@measured/puck 0.20.0-canary.8909f8cc → 0.20.0-canary.8f2f0f46
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/README.md +9 -9
- package/dist/{chunk-EMTLDPBH.mjs → chunk-5PAQR6UC.mjs} +797 -527
- package/dist/{chunk-32MJ3X3H.mjs → chunk-HUKJ36SA.mjs} +131 -69
- package/dist/index.css +116 -78
- package/dist/index.d.mts +17 -5
- package/dist/index.d.ts +17 -5
- package/dist/index.js +1042 -712
- package/dist/index.mjs +6 -2
- package/dist/no-external.css +116 -78
- package/dist/no-external.d.mts +2 -2
- package/dist/no-external.d.ts +2 -2
- package/dist/no-external.js +1042 -712
- package/dist/no-external.mjs +6 -2
- package/dist/rsc.d.mts +2 -2
- package/dist/rsc.d.ts +2 -2
- package/dist/rsc.js +138 -70
- package/dist/rsc.mjs +1 -1
- package/dist/{walk-tree-BCI5tk0w.d.mts → walk-tree-B57SgEEc.d.mts} +39 -3
- package/dist/{walk-tree-BCI5tk0w.d.ts → walk-tree-B57SgEEc.d.ts} +39 -3
- package/package.json +1 -1
|
@@ -12,17 +12,19 @@ import {
|
|
|
12
12
|
defaultViewports,
|
|
13
13
|
expandNode,
|
|
14
14
|
getChanged,
|
|
15
|
+
getSlotTransform,
|
|
15
16
|
init_react_import,
|
|
16
17
|
resolveComponentData,
|
|
17
18
|
rootAreaId,
|
|
18
19
|
rootDroppableId,
|
|
19
20
|
rootZone,
|
|
20
21
|
setupZone,
|
|
22
|
+
useFieldTransforms,
|
|
21
23
|
useSlots,
|
|
22
24
|
walkAppState,
|
|
23
25
|
walkField,
|
|
24
26
|
walkTree
|
|
25
|
-
} from "./chunk-
|
|
27
|
+
} from "./chunk-HUKJ36SA.mjs";
|
|
26
28
|
|
|
27
29
|
// ../../node_modules/classnames/index.js
|
|
28
30
|
var require_classnames = __commonJS({
|
|
@@ -93,8 +95,9 @@ var overrideKeys = [
|
|
|
93
95
|
"headerActions",
|
|
94
96
|
"fields",
|
|
95
97
|
"fieldLabel",
|
|
96
|
-
"
|
|
97
|
-
"
|
|
98
|
+
"drawer",
|
|
99
|
+
"drawerItem",
|
|
100
|
+
"componentOverlay",
|
|
98
101
|
"outline",
|
|
99
102
|
"puck",
|
|
100
103
|
"preview"
|
|
@@ -210,7 +213,6 @@ var replace = (list, index, newItem) => {
|
|
|
210
213
|
|
|
211
214
|
// lib/use-reset-auto-zoom.ts
|
|
212
215
|
init_react_import();
|
|
213
|
-
import { useCallback as useCallback2 } from "react";
|
|
214
216
|
|
|
215
217
|
// store/index.ts
|
|
216
218
|
init_react_import();
|
|
@@ -1271,7 +1273,8 @@ var createAppStore = (initialAppStore) => create2()(
|
|
|
1271
1273
|
},
|
|
1272
1274
|
status: "LOADING",
|
|
1273
1275
|
iframe: {},
|
|
1274
|
-
metadata: {}
|
|
1276
|
+
metadata: {},
|
|
1277
|
+
fieldTransforms: {}
|
|
1275
1278
|
}, initialAppStore), {
|
|
1276
1279
|
fields: createFieldsSlice(set, get),
|
|
1277
1280
|
history: createHistorySlice(set, get),
|
|
@@ -1587,56 +1590,18 @@ var getZoomConfig = (uiViewport, frame, zoom) => {
|
|
|
1587
1590
|
};
|
|
1588
1591
|
|
|
1589
1592
|
// lib/use-reset-auto-zoom.ts
|
|
1590
|
-
import { useShallow } from "zustand/react/shallow";
|
|
1591
1593
|
var useResetAutoZoom = (frameRef) => {
|
|
1592
|
-
const
|
|
1593
|
-
|
|
1594
|
-
|
|
1595
|
-
|
|
1596
|
-
|
|
1597
|
-
|
|
1598
|
-
|
|
1599
|
-
|
|
1600
|
-
|
|
1601
|
-
|
|
1602
|
-
|
|
1603
|
-
if (frameRef.current) {
|
|
1604
|
-
setZoomConfig(
|
|
1605
|
-
getZoomConfig(
|
|
1606
|
-
newViewports == null ? void 0 : newViewports.current,
|
|
1607
|
-
frameRef.current,
|
|
1608
|
-
zoomConfig.zoom
|
|
1609
|
-
)
|
|
1610
|
-
);
|
|
1611
|
-
}
|
|
1612
|
-
return;
|
|
1613
|
-
}
|
|
1614
|
-
const {
|
|
1615
|
-
isResettingRef,
|
|
1616
|
-
setShowTransition,
|
|
1617
|
-
showTransition = false
|
|
1618
|
-
} = options;
|
|
1619
|
-
if (!isResettingRef.current) {
|
|
1620
|
-
isResettingRef.current = true;
|
|
1621
|
-
if (setShowTransition) {
|
|
1622
|
-
setShowTransition(showTransition);
|
|
1623
|
-
}
|
|
1624
|
-
if (frameRef.current) {
|
|
1625
|
-
setZoomConfig(
|
|
1626
|
-
getZoomConfig(
|
|
1627
|
-
newViewports == null ? void 0 : newViewports.current,
|
|
1628
|
-
frameRef.current,
|
|
1629
|
-
zoomConfig.zoom
|
|
1630
|
-
)
|
|
1631
|
-
);
|
|
1632
|
-
}
|
|
1633
|
-
setTimeout(() => {
|
|
1634
|
-
isResettingRef.current = false;
|
|
1635
|
-
}, 0);
|
|
1636
|
-
}
|
|
1637
|
-
},
|
|
1638
|
-
[frameRef, zoomConfig, viewports, setZoomConfig]
|
|
1639
|
-
);
|
|
1594
|
+
const appStoreApi = useAppStoreApi();
|
|
1595
|
+
const resetAutoZoom = (options) => {
|
|
1596
|
+
const { state, zoomConfig, setZoomConfig } = appStoreApi.getState();
|
|
1597
|
+
const { viewports } = state.ui;
|
|
1598
|
+
const newViewports = (options == null ? void 0 : options.viewports) || viewports;
|
|
1599
|
+
if (frameRef.current) {
|
|
1600
|
+
setZoomConfig(
|
|
1601
|
+
getZoomConfig(newViewports == null ? void 0 : newViewports.current, frameRef.current, zoomConfig.zoom)
|
|
1602
|
+
);
|
|
1603
|
+
}
|
|
1604
|
+
};
|
|
1640
1605
|
return resetAutoZoom;
|
|
1641
1606
|
};
|
|
1642
1607
|
|
|
@@ -1817,11 +1782,11 @@ init_react_import();
|
|
|
1817
1782
|
|
|
1818
1783
|
// css-module:/home/runner/work/puck/puck/packages/core/components/AutoField/styles.module.css#css-module
|
|
1819
1784
|
init_react_import();
|
|
1820
|
-
var styles_module_default3 = { "InputWrapper": "
|
|
1785
|
+
var styles_module_default3 = { "InputWrapper": "_InputWrapper_bsxfo_1", "Input-label": "_Input-label_bsxfo_5", "Input-labelIcon": "_Input-labelIcon_bsxfo_14", "Input-disabledIcon": "_Input-disabledIcon_bsxfo_21", "Input-input": "_Input-input_bsxfo_26", "Input": "_Input_bsxfo_1", "Input--readOnly": "_Input--readOnly_bsxfo_82", "Input-radioGroupItems": "_Input-radioGroupItems_bsxfo_93", "Input-radio": "_Input-radio_bsxfo_93", "Input-radioInner": "_Input-radioInner_bsxfo_110", "Input-radioInput": "_Input-radioInput_bsxfo_155" };
|
|
1821
1786
|
|
|
1822
1787
|
// components/AutoField/index.tsx
|
|
1823
1788
|
import {
|
|
1824
|
-
useCallback as
|
|
1789
|
+
useCallback as useCallback4,
|
|
1825
1790
|
useContext as useContext3,
|
|
1826
1791
|
useEffect as useEffect10,
|
|
1827
1792
|
useMemo as useMemo3,
|
|
@@ -2169,7 +2134,7 @@ var ZoomOut = createLucideIcon("ZoomOut", [
|
|
|
2169
2134
|
init_react_import();
|
|
2170
2135
|
|
|
2171
2136
|
// components/AutoField/fields/ArrayField/index.tsx
|
|
2172
|
-
import { useCallback as
|
|
2137
|
+
import { useCallback as useCallback2, useEffect as useEffect6, useRef, useState as useState4 } from "react";
|
|
2173
2138
|
|
|
2174
2139
|
// components/DragIcon/index.tsx
|
|
2175
2140
|
init_react_import();
|
|
@@ -2697,7 +2662,7 @@ var ArrayField = ({
|
|
|
2697
2662
|
setLocalState({ arrayState: _arrayState, value });
|
|
2698
2663
|
}, [value]);
|
|
2699
2664
|
const appStore = useAppStoreApi();
|
|
2700
|
-
const mapArrayStateToUi =
|
|
2665
|
+
const mapArrayStateToUi = useCallback2(
|
|
2701
2666
|
(partialArrayState) => {
|
|
2702
2667
|
const state = appStore.getState().state;
|
|
2703
2668
|
return {
|
|
@@ -2708,13 +2673,13 @@ var ArrayField = ({
|
|
|
2708
2673
|
},
|
|
2709
2674
|
[arrayState, appStore]
|
|
2710
2675
|
);
|
|
2711
|
-
const getHighestIndex =
|
|
2676
|
+
const getHighestIndex = useCallback2(() => {
|
|
2712
2677
|
return arrayState.items.reduce(
|
|
2713
2678
|
(acc, item) => item._originalIndex > acc ? item._originalIndex : acc,
|
|
2714
2679
|
-1
|
|
2715
2680
|
);
|
|
2716
2681
|
}, [arrayState]);
|
|
2717
|
-
const regenerateArrayState =
|
|
2682
|
+
const regenerateArrayState = useCallback2(
|
|
2718
2683
|
(value2) => {
|
|
2719
2684
|
let highestIndex = getHighestIndex();
|
|
2720
2685
|
const newItems = Array.from(value2 || []).map((item, idx) => {
|
|
@@ -2745,14 +2710,19 @@ var ArrayField = ({
|
|
|
2745
2710
|
);
|
|
2746
2711
|
const forceReadOnly = !canEdit;
|
|
2747
2712
|
const valueRef = useRef(value);
|
|
2748
|
-
const uniqifyItem =
|
|
2713
|
+
const uniqifyItem = useCallback2(
|
|
2749
2714
|
(val) => {
|
|
2750
2715
|
if (field.type !== "array" || !field.arrayFields) return;
|
|
2751
2716
|
const config = appStore.getState().config;
|
|
2752
2717
|
return walkField({
|
|
2753
2718
|
value: val,
|
|
2754
2719
|
fields: field.arrayFields,
|
|
2755
|
-
|
|
2720
|
+
mappers: {
|
|
2721
|
+
slot: ({ value: value2 }) => {
|
|
2722
|
+
const content = value2;
|
|
2723
|
+
return content.map((item) => populateIds(item, config, true));
|
|
2724
|
+
}
|
|
2725
|
+
},
|
|
2756
2726
|
config
|
|
2757
2727
|
});
|
|
2758
2728
|
},
|
|
@@ -2907,49 +2877,51 @@ var ArrayField = ({
|
|
|
2907
2877
|
]
|
|
2908
2878
|
}
|
|
2909
2879
|
),
|
|
2910
|
-
/* @__PURE__ */ jsx8("div", { className: getClassNameItem("body"), children: /* @__PURE__ */ jsx8("fieldset", { className: getClassNameItem("fieldset"), children: Object.keys(field.arrayFields).map(
|
|
2911
|
-
|
|
2912
|
-
|
|
2913
|
-
|
|
2914
|
-
|
|
2915
|
-
|
|
2916
|
-
|
|
2917
|
-
|
|
2918
|
-
|
|
2919
|
-
|
|
2920
|
-
|
|
2921
|
-
|
|
2922
|
-
|
|
2923
|
-
|
|
2924
|
-
|
|
2925
|
-
|
|
2926
|
-
|
|
2927
|
-
|
|
2928
|
-
|
|
2929
|
-
|
|
2930
|
-
|
|
2931
|
-
|
|
2932
|
-
|
|
2933
|
-
|
|
2934
|
-
|
|
2935
|
-
|
|
2936
|
-
|
|
2937
|
-
|
|
2938
|
-
|
|
2939
|
-
|
|
2940
|
-
onChange(
|
|
2941
|
-
|
|
2942
|
-
|
|
2943
|
-
|
|
2944
|
-
|
|
2945
|
-
|
|
2880
|
+
/* @__PURE__ */ jsx8("div", { className: getClassNameItem("body"), children: arrayState.openId === _arrayId && /* @__PURE__ */ jsx8("fieldset", { className: getClassNameItem("fieldset"), children: Object.keys(field.arrayFields).map(
|
|
2881
|
+
(subName) => {
|
|
2882
|
+
const subField = field.arrayFields[subName];
|
|
2883
|
+
const indexName = `${name}[${i}]`;
|
|
2884
|
+
const subPath = `${indexName}.${subName}`;
|
|
2885
|
+
const localIndexName = `${localName}[${i}]`;
|
|
2886
|
+
const localWildcardName = `${localName}[*]`;
|
|
2887
|
+
const localSubPath = `${localIndexName}.${subName}`;
|
|
2888
|
+
const localWildcardSubPath = `${localWildcardName}.${subName}`;
|
|
2889
|
+
const subReadOnly = forceReadOnly ? forceReadOnly : typeof readOnlyFields[subPath] !== "undefined" ? readOnlyFields[localSubPath] : readOnlyFields[localWildcardSubPath];
|
|
2890
|
+
const label2 = subField.label || subName;
|
|
2891
|
+
return /* @__PURE__ */ jsx8(
|
|
2892
|
+
NestedFieldProvider,
|
|
2893
|
+
{
|
|
2894
|
+
name: localIndexName,
|
|
2895
|
+
wildcardName: localWildcardName,
|
|
2896
|
+
subName,
|
|
2897
|
+
readOnlyFields,
|
|
2898
|
+
children: /* @__PURE__ */ jsx8(
|
|
2899
|
+
AutoFieldPrivate,
|
|
2900
|
+
{
|
|
2901
|
+
name: subPath,
|
|
2902
|
+
label: label2,
|
|
2903
|
+
id: `${_arrayId}_${subName}`,
|
|
2904
|
+
readOnly: subReadOnly,
|
|
2905
|
+
field: __spreadProps(__spreadValues({}, subField), {
|
|
2906
|
+
label: label2
|
|
2907
|
+
// May be used by custom fields
|
|
2908
|
+
}),
|
|
2909
|
+
value: data[subName],
|
|
2910
|
+
onChange: (val, ui) => {
|
|
2911
|
+
onChange(
|
|
2912
|
+
replace(value, i, __spreadProps(__spreadValues({}, data), {
|
|
2913
|
+
[subName]: val
|
|
2914
|
+
})),
|
|
2915
|
+
ui
|
|
2916
|
+
);
|
|
2917
|
+
}
|
|
2946
2918
|
}
|
|
2947
|
-
|
|
2948
|
-
|
|
2949
|
-
|
|
2950
|
-
|
|
2951
|
-
|
|
2952
|
-
|
|
2919
|
+
)
|
|
2920
|
+
},
|
|
2921
|
+
subPath
|
|
2922
|
+
);
|
|
2923
|
+
}
|
|
2924
|
+
) }) })
|
|
2953
2925
|
]
|
|
2954
2926
|
}
|
|
2955
2927
|
)
|
|
@@ -3058,7 +3030,7 @@ import {
|
|
|
3058
3030
|
useMemo as useMemo2,
|
|
3059
3031
|
useEffect as useEffect8,
|
|
3060
3032
|
useState as useState6,
|
|
3061
|
-
useCallback as
|
|
3033
|
+
useCallback as useCallback3,
|
|
3062
3034
|
isValidElement
|
|
3063
3035
|
} from "react";
|
|
3064
3036
|
|
|
@@ -3168,7 +3140,7 @@ var ExternalInput = ({
|
|
|
3168
3140
|
return Array.from(validKeys);
|
|
3169
3141
|
}, [mappedData]);
|
|
3170
3142
|
const [searchQuery, setSearchQuery] = useState6(field.initialQuery || "");
|
|
3171
|
-
const search =
|
|
3143
|
+
const search = useCallback3(
|
|
3172
3144
|
(query, filters2) => __async(void 0, null, function* () {
|
|
3173
3145
|
setIsLoading(true);
|
|
3174
3146
|
const cacheKey = `${id}-${query}-${JSON.stringify(filters2)}`;
|
|
@@ -3181,7 +3153,7 @@ var ExternalInput = ({
|
|
|
3181
3153
|
}),
|
|
3182
3154
|
[id, field]
|
|
3183
3155
|
);
|
|
3184
|
-
const Footer =
|
|
3156
|
+
const Footer = useCallback3(
|
|
3185
3157
|
(props) => field.renderFooter ? field.renderFooter(props) : /* @__PURE__ */ jsxs6("span", { className: getClassNameModal("footer"), children: [
|
|
3186
3158
|
props.items.length,
|
|
3187
3159
|
" result",
|
|
@@ -3724,7 +3696,7 @@ function AutoFieldInternal(props) {
|
|
|
3724
3696
|
Label: Label2,
|
|
3725
3697
|
id: resolvedId
|
|
3726
3698
|
});
|
|
3727
|
-
const onFocus =
|
|
3699
|
+
const onFocus = useCallback4(
|
|
3728
3700
|
(e) => {
|
|
3729
3701
|
if (mergedProps.name && (e.target.nodeName === "INPUT" || e.target.nodeName === "TEXTAREA")) {
|
|
3730
3702
|
e.stopPropagation();
|
|
@@ -3738,7 +3710,7 @@ function AutoFieldInternal(props) {
|
|
|
3738
3710
|
},
|
|
3739
3711
|
[mergedProps.name]
|
|
3740
3712
|
);
|
|
3741
|
-
const onBlur =
|
|
3713
|
+
const onBlur = useCallback4((e) => {
|
|
3742
3714
|
if ("name" in e.target) {
|
|
3743
3715
|
dispatch({
|
|
3744
3716
|
type: "setUi",
|
|
@@ -3792,7 +3764,7 @@ function AutoFieldPrivate(props) {
|
|
|
3792
3764
|
const isFocused = useAppStore((s) => s.state.ui.field.focus === props.name);
|
|
3793
3765
|
const { value, onChange } = props;
|
|
3794
3766
|
const [localValue, setLocalValue] = useState8(value);
|
|
3795
|
-
const onChangeLocal =
|
|
3767
|
+
const onChangeLocal = useCallback4(
|
|
3796
3768
|
(val, ui) => {
|
|
3797
3769
|
setLocalValue(val);
|
|
3798
3770
|
onChange(val, ui);
|
|
@@ -3840,18 +3812,18 @@ init_react_import();
|
|
|
3840
3812
|
init_react_import();
|
|
3841
3813
|
import {
|
|
3842
3814
|
forwardRef as forwardRef3,
|
|
3843
|
-
memo,
|
|
3844
|
-
useCallback as
|
|
3815
|
+
memo as memo2,
|
|
3816
|
+
useCallback as useCallback11,
|
|
3845
3817
|
useContext as useContext8,
|
|
3846
|
-
useEffect as
|
|
3818
|
+
useEffect as useEffect18,
|
|
3847
3819
|
useMemo as useMemo8,
|
|
3848
|
-
useRef as
|
|
3820
|
+
useRef as useRef6
|
|
3849
3821
|
} from "react";
|
|
3850
3822
|
|
|
3851
3823
|
// components/DraggableComponent/index.tsx
|
|
3852
3824
|
init_react_import();
|
|
3853
3825
|
import {
|
|
3854
|
-
useCallback as
|
|
3826
|
+
useCallback as useCallback7,
|
|
3855
3827
|
useContext as useContext5,
|
|
3856
3828
|
useEffect as useEffect12,
|
|
3857
3829
|
useMemo as useMemo5,
|
|
@@ -3862,7 +3834,7 @@ import {
|
|
|
3862
3834
|
|
|
3863
3835
|
// css-module:/home/runner/work/puck/puck/packages/core/components/DraggableComponent/styles.module.css#css-module
|
|
3864
3836
|
init_react_import();
|
|
3865
|
-
var styles_module_default10 = { "DraggableComponent": "
|
|
3837
|
+
var styles_module_default10 = { "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" };
|
|
3866
3838
|
|
|
3867
3839
|
// components/DraggableComponent/index.tsx
|
|
3868
3840
|
import { createPortal as createPortal2 } from "react-dom";
|
|
@@ -3890,7 +3862,7 @@ function getDeepScrollPosition(element) {
|
|
|
3890
3862
|
init_react_import();
|
|
3891
3863
|
import {
|
|
3892
3864
|
createContext as createContext3,
|
|
3893
|
-
useCallback as
|
|
3865
|
+
useCallback as useCallback5,
|
|
3894
3866
|
useMemo as useMemo4
|
|
3895
3867
|
} from "react";
|
|
3896
3868
|
import { createStore as createStore2 } from "zustand";
|
|
@@ -3919,7 +3891,7 @@ var DropZoneProvider = ({
|
|
|
3919
3891
|
value
|
|
3920
3892
|
}) => {
|
|
3921
3893
|
const dispatch = useAppStore((s) => s.dispatch);
|
|
3922
|
-
const registerZone =
|
|
3894
|
+
const registerZone = useCallback5(
|
|
3923
3895
|
(zoneCompound) => {
|
|
3924
3896
|
dispatch({
|
|
3925
3897
|
type: "registerZone",
|
|
@@ -3938,7 +3910,7 @@ var DropZoneProvider = ({
|
|
|
3938
3910
|
};
|
|
3939
3911
|
|
|
3940
3912
|
// components/DraggableComponent/index.tsx
|
|
3941
|
-
import { useShallow as
|
|
3913
|
+
import { useShallow as useShallow2 } from "zustand/react/shallow";
|
|
3942
3914
|
import { useSortable as useSortable2 } from "@dnd-kit/react/sortable";
|
|
3943
3915
|
|
|
3944
3916
|
// lib/accumulate-transform.ts
|
|
@@ -3960,21 +3932,21 @@ function accumulateTransform(el) {
|
|
|
3960
3932
|
init_react_import();
|
|
3961
3933
|
import { useContext as useContext4 } from "react";
|
|
3962
3934
|
import { useStore as useStore2 } from "zustand";
|
|
3963
|
-
import { useShallow
|
|
3935
|
+
import { useShallow } from "zustand/react/shallow";
|
|
3964
3936
|
function useContextStore(context, selector) {
|
|
3965
3937
|
const store = useContext4(context);
|
|
3966
3938
|
if (!store) {
|
|
3967
3939
|
throw new Error("useContextStore must be used inside context");
|
|
3968
3940
|
}
|
|
3969
|
-
return useStore2(store,
|
|
3941
|
+
return useStore2(store, useShallow(selector));
|
|
3970
3942
|
}
|
|
3971
3943
|
|
|
3972
3944
|
// lib/dnd/use-on-drag-finished.ts
|
|
3973
3945
|
init_react_import();
|
|
3974
|
-
import { useCallback as
|
|
3946
|
+
import { useCallback as useCallback6 } from "react";
|
|
3975
3947
|
var useOnDragFinished = (cb, deps = []) => {
|
|
3976
3948
|
const appStore = useAppStoreApi();
|
|
3977
|
-
return
|
|
3949
|
+
return useCallback6(() => {
|
|
3978
3950
|
let dispose = () => {
|
|
3979
3951
|
};
|
|
3980
3952
|
const processDragging = (isDragging2) => {
|
|
@@ -4002,7 +3974,7 @@ var useOnDragFinished = (cb, deps = []) => {
|
|
|
4002
3974
|
};
|
|
4003
3975
|
|
|
4004
3976
|
// components/DraggableComponent/index.tsx
|
|
4005
|
-
import { jsx as jsx20, jsxs as jsxs9 } from "react/jsx-runtime";
|
|
3977
|
+
import { Fragment as Fragment6, jsx as jsx20, jsxs as jsxs9 } from "react/jsx-runtime";
|
|
4006
3978
|
var getClassName16 = get_class_name_factory_default("DraggableComponent", styles_module_default10);
|
|
4007
3979
|
var DEBUG2 = false;
|
|
4008
3980
|
var space = 8;
|
|
@@ -4020,6 +3992,9 @@ var DefaultActionBar = ({
|
|
|
4020
3992
|
] }),
|
|
4021
3993
|
/* @__PURE__ */ jsx20(ActionBar.Group, { children })
|
|
4022
3994
|
] });
|
|
3995
|
+
var DefaultOverlay = ({
|
|
3996
|
+
children
|
|
3997
|
+
}) => /* @__PURE__ */ jsx20(Fragment6, { children });
|
|
4023
3998
|
var DraggableComponent = ({
|
|
4024
3999
|
children,
|
|
4025
4000
|
depth,
|
|
@@ -4046,7 +4021,7 @@ var DraggableComponent = ({
|
|
|
4046
4021
|
const iframe = useAppStore((s) => s.iframe);
|
|
4047
4022
|
const ctx = useContext5(dropZoneContext);
|
|
4048
4023
|
const [localZones, setLocalZones] = useState10({});
|
|
4049
|
-
const registerLocalZone =
|
|
4024
|
+
const registerLocalZone = useCallback7(
|
|
4050
4025
|
(zoneCompound2, active) => {
|
|
4051
4026
|
var _a;
|
|
4052
4027
|
(_a = ctx == null ? void 0 : ctx.registerLocalZone) == null ? void 0 : _a.call(ctx, zoneCompound2, active);
|
|
@@ -4056,7 +4031,7 @@ var DraggableComponent = ({
|
|
|
4056
4031
|
},
|
|
4057
4032
|
[setLocalZones]
|
|
4058
4033
|
);
|
|
4059
|
-
const unregisterLocalZone =
|
|
4034
|
+
const unregisterLocalZone = useCallback7(
|
|
4060
4035
|
(zoneCompound2) => {
|
|
4061
4036
|
var _a;
|
|
4062
4037
|
(_a = ctx == null ? void 0 : ctx.unregisterLocalZone) == null ? void 0 : _a.call(ctx, zoneCompound2);
|
|
@@ -4069,12 +4044,12 @@ var DraggableComponent = ({
|
|
|
4069
4044
|
[setLocalZones]
|
|
4070
4045
|
);
|
|
4071
4046
|
const containsActiveZone = Object.values(localZones).filter(Boolean).length > 0;
|
|
4072
|
-
const path = useAppStore(
|
|
4047
|
+
const path = useAppStore(useShallow2((s) => {
|
|
4073
4048
|
var _a;
|
|
4074
4049
|
return (_a = s.state.indexes.nodes[id]) == null ? void 0 : _a.path;
|
|
4075
4050
|
}));
|
|
4076
4051
|
const permissions = useAppStore(
|
|
4077
|
-
|
|
4052
|
+
useShallow2((s) => {
|
|
4078
4053
|
const item = getItem({ index, zone: zoneCompound }, s.state);
|
|
4079
4054
|
return s.permissions.getPermissions({ item });
|
|
4080
4055
|
})
|
|
@@ -4131,7 +4106,7 @@ var DraggableComponent = ({
|
|
|
4131
4106
|
return cleanup;
|
|
4132
4107
|
}, [permissions.drag, zoneCompound]);
|
|
4133
4108
|
const ref = useRef2(null);
|
|
4134
|
-
const refSetter =
|
|
4109
|
+
const refSetter = useCallback7(
|
|
4135
4110
|
(el) => {
|
|
4136
4111
|
sortableRef(el);
|
|
4137
4112
|
if (el) {
|
|
@@ -4147,7 +4122,7 @@ var DraggableComponent = ({
|
|
|
4147
4122
|
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
|
|
4148
4123
|
);
|
|
4149
4124
|
}, [iframe.enabled, ref.current]);
|
|
4150
|
-
const getStyle =
|
|
4125
|
+
const getStyle = useCallback7(() => {
|
|
4151
4126
|
var _a, _b, _c;
|
|
4152
4127
|
if (!ref.current) return;
|
|
4153
4128
|
const rect = ref.current.getBoundingClientRect();
|
|
@@ -4173,7 +4148,7 @@ var DraggableComponent = ({
|
|
|
4173
4148
|
return style2;
|
|
4174
4149
|
}, [ref.current]);
|
|
4175
4150
|
const [style, setStyle] = useState10();
|
|
4176
|
-
const sync =
|
|
4151
|
+
const sync = useCallback7(() => {
|
|
4177
4152
|
setStyle(getStyle());
|
|
4178
4153
|
}, [ref.current, iframe]);
|
|
4179
4154
|
useEffect12(() => {
|
|
@@ -4186,10 +4161,10 @@ var DraggableComponent = ({
|
|
|
4186
4161
|
}
|
|
4187
4162
|
}, [ref.current]);
|
|
4188
4163
|
const registerNode = useAppStore((s) => s.nodes.registerNode);
|
|
4189
|
-
const hideOverlay =
|
|
4164
|
+
const hideOverlay = useCallback7(() => {
|
|
4190
4165
|
setIsVisible(false);
|
|
4191
4166
|
}, []);
|
|
4192
|
-
const showOverlay =
|
|
4167
|
+
const showOverlay = useCallback7(() => {
|
|
4193
4168
|
setIsVisible(true);
|
|
4194
4169
|
}, []);
|
|
4195
4170
|
useEffect12(() => {
|
|
@@ -4213,9 +4188,16 @@ var DraggableComponent = ({
|
|
|
4213
4188
|
() => overrides.actionBar || DefaultActionBar,
|
|
4214
4189
|
[overrides.actionBar]
|
|
4215
4190
|
);
|
|
4216
|
-
const
|
|
4191
|
+
const CustomOverlay = useMemo5(
|
|
4192
|
+
() => overrides.componentOverlay || DefaultOverlay,
|
|
4193
|
+
[overrides.componentOverlay]
|
|
4194
|
+
);
|
|
4195
|
+
const onClick = useCallback7(
|
|
4217
4196
|
(e) => {
|
|
4218
|
-
e.
|
|
4197
|
+
const el = e.target;
|
|
4198
|
+
if (!el.closest("[data-puck-overlay-portal]")) {
|
|
4199
|
+
e.stopPropagation();
|
|
4200
|
+
}
|
|
4219
4201
|
dispatch({
|
|
4220
4202
|
type: "setUi",
|
|
4221
4203
|
ui: {
|
|
@@ -4226,7 +4208,7 @@ var DraggableComponent = ({
|
|
|
4226
4208
|
[index, zoneCompound, id]
|
|
4227
4209
|
);
|
|
4228
4210
|
const appStore = useAppStoreApi();
|
|
4229
|
-
const onSelectParent =
|
|
4211
|
+
const onSelectParent = useCallback7(() => {
|
|
4230
4212
|
const { nodes, zones } = appStore.getState().state.indexes;
|
|
4231
4213
|
const node = nodes[id];
|
|
4232
4214
|
const parentNode = (node == null ? void 0 : node.parentId) ? nodes[node == null ? void 0 : node.parentId] : null;
|
|
@@ -4247,14 +4229,14 @@ var DraggableComponent = ({
|
|
|
4247
4229
|
}
|
|
4248
4230
|
});
|
|
4249
4231
|
}, [ctx, path]);
|
|
4250
|
-
const onDuplicate =
|
|
4232
|
+
const onDuplicate = useCallback7(() => {
|
|
4251
4233
|
dispatch({
|
|
4252
4234
|
type: "duplicate",
|
|
4253
4235
|
sourceIndex: index,
|
|
4254
4236
|
sourceZone: zoneCompound
|
|
4255
4237
|
});
|
|
4256
4238
|
}, [index, zoneCompound]);
|
|
4257
|
-
const onDelete =
|
|
4239
|
+
const onDelete = useCallback7(() => {
|
|
4258
4240
|
dispatch({
|
|
4259
4241
|
type: "remove",
|
|
4260
4242
|
index,
|
|
@@ -4344,7 +4326,7 @@ var DraggableComponent = ({
|
|
|
4344
4326
|
useEffect12(() => {
|
|
4345
4327
|
if (thisWasDragging) return onDragFinished();
|
|
4346
4328
|
}, [thisWasDragging, onDragFinished]);
|
|
4347
|
-
const syncActionsPosition =
|
|
4329
|
+
const syncActionsPosition = useCallback7(
|
|
4348
4330
|
(el) => {
|
|
4349
4331
|
if (el) {
|
|
4350
4332
|
const view = el.ownerDocument.defaultView;
|
|
@@ -4455,7 +4437,16 @@ var DraggableComponent = ({
|
|
|
4455
4437
|
)
|
|
4456
4438
|
}
|
|
4457
4439
|
),
|
|
4458
|
-
/* @__PURE__ */ jsx20("div", { className: getClassName16("
|
|
4440
|
+
/* @__PURE__ */ jsx20("div", { className: getClassName16("overlayWrapper"), children: /* @__PURE__ */ jsx20(
|
|
4441
|
+
CustomOverlay,
|
|
4442
|
+
{
|
|
4443
|
+
componentId: id,
|
|
4444
|
+
componentType,
|
|
4445
|
+
hover,
|
|
4446
|
+
isSelected,
|
|
4447
|
+
children: /* @__PURE__ */ jsx20("div", { className: getClassName16("overlay") })
|
|
4448
|
+
}
|
|
4449
|
+
) })
|
|
4459
4450
|
]
|
|
4460
4451
|
}
|
|
4461
4452
|
),
|
|
@@ -4487,7 +4478,7 @@ init_react_import();
|
|
|
4487
4478
|
import { DragDropProvider as DragDropProvider2 } from "@dnd-kit/react";
|
|
4488
4479
|
import {
|
|
4489
4480
|
createContext as createContext4,
|
|
4490
|
-
useCallback as
|
|
4481
|
+
useCallback as useCallback8,
|
|
4491
4482
|
useContext as useContext6,
|
|
4492
4483
|
useEffect as useEffect13,
|
|
4493
4484
|
useMemo as useMemo6,
|
|
@@ -4846,7 +4837,7 @@ function useDragListener(type, fn, deps = []) {
|
|
|
4846
4837
|
var AREA_CHANGE_DEBOUNCE_MS = 100;
|
|
4847
4838
|
var useTempDisableFallback = (timeout3) => {
|
|
4848
4839
|
const lastFallbackDisable = useRef3(null);
|
|
4849
|
-
return
|
|
4840
|
+
return useCallback8((manager) => {
|
|
4850
4841
|
collisionStore.setState({ fallbackEnabled: false });
|
|
4851
4842
|
const fallbackId = generateId();
|
|
4852
4843
|
lastFallbackDisable.current = fallbackId;
|
|
@@ -4879,7 +4870,7 @@ var DragDropContextClient = ({
|
|
|
4879
4870
|
hoveringComponent: null
|
|
4880
4871
|
}))
|
|
4881
4872
|
);
|
|
4882
|
-
const getChanged2 =
|
|
4873
|
+
const getChanged2 = useCallback8(
|
|
4883
4874
|
(params, id2) => {
|
|
4884
4875
|
const { zoneDepthIndex = {}, areaDepthIndex = {} } = zoneStore.getState() || {};
|
|
4885
4876
|
const stateHasZone = Object.keys(zoneDepthIndex).length > 0;
|
|
@@ -4900,7 +4891,7 @@ var DragDropContextClient = ({
|
|
|
4900
4891
|
},
|
|
4901
4892
|
[zoneStore]
|
|
4902
4893
|
);
|
|
4903
|
-
const setDeepestAndCollide =
|
|
4894
|
+
const setDeepestAndCollide = useCallback8(
|
|
4904
4895
|
(params, manager) => {
|
|
4905
4896
|
const { zoneChanged, areaChanged } = getChanged2(params, id);
|
|
4906
4897
|
if (!zoneChanged && !areaChanged) return;
|
|
@@ -5454,10 +5445,10 @@ import { useContext as useContext7, useEffect as useEffect15, useState as useSta
|
|
|
5454
5445
|
// lib/dnd/use-rendered-callback.ts
|
|
5455
5446
|
init_react_import();
|
|
5456
5447
|
import { useDragDropManager } from "@dnd-kit/react";
|
|
5457
|
-
import { useCallback as
|
|
5448
|
+
import { useCallback as useCallback9 } from "react";
|
|
5458
5449
|
function useRenderedCallback(callback, deps) {
|
|
5459
5450
|
const manager = useDragDropManager();
|
|
5460
|
-
return
|
|
5451
|
+
return useCallback9(
|
|
5461
5452
|
(...args) => __async(this, null, function* () {
|
|
5462
5453
|
yield manager == null ? void 0 : manager.renderer.rendering;
|
|
5463
5454
|
return callback(...args);
|
|
@@ -5528,7 +5519,7 @@ var useContentIdsWithPreview = (contentIds, zoneCompound) => {
|
|
|
5528
5519
|
|
|
5529
5520
|
// components/DropZone/lib/use-drag-axis.ts
|
|
5530
5521
|
init_react_import();
|
|
5531
|
-
import { useCallback as
|
|
5522
|
+
import { useCallback as useCallback10, useEffect as useEffect16, useState as useState15 } from "react";
|
|
5532
5523
|
var GRID_DRAG_AXIS = "dynamic";
|
|
5533
5524
|
var FLEX_ROW_DRAG_AXIS = "x";
|
|
5534
5525
|
var DEFAULT_DRAG_AXIS = "y";
|
|
@@ -5537,7 +5528,7 @@ var useDragAxis = (ref, collisionAxis) => {
|
|
|
5537
5528
|
const [dragAxis, setDragAxis] = useState15(
|
|
5538
5529
|
collisionAxis || DEFAULT_DRAG_AXIS
|
|
5539
5530
|
);
|
|
5540
|
-
const calculateDragAxis =
|
|
5531
|
+
const calculateDragAxis = useCallback10(() => {
|
|
5541
5532
|
if (ref.current) {
|
|
5542
5533
|
const computedStyle = window.getComputedStyle(ref.current);
|
|
5543
5534
|
if (computedStyle.display === "grid") {
|
|
@@ -5563,11 +5554,11 @@ var useDragAxis = (ref, collisionAxis) => {
|
|
|
5563
5554
|
};
|
|
5564
5555
|
|
|
5565
5556
|
// components/DropZone/index.tsx
|
|
5566
|
-
import { useShallow as
|
|
5557
|
+
import { useShallow as useShallow4 } from "zustand/react/shallow";
|
|
5567
5558
|
|
|
5568
5559
|
// components/SlotRender/index.tsx
|
|
5569
5560
|
init_react_import();
|
|
5570
|
-
import { useShallow as
|
|
5561
|
+
import { useShallow as useShallow3 } from "zustand/react/shallow";
|
|
5571
5562
|
import { jsx as jsx23 } from "react/jsx-runtime";
|
|
5572
5563
|
var ContextSlotRender = ({
|
|
5573
5564
|
componentId,
|
|
@@ -5576,7 +5567,7 @@ var ContextSlotRender = ({
|
|
|
5576
5567
|
const config = useAppStore((s) => s.config);
|
|
5577
5568
|
const metadata = useAppStore((s) => s.metadata);
|
|
5578
5569
|
const slotContent = useAppStore(
|
|
5579
|
-
|
|
5570
|
+
useShallow3((s) => {
|
|
5580
5571
|
var _a, _b;
|
|
5581
5572
|
const indexes = s.state.indexes;
|
|
5582
5573
|
const contentIds = (_b = (_a = indexes.zones[`${componentId}:${zone}`]) == null ? void 0 : _a.contentIds) != null ? _b : [];
|
|
@@ -5594,12 +5585,259 @@ var ContextSlotRender = ({
|
|
|
5594
5585
|
);
|
|
5595
5586
|
};
|
|
5596
5587
|
|
|
5588
|
+
// lib/field-transforms/default-transforms/inline-text-transform.tsx
|
|
5589
|
+
init_react_import();
|
|
5590
|
+
|
|
5591
|
+
// components/InlineTextField/index.tsx
|
|
5592
|
+
init_react_import();
|
|
5593
|
+
import { memo, useEffect as useEffect17, useRef as useRef5, useState as useState16 } from "react";
|
|
5594
|
+
|
|
5595
|
+
// lib/overlay-portal/index.tsx
|
|
5596
|
+
init_react_import();
|
|
5597
|
+
var registerOverlayPortal = (el, opts = {}) => {
|
|
5598
|
+
if (!el) return;
|
|
5599
|
+
const { disableDrag = false, disableDragOnFocus = true } = opts;
|
|
5600
|
+
const stopPropagation = (e) => {
|
|
5601
|
+
e.stopPropagation();
|
|
5602
|
+
};
|
|
5603
|
+
el.addEventListener("mouseover", stopPropagation, {
|
|
5604
|
+
capture: true
|
|
5605
|
+
});
|
|
5606
|
+
const onFocus = () => {
|
|
5607
|
+
setTimeout(() => {
|
|
5608
|
+
el.addEventListener("pointerdown", stopPropagation, {
|
|
5609
|
+
capture: true
|
|
5610
|
+
});
|
|
5611
|
+
}, 200);
|
|
5612
|
+
};
|
|
5613
|
+
const onBlur = () => {
|
|
5614
|
+
el.removeEventListener("pointerdown", stopPropagation, {
|
|
5615
|
+
capture: true
|
|
5616
|
+
});
|
|
5617
|
+
};
|
|
5618
|
+
if (disableDragOnFocus) {
|
|
5619
|
+
el.addEventListener("focus", onFocus, { capture: true });
|
|
5620
|
+
el.addEventListener("blur", onBlur, { capture: true });
|
|
5621
|
+
} else if (disableDrag) {
|
|
5622
|
+
el.addEventListener("pointerdown", stopPropagation, {
|
|
5623
|
+
capture: true
|
|
5624
|
+
});
|
|
5625
|
+
}
|
|
5626
|
+
el.setAttribute("data-puck-overlay-portal", "true");
|
|
5627
|
+
return () => {
|
|
5628
|
+
el.removeEventListener("mouseover", stopPropagation, {
|
|
5629
|
+
capture: true
|
|
5630
|
+
});
|
|
5631
|
+
if (disableDragOnFocus) {
|
|
5632
|
+
el.removeEventListener("focus", onFocus, { capture: true });
|
|
5633
|
+
el.removeEventListener("blur", onFocus, { capture: true });
|
|
5634
|
+
} else if (disableDrag) {
|
|
5635
|
+
el.removeEventListener("pointerdown", stopPropagation, {
|
|
5636
|
+
capture: true
|
|
5637
|
+
});
|
|
5638
|
+
}
|
|
5639
|
+
el.removeAttribute("data-puck-overlay-portal");
|
|
5640
|
+
};
|
|
5641
|
+
};
|
|
5642
|
+
|
|
5643
|
+
// css-module:/home/runner/work/puck/puck/packages/core/components/InlineTextField/styles.module.css#css-module
|
|
5644
|
+
init_react_import();
|
|
5645
|
+
var styles_module_default13 = { "InlineTextField": "_InlineTextField_ilw2a_1" };
|
|
5646
|
+
|
|
5647
|
+
// lib/data/set-deep.ts
|
|
5648
|
+
init_react_import();
|
|
5649
|
+
function setDeep(node, path, newVal) {
|
|
5650
|
+
const parts = path.split(".");
|
|
5651
|
+
const newNode = __spreadValues({}, node);
|
|
5652
|
+
let cur = newNode;
|
|
5653
|
+
for (let i = 0; i < parts.length; i++) {
|
|
5654
|
+
const [prop, idxStr] = parts[i].replace("]", "").split("[");
|
|
5655
|
+
const isLast = i === parts.length - 1;
|
|
5656
|
+
if (idxStr !== void 0) {
|
|
5657
|
+
if (!Array.isArray(cur[prop])) {
|
|
5658
|
+
cur[prop] = [];
|
|
5659
|
+
}
|
|
5660
|
+
const idx = Number(idxStr);
|
|
5661
|
+
if (isLast) {
|
|
5662
|
+
cur[prop][idx] = newVal;
|
|
5663
|
+
continue;
|
|
5664
|
+
}
|
|
5665
|
+
if (cur[prop][idx] === void 0) cur[prop][idx] = {};
|
|
5666
|
+
cur = cur[prop][idx];
|
|
5667
|
+
continue;
|
|
5668
|
+
}
|
|
5669
|
+
if (isLast) {
|
|
5670
|
+
cur[prop] = newVal;
|
|
5671
|
+
continue;
|
|
5672
|
+
}
|
|
5673
|
+
if (cur[prop] === void 0) {
|
|
5674
|
+
cur[prop] = {};
|
|
5675
|
+
}
|
|
5676
|
+
cur = cur[prop];
|
|
5677
|
+
}
|
|
5678
|
+
return __spreadValues(__spreadValues({}, node), newNode);
|
|
5679
|
+
}
|
|
5680
|
+
|
|
5681
|
+
// lib/get-selector-for-id.ts
|
|
5682
|
+
init_react_import();
|
|
5683
|
+
var getSelectorForId = (state, id) => {
|
|
5684
|
+
const node = state.indexes.nodes[id];
|
|
5685
|
+
if (!node) return;
|
|
5686
|
+
const zoneCompound = `${node.parentId}:${node.zone}`;
|
|
5687
|
+
const index = state.indexes.zones[zoneCompound].contentIds.indexOf(id);
|
|
5688
|
+
return { zone: zoneCompound, index };
|
|
5689
|
+
};
|
|
5690
|
+
|
|
5691
|
+
// components/InlineTextField/index.tsx
|
|
5692
|
+
import { jsx as jsx24 } from "react/jsx-runtime";
|
|
5693
|
+
var getClassName18 = get_class_name_factory_default("InlineTextField", styles_module_default13);
|
|
5694
|
+
var InlineTextFieldInternal = ({
|
|
5695
|
+
propPath,
|
|
5696
|
+
componentId,
|
|
5697
|
+
value,
|
|
5698
|
+
isReadOnly,
|
|
5699
|
+
opts = {}
|
|
5700
|
+
}) => {
|
|
5701
|
+
var _a;
|
|
5702
|
+
const ref = useRef5(null);
|
|
5703
|
+
const appStoreApi = useAppStoreApi();
|
|
5704
|
+
const disableLineBreaks = (_a = opts.disableLineBreaks) != null ? _a : false;
|
|
5705
|
+
useEffect17(() => {
|
|
5706
|
+
const appStore = appStoreApi.getState();
|
|
5707
|
+
const data = appStore.state.indexes.nodes[componentId].data;
|
|
5708
|
+
const componentConfig = appStore.getComponentConfig(data.type);
|
|
5709
|
+
if (!componentConfig) {
|
|
5710
|
+
throw new Error(
|
|
5711
|
+
`InlineTextField Error: No config defined for ${data.type}`
|
|
5712
|
+
);
|
|
5713
|
+
}
|
|
5714
|
+
if (ref.current) {
|
|
5715
|
+
if (value !== ref.current.innerText) {
|
|
5716
|
+
ref.current.replaceChildren(value);
|
|
5717
|
+
}
|
|
5718
|
+
const cleanupPortal = registerOverlayPortal(ref.current);
|
|
5719
|
+
const handleInput = (e) => __async(void 0, null, function* () {
|
|
5720
|
+
var _a2;
|
|
5721
|
+
const appStore2 = appStoreApi.getState();
|
|
5722
|
+
const node = appStore2.state.indexes.nodes[componentId];
|
|
5723
|
+
const zoneCompound = `${node.parentId}:${node.zone}`;
|
|
5724
|
+
const index = (_a2 = appStore2.state.indexes.zones[zoneCompound]) == null ? void 0 : _a2.contentIds.indexOf(
|
|
5725
|
+
componentId
|
|
5726
|
+
);
|
|
5727
|
+
const newProps = setDeep(node.data.props, propPath, e.target.innerText);
|
|
5728
|
+
const resolvedData = yield appStore2.resolveComponentData(
|
|
5729
|
+
__spreadProps(__spreadValues({}, node.data), { props: newProps }),
|
|
5730
|
+
"replace"
|
|
5731
|
+
);
|
|
5732
|
+
appStore2.dispatch({
|
|
5733
|
+
type: "replace",
|
|
5734
|
+
data: resolvedData.node,
|
|
5735
|
+
destinationIndex: index,
|
|
5736
|
+
destinationZone: zoneCompound
|
|
5737
|
+
});
|
|
5738
|
+
});
|
|
5739
|
+
ref.current.addEventListener("input", handleInput);
|
|
5740
|
+
return () => {
|
|
5741
|
+
var _a2;
|
|
5742
|
+
(_a2 = ref.current) == null ? void 0 : _a2.removeEventListener("input", handleInput);
|
|
5743
|
+
cleanupPortal == null ? void 0 : cleanupPortal();
|
|
5744
|
+
};
|
|
5745
|
+
}
|
|
5746
|
+
}, [appStoreApi, ref.current, value]);
|
|
5747
|
+
const [isHovering, setIsHovering] = useState16(false);
|
|
5748
|
+
const [isFocused, setIsFocused] = useState16(false);
|
|
5749
|
+
return /* @__PURE__ */ jsx24(
|
|
5750
|
+
"span",
|
|
5751
|
+
{
|
|
5752
|
+
className: getClassName18(),
|
|
5753
|
+
ref,
|
|
5754
|
+
contentEditable: isHovering || isFocused ? "plaintext-only" : "false",
|
|
5755
|
+
onClick: (e) => {
|
|
5756
|
+
e.preventDefault();
|
|
5757
|
+
e.stopPropagation();
|
|
5758
|
+
},
|
|
5759
|
+
onClickCapture: (e) => {
|
|
5760
|
+
e.preventDefault();
|
|
5761
|
+
e.stopPropagation();
|
|
5762
|
+
const itemSelector = getSelectorForId(
|
|
5763
|
+
appStoreApi.getState().state,
|
|
5764
|
+
componentId
|
|
5765
|
+
);
|
|
5766
|
+
appStoreApi.getState().setUi({ itemSelector });
|
|
5767
|
+
},
|
|
5768
|
+
onKeyDown: (e) => {
|
|
5769
|
+
e.stopPropagation();
|
|
5770
|
+
if (disableLineBreaks && e.key === "Enter" || isReadOnly) {
|
|
5771
|
+
e.preventDefault();
|
|
5772
|
+
}
|
|
5773
|
+
},
|
|
5774
|
+
onKeyUp: (e) => {
|
|
5775
|
+
e.stopPropagation();
|
|
5776
|
+
e.preventDefault();
|
|
5777
|
+
},
|
|
5778
|
+
onMouseOverCapture: () => setIsHovering(true),
|
|
5779
|
+
onMouseOutCapture: () => setIsHovering(false),
|
|
5780
|
+
onFocus: () => setIsFocused(true),
|
|
5781
|
+
onBlur: () => setIsFocused(false)
|
|
5782
|
+
}
|
|
5783
|
+
);
|
|
5784
|
+
};
|
|
5785
|
+
var InlineTextField = memo(InlineTextFieldInternal);
|
|
5786
|
+
|
|
5787
|
+
// lib/field-transforms/default-transforms/inline-text-transform.tsx
|
|
5788
|
+
import { jsx as jsx25 } from "react/jsx-runtime";
|
|
5789
|
+
var getInlineTextTransform = () => ({
|
|
5790
|
+
text: ({ value, componentId, field, propPath, isReadOnly }) => {
|
|
5791
|
+
if (field.contentEditable) {
|
|
5792
|
+
return /* @__PURE__ */ jsx25(
|
|
5793
|
+
InlineTextField,
|
|
5794
|
+
{
|
|
5795
|
+
propPath,
|
|
5796
|
+
componentId,
|
|
5797
|
+
value,
|
|
5798
|
+
opts: { disableLineBreaks: true },
|
|
5799
|
+
isReadOnly
|
|
5800
|
+
}
|
|
5801
|
+
);
|
|
5802
|
+
}
|
|
5803
|
+
return value;
|
|
5804
|
+
},
|
|
5805
|
+
textarea: ({ value, componentId, field, propPath, isReadOnly }) => {
|
|
5806
|
+
if (field.contentEditable) {
|
|
5807
|
+
return /* @__PURE__ */ jsx25(
|
|
5808
|
+
InlineTextField,
|
|
5809
|
+
{
|
|
5810
|
+
propPath,
|
|
5811
|
+
componentId,
|
|
5812
|
+
value,
|
|
5813
|
+
isReadOnly
|
|
5814
|
+
}
|
|
5815
|
+
);
|
|
5816
|
+
}
|
|
5817
|
+
return value;
|
|
5818
|
+
},
|
|
5819
|
+
custom: ({ value, componentId, field, propPath, isReadOnly }) => {
|
|
5820
|
+
if (field.contentEditable && typeof value === "string") {
|
|
5821
|
+
return /* @__PURE__ */ jsx25(
|
|
5822
|
+
InlineTextField,
|
|
5823
|
+
{
|
|
5824
|
+
propPath,
|
|
5825
|
+
componentId,
|
|
5826
|
+
value,
|
|
5827
|
+
isReadOnly
|
|
5828
|
+
}
|
|
5829
|
+
);
|
|
5830
|
+
}
|
|
5831
|
+
return value;
|
|
5832
|
+
}
|
|
5833
|
+
});
|
|
5834
|
+
|
|
5597
5835
|
// components/DropZone/index.tsx
|
|
5598
|
-
import { Fragment as
|
|
5599
|
-
var
|
|
5836
|
+
import { Fragment as Fragment7, jsx as jsx26, jsxs as jsxs11 } from "react/jsx-runtime";
|
|
5837
|
+
var getClassName19 = get_class_name_factory_default("DropZone", styles_module_default11);
|
|
5600
5838
|
var getRandomColor = () => `#${Math.floor(Math.random() * 16777215).toString(16)}`;
|
|
5601
5839
|
var RENDER_DEBUG = false;
|
|
5602
|
-
var DropZoneEditPure = (props) => /* @__PURE__ */
|
|
5840
|
+
var DropZoneEditPure = (props) => /* @__PURE__ */ jsx26(DropZoneEdit, __spreadValues({}, props));
|
|
5603
5841
|
var DropZoneChild = ({
|
|
5604
5842
|
zoneCompound,
|
|
5605
5843
|
componentId,
|
|
@@ -5614,7 +5852,7 @@ var DropZoneChild = ({
|
|
|
5614
5852
|
const { depth = 1 } = ctx != null ? ctx : {};
|
|
5615
5853
|
const zoneStore = useContext8(ZoneStoreContext);
|
|
5616
5854
|
const nodeProps = useAppStore(
|
|
5617
|
-
|
|
5855
|
+
useShallow4((s) => {
|
|
5618
5856
|
var _a2;
|
|
5619
5857
|
return (_a2 = s.state.indexes.nodes[componentId]) == null ? void 0 : _a2.flatData.props;
|
|
5620
5858
|
})
|
|
@@ -5626,7 +5864,7 @@ var DropZoneChild = ({
|
|
|
5626
5864
|
}
|
|
5627
5865
|
);
|
|
5628
5866
|
const nodeReadOnly = useAppStore(
|
|
5629
|
-
|
|
5867
|
+
useShallow4((s) => {
|
|
5630
5868
|
var _a2;
|
|
5631
5869
|
return (_a2 = s.state.indexes.nodes[componentId]) == null ? void 0 : _a2.data.readOnly;
|
|
5632
5870
|
})
|
|
@@ -5679,13 +5917,14 @@ var DropZoneChild = ({
|
|
|
5679
5917
|
let label = (_b = (_a = componentConfig == null ? void 0 : componentConfig.label) != null ? _a : item == null ? void 0 : item.type.toString()) != null ? _b : "Component";
|
|
5680
5918
|
const renderPreview = useMemo8(
|
|
5681
5919
|
() => function Preview3() {
|
|
5920
|
+
var _a2;
|
|
5682
5921
|
if (item && "element" in item && item.element) {
|
|
5683
5922
|
return (
|
|
5684
5923
|
// Safe to use this since the HTML is set by the user
|
|
5685
|
-
/* @__PURE__ */
|
|
5924
|
+
/* @__PURE__ */ jsx26("div", { dangerouslySetInnerHTML: { __html: item.element.outerHTML } })
|
|
5686
5925
|
);
|
|
5687
5926
|
}
|
|
5688
|
-
return /* @__PURE__ */
|
|
5927
|
+
return /* @__PURE__ */ jsx26(DrawerItemInner, { name: label, children: (_a2 = overrides.componentItem) != null ? _a2 : overrides.drawerItem });
|
|
5689
5928
|
},
|
|
5690
5929
|
[componentId, label, overrides]
|
|
5691
5930
|
);
|
|
@@ -5705,11 +5944,19 @@ var DropZoneChild = ({
|
|
|
5705
5944
|
[item == null ? void 0 : item.type, nodeType, defaultsProps]
|
|
5706
5945
|
);
|
|
5707
5946
|
const config = useAppStore((s) => s.config);
|
|
5708
|
-
const
|
|
5947
|
+
const plugins = useAppStore((s) => s.plugins);
|
|
5948
|
+
const userFieldTransforms = useAppStore((s) => s.fieldTransforms);
|
|
5949
|
+
const combinedFieldTransforms = useMemo8(
|
|
5950
|
+
() => __spreadValues(__spreadValues(__spreadValues(__spreadValues({}, getSlotTransform(DropZoneEditPure, (slotProps) => /* @__PURE__ */ jsx26(ContextSlotRender, { componentId, zone: slotProps.zone }))), getInlineTextTransform()), plugins.reduce(
|
|
5951
|
+
(acc, plugin) => __spreadValues(__spreadValues({}, acc), plugin.fieldTransforms),
|
|
5952
|
+
{}
|
|
5953
|
+
)), userFieldTransforms),
|
|
5954
|
+
[plugins, userFieldTransforms]
|
|
5955
|
+
);
|
|
5956
|
+
const transformedProps = useFieldTransforms(
|
|
5709
5957
|
config,
|
|
5710
5958
|
defaultedNode,
|
|
5711
|
-
|
|
5712
|
-
(slotProps) => /* @__PURE__ */ jsx24(ContextSlotRender, { componentId, zone: slotProps.zone }),
|
|
5959
|
+
combinedFieldTransforms,
|
|
5713
5960
|
nodeReadOnly,
|
|
5714
5961
|
isLoading
|
|
5715
5962
|
);
|
|
@@ -5723,7 +5970,7 @@ var DropZoneChild = ({
|
|
|
5723
5970
|
if (isInserting) {
|
|
5724
5971
|
Render2 = renderPreview;
|
|
5725
5972
|
}
|
|
5726
|
-
return /* @__PURE__ */
|
|
5973
|
+
return /* @__PURE__ */ jsx26(
|
|
5727
5974
|
DraggableComponent,
|
|
5728
5975
|
{
|
|
5729
5976
|
id: componentId,
|
|
@@ -5737,18 +5984,18 @@ var DropZoneChild = ({
|
|
|
5737
5984
|
autoDragAxis: dragAxis,
|
|
5738
5985
|
userDragAxis: collisionAxis,
|
|
5739
5986
|
inDroppableZone,
|
|
5740
|
-
children: (dragRef) => (componentConfig == null ? void 0 : componentConfig.inline) && !isInserting ? /* @__PURE__ */
|
|
5987
|
+
children: (dragRef) => (componentConfig == null ? void 0 : componentConfig.inline) && !isInserting ? /* @__PURE__ */ jsx26(Fragment7, { children: /* @__PURE__ */ jsx26(
|
|
5741
5988
|
Render2,
|
|
5742
|
-
__spreadProps(__spreadValues({},
|
|
5743
|
-
puck: __spreadProps(__spreadValues({},
|
|
5989
|
+
__spreadProps(__spreadValues({}, transformedProps), {
|
|
5990
|
+
puck: __spreadProps(__spreadValues({}, transformedProps.puck), {
|
|
5744
5991
|
dragRef
|
|
5745
5992
|
})
|
|
5746
5993
|
})
|
|
5747
|
-
) }) : /* @__PURE__ */
|
|
5994
|
+
) }) : /* @__PURE__ */ jsx26("div", { ref: dragRef, children: /* @__PURE__ */ jsx26(Render2, __spreadValues({}, transformedProps)) })
|
|
5748
5995
|
}
|
|
5749
5996
|
);
|
|
5750
5997
|
};
|
|
5751
|
-
var DropZoneChildMemo =
|
|
5998
|
+
var DropZoneChildMemo = memo2(DropZoneChild);
|
|
5752
5999
|
var DropZoneEdit = forwardRef3(
|
|
5753
6000
|
function DropZoneEditInternal({
|
|
5754
6001
|
zone,
|
|
@@ -5769,7 +6016,7 @@ var DropZoneEdit = forwardRef3(
|
|
|
5769
6016
|
unregisterLocalZone
|
|
5770
6017
|
} = ctx != null ? ctx : {};
|
|
5771
6018
|
const path = useAppStore(
|
|
5772
|
-
|
|
6019
|
+
useShallow4((s) => {
|
|
5773
6020
|
var _a;
|
|
5774
6021
|
return areaId ? (_a = s.state.indexes.nodes[areaId]) == null ? void 0 : _a.path : null;
|
|
5775
6022
|
})
|
|
@@ -5786,25 +6033,25 @@ var DropZoneEdit = forwardRef3(
|
|
|
5786
6033
|
(s) => s.nextAreaDepthIndex[areaId || ""]
|
|
5787
6034
|
);
|
|
5788
6035
|
const zoneContentIds = useAppStore(
|
|
5789
|
-
|
|
6036
|
+
useShallow4((s) => {
|
|
5790
6037
|
var _a;
|
|
5791
6038
|
return (_a = s.state.indexes.zones[zoneCompound]) == null ? void 0 : _a.contentIds;
|
|
5792
6039
|
})
|
|
5793
6040
|
);
|
|
5794
6041
|
const zoneType = useAppStore(
|
|
5795
|
-
|
|
6042
|
+
useShallow4((s) => {
|
|
5796
6043
|
var _a;
|
|
5797
6044
|
return (_a = s.state.indexes.zones[zoneCompound]) == null ? void 0 : _a.type;
|
|
5798
6045
|
})
|
|
5799
6046
|
);
|
|
5800
|
-
|
|
6047
|
+
useEffect18(() => {
|
|
5801
6048
|
if (!zoneType || zoneType === "dropzone") {
|
|
5802
6049
|
if (ctx == null ? void 0 : ctx.registerZone) {
|
|
5803
6050
|
ctx == null ? void 0 : ctx.registerZone(zoneCompound);
|
|
5804
6051
|
}
|
|
5805
6052
|
}
|
|
5806
6053
|
}, [zoneType, appStoreApi]);
|
|
5807
|
-
|
|
6054
|
+
useEffect18(() => {
|
|
5808
6055
|
if (zoneType === "dropzone") {
|
|
5809
6056
|
if (zoneCompound !== rootDroppableId) {
|
|
5810
6057
|
console.warn(
|
|
@@ -5816,8 +6063,8 @@ var DropZoneEdit = forwardRef3(
|
|
|
5816
6063
|
const contentIds = useMemo8(() => {
|
|
5817
6064
|
return zoneContentIds || [];
|
|
5818
6065
|
}, [zoneContentIds]);
|
|
5819
|
-
const ref =
|
|
5820
|
-
const acceptsTarget =
|
|
6066
|
+
const ref = useRef6(null);
|
|
6067
|
+
const acceptsTarget = useCallback11(
|
|
5821
6068
|
(componentType) => {
|
|
5822
6069
|
if (!componentType) {
|
|
5823
6070
|
return true;
|
|
@@ -5855,7 +6102,7 @@ var DropZoneEdit = forwardRef3(
|
|
|
5855
6102
|
}
|
|
5856
6103
|
return _isEnabled;
|
|
5857
6104
|
});
|
|
5858
|
-
|
|
6105
|
+
useEffect18(() => {
|
|
5859
6106
|
if (registerLocalZone) {
|
|
5860
6107
|
registerLocalZone(zoneCompound, targetAccepted || isEnabled);
|
|
5861
6108
|
}
|
|
@@ -5871,7 +6118,7 @@ var DropZoneEdit = forwardRef3(
|
|
|
5871
6118
|
);
|
|
5872
6119
|
const isDropEnabled = isEnabled && (preview ? contentIdsWithPreview.length === 1 : contentIdsWithPreview.length === 0);
|
|
5873
6120
|
const zoneStore = useContext8(ZoneStoreContext);
|
|
5874
|
-
|
|
6121
|
+
useEffect18(() => {
|
|
5875
6122
|
const { enabledIndex } = zoneStore.getState();
|
|
5876
6123
|
zoneStore.setState({
|
|
5877
6124
|
enabledIndex: __spreadProps(__spreadValues({}, enabledIndex), { [zoneCompound]: isEnabled })
|
|
@@ -5900,10 +6147,10 @@ var DropZoneEdit = forwardRef3(
|
|
|
5900
6147
|
userMinEmptyHeight,
|
|
5901
6148
|
ref
|
|
5902
6149
|
});
|
|
5903
|
-
return /* @__PURE__ */
|
|
6150
|
+
return /* @__PURE__ */ jsx26(
|
|
5904
6151
|
"div",
|
|
5905
6152
|
{
|
|
5906
|
-
className: `${
|
|
6153
|
+
className: `${getClassName19({
|
|
5907
6154
|
isRootZone,
|
|
5908
6155
|
hoveringOverArea,
|
|
5909
6156
|
isEnabled,
|
|
@@ -5921,7 +6168,7 @@ var DropZoneEdit = forwardRef3(
|
|
|
5921
6168
|
backgroundColor: RENDER_DEBUG ? getRandomColor() : style == null ? void 0 : style.backgroundColor
|
|
5922
6169
|
}),
|
|
5923
6170
|
children: contentIdsWithPreview.map((componentId, i) => {
|
|
5924
|
-
return /* @__PURE__ */
|
|
6171
|
+
return /* @__PURE__ */ jsx26(
|
|
5925
6172
|
DropZoneChildMemo,
|
|
5926
6173
|
{
|
|
5927
6174
|
zoneCompound,
|
|
@@ -5944,7 +6191,7 @@ var DropZoneRenderItem = ({
|
|
|
5944
6191
|
metadata
|
|
5945
6192
|
}) => {
|
|
5946
6193
|
const Component = config.components[item.type];
|
|
5947
|
-
const props = useSlots(config, item, (slotProps) => /* @__PURE__ */
|
|
6194
|
+
const props = useSlots(config, item, (slotProps) => /* @__PURE__ */ jsx26(SlotRenderPure, __spreadProps(__spreadValues({}, slotProps), { config, metadata })));
|
|
5948
6195
|
const nextContextValue = useMemo8(
|
|
5949
6196
|
() => ({
|
|
5950
6197
|
areaId: props.id,
|
|
@@ -5952,7 +6199,7 @@ var DropZoneRenderItem = ({
|
|
|
5952
6199
|
}),
|
|
5953
6200
|
[props]
|
|
5954
6201
|
);
|
|
5955
|
-
return /* @__PURE__ */
|
|
6202
|
+
return /* @__PURE__ */ jsx26(DropZoneProvider, { value: nextContextValue, children: /* @__PURE__ */ jsx26(
|
|
5956
6203
|
Component.render,
|
|
5957
6204
|
__spreadProps(__spreadValues({}, props), {
|
|
5958
6205
|
puck: __spreadProps(__spreadValues({}, props.puck), {
|
|
@@ -5962,7 +6209,7 @@ var DropZoneRenderItem = ({
|
|
|
5962
6209
|
})
|
|
5963
6210
|
) }, props.id);
|
|
5964
6211
|
};
|
|
5965
|
-
var DropZoneRenderPure = (props) => /* @__PURE__ */
|
|
6212
|
+
var DropZoneRenderPure = (props) => /* @__PURE__ */ jsx26(DropZoneRender, __spreadValues({}, props));
|
|
5966
6213
|
var DropZoneRender = forwardRef3(
|
|
5967
6214
|
function DropZoneRenderInternal({ className, style, zone }, ref) {
|
|
5968
6215
|
const ctx = useContext8(dropZoneContext);
|
|
@@ -5970,7 +6217,7 @@ var DropZoneRender = forwardRef3(
|
|
|
5970
6217
|
const { config, data, metadata } = useContext8(renderContext);
|
|
5971
6218
|
let zoneCompound = `${areaId}:${zone}`;
|
|
5972
6219
|
let content = (data == null ? void 0 : data.content) || [];
|
|
5973
|
-
|
|
6220
|
+
useEffect18(() => {
|
|
5974
6221
|
if (!content) {
|
|
5975
6222
|
if (ctx == null ? void 0 : ctx.registerZone) {
|
|
5976
6223
|
ctx == null ? void 0 : ctx.registerZone(zoneCompound);
|
|
@@ -5983,10 +6230,10 @@ var DropZoneRender = forwardRef3(
|
|
|
5983
6230
|
if (zoneCompound !== rootDroppableId) {
|
|
5984
6231
|
content = setupZone(data, zoneCompound).zones[zoneCompound];
|
|
5985
6232
|
}
|
|
5986
|
-
return /* @__PURE__ */
|
|
6233
|
+
return /* @__PURE__ */ jsx26("div", { className, style, ref, children: content.map((item) => {
|
|
5987
6234
|
const Component = config.components[item.type];
|
|
5988
6235
|
if (Component) {
|
|
5989
|
-
return /* @__PURE__ */
|
|
6236
|
+
return /* @__PURE__ */ jsx26(
|
|
5990
6237
|
DropZoneRenderItem,
|
|
5991
6238
|
{
|
|
5992
6239
|
config,
|
|
@@ -6000,20 +6247,20 @@ var DropZoneRender = forwardRef3(
|
|
|
6000
6247
|
}) });
|
|
6001
6248
|
}
|
|
6002
6249
|
);
|
|
6003
|
-
var DropZonePure = (props) => /* @__PURE__ */
|
|
6250
|
+
var DropZonePure = (props) => /* @__PURE__ */ jsx26(DropZone, __spreadValues({}, props));
|
|
6004
6251
|
var DropZone = forwardRef3(
|
|
6005
6252
|
function DropZone2(props, ref) {
|
|
6006
6253
|
const ctx = useContext8(dropZoneContext);
|
|
6007
6254
|
if ((ctx == null ? void 0 : ctx.mode) === "edit") {
|
|
6008
|
-
return /* @__PURE__ */
|
|
6255
|
+
return /* @__PURE__ */ jsx26(Fragment7, { children: /* @__PURE__ */ jsx26(DropZoneEdit, __spreadProps(__spreadValues({}, props), { ref })) });
|
|
6009
6256
|
}
|
|
6010
|
-
return /* @__PURE__ */
|
|
6257
|
+
return /* @__PURE__ */ jsx26(Fragment7, { children: /* @__PURE__ */ jsx26(DropZoneRender, __spreadProps(__spreadValues({}, props), { ref })) });
|
|
6011
6258
|
}
|
|
6012
6259
|
);
|
|
6013
6260
|
|
|
6014
6261
|
// components/Render/index.tsx
|
|
6015
6262
|
import React3, { useMemo as useMemo9 } from "react";
|
|
6016
|
-
import { jsx as
|
|
6263
|
+
import { jsx as jsx27 } from "react/jsx-runtime";
|
|
6017
6264
|
var renderContext = React3.createContext({
|
|
6018
6265
|
config: { components: {} },
|
|
6019
6266
|
data: { root: {}, content: [] },
|
|
@@ -6045,7 +6292,7 @@ function Render({
|
|
|
6045
6292
|
const propsWithSlots = useSlots(
|
|
6046
6293
|
config,
|
|
6047
6294
|
{ type: "root", props: pageProps },
|
|
6048
|
-
(props) => /* @__PURE__ */
|
|
6295
|
+
(props) => /* @__PURE__ */ jsx27(SlotRender, __spreadProps(__spreadValues({}, props), { config, metadata }))
|
|
6049
6296
|
);
|
|
6050
6297
|
const nextContextValue = useMemo9(
|
|
6051
6298
|
() => ({
|
|
@@ -6055,14 +6302,14 @@ function Render({
|
|
|
6055
6302
|
[]
|
|
6056
6303
|
);
|
|
6057
6304
|
if ((_a = config.root) == null ? void 0 : _a.render) {
|
|
6058
|
-
return /* @__PURE__ */
|
|
6305
|
+
return /* @__PURE__ */ jsx27(renderContext.Provider, { value: { config, data: defaultedData, metadata }, children: /* @__PURE__ */ jsx27(DropZoneProvider, { value: nextContextValue, children: /* @__PURE__ */ jsx27(config.root.render, __spreadProps(__spreadValues({}, propsWithSlots), { children: /* @__PURE__ */ jsx27(DropZoneRenderPure, { zone: rootZone }) })) }) });
|
|
6059
6306
|
}
|
|
6060
|
-
return /* @__PURE__ */
|
|
6307
|
+
return /* @__PURE__ */ jsx27(renderContext.Provider, { value: { config, data: defaultedData, metadata }, children: /* @__PURE__ */ jsx27(DropZoneProvider, { value: nextContextValue, children: /* @__PURE__ */ jsx27(DropZoneRenderPure, { zone: rootZone }) }) });
|
|
6061
6308
|
}
|
|
6062
6309
|
|
|
6063
6310
|
// lib/use-puck.ts
|
|
6064
6311
|
init_react_import();
|
|
6065
|
-
import { createContext as createContext5, useContext as useContext9, useEffect as
|
|
6312
|
+
import { createContext as createContext5, useContext as useContext9, useEffect as useEffect19, useState as useState17 } from "react";
|
|
6066
6313
|
import { createStore as createStore4, useStore as useStore3 } from "zustand";
|
|
6067
6314
|
var generateUsePuck = (store) => {
|
|
6068
6315
|
const history = {
|
|
@@ -6085,13 +6332,7 @@ var generateUsePuck = (store) => {
|
|
|
6085
6332
|
selectedItem: store.selectedItem || null,
|
|
6086
6333
|
getItemBySelector: (selector) => getItem(selector, store.state),
|
|
6087
6334
|
getItemById: (id) => store.state.indexes.nodes[id].data,
|
|
6088
|
-
getSelectorForId: (id) =>
|
|
6089
|
-
const node = store.state.indexes.nodes[id];
|
|
6090
|
-
if (!node) return;
|
|
6091
|
-
const zoneCompound = `${node.parentId}:${node.zone}`;
|
|
6092
|
-
const index = store.state.indexes.zones[zoneCompound].contentIds.indexOf(id);
|
|
6093
|
-
return { zone: zoneCompound, index };
|
|
6094
|
-
}
|
|
6335
|
+
getSelectorForId: (id) => getSelectorForId(store.state, id)
|
|
6095
6336
|
};
|
|
6096
6337
|
return storeData;
|
|
6097
6338
|
};
|
|
@@ -6109,12 +6350,12 @@ var convertToPickedStore = (store) => {
|
|
|
6109
6350
|
};
|
|
6110
6351
|
};
|
|
6111
6352
|
var useRegisterUsePuckStore = (appStore) => {
|
|
6112
|
-
const [usePuckStore] =
|
|
6353
|
+
const [usePuckStore] = useState17(
|
|
6113
6354
|
() => createStore4(
|
|
6114
6355
|
() => generateUsePuck(convertToPickedStore(appStore.getState()))
|
|
6115
6356
|
)
|
|
6116
6357
|
);
|
|
6117
|
-
|
|
6358
|
+
useEffect19(() => {
|
|
6118
6359
|
return appStore.subscribe(
|
|
6119
6360
|
(store) => convertToPickedStore(store),
|
|
6120
6361
|
(pickedStore) => {
|
|
@@ -6138,7 +6379,7 @@ function createUsePuck() {
|
|
|
6138
6379
|
};
|
|
6139
6380
|
}
|
|
6140
6381
|
function usePuck() {
|
|
6141
|
-
|
|
6382
|
+
useEffect19(() => {
|
|
6142
6383
|
console.warn(
|
|
6143
6384
|
"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."
|
|
6144
6385
|
);
|
|
@@ -6157,12 +6398,12 @@ function useGetPuck() {
|
|
|
6157
6398
|
init_react_import();
|
|
6158
6399
|
import {
|
|
6159
6400
|
createContext as createContext8,
|
|
6160
|
-
useCallback as
|
|
6401
|
+
useCallback as useCallback20,
|
|
6161
6402
|
useContext as useContext13,
|
|
6162
|
-
useEffect as
|
|
6403
|
+
useEffect as useEffect29,
|
|
6163
6404
|
useMemo as useMemo20,
|
|
6164
|
-
useRef as
|
|
6165
|
-
useState as
|
|
6405
|
+
useRef as useRef12,
|
|
6406
|
+
useState as useState25
|
|
6166
6407
|
} from "react";
|
|
6167
6408
|
|
|
6168
6409
|
// components/SidebarSection/index.tsx
|
|
@@ -6170,7 +6411,7 @@ init_react_import();
|
|
|
6170
6411
|
|
|
6171
6412
|
// css-module:/home/runner/work/puck/puck/packages/core/components/SidebarSection/styles.module.css#css-module
|
|
6172
6413
|
init_react_import();
|
|
6173
|
-
var
|
|
6414
|
+
var styles_module_default14 = { "SidebarSection": "_SidebarSection_8boj8_1", "SidebarSection-title": "_SidebarSection-title_8boj8_12", "SidebarSection--noBorderTop": "_SidebarSection--noBorderTop_8boj8_20", "SidebarSection-content": "_SidebarSection-content_8boj8_24", "SidebarSection--noPadding": "_SidebarSection--noPadding_8boj8_28", "SidebarSection-breadcrumbLabel": "_SidebarSection-breadcrumbLabel_8boj8_41", "SidebarSection-breadcrumbs": "_SidebarSection-breadcrumbs_8boj8_70", "SidebarSection-breadcrumb": "_SidebarSection-breadcrumb_8boj8_41", "SidebarSection-heading": "_SidebarSection-heading_8boj8_82", "SidebarSection-loadingOverlay": "_SidebarSection-loadingOverlay_8boj8_86" };
|
|
6174
6415
|
|
|
6175
6416
|
// lib/use-breadcrumbs.ts
|
|
6176
6417
|
init_react_import();
|
|
@@ -6217,8 +6458,8 @@ var useBreadcrumbs = (renderCount) => {
|
|
|
6217
6458
|
};
|
|
6218
6459
|
|
|
6219
6460
|
// components/SidebarSection/index.tsx
|
|
6220
|
-
import { jsx as
|
|
6221
|
-
var
|
|
6461
|
+
import { jsx as jsx28, jsxs as jsxs12 } from "react/jsx-runtime";
|
|
6462
|
+
var getClassName20 = get_class_name_factory_default("SidebarSection", styles_module_default14);
|
|
6222
6463
|
var SidebarSection = ({
|
|
6223
6464
|
children,
|
|
6224
6465
|
title,
|
|
@@ -6233,26 +6474,26 @@ var SidebarSection = ({
|
|
|
6233
6474
|
return /* @__PURE__ */ jsxs12(
|
|
6234
6475
|
"div",
|
|
6235
6476
|
{
|
|
6236
|
-
className:
|
|
6477
|
+
className: getClassName20({ noBorderTop, noPadding }),
|
|
6237
6478
|
style: { background },
|
|
6238
6479
|
children: [
|
|
6239
|
-
/* @__PURE__ */
|
|
6240
|
-
showBreadcrumbs ? breadcrumbs.map((breadcrumb, i) => /* @__PURE__ */ jsxs12("div", { className:
|
|
6241
|
-
/* @__PURE__ */
|
|
6480
|
+
/* @__PURE__ */ jsx28("div", { className: getClassName20("title"), children: /* @__PURE__ */ jsxs12("div", { className: getClassName20("breadcrumbs"), children: [
|
|
6481
|
+
showBreadcrumbs ? breadcrumbs.map((breadcrumb, i) => /* @__PURE__ */ jsxs12("div", { className: getClassName20("breadcrumb"), children: [
|
|
6482
|
+
/* @__PURE__ */ jsx28(
|
|
6242
6483
|
"button",
|
|
6243
6484
|
{
|
|
6244
6485
|
type: "button",
|
|
6245
|
-
className:
|
|
6486
|
+
className: getClassName20("breadcrumbLabel"),
|
|
6246
6487
|
onClick: () => setUi({ itemSelector: breadcrumb.selector }),
|
|
6247
6488
|
children: breadcrumb.label
|
|
6248
6489
|
}
|
|
6249
6490
|
),
|
|
6250
|
-
/* @__PURE__ */
|
|
6491
|
+
/* @__PURE__ */ jsx28(ChevronRight, { size: 16 })
|
|
6251
6492
|
] }, i)) : null,
|
|
6252
|
-
/* @__PURE__ */
|
|
6493
|
+
/* @__PURE__ */ jsx28("div", { className: getClassName20("heading"), children: /* @__PURE__ */ jsx28(Heading, { rank: "2", size: "xs", children: title }) })
|
|
6253
6494
|
] }) }),
|
|
6254
|
-
/* @__PURE__ */
|
|
6255
|
-
isLoading && /* @__PURE__ */
|
|
6495
|
+
/* @__PURE__ */ jsx28("div", { className: getClassName20("content"), children }),
|
|
6496
|
+
isLoading && /* @__PURE__ */ jsx28("div", { className: getClassName20("loadingOverlay"), children: /* @__PURE__ */ jsx28(Loader, { size: 32 }) })
|
|
6256
6497
|
]
|
|
6257
6498
|
}
|
|
6258
6499
|
);
|
|
@@ -6260,24 +6501,24 @@ var SidebarSection = ({
|
|
|
6260
6501
|
|
|
6261
6502
|
// css-module:/home/runner/work/puck/puck/packages/core/components/Puck/styles.module.css#css-module
|
|
6262
6503
|
init_react_import();
|
|
6263
|
-
var
|
|
6504
|
+
var styles_module_default15 = { "Puck": "_Puck_1yxlw_19", "Puck-portal": "_Puck-portal_1yxlw_31", "PuckLayout-inner": "_PuckLayout-inner_1yxlw_38", "PuckLayout--mounted": "_PuckLayout--mounted_1yxlw_59", "PuckLayout--leftSideBarVisible": "_PuckLayout--leftSideBarVisible_1yxlw_63", "PuckLayout--rightSideBarVisible": "_PuckLayout--rightSideBarVisible_1yxlw_69", "PuckLayout-mounted": "_PuckLayout-mounted_1yxlw_83", "PuckLayout": "_PuckLayout_1yxlw_38" };
|
|
6264
6505
|
|
|
6265
6506
|
// components/Puck/components/Fields/index.tsx
|
|
6266
6507
|
init_react_import();
|
|
6267
6508
|
|
|
6268
6509
|
// css-module:/home/runner/work/puck/puck/packages/core/components/Puck/components/Fields/styles.module.css#css-module
|
|
6269
6510
|
init_react_import();
|
|
6270
|
-
var
|
|
6511
|
+
var styles_module_default16 = { "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" };
|
|
6271
6512
|
|
|
6272
6513
|
// components/Puck/components/Fields/index.tsx
|
|
6273
|
-
import { memo as
|
|
6274
|
-
import { useShallow as
|
|
6275
|
-
import { Fragment as
|
|
6276
|
-
var
|
|
6514
|
+
import { memo as memo3, useCallback as useCallback12, useMemo as useMemo11 } from "react";
|
|
6515
|
+
import { useShallow as useShallow5 } from "zustand/react/shallow";
|
|
6516
|
+
import { Fragment as Fragment8, jsx as jsx29, jsxs as jsxs13 } from "react/jsx-runtime";
|
|
6517
|
+
var getClassName21 = get_class_name_factory_default("PuckFields", styles_module_default16);
|
|
6277
6518
|
var DefaultFields = ({
|
|
6278
6519
|
children
|
|
6279
6520
|
}) => {
|
|
6280
|
-
return /* @__PURE__ */
|
|
6521
|
+
return /* @__PURE__ */ jsx29(Fragment8, { children });
|
|
6281
6522
|
};
|
|
6282
6523
|
var createOnChange = (fieldName, appStore) => (value, updatedUi) => __async(void 0, null, function* () {
|
|
6283
6524
|
let currentProps;
|
|
@@ -6337,19 +6578,19 @@ var FieldsChild = ({ fieldName }) => {
|
|
|
6337
6578
|
return s.selectedItem ? `${s.selectedItem.props.id}_${field.type}_${fieldName}` : `root_${field.type}_${fieldName}`;
|
|
6338
6579
|
});
|
|
6339
6580
|
const permissions = useAppStore(
|
|
6340
|
-
|
|
6581
|
+
useShallow5((s) => {
|
|
6341
6582
|
const { selectedItem, permissions: permissions2 } = s;
|
|
6342
6583
|
return selectedItem ? permissions2.getPermissions({ item: selectedItem }) : permissions2.getPermissions({ root: true });
|
|
6343
6584
|
})
|
|
6344
6585
|
);
|
|
6345
6586
|
const appStore = useAppStoreApi();
|
|
6346
|
-
const onChange =
|
|
6587
|
+
const onChange = useCallback12(createOnChange(fieldName, appStore), [
|
|
6347
6588
|
fieldName
|
|
6348
6589
|
]);
|
|
6349
6590
|
const { visible = true } = field != null ? field : {};
|
|
6350
6591
|
if (!field || !id || !visible) return null;
|
|
6351
6592
|
if (field.type === "slot") return null;
|
|
6352
|
-
return /* @__PURE__ */
|
|
6593
|
+
return /* @__PURE__ */ jsx29("div", { className: getClassName21("field"), children: /* @__PURE__ */ jsx29(
|
|
6353
6594
|
AutoFieldPrivate,
|
|
6354
6595
|
{
|
|
6355
6596
|
field,
|
|
@@ -6361,7 +6602,7 @@ var FieldsChild = ({ fieldName }) => {
|
|
|
6361
6602
|
}
|
|
6362
6603
|
) }, id);
|
|
6363
6604
|
};
|
|
6364
|
-
var FieldsChildMemo =
|
|
6605
|
+
var FieldsChildMemo = memo3(FieldsChild);
|
|
6365
6606
|
var FieldsInternal = ({ wrapFields = true }) => {
|
|
6366
6607
|
const overrides = useAppStore((s) => s.overrides);
|
|
6367
6608
|
const componentResolving = useAppStore((s) => {
|
|
@@ -6369,7 +6610,7 @@ var FieldsInternal = ({ wrapFields = true }) => {
|
|
|
6369
6610
|
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;
|
|
6370
6611
|
return (loadingCount != null ? loadingCount : 0) > 0;
|
|
6371
6612
|
});
|
|
6372
|
-
const itemSelector = useAppStore(
|
|
6613
|
+
const itemSelector = useAppStore(useShallow5((s) => s.state.ui.itemSelector));
|
|
6373
6614
|
const id = useAppStore((s) => {
|
|
6374
6615
|
var _a;
|
|
6375
6616
|
return (_a = s.selectedItem) == null ? void 0 : _a.props.id;
|
|
@@ -6378,7 +6619,7 @@ var FieldsInternal = ({ wrapFields = true }) => {
|
|
|
6378
6619
|
useRegisterFieldsSlice(appStore, id);
|
|
6379
6620
|
const fieldsLoading = useAppStore((s) => s.fields.loading);
|
|
6380
6621
|
const fieldNames = useAppStore(
|
|
6381
|
-
|
|
6622
|
+
useShallow5((s) => {
|
|
6382
6623
|
if (s.fields.id === id) {
|
|
6383
6624
|
return Object.keys(s.fields.fields);
|
|
6384
6625
|
}
|
|
@@ -6390,47 +6631,56 @@ var FieldsInternal = ({ wrapFields = true }) => {
|
|
|
6390
6631
|
return /* @__PURE__ */ jsxs13(
|
|
6391
6632
|
"form",
|
|
6392
6633
|
{
|
|
6393
|
-
className:
|
|
6634
|
+
className: getClassName21({ wrapFields }),
|
|
6394
6635
|
onSubmit: (e) => {
|
|
6395
6636
|
e.preventDefault();
|
|
6396
6637
|
},
|
|
6397
6638
|
children: [
|
|
6398
|
-
/* @__PURE__ */
|
|
6399
|
-
isLoading && /* @__PURE__ */
|
|
6639
|
+
/* @__PURE__ */ jsx29(Wrapper, { isLoading, itemSelector, children: fieldNames.map((fieldName) => /* @__PURE__ */ jsx29(FieldsChildMemo, { fieldName }, fieldName)) }),
|
|
6640
|
+
isLoading && /* @__PURE__ */ jsx29("div", { className: getClassName21("loadingOverlay"), children: /* @__PURE__ */ jsx29("div", { className: getClassName21("loadingOverlayInner"), children: /* @__PURE__ */ jsx29(Loader, { size: 16 }) }) })
|
|
6400
6641
|
]
|
|
6401
6642
|
}
|
|
6402
6643
|
);
|
|
6403
6644
|
};
|
|
6404
|
-
var Fields =
|
|
6645
|
+
var Fields = memo3(FieldsInternal);
|
|
6405
6646
|
|
|
6406
6647
|
// components/Puck/components/Components/index.tsx
|
|
6407
6648
|
init_react_import();
|
|
6408
6649
|
|
|
6409
6650
|
// lib/use-component-list.tsx
|
|
6410
6651
|
init_react_import();
|
|
6411
|
-
import { useEffect as
|
|
6652
|
+
import { useEffect as useEffect21, useState as useState18 } from "react";
|
|
6412
6653
|
|
|
6413
6654
|
// components/ComponentList/index.tsx
|
|
6414
6655
|
init_react_import();
|
|
6415
6656
|
|
|
6416
6657
|
// css-module:/home/runner/work/puck/puck/packages/core/components/ComponentList/styles.module.css#css-module
|
|
6417
6658
|
init_react_import();
|
|
6418
|
-
var
|
|
6659
|
+
var styles_module_default17 = { "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" };
|
|
6419
6660
|
|
|
6420
6661
|
// components/ComponentList/index.tsx
|
|
6421
|
-
import {
|
|
6422
|
-
|
|
6662
|
+
import { useEffect as useEffect20 } from "react";
|
|
6663
|
+
import { jsx as jsx30, jsxs as jsxs14 } from "react/jsx-runtime";
|
|
6664
|
+
var getClassName22 = get_class_name_factory_default("ComponentList", styles_module_default17);
|
|
6423
6665
|
var ComponentListItem = ({
|
|
6424
6666
|
name,
|
|
6425
6667
|
label
|
|
6426
6668
|
}) => {
|
|
6669
|
+
var _a;
|
|
6427
6670
|
const overrides = useAppStore((s) => s.overrides);
|
|
6428
6671
|
const canInsert = useAppStore(
|
|
6429
6672
|
(s) => s.permissions.getPermissions({
|
|
6430
6673
|
type: name
|
|
6431
6674
|
}).insert
|
|
6432
6675
|
);
|
|
6433
|
-
|
|
6676
|
+
useEffect20(() => {
|
|
6677
|
+
if (overrides.componentItem) {
|
|
6678
|
+
console.warn(
|
|
6679
|
+
"The `componentItem` override has been deprecated and renamed to `drawerItem`"
|
|
6680
|
+
);
|
|
6681
|
+
}
|
|
6682
|
+
}, [overrides]);
|
|
6683
|
+
return /* @__PURE__ */ jsx30(Drawer.Item, { label, name, isDragDisabled: !canInsert, children: (_a = overrides.componentItem) != null ? _a : overrides.drawerItem });
|
|
6434
6684
|
};
|
|
6435
6685
|
var ComponentList = ({
|
|
6436
6686
|
children,
|
|
@@ -6441,12 +6691,12 @@ var ComponentList = ({
|
|
|
6441
6691
|
const setUi = useAppStore((s) => s.setUi);
|
|
6442
6692
|
const componentList = useAppStore((s) => s.state.ui.componentList);
|
|
6443
6693
|
const { expanded = true } = componentList[id] || {};
|
|
6444
|
-
return /* @__PURE__ */ jsxs14("div", { className:
|
|
6694
|
+
return /* @__PURE__ */ jsxs14("div", { className: getClassName22({ isExpanded: expanded }), children: [
|
|
6445
6695
|
title && /* @__PURE__ */ jsxs14(
|
|
6446
6696
|
"button",
|
|
6447
6697
|
{
|
|
6448
6698
|
type: "button",
|
|
6449
|
-
className:
|
|
6699
|
+
className: getClassName22("title"),
|
|
6450
6700
|
onClick: () => setUi({
|
|
6451
6701
|
componentList: __spreadProps(__spreadValues({}, componentList), {
|
|
6452
6702
|
[id]: __spreadProps(__spreadValues({}, componentList[id]), {
|
|
@@ -6456,14 +6706,14 @@ var ComponentList = ({
|
|
|
6456
6706
|
}),
|
|
6457
6707
|
title: expanded ? `Collapse${title ? ` ${title}` : ""}` : `Expand${title ? ` ${title}` : ""}`,
|
|
6458
6708
|
children: [
|
|
6459
|
-
/* @__PURE__ */
|
|
6460
|
-
/* @__PURE__ */
|
|
6709
|
+
/* @__PURE__ */ jsx30("div", { children: title }),
|
|
6710
|
+
/* @__PURE__ */ jsx30("div", { className: getClassName22("titleIcon"), children: expanded ? /* @__PURE__ */ jsx30(ChevronUp, { size: 12 }) : /* @__PURE__ */ jsx30(ChevronDown, { size: 12 }) })
|
|
6461
6711
|
]
|
|
6462
6712
|
}
|
|
6463
6713
|
),
|
|
6464
|
-
/* @__PURE__ */
|
|
6714
|
+
/* @__PURE__ */ jsx30("div", { className: getClassName22("content"), children: /* @__PURE__ */ jsx30(Drawer, { children: children || Object.keys(config.components).map((componentKey) => {
|
|
6465
6715
|
var _a;
|
|
6466
|
-
return /* @__PURE__ */
|
|
6716
|
+
return /* @__PURE__ */ jsx30(
|
|
6467
6717
|
ComponentListItem,
|
|
6468
6718
|
{
|
|
6469
6719
|
label: (_a = config.components[componentKey]["label"]) != null ? _a : componentKey,
|
|
@@ -6477,12 +6727,12 @@ var ComponentList = ({
|
|
|
6477
6727
|
ComponentList.Item = ComponentListItem;
|
|
6478
6728
|
|
|
6479
6729
|
// lib/use-component-list.tsx
|
|
6480
|
-
import { jsx as
|
|
6730
|
+
import { jsx as jsx31 } from "react/jsx-runtime";
|
|
6481
6731
|
var useComponentList = () => {
|
|
6482
|
-
const [componentList, setComponentList] =
|
|
6732
|
+
const [componentList, setComponentList] = useState18();
|
|
6483
6733
|
const config = useAppStore((s) => s.config);
|
|
6484
6734
|
const uiComponentList = useAppStore((s) => s.state.ui.componentList);
|
|
6485
|
-
|
|
6735
|
+
useEffect21(() => {
|
|
6486
6736
|
var _a, _b, _c;
|
|
6487
6737
|
if (Object.keys(uiComponentList).length > 0) {
|
|
6488
6738
|
const matchedComponents = [];
|
|
@@ -6492,7 +6742,7 @@ var useComponentList = () => {
|
|
|
6492
6742
|
if (category.visible === false || !category.components) {
|
|
6493
6743
|
return null;
|
|
6494
6744
|
}
|
|
6495
|
-
return /* @__PURE__ */
|
|
6745
|
+
return /* @__PURE__ */ jsx31(
|
|
6496
6746
|
ComponentList,
|
|
6497
6747
|
{
|
|
6498
6748
|
id: categoryKey,
|
|
@@ -6501,7 +6751,7 @@ var useComponentList = () => {
|
|
|
6501
6751
|
var _a2;
|
|
6502
6752
|
matchedComponents.push(componentName);
|
|
6503
6753
|
const componentConf = config.components[componentName] || {};
|
|
6504
|
-
return /* @__PURE__ */
|
|
6754
|
+
return /* @__PURE__ */ jsx31(
|
|
6505
6755
|
ComponentList.Item,
|
|
6506
6756
|
{
|
|
6507
6757
|
label: (_a2 = componentConf["label"]) != null ? _a2 : componentName,
|
|
@@ -6521,7 +6771,7 @@ var useComponentList = () => {
|
|
|
6521
6771
|
);
|
|
6522
6772
|
if (remainingComponents.length > 0 && !((_a = uiComponentList.other) == null ? void 0 : _a.components) && ((_b = uiComponentList.other) == null ? void 0 : _b.visible) !== false) {
|
|
6523
6773
|
_componentList.push(
|
|
6524
|
-
/* @__PURE__ */
|
|
6774
|
+
/* @__PURE__ */ jsx31(
|
|
6525
6775
|
ComponentList,
|
|
6526
6776
|
{
|
|
6527
6777
|
id: "other",
|
|
@@ -6529,7 +6779,7 @@ var useComponentList = () => {
|
|
|
6529
6779
|
children: remainingComponents.map((componentName, i) => {
|
|
6530
6780
|
var _a2;
|
|
6531
6781
|
const componentConf = config.components[componentName] || {};
|
|
6532
|
-
return /* @__PURE__ */
|
|
6782
|
+
return /* @__PURE__ */ jsx31(
|
|
6533
6783
|
ComponentList.Item,
|
|
6534
6784
|
{
|
|
6535
6785
|
name: componentName,
|
|
@@ -6552,29 +6802,36 @@ var useComponentList = () => {
|
|
|
6552
6802
|
|
|
6553
6803
|
// components/Puck/components/Components/index.tsx
|
|
6554
6804
|
import { useMemo as useMemo12 } from "react";
|
|
6555
|
-
import { jsx as
|
|
6805
|
+
import { jsx as jsx32 } from "react/jsx-runtime";
|
|
6556
6806
|
var Components = () => {
|
|
6557
6807
|
const overrides = useAppStore((s) => s.overrides);
|
|
6558
6808
|
const componentList = useComponentList();
|
|
6559
|
-
const Wrapper = useMemo12(() =>
|
|
6560
|
-
|
|
6809
|
+
const Wrapper = useMemo12(() => {
|
|
6810
|
+
if (overrides.components) {
|
|
6811
|
+
console.warn(
|
|
6812
|
+
"The `components` override has been deprecated and renamed to `drawer`"
|
|
6813
|
+
);
|
|
6814
|
+
}
|
|
6815
|
+
return overrides.components || overrides.drawer || "div";
|
|
6816
|
+
}, [overrides]);
|
|
6817
|
+
return /* @__PURE__ */ jsx32(Wrapper, { children: componentList ? componentList : /* @__PURE__ */ jsx32(ComponentList, { id: "all" }) });
|
|
6561
6818
|
};
|
|
6562
6819
|
|
|
6563
6820
|
// components/Puck/components/Preview/index.tsx
|
|
6564
6821
|
init_react_import();
|
|
6565
|
-
import { useCallback as
|
|
6822
|
+
import { useCallback as useCallback13, useEffect as useEffect23, useRef as useRef7, useMemo as useMemo13 } from "react";
|
|
6566
6823
|
|
|
6567
6824
|
// components/AutoFrame/index.tsx
|
|
6568
6825
|
init_react_import();
|
|
6569
6826
|
import {
|
|
6570
6827
|
createContext as createContext6,
|
|
6571
6828
|
useContext as useContext10,
|
|
6572
|
-
useEffect as
|
|
6573
|
-
useState as
|
|
6829
|
+
useEffect as useEffect22,
|
|
6830
|
+
useState as useState19
|
|
6574
6831
|
} from "react";
|
|
6575
6832
|
import hash from "object-hash";
|
|
6576
6833
|
import { createPortal as createPortal3 } from "react-dom";
|
|
6577
|
-
import { Fragment as
|
|
6834
|
+
import { Fragment as Fragment9, jsx as jsx33 } from "react/jsx-runtime";
|
|
6578
6835
|
var styleSelector = 'style, link[rel="stylesheet"]';
|
|
6579
6836
|
var collectStyles = (doc) => {
|
|
6580
6837
|
const collected = [];
|
|
@@ -6624,7 +6881,7 @@ var CopyHostStyles = ({
|
|
|
6624
6881
|
onStylesLoaded = () => null
|
|
6625
6882
|
}) => {
|
|
6626
6883
|
const { document: doc, window: win } = useFrame();
|
|
6627
|
-
|
|
6884
|
+
useEffect22(() => {
|
|
6628
6885
|
if (!win || !doc) {
|
|
6629
6886
|
return () => {
|
|
6630
6887
|
};
|
|
@@ -6781,7 +7038,7 @@ var CopyHostStyles = ({
|
|
|
6781
7038
|
observer.disconnect();
|
|
6782
7039
|
};
|
|
6783
7040
|
}, []);
|
|
6784
|
-
return /* @__PURE__ */
|
|
7041
|
+
return /* @__PURE__ */ jsx33(Fragment9, { children });
|
|
6785
7042
|
};
|
|
6786
7043
|
var autoFrameContext = createContext6({});
|
|
6787
7044
|
var useFrame = () => useContext10(autoFrameContext);
|
|
@@ -6805,11 +7062,11 @@ function AutoFrame(_a) {
|
|
|
6805
7062
|
"onNotReady",
|
|
6806
7063
|
"frameRef"
|
|
6807
7064
|
]);
|
|
6808
|
-
const [loaded, setLoaded] =
|
|
6809
|
-
const [ctx, setCtx] =
|
|
6810
|
-
const [mountTarget, setMountTarget] =
|
|
6811
|
-
const [stylesLoaded, setStylesLoaded] =
|
|
6812
|
-
|
|
7065
|
+
const [loaded, setLoaded] = useState19(false);
|
|
7066
|
+
const [ctx, setCtx] = useState19({});
|
|
7067
|
+
const [mountTarget, setMountTarget] = useState19();
|
|
7068
|
+
const [stylesLoaded, setStylesLoaded] = useState19(false);
|
|
7069
|
+
useEffect22(() => {
|
|
6813
7070
|
var _a2;
|
|
6814
7071
|
if (frameRef.current) {
|
|
6815
7072
|
const doc = frameRef.current.contentDocument;
|
|
@@ -6828,7 +7085,7 @@ function AutoFrame(_a) {
|
|
|
6828
7085
|
}
|
|
6829
7086
|
}
|
|
6830
7087
|
}, [frameRef, loaded, stylesLoaded]);
|
|
6831
|
-
return /* @__PURE__ */
|
|
7088
|
+
return /* @__PURE__ */ jsx33(
|
|
6832
7089
|
"iframe",
|
|
6833
7090
|
__spreadProps(__spreadValues({}, props), {
|
|
6834
7091
|
className,
|
|
@@ -6838,7 +7095,7 @@ function AutoFrame(_a) {
|
|
|
6838
7095
|
onLoad: () => {
|
|
6839
7096
|
setLoaded(true);
|
|
6840
7097
|
},
|
|
6841
|
-
children: /* @__PURE__ */
|
|
7098
|
+
children: /* @__PURE__ */ jsx33(autoFrameContext.Provider, { value: ctx, children: loaded && mountTarget && /* @__PURE__ */ jsx33(
|
|
6842
7099
|
CopyHostStyles,
|
|
6843
7100
|
{
|
|
6844
7101
|
debug,
|
|
@@ -6854,14 +7111,14 @@ var AutoFrame_default = AutoFrame;
|
|
|
6854
7111
|
|
|
6855
7112
|
// css-module:/home/runner/work/puck/puck/packages/core/components/Puck/components/Preview/styles.module.css#css-module
|
|
6856
7113
|
init_react_import();
|
|
6857
|
-
var
|
|
7114
|
+
var styles_module_default18 = { "PuckPreview": "_PuckPreview_z2rgu_1", "PuckPreview-frame": "_PuckPreview-frame_z2rgu_6" };
|
|
6858
7115
|
|
|
6859
7116
|
// components/Puck/components/Preview/index.tsx
|
|
6860
|
-
import { Fragment as
|
|
6861
|
-
var
|
|
7117
|
+
import { Fragment as Fragment10, jsx as jsx34 } from "react/jsx-runtime";
|
|
7118
|
+
var getClassName23 = get_class_name_factory_default("PuckPreview", styles_module_default18);
|
|
6862
7119
|
var useBubbleIframeEvents = (ref) => {
|
|
6863
7120
|
const status = useAppStore((s) => s.status);
|
|
6864
|
-
|
|
7121
|
+
useEffect23(() => {
|
|
6865
7122
|
if (ref.current && status === "READY") {
|
|
6866
7123
|
const iframe = ref.current;
|
|
6867
7124
|
const handlePointerMove = (event) => {
|
|
@@ -6910,7 +7167,7 @@ var Preview2 = ({ id = "puck-preview" }) => {
|
|
|
6910
7167
|
const renderData = useAppStore(
|
|
6911
7168
|
(s) => s.state.ui.previewMode === "edit" ? null : s.state.data
|
|
6912
7169
|
);
|
|
6913
|
-
const Page =
|
|
7170
|
+
const Page = useCallback13(
|
|
6914
7171
|
(pageProps) => {
|
|
6915
7172
|
var _a, _b;
|
|
6916
7173
|
const propsWithSlots = useSlots(
|
|
@@ -6920,15 +7177,15 @@ var Preview2 = ({ id = "puck-preview" }) => {
|
|
|
6920
7177
|
);
|
|
6921
7178
|
return ((_a = config.root) == null ? void 0 : _a.render) ? (_b = config.root) == null ? void 0 : _b.render(__spreadValues({
|
|
6922
7179
|
id: "puck-root"
|
|
6923
|
-
}, propsWithSlots)) : /* @__PURE__ */
|
|
7180
|
+
}, propsWithSlots)) : /* @__PURE__ */ jsx34(Fragment10, { children: propsWithSlots.children });
|
|
6924
7181
|
},
|
|
6925
7182
|
[config]
|
|
6926
7183
|
);
|
|
6927
7184
|
const Frame = useMemo13(() => overrides.iframe, [overrides]);
|
|
6928
7185
|
const rootProps = root.props || root;
|
|
6929
|
-
const ref =
|
|
7186
|
+
const ref = useRef7(null);
|
|
6930
7187
|
useBubbleIframeEvents(ref);
|
|
6931
|
-
const inner = !renderData ? /* @__PURE__ */
|
|
7188
|
+
const inner = !renderData ? /* @__PURE__ */ jsx34(
|
|
6932
7189
|
Page,
|
|
6933
7190
|
__spreadProps(__spreadValues({}, rootProps), {
|
|
6934
7191
|
puck: {
|
|
@@ -6938,28 +7195,31 @@ var Preview2 = ({ id = "puck-preview" }) => {
|
|
|
6938
7195
|
metadata
|
|
6939
7196
|
},
|
|
6940
7197
|
editMode: true,
|
|
6941
|
-
children: /* @__PURE__ */
|
|
7198
|
+
children: /* @__PURE__ */ jsx34(DropZonePure, { zone: rootDroppableId })
|
|
6942
7199
|
})
|
|
6943
|
-
) : /* @__PURE__ */
|
|
6944
|
-
|
|
7200
|
+
) : /* @__PURE__ */ jsx34(Render, { data: renderData, config, metadata });
|
|
7201
|
+
useEffect23(() => {
|
|
6945
7202
|
if (!iframe.enabled) {
|
|
6946
7203
|
setStatus("READY");
|
|
6947
7204
|
}
|
|
6948
7205
|
}, [iframe.enabled]);
|
|
6949
|
-
return /* @__PURE__ */
|
|
7206
|
+
return /* @__PURE__ */ jsx34(
|
|
6950
7207
|
"div",
|
|
6951
7208
|
{
|
|
6952
|
-
className:
|
|
7209
|
+
className: getClassName23(),
|
|
6953
7210
|
id,
|
|
6954
7211
|
"data-puck-preview": true,
|
|
6955
|
-
onClick: () => {
|
|
6956
|
-
|
|
7212
|
+
onClick: (e) => {
|
|
7213
|
+
const el = e.target;
|
|
7214
|
+
if (!el.hasAttribute("data-puck-component") && !el.hasAttribute("data-puck-dropzone")) {
|
|
7215
|
+
dispatch({ type: "setUi", ui: { itemSelector: null } });
|
|
7216
|
+
}
|
|
6957
7217
|
},
|
|
6958
|
-
children: iframe.enabled ? /* @__PURE__ */
|
|
7218
|
+
children: iframe.enabled ? /* @__PURE__ */ jsx34(
|
|
6959
7219
|
AutoFrame_default,
|
|
6960
7220
|
{
|
|
6961
7221
|
id: "preview-frame",
|
|
6962
|
-
className:
|
|
7222
|
+
className: getClassName23("frame"),
|
|
6963
7223
|
"data-rfd-iframe": true,
|
|
6964
7224
|
onReady: () => {
|
|
6965
7225
|
setStatus("READY");
|
|
@@ -6968,18 +7228,18 @@ var Preview2 = ({ id = "puck-preview" }) => {
|
|
|
6968
7228
|
setStatus("MOUNTED");
|
|
6969
7229
|
},
|
|
6970
7230
|
frameRef: ref,
|
|
6971
|
-
children: /* @__PURE__ */
|
|
7231
|
+
children: /* @__PURE__ */ jsx34(autoFrameContext.Consumer, { children: ({ document: document2 }) => {
|
|
6972
7232
|
if (Frame) {
|
|
6973
|
-
return /* @__PURE__ */
|
|
7233
|
+
return /* @__PURE__ */ jsx34(Frame, { document: document2, children: inner });
|
|
6974
7234
|
}
|
|
6975
7235
|
return inner;
|
|
6976
7236
|
} })
|
|
6977
7237
|
}
|
|
6978
|
-
) : /* @__PURE__ */
|
|
7238
|
+
) : /* @__PURE__ */ jsx34(
|
|
6979
7239
|
"div",
|
|
6980
7240
|
{
|
|
6981
7241
|
id: "preview-frame",
|
|
6982
|
-
className:
|
|
7242
|
+
className: getClassName23("frame"),
|
|
6983
7243
|
ref,
|
|
6984
7244
|
"data-puck-entry": true,
|
|
6985
7245
|
children: inner
|
|
@@ -6997,7 +7257,7 @@ init_react_import();
|
|
|
6997
7257
|
|
|
6998
7258
|
// css-module:/home/runner/work/puck/puck/packages/core/components/LayerTree/styles.module.css#css-module
|
|
6999
7259
|
init_react_import();
|
|
7000
|
-
var
|
|
7260
|
+
var styles_module_default19 = { "LayerTree": "_LayerTree_7rx04_1", "LayerTree-zoneTitle": "_LayerTree-zoneTitle_7rx04_11", "LayerTree-helper": "_LayerTree-helper_7rx04_17", "Layer": "_Layer_7rx04_1", "Layer-inner": "_Layer-inner_7rx04_29", "Layer--containsZone": "_Layer--containsZone_7rx04_35", "Layer-clickable": "_Layer-clickable_7rx04_39", "Layer--isSelected": "_Layer--isSelected_7rx04_61", "Layer-chevron": "_Layer-chevron_7rx04_77", "Layer--childIsSelected": "_Layer--childIsSelected_7rx04_78", "Layer-zones": "_Layer-zones_7rx04_82", "Layer-title": "_Layer-title_7rx04_96", "Layer-name": "_Layer-name_7rx04_105", "Layer-icon": "_Layer-icon_7rx04_111", "Layer-zoneIcon": "_Layer-zoneIcon_7rx04_116" };
|
|
7001
7261
|
|
|
7002
7262
|
// lib/scroll-into-view.ts
|
|
7003
7263
|
init_react_import();
|
|
@@ -7011,7 +7271,7 @@ var scrollIntoView = (el) => {
|
|
|
7011
7271
|
};
|
|
7012
7272
|
|
|
7013
7273
|
// components/LayerTree/index.tsx
|
|
7014
|
-
import { useCallback as
|
|
7274
|
+
import { useCallback as useCallback14, useContext as useContext11 } from "react";
|
|
7015
7275
|
|
|
7016
7276
|
// lib/on-scroll-end.ts
|
|
7017
7277
|
init_react_import();
|
|
@@ -7033,10 +7293,10 @@ var onScrollEnd = (frame, cb) => {
|
|
|
7033
7293
|
};
|
|
7034
7294
|
|
|
7035
7295
|
// components/LayerTree/index.tsx
|
|
7036
|
-
import { useShallow as
|
|
7037
|
-
import { Fragment as
|
|
7038
|
-
var
|
|
7039
|
-
var getClassNameLayer = get_class_name_factory_default("Layer",
|
|
7296
|
+
import { useShallow as useShallow6 } from "zustand/react/shallow";
|
|
7297
|
+
import { Fragment as Fragment11, jsx as jsx35, jsxs as jsxs15 } from "react/jsx-runtime";
|
|
7298
|
+
var getClassName24 = get_class_name_factory_default("LayerTree", styles_module_default19);
|
|
7299
|
+
var getClassNameLayer = get_class_name_factory_default("Layer", styles_module_default19);
|
|
7040
7300
|
var Layer = ({
|
|
7041
7301
|
index,
|
|
7042
7302
|
itemId,
|
|
@@ -7046,7 +7306,7 @@ var Layer = ({
|
|
|
7046
7306
|
const config = useAppStore((s) => s.config);
|
|
7047
7307
|
const itemSelector = useAppStore((s) => s.state.ui.itemSelector);
|
|
7048
7308
|
const dispatch = useAppStore((s) => s.dispatch);
|
|
7049
|
-
const setItemSelector =
|
|
7309
|
+
const setItemSelector = useCallback14(
|
|
7050
7310
|
(itemSelector2) => {
|
|
7051
7311
|
dispatch({ type: "setUi", ui: { itemSelector: itemSelector2 } });
|
|
7052
7312
|
},
|
|
@@ -7059,7 +7319,7 @@ var Layer = ({
|
|
|
7059
7319
|
const isSelected = selecedItemId === itemId || itemSelector && itemSelector.zone === rootDroppableId && !zoneCompound;
|
|
7060
7320
|
const nodeData = useAppStore((s) => s.state.indexes.nodes[itemId]);
|
|
7061
7321
|
const zonesForItem = useAppStore(
|
|
7062
|
-
|
|
7322
|
+
useShallow6(
|
|
7063
7323
|
(s) => Object.keys(s.state.indexes.zones).filter(
|
|
7064
7324
|
(z) => z.split(":")[0] === itemId
|
|
7065
7325
|
)
|
|
@@ -7091,7 +7351,7 @@ var Layer = ({
|
|
|
7091
7351
|
childIsSelected
|
|
7092
7352
|
}),
|
|
7093
7353
|
children: [
|
|
7094
|
-
/* @__PURE__ */
|
|
7354
|
+
/* @__PURE__ */ jsx35("div", { className: getClassNameLayer("inner"), children: /* @__PURE__ */ jsxs15(
|
|
7095
7355
|
"button",
|
|
7096
7356
|
{
|
|
7097
7357
|
type: "button",
|
|
@@ -7129,22 +7389,22 @@ var Layer = ({
|
|
|
7129
7389
|
zoneStore.setState({ hoveringComponent: null });
|
|
7130
7390
|
},
|
|
7131
7391
|
children: [
|
|
7132
|
-
containsZone && /* @__PURE__ */
|
|
7392
|
+
containsZone && /* @__PURE__ */ jsx35(
|
|
7133
7393
|
"div",
|
|
7134
7394
|
{
|
|
7135
7395
|
className: getClassNameLayer("chevron"),
|
|
7136
7396
|
title: isSelected ? "Collapse" : "Expand",
|
|
7137
|
-
children: /* @__PURE__ */
|
|
7397
|
+
children: /* @__PURE__ */ jsx35(ChevronDown, { size: "12" })
|
|
7138
7398
|
}
|
|
7139
7399
|
),
|
|
7140
7400
|
/* @__PURE__ */ jsxs15("div", { className: getClassNameLayer("title"), children: [
|
|
7141
|
-
/* @__PURE__ */
|
|
7142
|
-
/* @__PURE__ */
|
|
7401
|
+
/* @__PURE__ */ jsx35("div", { className: getClassNameLayer("icon"), children: nodeData.data.type === "Text" || nodeData.data.type === "Heading" ? /* @__PURE__ */ jsx35(Type, { size: "16" }) : /* @__PURE__ */ jsx35(LayoutGrid, { size: "16" }) }),
|
|
7402
|
+
/* @__PURE__ */ jsx35("div", { className: getClassNameLayer("name"), children: label })
|
|
7143
7403
|
] })
|
|
7144
7404
|
]
|
|
7145
7405
|
}
|
|
7146
7406
|
) }),
|
|
7147
|
-
containsZone && zonesForItem.map((subzone) => /* @__PURE__ */
|
|
7407
|
+
containsZone && zonesForItem.map((subzone) => /* @__PURE__ */ jsx35("div", { className: getClassNameLayer("zones"), children: /* @__PURE__ */ jsx35(LayerTree, { zoneCompound: subzone }) }, subzone))
|
|
7148
7408
|
]
|
|
7149
7409
|
}
|
|
7150
7410
|
);
|
|
@@ -7163,22 +7423,22 @@ var LayerTree = ({
|
|
|
7163
7423
|
return (_d = (_c = (_b = configForComponent == null ? void 0 : configForComponent.fields) == null ? void 0 : _b[slotId]) == null ? void 0 : _c.label) != null ? _d : slotId;
|
|
7164
7424
|
});
|
|
7165
7425
|
const contentIds = useAppStore(
|
|
7166
|
-
|
|
7426
|
+
useShallow6(
|
|
7167
7427
|
(s) => {
|
|
7168
7428
|
var _a, _b;
|
|
7169
7429
|
return zoneCompound ? (_b = (_a = s.state.indexes.zones[zoneCompound]) == null ? void 0 : _a.contentIds) != null ? _b : [] : [];
|
|
7170
7430
|
}
|
|
7171
7431
|
)
|
|
7172
7432
|
);
|
|
7173
|
-
return /* @__PURE__ */ jsxs15(
|
|
7174
|
-
label && /* @__PURE__ */ jsxs15("div", { className:
|
|
7175
|
-
/* @__PURE__ */
|
|
7433
|
+
return /* @__PURE__ */ jsxs15(Fragment11, { children: [
|
|
7434
|
+
label && /* @__PURE__ */ jsxs15("div", { className: getClassName24("zoneTitle"), children: [
|
|
7435
|
+
/* @__PURE__ */ jsx35("div", { className: getClassName24("zoneIcon"), children: /* @__PURE__ */ jsx35(Layers, { size: "16" }) }),
|
|
7176
7436
|
label
|
|
7177
7437
|
] }),
|
|
7178
|
-
/* @__PURE__ */ jsxs15("ul", { className:
|
|
7179
|
-
contentIds.length === 0 && /* @__PURE__ */
|
|
7438
|
+
/* @__PURE__ */ jsxs15("ul", { className: getClassName24(), children: [
|
|
7439
|
+
contentIds.length === 0 && /* @__PURE__ */ jsx35("div", { className: getClassName24("helper"), children: "No items" }),
|
|
7180
7440
|
contentIds.map((itemId, i) => {
|
|
7181
|
-
return /* @__PURE__ */
|
|
7441
|
+
return /* @__PURE__ */ jsx35(
|
|
7182
7442
|
Layer,
|
|
7183
7443
|
{
|
|
7184
7444
|
index: i,
|
|
@@ -7204,15 +7464,15 @@ var findZonesForArea = (state, area) => {
|
|
|
7204
7464
|
};
|
|
7205
7465
|
|
|
7206
7466
|
// components/Puck/components/Outline/index.tsx
|
|
7207
|
-
import { useShallow as
|
|
7208
|
-
import { jsx as
|
|
7467
|
+
import { useShallow as useShallow7 } from "zustand/react/shallow";
|
|
7468
|
+
import { jsx as jsx36 } from "react/jsx-runtime";
|
|
7209
7469
|
var Outline = () => {
|
|
7210
7470
|
const outlineOverride = useAppStore((s) => s.overrides.outline);
|
|
7211
7471
|
const rootZones = useAppStore(
|
|
7212
|
-
|
|
7472
|
+
useShallow7((s) => findZonesForArea(s.state, "root"))
|
|
7213
7473
|
);
|
|
7214
7474
|
const Wrapper = useMemo14(() => outlineOverride || "div", [outlineOverride]);
|
|
7215
|
-
return /* @__PURE__ */
|
|
7475
|
+
return /* @__PURE__ */ jsx36(Wrapper, { children: rootZones.map((zoneCompound) => /* @__PURE__ */ jsx36(
|
|
7216
7476
|
LayerTree,
|
|
7217
7477
|
{
|
|
7218
7478
|
label: rootZones.length === 1 ? "" : zoneCompound.split(":")[1],
|
|
@@ -7225,30 +7485,30 @@ var Outline = () => {
|
|
|
7225
7485
|
// components/Puck/components/Canvas/index.tsx
|
|
7226
7486
|
init_react_import();
|
|
7227
7487
|
import {
|
|
7228
|
-
useCallback as
|
|
7229
|
-
useEffect as
|
|
7488
|
+
useCallback as useCallback15,
|
|
7489
|
+
useEffect as useEffect25,
|
|
7230
7490
|
useMemo as useMemo17,
|
|
7231
|
-
useRef as
|
|
7232
|
-
useState as
|
|
7491
|
+
useRef as useRef9,
|
|
7492
|
+
useState as useState21
|
|
7233
7493
|
} from "react";
|
|
7234
7494
|
|
|
7235
7495
|
// components/ViewportControls/index.tsx
|
|
7236
7496
|
init_react_import();
|
|
7237
|
-
import { useEffect as
|
|
7497
|
+
import { useEffect as useEffect24, useMemo as useMemo15, useState as useState20 } from "react";
|
|
7238
7498
|
|
|
7239
7499
|
// css-module:/home/runner/work/puck/puck/packages/core/components/ViewportControls/styles.module.css#css-module
|
|
7240
7500
|
init_react_import();
|
|
7241
|
-
var
|
|
7501
|
+
var styles_module_default20 = { "ViewportControls": "_ViewportControls_gejzr_1", "ViewportControls-divider": "_ViewportControls-divider_gejzr_15", "ViewportControls-zoomSelect": "_ViewportControls-zoomSelect_gejzr_21", "ViewportButton--isActive": "_ViewportButton--isActive_gejzr_38", "ViewportButton-inner": "_ViewportButton-inner_gejzr_38" };
|
|
7242
7502
|
|
|
7243
7503
|
// components/ViewportControls/index.tsx
|
|
7244
|
-
import { jsx as
|
|
7504
|
+
import { jsx as jsx37, jsxs as jsxs16 } from "react/jsx-runtime";
|
|
7245
7505
|
var icons = {
|
|
7246
|
-
Smartphone: /* @__PURE__ */
|
|
7247
|
-
Tablet: /* @__PURE__ */
|
|
7248
|
-
Monitor: /* @__PURE__ */
|
|
7506
|
+
Smartphone: /* @__PURE__ */ jsx37(Smartphone, { size: 16 }),
|
|
7507
|
+
Tablet: /* @__PURE__ */ jsx37(Tablet, { size: 16 }),
|
|
7508
|
+
Monitor: /* @__PURE__ */ jsx37(Monitor, { size: 16 })
|
|
7249
7509
|
};
|
|
7250
|
-
var
|
|
7251
|
-
var getClassNameButton = get_class_name_factory_default("ViewportButton",
|
|
7510
|
+
var getClassName25 = get_class_name_factory_default("ViewportControls", styles_module_default20);
|
|
7511
|
+
var getClassNameButton = get_class_name_factory_default("ViewportButton", styles_module_default20);
|
|
7252
7512
|
var ViewportButton = ({
|
|
7253
7513
|
children,
|
|
7254
7514
|
height = "auto",
|
|
@@ -7257,11 +7517,11 @@ var ViewportButton = ({
|
|
|
7257
7517
|
onClick
|
|
7258
7518
|
}) => {
|
|
7259
7519
|
const viewports = useAppStore((s) => s.state.ui.viewports);
|
|
7260
|
-
const [isActive, setIsActive] =
|
|
7261
|
-
|
|
7520
|
+
const [isActive, setIsActive] = useState20(false);
|
|
7521
|
+
useEffect24(() => {
|
|
7262
7522
|
setIsActive(width === viewports.current.width);
|
|
7263
7523
|
}, [width, viewports.current.width]);
|
|
7264
|
-
return /* @__PURE__ */
|
|
7524
|
+
return /* @__PURE__ */ jsx37("span", { className: getClassNameButton({ isActive }), children: /* @__PURE__ */ jsx37(
|
|
7265
7525
|
IconButton,
|
|
7266
7526
|
{
|
|
7267
7527
|
type: "button",
|
|
@@ -7271,7 +7531,7 @@ var ViewportButton = ({
|
|
|
7271
7531
|
e.stopPropagation();
|
|
7272
7532
|
onClick({ width, height });
|
|
7273
7533
|
},
|
|
7274
|
-
children: /* @__PURE__ */
|
|
7534
|
+
children: /* @__PURE__ */ jsx37("span", { className: getClassNameButton("inner"), children })
|
|
7275
7535
|
}
|
|
7276
7536
|
) });
|
|
7277
7537
|
};
|
|
@@ -7307,8 +7567,8 @@ var ViewportControls = ({
|
|
|
7307
7567
|
].filter((a) => a.value <= autoZoom).sort((a, b) => a.value > b.value ? 1 : -1),
|
|
7308
7568
|
[autoZoom]
|
|
7309
7569
|
);
|
|
7310
|
-
return /* @__PURE__ */ jsxs16("div", { className:
|
|
7311
|
-
viewports.map((viewport, i) => /* @__PURE__ */
|
|
7570
|
+
return /* @__PURE__ */ jsxs16("div", { className: getClassName25(), children: [
|
|
7571
|
+
viewports.map((viewport, i) => /* @__PURE__ */ jsx37(
|
|
7312
7572
|
ViewportButton,
|
|
7313
7573
|
{
|
|
7314
7574
|
height: viewport.height,
|
|
@@ -7319,8 +7579,8 @@ var ViewportControls = ({
|
|
|
7319
7579
|
},
|
|
7320
7580
|
i
|
|
7321
7581
|
)),
|
|
7322
|
-
/* @__PURE__ */
|
|
7323
|
-
/* @__PURE__ */
|
|
7582
|
+
/* @__PURE__ */ jsx37("div", { className: getClassName25("divider") }),
|
|
7583
|
+
/* @__PURE__ */ jsx37(
|
|
7324
7584
|
IconButton,
|
|
7325
7585
|
{
|
|
7326
7586
|
type: "button",
|
|
@@ -7335,10 +7595,10 @@ var ViewportControls = ({
|
|
|
7335
7595
|
)].value
|
|
7336
7596
|
);
|
|
7337
7597
|
},
|
|
7338
|
-
children: /* @__PURE__ */
|
|
7598
|
+
children: /* @__PURE__ */ jsx37(ZoomOut, { size: 16 })
|
|
7339
7599
|
}
|
|
7340
7600
|
),
|
|
7341
|
-
/* @__PURE__ */
|
|
7601
|
+
/* @__PURE__ */ jsx37(
|
|
7342
7602
|
IconButton,
|
|
7343
7603
|
{
|
|
7344
7604
|
type: "button",
|
|
@@ -7353,19 +7613,19 @@ var ViewportControls = ({
|
|
|
7353
7613
|
)].value
|
|
7354
7614
|
);
|
|
7355
7615
|
},
|
|
7356
|
-
children: /* @__PURE__ */
|
|
7616
|
+
children: /* @__PURE__ */ jsx37(ZoomIn, { size: 16 })
|
|
7357
7617
|
}
|
|
7358
7618
|
),
|
|
7359
|
-
/* @__PURE__ */
|
|
7360
|
-
/* @__PURE__ */
|
|
7619
|
+
/* @__PURE__ */ jsx37("div", { className: getClassName25("divider") }),
|
|
7620
|
+
/* @__PURE__ */ jsx37(
|
|
7361
7621
|
"select",
|
|
7362
7622
|
{
|
|
7363
|
-
className:
|
|
7623
|
+
className: getClassName25("zoomSelect"),
|
|
7364
7624
|
value: zoom.toString(),
|
|
7365
7625
|
onChange: (e) => {
|
|
7366
7626
|
onZoom(parseFloat(e.currentTarget.value));
|
|
7367
7627
|
},
|
|
7368
|
-
children: zoomOptions.map((option) => /* @__PURE__ */
|
|
7628
|
+
children: zoomOptions.map((option) => /* @__PURE__ */ jsx37(
|
|
7369
7629
|
"option",
|
|
7370
7630
|
{
|
|
7371
7631
|
value: option.value,
|
|
@@ -7380,32 +7640,32 @@ var ViewportControls = ({
|
|
|
7380
7640
|
|
|
7381
7641
|
// css-module:/home/runner/work/puck/puck/packages/core/components/Puck/components/Canvas/styles.module.css#css-module
|
|
7382
7642
|
init_react_import();
|
|
7383
|
-
var
|
|
7643
|
+
var styles_module_default21 = { "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" };
|
|
7384
7644
|
|
|
7385
7645
|
// components/Puck/components/Canvas/index.tsx
|
|
7386
|
-
import { useShallow as
|
|
7646
|
+
import { useShallow as useShallow8 } from "zustand/react/shallow";
|
|
7387
7647
|
|
|
7388
7648
|
// lib/frame-context.tsx
|
|
7389
7649
|
init_react_import();
|
|
7390
7650
|
import {
|
|
7391
7651
|
createContext as createContext7,
|
|
7392
7652
|
useContext as useContext12,
|
|
7393
|
-
useRef as
|
|
7653
|
+
useRef as useRef8,
|
|
7394
7654
|
useMemo as useMemo16
|
|
7395
7655
|
} from "react";
|
|
7396
|
-
import { jsx as
|
|
7656
|
+
import { jsx as jsx38 } from "react/jsx-runtime";
|
|
7397
7657
|
var FrameContext = createContext7(null);
|
|
7398
7658
|
var FrameProvider = ({
|
|
7399
7659
|
children
|
|
7400
7660
|
}) => {
|
|
7401
|
-
const frameRef =
|
|
7661
|
+
const frameRef = useRef8(null);
|
|
7402
7662
|
const value = useMemo16(
|
|
7403
7663
|
() => ({
|
|
7404
7664
|
frameRef
|
|
7405
7665
|
}),
|
|
7406
7666
|
[]
|
|
7407
7667
|
);
|
|
7408
|
-
return /* @__PURE__ */
|
|
7668
|
+
return /* @__PURE__ */ jsx38(FrameContext.Provider, { value, children });
|
|
7409
7669
|
};
|
|
7410
7670
|
var useCanvasFrame = () => {
|
|
7411
7671
|
const context = useContext12(FrameContext);
|
|
@@ -7416,9 +7676,10 @@ var useCanvasFrame = () => {
|
|
|
7416
7676
|
};
|
|
7417
7677
|
|
|
7418
7678
|
// components/Puck/components/Canvas/index.tsx
|
|
7419
|
-
import { Fragment as
|
|
7420
|
-
var
|
|
7679
|
+
import { Fragment as Fragment12, jsx as jsx39, jsxs as jsxs17 } from "react/jsx-runtime";
|
|
7680
|
+
var getClassName26 = get_class_name_factory_default("PuckCanvas", styles_module_default21);
|
|
7421
7681
|
var ZOOM_ON_CHANGE = true;
|
|
7682
|
+
var TRANSITION_DURATION = 150;
|
|
7422
7683
|
var Canvas = () => {
|
|
7423
7684
|
const { frameRef } = useCanvasFrame();
|
|
7424
7685
|
const resetAutoZoom = useResetAutoZoom(frameRef);
|
|
@@ -7431,7 +7692,7 @@ var Canvas = () => {
|
|
|
7431
7692
|
status,
|
|
7432
7693
|
iframe
|
|
7433
7694
|
} = useAppStore(
|
|
7434
|
-
|
|
7695
|
+
useShallow8((s) => ({
|
|
7435
7696
|
dispatch: s.dispatch,
|
|
7436
7697
|
overrides: s.overrides,
|
|
7437
7698
|
setUi: s.setUi,
|
|
@@ -7448,7 +7709,7 @@ var Canvas = () => {
|
|
|
7448
7709
|
rightSideBarWidth,
|
|
7449
7710
|
viewports
|
|
7450
7711
|
} = useAppStore(
|
|
7451
|
-
|
|
7712
|
+
useShallow8((s) => ({
|
|
7452
7713
|
leftSideBarVisible: s.state.ui.leftSideBarVisible,
|
|
7453
7714
|
rightSideBarVisible: s.state.ui.rightSideBarVisible,
|
|
7454
7715
|
leftSideBarWidth: s.state.ui.leftSideBarWidth,
|
|
@@ -7456,17 +7717,17 @@ var Canvas = () => {
|
|
|
7456
7717
|
viewports: s.state.ui.viewports
|
|
7457
7718
|
}))
|
|
7458
7719
|
);
|
|
7459
|
-
const [showTransition, setShowTransition] =
|
|
7460
|
-
const
|
|
7720
|
+
const [showTransition, setShowTransition] = useState21(false);
|
|
7721
|
+
const isResizingRef = useRef9(false);
|
|
7461
7722
|
const defaultRender = useMemo17(() => {
|
|
7462
|
-
const PuckDefault = ({ children }) => /* @__PURE__ */
|
|
7723
|
+
const PuckDefault = ({ children }) => /* @__PURE__ */ jsx39(Fragment12, { children });
|
|
7463
7724
|
return PuckDefault;
|
|
7464
7725
|
}, []);
|
|
7465
7726
|
const CustomPreview = useMemo17(
|
|
7466
7727
|
() => overrides.preview || defaultRender,
|
|
7467
7728
|
[overrides]
|
|
7468
7729
|
);
|
|
7469
|
-
const getFrameDimensions =
|
|
7730
|
+
const getFrameDimensions = useCallback15(() => {
|
|
7470
7731
|
if (frameRef.current) {
|
|
7471
7732
|
const frame = frameRef.current;
|
|
7472
7733
|
const box = getBox(frame);
|
|
@@ -7474,23 +7735,17 @@ var Canvas = () => {
|
|
|
7474
7735
|
}
|
|
7475
7736
|
return { width: 0, height: 0 };
|
|
7476
7737
|
}, [frameRef]);
|
|
7477
|
-
|
|
7478
|
-
resetAutoZoom(
|
|
7479
|
-
isResettingRef: isResettingZoomRef,
|
|
7480
|
-
setShowTransition,
|
|
7481
|
-
showTransition: false,
|
|
7482
|
-
viewports
|
|
7483
|
-
});
|
|
7738
|
+
useEffect25(() => {
|
|
7739
|
+
resetAutoZoom();
|
|
7484
7740
|
}, [
|
|
7485
7741
|
frameRef,
|
|
7486
7742
|
leftSideBarVisible,
|
|
7487
7743
|
rightSideBarVisible,
|
|
7488
7744
|
leftSideBarWidth,
|
|
7489
7745
|
rightSideBarWidth,
|
|
7490
|
-
resetAutoZoom,
|
|
7491
7746
|
viewports
|
|
7492
7747
|
]);
|
|
7493
|
-
|
|
7748
|
+
useEffect25(() => {
|
|
7494
7749
|
const { height: frameHeight } = getFrameDimensions();
|
|
7495
7750
|
if (viewports.current.height === "auto") {
|
|
7496
7751
|
setZoomConfig(__spreadProps(__spreadValues({}, zoomConfig), {
|
|
@@ -7498,31 +7753,25 @@ var Canvas = () => {
|
|
|
7498
7753
|
}));
|
|
7499
7754
|
}
|
|
7500
7755
|
}, [zoomConfig.zoom, getFrameDimensions, setZoomConfig]);
|
|
7501
|
-
|
|
7756
|
+
useEffect25(() => {
|
|
7502
7757
|
if (ZOOM_ON_CHANGE) {
|
|
7503
|
-
resetAutoZoom(
|
|
7504
|
-
|
|
7505
|
-
|
|
7506
|
-
|
|
7507
|
-
|
|
7508
|
-
|
|
7509
|
-
|
|
7510
|
-
|
|
7511
|
-
|
|
7512
|
-
|
|
7513
|
-
|
|
7514
|
-
isResettingRef: isResettingZoomRef,
|
|
7515
|
-
setShowTransition,
|
|
7516
|
-
showTransition: false
|
|
7517
|
-
});
|
|
7518
|
-
};
|
|
7519
|
-
window.addEventListener("resize", cb);
|
|
7758
|
+
resetAutoZoom();
|
|
7759
|
+
}
|
|
7760
|
+
}, [viewports.current.width, viewports]);
|
|
7761
|
+
useEffect25(() => {
|
|
7762
|
+
if (!frameRef.current) return;
|
|
7763
|
+
const resizeObserver = new ResizeObserver(() => {
|
|
7764
|
+
if (!isResizingRef.current) {
|
|
7765
|
+
resetAutoZoom();
|
|
7766
|
+
}
|
|
7767
|
+
});
|
|
7768
|
+
resizeObserver.observe(frameRef.current);
|
|
7520
7769
|
return () => {
|
|
7521
|
-
|
|
7770
|
+
resizeObserver.disconnect();
|
|
7522
7771
|
};
|
|
7523
|
-
}, [
|
|
7524
|
-
const [showLoader, setShowLoader] =
|
|
7525
|
-
|
|
7772
|
+
}, [frameRef.current]);
|
|
7773
|
+
const [showLoader, setShowLoader] = useState21(false);
|
|
7774
|
+
useEffect25(() => {
|
|
7526
7775
|
setTimeout(() => {
|
|
7527
7776
|
setShowLoader(true);
|
|
7528
7777
|
}, 500);
|
|
@@ -7530,23 +7779,29 @@ var Canvas = () => {
|
|
|
7530
7779
|
return /* @__PURE__ */ jsxs17(
|
|
7531
7780
|
"div",
|
|
7532
7781
|
{
|
|
7533
|
-
className:
|
|
7782
|
+
className: getClassName26({
|
|
7534
7783
|
ready: status === "READY" || !iframe.enabled || !iframe.waitForStyles,
|
|
7535
7784
|
showLoader
|
|
7536
7785
|
}),
|
|
7537
|
-
onClick: () =>
|
|
7538
|
-
|
|
7539
|
-
|
|
7540
|
-
|
|
7541
|
-
|
|
7786
|
+
onClick: (e) => {
|
|
7787
|
+
const el = e.target;
|
|
7788
|
+
if (!el.hasAttribute("data-puck-component") && !el.hasAttribute("data-puck-dropzone")) {
|
|
7789
|
+
dispatch({
|
|
7790
|
+
type: "setUi",
|
|
7791
|
+
ui: { itemSelector: null },
|
|
7792
|
+
recordHistory: true
|
|
7793
|
+
});
|
|
7794
|
+
}
|
|
7795
|
+
},
|
|
7542
7796
|
children: [
|
|
7543
|
-
viewports.controlsVisible && iframe.enabled && /* @__PURE__ */
|
|
7797
|
+
viewports.controlsVisible && iframe.enabled && /* @__PURE__ */ jsx39("div", { className: getClassName26("controls"), children: /* @__PURE__ */ jsx39(
|
|
7544
7798
|
ViewportControls,
|
|
7545
7799
|
{
|
|
7546
7800
|
autoZoom: zoomConfig.autoZoom,
|
|
7547
7801
|
zoom: zoomConfig.zoom,
|
|
7548
7802
|
onViewportChange: (viewport) => {
|
|
7549
7803
|
setShowTransition(true);
|
|
7804
|
+
isResizingRef.current = true;
|
|
7550
7805
|
const uiViewport = __spreadProps(__spreadValues({}, viewport), {
|
|
7551
7806
|
height: viewport.height || "auto",
|
|
7552
7807
|
zoom: zoomConfig.zoom
|
|
@@ -7558,42 +7813,39 @@ var Canvas = () => {
|
|
|
7558
7813
|
setUi(newUi);
|
|
7559
7814
|
if (ZOOM_ON_CHANGE) {
|
|
7560
7815
|
resetAutoZoom({
|
|
7561
|
-
isResettingRef: isResettingZoomRef,
|
|
7562
|
-
setShowTransition,
|
|
7563
|
-
showTransition: true,
|
|
7564
7816
|
viewports: __spreadProps(__spreadValues({}, viewports), { current: uiViewport })
|
|
7565
7817
|
});
|
|
7566
7818
|
}
|
|
7567
7819
|
},
|
|
7568
7820
|
onZoom: (zoom) => {
|
|
7569
7821
|
setShowTransition(true);
|
|
7822
|
+
isResizingRef.current = true;
|
|
7570
7823
|
setZoomConfig(__spreadProps(__spreadValues({}, zoomConfig), { zoom }));
|
|
7571
7824
|
}
|
|
7572
7825
|
}
|
|
7573
7826
|
) }),
|
|
7574
|
-
/* @__PURE__ */ jsxs17("div", { className:
|
|
7575
|
-
/* @__PURE__ */
|
|
7827
|
+
/* @__PURE__ */ jsxs17("div", { className: getClassName26("inner"), ref: frameRef, children: [
|
|
7828
|
+
/* @__PURE__ */ jsx39(
|
|
7576
7829
|
"div",
|
|
7577
7830
|
{
|
|
7578
|
-
className:
|
|
7831
|
+
className: getClassName26("root"),
|
|
7579
7832
|
style: {
|
|
7580
7833
|
width: iframe.enabled ? viewports.current.width : "100%",
|
|
7581
7834
|
height: zoomConfig.rootHeight,
|
|
7582
7835
|
transform: iframe.enabled ? `scale(${zoomConfig.zoom})` : void 0,
|
|
7583
|
-
transition: showTransition ?
|
|
7836
|
+
transition: showTransition ? `width ${TRANSITION_DURATION}ms ease-out, height ${TRANSITION_DURATION}ms ease-out, transform ${TRANSITION_DURATION}ms ease-out` : "",
|
|
7584
7837
|
overflow: iframe.enabled ? void 0 : "auto"
|
|
7585
7838
|
},
|
|
7586
7839
|
suppressHydrationWarning: true,
|
|
7587
7840
|
id: "puck-canvas-root",
|
|
7588
7841
|
onTransitionEnd: () => {
|
|
7589
|
-
|
|
7590
|
-
|
|
7591
|
-
});
|
|
7842
|
+
setShowTransition(false);
|
|
7843
|
+
isResizingRef.current = false;
|
|
7592
7844
|
},
|
|
7593
|
-
children: /* @__PURE__ */
|
|
7845
|
+
children: /* @__PURE__ */ jsx39(CustomPreview, { children: /* @__PURE__ */ jsx39(Preview2, {}) })
|
|
7594
7846
|
}
|
|
7595
7847
|
),
|
|
7596
|
-
/* @__PURE__ */
|
|
7848
|
+
/* @__PURE__ */ jsx39("div", { className: getClassName26("loader"), children: /* @__PURE__ */ jsx39(Loader, { size: 24 }) })
|
|
7597
7849
|
] })
|
|
7598
7850
|
]
|
|
7599
7851
|
}
|
|
@@ -7612,8 +7864,11 @@ var loadOverrides = ({
|
|
|
7612
7864
|
}) => {
|
|
7613
7865
|
const collected = __spreadValues({}, overrides);
|
|
7614
7866
|
plugins == null ? void 0 : plugins.forEach((plugin) => {
|
|
7867
|
+
if (!plugin.overrides) return;
|
|
7615
7868
|
Object.keys(plugin.overrides).forEach((_overridesType) => {
|
|
7869
|
+
var _a;
|
|
7616
7870
|
const overridesType = _overridesType;
|
|
7871
|
+
if (!((_a = plugin.overrides) == null ? void 0 : _a[overridesType])) return;
|
|
7617
7872
|
if (overridesType === "fieldTypes") {
|
|
7618
7873
|
const fieldTypes = plugin.overrides.fieldTypes;
|
|
7619
7874
|
Object.keys(fieldTypes).forEach((fieldType) => {
|
|
@@ -7648,19 +7903,19 @@ var useLoadedOverrides = ({
|
|
|
7648
7903
|
|
|
7649
7904
|
// components/DefaultOverride/index.tsx
|
|
7650
7905
|
init_react_import();
|
|
7651
|
-
import { Fragment as
|
|
7652
|
-
var DefaultOverride = ({ children }) => /* @__PURE__ */
|
|
7906
|
+
import { Fragment as Fragment13, jsx as jsx40 } from "react/jsx-runtime";
|
|
7907
|
+
var DefaultOverride = ({ children }) => /* @__PURE__ */ jsx40(Fragment13, { children });
|
|
7653
7908
|
|
|
7654
7909
|
// lib/use-inject-css.ts
|
|
7655
7910
|
init_react_import();
|
|
7656
|
-
import { useEffect as
|
|
7911
|
+
import { useEffect as useEffect26, useState as useState22 } from "react";
|
|
7657
7912
|
var styles = ``;
|
|
7658
7913
|
var useInjectStyleSheet = (initialStyles, iframeEnabled) => {
|
|
7659
|
-
const [el, setEl] =
|
|
7660
|
-
|
|
7914
|
+
const [el, setEl] = useState22();
|
|
7915
|
+
useEffect26(() => {
|
|
7661
7916
|
setEl(document.createElement("style"));
|
|
7662
7917
|
}, []);
|
|
7663
|
-
|
|
7918
|
+
useEffect26(() => {
|
|
7664
7919
|
var _a;
|
|
7665
7920
|
if (!el || typeof window === "undefined") {
|
|
7666
7921
|
return;
|
|
@@ -7680,10 +7935,10 @@ var useInjectGlobalCss = (iframeEnabled) => {
|
|
|
7680
7935
|
|
|
7681
7936
|
// lib/use-preview-mode-hotkeys.ts
|
|
7682
7937
|
init_react_import();
|
|
7683
|
-
import { useCallback as
|
|
7938
|
+
import { useCallback as useCallback16 } from "react";
|
|
7684
7939
|
var usePreviewModeHotkeys = () => {
|
|
7685
7940
|
const appStore = useAppStoreApi();
|
|
7686
|
-
const toggleInteractive =
|
|
7941
|
+
const toggleInteractive = useCallback16(() => {
|
|
7687
7942
|
const dispatch = appStore.getState().dispatch;
|
|
7688
7943
|
dispatch({
|
|
7689
7944
|
type: "setUi",
|
|
@@ -7701,18 +7956,18 @@ import fdeq from "fast-deep-equal";
|
|
|
7701
7956
|
|
|
7702
7957
|
// components/Puck/components/Header/index.tsx
|
|
7703
7958
|
init_react_import();
|
|
7704
|
-
import { memo as
|
|
7959
|
+
import { memo as memo4, useCallback as useCallback17, useMemo as useMemo19, useState as useState23 } from "react";
|
|
7705
7960
|
|
|
7706
7961
|
// components/MenuBar/index.tsx
|
|
7707
7962
|
init_react_import();
|
|
7708
7963
|
|
|
7709
7964
|
// css-module:/home/runner/work/puck/puck/packages/core/components/MenuBar/styles.module.css#css-module
|
|
7710
7965
|
init_react_import();
|
|
7711
|
-
var
|
|
7966
|
+
var styles_module_default22 = { "MenuBar": "_MenuBar_8pf8c_1", "MenuBar--menuOpen": "_MenuBar--menuOpen_8pf8c_14", "MenuBar-inner": "_MenuBar-inner_8pf8c_29", "MenuBar-history": "_MenuBar-history_8pf8c_45" };
|
|
7712
7967
|
|
|
7713
7968
|
// components/MenuBar/index.tsx
|
|
7714
|
-
import { Fragment as
|
|
7715
|
-
var
|
|
7969
|
+
import { Fragment as Fragment14, jsx as jsx41, jsxs as jsxs18 } from "react/jsx-runtime";
|
|
7970
|
+
var getClassName27 = get_class_name_factory_default("MenuBar", styles_module_default22);
|
|
7716
7971
|
function MenuBar({
|
|
7717
7972
|
menuOpen = false,
|
|
7718
7973
|
renderHeaderActions,
|
|
@@ -7722,10 +7977,10 @@ function MenuBar({
|
|
|
7722
7977
|
const forward = useAppStore((s) => s.history.forward);
|
|
7723
7978
|
const hasFuture = useAppStore((s) => s.history.hasFuture());
|
|
7724
7979
|
const hasPast = useAppStore((s) => s.history.hasPast());
|
|
7725
|
-
return /* @__PURE__ */
|
|
7980
|
+
return /* @__PURE__ */ jsx41(
|
|
7726
7981
|
"div",
|
|
7727
7982
|
{
|
|
7728
|
-
className:
|
|
7983
|
+
className: getClassName27({ menuOpen }),
|
|
7729
7984
|
onClick: (event) => {
|
|
7730
7985
|
var _a;
|
|
7731
7986
|
const element = event.target;
|
|
@@ -7736,30 +7991,30 @@ function MenuBar({
|
|
|
7736
7991
|
setMenuOpen(false);
|
|
7737
7992
|
}
|
|
7738
7993
|
},
|
|
7739
|
-
children: /* @__PURE__ */ jsxs18("div", { className:
|
|
7740
|
-
/* @__PURE__ */ jsxs18("div", { className:
|
|
7741
|
-
/* @__PURE__ */
|
|
7994
|
+
children: /* @__PURE__ */ jsxs18("div", { className: getClassName27("inner"), children: [
|
|
7995
|
+
/* @__PURE__ */ jsxs18("div", { className: getClassName27("history"), children: [
|
|
7996
|
+
/* @__PURE__ */ jsx41(
|
|
7742
7997
|
IconButton,
|
|
7743
7998
|
{
|
|
7744
7999
|
type: "button",
|
|
7745
8000
|
title: "undo",
|
|
7746
8001
|
disabled: !hasPast,
|
|
7747
8002
|
onClick: back,
|
|
7748
|
-
children: /* @__PURE__ */
|
|
8003
|
+
children: /* @__PURE__ */ jsx41(Undo2, { size: 21 })
|
|
7749
8004
|
}
|
|
7750
8005
|
),
|
|
7751
|
-
/* @__PURE__ */
|
|
8006
|
+
/* @__PURE__ */ jsx41(
|
|
7752
8007
|
IconButton,
|
|
7753
8008
|
{
|
|
7754
8009
|
type: "button",
|
|
7755
8010
|
title: "redo",
|
|
7756
8011
|
disabled: !hasFuture,
|
|
7757
8012
|
onClick: forward,
|
|
7758
|
-
children: /* @__PURE__ */
|
|
8013
|
+
children: /* @__PURE__ */ jsx41(Redo2, { size: 21 })
|
|
7759
8014
|
}
|
|
7760
8015
|
)
|
|
7761
8016
|
] }),
|
|
7762
|
-
/* @__PURE__ */
|
|
8017
|
+
/* @__PURE__ */ jsx41(Fragment14, { children: renderHeaderActions && renderHeaderActions() })
|
|
7763
8018
|
] })
|
|
7764
8019
|
}
|
|
7765
8020
|
);
|
|
@@ -7767,11 +8022,11 @@ function MenuBar({
|
|
|
7767
8022
|
|
|
7768
8023
|
// css-module:/home/runner/work/puck/puck/packages/core/components/Puck/components/Header/styles.module.css#css-module
|
|
7769
8024
|
init_react_import();
|
|
7770
|
-
var
|
|
8025
|
+
var styles_module_default23 = { "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" };
|
|
7771
8026
|
|
|
7772
8027
|
// components/Puck/components/Header/index.tsx
|
|
7773
|
-
import { Fragment as
|
|
7774
|
-
var
|
|
8028
|
+
import { Fragment as Fragment15, jsx as jsx42, jsxs as jsxs19 } from "react/jsx-runtime";
|
|
8029
|
+
var getClassName28 = get_class_name_factory_default("PuckHeader", styles_module_default23);
|
|
7775
8030
|
var HeaderInner = () => {
|
|
7776
8031
|
const {
|
|
7777
8032
|
onPublish,
|
|
@@ -7792,7 +8047,7 @@ var HeaderInner = () => {
|
|
|
7792
8047
|
var _b = _a, { actions } = _b, props = __objRest(_b, ["actions"]);
|
|
7793
8048
|
const Comp = renderHeader;
|
|
7794
8049
|
const appState = useAppStore((s) => s.state);
|
|
7795
|
-
return /* @__PURE__ */
|
|
8050
|
+
return /* @__PURE__ */ jsx42(Comp, __spreadProps(__spreadValues({}, props), { dispatch, state: appState, children: actions }));
|
|
7796
8051
|
};
|
|
7797
8052
|
return RenderHeader;
|
|
7798
8053
|
}
|
|
@@ -7806,19 +8061,19 @@ var HeaderInner = () => {
|
|
|
7806
8061
|
const RenderHeader = (props) => {
|
|
7807
8062
|
const Comp = renderHeaderActions;
|
|
7808
8063
|
const appState = useAppStore((s) => s.state);
|
|
7809
|
-
return /* @__PURE__ */
|
|
8064
|
+
return /* @__PURE__ */ jsx42(Comp, __spreadProps(__spreadValues({}, props), { dispatch, state: appState }));
|
|
7810
8065
|
};
|
|
7811
8066
|
return RenderHeader;
|
|
7812
8067
|
}
|
|
7813
8068
|
return DefaultOverride;
|
|
7814
|
-
}, [
|
|
8069
|
+
}, [renderHeaderActions]);
|
|
7815
8070
|
const CustomHeader = useAppStore(
|
|
7816
8071
|
(s) => s.overrides.header || defaultHeaderRender
|
|
7817
8072
|
);
|
|
7818
8073
|
const CustomHeaderActions = useAppStore(
|
|
7819
8074
|
(s) => s.overrides.headerActions || defaultHeaderActionsRender
|
|
7820
8075
|
);
|
|
7821
|
-
const [menuOpen, setMenuOpen] =
|
|
8076
|
+
const [menuOpen, setMenuOpen] = useState23(false);
|
|
7822
8077
|
const rootTitle = useAppStore((s) => {
|
|
7823
8078
|
var _a, _b;
|
|
7824
8079
|
const rootData = (_a = s.state.indexes.nodes["root"]) == null ? void 0 : _a.data;
|
|
@@ -7828,7 +8083,7 @@ var HeaderInner = () => {
|
|
|
7828
8083
|
const rightSideBarVisible = useAppStore(
|
|
7829
8084
|
(s) => s.state.ui.rightSideBarVisible
|
|
7830
8085
|
);
|
|
7831
|
-
const toggleSidebars =
|
|
8086
|
+
const toggleSidebars = useCallback17(
|
|
7832
8087
|
(sidebar) => {
|
|
7833
8088
|
const widerViewport = window.matchMedia("(min-width: 638px)").matches;
|
|
7834
8089
|
const sideBarVisible = sidebar === "left" ? leftSideBarVisible : rightSideBarVisible;
|
|
@@ -7842,27 +8097,27 @@ var HeaderInner = () => {
|
|
|
7842
8097
|
},
|
|
7843
8098
|
[dispatch, leftSideBarVisible, rightSideBarVisible]
|
|
7844
8099
|
);
|
|
7845
|
-
return /* @__PURE__ */
|
|
8100
|
+
return /* @__PURE__ */ jsx42(
|
|
7846
8101
|
CustomHeader,
|
|
7847
8102
|
{
|
|
7848
|
-
actions: /* @__PURE__ */
|
|
8103
|
+
actions: /* @__PURE__ */ jsx42(Fragment15, { children: /* @__PURE__ */ jsx42(CustomHeaderActions, { children: /* @__PURE__ */ jsx42(
|
|
7849
8104
|
Button,
|
|
7850
8105
|
{
|
|
7851
8106
|
onClick: () => {
|
|
7852
8107
|
const data = appStore.getState().state.data;
|
|
7853
8108
|
onPublish && onPublish(data);
|
|
7854
8109
|
},
|
|
7855
|
-
icon: /* @__PURE__ */
|
|
8110
|
+
icon: /* @__PURE__ */ jsx42(Globe, { size: "14px" }),
|
|
7856
8111
|
children: "Publish"
|
|
7857
8112
|
}
|
|
7858
8113
|
) }) }),
|
|
7859
|
-
children: /* @__PURE__ */
|
|
8114
|
+
children: /* @__PURE__ */ jsx42(
|
|
7860
8115
|
"header",
|
|
7861
8116
|
{
|
|
7862
|
-
className:
|
|
7863
|
-
children: /* @__PURE__ */ jsxs19("div", { className:
|
|
7864
|
-
/* @__PURE__ */ jsxs19("div", { className:
|
|
7865
|
-
/* @__PURE__ */
|
|
8117
|
+
className: getClassName28({ leftSideBarVisible, rightSideBarVisible }),
|
|
8118
|
+
children: /* @__PURE__ */ jsxs19("div", { className: getClassName28("inner"), children: [
|
|
8119
|
+
/* @__PURE__ */ jsxs19("div", { className: getClassName28("toggle"), children: [
|
|
8120
|
+
/* @__PURE__ */ jsx42("div", { className: getClassName28("leftSideBarToggle"), children: /* @__PURE__ */ jsx42(
|
|
7866
8121
|
IconButton,
|
|
7867
8122
|
{
|
|
7868
8123
|
type: "button",
|
|
@@ -7870,10 +8125,10 @@ var HeaderInner = () => {
|
|
|
7870
8125
|
toggleSidebars("left");
|
|
7871
8126
|
},
|
|
7872
8127
|
title: "Toggle left sidebar",
|
|
7873
|
-
children: /* @__PURE__ */
|
|
8128
|
+
children: /* @__PURE__ */ jsx42(PanelLeft, { focusable: "false" })
|
|
7874
8129
|
}
|
|
7875
8130
|
) }),
|
|
7876
|
-
/* @__PURE__ */
|
|
8131
|
+
/* @__PURE__ */ jsx42("div", { className: getClassName28("rightSideBarToggle"), children: /* @__PURE__ */ jsx42(
|
|
7877
8132
|
IconButton,
|
|
7878
8133
|
{
|
|
7879
8134
|
type: "button",
|
|
@@ -7881,19 +8136,19 @@ var HeaderInner = () => {
|
|
|
7881
8136
|
toggleSidebars("right");
|
|
7882
8137
|
},
|
|
7883
8138
|
title: "Toggle right sidebar",
|
|
7884
|
-
children: /* @__PURE__ */
|
|
8139
|
+
children: /* @__PURE__ */ jsx42(PanelRight, { focusable: "false" })
|
|
7885
8140
|
}
|
|
7886
8141
|
) })
|
|
7887
8142
|
] }),
|
|
7888
|
-
/* @__PURE__ */
|
|
8143
|
+
/* @__PURE__ */ jsx42("div", { className: getClassName28("title"), children: /* @__PURE__ */ jsxs19(Heading, { rank: "2", size: "xs", children: [
|
|
7889
8144
|
headerTitle || rootTitle || "Page",
|
|
7890
|
-
headerPath && /* @__PURE__ */ jsxs19(
|
|
8145
|
+
headerPath && /* @__PURE__ */ jsxs19(Fragment15, { children: [
|
|
7891
8146
|
" ",
|
|
7892
|
-
/* @__PURE__ */
|
|
8147
|
+
/* @__PURE__ */ jsx42("code", { className: getClassName28("path"), children: headerPath })
|
|
7893
8148
|
] })
|
|
7894
8149
|
] }) }),
|
|
7895
|
-
/* @__PURE__ */ jsxs19("div", { className:
|
|
7896
|
-
/* @__PURE__ */
|
|
8150
|
+
/* @__PURE__ */ jsxs19("div", { className: getClassName28("tools"), children: [
|
|
8151
|
+
/* @__PURE__ */ jsx42("div", { className: getClassName28("menuButton"), children: /* @__PURE__ */ jsx42(
|
|
7897
8152
|
IconButton,
|
|
7898
8153
|
{
|
|
7899
8154
|
type: "button",
|
|
@@ -7901,23 +8156,23 @@ var HeaderInner = () => {
|
|
|
7901
8156
|
return setMenuOpen(!menuOpen);
|
|
7902
8157
|
},
|
|
7903
8158
|
title: "Toggle menu bar",
|
|
7904
|
-
children: menuOpen ? /* @__PURE__ */
|
|
8159
|
+
children: menuOpen ? /* @__PURE__ */ jsx42(ChevronUp, { focusable: "false" }) : /* @__PURE__ */ jsx42(ChevronDown, { focusable: "false" })
|
|
7905
8160
|
}
|
|
7906
8161
|
) }),
|
|
7907
|
-
/* @__PURE__ */
|
|
8162
|
+
/* @__PURE__ */ jsx42(
|
|
7908
8163
|
MenuBar,
|
|
7909
8164
|
{
|
|
7910
8165
|
dispatch,
|
|
7911
8166
|
onPublish,
|
|
7912
8167
|
menuOpen,
|
|
7913
|
-
renderHeaderActions: () => /* @__PURE__ */
|
|
8168
|
+
renderHeaderActions: () => /* @__PURE__ */ jsx42(CustomHeaderActions, { children: /* @__PURE__ */ jsx42(
|
|
7914
8169
|
Button,
|
|
7915
8170
|
{
|
|
7916
8171
|
onClick: () => {
|
|
7917
8172
|
const data = appStore.getState().state.data;
|
|
7918
8173
|
onPublish && onPublish(data);
|
|
7919
8174
|
},
|
|
7920
|
-
icon: /* @__PURE__ */
|
|
8175
|
+
icon: /* @__PURE__ */ jsx42(Globe, { size: "14px" }),
|
|
7921
8176
|
children: "Publish"
|
|
7922
8177
|
}
|
|
7923
8178
|
) }),
|
|
@@ -7931,22 +8186,22 @@ var HeaderInner = () => {
|
|
|
7931
8186
|
}
|
|
7932
8187
|
);
|
|
7933
8188
|
};
|
|
7934
|
-
var Header =
|
|
8189
|
+
var Header = memo4(HeaderInner);
|
|
7935
8190
|
|
|
7936
8191
|
// components/Puck/components/Sidebar/index.tsx
|
|
7937
8192
|
init_react_import();
|
|
7938
8193
|
|
|
7939
8194
|
// components/Puck/components/ResizeHandle/index.tsx
|
|
7940
8195
|
init_react_import();
|
|
7941
|
-
import { useCallback as
|
|
8196
|
+
import { useCallback as useCallback18, useRef as useRef10 } from "react";
|
|
7942
8197
|
|
|
7943
8198
|
// css-module:/home/runner/work/puck/puck/packages/core/components/Puck/components/ResizeHandle/styles.module.css#css-module
|
|
7944
8199
|
init_react_import();
|
|
7945
|
-
var
|
|
8200
|
+
var styles_module_default24 = { "ResizeHandle": "_ResizeHandle_144bf_2", "ResizeHandle--left": "_ResizeHandle--left_144bf_16", "ResizeHandle--right": "_ResizeHandle--right_144bf_20" };
|
|
7946
8201
|
|
|
7947
8202
|
// components/Puck/components/ResizeHandle/index.tsx
|
|
7948
|
-
import { jsx as
|
|
7949
|
-
var
|
|
8203
|
+
import { jsx as jsx43 } from "react/jsx-runtime";
|
|
8204
|
+
var getClassName29 = get_class_name_factory_default("ResizeHandle", styles_module_default24);
|
|
7950
8205
|
var ResizeHandle = ({
|
|
7951
8206
|
position,
|
|
7952
8207
|
sidebarRef,
|
|
@@ -7955,11 +8210,11 @@ var ResizeHandle = ({
|
|
|
7955
8210
|
}) => {
|
|
7956
8211
|
const { frameRef } = useCanvasFrame();
|
|
7957
8212
|
const resetAutoZoom = useResetAutoZoom(frameRef);
|
|
7958
|
-
const handleRef =
|
|
7959
|
-
const isDragging =
|
|
7960
|
-
const startX =
|
|
7961
|
-
const startWidth =
|
|
7962
|
-
const handleMouseMove =
|
|
8213
|
+
const handleRef = useRef10(null);
|
|
8214
|
+
const isDragging = useRef10(false);
|
|
8215
|
+
const startX = useRef10(0);
|
|
8216
|
+
const startWidth = useRef10(0);
|
|
8217
|
+
const handleMouseMove = useCallback18(
|
|
7963
8218
|
(e) => {
|
|
7964
8219
|
if (!isDragging.current) return;
|
|
7965
8220
|
const delta = e.clientX - startX.current;
|
|
@@ -7970,7 +8225,7 @@ var ResizeHandle = ({
|
|
|
7970
8225
|
},
|
|
7971
8226
|
[onResize, position]
|
|
7972
8227
|
);
|
|
7973
|
-
const handleMouseUp =
|
|
8228
|
+
const handleMouseUp = useCallback18(() => {
|
|
7974
8229
|
var _a;
|
|
7975
8230
|
if (!isDragging.current) return;
|
|
7976
8231
|
isDragging.current = false;
|
|
@@ -7985,8 +8240,8 @@ var ResizeHandle = ({
|
|
|
7985
8240
|
const finalWidth = ((_a = sidebarRef.current) == null ? void 0 : _a.getBoundingClientRect().width) || 0;
|
|
7986
8241
|
onResizeEnd(finalWidth);
|
|
7987
8242
|
resetAutoZoom();
|
|
7988
|
-
}, [onResizeEnd
|
|
7989
|
-
const handleMouseDown =
|
|
8243
|
+
}, [onResizeEnd]);
|
|
8244
|
+
const handleMouseDown = useCallback18(
|
|
7990
8245
|
(e) => {
|
|
7991
8246
|
var _a;
|
|
7992
8247
|
isDragging.current = true;
|
|
@@ -8004,11 +8259,11 @@ var ResizeHandle = ({
|
|
|
8004
8259
|
},
|
|
8005
8260
|
[position, handleMouseMove, handleMouseUp]
|
|
8006
8261
|
);
|
|
8007
|
-
return /* @__PURE__ */
|
|
8262
|
+
return /* @__PURE__ */ jsx43(
|
|
8008
8263
|
"div",
|
|
8009
8264
|
{
|
|
8010
8265
|
ref: handleRef,
|
|
8011
|
-
className:
|
|
8266
|
+
className: getClassName29({ [position]: true }),
|
|
8012
8267
|
onMouseDown: handleMouseDown
|
|
8013
8268
|
}
|
|
8014
8269
|
);
|
|
@@ -8016,24 +8271,23 @@ var ResizeHandle = ({
|
|
|
8016
8271
|
|
|
8017
8272
|
// css-module:/home/runner/work/puck/puck/packages/core/components/Puck/components/Sidebar/styles.module.css#css-module
|
|
8018
8273
|
init_react_import();
|
|
8019
|
-
var
|
|
8274
|
+
var styles_module_default25 = { "Sidebar": "_Sidebar_1xksb_1", "Sidebar--left": "_Sidebar--left_1xksb_8", "Sidebar--right": "_Sidebar--right_1xksb_14", "Sidebar-resizeHandle": "_Sidebar-resizeHandle_1xksb_20" };
|
|
8020
8275
|
|
|
8021
8276
|
// components/Puck/components/Sidebar/index.tsx
|
|
8022
|
-
import { Fragment as
|
|
8023
|
-
var
|
|
8277
|
+
import { Fragment as Fragment16, jsx as jsx44, jsxs as jsxs20 } from "react/jsx-runtime";
|
|
8278
|
+
var getClassName30 = get_class_name_factory_default("Sidebar", styles_module_default25);
|
|
8024
8279
|
var Sidebar = ({
|
|
8025
8280
|
position,
|
|
8026
8281
|
sidebarRef,
|
|
8027
8282
|
isVisible,
|
|
8028
|
-
width,
|
|
8029
8283
|
onResize,
|
|
8030
8284
|
onResizeEnd,
|
|
8031
8285
|
children
|
|
8032
8286
|
}) => {
|
|
8033
8287
|
if (!isVisible) return null;
|
|
8034
|
-
return /* @__PURE__ */ jsxs20(
|
|
8035
|
-
/* @__PURE__ */
|
|
8036
|
-
/* @__PURE__ */
|
|
8288
|
+
return /* @__PURE__ */ jsxs20(Fragment16, { children: [
|
|
8289
|
+
/* @__PURE__ */ jsx44("div", { ref: sidebarRef, className: getClassName30({ [position]: true }), children }),
|
|
8290
|
+
/* @__PURE__ */ jsx44("div", { className: `${getClassName30("resizeHandle")}`, children: /* @__PURE__ */ jsx44(
|
|
8037
8291
|
ResizeHandle,
|
|
8038
8292
|
{
|
|
8039
8293
|
position,
|
|
@@ -8047,25 +8301,26 @@ var Sidebar = ({
|
|
|
8047
8301
|
|
|
8048
8302
|
// lib/use-sidebar-resize.ts
|
|
8049
8303
|
init_react_import();
|
|
8050
|
-
import { useCallback as
|
|
8304
|
+
import { useCallback as useCallback19, useEffect as useEffect28, useRef as useRef11, useState as useState24 } from "react";
|
|
8051
8305
|
function useSidebarResize(position, dispatch) {
|
|
8052
|
-
const [width, setWidth] =
|
|
8053
|
-
const sidebarRef =
|
|
8306
|
+
const [width, setWidth] = useState24(null);
|
|
8307
|
+
const sidebarRef = useRef11(null);
|
|
8054
8308
|
const storeWidth = useAppStore(
|
|
8055
8309
|
(s) => position === "left" ? s.state.ui.leftSideBarWidth : s.state.ui.rightSideBarWidth
|
|
8056
8310
|
);
|
|
8057
|
-
|
|
8311
|
+
useEffect28(() => {
|
|
8058
8312
|
if (typeof window !== "undefined" && !storeWidth) {
|
|
8059
8313
|
try {
|
|
8060
8314
|
const savedWidths = localStorage.getItem("puck-sidebar-widths");
|
|
8061
8315
|
if (savedWidths) {
|
|
8062
8316
|
const widths = JSON.parse(savedWidths);
|
|
8063
8317
|
const savedWidth = widths[position];
|
|
8318
|
+
const key = position === "left" ? "leftSideBarWidth" : "rightSideBarWidth";
|
|
8064
8319
|
if (savedWidth) {
|
|
8065
8320
|
dispatch({
|
|
8066
8321
|
type: "setUi",
|
|
8067
8322
|
ui: {
|
|
8068
|
-
[
|
|
8323
|
+
[key]: savedWidth
|
|
8069
8324
|
}
|
|
8070
8325
|
});
|
|
8071
8326
|
}
|
|
@@ -8078,12 +8333,12 @@ function useSidebarResize(position, dispatch) {
|
|
|
8078
8333
|
}
|
|
8079
8334
|
}
|
|
8080
8335
|
}, [dispatch, position, storeWidth]);
|
|
8081
|
-
|
|
8336
|
+
useEffect28(() => {
|
|
8082
8337
|
if (storeWidth !== void 0) {
|
|
8083
8338
|
setWidth(storeWidth);
|
|
8084
8339
|
}
|
|
8085
8340
|
}, [storeWidth]);
|
|
8086
|
-
const handleResizeEnd =
|
|
8341
|
+
const handleResizeEnd = useCallback19(
|
|
8087
8342
|
(width2) => {
|
|
8088
8343
|
dispatch({
|
|
8089
8344
|
type: "setUi",
|
|
@@ -8126,9 +8381,9 @@ function useSidebarResize(position, dispatch) {
|
|
|
8126
8381
|
}
|
|
8127
8382
|
|
|
8128
8383
|
// components/Puck/index.tsx
|
|
8129
|
-
import { jsx as
|
|
8130
|
-
var
|
|
8131
|
-
var getLayoutClassName = get_class_name_factory_default("PuckLayout",
|
|
8384
|
+
import { jsx as jsx45, jsxs as jsxs21 } from "react/jsx-runtime";
|
|
8385
|
+
var getClassName31 = get_class_name_factory_default("Puck", styles_module_default15);
|
|
8386
|
+
var getLayoutClassName = get_class_name_factory_default("PuckLayout", styles_module_default15);
|
|
8132
8387
|
var FieldSideBar = () => {
|
|
8133
8388
|
const title = useAppStore(
|
|
8134
8389
|
(s) => {
|
|
@@ -8136,11 +8391,11 @@ var FieldSideBar = () => {
|
|
|
8136
8391
|
return s.selectedItem ? (_b = (_a = s.config.components[s.selectedItem.type]) == null ? void 0 : _a["label"]) != null ? _b : s.selectedItem.type.toString() : "Page";
|
|
8137
8392
|
}
|
|
8138
8393
|
);
|
|
8139
|
-
return /* @__PURE__ */
|
|
8394
|
+
return /* @__PURE__ */ jsx45(SidebarSection, { noPadding: true, noBorderTop: true, showBreadcrumbs: true, title, children: /* @__PURE__ */ jsx45(Fields, {}) });
|
|
8140
8395
|
};
|
|
8141
8396
|
var propsContext = createContext8({});
|
|
8142
8397
|
function PropsProvider(props) {
|
|
8143
|
-
return /* @__PURE__ */
|
|
8398
|
+
return /* @__PURE__ */ jsx45(propsContext.Provider, { value: props, children: props.children });
|
|
8144
8399
|
}
|
|
8145
8400
|
var usePropsContext = () => useContext13(propsContext);
|
|
8146
8401
|
function PuckProvider({ children }) {
|
|
@@ -8156,7 +8411,8 @@ function PuckProvider({ children }) {
|
|
|
8156
8411
|
iframe: _iframe,
|
|
8157
8412
|
initialHistory: _initialHistory,
|
|
8158
8413
|
metadata,
|
|
8159
|
-
onAction
|
|
8414
|
+
onAction,
|
|
8415
|
+
fieldTransforms
|
|
8160
8416
|
} = usePropsContext();
|
|
8161
8417
|
const iframe = useMemo20(
|
|
8162
8418
|
() => __spreadValues({
|
|
@@ -8165,7 +8421,7 @@ function PuckProvider({ children }) {
|
|
|
8165
8421
|
}, _iframe),
|
|
8166
8422
|
[_iframe]
|
|
8167
8423
|
);
|
|
8168
|
-
const [generatedAppState] =
|
|
8424
|
+
const [generatedAppState] = useState25(() => {
|
|
8169
8425
|
var _a, _b, _c, _d, _e, _f, _g, _h, _i;
|
|
8170
8426
|
const initial = __spreadValues(__spreadValues({}, defaultAppState.ui), initialUi);
|
|
8171
8427
|
let clientUiState = {};
|
|
@@ -8194,7 +8450,7 @@ function PuckProvider({ children }) {
|
|
|
8194
8450
|
}
|
|
8195
8451
|
}
|
|
8196
8452
|
if (Object.keys((initialData == null ? void 0 : initialData.root) || {}).length > 0 && !((_g = initialData == null ? void 0 : initialData.root) == null ? void 0 : _g.props)) {
|
|
8197
|
-
console.
|
|
8453
|
+
console.warn(
|
|
8198
8454
|
"Warning: Defining props on `root` is deprecated. Please use `root.props`, or republish this page to migrate automatically."
|
|
8199
8455
|
);
|
|
8200
8456
|
}
|
|
@@ -8225,7 +8481,7 @@ function PuckProvider({ children }) {
|
|
|
8225
8481
|
return walkAppState(newAppState, config);
|
|
8226
8482
|
});
|
|
8227
8483
|
const { appendData = true } = _initialHistory || {};
|
|
8228
|
-
const [blendedHistories] =
|
|
8484
|
+
const [blendedHistories] = useState25(
|
|
8229
8485
|
[
|
|
8230
8486
|
...(_initialHistory == null ? void 0 : _initialHistory.histories) || [],
|
|
8231
8487
|
...appendData ? [{ state: generatedAppState }] : []
|
|
@@ -8245,7 +8501,15 @@ function PuckProvider({ children }) {
|
|
|
8245
8501
|
overrides,
|
|
8246
8502
|
plugins
|
|
8247
8503
|
});
|
|
8248
|
-
const
|
|
8504
|
+
const loadedFieldTransforms = useMemo20(() => {
|
|
8505
|
+
const _plugins = plugins || [];
|
|
8506
|
+
const pluginFieldTransforms = _plugins.reduce(
|
|
8507
|
+
(acc, plugin) => __spreadValues(__spreadValues({}, acc), plugin.fieldTransforms),
|
|
8508
|
+
{}
|
|
8509
|
+
);
|
|
8510
|
+
return __spreadValues(__spreadValues({}, pluginFieldTransforms), fieldTransforms);
|
|
8511
|
+
}, [fieldTransforms, plugins]);
|
|
8512
|
+
const generateAppStore = useCallback20(
|
|
8249
8513
|
(state) => {
|
|
8250
8514
|
return {
|
|
8251
8515
|
state,
|
|
@@ -8255,7 +8519,8 @@ function PuckProvider({ children }) {
|
|
|
8255
8519
|
viewports,
|
|
8256
8520
|
iframe,
|
|
8257
8521
|
onAction,
|
|
8258
|
-
metadata
|
|
8522
|
+
metadata,
|
|
8523
|
+
fieldTransforms: loadedFieldTransforms
|
|
8259
8524
|
};
|
|
8260
8525
|
},
|
|
8261
8526
|
[
|
|
@@ -8266,18 +8531,19 @@ function PuckProvider({ children }) {
|
|
|
8266
8531
|
viewports,
|
|
8267
8532
|
iframe,
|
|
8268
8533
|
onAction,
|
|
8269
|
-
metadata
|
|
8534
|
+
metadata,
|
|
8535
|
+
loadedFieldTransforms
|
|
8270
8536
|
]
|
|
8271
8537
|
);
|
|
8272
|
-
const [appStore] =
|
|
8538
|
+
const [appStore] = useState25(
|
|
8273
8539
|
() => createAppStore(generateAppStore(initialAppState))
|
|
8274
8540
|
);
|
|
8275
|
-
|
|
8541
|
+
useEffect29(() => {
|
|
8276
8542
|
if (process.env.NODE_ENV !== "production") {
|
|
8277
8543
|
window.__PUCK_INTERNAL_DO_NOT_USE = { appStore };
|
|
8278
8544
|
}
|
|
8279
8545
|
}, [appStore]);
|
|
8280
|
-
|
|
8546
|
+
useEffect29(() => {
|
|
8281
8547
|
const state = appStore.getState().state;
|
|
8282
8548
|
appStore.setState(__spreadValues({}, generateAppStore(state)));
|
|
8283
8549
|
}, [config, plugins, loadedOverrides, viewports, iframe, onAction, metadata]);
|
|
@@ -8286,8 +8552,8 @@ function PuckProvider({ children }) {
|
|
|
8286
8552
|
index: initialHistoryIndex,
|
|
8287
8553
|
initialAppState
|
|
8288
8554
|
});
|
|
8289
|
-
const previousData =
|
|
8290
|
-
|
|
8555
|
+
const previousData = useRef12(null);
|
|
8556
|
+
useEffect29(() => {
|
|
8291
8557
|
appStore.subscribe(
|
|
8292
8558
|
(s) => s.state.data,
|
|
8293
8559
|
(data) => {
|
|
@@ -8301,11 +8567,11 @@ function PuckProvider({ children }) {
|
|
|
8301
8567
|
}, []);
|
|
8302
8568
|
useRegisterPermissionsSlice(appStore, permissions);
|
|
8303
8569
|
const uPuckStore = useRegisterUsePuckStore(appStore);
|
|
8304
|
-
|
|
8570
|
+
useEffect29(() => {
|
|
8305
8571
|
const { resolveAndCommitData } = appStore.getState();
|
|
8306
8572
|
resolveAndCommitData();
|
|
8307
8573
|
}, []);
|
|
8308
|
-
return /* @__PURE__ */
|
|
8574
|
+
return /* @__PURE__ */ jsx45(appStoreContext.Provider, { value: appStore, children: /* @__PURE__ */ jsx45(UsePuckStoreContext.Provider, { value: uPuckStore, children }) });
|
|
8309
8575
|
}
|
|
8310
8576
|
function PuckLayout({ children }) {
|
|
8311
8577
|
const {
|
|
@@ -8338,7 +8604,7 @@ function PuckLayout({ children }) {
|
|
|
8338
8604
|
sidebarRef: rightSidebarRef,
|
|
8339
8605
|
handleResizeEnd: handleRightSidebarResizeEnd
|
|
8340
8606
|
} = useSidebarResize("right", dispatch);
|
|
8341
|
-
|
|
8607
|
+
useEffect29(() => {
|
|
8342
8608
|
if (!window.matchMedia("(min-width: 638px)").matches) {
|
|
8343
8609
|
dispatch({
|
|
8344
8610
|
type: "setUi",
|
|
@@ -8366,13 +8632,13 @@ function PuckLayout({ children }) {
|
|
|
8366
8632
|
() => overrides.puck || DefaultOverride,
|
|
8367
8633
|
[overrides]
|
|
8368
8634
|
);
|
|
8369
|
-
const [mounted, setMounted] =
|
|
8370
|
-
|
|
8635
|
+
const [mounted, setMounted] = useState25(false);
|
|
8636
|
+
useEffect29(() => {
|
|
8371
8637
|
setMounted(true);
|
|
8372
8638
|
}, []);
|
|
8373
8639
|
const ready = useAppStore((s) => s.status === "READY");
|
|
8374
8640
|
useMonitorHotkeys();
|
|
8375
|
-
|
|
8641
|
+
useEffect29(() => {
|
|
8376
8642
|
if (ready && iframe.enabled) {
|
|
8377
8643
|
const frameDoc = getFrame();
|
|
8378
8644
|
if (frameDoc) {
|
|
@@ -8381,8 +8647,15 @@ function PuckLayout({ children }) {
|
|
|
8381
8647
|
}
|
|
8382
8648
|
}, [ready, iframe.enabled]);
|
|
8383
8649
|
usePreviewModeHotkeys();
|
|
8384
|
-
|
|
8385
|
-
|
|
8650
|
+
const layoutOptions = {};
|
|
8651
|
+
if (leftWidth) {
|
|
8652
|
+
layoutOptions["--puck-user-left-side-bar-width"] = `${leftWidth}px`;
|
|
8653
|
+
}
|
|
8654
|
+
if (rightWidth) {
|
|
8655
|
+
layoutOptions["--puck-user-right-side-bar-width"] = `${rightWidth}px`;
|
|
8656
|
+
}
|
|
8657
|
+
return /* @__PURE__ */ jsxs21("div", { className: `Puck ${getClassName31()}`, children: [
|
|
8658
|
+
/* @__PURE__ */ jsx45(DragDropContext, { disableAutoScroll: dnd == null ? void 0 : dnd.disableAutoScroll, children: /* @__PURE__ */ jsx45(CustomPuck, { children: children || /* @__PURE__ */ jsx45(FrameProvider, { children: /* @__PURE__ */ jsx45(
|
|
8386
8659
|
"div",
|
|
8387
8660
|
{
|
|
8388
8661
|
className: getLayoutClassName({
|
|
@@ -8394,41 +8667,33 @@ function PuckLayout({ children }) {
|
|
|
8394
8667
|
"div",
|
|
8395
8668
|
{
|
|
8396
8669
|
className: getLayoutClassName("inner"),
|
|
8397
|
-
style:
|
|
8398
|
-
gridTemplateColumns: `
|
|
8399
|
-
${leftSideBarVisible ? leftWidth ? `${leftWidth}px` : "var(--puck-side-bar-width)" : "0"}
|
|
8400
|
-
var(--puck-frame-width)
|
|
8401
|
-
${rightSideBarVisible ? rightWidth ? `${rightWidth}px` : "var(--puck-side-bar-width)" : "0"}
|
|
8402
|
-
`
|
|
8403
|
-
},
|
|
8670
|
+
style: layoutOptions,
|
|
8404
8671
|
children: [
|
|
8405
|
-
/* @__PURE__ */
|
|
8672
|
+
/* @__PURE__ */ jsx45(Header, {}),
|
|
8406
8673
|
/* @__PURE__ */ jsxs21(
|
|
8407
8674
|
Sidebar,
|
|
8408
8675
|
{
|
|
8409
8676
|
position: "left",
|
|
8410
8677
|
sidebarRef: leftSidebarRef,
|
|
8411
8678
|
isVisible: leftSideBarVisible,
|
|
8412
|
-
width: leftWidth,
|
|
8413
8679
|
onResize: setLeftWidth,
|
|
8414
8680
|
onResizeEnd: handleLeftSidebarResizeEnd,
|
|
8415
8681
|
children: [
|
|
8416
|
-
/* @__PURE__ */
|
|
8417
|
-
/* @__PURE__ */
|
|
8682
|
+
/* @__PURE__ */ jsx45(SidebarSection, { title: "Components", noBorderTop: true, children: /* @__PURE__ */ jsx45(Components, {}) }),
|
|
8683
|
+
/* @__PURE__ */ jsx45(SidebarSection, { title: "Outline", children: /* @__PURE__ */ jsx45(Outline, {}) })
|
|
8418
8684
|
]
|
|
8419
8685
|
}
|
|
8420
8686
|
),
|
|
8421
|
-
/* @__PURE__ */
|
|
8422
|
-
/* @__PURE__ */
|
|
8687
|
+
/* @__PURE__ */ jsx45(Canvas, {}),
|
|
8688
|
+
/* @__PURE__ */ jsx45(
|
|
8423
8689
|
Sidebar,
|
|
8424
8690
|
{
|
|
8425
8691
|
position: "right",
|
|
8426
8692
|
sidebarRef: rightSidebarRef,
|
|
8427
8693
|
isVisible: rightSideBarVisible,
|
|
8428
|
-
width: rightWidth,
|
|
8429
8694
|
onResize: setRightWidth,
|
|
8430
8695
|
onResizeEnd: handleRightSidebarResizeEnd,
|
|
8431
|
-
children: /* @__PURE__ */
|
|
8696
|
+
children: /* @__PURE__ */ jsx45(FieldSideBar, {})
|
|
8432
8697
|
}
|
|
8433
8698
|
)
|
|
8434
8699
|
]
|
|
@@ -8436,11 +8701,11 @@ function PuckLayout({ children }) {
|
|
|
8436
8701
|
)
|
|
8437
8702
|
}
|
|
8438
8703
|
) }) }) }),
|
|
8439
|
-
/* @__PURE__ */
|
|
8704
|
+
/* @__PURE__ */ jsx45("div", { id: "puck-portal-root", className: getClassName31("portal") })
|
|
8440
8705
|
] });
|
|
8441
8706
|
}
|
|
8442
8707
|
function Puck(props) {
|
|
8443
|
-
return /* @__PURE__ */
|
|
8708
|
+
return /* @__PURE__ */ jsx45(PropsProvider, __spreadProps(__spreadValues({}, props), { children: /* @__PURE__ */ jsx45(PuckProvider, __spreadProps(__spreadValues({}, props), { children: /* @__PURE__ */ jsx45(PuckLayout, __spreadValues({}, props)) })) }));
|
|
8444
8709
|
}
|
|
8445
8710
|
Puck.Components = Components;
|
|
8446
8711
|
Puck.Fields = Fields;
|
|
@@ -8459,6 +8724,9 @@ init_react_import();
|
|
|
8459
8724
|
// types/API/Viewports.ts
|
|
8460
8725
|
init_react_import();
|
|
8461
8726
|
|
|
8727
|
+
// types/API/FieldTransforms.ts
|
|
8728
|
+
init_react_import();
|
|
8729
|
+
|
|
8462
8730
|
// types/index.ts
|
|
8463
8731
|
init_react_import();
|
|
8464
8732
|
|
|
@@ -8492,6 +8760,8 @@ export {
|
|
|
8492
8760
|
AutoField,
|
|
8493
8761
|
renderContext,
|
|
8494
8762
|
Render,
|
|
8763
|
+
registerOverlayPortal,
|
|
8764
|
+
setDeep,
|
|
8495
8765
|
DropZone,
|
|
8496
8766
|
Drawer,
|
|
8497
8767
|
createUsePuck,
|