@measured/puck 0.19.0-canary.0308d24 → 0.19.0-canary.046cb9ed
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -4
- package/dist/chunk-COT3ZFIM.mjs +576 -0
- package/dist/index.css +69 -67
- package/dist/index.d.mts +113 -109
- package/dist/index.d.ts +113 -109
- package/dist/index.js +2253 -1662
- package/dist/index.mjs +1741 -1368
- package/dist/rsc.d.mts +2 -2
- package/dist/rsc.d.ts +2 -2
- package/dist/rsc.js +294 -135
- package/dist/rsc.mjs +6 -105
- package/dist/{resolve-all-data-3XjIPfNh.d.mts → walk-tree-CM-cu7GU.d.mts} +94 -26
- package/dist/{resolve-all-data-3XjIPfNh.d.ts → walk-tree-CM-cu7GU.d.ts} +94 -26
- package/package.json +4 -4
- package/dist/chunk-7N5DRY4G.mjs +0 -308
package/dist/index.mjs
CHANGED
@@ -1,4 +1,6 @@
|
|
1
1
|
import {
|
2
|
+
SlotRender,
|
3
|
+
SlotRenderPure,
|
2
4
|
__async,
|
3
5
|
__commonJS,
|
4
6
|
__objRest,
|
@@ -8,17 +10,20 @@ import {
|
|
8
10
|
__spreadProps,
|
9
11
|
__spreadValues,
|
10
12
|
__toESM,
|
13
|
+
createIsSlotConfig,
|
11
14
|
getChanged,
|
12
15
|
init_react_import,
|
16
|
+
isSlot,
|
13
17
|
resolveAllData,
|
14
18
|
resolveComponentData,
|
15
|
-
resolveRootData,
|
16
19
|
rootAreaId,
|
17
20
|
rootDroppableId,
|
18
21
|
rootZone,
|
19
22
|
setupZone,
|
20
|
-
transformProps
|
21
|
-
|
23
|
+
transformProps,
|
24
|
+
useSlots,
|
25
|
+
walkTree
|
26
|
+
} from "./chunk-COT3ZFIM.mjs";
|
22
27
|
|
23
28
|
// ../../node_modules/classnames/index.js
|
24
29
|
var require_classnames = __commonJS({
|
@@ -207,13 +212,13 @@ init_react_import();
|
|
207
212
|
|
208
213
|
// css-module:/home/runner/work/puck/puck/packages/core/components/AutoField/styles.module.css#css-module
|
209
214
|
init_react_import();
|
210
|
-
var styles_module_default2 = { "InputWrapper": "
|
215
|
+
var styles_module_default2 = { "InputWrapper": "_InputWrapper_4xor1_1", "Input-label": "_Input-label_4xor1_5", "Input-labelIcon": "_Input-labelIcon_4xor1_14", "Input-disabledIcon": "_Input-disabledIcon_4xor1_21", "Input-input": "_Input-input_4xor1_26", "Input": "_Input_4xor1_1", "Input--readOnly": "_Input--readOnly_4xor1_75", "Input-radioGroupItems": "_Input-radioGroupItems_4xor1_86", "Input-radio": "_Input-radio_4xor1_86", "Input-radioInner": "_Input-radioInner_4xor1_103", "Input-radioInput": "_Input-radioInput_4xor1_148" };
|
211
216
|
|
212
217
|
// components/AutoField/index.tsx
|
213
218
|
import {
|
214
219
|
useCallback as useCallback4,
|
215
220
|
useContext as useContext3,
|
216
|
-
useEffect as
|
221
|
+
useEffect as useEffect10,
|
217
222
|
useMemo as useMemo5,
|
218
223
|
useState as useState8
|
219
224
|
} from "react";
|
@@ -575,7 +580,7 @@ init_react_import();
|
|
575
580
|
// lib/filter.ts
|
576
581
|
init_react_import();
|
577
582
|
|
578
|
-
// lib/reorder.ts
|
583
|
+
// lib/data/reorder.ts
|
579
584
|
init_react_import();
|
580
585
|
var reorder = (list, startIndex, endIndex) => {
|
581
586
|
const result = Array.from(list);
|
@@ -584,7 +589,7 @@ var reorder = (list, startIndex, endIndex) => {
|
|
584
589
|
return result;
|
585
590
|
};
|
586
591
|
|
587
|
-
// lib/replace.ts
|
592
|
+
// lib/data/replace.ts
|
588
593
|
init_react_import();
|
589
594
|
var replace = (list, index, newItem) => {
|
590
595
|
const result = Array.from(list);
|
@@ -676,7 +681,7 @@ var IconButton = ({
|
|
676
681
|
};
|
677
682
|
|
678
683
|
// components/AutoField/fields/ArrayField/index.tsx
|
679
|
-
import { useCallback as useCallback2, useEffect as
|
684
|
+
import { useCallback as useCallback2, useEffect as useEffect5, useRef, useState as useState3 } from "react";
|
680
685
|
|
681
686
|
// components/DragIcon/index.tsx
|
682
687
|
init_react_import();
|
@@ -696,43 +701,36 @@ init_react_import();
|
|
696
701
|
// reducer/index.ts
|
697
702
|
init_react_import();
|
698
703
|
|
699
|
-
// reducer/
|
704
|
+
// reducer/actions/set.ts
|
700
705
|
init_react_import();
|
701
706
|
|
702
|
-
// lib/
|
707
|
+
// lib/data/walk-app-state.ts
|
703
708
|
init_react_import();
|
704
|
-
var insert = (list, index, item) => {
|
705
|
-
const result = Array.from(list);
|
706
|
-
result.splice(index, 0, item);
|
707
|
-
return result;
|
708
|
-
};
|
709
|
-
|
710
|
-
// lib/remove.ts
|
711
|
-
init_react_import();
|
712
|
-
var remove = (list, index) => {
|
713
|
-
const result = Array.from(list);
|
714
|
-
result.splice(index, 1);
|
715
|
-
return result;
|
716
|
-
};
|
717
709
|
|
718
|
-
// lib/
|
710
|
+
// lib/data/for-each-slot.ts
|
719
711
|
init_react_import();
|
720
|
-
|
721
|
-
|
722
|
-
|
723
|
-
|
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
|
+
}
|
724
729
|
}
|
725
|
-
|
726
|
-
return (item == null ? void 0 : item.props) ? __spreadProps(__spreadValues({}, item), { props: dynamicProps[item.props.id] || item.props }) : void 0;
|
727
|
-
}
|
728
|
-
|
729
|
-
// lib/reduce-related-zones.ts
|
730
|
-
init_react_import();
|
730
|
+
};
|
731
731
|
|
732
|
-
// lib/
|
732
|
+
// lib/data/for-related-zones.ts
|
733
733
|
init_react_import();
|
734
|
-
import { v4 as uuidv4 } from "uuid";
|
735
|
-
var generateId = (type) => type ? `${type}-${uuidv4()}` : uuidv4();
|
736
734
|
|
737
735
|
// lib/get-zone-id.ts
|
738
736
|
init_react_import();
|
@@ -746,301 +744,566 @@ var getZoneId = (zoneCompound) => {
|
|
746
744
|
return [rootDroppableId, zoneCompound];
|
747
745
|
};
|
748
746
|
|
749
|
-
// lib/
|
750
|
-
function
|
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) => {
|
751
760
|
return __spreadProps(__spreadValues({}, data), {
|
752
|
-
|
753
|
-
(acc,
|
754
|
-
|
755
|
-
|
756
|
-
const zones = data.zones;
|
757
|
-
return fn(acc, key, zones[key]);
|
761
|
+
props: Object.entries(data.props).reduce(
|
762
|
+
(acc, [propKey, propVal]) => {
|
763
|
+
if (isSlot(propVal)) {
|
764
|
+
return acc;
|
758
765
|
}
|
759
|
-
return __spreadProps(__spreadValues({}, acc), { [
|
766
|
+
return __spreadProps(__spreadValues({}, acc), { [propKey]: propVal });
|
760
767
|
},
|
761
|
-
{}
|
768
|
+
{ id: data.props.id }
|
762
769
|
)
|
763
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
|
+
});
|
764
895
|
}
|
765
|
-
|
766
|
-
|
767
|
-
|
768
|
-
|
769
|
-
|
770
|
-
|
771
|
-
|
896
|
+
|
897
|
+
// reducer/actions/set.ts
|
898
|
+
var setAction = (state, action, appStore) => {
|
899
|
+
if (typeof action.state === "object") {
|
900
|
+
const newState = __spreadValues(__spreadValues({}, state), action.state);
|
901
|
+
if (action.state.indexes) {
|
902
|
+
return newState;
|
903
|
+
}
|
904
|
+
console.warn(
|
905
|
+
"`set` is expensive and may cause unnecessary re-renders. Consider using a more atomic action instead."
|
906
|
+
);
|
907
|
+
return walkAppState(newState, appStore.config);
|
908
|
+
}
|
909
|
+
return __spreadValues(__spreadValues({}, state), action.state(state));
|
910
|
+
};
|
911
|
+
|
912
|
+
// reducer/actions/insert.ts
|
913
|
+
init_react_import();
|
914
|
+
|
915
|
+
// lib/data/insert.ts
|
916
|
+
init_react_import();
|
917
|
+
var insert = (list, index, item) => {
|
918
|
+
const result = Array.from(list || []);
|
919
|
+
result.splice(index, 0, item);
|
920
|
+
return result;
|
921
|
+
};
|
922
|
+
|
923
|
+
// lib/generate-id.ts
|
924
|
+
init_react_import();
|
925
|
+
import { v4 as uuidv4 } from "uuid";
|
926
|
+
var generateId = (type) => type ? `${type}-${uuidv4()}` : uuidv4();
|
927
|
+
|
928
|
+
// lib/data/get-ids-for-parent.ts
|
929
|
+
init_react_import();
|
930
|
+
var getIdsForParent = (zoneCompound, state) => {
|
931
|
+
const [parentId] = zoneCompound.split(":");
|
932
|
+
const node = state.indexes.nodes[parentId];
|
933
|
+
return ((node == null ? void 0 : node.path) || []).map((p) => p.split(":")[0]);
|
934
|
+
};
|
935
|
+
|
936
|
+
// lib/data/populate-ids.ts
|
937
|
+
init_react_import();
|
938
|
+
var populateIds = (data, config, override = false) => {
|
939
|
+
const id = generateId(data.type);
|
940
|
+
return walkTree(
|
941
|
+
__spreadProps(__spreadValues({}, data), {
|
942
|
+
props: override ? __spreadProps(__spreadValues({}, data.props), { id }) : __spreadValues({ id }, data.props)
|
943
|
+
}),
|
944
|
+
config,
|
945
|
+
(contents) => contents.map((item) => {
|
946
|
+
const id2 = generateId(item.type);
|
947
|
+
return __spreadProps(__spreadValues({}, item), {
|
948
|
+
props: override ? __spreadProps(__spreadValues({}, item.props), { id: id2 }) : __spreadValues({ id: id2 }, item.props)
|
949
|
+
});
|
950
|
+
})
|
951
|
+
);
|
952
|
+
};
|
953
|
+
|
954
|
+
// reducer/actions/insert.ts
|
955
|
+
function insertAction(state, action, appStore) {
|
956
|
+
const id = action.id || generateId(action.componentType);
|
957
|
+
const emptyComponentData = populateIds(
|
958
|
+
{
|
959
|
+
type: action.componentType,
|
960
|
+
props: __spreadProps(__spreadValues({}, appStore.config.components[action.componentType].defaultProps || {}), {
|
961
|
+
id
|
962
|
+
})
|
963
|
+
},
|
964
|
+
appStore.config
|
965
|
+
);
|
966
|
+
const [parentId] = action.destinationZone.split(":");
|
967
|
+
const idsInPath = getIdsForParent(action.destinationZone, state);
|
968
|
+
return walkAppState(
|
969
|
+
state,
|
970
|
+
appStore.config,
|
971
|
+
(content, zoneCompound) => {
|
972
|
+
if (zoneCompound === action.destinationZone) {
|
973
|
+
return insert(
|
974
|
+
content || [],
|
975
|
+
action.destinationIndex,
|
976
|
+
emptyComponentData
|
977
|
+
);
|
772
978
|
}
|
773
|
-
return
|
979
|
+
return content;
|
774
980
|
},
|
775
|
-
{
|
981
|
+
(childItem, path) => {
|
982
|
+
if (childItem.props.id === id || childItem.props.id === parentId) {
|
983
|
+
return childItem;
|
984
|
+
} else if (idsInPath.includes(childItem.props.id)) {
|
985
|
+
return childItem;
|
986
|
+
} else if (path.includes(action.destinationZone)) {
|
987
|
+
return childItem;
|
988
|
+
}
|
989
|
+
return null;
|
990
|
+
}
|
991
|
+
);
|
992
|
+
}
|
993
|
+
|
994
|
+
// reducer/actions/replace.ts
|
995
|
+
init_react_import();
|
996
|
+
var replaceAction = (state, action, appStore) => {
|
997
|
+
const [parentId] = action.destinationZone.split(":");
|
998
|
+
const idsInPath = getIdsForParent(action.destinationZone, state);
|
999
|
+
const originalId = state.indexes.zones[action.destinationZone].contentIds[action.destinationIndex];
|
1000
|
+
const idChanged = originalId !== action.data.props.id;
|
1001
|
+
if (idChanged) {
|
1002
|
+
throw new Error(
|
1003
|
+
`Can't change the id during a replace action. Please us "remove" and "insert" to define a new node.`
|
1004
|
+
);
|
1005
|
+
}
|
1006
|
+
const data = populateIds(action.data, appStore.config);
|
1007
|
+
return walkAppState(
|
1008
|
+
state,
|
1009
|
+
appStore.config,
|
1010
|
+
(content, zoneCompound) => {
|
1011
|
+
const newContent = [...content];
|
1012
|
+
if (zoneCompound === action.destinationZone) {
|
1013
|
+
newContent[action.destinationIndex] = data;
|
1014
|
+
}
|
1015
|
+
return newContent;
|
1016
|
+
},
|
1017
|
+
(childItem, path) => {
|
1018
|
+
const pathIds = path.map((p) => p.split(":")[0]);
|
1019
|
+
if (childItem.props.id === data.props.id) {
|
1020
|
+
return data;
|
1021
|
+
} else if (childItem.props.id === parentId) {
|
1022
|
+
return childItem;
|
1023
|
+
} else if (idsInPath.indexOf(childItem.props.id) > -1) {
|
1024
|
+
return childItem;
|
1025
|
+
} else if (pathIds.indexOf(data.props.id) > -1) {
|
1026
|
+
return childItem;
|
1027
|
+
}
|
1028
|
+
return null;
|
1029
|
+
}
|
776
1030
|
);
|
777
1031
|
};
|
778
|
-
|
779
|
-
|
780
|
-
|
781
|
-
|
782
|
-
|
783
|
-
|
784
|
-
|
785
|
-
|
1032
|
+
|
1033
|
+
// reducer/actions/replace-root.ts
|
1034
|
+
init_react_import();
|
1035
|
+
var replaceRootAction = (state, action, appStore) => {
|
1036
|
+
return walkAppState(
|
1037
|
+
state,
|
1038
|
+
appStore.config,
|
1039
|
+
(content) => content,
|
1040
|
+
(childItem) => {
|
1041
|
+
if (childItem.props.id === "root") {
|
1042
|
+
return __spreadProps(__spreadValues({}, childItem), {
|
1043
|
+
props: __spreadValues(__spreadValues({}, childItem.props), action.root.props),
|
1044
|
+
readOnly: action.root.readOnly
|
786
1045
|
});
|
787
1046
|
}
|
788
|
-
return
|
789
|
-
}
|
790
|
-
{}
|
1047
|
+
return childItem;
|
1048
|
+
}
|
791
1049
|
);
|
792
1050
|
};
|
793
|
-
|
794
|
-
|
795
|
-
|
796
|
-
|
797
|
-
|
798
|
-
|
799
|
-
|
800
|
-
|
801
|
-
|
802
|
-
return
|
803
|
-
const dupedZone = zone.map((zoneItem) => __spreadProps(__spreadValues({}, zoneItem), {
|
804
|
-
props: __spreadProps(__spreadValues({}, zoneItem.props), { id: generateId(zoneItem.type) })
|
805
|
-
}));
|
806
|
-
const dupeOfDupes = dupedZone.reduce(
|
807
|
-
(dupeOfDupes2, item2, index) => __spreadValues(__spreadValues({}, dupeOfDupes2), duplicateRelatedZones(zone[index], data, item2.props.id).zones),
|
808
|
-
acc
|
809
|
-
);
|
810
|
-
const [_, zoneId] = getZoneId(key);
|
811
|
-
return __spreadProps(__spreadValues({}, dupeOfDupes), {
|
812
|
-
[key]: zone,
|
813
|
-
[`${newId}:${zoneId}`]: dupedZone
|
814
|
-
});
|
815
|
-
});
|
1051
|
+
|
1052
|
+
// reducer/actions/duplicate.ts
|
1053
|
+
init_react_import();
|
1054
|
+
|
1055
|
+
// lib/data/get-item.ts
|
1056
|
+
init_react_import();
|
1057
|
+
function getItem(selector, state) {
|
1058
|
+
var _a, _b;
|
1059
|
+
const zone = (_a = state.indexes.zones) == null ? void 0 : _a[selector.zone || rootDroppableId];
|
1060
|
+
return zone ? (_b = state.indexes.nodes[zone.contentIds[selector.index]]) == null ? void 0 : _b.data : void 0;
|
816
1061
|
}
|
817
1062
|
|
818
|
-
// reducer/
|
819
|
-
|
820
|
-
|
821
|
-
|
822
|
-
|
823
|
-
|
824
|
-
|
825
|
-
}
|
826
|
-
|
827
|
-
|
828
|
-
zones: __spreadProps(__spreadValues({}, newData.zones), {
|
829
|
-
[action.destinationZone]: replace(
|
830
|
-
newData.zones[action.destinationZone],
|
831
|
-
action.destinationIndex,
|
832
|
-
action.data
|
833
|
-
)
|
1063
|
+
// reducer/actions/duplicate.ts
|
1064
|
+
function duplicateAction(state, action, appStore) {
|
1065
|
+
const item = getItem(
|
1066
|
+
{ index: action.sourceIndex, zone: action.sourceZone },
|
1067
|
+
state
|
1068
|
+
);
|
1069
|
+
const idsInPath = getIdsForParent(action.sourceZone, state);
|
1070
|
+
const newItem = __spreadProps(__spreadValues({}, item), {
|
1071
|
+
props: __spreadProps(__spreadValues({}, item.props), {
|
1072
|
+
id: generateId(item.type)
|
834
1073
|
})
|
835
1074
|
});
|
836
|
-
|
837
|
-
|
838
|
-
|
839
|
-
|
840
|
-
|
841
|
-
|
842
|
-
|
843
|
-
|
844
|
-
|
845
|
-
|
846
|
-
|
847
|
-
|
848
|
-
|
849
|
-
|
850
|
-
|
851
|
-
|
852
|
-
|
853
|
-
|
854
|
-
|
855
|
-
|
856
|
-
|
857
|
-
|
858
|
-
|
859
|
-
|
860
|
-
|
1075
|
+
const modified = walkAppState(
|
1076
|
+
state,
|
1077
|
+
appStore.config,
|
1078
|
+
(content, zoneCompound) => {
|
1079
|
+
if (zoneCompound === action.sourceZone) {
|
1080
|
+
return insert(content, action.sourceIndex + 1, item);
|
1081
|
+
}
|
1082
|
+
return content;
|
1083
|
+
},
|
1084
|
+
(childItem, path, index) => {
|
1085
|
+
const zoneCompound = path[path.length - 1];
|
1086
|
+
const parents = path.map((p) => p.split(":")[0]);
|
1087
|
+
if (parents.indexOf(newItem.props.id) > -1) {
|
1088
|
+
return __spreadProps(__spreadValues({}, childItem), {
|
1089
|
+
props: __spreadProps(__spreadValues({}, childItem.props), {
|
1090
|
+
id: generateId(childItem.type)
|
1091
|
+
})
|
1092
|
+
});
|
1093
|
+
}
|
1094
|
+
if (zoneCompound === action.sourceZone && index === action.sourceIndex + 1) {
|
1095
|
+
return newItem;
|
1096
|
+
}
|
1097
|
+
const [sourceZoneParent] = action.sourceZone.split(":");
|
1098
|
+
if (sourceZoneParent === childItem.props.id || idsInPath.indexOf(childItem.props.id) > -1) {
|
1099
|
+
return childItem;
|
1100
|
+
}
|
1101
|
+
return null;
|
1102
|
+
}
|
1103
|
+
);
|
1104
|
+
return __spreadProps(__spreadValues({}, modified), {
|
1105
|
+
ui: __spreadProps(__spreadValues({}, modified.ui), {
|
1106
|
+
itemSelector: {
|
1107
|
+
index: action.sourceIndex + 1,
|
1108
|
+
zone: action.sourceZone
|
1109
|
+
}
|
861
1110
|
})
|
862
1111
|
});
|
863
1112
|
}
|
864
|
-
|
865
|
-
|
866
|
-
|
867
|
-
|
868
|
-
|
869
|
-
|
870
|
-
|
871
|
-
|
872
|
-
|
873
|
-
|
874
|
-
const
|
875
|
-
|
876
|
-
|
877
|
-
[action.destinationZone]: reorder(
|
878
|
-
newData.zones[action.destinationZone],
|
879
|
-
action.sourceIndex,
|
880
|
-
action.destinationIndex
|
881
|
-
)
|
882
|
-
})
|
883
|
-
});
|
1113
|
+
|
1114
|
+
// reducer/actions/reorder.ts
|
1115
|
+
init_react_import();
|
1116
|
+
|
1117
|
+
// reducer/actions/move.ts
|
1118
|
+
init_react_import();
|
1119
|
+
|
1120
|
+
// lib/data/remove.ts
|
1121
|
+
init_react_import();
|
1122
|
+
var remove = (list, index) => {
|
1123
|
+
const result = Array.from(list);
|
1124
|
+
result.splice(index, 1);
|
1125
|
+
return result;
|
884
1126
|
};
|
885
|
-
|
886
|
-
|
887
|
-
|
888
|
-
|
889
|
-
|
890
|
-
const item = getItem(
|
891
|
-
{ index: action.sourceIndex, zone: action.sourceZone },
|
892
|
-
data
|
893
|
-
);
|
894
|
-
const newItem = __spreadProps(__spreadValues({}, item), {
|
895
|
-
props: __spreadProps(__spreadValues({}, item.props), {
|
896
|
-
id: generateId(item.type)
|
897
|
-
})
|
898
|
-
});
|
899
|
-
const dataWithRelatedDuplicated = duplicateRelatedZones(
|
900
|
-
item,
|
901
|
-
data,
|
902
|
-
newItem.props.id
|
903
|
-
);
|
904
|
-
if (action.sourceZone === rootDroppableId) {
|
905
|
-
return __spreadProps(__spreadValues({}, dataWithRelatedDuplicated), {
|
906
|
-
content: insert(data.content, action.sourceIndex + 1, newItem)
|
907
|
-
});
|
908
|
-
}
|
909
|
-
return __spreadProps(__spreadValues({}, dataWithRelatedDuplicated), {
|
910
|
-
zones: __spreadProps(__spreadValues({}, dataWithRelatedDuplicated.zones), {
|
911
|
-
[action.sourceZone]: insert(
|
912
|
-
dataWithRelatedDuplicated.zones[action.sourceZone],
|
913
|
-
action.sourceIndex + 1,
|
914
|
-
newItem
|
915
|
-
)
|
916
|
-
})
|
917
|
-
});
|
918
|
-
}
|
919
|
-
if (action.type === "reorder") {
|
920
|
-
return reorderAction(data, action);
|
1127
|
+
|
1128
|
+
// reducer/actions/move.ts
|
1129
|
+
var moveAction = (state, action, appStore) => {
|
1130
|
+
if (action.sourceZone === action.destinationZone && action.sourceIndex === action.destinationIndex) {
|
1131
|
+
return state;
|
921
1132
|
}
|
922
|
-
|
923
|
-
|
924
|
-
|
1133
|
+
const item = getItem(
|
1134
|
+
{ zone: action.sourceZone, index: action.sourceIndex },
|
1135
|
+
state
|
1136
|
+
);
|
1137
|
+
if (!item) return state;
|
1138
|
+
const idsInSourcePath = getIdsForParent(action.sourceZone, state);
|
1139
|
+
const idsInDestinationPath = getIdsForParent(action.destinationZone, state);
|
1140
|
+
return walkAppState(
|
1141
|
+
state,
|
1142
|
+
appStore.config,
|
1143
|
+
(content, zoneCompound) => {
|
1144
|
+
if (zoneCompound === action.sourceZone && zoneCompound === action.destinationZone) {
|
1145
|
+
return insert(
|
1146
|
+
remove(content, action.sourceIndex),
|
1147
|
+
action.destinationIndex,
|
1148
|
+
item
|
1149
|
+
);
|
1150
|
+
} else if (zoneCompound === action.sourceZone) {
|
1151
|
+
return remove(content, action.sourceIndex);
|
1152
|
+
} else if (zoneCompound === action.destinationZone) {
|
1153
|
+
return insert(content, action.destinationIndex, item);
|
1154
|
+
}
|
1155
|
+
return content;
|
1156
|
+
},
|
1157
|
+
(childItem, path) => {
|
1158
|
+
const [sourceZoneParent] = action.sourceZone.split(":");
|
1159
|
+
const [destinationZoneParent] = action.destinationZone.split(":");
|
1160
|
+
const childId = childItem.props.id;
|
1161
|
+
if (sourceZoneParent === childId || destinationZoneParent === childId || item.props.id === childId || idsInSourcePath.indexOf(childId) > -1 || idsInDestinationPath.indexOf(childId) > -1 || path.includes(action.destinationZone)) {
|
1162
|
+
return childItem;
|
1163
|
+
}
|
1164
|
+
return null;
|
925
1165
|
}
|
926
|
-
|
927
|
-
|
928
|
-
|
929
|
-
|
930
|
-
|
931
|
-
|
932
|
-
|
933
|
-
|
934
|
-
|
935
|
-
|
936
|
-
|
937
|
-
|
938
|
-
|
939
|
-
|
940
|
-
|
941
|
-
|
942
|
-
|
943
|
-
|
944
|
-
|
945
|
-
|
946
|
-
|
947
|
-
|
1166
|
+
);
|
1167
|
+
};
|
1168
|
+
|
1169
|
+
// reducer/actions/reorder.ts
|
1170
|
+
var reorderAction = (state, action, appStore) => {
|
1171
|
+
return moveAction(
|
1172
|
+
state,
|
1173
|
+
{
|
1174
|
+
type: "move",
|
1175
|
+
sourceIndex: action.sourceIndex,
|
1176
|
+
sourceZone: action.destinationZone,
|
1177
|
+
destinationIndex: action.destinationIndex,
|
1178
|
+
destinationZone: action.destinationZone
|
1179
|
+
},
|
1180
|
+
appStore
|
1181
|
+
);
|
1182
|
+
};
|
1183
|
+
|
1184
|
+
// reducer/actions/remove.ts
|
1185
|
+
init_react_import();
|
1186
|
+
var removeAction = (state, action, appStore) => {
|
1187
|
+
const item = getItem({ index: action.index, zone: action.zone }, state);
|
1188
|
+
const nodesToDelete = Object.entries(state.indexes.nodes).reduce(
|
1189
|
+
(acc, [nodeId, nodeData]) => {
|
1190
|
+
const pathIds = nodeData.path.map((p) => p.split(":")[0]);
|
1191
|
+
if (pathIds.includes(item.props.id)) {
|
1192
|
+
return [...acc, nodeId];
|
1193
|
+
}
|
1194
|
+
return acc;
|
1195
|
+
},
|
1196
|
+
[item.props.id]
|
1197
|
+
);
|
1198
|
+
const newState = walkAppState(
|
1199
|
+
state,
|
1200
|
+
appStore.config,
|
1201
|
+
(content, zoneCompound) => {
|
1202
|
+
if (zoneCompound === action.zone) {
|
1203
|
+
return remove(content, action.index);
|
1204
|
+
}
|
1205
|
+
return content;
|
948
1206
|
}
|
949
|
-
|
950
|
-
|
951
|
-
|
952
|
-
|
953
|
-
|
954
|
-
newData.zones[action.sourceZone],
|
955
|
-
action.sourceIndex
|
956
|
-
)
|
957
|
-
})
|
958
|
-
});
|
1207
|
+
);
|
1208
|
+
Object.keys(newState.data.zones || {}).forEach((zoneCompound) => {
|
1209
|
+
const parentId = zoneCompound.split(":")[0];
|
1210
|
+
if (nodesToDelete.includes(parentId) && newState.data.zones) {
|
1211
|
+
delete newState.data.zones[zoneCompound];
|
959
1212
|
}
|
960
|
-
|
961
|
-
|
962
|
-
|
963
|
-
|
964
|
-
|
965
|
-
),
|
966
|
-
[action.destinationZone]: insert(
|
967
|
-
newData.zones[action.destinationZone],
|
968
|
-
action.destinationIndex,
|
969
|
-
item
|
970
|
-
)
|
971
|
-
})
|
972
|
-
});
|
973
|
-
}
|
974
|
-
if (action.type === "replace") {
|
975
|
-
return replaceAction(data, action);
|
976
|
-
}
|
977
|
-
if (action.type === "remove") {
|
978
|
-
const item = getItem({ index: action.index, zone: action.zone }, data);
|
979
|
-
const dataWithRelatedRemoved = setupZone(
|
980
|
-
removeRelatedZones(item, data),
|
981
|
-
action.zone
|
982
|
-
);
|
983
|
-
if (action.zone === rootDroppableId) {
|
984
|
-
return __spreadProps(__spreadValues({}, dataWithRelatedRemoved), {
|
985
|
-
content: remove(data.content, action.index)
|
986
|
-
});
|
1213
|
+
});
|
1214
|
+
Object.keys(newState.indexes.zones).forEach((zoneCompound) => {
|
1215
|
+
const parentId = zoneCompound.split(":")[0];
|
1216
|
+
if (nodesToDelete.includes(parentId)) {
|
1217
|
+
delete newState.indexes.zones[zoneCompound];
|
987
1218
|
}
|
988
|
-
|
989
|
-
|
990
|
-
|
991
|
-
|
992
|
-
|
993
|
-
|
994
|
-
|
995
|
-
|
996
|
-
|
997
|
-
|
998
|
-
|
999
|
-
|
1000
|
-
|
1219
|
+
});
|
1220
|
+
nodesToDelete.forEach((id) => {
|
1221
|
+
delete newState.indexes.nodes[id];
|
1222
|
+
});
|
1223
|
+
return newState;
|
1224
|
+
};
|
1225
|
+
|
1226
|
+
// reducer/actions/register-zone.ts
|
1227
|
+
init_react_import();
|
1228
|
+
var zoneCache = {};
|
1229
|
+
function registerZoneAction(state, action) {
|
1230
|
+
if (zoneCache[action.zone]) {
|
1231
|
+
return __spreadProps(__spreadValues({}, state), {
|
1232
|
+
data: __spreadProps(__spreadValues({}, state.data), {
|
1233
|
+
zones: __spreadProps(__spreadValues({}, state.data.zones), {
|
1001
1234
|
[action.zone]: zoneCache[action.zone]
|
1002
1235
|
})
|
1003
|
-
})
|
1004
|
-
|
1005
|
-
|
1006
|
-
|
1007
|
-
|
1008
|
-
|
1009
|
-
|
1010
|
-
|
1011
|
-
|
1012
|
-
}
|
1013
|
-
return __spreadProps(__spreadValues({}, data), { zones: _zones });
|
1236
|
+
}),
|
1237
|
+
indexes: __spreadProps(__spreadValues({}, state.indexes), {
|
1238
|
+
zones: __spreadProps(__spreadValues({}, state.indexes.zones), {
|
1239
|
+
[action.zone]: __spreadProps(__spreadValues({}, state.indexes.zones[action.zone]), {
|
1240
|
+
contentIds: zoneCache[action.zone].map((item) => item.props.id),
|
1241
|
+
type: "dropzone"
|
1242
|
+
})
|
1243
|
+
})
|
1244
|
+
})
|
1245
|
+
});
|
1014
1246
|
}
|
1015
|
-
|
1016
|
-
|
1017
|
-
|
1018
|
-
|
1019
|
-
|
1247
|
+
return __spreadProps(__spreadValues({}, state), { data: setupZone(state.data, action.zone) });
|
1248
|
+
}
|
1249
|
+
function unregisterZoneAction(state, action) {
|
1250
|
+
const _zones = __spreadValues({}, state.data.zones || {});
|
1251
|
+
const zoneIndex = __spreadValues({}, state.indexes.zones || {});
|
1252
|
+
if (_zones[action.zone]) {
|
1253
|
+
zoneCache[action.zone] = _zones[action.zone];
|
1254
|
+
delete _zones[action.zone];
|
1020
1255
|
}
|
1021
|
-
|
1256
|
+
delete zoneIndex[action.zone];
|
1257
|
+
return __spreadProps(__spreadValues({}, state), {
|
1258
|
+
data: __spreadProps(__spreadValues({}, state.data), {
|
1259
|
+
zones: _zones
|
1260
|
+
}),
|
1261
|
+
indexes: __spreadProps(__spreadValues({}, state.indexes), {
|
1262
|
+
zones: zoneIndex
|
1263
|
+
})
|
1264
|
+
});
|
1022
1265
|
}
|
1023
1266
|
|
1024
|
-
// reducer/
|
1267
|
+
// reducer/actions/set-data.ts
|
1025
1268
|
init_react_import();
|
1026
|
-
var
|
1027
|
-
if (action.
|
1028
|
-
|
1029
|
-
|
1030
|
-
|
1031
|
-
return
|
1032
|
-
|
1033
|
-
|
1034
|
-
|
1035
|
-
|
1036
|
-
|
1269
|
+
var setDataAction = (state, action, appStore) => {
|
1270
|
+
if (typeof action.data === "object") {
|
1271
|
+
console.warn(
|
1272
|
+
"`setData` is expensive and may cause unnecessary re-renders. Consider using a more atomic action instead."
|
1273
|
+
);
|
1274
|
+
return walkAppState(
|
1275
|
+
__spreadProps(__spreadValues({}, state), {
|
1276
|
+
data: __spreadValues(__spreadValues({}, state.data), action.data)
|
1277
|
+
}),
|
1278
|
+
appStore.config
|
1279
|
+
);
|
1037
1280
|
}
|
1038
|
-
|
1039
|
-
|
1040
|
-
|
1281
|
+
return walkAppState(
|
1282
|
+
__spreadProps(__spreadValues({}, state), {
|
1283
|
+
data: __spreadValues(__spreadValues({}, state.data), action.data(state.data))
|
1284
|
+
}),
|
1285
|
+
appStore.config
|
1286
|
+
);
|
1287
|
+
};
|
1288
|
+
|
1289
|
+
// reducer/actions/set-ui.ts
|
1290
|
+
init_react_import();
|
1291
|
+
var setUiAction = (state, action) => {
|
1292
|
+
if (typeof action.ui === "object") {
|
1293
|
+
return __spreadProps(__spreadValues({}, state), {
|
1294
|
+
ui: __spreadValues(__spreadValues({}, state.ui), action.ui)
|
1041
1295
|
});
|
1042
1296
|
}
|
1043
|
-
return
|
1297
|
+
return __spreadProps(__spreadValues({}, state), {
|
1298
|
+
ui: __spreadValues(__spreadValues({}, state.ui), action.ui(state.ui))
|
1299
|
+
});
|
1300
|
+
};
|
1301
|
+
|
1302
|
+
// lib/data/make-state-public.ts
|
1303
|
+
init_react_import();
|
1304
|
+
var makeStatePublic = (state) => {
|
1305
|
+
const { data, ui } = state;
|
1306
|
+
return { data, ui };
|
1044
1307
|
};
|
1045
1308
|
|
1046
1309
|
// reducer/actions.tsx
|
@@ -1060,29 +1323,54 @@ function storeInterceptor(reducer, record, onAction) {
|
|
1060
1323
|
if (typeof action.recordHistory !== "undefined" ? action.recordHistory : isValidType) {
|
1061
1324
|
if (record) record(newAppState);
|
1062
1325
|
}
|
1063
|
-
onAction == null ? void 0 : onAction(action, newAppState, state);
|
1326
|
+
onAction == null ? void 0 : onAction(action, makeStatePublic(newAppState), makeStatePublic(state));
|
1064
1327
|
return newAppState;
|
1065
1328
|
};
|
1066
1329
|
}
|
1067
|
-
var setAction = (state, action) => {
|
1068
|
-
if (typeof action.state === "object") {
|
1069
|
-
return __spreadValues(__spreadValues({}, state), action.state);
|
1070
|
-
}
|
1071
|
-
return __spreadValues(__spreadValues({}, state), action.state(state));
|
1072
|
-
};
|
1073
1330
|
function createReducer({
|
1074
|
-
config,
|
1075
1331
|
record,
|
1076
|
-
onAction
|
1332
|
+
onAction,
|
1333
|
+
appStore
|
1077
1334
|
}) {
|
1078
1335
|
return storeInterceptor(
|
1079
1336
|
(state, action) => {
|
1080
|
-
const data = reduceData(state.data, action, config);
|
1081
|
-
const ui = reduceUi(state.ui, action);
|
1082
1337
|
if (action.type === "set") {
|
1083
|
-
return setAction(state, action);
|
1338
|
+
return setAction(state, action, appStore);
|
1339
|
+
}
|
1340
|
+
if (action.type === "insert") {
|
1341
|
+
return insertAction(state, action, appStore);
|
1342
|
+
}
|
1343
|
+
if (action.type === "replace") {
|
1344
|
+
return replaceAction(state, action, appStore);
|
1345
|
+
}
|
1346
|
+
if (action.type === "replaceRoot") {
|
1347
|
+
return replaceRootAction(state, action, appStore);
|
1348
|
+
}
|
1349
|
+
if (action.type === "duplicate") {
|
1350
|
+
return duplicateAction(state, action, appStore);
|
1084
1351
|
}
|
1085
|
-
|
1352
|
+
if (action.type === "reorder") {
|
1353
|
+
return reorderAction(state, action, appStore);
|
1354
|
+
}
|
1355
|
+
if (action.type === "move") {
|
1356
|
+
return moveAction(state, action, appStore);
|
1357
|
+
}
|
1358
|
+
if (action.type === "remove") {
|
1359
|
+
return removeAction(state, action, appStore);
|
1360
|
+
}
|
1361
|
+
if (action.type === "registerZone") {
|
1362
|
+
return registerZoneAction(state, action);
|
1363
|
+
}
|
1364
|
+
if (action.type === "unregisterZone") {
|
1365
|
+
return unregisterZoneAction(state, action);
|
1366
|
+
}
|
1367
|
+
if (action.type === "setData") {
|
1368
|
+
return setDataAction(state, action, appStore);
|
1369
|
+
}
|
1370
|
+
if (action.type === "setUi") {
|
1371
|
+
return setUiAction(state, action);
|
1372
|
+
}
|
1373
|
+
return state;
|
1086
1374
|
},
|
1087
1375
|
record,
|
1088
1376
|
onAction
|
@@ -1100,128 +1388,6 @@ var defaultViewports = [
|
|
1100
1388
|
// store/index.ts
|
1101
1389
|
import { create as create2, useStore } from "zustand";
|
1102
1390
|
import { subscribeWithSelector as subscribeWithSelector2 } from "zustand/middleware";
|
1103
|
-
|
1104
|
-
// lib/resolve-data.ts
|
1105
|
-
init_react_import();
|
1106
|
-
|
1107
|
-
// lib/apply-dynamic-props.ts
|
1108
|
-
init_react_import();
|
1109
|
-
var applyDynamicProps = (data, dynamicProps, rootData) => {
|
1110
|
-
return __spreadProps(__spreadValues({}, data), {
|
1111
|
-
root: rootData ? __spreadValues(__spreadValues({}, data.root), rootData ? rootData : {}) : data.root,
|
1112
|
-
content: data.content.map((item) => {
|
1113
|
-
return dynamicProps[item.props.id] ? __spreadValues(__spreadValues({}, item), dynamicProps[item.props.id]) : item;
|
1114
|
-
}),
|
1115
|
-
zones: Object.keys(data.zones || {}).reduce((acc, zoneKey) => {
|
1116
|
-
return __spreadProps(__spreadValues({}, acc), {
|
1117
|
-
[zoneKey]: data.zones[zoneKey].map((item) => {
|
1118
|
-
return dynamicProps[item.props.id] ? __spreadValues(__spreadValues({}, item), dynamicProps[item.props.id]) : item;
|
1119
|
-
})
|
1120
|
-
});
|
1121
|
-
}, {})
|
1122
|
-
});
|
1123
|
-
};
|
1124
|
-
|
1125
|
-
// lib/flatten-data.ts
|
1126
|
-
init_react_import();
|
1127
|
-
var flattenData = (data) => {
|
1128
|
-
return Object.keys(data.zones || {}).reduce(
|
1129
|
-
(acc, zone) => [...acc, ...data.zones[zone]],
|
1130
|
-
data.content
|
1131
|
-
);
|
1132
|
-
};
|
1133
|
-
|
1134
|
-
// lib/resolve-data.ts
|
1135
|
-
import fdeq from "fast-deep-equal";
|
1136
|
-
var resolveData = (newAppState, appStoreData) => {
|
1137
|
-
const {
|
1138
|
-
state: appState,
|
1139
|
-
config,
|
1140
|
-
dispatch,
|
1141
|
-
resolveDataRuns,
|
1142
|
-
setComponentLoading,
|
1143
|
-
unsetComponentLoading,
|
1144
|
-
metadata,
|
1145
|
-
permissions
|
1146
|
-
} = appStoreData;
|
1147
|
-
const deferredSetStates = {};
|
1148
|
-
const _setComponentLoading = (id, loading, defer2 = 0) => {
|
1149
|
-
if (deferredSetStates[id]) {
|
1150
|
-
clearTimeout(deferredSetStates[id]);
|
1151
|
-
delete deferredSetStates[id];
|
1152
|
-
}
|
1153
|
-
deferredSetStates[id] = setTimeout(() => {
|
1154
|
-
if (loading) {
|
1155
|
-
setComponentLoading(id);
|
1156
|
-
} else {
|
1157
|
-
unsetComponentLoading(id);
|
1158
|
-
}
|
1159
|
-
delete deferredSetStates[id];
|
1160
|
-
}, defer2);
|
1161
|
-
};
|
1162
|
-
const runResolvers = () => __async(void 0, null, function* () {
|
1163
|
-
const newData = newAppState.data;
|
1164
|
-
const flatContent = flattenData(newData).filter(
|
1165
|
-
(item) => {
|
1166
|
-
var _a;
|
1167
|
-
return !!((_a = config.components[item.type]) == null ? void 0 : _a.resolveData);
|
1168
|
-
}
|
1169
|
-
);
|
1170
|
-
const applyIfChange = (dynamicDataMap, dynamicRoot) => {
|
1171
|
-
const processed = applyDynamicProps(
|
1172
|
-
__spreadValues({}, appState.data),
|
1173
|
-
dynamicDataMap,
|
1174
|
-
dynamicRoot
|
1175
|
-
);
|
1176
|
-
const processedAppState = __spreadProps(__spreadValues({}, appState), { data: processed });
|
1177
|
-
const containsChanges = !fdeq(appState, processedAppState);
|
1178
|
-
if (containsChanges) {
|
1179
|
-
dispatch({
|
1180
|
-
type: "set",
|
1181
|
-
state: (prev) => __spreadProps(__spreadValues({}, prev), {
|
1182
|
-
data: applyDynamicProps(prev.data, dynamicDataMap, dynamicRoot),
|
1183
|
-
ui: resolveDataRuns > 0 ? __spreadValues(__spreadValues({}, prev.ui), newAppState.ui) : prev.ui
|
1184
|
-
}),
|
1185
|
-
recordHistory: resolveDataRuns > 0
|
1186
|
-
});
|
1187
|
-
}
|
1188
|
-
};
|
1189
|
-
const promises = [];
|
1190
|
-
promises.push(
|
1191
|
-
(() => __async(void 0, null, function* () {
|
1192
|
-
_setComponentLoading("puck-root", true, 50);
|
1193
|
-
const dynamicRoot = yield resolveRootData(newData, config, metadata);
|
1194
|
-
applyIfChange({}, dynamicRoot);
|
1195
|
-
_setComponentLoading("puck-root", false);
|
1196
|
-
}))()
|
1197
|
-
);
|
1198
|
-
flatContent.forEach((item) => {
|
1199
|
-
promises.push(
|
1200
|
-
(() => __async(void 0, null, function* () {
|
1201
|
-
permissions.resolvePermissions({ item }, true);
|
1202
|
-
const dynamicData = yield resolveComponentData(
|
1203
|
-
item,
|
1204
|
-
config,
|
1205
|
-
metadata,
|
1206
|
-
(item2) => {
|
1207
|
-
_setComponentLoading(item2.props.id, true, 50);
|
1208
|
-
},
|
1209
|
-
(item2) => {
|
1210
|
-
deferredSetStates[item2.props.id];
|
1211
|
-
_setComponentLoading(item2.props.id, false);
|
1212
|
-
}
|
1213
|
-
);
|
1214
|
-
const dynamicDataMap = { [item.props.id]: dynamicData };
|
1215
|
-
applyIfChange(dynamicDataMap);
|
1216
|
-
}))()
|
1217
|
-
);
|
1218
|
-
});
|
1219
|
-
yield Promise.all(promises);
|
1220
|
-
});
|
1221
|
-
return runResolvers();
|
1222
|
-
};
|
1223
|
-
|
1224
|
-
// store/index.ts
|
1225
1391
|
import { createContext, useContext } from "react";
|
1226
1392
|
|
1227
1393
|
// store/slices/history.ts
|
@@ -1416,7 +1582,7 @@ var createHistorySlice = (set, get) => {
|
|
1416
1582
|
const { dispatch, history } = get();
|
1417
1583
|
dispatch({
|
1418
1584
|
type: "set",
|
1419
|
-
state: ((_a = history.histories[
|
1585
|
+
state: ((_a = history.histories[index]) == null ? void 0 : _a.state) || history.initialAppState
|
1420
1586
|
});
|
1421
1587
|
set({ history: __spreadProps(__spreadValues({}, history), { index }) });
|
1422
1588
|
},
|
@@ -1454,71 +1620,14 @@ function useRegisterHistorySlice(appStore, {
|
|
1454
1620
|
|
1455
1621
|
// store/slices/nodes.ts
|
1456
1622
|
init_react_import();
|
1457
|
-
import deepEqual from "fast-deep-equal";
|
1458
|
-
import { useEffect as useEffect3 } from "react";
|
1459
|
-
var partialDeepEqual = (newItem, existingItem) => {
|
1460
|
-
const filteredExistingItem = Object.keys(newItem).reduce(
|
1461
|
-
(acc, key) => __spreadProps(__spreadValues({}, acc), { [key]: existingItem[key] }),
|
1462
|
-
{}
|
1463
|
-
);
|
1464
|
-
return deepEqual(newItem, filteredExistingItem);
|
1465
|
-
};
|
1466
|
-
var generateNodesSlice = (data, appStore) => {
|
1467
|
-
const nodeIndex = {};
|
1468
|
-
const forAllData = (cb) => {
|
1469
|
-
data.content.forEach((data2, index) => {
|
1470
|
-
cb(data2, rootAreaId, rootZone, index);
|
1471
|
-
});
|
1472
|
-
Object.entries(data.zones || {}).forEach(([zoneCompound, content]) => {
|
1473
|
-
const [parentId, zone] = zoneCompound.split(":");
|
1474
|
-
content.forEach((data2, index) => {
|
1475
|
-
cb(data2, parentId, zone, index);
|
1476
|
-
});
|
1477
|
-
});
|
1478
|
-
};
|
1479
|
-
forAllData((data2, parentId, zone, index) => {
|
1480
|
-
nodeIndex[data2.props.id] = { data: data2, parentId, zone, path: [], index };
|
1481
|
-
});
|
1482
|
-
const nodes = appStore.getState().nodes;
|
1483
|
-
const registerNode = nodes.registerNode;
|
1484
|
-
Object.keys(nodeIndex).forEach((componentId) => {
|
1485
|
-
const details = nodeIndex[componentId];
|
1486
|
-
let currentDetails = details;
|
1487
|
-
let path = [];
|
1488
|
-
while ((currentDetails == null ? void 0 : currentDetails.parentId) !== rootAreaId) {
|
1489
|
-
path.unshift(`${currentDetails.parentId}:${currentDetails.zone}`);
|
1490
|
-
currentDetails = nodeIndex[currentDetails.parentId];
|
1491
|
-
}
|
1492
|
-
path.unshift(rootDroppableId);
|
1493
|
-
nodeIndex[componentId].path = path;
|
1494
|
-
registerNode(componentId, nodeIndex[componentId]);
|
1495
|
-
});
|
1496
|
-
const rootProps = data.root.props || data.root;
|
1497
|
-
registerNode("root", {
|
1498
|
-
data: { type: "root", props: __spreadValues({ id: "root" }, rootProps) }
|
1499
|
-
});
|
1500
|
-
Object.keys(nodes.nodes).forEach((key) => {
|
1501
|
-
if (!nodeIndex[key] && key !== "root") {
|
1502
|
-
nodes.unregisterNode(key);
|
1503
|
-
}
|
1504
|
-
});
|
1505
|
-
};
|
1506
1623
|
var createNodesSlice = (set, get) => ({
|
1507
1624
|
nodes: {},
|
1508
1625
|
registerNode: (id, node) => {
|
1509
1626
|
const s = get().nodes;
|
1510
|
-
if (s.nodes[id] && partialDeepEqual(node, s.nodes[id])) {
|
1511
|
-
return;
|
1512
|
-
}
|
1513
1627
|
const emptyNode = {
|
1514
1628
|
id,
|
1515
1629
|
methods: { sync: () => null },
|
1516
|
-
|
1517
|
-
parentId: "",
|
1518
|
-
zone: "",
|
1519
|
-
path: [],
|
1520
|
-
element: null,
|
1521
|
-
index: -1
|
1630
|
+
element: null
|
1522
1631
|
};
|
1523
1632
|
const existingNode = s.nodes[id];
|
1524
1633
|
set({
|
@@ -1545,31 +1654,36 @@ var createNodesSlice = (set, get) => ({
|
|
1545
1654
|
}
|
1546
1655
|
}
|
1547
1656
|
});
|
1548
|
-
var useRegisterNodesSlice = (appStore) => {
|
1549
|
-
useEffect3(() => {
|
1550
|
-
return appStore.subscribe(
|
1551
|
-
(s) => s.state.data,
|
1552
|
-
(data) => generateNodesSlice(data, appStore)
|
1553
|
-
);
|
1554
|
-
}, []);
|
1555
|
-
};
|
1556
1657
|
|
1557
1658
|
// store/slices/permissions.ts
|
1558
1659
|
init_react_import();
|
1559
|
-
import { useEffect as
|
1660
|
+
import { useEffect as useEffect3 } from "react";
|
1661
|
+
|
1662
|
+
// lib/data/flatten-data.ts
|
1663
|
+
init_react_import();
|
1664
|
+
var flattenData = (state, config) => {
|
1665
|
+
const data = [];
|
1666
|
+
walkAppState(
|
1667
|
+
state,
|
1668
|
+
config,
|
1669
|
+
(content) => content,
|
1670
|
+
(item) => {
|
1671
|
+
data.push(item);
|
1672
|
+
return null;
|
1673
|
+
}
|
1674
|
+
);
|
1675
|
+
return data;
|
1676
|
+
};
|
1677
|
+
|
1678
|
+
// store/slices/permissions.ts
|
1560
1679
|
var createPermissionsSlice = (set, get) => {
|
1561
1680
|
const resolvePermissions = (..._0) => __async(void 0, [..._0], function* (params = {}, force) {
|
1562
|
-
const { state, permissions } = get();
|
1681
|
+
const { state, permissions, config } = get();
|
1563
1682
|
const { cache, globalPermissions } = permissions;
|
1564
1683
|
const resolveDataForItem = (item2, force2 = false) => __async(void 0, null, function* () {
|
1565
1684
|
var _a, _b, _c;
|
1566
|
-
const {
|
1567
|
-
|
1568
|
-
state: appState,
|
1569
|
-
setComponentLoading,
|
1570
|
-
unsetComponentLoading
|
1571
|
-
} = get();
|
1572
|
-
const componentConfig = item2.type === "root" ? config.root : config.components[item2.type];
|
1685
|
+
const { config: config2, state: appState, setComponentLoading } = get();
|
1686
|
+
const componentConfig = item2.type === "root" ? config2.root : config2.components[item2.type];
|
1573
1687
|
if (!componentConfig) {
|
1574
1688
|
return;
|
1575
1689
|
}
|
@@ -1577,14 +1691,14 @@ var createPermissionsSlice = (set, get) => {
|
|
1577
1691
|
if (componentConfig.resolvePermissions) {
|
1578
1692
|
const changed = getChanged(item2, (_a = cache[item2.props.id]) == null ? void 0 : _a.lastData);
|
1579
1693
|
if (Object.values(changed).some((el) => el === true) || force2) {
|
1580
|
-
setComponentLoading(item2.props.id);
|
1694
|
+
const clearTimeout2 = setComponentLoading(item2.props.id, true, 50);
|
1581
1695
|
const resolvedPermissions = yield componentConfig.resolvePermissions(
|
1582
1696
|
item2,
|
1583
1697
|
{
|
1584
1698
|
changed,
|
1585
1699
|
lastPermissions: ((_b = cache[item2.props.id]) == null ? void 0 : _b.lastPermissions) || null,
|
1586
1700
|
permissions: initialPermissions,
|
1587
|
-
appState,
|
1701
|
+
appState: makeStatePublic(appState),
|
1588
1702
|
lastData: ((_c = cache[item2.props.id]) == null ? void 0 : _c.lastData) || null
|
1589
1703
|
}
|
1590
1704
|
);
|
@@ -1602,7 +1716,7 @@ var createPermissionsSlice = (set, get) => {
|
|
1602
1716
|
})
|
1603
1717
|
})
|
1604
1718
|
});
|
1605
|
-
|
1719
|
+
clearTimeout2();
|
1606
1720
|
}
|
1607
1721
|
}
|
1608
1722
|
});
|
@@ -1612,7 +1726,7 @@ var createPermissionsSlice = (set, get) => {
|
|
1612
1726
|
// Shim the root data in by conforming to component data shape
|
1613
1727
|
{
|
1614
1728
|
type: "root",
|
1615
|
-
props: __spreadProps(__spreadValues({}, appState.data.root.props), { id: "
|
1729
|
+
props: __spreadProps(__spreadValues({}, appState.data.root.props), { id: "root" })
|
1616
1730
|
},
|
1617
1731
|
force2
|
1618
1732
|
);
|
@@ -1621,14 +1735,13 @@ var createPermissionsSlice = (set, get) => {
|
|
1621
1735
|
if (item) {
|
1622
1736
|
yield resolveDataForItem(item, force);
|
1623
1737
|
} else if (type) {
|
1624
|
-
flattenData(state
|
1738
|
+
flattenData(state, config).filter((item2) => item2.type === type).map((item2) => __async(void 0, null, function* () {
|
1625
1739
|
yield resolveDataForItem(item2, force);
|
1626
1740
|
}));
|
1627
1741
|
} else if (root) {
|
1628
1742
|
resolveDataForRoot(force);
|
1629
1743
|
} else {
|
1630
|
-
|
1631
|
-
flattenData(state.data).map((item2) => __async(void 0, null, function* () {
|
1744
|
+
flattenData(state, config).map((item2) => __async(void 0, null, function* () {
|
1632
1745
|
yield resolveDataForItem(item2, force);
|
1633
1746
|
}));
|
1634
1747
|
}
|
@@ -1658,7 +1771,7 @@ var createPermissionsSlice = (set, get) => {
|
|
1658
1771
|
} else if (root) {
|
1659
1772
|
const rootConfig = config.root;
|
1660
1773
|
const initialPermissions = __spreadValues(__spreadValues({}, globalPermissions), rootConfig == null ? void 0 : rootConfig.permissions);
|
1661
|
-
const resolvedForItem = resolvedPermissions["
|
1774
|
+
const resolvedForItem = resolvedPermissions["root"];
|
1662
1775
|
return resolvedForItem ? __spreadValues(__spreadValues({}, globalPermissions), resolvedForItem) : initialPermissions;
|
1663
1776
|
}
|
1664
1777
|
return globalPermissions;
|
@@ -1668,7 +1781,7 @@ var createPermissionsSlice = (set, get) => {
|
|
1668
1781
|
};
|
1669
1782
|
};
|
1670
1783
|
var useRegisterPermissionsSlice = (appStore, globalPermissions) => {
|
1671
|
-
|
1784
|
+
useEffect3(() => {
|
1672
1785
|
const { permissions } = appStore.getState();
|
1673
1786
|
const { globalPermissions: existingGlobalPermissions } = permissions;
|
1674
1787
|
appStore.setState({
|
@@ -1678,7 +1791,7 @@ var useRegisterPermissionsSlice = (appStore, globalPermissions) => {
|
|
1678
1791
|
});
|
1679
1792
|
permissions.resolvePermissions();
|
1680
1793
|
}, [globalPermissions]);
|
1681
|
-
|
1794
|
+
useEffect3(() => {
|
1682
1795
|
return appStore.subscribe(
|
1683
1796
|
(s) => s.state.data,
|
1684
1797
|
() => {
|
@@ -1686,7 +1799,7 @@ var useRegisterPermissionsSlice = (appStore, globalPermissions) => {
|
|
1686
1799
|
}
|
1687
1800
|
);
|
1688
1801
|
}, []);
|
1689
|
-
|
1802
|
+
useEffect3(() => {
|
1690
1803
|
return appStore.subscribe(
|
1691
1804
|
(s) => s.config,
|
1692
1805
|
() => {
|
@@ -1698,12 +1811,13 @@ var useRegisterPermissionsSlice = (appStore, globalPermissions) => {
|
|
1698
1811
|
|
1699
1812
|
// store/slices/fields.ts
|
1700
1813
|
init_react_import();
|
1701
|
-
import { useCallback, useEffect as
|
1702
|
-
var
|
1814
|
+
import { useCallback, useEffect as useEffect4 } from "react";
|
1815
|
+
var createFieldsSlice = (_set, _get) => {
|
1703
1816
|
return {
|
1704
1817
|
fields: {},
|
1705
1818
|
loading: false,
|
1706
|
-
lastResolvedData: {}
|
1819
|
+
lastResolvedData: {},
|
1820
|
+
id: void 0
|
1707
1821
|
};
|
1708
1822
|
};
|
1709
1823
|
var useRegisterFieldsSlice = (appStore, id) => {
|
@@ -1711,10 +1825,10 @@ var useRegisterFieldsSlice = (appStore, id) => {
|
|
1711
1825
|
(reset) => __async(void 0, null, function* () {
|
1712
1826
|
var _a, _b;
|
1713
1827
|
const { fields, lastResolvedData } = appStore.getState().fields;
|
1714
|
-
const
|
1715
|
-
const node =
|
1828
|
+
const nodes = appStore.getState().state.indexes.nodes;
|
1829
|
+
const node = nodes[id || "root"];
|
1716
1830
|
const componentData = node == null ? void 0 : node.data;
|
1717
|
-
const parentNode = (node == null ? void 0 : node.parentId) ?
|
1831
|
+
const parentNode = (node == null ? void 0 : node.parentId) ? nodes[node.parentId] : null;
|
1718
1832
|
const parent = (parentNode == null ? void 0 : parentNode.data) || null;
|
1719
1833
|
const { getComponentConfig, state } = appStore.getState();
|
1720
1834
|
const componentConfig = getComponentConfig(componentData == null ? void 0 : componentData.type);
|
@@ -1724,7 +1838,7 @@ var useRegisterFieldsSlice = (appStore, id) => {
|
|
1724
1838
|
let lastFields = fields;
|
1725
1839
|
if (reset) {
|
1726
1840
|
appStore.setState((s) => ({
|
1727
|
-
fields: __spreadProps(__spreadValues({}, s.fields), { fields: defaultFields })
|
1841
|
+
fields: __spreadProps(__spreadValues({}, s.fields), { fields: defaultFields, id })
|
1728
1842
|
}));
|
1729
1843
|
lastFields = defaultFields;
|
1730
1844
|
}
|
@@ -1741,7 +1855,7 @@ var useRegisterFieldsSlice = (appStore, id) => {
|
|
1741
1855
|
fields: defaultFields,
|
1742
1856
|
lastFields,
|
1743
1857
|
lastData,
|
1744
|
-
appState: state,
|
1858
|
+
appState: makeStatePublic(state),
|
1745
1859
|
parent
|
1746
1860
|
});
|
1747
1861
|
clearTimeout(timeout3);
|
@@ -1752,26 +1866,44 @@ var useRegisterFieldsSlice = (appStore, id) => {
|
|
1752
1866
|
fields: {
|
1753
1867
|
fields: newFields,
|
1754
1868
|
loading: false,
|
1755
|
-
lastResolvedData: componentData
|
1869
|
+
lastResolvedData: componentData,
|
1870
|
+
id
|
1756
1871
|
}
|
1757
1872
|
});
|
1758
1873
|
} else {
|
1759
1874
|
appStore.setState((s) => ({
|
1760
|
-
fields: __spreadProps(__spreadValues({}, s.fields), { fields: defaultFields })
|
1875
|
+
fields: __spreadProps(__spreadValues({}, s.fields), { fields: defaultFields, id })
|
1761
1876
|
}));
|
1762
1877
|
}
|
1763
1878
|
}),
|
1764
1879
|
[id]
|
1765
1880
|
);
|
1766
|
-
|
1881
|
+
useEffect4(() => {
|
1767
1882
|
resolveFields(true);
|
1768
1883
|
return appStore.subscribe(
|
1769
|
-
(s) => s.
|
1884
|
+
(s) => s.state.indexes.nodes[id || "root"],
|
1770
1885
|
() => resolveFields()
|
1771
1886
|
);
|
1772
1887
|
}, [id]);
|
1773
1888
|
};
|
1774
1889
|
|
1890
|
+
// lib/data/to-root.ts
|
1891
|
+
init_react_import();
|
1892
|
+
var toRoot = (item) => {
|
1893
|
+
if ("type" in item && item.type !== "root") {
|
1894
|
+
throw new Error("Converting non-root item to root.");
|
1895
|
+
}
|
1896
|
+
const { readOnly } = item;
|
1897
|
+
if (item.props) {
|
1898
|
+
if ("id" in item.props) {
|
1899
|
+
const _a = item.props, { id } = _a, props = __objRest(_a, ["id"]);
|
1900
|
+
return { props, readOnly };
|
1901
|
+
}
|
1902
|
+
return { props: item.props, readOnly };
|
1903
|
+
}
|
1904
|
+
return { props: {}, readOnly };
|
1905
|
+
};
|
1906
|
+
|
1775
1907
|
// store/index.ts
|
1776
1908
|
var defaultAppState = {
|
1777
1909
|
data: { content: [], root: {}, zones: {} },
|
@@ -1792,92 +1924,186 @@ var defaultAppState = {
|
|
1792
1924
|
controlsVisible: true
|
1793
1925
|
},
|
1794
1926
|
field: { focus: null }
|
1927
|
+
},
|
1928
|
+
indexes: {
|
1929
|
+
nodes: {},
|
1930
|
+
zones: {}
|
1795
1931
|
}
|
1796
1932
|
};
|
1797
1933
|
var defaultPageFields = {
|
1798
1934
|
title: { type: "text" }
|
1799
|
-
};
|
1800
|
-
var createAppStore = (initialAppStore) => create2()(
|
1801
|
-
subscribeWithSelector2((set, get) =>
|
1802
|
-
|
1803
|
-
|
1804
|
-
|
1805
|
-
|
1806
|
-
|
1807
|
-
|
1808
|
-
|
1809
|
-
|
1810
|
-
|
1811
|
-
|
1812
|
-
|
1813
|
-
|
1814
|
-
|
1815
|
-
|
1816
|
-
|
1817
|
-
|
1818
|
-
|
1819
|
-
|
1820
|
-
|
1821
|
-
|
1822
|
-
|
1823
|
-
|
1824
|
-
|
1825
|
-
|
1826
|
-
|
1827
|
-
|
1828
|
-
|
1829
|
-
|
1830
|
-
|
1831
|
-
|
1832
|
-
|
1833
|
-
|
1834
|
-
|
1835
|
-
|
1836
|
-
|
1837
|
-
|
1838
|
-
|
1839
|
-
|
1840
|
-
|
1841
|
-
|
1842
|
-
|
1843
|
-
|
1844
|
-
|
1845
|
-
|
1846
|
-
})
|
1847
|
-
|
1848
|
-
|
1849
|
-
|
1850
|
-
|
1851
|
-
|
1852
|
-
|
1853
|
-
|
1854
|
-
|
1855
|
-
|
1856
|
-
|
1857
|
-
|
1858
|
-
|
1859
|
-
|
1860
|
-
|
1861
|
-
|
1862
|
-
|
1863
|
-
|
1864
|
-
|
1865
|
-
|
1866
|
-
|
1867
|
-
|
1868
|
-
|
1869
|
-
|
1870
|
-
|
1871
|
-
|
1872
|
-
|
1873
|
-
|
1874
|
-
|
1875
|
-
|
1876
|
-
|
1877
|
-
|
1878
|
-
|
1879
|
-
|
1880
|
-
|
1935
|
+
};
|
1936
|
+
var createAppStore = (initialAppStore) => create2()(
|
1937
|
+
subscribeWithSelector2((set, get) => {
|
1938
|
+
var _a, _b;
|
1939
|
+
return __spreadProps(__spreadValues({
|
1940
|
+
state: defaultAppState,
|
1941
|
+
config: { components: {} },
|
1942
|
+
componentState: {},
|
1943
|
+
plugins: [],
|
1944
|
+
overrides: {},
|
1945
|
+
viewports: defaultViewports,
|
1946
|
+
zoomConfig: {
|
1947
|
+
autoZoom: 1,
|
1948
|
+
rootHeight: 0,
|
1949
|
+
zoom: 1
|
1950
|
+
},
|
1951
|
+
status: "LOADING",
|
1952
|
+
iframe: {},
|
1953
|
+
metadata: {}
|
1954
|
+
}, initialAppStore), {
|
1955
|
+
fields: createFieldsSlice(set, get),
|
1956
|
+
history: createHistorySlice(set, get),
|
1957
|
+
nodes: createNodesSlice(set, get),
|
1958
|
+
permissions: createPermissionsSlice(set, get),
|
1959
|
+
getComponentConfig: (type) => {
|
1960
|
+
var _a2;
|
1961
|
+
const { config, selectedItem } = get();
|
1962
|
+
const rootFields = ((_a2 = config.root) == null ? void 0 : _a2.fields) || defaultPageFields;
|
1963
|
+
return type && type !== "root" ? config.components[type] : selectedItem ? config.components[selectedItem.type] : __spreadProps(__spreadValues({}, config.root), { fields: rootFields });
|
1964
|
+
},
|
1965
|
+
selectedItem: ((_a = initialAppStore == null ? void 0 : initialAppStore.state) == null ? void 0 : _a.ui.itemSelector) ? getItem(
|
1966
|
+
(_b = initialAppStore == null ? void 0 : initialAppStore.state) == null ? void 0 : _b.ui.itemSelector,
|
1967
|
+
initialAppStore.state
|
1968
|
+
) : null,
|
1969
|
+
dispatch: (action) => set((s) => {
|
1970
|
+
var _a2, _b2;
|
1971
|
+
const { record } = get().history;
|
1972
|
+
const dispatch = createReducer({
|
1973
|
+
record,
|
1974
|
+
appStore: s
|
1975
|
+
});
|
1976
|
+
const state = dispatch(s.state, action);
|
1977
|
+
const selectedItem = state.ui.itemSelector ? getItem(state.ui.itemSelector, state) : null;
|
1978
|
+
(_b2 = (_a2 = get()).onAction) == null ? void 0 : _b2.call(_a2, action, state, get().state);
|
1979
|
+
return __spreadProps(__spreadValues({}, s), { state, selectedItem });
|
1980
|
+
}),
|
1981
|
+
setZoomConfig: (zoomConfig) => set({ zoomConfig }),
|
1982
|
+
setStatus: (status) => set({ status }),
|
1983
|
+
setComponentState: (componentState) => set({ componentState }),
|
1984
|
+
pendingLoadTimeouts: {},
|
1985
|
+
setComponentLoading: (id, loading = true, defer2 = 0) => {
|
1986
|
+
const { setComponentState, pendingLoadTimeouts } = get();
|
1987
|
+
const loadId = generateId();
|
1988
|
+
const setLoading = () => {
|
1989
|
+
var _a2;
|
1990
|
+
const { componentState } = get();
|
1991
|
+
setComponentState(__spreadProps(__spreadValues({}, componentState), {
|
1992
|
+
[id]: __spreadProps(__spreadValues({}, componentState[id]), {
|
1993
|
+
loadingCount: (((_a2 = componentState[id]) == null ? void 0 : _a2.loadingCount) || 0) + 1
|
1994
|
+
})
|
1995
|
+
}));
|
1996
|
+
};
|
1997
|
+
const unsetLoading = () => {
|
1998
|
+
var _a2;
|
1999
|
+
const { componentState } = get();
|
2000
|
+
clearTimeout(timeout3);
|
2001
|
+
delete pendingLoadTimeouts[loadId];
|
2002
|
+
set({ pendingLoadTimeouts });
|
2003
|
+
setComponentState(__spreadProps(__spreadValues({}, componentState), {
|
2004
|
+
[id]: __spreadProps(__spreadValues({}, componentState[id]), {
|
2005
|
+
loadingCount: Math.max(
|
2006
|
+
(((_a2 = componentState[id]) == null ? void 0 : _a2.loadingCount) || 0) - 1,
|
2007
|
+
0
|
2008
|
+
)
|
2009
|
+
})
|
2010
|
+
}));
|
2011
|
+
};
|
2012
|
+
const timeout3 = setTimeout(() => {
|
2013
|
+
if (loading) {
|
2014
|
+
setLoading();
|
2015
|
+
} else {
|
2016
|
+
unsetLoading();
|
2017
|
+
}
|
2018
|
+
delete pendingLoadTimeouts[loadId];
|
2019
|
+
set({ pendingLoadTimeouts });
|
2020
|
+
}, defer2);
|
2021
|
+
set({
|
2022
|
+
pendingLoadTimeouts: __spreadProps(__spreadValues({}, pendingLoadTimeouts), {
|
2023
|
+
[id]: timeout3
|
2024
|
+
})
|
2025
|
+
});
|
2026
|
+
return unsetLoading;
|
2027
|
+
},
|
2028
|
+
unsetComponentLoading: (id) => {
|
2029
|
+
const { setComponentLoading } = get();
|
2030
|
+
setComponentLoading(id, false);
|
2031
|
+
},
|
2032
|
+
// Helper
|
2033
|
+
setUi: (ui, recordHistory) => set((s) => {
|
2034
|
+
const dispatch = createReducer({
|
2035
|
+
record: () => {
|
2036
|
+
},
|
2037
|
+
appStore: s
|
2038
|
+
});
|
2039
|
+
const state = dispatch(s.state, {
|
2040
|
+
type: "setUi",
|
2041
|
+
ui,
|
2042
|
+
recordHistory
|
2043
|
+
});
|
2044
|
+
const selectedItem = state.ui.itemSelector ? getItem(state.ui.itemSelector, state) : null;
|
2045
|
+
return __spreadProps(__spreadValues({}, s), { state, selectedItem });
|
2046
|
+
}),
|
2047
|
+
resolveComponentData: (componentData, trigger) => __async(void 0, null, function* () {
|
2048
|
+
const { config, metadata, setComponentLoading, permissions } = get();
|
2049
|
+
const timeouts = {};
|
2050
|
+
return yield resolveComponentData(
|
2051
|
+
componentData,
|
2052
|
+
config,
|
2053
|
+
metadata,
|
2054
|
+
(item) => {
|
2055
|
+
const id = "id" in item.props ? item.props.id : "root";
|
2056
|
+
timeouts[id] = setComponentLoading(id, true, 50);
|
2057
|
+
},
|
2058
|
+
(item) => __async(void 0, null, function* () {
|
2059
|
+
const id = "id" in item.props ? item.props.id : "root";
|
2060
|
+
if ("type" in item) {
|
2061
|
+
yield permissions.refreshPermissions({ item });
|
2062
|
+
} else {
|
2063
|
+
yield permissions.refreshPermissions({ root: true });
|
2064
|
+
}
|
2065
|
+
timeouts[id]();
|
2066
|
+
}),
|
2067
|
+
trigger
|
2068
|
+
);
|
2069
|
+
}),
|
2070
|
+
resolveAndCommitData: () => __async(void 0, null, function* () {
|
2071
|
+
const { config, state, dispatch, resolveComponentData: resolveComponentData2 } = get();
|
2072
|
+
walkAppState(
|
2073
|
+
state,
|
2074
|
+
config,
|
2075
|
+
(content) => content,
|
2076
|
+
(childItem) => {
|
2077
|
+
resolveComponentData2(childItem, "load").then((resolved) => {
|
2078
|
+
const { state: state2 } = get();
|
2079
|
+
const node = state2.indexes.nodes[resolved.node.props.id];
|
2080
|
+
if (node && resolved.didChange) {
|
2081
|
+
if (resolved.node.props.id === "root") {
|
2082
|
+
dispatch({
|
2083
|
+
type: "replaceRoot",
|
2084
|
+
root: toRoot(resolved.node)
|
2085
|
+
});
|
2086
|
+
} else {
|
2087
|
+
const zoneCompound = `${node.parentId}:${node.zone}`;
|
2088
|
+
const parentZone = state2.indexes.zones[zoneCompound];
|
2089
|
+
const index = parentZone.contentIds.indexOf(
|
2090
|
+
resolved.node.props.id
|
2091
|
+
);
|
2092
|
+
dispatch({
|
2093
|
+
type: "replace",
|
2094
|
+
data: resolved.node,
|
2095
|
+
destinationIndex: index,
|
2096
|
+
destinationZone: zoneCompound
|
2097
|
+
});
|
2098
|
+
}
|
2099
|
+
}
|
2100
|
+
});
|
2101
|
+
return childItem;
|
2102
|
+
}
|
2103
|
+
);
|
2104
|
+
})
|
2105
|
+
});
|
2106
|
+
})
|
1881
2107
|
);
|
1882
2108
|
var appStoreContext = createContext(createAppStore());
|
1883
2109
|
function useAppStore(selector) {
|
@@ -1950,6 +2176,7 @@ var _PointerSensor = class _PointerSensor extends Sensor {
|
|
1950
2176
|
this.listeners = new Listeners();
|
1951
2177
|
this.cleanup = /* @__PURE__ */ new Set();
|
1952
2178
|
this.source = void 0;
|
2179
|
+
this.started = false;
|
1953
2180
|
__privateAdd(this, _clearTimeout);
|
1954
2181
|
this.handleCancel = this.handleCancel.bind(this);
|
1955
2182
|
this.handlePointerUp = this.handlePointerUp.bind(this);
|
@@ -2107,6 +2334,12 @@ var _PointerSensor = class _PointerSensor extends Sensor {
|
|
2107
2334
|
if (!status.idle) {
|
2108
2335
|
const canceled = !status.initialized;
|
2109
2336
|
this.manager.actions.stop({ canceled });
|
2337
|
+
} else if (this.started) {
|
2338
|
+
setTimeout(() => {
|
2339
|
+
if (!this.manager.dragOperation.status.idle) {
|
2340
|
+
this.manager.actions.stop({ canceled: false });
|
2341
|
+
}
|
2342
|
+
}, 10);
|
2110
2343
|
}
|
2111
2344
|
this.cleanup.forEach((cleanup) => cleanup());
|
2112
2345
|
this.cleanup.clear();
|
@@ -2121,12 +2354,13 @@ var _PointerSensor = class _PointerSensor extends Sensor {
|
|
2121
2354
|
var _a;
|
2122
2355
|
const { manager, initialCoordinates } = this;
|
2123
2356
|
(_a = __privateGet(this, _clearTimeout)) == null ? void 0 : _a.call(this);
|
2124
|
-
if (!initialCoordinates || manager.dragOperation.status.initialized) {
|
2357
|
+
if (!initialCoordinates || manager.dragOperation.status.initialized || this.started) {
|
2125
2358
|
return;
|
2126
2359
|
}
|
2127
2360
|
if (event.defaultPrevented) {
|
2128
2361
|
return;
|
2129
2362
|
}
|
2363
|
+
this.started = true;
|
2130
2364
|
event.preventDefault();
|
2131
2365
|
batch(() => {
|
2132
2366
|
manager.actions.setDragSource(source.id);
|
@@ -2154,6 +2388,9 @@ var _PointerSensor = class _PointerSensor extends Sensor {
|
|
2154
2388
|
]);
|
2155
2389
|
ownerDocument.body.setPointerCapture(event.pointerId);
|
2156
2390
|
this.cleanup.add(unbind);
|
2391
|
+
this.cleanup.add(() => {
|
2392
|
+
this.started = false;
|
2393
|
+
});
|
2157
2394
|
}
|
2158
2395
|
handleDragStart(event) {
|
2159
2396
|
const { target } = event;
|
@@ -2712,7 +2949,7 @@ var ArrayField = ({
|
|
2712
2949
|
openId: ""
|
2713
2950
|
};
|
2714
2951
|
const [localState, setLocalState] = useState3({ arrayState, value });
|
2715
|
-
|
2952
|
+
useEffect5(() => {
|
2716
2953
|
var _a;
|
2717
2954
|
const _arrayState = (_a = appStore.getState().state.ui.arrayState[id]) != null ? _a : arrayState;
|
2718
2955
|
setLocalState({ arrayState: _arrayState, value });
|
@@ -2754,7 +2991,7 @@ var ArrayField = ({
|
|
2754
2991
|
},
|
2755
2992
|
[arrayState]
|
2756
2993
|
);
|
2757
|
-
|
2994
|
+
useEffect5(() => {
|
2758
2995
|
if (arrayState.items.length > 0) {
|
2759
2996
|
setUi(mapArrayStateToUi(arrayState));
|
2760
2997
|
}
|
@@ -2765,6 +3002,7 @@ var ArrayField = ({
|
|
2765
3002
|
(s) => s.permissions.getPermissions({ item: s.selectedItem }).edit
|
2766
3003
|
);
|
2767
3004
|
const forceReadOnly = !canEdit;
|
3005
|
+
const valueRef = useRef(value);
|
2768
3006
|
if (field.type !== "array" || !field.arrayFields) {
|
2769
3007
|
return null;
|
2770
3008
|
}
|
@@ -2782,7 +3020,7 @@ var ArrayField = ({
|
|
2782
3020
|
onDragStart: (id2) => setDraggedItem(id2),
|
2783
3021
|
onDragEnd: () => {
|
2784
3022
|
setDraggedItem("");
|
2785
|
-
onChange(
|
3023
|
+
onChange(valueRef.current);
|
2786
3024
|
},
|
2787
3025
|
onMove: (move) => {
|
2788
3026
|
if (arrayState.items[move.source]._arrayId !== draggedItem) {
|
@@ -2805,6 +3043,7 @@ var ArrayField = ({
|
|
2805
3043
|
value: newValue,
|
2806
3044
|
arrayState: __spreadProps(__spreadValues({}, arrayState), { items: newArrayStateItems })
|
2807
3045
|
});
|
3046
|
+
valueRef.current = newValue;
|
2808
3047
|
},
|
2809
3048
|
children: /* @__PURE__ */ jsxs3(
|
2810
3049
|
"div",
|
@@ -3055,13 +3294,13 @@ var DefaultField = ({
|
|
3055
3294
|
|
3056
3295
|
// components/AutoField/fields/ExternalField/index.tsx
|
3057
3296
|
init_react_import();
|
3058
|
-
import { useEffect as
|
3297
|
+
import { useEffect as useEffect9 } from "react";
|
3059
3298
|
|
3060
3299
|
// components/ExternalInput/index.tsx
|
3061
3300
|
init_react_import();
|
3062
3301
|
import {
|
3063
3302
|
useMemo as useMemo2,
|
3064
|
-
useEffect as
|
3303
|
+
useEffect as useEffect8,
|
3065
3304
|
useState as useState6,
|
3066
3305
|
useCallback as useCallback3,
|
3067
3306
|
isValidElement
|
@@ -3073,7 +3312,7 @@ var styles_module_default6 = { "ExternalInput-actions": "_ExternalInput-actions_
|
|
3073
3312
|
|
3074
3313
|
// components/Modal/index.tsx
|
3075
3314
|
init_react_import();
|
3076
|
-
import { useEffect as
|
3315
|
+
import { useEffect as useEffect6, useState as useState4 } from "react";
|
3077
3316
|
|
3078
3317
|
// css-module:/home/runner/work/puck/puck/packages/core/components/Modal/styles.module.css#css-module
|
3079
3318
|
init_react_import();
|
@@ -3089,7 +3328,7 @@ var Modal = ({
|
|
3089
3328
|
isOpen
|
3090
3329
|
}) => {
|
3091
3330
|
const [rootEl, setRootEl] = useState4(null);
|
3092
|
-
|
3331
|
+
useEffect6(() => {
|
3093
3332
|
setRootEl(document.getElementById("puck-portal-root"));
|
3094
3333
|
}, []);
|
3095
3334
|
if (!rootEl) {
|
@@ -3136,7 +3375,7 @@ init_react_import();
|
|
3136
3375
|
|
3137
3376
|
// components/Button/Button.tsx
|
3138
3377
|
init_react_import();
|
3139
|
-
import { useEffect as
|
3378
|
+
import { useEffect as useEffect7, useState as useState5 } from "react";
|
3140
3379
|
|
3141
3380
|
// css-module:/home/runner/work/puck/puck/packages/core/components/Button/Button.module.css#css-module
|
3142
3381
|
init_react_import();
|
@@ -3187,7 +3426,7 @@ var Button = (_a) => {
|
|
3187
3426
|
"loading"
|
3188
3427
|
]);
|
3189
3428
|
const [loading, setLoading] = useState5(loadingProp);
|
3190
|
-
|
3429
|
+
useEffect7(() => setLoading(loadingProp), [loadingProp]);
|
3191
3430
|
const ElementType = href ? "a" : type ? "button" : "span";
|
3192
3431
|
const dataAttrs = filterDataAttrs(props);
|
3193
3432
|
const el = /* @__PURE__ */ jsxs5(
|
@@ -3284,7 +3523,7 @@ var ExternalInput = ({
|
|
3284
3523
|
] }),
|
3285
3524
|
[field.renderFooter]
|
3286
3525
|
);
|
3287
|
-
|
3526
|
+
useEffect8(() => {
|
3288
3527
|
search(searchQuery, filters);
|
3289
3528
|
}, []);
|
3290
3529
|
return /* @__PURE__ */ jsxs6(
|
@@ -3456,7 +3695,7 @@ var ExternalField = ({
|
|
3456
3695
|
var _a, _b, _c;
|
3457
3696
|
const validField = field;
|
3458
3697
|
const deprecatedField = field;
|
3459
|
-
|
3698
|
+
useEffect9(() => {
|
3460
3699
|
if (deprecatedField.adaptor) {
|
3461
3700
|
console.error(
|
3462
3701
|
"Warning: The `adaptor` API is deprecated. Please use updated APIs on the `external` field instead. This will be a breaking change in a future release."
|
@@ -3875,6 +4114,9 @@ function AutoFieldInternal(props) {
|
|
3875
4114
|
});
|
3876
4115
|
}
|
3877
4116
|
}, []);
|
4117
|
+
if (field.type === "slot") {
|
4118
|
+
return null;
|
4119
|
+
}
|
3878
4120
|
if (field.type === "custom") {
|
3879
4121
|
if (!field.render) {
|
3880
4122
|
return null;
|
@@ -3917,11 +4159,18 @@ function AutoFieldPrivate(props) {
|
|
3917
4159
|
},
|
3918
4160
|
[onChange]
|
3919
4161
|
);
|
3920
|
-
|
4162
|
+
useEffect10(() => {
|
3921
4163
|
if (!isFocused) {
|
3922
4164
|
setLocalValue(value);
|
3923
4165
|
}
|
3924
4166
|
}, [value]);
|
4167
|
+
useEffect10(() => {
|
4168
|
+
if (!isFocused) {
|
4169
|
+
if (value !== localValue) {
|
4170
|
+
setLocalValue(value);
|
4171
|
+
}
|
4172
|
+
}
|
4173
|
+
}, [isFocused, value, localValue]);
|
3925
4174
|
const localProps = {
|
3926
4175
|
value: localValue,
|
3927
4176
|
onChange: onChangeLocal
|
@@ -3938,6 +4187,9 @@ function AutoField(props) {
|
|
3938
4187
|
);
|
3939
4188
|
return DefaultLabel2;
|
3940
4189
|
}, [props.readOnly]);
|
4190
|
+
if (props.field.type === "slot") {
|
4191
|
+
return null;
|
4192
|
+
}
|
3941
4193
|
return /* @__PURE__ */ jsx18(AutoFieldInternal, __spreadProps(__spreadValues({}, props), { Label: DefaultLabel }));
|
3942
4194
|
}
|
3943
4195
|
|
@@ -3946,10 +4198,10 @@ init_react_import();
|
|
3946
4198
|
|
3947
4199
|
// css-module:/home/runner/work/puck/puck/packages/core/components/Drawer/styles.module.css#css-module
|
3948
4200
|
init_react_import();
|
3949
|
-
var styles_module_default10 = { "Drawer": "
|
4201
|
+
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" };
|
3950
4202
|
|
3951
4203
|
// components/Drawer/index.tsx
|
3952
|
-
import { useMemo as
|
4204
|
+
import { useMemo as useMemo11, useState as useState15 } from "react";
|
3953
4205
|
|
3954
4206
|
// components/DragDropContext/index.tsx
|
3955
4207
|
init_react_import();
|
@@ -3958,7 +4210,8 @@ import {
|
|
3958
4210
|
createContext as createContext4,
|
3959
4211
|
useCallback as useCallback10,
|
3960
4212
|
useContext as useContext7,
|
3961
|
-
useEffect as
|
4213
|
+
useEffect as useEffect16,
|
4214
|
+
useMemo as useMemo10,
|
3962
4215
|
useRef as useRef4,
|
3963
4216
|
useState as useState14
|
3964
4217
|
} from "react";
|
@@ -3968,10 +4221,11 @@ import { AutoScroller, defaultPreset } from "@dnd-kit/dom";
|
|
3968
4221
|
init_react_import();
|
3969
4222
|
import {
|
3970
4223
|
forwardRef as forwardRef3,
|
4224
|
+
memo,
|
3971
4225
|
useCallback as useCallback9,
|
3972
4226
|
useContext as useContext6,
|
3973
|
-
useEffect as
|
3974
|
-
useMemo as
|
4227
|
+
useEffect as useEffect15,
|
4228
|
+
useMemo as useMemo9,
|
3975
4229
|
useRef as useRef3
|
3976
4230
|
} from "react";
|
3977
4231
|
|
@@ -3980,7 +4234,7 @@ init_react_import();
|
|
3980
4234
|
import {
|
3981
4235
|
useCallback as useCallback6,
|
3982
4236
|
useContext as useContext5,
|
3983
|
-
useEffect as
|
4237
|
+
useEffect as useEffect11,
|
3984
4238
|
useMemo as useMemo7,
|
3985
4239
|
useRef as useRef2,
|
3986
4240
|
useState as useState10
|
@@ -3988,7 +4242,7 @@ import {
|
|
3988
4242
|
|
3989
4243
|
// css-module:/home/runner/work/puck/puck/packages/core/components/DraggableComponent/styles.module.css#css-module
|
3990
4244
|
init_react_import();
|
3991
|
-
var styles_module_default11 = { "DraggableComponent": "
|
4245
|
+
var styles_module_default11 = { "DraggableComponent": "_DraggableComponent_qzbgx_1", "DraggableComponent-overlay": "_DraggableComponent-overlay_qzbgx_12", "DraggableComponent-loadingOverlay": "_DraggableComponent-loadingOverlay_qzbgx_29", "DraggableComponent--hover": "_DraggableComponent--hover_qzbgx_45", "DraggableComponent--isLocked": "_DraggableComponent--isLocked_qzbgx_45", "DraggableComponent--isSelected": "_DraggableComponent--isSelected_qzbgx_54", "DraggableComponent-actionsOverlay": "_DraggableComponent-actionsOverlay_qzbgx_66", "DraggableComponent-actions": "_DraggableComponent-actions_qzbgx_66" };
|
3992
4246
|
|
3993
4247
|
// components/DraggableComponent/index.tsx
|
3994
4248
|
import { createPortal as createPortal2 } from "react-dom";
|
@@ -4044,45 +4298,33 @@ var DropZoneProvider = ({
|
|
4044
4298
|
value
|
4045
4299
|
}) => {
|
4046
4300
|
const [hoveringComponent, setHoveringComponent] = useState9();
|
4047
|
-
const [activeZones, setActiveZones] = useState9({});
|
4048
4301
|
const dispatch = useAppStore((s) => s.dispatch);
|
4049
4302
|
const registerZone = useCallback5(
|
4050
4303
|
(zoneCompound) => {
|
4051
|
-
if (!dispatch) {
|
4052
|
-
return;
|
4053
|
-
}
|
4054
4304
|
dispatch({
|
4055
4305
|
type: "registerZone",
|
4056
4306
|
zone: zoneCompound
|
4057
4307
|
});
|
4058
|
-
setActiveZones((latest) => __spreadProps(__spreadValues({}, latest), { [zoneCompound]: true }));
|
4059
4308
|
},
|
4060
|
-
[
|
4309
|
+
[dispatch]
|
4061
4310
|
);
|
4062
4311
|
const unregisterZone = useCallback5(
|
4063
4312
|
(zoneCompound) => {
|
4064
|
-
if (!dispatch) {
|
4065
|
-
return;
|
4066
|
-
}
|
4067
4313
|
dispatch({
|
4068
4314
|
type: "unregisterZone",
|
4069
4315
|
zone: zoneCompound
|
4070
4316
|
});
|
4071
|
-
setActiveZones((latest) => __spreadProps(__spreadValues({}, latest), {
|
4072
|
-
[zoneCompound]: false
|
4073
|
-
}));
|
4074
4317
|
},
|
4075
|
-
[
|
4318
|
+
[dispatch]
|
4076
4319
|
);
|
4077
4320
|
const memoValue = useMemo6(
|
4078
4321
|
() => __spreadValues({
|
4079
4322
|
hoveringComponent,
|
4080
4323
|
setHoveringComponent,
|
4081
4324
|
registerZone,
|
4082
|
-
unregisterZone
|
4083
|
-
activeZones
|
4325
|
+
unregisterZone
|
4084
4326
|
}, value),
|
4085
|
-
[value, hoveringComponent
|
4327
|
+
[value, hoveringComponent]
|
4086
4328
|
);
|
4087
4329
|
return /* @__PURE__ */ jsx19(Fragment5, { children: memoValue && /* @__PURE__ */ jsx19(dropZoneContext.Provider, { value: memoValue, children }) });
|
4088
4330
|
};
|
@@ -4143,12 +4385,6 @@ var DraggableComponent = ({
|
|
4143
4385
|
}
|
4144
4386
|
);
|
4145
4387
|
const overrides = useAppStore((s) => s.overrides);
|
4146
|
-
const selectedItem = useAppStore(
|
4147
|
-
(s) => {
|
4148
|
-
var _a;
|
4149
|
-
return ((_a = s.selectedItem) == null ? void 0 : _a.props.id) === id ? s.selectedItem : null;
|
4150
|
-
}
|
4151
|
-
);
|
4152
4388
|
const dispatch = useAppStore((s) => s.dispatch);
|
4153
4389
|
const iframe = useAppStore((s) => s.iframe);
|
4154
4390
|
const ctx = useContext5(dropZoneContext);
|
@@ -4176,16 +4412,15 @@ var DraggableComponent = ({
|
|
4176
4412
|
[setLocalZones]
|
4177
4413
|
);
|
4178
4414
|
const containsActiveZone = Object.values(localZones).filter(Boolean).length > 0;
|
4179
|
-
const path = useAppStore((s) => {
|
4180
|
-
var _a;
|
4181
|
-
return (_a = s.nodes.nodes[id]) == null ? void 0 : _a.path;
|
4182
|
-
});
|
4183
|
-
const item = useAppStore((s) => {
|
4415
|
+
const path = useAppStore(useShallow2((s) => {
|
4184
4416
|
var _a;
|
4185
|
-
return (_a = s.
|
4186
|
-
});
|
4417
|
+
return (_a = s.state.indexes.nodes[id]) == null ? void 0 : _a.path;
|
4418
|
+
}));
|
4187
4419
|
const permissions = useAppStore(
|
4188
|
-
useShallow2((s) =>
|
4420
|
+
useShallow2((s) => {
|
4421
|
+
const item = getItem({ index, zone: zoneCompound }, s.state);
|
4422
|
+
return s.permissions.getPermissions({ item });
|
4423
|
+
})
|
4189
4424
|
);
|
4190
4425
|
const userIsDragging = useContextStore(
|
4191
4426
|
ZoneStoreContext,
|
@@ -4230,7 +4465,7 @@ var DraggableComponent = ({
|
|
4230
4465
|
[sortableRef]
|
4231
4466
|
);
|
4232
4467
|
const [portalEl, setPortalEl] = useState10();
|
4233
|
-
|
4468
|
+
useEffect11(() => {
|
4234
4469
|
var _a, _b, _c;
|
4235
4470
|
setPortalEl(
|
4236
4471
|
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
|
@@ -4260,7 +4495,7 @@ var DraggableComponent = ({
|
|
4260
4495
|
const sync = useCallback6(() => {
|
4261
4496
|
setStyle(getStyle());
|
4262
4497
|
}, [ref.current, iframe]);
|
4263
|
-
|
4498
|
+
useEffect11(() => {
|
4264
4499
|
if (ref.current && !userIsDragging) {
|
4265
4500
|
const observer = new ResizeObserver(sync);
|
4266
4501
|
observer.observe(ref.current);
|
@@ -4270,7 +4505,7 @@ var DraggableComponent = ({
|
|
4270
4505
|
}
|
4271
4506
|
}, [ref.current, userIsDragging]);
|
4272
4507
|
const registerNode = useAppStore((s) => s.nodes.registerNode);
|
4273
|
-
|
4508
|
+
useEffect11(() => {
|
4274
4509
|
var _a;
|
4275
4510
|
registerNode(id, { methods: { sync }, element: (_a = ref.current) != null ? _a : null });
|
4276
4511
|
return () => {
|
@@ -4295,18 +4530,22 @@ var DraggableComponent = ({
|
|
4295
4530
|
);
|
4296
4531
|
const appStore = useAppStoreApi();
|
4297
4532
|
const onSelectParent = useCallback6(() => {
|
4298
|
-
const { nodes } = appStore.getState().
|
4533
|
+
const { nodes, zones } = appStore.getState().state.indexes;
|
4299
4534
|
const node = nodes[id];
|
4300
4535
|
const parentNode = (node == null ? void 0 : node.parentId) ? nodes[node == null ? void 0 : node.parentId] : null;
|
4301
|
-
if (!parentNode) {
|
4536
|
+
if (!parentNode || !node.parentId) {
|
4302
4537
|
return;
|
4303
4538
|
}
|
4539
|
+
const parentZoneCompound = `${parentNode.parentId}:${parentNode.zone}`;
|
4540
|
+
const parentIndex = zones[parentZoneCompound].contentIds.indexOf(
|
4541
|
+
node.parentId
|
4542
|
+
);
|
4304
4543
|
dispatch({
|
4305
4544
|
type: "setUi",
|
4306
4545
|
ui: {
|
4307
4546
|
itemSelector: {
|
4308
|
-
zone:
|
4309
|
-
index:
|
4547
|
+
zone: parentZoneCompound,
|
4548
|
+
index: parentIndex
|
4310
4549
|
}
|
4311
4550
|
}
|
4312
4551
|
});
|
@@ -4327,7 +4566,7 @@ var DraggableComponent = ({
|
|
4327
4566
|
}, [index, zoneCompound]);
|
4328
4567
|
const [hover, setHover] = useState10(false);
|
4329
4568
|
const indicativeHover = (ctx == null ? void 0 : ctx.hoveringComponent) === id;
|
4330
|
-
|
4569
|
+
useEffect11(() => {
|
4331
4570
|
if (!ref.current) {
|
4332
4571
|
return;
|
4333
4572
|
}
|
@@ -4377,7 +4616,7 @@ var DraggableComponent = ({
|
|
4377
4616
|
thisIsDragging,
|
4378
4617
|
inDroppableZone
|
4379
4618
|
]);
|
4380
|
-
|
4619
|
+
useEffect11(() => {
|
4381
4620
|
if (ref.current && disabled) {
|
4382
4621
|
ref.current.setAttribute("data-puck-disabled", "");
|
4383
4622
|
return () => {
|
@@ -4387,7 +4626,7 @@ var DraggableComponent = ({
|
|
4387
4626
|
}
|
4388
4627
|
}, [disabled, ref]);
|
4389
4628
|
const [isVisible, setIsVisible] = useState10(false);
|
4390
|
-
|
4629
|
+
useEffect11(() => {
|
4391
4630
|
sync();
|
4392
4631
|
if ((isSelected || hover || indicativeHover) && !userIsDragging) {
|
4393
4632
|
setIsVisible(true);
|
@@ -4420,7 +4659,7 @@ var DraggableComponent = ({
|
|
4420
4659
|
},
|
4421
4660
|
[zoom]
|
4422
4661
|
);
|
4423
|
-
|
4662
|
+
useEffect11(() => {
|
4424
4663
|
if (userDragAxis) {
|
4425
4664
|
setDragAxis(userDragAxis);
|
4426
4665
|
return;
|
@@ -4435,85 +4674,91 @@ var DraggableComponent = ({
|
|
4435
4674
|
setDragAxis(autoDragAxis);
|
4436
4675
|
}, [ref, userDragAxis, autoDragAxis]);
|
4437
4676
|
const parentAction = (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 }) });
|
4438
|
-
|
4439
|
-
|
4440
|
-
|
4441
|
-
|
4442
|
-
|
4443
|
-
|
4444
|
-
|
4445
|
-
|
4446
|
-
|
4447
|
-
|
4448
|
-
|
4449
|
-
|
4450
|
-
|
4451
|
-
|
4452
|
-
|
4453
|
-
|
4454
|
-
|
4455
|
-
|
4456
|
-
|
4457
|
-
|
4458
|
-
|
4459
|
-
|
4460
|
-
|
4461
|
-
|
4462
|
-
|
4463
|
-
|
4464
|
-
|
4677
|
+
const nextContextValue = useMemo7(
|
4678
|
+
() => __spreadProps(__spreadValues({}, ctx), {
|
4679
|
+
areaId: id,
|
4680
|
+
zoneCompound,
|
4681
|
+
index,
|
4682
|
+
depth: depth + 1,
|
4683
|
+
registerLocalZone,
|
4684
|
+
unregisterLocalZone
|
4685
|
+
}),
|
4686
|
+
[
|
4687
|
+
ctx,
|
4688
|
+
id,
|
4689
|
+
zoneCompound,
|
4690
|
+
index,
|
4691
|
+
depth,
|
4692
|
+
registerLocalZone,
|
4693
|
+
unregisterLocalZone
|
4694
|
+
]
|
4695
|
+
);
|
4696
|
+
return /* @__PURE__ */ jsxs9(DropZoneProvider, { value: nextContextValue, children: [
|
4697
|
+
isVisible && createPortal2(
|
4698
|
+
/* @__PURE__ */ jsxs9(
|
4699
|
+
"div",
|
4700
|
+
{
|
4701
|
+
className: getClassName16({
|
4702
|
+
isSelected,
|
4703
|
+
isDragging: thisIsDragging,
|
4704
|
+
hover: hover || indicativeHover
|
4705
|
+
}),
|
4706
|
+
style: __spreadValues({}, style),
|
4707
|
+
"data-puck-overlay": true,
|
4708
|
+
children: [
|
4709
|
+
debug,
|
4710
|
+
isLoading && /* @__PURE__ */ jsx20("div", { className: getClassName16("loadingOverlay"), children: /* @__PURE__ */ jsx20(Loader, {}) }),
|
4711
|
+
/* @__PURE__ */ jsx20(
|
4712
|
+
"div",
|
4713
|
+
{
|
4714
|
+
className: getClassName16("actionsOverlay"),
|
4715
|
+
style: {
|
4716
|
+
top: actionsOverlayTop / zoom
|
4717
|
+
},
|
4718
|
+
children: /* @__PURE__ */ jsx20(
|
4465
4719
|
"div",
|
4466
4720
|
{
|
4467
|
-
className: getClassName16("
|
4721
|
+
className: getClassName16("actions"),
|
4468
4722
|
style: {
|
4469
|
-
|
4723
|
+
transform: `scale(${1 / zoom}`,
|
4724
|
+
top: actionsTop / zoom,
|
4725
|
+
right: 0,
|
4726
|
+
paddingLeft: actionsSide,
|
4727
|
+
paddingRight: actionsSide
|
4470
4728
|
},
|
4471
|
-
|
4472
|
-
|
4729
|
+
ref: syncActionsPosition,
|
4730
|
+
children: /* @__PURE__ */ jsxs9(
|
4731
|
+
CustomActionBar,
|
4473
4732
|
{
|
4474
|
-
|
4475
|
-
|
4476
|
-
|
4477
|
-
|
4478
|
-
|
4479
|
-
|
4480
|
-
paddingRight: actionsSide
|
4481
|
-
},
|
4482
|
-
ref: syncActionsPosition,
|
4483
|
-
children: /* @__PURE__ */ jsxs9(
|
4484
|
-
CustomActionBar,
|
4485
|
-
{
|
4486
|
-
parentAction,
|
4487
|
-
label: DEBUG2 ? id : label,
|
4488
|
-
children: [
|
4489
|
-
permissions.duplicate && /* @__PURE__ */ jsx20(ActionBar.Action, { onClick: onDuplicate, label: "Duplicate", children: /* @__PURE__ */ jsx20(Copy, { size: 16 }) }),
|
4490
|
-
permissions.delete && /* @__PURE__ */ jsx20(ActionBar.Action, { onClick: onDelete, label: "Delete", children: /* @__PURE__ */ jsx20(Trash, { size: 16 }) })
|
4491
|
-
]
|
4492
|
-
}
|
4493
|
-
)
|
4733
|
+
parentAction,
|
4734
|
+
label: DEBUG2 ? id : label,
|
4735
|
+
children: [
|
4736
|
+
permissions.duplicate && /* @__PURE__ */ jsx20(ActionBar.Action, { onClick: onDuplicate, label: "Duplicate", children: /* @__PURE__ */ jsx20(Copy, { size: 16 }) }),
|
4737
|
+
permissions.delete && /* @__PURE__ */ jsx20(ActionBar.Action, { onClick: onDelete, label: "Delete", children: /* @__PURE__ */ jsx20(Trash, { size: 16 }) })
|
4738
|
+
]
|
4494
4739
|
}
|
4495
4740
|
)
|
4496
4741
|
}
|
4497
|
-
)
|
4498
|
-
|
4499
|
-
|
4500
|
-
}
|
4501
|
-
|
4502
|
-
|
4503
|
-
|
4504
|
-
|
4505
|
-
|
4506
|
-
|
4507
|
-
);
|
4742
|
+
)
|
4743
|
+
}
|
4744
|
+
),
|
4745
|
+
/* @__PURE__ */ jsx20("div", { className: getClassName16("overlay") })
|
4746
|
+
]
|
4747
|
+
}
|
4748
|
+
),
|
4749
|
+
portalEl || document.body
|
4750
|
+
),
|
4751
|
+
children(refSetter)
|
4752
|
+
] });
|
4508
4753
|
};
|
4509
4754
|
|
4510
4755
|
// css-module:/home/runner/work/puck/puck/packages/core/components/DropZone/styles.module.css#css-module
|
4511
4756
|
init_react_import();
|
4512
|
-
var styles_module_default12 = { "DropZone": "
|
4757
|
+
var styles_module_default12 = { "DropZone": "_DropZone_3dmev_1", "DropZone--hasChildren": "_DropZone--hasChildren_3dmev_11", "DropZone--userIsDragging": "_DropZone--userIsDragging_3dmev_19", "DropZone--isAreaSelected": "_DropZone--isAreaSelected_3dmev_23", "DropZone--hoveringOverArea": "_DropZone--hoveringOverArea_3dmev_24", "DropZone--isRootZone": "_DropZone--isRootZone_3dmev_24", "DropZone--isDestination": "_DropZone--isDestination_3dmev_34", "DropZone-item": "_DropZone-item_3dmev_46", "DropZone-hitbox": "_DropZone-hitbox_3dmev_50", "DropZone--isEnabled": "_DropZone--isEnabled_3dmev_58", "DropZone--isAnimating": "_DropZone--isAnimating_3dmev_67" };
|
4513
4758
|
|
4514
4759
|
// components/DropZone/lib/use-min-empty-height.ts
|
4515
4760
|
init_react_import();
|
4516
|
-
import { useEffect as
|
4761
|
+
import { useEffect as useEffect12, useState as useState11 } from "react";
|
4517
4762
|
var useMinEmptyHeight = ({
|
4518
4763
|
zoneCompound,
|
4519
4764
|
userMinEmptyHeight,
|
@@ -4529,7 +4774,7 @@ var useMinEmptyHeight = ({
|
|
4529
4774
|
isZone: ((_b = s.draggedItem) == null ? void 0 : _b.data.zone) === zoneCompound
|
4530
4775
|
};
|
4531
4776
|
});
|
4532
|
-
|
4777
|
+
useEffect12(() => {
|
4533
4778
|
if (draggedItem && ref.current) {
|
4534
4779
|
if (isZone) {
|
4535
4780
|
const rect = ref.current.getBoundingClientRect();
|
@@ -4540,10 +4785,18 @@ var useMinEmptyHeight = ({
|
|
4540
4785
|
}
|
4541
4786
|
setPrevHeight(0);
|
4542
4787
|
setTimeout(() => {
|
4543
|
-
|
4544
|
-
|
4788
|
+
var _a, _b;
|
4789
|
+
const zones = appStore.getState().state.indexes.zones;
|
4790
|
+
const nodes = appStore.getState().nodes;
|
4791
|
+
const selectedItem = appStore.getState().selectedItem;
|
4792
|
+
const contentIds = ((_a = zones[zoneCompound]) == null ? void 0 : _a.contentIds) || [];
|
4793
|
+
contentIds.forEach((contentId) => {
|
4794
|
+
const node = nodes.nodes[contentId];
|
4545
4795
|
node == null ? void 0 : node.methods.sync();
|
4546
4796
|
});
|
4797
|
+
if (selectedItem) {
|
4798
|
+
(_b = nodes.nodes[selectedItem.props.id]) == null ? void 0 : _b.methods.sync();
|
4799
|
+
}
|
4547
4800
|
setIsAnimating(false);
|
4548
4801
|
}, 400);
|
4549
4802
|
}, [ref.current, draggedItem, zoneCompound]);
|
@@ -4567,7 +4820,7 @@ function assignRefs(refs, node) {
|
|
4567
4820
|
|
4568
4821
|
// components/DropZone/lib/use-content-with-preview.ts
|
4569
4822
|
init_react_import();
|
4570
|
-
import { useEffect as
|
4823
|
+
import { useEffect as useEffect13, useState as useState12 } from "react";
|
4571
4824
|
|
4572
4825
|
// lib/dnd/use-rendered-callback.ts
|
4573
4826
|
init_react_import();
|
@@ -4634,7 +4887,7 @@ var useContentIdsWithPreview = (contentIds, zoneCompound) => {
|
|
4634
4887
|
},
|
4635
4888
|
[draggedItemId, previewExists]
|
4636
4889
|
);
|
4637
|
-
|
4890
|
+
useEffect13(() => {
|
4638
4891
|
updateContent(contentIds, preview, isDragging);
|
4639
4892
|
}, [contentIds, preview, isDragging]);
|
4640
4893
|
return [contentIdsWithPreview, localPreview];
|
@@ -4642,7 +4895,7 @@ var useContentIdsWithPreview = (contentIds, zoneCompound) => {
|
|
4642
4895
|
|
4643
4896
|
// components/DropZone/lib/use-drag-axis.ts
|
4644
4897
|
init_react_import();
|
4645
|
-
import { useCallback as useCallback8, useEffect as
|
4898
|
+
import { useCallback as useCallback8, useEffect as useEffect14, useState as useState13 } from "react";
|
4646
4899
|
var GRID_DRAG_AXIS = "dynamic";
|
4647
4900
|
var FLEX_ROW_DRAG_AXIS = "x";
|
4648
4901
|
var DEFAULT_DRAG_AXIS = "y";
|
@@ -4663,7 +4916,7 @@ var useDragAxis = (ref, collisionAxis) => {
|
|
4663
4916
|
}
|
4664
4917
|
}
|
4665
4918
|
}, [ref.current]);
|
4666
|
-
|
4919
|
+
useEffect14(() => {
|
4667
4920
|
const onViewportChange = () => {
|
4668
4921
|
calculateDragAxis();
|
4669
4922
|
};
|
@@ -4672,7 +4925,7 @@ var useDragAxis = (ref, collisionAxis) => {
|
|
4672
4925
|
window.removeEventListener("viewportchange", onViewportChange);
|
4673
4926
|
};
|
4674
4927
|
}, []);
|
4675
|
-
|
4928
|
+
useEffect14(calculateDragAxis, [status, collisionAxis]);
|
4676
4929
|
return [dragAxis, calculateDragAxis];
|
4677
4930
|
};
|
4678
4931
|
|
@@ -4681,8 +4934,36 @@ import { useShallow as useShallow3 } from "zustand/react/shallow";
|
|
4681
4934
|
|
4682
4935
|
// components/Render/index.tsx
|
4683
4936
|
init_react_import();
|
4684
|
-
import React3 from "react";
|
4937
|
+
import React3, { useMemo as useMemo8 } from "react";
|
4938
|
+
|
4939
|
+
// components/SlotRender/index.tsx
|
4940
|
+
init_react_import();
|
4685
4941
|
import { jsx as jsx21 } from "react/jsx-runtime";
|
4942
|
+
var ContextSlotRender = ({
|
4943
|
+
componentId,
|
4944
|
+
zone
|
4945
|
+
}) => {
|
4946
|
+
const config = useAppStore((s) => s.config);
|
4947
|
+
const metadata = useAppStore((s) => s.metadata);
|
4948
|
+
const slotContent = useAppStore(
|
4949
|
+
(s) => {
|
4950
|
+
var _a, _b;
|
4951
|
+
return (_b = (_a = s.state.indexes.nodes[componentId]) == null ? void 0 : _a.data.props[zone]) != null ? _b : null;
|
4952
|
+
}
|
4953
|
+
);
|
4954
|
+
return /* @__PURE__ */ jsx21(
|
4955
|
+
SlotRenderPure,
|
4956
|
+
{
|
4957
|
+
content: slotContent,
|
4958
|
+
zone,
|
4959
|
+
config,
|
4960
|
+
metadata
|
4961
|
+
}
|
4962
|
+
);
|
4963
|
+
};
|
4964
|
+
|
4965
|
+
// components/Render/index.tsx
|
4966
|
+
import { jsx as jsx22 } from "react/jsx-runtime";
|
4686
4967
|
var renderContext = React3.createContext({
|
4687
4968
|
config: { components: {} },
|
4688
4969
|
data: { root: {}, content: [] },
|
@@ -4700,51 +4981,38 @@ function Render({
|
|
4700
4981
|
});
|
4701
4982
|
const rootProps = defaultedData.root.props || defaultedData.root;
|
4702
4983
|
const title = (rootProps == null ? void 0 : rootProps.title) || "";
|
4984
|
+
const pageProps = __spreadProps(__spreadValues({}, rootProps), {
|
4985
|
+
puck: {
|
4986
|
+
renderDropZone: DropZonePure,
|
4987
|
+
isEditing: false,
|
4988
|
+
dragRef: null,
|
4989
|
+
metadata
|
4990
|
+
},
|
4991
|
+
title,
|
4992
|
+
editMode: false,
|
4993
|
+
id: "puck-root"
|
4994
|
+
});
|
4995
|
+
const propsWithSlots = useSlots(config.root, pageProps, (props) => /* @__PURE__ */ jsx22(SlotRender, __spreadProps(__spreadValues({}, props), { config, metadata })));
|
4996
|
+
const nextContextValue = useMemo8(
|
4997
|
+
() => ({
|
4998
|
+
mode: "render",
|
4999
|
+
depth: 0
|
5000
|
+
}),
|
5001
|
+
[]
|
5002
|
+
);
|
4703
5003
|
if ((_a = config.root) == null ? void 0 : _a.render) {
|
4704
|
-
return /* @__PURE__ */
|
4705
|
-
DropZoneProvider,
|
4706
|
-
{
|
4707
|
-
value: {
|
4708
|
-
mode: "render",
|
4709
|
-
depth: 0
|
4710
|
-
},
|
4711
|
-
children: /* @__PURE__ */ jsx21(
|
4712
|
-
config.root.render,
|
4713
|
-
__spreadProps(__spreadValues({}, rootProps), {
|
4714
|
-
puck: {
|
4715
|
-
renderDropZone: DropZonePure,
|
4716
|
-
isEditing: false,
|
4717
|
-
dragRef: null
|
4718
|
-
},
|
4719
|
-
title,
|
4720
|
-
editMode: false,
|
4721
|
-
id: "puck-root",
|
4722
|
-
children: /* @__PURE__ */ jsx21(DropZoneRenderPure, { zone: rootZone })
|
4723
|
-
})
|
4724
|
-
)
|
4725
|
-
}
|
4726
|
-
) });
|
5004
|
+
return /* @__PURE__ */ jsx22(renderContext.Provider, { value: { config, data: defaultedData, metadata }, children: /* @__PURE__ */ jsx22(DropZoneProvider, { value: nextContextValue, children: /* @__PURE__ */ jsx22(config.root.render, __spreadProps(__spreadValues({}, propsWithSlots), { children: /* @__PURE__ */ jsx22(DropZoneRenderPure, { zone: rootZone }) })) }) });
|
4727
5005
|
}
|
4728
|
-
return /* @__PURE__ */
|
4729
|
-
DropZoneProvider,
|
4730
|
-
{
|
4731
|
-
value: {
|
4732
|
-
mode: "render",
|
4733
|
-
depth: 0
|
4734
|
-
},
|
4735
|
-
children: /* @__PURE__ */ jsx21(DropZoneRenderPure, { zone: rootZone })
|
4736
|
-
}
|
4737
|
-
) });
|
5006
|
+
return /* @__PURE__ */ jsx22(renderContext.Provider, { value: { config, data: defaultedData, metadata }, children: /* @__PURE__ */ jsx22(DropZoneProvider, { value: nextContextValue, children: /* @__PURE__ */ jsx22(DropZoneRenderPure, { zone: rootZone }) }) });
|
4738
5007
|
}
|
4739
5008
|
|
4740
5009
|
// components/DropZone/index.tsx
|
4741
|
-
import { Fragment as Fragment6, jsx as
|
5010
|
+
import { Fragment as Fragment6, jsx as jsx23, jsxs as jsxs10 } from "react/jsx-runtime";
|
4742
5011
|
var getClassName17 = get_class_name_factory_default("DropZone", styles_module_default12);
|
4743
5012
|
var getRandomColor = () => `#${Math.floor(Math.random() * 16777215).toString(16)}`;
|
4744
5013
|
var RENDER_DEBUG = false;
|
4745
|
-
var DropZoneEditPure = (props) => /* @__PURE__ */
|
5014
|
+
var DropZoneEditPure = (props) => /* @__PURE__ */ jsx23(DropZoneEdit, __spreadValues({}, props));
|
4746
5015
|
var DropZoneChild = ({
|
4747
|
-
zone,
|
4748
5016
|
zoneCompound,
|
4749
5017
|
componentId,
|
4750
5018
|
preview,
|
@@ -4756,27 +5024,37 @@ var DropZoneChild = ({
|
|
4756
5024
|
}) => {
|
4757
5025
|
var _a, _b;
|
4758
5026
|
const metadata = useAppStore((s) => s.metadata);
|
4759
|
-
const puckProps = {
|
4760
|
-
renderDropZone: DropZoneEditPure,
|
4761
|
-
isEditing: true,
|
4762
|
-
dragRef: null,
|
4763
|
-
metadata
|
4764
|
-
};
|
4765
5027
|
const ctx = useContext6(dropZoneContext);
|
4766
|
-
const { depth } = ctx;
|
4767
|
-
const
|
5028
|
+
const { depth = 1 } = ctx != null ? ctx : {};
|
5029
|
+
const nodeProps = useAppStore(
|
4768
5030
|
useShallow3((s) => {
|
4769
|
-
|
4770
|
-
|
4771
|
-
|
4772
|
-
|
4773
|
-
|
5031
|
+
var _a2;
|
5032
|
+
return (_a2 = s.state.indexes.nodes[componentId]) == null ? void 0 : _a2.flatData.props;
|
5033
|
+
})
|
5034
|
+
);
|
5035
|
+
const nodeType = useAppStore(
|
5036
|
+
(s) => {
|
5037
|
+
var _a2;
|
5038
|
+
return (_a2 = s.state.indexes.nodes[componentId]) == null ? void 0 : _a2.data.type;
|
5039
|
+
}
|
5040
|
+
);
|
5041
|
+
const nodeReadOnly = useAppStore(
|
5042
|
+
useShallow3((s) => {
|
5043
|
+
var _a2;
|
5044
|
+
return (_a2 = s.state.indexes.nodes[componentId]) == null ? void 0 : _a2.data.readOnly;
|
4774
5045
|
})
|
4775
5046
|
);
|
4776
|
-
const
|
5047
|
+
const node = { type: nodeType, props: nodeProps };
|
5048
|
+
const item = nodeProps ? node : (preview == null ? void 0 : preview.componentType) ? { type: preview.componentType, props: preview.props } : null;
|
4777
5049
|
const componentConfig = useAppStore(
|
4778
5050
|
(s) => (item == null ? void 0 : item.type) ? s.config.components[item.type] : null
|
4779
5051
|
);
|
5052
|
+
const puckProps = {
|
5053
|
+
renderDropZone: DropZoneEditPure,
|
5054
|
+
isEditing: true,
|
5055
|
+
dragRef: null,
|
5056
|
+
metadata: __spreadValues(__spreadValues({}, metadata), componentConfig == null ? void 0 : componentConfig.metadata)
|
5057
|
+
};
|
4780
5058
|
const overrides = useAppStore((s) => s.overrides);
|
4781
5059
|
const isLoading = useAppStore(
|
4782
5060
|
(s) => {
|
@@ -4791,18 +5069,29 @@ var DropZoneChild = ({
|
|
4791
5069
|
}
|
4792
5070
|
);
|
4793
5071
|
let label = (_b = (_a = componentConfig == null ? void 0 : componentConfig.label) != null ? _a : item == null ? void 0 : item.type.toString()) != null ? _b : "Component";
|
4794
|
-
const renderPreview =
|
5072
|
+
const renderPreview = useMemo9(
|
4795
5073
|
() => function Preview4() {
|
4796
|
-
return /* @__PURE__ */
|
5074
|
+
return /* @__PURE__ */ jsx23(DrawerItemInner, { name: label, children: overrides.componentItem });
|
4797
5075
|
},
|
4798
5076
|
[componentId, label, overrides]
|
4799
5077
|
);
|
5078
|
+
const defaultsProps = useMemo9(
|
5079
|
+
() => __spreadProps(__spreadValues(__spreadValues({}, componentConfig == null ? void 0 : componentConfig.defaultProps), item == null ? void 0 : item.props), {
|
5080
|
+
puck: puckProps,
|
5081
|
+
editMode: true
|
5082
|
+
// DEPRECATED
|
5083
|
+
}),
|
5084
|
+
[componentConfig == null ? void 0 : componentConfig.defaultProps, item == null ? void 0 : item.props, puckProps]
|
5085
|
+
);
|
5086
|
+
const defaultedPropsWithSlots = useSlots(
|
5087
|
+
componentConfig,
|
5088
|
+
defaultsProps,
|
5089
|
+
DropZoneEditPure,
|
5090
|
+
(slotProps) => /* @__PURE__ */ jsx23(ContextSlotRender, { componentId, zone: slotProps.zone }),
|
5091
|
+
nodeReadOnly,
|
5092
|
+
isLoading
|
5093
|
+
);
|
4800
5094
|
if (!item) return;
|
4801
|
-
const defaultedProps = __spreadProps(__spreadValues(__spreadValues({}, componentConfig == null ? void 0 : componentConfig.defaultProps), item.props), {
|
4802
|
-
puck: puckProps,
|
4803
|
-
editMode: true
|
4804
|
-
// DEPRECATED
|
4805
|
-
});
|
4806
5095
|
let Render2 = componentConfig ? componentConfig.render : () => /* @__PURE__ */ jsxs10("div", { style: { padding: 48, textAlign: "center" }, children: [
|
4807
5096
|
"No configuration for ",
|
4808
5097
|
item.type
|
@@ -4812,7 +5101,7 @@ var DropZoneChild = ({
|
|
4812
5101
|
if (isPreview) {
|
4813
5102
|
Render2 = renderPreview;
|
4814
5103
|
}
|
4815
|
-
return /* @__PURE__ */
|
5104
|
+
return /* @__PURE__ */ jsx23(
|
4816
5105
|
DraggableComponent,
|
4817
5106
|
{
|
4818
5107
|
id: componentId,
|
@@ -4827,17 +5116,18 @@ var DropZoneChild = ({
|
|
4827
5116
|
autoDragAxis: dragAxis,
|
4828
5117
|
userDragAxis: collisionAxis,
|
4829
5118
|
inDroppableZone,
|
4830
|
-
children: (dragRef) => (componentConfig == null ? void 0 : componentConfig.inline) && !isPreview ? /* @__PURE__ */
|
5119
|
+
children: (dragRef) => (componentConfig == null ? void 0 : componentConfig.inline) && !isPreview ? /* @__PURE__ */ jsx23(Fragment6, { children: /* @__PURE__ */ jsx23(
|
4831
5120
|
Render2,
|
4832
|
-
__spreadProps(__spreadValues({},
|
4833
|
-
puck: __spreadProps(__spreadValues({},
|
5121
|
+
__spreadProps(__spreadValues({}, defaultedPropsWithSlots), {
|
5122
|
+
puck: __spreadProps(__spreadValues({}, defaultedPropsWithSlots.puck), {
|
4834
5123
|
dragRef
|
4835
5124
|
})
|
4836
5125
|
})
|
4837
|
-
) }) : /* @__PURE__ */
|
5126
|
+
) }) : /* @__PURE__ */ jsx23("div", { ref: dragRef, children: /* @__PURE__ */ jsx23(Render2, __spreadValues({}, defaultedPropsWithSlots)) })
|
4838
5127
|
}
|
4839
5128
|
);
|
4840
5129
|
};
|
5130
|
+
var DropZoneChildMemo = memo(DropZoneChild);
|
4841
5131
|
var DropZoneEdit = forwardRef3(
|
4842
5132
|
function DropZoneEditInternal({
|
4843
5133
|
zone,
|
@@ -4852,16 +5142,15 @@ var DropZoneEdit = forwardRef3(
|
|
4852
5142
|
const {
|
4853
5143
|
// These all need setting via context
|
4854
5144
|
areaId,
|
4855
|
-
depth,
|
5145
|
+
depth = 0,
|
4856
5146
|
registerLocalZone,
|
4857
|
-
unregisterLocalZone
|
4858
|
-
|
4859
|
-
} = ctx;
|
5147
|
+
unregisterLocalZone
|
5148
|
+
} = ctx != null ? ctx : {};
|
4860
5149
|
const path = useAppStore(
|
4861
|
-
(s) => {
|
5150
|
+
useShallow3((s) => {
|
4862
5151
|
var _a;
|
4863
|
-
return areaId ? (_a = s.
|
4864
|
-
}
|
5152
|
+
return areaId ? (_a = s.state.indexes.nodes[areaId]) == null ? void 0 : _a.path : null;
|
5153
|
+
})
|
4865
5154
|
);
|
4866
5155
|
let zoneCompound = rootDroppableId;
|
4867
5156
|
if (areaId) {
|
@@ -4876,34 +5165,50 @@ var DropZoneEdit = forwardRef3(
|
|
4876
5165
|
draggedComponentType,
|
4877
5166
|
userIsDragging
|
4878
5167
|
} = useContextStore(ZoneStoreContext, (s) => {
|
4879
|
-
var _a, _b
|
5168
|
+
var _a, _b;
|
4880
5169
|
return {
|
4881
5170
|
isDeepestZone: (_a = s.zoneDepthIndex[zoneCompound]) != null ? _a : false,
|
4882
5171
|
inNextDeepestArea: s.nextAreaDepthIndex[areaId || ""],
|
4883
|
-
|
4884
|
-
draggedComponentType: (_c = s.draggedItem) == null ? void 0 : _c.data.componentType,
|
5172
|
+
draggedComponentType: (_b = s.draggedItem) == null ? void 0 : _b.data.componentType,
|
4885
5173
|
userIsDragging: !!s.draggedItem
|
4886
5174
|
};
|
4887
5175
|
});
|
4888
|
-
|
4889
|
-
if (ctx == null ? void 0 : ctx.registerZone) {
|
4890
|
-
ctx == null ? void 0 : ctx.registerZone(zoneCompound);
|
4891
|
-
}
|
4892
|
-
return () => {
|
4893
|
-
if (ctx == null ? void 0 : ctx.unregisterZone) {
|
4894
|
-
ctx == null ? void 0 : ctx.unregisterZone(zoneCompound);
|
4895
|
-
}
|
4896
|
-
};
|
4897
|
-
}, []);
|
4898
|
-
const contentIds = useAppStore(
|
5176
|
+
const zoneContentIds = useAppStore(
|
4899
5177
|
useShallow3((s) => {
|
4900
|
-
|
4901
|
-
|
4902
|
-
|
4903
|
-
|
4904
|
-
|
5178
|
+
var _a;
|
5179
|
+
return (_a = s.state.indexes.zones[zoneCompound]) == null ? void 0 : _a.contentIds;
|
5180
|
+
})
|
5181
|
+
);
|
5182
|
+
const zoneType = useAppStore(
|
5183
|
+
useShallow3((s) => {
|
5184
|
+
var _a;
|
5185
|
+
return (_a = s.state.indexes.zones[zoneCompound]) == null ? void 0 : _a.type;
|
4905
5186
|
})
|
4906
5187
|
);
|
5188
|
+
useEffect15(() => {
|
5189
|
+
if (!zoneType || zoneType === "dropzone") {
|
5190
|
+
if (ctx == null ? void 0 : ctx.registerZone) {
|
5191
|
+
ctx == null ? void 0 : ctx.registerZone(zoneCompound);
|
5192
|
+
}
|
5193
|
+
return () => {
|
5194
|
+
if (ctx == null ? void 0 : ctx.unregisterZone) {
|
5195
|
+
ctx == null ? void 0 : ctx.unregisterZone(zoneCompound);
|
5196
|
+
}
|
5197
|
+
};
|
5198
|
+
}
|
5199
|
+
}, [zoneType]);
|
5200
|
+
useEffect15(() => {
|
5201
|
+
if (zoneType === "dropzone") {
|
5202
|
+
if (zoneCompound !== rootDroppableId) {
|
5203
|
+
console.warn(
|
5204
|
+
"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"
|
5205
|
+
);
|
5206
|
+
}
|
5207
|
+
}
|
5208
|
+
}, [zoneType]);
|
5209
|
+
const contentIds = useMemo9(() => {
|
5210
|
+
return zoneContentIds || [];
|
5211
|
+
}, [zoneContentIds]);
|
4907
5212
|
const ref = useRef3(null);
|
4908
5213
|
const acceptsTarget = useCallback9(
|
4909
5214
|
(componentType) => {
|
@@ -4927,7 +5232,7 @@ var DropZoneEdit = forwardRef3(
|
|
4927
5232
|
},
|
4928
5233
|
[allow, disallow]
|
4929
5234
|
);
|
4930
|
-
|
5235
|
+
useEffect15(() => {
|
4931
5236
|
if (registerLocalZone) {
|
4932
5237
|
registerLocalZone(zoneCompound, acceptsTarget(draggedComponentType));
|
4933
5238
|
}
|
@@ -4973,7 +5278,7 @@ var DropZoneEdit = forwardRef3(
|
|
4973
5278
|
userMinEmptyHeight,
|
4974
5279
|
ref
|
4975
5280
|
});
|
4976
|
-
return /* @__PURE__ */
|
5281
|
+
return /* @__PURE__ */ jsx23(
|
4977
5282
|
"div",
|
4978
5283
|
{
|
4979
5284
|
className: `${getClassName17({
|
@@ -4983,7 +5288,6 @@ var DropZoneEdit = forwardRef3(
|
|
4983
5288
|
isEnabled,
|
4984
5289
|
isAreaSelected,
|
4985
5290
|
hasChildren: contentIds.length > 0,
|
4986
|
-
isActive: activeZones == null ? void 0 : activeZones[zoneCompound],
|
4987
5291
|
isAnimating
|
4988
5292
|
})}${className ? ` ${className}` : ""}`,
|
4989
5293
|
ref: (node) => {
|
@@ -4996,10 +5300,9 @@ var DropZoneEdit = forwardRef3(
|
|
4996
5300
|
backgroundColor: RENDER_DEBUG ? getRandomColor() : style == null ? void 0 : style.backgroundColor
|
4997
5301
|
}),
|
4998
5302
|
children: contentIdsWithPreview.map((componentId, i) => {
|
4999
|
-
return /* @__PURE__ */
|
5000
|
-
|
5303
|
+
return /* @__PURE__ */ jsx23(
|
5304
|
+
DropZoneChildMemo,
|
5001
5305
|
{
|
5002
|
-
zone,
|
5003
5306
|
zoneCompound,
|
5004
5307
|
componentId,
|
5005
5308
|
preview,
|
@@ -5016,7 +5319,31 @@ var DropZoneEdit = forwardRef3(
|
|
5016
5319
|
);
|
5017
5320
|
}
|
5018
5321
|
);
|
5019
|
-
var
|
5322
|
+
var DropZoneRenderItem = ({
|
5323
|
+
config,
|
5324
|
+
item,
|
5325
|
+
metadata
|
5326
|
+
}) => {
|
5327
|
+
const Component = config.components[item.type];
|
5328
|
+
const props = useSlots(Component, item.props, (slotProps) => /* @__PURE__ */ jsx23(SlotRenderPure, __spreadProps(__spreadValues({}, slotProps), { config, metadata })));
|
5329
|
+
const nextContextValue = useMemo9(
|
5330
|
+
() => ({
|
5331
|
+
areaId: props.id,
|
5332
|
+
depth: 1
|
5333
|
+
}),
|
5334
|
+
[props]
|
5335
|
+
);
|
5336
|
+
return /* @__PURE__ */ jsx23(DropZoneProvider, { value: nextContextValue, children: /* @__PURE__ */ jsx23(
|
5337
|
+
Component.render,
|
5338
|
+
__spreadProps(__spreadValues({}, props), {
|
5339
|
+
puck: __spreadProps(__spreadValues({}, props.puck), {
|
5340
|
+
renderDropZone: DropZoneRenderPure,
|
5341
|
+
metadata: __spreadValues(__spreadValues({}, metadata), Component.metadata)
|
5342
|
+
})
|
5343
|
+
})
|
5344
|
+
) }, props.id);
|
5345
|
+
};
|
5346
|
+
var DropZoneRenderPure = (props) => /* @__PURE__ */ jsx23(DropZoneRender, __spreadValues({}, props));
|
5020
5347
|
var DropZoneRender = forwardRef3(
|
5021
5348
|
function DropZoneRenderInternal({ className, style, zone }, ref) {
|
5022
5349
|
const ctx = useContext6(dropZoneContext);
|
@@ -5024,16 +5351,18 @@ var DropZoneRender = forwardRef3(
|
|
5024
5351
|
const { config, data, metadata } = useContext6(renderContext);
|
5025
5352
|
let zoneCompound = rootDroppableId;
|
5026
5353
|
let content = (data == null ? void 0 : data.content) || [];
|
5027
|
-
|
5028
|
-
if (
|
5029
|
-
ctx == null ? void 0 : ctx.registerZone
|
5030
|
-
|
5031
|
-
return () => {
|
5032
|
-
if (ctx == null ? void 0 : ctx.unregisterZone) {
|
5033
|
-
ctx == null ? void 0 : ctx.unregisterZone(zoneCompound);
|
5354
|
+
useEffect15(() => {
|
5355
|
+
if (!content) {
|
5356
|
+
if (ctx == null ? void 0 : ctx.registerZone) {
|
5357
|
+
ctx == null ? void 0 : ctx.registerZone(zoneCompound);
|
5034
5358
|
}
|
5035
|
-
|
5036
|
-
|
5359
|
+
return () => {
|
5360
|
+
if (ctx == null ? void 0 : ctx.unregisterZone) {
|
5361
|
+
ctx == null ? void 0 : ctx.unregisterZone(zoneCompound);
|
5362
|
+
}
|
5363
|
+
};
|
5364
|
+
}
|
5365
|
+
}, [content]);
|
5037
5366
|
if (!data || !config) {
|
5038
5367
|
return null;
|
5039
5368
|
}
|
@@ -5041,25 +5370,15 @@ var DropZoneRender = forwardRef3(
|
|
5041
5370
|
zoneCompound = `${areaId}:${zone}`;
|
5042
5371
|
content = setupZone(data, zoneCompound).zones[zoneCompound];
|
5043
5372
|
}
|
5044
|
-
return /* @__PURE__ */
|
5373
|
+
return /* @__PURE__ */ jsx23("div", { className, style, ref, children: content.map((item) => {
|
5045
5374
|
const Component = config.components[item.type];
|
5046
5375
|
if (Component) {
|
5047
|
-
return /* @__PURE__ */
|
5048
|
-
|
5376
|
+
return /* @__PURE__ */ jsx23(
|
5377
|
+
DropZoneRenderItem,
|
5049
5378
|
{
|
5050
|
-
|
5051
|
-
|
5052
|
-
|
5053
|
-
},
|
5054
|
-
children: /* @__PURE__ */ jsx22(
|
5055
|
-
Component.render,
|
5056
|
-
__spreadProps(__spreadValues({}, item.props), {
|
5057
|
-
puck: {
|
5058
|
-
renderDropZone: DropZoneRenderPure,
|
5059
|
-
metadata: metadata || {}
|
5060
|
-
}
|
5061
|
-
})
|
5062
|
-
)
|
5379
|
+
config,
|
5380
|
+
item,
|
5381
|
+
metadata
|
5063
5382
|
},
|
5064
5383
|
item.props.id
|
5065
5384
|
);
|
@@ -5068,14 +5387,14 @@ var DropZoneRender = forwardRef3(
|
|
5068
5387
|
}) });
|
5069
5388
|
}
|
5070
5389
|
);
|
5071
|
-
var DropZonePure = (props) => /* @__PURE__ */
|
5390
|
+
var DropZonePure = (props) => /* @__PURE__ */ jsx23(DropZone, __spreadValues({}, props));
|
5072
5391
|
var DropZone = forwardRef3(
|
5073
5392
|
function DropZone2(props, ref) {
|
5074
5393
|
const ctx = useContext6(dropZoneContext);
|
5075
5394
|
if ((ctx == null ? void 0 : ctx.mode) === "edit") {
|
5076
|
-
return /* @__PURE__ */
|
5395
|
+
return /* @__PURE__ */ jsx23(Fragment6, { children: /* @__PURE__ */ jsx23(DropZoneEdit, __spreadProps(__spreadValues({}, props), { ref })) });
|
5077
5396
|
}
|
5078
|
-
return /* @__PURE__ */
|
5397
|
+
return /* @__PURE__ */ jsx23(Fragment6, { children: /* @__PURE__ */ jsx23(DropZoneRender, __spreadProps(__spreadValues({}, props), { ref })) });
|
5079
5398
|
}
|
5080
5399
|
);
|
5081
5400
|
|
@@ -5131,7 +5450,7 @@ var GlobalPosition = class {
|
|
5131
5450
|
var _a;
|
5132
5451
|
this.target = target;
|
5133
5452
|
this.original = original;
|
5134
|
-
this.frameEl = document.querySelector("iframe");
|
5453
|
+
this.frameEl = document.querySelector("iframe#preview-frame");
|
5135
5454
|
if (this.frameEl) {
|
5136
5455
|
this.frameRect = this.frameEl.getBoundingClientRect();
|
5137
5456
|
this.scaleFactor = this.frameRect.width / (((_a = this.frameEl.contentWindow) == null ? void 0 : _a.innerWidth) || 1);
|
@@ -5211,6 +5530,7 @@ var getZoneId2 = (candidate) => {
|
|
5211
5530
|
}
|
5212
5531
|
return id;
|
5213
5532
|
};
|
5533
|
+
var BUFFER = 6;
|
5214
5534
|
var getPointerCollisions = (position, manager) => {
|
5215
5535
|
const candidates = [];
|
5216
5536
|
let elements = position.target.ownerDocument.elementsFromPoint(
|
@@ -5234,13 +5554,25 @@ var getPointerCollisions = (position, manager) => {
|
|
5234
5554
|
for (let i = 0; i < elements.length; i++) {
|
5235
5555
|
const element = elements[i];
|
5236
5556
|
const dropzoneId = element.getAttribute("data-puck-dropzone");
|
5557
|
+
const id = element.getAttribute("data-puck-dnd");
|
5558
|
+
if (BUFFER && (dropzoneId || id)) {
|
5559
|
+
const box = element.getBoundingClientRect();
|
5560
|
+
const contractedBox = {
|
5561
|
+
left: box.left + BUFFER,
|
5562
|
+
right: box.right - BUFFER,
|
5563
|
+
top: box.top + BUFFER,
|
5564
|
+
bottom: box.bottom - BUFFER
|
5565
|
+
};
|
5566
|
+
if (position.frame.x < contractedBox.left || position.frame.x > contractedBox.right || position.frame.y > contractedBox.bottom || position.frame.y < contractedBox.top) {
|
5567
|
+
continue;
|
5568
|
+
}
|
5569
|
+
}
|
5237
5570
|
if (dropzoneId) {
|
5238
5571
|
const droppable = manager.registry.droppables.get(dropzoneId);
|
5239
5572
|
if (droppable) {
|
5240
5573
|
candidates.push(droppable);
|
5241
5574
|
}
|
5242
5575
|
}
|
5243
|
-
const id = element.getAttribute("data-puck-dnd");
|
5244
5576
|
if (id) {
|
5245
5577
|
const droppable = manager.registry.droppables.get(id);
|
5246
5578
|
if (droppable) {
|
@@ -5294,8 +5626,8 @@ var findDeepestCandidate = (position, manager) => {
|
|
5294
5626
|
return { zone, area };
|
5295
5627
|
}
|
5296
5628
|
return {
|
5297
|
-
zone:
|
5298
|
-
area:
|
5629
|
+
zone: rootDroppableId,
|
5630
|
+
area: rootAreaId
|
5299
5631
|
};
|
5300
5632
|
};
|
5301
5633
|
var createNestedDroppablePlugin = ({ onChange }, id) => class NestedDroppablePlugin extends Plugin {
|
@@ -5340,12 +5672,7 @@ var createNestedDroppablePlugin = ({ onChange }, id) => class NestedDroppablePlu
|
|
5340
5672
|
|
5341
5673
|
// lib/insert-component.ts
|
5342
5674
|
init_react_import();
|
5343
|
-
var insertComponent = (componentType, zone, index, {
|
5344
|
-
config,
|
5345
|
-
dispatch,
|
5346
|
-
resolveData: resolveData2,
|
5347
|
-
state
|
5348
|
-
}) => {
|
5675
|
+
var insertComponent = (componentType, zone, index, appStore) => __async(void 0, null, function* () {
|
5349
5676
|
const id = generateId(componentType);
|
5350
5677
|
const insertActionData = {
|
5351
5678
|
type: "insert",
|
@@ -5354,7 +5681,8 @@ var insertComponent = (componentType, zone, index, {
|
|
5354
5681
|
destinationZone: zone,
|
5355
5682
|
id
|
5356
5683
|
};
|
5357
|
-
const
|
5684
|
+
const { state, dispatch, resolveComponentData: resolveComponentData2 } = appStore;
|
5685
|
+
const insertedState = insertAction(state, insertActionData, appStore);
|
5358
5686
|
dispatch(__spreadProps(__spreadValues({}, insertActionData), {
|
5359
5687
|
// Dispatch insert rather set, as user's may rely on this via onAction
|
5360
5688
|
// We must always record history here so the insert is added to user history
|
@@ -5367,11 +5695,19 @@ var insertComponent = (componentType, zone, index, {
|
|
5367
5695
|
zone
|
5368
5696
|
};
|
5369
5697
|
dispatch({ type: "setUi", ui: { itemSelector } });
|
5370
|
-
|
5371
|
-
|
5372
|
-
|
5373
|
-
|
5374
|
-
|
5698
|
+
const itemData = getItem(itemSelector, insertedState);
|
5699
|
+
if (itemData) {
|
5700
|
+
const resolved = yield resolveComponentData2(itemData, "insert");
|
5701
|
+
if (resolved.didChange) {
|
5702
|
+
dispatch({
|
5703
|
+
type: "replace",
|
5704
|
+
destinationZone: itemSelector.zone,
|
5705
|
+
destinationIndex: itemSelector.index,
|
5706
|
+
data: resolved.node
|
5707
|
+
});
|
5708
|
+
}
|
5709
|
+
}
|
5710
|
+
});
|
5375
5711
|
|
5376
5712
|
// components/DragDropContext/index.tsx
|
5377
5713
|
import { useDebouncedCallback } from "use-debounce";
|
@@ -5389,14 +5725,14 @@ function getDeepDir(el) {
|
|
5389
5725
|
}
|
5390
5726
|
|
5391
5727
|
// components/DragDropContext/index.tsx
|
5392
|
-
import { jsx as
|
5728
|
+
import { jsx as jsx24 } from "react/jsx-runtime";
|
5393
5729
|
var DEBUG3 = false;
|
5394
5730
|
var dragListenerContext = createContext4({
|
5395
5731
|
dragListeners: {}
|
5396
5732
|
});
|
5397
5733
|
function useDragListener(type, fn, deps = []) {
|
5398
5734
|
const { setDragListeners } = useContext7(dragListenerContext);
|
5399
|
-
|
5735
|
+
useEffect16(() => {
|
5400
5736
|
if (setDragListeners) {
|
5401
5737
|
setDragListeners((old) => __spreadProps(__spreadValues({}, old), {
|
5402
5738
|
[type]: [...old[type] || [], fn]
|
@@ -5423,10 +5759,7 @@ var DragDropContextClient = ({
|
|
5423
5759
|
children,
|
5424
5760
|
disableAutoScroll
|
5425
5761
|
}) => {
|
5426
|
-
const config = useAppStore((s) => s.config);
|
5427
5762
|
const dispatch = useAppStore((s) => s.dispatch);
|
5428
|
-
const resolveData2 = useAppStore((s) => s.resolveData);
|
5429
|
-
const metadata = useAppStore((s) => s.metadata);
|
5430
5763
|
const appStore = useAppStoreApi();
|
5431
5764
|
const id = useSafeId();
|
5432
5765
|
const debouncedParamsRef = useRef4(null);
|
@@ -5486,7 +5819,7 @@ var DragDropContextClient = ({
|
|
5486
5819
|
setDeepestDb.cancel();
|
5487
5820
|
debouncedParamsRef.current = null;
|
5488
5821
|
};
|
5489
|
-
|
5822
|
+
useEffect16(() => {
|
5490
5823
|
if (DEBUG3) {
|
5491
5824
|
zoneStore.subscribe(
|
5492
5825
|
(s) => {
|
@@ -5551,14 +5884,22 @@ var DragDropContextClient = ({
|
|
5551
5884
|
const [dragListeners, setDragListeners] = useState14({});
|
5552
5885
|
const dragMode = useRef4(null);
|
5553
5886
|
const initialSelector = useRef4(void 0);
|
5554
|
-
|
5887
|
+
const nextContextValue = useMemo10(
|
5888
|
+
() => ({
|
5889
|
+
mode: "edit",
|
5890
|
+
areaId: "root",
|
5891
|
+
depth: 0
|
5892
|
+
}),
|
5893
|
+
[]
|
5894
|
+
);
|
5895
|
+
return /* @__PURE__ */ jsx24("div", { id, children: /* @__PURE__ */ jsx24(
|
5555
5896
|
dragListenerContext.Provider,
|
5556
5897
|
{
|
5557
5898
|
value: {
|
5558
5899
|
dragListeners,
|
5559
5900
|
setDragListeners
|
5560
5901
|
},
|
5561
|
-
children: /* @__PURE__ */
|
5902
|
+
children: /* @__PURE__ */ jsx24(
|
5562
5903
|
DragDropProvider2,
|
5563
5904
|
{
|
5564
5905
|
plugins,
|
@@ -5592,13 +5933,12 @@ var DragDropContextClient = ({
|
|
5592
5933
|
}
|
5593
5934
|
if (thisPreview) {
|
5594
5935
|
zoneStore.setState({ previewIndex: {} });
|
5595
|
-
const state = appStore.getState().state;
|
5596
5936
|
if (thisPreview.type === "insert") {
|
5597
5937
|
insertComponent(
|
5598
5938
|
thisPreview.componentType,
|
5599
5939
|
thisPreview.zone,
|
5600
5940
|
thisPreview.index,
|
5601
|
-
|
5941
|
+
appStore.getState()
|
5602
5942
|
);
|
5603
5943
|
} else if (initialSelector.current) {
|
5604
5944
|
dispatch({
|
@@ -5658,7 +5998,7 @@ var DragDropContextClient = ({
|
|
5658
5998
|
targetZone = target.id.toString();
|
5659
5999
|
targetIndex = 0;
|
5660
6000
|
}
|
5661
|
-
const path = ((_d = appStore.getState().
|
6001
|
+
const path = ((_d = appStore.getState().state.indexes.nodes[target.id]) == null ? void 0 : _d.path) || [];
|
5662
6002
|
if (targetId === sourceId || path.find((path2) => {
|
5663
6003
|
const [pathId] = path2.split(":");
|
5664
6004
|
return pathId === sourceId;
|
@@ -5688,8 +6028,7 @@ var DragDropContextClient = ({
|
|
5688
6028
|
}
|
5689
6029
|
const item = getItem(
|
5690
6030
|
initialSelector.current,
|
5691
|
-
appStore.getState().state
|
5692
|
-
{}
|
6031
|
+
appStore.getState().state
|
5693
6032
|
);
|
5694
6033
|
if (item) {
|
5695
6034
|
zoneStore.setState({
|
@@ -5718,13 +6057,12 @@ var DragDropContextClient = ({
|
|
5718
6057
|
const { source } = event.operation;
|
5719
6058
|
if (source && source.type !== "void") {
|
5720
6059
|
const sourceData = source.data;
|
5721
|
-
const { data } = appStore.getState().state;
|
5722
6060
|
const item = getItem(
|
5723
6061
|
{
|
5724
6062
|
zone: sourceData.zone,
|
5725
6063
|
index: sourceData.index
|
5726
6064
|
},
|
5727
|
-
|
6065
|
+
appStore.getState().state
|
5728
6066
|
);
|
5729
6067
|
if (item) {
|
5730
6068
|
zoneStore.setState({
|
@@ -5751,17 +6089,7 @@ var DragDropContextClient = ({
|
|
5751
6089
|
initialSelector.current = void 0;
|
5752
6090
|
zoneStore.setState({ draggedItem: event.operation.source });
|
5753
6091
|
},
|
5754
|
-
children: /* @__PURE__ */
|
5755
|
-
DropZoneProvider,
|
5756
|
-
{
|
5757
|
-
value: {
|
5758
|
-
mode: "edit",
|
5759
|
-
areaId: "root",
|
5760
|
-
depth: 0
|
5761
|
-
},
|
5762
|
-
children
|
5763
|
-
}
|
5764
|
-
) })
|
6092
|
+
children: /* @__PURE__ */ jsx24(ZoneStoreProvider, { store: zoneStore, children: /* @__PURE__ */ jsx24(DropZoneProvider, { value: nextContextValue, children }) })
|
5765
6093
|
}
|
5766
6094
|
)
|
5767
6095
|
}
|
@@ -5775,11 +6103,11 @@ var DragDropContext = ({
|
|
5775
6103
|
if (status === "LOADING") {
|
5776
6104
|
return children;
|
5777
6105
|
}
|
5778
|
-
return /* @__PURE__ */
|
6106
|
+
return /* @__PURE__ */ jsx24(DragDropContextClient, { disableAutoScroll, children });
|
5779
6107
|
};
|
5780
6108
|
|
5781
6109
|
// components/Drawer/index.tsx
|
5782
|
-
import { jsx as
|
6110
|
+
import { jsx as jsx25, jsxs as jsxs11 } from "react/jsx-runtime";
|
5783
6111
|
var getClassName18 = get_class_name_factory_default("Drawer", styles_module_default10);
|
5784
6112
|
var getClassNameItem2 = get_class_name_factory_default("DrawerItem", styles_module_default10);
|
5785
6113
|
var DrawerItemInner = ({
|
@@ -5789,11 +6117,11 @@ var DrawerItemInner = ({
|
|
5789
6117
|
dragRef,
|
5790
6118
|
isDragDisabled
|
5791
6119
|
}) => {
|
5792
|
-
const CustomInner =
|
5793
|
-
() => children || (({ children: children2 }) => /* @__PURE__ */
|
6120
|
+
const CustomInner = useMemo11(
|
6121
|
+
() => children || (({ children: children2 }) => /* @__PURE__ */ jsx25("div", { className: getClassNameItem2("default"), children: children2 })),
|
5794
6122
|
[children]
|
5795
6123
|
);
|
5796
|
-
return /* @__PURE__ */
|
6124
|
+
return /* @__PURE__ */ jsx25(
|
5797
6125
|
"div",
|
5798
6126
|
{
|
5799
6127
|
className: getClassNameItem2({ disabled: isDragDisabled }),
|
@@ -5801,9 +6129,9 @@ var DrawerItemInner = ({
|
|
5801
6129
|
onMouseDown: (e) => e.preventDefault(),
|
5802
6130
|
"data-testid": dragRef ? `drawer-item:${name}` : "",
|
5803
6131
|
"data-puck-drawer-item": true,
|
5804
|
-
children: /* @__PURE__ */
|
5805
|
-
/* @__PURE__ */
|
5806
|
-
/* @__PURE__ */
|
6132
|
+
children: /* @__PURE__ */ jsx25(CustomInner, { name, children: /* @__PURE__ */ jsx25("div", { className: getClassNameItem2("draggableWrapper"), children: /* @__PURE__ */ jsxs11("div", { className: getClassNameItem2("draggable"), children: [
|
6133
|
+
/* @__PURE__ */ jsx25("div", { className: getClassNameItem2("name"), children: label != null ? label : name }),
|
6134
|
+
/* @__PURE__ */ jsx25("div", { className: getClassNameItem2("icon"), children: /* @__PURE__ */ jsx25(DragIcon, {}) })
|
5807
6135
|
] }) }) })
|
5808
6136
|
}
|
5809
6137
|
);
|
@@ -5821,8 +6149,8 @@ var DrawerItemDraggable = ({
|
|
5821
6149
|
disabled: isDragDisabled
|
5822
6150
|
});
|
5823
6151
|
return /* @__PURE__ */ jsxs11("div", { className: getClassName18("draggable"), children: [
|
5824
|
-
/* @__PURE__ */
|
5825
|
-
/* @__PURE__ */
|
6152
|
+
/* @__PURE__ */ jsx25("div", { className: getClassName18("draggableBg"), children: /* @__PURE__ */ jsx25(DrawerItemInner, { name, label, children }) }),
|
6153
|
+
/* @__PURE__ */ jsx25("div", { className: getClassName18("draggableFg"), children: /* @__PURE__ */ jsx25(
|
5826
6154
|
DrawerItemInner,
|
5827
6155
|
{
|
5828
6156
|
name,
|
@@ -5856,7 +6184,7 @@ var DrawerItem = ({
|
|
5856
6184
|
},
|
5857
6185
|
[resolvedId]
|
5858
6186
|
);
|
5859
|
-
return /* @__PURE__ */
|
6187
|
+
return /* @__PURE__ */ jsx25("div", { children: /* @__PURE__ */ jsx25(
|
5860
6188
|
DrawerItemDraggable,
|
5861
6189
|
{
|
5862
6190
|
name,
|
@@ -5889,7 +6217,7 @@ var Drawer = ({
|
|
5889
6217
|
collisionPriority: 0
|
5890
6218
|
// Never collide with this, but we use it so NestedDroppablePlugin respects the Drawer
|
5891
6219
|
});
|
5892
|
-
return /* @__PURE__ */
|
6220
|
+
return /* @__PURE__ */ jsx25(
|
5893
6221
|
"div",
|
5894
6222
|
{
|
5895
6223
|
className: getClassName18(),
|
@@ -5908,8 +6236,9 @@ import {
|
|
5908
6236
|
createContext as createContext7,
|
5909
6237
|
useCallback as useCallback16,
|
5910
6238
|
useContext as useContext11,
|
5911
|
-
useEffect as
|
5912
|
-
useMemo as
|
6239
|
+
useEffect as useEffect24,
|
6240
|
+
useMemo as useMemo20,
|
6241
|
+
useRef as useRef7,
|
5913
6242
|
useState as useState22
|
5914
6243
|
} from "react";
|
5915
6244
|
|
@@ -5922,7 +6251,7 @@ var styles_module_default13 = { "SidebarSection": "_SidebarSection_8boj8_1", "Si
|
|
5922
6251
|
|
5923
6252
|
// lib/use-breadcrumbs.ts
|
5924
6253
|
init_react_import();
|
5925
|
-
import { useMemo as
|
6254
|
+
import { useMemo as useMemo12 } from "react";
|
5926
6255
|
var useBreadcrumbs = (renderCount) => {
|
5927
6256
|
const selectedId = useAppStore((s) => {
|
5928
6257
|
var _a;
|
@@ -5931,12 +6260,12 @@ var useBreadcrumbs = (renderCount) => {
|
|
5931
6260
|
const config = useAppStore((s) => s.config);
|
5932
6261
|
const path = useAppStore((s) => {
|
5933
6262
|
var _a;
|
5934
|
-
return (_a = s.
|
6263
|
+
return (_a = s.state.indexes.nodes[selectedId]) == null ? void 0 : _a.path;
|
5935
6264
|
});
|
5936
6265
|
const appStore = useAppStoreApi();
|
5937
|
-
return
|
6266
|
+
return useMemo12(() => {
|
5938
6267
|
const breadcrumbs = (path == null ? void 0 : path.map((zoneCompound) => {
|
5939
|
-
var _a, _b;
|
6268
|
+
var _a, _b, _c;
|
5940
6269
|
const [componentId] = zoneCompound.split(":");
|
5941
6270
|
if (componentId === "root") {
|
5942
6271
|
return {
|
@@ -5944,12 +6273,15 @@ var useBreadcrumbs = (renderCount) => {
|
|
5944
6273
|
selector: null
|
5945
6274
|
};
|
5946
6275
|
}
|
5947
|
-
const node = appStore.getState().
|
5948
|
-
const
|
6276
|
+
const node = appStore.getState().state.indexes.nodes[componentId];
|
6277
|
+
const parentId = node.path[node.path.length - 1];
|
6278
|
+
const contentIds = ((_a = appStore.getState().state.indexes.zones[parentId]) == null ? void 0 : _a.contentIds) || [];
|
6279
|
+
const index = contentIds.indexOf(componentId);
|
6280
|
+
const label = node ? (_c = (_b = config.components[node.data.type]) == null ? void 0 : _b.label) != null ? _c : node.data.type : "Component";
|
5949
6281
|
return {
|
5950
6282
|
label,
|
5951
6283
|
selector: node ? {
|
5952
|
-
index
|
6284
|
+
index,
|
5953
6285
|
zone: node.path[node.path.length - 1]
|
5954
6286
|
} : null
|
5955
6287
|
};
|
@@ -5962,7 +6294,7 @@ var useBreadcrumbs = (renderCount) => {
|
|
5962
6294
|
};
|
5963
6295
|
|
5964
6296
|
// components/SidebarSection/index.tsx
|
5965
|
-
import { jsx as
|
6297
|
+
import { jsx as jsx26, jsxs as jsxs12 } from "react/jsx-runtime";
|
5966
6298
|
var getClassName19 = get_class_name_factory_default("SidebarSection", styles_module_default13);
|
5967
6299
|
var SidebarSection = ({
|
5968
6300
|
children,
|
@@ -5981,9 +6313,9 @@ var SidebarSection = ({
|
|
5981
6313
|
className: getClassName19({ noBorderTop, noPadding }),
|
5982
6314
|
style: { background },
|
5983
6315
|
children: [
|
5984
|
-
/* @__PURE__ */
|
6316
|
+
/* @__PURE__ */ jsx26("div", { className: getClassName19("title"), children: /* @__PURE__ */ jsxs12("div", { className: getClassName19("breadcrumbs"), children: [
|
5985
6317
|
showBreadcrumbs ? breadcrumbs.map((breadcrumb, i) => /* @__PURE__ */ jsxs12("div", { className: getClassName19("breadcrumb"), children: [
|
5986
|
-
/* @__PURE__ */
|
6318
|
+
/* @__PURE__ */ jsx26(
|
5987
6319
|
"button",
|
5988
6320
|
{
|
5989
6321
|
type: "button",
|
@@ -5992,12 +6324,12 @@ var SidebarSection = ({
|
|
5992
6324
|
children: breadcrumb.label
|
5993
6325
|
}
|
5994
6326
|
),
|
5995
|
-
/* @__PURE__ */
|
6327
|
+
/* @__PURE__ */ jsx26(ChevronRight, { size: 16 })
|
5996
6328
|
] }, i)) : null,
|
5997
|
-
/* @__PURE__ */
|
6329
|
+
/* @__PURE__ */ jsx26("div", { className: getClassName19("heading"), children: /* @__PURE__ */ jsx26(Heading, { rank: "2", size: "xs", children: title }) })
|
5998
6330
|
] }) }),
|
5999
|
-
/* @__PURE__ */
|
6000
|
-
isLoading && /* @__PURE__ */
|
6331
|
+
/* @__PURE__ */ jsx26("div", { className: getClassName19("content"), children }),
|
6332
|
+
isLoading && /* @__PURE__ */ jsx26("div", { className: getClassName19("loadingOverlay"), children: /* @__PURE__ */ jsx26(Loader, { size: 32 }) })
|
6001
6333
|
]
|
6002
6334
|
}
|
6003
6335
|
);
|
@@ -6011,7 +6343,7 @@ init_react_import();
|
|
6011
6343
|
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" };
|
6012
6344
|
|
6013
6345
|
// components/MenuBar/index.tsx
|
6014
|
-
import { Fragment as Fragment7, jsx as
|
6346
|
+
import { Fragment as Fragment7, jsx as jsx27, jsxs as jsxs13 } from "react/jsx-runtime";
|
6015
6347
|
var getClassName20 = get_class_name_factory_default("MenuBar", styles_module_default14);
|
6016
6348
|
function MenuBar({
|
6017
6349
|
menuOpen = false,
|
@@ -6022,7 +6354,7 @@ function MenuBar({
|
|
6022
6354
|
const forward = useAppStore((s) => s.history.forward);
|
6023
6355
|
const hasFuture = useAppStore((s) => s.history.hasFuture());
|
6024
6356
|
const hasPast = useAppStore((s) => s.history.hasPast());
|
6025
|
-
return /* @__PURE__ */
|
6357
|
+
return /* @__PURE__ */ jsx27(
|
6026
6358
|
"div",
|
6027
6359
|
{
|
6028
6360
|
className: getClassName20({ menuOpen }),
|
@@ -6038,10 +6370,10 @@ function MenuBar({
|
|
6038
6370
|
},
|
6039
6371
|
children: /* @__PURE__ */ jsxs13("div", { className: getClassName20("inner"), children: [
|
6040
6372
|
/* @__PURE__ */ jsxs13("div", { className: getClassName20("history"), children: [
|
6041
|
-
/* @__PURE__ */
|
6042
|
-
/* @__PURE__ */
|
6373
|
+
/* @__PURE__ */ jsx27(IconButton, { title: "undo", disabled: !hasPast, onClick: back, children: /* @__PURE__ */ jsx27(Undo2, { size: 21 }) }),
|
6374
|
+
/* @__PURE__ */ jsx27(IconButton, { title: "redo", disabled: !hasFuture, onClick: forward, children: /* @__PURE__ */ jsx27(Redo2, { size: 21 }) })
|
6043
6375
|
] }),
|
6044
|
-
/* @__PURE__ */
|
6376
|
+
/* @__PURE__ */ jsx27(Fragment7, { children: renderHeaderActions && renderHeaderActions() })
|
6045
6377
|
] })
|
6046
6378
|
}
|
6047
6379
|
);
|
@@ -6059,19 +6391,18 @@ init_react_import();
|
|
6059
6391
|
var styles_module_default16 = { "PuckFields": "_PuckFields_10bh7_1", "PuckFields--isLoading": "_PuckFields--isLoading_10bh7_6", "PuckFields-loadingOverlay": "_PuckFields-loadingOverlay_10bh7_10", "PuckFields-loadingOverlayInner": "_PuckFields-loadingOverlayInner_10bh7_25", "PuckFields-field": "_PuckFields-field_10bh7_32", "PuckFields--wrapFields": "_PuckFields--wrapFields_10bh7_36" };
|
6060
6392
|
|
6061
6393
|
// components/Puck/components/Fields/index.tsx
|
6062
|
-
import { useCallback as useCallback11, useMemo as
|
6394
|
+
import { useCallback as useCallback11, useMemo as useMemo13 } from "react";
|
6063
6395
|
import { useShallow as useShallow4 } from "zustand/react/shallow";
|
6064
|
-
import { Fragment as Fragment8, jsx as
|
6396
|
+
import { Fragment as Fragment8, jsx as jsx28, jsxs as jsxs14 } from "react/jsx-runtime";
|
6065
6397
|
var getClassName21 = get_class_name_factory_default("PuckFields", styles_module_default16);
|
6066
6398
|
var DefaultFields = ({
|
6067
6399
|
children
|
6068
6400
|
}) => {
|
6069
|
-
return /* @__PURE__ */
|
6401
|
+
return /* @__PURE__ */ jsx28(Fragment8, { children });
|
6070
6402
|
};
|
6071
|
-
var createOnChange = (fieldName, appStore) => (value, updatedUi) => {
|
6072
|
-
var _a, _b;
|
6403
|
+
var createOnChange = (fieldName, appStore) => (value, updatedUi) => __async(void 0, null, function* () {
|
6073
6404
|
let currentProps;
|
6074
|
-
const { dispatch,
|
6405
|
+
const { dispatch, state, selectedItem, resolveComponentData: resolveComponentData2 } = appStore.getState();
|
6075
6406
|
const { data, ui } = state;
|
6076
6407
|
const { itemSelector } = ui;
|
6077
6408
|
const rootProps = data.root.props || data.root;
|
@@ -6084,48 +6415,27 @@ var createOnChange = (fieldName, appStore) => (value, updatedUi) => {
|
|
6084
6415
|
[fieldName]: value
|
6085
6416
|
});
|
6086
6417
|
if (selectedItem && itemSelector) {
|
6087
|
-
|
6418
|
+
dispatch({
|
6088
6419
|
type: "replace",
|
6089
6420
|
destinationIndex: itemSelector.index,
|
6090
6421
|
destinationZone: itemSelector.zone || rootDroppableId,
|
6091
|
-
data:
|
6092
|
-
|
6093
|
-
|
6094
|
-
|
6095
|
-
|
6096
|
-
|
6097
|
-
data: __spreadValues(__spreadValues({}, data), replacedData),
|
6098
|
-
ui: __spreadValues(__spreadValues({}, ui), updatedUi)
|
6099
|
-
}
|
6100
|
-
};
|
6101
|
-
if ((_a = config.components[selectedItem.type]) == null ? void 0 : _a.resolveData) {
|
6102
|
-
resolveData2(setAction(state, setActionData));
|
6103
|
-
} else {
|
6104
|
-
dispatch(__spreadProps(__spreadValues({}, setActionData), {
|
6105
|
-
recordHistory: true
|
6106
|
-
}));
|
6107
|
-
}
|
6422
|
+
data: (yield resolveComponentData2(
|
6423
|
+
__spreadProps(__spreadValues({}, selectedItem), { props: newProps }),
|
6424
|
+
"replace"
|
6425
|
+
)).node,
|
6426
|
+
ui: updatedUi
|
6427
|
+
});
|
6108
6428
|
} else {
|
6109
6429
|
if (data.root.props) {
|
6110
|
-
|
6111
|
-
|
6112
|
-
|
6113
|
-
|
6114
|
-
|
6115
|
-
|
6116
|
-
})
|
6117
|
-
|
6118
|
-
|
6119
|
-
type: "set",
|
6120
|
-
state: {
|
6121
|
-
ui: __spreadValues(__spreadValues({}, ui), updatedUi),
|
6122
|
-
data: __spreadProps(__spreadValues({}, data), {
|
6123
|
-
root: { props: newProps }
|
6124
|
-
})
|
6125
|
-
},
|
6126
|
-
recordHistory: true
|
6127
|
-
});
|
6128
|
-
}
|
6430
|
+
dispatch({
|
6431
|
+
type: "replaceRoot",
|
6432
|
+
root: (yield resolveComponentData2(
|
6433
|
+
__spreadProps(__spreadValues({}, data.root), { props: newProps }),
|
6434
|
+
"replace"
|
6435
|
+
)).node,
|
6436
|
+
ui: __spreadValues(__spreadValues({}, ui), updatedUi),
|
6437
|
+
recordHistory: true
|
6438
|
+
});
|
6129
6439
|
} else {
|
6130
6440
|
dispatch({
|
6131
6441
|
type: "setData",
|
@@ -6133,7 +6443,7 @@ var createOnChange = (fieldName, appStore) => (value, updatedUi) => {
|
|
6133
6443
|
});
|
6134
6444
|
}
|
6135
6445
|
}
|
6136
|
-
};
|
6446
|
+
});
|
6137
6447
|
var FieldsChild = ({ fieldName }) => {
|
6138
6448
|
const field = useAppStore((s) => s.fields.fields[fieldName]);
|
6139
6449
|
const isReadOnly = useAppStore(
|
@@ -6158,7 +6468,8 @@ var FieldsChild = ({ fieldName }) => {
|
|
6158
6468
|
fieldName
|
6159
6469
|
]);
|
6160
6470
|
if (!field || !id) return null;
|
6161
|
-
|
6471
|
+
if (field.type === "slot") return null;
|
6472
|
+
return /* @__PURE__ */ jsx28("div", { className: getClassName21("field"), children: /* @__PURE__ */ jsx28(
|
6162
6473
|
AutoFieldPrivate,
|
6163
6474
|
{
|
6164
6475
|
field,
|
@@ -6174,7 +6485,7 @@ var Fields = ({ wrapFields = true }) => {
|
|
6174
6485
|
const overrides = useAppStore((s) => s.overrides);
|
6175
6486
|
const componentResolving = useAppStore((s) => {
|
6176
6487
|
var _a, _b;
|
6177
|
-
const loadingCount = s.selectedItem ? (_a = s.componentState[s.selectedItem.props.id]) == null ? void 0 : _a.loadingCount : (_b = s.componentState["
|
6488
|
+
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;
|
6178
6489
|
return (loadingCount != null ? loadingCount : 0) > 0;
|
6179
6490
|
});
|
6180
6491
|
const itemSelector = useAppStore(useShallow4((s) => s.state.ui.itemSelector));
|
@@ -6186,10 +6497,15 @@ var Fields = ({ wrapFields = true }) => {
|
|
6186
6497
|
useRegisterFieldsSlice(appStore, id);
|
6187
6498
|
const fieldsLoading = useAppStore((s) => s.fields.loading);
|
6188
6499
|
const fieldNames = useAppStore(
|
6189
|
-
useShallow4((s) =>
|
6500
|
+
useShallow4((s) => {
|
6501
|
+
if (s.fields.id === id) {
|
6502
|
+
return Object.keys(s.fields.fields);
|
6503
|
+
}
|
6504
|
+
return [];
|
6505
|
+
})
|
6190
6506
|
);
|
6191
6507
|
const isLoading = fieldsLoading || componentResolving;
|
6192
|
-
const Wrapper =
|
6508
|
+
const Wrapper = useMemo13(() => overrides.fields || DefaultFields, [overrides]);
|
6193
6509
|
return /* @__PURE__ */ jsxs14(
|
6194
6510
|
"form",
|
6195
6511
|
{
|
@@ -6198,8 +6514,8 @@ var Fields = ({ wrapFields = true }) => {
|
|
6198
6514
|
e.preventDefault();
|
6199
6515
|
},
|
6200
6516
|
children: [
|
6201
|
-
/* @__PURE__ */
|
6202
|
-
isLoading && /* @__PURE__ */
|
6517
|
+
/* @__PURE__ */ jsx28(Wrapper, { isLoading, itemSelector, children: fieldNames.map((fieldName) => /* @__PURE__ */ jsx28(FieldsChild, { fieldName }, fieldName)) }),
|
6518
|
+
isLoading && /* @__PURE__ */ jsx28("div", { className: getClassName21("loadingOverlay"), children: /* @__PURE__ */ jsx28("div", { className: getClassName21("loadingOverlayInner"), children: /* @__PURE__ */ jsx28(Loader, { size: 16 }) }) })
|
6203
6519
|
]
|
6204
6520
|
}
|
6205
6521
|
);
|
@@ -6210,7 +6526,7 @@ init_react_import();
|
|
6210
6526
|
|
6211
6527
|
// lib/use-component-list.tsx
|
6212
6528
|
init_react_import();
|
6213
|
-
import { useEffect as
|
6529
|
+
import { useEffect as useEffect17, useState as useState16 } from "react";
|
6214
6530
|
|
6215
6531
|
// components/ComponentList/index.tsx
|
6216
6532
|
init_react_import();
|
@@ -6220,7 +6536,7 @@ init_react_import();
|
|
6220
6536
|
var styles_module_default17 = { "ComponentList": "_ComponentList_1rrlt_1", "ComponentList--isExpanded": "_ComponentList--isExpanded_1rrlt_5", "ComponentList-content": "_ComponentList-content_1rrlt_9", "ComponentList-title": "_ComponentList-title_1rrlt_17", "ComponentList-titleIcon": "_ComponentList-titleIcon_1rrlt_53" };
|
6221
6537
|
|
6222
6538
|
// components/ComponentList/index.tsx
|
6223
|
-
import { jsx as
|
6539
|
+
import { jsx as jsx29, jsxs as jsxs15 } from "react/jsx-runtime";
|
6224
6540
|
var getClassName22 = get_class_name_factory_default("ComponentList", styles_module_default17);
|
6225
6541
|
var ComponentListItem = ({
|
6226
6542
|
name,
|
@@ -6232,7 +6548,7 @@ var ComponentListItem = ({
|
|
6232
6548
|
type: name
|
6233
6549
|
}).insert
|
6234
6550
|
);
|
6235
|
-
return /* @__PURE__ */
|
6551
|
+
return /* @__PURE__ */ jsx29(Drawer.Item, { label, name, isDragDisabled: !canInsert, children: overrides.componentItem });
|
6236
6552
|
};
|
6237
6553
|
var ComponentList = ({
|
6238
6554
|
children,
|
@@ -6258,14 +6574,14 @@ var ComponentList = ({
|
|
6258
6574
|
}),
|
6259
6575
|
title: expanded ? `Collapse${title ? ` ${title}` : ""}` : `Expand${title ? ` ${title}` : ""}`,
|
6260
6576
|
children: [
|
6261
|
-
/* @__PURE__ */
|
6262
|
-
/* @__PURE__ */
|
6577
|
+
/* @__PURE__ */ jsx29("div", { children: title }),
|
6578
|
+
/* @__PURE__ */ jsx29("div", { className: getClassName22("titleIcon"), children: expanded ? /* @__PURE__ */ jsx29(ChevronUp, { size: 12 }) : /* @__PURE__ */ jsx29(ChevronDown, { size: 12 }) })
|
6263
6579
|
]
|
6264
6580
|
}
|
6265
6581
|
),
|
6266
|
-
/* @__PURE__ */
|
6582
|
+
/* @__PURE__ */ jsx29("div", { className: getClassName22("content"), children: /* @__PURE__ */ jsx29(Drawer, { children: children || Object.keys(config.components).map((componentKey) => {
|
6267
6583
|
var _a;
|
6268
|
-
return /* @__PURE__ */
|
6584
|
+
return /* @__PURE__ */ jsx29(
|
6269
6585
|
ComponentListItem,
|
6270
6586
|
{
|
6271
6587
|
label: (_a = config.components[componentKey]["label"]) != null ? _a : componentKey,
|
@@ -6279,12 +6595,12 @@ var ComponentList = ({
|
|
6279
6595
|
ComponentList.Item = ComponentListItem;
|
6280
6596
|
|
6281
6597
|
// lib/use-component-list.tsx
|
6282
|
-
import { jsx as
|
6598
|
+
import { jsx as jsx30 } from "react/jsx-runtime";
|
6283
6599
|
var useComponentList = () => {
|
6284
6600
|
const [componentList, setComponentList] = useState16();
|
6285
6601
|
const config = useAppStore((s) => s.config);
|
6286
6602
|
const uiComponentList = useAppStore((s) => s.state.ui.componentList);
|
6287
|
-
|
6603
|
+
useEffect17(() => {
|
6288
6604
|
var _a, _b, _c;
|
6289
6605
|
if (Object.keys(uiComponentList).length > 0) {
|
6290
6606
|
const matchedComponents = [];
|
@@ -6294,7 +6610,7 @@ var useComponentList = () => {
|
|
6294
6610
|
if (category.visible === false || !category.components) {
|
6295
6611
|
return null;
|
6296
6612
|
}
|
6297
|
-
return /* @__PURE__ */
|
6613
|
+
return /* @__PURE__ */ jsx30(
|
6298
6614
|
ComponentList,
|
6299
6615
|
{
|
6300
6616
|
id: categoryKey,
|
@@ -6303,7 +6619,7 @@ var useComponentList = () => {
|
|
6303
6619
|
var _a2;
|
6304
6620
|
matchedComponents.push(componentName);
|
6305
6621
|
const componentConf = config.components[componentName] || {};
|
6306
|
-
return /* @__PURE__ */
|
6622
|
+
return /* @__PURE__ */ jsx30(
|
6307
6623
|
ComponentList.Item,
|
6308
6624
|
{
|
6309
6625
|
label: (_a2 = componentConf["label"]) != null ? _a2 : componentName,
|
@@ -6323,7 +6639,7 @@ var useComponentList = () => {
|
|
6323
6639
|
);
|
6324
6640
|
if (remainingComponents.length > 0 && !((_a = uiComponentList.other) == null ? void 0 : _a.components) && ((_b = uiComponentList.other) == null ? void 0 : _b.visible) !== false) {
|
6325
6641
|
_componentList.push(
|
6326
|
-
/* @__PURE__ */
|
6642
|
+
/* @__PURE__ */ jsx30(
|
6327
6643
|
ComponentList,
|
6328
6644
|
{
|
6329
6645
|
id: "other",
|
@@ -6331,7 +6647,7 @@ var useComponentList = () => {
|
|
6331
6647
|
children: remainingComponents.map((componentName, i) => {
|
6332
6648
|
var _a2;
|
6333
6649
|
const componentConf = config.components[componentName] || {};
|
6334
|
-
return /* @__PURE__ */
|
6650
|
+
return /* @__PURE__ */ jsx30(
|
6335
6651
|
ComponentList.Item,
|
6336
6652
|
{
|
6337
6653
|
name: componentName,
|
@@ -6353,30 +6669,30 @@ var useComponentList = () => {
|
|
6353
6669
|
};
|
6354
6670
|
|
6355
6671
|
// components/Puck/components/Components/index.tsx
|
6356
|
-
import { useMemo as
|
6357
|
-
import { jsx as
|
6672
|
+
import { useMemo as useMemo14 } from "react";
|
6673
|
+
import { jsx as jsx31 } from "react/jsx-runtime";
|
6358
6674
|
var Components = () => {
|
6359
6675
|
const overrides = useAppStore((s) => s.overrides);
|
6360
6676
|
const componentList = useComponentList();
|
6361
|
-
const Wrapper =
|
6362
|
-
return /* @__PURE__ */
|
6677
|
+
const Wrapper = useMemo14(() => overrides.components || "div", [overrides]);
|
6678
|
+
return /* @__PURE__ */ jsx31(Wrapper, { children: componentList ? componentList : /* @__PURE__ */ jsx31(ComponentList, { id: "all" }) });
|
6363
6679
|
};
|
6364
6680
|
|
6365
6681
|
// components/Puck/components/Preview/index.tsx
|
6366
6682
|
init_react_import();
|
6367
|
-
import { useCallback as useCallback12, useEffect as
|
6683
|
+
import { useCallback as useCallback12, useEffect as useEffect19, useRef as useRef5, useMemo as useMemo15 } from "react";
|
6368
6684
|
|
6369
6685
|
// components/AutoFrame/index.tsx
|
6370
6686
|
init_react_import();
|
6371
6687
|
import {
|
6372
6688
|
createContext as createContext5,
|
6373
6689
|
useContext as useContext8,
|
6374
|
-
useEffect as
|
6690
|
+
useEffect as useEffect18,
|
6375
6691
|
useState as useState17
|
6376
6692
|
} from "react";
|
6377
6693
|
import hash from "object-hash";
|
6378
6694
|
import { createPortal as createPortal3 } from "react-dom";
|
6379
|
-
import { Fragment as Fragment9, jsx as
|
6695
|
+
import { Fragment as Fragment9, jsx as jsx32 } from "react/jsx-runtime";
|
6380
6696
|
var styleSelector = 'style, link[rel="stylesheet"]';
|
6381
6697
|
var collectStyles = (doc) => {
|
6382
6698
|
const collected = [];
|
@@ -6419,7 +6735,7 @@ var CopyHostStyles = ({
|
|
6419
6735
|
onStylesLoaded = () => null
|
6420
6736
|
}) => {
|
6421
6737
|
const { document: doc, window: win } = useFrame();
|
6422
|
-
|
6738
|
+
useEffect18(() => {
|
6423
6739
|
if (!win || !doc) {
|
6424
6740
|
return () => {
|
6425
6741
|
};
|
@@ -6576,7 +6892,7 @@ var CopyHostStyles = ({
|
|
6576
6892
|
observer.disconnect();
|
6577
6893
|
};
|
6578
6894
|
}, []);
|
6579
|
-
return /* @__PURE__ */
|
6895
|
+
return /* @__PURE__ */ jsx32(Fragment9, { children });
|
6580
6896
|
};
|
6581
6897
|
var autoFrameContext = createContext5({});
|
6582
6898
|
var useFrame = () => useContext8(autoFrameContext);
|
@@ -6604,7 +6920,7 @@ function AutoFrame(_a) {
|
|
6604
6920
|
const [ctx, setCtx] = useState17({});
|
6605
6921
|
const [mountTarget, setMountTarget] = useState17();
|
6606
6922
|
const [stylesLoaded, setStylesLoaded] = useState17(false);
|
6607
|
-
|
6923
|
+
useEffect18(() => {
|
6608
6924
|
var _a2;
|
6609
6925
|
if (frameRef.current) {
|
6610
6926
|
const doc = frameRef.current.contentDocument;
|
@@ -6623,7 +6939,7 @@ function AutoFrame(_a) {
|
|
6623
6939
|
}
|
6624
6940
|
}
|
6625
6941
|
}, [frameRef, loaded, stylesLoaded]);
|
6626
|
-
return /* @__PURE__ */
|
6942
|
+
return /* @__PURE__ */ jsx32(
|
6627
6943
|
"iframe",
|
6628
6944
|
__spreadProps(__spreadValues({}, props), {
|
6629
6945
|
className,
|
@@ -6633,7 +6949,7 @@ function AutoFrame(_a) {
|
|
6633
6949
|
onLoad: () => {
|
6634
6950
|
setLoaded(true);
|
6635
6951
|
},
|
6636
|
-
children: /* @__PURE__ */
|
6952
|
+
children: /* @__PURE__ */ jsx32(autoFrameContext.Provider, { value: ctx, children: loaded && mountTarget && /* @__PURE__ */ jsx32(
|
6637
6953
|
CopyHostStyles,
|
6638
6954
|
{
|
6639
6955
|
debug,
|
@@ -6652,11 +6968,11 @@ init_react_import();
|
|
6652
6968
|
var styles_module_default18 = { "PuckPreview": "_PuckPreview_z2rgu_1", "PuckPreview-frame": "_PuckPreview-frame_z2rgu_6" };
|
6653
6969
|
|
6654
6970
|
// components/Puck/components/Preview/index.tsx
|
6655
|
-
import { Fragment as Fragment10, jsx as
|
6971
|
+
import { Fragment as Fragment10, jsx as jsx33 } from "react/jsx-runtime";
|
6656
6972
|
var getClassName23 = get_class_name_factory_default("PuckPreview", styles_module_default18);
|
6657
6973
|
var useBubbleIframeEvents = (ref) => {
|
6658
6974
|
const status = useAppStore((s) => s.status);
|
6659
|
-
|
6975
|
+
useEffect19(() => {
|
6660
6976
|
if (ref.current && status === "READY") {
|
6661
6977
|
const iframe = ref.current;
|
6662
6978
|
const handlePointerMove = (event) => {
|
@@ -6708,17 +7024,19 @@ var Preview3 = ({ id = "puck-preview" }) => {
|
|
6708
7024
|
const Page = useCallback12(
|
6709
7025
|
(pageProps) => {
|
6710
7026
|
var _a, _b;
|
7027
|
+
const rootConfig = config.root;
|
7028
|
+
const propsWithSlots = useSlots(rootConfig, pageProps, DropZoneEditPure);
|
6711
7029
|
return ((_a = config.root) == null ? void 0 : _a.render) ? (_b = config.root) == null ? void 0 : _b.render(__spreadValues({
|
6712
7030
|
id: "puck-root"
|
6713
|
-
},
|
7031
|
+
}, propsWithSlots)) : /* @__PURE__ */ jsx33(Fragment10, { children: propsWithSlots.children });
|
6714
7032
|
},
|
6715
7033
|
[config.root]
|
6716
7034
|
);
|
6717
|
-
const Frame =
|
7035
|
+
const Frame = useMemo15(() => overrides.iframe, [overrides]);
|
6718
7036
|
const rootProps = root.props || root;
|
6719
7037
|
const ref = useRef5(null);
|
6720
7038
|
useBubbleIframeEvents(ref);
|
6721
|
-
const inner = !renderData ? /* @__PURE__ */
|
7039
|
+
const inner = !renderData ? /* @__PURE__ */ jsx33(
|
6722
7040
|
Page,
|
6723
7041
|
__spreadProps(__spreadValues({}, rootProps), {
|
6724
7042
|
puck: {
|
@@ -6728,15 +7046,15 @@ var Preview3 = ({ id = "puck-preview" }) => {
|
|
6728
7046
|
metadata
|
6729
7047
|
},
|
6730
7048
|
editMode: true,
|
6731
|
-
children: /* @__PURE__ */
|
7049
|
+
children: /* @__PURE__ */ jsx33(DropZonePure, { zone: rootDroppableId })
|
6732
7050
|
})
|
6733
|
-
) : /* @__PURE__ */
|
6734
|
-
|
7051
|
+
) : /* @__PURE__ */ jsx33(Render, { data: renderData, config });
|
7052
|
+
useEffect19(() => {
|
6735
7053
|
if (!iframe.enabled) {
|
6736
7054
|
setStatus("READY");
|
6737
7055
|
}
|
6738
7056
|
}, [iframe.enabled]);
|
6739
|
-
return /* @__PURE__ */
|
7057
|
+
return /* @__PURE__ */ jsx33(
|
6740
7058
|
"div",
|
6741
7059
|
{
|
6742
7060
|
className: getClassName23(),
|
@@ -6745,7 +7063,7 @@ var Preview3 = ({ id = "puck-preview" }) => {
|
|
6745
7063
|
onClick: () => {
|
6746
7064
|
dispatch({ type: "setUi", ui: { itemSelector: null } });
|
6747
7065
|
},
|
6748
|
-
children: iframe.enabled ? /* @__PURE__ */
|
7066
|
+
children: iframe.enabled ? /* @__PURE__ */ jsx33(
|
6749
7067
|
AutoFrame_default,
|
6750
7068
|
{
|
6751
7069
|
id: "preview-frame",
|
@@ -6758,14 +7076,14 @@ var Preview3 = ({ id = "puck-preview" }) => {
|
|
6758
7076
|
setStatus("MOUNTED");
|
6759
7077
|
},
|
6760
7078
|
frameRef: ref,
|
6761
|
-
children: /* @__PURE__ */
|
7079
|
+
children: /* @__PURE__ */ jsx33(autoFrameContext.Consumer, { children: ({ document: document2 }) => {
|
6762
7080
|
if (Frame) {
|
6763
|
-
return /* @__PURE__ */
|
7081
|
+
return /* @__PURE__ */ jsx33(Frame, { document: document2, children: inner });
|
6764
7082
|
}
|
6765
7083
|
return inner;
|
6766
7084
|
} })
|
6767
7085
|
}
|
6768
|
-
) : /* @__PURE__ */
|
7086
|
+
) : /* @__PURE__ */ jsx33(
|
6769
7087
|
"div",
|
6770
7088
|
{
|
6771
7089
|
id: "preview-frame",
|
@@ -6782,27 +7100,6 @@ var Preview3 = ({ id = "puck-preview" }) => {
|
|
6782
7100
|
// components/Puck/components/Outline/index.tsx
|
6783
7101
|
init_react_import();
|
6784
7102
|
|
6785
|
-
// lib/area-contains-zones.ts
|
6786
|
-
init_react_import();
|
6787
|
-
|
6788
|
-
// lib/find-zones-for-area.ts
|
6789
|
-
init_react_import();
|
6790
|
-
var findZonesForArea = (data, area) => {
|
6791
|
-
const { zones = {} } = data;
|
6792
|
-
const result = Object.keys(zones).filter(
|
6793
|
-
(zoneId) => getZoneId(zoneId)[0] === area
|
6794
|
-
);
|
6795
|
-
return result.reduce((acc, key) => {
|
6796
|
-
return __spreadProps(__spreadValues({}, acc), { [key]: zones[key] });
|
6797
|
-
}, {});
|
6798
|
-
};
|
6799
|
-
|
6800
|
-
// lib/area-contains-zones.ts
|
6801
|
-
var areaContainsZones = (data, area) => {
|
6802
|
-
const zones = Object.keys(findZonesForArea(data, area));
|
6803
|
-
return zones.length > 0;
|
6804
|
-
};
|
6805
|
-
|
6806
7103
|
// components/LayerTree/index.tsx
|
6807
7104
|
init_react_import();
|
6808
7105
|
|
@@ -6822,7 +7119,7 @@ var scrollIntoView = (el) => {
|
|
6822
7119
|
};
|
6823
7120
|
|
6824
7121
|
// components/LayerTree/index.tsx
|
6825
|
-
import { useContext as useContext9 } from "react";
|
7122
|
+
import { useCallback as useCallback13, useContext as useContext9 } from "react";
|
6826
7123
|
|
6827
7124
|
// lib/on-scroll-end.ts
|
6828
7125
|
init_react_import();
|
@@ -6844,124 +7141,147 @@ var onScrollEnd = (frame, cb) => {
|
|
6844
7141
|
};
|
6845
7142
|
|
6846
7143
|
// components/LayerTree/index.tsx
|
6847
|
-
import {
|
7144
|
+
import { useShallow as useShallow5 } from "zustand/react/shallow";
|
7145
|
+
import { Fragment as Fragment11, jsx as jsx34, jsxs as jsxs16 } from "react/jsx-runtime";
|
6848
7146
|
var getClassName24 = get_class_name_factory_default("LayerTree", styles_module_default19);
|
6849
7147
|
var getClassNameLayer = get_class_name_factory_default("Layer", styles_module_default19);
|
6850
|
-
var
|
6851
|
-
|
6852
|
-
|
6853
|
-
|
6854
|
-
itemSelector,
|
6855
|
-
setItemSelector,
|
6856
|
-
zone,
|
6857
|
-
label
|
7148
|
+
var Layer = ({
|
7149
|
+
index,
|
7150
|
+
itemId,
|
7151
|
+
zoneCompound
|
6858
7152
|
}) => {
|
6859
|
-
|
7153
|
+
var _a;
|
6860
7154
|
const ctx = useContext9(dropZoneContext);
|
6861
|
-
const
|
7155
|
+
const config = useAppStore((s) => s.config);
|
7156
|
+
const itemSelector = useAppStore((s) => s.state.ui.itemSelector);
|
7157
|
+
const dispatch = useAppStore((s) => s.dispatch);
|
7158
|
+
const setItemSelector = useCallback13(
|
7159
|
+
(itemSelector2) => {
|
7160
|
+
dispatch({ type: "setUi", ui: { itemSelector: itemSelector2 } });
|
7161
|
+
},
|
7162
|
+
[dispatch]
|
7163
|
+
);
|
7164
|
+
const selecedItemId = useAppStore((s) => {
|
7165
|
+
var _a2;
|
7166
|
+
return (_a2 = s.selectedItem) == null ? void 0 : _a2.props.id;
|
7167
|
+
});
|
7168
|
+
const isSelected = selecedItemId === itemId || itemSelector && itemSelector.zone === rootDroppableId && !zoneCompound;
|
7169
|
+
const nodeData = useAppStore((s) => s.state.indexes.nodes[itemId]);
|
7170
|
+
const zonesForItem = useAppStore(
|
7171
|
+
useShallow5(
|
7172
|
+
(s) => Object.keys(s.state.indexes.zones).filter(
|
7173
|
+
(z) => z.split(":")[0] === itemId
|
7174
|
+
)
|
7175
|
+
)
|
7176
|
+
);
|
7177
|
+
const containsZone = zonesForItem.length > 0;
|
7178
|
+
const { setHoveringComponent = () => {
|
7179
|
+
}, hoveringComponent } = ctx || {};
|
7180
|
+
const isHovering = hoveringComponent === itemId;
|
7181
|
+
const childIsSelected = useAppStore((s) => {
|
7182
|
+
var _a2, _b;
|
7183
|
+
const selectedData = s.state.indexes.nodes[(_a2 = s.selectedItem) == null ? void 0 : _a2.props.id];
|
7184
|
+
return (_b = selectedData == null ? void 0 : selectedData.path.some((candidate) => {
|
7185
|
+
const [candidateId] = candidate.split(":");
|
7186
|
+
return candidateId === itemId;
|
7187
|
+
})) != null ? _b : false;
|
7188
|
+
});
|
7189
|
+
const componentConfig = config.components[nodeData.data.type];
|
7190
|
+
const label = (_a = componentConfig == null ? void 0 : componentConfig["label"]) != null ? _a : nodeData.data.type.toString();
|
7191
|
+
return /* @__PURE__ */ jsxs16(
|
7192
|
+
"li",
|
7193
|
+
{
|
7194
|
+
className: getClassNameLayer({
|
7195
|
+
isSelected,
|
7196
|
+
isHovering,
|
7197
|
+
containsZone,
|
7198
|
+
childIsSelected
|
7199
|
+
}),
|
7200
|
+
children: [
|
7201
|
+
/* @__PURE__ */ jsx34("div", { className: getClassNameLayer("inner"), children: /* @__PURE__ */ jsxs16(
|
7202
|
+
"button",
|
7203
|
+
{
|
7204
|
+
type: "button",
|
7205
|
+
className: getClassNameLayer("clickable"),
|
7206
|
+
onClick: () => {
|
7207
|
+
if (isSelected) {
|
7208
|
+
setItemSelector(null);
|
7209
|
+
return;
|
7210
|
+
}
|
7211
|
+
const frame = getFrame();
|
7212
|
+
const el = frame == null ? void 0 : frame.querySelector(
|
7213
|
+
`[data-puck-component="${itemId}"]`
|
7214
|
+
);
|
7215
|
+
if (!el) {
|
7216
|
+
console.error("Scroll failed. No element was found for", itemId);
|
7217
|
+
return;
|
7218
|
+
}
|
7219
|
+
scrollIntoView(el);
|
7220
|
+
onScrollEnd(frame, () => {
|
7221
|
+
setItemSelector({
|
7222
|
+
index,
|
7223
|
+
zone: zoneCompound
|
7224
|
+
});
|
7225
|
+
});
|
7226
|
+
},
|
7227
|
+
onMouseOver: (e) => {
|
7228
|
+
e.stopPropagation();
|
7229
|
+
setHoveringComponent(itemId);
|
7230
|
+
},
|
7231
|
+
onMouseOut: (e) => {
|
7232
|
+
e.stopPropagation();
|
7233
|
+
setHoveringComponent(null);
|
7234
|
+
},
|
7235
|
+
children: [
|
7236
|
+
containsZone && /* @__PURE__ */ jsx34(
|
7237
|
+
"div",
|
7238
|
+
{
|
7239
|
+
className: getClassNameLayer("chevron"),
|
7240
|
+
title: isSelected ? "Collapse" : "Expand",
|
7241
|
+
children: /* @__PURE__ */ jsx34(ChevronDown, { size: "12" })
|
7242
|
+
}
|
7243
|
+
),
|
7244
|
+
/* @__PURE__ */ jsxs16("div", { className: getClassNameLayer("title"), children: [
|
7245
|
+
/* @__PURE__ */ jsx34("div", { className: getClassNameLayer("icon"), children: nodeData.data.type === "Text" || nodeData.data.type === "Heading" ? /* @__PURE__ */ jsx34(Type, { size: "16" }) : /* @__PURE__ */ jsx34(LayoutGrid, { size: "16" }) }),
|
7246
|
+
/* @__PURE__ */ jsx34("div", { className: getClassNameLayer("name"), children: label })
|
7247
|
+
] })
|
7248
|
+
]
|
7249
|
+
}
|
7250
|
+
) }),
|
7251
|
+
containsZone && zonesForItem.map((subzone) => /* @__PURE__ */ jsx34("div", { className: getClassNameLayer("zones"), children: /* @__PURE__ */ jsx34(LayerTree, { zoneCompound: subzone }) }, subzone))
|
7252
|
+
]
|
7253
|
+
}
|
7254
|
+
);
|
7255
|
+
};
|
7256
|
+
var LayerTree = ({
|
7257
|
+
label: _label,
|
7258
|
+
zoneCompound
|
7259
|
+
}) => {
|
7260
|
+
const label = _label != null ? _label : zoneCompound.split(":")[1];
|
7261
|
+
const contentIds = useAppStore(
|
7262
|
+
useShallow5(
|
7263
|
+
(s) => {
|
7264
|
+
var _a, _b;
|
7265
|
+
return zoneCompound ? (_b = (_a = s.state.indexes.zones[zoneCompound]) == null ? void 0 : _a.contentIds) != null ? _b : [] : [];
|
7266
|
+
}
|
7267
|
+
)
|
7268
|
+
);
|
6862
7269
|
return /* @__PURE__ */ jsxs16(Fragment11, { children: [
|
6863
7270
|
label && /* @__PURE__ */ jsxs16("div", { className: getClassName24("zoneTitle"), children: [
|
6864
|
-
/* @__PURE__ */
|
6865
|
-
" ",
|
7271
|
+
/* @__PURE__ */ jsx34("div", { className: getClassName24("zoneIcon"), children: /* @__PURE__ */ jsx34(Layers, { size: "16" }) }),
|
6866
7272
|
label
|
6867
7273
|
] }),
|
6868
7274
|
/* @__PURE__ */ jsxs16("ul", { className: getClassName24(), children: [
|
6869
|
-
|
6870
|
-
|
6871
|
-
|
6872
|
-
|
6873
|
-
const zonesForItem = findZonesForArea(data, item.props.id);
|
6874
|
-
const containsZone = Object.keys(zonesForItem).length > 0;
|
6875
|
-
const { setHoveringComponent = () => {
|
6876
|
-
}, hoveringComponent } = ctx || {};
|
6877
|
-
const selectedItem = itemSelector && data ? getItem(itemSelector, data) : null;
|
6878
|
-
const isHovering = hoveringComponent === item.props.id;
|
6879
|
-
const path = selectedItem ? (_b = (_a = nodes[selectedItem == null ? void 0 : selectedItem.props.id]) == null ? void 0 : _a.path) != null ? _b : [] : [];
|
6880
|
-
const childIsSelected = (_c = path == null ? void 0 : path.some((candidate) => {
|
6881
|
-
const [candidateId] = candidate.split(":");
|
6882
|
-
return candidateId === item.props.id;
|
6883
|
-
})) != null ? _c : false;
|
6884
|
-
const componentConfig = config.components[item.type];
|
6885
|
-
const label2 = (_d = componentConfig == null ? void 0 : componentConfig["label"]) != null ? _d : item.type.toString();
|
6886
|
-
return /* @__PURE__ */ jsxs16(
|
6887
|
-
"li",
|
7275
|
+
contentIds.length === 0 && /* @__PURE__ */ jsx34("div", { className: getClassName24("helper"), children: "No items" }),
|
7276
|
+
contentIds.map((itemId, i) => {
|
7277
|
+
return /* @__PURE__ */ jsx34(
|
7278
|
+
Layer,
|
6888
7279
|
{
|
6889
|
-
|
6890
|
-
|
6891
|
-
|
6892
|
-
containsZone,
|
6893
|
-
childIsSelected
|
6894
|
-
}),
|
6895
|
-
children: [
|
6896
|
-
/* @__PURE__ */ jsx33("div", { className: getClassNameLayer("inner"), children: /* @__PURE__ */ jsxs16(
|
6897
|
-
"button",
|
6898
|
-
{
|
6899
|
-
type: "button",
|
6900
|
-
className: getClassNameLayer("clickable"),
|
6901
|
-
onClick: () => {
|
6902
|
-
if (isSelected) {
|
6903
|
-
setItemSelector(null);
|
6904
|
-
return;
|
6905
|
-
}
|
6906
|
-
const id = zoneContent[i].props.id;
|
6907
|
-
const frame = getFrame();
|
6908
|
-
const el = frame == null ? void 0 : frame.querySelector(
|
6909
|
-
`[data-puck-component="${id}"]`
|
6910
|
-
);
|
6911
|
-
if (!el) {
|
6912
|
-
console.error(
|
6913
|
-
"Scroll failed. No element was found for",
|
6914
|
-
id
|
6915
|
-
);
|
6916
|
-
return;
|
6917
|
-
}
|
6918
|
-
scrollIntoView(el);
|
6919
|
-
onScrollEnd(frame, () => {
|
6920
|
-
setItemSelector({
|
6921
|
-
index: i,
|
6922
|
-
zone
|
6923
|
-
});
|
6924
|
-
});
|
6925
|
-
},
|
6926
|
-
onMouseOver: (e) => {
|
6927
|
-
e.stopPropagation();
|
6928
|
-
setHoveringComponent(item.props.id);
|
6929
|
-
},
|
6930
|
-
onMouseOut: (e) => {
|
6931
|
-
e.stopPropagation();
|
6932
|
-
setHoveringComponent(null);
|
6933
|
-
},
|
6934
|
-
children: [
|
6935
|
-
containsZone && /* @__PURE__ */ jsx33(
|
6936
|
-
"div",
|
6937
|
-
{
|
6938
|
-
className: getClassNameLayer("chevron"),
|
6939
|
-
title: isSelected ? "Collapse" : "Expand",
|
6940
|
-
children: /* @__PURE__ */ jsx33(ChevronDown, { size: "12" })
|
6941
|
-
}
|
6942
|
-
),
|
6943
|
-
/* @__PURE__ */ jsxs16("div", { className: getClassNameLayer("title"), children: [
|
6944
|
-
/* @__PURE__ */ jsx33("div", { className: getClassNameLayer("icon"), children: item.type === "Text" || item.type === "Heading" ? /* @__PURE__ */ jsx33(Type, { size: "16" }) : /* @__PURE__ */ jsx33(LayoutGrid, { size: "16" }) }),
|
6945
|
-
/* @__PURE__ */ jsx33("div", { className: getClassNameLayer("name"), children: label2 })
|
6946
|
-
] })
|
6947
|
-
]
|
6948
|
-
}
|
6949
|
-
) }),
|
6950
|
-
containsZone && Object.keys(zonesForItem).map((zoneKey, idx) => /* @__PURE__ */ jsx33("div", { className: getClassNameLayer("zones"), children: /* @__PURE__ */ jsx33(
|
6951
|
-
LayerTree,
|
6952
|
-
{
|
6953
|
-
config,
|
6954
|
-
data,
|
6955
|
-
zoneContent: zones[zoneKey],
|
6956
|
-
setItemSelector,
|
6957
|
-
itemSelector,
|
6958
|
-
zone: zoneKey,
|
6959
|
-
label: getZoneId(zoneKey)[1]
|
6960
|
-
}
|
6961
|
-
) }, idx))
|
6962
|
-
]
|
7280
|
+
index: i,
|
7281
|
+
itemId,
|
7282
|
+
zoneCompound
|
6963
7283
|
},
|
6964
|
-
|
7284
|
+
itemId
|
6965
7285
|
);
|
6966
7286
|
})
|
6967
7287
|
] })
|
@@ -6969,56 +7289,33 @@ var LayerTree = ({
|
|
6969
7289
|
};
|
6970
7290
|
|
6971
7291
|
// components/Puck/components/Outline/index.tsx
|
6972
|
-
import {
|
6973
|
-
|
7292
|
+
import { useMemo as useMemo16 } from "react";
|
7293
|
+
|
7294
|
+
// lib/data/find-zones-for-area.ts
|
7295
|
+
init_react_import();
|
7296
|
+
var findZonesForArea = (state, area) => {
|
7297
|
+
return Object.keys(state.indexes.zones).filter(
|
7298
|
+
(zone) => zone.split(":")[0] === area
|
7299
|
+
);
|
7300
|
+
};
|
7301
|
+
|
7302
|
+
// components/Puck/components/Outline/index.tsx
|
7303
|
+
import { useShallow as useShallow6 } from "zustand/react/shallow";
|
7304
|
+
import { jsx as jsx35 } from "react/jsx-runtime";
|
6974
7305
|
var Outline = () => {
|
6975
|
-
const state = useAppStore((s) => s.state);
|
6976
|
-
const config = useAppStore((s) => s.config);
|
6977
7306
|
const outlineOverride = useAppStore((s) => s.overrides.outline);
|
6978
|
-
const
|
6979
|
-
|
6980
|
-
const appStore = useAppStoreApi();
|
6981
|
-
const setItemSelector = useCallback13(
|
6982
|
-
(newItemSelector) => {
|
6983
|
-
const { dispatch } = appStore.getState();
|
6984
|
-
dispatch({
|
6985
|
-
type: "setUi",
|
6986
|
-
ui: { itemSelector: newItemSelector }
|
6987
|
-
});
|
6988
|
-
},
|
6989
|
-
[appStore]
|
7307
|
+
const rootZones = useAppStore(
|
7308
|
+
useShallow6((s) => findZonesForArea(s.state, "root"))
|
6990
7309
|
);
|
6991
|
-
const Wrapper =
|
6992
|
-
return /* @__PURE__ */
|
6993
|
-
|
6994
|
-
|
6995
|
-
|
6996
|
-
|
6997
|
-
|
6998
|
-
|
6999
|
-
|
7000
|
-
setItemSelector,
|
7001
|
-
itemSelector
|
7002
|
-
}
|
7003
|
-
),
|
7004
|
-
Object.entries(findZonesForArea(data, "root")).map(
|
7005
|
-
([zoneKey, zone]) => {
|
7006
|
-
return /* @__PURE__ */ jsx34(
|
7007
|
-
LayerTree,
|
7008
|
-
{
|
7009
|
-
config,
|
7010
|
-
data,
|
7011
|
-
label: zoneKey,
|
7012
|
-
zone: zoneKey,
|
7013
|
-
zoneContent: zone,
|
7014
|
-
setItemSelector,
|
7015
|
-
itemSelector
|
7016
|
-
},
|
7017
|
-
zoneKey
|
7018
|
-
);
|
7019
|
-
}
|
7020
|
-
)
|
7021
|
-
] }) }) });
|
7310
|
+
const Wrapper = useMemo16(() => outlineOverride || "div", [outlineOverride]);
|
7311
|
+
return /* @__PURE__ */ jsx35(Wrapper, { children: rootZones.map((zoneCompound) => /* @__PURE__ */ jsx35(
|
7312
|
+
LayerTree,
|
7313
|
+
{
|
7314
|
+
label: rootZones.length === 1 ? "" : zoneCompound.split(":")[1],
|
7315
|
+
zoneCompound
|
7316
|
+
},
|
7317
|
+
zoneCompound
|
7318
|
+
)) });
|
7022
7319
|
};
|
7023
7320
|
|
7024
7321
|
// components/Puck/components/Canvas/index.tsx
|
@@ -7146,26 +7443,26 @@ var getBox = function getBox2(el) {
|
|
7146
7443
|
// components/Puck/components/Canvas/index.tsx
|
7147
7444
|
import {
|
7148
7445
|
useCallback as useCallback14,
|
7149
|
-
useEffect as
|
7150
|
-
useMemo as
|
7446
|
+
useEffect as useEffect21,
|
7447
|
+
useMemo as useMemo18,
|
7151
7448
|
useRef as useRef6,
|
7152
7449
|
useState as useState19
|
7153
7450
|
} from "react";
|
7154
7451
|
|
7155
7452
|
// components/ViewportControls/index.tsx
|
7156
7453
|
init_react_import();
|
7157
|
-
import { useEffect as
|
7454
|
+
import { useEffect as useEffect20, useMemo as useMemo17, useState as useState18 } from "react";
|
7158
7455
|
|
7159
7456
|
// css-module:/home/runner/work/puck/puck/packages/core/components/ViewportControls/styles.module.css#css-module
|
7160
7457
|
init_react_import();
|
7161
7458
|
var styles_module_default20 = { "ViewportControls": "_ViewportControls_gejzr_1", "ViewportControls-divider": "_ViewportControls-divider_gejzr_15", "ViewportControls-zoomSelect": "_ViewportControls-zoomSelect_gejzr_21", "ViewportButton--isActive": "_ViewportButton--isActive_gejzr_38", "ViewportButton-inner": "_ViewportButton-inner_gejzr_38" };
|
7162
7459
|
|
7163
7460
|
// components/ViewportControls/index.tsx
|
7164
|
-
import { jsx as
|
7461
|
+
import { jsx as jsx36, jsxs as jsxs17 } from "react/jsx-runtime";
|
7165
7462
|
var icons = {
|
7166
|
-
Smartphone: /* @__PURE__ */
|
7167
|
-
Tablet: /* @__PURE__ */
|
7168
|
-
Monitor: /* @__PURE__ */
|
7463
|
+
Smartphone: /* @__PURE__ */ jsx36(Smartphone, { size: 16 }),
|
7464
|
+
Tablet: /* @__PURE__ */ jsx36(Tablet, { size: 16 }),
|
7465
|
+
Monitor: /* @__PURE__ */ jsx36(Monitor, { size: 16 })
|
7169
7466
|
};
|
7170
7467
|
var getClassName25 = get_class_name_factory_default("ViewportControls", styles_module_default20);
|
7171
7468
|
var getClassNameButton = get_class_name_factory_default("ViewportButton", styles_module_default20);
|
@@ -7178,10 +7475,10 @@ var ViewportButton = ({
|
|
7178
7475
|
}) => {
|
7179
7476
|
const viewports = useAppStore((s) => s.state.ui.viewports);
|
7180
7477
|
const [isActive, setIsActive] = useState18(false);
|
7181
|
-
|
7478
|
+
useEffect20(() => {
|
7182
7479
|
setIsActive(width === viewports.current.width);
|
7183
7480
|
}, [width, viewports.current.width]);
|
7184
|
-
return /* @__PURE__ */
|
7481
|
+
return /* @__PURE__ */ jsx36("span", { className: getClassNameButton({ isActive }), children: /* @__PURE__ */ jsx36(
|
7185
7482
|
IconButton,
|
7186
7483
|
{
|
7187
7484
|
title,
|
@@ -7190,7 +7487,7 @@ var ViewportButton = ({
|
|
7190
7487
|
e.stopPropagation();
|
7191
7488
|
onClick({ width, height });
|
7192
7489
|
},
|
7193
|
-
children: /* @__PURE__ */
|
7490
|
+
children: /* @__PURE__ */ jsx36("span", { className: getClassNameButton("inner"), children })
|
7194
7491
|
}
|
7195
7492
|
) });
|
7196
7493
|
};
|
@@ -7214,7 +7511,7 @@ var ViewportControls = ({
|
|
7214
7511
|
const defaultsContainAutoZoom = defaultZoomOptions.find(
|
7215
7512
|
(option) => option.value === autoZoom
|
7216
7513
|
);
|
7217
|
-
const zoomOptions =
|
7514
|
+
const zoomOptions = useMemo17(
|
7218
7515
|
() => [
|
7219
7516
|
...defaultZoomOptions,
|
7220
7517
|
...defaultsContainAutoZoom ? [] : [
|
@@ -7226,8 +7523,8 @@ var ViewportControls = ({
|
|
7226
7523
|
].filter((a) => a.value <= autoZoom).sort((a, b) => a.value > b.value ? 1 : -1),
|
7227
7524
|
[autoZoom]
|
7228
7525
|
);
|
7229
|
-
return /* @__PURE__ */
|
7230
|
-
viewports.map((viewport, i) => /* @__PURE__ */
|
7526
|
+
return /* @__PURE__ */ jsxs17("div", { className: getClassName25(), children: [
|
7527
|
+
viewports.map((viewport, i) => /* @__PURE__ */ jsx36(
|
7231
7528
|
ViewportButton,
|
7232
7529
|
{
|
7233
7530
|
height: viewport.height,
|
@@ -7238,8 +7535,8 @@ var ViewportControls = ({
|
|
7238
7535
|
},
|
7239
7536
|
i
|
7240
7537
|
)),
|
7241
|
-
/* @__PURE__ */
|
7242
|
-
/* @__PURE__ */
|
7538
|
+
/* @__PURE__ */ jsx36("div", { className: getClassName25("divider") }),
|
7539
|
+
/* @__PURE__ */ jsx36(
|
7243
7540
|
IconButton,
|
7244
7541
|
{
|
7245
7542
|
title: "Zoom viewport out",
|
@@ -7253,10 +7550,10 @@ var ViewportControls = ({
|
|
7253
7550
|
)].value
|
7254
7551
|
);
|
7255
7552
|
},
|
7256
|
-
children: /* @__PURE__ */
|
7553
|
+
children: /* @__PURE__ */ jsx36(ZoomOut, { size: 16 })
|
7257
7554
|
}
|
7258
7555
|
),
|
7259
|
-
/* @__PURE__ */
|
7556
|
+
/* @__PURE__ */ jsx36(
|
7260
7557
|
IconButton,
|
7261
7558
|
{
|
7262
7559
|
title: "Zoom viewport in",
|
@@ -7270,11 +7567,11 @@ var ViewportControls = ({
|
|
7270
7567
|
)].value
|
7271
7568
|
);
|
7272
7569
|
},
|
7273
|
-
children: /* @__PURE__ */
|
7570
|
+
children: /* @__PURE__ */ jsx36(ZoomIn, { size: 16 })
|
7274
7571
|
}
|
7275
7572
|
),
|
7276
|
-
/* @__PURE__ */
|
7277
|
-
/* @__PURE__ */
|
7573
|
+
/* @__PURE__ */ jsx36("div", { className: getClassName25("divider") }),
|
7574
|
+
/* @__PURE__ */ jsx36(
|
7278
7575
|
"select",
|
7279
7576
|
{
|
7280
7577
|
className: getClassName25("zoomSelect"),
|
@@ -7282,7 +7579,7 @@ var ViewportControls = ({
|
|
7282
7579
|
onChange: (e) => {
|
7283
7580
|
onZoom(parseFloat(e.currentTarget.value));
|
7284
7581
|
},
|
7285
|
-
children: zoomOptions.map((option) => /* @__PURE__ */
|
7582
|
+
children: zoomOptions.map((option) => /* @__PURE__ */ jsx36(
|
7286
7583
|
"option",
|
7287
7584
|
{
|
7288
7585
|
value: option.value,
|
@@ -7330,8 +7627,8 @@ var getZoomConfig = (uiViewport, frame, zoom) => {
|
|
7330
7627
|
};
|
7331
7628
|
|
7332
7629
|
// components/Puck/components/Canvas/index.tsx
|
7333
|
-
import { useShallow as
|
7334
|
-
import { Fragment as
|
7630
|
+
import { useShallow as useShallow7 } from "zustand/react/shallow";
|
7631
|
+
import { Fragment as Fragment12, jsx as jsx37, jsxs as jsxs18 } from "react/jsx-runtime";
|
7335
7632
|
var getClassName26 = get_class_name_factory_default("PuckCanvas", styles_module_default21);
|
7336
7633
|
var ZOOM_ON_CHANGE = true;
|
7337
7634
|
var Canvas = () => {
|
@@ -7344,7 +7641,7 @@ var Canvas = () => {
|
|
7344
7641
|
status,
|
7345
7642
|
iframe
|
7346
7643
|
} = useAppStore(
|
7347
|
-
|
7644
|
+
useShallow7((s) => ({
|
7348
7645
|
dispatch: s.dispatch,
|
7349
7646
|
overrides: s.overrides,
|
7350
7647
|
setUi: s.setUi,
|
@@ -7355,7 +7652,7 @@ var Canvas = () => {
|
|
7355
7652
|
}))
|
7356
7653
|
);
|
7357
7654
|
const { leftSideBarVisible, rightSideBarVisible, viewports } = useAppStore(
|
7358
|
-
|
7655
|
+
useShallow7((s) => ({
|
7359
7656
|
leftSideBarVisible: s.state.ui.leftSideBarVisible,
|
7360
7657
|
rightSideBarVisible: s.state.ui.rightSideBarVisible,
|
7361
7658
|
viewports: s.state.ui.viewports
|
@@ -7363,11 +7660,11 @@ var Canvas = () => {
|
|
7363
7660
|
);
|
7364
7661
|
const frameRef = useRef6(null);
|
7365
7662
|
const [showTransition, setShowTransition] = useState19(false);
|
7366
|
-
const defaultRender =
|
7367
|
-
const PuckDefault = ({ children }) => /* @__PURE__ */
|
7663
|
+
const defaultRender = useMemo18(() => {
|
7664
|
+
const PuckDefault = ({ children }) => /* @__PURE__ */ jsx37(Fragment12, { children });
|
7368
7665
|
return PuckDefault;
|
7369
7666
|
}, []);
|
7370
|
-
const CustomPreview =
|
7667
|
+
const CustomPreview = useMemo18(
|
7371
7668
|
() => overrides.preview || defaultRender,
|
7372
7669
|
[overrides]
|
7373
7670
|
);
|
@@ -7393,11 +7690,11 @@ var Canvas = () => {
|
|
7393
7690
|
},
|
7394
7691
|
[frameRef, zoomConfig, viewports]
|
7395
7692
|
);
|
7396
|
-
|
7693
|
+
useEffect21(() => {
|
7397
7694
|
setShowTransition(false);
|
7398
7695
|
resetAutoZoom(viewports);
|
7399
7696
|
}, [frameRef, leftSideBarVisible, rightSideBarVisible]);
|
7400
|
-
|
7697
|
+
useEffect21(() => {
|
7401
7698
|
const { height: frameHeight } = getFrameDimensions();
|
7402
7699
|
if (viewports.current.height === "auto") {
|
7403
7700
|
setZoomConfig(__spreadProps(__spreadValues({}, zoomConfig), {
|
@@ -7405,13 +7702,13 @@ var Canvas = () => {
|
|
7405
7702
|
}));
|
7406
7703
|
}
|
7407
7704
|
}, [zoomConfig.zoom]);
|
7408
|
-
|
7705
|
+
useEffect21(() => {
|
7409
7706
|
if (ZOOM_ON_CHANGE) {
|
7410
7707
|
setShowTransition(true);
|
7411
7708
|
resetAutoZoom(viewports);
|
7412
7709
|
}
|
7413
7710
|
}, [viewports.current.width]);
|
7414
|
-
|
7711
|
+
useEffect21(() => {
|
7415
7712
|
const cb = () => {
|
7416
7713
|
setShowTransition(false);
|
7417
7714
|
resetAutoZoom();
|
@@ -7422,12 +7719,12 @@ var Canvas = () => {
|
|
7422
7719
|
};
|
7423
7720
|
}, []);
|
7424
7721
|
const [showLoader, setShowLoader] = useState19(false);
|
7425
|
-
|
7722
|
+
useEffect21(() => {
|
7426
7723
|
setTimeout(() => {
|
7427
7724
|
setShowLoader(true);
|
7428
7725
|
}, 500);
|
7429
7726
|
}, []);
|
7430
|
-
return /* @__PURE__ */
|
7727
|
+
return /* @__PURE__ */ jsxs18(
|
7431
7728
|
"div",
|
7432
7729
|
{
|
7433
7730
|
className: getClassName26({
|
@@ -7440,7 +7737,7 @@ var Canvas = () => {
|
|
7440
7737
|
recordHistory: true
|
7441
7738
|
}),
|
7442
7739
|
children: [
|
7443
|
-
viewports.controlsVisible && iframe.enabled && /* @__PURE__ */
|
7740
|
+
viewports.controlsVisible && iframe.enabled && /* @__PURE__ */ jsx37("div", { className: getClassName26("controls"), children: /* @__PURE__ */ jsx37(
|
7444
7741
|
ViewportControls,
|
7445
7742
|
{
|
7446
7743
|
autoZoom: zoomConfig.autoZoom,
|
@@ -7466,8 +7763,8 @@ var Canvas = () => {
|
|
7466
7763
|
}
|
7467
7764
|
}
|
7468
7765
|
) }),
|
7469
|
-
/* @__PURE__ */
|
7470
|
-
/* @__PURE__ */
|
7766
|
+
/* @__PURE__ */ jsxs18("div", { className: getClassName26("inner"), ref: frameRef, children: [
|
7767
|
+
/* @__PURE__ */ jsx37(
|
7471
7768
|
"div",
|
7472
7769
|
{
|
7473
7770
|
className: getClassName26("root"),
|
@@ -7488,10 +7785,10 @@ var Canvas = () => {
|
|
7488
7785
|
})
|
7489
7786
|
);
|
7490
7787
|
},
|
7491
|
-
children: /* @__PURE__ */
|
7788
|
+
children: /* @__PURE__ */ jsx37(CustomPreview, { children: /* @__PURE__ */ jsx37(Preview3, {}) })
|
7492
7789
|
}
|
7493
7790
|
),
|
7494
|
-
/* @__PURE__ */
|
7791
|
+
/* @__PURE__ */ jsx37("div", { className: getClassName26("loader"), children: /* @__PURE__ */ jsx37(Loader, { size: 24 }) })
|
7495
7792
|
] })
|
7496
7793
|
]
|
7497
7794
|
}
|
@@ -7500,7 +7797,7 @@ var Canvas = () => {
|
|
7500
7797
|
|
7501
7798
|
// lib/use-loaded-overrides.ts
|
7502
7799
|
init_react_import();
|
7503
|
-
import { useMemo as
|
7800
|
+
import { useMemo as useMemo19 } from "react";
|
7504
7801
|
|
7505
7802
|
// lib/load-overrides.ts
|
7506
7803
|
init_react_import();
|
@@ -7539,26 +7836,26 @@ var useLoadedOverrides = ({
|
|
7539
7836
|
overrides,
|
7540
7837
|
plugins
|
7541
7838
|
}) => {
|
7542
|
-
return
|
7839
|
+
return useMemo19(() => {
|
7543
7840
|
return loadOverrides({ overrides, plugins });
|
7544
7841
|
}, [plugins, overrides]);
|
7545
7842
|
};
|
7546
7843
|
|
7547
7844
|
// components/DefaultOverride/index.tsx
|
7548
7845
|
init_react_import();
|
7549
|
-
import { Fragment as
|
7550
|
-
var DefaultOverride = ({ children }) => /* @__PURE__ */
|
7846
|
+
import { Fragment as Fragment13, jsx as jsx38 } from "react/jsx-runtime";
|
7847
|
+
var DefaultOverride = ({ children }) => /* @__PURE__ */ jsx38(Fragment13, { children });
|
7551
7848
|
|
7552
7849
|
// lib/use-inject-css.ts
|
7553
7850
|
init_react_import();
|
7554
|
-
import { useEffect as
|
7851
|
+
import { useEffect as useEffect22, useState as useState20 } from "react";
|
7555
7852
|
var styles = ``;
|
7556
7853
|
var useInjectStyleSheet = (initialStyles, iframeEnabled) => {
|
7557
7854
|
const [el, setEl] = useState20();
|
7558
|
-
|
7855
|
+
useEffect22(() => {
|
7559
7856
|
setEl(document.createElement("style"));
|
7560
7857
|
}, []);
|
7561
|
-
|
7858
|
+
useEffect22(() => {
|
7562
7859
|
var _a;
|
7563
7860
|
if (!el || typeof window === "undefined") {
|
7564
7861
|
return;
|
@@ -7596,7 +7893,7 @@ var usePreviewModeHotkeys = () => {
|
|
7596
7893
|
|
7597
7894
|
// lib/use-puck.ts
|
7598
7895
|
init_react_import();
|
7599
|
-
import { createContext as createContext6, useContext as useContext10, useEffect as
|
7896
|
+
import { createContext as createContext6, useContext as useContext10, useEffect as useEffect23, useState as useState21 } from "react";
|
7600
7897
|
import { createStore as createStore4, useStore as useStore3 } from "zustand";
|
7601
7898
|
var generateUsePuck = (store) => {
|
7602
7899
|
const history = {
|
@@ -7610,13 +7907,22 @@ var generateUsePuck = (store) => {
|
|
7610
7907
|
index: store.history.index
|
7611
7908
|
};
|
7612
7909
|
const storeData = {
|
7613
|
-
appState: store.state,
|
7910
|
+
appState: makeStatePublic(store.state),
|
7614
7911
|
config: store.config,
|
7615
7912
|
dispatch: store.dispatch,
|
7616
7913
|
getPermissions: store.permissions.getPermissions,
|
7617
7914
|
refreshPermissions: store.permissions.refreshPermissions,
|
7618
7915
|
history,
|
7619
|
-
selectedItem: store.selectedItem || null
|
7916
|
+
selectedItem: store.selectedItem || null,
|
7917
|
+
getItemBySelector: (selector) => getItem(selector, store.state),
|
7918
|
+
getItemById: (id) => store.state.indexes.nodes[id].data,
|
7919
|
+
getSelectorForId: (id) => {
|
7920
|
+
const node = store.state.indexes.nodes[id];
|
7921
|
+
if (!node) return;
|
7922
|
+
const zoneCompound = `${node.parentId}:${node.zone}`;
|
7923
|
+
const index = store.state.indexes.zones[zoneCompound].contentIds.indexOf(id);
|
7924
|
+
return { zone: zoneCompound, index };
|
7925
|
+
}
|
7620
7926
|
};
|
7621
7927
|
const get = () => storeData;
|
7622
7928
|
return __spreadProps(__spreadValues({}, storeData), { get });
|
@@ -7624,23 +7930,25 @@ var generateUsePuck = (store) => {
|
|
7624
7930
|
var UsePuckStoreContext = createContext6(
|
7625
7931
|
null
|
7626
7932
|
);
|
7933
|
+
var convertToPickedStore = (store) => {
|
7934
|
+
return {
|
7935
|
+
state: store.state,
|
7936
|
+
config: store.config,
|
7937
|
+
dispatch: store.dispatch,
|
7938
|
+
permissions: store.permissions,
|
7939
|
+
history: store.history,
|
7940
|
+
selectedItem: store.selectedItem
|
7941
|
+
};
|
7942
|
+
};
|
7627
7943
|
var useRegisterUsePuckStore = (appStore) => {
|
7628
7944
|
const [usePuckStore] = useState21(
|
7629
|
-
() => createStore4(
|
7945
|
+
() => createStore4(
|
7946
|
+
() => generateUsePuck(convertToPickedStore(appStore.getState()))
|
7947
|
+
)
|
7630
7948
|
);
|
7631
|
-
|
7949
|
+
useEffect23(() => {
|
7632
7950
|
return appStore.subscribe(
|
7633
|
-
(store) =>
|
7634
|
-
const pickedStore = {
|
7635
|
-
state: store.state,
|
7636
|
-
config: store.config,
|
7637
|
-
dispatch: store.dispatch,
|
7638
|
-
permissions: store.permissions,
|
7639
|
-
history: store.history,
|
7640
|
-
selectedItem: store.selectedItem
|
7641
|
-
};
|
7642
|
-
return pickedStore;
|
7643
|
-
},
|
7951
|
+
(store) => convertToPickedStore(store),
|
7644
7952
|
(pickedStore) => {
|
7645
7953
|
usePuckStore.setState(generateUsePuck(pickedStore));
|
7646
7954
|
}
|
@@ -7662,7 +7970,7 @@ function createUsePuck() {
|
|
7662
7970
|
};
|
7663
7971
|
}
|
7664
7972
|
function usePuck() {
|
7665
|
-
|
7973
|
+
useEffect23(() => {
|
7666
7974
|
console.warn(
|
7667
7975
|
"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."
|
7668
7976
|
);
|
@@ -7671,7 +7979,8 @@ function usePuck() {
|
|
7671
7979
|
}
|
7672
7980
|
|
7673
7981
|
// components/Puck/index.tsx
|
7674
|
-
import
|
7982
|
+
import fdeq from "fast-deep-equal";
|
7983
|
+
import { Fragment as Fragment14, jsx as jsx39, jsxs as jsxs19 } from "react/jsx-runtime";
|
7675
7984
|
var getClassName27 = get_class_name_factory_default("Puck", styles_module_default15);
|
7676
7985
|
var getLayoutClassName = get_class_name_factory_default("PuckLayout", styles_module_default15);
|
7677
7986
|
var FieldSideBar = () => {
|
@@ -7681,11 +7990,11 @@ var FieldSideBar = () => {
|
|
7681
7990
|
return s.selectedItem ? (_b = (_a = s.config.components[s.selectedItem.type]) == null ? void 0 : _a["label"]) != null ? _b : s.selectedItem.type.toString() : "Page";
|
7682
7991
|
}
|
7683
7992
|
);
|
7684
|
-
return /* @__PURE__ */
|
7993
|
+
return /* @__PURE__ */ jsx39(SidebarSection, { noPadding: true, noBorderTop: true, showBreadcrumbs: true, title, children: /* @__PURE__ */ jsx39(Fields, {}) });
|
7685
7994
|
};
|
7686
7995
|
var propsContext = createContext7({});
|
7687
7996
|
function PropsProvider(props) {
|
7688
|
-
return /* @__PURE__ */
|
7997
|
+
return /* @__PURE__ */ jsx39(propsContext.Provider, { value: props, children: props.children });
|
7689
7998
|
}
|
7690
7999
|
var usePropsContext = () => useContext11(propsContext);
|
7691
8000
|
function PuckProvider({ children }) {
|
@@ -7742,7 +8051,7 @@ function PuckProvider({ children }) {
|
|
7742
8051
|
}
|
7743
8052
|
const rootProps = ((_h = initialData == null ? void 0 : initialData.root) == null ? void 0 : _h.props) || (initialData == null ? void 0 : initialData.root) || {};
|
7744
8053
|
const defaultedRootProps = __spreadValues(__spreadValues({}, (_i = config.root) == null ? void 0 : _i.defaultProps), rootProps);
|
7745
|
-
|
8054
|
+
const newAppState = __spreadProps(__spreadValues({}, defaultAppState), {
|
7746
8055
|
data: __spreadProps(__spreadValues({}, initialData), {
|
7747
8056
|
root: __spreadProps(__spreadValues({}, initialData == null ? void 0 : initialData.root), { props: defaultedRootProps }),
|
7748
8057
|
content: initialData.content || []
|
@@ -7764,77 +8073,88 @@ function PuckProvider({ children }) {
|
|
7764
8073
|
) : {}
|
7765
8074
|
})
|
7766
8075
|
});
|
8076
|
+
return walkAppState(newAppState, config);
|
7767
8077
|
});
|
7768
8078
|
const { appendData = true } = _initialHistory || {};
|
7769
|
-
const blendedHistories =
|
7770
|
-
|
7771
|
-
|
7772
|
-
|
7773
|
-
|
7774
|
-
|
7775
|
-
|
8079
|
+
const [blendedHistories] = useState22(
|
8080
|
+
[
|
8081
|
+
...(_initialHistory == null ? void 0 : _initialHistory.histories) || [],
|
8082
|
+
...appendData ? [{ state: generatedAppState }] : []
|
8083
|
+
].map((history) => {
|
8084
|
+
let newState = __spreadValues(__spreadValues({}, generatedAppState), history.state);
|
8085
|
+
if (!history.state.indexes) {
|
8086
|
+
newState = walkAppState(newState, config);
|
8087
|
+
}
|
8088
|
+
return __spreadProps(__spreadValues({}, history), {
|
8089
|
+
state: newState
|
8090
|
+
});
|
8091
|
+
})
|
8092
|
+
);
|
7776
8093
|
const initialHistoryIndex = (_initialHistory == null ? void 0 : _initialHistory.index) || blendedHistories.length - 1;
|
7777
8094
|
const initialAppState = blendedHistories[initialHistoryIndex].state;
|
7778
8095
|
const loadedOverrides = useLoadedOverrides({
|
7779
8096
|
overrides,
|
7780
8097
|
plugins
|
7781
8098
|
});
|
7782
|
-
const generateAppStore = useCallback16(
|
7783
|
-
|
7784
|
-
|
8099
|
+
const generateAppStore = useCallback16(
|
8100
|
+
(state) => {
|
8101
|
+
return {
|
8102
|
+
state,
|
8103
|
+
config,
|
8104
|
+
plugins: plugins || [],
|
8105
|
+
overrides: loadedOverrides,
|
8106
|
+
viewports,
|
8107
|
+
iframe,
|
8108
|
+
onAction,
|
8109
|
+
metadata
|
8110
|
+
};
|
8111
|
+
},
|
8112
|
+
[
|
8113
|
+
initialAppState,
|
7785
8114
|
config,
|
7786
|
-
plugins
|
7787
|
-
|
8115
|
+
plugins,
|
8116
|
+
loadedOverrides,
|
7788
8117
|
viewports,
|
7789
8118
|
iframe,
|
7790
8119
|
onAction,
|
7791
8120
|
metadata
|
7792
|
-
|
7793
|
-
|
7794
|
-
|
7795
|
-
|
7796
|
-
|
7797
|
-
|
7798
|
-
|
7799
|
-
|
7800
|
-
|
7801
|
-
metadata
|
7802
|
-
]);
|
7803
|
-
const [appStore] = useState22(() => createAppStore(generateAppStore()));
|
7804
|
-
useEffect25(() => {
|
7805
|
-
appStore.setState(__spreadValues({}, generateAppStore()));
|
7806
|
-
}, [
|
7807
|
-
initialAppState,
|
7808
|
-
config,
|
7809
|
-
plugins,
|
7810
|
-
loadedOverrides,
|
7811
|
-
viewports,
|
7812
|
-
iframe,
|
7813
|
-
onAction,
|
7814
|
-
metadata
|
7815
|
-
]);
|
8121
|
+
]
|
8122
|
+
);
|
8123
|
+
const [appStore] = useState22(
|
8124
|
+
() => createAppStore(generateAppStore(initialAppState))
|
8125
|
+
);
|
8126
|
+
useEffect24(() => {
|
8127
|
+
const state = appStore.getState().state;
|
8128
|
+
appStore.setState(__spreadValues({}, generateAppStore(state)));
|
8129
|
+
}, [config, plugins, loadedOverrides, viewports, iframe, onAction, metadata]);
|
7816
8130
|
useRegisterHistorySlice(appStore, {
|
7817
8131
|
histories: blendedHistories,
|
7818
8132
|
index: initialHistoryIndex,
|
7819
8133
|
initialAppState
|
7820
8134
|
});
|
7821
|
-
|
7822
|
-
|
7823
|
-
|
7824
|
-
|
8135
|
+
const previousData = useRef7(null);
|
8136
|
+
useEffect24(() => {
|
8137
|
+
appStore.subscribe(
|
8138
|
+
(s) => s.state.data,
|
8139
|
+
(data) => {
|
8140
|
+
if (onChange) {
|
8141
|
+
if (fdeq(data, previousData.current)) return;
|
8142
|
+
onChange(data);
|
8143
|
+
previousData.current = data;
|
8144
|
+
}
|
8145
|
+
}
|
8146
|
+
);
|
7825
8147
|
}, []);
|
7826
|
-
useRegisterNodesSlice(appStore);
|
7827
8148
|
useRegisterPermissionsSlice(appStore, permissions);
|
7828
8149
|
const uPuckStore = useRegisterUsePuckStore(appStore);
|
7829
|
-
|
7830
|
-
const {
|
7831
|
-
|
8150
|
+
useEffect24(() => {
|
8151
|
+
const { resolveAndCommitData } = appStore.getState();
|
8152
|
+
resolveAndCommitData();
|
7832
8153
|
}, []);
|
7833
|
-
return /* @__PURE__ */
|
8154
|
+
return /* @__PURE__ */ jsx39(appStoreContext.Provider, { value: appStore, children: /* @__PURE__ */ jsx39(UsePuckStoreContext.Provider, { value: uPuckStore, children }) });
|
7834
8155
|
}
|
7835
8156
|
function PuckLayout({ children }) {
|
7836
8157
|
const {
|
7837
|
-
onChange,
|
7838
8158
|
onPublish,
|
7839
8159
|
renderHeader,
|
7840
8160
|
renderHeaderActions,
|
@@ -7855,11 +8175,6 @@ function PuckLayout({ children }) {
|
|
7855
8175
|
);
|
7856
8176
|
const [menuOpen, setMenuOpen] = useState22(false);
|
7857
8177
|
const appStore = useAppStoreApi();
|
7858
|
-
useEffect25(() => {
|
7859
|
-
return appStore.subscribe((s) => {
|
7860
|
-
if (onChange) onChange(s.state.data);
|
7861
|
-
});
|
7862
|
-
}, [appStore]);
|
7863
8178
|
const rootProps = useAppStore(
|
7864
8179
|
(s) => s.state.data.root.props || s.state.data.root.props
|
7865
8180
|
);
|
@@ -7878,7 +8193,7 @@ function PuckLayout({ children }) {
|
|
7878
8193
|
},
|
7879
8194
|
[dispatch, leftSideBarVisible, rightSideBarVisible]
|
7880
8195
|
);
|
7881
|
-
|
8196
|
+
useEffect24(() => {
|
7882
8197
|
if (!window.matchMedia("(min-width: 638px)").matches) {
|
7883
8198
|
dispatch({
|
7884
8199
|
type: "setUi",
|
@@ -7901,7 +8216,7 @@ function PuckLayout({ children }) {
|
|
7901
8216
|
window.removeEventListener("resize", handleResize);
|
7902
8217
|
};
|
7903
8218
|
}, []);
|
7904
|
-
const defaultHeaderRender =
|
8219
|
+
const defaultHeaderRender = useMemo20(() => {
|
7905
8220
|
if (renderHeader) {
|
7906
8221
|
console.warn(
|
7907
8222
|
"`renderHeader` is deprecated. Please use `overrides.header` and the `usePuck` hook instead"
|
@@ -7910,13 +8225,13 @@ function PuckLayout({ children }) {
|
|
7910
8225
|
var _b = _a, { actions } = _b, props = __objRest(_b, ["actions"]);
|
7911
8226
|
const Comp = renderHeader;
|
7912
8227
|
const appState = useAppStore((s) => s.state);
|
7913
|
-
return /* @__PURE__ */
|
8228
|
+
return /* @__PURE__ */ jsx39(Comp, __spreadProps(__spreadValues({}, props), { dispatch, state: appState, children: actions }));
|
7914
8229
|
};
|
7915
8230
|
return RenderHeader;
|
7916
8231
|
}
|
7917
8232
|
return DefaultOverride;
|
7918
8233
|
}, [renderHeader]);
|
7919
|
-
const defaultHeaderActionsRender =
|
8234
|
+
const defaultHeaderActionsRender = useMemo20(() => {
|
7920
8235
|
if (renderHeaderActions) {
|
7921
8236
|
console.warn(
|
7922
8237
|
"`renderHeaderActions` is deprecated. Please use `overrides.headerActions` and the `usePuck` hook instead."
|
@@ -7924,32 +8239,32 @@ function PuckLayout({ children }) {
|
|
7924
8239
|
const RenderHeader = (props) => {
|
7925
8240
|
const Comp = renderHeaderActions;
|
7926
8241
|
const appState = useAppStore((s) => s.state);
|
7927
|
-
return /* @__PURE__ */
|
8242
|
+
return /* @__PURE__ */ jsx39(Comp, __spreadProps(__spreadValues({}, props), { dispatch, state: appState }));
|
7928
8243
|
};
|
7929
8244
|
return RenderHeader;
|
7930
8245
|
}
|
7931
8246
|
return DefaultOverride;
|
7932
8247
|
}, [renderHeader]);
|
7933
8248
|
const overrides = useAppStore((s) => s.overrides);
|
7934
|
-
const CustomPuck =
|
8249
|
+
const CustomPuck = useMemo20(
|
7935
8250
|
() => overrides.puck || DefaultOverride,
|
7936
8251
|
[overrides]
|
7937
8252
|
);
|
7938
|
-
const CustomHeader =
|
8253
|
+
const CustomHeader = useMemo20(
|
7939
8254
|
() => overrides.header || defaultHeaderRender,
|
7940
8255
|
[overrides]
|
7941
8256
|
);
|
7942
|
-
const CustomHeaderActions =
|
8257
|
+
const CustomHeaderActions = useMemo20(
|
7943
8258
|
() => overrides.headerActions || defaultHeaderActionsRender,
|
7944
8259
|
[overrides]
|
7945
8260
|
);
|
7946
8261
|
const [mounted, setMounted] = useState22(false);
|
7947
|
-
|
8262
|
+
useEffect24(() => {
|
7948
8263
|
setMounted(true);
|
7949
8264
|
}, []);
|
7950
8265
|
const ready = useAppStore((s) => s.status === "READY");
|
7951
8266
|
useMonitorHotkeys();
|
7952
|
-
|
8267
|
+
useEffect24(() => {
|
7953
8268
|
if (ready && iframe.enabled) {
|
7954
8269
|
const frameDoc = getFrame();
|
7955
8270
|
if (frameDoc) {
|
@@ -7958,8 +8273,8 @@ function PuckLayout({ children }) {
|
|
7958
8273
|
}
|
7959
8274
|
}, [ready, iframe.enabled]);
|
7960
8275
|
usePreviewModeHotkeys();
|
7961
|
-
return /* @__PURE__ */
|
7962
|
-
/* @__PURE__ */
|
8276
|
+
return /* @__PURE__ */ jsxs19("div", { className: `Puck ${getClassName27()}`, children: [
|
8277
|
+
/* @__PURE__ */ jsx39(DragDropContext, { disableAutoScroll: dnd == null ? void 0 : dnd.disableAutoScroll, children: /* @__PURE__ */ jsx39(CustomPuck, { children: children || /* @__PURE__ */ jsx39(
|
7963
8278
|
"div",
|
7964
8279
|
{
|
7965
8280
|
className: getLayoutClassName({
|
@@ -7968,61 +8283,61 @@ function PuckLayout({ children }) {
|
|
7968
8283
|
mounted,
|
7969
8284
|
rightSideBarVisible
|
7970
8285
|
}),
|
7971
|
-
children: /* @__PURE__ */
|
7972
|
-
/* @__PURE__ */
|
8286
|
+
children: /* @__PURE__ */ jsxs19("div", { className: getLayoutClassName("inner"), children: [
|
8287
|
+
/* @__PURE__ */ jsx39(
|
7973
8288
|
CustomHeader,
|
7974
8289
|
{
|
7975
|
-
actions: /* @__PURE__ */
|
8290
|
+
actions: /* @__PURE__ */ jsx39(Fragment14, { children: /* @__PURE__ */ jsx39(CustomHeaderActions, { children: /* @__PURE__ */ jsx39(
|
7976
8291
|
Button,
|
7977
8292
|
{
|
7978
8293
|
onClick: () => {
|
7979
8294
|
const data = appStore.getState().state.data;
|
7980
8295
|
onPublish && onPublish(data);
|
7981
8296
|
},
|
7982
|
-
icon: /* @__PURE__ */
|
8297
|
+
icon: /* @__PURE__ */ jsx39(Globe, { size: "14px" }),
|
7983
8298
|
children: "Publish"
|
7984
8299
|
}
|
7985
8300
|
) }) }),
|
7986
|
-
children: /* @__PURE__ */
|
7987
|
-
/* @__PURE__ */
|
7988
|
-
/* @__PURE__ */
|
8301
|
+
children: /* @__PURE__ */ jsx39("header", { className: getLayoutClassName("header"), children: /* @__PURE__ */ jsxs19("div", { className: getLayoutClassName("headerInner"), children: [
|
8302
|
+
/* @__PURE__ */ jsxs19("div", { className: getLayoutClassName("headerToggle"), children: [
|
8303
|
+
/* @__PURE__ */ jsx39(
|
7989
8304
|
"div",
|
7990
8305
|
{
|
7991
8306
|
className: getLayoutClassName("leftSideBarToggle"),
|
7992
|
-
children: /* @__PURE__ */
|
8307
|
+
children: /* @__PURE__ */ jsx39(
|
7993
8308
|
IconButton,
|
7994
8309
|
{
|
7995
8310
|
onClick: () => {
|
7996
8311
|
toggleSidebars("left");
|
7997
8312
|
},
|
7998
8313
|
title: "Toggle left sidebar",
|
7999
|
-
children: /* @__PURE__ */
|
8314
|
+
children: /* @__PURE__ */ jsx39(PanelLeft, { focusable: "false" })
|
8000
8315
|
}
|
8001
8316
|
)
|
8002
8317
|
}
|
8003
8318
|
),
|
8004
|
-
/* @__PURE__ */
|
8319
|
+
/* @__PURE__ */ jsx39(
|
8005
8320
|
"div",
|
8006
8321
|
{
|
8007
8322
|
className: getLayoutClassName("rightSideBarToggle"),
|
8008
|
-
children: /* @__PURE__ */
|
8323
|
+
children: /* @__PURE__ */ jsx39(
|
8009
8324
|
IconButton,
|
8010
8325
|
{
|
8011
8326
|
onClick: () => {
|
8012
8327
|
toggleSidebars("right");
|
8013
8328
|
},
|
8014
8329
|
title: "Toggle right sidebar",
|
8015
|
-
children: /* @__PURE__ */
|
8330
|
+
children: /* @__PURE__ */ jsx39(PanelRight, { focusable: "false" })
|
8016
8331
|
}
|
8017
8332
|
)
|
8018
8333
|
}
|
8019
8334
|
)
|
8020
8335
|
] }),
|
8021
|
-
/* @__PURE__ */
|
8336
|
+
/* @__PURE__ */ jsx39("div", { className: getLayoutClassName("headerTitle"), children: /* @__PURE__ */ jsxs19(Heading, { rank: "2", size: "xs", children: [
|
8022
8337
|
headerTitle || (rootProps == null ? void 0 : rootProps.title) || "Page",
|
8023
|
-
headerPath && /* @__PURE__ */
|
8338
|
+
headerPath && /* @__PURE__ */ jsxs19(Fragment14, { children: [
|
8024
8339
|
" ",
|
8025
|
-
/* @__PURE__ */
|
8340
|
+
/* @__PURE__ */ jsx39(
|
8026
8341
|
"code",
|
8027
8342
|
{
|
8028
8343
|
className: getLayoutClassName("headerPath"),
|
@@ -8031,31 +8346,31 @@ function PuckLayout({ children }) {
|
|
8031
8346
|
)
|
8032
8347
|
] })
|
8033
8348
|
] }) }),
|
8034
|
-
/* @__PURE__ */
|
8035
|
-
/* @__PURE__ */
|
8349
|
+
/* @__PURE__ */ jsxs19("div", { className: getLayoutClassName("headerTools"), children: [
|
8350
|
+
/* @__PURE__ */ jsx39("div", { className: getLayoutClassName("menuButton"), children: /* @__PURE__ */ jsx39(
|
8036
8351
|
IconButton,
|
8037
8352
|
{
|
8038
8353
|
onClick: () => {
|
8039
8354
|
return setMenuOpen(!menuOpen);
|
8040
8355
|
},
|
8041
8356
|
title: "Toggle menu bar",
|
8042
|
-
children: menuOpen ? /* @__PURE__ */
|
8357
|
+
children: menuOpen ? /* @__PURE__ */ jsx39(ChevronUp, { focusable: "false" }) : /* @__PURE__ */ jsx39(ChevronDown, { focusable: "false" })
|
8043
8358
|
}
|
8044
8359
|
) }),
|
8045
|
-
/* @__PURE__ */
|
8360
|
+
/* @__PURE__ */ jsx39(
|
8046
8361
|
MenuBar,
|
8047
8362
|
{
|
8048
8363
|
dispatch,
|
8049
8364
|
onPublish,
|
8050
8365
|
menuOpen,
|
8051
|
-
renderHeaderActions: () => /* @__PURE__ */
|
8366
|
+
renderHeaderActions: () => /* @__PURE__ */ jsx39(CustomHeaderActions, { children: /* @__PURE__ */ jsx39(
|
8052
8367
|
Button,
|
8053
8368
|
{
|
8054
8369
|
onClick: () => {
|
8055
8370
|
const data = appStore.getState().state.data;
|
8056
8371
|
onPublish && onPublish(data);
|
8057
8372
|
},
|
8058
|
-
icon: /* @__PURE__ */
|
8373
|
+
icon: /* @__PURE__ */ jsx39(Globe, { size: "14px" }),
|
8059
8374
|
children: "Publish"
|
8060
8375
|
}
|
8061
8376
|
) }),
|
@@ -8066,20 +8381,20 @@ function PuckLayout({ children }) {
|
|
8066
8381
|
] }) })
|
8067
8382
|
}
|
8068
8383
|
),
|
8069
|
-
/* @__PURE__ */
|
8070
|
-
/* @__PURE__ */
|
8071
|
-
/* @__PURE__ */
|
8384
|
+
/* @__PURE__ */ jsxs19("div", { className: getLayoutClassName("leftSideBar"), children: [
|
8385
|
+
/* @__PURE__ */ jsx39(SidebarSection, { title: "Components", noBorderTop: true, children: /* @__PURE__ */ jsx39(Components, {}) }),
|
8386
|
+
/* @__PURE__ */ jsx39(SidebarSection, { title: "Outline", children: /* @__PURE__ */ jsx39(Outline, {}) })
|
8072
8387
|
] }),
|
8073
|
-
/* @__PURE__ */
|
8074
|
-
/* @__PURE__ */
|
8388
|
+
/* @__PURE__ */ jsx39(Canvas, {}),
|
8389
|
+
/* @__PURE__ */ jsx39("div", { className: getLayoutClassName("rightSideBar"), children: /* @__PURE__ */ jsx39(FieldSideBar, {}) })
|
8075
8390
|
] })
|
8076
8391
|
}
|
8077
8392
|
) }) }),
|
8078
|
-
/* @__PURE__ */
|
8393
|
+
/* @__PURE__ */ jsx39("div", { id: "puck-portal-root", className: getClassName27("portal") })
|
8079
8394
|
] });
|
8080
8395
|
}
|
8081
8396
|
function Puck(props) {
|
8082
|
-
return /* @__PURE__ */
|
8397
|
+
return /* @__PURE__ */ jsx39(PropsProvider, __spreadProps(__spreadValues({}, props), { children: /* @__PURE__ */ jsx39(PuckProvider, __spreadProps(__spreadValues({}, props), { children: /* @__PURE__ */ jsx39(PuckLayout, __spreadValues({}, props)) })) }));
|
8083
8398
|
}
|
8084
8399
|
Puck.Components = Components;
|
8085
8400
|
Puck.Fields = Fields;
|
@@ -8103,10 +8418,67 @@ var migrations = [
|
|
8103
8418
|
});
|
8104
8419
|
}
|
8105
8420
|
return data;
|
8421
|
+
},
|
8422
|
+
// Migrate zones to slots
|
8423
|
+
(data, config) => {
|
8424
|
+
var _a;
|
8425
|
+
if (!config) return data;
|
8426
|
+
console.log("Migrating DropZones to slots...");
|
8427
|
+
const updatedItems = {};
|
8428
|
+
const appState = __spreadProps(__spreadValues({}, defaultAppState), { data });
|
8429
|
+
const { indexes } = walkAppState(appState, config);
|
8430
|
+
const deletedCompounds = [];
|
8431
|
+
walkAppState(appState, config, (content, zoneCompound, zoneType) => {
|
8432
|
+
var _a2, _b;
|
8433
|
+
if (zoneType === "dropzone") {
|
8434
|
+
const [id, slotName] = zoneCompound.split(":");
|
8435
|
+
const nodeData = indexes.nodes[id].data;
|
8436
|
+
const componentType = nodeData.type;
|
8437
|
+
const configForComponent = config.components[componentType];
|
8438
|
+
if (((_b = (_a2 = configForComponent == null ? void 0 : configForComponent.fields) == null ? void 0 : _a2[slotName]) == null ? void 0 : _b.type) === "slot") {
|
8439
|
+
updatedItems[id] = __spreadProps(__spreadValues({}, nodeData), {
|
8440
|
+
props: __spreadProps(__spreadValues({}, nodeData.props), {
|
8441
|
+
[slotName]: content
|
8442
|
+
})
|
8443
|
+
});
|
8444
|
+
deletedCompounds.push(zoneCompound);
|
8445
|
+
}
|
8446
|
+
return content;
|
8447
|
+
}
|
8448
|
+
return content;
|
8449
|
+
});
|
8450
|
+
const updated = walkAppState(
|
8451
|
+
appState,
|
8452
|
+
config,
|
8453
|
+
(content) => content,
|
8454
|
+
(item) => {
|
8455
|
+
var _a2;
|
8456
|
+
return (_a2 = updatedItems[item.props.id]) != null ? _a2 : item;
|
8457
|
+
}
|
8458
|
+
);
|
8459
|
+
deletedCompounds.forEach((zoneCompound) => {
|
8460
|
+
var _a2;
|
8461
|
+
const [_, propName] = zoneCompound.split(":");
|
8462
|
+
console.log(
|
8463
|
+
`\u2713 Success: Migrated "${zoneCompound}" from DropZone to slot field "${propName}"`
|
8464
|
+
);
|
8465
|
+
(_a2 = updated.data.zones) == null ? true : delete _a2[zoneCompound];
|
8466
|
+
});
|
8467
|
+
Object.keys((_a = updated.data.zones) != null ? _a : {}).forEach((zoneCompound) => {
|
8468
|
+
const [_, propName] = zoneCompound.split(":");
|
8469
|
+
throw new Error(
|
8470
|
+
`Could not migrate DropZone "${zoneCompound}" to slot field. No slot exists with the name "${propName}".`
|
8471
|
+
);
|
8472
|
+
});
|
8473
|
+
delete updated.data.zones;
|
8474
|
+
return updated.data;
|
8106
8475
|
}
|
8107
8476
|
];
|
8108
|
-
function migrate(data) {
|
8109
|
-
return migrations == null ? void 0 : migrations.reduce(
|
8477
|
+
function migrate(data, config) {
|
8478
|
+
return migrations == null ? void 0 : migrations.reduce(
|
8479
|
+
(acc, migration) => migration(acc, config),
|
8480
|
+
data
|
8481
|
+
);
|
8110
8482
|
}
|
8111
8483
|
export {
|
8112
8484
|
Action,
|
@@ -8127,7 +8499,8 @@ export {
|
|
8127
8499
|
renderContext,
|
8128
8500
|
resolveAllData,
|
8129
8501
|
transformProps,
|
8130
|
-
usePuck
|
8502
|
+
usePuck,
|
8503
|
+
walkTree
|
8131
8504
|
};
|
8132
8505
|
/*! Bundled license information:
|
8133
8506
|
|