@measured/puck 0.19.0-canary.8d459e4e → 0.19.0-canary.8e1d7223
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/chunk-HGAPIQP5.mjs +949 -0
- package/dist/index.css +143 -143
- package/dist/index.d.mts +14 -13
- package/dist/index.d.ts +14 -13
- package/dist/index.js +1444 -1409
- package/dist/index.mjs +1026 -1403
- package/dist/rsc.d.mts +2 -2
- package/dist/rsc.d.ts +2 -2
- package/dist/rsc.js +537 -124
- package/dist/rsc.mjs +7 -3
- package/dist/{resolve-all-data-DtB0OZRl.d.mts → walk-tree-DBd3aQ_5.d.mts} +50 -22
- package/dist/{resolve-all-data-DtB0OZRl.d.ts → walk-tree-DBd3aQ_5.d.ts} +50 -22
- package/package.json +12 -7
- package/dist/chunk-D6ENWNOG.mjs +0 -543
package/dist/index.mjs
CHANGED
@@ -4,17 +4,15 @@ import {
|
|
4
4
|
__async,
|
5
5
|
__commonJS,
|
6
6
|
__objRest,
|
7
|
-
__privateAdd,
|
8
|
-
__privateGet,
|
9
|
-
__privateSet,
|
10
7
|
__spreadProps,
|
11
8
|
__spreadValues,
|
12
9
|
__toESM,
|
13
|
-
|
10
|
+
defaultAppState,
|
11
|
+
defaultViewports,
|
12
|
+
expandNode,
|
14
13
|
getChanged,
|
15
14
|
init_react_import,
|
16
|
-
|
17
|
-
mapSlotsSync,
|
15
|
+
migrate,
|
18
16
|
resolveAllData,
|
19
17
|
resolveComponentData,
|
20
18
|
rootAreaId,
|
@@ -22,8 +20,11 @@ import {
|
|
22
20
|
rootZone,
|
23
21
|
setupZone,
|
24
22
|
transformProps,
|
25
|
-
useSlots
|
26
|
-
|
23
|
+
useSlots,
|
24
|
+
walkAppState,
|
25
|
+
walkField,
|
26
|
+
walkTree
|
27
|
+
} from "./chunk-HGAPIQP5.mjs";
|
27
28
|
|
28
29
|
// ../../node_modules/classnames/index.js
|
29
30
|
var require_classnames = __commonJS({
|
@@ -703,198 +704,6 @@ init_react_import();
|
|
703
704
|
|
704
705
|
// reducer/actions/set.ts
|
705
706
|
init_react_import();
|
706
|
-
|
707
|
-
// lib/data/walk-app-state.ts
|
708
|
-
init_react_import();
|
709
|
-
|
710
|
-
// lib/data/for-each-slot.ts
|
711
|
-
init_react_import();
|
712
|
-
var forEachSlot = (item, cb, recursive = false, isSlot2 = isSlot) => {
|
713
|
-
const props = item.props || {};
|
714
|
-
const propKeys = Object.keys(props);
|
715
|
-
for (let i = 0; i < propKeys.length; i++) {
|
716
|
-
const propKey = propKeys[i];
|
717
|
-
const itemType = "type" in item ? item.type : "root";
|
718
|
-
if (isSlot2(itemType, propKey, props[propKey])) {
|
719
|
-
const content = props[propKey];
|
720
|
-
cb(props.id, propKey, content);
|
721
|
-
if (recursive) {
|
722
|
-
content.forEach(
|
723
|
-
(childItem) => __async(void 0, null, function* () {
|
724
|
-
return forEachSlot(childItem, cb, true, isSlot2);
|
725
|
-
})
|
726
|
-
);
|
727
|
-
}
|
728
|
-
}
|
729
|
-
}
|
730
|
-
};
|
731
|
-
|
732
|
-
// lib/data/for-related-zones.ts
|
733
|
-
init_react_import();
|
734
|
-
|
735
|
-
// lib/get-zone-id.ts
|
736
|
-
init_react_import();
|
737
|
-
var getZoneId = (zoneCompound) => {
|
738
|
-
if (!zoneCompound) {
|
739
|
-
return [];
|
740
|
-
}
|
741
|
-
if (zoneCompound && zoneCompound.indexOf(":") > -1) {
|
742
|
-
return zoneCompound.split(":");
|
743
|
-
}
|
744
|
-
return [rootDroppableId, zoneCompound];
|
745
|
-
};
|
746
|
-
|
747
|
-
// lib/data/for-related-zones.ts
|
748
|
-
function forRelatedZones(item, data, cb, path = []) {
|
749
|
-
Object.entries(data.zones || {}).forEach(([zoneCompound, content]) => {
|
750
|
-
const [parentId] = getZoneId(zoneCompound);
|
751
|
-
if (parentId === item.props.id) {
|
752
|
-
cb(path, zoneCompound, content);
|
753
|
-
}
|
754
|
-
});
|
755
|
-
}
|
756
|
-
|
757
|
-
// lib/data/strip-slots.ts
|
758
|
-
init_react_import();
|
759
|
-
var stripSlots = (data) => {
|
760
|
-
return __spreadProps(__spreadValues({}, data), {
|
761
|
-
props: Object.entries(data.props).reduce(
|
762
|
-
(acc, [propKey, propVal]) => {
|
763
|
-
if (isSlot(propVal)) {
|
764
|
-
return acc;
|
765
|
-
}
|
766
|
-
return __spreadProps(__spreadValues({}, acc), { [propKey]: propVal });
|
767
|
-
},
|
768
|
-
{ id: data.props.id }
|
769
|
-
)
|
770
|
-
});
|
771
|
-
};
|
772
|
-
|
773
|
-
// lib/data/walk-app-state.ts
|
774
|
-
function walkAppState(state, config, mapContent = (content) => content, mapNodeOrSkip = (item) => item) {
|
775
|
-
var _a;
|
776
|
-
let newZones = {};
|
777
|
-
const newZoneIndex = {};
|
778
|
-
const newNodeIndex = {};
|
779
|
-
const processContent = (path, zoneCompound, content, zoneType, newId) => {
|
780
|
-
var _a2;
|
781
|
-
const [parentId] = zoneCompound.split(":");
|
782
|
-
const mappedContent = ((_a2 = mapContent(content, zoneCompound, zoneType)) != null ? _a2 : content) || [];
|
783
|
-
const [_2, zone] = zoneCompound.split(":");
|
784
|
-
const newZoneCompound = `${newId || parentId}:${zone}`;
|
785
|
-
const newContent2 = mappedContent.map(
|
786
|
-
(zoneChild, index) => processItem(zoneChild, [...path, newZoneCompound], index)
|
787
|
-
);
|
788
|
-
newZoneIndex[newZoneCompound] = {
|
789
|
-
contentIds: newContent2.map((item) => item.props.id),
|
790
|
-
type: zoneType
|
791
|
-
};
|
792
|
-
return [newZoneCompound, newContent2];
|
793
|
-
};
|
794
|
-
const processRelatedZones = (item, newId, initialPath) => {
|
795
|
-
forRelatedZones(
|
796
|
-
item,
|
797
|
-
state.data,
|
798
|
-
(relatedPath, relatedZoneCompound, relatedContent) => {
|
799
|
-
const [zoneCompound, newContent2] = processContent(
|
800
|
-
relatedPath,
|
801
|
-
relatedZoneCompound,
|
802
|
-
relatedContent,
|
803
|
-
"dropzone",
|
804
|
-
newId
|
805
|
-
);
|
806
|
-
newZones[zoneCompound] = newContent2;
|
807
|
-
},
|
808
|
-
initialPath
|
809
|
-
);
|
810
|
-
};
|
811
|
-
const processItem = (item, path, index) => {
|
812
|
-
const mappedItem = mapNodeOrSkip(item, path, index);
|
813
|
-
if (!mappedItem) return item;
|
814
|
-
const id = mappedItem.props.id;
|
815
|
-
const newProps = __spreadValues({}, mappedItem.props);
|
816
|
-
forEachSlot(
|
817
|
-
mappedItem,
|
818
|
-
(parentId2, slotId, content) => {
|
819
|
-
const zoneCompound = `${parentId2}:${slotId}`;
|
820
|
-
const [_2, newContent2] = processContent(
|
821
|
-
path,
|
822
|
-
zoneCompound,
|
823
|
-
content,
|
824
|
-
"slot",
|
825
|
-
parentId2
|
826
|
-
);
|
827
|
-
newProps[slotId] = newContent2;
|
828
|
-
},
|
829
|
-
false,
|
830
|
-
createIsSlotConfig(config)
|
831
|
-
);
|
832
|
-
processRelatedZones(item, id, path);
|
833
|
-
const newItem = __spreadProps(__spreadValues({}, item), { props: newProps });
|
834
|
-
const thisZoneCompound = path[path.length - 1];
|
835
|
-
const [parentId, zone] = thisZoneCompound ? thisZoneCompound.split(":") : [null, ""];
|
836
|
-
newNodeIndex[id] = {
|
837
|
-
data: newItem,
|
838
|
-
flatData: stripSlots(newItem),
|
839
|
-
path,
|
840
|
-
parentId,
|
841
|
-
zone
|
842
|
-
};
|
843
|
-
const finalData = __spreadProps(__spreadValues({}, newItem), { props: __spreadValues({}, newItem.props) });
|
844
|
-
if (newProps.id === "root") {
|
845
|
-
delete finalData["type"];
|
846
|
-
delete finalData.props["id"];
|
847
|
-
}
|
848
|
-
return finalData;
|
849
|
-
};
|
850
|
-
const zones = state.data.zones || {};
|
851
|
-
const [_, newContent] = processContent(
|
852
|
-
[],
|
853
|
-
rootDroppableId,
|
854
|
-
state.data.content,
|
855
|
-
"root"
|
856
|
-
);
|
857
|
-
const processedContent = newContent;
|
858
|
-
const zonesAlreadyProcessed = Object.keys(newZones);
|
859
|
-
Object.keys(zones || {}).forEach((zoneCompound) => {
|
860
|
-
const [parentId] = zoneCompound.split(":");
|
861
|
-
if (zonesAlreadyProcessed.includes(zoneCompound)) {
|
862
|
-
return;
|
863
|
-
}
|
864
|
-
const [_2, newContent2] = processContent(
|
865
|
-
[rootDroppableId],
|
866
|
-
zoneCompound,
|
867
|
-
zones[zoneCompound],
|
868
|
-
"dropzone",
|
869
|
-
parentId
|
870
|
-
);
|
871
|
-
newZones[zoneCompound] = newContent2;
|
872
|
-
}, newZones);
|
873
|
-
const processedRoot = processItem(
|
874
|
-
{
|
875
|
-
type: "root",
|
876
|
-
props: __spreadProps(__spreadValues({}, (_a = state.data.root.props) != null ? _a : state.data.root), { id: "root" })
|
877
|
-
},
|
878
|
-
[],
|
879
|
-
-1
|
880
|
-
);
|
881
|
-
const root = __spreadProps(__spreadValues({}, state.data.root), {
|
882
|
-
props: processedRoot.props
|
883
|
-
});
|
884
|
-
return __spreadProps(__spreadValues({}, state), {
|
885
|
-
data: {
|
886
|
-
root,
|
887
|
-
content: processedContent,
|
888
|
-
zones: __spreadValues(__spreadValues({}, state.data.zones), newZones)
|
889
|
-
},
|
890
|
-
indexes: {
|
891
|
-
nodes: __spreadValues(__spreadValues({}, state.indexes.nodes), newNodeIndex),
|
892
|
-
zones: __spreadValues(__spreadValues({}, state.indexes.zones), newZoneIndex)
|
893
|
-
}
|
894
|
-
});
|
895
|
-
}
|
896
|
-
|
897
|
-
// reducer/actions/set.ts
|
898
707
|
var setAction = (state, action, appStore) => {
|
899
708
|
if (typeof action.state === "object") {
|
900
709
|
const newState = __spreadValues(__spreadValues({}, state), action.state);
|
@@ -933,15 +742,36 @@ var getIdsForParent = (zoneCompound, state) => {
|
|
933
742
|
return ((node == null ? void 0 : node.path) || []).map((p) => p.split(":")[0]);
|
934
743
|
};
|
935
744
|
|
745
|
+
// lib/data/populate-ids.ts
|
746
|
+
init_react_import();
|
747
|
+
var populateIds = (data, config, override = false) => {
|
748
|
+
const id = generateId(data.type);
|
749
|
+
return walkTree(
|
750
|
+
__spreadProps(__spreadValues({}, data), {
|
751
|
+
props: override ? __spreadProps(__spreadValues({}, data.props), { id }) : __spreadValues({}, data.props)
|
752
|
+
}),
|
753
|
+
config,
|
754
|
+
(contents) => contents.map((item) => {
|
755
|
+
const id2 = generateId(item.type);
|
756
|
+
return __spreadProps(__spreadValues({}, item), {
|
757
|
+
props: override ? __spreadProps(__spreadValues({}, item.props), { id: id2 }) : __spreadValues({ id: id2 }, item.props)
|
758
|
+
});
|
759
|
+
})
|
760
|
+
);
|
761
|
+
};
|
762
|
+
|
936
763
|
// reducer/actions/insert.ts
|
937
764
|
function insertAction(state, action, appStore) {
|
938
765
|
const id = action.id || generateId(action.componentType);
|
939
|
-
const emptyComponentData =
|
940
|
-
|
941
|
-
|
942
|
-
|
943
|
-
|
944
|
-
|
766
|
+
const emptyComponentData = populateIds(
|
767
|
+
{
|
768
|
+
type: action.componentType,
|
769
|
+
props: __spreadProps(__spreadValues({}, appStore.config.components[action.componentType].defaultProps || {}), {
|
770
|
+
id
|
771
|
+
})
|
772
|
+
},
|
773
|
+
appStore.config
|
774
|
+
);
|
945
775
|
const [parentId] = action.destinationZone.split(":");
|
946
776
|
const idsInPath = getIdsForParent(action.destinationZone, state);
|
947
777
|
return walkAppState(
|
@@ -982,25 +812,26 @@ var replaceAction = (state, action, appStore) => {
|
|
982
812
|
`Can't change the id during a replace action. Please us "remove" and "insert" to define a new node.`
|
983
813
|
);
|
984
814
|
}
|
815
|
+
const data = populateIds(action.data, appStore.config);
|
985
816
|
return walkAppState(
|
986
817
|
state,
|
987
818
|
appStore.config,
|
988
819
|
(content, zoneCompound) => {
|
989
820
|
const newContent = [...content];
|
990
821
|
if (zoneCompound === action.destinationZone) {
|
991
|
-
newContent[action.destinationIndex] =
|
822
|
+
newContent[action.destinationIndex] = data;
|
992
823
|
}
|
993
824
|
return newContent;
|
994
825
|
},
|
995
826
|
(childItem, path) => {
|
996
827
|
const pathIds = path.map((p) => p.split(":")[0]);
|
997
|
-
if (childItem.props.id ===
|
998
|
-
return
|
828
|
+
if (childItem.props.id === data.props.id) {
|
829
|
+
return data;
|
999
830
|
} else if (childItem.props.id === parentId) {
|
1000
831
|
return childItem;
|
1001
832
|
} else if (idsInPath.indexOf(childItem.props.id) > -1) {
|
1002
833
|
return childItem;
|
1003
|
-
} else if (pathIds.indexOf(
|
834
|
+
} else if (pathIds.indexOf(data.props.id) > -1) {
|
1004
835
|
return childItem;
|
1005
836
|
}
|
1006
837
|
return null;
|
@@ -1355,14 +1186,6 @@ function createReducer({
|
|
1355
1186
|
);
|
1356
1187
|
}
|
1357
1188
|
|
1358
|
-
// components/ViewportControls/default-viewports.ts
|
1359
|
-
init_react_import();
|
1360
|
-
var defaultViewports = [
|
1361
|
-
{ width: 360, height: "auto", icon: "Smartphone", label: "Small" },
|
1362
|
-
{ width: 768, height: "auto", icon: "Tablet", label: "Medium" },
|
1363
|
-
{ width: 1280, height: "auto", icon: "Monitor", label: "Large" }
|
1364
|
-
];
|
1365
|
-
|
1366
1189
|
// store/index.ts
|
1367
1190
|
import { create as create2, useStore } from "zustand";
|
1368
1191
|
import { subscribeWithSelector as subscribeWithSelector2 } from "zustand/middleware";
|
@@ -1604,7 +1427,11 @@ var createNodesSlice = (set, get) => ({
|
|
1604
1427
|
const s = get().nodes;
|
1605
1428
|
const emptyNode = {
|
1606
1429
|
id,
|
1607
|
-
methods: {
|
1430
|
+
methods: {
|
1431
|
+
sync: () => null,
|
1432
|
+
hideOverlay: () => null,
|
1433
|
+
showOverlay: () => null
|
1434
|
+
},
|
1608
1435
|
element: null
|
1609
1436
|
};
|
1610
1437
|
const existingNode = s.nodes[id];
|
@@ -1794,7 +1621,8 @@ var createFieldsSlice = (_set, _get) => {
|
|
1794
1621
|
return {
|
1795
1622
|
fields: {},
|
1796
1623
|
loading: false,
|
1797
|
-
lastResolvedData: {}
|
1624
|
+
lastResolvedData: {},
|
1625
|
+
id: void 0
|
1798
1626
|
};
|
1799
1627
|
};
|
1800
1628
|
var useRegisterFieldsSlice = (appStore, id) => {
|
@@ -1815,7 +1643,7 @@ var useRegisterFieldsSlice = (appStore, id) => {
|
|
1815
1643
|
let lastFields = fields;
|
1816
1644
|
if (reset) {
|
1817
1645
|
appStore.setState((s) => ({
|
1818
|
-
fields: __spreadProps(__spreadValues({}, s.fields), { fields: defaultFields })
|
1646
|
+
fields: __spreadProps(__spreadValues({}, s.fields), { fields: defaultFields, id })
|
1819
1647
|
}));
|
1820
1648
|
lastFields = defaultFields;
|
1821
1649
|
}
|
@@ -1843,12 +1671,13 @@ var useRegisterFieldsSlice = (appStore, id) => {
|
|
1843
1671
|
fields: {
|
1844
1672
|
fields: newFields,
|
1845
1673
|
loading: false,
|
1846
|
-
lastResolvedData: componentData
|
1674
|
+
lastResolvedData: componentData,
|
1675
|
+
id
|
1847
1676
|
}
|
1848
1677
|
});
|
1849
1678
|
} else {
|
1850
1679
|
appStore.setState((s) => ({
|
1851
|
-
fields: __spreadProps(__spreadValues({}, s.fields), { fields: defaultFields })
|
1680
|
+
fields: __spreadProps(__spreadValues({}, s.fields), { fields: defaultFields, id })
|
1852
1681
|
}));
|
1853
1682
|
}
|
1854
1683
|
}),
|
@@ -1881,31 +1710,6 @@ var toRoot = (item) => {
|
|
1881
1710
|
};
|
1882
1711
|
|
1883
1712
|
// store/index.ts
|
1884
|
-
var defaultAppState = {
|
1885
|
-
data: { content: [], root: {}, zones: {} },
|
1886
|
-
ui: {
|
1887
|
-
leftSideBarVisible: true,
|
1888
|
-
rightSideBarVisible: true,
|
1889
|
-
arrayState: {},
|
1890
|
-
itemSelector: null,
|
1891
|
-
componentList: {},
|
1892
|
-
isDragging: false,
|
1893
|
-
previewMode: "edit",
|
1894
|
-
viewports: {
|
1895
|
-
current: {
|
1896
|
-
width: defaultViewports[0].width,
|
1897
|
-
height: defaultViewports[0].height || "auto"
|
1898
|
-
},
|
1899
|
-
options: [],
|
1900
|
-
controlsVisible: true
|
1901
|
-
},
|
1902
|
-
field: { focus: null }
|
1903
|
-
},
|
1904
|
-
indexes: {
|
1905
|
-
nodes: {},
|
1906
|
-
zones: {}
|
1907
|
-
}
|
1908
|
-
};
|
1909
1713
|
var defaultPageFields = {
|
1910
1714
|
title: { type: "text" }
|
1911
1715
|
};
|
@@ -2094,326 +1898,11 @@ function useAppStoreApi() {
|
|
2094
1898
|
init_react_import();
|
2095
1899
|
import { DragDropProvider } from "@dnd-kit/react";
|
2096
1900
|
|
2097
|
-
// lib/dnd/dnd-kit/safe.ts
|
2098
|
-
init_react_import();
|
2099
|
-
import {
|
2100
|
-
useDraggable,
|
2101
|
-
useDroppable
|
2102
|
-
} from "@dnd-kit/react";
|
2103
|
-
import { useSortable } from "@dnd-kit/react/sortable";
|
2104
|
-
function useDroppableSafe(input) {
|
2105
|
-
if (typeof window === "undefined") {
|
2106
|
-
return { ref: () => {
|
2107
|
-
} };
|
2108
|
-
}
|
2109
|
-
return useDroppable(input);
|
2110
|
-
}
|
2111
|
-
function useDraggableSafe(input) {
|
2112
|
-
if (typeof window === "undefined") {
|
2113
|
-
return { ref: () => {
|
2114
|
-
} };
|
2115
|
-
}
|
2116
|
-
return useDraggable(input);
|
2117
|
-
}
|
2118
|
-
function useSortableSafe(input) {
|
2119
|
-
if (typeof window === "undefined") {
|
2120
|
-
return { ref: () => {
|
2121
|
-
}, status: "idle", handleRef: () => {
|
2122
|
-
} };
|
2123
|
-
}
|
2124
|
-
return useSortable(input);
|
2125
|
-
}
|
2126
|
-
|
2127
1901
|
// lib/dnd/use-sensors.ts
|
2128
1902
|
init_react_import();
|
2129
1903
|
import { useState as useState2 } from "react";
|
2130
|
-
|
2131
|
-
|
2132
|
-
init_react_import();
|
2133
|
-
import { batch, effect } from "@dnd-kit/state";
|
2134
|
-
import { Sensor, configurator } from "@dnd-kit/abstract";
|
2135
|
-
import {
|
2136
|
-
exceedsDistance
|
2137
|
-
} from "@dnd-kit/geometry";
|
2138
|
-
import {
|
2139
|
-
getDocument,
|
2140
|
-
isElement,
|
2141
|
-
isHTMLElement,
|
2142
|
-
isPointerEvent,
|
2143
|
-
Listeners,
|
2144
|
-
getFrameTransform
|
2145
|
-
} from "@dnd-kit/dom/utilities";
|
2146
|
-
var _clearTimeout;
|
2147
|
-
var _PointerSensor = class _PointerSensor extends Sensor {
|
2148
|
-
constructor(manager, options) {
|
2149
|
-
super(manager);
|
2150
|
-
this.manager = manager;
|
2151
|
-
this.options = options;
|
2152
|
-
this.listeners = new Listeners();
|
2153
|
-
this.cleanup = /* @__PURE__ */ new Set();
|
2154
|
-
this.source = void 0;
|
2155
|
-
this.started = false;
|
2156
|
-
__privateAdd(this, _clearTimeout);
|
2157
|
-
this.handleCancel = this.handleCancel.bind(this);
|
2158
|
-
this.handlePointerUp = this.handlePointerUp.bind(this);
|
2159
|
-
this.handleKeyDown = this.handleKeyDown.bind(this);
|
2160
|
-
effect(() => {
|
2161
|
-
const unbindGlobal = this.bindGlobal(options != null ? options : {});
|
2162
|
-
return () => {
|
2163
|
-
unbindGlobal();
|
2164
|
-
};
|
2165
|
-
});
|
2166
|
-
}
|
2167
|
-
bind(source, options = this.options) {
|
2168
|
-
const unbind = effect(() => {
|
2169
|
-
var _a;
|
2170
|
-
const target = (_a = source.handle) != null ? _a : source.element;
|
2171
|
-
const listener = (event) => {
|
2172
|
-
if (isPointerEvent(event)) {
|
2173
|
-
this.handlePointerDown(event, source, options);
|
2174
|
-
}
|
2175
|
-
};
|
2176
|
-
if (target) {
|
2177
|
-
patchWindow(target.ownerDocument.defaultView);
|
2178
|
-
target.addEventListener("pointerdown", listener);
|
2179
|
-
return () => {
|
2180
|
-
target.removeEventListener("pointerdown", listener);
|
2181
|
-
};
|
2182
|
-
}
|
2183
|
-
});
|
2184
|
-
return unbind;
|
2185
|
-
}
|
2186
|
-
bindGlobal(options) {
|
2187
|
-
const documents = /* @__PURE__ */ new Set();
|
2188
|
-
for (const draggable of this.manager.registry.draggables.value) {
|
2189
|
-
if (draggable.element) {
|
2190
|
-
documents.add(getDocument(draggable.element));
|
2191
|
-
}
|
2192
|
-
}
|
2193
|
-
for (const droppable of this.manager.registry.droppables.value) {
|
2194
|
-
if (droppable.element) {
|
2195
|
-
documents.add(getDocument(droppable.element));
|
2196
|
-
}
|
2197
|
-
}
|
2198
|
-
const unbindFns = Array.from(documents).map(
|
2199
|
-
(doc) => this.listeners.bind(doc, [
|
2200
|
-
{
|
2201
|
-
type: "pointermove",
|
2202
|
-
listener: (event) => this.handlePointerMove(event, doc, options)
|
2203
|
-
},
|
2204
|
-
{
|
2205
|
-
type: "pointerup",
|
2206
|
-
listener: this.handlePointerUp,
|
2207
|
-
options: {
|
2208
|
-
capture: true
|
2209
|
-
}
|
2210
|
-
},
|
2211
|
-
{
|
2212
|
-
// Cancel activation if there is a competing Drag and Drop interaction
|
2213
|
-
type: "dragstart",
|
2214
|
-
listener: this.handleDragStart
|
2215
|
-
}
|
2216
|
-
])
|
2217
|
-
);
|
2218
|
-
return () => {
|
2219
|
-
unbindFns.forEach((unbind) => unbind());
|
2220
|
-
};
|
2221
|
-
}
|
2222
|
-
handlePointerDown(event, source, options = {}) {
|
2223
|
-
if (this.disabled || !event.isPrimary || event.button !== 0 || !isElement(event.target) || source.disabled) {
|
2224
|
-
return;
|
2225
|
-
}
|
2226
|
-
const offset = getFrameTransform(source.element);
|
2227
|
-
this.initialCoordinates = {
|
2228
|
-
x: event.clientX * offset.scaleX + offset.x,
|
2229
|
-
y: event.clientY * offset.scaleY + offset.y
|
2230
|
-
};
|
2231
|
-
this.source = source;
|
2232
|
-
const { activationConstraints } = options;
|
2233
|
-
const constraints = typeof activationConstraints === "function" ? activationConstraints(event, source) : activationConstraints;
|
2234
|
-
event.stopImmediatePropagation();
|
2235
|
-
if (!(constraints == null ? void 0 : constraints.delay) && !(constraints == null ? void 0 : constraints.distance)) {
|
2236
|
-
this.handleStart(source, event);
|
2237
|
-
} else {
|
2238
|
-
const { delay } = constraints;
|
2239
|
-
if (delay) {
|
2240
|
-
const timeout3 = setTimeout(
|
2241
|
-
() => this.handleStart(source, event),
|
2242
|
-
delay.value
|
2243
|
-
);
|
2244
|
-
__privateSet(this, _clearTimeout, () => {
|
2245
|
-
clearTimeout(timeout3);
|
2246
|
-
__privateSet(this, _clearTimeout, void 0);
|
2247
|
-
});
|
2248
|
-
}
|
2249
|
-
}
|
2250
|
-
const cleanup = () => {
|
2251
|
-
var _a;
|
2252
|
-
(_a = __privateGet(this, _clearTimeout)) == null ? void 0 : _a.call(this);
|
2253
|
-
this.initialCoordinates = void 0;
|
2254
|
-
this.source = void 0;
|
2255
|
-
};
|
2256
|
-
this.cleanup.add(cleanup);
|
2257
|
-
}
|
2258
|
-
handlePointerMove(event, doc, options) {
|
2259
|
-
if (!this.source) {
|
2260
|
-
return;
|
2261
|
-
}
|
2262
|
-
const ownerDocument = this.source.element && getDocument(this.source.element);
|
2263
|
-
if (doc !== ownerDocument) {
|
2264
|
-
return;
|
2265
|
-
}
|
2266
|
-
const coordinates = {
|
2267
|
-
x: event.clientX,
|
2268
|
-
y: event.clientY
|
2269
|
-
};
|
2270
|
-
const offset = getFrameTransform(this.source.element);
|
2271
|
-
coordinates.x = coordinates.x * offset.scaleX + offset.x;
|
2272
|
-
coordinates.y = coordinates.y * offset.scaleY + offset.y;
|
2273
|
-
if (this.manager.dragOperation.status.dragging) {
|
2274
|
-
event.preventDefault();
|
2275
|
-
event.stopPropagation();
|
2276
|
-
this.manager.actions.move({ to: coordinates });
|
2277
|
-
return;
|
2278
|
-
}
|
2279
|
-
if (!this.initialCoordinates) {
|
2280
|
-
return;
|
2281
|
-
}
|
2282
|
-
const delta = {
|
2283
|
-
x: coordinates.x - this.initialCoordinates.x,
|
2284
|
-
y: coordinates.y - this.initialCoordinates.y
|
2285
|
-
};
|
2286
|
-
const { activationConstraints } = options;
|
2287
|
-
const constraints = typeof activationConstraints === "function" ? activationConstraints(event, this.source) : activationConstraints;
|
2288
|
-
const { distance, delay } = constraints != null ? constraints : {};
|
2289
|
-
if (distance) {
|
2290
|
-
if (distance.tolerance != null && exceedsDistance(delta, distance.tolerance)) {
|
2291
|
-
return this.handleCancel();
|
2292
|
-
}
|
2293
|
-
if (exceedsDistance(delta, distance.value)) {
|
2294
|
-
return this.handleStart(this.source, event);
|
2295
|
-
}
|
2296
|
-
}
|
2297
|
-
if (delay) {
|
2298
|
-
if (exceedsDistance(delta, delay.tolerance)) {
|
2299
|
-
return this.handleCancel();
|
2300
|
-
}
|
2301
|
-
}
|
2302
|
-
}
|
2303
|
-
handlePointerUp(event) {
|
2304
|
-
if (!this.source) {
|
2305
|
-
return;
|
2306
|
-
}
|
2307
|
-
event.preventDefault();
|
2308
|
-
event.stopPropagation();
|
2309
|
-
const { status } = this.manager.dragOperation;
|
2310
|
-
if (!status.idle) {
|
2311
|
-
const canceled = !status.initialized;
|
2312
|
-
this.manager.actions.stop({ canceled });
|
2313
|
-
} else if (this.started) {
|
2314
|
-
setTimeout(() => {
|
2315
|
-
if (!this.manager.dragOperation.status.idle) {
|
2316
|
-
this.manager.actions.stop({ canceled: false });
|
2317
|
-
}
|
2318
|
-
}, 10);
|
2319
|
-
}
|
2320
|
-
this.cleanup.forEach((cleanup) => cleanup());
|
2321
|
-
this.cleanup.clear();
|
2322
|
-
}
|
2323
|
-
handleKeyDown(event) {
|
2324
|
-
if (event.key === "Escape") {
|
2325
|
-
event.preventDefault();
|
2326
|
-
this.handleCancel();
|
2327
|
-
}
|
2328
|
-
}
|
2329
|
-
handleStart(source, event) {
|
2330
|
-
var _a;
|
2331
|
-
const { manager, initialCoordinates } = this;
|
2332
|
-
(_a = __privateGet(this, _clearTimeout)) == null ? void 0 : _a.call(this);
|
2333
|
-
if (!initialCoordinates || manager.dragOperation.status.initialized || this.started) {
|
2334
|
-
return;
|
2335
|
-
}
|
2336
|
-
if (event.defaultPrevented) {
|
2337
|
-
return;
|
2338
|
-
}
|
2339
|
-
this.started = true;
|
2340
|
-
event.preventDefault();
|
2341
|
-
batch(() => {
|
2342
|
-
manager.actions.setDragSource(source.id);
|
2343
|
-
manager.actions.start({ coordinates: initialCoordinates, event });
|
2344
|
-
});
|
2345
|
-
const ownerDocument = getDocument(event.target);
|
2346
|
-
const unbind = this.listeners.bind(ownerDocument, [
|
2347
|
-
{
|
2348
|
-
// Prevent scrolling on touch devices
|
2349
|
-
type: "touchmove",
|
2350
|
-
listener: preventDefault,
|
2351
|
-
options: {
|
2352
|
-
passive: false
|
2353
|
-
}
|
2354
|
-
},
|
2355
|
-
{
|
2356
|
-
// Prevent click events
|
2357
|
-
type: "click",
|
2358
|
-
listener: preventDefault
|
2359
|
-
},
|
2360
|
-
{
|
2361
|
-
type: "keydown",
|
2362
|
-
listener: this.handleKeyDown
|
2363
|
-
}
|
2364
|
-
]);
|
2365
|
-
ownerDocument.body.setPointerCapture(event.pointerId);
|
2366
|
-
this.cleanup.add(unbind);
|
2367
|
-
this.cleanup.add(() => {
|
2368
|
-
this.started = false;
|
2369
|
-
});
|
2370
|
-
}
|
2371
|
-
handleDragStart(event) {
|
2372
|
-
const { target } = event;
|
2373
|
-
if (!isElement(target)) {
|
2374
|
-
return;
|
2375
|
-
}
|
2376
|
-
const isNativeDraggable = isHTMLElement(target) && target.draggable && target.getAttribute("draggable") === "true";
|
2377
|
-
if (isNativeDraggable) {
|
2378
|
-
this.handleCancel();
|
2379
|
-
} else {
|
2380
|
-
preventDefault(event);
|
2381
|
-
}
|
2382
|
-
}
|
2383
|
-
handleCancel() {
|
2384
|
-
const { dragOperation } = this.manager;
|
2385
|
-
if (dragOperation.status.initialized) {
|
2386
|
-
this.manager.actions.stop({ canceled: true });
|
2387
|
-
}
|
2388
|
-
this.cleanup.forEach((cleanup) => cleanup());
|
2389
|
-
this.cleanup.clear();
|
2390
|
-
}
|
2391
|
-
destroy() {
|
2392
|
-
this.listeners.clear();
|
2393
|
-
}
|
2394
|
-
};
|
2395
|
-
_clearTimeout = new WeakMap();
|
2396
|
-
_PointerSensor.configure = configurator(_PointerSensor);
|
2397
|
-
var PointerSensor = _PointerSensor;
|
2398
|
-
function preventDefault(event) {
|
2399
|
-
event.preventDefault();
|
2400
|
-
}
|
2401
|
-
function noop() {
|
2402
|
-
}
|
2403
|
-
var windows = /* @__PURE__ */ new WeakSet();
|
2404
|
-
function patchWindow(window2) {
|
2405
|
-
if (!window2 || windows.has(window2)) {
|
2406
|
-
return;
|
2407
|
-
}
|
2408
|
-
window2.addEventListener("touchmove", noop, {
|
2409
|
-
capture: false,
|
2410
|
-
passive: false
|
2411
|
-
});
|
2412
|
-
windows.add(window2);
|
2413
|
-
}
|
2414
|
-
|
2415
|
-
// lib/dnd/use-sensors.ts
|
2416
|
-
import { isElement as isElement2 } from "@dnd-kit/dom/utilities";
|
1904
|
+
import { PointerSensor } from "@dnd-kit/react";
|
1905
|
+
import { isElement } from "@dnd-kit/dom/utilities";
|
2417
1906
|
var useSensors = ({
|
2418
1907
|
other,
|
2419
1908
|
mouse,
|
@@ -2427,7 +1916,7 @@ var useSensors = ({
|
|
2427
1916
|
activationConstraints(event, source) {
|
2428
1917
|
var _a;
|
2429
1918
|
const { pointerType, target } = event;
|
2430
|
-
if (pointerType === "mouse" &&
|
1919
|
+
if (pointerType === "mouse" && isElement(target) && (source.handle === target || ((_a = source.handle) == null ? void 0 : _a.contains(target)))) {
|
2431
1920
|
return mouse;
|
2432
1921
|
}
|
2433
1922
|
if (pointerType === "touch") {
|
@@ -2597,7 +2086,7 @@ import { Point as Point2 } from "@dnd-kit/geometry";
|
|
2597
2086
|
import { CollisionPriority as CollisionPriority2, CollisionType as CollisionType22 } from "@dnd-kit/abstract";
|
2598
2087
|
import { Point as Point22 } from "@dnd-kit/geometry";
|
2599
2088
|
import { CollisionPriority as CollisionPriority3, CollisionType as CollisionType3 } from "@dnd-kit/abstract";
|
2600
|
-
import { Point as Point3 } from "@dnd-kit/geometry";
|
2089
|
+
import { Point as Point3, Rectangle } from "@dnd-kit/geometry";
|
2601
2090
|
import { CollisionPriority as CollisionPriority4, CollisionType as CollisionType4 } from "@dnd-kit/abstract";
|
2602
2091
|
import { Point as Point4 } from "@dnd-kit/geometry";
|
2603
2092
|
import { CollisionPriority as CollisionPriority5, CollisionType as CollisionType5 } from "@dnd-kit/abstract";
|
@@ -2633,31 +2122,15 @@ var closestCorners = (input) => {
|
|
2633
2122
|
if (!droppable.shape) {
|
2634
2123
|
return null;
|
2635
2124
|
}
|
2636
|
-
const
|
2637
|
-
const
|
2638
|
-
|
2639
|
-
|
2640
|
-
|
2641
|
-
},
|
2642
|
-
{
|
2643
|
-
x: right,
|
2644
|
-
y: top
|
2645
|
-
},
|
2646
|
-
{
|
2647
|
-
x: left,
|
2648
|
-
y: bottom
|
2649
|
-
},
|
2650
|
-
{
|
2651
|
-
x: right,
|
2652
|
-
y: bottom
|
2653
|
-
}
|
2654
|
-
];
|
2655
|
-
const distance = corners.reduce(
|
2656
|
-
(acc, corner) => {
|
2125
|
+
const shapeCorners = shape ? Rectangle.from(shape.current.boundingRectangle).corners : void 0;
|
2126
|
+
const distance = Rectangle.from(
|
2127
|
+
droppable.shape.boundingRectangle
|
2128
|
+
).corners.reduce(
|
2129
|
+
(acc, corner, index) => {
|
2657
2130
|
var _a;
|
2658
2131
|
return acc + Point3.distance(
|
2659
2132
|
Point3.from(corner),
|
2660
|
-
(_a =
|
2133
|
+
(_a = shapeCorners == null ? void 0 : shapeCorners[index]) != null ? _a : position.current
|
2661
2134
|
);
|
2662
2135
|
},
|
2663
2136
|
0
|
@@ -2692,12 +2165,7 @@ var createDynamicCollisionDetector = (dragAxis, midpointOffset = 0.05) => (input
|
|
2692
2165
|
const { center: dragCenter } = dragShape;
|
2693
2166
|
const { fallbackEnabled } = collisionStore.getState();
|
2694
2167
|
const interval = trackMovementInterval(position.current, dragAxis);
|
2695
|
-
|
2696
|
-
direction: interval.direction
|
2697
|
-
});
|
2698
|
-
const collisionMap = dragOperation.data.collisionMap || {};
|
2699
|
-
dragOperation.data.collisionMap = collisionMap;
|
2700
|
-
collisionMap[droppable.id] = {
|
2168
|
+
const data = {
|
2701
2169
|
direction: interval.direction
|
2702
2170
|
};
|
2703
2171
|
const { center: dropCenter } = dropShape;
|
@@ -2712,7 +2180,8 @@ var createDynamicCollisionDetector = (dragAxis, midpointOffset = 0.05) => (input
|
|
2712
2180
|
collisionDebug(dragCenter, dropCenter, droppable.id.toString(), "yellow");
|
2713
2181
|
if (collision) {
|
2714
2182
|
return __spreadProps(__spreadValues({}, collision), {
|
2715
|
-
priority: CollisionPriority7.Highest
|
2183
|
+
priority: CollisionPriority7.Highest,
|
2184
|
+
data
|
2716
2185
|
});
|
2717
2186
|
}
|
2718
2187
|
}
|
@@ -2734,7 +2203,7 @@ var createDynamicCollisionDetector = (dragAxis, midpointOffset = 0.05) => (input
|
|
2734
2203
|
};
|
2735
2204
|
const shouldFlushId = flushNext === droppable.id;
|
2736
2205
|
flushNext = "";
|
2737
|
-
return __spreadProps(__spreadValues({}, collision), { id: shouldFlushId ? "flush" : collision.id });
|
2206
|
+
return __spreadProps(__spreadValues({}, collision), { id: shouldFlushId ? "flush" : collision.id, data });
|
2738
2207
|
}
|
2739
2208
|
if (fallbackEnabled && ((_c = dragOperation.source) == null ? void 0 : _c.id) !== droppable.id) {
|
2740
2209
|
const xAxisIntersection = dropShape.boundingRectangle.right > dragShape.boundingRectangle.left && dropShape.boundingRectangle.left < dragShape.boundingRectangle.right;
|
@@ -2746,9 +2215,7 @@ var createDynamicCollisionDetector = (dragAxis, midpointOffset = 0.05) => (input
|
|
2746
2215
|
x: dragShape.center.x - (((_d = droppable.shape) == null ? void 0 : _d.center.x) || 0),
|
2747
2216
|
y: dragShape.center.y - (((_e = droppable.shape) == null ? void 0 : _e.center.y) || 0)
|
2748
2217
|
});
|
2749
|
-
|
2750
|
-
direction
|
2751
|
-
};
|
2218
|
+
data.direction = direction;
|
2752
2219
|
if (intersectionArea) {
|
2753
2220
|
collisionDebug(
|
2754
2221
|
dragCenter,
|
@@ -2759,7 +2226,8 @@ var createDynamicCollisionDetector = (dragAxis, midpointOffset = 0.05) => (input
|
|
2759
2226
|
);
|
2760
2227
|
flushNext = droppable.id;
|
2761
2228
|
return __spreadProps(__spreadValues({}, fallbackCollision), {
|
2762
|
-
priority: CollisionPriority7.Low
|
2229
|
+
priority: CollisionPriority7.Low,
|
2230
|
+
data
|
2763
2231
|
});
|
2764
2232
|
}
|
2765
2233
|
collisionDebug(
|
@@ -2769,16 +2237,19 @@ var createDynamicCollisionDetector = (dragAxis, midpointOffset = 0.05) => (input
|
|
2769
2237
|
"orange",
|
2770
2238
|
direction || ""
|
2771
2239
|
);
|
2772
|
-
return __spreadProps(__spreadValues({}, fallbackCollision), {
|
2240
|
+
return __spreadProps(__spreadValues({}, fallbackCollision), {
|
2241
|
+
priority: CollisionPriority7.Lowest,
|
2242
|
+
data
|
2243
|
+
});
|
2773
2244
|
}
|
2774
2245
|
}
|
2775
2246
|
}
|
2776
2247
|
collisionDebug(dragCenter, dropCenter, droppable.id.toString(), "hotpink");
|
2777
|
-
delete collisionMap[droppable.id];
|
2778
2248
|
return null;
|
2779
2249
|
};
|
2780
2250
|
|
2781
2251
|
// components/Sortable/index.tsx
|
2252
|
+
import { useSortable } from "@dnd-kit/react/sortable";
|
2782
2253
|
import { jsx as jsx5 } from "react/jsx-runtime";
|
2783
2254
|
var SortableProvider = ({
|
2784
2255
|
children,
|
@@ -2798,16 +2269,16 @@ var SortableProvider = ({
|
|
2798
2269
|
return onDragStart((_b = (_a = event.operation.source) == null ? void 0 : _a.id.toString()) != null ? _b : "");
|
2799
2270
|
},
|
2800
2271
|
onDragOver: (event, manager) => {
|
2801
|
-
var _a
|
2272
|
+
var _a;
|
2802
2273
|
event.preventDefault();
|
2803
2274
|
const { operation } = event;
|
2804
2275
|
const { source, target } = operation;
|
2805
2276
|
if (!source || !target) return;
|
2806
2277
|
let sourceIndex = source.data.index;
|
2807
2278
|
let targetIndex = target.data.index;
|
2808
|
-
const collisionData = (
|
2279
|
+
const collisionData = (_a = manager.collisionObserver.collisions[0]) == null ? void 0 : _a.data;
|
2809
2280
|
if (sourceIndex !== targetIndex && source.id !== target.id) {
|
2810
|
-
const collisionPosition = collisionData.direction === "up" ? "before" : "after";
|
2281
|
+
const collisionPosition = (collisionData == null ? void 0 : collisionData.direction) === "up" ? "before" : "after";
|
2811
2282
|
if (targetIndex >= sourceIndex) {
|
2812
2283
|
targetIndex = targetIndex - 1;
|
2813
2284
|
}
|
@@ -2838,9 +2309,10 @@ var Sortable = ({
|
|
2838
2309
|
}) => {
|
2839
2310
|
const {
|
2840
2311
|
ref: sortableRef,
|
2841
|
-
|
2312
|
+
isDragging,
|
2313
|
+
isDropping,
|
2842
2314
|
handleRef
|
2843
|
-
} =
|
2315
|
+
} = useSortable({
|
2844
2316
|
id,
|
2845
2317
|
type,
|
2846
2318
|
index,
|
@@ -2848,7 +2320,7 @@ var Sortable = ({
|
|
2848
2320
|
data: { index },
|
2849
2321
|
collisionDetector: createDynamicCollisionDetector("y")
|
2850
2322
|
});
|
2851
|
-
return children({
|
2323
|
+
return children({ isDragging, isDropping, ref: sortableRef, handleRef });
|
2852
2324
|
};
|
2853
2325
|
|
2854
2326
|
// components/AutoField/context.tsx
|
@@ -2973,12 +2445,25 @@ var ArrayField = ({
|
|
2973
2445
|
}
|
2974
2446
|
}, []);
|
2975
2447
|
const [draggedItem, setDraggedItem] = useState3("");
|
2976
|
-
const
|
2448
|
+
const isDraggingAny = !!draggedItem;
|
2977
2449
|
const canEdit = useAppStore(
|
2978
2450
|
(s) => s.permissions.getPermissions({ item: s.selectedItem }).edit
|
2979
2451
|
);
|
2980
2452
|
const forceReadOnly = !canEdit;
|
2981
2453
|
const valueRef = useRef(value);
|
2454
|
+
const uniqifyItem = useCallback2(
|
2455
|
+
(val) => {
|
2456
|
+
if (field.type !== "array" || !field.arrayFields) return;
|
2457
|
+
const config = appStore.getState().config;
|
2458
|
+
return walkField({
|
2459
|
+
value: val,
|
2460
|
+
fields: field.arrayFields,
|
2461
|
+
map: (content) => content.map((item) => populateIds(item, config, true)),
|
2462
|
+
config
|
2463
|
+
});
|
2464
|
+
},
|
2465
|
+
[appStore, field]
|
2466
|
+
);
|
2982
2467
|
if (field.type !== "array" || !field.arrayFields) {
|
2983
2468
|
return null;
|
2984
2469
|
}
|
@@ -3038,13 +2523,13 @@ var ArrayField = ({
|
|
3038
2523
|
id: _arrayId,
|
3039
2524
|
index: i,
|
3040
2525
|
disabled: readOnly,
|
3041
|
-
children: ({
|
2526
|
+
children: ({ isDragging, ref, handleRef }) => /* @__PURE__ */ jsxs3(
|
3042
2527
|
"div",
|
3043
2528
|
{
|
3044
2529
|
ref,
|
3045
2530
|
className: getClassNameItem({
|
3046
2531
|
isExpanded: arrayState.openId === _arrayId,
|
3047
|
-
isDragging
|
2532
|
+
isDragging,
|
3048
2533
|
readOnly
|
3049
2534
|
}),
|
3050
2535
|
children: [
|
@@ -3083,11 +2568,10 @@ var ArrayField = ({
|
|
3083
2568
|
onClick: (e) => {
|
3084
2569
|
e.stopPropagation();
|
3085
2570
|
const existingValue = [...value || []];
|
3086
|
-
|
3087
|
-
i,
|
3088
|
-
0,
|
2571
|
+
const newItem = uniqifyItem(
|
3089
2572
|
existingValue[i]
|
3090
2573
|
);
|
2574
|
+
existingValue.splice(i, 0, newItem);
|
3091
2575
|
const newUi = mapArrayStateToUi(
|
3092
2576
|
regenerateArrayState(existingValue)
|
3093
2577
|
);
|
@@ -3185,12 +2669,11 @@ var ArrayField = ({
|
|
3185
2669
|
type: "button",
|
3186
2670
|
className: getClassName5("addButton"),
|
3187
2671
|
onClick: () => {
|
3188
|
-
|
2672
|
+
var _a;
|
2673
|
+
if (isDraggingAny) return;
|
3189
2674
|
const existingValue = value || [];
|
3190
|
-
const
|
3191
|
-
|
3192
|
-
field.defaultItemProps || {}
|
3193
|
-
];
|
2675
|
+
const newItem = uniqifyItem((_a = field.defaultItemProps) != null ? _a : {});
|
2676
|
+
const newValue = [...existingValue, newItem];
|
3194
2677
|
const newArrayState = regenerateArrayState(newValue);
|
3195
2678
|
setUi(mapArrayStateToUi(newArrayState), false);
|
3196
2679
|
onChange(newValue);
|
@@ -4090,6 +3573,10 @@ function AutoFieldInternal(props) {
|
|
4090
3573
|
});
|
4091
3574
|
}
|
4092
3575
|
}, []);
|
3576
|
+
const { visible = true } = props.field;
|
3577
|
+
if (!visible) {
|
3578
|
+
return null;
|
3579
|
+
}
|
4093
3580
|
if (field.type === "slot") {
|
4094
3581
|
return null;
|
4095
3582
|
}
|
@@ -4174,7 +3661,7 @@ init_react_import();
|
|
4174
3661
|
|
4175
3662
|
// css-module:/home/runner/work/puck/puck/packages/core/components/Drawer/styles.module.css#css-module
|
4176
3663
|
init_react_import();
|
4177
|
-
var styles_module_default10 = { "Drawer": "
|
3664
|
+
var styles_module_default10 = { "Drawer": "_Drawer_pl7z0_1", "Drawer-draggable": "_Drawer-draggable_pl7z0_8", "Drawer-draggableBg": "_Drawer-draggableBg_pl7z0_12", "DrawerItem-draggable": "_DrawerItem-draggable_pl7z0_22", "DrawerItem--disabled": "_DrawerItem--disabled_pl7z0_35", "DrawerItem": "_DrawerItem_pl7z0_22", "Drawer--isDraggingFrom": "_Drawer--isDraggingFrom_pl7z0_45", "DrawerItem-name": "_DrawerItem-name_pl7z0_63" };
|
4178
3665
|
|
4179
3666
|
// components/Drawer/index.tsx
|
4180
3667
|
import { useMemo as useMemo11, useState as useState15 } from "react";
|
@@ -4184,11 +3671,11 @@ init_react_import();
|
|
4184
3671
|
import { DragDropProvider as DragDropProvider2 } from "@dnd-kit/react";
|
4185
3672
|
import {
|
4186
3673
|
createContext as createContext4,
|
4187
|
-
useCallback as
|
4188
|
-
useContext as
|
4189
|
-
useEffect as
|
3674
|
+
useCallback as useCallback11,
|
3675
|
+
useContext as useContext8,
|
3676
|
+
useEffect as useEffect17,
|
4190
3677
|
useMemo as useMemo10,
|
4191
|
-
useRef as
|
3678
|
+
useRef as useRef5,
|
4192
3679
|
useState as useState14
|
4193
3680
|
} from "react";
|
4194
3681
|
import { AutoScroller, defaultPreset } from "@dnd-kit/dom";
|
@@ -4198,22 +3685,23 @@ init_react_import();
|
|
4198
3685
|
import {
|
4199
3686
|
forwardRef as forwardRef3,
|
4200
3687
|
memo,
|
4201
|
-
useCallback as
|
4202
|
-
useContext as
|
4203
|
-
useEffect as
|
3688
|
+
useCallback as useCallback10,
|
3689
|
+
useContext as useContext7,
|
3690
|
+
useEffect as useEffect16,
|
4204
3691
|
useMemo as useMemo9,
|
4205
|
-
useRef as
|
3692
|
+
useRef as useRef4
|
4206
3693
|
} from "react";
|
4207
3694
|
|
4208
3695
|
// components/DraggableComponent/index.tsx
|
4209
3696
|
init_react_import();
|
4210
3697
|
import {
|
4211
|
-
useCallback as
|
3698
|
+
useCallback as useCallback7,
|
4212
3699
|
useContext as useContext5,
|
4213
|
-
useEffect as
|
3700
|
+
useEffect as useEffect12,
|
4214
3701
|
useMemo as useMemo7,
|
4215
3702
|
useRef as useRef2,
|
4216
|
-
useState as useState10
|
3703
|
+
useState as useState10,
|
3704
|
+
useTransition
|
4217
3705
|
} from "react";
|
4218
3706
|
|
4219
3707
|
// css-module:/home/runner/work/puck/puck/packages/core/components/DraggableComponent/styles.module.css#css-module
|
@@ -4247,8 +3735,7 @@ init_react_import();
|
|
4247
3735
|
import {
|
4248
3736
|
createContext as createContext3,
|
4249
3737
|
useCallback as useCallback5,
|
4250
|
-
useMemo as useMemo6
|
4251
|
-
useState as useState9
|
3738
|
+
useMemo as useMemo6
|
4252
3739
|
} from "react";
|
4253
3740
|
import { createStore as createStore2 } from "zustand";
|
4254
3741
|
import { Fragment as Fragment5, jsx as jsx19 } from "react/jsx-runtime";
|
@@ -4260,7 +3747,9 @@ var ZoneStoreContext = createContext3(
|
|
4260
3747
|
areaDepthIndex: {},
|
4261
3748
|
nextAreaDepthIndex: {},
|
4262
3749
|
draggedItem: null,
|
4263
|
-
previewIndex: {}
|
3750
|
+
previewIndex: {},
|
3751
|
+
enabledIndex: {},
|
3752
|
+
hoveringComponent: null
|
4264
3753
|
}))
|
4265
3754
|
);
|
4266
3755
|
var ZoneStoreProvider = ({
|
@@ -4273,7 +3762,6 @@ var DropZoneProvider = ({
|
|
4273
3762
|
children,
|
4274
3763
|
value
|
4275
3764
|
}) => {
|
4276
|
-
const [hoveringComponent, setHoveringComponent] = useState9();
|
4277
3765
|
const dispatch = useAppStore((s) => s.dispatch);
|
4278
3766
|
const registerZone = useCallback5(
|
4279
3767
|
(zoneCompound) => {
|
@@ -4295,16 +3783,33 @@ var DropZoneProvider = ({
|
|
4295
3783
|
);
|
4296
3784
|
const memoValue = useMemo6(
|
4297
3785
|
() => __spreadValues({
|
4298
|
-
hoveringComponent,
|
4299
|
-
setHoveringComponent,
|
4300
3786
|
registerZone,
|
4301
3787
|
unregisterZone
|
4302
3788
|
}, value),
|
4303
|
-
[value
|
3789
|
+
[value]
|
4304
3790
|
);
|
4305
3791
|
return /* @__PURE__ */ jsx19(Fragment5, { children: memoValue && /* @__PURE__ */ jsx19(dropZoneContext.Provider, { value: memoValue, children }) });
|
4306
3792
|
};
|
4307
3793
|
|
3794
|
+
// components/DraggableComponent/index.tsx
|
3795
|
+
import { useShallow as useShallow2 } from "zustand/react/shallow";
|
3796
|
+
import { useSortable as useSortable2 } from "@dnd-kit/react/sortable";
|
3797
|
+
|
3798
|
+
// lib/accumulate-transform.ts
|
3799
|
+
init_react_import();
|
3800
|
+
function accumulateTransform(el) {
|
3801
|
+
let matrix = new DOMMatrixReadOnly();
|
3802
|
+
let n = el.parentElement;
|
3803
|
+
while (n && n !== document.documentElement) {
|
3804
|
+
const t = getComputedStyle(n).transform;
|
3805
|
+
if (t && t !== "none") {
|
3806
|
+
matrix = new DOMMatrixReadOnly(t).multiply(matrix);
|
3807
|
+
}
|
3808
|
+
n = n.parentElement;
|
3809
|
+
}
|
3810
|
+
return { scaleX: matrix.a, scaleY: matrix.d };
|
3811
|
+
}
|
3812
|
+
|
4308
3813
|
// lib/use-context-store.ts
|
4309
3814
|
init_react_import();
|
4310
3815
|
import { useContext as useContext4 } from "react";
|
@@ -4318,8 +3823,39 @@ function useContextStore(context, selector) {
|
|
4318
3823
|
return useStore2(store, useShallow(selector));
|
4319
3824
|
}
|
4320
3825
|
|
3826
|
+
// lib/dnd/use-on-drag-finished.ts
|
3827
|
+
init_react_import();
|
3828
|
+
import { useCallback as useCallback6 } from "react";
|
3829
|
+
var useOnDragFinished = (cb, deps = []) => {
|
3830
|
+
const appStore = useAppStoreApi();
|
3831
|
+
return useCallback6(() => {
|
3832
|
+
let dispose = () => {
|
3833
|
+
};
|
3834
|
+
const processDragging = (isDragging2) => {
|
3835
|
+
if (isDragging2) {
|
3836
|
+
cb(false);
|
3837
|
+
} else {
|
3838
|
+
setTimeout(() => {
|
3839
|
+
cb(true);
|
3840
|
+
}, 0);
|
3841
|
+
if (dispose) dispose();
|
3842
|
+
}
|
3843
|
+
};
|
3844
|
+
const isDragging = appStore.getState().state.ui.isDragging;
|
3845
|
+
processDragging(isDragging);
|
3846
|
+
if (isDragging) {
|
3847
|
+
dispose = appStore.subscribe(
|
3848
|
+
(s) => s.state.ui.isDragging,
|
3849
|
+
(isDragging2) => {
|
3850
|
+
processDragging(isDragging2);
|
3851
|
+
}
|
3852
|
+
);
|
3853
|
+
}
|
3854
|
+
return dispose;
|
3855
|
+
}, [appStore, ...deps]);
|
3856
|
+
};
|
3857
|
+
|
4321
3858
|
// components/DraggableComponent/index.tsx
|
4322
|
-
import { useShallow as useShallow2 } from "zustand/react/shallow";
|
4323
3859
|
import { jsx as jsx20, jsxs as jsxs9 } from "react/jsx-runtime";
|
4324
3860
|
var getClassName16 = get_class_name_factory_default("DraggableComponent", styles_module_default11);
|
4325
3861
|
var DEBUG2 = false;
|
@@ -4349,7 +3885,6 @@ var DraggableComponent = ({
|
|
4349
3885
|
isSelected = false,
|
4350
3886
|
debug,
|
4351
3887
|
label,
|
4352
|
-
isEnabled,
|
4353
3888
|
autoDragAxis,
|
4354
3889
|
userDragAxis,
|
4355
3890
|
inDroppableZone = true
|
@@ -4365,7 +3900,7 @@ var DraggableComponent = ({
|
|
4365
3900
|
const iframe = useAppStore((s) => s.iframe);
|
4366
3901
|
const ctx = useContext5(dropZoneContext);
|
4367
3902
|
const [localZones, setLocalZones] = useState10({});
|
4368
|
-
const registerLocalZone =
|
3903
|
+
const registerLocalZone = useCallback7(
|
4369
3904
|
(zoneCompound2, active) => {
|
4370
3905
|
var _a;
|
4371
3906
|
(_a = ctx == null ? void 0 : ctx.registerLocalZone) == null ? void 0 : _a.call(ctx, zoneCompound2, active);
|
@@ -4375,7 +3910,7 @@ var DraggableComponent = ({
|
|
4375
3910
|
},
|
4376
3911
|
[setLocalZones]
|
4377
3912
|
);
|
4378
|
-
const unregisterLocalZone =
|
3913
|
+
const unregisterLocalZone = useCallback7(
|
4379
3914
|
(zoneCompound2) => {
|
4380
3915
|
var _a;
|
4381
3916
|
(_a = ctx == null ? void 0 : ctx.unregisterLocalZone) == null ? void 0 : _a.call(ctx, zoneCompound2);
|
@@ -4398,14 +3933,17 @@ var DraggableComponent = ({
|
|
4398
3933
|
return s.permissions.getPermissions({ item });
|
4399
3934
|
})
|
4400
3935
|
);
|
4401
|
-
const
|
4402
|
-
ZoneStoreContext,
|
4403
|
-
(s) => !!s.draggedItem
|
4404
|
-
);
|
4405
|
-
const canCollide = permissions.drag || userIsDragging;
|
4406
|
-
const disabled = !isEnabled || !canCollide;
|
3936
|
+
const zoneStore = useContext5(ZoneStoreContext);
|
4407
3937
|
const [dragAxis, setDragAxis] = useState10(userDragAxis || autoDragAxis);
|
4408
|
-
const
|
3938
|
+
const dynamicCollisionDetector = useMemo7(
|
3939
|
+
() => createDynamicCollisionDetector(dragAxis),
|
3940
|
+
[dragAxis]
|
3941
|
+
);
|
3942
|
+
const {
|
3943
|
+
ref: sortableRef,
|
3944
|
+
isDragging: thisIsDragging,
|
3945
|
+
sortable
|
3946
|
+
} = useSortable2({
|
4409
3947
|
id,
|
4410
3948
|
index,
|
4411
3949
|
group: zoneCompound,
|
@@ -4420,18 +3958,34 @@ var DraggableComponent = ({
|
|
4420
3958
|
path: path || [],
|
4421
3959
|
inDroppableZone
|
4422
3960
|
},
|
4423
|
-
collisionPriority:
|
4424
|
-
collisionDetector:
|
4425
|
-
disabled,
|
3961
|
+
collisionPriority: depth,
|
3962
|
+
collisionDetector: dynamicCollisionDetector,
|
4426
3963
|
// "Out of the way" transition from react-beautiful-dnd
|
4427
3964
|
transition: {
|
4428
3965
|
duration: 200,
|
4429
3966
|
easing: "cubic-bezier(0.2, 0, 0, 1)"
|
4430
|
-
}
|
3967
|
+
},
|
3968
|
+
feedback: "clone"
|
4431
3969
|
});
|
4432
|
-
|
3970
|
+
useEffect12(() => {
|
3971
|
+
const isEnabled = zoneStore.getState().enabledIndex[zoneCompound];
|
3972
|
+
sortable.droppable.disabled = !isEnabled;
|
3973
|
+
sortable.draggable.disabled = !permissions.drag;
|
3974
|
+
const cleanup = zoneStore.subscribe((s) => {
|
3975
|
+
sortable.droppable.disabled = !s.enabledIndex[zoneCompound];
|
3976
|
+
});
|
3977
|
+
if (ref.current && !permissions.drag) {
|
3978
|
+
ref.current.setAttribute("data-puck-disabled", "");
|
3979
|
+
return () => {
|
3980
|
+
var _a;
|
3981
|
+
(_a = ref.current) == null ? void 0 : _a.removeAttribute("data-puck-disabled");
|
3982
|
+
cleanup();
|
3983
|
+
};
|
3984
|
+
}
|
3985
|
+
return cleanup;
|
3986
|
+
}, [permissions.drag, zoneCompound]);
|
4433
3987
|
const ref = useRef2(null);
|
4434
|
-
const refSetter =
|
3988
|
+
const refSetter = useCallback7(
|
4435
3989
|
(el) => {
|
4436
3990
|
sortableRef(el);
|
4437
3991
|
if (el) {
|
@@ -4441,13 +3995,13 @@ var DraggableComponent = ({
|
|
4441
3995
|
[sortableRef]
|
4442
3996
|
);
|
4443
3997
|
const [portalEl, setPortalEl] = useState10();
|
4444
|
-
|
3998
|
+
useEffect12(() => {
|
4445
3999
|
var _a, _b, _c;
|
4446
4000
|
setPortalEl(
|
4447
4001
|
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
|
4448
4002
|
);
|
4449
4003
|
}, [iframe.enabled, ref.current]);
|
4450
|
-
const getStyle =
|
4004
|
+
const getStyle = useCallback7(() => {
|
4451
4005
|
var _a, _b, _c;
|
4452
4006
|
if (!ref.current) return;
|
4453
4007
|
const rect = ref.current.getBoundingClientRect();
|
@@ -4459,40 +4013,61 @@ var DraggableComponent = ({
|
|
4459
4013
|
x: deepScrollPosition.x - portalScroll.x - ((_b = portalContainerRect == null ? void 0 : portalContainerRect.left) != null ? _b : 0),
|
4460
4014
|
y: deepScrollPosition.y - portalScroll.y - ((_c = portalContainerRect == null ? void 0 : portalContainerRect.top) != null ? _c : 0)
|
4461
4015
|
};
|
4016
|
+
const untransformed = {
|
4017
|
+
height: ref.current.offsetHeight,
|
4018
|
+
width: ref.current.offsetWidth
|
4019
|
+
};
|
4020
|
+
const transform = accumulateTransform(ref.current);
|
4462
4021
|
const style2 = {
|
4463
|
-
left: `${rect.left + scroll.x}px`,
|
4464
|
-
top: `${rect.top + scroll.y}px`,
|
4465
|
-
height: `${
|
4466
|
-
width: `${
|
4022
|
+
left: `${(rect.left + scroll.x) / transform.scaleX}px`,
|
4023
|
+
top: `${(rect.top + scroll.y) / transform.scaleY}px`,
|
4024
|
+
height: `${untransformed.height}px`,
|
4025
|
+
width: `${untransformed.width}px`
|
4467
4026
|
};
|
4468
4027
|
return style2;
|
4469
4028
|
}, [ref.current]);
|
4470
4029
|
const [style, setStyle] = useState10();
|
4471
|
-
const sync =
|
4030
|
+
const sync = useCallback7(() => {
|
4472
4031
|
setStyle(getStyle());
|
4473
4032
|
}, [ref.current, iframe]);
|
4474
|
-
|
4475
|
-
if (ref.current
|
4033
|
+
useEffect12(() => {
|
4034
|
+
if (ref.current) {
|
4476
4035
|
const observer = new ResizeObserver(sync);
|
4477
4036
|
observer.observe(ref.current);
|
4478
4037
|
return () => {
|
4479
4038
|
observer.disconnect();
|
4480
4039
|
};
|
4481
4040
|
}
|
4482
|
-
}, [ref.current
|
4041
|
+
}, [ref.current]);
|
4483
4042
|
const registerNode = useAppStore((s) => s.nodes.registerNode);
|
4484
|
-
|
4043
|
+
const hideOverlay = useCallback7(() => {
|
4044
|
+
setIsVisible(false);
|
4045
|
+
}, []);
|
4046
|
+
const showOverlay = useCallback7(() => {
|
4047
|
+
setIsVisible(true);
|
4048
|
+
}, []);
|
4049
|
+
useEffect12(() => {
|
4485
4050
|
var _a;
|
4486
|
-
registerNode(id, {
|
4051
|
+
registerNode(id, {
|
4052
|
+
methods: { sync, showOverlay, hideOverlay },
|
4053
|
+
element: (_a = ref.current) != null ? _a : null
|
4054
|
+
});
|
4487
4055
|
return () => {
|
4488
|
-
registerNode(id, {
|
4056
|
+
registerNode(id, {
|
4057
|
+
methods: {
|
4058
|
+
sync: () => null,
|
4059
|
+
hideOverlay: () => null,
|
4060
|
+
showOverlay: () => null
|
4061
|
+
},
|
4062
|
+
element: null
|
4063
|
+
});
|
4489
4064
|
};
|
4490
4065
|
}, [id, zoneCompound, index, componentType, sync]);
|
4491
4066
|
const CustomActionBar = useMemo7(
|
4492
4067
|
() => overrides.actionBar || DefaultActionBar,
|
4493
4068
|
[overrides.actionBar]
|
4494
4069
|
);
|
4495
|
-
const onClick =
|
4070
|
+
const onClick = useCallback7(
|
4496
4071
|
(e) => {
|
4497
4072
|
e.stopPropagation();
|
4498
4073
|
dispatch({
|
@@ -4505,7 +4080,7 @@ var DraggableComponent = ({
|
|
4505
4080
|
[index, zoneCompound, id]
|
4506
4081
|
);
|
4507
4082
|
const appStore = useAppStoreApi();
|
4508
|
-
const onSelectParent =
|
4083
|
+
const onSelectParent = useCallback7(() => {
|
4509
4084
|
const { nodes, zones } = appStore.getState().state.indexes;
|
4510
4085
|
const node = nodes[id];
|
4511
4086
|
const parentNode = (node == null ? void 0 : node.parentId) ? nodes[node == null ? void 0 : node.parentId] : null;
|
@@ -4526,14 +4101,14 @@ var DraggableComponent = ({
|
|
4526
4101
|
}
|
4527
4102
|
});
|
4528
4103
|
}, [ctx, path]);
|
4529
|
-
const onDuplicate =
|
4104
|
+
const onDuplicate = useCallback7(() => {
|
4530
4105
|
dispatch({
|
4531
4106
|
type: "duplicate",
|
4532
4107
|
sourceIndex: index,
|
4533
4108
|
sourceZone: zoneCompound
|
4534
4109
|
});
|
4535
4110
|
}, [index, zoneCompound]);
|
4536
|
-
const onDelete =
|
4111
|
+
const onDelete = useCallback7(() => {
|
4537
4112
|
dispatch({
|
4538
4113
|
type: "remove",
|
4539
4114
|
index,
|
@@ -4541,13 +4116,17 @@ var DraggableComponent = ({
|
|
4541
4116
|
});
|
4542
4117
|
}, [index, zoneCompound]);
|
4543
4118
|
const [hover, setHover] = useState10(false);
|
4544
|
-
const indicativeHover = (
|
4545
|
-
|
4119
|
+
const indicativeHover = useContextStore(
|
4120
|
+
ZoneStoreContext,
|
4121
|
+
(s) => s.hoveringComponent === id
|
4122
|
+
);
|
4123
|
+
useEffect12(() => {
|
4546
4124
|
if (!ref.current) {
|
4547
4125
|
return;
|
4548
4126
|
}
|
4549
4127
|
const el = ref.current;
|
4550
4128
|
const _onMouseOver = (e) => {
|
4129
|
+
const userIsDragging = !!zoneStore.getState().draggedItem;
|
4551
4130
|
if (userIsDragging) {
|
4552
4131
|
if (thisIsDragging) {
|
4553
4132
|
setHover(true);
|
@@ -4569,18 +4148,12 @@ var DraggableComponent = ({
|
|
4569
4148
|
el.addEventListener("click", onClick);
|
4570
4149
|
el.addEventListener("mouseover", _onMouseOver);
|
4571
4150
|
el.addEventListener("mouseout", _onMouseOut);
|
4572
|
-
if (thisIsDragging) {
|
4573
|
-
el.setAttribute("data-puck-dragging", "");
|
4574
|
-
} else {
|
4575
|
-
el.removeAttribute("data-puck-dragging");
|
4576
|
-
}
|
4577
4151
|
return () => {
|
4578
4152
|
el.removeAttribute("data-puck-component");
|
4579
4153
|
el.removeAttribute("data-puck-dnd");
|
4580
4154
|
el.removeEventListener("click", onClick);
|
4581
4155
|
el.removeEventListener("mouseover", _onMouseOver);
|
4582
4156
|
el.removeEventListener("mouseout", _onMouseOut);
|
4583
|
-
el.removeAttribute("data-puck-dragging");
|
4584
4157
|
};
|
4585
4158
|
}, [
|
4586
4159
|
ref,
|
@@ -4588,29 +4161,43 @@ var DraggableComponent = ({
|
|
4588
4161
|
containsActiveZone,
|
4589
4162
|
zoneCompound,
|
4590
4163
|
id,
|
4591
|
-
userIsDragging,
|
4592
4164
|
thisIsDragging,
|
4593
4165
|
inDroppableZone
|
4594
4166
|
]);
|
4595
|
-
useEffect11(() => {
|
4596
|
-
if (ref.current && disabled) {
|
4597
|
-
ref.current.setAttribute("data-puck-disabled", "");
|
4598
|
-
return () => {
|
4599
|
-
var _a;
|
4600
|
-
(_a = ref.current) == null ? void 0 : _a.removeAttribute("data-puck-disabled");
|
4601
|
-
};
|
4602
|
-
}
|
4603
|
-
}, [disabled, ref]);
|
4604
4167
|
const [isVisible, setIsVisible] = useState10(false);
|
4605
|
-
|
4606
|
-
|
4607
|
-
|
4608
|
-
|
4168
|
+
const [dragFinished, setDragFinished] = useState10(true);
|
4169
|
+
const [_, startTransition] = useTransition();
|
4170
|
+
useEffect12(() => {
|
4171
|
+
startTransition(() => {
|
4172
|
+
if (hover || indicativeHover || isSelected) {
|
4173
|
+
sync();
|
4174
|
+
setIsVisible(true);
|
4175
|
+
setThisWasDragging(false);
|
4176
|
+
} else {
|
4177
|
+
setIsVisible(false);
|
4178
|
+
}
|
4179
|
+
});
|
4180
|
+
}, [hover, indicativeHover, isSelected, iframe]);
|
4181
|
+
const [thisWasDragging, setThisWasDragging] = useState10(false);
|
4182
|
+
const onDragFinished = useOnDragFinished((finished) => {
|
4183
|
+
if (finished) {
|
4184
|
+
startTransition(() => {
|
4185
|
+
sync();
|
4186
|
+
setDragFinished(true);
|
4187
|
+
});
|
4609
4188
|
} else {
|
4610
|
-
|
4189
|
+
setDragFinished(false);
|
4190
|
+
}
|
4191
|
+
});
|
4192
|
+
useEffect12(() => {
|
4193
|
+
if (thisIsDragging) {
|
4194
|
+
setThisWasDragging(true);
|
4611
4195
|
}
|
4612
|
-
}, [
|
4613
|
-
|
4196
|
+
}, [thisIsDragging]);
|
4197
|
+
useEffect12(() => {
|
4198
|
+
if (thisWasDragging) return onDragFinished();
|
4199
|
+
}, [thisWasDragging, onDragFinished]);
|
4200
|
+
const syncActionsPosition = useCallback7(
|
4614
4201
|
(el) => {
|
4615
4202
|
if (el) {
|
4616
4203
|
const view = el.ownerDocument.defaultView;
|
@@ -4635,7 +4222,7 @@ var DraggableComponent = ({
|
|
4635
4222
|
},
|
4636
4223
|
[zoom]
|
4637
4224
|
);
|
4638
|
-
|
4225
|
+
useEffect12(() => {
|
4639
4226
|
if (userDragAxis) {
|
4640
4227
|
setDragAxis(userDragAxis);
|
4641
4228
|
return;
|
@@ -4649,7 +4236,10 @@ var DraggableComponent = ({
|
|
4649
4236
|
}
|
4650
4237
|
setDragAxis(autoDragAxis);
|
4651
4238
|
}, [ref, userDragAxis, autoDragAxis]);
|
4652
|
-
const parentAction = (
|
4239
|
+
const parentAction = useMemo7(
|
4240
|
+
() => (ctx == null ? void 0 : ctx.areaId) && (ctx == null ? void 0 : ctx.areaId) !== "root" && /* @__PURE__ */ jsx20(ActionBar.Action, { onClick: onSelectParent, label: "Select parent", children: /* @__PURE__ */ jsx20(CornerLeftUp, { size: 16 }) }),
|
4241
|
+
[ctx == null ? void 0 : ctx.areaId]
|
4242
|
+
);
|
4653
4243
|
const nextContextValue = useMemo7(
|
4654
4244
|
() => __spreadProps(__spreadValues({}, ctx), {
|
4655
4245
|
areaId: id,
|
@@ -4670,7 +4260,7 @@ var DraggableComponent = ({
|
|
4670
4260
|
]
|
4671
4261
|
);
|
4672
4262
|
return /* @__PURE__ */ jsxs9(DropZoneProvider, { value: nextContextValue, children: [
|
4673
|
-
isVisible && createPortal2(
|
4263
|
+
dragFinished && isVisible && createPortal2(
|
4674
4264
|
/* @__PURE__ */ jsxs9(
|
4675
4265
|
"div",
|
4676
4266
|
{
|
@@ -4730,11 +4320,15 @@ var DraggableComponent = ({
|
|
4730
4320
|
|
4731
4321
|
// css-module:/home/runner/work/puck/puck/packages/core/components/DropZone/styles.module.css#css-module
|
4732
4322
|
init_react_import();
|
4733
|
-
var styles_module_default12 = { "DropZone": "
|
4323
|
+
var styles_module_default12 = { "DropZone": "_DropZone_1i2sv_1", "DropZone--hasChildren": "_DropZone--hasChildren_1i2sv_11", "DropZone--isAreaSelected": "_DropZone--isAreaSelected_1i2sv_24", "DropZone--hoveringOverArea": "_DropZone--hoveringOverArea_1i2sv_25", "DropZone--isRootZone": "_DropZone--isRootZone_1i2sv_25", "DropZone--isDestination": "_DropZone--isDestination_1i2sv_35", "DropZone-item": "_DropZone-item_1i2sv_47", "DropZone-hitbox": "_DropZone-hitbox_1i2sv_51", "DropZone--isEnabled": "_DropZone--isEnabled_1i2sv_59", "DropZone--isAnimating": "_DropZone--isAnimating_1i2sv_68" };
|
4324
|
+
|
4325
|
+
// components/DropZone/index.tsx
|
4326
|
+
import { useDroppable } from "@dnd-kit/react";
|
4734
4327
|
|
4735
4328
|
// components/DropZone/lib/use-min-empty-height.ts
|
4736
4329
|
init_react_import();
|
4737
|
-
import { useEffect as
|
4330
|
+
import { useEffect as useEffect13, useRef as useRef3, useState as useState11 } from "react";
|
4331
|
+
var getNumItems = (appStore, zoneCompound) => appStore.getState().state.indexes.zones[zoneCompound].contentIds.length;
|
4738
4332
|
var useMinEmptyHeight = ({
|
4739
4333
|
zoneCompound,
|
4740
4334
|
userMinEmptyHeight,
|
@@ -4750,32 +4344,52 @@ var useMinEmptyHeight = ({
|
|
4750
4344
|
isZone: ((_b = s.draggedItem) == null ? void 0 : _b.data.zone) === zoneCompound
|
4751
4345
|
};
|
4752
4346
|
});
|
4753
|
-
|
4347
|
+
const numItems = useRef3(0);
|
4348
|
+
const onDragFinished = useOnDragFinished(
|
4349
|
+
(finished) => {
|
4350
|
+
var _a;
|
4351
|
+
if (finished) {
|
4352
|
+
const newNumItems = getNumItems(appStore, zoneCompound);
|
4353
|
+
setPrevHeight(0);
|
4354
|
+
if (newNumItems || numItems.current === 0) {
|
4355
|
+
setIsAnimating(false);
|
4356
|
+
return;
|
4357
|
+
}
|
4358
|
+
const selectedItem = appStore.getState().selectedItem;
|
4359
|
+
const zones = appStore.getState().state.indexes.zones;
|
4360
|
+
const nodes = appStore.getState().nodes;
|
4361
|
+
(_a = nodes.nodes[selectedItem == null ? void 0 : selectedItem.props.id]) == null ? void 0 : _a.methods.hideOverlay();
|
4362
|
+
setTimeout(() => {
|
4363
|
+
var _a2;
|
4364
|
+
const contentIds = ((_a2 = zones[zoneCompound]) == null ? void 0 : _a2.contentIds) || [];
|
4365
|
+
contentIds.forEach((contentId) => {
|
4366
|
+
const node = nodes.nodes[contentId];
|
4367
|
+
node == null ? void 0 : node.methods.sync();
|
4368
|
+
});
|
4369
|
+
if (selectedItem) {
|
4370
|
+
setTimeout(() => {
|
4371
|
+
var _a3, _b;
|
4372
|
+
(_a3 = nodes.nodes[selectedItem.props.id]) == null ? void 0 : _a3.methods.sync();
|
4373
|
+
(_b = nodes.nodes[selectedItem.props.id]) == null ? void 0 : _b.methods.showOverlay();
|
4374
|
+
}, 200);
|
4375
|
+
}
|
4376
|
+
setIsAnimating(false);
|
4377
|
+
}, 100);
|
4378
|
+
}
|
4379
|
+
},
|
4380
|
+
[appStore, prevHeight, zoneCompound]
|
4381
|
+
);
|
4382
|
+
useEffect13(() => {
|
4754
4383
|
if (draggedItem && ref.current) {
|
4755
4384
|
if (isZone) {
|
4756
4385
|
const rect = ref.current.getBoundingClientRect();
|
4386
|
+
numItems.current = getNumItems(appStore, zoneCompound);
|
4757
4387
|
setPrevHeight(rect.height);
|
4758
4388
|
setIsAnimating(true);
|
4759
|
-
return;
|
4389
|
+
return onDragFinished();
|
4760
4390
|
}
|
4761
4391
|
}
|
4762
|
-
|
4763
|
-
setTimeout(() => {
|
4764
|
-
var _a, _b;
|
4765
|
-
const zones = appStore.getState().state.indexes.zones;
|
4766
|
-
const nodes = appStore.getState().nodes;
|
4767
|
-
const selectedItem = appStore.getState().selectedItem;
|
4768
|
-
const contentIds = ((_a = zones[zoneCompound]) == null ? void 0 : _a.contentIds) || [];
|
4769
|
-
contentIds.forEach((contentId) => {
|
4770
|
-
const node = nodes.nodes[contentId];
|
4771
|
-
node == null ? void 0 : node.methods.sync();
|
4772
|
-
});
|
4773
|
-
if (selectedItem) {
|
4774
|
-
(_b = nodes.nodes[selectedItem.props.id]) == null ? void 0 : _b.methods.sync();
|
4775
|
-
}
|
4776
|
-
setIsAnimating(false);
|
4777
|
-
}, 400);
|
4778
|
-
}, [ref.current, draggedItem, zoneCompound]);
|
4392
|
+
}, [ref.current, draggedItem, onDragFinished]);
|
4779
4393
|
return [prevHeight || userMinEmptyHeight, isAnimating];
|
4780
4394
|
};
|
4781
4395
|
|
@@ -4796,15 +4410,15 @@ function assignRefs(refs, node) {
|
|
4796
4410
|
|
4797
4411
|
// components/DropZone/lib/use-content-with-preview.ts
|
4798
4412
|
init_react_import();
|
4799
|
-
import { useEffect as
|
4413
|
+
import { useContext as useContext6, useEffect as useEffect14, useState as useState12 } from "react";
|
4800
4414
|
|
4801
4415
|
// lib/dnd/use-rendered-callback.ts
|
4802
4416
|
init_react_import();
|
4803
4417
|
import { useDragDropManager } from "@dnd-kit/react";
|
4804
|
-
import { useCallback as
|
4418
|
+
import { useCallback as useCallback8 } from "react";
|
4805
4419
|
function useRenderedCallback(callback, deps) {
|
4806
4420
|
const manager = useDragDropManager();
|
4807
|
-
return
|
4421
|
+
return useCallback8(
|
4808
4422
|
(...args) => __async(this, null, function* () {
|
4809
4423
|
yield manager == null ? void 0 : manager.renderer.rendering;
|
4810
4424
|
return callback(...args);
|
@@ -4815,16 +4429,10 @@ function useRenderedCallback(callback, deps) {
|
|
4815
4429
|
|
4816
4430
|
// components/DropZone/lib/use-content-with-preview.ts
|
4817
4431
|
var useContentIdsWithPreview = (contentIds, zoneCompound) => {
|
4818
|
-
const
|
4432
|
+
const zoneStore = useContext6(ZoneStoreContext);
|
4433
|
+
const preview = useContextStore(
|
4819
4434
|
ZoneStoreContext,
|
4820
|
-
(s) =>
|
4821
|
-
var _a;
|
4822
|
-
return {
|
4823
|
-
draggedItemId: (_a = s.draggedItem) == null ? void 0 : _a.id,
|
4824
|
-
preview: s.previewIndex[zoneCompound],
|
4825
|
-
previewExists: Object.keys(s.previewIndex || {}).length > 0
|
4826
|
-
};
|
4827
|
-
}
|
4435
|
+
(s) => s.previewIndex[zoneCompound]
|
4828
4436
|
);
|
4829
4437
|
const isDragging = useAppStore((s) => s.state.ui.isDragging);
|
4830
4438
|
const [contentIdsWithPreview, setContentIdsWithPreview] = useState12(contentIds);
|
@@ -4832,10 +4440,10 @@ var useContentIdsWithPreview = (contentIds, zoneCompound) => {
|
|
4832
4440
|
preview
|
4833
4441
|
);
|
4834
4442
|
const updateContent = useRenderedCallback(
|
4835
|
-
(contentIds2, preview2
|
4836
|
-
|
4837
|
-
|
4838
|
-
|
4443
|
+
(contentIds2, preview2) => {
|
4444
|
+
var _a;
|
4445
|
+
const s = zoneStore.getState();
|
4446
|
+
const draggedItemId = (_a = s.draggedItem) == null ? void 0 : _a.id;
|
4839
4447
|
if (preview2) {
|
4840
4448
|
if (preview2.type === "insert") {
|
4841
4449
|
setContentIdsWithPreview(
|
@@ -4856,14 +4464,14 @@ var useContentIdsWithPreview = (contentIds, zoneCompound) => {
|
|
4856
4464
|
}
|
4857
4465
|
} else {
|
4858
4466
|
setContentIdsWithPreview(
|
4859
|
-
|
4467
|
+
contentIds2.filter((id) => id !== draggedItemId)
|
4860
4468
|
);
|
4861
4469
|
}
|
4862
4470
|
setLocalPreview(preview2);
|
4863
4471
|
},
|
4864
|
-
[
|
4472
|
+
[]
|
4865
4473
|
);
|
4866
|
-
|
4474
|
+
useEffect14(() => {
|
4867
4475
|
updateContent(contentIds, preview, isDragging);
|
4868
4476
|
}, [contentIds, preview, isDragging]);
|
4869
4477
|
return [contentIdsWithPreview, localPreview];
|
@@ -4871,7 +4479,7 @@ var useContentIdsWithPreview = (contentIds, zoneCompound) => {
|
|
4871
4479
|
|
4872
4480
|
// components/DropZone/lib/use-drag-axis.ts
|
4873
4481
|
init_react_import();
|
4874
|
-
import { useCallback as
|
4482
|
+
import { useCallback as useCallback9, useEffect as useEffect15, useState as useState13 } from "react";
|
4875
4483
|
var GRID_DRAG_AXIS = "dynamic";
|
4876
4484
|
var FLEX_ROW_DRAG_AXIS = "x";
|
4877
4485
|
var DEFAULT_DRAG_AXIS = "y";
|
@@ -4880,7 +4488,7 @@ var useDragAxis = (ref, collisionAxis) => {
|
|
4880
4488
|
const [dragAxis, setDragAxis] = useState13(
|
4881
4489
|
collisionAxis || DEFAULT_DRAG_AXIS
|
4882
4490
|
);
|
4883
|
-
const calculateDragAxis =
|
4491
|
+
const calculateDragAxis = useCallback9(() => {
|
4884
4492
|
if (ref.current) {
|
4885
4493
|
const computedStyle = window.getComputedStyle(ref.current);
|
4886
4494
|
if (computedStyle.display === "grid") {
|
@@ -4892,7 +4500,7 @@ var useDragAxis = (ref, collisionAxis) => {
|
|
4892
4500
|
}
|
4893
4501
|
}
|
4894
4502
|
}, [ref.current]);
|
4895
|
-
|
4503
|
+
useEffect15(() => {
|
4896
4504
|
const onViewportChange = () => {
|
4897
4505
|
calculateDragAxis();
|
4898
4506
|
};
|
@@ -4901,12 +4509,12 @@ var useDragAxis = (ref, collisionAxis) => {
|
|
4901
4509
|
window.removeEventListener("viewportchange", onViewportChange);
|
4902
4510
|
};
|
4903
4511
|
}, []);
|
4904
|
-
|
4512
|
+
useEffect15(calculateDragAxis, [status, collisionAxis]);
|
4905
4513
|
return [dragAxis, calculateDragAxis];
|
4906
4514
|
};
|
4907
4515
|
|
4908
4516
|
// components/DropZone/index.tsx
|
4909
|
-
import { useShallow as
|
4517
|
+
import { useShallow as useShallow4 } from "zustand/react/shallow";
|
4910
4518
|
|
4911
4519
|
// components/Render/index.tsx
|
4912
4520
|
init_react_import();
|
@@ -4914,6 +4522,7 @@ import React3, { useMemo as useMemo8 } from "react";
|
|
4914
4522
|
|
4915
4523
|
// components/SlotRender/index.tsx
|
4916
4524
|
init_react_import();
|
4525
|
+
import { useShallow as useShallow3 } from "zustand/react/shallow";
|
4917
4526
|
import { jsx as jsx21 } from "react/jsx-runtime";
|
4918
4527
|
var ContextSlotRender = ({
|
4919
4528
|
componentId,
|
@@ -4922,10 +4531,12 @@ var ContextSlotRender = ({
|
|
4922
4531
|
const config = useAppStore((s) => s.config);
|
4923
4532
|
const metadata = useAppStore((s) => s.metadata);
|
4924
4533
|
const slotContent = useAppStore(
|
4925
|
-
(s) => {
|
4534
|
+
useShallow3((s) => {
|
4926
4535
|
var _a, _b;
|
4927
|
-
|
4928
|
-
|
4536
|
+
const indexes = s.state.indexes;
|
4537
|
+
const contentIds = (_b = (_a = indexes.zones[`${componentId}:${zone}`]) == null ? void 0 : _a.contentIds) != null ? _b : [];
|
4538
|
+
return contentIds.map((contentId) => indexes.nodes[contentId].flatData);
|
4539
|
+
})
|
4929
4540
|
);
|
4930
4541
|
return /* @__PURE__ */ jsx21(
|
4931
4542
|
SlotRenderPure,
|
@@ -4955,7 +4566,7 @@ function Render({
|
|
4955
4566
|
root: data.root || {},
|
4956
4567
|
content: data.content || []
|
4957
4568
|
});
|
4958
|
-
const rootProps = defaultedData.root.props
|
4569
|
+
const rootProps = "props" in defaultedData.root ? defaultedData.root.props : defaultedData.root;
|
4959
4570
|
const title = (rootProps == null ? void 0 : rootProps.title) || "";
|
4960
4571
|
const pageProps = __spreadProps(__spreadValues({}, rootProps), {
|
4961
4572
|
puck: {
|
@@ -4968,7 +4579,11 @@ function Render({
|
|
4968
4579
|
editMode: false,
|
4969
4580
|
id: "puck-root"
|
4970
4581
|
});
|
4971
|
-
const propsWithSlots = useSlots(
|
4582
|
+
const propsWithSlots = useSlots(
|
4583
|
+
config,
|
4584
|
+
{ type: "root", props: pageProps },
|
4585
|
+
(props) => /* @__PURE__ */ jsx22(SlotRender, __spreadProps(__spreadValues({}, props), { config, metadata }))
|
4586
|
+
);
|
4972
4587
|
const nextContextValue = useMemo8(
|
4973
4588
|
() => ({
|
4974
4589
|
mode: "render",
|
@@ -4991,19 +4606,18 @@ var DropZoneEditPure = (props) => /* @__PURE__ */ jsx23(DropZoneEdit, __spreadVa
|
|
4991
4606
|
var DropZoneChild = ({
|
4992
4607
|
zoneCompound,
|
4993
4608
|
componentId,
|
4994
|
-
preview,
|
4995
4609
|
index,
|
4996
|
-
isEnabled,
|
4997
4610
|
dragAxis,
|
4998
4611
|
collisionAxis,
|
4999
4612
|
inDroppableZone
|
5000
4613
|
}) => {
|
5001
4614
|
var _a, _b;
|
5002
4615
|
const metadata = useAppStore((s) => s.metadata);
|
5003
|
-
const ctx =
|
4616
|
+
const ctx = useContext7(dropZoneContext);
|
5004
4617
|
const { depth = 1 } = ctx != null ? ctx : {};
|
4618
|
+
const zoneStore = useContext7(ZoneStoreContext);
|
5005
4619
|
const nodeProps = useAppStore(
|
5006
|
-
|
4620
|
+
useShallow4((s) => {
|
5007
4621
|
var _a2;
|
5008
4622
|
return (_a2 = s.state.indexes.nodes[componentId]) == null ? void 0 : _a2.flatData.props;
|
5009
4623
|
})
|
@@ -5015,22 +4629,42 @@ var DropZoneChild = ({
|
|
5015
4629
|
}
|
5016
4630
|
);
|
5017
4631
|
const nodeReadOnly = useAppStore(
|
5018
|
-
|
4632
|
+
useShallow4((s) => {
|
5019
4633
|
var _a2;
|
5020
4634
|
return (_a2 = s.state.indexes.nodes[componentId]) == null ? void 0 : _a2.data.readOnly;
|
5021
4635
|
})
|
5022
4636
|
);
|
5023
|
-
const
|
5024
|
-
const item =
|
4637
|
+
const appStore = useAppStoreApi();
|
4638
|
+
const item = useMemo9(() => {
|
4639
|
+
if (nodeProps) {
|
4640
|
+
const expanded = expandNode({
|
4641
|
+
type: nodeType,
|
4642
|
+
props: nodeProps
|
4643
|
+
});
|
4644
|
+
return expanded;
|
4645
|
+
}
|
4646
|
+
const preview = zoneStore.getState().previewIndex[zoneCompound];
|
4647
|
+
if (componentId === (preview == null ? void 0 : preview.props.id)) {
|
4648
|
+
return {
|
4649
|
+
type: preview.componentType,
|
4650
|
+
props: preview.props,
|
4651
|
+
previewType: preview.type
|
4652
|
+
};
|
4653
|
+
}
|
4654
|
+
return null;
|
4655
|
+
}, [appStore, componentId, zoneCompound, nodeType, nodeProps]);
|
5025
4656
|
const componentConfig = useAppStore(
|
5026
4657
|
(s) => (item == null ? void 0 : item.type) ? s.config.components[item.type] : null
|
5027
4658
|
);
|
5028
|
-
const puckProps =
|
5029
|
-
|
5030
|
-
|
5031
|
-
|
5032
|
-
|
5033
|
-
|
4659
|
+
const puckProps = useMemo9(
|
4660
|
+
() => ({
|
4661
|
+
renderDropZone: DropZoneEditPure,
|
4662
|
+
isEditing: true,
|
4663
|
+
dragRef: null,
|
4664
|
+
metadata: __spreadValues(__spreadValues({}, metadata), componentConfig == null ? void 0 : componentConfig.metadata)
|
4665
|
+
}),
|
4666
|
+
[metadata, componentConfig == null ? void 0 : componentConfig.metadata]
|
4667
|
+
);
|
5034
4668
|
const overrides = useAppStore((s) => s.overrides);
|
5035
4669
|
const isLoading = useAppStore(
|
5036
4670
|
(s) => {
|
@@ -5046,7 +4680,7 @@ var DropZoneChild = ({
|
|
5046
4680
|
);
|
5047
4681
|
let label = (_b = (_a = componentConfig == null ? void 0 : componentConfig.label) != null ? _a : item == null ? void 0 : item.type.toString()) != null ? _b : "Component";
|
5048
4682
|
const renderPreview = useMemo9(
|
5049
|
-
() => function
|
4683
|
+
() => function Preview3() {
|
5050
4684
|
return /* @__PURE__ */ jsx23(DrawerItemInner, { name: label, children: overrides.componentItem });
|
5051
4685
|
},
|
5052
4686
|
[componentId, label, overrides]
|
@@ -5059,9 +4693,17 @@ var DropZoneChild = ({
|
|
5059
4693
|
}),
|
5060
4694
|
[componentConfig == null ? void 0 : componentConfig.defaultProps, item == null ? void 0 : item.props, puckProps]
|
5061
4695
|
);
|
4696
|
+
const defaultedNode = useMemo9(
|
4697
|
+
() => {
|
4698
|
+
var _a2;
|
4699
|
+
return { type: (_a2 = item == null ? void 0 : item.type) != null ? _a2 : nodeType, props: defaultsProps };
|
4700
|
+
},
|
4701
|
+
[item == null ? void 0 : item.type, nodeType, defaultsProps]
|
4702
|
+
);
|
4703
|
+
const config = useAppStore((s) => s.config);
|
5062
4704
|
const defaultedPropsWithSlots = useSlots(
|
5063
|
-
|
5064
|
-
|
4705
|
+
config,
|
4706
|
+
defaultedNode,
|
5065
4707
|
DropZoneEditPure,
|
5066
4708
|
(slotProps) => /* @__PURE__ */ jsx23(ContextSlotRender, { componentId, zone: slotProps.zone }),
|
5067
4709
|
nodeReadOnly,
|
@@ -5073,8 +4715,8 @@ var DropZoneChild = ({
|
|
5073
4715
|
item.type
|
5074
4716
|
] });
|
5075
4717
|
let componentType = item.type;
|
5076
|
-
const
|
5077
|
-
if (
|
4718
|
+
const isInserting = "previewType" in item ? item.previewType === "insert" : false;
|
4719
|
+
if (isInserting) {
|
5078
4720
|
Render2 = renderPreview;
|
5079
4721
|
}
|
5080
4722
|
return /* @__PURE__ */ jsx23(
|
@@ -5088,11 +4730,10 @@ var DropZoneChild = ({
|
|
5088
4730
|
isLoading,
|
5089
4731
|
isSelected,
|
5090
4732
|
label,
|
5091
|
-
isEnabled,
|
5092
4733
|
autoDragAxis: dragAxis,
|
5093
4734
|
userDragAxis: collisionAxis,
|
5094
4735
|
inDroppableZone,
|
5095
|
-
children: (dragRef) => (componentConfig == null ? void 0 : componentConfig.inline) && !
|
4736
|
+
children: (dragRef) => (componentConfig == null ? void 0 : componentConfig.inline) && !isInserting ? /* @__PURE__ */ jsx23(Fragment6, { children: /* @__PURE__ */ jsx23(
|
5096
4737
|
Render2,
|
5097
4738
|
__spreadProps(__spreadValues({}, defaultedPropsWithSlots), {
|
5098
4739
|
puck: __spreadProps(__spreadValues({}, defaultedPropsWithSlots.puck), {
|
@@ -5114,7 +4755,7 @@ var DropZoneEdit = forwardRef3(
|
|
5114
4755
|
minEmptyHeight: userMinEmptyHeight = 128,
|
5115
4756
|
collisionAxis
|
5116
4757
|
}, userRef) {
|
5117
|
-
const ctx =
|
4758
|
+
const ctx = useContext7(dropZoneContext);
|
5118
4759
|
const {
|
5119
4760
|
// These all need setting via context
|
5120
4761
|
areaId,
|
@@ -5123,7 +4764,7 @@ var DropZoneEdit = forwardRef3(
|
|
5123
4764
|
unregisterLocalZone
|
5124
4765
|
} = ctx != null ? ctx : {};
|
5125
4766
|
const path = useAppStore(
|
5126
|
-
|
4767
|
+
useShallow4((s) => {
|
5127
4768
|
var _a;
|
5128
4769
|
return areaId ? (_a = s.state.indexes.nodes[areaId]) == null ? void 0 : _a.path : null;
|
5129
4770
|
})
|
@@ -5135,39 +4776,24 @@ var DropZoneEdit = forwardRef3(
|
|
5135
4776
|
}
|
5136
4777
|
}
|
5137
4778
|
const isRootZone = zoneCompound === rootDroppableId || zone === rootDroppableId || areaId === "root";
|
5138
|
-
const
|
5139
|
-
|
5140
|
-
|
5141
|
-
|
5142
|
-
userIsDragging
|
5143
|
-
} = useContextStore(ZoneStoreContext, (s) => {
|
5144
|
-
var _a, _b;
|
5145
|
-
return {
|
5146
|
-
isDeepestZone: (_a = s.zoneDepthIndex[zoneCompound]) != null ? _a : false,
|
5147
|
-
inNextDeepestArea: s.nextAreaDepthIndex[areaId || ""],
|
5148
|
-
draggedComponentType: (_b = s.draggedItem) == null ? void 0 : _b.data.componentType,
|
5149
|
-
userIsDragging: !!s.draggedItem
|
5150
|
-
};
|
5151
|
-
});
|
4779
|
+
const inNextDeepestArea = useContextStore(
|
4780
|
+
ZoneStoreContext,
|
4781
|
+
(s) => s.nextAreaDepthIndex[areaId || ""]
|
4782
|
+
);
|
5152
4783
|
const zoneContentIds = useAppStore(
|
5153
|
-
|
4784
|
+
useShallow4((s) => {
|
5154
4785
|
var _a;
|
5155
4786
|
return (_a = s.state.indexes.zones[zoneCompound]) == null ? void 0 : _a.contentIds;
|
5156
4787
|
})
|
5157
4788
|
);
|
5158
4789
|
const zoneType = useAppStore(
|
5159
|
-
|
4790
|
+
useShallow4((s) => {
|
5160
4791
|
var _a;
|
5161
4792
|
return (_a = s.state.indexes.zones[zoneCompound]) == null ? void 0 : _a.type;
|
5162
4793
|
})
|
5163
4794
|
);
|
5164
|
-
|
4795
|
+
useEffect16(() => {
|
5165
4796
|
if (!zoneType || zoneType === "dropzone") {
|
5166
|
-
if (zoneCompound !== rootDroppableId) {
|
5167
|
-
console.warn(
|
5168
|
-
"DropZones have been deprecated in favor of slot fields and will be removed in a future version of Puck. Please see the migration guide: https://www.puckeditor.com/docs/guides/migrations/dropzones-to-slots"
|
5169
|
-
);
|
5170
|
-
}
|
5171
4797
|
if (ctx == null ? void 0 : ctx.registerZone) {
|
5172
4798
|
ctx == null ? void 0 : ctx.registerZone(zoneCompound);
|
5173
4799
|
}
|
@@ -5178,11 +4804,20 @@ var DropZoneEdit = forwardRef3(
|
|
5178
4804
|
};
|
5179
4805
|
}
|
5180
4806
|
}, [zoneType]);
|
4807
|
+
useEffect16(() => {
|
4808
|
+
if (zoneType === "dropzone") {
|
4809
|
+
if (zoneCompound !== rootDroppableId) {
|
4810
|
+
console.warn(
|
4811
|
+
"DropZones have been deprecated in favor of slot fields and will be removed in a future version of Puck. Please see the migration guide: https://www.puckeditor.com/docs/guides/migrations/dropzones-to-slots"
|
4812
|
+
);
|
4813
|
+
}
|
4814
|
+
}
|
4815
|
+
}, [zoneType]);
|
5181
4816
|
const contentIds = useMemo9(() => {
|
5182
4817
|
return zoneContentIds || [];
|
5183
4818
|
}, [zoneContentIds]);
|
5184
|
-
const ref =
|
5185
|
-
const acceptsTarget =
|
4819
|
+
const ref = useRef4(null);
|
4820
|
+
const acceptsTarget = useCallback10(
|
5186
4821
|
(componentType) => {
|
5187
4822
|
if (!componentType) {
|
5188
4823
|
return true;
|
@@ -5204,29 +4839,44 @@ var DropZoneEdit = forwardRef3(
|
|
5204
4839
|
},
|
5205
4840
|
[allow, disallow]
|
5206
4841
|
);
|
5207
|
-
|
4842
|
+
const targetAccepted = useContextStore(ZoneStoreContext, (s) => {
|
4843
|
+
var _a;
|
4844
|
+
const draggedComponentType = (_a = s.draggedItem) == null ? void 0 : _a.data.componentType;
|
4845
|
+
return acceptsTarget(draggedComponentType);
|
4846
|
+
});
|
4847
|
+
const hoveringOverArea = inNextDeepestArea || isRootZone;
|
4848
|
+
const isEnabled = useContextStore(ZoneStoreContext, (s) => {
|
4849
|
+
var _a;
|
4850
|
+
let _isEnabled = true;
|
4851
|
+
const isDeepestZone = (_a = s.zoneDepthIndex[zoneCompound]) != null ? _a : false;
|
4852
|
+
_isEnabled = isDeepestZone;
|
4853
|
+
if (_isEnabled) {
|
4854
|
+
_isEnabled = targetAccepted;
|
4855
|
+
}
|
4856
|
+
return _isEnabled;
|
4857
|
+
});
|
4858
|
+
useEffect16(() => {
|
5208
4859
|
if (registerLocalZone) {
|
5209
|
-
registerLocalZone(zoneCompound,
|
4860
|
+
registerLocalZone(zoneCompound, isEnabled);
|
5210
4861
|
}
|
5211
4862
|
return () => {
|
5212
4863
|
if (unregisterLocalZone) {
|
5213
4864
|
unregisterLocalZone(zoneCompound);
|
5214
4865
|
}
|
5215
4866
|
};
|
5216
|
-
}, [
|
5217
|
-
const hoveringOverArea = inNextDeepestArea || isRootZone;
|
5218
|
-
let isEnabled = true;
|
5219
|
-
if (userIsDragging) {
|
5220
|
-
isEnabled = isDeepestZone;
|
5221
|
-
}
|
5222
|
-
if (isEnabled) {
|
5223
|
-
isEnabled = acceptsTarget(draggedComponentType);
|
5224
|
-
}
|
4867
|
+
}, [isEnabled, zoneCompound]);
|
5225
4868
|
const [contentIdsWithPreview, preview] = useContentIdsWithPreview(
|
5226
4869
|
contentIds,
|
5227
4870
|
zoneCompound
|
5228
4871
|
);
|
5229
4872
|
const isDropEnabled = isEnabled && (preview ? contentIdsWithPreview.length === 1 : contentIdsWithPreview.length === 0);
|
4873
|
+
const zoneStore = useContext7(ZoneStoreContext);
|
4874
|
+
useEffect16(() => {
|
4875
|
+
const { enabledIndex } = zoneStore.getState();
|
4876
|
+
zoneStore.setState({
|
4877
|
+
enabledIndex: __spreadProps(__spreadValues({}, enabledIndex), { [zoneCompound]: isEnabled })
|
4878
|
+
});
|
4879
|
+
}, [isEnabled, zoneStore, zoneCompound]);
|
5230
4880
|
const droppableConfig = {
|
5231
4881
|
id: zoneCompound,
|
5232
4882
|
collisionPriority: isEnabled ? depth : 0,
|
@@ -5236,11 +4886,11 @@ var DropZoneEdit = forwardRef3(
|
|
5236
4886
|
data: {
|
5237
4887
|
areaId,
|
5238
4888
|
depth,
|
5239
|
-
isDroppableTarget:
|
4889
|
+
isDroppableTarget: targetAccepted,
|
5240
4890
|
path: path || []
|
5241
4891
|
}
|
5242
4892
|
};
|
5243
|
-
const { ref: dropRef } =
|
4893
|
+
const { ref: dropRef } = useDroppable(droppableConfig);
|
5244
4894
|
const isAreaSelected = useAppStore(
|
5245
4895
|
(s) => (s == null ? void 0 : s.selectedItem) && areaId === (s == null ? void 0 : s.selectedItem.props.id)
|
5246
4896
|
);
|
@@ -5255,7 +4905,6 @@ var DropZoneEdit = forwardRef3(
|
|
5255
4905
|
{
|
5256
4906
|
className: `${getClassName17({
|
5257
4907
|
isRootZone,
|
5258
|
-
userIsDragging,
|
5259
4908
|
hoveringOverArea,
|
5260
4909
|
isEnabled,
|
5261
4910
|
isAreaSelected,
|
@@ -5277,12 +4926,10 @@ var DropZoneEdit = forwardRef3(
|
|
5277
4926
|
{
|
5278
4927
|
zoneCompound,
|
5279
4928
|
componentId,
|
5280
|
-
preview,
|
5281
4929
|
dragAxis,
|
5282
|
-
isEnabled,
|
5283
4930
|
index: i,
|
5284
4931
|
collisionAxis,
|
5285
|
-
inDroppableZone:
|
4932
|
+
inDroppableZone: targetAccepted
|
5286
4933
|
},
|
5287
4934
|
componentId
|
5288
4935
|
);
|
@@ -5297,7 +4944,7 @@ var DropZoneRenderItem = ({
|
|
5297
4944
|
metadata
|
5298
4945
|
}) => {
|
5299
4946
|
const Component = config.components[item.type];
|
5300
|
-
const props = useSlots(
|
4947
|
+
const props = useSlots(config, item, (slotProps) => /* @__PURE__ */ jsx23(SlotRenderPure, __spreadProps(__spreadValues({}, slotProps), { config, metadata })));
|
5301
4948
|
const nextContextValue = useMemo9(
|
5302
4949
|
() => ({
|
5303
4950
|
areaId: props.id,
|
@@ -5318,12 +4965,12 @@ var DropZoneRenderItem = ({
|
|
5318
4965
|
var DropZoneRenderPure = (props) => /* @__PURE__ */ jsx23(DropZoneRender, __spreadValues({}, props));
|
5319
4966
|
var DropZoneRender = forwardRef3(
|
5320
4967
|
function DropZoneRenderInternal({ className, style, zone }, ref) {
|
5321
|
-
const ctx =
|
4968
|
+
const ctx = useContext7(dropZoneContext);
|
5322
4969
|
const { areaId = "root" } = ctx || {};
|
5323
|
-
const { config, data, metadata } =
|
4970
|
+
const { config, data, metadata } = useContext7(renderContext);
|
5324
4971
|
let zoneCompound = rootDroppableId;
|
5325
4972
|
let content = (data == null ? void 0 : data.content) || [];
|
5326
|
-
|
4973
|
+
useEffect16(() => {
|
5327
4974
|
if (!content) {
|
5328
4975
|
if (ctx == null ? void 0 : ctx.registerZone) {
|
5329
4976
|
ctx == null ? void 0 : ctx.registerZone(zoneCompound);
|
@@ -5362,7 +5009,7 @@ var DropZoneRender = forwardRef3(
|
|
5362
5009
|
var DropZonePure = (props) => /* @__PURE__ */ jsx23(DropZone, __spreadValues({}, props));
|
5363
5010
|
var DropZone = forwardRef3(
|
5364
5011
|
function DropZone2(props, ref) {
|
5365
|
-
const ctx =
|
5012
|
+
const ctx = useContext7(dropZoneContext);
|
5366
5013
|
if ((ctx == null ? void 0 : ctx.mode) === "edit") {
|
5367
5014
|
return /* @__PURE__ */ jsx23(Fragment6, { children: /* @__PURE__ */ jsx23(DropZoneEdit, __spreadProps(__spreadValues({}, props), { ref })) });
|
5368
5015
|
}
|
@@ -5373,7 +5020,6 @@ var DropZone = forwardRef3(
|
|
5373
5020
|
// lib/dnd/NestedDroppablePlugin.ts
|
5374
5021
|
init_react_import();
|
5375
5022
|
import { Plugin } from "@dnd-kit/abstract";
|
5376
|
-
import { effects } from "@dnd-kit/state";
|
5377
5023
|
|
5378
5024
|
// lib/throttle.ts
|
5379
5025
|
init_react_import();
|
@@ -5422,7 +5068,7 @@ var GlobalPosition = class {
|
|
5422
5068
|
var _a;
|
5423
5069
|
this.target = target;
|
5424
5070
|
this.original = original;
|
5425
|
-
this.frameEl = document.querySelector("#preview-frame");
|
5071
|
+
this.frameEl = document.querySelector("iframe#preview-frame");
|
5426
5072
|
if (this.frameEl) {
|
5427
5073
|
this.frameRect = this.frameEl.getBoundingClientRect();
|
5428
5074
|
this.scaleFactor = this.frameRect.width / (((_a = this.frameEl.contentWindow) == null ? void 0 : _a.innerWidth) || 1);
|
@@ -5487,7 +5133,7 @@ var depthSort = (candidates) => {
|
|
5487
5133
|
return 0;
|
5488
5134
|
});
|
5489
5135
|
};
|
5490
|
-
var
|
5136
|
+
var getZoneId = (candidate) => {
|
5491
5137
|
let id = candidate == null ? void 0 : candidate.id;
|
5492
5138
|
if (!candidate) return null;
|
5493
5139
|
if (candidate.type === "component") {
|
@@ -5502,6 +5148,7 @@ var getZoneId2 = (candidate) => {
|
|
5502
5148
|
}
|
5503
5149
|
return id;
|
5504
5150
|
};
|
5151
|
+
var BUFFER = 6;
|
5505
5152
|
var getPointerCollisions = (position, manager) => {
|
5506
5153
|
const candidates = [];
|
5507
5154
|
let elements = position.target.ownerDocument.elementsFromPoint(
|
@@ -5525,13 +5172,26 @@ var getPointerCollisions = (position, manager) => {
|
|
5525
5172
|
for (let i = 0; i < elements.length; i++) {
|
5526
5173
|
const element = elements[i];
|
5527
5174
|
const dropzoneId = element.getAttribute("data-puck-dropzone");
|
5175
|
+
const id = element.getAttribute("data-puck-dnd");
|
5176
|
+
const isVoid = element.hasAttribute("data-puck-dnd-void");
|
5177
|
+
if (BUFFER && (dropzoneId || id) && !isVoid) {
|
5178
|
+
const box = element.getBoundingClientRect();
|
5179
|
+
const contractedBox = {
|
5180
|
+
left: box.left + BUFFER,
|
5181
|
+
right: box.right - BUFFER,
|
5182
|
+
top: box.top + BUFFER,
|
5183
|
+
bottom: box.bottom - BUFFER
|
5184
|
+
};
|
5185
|
+
if (position.frame.x < contractedBox.left || position.frame.x > contractedBox.right || position.frame.y > contractedBox.bottom || position.frame.y < contractedBox.top) {
|
5186
|
+
continue;
|
5187
|
+
}
|
5188
|
+
}
|
5528
5189
|
if (dropzoneId) {
|
5529
5190
|
const droppable = manager.registry.droppables.get(dropzoneId);
|
5530
5191
|
if (droppable) {
|
5531
5192
|
candidates.push(droppable);
|
5532
5193
|
}
|
5533
5194
|
}
|
5534
|
-
const id = element.getAttribute("data-puck-dnd");
|
5535
5195
|
if (id) {
|
5536
5196
|
const droppable = manager.registry.droppables.get(id);
|
5537
5197
|
if (droppable) {
|
@@ -5580,13 +5240,13 @@ var findDeepestCandidate = (position, manager) => {
|
|
5580
5240
|
return true;
|
5581
5241
|
});
|
5582
5242
|
filteredCandidates.reverse();
|
5583
|
-
const zone =
|
5243
|
+
const zone = getZoneId(filteredCandidates[0]);
|
5584
5244
|
const area = (_a = filteredCandidates[0]) == null ? void 0 : _a.data.areaId;
|
5585
5245
|
return { zone, area };
|
5586
5246
|
}
|
5587
5247
|
return {
|
5588
|
-
zone:
|
5589
|
-
area:
|
5248
|
+
zone: rootDroppableId,
|
5249
|
+
area: rootAreaId
|
5590
5250
|
};
|
5591
5251
|
};
|
5592
5252
|
var createNestedDroppablePlugin = ({ onChange }, id) => class NestedDroppablePlugin extends Plugin {
|
@@ -5595,7 +5255,7 @@ var createNestedDroppablePlugin = ({ onChange }, id) => class NestedDroppablePlu
|
|
5595
5255
|
if (typeof window === "undefined") {
|
5596
5256
|
return;
|
5597
5257
|
}
|
5598
|
-
|
5258
|
+
this.registerEffect(() => {
|
5599
5259
|
const handleMove = (event) => {
|
5600
5260
|
const target = event instanceof BubbledPointerEvent ? event.originalTarget || event.target : event.target;
|
5601
5261
|
const position = new GlobalPosition(target, {
|
@@ -5619,12 +5279,12 @@ var createNestedDroppablePlugin = ({ onChange }, id) => class NestedDroppablePlu
|
|
5619
5279
|
capture: true
|
5620
5280
|
// dndkit's PointerSensor prevents propagation during drag
|
5621
5281
|
});
|
5622
|
-
|
5282
|
+
const cleanup = () => {
|
5623
5283
|
document.body.removeEventListener("pointermove", handlePointerMove, {
|
5624
5284
|
capture: true
|
5625
5285
|
});
|
5626
|
-
cleanupEffect();
|
5627
5286
|
};
|
5287
|
+
return cleanup;
|
5628
5288
|
});
|
5629
5289
|
}
|
5630
5290
|
};
|
@@ -5684,14 +5344,15 @@ function getDeepDir(el) {
|
|
5684
5344
|
}
|
5685
5345
|
|
5686
5346
|
// components/DragDropContext/index.tsx
|
5347
|
+
import { effect } from "@dnd-kit/state";
|
5687
5348
|
import { jsx as jsx24 } from "react/jsx-runtime";
|
5688
5349
|
var DEBUG3 = false;
|
5689
5350
|
var dragListenerContext = createContext4({
|
5690
5351
|
dragListeners: {}
|
5691
5352
|
});
|
5692
5353
|
function useDragListener(type, fn, deps = []) {
|
5693
|
-
const { setDragListeners } =
|
5694
|
-
|
5354
|
+
const { setDragListeners } = useContext8(dragListenerContext);
|
5355
|
+
useEffect17(() => {
|
5695
5356
|
if (setDragListeners) {
|
5696
5357
|
setDragListeners((old) => __spreadProps(__spreadValues({}, old), {
|
5697
5358
|
[type]: [...old[type] || [], fn]
|
@@ -5701,8 +5362,8 @@ function useDragListener(type, fn, deps = []) {
|
|
5701
5362
|
}
|
5702
5363
|
var AREA_CHANGE_DEBOUNCE_MS = 100;
|
5703
5364
|
var useTempDisableFallback = (timeout3) => {
|
5704
|
-
const lastFallbackDisable =
|
5705
|
-
return
|
5365
|
+
const lastFallbackDisable = useRef5(null);
|
5366
|
+
return useCallback11((manager) => {
|
5706
5367
|
collisionStore.setState({ fallbackEnabled: false });
|
5707
5368
|
const fallbackId = generateId();
|
5708
5369
|
lastFallbackDisable.current = fallbackId;
|
@@ -5721,7 +5382,7 @@ var DragDropContextClient = ({
|
|
5721
5382
|
const dispatch = useAppStore((s) => s.dispatch);
|
5722
5383
|
const appStore = useAppStoreApi();
|
5723
5384
|
const id = useSafeId();
|
5724
|
-
const debouncedParamsRef =
|
5385
|
+
const debouncedParamsRef = useRef5(null);
|
5725
5386
|
const tempDisableFallback = useTempDisableFallback(100);
|
5726
5387
|
const [zoneStore] = useState14(
|
5727
5388
|
() => createStore3(() => ({
|
@@ -5730,10 +5391,12 @@ var DragDropContextClient = ({
|
|
5730
5391
|
areaDepthIndex: {},
|
5731
5392
|
nextAreaDepthIndex: {},
|
5732
5393
|
draggedItem: null,
|
5733
|
-
previewIndex: {}
|
5394
|
+
previewIndex: {},
|
5395
|
+
enabledIndex: {},
|
5396
|
+
hoveringComponent: null
|
5734
5397
|
}))
|
5735
5398
|
);
|
5736
|
-
const getChanged2 =
|
5399
|
+
const getChanged2 = useCallback11(
|
5737
5400
|
(params, id2) => {
|
5738
5401
|
const { zoneDepthIndex = {}, areaDepthIndex = {} } = zoneStore.getState() || {};
|
5739
5402
|
const stateHasZone = Object.keys(zoneDepthIndex).length > 0;
|
@@ -5754,7 +5417,7 @@ var DragDropContextClient = ({
|
|
5754
5417
|
},
|
5755
5418
|
[zoneStore]
|
5756
5419
|
);
|
5757
|
-
const setDeepestAndCollide =
|
5420
|
+
const setDeepestAndCollide = useCallback11(
|
5758
5421
|
(params, manager) => {
|
5759
5422
|
const { zoneChanged, areaChanged } = getChanged2(params, id);
|
5760
5423
|
if (!zoneChanged && !areaChanged) return;
|
@@ -5778,7 +5441,7 @@ var DragDropContextClient = ({
|
|
5778
5441
|
setDeepestDb.cancel();
|
5779
5442
|
debouncedParamsRef.current = null;
|
5780
5443
|
};
|
5781
|
-
|
5444
|
+
useEffect17(() => {
|
5782
5445
|
if (DEBUG3) {
|
5783
5446
|
zoneStore.subscribe(
|
5784
5447
|
(s) => {
|
@@ -5841,8 +5504,8 @@ var DragDropContextClient = ({
|
|
5841
5504
|
]);
|
5842
5505
|
const sensors = useSensors();
|
5843
5506
|
const [dragListeners, setDragListeners] = useState14({});
|
5844
|
-
const dragMode =
|
5845
|
-
const initialSelector =
|
5507
|
+
const dragMode = useRef5(null);
|
5508
|
+
const initialSelector = useRef5(void 0);
|
5846
5509
|
const nextContextValue = useMemo10(
|
5847
5510
|
() => ({
|
5848
5511
|
mode: "edit",
|
@@ -5864,7 +5527,9 @@ var DragDropContextClient = ({
|
|
5864
5527
|
plugins,
|
5865
5528
|
sensors,
|
5866
5529
|
onDragEnd: (event, manager) => {
|
5867
|
-
var _a;
|
5530
|
+
var _a, _b;
|
5531
|
+
const entryEl = (_a = getFrame()) == null ? void 0 : _a.querySelector("[data-puck-entry]");
|
5532
|
+
entryEl == null ? void 0 : entryEl.removeAttribute("data-puck-dragging");
|
5868
5533
|
const { source, target } = event.operation;
|
5869
5534
|
if (!source) {
|
5870
5535
|
zoneStore.setState({ draggedItem: null });
|
@@ -5872,9 +5537,9 @@ var DragDropContextClient = ({
|
|
5872
5537
|
}
|
5873
5538
|
const { zone, index } = source.data;
|
5874
5539
|
const { previewIndex = {} } = zoneStore.getState() || {};
|
5875
|
-
const thisPreview = ((
|
5876
|
-
|
5877
|
-
var _a2,
|
5540
|
+
const thisPreview = ((_b = previewIndex[zone]) == null ? void 0 : _b.props.id) === source.id ? previewIndex[zone] : null;
|
5541
|
+
const onAnimationEnd = () => {
|
5542
|
+
var _a2, _b2;
|
5878
5543
|
zoneStore.setState({ draggedItem: null });
|
5879
5544
|
if (event.canceled || (target == null ? void 0 : target.type) === "void") {
|
5880
5545
|
zoneStore.setState({ previewIndex: {} });
|
@@ -5910,23 +5575,28 @@ var DragDropContextClient = ({
|
|
5910
5575
|
});
|
5911
5576
|
}
|
5912
5577
|
}
|
5913
|
-
|
5914
|
-
|
5915
|
-
|
5916
|
-
|
5917
|
-
|
5918
|
-
|
5919
|
-
|
5920
|
-
|
5921
|
-
|
5922
|
-
}, 50);
|
5923
|
-
(_b = dragListeners.dragend) == null ? void 0 : _b.forEach((fn) => {
|
5578
|
+
dispatch({
|
5579
|
+
type: "setUi",
|
5580
|
+
ui: {
|
5581
|
+
itemSelector: { index, zone },
|
5582
|
+
isDragging: false
|
5583
|
+
},
|
5584
|
+
recordHistory: true
|
5585
|
+
});
|
5586
|
+
(_b2 = dragListeners.dragend) == null ? void 0 : _b2.forEach((fn) => {
|
5924
5587
|
fn(event, manager);
|
5925
5588
|
});
|
5926
|
-
}
|
5589
|
+
};
|
5590
|
+
let dispose;
|
5591
|
+
dispose = effect(() => {
|
5592
|
+
if (source.status === "idle") {
|
5593
|
+
onAnimationEnd();
|
5594
|
+
dispose == null ? void 0 : dispose();
|
5595
|
+
}
|
5596
|
+
});
|
5927
5597
|
},
|
5928
5598
|
onDragOver: (event, manager) => {
|
5929
|
-
var _a, _b, _c, _d
|
5599
|
+
var _a, _b, _c, _d;
|
5930
5600
|
event.preventDefault();
|
5931
5601
|
const draggedItem = (_a = zoneStore.getState()) == null ? void 0 : _a.draggedItem;
|
5932
5602
|
if (!draggedItem) return;
|
@@ -5944,7 +5614,7 @@ var DragDropContextClient = ({
|
|
5944
5614
|
const targetData = target.data;
|
5945
5615
|
targetZone = targetData.zone;
|
5946
5616
|
targetIndex = targetData.index;
|
5947
|
-
const collisionData = (
|
5617
|
+
const collisionData = (_b = manager.collisionObserver.collisions[0]) == null ? void 0 : _b.data;
|
5948
5618
|
const dir = getDeepDir(target.element);
|
5949
5619
|
const collisionPosition = (collisionData == null ? void 0 : collisionData.direction) === "up" || dir === "ltr" && (collisionData == null ? void 0 : collisionData.direction) === "left" || dir === "rtl" && (collisionData == null ? void 0 : collisionData.direction) === "right" ? "before" : "after";
|
5950
5620
|
if (targetIndex >= sourceIndex && sourceZone === targetZone) {
|
@@ -5957,7 +5627,7 @@ var DragDropContextClient = ({
|
|
5957
5627
|
targetZone = target.id.toString();
|
5958
5628
|
targetIndex = 0;
|
5959
5629
|
}
|
5960
|
-
const path = ((
|
5630
|
+
const path = ((_c = appStore.getState().state.indexes.nodes[target.id]) == null ? void 0 : _c.path) || [];
|
5961
5631
|
if (targetId === sourceId || path.find((path2) => {
|
5962
5632
|
const [pathId] = path2.split(":");
|
5963
5633
|
return pathId === sourceId;
|
@@ -6003,16 +5673,12 @@ var DragDropContextClient = ({
|
|
6003
5673
|
});
|
6004
5674
|
}
|
6005
5675
|
}
|
6006
|
-
(
|
5676
|
+
(_d = dragListeners.dragover) == null ? void 0 : _d.forEach((fn) => {
|
6007
5677
|
fn(event, manager);
|
6008
5678
|
});
|
6009
5679
|
},
|
6010
5680
|
onDragStart: (event, manager) => {
|
6011
5681
|
var _a;
|
6012
|
-
dispatch({
|
6013
|
-
type: "setUi",
|
6014
|
-
ui: { itemSelector: null, isDragging: true }
|
6015
|
-
});
|
6016
5682
|
const { source } = event.operation;
|
6017
5683
|
if (source && source.type !== "void") {
|
6018
5684
|
const sourceData = source.data;
|
@@ -6042,11 +5708,31 @@ var DragDropContextClient = ({
|
|
6042
5708
|
});
|
6043
5709
|
},
|
6044
5710
|
onBeforeDragStart: (event) => {
|
6045
|
-
var _a;
|
6046
|
-
const isNewComponent = ((_a = event.operation.source) == null ? void 0 : _a.
|
5711
|
+
var _a, _b, _c, _d;
|
5712
|
+
const isNewComponent = ((_a = event.operation.source) == null ? void 0 : _a.type) === "drawer";
|
6047
5713
|
dragMode.current = isNewComponent ? "new" : "existing";
|
6048
5714
|
initialSelector.current = void 0;
|
6049
5715
|
zoneStore.setState({ draggedItem: event.operation.source });
|
5716
|
+
if (((_b = appStore.getState().selectedItem) == null ? void 0 : _b.props.id) !== ((_c = event.operation.source) == null ? void 0 : _c.id)) {
|
5717
|
+
dispatch({
|
5718
|
+
type: "setUi",
|
5719
|
+
ui: {
|
5720
|
+
itemSelector: null,
|
5721
|
+
isDragging: true
|
5722
|
+
},
|
5723
|
+
recordHistory: false
|
5724
|
+
});
|
5725
|
+
} else {
|
5726
|
+
dispatch({
|
5727
|
+
type: "setUi",
|
5728
|
+
ui: {
|
5729
|
+
isDragging: true
|
5730
|
+
},
|
5731
|
+
recordHistory: false
|
5732
|
+
});
|
5733
|
+
}
|
5734
|
+
const entryEl = (_d = getFrame()) == null ? void 0 : _d.querySelector("[data-puck-entry]");
|
5735
|
+
entryEl == null ? void 0 : entryEl.setAttribute("data-puck-dragging", "true");
|
6050
5736
|
},
|
6051
5737
|
children: /* @__PURE__ */ jsx24(ZoneStoreProvider, { store: zoneStore, children: /* @__PURE__ */ jsx24(DropZoneProvider, { value: nextContextValue, children }) })
|
6052
5738
|
}
|
@@ -6066,6 +5752,7 @@ var DragDropContext = ({
|
|
6066
5752
|
};
|
6067
5753
|
|
6068
5754
|
// components/Drawer/index.tsx
|
5755
|
+
import { useDraggable, useDroppable as useDroppable2 } from "@dnd-kit/react";
|
6069
5756
|
import { jsx as jsx25, jsxs as jsxs11 } from "react/jsx-runtime";
|
6070
5757
|
var getClassName18 = get_class_name_factory_default("Drawer", styles_module_default10);
|
6071
5758
|
var getClassNameItem2 = get_class_name_factory_default("DrawerItem", styles_module_default10);
|
@@ -6102,10 +5789,11 @@ var DrawerItemDraggable = ({
|
|
6102
5789
|
id,
|
6103
5790
|
isDragDisabled
|
6104
5791
|
}) => {
|
6105
|
-
const { ref } =
|
5792
|
+
const { ref } = useDraggable({
|
6106
5793
|
id,
|
6107
|
-
data: {
|
6108
|
-
disabled: isDragDisabled
|
5794
|
+
data: { componentType: name },
|
5795
|
+
disabled: isDragDisabled,
|
5796
|
+
type: "drawer"
|
6109
5797
|
});
|
6110
5798
|
return /* @__PURE__ */ jsxs11("div", { className: getClassName18("draggable"), children: [
|
6111
5799
|
/* @__PURE__ */ jsx25("div", { className: getClassName18("draggableBg"), children: /* @__PURE__ */ jsx25(DrawerItemInner, { name, label, children }) }),
|
@@ -6170,7 +5858,7 @@ var Drawer = ({
|
|
6170
5858
|
);
|
6171
5859
|
}
|
6172
5860
|
const id = useSafeId();
|
6173
|
-
const { ref } =
|
5861
|
+
const { ref } = useDroppable2({
|
6174
5862
|
id,
|
6175
5863
|
type: "void",
|
6176
5864
|
collisionPriority: 0
|
@@ -6183,6 +5871,7 @@ var Drawer = ({
|
|
6183
5871
|
ref,
|
6184
5872
|
"data-puck-dnd": id,
|
6185
5873
|
"data-puck-drawer": true,
|
5874
|
+
"data-puck-dnd-void": true,
|
6186
5875
|
children
|
6187
5876
|
}
|
6188
5877
|
);
|
@@ -6193,11 +5882,12 @@ Drawer.Item = DrawerItem;
|
|
6193
5882
|
init_react_import();
|
6194
5883
|
import {
|
6195
5884
|
createContext as createContext7,
|
6196
|
-
useCallback as
|
6197
|
-
useContext as
|
6198
|
-
useEffect as
|
6199
|
-
useMemo as
|
6200
|
-
|
5885
|
+
useCallback as useCallback18,
|
5886
|
+
useContext as useContext12,
|
5887
|
+
useEffect as useEffect25,
|
5888
|
+
useMemo as useMemo21,
|
5889
|
+
useRef as useRef8,
|
5890
|
+
useState as useState23
|
6201
5891
|
} from "react";
|
6202
5892
|
|
6203
5893
|
// components/SidebarSection/index.tsx
|
@@ -6293,70 +5983,26 @@ var SidebarSection = ({
|
|
6293
5983
|
);
|
6294
5984
|
};
|
6295
5985
|
|
6296
|
-
// components/MenuBar/index.tsx
|
6297
|
-
init_react_import();
|
6298
|
-
|
6299
|
-
// css-module:/home/runner/work/puck/puck/packages/core/components/MenuBar/styles.module.css#css-module
|
6300
|
-
init_react_import();
|
6301
|
-
var styles_module_default14 = { "MenuBar": "_MenuBar_8pf8c_1", "MenuBar--menuOpen": "_MenuBar--menuOpen_8pf8c_14", "MenuBar-inner": "_MenuBar-inner_8pf8c_29", "MenuBar-history": "_MenuBar-history_8pf8c_45" };
|
6302
|
-
|
6303
|
-
// components/MenuBar/index.tsx
|
6304
|
-
import { Fragment as Fragment7, jsx as jsx27, jsxs as jsxs13 } from "react/jsx-runtime";
|
6305
|
-
var getClassName20 = get_class_name_factory_default("MenuBar", styles_module_default14);
|
6306
|
-
function MenuBar({
|
6307
|
-
menuOpen = false,
|
6308
|
-
renderHeaderActions,
|
6309
|
-
setMenuOpen
|
6310
|
-
}) {
|
6311
|
-
const back = useAppStore((s) => s.history.back);
|
6312
|
-
const forward = useAppStore((s) => s.history.forward);
|
6313
|
-
const hasFuture = useAppStore((s) => s.history.hasFuture());
|
6314
|
-
const hasPast = useAppStore((s) => s.history.hasPast());
|
6315
|
-
return /* @__PURE__ */ jsx27(
|
6316
|
-
"div",
|
6317
|
-
{
|
6318
|
-
className: getClassName20({ menuOpen }),
|
6319
|
-
onClick: (event) => {
|
6320
|
-
var _a;
|
6321
|
-
const element = event.target;
|
6322
|
-
if (window.matchMedia("(min-width: 638px)").matches) {
|
6323
|
-
return;
|
6324
|
-
}
|
6325
|
-
if (element.tagName === "A" && ((_a = element.getAttribute("href")) == null ? void 0 : _a.startsWith("#"))) {
|
6326
|
-
setMenuOpen(false);
|
6327
|
-
}
|
6328
|
-
},
|
6329
|
-
children: /* @__PURE__ */ jsxs13("div", { className: getClassName20("inner"), children: [
|
6330
|
-
/* @__PURE__ */ jsxs13("div", { className: getClassName20("history"), children: [
|
6331
|
-
/* @__PURE__ */ jsx27(IconButton, { title: "undo", disabled: !hasPast, onClick: back, children: /* @__PURE__ */ jsx27(Undo2, { size: 21 }) }),
|
6332
|
-
/* @__PURE__ */ jsx27(IconButton, { title: "redo", disabled: !hasFuture, onClick: forward, children: /* @__PURE__ */ jsx27(Redo2, { size: 21 }) })
|
6333
|
-
] }),
|
6334
|
-
/* @__PURE__ */ jsx27(Fragment7, { children: renderHeaderActions && renderHeaderActions() })
|
6335
|
-
] })
|
6336
|
-
}
|
6337
|
-
);
|
6338
|
-
}
|
6339
|
-
|
6340
5986
|
// css-module:/home/runner/work/puck/puck/packages/core/components/Puck/styles.module.css#css-module
|
6341
5987
|
init_react_import();
|
6342
|
-
var
|
5988
|
+
var styles_module_default14 = { "Puck": "_Puck_mc1k2_19", "Puck-portal": "_Puck-portal_mc1k2_24", "PuckLayout-inner": "_PuckLayout-inner_mc1k2_31", "PuckLayout--mounted": "_PuckLayout--mounted_mc1k2_43", "PuckLayout--leftSideBarVisible": "_PuckLayout--leftSideBarVisible_mc1k2_47", "PuckLayout--rightSideBarVisible": "_PuckLayout--rightSideBarVisible_mc1k2_53", "PuckLayout-mounted": "_PuckLayout-mounted_mc1k2_67", "PuckLayout": "_PuckLayout_mc1k2_31", "PuckLayout-leftSideBar": "_PuckLayout-leftSideBar_mc1k2_108", "PuckLayout-rightSideBar": "_PuckLayout-rightSideBar_mc1k2_117" };
|
6343
5989
|
|
6344
5990
|
// components/Puck/components/Fields/index.tsx
|
6345
5991
|
init_react_import();
|
6346
5992
|
|
6347
5993
|
// css-module:/home/runner/work/puck/puck/packages/core/components/Puck/components/Fields/styles.module.css#css-module
|
6348
5994
|
init_react_import();
|
6349
|
-
var
|
5995
|
+
var styles_module_default15 = { "PuckFields": "_PuckFields_10bh7_1", "PuckFields--isLoading": "_PuckFields--isLoading_10bh7_6", "PuckFields-loadingOverlay": "_PuckFields-loadingOverlay_10bh7_10", "PuckFields-loadingOverlayInner": "_PuckFields-loadingOverlayInner_10bh7_25", "PuckFields-field": "_PuckFields-field_10bh7_32", "PuckFields--wrapFields": "_PuckFields--wrapFields_10bh7_36" };
|
6350
5996
|
|
6351
5997
|
// components/Puck/components/Fields/index.tsx
|
6352
|
-
import { useCallback as
|
6353
|
-
import { useShallow as
|
6354
|
-
import { Fragment as
|
6355
|
-
var
|
5998
|
+
import { memo as memo2, useCallback as useCallback12, useMemo as useMemo13 } from "react";
|
5999
|
+
import { useShallow as useShallow5 } from "zustand/react/shallow";
|
6000
|
+
import { Fragment as Fragment7, jsx as jsx27, jsxs as jsxs13 } from "react/jsx-runtime";
|
6001
|
+
var getClassName20 = get_class_name_factory_default("PuckFields", styles_module_default15);
|
6356
6002
|
var DefaultFields = ({
|
6357
6003
|
children
|
6358
6004
|
}) => {
|
6359
|
-
return /* @__PURE__ */
|
6005
|
+
return /* @__PURE__ */ jsx27(Fragment7, { children });
|
6360
6006
|
};
|
6361
6007
|
var createOnChange = (fieldName, appStore) => (value, updatedUi) => __async(void 0, null, function* () {
|
6362
6008
|
let currentProps;
|
@@ -6416,18 +6062,19 @@ var FieldsChild = ({ fieldName }) => {
|
|
6416
6062
|
return s.selectedItem ? `${s.selectedItem.props.id}_${field.type}_${fieldName}` : `root_${field.type}_${fieldName}`;
|
6417
6063
|
});
|
6418
6064
|
const permissions = useAppStore(
|
6419
|
-
|
6065
|
+
useShallow5((s) => {
|
6420
6066
|
const { selectedItem, permissions: permissions2 } = s;
|
6421
6067
|
return selectedItem ? permissions2.getPermissions({ item: selectedItem }) : permissions2.getPermissions({ root: true });
|
6422
6068
|
})
|
6423
6069
|
);
|
6424
6070
|
const appStore = useAppStoreApi();
|
6425
|
-
const onChange =
|
6071
|
+
const onChange = useCallback12(createOnChange(fieldName, appStore), [
|
6426
6072
|
fieldName
|
6427
6073
|
]);
|
6428
|
-
|
6074
|
+
const { visible = true } = field != null ? field : {};
|
6075
|
+
if (!field || !id || !visible) return null;
|
6429
6076
|
if (field.type === "slot") return null;
|
6430
|
-
return /* @__PURE__ */
|
6077
|
+
return /* @__PURE__ */ jsx27("div", { className: getClassName20("field"), children: /* @__PURE__ */ jsx27(
|
6431
6078
|
AutoFieldPrivate,
|
6432
6079
|
{
|
6433
6080
|
field,
|
@@ -6439,14 +6086,15 @@ var FieldsChild = ({ fieldName }) => {
|
|
6439
6086
|
}
|
6440
6087
|
) }, id);
|
6441
6088
|
};
|
6442
|
-
var
|
6089
|
+
var FieldsChildMemo = memo2(FieldsChild);
|
6090
|
+
var FieldsInternal = ({ wrapFields = true }) => {
|
6443
6091
|
const overrides = useAppStore((s) => s.overrides);
|
6444
6092
|
const componentResolving = useAppStore((s) => {
|
6445
6093
|
var _a, _b;
|
6446
6094
|
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;
|
6447
6095
|
return (loadingCount != null ? loadingCount : 0) > 0;
|
6448
6096
|
});
|
6449
|
-
const itemSelector = useAppStore(
|
6097
|
+
const itemSelector = useAppStore(useShallow5((s) => s.state.ui.itemSelector));
|
6450
6098
|
const id = useAppStore((s) => {
|
6451
6099
|
var _a;
|
6452
6100
|
return (_a = s.selectedItem) == null ? void 0 : _a.props.id;
|
@@ -6455,42 +6103,48 @@ var Fields = ({ wrapFields = true }) => {
|
|
6455
6103
|
useRegisterFieldsSlice(appStore, id);
|
6456
6104
|
const fieldsLoading = useAppStore((s) => s.fields.loading);
|
6457
6105
|
const fieldNames = useAppStore(
|
6458
|
-
|
6106
|
+
useShallow5((s) => {
|
6107
|
+
if (s.fields.id === id) {
|
6108
|
+
return Object.keys(s.fields.fields);
|
6109
|
+
}
|
6110
|
+
return [];
|
6111
|
+
})
|
6459
6112
|
);
|
6460
6113
|
const isLoading = fieldsLoading || componentResolving;
|
6461
6114
|
const Wrapper = useMemo13(() => overrides.fields || DefaultFields, [overrides]);
|
6462
|
-
return /* @__PURE__ */
|
6115
|
+
return /* @__PURE__ */ jsxs13(
|
6463
6116
|
"form",
|
6464
6117
|
{
|
6465
|
-
className:
|
6118
|
+
className: getClassName20({ wrapFields }),
|
6466
6119
|
onSubmit: (e) => {
|
6467
6120
|
e.preventDefault();
|
6468
6121
|
},
|
6469
6122
|
children: [
|
6470
|
-
/* @__PURE__ */
|
6471
|
-
isLoading && /* @__PURE__ */
|
6123
|
+
/* @__PURE__ */ jsx27(Wrapper, { isLoading, itemSelector, children: fieldNames.map((fieldName) => /* @__PURE__ */ jsx27(FieldsChildMemo, { fieldName }, fieldName)) }),
|
6124
|
+
isLoading && /* @__PURE__ */ jsx27("div", { className: getClassName20("loadingOverlay"), children: /* @__PURE__ */ jsx27("div", { className: getClassName20("loadingOverlayInner"), children: /* @__PURE__ */ jsx27(Loader, { size: 16 }) }) })
|
6472
6125
|
]
|
6473
6126
|
}
|
6474
6127
|
);
|
6475
6128
|
};
|
6129
|
+
var Fields = memo2(FieldsInternal);
|
6476
6130
|
|
6477
6131
|
// components/Puck/components/Components/index.tsx
|
6478
6132
|
init_react_import();
|
6479
6133
|
|
6480
6134
|
// lib/use-component-list.tsx
|
6481
6135
|
init_react_import();
|
6482
|
-
import { useEffect as
|
6136
|
+
import { useEffect as useEffect18, useState as useState16 } from "react";
|
6483
6137
|
|
6484
6138
|
// components/ComponentList/index.tsx
|
6485
6139
|
init_react_import();
|
6486
6140
|
|
6487
6141
|
// css-module:/home/runner/work/puck/puck/packages/core/components/ComponentList/styles.module.css#css-module
|
6488
6142
|
init_react_import();
|
6489
|
-
var
|
6143
|
+
var styles_module_default16 = { "ComponentList": "_ComponentList_1rrlt_1", "ComponentList--isExpanded": "_ComponentList--isExpanded_1rrlt_5", "ComponentList-content": "_ComponentList-content_1rrlt_9", "ComponentList-title": "_ComponentList-title_1rrlt_17", "ComponentList-titleIcon": "_ComponentList-titleIcon_1rrlt_53" };
|
6490
6144
|
|
6491
6145
|
// components/ComponentList/index.tsx
|
6492
|
-
import { jsx as
|
6493
|
-
var
|
6146
|
+
import { jsx as jsx28, jsxs as jsxs14 } from "react/jsx-runtime";
|
6147
|
+
var getClassName21 = get_class_name_factory_default("ComponentList", styles_module_default16);
|
6494
6148
|
var ComponentListItem = ({
|
6495
6149
|
name,
|
6496
6150
|
label
|
@@ -6501,7 +6155,7 @@ var ComponentListItem = ({
|
|
6501
6155
|
type: name
|
6502
6156
|
}).insert
|
6503
6157
|
);
|
6504
|
-
return /* @__PURE__ */
|
6158
|
+
return /* @__PURE__ */ jsx28(Drawer.Item, { label, name, isDragDisabled: !canInsert, children: overrides.componentItem });
|
6505
6159
|
};
|
6506
6160
|
var ComponentList = ({
|
6507
6161
|
children,
|
@@ -6512,12 +6166,12 @@ var ComponentList = ({
|
|
6512
6166
|
const setUi = useAppStore((s) => s.setUi);
|
6513
6167
|
const componentList = useAppStore((s) => s.state.ui.componentList);
|
6514
6168
|
const { expanded = true } = componentList[id] || {};
|
6515
|
-
return /* @__PURE__ */
|
6516
|
-
title && /* @__PURE__ */
|
6169
|
+
return /* @__PURE__ */ jsxs14("div", { className: getClassName21({ isExpanded: expanded }), children: [
|
6170
|
+
title && /* @__PURE__ */ jsxs14(
|
6517
6171
|
"button",
|
6518
6172
|
{
|
6519
6173
|
type: "button",
|
6520
|
-
className:
|
6174
|
+
className: getClassName21("title"),
|
6521
6175
|
onClick: () => setUi({
|
6522
6176
|
componentList: __spreadProps(__spreadValues({}, componentList), {
|
6523
6177
|
[id]: __spreadProps(__spreadValues({}, componentList[id]), {
|
@@ -6527,14 +6181,14 @@ var ComponentList = ({
|
|
6527
6181
|
}),
|
6528
6182
|
title: expanded ? `Collapse${title ? ` ${title}` : ""}` : `Expand${title ? ` ${title}` : ""}`,
|
6529
6183
|
children: [
|
6530
|
-
/* @__PURE__ */
|
6531
|
-
/* @__PURE__ */
|
6184
|
+
/* @__PURE__ */ jsx28("div", { children: title }),
|
6185
|
+
/* @__PURE__ */ jsx28("div", { className: getClassName21("titleIcon"), children: expanded ? /* @__PURE__ */ jsx28(ChevronUp, { size: 12 }) : /* @__PURE__ */ jsx28(ChevronDown, { size: 12 }) })
|
6532
6186
|
]
|
6533
6187
|
}
|
6534
6188
|
),
|
6535
|
-
/* @__PURE__ */
|
6189
|
+
/* @__PURE__ */ jsx28("div", { className: getClassName21("content"), children: /* @__PURE__ */ jsx28(Drawer, { children: children || Object.keys(config.components).map((componentKey) => {
|
6536
6190
|
var _a;
|
6537
|
-
return /* @__PURE__ */
|
6191
|
+
return /* @__PURE__ */ jsx28(
|
6538
6192
|
ComponentListItem,
|
6539
6193
|
{
|
6540
6194
|
label: (_a = config.components[componentKey]["label"]) != null ? _a : componentKey,
|
@@ -6548,12 +6202,12 @@ var ComponentList = ({
|
|
6548
6202
|
ComponentList.Item = ComponentListItem;
|
6549
6203
|
|
6550
6204
|
// lib/use-component-list.tsx
|
6551
|
-
import { jsx as
|
6205
|
+
import { jsx as jsx29 } from "react/jsx-runtime";
|
6552
6206
|
var useComponentList = () => {
|
6553
6207
|
const [componentList, setComponentList] = useState16();
|
6554
6208
|
const config = useAppStore((s) => s.config);
|
6555
6209
|
const uiComponentList = useAppStore((s) => s.state.ui.componentList);
|
6556
|
-
|
6210
|
+
useEffect18(() => {
|
6557
6211
|
var _a, _b, _c;
|
6558
6212
|
if (Object.keys(uiComponentList).length > 0) {
|
6559
6213
|
const matchedComponents = [];
|
@@ -6563,7 +6217,7 @@ var useComponentList = () => {
|
|
6563
6217
|
if (category.visible === false || !category.components) {
|
6564
6218
|
return null;
|
6565
6219
|
}
|
6566
|
-
return /* @__PURE__ */
|
6220
|
+
return /* @__PURE__ */ jsx29(
|
6567
6221
|
ComponentList,
|
6568
6222
|
{
|
6569
6223
|
id: categoryKey,
|
@@ -6572,7 +6226,7 @@ var useComponentList = () => {
|
|
6572
6226
|
var _a2;
|
6573
6227
|
matchedComponents.push(componentName);
|
6574
6228
|
const componentConf = config.components[componentName] || {};
|
6575
|
-
return /* @__PURE__ */
|
6229
|
+
return /* @__PURE__ */ jsx29(
|
6576
6230
|
ComponentList.Item,
|
6577
6231
|
{
|
6578
6232
|
label: (_a2 = componentConf["label"]) != null ? _a2 : componentName,
|
@@ -6592,7 +6246,7 @@ var useComponentList = () => {
|
|
6592
6246
|
);
|
6593
6247
|
if (remainingComponents.length > 0 && !((_a = uiComponentList.other) == null ? void 0 : _a.components) && ((_b = uiComponentList.other) == null ? void 0 : _b.visible) !== false) {
|
6594
6248
|
_componentList.push(
|
6595
|
-
/* @__PURE__ */
|
6249
|
+
/* @__PURE__ */ jsx29(
|
6596
6250
|
ComponentList,
|
6597
6251
|
{
|
6598
6252
|
id: "other",
|
@@ -6600,7 +6254,7 @@ var useComponentList = () => {
|
|
6600
6254
|
children: remainingComponents.map((componentName, i) => {
|
6601
6255
|
var _a2;
|
6602
6256
|
const componentConf = config.components[componentName] || {};
|
6603
|
-
return /* @__PURE__ */
|
6257
|
+
return /* @__PURE__ */ jsx29(
|
6604
6258
|
ComponentList.Item,
|
6605
6259
|
{
|
6606
6260
|
name: componentName,
|
@@ -6623,29 +6277,29 @@ var useComponentList = () => {
|
|
6623
6277
|
|
6624
6278
|
// components/Puck/components/Components/index.tsx
|
6625
6279
|
import { useMemo as useMemo14 } from "react";
|
6626
|
-
import { jsx as
|
6280
|
+
import { jsx as jsx30 } from "react/jsx-runtime";
|
6627
6281
|
var Components = () => {
|
6628
6282
|
const overrides = useAppStore((s) => s.overrides);
|
6629
6283
|
const componentList = useComponentList();
|
6630
6284
|
const Wrapper = useMemo14(() => overrides.components || "div", [overrides]);
|
6631
|
-
return /* @__PURE__ */
|
6285
|
+
return /* @__PURE__ */ jsx30(Wrapper, { children: componentList ? componentList : /* @__PURE__ */ jsx30(ComponentList, { id: "all" }) });
|
6632
6286
|
};
|
6633
6287
|
|
6634
6288
|
// components/Puck/components/Preview/index.tsx
|
6635
6289
|
init_react_import();
|
6636
|
-
import { useCallback as
|
6290
|
+
import { useCallback as useCallback13, useEffect as useEffect20, useRef as useRef6, useMemo as useMemo15 } from "react";
|
6637
6291
|
|
6638
6292
|
// components/AutoFrame/index.tsx
|
6639
6293
|
init_react_import();
|
6640
6294
|
import {
|
6641
6295
|
createContext as createContext5,
|
6642
|
-
useContext as
|
6643
|
-
useEffect as
|
6296
|
+
useContext as useContext9,
|
6297
|
+
useEffect as useEffect19,
|
6644
6298
|
useState as useState17
|
6645
6299
|
} from "react";
|
6646
6300
|
import hash from "object-hash";
|
6647
6301
|
import { createPortal as createPortal3 } from "react-dom";
|
6648
|
-
import { Fragment as
|
6302
|
+
import { Fragment as Fragment8, jsx as jsx31 } from "react/jsx-runtime";
|
6649
6303
|
var styleSelector = 'style, link[rel="stylesheet"]';
|
6650
6304
|
var collectStyles = (doc) => {
|
6651
6305
|
const collected = [];
|
@@ -6688,7 +6342,7 @@ var CopyHostStyles = ({
|
|
6688
6342
|
onStylesLoaded = () => null
|
6689
6343
|
}) => {
|
6690
6344
|
const { document: doc, window: win } = useFrame();
|
6691
|
-
|
6345
|
+
useEffect19(() => {
|
6692
6346
|
if (!win || !doc) {
|
6693
6347
|
return () => {
|
6694
6348
|
};
|
@@ -6845,10 +6499,10 @@ var CopyHostStyles = ({
|
|
6845
6499
|
observer.disconnect();
|
6846
6500
|
};
|
6847
6501
|
}, []);
|
6848
|
-
return /* @__PURE__ */
|
6502
|
+
return /* @__PURE__ */ jsx31(Fragment8, { children });
|
6849
6503
|
};
|
6850
6504
|
var autoFrameContext = createContext5({});
|
6851
|
-
var useFrame = () =>
|
6505
|
+
var useFrame = () => useContext9(autoFrameContext);
|
6852
6506
|
function AutoFrame(_a) {
|
6853
6507
|
var _b = _a, {
|
6854
6508
|
children,
|
@@ -6873,7 +6527,7 @@ function AutoFrame(_a) {
|
|
6873
6527
|
const [ctx, setCtx] = useState17({});
|
6874
6528
|
const [mountTarget, setMountTarget] = useState17();
|
6875
6529
|
const [stylesLoaded, setStylesLoaded] = useState17(false);
|
6876
|
-
|
6530
|
+
useEffect19(() => {
|
6877
6531
|
var _a2;
|
6878
6532
|
if (frameRef.current) {
|
6879
6533
|
const doc = frameRef.current.contentDocument;
|
@@ -6892,7 +6546,7 @@ function AutoFrame(_a) {
|
|
6892
6546
|
}
|
6893
6547
|
}
|
6894
6548
|
}, [frameRef, loaded, stylesLoaded]);
|
6895
|
-
return /* @__PURE__ */
|
6549
|
+
return /* @__PURE__ */ jsx31(
|
6896
6550
|
"iframe",
|
6897
6551
|
__spreadProps(__spreadValues({}, props), {
|
6898
6552
|
className,
|
@@ -6902,7 +6556,7 @@ function AutoFrame(_a) {
|
|
6902
6556
|
onLoad: () => {
|
6903
6557
|
setLoaded(true);
|
6904
6558
|
},
|
6905
|
-
children: /* @__PURE__ */
|
6559
|
+
children: /* @__PURE__ */ jsx31(autoFrameContext.Provider, { value: ctx, children: loaded && mountTarget && /* @__PURE__ */ jsx31(
|
6906
6560
|
CopyHostStyles,
|
6907
6561
|
{
|
6908
6562
|
debug,
|
@@ -6918,14 +6572,14 @@ var AutoFrame_default = AutoFrame;
|
|
6918
6572
|
|
6919
6573
|
// css-module:/home/runner/work/puck/puck/packages/core/components/Puck/components/Preview/styles.module.css#css-module
|
6920
6574
|
init_react_import();
|
6921
|
-
var
|
6575
|
+
var styles_module_default17 = { "PuckPreview": "_PuckPreview_z2rgu_1", "PuckPreview-frame": "_PuckPreview-frame_z2rgu_6" };
|
6922
6576
|
|
6923
6577
|
// components/Puck/components/Preview/index.tsx
|
6924
|
-
import { Fragment as
|
6925
|
-
var
|
6578
|
+
import { Fragment as Fragment9, jsx as jsx32 } from "react/jsx-runtime";
|
6579
|
+
var getClassName22 = get_class_name_factory_default("PuckPreview", styles_module_default17);
|
6926
6580
|
var useBubbleIframeEvents = (ref) => {
|
6927
6581
|
const status = useAppStore((s) => s.status);
|
6928
|
-
|
6582
|
+
useEffect20(() => {
|
6929
6583
|
if (ref.current && status === "READY") {
|
6930
6584
|
const iframe = ref.current;
|
6931
6585
|
const handlePointerMove = (event) => {
|
@@ -6963,7 +6617,7 @@ var useBubbleIframeEvents = (ref) => {
|
|
6963
6617
|
}
|
6964
6618
|
}, [status]);
|
6965
6619
|
};
|
6966
|
-
var
|
6620
|
+
var Preview2 = ({ id = "puck-preview" }) => {
|
6967
6621
|
const dispatch = useAppStore((s) => s.dispatch);
|
6968
6622
|
const root = useAppStore((s) => s.state.data.root);
|
6969
6623
|
const config = useAppStore((s) => s.config);
|
@@ -6974,22 +6628,25 @@ var Preview3 = ({ id = "puck-preview" }) => {
|
|
6974
6628
|
const renderData = useAppStore(
|
6975
6629
|
(s) => s.state.ui.previewMode === "edit" ? null : s.state.data
|
6976
6630
|
);
|
6977
|
-
const Page =
|
6631
|
+
const Page = useCallback13(
|
6978
6632
|
(pageProps) => {
|
6979
6633
|
var _a, _b;
|
6980
|
-
const
|
6981
|
-
|
6634
|
+
const propsWithSlots = useSlots(
|
6635
|
+
config,
|
6636
|
+
{ type: "root", props: pageProps },
|
6637
|
+
DropZoneEditPure
|
6638
|
+
);
|
6982
6639
|
return ((_a = config.root) == null ? void 0 : _a.render) ? (_b = config.root) == null ? void 0 : _b.render(__spreadValues({
|
6983
6640
|
id: "puck-root"
|
6984
|
-
}, propsWithSlots)) : /* @__PURE__ */
|
6641
|
+
}, propsWithSlots)) : /* @__PURE__ */ jsx32(Fragment9, { children: propsWithSlots.children });
|
6985
6642
|
},
|
6986
|
-
[config
|
6643
|
+
[config]
|
6987
6644
|
);
|
6988
6645
|
const Frame = useMemo15(() => overrides.iframe, [overrides]);
|
6989
6646
|
const rootProps = root.props || root;
|
6990
|
-
const ref =
|
6647
|
+
const ref = useRef6(null);
|
6991
6648
|
useBubbleIframeEvents(ref);
|
6992
|
-
const inner = !renderData ? /* @__PURE__ */
|
6649
|
+
const inner = !renderData ? /* @__PURE__ */ jsx32(
|
6993
6650
|
Page,
|
6994
6651
|
__spreadProps(__spreadValues({}, rootProps), {
|
6995
6652
|
puck: {
|
@@ -6999,28 +6656,28 @@ var Preview3 = ({ id = "puck-preview" }) => {
|
|
6999
6656
|
metadata
|
7000
6657
|
},
|
7001
6658
|
editMode: true,
|
7002
|
-
children: /* @__PURE__ */
|
6659
|
+
children: /* @__PURE__ */ jsx32(DropZonePure, { zone: rootDroppableId })
|
7003
6660
|
})
|
7004
|
-
) : /* @__PURE__ */
|
7005
|
-
|
6661
|
+
) : /* @__PURE__ */ jsx32(Render, { data: renderData, config });
|
6662
|
+
useEffect20(() => {
|
7006
6663
|
if (!iframe.enabled) {
|
7007
6664
|
setStatus("READY");
|
7008
6665
|
}
|
7009
6666
|
}, [iframe.enabled]);
|
7010
|
-
return /* @__PURE__ */
|
6667
|
+
return /* @__PURE__ */ jsx32(
|
7011
6668
|
"div",
|
7012
6669
|
{
|
7013
|
-
className:
|
6670
|
+
className: getClassName22(),
|
7014
6671
|
id,
|
7015
6672
|
"data-puck-preview": true,
|
7016
6673
|
onClick: () => {
|
7017
6674
|
dispatch({ type: "setUi", ui: { itemSelector: null } });
|
7018
6675
|
},
|
7019
|
-
children: iframe.enabled ? /* @__PURE__ */
|
6676
|
+
children: iframe.enabled ? /* @__PURE__ */ jsx32(
|
7020
6677
|
AutoFrame_default,
|
7021
6678
|
{
|
7022
6679
|
id: "preview-frame",
|
7023
|
-
className:
|
6680
|
+
className: getClassName22("frame"),
|
7024
6681
|
"data-rfd-iframe": true,
|
7025
6682
|
onReady: () => {
|
7026
6683
|
setStatus("READY");
|
@@ -7029,18 +6686,18 @@ var Preview3 = ({ id = "puck-preview" }) => {
|
|
7029
6686
|
setStatus("MOUNTED");
|
7030
6687
|
},
|
7031
6688
|
frameRef: ref,
|
7032
|
-
children: /* @__PURE__ */
|
6689
|
+
children: /* @__PURE__ */ jsx32(autoFrameContext.Consumer, { children: ({ document: document2 }) => {
|
7033
6690
|
if (Frame) {
|
7034
|
-
return /* @__PURE__ */
|
6691
|
+
return /* @__PURE__ */ jsx32(Frame, { document: document2, children: inner });
|
7035
6692
|
}
|
7036
6693
|
return inner;
|
7037
6694
|
} })
|
7038
6695
|
}
|
7039
|
-
) : /* @__PURE__ */
|
6696
|
+
) : /* @__PURE__ */ jsx32(
|
7040
6697
|
"div",
|
7041
6698
|
{
|
7042
6699
|
id: "preview-frame",
|
7043
|
-
className:
|
6700
|
+
className: getClassName22("frame"),
|
7044
6701
|
ref,
|
7045
6702
|
"data-puck-entry": true,
|
7046
6703
|
children: inner
|
@@ -7058,7 +6715,7 @@ init_react_import();
|
|
7058
6715
|
|
7059
6716
|
// css-module:/home/runner/work/puck/puck/packages/core/components/LayerTree/styles.module.css#css-module
|
7060
6717
|
init_react_import();
|
7061
|
-
var
|
6718
|
+
var styles_module_default18 = { "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" };
|
7062
6719
|
|
7063
6720
|
// lib/scroll-into-view.ts
|
7064
6721
|
init_react_import();
|
@@ -7072,7 +6729,7 @@ var scrollIntoView = (el) => {
|
|
7072
6729
|
};
|
7073
6730
|
|
7074
6731
|
// components/LayerTree/index.tsx
|
7075
|
-
import { useCallback as
|
6732
|
+
import { useCallback as useCallback14, useContext as useContext10 } from "react";
|
7076
6733
|
|
7077
6734
|
// lib/on-scroll-end.ts
|
7078
6735
|
init_react_import();
|
@@ -7094,21 +6751,21 @@ var onScrollEnd = (frame, cb) => {
|
|
7094
6751
|
};
|
7095
6752
|
|
7096
6753
|
// components/LayerTree/index.tsx
|
7097
|
-
import { useShallow as
|
7098
|
-
import { Fragment as
|
7099
|
-
var
|
7100
|
-
var getClassNameLayer = get_class_name_factory_default("Layer",
|
6754
|
+
import { useShallow as useShallow6 } from "zustand/react/shallow";
|
6755
|
+
import { Fragment as Fragment10, jsx as jsx33, jsxs as jsxs15 } from "react/jsx-runtime";
|
6756
|
+
var getClassName23 = get_class_name_factory_default("LayerTree", styles_module_default18);
|
6757
|
+
var getClassNameLayer = get_class_name_factory_default("Layer", styles_module_default18);
|
7101
6758
|
var Layer = ({
|
7102
6759
|
index,
|
7103
6760
|
itemId,
|
7104
6761
|
zoneCompound
|
7105
6762
|
}) => {
|
7106
6763
|
var _a;
|
7107
|
-
const ctx =
|
6764
|
+
const ctx = useContext10(dropZoneContext);
|
7108
6765
|
const config = useAppStore((s) => s.config);
|
7109
6766
|
const itemSelector = useAppStore((s) => s.state.ui.itemSelector);
|
7110
6767
|
const dispatch = useAppStore((s) => s.dispatch);
|
7111
|
-
const setItemSelector =
|
6768
|
+
const setItemSelector = useCallback14(
|
7112
6769
|
(itemSelector2) => {
|
7113
6770
|
dispatch({ type: "setUi", ui: { itemSelector: itemSelector2 } });
|
7114
6771
|
},
|
@@ -7121,16 +6778,18 @@ var Layer = ({
|
|
7121
6778
|
const isSelected = selecedItemId === itemId || itemSelector && itemSelector.zone === rootDroppableId && !zoneCompound;
|
7122
6779
|
const nodeData = useAppStore((s) => s.state.indexes.nodes[itemId]);
|
7123
6780
|
const zonesForItem = useAppStore(
|
7124
|
-
|
6781
|
+
useShallow6(
|
7125
6782
|
(s) => Object.keys(s.state.indexes.zones).filter(
|
7126
6783
|
(z) => z.split(":")[0] === itemId
|
7127
6784
|
)
|
7128
6785
|
)
|
7129
6786
|
);
|
7130
6787
|
const containsZone = zonesForItem.length > 0;
|
7131
|
-
const
|
7132
|
-
|
7133
|
-
|
6788
|
+
const zoneStore = useContext10(ZoneStoreContext);
|
6789
|
+
const isHovering = useContextStore(
|
6790
|
+
ZoneStoreContext,
|
6791
|
+
(s) => s.hoveringComponent === itemId
|
6792
|
+
);
|
7134
6793
|
const childIsSelected = useAppStore((s) => {
|
7135
6794
|
var _a2, _b;
|
7136
6795
|
const selectedData = s.state.indexes.nodes[(_a2 = s.selectedItem) == null ? void 0 : _a2.props.id];
|
@@ -7141,7 +6800,7 @@ var Layer = ({
|
|
7141
6800
|
});
|
7142
6801
|
const componentConfig = config.components[nodeData.data.type];
|
7143
6802
|
const label = (_a = componentConfig == null ? void 0 : componentConfig["label"]) != null ? _a : nodeData.data.type.toString();
|
7144
|
-
return /* @__PURE__ */
|
6803
|
+
return /* @__PURE__ */ jsxs15(
|
7145
6804
|
"li",
|
7146
6805
|
{
|
7147
6806
|
className: getClassNameLayer({
|
@@ -7151,7 +6810,7 @@ var Layer = ({
|
|
7151
6810
|
childIsSelected
|
7152
6811
|
}),
|
7153
6812
|
children: [
|
7154
|
-
/* @__PURE__ */
|
6813
|
+
/* @__PURE__ */ jsx33("div", { className: getClassNameLayer("inner"), children: /* @__PURE__ */ jsxs15(
|
7155
6814
|
"button",
|
7156
6815
|
{
|
7157
6816
|
type: "button",
|
@@ -7166,7 +6825,10 @@ var Layer = ({
|
|
7166
6825
|
`[data-puck-component="${itemId}"]`
|
7167
6826
|
);
|
7168
6827
|
if (!el) {
|
7169
|
-
|
6828
|
+
setItemSelector({
|
6829
|
+
index,
|
6830
|
+
zone: zoneCompound
|
6831
|
+
});
|
7170
6832
|
return;
|
7171
6833
|
}
|
7172
6834
|
scrollIntoView(el);
|
@@ -7177,31 +6839,31 @@ var Layer = ({
|
|
7177
6839
|
});
|
7178
6840
|
});
|
7179
6841
|
},
|
7180
|
-
|
6842
|
+
onMouseEnter: (e) => {
|
7181
6843
|
e.stopPropagation();
|
7182
|
-
|
6844
|
+
zoneStore.setState({ hoveringComponent: itemId });
|
7183
6845
|
},
|
7184
|
-
|
6846
|
+
onMouseLeave: (e) => {
|
7185
6847
|
e.stopPropagation();
|
7186
|
-
|
6848
|
+
zoneStore.setState({ hoveringComponent: null });
|
7187
6849
|
},
|
7188
6850
|
children: [
|
7189
|
-
containsZone && /* @__PURE__ */
|
6851
|
+
containsZone && /* @__PURE__ */ jsx33(
|
7190
6852
|
"div",
|
7191
6853
|
{
|
7192
6854
|
className: getClassNameLayer("chevron"),
|
7193
6855
|
title: isSelected ? "Collapse" : "Expand",
|
7194
|
-
children: /* @__PURE__ */
|
6856
|
+
children: /* @__PURE__ */ jsx33(ChevronDown, { size: "12" })
|
7195
6857
|
}
|
7196
6858
|
),
|
7197
|
-
/* @__PURE__ */
|
7198
|
-
/* @__PURE__ */
|
7199
|
-
/* @__PURE__ */
|
6859
|
+
/* @__PURE__ */ jsxs15("div", { className: getClassNameLayer("title"), children: [
|
6860
|
+
/* @__PURE__ */ jsx33("div", { className: getClassNameLayer("icon"), children: nodeData.data.type === "Text" || nodeData.data.type === "Heading" ? /* @__PURE__ */ jsx33(Type, { size: "16" }) : /* @__PURE__ */ jsx33(LayoutGrid, { size: "16" }) }),
|
6861
|
+
/* @__PURE__ */ jsx33("div", { className: getClassNameLayer("name"), children: label })
|
7200
6862
|
] })
|
7201
6863
|
]
|
7202
6864
|
}
|
7203
6865
|
) }),
|
7204
|
-
containsZone && zonesForItem.map((subzone) => /* @__PURE__ */
|
6866
|
+
containsZone && zonesForItem.map((subzone) => /* @__PURE__ */ jsx33("div", { className: getClassNameLayer("zones"), children: /* @__PURE__ */ jsx33(LayerTree, { zoneCompound: subzone }) }, subzone))
|
7205
6867
|
]
|
7206
6868
|
}
|
7207
6869
|
);
|
@@ -7212,22 +6874,22 @@ var LayerTree = ({
|
|
7212
6874
|
}) => {
|
7213
6875
|
const label = _label != null ? _label : zoneCompound.split(":")[1];
|
7214
6876
|
const contentIds = useAppStore(
|
7215
|
-
|
6877
|
+
useShallow6(
|
7216
6878
|
(s) => {
|
7217
6879
|
var _a, _b;
|
7218
6880
|
return zoneCompound ? (_b = (_a = s.state.indexes.zones[zoneCompound]) == null ? void 0 : _a.contentIds) != null ? _b : [] : [];
|
7219
6881
|
}
|
7220
6882
|
)
|
7221
6883
|
);
|
7222
|
-
return /* @__PURE__ */
|
7223
|
-
label && /* @__PURE__ */
|
7224
|
-
/* @__PURE__ */
|
6884
|
+
return /* @__PURE__ */ jsxs15(Fragment10, { children: [
|
6885
|
+
label && /* @__PURE__ */ jsxs15("div", { className: getClassName23("zoneTitle"), children: [
|
6886
|
+
/* @__PURE__ */ jsx33("div", { className: getClassName23("zoneIcon"), children: /* @__PURE__ */ jsx33(Layers, { size: "16" }) }),
|
7225
6887
|
label
|
7226
6888
|
] }),
|
7227
|
-
/* @__PURE__ */
|
7228
|
-
contentIds.length === 0 && /* @__PURE__ */
|
6889
|
+
/* @__PURE__ */ jsxs15("ul", { className: getClassName23(), children: [
|
6890
|
+
contentIds.length === 0 && /* @__PURE__ */ jsx33("div", { className: getClassName23("helper"), children: "No items" }),
|
7229
6891
|
contentIds.map((itemId, i) => {
|
7230
|
-
return /* @__PURE__ */
|
6892
|
+
return /* @__PURE__ */ jsx33(
|
7231
6893
|
Layer,
|
7232
6894
|
{
|
7233
6895
|
index: i,
|
@@ -7253,15 +6915,15 @@ var findZonesForArea = (state, area) => {
|
|
7253
6915
|
};
|
7254
6916
|
|
7255
6917
|
// components/Puck/components/Outline/index.tsx
|
7256
|
-
import { useShallow as
|
7257
|
-
import { jsx as
|
6918
|
+
import { useShallow as useShallow7 } from "zustand/react/shallow";
|
6919
|
+
import { jsx as jsx34 } from "react/jsx-runtime";
|
7258
6920
|
var Outline = () => {
|
7259
6921
|
const outlineOverride = useAppStore((s) => s.overrides.outline);
|
7260
6922
|
const rootZones = useAppStore(
|
7261
|
-
|
6923
|
+
useShallow7((s) => findZonesForArea(s.state, "root"))
|
7262
6924
|
);
|
7263
6925
|
const Wrapper = useMemo16(() => outlineOverride || "div", [outlineOverride]);
|
7264
|
-
return /* @__PURE__ */
|
6926
|
+
return /* @__PURE__ */ jsx34(Wrapper, { children: rootZones.map((zoneCompound) => /* @__PURE__ */ jsx34(
|
7265
6927
|
LayerTree,
|
7266
6928
|
{
|
7267
6929
|
label: rootZones.length === 1 ? "" : zoneCompound.split(":")[1],
|
@@ -7395,30 +7057,30 @@ var getBox = function getBox2(el) {
|
|
7395
7057
|
|
7396
7058
|
// components/Puck/components/Canvas/index.tsx
|
7397
7059
|
import {
|
7398
|
-
useCallback as
|
7399
|
-
useEffect as
|
7060
|
+
useCallback as useCallback15,
|
7061
|
+
useEffect as useEffect22,
|
7400
7062
|
useMemo as useMemo18,
|
7401
|
-
useRef as
|
7063
|
+
useRef as useRef7,
|
7402
7064
|
useState as useState19
|
7403
7065
|
} from "react";
|
7404
7066
|
|
7405
7067
|
// components/ViewportControls/index.tsx
|
7406
7068
|
init_react_import();
|
7407
|
-
import { useEffect as
|
7069
|
+
import { useEffect as useEffect21, useMemo as useMemo17, useState as useState18 } from "react";
|
7408
7070
|
|
7409
7071
|
// css-module:/home/runner/work/puck/puck/packages/core/components/ViewportControls/styles.module.css#css-module
|
7410
7072
|
init_react_import();
|
7411
|
-
var
|
7073
|
+
var styles_module_default19 = { "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" };
|
7412
7074
|
|
7413
7075
|
// components/ViewportControls/index.tsx
|
7414
|
-
import { jsx as
|
7076
|
+
import { jsx as jsx35, jsxs as jsxs16 } from "react/jsx-runtime";
|
7415
7077
|
var icons = {
|
7416
|
-
Smartphone: /* @__PURE__ */
|
7417
|
-
Tablet: /* @__PURE__ */
|
7418
|
-
Monitor: /* @__PURE__ */
|
7078
|
+
Smartphone: /* @__PURE__ */ jsx35(Smartphone, { size: 16 }),
|
7079
|
+
Tablet: /* @__PURE__ */ jsx35(Tablet, { size: 16 }),
|
7080
|
+
Monitor: /* @__PURE__ */ jsx35(Monitor, { size: 16 })
|
7419
7081
|
};
|
7420
|
-
var
|
7421
|
-
var getClassNameButton = get_class_name_factory_default("ViewportButton",
|
7082
|
+
var getClassName24 = get_class_name_factory_default("ViewportControls", styles_module_default19);
|
7083
|
+
var getClassNameButton = get_class_name_factory_default("ViewportButton", styles_module_default19);
|
7422
7084
|
var ViewportButton = ({
|
7423
7085
|
children,
|
7424
7086
|
height = "auto",
|
@@ -7428,10 +7090,10 @@ var ViewportButton = ({
|
|
7428
7090
|
}) => {
|
7429
7091
|
const viewports = useAppStore((s) => s.state.ui.viewports);
|
7430
7092
|
const [isActive, setIsActive] = useState18(false);
|
7431
|
-
|
7093
|
+
useEffect21(() => {
|
7432
7094
|
setIsActive(width === viewports.current.width);
|
7433
7095
|
}, [width, viewports.current.width]);
|
7434
|
-
return /* @__PURE__ */
|
7096
|
+
return /* @__PURE__ */ jsx35("span", { className: getClassNameButton({ isActive }), children: /* @__PURE__ */ jsx35(
|
7435
7097
|
IconButton,
|
7436
7098
|
{
|
7437
7099
|
title,
|
@@ -7440,7 +7102,7 @@ var ViewportButton = ({
|
|
7440
7102
|
e.stopPropagation();
|
7441
7103
|
onClick({ width, height });
|
7442
7104
|
},
|
7443
|
-
children: /* @__PURE__ */
|
7105
|
+
children: /* @__PURE__ */ jsx35("span", { className: getClassNameButton("inner"), children })
|
7444
7106
|
}
|
7445
7107
|
) });
|
7446
7108
|
};
|
@@ -7476,8 +7138,8 @@ var ViewportControls = ({
|
|
7476
7138
|
].filter((a) => a.value <= autoZoom).sort((a, b) => a.value > b.value ? 1 : -1),
|
7477
7139
|
[autoZoom]
|
7478
7140
|
);
|
7479
|
-
return /* @__PURE__ */
|
7480
|
-
viewports.map((viewport, i) => /* @__PURE__ */
|
7141
|
+
return /* @__PURE__ */ jsxs16("div", { className: getClassName24(), children: [
|
7142
|
+
viewports.map((viewport, i) => /* @__PURE__ */ jsx35(
|
7481
7143
|
ViewportButton,
|
7482
7144
|
{
|
7483
7145
|
height: viewport.height,
|
@@ -7488,8 +7150,8 @@ var ViewportControls = ({
|
|
7488
7150
|
},
|
7489
7151
|
i
|
7490
7152
|
)),
|
7491
|
-
/* @__PURE__ */
|
7492
|
-
/* @__PURE__ */
|
7153
|
+
/* @__PURE__ */ jsx35("div", { className: getClassName24("divider") }),
|
7154
|
+
/* @__PURE__ */ jsx35(
|
7493
7155
|
IconButton,
|
7494
7156
|
{
|
7495
7157
|
title: "Zoom viewport out",
|
@@ -7503,10 +7165,10 @@ var ViewportControls = ({
|
|
7503
7165
|
)].value
|
7504
7166
|
);
|
7505
7167
|
},
|
7506
|
-
children: /* @__PURE__ */
|
7168
|
+
children: /* @__PURE__ */ jsx35(ZoomOut, { size: 16 })
|
7507
7169
|
}
|
7508
7170
|
),
|
7509
|
-
/* @__PURE__ */
|
7171
|
+
/* @__PURE__ */ jsx35(
|
7510
7172
|
IconButton,
|
7511
7173
|
{
|
7512
7174
|
title: "Zoom viewport in",
|
@@ -7520,19 +7182,19 @@ var ViewportControls = ({
|
|
7520
7182
|
)].value
|
7521
7183
|
);
|
7522
7184
|
},
|
7523
|
-
children: /* @__PURE__ */
|
7185
|
+
children: /* @__PURE__ */ jsx35(ZoomIn, { size: 16 })
|
7524
7186
|
}
|
7525
7187
|
),
|
7526
|
-
/* @__PURE__ */
|
7527
|
-
/* @__PURE__ */
|
7188
|
+
/* @__PURE__ */ jsx35("div", { className: getClassName24("divider") }),
|
7189
|
+
/* @__PURE__ */ jsx35(
|
7528
7190
|
"select",
|
7529
7191
|
{
|
7530
|
-
className:
|
7192
|
+
className: getClassName24("zoomSelect"),
|
7531
7193
|
value: zoom.toString(),
|
7532
7194
|
onChange: (e) => {
|
7533
7195
|
onZoom(parseFloat(e.currentTarget.value));
|
7534
7196
|
},
|
7535
|
-
children: zoomOptions.map((option) => /* @__PURE__ */
|
7197
|
+
children: zoomOptions.map((option) => /* @__PURE__ */ jsx35(
|
7536
7198
|
"option",
|
7537
7199
|
{
|
7538
7200
|
value: option.value,
|
@@ -7547,7 +7209,7 @@ var ViewportControls = ({
|
|
7547
7209
|
|
7548
7210
|
// css-module:/home/runner/work/puck/puck/packages/core/components/Puck/components/Canvas/styles.module.css#css-module
|
7549
7211
|
init_react_import();
|
7550
|
-
var
|
7212
|
+
var styles_module_default20 = { "PuckCanvas": "_PuckCanvas_18jay_1", "PuckCanvas-controls": "_PuckCanvas-controls_18jay_16", "PuckCanvas-inner": "_PuckCanvas-inner_18jay_21", "PuckCanvas-root": "_PuckCanvas-root_18jay_30", "PuckCanvas--ready": "_PuckCanvas--ready_18jay_55", "PuckCanvas-loader": "_PuckCanvas-loader_18jay_60", "PuckCanvas--showLoader": "_PuckCanvas--showLoader_18jay_70" };
|
7551
7213
|
|
7552
7214
|
// lib/get-zoom-config.ts
|
7553
7215
|
init_react_import();
|
@@ -7580,9 +7242,9 @@ var getZoomConfig = (uiViewport, frame, zoom) => {
|
|
7580
7242
|
};
|
7581
7243
|
|
7582
7244
|
// components/Puck/components/Canvas/index.tsx
|
7583
|
-
import { useShallow as
|
7584
|
-
import { Fragment as
|
7585
|
-
var
|
7245
|
+
import { useShallow as useShallow8 } from "zustand/react/shallow";
|
7246
|
+
import { Fragment as Fragment11, jsx as jsx36, jsxs as jsxs17 } from "react/jsx-runtime";
|
7247
|
+
var getClassName25 = get_class_name_factory_default("PuckCanvas", styles_module_default20);
|
7586
7248
|
var ZOOM_ON_CHANGE = true;
|
7587
7249
|
var Canvas = () => {
|
7588
7250
|
const {
|
@@ -7594,7 +7256,7 @@ var Canvas = () => {
|
|
7594
7256
|
status,
|
7595
7257
|
iframe
|
7596
7258
|
} = useAppStore(
|
7597
|
-
|
7259
|
+
useShallow8((s) => ({
|
7598
7260
|
dispatch: s.dispatch,
|
7599
7261
|
overrides: s.overrides,
|
7600
7262
|
setUi: s.setUi,
|
@@ -7605,23 +7267,23 @@ var Canvas = () => {
|
|
7605
7267
|
}))
|
7606
7268
|
);
|
7607
7269
|
const { leftSideBarVisible, rightSideBarVisible, viewports } = useAppStore(
|
7608
|
-
|
7270
|
+
useShallow8((s) => ({
|
7609
7271
|
leftSideBarVisible: s.state.ui.leftSideBarVisible,
|
7610
7272
|
rightSideBarVisible: s.state.ui.rightSideBarVisible,
|
7611
7273
|
viewports: s.state.ui.viewports
|
7612
7274
|
}))
|
7613
7275
|
);
|
7614
|
-
const frameRef =
|
7276
|
+
const frameRef = useRef7(null);
|
7615
7277
|
const [showTransition, setShowTransition] = useState19(false);
|
7616
7278
|
const defaultRender = useMemo18(() => {
|
7617
|
-
const PuckDefault = ({ children }) => /* @__PURE__ */
|
7279
|
+
const PuckDefault = ({ children }) => /* @__PURE__ */ jsx36(Fragment11, { children });
|
7618
7280
|
return PuckDefault;
|
7619
7281
|
}, []);
|
7620
7282
|
const CustomPreview = useMemo18(
|
7621
7283
|
() => overrides.preview || defaultRender,
|
7622
7284
|
[overrides]
|
7623
7285
|
);
|
7624
|
-
const getFrameDimensions =
|
7286
|
+
const getFrameDimensions = useCallback15(() => {
|
7625
7287
|
if (frameRef.current) {
|
7626
7288
|
const frame = frameRef.current;
|
7627
7289
|
const box = getBox(frame);
|
@@ -7629,7 +7291,7 @@ var Canvas = () => {
|
|
7629
7291
|
}
|
7630
7292
|
return { width: 0, height: 0 };
|
7631
7293
|
}, [frameRef]);
|
7632
|
-
const resetAutoZoom =
|
7294
|
+
const resetAutoZoom = useCallback15(
|
7633
7295
|
(newViewports = viewports) => {
|
7634
7296
|
if (frameRef.current) {
|
7635
7297
|
setZoomConfig(
|
@@ -7643,11 +7305,11 @@ var Canvas = () => {
|
|
7643
7305
|
},
|
7644
7306
|
[frameRef, zoomConfig, viewports]
|
7645
7307
|
);
|
7646
|
-
|
7308
|
+
useEffect22(() => {
|
7647
7309
|
setShowTransition(false);
|
7648
7310
|
resetAutoZoom(viewports);
|
7649
7311
|
}, [frameRef, leftSideBarVisible, rightSideBarVisible]);
|
7650
|
-
|
7312
|
+
useEffect22(() => {
|
7651
7313
|
const { height: frameHeight } = getFrameDimensions();
|
7652
7314
|
if (viewports.current.height === "auto") {
|
7653
7315
|
setZoomConfig(__spreadProps(__spreadValues({}, zoomConfig), {
|
@@ -7655,13 +7317,13 @@ var Canvas = () => {
|
|
7655
7317
|
}));
|
7656
7318
|
}
|
7657
7319
|
}, [zoomConfig.zoom]);
|
7658
|
-
|
7320
|
+
useEffect22(() => {
|
7659
7321
|
if (ZOOM_ON_CHANGE) {
|
7660
7322
|
setShowTransition(true);
|
7661
7323
|
resetAutoZoom(viewports);
|
7662
7324
|
}
|
7663
7325
|
}, [viewports.current.width]);
|
7664
|
-
|
7326
|
+
useEffect22(() => {
|
7665
7327
|
const cb = () => {
|
7666
7328
|
setShowTransition(false);
|
7667
7329
|
resetAutoZoom();
|
@@ -7672,15 +7334,15 @@ var Canvas = () => {
|
|
7672
7334
|
};
|
7673
7335
|
}, []);
|
7674
7336
|
const [showLoader, setShowLoader] = useState19(false);
|
7675
|
-
|
7337
|
+
useEffect22(() => {
|
7676
7338
|
setTimeout(() => {
|
7677
7339
|
setShowLoader(true);
|
7678
7340
|
}, 500);
|
7679
7341
|
}, []);
|
7680
|
-
return /* @__PURE__ */
|
7342
|
+
return /* @__PURE__ */ jsxs17(
|
7681
7343
|
"div",
|
7682
7344
|
{
|
7683
|
-
className:
|
7345
|
+
className: getClassName25({
|
7684
7346
|
ready: status === "READY" || !iframe.enabled || !iframe.waitForStyles,
|
7685
7347
|
showLoader
|
7686
7348
|
}),
|
@@ -7690,7 +7352,7 @@ var Canvas = () => {
|
|
7690
7352
|
recordHistory: true
|
7691
7353
|
}),
|
7692
7354
|
children: [
|
7693
|
-
viewports.controlsVisible && iframe.enabled && /* @__PURE__ */
|
7355
|
+
viewports.controlsVisible && iframe.enabled && /* @__PURE__ */ jsx36("div", { className: getClassName25("controls"), children: /* @__PURE__ */ jsx36(
|
7694
7356
|
ViewportControls,
|
7695
7357
|
{
|
7696
7358
|
autoZoom: zoomConfig.autoZoom,
|
@@ -7716,11 +7378,11 @@ var Canvas = () => {
|
|
7716
7378
|
}
|
7717
7379
|
}
|
7718
7380
|
) }),
|
7719
|
-
/* @__PURE__ */
|
7720
|
-
/* @__PURE__ */
|
7381
|
+
/* @__PURE__ */ jsxs17("div", { className: getClassName25("inner"), ref: frameRef, children: [
|
7382
|
+
/* @__PURE__ */ jsx36(
|
7721
7383
|
"div",
|
7722
7384
|
{
|
7723
|
-
className:
|
7385
|
+
className: getClassName25("root"),
|
7724
7386
|
style: {
|
7725
7387
|
width: iframe.enabled ? viewports.current.width : "100%",
|
7726
7388
|
height: zoomConfig.rootHeight,
|
@@ -7738,10 +7400,10 @@ var Canvas = () => {
|
|
7738
7400
|
})
|
7739
7401
|
);
|
7740
7402
|
},
|
7741
|
-
children: /* @__PURE__ */
|
7403
|
+
children: /* @__PURE__ */ jsx36(CustomPreview, { children: /* @__PURE__ */ jsx36(Preview2, {}) })
|
7742
7404
|
}
|
7743
7405
|
),
|
7744
|
-
/* @__PURE__ */
|
7406
|
+
/* @__PURE__ */ jsx36("div", { className: getClassName25("loader"), children: /* @__PURE__ */ jsx36(Loader, { size: 24 }) })
|
7745
7407
|
] })
|
7746
7408
|
]
|
7747
7409
|
}
|
@@ -7796,19 +7458,19 @@ var useLoadedOverrides = ({
|
|
7796
7458
|
|
7797
7459
|
// components/DefaultOverride/index.tsx
|
7798
7460
|
init_react_import();
|
7799
|
-
import { Fragment as
|
7800
|
-
var DefaultOverride = ({ children }) => /* @__PURE__ */
|
7461
|
+
import { Fragment as Fragment12, jsx as jsx37 } from "react/jsx-runtime";
|
7462
|
+
var DefaultOverride = ({ children }) => /* @__PURE__ */ jsx37(Fragment12, { children });
|
7801
7463
|
|
7802
7464
|
// lib/use-inject-css.ts
|
7803
7465
|
init_react_import();
|
7804
|
-
import { useEffect as
|
7466
|
+
import { useEffect as useEffect23, useState as useState20 } from "react";
|
7805
7467
|
var styles = ``;
|
7806
7468
|
var useInjectStyleSheet = (initialStyles, iframeEnabled) => {
|
7807
7469
|
const [el, setEl] = useState20();
|
7808
|
-
|
7470
|
+
useEffect23(() => {
|
7809
7471
|
setEl(document.createElement("style"));
|
7810
7472
|
}, []);
|
7811
|
-
|
7473
|
+
useEffect23(() => {
|
7812
7474
|
var _a;
|
7813
7475
|
if (!el || typeof window === "undefined") {
|
7814
7476
|
return;
|
@@ -7828,10 +7490,10 @@ var useInjectGlobalCss = (iframeEnabled) => {
|
|
7828
7490
|
|
7829
7491
|
// lib/use-preview-mode-hotkeys.ts
|
7830
7492
|
init_react_import();
|
7831
|
-
import { useCallback as
|
7493
|
+
import { useCallback as useCallback16 } from "react";
|
7832
7494
|
var usePreviewModeHotkeys = () => {
|
7833
7495
|
const appStore = useAppStoreApi();
|
7834
|
-
const toggleInteractive =
|
7496
|
+
const toggleInteractive = useCallback16(() => {
|
7835
7497
|
const dispatch = appStore.getState().dispatch;
|
7836
7498
|
dispatch({
|
7837
7499
|
type: "setUi",
|
@@ -7846,7 +7508,7 @@ var usePreviewModeHotkeys = () => {
|
|
7846
7508
|
|
7847
7509
|
// lib/use-puck.ts
|
7848
7510
|
init_react_import();
|
7849
|
-
import { createContext as createContext6, useContext as
|
7511
|
+
import { createContext as createContext6, useContext as useContext11, useEffect as useEffect24, useState as useState21 } from "react";
|
7850
7512
|
import { createStore as createStore4, useStore as useStore3 } from "zustand";
|
7851
7513
|
var generateUsePuck = (store) => {
|
7852
7514
|
const history = {
|
@@ -7899,7 +7561,7 @@ var useRegisterUsePuckStore = (appStore) => {
|
|
7899
7561
|
() => generateUsePuck(convertToPickedStore(appStore.getState()))
|
7900
7562
|
)
|
7901
7563
|
);
|
7902
|
-
|
7564
|
+
useEffect24(() => {
|
7903
7565
|
return appStore.subscribe(
|
7904
7566
|
(store) => convertToPickedStore(store),
|
7905
7567
|
(pickedStore) => {
|
@@ -7911,7 +7573,7 @@ var useRegisterUsePuckStore = (appStore) => {
|
|
7911
7573
|
};
|
7912
7574
|
function createUsePuck() {
|
7913
7575
|
return function usePuck2(selector) {
|
7914
|
-
const usePuckApi =
|
7576
|
+
const usePuckApi = useContext11(UsePuckStoreContext);
|
7915
7577
|
if (!usePuckApi) {
|
7916
7578
|
throw new Error("usePuck must be used inside <Puck>.");
|
7917
7579
|
}
|
@@ -7923,18 +7585,241 @@ function createUsePuck() {
|
|
7923
7585
|
};
|
7924
7586
|
}
|
7925
7587
|
function usePuck() {
|
7926
|
-
|
7588
|
+
useEffect24(() => {
|
7927
7589
|
console.warn(
|
7928
7590
|
"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."
|
7929
7591
|
);
|
7930
7592
|
}, []);
|
7931
7593
|
return createUsePuck()((s) => s);
|
7932
7594
|
}
|
7595
|
+
function useGetPuck() {
|
7596
|
+
const usePuckApi = useContext11(UsePuckStoreContext);
|
7597
|
+
if (!usePuckApi) {
|
7598
|
+
throw new Error("usePuckGet must be used inside <Puck>.");
|
7599
|
+
}
|
7600
|
+
return usePuckApi.getState;
|
7601
|
+
}
|
7933
7602
|
|
7934
7603
|
// components/Puck/index.tsx
|
7604
|
+
import fdeq from "fast-deep-equal";
|
7605
|
+
|
7606
|
+
// components/Puck/components/Header/index.tsx
|
7607
|
+
init_react_import();
|
7608
|
+
import { memo as memo3, useCallback as useCallback17, useMemo as useMemo20, useState as useState22 } from "react";
|
7609
|
+
|
7610
|
+
// components/MenuBar/index.tsx
|
7611
|
+
init_react_import();
|
7612
|
+
|
7613
|
+
// css-module:/home/runner/work/puck/puck/packages/core/components/MenuBar/styles.module.css#css-module
|
7614
|
+
init_react_import();
|
7615
|
+
var styles_module_default21 = { "MenuBar": "_MenuBar_8pf8c_1", "MenuBar--menuOpen": "_MenuBar--menuOpen_8pf8c_14", "MenuBar-inner": "_MenuBar-inner_8pf8c_29", "MenuBar-history": "_MenuBar-history_8pf8c_45" };
|
7616
|
+
|
7617
|
+
// components/MenuBar/index.tsx
|
7618
|
+
import { Fragment as Fragment13, jsx as jsx38, jsxs as jsxs18 } from "react/jsx-runtime";
|
7619
|
+
var getClassName26 = get_class_name_factory_default("MenuBar", styles_module_default21);
|
7620
|
+
function MenuBar({
|
7621
|
+
menuOpen = false,
|
7622
|
+
renderHeaderActions,
|
7623
|
+
setMenuOpen
|
7624
|
+
}) {
|
7625
|
+
const back = useAppStore((s) => s.history.back);
|
7626
|
+
const forward = useAppStore((s) => s.history.forward);
|
7627
|
+
const hasFuture = useAppStore((s) => s.history.hasFuture());
|
7628
|
+
const hasPast = useAppStore((s) => s.history.hasPast());
|
7629
|
+
return /* @__PURE__ */ jsx38(
|
7630
|
+
"div",
|
7631
|
+
{
|
7632
|
+
className: getClassName26({ menuOpen }),
|
7633
|
+
onClick: (event) => {
|
7634
|
+
var _a;
|
7635
|
+
const element = event.target;
|
7636
|
+
if (window.matchMedia("(min-width: 638px)").matches) {
|
7637
|
+
return;
|
7638
|
+
}
|
7639
|
+
if (element.tagName === "A" && ((_a = element.getAttribute("href")) == null ? void 0 : _a.startsWith("#"))) {
|
7640
|
+
setMenuOpen(false);
|
7641
|
+
}
|
7642
|
+
},
|
7643
|
+
children: /* @__PURE__ */ jsxs18("div", { className: getClassName26("inner"), children: [
|
7644
|
+
/* @__PURE__ */ jsxs18("div", { className: getClassName26("history"), children: [
|
7645
|
+
/* @__PURE__ */ jsx38(IconButton, { title: "undo", disabled: !hasPast, onClick: back, children: /* @__PURE__ */ jsx38(Undo2, { size: 21 }) }),
|
7646
|
+
/* @__PURE__ */ jsx38(IconButton, { title: "redo", disabled: !hasFuture, onClick: forward, children: /* @__PURE__ */ jsx38(Redo2, { size: 21 }) })
|
7647
|
+
] }),
|
7648
|
+
/* @__PURE__ */ jsx38(Fragment13, { children: renderHeaderActions && renderHeaderActions() })
|
7649
|
+
] })
|
7650
|
+
}
|
7651
|
+
);
|
7652
|
+
}
|
7653
|
+
|
7654
|
+
// css-module:/home/runner/work/puck/puck/packages/core/components/Puck/components/Header/styles.module.css#css-module
|
7655
|
+
init_react_import();
|
7656
|
+
var styles_module_default22 = { "PuckHeader": "_PuckHeader_15xnq_1", "PuckHeader-inner": "_PuckHeader-inner_15xnq_10", "PuckHeader-toggle": "_PuckHeader-toggle_15xnq_20", "PuckHeader--rightSideBarVisible": "_PuckHeader--rightSideBarVisible_15xnq_27", "PuckHeader-rightSideBarToggle": "_PuckHeader-rightSideBarToggle_15xnq_27", "PuckHeader--leftSideBarVisible": "_PuckHeader--leftSideBarVisible_15xnq_28", "PuckHeader-leftSideBarToggle": "_PuckHeader-leftSideBarToggle_15xnq_28", "PuckHeader-title": "_PuckHeader-title_15xnq_32", "PuckHeader-path": "_PuckHeader-path_15xnq_36", "PuckHeader-tools": "_PuckHeader-tools_15xnq_43", "PuckHeader-menuButton": "_PuckHeader-menuButton_15xnq_49", "PuckHeader--menuOpen": "_PuckHeader--menuOpen_15xnq_54" };
|
7657
|
+
|
7658
|
+
// components/Puck/components/Header/index.tsx
|
7935
7659
|
import { Fragment as Fragment14, jsx as jsx39, jsxs as jsxs19 } from "react/jsx-runtime";
|
7936
|
-
var getClassName27 = get_class_name_factory_default("
|
7937
|
-
var
|
7660
|
+
var getClassName27 = get_class_name_factory_default("PuckHeader", styles_module_default22);
|
7661
|
+
var HeaderInner = () => {
|
7662
|
+
const {
|
7663
|
+
onPublish,
|
7664
|
+
renderHeader,
|
7665
|
+
renderHeaderActions,
|
7666
|
+
headerTitle,
|
7667
|
+
headerPath,
|
7668
|
+
iframe: _iframe
|
7669
|
+
} = usePropsContext();
|
7670
|
+
const dispatch = useAppStore((s) => s.dispatch);
|
7671
|
+
const appStore = useAppStoreApi();
|
7672
|
+
const defaultHeaderRender = useMemo20(() => {
|
7673
|
+
if (renderHeader) {
|
7674
|
+
console.warn(
|
7675
|
+
"`renderHeader` is deprecated. Please use `overrides.header` and the `usePuck` hook instead"
|
7676
|
+
);
|
7677
|
+
const RenderHeader = (_a) => {
|
7678
|
+
var _b = _a, { actions } = _b, props = __objRest(_b, ["actions"]);
|
7679
|
+
const Comp = renderHeader;
|
7680
|
+
const appState = useAppStore((s) => s.state);
|
7681
|
+
return /* @__PURE__ */ jsx39(Comp, __spreadProps(__spreadValues({}, props), { dispatch, state: appState, children: actions }));
|
7682
|
+
};
|
7683
|
+
return RenderHeader;
|
7684
|
+
}
|
7685
|
+
return DefaultOverride;
|
7686
|
+
}, [renderHeader]);
|
7687
|
+
const defaultHeaderActionsRender = useMemo20(() => {
|
7688
|
+
if (renderHeaderActions) {
|
7689
|
+
console.warn(
|
7690
|
+
"`renderHeaderActions` is deprecated. Please use `overrides.headerActions` and the `usePuck` hook instead."
|
7691
|
+
);
|
7692
|
+
const RenderHeader = (props) => {
|
7693
|
+
const Comp = renderHeaderActions;
|
7694
|
+
const appState = useAppStore((s) => s.state);
|
7695
|
+
return /* @__PURE__ */ jsx39(Comp, __spreadProps(__spreadValues({}, props), { dispatch, state: appState }));
|
7696
|
+
};
|
7697
|
+
return RenderHeader;
|
7698
|
+
}
|
7699
|
+
return DefaultOverride;
|
7700
|
+
}, [renderHeader]);
|
7701
|
+
const CustomHeader = useAppStore(
|
7702
|
+
(s) => s.overrides.header || defaultHeaderRender
|
7703
|
+
);
|
7704
|
+
const CustomHeaderActions = useAppStore(
|
7705
|
+
(s) => s.overrides.headerActions || defaultHeaderActionsRender
|
7706
|
+
);
|
7707
|
+
const [menuOpen, setMenuOpen] = useState22(false);
|
7708
|
+
const rootTitle = useAppStore((s) => {
|
7709
|
+
var _a, _b;
|
7710
|
+
const rootData = (_a = s.state.indexes.nodes["root"]) == null ? void 0 : _a.data;
|
7711
|
+
return (_b = rootData.props.title) != null ? _b : "";
|
7712
|
+
});
|
7713
|
+
const leftSideBarVisible = useAppStore((s) => s.state.ui.leftSideBarVisible);
|
7714
|
+
const rightSideBarVisible = useAppStore(
|
7715
|
+
(s) => s.state.ui.rightSideBarVisible
|
7716
|
+
);
|
7717
|
+
const toggleSidebars = useCallback17(
|
7718
|
+
(sidebar) => {
|
7719
|
+
const widerViewport = window.matchMedia("(min-width: 638px)").matches;
|
7720
|
+
const sideBarVisible = sidebar === "left" ? leftSideBarVisible : rightSideBarVisible;
|
7721
|
+
const oppositeSideBar = sidebar === "left" ? "rightSideBarVisible" : "leftSideBarVisible";
|
7722
|
+
dispatch({
|
7723
|
+
type: "setUi",
|
7724
|
+
ui: __spreadValues({
|
7725
|
+
[`${sidebar}SideBarVisible`]: !sideBarVisible
|
7726
|
+
}, !widerViewport ? { [oppositeSideBar]: false } : {})
|
7727
|
+
});
|
7728
|
+
},
|
7729
|
+
[dispatch, leftSideBarVisible, rightSideBarVisible]
|
7730
|
+
);
|
7731
|
+
return /* @__PURE__ */ jsx39(
|
7732
|
+
CustomHeader,
|
7733
|
+
{
|
7734
|
+
actions: /* @__PURE__ */ jsx39(Fragment14, { children: /* @__PURE__ */ jsx39(CustomHeaderActions, { children: /* @__PURE__ */ jsx39(
|
7735
|
+
Button,
|
7736
|
+
{
|
7737
|
+
onClick: () => {
|
7738
|
+
const data = appStore.getState().state.data;
|
7739
|
+
onPublish && onPublish(data);
|
7740
|
+
},
|
7741
|
+
icon: /* @__PURE__ */ jsx39(Globe, { size: "14px" }),
|
7742
|
+
children: "Publish"
|
7743
|
+
}
|
7744
|
+
) }) }),
|
7745
|
+
children: /* @__PURE__ */ jsx39(
|
7746
|
+
"header",
|
7747
|
+
{
|
7748
|
+
className: getClassName27({ leftSideBarVisible, rightSideBarVisible }),
|
7749
|
+
children: /* @__PURE__ */ jsxs19("div", { className: getClassName27("inner"), children: [
|
7750
|
+
/* @__PURE__ */ jsxs19("div", { className: getClassName27("toggle"), children: [
|
7751
|
+
/* @__PURE__ */ jsx39("div", { className: getClassName27("leftSideBarToggle"), children: /* @__PURE__ */ jsx39(
|
7752
|
+
IconButton,
|
7753
|
+
{
|
7754
|
+
onClick: () => {
|
7755
|
+
toggleSidebars("left");
|
7756
|
+
},
|
7757
|
+
title: "Toggle left sidebar",
|
7758
|
+
children: /* @__PURE__ */ jsx39(PanelLeft, { focusable: "false" })
|
7759
|
+
}
|
7760
|
+
) }),
|
7761
|
+
/* @__PURE__ */ jsx39("div", { className: getClassName27("rightSideBarToggle"), children: /* @__PURE__ */ jsx39(
|
7762
|
+
IconButton,
|
7763
|
+
{
|
7764
|
+
onClick: () => {
|
7765
|
+
toggleSidebars("right");
|
7766
|
+
},
|
7767
|
+
title: "Toggle right sidebar",
|
7768
|
+
children: /* @__PURE__ */ jsx39(PanelRight, { focusable: "false" })
|
7769
|
+
}
|
7770
|
+
) })
|
7771
|
+
] }),
|
7772
|
+
/* @__PURE__ */ jsx39("div", { className: getClassName27("title"), children: /* @__PURE__ */ jsxs19(Heading, { rank: "2", size: "xs", children: [
|
7773
|
+
headerTitle || rootTitle || "Page",
|
7774
|
+
headerPath && /* @__PURE__ */ jsxs19(Fragment14, { children: [
|
7775
|
+
" ",
|
7776
|
+
/* @__PURE__ */ jsx39("code", { className: getClassName27("path"), children: headerPath })
|
7777
|
+
] })
|
7778
|
+
] }) }),
|
7779
|
+
/* @__PURE__ */ jsxs19("div", { className: getClassName27("tools"), children: [
|
7780
|
+
/* @__PURE__ */ jsx39("div", { className: getClassName27("menuButton"), children: /* @__PURE__ */ jsx39(
|
7781
|
+
IconButton,
|
7782
|
+
{
|
7783
|
+
onClick: () => {
|
7784
|
+
return setMenuOpen(!menuOpen);
|
7785
|
+
},
|
7786
|
+
title: "Toggle menu bar",
|
7787
|
+
children: menuOpen ? /* @__PURE__ */ jsx39(ChevronUp, { focusable: "false" }) : /* @__PURE__ */ jsx39(ChevronDown, { focusable: "false" })
|
7788
|
+
}
|
7789
|
+
) }),
|
7790
|
+
/* @__PURE__ */ jsx39(
|
7791
|
+
MenuBar,
|
7792
|
+
{
|
7793
|
+
dispatch,
|
7794
|
+
onPublish,
|
7795
|
+
menuOpen,
|
7796
|
+
renderHeaderActions: () => /* @__PURE__ */ jsx39(CustomHeaderActions, { children: /* @__PURE__ */ jsx39(
|
7797
|
+
Button,
|
7798
|
+
{
|
7799
|
+
onClick: () => {
|
7800
|
+
const data = appStore.getState().state.data;
|
7801
|
+
onPublish && onPublish(data);
|
7802
|
+
},
|
7803
|
+
icon: /* @__PURE__ */ jsx39(Globe, { size: "14px" }),
|
7804
|
+
children: "Publish"
|
7805
|
+
}
|
7806
|
+
) }),
|
7807
|
+
setMenuOpen
|
7808
|
+
}
|
7809
|
+
)
|
7810
|
+
] })
|
7811
|
+
] })
|
7812
|
+
}
|
7813
|
+
)
|
7814
|
+
}
|
7815
|
+
);
|
7816
|
+
};
|
7817
|
+
var Header = memo3(HeaderInner);
|
7818
|
+
|
7819
|
+
// components/Puck/index.tsx
|
7820
|
+
import { jsx as jsx40, jsxs as jsxs20 } from "react/jsx-runtime";
|
7821
|
+
var getClassName28 = get_class_name_factory_default("Puck", styles_module_default14);
|
7822
|
+
var getLayoutClassName = get_class_name_factory_default("PuckLayout", styles_module_default14);
|
7938
7823
|
var FieldSideBar = () => {
|
7939
7824
|
const title = useAppStore(
|
7940
7825
|
(s) => {
|
@@ -7942,13 +7827,13 @@ var FieldSideBar = () => {
|
|
7942
7827
|
return s.selectedItem ? (_b = (_a = s.config.components[s.selectedItem.type]) == null ? void 0 : _a["label"]) != null ? _b : s.selectedItem.type.toString() : "Page";
|
7943
7828
|
}
|
7944
7829
|
);
|
7945
|
-
return /* @__PURE__ */
|
7830
|
+
return /* @__PURE__ */ jsx40(SidebarSection, { noPadding: true, noBorderTop: true, showBreadcrumbs: true, title, children: /* @__PURE__ */ jsx40(Fields, {}) });
|
7946
7831
|
};
|
7947
7832
|
var propsContext = createContext7({});
|
7948
7833
|
function PropsProvider(props) {
|
7949
|
-
return /* @__PURE__ */
|
7834
|
+
return /* @__PURE__ */ jsx40(propsContext.Provider, { value: props, children: props.children });
|
7950
7835
|
}
|
7951
|
-
var usePropsContext = () =>
|
7836
|
+
var usePropsContext = () => useContext12(propsContext);
|
7952
7837
|
function PuckProvider({ children }) {
|
7953
7838
|
const {
|
7954
7839
|
config,
|
@@ -7964,11 +7849,14 @@ function PuckProvider({ children }) {
|
|
7964
7849
|
metadata,
|
7965
7850
|
onAction
|
7966
7851
|
} = usePropsContext();
|
7967
|
-
const iframe =
|
7968
|
-
|
7969
|
-
|
7970
|
-
|
7971
|
-
|
7852
|
+
const iframe = useMemo21(
|
7853
|
+
() => __spreadValues({
|
7854
|
+
enabled: true,
|
7855
|
+
waitForStyles: true
|
7856
|
+
}, _iframe),
|
7857
|
+
[_iframe]
|
7858
|
+
);
|
7859
|
+
const [generatedAppState] = useState23(() => {
|
7972
7860
|
var _a, _b, _c, _d, _e, _f, _g, _h, _i;
|
7973
7861
|
const initial = __spreadValues(__spreadValues({}, defaultAppState.ui), initialUi);
|
7974
7862
|
let clientUiState = {};
|
@@ -8028,7 +7916,7 @@ function PuckProvider({ children }) {
|
|
8028
7916
|
return walkAppState(newAppState, config);
|
8029
7917
|
});
|
8030
7918
|
const { appendData = true } = _initialHistory || {};
|
8031
|
-
const [blendedHistories] =
|
7919
|
+
const [blendedHistories] = useState23(
|
8032
7920
|
[
|
8033
7921
|
...(_initialHistory == null ? void 0 : _initialHistory.histories) || [],
|
8034
7922
|
...appendData ? [{ state: generatedAppState }] : []
|
@@ -8048,7 +7936,7 @@ function PuckProvider({ children }) {
|
|
8048
7936
|
overrides,
|
8049
7937
|
plugins
|
8050
7938
|
});
|
8051
|
-
const generateAppStore =
|
7939
|
+
const generateAppStore = useCallback18(
|
8052
7940
|
(state) => {
|
8053
7941
|
return {
|
8054
7942
|
state,
|
@@ -8072,10 +7960,10 @@ function PuckProvider({ children }) {
|
|
8072
7960
|
metadata
|
8073
7961
|
]
|
8074
7962
|
);
|
8075
|
-
const [appStore] =
|
7963
|
+
const [appStore] = useState23(
|
8076
7964
|
() => createAppStore(generateAppStore(initialAppState))
|
8077
7965
|
);
|
8078
|
-
|
7966
|
+
useEffect25(() => {
|
8079
7967
|
const state = appStore.getState().state;
|
8080
7968
|
appStore.setState(__spreadValues({}, generateAppStore(state)));
|
8081
7969
|
}, [config, plugins, loadedOverrides, viewports, iframe, onAction, metadata]);
|
@@ -8084,66 +7972,47 @@ function PuckProvider({ children }) {
|
|
8084
7972
|
index: initialHistoryIndex,
|
8085
7973
|
initialAppState
|
8086
7974
|
});
|
8087
|
-
|
8088
|
-
|
8089
|
-
|
8090
|
-
|
7975
|
+
const previousData = useRef8(null);
|
7976
|
+
useEffect25(() => {
|
7977
|
+
appStore.subscribe(
|
7978
|
+
(s) => s.state.data,
|
7979
|
+
(data) => {
|
7980
|
+
if (onChange) {
|
7981
|
+
if (fdeq(data, previousData.current)) return;
|
7982
|
+
onChange(data);
|
7983
|
+
previousData.current = data;
|
7984
|
+
}
|
7985
|
+
}
|
7986
|
+
);
|
8091
7987
|
}, []);
|
8092
7988
|
useRegisterPermissionsSlice(appStore, permissions);
|
8093
7989
|
const uPuckStore = useRegisterUsePuckStore(appStore);
|
8094
|
-
|
7990
|
+
useEffect25(() => {
|
8095
7991
|
const { resolveAndCommitData } = appStore.getState();
|
8096
7992
|
resolveAndCommitData();
|
8097
7993
|
}, []);
|
8098
|
-
return /* @__PURE__ */
|
7994
|
+
return /* @__PURE__ */ jsx40(appStoreContext.Provider, { value: appStore, children: /* @__PURE__ */ jsx40(UsePuckStoreContext.Provider, { value: uPuckStore, children }) });
|
8099
7995
|
}
|
8100
7996
|
function PuckLayout({ children }) {
|
8101
7997
|
const {
|
8102
|
-
onChange,
|
8103
|
-
onPublish,
|
8104
|
-
renderHeader,
|
8105
|
-
renderHeaderActions,
|
8106
|
-
headerTitle,
|
8107
|
-
headerPath,
|
8108
7998
|
iframe: _iframe,
|
8109
7999
|
dnd,
|
8110
8000
|
initialHistory: _initialHistory
|
8111
8001
|
} = usePropsContext();
|
8112
|
-
const iframe =
|
8113
|
-
|
8114
|
-
|
8115
|
-
|
8002
|
+
const iframe = useMemo21(
|
8003
|
+
() => __spreadValues({
|
8004
|
+
enabled: true,
|
8005
|
+
waitForStyles: true
|
8006
|
+
}, _iframe),
|
8007
|
+
[_iframe]
|
8008
|
+
);
|
8116
8009
|
useInjectGlobalCss(iframe.enabled);
|
8117
8010
|
const leftSideBarVisible = useAppStore((s) => s.state.ui.leftSideBarVisible);
|
8118
8011
|
const rightSideBarVisible = useAppStore(
|
8119
8012
|
(s) => s.state.ui.rightSideBarVisible
|
8120
8013
|
);
|
8121
|
-
const [menuOpen, setMenuOpen] = useState22(false);
|
8122
|
-
const appStore = useAppStoreApi();
|
8123
|
-
useEffect24(() => {
|
8124
|
-
return appStore.subscribe((s) => {
|
8125
|
-
if (onChange) onChange(s.state.data);
|
8126
|
-
});
|
8127
|
-
}, [appStore]);
|
8128
|
-
const rootProps = useAppStore(
|
8129
|
-
(s) => s.state.data.root.props || s.state.data.root.props
|
8130
|
-
);
|
8131
8014
|
const dispatch = useAppStore((s) => s.dispatch);
|
8132
|
-
|
8133
|
-
(sidebar) => {
|
8134
|
-
const widerViewport = window.matchMedia("(min-width: 638px)").matches;
|
8135
|
-
const sideBarVisible = sidebar === "left" ? leftSideBarVisible : rightSideBarVisible;
|
8136
|
-
const oppositeSideBar = sidebar === "left" ? "rightSideBarVisible" : "leftSideBarVisible";
|
8137
|
-
dispatch({
|
8138
|
-
type: "setUi",
|
8139
|
-
ui: __spreadValues({
|
8140
|
-
[`${sidebar}SideBarVisible`]: !sideBarVisible
|
8141
|
-
}, !widerViewport ? { [oppositeSideBar]: false } : {})
|
8142
|
-
});
|
8143
|
-
},
|
8144
|
-
[dispatch, leftSideBarVisible, rightSideBarVisible]
|
8145
|
-
);
|
8146
|
-
useEffect24(() => {
|
8015
|
+
useEffect25(() => {
|
8147
8016
|
if (!window.matchMedia("(min-width: 638px)").matches) {
|
8148
8017
|
dispatch({
|
8149
8018
|
type: "setUi",
|
@@ -8166,55 +8035,18 @@ function PuckLayout({ children }) {
|
|
8166
8035
|
window.removeEventListener("resize", handleResize);
|
8167
8036
|
};
|
8168
8037
|
}, []);
|
8169
|
-
const defaultHeaderRender = useMemo20(() => {
|
8170
|
-
if (renderHeader) {
|
8171
|
-
console.warn(
|
8172
|
-
"`renderHeader` is deprecated. Please use `overrides.header` and the `usePuck` hook instead"
|
8173
|
-
);
|
8174
|
-
const RenderHeader = (_a) => {
|
8175
|
-
var _b = _a, { actions } = _b, props = __objRest(_b, ["actions"]);
|
8176
|
-
const Comp = renderHeader;
|
8177
|
-
const appState = useAppStore((s) => s.state);
|
8178
|
-
return /* @__PURE__ */ jsx39(Comp, __spreadProps(__spreadValues({}, props), { dispatch, state: appState, children: actions }));
|
8179
|
-
};
|
8180
|
-
return RenderHeader;
|
8181
|
-
}
|
8182
|
-
return DefaultOverride;
|
8183
|
-
}, [renderHeader]);
|
8184
|
-
const defaultHeaderActionsRender = useMemo20(() => {
|
8185
|
-
if (renderHeaderActions) {
|
8186
|
-
console.warn(
|
8187
|
-
"`renderHeaderActions` is deprecated. Please use `overrides.headerActions` and the `usePuck` hook instead."
|
8188
|
-
);
|
8189
|
-
const RenderHeader = (props) => {
|
8190
|
-
const Comp = renderHeaderActions;
|
8191
|
-
const appState = useAppStore((s) => s.state);
|
8192
|
-
return /* @__PURE__ */ jsx39(Comp, __spreadProps(__spreadValues({}, props), { dispatch, state: appState }));
|
8193
|
-
};
|
8194
|
-
return RenderHeader;
|
8195
|
-
}
|
8196
|
-
return DefaultOverride;
|
8197
|
-
}, [renderHeader]);
|
8198
8038
|
const overrides = useAppStore((s) => s.overrides);
|
8199
|
-
const CustomPuck =
|
8039
|
+
const CustomPuck = useMemo21(
|
8200
8040
|
() => overrides.puck || DefaultOverride,
|
8201
8041
|
[overrides]
|
8202
8042
|
);
|
8203
|
-
const
|
8204
|
-
|
8205
|
-
[overrides]
|
8206
|
-
);
|
8207
|
-
const CustomHeaderActions = useMemo20(
|
8208
|
-
() => overrides.headerActions || defaultHeaderActionsRender,
|
8209
|
-
[overrides]
|
8210
|
-
);
|
8211
|
-
const [mounted, setMounted] = useState22(false);
|
8212
|
-
useEffect24(() => {
|
8043
|
+
const [mounted, setMounted] = useState23(false);
|
8044
|
+
useEffect25(() => {
|
8213
8045
|
setMounted(true);
|
8214
8046
|
}, []);
|
8215
8047
|
const ready = useAppStore((s) => s.status === "READY");
|
8216
8048
|
useMonitorHotkeys();
|
8217
|
-
|
8049
|
+
useEffect25(() => {
|
8218
8050
|
if (ready && iframe.enabled) {
|
8219
8051
|
const frameDoc = getFrame();
|
8220
8052
|
if (frameDoc) {
|
@@ -8223,246 +8055,36 @@ function PuckLayout({ children }) {
|
|
8223
8055
|
}
|
8224
8056
|
}, [ready, iframe.enabled]);
|
8225
8057
|
usePreviewModeHotkeys();
|
8226
|
-
return /* @__PURE__ */
|
8227
|
-
/* @__PURE__ */
|
8058
|
+
return /* @__PURE__ */ jsxs20("div", { className: `Puck ${getClassName28()}`, children: [
|
8059
|
+
/* @__PURE__ */ jsx40(DragDropContext, { disableAutoScroll: dnd == null ? void 0 : dnd.disableAutoScroll, children: /* @__PURE__ */ jsx40(CustomPuck, { children: children || /* @__PURE__ */ jsx40(
|
8228
8060
|
"div",
|
8229
8061
|
{
|
8230
8062
|
className: getLayoutClassName({
|
8231
8063
|
leftSideBarVisible,
|
8232
|
-
menuOpen,
|
8233
8064
|
mounted,
|
8234
8065
|
rightSideBarVisible
|
8235
8066
|
}),
|
8236
|
-
children: /* @__PURE__ */
|
8237
|
-
/* @__PURE__ */
|
8238
|
-
|
8239
|
-
{
|
8240
|
-
|
8241
|
-
Button,
|
8242
|
-
{
|
8243
|
-
onClick: () => {
|
8244
|
-
const data = appStore.getState().state.data;
|
8245
|
-
onPublish && onPublish(data);
|
8246
|
-
},
|
8247
|
-
icon: /* @__PURE__ */ jsx39(Globe, { size: "14px" }),
|
8248
|
-
children: "Publish"
|
8249
|
-
}
|
8250
|
-
) }) }),
|
8251
|
-
children: /* @__PURE__ */ jsx39("header", { className: getLayoutClassName("header"), children: /* @__PURE__ */ jsxs19("div", { className: getLayoutClassName("headerInner"), children: [
|
8252
|
-
/* @__PURE__ */ jsxs19("div", { className: getLayoutClassName("headerToggle"), children: [
|
8253
|
-
/* @__PURE__ */ jsx39(
|
8254
|
-
"div",
|
8255
|
-
{
|
8256
|
-
className: getLayoutClassName("leftSideBarToggle"),
|
8257
|
-
children: /* @__PURE__ */ jsx39(
|
8258
|
-
IconButton,
|
8259
|
-
{
|
8260
|
-
onClick: () => {
|
8261
|
-
toggleSidebars("left");
|
8262
|
-
},
|
8263
|
-
title: "Toggle left sidebar",
|
8264
|
-
children: /* @__PURE__ */ jsx39(PanelLeft, { focusable: "false" })
|
8265
|
-
}
|
8266
|
-
)
|
8267
|
-
}
|
8268
|
-
),
|
8269
|
-
/* @__PURE__ */ jsx39(
|
8270
|
-
"div",
|
8271
|
-
{
|
8272
|
-
className: getLayoutClassName("rightSideBarToggle"),
|
8273
|
-
children: /* @__PURE__ */ jsx39(
|
8274
|
-
IconButton,
|
8275
|
-
{
|
8276
|
-
onClick: () => {
|
8277
|
-
toggleSidebars("right");
|
8278
|
-
},
|
8279
|
-
title: "Toggle right sidebar",
|
8280
|
-
children: /* @__PURE__ */ jsx39(PanelRight, { focusable: "false" })
|
8281
|
-
}
|
8282
|
-
)
|
8283
|
-
}
|
8284
|
-
)
|
8285
|
-
] }),
|
8286
|
-
/* @__PURE__ */ jsx39("div", { className: getLayoutClassName("headerTitle"), children: /* @__PURE__ */ jsxs19(Heading, { rank: "2", size: "xs", children: [
|
8287
|
-
headerTitle || (rootProps == null ? void 0 : rootProps.title) || "Page",
|
8288
|
-
headerPath && /* @__PURE__ */ jsxs19(Fragment14, { children: [
|
8289
|
-
" ",
|
8290
|
-
/* @__PURE__ */ jsx39(
|
8291
|
-
"code",
|
8292
|
-
{
|
8293
|
-
className: getLayoutClassName("headerPath"),
|
8294
|
-
children: headerPath
|
8295
|
-
}
|
8296
|
-
)
|
8297
|
-
] })
|
8298
|
-
] }) }),
|
8299
|
-
/* @__PURE__ */ jsxs19("div", { className: getLayoutClassName("headerTools"), children: [
|
8300
|
-
/* @__PURE__ */ jsx39("div", { className: getLayoutClassName("menuButton"), children: /* @__PURE__ */ jsx39(
|
8301
|
-
IconButton,
|
8302
|
-
{
|
8303
|
-
onClick: () => {
|
8304
|
-
return setMenuOpen(!menuOpen);
|
8305
|
-
},
|
8306
|
-
title: "Toggle menu bar",
|
8307
|
-
children: menuOpen ? /* @__PURE__ */ jsx39(ChevronUp, { focusable: "false" }) : /* @__PURE__ */ jsx39(ChevronDown, { focusable: "false" })
|
8308
|
-
}
|
8309
|
-
) }),
|
8310
|
-
/* @__PURE__ */ jsx39(
|
8311
|
-
MenuBar,
|
8312
|
-
{
|
8313
|
-
dispatch,
|
8314
|
-
onPublish,
|
8315
|
-
menuOpen,
|
8316
|
-
renderHeaderActions: () => /* @__PURE__ */ jsx39(CustomHeaderActions, { children: /* @__PURE__ */ jsx39(
|
8317
|
-
Button,
|
8318
|
-
{
|
8319
|
-
onClick: () => {
|
8320
|
-
const data = appStore.getState().state.data;
|
8321
|
-
onPublish && onPublish(data);
|
8322
|
-
},
|
8323
|
-
icon: /* @__PURE__ */ jsx39(Globe, { size: "14px" }),
|
8324
|
-
children: "Publish"
|
8325
|
-
}
|
8326
|
-
) }),
|
8327
|
-
setMenuOpen
|
8328
|
-
}
|
8329
|
-
)
|
8330
|
-
] })
|
8331
|
-
] }) })
|
8332
|
-
}
|
8333
|
-
),
|
8334
|
-
/* @__PURE__ */ jsxs19("div", { className: getLayoutClassName("leftSideBar"), children: [
|
8335
|
-
/* @__PURE__ */ jsx39(SidebarSection, { title: "Components", noBorderTop: true, children: /* @__PURE__ */ jsx39(Components, {}) }),
|
8336
|
-
/* @__PURE__ */ jsx39(SidebarSection, { title: "Outline", children: /* @__PURE__ */ jsx39(Outline, {}) })
|
8067
|
+
children: /* @__PURE__ */ jsxs20("div", { className: getLayoutClassName("inner"), children: [
|
8068
|
+
/* @__PURE__ */ jsx40(Header, {}),
|
8069
|
+
/* @__PURE__ */ jsxs20("div", { className: getLayoutClassName("leftSideBar"), children: [
|
8070
|
+
/* @__PURE__ */ jsx40(SidebarSection, { title: "Components", noBorderTop: true, children: /* @__PURE__ */ jsx40(Components, {}) }),
|
8071
|
+
/* @__PURE__ */ jsx40(SidebarSection, { title: "Outline", children: /* @__PURE__ */ jsx40(Outline, {}) })
|
8337
8072
|
] }),
|
8338
|
-
/* @__PURE__ */
|
8339
|
-
/* @__PURE__ */
|
8073
|
+
/* @__PURE__ */ jsx40(Canvas, {}),
|
8074
|
+
/* @__PURE__ */ jsx40("div", { className: getLayoutClassName("rightSideBar"), children: /* @__PURE__ */ jsx40(FieldSideBar, {}) })
|
8340
8075
|
] })
|
8341
8076
|
}
|
8342
8077
|
) }) }),
|
8343
|
-
/* @__PURE__ */
|
8078
|
+
/* @__PURE__ */ jsx40("div", { id: "puck-portal-root", className: getClassName28("portal") })
|
8344
8079
|
] });
|
8345
8080
|
}
|
8346
8081
|
function Puck(props) {
|
8347
|
-
return /* @__PURE__ */
|
8082
|
+
return /* @__PURE__ */ jsx40(PropsProvider, __spreadProps(__spreadValues({}, props), { children: /* @__PURE__ */ jsx40(PuckProvider, __spreadProps(__spreadValues({}, props), { children: /* @__PURE__ */ jsx40(PuckLayout, __spreadValues({}, props)) })) }));
|
8348
8083
|
}
|
8349
8084
|
Puck.Components = Components;
|
8350
8085
|
Puck.Fields = Fields;
|
8351
8086
|
Puck.Outline = Outline;
|
8352
|
-
Puck.Preview =
|
8353
|
-
|
8354
|
-
// lib/migrate.ts
|
8355
|
-
init_react_import();
|
8356
|
-
var migrations = [
|
8357
|
-
// Migrate root to root.props
|
8358
|
-
(data) => {
|
8359
|
-
const rootProps = data.root.props || data.root;
|
8360
|
-
if (Object.keys(data.root).length > 0 && !data.root.props) {
|
8361
|
-
console.warn(
|
8362
|
-
"Migration applied: Root props moved from `root` to `root.props`."
|
8363
|
-
);
|
8364
|
-
return __spreadProps(__spreadValues({}, data), {
|
8365
|
-
root: {
|
8366
|
-
props: __spreadValues({}, rootProps)
|
8367
|
-
}
|
8368
|
-
});
|
8369
|
-
}
|
8370
|
-
return data;
|
8371
|
-
},
|
8372
|
-
// Migrate zones to slots
|
8373
|
-
(data, config) => {
|
8374
|
-
var _a;
|
8375
|
-
if (!config) return data;
|
8376
|
-
console.log("Migrating DropZones to slots...");
|
8377
|
-
const updatedItems = {};
|
8378
|
-
const appState = __spreadProps(__spreadValues({}, defaultAppState), { data });
|
8379
|
-
const { indexes } = walkAppState(appState, config);
|
8380
|
-
const deletedCompounds = [];
|
8381
|
-
walkAppState(appState, config, (content, zoneCompound, zoneType) => {
|
8382
|
-
var _a2, _b;
|
8383
|
-
if (zoneType === "dropzone") {
|
8384
|
-
const [id, slotName] = zoneCompound.split(":");
|
8385
|
-
const nodeData = indexes.nodes[id].data;
|
8386
|
-
const componentType = nodeData.type;
|
8387
|
-
const configForComponent = config.components[componentType];
|
8388
|
-
if (((_b = (_a2 = configForComponent == null ? void 0 : configForComponent.fields) == null ? void 0 : _a2[slotName]) == null ? void 0 : _b.type) === "slot") {
|
8389
|
-
updatedItems[id] = __spreadProps(__spreadValues({}, nodeData), {
|
8390
|
-
props: __spreadProps(__spreadValues({}, nodeData.props), {
|
8391
|
-
[slotName]: content
|
8392
|
-
})
|
8393
|
-
});
|
8394
|
-
deletedCompounds.push(zoneCompound);
|
8395
|
-
}
|
8396
|
-
return content;
|
8397
|
-
}
|
8398
|
-
return content;
|
8399
|
-
});
|
8400
|
-
const updated = walkAppState(
|
8401
|
-
appState,
|
8402
|
-
config,
|
8403
|
-
(content) => content,
|
8404
|
-
(item) => {
|
8405
|
-
var _a2;
|
8406
|
-
return (_a2 = updatedItems[item.props.id]) != null ? _a2 : item;
|
8407
|
-
}
|
8408
|
-
);
|
8409
|
-
deletedCompounds.forEach((zoneCompound) => {
|
8410
|
-
var _a2;
|
8411
|
-
const [_, propName] = zoneCompound.split(":");
|
8412
|
-
console.log(
|
8413
|
-
`\u2713 Success: Migrated "${zoneCompound}" from DropZone to slot field "${propName}"`
|
8414
|
-
);
|
8415
|
-
(_a2 = updated.data.zones) == null ? true : delete _a2[zoneCompound];
|
8416
|
-
});
|
8417
|
-
Object.keys((_a = updated.data.zones) != null ? _a : {}).forEach((zoneCompound) => {
|
8418
|
-
const [_, propName] = zoneCompound.split(":");
|
8419
|
-
throw new Error(
|
8420
|
-
`Could not migrate DropZone "${zoneCompound}" to slot field. No slot exists with the name "${propName}".`
|
8421
|
-
);
|
8422
|
-
});
|
8423
|
-
delete updated.data.zones;
|
8424
|
-
return updated.data;
|
8425
|
-
}
|
8426
|
-
];
|
8427
|
-
function migrate(data, config) {
|
8428
|
-
return migrations == null ? void 0 : migrations.reduce(
|
8429
|
-
(acc, migration) => migration(acc, config),
|
8430
|
-
data
|
8431
|
-
);
|
8432
|
-
}
|
8433
|
-
|
8434
|
-
// lib/data/walk-tree.ts
|
8435
|
-
init_react_import();
|
8436
|
-
function walkTree(data, config, callbackFn) {
|
8437
|
-
var _a, _b;
|
8438
|
-
const isSlot2 = createIsSlotConfig(config);
|
8439
|
-
const walkItem = (item) => {
|
8440
|
-
return mapSlotsSync(
|
8441
|
-
item,
|
8442
|
-
(content, parentId, propName) => callbackFn(content, { parentId, propName }),
|
8443
|
-
isSlot2
|
8444
|
-
);
|
8445
|
-
};
|
8446
|
-
if ("props" in data) {
|
8447
|
-
return walkItem(data);
|
8448
|
-
}
|
8449
|
-
const _data = data;
|
8450
|
-
const zones = (_a = _data.zones) != null ? _a : {};
|
8451
|
-
const mappedContent = _data.content.map(walkItem);
|
8452
|
-
return {
|
8453
|
-
root: walkItem(_data.root),
|
8454
|
-
content: (_b = callbackFn(mappedContent, {
|
8455
|
-
parentId: "root",
|
8456
|
-
propName: "default-zone"
|
8457
|
-
})) != null ? _b : mappedContent,
|
8458
|
-
zones: Object.keys(zones).reduce(
|
8459
|
-
(acc, zoneCompound) => __spreadProps(__spreadValues({}, acc), {
|
8460
|
-
[zoneCompound]: zones[zoneCompound].map(walkItem)
|
8461
|
-
}),
|
8462
|
-
{}
|
8463
|
-
)
|
8464
|
-
};
|
8465
|
-
}
|
8087
|
+
Puck.Preview = Preview2;
|
8466
8088
|
export {
|
8467
8089
|
Action,
|
8468
8090
|
ActionBar,
|
@@ -8482,6 +8104,7 @@ export {
|
|
8482
8104
|
renderContext,
|
8483
8105
|
resolveAllData,
|
8484
8106
|
transformProps,
|
8107
|
+
useGetPuck,
|
8485
8108
|
usePuck,
|
8486
8109
|
walkTree
|
8487
8110
|
};
|