@measured/puck 0.20.0-canary.d405985b → 0.20.0-canary.def0ecb5
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-DBSNJT3R.mjs → chunk-VATSTM62.mjs} +2506 -2158
- package/dist/index.css +93 -46
- package/dist/index.d.mts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +1210 -867
- package/dist/index.mjs +1 -1
- package/dist/no-external.css +93 -46
- package/dist/no-external.d.mts +1 -1
- package/dist/no-external.d.ts +1 -1
- package/dist/no-external.js +1210 -867
- 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-Bp8tnkJS.d.mts → walk-tree-mCPqBAls.d.mts} +16 -2
- package/dist/{walk-tree-Bp8tnkJS.d.ts → walk-tree-mCPqBAls.d.ts} +16 -2
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -203,8 +203,9 @@ var overrideKeys = [
|
|
|
203
203
|
"headerActions",
|
|
204
204
|
"fields",
|
|
205
205
|
"fieldLabel",
|
|
206
|
-
"
|
|
207
|
-
"
|
|
206
|
+
"drawer",
|
|
207
|
+
"drawerItem",
|
|
208
|
+
"componentOverlay",
|
|
208
209
|
"outline",
|
|
209
210
|
"puck",
|
|
210
211
|
"preview"
|
|
@@ -309,7 +310,7 @@ init_react_import();
|
|
|
309
310
|
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
311
|
|
|
311
312
|
// components/AutoField/index.tsx
|
|
312
|
-
var
|
|
313
|
+
var import_react21 = require("react");
|
|
313
314
|
|
|
314
315
|
// components/AutoField/fields/index.tsx
|
|
315
316
|
init_react_import();
|
|
@@ -653,7 +654,7 @@ init_react_import();
|
|
|
653
654
|
|
|
654
655
|
// components/IconButton/IconButton.tsx
|
|
655
656
|
init_react_import();
|
|
656
|
-
var
|
|
657
|
+
var import_react10 = require("react");
|
|
657
658
|
|
|
658
659
|
// css-module:/home/runner/work/puck/puck/packages/core/components/IconButton/IconButton.module.css#css-module
|
|
659
660
|
init_react_import();
|
|
@@ -686,102 +687,9 @@ var replace = (list, index, newItem) => {
|
|
|
686
687
|
return result;
|
|
687
688
|
};
|
|
688
689
|
|
|
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
|
|
690
|
+
// lib/use-reset-auto-zoom.ts
|
|
778
691
|
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" }) }) });
|
|
692
|
+
var import_react9 = require("react");
|
|
785
693
|
|
|
786
694
|
// store/index.ts
|
|
787
695
|
init_react_import();
|
|
@@ -1684,15 +1592,15 @@ var defaultViewports = [
|
|
|
1684
1592
|
// store/index.ts
|
|
1685
1593
|
var import_zustand2 = require("zustand");
|
|
1686
1594
|
var import_middleware2 = require("zustand/middleware");
|
|
1687
|
-
var
|
|
1595
|
+
var import_react8 = require("react");
|
|
1688
1596
|
|
|
1689
1597
|
// store/slices/history.ts
|
|
1690
1598
|
init_react_import();
|
|
1691
|
-
var
|
|
1599
|
+
var import_react5 = require("react");
|
|
1692
1600
|
|
|
1693
1601
|
// lib/use-hotkey.ts
|
|
1694
1602
|
init_react_import();
|
|
1695
|
-
var
|
|
1603
|
+
var import_react4 = require("react");
|
|
1696
1604
|
var import_zustand = require("zustand");
|
|
1697
1605
|
var import_middleware = require("zustand/middleware");
|
|
1698
1606
|
var keyCodeMap = {
|
|
@@ -1785,10 +1693,10 @@ var monitorHotkeys = (doc) => {
|
|
|
1785
1693
|
};
|
|
1786
1694
|
};
|
|
1787
1695
|
var useMonitorHotkeys = () => {
|
|
1788
|
-
(0,
|
|
1696
|
+
(0, import_react4.useEffect)(() => monitorHotkeys(document), []);
|
|
1789
1697
|
};
|
|
1790
1698
|
var useHotkey = (combo, cb) => {
|
|
1791
|
-
(0,
|
|
1699
|
+
(0, import_react4.useEffect)(
|
|
1792
1700
|
() => useHotkeyStore.setState((s) => ({
|
|
1793
1701
|
triggers: __spreadProps(__spreadValues({}, s.triggers), {
|
|
1794
1702
|
[`${Object.keys(combo).join("+")}`]: { combo, cb }
|
|
@@ -1897,7 +1805,7 @@ function useRegisterHistorySlice(appStore, {
|
|
|
1897
1805
|
index,
|
|
1898
1806
|
initialAppState
|
|
1899
1807
|
}) {
|
|
1900
|
-
(0,
|
|
1808
|
+
(0, import_react5.useEffect)(
|
|
1901
1809
|
() => appStore.setState({
|
|
1902
1810
|
history: __spreadProps(__spreadValues({}, appStore.getState().history), {
|
|
1903
1811
|
histories,
|
|
@@ -1964,7 +1872,7 @@ var createNodesSlice = (set, get) => ({
|
|
|
1964
1872
|
|
|
1965
1873
|
// store/slices/permissions.ts
|
|
1966
1874
|
init_react_import();
|
|
1967
|
-
var
|
|
1875
|
+
var import_react6 = require("react");
|
|
1968
1876
|
|
|
1969
1877
|
// lib/data/flatten-data.ts
|
|
1970
1878
|
init_react_import();
|
|
@@ -2101,7 +2009,7 @@ var createPermissionsSlice = (set, get) => {
|
|
|
2101
2009
|
};
|
|
2102
2010
|
};
|
|
2103
2011
|
var useRegisterPermissionsSlice = (appStore, globalPermissions) => {
|
|
2104
|
-
(0,
|
|
2012
|
+
(0, import_react6.useEffect)(() => {
|
|
2105
2013
|
const { permissions } = appStore.getState();
|
|
2106
2014
|
const { globalPermissions: existingGlobalPermissions } = permissions;
|
|
2107
2015
|
appStore.setState({
|
|
@@ -2111,7 +2019,7 @@ var useRegisterPermissionsSlice = (appStore, globalPermissions) => {
|
|
|
2111
2019
|
});
|
|
2112
2020
|
permissions.resolvePermissions();
|
|
2113
2021
|
}, [globalPermissions]);
|
|
2114
|
-
(0,
|
|
2022
|
+
(0, import_react6.useEffect)(() => {
|
|
2115
2023
|
return appStore.subscribe(
|
|
2116
2024
|
(s) => s.state.data,
|
|
2117
2025
|
() => {
|
|
@@ -2119,7 +2027,7 @@ var useRegisterPermissionsSlice = (appStore, globalPermissions) => {
|
|
|
2119
2027
|
}
|
|
2120
2028
|
);
|
|
2121
2029
|
}, []);
|
|
2122
|
-
(0,
|
|
2030
|
+
(0, import_react6.useEffect)(() => {
|
|
2123
2031
|
return appStore.subscribe(
|
|
2124
2032
|
(s) => s.config,
|
|
2125
2033
|
() => {
|
|
@@ -2131,7 +2039,7 @@ var useRegisterPermissionsSlice = (appStore, globalPermissions) => {
|
|
|
2131
2039
|
|
|
2132
2040
|
// store/slices/fields.ts
|
|
2133
2041
|
init_react_import();
|
|
2134
|
-
var
|
|
2042
|
+
var import_react7 = require("react");
|
|
2135
2043
|
var createFieldsSlice = (_set, _get) => {
|
|
2136
2044
|
return {
|
|
2137
2045
|
fields: {},
|
|
@@ -2141,7 +2049,7 @@ var createFieldsSlice = (_set, _get) => {
|
|
|
2141
2049
|
};
|
|
2142
2050
|
};
|
|
2143
2051
|
var useRegisterFieldsSlice = (appStore, id) => {
|
|
2144
|
-
const resolveFields = (0,
|
|
2052
|
+
const resolveFields = (0, import_react7.useCallback)(
|
|
2145
2053
|
(reset) => __async(void 0, null, function* () {
|
|
2146
2054
|
var _a, _b;
|
|
2147
2055
|
const { fields, lastResolvedData } = appStore.getState().fields;
|
|
@@ -2198,7 +2106,7 @@ var useRegisterFieldsSlice = (appStore, id) => {
|
|
|
2198
2106
|
}),
|
|
2199
2107
|
[id]
|
|
2200
2108
|
);
|
|
2201
|
-
(0,
|
|
2109
|
+
(0, import_react7.useEffect)(() => {
|
|
2202
2110
|
resolveFields(true);
|
|
2203
2111
|
return appStore.subscribe(
|
|
2204
2112
|
(s) => s.state.indexes.nodes[id || "root"],
|
|
@@ -2490,133 +2398,435 @@ var createAppStore = (initialAppStore) => (0, import_zustand2.create)()(
|
|
|
2490
2398
|
});
|
|
2491
2399
|
})
|
|
2492
2400
|
);
|
|
2493
|
-
var appStoreContext = (0,
|
|
2401
|
+
var appStoreContext = (0, import_react8.createContext)(createAppStore());
|
|
2494
2402
|
function useAppStore(selector) {
|
|
2495
|
-
const context = (0,
|
|
2403
|
+
const context = (0, import_react8.useContext)(appStoreContext);
|
|
2496
2404
|
return (0, import_zustand2.useStore)(context, selector);
|
|
2497
2405
|
}
|
|
2498
2406
|
function useAppStoreApi() {
|
|
2499
|
-
return (0,
|
|
2407
|
+
return (0, import_react8.useContext)(appStoreContext);
|
|
2500
2408
|
}
|
|
2501
2409
|
|
|
2502
|
-
//
|
|
2503
|
-
init_react_import();
|
|
2504
|
-
var import_react12 = require("@dnd-kit/react");
|
|
2505
|
-
|
|
2506
|
-
// lib/dnd/use-sensors.ts
|
|
2410
|
+
// lib/get-zoom-config.ts
|
|
2507
2411
|
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
2412
|
|
|
2542
|
-
//
|
|
2413
|
+
// ../../node_modules/css-box-model/dist/css-box-model.esm.js
|
|
2543
2414
|
init_react_import();
|
|
2544
|
-
var import_abstract8 = require("@dnd-kit/abstract");
|
|
2545
2415
|
|
|
2546
|
-
//
|
|
2416
|
+
// ../../node_modules/tiny-invariant/dist/esm/tiny-invariant.js
|
|
2547
2417
|
init_react_import();
|
|
2548
|
-
var
|
|
2418
|
+
var isProduction = process.env.NODE_ENV === "production";
|
|
2419
|
+
var prefix = "Invariant failed";
|
|
2420
|
+
function invariant(condition, message) {
|
|
2421
|
+
if (condition) {
|
|
2422
|
+
return;
|
|
2423
|
+
}
|
|
2424
|
+
if (isProduction) {
|
|
2425
|
+
throw new Error(prefix);
|
|
2426
|
+
}
|
|
2427
|
+
var provided = typeof message === "function" ? message() : message;
|
|
2428
|
+
var value = provided ? "".concat(prefix, ": ").concat(provided) : prefix;
|
|
2429
|
+
throw new Error(value);
|
|
2430
|
+
}
|
|
2549
2431
|
|
|
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;
|
|
2432
|
+
// ../../node_modules/css-box-model/dist/css-box-model.esm.js
|
|
2433
|
+
var getRect = function getRect2(_ref) {
|
|
2434
|
+
var top = _ref.top, right = _ref.right, bottom = _ref.bottom, left = _ref.left;
|
|
2435
|
+
var width = right - left;
|
|
2436
|
+
var height = bottom - top;
|
|
2437
|
+
var rect = {
|
|
2438
|
+
top,
|
|
2439
|
+
right,
|
|
2440
|
+
bottom,
|
|
2441
|
+
left,
|
|
2442
|
+
width,
|
|
2443
|
+
height,
|
|
2444
|
+
x: left,
|
|
2445
|
+
y: top,
|
|
2446
|
+
center: {
|
|
2447
|
+
x: (right + left) / 2,
|
|
2448
|
+
y: (bottom + top) / 2
|
|
2595
2449
|
}
|
|
2596
|
-
}
|
|
2450
|
+
};
|
|
2451
|
+
return rect;
|
|
2597
2452
|
};
|
|
2598
|
-
|
|
2599
|
-
|
|
2600
|
-
|
|
2601
|
-
|
|
2602
|
-
|
|
2603
|
-
|
|
2604
|
-
|
|
2605
|
-
|
|
2606
|
-
|
|
2607
|
-
|
|
2608
|
-
|
|
2609
|
-
|
|
2610
|
-
|
|
2611
|
-
|
|
2612
|
-
|
|
2613
|
-
|
|
2614
|
-
|
|
2615
|
-
|
|
2616
|
-
|
|
2617
|
-
|
|
2618
|
-
|
|
2619
|
-
|
|
2453
|
+
var expand = function expand2(target, expandBy) {
|
|
2454
|
+
return {
|
|
2455
|
+
top: target.top - expandBy.top,
|
|
2456
|
+
left: target.left - expandBy.left,
|
|
2457
|
+
bottom: target.bottom + expandBy.bottom,
|
|
2458
|
+
right: target.right + expandBy.right
|
|
2459
|
+
};
|
|
2460
|
+
};
|
|
2461
|
+
var shrink = function shrink2(target, shrinkBy) {
|
|
2462
|
+
return {
|
|
2463
|
+
top: target.top + shrinkBy.top,
|
|
2464
|
+
left: target.left + shrinkBy.left,
|
|
2465
|
+
bottom: target.bottom - shrinkBy.bottom,
|
|
2466
|
+
right: target.right - shrinkBy.right
|
|
2467
|
+
};
|
|
2468
|
+
};
|
|
2469
|
+
var noSpacing = {
|
|
2470
|
+
top: 0,
|
|
2471
|
+
right: 0,
|
|
2472
|
+
bottom: 0,
|
|
2473
|
+
left: 0
|
|
2474
|
+
};
|
|
2475
|
+
var createBox = function createBox2(_ref2) {
|
|
2476
|
+
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;
|
|
2477
|
+
var marginBox = getRect(expand(borderBox, margin));
|
|
2478
|
+
var paddingBox = getRect(shrink(borderBox, border));
|
|
2479
|
+
var contentBox = getRect(shrink(paddingBox, padding));
|
|
2480
|
+
return {
|
|
2481
|
+
marginBox,
|
|
2482
|
+
borderBox: getRect(borderBox),
|
|
2483
|
+
paddingBox,
|
|
2484
|
+
contentBox,
|
|
2485
|
+
margin,
|
|
2486
|
+
border,
|
|
2487
|
+
padding
|
|
2488
|
+
};
|
|
2489
|
+
};
|
|
2490
|
+
var parse = function parse2(raw) {
|
|
2491
|
+
var value = raw.slice(0, -2);
|
|
2492
|
+
var suffix = raw.slice(-2);
|
|
2493
|
+
if (suffix !== "px") {
|
|
2494
|
+
return 0;
|
|
2495
|
+
}
|
|
2496
|
+
var result = Number(value);
|
|
2497
|
+
!!isNaN(result) ? process.env.NODE_ENV !== "production" ? invariant(false, "Could not parse value [raw: " + raw + ", without suffix: " + value + "]") : invariant(false) : void 0;
|
|
2498
|
+
return result;
|
|
2499
|
+
};
|
|
2500
|
+
var calculateBox = function calculateBox2(borderBox, styles2) {
|
|
2501
|
+
var margin = {
|
|
2502
|
+
top: parse(styles2.marginTop),
|
|
2503
|
+
right: parse(styles2.marginRight),
|
|
2504
|
+
bottom: parse(styles2.marginBottom),
|
|
2505
|
+
left: parse(styles2.marginLeft)
|
|
2506
|
+
};
|
|
2507
|
+
var padding = {
|
|
2508
|
+
top: parse(styles2.paddingTop),
|
|
2509
|
+
right: parse(styles2.paddingRight),
|
|
2510
|
+
bottom: parse(styles2.paddingBottom),
|
|
2511
|
+
left: parse(styles2.paddingLeft)
|
|
2512
|
+
};
|
|
2513
|
+
var border = {
|
|
2514
|
+
top: parse(styles2.borderTopWidth),
|
|
2515
|
+
right: parse(styles2.borderRightWidth),
|
|
2516
|
+
bottom: parse(styles2.borderBottomWidth),
|
|
2517
|
+
left: parse(styles2.borderLeftWidth)
|
|
2518
|
+
};
|
|
2519
|
+
return createBox({
|
|
2520
|
+
borderBox,
|
|
2521
|
+
margin,
|
|
2522
|
+
padding,
|
|
2523
|
+
border
|
|
2524
|
+
});
|
|
2525
|
+
};
|
|
2526
|
+
var getBox = function getBox2(el) {
|
|
2527
|
+
var borderBox = el.getBoundingClientRect();
|
|
2528
|
+
var styles2 = window.getComputedStyle(el);
|
|
2529
|
+
return calculateBox(borderBox, styles2);
|
|
2530
|
+
};
|
|
2531
|
+
|
|
2532
|
+
// lib/get-zoom-config.ts
|
|
2533
|
+
var RESET_ZOOM_SMALLER_THAN_FRAME = true;
|
|
2534
|
+
var getZoomConfig = (uiViewport, frame, zoom) => {
|
|
2535
|
+
const box = getBox(frame);
|
|
2536
|
+
const { width: frameWidth, height: frameHeight } = box.contentBox;
|
|
2537
|
+
const viewportHeight = uiViewport.height === "auto" ? frameHeight : uiViewport.height;
|
|
2538
|
+
let rootHeight = 0;
|
|
2539
|
+
let autoZoom = 1;
|
|
2540
|
+
if (uiViewport.width > frameWidth || viewportHeight > frameHeight) {
|
|
2541
|
+
const widthZoom = Math.min(frameWidth / uiViewport.width, 1);
|
|
2542
|
+
const heightZoom = Math.min(frameHeight / viewportHeight, 1);
|
|
2543
|
+
zoom = widthZoom;
|
|
2544
|
+
if (widthZoom < heightZoom) {
|
|
2545
|
+
rootHeight = viewportHeight / zoom;
|
|
2546
|
+
} else {
|
|
2547
|
+
rootHeight = viewportHeight;
|
|
2548
|
+
zoom = heightZoom;
|
|
2549
|
+
}
|
|
2550
|
+
autoZoom = zoom;
|
|
2551
|
+
} else {
|
|
2552
|
+
if (RESET_ZOOM_SMALLER_THAN_FRAME) {
|
|
2553
|
+
autoZoom = 1;
|
|
2554
|
+
zoom = 1;
|
|
2555
|
+
rootHeight = viewportHeight;
|
|
2556
|
+
}
|
|
2557
|
+
}
|
|
2558
|
+
return { autoZoom, rootHeight, zoom };
|
|
2559
|
+
};
|
|
2560
|
+
|
|
2561
|
+
// lib/use-reset-auto-zoom.ts
|
|
2562
|
+
var import_shallow = require("zustand/react/shallow");
|
|
2563
|
+
var useResetAutoZoom = (frameRef) => {
|
|
2564
|
+
const { viewports, zoomConfig, setZoomConfig } = useAppStore(
|
|
2565
|
+
(0, import_shallow.useShallow)((s) => ({
|
|
2566
|
+
viewports: s.state.ui.viewports,
|
|
2567
|
+
zoomConfig: s.zoomConfig,
|
|
2568
|
+
setZoomConfig: s.setZoomConfig
|
|
2569
|
+
}))
|
|
2570
|
+
);
|
|
2571
|
+
const resetAutoZoom = (0, import_react9.useCallback)(
|
|
2572
|
+
(options) => {
|
|
2573
|
+
const newViewports = (options == null ? void 0 : options.viewports) || viewports;
|
|
2574
|
+
if (!(options == null ? void 0 : options.isResettingRef)) {
|
|
2575
|
+
if (frameRef.current) {
|
|
2576
|
+
setZoomConfig(
|
|
2577
|
+
getZoomConfig(
|
|
2578
|
+
newViewports == null ? void 0 : newViewports.current,
|
|
2579
|
+
frameRef.current,
|
|
2580
|
+
zoomConfig.zoom
|
|
2581
|
+
)
|
|
2582
|
+
);
|
|
2583
|
+
}
|
|
2584
|
+
return;
|
|
2585
|
+
}
|
|
2586
|
+
const {
|
|
2587
|
+
isResettingRef,
|
|
2588
|
+
setShowTransition,
|
|
2589
|
+
showTransition = false
|
|
2590
|
+
} = options;
|
|
2591
|
+
if (!isResettingRef.current) {
|
|
2592
|
+
isResettingRef.current = true;
|
|
2593
|
+
if (setShowTransition) {
|
|
2594
|
+
setShowTransition(showTransition);
|
|
2595
|
+
}
|
|
2596
|
+
if (frameRef.current) {
|
|
2597
|
+
setZoomConfig(
|
|
2598
|
+
getZoomConfig(
|
|
2599
|
+
newViewports == null ? void 0 : newViewports.current,
|
|
2600
|
+
frameRef.current,
|
|
2601
|
+
zoomConfig.zoom
|
|
2602
|
+
)
|
|
2603
|
+
);
|
|
2604
|
+
}
|
|
2605
|
+
setTimeout(() => {
|
|
2606
|
+
isResettingRef.current = false;
|
|
2607
|
+
}, 0);
|
|
2608
|
+
}
|
|
2609
|
+
},
|
|
2610
|
+
[frameRef, zoomConfig, viewports, setZoomConfig]
|
|
2611
|
+
);
|
|
2612
|
+
return resetAutoZoom;
|
|
2613
|
+
};
|
|
2614
|
+
|
|
2615
|
+
// css-module:/home/runner/work/puck/puck/packages/core/components/Loader/styles.module.css#css-module
|
|
2616
|
+
init_react_import();
|
|
2617
|
+
var styles_module_default4 = { "Loader": "_Loader_nacdm_13", "loader-animation": "_loader-animation_nacdm_1" };
|
|
2618
|
+
|
|
2619
|
+
// components/Loader/index.tsx
|
|
2620
|
+
var import_jsx_runtime2 = require("react/jsx-runtime");
|
|
2621
|
+
var getClassName2 = get_class_name_factory_default("Loader", styles_module_default4);
|
|
2622
|
+
var Loader = (_a) => {
|
|
2623
|
+
var _b = _a, {
|
|
2624
|
+
color,
|
|
2625
|
+
size = 16
|
|
2626
|
+
} = _b, props = __objRest(_b, [
|
|
2627
|
+
"color",
|
|
2628
|
+
"size"
|
|
2629
|
+
]);
|
|
2630
|
+
return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
2631
|
+
"span",
|
|
2632
|
+
__spreadValues({
|
|
2633
|
+
className: getClassName2(),
|
|
2634
|
+
style: {
|
|
2635
|
+
width: size,
|
|
2636
|
+
height: size,
|
|
2637
|
+
color
|
|
2638
|
+
},
|
|
2639
|
+
"aria-label": "loading"
|
|
2640
|
+
}, props)
|
|
2641
|
+
);
|
|
2642
|
+
};
|
|
2643
|
+
|
|
2644
|
+
// components/IconButton/IconButton.tsx
|
|
2645
|
+
var import_jsx_runtime3 = require("react/jsx-runtime");
|
|
2646
|
+
var getClassName3 = get_class_name_factory_default("IconButton", IconButton_module_default);
|
|
2647
|
+
var IconButton = ({
|
|
2648
|
+
children,
|
|
2649
|
+
href,
|
|
2650
|
+
onClick,
|
|
2651
|
+
variant = "primary",
|
|
2652
|
+
type,
|
|
2653
|
+
disabled,
|
|
2654
|
+
tabIndex,
|
|
2655
|
+
newTab,
|
|
2656
|
+
fullWidth,
|
|
2657
|
+
title
|
|
2658
|
+
}) => {
|
|
2659
|
+
const [loading, setLoading] = (0, import_react10.useState)(false);
|
|
2660
|
+
const ElementType = href ? "a" : "button";
|
|
2661
|
+
const el = /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(
|
|
2662
|
+
ElementType,
|
|
2663
|
+
{
|
|
2664
|
+
className: getClassName3({
|
|
2665
|
+
primary: variant === "primary",
|
|
2666
|
+
secondary: variant === "secondary",
|
|
2667
|
+
disabled,
|
|
2668
|
+
fullWidth
|
|
2669
|
+
}),
|
|
2670
|
+
onClick: (e) => {
|
|
2671
|
+
if (!onClick) return;
|
|
2672
|
+
setLoading(true);
|
|
2673
|
+
Promise.resolve(onClick(e)).then(() => {
|
|
2674
|
+
setLoading(false);
|
|
2675
|
+
});
|
|
2676
|
+
},
|
|
2677
|
+
type,
|
|
2678
|
+
disabled: disabled || loading,
|
|
2679
|
+
tabIndex,
|
|
2680
|
+
target: newTab ? "_blank" : void 0,
|
|
2681
|
+
rel: newTab ? "noreferrer" : void 0,
|
|
2682
|
+
href,
|
|
2683
|
+
title,
|
|
2684
|
+
children: [
|
|
2685
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("span", { className: getClassName3("title"), children: title }),
|
|
2686
|
+
children,
|
|
2687
|
+
loading && /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(import_jsx_runtime3.Fragment, { children: [
|
|
2688
|
+
"\xA0\xA0",
|
|
2689
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)(Loader, { size: 14 })
|
|
2690
|
+
] })
|
|
2691
|
+
]
|
|
2692
|
+
}
|
|
2693
|
+
);
|
|
2694
|
+
return el;
|
|
2695
|
+
};
|
|
2696
|
+
|
|
2697
|
+
// components/AutoField/fields/ArrayField/index.tsx
|
|
2698
|
+
var import_react15 = require("react");
|
|
2699
|
+
|
|
2700
|
+
// components/DragIcon/index.tsx
|
|
2701
|
+
init_react_import();
|
|
2702
|
+
|
|
2703
|
+
// css-module:/home/runner/work/puck/puck/packages/core/components/DragIcon/styles.module.css#css-module
|
|
2704
|
+
init_react_import();
|
|
2705
|
+
var styles_module_default5 = { "DragIcon": "_DragIcon_17p8x_1", "DragIcon--disabled": "_DragIcon--disabled_17p8x_8" };
|
|
2706
|
+
|
|
2707
|
+
// components/DragIcon/index.tsx
|
|
2708
|
+
var import_jsx_runtime4 = require("react/jsx-runtime");
|
|
2709
|
+
var getClassName4 = get_class_name_factory_default("DragIcon", styles_module_default5);
|
|
2710
|
+
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" }) }) });
|
|
2711
|
+
|
|
2712
|
+
// components/Sortable/index.tsx
|
|
2713
|
+
init_react_import();
|
|
2714
|
+
var import_react13 = require("@dnd-kit/react");
|
|
2715
|
+
|
|
2716
|
+
// lib/dnd/use-sensors.ts
|
|
2717
|
+
init_react_import();
|
|
2718
|
+
var import_react11 = require("react");
|
|
2719
|
+
var import_react12 = require("@dnd-kit/react");
|
|
2720
|
+
var import_utilities = require("@dnd-kit/dom/utilities");
|
|
2721
|
+
var touchDefault = { delay: { value: 200, tolerance: 10 } };
|
|
2722
|
+
var otherDefault = {
|
|
2723
|
+
delay: { value: 200, tolerance: 10 },
|
|
2724
|
+
distance: { value: 5 }
|
|
2725
|
+
};
|
|
2726
|
+
var useSensors = ({
|
|
2727
|
+
other = otherDefault,
|
|
2728
|
+
mouse,
|
|
2729
|
+
touch = touchDefault
|
|
2730
|
+
} = {
|
|
2731
|
+
touch: touchDefault,
|
|
2732
|
+
other: otherDefault
|
|
2733
|
+
}) => {
|
|
2734
|
+
const [sensors] = (0, import_react11.useState)(() => [
|
|
2735
|
+
import_react12.PointerSensor.configure({
|
|
2736
|
+
activationConstraints(event, source) {
|
|
2737
|
+
var _a;
|
|
2738
|
+
const { pointerType, target } = event;
|
|
2739
|
+
if (pointerType === "mouse" && (0, import_utilities.isElement)(target) && (source.handle === target || ((_a = source.handle) == null ? void 0 : _a.contains(target)))) {
|
|
2740
|
+
return mouse;
|
|
2741
|
+
}
|
|
2742
|
+
if (pointerType === "touch") {
|
|
2743
|
+
return touch;
|
|
2744
|
+
}
|
|
2745
|
+
return other;
|
|
2746
|
+
}
|
|
2747
|
+
})
|
|
2748
|
+
]);
|
|
2749
|
+
return sensors;
|
|
2750
|
+
};
|
|
2751
|
+
|
|
2752
|
+
// lib/dnd/collision/dynamic/index.ts
|
|
2753
|
+
init_react_import();
|
|
2754
|
+
var import_abstract8 = require("@dnd-kit/abstract");
|
|
2755
|
+
|
|
2756
|
+
// lib/dnd/collision/directional/index.ts
|
|
2757
|
+
init_react_import();
|
|
2758
|
+
var import_abstract = require("@dnd-kit/abstract");
|
|
2759
|
+
|
|
2760
|
+
// lib/dnd/collision/collision-debug.ts
|
|
2761
|
+
init_react_import();
|
|
2762
|
+
var DEBUG = false;
|
|
2763
|
+
var debugElements = {};
|
|
2764
|
+
var timeout;
|
|
2765
|
+
var collisionDebug = (a, b, id, color, label) => {
|
|
2766
|
+
if (!DEBUG) return;
|
|
2767
|
+
const debugId = `${id}-debug`;
|
|
2768
|
+
clearTimeout(timeout);
|
|
2769
|
+
timeout = setTimeout(() => {
|
|
2770
|
+
Object.entries(debugElements).forEach(([id2, { svg }]) => {
|
|
2771
|
+
svg.remove();
|
|
2772
|
+
delete debugElements[id2];
|
|
2773
|
+
});
|
|
2774
|
+
}, 1e3);
|
|
2775
|
+
requestAnimationFrame(() => {
|
|
2776
|
+
var _a, _b;
|
|
2777
|
+
const existingEl = debugElements[debugId];
|
|
2778
|
+
let line = (_a = debugElements[debugId]) == null ? void 0 : _a.line;
|
|
2779
|
+
let text = (_b = debugElements[debugId]) == null ? void 0 : _b.text;
|
|
2780
|
+
if (!existingEl) {
|
|
2781
|
+
const svgNs = "http://www.w3.org/2000/svg";
|
|
2782
|
+
const svg = document.createElementNS(svgNs, "svg");
|
|
2783
|
+
line = document.createElementNS(svgNs, "line");
|
|
2784
|
+
text = document.createElementNS(svgNs, "text");
|
|
2785
|
+
svg.setAttribute("id", debugId);
|
|
2786
|
+
svg.setAttribute(
|
|
2787
|
+
"style",
|
|
2788
|
+
"position: fixed; height: 100%; width: 100%; pointer-events: none; top: 0px; left: 0px;"
|
|
2789
|
+
);
|
|
2790
|
+
svg.appendChild(line);
|
|
2791
|
+
svg.appendChild(text);
|
|
2792
|
+
text.setAttribute("fill", `black`);
|
|
2793
|
+
document.body.appendChild(svg);
|
|
2794
|
+
debugElements[debugId] = { svg, line, text };
|
|
2795
|
+
}
|
|
2796
|
+
line.setAttribute("x1", a.x.toString());
|
|
2797
|
+
line.setAttribute("x2", b.x.toString());
|
|
2798
|
+
line.setAttribute("y1", a.y.toString());
|
|
2799
|
+
line.setAttribute("y2", b.y.toString());
|
|
2800
|
+
line.setAttribute("style", `stroke:${color};stroke-width:2`);
|
|
2801
|
+
text.setAttribute("x", (a.x - (a.x - b.x) / 2).toString());
|
|
2802
|
+
text.setAttribute("y", (a.y - (a.y - b.y) / 2).toString());
|
|
2803
|
+
if (label) {
|
|
2804
|
+
text.innerHTML = label;
|
|
2805
|
+
}
|
|
2806
|
+
});
|
|
2807
|
+
};
|
|
2808
|
+
|
|
2809
|
+
// lib/dnd/collision/directional/index.ts
|
|
2810
|
+
var distanceChange = "increasing";
|
|
2811
|
+
var directionalCollision = (input, previous) => {
|
|
2812
|
+
var _a;
|
|
2813
|
+
const { dragOperation, droppable } = input;
|
|
2814
|
+
const { shape: dropShape } = droppable;
|
|
2815
|
+
const { position } = dragOperation;
|
|
2816
|
+
const dragShape = (_a = dragOperation.shape) == null ? void 0 : _a.current;
|
|
2817
|
+
if (!dragShape || !dropShape) return null;
|
|
2818
|
+
const dropCenter = dropShape.center;
|
|
2819
|
+
const distanceToPrevious = Math.sqrt(
|
|
2820
|
+
Math.pow(dropCenter.x - previous.x, 2) + Math.pow(dropCenter.y - previous.y, 2)
|
|
2821
|
+
);
|
|
2822
|
+
const distanceToCurrent = Math.sqrt(
|
|
2823
|
+
Math.pow(dropCenter.x - position.current.x, 2) + Math.pow(dropCenter.y - position.current.y, 2)
|
|
2824
|
+
);
|
|
2825
|
+
distanceChange = distanceToCurrent === distanceToPrevious ? distanceChange : distanceToCurrent < distanceToPrevious ? "decreasing" : "increasing";
|
|
2826
|
+
collisionDebug(
|
|
2827
|
+
dragShape.center,
|
|
2828
|
+
dropCenter,
|
|
2829
|
+
droppable.id.toString(),
|
|
2620
2830
|
"rebeccapurple"
|
|
2621
2831
|
);
|
|
2622
2832
|
if (distanceChange === "decreasing") {
|
|
@@ -2868,7 +3078,7 @@ var SortableProvider = ({
|
|
|
2868
3078
|
mouse: { distance: { value: 5 } }
|
|
2869
3079
|
});
|
|
2870
3080
|
return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
2871
|
-
|
|
3081
|
+
import_react13.DragDropProvider,
|
|
2872
3082
|
{
|
|
2873
3083
|
sensors,
|
|
2874
3084
|
onDragStart: (event) => {
|
|
@@ -2932,11 +3142,11 @@ var Sortable = ({
|
|
|
2932
3142
|
|
|
2933
3143
|
// components/AutoField/context.tsx
|
|
2934
3144
|
init_react_import();
|
|
2935
|
-
var
|
|
3145
|
+
var import_react14 = require("react");
|
|
2936
3146
|
var import_jsx_runtime6 = require("react/jsx-runtime");
|
|
2937
|
-
var NestedFieldContext = (0,
|
|
3147
|
+
var NestedFieldContext = (0, import_react14.createContext)({});
|
|
2938
3148
|
var useNestedFieldContext = () => {
|
|
2939
|
-
const context = (0,
|
|
3149
|
+
const context = (0, import_react14.useContext)(NestedFieldContext);
|
|
2940
3150
|
return __spreadProps(__spreadValues({}, context), {
|
|
2941
3151
|
readOnlyFields: context.readOnlyFields || {}
|
|
2942
3152
|
});
|
|
@@ -2950,7 +3160,7 @@ var NestedFieldProvider = ({
|
|
|
2950
3160
|
}) => {
|
|
2951
3161
|
const subPath = `${name}.${subName}`;
|
|
2952
3162
|
const wildcardSubPath = `${wildcardName}.${subName}`;
|
|
2953
|
-
const subReadOnlyFields = (0,
|
|
3163
|
+
const subReadOnlyFields = (0, import_react14.useMemo)(
|
|
2954
3164
|
() => Object.keys(readOnlyFields).reduce((acc, readOnlyKey) => {
|
|
2955
3165
|
const isLocal = readOnlyKey.indexOf(subPath) > -1 || readOnlyKey.indexOf(wildcardSubPath) > -1;
|
|
2956
3166
|
if (isLocal) {
|
|
@@ -3003,14 +3213,14 @@ var ArrayField = ({
|
|
|
3003
3213
|
}),
|
|
3004
3214
|
openId: ""
|
|
3005
3215
|
};
|
|
3006
|
-
const [localState, setLocalState] = (0,
|
|
3007
|
-
(0,
|
|
3216
|
+
const [localState, setLocalState] = (0, import_react15.useState)({ arrayState, value });
|
|
3217
|
+
(0, import_react15.useEffect)(() => {
|
|
3008
3218
|
var _a;
|
|
3009
3219
|
const _arrayState = (_a = appStore.getState().state.ui.arrayState[id]) != null ? _a : arrayState;
|
|
3010
3220
|
setLocalState({ arrayState: _arrayState, value });
|
|
3011
3221
|
}, [value]);
|
|
3012
3222
|
const appStore = useAppStoreApi();
|
|
3013
|
-
const mapArrayStateToUi = (0,
|
|
3223
|
+
const mapArrayStateToUi = (0, import_react15.useCallback)(
|
|
3014
3224
|
(partialArrayState) => {
|
|
3015
3225
|
const state = appStore.getState().state;
|
|
3016
3226
|
return {
|
|
@@ -3021,13 +3231,13 @@ var ArrayField = ({
|
|
|
3021
3231
|
},
|
|
3022
3232
|
[arrayState, appStore]
|
|
3023
3233
|
);
|
|
3024
|
-
const getHighestIndex = (0,
|
|
3234
|
+
const getHighestIndex = (0, import_react15.useCallback)(() => {
|
|
3025
3235
|
return arrayState.items.reduce(
|
|
3026
3236
|
(acc, item) => item._originalIndex > acc ? item._originalIndex : acc,
|
|
3027
3237
|
-1
|
|
3028
3238
|
);
|
|
3029
3239
|
}, [arrayState]);
|
|
3030
|
-
const regenerateArrayState = (0,
|
|
3240
|
+
const regenerateArrayState = (0, import_react15.useCallback)(
|
|
3031
3241
|
(value2) => {
|
|
3032
3242
|
let highestIndex = getHighestIndex();
|
|
3033
3243
|
const newItems = Array.from(value2 || []).map((item, idx) => {
|
|
@@ -3046,19 +3256,19 @@ var ArrayField = ({
|
|
|
3046
3256
|
},
|
|
3047
3257
|
[arrayState]
|
|
3048
3258
|
);
|
|
3049
|
-
(0,
|
|
3259
|
+
(0, import_react15.useEffect)(() => {
|
|
3050
3260
|
if (arrayState.items.length > 0) {
|
|
3051
3261
|
setUi(mapArrayStateToUi(arrayState));
|
|
3052
3262
|
}
|
|
3053
3263
|
}, []);
|
|
3054
|
-
const [draggedItem, setDraggedItem] = (0,
|
|
3264
|
+
const [draggedItem, setDraggedItem] = (0, import_react15.useState)("");
|
|
3055
3265
|
const isDraggingAny = !!draggedItem;
|
|
3056
3266
|
const canEdit = useAppStore(
|
|
3057
3267
|
(s) => s.permissions.getPermissions({ item: s.selectedItem }).edit
|
|
3058
3268
|
);
|
|
3059
3269
|
const forceReadOnly = !canEdit;
|
|
3060
|
-
const valueRef = (0,
|
|
3061
|
-
const uniqifyItem = (0,
|
|
3270
|
+
const valueRef = (0, import_react15.useRef)(value);
|
|
3271
|
+
const uniqifyItem = (0, import_react15.useCallback)(
|
|
3062
3272
|
(val) => {
|
|
3063
3273
|
if (field.type !== "array" || !field.arrayFields) return;
|
|
3064
3274
|
const config = appStore.getState().config;
|
|
@@ -3363,11 +3573,11 @@ var DefaultField = ({
|
|
|
3363
3573
|
|
|
3364
3574
|
// components/AutoField/fields/ExternalField/index.tsx
|
|
3365
3575
|
init_react_import();
|
|
3366
|
-
var
|
|
3576
|
+
var import_react19 = require("react");
|
|
3367
3577
|
|
|
3368
3578
|
// components/ExternalInput/index.tsx
|
|
3369
3579
|
init_react_import();
|
|
3370
|
-
var
|
|
3580
|
+
var import_react18 = require("react");
|
|
3371
3581
|
|
|
3372
3582
|
// css-module:/home/runner/work/puck/puck/packages/core/components/ExternalInput/styles.module.css#css-module
|
|
3373
3583
|
init_react_import();
|
|
@@ -3375,7 +3585,7 @@ var styles_module_default6 = { "ExternalInput-actions": "_ExternalInput-actions_
|
|
|
3375
3585
|
|
|
3376
3586
|
// components/Modal/index.tsx
|
|
3377
3587
|
init_react_import();
|
|
3378
|
-
var
|
|
3588
|
+
var import_react16 = require("react");
|
|
3379
3589
|
|
|
3380
3590
|
// css-module:/home/runner/work/puck/puck/packages/core/components/Modal/styles.module.css#css-module
|
|
3381
3591
|
init_react_import();
|
|
@@ -3390,8 +3600,8 @@ var Modal = ({
|
|
|
3390
3600
|
onClose,
|
|
3391
3601
|
isOpen
|
|
3392
3602
|
}) => {
|
|
3393
|
-
const [rootEl, setRootEl] = (0,
|
|
3394
|
-
(0,
|
|
3603
|
+
const [rootEl, setRootEl] = (0, import_react16.useState)(null);
|
|
3604
|
+
(0, import_react16.useEffect)(() => {
|
|
3395
3605
|
setRootEl(document.getElementById("puck-portal-root"));
|
|
3396
3606
|
}, []);
|
|
3397
3607
|
if (!rootEl) {
|
|
@@ -3438,7 +3648,7 @@ init_react_import();
|
|
|
3438
3648
|
|
|
3439
3649
|
// components/Button/Button.tsx
|
|
3440
3650
|
init_react_import();
|
|
3441
|
-
var
|
|
3651
|
+
var import_react17 = require("react");
|
|
3442
3652
|
|
|
3443
3653
|
// css-module:/home/runner/work/puck/puck/packages/core/components/Button/Button.module.css#css-module
|
|
3444
3654
|
init_react_import();
|
|
@@ -3488,8 +3698,8 @@ var Button = (_a) => {
|
|
|
3488
3698
|
"size",
|
|
3489
3699
|
"loading"
|
|
3490
3700
|
]);
|
|
3491
|
-
const [loading, setLoading] = (0,
|
|
3492
|
-
(0,
|
|
3701
|
+
const [loading, setLoading] = (0, import_react17.useState)(loadingProp);
|
|
3702
|
+
(0, import_react17.useEffect)(() => setLoading(loadingProp), [loadingProp]);
|
|
3493
3703
|
const ElementType = href ? "a" : type ? "button" : "span";
|
|
3494
3704
|
const dataAttrs = filterDataAttrs(props);
|
|
3495
3705
|
const el = /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)(
|
|
@@ -3544,28 +3754,28 @@ var ExternalInput = ({
|
|
|
3544
3754
|
mapRow = (val) => val,
|
|
3545
3755
|
filterFields
|
|
3546
3756
|
} = field || {};
|
|
3547
|
-
const [data, setData] = (0,
|
|
3548
|
-
const [isOpen, setOpen] = (0,
|
|
3549
|
-
const [isLoading, setIsLoading] = (0,
|
|
3757
|
+
const [data, setData] = (0, import_react18.useState)([]);
|
|
3758
|
+
const [isOpen, setOpen] = (0, import_react18.useState)(false);
|
|
3759
|
+
const [isLoading, setIsLoading] = (0, import_react18.useState)(true);
|
|
3550
3760
|
const hasFilterFields = !!filterFields;
|
|
3551
|
-
const [filters, setFilters] = (0,
|
|
3552
|
-
const [filtersToggled, setFiltersToggled] = (0,
|
|
3553
|
-
const mappedData = (0,
|
|
3761
|
+
const [filters, setFilters] = (0, import_react18.useState)(field.initialFilters || {});
|
|
3762
|
+
const [filtersToggled, setFiltersToggled] = (0, import_react18.useState)(hasFilterFields);
|
|
3763
|
+
const mappedData = (0, import_react18.useMemo)(() => {
|
|
3554
3764
|
return data.map(mapRow);
|
|
3555
3765
|
}, [data]);
|
|
3556
|
-
const keys = (0,
|
|
3766
|
+
const keys = (0, import_react18.useMemo)(() => {
|
|
3557
3767
|
const validKeys = /* @__PURE__ */ new Set();
|
|
3558
3768
|
for (const item of mappedData) {
|
|
3559
3769
|
for (const key of Object.keys(item)) {
|
|
3560
|
-
if (typeof item[key] === "string" || typeof item[key] === "number" || (0,
|
|
3770
|
+
if (typeof item[key] === "string" || typeof item[key] === "number" || (0, import_react18.isValidElement)(item[key])) {
|
|
3561
3771
|
validKeys.add(key);
|
|
3562
3772
|
}
|
|
3563
3773
|
}
|
|
3564
3774
|
}
|
|
3565
3775
|
return Array.from(validKeys);
|
|
3566
3776
|
}, [mappedData]);
|
|
3567
|
-
const [searchQuery, setSearchQuery] = (0,
|
|
3568
|
-
const search = (0,
|
|
3777
|
+
const [searchQuery, setSearchQuery] = (0, import_react18.useState)(field.initialQuery || "");
|
|
3778
|
+
const search = (0, import_react18.useCallback)(
|
|
3569
3779
|
(query, filters2) => __async(void 0, null, function* () {
|
|
3570
3780
|
setIsLoading(true);
|
|
3571
3781
|
const cacheKey = `${id}-${query}-${JSON.stringify(filters2)}`;
|
|
@@ -3578,7 +3788,7 @@ var ExternalInput = ({
|
|
|
3578
3788
|
}),
|
|
3579
3789
|
[id, field]
|
|
3580
3790
|
);
|
|
3581
|
-
const Footer = (0,
|
|
3791
|
+
const Footer = (0, import_react18.useCallback)(
|
|
3582
3792
|
(props) => field.renderFooter ? field.renderFooter(props) : /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)("span", { className: getClassNameModal("footer"), children: [
|
|
3583
3793
|
props.items.length,
|
|
3584
3794
|
" result",
|
|
@@ -3586,7 +3796,7 @@ var ExternalInput = ({
|
|
|
3586
3796
|
] }),
|
|
3587
3797
|
[field.renderFooter]
|
|
3588
3798
|
);
|
|
3589
|
-
(0,
|
|
3799
|
+
(0, import_react18.useEffect)(() => {
|
|
3590
3800
|
search(searchQuery, filters);
|
|
3591
3801
|
}, []);
|
|
3592
3802
|
return /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)(
|
|
@@ -3759,7 +3969,7 @@ var ExternalField = ({
|
|
|
3759
3969
|
var _a, _b, _c;
|
|
3760
3970
|
const validField = field;
|
|
3761
3971
|
const deprecatedField = field;
|
|
3762
|
-
(0,
|
|
3972
|
+
(0, import_react19.useEffect)(() => {
|
|
3763
3973
|
if (deprecatedField.adaptor) {
|
|
3764
3974
|
console.error(
|
|
3765
3975
|
"Warning: The `adaptor` API is deprecated. Please use updated APIs on the `external` field instead. This will be a breaking change in a future release."
|
|
@@ -3802,20 +4012,6 @@ var ExternalField = ({
|
|
|
3802
4012
|
|
|
3803
4013
|
// components/AutoField/fields/RadioField/index.tsx
|
|
3804
4014
|
init_react_import();
|
|
3805
|
-
var import_react19 = require("react");
|
|
3806
|
-
|
|
3807
|
-
// lib/safe-json-parse.ts
|
|
3808
|
-
init_react_import();
|
|
3809
|
-
var safeJsonParse = (str) => {
|
|
3810
|
-
try {
|
|
3811
|
-
const jsonValue = JSON.parse(str);
|
|
3812
|
-
return jsonValue;
|
|
3813
|
-
} catch (e) {
|
|
3814
|
-
return str;
|
|
3815
|
-
}
|
|
3816
|
-
};
|
|
3817
|
-
|
|
3818
|
-
// components/AutoField/fields/RadioField/index.tsx
|
|
3819
4015
|
var import_jsx_runtime14 = require("react/jsx-runtime");
|
|
3820
4016
|
var getClassName11 = get_class_name_factory_default("Input", styles_module_default2);
|
|
3821
4017
|
var RadioField = ({
|
|
@@ -3829,57 +4025,49 @@ var RadioField = ({
|
|
|
3829
4025
|
labelIcon,
|
|
3830
4026
|
Label: Label2
|
|
3831
4027
|
}) => {
|
|
3832
|
-
const flatOptions = (0, import_react19.useMemo)(
|
|
3833
|
-
() => field.type === "radio" ? field.options.map(({ value: value2 }) => value2) : [],
|
|
3834
|
-
[field]
|
|
3835
|
-
);
|
|
3836
4028
|
if (field.type !== "radio" || !field.options) {
|
|
3837
4029
|
return null;
|
|
3838
4030
|
}
|
|
3839
|
-
return /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
|
|
3840
|
-
Label2,
|
|
3841
|
-
{
|
|
3842
|
-
icon: labelIcon || /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(CircleCheckBig, { size: 16 }),
|
|
3843
|
-
label: label || name,
|
|
3844
|
-
readOnly,
|
|
3845
|
-
el: "div",
|
|
3846
|
-
children: /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("div", { className: getClassName11("radioGroupItems"), id, children: field.options.map((option) =>
|
|
3847
|
-
|
|
3848
|
-
|
|
3849
|
-
|
|
3850
|
-
|
|
3851
|
-
|
|
3852
|
-
|
|
3853
|
-
|
|
3854
|
-
|
|
3855
|
-
|
|
3856
|
-
|
|
3857
|
-
|
|
3858
|
-
|
|
3859
|
-
|
|
3860
|
-
|
|
3861
|
-
|
|
3862
|
-
|
|
3863
|
-
|
|
3864
|
-
|
|
3865
|
-
|
|
3866
|
-
|
|
3867
|
-
|
|
3868
|
-
|
|
3869
|
-
|
|
3870
|
-
|
|
3871
|
-
|
|
3872
|
-
|
|
3873
|
-
},
|
|
3874
|
-
option.label + option.value
|
|
3875
|
-
)) })
|
|
4031
|
+
return /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
|
|
4032
|
+
Label2,
|
|
4033
|
+
{
|
|
4034
|
+
icon: labelIcon || /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(CircleCheckBig, { size: 16 }),
|
|
4035
|
+
label: label || name,
|
|
4036
|
+
readOnly,
|
|
4037
|
+
el: "div",
|
|
4038
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("div", { className: getClassName11("radioGroupItems"), id, children: field.options.map((option) => {
|
|
4039
|
+
var _a;
|
|
4040
|
+
return /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)(
|
|
4041
|
+
"label",
|
|
4042
|
+
{
|
|
4043
|
+
className: getClassName11("radio"),
|
|
4044
|
+
children: [
|
|
4045
|
+
/* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
|
|
4046
|
+
"input",
|
|
4047
|
+
{
|
|
4048
|
+
type: "radio",
|
|
4049
|
+
className: getClassName11("radioInput"),
|
|
4050
|
+
value: JSON.stringify({ value: option.value }),
|
|
4051
|
+
name,
|
|
4052
|
+
onChange: (e) => {
|
|
4053
|
+
onChange(JSON.parse(e.target.value).value);
|
|
4054
|
+
},
|
|
4055
|
+
disabled: readOnly,
|
|
4056
|
+
checked: value === option.value
|
|
4057
|
+
}
|
|
4058
|
+
),
|
|
4059
|
+
/* @__PURE__ */ (0, import_jsx_runtime14.jsx)("div", { className: getClassName11("radioInner"), children: option.label || ((_a = option.value) == null ? void 0 : _a.toString()) })
|
|
4060
|
+
]
|
|
4061
|
+
},
|
|
4062
|
+
option.label + option.value
|
|
4063
|
+
);
|
|
4064
|
+
}) })
|
|
3876
4065
|
}
|
|
3877
4066
|
);
|
|
3878
4067
|
};
|
|
3879
4068
|
|
|
3880
4069
|
// components/AutoField/fields/SelectField/index.tsx
|
|
3881
4070
|
init_react_import();
|
|
3882
|
-
var import_react20 = require("react");
|
|
3883
4071
|
var import_jsx_runtime15 = require("react/jsx-runtime");
|
|
3884
4072
|
var getClassName12 = get_class_name_factory_default("Input", styles_module_default2);
|
|
3885
4073
|
var SelectField = ({
|
|
@@ -3893,10 +4081,6 @@ var SelectField = ({
|
|
|
3893
4081
|
readOnly,
|
|
3894
4082
|
id
|
|
3895
4083
|
}) => {
|
|
3896
|
-
const flatOptions = (0, import_react20.useMemo)(
|
|
3897
|
-
() => field.type === "select" ? field.options.map(({ value: value2 }) => value2) : [],
|
|
3898
|
-
[field]
|
|
3899
|
-
);
|
|
3900
4084
|
if (field.type !== "select" || !field.options) {
|
|
3901
4085
|
return null;
|
|
3902
4086
|
}
|
|
@@ -3914,22 +4098,16 @@ var SelectField = ({
|
|
|
3914
4098
|
className: getClassName12("input"),
|
|
3915
4099
|
disabled: readOnly,
|
|
3916
4100
|
onChange: (e) => {
|
|
3917
|
-
|
|
3918
|
-
const jsonValue = (_a = safeJsonParse(e.target.value)) != null ? _a : e.target.value;
|
|
3919
|
-
if (flatOptions.indexOf(jsonValue) > -1) {
|
|
3920
|
-
onChange(jsonValue);
|
|
3921
|
-
} else {
|
|
3922
|
-
onChange(e.target.value);
|
|
3923
|
-
}
|
|
4101
|
+
onChange(JSON.parse(e.target.value).value);
|
|
3924
4102
|
},
|
|
3925
|
-
value,
|
|
4103
|
+
value: JSON.stringify({ value }),
|
|
3926
4104
|
children: field.options.map((option) => /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
|
|
3927
4105
|
"option",
|
|
3928
4106
|
{
|
|
3929
4107
|
label: option.label,
|
|
3930
|
-
value: option.value
|
|
4108
|
+
value: JSON.stringify({ value: option.value })
|
|
3931
4109
|
},
|
|
3932
|
-
option.label + option.value
|
|
4110
|
+
option.label + JSON.stringify(option.value)
|
|
3933
4111
|
))
|
|
3934
4112
|
}
|
|
3935
4113
|
)
|
|
@@ -4053,12 +4231,12 @@ var ObjectField = ({
|
|
|
4053
4231
|
|
|
4054
4232
|
// lib/use-safe-id.ts
|
|
4055
4233
|
init_react_import();
|
|
4056
|
-
var
|
|
4234
|
+
var import_react20 = __toESM(require("react"));
|
|
4057
4235
|
var useSafeId = () => {
|
|
4058
|
-
if (typeof
|
|
4059
|
-
return
|
|
4236
|
+
if (typeof import_react20.default.useId !== "undefined") {
|
|
4237
|
+
return import_react20.default.useId();
|
|
4060
4238
|
}
|
|
4061
|
-
const [id] = (0,
|
|
4239
|
+
const [id] = (0, import_react20.useState)(generateId());
|
|
4062
4240
|
return id;
|
|
4063
4241
|
};
|
|
4064
4242
|
|
|
@@ -4092,7 +4270,7 @@ var FieldLabelInternal = ({
|
|
|
4092
4270
|
readOnly
|
|
4093
4271
|
}) => {
|
|
4094
4272
|
const overrides = useAppStore((s) => s.overrides);
|
|
4095
|
-
const Wrapper = (0,
|
|
4273
|
+
const Wrapper = (0, import_react21.useMemo)(
|
|
4096
4274
|
() => overrides.fieldLabel || FieldLabel,
|
|
4097
4275
|
[overrides]
|
|
4098
4276
|
);
|
|
@@ -4119,7 +4297,7 @@ function AutoFieldInternal(props) {
|
|
|
4119
4297
|
var _a2;
|
|
4120
4298
|
return (_a2 = s.selectedItem) == null ? void 0 : _a2.readOnly;
|
|
4121
4299
|
});
|
|
4122
|
-
const nestedFieldContext = (0,
|
|
4300
|
+
const nestedFieldContext = (0, import_react21.useContext)(NestedFieldContext);
|
|
4123
4301
|
const { id, Label: Label2 = FieldLabelInternal } = props;
|
|
4124
4302
|
const field = props.field;
|
|
4125
4303
|
const label = field.label;
|
|
@@ -4153,7 +4331,7 @@ function AutoFieldInternal(props) {
|
|
|
4153
4331
|
Label: Label2,
|
|
4154
4332
|
id: resolvedId
|
|
4155
4333
|
});
|
|
4156
|
-
const onFocus = (0,
|
|
4334
|
+
const onFocus = (0, import_react21.useCallback)(
|
|
4157
4335
|
(e) => {
|
|
4158
4336
|
if (mergedProps.name && (e.target.nodeName === "INPUT" || e.target.nodeName === "TEXTAREA")) {
|
|
4159
4337
|
e.stopPropagation();
|
|
@@ -4167,7 +4345,7 @@ function AutoFieldInternal(props) {
|
|
|
4167
4345
|
},
|
|
4168
4346
|
[mergedProps.name]
|
|
4169
4347
|
);
|
|
4170
|
-
const onBlur = (0,
|
|
4348
|
+
const onBlur = (0, import_react21.useCallback)((e) => {
|
|
4171
4349
|
if ("name" in e.target) {
|
|
4172
4350
|
dispatch({
|
|
4173
4351
|
type: "setUi",
|
|
@@ -4220,20 +4398,20 @@ function AutoFieldInternal(props) {
|
|
|
4220
4398
|
function AutoFieldPrivate(props) {
|
|
4221
4399
|
const isFocused = useAppStore((s) => s.state.ui.field.focus === props.name);
|
|
4222
4400
|
const { value, onChange } = props;
|
|
4223
|
-
const [localValue, setLocalValue] = (0,
|
|
4224
|
-
const onChangeLocal = (0,
|
|
4401
|
+
const [localValue, setLocalValue] = (0, import_react21.useState)(value);
|
|
4402
|
+
const onChangeLocal = (0, import_react21.useCallback)(
|
|
4225
4403
|
(val, ui) => {
|
|
4226
4404
|
setLocalValue(val);
|
|
4227
4405
|
onChange(val, ui);
|
|
4228
4406
|
},
|
|
4229
4407
|
[onChange]
|
|
4230
4408
|
);
|
|
4231
|
-
(0,
|
|
4409
|
+
(0, import_react21.useEffect)(() => {
|
|
4232
4410
|
if (!isFocused) {
|
|
4233
4411
|
setLocalValue(value);
|
|
4234
4412
|
}
|
|
4235
4413
|
}, [value]);
|
|
4236
|
-
(0,
|
|
4414
|
+
(0, import_react21.useEffect)(() => {
|
|
4237
4415
|
if (!isFocused) {
|
|
4238
4416
|
if (value !== localValue) {
|
|
4239
4417
|
setLocalValue(value);
|
|
@@ -4247,7 +4425,7 @@ function AutoFieldPrivate(props) {
|
|
|
4247
4425
|
return /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(AutoFieldInternal, __spreadValues(__spreadValues({}, props), localProps));
|
|
4248
4426
|
}
|
|
4249
4427
|
function AutoField(props) {
|
|
4250
|
-
const DefaultLabel = (0,
|
|
4428
|
+
const DefaultLabel = (0, import_react21.useMemo)(() => {
|
|
4251
4429
|
const DefaultLabel2 = (labelProps) => /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
|
|
4252
4430
|
"div",
|
|
4253
4431
|
__spreadProps(__spreadValues({}, labelProps), {
|
|
@@ -4270,25 +4448,25 @@ init_react_import();
|
|
|
4270
4448
|
var styles_module_default10 = { "Drawer": "_Drawer_pl7z0_1", "Drawer-draggable": "_Drawer-draggable_pl7z0_8", "Drawer-draggableBg": "_Drawer-draggableBg_pl7z0_12", "DrawerItem-draggable": "_DrawerItem-draggable_pl7z0_22", "DrawerItem--disabled": "_DrawerItem--disabled_pl7z0_35", "DrawerItem": "_DrawerItem_pl7z0_22", "Drawer--isDraggingFrom": "_Drawer--isDraggingFrom_pl7z0_45", "DrawerItem-name": "_DrawerItem-name_pl7z0_63" };
|
|
4271
4449
|
|
|
4272
4450
|
// components/Drawer/index.tsx
|
|
4273
|
-
var
|
|
4451
|
+
var import_react38 = require("react");
|
|
4274
4452
|
|
|
4275
4453
|
// components/DragDropContext/index.tsx
|
|
4276
4454
|
init_react_import();
|
|
4277
|
-
var
|
|
4278
|
-
var
|
|
4455
|
+
var import_react36 = require("@dnd-kit/react");
|
|
4456
|
+
var import_react37 = require("react");
|
|
4279
4457
|
var import_dom = require("@dnd-kit/dom");
|
|
4280
4458
|
|
|
4281
4459
|
// components/DropZone/index.tsx
|
|
4282
4460
|
init_react_import();
|
|
4283
|
-
var
|
|
4461
|
+
var import_react34 = require("react");
|
|
4284
4462
|
|
|
4285
4463
|
// components/DraggableComponent/index.tsx
|
|
4286
4464
|
init_react_import();
|
|
4287
|
-
var
|
|
4465
|
+
var import_react25 = require("react");
|
|
4288
4466
|
|
|
4289
4467
|
// css-module:/home/runner/work/puck/puck/packages/core/components/DraggableComponent/styles.module.css#css-module
|
|
4290
4468
|
init_react_import();
|
|
4291
|
-
var styles_module_default11 = { "DraggableComponent": "
|
|
4469
|
+
var styles_module_default11 = { "DraggableComponent": "_DraggableComponent_1vaqy_1", "DraggableComponent-overlayWrapper": "_DraggableComponent-overlayWrapper_1vaqy_12", "DraggableComponent-overlay": "_DraggableComponent-overlay_1vaqy_12", "DraggableComponent-loadingOverlay": "_DraggableComponent-loadingOverlay_1vaqy_34", "DraggableComponent--hover": "_DraggableComponent--hover_1vaqy_50", "DraggableComponent--isSelected": "_DraggableComponent--isSelected_1vaqy_57", "DraggableComponent-actionsOverlay": "_DraggableComponent-actionsOverlay_1vaqy_71", "DraggableComponent-actions": "_DraggableComponent-actions_1vaqy_71" };
|
|
4292
4470
|
|
|
4293
4471
|
// components/DraggableComponent/index.tsx
|
|
4294
4472
|
var import_react_dom2 = require("react-dom");
|
|
@@ -4314,11 +4492,11 @@ function getDeepScrollPosition(element) {
|
|
|
4314
4492
|
|
|
4315
4493
|
// components/DropZone/context.tsx
|
|
4316
4494
|
init_react_import();
|
|
4317
|
-
var
|
|
4495
|
+
var import_react22 = require("react");
|
|
4318
4496
|
var import_zustand3 = require("zustand");
|
|
4319
4497
|
var import_jsx_runtime19 = require("react/jsx-runtime");
|
|
4320
|
-
var dropZoneContext = (0,
|
|
4321
|
-
var ZoneStoreContext = (0,
|
|
4498
|
+
var dropZoneContext = (0, import_react22.createContext)(null);
|
|
4499
|
+
var ZoneStoreContext = (0, import_react22.createContext)(
|
|
4322
4500
|
(0, import_zustand3.createStore)(() => ({
|
|
4323
4501
|
zoneDepthIndex: {},
|
|
4324
4502
|
nextZoneDepthIndex: {},
|
|
@@ -4341,7 +4519,7 @@ var DropZoneProvider = ({
|
|
|
4341
4519
|
value
|
|
4342
4520
|
}) => {
|
|
4343
4521
|
const dispatch = useAppStore((s) => s.dispatch);
|
|
4344
|
-
const registerZone = (0,
|
|
4522
|
+
const registerZone = (0, import_react22.useCallback)(
|
|
4345
4523
|
(zoneCompound) => {
|
|
4346
4524
|
dispatch({
|
|
4347
4525
|
type: "registerZone",
|
|
@@ -4350,7 +4528,7 @@ var DropZoneProvider = ({
|
|
|
4350
4528
|
},
|
|
4351
4529
|
[dispatch]
|
|
4352
4530
|
);
|
|
4353
|
-
const memoValue = (0,
|
|
4531
|
+
const memoValue = (0, import_react22.useMemo)(
|
|
4354
4532
|
() => __spreadValues({
|
|
4355
4533
|
registerZone
|
|
4356
4534
|
}, value),
|
|
@@ -4360,7 +4538,7 @@ var DropZoneProvider = ({
|
|
|
4360
4538
|
};
|
|
4361
4539
|
|
|
4362
4540
|
// components/DraggableComponent/index.tsx
|
|
4363
|
-
var
|
|
4541
|
+
var import_shallow3 = require("zustand/react/shallow");
|
|
4364
4542
|
var import_sortable2 = require("@dnd-kit/react/sortable");
|
|
4365
4543
|
|
|
4366
4544
|
// lib/accumulate-transform.ts
|
|
@@ -4380,23 +4558,23 @@ function accumulateTransform(el) {
|
|
|
4380
4558
|
|
|
4381
4559
|
// lib/use-context-store.ts
|
|
4382
4560
|
init_react_import();
|
|
4383
|
-
var
|
|
4561
|
+
var import_react23 = require("react");
|
|
4384
4562
|
var import_zustand4 = require("zustand");
|
|
4385
|
-
var
|
|
4563
|
+
var import_shallow2 = require("zustand/react/shallow");
|
|
4386
4564
|
function useContextStore(context, selector) {
|
|
4387
|
-
const store = (0,
|
|
4565
|
+
const store = (0, import_react23.useContext)(context);
|
|
4388
4566
|
if (!store) {
|
|
4389
4567
|
throw new Error("useContextStore must be used inside context");
|
|
4390
4568
|
}
|
|
4391
|
-
return (0, import_zustand4.useStore)(store, (0,
|
|
4569
|
+
return (0, import_zustand4.useStore)(store, (0, import_shallow2.useShallow)(selector));
|
|
4392
4570
|
}
|
|
4393
4571
|
|
|
4394
4572
|
// lib/dnd/use-on-drag-finished.ts
|
|
4395
4573
|
init_react_import();
|
|
4396
|
-
var
|
|
4574
|
+
var import_react24 = require("react");
|
|
4397
4575
|
var useOnDragFinished = (cb, deps = []) => {
|
|
4398
4576
|
const appStore = useAppStoreApi();
|
|
4399
|
-
return (0,
|
|
4577
|
+
return (0, import_react24.useCallback)(() => {
|
|
4400
4578
|
let dispose = () => {
|
|
4401
4579
|
};
|
|
4402
4580
|
const processDragging = (isDragging2) => {
|
|
@@ -4442,6 +4620,9 @@ var DefaultActionBar = ({
|
|
|
4442
4620
|
] }),
|
|
4443
4621
|
/* @__PURE__ */ (0, import_jsx_runtime20.jsx)(ActionBar.Group, { children })
|
|
4444
4622
|
] });
|
|
4623
|
+
var DefaultOverlay = ({
|
|
4624
|
+
children
|
|
4625
|
+
}) => /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(import_jsx_runtime20.Fragment, { children });
|
|
4445
4626
|
var DraggableComponent = ({
|
|
4446
4627
|
children,
|
|
4447
4628
|
depth,
|
|
@@ -4466,9 +4647,9 @@ var DraggableComponent = ({
|
|
|
4466
4647
|
const overrides = useAppStore((s) => s.overrides);
|
|
4467
4648
|
const dispatch = useAppStore((s) => s.dispatch);
|
|
4468
4649
|
const iframe = useAppStore((s) => s.iframe);
|
|
4469
|
-
const ctx = (0,
|
|
4470
|
-
const [localZones, setLocalZones] = (0,
|
|
4471
|
-
const registerLocalZone = (0,
|
|
4650
|
+
const ctx = (0, import_react25.useContext)(dropZoneContext);
|
|
4651
|
+
const [localZones, setLocalZones] = (0, import_react25.useState)({});
|
|
4652
|
+
const registerLocalZone = (0, import_react25.useCallback)(
|
|
4472
4653
|
(zoneCompound2, active) => {
|
|
4473
4654
|
var _a;
|
|
4474
4655
|
(_a = ctx == null ? void 0 : ctx.registerLocalZone) == null ? void 0 : _a.call(ctx, zoneCompound2, active);
|
|
@@ -4478,7 +4659,7 @@ var DraggableComponent = ({
|
|
|
4478
4659
|
},
|
|
4479
4660
|
[setLocalZones]
|
|
4480
4661
|
);
|
|
4481
|
-
const unregisterLocalZone = (0,
|
|
4662
|
+
const unregisterLocalZone = (0, import_react25.useCallback)(
|
|
4482
4663
|
(zoneCompound2) => {
|
|
4483
4664
|
var _a;
|
|
4484
4665
|
(_a = ctx == null ? void 0 : ctx.unregisterLocalZone) == null ? void 0 : _a.call(ctx, zoneCompound2);
|
|
@@ -4491,19 +4672,19 @@ var DraggableComponent = ({
|
|
|
4491
4672
|
[setLocalZones]
|
|
4492
4673
|
);
|
|
4493
4674
|
const containsActiveZone = Object.values(localZones).filter(Boolean).length > 0;
|
|
4494
|
-
const path = useAppStore((0,
|
|
4675
|
+
const path = useAppStore((0, import_shallow3.useShallow)((s) => {
|
|
4495
4676
|
var _a;
|
|
4496
4677
|
return (_a = s.state.indexes.nodes[id]) == null ? void 0 : _a.path;
|
|
4497
4678
|
}));
|
|
4498
4679
|
const permissions = useAppStore(
|
|
4499
|
-
(0,
|
|
4680
|
+
(0, import_shallow3.useShallow)((s) => {
|
|
4500
4681
|
const item = getItem({ index, zone: zoneCompound }, s.state);
|
|
4501
4682
|
return s.permissions.getPermissions({ item });
|
|
4502
4683
|
})
|
|
4503
4684
|
);
|
|
4504
|
-
const zoneStore = (0,
|
|
4505
|
-
const [dragAxis, setDragAxis] = (0,
|
|
4506
|
-
const dynamicCollisionDetector = (0,
|
|
4685
|
+
const zoneStore = (0, import_react25.useContext)(ZoneStoreContext);
|
|
4686
|
+
const [dragAxis, setDragAxis] = (0, import_react25.useState)(userDragAxis || autoDragAxis);
|
|
4687
|
+
const dynamicCollisionDetector = (0, import_react25.useMemo)(
|
|
4507
4688
|
() => createDynamicCollisionDetector(dragAxis),
|
|
4508
4689
|
[dragAxis]
|
|
4509
4690
|
);
|
|
@@ -4535,7 +4716,7 @@ var DraggableComponent = ({
|
|
|
4535
4716
|
},
|
|
4536
4717
|
feedback: "clone"
|
|
4537
4718
|
});
|
|
4538
|
-
(0,
|
|
4719
|
+
(0, import_react25.useEffect)(() => {
|
|
4539
4720
|
const isEnabled = zoneStore.getState().enabledIndex[zoneCompound];
|
|
4540
4721
|
sortable.droppable.disabled = !isEnabled;
|
|
4541
4722
|
sortable.draggable.disabled = !permissions.drag;
|
|
@@ -4552,8 +4733,8 @@ var DraggableComponent = ({
|
|
|
4552
4733
|
}
|
|
4553
4734
|
return cleanup;
|
|
4554
4735
|
}, [permissions.drag, zoneCompound]);
|
|
4555
|
-
const ref = (0,
|
|
4556
|
-
const refSetter = (0,
|
|
4736
|
+
const ref = (0, import_react25.useRef)(null);
|
|
4737
|
+
const refSetter = (0, import_react25.useCallback)(
|
|
4557
4738
|
(el) => {
|
|
4558
4739
|
sortableRef(el);
|
|
4559
4740
|
if (el) {
|
|
@@ -4562,14 +4743,14 @@ var DraggableComponent = ({
|
|
|
4562
4743
|
},
|
|
4563
4744
|
[sortableRef]
|
|
4564
4745
|
);
|
|
4565
|
-
const [portalEl, setPortalEl] = (0,
|
|
4566
|
-
(0,
|
|
4746
|
+
const [portalEl, setPortalEl] = (0, import_react25.useState)();
|
|
4747
|
+
(0, import_react25.useEffect)(() => {
|
|
4567
4748
|
var _a, _b, _c;
|
|
4568
4749
|
setPortalEl(
|
|
4569
4750
|
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
|
|
4570
4751
|
);
|
|
4571
4752
|
}, [iframe.enabled, ref.current]);
|
|
4572
|
-
const getStyle = (0,
|
|
4753
|
+
const getStyle = (0, import_react25.useCallback)(() => {
|
|
4573
4754
|
var _a, _b, _c;
|
|
4574
4755
|
if (!ref.current) return;
|
|
4575
4756
|
const rect = ref.current.getBoundingClientRect();
|
|
@@ -4594,11 +4775,11 @@ var DraggableComponent = ({
|
|
|
4594
4775
|
};
|
|
4595
4776
|
return style2;
|
|
4596
4777
|
}, [ref.current]);
|
|
4597
|
-
const [style, setStyle] = (0,
|
|
4598
|
-
const sync = (0,
|
|
4778
|
+
const [style, setStyle] = (0, import_react25.useState)();
|
|
4779
|
+
const sync = (0, import_react25.useCallback)(() => {
|
|
4599
4780
|
setStyle(getStyle());
|
|
4600
4781
|
}, [ref.current, iframe]);
|
|
4601
|
-
(0,
|
|
4782
|
+
(0, import_react25.useEffect)(() => {
|
|
4602
4783
|
if (ref.current) {
|
|
4603
4784
|
const observer = new ResizeObserver(sync);
|
|
4604
4785
|
observer.observe(ref.current);
|
|
@@ -4608,13 +4789,13 @@ var DraggableComponent = ({
|
|
|
4608
4789
|
}
|
|
4609
4790
|
}, [ref.current]);
|
|
4610
4791
|
const registerNode = useAppStore((s) => s.nodes.registerNode);
|
|
4611
|
-
const hideOverlay = (0,
|
|
4792
|
+
const hideOverlay = (0, import_react25.useCallback)(() => {
|
|
4612
4793
|
setIsVisible(false);
|
|
4613
4794
|
}, []);
|
|
4614
|
-
const showOverlay = (0,
|
|
4795
|
+
const showOverlay = (0, import_react25.useCallback)(() => {
|
|
4615
4796
|
setIsVisible(true);
|
|
4616
4797
|
}, []);
|
|
4617
|
-
(0,
|
|
4798
|
+
(0, import_react25.useEffect)(() => {
|
|
4618
4799
|
var _a;
|
|
4619
4800
|
registerNode(id, {
|
|
4620
4801
|
methods: { sync, showOverlay, hideOverlay },
|
|
@@ -4631,11 +4812,15 @@ var DraggableComponent = ({
|
|
|
4631
4812
|
});
|
|
4632
4813
|
};
|
|
4633
4814
|
}, [id, zoneCompound, index, componentType, sync]);
|
|
4634
|
-
const CustomActionBar = (0,
|
|
4815
|
+
const CustomActionBar = (0, import_react25.useMemo)(
|
|
4635
4816
|
() => overrides.actionBar || DefaultActionBar,
|
|
4636
4817
|
[overrides.actionBar]
|
|
4637
4818
|
);
|
|
4638
|
-
const
|
|
4819
|
+
const CustomOverlay = (0, import_react25.useMemo)(
|
|
4820
|
+
() => overrides.componentOverlay || DefaultOverlay,
|
|
4821
|
+
[overrides.componentOverlay]
|
|
4822
|
+
);
|
|
4823
|
+
const onClick = (0, import_react25.useCallback)(
|
|
4639
4824
|
(e) => {
|
|
4640
4825
|
e.stopPropagation();
|
|
4641
4826
|
dispatch({
|
|
@@ -4648,7 +4833,7 @@ var DraggableComponent = ({
|
|
|
4648
4833
|
[index, zoneCompound, id]
|
|
4649
4834
|
);
|
|
4650
4835
|
const appStore = useAppStoreApi();
|
|
4651
|
-
const onSelectParent = (0,
|
|
4836
|
+
const onSelectParent = (0, import_react25.useCallback)(() => {
|
|
4652
4837
|
const { nodes, zones } = appStore.getState().state.indexes;
|
|
4653
4838
|
const node = nodes[id];
|
|
4654
4839
|
const parentNode = (node == null ? void 0 : node.parentId) ? nodes[node == null ? void 0 : node.parentId] : null;
|
|
@@ -4669,26 +4854,26 @@ var DraggableComponent = ({
|
|
|
4669
4854
|
}
|
|
4670
4855
|
});
|
|
4671
4856
|
}, [ctx, path]);
|
|
4672
|
-
const onDuplicate = (0,
|
|
4857
|
+
const onDuplicate = (0, import_react25.useCallback)(() => {
|
|
4673
4858
|
dispatch({
|
|
4674
4859
|
type: "duplicate",
|
|
4675
4860
|
sourceIndex: index,
|
|
4676
4861
|
sourceZone: zoneCompound
|
|
4677
4862
|
});
|
|
4678
4863
|
}, [index, zoneCompound]);
|
|
4679
|
-
const onDelete = (0,
|
|
4864
|
+
const onDelete = (0, import_react25.useCallback)(() => {
|
|
4680
4865
|
dispatch({
|
|
4681
4866
|
type: "remove",
|
|
4682
4867
|
index,
|
|
4683
4868
|
zone: zoneCompound
|
|
4684
4869
|
});
|
|
4685
4870
|
}, [index, zoneCompound]);
|
|
4686
|
-
const [hover, setHover] = (0,
|
|
4871
|
+
const [hover, setHover] = (0, import_react25.useState)(false);
|
|
4687
4872
|
const indicativeHover = useContextStore(
|
|
4688
4873
|
ZoneStoreContext,
|
|
4689
4874
|
(s) => s.hoveringComponent === id
|
|
4690
4875
|
);
|
|
4691
|
-
(0,
|
|
4876
|
+
(0, import_react25.useEffect)(() => {
|
|
4692
4877
|
if (!ref.current) {
|
|
4693
4878
|
return;
|
|
4694
4879
|
}
|
|
@@ -4733,10 +4918,10 @@ var DraggableComponent = ({
|
|
|
4733
4918
|
thisIsDragging,
|
|
4734
4919
|
inDroppableZone
|
|
4735
4920
|
]);
|
|
4736
|
-
const [isVisible, setIsVisible] = (0,
|
|
4737
|
-
const [dragFinished, setDragFinished] = (0,
|
|
4738
|
-
const [_, startTransition] = (0,
|
|
4739
|
-
(0,
|
|
4921
|
+
const [isVisible, setIsVisible] = (0, import_react25.useState)(false);
|
|
4922
|
+
const [dragFinished, setDragFinished] = (0, import_react25.useState)(true);
|
|
4923
|
+
const [_, startTransition] = (0, import_react25.useTransition)();
|
|
4924
|
+
(0, import_react25.useEffect)(() => {
|
|
4740
4925
|
startTransition(() => {
|
|
4741
4926
|
if (hover || indicativeHover || isSelected) {
|
|
4742
4927
|
sync();
|
|
@@ -4747,7 +4932,7 @@ var DraggableComponent = ({
|
|
|
4747
4932
|
}
|
|
4748
4933
|
});
|
|
4749
4934
|
}, [hover, indicativeHover, isSelected, iframe]);
|
|
4750
|
-
const [thisWasDragging, setThisWasDragging] = (0,
|
|
4935
|
+
const [thisWasDragging, setThisWasDragging] = (0, import_react25.useState)(false);
|
|
4751
4936
|
const onDragFinished = useOnDragFinished((finished) => {
|
|
4752
4937
|
if (finished) {
|
|
4753
4938
|
startTransition(() => {
|
|
@@ -4758,15 +4943,15 @@ var DraggableComponent = ({
|
|
|
4758
4943
|
setDragFinished(false);
|
|
4759
4944
|
}
|
|
4760
4945
|
});
|
|
4761
|
-
(0,
|
|
4946
|
+
(0, import_react25.useEffect)(() => {
|
|
4762
4947
|
if (thisIsDragging) {
|
|
4763
4948
|
setThisWasDragging(true);
|
|
4764
4949
|
}
|
|
4765
4950
|
}, [thisIsDragging]);
|
|
4766
|
-
(0,
|
|
4951
|
+
(0, import_react25.useEffect)(() => {
|
|
4767
4952
|
if (thisWasDragging) return onDragFinished();
|
|
4768
4953
|
}, [thisWasDragging, onDragFinished]);
|
|
4769
|
-
const syncActionsPosition = (0,
|
|
4954
|
+
const syncActionsPosition = (0, import_react25.useCallback)(
|
|
4770
4955
|
(el) => {
|
|
4771
4956
|
if (el) {
|
|
4772
4957
|
const view = el.ownerDocument.defaultView;
|
|
@@ -4791,7 +4976,7 @@ var DraggableComponent = ({
|
|
|
4791
4976
|
},
|
|
4792
4977
|
[zoom]
|
|
4793
4978
|
);
|
|
4794
|
-
(0,
|
|
4979
|
+
(0, import_react25.useEffect)(() => {
|
|
4795
4980
|
if (userDragAxis) {
|
|
4796
4981
|
setDragAxis(userDragAxis);
|
|
4797
4982
|
return;
|
|
@@ -4805,11 +4990,11 @@ var DraggableComponent = ({
|
|
|
4805
4990
|
}
|
|
4806
4991
|
setDragAxis(autoDragAxis);
|
|
4807
4992
|
}, [ref, userDragAxis, autoDragAxis]);
|
|
4808
|
-
const parentAction = (0,
|
|
4993
|
+
const parentAction = (0, import_react25.useMemo)(
|
|
4809
4994
|
() => (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 }) }),
|
|
4810
4995
|
[ctx == null ? void 0 : ctx.areaId]
|
|
4811
4996
|
);
|
|
4812
|
-
const nextContextValue = (0,
|
|
4997
|
+
const nextContextValue = (0, import_react25.useMemo)(
|
|
4813
4998
|
() => __spreadProps(__spreadValues({}, ctx), {
|
|
4814
4999
|
areaId: id,
|
|
4815
5000
|
zoneCompound,
|
|
@@ -4877,7 +5062,16 @@ var DraggableComponent = ({
|
|
|
4877
5062
|
)
|
|
4878
5063
|
}
|
|
4879
5064
|
),
|
|
4880
|
-
/* @__PURE__ */ (0, import_jsx_runtime20.jsx)("div", { className: getClassName16("
|
|
5065
|
+
/* @__PURE__ */ (0, import_jsx_runtime20.jsx)("div", { className: getClassName16("overlayWrapper"), children: /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(
|
|
5066
|
+
CustomOverlay,
|
|
5067
|
+
{
|
|
5068
|
+
componentId: id,
|
|
5069
|
+
componentType,
|
|
5070
|
+
hover,
|
|
5071
|
+
isSelected,
|
|
5072
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime20.jsx)("div", { className: getClassName16("overlay") })
|
|
5073
|
+
}
|
|
5074
|
+
) })
|
|
4881
5075
|
]
|
|
4882
5076
|
}
|
|
4883
5077
|
),
|
|
@@ -4892,11 +5086,11 @@ init_react_import();
|
|
|
4892
5086
|
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" };
|
|
4893
5087
|
|
|
4894
5088
|
// components/DropZone/index.tsx
|
|
4895
|
-
var
|
|
5089
|
+
var import_react35 = require("@dnd-kit/react");
|
|
4896
5090
|
|
|
4897
5091
|
// components/DropZone/lib/use-min-empty-height.ts
|
|
4898
5092
|
init_react_import();
|
|
4899
|
-
var
|
|
5093
|
+
var import_react26 = require("react");
|
|
4900
5094
|
var getNumItems = (appStore, zoneCompound) => appStore.getState().state.indexes.zones[zoneCompound].contentIds.length;
|
|
4901
5095
|
var useMinEmptyHeight = ({
|
|
4902
5096
|
zoneCompound,
|
|
@@ -4904,8 +5098,8 @@ var useMinEmptyHeight = ({
|
|
|
4904
5098
|
ref
|
|
4905
5099
|
}) => {
|
|
4906
5100
|
const appStore = useAppStoreApi();
|
|
4907
|
-
const [prevHeight, setPrevHeight] = (0,
|
|
4908
|
-
const [isAnimating, setIsAnimating] = (0,
|
|
5101
|
+
const [prevHeight, setPrevHeight] = (0, import_react26.useState)(0);
|
|
5102
|
+
const [isAnimating, setIsAnimating] = (0, import_react26.useState)(false);
|
|
4909
5103
|
const { draggedItem, isZone } = useContextStore(ZoneStoreContext, (s) => {
|
|
4910
5104
|
var _a, _b;
|
|
4911
5105
|
return {
|
|
@@ -4913,7 +5107,7 @@ var useMinEmptyHeight = ({
|
|
|
4913
5107
|
isZone: ((_b = s.draggedItem) == null ? void 0 : _b.data.zone) === zoneCompound
|
|
4914
5108
|
};
|
|
4915
5109
|
});
|
|
4916
|
-
const numItems = (0,
|
|
5110
|
+
const numItems = (0, import_react26.useRef)(0);
|
|
4917
5111
|
const onDragFinished = useOnDragFinished(
|
|
4918
5112
|
(finished) => {
|
|
4919
5113
|
var _a;
|
|
@@ -4948,7 +5142,7 @@ var useMinEmptyHeight = ({
|
|
|
4948
5142
|
},
|
|
4949
5143
|
[appStore, prevHeight, zoneCompound]
|
|
4950
5144
|
);
|
|
4951
|
-
(0,
|
|
5145
|
+
(0, import_react26.useEffect)(() => {
|
|
4952
5146
|
if (draggedItem && ref.current) {
|
|
4953
5147
|
if (isZone) {
|
|
4954
5148
|
const rect = ref.current.getBoundingClientRect();
|
|
@@ -4979,15 +5173,15 @@ function assignRefs(refs, node) {
|
|
|
4979
5173
|
|
|
4980
5174
|
// components/DropZone/lib/use-content-with-preview.ts
|
|
4981
5175
|
init_react_import();
|
|
4982
|
-
var
|
|
5176
|
+
var import_react29 = require("react");
|
|
4983
5177
|
|
|
4984
5178
|
// lib/dnd/use-rendered-callback.ts
|
|
4985
5179
|
init_react_import();
|
|
4986
|
-
var
|
|
4987
|
-
var
|
|
5180
|
+
var import_react27 = require("@dnd-kit/react");
|
|
5181
|
+
var import_react28 = require("react");
|
|
4988
5182
|
function useRenderedCallback(callback, deps) {
|
|
4989
|
-
const manager = (0,
|
|
4990
|
-
return (0,
|
|
5183
|
+
const manager = (0, import_react27.useDragDropManager)();
|
|
5184
|
+
return (0, import_react28.useCallback)(
|
|
4991
5185
|
(...args) => __async(this, null, function* () {
|
|
4992
5186
|
yield manager == null ? void 0 : manager.renderer.rendering;
|
|
4993
5187
|
return callback(...args);
|
|
@@ -4998,14 +5192,14 @@ function useRenderedCallback(callback, deps) {
|
|
|
4998
5192
|
|
|
4999
5193
|
// components/DropZone/lib/use-content-with-preview.ts
|
|
5000
5194
|
var useContentIdsWithPreview = (contentIds, zoneCompound) => {
|
|
5001
|
-
const zoneStore = (0,
|
|
5195
|
+
const zoneStore = (0, import_react29.useContext)(ZoneStoreContext);
|
|
5002
5196
|
const preview = useContextStore(
|
|
5003
5197
|
ZoneStoreContext,
|
|
5004
5198
|
(s) => s.previewIndex[zoneCompound]
|
|
5005
5199
|
);
|
|
5006
5200
|
const isDragging = useAppStore((s) => s.state.ui.isDragging);
|
|
5007
|
-
const [contentIdsWithPreview, setContentIdsWithPreview] = (0,
|
|
5008
|
-
const [localPreview, setLocalPreview] = (0,
|
|
5201
|
+
const [contentIdsWithPreview, setContentIdsWithPreview] = (0, import_react29.useState)(contentIds);
|
|
5202
|
+
const [localPreview, setLocalPreview] = (0, import_react29.useState)(
|
|
5009
5203
|
preview
|
|
5010
5204
|
);
|
|
5011
5205
|
const updateContent = useRenderedCallback(
|
|
@@ -5040,7 +5234,7 @@ var useContentIdsWithPreview = (contentIds, zoneCompound) => {
|
|
|
5040
5234
|
},
|
|
5041
5235
|
[]
|
|
5042
5236
|
);
|
|
5043
|
-
(0,
|
|
5237
|
+
(0, import_react29.useEffect)(() => {
|
|
5044
5238
|
var _a;
|
|
5045
5239
|
const s = zoneStore.getState();
|
|
5046
5240
|
const draggedItemId = (_a = s.draggedItem) == null ? void 0 : _a.id;
|
|
@@ -5058,16 +5252,16 @@ var useContentIdsWithPreview = (contentIds, zoneCompound) => {
|
|
|
5058
5252
|
|
|
5059
5253
|
// components/DropZone/lib/use-drag-axis.ts
|
|
5060
5254
|
init_react_import();
|
|
5061
|
-
var
|
|
5255
|
+
var import_react30 = require("react");
|
|
5062
5256
|
var GRID_DRAG_AXIS = "dynamic";
|
|
5063
5257
|
var FLEX_ROW_DRAG_AXIS = "x";
|
|
5064
5258
|
var DEFAULT_DRAG_AXIS = "y";
|
|
5065
5259
|
var useDragAxis = (ref, collisionAxis) => {
|
|
5066
5260
|
const status = useAppStore((s) => s.status);
|
|
5067
|
-
const [dragAxis, setDragAxis] = (0,
|
|
5261
|
+
const [dragAxis, setDragAxis] = (0, import_react30.useState)(
|
|
5068
5262
|
collisionAxis || DEFAULT_DRAG_AXIS
|
|
5069
5263
|
);
|
|
5070
|
-
const calculateDragAxis = (0,
|
|
5264
|
+
const calculateDragAxis = (0, import_react30.useCallback)(() => {
|
|
5071
5265
|
if (ref.current) {
|
|
5072
5266
|
const computedStyle = window.getComputedStyle(ref.current);
|
|
5073
5267
|
if (computedStyle.display === "grid") {
|
|
@@ -5079,7 +5273,7 @@ var useDragAxis = (ref, collisionAxis) => {
|
|
|
5079
5273
|
}
|
|
5080
5274
|
}
|
|
5081
5275
|
}, [ref.current]);
|
|
5082
|
-
(0,
|
|
5276
|
+
(0, import_react30.useEffect)(() => {
|
|
5083
5277
|
const onViewportChange = () => {
|
|
5084
5278
|
calculateDragAxis();
|
|
5085
5279
|
};
|
|
@@ -5088,21 +5282,21 @@ var useDragAxis = (ref, collisionAxis) => {
|
|
|
5088
5282
|
window.removeEventListener("viewportchange", onViewportChange);
|
|
5089
5283
|
};
|
|
5090
5284
|
}, []);
|
|
5091
|
-
(0,
|
|
5285
|
+
(0, import_react30.useEffect)(calculateDragAxis, [status, collisionAxis]);
|
|
5092
5286
|
return [dragAxis, calculateDragAxis];
|
|
5093
5287
|
};
|
|
5094
5288
|
|
|
5095
5289
|
// components/DropZone/index.tsx
|
|
5096
|
-
var
|
|
5290
|
+
var import_shallow5 = require("zustand/react/shallow");
|
|
5097
5291
|
|
|
5098
5292
|
// components/Render/index.tsx
|
|
5099
5293
|
init_react_import();
|
|
5100
5294
|
|
|
5101
5295
|
// lib/use-slots.tsx
|
|
5102
5296
|
init_react_import();
|
|
5103
|
-
var
|
|
5297
|
+
var import_react31 = require("react");
|
|
5104
5298
|
function useSlots(config, item, renderSlotEdit, renderSlotRender = renderSlotEdit, readOnly, forceReadOnly) {
|
|
5105
|
-
const slotProps = (0,
|
|
5299
|
+
const slotProps = (0, import_react31.useMemo)(() => {
|
|
5106
5300
|
const mapped = mapSlots(
|
|
5107
5301
|
item,
|
|
5108
5302
|
(content, _parentId, propName, field, propPath) => {
|
|
@@ -5122,7 +5316,7 @@ function useSlots(config, item, renderSlotEdit, renderSlotRender = renderSlotEdi
|
|
|
5122
5316
|
).props;
|
|
5123
5317
|
return mapped;
|
|
5124
5318
|
}, [config, item, readOnly, forceReadOnly]);
|
|
5125
|
-
const mergedProps = (0,
|
|
5319
|
+
const mergedProps = (0, import_react31.useMemo)(
|
|
5126
5320
|
() => __spreadValues(__spreadValues({}, item.props), slotProps),
|
|
5127
5321
|
[item.props, slotProps]
|
|
5128
5322
|
);
|
|
@@ -5130,15 +5324,15 @@ function useSlots(config, item, renderSlotEdit, renderSlotRender = renderSlotEdi
|
|
|
5130
5324
|
}
|
|
5131
5325
|
|
|
5132
5326
|
// components/Render/index.tsx
|
|
5133
|
-
var
|
|
5327
|
+
var import_react33 = __toESM(require("react"));
|
|
5134
5328
|
|
|
5135
5329
|
// components/SlotRender/index.tsx
|
|
5136
5330
|
init_react_import();
|
|
5137
|
-
var
|
|
5331
|
+
var import_shallow4 = require("zustand/react/shallow");
|
|
5138
5332
|
|
|
5139
5333
|
// components/SlotRender/server.tsx
|
|
5140
5334
|
init_react_import();
|
|
5141
|
-
var
|
|
5335
|
+
var import_react32 = require("react");
|
|
5142
5336
|
|
|
5143
5337
|
// components/ServerRender/index.tsx
|
|
5144
5338
|
init_react_import();
|
|
@@ -5207,7 +5401,7 @@ var Item = ({
|
|
|
5207
5401
|
})
|
|
5208
5402
|
);
|
|
5209
5403
|
};
|
|
5210
|
-
var SlotRender = (0,
|
|
5404
|
+
var SlotRender = (0, import_react32.forwardRef)(
|
|
5211
5405
|
function SlotRenderInternal({ className, style, content, config, metadata }, ref) {
|
|
5212
5406
|
return /* @__PURE__ */ (0, import_jsx_runtime22.jsx)("div", { className, style, ref, children: content.map((item) => {
|
|
5213
5407
|
if (!config.components[item.type]) {
|
|
@@ -5235,7 +5429,7 @@ var ContextSlotRender = ({
|
|
|
5235
5429
|
const config = useAppStore((s) => s.config);
|
|
5236
5430
|
const metadata = useAppStore((s) => s.metadata);
|
|
5237
5431
|
const slotContent = useAppStore(
|
|
5238
|
-
(0,
|
|
5432
|
+
(0, import_shallow4.useShallow)((s) => {
|
|
5239
5433
|
var _a, _b;
|
|
5240
5434
|
const indexes = s.state.indexes;
|
|
5241
5435
|
const contentIds = (_b = (_a = indexes.zones[`${componentId}:${zone}`]) == null ? void 0 : _a.contentIds) != null ? _b : [];
|
|
@@ -5255,7 +5449,7 @@ var ContextSlotRender = ({
|
|
|
5255
5449
|
|
|
5256
5450
|
// components/Render/index.tsx
|
|
5257
5451
|
var import_jsx_runtime24 = require("react/jsx-runtime");
|
|
5258
|
-
var renderContext =
|
|
5452
|
+
var renderContext = import_react33.default.createContext({
|
|
5259
5453
|
config: { components: {} },
|
|
5260
5454
|
data: { root: {}, content: [] },
|
|
5261
5455
|
metadata: {}
|
|
@@ -5288,7 +5482,7 @@ function Render({
|
|
|
5288
5482
|
{ type: "root", props: pageProps },
|
|
5289
5483
|
(props) => /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(SlotRender, __spreadProps(__spreadValues({}, props), { config, metadata }))
|
|
5290
5484
|
);
|
|
5291
|
-
const nextContextValue = (0,
|
|
5485
|
+
const nextContextValue = (0, import_react33.useMemo)(
|
|
5292
5486
|
() => ({
|
|
5293
5487
|
mode: "render",
|
|
5294
5488
|
depth: 0
|
|
@@ -5317,11 +5511,11 @@ var DropZoneChild = ({
|
|
|
5317
5511
|
}) => {
|
|
5318
5512
|
var _a, _b;
|
|
5319
5513
|
const metadata = useAppStore((s) => s.metadata);
|
|
5320
|
-
const ctx = (0,
|
|
5514
|
+
const ctx = (0, import_react34.useContext)(dropZoneContext);
|
|
5321
5515
|
const { depth = 1 } = ctx != null ? ctx : {};
|
|
5322
|
-
const zoneStore = (0,
|
|
5516
|
+
const zoneStore = (0, import_react34.useContext)(ZoneStoreContext);
|
|
5323
5517
|
const nodeProps = useAppStore(
|
|
5324
|
-
(0,
|
|
5518
|
+
(0, import_shallow5.useShallow)((s) => {
|
|
5325
5519
|
var _a2;
|
|
5326
5520
|
return (_a2 = s.state.indexes.nodes[componentId]) == null ? void 0 : _a2.flatData.props;
|
|
5327
5521
|
})
|
|
@@ -5333,13 +5527,13 @@ var DropZoneChild = ({
|
|
|
5333
5527
|
}
|
|
5334
5528
|
);
|
|
5335
5529
|
const nodeReadOnly = useAppStore(
|
|
5336
|
-
(0,
|
|
5530
|
+
(0, import_shallow5.useShallow)((s) => {
|
|
5337
5531
|
var _a2;
|
|
5338
5532
|
return (_a2 = s.state.indexes.nodes[componentId]) == null ? void 0 : _a2.data.readOnly;
|
|
5339
5533
|
})
|
|
5340
5534
|
);
|
|
5341
5535
|
const appStore = useAppStoreApi();
|
|
5342
|
-
const item = (0,
|
|
5536
|
+
const item = (0, import_react34.useMemo)(() => {
|
|
5343
5537
|
if (nodeProps) {
|
|
5344
5538
|
const expanded = expandNode({
|
|
5345
5539
|
type: nodeType,
|
|
@@ -5361,7 +5555,7 @@ var DropZoneChild = ({
|
|
|
5361
5555
|
const componentConfig = useAppStore(
|
|
5362
5556
|
(s) => (item == null ? void 0 : item.type) ? s.config.components[item.type] : null
|
|
5363
5557
|
);
|
|
5364
|
-
const puckProps = (0,
|
|
5558
|
+
const puckProps = (0, import_react34.useMemo)(
|
|
5365
5559
|
() => ({
|
|
5366
5560
|
renderDropZone: DropZoneEditPure,
|
|
5367
5561
|
isEditing: true,
|
|
@@ -5384,19 +5578,20 @@ var DropZoneChild = ({
|
|
|
5384
5578
|
}
|
|
5385
5579
|
);
|
|
5386
5580
|
let label = (_b = (_a = componentConfig == null ? void 0 : componentConfig.label) != null ? _a : item == null ? void 0 : item.type.toString()) != null ? _b : "Component";
|
|
5387
|
-
const renderPreview = (0,
|
|
5581
|
+
const renderPreview = (0, import_react34.useMemo)(
|
|
5388
5582
|
() => function Preview3() {
|
|
5583
|
+
var _a2;
|
|
5389
5584
|
if (item && "element" in item && item.element) {
|
|
5390
5585
|
return (
|
|
5391
5586
|
// Safe to use this since the HTML is set by the user
|
|
5392
5587
|
/* @__PURE__ */ (0, import_jsx_runtime25.jsx)("div", { dangerouslySetInnerHTML: { __html: item.element.outerHTML } })
|
|
5393
5588
|
);
|
|
5394
5589
|
}
|
|
5395
|
-
return /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(DrawerItemInner, { name: label, children: overrides.componentItem });
|
|
5590
|
+
return /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(DrawerItemInner, { name: label, children: (_a2 = overrides.componentItem) != null ? _a2 : overrides.drawerItem });
|
|
5396
5591
|
},
|
|
5397
5592
|
[componentId, label, overrides]
|
|
5398
5593
|
);
|
|
5399
|
-
const defaultsProps = (0,
|
|
5594
|
+
const defaultsProps = (0, import_react34.useMemo)(
|
|
5400
5595
|
() => __spreadProps(__spreadValues(__spreadValues({}, componentConfig == null ? void 0 : componentConfig.defaultProps), item == null ? void 0 : item.props), {
|
|
5401
5596
|
puck: puckProps,
|
|
5402
5597
|
editMode: true
|
|
@@ -5404,7 +5599,7 @@ var DropZoneChild = ({
|
|
|
5404
5599
|
}),
|
|
5405
5600
|
[componentConfig == null ? void 0 : componentConfig.defaultProps, item == null ? void 0 : item.props, puckProps]
|
|
5406
5601
|
);
|
|
5407
|
-
const defaultedNode = (0,
|
|
5602
|
+
const defaultedNode = (0, import_react34.useMemo)(
|
|
5408
5603
|
() => {
|
|
5409
5604
|
var _a2;
|
|
5410
5605
|
return { type: (_a2 = item == null ? void 0 : item.type) != null ? _a2 : nodeType, props: defaultsProps };
|
|
@@ -5455,8 +5650,8 @@ var DropZoneChild = ({
|
|
|
5455
5650
|
}
|
|
5456
5651
|
);
|
|
5457
5652
|
};
|
|
5458
|
-
var DropZoneChildMemo = (0,
|
|
5459
|
-
var DropZoneEdit = (0,
|
|
5653
|
+
var DropZoneChildMemo = (0, import_react34.memo)(DropZoneChild);
|
|
5654
|
+
var DropZoneEdit = (0, import_react34.forwardRef)(
|
|
5460
5655
|
function DropZoneEditInternal({
|
|
5461
5656
|
zone,
|
|
5462
5657
|
allow,
|
|
@@ -5466,7 +5661,7 @@ var DropZoneEdit = (0, import_react35.forwardRef)(
|
|
|
5466
5661
|
minEmptyHeight: userMinEmptyHeight = 128,
|
|
5467
5662
|
collisionAxis
|
|
5468
5663
|
}, userRef) {
|
|
5469
|
-
const ctx = (0,
|
|
5664
|
+
const ctx = (0, import_react34.useContext)(dropZoneContext);
|
|
5470
5665
|
const appStoreApi = useAppStoreApi();
|
|
5471
5666
|
const {
|
|
5472
5667
|
// These all need setting via context
|
|
@@ -5476,7 +5671,7 @@ var DropZoneEdit = (0, import_react35.forwardRef)(
|
|
|
5476
5671
|
unregisterLocalZone
|
|
5477
5672
|
} = ctx != null ? ctx : {};
|
|
5478
5673
|
const path = useAppStore(
|
|
5479
|
-
(0,
|
|
5674
|
+
(0, import_shallow5.useShallow)((s) => {
|
|
5480
5675
|
var _a;
|
|
5481
5676
|
return areaId ? (_a = s.state.indexes.nodes[areaId]) == null ? void 0 : _a.path : null;
|
|
5482
5677
|
})
|
|
@@ -5493,25 +5688,25 @@ var DropZoneEdit = (0, import_react35.forwardRef)(
|
|
|
5493
5688
|
(s) => s.nextAreaDepthIndex[areaId || ""]
|
|
5494
5689
|
);
|
|
5495
5690
|
const zoneContentIds = useAppStore(
|
|
5496
|
-
(0,
|
|
5691
|
+
(0, import_shallow5.useShallow)((s) => {
|
|
5497
5692
|
var _a;
|
|
5498
5693
|
return (_a = s.state.indexes.zones[zoneCompound]) == null ? void 0 : _a.contentIds;
|
|
5499
5694
|
})
|
|
5500
5695
|
);
|
|
5501
5696
|
const zoneType = useAppStore(
|
|
5502
|
-
(0,
|
|
5697
|
+
(0, import_shallow5.useShallow)((s) => {
|
|
5503
5698
|
var _a;
|
|
5504
5699
|
return (_a = s.state.indexes.zones[zoneCompound]) == null ? void 0 : _a.type;
|
|
5505
5700
|
})
|
|
5506
5701
|
);
|
|
5507
|
-
(0,
|
|
5702
|
+
(0, import_react34.useEffect)(() => {
|
|
5508
5703
|
if (!zoneType || zoneType === "dropzone") {
|
|
5509
5704
|
if (ctx == null ? void 0 : ctx.registerZone) {
|
|
5510
5705
|
ctx == null ? void 0 : ctx.registerZone(zoneCompound);
|
|
5511
5706
|
}
|
|
5512
5707
|
}
|
|
5513
5708
|
}, [zoneType, appStoreApi]);
|
|
5514
|
-
(0,
|
|
5709
|
+
(0, import_react34.useEffect)(() => {
|
|
5515
5710
|
if (zoneType === "dropzone") {
|
|
5516
5711
|
if (zoneCompound !== rootDroppableId) {
|
|
5517
5712
|
console.warn(
|
|
@@ -5520,11 +5715,11 @@ var DropZoneEdit = (0, import_react35.forwardRef)(
|
|
|
5520
5715
|
}
|
|
5521
5716
|
}
|
|
5522
5717
|
}, [zoneType]);
|
|
5523
|
-
const contentIds = (0,
|
|
5718
|
+
const contentIds = (0, import_react34.useMemo)(() => {
|
|
5524
5719
|
return zoneContentIds || [];
|
|
5525
5720
|
}, [zoneContentIds]);
|
|
5526
|
-
const ref = (0,
|
|
5527
|
-
const acceptsTarget = (0,
|
|
5721
|
+
const ref = (0, import_react34.useRef)(null);
|
|
5722
|
+
const acceptsTarget = (0, import_react34.useCallback)(
|
|
5528
5723
|
(componentType) => {
|
|
5529
5724
|
if (!componentType) {
|
|
5530
5725
|
return true;
|
|
@@ -5562,7 +5757,7 @@ var DropZoneEdit = (0, import_react35.forwardRef)(
|
|
|
5562
5757
|
}
|
|
5563
5758
|
return _isEnabled;
|
|
5564
5759
|
});
|
|
5565
|
-
(0,
|
|
5760
|
+
(0, import_react34.useEffect)(() => {
|
|
5566
5761
|
if (registerLocalZone) {
|
|
5567
5762
|
registerLocalZone(zoneCompound, targetAccepted || isEnabled);
|
|
5568
5763
|
}
|
|
@@ -5577,8 +5772,8 @@ var DropZoneEdit = (0, import_react35.forwardRef)(
|
|
|
5577
5772
|
zoneCompound
|
|
5578
5773
|
);
|
|
5579
5774
|
const isDropEnabled = isEnabled && (preview ? contentIdsWithPreview.length === 1 : contentIdsWithPreview.length === 0);
|
|
5580
|
-
const zoneStore = (0,
|
|
5581
|
-
(0,
|
|
5775
|
+
const zoneStore = (0, import_react34.useContext)(ZoneStoreContext);
|
|
5776
|
+
(0, import_react34.useEffect)(() => {
|
|
5582
5777
|
const { enabledIndex } = zoneStore.getState();
|
|
5583
5778
|
zoneStore.setState({
|
|
5584
5779
|
enabledIndex: __spreadProps(__spreadValues({}, enabledIndex), { [zoneCompound]: isEnabled })
|
|
@@ -5597,7 +5792,7 @@ var DropZoneEdit = (0, import_react35.forwardRef)(
|
|
|
5597
5792
|
path: path || []
|
|
5598
5793
|
}
|
|
5599
5794
|
};
|
|
5600
|
-
const { ref: dropRef } = (0,
|
|
5795
|
+
const { ref: dropRef } = (0, import_react35.useDroppable)(droppableConfig);
|
|
5601
5796
|
const isAreaSelected = useAppStore(
|
|
5602
5797
|
(s) => (s == null ? void 0 : s.selectedItem) && areaId === (s == null ? void 0 : s.selectedItem.props.id)
|
|
5603
5798
|
);
|
|
@@ -5652,7 +5847,7 @@ var DropZoneRenderItem = ({
|
|
|
5652
5847
|
}) => {
|
|
5653
5848
|
const Component = config.components[item.type];
|
|
5654
5849
|
const props = useSlots(config, item, (slotProps) => /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(SlotRenderPure, __spreadProps(__spreadValues({}, slotProps), { config, metadata })));
|
|
5655
|
-
const nextContextValue = (0,
|
|
5850
|
+
const nextContextValue = (0, import_react34.useMemo)(
|
|
5656
5851
|
() => ({
|
|
5657
5852
|
areaId: props.id,
|
|
5658
5853
|
depth: 1
|
|
@@ -5670,14 +5865,14 @@ var DropZoneRenderItem = ({
|
|
|
5670
5865
|
) }, props.id);
|
|
5671
5866
|
};
|
|
5672
5867
|
var DropZoneRenderPure = (props) => /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(DropZoneRender2, __spreadValues({}, props));
|
|
5673
|
-
var DropZoneRender2 = (0,
|
|
5868
|
+
var DropZoneRender2 = (0, import_react34.forwardRef)(
|
|
5674
5869
|
function DropZoneRenderInternal({ className, style, zone }, ref) {
|
|
5675
|
-
const ctx = (0,
|
|
5870
|
+
const ctx = (0, import_react34.useContext)(dropZoneContext);
|
|
5676
5871
|
const { areaId = "root" } = ctx || {};
|
|
5677
|
-
const { config, data, metadata } = (0,
|
|
5872
|
+
const { config, data, metadata } = (0, import_react34.useContext)(renderContext);
|
|
5678
5873
|
let zoneCompound = `${areaId}:${zone}`;
|
|
5679
5874
|
let content = (data == null ? void 0 : data.content) || [];
|
|
5680
|
-
(0,
|
|
5875
|
+
(0, import_react34.useEffect)(() => {
|
|
5681
5876
|
if (!content) {
|
|
5682
5877
|
if (ctx == null ? void 0 : ctx.registerZone) {
|
|
5683
5878
|
ctx == null ? void 0 : ctx.registerZone(zoneCompound);
|
|
@@ -5708,9 +5903,9 @@ var DropZoneRender2 = (0, import_react35.forwardRef)(
|
|
|
5708
5903
|
}
|
|
5709
5904
|
);
|
|
5710
5905
|
var DropZonePure = (props) => /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(DropZone, __spreadValues({}, props));
|
|
5711
|
-
var DropZone = (0,
|
|
5906
|
+
var DropZone = (0, import_react34.forwardRef)(
|
|
5712
5907
|
function DropZone2(props, ref) {
|
|
5713
|
-
const ctx = (0,
|
|
5908
|
+
const ctx = (0, import_react34.useContext)(dropZoneContext);
|
|
5714
5909
|
if ((ctx == null ? void 0 : ctx.mode) === "edit") {
|
|
5715
5910
|
return /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(import_jsx_runtime25.Fragment, { children: /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(DropZoneEdit, __spreadProps(__spreadValues({}, props), { ref })) });
|
|
5716
5911
|
}
|
|
@@ -6052,12 +6247,12 @@ function getDeepDir(el) {
|
|
|
6052
6247
|
var import_state = require("@dnd-kit/state");
|
|
6053
6248
|
var import_jsx_runtime26 = require("react/jsx-runtime");
|
|
6054
6249
|
var DEBUG3 = false;
|
|
6055
|
-
var dragListenerContext = (0,
|
|
6250
|
+
var dragListenerContext = (0, import_react37.createContext)({
|
|
6056
6251
|
dragListeners: {}
|
|
6057
6252
|
});
|
|
6058
6253
|
function useDragListener(type, fn, deps = []) {
|
|
6059
|
-
const { setDragListeners } = (0,
|
|
6060
|
-
(0,
|
|
6254
|
+
const { setDragListeners } = (0, import_react37.useContext)(dragListenerContext);
|
|
6255
|
+
(0, import_react37.useEffect)(() => {
|
|
6061
6256
|
if (setDragListeners) {
|
|
6062
6257
|
setDragListeners((old) => __spreadProps(__spreadValues({}, old), {
|
|
6063
6258
|
[type]: [...old[type] || [], fn]
|
|
@@ -6067,8 +6262,8 @@ function useDragListener(type, fn, deps = []) {
|
|
|
6067
6262
|
}
|
|
6068
6263
|
var AREA_CHANGE_DEBOUNCE_MS = 100;
|
|
6069
6264
|
var useTempDisableFallback = (timeout3) => {
|
|
6070
|
-
const lastFallbackDisable = (0,
|
|
6071
|
-
return (0,
|
|
6265
|
+
const lastFallbackDisable = (0, import_react37.useRef)(null);
|
|
6266
|
+
return (0, import_react37.useCallback)((manager) => {
|
|
6072
6267
|
collisionStore.setState({ fallbackEnabled: false });
|
|
6073
6268
|
const fallbackId = generateId();
|
|
6074
6269
|
lastFallbackDisable.current = fallbackId;
|
|
@@ -6087,9 +6282,9 @@ var DragDropContextClient = ({
|
|
|
6087
6282
|
const dispatch = useAppStore((s) => s.dispatch);
|
|
6088
6283
|
const appStore = useAppStoreApi();
|
|
6089
6284
|
const id = useSafeId();
|
|
6090
|
-
const debouncedParamsRef = (0,
|
|
6285
|
+
const debouncedParamsRef = (0, import_react37.useRef)(null);
|
|
6091
6286
|
const tempDisableFallback = useTempDisableFallback(100);
|
|
6092
|
-
const [zoneStore] = (0,
|
|
6287
|
+
const [zoneStore] = (0, import_react37.useState)(
|
|
6093
6288
|
() => (0, import_zustand5.createStore)(() => ({
|
|
6094
6289
|
zoneDepthIndex: {},
|
|
6095
6290
|
nextZoneDepthIndex: {},
|
|
@@ -6101,7 +6296,7 @@ var DragDropContextClient = ({
|
|
|
6101
6296
|
hoveringComponent: null
|
|
6102
6297
|
}))
|
|
6103
6298
|
);
|
|
6104
|
-
const getChanged2 = (0,
|
|
6299
|
+
const getChanged2 = (0, import_react37.useCallback)(
|
|
6105
6300
|
(params, id2) => {
|
|
6106
6301
|
const { zoneDepthIndex = {}, areaDepthIndex = {} } = zoneStore.getState() || {};
|
|
6107
6302
|
const stateHasZone = Object.keys(zoneDepthIndex).length > 0;
|
|
@@ -6122,7 +6317,7 @@ var DragDropContextClient = ({
|
|
|
6122
6317
|
},
|
|
6123
6318
|
[zoneStore]
|
|
6124
6319
|
);
|
|
6125
|
-
const setDeepestAndCollide = (0,
|
|
6320
|
+
const setDeepestAndCollide = (0, import_react37.useCallback)(
|
|
6126
6321
|
(params, manager) => {
|
|
6127
6322
|
const { zoneChanged, areaChanged } = getChanged2(params, id);
|
|
6128
6323
|
if (!zoneChanged && !areaChanged) return;
|
|
@@ -6146,7 +6341,7 @@ var DragDropContextClient = ({
|
|
|
6146
6341
|
setDeepestDb.cancel();
|
|
6147
6342
|
debouncedParamsRef.current = null;
|
|
6148
6343
|
};
|
|
6149
|
-
(0,
|
|
6344
|
+
(0, import_react37.useEffect)(() => {
|
|
6150
6345
|
if (DEBUG3) {
|
|
6151
6346
|
zoneStore.subscribe(
|
|
6152
6347
|
(s) => {
|
|
@@ -6160,7 +6355,7 @@ var DragDropContextClient = ({
|
|
|
6160
6355
|
);
|
|
6161
6356
|
}
|
|
6162
6357
|
}, []);
|
|
6163
|
-
const [plugins] = (0,
|
|
6358
|
+
const [plugins] = (0, import_react37.useState)(() => [
|
|
6164
6359
|
...disableAutoScroll ? import_dom.defaultPreset.plugins.filter((plugin) => plugin !== import_dom.AutoScroller) : import_dom.defaultPreset.plugins,
|
|
6165
6360
|
createNestedDroppablePlugin(
|
|
6166
6361
|
{
|
|
@@ -6208,10 +6403,10 @@ var DragDropContextClient = ({
|
|
|
6208
6403
|
)
|
|
6209
6404
|
]);
|
|
6210
6405
|
const sensors = useSensors();
|
|
6211
|
-
const [dragListeners, setDragListeners] = (0,
|
|
6212
|
-
const dragMode = (0,
|
|
6213
|
-
const initialSelector = (0,
|
|
6214
|
-
const nextContextValue = (0,
|
|
6406
|
+
const [dragListeners, setDragListeners] = (0, import_react37.useState)({});
|
|
6407
|
+
const dragMode = (0, import_react37.useRef)(null);
|
|
6408
|
+
const initialSelector = (0, import_react37.useRef)(void 0);
|
|
6409
|
+
const nextContextValue = (0, import_react37.useMemo)(
|
|
6215
6410
|
() => ({
|
|
6216
6411
|
mode: "edit",
|
|
6217
6412
|
areaId: "root",
|
|
@@ -6227,7 +6422,7 @@ var DragDropContextClient = ({
|
|
|
6227
6422
|
setDragListeners
|
|
6228
6423
|
},
|
|
6229
6424
|
children: /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(
|
|
6230
|
-
|
|
6425
|
+
import_react36.DragDropProvider,
|
|
6231
6426
|
{
|
|
6232
6427
|
plugins,
|
|
6233
6428
|
sensors,
|
|
@@ -6460,7 +6655,7 @@ var DragDropContext = ({
|
|
|
6460
6655
|
};
|
|
6461
6656
|
|
|
6462
6657
|
// components/Drawer/index.tsx
|
|
6463
|
-
var
|
|
6658
|
+
var import_react39 = require("@dnd-kit/react");
|
|
6464
6659
|
var import_jsx_runtime27 = require("react/jsx-runtime");
|
|
6465
6660
|
var getClassName18 = get_class_name_factory_default("Drawer", styles_module_default10);
|
|
6466
6661
|
var getClassNameItem2 = get_class_name_factory_default("DrawerItem", styles_module_default10);
|
|
@@ -6471,7 +6666,7 @@ var DrawerItemInner = ({
|
|
|
6471
6666
|
dragRef,
|
|
6472
6667
|
isDragDisabled
|
|
6473
6668
|
}) => {
|
|
6474
|
-
const CustomInner = (0,
|
|
6669
|
+
const CustomInner = (0, import_react38.useMemo)(
|
|
6475
6670
|
() => children || (({ children: children2 }) => /* @__PURE__ */ (0, import_jsx_runtime27.jsx)("div", { className: getClassNameItem2("default"), children: children2 })),
|
|
6476
6671
|
[children]
|
|
6477
6672
|
);
|
|
@@ -6497,7 +6692,7 @@ var DrawerItemDraggable = ({
|
|
|
6497
6692
|
id,
|
|
6498
6693
|
isDragDisabled
|
|
6499
6694
|
}) => {
|
|
6500
|
-
const { ref } = (0,
|
|
6695
|
+
const { ref } = (0, import_react39.useDraggable)({
|
|
6501
6696
|
id,
|
|
6502
6697
|
data: { componentType: name },
|
|
6503
6698
|
disabled: isDragDisabled,
|
|
@@ -6526,7 +6721,7 @@ var DrawerItem = ({
|
|
|
6526
6721
|
isDragDisabled
|
|
6527
6722
|
}) => {
|
|
6528
6723
|
const resolvedId = id || name;
|
|
6529
|
-
const [dynamicId, setDynamicId] = (0,
|
|
6724
|
+
const [dynamicId, setDynamicId] = (0, import_react38.useState)(generateId(resolvedId));
|
|
6530
6725
|
if (typeof index !== "undefined") {
|
|
6531
6726
|
console.error(
|
|
6532
6727
|
"Warning: The `index` prop on Drawer.Item is deprecated and no longer required."
|
|
@@ -6566,7 +6761,7 @@ var Drawer = ({
|
|
|
6566
6761
|
);
|
|
6567
6762
|
}
|
|
6568
6763
|
const id = useSafeId();
|
|
6569
|
-
const { ref } = (0,
|
|
6764
|
+
const { ref } = (0, import_react39.useDroppable)({
|
|
6570
6765
|
id,
|
|
6571
6766
|
type: "void",
|
|
6572
6767
|
collisionPriority: 0
|
|
@@ -6588,7 +6783,7 @@ Drawer.Item = DrawerItem;
|
|
|
6588
6783
|
|
|
6589
6784
|
// components/Puck/index.tsx
|
|
6590
6785
|
init_react_import();
|
|
6591
|
-
var
|
|
6786
|
+
var import_react59 = require("react");
|
|
6592
6787
|
|
|
6593
6788
|
// components/SidebarSection/index.tsx
|
|
6594
6789
|
init_react_import();
|
|
@@ -6599,7 +6794,7 @@ var styles_module_default13 = { "SidebarSection": "_SidebarSection_8boj8_1", "Si
|
|
|
6599
6794
|
|
|
6600
6795
|
// lib/use-breadcrumbs.ts
|
|
6601
6796
|
init_react_import();
|
|
6602
|
-
var
|
|
6797
|
+
var import_react40 = require("react");
|
|
6603
6798
|
var useBreadcrumbs = (renderCount) => {
|
|
6604
6799
|
const selectedId = useAppStore((s) => {
|
|
6605
6800
|
var _a;
|
|
@@ -6611,7 +6806,7 @@ var useBreadcrumbs = (renderCount) => {
|
|
|
6611
6806
|
return (_a = s.state.indexes.nodes[selectedId]) == null ? void 0 : _a.path;
|
|
6612
6807
|
});
|
|
6613
6808
|
const appStore = useAppStoreApi();
|
|
6614
|
-
return (0,
|
|
6809
|
+
return (0, import_react40.useMemo)(() => {
|
|
6615
6810
|
const breadcrumbs = (path == null ? void 0 : path.map((zoneCompound) => {
|
|
6616
6811
|
var _a, _b, _c;
|
|
6617
6812
|
const [componentId] = zoneCompound.split(":");
|
|
@@ -6685,7 +6880,7 @@ var SidebarSection = ({
|
|
|
6685
6880
|
|
|
6686
6881
|
// css-module:/home/runner/work/puck/puck/packages/core/components/Puck/styles.module.css#css-module
|
|
6687
6882
|
init_react_import();
|
|
6688
|
-
var styles_module_default14 = { "Puck": "
|
|
6883
|
+
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" };
|
|
6689
6884
|
|
|
6690
6885
|
// components/Puck/components/Fields/index.tsx
|
|
6691
6886
|
init_react_import();
|
|
@@ -6695,8 +6890,8 @@ init_react_import();
|
|
|
6695
6890
|
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" };
|
|
6696
6891
|
|
|
6697
6892
|
// components/Puck/components/Fields/index.tsx
|
|
6698
|
-
var
|
|
6699
|
-
var
|
|
6893
|
+
var import_react41 = require("react");
|
|
6894
|
+
var import_shallow6 = require("zustand/react/shallow");
|
|
6700
6895
|
var import_jsx_runtime29 = require("react/jsx-runtime");
|
|
6701
6896
|
var getClassName20 = get_class_name_factory_default("PuckFields", styles_module_default15);
|
|
6702
6897
|
var DefaultFields = ({
|
|
@@ -6762,13 +6957,13 @@ var FieldsChild = ({ fieldName }) => {
|
|
|
6762
6957
|
return s.selectedItem ? `${s.selectedItem.props.id}_${field.type}_${fieldName}` : `root_${field.type}_${fieldName}`;
|
|
6763
6958
|
});
|
|
6764
6959
|
const permissions = useAppStore(
|
|
6765
|
-
(0,
|
|
6960
|
+
(0, import_shallow6.useShallow)((s) => {
|
|
6766
6961
|
const { selectedItem, permissions: permissions2 } = s;
|
|
6767
6962
|
return selectedItem ? permissions2.getPermissions({ item: selectedItem }) : permissions2.getPermissions({ root: true });
|
|
6768
6963
|
})
|
|
6769
6964
|
);
|
|
6770
6965
|
const appStore = useAppStoreApi();
|
|
6771
|
-
const onChange = (0,
|
|
6966
|
+
const onChange = (0, import_react41.useCallback)(createOnChange(fieldName, appStore), [
|
|
6772
6967
|
fieldName
|
|
6773
6968
|
]);
|
|
6774
6969
|
const { visible = true } = field != null ? field : {};
|
|
@@ -6786,7 +6981,7 @@ var FieldsChild = ({ fieldName }) => {
|
|
|
6786
6981
|
}
|
|
6787
6982
|
) }, id);
|
|
6788
6983
|
};
|
|
6789
|
-
var FieldsChildMemo = (0,
|
|
6984
|
+
var FieldsChildMemo = (0, import_react41.memo)(FieldsChild);
|
|
6790
6985
|
var FieldsInternal = ({ wrapFields = true }) => {
|
|
6791
6986
|
const overrides = useAppStore((s) => s.overrides);
|
|
6792
6987
|
const componentResolving = useAppStore((s) => {
|
|
@@ -6794,7 +6989,7 @@ var FieldsInternal = ({ wrapFields = true }) => {
|
|
|
6794
6989
|
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;
|
|
6795
6990
|
return (loadingCount != null ? loadingCount : 0) > 0;
|
|
6796
6991
|
});
|
|
6797
|
-
const itemSelector = useAppStore((0,
|
|
6992
|
+
const itemSelector = useAppStore((0, import_shallow6.useShallow)((s) => s.state.ui.itemSelector));
|
|
6798
6993
|
const id = useAppStore((s) => {
|
|
6799
6994
|
var _a;
|
|
6800
6995
|
return (_a = s.selectedItem) == null ? void 0 : _a.props.id;
|
|
@@ -6803,7 +6998,7 @@ var FieldsInternal = ({ wrapFields = true }) => {
|
|
|
6803
6998
|
useRegisterFieldsSlice(appStore, id);
|
|
6804
6999
|
const fieldsLoading = useAppStore((s) => s.fields.loading);
|
|
6805
7000
|
const fieldNames = useAppStore(
|
|
6806
|
-
(0,
|
|
7001
|
+
(0, import_shallow6.useShallow)((s) => {
|
|
6807
7002
|
if (s.fields.id === id) {
|
|
6808
7003
|
return Object.keys(s.fields.fields);
|
|
6809
7004
|
}
|
|
@@ -6811,7 +7006,7 @@ var FieldsInternal = ({ wrapFields = true }) => {
|
|
|
6811
7006
|
})
|
|
6812
7007
|
);
|
|
6813
7008
|
const isLoading = fieldsLoading || componentResolving;
|
|
6814
|
-
const Wrapper = (0,
|
|
7009
|
+
const Wrapper = (0, import_react41.useMemo)(() => overrides.fields || DefaultFields, [overrides]);
|
|
6815
7010
|
return /* @__PURE__ */ (0, import_jsx_runtime29.jsxs)(
|
|
6816
7011
|
"form",
|
|
6817
7012
|
{
|
|
@@ -6826,7 +7021,7 @@ var FieldsInternal = ({ wrapFields = true }) => {
|
|
|
6826
7021
|
}
|
|
6827
7022
|
);
|
|
6828
7023
|
};
|
|
6829
|
-
var Fields = (0,
|
|
7024
|
+
var Fields = (0, import_react41.memo)(FieldsInternal);
|
|
6830
7025
|
|
|
6831
7026
|
// components/Puck/components/Components/index.tsx
|
|
6832
7027
|
init_react_import();
|
|
@@ -6843,19 +7038,28 @@ init_react_import();
|
|
|
6843
7038
|
var styles_module_default16 = { "ComponentList": "_ComponentList_1rrlt_1", "ComponentList--isExpanded": "_ComponentList--isExpanded_1rrlt_5", "ComponentList-content": "_ComponentList-content_1rrlt_9", "ComponentList-title": "_ComponentList-title_1rrlt_17", "ComponentList-titleIcon": "_ComponentList-titleIcon_1rrlt_53" };
|
|
6844
7039
|
|
|
6845
7040
|
// components/ComponentList/index.tsx
|
|
7041
|
+
var import_react42 = require("react");
|
|
6846
7042
|
var import_jsx_runtime30 = require("react/jsx-runtime");
|
|
6847
7043
|
var getClassName21 = get_class_name_factory_default("ComponentList", styles_module_default16);
|
|
6848
7044
|
var ComponentListItem = ({
|
|
6849
7045
|
name,
|
|
6850
7046
|
label
|
|
6851
7047
|
}) => {
|
|
7048
|
+
var _a;
|
|
6852
7049
|
const overrides = useAppStore((s) => s.overrides);
|
|
6853
7050
|
const canInsert = useAppStore(
|
|
6854
7051
|
(s) => s.permissions.getPermissions({
|
|
6855
7052
|
type: name
|
|
6856
7053
|
}).insert
|
|
6857
7054
|
);
|
|
6858
|
-
|
|
7055
|
+
(0, import_react42.useEffect)(() => {
|
|
7056
|
+
if (overrides.componentItem) {
|
|
7057
|
+
console.warn(
|
|
7058
|
+
"The `componentItem` override has been deprecated and renamed to `drawerItem`"
|
|
7059
|
+
);
|
|
7060
|
+
}
|
|
7061
|
+
}, [overrides]);
|
|
7062
|
+
return /* @__PURE__ */ (0, import_jsx_runtime30.jsx)(Drawer.Item, { label, name, isDragDisabled: !canInsert, children: (_a = overrides.componentItem) != null ? _a : overrides.drawerItem });
|
|
6859
7063
|
};
|
|
6860
7064
|
var ComponentList = ({
|
|
6861
7065
|
children,
|
|
@@ -6981,7 +7185,14 @@ var import_jsx_runtime32 = require("react/jsx-runtime");
|
|
|
6981
7185
|
var Components = () => {
|
|
6982
7186
|
const overrides = useAppStore((s) => s.overrides);
|
|
6983
7187
|
const componentList = useComponentList();
|
|
6984
|
-
const Wrapper = (0, import_react44.useMemo)(() =>
|
|
7188
|
+
const Wrapper = (0, import_react44.useMemo)(() => {
|
|
7189
|
+
if (overrides.components) {
|
|
7190
|
+
console.warn(
|
|
7191
|
+
"The `components` override has been deprecated and renamed to `drawer`"
|
|
7192
|
+
);
|
|
7193
|
+
}
|
|
7194
|
+
return overrides.components || overrides.drawer || "div";
|
|
7195
|
+
}, [overrides]);
|
|
6985
7196
|
return /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(Wrapper, { children: componentList ? componentList : /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(ComponentList, { id: "all" }) });
|
|
6986
7197
|
};
|
|
6987
7198
|
|
|
@@ -7453,7 +7664,7 @@ var onScrollEnd = (frame, cb) => {
|
|
|
7453
7664
|
};
|
|
7454
7665
|
|
|
7455
7666
|
// components/LayerTree/index.tsx
|
|
7456
|
-
var
|
|
7667
|
+
var import_shallow7 = require("zustand/react/shallow");
|
|
7457
7668
|
var import_jsx_runtime35 = require("react/jsx-runtime");
|
|
7458
7669
|
var getClassName23 = get_class_name_factory_default("LayerTree", styles_module_default18);
|
|
7459
7670
|
var getClassNameLayer = get_class_name_factory_default("Layer", styles_module_default18);
|
|
@@ -7479,7 +7690,7 @@ var Layer = ({
|
|
|
7479
7690
|
const isSelected = selecedItemId === itemId || itemSelector && itemSelector.zone === rootDroppableId && !zoneCompound;
|
|
7480
7691
|
const nodeData = useAppStore((s) => s.state.indexes.nodes[itemId]);
|
|
7481
7692
|
const zonesForItem = useAppStore(
|
|
7482
|
-
(0,
|
|
7693
|
+
(0, import_shallow7.useShallow)(
|
|
7483
7694
|
(s) => Object.keys(s.state.indexes.zones).filter(
|
|
7484
7695
|
(z) => z.split(":")[0] === itemId
|
|
7485
7696
|
)
|
|
@@ -7569,203 +7780,82 @@ var Layer = ({
|
|
|
7569
7780
|
}
|
|
7570
7781
|
);
|
|
7571
7782
|
};
|
|
7572
|
-
var LayerTree = ({
|
|
7573
|
-
label: _label,
|
|
7574
|
-
zoneCompound
|
|
7575
|
-
}) => {
|
|
7576
|
-
const label = useAppStore((s) => {
|
|
7577
|
-
var _a, _b, _c, _d;
|
|
7578
|
-
if (_label) return _label;
|
|
7579
|
-
if (zoneCompound === rootDroppableId) return;
|
|
7580
|
-
const [componentId, slotId] = zoneCompound.split(":");
|
|
7581
|
-
const componentType = (_a = s.state.indexes.nodes[componentId]) == null ? void 0 : _a.data.type;
|
|
7582
|
-
const configForComponent = componentType && componentType !== rootAreaId ? s.config.components[componentType] : s.config.root;
|
|
7583
|
-
return (_d = (_c = (_b = configForComponent == null ? void 0 : configForComponent.fields) == null ? void 0 : _b[slotId]) == null ? void 0 : _c.label) != null ? _d : slotId;
|
|
7584
|
-
});
|
|
7585
|
-
const contentIds = useAppStore(
|
|
7586
|
-
(0, import_shallow6.useShallow)(
|
|
7587
|
-
(s) => {
|
|
7588
|
-
var _a, _b;
|
|
7589
|
-
return zoneCompound ? (_b = (_a = s.state.indexes.zones[zoneCompound]) == null ? void 0 : _a.contentIds) != null ? _b : [] : [];
|
|
7590
|
-
}
|
|
7591
|
-
)
|
|
7592
|
-
);
|
|
7593
|
-
return /* @__PURE__ */ (0, import_jsx_runtime35.jsxs)(import_jsx_runtime35.Fragment, { children: [
|
|
7594
|
-
label && /* @__PURE__ */ (0, import_jsx_runtime35.jsxs)("div", { className: getClassName23("zoneTitle"), children: [
|
|
7595
|
-
/* @__PURE__ */ (0, import_jsx_runtime35.jsx)("div", { className: getClassName23("zoneIcon"), children: /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(Layers, { size: "16" }) }),
|
|
7596
|
-
label
|
|
7597
|
-
] }),
|
|
7598
|
-
/* @__PURE__ */ (0, import_jsx_runtime35.jsxs)("ul", { className: getClassName23(), children: [
|
|
7599
|
-
contentIds.length === 0 && /* @__PURE__ */ (0, import_jsx_runtime35.jsx)("div", { className: getClassName23("helper"), children: "No items" }),
|
|
7600
|
-
contentIds.map((itemId, i) => {
|
|
7601
|
-
return /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(
|
|
7602
|
-
Layer,
|
|
7603
|
-
{
|
|
7604
|
-
index: i,
|
|
7605
|
-
itemId,
|
|
7606
|
-
zoneCompound
|
|
7607
|
-
},
|
|
7608
|
-
itemId
|
|
7609
|
-
);
|
|
7610
|
-
})
|
|
7611
|
-
] })
|
|
7612
|
-
] });
|
|
7613
|
-
};
|
|
7614
|
-
|
|
7615
|
-
// components/Puck/components/Outline/index.tsx
|
|
7616
|
-
var import_react48 = require("react");
|
|
7617
|
-
|
|
7618
|
-
// lib/data/find-zones-for-area.ts
|
|
7619
|
-
init_react_import();
|
|
7620
|
-
var findZonesForArea = (state, area) => {
|
|
7621
|
-
return Object.keys(state.indexes.zones).filter(
|
|
7622
|
-
(zone) => zone.split(":")[0] === area
|
|
7623
|
-
);
|
|
7624
|
-
};
|
|
7625
|
-
|
|
7626
|
-
// components/Puck/components/Outline/index.tsx
|
|
7627
|
-
var import_shallow7 = require("zustand/react/shallow");
|
|
7628
|
-
var import_jsx_runtime36 = require("react/jsx-runtime");
|
|
7629
|
-
var Outline = () => {
|
|
7630
|
-
const outlineOverride = useAppStore((s) => s.overrides.outline);
|
|
7631
|
-
const rootZones = useAppStore(
|
|
7632
|
-
(0, import_shallow7.useShallow)((s) => findZonesForArea(s.state, "root"))
|
|
7633
|
-
);
|
|
7634
|
-
const Wrapper = (0, import_react48.useMemo)(() => outlineOverride || "div", [outlineOverride]);
|
|
7635
|
-
return /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(Wrapper, { children: rootZones.map((zoneCompound) => /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(
|
|
7636
|
-
LayerTree,
|
|
7637
|
-
{
|
|
7638
|
-
label: rootZones.length === 1 ? "" : zoneCompound.split(":")[1],
|
|
7639
|
-
zoneCompound
|
|
7640
|
-
},
|
|
7641
|
-
zoneCompound
|
|
7642
|
-
)) });
|
|
7643
|
-
};
|
|
7644
|
-
|
|
7645
|
-
// components/Puck/components/Canvas/index.tsx
|
|
7646
|
-
init_react_import();
|
|
7647
|
-
|
|
7648
|
-
// ../../node_modules/css-box-model/dist/css-box-model.esm.js
|
|
7649
|
-
init_react_import();
|
|
7650
|
-
|
|
7651
|
-
// ../../node_modules/tiny-invariant/dist/esm/tiny-invariant.js
|
|
7652
|
-
init_react_import();
|
|
7653
|
-
var isProduction = process.env.NODE_ENV === "production";
|
|
7654
|
-
var prefix = "Invariant failed";
|
|
7655
|
-
function invariant(condition, message) {
|
|
7656
|
-
if (condition) {
|
|
7657
|
-
return;
|
|
7658
|
-
}
|
|
7659
|
-
if (isProduction) {
|
|
7660
|
-
throw new Error(prefix);
|
|
7661
|
-
}
|
|
7662
|
-
var provided = typeof message === "function" ? message() : message;
|
|
7663
|
-
var value = provided ? "".concat(prefix, ": ").concat(provided) : prefix;
|
|
7664
|
-
throw new Error(value);
|
|
7665
|
-
}
|
|
7666
|
-
|
|
7667
|
-
// ../../node_modules/css-box-model/dist/css-box-model.esm.js
|
|
7668
|
-
var getRect = function getRect2(_ref) {
|
|
7669
|
-
var top = _ref.top, right = _ref.right, bottom = _ref.bottom, left = _ref.left;
|
|
7670
|
-
var width = right - left;
|
|
7671
|
-
var height = bottom - top;
|
|
7672
|
-
var rect = {
|
|
7673
|
-
top,
|
|
7674
|
-
right,
|
|
7675
|
-
bottom,
|
|
7676
|
-
left,
|
|
7677
|
-
width,
|
|
7678
|
-
height,
|
|
7679
|
-
x: left,
|
|
7680
|
-
y: top,
|
|
7681
|
-
center: {
|
|
7682
|
-
x: (right + left) / 2,
|
|
7683
|
-
y: (bottom + top) / 2
|
|
7684
|
-
}
|
|
7685
|
-
};
|
|
7686
|
-
return rect;
|
|
7687
|
-
};
|
|
7688
|
-
var expand = function expand2(target, expandBy) {
|
|
7689
|
-
return {
|
|
7690
|
-
top: target.top - expandBy.top,
|
|
7691
|
-
left: target.left - expandBy.left,
|
|
7692
|
-
bottom: target.bottom + expandBy.bottom,
|
|
7693
|
-
right: target.right + expandBy.right
|
|
7694
|
-
};
|
|
7695
|
-
};
|
|
7696
|
-
var shrink = function shrink2(target, shrinkBy) {
|
|
7697
|
-
return {
|
|
7698
|
-
top: target.top + shrinkBy.top,
|
|
7699
|
-
left: target.left + shrinkBy.left,
|
|
7700
|
-
bottom: target.bottom - shrinkBy.bottom,
|
|
7701
|
-
right: target.right - shrinkBy.right
|
|
7702
|
-
};
|
|
7703
|
-
};
|
|
7704
|
-
var noSpacing = {
|
|
7705
|
-
top: 0,
|
|
7706
|
-
right: 0,
|
|
7707
|
-
bottom: 0,
|
|
7708
|
-
left: 0
|
|
7709
|
-
};
|
|
7710
|
-
var createBox = function createBox2(_ref2) {
|
|
7711
|
-
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;
|
|
7712
|
-
var marginBox = getRect(expand(borderBox, margin));
|
|
7713
|
-
var paddingBox = getRect(shrink(borderBox, border));
|
|
7714
|
-
var contentBox = getRect(shrink(paddingBox, padding));
|
|
7715
|
-
return {
|
|
7716
|
-
marginBox,
|
|
7717
|
-
borderBox: getRect(borderBox),
|
|
7718
|
-
paddingBox,
|
|
7719
|
-
contentBox,
|
|
7720
|
-
margin,
|
|
7721
|
-
border,
|
|
7722
|
-
padding
|
|
7723
|
-
};
|
|
7724
|
-
};
|
|
7725
|
-
var parse = function parse2(raw) {
|
|
7726
|
-
var value = raw.slice(0, -2);
|
|
7727
|
-
var suffix = raw.slice(-2);
|
|
7728
|
-
if (suffix !== "px") {
|
|
7729
|
-
return 0;
|
|
7730
|
-
}
|
|
7731
|
-
var result = Number(value);
|
|
7732
|
-
!!isNaN(result) ? process.env.NODE_ENV !== "production" ? invariant(false, "Could not parse value [raw: " + raw + ", without suffix: " + value + "]") : invariant(false) : void 0;
|
|
7733
|
-
return result;
|
|
7734
|
-
};
|
|
7735
|
-
var calculateBox = function calculateBox2(borderBox, styles2) {
|
|
7736
|
-
var margin = {
|
|
7737
|
-
top: parse(styles2.marginTop),
|
|
7738
|
-
right: parse(styles2.marginRight),
|
|
7739
|
-
bottom: parse(styles2.marginBottom),
|
|
7740
|
-
left: parse(styles2.marginLeft)
|
|
7741
|
-
};
|
|
7742
|
-
var padding = {
|
|
7743
|
-
top: parse(styles2.paddingTop),
|
|
7744
|
-
right: parse(styles2.paddingRight),
|
|
7745
|
-
bottom: parse(styles2.paddingBottom),
|
|
7746
|
-
left: parse(styles2.paddingLeft)
|
|
7747
|
-
};
|
|
7748
|
-
var border = {
|
|
7749
|
-
top: parse(styles2.borderTopWidth),
|
|
7750
|
-
right: parse(styles2.borderRightWidth),
|
|
7751
|
-
bottom: parse(styles2.borderBottomWidth),
|
|
7752
|
-
left: parse(styles2.borderLeftWidth)
|
|
7753
|
-
};
|
|
7754
|
-
return createBox({
|
|
7755
|
-
borderBox,
|
|
7756
|
-
margin,
|
|
7757
|
-
padding,
|
|
7758
|
-
border
|
|
7783
|
+
var LayerTree = ({
|
|
7784
|
+
label: _label,
|
|
7785
|
+
zoneCompound
|
|
7786
|
+
}) => {
|
|
7787
|
+
const label = useAppStore((s) => {
|
|
7788
|
+
var _a, _b, _c, _d;
|
|
7789
|
+
if (_label) return _label;
|
|
7790
|
+
if (zoneCompound === rootDroppableId) return;
|
|
7791
|
+
const [componentId, slotId] = zoneCompound.split(":");
|
|
7792
|
+
const componentType = (_a = s.state.indexes.nodes[componentId]) == null ? void 0 : _a.data.type;
|
|
7793
|
+
const configForComponent = componentType && componentType !== rootAreaId ? s.config.components[componentType] : s.config.root;
|
|
7794
|
+
return (_d = (_c = (_b = configForComponent == null ? void 0 : configForComponent.fields) == null ? void 0 : _b[slotId]) == null ? void 0 : _c.label) != null ? _d : slotId;
|
|
7759
7795
|
});
|
|
7796
|
+
const contentIds = useAppStore(
|
|
7797
|
+
(0, import_shallow7.useShallow)(
|
|
7798
|
+
(s) => {
|
|
7799
|
+
var _a, _b;
|
|
7800
|
+
return zoneCompound ? (_b = (_a = s.state.indexes.zones[zoneCompound]) == null ? void 0 : _a.contentIds) != null ? _b : [] : [];
|
|
7801
|
+
}
|
|
7802
|
+
)
|
|
7803
|
+
);
|
|
7804
|
+
return /* @__PURE__ */ (0, import_jsx_runtime35.jsxs)(import_jsx_runtime35.Fragment, { children: [
|
|
7805
|
+
label && /* @__PURE__ */ (0, import_jsx_runtime35.jsxs)("div", { className: getClassName23("zoneTitle"), children: [
|
|
7806
|
+
/* @__PURE__ */ (0, import_jsx_runtime35.jsx)("div", { className: getClassName23("zoneIcon"), children: /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(Layers, { size: "16" }) }),
|
|
7807
|
+
label
|
|
7808
|
+
] }),
|
|
7809
|
+
/* @__PURE__ */ (0, import_jsx_runtime35.jsxs)("ul", { className: getClassName23(), children: [
|
|
7810
|
+
contentIds.length === 0 && /* @__PURE__ */ (0, import_jsx_runtime35.jsx)("div", { className: getClassName23("helper"), children: "No items" }),
|
|
7811
|
+
contentIds.map((itemId, i) => {
|
|
7812
|
+
return /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(
|
|
7813
|
+
Layer,
|
|
7814
|
+
{
|
|
7815
|
+
index: i,
|
|
7816
|
+
itemId,
|
|
7817
|
+
zoneCompound
|
|
7818
|
+
},
|
|
7819
|
+
itemId
|
|
7820
|
+
);
|
|
7821
|
+
})
|
|
7822
|
+
] })
|
|
7823
|
+
] });
|
|
7760
7824
|
};
|
|
7761
|
-
|
|
7762
|
-
|
|
7763
|
-
|
|
7764
|
-
|
|
7825
|
+
|
|
7826
|
+
// components/Puck/components/Outline/index.tsx
|
|
7827
|
+
var import_react48 = require("react");
|
|
7828
|
+
|
|
7829
|
+
// lib/data/find-zones-for-area.ts
|
|
7830
|
+
init_react_import();
|
|
7831
|
+
var findZonesForArea = (state, area) => {
|
|
7832
|
+
return Object.keys(state.indexes.zones).filter(
|
|
7833
|
+
(zone) => zone.split(":")[0] === area
|
|
7834
|
+
);
|
|
7835
|
+
};
|
|
7836
|
+
|
|
7837
|
+
// components/Puck/components/Outline/index.tsx
|
|
7838
|
+
var import_shallow8 = require("zustand/react/shallow");
|
|
7839
|
+
var import_jsx_runtime36 = require("react/jsx-runtime");
|
|
7840
|
+
var Outline = () => {
|
|
7841
|
+
const outlineOverride = useAppStore((s) => s.overrides.outline);
|
|
7842
|
+
const rootZones = useAppStore(
|
|
7843
|
+
(0, import_shallow8.useShallow)((s) => findZonesForArea(s.state, "root"))
|
|
7844
|
+
);
|
|
7845
|
+
const Wrapper = (0, import_react48.useMemo)(() => outlineOverride || "div", [outlineOverride]);
|
|
7846
|
+
return /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(Wrapper, { children: rootZones.map((zoneCompound) => /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(
|
|
7847
|
+
LayerTree,
|
|
7848
|
+
{
|
|
7849
|
+
label: rootZones.length === 1 ? "" : zoneCompound.split(":")[1],
|
|
7850
|
+
zoneCompound
|
|
7851
|
+
},
|
|
7852
|
+
zoneCompound
|
|
7853
|
+
)) });
|
|
7765
7854
|
};
|
|
7766
7855
|
|
|
7767
7856
|
// components/Puck/components/Canvas/index.tsx
|
|
7768
|
-
|
|
7857
|
+
init_react_import();
|
|
7858
|
+
var import_react51 = require("react");
|
|
7769
7859
|
|
|
7770
7860
|
// components/ViewportControls/index.tsx
|
|
7771
7861
|
init_react_import();
|
|
@@ -7917,42 +8007,41 @@ var ViewportControls = ({
|
|
|
7917
8007
|
init_react_import();
|
|
7918
8008
|
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" };
|
|
7919
8009
|
|
|
7920
|
-
//
|
|
8010
|
+
// components/Puck/components/Canvas/index.tsx
|
|
8011
|
+
var import_shallow9 = require("zustand/react/shallow");
|
|
8012
|
+
|
|
8013
|
+
// lib/frame-context.tsx
|
|
7921
8014
|
init_react_import();
|
|
7922
|
-
var
|
|
7923
|
-
var
|
|
7924
|
-
|
|
7925
|
-
|
|
7926
|
-
|
|
7927
|
-
|
|
7928
|
-
|
|
7929
|
-
|
|
7930
|
-
|
|
7931
|
-
|
|
7932
|
-
|
|
7933
|
-
|
|
7934
|
-
|
|
7935
|
-
|
|
7936
|
-
|
|
7937
|
-
|
|
7938
|
-
|
|
7939
|
-
|
|
7940
|
-
|
|
7941
|
-
if (RESET_ZOOM_SMALLER_THAN_FRAME) {
|
|
7942
|
-
autoZoom = 1;
|
|
7943
|
-
zoom = 1;
|
|
7944
|
-
rootHeight = viewportHeight;
|
|
7945
|
-
}
|
|
8015
|
+
var import_react50 = require("react");
|
|
8016
|
+
var import_jsx_runtime38 = require("react/jsx-runtime");
|
|
8017
|
+
var FrameContext = (0, import_react50.createContext)(null);
|
|
8018
|
+
var FrameProvider = ({
|
|
8019
|
+
children
|
|
8020
|
+
}) => {
|
|
8021
|
+
const frameRef = (0, import_react50.useRef)(null);
|
|
8022
|
+
const value = (0, import_react50.useMemo)(
|
|
8023
|
+
() => ({
|
|
8024
|
+
frameRef
|
|
8025
|
+
}),
|
|
8026
|
+
[]
|
|
8027
|
+
);
|
|
8028
|
+
return /* @__PURE__ */ (0, import_jsx_runtime38.jsx)(FrameContext.Provider, { value, children });
|
|
8029
|
+
};
|
|
8030
|
+
var useCanvasFrame = () => {
|
|
8031
|
+
const context = (0, import_react50.useContext)(FrameContext);
|
|
8032
|
+
if (context === null) {
|
|
8033
|
+
throw new Error("useCanvasFrame must be used within a FrameProvider");
|
|
7946
8034
|
}
|
|
7947
|
-
return
|
|
8035
|
+
return context;
|
|
7948
8036
|
};
|
|
7949
8037
|
|
|
7950
8038
|
// components/Puck/components/Canvas/index.tsx
|
|
7951
|
-
var
|
|
7952
|
-
var import_jsx_runtime38 = require("react/jsx-runtime");
|
|
8039
|
+
var import_jsx_runtime39 = require("react/jsx-runtime");
|
|
7953
8040
|
var getClassName25 = get_class_name_factory_default("PuckCanvas", styles_module_default20);
|
|
7954
8041
|
var ZOOM_ON_CHANGE = true;
|
|
7955
8042
|
var Canvas = () => {
|
|
8043
|
+
const { frameRef } = useCanvasFrame();
|
|
8044
|
+
const resetAutoZoom = useResetAutoZoom(frameRef);
|
|
7956
8045
|
const {
|
|
7957
8046
|
dispatch,
|
|
7958
8047
|
overrides,
|
|
@@ -7962,7 +8051,7 @@ var Canvas = () => {
|
|
|
7962
8051
|
status,
|
|
7963
8052
|
iframe
|
|
7964
8053
|
} = useAppStore(
|
|
7965
|
-
(0,
|
|
8054
|
+
(0, import_shallow9.useShallow)((s) => ({
|
|
7966
8055
|
dispatch: s.dispatch,
|
|
7967
8056
|
overrides: s.overrides,
|
|
7968
8057
|
setUi: s.setUi,
|
|
@@ -7972,24 +8061,32 @@ var Canvas = () => {
|
|
|
7972
8061
|
iframe: s.iframe
|
|
7973
8062
|
}))
|
|
7974
8063
|
);
|
|
7975
|
-
const {
|
|
7976
|
-
|
|
8064
|
+
const {
|
|
8065
|
+
leftSideBarVisible,
|
|
8066
|
+
rightSideBarVisible,
|
|
8067
|
+
leftSideBarWidth,
|
|
8068
|
+
rightSideBarWidth,
|
|
8069
|
+
viewports
|
|
8070
|
+
} = useAppStore(
|
|
8071
|
+
(0, import_shallow9.useShallow)((s) => ({
|
|
7977
8072
|
leftSideBarVisible: s.state.ui.leftSideBarVisible,
|
|
7978
8073
|
rightSideBarVisible: s.state.ui.rightSideBarVisible,
|
|
8074
|
+
leftSideBarWidth: s.state.ui.leftSideBarWidth,
|
|
8075
|
+
rightSideBarWidth: s.state.ui.rightSideBarWidth,
|
|
7979
8076
|
viewports: s.state.ui.viewports
|
|
7980
8077
|
}))
|
|
7981
8078
|
);
|
|
7982
|
-
const
|
|
7983
|
-
const
|
|
7984
|
-
const defaultRender = (0,
|
|
7985
|
-
const PuckDefault = ({ children }) => /* @__PURE__ */ (0,
|
|
8079
|
+
const [showTransition, setShowTransition] = (0, import_react51.useState)(false);
|
|
8080
|
+
const isResettingZoomRef = (0, import_react51.useRef)(false);
|
|
8081
|
+
const defaultRender = (0, import_react51.useMemo)(() => {
|
|
8082
|
+
const PuckDefault = ({ children }) => /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(import_jsx_runtime39.Fragment, { children });
|
|
7986
8083
|
return PuckDefault;
|
|
7987
8084
|
}, []);
|
|
7988
|
-
const CustomPreview = (0,
|
|
8085
|
+
const CustomPreview = (0, import_react51.useMemo)(
|
|
7989
8086
|
() => overrides.preview || defaultRender,
|
|
7990
8087
|
[overrides]
|
|
7991
8088
|
);
|
|
7992
|
-
const getFrameDimensions = (0,
|
|
8089
|
+
const getFrameDimensions = (0, import_react51.useCallback)(() => {
|
|
7993
8090
|
if (frameRef.current) {
|
|
7994
8091
|
const frame = frameRef.current;
|
|
7995
8092
|
const box = getBox(frame);
|
|
@@ -7997,55 +8094,60 @@ var Canvas = () => {
|
|
|
7997
8094
|
}
|
|
7998
8095
|
return { width: 0, height: 0 };
|
|
7999
8096
|
}, [frameRef]);
|
|
8000
|
-
|
|
8001
|
-
(
|
|
8002
|
-
|
|
8003
|
-
|
|
8004
|
-
|
|
8005
|
-
|
|
8006
|
-
|
|
8007
|
-
|
|
8008
|
-
|
|
8009
|
-
|
|
8010
|
-
|
|
8011
|
-
|
|
8012
|
-
|
|
8013
|
-
|
|
8014
|
-
|
|
8015
|
-
|
|
8016
|
-
|
|
8017
|
-
}, [frameRef, leftSideBarVisible, rightSideBarVisible]);
|
|
8018
|
-
(0, import_react50.useEffect)(() => {
|
|
8097
|
+
(0, import_react51.useEffect)(() => {
|
|
8098
|
+
resetAutoZoom({
|
|
8099
|
+
isResettingRef: isResettingZoomRef,
|
|
8100
|
+
setShowTransition,
|
|
8101
|
+
showTransition: false,
|
|
8102
|
+
viewports
|
|
8103
|
+
});
|
|
8104
|
+
}, [
|
|
8105
|
+
frameRef,
|
|
8106
|
+
leftSideBarVisible,
|
|
8107
|
+
rightSideBarVisible,
|
|
8108
|
+
leftSideBarWidth,
|
|
8109
|
+
rightSideBarWidth,
|
|
8110
|
+
resetAutoZoom,
|
|
8111
|
+
viewports
|
|
8112
|
+
]);
|
|
8113
|
+
(0, import_react51.useEffect)(() => {
|
|
8019
8114
|
const { height: frameHeight } = getFrameDimensions();
|
|
8020
8115
|
if (viewports.current.height === "auto") {
|
|
8021
8116
|
setZoomConfig(__spreadProps(__spreadValues({}, zoomConfig), {
|
|
8022
8117
|
rootHeight: frameHeight / zoomConfig.zoom
|
|
8023
8118
|
}));
|
|
8024
8119
|
}
|
|
8025
|
-
}, [zoomConfig.zoom]);
|
|
8026
|
-
(0,
|
|
8120
|
+
}, [zoomConfig.zoom, getFrameDimensions, setZoomConfig]);
|
|
8121
|
+
(0, import_react51.useEffect)(() => {
|
|
8027
8122
|
if (ZOOM_ON_CHANGE) {
|
|
8028
|
-
|
|
8029
|
-
|
|
8123
|
+
resetAutoZoom({
|
|
8124
|
+
isResettingRef: isResettingZoomRef,
|
|
8125
|
+
setShowTransition,
|
|
8126
|
+
showTransition: true,
|
|
8127
|
+
viewports
|
|
8128
|
+
});
|
|
8030
8129
|
}
|
|
8031
|
-
}, [viewports.current.width]);
|
|
8032
|
-
(0,
|
|
8130
|
+
}, [viewports.current.width, resetAutoZoom, viewports]);
|
|
8131
|
+
(0, import_react51.useEffect)(() => {
|
|
8033
8132
|
const cb = () => {
|
|
8034
|
-
|
|
8035
|
-
|
|
8133
|
+
resetAutoZoom({
|
|
8134
|
+
isResettingRef: isResettingZoomRef,
|
|
8135
|
+
setShowTransition,
|
|
8136
|
+
showTransition: false
|
|
8137
|
+
});
|
|
8036
8138
|
};
|
|
8037
8139
|
window.addEventListener("resize", cb);
|
|
8038
8140
|
return () => {
|
|
8039
8141
|
window.removeEventListener("resize", cb);
|
|
8040
8142
|
};
|
|
8041
|
-
}, []);
|
|
8042
|
-
const [showLoader, setShowLoader] = (0,
|
|
8043
|
-
(0,
|
|
8143
|
+
}, [resetAutoZoom]);
|
|
8144
|
+
const [showLoader, setShowLoader] = (0, import_react51.useState)(false);
|
|
8145
|
+
(0, import_react51.useEffect)(() => {
|
|
8044
8146
|
setTimeout(() => {
|
|
8045
8147
|
setShowLoader(true);
|
|
8046
8148
|
}, 500);
|
|
8047
8149
|
}, []);
|
|
8048
|
-
return /* @__PURE__ */ (0,
|
|
8150
|
+
return /* @__PURE__ */ (0, import_jsx_runtime39.jsxs)(
|
|
8049
8151
|
"div",
|
|
8050
8152
|
{
|
|
8051
8153
|
className: getClassName25({
|
|
@@ -8058,7 +8160,7 @@ var Canvas = () => {
|
|
|
8058
8160
|
recordHistory: true
|
|
8059
8161
|
}),
|
|
8060
8162
|
children: [
|
|
8061
|
-
viewports.controlsVisible && iframe.enabled && /* @__PURE__ */ (0,
|
|
8163
|
+
viewports.controlsVisible && iframe.enabled && /* @__PURE__ */ (0, import_jsx_runtime39.jsx)("div", { className: getClassName25("controls"), children: /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(
|
|
8062
8164
|
ViewportControls,
|
|
8063
8165
|
{
|
|
8064
8166
|
autoZoom: zoomConfig.autoZoom,
|
|
@@ -8075,7 +8177,12 @@ var Canvas = () => {
|
|
|
8075
8177
|
};
|
|
8076
8178
|
setUi(newUi);
|
|
8077
8179
|
if (ZOOM_ON_CHANGE) {
|
|
8078
|
-
resetAutoZoom(
|
|
8180
|
+
resetAutoZoom({
|
|
8181
|
+
isResettingRef: isResettingZoomRef,
|
|
8182
|
+
setShowTransition,
|
|
8183
|
+
showTransition: true,
|
|
8184
|
+
viewports: __spreadProps(__spreadValues({}, viewports), { current: uiViewport })
|
|
8185
|
+
});
|
|
8079
8186
|
}
|
|
8080
8187
|
},
|
|
8081
8188
|
onZoom: (zoom) => {
|
|
@@ -8084,8 +8191,8 @@ var Canvas = () => {
|
|
|
8084
8191
|
}
|
|
8085
8192
|
}
|
|
8086
8193
|
) }),
|
|
8087
|
-
/* @__PURE__ */ (0,
|
|
8088
|
-
/* @__PURE__ */ (0,
|
|
8194
|
+
/* @__PURE__ */ (0, import_jsx_runtime39.jsxs)("div", { className: getClassName25("inner"), ref: frameRef, children: [
|
|
8195
|
+
/* @__PURE__ */ (0, import_jsx_runtime39.jsx)(
|
|
8089
8196
|
"div",
|
|
8090
8197
|
{
|
|
8091
8198
|
className: getClassName25("root"),
|
|
@@ -8099,17 +8206,14 @@ var Canvas = () => {
|
|
|
8099
8206
|
suppressHydrationWarning: true,
|
|
8100
8207
|
id: "puck-canvas-root",
|
|
8101
8208
|
onTransitionEnd: () => {
|
|
8102
|
-
|
|
8103
|
-
|
|
8104
|
-
|
|
8105
|
-
cancelable: false
|
|
8106
|
-
})
|
|
8107
|
-
);
|
|
8209
|
+
resetAutoZoom({
|
|
8210
|
+
isResettingRef: isResettingZoomRef
|
|
8211
|
+
});
|
|
8108
8212
|
},
|
|
8109
|
-
children: /* @__PURE__ */ (0,
|
|
8213
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(CustomPreview, { children: /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(Preview2, {}) })
|
|
8110
8214
|
}
|
|
8111
8215
|
),
|
|
8112
|
-
/* @__PURE__ */ (0,
|
|
8216
|
+
/* @__PURE__ */ (0, import_jsx_runtime39.jsx)("div", { className: getClassName25("loader"), children: /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(Loader, { size: 24 }) })
|
|
8113
8217
|
] })
|
|
8114
8218
|
]
|
|
8115
8219
|
}
|
|
@@ -8118,7 +8222,7 @@ var Canvas = () => {
|
|
|
8118
8222
|
|
|
8119
8223
|
// lib/use-loaded-overrides.ts
|
|
8120
8224
|
init_react_import();
|
|
8121
|
-
var
|
|
8225
|
+
var import_react52 = require("react");
|
|
8122
8226
|
|
|
8123
8227
|
// lib/load-overrides.ts
|
|
8124
8228
|
init_react_import();
|
|
@@ -8157,26 +8261,26 @@ var useLoadedOverrides = ({
|
|
|
8157
8261
|
overrides,
|
|
8158
8262
|
plugins
|
|
8159
8263
|
}) => {
|
|
8160
|
-
return (0,
|
|
8264
|
+
return (0, import_react52.useMemo)(() => {
|
|
8161
8265
|
return loadOverrides({ overrides, plugins });
|
|
8162
8266
|
}, [plugins, overrides]);
|
|
8163
8267
|
};
|
|
8164
8268
|
|
|
8165
8269
|
// components/DefaultOverride/index.tsx
|
|
8166
8270
|
init_react_import();
|
|
8167
|
-
var
|
|
8168
|
-
var DefaultOverride = ({ children }) => /* @__PURE__ */ (0,
|
|
8271
|
+
var import_jsx_runtime40 = require("react/jsx-runtime");
|
|
8272
|
+
var DefaultOverride = ({ children }) => /* @__PURE__ */ (0, import_jsx_runtime40.jsx)(import_jsx_runtime40.Fragment, { children });
|
|
8169
8273
|
|
|
8170
8274
|
// lib/use-inject-css.ts
|
|
8171
8275
|
init_react_import();
|
|
8172
|
-
var
|
|
8276
|
+
var import_react53 = require("react");
|
|
8173
8277
|
var styles = ``;
|
|
8174
8278
|
var useInjectStyleSheet = (initialStyles, iframeEnabled) => {
|
|
8175
|
-
const [el, setEl] = (0,
|
|
8176
|
-
(0,
|
|
8279
|
+
const [el, setEl] = (0, import_react53.useState)();
|
|
8280
|
+
(0, import_react53.useEffect)(() => {
|
|
8177
8281
|
setEl(document.createElement("style"));
|
|
8178
8282
|
}, []);
|
|
8179
|
-
(0,
|
|
8283
|
+
(0, import_react53.useEffect)(() => {
|
|
8180
8284
|
var _a;
|
|
8181
8285
|
if (!el || typeof window === "undefined") {
|
|
8182
8286
|
return;
|
|
@@ -8196,10 +8300,10 @@ var useInjectGlobalCss = (iframeEnabled) => {
|
|
|
8196
8300
|
|
|
8197
8301
|
// lib/use-preview-mode-hotkeys.ts
|
|
8198
8302
|
init_react_import();
|
|
8199
|
-
var
|
|
8303
|
+
var import_react54 = require("react");
|
|
8200
8304
|
var usePreviewModeHotkeys = () => {
|
|
8201
8305
|
const appStore = useAppStoreApi();
|
|
8202
|
-
const toggleInteractive = (0,
|
|
8306
|
+
const toggleInteractive = (0, import_react54.useCallback)(() => {
|
|
8203
8307
|
const dispatch = appStore.getState().dispatch;
|
|
8204
8308
|
dispatch({
|
|
8205
8309
|
type: "setUi",
|
|
@@ -8214,7 +8318,7 @@ var usePreviewModeHotkeys = () => {
|
|
|
8214
8318
|
|
|
8215
8319
|
// lib/use-puck.ts
|
|
8216
8320
|
init_react_import();
|
|
8217
|
-
var
|
|
8321
|
+
var import_react55 = require("react");
|
|
8218
8322
|
var import_zustand6 = require("zustand");
|
|
8219
8323
|
var generateUsePuck = (store) => {
|
|
8220
8324
|
const history = {
|
|
@@ -8247,7 +8351,7 @@ var generateUsePuck = (store) => {
|
|
|
8247
8351
|
};
|
|
8248
8352
|
return storeData;
|
|
8249
8353
|
};
|
|
8250
|
-
var UsePuckStoreContext = (0,
|
|
8354
|
+
var UsePuckStoreContext = (0, import_react55.createContext)(
|
|
8251
8355
|
null
|
|
8252
8356
|
);
|
|
8253
8357
|
var convertToPickedStore = (store) => {
|
|
@@ -8261,12 +8365,12 @@ var convertToPickedStore = (store) => {
|
|
|
8261
8365
|
};
|
|
8262
8366
|
};
|
|
8263
8367
|
var useRegisterUsePuckStore = (appStore) => {
|
|
8264
|
-
const [usePuckStore] = (0,
|
|
8368
|
+
const [usePuckStore] = (0, import_react55.useState)(
|
|
8265
8369
|
() => (0, import_zustand6.createStore)(
|
|
8266
8370
|
() => generateUsePuck(convertToPickedStore(appStore.getState()))
|
|
8267
8371
|
)
|
|
8268
8372
|
);
|
|
8269
|
-
(0,
|
|
8373
|
+
(0, import_react55.useEffect)(() => {
|
|
8270
8374
|
return appStore.subscribe(
|
|
8271
8375
|
(store) => convertToPickedStore(store),
|
|
8272
8376
|
(pickedStore) => {
|
|
@@ -8278,7 +8382,7 @@ var useRegisterUsePuckStore = (appStore) => {
|
|
|
8278
8382
|
};
|
|
8279
8383
|
function createUsePuck() {
|
|
8280
8384
|
return function usePuck2(selector) {
|
|
8281
|
-
const usePuckApi = (0,
|
|
8385
|
+
const usePuckApi = (0, import_react55.useContext)(UsePuckStoreContext);
|
|
8282
8386
|
if (!usePuckApi) {
|
|
8283
8387
|
throw new Error("usePuck must be used inside <Puck>.");
|
|
8284
8388
|
}
|
|
@@ -8290,7 +8394,7 @@ function createUsePuck() {
|
|
|
8290
8394
|
};
|
|
8291
8395
|
}
|
|
8292
8396
|
function usePuck() {
|
|
8293
|
-
(0,
|
|
8397
|
+
(0, import_react55.useEffect)(() => {
|
|
8294
8398
|
console.warn(
|
|
8295
8399
|
"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."
|
|
8296
8400
|
);
|
|
@@ -8298,7 +8402,7 @@ function usePuck() {
|
|
|
8298
8402
|
return createUsePuck()((s) => s);
|
|
8299
8403
|
}
|
|
8300
8404
|
function useGetPuck() {
|
|
8301
|
-
const usePuckApi = (0,
|
|
8405
|
+
const usePuckApi = (0, import_react55.useContext)(UsePuckStoreContext);
|
|
8302
8406
|
if (!usePuckApi) {
|
|
8303
8407
|
throw new Error("usePuckGet must be used inside <Puck>.");
|
|
8304
8408
|
}
|
|
@@ -8310,7 +8414,7 @@ var import_fast_deep_equal3 = __toESM(require("fast-deep-equal"));
|
|
|
8310
8414
|
|
|
8311
8415
|
// components/Puck/components/Header/index.tsx
|
|
8312
8416
|
init_react_import();
|
|
8313
|
-
var
|
|
8417
|
+
var import_react56 = require("react");
|
|
8314
8418
|
|
|
8315
8419
|
// components/MenuBar/index.tsx
|
|
8316
8420
|
init_react_import();
|
|
@@ -8320,7 +8424,7 @@ init_react_import();
|
|
|
8320
8424
|
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" };
|
|
8321
8425
|
|
|
8322
8426
|
// components/MenuBar/index.tsx
|
|
8323
|
-
var
|
|
8427
|
+
var import_jsx_runtime41 = require("react/jsx-runtime");
|
|
8324
8428
|
var getClassName26 = get_class_name_factory_default("MenuBar", styles_module_default21);
|
|
8325
8429
|
function MenuBar({
|
|
8326
8430
|
menuOpen = false,
|
|
@@ -8331,7 +8435,7 @@ function MenuBar({
|
|
|
8331
8435
|
const forward = useAppStore((s) => s.history.forward);
|
|
8332
8436
|
const hasFuture = useAppStore((s) => s.history.hasFuture());
|
|
8333
8437
|
const hasPast = useAppStore((s) => s.history.hasPast());
|
|
8334
|
-
return /* @__PURE__ */ (0,
|
|
8438
|
+
return /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(
|
|
8335
8439
|
"div",
|
|
8336
8440
|
{
|
|
8337
8441
|
className: getClassName26({ menuOpen }),
|
|
@@ -8345,30 +8449,30 @@ function MenuBar({
|
|
|
8345
8449
|
setMenuOpen(false);
|
|
8346
8450
|
}
|
|
8347
8451
|
},
|
|
8348
|
-
children: /* @__PURE__ */ (0,
|
|
8349
|
-
/* @__PURE__ */ (0,
|
|
8350
|
-
/* @__PURE__ */ (0,
|
|
8452
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime41.jsxs)("div", { className: getClassName26("inner"), children: [
|
|
8453
|
+
/* @__PURE__ */ (0, import_jsx_runtime41.jsxs)("div", { className: getClassName26("history"), children: [
|
|
8454
|
+
/* @__PURE__ */ (0, import_jsx_runtime41.jsx)(
|
|
8351
8455
|
IconButton,
|
|
8352
8456
|
{
|
|
8353
8457
|
type: "button",
|
|
8354
8458
|
title: "undo",
|
|
8355
8459
|
disabled: !hasPast,
|
|
8356
8460
|
onClick: back,
|
|
8357
|
-
children: /* @__PURE__ */ (0,
|
|
8461
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(Undo2, { size: 21 })
|
|
8358
8462
|
}
|
|
8359
8463
|
),
|
|
8360
|
-
/* @__PURE__ */ (0,
|
|
8464
|
+
/* @__PURE__ */ (0, import_jsx_runtime41.jsx)(
|
|
8361
8465
|
IconButton,
|
|
8362
8466
|
{
|
|
8363
8467
|
type: "button",
|
|
8364
8468
|
title: "redo",
|
|
8365
8469
|
disabled: !hasFuture,
|
|
8366
8470
|
onClick: forward,
|
|
8367
|
-
children: /* @__PURE__ */ (0,
|
|
8471
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(Redo2, { size: 21 })
|
|
8368
8472
|
}
|
|
8369
8473
|
)
|
|
8370
8474
|
] }),
|
|
8371
|
-
/* @__PURE__ */ (0,
|
|
8475
|
+
/* @__PURE__ */ (0, import_jsx_runtime41.jsx)(import_jsx_runtime41.Fragment, { children: renderHeaderActions && renderHeaderActions() })
|
|
8372
8476
|
] })
|
|
8373
8477
|
}
|
|
8374
8478
|
);
|
|
@@ -8379,7 +8483,7 @@ init_react_import();
|
|
|
8379
8483
|
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" };
|
|
8380
8484
|
|
|
8381
8485
|
// components/Puck/components/Header/index.tsx
|
|
8382
|
-
var
|
|
8486
|
+
var import_jsx_runtime42 = require("react/jsx-runtime");
|
|
8383
8487
|
var getClassName27 = get_class_name_factory_default("PuckHeader", styles_module_default22);
|
|
8384
8488
|
var HeaderInner = () => {
|
|
8385
8489
|
const {
|
|
@@ -8392,7 +8496,7 @@ var HeaderInner = () => {
|
|
|
8392
8496
|
} = usePropsContext();
|
|
8393
8497
|
const dispatch = useAppStore((s) => s.dispatch);
|
|
8394
8498
|
const appStore = useAppStoreApi();
|
|
8395
|
-
const defaultHeaderRender = (0,
|
|
8499
|
+
const defaultHeaderRender = (0, import_react56.useMemo)(() => {
|
|
8396
8500
|
if (renderHeader) {
|
|
8397
8501
|
console.warn(
|
|
8398
8502
|
"`renderHeader` is deprecated. Please use `overrides.header` and the `usePuck` hook instead"
|
|
@@ -8401,13 +8505,13 @@ var HeaderInner = () => {
|
|
|
8401
8505
|
var _b = _a, { actions } = _b, props = __objRest(_b, ["actions"]);
|
|
8402
8506
|
const Comp = renderHeader;
|
|
8403
8507
|
const appState = useAppStore((s) => s.state);
|
|
8404
|
-
return /* @__PURE__ */ (0,
|
|
8508
|
+
return /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(Comp, __spreadProps(__spreadValues({}, props), { dispatch, state: appState, children: actions }));
|
|
8405
8509
|
};
|
|
8406
8510
|
return RenderHeader;
|
|
8407
8511
|
}
|
|
8408
8512
|
return DefaultOverride;
|
|
8409
8513
|
}, [renderHeader]);
|
|
8410
|
-
const defaultHeaderActionsRender = (0,
|
|
8514
|
+
const defaultHeaderActionsRender = (0, import_react56.useMemo)(() => {
|
|
8411
8515
|
if (renderHeaderActions) {
|
|
8412
8516
|
console.warn(
|
|
8413
8517
|
"`renderHeaderActions` is deprecated. Please use `overrides.headerActions` and the `usePuck` hook instead."
|
|
@@ -8415,7 +8519,7 @@ var HeaderInner = () => {
|
|
|
8415
8519
|
const RenderHeader = (props) => {
|
|
8416
8520
|
const Comp = renderHeaderActions;
|
|
8417
8521
|
const appState = useAppStore((s) => s.state);
|
|
8418
|
-
return /* @__PURE__ */ (0,
|
|
8522
|
+
return /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(Comp, __spreadProps(__spreadValues({}, props), { dispatch, state: appState }));
|
|
8419
8523
|
};
|
|
8420
8524
|
return RenderHeader;
|
|
8421
8525
|
}
|
|
@@ -8427,7 +8531,7 @@ var HeaderInner = () => {
|
|
|
8427
8531
|
const CustomHeaderActions = useAppStore(
|
|
8428
8532
|
(s) => s.overrides.headerActions || defaultHeaderActionsRender
|
|
8429
8533
|
);
|
|
8430
|
-
const [menuOpen, setMenuOpen] = (0,
|
|
8534
|
+
const [menuOpen, setMenuOpen] = (0, import_react56.useState)(false);
|
|
8431
8535
|
const rootTitle = useAppStore((s) => {
|
|
8432
8536
|
var _a, _b;
|
|
8433
8537
|
const rootData = (_a = s.state.indexes.nodes["root"]) == null ? void 0 : _a.data;
|
|
@@ -8437,7 +8541,7 @@ var HeaderInner = () => {
|
|
|
8437
8541
|
const rightSideBarVisible = useAppStore(
|
|
8438
8542
|
(s) => s.state.ui.rightSideBarVisible
|
|
8439
8543
|
);
|
|
8440
|
-
const toggleSidebars = (0,
|
|
8544
|
+
const toggleSidebars = (0, import_react56.useCallback)(
|
|
8441
8545
|
(sidebar) => {
|
|
8442
8546
|
const widerViewport = window.matchMedia("(min-width: 638px)").matches;
|
|
8443
8547
|
const sideBarVisible = sidebar === "left" ? leftSideBarVisible : rightSideBarVisible;
|
|
@@ -8451,27 +8555,27 @@ var HeaderInner = () => {
|
|
|
8451
8555
|
},
|
|
8452
8556
|
[dispatch, leftSideBarVisible, rightSideBarVisible]
|
|
8453
8557
|
);
|
|
8454
|
-
return /* @__PURE__ */ (0,
|
|
8558
|
+
return /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(
|
|
8455
8559
|
CustomHeader,
|
|
8456
8560
|
{
|
|
8457
|
-
actions: /* @__PURE__ */ (0,
|
|
8561
|
+
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)(
|
|
8458
8562
|
Button,
|
|
8459
8563
|
{
|
|
8460
8564
|
onClick: () => {
|
|
8461
8565
|
const data = appStore.getState().state.data;
|
|
8462
8566
|
onPublish && onPublish(data);
|
|
8463
8567
|
},
|
|
8464
|
-
icon: /* @__PURE__ */ (0,
|
|
8568
|
+
icon: /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(Globe, { size: "14px" }),
|
|
8465
8569
|
children: "Publish"
|
|
8466
8570
|
}
|
|
8467
8571
|
) }) }),
|
|
8468
|
-
children: /* @__PURE__ */ (0,
|
|
8572
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(
|
|
8469
8573
|
"header",
|
|
8470
8574
|
{
|
|
8471
8575
|
className: getClassName27({ leftSideBarVisible, rightSideBarVisible }),
|
|
8472
|
-
children: /* @__PURE__ */ (0,
|
|
8473
|
-
/* @__PURE__ */ (0,
|
|
8474
|
-
/* @__PURE__ */ (0,
|
|
8576
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime42.jsxs)("div", { className: getClassName27("inner"), children: [
|
|
8577
|
+
/* @__PURE__ */ (0, import_jsx_runtime42.jsxs)("div", { className: getClassName27("toggle"), children: [
|
|
8578
|
+
/* @__PURE__ */ (0, import_jsx_runtime42.jsx)("div", { className: getClassName27("leftSideBarToggle"), children: /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(
|
|
8475
8579
|
IconButton,
|
|
8476
8580
|
{
|
|
8477
8581
|
type: "button",
|
|
@@ -8479,10 +8583,10 @@ var HeaderInner = () => {
|
|
|
8479
8583
|
toggleSidebars("left");
|
|
8480
8584
|
},
|
|
8481
8585
|
title: "Toggle left sidebar",
|
|
8482
|
-
children: /* @__PURE__ */ (0,
|
|
8586
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(PanelLeft, { focusable: "false" })
|
|
8483
8587
|
}
|
|
8484
8588
|
) }),
|
|
8485
|
-
/* @__PURE__ */ (0,
|
|
8589
|
+
/* @__PURE__ */ (0, import_jsx_runtime42.jsx)("div", { className: getClassName27("rightSideBarToggle"), children: /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(
|
|
8486
8590
|
IconButton,
|
|
8487
8591
|
{
|
|
8488
8592
|
type: "button",
|
|
@@ -8490,19 +8594,19 @@ var HeaderInner = () => {
|
|
|
8490
8594
|
toggleSidebars("right");
|
|
8491
8595
|
},
|
|
8492
8596
|
title: "Toggle right sidebar",
|
|
8493
|
-
children: /* @__PURE__ */ (0,
|
|
8597
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(PanelRight, { focusable: "false" })
|
|
8494
8598
|
}
|
|
8495
8599
|
) })
|
|
8496
8600
|
] }),
|
|
8497
|
-
/* @__PURE__ */ (0,
|
|
8601
|
+
/* @__PURE__ */ (0, import_jsx_runtime42.jsx)("div", { className: getClassName27("title"), children: /* @__PURE__ */ (0, import_jsx_runtime42.jsxs)(Heading, { rank: "2", size: "xs", children: [
|
|
8498
8602
|
headerTitle || rootTitle || "Page",
|
|
8499
|
-
headerPath && /* @__PURE__ */ (0,
|
|
8603
|
+
headerPath && /* @__PURE__ */ (0, import_jsx_runtime42.jsxs)(import_jsx_runtime42.Fragment, { children: [
|
|
8500
8604
|
" ",
|
|
8501
|
-
/* @__PURE__ */ (0,
|
|
8605
|
+
/* @__PURE__ */ (0, import_jsx_runtime42.jsx)("code", { className: getClassName27("path"), children: headerPath })
|
|
8502
8606
|
] })
|
|
8503
8607
|
] }) }),
|
|
8504
|
-
/* @__PURE__ */ (0,
|
|
8505
|
-
/* @__PURE__ */ (0,
|
|
8608
|
+
/* @__PURE__ */ (0, import_jsx_runtime42.jsxs)("div", { className: getClassName27("tools"), children: [
|
|
8609
|
+
/* @__PURE__ */ (0, import_jsx_runtime42.jsx)("div", { className: getClassName27("menuButton"), children: /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(
|
|
8506
8610
|
IconButton,
|
|
8507
8611
|
{
|
|
8508
8612
|
type: "button",
|
|
@@ -8510,23 +8614,23 @@ var HeaderInner = () => {
|
|
|
8510
8614
|
return setMenuOpen(!menuOpen);
|
|
8511
8615
|
},
|
|
8512
8616
|
title: "Toggle menu bar",
|
|
8513
|
-
children: menuOpen ? /* @__PURE__ */ (0,
|
|
8617
|
+
children: menuOpen ? /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(ChevronUp, { focusable: "false" }) : /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(ChevronDown, { focusable: "false" })
|
|
8514
8618
|
}
|
|
8515
8619
|
) }),
|
|
8516
|
-
/* @__PURE__ */ (0,
|
|
8620
|
+
/* @__PURE__ */ (0, import_jsx_runtime42.jsx)(
|
|
8517
8621
|
MenuBar,
|
|
8518
8622
|
{
|
|
8519
8623
|
dispatch,
|
|
8520
8624
|
onPublish,
|
|
8521
8625
|
menuOpen,
|
|
8522
|
-
renderHeaderActions: () => /* @__PURE__ */ (0,
|
|
8626
|
+
renderHeaderActions: () => /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(CustomHeaderActions, { children: /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(
|
|
8523
8627
|
Button,
|
|
8524
8628
|
{
|
|
8525
8629
|
onClick: () => {
|
|
8526
8630
|
const data = appStore.getState().state.data;
|
|
8527
8631
|
onPublish && onPublish(data);
|
|
8528
8632
|
},
|
|
8529
|
-
icon: /* @__PURE__ */ (0,
|
|
8633
|
+
icon: /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(Globe, { size: "14px" }),
|
|
8530
8634
|
children: "Publish"
|
|
8531
8635
|
}
|
|
8532
8636
|
) }),
|
|
@@ -8540,11 +8644,203 @@ var HeaderInner = () => {
|
|
|
8540
8644
|
}
|
|
8541
8645
|
);
|
|
8542
8646
|
};
|
|
8543
|
-
var Header = (0,
|
|
8647
|
+
var Header = (0, import_react56.memo)(HeaderInner);
|
|
8648
|
+
|
|
8649
|
+
// components/Puck/components/Sidebar/index.tsx
|
|
8650
|
+
init_react_import();
|
|
8651
|
+
|
|
8652
|
+
// components/Puck/components/ResizeHandle/index.tsx
|
|
8653
|
+
init_react_import();
|
|
8654
|
+
var import_react57 = require("react");
|
|
8655
|
+
|
|
8656
|
+
// css-module:/home/runner/work/puck/puck/packages/core/components/Puck/components/ResizeHandle/styles.module.css#css-module
|
|
8657
|
+
init_react_import();
|
|
8658
|
+
var styles_module_default23 = { "ResizeHandle": "_ResizeHandle_v7w0r_1", "ResizeHandle--left": "_ResizeHandle--left_v7w0r_15", "ResizeHandle--right": "_ResizeHandle--right_v7w0r_19" };
|
|
8659
|
+
|
|
8660
|
+
// components/Puck/components/ResizeHandle/index.tsx
|
|
8661
|
+
var import_jsx_runtime43 = require("react/jsx-runtime");
|
|
8662
|
+
var getClassName28 = get_class_name_factory_default("ResizeHandle", styles_module_default23);
|
|
8663
|
+
var ResizeHandle = ({
|
|
8664
|
+
position,
|
|
8665
|
+
sidebarRef,
|
|
8666
|
+
onResize,
|
|
8667
|
+
onResizeEnd
|
|
8668
|
+
}) => {
|
|
8669
|
+
const { frameRef } = useCanvasFrame();
|
|
8670
|
+
const resetAutoZoom = useResetAutoZoom(frameRef);
|
|
8671
|
+
const handleRef = (0, import_react57.useRef)(null);
|
|
8672
|
+
const isDragging = (0, import_react57.useRef)(false);
|
|
8673
|
+
const startX = (0, import_react57.useRef)(0);
|
|
8674
|
+
const startWidth = (0, import_react57.useRef)(0);
|
|
8675
|
+
const handleMouseMove = (0, import_react57.useCallback)(
|
|
8676
|
+
(e) => {
|
|
8677
|
+
if (!isDragging.current) return;
|
|
8678
|
+
const delta = e.clientX - startX.current;
|
|
8679
|
+
const newWidth = position === "left" ? startWidth.current + delta : startWidth.current - delta;
|
|
8680
|
+
const width = Math.max(192, newWidth);
|
|
8681
|
+
onResize(width);
|
|
8682
|
+
e.preventDefault();
|
|
8683
|
+
},
|
|
8684
|
+
[onResize, position]
|
|
8685
|
+
);
|
|
8686
|
+
const handleMouseUp = (0, import_react57.useCallback)(() => {
|
|
8687
|
+
var _a;
|
|
8688
|
+
if (!isDragging.current) return;
|
|
8689
|
+
isDragging.current = false;
|
|
8690
|
+
document.body.style.cursor = "";
|
|
8691
|
+
document.body.style.userSelect = "";
|
|
8692
|
+
const overlay = document.getElementById("resize-overlay");
|
|
8693
|
+
if (overlay) {
|
|
8694
|
+
document.body.removeChild(overlay);
|
|
8695
|
+
}
|
|
8696
|
+
document.removeEventListener("mousemove", handleMouseMove);
|
|
8697
|
+
document.removeEventListener("mouseup", handleMouseUp);
|
|
8698
|
+
const finalWidth = ((_a = sidebarRef.current) == null ? void 0 : _a.getBoundingClientRect().width) || 0;
|
|
8699
|
+
onResizeEnd(finalWidth);
|
|
8700
|
+
resetAutoZoom();
|
|
8701
|
+
}, [onResizeEnd, resetAutoZoom]);
|
|
8702
|
+
const handleMouseDown = (0, import_react57.useCallback)(
|
|
8703
|
+
(e) => {
|
|
8704
|
+
var _a;
|
|
8705
|
+
isDragging.current = true;
|
|
8706
|
+
startX.current = e.clientX;
|
|
8707
|
+
startWidth.current = ((_a = sidebarRef.current) == null ? void 0 : _a.getBoundingClientRect().width) || 0;
|
|
8708
|
+
document.body.style.cursor = "col-resize";
|
|
8709
|
+
document.body.style.userSelect = "none";
|
|
8710
|
+
const overlay = document.createElement("div");
|
|
8711
|
+
overlay.id = "resize-overlay";
|
|
8712
|
+
overlay.setAttribute("data-resize-overlay", "");
|
|
8713
|
+
document.body.appendChild(overlay);
|
|
8714
|
+
document.addEventListener("mousemove", handleMouseMove);
|
|
8715
|
+
document.addEventListener("mouseup", handleMouseUp);
|
|
8716
|
+
e.preventDefault();
|
|
8717
|
+
},
|
|
8718
|
+
[position, handleMouseMove, handleMouseUp]
|
|
8719
|
+
);
|
|
8720
|
+
return /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(
|
|
8721
|
+
"div",
|
|
8722
|
+
{
|
|
8723
|
+
ref: handleRef,
|
|
8724
|
+
className: getClassName28({ [position]: true }),
|
|
8725
|
+
onMouseDown: handleMouseDown
|
|
8726
|
+
}
|
|
8727
|
+
);
|
|
8728
|
+
};
|
|
8729
|
+
|
|
8730
|
+
// css-module:/home/runner/work/puck/puck/packages/core/components/Puck/components/Sidebar/styles.module.css#css-module
|
|
8731
|
+
init_react_import();
|
|
8732
|
+
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" };
|
|
8733
|
+
|
|
8734
|
+
// components/Puck/components/Sidebar/index.tsx
|
|
8735
|
+
var import_jsx_runtime44 = require("react/jsx-runtime");
|
|
8736
|
+
var getClassName29 = get_class_name_factory_default("Sidebar", styles_module_default24);
|
|
8737
|
+
var Sidebar = ({
|
|
8738
|
+
position,
|
|
8739
|
+
sidebarRef,
|
|
8740
|
+
isVisible,
|
|
8741
|
+
width,
|
|
8742
|
+
onResize,
|
|
8743
|
+
onResizeEnd,
|
|
8744
|
+
children
|
|
8745
|
+
}) => {
|
|
8746
|
+
if (!isVisible) return null;
|
|
8747
|
+
return /* @__PURE__ */ (0, import_jsx_runtime44.jsxs)(import_jsx_runtime44.Fragment, { children: [
|
|
8748
|
+
/* @__PURE__ */ (0, import_jsx_runtime44.jsx)("div", { ref: sidebarRef, className: getClassName29({ [position]: true }), children }),
|
|
8749
|
+
/* @__PURE__ */ (0, import_jsx_runtime44.jsx)("div", { className: `${getClassName29("resizeHandle")}`, children: /* @__PURE__ */ (0, import_jsx_runtime44.jsx)(
|
|
8750
|
+
ResizeHandle,
|
|
8751
|
+
{
|
|
8752
|
+
position,
|
|
8753
|
+
sidebarRef,
|
|
8754
|
+
onResize,
|
|
8755
|
+
onResizeEnd
|
|
8756
|
+
}
|
|
8757
|
+
) })
|
|
8758
|
+
] });
|
|
8759
|
+
};
|
|
8760
|
+
|
|
8761
|
+
// lib/use-sidebar-resize.ts
|
|
8762
|
+
init_react_import();
|
|
8763
|
+
var import_react58 = require("react");
|
|
8764
|
+
function useSidebarResize(position, dispatch) {
|
|
8765
|
+
const [width, setWidth] = (0, import_react58.useState)(null);
|
|
8766
|
+
const sidebarRef = (0, import_react58.useRef)(null);
|
|
8767
|
+
const storeWidth = useAppStore(
|
|
8768
|
+
(s) => position === "left" ? s.state.ui.leftSideBarWidth : s.state.ui.rightSideBarWidth
|
|
8769
|
+
);
|
|
8770
|
+
(0, import_react58.useEffect)(() => {
|
|
8771
|
+
if (typeof window !== "undefined" && !storeWidth) {
|
|
8772
|
+
try {
|
|
8773
|
+
const savedWidths = localStorage.getItem("puck-sidebar-widths");
|
|
8774
|
+
if (savedWidths) {
|
|
8775
|
+
const widths = JSON.parse(savedWidths);
|
|
8776
|
+
const savedWidth = widths[position];
|
|
8777
|
+
if (savedWidth) {
|
|
8778
|
+
dispatch({
|
|
8779
|
+
type: "setUi",
|
|
8780
|
+
ui: {
|
|
8781
|
+
[position === "left" ? "leftSideBarWidth" : "rightSideBarWidth"]: savedWidth
|
|
8782
|
+
}
|
|
8783
|
+
});
|
|
8784
|
+
}
|
|
8785
|
+
}
|
|
8786
|
+
} catch (error) {
|
|
8787
|
+
console.error(
|
|
8788
|
+
`Failed to load ${position} sidebar width from localStorage`,
|
|
8789
|
+
error
|
|
8790
|
+
);
|
|
8791
|
+
}
|
|
8792
|
+
}
|
|
8793
|
+
}, [dispatch, position, storeWidth]);
|
|
8794
|
+
(0, import_react58.useEffect)(() => {
|
|
8795
|
+
if (storeWidth !== void 0) {
|
|
8796
|
+
setWidth(storeWidth);
|
|
8797
|
+
}
|
|
8798
|
+
}, [storeWidth]);
|
|
8799
|
+
const handleResizeEnd = (0, import_react58.useCallback)(
|
|
8800
|
+
(width2) => {
|
|
8801
|
+
dispatch({
|
|
8802
|
+
type: "setUi",
|
|
8803
|
+
ui: {
|
|
8804
|
+
[position === "left" ? "leftSideBarWidth" : "rightSideBarWidth"]: width2
|
|
8805
|
+
}
|
|
8806
|
+
});
|
|
8807
|
+
let widths = {};
|
|
8808
|
+
try {
|
|
8809
|
+
const savedWidths = localStorage.getItem("puck-sidebar-widths");
|
|
8810
|
+
widths = savedWidths ? JSON.parse(savedWidths) : {};
|
|
8811
|
+
} catch (error) {
|
|
8812
|
+
console.error(
|
|
8813
|
+
`Failed to save ${position} sidebar width to localStorage`,
|
|
8814
|
+
error
|
|
8815
|
+
);
|
|
8816
|
+
} finally {
|
|
8817
|
+
localStorage.setItem(
|
|
8818
|
+
"puck-sidebar-widths",
|
|
8819
|
+
JSON.stringify(__spreadProps(__spreadValues({}, widths), {
|
|
8820
|
+
[position]: width2
|
|
8821
|
+
}))
|
|
8822
|
+
);
|
|
8823
|
+
}
|
|
8824
|
+
window.dispatchEvent(
|
|
8825
|
+
new CustomEvent("viewportchange", {
|
|
8826
|
+
bubbles: true,
|
|
8827
|
+
cancelable: false
|
|
8828
|
+
})
|
|
8829
|
+
);
|
|
8830
|
+
},
|
|
8831
|
+
[dispatch, position]
|
|
8832
|
+
);
|
|
8833
|
+
return {
|
|
8834
|
+
width,
|
|
8835
|
+
setWidth,
|
|
8836
|
+
sidebarRef,
|
|
8837
|
+
handleResizeEnd
|
|
8838
|
+
};
|
|
8839
|
+
}
|
|
8544
8840
|
|
|
8545
8841
|
// components/Puck/index.tsx
|
|
8546
|
-
var
|
|
8547
|
-
var
|
|
8842
|
+
var import_jsx_runtime45 = require("react/jsx-runtime");
|
|
8843
|
+
var getClassName30 = get_class_name_factory_default("Puck", styles_module_default14);
|
|
8548
8844
|
var getLayoutClassName = get_class_name_factory_default("PuckLayout", styles_module_default14);
|
|
8549
8845
|
var FieldSideBar = () => {
|
|
8550
8846
|
const title = useAppStore(
|
|
@@ -8553,13 +8849,13 @@ var FieldSideBar = () => {
|
|
|
8553
8849
|
return s.selectedItem ? (_b = (_a = s.config.components[s.selectedItem.type]) == null ? void 0 : _a["label"]) != null ? _b : s.selectedItem.type.toString() : "Page";
|
|
8554
8850
|
}
|
|
8555
8851
|
);
|
|
8556
|
-
return /* @__PURE__ */ (0,
|
|
8852
|
+
return /* @__PURE__ */ (0, import_jsx_runtime45.jsx)(SidebarSection, { noPadding: true, noBorderTop: true, showBreadcrumbs: true, title, children: /* @__PURE__ */ (0, import_jsx_runtime45.jsx)(Fields, {}) });
|
|
8557
8853
|
};
|
|
8558
|
-
var propsContext = (0,
|
|
8854
|
+
var propsContext = (0, import_react59.createContext)({});
|
|
8559
8855
|
function PropsProvider(props) {
|
|
8560
|
-
return /* @__PURE__ */ (0,
|
|
8856
|
+
return /* @__PURE__ */ (0, import_jsx_runtime45.jsx)(propsContext.Provider, { value: props, children: props.children });
|
|
8561
8857
|
}
|
|
8562
|
-
var usePropsContext = () => (0,
|
|
8858
|
+
var usePropsContext = () => (0, import_react59.useContext)(propsContext);
|
|
8563
8859
|
function PuckProvider({ children }) {
|
|
8564
8860
|
const {
|
|
8565
8861
|
config,
|
|
@@ -8575,14 +8871,14 @@ function PuckProvider({ children }) {
|
|
|
8575
8871
|
metadata,
|
|
8576
8872
|
onAction
|
|
8577
8873
|
} = usePropsContext();
|
|
8578
|
-
const iframe = (0,
|
|
8874
|
+
const iframe = (0, import_react59.useMemo)(
|
|
8579
8875
|
() => __spreadValues({
|
|
8580
8876
|
enabled: true,
|
|
8581
8877
|
waitForStyles: true
|
|
8582
8878
|
}, _iframe),
|
|
8583
8879
|
[_iframe]
|
|
8584
8880
|
);
|
|
8585
|
-
const [generatedAppState] = (0,
|
|
8881
|
+
const [generatedAppState] = (0, import_react59.useState)(() => {
|
|
8586
8882
|
var _a, _b, _c, _d, _e, _f, _g, _h, _i;
|
|
8587
8883
|
const initial = __spreadValues(__spreadValues({}, defaultAppState.ui), initialUi);
|
|
8588
8884
|
let clientUiState = {};
|
|
@@ -8611,7 +8907,7 @@ function PuckProvider({ children }) {
|
|
|
8611
8907
|
}
|
|
8612
8908
|
}
|
|
8613
8909
|
if (Object.keys((initialData == null ? void 0 : initialData.root) || {}).length > 0 && !((_g = initialData == null ? void 0 : initialData.root) == null ? void 0 : _g.props)) {
|
|
8614
|
-
console.
|
|
8910
|
+
console.warn(
|
|
8615
8911
|
"Warning: Defining props on `root` is deprecated. Please use `root.props`, or republish this page to migrate automatically."
|
|
8616
8912
|
);
|
|
8617
8913
|
}
|
|
@@ -8642,7 +8938,7 @@ function PuckProvider({ children }) {
|
|
|
8642
8938
|
return walkAppState(newAppState, config);
|
|
8643
8939
|
});
|
|
8644
8940
|
const { appendData = true } = _initialHistory || {};
|
|
8645
|
-
const [blendedHistories] = (0,
|
|
8941
|
+
const [blendedHistories] = (0, import_react59.useState)(
|
|
8646
8942
|
[
|
|
8647
8943
|
...(_initialHistory == null ? void 0 : _initialHistory.histories) || [],
|
|
8648
8944
|
...appendData ? [{ state: generatedAppState }] : []
|
|
@@ -8662,7 +8958,7 @@ function PuckProvider({ children }) {
|
|
|
8662
8958
|
overrides,
|
|
8663
8959
|
plugins
|
|
8664
8960
|
});
|
|
8665
|
-
const generateAppStore = (0,
|
|
8961
|
+
const generateAppStore = (0, import_react59.useCallback)(
|
|
8666
8962
|
(state) => {
|
|
8667
8963
|
return {
|
|
8668
8964
|
state,
|
|
@@ -8686,15 +8982,15 @@ function PuckProvider({ children }) {
|
|
|
8686
8982
|
metadata
|
|
8687
8983
|
]
|
|
8688
8984
|
);
|
|
8689
|
-
const [appStore] = (0,
|
|
8985
|
+
const [appStore] = (0, import_react59.useState)(
|
|
8690
8986
|
() => createAppStore(generateAppStore(initialAppState))
|
|
8691
8987
|
);
|
|
8692
|
-
(0,
|
|
8988
|
+
(0, import_react59.useEffect)(() => {
|
|
8693
8989
|
if (process.env.NODE_ENV !== "production") {
|
|
8694
8990
|
window.__PUCK_INTERNAL_DO_NOT_USE = { appStore };
|
|
8695
8991
|
}
|
|
8696
8992
|
}, [appStore]);
|
|
8697
|
-
(0,
|
|
8993
|
+
(0, import_react59.useEffect)(() => {
|
|
8698
8994
|
const state = appStore.getState().state;
|
|
8699
8995
|
appStore.setState(__spreadValues({}, generateAppStore(state)));
|
|
8700
8996
|
}, [config, plugins, loadedOverrides, viewports, iframe, onAction, metadata]);
|
|
@@ -8703,8 +8999,8 @@ function PuckProvider({ children }) {
|
|
|
8703
8999
|
index: initialHistoryIndex,
|
|
8704
9000
|
initialAppState
|
|
8705
9001
|
});
|
|
8706
|
-
const previousData = (0,
|
|
8707
|
-
(0,
|
|
9002
|
+
const previousData = (0, import_react59.useRef)(null);
|
|
9003
|
+
(0, import_react59.useEffect)(() => {
|
|
8708
9004
|
appStore.subscribe(
|
|
8709
9005
|
(s) => s.state.data,
|
|
8710
9006
|
(data) => {
|
|
@@ -8718,11 +9014,11 @@ function PuckProvider({ children }) {
|
|
|
8718
9014
|
}, []);
|
|
8719
9015
|
useRegisterPermissionsSlice(appStore, permissions);
|
|
8720
9016
|
const uPuckStore = useRegisterUsePuckStore(appStore);
|
|
8721
|
-
(0,
|
|
9017
|
+
(0, import_react59.useEffect)(() => {
|
|
8722
9018
|
const { resolveAndCommitData } = appStore.getState();
|
|
8723
9019
|
resolveAndCommitData();
|
|
8724
9020
|
}, []);
|
|
8725
|
-
return /* @__PURE__ */ (0,
|
|
9021
|
+
return /* @__PURE__ */ (0, import_jsx_runtime45.jsx)(appStoreContext.Provider, { value: appStore, children: /* @__PURE__ */ (0, import_jsx_runtime45.jsx)(UsePuckStoreContext.Provider, { value: uPuckStore, children }) });
|
|
8726
9022
|
}
|
|
8727
9023
|
function PuckLayout({ children }) {
|
|
8728
9024
|
const {
|
|
@@ -8730,7 +9026,7 @@ function PuckLayout({ children }) {
|
|
|
8730
9026
|
dnd,
|
|
8731
9027
|
initialHistory: _initialHistory
|
|
8732
9028
|
} = usePropsContext();
|
|
8733
|
-
const iframe = (0,
|
|
9029
|
+
const iframe = (0, import_react59.useMemo)(
|
|
8734
9030
|
() => __spreadValues({
|
|
8735
9031
|
enabled: true,
|
|
8736
9032
|
waitForStyles: true
|
|
@@ -8738,12 +9034,24 @@ function PuckLayout({ children }) {
|
|
|
8738
9034
|
[_iframe]
|
|
8739
9035
|
);
|
|
8740
9036
|
useInjectGlobalCss(iframe.enabled);
|
|
9037
|
+
const dispatch = useAppStore((s) => s.dispatch);
|
|
8741
9038
|
const leftSideBarVisible = useAppStore((s) => s.state.ui.leftSideBarVisible);
|
|
8742
9039
|
const rightSideBarVisible = useAppStore(
|
|
8743
9040
|
(s) => s.state.ui.rightSideBarVisible
|
|
8744
9041
|
);
|
|
8745
|
-
const
|
|
8746
|
-
|
|
9042
|
+
const {
|
|
9043
|
+
width: leftWidth,
|
|
9044
|
+
setWidth: setLeftWidth,
|
|
9045
|
+
sidebarRef: leftSidebarRef,
|
|
9046
|
+
handleResizeEnd: handleLeftSidebarResizeEnd
|
|
9047
|
+
} = useSidebarResize("left", dispatch);
|
|
9048
|
+
const {
|
|
9049
|
+
width: rightWidth,
|
|
9050
|
+
setWidth: setRightWidth,
|
|
9051
|
+
sidebarRef: rightSidebarRef,
|
|
9052
|
+
handleResizeEnd: handleRightSidebarResizeEnd
|
|
9053
|
+
} = useSidebarResize("right", dispatch);
|
|
9054
|
+
(0, import_react59.useEffect)(() => {
|
|
8747
9055
|
if (!window.matchMedia("(min-width: 638px)").matches) {
|
|
8748
9056
|
dispatch({
|
|
8749
9057
|
type: "setUi",
|
|
@@ -8767,17 +9075,17 @@ function PuckLayout({ children }) {
|
|
|
8767
9075
|
};
|
|
8768
9076
|
}, []);
|
|
8769
9077
|
const overrides = useAppStore((s) => s.overrides);
|
|
8770
|
-
const CustomPuck = (0,
|
|
9078
|
+
const CustomPuck = (0, import_react59.useMemo)(
|
|
8771
9079
|
() => overrides.puck || DefaultOverride,
|
|
8772
9080
|
[overrides]
|
|
8773
9081
|
);
|
|
8774
|
-
const [mounted, setMounted] = (0,
|
|
8775
|
-
(0,
|
|
9082
|
+
const [mounted, setMounted] = (0, import_react59.useState)(false);
|
|
9083
|
+
(0, import_react59.useEffect)(() => {
|
|
8776
9084
|
setMounted(true);
|
|
8777
9085
|
}, []);
|
|
8778
9086
|
const ready = useAppStore((s) => s.status === "READY");
|
|
8779
9087
|
useMonitorHotkeys();
|
|
8780
|
-
(0,
|
|
9088
|
+
(0, import_react59.useEffect)(() => {
|
|
8781
9089
|
if (ready && iframe.enabled) {
|
|
8782
9090
|
const frameDoc = getFrame();
|
|
8783
9091
|
if (frameDoc) {
|
|
@@ -8786,8 +9094,8 @@ function PuckLayout({ children }) {
|
|
|
8786
9094
|
}
|
|
8787
9095
|
}, [ready, iframe.enabled]);
|
|
8788
9096
|
usePreviewModeHotkeys();
|
|
8789
|
-
return /* @__PURE__ */ (0,
|
|
8790
|
-
/* @__PURE__ */ (0,
|
|
9097
|
+
return /* @__PURE__ */ (0, import_jsx_runtime45.jsxs)("div", { className: `Puck ${getClassName30()}`, children: [
|
|
9098
|
+
/* @__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)(
|
|
8791
9099
|
"div",
|
|
8792
9100
|
{
|
|
8793
9101
|
className: getLayoutClassName({
|
|
@@ -8795,22 +9103,57 @@ function PuckLayout({ children }) {
|
|
|
8795
9103
|
mounted,
|
|
8796
9104
|
rightSideBarVisible
|
|
8797
9105
|
}),
|
|
8798
|
-
children: /* @__PURE__ */ (0,
|
|
8799
|
-
|
|
8800
|
-
|
|
8801
|
-
|
|
8802
|
-
|
|
8803
|
-
|
|
8804
|
-
|
|
8805
|
-
|
|
8806
|
-
|
|
9106
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime45.jsxs)(
|
|
9107
|
+
"div",
|
|
9108
|
+
{
|
|
9109
|
+
className: getLayoutClassName("inner"),
|
|
9110
|
+
style: {
|
|
9111
|
+
gridTemplateColumns: `
|
|
9112
|
+
${leftSideBarVisible ? leftWidth ? `${leftWidth}px` : "var(--puck-side-bar-width)" : "0"}
|
|
9113
|
+
var(--puck-frame-width)
|
|
9114
|
+
${rightSideBarVisible ? rightWidth ? `${rightWidth}px` : "var(--puck-side-bar-width)" : "0"}
|
|
9115
|
+
`
|
|
9116
|
+
},
|
|
9117
|
+
children: [
|
|
9118
|
+
/* @__PURE__ */ (0, import_jsx_runtime45.jsx)(Header, {}),
|
|
9119
|
+
/* @__PURE__ */ (0, import_jsx_runtime45.jsxs)(
|
|
9120
|
+
Sidebar,
|
|
9121
|
+
{
|
|
9122
|
+
position: "left",
|
|
9123
|
+
sidebarRef: leftSidebarRef,
|
|
9124
|
+
isVisible: leftSideBarVisible,
|
|
9125
|
+
width: leftWidth,
|
|
9126
|
+
onResize: setLeftWidth,
|
|
9127
|
+
onResizeEnd: handleLeftSidebarResizeEnd,
|
|
9128
|
+
children: [
|
|
9129
|
+
/* @__PURE__ */ (0, import_jsx_runtime45.jsx)(SidebarSection, { title: "Components", noBorderTop: true, children: /* @__PURE__ */ (0, import_jsx_runtime45.jsx)(Components, {}) }),
|
|
9130
|
+
/* @__PURE__ */ (0, import_jsx_runtime45.jsx)(SidebarSection, { title: "Outline", children: /* @__PURE__ */ (0, import_jsx_runtime45.jsx)(Outline, {}) })
|
|
9131
|
+
]
|
|
9132
|
+
}
|
|
9133
|
+
),
|
|
9134
|
+
/* @__PURE__ */ (0, import_jsx_runtime45.jsx)(Canvas, {}),
|
|
9135
|
+
/* @__PURE__ */ (0, import_jsx_runtime45.jsx)(
|
|
9136
|
+
Sidebar,
|
|
9137
|
+
{
|
|
9138
|
+
position: "right",
|
|
9139
|
+
sidebarRef: rightSidebarRef,
|
|
9140
|
+
isVisible: rightSideBarVisible,
|
|
9141
|
+
width: rightWidth,
|
|
9142
|
+
onResize: setRightWidth,
|
|
9143
|
+
onResizeEnd: handleRightSidebarResizeEnd,
|
|
9144
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime45.jsx)(FieldSideBar, {})
|
|
9145
|
+
}
|
|
9146
|
+
)
|
|
9147
|
+
]
|
|
9148
|
+
}
|
|
9149
|
+
)
|
|
8807
9150
|
}
|
|
8808
|
-
) }) }),
|
|
8809
|
-
/* @__PURE__ */ (0,
|
|
9151
|
+
) }) }) }),
|
|
9152
|
+
/* @__PURE__ */ (0, import_jsx_runtime45.jsx)("div", { id: "puck-portal-root", className: getClassName30("portal") })
|
|
8810
9153
|
] });
|
|
8811
9154
|
}
|
|
8812
9155
|
function Puck(props) {
|
|
8813
|
-
return /* @__PURE__ */ (0,
|
|
9156
|
+
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)) })) }));
|
|
8814
9157
|
}
|
|
8815
9158
|
Puck.Components = Components;
|
|
8816
9159
|
Puck.Fields = Fields;
|