@measured/puck 0.20.0-canary.33cf4f0e → 0.20.0-canary.3d781f5a
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/{chunk-IAEXMHQX.mjs → chunk-32MJ3X3H.mjs} +92 -6
- package/dist/chunk-5HI4IJHF.mjs +8858 -0
- package/dist/index.css +107 -46
- package/dist/index.d.mts +9 -8
- package/dist/index.d.ts +9 -8
- package/dist/index.js +1279 -901
- package/dist/index.mjs +27 -8460
- package/dist/no-external.css +1811 -0
- package/dist/no-external.d.mts +4 -2
- package/dist/no-external.d.ts +4 -2
- package/dist/no-external.js +9708 -1
- package/dist/no-external.mjs +50 -2
- package/dist/rsc.d.mts +2 -2
- package/dist/rsc.d.ts +2 -2
- package/dist/rsc.mjs +2 -4
- package/dist/{walk-tree-6p9XnDIV.d.mts → walk-tree-mCPqBAls.d.mts} +19 -4
- package/dist/{walk-tree-6p9XnDIV.d.ts → walk-tree-mCPqBAls.d.ts} +19 -4
- package/package.json +1 -1
- package/dist/chunk-M6W7YEVX.mjs +0 -95
package/dist/index.js
CHANGED
|
@@ -171,6 +171,7 @@ __export(bundle_exports, {
|
|
|
171
171
|
createUsePuck: () => createUsePuck,
|
|
172
172
|
migrate: () => migrate,
|
|
173
173
|
overrideKeys: () => overrideKeys,
|
|
174
|
+
registerOverlayPortal: () => registerOverlayPortal,
|
|
174
175
|
renderContext: () => renderContext,
|
|
175
176
|
resolveAllData: () => resolveAllData,
|
|
176
177
|
transformProps: () => transformProps,
|
|
@@ -203,8 +204,9 @@ var overrideKeys = [
|
|
|
203
204
|
"headerActions",
|
|
204
205
|
"fields",
|
|
205
206
|
"fieldLabel",
|
|
206
|
-
"
|
|
207
|
-
"
|
|
207
|
+
"drawer",
|
|
208
|
+
"drawerItem",
|
|
209
|
+
"componentOverlay",
|
|
208
210
|
"outline",
|
|
209
211
|
"puck",
|
|
210
212
|
"preview"
|
|
@@ -309,7 +311,7 @@ init_react_import();
|
|
|
309
311
|
var styles_module_default2 = { "InputWrapper": "_InputWrapper_py9hf_1", "Input-label": "_Input-label_py9hf_5", "Input-labelIcon": "_Input-labelIcon_py9hf_14", "Input-disabledIcon": "_Input-disabledIcon_py9hf_21", "Input-input": "_Input-input_py9hf_26", "Input": "_Input_py9hf_1", "Input--readOnly": "_Input--readOnly_py9hf_76", "Input-radioGroupItems": "_Input-radioGroupItems_py9hf_87", "Input-radio": "_Input-radio_py9hf_87", "Input-radioInner": "_Input-radioInner_py9hf_104", "Input-radioInput": "_Input-radioInput_py9hf_149" };
|
|
310
312
|
|
|
311
313
|
// components/AutoField/index.tsx
|
|
312
|
-
var
|
|
314
|
+
var import_react21 = require("react");
|
|
313
315
|
|
|
314
316
|
// components/AutoField/fields/index.tsx
|
|
315
317
|
init_react_import();
|
|
@@ -653,7 +655,7 @@ init_react_import();
|
|
|
653
655
|
|
|
654
656
|
// components/IconButton/IconButton.tsx
|
|
655
657
|
init_react_import();
|
|
656
|
-
var
|
|
658
|
+
var import_react10 = require("react");
|
|
657
659
|
|
|
658
660
|
// css-module:/home/runner/work/puck/puck/packages/core/components/IconButton/IconButton.module.css#css-module
|
|
659
661
|
init_react_import();
|
|
@@ -686,102 +688,9 @@ var replace = (list, index, newItem) => {
|
|
|
686
688
|
return result;
|
|
687
689
|
};
|
|
688
690
|
|
|
689
|
-
//
|
|
690
|
-
init_react_import();
|
|
691
|
-
var styles_module_default4 = { "Loader": "_Loader_nacdm_13", "loader-animation": "_loader-animation_nacdm_1" };
|
|
692
|
-
|
|
693
|
-
// components/Loader/index.tsx
|
|
694
|
-
var import_jsx_runtime2 = require("react/jsx-runtime");
|
|
695
|
-
var getClassName2 = get_class_name_factory_default("Loader", styles_module_default4);
|
|
696
|
-
var Loader = (_a) => {
|
|
697
|
-
var _b = _a, {
|
|
698
|
-
color,
|
|
699
|
-
size = 16
|
|
700
|
-
} = _b, props = __objRest(_b, [
|
|
701
|
-
"color",
|
|
702
|
-
"size"
|
|
703
|
-
]);
|
|
704
|
-
return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
705
|
-
"span",
|
|
706
|
-
__spreadValues({
|
|
707
|
-
className: getClassName2(),
|
|
708
|
-
style: {
|
|
709
|
-
width: size,
|
|
710
|
-
height: size,
|
|
711
|
-
color
|
|
712
|
-
},
|
|
713
|
-
"aria-label": "loading"
|
|
714
|
-
}, props)
|
|
715
|
-
);
|
|
716
|
-
};
|
|
717
|
-
|
|
718
|
-
// components/IconButton/IconButton.tsx
|
|
719
|
-
var import_jsx_runtime3 = require("react/jsx-runtime");
|
|
720
|
-
var getClassName3 = get_class_name_factory_default("IconButton", IconButton_module_default);
|
|
721
|
-
var IconButton = ({
|
|
722
|
-
children,
|
|
723
|
-
href,
|
|
724
|
-
onClick,
|
|
725
|
-
variant = "primary",
|
|
726
|
-
type,
|
|
727
|
-
disabled,
|
|
728
|
-
tabIndex,
|
|
729
|
-
newTab,
|
|
730
|
-
fullWidth,
|
|
731
|
-
title
|
|
732
|
-
}) => {
|
|
733
|
-
const [loading, setLoading] = (0, import_react4.useState)(false);
|
|
734
|
-
const ElementType = href ? "a" : "button";
|
|
735
|
-
const el = /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(
|
|
736
|
-
ElementType,
|
|
737
|
-
{
|
|
738
|
-
className: getClassName3({
|
|
739
|
-
primary: variant === "primary",
|
|
740
|
-
secondary: variant === "secondary",
|
|
741
|
-
disabled,
|
|
742
|
-
fullWidth
|
|
743
|
-
}),
|
|
744
|
-
onClick: (e) => {
|
|
745
|
-
if (!onClick) return;
|
|
746
|
-
setLoading(true);
|
|
747
|
-
Promise.resolve(onClick(e)).then(() => {
|
|
748
|
-
setLoading(false);
|
|
749
|
-
});
|
|
750
|
-
},
|
|
751
|
-
type,
|
|
752
|
-
disabled: disabled || loading,
|
|
753
|
-
tabIndex,
|
|
754
|
-
target: newTab ? "_blank" : void 0,
|
|
755
|
-
rel: newTab ? "noreferrer" : void 0,
|
|
756
|
-
href,
|
|
757
|
-
title,
|
|
758
|
-
children: [
|
|
759
|
-
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("span", { className: getClassName3("title"), children: title }),
|
|
760
|
-
children,
|
|
761
|
-
loading && /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(import_jsx_runtime3.Fragment, { children: [
|
|
762
|
-
"\xA0\xA0",
|
|
763
|
-
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)(Loader, { size: 14 })
|
|
764
|
-
] })
|
|
765
|
-
]
|
|
766
|
-
}
|
|
767
|
-
);
|
|
768
|
-
return el;
|
|
769
|
-
};
|
|
770
|
-
|
|
771
|
-
// components/AutoField/fields/ArrayField/index.tsx
|
|
772
|
-
var import_react14 = require("react");
|
|
773
|
-
|
|
774
|
-
// components/DragIcon/index.tsx
|
|
775
|
-
init_react_import();
|
|
776
|
-
|
|
777
|
-
// css-module:/home/runner/work/puck/puck/packages/core/components/DragIcon/styles.module.css#css-module
|
|
691
|
+
// lib/use-reset-auto-zoom.ts
|
|
778
692
|
init_react_import();
|
|
779
|
-
var
|
|
780
|
-
|
|
781
|
-
// components/DragIcon/index.tsx
|
|
782
|
-
var import_jsx_runtime4 = require("react/jsx-runtime");
|
|
783
|
-
var getClassName4 = get_class_name_factory_default("DragIcon", styles_module_default5);
|
|
784
|
-
var DragIcon = ({ isDragDisabled }) => /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("div", { className: getClassName4({ disabled: isDragDisabled }), children: /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("svg", { viewBox: "0 0 20 20", width: "12", fill: "currentColor", children: /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("path", { d: "M7 2a2 2 0 1 0 .001 4.001A2 2 0 0 0 7 2zm0 6a2 2 0 1 0 .001 4.001A2 2 0 0 0 7 8zm0 6a2 2 0 1 0 .001 4.001A2 2 0 0 0 7 14zm6-8a2 2 0 1 0-.001-4.001A2 2 0 0 0 13 6zm0 2a2 2 0 1 0 .001 4.001A2 2 0 0 0 13 8zm0 6a2 2 0 1 0 .001 4.001A2 2 0 0 0 13 14z" }) }) });
|
|
693
|
+
var import_react9 = require("react");
|
|
785
694
|
|
|
786
695
|
// store/index.ts
|
|
787
696
|
init_react_import();
|
|
@@ -1684,15 +1593,15 @@ var defaultViewports = [
|
|
|
1684
1593
|
// store/index.ts
|
|
1685
1594
|
var import_zustand2 = require("zustand");
|
|
1686
1595
|
var import_middleware2 = require("zustand/middleware");
|
|
1687
|
-
var
|
|
1596
|
+
var import_react8 = require("react");
|
|
1688
1597
|
|
|
1689
1598
|
// store/slices/history.ts
|
|
1690
1599
|
init_react_import();
|
|
1691
|
-
var
|
|
1600
|
+
var import_react5 = require("react");
|
|
1692
1601
|
|
|
1693
1602
|
// lib/use-hotkey.ts
|
|
1694
1603
|
init_react_import();
|
|
1695
|
-
var
|
|
1604
|
+
var import_react4 = require("react");
|
|
1696
1605
|
var import_zustand = require("zustand");
|
|
1697
1606
|
var import_middleware = require("zustand/middleware");
|
|
1698
1607
|
var keyCodeMap = {
|
|
@@ -1785,10 +1694,10 @@ var monitorHotkeys = (doc) => {
|
|
|
1785
1694
|
};
|
|
1786
1695
|
};
|
|
1787
1696
|
var useMonitorHotkeys = () => {
|
|
1788
|
-
(0,
|
|
1697
|
+
(0, import_react4.useEffect)(() => monitorHotkeys(document), []);
|
|
1789
1698
|
};
|
|
1790
1699
|
var useHotkey = (combo, cb) => {
|
|
1791
|
-
(0,
|
|
1700
|
+
(0, import_react4.useEffect)(
|
|
1792
1701
|
() => useHotkeyStore.setState((s) => ({
|
|
1793
1702
|
triggers: __spreadProps(__spreadValues({}, s.triggers), {
|
|
1794
1703
|
[`${Object.keys(combo).join("+")}`]: { combo, cb }
|
|
@@ -1897,7 +1806,7 @@ function useRegisterHistorySlice(appStore, {
|
|
|
1897
1806
|
index,
|
|
1898
1807
|
initialAppState
|
|
1899
1808
|
}) {
|
|
1900
|
-
(0,
|
|
1809
|
+
(0, import_react5.useEffect)(
|
|
1901
1810
|
() => appStore.setState({
|
|
1902
1811
|
history: __spreadProps(__spreadValues({}, appStore.getState().history), {
|
|
1903
1812
|
histories,
|
|
@@ -1964,7 +1873,7 @@ var createNodesSlice = (set, get) => ({
|
|
|
1964
1873
|
|
|
1965
1874
|
// store/slices/permissions.ts
|
|
1966
1875
|
init_react_import();
|
|
1967
|
-
var
|
|
1876
|
+
var import_react6 = require("react");
|
|
1968
1877
|
|
|
1969
1878
|
// lib/data/flatten-data.ts
|
|
1970
1879
|
init_react_import();
|
|
@@ -2101,7 +2010,7 @@ var createPermissionsSlice = (set, get) => {
|
|
|
2101
2010
|
};
|
|
2102
2011
|
};
|
|
2103
2012
|
var useRegisterPermissionsSlice = (appStore, globalPermissions) => {
|
|
2104
|
-
(0,
|
|
2013
|
+
(0, import_react6.useEffect)(() => {
|
|
2105
2014
|
const { permissions } = appStore.getState();
|
|
2106
2015
|
const { globalPermissions: existingGlobalPermissions } = permissions;
|
|
2107
2016
|
appStore.setState({
|
|
@@ -2111,7 +2020,7 @@ var useRegisterPermissionsSlice = (appStore, globalPermissions) => {
|
|
|
2111
2020
|
});
|
|
2112
2021
|
permissions.resolvePermissions();
|
|
2113
2022
|
}, [globalPermissions]);
|
|
2114
|
-
(0,
|
|
2023
|
+
(0, import_react6.useEffect)(() => {
|
|
2115
2024
|
return appStore.subscribe(
|
|
2116
2025
|
(s) => s.state.data,
|
|
2117
2026
|
() => {
|
|
@@ -2119,7 +2028,7 @@ var useRegisterPermissionsSlice = (appStore, globalPermissions) => {
|
|
|
2119
2028
|
}
|
|
2120
2029
|
);
|
|
2121
2030
|
}, []);
|
|
2122
|
-
(0,
|
|
2031
|
+
(0, import_react6.useEffect)(() => {
|
|
2123
2032
|
return appStore.subscribe(
|
|
2124
2033
|
(s) => s.config,
|
|
2125
2034
|
() => {
|
|
@@ -2131,7 +2040,7 @@ var useRegisterPermissionsSlice = (appStore, globalPermissions) => {
|
|
|
2131
2040
|
|
|
2132
2041
|
// store/slices/fields.ts
|
|
2133
2042
|
init_react_import();
|
|
2134
|
-
var
|
|
2043
|
+
var import_react7 = require("react");
|
|
2135
2044
|
var createFieldsSlice = (_set, _get) => {
|
|
2136
2045
|
return {
|
|
2137
2046
|
fields: {},
|
|
@@ -2141,7 +2050,7 @@ var createFieldsSlice = (_set, _get) => {
|
|
|
2141
2050
|
};
|
|
2142
2051
|
};
|
|
2143
2052
|
var useRegisterFieldsSlice = (appStore, id) => {
|
|
2144
|
-
const resolveFields = (0,
|
|
2053
|
+
const resolveFields = (0, import_react7.useCallback)(
|
|
2145
2054
|
(reset) => __async(void 0, null, function* () {
|
|
2146
2055
|
var _a, _b;
|
|
2147
2056
|
const { fields, lastResolvedData } = appStore.getState().fields;
|
|
@@ -2198,7 +2107,7 @@ var useRegisterFieldsSlice = (appStore, id) => {
|
|
|
2198
2107
|
}),
|
|
2199
2108
|
[id]
|
|
2200
2109
|
);
|
|
2201
|
-
(0,
|
|
2110
|
+
(0, import_react7.useEffect)(() => {
|
|
2202
2111
|
resolveFields(true);
|
|
2203
2112
|
return appStore.subscribe(
|
|
2204
2113
|
(s) => s.state.indexes.nodes[id || "root"],
|
|
@@ -2490,133 +2399,435 @@ var createAppStore = (initialAppStore) => (0, import_zustand2.create)()(
|
|
|
2490
2399
|
});
|
|
2491
2400
|
})
|
|
2492
2401
|
);
|
|
2493
|
-
var appStoreContext = (0,
|
|
2402
|
+
var appStoreContext = (0, import_react8.createContext)(createAppStore());
|
|
2494
2403
|
function useAppStore(selector) {
|
|
2495
|
-
const context = (0,
|
|
2404
|
+
const context = (0, import_react8.useContext)(appStoreContext);
|
|
2496
2405
|
return (0, import_zustand2.useStore)(context, selector);
|
|
2497
2406
|
}
|
|
2498
2407
|
function useAppStoreApi() {
|
|
2499
|
-
return (0,
|
|
2408
|
+
return (0, import_react8.useContext)(appStoreContext);
|
|
2500
2409
|
}
|
|
2501
2410
|
|
|
2502
|
-
//
|
|
2503
|
-
init_react_import();
|
|
2504
|
-
var import_react12 = require("@dnd-kit/react");
|
|
2505
|
-
|
|
2506
|
-
// lib/dnd/use-sensors.ts
|
|
2411
|
+
// lib/get-zoom-config.ts
|
|
2507
2412
|
init_react_import();
|
|
2508
|
-
var import_react10 = require("react");
|
|
2509
|
-
var import_react11 = require("@dnd-kit/react");
|
|
2510
|
-
var import_utilities = require("@dnd-kit/dom/utilities");
|
|
2511
|
-
var touchDefault = { delay: { value: 200, tolerance: 10 } };
|
|
2512
|
-
var otherDefault = {
|
|
2513
|
-
delay: { value: 200, tolerance: 10 },
|
|
2514
|
-
distance: { value: 5 }
|
|
2515
|
-
};
|
|
2516
|
-
var useSensors = ({
|
|
2517
|
-
other = otherDefault,
|
|
2518
|
-
mouse,
|
|
2519
|
-
touch = touchDefault
|
|
2520
|
-
} = {
|
|
2521
|
-
touch: touchDefault,
|
|
2522
|
-
other: otherDefault
|
|
2523
|
-
}) => {
|
|
2524
|
-
const [sensors] = (0, import_react10.useState)(() => [
|
|
2525
|
-
import_react11.PointerSensor.configure({
|
|
2526
|
-
activationConstraints(event, source) {
|
|
2527
|
-
var _a;
|
|
2528
|
-
const { pointerType, target } = event;
|
|
2529
|
-
if (pointerType === "mouse" && (0, import_utilities.isElement)(target) && (source.handle === target || ((_a = source.handle) == null ? void 0 : _a.contains(target)))) {
|
|
2530
|
-
return mouse;
|
|
2531
|
-
}
|
|
2532
|
-
if (pointerType === "touch") {
|
|
2533
|
-
return touch;
|
|
2534
|
-
}
|
|
2535
|
-
return other;
|
|
2536
|
-
}
|
|
2537
|
-
})
|
|
2538
|
-
]);
|
|
2539
|
-
return sensors;
|
|
2540
|
-
};
|
|
2541
2413
|
|
|
2542
|
-
//
|
|
2414
|
+
// ../../node_modules/css-box-model/dist/css-box-model.esm.js
|
|
2543
2415
|
init_react_import();
|
|
2544
|
-
var import_abstract8 = require("@dnd-kit/abstract");
|
|
2545
2416
|
|
|
2546
|
-
//
|
|
2417
|
+
// ../../node_modules/tiny-invariant/dist/esm/tiny-invariant.js
|
|
2547
2418
|
init_react_import();
|
|
2548
|
-
var
|
|
2419
|
+
var isProduction = process.env.NODE_ENV === "production";
|
|
2420
|
+
var prefix = "Invariant failed";
|
|
2421
|
+
function invariant(condition, message) {
|
|
2422
|
+
if (condition) {
|
|
2423
|
+
return;
|
|
2424
|
+
}
|
|
2425
|
+
if (isProduction) {
|
|
2426
|
+
throw new Error(prefix);
|
|
2427
|
+
}
|
|
2428
|
+
var provided = typeof message === "function" ? message() : message;
|
|
2429
|
+
var value = provided ? "".concat(prefix, ": ").concat(provided) : prefix;
|
|
2430
|
+
throw new Error(value);
|
|
2431
|
+
}
|
|
2549
2432
|
|
|
2550
|
-
//
|
|
2551
|
-
|
|
2552
|
-
var
|
|
2553
|
-
var
|
|
2554
|
-
var
|
|
2555
|
-
var
|
|
2556
|
-
|
|
2557
|
-
|
|
2558
|
-
|
|
2559
|
-
|
|
2560
|
-
|
|
2561
|
-
|
|
2562
|
-
|
|
2563
|
-
|
|
2564
|
-
|
|
2565
|
-
|
|
2566
|
-
|
|
2567
|
-
const existingEl = debugElements[debugId];
|
|
2568
|
-
let line = (_a = debugElements[debugId]) == null ? void 0 : _a.line;
|
|
2569
|
-
let text = (_b = debugElements[debugId]) == null ? void 0 : _b.text;
|
|
2570
|
-
if (!existingEl) {
|
|
2571
|
-
const svgNs = "http://www.w3.org/2000/svg";
|
|
2572
|
-
const svg = document.createElementNS(svgNs, "svg");
|
|
2573
|
-
line = document.createElementNS(svgNs, "line");
|
|
2574
|
-
text = document.createElementNS(svgNs, "text");
|
|
2575
|
-
svg.setAttribute("id", debugId);
|
|
2576
|
-
svg.setAttribute(
|
|
2577
|
-
"style",
|
|
2578
|
-
"position: fixed; height: 100%; width: 100%; pointer-events: none; top: 0px; left: 0px;"
|
|
2579
|
-
);
|
|
2580
|
-
svg.appendChild(line);
|
|
2581
|
-
svg.appendChild(text);
|
|
2582
|
-
text.setAttribute("fill", `black`);
|
|
2583
|
-
document.body.appendChild(svg);
|
|
2584
|
-
debugElements[debugId] = { svg, line, text };
|
|
2585
|
-
}
|
|
2586
|
-
line.setAttribute("x1", a.x.toString());
|
|
2587
|
-
line.setAttribute("x2", b.x.toString());
|
|
2588
|
-
line.setAttribute("y1", a.y.toString());
|
|
2589
|
-
line.setAttribute("y2", b.y.toString());
|
|
2590
|
-
line.setAttribute("style", `stroke:${color};stroke-width:2`);
|
|
2591
|
-
text.setAttribute("x", (a.x - (a.x - b.x) / 2).toString());
|
|
2592
|
-
text.setAttribute("y", (a.y - (a.y - b.y) / 2).toString());
|
|
2593
|
-
if (label) {
|
|
2594
|
-
text.innerHTML = label;
|
|
2433
|
+
// ../../node_modules/css-box-model/dist/css-box-model.esm.js
|
|
2434
|
+
var getRect = function getRect2(_ref) {
|
|
2435
|
+
var top = _ref.top, right = _ref.right, bottom = _ref.bottom, left = _ref.left;
|
|
2436
|
+
var width = right - left;
|
|
2437
|
+
var height = bottom - top;
|
|
2438
|
+
var rect = {
|
|
2439
|
+
top,
|
|
2440
|
+
right,
|
|
2441
|
+
bottom,
|
|
2442
|
+
left,
|
|
2443
|
+
width,
|
|
2444
|
+
height,
|
|
2445
|
+
x: left,
|
|
2446
|
+
y: top,
|
|
2447
|
+
center: {
|
|
2448
|
+
x: (right + left) / 2,
|
|
2449
|
+
y: (bottom + top) / 2
|
|
2595
2450
|
}
|
|
2596
|
-
}
|
|
2451
|
+
};
|
|
2452
|
+
return rect;
|
|
2597
2453
|
};
|
|
2598
|
-
|
|
2599
|
-
|
|
2600
|
-
|
|
2601
|
-
|
|
2602
|
-
|
|
2603
|
-
|
|
2604
|
-
|
|
2605
|
-
|
|
2606
|
-
|
|
2607
|
-
|
|
2608
|
-
|
|
2609
|
-
|
|
2610
|
-
|
|
2611
|
-
|
|
2612
|
-
|
|
2613
|
-
|
|
2614
|
-
|
|
2615
|
-
|
|
2616
|
-
|
|
2617
|
-
|
|
2618
|
-
|
|
2619
|
-
|
|
2454
|
+
var expand = function expand2(target, expandBy) {
|
|
2455
|
+
return {
|
|
2456
|
+
top: target.top - expandBy.top,
|
|
2457
|
+
left: target.left - expandBy.left,
|
|
2458
|
+
bottom: target.bottom + expandBy.bottom,
|
|
2459
|
+
right: target.right + expandBy.right
|
|
2460
|
+
};
|
|
2461
|
+
};
|
|
2462
|
+
var shrink = function shrink2(target, shrinkBy) {
|
|
2463
|
+
return {
|
|
2464
|
+
top: target.top + shrinkBy.top,
|
|
2465
|
+
left: target.left + shrinkBy.left,
|
|
2466
|
+
bottom: target.bottom - shrinkBy.bottom,
|
|
2467
|
+
right: target.right - shrinkBy.right
|
|
2468
|
+
};
|
|
2469
|
+
};
|
|
2470
|
+
var noSpacing = {
|
|
2471
|
+
top: 0,
|
|
2472
|
+
right: 0,
|
|
2473
|
+
bottom: 0,
|
|
2474
|
+
left: 0
|
|
2475
|
+
};
|
|
2476
|
+
var createBox = function createBox2(_ref2) {
|
|
2477
|
+
var borderBox = _ref2.borderBox, _ref2$margin = _ref2.margin, margin = _ref2$margin === void 0 ? noSpacing : _ref2$margin, _ref2$border = _ref2.border, border = _ref2$border === void 0 ? noSpacing : _ref2$border, _ref2$padding = _ref2.padding, padding = _ref2$padding === void 0 ? noSpacing : _ref2$padding;
|
|
2478
|
+
var marginBox = getRect(expand(borderBox, margin));
|
|
2479
|
+
var paddingBox = getRect(shrink(borderBox, border));
|
|
2480
|
+
var contentBox = getRect(shrink(paddingBox, padding));
|
|
2481
|
+
return {
|
|
2482
|
+
marginBox,
|
|
2483
|
+
borderBox: getRect(borderBox),
|
|
2484
|
+
paddingBox,
|
|
2485
|
+
contentBox,
|
|
2486
|
+
margin,
|
|
2487
|
+
border,
|
|
2488
|
+
padding
|
|
2489
|
+
};
|
|
2490
|
+
};
|
|
2491
|
+
var parse = function parse2(raw) {
|
|
2492
|
+
var value = raw.slice(0, -2);
|
|
2493
|
+
var suffix = raw.slice(-2);
|
|
2494
|
+
if (suffix !== "px") {
|
|
2495
|
+
return 0;
|
|
2496
|
+
}
|
|
2497
|
+
var result = Number(value);
|
|
2498
|
+
!!isNaN(result) ? process.env.NODE_ENV !== "production" ? invariant(false, "Could not parse value [raw: " + raw + ", without suffix: " + value + "]") : invariant(false) : void 0;
|
|
2499
|
+
return result;
|
|
2500
|
+
};
|
|
2501
|
+
var calculateBox = function calculateBox2(borderBox, styles2) {
|
|
2502
|
+
var margin = {
|
|
2503
|
+
top: parse(styles2.marginTop),
|
|
2504
|
+
right: parse(styles2.marginRight),
|
|
2505
|
+
bottom: parse(styles2.marginBottom),
|
|
2506
|
+
left: parse(styles2.marginLeft)
|
|
2507
|
+
};
|
|
2508
|
+
var padding = {
|
|
2509
|
+
top: parse(styles2.paddingTop),
|
|
2510
|
+
right: parse(styles2.paddingRight),
|
|
2511
|
+
bottom: parse(styles2.paddingBottom),
|
|
2512
|
+
left: parse(styles2.paddingLeft)
|
|
2513
|
+
};
|
|
2514
|
+
var border = {
|
|
2515
|
+
top: parse(styles2.borderTopWidth),
|
|
2516
|
+
right: parse(styles2.borderRightWidth),
|
|
2517
|
+
bottom: parse(styles2.borderBottomWidth),
|
|
2518
|
+
left: parse(styles2.borderLeftWidth)
|
|
2519
|
+
};
|
|
2520
|
+
return createBox({
|
|
2521
|
+
borderBox,
|
|
2522
|
+
margin,
|
|
2523
|
+
padding,
|
|
2524
|
+
border
|
|
2525
|
+
});
|
|
2526
|
+
};
|
|
2527
|
+
var getBox = function getBox2(el) {
|
|
2528
|
+
var borderBox = el.getBoundingClientRect();
|
|
2529
|
+
var styles2 = window.getComputedStyle(el);
|
|
2530
|
+
return calculateBox(borderBox, styles2);
|
|
2531
|
+
};
|
|
2532
|
+
|
|
2533
|
+
// lib/get-zoom-config.ts
|
|
2534
|
+
var RESET_ZOOM_SMALLER_THAN_FRAME = true;
|
|
2535
|
+
var getZoomConfig = (uiViewport, frame, zoom) => {
|
|
2536
|
+
const box = getBox(frame);
|
|
2537
|
+
const { width: frameWidth, height: frameHeight } = box.contentBox;
|
|
2538
|
+
const viewportHeight = uiViewport.height === "auto" ? frameHeight : uiViewport.height;
|
|
2539
|
+
let rootHeight = 0;
|
|
2540
|
+
let autoZoom = 1;
|
|
2541
|
+
if (uiViewport.width > frameWidth || viewportHeight > frameHeight) {
|
|
2542
|
+
const widthZoom = Math.min(frameWidth / uiViewport.width, 1);
|
|
2543
|
+
const heightZoom = Math.min(frameHeight / viewportHeight, 1);
|
|
2544
|
+
zoom = widthZoom;
|
|
2545
|
+
if (widthZoom < heightZoom) {
|
|
2546
|
+
rootHeight = viewportHeight / zoom;
|
|
2547
|
+
} else {
|
|
2548
|
+
rootHeight = viewportHeight;
|
|
2549
|
+
zoom = heightZoom;
|
|
2550
|
+
}
|
|
2551
|
+
autoZoom = zoom;
|
|
2552
|
+
} else {
|
|
2553
|
+
if (RESET_ZOOM_SMALLER_THAN_FRAME) {
|
|
2554
|
+
autoZoom = 1;
|
|
2555
|
+
zoom = 1;
|
|
2556
|
+
rootHeight = viewportHeight;
|
|
2557
|
+
}
|
|
2558
|
+
}
|
|
2559
|
+
return { autoZoom, rootHeight, zoom };
|
|
2560
|
+
};
|
|
2561
|
+
|
|
2562
|
+
// lib/use-reset-auto-zoom.ts
|
|
2563
|
+
var import_shallow = require("zustand/react/shallow");
|
|
2564
|
+
var useResetAutoZoom = (frameRef) => {
|
|
2565
|
+
const { viewports, zoomConfig, setZoomConfig } = useAppStore(
|
|
2566
|
+
(0, import_shallow.useShallow)((s) => ({
|
|
2567
|
+
viewports: s.state.ui.viewports,
|
|
2568
|
+
zoomConfig: s.zoomConfig,
|
|
2569
|
+
setZoomConfig: s.setZoomConfig
|
|
2570
|
+
}))
|
|
2571
|
+
);
|
|
2572
|
+
const resetAutoZoom = (0, import_react9.useCallback)(
|
|
2573
|
+
(options) => {
|
|
2574
|
+
const newViewports = (options == null ? void 0 : options.viewports) || viewports;
|
|
2575
|
+
if (!(options == null ? void 0 : options.isResettingRef)) {
|
|
2576
|
+
if (frameRef.current) {
|
|
2577
|
+
setZoomConfig(
|
|
2578
|
+
getZoomConfig(
|
|
2579
|
+
newViewports == null ? void 0 : newViewports.current,
|
|
2580
|
+
frameRef.current,
|
|
2581
|
+
zoomConfig.zoom
|
|
2582
|
+
)
|
|
2583
|
+
);
|
|
2584
|
+
}
|
|
2585
|
+
return;
|
|
2586
|
+
}
|
|
2587
|
+
const {
|
|
2588
|
+
isResettingRef,
|
|
2589
|
+
setShowTransition,
|
|
2590
|
+
showTransition = false
|
|
2591
|
+
} = options;
|
|
2592
|
+
if (!isResettingRef.current) {
|
|
2593
|
+
isResettingRef.current = true;
|
|
2594
|
+
if (setShowTransition) {
|
|
2595
|
+
setShowTransition(showTransition);
|
|
2596
|
+
}
|
|
2597
|
+
if (frameRef.current) {
|
|
2598
|
+
setZoomConfig(
|
|
2599
|
+
getZoomConfig(
|
|
2600
|
+
newViewports == null ? void 0 : newViewports.current,
|
|
2601
|
+
frameRef.current,
|
|
2602
|
+
zoomConfig.zoom
|
|
2603
|
+
)
|
|
2604
|
+
);
|
|
2605
|
+
}
|
|
2606
|
+
setTimeout(() => {
|
|
2607
|
+
isResettingRef.current = false;
|
|
2608
|
+
}, 0);
|
|
2609
|
+
}
|
|
2610
|
+
},
|
|
2611
|
+
[frameRef, zoomConfig, viewports, setZoomConfig]
|
|
2612
|
+
);
|
|
2613
|
+
return resetAutoZoom;
|
|
2614
|
+
};
|
|
2615
|
+
|
|
2616
|
+
// css-module:/home/runner/work/puck/puck/packages/core/components/Loader/styles.module.css#css-module
|
|
2617
|
+
init_react_import();
|
|
2618
|
+
var styles_module_default4 = { "Loader": "_Loader_nacdm_13", "loader-animation": "_loader-animation_nacdm_1" };
|
|
2619
|
+
|
|
2620
|
+
// components/Loader/index.tsx
|
|
2621
|
+
var import_jsx_runtime2 = require("react/jsx-runtime");
|
|
2622
|
+
var getClassName2 = get_class_name_factory_default("Loader", styles_module_default4);
|
|
2623
|
+
var Loader = (_a) => {
|
|
2624
|
+
var _b = _a, {
|
|
2625
|
+
color,
|
|
2626
|
+
size = 16
|
|
2627
|
+
} = _b, props = __objRest(_b, [
|
|
2628
|
+
"color",
|
|
2629
|
+
"size"
|
|
2630
|
+
]);
|
|
2631
|
+
return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
2632
|
+
"span",
|
|
2633
|
+
__spreadValues({
|
|
2634
|
+
className: getClassName2(),
|
|
2635
|
+
style: {
|
|
2636
|
+
width: size,
|
|
2637
|
+
height: size,
|
|
2638
|
+
color
|
|
2639
|
+
},
|
|
2640
|
+
"aria-label": "loading"
|
|
2641
|
+
}, props)
|
|
2642
|
+
);
|
|
2643
|
+
};
|
|
2644
|
+
|
|
2645
|
+
// components/IconButton/IconButton.tsx
|
|
2646
|
+
var import_jsx_runtime3 = require("react/jsx-runtime");
|
|
2647
|
+
var getClassName3 = get_class_name_factory_default("IconButton", IconButton_module_default);
|
|
2648
|
+
var IconButton = ({
|
|
2649
|
+
children,
|
|
2650
|
+
href,
|
|
2651
|
+
onClick,
|
|
2652
|
+
variant = "primary",
|
|
2653
|
+
type,
|
|
2654
|
+
disabled,
|
|
2655
|
+
tabIndex,
|
|
2656
|
+
newTab,
|
|
2657
|
+
fullWidth,
|
|
2658
|
+
title
|
|
2659
|
+
}) => {
|
|
2660
|
+
const [loading, setLoading] = (0, import_react10.useState)(false);
|
|
2661
|
+
const ElementType = href ? "a" : "button";
|
|
2662
|
+
const el = /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(
|
|
2663
|
+
ElementType,
|
|
2664
|
+
{
|
|
2665
|
+
className: getClassName3({
|
|
2666
|
+
primary: variant === "primary",
|
|
2667
|
+
secondary: variant === "secondary",
|
|
2668
|
+
disabled,
|
|
2669
|
+
fullWidth
|
|
2670
|
+
}),
|
|
2671
|
+
onClick: (e) => {
|
|
2672
|
+
if (!onClick) return;
|
|
2673
|
+
setLoading(true);
|
|
2674
|
+
Promise.resolve(onClick(e)).then(() => {
|
|
2675
|
+
setLoading(false);
|
|
2676
|
+
});
|
|
2677
|
+
},
|
|
2678
|
+
type,
|
|
2679
|
+
disabled: disabled || loading,
|
|
2680
|
+
tabIndex,
|
|
2681
|
+
target: newTab ? "_blank" : void 0,
|
|
2682
|
+
rel: newTab ? "noreferrer" : void 0,
|
|
2683
|
+
href,
|
|
2684
|
+
title,
|
|
2685
|
+
children: [
|
|
2686
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("span", { className: getClassName3("title"), children: title }),
|
|
2687
|
+
children,
|
|
2688
|
+
loading && /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(import_jsx_runtime3.Fragment, { children: [
|
|
2689
|
+
"\xA0\xA0",
|
|
2690
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)(Loader, { size: 14 })
|
|
2691
|
+
] })
|
|
2692
|
+
]
|
|
2693
|
+
}
|
|
2694
|
+
);
|
|
2695
|
+
return el;
|
|
2696
|
+
};
|
|
2697
|
+
|
|
2698
|
+
// components/AutoField/fields/ArrayField/index.tsx
|
|
2699
|
+
var import_react15 = require("react");
|
|
2700
|
+
|
|
2701
|
+
// components/DragIcon/index.tsx
|
|
2702
|
+
init_react_import();
|
|
2703
|
+
|
|
2704
|
+
// css-module:/home/runner/work/puck/puck/packages/core/components/DragIcon/styles.module.css#css-module
|
|
2705
|
+
init_react_import();
|
|
2706
|
+
var styles_module_default5 = { "DragIcon": "_DragIcon_17p8x_1", "DragIcon--disabled": "_DragIcon--disabled_17p8x_8" };
|
|
2707
|
+
|
|
2708
|
+
// components/DragIcon/index.tsx
|
|
2709
|
+
var import_jsx_runtime4 = require("react/jsx-runtime");
|
|
2710
|
+
var getClassName4 = get_class_name_factory_default("DragIcon", styles_module_default5);
|
|
2711
|
+
var DragIcon = ({ isDragDisabled }) => /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("div", { className: getClassName4({ disabled: isDragDisabled }), children: /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("svg", { viewBox: "0 0 20 20", width: "12", fill: "currentColor", children: /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("path", { d: "M7 2a2 2 0 1 0 .001 4.001A2 2 0 0 0 7 2zm0 6a2 2 0 1 0 .001 4.001A2 2 0 0 0 7 8zm0 6a2 2 0 1 0 .001 4.001A2 2 0 0 0 7 14zm6-8a2 2 0 1 0-.001-4.001A2 2 0 0 0 13 6zm0 2a2 2 0 1 0 .001 4.001A2 2 0 0 0 13 8zm0 6a2 2 0 1 0 .001 4.001A2 2 0 0 0 13 14z" }) }) });
|
|
2712
|
+
|
|
2713
|
+
// components/Sortable/index.tsx
|
|
2714
|
+
init_react_import();
|
|
2715
|
+
var import_react13 = require("@dnd-kit/react");
|
|
2716
|
+
|
|
2717
|
+
// lib/dnd/use-sensors.ts
|
|
2718
|
+
init_react_import();
|
|
2719
|
+
var import_react11 = require("react");
|
|
2720
|
+
var import_react12 = require("@dnd-kit/react");
|
|
2721
|
+
var import_utilities = require("@dnd-kit/dom/utilities");
|
|
2722
|
+
var touchDefault = { delay: { value: 200, tolerance: 10 } };
|
|
2723
|
+
var otherDefault = {
|
|
2724
|
+
delay: { value: 200, tolerance: 10 },
|
|
2725
|
+
distance: { value: 5 }
|
|
2726
|
+
};
|
|
2727
|
+
var useSensors = ({
|
|
2728
|
+
other = otherDefault,
|
|
2729
|
+
mouse,
|
|
2730
|
+
touch = touchDefault
|
|
2731
|
+
} = {
|
|
2732
|
+
touch: touchDefault,
|
|
2733
|
+
other: otherDefault
|
|
2734
|
+
}) => {
|
|
2735
|
+
const [sensors] = (0, import_react11.useState)(() => [
|
|
2736
|
+
import_react12.PointerSensor.configure({
|
|
2737
|
+
activationConstraints(event, source) {
|
|
2738
|
+
var _a;
|
|
2739
|
+
const { pointerType, target } = event;
|
|
2740
|
+
if (pointerType === "mouse" && (0, import_utilities.isElement)(target) && (source.handle === target || ((_a = source.handle) == null ? void 0 : _a.contains(target)))) {
|
|
2741
|
+
return mouse;
|
|
2742
|
+
}
|
|
2743
|
+
if (pointerType === "touch") {
|
|
2744
|
+
return touch;
|
|
2745
|
+
}
|
|
2746
|
+
return other;
|
|
2747
|
+
}
|
|
2748
|
+
})
|
|
2749
|
+
]);
|
|
2750
|
+
return sensors;
|
|
2751
|
+
};
|
|
2752
|
+
|
|
2753
|
+
// lib/dnd/collision/dynamic/index.ts
|
|
2754
|
+
init_react_import();
|
|
2755
|
+
var import_abstract8 = require("@dnd-kit/abstract");
|
|
2756
|
+
|
|
2757
|
+
// lib/dnd/collision/directional/index.ts
|
|
2758
|
+
init_react_import();
|
|
2759
|
+
var import_abstract = require("@dnd-kit/abstract");
|
|
2760
|
+
|
|
2761
|
+
// lib/dnd/collision/collision-debug.ts
|
|
2762
|
+
init_react_import();
|
|
2763
|
+
var DEBUG = false;
|
|
2764
|
+
var debugElements = {};
|
|
2765
|
+
var timeout;
|
|
2766
|
+
var collisionDebug = (a, b, id, color, label) => {
|
|
2767
|
+
if (!DEBUG) return;
|
|
2768
|
+
const debugId = `${id}-debug`;
|
|
2769
|
+
clearTimeout(timeout);
|
|
2770
|
+
timeout = setTimeout(() => {
|
|
2771
|
+
Object.entries(debugElements).forEach(([id2, { svg }]) => {
|
|
2772
|
+
svg.remove();
|
|
2773
|
+
delete debugElements[id2];
|
|
2774
|
+
});
|
|
2775
|
+
}, 1e3);
|
|
2776
|
+
requestAnimationFrame(() => {
|
|
2777
|
+
var _a, _b;
|
|
2778
|
+
const existingEl = debugElements[debugId];
|
|
2779
|
+
let line = (_a = debugElements[debugId]) == null ? void 0 : _a.line;
|
|
2780
|
+
let text = (_b = debugElements[debugId]) == null ? void 0 : _b.text;
|
|
2781
|
+
if (!existingEl) {
|
|
2782
|
+
const svgNs = "http://www.w3.org/2000/svg";
|
|
2783
|
+
const svg = document.createElementNS(svgNs, "svg");
|
|
2784
|
+
line = document.createElementNS(svgNs, "line");
|
|
2785
|
+
text = document.createElementNS(svgNs, "text");
|
|
2786
|
+
svg.setAttribute("id", debugId);
|
|
2787
|
+
svg.setAttribute(
|
|
2788
|
+
"style",
|
|
2789
|
+
"position: fixed; height: 100%; width: 100%; pointer-events: none; top: 0px; left: 0px;"
|
|
2790
|
+
);
|
|
2791
|
+
svg.appendChild(line);
|
|
2792
|
+
svg.appendChild(text);
|
|
2793
|
+
text.setAttribute("fill", `black`);
|
|
2794
|
+
document.body.appendChild(svg);
|
|
2795
|
+
debugElements[debugId] = { svg, line, text };
|
|
2796
|
+
}
|
|
2797
|
+
line.setAttribute("x1", a.x.toString());
|
|
2798
|
+
line.setAttribute("x2", b.x.toString());
|
|
2799
|
+
line.setAttribute("y1", a.y.toString());
|
|
2800
|
+
line.setAttribute("y2", b.y.toString());
|
|
2801
|
+
line.setAttribute("style", `stroke:${color};stroke-width:2`);
|
|
2802
|
+
text.setAttribute("x", (a.x - (a.x - b.x) / 2).toString());
|
|
2803
|
+
text.setAttribute("y", (a.y - (a.y - b.y) / 2).toString());
|
|
2804
|
+
if (label) {
|
|
2805
|
+
text.innerHTML = label;
|
|
2806
|
+
}
|
|
2807
|
+
});
|
|
2808
|
+
};
|
|
2809
|
+
|
|
2810
|
+
// lib/dnd/collision/directional/index.ts
|
|
2811
|
+
var distanceChange = "increasing";
|
|
2812
|
+
var directionalCollision = (input, previous) => {
|
|
2813
|
+
var _a;
|
|
2814
|
+
const { dragOperation, droppable } = input;
|
|
2815
|
+
const { shape: dropShape } = droppable;
|
|
2816
|
+
const { position } = dragOperation;
|
|
2817
|
+
const dragShape = (_a = dragOperation.shape) == null ? void 0 : _a.current;
|
|
2818
|
+
if (!dragShape || !dropShape) return null;
|
|
2819
|
+
const dropCenter = dropShape.center;
|
|
2820
|
+
const distanceToPrevious = Math.sqrt(
|
|
2821
|
+
Math.pow(dropCenter.x - previous.x, 2) + Math.pow(dropCenter.y - previous.y, 2)
|
|
2822
|
+
);
|
|
2823
|
+
const distanceToCurrent = Math.sqrt(
|
|
2824
|
+
Math.pow(dropCenter.x - position.current.x, 2) + Math.pow(dropCenter.y - position.current.y, 2)
|
|
2825
|
+
);
|
|
2826
|
+
distanceChange = distanceToCurrent === distanceToPrevious ? distanceChange : distanceToCurrent < distanceToPrevious ? "decreasing" : "increasing";
|
|
2827
|
+
collisionDebug(
|
|
2828
|
+
dragShape.center,
|
|
2829
|
+
dropCenter,
|
|
2830
|
+
droppable.id.toString(),
|
|
2620
2831
|
"rebeccapurple"
|
|
2621
2832
|
);
|
|
2622
2833
|
if (distanceChange === "decreasing") {
|
|
@@ -2868,7 +3079,7 @@ var SortableProvider = ({
|
|
|
2868
3079
|
mouse: { distance: { value: 5 } }
|
|
2869
3080
|
});
|
|
2870
3081
|
return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
2871
|
-
|
|
3082
|
+
import_react13.DragDropProvider,
|
|
2872
3083
|
{
|
|
2873
3084
|
sensors,
|
|
2874
3085
|
onDragStart: (event) => {
|
|
@@ -2932,11 +3143,11 @@ var Sortable = ({
|
|
|
2932
3143
|
|
|
2933
3144
|
// components/AutoField/context.tsx
|
|
2934
3145
|
init_react_import();
|
|
2935
|
-
var
|
|
3146
|
+
var import_react14 = require("react");
|
|
2936
3147
|
var import_jsx_runtime6 = require("react/jsx-runtime");
|
|
2937
|
-
var NestedFieldContext = (0,
|
|
3148
|
+
var NestedFieldContext = (0, import_react14.createContext)({});
|
|
2938
3149
|
var useNestedFieldContext = () => {
|
|
2939
|
-
const context = (0,
|
|
3150
|
+
const context = (0, import_react14.useContext)(NestedFieldContext);
|
|
2940
3151
|
return __spreadProps(__spreadValues({}, context), {
|
|
2941
3152
|
readOnlyFields: context.readOnlyFields || {}
|
|
2942
3153
|
});
|
|
@@ -2950,7 +3161,7 @@ var NestedFieldProvider = ({
|
|
|
2950
3161
|
}) => {
|
|
2951
3162
|
const subPath = `${name}.${subName}`;
|
|
2952
3163
|
const wildcardSubPath = `${wildcardName}.${subName}`;
|
|
2953
|
-
const subReadOnlyFields = (0,
|
|
3164
|
+
const subReadOnlyFields = (0, import_react14.useMemo)(
|
|
2954
3165
|
() => Object.keys(readOnlyFields).reduce((acc, readOnlyKey) => {
|
|
2955
3166
|
const isLocal = readOnlyKey.indexOf(subPath) > -1 || readOnlyKey.indexOf(wildcardSubPath) > -1;
|
|
2956
3167
|
if (isLocal) {
|
|
@@ -3003,14 +3214,14 @@ var ArrayField = ({
|
|
|
3003
3214
|
}),
|
|
3004
3215
|
openId: ""
|
|
3005
3216
|
};
|
|
3006
|
-
const [localState, setLocalState] = (0,
|
|
3007
|
-
(0,
|
|
3217
|
+
const [localState, setLocalState] = (0, import_react15.useState)({ arrayState, value });
|
|
3218
|
+
(0, import_react15.useEffect)(() => {
|
|
3008
3219
|
var _a;
|
|
3009
3220
|
const _arrayState = (_a = appStore.getState().state.ui.arrayState[id]) != null ? _a : arrayState;
|
|
3010
3221
|
setLocalState({ arrayState: _arrayState, value });
|
|
3011
3222
|
}, [value]);
|
|
3012
3223
|
const appStore = useAppStoreApi();
|
|
3013
|
-
const mapArrayStateToUi = (0,
|
|
3224
|
+
const mapArrayStateToUi = (0, import_react15.useCallback)(
|
|
3014
3225
|
(partialArrayState) => {
|
|
3015
3226
|
const state = appStore.getState().state;
|
|
3016
3227
|
return {
|
|
@@ -3021,13 +3232,13 @@ var ArrayField = ({
|
|
|
3021
3232
|
},
|
|
3022
3233
|
[arrayState, appStore]
|
|
3023
3234
|
);
|
|
3024
|
-
const getHighestIndex = (0,
|
|
3235
|
+
const getHighestIndex = (0, import_react15.useCallback)(() => {
|
|
3025
3236
|
return arrayState.items.reduce(
|
|
3026
3237
|
(acc, item) => item._originalIndex > acc ? item._originalIndex : acc,
|
|
3027
3238
|
-1
|
|
3028
3239
|
);
|
|
3029
3240
|
}, [arrayState]);
|
|
3030
|
-
const regenerateArrayState = (0,
|
|
3241
|
+
const regenerateArrayState = (0, import_react15.useCallback)(
|
|
3031
3242
|
(value2) => {
|
|
3032
3243
|
let highestIndex = getHighestIndex();
|
|
3033
3244
|
const newItems = Array.from(value2 || []).map((item, idx) => {
|
|
@@ -3046,19 +3257,19 @@ var ArrayField = ({
|
|
|
3046
3257
|
},
|
|
3047
3258
|
[arrayState]
|
|
3048
3259
|
);
|
|
3049
|
-
(0,
|
|
3260
|
+
(0, import_react15.useEffect)(() => {
|
|
3050
3261
|
if (arrayState.items.length > 0) {
|
|
3051
3262
|
setUi(mapArrayStateToUi(arrayState));
|
|
3052
3263
|
}
|
|
3053
3264
|
}, []);
|
|
3054
|
-
const [draggedItem, setDraggedItem] = (0,
|
|
3265
|
+
const [draggedItem, setDraggedItem] = (0, import_react15.useState)("");
|
|
3055
3266
|
const isDraggingAny = !!draggedItem;
|
|
3056
3267
|
const canEdit = useAppStore(
|
|
3057
3268
|
(s) => s.permissions.getPermissions({ item: s.selectedItem }).edit
|
|
3058
3269
|
);
|
|
3059
3270
|
const forceReadOnly = !canEdit;
|
|
3060
|
-
const valueRef = (0,
|
|
3061
|
-
const uniqifyItem = (0,
|
|
3271
|
+
const valueRef = (0, import_react15.useRef)(value);
|
|
3272
|
+
const uniqifyItem = (0, import_react15.useCallback)(
|
|
3062
3273
|
(val) => {
|
|
3063
3274
|
if (field.type !== "array" || !field.arrayFields) return;
|
|
3064
3275
|
const config = appStore.getState().config;
|
|
@@ -3363,11 +3574,11 @@ var DefaultField = ({
|
|
|
3363
3574
|
|
|
3364
3575
|
// components/AutoField/fields/ExternalField/index.tsx
|
|
3365
3576
|
init_react_import();
|
|
3366
|
-
var
|
|
3577
|
+
var import_react19 = require("react");
|
|
3367
3578
|
|
|
3368
3579
|
// components/ExternalInput/index.tsx
|
|
3369
3580
|
init_react_import();
|
|
3370
|
-
var
|
|
3581
|
+
var import_react18 = require("react");
|
|
3371
3582
|
|
|
3372
3583
|
// css-module:/home/runner/work/puck/puck/packages/core/components/ExternalInput/styles.module.css#css-module
|
|
3373
3584
|
init_react_import();
|
|
@@ -3375,7 +3586,7 @@ var styles_module_default6 = { "ExternalInput-actions": "_ExternalInput-actions_
|
|
|
3375
3586
|
|
|
3376
3587
|
// components/Modal/index.tsx
|
|
3377
3588
|
init_react_import();
|
|
3378
|
-
var
|
|
3589
|
+
var import_react16 = require("react");
|
|
3379
3590
|
|
|
3380
3591
|
// css-module:/home/runner/work/puck/puck/packages/core/components/Modal/styles.module.css#css-module
|
|
3381
3592
|
init_react_import();
|
|
@@ -3390,8 +3601,8 @@ var Modal = ({
|
|
|
3390
3601
|
onClose,
|
|
3391
3602
|
isOpen
|
|
3392
3603
|
}) => {
|
|
3393
|
-
const [rootEl, setRootEl] = (0,
|
|
3394
|
-
(0,
|
|
3604
|
+
const [rootEl, setRootEl] = (0, import_react16.useState)(null);
|
|
3605
|
+
(0, import_react16.useEffect)(() => {
|
|
3395
3606
|
setRootEl(document.getElementById("puck-portal-root"));
|
|
3396
3607
|
}, []);
|
|
3397
3608
|
if (!rootEl) {
|
|
@@ -3438,7 +3649,7 @@ init_react_import();
|
|
|
3438
3649
|
|
|
3439
3650
|
// components/Button/Button.tsx
|
|
3440
3651
|
init_react_import();
|
|
3441
|
-
var
|
|
3652
|
+
var import_react17 = require("react");
|
|
3442
3653
|
|
|
3443
3654
|
// css-module:/home/runner/work/puck/puck/packages/core/components/Button/Button.module.css#css-module
|
|
3444
3655
|
init_react_import();
|
|
@@ -3488,8 +3699,8 @@ var Button = (_a) => {
|
|
|
3488
3699
|
"size",
|
|
3489
3700
|
"loading"
|
|
3490
3701
|
]);
|
|
3491
|
-
const [loading, setLoading] = (0,
|
|
3492
|
-
(0,
|
|
3702
|
+
const [loading, setLoading] = (0, import_react17.useState)(loadingProp);
|
|
3703
|
+
(0, import_react17.useEffect)(() => setLoading(loadingProp), [loadingProp]);
|
|
3493
3704
|
const ElementType = href ? "a" : type ? "button" : "span";
|
|
3494
3705
|
const dataAttrs = filterDataAttrs(props);
|
|
3495
3706
|
const el = /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)(
|
|
@@ -3544,28 +3755,28 @@ var ExternalInput = ({
|
|
|
3544
3755
|
mapRow = (val) => val,
|
|
3545
3756
|
filterFields
|
|
3546
3757
|
} = field || {};
|
|
3547
|
-
const [data, setData] = (0,
|
|
3548
|
-
const [isOpen, setOpen] = (0,
|
|
3549
|
-
const [isLoading, setIsLoading] = (0,
|
|
3758
|
+
const [data, setData] = (0, import_react18.useState)([]);
|
|
3759
|
+
const [isOpen, setOpen] = (0, import_react18.useState)(false);
|
|
3760
|
+
const [isLoading, setIsLoading] = (0, import_react18.useState)(true);
|
|
3550
3761
|
const hasFilterFields = !!filterFields;
|
|
3551
|
-
const [filters, setFilters] = (0,
|
|
3552
|
-
const [filtersToggled, setFiltersToggled] = (0,
|
|
3553
|
-
const mappedData = (0,
|
|
3762
|
+
const [filters, setFilters] = (0, import_react18.useState)(field.initialFilters || {});
|
|
3763
|
+
const [filtersToggled, setFiltersToggled] = (0, import_react18.useState)(hasFilterFields);
|
|
3764
|
+
const mappedData = (0, import_react18.useMemo)(() => {
|
|
3554
3765
|
return data.map(mapRow);
|
|
3555
3766
|
}, [data]);
|
|
3556
|
-
const keys = (0,
|
|
3767
|
+
const keys = (0, import_react18.useMemo)(() => {
|
|
3557
3768
|
const validKeys = /* @__PURE__ */ new Set();
|
|
3558
3769
|
for (const item of mappedData) {
|
|
3559
3770
|
for (const key of Object.keys(item)) {
|
|
3560
|
-
if (typeof item[key] === "string" || typeof item[key] === "number" || (0,
|
|
3771
|
+
if (typeof item[key] === "string" || typeof item[key] === "number" || (0, import_react18.isValidElement)(item[key])) {
|
|
3561
3772
|
validKeys.add(key);
|
|
3562
3773
|
}
|
|
3563
3774
|
}
|
|
3564
3775
|
}
|
|
3565
3776
|
return Array.from(validKeys);
|
|
3566
3777
|
}, [mappedData]);
|
|
3567
|
-
const [searchQuery, setSearchQuery] = (0,
|
|
3568
|
-
const search = (0,
|
|
3778
|
+
const [searchQuery, setSearchQuery] = (0, import_react18.useState)(field.initialQuery || "");
|
|
3779
|
+
const search = (0, import_react18.useCallback)(
|
|
3569
3780
|
(query, filters2) => __async(void 0, null, function* () {
|
|
3570
3781
|
setIsLoading(true);
|
|
3571
3782
|
const cacheKey = `${id}-${query}-${JSON.stringify(filters2)}`;
|
|
@@ -3578,7 +3789,7 @@ var ExternalInput = ({
|
|
|
3578
3789
|
}),
|
|
3579
3790
|
[id, field]
|
|
3580
3791
|
);
|
|
3581
|
-
const Footer = (0,
|
|
3792
|
+
const Footer = (0, import_react18.useCallback)(
|
|
3582
3793
|
(props) => field.renderFooter ? field.renderFooter(props) : /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)("span", { className: getClassNameModal("footer"), children: [
|
|
3583
3794
|
props.items.length,
|
|
3584
3795
|
" result",
|
|
@@ -3586,7 +3797,7 @@ var ExternalInput = ({
|
|
|
3586
3797
|
] }),
|
|
3587
3798
|
[field.renderFooter]
|
|
3588
3799
|
);
|
|
3589
|
-
(0,
|
|
3800
|
+
(0, import_react18.useEffect)(() => {
|
|
3590
3801
|
search(searchQuery, filters);
|
|
3591
3802
|
}, []);
|
|
3592
3803
|
return /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)(
|
|
@@ -3759,7 +3970,7 @@ var ExternalField = ({
|
|
|
3759
3970
|
var _a, _b, _c;
|
|
3760
3971
|
const validField = field;
|
|
3761
3972
|
const deprecatedField = field;
|
|
3762
|
-
(0,
|
|
3973
|
+
(0, import_react19.useEffect)(() => {
|
|
3763
3974
|
if (deprecatedField.adaptor) {
|
|
3764
3975
|
console.error(
|
|
3765
3976
|
"Warning: The `adaptor` API is deprecated. Please use updated APIs on the `external` field instead. This will be a breaking change in a future release."
|
|
@@ -3802,20 +4013,6 @@ var ExternalField = ({
|
|
|
3802
4013
|
|
|
3803
4014
|
// components/AutoField/fields/RadioField/index.tsx
|
|
3804
4015
|
init_react_import();
|
|
3805
|
-
var import_react19 = require("react");
|
|
3806
|
-
|
|
3807
|
-
// lib/safe-json-parse.ts
|
|
3808
|
-
init_react_import();
|
|
3809
|
-
var safeJsonParse = (str) => {
|
|
3810
|
-
try {
|
|
3811
|
-
const jsonValue = JSON.parse(str);
|
|
3812
|
-
return jsonValue;
|
|
3813
|
-
} catch (e) {
|
|
3814
|
-
return str;
|
|
3815
|
-
}
|
|
3816
|
-
};
|
|
3817
|
-
|
|
3818
|
-
// components/AutoField/fields/RadioField/index.tsx
|
|
3819
4016
|
var import_jsx_runtime14 = require("react/jsx-runtime");
|
|
3820
4017
|
var getClassName11 = get_class_name_factory_default("Input", styles_module_default2);
|
|
3821
4018
|
var RadioField = ({
|
|
@@ -3829,10 +4026,6 @@ var RadioField = ({
|
|
|
3829
4026
|
labelIcon,
|
|
3830
4027
|
Label: Label2
|
|
3831
4028
|
}) => {
|
|
3832
|
-
const flatOptions = (0, import_react19.useMemo)(
|
|
3833
|
-
() => field.type === "radio" ? field.options.map(({ value: value2 }) => value2) : [],
|
|
3834
|
-
[field]
|
|
3835
|
-
);
|
|
3836
4029
|
if (field.type !== "radio" || !field.options) {
|
|
3837
4030
|
return null;
|
|
3838
4031
|
}
|
|
@@ -3843,43 +4036,39 @@ var RadioField = ({
|
|
|
3843
4036
|
label: label || name,
|
|
3844
4037
|
readOnly,
|
|
3845
4038
|
el: "div",
|
|
3846
|
-
children: /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("div", { className: getClassName11("radioGroupItems"), id, children: field.options.map((option) =>
|
|
3847
|
-
|
|
3848
|
-
|
|
3849
|
-
|
|
3850
|
-
|
|
3851
|
-
|
|
3852
|
-
|
|
3853
|
-
|
|
3854
|
-
|
|
3855
|
-
|
|
3856
|
-
|
|
3857
|
-
|
|
3858
|
-
|
|
3859
|
-
|
|
3860
|
-
|
|
3861
|
-
|
|
3862
|
-
|
|
3863
|
-
|
|
3864
|
-
|
|
3865
|
-
|
|
3866
|
-
|
|
3867
|
-
|
|
3868
|
-
|
|
3869
|
-
|
|
3870
|
-
|
|
3871
|
-
|
|
3872
|
-
|
|
3873
|
-
},
|
|
3874
|
-
option.label + option.value
|
|
3875
|
-
)) })
|
|
4039
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("div", { className: getClassName11("radioGroupItems"), id, children: field.options.map((option) => {
|
|
4040
|
+
var _a;
|
|
4041
|
+
return /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)(
|
|
4042
|
+
"label",
|
|
4043
|
+
{
|
|
4044
|
+
className: getClassName11("radio"),
|
|
4045
|
+
children: [
|
|
4046
|
+
/* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
|
|
4047
|
+
"input",
|
|
4048
|
+
{
|
|
4049
|
+
type: "radio",
|
|
4050
|
+
className: getClassName11("radioInput"),
|
|
4051
|
+
value: JSON.stringify({ value: option.value }),
|
|
4052
|
+
name,
|
|
4053
|
+
onChange: (e) => {
|
|
4054
|
+
onChange(JSON.parse(e.target.value).value);
|
|
4055
|
+
},
|
|
4056
|
+
disabled: readOnly,
|
|
4057
|
+
checked: value === option.value
|
|
4058
|
+
}
|
|
4059
|
+
),
|
|
4060
|
+
/* @__PURE__ */ (0, import_jsx_runtime14.jsx)("div", { className: getClassName11("radioInner"), children: option.label || ((_a = option.value) == null ? void 0 : _a.toString()) })
|
|
4061
|
+
]
|
|
4062
|
+
},
|
|
4063
|
+
option.label + option.value
|
|
4064
|
+
);
|
|
4065
|
+
}) })
|
|
3876
4066
|
}
|
|
3877
4067
|
);
|
|
3878
4068
|
};
|
|
3879
4069
|
|
|
3880
4070
|
// components/AutoField/fields/SelectField/index.tsx
|
|
3881
4071
|
init_react_import();
|
|
3882
|
-
var import_react20 = require("react");
|
|
3883
4072
|
var import_jsx_runtime15 = require("react/jsx-runtime");
|
|
3884
4073
|
var getClassName12 = get_class_name_factory_default("Input", styles_module_default2);
|
|
3885
4074
|
var SelectField = ({
|
|
@@ -3893,10 +4082,6 @@ var SelectField = ({
|
|
|
3893
4082
|
readOnly,
|
|
3894
4083
|
id
|
|
3895
4084
|
}) => {
|
|
3896
|
-
const flatOptions = (0, import_react20.useMemo)(
|
|
3897
|
-
() => field.type === "select" ? field.options.map(({ value: value2 }) => value2) : [],
|
|
3898
|
-
[field]
|
|
3899
|
-
);
|
|
3900
4085
|
if (field.type !== "select" || !field.options) {
|
|
3901
4086
|
return null;
|
|
3902
4087
|
}
|
|
@@ -3914,22 +4099,16 @@ var SelectField = ({
|
|
|
3914
4099
|
className: getClassName12("input"),
|
|
3915
4100
|
disabled: readOnly,
|
|
3916
4101
|
onChange: (e) => {
|
|
3917
|
-
|
|
3918
|
-
const jsonValue = (_a = safeJsonParse(e.target.value)) != null ? _a : e.target.value;
|
|
3919
|
-
if (flatOptions.indexOf(jsonValue) > -1) {
|
|
3920
|
-
onChange(jsonValue);
|
|
3921
|
-
} else {
|
|
3922
|
-
onChange(e.target.value);
|
|
3923
|
-
}
|
|
4102
|
+
onChange(JSON.parse(e.target.value).value);
|
|
3924
4103
|
},
|
|
3925
|
-
value,
|
|
4104
|
+
value: JSON.stringify({ value }),
|
|
3926
4105
|
children: field.options.map((option) => /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
|
|
3927
4106
|
"option",
|
|
3928
4107
|
{
|
|
3929
4108
|
label: option.label,
|
|
3930
|
-
value: option.value
|
|
4109
|
+
value: JSON.stringify({ value: option.value })
|
|
3931
4110
|
},
|
|
3932
|
-
option.label + option.value
|
|
4111
|
+
option.label + JSON.stringify(option.value)
|
|
3933
4112
|
))
|
|
3934
4113
|
}
|
|
3935
4114
|
)
|
|
@@ -4053,12 +4232,12 @@ var ObjectField = ({
|
|
|
4053
4232
|
|
|
4054
4233
|
// lib/use-safe-id.ts
|
|
4055
4234
|
init_react_import();
|
|
4056
|
-
var
|
|
4235
|
+
var import_react20 = __toESM(require("react"));
|
|
4057
4236
|
var useSafeId = () => {
|
|
4058
|
-
if (typeof
|
|
4059
|
-
return
|
|
4237
|
+
if (typeof import_react20.default.useId !== "undefined") {
|
|
4238
|
+
return import_react20.default.useId();
|
|
4060
4239
|
}
|
|
4061
|
-
const [id] = (0,
|
|
4240
|
+
const [id] = (0, import_react20.useState)(generateId());
|
|
4062
4241
|
return id;
|
|
4063
4242
|
};
|
|
4064
4243
|
|
|
@@ -4092,7 +4271,7 @@ var FieldLabelInternal = ({
|
|
|
4092
4271
|
readOnly
|
|
4093
4272
|
}) => {
|
|
4094
4273
|
const overrides = useAppStore((s) => s.overrides);
|
|
4095
|
-
const Wrapper = (0,
|
|
4274
|
+
const Wrapper = (0, import_react21.useMemo)(
|
|
4096
4275
|
() => overrides.fieldLabel || FieldLabel,
|
|
4097
4276
|
[overrides]
|
|
4098
4277
|
);
|
|
@@ -4119,7 +4298,7 @@ function AutoFieldInternal(props) {
|
|
|
4119
4298
|
var _a2;
|
|
4120
4299
|
return (_a2 = s.selectedItem) == null ? void 0 : _a2.readOnly;
|
|
4121
4300
|
});
|
|
4122
|
-
const nestedFieldContext = (0,
|
|
4301
|
+
const nestedFieldContext = (0, import_react21.useContext)(NestedFieldContext);
|
|
4123
4302
|
const { id, Label: Label2 = FieldLabelInternal } = props;
|
|
4124
4303
|
const field = props.field;
|
|
4125
4304
|
const label = field.label;
|
|
@@ -4153,7 +4332,7 @@ function AutoFieldInternal(props) {
|
|
|
4153
4332
|
Label: Label2,
|
|
4154
4333
|
id: resolvedId
|
|
4155
4334
|
});
|
|
4156
|
-
const onFocus = (0,
|
|
4335
|
+
const onFocus = (0, import_react21.useCallback)(
|
|
4157
4336
|
(e) => {
|
|
4158
4337
|
if (mergedProps.name && (e.target.nodeName === "INPUT" || e.target.nodeName === "TEXTAREA")) {
|
|
4159
4338
|
e.stopPropagation();
|
|
@@ -4167,7 +4346,7 @@ function AutoFieldInternal(props) {
|
|
|
4167
4346
|
},
|
|
4168
4347
|
[mergedProps.name]
|
|
4169
4348
|
);
|
|
4170
|
-
const onBlur = (0,
|
|
4349
|
+
const onBlur = (0, import_react21.useCallback)((e) => {
|
|
4171
4350
|
if ("name" in e.target) {
|
|
4172
4351
|
dispatch({
|
|
4173
4352
|
type: "setUi",
|
|
@@ -4220,20 +4399,20 @@ function AutoFieldInternal(props) {
|
|
|
4220
4399
|
function AutoFieldPrivate(props) {
|
|
4221
4400
|
const isFocused = useAppStore((s) => s.state.ui.field.focus === props.name);
|
|
4222
4401
|
const { value, onChange } = props;
|
|
4223
|
-
const [localValue, setLocalValue] = (0,
|
|
4224
|
-
const onChangeLocal = (0,
|
|
4402
|
+
const [localValue, setLocalValue] = (0, import_react21.useState)(value);
|
|
4403
|
+
const onChangeLocal = (0, import_react21.useCallback)(
|
|
4225
4404
|
(val, ui) => {
|
|
4226
4405
|
setLocalValue(val);
|
|
4227
4406
|
onChange(val, ui);
|
|
4228
4407
|
},
|
|
4229
4408
|
[onChange]
|
|
4230
4409
|
);
|
|
4231
|
-
(0,
|
|
4410
|
+
(0, import_react21.useEffect)(() => {
|
|
4232
4411
|
if (!isFocused) {
|
|
4233
4412
|
setLocalValue(value);
|
|
4234
4413
|
}
|
|
4235
4414
|
}, [value]);
|
|
4236
|
-
(0,
|
|
4415
|
+
(0, import_react21.useEffect)(() => {
|
|
4237
4416
|
if (!isFocused) {
|
|
4238
4417
|
if (value !== localValue) {
|
|
4239
4418
|
setLocalValue(value);
|
|
@@ -4247,7 +4426,7 @@ function AutoFieldPrivate(props) {
|
|
|
4247
4426
|
return /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(AutoFieldInternal, __spreadValues(__spreadValues({}, props), localProps));
|
|
4248
4427
|
}
|
|
4249
4428
|
function AutoField(props) {
|
|
4250
|
-
const DefaultLabel = (0,
|
|
4429
|
+
const DefaultLabel = (0, import_react21.useMemo)(() => {
|
|
4251
4430
|
const DefaultLabel2 = (labelProps) => /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
|
|
4252
4431
|
"div",
|
|
4253
4432
|
__spreadProps(__spreadValues({}, labelProps), {
|
|
@@ -4270,25 +4449,25 @@ init_react_import();
|
|
|
4270
4449
|
var styles_module_default10 = { "Drawer": "_Drawer_pl7z0_1", "Drawer-draggable": "_Drawer-draggable_pl7z0_8", "Drawer-draggableBg": "_Drawer-draggableBg_pl7z0_12", "DrawerItem-draggable": "_DrawerItem-draggable_pl7z0_22", "DrawerItem--disabled": "_DrawerItem--disabled_pl7z0_35", "DrawerItem": "_DrawerItem_pl7z0_22", "Drawer--isDraggingFrom": "_Drawer--isDraggingFrom_pl7z0_45", "DrawerItem-name": "_DrawerItem-name_pl7z0_63" };
|
|
4271
4450
|
|
|
4272
4451
|
// components/Drawer/index.tsx
|
|
4273
|
-
var
|
|
4452
|
+
var import_react38 = require("react");
|
|
4274
4453
|
|
|
4275
4454
|
// components/DragDropContext/index.tsx
|
|
4276
4455
|
init_react_import();
|
|
4277
|
-
var
|
|
4278
|
-
var
|
|
4456
|
+
var import_react36 = require("@dnd-kit/react");
|
|
4457
|
+
var import_react37 = require("react");
|
|
4279
4458
|
var import_dom = require("@dnd-kit/dom");
|
|
4280
4459
|
|
|
4281
4460
|
// components/DropZone/index.tsx
|
|
4282
4461
|
init_react_import();
|
|
4283
|
-
var
|
|
4462
|
+
var import_react34 = require("react");
|
|
4284
4463
|
|
|
4285
4464
|
// components/DraggableComponent/index.tsx
|
|
4286
4465
|
init_react_import();
|
|
4287
|
-
var
|
|
4466
|
+
var import_react25 = require("react");
|
|
4288
4467
|
|
|
4289
4468
|
// css-module:/home/runner/work/puck/puck/packages/core/components/DraggableComponent/styles.module.css#css-module
|
|
4290
4469
|
init_react_import();
|
|
4291
|
-
var styles_module_default11 = { "DraggableComponent": "
|
|
4470
|
+
var styles_module_default11 = { "DraggableComponent": "_DraggableComponent_1vaqy_1", "DraggableComponent-overlayWrapper": "_DraggableComponent-overlayWrapper_1vaqy_12", "DraggableComponent-overlay": "_DraggableComponent-overlay_1vaqy_12", "DraggableComponent-loadingOverlay": "_DraggableComponent-loadingOverlay_1vaqy_34", "DraggableComponent--hover": "_DraggableComponent--hover_1vaqy_50", "DraggableComponent--isSelected": "_DraggableComponent--isSelected_1vaqy_57", "DraggableComponent-actionsOverlay": "_DraggableComponent-actionsOverlay_1vaqy_71", "DraggableComponent-actions": "_DraggableComponent-actions_1vaqy_71" };
|
|
4292
4471
|
|
|
4293
4472
|
// components/DraggableComponent/index.tsx
|
|
4294
4473
|
var import_react_dom2 = require("react-dom");
|
|
@@ -4314,11 +4493,11 @@ function getDeepScrollPosition(element) {
|
|
|
4314
4493
|
|
|
4315
4494
|
// components/DropZone/context.tsx
|
|
4316
4495
|
init_react_import();
|
|
4317
|
-
var
|
|
4496
|
+
var import_react22 = require("react");
|
|
4318
4497
|
var import_zustand3 = require("zustand");
|
|
4319
4498
|
var import_jsx_runtime19 = require("react/jsx-runtime");
|
|
4320
|
-
var dropZoneContext = (0,
|
|
4321
|
-
var ZoneStoreContext = (0,
|
|
4499
|
+
var dropZoneContext = (0, import_react22.createContext)(null);
|
|
4500
|
+
var ZoneStoreContext = (0, import_react22.createContext)(
|
|
4322
4501
|
(0, import_zustand3.createStore)(() => ({
|
|
4323
4502
|
zoneDepthIndex: {},
|
|
4324
4503
|
nextZoneDepthIndex: {},
|
|
@@ -4341,7 +4520,7 @@ var DropZoneProvider = ({
|
|
|
4341
4520
|
value
|
|
4342
4521
|
}) => {
|
|
4343
4522
|
const dispatch = useAppStore((s) => s.dispatch);
|
|
4344
|
-
const registerZone = (0,
|
|
4523
|
+
const registerZone = (0, import_react22.useCallback)(
|
|
4345
4524
|
(zoneCompound) => {
|
|
4346
4525
|
dispatch({
|
|
4347
4526
|
type: "registerZone",
|
|
@@ -4350,19 +4529,9 @@ var DropZoneProvider = ({
|
|
|
4350
4529
|
},
|
|
4351
4530
|
[dispatch]
|
|
4352
4531
|
);
|
|
4353
|
-
const
|
|
4354
|
-
(zoneCompound) => {
|
|
4355
|
-
dispatch({
|
|
4356
|
-
type: "unregisterZone",
|
|
4357
|
-
zone: zoneCompound
|
|
4358
|
-
});
|
|
4359
|
-
},
|
|
4360
|
-
[dispatch]
|
|
4361
|
-
);
|
|
4362
|
-
const memoValue = (0, import_react23.useMemo)(
|
|
4532
|
+
const memoValue = (0, import_react22.useMemo)(
|
|
4363
4533
|
() => __spreadValues({
|
|
4364
|
-
registerZone
|
|
4365
|
-
unregisterZone
|
|
4534
|
+
registerZone
|
|
4366
4535
|
}, value),
|
|
4367
4536
|
[value]
|
|
4368
4537
|
);
|
|
@@ -4370,7 +4539,7 @@ var DropZoneProvider = ({
|
|
|
4370
4539
|
};
|
|
4371
4540
|
|
|
4372
4541
|
// components/DraggableComponent/index.tsx
|
|
4373
|
-
var
|
|
4542
|
+
var import_shallow3 = require("zustand/react/shallow");
|
|
4374
4543
|
var import_sortable2 = require("@dnd-kit/react/sortable");
|
|
4375
4544
|
|
|
4376
4545
|
// lib/accumulate-transform.ts
|
|
@@ -4390,23 +4559,23 @@ function accumulateTransform(el) {
|
|
|
4390
4559
|
|
|
4391
4560
|
// lib/use-context-store.ts
|
|
4392
4561
|
init_react_import();
|
|
4393
|
-
var
|
|
4562
|
+
var import_react23 = require("react");
|
|
4394
4563
|
var import_zustand4 = require("zustand");
|
|
4395
|
-
var
|
|
4564
|
+
var import_shallow2 = require("zustand/react/shallow");
|
|
4396
4565
|
function useContextStore(context, selector) {
|
|
4397
|
-
const store = (0,
|
|
4566
|
+
const store = (0, import_react23.useContext)(context);
|
|
4398
4567
|
if (!store) {
|
|
4399
4568
|
throw new Error("useContextStore must be used inside context");
|
|
4400
4569
|
}
|
|
4401
|
-
return (0, import_zustand4.useStore)(store, (0,
|
|
4570
|
+
return (0, import_zustand4.useStore)(store, (0, import_shallow2.useShallow)(selector));
|
|
4402
4571
|
}
|
|
4403
4572
|
|
|
4404
4573
|
// lib/dnd/use-on-drag-finished.ts
|
|
4405
4574
|
init_react_import();
|
|
4406
|
-
var
|
|
4575
|
+
var import_react24 = require("react");
|
|
4407
4576
|
var useOnDragFinished = (cb, deps = []) => {
|
|
4408
4577
|
const appStore = useAppStoreApi();
|
|
4409
|
-
return (0,
|
|
4578
|
+
return (0, import_react24.useCallback)(() => {
|
|
4410
4579
|
let dispose = () => {
|
|
4411
4580
|
};
|
|
4412
4581
|
const processDragging = (isDragging2) => {
|
|
@@ -4452,6 +4621,9 @@ var DefaultActionBar = ({
|
|
|
4452
4621
|
] }),
|
|
4453
4622
|
/* @__PURE__ */ (0, import_jsx_runtime20.jsx)(ActionBar.Group, { children })
|
|
4454
4623
|
] });
|
|
4624
|
+
var DefaultOverlay = ({
|
|
4625
|
+
children
|
|
4626
|
+
}) => /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(import_jsx_runtime20.Fragment, { children });
|
|
4455
4627
|
var DraggableComponent = ({
|
|
4456
4628
|
children,
|
|
4457
4629
|
depth,
|
|
@@ -4476,9 +4648,9 @@ var DraggableComponent = ({
|
|
|
4476
4648
|
const overrides = useAppStore((s) => s.overrides);
|
|
4477
4649
|
const dispatch = useAppStore((s) => s.dispatch);
|
|
4478
4650
|
const iframe = useAppStore((s) => s.iframe);
|
|
4479
|
-
const ctx = (0,
|
|
4480
|
-
const [localZones, setLocalZones] = (0,
|
|
4481
|
-
const registerLocalZone = (0,
|
|
4651
|
+
const ctx = (0, import_react25.useContext)(dropZoneContext);
|
|
4652
|
+
const [localZones, setLocalZones] = (0, import_react25.useState)({});
|
|
4653
|
+
const registerLocalZone = (0, import_react25.useCallback)(
|
|
4482
4654
|
(zoneCompound2, active) => {
|
|
4483
4655
|
var _a;
|
|
4484
4656
|
(_a = ctx == null ? void 0 : ctx.registerLocalZone) == null ? void 0 : _a.call(ctx, zoneCompound2, active);
|
|
@@ -4488,7 +4660,7 @@ var DraggableComponent = ({
|
|
|
4488
4660
|
},
|
|
4489
4661
|
[setLocalZones]
|
|
4490
4662
|
);
|
|
4491
|
-
const unregisterLocalZone = (0,
|
|
4663
|
+
const unregisterLocalZone = (0, import_react25.useCallback)(
|
|
4492
4664
|
(zoneCompound2) => {
|
|
4493
4665
|
var _a;
|
|
4494
4666
|
(_a = ctx == null ? void 0 : ctx.unregisterLocalZone) == null ? void 0 : _a.call(ctx, zoneCompound2);
|
|
@@ -4501,19 +4673,19 @@ var DraggableComponent = ({
|
|
|
4501
4673
|
[setLocalZones]
|
|
4502
4674
|
);
|
|
4503
4675
|
const containsActiveZone = Object.values(localZones).filter(Boolean).length > 0;
|
|
4504
|
-
const path = useAppStore((0,
|
|
4676
|
+
const path = useAppStore((0, import_shallow3.useShallow)((s) => {
|
|
4505
4677
|
var _a;
|
|
4506
4678
|
return (_a = s.state.indexes.nodes[id]) == null ? void 0 : _a.path;
|
|
4507
4679
|
}));
|
|
4508
4680
|
const permissions = useAppStore(
|
|
4509
|
-
(0,
|
|
4681
|
+
(0, import_shallow3.useShallow)((s) => {
|
|
4510
4682
|
const item = getItem({ index, zone: zoneCompound }, s.state);
|
|
4511
4683
|
return s.permissions.getPermissions({ item });
|
|
4512
4684
|
})
|
|
4513
4685
|
);
|
|
4514
|
-
const zoneStore = (0,
|
|
4515
|
-
const [dragAxis, setDragAxis] = (0,
|
|
4516
|
-
const dynamicCollisionDetector = (0,
|
|
4686
|
+
const zoneStore = (0, import_react25.useContext)(ZoneStoreContext);
|
|
4687
|
+
const [dragAxis, setDragAxis] = (0, import_react25.useState)(userDragAxis || autoDragAxis);
|
|
4688
|
+
const dynamicCollisionDetector = (0, import_react25.useMemo)(
|
|
4517
4689
|
() => createDynamicCollisionDetector(dragAxis),
|
|
4518
4690
|
[dragAxis]
|
|
4519
4691
|
);
|
|
@@ -4545,7 +4717,7 @@ var DraggableComponent = ({
|
|
|
4545
4717
|
},
|
|
4546
4718
|
feedback: "clone"
|
|
4547
4719
|
});
|
|
4548
|
-
(0,
|
|
4720
|
+
(0, import_react25.useEffect)(() => {
|
|
4549
4721
|
const isEnabled = zoneStore.getState().enabledIndex[zoneCompound];
|
|
4550
4722
|
sortable.droppable.disabled = !isEnabled;
|
|
4551
4723
|
sortable.draggable.disabled = !permissions.drag;
|
|
@@ -4562,8 +4734,8 @@ var DraggableComponent = ({
|
|
|
4562
4734
|
}
|
|
4563
4735
|
return cleanup;
|
|
4564
4736
|
}, [permissions.drag, zoneCompound]);
|
|
4565
|
-
const ref = (0,
|
|
4566
|
-
const refSetter = (0,
|
|
4737
|
+
const ref = (0, import_react25.useRef)(null);
|
|
4738
|
+
const refSetter = (0, import_react25.useCallback)(
|
|
4567
4739
|
(el) => {
|
|
4568
4740
|
sortableRef(el);
|
|
4569
4741
|
if (el) {
|
|
@@ -4572,14 +4744,14 @@ var DraggableComponent = ({
|
|
|
4572
4744
|
},
|
|
4573
4745
|
[sortableRef]
|
|
4574
4746
|
);
|
|
4575
|
-
const [portalEl, setPortalEl] = (0,
|
|
4576
|
-
(0,
|
|
4747
|
+
const [portalEl, setPortalEl] = (0, import_react25.useState)();
|
|
4748
|
+
(0, import_react25.useEffect)(() => {
|
|
4577
4749
|
var _a, _b, _c;
|
|
4578
4750
|
setPortalEl(
|
|
4579
4751
|
iframe.enabled ? (_a = ref.current) == null ? void 0 : _a.ownerDocument.body : (_c = (_b = ref.current) == null ? void 0 : _b.closest("[data-puck-preview]")) != null ? _c : document.body
|
|
4580
4752
|
);
|
|
4581
4753
|
}, [iframe.enabled, ref.current]);
|
|
4582
|
-
const getStyle = (0,
|
|
4754
|
+
const getStyle = (0, import_react25.useCallback)(() => {
|
|
4583
4755
|
var _a, _b, _c;
|
|
4584
4756
|
if (!ref.current) return;
|
|
4585
4757
|
const rect = ref.current.getBoundingClientRect();
|
|
@@ -4604,11 +4776,11 @@ var DraggableComponent = ({
|
|
|
4604
4776
|
};
|
|
4605
4777
|
return style2;
|
|
4606
4778
|
}, [ref.current]);
|
|
4607
|
-
const [style, setStyle] = (0,
|
|
4608
|
-
const sync = (0,
|
|
4779
|
+
const [style, setStyle] = (0, import_react25.useState)();
|
|
4780
|
+
const sync = (0, import_react25.useCallback)(() => {
|
|
4609
4781
|
setStyle(getStyle());
|
|
4610
4782
|
}, [ref.current, iframe]);
|
|
4611
|
-
(0,
|
|
4783
|
+
(0, import_react25.useEffect)(() => {
|
|
4612
4784
|
if (ref.current) {
|
|
4613
4785
|
const observer = new ResizeObserver(sync);
|
|
4614
4786
|
observer.observe(ref.current);
|
|
@@ -4618,13 +4790,13 @@ var DraggableComponent = ({
|
|
|
4618
4790
|
}
|
|
4619
4791
|
}, [ref.current]);
|
|
4620
4792
|
const registerNode = useAppStore((s) => s.nodes.registerNode);
|
|
4621
|
-
const hideOverlay = (0,
|
|
4793
|
+
const hideOverlay = (0, import_react25.useCallback)(() => {
|
|
4622
4794
|
setIsVisible(false);
|
|
4623
4795
|
}, []);
|
|
4624
|
-
const showOverlay = (0,
|
|
4796
|
+
const showOverlay = (0, import_react25.useCallback)(() => {
|
|
4625
4797
|
setIsVisible(true);
|
|
4626
4798
|
}, []);
|
|
4627
|
-
(0,
|
|
4799
|
+
(0, import_react25.useEffect)(() => {
|
|
4628
4800
|
var _a;
|
|
4629
4801
|
registerNode(id, {
|
|
4630
4802
|
methods: { sync, showOverlay, hideOverlay },
|
|
@@ -4641,13 +4813,20 @@ var DraggableComponent = ({
|
|
|
4641
4813
|
});
|
|
4642
4814
|
};
|
|
4643
4815
|
}, [id, zoneCompound, index, componentType, sync]);
|
|
4644
|
-
const CustomActionBar = (0,
|
|
4816
|
+
const CustomActionBar = (0, import_react25.useMemo)(
|
|
4645
4817
|
() => overrides.actionBar || DefaultActionBar,
|
|
4646
4818
|
[overrides.actionBar]
|
|
4647
4819
|
);
|
|
4648
|
-
const
|
|
4820
|
+
const CustomOverlay = (0, import_react25.useMemo)(
|
|
4821
|
+
() => overrides.componentOverlay || DefaultOverlay,
|
|
4822
|
+
[overrides.componentOverlay]
|
|
4823
|
+
);
|
|
4824
|
+
const onClick = (0, import_react25.useCallback)(
|
|
4649
4825
|
(e) => {
|
|
4650
|
-
e.
|
|
4826
|
+
const el = e.target;
|
|
4827
|
+
if (!el.closest("[data-puck-overlay-portal]")) {
|
|
4828
|
+
e.stopPropagation();
|
|
4829
|
+
}
|
|
4651
4830
|
dispatch({
|
|
4652
4831
|
type: "setUi",
|
|
4653
4832
|
ui: {
|
|
@@ -4658,7 +4837,7 @@ var DraggableComponent = ({
|
|
|
4658
4837
|
[index, zoneCompound, id]
|
|
4659
4838
|
);
|
|
4660
4839
|
const appStore = useAppStoreApi();
|
|
4661
|
-
const onSelectParent = (0,
|
|
4840
|
+
const onSelectParent = (0, import_react25.useCallback)(() => {
|
|
4662
4841
|
const { nodes, zones } = appStore.getState().state.indexes;
|
|
4663
4842
|
const node = nodes[id];
|
|
4664
4843
|
const parentNode = (node == null ? void 0 : node.parentId) ? nodes[node == null ? void 0 : node.parentId] : null;
|
|
@@ -4679,26 +4858,26 @@ var DraggableComponent = ({
|
|
|
4679
4858
|
}
|
|
4680
4859
|
});
|
|
4681
4860
|
}, [ctx, path]);
|
|
4682
|
-
const onDuplicate = (0,
|
|
4861
|
+
const onDuplicate = (0, import_react25.useCallback)(() => {
|
|
4683
4862
|
dispatch({
|
|
4684
4863
|
type: "duplicate",
|
|
4685
4864
|
sourceIndex: index,
|
|
4686
4865
|
sourceZone: zoneCompound
|
|
4687
4866
|
});
|
|
4688
4867
|
}, [index, zoneCompound]);
|
|
4689
|
-
const onDelete = (0,
|
|
4868
|
+
const onDelete = (0, import_react25.useCallback)(() => {
|
|
4690
4869
|
dispatch({
|
|
4691
4870
|
type: "remove",
|
|
4692
4871
|
index,
|
|
4693
4872
|
zone: zoneCompound
|
|
4694
4873
|
});
|
|
4695
4874
|
}, [index, zoneCompound]);
|
|
4696
|
-
const [hover, setHover] = (0,
|
|
4875
|
+
const [hover, setHover] = (0, import_react25.useState)(false);
|
|
4697
4876
|
const indicativeHover = useContextStore(
|
|
4698
4877
|
ZoneStoreContext,
|
|
4699
4878
|
(s) => s.hoveringComponent === id
|
|
4700
4879
|
);
|
|
4701
|
-
(0,
|
|
4880
|
+
(0, import_react25.useEffect)(() => {
|
|
4702
4881
|
if (!ref.current) {
|
|
4703
4882
|
return;
|
|
4704
4883
|
}
|
|
@@ -4734,7 +4913,8 @@ var DraggableComponent = ({
|
|
|
4734
4913
|
el.removeEventListener("mouseout", _onMouseOut);
|
|
4735
4914
|
};
|
|
4736
4915
|
}, [
|
|
4737
|
-
ref,
|
|
4916
|
+
ref.current,
|
|
4917
|
+
// Remount attributes if the element changes
|
|
4738
4918
|
onClick,
|
|
4739
4919
|
containsActiveZone,
|
|
4740
4920
|
zoneCompound,
|
|
@@ -4742,10 +4922,10 @@ var DraggableComponent = ({
|
|
|
4742
4922
|
thisIsDragging,
|
|
4743
4923
|
inDroppableZone
|
|
4744
4924
|
]);
|
|
4745
|
-
const [isVisible, setIsVisible] = (0,
|
|
4746
|
-
const [dragFinished, setDragFinished] = (0,
|
|
4747
|
-
const [_, startTransition] = (0,
|
|
4748
|
-
(0,
|
|
4925
|
+
const [isVisible, setIsVisible] = (0, import_react25.useState)(false);
|
|
4926
|
+
const [dragFinished, setDragFinished] = (0, import_react25.useState)(true);
|
|
4927
|
+
const [_, startTransition] = (0, import_react25.useTransition)();
|
|
4928
|
+
(0, import_react25.useEffect)(() => {
|
|
4749
4929
|
startTransition(() => {
|
|
4750
4930
|
if (hover || indicativeHover || isSelected) {
|
|
4751
4931
|
sync();
|
|
@@ -4756,7 +4936,7 @@ var DraggableComponent = ({
|
|
|
4756
4936
|
}
|
|
4757
4937
|
});
|
|
4758
4938
|
}, [hover, indicativeHover, isSelected, iframe]);
|
|
4759
|
-
const [thisWasDragging, setThisWasDragging] = (0,
|
|
4939
|
+
const [thisWasDragging, setThisWasDragging] = (0, import_react25.useState)(false);
|
|
4760
4940
|
const onDragFinished = useOnDragFinished((finished) => {
|
|
4761
4941
|
if (finished) {
|
|
4762
4942
|
startTransition(() => {
|
|
@@ -4767,15 +4947,15 @@ var DraggableComponent = ({
|
|
|
4767
4947
|
setDragFinished(false);
|
|
4768
4948
|
}
|
|
4769
4949
|
});
|
|
4770
|
-
(0,
|
|
4950
|
+
(0, import_react25.useEffect)(() => {
|
|
4771
4951
|
if (thisIsDragging) {
|
|
4772
4952
|
setThisWasDragging(true);
|
|
4773
4953
|
}
|
|
4774
4954
|
}, [thisIsDragging]);
|
|
4775
|
-
(0,
|
|
4955
|
+
(0, import_react25.useEffect)(() => {
|
|
4776
4956
|
if (thisWasDragging) return onDragFinished();
|
|
4777
4957
|
}, [thisWasDragging, onDragFinished]);
|
|
4778
|
-
const syncActionsPosition = (0,
|
|
4958
|
+
const syncActionsPosition = (0, import_react25.useCallback)(
|
|
4779
4959
|
(el) => {
|
|
4780
4960
|
if (el) {
|
|
4781
4961
|
const view = el.ownerDocument.defaultView;
|
|
@@ -4800,7 +4980,7 @@ var DraggableComponent = ({
|
|
|
4800
4980
|
},
|
|
4801
4981
|
[zoom]
|
|
4802
4982
|
);
|
|
4803
|
-
(0,
|
|
4983
|
+
(0, import_react25.useEffect)(() => {
|
|
4804
4984
|
if (userDragAxis) {
|
|
4805
4985
|
setDragAxis(userDragAxis);
|
|
4806
4986
|
return;
|
|
@@ -4814,11 +4994,11 @@ var DraggableComponent = ({
|
|
|
4814
4994
|
}
|
|
4815
4995
|
setDragAxis(autoDragAxis);
|
|
4816
4996
|
}, [ref, userDragAxis, autoDragAxis]);
|
|
4817
|
-
const parentAction = (0,
|
|
4997
|
+
const parentAction = (0, import_react25.useMemo)(
|
|
4818
4998
|
() => (ctx == null ? void 0 : ctx.areaId) && (ctx == null ? void 0 : ctx.areaId) !== "root" && /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(ActionBar.Action, { onClick: onSelectParent, label: "Select parent", children: /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(CornerLeftUp, { size: 16 }) }),
|
|
4819
4999
|
[ctx == null ? void 0 : ctx.areaId]
|
|
4820
5000
|
);
|
|
4821
|
-
const nextContextValue = (0,
|
|
5001
|
+
const nextContextValue = (0, import_react25.useMemo)(
|
|
4822
5002
|
() => __spreadProps(__spreadValues({}, ctx), {
|
|
4823
5003
|
areaId: id,
|
|
4824
5004
|
zoneCompound,
|
|
@@ -4886,7 +5066,16 @@ var DraggableComponent = ({
|
|
|
4886
5066
|
)
|
|
4887
5067
|
}
|
|
4888
5068
|
),
|
|
4889
|
-
/* @__PURE__ */ (0, import_jsx_runtime20.jsx)("div", { className: getClassName16("
|
|
5069
|
+
/* @__PURE__ */ (0, import_jsx_runtime20.jsx)("div", { className: getClassName16("overlayWrapper"), children: /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(
|
|
5070
|
+
CustomOverlay,
|
|
5071
|
+
{
|
|
5072
|
+
componentId: id,
|
|
5073
|
+
componentType,
|
|
5074
|
+
hover,
|
|
5075
|
+
isSelected,
|
|
5076
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime20.jsx)("div", { className: getClassName16("overlay") })
|
|
5077
|
+
}
|
|
5078
|
+
) })
|
|
4890
5079
|
]
|
|
4891
5080
|
}
|
|
4892
5081
|
),
|
|
@@ -4901,11 +5090,11 @@ init_react_import();
|
|
|
4901
5090
|
var styles_module_default12 = { "DropZone": "_DropZone_1i2sv_1", "DropZone--hasChildren": "_DropZone--hasChildren_1i2sv_11", "DropZone--isAreaSelected": "_DropZone--isAreaSelected_1i2sv_24", "DropZone--hoveringOverArea": "_DropZone--hoveringOverArea_1i2sv_25", "DropZone--isRootZone": "_DropZone--isRootZone_1i2sv_25", "DropZone--isDestination": "_DropZone--isDestination_1i2sv_35", "DropZone-item": "_DropZone-item_1i2sv_47", "DropZone-hitbox": "_DropZone-hitbox_1i2sv_51", "DropZone--isEnabled": "_DropZone--isEnabled_1i2sv_59", "DropZone--isAnimating": "_DropZone--isAnimating_1i2sv_68" };
|
|
4902
5091
|
|
|
4903
5092
|
// components/DropZone/index.tsx
|
|
4904
|
-
var
|
|
5093
|
+
var import_react35 = require("@dnd-kit/react");
|
|
4905
5094
|
|
|
4906
5095
|
// components/DropZone/lib/use-min-empty-height.ts
|
|
4907
5096
|
init_react_import();
|
|
4908
|
-
var
|
|
5097
|
+
var import_react26 = require("react");
|
|
4909
5098
|
var getNumItems = (appStore, zoneCompound) => appStore.getState().state.indexes.zones[zoneCompound].contentIds.length;
|
|
4910
5099
|
var useMinEmptyHeight = ({
|
|
4911
5100
|
zoneCompound,
|
|
@@ -4913,8 +5102,8 @@ var useMinEmptyHeight = ({
|
|
|
4913
5102
|
ref
|
|
4914
5103
|
}) => {
|
|
4915
5104
|
const appStore = useAppStoreApi();
|
|
4916
|
-
const [prevHeight, setPrevHeight] = (0,
|
|
4917
|
-
const [isAnimating, setIsAnimating] = (0,
|
|
5105
|
+
const [prevHeight, setPrevHeight] = (0, import_react26.useState)(0);
|
|
5106
|
+
const [isAnimating, setIsAnimating] = (0, import_react26.useState)(false);
|
|
4918
5107
|
const { draggedItem, isZone } = useContextStore(ZoneStoreContext, (s) => {
|
|
4919
5108
|
var _a, _b;
|
|
4920
5109
|
return {
|
|
@@ -4922,7 +5111,7 @@ var useMinEmptyHeight = ({
|
|
|
4922
5111
|
isZone: ((_b = s.draggedItem) == null ? void 0 : _b.data.zone) === zoneCompound
|
|
4923
5112
|
};
|
|
4924
5113
|
});
|
|
4925
|
-
const numItems = (0,
|
|
5114
|
+
const numItems = (0, import_react26.useRef)(0);
|
|
4926
5115
|
const onDragFinished = useOnDragFinished(
|
|
4927
5116
|
(finished) => {
|
|
4928
5117
|
var _a;
|
|
@@ -4957,7 +5146,7 @@ var useMinEmptyHeight = ({
|
|
|
4957
5146
|
},
|
|
4958
5147
|
[appStore, prevHeight, zoneCompound]
|
|
4959
5148
|
);
|
|
4960
|
-
(0,
|
|
5149
|
+
(0, import_react26.useEffect)(() => {
|
|
4961
5150
|
if (draggedItem && ref.current) {
|
|
4962
5151
|
if (isZone) {
|
|
4963
5152
|
const rect = ref.current.getBoundingClientRect();
|
|
@@ -4988,15 +5177,15 @@ function assignRefs(refs, node) {
|
|
|
4988
5177
|
|
|
4989
5178
|
// components/DropZone/lib/use-content-with-preview.ts
|
|
4990
5179
|
init_react_import();
|
|
4991
|
-
var
|
|
5180
|
+
var import_react29 = require("react");
|
|
4992
5181
|
|
|
4993
5182
|
// lib/dnd/use-rendered-callback.ts
|
|
4994
5183
|
init_react_import();
|
|
4995
|
-
var
|
|
4996
|
-
var
|
|
5184
|
+
var import_react27 = require("@dnd-kit/react");
|
|
5185
|
+
var import_react28 = require("react");
|
|
4997
5186
|
function useRenderedCallback(callback, deps) {
|
|
4998
|
-
const manager = (0,
|
|
4999
|
-
return (0,
|
|
5187
|
+
const manager = (0, import_react27.useDragDropManager)();
|
|
5188
|
+
return (0, import_react28.useCallback)(
|
|
5000
5189
|
(...args) => __async(this, null, function* () {
|
|
5001
5190
|
yield manager == null ? void 0 : manager.renderer.rendering;
|
|
5002
5191
|
return callback(...args);
|
|
@@ -5007,14 +5196,14 @@ function useRenderedCallback(callback, deps) {
|
|
|
5007
5196
|
|
|
5008
5197
|
// components/DropZone/lib/use-content-with-preview.ts
|
|
5009
5198
|
var useContentIdsWithPreview = (contentIds, zoneCompound) => {
|
|
5010
|
-
const zoneStore = (0,
|
|
5199
|
+
const zoneStore = (0, import_react29.useContext)(ZoneStoreContext);
|
|
5011
5200
|
const preview = useContextStore(
|
|
5012
5201
|
ZoneStoreContext,
|
|
5013
5202
|
(s) => s.previewIndex[zoneCompound]
|
|
5014
5203
|
);
|
|
5015
5204
|
const isDragging = useAppStore((s) => s.state.ui.isDragging);
|
|
5016
|
-
const [contentIdsWithPreview, setContentIdsWithPreview] = (0,
|
|
5017
|
-
const [localPreview, setLocalPreview] = (0,
|
|
5205
|
+
const [contentIdsWithPreview, setContentIdsWithPreview] = (0, import_react29.useState)(contentIds);
|
|
5206
|
+
const [localPreview, setLocalPreview] = (0, import_react29.useState)(
|
|
5018
5207
|
preview
|
|
5019
5208
|
);
|
|
5020
5209
|
const updateContent = useRenderedCallback(
|
|
@@ -5049,7 +5238,7 @@ var useContentIdsWithPreview = (contentIds, zoneCompound) => {
|
|
|
5049
5238
|
},
|
|
5050
5239
|
[]
|
|
5051
5240
|
);
|
|
5052
|
-
(0,
|
|
5241
|
+
(0, import_react29.useEffect)(() => {
|
|
5053
5242
|
var _a;
|
|
5054
5243
|
const s = zoneStore.getState();
|
|
5055
5244
|
const draggedItemId = (_a = s.draggedItem) == null ? void 0 : _a.id;
|
|
@@ -5067,16 +5256,16 @@ var useContentIdsWithPreview = (contentIds, zoneCompound) => {
|
|
|
5067
5256
|
|
|
5068
5257
|
// components/DropZone/lib/use-drag-axis.ts
|
|
5069
5258
|
init_react_import();
|
|
5070
|
-
var
|
|
5259
|
+
var import_react30 = require("react");
|
|
5071
5260
|
var GRID_DRAG_AXIS = "dynamic";
|
|
5072
5261
|
var FLEX_ROW_DRAG_AXIS = "x";
|
|
5073
5262
|
var DEFAULT_DRAG_AXIS = "y";
|
|
5074
5263
|
var useDragAxis = (ref, collisionAxis) => {
|
|
5075
5264
|
const status = useAppStore((s) => s.status);
|
|
5076
|
-
const [dragAxis, setDragAxis] = (0,
|
|
5265
|
+
const [dragAxis, setDragAxis] = (0, import_react30.useState)(
|
|
5077
5266
|
collisionAxis || DEFAULT_DRAG_AXIS
|
|
5078
5267
|
);
|
|
5079
|
-
const calculateDragAxis = (0,
|
|
5268
|
+
const calculateDragAxis = (0, import_react30.useCallback)(() => {
|
|
5080
5269
|
if (ref.current) {
|
|
5081
5270
|
const computedStyle = window.getComputedStyle(ref.current);
|
|
5082
5271
|
if (computedStyle.display === "grid") {
|
|
@@ -5088,7 +5277,7 @@ var useDragAxis = (ref, collisionAxis) => {
|
|
|
5088
5277
|
}
|
|
5089
5278
|
}
|
|
5090
5279
|
}, [ref.current]);
|
|
5091
|
-
(0,
|
|
5280
|
+
(0, import_react30.useEffect)(() => {
|
|
5092
5281
|
const onViewportChange = () => {
|
|
5093
5282
|
calculateDragAxis();
|
|
5094
5283
|
};
|
|
@@ -5097,21 +5286,21 @@ var useDragAxis = (ref, collisionAxis) => {
|
|
|
5097
5286
|
window.removeEventListener("viewportchange", onViewportChange);
|
|
5098
5287
|
};
|
|
5099
5288
|
}, []);
|
|
5100
|
-
(0,
|
|
5289
|
+
(0, import_react30.useEffect)(calculateDragAxis, [status, collisionAxis]);
|
|
5101
5290
|
return [dragAxis, calculateDragAxis];
|
|
5102
5291
|
};
|
|
5103
5292
|
|
|
5104
5293
|
// components/DropZone/index.tsx
|
|
5105
|
-
var
|
|
5294
|
+
var import_shallow5 = require("zustand/react/shallow");
|
|
5106
5295
|
|
|
5107
5296
|
// components/Render/index.tsx
|
|
5108
5297
|
init_react_import();
|
|
5109
5298
|
|
|
5110
5299
|
// lib/use-slots.tsx
|
|
5111
5300
|
init_react_import();
|
|
5112
|
-
var
|
|
5301
|
+
var import_react31 = require("react");
|
|
5113
5302
|
function useSlots(config, item, renderSlotEdit, renderSlotRender = renderSlotEdit, readOnly, forceReadOnly) {
|
|
5114
|
-
const slotProps = (0,
|
|
5303
|
+
const slotProps = (0, import_react31.useMemo)(() => {
|
|
5115
5304
|
const mapped = mapSlots(
|
|
5116
5305
|
item,
|
|
5117
5306
|
(content, _parentId, propName, field, propPath) => {
|
|
@@ -5131,7 +5320,7 @@ function useSlots(config, item, renderSlotEdit, renderSlotRender = renderSlotEdi
|
|
|
5131
5320
|
).props;
|
|
5132
5321
|
return mapped;
|
|
5133
5322
|
}, [config, item, readOnly, forceReadOnly]);
|
|
5134
|
-
const mergedProps = (0,
|
|
5323
|
+
const mergedProps = (0, import_react31.useMemo)(
|
|
5135
5324
|
() => __spreadValues(__spreadValues({}, item.props), slotProps),
|
|
5136
5325
|
[item.props, slotProps]
|
|
5137
5326
|
);
|
|
@@ -5139,15 +5328,15 @@ function useSlots(config, item, renderSlotEdit, renderSlotRender = renderSlotEdi
|
|
|
5139
5328
|
}
|
|
5140
5329
|
|
|
5141
5330
|
// components/Render/index.tsx
|
|
5142
|
-
var
|
|
5331
|
+
var import_react33 = __toESM(require("react"));
|
|
5143
5332
|
|
|
5144
5333
|
// components/SlotRender/index.tsx
|
|
5145
5334
|
init_react_import();
|
|
5146
|
-
var
|
|
5335
|
+
var import_shallow4 = require("zustand/react/shallow");
|
|
5147
5336
|
|
|
5148
5337
|
// components/SlotRender/server.tsx
|
|
5149
5338
|
init_react_import();
|
|
5150
|
-
var
|
|
5339
|
+
var import_react32 = require("react");
|
|
5151
5340
|
|
|
5152
5341
|
// components/ServerRender/index.tsx
|
|
5153
5342
|
init_react_import();
|
|
@@ -5216,7 +5405,7 @@ var Item = ({
|
|
|
5216
5405
|
})
|
|
5217
5406
|
);
|
|
5218
5407
|
};
|
|
5219
|
-
var SlotRender = (0,
|
|
5408
|
+
var SlotRender = (0, import_react32.forwardRef)(
|
|
5220
5409
|
function SlotRenderInternal({ className, style, content, config, metadata }, ref) {
|
|
5221
5410
|
return /* @__PURE__ */ (0, import_jsx_runtime22.jsx)("div", { className, style, ref, children: content.map((item) => {
|
|
5222
5411
|
if (!config.components[item.type]) {
|
|
@@ -5244,7 +5433,7 @@ var ContextSlotRender = ({
|
|
|
5244
5433
|
const config = useAppStore((s) => s.config);
|
|
5245
5434
|
const metadata = useAppStore((s) => s.metadata);
|
|
5246
5435
|
const slotContent = useAppStore(
|
|
5247
|
-
(0,
|
|
5436
|
+
(0, import_shallow4.useShallow)((s) => {
|
|
5248
5437
|
var _a, _b;
|
|
5249
5438
|
const indexes = s.state.indexes;
|
|
5250
5439
|
const contentIds = (_b = (_a = indexes.zones[`${componentId}:${zone}`]) == null ? void 0 : _a.contentIds) != null ? _b : [];
|
|
@@ -5264,7 +5453,7 @@ var ContextSlotRender = ({
|
|
|
5264
5453
|
|
|
5265
5454
|
// components/Render/index.tsx
|
|
5266
5455
|
var import_jsx_runtime24 = require("react/jsx-runtime");
|
|
5267
|
-
var renderContext =
|
|
5456
|
+
var renderContext = import_react33.default.createContext({
|
|
5268
5457
|
config: { components: {} },
|
|
5269
5458
|
data: { root: {}, content: [] },
|
|
5270
5459
|
metadata: {}
|
|
@@ -5297,7 +5486,7 @@ function Render({
|
|
|
5297
5486
|
{ type: "root", props: pageProps },
|
|
5298
5487
|
(props) => /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(SlotRender, __spreadProps(__spreadValues({}, props), { config, metadata }))
|
|
5299
5488
|
);
|
|
5300
|
-
const nextContextValue = (0,
|
|
5489
|
+
const nextContextValue = (0, import_react33.useMemo)(
|
|
5301
5490
|
() => ({
|
|
5302
5491
|
mode: "render",
|
|
5303
5492
|
depth: 0
|
|
@@ -5326,11 +5515,11 @@ var DropZoneChild = ({
|
|
|
5326
5515
|
}) => {
|
|
5327
5516
|
var _a, _b;
|
|
5328
5517
|
const metadata = useAppStore((s) => s.metadata);
|
|
5329
|
-
const ctx = (0,
|
|
5518
|
+
const ctx = (0, import_react34.useContext)(dropZoneContext);
|
|
5330
5519
|
const { depth = 1 } = ctx != null ? ctx : {};
|
|
5331
|
-
const zoneStore = (0,
|
|
5520
|
+
const zoneStore = (0, import_react34.useContext)(ZoneStoreContext);
|
|
5332
5521
|
const nodeProps = useAppStore(
|
|
5333
|
-
(0,
|
|
5522
|
+
(0, import_shallow5.useShallow)((s) => {
|
|
5334
5523
|
var _a2;
|
|
5335
5524
|
return (_a2 = s.state.indexes.nodes[componentId]) == null ? void 0 : _a2.flatData.props;
|
|
5336
5525
|
})
|
|
@@ -5342,13 +5531,13 @@ var DropZoneChild = ({
|
|
|
5342
5531
|
}
|
|
5343
5532
|
);
|
|
5344
5533
|
const nodeReadOnly = useAppStore(
|
|
5345
|
-
(0,
|
|
5534
|
+
(0, import_shallow5.useShallow)((s) => {
|
|
5346
5535
|
var _a2;
|
|
5347
5536
|
return (_a2 = s.state.indexes.nodes[componentId]) == null ? void 0 : _a2.data.readOnly;
|
|
5348
5537
|
})
|
|
5349
5538
|
);
|
|
5350
5539
|
const appStore = useAppStoreApi();
|
|
5351
|
-
const item = (0,
|
|
5540
|
+
const item = (0, import_react34.useMemo)(() => {
|
|
5352
5541
|
if (nodeProps) {
|
|
5353
5542
|
const expanded = expandNode({
|
|
5354
5543
|
type: nodeType,
|
|
@@ -5361,7 +5550,8 @@ var DropZoneChild = ({
|
|
|
5361
5550
|
return {
|
|
5362
5551
|
type: preview.componentType,
|
|
5363
5552
|
props: preview.props,
|
|
5364
|
-
previewType: preview.type
|
|
5553
|
+
previewType: preview.type,
|
|
5554
|
+
element: preview.element
|
|
5365
5555
|
};
|
|
5366
5556
|
}
|
|
5367
5557
|
return null;
|
|
@@ -5369,7 +5559,7 @@ var DropZoneChild = ({
|
|
|
5369
5559
|
const componentConfig = useAppStore(
|
|
5370
5560
|
(s) => (item == null ? void 0 : item.type) ? s.config.components[item.type] : null
|
|
5371
5561
|
);
|
|
5372
|
-
const puckProps = (0,
|
|
5562
|
+
const puckProps = (0, import_react34.useMemo)(
|
|
5373
5563
|
() => ({
|
|
5374
5564
|
renderDropZone: DropZoneEditPure,
|
|
5375
5565
|
isEditing: true,
|
|
@@ -5392,13 +5582,20 @@ var DropZoneChild = ({
|
|
|
5392
5582
|
}
|
|
5393
5583
|
);
|
|
5394
5584
|
let label = (_b = (_a = componentConfig == null ? void 0 : componentConfig.label) != null ? _a : item == null ? void 0 : item.type.toString()) != null ? _b : "Component";
|
|
5395
|
-
const renderPreview = (0,
|
|
5585
|
+
const renderPreview = (0, import_react34.useMemo)(
|
|
5396
5586
|
() => function Preview3() {
|
|
5397
|
-
|
|
5587
|
+
var _a2;
|
|
5588
|
+
if (item && "element" in item && item.element) {
|
|
5589
|
+
return (
|
|
5590
|
+
// Safe to use this since the HTML is set by the user
|
|
5591
|
+
/* @__PURE__ */ (0, import_jsx_runtime25.jsx)("div", { dangerouslySetInnerHTML: { __html: item.element.outerHTML } })
|
|
5592
|
+
);
|
|
5593
|
+
}
|
|
5594
|
+
return /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(DrawerItemInner, { name: label, children: (_a2 = overrides.componentItem) != null ? _a2 : overrides.drawerItem });
|
|
5398
5595
|
},
|
|
5399
5596
|
[componentId, label, overrides]
|
|
5400
5597
|
);
|
|
5401
|
-
const defaultsProps = (0,
|
|
5598
|
+
const defaultsProps = (0, import_react34.useMemo)(
|
|
5402
5599
|
() => __spreadProps(__spreadValues(__spreadValues({}, componentConfig == null ? void 0 : componentConfig.defaultProps), item == null ? void 0 : item.props), {
|
|
5403
5600
|
puck: puckProps,
|
|
5404
5601
|
editMode: true
|
|
@@ -5406,7 +5603,7 @@ var DropZoneChild = ({
|
|
|
5406
5603
|
}),
|
|
5407
5604
|
[componentConfig == null ? void 0 : componentConfig.defaultProps, item == null ? void 0 : item.props, puckProps]
|
|
5408
5605
|
);
|
|
5409
|
-
const defaultedNode = (0,
|
|
5606
|
+
const defaultedNode = (0, import_react34.useMemo)(
|
|
5410
5607
|
() => {
|
|
5411
5608
|
var _a2;
|
|
5412
5609
|
return { type: (_a2 = item == null ? void 0 : item.type) != null ? _a2 : nodeType, props: defaultsProps };
|
|
@@ -5457,8 +5654,8 @@ var DropZoneChild = ({
|
|
|
5457
5654
|
}
|
|
5458
5655
|
);
|
|
5459
5656
|
};
|
|
5460
|
-
var DropZoneChildMemo = (0,
|
|
5461
|
-
var DropZoneEdit = (0,
|
|
5657
|
+
var DropZoneChildMemo = (0, import_react34.memo)(DropZoneChild);
|
|
5658
|
+
var DropZoneEdit = (0, import_react34.forwardRef)(
|
|
5462
5659
|
function DropZoneEditInternal({
|
|
5463
5660
|
zone,
|
|
5464
5661
|
allow,
|
|
@@ -5468,7 +5665,8 @@ var DropZoneEdit = (0, import_react35.forwardRef)(
|
|
|
5468
5665
|
minEmptyHeight: userMinEmptyHeight = 128,
|
|
5469
5666
|
collisionAxis
|
|
5470
5667
|
}, userRef) {
|
|
5471
|
-
const ctx = (0,
|
|
5668
|
+
const ctx = (0, import_react34.useContext)(dropZoneContext);
|
|
5669
|
+
const appStoreApi = useAppStoreApi();
|
|
5472
5670
|
const {
|
|
5473
5671
|
// These all need setting via context
|
|
5474
5672
|
areaId,
|
|
@@ -5477,7 +5675,7 @@ var DropZoneEdit = (0, import_react35.forwardRef)(
|
|
|
5477
5675
|
unregisterLocalZone
|
|
5478
5676
|
} = ctx != null ? ctx : {};
|
|
5479
5677
|
const path = useAppStore(
|
|
5480
|
-
(0,
|
|
5678
|
+
(0, import_shallow5.useShallow)((s) => {
|
|
5481
5679
|
var _a;
|
|
5482
5680
|
return areaId ? (_a = s.state.indexes.nodes[areaId]) == null ? void 0 : _a.path : null;
|
|
5483
5681
|
})
|
|
@@ -5494,30 +5692,25 @@ var DropZoneEdit = (0, import_react35.forwardRef)(
|
|
|
5494
5692
|
(s) => s.nextAreaDepthIndex[areaId || ""]
|
|
5495
5693
|
);
|
|
5496
5694
|
const zoneContentIds = useAppStore(
|
|
5497
|
-
(0,
|
|
5695
|
+
(0, import_shallow5.useShallow)((s) => {
|
|
5498
5696
|
var _a;
|
|
5499
5697
|
return (_a = s.state.indexes.zones[zoneCompound]) == null ? void 0 : _a.contentIds;
|
|
5500
5698
|
})
|
|
5501
5699
|
);
|
|
5502
5700
|
const zoneType = useAppStore(
|
|
5503
|
-
(0,
|
|
5701
|
+
(0, import_shallow5.useShallow)((s) => {
|
|
5504
5702
|
var _a;
|
|
5505
5703
|
return (_a = s.state.indexes.zones[zoneCompound]) == null ? void 0 : _a.type;
|
|
5506
5704
|
})
|
|
5507
5705
|
);
|
|
5508
|
-
(0,
|
|
5706
|
+
(0, import_react34.useEffect)(() => {
|
|
5509
5707
|
if (!zoneType || zoneType === "dropzone") {
|
|
5510
5708
|
if (ctx == null ? void 0 : ctx.registerZone) {
|
|
5511
5709
|
ctx == null ? void 0 : ctx.registerZone(zoneCompound);
|
|
5512
5710
|
}
|
|
5513
|
-
return () => {
|
|
5514
|
-
if (ctx == null ? void 0 : ctx.unregisterZone) {
|
|
5515
|
-
ctx == null ? void 0 : ctx.unregisterZone(zoneCompound);
|
|
5516
|
-
}
|
|
5517
|
-
};
|
|
5518
5711
|
}
|
|
5519
|
-
}, [zoneType]);
|
|
5520
|
-
(0,
|
|
5712
|
+
}, [zoneType, appStoreApi]);
|
|
5713
|
+
(0, import_react34.useEffect)(() => {
|
|
5521
5714
|
if (zoneType === "dropzone") {
|
|
5522
5715
|
if (zoneCompound !== rootDroppableId) {
|
|
5523
5716
|
console.warn(
|
|
@@ -5526,11 +5719,11 @@ var DropZoneEdit = (0, import_react35.forwardRef)(
|
|
|
5526
5719
|
}
|
|
5527
5720
|
}
|
|
5528
5721
|
}, [zoneType]);
|
|
5529
|
-
const contentIds = (0,
|
|
5722
|
+
const contentIds = (0, import_react34.useMemo)(() => {
|
|
5530
5723
|
return zoneContentIds || [];
|
|
5531
5724
|
}, [zoneContentIds]);
|
|
5532
|
-
const ref = (0,
|
|
5533
|
-
const acceptsTarget = (0,
|
|
5725
|
+
const ref = (0, import_react34.useRef)(null);
|
|
5726
|
+
const acceptsTarget = (0, import_react34.useCallback)(
|
|
5534
5727
|
(componentType) => {
|
|
5535
5728
|
if (!componentType) {
|
|
5536
5729
|
return true;
|
|
@@ -5568,7 +5761,7 @@ var DropZoneEdit = (0, import_react35.forwardRef)(
|
|
|
5568
5761
|
}
|
|
5569
5762
|
return _isEnabled;
|
|
5570
5763
|
});
|
|
5571
|
-
(0,
|
|
5764
|
+
(0, import_react34.useEffect)(() => {
|
|
5572
5765
|
if (registerLocalZone) {
|
|
5573
5766
|
registerLocalZone(zoneCompound, targetAccepted || isEnabled);
|
|
5574
5767
|
}
|
|
@@ -5583,8 +5776,8 @@ var DropZoneEdit = (0, import_react35.forwardRef)(
|
|
|
5583
5776
|
zoneCompound
|
|
5584
5777
|
);
|
|
5585
5778
|
const isDropEnabled = isEnabled && (preview ? contentIdsWithPreview.length === 1 : contentIdsWithPreview.length === 0);
|
|
5586
|
-
const zoneStore = (0,
|
|
5587
|
-
(0,
|
|
5779
|
+
const zoneStore = (0, import_react34.useContext)(ZoneStoreContext);
|
|
5780
|
+
(0, import_react34.useEffect)(() => {
|
|
5588
5781
|
const { enabledIndex } = zoneStore.getState();
|
|
5589
5782
|
zoneStore.setState({
|
|
5590
5783
|
enabledIndex: __spreadProps(__spreadValues({}, enabledIndex), { [zoneCompound]: isEnabled })
|
|
@@ -5603,7 +5796,7 @@ var DropZoneEdit = (0, import_react35.forwardRef)(
|
|
|
5603
5796
|
path: path || []
|
|
5604
5797
|
}
|
|
5605
5798
|
};
|
|
5606
|
-
const { ref: dropRef } = (0,
|
|
5799
|
+
const { ref: dropRef } = (0, import_react35.useDroppable)(droppableConfig);
|
|
5607
5800
|
const isAreaSelected = useAppStore(
|
|
5608
5801
|
(s) => (s == null ? void 0 : s.selectedItem) && areaId === (s == null ? void 0 : s.selectedItem.props.id)
|
|
5609
5802
|
);
|
|
@@ -5658,7 +5851,7 @@ var DropZoneRenderItem = ({
|
|
|
5658
5851
|
}) => {
|
|
5659
5852
|
const Component = config.components[item.type];
|
|
5660
5853
|
const props = useSlots(config, item, (slotProps) => /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(SlotRenderPure, __spreadProps(__spreadValues({}, slotProps), { config, metadata })));
|
|
5661
|
-
const nextContextValue = (0,
|
|
5854
|
+
const nextContextValue = (0, import_react34.useMemo)(
|
|
5662
5855
|
() => ({
|
|
5663
5856
|
areaId: props.id,
|
|
5664
5857
|
depth: 1
|
|
@@ -5676,23 +5869,18 @@ var DropZoneRenderItem = ({
|
|
|
5676
5869
|
) }, props.id);
|
|
5677
5870
|
};
|
|
5678
5871
|
var DropZoneRenderPure = (props) => /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(DropZoneRender2, __spreadValues({}, props));
|
|
5679
|
-
var DropZoneRender2 = (0,
|
|
5872
|
+
var DropZoneRender2 = (0, import_react34.forwardRef)(
|
|
5680
5873
|
function DropZoneRenderInternal({ className, style, zone }, ref) {
|
|
5681
|
-
const ctx = (0,
|
|
5874
|
+
const ctx = (0, import_react34.useContext)(dropZoneContext);
|
|
5682
5875
|
const { areaId = "root" } = ctx || {};
|
|
5683
|
-
const { config, data, metadata } = (0,
|
|
5876
|
+
const { config, data, metadata } = (0, import_react34.useContext)(renderContext);
|
|
5684
5877
|
let zoneCompound = `${areaId}:${zone}`;
|
|
5685
5878
|
let content = (data == null ? void 0 : data.content) || [];
|
|
5686
|
-
(0,
|
|
5879
|
+
(0, import_react34.useEffect)(() => {
|
|
5687
5880
|
if (!content) {
|
|
5688
5881
|
if (ctx == null ? void 0 : ctx.registerZone) {
|
|
5689
5882
|
ctx == null ? void 0 : ctx.registerZone(zoneCompound);
|
|
5690
5883
|
}
|
|
5691
|
-
return () => {
|
|
5692
|
-
if (ctx == null ? void 0 : ctx.unregisterZone) {
|
|
5693
|
-
ctx == null ? void 0 : ctx.unregisterZone(zoneCompound);
|
|
5694
|
-
}
|
|
5695
|
-
};
|
|
5696
5884
|
}
|
|
5697
5885
|
}, [content]);
|
|
5698
5886
|
if (!data || !config) {
|
|
@@ -5719,9 +5907,9 @@ var DropZoneRender2 = (0, import_react35.forwardRef)(
|
|
|
5719
5907
|
}
|
|
5720
5908
|
);
|
|
5721
5909
|
var DropZonePure = (props) => /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(DropZone, __spreadValues({}, props));
|
|
5722
|
-
var DropZone = (0,
|
|
5910
|
+
var DropZone = (0, import_react34.forwardRef)(
|
|
5723
5911
|
function DropZone2(props, ref) {
|
|
5724
|
-
const ctx = (0,
|
|
5912
|
+
const ctx = (0, import_react34.useContext)(dropZoneContext);
|
|
5725
5913
|
if ((ctx == null ? void 0 : ctx.mode) === "edit") {
|
|
5726
5914
|
return /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(import_jsx_runtime25.Fragment, { children: /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(DropZoneEdit, __spreadProps(__spreadValues({}, props), { ref })) });
|
|
5727
5915
|
}
|
|
@@ -5953,6 +6141,7 @@ var findDeepestCandidate = (position, manager) => {
|
|
|
5953
6141
|
});
|
|
5954
6142
|
filteredCandidates.reverse();
|
|
5955
6143
|
const primaryCandidate = filteredCandidates[0];
|
|
6144
|
+
if (!primaryCandidate) return { zone: null, area: null };
|
|
5956
6145
|
const primaryCandidateData = primaryCandidate.data;
|
|
5957
6146
|
const primaryCandidateIsComponent = "containsActiveZone" in primaryCandidateData;
|
|
5958
6147
|
const zone = getZoneId2(primaryCandidate);
|
|
@@ -6062,12 +6251,12 @@ function getDeepDir(el) {
|
|
|
6062
6251
|
var import_state = require("@dnd-kit/state");
|
|
6063
6252
|
var import_jsx_runtime26 = require("react/jsx-runtime");
|
|
6064
6253
|
var DEBUG3 = false;
|
|
6065
|
-
var dragListenerContext = (0,
|
|
6254
|
+
var dragListenerContext = (0, import_react37.createContext)({
|
|
6066
6255
|
dragListeners: {}
|
|
6067
6256
|
});
|
|
6068
6257
|
function useDragListener(type, fn, deps = []) {
|
|
6069
|
-
const { setDragListeners } = (0,
|
|
6070
|
-
(0,
|
|
6258
|
+
const { setDragListeners } = (0, import_react37.useContext)(dragListenerContext);
|
|
6259
|
+
(0, import_react37.useEffect)(() => {
|
|
6071
6260
|
if (setDragListeners) {
|
|
6072
6261
|
setDragListeners((old) => __spreadProps(__spreadValues({}, old), {
|
|
6073
6262
|
[type]: [...old[type] || [], fn]
|
|
@@ -6077,8 +6266,8 @@ function useDragListener(type, fn, deps = []) {
|
|
|
6077
6266
|
}
|
|
6078
6267
|
var AREA_CHANGE_DEBOUNCE_MS = 100;
|
|
6079
6268
|
var useTempDisableFallback = (timeout3) => {
|
|
6080
|
-
const lastFallbackDisable = (0,
|
|
6081
|
-
return (0,
|
|
6269
|
+
const lastFallbackDisable = (0, import_react37.useRef)(null);
|
|
6270
|
+
return (0, import_react37.useCallback)((manager) => {
|
|
6082
6271
|
collisionStore.setState({ fallbackEnabled: false });
|
|
6083
6272
|
const fallbackId = generateId();
|
|
6084
6273
|
lastFallbackDisable.current = fallbackId;
|
|
@@ -6097,9 +6286,9 @@ var DragDropContextClient = ({
|
|
|
6097
6286
|
const dispatch = useAppStore((s) => s.dispatch);
|
|
6098
6287
|
const appStore = useAppStoreApi();
|
|
6099
6288
|
const id = useSafeId();
|
|
6100
|
-
const debouncedParamsRef = (0,
|
|
6289
|
+
const debouncedParamsRef = (0, import_react37.useRef)(null);
|
|
6101
6290
|
const tempDisableFallback = useTempDisableFallback(100);
|
|
6102
|
-
const [zoneStore] = (0,
|
|
6291
|
+
const [zoneStore] = (0, import_react37.useState)(
|
|
6103
6292
|
() => (0, import_zustand5.createStore)(() => ({
|
|
6104
6293
|
zoneDepthIndex: {},
|
|
6105
6294
|
nextZoneDepthIndex: {},
|
|
@@ -6111,7 +6300,7 @@ var DragDropContextClient = ({
|
|
|
6111
6300
|
hoveringComponent: null
|
|
6112
6301
|
}))
|
|
6113
6302
|
);
|
|
6114
|
-
const getChanged2 = (0,
|
|
6303
|
+
const getChanged2 = (0, import_react37.useCallback)(
|
|
6115
6304
|
(params, id2) => {
|
|
6116
6305
|
const { zoneDepthIndex = {}, areaDepthIndex = {} } = zoneStore.getState() || {};
|
|
6117
6306
|
const stateHasZone = Object.keys(zoneDepthIndex).length > 0;
|
|
@@ -6132,7 +6321,7 @@ var DragDropContextClient = ({
|
|
|
6132
6321
|
},
|
|
6133
6322
|
[zoneStore]
|
|
6134
6323
|
);
|
|
6135
|
-
const setDeepestAndCollide = (0,
|
|
6324
|
+
const setDeepestAndCollide = (0, import_react37.useCallback)(
|
|
6136
6325
|
(params, manager) => {
|
|
6137
6326
|
const { zoneChanged, areaChanged } = getChanged2(params, id);
|
|
6138
6327
|
if (!zoneChanged && !areaChanged) return;
|
|
@@ -6156,7 +6345,7 @@ var DragDropContextClient = ({
|
|
|
6156
6345
|
setDeepestDb.cancel();
|
|
6157
6346
|
debouncedParamsRef.current = null;
|
|
6158
6347
|
};
|
|
6159
|
-
(0,
|
|
6348
|
+
(0, import_react37.useEffect)(() => {
|
|
6160
6349
|
if (DEBUG3) {
|
|
6161
6350
|
zoneStore.subscribe(
|
|
6162
6351
|
(s) => {
|
|
@@ -6170,7 +6359,7 @@ var DragDropContextClient = ({
|
|
|
6170
6359
|
);
|
|
6171
6360
|
}
|
|
6172
6361
|
}, []);
|
|
6173
|
-
const [plugins] = (0,
|
|
6362
|
+
const [plugins] = (0, import_react37.useState)(() => [
|
|
6174
6363
|
...disableAutoScroll ? import_dom.defaultPreset.plugins.filter((plugin) => plugin !== import_dom.AutoScroller) : import_dom.defaultPreset.plugins,
|
|
6175
6364
|
createNestedDroppablePlugin(
|
|
6176
6365
|
{
|
|
@@ -6218,10 +6407,10 @@ var DragDropContextClient = ({
|
|
|
6218
6407
|
)
|
|
6219
6408
|
]);
|
|
6220
6409
|
const sensors = useSensors();
|
|
6221
|
-
const [dragListeners, setDragListeners] = (0,
|
|
6222
|
-
const dragMode = (0,
|
|
6223
|
-
const initialSelector = (0,
|
|
6224
|
-
const nextContextValue = (0,
|
|
6410
|
+
const [dragListeners, setDragListeners] = (0, import_react37.useState)({});
|
|
6411
|
+
const dragMode = (0, import_react37.useRef)(null);
|
|
6412
|
+
const initialSelector = (0, import_react37.useRef)(void 0);
|
|
6413
|
+
const nextContextValue = (0, import_react37.useMemo)(
|
|
6225
6414
|
() => ({
|
|
6226
6415
|
mode: "edit",
|
|
6227
6416
|
areaId: "root",
|
|
@@ -6237,7 +6426,7 @@ var DragDropContextClient = ({
|
|
|
6237
6426
|
setDragListeners
|
|
6238
6427
|
},
|
|
6239
6428
|
children: /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(
|
|
6240
|
-
|
|
6429
|
+
import_react36.DragDropProvider,
|
|
6241
6430
|
{
|
|
6242
6431
|
plugins,
|
|
6243
6432
|
sensors,
|
|
@@ -6357,6 +6546,7 @@ var DragDropContextClient = ({
|
|
|
6357
6546
|
type: "insert",
|
|
6358
6547
|
index: targetIndex,
|
|
6359
6548
|
zone: targetZone,
|
|
6549
|
+
element: source.element,
|
|
6360
6550
|
props: {
|
|
6361
6551
|
id: source.id.toString()
|
|
6362
6552
|
}
|
|
@@ -6382,7 +6572,8 @@ var DragDropContextClient = ({
|
|
|
6382
6572
|
type: "move",
|
|
6383
6573
|
index: targetIndex,
|
|
6384
6574
|
zone: targetZone,
|
|
6385
|
-
props: item.props
|
|
6575
|
+
props: item.props,
|
|
6576
|
+
element: source.element
|
|
6386
6577
|
}
|
|
6387
6578
|
}
|
|
6388
6579
|
});
|
|
@@ -6412,7 +6603,8 @@ var DragDropContextClient = ({
|
|
|
6412
6603
|
type: "move",
|
|
6413
6604
|
index: sourceData.index,
|
|
6414
6605
|
zone: sourceData.zone,
|
|
6415
|
-
props: item.props
|
|
6606
|
+
props: item.props,
|
|
6607
|
+
element: source.element
|
|
6416
6608
|
}
|
|
6417
6609
|
}
|
|
6418
6610
|
});
|
|
@@ -6467,7 +6659,7 @@ var DragDropContext = ({
|
|
|
6467
6659
|
};
|
|
6468
6660
|
|
|
6469
6661
|
// components/Drawer/index.tsx
|
|
6470
|
-
var
|
|
6662
|
+
var import_react39 = require("@dnd-kit/react");
|
|
6471
6663
|
var import_jsx_runtime27 = require("react/jsx-runtime");
|
|
6472
6664
|
var getClassName18 = get_class_name_factory_default("Drawer", styles_module_default10);
|
|
6473
6665
|
var getClassNameItem2 = get_class_name_factory_default("DrawerItem", styles_module_default10);
|
|
@@ -6478,7 +6670,7 @@ var DrawerItemInner = ({
|
|
|
6478
6670
|
dragRef,
|
|
6479
6671
|
isDragDisabled
|
|
6480
6672
|
}) => {
|
|
6481
|
-
const CustomInner = (0,
|
|
6673
|
+
const CustomInner = (0, import_react38.useMemo)(
|
|
6482
6674
|
() => children || (({ children: children2 }) => /* @__PURE__ */ (0, import_jsx_runtime27.jsx)("div", { className: getClassNameItem2("default"), children: children2 })),
|
|
6483
6675
|
[children]
|
|
6484
6676
|
);
|
|
@@ -6504,7 +6696,7 @@ var DrawerItemDraggable = ({
|
|
|
6504
6696
|
id,
|
|
6505
6697
|
isDragDisabled
|
|
6506
6698
|
}) => {
|
|
6507
|
-
const { ref } = (0,
|
|
6699
|
+
const { ref } = (0, import_react39.useDraggable)({
|
|
6508
6700
|
id,
|
|
6509
6701
|
data: { componentType: name },
|
|
6510
6702
|
disabled: isDragDisabled,
|
|
@@ -6533,7 +6725,7 @@ var DrawerItem = ({
|
|
|
6533
6725
|
isDragDisabled
|
|
6534
6726
|
}) => {
|
|
6535
6727
|
const resolvedId = id || name;
|
|
6536
|
-
const [dynamicId, setDynamicId] = (0,
|
|
6728
|
+
const [dynamicId, setDynamicId] = (0, import_react38.useState)(generateId(resolvedId));
|
|
6537
6729
|
if (typeof index !== "undefined") {
|
|
6538
6730
|
console.error(
|
|
6539
6731
|
"Warning: The `index` prop on Drawer.Item is deprecated and no longer required."
|
|
@@ -6573,7 +6765,7 @@ var Drawer = ({
|
|
|
6573
6765
|
);
|
|
6574
6766
|
}
|
|
6575
6767
|
const id = useSafeId();
|
|
6576
|
-
const { ref } = (0,
|
|
6768
|
+
const { ref } = (0, import_react39.useDroppable)({
|
|
6577
6769
|
id,
|
|
6578
6770
|
type: "void",
|
|
6579
6771
|
collisionPriority: 0
|
|
@@ -6595,7 +6787,7 @@ Drawer.Item = DrawerItem;
|
|
|
6595
6787
|
|
|
6596
6788
|
// components/Puck/index.tsx
|
|
6597
6789
|
init_react_import();
|
|
6598
|
-
var
|
|
6790
|
+
var import_react59 = require("react");
|
|
6599
6791
|
|
|
6600
6792
|
// components/SidebarSection/index.tsx
|
|
6601
6793
|
init_react_import();
|
|
@@ -6606,7 +6798,7 @@ var styles_module_default13 = { "SidebarSection": "_SidebarSection_8boj8_1", "Si
|
|
|
6606
6798
|
|
|
6607
6799
|
// lib/use-breadcrumbs.ts
|
|
6608
6800
|
init_react_import();
|
|
6609
|
-
var
|
|
6801
|
+
var import_react40 = require("react");
|
|
6610
6802
|
var useBreadcrumbs = (renderCount) => {
|
|
6611
6803
|
const selectedId = useAppStore((s) => {
|
|
6612
6804
|
var _a;
|
|
@@ -6618,7 +6810,7 @@ var useBreadcrumbs = (renderCount) => {
|
|
|
6618
6810
|
return (_a = s.state.indexes.nodes[selectedId]) == null ? void 0 : _a.path;
|
|
6619
6811
|
});
|
|
6620
6812
|
const appStore = useAppStoreApi();
|
|
6621
|
-
return (0,
|
|
6813
|
+
return (0, import_react40.useMemo)(() => {
|
|
6622
6814
|
const breadcrumbs = (path == null ? void 0 : path.map((zoneCompound) => {
|
|
6623
6815
|
var _a, _b, _c;
|
|
6624
6816
|
const [componentId] = zoneCompound.split(":");
|
|
@@ -6692,7 +6884,7 @@ var SidebarSection = ({
|
|
|
6692
6884
|
|
|
6693
6885
|
// css-module:/home/runner/work/puck/puck/packages/core/components/Puck/styles.module.css#css-module
|
|
6694
6886
|
init_react_import();
|
|
6695
|
-
var styles_module_default14 = { "Puck": "
|
|
6887
|
+
var styles_module_default14 = { "Puck": "_Puck_vnhjy_19", "Puck-portal": "_Puck-portal_vnhjy_31", "PuckLayout-inner": "_PuckLayout-inner_vnhjy_38", "PuckLayout--mounted": "_PuckLayout--mounted_vnhjy_50", "PuckLayout--leftSideBarVisible": "_PuckLayout--leftSideBarVisible_vnhjy_54", "PuckLayout--rightSideBarVisible": "_PuckLayout--rightSideBarVisible_vnhjy_60", "PuckLayout-mounted": "_PuckLayout-mounted_vnhjy_74", "PuckLayout": "_PuckLayout_vnhjy_38" };
|
|
6696
6888
|
|
|
6697
6889
|
// components/Puck/components/Fields/index.tsx
|
|
6698
6890
|
init_react_import();
|
|
@@ -6702,8 +6894,8 @@ init_react_import();
|
|
|
6702
6894
|
var styles_module_default15 = { "PuckFields": "_PuckFields_10bh7_1", "PuckFields--isLoading": "_PuckFields--isLoading_10bh7_6", "PuckFields-loadingOverlay": "_PuckFields-loadingOverlay_10bh7_10", "PuckFields-loadingOverlayInner": "_PuckFields-loadingOverlayInner_10bh7_25", "PuckFields-field": "_PuckFields-field_10bh7_32", "PuckFields--wrapFields": "_PuckFields--wrapFields_10bh7_36" };
|
|
6703
6895
|
|
|
6704
6896
|
// components/Puck/components/Fields/index.tsx
|
|
6705
|
-
var
|
|
6706
|
-
var
|
|
6897
|
+
var import_react41 = require("react");
|
|
6898
|
+
var import_shallow6 = require("zustand/react/shallow");
|
|
6707
6899
|
var import_jsx_runtime29 = require("react/jsx-runtime");
|
|
6708
6900
|
var getClassName20 = get_class_name_factory_default("PuckFields", styles_module_default15);
|
|
6709
6901
|
var DefaultFields = ({
|
|
@@ -6769,13 +6961,13 @@ var FieldsChild = ({ fieldName }) => {
|
|
|
6769
6961
|
return s.selectedItem ? `${s.selectedItem.props.id}_${field.type}_${fieldName}` : `root_${field.type}_${fieldName}`;
|
|
6770
6962
|
});
|
|
6771
6963
|
const permissions = useAppStore(
|
|
6772
|
-
(0,
|
|
6964
|
+
(0, import_shallow6.useShallow)((s) => {
|
|
6773
6965
|
const { selectedItem, permissions: permissions2 } = s;
|
|
6774
6966
|
return selectedItem ? permissions2.getPermissions({ item: selectedItem }) : permissions2.getPermissions({ root: true });
|
|
6775
6967
|
})
|
|
6776
6968
|
);
|
|
6777
6969
|
const appStore = useAppStoreApi();
|
|
6778
|
-
const onChange = (0,
|
|
6970
|
+
const onChange = (0, import_react41.useCallback)(createOnChange(fieldName, appStore), [
|
|
6779
6971
|
fieldName
|
|
6780
6972
|
]);
|
|
6781
6973
|
const { visible = true } = field != null ? field : {};
|
|
@@ -6793,7 +6985,7 @@ var FieldsChild = ({ fieldName }) => {
|
|
|
6793
6985
|
}
|
|
6794
6986
|
) }, id);
|
|
6795
6987
|
};
|
|
6796
|
-
var FieldsChildMemo = (0,
|
|
6988
|
+
var FieldsChildMemo = (0, import_react41.memo)(FieldsChild);
|
|
6797
6989
|
var FieldsInternal = ({ wrapFields = true }) => {
|
|
6798
6990
|
const overrides = useAppStore((s) => s.overrides);
|
|
6799
6991
|
const componentResolving = useAppStore((s) => {
|
|
@@ -6801,7 +6993,7 @@ var FieldsInternal = ({ wrapFields = true }) => {
|
|
|
6801
6993
|
const loadingCount = s.selectedItem ? (_a = s.componentState[s.selectedItem.props.id]) == null ? void 0 : _a.loadingCount : (_b = s.componentState["root"]) == null ? void 0 : _b.loadingCount;
|
|
6802
6994
|
return (loadingCount != null ? loadingCount : 0) > 0;
|
|
6803
6995
|
});
|
|
6804
|
-
const itemSelector = useAppStore((0,
|
|
6996
|
+
const itemSelector = useAppStore((0, import_shallow6.useShallow)((s) => s.state.ui.itemSelector));
|
|
6805
6997
|
const id = useAppStore((s) => {
|
|
6806
6998
|
var _a;
|
|
6807
6999
|
return (_a = s.selectedItem) == null ? void 0 : _a.props.id;
|
|
@@ -6810,7 +7002,7 @@ var FieldsInternal = ({ wrapFields = true }) => {
|
|
|
6810
7002
|
useRegisterFieldsSlice(appStore, id);
|
|
6811
7003
|
const fieldsLoading = useAppStore((s) => s.fields.loading);
|
|
6812
7004
|
const fieldNames = useAppStore(
|
|
6813
|
-
(0,
|
|
7005
|
+
(0, import_shallow6.useShallow)((s) => {
|
|
6814
7006
|
if (s.fields.id === id) {
|
|
6815
7007
|
return Object.keys(s.fields.fields);
|
|
6816
7008
|
}
|
|
@@ -6818,7 +7010,7 @@ var FieldsInternal = ({ wrapFields = true }) => {
|
|
|
6818
7010
|
})
|
|
6819
7011
|
);
|
|
6820
7012
|
const isLoading = fieldsLoading || componentResolving;
|
|
6821
|
-
const Wrapper = (0,
|
|
7013
|
+
const Wrapper = (0, import_react41.useMemo)(() => overrides.fields || DefaultFields, [overrides]);
|
|
6822
7014
|
return /* @__PURE__ */ (0, import_jsx_runtime29.jsxs)(
|
|
6823
7015
|
"form",
|
|
6824
7016
|
{
|
|
@@ -6833,7 +7025,7 @@ var FieldsInternal = ({ wrapFields = true }) => {
|
|
|
6833
7025
|
}
|
|
6834
7026
|
);
|
|
6835
7027
|
};
|
|
6836
|
-
var Fields = (0,
|
|
7028
|
+
var Fields = (0, import_react41.memo)(FieldsInternal);
|
|
6837
7029
|
|
|
6838
7030
|
// components/Puck/components/Components/index.tsx
|
|
6839
7031
|
init_react_import();
|
|
@@ -6850,19 +7042,28 @@ init_react_import();
|
|
|
6850
7042
|
var styles_module_default16 = { "ComponentList": "_ComponentList_1rrlt_1", "ComponentList--isExpanded": "_ComponentList--isExpanded_1rrlt_5", "ComponentList-content": "_ComponentList-content_1rrlt_9", "ComponentList-title": "_ComponentList-title_1rrlt_17", "ComponentList-titleIcon": "_ComponentList-titleIcon_1rrlt_53" };
|
|
6851
7043
|
|
|
6852
7044
|
// components/ComponentList/index.tsx
|
|
7045
|
+
var import_react42 = require("react");
|
|
6853
7046
|
var import_jsx_runtime30 = require("react/jsx-runtime");
|
|
6854
7047
|
var getClassName21 = get_class_name_factory_default("ComponentList", styles_module_default16);
|
|
6855
7048
|
var ComponentListItem = ({
|
|
6856
7049
|
name,
|
|
6857
7050
|
label
|
|
6858
7051
|
}) => {
|
|
7052
|
+
var _a;
|
|
6859
7053
|
const overrides = useAppStore((s) => s.overrides);
|
|
6860
7054
|
const canInsert = useAppStore(
|
|
6861
7055
|
(s) => s.permissions.getPermissions({
|
|
6862
7056
|
type: name
|
|
6863
7057
|
}).insert
|
|
6864
7058
|
);
|
|
6865
|
-
|
|
7059
|
+
(0, import_react42.useEffect)(() => {
|
|
7060
|
+
if (overrides.componentItem) {
|
|
7061
|
+
console.warn(
|
|
7062
|
+
"The `componentItem` override has been deprecated and renamed to `drawerItem`"
|
|
7063
|
+
);
|
|
7064
|
+
}
|
|
7065
|
+
}, [overrides]);
|
|
7066
|
+
return /* @__PURE__ */ (0, import_jsx_runtime30.jsx)(Drawer.Item, { label, name, isDragDisabled: !canInsert, children: (_a = overrides.componentItem) != null ? _a : overrides.drawerItem });
|
|
6866
7067
|
};
|
|
6867
7068
|
var ComponentList = ({
|
|
6868
7069
|
children,
|
|
@@ -6988,7 +7189,14 @@ var import_jsx_runtime32 = require("react/jsx-runtime");
|
|
|
6988
7189
|
var Components = () => {
|
|
6989
7190
|
const overrides = useAppStore((s) => s.overrides);
|
|
6990
7191
|
const componentList = useComponentList();
|
|
6991
|
-
const Wrapper = (0, import_react44.useMemo)(() =>
|
|
7192
|
+
const Wrapper = (0, import_react44.useMemo)(() => {
|
|
7193
|
+
if (overrides.components) {
|
|
7194
|
+
console.warn(
|
|
7195
|
+
"The `components` override has been deprecated and renamed to `drawer`"
|
|
7196
|
+
);
|
|
7197
|
+
}
|
|
7198
|
+
return overrides.components || overrides.drawer || "div";
|
|
7199
|
+
}, [overrides]);
|
|
6992
7200
|
return /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(Wrapper, { children: componentList ? componentList : /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(ComponentList, { id: "all" }) });
|
|
6993
7201
|
};
|
|
6994
7202
|
|
|
@@ -7367,7 +7575,7 @@ var Preview2 = ({ id = "puck-preview" }) => {
|
|
|
7367
7575
|
editMode: true,
|
|
7368
7576
|
children: /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(DropZonePure, { zone: rootDroppableId })
|
|
7369
7577
|
})
|
|
7370
|
-
) : /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(Render, { data: renderData, config });
|
|
7578
|
+
) : /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(Render, { data: renderData, config, metadata });
|
|
7371
7579
|
(0, import_react46.useEffect)(() => {
|
|
7372
7580
|
if (!iframe.enabled) {
|
|
7373
7581
|
setStatus("READY");
|
|
@@ -7379,8 +7587,11 @@ var Preview2 = ({ id = "puck-preview" }) => {
|
|
|
7379
7587
|
className: getClassName22(),
|
|
7380
7588
|
id,
|
|
7381
7589
|
"data-puck-preview": true,
|
|
7382
|
-
onClick: () => {
|
|
7383
|
-
|
|
7590
|
+
onClick: (e) => {
|
|
7591
|
+
const el = e.target;
|
|
7592
|
+
if (!el.hasAttribute("data-puck-component") && !el.hasAttribute("data-puck-dropzone")) {
|
|
7593
|
+
dispatch({ type: "setUi", ui: { itemSelector: null } });
|
|
7594
|
+
}
|
|
7384
7595
|
},
|
|
7385
7596
|
children: iframe.enabled ? /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(
|
|
7386
7597
|
AutoFrame_default,
|
|
@@ -7460,7 +7671,7 @@ var onScrollEnd = (frame, cb) => {
|
|
|
7460
7671
|
};
|
|
7461
7672
|
|
|
7462
7673
|
// components/LayerTree/index.tsx
|
|
7463
|
-
var
|
|
7674
|
+
var import_shallow7 = require("zustand/react/shallow");
|
|
7464
7675
|
var import_jsx_runtime35 = require("react/jsx-runtime");
|
|
7465
7676
|
var getClassName23 = get_class_name_factory_default("LayerTree", styles_module_default18);
|
|
7466
7677
|
var getClassNameLayer = get_class_name_factory_default("Layer", styles_module_default18);
|
|
@@ -7486,7 +7697,7 @@ var Layer = ({
|
|
|
7486
7697
|
const isSelected = selecedItemId === itemId || itemSelector && itemSelector.zone === rootDroppableId && !zoneCompound;
|
|
7487
7698
|
const nodeData = useAppStore((s) => s.state.indexes.nodes[itemId]);
|
|
7488
7699
|
const zonesForItem = useAppStore(
|
|
7489
|
-
(0,
|
|
7700
|
+
(0, import_shallow7.useShallow)(
|
|
7490
7701
|
(s) => Object.keys(s.state.indexes.zones).filter(
|
|
7491
7702
|
(z) => z.split(":")[0] === itemId
|
|
7492
7703
|
)
|
|
@@ -7572,207 +7783,86 @@ var Layer = ({
|
|
|
7572
7783
|
}
|
|
7573
7784
|
) }),
|
|
7574
7785
|
containsZone && zonesForItem.map((subzone) => /* @__PURE__ */ (0, import_jsx_runtime35.jsx)("div", { className: getClassNameLayer("zones"), children: /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(LayerTree, { zoneCompound: subzone }) }, subzone))
|
|
7575
|
-
]
|
|
7576
|
-
}
|
|
7577
|
-
);
|
|
7578
|
-
};
|
|
7579
|
-
var LayerTree = ({
|
|
7580
|
-
label: _label,
|
|
7581
|
-
zoneCompound
|
|
7582
|
-
}) => {
|
|
7583
|
-
const label = useAppStore((s) => {
|
|
7584
|
-
var _a, _b, _c, _d;
|
|
7585
|
-
if (_label) return _label;
|
|
7586
|
-
if (zoneCompound === rootDroppableId) return;
|
|
7587
|
-
const [componentId, slotId] = zoneCompound.split(":");
|
|
7588
|
-
const componentType = (_a = s.state.indexes.nodes[componentId]) == null ? void 0 : _a.data.type;
|
|
7589
|
-
const configForComponent = componentType && componentType !== rootAreaId ? s.config.components[componentType] : s.config.root;
|
|
7590
|
-
return (_d = (_c = (_b = configForComponent == null ? void 0 : configForComponent.fields) == null ? void 0 : _b[slotId]) == null ? void 0 : _c.label) != null ? _d : slotId;
|
|
7591
|
-
});
|
|
7592
|
-
const contentIds = useAppStore(
|
|
7593
|
-
(0, import_shallow6.useShallow)(
|
|
7594
|
-
(s) => {
|
|
7595
|
-
var _a, _b;
|
|
7596
|
-
return zoneCompound ? (_b = (_a = s.state.indexes.zones[zoneCompound]) == null ? void 0 : _a.contentIds) != null ? _b : [] : [];
|
|
7597
|
-
}
|
|
7598
|
-
)
|
|
7599
|
-
);
|
|
7600
|
-
return /* @__PURE__ */ (0, import_jsx_runtime35.jsxs)(import_jsx_runtime35.Fragment, { children: [
|
|
7601
|
-
label && /* @__PURE__ */ (0, import_jsx_runtime35.jsxs)("div", { className: getClassName23("zoneTitle"), children: [
|
|
7602
|
-
/* @__PURE__ */ (0, import_jsx_runtime35.jsx)("div", { className: getClassName23("zoneIcon"), children: /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(Layers, { size: "16" }) }),
|
|
7603
|
-
label
|
|
7604
|
-
] }),
|
|
7605
|
-
/* @__PURE__ */ (0, import_jsx_runtime35.jsxs)("ul", { className: getClassName23(), children: [
|
|
7606
|
-
contentIds.length === 0 && /* @__PURE__ */ (0, import_jsx_runtime35.jsx)("div", { className: getClassName23("helper"), children: "No items" }),
|
|
7607
|
-
contentIds.map((itemId, i) => {
|
|
7608
|
-
return /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(
|
|
7609
|
-
Layer,
|
|
7610
|
-
{
|
|
7611
|
-
index: i,
|
|
7612
|
-
itemId,
|
|
7613
|
-
zoneCompound
|
|
7614
|
-
},
|
|
7615
|
-
itemId
|
|
7616
|
-
);
|
|
7617
|
-
})
|
|
7618
|
-
] })
|
|
7619
|
-
] });
|
|
7620
|
-
};
|
|
7621
|
-
|
|
7622
|
-
// components/Puck/components/Outline/index.tsx
|
|
7623
|
-
var import_react48 = require("react");
|
|
7624
|
-
|
|
7625
|
-
// lib/data/find-zones-for-area.ts
|
|
7626
|
-
init_react_import();
|
|
7627
|
-
var findZonesForArea = (state, area) => {
|
|
7628
|
-
return Object.keys(state.indexes.zones).filter(
|
|
7629
|
-
(zone) => zone.split(":")[0] === area
|
|
7630
|
-
);
|
|
7631
|
-
};
|
|
7632
|
-
|
|
7633
|
-
// components/Puck/components/Outline/index.tsx
|
|
7634
|
-
var import_shallow7 = require("zustand/react/shallow");
|
|
7635
|
-
var import_jsx_runtime36 = require("react/jsx-runtime");
|
|
7636
|
-
var Outline = () => {
|
|
7637
|
-
const outlineOverride = useAppStore((s) => s.overrides.outline);
|
|
7638
|
-
const rootZones = useAppStore(
|
|
7639
|
-
(0, import_shallow7.useShallow)((s) => findZonesForArea(s.state, "root"))
|
|
7640
|
-
);
|
|
7641
|
-
const Wrapper = (0, import_react48.useMemo)(() => outlineOverride || "div", [outlineOverride]);
|
|
7642
|
-
return /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(Wrapper, { children: rootZones.map((zoneCompound) => /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(
|
|
7643
|
-
LayerTree,
|
|
7644
|
-
{
|
|
7645
|
-
label: rootZones.length === 1 ? "" : zoneCompound.split(":")[1],
|
|
7646
|
-
zoneCompound
|
|
7647
|
-
},
|
|
7648
|
-
zoneCompound
|
|
7649
|
-
)) });
|
|
7650
|
-
};
|
|
7651
|
-
|
|
7652
|
-
// components/Puck/components/Canvas/index.tsx
|
|
7653
|
-
init_react_import();
|
|
7654
|
-
|
|
7655
|
-
// ../../node_modules/css-box-model/dist/css-box-model.esm.js
|
|
7656
|
-
init_react_import();
|
|
7657
|
-
|
|
7658
|
-
// ../../node_modules/tiny-invariant/dist/esm/tiny-invariant.js
|
|
7659
|
-
init_react_import();
|
|
7660
|
-
var isProduction = process.env.NODE_ENV === "production";
|
|
7661
|
-
var prefix = "Invariant failed";
|
|
7662
|
-
function invariant(condition, message) {
|
|
7663
|
-
if (condition) {
|
|
7664
|
-
return;
|
|
7665
|
-
}
|
|
7666
|
-
if (isProduction) {
|
|
7667
|
-
throw new Error(prefix);
|
|
7668
|
-
}
|
|
7669
|
-
var provided = typeof message === "function" ? message() : message;
|
|
7670
|
-
var value = provided ? "".concat(prefix, ": ").concat(provided) : prefix;
|
|
7671
|
-
throw new Error(value);
|
|
7672
|
-
}
|
|
7673
|
-
|
|
7674
|
-
// ../../node_modules/css-box-model/dist/css-box-model.esm.js
|
|
7675
|
-
var getRect = function getRect2(_ref) {
|
|
7676
|
-
var top = _ref.top, right = _ref.right, bottom = _ref.bottom, left = _ref.left;
|
|
7677
|
-
var width = right - left;
|
|
7678
|
-
var height = bottom - top;
|
|
7679
|
-
var rect = {
|
|
7680
|
-
top,
|
|
7681
|
-
right,
|
|
7682
|
-
bottom,
|
|
7683
|
-
left,
|
|
7684
|
-
width,
|
|
7685
|
-
height,
|
|
7686
|
-
x: left,
|
|
7687
|
-
y: top,
|
|
7688
|
-
center: {
|
|
7689
|
-
x: (right + left) / 2,
|
|
7690
|
-
y: (bottom + top) / 2
|
|
7691
|
-
}
|
|
7692
|
-
};
|
|
7693
|
-
return rect;
|
|
7694
|
-
};
|
|
7695
|
-
var expand = function expand2(target, expandBy) {
|
|
7696
|
-
return {
|
|
7697
|
-
top: target.top - expandBy.top,
|
|
7698
|
-
left: target.left - expandBy.left,
|
|
7699
|
-
bottom: target.bottom + expandBy.bottom,
|
|
7700
|
-
right: target.right + expandBy.right
|
|
7701
|
-
};
|
|
7702
|
-
};
|
|
7703
|
-
var shrink = function shrink2(target, shrinkBy) {
|
|
7704
|
-
return {
|
|
7705
|
-
top: target.top + shrinkBy.top,
|
|
7706
|
-
left: target.left + shrinkBy.left,
|
|
7707
|
-
bottom: target.bottom - shrinkBy.bottom,
|
|
7708
|
-
right: target.right - shrinkBy.right
|
|
7709
|
-
};
|
|
7710
|
-
};
|
|
7711
|
-
var noSpacing = {
|
|
7712
|
-
top: 0,
|
|
7713
|
-
right: 0,
|
|
7714
|
-
bottom: 0,
|
|
7715
|
-
left: 0
|
|
7716
|
-
};
|
|
7717
|
-
var createBox = function createBox2(_ref2) {
|
|
7718
|
-
var borderBox = _ref2.borderBox, _ref2$margin = _ref2.margin, margin = _ref2$margin === void 0 ? noSpacing : _ref2$margin, _ref2$border = _ref2.border, border = _ref2$border === void 0 ? noSpacing : _ref2$border, _ref2$padding = _ref2.padding, padding = _ref2$padding === void 0 ? noSpacing : _ref2$padding;
|
|
7719
|
-
var marginBox = getRect(expand(borderBox, margin));
|
|
7720
|
-
var paddingBox = getRect(shrink(borderBox, border));
|
|
7721
|
-
var contentBox = getRect(shrink(paddingBox, padding));
|
|
7722
|
-
return {
|
|
7723
|
-
marginBox,
|
|
7724
|
-
borderBox: getRect(borderBox),
|
|
7725
|
-
paddingBox,
|
|
7726
|
-
contentBox,
|
|
7727
|
-
margin,
|
|
7728
|
-
border,
|
|
7729
|
-
padding
|
|
7730
|
-
};
|
|
7731
|
-
};
|
|
7732
|
-
var parse = function parse2(raw) {
|
|
7733
|
-
var value = raw.slice(0, -2);
|
|
7734
|
-
var suffix = raw.slice(-2);
|
|
7735
|
-
if (suffix !== "px") {
|
|
7736
|
-
return 0;
|
|
7737
|
-
}
|
|
7738
|
-
var result = Number(value);
|
|
7739
|
-
!!isNaN(result) ? process.env.NODE_ENV !== "production" ? invariant(false, "Could not parse value [raw: " + raw + ", without suffix: " + value + "]") : invariant(false) : void 0;
|
|
7740
|
-
return result;
|
|
7741
|
-
};
|
|
7742
|
-
var calculateBox = function calculateBox2(borderBox, styles2) {
|
|
7743
|
-
var margin = {
|
|
7744
|
-
top: parse(styles2.marginTop),
|
|
7745
|
-
right: parse(styles2.marginRight),
|
|
7746
|
-
bottom: parse(styles2.marginBottom),
|
|
7747
|
-
left: parse(styles2.marginLeft)
|
|
7748
|
-
};
|
|
7749
|
-
var padding = {
|
|
7750
|
-
top: parse(styles2.paddingTop),
|
|
7751
|
-
right: parse(styles2.paddingRight),
|
|
7752
|
-
bottom: parse(styles2.paddingBottom),
|
|
7753
|
-
left: parse(styles2.paddingLeft)
|
|
7754
|
-
};
|
|
7755
|
-
var border = {
|
|
7756
|
-
top: parse(styles2.borderTopWidth),
|
|
7757
|
-
right: parse(styles2.borderRightWidth),
|
|
7758
|
-
bottom: parse(styles2.borderBottomWidth),
|
|
7759
|
-
left: parse(styles2.borderLeftWidth)
|
|
7760
|
-
};
|
|
7761
|
-
return createBox({
|
|
7762
|
-
borderBox,
|
|
7763
|
-
margin,
|
|
7764
|
-
padding,
|
|
7765
|
-
border
|
|
7786
|
+
]
|
|
7787
|
+
}
|
|
7788
|
+
);
|
|
7789
|
+
};
|
|
7790
|
+
var LayerTree = ({
|
|
7791
|
+
label: _label,
|
|
7792
|
+
zoneCompound
|
|
7793
|
+
}) => {
|
|
7794
|
+
const label = useAppStore((s) => {
|
|
7795
|
+
var _a, _b, _c, _d;
|
|
7796
|
+
if (_label) return _label;
|
|
7797
|
+
if (zoneCompound === rootDroppableId) return;
|
|
7798
|
+
const [componentId, slotId] = zoneCompound.split(":");
|
|
7799
|
+
const componentType = (_a = s.state.indexes.nodes[componentId]) == null ? void 0 : _a.data.type;
|
|
7800
|
+
const configForComponent = componentType && componentType !== rootAreaId ? s.config.components[componentType] : s.config.root;
|
|
7801
|
+
return (_d = (_c = (_b = configForComponent == null ? void 0 : configForComponent.fields) == null ? void 0 : _b[slotId]) == null ? void 0 : _c.label) != null ? _d : slotId;
|
|
7766
7802
|
});
|
|
7803
|
+
const contentIds = useAppStore(
|
|
7804
|
+
(0, import_shallow7.useShallow)(
|
|
7805
|
+
(s) => {
|
|
7806
|
+
var _a, _b;
|
|
7807
|
+
return zoneCompound ? (_b = (_a = s.state.indexes.zones[zoneCompound]) == null ? void 0 : _a.contentIds) != null ? _b : [] : [];
|
|
7808
|
+
}
|
|
7809
|
+
)
|
|
7810
|
+
);
|
|
7811
|
+
return /* @__PURE__ */ (0, import_jsx_runtime35.jsxs)(import_jsx_runtime35.Fragment, { children: [
|
|
7812
|
+
label && /* @__PURE__ */ (0, import_jsx_runtime35.jsxs)("div", { className: getClassName23("zoneTitle"), children: [
|
|
7813
|
+
/* @__PURE__ */ (0, import_jsx_runtime35.jsx)("div", { className: getClassName23("zoneIcon"), children: /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(Layers, { size: "16" }) }),
|
|
7814
|
+
label
|
|
7815
|
+
] }),
|
|
7816
|
+
/* @__PURE__ */ (0, import_jsx_runtime35.jsxs)("ul", { className: getClassName23(), children: [
|
|
7817
|
+
contentIds.length === 0 && /* @__PURE__ */ (0, import_jsx_runtime35.jsx)("div", { className: getClassName23("helper"), children: "No items" }),
|
|
7818
|
+
contentIds.map((itemId, i) => {
|
|
7819
|
+
return /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(
|
|
7820
|
+
Layer,
|
|
7821
|
+
{
|
|
7822
|
+
index: i,
|
|
7823
|
+
itemId,
|
|
7824
|
+
zoneCompound
|
|
7825
|
+
},
|
|
7826
|
+
itemId
|
|
7827
|
+
);
|
|
7828
|
+
})
|
|
7829
|
+
] })
|
|
7830
|
+
] });
|
|
7767
7831
|
};
|
|
7768
|
-
|
|
7769
|
-
|
|
7770
|
-
|
|
7771
|
-
|
|
7832
|
+
|
|
7833
|
+
// components/Puck/components/Outline/index.tsx
|
|
7834
|
+
var import_react48 = require("react");
|
|
7835
|
+
|
|
7836
|
+
// lib/data/find-zones-for-area.ts
|
|
7837
|
+
init_react_import();
|
|
7838
|
+
var findZonesForArea = (state, area) => {
|
|
7839
|
+
return Object.keys(state.indexes.zones).filter(
|
|
7840
|
+
(zone) => zone.split(":")[0] === area
|
|
7841
|
+
);
|
|
7842
|
+
};
|
|
7843
|
+
|
|
7844
|
+
// components/Puck/components/Outline/index.tsx
|
|
7845
|
+
var import_shallow8 = require("zustand/react/shallow");
|
|
7846
|
+
var import_jsx_runtime36 = require("react/jsx-runtime");
|
|
7847
|
+
var Outline = () => {
|
|
7848
|
+
const outlineOverride = useAppStore((s) => s.overrides.outline);
|
|
7849
|
+
const rootZones = useAppStore(
|
|
7850
|
+
(0, import_shallow8.useShallow)((s) => findZonesForArea(s.state, "root"))
|
|
7851
|
+
);
|
|
7852
|
+
const Wrapper = (0, import_react48.useMemo)(() => outlineOverride || "div", [outlineOverride]);
|
|
7853
|
+
return /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(Wrapper, { children: rootZones.map((zoneCompound) => /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(
|
|
7854
|
+
LayerTree,
|
|
7855
|
+
{
|
|
7856
|
+
label: rootZones.length === 1 ? "" : zoneCompound.split(":")[1],
|
|
7857
|
+
zoneCompound
|
|
7858
|
+
},
|
|
7859
|
+
zoneCompound
|
|
7860
|
+
)) });
|
|
7772
7861
|
};
|
|
7773
7862
|
|
|
7774
7863
|
// components/Puck/components/Canvas/index.tsx
|
|
7775
|
-
|
|
7864
|
+
init_react_import();
|
|
7865
|
+
var import_react51 = require("react");
|
|
7776
7866
|
|
|
7777
7867
|
// components/ViewportControls/index.tsx
|
|
7778
7868
|
init_react_import();
|
|
@@ -7924,42 +8014,41 @@ var ViewportControls = ({
|
|
|
7924
8014
|
init_react_import();
|
|
7925
8015
|
var styles_module_default20 = { "PuckCanvas": "_PuckCanvas_18jay_1", "PuckCanvas-controls": "_PuckCanvas-controls_18jay_16", "PuckCanvas-inner": "_PuckCanvas-inner_18jay_21", "PuckCanvas-root": "_PuckCanvas-root_18jay_30", "PuckCanvas--ready": "_PuckCanvas--ready_18jay_55", "PuckCanvas-loader": "_PuckCanvas-loader_18jay_60", "PuckCanvas--showLoader": "_PuckCanvas--showLoader_18jay_70" };
|
|
7926
8016
|
|
|
7927
|
-
//
|
|
8017
|
+
// components/Puck/components/Canvas/index.tsx
|
|
8018
|
+
var import_shallow9 = require("zustand/react/shallow");
|
|
8019
|
+
|
|
8020
|
+
// lib/frame-context.tsx
|
|
7928
8021
|
init_react_import();
|
|
7929
|
-
var
|
|
7930
|
-
var
|
|
7931
|
-
|
|
7932
|
-
|
|
7933
|
-
|
|
7934
|
-
|
|
7935
|
-
|
|
7936
|
-
|
|
7937
|
-
|
|
7938
|
-
|
|
7939
|
-
|
|
7940
|
-
|
|
7941
|
-
|
|
7942
|
-
|
|
7943
|
-
|
|
7944
|
-
|
|
7945
|
-
|
|
7946
|
-
|
|
7947
|
-
|
|
7948
|
-
if (RESET_ZOOM_SMALLER_THAN_FRAME) {
|
|
7949
|
-
autoZoom = 1;
|
|
7950
|
-
zoom = 1;
|
|
7951
|
-
rootHeight = viewportHeight;
|
|
7952
|
-
}
|
|
8022
|
+
var import_react50 = require("react");
|
|
8023
|
+
var import_jsx_runtime38 = require("react/jsx-runtime");
|
|
8024
|
+
var FrameContext = (0, import_react50.createContext)(null);
|
|
8025
|
+
var FrameProvider = ({
|
|
8026
|
+
children
|
|
8027
|
+
}) => {
|
|
8028
|
+
const frameRef = (0, import_react50.useRef)(null);
|
|
8029
|
+
const value = (0, import_react50.useMemo)(
|
|
8030
|
+
() => ({
|
|
8031
|
+
frameRef
|
|
8032
|
+
}),
|
|
8033
|
+
[]
|
|
8034
|
+
);
|
|
8035
|
+
return /* @__PURE__ */ (0, import_jsx_runtime38.jsx)(FrameContext.Provider, { value, children });
|
|
8036
|
+
};
|
|
8037
|
+
var useCanvasFrame = () => {
|
|
8038
|
+
const context = (0, import_react50.useContext)(FrameContext);
|
|
8039
|
+
if (context === null) {
|
|
8040
|
+
throw new Error("useCanvasFrame must be used within a FrameProvider");
|
|
7953
8041
|
}
|
|
7954
|
-
return
|
|
8042
|
+
return context;
|
|
7955
8043
|
};
|
|
7956
8044
|
|
|
7957
8045
|
// components/Puck/components/Canvas/index.tsx
|
|
7958
|
-
var
|
|
7959
|
-
var import_jsx_runtime38 = require("react/jsx-runtime");
|
|
8046
|
+
var import_jsx_runtime39 = require("react/jsx-runtime");
|
|
7960
8047
|
var getClassName25 = get_class_name_factory_default("PuckCanvas", styles_module_default20);
|
|
7961
8048
|
var ZOOM_ON_CHANGE = true;
|
|
7962
8049
|
var Canvas = () => {
|
|
8050
|
+
const { frameRef } = useCanvasFrame();
|
|
8051
|
+
const resetAutoZoom = useResetAutoZoom(frameRef);
|
|
7963
8052
|
const {
|
|
7964
8053
|
dispatch,
|
|
7965
8054
|
overrides,
|
|
@@ -7969,7 +8058,7 @@ var Canvas = () => {
|
|
|
7969
8058
|
status,
|
|
7970
8059
|
iframe
|
|
7971
8060
|
} = useAppStore(
|
|
7972
|
-
(0,
|
|
8061
|
+
(0, import_shallow9.useShallow)((s) => ({
|
|
7973
8062
|
dispatch: s.dispatch,
|
|
7974
8063
|
overrides: s.overrides,
|
|
7975
8064
|
setUi: s.setUi,
|
|
@@ -7979,24 +8068,32 @@ var Canvas = () => {
|
|
|
7979
8068
|
iframe: s.iframe
|
|
7980
8069
|
}))
|
|
7981
8070
|
);
|
|
7982
|
-
const {
|
|
7983
|
-
|
|
8071
|
+
const {
|
|
8072
|
+
leftSideBarVisible,
|
|
8073
|
+
rightSideBarVisible,
|
|
8074
|
+
leftSideBarWidth,
|
|
8075
|
+
rightSideBarWidth,
|
|
8076
|
+
viewports
|
|
8077
|
+
} = useAppStore(
|
|
8078
|
+
(0, import_shallow9.useShallow)((s) => ({
|
|
7984
8079
|
leftSideBarVisible: s.state.ui.leftSideBarVisible,
|
|
7985
8080
|
rightSideBarVisible: s.state.ui.rightSideBarVisible,
|
|
8081
|
+
leftSideBarWidth: s.state.ui.leftSideBarWidth,
|
|
8082
|
+
rightSideBarWidth: s.state.ui.rightSideBarWidth,
|
|
7986
8083
|
viewports: s.state.ui.viewports
|
|
7987
8084
|
}))
|
|
7988
8085
|
);
|
|
7989
|
-
const
|
|
7990
|
-
const
|
|
7991
|
-
const defaultRender = (0,
|
|
7992
|
-
const PuckDefault = ({ children }) => /* @__PURE__ */ (0,
|
|
8086
|
+
const [showTransition, setShowTransition] = (0, import_react51.useState)(false);
|
|
8087
|
+
const isResettingZoomRef = (0, import_react51.useRef)(false);
|
|
8088
|
+
const defaultRender = (0, import_react51.useMemo)(() => {
|
|
8089
|
+
const PuckDefault = ({ children }) => /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(import_jsx_runtime39.Fragment, { children });
|
|
7993
8090
|
return PuckDefault;
|
|
7994
8091
|
}, []);
|
|
7995
|
-
const CustomPreview = (0,
|
|
8092
|
+
const CustomPreview = (0, import_react51.useMemo)(
|
|
7996
8093
|
() => overrides.preview || defaultRender,
|
|
7997
8094
|
[overrides]
|
|
7998
8095
|
);
|
|
7999
|
-
const getFrameDimensions = (0,
|
|
8096
|
+
const getFrameDimensions = (0, import_react51.useCallback)(() => {
|
|
8000
8097
|
if (frameRef.current) {
|
|
8001
8098
|
const frame = frameRef.current;
|
|
8002
8099
|
const box = getBox(frame);
|
|
@@ -8004,68 +8101,78 @@ var Canvas = () => {
|
|
|
8004
8101
|
}
|
|
8005
8102
|
return { width: 0, height: 0 };
|
|
8006
8103
|
}, [frameRef]);
|
|
8007
|
-
|
|
8008
|
-
(
|
|
8009
|
-
|
|
8010
|
-
|
|
8011
|
-
|
|
8012
|
-
|
|
8013
|
-
|
|
8014
|
-
|
|
8015
|
-
|
|
8016
|
-
|
|
8017
|
-
|
|
8018
|
-
|
|
8019
|
-
|
|
8020
|
-
|
|
8021
|
-
|
|
8022
|
-
|
|
8023
|
-
|
|
8024
|
-
}, [frameRef, leftSideBarVisible, rightSideBarVisible]);
|
|
8025
|
-
(0, import_react50.useEffect)(() => {
|
|
8104
|
+
(0, import_react51.useEffect)(() => {
|
|
8105
|
+
resetAutoZoom({
|
|
8106
|
+
isResettingRef: isResettingZoomRef,
|
|
8107
|
+
setShowTransition,
|
|
8108
|
+
showTransition: false,
|
|
8109
|
+
viewports
|
|
8110
|
+
});
|
|
8111
|
+
}, [
|
|
8112
|
+
frameRef,
|
|
8113
|
+
leftSideBarVisible,
|
|
8114
|
+
rightSideBarVisible,
|
|
8115
|
+
leftSideBarWidth,
|
|
8116
|
+
rightSideBarWidth,
|
|
8117
|
+
resetAutoZoom,
|
|
8118
|
+
viewports
|
|
8119
|
+
]);
|
|
8120
|
+
(0, import_react51.useEffect)(() => {
|
|
8026
8121
|
const { height: frameHeight } = getFrameDimensions();
|
|
8027
8122
|
if (viewports.current.height === "auto") {
|
|
8028
8123
|
setZoomConfig(__spreadProps(__spreadValues({}, zoomConfig), {
|
|
8029
8124
|
rootHeight: frameHeight / zoomConfig.zoom
|
|
8030
8125
|
}));
|
|
8031
8126
|
}
|
|
8032
|
-
}, [zoomConfig.zoom]);
|
|
8033
|
-
(0,
|
|
8127
|
+
}, [zoomConfig.zoom, getFrameDimensions, setZoomConfig]);
|
|
8128
|
+
(0, import_react51.useEffect)(() => {
|
|
8034
8129
|
if (ZOOM_ON_CHANGE) {
|
|
8035
|
-
|
|
8036
|
-
|
|
8130
|
+
resetAutoZoom({
|
|
8131
|
+
isResettingRef: isResettingZoomRef,
|
|
8132
|
+
setShowTransition,
|
|
8133
|
+
showTransition: true,
|
|
8134
|
+
viewports
|
|
8135
|
+
});
|
|
8037
8136
|
}
|
|
8038
|
-
}, [viewports.current.width]);
|
|
8039
|
-
(0,
|
|
8137
|
+
}, [viewports.current.width, resetAutoZoom, viewports]);
|
|
8138
|
+
(0, import_react51.useEffect)(() => {
|
|
8040
8139
|
const cb = () => {
|
|
8041
|
-
|
|
8042
|
-
|
|
8140
|
+
resetAutoZoom({
|
|
8141
|
+
isResettingRef: isResettingZoomRef,
|
|
8142
|
+
setShowTransition,
|
|
8143
|
+
showTransition: false
|
|
8144
|
+
});
|
|
8043
8145
|
};
|
|
8044
8146
|
window.addEventListener("resize", cb);
|
|
8045
8147
|
return () => {
|
|
8046
8148
|
window.removeEventListener("resize", cb);
|
|
8047
8149
|
};
|
|
8048
|
-
}, []);
|
|
8049
|
-
const [showLoader, setShowLoader] = (0,
|
|
8050
|
-
(0,
|
|
8150
|
+
}, [resetAutoZoom]);
|
|
8151
|
+
const [showLoader, setShowLoader] = (0, import_react51.useState)(false);
|
|
8152
|
+
(0, import_react51.useEffect)(() => {
|
|
8051
8153
|
setTimeout(() => {
|
|
8052
8154
|
setShowLoader(true);
|
|
8053
8155
|
}, 500);
|
|
8054
8156
|
}, []);
|
|
8055
|
-
return /* @__PURE__ */ (0,
|
|
8157
|
+
return /* @__PURE__ */ (0, import_jsx_runtime39.jsxs)(
|
|
8056
8158
|
"div",
|
|
8057
8159
|
{
|
|
8058
8160
|
className: getClassName25({
|
|
8059
8161
|
ready: status === "READY" || !iframe.enabled || !iframe.waitForStyles,
|
|
8060
8162
|
showLoader
|
|
8061
8163
|
}),
|
|
8062
|
-
onClick: () =>
|
|
8063
|
-
|
|
8064
|
-
|
|
8065
|
-
|
|
8066
|
-
|
|
8164
|
+
onClick: (e) => {
|
|
8165
|
+
const el = e.target;
|
|
8166
|
+
if (!el.hasAttribute("data-puck-component") && !el.hasAttribute("data-puck-dropzone")) {
|
|
8167
|
+
dispatch({
|
|
8168
|
+
type: "setUi",
|
|
8169
|
+
ui: { itemSelector: null },
|
|
8170
|
+
recordHistory: true
|
|
8171
|
+
});
|
|
8172
|
+
}
|
|
8173
|
+
},
|
|
8067
8174
|
children: [
|
|
8068
|
-
viewports.controlsVisible && iframe.enabled && /* @__PURE__ */ (0,
|
|
8175
|
+
viewports.controlsVisible && iframe.enabled && /* @__PURE__ */ (0, import_jsx_runtime39.jsx)("div", { className: getClassName25("controls"), children: /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(
|
|
8069
8176
|
ViewportControls,
|
|
8070
8177
|
{
|
|
8071
8178
|
autoZoom: zoomConfig.autoZoom,
|
|
@@ -8082,7 +8189,12 @@ var Canvas = () => {
|
|
|
8082
8189
|
};
|
|
8083
8190
|
setUi(newUi);
|
|
8084
8191
|
if (ZOOM_ON_CHANGE) {
|
|
8085
|
-
resetAutoZoom(
|
|
8192
|
+
resetAutoZoom({
|
|
8193
|
+
isResettingRef: isResettingZoomRef,
|
|
8194
|
+
setShowTransition,
|
|
8195
|
+
showTransition: true,
|
|
8196
|
+
viewports: __spreadProps(__spreadValues({}, viewports), { current: uiViewport })
|
|
8197
|
+
});
|
|
8086
8198
|
}
|
|
8087
8199
|
},
|
|
8088
8200
|
onZoom: (zoom) => {
|
|
@@ -8091,8 +8203,8 @@ var Canvas = () => {
|
|
|
8091
8203
|
}
|
|
8092
8204
|
}
|
|
8093
8205
|
) }),
|
|
8094
|
-
/* @__PURE__ */ (0,
|
|
8095
|
-
/* @__PURE__ */ (0,
|
|
8206
|
+
/* @__PURE__ */ (0, import_jsx_runtime39.jsxs)("div", { className: getClassName25("inner"), ref: frameRef, children: [
|
|
8207
|
+
/* @__PURE__ */ (0, import_jsx_runtime39.jsx)(
|
|
8096
8208
|
"div",
|
|
8097
8209
|
{
|
|
8098
8210
|
className: getClassName25("root"),
|
|
@@ -8106,17 +8218,14 @@ var Canvas = () => {
|
|
|
8106
8218
|
suppressHydrationWarning: true,
|
|
8107
8219
|
id: "puck-canvas-root",
|
|
8108
8220
|
onTransitionEnd: () => {
|
|
8109
|
-
|
|
8110
|
-
|
|
8111
|
-
|
|
8112
|
-
cancelable: false
|
|
8113
|
-
})
|
|
8114
|
-
);
|
|
8221
|
+
resetAutoZoom({
|
|
8222
|
+
isResettingRef: isResettingZoomRef
|
|
8223
|
+
});
|
|
8115
8224
|
},
|
|
8116
|
-
children: /* @__PURE__ */ (0,
|
|
8225
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(CustomPreview, { children: /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(Preview2, {}) })
|
|
8117
8226
|
}
|
|
8118
8227
|
),
|
|
8119
|
-
/* @__PURE__ */ (0,
|
|
8228
|
+
/* @__PURE__ */ (0, import_jsx_runtime39.jsx)("div", { className: getClassName25("loader"), children: /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(Loader, { size: 24 }) })
|
|
8120
8229
|
] })
|
|
8121
8230
|
]
|
|
8122
8231
|
}
|
|
@@ -8125,7 +8234,7 @@ var Canvas = () => {
|
|
|
8125
8234
|
|
|
8126
8235
|
// lib/use-loaded-overrides.ts
|
|
8127
8236
|
init_react_import();
|
|
8128
|
-
var
|
|
8237
|
+
var import_react52 = require("react");
|
|
8129
8238
|
|
|
8130
8239
|
// lib/load-overrides.ts
|
|
8131
8240
|
init_react_import();
|
|
@@ -8164,26 +8273,26 @@ var useLoadedOverrides = ({
|
|
|
8164
8273
|
overrides,
|
|
8165
8274
|
plugins
|
|
8166
8275
|
}) => {
|
|
8167
|
-
return (0,
|
|
8276
|
+
return (0, import_react52.useMemo)(() => {
|
|
8168
8277
|
return loadOverrides({ overrides, plugins });
|
|
8169
8278
|
}, [plugins, overrides]);
|
|
8170
8279
|
};
|
|
8171
8280
|
|
|
8172
8281
|
// components/DefaultOverride/index.tsx
|
|
8173
8282
|
init_react_import();
|
|
8174
|
-
var
|
|
8175
|
-
var DefaultOverride = ({ children }) => /* @__PURE__ */ (0,
|
|
8283
|
+
var import_jsx_runtime40 = require("react/jsx-runtime");
|
|
8284
|
+
var DefaultOverride = ({ children }) => /* @__PURE__ */ (0, import_jsx_runtime40.jsx)(import_jsx_runtime40.Fragment, { children });
|
|
8176
8285
|
|
|
8177
8286
|
// lib/use-inject-css.ts
|
|
8178
8287
|
init_react_import();
|
|
8179
|
-
var
|
|
8288
|
+
var import_react53 = require("react");
|
|
8180
8289
|
var styles = ``;
|
|
8181
8290
|
var useInjectStyleSheet = (initialStyles, iframeEnabled) => {
|
|
8182
|
-
const [el, setEl] = (0,
|
|
8183
|
-
(0,
|
|
8291
|
+
const [el, setEl] = (0, import_react53.useState)();
|
|
8292
|
+
(0, import_react53.useEffect)(() => {
|
|
8184
8293
|
setEl(document.createElement("style"));
|
|
8185
8294
|
}, []);
|
|
8186
|
-
(0,
|
|
8295
|
+
(0, import_react53.useEffect)(() => {
|
|
8187
8296
|
var _a;
|
|
8188
8297
|
if (!el || typeof window === "undefined") {
|
|
8189
8298
|
return;
|
|
@@ -8203,10 +8312,10 @@ var useInjectGlobalCss = (iframeEnabled) => {
|
|
|
8203
8312
|
|
|
8204
8313
|
// lib/use-preview-mode-hotkeys.ts
|
|
8205
8314
|
init_react_import();
|
|
8206
|
-
var
|
|
8315
|
+
var import_react54 = require("react");
|
|
8207
8316
|
var usePreviewModeHotkeys = () => {
|
|
8208
8317
|
const appStore = useAppStoreApi();
|
|
8209
|
-
const toggleInteractive = (0,
|
|
8318
|
+
const toggleInteractive = (0, import_react54.useCallback)(() => {
|
|
8210
8319
|
const dispatch = appStore.getState().dispatch;
|
|
8211
8320
|
dispatch({
|
|
8212
8321
|
type: "setUi",
|
|
@@ -8221,7 +8330,7 @@ var usePreviewModeHotkeys = () => {
|
|
|
8221
8330
|
|
|
8222
8331
|
// lib/use-puck.ts
|
|
8223
8332
|
init_react_import();
|
|
8224
|
-
var
|
|
8333
|
+
var import_react55 = require("react");
|
|
8225
8334
|
var import_zustand6 = require("zustand");
|
|
8226
8335
|
var generateUsePuck = (store) => {
|
|
8227
8336
|
const history = {
|
|
@@ -8252,10 +8361,9 @@ var generateUsePuck = (store) => {
|
|
|
8252
8361
|
return { zone: zoneCompound, index };
|
|
8253
8362
|
}
|
|
8254
8363
|
};
|
|
8255
|
-
|
|
8256
|
-
return __spreadProps(__spreadValues({}, storeData), { get });
|
|
8364
|
+
return storeData;
|
|
8257
8365
|
};
|
|
8258
|
-
var UsePuckStoreContext = (0,
|
|
8366
|
+
var UsePuckStoreContext = (0, import_react55.createContext)(
|
|
8259
8367
|
null
|
|
8260
8368
|
);
|
|
8261
8369
|
var convertToPickedStore = (store) => {
|
|
@@ -8269,12 +8377,12 @@ var convertToPickedStore = (store) => {
|
|
|
8269
8377
|
};
|
|
8270
8378
|
};
|
|
8271
8379
|
var useRegisterUsePuckStore = (appStore) => {
|
|
8272
|
-
const [usePuckStore] = (0,
|
|
8380
|
+
const [usePuckStore] = (0, import_react55.useState)(
|
|
8273
8381
|
() => (0, import_zustand6.createStore)(
|
|
8274
8382
|
() => generateUsePuck(convertToPickedStore(appStore.getState()))
|
|
8275
8383
|
)
|
|
8276
8384
|
);
|
|
8277
|
-
(0,
|
|
8385
|
+
(0, import_react55.useEffect)(() => {
|
|
8278
8386
|
return appStore.subscribe(
|
|
8279
8387
|
(store) => convertToPickedStore(store),
|
|
8280
8388
|
(pickedStore) => {
|
|
@@ -8286,7 +8394,7 @@ var useRegisterUsePuckStore = (appStore) => {
|
|
|
8286
8394
|
};
|
|
8287
8395
|
function createUsePuck() {
|
|
8288
8396
|
return function usePuck2(selector) {
|
|
8289
|
-
const usePuckApi = (0,
|
|
8397
|
+
const usePuckApi = (0, import_react55.useContext)(UsePuckStoreContext);
|
|
8290
8398
|
if (!usePuckApi) {
|
|
8291
8399
|
throw new Error("usePuck must be used inside <Puck>.");
|
|
8292
8400
|
}
|
|
@@ -8298,7 +8406,7 @@ function createUsePuck() {
|
|
|
8298
8406
|
};
|
|
8299
8407
|
}
|
|
8300
8408
|
function usePuck() {
|
|
8301
|
-
(0,
|
|
8409
|
+
(0, import_react55.useEffect)(() => {
|
|
8302
8410
|
console.warn(
|
|
8303
8411
|
"You're using the `usePuck` method without a selector, which may cause unnecessary re-renders. Replace with `createUsePuck` and provide a selector for improved performance."
|
|
8304
8412
|
);
|
|
@@ -8306,7 +8414,7 @@ function usePuck() {
|
|
|
8306
8414
|
return createUsePuck()((s) => s);
|
|
8307
8415
|
}
|
|
8308
8416
|
function useGetPuck() {
|
|
8309
|
-
const usePuckApi = (0,
|
|
8417
|
+
const usePuckApi = (0, import_react55.useContext)(UsePuckStoreContext);
|
|
8310
8418
|
if (!usePuckApi) {
|
|
8311
8419
|
throw new Error("usePuckGet must be used inside <Puck>.");
|
|
8312
8420
|
}
|
|
@@ -8318,7 +8426,7 @@ var import_fast_deep_equal3 = __toESM(require("fast-deep-equal"));
|
|
|
8318
8426
|
|
|
8319
8427
|
// components/Puck/components/Header/index.tsx
|
|
8320
8428
|
init_react_import();
|
|
8321
|
-
var
|
|
8429
|
+
var import_react56 = require("react");
|
|
8322
8430
|
|
|
8323
8431
|
// components/MenuBar/index.tsx
|
|
8324
8432
|
init_react_import();
|
|
@@ -8328,7 +8436,7 @@ init_react_import();
|
|
|
8328
8436
|
var styles_module_default21 = { "MenuBar": "_MenuBar_8pf8c_1", "MenuBar--menuOpen": "_MenuBar--menuOpen_8pf8c_14", "MenuBar-inner": "_MenuBar-inner_8pf8c_29", "MenuBar-history": "_MenuBar-history_8pf8c_45" };
|
|
8329
8437
|
|
|
8330
8438
|
// components/MenuBar/index.tsx
|
|
8331
|
-
var
|
|
8439
|
+
var import_jsx_runtime41 = require("react/jsx-runtime");
|
|
8332
8440
|
var getClassName26 = get_class_name_factory_default("MenuBar", styles_module_default21);
|
|
8333
8441
|
function MenuBar({
|
|
8334
8442
|
menuOpen = false,
|
|
@@ -8339,7 +8447,7 @@ function MenuBar({
|
|
|
8339
8447
|
const forward = useAppStore((s) => s.history.forward);
|
|
8340
8448
|
const hasFuture = useAppStore((s) => s.history.hasFuture());
|
|
8341
8449
|
const hasPast = useAppStore((s) => s.history.hasPast());
|
|
8342
|
-
return /* @__PURE__ */ (0,
|
|
8450
|
+
return /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(
|
|
8343
8451
|
"div",
|
|
8344
8452
|
{
|
|
8345
8453
|
className: getClassName26({ menuOpen }),
|
|
@@ -8353,30 +8461,30 @@ function MenuBar({
|
|
|
8353
8461
|
setMenuOpen(false);
|
|
8354
8462
|
}
|
|
8355
8463
|
},
|
|
8356
|
-
children: /* @__PURE__ */ (0,
|
|
8357
|
-
/* @__PURE__ */ (0,
|
|
8358
|
-
/* @__PURE__ */ (0,
|
|
8464
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime41.jsxs)("div", { className: getClassName26("inner"), children: [
|
|
8465
|
+
/* @__PURE__ */ (0, import_jsx_runtime41.jsxs)("div", { className: getClassName26("history"), children: [
|
|
8466
|
+
/* @__PURE__ */ (0, import_jsx_runtime41.jsx)(
|
|
8359
8467
|
IconButton,
|
|
8360
8468
|
{
|
|
8361
8469
|
type: "button",
|
|
8362
8470
|
title: "undo",
|
|
8363
8471
|
disabled: !hasPast,
|
|
8364
8472
|
onClick: back,
|
|
8365
|
-
children: /* @__PURE__ */ (0,
|
|
8473
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(Undo2, { size: 21 })
|
|
8366
8474
|
}
|
|
8367
8475
|
),
|
|
8368
|
-
/* @__PURE__ */ (0,
|
|
8476
|
+
/* @__PURE__ */ (0, import_jsx_runtime41.jsx)(
|
|
8369
8477
|
IconButton,
|
|
8370
8478
|
{
|
|
8371
8479
|
type: "button",
|
|
8372
8480
|
title: "redo",
|
|
8373
8481
|
disabled: !hasFuture,
|
|
8374
8482
|
onClick: forward,
|
|
8375
|
-
children: /* @__PURE__ */ (0,
|
|
8483
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(Redo2, { size: 21 })
|
|
8376
8484
|
}
|
|
8377
8485
|
)
|
|
8378
8486
|
] }),
|
|
8379
|
-
/* @__PURE__ */ (0,
|
|
8487
|
+
/* @__PURE__ */ (0, import_jsx_runtime41.jsx)(import_jsx_runtime41.Fragment, { children: renderHeaderActions && renderHeaderActions() })
|
|
8380
8488
|
] })
|
|
8381
8489
|
}
|
|
8382
8490
|
);
|
|
@@ -8387,7 +8495,7 @@ init_react_import();
|
|
|
8387
8495
|
var styles_module_default22 = { "PuckHeader": "_PuckHeader_15xnq_1", "PuckHeader-inner": "_PuckHeader-inner_15xnq_10", "PuckHeader-toggle": "_PuckHeader-toggle_15xnq_20", "PuckHeader--rightSideBarVisible": "_PuckHeader--rightSideBarVisible_15xnq_27", "PuckHeader-rightSideBarToggle": "_PuckHeader-rightSideBarToggle_15xnq_27", "PuckHeader--leftSideBarVisible": "_PuckHeader--leftSideBarVisible_15xnq_28", "PuckHeader-leftSideBarToggle": "_PuckHeader-leftSideBarToggle_15xnq_28", "PuckHeader-title": "_PuckHeader-title_15xnq_32", "PuckHeader-path": "_PuckHeader-path_15xnq_36", "PuckHeader-tools": "_PuckHeader-tools_15xnq_43", "PuckHeader-menuButton": "_PuckHeader-menuButton_15xnq_49", "PuckHeader--menuOpen": "_PuckHeader--menuOpen_15xnq_54" };
|
|
8388
8496
|
|
|
8389
8497
|
// components/Puck/components/Header/index.tsx
|
|
8390
|
-
var
|
|
8498
|
+
var import_jsx_runtime42 = require("react/jsx-runtime");
|
|
8391
8499
|
var getClassName27 = get_class_name_factory_default("PuckHeader", styles_module_default22);
|
|
8392
8500
|
var HeaderInner = () => {
|
|
8393
8501
|
const {
|
|
@@ -8400,7 +8508,7 @@ var HeaderInner = () => {
|
|
|
8400
8508
|
} = usePropsContext();
|
|
8401
8509
|
const dispatch = useAppStore((s) => s.dispatch);
|
|
8402
8510
|
const appStore = useAppStoreApi();
|
|
8403
|
-
const defaultHeaderRender = (0,
|
|
8511
|
+
const defaultHeaderRender = (0, import_react56.useMemo)(() => {
|
|
8404
8512
|
if (renderHeader) {
|
|
8405
8513
|
console.warn(
|
|
8406
8514
|
"`renderHeader` is deprecated. Please use `overrides.header` and the `usePuck` hook instead"
|
|
@@ -8409,13 +8517,13 @@ var HeaderInner = () => {
|
|
|
8409
8517
|
var _b = _a, { actions } = _b, props = __objRest(_b, ["actions"]);
|
|
8410
8518
|
const Comp = renderHeader;
|
|
8411
8519
|
const appState = useAppStore((s) => s.state);
|
|
8412
|
-
return /* @__PURE__ */ (0,
|
|
8520
|
+
return /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(Comp, __spreadProps(__spreadValues({}, props), { dispatch, state: appState, children: actions }));
|
|
8413
8521
|
};
|
|
8414
8522
|
return RenderHeader;
|
|
8415
8523
|
}
|
|
8416
8524
|
return DefaultOverride;
|
|
8417
8525
|
}, [renderHeader]);
|
|
8418
|
-
const defaultHeaderActionsRender = (0,
|
|
8526
|
+
const defaultHeaderActionsRender = (0, import_react56.useMemo)(() => {
|
|
8419
8527
|
if (renderHeaderActions) {
|
|
8420
8528
|
console.warn(
|
|
8421
8529
|
"`renderHeaderActions` is deprecated. Please use `overrides.headerActions` and the `usePuck` hook instead."
|
|
@@ -8423,7 +8531,7 @@ var HeaderInner = () => {
|
|
|
8423
8531
|
const RenderHeader = (props) => {
|
|
8424
8532
|
const Comp = renderHeaderActions;
|
|
8425
8533
|
const appState = useAppStore((s) => s.state);
|
|
8426
|
-
return /* @__PURE__ */ (0,
|
|
8534
|
+
return /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(Comp, __spreadProps(__spreadValues({}, props), { dispatch, state: appState }));
|
|
8427
8535
|
};
|
|
8428
8536
|
return RenderHeader;
|
|
8429
8537
|
}
|
|
@@ -8435,7 +8543,7 @@ var HeaderInner = () => {
|
|
|
8435
8543
|
const CustomHeaderActions = useAppStore(
|
|
8436
8544
|
(s) => s.overrides.headerActions || defaultHeaderActionsRender
|
|
8437
8545
|
);
|
|
8438
|
-
const [menuOpen, setMenuOpen] = (0,
|
|
8546
|
+
const [menuOpen, setMenuOpen] = (0, import_react56.useState)(false);
|
|
8439
8547
|
const rootTitle = useAppStore((s) => {
|
|
8440
8548
|
var _a, _b;
|
|
8441
8549
|
const rootData = (_a = s.state.indexes.nodes["root"]) == null ? void 0 : _a.data;
|
|
@@ -8445,7 +8553,7 @@ var HeaderInner = () => {
|
|
|
8445
8553
|
const rightSideBarVisible = useAppStore(
|
|
8446
8554
|
(s) => s.state.ui.rightSideBarVisible
|
|
8447
8555
|
);
|
|
8448
|
-
const toggleSidebars = (0,
|
|
8556
|
+
const toggleSidebars = (0, import_react56.useCallback)(
|
|
8449
8557
|
(sidebar) => {
|
|
8450
8558
|
const widerViewport = window.matchMedia("(min-width: 638px)").matches;
|
|
8451
8559
|
const sideBarVisible = sidebar === "left" ? leftSideBarVisible : rightSideBarVisible;
|
|
@@ -8459,27 +8567,27 @@ var HeaderInner = () => {
|
|
|
8459
8567
|
},
|
|
8460
8568
|
[dispatch, leftSideBarVisible, rightSideBarVisible]
|
|
8461
8569
|
);
|
|
8462
|
-
return /* @__PURE__ */ (0,
|
|
8570
|
+
return /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(
|
|
8463
8571
|
CustomHeader,
|
|
8464
8572
|
{
|
|
8465
|
-
actions: /* @__PURE__ */ (0,
|
|
8573
|
+
actions: /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(import_jsx_runtime42.Fragment, { children: /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(CustomHeaderActions, { children: /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(
|
|
8466
8574
|
Button,
|
|
8467
8575
|
{
|
|
8468
8576
|
onClick: () => {
|
|
8469
8577
|
const data = appStore.getState().state.data;
|
|
8470
8578
|
onPublish && onPublish(data);
|
|
8471
8579
|
},
|
|
8472
|
-
icon: /* @__PURE__ */ (0,
|
|
8580
|
+
icon: /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(Globe, { size: "14px" }),
|
|
8473
8581
|
children: "Publish"
|
|
8474
8582
|
}
|
|
8475
8583
|
) }) }),
|
|
8476
|
-
children: /* @__PURE__ */ (0,
|
|
8584
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(
|
|
8477
8585
|
"header",
|
|
8478
8586
|
{
|
|
8479
8587
|
className: getClassName27({ leftSideBarVisible, rightSideBarVisible }),
|
|
8480
|
-
children: /* @__PURE__ */ (0,
|
|
8481
|
-
/* @__PURE__ */ (0,
|
|
8482
|
-
/* @__PURE__ */ (0,
|
|
8588
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime42.jsxs)("div", { className: getClassName27("inner"), children: [
|
|
8589
|
+
/* @__PURE__ */ (0, import_jsx_runtime42.jsxs)("div", { className: getClassName27("toggle"), children: [
|
|
8590
|
+
/* @__PURE__ */ (0, import_jsx_runtime42.jsx)("div", { className: getClassName27("leftSideBarToggle"), children: /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(
|
|
8483
8591
|
IconButton,
|
|
8484
8592
|
{
|
|
8485
8593
|
type: "button",
|
|
@@ -8487,10 +8595,10 @@ var HeaderInner = () => {
|
|
|
8487
8595
|
toggleSidebars("left");
|
|
8488
8596
|
},
|
|
8489
8597
|
title: "Toggle left sidebar",
|
|
8490
|
-
children: /* @__PURE__ */ (0,
|
|
8598
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(PanelLeft, { focusable: "false" })
|
|
8491
8599
|
}
|
|
8492
8600
|
) }),
|
|
8493
|
-
/* @__PURE__ */ (0,
|
|
8601
|
+
/* @__PURE__ */ (0, import_jsx_runtime42.jsx)("div", { className: getClassName27("rightSideBarToggle"), children: /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(
|
|
8494
8602
|
IconButton,
|
|
8495
8603
|
{
|
|
8496
8604
|
type: "button",
|
|
@@ -8498,19 +8606,19 @@ var HeaderInner = () => {
|
|
|
8498
8606
|
toggleSidebars("right");
|
|
8499
8607
|
},
|
|
8500
8608
|
title: "Toggle right sidebar",
|
|
8501
|
-
children: /* @__PURE__ */ (0,
|
|
8609
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(PanelRight, { focusable: "false" })
|
|
8502
8610
|
}
|
|
8503
8611
|
) })
|
|
8504
8612
|
] }),
|
|
8505
|
-
/* @__PURE__ */ (0,
|
|
8613
|
+
/* @__PURE__ */ (0, import_jsx_runtime42.jsx)("div", { className: getClassName27("title"), children: /* @__PURE__ */ (0, import_jsx_runtime42.jsxs)(Heading, { rank: "2", size: "xs", children: [
|
|
8506
8614
|
headerTitle || rootTitle || "Page",
|
|
8507
|
-
headerPath && /* @__PURE__ */ (0,
|
|
8615
|
+
headerPath && /* @__PURE__ */ (0, import_jsx_runtime42.jsxs)(import_jsx_runtime42.Fragment, { children: [
|
|
8508
8616
|
" ",
|
|
8509
|
-
/* @__PURE__ */ (0,
|
|
8617
|
+
/* @__PURE__ */ (0, import_jsx_runtime42.jsx)("code", { className: getClassName27("path"), children: headerPath })
|
|
8510
8618
|
] })
|
|
8511
8619
|
] }) }),
|
|
8512
|
-
/* @__PURE__ */ (0,
|
|
8513
|
-
/* @__PURE__ */ (0,
|
|
8620
|
+
/* @__PURE__ */ (0, import_jsx_runtime42.jsxs)("div", { className: getClassName27("tools"), children: [
|
|
8621
|
+
/* @__PURE__ */ (0, import_jsx_runtime42.jsx)("div", { className: getClassName27("menuButton"), children: /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(
|
|
8514
8622
|
IconButton,
|
|
8515
8623
|
{
|
|
8516
8624
|
type: "button",
|
|
@@ -8518,23 +8626,23 @@ var HeaderInner = () => {
|
|
|
8518
8626
|
return setMenuOpen(!menuOpen);
|
|
8519
8627
|
},
|
|
8520
8628
|
title: "Toggle menu bar",
|
|
8521
|
-
children: menuOpen ? /* @__PURE__ */ (0,
|
|
8629
|
+
children: menuOpen ? /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(ChevronUp, { focusable: "false" }) : /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(ChevronDown, { focusable: "false" })
|
|
8522
8630
|
}
|
|
8523
8631
|
) }),
|
|
8524
|
-
/* @__PURE__ */ (0,
|
|
8632
|
+
/* @__PURE__ */ (0, import_jsx_runtime42.jsx)(
|
|
8525
8633
|
MenuBar,
|
|
8526
8634
|
{
|
|
8527
8635
|
dispatch,
|
|
8528
8636
|
onPublish,
|
|
8529
8637
|
menuOpen,
|
|
8530
|
-
renderHeaderActions: () => /* @__PURE__ */ (0,
|
|
8638
|
+
renderHeaderActions: () => /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(CustomHeaderActions, { children: /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(
|
|
8531
8639
|
Button,
|
|
8532
8640
|
{
|
|
8533
8641
|
onClick: () => {
|
|
8534
8642
|
const data = appStore.getState().state.data;
|
|
8535
8643
|
onPublish && onPublish(data);
|
|
8536
8644
|
},
|
|
8537
|
-
icon: /* @__PURE__ */ (0,
|
|
8645
|
+
icon: /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(Globe, { size: "14px" }),
|
|
8538
8646
|
children: "Publish"
|
|
8539
8647
|
}
|
|
8540
8648
|
) }),
|
|
@@ -8548,11 +8656,203 @@ var HeaderInner = () => {
|
|
|
8548
8656
|
}
|
|
8549
8657
|
);
|
|
8550
8658
|
};
|
|
8551
|
-
var Header = (0,
|
|
8659
|
+
var Header = (0, import_react56.memo)(HeaderInner);
|
|
8660
|
+
|
|
8661
|
+
// components/Puck/components/Sidebar/index.tsx
|
|
8662
|
+
init_react_import();
|
|
8663
|
+
|
|
8664
|
+
// components/Puck/components/ResizeHandle/index.tsx
|
|
8665
|
+
init_react_import();
|
|
8666
|
+
var import_react57 = require("react");
|
|
8667
|
+
|
|
8668
|
+
// css-module:/home/runner/work/puck/puck/packages/core/components/Puck/components/ResizeHandle/styles.module.css#css-module
|
|
8669
|
+
init_react_import();
|
|
8670
|
+
var styles_module_default23 = { "ResizeHandle": "_ResizeHandle_v7w0r_1", "ResizeHandle--left": "_ResizeHandle--left_v7w0r_15", "ResizeHandle--right": "_ResizeHandle--right_v7w0r_19" };
|
|
8671
|
+
|
|
8672
|
+
// components/Puck/components/ResizeHandle/index.tsx
|
|
8673
|
+
var import_jsx_runtime43 = require("react/jsx-runtime");
|
|
8674
|
+
var getClassName28 = get_class_name_factory_default("ResizeHandle", styles_module_default23);
|
|
8675
|
+
var ResizeHandle = ({
|
|
8676
|
+
position,
|
|
8677
|
+
sidebarRef,
|
|
8678
|
+
onResize,
|
|
8679
|
+
onResizeEnd
|
|
8680
|
+
}) => {
|
|
8681
|
+
const { frameRef } = useCanvasFrame();
|
|
8682
|
+
const resetAutoZoom = useResetAutoZoom(frameRef);
|
|
8683
|
+
const handleRef = (0, import_react57.useRef)(null);
|
|
8684
|
+
const isDragging = (0, import_react57.useRef)(false);
|
|
8685
|
+
const startX = (0, import_react57.useRef)(0);
|
|
8686
|
+
const startWidth = (0, import_react57.useRef)(0);
|
|
8687
|
+
const handleMouseMove = (0, import_react57.useCallback)(
|
|
8688
|
+
(e) => {
|
|
8689
|
+
if (!isDragging.current) return;
|
|
8690
|
+
const delta = e.clientX - startX.current;
|
|
8691
|
+
const newWidth = position === "left" ? startWidth.current + delta : startWidth.current - delta;
|
|
8692
|
+
const width = Math.max(192, newWidth);
|
|
8693
|
+
onResize(width);
|
|
8694
|
+
e.preventDefault();
|
|
8695
|
+
},
|
|
8696
|
+
[onResize, position]
|
|
8697
|
+
);
|
|
8698
|
+
const handleMouseUp = (0, import_react57.useCallback)(() => {
|
|
8699
|
+
var _a;
|
|
8700
|
+
if (!isDragging.current) return;
|
|
8701
|
+
isDragging.current = false;
|
|
8702
|
+
document.body.style.cursor = "";
|
|
8703
|
+
document.body.style.userSelect = "";
|
|
8704
|
+
const overlay = document.getElementById("resize-overlay");
|
|
8705
|
+
if (overlay) {
|
|
8706
|
+
document.body.removeChild(overlay);
|
|
8707
|
+
}
|
|
8708
|
+
document.removeEventListener("mousemove", handleMouseMove);
|
|
8709
|
+
document.removeEventListener("mouseup", handleMouseUp);
|
|
8710
|
+
const finalWidth = ((_a = sidebarRef.current) == null ? void 0 : _a.getBoundingClientRect().width) || 0;
|
|
8711
|
+
onResizeEnd(finalWidth);
|
|
8712
|
+
resetAutoZoom();
|
|
8713
|
+
}, [onResizeEnd, resetAutoZoom]);
|
|
8714
|
+
const handleMouseDown = (0, import_react57.useCallback)(
|
|
8715
|
+
(e) => {
|
|
8716
|
+
var _a;
|
|
8717
|
+
isDragging.current = true;
|
|
8718
|
+
startX.current = e.clientX;
|
|
8719
|
+
startWidth.current = ((_a = sidebarRef.current) == null ? void 0 : _a.getBoundingClientRect().width) || 0;
|
|
8720
|
+
document.body.style.cursor = "col-resize";
|
|
8721
|
+
document.body.style.userSelect = "none";
|
|
8722
|
+
const overlay = document.createElement("div");
|
|
8723
|
+
overlay.id = "resize-overlay";
|
|
8724
|
+
overlay.setAttribute("data-resize-overlay", "");
|
|
8725
|
+
document.body.appendChild(overlay);
|
|
8726
|
+
document.addEventListener("mousemove", handleMouseMove);
|
|
8727
|
+
document.addEventListener("mouseup", handleMouseUp);
|
|
8728
|
+
e.preventDefault();
|
|
8729
|
+
},
|
|
8730
|
+
[position, handleMouseMove, handleMouseUp]
|
|
8731
|
+
);
|
|
8732
|
+
return /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(
|
|
8733
|
+
"div",
|
|
8734
|
+
{
|
|
8735
|
+
ref: handleRef,
|
|
8736
|
+
className: getClassName28({ [position]: true }),
|
|
8737
|
+
onMouseDown: handleMouseDown
|
|
8738
|
+
}
|
|
8739
|
+
);
|
|
8740
|
+
};
|
|
8741
|
+
|
|
8742
|
+
// css-module:/home/runner/work/puck/puck/packages/core/components/Puck/components/Sidebar/styles.module.css#css-module
|
|
8743
|
+
init_react_import();
|
|
8744
|
+
var styles_module_default24 = { "Sidebar": "_Sidebar_1xksb_1", "Sidebar--left": "_Sidebar--left_1xksb_8", "Sidebar--right": "_Sidebar--right_1xksb_14", "Sidebar-resizeHandle": "_Sidebar-resizeHandle_1xksb_20" };
|
|
8745
|
+
|
|
8746
|
+
// components/Puck/components/Sidebar/index.tsx
|
|
8747
|
+
var import_jsx_runtime44 = require("react/jsx-runtime");
|
|
8748
|
+
var getClassName29 = get_class_name_factory_default("Sidebar", styles_module_default24);
|
|
8749
|
+
var Sidebar = ({
|
|
8750
|
+
position,
|
|
8751
|
+
sidebarRef,
|
|
8752
|
+
isVisible,
|
|
8753
|
+
width,
|
|
8754
|
+
onResize,
|
|
8755
|
+
onResizeEnd,
|
|
8756
|
+
children
|
|
8757
|
+
}) => {
|
|
8758
|
+
if (!isVisible) return null;
|
|
8759
|
+
return /* @__PURE__ */ (0, import_jsx_runtime44.jsxs)(import_jsx_runtime44.Fragment, { children: [
|
|
8760
|
+
/* @__PURE__ */ (0, import_jsx_runtime44.jsx)("div", { ref: sidebarRef, className: getClassName29({ [position]: true }), children }),
|
|
8761
|
+
/* @__PURE__ */ (0, import_jsx_runtime44.jsx)("div", { className: `${getClassName29("resizeHandle")}`, children: /* @__PURE__ */ (0, import_jsx_runtime44.jsx)(
|
|
8762
|
+
ResizeHandle,
|
|
8763
|
+
{
|
|
8764
|
+
position,
|
|
8765
|
+
sidebarRef,
|
|
8766
|
+
onResize,
|
|
8767
|
+
onResizeEnd
|
|
8768
|
+
}
|
|
8769
|
+
) })
|
|
8770
|
+
] });
|
|
8771
|
+
};
|
|
8772
|
+
|
|
8773
|
+
// lib/use-sidebar-resize.ts
|
|
8774
|
+
init_react_import();
|
|
8775
|
+
var import_react58 = require("react");
|
|
8776
|
+
function useSidebarResize(position, dispatch) {
|
|
8777
|
+
const [width, setWidth] = (0, import_react58.useState)(null);
|
|
8778
|
+
const sidebarRef = (0, import_react58.useRef)(null);
|
|
8779
|
+
const storeWidth = useAppStore(
|
|
8780
|
+
(s) => position === "left" ? s.state.ui.leftSideBarWidth : s.state.ui.rightSideBarWidth
|
|
8781
|
+
);
|
|
8782
|
+
(0, import_react58.useEffect)(() => {
|
|
8783
|
+
if (typeof window !== "undefined" && !storeWidth) {
|
|
8784
|
+
try {
|
|
8785
|
+
const savedWidths = localStorage.getItem("puck-sidebar-widths");
|
|
8786
|
+
if (savedWidths) {
|
|
8787
|
+
const widths = JSON.parse(savedWidths);
|
|
8788
|
+
const savedWidth = widths[position];
|
|
8789
|
+
if (savedWidth) {
|
|
8790
|
+
dispatch({
|
|
8791
|
+
type: "setUi",
|
|
8792
|
+
ui: {
|
|
8793
|
+
[position === "left" ? "leftSideBarWidth" : "rightSideBarWidth"]: savedWidth
|
|
8794
|
+
}
|
|
8795
|
+
});
|
|
8796
|
+
}
|
|
8797
|
+
}
|
|
8798
|
+
} catch (error) {
|
|
8799
|
+
console.error(
|
|
8800
|
+
`Failed to load ${position} sidebar width from localStorage`,
|
|
8801
|
+
error
|
|
8802
|
+
);
|
|
8803
|
+
}
|
|
8804
|
+
}
|
|
8805
|
+
}, [dispatch, position, storeWidth]);
|
|
8806
|
+
(0, import_react58.useEffect)(() => {
|
|
8807
|
+
if (storeWidth !== void 0) {
|
|
8808
|
+
setWidth(storeWidth);
|
|
8809
|
+
}
|
|
8810
|
+
}, [storeWidth]);
|
|
8811
|
+
const handleResizeEnd = (0, import_react58.useCallback)(
|
|
8812
|
+
(width2) => {
|
|
8813
|
+
dispatch({
|
|
8814
|
+
type: "setUi",
|
|
8815
|
+
ui: {
|
|
8816
|
+
[position === "left" ? "leftSideBarWidth" : "rightSideBarWidth"]: width2
|
|
8817
|
+
}
|
|
8818
|
+
});
|
|
8819
|
+
let widths = {};
|
|
8820
|
+
try {
|
|
8821
|
+
const savedWidths = localStorage.getItem("puck-sidebar-widths");
|
|
8822
|
+
widths = savedWidths ? JSON.parse(savedWidths) : {};
|
|
8823
|
+
} catch (error) {
|
|
8824
|
+
console.error(
|
|
8825
|
+
`Failed to save ${position} sidebar width to localStorage`,
|
|
8826
|
+
error
|
|
8827
|
+
);
|
|
8828
|
+
} finally {
|
|
8829
|
+
localStorage.setItem(
|
|
8830
|
+
"puck-sidebar-widths",
|
|
8831
|
+
JSON.stringify(__spreadProps(__spreadValues({}, widths), {
|
|
8832
|
+
[position]: width2
|
|
8833
|
+
}))
|
|
8834
|
+
);
|
|
8835
|
+
}
|
|
8836
|
+
window.dispatchEvent(
|
|
8837
|
+
new CustomEvent("viewportchange", {
|
|
8838
|
+
bubbles: true,
|
|
8839
|
+
cancelable: false
|
|
8840
|
+
})
|
|
8841
|
+
);
|
|
8842
|
+
},
|
|
8843
|
+
[dispatch, position]
|
|
8844
|
+
);
|
|
8845
|
+
return {
|
|
8846
|
+
width,
|
|
8847
|
+
setWidth,
|
|
8848
|
+
sidebarRef,
|
|
8849
|
+
handleResizeEnd
|
|
8850
|
+
};
|
|
8851
|
+
}
|
|
8552
8852
|
|
|
8553
8853
|
// components/Puck/index.tsx
|
|
8554
|
-
var
|
|
8555
|
-
var
|
|
8854
|
+
var import_jsx_runtime45 = require("react/jsx-runtime");
|
|
8855
|
+
var getClassName30 = get_class_name_factory_default("Puck", styles_module_default14);
|
|
8556
8856
|
var getLayoutClassName = get_class_name_factory_default("PuckLayout", styles_module_default14);
|
|
8557
8857
|
var FieldSideBar = () => {
|
|
8558
8858
|
const title = useAppStore(
|
|
@@ -8561,13 +8861,13 @@ var FieldSideBar = () => {
|
|
|
8561
8861
|
return s.selectedItem ? (_b = (_a = s.config.components[s.selectedItem.type]) == null ? void 0 : _a["label"]) != null ? _b : s.selectedItem.type.toString() : "Page";
|
|
8562
8862
|
}
|
|
8563
8863
|
);
|
|
8564
|
-
return /* @__PURE__ */ (0,
|
|
8864
|
+
return /* @__PURE__ */ (0, import_jsx_runtime45.jsx)(SidebarSection, { noPadding: true, noBorderTop: true, showBreadcrumbs: true, title, children: /* @__PURE__ */ (0, import_jsx_runtime45.jsx)(Fields, {}) });
|
|
8565
8865
|
};
|
|
8566
|
-
var propsContext = (0,
|
|
8866
|
+
var propsContext = (0, import_react59.createContext)({});
|
|
8567
8867
|
function PropsProvider(props) {
|
|
8568
|
-
return /* @__PURE__ */ (0,
|
|
8868
|
+
return /* @__PURE__ */ (0, import_jsx_runtime45.jsx)(propsContext.Provider, { value: props, children: props.children });
|
|
8569
8869
|
}
|
|
8570
|
-
var usePropsContext = () => (0,
|
|
8870
|
+
var usePropsContext = () => (0, import_react59.useContext)(propsContext);
|
|
8571
8871
|
function PuckProvider({ children }) {
|
|
8572
8872
|
const {
|
|
8573
8873
|
config,
|
|
@@ -8583,14 +8883,14 @@ function PuckProvider({ children }) {
|
|
|
8583
8883
|
metadata,
|
|
8584
8884
|
onAction
|
|
8585
8885
|
} = usePropsContext();
|
|
8586
|
-
const iframe = (0,
|
|
8886
|
+
const iframe = (0, import_react59.useMemo)(
|
|
8587
8887
|
() => __spreadValues({
|
|
8588
8888
|
enabled: true,
|
|
8589
8889
|
waitForStyles: true
|
|
8590
8890
|
}, _iframe),
|
|
8591
8891
|
[_iframe]
|
|
8592
8892
|
);
|
|
8593
|
-
const [generatedAppState] = (0,
|
|
8893
|
+
const [generatedAppState] = (0, import_react59.useState)(() => {
|
|
8594
8894
|
var _a, _b, _c, _d, _e, _f, _g, _h, _i;
|
|
8595
8895
|
const initial = __spreadValues(__spreadValues({}, defaultAppState.ui), initialUi);
|
|
8596
8896
|
let clientUiState = {};
|
|
@@ -8619,7 +8919,7 @@ function PuckProvider({ children }) {
|
|
|
8619
8919
|
}
|
|
8620
8920
|
}
|
|
8621
8921
|
if (Object.keys((initialData == null ? void 0 : initialData.root) || {}).length > 0 && !((_g = initialData == null ? void 0 : initialData.root) == null ? void 0 : _g.props)) {
|
|
8622
|
-
console.
|
|
8922
|
+
console.warn(
|
|
8623
8923
|
"Warning: Defining props on `root` is deprecated. Please use `root.props`, or republish this page to migrate automatically."
|
|
8624
8924
|
);
|
|
8625
8925
|
}
|
|
@@ -8650,7 +8950,7 @@ function PuckProvider({ children }) {
|
|
|
8650
8950
|
return walkAppState(newAppState, config);
|
|
8651
8951
|
});
|
|
8652
8952
|
const { appendData = true } = _initialHistory || {};
|
|
8653
|
-
const [blendedHistories] = (0,
|
|
8953
|
+
const [blendedHistories] = (0, import_react59.useState)(
|
|
8654
8954
|
[
|
|
8655
8955
|
...(_initialHistory == null ? void 0 : _initialHistory.histories) || [],
|
|
8656
8956
|
...appendData ? [{ state: generatedAppState }] : []
|
|
@@ -8670,7 +8970,7 @@ function PuckProvider({ children }) {
|
|
|
8670
8970
|
overrides,
|
|
8671
8971
|
plugins
|
|
8672
8972
|
});
|
|
8673
|
-
const generateAppStore = (0,
|
|
8973
|
+
const generateAppStore = (0, import_react59.useCallback)(
|
|
8674
8974
|
(state) => {
|
|
8675
8975
|
return {
|
|
8676
8976
|
state,
|
|
@@ -8694,15 +8994,15 @@ function PuckProvider({ children }) {
|
|
|
8694
8994
|
metadata
|
|
8695
8995
|
]
|
|
8696
8996
|
);
|
|
8697
|
-
const [appStore] = (0,
|
|
8997
|
+
const [appStore] = (0, import_react59.useState)(
|
|
8698
8998
|
() => createAppStore(generateAppStore(initialAppState))
|
|
8699
8999
|
);
|
|
8700
|
-
(0,
|
|
9000
|
+
(0, import_react59.useEffect)(() => {
|
|
8701
9001
|
if (process.env.NODE_ENV !== "production") {
|
|
8702
9002
|
window.__PUCK_INTERNAL_DO_NOT_USE = { appStore };
|
|
8703
9003
|
}
|
|
8704
9004
|
}, [appStore]);
|
|
8705
|
-
(0,
|
|
9005
|
+
(0, import_react59.useEffect)(() => {
|
|
8706
9006
|
const state = appStore.getState().state;
|
|
8707
9007
|
appStore.setState(__spreadValues({}, generateAppStore(state)));
|
|
8708
9008
|
}, [config, plugins, loadedOverrides, viewports, iframe, onAction, metadata]);
|
|
@@ -8711,8 +9011,8 @@ function PuckProvider({ children }) {
|
|
|
8711
9011
|
index: initialHistoryIndex,
|
|
8712
9012
|
initialAppState
|
|
8713
9013
|
});
|
|
8714
|
-
const previousData = (0,
|
|
8715
|
-
(0,
|
|
9014
|
+
const previousData = (0, import_react59.useRef)(null);
|
|
9015
|
+
(0, import_react59.useEffect)(() => {
|
|
8716
9016
|
appStore.subscribe(
|
|
8717
9017
|
(s) => s.state.data,
|
|
8718
9018
|
(data) => {
|
|
@@ -8726,11 +9026,11 @@ function PuckProvider({ children }) {
|
|
|
8726
9026
|
}, []);
|
|
8727
9027
|
useRegisterPermissionsSlice(appStore, permissions);
|
|
8728
9028
|
const uPuckStore = useRegisterUsePuckStore(appStore);
|
|
8729
|
-
(0,
|
|
9029
|
+
(0, import_react59.useEffect)(() => {
|
|
8730
9030
|
const { resolveAndCommitData } = appStore.getState();
|
|
8731
9031
|
resolveAndCommitData();
|
|
8732
9032
|
}, []);
|
|
8733
|
-
return /* @__PURE__ */ (0,
|
|
9033
|
+
return /* @__PURE__ */ (0, import_jsx_runtime45.jsx)(appStoreContext.Provider, { value: appStore, children: /* @__PURE__ */ (0, import_jsx_runtime45.jsx)(UsePuckStoreContext.Provider, { value: uPuckStore, children }) });
|
|
8734
9034
|
}
|
|
8735
9035
|
function PuckLayout({ children }) {
|
|
8736
9036
|
const {
|
|
@@ -8738,7 +9038,7 @@ function PuckLayout({ children }) {
|
|
|
8738
9038
|
dnd,
|
|
8739
9039
|
initialHistory: _initialHistory
|
|
8740
9040
|
} = usePropsContext();
|
|
8741
|
-
const iframe = (0,
|
|
9041
|
+
const iframe = (0, import_react59.useMemo)(
|
|
8742
9042
|
() => __spreadValues({
|
|
8743
9043
|
enabled: true,
|
|
8744
9044
|
waitForStyles: true
|
|
@@ -8746,12 +9046,24 @@ function PuckLayout({ children }) {
|
|
|
8746
9046
|
[_iframe]
|
|
8747
9047
|
);
|
|
8748
9048
|
useInjectGlobalCss(iframe.enabled);
|
|
9049
|
+
const dispatch = useAppStore((s) => s.dispatch);
|
|
8749
9050
|
const leftSideBarVisible = useAppStore((s) => s.state.ui.leftSideBarVisible);
|
|
8750
9051
|
const rightSideBarVisible = useAppStore(
|
|
8751
9052
|
(s) => s.state.ui.rightSideBarVisible
|
|
8752
9053
|
);
|
|
8753
|
-
const
|
|
8754
|
-
|
|
9054
|
+
const {
|
|
9055
|
+
width: leftWidth,
|
|
9056
|
+
setWidth: setLeftWidth,
|
|
9057
|
+
sidebarRef: leftSidebarRef,
|
|
9058
|
+
handleResizeEnd: handleLeftSidebarResizeEnd
|
|
9059
|
+
} = useSidebarResize("left", dispatch);
|
|
9060
|
+
const {
|
|
9061
|
+
width: rightWidth,
|
|
9062
|
+
setWidth: setRightWidth,
|
|
9063
|
+
sidebarRef: rightSidebarRef,
|
|
9064
|
+
handleResizeEnd: handleRightSidebarResizeEnd
|
|
9065
|
+
} = useSidebarResize("right", dispatch);
|
|
9066
|
+
(0, import_react59.useEffect)(() => {
|
|
8755
9067
|
if (!window.matchMedia("(min-width: 638px)").matches) {
|
|
8756
9068
|
dispatch({
|
|
8757
9069
|
type: "setUi",
|
|
@@ -8775,17 +9087,17 @@ function PuckLayout({ children }) {
|
|
|
8775
9087
|
};
|
|
8776
9088
|
}, []);
|
|
8777
9089
|
const overrides = useAppStore((s) => s.overrides);
|
|
8778
|
-
const CustomPuck = (0,
|
|
9090
|
+
const CustomPuck = (0, import_react59.useMemo)(
|
|
8779
9091
|
() => overrides.puck || DefaultOverride,
|
|
8780
9092
|
[overrides]
|
|
8781
9093
|
);
|
|
8782
|
-
const [mounted, setMounted] = (0,
|
|
8783
|
-
(0,
|
|
9094
|
+
const [mounted, setMounted] = (0, import_react59.useState)(false);
|
|
9095
|
+
(0, import_react59.useEffect)(() => {
|
|
8784
9096
|
setMounted(true);
|
|
8785
9097
|
}, []);
|
|
8786
9098
|
const ready = useAppStore((s) => s.status === "READY");
|
|
8787
9099
|
useMonitorHotkeys();
|
|
8788
|
-
(0,
|
|
9100
|
+
(0, import_react59.useEffect)(() => {
|
|
8789
9101
|
if (ready && iframe.enabled) {
|
|
8790
9102
|
const frameDoc = getFrame();
|
|
8791
9103
|
if (frameDoc) {
|
|
@@ -8794,8 +9106,8 @@ function PuckLayout({ children }) {
|
|
|
8794
9106
|
}
|
|
8795
9107
|
}, [ready, iframe.enabled]);
|
|
8796
9108
|
usePreviewModeHotkeys();
|
|
8797
|
-
return /* @__PURE__ */ (0,
|
|
8798
|
-
/* @__PURE__ */ (0,
|
|
9109
|
+
return /* @__PURE__ */ (0, import_jsx_runtime45.jsxs)("div", { className: `Puck ${getClassName30()}`, children: [
|
|
9110
|
+
/* @__PURE__ */ (0, import_jsx_runtime45.jsx)(DragDropContext, { disableAutoScroll: dnd == null ? void 0 : dnd.disableAutoScroll, children: /* @__PURE__ */ (0, import_jsx_runtime45.jsx)(CustomPuck, { children: children || /* @__PURE__ */ (0, import_jsx_runtime45.jsx)(FrameProvider, { children: /* @__PURE__ */ (0, import_jsx_runtime45.jsx)(
|
|
8799
9111
|
"div",
|
|
8800
9112
|
{
|
|
8801
9113
|
className: getLayoutClassName({
|
|
@@ -8803,22 +9115,57 @@ function PuckLayout({ children }) {
|
|
|
8803
9115
|
mounted,
|
|
8804
9116
|
rightSideBarVisible
|
|
8805
9117
|
}),
|
|
8806
|
-
children: /* @__PURE__ */ (0,
|
|
8807
|
-
|
|
8808
|
-
|
|
8809
|
-
|
|
8810
|
-
|
|
8811
|
-
|
|
8812
|
-
|
|
8813
|
-
|
|
8814
|
-
|
|
9118
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime45.jsxs)(
|
|
9119
|
+
"div",
|
|
9120
|
+
{
|
|
9121
|
+
className: getLayoutClassName("inner"),
|
|
9122
|
+
style: {
|
|
9123
|
+
gridTemplateColumns: `
|
|
9124
|
+
${leftSideBarVisible ? leftWidth ? `${leftWidth}px` : "var(--puck-side-bar-width)" : "0"}
|
|
9125
|
+
var(--puck-frame-width)
|
|
9126
|
+
${rightSideBarVisible ? rightWidth ? `${rightWidth}px` : "var(--puck-side-bar-width)" : "0"}
|
|
9127
|
+
`
|
|
9128
|
+
},
|
|
9129
|
+
children: [
|
|
9130
|
+
/* @__PURE__ */ (0, import_jsx_runtime45.jsx)(Header, {}),
|
|
9131
|
+
/* @__PURE__ */ (0, import_jsx_runtime45.jsxs)(
|
|
9132
|
+
Sidebar,
|
|
9133
|
+
{
|
|
9134
|
+
position: "left",
|
|
9135
|
+
sidebarRef: leftSidebarRef,
|
|
9136
|
+
isVisible: leftSideBarVisible,
|
|
9137
|
+
width: leftWidth,
|
|
9138
|
+
onResize: setLeftWidth,
|
|
9139
|
+
onResizeEnd: handleLeftSidebarResizeEnd,
|
|
9140
|
+
children: [
|
|
9141
|
+
/* @__PURE__ */ (0, import_jsx_runtime45.jsx)(SidebarSection, { title: "Components", noBorderTop: true, children: /* @__PURE__ */ (0, import_jsx_runtime45.jsx)(Components, {}) }),
|
|
9142
|
+
/* @__PURE__ */ (0, import_jsx_runtime45.jsx)(SidebarSection, { title: "Outline", children: /* @__PURE__ */ (0, import_jsx_runtime45.jsx)(Outline, {}) })
|
|
9143
|
+
]
|
|
9144
|
+
}
|
|
9145
|
+
),
|
|
9146
|
+
/* @__PURE__ */ (0, import_jsx_runtime45.jsx)(Canvas, {}),
|
|
9147
|
+
/* @__PURE__ */ (0, import_jsx_runtime45.jsx)(
|
|
9148
|
+
Sidebar,
|
|
9149
|
+
{
|
|
9150
|
+
position: "right",
|
|
9151
|
+
sidebarRef: rightSidebarRef,
|
|
9152
|
+
isVisible: rightSideBarVisible,
|
|
9153
|
+
width: rightWidth,
|
|
9154
|
+
onResize: setRightWidth,
|
|
9155
|
+
onResizeEnd: handleRightSidebarResizeEnd,
|
|
9156
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime45.jsx)(FieldSideBar, {})
|
|
9157
|
+
}
|
|
9158
|
+
)
|
|
9159
|
+
]
|
|
9160
|
+
}
|
|
9161
|
+
)
|
|
8815
9162
|
}
|
|
8816
|
-
) }) }),
|
|
8817
|
-
/* @__PURE__ */ (0,
|
|
9163
|
+
) }) }) }),
|
|
9164
|
+
/* @__PURE__ */ (0, import_jsx_runtime45.jsx)("div", { id: "puck-portal-root", className: getClassName30("portal") })
|
|
8818
9165
|
] });
|
|
8819
9166
|
}
|
|
8820
9167
|
function Puck(props) {
|
|
8821
|
-
return /* @__PURE__ */ (0,
|
|
9168
|
+
return /* @__PURE__ */ (0, import_jsx_runtime45.jsx)(PropsProvider, __spreadProps(__spreadValues({}, props), { children: /* @__PURE__ */ (0, import_jsx_runtime45.jsx)(PuckProvider, __spreadProps(__spreadValues({}, props), { children: /* @__PURE__ */ (0, import_jsx_runtime45.jsx)(PuckLayout, __spreadValues({}, props)) })) }));
|
|
8822
9169
|
}
|
|
8823
9170
|
Puck.Components = Components;
|
|
8824
9171
|
Puck.Fields = Fields;
|
|
@@ -8987,6 +9334,36 @@ function transformProps(data, propTransforms, config = { components: {} }) {
|
|
|
8987
9334
|
return updatedData;
|
|
8988
9335
|
}
|
|
8989
9336
|
|
|
9337
|
+
// lib/overlay-portal/index.tsx
|
|
9338
|
+
init_react_import();
|
|
9339
|
+
var registerOverlayPortal = (el, opts = {}) => {
|
|
9340
|
+
if (!el) return;
|
|
9341
|
+
const { disableDrag = true } = opts;
|
|
9342
|
+
const stopPropagation = (e) => {
|
|
9343
|
+
e.stopPropagation();
|
|
9344
|
+
};
|
|
9345
|
+
el.addEventListener("mouseover", stopPropagation, {
|
|
9346
|
+
capture: true
|
|
9347
|
+
});
|
|
9348
|
+
if (disableDrag) {
|
|
9349
|
+
el.addEventListener("pointerdown", stopPropagation, {
|
|
9350
|
+
capture: true
|
|
9351
|
+
});
|
|
9352
|
+
}
|
|
9353
|
+
el.setAttribute("data-puck-overlay-portal", "true");
|
|
9354
|
+
return () => {
|
|
9355
|
+
el.removeEventListener("mouseover", stopPropagation, {
|
|
9356
|
+
capture: true
|
|
9357
|
+
});
|
|
9358
|
+
if (disableDrag) {
|
|
9359
|
+
el.removeEventListener("pointerdown", stopPropagation, {
|
|
9360
|
+
capture: true
|
|
9361
|
+
});
|
|
9362
|
+
}
|
|
9363
|
+
el.removeAttribute("data-puck-overlay-portal");
|
|
9364
|
+
};
|
|
9365
|
+
};
|
|
9366
|
+
|
|
8990
9367
|
// lib/resolve-all-data.ts
|
|
8991
9368
|
init_react_import();
|
|
8992
9369
|
|
|
@@ -9065,6 +9442,7 @@ function resolveAllData(_0, _1) {
|
|
|
9065
9442
|
createUsePuck,
|
|
9066
9443
|
migrate,
|
|
9067
9444
|
overrideKeys,
|
|
9445
|
+
registerOverlayPortal,
|
|
9068
9446
|
renderContext,
|
|
9069
9447
|
resolveAllData,
|
|
9070
9448
|
transformProps,
|