@measured/puck 0.19.0-canary.a281c342 → 0.19.0-canary.a6dd529f
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 +1 -0
- package/dist/{chunk-6SCV2ENX.mjs → chunk-ZOHJNF5K.mjs} +812 -661
- package/dist/index.css +44 -38
- package/dist/index.d.mts +18 -8
- package/dist/index.d.ts +18 -8
- package/dist/index.js +912 -712
- package/dist/index.mjs +131 -77
- package/dist/{resolve-all-data-Cs8PfTrg.d.mts → resolve-all-data-BFRAghCj.d.mts} +5 -1
- package/dist/{resolve-all-data-Cs8PfTrg.d.ts → resolve-all-data-BFRAghCj.d.ts} +5 -1
- package/dist/rsc.css +12 -11
- package/dist/rsc.d.mts +2 -2
- package/dist/rsc.d.ts +2 -2
- package/dist/rsc.js +718 -582
- package/dist/rsc.mjs +1 -1
- package/package.json +1 -1
@@ -226,6 +226,68 @@ ActionBar.Action = Action;
|
|
226
226
|
ActionBar.Label = Label;
|
227
227
|
ActionBar.Group = Group;
|
228
228
|
|
229
|
+
// lib/data/map-slots.ts
|
230
|
+
init_react_import();
|
231
|
+
|
232
|
+
// lib/data/is-slot.ts
|
233
|
+
init_react_import();
|
234
|
+
var isSlot = (prop) => {
|
235
|
+
var _a, _b;
|
236
|
+
return Array.isArray(prop) && typeof ((_a = prop[0]) == null ? void 0 : _a.type) === "string" && typeof ((_b = prop[0]) == null ? void 0 : _b.props) === "object";
|
237
|
+
};
|
238
|
+
var createIsSlotConfig = (config) => (itemType, propName, propValue) => {
|
239
|
+
var _a, _b;
|
240
|
+
const configForComponent = itemType === "root" ? config == null ? void 0 : config.root : config == null ? void 0 : config.components[itemType];
|
241
|
+
if (!configForComponent) return isSlot(propValue);
|
242
|
+
return ((_b = (_a = configForComponent.fields) == null ? void 0 : _a[propName]) == null ? void 0 : _b.type) === "slot";
|
243
|
+
};
|
244
|
+
|
245
|
+
// lib/data/map-slots.ts
|
246
|
+
function mapSlotsAsync(_0, _1) {
|
247
|
+
return __async(this, arguments, function* (item, map, recursive = true, isSlot2 = isSlot) {
|
248
|
+
const props = __spreadValues({}, item.props);
|
249
|
+
const propKeys = Object.keys(props);
|
250
|
+
for (let i = 0; i < propKeys.length; i++) {
|
251
|
+
const propKey = propKeys[i];
|
252
|
+
const itemType = "type" in item ? item.type : "root";
|
253
|
+
if (isSlot2(itemType, propKey, props[propKey])) {
|
254
|
+
const content = props[propKey];
|
255
|
+
const mappedContent = recursive ? yield Promise.all(
|
256
|
+
content.map((item2) => __async(this, null, function* () {
|
257
|
+
return yield mapSlotsAsync(item2, map, recursive, isSlot2);
|
258
|
+
}))
|
259
|
+
) : content;
|
260
|
+
props[propKey] = yield map(mappedContent, propKey);
|
261
|
+
}
|
262
|
+
}
|
263
|
+
return __spreadProps(__spreadValues({}, item), { props });
|
264
|
+
});
|
265
|
+
}
|
266
|
+
function mapSlotsSync(item, map, isSlot2 = isSlot) {
|
267
|
+
const props = __spreadValues({}, item.props);
|
268
|
+
const propKeys = Object.keys(props);
|
269
|
+
for (let i = 0; i < propKeys.length; i++) {
|
270
|
+
const propKey = propKeys[i];
|
271
|
+
const itemType = "type" in item ? item.type : "root";
|
272
|
+
if (isSlot2(itemType, propKey, props[propKey])) {
|
273
|
+
const content = props[propKey];
|
274
|
+
const mappedContent = content.map((item2) => {
|
275
|
+
return mapSlotsSync(item2, map, isSlot2);
|
276
|
+
});
|
277
|
+
props[propKey] = map(mappedContent, props.id, propKey);
|
278
|
+
}
|
279
|
+
}
|
280
|
+
return __spreadProps(__spreadValues({}, item), { props });
|
281
|
+
}
|
282
|
+
function mapSlotsPublic(item, config, map) {
|
283
|
+
const isSlot2 = createIsSlotConfig(config);
|
284
|
+
return mapSlotsSync(
|
285
|
+
item,
|
286
|
+
(content, parentId, propName) => map(content, { parentId, propName }),
|
287
|
+
isSlot2
|
288
|
+
);
|
289
|
+
}
|
290
|
+
|
229
291
|
// components/Render/index.tsx
|
230
292
|
init_react_import();
|
231
293
|
|
@@ -235,36 +297,44 @@ var rootAreaId = "root";
|
|
235
297
|
var rootZone = "default-zone";
|
236
298
|
var rootDroppableId = `${rootAreaId}:${rootZone}`;
|
237
299
|
|
238
|
-
// lib/use-slots.
|
300
|
+
// lib/use-slots.tsx
|
239
301
|
init_react_import();
|
240
302
|
import { useMemo } from "react";
|
241
|
-
function useSlots(config, props,
|
242
|
-
|
303
|
+
function useSlots(config, props, renderSlotEdit, renderSlotRender = renderSlotEdit, readOnly, forceReadOnly) {
|
304
|
+
const slotProps = useMemo(() => {
|
243
305
|
if (!(config == null ? void 0 : config.fields)) return props;
|
244
|
-
const
|
306
|
+
const slotProps2 = {};
|
245
307
|
const fieldKeys = Object.keys(config.fields);
|
246
308
|
for (let i = 0; i < fieldKeys.length; i++) {
|
247
309
|
const fieldKey = fieldKeys[i];
|
248
310
|
const field = config.fields[fieldKey];
|
249
311
|
if ((field == null ? void 0 : field.type) === "slot") {
|
250
|
-
|
312
|
+
const content = props[fieldKey] || [];
|
313
|
+
const render = (readOnly == null ? void 0 : readOnly[fieldKey]) || forceReadOnly ? renderSlotRender : renderSlotEdit;
|
314
|
+
const Slot = (dzProps) => render(__spreadProps(__spreadValues({
|
315
|
+
allow: field.allow,
|
316
|
+
disallow: field.disallow
|
317
|
+
}, dzProps), {
|
251
318
|
zone: fieldKey,
|
252
|
-
content
|
319
|
+
content
|
253
320
|
}));
|
321
|
+
slotProps2[fieldKey] = Slot;
|
254
322
|
}
|
255
323
|
}
|
256
|
-
return
|
257
|
-
}, [config,
|
324
|
+
return slotProps2;
|
325
|
+
}, [config, readOnly, forceReadOnly]);
|
326
|
+
return __spreadValues(__spreadValues({}, props), slotProps);
|
258
327
|
}
|
259
328
|
|
260
329
|
// components/DropZone/index.tsx
|
261
330
|
init_react_import();
|
262
331
|
import {
|
263
332
|
forwardRef as forwardRef4,
|
333
|
+
memo,
|
264
334
|
useCallback as useCallback7,
|
265
335
|
useContext as useContext5,
|
266
336
|
useEffect as useEffect10,
|
267
|
-
useMemo as
|
337
|
+
useMemo as useMemo6,
|
268
338
|
useRef as useRef3
|
269
339
|
} from "react";
|
270
340
|
|
@@ -281,7 +351,7 @@ import {
|
|
281
351
|
|
282
352
|
// css-module:/home/runner/work/puck/puck/packages/core/components/DraggableComponent/styles.module.css#css-module
|
283
353
|
init_react_import();
|
284
|
-
var styles_module_default2 = { "DraggableComponent": "
|
354
|
+
var styles_module_default2 = { "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" };
|
285
355
|
|
286
356
|
// ../../node_modules/lucide-react/dist/esm/lucide-react.js
|
287
357
|
init_react_import();
|
@@ -616,72 +686,15 @@ init_react_import();
|
|
616
686
|
// reducer/index.ts
|
617
687
|
init_react_import();
|
618
688
|
|
619
|
-
// reducer/
|
689
|
+
// reducer/actions/set.ts
|
620
690
|
init_react_import();
|
621
691
|
|
622
|
-
// lib/
|
692
|
+
// lib/data/walk-tree.ts
|
623
693
|
init_react_import();
|
624
|
-
var insert = (list, index, item) => {
|
625
|
-
const result = Array.from(list || []);
|
626
|
-
result.splice(index, 0, item);
|
627
|
-
return result;
|
628
|
-
};
|
629
694
|
|
630
|
-
// lib/
|
695
|
+
// lib/data/for-each-slot.ts
|
631
696
|
init_react_import();
|
632
|
-
var
|
633
|
-
const result = Array.from(list);
|
634
|
-
result.splice(index, 1);
|
635
|
-
return result;
|
636
|
-
};
|
637
|
-
|
638
|
-
// lib/setup-zone.ts
|
639
|
-
init_react_import();
|
640
|
-
var setupZone = (data, zoneKey) => {
|
641
|
-
if (zoneKey === rootDroppableId) {
|
642
|
-
return data;
|
643
|
-
}
|
644
|
-
const newData = __spreadProps(__spreadValues({}, data), {
|
645
|
-
zones: data.zones ? __spreadValues({}, data.zones) : {}
|
646
|
-
});
|
647
|
-
newData.zones[zoneKey] = newData.zones[zoneKey] || [];
|
648
|
-
return newData;
|
649
|
-
};
|
650
|
-
|
651
|
-
// lib/get-item.ts
|
652
|
-
init_react_import();
|
653
|
-
function getItem(selector, state) {
|
654
|
-
var _a, _b;
|
655
|
-
const zone = (_a = state.indexes.zones) == null ? void 0 : _a[selector.zone || rootDroppableId];
|
656
|
-
return zone ? (_b = state.indexes.nodes[zone.contentIds[selector.index]]) == null ? void 0 : _b.data : void 0;
|
657
|
-
}
|
658
|
-
|
659
|
-
// lib/generate-id.ts
|
660
|
-
init_react_import();
|
661
|
-
import { v4 as uuidv4 } from "uuid";
|
662
|
-
var generateId = (type) => type ? `${type}-${uuidv4()}` : uuidv4();
|
663
|
-
|
664
|
-
// lib/walk-tree.ts
|
665
|
-
init_react_import();
|
666
|
-
|
667
|
-
// lib/for-each-slot.ts
|
668
|
-
init_react_import();
|
669
|
-
|
670
|
-
// lib/is-slot.ts
|
671
|
-
init_react_import();
|
672
|
-
var isSlot = (prop) => {
|
673
|
-
var _a, _b;
|
674
|
-
return Array.isArray(prop) && typeof ((_a = prop[0]) == null ? void 0 : _a.type) === "string" && typeof ((_b = prop[0]) == null ? void 0 : _b.props) === "object";
|
675
|
-
};
|
676
|
-
var createIsSlotConfig = (config) => (itemType, propName, propValue) => {
|
677
|
-
var _a, _b;
|
678
|
-
const configForComponent = itemType === "root" ? config == null ? void 0 : config.root : config == null ? void 0 : config.components[itemType];
|
679
|
-
if (!configForComponent) return isSlot(propValue);
|
680
|
-
return ((_b = (_a = configForComponent.fields) == null ? void 0 : _a[propName]) == null ? void 0 : _b.type) === "slot";
|
681
|
-
};
|
682
|
-
|
683
|
-
// lib/for-each-slot.ts
|
684
|
-
var forEachSlot = (_0, _1, ..._2) => __async(void 0, [_0, _1, ..._2], function* (item, cb, recursive = false, isSlot2 = isSlot) {
|
697
|
+
var forEachSlot = (item, cb, recursive = false, isSlot2 = isSlot) => {
|
685
698
|
const props = item.props || {};
|
686
699
|
const propKeys = Object.keys(props);
|
687
700
|
for (let i = 0; i < propKeys.length; i++) {
|
@@ -689,19 +702,19 @@ var forEachSlot = (_0, _1, ..._2) => __async(void 0, [_0, _1, ..._2], function*
|
|
689
702
|
const itemType = "type" in item ? item.type : "root";
|
690
703
|
if (isSlot2(itemType, propKey, props[propKey])) {
|
691
704
|
const content = props[propKey];
|
692
|
-
|
705
|
+
cb(props.id, propKey, content);
|
693
706
|
if (recursive) {
|
694
707
|
content.forEach(
|
695
708
|
(childItem) => __async(void 0, null, function* () {
|
696
|
-
return
|
709
|
+
return forEachSlot(childItem, cb, true, isSlot2);
|
697
710
|
})
|
698
711
|
);
|
699
712
|
}
|
700
713
|
}
|
701
714
|
}
|
702
|
-
}
|
715
|
+
};
|
703
716
|
|
704
|
-
// lib/for-related-zones.ts
|
717
|
+
// lib/data/for-related-zones.ts
|
705
718
|
init_react_import();
|
706
719
|
|
707
720
|
// lib/get-zone-id.ts
|
@@ -716,19 +729,17 @@ var getZoneId = (zoneCompound) => {
|
|
716
729
|
return [rootDroppableId, zoneCompound];
|
717
730
|
};
|
718
731
|
|
719
|
-
// lib/for-related-zones.ts
|
732
|
+
// lib/data/for-related-zones.ts
|
720
733
|
function forRelatedZones(item, data, cb, path = []) {
|
721
734
|
Object.entries(data.zones || {}).forEach(([zoneCompound, content]) => {
|
722
735
|
const [parentId] = getZoneId(zoneCompound);
|
723
736
|
if (parentId === item.props.id) {
|
724
|
-
const newPath = [...path, zoneCompound];
|
725
|
-
content.forEach((item2) => forRelatedZones(item2, data, cb, newPath));
|
726
737
|
cb(path, zoneCompound, content);
|
727
738
|
}
|
728
739
|
});
|
729
740
|
}
|
730
741
|
|
731
|
-
// lib/strip-slots.ts
|
742
|
+
// lib/data/strip-slots.ts
|
732
743
|
init_react_import();
|
733
744
|
var stripSlots = (data) => {
|
734
745
|
return __spreadProps(__spreadValues({}, data), {
|
@@ -744,7 +755,7 @@ var stripSlots = (data) => {
|
|
744
755
|
});
|
745
756
|
};
|
746
757
|
|
747
|
-
// lib/walk-tree.ts
|
758
|
+
// lib/data/walk-tree.ts
|
748
759
|
function walkTree(state, config, mapContent = (content) => content, mapNodeOrSkip = (item) => item) {
|
749
760
|
var _a;
|
750
761
|
let newZones = {};
|
@@ -786,7 +797,6 @@ function walkTree(state, config, mapContent = (content) => content, mapNodeOrSki
|
|
786
797
|
const mappedItem = mapNodeOrSkip(item, path, index);
|
787
798
|
if (!mappedItem) return item;
|
788
799
|
const id = mappedItem.props.id;
|
789
|
-
processRelatedZones(item, id, path);
|
790
800
|
const newProps = __spreadValues({}, mappedItem.props);
|
791
801
|
forEachSlot(
|
792
802
|
mappedItem,
|
@@ -804,6 +814,7 @@ function walkTree(state, config, mapContent = (content) => content, mapNodeOrSki
|
|
804
814
|
false,
|
805
815
|
createIsSlotConfig(config)
|
806
816
|
);
|
817
|
+
processRelatedZones(item, id, path);
|
807
818
|
const newItem = __spreadProps(__spreadValues({}, item), { props: newProps });
|
808
819
|
const thisZoneCompound = path[path.length - 1];
|
809
820
|
const [parentId, zone] = thisZoneCompound ? thisZoneCompound.split(":") : [null, ""];
|
@@ -858,7 +869,6 @@ function walkTree(state, config, mapContent = (content) => content, mapNodeOrSki
|
|
858
869
|
return __spreadProps(__spreadValues({}, state), {
|
859
870
|
data: {
|
860
871
|
root,
|
861
|
-
// root: state.data.root, // TODO changing root causes it's entire subtree to re-render. Let's keep this disabled until the performance issues are resolved in #644.
|
862
872
|
content: processedContent,
|
863
873
|
zones: __spreadValues(__spreadValues({}, state.data.zones), newZones)
|
864
874
|
},
|
@@ -869,18 +879,51 @@ function walkTree(state, config, mapContent = (content) => content, mapNodeOrSki
|
|
869
879
|
});
|
870
880
|
}
|
871
881
|
|
872
|
-
// reducer/
|
873
|
-
var
|
882
|
+
// reducer/actions/set.ts
|
883
|
+
var setAction = (state, action, appStore) => {
|
884
|
+
if (typeof action.state === "object") {
|
885
|
+
const newState = __spreadValues(__spreadValues({}, state), action.state);
|
886
|
+
if (action.state.indexes) {
|
887
|
+
return newState;
|
888
|
+
}
|
889
|
+
console.warn(
|
890
|
+
"`set` is expensive and may cause unnecessary re-renders. Consider using a more atomic action instead."
|
891
|
+
);
|
892
|
+
return walkTree(newState, appStore.config);
|
893
|
+
}
|
894
|
+
return __spreadValues(__spreadValues({}, state), action.state(state));
|
895
|
+
};
|
896
|
+
|
897
|
+
// reducer/actions/insert.ts
|
898
|
+
init_react_import();
|
899
|
+
|
900
|
+
// lib/data/insert.ts
|
901
|
+
init_react_import();
|
902
|
+
var insert = (list, index, item) => {
|
903
|
+
const result = Array.from(list || []);
|
904
|
+
result.splice(index, 0, item);
|
905
|
+
return result;
|
906
|
+
};
|
907
|
+
|
908
|
+
// lib/generate-id.ts
|
909
|
+
init_react_import();
|
910
|
+
import { v4 as uuidv4 } from "uuid";
|
911
|
+
var generateId = (type) => type ? `${type}-${uuidv4()}` : uuidv4();
|
912
|
+
|
913
|
+
// lib/data/get-ids-for-parent.ts
|
914
|
+
init_react_import();
|
874
915
|
var getIdsForParent = (zoneCompound, state) => {
|
875
916
|
const [parentId] = zoneCompound.split(":");
|
876
917
|
const node = state.indexes.nodes[parentId];
|
877
918
|
return ((node == null ? void 0 : node.path) || []).map((p) => p.split(":")[0]);
|
878
919
|
};
|
879
|
-
|
920
|
+
|
921
|
+
// reducer/actions/insert.ts
|
922
|
+
function insertAction(state, action, appStore) {
|
880
923
|
const id = action.id || generateId(action.componentType);
|
881
924
|
const emptyComponentData = {
|
882
925
|
type: action.componentType,
|
883
|
-
props: __spreadProps(__spreadValues({}, config.components[action.componentType].defaultProps || {}), {
|
926
|
+
props: __spreadProps(__spreadValues({}, appStore.config.components[action.componentType].defaultProps || {}), {
|
884
927
|
id
|
885
928
|
})
|
886
929
|
};
|
@@ -888,7 +931,7 @@ function insertAction(state, action, config) {
|
|
888
931
|
const idsInPath = getIdsForParent(action.destinationZone, state);
|
889
932
|
return walkTree(
|
890
933
|
state,
|
891
|
-
config,
|
934
|
+
appStore.config,
|
892
935
|
(content, zoneCompound) => {
|
893
936
|
if (zoneCompound === action.destinationZone) {
|
894
937
|
return insert(
|
@@ -911,6 +954,141 @@ function insertAction(state, action, config) {
|
|
911
954
|
}
|
912
955
|
);
|
913
956
|
}
|
957
|
+
|
958
|
+
// reducer/actions/replace.ts
|
959
|
+
init_react_import();
|
960
|
+
var replaceAction = (state, action, appStore) => {
|
961
|
+
const [parentId] = action.destinationZone.split(":");
|
962
|
+
const idsInPath = getIdsForParent(action.destinationZone, state);
|
963
|
+
const originalId = state.indexes.zones[action.destinationZone].contentIds[action.destinationIndex];
|
964
|
+
const idChanged = originalId !== action.data.props.id;
|
965
|
+
if (idChanged) {
|
966
|
+
throw new Error(
|
967
|
+
`Can't change the id during a replace action. Please us "remove" and "insert" to define a new node.`
|
968
|
+
);
|
969
|
+
}
|
970
|
+
return walkTree(
|
971
|
+
state,
|
972
|
+
appStore.config,
|
973
|
+
(content, zoneCompound) => {
|
974
|
+
const newContent = [...content];
|
975
|
+
if (zoneCompound === action.destinationZone) {
|
976
|
+
newContent[action.destinationIndex] = action.data;
|
977
|
+
}
|
978
|
+
return newContent;
|
979
|
+
},
|
980
|
+
(childItem, path) => {
|
981
|
+
const pathIds = path.map((p) => p.split(":")[0]);
|
982
|
+
if (childItem.props.id === action.data.props.id) {
|
983
|
+
return action.data;
|
984
|
+
} else if (childItem.props.id === parentId) {
|
985
|
+
return childItem;
|
986
|
+
} else if (idsInPath.indexOf(childItem.props.id) > -1) {
|
987
|
+
return childItem;
|
988
|
+
} else if (pathIds.indexOf(action.data.props.id) > -1) {
|
989
|
+
return childItem;
|
990
|
+
}
|
991
|
+
return null;
|
992
|
+
}
|
993
|
+
);
|
994
|
+
};
|
995
|
+
|
996
|
+
// reducer/actions/replace-root.ts
|
997
|
+
init_react_import();
|
998
|
+
var replaceRootAction = (state, action, appStore) => {
|
999
|
+
return walkTree(
|
1000
|
+
state,
|
1001
|
+
appStore.config,
|
1002
|
+
(content) => content,
|
1003
|
+
(childItem) => {
|
1004
|
+
if (childItem.props.id === "root") {
|
1005
|
+
return __spreadProps(__spreadValues({}, childItem), {
|
1006
|
+
props: __spreadValues(__spreadValues({}, childItem.props), action.root.props),
|
1007
|
+
readOnly: action.root.readOnly
|
1008
|
+
});
|
1009
|
+
}
|
1010
|
+
return childItem;
|
1011
|
+
}
|
1012
|
+
);
|
1013
|
+
};
|
1014
|
+
|
1015
|
+
// reducer/actions/duplicate.ts
|
1016
|
+
init_react_import();
|
1017
|
+
|
1018
|
+
// lib/data/get-item.ts
|
1019
|
+
init_react_import();
|
1020
|
+
function getItem(selector, state) {
|
1021
|
+
var _a, _b;
|
1022
|
+
const zone = (_a = state.indexes.zones) == null ? void 0 : _a[selector.zone || rootDroppableId];
|
1023
|
+
return zone ? (_b = state.indexes.nodes[zone.contentIds[selector.index]]) == null ? void 0 : _b.data : void 0;
|
1024
|
+
}
|
1025
|
+
|
1026
|
+
// reducer/actions/duplicate.ts
|
1027
|
+
function duplicateAction(state, action, appStore) {
|
1028
|
+
const item = getItem(
|
1029
|
+
{ index: action.sourceIndex, zone: action.sourceZone },
|
1030
|
+
state
|
1031
|
+
);
|
1032
|
+
const idsInPath = getIdsForParent(action.sourceZone, state);
|
1033
|
+
const newItem = __spreadProps(__spreadValues({}, item), {
|
1034
|
+
props: __spreadProps(__spreadValues({}, item.props), {
|
1035
|
+
id: generateId(item.type)
|
1036
|
+
})
|
1037
|
+
});
|
1038
|
+
const modified = walkTree(
|
1039
|
+
state,
|
1040
|
+
appStore.config,
|
1041
|
+
(content, zoneCompound) => {
|
1042
|
+
if (zoneCompound === action.sourceZone) {
|
1043
|
+
return insert(content, action.sourceIndex + 1, item);
|
1044
|
+
}
|
1045
|
+
return content;
|
1046
|
+
},
|
1047
|
+
(childItem, path, index) => {
|
1048
|
+
const zoneCompound = path[path.length - 1];
|
1049
|
+
const parents = path.map((p) => p.split(":")[0]);
|
1050
|
+
if (parents.indexOf(newItem.props.id) > -1) {
|
1051
|
+
return __spreadProps(__spreadValues({}, childItem), {
|
1052
|
+
props: __spreadProps(__spreadValues({}, childItem.props), {
|
1053
|
+
id: generateId(childItem.type)
|
1054
|
+
})
|
1055
|
+
});
|
1056
|
+
}
|
1057
|
+
if (zoneCompound === action.sourceZone && index === action.sourceIndex + 1) {
|
1058
|
+
return newItem;
|
1059
|
+
}
|
1060
|
+
const [sourceZoneParent] = action.sourceZone.split(":");
|
1061
|
+
if (sourceZoneParent === childItem.props.id || idsInPath.indexOf(childItem.props.id) > -1) {
|
1062
|
+
return childItem;
|
1063
|
+
}
|
1064
|
+
return null;
|
1065
|
+
}
|
1066
|
+
);
|
1067
|
+
return __spreadProps(__spreadValues({}, modified), {
|
1068
|
+
ui: __spreadProps(__spreadValues({}, modified.ui), {
|
1069
|
+
itemSelector: {
|
1070
|
+
index: action.sourceIndex + 1,
|
1071
|
+
zone: action.sourceZone
|
1072
|
+
}
|
1073
|
+
})
|
1074
|
+
});
|
1075
|
+
}
|
1076
|
+
|
1077
|
+
// reducer/actions/reorder.ts
|
1078
|
+
init_react_import();
|
1079
|
+
|
1080
|
+
// reducer/actions/move.ts
|
1081
|
+
init_react_import();
|
1082
|
+
|
1083
|
+
// lib/data/remove.ts
|
1084
|
+
init_react_import();
|
1085
|
+
var remove = (list, index) => {
|
1086
|
+
const result = Array.from(list);
|
1087
|
+
result.splice(index, 1);
|
1088
|
+
return result;
|
1089
|
+
};
|
1090
|
+
|
1091
|
+
// reducer/actions/move.ts
|
914
1092
|
var moveAction = (state, action, appStore) => {
|
915
1093
|
if (action.sourceZone === action.destinationZone && action.sourceIndex === action.destinationIndex) {
|
916
1094
|
return state;
|
@@ -950,57 +1128,26 @@ var moveAction = (state, action, appStore) => {
|
|
950
1128
|
}
|
951
1129
|
);
|
952
1130
|
};
|
953
|
-
|
954
|
-
|
955
|
-
|
956
|
-
|
957
|
-
const idChanged = originalId !== action.data.props.id;
|
958
|
-
if (idChanged) {
|
959
|
-
throw new Error(
|
960
|
-
`Can't change the id during a replace action. Please us "remove" and "insert" to define a new node.`
|
961
|
-
);
|
962
|
-
}
|
963
|
-
return walkTree(
|
1131
|
+
|
1132
|
+
// reducer/actions/reorder.ts
|
1133
|
+
var reorderAction = (state, action, appStore) => {
|
1134
|
+
return moveAction(
|
964
1135
|
state,
|
965
|
-
|
966
|
-
|
967
|
-
|
968
|
-
|
969
|
-
|
970
|
-
|
971
|
-
return newContent;
|
1136
|
+
{
|
1137
|
+
type: "move",
|
1138
|
+
sourceIndex: action.sourceIndex,
|
1139
|
+
sourceZone: action.destinationZone,
|
1140
|
+
destinationIndex: action.destinationIndex,
|
1141
|
+
destinationZone: action.destinationZone
|
972
1142
|
},
|
973
|
-
|
974
|
-
const pathIds = path.map((p) => p.split(":")[0]);
|
975
|
-
if (childItem.props.id === action.data.props.id) {
|
976
|
-
return action.data;
|
977
|
-
} else if (childItem.props.id === parentId) {
|
978
|
-
return childItem;
|
979
|
-
} else if (idsInPath.indexOf(childItem.props.id) > -1) {
|
980
|
-
return childItem;
|
981
|
-
} else if (pathIds.indexOf(action.data.props.id) > -1) {
|
982
|
-
return childItem;
|
983
|
-
}
|
984
|
-
return null;
|
985
|
-
}
|
1143
|
+
appStore
|
986
1144
|
);
|
987
1145
|
};
|
988
|
-
|
989
|
-
|
990
|
-
|
991
|
-
if (action.state.indexes) {
|
992
|
-
console.warn(
|
993
|
-
"`set` is expensive and may cause unnecessary re-renders. Consider using a more atomic action instead."
|
994
|
-
);
|
995
|
-
return newState;
|
996
|
-
}
|
997
|
-
return walkTree(newState, appStore.config);
|
998
|
-
}
|
999
|
-
return __spreadValues(__spreadValues({}, state), action.state(state));
|
1000
|
-
};
|
1146
|
+
|
1147
|
+
// reducer/actions/remove.ts
|
1148
|
+
init_react_import();
|
1001
1149
|
var removeAction = (state, action, appStore) => {
|
1002
1150
|
const item = getItem({ index: action.index, zone: action.zone }, state);
|
1003
|
-
const [parentId] = action.zone.split(":");
|
1004
1151
|
const nodesToDelete = Object.entries(state.indexes.nodes).reduce(
|
1005
1152
|
(acc, [nodeId, nodeData]) => {
|
1006
1153
|
const pathIds = nodeData.path.map((p) => p.split(":")[0]);
|
@@ -1019,24 +1166,17 @@ var removeAction = (state, action, appStore) => {
|
|
1019
1166
|
return remove(content, action.index);
|
1020
1167
|
}
|
1021
1168
|
return content;
|
1022
|
-
},
|
1023
|
-
(childItem, path) => {
|
1024
|
-
const parentIds = path.map((p) => p.split(":")[0]);
|
1025
|
-
if (childItem.props.id === parentId || childItem.props.id === item.props.id || parentIds.indexOf(item.props.id) > -1) {
|
1026
|
-
return childItem;
|
1027
|
-
}
|
1028
|
-
return null;
|
1029
1169
|
}
|
1030
1170
|
);
|
1031
1171
|
Object.keys(newState.data.zones || {}).forEach((zoneCompound) => {
|
1032
|
-
const
|
1033
|
-
if (nodesToDelete.includes(
|
1172
|
+
const parentId = zoneCompound.split(":")[0];
|
1173
|
+
if (nodesToDelete.includes(parentId) && newState.data.zones) {
|
1034
1174
|
delete newState.data.zones[zoneCompound];
|
1035
1175
|
}
|
1036
1176
|
});
|
1037
1177
|
Object.keys(newState.indexes.zones).forEach((zoneCompound) => {
|
1038
|
-
const
|
1039
|
-
if (nodesToDelete.includes(
|
1178
|
+
const parentId = zoneCompound.split(":")[0];
|
1179
|
+
if (nodesToDelete.includes(parentId)) {
|
1040
1180
|
delete newState.indexes.zones[zoneCompound];
|
1041
1181
|
}
|
1042
1182
|
});
|
@@ -1045,168 +1185,104 @@ var removeAction = (state, action, appStore) => {
|
|
1045
1185
|
});
|
1046
1186
|
return newState;
|
1047
1187
|
};
|
1048
|
-
|
1049
|
-
|
1050
|
-
|
1051
|
-
|
1052
|
-
|
1053
|
-
|
1054
|
-
|
1055
|
-
if (
|
1056
|
-
return
|
1057
|
-
}
|
1058
|
-
if (action.type === "replaceRoot") {
|
1059
|
-
return walkTree(
|
1060
|
-
state,
|
1061
|
-
appStore.config,
|
1062
|
-
(content) => content,
|
1063
|
-
(childItem) => {
|
1064
|
-
if (childItem.props.id === "root") {
|
1065
|
-
return __spreadProps(__spreadValues({}, childItem), {
|
1066
|
-
props: __spreadValues(__spreadValues({}, childItem.props), action.root.props),
|
1067
|
-
readOnly: action.root.readOnly
|
1068
|
-
});
|
1069
|
-
}
|
1070
|
-
return childItem;
|
1071
|
-
}
|
1072
|
-
);
|
1073
|
-
}
|
1074
|
-
if (action.type === "duplicate") {
|
1075
|
-
const item = getItem(
|
1076
|
-
{ index: action.sourceIndex, zone: action.sourceZone },
|
1077
|
-
state
|
1078
|
-
);
|
1079
|
-
const idsInPath = getIdsForParent(action.sourceZone, state);
|
1080
|
-
const newItem = __spreadProps(__spreadValues({}, item), {
|
1081
|
-
props: __spreadProps(__spreadValues({}, item.props), {
|
1082
|
-
id: generateId(item.type)
|
1083
|
-
})
|
1084
|
-
});
|
1085
|
-
const modified = walkTree(
|
1086
|
-
state,
|
1087
|
-
appStore.config,
|
1088
|
-
(content, zoneCompound) => {
|
1089
|
-
if (zoneCompound === action.sourceZone) {
|
1090
|
-
return insert(content, action.sourceIndex + 1, item);
|
1091
|
-
}
|
1092
|
-
return content;
|
1093
|
-
},
|
1094
|
-
(childItem, path, index) => {
|
1095
|
-
const zoneCompound = path[path.length - 1];
|
1096
|
-
const parents = path.map((p) => p.split(":")[0]);
|
1097
|
-
if (parents.indexOf(newItem.props.id) > -1) {
|
1098
|
-
return __spreadProps(__spreadValues({}, childItem), {
|
1099
|
-
props: __spreadProps(__spreadValues({}, childItem.props), {
|
1100
|
-
id: generateId(childItem.type)
|
1101
|
-
})
|
1102
|
-
});
|
1103
|
-
}
|
1104
|
-
if (zoneCompound === action.sourceZone && index === action.sourceIndex + 1) {
|
1105
|
-
return newItem;
|
1106
|
-
}
|
1107
|
-
const [sourceZoneParent] = action.sourceZone.split(":");
|
1108
|
-
if (sourceZoneParent === childItem.props.id || idsInPath.indexOf(childItem.props.id) > -1) {
|
1109
|
-
return childItem;
|
1110
|
-
}
|
1111
|
-
return null;
|
1112
|
-
}
|
1113
|
-
);
|
1114
|
-
return __spreadProps(__spreadValues({}, modified), {
|
1115
|
-
ui: __spreadProps(__spreadValues({}, modified.ui), {
|
1116
|
-
itemSelector: {
|
1117
|
-
index: action.sourceIndex + 1,
|
1118
|
-
zone: action.sourceZone
|
1119
|
-
}
|
1120
|
-
})
|
1121
|
-
});
|
1122
|
-
}
|
1123
|
-
if (action.type === "reorder") {
|
1124
|
-
return moveAction(
|
1125
|
-
state,
|
1126
|
-
{
|
1127
|
-
type: "move",
|
1128
|
-
sourceIndex: action.sourceIndex,
|
1129
|
-
sourceZone: action.destinationZone,
|
1130
|
-
destinationIndex: action.destinationIndex,
|
1131
|
-
destinationZone: action.destinationZone
|
1132
|
-
},
|
1133
|
-
appStore
|
1134
|
-
);
|
1135
|
-
}
|
1136
|
-
if (action.type === "move") {
|
1137
|
-
return moveAction(state, action, appStore);
|
1138
|
-
}
|
1139
|
-
if (action.type === "remove") {
|
1140
|
-
return removeAction(state, action, appStore);
|
1141
|
-
}
|
1142
|
-
if (action.type === "registerZone") {
|
1143
|
-
if (zoneCache[action.zone]) {
|
1144
|
-
return __spreadProps(__spreadValues({}, state), {
|
1145
|
-
data: __spreadProps(__spreadValues({}, state.data), {
|
1146
|
-
zones: __spreadProps(__spreadValues({}, state.data.zones), {
|
1147
|
-
[action.zone]: zoneCache[action.zone]
|
1148
|
-
})
|
1149
|
-
}),
|
1150
|
-
indexes: __spreadProps(__spreadValues({}, state.indexes), {
|
1151
|
-
zones: __spreadProps(__spreadValues({}, state.indexes.zones), {
|
1152
|
-
[action.zone]: __spreadProps(__spreadValues({}, state.indexes.zones[action.zone]), {
|
1153
|
-
contentIds: zoneCache[action.zone].map((item) => item.props.id),
|
1154
|
-
type: "dropzone"
|
1155
|
-
})
|
1156
|
-
})
|
1157
|
-
})
|
1158
|
-
});
|
1159
|
-
}
|
1160
|
-
return __spreadProps(__spreadValues({}, state), { data: setupZone(state.data, action.zone) });
|
1188
|
+
|
1189
|
+
// reducer/actions/register-zone.ts
|
1190
|
+
init_react_import();
|
1191
|
+
|
1192
|
+
// lib/data/setup-zone.ts
|
1193
|
+
init_react_import();
|
1194
|
+
var setupZone = (data, zoneKey) => {
|
1195
|
+
if (zoneKey === rootDroppableId) {
|
1196
|
+
return data;
|
1161
1197
|
}
|
1162
|
-
|
1163
|
-
|
1164
|
-
|
1165
|
-
|
1166
|
-
|
1167
|
-
|
1168
|
-
|
1169
|
-
|
1198
|
+
const newData = __spreadProps(__spreadValues({}, data), {
|
1199
|
+
zones: data.zones ? __spreadValues({}, data.zones) : {}
|
1200
|
+
});
|
1201
|
+
newData.zones[zoneKey] = newData.zones[zoneKey] || [];
|
1202
|
+
return newData;
|
1203
|
+
};
|
1204
|
+
|
1205
|
+
// reducer/actions/register-zone.ts
|
1206
|
+
var zoneCache = {};
|
1207
|
+
function registerZoneAction(state, action) {
|
1208
|
+
if (zoneCache[action.zone]) {
|
1170
1209
|
return __spreadProps(__spreadValues({}, state), {
|
1171
1210
|
data: __spreadProps(__spreadValues({}, state.data), {
|
1172
|
-
zones:
|
1211
|
+
zones: __spreadProps(__spreadValues({}, state.data.zones), {
|
1212
|
+
[action.zone]: zoneCache[action.zone]
|
1213
|
+
})
|
1173
1214
|
}),
|
1174
1215
|
indexes: __spreadProps(__spreadValues({}, state.indexes), {
|
1175
|
-
zones:
|
1216
|
+
zones: __spreadProps(__spreadValues({}, state.indexes.zones), {
|
1217
|
+
[action.zone]: __spreadProps(__spreadValues({}, state.indexes.zones[action.zone]), {
|
1218
|
+
contentIds: zoneCache[action.zone].map((item) => item.props.id),
|
1219
|
+
type: "dropzone"
|
1220
|
+
})
|
1221
|
+
})
|
1176
1222
|
})
|
1177
1223
|
});
|
1178
1224
|
}
|
1179
|
-
|
1180
|
-
|
1181
|
-
|
1182
|
-
|
1183
|
-
|
1184
|
-
|
1185
|
-
|
1186
|
-
|
1187
|
-
|
1188
|
-
|
1189
|
-
|
1190
|
-
}
|
1225
|
+
return __spreadProps(__spreadValues({}, state), { data: setupZone(state.data, action.zone) });
|
1226
|
+
}
|
1227
|
+
function unregisterZoneAction(state, action) {
|
1228
|
+
const _zones = __spreadValues({}, state.data.zones || {});
|
1229
|
+
const zoneIndex = __spreadValues({}, state.indexes.zones || {});
|
1230
|
+
if (_zones[action.zone]) {
|
1231
|
+
zoneCache[action.zone] = _zones[action.zone];
|
1232
|
+
delete _zones[action.zone];
|
1233
|
+
}
|
1234
|
+
delete zoneIndex[action.zone];
|
1235
|
+
return __spreadProps(__spreadValues({}, state), {
|
1236
|
+
data: __spreadProps(__spreadValues({}, state.data), {
|
1237
|
+
zones: _zones
|
1238
|
+
}),
|
1239
|
+
indexes: __spreadProps(__spreadValues({}, state.indexes), {
|
1240
|
+
zones: zoneIndex
|
1241
|
+
})
|
1242
|
+
});
|
1243
|
+
}
|
1244
|
+
|
1245
|
+
// reducer/actions/set-data.ts
|
1246
|
+
init_react_import();
|
1247
|
+
var setDataAction = (state, action, appStore) => {
|
1248
|
+
if (typeof action.data === "object") {
|
1249
|
+
console.warn(
|
1250
|
+
"`setData` is expensive and may cause unnecessary re-renders. Consider using a more atomic action instead."
|
1251
|
+
);
|
1191
1252
|
return walkTree(
|
1192
1253
|
__spreadProps(__spreadValues({}, state), {
|
1193
|
-
data: __spreadValues(__spreadValues({}, state.data), action.data
|
1254
|
+
data: __spreadValues(__spreadValues({}, state.data), action.data)
|
1194
1255
|
}),
|
1195
1256
|
appStore.config
|
1196
1257
|
);
|
1197
1258
|
}
|
1198
|
-
|
1199
|
-
|
1200
|
-
|
1201
|
-
|
1202
|
-
|
1203
|
-
|
1259
|
+
return walkTree(
|
1260
|
+
__spreadProps(__spreadValues({}, state), {
|
1261
|
+
data: __spreadValues(__spreadValues({}, state.data), action.data(state.data))
|
1262
|
+
}),
|
1263
|
+
appStore.config
|
1264
|
+
);
|
1265
|
+
};
|
1266
|
+
|
1267
|
+
// reducer/actions/set-ui.ts
|
1268
|
+
init_react_import();
|
1269
|
+
var setUiAction = (state, action) => {
|
1270
|
+
if (typeof action.ui === "object") {
|
1204
1271
|
return __spreadProps(__spreadValues({}, state), {
|
1205
|
-
ui: __spreadValues(__spreadValues({}, state.ui), action.ui
|
1272
|
+
ui: __spreadValues(__spreadValues({}, state.ui), action.ui)
|
1206
1273
|
});
|
1207
1274
|
}
|
1208
|
-
return state
|
1209
|
-
}
|
1275
|
+
return __spreadProps(__spreadValues({}, state), {
|
1276
|
+
ui: __spreadValues(__spreadValues({}, state.ui), action.ui(state.ui))
|
1277
|
+
});
|
1278
|
+
};
|
1279
|
+
|
1280
|
+
// lib/data/make-state-public.ts
|
1281
|
+
init_react_import();
|
1282
|
+
var makeStatePublic = (state) => {
|
1283
|
+
const { data, ui } = state;
|
1284
|
+
return { data, ui };
|
1285
|
+
};
|
1210
1286
|
|
1211
1287
|
// reducer/actions.tsx
|
1212
1288
|
init_react_import();
|
@@ -1225,7 +1301,7 @@ function storeInterceptor(reducer, record, onAction) {
|
|
1225
1301
|
if (typeof action.recordHistory !== "undefined" ? action.recordHistory : isValidType) {
|
1226
1302
|
if (record) record(newAppState);
|
1227
1303
|
}
|
1228
|
-
onAction == null ? void 0 : onAction(action, newAppState, state);
|
1304
|
+
onAction == null ? void 0 : onAction(action, makeStatePublic(newAppState), makeStatePublic(state));
|
1229
1305
|
return newAppState;
|
1230
1306
|
};
|
1231
1307
|
}
|
@@ -1236,8 +1312,43 @@ function createReducer({
|
|
1236
1312
|
}) {
|
1237
1313
|
return storeInterceptor(
|
1238
1314
|
(state, action) => {
|
1239
|
-
|
1240
|
-
|
1315
|
+
if (action.type === "set") {
|
1316
|
+
return setAction(state, action, appStore);
|
1317
|
+
}
|
1318
|
+
if (action.type === "insert") {
|
1319
|
+
return insertAction(state, action, appStore);
|
1320
|
+
}
|
1321
|
+
if (action.type === "replace") {
|
1322
|
+
return replaceAction(state, action, appStore);
|
1323
|
+
}
|
1324
|
+
if (action.type === "replaceRoot") {
|
1325
|
+
return replaceRootAction(state, action, appStore);
|
1326
|
+
}
|
1327
|
+
if (action.type === "duplicate") {
|
1328
|
+
return duplicateAction(state, action, appStore);
|
1329
|
+
}
|
1330
|
+
if (action.type === "reorder") {
|
1331
|
+
return reorderAction(state, action, appStore);
|
1332
|
+
}
|
1333
|
+
if (action.type === "move") {
|
1334
|
+
return moveAction(state, action, appStore);
|
1335
|
+
}
|
1336
|
+
if (action.type === "remove") {
|
1337
|
+
return removeAction(state, action, appStore);
|
1338
|
+
}
|
1339
|
+
if (action.type === "registerZone") {
|
1340
|
+
return registerZoneAction(state, action);
|
1341
|
+
}
|
1342
|
+
if (action.type === "unregisterZone") {
|
1343
|
+
return unregisterZoneAction(state, action);
|
1344
|
+
}
|
1345
|
+
if (action.type === "setData") {
|
1346
|
+
return setDataAction(state, action, appStore);
|
1347
|
+
}
|
1348
|
+
if (action.type === "setUi") {
|
1349
|
+
return setUiAction(state, action);
|
1350
|
+
}
|
1351
|
+
return state;
|
1241
1352
|
},
|
1242
1353
|
record,
|
1243
1354
|
onAction
|
@@ -1449,7 +1560,7 @@ var createHistorySlice = (set, get) => {
|
|
1449
1560
|
const { dispatch, history } = get();
|
1450
1561
|
dispatch({
|
1451
1562
|
type: "set",
|
1452
|
-
state: ((_a = history.histories[
|
1563
|
+
state: ((_a = history.histories[index]) == null ? void 0 : _a.state) || history.initialAppState
|
1453
1564
|
});
|
1454
1565
|
set({ history: __spreadProps(__spreadValues({}, history), { index }) });
|
1455
1566
|
},
|
@@ -1526,7 +1637,7 @@ var createNodesSlice = (set, get) => ({
|
|
1526
1637
|
init_react_import();
|
1527
1638
|
import { useEffect as useEffect3 } from "react";
|
1528
1639
|
|
1529
|
-
// lib/flatten-data.ts
|
1640
|
+
// lib/data/flatten-data.ts
|
1530
1641
|
init_react_import();
|
1531
1642
|
var flattenData = (state, config) => {
|
1532
1643
|
const data = [];
|
@@ -1561,12 +1672,7 @@ var createPermissionsSlice = (set, get) => {
|
|
1561
1672
|
const { cache: cache2, globalPermissions } = permissions;
|
1562
1673
|
const resolveDataForItem = (item2, force2 = false) => __async(void 0, null, function* () {
|
1563
1674
|
var _a, _b, _c;
|
1564
|
-
const {
|
1565
|
-
config: config2,
|
1566
|
-
state: appState,
|
1567
|
-
setComponentLoading,
|
1568
|
-
unsetComponentLoading
|
1569
|
-
} = get();
|
1675
|
+
const { config: config2, state: appState, setComponentLoading } = get();
|
1570
1676
|
const componentConfig = item2.type === "root" ? config2.root : config2.components[item2.type];
|
1571
1677
|
if (!componentConfig) {
|
1572
1678
|
return;
|
@@ -1575,14 +1681,14 @@ var createPermissionsSlice = (set, get) => {
|
|
1575
1681
|
if (componentConfig.resolvePermissions) {
|
1576
1682
|
const changed = getChanged(item2, (_a = cache2[item2.props.id]) == null ? void 0 : _a.lastData);
|
1577
1683
|
if (Object.values(changed).some((el) => el === true) || force2) {
|
1578
|
-
setComponentLoading(item2.props.id);
|
1684
|
+
const clearTimeout2 = setComponentLoading(item2.props.id, true, 50);
|
1579
1685
|
const resolvedPermissions = yield componentConfig.resolvePermissions(
|
1580
1686
|
item2,
|
1581
1687
|
{
|
1582
1688
|
changed,
|
1583
1689
|
lastPermissions: ((_b = cache2[item2.props.id]) == null ? void 0 : _b.lastPermissions) || null,
|
1584
1690
|
permissions: initialPermissions,
|
1585
|
-
appState,
|
1691
|
+
appState: makeStatePublic(appState),
|
1586
1692
|
lastData: ((_c = cache2[item2.props.id]) == null ? void 0 : _c.lastData) || null
|
1587
1693
|
}
|
1588
1694
|
);
|
@@ -1600,7 +1706,7 @@ var createPermissionsSlice = (set, get) => {
|
|
1600
1706
|
})
|
1601
1707
|
})
|
1602
1708
|
});
|
1603
|
-
|
1709
|
+
clearTimeout2();
|
1604
1710
|
}
|
1605
1711
|
}
|
1606
1712
|
});
|
@@ -1610,7 +1716,7 @@ var createPermissionsSlice = (set, get) => {
|
|
1610
1716
|
// Shim the root data in by conforming to component data shape
|
1611
1717
|
{
|
1612
1718
|
type: "root",
|
1613
|
-
props: __spreadProps(__spreadValues({}, appState.data.root.props), { id: "
|
1719
|
+
props: __spreadProps(__spreadValues({}, appState.data.root.props), { id: "root" })
|
1614
1720
|
},
|
1615
1721
|
force2
|
1616
1722
|
);
|
@@ -1625,7 +1731,6 @@ var createPermissionsSlice = (set, get) => {
|
|
1625
1731
|
} else if (root) {
|
1626
1732
|
resolveDataForRoot(force);
|
1627
1733
|
} else {
|
1628
|
-
resolveDataForRoot(force);
|
1629
1734
|
flattenData(state, config).map((item2) => __async(void 0, null, function* () {
|
1630
1735
|
yield resolveDataForItem(item2, force);
|
1631
1736
|
}));
|
@@ -1656,7 +1761,7 @@ var createPermissionsSlice = (set, get) => {
|
|
1656
1761
|
} else if (root) {
|
1657
1762
|
const rootConfig = config.root;
|
1658
1763
|
const initialPermissions = __spreadValues(__spreadValues({}, globalPermissions), rootConfig == null ? void 0 : rootConfig.permissions);
|
1659
|
-
const resolvedForItem = resolvedPermissions["
|
1764
|
+
const resolvedForItem = resolvedPermissions["root"];
|
1660
1765
|
return resolvedForItem ? __spreadValues(__spreadValues({}, globalPermissions), resolvedForItem) : initialPermissions;
|
1661
1766
|
}
|
1662
1767
|
return globalPermissions;
|
@@ -1739,7 +1844,7 @@ var useRegisterFieldsSlice = (appStore, id) => {
|
|
1739
1844
|
fields: defaultFields,
|
1740
1845
|
lastFields,
|
1741
1846
|
lastData,
|
1742
|
-
appState: state,
|
1847
|
+
appState: makeStatePublic(state),
|
1743
1848
|
parent
|
1744
1849
|
});
|
1745
1850
|
clearTimeout(timeout3);
|
@@ -1772,30 +1877,6 @@ var useRegisterFieldsSlice = (appStore, id) => {
|
|
1772
1877
|
|
1773
1878
|
// lib/resolve-component-data.ts
|
1774
1879
|
init_react_import();
|
1775
|
-
|
1776
|
-
// lib/map-slots.ts
|
1777
|
-
init_react_import();
|
1778
|
-
function mapSlots(item, map, recursive = true, isSlot2) {
|
1779
|
-
return __async(this, null, function* () {
|
1780
|
-
const props = __spreadValues({}, item.props);
|
1781
|
-
yield forEachSlot(
|
1782
|
-
item,
|
1783
|
-
(_parentId, propName, content) => __async(this, null, function* () {
|
1784
|
-
const mappedContent = recursive ? yield Promise.all(
|
1785
|
-
content.map((item2) => __async(this, null, function* () {
|
1786
|
-
return yield mapSlots(item2, map, recursive, isSlot2);
|
1787
|
-
}))
|
1788
|
-
) : content;
|
1789
|
-
props[propName] = yield map(mappedContent, propName);
|
1790
|
-
}),
|
1791
|
-
false,
|
1792
|
-
isSlot2
|
1793
|
-
);
|
1794
|
-
return __spreadProps(__spreadValues({}, item), { props });
|
1795
|
-
});
|
1796
|
-
}
|
1797
|
-
|
1798
|
-
// lib/resolve-component-data.ts
|
1799
1880
|
import fdeq from "fast-deep-equal";
|
1800
1881
|
var cache = { lastChange: {} };
|
1801
1882
|
var resolveComponentData = (_0, _1, ..._2) => __async(void 0, [_0, _1, ..._2], function* (item, config, metadata = {}, onResolveStart, onResolveEnd, trigger = "replace", recursive = true) {
|
@@ -1813,14 +1894,14 @@ var resolveComponentData = (_0, _1, ..._2) => __async(void 0, [_0, _1, ..._2], f
|
|
1813
1894
|
const { props: resolvedProps, readOnly = {} } = yield configForItem.resolveData(item, {
|
1814
1895
|
changed,
|
1815
1896
|
lastData: oldItem,
|
1816
|
-
metadata,
|
1897
|
+
metadata: __spreadValues(__spreadValues({}, metadata), configForItem.metadata),
|
1817
1898
|
trigger
|
1818
1899
|
});
|
1819
1900
|
let resolvedItem = __spreadProps(__spreadValues({}, item), {
|
1820
1901
|
props: __spreadValues(__spreadValues({}, item.props), resolvedProps)
|
1821
1902
|
});
|
1822
1903
|
if (recursive) {
|
1823
|
-
resolvedItem = yield
|
1904
|
+
resolvedItem = yield mapSlotsAsync(
|
1824
1905
|
resolvedItem,
|
1825
1906
|
(content) => __async(void 0, null, function* () {
|
1826
1907
|
return Promise.all(
|
@@ -1858,7 +1939,7 @@ var resolveComponentData = (_0, _1, ..._2) => __async(void 0, [_0, _1, ..._2], f
|
|
1858
1939
|
return { node: item, didChange: false };
|
1859
1940
|
});
|
1860
1941
|
|
1861
|
-
// lib/to-root.ts
|
1942
|
+
// lib/data/to-root.ts
|
1862
1943
|
init_react_import();
|
1863
1944
|
var toRoot = (item) => {
|
1864
1945
|
if ("type" in item && item.type !== "root") {
|
@@ -1905,166 +1986,176 @@ var defaultPageFields = {
|
|
1905
1986
|
title: { type: "text" }
|
1906
1987
|
};
|
1907
1988
|
var createAppStore = (initialAppStore) => create2()(
|
1908
|
-
subscribeWithSelector2((set, get) =>
|
1909
|
-
|
1910
|
-
|
1911
|
-
|
1912
|
-
|
1913
|
-
|
1914
|
-
|
1915
|
-
|
1916
|
-
|
1917
|
-
|
1918
|
-
|
1919
|
-
|
1920
|
-
|
1921
|
-
|
1922
|
-
|
1923
|
-
|
1924
|
-
|
1925
|
-
|
1926
|
-
|
1927
|
-
|
1928
|
-
|
1929
|
-
|
1930
|
-
|
1931
|
-
|
1932
|
-
|
1933
|
-
|
1934
|
-
|
1935
|
-
|
1936
|
-
|
1937
|
-
|
1938
|
-
|
1939
|
-
|
1940
|
-
|
1941
|
-
|
1942
|
-
|
1943
|
-
|
1944
|
-
|
1945
|
-
|
1946
|
-
|
1947
|
-
|
1948
|
-
|
1949
|
-
|
1950
|
-
|
1951
|
-
|
1952
|
-
|
1953
|
-
|
1954
|
-
|
1955
|
-
|
1956
|
-
|
1957
|
-
|
1958
|
-
|
1959
|
-
|
1960
|
-
|
1961
|
-
|
1962
|
-
|
1963
|
-
|
1964
|
-
|
1965
|
-
|
1966
|
-
|
1967
|
-
|
1968
|
-
|
1969
|
-
|
1970
|
-
|
1989
|
+
subscribeWithSelector2((set, get) => {
|
1990
|
+
var _a, _b;
|
1991
|
+
return __spreadProps(__spreadValues({
|
1992
|
+
state: defaultAppState,
|
1993
|
+
config: { components: {} },
|
1994
|
+
componentState: {},
|
1995
|
+
plugins: [],
|
1996
|
+
overrides: {},
|
1997
|
+
viewports: defaultViewports,
|
1998
|
+
zoomConfig: {
|
1999
|
+
autoZoom: 1,
|
2000
|
+
rootHeight: 0,
|
2001
|
+
zoom: 1
|
2002
|
+
},
|
2003
|
+
status: "LOADING",
|
2004
|
+
iframe: {},
|
2005
|
+
metadata: {}
|
2006
|
+
}, initialAppStore), {
|
2007
|
+
fields: createFieldsSlice(set, get),
|
2008
|
+
history: createHistorySlice(set, get),
|
2009
|
+
nodes: createNodesSlice(set, get),
|
2010
|
+
permissions: createPermissionsSlice(set, get),
|
2011
|
+
getComponentConfig: (type) => {
|
2012
|
+
var _a2;
|
2013
|
+
const { config, selectedItem } = get();
|
2014
|
+
const rootFields = ((_a2 = config.root) == null ? void 0 : _a2.fields) || defaultPageFields;
|
2015
|
+
return type && type !== "root" ? config.components[type] : selectedItem ? config.components[selectedItem.type] : __spreadProps(__spreadValues({}, config.root), { fields: rootFields });
|
2016
|
+
},
|
2017
|
+
selectedItem: ((_a = initialAppStore == null ? void 0 : initialAppStore.state) == null ? void 0 : _a.ui.itemSelector) ? getItem(
|
2018
|
+
(_b = initialAppStore == null ? void 0 : initialAppStore.state) == null ? void 0 : _b.ui.itemSelector,
|
2019
|
+
initialAppStore.state
|
2020
|
+
) : null,
|
2021
|
+
dispatch: (action) => set((s) => {
|
2022
|
+
var _a2, _b2;
|
2023
|
+
const { record } = get().history;
|
2024
|
+
const dispatch = createReducer({
|
2025
|
+
record,
|
2026
|
+
appStore: s
|
2027
|
+
});
|
2028
|
+
const state = dispatch(s.state, action);
|
2029
|
+
const selectedItem = state.ui.itemSelector ? getItem(state.ui.itemSelector, state) : null;
|
2030
|
+
(_b2 = (_a2 = get()).onAction) == null ? void 0 : _b2.call(_a2, action, state, get().state);
|
2031
|
+
return __spreadProps(__spreadValues({}, s), { state, selectedItem });
|
2032
|
+
}),
|
2033
|
+
setZoomConfig: (zoomConfig) => set({ zoomConfig }),
|
2034
|
+
setStatus: (status) => set({ status }),
|
2035
|
+
setComponentState: (componentState) => set({ componentState }),
|
2036
|
+
pendingLoadTimeouts: {},
|
2037
|
+
setComponentLoading: (id, loading = true, defer = 0) => {
|
2038
|
+
const { setComponentState, pendingLoadTimeouts } = get();
|
2039
|
+
const loadId = generateId();
|
2040
|
+
const setLoading = () => {
|
2041
|
+
var _a2;
|
2042
|
+
const { componentState } = get();
|
2043
|
+
setComponentState(__spreadProps(__spreadValues({}, componentState), {
|
2044
|
+
[id]: __spreadProps(__spreadValues({}, componentState[id]), {
|
2045
|
+
loadingCount: (((_a2 = componentState[id]) == null ? void 0 : _a2.loadingCount) || 0) + 1
|
2046
|
+
})
|
2047
|
+
}));
|
2048
|
+
};
|
2049
|
+
const unsetLoading = () => {
|
2050
|
+
var _a2;
|
2051
|
+
const { componentState } = get();
|
2052
|
+
clearTimeout(timeout3);
|
2053
|
+
delete pendingLoadTimeouts[loadId];
|
2054
|
+
set({ pendingLoadTimeouts });
|
2055
|
+
setComponentState(__spreadProps(__spreadValues({}, componentState), {
|
2056
|
+
[id]: __spreadProps(__spreadValues({}, componentState[id]), {
|
2057
|
+
loadingCount: Math.max(
|
2058
|
+
(((_a2 = componentState[id]) == null ? void 0 : _a2.loadingCount) || 0) - 1,
|
2059
|
+
0
|
2060
|
+
)
|
2061
|
+
})
|
2062
|
+
}));
|
2063
|
+
};
|
2064
|
+
const timeout3 = setTimeout(() => {
|
2065
|
+
if (loading) {
|
2066
|
+
setLoading();
|
2067
|
+
} else {
|
2068
|
+
unsetLoading();
|
2069
|
+
}
|
2070
|
+
delete pendingLoadTimeouts[loadId];
|
2071
|
+
set({ pendingLoadTimeouts });
|
2072
|
+
}, defer);
|
2073
|
+
set({
|
2074
|
+
pendingLoadTimeouts: __spreadProps(__spreadValues({}, pendingLoadTimeouts), {
|
2075
|
+
[id]: timeout3
|
1971
2076
|
})
|
1972
|
-
})
|
1973
|
-
|
1974
|
-
|
1975
|
-
|
1976
|
-
|
1977
|
-
|
1978
|
-
}
|
1979
|
-
|
1980
|
-
|
1981
|
-
|
1982
|
-
|
1983
|
-
|
1984
|
-
|
1985
|
-
|
1986
|
-
|
1987
|
-
|
1988
|
-
|
1989
|
-
|
1990
|
-
|
1991
|
-
|
1992
|
-
|
1993
|
-
|
1994
|
-
|
1995
|
-
|
1996
|
-
|
1997
|
-
|
1998
|
-
|
1999
|
-
|
2000
|
-
|
2001
|
-
|
2002
|
-
|
2003
|
-
|
2004
|
-
|
2005
|
-
|
2006
|
-
|
2007
|
-
|
2008
|
-
|
2009
|
-
|
2010
|
-
|
2011
|
-
return __spreadProps(__spreadValues({}, s), { state, selectedItem });
|
2012
|
-
}),
|
2013
|
-
resolveComponentData: (componentData, trigger) => __async(void 0, null, function* () {
|
2014
|
-
const { config, metadata, setComponentLoading } = get();
|
2015
|
-
return yield resolveComponentData(
|
2016
|
-
componentData,
|
2017
|
-
config,
|
2018
|
-
metadata,
|
2019
|
-
(item) => setComponentLoading(
|
2020
|
-
"id" in item.props ? item.props.id : "root",
|
2021
|
-
true,
|
2022
|
-
50
|
2023
|
-
),
|
2024
|
-
(item) => setComponentLoading(
|
2025
|
-
"id" in item.props ? item.props.id : "root",
|
2026
|
-
false,
|
2027
|
-
0
|
2028
|
-
),
|
2029
|
-
trigger
|
2030
|
-
);
|
2031
|
-
}),
|
2032
|
-
resolveAndCommitData: () => __async(void 0, null, function* () {
|
2033
|
-
const { config, state, dispatch, resolveComponentData: resolveComponentData2 } = get();
|
2034
|
-
walkTree(
|
2035
|
-
state,
|
2036
|
-
config,
|
2037
|
-
(content) => content,
|
2038
|
-
(childItem) => {
|
2039
|
-
resolveComponentData2(childItem, "load").then((resolved) => {
|
2040
|
-
const { state: state2 } = get();
|
2041
|
-
const node = state2.indexes.nodes[resolved.node.props.id];
|
2042
|
-
if (node && resolved.didChange) {
|
2043
|
-
if (resolved.node.props.id === "root") {
|
2044
|
-
dispatch({
|
2045
|
-
type: "replaceRoot",
|
2046
|
-
root: toRoot(resolved.node)
|
2047
|
-
});
|
2048
|
-
} else {
|
2049
|
-
const zoneCompound = `${node.parentId}:${node.zone}`;
|
2050
|
-
const parentZone = state2.indexes.zones[zoneCompound];
|
2051
|
-
const index = parentZone.contentIds.indexOf(
|
2052
|
-
resolved.node.props.id
|
2053
|
-
);
|
2054
|
-
dispatch({
|
2055
|
-
type: "replace",
|
2056
|
-
data: resolved.node,
|
2057
|
-
destinationIndex: index,
|
2058
|
-
destinationZone: zoneCompound
|
2059
|
-
});
|
2060
|
-
}
|
2077
|
+
});
|
2078
|
+
return unsetLoading;
|
2079
|
+
},
|
2080
|
+
unsetComponentLoading: (id) => {
|
2081
|
+
const { setComponentLoading } = get();
|
2082
|
+
setComponentLoading(id, false);
|
2083
|
+
},
|
2084
|
+
// Helper
|
2085
|
+
setUi: (ui, recordHistory) => set((s) => {
|
2086
|
+
const dispatch = createReducer({
|
2087
|
+
record: () => {
|
2088
|
+
},
|
2089
|
+
appStore: s
|
2090
|
+
});
|
2091
|
+
const state = dispatch(s.state, {
|
2092
|
+
type: "setUi",
|
2093
|
+
ui,
|
2094
|
+
recordHistory
|
2095
|
+
});
|
2096
|
+
const selectedItem = state.ui.itemSelector ? getItem(state.ui.itemSelector, state) : null;
|
2097
|
+
return __spreadProps(__spreadValues({}, s), { state, selectedItem });
|
2098
|
+
}),
|
2099
|
+
resolveComponentData: (componentData, trigger) => __async(void 0, null, function* () {
|
2100
|
+
const { config, metadata, setComponentLoading, permissions } = get();
|
2101
|
+
const timeouts = {};
|
2102
|
+
return yield resolveComponentData(
|
2103
|
+
componentData,
|
2104
|
+
config,
|
2105
|
+
metadata,
|
2106
|
+
(item) => {
|
2107
|
+
const id = "id" in item.props ? item.props.id : "root";
|
2108
|
+
timeouts[id] = setComponentLoading(id, true, 50);
|
2109
|
+
},
|
2110
|
+
(item) => __async(void 0, null, function* () {
|
2111
|
+
const id = "id" in item.props ? item.props.id : "root";
|
2112
|
+
if ("type" in item) {
|
2113
|
+
yield permissions.refreshPermissions({ item });
|
2114
|
+
} else {
|
2115
|
+
yield permissions.refreshPermissions({ root: true });
|
2061
2116
|
}
|
2062
|
-
|
2063
|
-
|
2064
|
-
|
2065
|
-
|
2066
|
-
|
2067
|
-
|
2117
|
+
timeouts[id]();
|
2118
|
+
}),
|
2119
|
+
trigger
|
2120
|
+
);
|
2121
|
+
}),
|
2122
|
+
resolveAndCommitData: () => __async(void 0, null, function* () {
|
2123
|
+
const { config, state, dispatch, resolveComponentData: resolveComponentData2 } = get();
|
2124
|
+
walkTree(
|
2125
|
+
state,
|
2126
|
+
config,
|
2127
|
+
(content) => content,
|
2128
|
+
(childItem) => {
|
2129
|
+
resolveComponentData2(childItem, "load").then((resolved) => {
|
2130
|
+
const { state: state2 } = get();
|
2131
|
+
const node = state2.indexes.nodes[resolved.node.props.id];
|
2132
|
+
if (node && resolved.didChange) {
|
2133
|
+
if (resolved.node.props.id === "root") {
|
2134
|
+
dispatch({
|
2135
|
+
type: "replaceRoot",
|
2136
|
+
root: toRoot(resolved.node)
|
2137
|
+
});
|
2138
|
+
} else {
|
2139
|
+
const zoneCompound = `${node.parentId}:${node.zone}`;
|
2140
|
+
const parentZone = state2.indexes.zones[zoneCompound];
|
2141
|
+
const index = parentZone.contentIds.indexOf(
|
2142
|
+
resolved.node.props.id
|
2143
|
+
);
|
2144
|
+
dispatch({
|
2145
|
+
type: "replace",
|
2146
|
+
data: resolved.node,
|
2147
|
+
destinationIndex: index,
|
2148
|
+
destinationZone: zoneCompound
|
2149
|
+
});
|
2150
|
+
}
|
2151
|
+
}
|
2152
|
+
});
|
2153
|
+
return childItem;
|
2154
|
+
}
|
2155
|
+
);
|
2156
|
+
})
|
2157
|
+
});
|
2158
|
+
})
|
2068
2159
|
);
|
2069
2160
|
var appStoreContext = createContext(createAppStore());
|
2070
2161
|
function useAppStore(selector) {
|
@@ -2084,7 +2175,7 @@ init_react_import();
|
|
2084
2175
|
// lib/filter.ts
|
2085
2176
|
init_react_import();
|
2086
2177
|
|
2087
|
-
// lib/reorder.ts
|
2178
|
+
// lib/data/reorder.ts
|
2088
2179
|
init_react_import();
|
2089
2180
|
var reorder = (list, startIndex, endIndex) => {
|
2090
2181
|
const result = Array.from(list);
|
@@ -2093,7 +2184,7 @@ var reorder = (list, startIndex, endIndex) => {
|
|
2093
2184
|
return result;
|
2094
2185
|
};
|
2095
2186
|
|
2096
|
-
// lib/replace.ts
|
2187
|
+
// lib/data/replace.ts
|
2097
2188
|
init_react_import();
|
2098
2189
|
var replace = (list, index, newItem) => {
|
2099
2190
|
const result = Array.from(list);
|
@@ -2553,7 +2644,6 @@ var DropZoneProvider = ({
|
|
2553
2644
|
value
|
2554
2645
|
}) => {
|
2555
2646
|
const [hoveringComponent, setHoveringComponent] = useState();
|
2556
|
-
const [activeZones, setActiveZones] = useState({});
|
2557
2647
|
const dispatch = useAppStore((s) => s.dispatch);
|
2558
2648
|
const registerZone = useCallback2(
|
2559
2649
|
(zoneCompound) => {
|
@@ -2562,7 +2652,7 @@ var DropZoneProvider = ({
|
|
2562
2652
|
zone: zoneCompound
|
2563
2653
|
});
|
2564
2654
|
},
|
2565
|
-
[
|
2655
|
+
[dispatch]
|
2566
2656
|
);
|
2567
2657
|
const unregisterZone = useCallback2(
|
2568
2658
|
(zoneCompound) => {
|
@@ -2571,17 +2661,16 @@ var DropZoneProvider = ({
|
|
2571
2661
|
zone: zoneCompound
|
2572
2662
|
});
|
2573
2663
|
},
|
2574
|
-
[
|
2664
|
+
[dispatch]
|
2575
2665
|
);
|
2576
2666
|
const memoValue = useMemo2(
|
2577
2667
|
() => __spreadValues({
|
2578
2668
|
hoveringComponent,
|
2579
2669
|
setHoveringComponent,
|
2580
2670
|
registerZone,
|
2581
|
-
unregisterZone
|
2582
|
-
activeZones
|
2671
|
+
unregisterZone
|
2583
2672
|
}, value),
|
2584
|
-
[value, hoveringComponent
|
2673
|
+
[value, hoveringComponent]
|
2585
2674
|
);
|
2586
2675
|
return /* @__PURE__ */ jsx3(Fragment, { children: memoValue && /* @__PURE__ */ jsx3(dropZoneContext.Provider, { value: memoValue, children }) });
|
2587
2676
|
};
|
@@ -2674,8 +2763,10 @@ var DraggableComponent = ({
|
|
2674
2763
|
return (_a = s.state.indexes.nodes[id]) == null ? void 0 : _a.path;
|
2675
2764
|
}));
|
2676
2765
|
const permissions = useAppStore(
|
2677
|
-
useShallow2((s) =>
|
2678
|
-
|
2766
|
+
useShallow2((s) => {
|
2767
|
+
const item = getItem({ index, zone: zoneCompound }, s.state);
|
2768
|
+
return s.permissions.getPermissions({ item });
|
2769
|
+
})
|
2679
2770
|
);
|
2680
2771
|
const userIsDragging = useContextStore(
|
2681
2772
|
ZoneStoreContext,
|
@@ -2929,76 +3020,82 @@ var DraggableComponent = ({
|
|
2929
3020
|
setDragAxis(autoDragAxis);
|
2930
3021
|
}, [ref, userDragAxis, autoDragAxis]);
|
2931
3022
|
const parentAction = (ctx == null ? void 0 : ctx.areaId) && (ctx == null ? void 0 : ctx.areaId) !== "root" && /* @__PURE__ */ jsx4(ActionBar.Action, { onClick: onSelectParent, label: "Select parent", children: /* @__PURE__ */ jsx4(CornerLeftUp, { size: 16 }) });
|
2932
|
-
|
2933
|
-
|
2934
|
-
|
2935
|
-
|
2936
|
-
|
2937
|
-
|
2938
|
-
|
2939
|
-
|
2940
|
-
|
2941
|
-
|
2942
|
-
|
2943
|
-
|
2944
|
-
|
2945
|
-
|
2946
|
-
|
2947
|
-
|
2948
|
-
|
2949
|
-
|
2950
|
-
|
2951
|
-
|
2952
|
-
|
2953
|
-
|
2954
|
-
|
2955
|
-
|
2956
|
-
|
2957
|
-
|
2958
|
-
|
3023
|
+
const nextContextValue = useMemo3(
|
3024
|
+
() => __spreadProps(__spreadValues({}, ctx), {
|
3025
|
+
areaId: id,
|
3026
|
+
zoneCompound,
|
3027
|
+
index,
|
3028
|
+
depth: depth + 1,
|
3029
|
+
registerLocalZone,
|
3030
|
+
unregisterLocalZone
|
3031
|
+
}),
|
3032
|
+
[
|
3033
|
+
ctx,
|
3034
|
+
id,
|
3035
|
+
zoneCompound,
|
3036
|
+
index,
|
3037
|
+
depth,
|
3038
|
+
registerLocalZone,
|
3039
|
+
unregisterLocalZone
|
3040
|
+
]
|
3041
|
+
);
|
3042
|
+
return /* @__PURE__ */ jsxs2(DropZoneProvider, { value: nextContextValue, children: [
|
3043
|
+
isVisible && createPortal(
|
3044
|
+
/* @__PURE__ */ jsxs2(
|
3045
|
+
"div",
|
3046
|
+
{
|
3047
|
+
className: getClassName3({
|
3048
|
+
isSelected,
|
3049
|
+
isDragging: thisIsDragging,
|
3050
|
+
hover: hover || indicativeHover
|
3051
|
+
}),
|
3052
|
+
style: __spreadValues({}, style),
|
3053
|
+
"data-puck-overlay": true,
|
3054
|
+
children: [
|
3055
|
+
debug,
|
3056
|
+
isLoading && /* @__PURE__ */ jsx4("div", { className: getClassName3("loadingOverlay"), children: /* @__PURE__ */ jsx4(Loader, {}) }),
|
3057
|
+
/* @__PURE__ */ jsx4(
|
3058
|
+
"div",
|
3059
|
+
{
|
3060
|
+
className: getClassName3("actionsOverlay"),
|
3061
|
+
style: {
|
3062
|
+
top: actionsOverlayTop / zoom
|
3063
|
+
},
|
3064
|
+
children: /* @__PURE__ */ jsx4(
|
2959
3065
|
"div",
|
2960
3066
|
{
|
2961
|
-
className: getClassName3("
|
3067
|
+
className: getClassName3("actions"),
|
2962
3068
|
style: {
|
2963
|
-
|
3069
|
+
transform: `scale(${1 / zoom}`,
|
3070
|
+
top: actionsTop / zoom,
|
3071
|
+
right: 0,
|
3072
|
+
paddingLeft: actionsSide,
|
3073
|
+
paddingRight: actionsSide
|
2964
3074
|
},
|
2965
|
-
|
2966
|
-
|
3075
|
+
ref: syncActionsPosition,
|
3076
|
+
children: /* @__PURE__ */ jsxs2(
|
3077
|
+
CustomActionBar,
|
2967
3078
|
{
|
2968
|
-
|
2969
|
-
|
2970
|
-
|
2971
|
-
|
2972
|
-
|
2973
|
-
|
2974
|
-
paddingRight: actionsSide
|
2975
|
-
},
|
2976
|
-
ref: syncActionsPosition,
|
2977
|
-
children: /* @__PURE__ */ jsxs2(
|
2978
|
-
CustomActionBar,
|
2979
|
-
{
|
2980
|
-
parentAction,
|
2981
|
-
label: DEBUG2 ? id : label,
|
2982
|
-
children: [
|
2983
|
-
permissions.duplicate && /* @__PURE__ */ jsx4(ActionBar.Action, { onClick: onDuplicate, label: "Duplicate", children: /* @__PURE__ */ jsx4(Copy, { size: 16 }) }),
|
2984
|
-
permissions.delete && /* @__PURE__ */ jsx4(ActionBar.Action, { onClick: onDelete, label: "Delete", children: /* @__PURE__ */ jsx4(Trash, { size: 16 }) })
|
2985
|
-
]
|
2986
|
-
}
|
2987
|
-
)
|
3079
|
+
parentAction,
|
3080
|
+
label: DEBUG2 ? id : label,
|
3081
|
+
children: [
|
3082
|
+
permissions.duplicate && /* @__PURE__ */ jsx4(ActionBar.Action, { onClick: onDuplicate, label: "Duplicate", children: /* @__PURE__ */ jsx4(Copy, { size: 16 }) }),
|
3083
|
+
permissions.delete && /* @__PURE__ */ jsx4(ActionBar.Action, { onClick: onDelete, label: "Delete", children: /* @__PURE__ */ jsx4(Trash, { size: 16 }) })
|
3084
|
+
]
|
2988
3085
|
}
|
2989
3086
|
)
|
2990
3087
|
}
|
2991
|
-
)
|
2992
|
-
|
2993
|
-
|
2994
|
-
}
|
2995
|
-
|
2996
|
-
|
2997
|
-
|
2998
|
-
|
2999
|
-
|
3000
|
-
|
3001
|
-
);
|
3088
|
+
)
|
3089
|
+
}
|
3090
|
+
),
|
3091
|
+
/* @__PURE__ */ jsx4("div", { className: getClassName3("overlay") })
|
3092
|
+
]
|
3093
|
+
}
|
3094
|
+
),
|
3095
|
+
portalEl || document.body
|
3096
|
+
),
|
3097
|
+
children(refSetter)
|
3098
|
+
] });
|
3002
3099
|
};
|
3003
3100
|
|
3004
3101
|
// css-module:/home/runner/work/puck/puck/packages/core/components/DropZone/styles.module.css#css-module
|
@@ -3025,7 +3122,7 @@ var getClassName4 = get_class_name_factory_default("DragIcon", styles_module_def
|
|
3025
3122
|
var DragIcon = ({ isDragDisabled }) => /* @__PURE__ */ jsx5("div", { className: getClassName4({ disabled: isDragDisabled }), children: /* @__PURE__ */ jsx5("svg", { viewBox: "0 0 20 20", width: "12", fill: "currentColor", children: /* @__PURE__ */ jsx5("path", { d: "M7 2a2 2 0 1 0 .001 4.001A2 2 0 0 0 7 2zm0 6a2 2 0 1 0 .001 4.001A2 2 0 0 0 7 8zm0 6a2 2 0 1 0 .001 4.001A2 2 0 0 0 7 14zm6-8a2 2 0 1 0-.001-4.001A2 2 0 0 0 13 6zm0 2a2 2 0 1 0 .001 4.001A2 2 0 0 0 13 8zm0 6a2 2 0 1 0 .001 4.001A2 2 0 0 0 13 14z" }) }) });
|
3026
3123
|
|
3027
3124
|
// components/Drawer/index.tsx
|
3028
|
-
import { useMemo as
|
3125
|
+
import { useMemo as useMemo5, useState as useState6 } from "react";
|
3029
3126
|
|
3030
3127
|
// components/DragDropContext/index.tsx
|
3031
3128
|
init_react_import();
|
@@ -3035,6 +3132,7 @@ import {
|
|
3035
3132
|
useCallback as useCallback4,
|
3036
3133
|
useContext as useContext4,
|
3037
3134
|
useEffect as useEffect6,
|
3135
|
+
useMemo as useMemo4,
|
3038
3136
|
useRef as useRef2,
|
3039
3137
|
useState as useState5
|
3040
3138
|
} from "react";
|
@@ -3310,8 +3408,8 @@ var insertComponent = (componentType, zone, index, appStore) => __async(void 0,
|
|
3310
3408
|
destinationZone: zone,
|
3311
3409
|
id
|
3312
3410
|
};
|
3313
|
-
const { state,
|
3314
|
-
const insertedState = insertAction(state, insertActionData,
|
3411
|
+
const { state, dispatch, resolveComponentData: resolveComponentData2 } = appStore;
|
3412
|
+
const insertedState = insertAction(state, insertActionData, appStore);
|
3315
3413
|
dispatch(__spreadProps(__spreadValues({}, insertActionData), {
|
3316
3414
|
// Dispatch insert rather set, as user's may rely on this via onAction
|
3317
3415
|
// We must always record history here so the insert is added to user history
|
@@ -3840,6 +3938,14 @@ var DragDropContextClient = ({
|
|
3840
3938
|
const [dragListeners, setDragListeners] = useState5({});
|
3841
3939
|
const dragMode = useRef2(null);
|
3842
3940
|
const initialSelector = useRef2(void 0);
|
3941
|
+
const nextContextValue = useMemo4(
|
3942
|
+
() => ({
|
3943
|
+
mode: "edit",
|
3944
|
+
areaId: "root",
|
3945
|
+
depth: 0
|
3946
|
+
}),
|
3947
|
+
[]
|
3948
|
+
);
|
3843
3949
|
return /* @__PURE__ */ jsx6("div", { id, children: /* @__PURE__ */ jsx6(
|
3844
3950
|
dragListenerContext.Provider,
|
3845
3951
|
{
|
@@ -3881,7 +3987,6 @@ var DragDropContextClient = ({
|
|
3881
3987
|
}
|
3882
3988
|
if (thisPreview) {
|
3883
3989
|
zoneStore.setState({ previewIndex: {} });
|
3884
|
-
const state = appStore.getState().state;
|
3885
3990
|
if (thisPreview.type === "insert") {
|
3886
3991
|
insertComponent(
|
3887
3992
|
thisPreview.componentType,
|
@@ -4038,17 +4143,7 @@ var DragDropContextClient = ({
|
|
4038
4143
|
initialSelector.current = void 0;
|
4039
4144
|
zoneStore.setState({ draggedItem: event.operation.source });
|
4040
4145
|
},
|
4041
|
-
children: /* @__PURE__ */ jsx6(ZoneStoreProvider, { store: zoneStore, children: /* @__PURE__ */ jsx6(
|
4042
|
-
DropZoneProvider,
|
4043
|
-
{
|
4044
|
-
value: {
|
4045
|
-
mode: "edit",
|
4046
|
-
areaId: "root",
|
4047
|
-
depth: 0
|
4048
|
-
},
|
4049
|
-
children
|
4050
|
-
}
|
4051
|
-
) })
|
4146
|
+
children: /* @__PURE__ */ jsx6(ZoneStoreProvider, { store: zoneStore, children: /* @__PURE__ */ jsx6(DropZoneProvider, { value: nextContextValue, children }) })
|
4052
4147
|
}
|
4053
4148
|
)
|
4054
4149
|
}
|
@@ -4076,7 +4171,7 @@ var DrawerItemInner = ({
|
|
4076
4171
|
dragRef,
|
4077
4172
|
isDragDisabled
|
4078
4173
|
}) => {
|
4079
|
-
const CustomInner =
|
4174
|
+
const CustomInner = useMemo5(
|
4080
4175
|
() => children || (({ children: children2 }) => /* @__PURE__ */ jsx7("div", { className: getClassNameItem("default"), children: children2 })),
|
4081
4176
|
[children]
|
4082
4177
|
);
|
@@ -4370,30 +4465,60 @@ init_react_import();
|
|
4370
4465
|
import { forwardRef as forwardRef3 } from "react";
|
4371
4466
|
import { jsx as jsx8 } from "react/jsx-runtime";
|
4372
4467
|
var SlotRenderPure = (props) => /* @__PURE__ */ jsx8(SlotRender, __spreadValues({}, props));
|
4468
|
+
var ContextSlotRender = ({
|
4469
|
+
componentId,
|
4470
|
+
zone
|
4471
|
+
}) => {
|
4472
|
+
const config = useAppStore((s) => s.config);
|
4473
|
+
const metadata = useAppStore((s) => s.metadata);
|
4474
|
+
const slotContent = useAppStore(
|
4475
|
+
(s) => {
|
4476
|
+
var _a, _b;
|
4477
|
+
return (_b = (_a = s.state.indexes.nodes[componentId]) == null ? void 0 : _a.data.props[zone]) != null ? _b : null;
|
4478
|
+
}
|
4479
|
+
);
|
4480
|
+
return /* @__PURE__ */ jsx8(
|
4481
|
+
SlotRenderPure,
|
4482
|
+
{
|
4483
|
+
content: slotContent,
|
4484
|
+
zone,
|
4485
|
+
config,
|
4486
|
+
metadata
|
4487
|
+
}
|
4488
|
+
);
|
4489
|
+
};
|
4490
|
+
var Item = ({
|
4491
|
+
config,
|
4492
|
+
item,
|
4493
|
+
metadata
|
4494
|
+
}) => {
|
4495
|
+
const Component = config.components[item.type];
|
4496
|
+
const props = useSlots(Component, item.props, (slotProps) => /* @__PURE__ */ jsx8(SlotRenderPure, __spreadProps(__spreadValues({}, slotProps), { config, metadata })));
|
4497
|
+
return /* @__PURE__ */ jsx8(
|
4498
|
+
Component.render,
|
4499
|
+
__spreadProps(__spreadValues({}, props), {
|
4500
|
+
puck: __spreadProps(__spreadValues({}, props.puck), {
|
4501
|
+
renderDropZone: DropZoneRenderPure,
|
4502
|
+
metadata: metadata || {}
|
4503
|
+
})
|
4504
|
+
})
|
4505
|
+
);
|
4506
|
+
};
|
4373
4507
|
var SlotRender = forwardRef3(
|
4374
4508
|
function SlotRenderInternal({ className, style, content, config, metadata }, ref) {
|
4375
4509
|
return /* @__PURE__ */ jsx8("div", { className, style, ref, children: content.map((item) => {
|
4376
|
-
|
4377
|
-
|
4378
|
-
const props = useSlots(Component, item.props, (slotProps) => /* @__PURE__ */ jsx8(
|
4379
|
-
SlotRenderPure,
|
4380
|
-
__spreadProps(__spreadValues({}, slotProps), {
|
4381
|
-
config,
|
4382
|
-
metadata
|
4383
|
-
})
|
4384
|
-
));
|
4385
|
-
return /* @__PURE__ */ jsx8(
|
4386
|
-
Component.render,
|
4387
|
-
__spreadProps(__spreadValues({}, props), {
|
4388
|
-
puck: {
|
4389
|
-
renderDropZone: DropZoneRenderPure,
|
4390
|
-
metadata: metadata || {}
|
4391
|
-
}
|
4392
|
-
}),
|
4393
|
-
props.id
|
4394
|
-
);
|
4510
|
+
if (!config.components[item.type]) {
|
4511
|
+
return null;
|
4395
4512
|
}
|
4396
|
-
return
|
4513
|
+
return /* @__PURE__ */ jsx8(
|
4514
|
+
Item,
|
4515
|
+
{
|
4516
|
+
config,
|
4517
|
+
item,
|
4518
|
+
metadata
|
4519
|
+
},
|
4520
|
+
item.props.id
|
4521
|
+
);
|
4397
4522
|
}) });
|
4398
4523
|
}
|
4399
4524
|
);
|
@@ -4416,14 +4541,8 @@ var DropZoneChild = ({
|
|
4416
4541
|
}) => {
|
4417
4542
|
var _a, _b;
|
4418
4543
|
const metadata = useAppStore((s) => s.metadata);
|
4419
|
-
const puckProps = {
|
4420
|
-
renderDropZone: DropZoneEditPure,
|
4421
|
-
isEditing: true,
|
4422
|
-
dragRef: null,
|
4423
|
-
metadata
|
4424
|
-
};
|
4425
4544
|
const ctx = useContext5(dropZoneContext);
|
4426
|
-
const { depth } = ctx;
|
4545
|
+
const { depth = 1 } = ctx != null ? ctx : {};
|
4427
4546
|
const nodeProps = useAppStore(
|
4428
4547
|
useShallow3((s) => {
|
4429
4548
|
var _a2;
|
@@ -4436,11 +4555,23 @@ var DropZoneChild = ({
|
|
4436
4555
|
return (_a2 = s.state.indexes.nodes[componentId]) == null ? void 0 : _a2.data.type;
|
4437
4556
|
}
|
4438
4557
|
);
|
4558
|
+
const nodeReadOnly = useAppStore(
|
4559
|
+
useShallow3((s) => {
|
4560
|
+
var _a2;
|
4561
|
+
return (_a2 = s.state.indexes.nodes[componentId]) == null ? void 0 : _a2.data.readOnly;
|
4562
|
+
})
|
4563
|
+
);
|
4439
4564
|
const node = { type: nodeType, props: nodeProps };
|
4440
4565
|
const item = nodeProps ? node : (preview == null ? void 0 : preview.componentType) ? { type: preview.componentType, props: preview.props } : null;
|
4441
4566
|
const componentConfig = useAppStore(
|
4442
4567
|
(s) => (item == null ? void 0 : item.type) ? s.config.components[item.type] : null
|
4443
4568
|
);
|
4569
|
+
const puckProps = {
|
4570
|
+
renderDropZone: DropZoneEditPure,
|
4571
|
+
isEditing: true,
|
4572
|
+
dragRef: null,
|
4573
|
+
metadata: __spreadValues(__spreadValues({}, metadata), componentConfig == null ? void 0 : componentConfig.metadata)
|
4574
|
+
};
|
4444
4575
|
const overrides = useAppStore((s) => s.overrides);
|
4445
4576
|
const isLoading = useAppStore(
|
4446
4577
|
(s) => {
|
@@ -4455,13 +4586,13 @@ var DropZoneChild = ({
|
|
4455
4586
|
}
|
4456
4587
|
);
|
4457
4588
|
let label = (_b = (_a = componentConfig == null ? void 0 : componentConfig.label) != null ? _a : item == null ? void 0 : item.type.toString()) != null ? _b : "Component";
|
4458
|
-
const renderPreview =
|
4589
|
+
const renderPreview = useMemo6(
|
4459
4590
|
() => function Preview3() {
|
4460
4591
|
return /* @__PURE__ */ jsx9(DrawerItemInner, { name: label, children: overrides.componentItem });
|
4461
4592
|
},
|
4462
4593
|
[componentId, label, overrides]
|
4463
4594
|
);
|
4464
|
-
const defaultsProps =
|
4595
|
+
const defaultsProps = useMemo6(
|
4465
4596
|
() => __spreadProps(__spreadValues(__spreadValues({}, componentConfig == null ? void 0 : componentConfig.defaultProps), item == null ? void 0 : item.props), {
|
4466
4597
|
puck: puckProps,
|
4467
4598
|
editMode: true
|
@@ -4472,7 +4603,10 @@ var DropZoneChild = ({
|
|
4472
4603
|
const defaultedPropsWithSlots = useSlots(
|
4473
4604
|
componentConfig,
|
4474
4605
|
defaultsProps,
|
4475
|
-
DropZoneEditPure
|
4606
|
+
DropZoneEditPure,
|
4607
|
+
(slotProps) => /* @__PURE__ */ jsx9(ContextSlotRender, { componentId, zone: slotProps.zone }),
|
4608
|
+
nodeReadOnly,
|
4609
|
+
isLoading
|
4476
4610
|
);
|
4477
4611
|
if (!item) return;
|
4478
4612
|
let Render2 = componentConfig ? componentConfig.render : () => /* @__PURE__ */ jsxs4("div", { style: { padding: 48, textAlign: "center" }, children: [
|
@@ -4510,6 +4644,7 @@ var DropZoneChild = ({
|
|
4510
4644
|
}
|
4511
4645
|
);
|
4512
4646
|
};
|
4647
|
+
var DropZoneChildMemo = memo(DropZoneChild);
|
4513
4648
|
var DropZoneEdit = forwardRef4(
|
4514
4649
|
function DropZoneEditInternal({
|
4515
4650
|
zone,
|
@@ -4524,10 +4659,10 @@ var DropZoneEdit = forwardRef4(
|
|
4524
4659
|
const {
|
4525
4660
|
// These all need setting via context
|
4526
4661
|
areaId,
|
4527
|
-
depth,
|
4662
|
+
depth = 0,
|
4528
4663
|
registerLocalZone,
|
4529
4664
|
unregisterLocalZone
|
4530
|
-
} = ctx;
|
4665
|
+
} = ctx != null ? ctx : {};
|
4531
4666
|
const path = useAppStore(
|
4532
4667
|
useShallow3((s) => {
|
4533
4668
|
var _a;
|
@@ -4569,6 +4704,11 @@ var DropZoneEdit = forwardRef4(
|
|
4569
4704
|
);
|
4570
4705
|
useEffect10(() => {
|
4571
4706
|
if (!zoneType || zoneType === "dropzone") {
|
4707
|
+
if (zoneCompound !== rootDroppableId) {
|
4708
|
+
console.warn(
|
4709
|
+
"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"
|
4710
|
+
);
|
4711
|
+
}
|
4572
4712
|
if (ctx == null ? void 0 : ctx.registerZone) {
|
4573
4713
|
ctx == null ? void 0 : ctx.registerZone(zoneCompound);
|
4574
4714
|
}
|
@@ -4579,7 +4719,7 @@ var DropZoneEdit = forwardRef4(
|
|
4579
4719
|
};
|
4580
4720
|
}
|
4581
4721
|
}, [zoneType]);
|
4582
|
-
const contentIds =
|
4722
|
+
const contentIds = useMemo6(() => {
|
4583
4723
|
return zoneContentIds || [];
|
4584
4724
|
}, [zoneContentIds]);
|
4585
4725
|
const ref = useRef3(null);
|
@@ -4674,7 +4814,7 @@ var DropZoneEdit = forwardRef4(
|
|
4674
4814
|
}),
|
4675
4815
|
children: contentIdsWithPreview.map((componentId, i) => {
|
4676
4816
|
return /* @__PURE__ */ jsx9(
|
4677
|
-
|
4817
|
+
DropZoneChildMemo,
|
4678
4818
|
{
|
4679
4819
|
zoneCompound,
|
4680
4820
|
componentId,
|
@@ -4692,6 +4832,30 @@ var DropZoneEdit = forwardRef4(
|
|
4692
4832
|
);
|
4693
4833
|
}
|
4694
4834
|
);
|
4835
|
+
var DropZoneRenderItem = ({
|
4836
|
+
config,
|
4837
|
+
item,
|
4838
|
+
metadata
|
4839
|
+
}) => {
|
4840
|
+
const Component = config.components[item.type];
|
4841
|
+
const props = useSlots(Component, item.props, (slotProps) => /* @__PURE__ */ jsx9(SlotRenderPure, __spreadProps(__spreadValues({}, slotProps), { config, metadata })));
|
4842
|
+
const nextContextValue = useMemo6(
|
4843
|
+
() => ({
|
4844
|
+
areaId: props.id,
|
4845
|
+
depth: 1
|
4846
|
+
}),
|
4847
|
+
[props]
|
4848
|
+
);
|
4849
|
+
return /* @__PURE__ */ jsx9(DropZoneProvider, { value: nextContextValue, children: /* @__PURE__ */ jsx9(
|
4850
|
+
Component.render,
|
4851
|
+
__spreadProps(__spreadValues({}, props), {
|
4852
|
+
puck: __spreadProps(__spreadValues({}, props.puck), {
|
4853
|
+
renderDropZone: DropZoneRenderPure,
|
4854
|
+
metadata: __spreadValues(__spreadValues({}, metadata), Component.metadata)
|
4855
|
+
})
|
4856
|
+
})
|
4857
|
+
) }, props.id);
|
4858
|
+
};
|
4695
4859
|
var DropZoneRenderPure = (props) => /* @__PURE__ */ jsx9(DropZoneRender, __spreadValues({}, props));
|
4696
4860
|
var DropZoneRender = forwardRef4(
|
4697
4861
|
function DropZoneRenderInternal({ className, style, zone }, ref) {
|
@@ -4722,31 +4886,14 @@ var DropZoneRender = forwardRef4(
|
|
4722
4886
|
return /* @__PURE__ */ jsx9("div", { className, style, ref, children: content.map((item) => {
|
4723
4887
|
const Component = config.components[item.type];
|
4724
4888
|
if (Component) {
|
4725
|
-
const props = useSlots(Component, item.props, (slotProps) => /* @__PURE__ */ jsx9(
|
4726
|
-
SlotRenderPure,
|
4727
|
-
__spreadProps(__spreadValues({}, slotProps), {
|
4728
|
-
config,
|
4729
|
-
metadata
|
4730
|
-
})
|
4731
|
-
));
|
4732
4889
|
return /* @__PURE__ */ jsx9(
|
4733
|
-
|
4890
|
+
DropZoneRenderItem,
|
4734
4891
|
{
|
4735
|
-
|
4736
|
-
|
4737
|
-
|
4738
|
-
},
|
4739
|
-
children: /* @__PURE__ */ jsx9(
|
4740
|
-
Component.render,
|
4741
|
-
__spreadProps(__spreadValues({}, props), {
|
4742
|
-
puck: {
|
4743
|
-
renderDropZone: DropZoneRenderPure,
|
4744
|
-
metadata: metadata || {}
|
4745
|
-
}
|
4746
|
-
})
|
4747
|
-
)
|
4892
|
+
config,
|
4893
|
+
item,
|
4894
|
+
metadata
|
4748
4895
|
},
|
4749
|
-
props.id
|
4896
|
+
item.props.id
|
4750
4897
|
);
|
4751
4898
|
}
|
4752
4899
|
return null;
|
@@ -4765,7 +4912,7 @@ var DropZone = forwardRef4(
|
|
4765
4912
|
);
|
4766
4913
|
|
4767
4914
|
// components/Render/index.tsx
|
4768
|
-
import React3 from "react";
|
4915
|
+
import React3, { useMemo as useMemo7 } from "react";
|
4769
4916
|
import { jsx as jsx10 } from "react/jsx-runtime";
|
4770
4917
|
var renderContext = React3.createContext({
|
4771
4918
|
config: { components: {} },
|
@@ -4796,34 +4943,23 @@ function Render({
|
|
4796
4943
|
id: "puck-root"
|
4797
4944
|
});
|
4798
4945
|
const propsWithSlots = useSlots(config.root, pageProps, (props) => /* @__PURE__ */ jsx10(SlotRender, __spreadProps(__spreadValues({}, props), { config, metadata })));
|
4946
|
+
const nextContextValue = useMemo7(
|
4947
|
+
() => ({
|
4948
|
+
mode: "render",
|
4949
|
+
depth: 0
|
4950
|
+
}),
|
4951
|
+
[]
|
4952
|
+
);
|
4799
4953
|
if ((_a = config.root) == null ? void 0 : _a.render) {
|
4800
|
-
return /* @__PURE__ */ jsx10(renderContext.Provider, { value: { config, data: defaultedData, metadata }, children: /* @__PURE__ */ jsx10(
|
4801
|
-
DropZoneProvider,
|
4802
|
-
{
|
4803
|
-
value: {
|
4804
|
-
mode: "render",
|
4805
|
-
depth: 0
|
4806
|
-
},
|
4807
|
-
children: /* @__PURE__ */ jsx10(config.root.render, __spreadProps(__spreadValues({}, propsWithSlots), { children: /* @__PURE__ */ jsx10(DropZoneRenderPure, { zone: rootZone }) }))
|
4808
|
-
}
|
4809
|
-
) });
|
4954
|
+
return /* @__PURE__ */ jsx10(renderContext.Provider, { value: { config, data: defaultedData, metadata }, children: /* @__PURE__ */ jsx10(DropZoneProvider, { value: nextContextValue, children: /* @__PURE__ */ jsx10(config.root.render, __spreadProps(__spreadValues({}, propsWithSlots), { children: /* @__PURE__ */ jsx10(DropZoneRenderPure, { zone: rootZone }) })) }) });
|
4810
4955
|
}
|
4811
|
-
return /* @__PURE__ */ jsx10(renderContext.Provider, { value: { config, data: defaultedData, metadata }, children: /* @__PURE__ */ jsx10(
|
4812
|
-
DropZoneProvider,
|
4813
|
-
{
|
4814
|
-
value: {
|
4815
|
-
mode: "render",
|
4816
|
-
depth: 0
|
4817
|
-
},
|
4818
|
-
children: /* @__PURE__ */ jsx10(DropZoneRenderPure, { zone: rootZone })
|
4819
|
-
}
|
4820
|
-
) });
|
4956
|
+
return /* @__PURE__ */ jsx10(renderContext.Provider, { value: { config, data: defaultedData, metadata }, children: /* @__PURE__ */ jsx10(DropZoneProvider, { value: nextContextValue, children: /* @__PURE__ */ jsx10(DropZoneRenderPure, { zone: rootZone }) }) });
|
4821
4957
|
}
|
4822
4958
|
|
4823
4959
|
// lib/transform-props.ts
|
4824
4960
|
init_react_import();
|
4825
4961
|
|
4826
|
-
// lib/default-data.ts
|
4962
|
+
// lib/data/default-data.ts
|
4827
4963
|
init_react_import();
|
4828
4964
|
var defaultData = (data) => __spreadProps(__spreadValues({}, data), {
|
4829
4965
|
root: data.root || {},
|
@@ -4866,7 +5002,7 @@ function transformProps(data, propTransforms) {
|
|
4866
5002
|
// lib/resolve-all-data.ts
|
4867
5003
|
init_react_import();
|
4868
5004
|
|
4869
|
-
// lib/to-component.ts
|
5005
|
+
// lib/data/to-component.ts
|
4870
5006
|
init_react_import();
|
4871
5007
|
var toComponent = (item) => {
|
4872
5008
|
return "type" in item ? item : __spreadProps(__spreadValues({}, item), {
|
@@ -4894,17 +5030,29 @@ function resolveAllData(_0, _1) {
|
|
4894
5030
|
"force",
|
4895
5031
|
false
|
4896
5032
|
)).node;
|
4897
|
-
const resolvedDeep = yield
|
5033
|
+
const resolvedDeep = yield mapSlotsAsync(
|
5034
|
+
resolved,
|
5035
|
+
processContent,
|
5036
|
+
false
|
5037
|
+
);
|
4898
5038
|
onResolveEnd == null ? void 0 : onResolveEnd(toComponent(resolvedDeep));
|
4899
5039
|
return resolvedDeep;
|
4900
5040
|
});
|
4901
5041
|
const processContent = (content) => __async(this, null, function* () {
|
4902
5042
|
return Promise.all(content.map(resolveNode));
|
4903
5043
|
});
|
5044
|
+
const processZones = () => __async(this, null, function* () {
|
5045
|
+
var _a2;
|
5046
|
+
const zones = (_a2 = data.zones) != null ? _a2 : {};
|
5047
|
+
Object.entries(zones).forEach((_02) => __async(this, [_02], function* ([zoneKey, content]) {
|
5048
|
+
zones[zoneKey] = yield Promise.all(content.map(resolveNode));
|
5049
|
+
}));
|
5050
|
+
return zones;
|
5051
|
+
});
|
4904
5052
|
const dynamic = {
|
4905
5053
|
root: yield resolveNode(defaultedData.root),
|
4906
5054
|
content: yield processContent(defaultedData.content),
|
4907
|
-
zones:
|
5055
|
+
zones: yield processZones()
|
4908
5056
|
};
|
4909
5057
|
Object.keys((_a = defaultedData.zones) != null ? _a : {}).forEach((zoneKey) => __async(this, null, function* () {
|
4910
5058
|
const content = defaultedData.zones[zoneKey];
|
@@ -4960,8 +5108,10 @@ export {
|
|
4960
5108
|
rootAreaId,
|
4961
5109
|
rootZone,
|
4962
5110
|
rootDroppableId,
|
4963
|
-
setupZone,
|
4964
5111
|
walkTree,
|
5112
|
+
getItem,
|
5113
|
+
setupZone,
|
5114
|
+
makeStatePublic,
|
4965
5115
|
defaultViewports,
|
4966
5116
|
monitorHotkeys,
|
4967
5117
|
useMonitorHotkeys,
|
@@ -4969,6 +5119,7 @@ export {
|
|
4969
5119
|
useRegisterHistorySlice,
|
4970
5120
|
useRegisterPermissionsSlice,
|
4971
5121
|
useRegisterFieldsSlice,
|
5122
|
+
mapSlotsPublic,
|
4972
5123
|
defaultAppState,
|
4973
5124
|
createAppStore,
|
4974
5125
|
appStoreContext,
|