@measured/puck 0.20.0-canary.6dace1cf → 0.20.0-canary.88a4251d
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-4KAREQPB.mjs → chunk-EMTLDPBH.mjs} +2396 -2050
- package/dist/index.css +76 -31
- package/dist/index.d.mts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +1159 -818
- package/dist/index.mjs +1 -1
- package/dist/no-external.css +76 -31
- package/dist/no-external.d.mts +1 -1
- package/dist/no-external.d.ts +1 -1
- package/dist/no-external.js +1159 -818
- package/dist/no-external.mjs +1 -1
- package/dist/rsc.d.mts +2 -2
- package/dist/rsc.d.ts +2 -2
- package/dist/{walk-tree-DrNRq2FV.d.mts → walk-tree-BCI5tk0w.d.mts} +2 -0
- package/dist/{walk-tree-DrNRq2FV.d.ts → walk-tree-BCI5tk0w.d.ts} +2 -0
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -309,7 +309,7 @@ init_react_import();
|
|
|
309
309
|
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
310
|
|
|
311
311
|
// components/AutoField/index.tsx
|
|
312
|
-
var
|
|
312
|
+
var import_react21 = require("react");
|
|
313
313
|
|
|
314
314
|
// components/AutoField/fields/index.tsx
|
|
315
315
|
init_react_import();
|
|
@@ -653,7 +653,7 @@ init_react_import();
|
|
|
653
653
|
|
|
654
654
|
// components/IconButton/IconButton.tsx
|
|
655
655
|
init_react_import();
|
|
656
|
-
var
|
|
656
|
+
var import_react10 = require("react");
|
|
657
657
|
|
|
658
658
|
// css-module:/home/runner/work/puck/puck/packages/core/components/IconButton/IconButton.module.css#css-module
|
|
659
659
|
init_react_import();
|
|
@@ -686,102 +686,9 @@ var replace = (list, index, newItem) => {
|
|
|
686
686
|
return result;
|
|
687
687
|
};
|
|
688
688
|
|
|
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
|
|
689
|
+
// lib/use-reset-auto-zoom.ts
|
|
778
690
|
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" }) }) });
|
|
691
|
+
var import_react9 = require("react");
|
|
785
692
|
|
|
786
693
|
// store/index.ts
|
|
787
694
|
init_react_import();
|
|
@@ -1684,15 +1591,15 @@ var defaultViewports = [
|
|
|
1684
1591
|
// store/index.ts
|
|
1685
1592
|
var import_zustand2 = require("zustand");
|
|
1686
1593
|
var import_middleware2 = require("zustand/middleware");
|
|
1687
|
-
var
|
|
1594
|
+
var import_react8 = require("react");
|
|
1688
1595
|
|
|
1689
1596
|
// store/slices/history.ts
|
|
1690
1597
|
init_react_import();
|
|
1691
|
-
var
|
|
1598
|
+
var import_react5 = require("react");
|
|
1692
1599
|
|
|
1693
1600
|
// lib/use-hotkey.ts
|
|
1694
1601
|
init_react_import();
|
|
1695
|
-
var
|
|
1602
|
+
var import_react4 = require("react");
|
|
1696
1603
|
var import_zustand = require("zustand");
|
|
1697
1604
|
var import_middleware = require("zustand/middleware");
|
|
1698
1605
|
var keyCodeMap = {
|
|
@@ -1785,10 +1692,10 @@ var monitorHotkeys = (doc) => {
|
|
|
1785
1692
|
};
|
|
1786
1693
|
};
|
|
1787
1694
|
var useMonitorHotkeys = () => {
|
|
1788
|
-
(0,
|
|
1695
|
+
(0, import_react4.useEffect)(() => monitorHotkeys(document), []);
|
|
1789
1696
|
};
|
|
1790
1697
|
var useHotkey = (combo, cb) => {
|
|
1791
|
-
(0,
|
|
1698
|
+
(0, import_react4.useEffect)(
|
|
1792
1699
|
() => useHotkeyStore.setState((s) => ({
|
|
1793
1700
|
triggers: __spreadProps(__spreadValues({}, s.triggers), {
|
|
1794
1701
|
[`${Object.keys(combo).join("+")}`]: { combo, cb }
|
|
@@ -1897,7 +1804,7 @@ function useRegisterHistorySlice(appStore, {
|
|
|
1897
1804
|
index,
|
|
1898
1805
|
initialAppState
|
|
1899
1806
|
}) {
|
|
1900
|
-
(0,
|
|
1807
|
+
(0, import_react5.useEffect)(
|
|
1901
1808
|
() => appStore.setState({
|
|
1902
1809
|
history: __spreadProps(__spreadValues({}, appStore.getState().history), {
|
|
1903
1810
|
histories,
|
|
@@ -1964,7 +1871,7 @@ var createNodesSlice = (set, get) => ({
|
|
|
1964
1871
|
|
|
1965
1872
|
// store/slices/permissions.ts
|
|
1966
1873
|
init_react_import();
|
|
1967
|
-
var
|
|
1874
|
+
var import_react6 = require("react");
|
|
1968
1875
|
|
|
1969
1876
|
// lib/data/flatten-data.ts
|
|
1970
1877
|
init_react_import();
|
|
@@ -2101,7 +2008,7 @@ var createPermissionsSlice = (set, get) => {
|
|
|
2101
2008
|
};
|
|
2102
2009
|
};
|
|
2103
2010
|
var useRegisterPermissionsSlice = (appStore, globalPermissions) => {
|
|
2104
|
-
(0,
|
|
2011
|
+
(0, import_react6.useEffect)(() => {
|
|
2105
2012
|
const { permissions } = appStore.getState();
|
|
2106
2013
|
const { globalPermissions: existingGlobalPermissions } = permissions;
|
|
2107
2014
|
appStore.setState({
|
|
@@ -2111,7 +2018,7 @@ var useRegisterPermissionsSlice = (appStore, globalPermissions) => {
|
|
|
2111
2018
|
});
|
|
2112
2019
|
permissions.resolvePermissions();
|
|
2113
2020
|
}, [globalPermissions]);
|
|
2114
|
-
(0,
|
|
2021
|
+
(0, import_react6.useEffect)(() => {
|
|
2115
2022
|
return appStore.subscribe(
|
|
2116
2023
|
(s) => s.state.data,
|
|
2117
2024
|
() => {
|
|
@@ -2119,7 +2026,7 @@ var useRegisterPermissionsSlice = (appStore, globalPermissions) => {
|
|
|
2119
2026
|
}
|
|
2120
2027
|
);
|
|
2121
2028
|
}, []);
|
|
2122
|
-
(0,
|
|
2029
|
+
(0, import_react6.useEffect)(() => {
|
|
2123
2030
|
return appStore.subscribe(
|
|
2124
2031
|
(s) => s.config,
|
|
2125
2032
|
() => {
|
|
@@ -2131,7 +2038,7 @@ var useRegisterPermissionsSlice = (appStore, globalPermissions) => {
|
|
|
2131
2038
|
|
|
2132
2039
|
// store/slices/fields.ts
|
|
2133
2040
|
init_react_import();
|
|
2134
|
-
var
|
|
2041
|
+
var import_react7 = require("react");
|
|
2135
2042
|
var createFieldsSlice = (_set, _get) => {
|
|
2136
2043
|
return {
|
|
2137
2044
|
fields: {},
|
|
@@ -2141,7 +2048,7 @@ var createFieldsSlice = (_set, _get) => {
|
|
|
2141
2048
|
};
|
|
2142
2049
|
};
|
|
2143
2050
|
var useRegisterFieldsSlice = (appStore, id) => {
|
|
2144
|
-
const resolveFields = (0,
|
|
2051
|
+
const resolveFields = (0, import_react7.useCallback)(
|
|
2145
2052
|
(reset) => __async(void 0, null, function* () {
|
|
2146
2053
|
var _a, _b;
|
|
2147
2054
|
const { fields, lastResolvedData } = appStore.getState().fields;
|
|
@@ -2198,7 +2105,7 @@ var useRegisterFieldsSlice = (appStore, id) => {
|
|
|
2198
2105
|
}),
|
|
2199
2106
|
[id]
|
|
2200
2107
|
);
|
|
2201
|
-
(0,
|
|
2108
|
+
(0, import_react7.useEffect)(() => {
|
|
2202
2109
|
resolveFields(true);
|
|
2203
2110
|
return appStore.subscribe(
|
|
2204
2111
|
(s) => s.state.indexes.nodes[id || "root"],
|
|
@@ -2490,133 +2397,435 @@ var createAppStore = (initialAppStore) => (0, import_zustand2.create)()(
|
|
|
2490
2397
|
});
|
|
2491
2398
|
})
|
|
2492
2399
|
);
|
|
2493
|
-
var appStoreContext = (0,
|
|
2400
|
+
var appStoreContext = (0, import_react8.createContext)(createAppStore());
|
|
2494
2401
|
function useAppStore(selector) {
|
|
2495
|
-
const context = (0,
|
|
2402
|
+
const context = (0, import_react8.useContext)(appStoreContext);
|
|
2496
2403
|
return (0, import_zustand2.useStore)(context, selector);
|
|
2497
2404
|
}
|
|
2498
2405
|
function useAppStoreApi() {
|
|
2499
|
-
return (0,
|
|
2406
|
+
return (0, import_react8.useContext)(appStoreContext);
|
|
2500
2407
|
}
|
|
2501
2408
|
|
|
2502
|
-
//
|
|
2503
|
-
init_react_import();
|
|
2504
|
-
var import_react12 = require("@dnd-kit/react");
|
|
2505
|
-
|
|
2506
|
-
// lib/dnd/use-sensors.ts
|
|
2409
|
+
// lib/get-zoom-config.ts
|
|
2507
2410
|
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
2411
|
|
|
2542
|
-
//
|
|
2412
|
+
// ../../node_modules/css-box-model/dist/css-box-model.esm.js
|
|
2543
2413
|
init_react_import();
|
|
2544
|
-
var import_abstract8 = require("@dnd-kit/abstract");
|
|
2545
2414
|
|
|
2546
|
-
//
|
|
2415
|
+
// ../../node_modules/tiny-invariant/dist/esm/tiny-invariant.js
|
|
2547
2416
|
init_react_import();
|
|
2548
|
-
var
|
|
2417
|
+
var isProduction = process.env.NODE_ENV === "production";
|
|
2418
|
+
var prefix = "Invariant failed";
|
|
2419
|
+
function invariant(condition, message) {
|
|
2420
|
+
if (condition) {
|
|
2421
|
+
return;
|
|
2422
|
+
}
|
|
2423
|
+
if (isProduction) {
|
|
2424
|
+
throw new Error(prefix);
|
|
2425
|
+
}
|
|
2426
|
+
var provided = typeof message === "function" ? message() : message;
|
|
2427
|
+
var value = provided ? "".concat(prefix, ": ").concat(provided) : prefix;
|
|
2428
|
+
throw new Error(value);
|
|
2429
|
+
}
|
|
2549
2430
|
|
|
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;
|
|
2431
|
+
// ../../node_modules/css-box-model/dist/css-box-model.esm.js
|
|
2432
|
+
var getRect = function getRect2(_ref) {
|
|
2433
|
+
var top = _ref.top, right = _ref.right, bottom = _ref.bottom, left = _ref.left;
|
|
2434
|
+
var width = right - left;
|
|
2435
|
+
var height = bottom - top;
|
|
2436
|
+
var rect = {
|
|
2437
|
+
top,
|
|
2438
|
+
right,
|
|
2439
|
+
bottom,
|
|
2440
|
+
left,
|
|
2441
|
+
width,
|
|
2442
|
+
height,
|
|
2443
|
+
x: left,
|
|
2444
|
+
y: top,
|
|
2445
|
+
center: {
|
|
2446
|
+
x: (right + left) / 2,
|
|
2447
|
+
y: (bottom + top) / 2
|
|
2595
2448
|
}
|
|
2596
|
-
}
|
|
2449
|
+
};
|
|
2450
|
+
return rect;
|
|
2597
2451
|
};
|
|
2598
|
-
|
|
2599
|
-
|
|
2600
|
-
|
|
2601
|
-
|
|
2602
|
-
|
|
2603
|
-
|
|
2604
|
-
|
|
2605
|
-
|
|
2606
|
-
|
|
2607
|
-
|
|
2608
|
-
|
|
2609
|
-
|
|
2610
|
-
|
|
2611
|
-
|
|
2612
|
-
|
|
2613
|
-
|
|
2614
|
-
|
|
2615
|
-
|
|
2616
|
-
|
|
2617
|
-
|
|
2618
|
-
|
|
2619
|
-
|
|
2452
|
+
var expand = function expand2(target, expandBy) {
|
|
2453
|
+
return {
|
|
2454
|
+
top: target.top - expandBy.top,
|
|
2455
|
+
left: target.left - expandBy.left,
|
|
2456
|
+
bottom: target.bottom + expandBy.bottom,
|
|
2457
|
+
right: target.right + expandBy.right
|
|
2458
|
+
};
|
|
2459
|
+
};
|
|
2460
|
+
var shrink = function shrink2(target, shrinkBy) {
|
|
2461
|
+
return {
|
|
2462
|
+
top: target.top + shrinkBy.top,
|
|
2463
|
+
left: target.left + shrinkBy.left,
|
|
2464
|
+
bottom: target.bottom - shrinkBy.bottom,
|
|
2465
|
+
right: target.right - shrinkBy.right
|
|
2466
|
+
};
|
|
2467
|
+
};
|
|
2468
|
+
var noSpacing = {
|
|
2469
|
+
top: 0,
|
|
2470
|
+
right: 0,
|
|
2471
|
+
bottom: 0,
|
|
2472
|
+
left: 0
|
|
2473
|
+
};
|
|
2474
|
+
var createBox = function createBox2(_ref2) {
|
|
2475
|
+
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;
|
|
2476
|
+
var marginBox = getRect(expand(borderBox, margin));
|
|
2477
|
+
var paddingBox = getRect(shrink(borderBox, border));
|
|
2478
|
+
var contentBox = getRect(shrink(paddingBox, padding));
|
|
2479
|
+
return {
|
|
2480
|
+
marginBox,
|
|
2481
|
+
borderBox: getRect(borderBox),
|
|
2482
|
+
paddingBox,
|
|
2483
|
+
contentBox,
|
|
2484
|
+
margin,
|
|
2485
|
+
border,
|
|
2486
|
+
padding
|
|
2487
|
+
};
|
|
2488
|
+
};
|
|
2489
|
+
var parse = function parse2(raw) {
|
|
2490
|
+
var value = raw.slice(0, -2);
|
|
2491
|
+
var suffix = raw.slice(-2);
|
|
2492
|
+
if (suffix !== "px") {
|
|
2493
|
+
return 0;
|
|
2494
|
+
}
|
|
2495
|
+
var result = Number(value);
|
|
2496
|
+
!!isNaN(result) ? process.env.NODE_ENV !== "production" ? invariant(false, "Could not parse value [raw: " + raw + ", without suffix: " + value + "]") : invariant(false) : void 0;
|
|
2497
|
+
return result;
|
|
2498
|
+
};
|
|
2499
|
+
var calculateBox = function calculateBox2(borderBox, styles2) {
|
|
2500
|
+
var margin = {
|
|
2501
|
+
top: parse(styles2.marginTop),
|
|
2502
|
+
right: parse(styles2.marginRight),
|
|
2503
|
+
bottom: parse(styles2.marginBottom),
|
|
2504
|
+
left: parse(styles2.marginLeft)
|
|
2505
|
+
};
|
|
2506
|
+
var padding = {
|
|
2507
|
+
top: parse(styles2.paddingTop),
|
|
2508
|
+
right: parse(styles2.paddingRight),
|
|
2509
|
+
bottom: parse(styles2.paddingBottom),
|
|
2510
|
+
left: parse(styles2.paddingLeft)
|
|
2511
|
+
};
|
|
2512
|
+
var border = {
|
|
2513
|
+
top: parse(styles2.borderTopWidth),
|
|
2514
|
+
right: parse(styles2.borderRightWidth),
|
|
2515
|
+
bottom: parse(styles2.borderBottomWidth),
|
|
2516
|
+
left: parse(styles2.borderLeftWidth)
|
|
2517
|
+
};
|
|
2518
|
+
return createBox({
|
|
2519
|
+
borderBox,
|
|
2520
|
+
margin,
|
|
2521
|
+
padding,
|
|
2522
|
+
border
|
|
2523
|
+
});
|
|
2524
|
+
};
|
|
2525
|
+
var getBox = function getBox2(el) {
|
|
2526
|
+
var borderBox = el.getBoundingClientRect();
|
|
2527
|
+
var styles2 = window.getComputedStyle(el);
|
|
2528
|
+
return calculateBox(borderBox, styles2);
|
|
2529
|
+
};
|
|
2530
|
+
|
|
2531
|
+
// lib/get-zoom-config.ts
|
|
2532
|
+
var RESET_ZOOM_SMALLER_THAN_FRAME = true;
|
|
2533
|
+
var getZoomConfig = (uiViewport, frame, zoom) => {
|
|
2534
|
+
const box = getBox(frame);
|
|
2535
|
+
const { width: frameWidth, height: frameHeight } = box.contentBox;
|
|
2536
|
+
const viewportHeight = uiViewport.height === "auto" ? frameHeight : uiViewport.height;
|
|
2537
|
+
let rootHeight = 0;
|
|
2538
|
+
let autoZoom = 1;
|
|
2539
|
+
if (uiViewport.width > frameWidth || viewportHeight > frameHeight) {
|
|
2540
|
+
const widthZoom = Math.min(frameWidth / uiViewport.width, 1);
|
|
2541
|
+
const heightZoom = Math.min(frameHeight / viewportHeight, 1);
|
|
2542
|
+
zoom = widthZoom;
|
|
2543
|
+
if (widthZoom < heightZoom) {
|
|
2544
|
+
rootHeight = viewportHeight / zoom;
|
|
2545
|
+
} else {
|
|
2546
|
+
rootHeight = viewportHeight;
|
|
2547
|
+
zoom = heightZoom;
|
|
2548
|
+
}
|
|
2549
|
+
autoZoom = zoom;
|
|
2550
|
+
} else {
|
|
2551
|
+
if (RESET_ZOOM_SMALLER_THAN_FRAME) {
|
|
2552
|
+
autoZoom = 1;
|
|
2553
|
+
zoom = 1;
|
|
2554
|
+
rootHeight = viewportHeight;
|
|
2555
|
+
}
|
|
2556
|
+
}
|
|
2557
|
+
return { autoZoom, rootHeight, zoom };
|
|
2558
|
+
};
|
|
2559
|
+
|
|
2560
|
+
// lib/use-reset-auto-zoom.ts
|
|
2561
|
+
var import_shallow = require("zustand/react/shallow");
|
|
2562
|
+
var useResetAutoZoom = (frameRef) => {
|
|
2563
|
+
const { viewports, zoomConfig, setZoomConfig } = useAppStore(
|
|
2564
|
+
(0, import_shallow.useShallow)((s) => ({
|
|
2565
|
+
viewports: s.state.ui.viewports,
|
|
2566
|
+
zoomConfig: s.zoomConfig,
|
|
2567
|
+
setZoomConfig: s.setZoomConfig
|
|
2568
|
+
}))
|
|
2569
|
+
);
|
|
2570
|
+
const resetAutoZoom = (0, import_react9.useCallback)(
|
|
2571
|
+
(options) => {
|
|
2572
|
+
const newViewports = (options == null ? void 0 : options.viewports) || viewports;
|
|
2573
|
+
if (!(options == null ? void 0 : options.isResettingRef)) {
|
|
2574
|
+
if (frameRef.current) {
|
|
2575
|
+
setZoomConfig(
|
|
2576
|
+
getZoomConfig(
|
|
2577
|
+
newViewports == null ? void 0 : newViewports.current,
|
|
2578
|
+
frameRef.current,
|
|
2579
|
+
zoomConfig.zoom
|
|
2580
|
+
)
|
|
2581
|
+
);
|
|
2582
|
+
}
|
|
2583
|
+
return;
|
|
2584
|
+
}
|
|
2585
|
+
const {
|
|
2586
|
+
isResettingRef,
|
|
2587
|
+
setShowTransition,
|
|
2588
|
+
showTransition = false
|
|
2589
|
+
} = options;
|
|
2590
|
+
if (!isResettingRef.current) {
|
|
2591
|
+
isResettingRef.current = true;
|
|
2592
|
+
if (setShowTransition) {
|
|
2593
|
+
setShowTransition(showTransition);
|
|
2594
|
+
}
|
|
2595
|
+
if (frameRef.current) {
|
|
2596
|
+
setZoomConfig(
|
|
2597
|
+
getZoomConfig(
|
|
2598
|
+
newViewports == null ? void 0 : newViewports.current,
|
|
2599
|
+
frameRef.current,
|
|
2600
|
+
zoomConfig.zoom
|
|
2601
|
+
)
|
|
2602
|
+
);
|
|
2603
|
+
}
|
|
2604
|
+
setTimeout(() => {
|
|
2605
|
+
isResettingRef.current = false;
|
|
2606
|
+
}, 0);
|
|
2607
|
+
}
|
|
2608
|
+
},
|
|
2609
|
+
[frameRef, zoomConfig, viewports, setZoomConfig]
|
|
2610
|
+
);
|
|
2611
|
+
return resetAutoZoom;
|
|
2612
|
+
};
|
|
2613
|
+
|
|
2614
|
+
// css-module:/home/runner/work/puck/puck/packages/core/components/Loader/styles.module.css#css-module
|
|
2615
|
+
init_react_import();
|
|
2616
|
+
var styles_module_default4 = { "Loader": "_Loader_nacdm_13", "loader-animation": "_loader-animation_nacdm_1" };
|
|
2617
|
+
|
|
2618
|
+
// components/Loader/index.tsx
|
|
2619
|
+
var import_jsx_runtime2 = require("react/jsx-runtime");
|
|
2620
|
+
var getClassName2 = get_class_name_factory_default("Loader", styles_module_default4);
|
|
2621
|
+
var Loader = (_a) => {
|
|
2622
|
+
var _b = _a, {
|
|
2623
|
+
color,
|
|
2624
|
+
size = 16
|
|
2625
|
+
} = _b, props = __objRest(_b, [
|
|
2626
|
+
"color",
|
|
2627
|
+
"size"
|
|
2628
|
+
]);
|
|
2629
|
+
return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
2630
|
+
"span",
|
|
2631
|
+
__spreadValues({
|
|
2632
|
+
className: getClassName2(),
|
|
2633
|
+
style: {
|
|
2634
|
+
width: size,
|
|
2635
|
+
height: size,
|
|
2636
|
+
color
|
|
2637
|
+
},
|
|
2638
|
+
"aria-label": "loading"
|
|
2639
|
+
}, props)
|
|
2640
|
+
);
|
|
2641
|
+
};
|
|
2642
|
+
|
|
2643
|
+
// components/IconButton/IconButton.tsx
|
|
2644
|
+
var import_jsx_runtime3 = require("react/jsx-runtime");
|
|
2645
|
+
var getClassName3 = get_class_name_factory_default("IconButton", IconButton_module_default);
|
|
2646
|
+
var IconButton = ({
|
|
2647
|
+
children,
|
|
2648
|
+
href,
|
|
2649
|
+
onClick,
|
|
2650
|
+
variant = "primary",
|
|
2651
|
+
type,
|
|
2652
|
+
disabled,
|
|
2653
|
+
tabIndex,
|
|
2654
|
+
newTab,
|
|
2655
|
+
fullWidth,
|
|
2656
|
+
title
|
|
2657
|
+
}) => {
|
|
2658
|
+
const [loading, setLoading] = (0, import_react10.useState)(false);
|
|
2659
|
+
const ElementType = href ? "a" : "button";
|
|
2660
|
+
const el = /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(
|
|
2661
|
+
ElementType,
|
|
2662
|
+
{
|
|
2663
|
+
className: getClassName3({
|
|
2664
|
+
primary: variant === "primary",
|
|
2665
|
+
secondary: variant === "secondary",
|
|
2666
|
+
disabled,
|
|
2667
|
+
fullWidth
|
|
2668
|
+
}),
|
|
2669
|
+
onClick: (e) => {
|
|
2670
|
+
if (!onClick) return;
|
|
2671
|
+
setLoading(true);
|
|
2672
|
+
Promise.resolve(onClick(e)).then(() => {
|
|
2673
|
+
setLoading(false);
|
|
2674
|
+
});
|
|
2675
|
+
},
|
|
2676
|
+
type,
|
|
2677
|
+
disabled: disabled || loading,
|
|
2678
|
+
tabIndex,
|
|
2679
|
+
target: newTab ? "_blank" : void 0,
|
|
2680
|
+
rel: newTab ? "noreferrer" : void 0,
|
|
2681
|
+
href,
|
|
2682
|
+
title,
|
|
2683
|
+
children: [
|
|
2684
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("span", { className: getClassName3("title"), children: title }),
|
|
2685
|
+
children,
|
|
2686
|
+
loading && /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(import_jsx_runtime3.Fragment, { children: [
|
|
2687
|
+
"\xA0\xA0",
|
|
2688
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)(Loader, { size: 14 })
|
|
2689
|
+
] })
|
|
2690
|
+
]
|
|
2691
|
+
}
|
|
2692
|
+
);
|
|
2693
|
+
return el;
|
|
2694
|
+
};
|
|
2695
|
+
|
|
2696
|
+
// components/AutoField/fields/ArrayField/index.tsx
|
|
2697
|
+
var import_react15 = require("react");
|
|
2698
|
+
|
|
2699
|
+
// components/DragIcon/index.tsx
|
|
2700
|
+
init_react_import();
|
|
2701
|
+
|
|
2702
|
+
// css-module:/home/runner/work/puck/puck/packages/core/components/DragIcon/styles.module.css#css-module
|
|
2703
|
+
init_react_import();
|
|
2704
|
+
var styles_module_default5 = { "DragIcon": "_DragIcon_17p8x_1", "DragIcon--disabled": "_DragIcon--disabled_17p8x_8" };
|
|
2705
|
+
|
|
2706
|
+
// components/DragIcon/index.tsx
|
|
2707
|
+
var import_jsx_runtime4 = require("react/jsx-runtime");
|
|
2708
|
+
var getClassName4 = get_class_name_factory_default("DragIcon", styles_module_default5);
|
|
2709
|
+
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" }) }) });
|
|
2710
|
+
|
|
2711
|
+
// components/Sortable/index.tsx
|
|
2712
|
+
init_react_import();
|
|
2713
|
+
var import_react13 = require("@dnd-kit/react");
|
|
2714
|
+
|
|
2715
|
+
// lib/dnd/use-sensors.ts
|
|
2716
|
+
init_react_import();
|
|
2717
|
+
var import_react11 = require("react");
|
|
2718
|
+
var import_react12 = require("@dnd-kit/react");
|
|
2719
|
+
var import_utilities = require("@dnd-kit/dom/utilities");
|
|
2720
|
+
var touchDefault = { delay: { value: 200, tolerance: 10 } };
|
|
2721
|
+
var otherDefault = {
|
|
2722
|
+
delay: { value: 200, tolerance: 10 },
|
|
2723
|
+
distance: { value: 5 }
|
|
2724
|
+
};
|
|
2725
|
+
var useSensors = ({
|
|
2726
|
+
other = otherDefault,
|
|
2727
|
+
mouse,
|
|
2728
|
+
touch = touchDefault
|
|
2729
|
+
} = {
|
|
2730
|
+
touch: touchDefault,
|
|
2731
|
+
other: otherDefault
|
|
2732
|
+
}) => {
|
|
2733
|
+
const [sensors] = (0, import_react11.useState)(() => [
|
|
2734
|
+
import_react12.PointerSensor.configure({
|
|
2735
|
+
activationConstraints(event, source) {
|
|
2736
|
+
var _a;
|
|
2737
|
+
const { pointerType, target } = event;
|
|
2738
|
+
if (pointerType === "mouse" && (0, import_utilities.isElement)(target) && (source.handle === target || ((_a = source.handle) == null ? void 0 : _a.contains(target)))) {
|
|
2739
|
+
return mouse;
|
|
2740
|
+
}
|
|
2741
|
+
if (pointerType === "touch") {
|
|
2742
|
+
return touch;
|
|
2743
|
+
}
|
|
2744
|
+
return other;
|
|
2745
|
+
}
|
|
2746
|
+
})
|
|
2747
|
+
]);
|
|
2748
|
+
return sensors;
|
|
2749
|
+
};
|
|
2750
|
+
|
|
2751
|
+
// lib/dnd/collision/dynamic/index.ts
|
|
2752
|
+
init_react_import();
|
|
2753
|
+
var import_abstract8 = require("@dnd-kit/abstract");
|
|
2754
|
+
|
|
2755
|
+
// lib/dnd/collision/directional/index.ts
|
|
2756
|
+
init_react_import();
|
|
2757
|
+
var import_abstract = require("@dnd-kit/abstract");
|
|
2758
|
+
|
|
2759
|
+
// lib/dnd/collision/collision-debug.ts
|
|
2760
|
+
init_react_import();
|
|
2761
|
+
var DEBUG = false;
|
|
2762
|
+
var debugElements = {};
|
|
2763
|
+
var timeout;
|
|
2764
|
+
var collisionDebug = (a, b, id, color, label) => {
|
|
2765
|
+
if (!DEBUG) return;
|
|
2766
|
+
const debugId = `${id}-debug`;
|
|
2767
|
+
clearTimeout(timeout);
|
|
2768
|
+
timeout = setTimeout(() => {
|
|
2769
|
+
Object.entries(debugElements).forEach(([id2, { svg }]) => {
|
|
2770
|
+
svg.remove();
|
|
2771
|
+
delete debugElements[id2];
|
|
2772
|
+
});
|
|
2773
|
+
}, 1e3);
|
|
2774
|
+
requestAnimationFrame(() => {
|
|
2775
|
+
var _a, _b;
|
|
2776
|
+
const existingEl = debugElements[debugId];
|
|
2777
|
+
let line = (_a = debugElements[debugId]) == null ? void 0 : _a.line;
|
|
2778
|
+
let text = (_b = debugElements[debugId]) == null ? void 0 : _b.text;
|
|
2779
|
+
if (!existingEl) {
|
|
2780
|
+
const svgNs = "http://www.w3.org/2000/svg";
|
|
2781
|
+
const svg = document.createElementNS(svgNs, "svg");
|
|
2782
|
+
line = document.createElementNS(svgNs, "line");
|
|
2783
|
+
text = document.createElementNS(svgNs, "text");
|
|
2784
|
+
svg.setAttribute("id", debugId);
|
|
2785
|
+
svg.setAttribute(
|
|
2786
|
+
"style",
|
|
2787
|
+
"position: fixed; height: 100%; width: 100%; pointer-events: none; top: 0px; left: 0px;"
|
|
2788
|
+
);
|
|
2789
|
+
svg.appendChild(line);
|
|
2790
|
+
svg.appendChild(text);
|
|
2791
|
+
text.setAttribute("fill", `black`);
|
|
2792
|
+
document.body.appendChild(svg);
|
|
2793
|
+
debugElements[debugId] = { svg, line, text };
|
|
2794
|
+
}
|
|
2795
|
+
line.setAttribute("x1", a.x.toString());
|
|
2796
|
+
line.setAttribute("x2", b.x.toString());
|
|
2797
|
+
line.setAttribute("y1", a.y.toString());
|
|
2798
|
+
line.setAttribute("y2", b.y.toString());
|
|
2799
|
+
line.setAttribute("style", `stroke:${color};stroke-width:2`);
|
|
2800
|
+
text.setAttribute("x", (a.x - (a.x - b.x) / 2).toString());
|
|
2801
|
+
text.setAttribute("y", (a.y - (a.y - b.y) / 2).toString());
|
|
2802
|
+
if (label) {
|
|
2803
|
+
text.innerHTML = label;
|
|
2804
|
+
}
|
|
2805
|
+
});
|
|
2806
|
+
};
|
|
2807
|
+
|
|
2808
|
+
// lib/dnd/collision/directional/index.ts
|
|
2809
|
+
var distanceChange = "increasing";
|
|
2810
|
+
var directionalCollision = (input, previous) => {
|
|
2811
|
+
var _a;
|
|
2812
|
+
const { dragOperation, droppable } = input;
|
|
2813
|
+
const { shape: dropShape } = droppable;
|
|
2814
|
+
const { position } = dragOperation;
|
|
2815
|
+
const dragShape = (_a = dragOperation.shape) == null ? void 0 : _a.current;
|
|
2816
|
+
if (!dragShape || !dropShape) return null;
|
|
2817
|
+
const dropCenter = dropShape.center;
|
|
2818
|
+
const distanceToPrevious = Math.sqrt(
|
|
2819
|
+
Math.pow(dropCenter.x - previous.x, 2) + Math.pow(dropCenter.y - previous.y, 2)
|
|
2820
|
+
);
|
|
2821
|
+
const distanceToCurrent = Math.sqrt(
|
|
2822
|
+
Math.pow(dropCenter.x - position.current.x, 2) + Math.pow(dropCenter.y - position.current.y, 2)
|
|
2823
|
+
);
|
|
2824
|
+
distanceChange = distanceToCurrent === distanceToPrevious ? distanceChange : distanceToCurrent < distanceToPrevious ? "decreasing" : "increasing";
|
|
2825
|
+
collisionDebug(
|
|
2826
|
+
dragShape.center,
|
|
2827
|
+
dropCenter,
|
|
2828
|
+
droppable.id.toString(),
|
|
2620
2829
|
"rebeccapurple"
|
|
2621
2830
|
);
|
|
2622
2831
|
if (distanceChange === "decreasing") {
|
|
@@ -2868,7 +3077,7 @@ var SortableProvider = ({
|
|
|
2868
3077
|
mouse: { distance: { value: 5 } }
|
|
2869
3078
|
});
|
|
2870
3079
|
return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
2871
|
-
|
|
3080
|
+
import_react13.DragDropProvider,
|
|
2872
3081
|
{
|
|
2873
3082
|
sensors,
|
|
2874
3083
|
onDragStart: (event) => {
|
|
@@ -2932,11 +3141,11 @@ var Sortable = ({
|
|
|
2932
3141
|
|
|
2933
3142
|
// components/AutoField/context.tsx
|
|
2934
3143
|
init_react_import();
|
|
2935
|
-
var
|
|
3144
|
+
var import_react14 = require("react");
|
|
2936
3145
|
var import_jsx_runtime6 = require("react/jsx-runtime");
|
|
2937
|
-
var NestedFieldContext = (0,
|
|
3146
|
+
var NestedFieldContext = (0, import_react14.createContext)({});
|
|
2938
3147
|
var useNestedFieldContext = () => {
|
|
2939
|
-
const context = (0,
|
|
3148
|
+
const context = (0, import_react14.useContext)(NestedFieldContext);
|
|
2940
3149
|
return __spreadProps(__spreadValues({}, context), {
|
|
2941
3150
|
readOnlyFields: context.readOnlyFields || {}
|
|
2942
3151
|
});
|
|
@@ -2950,7 +3159,7 @@ var NestedFieldProvider = ({
|
|
|
2950
3159
|
}) => {
|
|
2951
3160
|
const subPath = `${name}.${subName}`;
|
|
2952
3161
|
const wildcardSubPath = `${wildcardName}.${subName}`;
|
|
2953
|
-
const subReadOnlyFields = (0,
|
|
3162
|
+
const subReadOnlyFields = (0, import_react14.useMemo)(
|
|
2954
3163
|
() => Object.keys(readOnlyFields).reduce((acc, readOnlyKey) => {
|
|
2955
3164
|
const isLocal = readOnlyKey.indexOf(subPath) > -1 || readOnlyKey.indexOf(wildcardSubPath) > -1;
|
|
2956
3165
|
if (isLocal) {
|
|
@@ -3003,14 +3212,14 @@ var ArrayField = ({
|
|
|
3003
3212
|
}),
|
|
3004
3213
|
openId: ""
|
|
3005
3214
|
};
|
|
3006
|
-
const [localState, setLocalState] = (0,
|
|
3007
|
-
(0,
|
|
3215
|
+
const [localState, setLocalState] = (0, import_react15.useState)({ arrayState, value });
|
|
3216
|
+
(0, import_react15.useEffect)(() => {
|
|
3008
3217
|
var _a;
|
|
3009
3218
|
const _arrayState = (_a = appStore.getState().state.ui.arrayState[id]) != null ? _a : arrayState;
|
|
3010
3219
|
setLocalState({ arrayState: _arrayState, value });
|
|
3011
3220
|
}, [value]);
|
|
3012
3221
|
const appStore = useAppStoreApi();
|
|
3013
|
-
const mapArrayStateToUi = (0,
|
|
3222
|
+
const mapArrayStateToUi = (0, import_react15.useCallback)(
|
|
3014
3223
|
(partialArrayState) => {
|
|
3015
3224
|
const state = appStore.getState().state;
|
|
3016
3225
|
return {
|
|
@@ -3021,13 +3230,13 @@ var ArrayField = ({
|
|
|
3021
3230
|
},
|
|
3022
3231
|
[arrayState, appStore]
|
|
3023
3232
|
);
|
|
3024
|
-
const getHighestIndex = (0,
|
|
3233
|
+
const getHighestIndex = (0, import_react15.useCallback)(() => {
|
|
3025
3234
|
return arrayState.items.reduce(
|
|
3026
3235
|
(acc, item) => item._originalIndex > acc ? item._originalIndex : acc,
|
|
3027
3236
|
-1
|
|
3028
3237
|
);
|
|
3029
3238
|
}, [arrayState]);
|
|
3030
|
-
const regenerateArrayState = (0,
|
|
3239
|
+
const regenerateArrayState = (0, import_react15.useCallback)(
|
|
3031
3240
|
(value2) => {
|
|
3032
3241
|
let highestIndex = getHighestIndex();
|
|
3033
3242
|
const newItems = Array.from(value2 || []).map((item, idx) => {
|
|
@@ -3046,19 +3255,19 @@ var ArrayField = ({
|
|
|
3046
3255
|
},
|
|
3047
3256
|
[arrayState]
|
|
3048
3257
|
);
|
|
3049
|
-
(0,
|
|
3258
|
+
(0, import_react15.useEffect)(() => {
|
|
3050
3259
|
if (arrayState.items.length > 0) {
|
|
3051
3260
|
setUi(mapArrayStateToUi(arrayState));
|
|
3052
3261
|
}
|
|
3053
3262
|
}, []);
|
|
3054
|
-
const [draggedItem, setDraggedItem] = (0,
|
|
3263
|
+
const [draggedItem, setDraggedItem] = (0, import_react15.useState)("");
|
|
3055
3264
|
const isDraggingAny = !!draggedItem;
|
|
3056
3265
|
const canEdit = useAppStore(
|
|
3057
3266
|
(s) => s.permissions.getPermissions({ item: s.selectedItem }).edit
|
|
3058
3267
|
);
|
|
3059
3268
|
const forceReadOnly = !canEdit;
|
|
3060
|
-
const valueRef = (0,
|
|
3061
|
-
const uniqifyItem = (0,
|
|
3269
|
+
const valueRef = (0, import_react15.useRef)(value);
|
|
3270
|
+
const uniqifyItem = (0, import_react15.useCallback)(
|
|
3062
3271
|
(val) => {
|
|
3063
3272
|
if (field.type !== "array" || !field.arrayFields) return;
|
|
3064
3273
|
const config = appStore.getState().config;
|
|
@@ -3363,11 +3572,11 @@ var DefaultField = ({
|
|
|
3363
3572
|
|
|
3364
3573
|
// components/AutoField/fields/ExternalField/index.tsx
|
|
3365
3574
|
init_react_import();
|
|
3366
|
-
var
|
|
3575
|
+
var import_react19 = require("react");
|
|
3367
3576
|
|
|
3368
3577
|
// components/ExternalInput/index.tsx
|
|
3369
3578
|
init_react_import();
|
|
3370
|
-
var
|
|
3579
|
+
var import_react18 = require("react");
|
|
3371
3580
|
|
|
3372
3581
|
// css-module:/home/runner/work/puck/puck/packages/core/components/ExternalInput/styles.module.css#css-module
|
|
3373
3582
|
init_react_import();
|
|
@@ -3375,7 +3584,7 @@ var styles_module_default6 = { "ExternalInput-actions": "_ExternalInput-actions_
|
|
|
3375
3584
|
|
|
3376
3585
|
// components/Modal/index.tsx
|
|
3377
3586
|
init_react_import();
|
|
3378
|
-
var
|
|
3587
|
+
var import_react16 = require("react");
|
|
3379
3588
|
|
|
3380
3589
|
// css-module:/home/runner/work/puck/puck/packages/core/components/Modal/styles.module.css#css-module
|
|
3381
3590
|
init_react_import();
|
|
@@ -3390,8 +3599,8 @@ var Modal = ({
|
|
|
3390
3599
|
onClose,
|
|
3391
3600
|
isOpen
|
|
3392
3601
|
}) => {
|
|
3393
|
-
const [rootEl, setRootEl] = (0,
|
|
3394
|
-
(0,
|
|
3602
|
+
const [rootEl, setRootEl] = (0, import_react16.useState)(null);
|
|
3603
|
+
(0, import_react16.useEffect)(() => {
|
|
3395
3604
|
setRootEl(document.getElementById("puck-portal-root"));
|
|
3396
3605
|
}, []);
|
|
3397
3606
|
if (!rootEl) {
|
|
@@ -3438,7 +3647,7 @@ init_react_import();
|
|
|
3438
3647
|
|
|
3439
3648
|
// components/Button/Button.tsx
|
|
3440
3649
|
init_react_import();
|
|
3441
|
-
var
|
|
3650
|
+
var import_react17 = require("react");
|
|
3442
3651
|
|
|
3443
3652
|
// css-module:/home/runner/work/puck/puck/packages/core/components/Button/Button.module.css#css-module
|
|
3444
3653
|
init_react_import();
|
|
@@ -3488,8 +3697,8 @@ var Button = (_a) => {
|
|
|
3488
3697
|
"size",
|
|
3489
3698
|
"loading"
|
|
3490
3699
|
]);
|
|
3491
|
-
const [loading, setLoading] = (0,
|
|
3492
|
-
(0,
|
|
3700
|
+
const [loading, setLoading] = (0, import_react17.useState)(loadingProp);
|
|
3701
|
+
(0, import_react17.useEffect)(() => setLoading(loadingProp), [loadingProp]);
|
|
3493
3702
|
const ElementType = href ? "a" : type ? "button" : "span";
|
|
3494
3703
|
const dataAttrs = filterDataAttrs(props);
|
|
3495
3704
|
const el = /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)(
|
|
@@ -3544,28 +3753,28 @@ var ExternalInput = ({
|
|
|
3544
3753
|
mapRow = (val) => val,
|
|
3545
3754
|
filterFields
|
|
3546
3755
|
} = field || {};
|
|
3547
|
-
const [data, setData] = (0,
|
|
3548
|
-
const [isOpen, setOpen] = (0,
|
|
3549
|
-
const [isLoading, setIsLoading] = (0,
|
|
3756
|
+
const [data, setData] = (0, import_react18.useState)([]);
|
|
3757
|
+
const [isOpen, setOpen] = (0, import_react18.useState)(false);
|
|
3758
|
+
const [isLoading, setIsLoading] = (0, import_react18.useState)(true);
|
|
3550
3759
|
const hasFilterFields = !!filterFields;
|
|
3551
|
-
const [filters, setFilters] = (0,
|
|
3552
|
-
const [filtersToggled, setFiltersToggled] = (0,
|
|
3553
|
-
const mappedData = (0,
|
|
3760
|
+
const [filters, setFilters] = (0, import_react18.useState)(field.initialFilters || {});
|
|
3761
|
+
const [filtersToggled, setFiltersToggled] = (0, import_react18.useState)(hasFilterFields);
|
|
3762
|
+
const mappedData = (0, import_react18.useMemo)(() => {
|
|
3554
3763
|
return data.map(mapRow);
|
|
3555
3764
|
}, [data]);
|
|
3556
|
-
const keys = (0,
|
|
3765
|
+
const keys = (0, import_react18.useMemo)(() => {
|
|
3557
3766
|
const validKeys = /* @__PURE__ */ new Set();
|
|
3558
3767
|
for (const item of mappedData) {
|
|
3559
3768
|
for (const key of Object.keys(item)) {
|
|
3560
|
-
if (typeof item[key] === "string" || typeof item[key] === "number" || (0,
|
|
3769
|
+
if (typeof item[key] === "string" || typeof item[key] === "number" || (0, import_react18.isValidElement)(item[key])) {
|
|
3561
3770
|
validKeys.add(key);
|
|
3562
3771
|
}
|
|
3563
3772
|
}
|
|
3564
3773
|
}
|
|
3565
3774
|
return Array.from(validKeys);
|
|
3566
3775
|
}, [mappedData]);
|
|
3567
|
-
const [searchQuery, setSearchQuery] = (0,
|
|
3568
|
-
const search = (0,
|
|
3776
|
+
const [searchQuery, setSearchQuery] = (0, import_react18.useState)(field.initialQuery || "");
|
|
3777
|
+
const search = (0, import_react18.useCallback)(
|
|
3569
3778
|
(query, filters2) => __async(void 0, null, function* () {
|
|
3570
3779
|
setIsLoading(true);
|
|
3571
3780
|
const cacheKey = `${id}-${query}-${JSON.stringify(filters2)}`;
|
|
@@ -3578,7 +3787,7 @@ var ExternalInput = ({
|
|
|
3578
3787
|
}),
|
|
3579
3788
|
[id, field]
|
|
3580
3789
|
);
|
|
3581
|
-
const Footer = (0,
|
|
3790
|
+
const Footer = (0, import_react18.useCallback)(
|
|
3582
3791
|
(props) => field.renderFooter ? field.renderFooter(props) : /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)("span", { className: getClassNameModal("footer"), children: [
|
|
3583
3792
|
props.items.length,
|
|
3584
3793
|
" result",
|
|
@@ -3586,7 +3795,7 @@ var ExternalInput = ({
|
|
|
3586
3795
|
] }),
|
|
3587
3796
|
[field.renderFooter]
|
|
3588
3797
|
);
|
|
3589
|
-
(0,
|
|
3798
|
+
(0, import_react18.useEffect)(() => {
|
|
3590
3799
|
search(searchQuery, filters);
|
|
3591
3800
|
}, []);
|
|
3592
3801
|
return /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)(
|
|
@@ -3759,7 +3968,7 @@ var ExternalField = ({
|
|
|
3759
3968
|
var _a, _b, _c;
|
|
3760
3969
|
const validField = field;
|
|
3761
3970
|
const deprecatedField = field;
|
|
3762
|
-
(0,
|
|
3971
|
+
(0, import_react19.useEffect)(() => {
|
|
3763
3972
|
if (deprecatedField.adaptor) {
|
|
3764
3973
|
console.error(
|
|
3765
3974
|
"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."
|
|
@@ -4021,12 +4230,12 @@ var ObjectField = ({
|
|
|
4021
4230
|
|
|
4022
4231
|
// lib/use-safe-id.ts
|
|
4023
4232
|
init_react_import();
|
|
4024
|
-
var
|
|
4233
|
+
var import_react20 = __toESM(require("react"));
|
|
4025
4234
|
var useSafeId = () => {
|
|
4026
|
-
if (typeof
|
|
4027
|
-
return
|
|
4235
|
+
if (typeof import_react20.default.useId !== "undefined") {
|
|
4236
|
+
return import_react20.default.useId();
|
|
4028
4237
|
}
|
|
4029
|
-
const [id] = (0,
|
|
4238
|
+
const [id] = (0, import_react20.useState)(generateId());
|
|
4030
4239
|
return id;
|
|
4031
4240
|
};
|
|
4032
4241
|
|
|
@@ -4060,7 +4269,7 @@ var FieldLabelInternal = ({
|
|
|
4060
4269
|
readOnly
|
|
4061
4270
|
}) => {
|
|
4062
4271
|
const overrides = useAppStore((s) => s.overrides);
|
|
4063
|
-
const Wrapper = (0,
|
|
4272
|
+
const Wrapper = (0, import_react21.useMemo)(
|
|
4064
4273
|
() => overrides.fieldLabel || FieldLabel,
|
|
4065
4274
|
[overrides]
|
|
4066
4275
|
);
|
|
@@ -4087,7 +4296,7 @@ function AutoFieldInternal(props) {
|
|
|
4087
4296
|
var _a2;
|
|
4088
4297
|
return (_a2 = s.selectedItem) == null ? void 0 : _a2.readOnly;
|
|
4089
4298
|
});
|
|
4090
|
-
const nestedFieldContext = (0,
|
|
4299
|
+
const nestedFieldContext = (0, import_react21.useContext)(NestedFieldContext);
|
|
4091
4300
|
const { id, Label: Label2 = FieldLabelInternal } = props;
|
|
4092
4301
|
const field = props.field;
|
|
4093
4302
|
const label = field.label;
|
|
@@ -4121,7 +4330,7 @@ function AutoFieldInternal(props) {
|
|
|
4121
4330
|
Label: Label2,
|
|
4122
4331
|
id: resolvedId
|
|
4123
4332
|
});
|
|
4124
|
-
const onFocus = (0,
|
|
4333
|
+
const onFocus = (0, import_react21.useCallback)(
|
|
4125
4334
|
(e) => {
|
|
4126
4335
|
if (mergedProps.name && (e.target.nodeName === "INPUT" || e.target.nodeName === "TEXTAREA")) {
|
|
4127
4336
|
e.stopPropagation();
|
|
@@ -4135,7 +4344,7 @@ function AutoFieldInternal(props) {
|
|
|
4135
4344
|
},
|
|
4136
4345
|
[mergedProps.name]
|
|
4137
4346
|
);
|
|
4138
|
-
const onBlur = (0,
|
|
4347
|
+
const onBlur = (0, import_react21.useCallback)((e) => {
|
|
4139
4348
|
if ("name" in e.target) {
|
|
4140
4349
|
dispatch({
|
|
4141
4350
|
type: "setUi",
|
|
@@ -4188,20 +4397,20 @@ function AutoFieldInternal(props) {
|
|
|
4188
4397
|
function AutoFieldPrivate(props) {
|
|
4189
4398
|
const isFocused = useAppStore((s) => s.state.ui.field.focus === props.name);
|
|
4190
4399
|
const { value, onChange } = props;
|
|
4191
|
-
const [localValue, setLocalValue] = (0,
|
|
4192
|
-
const onChangeLocal = (0,
|
|
4400
|
+
const [localValue, setLocalValue] = (0, import_react21.useState)(value);
|
|
4401
|
+
const onChangeLocal = (0, import_react21.useCallback)(
|
|
4193
4402
|
(val, ui) => {
|
|
4194
4403
|
setLocalValue(val);
|
|
4195
4404
|
onChange(val, ui);
|
|
4196
4405
|
},
|
|
4197
4406
|
[onChange]
|
|
4198
4407
|
);
|
|
4199
|
-
(0,
|
|
4408
|
+
(0, import_react21.useEffect)(() => {
|
|
4200
4409
|
if (!isFocused) {
|
|
4201
4410
|
setLocalValue(value);
|
|
4202
4411
|
}
|
|
4203
4412
|
}, [value]);
|
|
4204
|
-
(0,
|
|
4413
|
+
(0, import_react21.useEffect)(() => {
|
|
4205
4414
|
if (!isFocused) {
|
|
4206
4415
|
if (value !== localValue) {
|
|
4207
4416
|
setLocalValue(value);
|
|
@@ -4215,7 +4424,7 @@ function AutoFieldPrivate(props) {
|
|
|
4215
4424
|
return /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(AutoFieldInternal, __spreadValues(__spreadValues({}, props), localProps));
|
|
4216
4425
|
}
|
|
4217
4426
|
function AutoField(props) {
|
|
4218
|
-
const DefaultLabel = (0,
|
|
4427
|
+
const DefaultLabel = (0, import_react21.useMemo)(() => {
|
|
4219
4428
|
const DefaultLabel2 = (labelProps) => /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
|
|
4220
4429
|
"div",
|
|
4221
4430
|
__spreadProps(__spreadValues({}, labelProps), {
|
|
@@ -4238,21 +4447,21 @@ init_react_import();
|
|
|
4238
4447
|
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" };
|
|
4239
4448
|
|
|
4240
4449
|
// components/Drawer/index.tsx
|
|
4241
|
-
var
|
|
4450
|
+
var import_react38 = require("react");
|
|
4242
4451
|
|
|
4243
4452
|
// components/DragDropContext/index.tsx
|
|
4244
4453
|
init_react_import();
|
|
4245
|
-
var
|
|
4246
|
-
var
|
|
4454
|
+
var import_react36 = require("@dnd-kit/react");
|
|
4455
|
+
var import_react37 = require("react");
|
|
4247
4456
|
var import_dom = require("@dnd-kit/dom");
|
|
4248
4457
|
|
|
4249
4458
|
// components/DropZone/index.tsx
|
|
4250
4459
|
init_react_import();
|
|
4251
|
-
var
|
|
4460
|
+
var import_react34 = require("react");
|
|
4252
4461
|
|
|
4253
4462
|
// components/DraggableComponent/index.tsx
|
|
4254
4463
|
init_react_import();
|
|
4255
|
-
var
|
|
4464
|
+
var import_react25 = require("react");
|
|
4256
4465
|
|
|
4257
4466
|
// css-module:/home/runner/work/puck/puck/packages/core/components/DraggableComponent/styles.module.css#css-module
|
|
4258
4467
|
init_react_import();
|
|
@@ -4282,11 +4491,11 @@ function getDeepScrollPosition(element) {
|
|
|
4282
4491
|
|
|
4283
4492
|
// components/DropZone/context.tsx
|
|
4284
4493
|
init_react_import();
|
|
4285
|
-
var
|
|
4494
|
+
var import_react22 = require("react");
|
|
4286
4495
|
var import_zustand3 = require("zustand");
|
|
4287
4496
|
var import_jsx_runtime19 = require("react/jsx-runtime");
|
|
4288
|
-
var dropZoneContext = (0,
|
|
4289
|
-
var ZoneStoreContext = (0,
|
|
4497
|
+
var dropZoneContext = (0, import_react22.createContext)(null);
|
|
4498
|
+
var ZoneStoreContext = (0, import_react22.createContext)(
|
|
4290
4499
|
(0, import_zustand3.createStore)(() => ({
|
|
4291
4500
|
zoneDepthIndex: {},
|
|
4292
4501
|
nextZoneDepthIndex: {},
|
|
@@ -4309,7 +4518,7 @@ var DropZoneProvider = ({
|
|
|
4309
4518
|
value
|
|
4310
4519
|
}) => {
|
|
4311
4520
|
const dispatch = useAppStore((s) => s.dispatch);
|
|
4312
|
-
const registerZone = (0,
|
|
4521
|
+
const registerZone = (0, import_react22.useCallback)(
|
|
4313
4522
|
(zoneCompound) => {
|
|
4314
4523
|
dispatch({
|
|
4315
4524
|
type: "registerZone",
|
|
@@ -4318,7 +4527,7 @@ var DropZoneProvider = ({
|
|
|
4318
4527
|
},
|
|
4319
4528
|
[dispatch]
|
|
4320
4529
|
);
|
|
4321
|
-
const memoValue = (0,
|
|
4530
|
+
const memoValue = (0, import_react22.useMemo)(
|
|
4322
4531
|
() => __spreadValues({
|
|
4323
4532
|
registerZone
|
|
4324
4533
|
}, value),
|
|
@@ -4328,7 +4537,7 @@ var DropZoneProvider = ({
|
|
|
4328
4537
|
};
|
|
4329
4538
|
|
|
4330
4539
|
// components/DraggableComponent/index.tsx
|
|
4331
|
-
var
|
|
4540
|
+
var import_shallow3 = require("zustand/react/shallow");
|
|
4332
4541
|
var import_sortable2 = require("@dnd-kit/react/sortable");
|
|
4333
4542
|
|
|
4334
4543
|
// lib/accumulate-transform.ts
|
|
@@ -4348,23 +4557,23 @@ function accumulateTransform(el) {
|
|
|
4348
4557
|
|
|
4349
4558
|
// lib/use-context-store.ts
|
|
4350
4559
|
init_react_import();
|
|
4351
|
-
var
|
|
4560
|
+
var import_react23 = require("react");
|
|
4352
4561
|
var import_zustand4 = require("zustand");
|
|
4353
|
-
var
|
|
4562
|
+
var import_shallow2 = require("zustand/react/shallow");
|
|
4354
4563
|
function useContextStore(context, selector) {
|
|
4355
|
-
const store = (0,
|
|
4564
|
+
const store = (0, import_react23.useContext)(context);
|
|
4356
4565
|
if (!store) {
|
|
4357
4566
|
throw new Error("useContextStore must be used inside context");
|
|
4358
4567
|
}
|
|
4359
|
-
return (0, import_zustand4.useStore)(store, (0,
|
|
4568
|
+
return (0, import_zustand4.useStore)(store, (0, import_shallow2.useShallow)(selector));
|
|
4360
4569
|
}
|
|
4361
4570
|
|
|
4362
4571
|
// lib/dnd/use-on-drag-finished.ts
|
|
4363
4572
|
init_react_import();
|
|
4364
|
-
var
|
|
4573
|
+
var import_react24 = require("react");
|
|
4365
4574
|
var useOnDragFinished = (cb, deps = []) => {
|
|
4366
4575
|
const appStore = useAppStoreApi();
|
|
4367
|
-
return (0,
|
|
4576
|
+
return (0, import_react24.useCallback)(() => {
|
|
4368
4577
|
let dispose = () => {
|
|
4369
4578
|
};
|
|
4370
4579
|
const processDragging = (isDragging2) => {
|
|
@@ -4434,9 +4643,9 @@ var DraggableComponent = ({
|
|
|
4434
4643
|
const overrides = useAppStore((s) => s.overrides);
|
|
4435
4644
|
const dispatch = useAppStore((s) => s.dispatch);
|
|
4436
4645
|
const iframe = useAppStore((s) => s.iframe);
|
|
4437
|
-
const ctx = (0,
|
|
4438
|
-
const [localZones, setLocalZones] = (0,
|
|
4439
|
-
const registerLocalZone = (0,
|
|
4646
|
+
const ctx = (0, import_react25.useContext)(dropZoneContext);
|
|
4647
|
+
const [localZones, setLocalZones] = (0, import_react25.useState)({});
|
|
4648
|
+
const registerLocalZone = (0, import_react25.useCallback)(
|
|
4440
4649
|
(zoneCompound2, active) => {
|
|
4441
4650
|
var _a;
|
|
4442
4651
|
(_a = ctx == null ? void 0 : ctx.registerLocalZone) == null ? void 0 : _a.call(ctx, zoneCompound2, active);
|
|
@@ -4446,7 +4655,7 @@ var DraggableComponent = ({
|
|
|
4446
4655
|
},
|
|
4447
4656
|
[setLocalZones]
|
|
4448
4657
|
);
|
|
4449
|
-
const unregisterLocalZone = (0,
|
|
4658
|
+
const unregisterLocalZone = (0, import_react25.useCallback)(
|
|
4450
4659
|
(zoneCompound2) => {
|
|
4451
4660
|
var _a;
|
|
4452
4661
|
(_a = ctx == null ? void 0 : ctx.unregisterLocalZone) == null ? void 0 : _a.call(ctx, zoneCompound2);
|
|
@@ -4459,19 +4668,19 @@ var DraggableComponent = ({
|
|
|
4459
4668
|
[setLocalZones]
|
|
4460
4669
|
);
|
|
4461
4670
|
const containsActiveZone = Object.values(localZones).filter(Boolean).length > 0;
|
|
4462
|
-
const path = useAppStore((0,
|
|
4671
|
+
const path = useAppStore((0, import_shallow3.useShallow)((s) => {
|
|
4463
4672
|
var _a;
|
|
4464
4673
|
return (_a = s.state.indexes.nodes[id]) == null ? void 0 : _a.path;
|
|
4465
4674
|
}));
|
|
4466
4675
|
const permissions = useAppStore(
|
|
4467
|
-
(0,
|
|
4676
|
+
(0, import_shallow3.useShallow)((s) => {
|
|
4468
4677
|
const item = getItem({ index, zone: zoneCompound }, s.state);
|
|
4469
4678
|
return s.permissions.getPermissions({ item });
|
|
4470
4679
|
})
|
|
4471
4680
|
);
|
|
4472
|
-
const zoneStore = (0,
|
|
4473
|
-
const [dragAxis, setDragAxis] = (0,
|
|
4474
|
-
const dynamicCollisionDetector = (0,
|
|
4681
|
+
const zoneStore = (0, import_react25.useContext)(ZoneStoreContext);
|
|
4682
|
+
const [dragAxis, setDragAxis] = (0, import_react25.useState)(userDragAxis || autoDragAxis);
|
|
4683
|
+
const dynamicCollisionDetector = (0, import_react25.useMemo)(
|
|
4475
4684
|
() => createDynamicCollisionDetector(dragAxis),
|
|
4476
4685
|
[dragAxis]
|
|
4477
4686
|
);
|
|
@@ -4503,7 +4712,7 @@ var DraggableComponent = ({
|
|
|
4503
4712
|
},
|
|
4504
4713
|
feedback: "clone"
|
|
4505
4714
|
});
|
|
4506
|
-
(0,
|
|
4715
|
+
(0, import_react25.useEffect)(() => {
|
|
4507
4716
|
const isEnabled = zoneStore.getState().enabledIndex[zoneCompound];
|
|
4508
4717
|
sortable.droppable.disabled = !isEnabled;
|
|
4509
4718
|
sortable.draggable.disabled = !permissions.drag;
|
|
@@ -4520,8 +4729,8 @@ var DraggableComponent = ({
|
|
|
4520
4729
|
}
|
|
4521
4730
|
return cleanup;
|
|
4522
4731
|
}, [permissions.drag, zoneCompound]);
|
|
4523
|
-
const ref = (0,
|
|
4524
|
-
const refSetter = (0,
|
|
4732
|
+
const ref = (0, import_react25.useRef)(null);
|
|
4733
|
+
const refSetter = (0, import_react25.useCallback)(
|
|
4525
4734
|
(el) => {
|
|
4526
4735
|
sortableRef(el);
|
|
4527
4736
|
if (el) {
|
|
@@ -4530,14 +4739,14 @@ var DraggableComponent = ({
|
|
|
4530
4739
|
},
|
|
4531
4740
|
[sortableRef]
|
|
4532
4741
|
);
|
|
4533
|
-
const [portalEl, setPortalEl] = (0,
|
|
4534
|
-
(0,
|
|
4742
|
+
const [portalEl, setPortalEl] = (0, import_react25.useState)();
|
|
4743
|
+
(0, import_react25.useEffect)(() => {
|
|
4535
4744
|
var _a, _b, _c;
|
|
4536
4745
|
setPortalEl(
|
|
4537
4746
|
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
|
|
4538
4747
|
);
|
|
4539
4748
|
}, [iframe.enabled, ref.current]);
|
|
4540
|
-
const getStyle = (0,
|
|
4749
|
+
const getStyle = (0, import_react25.useCallback)(() => {
|
|
4541
4750
|
var _a, _b, _c;
|
|
4542
4751
|
if (!ref.current) return;
|
|
4543
4752
|
const rect = ref.current.getBoundingClientRect();
|
|
@@ -4562,11 +4771,11 @@ var DraggableComponent = ({
|
|
|
4562
4771
|
};
|
|
4563
4772
|
return style2;
|
|
4564
4773
|
}, [ref.current]);
|
|
4565
|
-
const [style, setStyle] = (0,
|
|
4566
|
-
const sync = (0,
|
|
4774
|
+
const [style, setStyle] = (0, import_react25.useState)();
|
|
4775
|
+
const sync = (0, import_react25.useCallback)(() => {
|
|
4567
4776
|
setStyle(getStyle());
|
|
4568
4777
|
}, [ref.current, iframe]);
|
|
4569
|
-
(0,
|
|
4778
|
+
(0, import_react25.useEffect)(() => {
|
|
4570
4779
|
if (ref.current) {
|
|
4571
4780
|
const observer = new ResizeObserver(sync);
|
|
4572
4781
|
observer.observe(ref.current);
|
|
@@ -4576,13 +4785,13 @@ var DraggableComponent = ({
|
|
|
4576
4785
|
}
|
|
4577
4786
|
}, [ref.current]);
|
|
4578
4787
|
const registerNode = useAppStore((s) => s.nodes.registerNode);
|
|
4579
|
-
const hideOverlay = (0,
|
|
4788
|
+
const hideOverlay = (0, import_react25.useCallback)(() => {
|
|
4580
4789
|
setIsVisible(false);
|
|
4581
4790
|
}, []);
|
|
4582
|
-
const showOverlay = (0,
|
|
4791
|
+
const showOverlay = (0, import_react25.useCallback)(() => {
|
|
4583
4792
|
setIsVisible(true);
|
|
4584
4793
|
}, []);
|
|
4585
|
-
(0,
|
|
4794
|
+
(0, import_react25.useEffect)(() => {
|
|
4586
4795
|
var _a;
|
|
4587
4796
|
registerNode(id, {
|
|
4588
4797
|
methods: { sync, showOverlay, hideOverlay },
|
|
@@ -4599,11 +4808,11 @@ var DraggableComponent = ({
|
|
|
4599
4808
|
});
|
|
4600
4809
|
};
|
|
4601
4810
|
}, [id, zoneCompound, index, componentType, sync]);
|
|
4602
|
-
const CustomActionBar = (0,
|
|
4811
|
+
const CustomActionBar = (0, import_react25.useMemo)(
|
|
4603
4812
|
() => overrides.actionBar || DefaultActionBar,
|
|
4604
4813
|
[overrides.actionBar]
|
|
4605
4814
|
);
|
|
4606
|
-
const onClick = (0,
|
|
4815
|
+
const onClick = (0, import_react25.useCallback)(
|
|
4607
4816
|
(e) => {
|
|
4608
4817
|
e.stopPropagation();
|
|
4609
4818
|
dispatch({
|
|
@@ -4616,7 +4825,7 @@ var DraggableComponent = ({
|
|
|
4616
4825
|
[index, zoneCompound, id]
|
|
4617
4826
|
);
|
|
4618
4827
|
const appStore = useAppStoreApi();
|
|
4619
|
-
const onSelectParent = (0,
|
|
4828
|
+
const onSelectParent = (0, import_react25.useCallback)(() => {
|
|
4620
4829
|
const { nodes, zones } = appStore.getState().state.indexes;
|
|
4621
4830
|
const node = nodes[id];
|
|
4622
4831
|
const parentNode = (node == null ? void 0 : node.parentId) ? nodes[node == null ? void 0 : node.parentId] : null;
|
|
@@ -4637,26 +4846,26 @@ var DraggableComponent = ({
|
|
|
4637
4846
|
}
|
|
4638
4847
|
});
|
|
4639
4848
|
}, [ctx, path]);
|
|
4640
|
-
const onDuplicate = (0,
|
|
4849
|
+
const onDuplicate = (0, import_react25.useCallback)(() => {
|
|
4641
4850
|
dispatch({
|
|
4642
4851
|
type: "duplicate",
|
|
4643
4852
|
sourceIndex: index,
|
|
4644
4853
|
sourceZone: zoneCompound
|
|
4645
4854
|
});
|
|
4646
4855
|
}, [index, zoneCompound]);
|
|
4647
|
-
const onDelete = (0,
|
|
4856
|
+
const onDelete = (0, import_react25.useCallback)(() => {
|
|
4648
4857
|
dispatch({
|
|
4649
4858
|
type: "remove",
|
|
4650
4859
|
index,
|
|
4651
4860
|
zone: zoneCompound
|
|
4652
4861
|
});
|
|
4653
4862
|
}, [index, zoneCompound]);
|
|
4654
|
-
const [hover, setHover] = (0,
|
|
4863
|
+
const [hover, setHover] = (0, import_react25.useState)(false);
|
|
4655
4864
|
const indicativeHover = useContextStore(
|
|
4656
4865
|
ZoneStoreContext,
|
|
4657
4866
|
(s) => s.hoveringComponent === id
|
|
4658
4867
|
);
|
|
4659
|
-
(0,
|
|
4868
|
+
(0, import_react25.useEffect)(() => {
|
|
4660
4869
|
if (!ref.current) {
|
|
4661
4870
|
return;
|
|
4662
4871
|
}
|
|
@@ -4701,10 +4910,10 @@ var DraggableComponent = ({
|
|
|
4701
4910
|
thisIsDragging,
|
|
4702
4911
|
inDroppableZone
|
|
4703
4912
|
]);
|
|
4704
|
-
const [isVisible, setIsVisible] = (0,
|
|
4705
|
-
const [dragFinished, setDragFinished] = (0,
|
|
4706
|
-
const [_, startTransition] = (0,
|
|
4707
|
-
(0,
|
|
4913
|
+
const [isVisible, setIsVisible] = (0, import_react25.useState)(false);
|
|
4914
|
+
const [dragFinished, setDragFinished] = (0, import_react25.useState)(true);
|
|
4915
|
+
const [_, startTransition] = (0, import_react25.useTransition)();
|
|
4916
|
+
(0, import_react25.useEffect)(() => {
|
|
4708
4917
|
startTransition(() => {
|
|
4709
4918
|
if (hover || indicativeHover || isSelected) {
|
|
4710
4919
|
sync();
|
|
@@ -4715,7 +4924,7 @@ var DraggableComponent = ({
|
|
|
4715
4924
|
}
|
|
4716
4925
|
});
|
|
4717
4926
|
}, [hover, indicativeHover, isSelected, iframe]);
|
|
4718
|
-
const [thisWasDragging, setThisWasDragging] = (0,
|
|
4927
|
+
const [thisWasDragging, setThisWasDragging] = (0, import_react25.useState)(false);
|
|
4719
4928
|
const onDragFinished = useOnDragFinished((finished) => {
|
|
4720
4929
|
if (finished) {
|
|
4721
4930
|
startTransition(() => {
|
|
@@ -4726,15 +4935,15 @@ var DraggableComponent = ({
|
|
|
4726
4935
|
setDragFinished(false);
|
|
4727
4936
|
}
|
|
4728
4937
|
});
|
|
4729
|
-
(0,
|
|
4938
|
+
(0, import_react25.useEffect)(() => {
|
|
4730
4939
|
if (thisIsDragging) {
|
|
4731
4940
|
setThisWasDragging(true);
|
|
4732
4941
|
}
|
|
4733
4942
|
}, [thisIsDragging]);
|
|
4734
|
-
(0,
|
|
4943
|
+
(0, import_react25.useEffect)(() => {
|
|
4735
4944
|
if (thisWasDragging) return onDragFinished();
|
|
4736
4945
|
}, [thisWasDragging, onDragFinished]);
|
|
4737
|
-
const syncActionsPosition = (0,
|
|
4946
|
+
const syncActionsPosition = (0, import_react25.useCallback)(
|
|
4738
4947
|
(el) => {
|
|
4739
4948
|
if (el) {
|
|
4740
4949
|
const view = el.ownerDocument.defaultView;
|
|
@@ -4759,7 +4968,7 @@ var DraggableComponent = ({
|
|
|
4759
4968
|
},
|
|
4760
4969
|
[zoom]
|
|
4761
4970
|
);
|
|
4762
|
-
(0,
|
|
4971
|
+
(0, import_react25.useEffect)(() => {
|
|
4763
4972
|
if (userDragAxis) {
|
|
4764
4973
|
setDragAxis(userDragAxis);
|
|
4765
4974
|
return;
|
|
@@ -4773,11 +4982,11 @@ var DraggableComponent = ({
|
|
|
4773
4982
|
}
|
|
4774
4983
|
setDragAxis(autoDragAxis);
|
|
4775
4984
|
}, [ref, userDragAxis, autoDragAxis]);
|
|
4776
|
-
const parentAction = (0,
|
|
4985
|
+
const parentAction = (0, import_react25.useMemo)(
|
|
4777
4986
|
() => (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 }) }),
|
|
4778
4987
|
[ctx == null ? void 0 : ctx.areaId]
|
|
4779
4988
|
);
|
|
4780
|
-
const nextContextValue = (0,
|
|
4989
|
+
const nextContextValue = (0, import_react25.useMemo)(
|
|
4781
4990
|
() => __spreadProps(__spreadValues({}, ctx), {
|
|
4782
4991
|
areaId: id,
|
|
4783
4992
|
zoneCompound,
|
|
@@ -4860,11 +5069,11 @@ init_react_import();
|
|
|
4860
5069
|
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" };
|
|
4861
5070
|
|
|
4862
5071
|
// components/DropZone/index.tsx
|
|
4863
|
-
var
|
|
5072
|
+
var import_react35 = require("@dnd-kit/react");
|
|
4864
5073
|
|
|
4865
5074
|
// components/DropZone/lib/use-min-empty-height.ts
|
|
4866
5075
|
init_react_import();
|
|
4867
|
-
var
|
|
5076
|
+
var import_react26 = require("react");
|
|
4868
5077
|
var getNumItems = (appStore, zoneCompound) => appStore.getState().state.indexes.zones[zoneCompound].contentIds.length;
|
|
4869
5078
|
var useMinEmptyHeight = ({
|
|
4870
5079
|
zoneCompound,
|
|
@@ -4872,8 +5081,8 @@ var useMinEmptyHeight = ({
|
|
|
4872
5081
|
ref
|
|
4873
5082
|
}) => {
|
|
4874
5083
|
const appStore = useAppStoreApi();
|
|
4875
|
-
const [prevHeight, setPrevHeight] = (0,
|
|
4876
|
-
const [isAnimating, setIsAnimating] = (0,
|
|
5084
|
+
const [prevHeight, setPrevHeight] = (0, import_react26.useState)(0);
|
|
5085
|
+
const [isAnimating, setIsAnimating] = (0, import_react26.useState)(false);
|
|
4877
5086
|
const { draggedItem, isZone } = useContextStore(ZoneStoreContext, (s) => {
|
|
4878
5087
|
var _a, _b;
|
|
4879
5088
|
return {
|
|
@@ -4881,7 +5090,7 @@ var useMinEmptyHeight = ({
|
|
|
4881
5090
|
isZone: ((_b = s.draggedItem) == null ? void 0 : _b.data.zone) === zoneCompound
|
|
4882
5091
|
};
|
|
4883
5092
|
});
|
|
4884
|
-
const numItems = (0,
|
|
5093
|
+
const numItems = (0, import_react26.useRef)(0);
|
|
4885
5094
|
const onDragFinished = useOnDragFinished(
|
|
4886
5095
|
(finished) => {
|
|
4887
5096
|
var _a;
|
|
@@ -4916,7 +5125,7 @@ var useMinEmptyHeight = ({
|
|
|
4916
5125
|
},
|
|
4917
5126
|
[appStore, prevHeight, zoneCompound]
|
|
4918
5127
|
);
|
|
4919
|
-
(0,
|
|
5128
|
+
(0, import_react26.useEffect)(() => {
|
|
4920
5129
|
if (draggedItem && ref.current) {
|
|
4921
5130
|
if (isZone) {
|
|
4922
5131
|
const rect = ref.current.getBoundingClientRect();
|
|
@@ -4947,15 +5156,15 @@ function assignRefs(refs, node) {
|
|
|
4947
5156
|
|
|
4948
5157
|
// components/DropZone/lib/use-content-with-preview.ts
|
|
4949
5158
|
init_react_import();
|
|
4950
|
-
var
|
|
5159
|
+
var import_react29 = require("react");
|
|
4951
5160
|
|
|
4952
5161
|
// lib/dnd/use-rendered-callback.ts
|
|
4953
5162
|
init_react_import();
|
|
4954
|
-
var
|
|
4955
|
-
var
|
|
5163
|
+
var import_react27 = require("@dnd-kit/react");
|
|
5164
|
+
var import_react28 = require("react");
|
|
4956
5165
|
function useRenderedCallback(callback, deps) {
|
|
4957
|
-
const manager = (0,
|
|
4958
|
-
return (0,
|
|
5166
|
+
const manager = (0, import_react27.useDragDropManager)();
|
|
5167
|
+
return (0, import_react28.useCallback)(
|
|
4959
5168
|
(...args) => __async(this, null, function* () {
|
|
4960
5169
|
yield manager == null ? void 0 : manager.renderer.rendering;
|
|
4961
5170
|
return callback(...args);
|
|
@@ -4966,14 +5175,14 @@ function useRenderedCallback(callback, deps) {
|
|
|
4966
5175
|
|
|
4967
5176
|
// components/DropZone/lib/use-content-with-preview.ts
|
|
4968
5177
|
var useContentIdsWithPreview = (contentIds, zoneCompound) => {
|
|
4969
|
-
const zoneStore = (0,
|
|
5178
|
+
const zoneStore = (0, import_react29.useContext)(ZoneStoreContext);
|
|
4970
5179
|
const preview = useContextStore(
|
|
4971
5180
|
ZoneStoreContext,
|
|
4972
5181
|
(s) => s.previewIndex[zoneCompound]
|
|
4973
5182
|
);
|
|
4974
5183
|
const isDragging = useAppStore((s) => s.state.ui.isDragging);
|
|
4975
|
-
const [contentIdsWithPreview, setContentIdsWithPreview] = (0,
|
|
4976
|
-
const [localPreview, setLocalPreview] = (0,
|
|
5184
|
+
const [contentIdsWithPreview, setContentIdsWithPreview] = (0, import_react29.useState)(contentIds);
|
|
5185
|
+
const [localPreview, setLocalPreview] = (0, import_react29.useState)(
|
|
4977
5186
|
preview
|
|
4978
5187
|
);
|
|
4979
5188
|
const updateContent = useRenderedCallback(
|
|
@@ -5008,7 +5217,7 @@ var useContentIdsWithPreview = (contentIds, zoneCompound) => {
|
|
|
5008
5217
|
},
|
|
5009
5218
|
[]
|
|
5010
5219
|
);
|
|
5011
|
-
(0,
|
|
5220
|
+
(0, import_react29.useEffect)(() => {
|
|
5012
5221
|
var _a;
|
|
5013
5222
|
const s = zoneStore.getState();
|
|
5014
5223
|
const draggedItemId = (_a = s.draggedItem) == null ? void 0 : _a.id;
|
|
@@ -5026,16 +5235,16 @@ var useContentIdsWithPreview = (contentIds, zoneCompound) => {
|
|
|
5026
5235
|
|
|
5027
5236
|
// components/DropZone/lib/use-drag-axis.ts
|
|
5028
5237
|
init_react_import();
|
|
5029
|
-
var
|
|
5238
|
+
var import_react30 = require("react");
|
|
5030
5239
|
var GRID_DRAG_AXIS = "dynamic";
|
|
5031
5240
|
var FLEX_ROW_DRAG_AXIS = "x";
|
|
5032
5241
|
var DEFAULT_DRAG_AXIS = "y";
|
|
5033
5242
|
var useDragAxis = (ref, collisionAxis) => {
|
|
5034
5243
|
const status = useAppStore((s) => s.status);
|
|
5035
|
-
const [dragAxis, setDragAxis] = (0,
|
|
5244
|
+
const [dragAxis, setDragAxis] = (0, import_react30.useState)(
|
|
5036
5245
|
collisionAxis || DEFAULT_DRAG_AXIS
|
|
5037
5246
|
);
|
|
5038
|
-
const calculateDragAxis = (0,
|
|
5247
|
+
const calculateDragAxis = (0, import_react30.useCallback)(() => {
|
|
5039
5248
|
if (ref.current) {
|
|
5040
5249
|
const computedStyle = window.getComputedStyle(ref.current);
|
|
5041
5250
|
if (computedStyle.display === "grid") {
|
|
@@ -5047,7 +5256,7 @@ var useDragAxis = (ref, collisionAxis) => {
|
|
|
5047
5256
|
}
|
|
5048
5257
|
}
|
|
5049
5258
|
}, [ref.current]);
|
|
5050
|
-
(0,
|
|
5259
|
+
(0, import_react30.useEffect)(() => {
|
|
5051
5260
|
const onViewportChange = () => {
|
|
5052
5261
|
calculateDragAxis();
|
|
5053
5262
|
};
|
|
@@ -5056,21 +5265,21 @@ var useDragAxis = (ref, collisionAxis) => {
|
|
|
5056
5265
|
window.removeEventListener("viewportchange", onViewportChange);
|
|
5057
5266
|
};
|
|
5058
5267
|
}, []);
|
|
5059
|
-
(0,
|
|
5268
|
+
(0, import_react30.useEffect)(calculateDragAxis, [status, collisionAxis]);
|
|
5060
5269
|
return [dragAxis, calculateDragAxis];
|
|
5061
5270
|
};
|
|
5062
5271
|
|
|
5063
5272
|
// components/DropZone/index.tsx
|
|
5064
|
-
var
|
|
5273
|
+
var import_shallow5 = require("zustand/react/shallow");
|
|
5065
5274
|
|
|
5066
5275
|
// components/Render/index.tsx
|
|
5067
5276
|
init_react_import();
|
|
5068
5277
|
|
|
5069
5278
|
// lib/use-slots.tsx
|
|
5070
5279
|
init_react_import();
|
|
5071
|
-
var
|
|
5280
|
+
var import_react31 = require("react");
|
|
5072
5281
|
function useSlots(config, item, renderSlotEdit, renderSlotRender = renderSlotEdit, readOnly, forceReadOnly) {
|
|
5073
|
-
const slotProps = (0,
|
|
5282
|
+
const slotProps = (0, import_react31.useMemo)(() => {
|
|
5074
5283
|
const mapped = mapSlots(
|
|
5075
5284
|
item,
|
|
5076
5285
|
(content, _parentId, propName, field, propPath) => {
|
|
@@ -5090,7 +5299,7 @@ function useSlots(config, item, renderSlotEdit, renderSlotRender = renderSlotEdi
|
|
|
5090
5299
|
).props;
|
|
5091
5300
|
return mapped;
|
|
5092
5301
|
}, [config, item, readOnly, forceReadOnly]);
|
|
5093
|
-
const mergedProps = (0,
|
|
5302
|
+
const mergedProps = (0, import_react31.useMemo)(
|
|
5094
5303
|
() => __spreadValues(__spreadValues({}, item.props), slotProps),
|
|
5095
5304
|
[item.props, slotProps]
|
|
5096
5305
|
);
|
|
@@ -5098,15 +5307,15 @@ function useSlots(config, item, renderSlotEdit, renderSlotRender = renderSlotEdi
|
|
|
5098
5307
|
}
|
|
5099
5308
|
|
|
5100
5309
|
// components/Render/index.tsx
|
|
5101
|
-
var
|
|
5310
|
+
var import_react33 = __toESM(require("react"));
|
|
5102
5311
|
|
|
5103
5312
|
// components/SlotRender/index.tsx
|
|
5104
5313
|
init_react_import();
|
|
5105
|
-
var
|
|
5314
|
+
var import_shallow4 = require("zustand/react/shallow");
|
|
5106
5315
|
|
|
5107
5316
|
// components/SlotRender/server.tsx
|
|
5108
5317
|
init_react_import();
|
|
5109
|
-
var
|
|
5318
|
+
var import_react32 = require("react");
|
|
5110
5319
|
|
|
5111
5320
|
// components/ServerRender/index.tsx
|
|
5112
5321
|
init_react_import();
|
|
@@ -5175,7 +5384,7 @@ var Item = ({
|
|
|
5175
5384
|
})
|
|
5176
5385
|
);
|
|
5177
5386
|
};
|
|
5178
|
-
var SlotRender = (0,
|
|
5387
|
+
var SlotRender = (0, import_react32.forwardRef)(
|
|
5179
5388
|
function SlotRenderInternal({ className, style, content, config, metadata }, ref) {
|
|
5180
5389
|
return /* @__PURE__ */ (0, import_jsx_runtime22.jsx)("div", { className, style, ref, children: content.map((item) => {
|
|
5181
5390
|
if (!config.components[item.type]) {
|
|
@@ -5203,7 +5412,7 @@ var ContextSlotRender = ({
|
|
|
5203
5412
|
const config = useAppStore((s) => s.config);
|
|
5204
5413
|
const metadata = useAppStore((s) => s.metadata);
|
|
5205
5414
|
const slotContent = useAppStore(
|
|
5206
|
-
(0,
|
|
5415
|
+
(0, import_shallow4.useShallow)((s) => {
|
|
5207
5416
|
var _a, _b;
|
|
5208
5417
|
const indexes = s.state.indexes;
|
|
5209
5418
|
const contentIds = (_b = (_a = indexes.zones[`${componentId}:${zone}`]) == null ? void 0 : _a.contentIds) != null ? _b : [];
|
|
@@ -5223,7 +5432,7 @@ var ContextSlotRender = ({
|
|
|
5223
5432
|
|
|
5224
5433
|
// components/Render/index.tsx
|
|
5225
5434
|
var import_jsx_runtime24 = require("react/jsx-runtime");
|
|
5226
|
-
var renderContext =
|
|
5435
|
+
var renderContext = import_react33.default.createContext({
|
|
5227
5436
|
config: { components: {} },
|
|
5228
5437
|
data: { root: {}, content: [] },
|
|
5229
5438
|
metadata: {}
|
|
@@ -5256,7 +5465,7 @@ function Render({
|
|
|
5256
5465
|
{ type: "root", props: pageProps },
|
|
5257
5466
|
(props) => /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(SlotRender, __spreadProps(__spreadValues({}, props), { config, metadata }))
|
|
5258
5467
|
);
|
|
5259
|
-
const nextContextValue = (0,
|
|
5468
|
+
const nextContextValue = (0, import_react33.useMemo)(
|
|
5260
5469
|
() => ({
|
|
5261
5470
|
mode: "render",
|
|
5262
5471
|
depth: 0
|
|
@@ -5285,11 +5494,11 @@ var DropZoneChild = ({
|
|
|
5285
5494
|
}) => {
|
|
5286
5495
|
var _a, _b;
|
|
5287
5496
|
const metadata = useAppStore((s) => s.metadata);
|
|
5288
|
-
const ctx = (0,
|
|
5497
|
+
const ctx = (0, import_react34.useContext)(dropZoneContext);
|
|
5289
5498
|
const { depth = 1 } = ctx != null ? ctx : {};
|
|
5290
|
-
const zoneStore = (0,
|
|
5499
|
+
const zoneStore = (0, import_react34.useContext)(ZoneStoreContext);
|
|
5291
5500
|
const nodeProps = useAppStore(
|
|
5292
|
-
(0,
|
|
5501
|
+
(0, import_shallow5.useShallow)((s) => {
|
|
5293
5502
|
var _a2;
|
|
5294
5503
|
return (_a2 = s.state.indexes.nodes[componentId]) == null ? void 0 : _a2.flatData.props;
|
|
5295
5504
|
})
|
|
@@ -5301,13 +5510,13 @@ var DropZoneChild = ({
|
|
|
5301
5510
|
}
|
|
5302
5511
|
);
|
|
5303
5512
|
const nodeReadOnly = useAppStore(
|
|
5304
|
-
(0,
|
|
5513
|
+
(0, import_shallow5.useShallow)((s) => {
|
|
5305
5514
|
var _a2;
|
|
5306
5515
|
return (_a2 = s.state.indexes.nodes[componentId]) == null ? void 0 : _a2.data.readOnly;
|
|
5307
5516
|
})
|
|
5308
5517
|
);
|
|
5309
5518
|
const appStore = useAppStoreApi();
|
|
5310
|
-
const item = (0,
|
|
5519
|
+
const item = (0, import_react34.useMemo)(() => {
|
|
5311
5520
|
if (nodeProps) {
|
|
5312
5521
|
const expanded = expandNode({
|
|
5313
5522
|
type: nodeType,
|
|
@@ -5329,7 +5538,7 @@ var DropZoneChild = ({
|
|
|
5329
5538
|
const componentConfig = useAppStore(
|
|
5330
5539
|
(s) => (item == null ? void 0 : item.type) ? s.config.components[item.type] : null
|
|
5331
5540
|
);
|
|
5332
|
-
const puckProps = (0,
|
|
5541
|
+
const puckProps = (0, import_react34.useMemo)(
|
|
5333
5542
|
() => ({
|
|
5334
5543
|
renderDropZone: DropZoneEditPure,
|
|
5335
5544
|
isEditing: true,
|
|
@@ -5352,7 +5561,7 @@ var DropZoneChild = ({
|
|
|
5352
5561
|
}
|
|
5353
5562
|
);
|
|
5354
5563
|
let label = (_b = (_a = componentConfig == null ? void 0 : componentConfig.label) != null ? _a : item == null ? void 0 : item.type.toString()) != null ? _b : "Component";
|
|
5355
|
-
const renderPreview = (0,
|
|
5564
|
+
const renderPreview = (0, import_react34.useMemo)(
|
|
5356
5565
|
() => function Preview3() {
|
|
5357
5566
|
if (item && "element" in item && item.element) {
|
|
5358
5567
|
return (
|
|
@@ -5364,7 +5573,7 @@ var DropZoneChild = ({
|
|
|
5364
5573
|
},
|
|
5365
5574
|
[componentId, label, overrides]
|
|
5366
5575
|
);
|
|
5367
|
-
const defaultsProps = (0,
|
|
5576
|
+
const defaultsProps = (0, import_react34.useMemo)(
|
|
5368
5577
|
() => __spreadProps(__spreadValues(__spreadValues({}, componentConfig == null ? void 0 : componentConfig.defaultProps), item == null ? void 0 : item.props), {
|
|
5369
5578
|
puck: puckProps,
|
|
5370
5579
|
editMode: true
|
|
@@ -5372,7 +5581,7 @@ var DropZoneChild = ({
|
|
|
5372
5581
|
}),
|
|
5373
5582
|
[componentConfig == null ? void 0 : componentConfig.defaultProps, item == null ? void 0 : item.props, puckProps]
|
|
5374
5583
|
);
|
|
5375
|
-
const defaultedNode = (0,
|
|
5584
|
+
const defaultedNode = (0, import_react34.useMemo)(
|
|
5376
5585
|
() => {
|
|
5377
5586
|
var _a2;
|
|
5378
5587
|
return { type: (_a2 = item == null ? void 0 : item.type) != null ? _a2 : nodeType, props: defaultsProps };
|
|
@@ -5423,8 +5632,8 @@ var DropZoneChild = ({
|
|
|
5423
5632
|
}
|
|
5424
5633
|
);
|
|
5425
5634
|
};
|
|
5426
|
-
var DropZoneChildMemo = (0,
|
|
5427
|
-
var DropZoneEdit = (0,
|
|
5635
|
+
var DropZoneChildMemo = (0, import_react34.memo)(DropZoneChild);
|
|
5636
|
+
var DropZoneEdit = (0, import_react34.forwardRef)(
|
|
5428
5637
|
function DropZoneEditInternal({
|
|
5429
5638
|
zone,
|
|
5430
5639
|
allow,
|
|
@@ -5434,7 +5643,7 @@ var DropZoneEdit = (0, import_react33.forwardRef)(
|
|
|
5434
5643
|
minEmptyHeight: userMinEmptyHeight = 128,
|
|
5435
5644
|
collisionAxis
|
|
5436
5645
|
}, userRef) {
|
|
5437
|
-
const ctx = (0,
|
|
5646
|
+
const ctx = (0, import_react34.useContext)(dropZoneContext);
|
|
5438
5647
|
const appStoreApi = useAppStoreApi();
|
|
5439
5648
|
const {
|
|
5440
5649
|
// These all need setting via context
|
|
@@ -5444,7 +5653,7 @@ var DropZoneEdit = (0, import_react33.forwardRef)(
|
|
|
5444
5653
|
unregisterLocalZone
|
|
5445
5654
|
} = ctx != null ? ctx : {};
|
|
5446
5655
|
const path = useAppStore(
|
|
5447
|
-
(0,
|
|
5656
|
+
(0, import_shallow5.useShallow)((s) => {
|
|
5448
5657
|
var _a;
|
|
5449
5658
|
return areaId ? (_a = s.state.indexes.nodes[areaId]) == null ? void 0 : _a.path : null;
|
|
5450
5659
|
})
|
|
@@ -5461,25 +5670,25 @@ var DropZoneEdit = (0, import_react33.forwardRef)(
|
|
|
5461
5670
|
(s) => s.nextAreaDepthIndex[areaId || ""]
|
|
5462
5671
|
);
|
|
5463
5672
|
const zoneContentIds = useAppStore(
|
|
5464
|
-
(0,
|
|
5673
|
+
(0, import_shallow5.useShallow)((s) => {
|
|
5465
5674
|
var _a;
|
|
5466
5675
|
return (_a = s.state.indexes.zones[zoneCompound]) == null ? void 0 : _a.contentIds;
|
|
5467
5676
|
})
|
|
5468
5677
|
);
|
|
5469
5678
|
const zoneType = useAppStore(
|
|
5470
|
-
(0,
|
|
5679
|
+
(0, import_shallow5.useShallow)((s) => {
|
|
5471
5680
|
var _a;
|
|
5472
5681
|
return (_a = s.state.indexes.zones[zoneCompound]) == null ? void 0 : _a.type;
|
|
5473
5682
|
})
|
|
5474
5683
|
);
|
|
5475
|
-
(0,
|
|
5684
|
+
(0, import_react34.useEffect)(() => {
|
|
5476
5685
|
if (!zoneType || zoneType === "dropzone") {
|
|
5477
5686
|
if (ctx == null ? void 0 : ctx.registerZone) {
|
|
5478
5687
|
ctx == null ? void 0 : ctx.registerZone(zoneCompound);
|
|
5479
5688
|
}
|
|
5480
5689
|
}
|
|
5481
5690
|
}, [zoneType, appStoreApi]);
|
|
5482
|
-
(0,
|
|
5691
|
+
(0, import_react34.useEffect)(() => {
|
|
5483
5692
|
if (zoneType === "dropzone") {
|
|
5484
5693
|
if (zoneCompound !== rootDroppableId) {
|
|
5485
5694
|
console.warn(
|
|
@@ -5488,11 +5697,11 @@ var DropZoneEdit = (0, import_react33.forwardRef)(
|
|
|
5488
5697
|
}
|
|
5489
5698
|
}
|
|
5490
5699
|
}, [zoneType]);
|
|
5491
|
-
const contentIds = (0,
|
|
5700
|
+
const contentIds = (0, import_react34.useMemo)(() => {
|
|
5492
5701
|
return zoneContentIds || [];
|
|
5493
5702
|
}, [zoneContentIds]);
|
|
5494
|
-
const ref = (0,
|
|
5495
|
-
const acceptsTarget = (0,
|
|
5703
|
+
const ref = (0, import_react34.useRef)(null);
|
|
5704
|
+
const acceptsTarget = (0, import_react34.useCallback)(
|
|
5496
5705
|
(componentType) => {
|
|
5497
5706
|
if (!componentType) {
|
|
5498
5707
|
return true;
|
|
@@ -5530,7 +5739,7 @@ var DropZoneEdit = (0, import_react33.forwardRef)(
|
|
|
5530
5739
|
}
|
|
5531
5740
|
return _isEnabled;
|
|
5532
5741
|
});
|
|
5533
|
-
(0,
|
|
5742
|
+
(0, import_react34.useEffect)(() => {
|
|
5534
5743
|
if (registerLocalZone) {
|
|
5535
5744
|
registerLocalZone(zoneCompound, targetAccepted || isEnabled);
|
|
5536
5745
|
}
|
|
@@ -5545,8 +5754,8 @@ var DropZoneEdit = (0, import_react33.forwardRef)(
|
|
|
5545
5754
|
zoneCompound
|
|
5546
5755
|
);
|
|
5547
5756
|
const isDropEnabled = isEnabled && (preview ? contentIdsWithPreview.length === 1 : contentIdsWithPreview.length === 0);
|
|
5548
|
-
const zoneStore = (0,
|
|
5549
|
-
(0,
|
|
5757
|
+
const zoneStore = (0, import_react34.useContext)(ZoneStoreContext);
|
|
5758
|
+
(0, import_react34.useEffect)(() => {
|
|
5550
5759
|
const { enabledIndex } = zoneStore.getState();
|
|
5551
5760
|
zoneStore.setState({
|
|
5552
5761
|
enabledIndex: __spreadProps(__spreadValues({}, enabledIndex), { [zoneCompound]: isEnabled })
|
|
@@ -5565,7 +5774,7 @@ var DropZoneEdit = (0, import_react33.forwardRef)(
|
|
|
5565
5774
|
path: path || []
|
|
5566
5775
|
}
|
|
5567
5776
|
};
|
|
5568
|
-
const { ref: dropRef } = (0,
|
|
5777
|
+
const { ref: dropRef } = (0, import_react35.useDroppable)(droppableConfig);
|
|
5569
5778
|
const isAreaSelected = useAppStore(
|
|
5570
5779
|
(s) => (s == null ? void 0 : s.selectedItem) && areaId === (s == null ? void 0 : s.selectedItem.props.id)
|
|
5571
5780
|
);
|
|
@@ -5620,7 +5829,7 @@ var DropZoneRenderItem = ({
|
|
|
5620
5829
|
}) => {
|
|
5621
5830
|
const Component = config.components[item.type];
|
|
5622
5831
|
const props = useSlots(config, item, (slotProps) => /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(SlotRenderPure, __spreadProps(__spreadValues({}, slotProps), { config, metadata })));
|
|
5623
|
-
const nextContextValue = (0,
|
|
5832
|
+
const nextContextValue = (0, import_react34.useMemo)(
|
|
5624
5833
|
() => ({
|
|
5625
5834
|
areaId: props.id,
|
|
5626
5835
|
depth: 1
|
|
@@ -5638,14 +5847,14 @@ var DropZoneRenderItem = ({
|
|
|
5638
5847
|
) }, props.id);
|
|
5639
5848
|
};
|
|
5640
5849
|
var DropZoneRenderPure = (props) => /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(DropZoneRender2, __spreadValues({}, props));
|
|
5641
|
-
var DropZoneRender2 = (0,
|
|
5850
|
+
var DropZoneRender2 = (0, import_react34.forwardRef)(
|
|
5642
5851
|
function DropZoneRenderInternal({ className, style, zone }, ref) {
|
|
5643
|
-
const ctx = (0,
|
|
5852
|
+
const ctx = (0, import_react34.useContext)(dropZoneContext);
|
|
5644
5853
|
const { areaId = "root" } = ctx || {};
|
|
5645
|
-
const { config, data, metadata } = (0,
|
|
5854
|
+
const { config, data, metadata } = (0, import_react34.useContext)(renderContext);
|
|
5646
5855
|
let zoneCompound = `${areaId}:${zone}`;
|
|
5647
5856
|
let content = (data == null ? void 0 : data.content) || [];
|
|
5648
|
-
(0,
|
|
5857
|
+
(0, import_react34.useEffect)(() => {
|
|
5649
5858
|
if (!content) {
|
|
5650
5859
|
if (ctx == null ? void 0 : ctx.registerZone) {
|
|
5651
5860
|
ctx == null ? void 0 : ctx.registerZone(zoneCompound);
|
|
@@ -5676,9 +5885,9 @@ var DropZoneRender2 = (0, import_react33.forwardRef)(
|
|
|
5676
5885
|
}
|
|
5677
5886
|
);
|
|
5678
5887
|
var DropZonePure = (props) => /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(DropZone, __spreadValues({}, props));
|
|
5679
|
-
var DropZone = (0,
|
|
5888
|
+
var DropZone = (0, import_react34.forwardRef)(
|
|
5680
5889
|
function DropZone2(props, ref) {
|
|
5681
|
-
const ctx = (0,
|
|
5890
|
+
const ctx = (0, import_react34.useContext)(dropZoneContext);
|
|
5682
5891
|
if ((ctx == null ? void 0 : ctx.mode) === "edit") {
|
|
5683
5892
|
return /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(import_jsx_runtime25.Fragment, { children: /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(DropZoneEdit, __spreadProps(__spreadValues({}, props), { ref })) });
|
|
5684
5893
|
}
|
|
@@ -6020,12 +6229,12 @@ function getDeepDir(el) {
|
|
|
6020
6229
|
var import_state = require("@dnd-kit/state");
|
|
6021
6230
|
var import_jsx_runtime26 = require("react/jsx-runtime");
|
|
6022
6231
|
var DEBUG3 = false;
|
|
6023
|
-
var dragListenerContext = (0,
|
|
6232
|
+
var dragListenerContext = (0, import_react37.createContext)({
|
|
6024
6233
|
dragListeners: {}
|
|
6025
6234
|
});
|
|
6026
6235
|
function useDragListener(type, fn, deps = []) {
|
|
6027
|
-
const { setDragListeners } = (0,
|
|
6028
|
-
(0,
|
|
6236
|
+
const { setDragListeners } = (0, import_react37.useContext)(dragListenerContext);
|
|
6237
|
+
(0, import_react37.useEffect)(() => {
|
|
6029
6238
|
if (setDragListeners) {
|
|
6030
6239
|
setDragListeners((old) => __spreadProps(__spreadValues({}, old), {
|
|
6031
6240
|
[type]: [...old[type] || [], fn]
|
|
@@ -6035,8 +6244,8 @@ function useDragListener(type, fn, deps = []) {
|
|
|
6035
6244
|
}
|
|
6036
6245
|
var AREA_CHANGE_DEBOUNCE_MS = 100;
|
|
6037
6246
|
var useTempDisableFallback = (timeout3) => {
|
|
6038
|
-
const lastFallbackDisable = (0,
|
|
6039
|
-
return (0,
|
|
6247
|
+
const lastFallbackDisable = (0, import_react37.useRef)(null);
|
|
6248
|
+
return (0, import_react37.useCallback)((manager) => {
|
|
6040
6249
|
collisionStore.setState({ fallbackEnabled: false });
|
|
6041
6250
|
const fallbackId = generateId();
|
|
6042
6251
|
lastFallbackDisable.current = fallbackId;
|
|
@@ -6055,9 +6264,9 @@ var DragDropContextClient = ({
|
|
|
6055
6264
|
const dispatch = useAppStore((s) => s.dispatch);
|
|
6056
6265
|
const appStore = useAppStoreApi();
|
|
6057
6266
|
const id = useSafeId();
|
|
6058
|
-
const debouncedParamsRef = (0,
|
|
6267
|
+
const debouncedParamsRef = (0, import_react37.useRef)(null);
|
|
6059
6268
|
const tempDisableFallback = useTempDisableFallback(100);
|
|
6060
|
-
const [zoneStore] = (0,
|
|
6269
|
+
const [zoneStore] = (0, import_react37.useState)(
|
|
6061
6270
|
() => (0, import_zustand5.createStore)(() => ({
|
|
6062
6271
|
zoneDepthIndex: {},
|
|
6063
6272
|
nextZoneDepthIndex: {},
|
|
@@ -6069,7 +6278,7 @@ var DragDropContextClient = ({
|
|
|
6069
6278
|
hoveringComponent: null
|
|
6070
6279
|
}))
|
|
6071
6280
|
);
|
|
6072
|
-
const getChanged2 = (0,
|
|
6281
|
+
const getChanged2 = (0, import_react37.useCallback)(
|
|
6073
6282
|
(params, id2) => {
|
|
6074
6283
|
const { zoneDepthIndex = {}, areaDepthIndex = {} } = zoneStore.getState() || {};
|
|
6075
6284
|
const stateHasZone = Object.keys(zoneDepthIndex).length > 0;
|
|
@@ -6090,7 +6299,7 @@ var DragDropContextClient = ({
|
|
|
6090
6299
|
},
|
|
6091
6300
|
[zoneStore]
|
|
6092
6301
|
);
|
|
6093
|
-
const setDeepestAndCollide = (0,
|
|
6302
|
+
const setDeepestAndCollide = (0, import_react37.useCallback)(
|
|
6094
6303
|
(params, manager) => {
|
|
6095
6304
|
const { zoneChanged, areaChanged } = getChanged2(params, id);
|
|
6096
6305
|
if (!zoneChanged && !areaChanged) return;
|
|
@@ -6114,7 +6323,7 @@ var DragDropContextClient = ({
|
|
|
6114
6323
|
setDeepestDb.cancel();
|
|
6115
6324
|
debouncedParamsRef.current = null;
|
|
6116
6325
|
};
|
|
6117
|
-
(0,
|
|
6326
|
+
(0, import_react37.useEffect)(() => {
|
|
6118
6327
|
if (DEBUG3) {
|
|
6119
6328
|
zoneStore.subscribe(
|
|
6120
6329
|
(s) => {
|
|
@@ -6128,7 +6337,7 @@ var DragDropContextClient = ({
|
|
|
6128
6337
|
);
|
|
6129
6338
|
}
|
|
6130
6339
|
}, []);
|
|
6131
|
-
const [plugins] = (0,
|
|
6340
|
+
const [plugins] = (0, import_react37.useState)(() => [
|
|
6132
6341
|
...disableAutoScroll ? import_dom.defaultPreset.plugins.filter((plugin) => plugin !== import_dom.AutoScroller) : import_dom.defaultPreset.plugins,
|
|
6133
6342
|
createNestedDroppablePlugin(
|
|
6134
6343
|
{
|
|
@@ -6176,10 +6385,10 @@ var DragDropContextClient = ({
|
|
|
6176
6385
|
)
|
|
6177
6386
|
]);
|
|
6178
6387
|
const sensors = useSensors();
|
|
6179
|
-
const [dragListeners, setDragListeners] = (0,
|
|
6180
|
-
const dragMode = (0,
|
|
6181
|
-
const initialSelector = (0,
|
|
6182
|
-
const nextContextValue = (0,
|
|
6388
|
+
const [dragListeners, setDragListeners] = (0, import_react37.useState)({});
|
|
6389
|
+
const dragMode = (0, import_react37.useRef)(null);
|
|
6390
|
+
const initialSelector = (0, import_react37.useRef)(void 0);
|
|
6391
|
+
const nextContextValue = (0, import_react37.useMemo)(
|
|
6183
6392
|
() => ({
|
|
6184
6393
|
mode: "edit",
|
|
6185
6394
|
areaId: "root",
|
|
@@ -6195,7 +6404,7 @@ var DragDropContextClient = ({
|
|
|
6195
6404
|
setDragListeners
|
|
6196
6405
|
},
|
|
6197
6406
|
children: /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(
|
|
6198
|
-
|
|
6407
|
+
import_react36.DragDropProvider,
|
|
6199
6408
|
{
|
|
6200
6409
|
plugins,
|
|
6201
6410
|
sensors,
|
|
@@ -6428,7 +6637,7 @@ var DragDropContext = ({
|
|
|
6428
6637
|
};
|
|
6429
6638
|
|
|
6430
6639
|
// components/Drawer/index.tsx
|
|
6431
|
-
var
|
|
6640
|
+
var import_react39 = require("@dnd-kit/react");
|
|
6432
6641
|
var import_jsx_runtime27 = require("react/jsx-runtime");
|
|
6433
6642
|
var getClassName18 = get_class_name_factory_default("Drawer", styles_module_default10);
|
|
6434
6643
|
var getClassNameItem2 = get_class_name_factory_default("DrawerItem", styles_module_default10);
|
|
@@ -6439,7 +6648,7 @@ var DrawerItemInner = ({
|
|
|
6439
6648
|
dragRef,
|
|
6440
6649
|
isDragDisabled
|
|
6441
6650
|
}) => {
|
|
6442
|
-
const CustomInner = (0,
|
|
6651
|
+
const CustomInner = (0, import_react38.useMemo)(
|
|
6443
6652
|
() => children || (({ children: children2 }) => /* @__PURE__ */ (0, import_jsx_runtime27.jsx)("div", { className: getClassNameItem2("default"), children: children2 })),
|
|
6444
6653
|
[children]
|
|
6445
6654
|
);
|
|
@@ -6465,7 +6674,7 @@ var DrawerItemDraggable = ({
|
|
|
6465
6674
|
id,
|
|
6466
6675
|
isDragDisabled
|
|
6467
6676
|
}) => {
|
|
6468
|
-
const { ref } = (0,
|
|
6677
|
+
const { ref } = (0, import_react39.useDraggable)({
|
|
6469
6678
|
id,
|
|
6470
6679
|
data: { componentType: name },
|
|
6471
6680
|
disabled: isDragDisabled,
|
|
@@ -6494,7 +6703,7 @@ var DrawerItem = ({
|
|
|
6494
6703
|
isDragDisabled
|
|
6495
6704
|
}) => {
|
|
6496
6705
|
const resolvedId = id || name;
|
|
6497
|
-
const [dynamicId, setDynamicId] = (0,
|
|
6706
|
+
const [dynamicId, setDynamicId] = (0, import_react38.useState)(generateId(resolvedId));
|
|
6498
6707
|
if (typeof index !== "undefined") {
|
|
6499
6708
|
console.error(
|
|
6500
6709
|
"Warning: The `index` prop on Drawer.Item is deprecated and no longer required."
|
|
@@ -6534,7 +6743,7 @@ var Drawer = ({
|
|
|
6534
6743
|
);
|
|
6535
6744
|
}
|
|
6536
6745
|
const id = useSafeId();
|
|
6537
|
-
const { ref } = (0,
|
|
6746
|
+
const { ref } = (0, import_react39.useDroppable)({
|
|
6538
6747
|
id,
|
|
6539
6748
|
type: "void",
|
|
6540
6749
|
collisionPriority: 0
|
|
@@ -6556,7 +6765,7 @@ Drawer.Item = DrawerItem;
|
|
|
6556
6765
|
|
|
6557
6766
|
// components/Puck/index.tsx
|
|
6558
6767
|
init_react_import();
|
|
6559
|
-
var
|
|
6768
|
+
var import_react58 = require("react");
|
|
6560
6769
|
|
|
6561
6770
|
// components/SidebarSection/index.tsx
|
|
6562
6771
|
init_react_import();
|
|
@@ -6567,7 +6776,7 @@ var styles_module_default13 = { "SidebarSection": "_SidebarSection_8boj8_1", "Si
|
|
|
6567
6776
|
|
|
6568
6777
|
// lib/use-breadcrumbs.ts
|
|
6569
6778
|
init_react_import();
|
|
6570
|
-
var
|
|
6779
|
+
var import_react40 = require("react");
|
|
6571
6780
|
var useBreadcrumbs = (renderCount) => {
|
|
6572
6781
|
const selectedId = useAppStore((s) => {
|
|
6573
6782
|
var _a;
|
|
@@ -6579,7 +6788,7 @@ var useBreadcrumbs = (renderCount) => {
|
|
|
6579
6788
|
return (_a = s.state.indexes.nodes[selectedId]) == null ? void 0 : _a.path;
|
|
6580
6789
|
});
|
|
6581
6790
|
const appStore = useAppStoreApi();
|
|
6582
|
-
return (0,
|
|
6791
|
+
return (0, import_react40.useMemo)(() => {
|
|
6583
6792
|
const breadcrumbs = (path == null ? void 0 : path.map((zoneCompound) => {
|
|
6584
6793
|
var _a, _b, _c;
|
|
6585
6794
|
const [componentId] = zoneCompound.split(":");
|
|
@@ -6653,7 +6862,7 @@ var SidebarSection = ({
|
|
|
6653
6862
|
|
|
6654
6863
|
// css-module:/home/runner/work/puck/puck/packages/core/components/Puck/styles.module.css#css-module
|
|
6655
6864
|
init_react_import();
|
|
6656
|
-
var styles_module_default14 = { "Puck": "
|
|
6865
|
+
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" };
|
|
6657
6866
|
|
|
6658
6867
|
// components/Puck/components/Fields/index.tsx
|
|
6659
6868
|
init_react_import();
|
|
@@ -6663,8 +6872,8 @@ init_react_import();
|
|
|
6663
6872
|
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" };
|
|
6664
6873
|
|
|
6665
6874
|
// components/Puck/components/Fields/index.tsx
|
|
6666
|
-
var
|
|
6667
|
-
var
|
|
6875
|
+
var import_react41 = require("react");
|
|
6876
|
+
var import_shallow6 = require("zustand/react/shallow");
|
|
6668
6877
|
var import_jsx_runtime29 = require("react/jsx-runtime");
|
|
6669
6878
|
var getClassName20 = get_class_name_factory_default("PuckFields", styles_module_default15);
|
|
6670
6879
|
var DefaultFields = ({
|
|
@@ -6730,13 +6939,13 @@ var FieldsChild = ({ fieldName }) => {
|
|
|
6730
6939
|
return s.selectedItem ? `${s.selectedItem.props.id}_${field.type}_${fieldName}` : `root_${field.type}_${fieldName}`;
|
|
6731
6940
|
});
|
|
6732
6941
|
const permissions = useAppStore(
|
|
6733
|
-
(0,
|
|
6942
|
+
(0, import_shallow6.useShallow)((s) => {
|
|
6734
6943
|
const { selectedItem, permissions: permissions2 } = s;
|
|
6735
6944
|
return selectedItem ? permissions2.getPermissions({ item: selectedItem }) : permissions2.getPermissions({ root: true });
|
|
6736
6945
|
})
|
|
6737
6946
|
);
|
|
6738
6947
|
const appStore = useAppStoreApi();
|
|
6739
|
-
const onChange = (0,
|
|
6948
|
+
const onChange = (0, import_react41.useCallback)(createOnChange(fieldName, appStore), [
|
|
6740
6949
|
fieldName
|
|
6741
6950
|
]);
|
|
6742
6951
|
const { visible = true } = field != null ? field : {};
|
|
@@ -6754,7 +6963,7 @@ var FieldsChild = ({ fieldName }) => {
|
|
|
6754
6963
|
}
|
|
6755
6964
|
) }, id);
|
|
6756
6965
|
};
|
|
6757
|
-
var FieldsChildMemo = (0,
|
|
6966
|
+
var FieldsChildMemo = (0, import_react41.memo)(FieldsChild);
|
|
6758
6967
|
var FieldsInternal = ({ wrapFields = true }) => {
|
|
6759
6968
|
const overrides = useAppStore((s) => s.overrides);
|
|
6760
6969
|
const componentResolving = useAppStore((s) => {
|
|
@@ -6762,7 +6971,7 @@ var FieldsInternal = ({ wrapFields = true }) => {
|
|
|
6762
6971
|
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;
|
|
6763
6972
|
return (loadingCount != null ? loadingCount : 0) > 0;
|
|
6764
6973
|
});
|
|
6765
|
-
const itemSelector = useAppStore((0,
|
|
6974
|
+
const itemSelector = useAppStore((0, import_shallow6.useShallow)((s) => s.state.ui.itemSelector));
|
|
6766
6975
|
const id = useAppStore((s) => {
|
|
6767
6976
|
var _a;
|
|
6768
6977
|
return (_a = s.selectedItem) == null ? void 0 : _a.props.id;
|
|
@@ -6771,7 +6980,7 @@ var FieldsInternal = ({ wrapFields = true }) => {
|
|
|
6771
6980
|
useRegisterFieldsSlice(appStore, id);
|
|
6772
6981
|
const fieldsLoading = useAppStore((s) => s.fields.loading);
|
|
6773
6982
|
const fieldNames = useAppStore(
|
|
6774
|
-
(0,
|
|
6983
|
+
(0, import_shallow6.useShallow)((s) => {
|
|
6775
6984
|
if (s.fields.id === id) {
|
|
6776
6985
|
return Object.keys(s.fields.fields);
|
|
6777
6986
|
}
|
|
@@ -6779,7 +6988,7 @@ var FieldsInternal = ({ wrapFields = true }) => {
|
|
|
6779
6988
|
})
|
|
6780
6989
|
);
|
|
6781
6990
|
const isLoading = fieldsLoading || componentResolving;
|
|
6782
|
-
const Wrapper = (0,
|
|
6991
|
+
const Wrapper = (0, import_react41.useMemo)(() => overrides.fields || DefaultFields, [overrides]);
|
|
6783
6992
|
return /* @__PURE__ */ (0, import_jsx_runtime29.jsxs)(
|
|
6784
6993
|
"form",
|
|
6785
6994
|
{
|
|
@@ -6794,14 +7003,14 @@ var FieldsInternal = ({ wrapFields = true }) => {
|
|
|
6794
7003
|
}
|
|
6795
7004
|
);
|
|
6796
7005
|
};
|
|
6797
|
-
var Fields = (0,
|
|
7006
|
+
var Fields = (0, import_react41.memo)(FieldsInternal);
|
|
6798
7007
|
|
|
6799
7008
|
// components/Puck/components/Components/index.tsx
|
|
6800
7009
|
init_react_import();
|
|
6801
7010
|
|
|
6802
7011
|
// lib/use-component-list.tsx
|
|
6803
7012
|
init_react_import();
|
|
6804
|
-
var
|
|
7013
|
+
var import_react42 = require("react");
|
|
6805
7014
|
|
|
6806
7015
|
// components/ComponentList/index.tsx
|
|
6807
7016
|
init_react_import();
|
|
@@ -6872,10 +7081,10 @@ ComponentList.Item = ComponentListItem;
|
|
|
6872
7081
|
// lib/use-component-list.tsx
|
|
6873
7082
|
var import_jsx_runtime31 = require("react/jsx-runtime");
|
|
6874
7083
|
var useComponentList = () => {
|
|
6875
|
-
const [componentList, setComponentList] = (0,
|
|
7084
|
+
const [componentList, setComponentList] = (0, import_react42.useState)();
|
|
6876
7085
|
const config = useAppStore((s) => s.config);
|
|
6877
7086
|
const uiComponentList = useAppStore((s) => s.state.ui.componentList);
|
|
6878
|
-
(0,
|
|
7087
|
+
(0, import_react42.useEffect)(() => {
|
|
6879
7088
|
var _a, _b, _c;
|
|
6880
7089
|
if (Object.keys(uiComponentList).length > 0) {
|
|
6881
7090
|
const matchedComponents = [];
|
|
@@ -6944,22 +7153,22 @@ var useComponentList = () => {
|
|
|
6944
7153
|
};
|
|
6945
7154
|
|
|
6946
7155
|
// components/Puck/components/Components/index.tsx
|
|
6947
|
-
var
|
|
7156
|
+
var import_react43 = require("react");
|
|
6948
7157
|
var import_jsx_runtime32 = require("react/jsx-runtime");
|
|
6949
7158
|
var Components = () => {
|
|
6950
7159
|
const overrides = useAppStore((s) => s.overrides);
|
|
6951
7160
|
const componentList = useComponentList();
|
|
6952
|
-
const Wrapper = (0,
|
|
7161
|
+
const Wrapper = (0, import_react43.useMemo)(() => overrides.components || "div", [overrides]);
|
|
6953
7162
|
return /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(Wrapper, { children: componentList ? componentList : /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(ComponentList, { id: "all" }) });
|
|
6954
7163
|
};
|
|
6955
7164
|
|
|
6956
7165
|
// components/Puck/components/Preview/index.tsx
|
|
6957
7166
|
init_react_import();
|
|
6958
|
-
var
|
|
7167
|
+
var import_react45 = require("react");
|
|
6959
7168
|
|
|
6960
7169
|
// components/AutoFrame/index.tsx
|
|
6961
7170
|
init_react_import();
|
|
6962
|
-
var
|
|
7171
|
+
var import_react44 = require("react");
|
|
6963
7172
|
var import_object_hash = __toESM(require("object-hash"));
|
|
6964
7173
|
var import_react_dom3 = require("react-dom");
|
|
6965
7174
|
var import_jsx_runtime33 = require("react/jsx-runtime");
|
|
@@ -7012,7 +7221,7 @@ var CopyHostStyles = ({
|
|
|
7012
7221
|
onStylesLoaded = () => null
|
|
7013
7222
|
}) => {
|
|
7014
7223
|
const { document: doc, window: win } = useFrame();
|
|
7015
|
-
(0,
|
|
7224
|
+
(0, import_react44.useEffect)(() => {
|
|
7016
7225
|
if (!win || !doc) {
|
|
7017
7226
|
return () => {
|
|
7018
7227
|
};
|
|
@@ -7171,8 +7380,8 @@ var CopyHostStyles = ({
|
|
|
7171
7380
|
}, []);
|
|
7172
7381
|
return /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(import_jsx_runtime33.Fragment, { children });
|
|
7173
7382
|
};
|
|
7174
|
-
var autoFrameContext = (0,
|
|
7175
|
-
var useFrame = () => (0,
|
|
7383
|
+
var autoFrameContext = (0, import_react44.createContext)({});
|
|
7384
|
+
var useFrame = () => (0, import_react44.useContext)(autoFrameContext);
|
|
7176
7385
|
function AutoFrame(_a) {
|
|
7177
7386
|
var _b = _a, {
|
|
7178
7387
|
children,
|
|
@@ -7193,11 +7402,11 @@ function AutoFrame(_a) {
|
|
|
7193
7402
|
"onNotReady",
|
|
7194
7403
|
"frameRef"
|
|
7195
7404
|
]);
|
|
7196
|
-
const [loaded, setLoaded] = (0,
|
|
7197
|
-
const [ctx, setCtx] = (0,
|
|
7198
|
-
const [mountTarget, setMountTarget] = (0,
|
|
7199
|
-
const [stylesLoaded, setStylesLoaded] = (0,
|
|
7200
|
-
(0,
|
|
7405
|
+
const [loaded, setLoaded] = (0, import_react44.useState)(false);
|
|
7406
|
+
const [ctx, setCtx] = (0, import_react44.useState)({});
|
|
7407
|
+
const [mountTarget, setMountTarget] = (0, import_react44.useState)();
|
|
7408
|
+
const [stylesLoaded, setStylesLoaded] = (0, import_react44.useState)(false);
|
|
7409
|
+
(0, import_react44.useEffect)(() => {
|
|
7201
7410
|
var _a2;
|
|
7202
7411
|
if (frameRef.current) {
|
|
7203
7412
|
const doc = frameRef.current.contentDocument;
|
|
@@ -7249,7 +7458,7 @@ var import_jsx_runtime34 = require("react/jsx-runtime");
|
|
|
7249
7458
|
var getClassName22 = get_class_name_factory_default("PuckPreview", styles_module_default17);
|
|
7250
7459
|
var useBubbleIframeEvents = (ref) => {
|
|
7251
7460
|
const status = useAppStore((s) => s.status);
|
|
7252
|
-
(0,
|
|
7461
|
+
(0, import_react45.useEffect)(() => {
|
|
7253
7462
|
if (ref.current && status === "READY") {
|
|
7254
7463
|
const iframe = ref.current;
|
|
7255
7464
|
const handlePointerMove = (event) => {
|
|
@@ -7298,7 +7507,7 @@ var Preview2 = ({ id = "puck-preview" }) => {
|
|
|
7298
7507
|
const renderData = useAppStore(
|
|
7299
7508
|
(s) => s.state.ui.previewMode === "edit" ? null : s.state.data
|
|
7300
7509
|
);
|
|
7301
|
-
const Page = (0,
|
|
7510
|
+
const Page = (0, import_react45.useCallback)(
|
|
7302
7511
|
(pageProps) => {
|
|
7303
7512
|
var _a, _b;
|
|
7304
7513
|
const propsWithSlots = useSlots(
|
|
@@ -7312,9 +7521,9 @@ var Preview2 = ({ id = "puck-preview" }) => {
|
|
|
7312
7521
|
},
|
|
7313
7522
|
[config]
|
|
7314
7523
|
);
|
|
7315
|
-
const Frame = (0,
|
|
7524
|
+
const Frame = (0, import_react45.useMemo)(() => overrides.iframe, [overrides]);
|
|
7316
7525
|
const rootProps = root.props || root;
|
|
7317
|
-
const ref = (0,
|
|
7526
|
+
const ref = (0, import_react45.useRef)(null);
|
|
7318
7527
|
useBubbleIframeEvents(ref);
|
|
7319
7528
|
const inner = !renderData ? /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(
|
|
7320
7529
|
Page,
|
|
@@ -7329,7 +7538,7 @@ var Preview2 = ({ id = "puck-preview" }) => {
|
|
|
7329
7538
|
children: /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(DropZonePure, { zone: rootDroppableId })
|
|
7330
7539
|
})
|
|
7331
7540
|
) : /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(Render, { data: renderData, config, metadata });
|
|
7332
|
-
(0,
|
|
7541
|
+
(0, import_react45.useEffect)(() => {
|
|
7333
7542
|
if (!iframe.enabled) {
|
|
7334
7543
|
setStatus("READY");
|
|
7335
7544
|
}
|
|
@@ -7399,7 +7608,7 @@ var scrollIntoView = (el) => {
|
|
|
7399
7608
|
};
|
|
7400
7609
|
|
|
7401
7610
|
// components/LayerTree/index.tsx
|
|
7402
|
-
var
|
|
7611
|
+
var import_react46 = require("react");
|
|
7403
7612
|
|
|
7404
7613
|
// lib/on-scroll-end.ts
|
|
7405
7614
|
init_react_import();
|
|
@@ -7421,7 +7630,7 @@ var onScrollEnd = (frame, cb) => {
|
|
|
7421
7630
|
};
|
|
7422
7631
|
|
|
7423
7632
|
// components/LayerTree/index.tsx
|
|
7424
|
-
var
|
|
7633
|
+
var import_shallow7 = require("zustand/react/shallow");
|
|
7425
7634
|
var import_jsx_runtime35 = require("react/jsx-runtime");
|
|
7426
7635
|
var getClassName23 = get_class_name_factory_default("LayerTree", styles_module_default18);
|
|
7427
7636
|
var getClassNameLayer = get_class_name_factory_default("Layer", styles_module_default18);
|
|
@@ -7434,7 +7643,7 @@ var Layer = ({
|
|
|
7434
7643
|
const config = useAppStore((s) => s.config);
|
|
7435
7644
|
const itemSelector = useAppStore((s) => s.state.ui.itemSelector);
|
|
7436
7645
|
const dispatch = useAppStore((s) => s.dispatch);
|
|
7437
|
-
const setItemSelector = (0,
|
|
7646
|
+
const setItemSelector = (0, import_react46.useCallback)(
|
|
7438
7647
|
(itemSelector2) => {
|
|
7439
7648
|
dispatch({ type: "setUi", ui: { itemSelector: itemSelector2 } });
|
|
7440
7649
|
},
|
|
@@ -7447,14 +7656,14 @@ var Layer = ({
|
|
|
7447
7656
|
const isSelected = selecedItemId === itemId || itemSelector && itemSelector.zone === rootDroppableId && !zoneCompound;
|
|
7448
7657
|
const nodeData = useAppStore((s) => s.state.indexes.nodes[itemId]);
|
|
7449
7658
|
const zonesForItem = useAppStore(
|
|
7450
|
-
(0,
|
|
7659
|
+
(0, import_shallow7.useShallow)(
|
|
7451
7660
|
(s) => Object.keys(s.state.indexes.zones).filter(
|
|
7452
7661
|
(z) => z.split(":")[0] === itemId
|
|
7453
7662
|
)
|
|
7454
7663
|
)
|
|
7455
7664
|
);
|
|
7456
7665
|
const containsZone = zonesForItem.length > 0;
|
|
7457
|
-
const zoneStore = (0,
|
|
7666
|
+
const zoneStore = (0, import_react46.useContext)(ZoneStoreContext);
|
|
7458
7667
|
const isHovering = useContextStore(
|
|
7459
7668
|
ZoneStoreContext,
|
|
7460
7669
|
(s) => s.hoveringComponent === itemId
|
|
@@ -7535,209 +7744,88 @@ var Layer = ({
|
|
|
7535
7744
|
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))
|
|
7536
7745
|
]
|
|
7537
7746
|
}
|
|
7538
|
-
);
|
|
7539
|
-
};
|
|
7540
|
-
var LayerTree = ({
|
|
7541
|
-
label: _label,
|
|
7542
|
-
zoneCompound
|
|
7543
|
-
}) => {
|
|
7544
|
-
const label = useAppStore((s) => {
|
|
7545
|
-
var _a, _b, _c, _d;
|
|
7546
|
-
if (_label) return _label;
|
|
7547
|
-
if (zoneCompound === rootDroppableId) return;
|
|
7548
|
-
const [componentId, slotId] = zoneCompound.split(":");
|
|
7549
|
-
const componentType = (_a = s.state.indexes.nodes[componentId]) == null ? void 0 : _a.data.type;
|
|
7550
|
-
const configForComponent = componentType && componentType !== rootAreaId ? s.config.components[componentType] : s.config.root;
|
|
7551
|
-
return (_d = (_c = (_b = configForComponent == null ? void 0 : configForComponent.fields) == null ? void 0 : _b[slotId]) == null ? void 0 : _c.label) != null ? _d : slotId;
|
|
7552
|
-
});
|
|
7553
|
-
const contentIds = useAppStore(
|
|
7554
|
-
(0, import_shallow6.useShallow)(
|
|
7555
|
-
(s) => {
|
|
7556
|
-
var _a, _b;
|
|
7557
|
-
return zoneCompound ? (_b = (_a = s.state.indexes.zones[zoneCompound]) == null ? void 0 : _a.contentIds) != null ? _b : [] : [];
|
|
7558
|
-
}
|
|
7559
|
-
)
|
|
7560
|
-
);
|
|
7561
|
-
return /* @__PURE__ */ (0, import_jsx_runtime35.jsxs)(import_jsx_runtime35.Fragment, { children: [
|
|
7562
|
-
label && /* @__PURE__ */ (0, import_jsx_runtime35.jsxs)("div", { className: getClassName23("zoneTitle"), children: [
|
|
7563
|
-
/* @__PURE__ */ (0, import_jsx_runtime35.jsx)("div", { className: getClassName23("zoneIcon"), children: /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(Layers, { size: "16" }) }),
|
|
7564
|
-
label
|
|
7565
|
-
] }),
|
|
7566
|
-
/* @__PURE__ */ (0, import_jsx_runtime35.jsxs)("ul", { className: getClassName23(), children: [
|
|
7567
|
-
contentIds.length === 0 && /* @__PURE__ */ (0, import_jsx_runtime35.jsx)("div", { className: getClassName23("helper"), children: "No items" }),
|
|
7568
|
-
contentIds.map((itemId, i) => {
|
|
7569
|
-
return /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(
|
|
7570
|
-
Layer,
|
|
7571
|
-
{
|
|
7572
|
-
index: i,
|
|
7573
|
-
itemId,
|
|
7574
|
-
zoneCompound
|
|
7575
|
-
},
|
|
7576
|
-
itemId
|
|
7577
|
-
);
|
|
7578
|
-
})
|
|
7579
|
-
] })
|
|
7580
|
-
] });
|
|
7581
|
-
};
|
|
7582
|
-
|
|
7583
|
-
// components/Puck/components/Outline/index.tsx
|
|
7584
|
-
var import_react46 = require("react");
|
|
7585
|
-
|
|
7586
|
-
// lib/data/find-zones-for-area.ts
|
|
7587
|
-
init_react_import();
|
|
7588
|
-
var findZonesForArea = (state, area) => {
|
|
7589
|
-
return Object.keys(state.indexes.zones).filter(
|
|
7590
|
-
(zone) => zone.split(":")[0] === area
|
|
7591
|
-
);
|
|
7592
|
-
};
|
|
7593
|
-
|
|
7594
|
-
// components/Puck/components/Outline/index.tsx
|
|
7595
|
-
var import_shallow7 = require("zustand/react/shallow");
|
|
7596
|
-
var import_jsx_runtime36 = require("react/jsx-runtime");
|
|
7597
|
-
var Outline = () => {
|
|
7598
|
-
const outlineOverride = useAppStore((s) => s.overrides.outline);
|
|
7599
|
-
const rootZones = useAppStore(
|
|
7600
|
-
(0, import_shallow7.useShallow)((s) => findZonesForArea(s.state, "root"))
|
|
7601
|
-
);
|
|
7602
|
-
const Wrapper = (0, import_react46.useMemo)(() => outlineOverride || "div", [outlineOverride]);
|
|
7603
|
-
return /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(Wrapper, { children: rootZones.map((zoneCompound) => /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(
|
|
7604
|
-
LayerTree,
|
|
7605
|
-
{
|
|
7606
|
-
label: rootZones.length === 1 ? "" : zoneCompound.split(":")[1],
|
|
7607
|
-
zoneCompound
|
|
7608
|
-
},
|
|
7609
|
-
zoneCompound
|
|
7610
|
-
)) });
|
|
7611
|
-
};
|
|
7612
|
-
|
|
7613
|
-
// components/Puck/components/Canvas/index.tsx
|
|
7614
|
-
init_react_import();
|
|
7615
|
-
|
|
7616
|
-
// ../../node_modules/css-box-model/dist/css-box-model.esm.js
|
|
7617
|
-
init_react_import();
|
|
7618
|
-
|
|
7619
|
-
// ../../node_modules/tiny-invariant/dist/esm/tiny-invariant.js
|
|
7620
|
-
init_react_import();
|
|
7621
|
-
var isProduction = process.env.NODE_ENV === "production";
|
|
7622
|
-
var prefix = "Invariant failed";
|
|
7623
|
-
function invariant(condition, message) {
|
|
7624
|
-
if (condition) {
|
|
7625
|
-
return;
|
|
7626
|
-
}
|
|
7627
|
-
if (isProduction) {
|
|
7628
|
-
throw new Error(prefix);
|
|
7629
|
-
}
|
|
7630
|
-
var provided = typeof message === "function" ? message() : message;
|
|
7631
|
-
var value = provided ? "".concat(prefix, ": ").concat(provided) : prefix;
|
|
7632
|
-
throw new Error(value);
|
|
7633
|
-
}
|
|
7634
|
-
|
|
7635
|
-
// ../../node_modules/css-box-model/dist/css-box-model.esm.js
|
|
7636
|
-
var getRect = function getRect2(_ref) {
|
|
7637
|
-
var top = _ref.top, right = _ref.right, bottom = _ref.bottom, left = _ref.left;
|
|
7638
|
-
var width = right - left;
|
|
7639
|
-
var height = bottom - top;
|
|
7640
|
-
var rect = {
|
|
7641
|
-
top,
|
|
7642
|
-
right,
|
|
7643
|
-
bottom,
|
|
7644
|
-
left,
|
|
7645
|
-
width,
|
|
7646
|
-
height,
|
|
7647
|
-
x: left,
|
|
7648
|
-
y: top,
|
|
7649
|
-
center: {
|
|
7650
|
-
x: (right + left) / 2,
|
|
7651
|
-
y: (bottom + top) / 2
|
|
7652
|
-
}
|
|
7653
|
-
};
|
|
7654
|
-
return rect;
|
|
7655
|
-
};
|
|
7656
|
-
var expand = function expand2(target, expandBy) {
|
|
7657
|
-
return {
|
|
7658
|
-
top: target.top - expandBy.top,
|
|
7659
|
-
left: target.left - expandBy.left,
|
|
7660
|
-
bottom: target.bottom + expandBy.bottom,
|
|
7661
|
-
right: target.right + expandBy.right
|
|
7662
|
-
};
|
|
7663
|
-
};
|
|
7664
|
-
var shrink = function shrink2(target, shrinkBy) {
|
|
7665
|
-
return {
|
|
7666
|
-
top: target.top + shrinkBy.top,
|
|
7667
|
-
left: target.left + shrinkBy.left,
|
|
7668
|
-
bottom: target.bottom - shrinkBy.bottom,
|
|
7669
|
-
right: target.right - shrinkBy.right
|
|
7670
|
-
};
|
|
7671
|
-
};
|
|
7672
|
-
var noSpacing = {
|
|
7673
|
-
top: 0,
|
|
7674
|
-
right: 0,
|
|
7675
|
-
bottom: 0,
|
|
7676
|
-
left: 0
|
|
7677
|
-
};
|
|
7678
|
-
var createBox = function createBox2(_ref2) {
|
|
7679
|
-
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;
|
|
7680
|
-
var marginBox = getRect(expand(borderBox, margin));
|
|
7681
|
-
var paddingBox = getRect(shrink(borderBox, border));
|
|
7682
|
-
var contentBox = getRect(shrink(paddingBox, padding));
|
|
7683
|
-
return {
|
|
7684
|
-
marginBox,
|
|
7685
|
-
borderBox: getRect(borderBox),
|
|
7686
|
-
paddingBox,
|
|
7687
|
-
contentBox,
|
|
7688
|
-
margin,
|
|
7689
|
-
border,
|
|
7690
|
-
padding
|
|
7691
|
-
};
|
|
7692
|
-
};
|
|
7693
|
-
var parse = function parse2(raw) {
|
|
7694
|
-
var value = raw.slice(0, -2);
|
|
7695
|
-
var suffix = raw.slice(-2);
|
|
7696
|
-
if (suffix !== "px") {
|
|
7697
|
-
return 0;
|
|
7698
|
-
}
|
|
7699
|
-
var result = Number(value);
|
|
7700
|
-
!!isNaN(result) ? process.env.NODE_ENV !== "production" ? invariant(false, "Could not parse value [raw: " + raw + ", without suffix: " + value + "]") : invariant(false) : void 0;
|
|
7701
|
-
return result;
|
|
7702
|
-
};
|
|
7703
|
-
var calculateBox = function calculateBox2(borderBox, styles2) {
|
|
7704
|
-
var margin = {
|
|
7705
|
-
top: parse(styles2.marginTop),
|
|
7706
|
-
right: parse(styles2.marginRight),
|
|
7707
|
-
bottom: parse(styles2.marginBottom),
|
|
7708
|
-
left: parse(styles2.marginLeft)
|
|
7709
|
-
};
|
|
7710
|
-
var padding = {
|
|
7711
|
-
top: parse(styles2.paddingTop),
|
|
7712
|
-
right: parse(styles2.paddingRight),
|
|
7713
|
-
bottom: parse(styles2.paddingBottom),
|
|
7714
|
-
left: parse(styles2.paddingLeft)
|
|
7715
|
-
};
|
|
7716
|
-
var border = {
|
|
7717
|
-
top: parse(styles2.borderTopWidth),
|
|
7718
|
-
right: parse(styles2.borderRightWidth),
|
|
7719
|
-
bottom: parse(styles2.borderBottomWidth),
|
|
7720
|
-
left: parse(styles2.borderLeftWidth)
|
|
7721
|
-
};
|
|
7722
|
-
return createBox({
|
|
7723
|
-
borderBox,
|
|
7724
|
-
margin,
|
|
7725
|
-
padding,
|
|
7726
|
-
border
|
|
7747
|
+
);
|
|
7748
|
+
};
|
|
7749
|
+
var LayerTree = ({
|
|
7750
|
+
label: _label,
|
|
7751
|
+
zoneCompound
|
|
7752
|
+
}) => {
|
|
7753
|
+
const label = useAppStore((s) => {
|
|
7754
|
+
var _a, _b, _c, _d;
|
|
7755
|
+
if (_label) return _label;
|
|
7756
|
+
if (zoneCompound === rootDroppableId) return;
|
|
7757
|
+
const [componentId, slotId] = zoneCompound.split(":");
|
|
7758
|
+
const componentType = (_a = s.state.indexes.nodes[componentId]) == null ? void 0 : _a.data.type;
|
|
7759
|
+
const configForComponent = componentType && componentType !== rootAreaId ? s.config.components[componentType] : s.config.root;
|
|
7760
|
+
return (_d = (_c = (_b = configForComponent == null ? void 0 : configForComponent.fields) == null ? void 0 : _b[slotId]) == null ? void 0 : _c.label) != null ? _d : slotId;
|
|
7727
7761
|
});
|
|
7762
|
+
const contentIds = useAppStore(
|
|
7763
|
+
(0, import_shallow7.useShallow)(
|
|
7764
|
+
(s) => {
|
|
7765
|
+
var _a, _b;
|
|
7766
|
+
return zoneCompound ? (_b = (_a = s.state.indexes.zones[zoneCompound]) == null ? void 0 : _a.contentIds) != null ? _b : [] : [];
|
|
7767
|
+
}
|
|
7768
|
+
)
|
|
7769
|
+
);
|
|
7770
|
+
return /* @__PURE__ */ (0, import_jsx_runtime35.jsxs)(import_jsx_runtime35.Fragment, { children: [
|
|
7771
|
+
label && /* @__PURE__ */ (0, import_jsx_runtime35.jsxs)("div", { className: getClassName23("zoneTitle"), children: [
|
|
7772
|
+
/* @__PURE__ */ (0, import_jsx_runtime35.jsx)("div", { className: getClassName23("zoneIcon"), children: /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(Layers, { size: "16" }) }),
|
|
7773
|
+
label
|
|
7774
|
+
] }),
|
|
7775
|
+
/* @__PURE__ */ (0, import_jsx_runtime35.jsxs)("ul", { className: getClassName23(), children: [
|
|
7776
|
+
contentIds.length === 0 && /* @__PURE__ */ (0, import_jsx_runtime35.jsx)("div", { className: getClassName23("helper"), children: "No items" }),
|
|
7777
|
+
contentIds.map((itemId, i) => {
|
|
7778
|
+
return /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(
|
|
7779
|
+
Layer,
|
|
7780
|
+
{
|
|
7781
|
+
index: i,
|
|
7782
|
+
itemId,
|
|
7783
|
+
zoneCompound
|
|
7784
|
+
},
|
|
7785
|
+
itemId
|
|
7786
|
+
);
|
|
7787
|
+
})
|
|
7788
|
+
] })
|
|
7789
|
+
] });
|
|
7728
7790
|
};
|
|
7729
|
-
|
|
7730
|
-
|
|
7731
|
-
|
|
7732
|
-
|
|
7791
|
+
|
|
7792
|
+
// components/Puck/components/Outline/index.tsx
|
|
7793
|
+
var import_react47 = require("react");
|
|
7794
|
+
|
|
7795
|
+
// lib/data/find-zones-for-area.ts
|
|
7796
|
+
init_react_import();
|
|
7797
|
+
var findZonesForArea = (state, area) => {
|
|
7798
|
+
return Object.keys(state.indexes.zones).filter(
|
|
7799
|
+
(zone) => zone.split(":")[0] === area
|
|
7800
|
+
);
|
|
7801
|
+
};
|
|
7802
|
+
|
|
7803
|
+
// components/Puck/components/Outline/index.tsx
|
|
7804
|
+
var import_shallow8 = require("zustand/react/shallow");
|
|
7805
|
+
var import_jsx_runtime36 = require("react/jsx-runtime");
|
|
7806
|
+
var Outline = () => {
|
|
7807
|
+
const outlineOverride = useAppStore((s) => s.overrides.outline);
|
|
7808
|
+
const rootZones = useAppStore(
|
|
7809
|
+
(0, import_shallow8.useShallow)((s) => findZonesForArea(s.state, "root"))
|
|
7810
|
+
);
|
|
7811
|
+
const Wrapper = (0, import_react47.useMemo)(() => outlineOverride || "div", [outlineOverride]);
|
|
7812
|
+
return /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(Wrapper, { children: rootZones.map((zoneCompound) => /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(
|
|
7813
|
+
LayerTree,
|
|
7814
|
+
{
|
|
7815
|
+
label: rootZones.length === 1 ? "" : zoneCompound.split(":")[1],
|
|
7816
|
+
zoneCompound
|
|
7817
|
+
},
|
|
7818
|
+
zoneCompound
|
|
7819
|
+
)) });
|
|
7733
7820
|
};
|
|
7734
7821
|
|
|
7735
7822
|
// components/Puck/components/Canvas/index.tsx
|
|
7736
|
-
|
|
7823
|
+
init_react_import();
|
|
7824
|
+
var import_react50 = require("react");
|
|
7737
7825
|
|
|
7738
7826
|
// components/ViewportControls/index.tsx
|
|
7739
7827
|
init_react_import();
|
|
7740
|
-
var
|
|
7828
|
+
var import_react48 = require("react");
|
|
7741
7829
|
|
|
7742
7830
|
// css-module:/home/runner/work/puck/puck/packages/core/components/ViewportControls/styles.module.css#css-module
|
|
7743
7831
|
init_react_import();
|
|
@@ -7760,8 +7848,8 @@ var ViewportButton = ({
|
|
|
7760
7848
|
onClick
|
|
7761
7849
|
}) => {
|
|
7762
7850
|
const viewports = useAppStore((s) => s.state.ui.viewports);
|
|
7763
|
-
const [isActive, setIsActive] = (0,
|
|
7764
|
-
(0,
|
|
7851
|
+
const [isActive, setIsActive] = (0, import_react48.useState)(false);
|
|
7852
|
+
(0, import_react48.useEffect)(() => {
|
|
7765
7853
|
setIsActive(width === viewports.current.width);
|
|
7766
7854
|
}, [width, viewports.current.width]);
|
|
7767
7855
|
return /* @__PURE__ */ (0, import_jsx_runtime37.jsx)("span", { className: getClassNameButton({ isActive }), children: /* @__PURE__ */ (0, import_jsx_runtime37.jsx)(
|
|
@@ -7798,7 +7886,7 @@ var ViewportControls = ({
|
|
|
7798
7886
|
const defaultsContainAutoZoom = defaultZoomOptions.find(
|
|
7799
7887
|
(option) => option.value === autoZoom
|
|
7800
7888
|
);
|
|
7801
|
-
const zoomOptions = (0,
|
|
7889
|
+
const zoomOptions = (0, import_react48.useMemo)(
|
|
7802
7890
|
() => [
|
|
7803
7891
|
...defaultZoomOptions,
|
|
7804
7892
|
...defaultsContainAutoZoom ? [] : [
|
|
@@ -7885,42 +7973,41 @@ var ViewportControls = ({
|
|
|
7885
7973
|
init_react_import();
|
|
7886
7974
|
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" };
|
|
7887
7975
|
|
|
7888
|
-
//
|
|
7976
|
+
// components/Puck/components/Canvas/index.tsx
|
|
7977
|
+
var import_shallow9 = require("zustand/react/shallow");
|
|
7978
|
+
|
|
7979
|
+
// lib/frame-context.tsx
|
|
7889
7980
|
init_react_import();
|
|
7890
|
-
var
|
|
7891
|
-
var
|
|
7892
|
-
|
|
7893
|
-
|
|
7894
|
-
|
|
7895
|
-
|
|
7896
|
-
|
|
7897
|
-
|
|
7898
|
-
|
|
7899
|
-
|
|
7900
|
-
|
|
7901
|
-
|
|
7902
|
-
|
|
7903
|
-
|
|
7904
|
-
|
|
7905
|
-
|
|
7906
|
-
|
|
7907
|
-
|
|
7908
|
-
|
|
7909
|
-
if (RESET_ZOOM_SMALLER_THAN_FRAME) {
|
|
7910
|
-
autoZoom = 1;
|
|
7911
|
-
zoom = 1;
|
|
7912
|
-
rootHeight = viewportHeight;
|
|
7913
|
-
}
|
|
7981
|
+
var import_react49 = require("react");
|
|
7982
|
+
var import_jsx_runtime38 = require("react/jsx-runtime");
|
|
7983
|
+
var FrameContext = (0, import_react49.createContext)(null);
|
|
7984
|
+
var FrameProvider = ({
|
|
7985
|
+
children
|
|
7986
|
+
}) => {
|
|
7987
|
+
const frameRef = (0, import_react49.useRef)(null);
|
|
7988
|
+
const value = (0, import_react49.useMemo)(
|
|
7989
|
+
() => ({
|
|
7990
|
+
frameRef
|
|
7991
|
+
}),
|
|
7992
|
+
[]
|
|
7993
|
+
);
|
|
7994
|
+
return /* @__PURE__ */ (0, import_jsx_runtime38.jsx)(FrameContext.Provider, { value, children });
|
|
7995
|
+
};
|
|
7996
|
+
var useCanvasFrame = () => {
|
|
7997
|
+
const context = (0, import_react49.useContext)(FrameContext);
|
|
7998
|
+
if (context === null) {
|
|
7999
|
+
throw new Error("useCanvasFrame must be used within a FrameProvider");
|
|
7914
8000
|
}
|
|
7915
|
-
return
|
|
8001
|
+
return context;
|
|
7916
8002
|
};
|
|
7917
8003
|
|
|
7918
8004
|
// components/Puck/components/Canvas/index.tsx
|
|
7919
|
-
var
|
|
7920
|
-
var import_jsx_runtime38 = require("react/jsx-runtime");
|
|
8005
|
+
var import_jsx_runtime39 = require("react/jsx-runtime");
|
|
7921
8006
|
var getClassName25 = get_class_name_factory_default("PuckCanvas", styles_module_default20);
|
|
7922
8007
|
var ZOOM_ON_CHANGE = true;
|
|
7923
8008
|
var Canvas = () => {
|
|
8009
|
+
const { frameRef } = useCanvasFrame();
|
|
8010
|
+
const resetAutoZoom = useResetAutoZoom(frameRef);
|
|
7924
8011
|
const {
|
|
7925
8012
|
dispatch,
|
|
7926
8013
|
overrides,
|
|
@@ -7930,7 +8017,7 @@ var Canvas = () => {
|
|
|
7930
8017
|
status,
|
|
7931
8018
|
iframe
|
|
7932
8019
|
} = useAppStore(
|
|
7933
|
-
(0,
|
|
8020
|
+
(0, import_shallow9.useShallow)((s) => ({
|
|
7934
8021
|
dispatch: s.dispatch,
|
|
7935
8022
|
overrides: s.overrides,
|
|
7936
8023
|
setUi: s.setUi,
|
|
@@ -7940,24 +8027,32 @@ var Canvas = () => {
|
|
|
7940
8027
|
iframe: s.iframe
|
|
7941
8028
|
}))
|
|
7942
8029
|
);
|
|
7943
|
-
const {
|
|
7944
|
-
|
|
8030
|
+
const {
|
|
8031
|
+
leftSideBarVisible,
|
|
8032
|
+
rightSideBarVisible,
|
|
8033
|
+
leftSideBarWidth,
|
|
8034
|
+
rightSideBarWidth,
|
|
8035
|
+
viewports
|
|
8036
|
+
} = useAppStore(
|
|
8037
|
+
(0, import_shallow9.useShallow)((s) => ({
|
|
7945
8038
|
leftSideBarVisible: s.state.ui.leftSideBarVisible,
|
|
7946
8039
|
rightSideBarVisible: s.state.ui.rightSideBarVisible,
|
|
8040
|
+
leftSideBarWidth: s.state.ui.leftSideBarWidth,
|
|
8041
|
+
rightSideBarWidth: s.state.ui.rightSideBarWidth,
|
|
7947
8042
|
viewports: s.state.ui.viewports
|
|
7948
8043
|
}))
|
|
7949
8044
|
);
|
|
7950
|
-
const
|
|
7951
|
-
const
|
|
7952
|
-
const defaultRender = (0,
|
|
7953
|
-
const PuckDefault = ({ children }) => /* @__PURE__ */ (0,
|
|
8045
|
+
const [showTransition, setShowTransition] = (0, import_react50.useState)(false);
|
|
8046
|
+
const isResettingZoomRef = (0, import_react50.useRef)(false);
|
|
8047
|
+
const defaultRender = (0, import_react50.useMemo)(() => {
|
|
8048
|
+
const PuckDefault = ({ children }) => /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(import_jsx_runtime39.Fragment, { children });
|
|
7954
8049
|
return PuckDefault;
|
|
7955
8050
|
}, []);
|
|
7956
|
-
const CustomPreview = (0,
|
|
8051
|
+
const CustomPreview = (0, import_react50.useMemo)(
|
|
7957
8052
|
() => overrides.preview || defaultRender,
|
|
7958
8053
|
[overrides]
|
|
7959
8054
|
);
|
|
7960
|
-
const getFrameDimensions = (0,
|
|
8055
|
+
const getFrameDimensions = (0, import_react50.useCallback)(() => {
|
|
7961
8056
|
if (frameRef.current) {
|
|
7962
8057
|
const frame = frameRef.current;
|
|
7963
8058
|
const box = getBox(frame);
|
|
@@ -7965,55 +8060,60 @@ var Canvas = () => {
|
|
|
7965
8060
|
}
|
|
7966
8061
|
return { width: 0, height: 0 };
|
|
7967
8062
|
}, [frameRef]);
|
|
7968
|
-
|
|
7969
|
-
(
|
|
7970
|
-
|
|
7971
|
-
|
|
7972
|
-
|
|
7973
|
-
|
|
7974
|
-
|
|
7975
|
-
|
|
7976
|
-
|
|
7977
|
-
|
|
7978
|
-
|
|
7979
|
-
|
|
7980
|
-
|
|
7981
|
-
|
|
7982
|
-
|
|
7983
|
-
|
|
7984
|
-
|
|
7985
|
-
}, [frameRef, leftSideBarVisible, rightSideBarVisible]);
|
|
7986
|
-
(0, import_react48.useEffect)(() => {
|
|
8063
|
+
(0, import_react50.useEffect)(() => {
|
|
8064
|
+
resetAutoZoom({
|
|
8065
|
+
isResettingRef: isResettingZoomRef,
|
|
8066
|
+
setShowTransition,
|
|
8067
|
+
showTransition: false,
|
|
8068
|
+
viewports
|
|
8069
|
+
});
|
|
8070
|
+
}, [
|
|
8071
|
+
frameRef,
|
|
8072
|
+
leftSideBarVisible,
|
|
8073
|
+
rightSideBarVisible,
|
|
8074
|
+
leftSideBarWidth,
|
|
8075
|
+
rightSideBarWidth,
|
|
8076
|
+
resetAutoZoom,
|
|
8077
|
+
viewports
|
|
8078
|
+
]);
|
|
8079
|
+
(0, import_react50.useEffect)(() => {
|
|
7987
8080
|
const { height: frameHeight } = getFrameDimensions();
|
|
7988
8081
|
if (viewports.current.height === "auto") {
|
|
7989
8082
|
setZoomConfig(__spreadProps(__spreadValues({}, zoomConfig), {
|
|
7990
8083
|
rootHeight: frameHeight / zoomConfig.zoom
|
|
7991
8084
|
}));
|
|
7992
8085
|
}
|
|
7993
|
-
}, [zoomConfig.zoom]);
|
|
7994
|
-
(0,
|
|
8086
|
+
}, [zoomConfig.zoom, getFrameDimensions, setZoomConfig]);
|
|
8087
|
+
(0, import_react50.useEffect)(() => {
|
|
7995
8088
|
if (ZOOM_ON_CHANGE) {
|
|
7996
|
-
|
|
7997
|
-
|
|
8089
|
+
resetAutoZoom({
|
|
8090
|
+
isResettingRef: isResettingZoomRef,
|
|
8091
|
+
setShowTransition,
|
|
8092
|
+
showTransition: true,
|
|
8093
|
+
viewports
|
|
8094
|
+
});
|
|
7998
8095
|
}
|
|
7999
|
-
}, [viewports.current.width]);
|
|
8000
|
-
(0,
|
|
8096
|
+
}, [viewports.current.width, resetAutoZoom, viewports]);
|
|
8097
|
+
(0, import_react50.useEffect)(() => {
|
|
8001
8098
|
const cb = () => {
|
|
8002
|
-
|
|
8003
|
-
|
|
8099
|
+
resetAutoZoom({
|
|
8100
|
+
isResettingRef: isResettingZoomRef,
|
|
8101
|
+
setShowTransition,
|
|
8102
|
+
showTransition: false
|
|
8103
|
+
});
|
|
8004
8104
|
};
|
|
8005
8105
|
window.addEventListener("resize", cb);
|
|
8006
8106
|
return () => {
|
|
8007
8107
|
window.removeEventListener("resize", cb);
|
|
8008
8108
|
};
|
|
8009
|
-
}, []);
|
|
8010
|
-
const [showLoader, setShowLoader] = (0,
|
|
8011
|
-
(0,
|
|
8109
|
+
}, [resetAutoZoom]);
|
|
8110
|
+
const [showLoader, setShowLoader] = (0, import_react50.useState)(false);
|
|
8111
|
+
(0, import_react50.useEffect)(() => {
|
|
8012
8112
|
setTimeout(() => {
|
|
8013
8113
|
setShowLoader(true);
|
|
8014
8114
|
}, 500);
|
|
8015
8115
|
}, []);
|
|
8016
|
-
return /* @__PURE__ */ (0,
|
|
8116
|
+
return /* @__PURE__ */ (0, import_jsx_runtime39.jsxs)(
|
|
8017
8117
|
"div",
|
|
8018
8118
|
{
|
|
8019
8119
|
className: getClassName25({
|
|
@@ -8026,7 +8126,7 @@ var Canvas = () => {
|
|
|
8026
8126
|
recordHistory: true
|
|
8027
8127
|
}),
|
|
8028
8128
|
children: [
|
|
8029
|
-
viewports.controlsVisible && iframe.enabled && /* @__PURE__ */ (0,
|
|
8129
|
+
viewports.controlsVisible && iframe.enabled && /* @__PURE__ */ (0, import_jsx_runtime39.jsx)("div", { className: getClassName25("controls"), children: /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(
|
|
8030
8130
|
ViewportControls,
|
|
8031
8131
|
{
|
|
8032
8132
|
autoZoom: zoomConfig.autoZoom,
|
|
@@ -8043,7 +8143,12 @@ var Canvas = () => {
|
|
|
8043
8143
|
};
|
|
8044
8144
|
setUi(newUi);
|
|
8045
8145
|
if (ZOOM_ON_CHANGE) {
|
|
8046
|
-
resetAutoZoom(
|
|
8146
|
+
resetAutoZoom({
|
|
8147
|
+
isResettingRef: isResettingZoomRef,
|
|
8148
|
+
setShowTransition,
|
|
8149
|
+
showTransition: true,
|
|
8150
|
+
viewports: __spreadProps(__spreadValues({}, viewports), { current: uiViewport })
|
|
8151
|
+
});
|
|
8047
8152
|
}
|
|
8048
8153
|
},
|
|
8049
8154
|
onZoom: (zoom) => {
|
|
@@ -8052,8 +8157,8 @@ var Canvas = () => {
|
|
|
8052
8157
|
}
|
|
8053
8158
|
}
|
|
8054
8159
|
) }),
|
|
8055
|
-
/* @__PURE__ */ (0,
|
|
8056
|
-
/* @__PURE__ */ (0,
|
|
8160
|
+
/* @__PURE__ */ (0, import_jsx_runtime39.jsxs)("div", { className: getClassName25("inner"), ref: frameRef, children: [
|
|
8161
|
+
/* @__PURE__ */ (0, import_jsx_runtime39.jsx)(
|
|
8057
8162
|
"div",
|
|
8058
8163
|
{
|
|
8059
8164
|
className: getClassName25("root"),
|
|
@@ -8067,17 +8172,14 @@ var Canvas = () => {
|
|
|
8067
8172
|
suppressHydrationWarning: true,
|
|
8068
8173
|
id: "puck-canvas-root",
|
|
8069
8174
|
onTransitionEnd: () => {
|
|
8070
|
-
|
|
8071
|
-
|
|
8072
|
-
|
|
8073
|
-
cancelable: false
|
|
8074
|
-
})
|
|
8075
|
-
);
|
|
8175
|
+
resetAutoZoom({
|
|
8176
|
+
isResettingRef: isResettingZoomRef
|
|
8177
|
+
});
|
|
8076
8178
|
},
|
|
8077
|
-
children: /* @__PURE__ */ (0,
|
|
8179
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(CustomPreview, { children: /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(Preview2, {}) })
|
|
8078
8180
|
}
|
|
8079
8181
|
),
|
|
8080
|
-
/* @__PURE__ */ (0,
|
|
8182
|
+
/* @__PURE__ */ (0, import_jsx_runtime39.jsx)("div", { className: getClassName25("loader"), children: /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(Loader, { size: 24 }) })
|
|
8081
8183
|
] })
|
|
8082
8184
|
]
|
|
8083
8185
|
}
|
|
@@ -8086,7 +8188,7 @@ var Canvas = () => {
|
|
|
8086
8188
|
|
|
8087
8189
|
// lib/use-loaded-overrides.ts
|
|
8088
8190
|
init_react_import();
|
|
8089
|
-
var
|
|
8191
|
+
var import_react51 = require("react");
|
|
8090
8192
|
|
|
8091
8193
|
// lib/load-overrides.ts
|
|
8092
8194
|
init_react_import();
|
|
@@ -8125,26 +8227,26 @@ var useLoadedOverrides = ({
|
|
|
8125
8227
|
overrides,
|
|
8126
8228
|
plugins
|
|
8127
8229
|
}) => {
|
|
8128
|
-
return (0,
|
|
8230
|
+
return (0, import_react51.useMemo)(() => {
|
|
8129
8231
|
return loadOverrides({ overrides, plugins });
|
|
8130
8232
|
}, [plugins, overrides]);
|
|
8131
8233
|
};
|
|
8132
8234
|
|
|
8133
8235
|
// components/DefaultOverride/index.tsx
|
|
8134
8236
|
init_react_import();
|
|
8135
|
-
var
|
|
8136
|
-
var DefaultOverride = ({ children }) => /* @__PURE__ */ (0,
|
|
8237
|
+
var import_jsx_runtime40 = require("react/jsx-runtime");
|
|
8238
|
+
var DefaultOverride = ({ children }) => /* @__PURE__ */ (0, import_jsx_runtime40.jsx)(import_jsx_runtime40.Fragment, { children });
|
|
8137
8239
|
|
|
8138
8240
|
// lib/use-inject-css.ts
|
|
8139
8241
|
init_react_import();
|
|
8140
|
-
var
|
|
8242
|
+
var import_react52 = require("react");
|
|
8141
8243
|
var styles = ``;
|
|
8142
8244
|
var useInjectStyleSheet = (initialStyles, iframeEnabled) => {
|
|
8143
|
-
const [el, setEl] = (0,
|
|
8144
|
-
(0,
|
|
8245
|
+
const [el, setEl] = (0, import_react52.useState)();
|
|
8246
|
+
(0, import_react52.useEffect)(() => {
|
|
8145
8247
|
setEl(document.createElement("style"));
|
|
8146
8248
|
}, []);
|
|
8147
|
-
(0,
|
|
8249
|
+
(0, import_react52.useEffect)(() => {
|
|
8148
8250
|
var _a;
|
|
8149
8251
|
if (!el || typeof window === "undefined") {
|
|
8150
8252
|
return;
|
|
@@ -8164,10 +8266,10 @@ var useInjectGlobalCss = (iframeEnabled) => {
|
|
|
8164
8266
|
|
|
8165
8267
|
// lib/use-preview-mode-hotkeys.ts
|
|
8166
8268
|
init_react_import();
|
|
8167
|
-
var
|
|
8269
|
+
var import_react53 = require("react");
|
|
8168
8270
|
var usePreviewModeHotkeys = () => {
|
|
8169
8271
|
const appStore = useAppStoreApi();
|
|
8170
|
-
const toggleInteractive = (0,
|
|
8272
|
+
const toggleInteractive = (0, import_react53.useCallback)(() => {
|
|
8171
8273
|
const dispatch = appStore.getState().dispatch;
|
|
8172
8274
|
dispatch({
|
|
8173
8275
|
type: "setUi",
|
|
@@ -8182,7 +8284,7 @@ var usePreviewModeHotkeys = () => {
|
|
|
8182
8284
|
|
|
8183
8285
|
// lib/use-puck.ts
|
|
8184
8286
|
init_react_import();
|
|
8185
|
-
var
|
|
8287
|
+
var import_react54 = require("react");
|
|
8186
8288
|
var import_zustand6 = require("zustand");
|
|
8187
8289
|
var generateUsePuck = (store) => {
|
|
8188
8290
|
const history = {
|
|
@@ -8215,7 +8317,7 @@ var generateUsePuck = (store) => {
|
|
|
8215
8317
|
};
|
|
8216
8318
|
return storeData;
|
|
8217
8319
|
};
|
|
8218
|
-
var UsePuckStoreContext = (0,
|
|
8320
|
+
var UsePuckStoreContext = (0, import_react54.createContext)(
|
|
8219
8321
|
null
|
|
8220
8322
|
);
|
|
8221
8323
|
var convertToPickedStore = (store) => {
|
|
@@ -8229,12 +8331,12 @@ var convertToPickedStore = (store) => {
|
|
|
8229
8331
|
};
|
|
8230
8332
|
};
|
|
8231
8333
|
var useRegisterUsePuckStore = (appStore) => {
|
|
8232
|
-
const [usePuckStore] = (0,
|
|
8334
|
+
const [usePuckStore] = (0, import_react54.useState)(
|
|
8233
8335
|
() => (0, import_zustand6.createStore)(
|
|
8234
8336
|
() => generateUsePuck(convertToPickedStore(appStore.getState()))
|
|
8235
8337
|
)
|
|
8236
8338
|
);
|
|
8237
|
-
(0,
|
|
8339
|
+
(0, import_react54.useEffect)(() => {
|
|
8238
8340
|
return appStore.subscribe(
|
|
8239
8341
|
(store) => convertToPickedStore(store),
|
|
8240
8342
|
(pickedStore) => {
|
|
@@ -8246,7 +8348,7 @@ var useRegisterUsePuckStore = (appStore) => {
|
|
|
8246
8348
|
};
|
|
8247
8349
|
function createUsePuck() {
|
|
8248
8350
|
return function usePuck2(selector) {
|
|
8249
|
-
const usePuckApi = (0,
|
|
8351
|
+
const usePuckApi = (0, import_react54.useContext)(UsePuckStoreContext);
|
|
8250
8352
|
if (!usePuckApi) {
|
|
8251
8353
|
throw new Error("usePuck must be used inside <Puck>.");
|
|
8252
8354
|
}
|
|
@@ -8258,7 +8360,7 @@ function createUsePuck() {
|
|
|
8258
8360
|
};
|
|
8259
8361
|
}
|
|
8260
8362
|
function usePuck() {
|
|
8261
|
-
(0,
|
|
8363
|
+
(0, import_react54.useEffect)(() => {
|
|
8262
8364
|
console.warn(
|
|
8263
8365
|
"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."
|
|
8264
8366
|
);
|
|
@@ -8266,7 +8368,7 @@ function usePuck() {
|
|
|
8266
8368
|
return createUsePuck()((s) => s);
|
|
8267
8369
|
}
|
|
8268
8370
|
function useGetPuck() {
|
|
8269
|
-
const usePuckApi = (0,
|
|
8371
|
+
const usePuckApi = (0, import_react54.useContext)(UsePuckStoreContext);
|
|
8270
8372
|
if (!usePuckApi) {
|
|
8271
8373
|
throw new Error("usePuckGet must be used inside <Puck>.");
|
|
8272
8374
|
}
|
|
@@ -8278,7 +8380,7 @@ var import_fast_deep_equal3 = __toESM(require("fast-deep-equal"));
|
|
|
8278
8380
|
|
|
8279
8381
|
// components/Puck/components/Header/index.tsx
|
|
8280
8382
|
init_react_import();
|
|
8281
|
-
var
|
|
8383
|
+
var import_react55 = require("react");
|
|
8282
8384
|
|
|
8283
8385
|
// components/MenuBar/index.tsx
|
|
8284
8386
|
init_react_import();
|
|
@@ -8288,7 +8390,7 @@ init_react_import();
|
|
|
8288
8390
|
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" };
|
|
8289
8391
|
|
|
8290
8392
|
// components/MenuBar/index.tsx
|
|
8291
|
-
var
|
|
8393
|
+
var import_jsx_runtime41 = require("react/jsx-runtime");
|
|
8292
8394
|
var getClassName26 = get_class_name_factory_default("MenuBar", styles_module_default21);
|
|
8293
8395
|
function MenuBar({
|
|
8294
8396
|
menuOpen = false,
|
|
@@ -8299,7 +8401,7 @@ function MenuBar({
|
|
|
8299
8401
|
const forward = useAppStore((s) => s.history.forward);
|
|
8300
8402
|
const hasFuture = useAppStore((s) => s.history.hasFuture());
|
|
8301
8403
|
const hasPast = useAppStore((s) => s.history.hasPast());
|
|
8302
|
-
return /* @__PURE__ */ (0,
|
|
8404
|
+
return /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(
|
|
8303
8405
|
"div",
|
|
8304
8406
|
{
|
|
8305
8407
|
className: getClassName26({ menuOpen }),
|
|
@@ -8313,30 +8415,30 @@ function MenuBar({
|
|
|
8313
8415
|
setMenuOpen(false);
|
|
8314
8416
|
}
|
|
8315
8417
|
},
|
|
8316
|
-
children: /* @__PURE__ */ (0,
|
|
8317
|
-
/* @__PURE__ */ (0,
|
|
8318
|
-
/* @__PURE__ */ (0,
|
|
8418
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime41.jsxs)("div", { className: getClassName26("inner"), children: [
|
|
8419
|
+
/* @__PURE__ */ (0, import_jsx_runtime41.jsxs)("div", { className: getClassName26("history"), children: [
|
|
8420
|
+
/* @__PURE__ */ (0, import_jsx_runtime41.jsx)(
|
|
8319
8421
|
IconButton,
|
|
8320
8422
|
{
|
|
8321
8423
|
type: "button",
|
|
8322
8424
|
title: "undo",
|
|
8323
8425
|
disabled: !hasPast,
|
|
8324
8426
|
onClick: back,
|
|
8325
|
-
children: /* @__PURE__ */ (0,
|
|
8427
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(Undo2, { size: 21 })
|
|
8326
8428
|
}
|
|
8327
8429
|
),
|
|
8328
|
-
/* @__PURE__ */ (0,
|
|
8430
|
+
/* @__PURE__ */ (0, import_jsx_runtime41.jsx)(
|
|
8329
8431
|
IconButton,
|
|
8330
8432
|
{
|
|
8331
8433
|
type: "button",
|
|
8332
8434
|
title: "redo",
|
|
8333
8435
|
disabled: !hasFuture,
|
|
8334
8436
|
onClick: forward,
|
|
8335
|
-
children: /* @__PURE__ */ (0,
|
|
8437
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(Redo2, { size: 21 })
|
|
8336
8438
|
}
|
|
8337
8439
|
)
|
|
8338
8440
|
] }),
|
|
8339
|
-
/* @__PURE__ */ (0,
|
|
8441
|
+
/* @__PURE__ */ (0, import_jsx_runtime41.jsx)(import_jsx_runtime41.Fragment, { children: renderHeaderActions && renderHeaderActions() })
|
|
8340
8442
|
] })
|
|
8341
8443
|
}
|
|
8342
8444
|
);
|
|
@@ -8347,7 +8449,7 @@ init_react_import();
|
|
|
8347
8449
|
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" };
|
|
8348
8450
|
|
|
8349
8451
|
// components/Puck/components/Header/index.tsx
|
|
8350
|
-
var
|
|
8452
|
+
var import_jsx_runtime42 = require("react/jsx-runtime");
|
|
8351
8453
|
var getClassName27 = get_class_name_factory_default("PuckHeader", styles_module_default22);
|
|
8352
8454
|
var HeaderInner = () => {
|
|
8353
8455
|
const {
|
|
@@ -8360,7 +8462,7 @@ var HeaderInner = () => {
|
|
|
8360
8462
|
} = usePropsContext();
|
|
8361
8463
|
const dispatch = useAppStore((s) => s.dispatch);
|
|
8362
8464
|
const appStore = useAppStoreApi();
|
|
8363
|
-
const defaultHeaderRender = (0,
|
|
8465
|
+
const defaultHeaderRender = (0, import_react55.useMemo)(() => {
|
|
8364
8466
|
if (renderHeader) {
|
|
8365
8467
|
console.warn(
|
|
8366
8468
|
"`renderHeader` is deprecated. Please use `overrides.header` and the `usePuck` hook instead"
|
|
@@ -8369,13 +8471,13 @@ var HeaderInner = () => {
|
|
|
8369
8471
|
var _b = _a, { actions } = _b, props = __objRest(_b, ["actions"]);
|
|
8370
8472
|
const Comp = renderHeader;
|
|
8371
8473
|
const appState = useAppStore((s) => s.state);
|
|
8372
|
-
return /* @__PURE__ */ (0,
|
|
8474
|
+
return /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(Comp, __spreadProps(__spreadValues({}, props), { dispatch, state: appState, children: actions }));
|
|
8373
8475
|
};
|
|
8374
8476
|
return RenderHeader;
|
|
8375
8477
|
}
|
|
8376
8478
|
return DefaultOverride;
|
|
8377
8479
|
}, [renderHeader]);
|
|
8378
|
-
const defaultHeaderActionsRender = (0,
|
|
8480
|
+
const defaultHeaderActionsRender = (0, import_react55.useMemo)(() => {
|
|
8379
8481
|
if (renderHeaderActions) {
|
|
8380
8482
|
console.warn(
|
|
8381
8483
|
"`renderHeaderActions` is deprecated. Please use `overrides.headerActions` and the `usePuck` hook instead."
|
|
@@ -8383,7 +8485,7 @@ var HeaderInner = () => {
|
|
|
8383
8485
|
const RenderHeader = (props) => {
|
|
8384
8486
|
const Comp = renderHeaderActions;
|
|
8385
8487
|
const appState = useAppStore((s) => s.state);
|
|
8386
|
-
return /* @__PURE__ */ (0,
|
|
8488
|
+
return /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(Comp, __spreadProps(__spreadValues({}, props), { dispatch, state: appState }));
|
|
8387
8489
|
};
|
|
8388
8490
|
return RenderHeader;
|
|
8389
8491
|
}
|
|
@@ -8395,7 +8497,7 @@ var HeaderInner = () => {
|
|
|
8395
8497
|
const CustomHeaderActions = useAppStore(
|
|
8396
8498
|
(s) => s.overrides.headerActions || defaultHeaderActionsRender
|
|
8397
8499
|
);
|
|
8398
|
-
const [menuOpen, setMenuOpen] = (0,
|
|
8500
|
+
const [menuOpen, setMenuOpen] = (0, import_react55.useState)(false);
|
|
8399
8501
|
const rootTitle = useAppStore((s) => {
|
|
8400
8502
|
var _a, _b;
|
|
8401
8503
|
const rootData = (_a = s.state.indexes.nodes["root"]) == null ? void 0 : _a.data;
|
|
@@ -8405,7 +8507,7 @@ var HeaderInner = () => {
|
|
|
8405
8507
|
const rightSideBarVisible = useAppStore(
|
|
8406
8508
|
(s) => s.state.ui.rightSideBarVisible
|
|
8407
8509
|
);
|
|
8408
|
-
const toggleSidebars = (0,
|
|
8510
|
+
const toggleSidebars = (0, import_react55.useCallback)(
|
|
8409
8511
|
(sidebar) => {
|
|
8410
8512
|
const widerViewport = window.matchMedia("(min-width: 638px)").matches;
|
|
8411
8513
|
const sideBarVisible = sidebar === "left" ? leftSideBarVisible : rightSideBarVisible;
|
|
@@ -8419,27 +8521,27 @@ var HeaderInner = () => {
|
|
|
8419
8521
|
},
|
|
8420
8522
|
[dispatch, leftSideBarVisible, rightSideBarVisible]
|
|
8421
8523
|
);
|
|
8422
|
-
return /* @__PURE__ */ (0,
|
|
8524
|
+
return /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(
|
|
8423
8525
|
CustomHeader,
|
|
8424
8526
|
{
|
|
8425
|
-
actions: /* @__PURE__ */ (0,
|
|
8527
|
+
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)(
|
|
8426
8528
|
Button,
|
|
8427
8529
|
{
|
|
8428
8530
|
onClick: () => {
|
|
8429
8531
|
const data = appStore.getState().state.data;
|
|
8430
8532
|
onPublish && onPublish(data);
|
|
8431
8533
|
},
|
|
8432
|
-
icon: /* @__PURE__ */ (0,
|
|
8534
|
+
icon: /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(Globe, { size: "14px" }),
|
|
8433
8535
|
children: "Publish"
|
|
8434
8536
|
}
|
|
8435
8537
|
) }) }),
|
|
8436
|
-
children: /* @__PURE__ */ (0,
|
|
8538
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(
|
|
8437
8539
|
"header",
|
|
8438
8540
|
{
|
|
8439
8541
|
className: getClassName27({ leftSideBarVisible, rightSideBarVisible }),
|
|
8440
|
-
children: /* @__PURE__ */ (0,
|
|
8441
|
-
/* @__PURE__ */ (0,
|
|
8442
|
-
/* @__PURE__ */ (0,
|
|
8542
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime42.jsxs)("div", { className: getClassName27("inner"), children: [
|
|
8543
|
+
/* @__PURE__ */ (0, import_jsx_runtime42.jsxs)("div", { className: getClassName27("toggle"), children: [
|
|
8544
|
+
/* @__PURE__ */ (0, import_jsx_runtime42.jsx)("div", { className: getClassName27("leftSideBarToggle"), children: /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(
|
|
8443
8545
|
IconButton,
|
|
8444
8546
|
{
|
|
8445
8547
|
type: "button",
|
|
@@ -8447,10 +8549,10 @@ var HeaderInner = () => {
|
|
|
8447
8549
|
toggleSidebars("left");
|
|
8448
8550
|
},
|
|
8449
8551
|
title: "Toggle left sidebar",
|
|
8450
|
-
children: /* @__PURE__ */ (0,
|
|
8552
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(PanelLeft, { focusable: "false" })
|
|
8451
8553
|
}
|
|
8452
8554
|
) }),
|
|
8453
|
-
/* @__PURE__ */ (0,
|
|
8555
|
+
/* @__PURE__ */ (0, import_jsx_runtime42.jsx)("div", { className: getClassName27("rightSideBarToggle"), children: /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(
|
|
8454
8556
|
IconButton,
|
|
8455
8557
|
{
|
|
8456
8558
|
type: "button",
|
|
@@ -8458,19 +8560,19 @@ var HeaderInner = () => {
|
|
|
8458
8560
|
toggleSidebars("right");
|
|
8459
8561
|
},
|
|
8460
8562
|
title: "Toggle right sidebar",
|
|
8461
|
-
children: /* @__PURE__ */ (0,
|
|
8563
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(PanelRight, { focusable: "false" })
|
|
8462
8564
|
}
|
|
8463
8565
|
) })
|
|
8464
8566
|
] }),
|
|
8465
|
-
/* @__PURE__ */ (0,
|
|
8567
|
+
/* @__PURE__ */ (0, import_jsx_runtime42.jsx)("div", { className: getClassName27("title"), children: /* @__PURE__ */ (0, import_jsx_runtime42.jsxs)(Heading, { rank: "2", size: "xs", children: [
|
|
8466
8568
|
headerTitle || rootTitle || "Page",
|
|
8467
|
-
headerPath && /* @__PURE__ */ (0,
|
|
8569
|
+
headerPath && /* @__PURE__ */ (0, import_jsx_runtime42.jsxs)(import_jsx_runtime42.Fragment, { children: [
|
|
8468
8570
|
" ",
|
|
8469
|
-
/* @__PURE__ */ (0,
|
|
8571
|
+
/* @__PURE__ */ (0, import_jsx_runtime42.jsx)("code", { className: getClassName27("path"), children: headerPath })
|
|
8470
8572
|
] })
|
|
8471
8573
|
] }) }),
|
|
8472
|
-
/* @__PURE__ */ (0,
|
|
8473
|
-
/* @__PURE__ */ (0,
|
|
8574
|
+
/* @__PURE__ */ (0, import_jsx_runtime42.jsxs)("div", { className: getClassName27("tools"), children: [
|
|
8575
|
+
/* @__PURE__ */ (0, import_jsx_runtime42.jsx)("div", { className: getClassName27("menuButton"), children: /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(
|
|
8474
8576
|
IconButton,
|
|
8475
8577
|
{
|
|
8476
8578
|
type: "button",
|
|
@@ -8478,23 +8580,23 @@ var HeaderInner = () => {
|
|
|
8478
8580
|
return setMenuOpen(!menuOpen);
|
|
8479
8581
|
},
|
|
8480
8582
|
title: "Toggle menu bar",
|
|
8481
|
-
children: menuOpen ? /* @__PURE__ */ (0,
|
|
8583
|
+
children: menuOpen ? /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(ChevronUp, { focusable: "false" }) : /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(ChevronDown, { focusable: "false" })
|
|
8482
8584
|
}
|
|
8483
8585
|
) }),
|
|
8484
|
-
/* @__PURE__ */ (0,
|
|
8586
|
+
/* @__PURE__ */ (0, import_jsx_runtime42.jsx)(
|
|
8485
8587
|
MenuBar,
|
|
8486
8588
|
{
|
|
8487
8589
|
dispatch,
|
|
8488
8590
|
onPublish,
|
|
8489
8591
|
menuOpen,
|
|
8490
|
-
renderHeaderActions: () => /* @__PURE__ */ (0,
|
|
8592
|
+
renderHeaderActions: () => /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(CustomHeaderActions, { children: /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(
|
|
8491
8593
|
Button,
|
|
8492
8594
|
{
|
|
8493
8595
|
onClick: () => {
|
|
8494
8596
|
const data = appStore.getState().state.data;
|
|
8495
8597
|
onPublish && onPublish(data);
|
|
8496
8598
|
},
|
|
8497
|
-
icon: /* @__PURE__ */ (0,
|
|
8599
|
+
icon: /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(Globe, { size: "14px" }),
|
|
8498
8600
|
children: "Publish"
|
|
8499
8601
|
}
|
|
8500
8602
|
) }),
|
|
@@ -8508,11 +8610,203 @@ var HeaderInner = () => {
|
|
|
8508
8610
|
}
|
|
8509
8611
|
);
|
|
8510
8612
|
};
|
|
8511
|
-
var Header = (0,
|
|
8613
|
+
var Header = (0, import_react55.memo)(HeaderInner);
|
|
8614
|
+
|
|
8615
|
+
// components/Puck/components/Sidebar/index.tsx
|
|
8616
|
+
init_react_import();
|
|
8617
|
+
|
|
8618
|
+
// components/Puck/components/ResizeHandle/index.tsx
|
|
8619
|
+
init_react_import();
|
|
8620
|
+
var import_react56 = require("react");
|
|
8621
|
+
|
|
8622
|
+
// css-module:/home/runner/work/puck/puck/packages/core/components/Puck/components/ResizeHandle/styles.module.css#css-module
|
|
8623
|
+
init_react_import();
|
|
8624
|
+
var styles_module_default23 = { "ResizeHandle": "_ResizeHandle_v7w0r_1", "ResizeHandle--left": "_ResizeHandle--left_v7w0r_15", "ResizeHandle--right": "_ResizeHandle--right_v7w0r_19" };
|
|
8625
|
+
|
|
8626
|
+
// components/Puck/components/ResizeHandle/index.tsx
|
|
8627
|
+
var import_jsx_runtime43 = require("react/jsx-runtime");
|
|
8628
|
+
var getClassName28 = get_class_name_factory_default("ResizeHandle", styles_module_default23);
|
|
8629
|
+
var ResizeHandle = ({
|
|
8630
|
+
position,
|
|
8631
|
+
sidebarRef,
|
|
8632
|
+
onResize,
|
|
8633
|
+
onResizeEnd
|
|
8634
|
+
}) => {
|
|
8635
|
+
const { frameRef } = useCanvasFrame();
|
|
8636
|
+
const resetAutoZoom = useResetAutoZoom(frameRef);
|
|
8637
|
+
const handleRef = (0, import_react56.useRef)(null);
|
|
8638
|
+
const isDragging = (0, import_react56.useRef)(false);
|
|
8639
|
+
const startX = (0, import_react56.useRef)(0);
|
|
8640
|
+
const startWidth = (0, import_react56.useRef)(0);
|
|
8641
|
+
const handleMouseMove = (0, import_react56.useCallback)(
|
|
8642
|
+
(e) => {
|
|
8643
|
+
if (!isDragging.current) return;
|
|
8644
|
+
const delta = e.clientX - startX.current;
|
|
8645
|
+
const newWidth = position === "left" ? startWidth.current + delta : startWidth.current - delta;
|
|
8646
|
+
const width = Math.max(192, newWidth);
|
|
8647
|
+
onResize(width);
|
|
8648
|
+
e.preventDefault();
|
|
8649
|
+
},
|
|
8650
|
+
[onResize, position]
|
|
8651
|
+
);
|
|
8652
|
+
const handleMouseUp = (0, import_react56.useCallback)(() => {
|
|
8653
|
+
var _a;
|
|
8654
|
+
if (!isDragging.current) return;
|
|
8655
|
+
isDragging.current = false;
|
|
8656
|
+
document.body.style.cursor = "";
|
|
8657
|
+
document.body.style.userSelect = "";
|
|
8658
|
+
const overlay = document.getElementById("resize-overlay");
|
|
8659
|
+
if (overlay) {
|
|
8660
|
+
document.body.removeChild(overlay);
|
|
8661
|
+
}
|
|
8662
|
+
document.removeEventListener("mousemove", handleMouseMove);
|
|
8663
|
+
document.removeEventListener("mouseup", handleMouseUp);
|
|
8664
|
+
const finalWidth = ((_a = sidebarRef.current) == null ? void 0 : _a.getBoundingClientRect().width) || 0;
|
|
8665
|
+
onResizeEnd(finalWidth);
|
|
8666
|
+
resetAutoZoom();
|
|
8667
|
+
}, [onResizeEnd, resetAutoZoom]);
|
|
8668
|
+
const handleMouseDown = (0, import_react56.useCallback)(
|
|
8669
|
+
(e) => {
|
|
8670
|
+
var _a;
|
|
8671
|
+
isDragging.current = true;
|
|
8672
|
+
startX.current = e.clientX;
|
|
8673
|
+
startWidth.current = ((_a = sidebarRef.current) == null ? void 0 : _a.getBoundingClientRect().width) || 0;
|
|
8674
|
+
document.body.style.cursor = "col-resize";
|
|
8675
|
+
document.body.style.userSelect = "none";
|
|
8676
|
+
const overlay = document.createElement("div");
|
|
8677
|
+
overlay.id = "resize-overlay";
|
|
8678
|
+
overlay.setAttribute("data-resize-overlay", "");
|
|
8679
|
+
document.body.appendChild(overlay);
|
|
8680
|
+
document.addEventListener("mousemove", handleMouseMove);
|
|
8681
|
+
document.addEventListener("mouseup", handleMouseUp);
|
|
8682
|
+
e.preventDefault();
|
|
8683
|
+
},
|
|
8684
|
+
[position, handleMouseMove, handleMouseUp]
|
|
8685
|
+
);
|
|
8686
|
+
return /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(
|
|
8687
|
+
"div",
|
|
8688
|
+
{
|
|
8689
|
+
ref: handleRef,
|
|
8690
|
+
className: getClassName28({ [position]: true }),
|
|
8691
|
+
onMouseDown: handleMouseDown
|
|
8692
|
+
}
|
|
8693
|
+
);
|
|
8694
|
+
};
|
|
8695
|
+
|
|
8696
|
+
// css-module:/home/runner/work/puck/puck/packages/core/components/Puck/components/Sidebar/styles.module.css#css-module
|
|
8697
|
+
init_react_import();
|
|
8698
|
+
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" };
|
|
8699
|
+
|
|
8700
|
+
// components/Puck/components/Sidebar/index.tsx
|
|
8701
|
+
var import_jsx_runtime44 = require("react/jsx-runtime");
|
|
8702
|
+
var getClassName29 = get_class_name_factory_default("Sidebar", styles_module_default24);
|
|
8703
|
+
var Sidebar = ({
|
|
8704
|
+
position,
|
|
8705
|
+
sidebarRef,
|
|
8706
|
+
isVisible,
|
|
8707
|
+
width,
|
|
8708
|
+
onResize,
|
|
8709
|
+
onResizeEnd,
|
|
8710
|
+
children
|
|
8711
|
+
}) => {
|
|
8712
|
+
if (!isVisible) return null;
|
|
8713
|
+
return /* @__PURE__ */ (0, import_jsx_runtime44.jsxs)(import_jsx_runtime44.Fragment, { children: [
|
|
8714
|
+
/* @__PURE__ */ (0, import_jsx_runtime44.jsx)("div", { ref: sidebarRef, className: getClassName29({ [position]: true }), children }),
|
|
8715
|
+
/* @__PURE__ */ (0, import_jsx_runtime44.jsx)("div", { className: `${getClassName29("resizeHandle")}`, children: /* @__PURE__ */ (0, import_jsx_runtime44.jsx)(
|
|
8716
|
+
ResizeHandle,
|
|
8717
|
+
{
|
|
8718
|
+
position,
|
|
8719
|
+
sidebarRef,
|
|
8720
|
+
onResize,
|
|
8721
|
+
onResizeEnd
|
|
8722
|
+
}
|
|
8723
|
+
) })
|
|
8724
|
+
] });
|
|
8725
|
+
};
|
|
8726
|
+
|
|
8727
|
+
// lib/use-sidebar-resize.ts
|
|
8728
|
+
init_react_import();
|
|
8729
|
+
var import_react57 = require("react");
|
|
8730
|
+
function useSidebarResize(position, dispatch) {
|
|
8731
|
+
const [width, setWidth] = (0, import_react57.useState)(null);
|
|
8732
|
+
const sidebarRef = (0, import_react57.useRef)(null);
|
|
8733
|
+
const storeWidth = useAppStore(
|
|
8734
|
+
(s) => position === "left" ? s.state.ui.leftSideBarWidth : s.state.ui.rightSideBarWidth
|
|
8735
|
+
);
|
|
8736
|
+
(0, import_react57.useEffect)(() => {
|
|
8737
|
+
if (typeof window !== "undefined" && !storeWidth) {
|
|
8738
|
+
try {
|
|
8739
|
+
const savedWidths = localStorage.getItem("puck-sidebar-widths");
|
|
8740
|
+
if (savedWidths) {
|
|
8741
|
+
const widths = JSON.parse(savedWidths);
|
|
8742
|
+
const savedWidth = widths[position];
|
|
8743
|
+
if (savedWidth) {
|
|
8744
|
+
dispatch({
|
|
8745
|
+
type: "setUi",
|
|
8746
|
+
ui: {
|
|
8747
|
+
[position === "left" ? "leftSideBarWidth" : "rightSideBarWidth"]: savedWidth
|
|
8748
|
+
}
|
|
8749
|
+
});
|
|
8750
|
+
}
|
|
8751
|
+
}
|
|
8752
|
+
} catch (error) {
|
|
8753
|
+
console.error(
|
|
8754
|
+
`Failed to load ${position} sidebar width from localStorage`,
|
|
8755
|
+
error
|
|
8756
|
+
);
|
|
8757
|
+
}
|
|
8758
|
+
}
|
|
8759
|
+
}, [dispatch, position, storeWidth]);
|
|
8760
|
+
(0, import_react57.useEffect)(() => {
|
|
8761
|
+
if (storeWidth !== void 0) {
|
|
8762
|
+
setWidth(storeWidth);
|
|
8763
|
+
}
|
|
8764
|
+
}, [storeWidth]);
|
|
8765
|
+
const handleResizeEnd = (0, import_react57.useCallback)(
|
|
8766
|
+
(width2) => {
|
|
8767
|
+
dispatch({
|
|
8768
|
+
type: "setUi",
|
|
8769
|
+
ui: {
|
|
8770
|
+
[position === "left" ? "leftSideBarWidth" : "rightSideBarWidth"]: width2
|
|
8771
|
+
}
|
|
8772
|
+
});
|
|
8773
|
+
let widths = {};
|
|
8774
|
+
try {
|
|
8775
|
+
const savedWidths = localStorage.getItem("puck-sidebar-widths");
|
|
8776
|
+
widths = savedWidths ? JSON.parse(savedWidths) : {};
|
|
8777
|
+
} catch (error) {
|
|
8778
|
+
console.error(
|
|
8779
|
+
`Failed to save ${position} sidebar width to localStorage`,
|
|
8780
|
+
error
|
|
8781
|
+
);
|
|
8782
|
+
} finally {
|
|
8783
|
+
localStorage.setItem(
|
|
8784
|
+
"puck-sidebar-widths",
|
|
8785
|
+
JSON.stringify(__spreadProps(__spreadValues({}, widths), {
|
|
8786
|
+
[position]: width2
|
|
8787
|
+
}))
|
|
8788
|
+
);
|
|
8789
|
+
}
|
|
8790
|
+
window.dispatchEvent(
|
|
8791
|
+
new CustomEvent("viewportchange", {
|
|
8792
|
+
bubbles: true,
|
|
8793
|
+
cancelable: false
|
|
8794
|
+
})
|
|
8795
|
+
);
|
|
8796
|
+
},
|
|
8797
|
+
[dispatch, position]
|
|
8798
|
+
);
|
|
8799
|
+
return {
|
|
8800
|
+
width,
|
|
8801
|
+
setWidth,
|
|
8802
|
+
sidebarRef,
|
|
8803
|
+
handleResizeEnd
|
|
8804
|
+
};
|
|
8805
|
+
}
|
|
8512
8806
|
|
|
8513
8807
|
// components/Puck/index.tsx
|
|
8514
|
-
var
|
|
8515
|
-
var
|
|
8808
|
+
var import_jsx_runtime45 = require("react/jsx-runtime");
|
|
8809
|
+
var getClassName30 = get_class_name_factory_default("Puck", styles_module_default14);
|
|
8516
8810
|
var getLayoutClassName = get_class_name_factory_default("PuckLayout", styles_module_default14);
|
|
8517
8811
|
var FieldSideBar = () => {
|
|
8518
8812
|
const title = useAppStore(
|
|
@@ -8521,13 +8815,13 @@ var FieldSideBar = () => {
|
|
|
8521
8815
|
return s.selectedItem ? (_b = (_a = s.config.components[s.selectedItem.type]) == null ? void 0 : _a["label"]) != null ? _b : s.selectedItem.type.toString() : "Page";
|
|
8522
8816
|
}
|
|
8523
8817
|
);
|
|
8524
|
-
return /* @__PURE__ */ (0,
|
|
8818
|
+
return /* @__PURE__ */ (0, import_jsx_runtime45.jsx)(SidebarSection, { noPadding: true, noBorderTop: true, showBreadcrumbs: true, title, children: /* @__PURE__ */ (0, import_jsx_runtime45.jsx)(Fields, {}) });
|
|
8525
8819
|
};
|
|
8526
|
-
var propsContext = (0,
|
|
8820
|
+
var propsContext = (0, import_react58.createContext)({});
|
|
8527
8821
|
function PropsProvider(props) {
|
|
8528
|
-
return /* @__PURE__ */ (0,
|
|
8822
|
+
return /* @__PURE__ */ (0, import_jsx_runtime45.jsx)(propsContext.Provider, { value: props, children: props.children });
|
|
8529
8823
|
}
|
|
8530
|
-
var usePropsContext = () => (0,
|
|
8824
|
+
var usePropsContext = () => (0, import_react58.useContext)(propsContext);
|
|
8531
8825
|
function PuckProvider({ children }) {
|
|
8532
8826
|
const {
|
|
8533
8827
|
config,
|
|
@@ -8543,14 +8837,14 @@ function PuckProvider({ children }) {
|
|
|
8543
8837
|
metadata,
|
|
8544
8838
|
onAction
|
|
8545
8839
|
} = usePropsContext();
|
|
8546
|
-
const iframe = (0,
|
|
8840
|
+
const iframe = (0, import_react58.useMemo)(
|
|
8547
8841
|
() => __spreadValues({
|
|
8548
8842
|
enabled: true,
|
|
8549
8843
|
waitForStyles: true
|
|
8550
8844
|
}, _iframe),
|
|
8551
8845
|
[_iframe]
|
|
8552
8846
|
);
|
|
8553
|
-
const [generatedAppState] = (0,
|
|
8847
|
+
const [generatedAppState] = (0, import_react58.useState)(() => {
|
|
8554
8848
|
var _a, _b, _c, _d, _e, _f, _g, _h, _i;
|
|
8555
8849
|
const initial = __spreadValues(__spreadValues({}, defaultAppState.ui), initialUi);
|
|
8556
8850
|
let clientUiState = {};
|
|
@@ -8610,7 +8904,7 @@ function PuckProvider({ children }) {
|
|
|
8610
8904
|
return walkAppState(newAppState, config);
|
|
8611
8905
|
});
|
|
8612
8906
|
const { appendData = true } = _initialHistory || {};
|
|
8613
|
-
const [blendedHistories] = (0,
|
|
8907
|
+
const [blendedHistories] = (0, import_react58.useState)(
|
|
8614
8908
|
[
|
|
8615
8909
|
...(_initialHistory == null ? void 0 : _initialHistory.histories) || [],
|
|
8616
8910
|
...appendData ? [{ state: generatedAppState }] : []
|
|
@@ -8630,7 +8924,7 @@ function PuckProvider({ children }) {
|
|
|
8630
8924
|
overrides,
|
|
8631
8925
|
plugins
|
|
8632
8926
|
});
|
|
8633
|
-
const generateAppStore = (0,
|
|
8927
|
+
const generateAppStore = (0, import_react58.useCallback)(
|
|
8634
8928
|
(state) => {
|
|
8635
8929
|
return {
|
|
8636
8930
|
state,
|
|
@@ -8654,15 +8948,15 @@ function PuckProvider({ children }) {
|
|
|
8654
8948
|
metadata
|
|
8655
8949
|
]
|
|
8656
8950
|
);
|
|
8657
|
-
const [appStore] = (0,
|
|
8951
|
+
const [appStore] = (0, import_react58.useState)(
|
|
8658
8952
|
() => createAppStore(generateAppStore(initialAppState))
|
|
8659
8953
|
);
|
|
8660
|
-
(0,
|
|
8954
|
+
(0, import_react58.useEffect)(() => {
|
|
8661
8955
|
if (process.env.NODE_ENV !== "production") {
|
|
8662
8956
|
window.__PUCK_INTERNAL_DO_NOT_USE = { appStore };
|
|
8663
8957
|
}
|
|
8664
8958
|
}, [appStore]);
|
|
8665
|
-
(0,
|
|
8959
|
+
(0, import_react58.useEffect)(() => {
|
|
8666
8960
|
const state = appStore.getState().state;
|
|
8667
8961
|
appStore.setState(__spreadValues({}, generateAppStore(state)));
|
|
8668
8962
|
}, [config, plugins, loadedOverrides, viewports, iframe, onAction, metadata]);
|
|
@@ -8671,8 +8965,8 @@ function PuckProvider({ children }) {
|
|
|
8671
8965
|
index: initialHistoryIndex,
|
|
8672
8966
|
initialAppState
|
|
8673
8967
|
});
|
|
8674
|
-
const previousData = (0,
|
|
8675
|
-
(0,
|
|
8968
|
+
const previousData = (0, import_react58.useRef)(null);
|
|
8969
|
+
(0, import_react58.useEffect)(() => {
|
|
8676
8970
|
appStore.subscribe(
|
|
8677
8971
|
(s) => s.state.data,
|
|
8678
8972
|
(data) => {
|
|
@@ -8686,11 +8980,11 @@ function PuckProvider({ children }) {
|
|
|
8686
8980
|
}, []);
|
|
8687
8981
|
useRegisterPermissionsSlice(appStore, permissions);
|
|
8688
8982
|
const uPuckStore = useRegisterUsePuckStore(appStore);
|
|
8689
|
-
(0,
|
|
8983
|
+
(0, import_react58.useEffect)(() => {
|
|
8690
8984
|
const { resolveAndCommitData } = appStore.getState();
|
|
8691
8985
|
resolveAndCommitData();
|
|
8692
8986
|
}, []);
|
|
8693
|
-
return /* @__PURE__ */ (0,
|
|
8987
|
+
return /* @__PURE__ */ (0, import_jsx_runtime45.jsx)(appStoreContext.Provider, { value: appStore, children: /* @__PURE__ */ (0, import_jsx_runtime45.jsx)(UsePuckStoreContext.Provider, { value: uPuckStore, children }) });
|
|
8694
8988
|
}
|
|
8695
8989
|
function PuckLayout({ children }) {
|
|
8696
8990
|
const {
|
|
@@ -8698,7 +8992,7 @@ function PuckLayout({ children }) {
|
|
|
8698
8992
|
dnd,
|
|
8699
8993
|
initialHistory: _initialHistory
|
|
8700
8994
|
} = usePropsContext();
|
|
8701
|
-
const iframe = (0,
|
|
8995
|
+
const iframe = (0, import_react58.useMemo)(
|
|
8702
8996
|
() => __spreadValues({
|
|
8703
8997
|
enabled: true,
|
|
8704
8998
|
waitForStyles: true
|
|
@@ -8706,12 +9000,24 @@ function PuckLayout({ children }) {
|
|
|
8706
9000
|
[_iframe]
|
|
8707
9001
|
);
|
|
8708
9002
|
useInjectGlobalCss(iframe.enabled);
|
|
9003
|
+
const dispatch = useAppStore((s) => s.dispatch);
|
|
8709
9004
|
const leftSideBarVisible = useAppStore((s) => s.state.ui.leftSideBarVisible);
|
|
8710
9005
|
const rightSideBarVisible = useAppStore(
|
|
8711
9006
|
(s) => s.state.ui.rightSideBarVisible
|
|
8712
9007
|
);
|
|
8713
|
-
const
|
|
8714
|
-
|
|
9008
|
+
const {
|
|
9009
|
+
width: leftWidth,
|
|
9010
|
+
setWidth: setLeftWidth,
|
|
9011
|
+
sidebarRef: leftSidebarRef,
|
|
9012
|
+
handleResizeEnd: handleLeftSidebarResizeEnd
|
|
9013
|
+
} = useSidebarResize("left", dispatch);
|
|
9014
|
+
const {
|
|
9015
|
+
width: rightWidth,
|
|
9016
|
+
setWidth: setRightWidth,
|
|
9017
|
+
sidebarRef: rightSidebarRef,
|
|
9018
|
+
handleResizeEnd: handleRightSidebarResizeEnd
|
|
9019
|
+
} = useSidebarResize("right", dispatch);
|
|
9020
|
+
(0, import_react58.useEffect)(() => {
|
|
8715
9021
|
if (!window.matchMedia("(min-width: 638px)").matches) {
|
|
8716
9022
|
dispatch({
|
|
8717
9023
|
type: "setUi",
|
|
@@ -8735,17 +9041,17 @@ function PuckLayout({ children }) {
|
|
|
8735
9041
|
};
|
|
8736
9042
|
}, []);
|
|
8737
9043
|
const overrides = useAppStore((s) => s.overrides);
|
|
8738
|
-
const CustomPuck = (0,
|
|
9044
|
+
const CustomPuck = (0, import_react58.useMemo)(
|
|
8739
9045
|
() => overrides.puck || DefaultOverride,
|
|
8740
9046
|
[overrides]
|
|
8741
9047
|
);
|
|
8742
|
-
const [mounted, setMounted] = (0,
|
|
8743
|
-
(0,
|
|
9048
|
+
const [mounted, setMounted] = (0, import_react58.useState)(false);
|
|
9049
|
+
(0, import_react58.useEffect)(() => {
|
|
8744
9050
|
setMounted(true);
|
|
8745
9051
|
}, []);
|
|
8746
9052
|
const ready = useAppStore((s) => s.status === "READY");
|
|
8747
9053
|
useMonitorHotkeys();
|
|
8748
|
-
(0,
|
|
9054
|
+
(0, import_react58.useEffect)(() => {
|
|
8749
9055
|
if (ready && iframe.enabled) {
|
|
8750
9056
|
const frameDoc = getFrame();
|
|
8751
9057
|
if (frameDoc) {
|
|
@@ -8754,8 +9060,8 @@ function PuckLayout({ children }) {
|
|
|
8754
9060
|
}
|
|
8755
9061
|
}, [ready, iframe.enabled]);
|
|
8756
9062
|
usePreviewModeHotkeys();
|
|
8757
|
-
return /* @__PURE__ */ (0,
|
|
8758
|
-
/* @__PURE__ */ (0,
|
|
9063
|
+
return /* @__PURE__ */ (0, import_jsx_runtime45.jsxs)("div", { className: `Puck ${getClassName30()}`, children: [
|
|
9064
|
+
/* @__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)(
|
|
8759
9065
|
"div",
|
|
8760
9066
|
{
|
|
8761
9067
|
className: getLayoutClassName({
|
|
@@ -8763,22 +9069,57 @@ function PuckLayout({ children }) {
|
|
|
8763
9069
|
mounted,
|
|
8764
9070
|
rightSideBarVisible
|
|
8765
9071
|
}),
|
|
8766
|
-
children: /* @__PURE__ */ (0,
|
|
8767
|
-
|
|
8768
|
-
|
|
8769
|
-
|
|
8770
|
-
|
|
8771
|
-
|
|
8772
|
-
|
|
8773
|
-
|
|
8774
|
-
|
|
9072
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime45.jsxs)(
|
|
9073
|
+
"div",
|
|
9074
|
+
{
|
|
9075
|
+
className: getLayoutClassName("inner"),
|
|
9076
|
+
style: {
|
|
9077
|
+
gridTemplateColumns: `
|
|
9078
|
+
${leftSideBarVisible ? leftWidth ? `${leftWidth}px` : "var(--puck-side-bar-width)" : "0"}
|
|
9079
|
+
var(--puck-frame-width)
|
|
9080
|
+
${rightSideBarVisible ? rightWidth ? `${rightWidth}px` : "var(--puck-side-bar-width)" : "0"}
|
|
9081
|
+
`
|
|
9082
|
+
},
|
|
9083
|
+
children: [
|
|
9084
|
+
/* @__PURE__ */ (0, import_jsx_runtime45.jsx)(Header, {}),
|
|
9085
|
+
/* @__PURE__ */ (0, import_jsx_runtime45.jsxs)(
|
|
9086
|
+
Sidebar,
|
|
9087
|
+
{
|
|
9088
|
+
position: "left",
|
|
9089
|
+
sidebarRef: leftSidebarRef,
|
|
9090
|
+
isVisible: leftSideBarVisible,
|
|
9091
|
+
width: leftWidth,
|
|
9092
|
+
onResize: setLeftWidth,
|
|
9093
|
+
onResizeEnd: handleLeftSidebarResizeEnd,
|
|
9094
|
+
children: [
|
|
9095
|
+
/* @__PURE__ */ (0, import_jsx_runtime45.jsx)(SidebarSection, { title: "Components", noBorderTop: true, children: /* @__PURE__ */ (0, import_jsx_runtime45.jsx)(Components, {}) }),
|
|
9096
|
+
/* @__PURE__ */ (0, import_jsx_runtime45.jsx)(SidebarSection, { title: "Outline", children: /* @__PURE__ */ (0, import_jsx_runtime45.jsx)(Outline, {}) })
|
|
9097
|
+
]
|
|
9098
|
+
}
|
|
9099
|
+
),
|
|
9100
|
+
/* @__PURE__ */ (0, import_jsx_runtime45.jsx)(Canvas, {}),
|
|
9101
|
+
/* @__PURE__ */ (0, import_jsx_runtime45.jsx)(
|
|
9102
|
+
Sidebar,
|
|
9103
|
+
{
|
|
9104
|
+
position: "right",
|
|
9105
|
+
sidebarRef: rightSidebarRef,
|
|
9106
|
+
isVisible: rightSideBarVisible,
|
|
9107
|
+
width: rightWidth,
|
|
9108
|
+
onResize: setRightWidth,
|
|
9109
|
+
onResizeEnd: handleRightSidebarResizeEnd,
|
|
9110
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime45.jsx)(FieldSideBar, {})
|
|
9111
|
+
}
|
|
9112
|
+
)
|
|
9113
|
+
]
|
|
9114
|
+
}
|
|
9115
|
+
)
|
|
8775
9116
|
}
|
|
8776
|
-
) }) }),
|
|
8777
|
-
/* @__PURE__ */ (0,
|
|
9117
|
+
) }) }) }),
|
|
9118
|
+
/* @__PURE__ */ (0, import_jsx_runtime45.jsx)("div", { id: "puck-portal-root", className: getClassName30("portal") })
|
|
8778
9119
|
] });
|
|
8779
9120
|
}
|
|
8780
9121
|
function Puck(props) {
|
|
8781
|
-
return /* @__PURE__ */ (0,
|
|
9122
|
+
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)) })) }));
|
|
8782
9123
|
}
|
|
8783
9124
|
Puck.Components = Components;
|
|
8784
9125
|
Puck.Fields = Fields;
|