@measured/puck 0.19.0-canary.427e686f → 0.19.0-canary.467a4bf6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{chunk-LKVFR7SK.mjs → chunk-LXKK52AO.mjs} +78 -74
- package/dist/index.d.mts +3 -3
- package/dist/index.d.ts +3 -3
- package/dist/index.js +32 -58
- package/dist/index.mjs +10 -44
- package/dist/rsc.js +14 -14
- 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
|
|
@@ -627,26 +689,11 @@ init_react_import();
|
|
627
689
|
// reducer/actions/set.ts
|
628
690
|
init_react_import();
|
629
691
|
|
630
|
-
// lib/data/walk-
|
692
|
+
// lib/data/walk-tree.ts
|
631
693
|
init_react_import();
|
632
694
|
|
633
695
|
// lib/data/for-each-slot.ts
|
634
696
|
init_react_import();
|
635
|
-
|
636
|
-
// lib/data/is-slot.ts
|
637
|
-
init_react_import();
|
638
|
-
var isSlot = (prop) => {
|
639
|
-
var _a, _b;
|
640
|
-
return Array.isArray(prop) && typeof ((_a = prop[0]) == null ? void 0 : _a.type) === "string" && typeof ((_b = prop[0]) == null ? void 0 : _b.props) === "object";
|
641
|
-
};
|
642
|
-
var createIsSlotConfig = (config) => (itemType, propName, propValue) => {
|
643
|
-
var _a, _b;
|
644
|
-
const configForComponent = itemType === "root" ? config == null ? void 0 : config.root : config == null ? void 0 : config.components[itemType];
|
645
|
-
if (!configForComponent) return isSlot(propValue);
|
646
|
-
return ((_b = (_a = configForComponent.fields) == null ? void 0 : _a[propName]) == null ? void 0 : _b.type) === "slot";
|
647
|
-
};
|
648
|
-
|
649
|
-
// lib/data/for-each-slot.ts
|
650
697
|
var forEachSlot = (item, cb, recursive = false, isSlot2 = isSlot) => {
|
651
698
|
const props = item.props || {};
|
652
699
|
const propKeys = Object.keys(props);
|
@@ -708,8 +755,8 @@ var stripSlots = (data) => {
|
|
708
755
|
});
|
709
756
|
};
|
710
757
|
|
711
|
-
// lib/data/walk-
|
712
|
-
function
|
758
|
+
// lib/data/walk-tree.ts
|
759
|
+
function walkTree(state, config, mapContent = (content) => content, mapNodeOrSkip = (item) => item) {
|
713
760
|
var _a;
|
714
761
|
let newZones = {};
|
715
762
|
const newZoneIndex = {};
|
@@ -842,7 +889,7 @@ var setAction = (state, action, appStore) => {
|
|
842
889
|
console.warn(
|
843
890
|
"`set` is expensive and may cause unnecessary re-renders. Consider using a more atomic action instead."
|
844
891
|
);
|
845
|
-
return
|
892
|
+
return walkTree(newState, appStore.config);
|
846
893
|
}
|
847
894
|
return __spreadValues(__spreadValues({}, state), action.state(state));
|
848
895
|
};
|
@@ -882,7 +929,7 @@ function insertAction(state, action, appStore) {
|
|
882
929
|
};
|
883
930
|
const [parentId] = action.destinationZone.split(":");
|
884
931
|
const idsInPath = getIdsForParent(action.destinationZone, state);
|
885
|
-
return
|
932
|
+
return walkTree(
|
886
933
|
state,
|
887
934
|
appStore.config,
|
888
935
|
(content, zoneCompound) => {
|
@@ -920,7 +967,7 @@ var replaceAction = (state, action, appStore) => {
|
|
920
967
|
`Can't change the id during a replace action. Please us "remove" and "insert" to define a new node.`
|
921
968
|
);
|
922
969
|
}
|
923
|
-
return
|
970
|
+
return walkTree(
|
924
971
|
state,
|
925
972
|
appStore.config,
|
926
973
|
(content, zoneCompound) => {
|
@@ -949,7 +996,7 @@ var replaceAction = (state, action, appStore) => {
|
|
949
996
|
// reducer/actions/replace-root.ts
|
950
997
|
init_react_import();
|
951
998
|
var replaceRootAction = (state, action, appStore) => {
|
952
|
-
return
|
999
|
+
return walkTree(
|
953
1000
|
state,
|
954
1001
|
appStore.config,
|
955
1002
|
(content) => content,
|
@@ -988,7 +1035,7 @@ function duplicateAction(state, action, appStore) {
|
|
988
1035
|
id: generateId(item.type)
|
989
1036
|
})
|
990
1037
|
});
|
991
|
-
const modified =
|
1038
|
+
const modified = walkTree(
|
992
1039
|
state,
|
993
1040
|
appStore.config,
|
994
1041
|
(content, zoneCompound) => {
|
@@ -1053,7 +1100,7 @@ var moveAction = (state, action, appStore) => {
|
|
1053
1100
|
if (!item) return state;
|
1054
1101
|
const idsInSourcePath = getIdsForParent(action.sourceZone, state);
|
1055
1102
|
const idsInDestinationPath = getIdsForParent(action.destinationZone, state);
|
1056
|
-
return
|
1103
|
+
return walkTree(
|
1057
1104
|
state,
|
1058
1105
|
appStore.config,
|
1059
1106
|
(content, zoneCompound) => {
|
@@ -1111,7 +1158,7 @@ var removeAction = (state, action, appStore) => {
|
|
1111
1158
|
},
|
1112
1159
|
[item.props.id]
|
1113
1160
|
);
|
1114
|
-
const newState =
|
1161
|
+
const newState = walkTree(
|
1115
1162
|
state,
|
1116
1163
|
appStore.config,
|
1117
1164
|
(content, zoneCompound) => {
|
@@ -1202,14 +1249,14 @@ var setDataAction = (state, action, appStore) => {
|
|
1202
1249
|
console.warn(
|
1203
1250
|
"`setData` is expensive and may cause unnecessary re-renders. Consider using a more atomic action instead."
|
1204
1251
|
);
|
1205
|
-
return
|
1252
|
+
return walkTree(
|
1206
1253
|
__spreadProps(__spreadValues({}, state), {
|
1207
1254
|
data: __spreadValues(__spreadValues({}, state.data), action.data)
|
1208
1255
|
}),
|
1209
1256
|
appStore.config
|
1210
1257
|
);
|
1211
1258
|
}
|
1212
|
-
return
|
1259
|
+
return walkTree(
|
1213
1260
|
__spreadProps(__spreadValues({}, state), {
|
1214
1261
|
data: __spreadValues(__spreadValues({}, state.data), action.data(state.data))
|
1215
1262
|
}),
|
@@ -1594,7 +1641,7 @@ import { useEffect as useEffect3 } from "react";
|
|
1594
1641
|
init_react_import();
|
1595
1642
|
var flattenData = (state, config) => {
|
1596
1643
|
const data = [];
|
1597
|
-
|
1644
|
+
walkTree(
|
1598
1645
|
state,
|
1599
1646
|
config,
|
1600
1647
|
(content) => content,
|
@@ -1830,48 +1877,6 @@ var useRegisterFieldsSlice = (appStore, id) => {
|
|
1830
1877
|
|
1831
1878
|
// lib/resolve-component-data.ts
|
1832
1879
|
init_react_import();
|
1833
|
-
|
1834
|
-
// lib/data/map-slots.ts
|
1835
|
-
init_react_import();
|
1836
|
-
function mapSlotsAsync(_0, _1) {
|
1837
|
-
return __async(this, arguments, function* (item, map, recursive = true, isSlot2 = isSlot) {
|
1838
|
-
const props = __spreadValues({}, item.props);
|
1839
|
-
const propKeys = Object.keys(props);
|
1840
|
-
for (let i = 0; i < propKeys.length; i++) {
|
1841
|
-
const propKey = propKeys[i];
|
1842
|
-
const itemType = "type" in item ? item.type : "root";
|
1843
|
-
if (isSlot2(itemType, propKey, props[propKey])) {
|
1844
|
-
const content = props[propKey];
|
1845
|
-
const mappedContent = recursive ? yield Promise.all(
|
1846
|
-
content.map((item2) => __async(this, null, function* () {
|
1847
|
-
return yield mapSlotsAsync(item2, map, recursive, isSlot2);
|
1848
|
-
}))
|
1849
|
-
) : content;
|
1850
|
-
props[propKey] = yield map(mappedContent, propKey);
|
1851
|
-
}
|
1852
|
-
}
|
1853
|
-
return __spreadProps(__spreadValues({}, item), { props });
|
1854
|
-
});
|
1855
|
-
}
|
1856
|
-
function mapSlotsSync(item, map, isSlot2 = isSlot) {
|
1857
|
-
var _a, _b;
|
1858
|
-
const props = __spreadValues({}, item.props);
|
1859
|
-
const propKeys = Object.keys(props);
|
1860
|
-
for (let i = 0; i < propKeys.length; i++) {
|
1861
|
-
const propKey = propKeys[i];
|
1862
|
-
const itemType = "type" in item ? item.type : "root";
|
1863
|
-
if (isSlot2(itemType, propKey, props[propKey])) {
|
1864
|
-
const content = props[propKey];
|
1865
|
-
const mappedContent = content.map((item2) => {
|
1866
|
-
return mapSlotsSync(item2, map, isSlot2);
|
1867
|
-
});
|
1868
|
-
props[propKey] = (_b = map(mappedContent, (_a = props.id) != null ? _a : "root", propKey)) != null ? _b : mappedContent;
|
1869
|
-
}
|
1870
|
-
}
|
1871
|
-
return __spreadProps(__spreadValues({}, item), { props });
|
1872
|
-
}
|
1873
|
-
|
1874
|
-
// lib/resolve-component-data.ts
|
1875
1880
|
import fdeq from "fast-deep-equal";
|
1876
1881
|
var cache = { lastChange: {} };
|
1877
1882
|
var resolveComponentData = (_0, _1, ..._2) => __async(void 0, [_0, _1, ..._2], function* (item, config, metadata = {}, onResolveStart, onResolveEnd, trigger = "replace", recursive = true) {
|
@@ -2116,7 +2121,7 @@ var createAppStore = (initialAppStore) => create2()(
|
|
2116
2121
|
}),
|
2117
2122
|
resolveAndCommitData: () => __async(void 0, null, function* () {
|
2118
2123
|
const { config, state, dispatch, resolveComponentData: resolveComponentData2 } = get();
|
2119
|
-
|
2124
|
+
walkTree(
|
2120
2125
|
state,
|
2121
2126
|
config,
|
2122
2127
|
(content) => content,
|
@@ -5100,11 +5105,10 @@ export {
|
|
5100
5105
|
replace,
|
5101
5106
|
Loader,
|
5102
5107
|
DragIcon,
|
5103
|
-
createIsSlotConfig,
|
5104
5108
|
rootAreaId,
|
5105
5109
|
rootZone,
|
5106
5110
|
rootDroppableId,
|
5107
|
-
|
5111
|
+
walkTree,
|
5108
5112
|
getItem,
|
5109
5113
|
setupZone,
|
5110
5114
|
makeStatePublic,
|
@@ -5115,7 +5119,7 @@ export {
|
|
5115
5119
|
useRegisterHistorySlice,
|
5116
5120
|
useRegisterPermissionsSlice,
|
5117
5121
|
useRegisterFieldsSlice,
|
5118
|
-
|
5122
|
+
mapSlotsPublic,
|
5119
5123
|
defaultAppState,
|
5120
5124
|
createAppStore,
|
5121
5125
|
appStoreContext,
|
package/dist/index.d.mts
CHANGED
@@ -248,11 +248,11 @@ declare function Render<UserConfig extends Config = Config, G extends UserGeneri
|
|
248
248
|
|
249
249
|
declare function migrate(data: Data, config?: Config): Data;
|
250
250
|
|
251
|
-
type
|
251
|
+
type MapSlotOptions = {
|
252
252
|
parentId: string;
|
253
253
|
propName: string;
|
254
254
|
};
|
255
|
-
declare function
|
255
|
+
declare function mapSlotsPublic<T extends ComponentData | RootData>(item: T, config: Config, map: (data: Content, options: MapSlotOptions) => Content): T;
|
256
256
|
|
257
257
|
type WithGet<T> = T & {
|
258
258
|
get: () => T;
|
@@ -292,4 +292,4 @@ type UsePuckStore<UserConfig extends Config = Config> = WithGet<PuckApi<UserConf
|
|
292
292
|
declare function createUsePuck<UserConfig extends Config = Config>(): <T = PuckApi<UserConfig>>(selector: (state: UsePuckStore<UserConfig>) => T) => T;
|
293
293
|
declare function usePuck<UserConfig extends Config = Config>(): UsePuckStore<UserConfig>;
|
294
294
|
|
295
|
-
export { Action, ActionBar, AppState, AutoField, Button, ComponentConfig, ComponentData, Config, Content, Data, Drawer, DropZone, Field, FieldLabel, FieldProps, Fields, Group, History, IconButton, IframeConfig, InitialHistory, Label, Metadata, OnAction, Overrides, Permissions, Plugin, Puck, PuckAction, type PuckApi, Render, ResolveDataTrigger, RootData, RootDataWithProps, UiState, type UsePuckData, UserGenerics, Viewports, createUsePuck, migrate, renderContext, usePuck
|
295
|
+
export { Action, ActionBar, AppState, AutoField, Button, ComponentConfig, ComponentData, Config, Content, Data, Drawer, DropZone, Field, FieldLabel, FieldProps, Fields, Group, History, IconButton, IframeConfig, InitialHistory, Label, Metadata, OnAction, Overrides, Permissions, Plugin, Puck, PuckAction, type PuckApi, Render, ResolveDataTrigger, RootData, RootDataWithProps, UiState, type UsePuckData, UserGenerics, Viewports, createUsePuck, mapSlotsPublic as mapSlots, migrate, renderContext, usePuck };
|
package/dist/index.d.ts
CHANGED
@@ -248,11 +248,11 @@ declare function Render<UserConfig extends Config = Config, G extends UserGeneri
|
|
248
248
|
|
249
249
|
declare function migrate(data: Data, config?: Config): Data;
|
250
250
|
|
251
|
-
type
|
251
|
+
type MapSlotOptions = {
|
252
252
|
parentId: string;
|
253
253
|
propName: string;
|
254
254
|
};
|
255
|
-
declare function
|
255
|
+
declare function mapSlotsPublic<T extends ComponentData | RootData>(item: T, config: Config, map: (data: Content, options: MapSlotOptions) => Content): T;
|
256
256
|
|
257
257
|
type WithGet<T> = T & {
|
258
258
|
get: () => T;
|
@@ -292,4 +292,4 @@ type UsePuckStore<UserConfig extends Config = Config> = WithGet<PuckApi<UserConf
|
|
292
292
|
declare function createUsePuck<UserConfig extends Config = Config>(): <T = PuckApi<UserConfig>>(selector: (state: UsePuckStore<UserConfig>) => T) => T;
|
293
293
|
declare function usePuck<UserConfig extends Config = Config>(): UsePuckStore<UserConfig>;
|
294
294
|
|
295
|
-
export { Action, ActionBar, AppState, AutoField, Button, ComponentConfig, ComponentData, Config, Content, Data, Drawer, DropZone, Field, FieldLabel, FieldProps, Fields, Group, History, IconButton, IframeConfig, InitialHistory, Label, Metadata, OnAction, Overrides, Permissions, Plugin, Puck, PuckAction, type PuckApi, Render, ResolveDataTrigger, RootData, RootDataWithProps, UiState, type UsePuckData, UserGenerics, Viewports, createUsePuck, migrate, renderContext, usePuck
|
295
|
+
export { Action, ActionBar, AppState, AutoField, Button, ComponentConfig, ComponentData, Config, Content, Data, Drawer, DropZone, Field, FieldLabel, FieldProps, Fields, Group, History, IconButton, IframeConfig, InitialHistory, Label, Metadata, OnAction, Overrides, Permissions, Plugin, Puck, PuckAction, type PuckApi, Render, ResolveDataTrigger, RootData, RootDataWithProps, UiState, type UsePuckData, UserGenerics, Viewports, createUsePuck, mapSlotsPublic as mapSlots, migrate, renderContext, usePuck };
|
package/dist/index.js
CHANGED
@@ -176,13 +176,13 @@ __export(core_exports, {
|
|
176
176
|
Puck: () => Puck,
|
177
177
|
Render: () => Render,
|
178
178
|
createUsePuck: () => createUsePuck,
|
179
|
+
mapSlots: () => mapSlotsPublic,
|
179
180
|
migrate: () => migrate,
|
180
181
|
overrideKeys: () => overrideKeys,
|
181
182
|
renderContext: () => renderContext,
|
182
183
|
resolveAllData: () => resolveAllData,
|
183
184
|
transformProps: () => transformProps,
|
184
|
-
usePuck: () => usePuck
|
185
|
-
walkTree: () => walkTree
|
185
|
+
usePuck: () => usePuck
|
186
186
|
});
|
187
187
|
module.exports = __toCommonJS(core_exports);
|
188
188
|
init_react_import();
|
@@ -795,7 +795,7 @@ init_react_import();
|
|
795
795
|
// reducer/actions/set.ts
|
796
796
|
init_react_import();
|
797
797
|
|
798
|
-
// lib/data/walk-
|
798
|
+
// lib/data/walk-tree.ts
|
799
799
|
init_react_import();
|
800
800
|
|
801
801
|
// lib/data/for-each-slot.ts
|
@@ -884,8 +884,8 @@ var stripSlots = (data) => {
|
|
884
884
|
});
|
885
885
|
};
|
886
886
|
|
887
|
-
// lib/data/walk-
|
888
|
-
function
|
887
|
+
// lib/data/walk-tree.ts
|
888
|
+
function walkTree(state, config, mapContent = (content) => content, mapNodeOrSkip = (item) => item) {
|
889
889
|
var _a;
|
890
890
|
let newZones = {};
|
891
891
|
const newZoneIndex = {};
|
@@ -1018,7 +1018,7 @@ var setAction = (state, action, appStore) => {
|
|
1018
1018
|
console.warn(
|
1019
1019
|
"`set` is expensive and may cause unnecessary re-renders. Consider using a more atomic action instead."
|
1020
1020
|
);
|
1021
|
-
return
|
1021
|
+
return walkTree(newState, appStore.config);
|
1022
1022
|
}
|
1023
1023
|
return __spreadValues(__spreadValues({}, state), action.state(state));
|
1024
1024
|
};
|
@@ -1058,7 +1058,7 @@ function insertAction(state, action, appStore) {
|
|
1058
1058
|
};
|
1059
1059
|
const [parentId] = action.destinationZone.split(":");
|
1060
1060
|
const idsInPath = getIdsForParent(action.destinationZone, state);
|
1061
|
-
return
|
1061
|
+
return walkTree(
|
1062
1062
|
state,
|
1063
1063
|
appStore.config,
|
1064
1064
|
(content, zoneCompound) => {
|
@@ -1096,7 +1096,7 @@ var replaceAction = (state, action, appStore) => {
|
|
1096
1096
|
`Can't change the id during a replace action. Please us "remove" and "insert" to define a new node.`
|
1097
1097
|
);
|
1098
1098
|
}
|
1099
|
-
return
|
1099
|
+
return walkTree(
|
1100
1100
|
state,
|
1101
1101
|
appStore.config,
|
1102
1102
|
(content, zoneCompound) => {
|
@@ -1125,7 +1125,7 @@ var replaceAction = (state, action, appStore) => {
|
|
1125
1125
|
// reducer/actions/replace-root.ts
|
1126
1126
|
init_react_import();
|
1127
1127
|
var replaceRootAction = (state, action, appStore) => {
|
1128
|
-
return
|
1128
|
+
return walkTree(
|
1129
1129
|
state,
|
1130
1130
|
appStore.config,
|
1131
1131
|
(content) => content,
|
@@ -1164,7 +1164,7 @@ function duplicateAction(state, action, appStore) {
|
|
1164
1164
|
id: generateId(item.type)
|
1165
1165
|
})
|
1166
1166
|
});
|
1167
|
-
const modified =
|
1167
|
+
const modified = walkTree(
|
1168
1168
|
state,
|
1169
1169
|
appStore.config,
|
1170
1170
|
(content, zoneCompound) => {
|
@@ -1229,7 +1229,7 @@ var moveAction = (state, action, appStore) => {
|
|
1229
1229
|
if (!item) return state;
|
1230
1230
|
const idsInSourcePath = getIdsForParent(action.sourceZone, state);
|
1231
1231
|
const idsInDestinationPath = getIdsForParent(action.destinationZone, state);
|
1232
|
-
return
|
1232
|
+
return walkTree(
|
1233
1233
|
state,
|
1234
1234
|
appStore.config,
|
1235
1235
|
(content, zoneCompound) => {
|
@@ -1287,7 +1287,7 @@ var removeAction = (state, action, appStore) => {
|
|
1287
1287
|
},
|
1288
1288
|
[item.props.id]
|
1289
1289
|
);
|
1290
|
-
const newState =
|
1290
|
+
const newState = walkTree(
|
1291
1291
|
state,
|
1292
1292
|
appStore.config,
|
1293
1293
|
(content, zoneCompound) => {
|
@@ -1378,14 +1378,14 @@ var setDataAction = (state, action, appStore) => {
|
|
1378
1378
|
console.warn(
|
1379
1379
|
"`setData` is expensive and may cause unnecessary re-renders. Consider using a more atomic action instead."
|
1380
1380
|
);
|
1381
|
-
return
|
1381
|
+
return walkTree(
|
1382
1382
|
__spreadProps(__spreadValues({}, state), {
|
1383
1383
|
data: __spreadValues(__spreadValues({}, state.data), action.data)
|
1384
1384
|
}),
|
1385
1385
|
appStore.config
|
1386
1386
|
);
|
1387
1387
|
}
|
1388
|
-
return
|
1388
|
+
return walkTree(
|
1389
1389
|
__spreadProps(__spreadValues({}, state), {
|
1390
1390
|
data: __spreadValues(__spreadValues({}, state.data), action.data(state.data))
|
1391
1391
|
}),
|
@@ -1770,7 +1770,7 @@ var import_react7 = require("react");
|
|
1770
1770
|
init_react_import();
|
1771
1771
|
var flattenData = (state, config) => {
|
1772
1772
|
const data = [];
|
1773
|
-
|
1773
|
+
walkTree(
|
1774
1774
|
state,
|
1775
1775
|
config,
|
1776
1776
|
(content) => content,
|
@@ -2030,7 +2030,6 @@ function mapSlotsAsync(_0, _1) {
|
|
2030
2030
|
});
|
2031
2031
|
}
|
2032
2032
|
function mapSlotsSync(item, map, isSlot2 = isSlot) {
|
2033
|
-
var _a, _b;
|
2034
2033
|
const props = __spreadValues({}, item.props);
|
2035
2034
|
const propKeys = Object.keys(props);
|
2036
2035
|
for (let i = 0; i < propKeys.length; i++) {
|
@@ -2041,11 +2040,19 @@ function mapSlotsSync(item, map, isSlot2 = isSlot) {
|
|
2041
2040
|
const mappedContent = content.map((item2) => {
|
2042
2041
|
return mapSlotsSync(item2, map, isSlot2);
|
2043
2042
|
});
|
2044
|
-
props[propKey] =
|
2043
|
+
props[propKey] = map(mappedContent, props.id, propKey);
|
2045
2044
|
}
|
2046
2045
|
}
|
2047
2046
|
return __spreadProps(__spreadValues({}, item), { props });
|
2048
2047
|
}
|
2048
|
+
function mapSlotsPublic(item, config, map) {
|
2049
|
+
const isSlot2 = createIsSlotConfig(config);
|
2050
|
+
return mapSlotsSync(
|
2051
|
+
item,
|
2052
|
+
(content, parentId, propName) => map(content, { parentId, propName }),
|
2053
|
+
isSlot2
|
2054
|
+
);
|
2055
|
+
}
|
2049
2056
|
|
2050
2057
|
// lib/resolve-component-data.ts
|
2051
2058
|
var import_fast_deep_equal = __toESM(require("fast-deep-equal"));
|
@@ -2292,7 +2299,7 @@ var createAppStore = (initialAppStore) => (0, import_zustand2.create)()(
|
|
2292
2299
|
}),
|
2293
2300
|
resolveAndCommitData: () => __async(void 0, null, function* () {
|
2294
2301
|
const { config, state, dispatch, resolveComponentData: resolveComponentData2 } = get();
|
2295
|
-
|
2302
|
+
walkTree(
|
2296
2303
|
state,
|
2297
2304
|
config,
|
2298
2305
|
(content) => content,
|
@@ -8273,7 +8280,7 @@ function PuckProvider({ children }) {
|
|
8273
8280
|
) : {}
|
8274
8281
|
})
|
8275
8282
|
});
|
8276
|
-
return
|
8283
|
+
return walkTree(newAppState, config);
|
8277
8284
|
});
|
8278
8285
|
const { appendData = true } = _initialHistory || {};
|
8279
8286
|
const [blendedHistories] = (0, import_react52.useState)(
|
@@ -8283,7 +8290,7 @@ function PuckProvider({ children }) {
|
|
8283
8290
|
].map((history) => {
|
8284
8291
|
let newState = __spreadValues(__spreadValues({}, generatedAppState), history.state);
|
8285
8292
|
if (!history.state.indexes) {
|
8286
|
-
newState =
|
8293
|
+
newState = walkTree(newState, config);
|
8287
8294
|
}
|
8288
8295
|
return __spreadProps(__spreadValues({}, history), {
|
8289
8296
|
state: newState
|
@@ -8624,9 +8631,9 @@ var migrations = [
|
|
8624
8631
|
console.log("Migrating DropZones to slots...");
|
8625
8632
|
const updatedItems = {};
|
8626
8633
|
const appState = __spreadProps(__spreadValues({}, defaultAppState), { data });
|
8627
|
-
const { indexes } =
|
8634
|
+
const { indexes } = walkTree(appState, config);
|
8628
8635
|
const deletedCompounds = [];
|
8629
|
-
|
8636
|
+
walkTree(appState, config, (content, zoneCompound, zoneType) => {
|
8630
8637
|
var _a2, _b;
|
8631
8638
|
if (zoneType === "dropzone") {
|
8632
8639
|
const [id, slotName] = zoneCompound.split(":");
|
@@ -8645,7 +8652,7 @@ var migrations = [
|
|
8645
8652
|
}
|
8646
8653
|
return content;
|
8647
8654
|
});
|
8648
|
-
const updated =
|
8655
|
+
const updated = walkTree(
|
8649
8656
|
appState,
|
8650
8657
|
config,
|
8651
8658
|
(content) => content,
|
@@ -8784,39 +8791,6 @@ function resolveAllData(_0, _1) {
|
|
8784
8791
|
return dynamic;
|
8785
8792
|
});
|
8786
8793
|
}
|
8787
|
-
|
8788
|
-
// lib/data/walk-tree.ts
|
8789
|
-
init_react_import();
|
8790
|
-
function walkTree(data, config, callbackFn) {
|
8791
|
-
var _a, _b;
|
8792
|
-
const isSlot2 = createIsSlotConfig(config);
|
8793
|
-
const walkItem = (item) => {
|
8794
|
-
return mapSlotsSync(
|
8795
|
-
item,
|
8796
|
-
(content, parentId, propName) => callbackFn(content, { parentId, propName }),
|
8797
|
-
isSlot2
|
8798
|
-
);
|
8799
|
-
};
|
8800
|
-
if ("props" in data) {
|
8801
|
-
return walkItem(data);
|
8802
|
-
}
|
8803
|
-
const _data = data;
|
8804
|
-
const zones = (_a = _data.zones) != null ? _a : {};
|
8805
|
-
const mappedContent = _data.content.map(walkItem);
|
8806
|
-
return {
|
8807
|
-
root: walkItem(_data.root),
|
8808
|
-
content: (_b = callbackFn(mappedContent, {
|
8809
|
-
parentId: "root",
|
8810
|
-
propName: "default-zone"
|
8811
|
-
})) != null ? _b : mappedContent,
|
8812
|
-
zones: Object.keys(zones).reduce(
|
8813
|
-
(acc, zoneCompound) => __spreadProps(__spreadValues({}, acc), {
|
8814
|
-
[zoneCompound]: zones[zoneCompound].map(walkItem)
|
8815
|
-
}),
|
8816
|
-
{}
|
8817
|
-
)
|
8818
|
-
};
|
8819
|
-
}
|
8820
8794
|
// Annotate the CommonJS export names for ESM import in node:
|
8821
8795
|
0 && (module.exports = {
|
8822
8796
|
Action,
|
@@ -8832,13 +8806,13 @@ function walkTree(data, config, callbackFn) {
|
|
8832
8806
|
Puck,
|
8833
8807
|
Render,
|
8834
8808
|
createUsePuck,
|
8809
|
+
mapSlots,
|
8835
8810
|
migrate,
|
8836
8811
|
overrideKeys,
|
8837
8812
|
renderContext,
|
8838
8813
|
resolveAllData,
|
8839
8814
|
transformProps,
|
8840
|
-
usePuck
|
8841
|
-
walkTree
|
8815
|
+
usePuck
|
8842
8816
|
});
|
8843
8817
|
/*! Bundled license information:
|
8844
8818
|
|
package/dist/index.mjs
CHANGED
@@ -47,7 +47,6 @@ import {
|
|
47
47
|
appStoreContext,
|
48
48
|
createAppStore,
|
49
49
|
createDynamicCollisionDetector,
|
50
|
-
createIsSlotConfig,
|
51
50
|
defaultAppState,
|
52
51
|
defaultViewports,
|
53
52
|
dropZoneContext,
|
@@ -56,7 +55,7 @@ import {
|
|
56
55
|
get_class_name_factory_default,
|
57
56
|
init_react_import,
|
58
57
|
makeStatePublic,
|
59
|
-
|
58
|
+
mapSlotsPublic,
|
60
59
|
monitorHotkeys,
|
61
60
|
renderContext,
|
62
61
|
reorder,
|
@@ -75,8 +74,8 @@ import {
|
|
75
74
|
useSensors,
|
76
75
|
useSlots,
|
77
76
|
useSortableSafe,
|
78
|
-
|
79
|
-
} from "./chunk-
|
77
|
+
walkTree
|
78
|
+
} from "./chunk-LXKK52AO.mjs";
|
80
79
|
|
81
80
|
// index.ts
|
82
81
|
init_react_import();
|
@@ -3436,7 +3435,7 @@ function PuckProvider({ children }) {
|
|
3436
3435
|
) : {}
|
3437
3436
|
})
|
3438
3437
|
});
|
3439
|
-
return
|
3438
|
+
return walkTree(newAppState, config);
|
3440
3439
|
});
|
3441
3440
|
const { appendData = true } = _initialHistory || {};
|
3442
3441
|
const [blendedHistories] = useState13(
|
@@ -3446,7 +3445,7 @@ function PuckProvider({ children }) {
|
|
3446
3445
|
].map((history) => {
|
3447
3446
|
let newState = __spreadValues(__spreadValues({}, generatedAppState), history.state);
|
3448
3447
|
if (!history.state.indexes) {
|
3449
|
-
newState =
|
3448
|
+
newState = walkTree(newState, config);
|
3450
3449
|
}
|
3451
3450
|
return __spreadProps(__spreadValues({}, history), {
|
3452
3451
|
state: newState
|
@@ -3787,9 +3786,9 @@ var migrations = [
|
|
3787
3786
|
console.log("Migrating DropZones to slots...");
|
3788
3787
|
const updatedItems = {};
|
3789
3788
|
const appState = __spreadProps(__spreadValues({}, defaultAppState), { data });
|
3790
|
-
const { indexes } =
|
3789
|
+
const { indexes } = walkTree(appState, config);
|
3791
3790
|
const deletedCompounds = [];
|
3792
|
-
|
3791
|
+
walkTree(appState, config, (content, zoneCompound, zoneType) => {
|
3793
3792
|
var _a2, _b;
|
3794
3793
|
if (zoneType === "dropzone") {
|
3795
3794
|
const [id, slotName] = zoneCompound.split(":");
|
@@ -3808,7 +3807,7 @@ var migrations = [
|
|
3808
3807
|
}
|
3809
3808
|
return content;
|
3810
3809
|
});
|
3811
|
-
const updated =
|
3810
|
+
const updated = walkTree(
|
3812
3811
|
appState,
|
3813
3812
|
config,
|
3814
3813
|
(content) => content,
|
@@ -3841,39 +3840,6 @@ function migrate(data, config) {
|
|
3841
3840
|
data
|
3842
3841
|
);
|
3843
3842
|
}
|
3844
|
-
|
3845
|
-
// lib/data/walk-tree.ts
|
3846
|
-
init_react_import();
|
3847
|
-
function walkTree(data, config, callbackFn) {
|
3848
|
-
var _a, _b;
|
3849
|
-
const isSlot = createIsSlotConfig(config);
|
3850
|
-
const walkItem = (item) => {
|
3851
|
-
return mapSlotsSync(
|
3852
|
-
item,
|
3853
|
-
(content, parentId, propName) => callbackFn(content, { parentId, propName }),
|
3854
|
-
isSlot
|
3855
|
-
);
|
3856
|
-
};
|
3857
|
-
if ("props" in data) {
|
3858
|
-
return walkItem(data);
|
3859
|
-
}
|
3860
|
-
const _data = data;
|
3861
|
-
const zones = (_a = _data.zones) != null ? _a : {};
|
3862
|
-
const mappedContent = _data.content.map(walkItem);
|
3863
|
-
return {
|
3864
|
-
root: walkItem(_data.root),
|
3865
|
-
content: (_b = callbackFn(mappedContent, {
|
3866
|
-
parentId: "root",
|
3867
|
-
propName: "default-zone"
|
3868
|
-
})) != null ? _b : mappedContent,
|
3869
|
-
zones: Object.keys(zones).reduce(
|
3870
|
-
(acc, zoneCompound) => __spreadProps(__spreadValues({}, acc), {
|
3871
|
-
[zoneCompound]: zones[zoneCompound].map(walkItem)
|
3872
|
-
}),
|
3873
|
-
{}
|
3874
|
-
)
|
3875
|
-
};
|
3876
|
-
}
|
3877
3843
|
export {
|
3878
3844
|
Action,
|
3879
3845
|
ActionBar,
|
@@ -3888,11 +3854,11 @@ export {
|
|
3888
3854
|
Puck,
|
3889
3855
|
Render,
|
3890
3856
|
createUsePuck,
|
3857
|
+
mapSlotsPublic as mapSlots,
|
3891
3858
|
migrate,
|
3892
3859
|
overrideKeys,
|
3893
3860
|
renderContext,
|
3894
3861
|
resolveAllData,
|
3895
3862
|
transformProps,
|
3896
|
-
usePuck
|
3897
|
-
walkTree
|
3863
|
+
usePuck
|
3898
3864
|
};
|
package/dist/rsc.js
CHANGED
@@ -382,7 +382,7 @@ init_react_import();
|
|
382
382
|
// reducer/actions/set.ts
|
383
383
|
init_react_import();
|
384
384
|
|
385
|
-
// lib/data/walk-
|
385
|
+
// lib/data/walk-tree.ts
|
386
386
|
init_react_import();
|
387
387
|
|
388
388
|
// lib/data/for-each-slot.ts
|
@@ -463,8 +463,8 @@ var stripSlots = (data) => {
|
|
463
463
|
});
|
464
464
|
};
|
465
465
|
|
466
|
-
// lib/data/walk-
|
467
|
-
function
|
466
|
+
// lib/data/walk-tree.ts
|
467
|
+
function walkTree(state, config, mapContent = (content) => content, mapNodeOrSkip = (item) => item) {
|
468
468
|
var _a;
|
469
469
|
let newZones = {};
|
470
470
|
const newZoneIndex = {};
|
@@ -597,7 +597,7 @@ var setAction = (state, action, appStore) => {
|
|
597
597
|
console.warn(
|
598
598
|
"`set` is expensive and may cause unnecessary re-renders. Consider using a more atomic action instead."
|
599
599
|
);
|
600
|
-
return
|
600
|
+
return walkTree(newState, appStore.config);
|
601
601
|
}
|
602
602
|
return __spreadValues(__spreadValues({}, state), action.state(state));
|
603
603
|
};
|
@@ -637,7 +637,7 @@ function insertAction(state, action, appStore) {
|
|
637
637
|
};
|
638
638
|
const [parentId] = action.destinationZone.split(":");
|
639
639
|
const idsInPath = getIdsForParent(action.destinationZone, state);
|
640
|
-
return
|
640
|
+
return walkTree(
|
641
641
|
state,
|
642
642
|
appStore.config,
|
643
643
|
(content, zoneCompound) => {
|
@@ -675,7 +675,7 @@ var replaceAction = (state, action, appStore) => {
|
|
675
675
|
`Can't change the id during a replace action. Please us "remove" and "insert" to define a new node.`
|
676
676
|
);
|
677
677
|
}
|
678
|
-
return
|
678
|
+
return walkTree(
|
679
679
|
state,
|
680
680
|
appStore.config,
|
681
681
|
(content, zoneCompound) => {
|
@@ -704,7 +704,7 @@ var replaceAction = (state, action, appStore) => {
|
|
704
704
|
// reducer/actions/replace-root.ts
|
705
705
|
init_react_import();
|
706
706
|
var replaceRootAction = (state, action, appStore) => {
|
707
|
-
return
|
707
|
+
return walkTree(
|
708
708
|
state,
|
709
709
|
appStore.config,
|
710
710
|
(content) => content,
|
@@ -743,7 +743,7 @@ function duplicateAction(state, action, appStore) {
|
|
743
743
|
id: generateId(item.type)
|
744
744
|
})
|
745
745
|
});
|
746
|
-
const modified =
|
746
|
+
const modified = walkTree(
|
747
747
|
state,
|
748
748
|
appStore.config,
|
749
749
|
(content, zoneCompound) => {
|
@@ -808,7 +808,7 @@ var moveAction = (state, action, appStore) => {
|
|
808
808
|
if (!item) return state;
|
809
809
|
const idsInSourcePath = getIdsForParent(action.sourceZone, state);
|
810
810
|
const idsInDestinationPath = getIdsForParent(action.destinationZone, state);
|
811
|
-
return
|
811
|
+
return walkTree(
|
812
812
|
state,
|
813
813
|
appStore.config,
|
814
814
|
(content, zoneCompound) => {
|
@@ -866,7 +866,7 @@ var removeAction = (state, action, appStore) => {
|
|
866
866
|
},
|
867
867
|
[item.props.id]
|
868
868
|
);
|
869
|
-
const newState =
|
869
|
+
const newState = walkTree(
|
870
870
|
state,
|
871
871
|
appStore.config,
|
872
872
|
(content, zoneCompound) => {
|
@@ -942,14 +942,14 @@ var setDataAction = (state, action, appStore) => {
|
|
942
942
|
console.warn(
|
943
943
|
"`setData` is expensive and may cause unnecessary re-renders. Consider using a more atomic action instead."
|
944
944
|
);
|
945
|
-
return
|
945
|
+
return walkTree(
|
946
946
|
__spreadProps(__spreadValues({}, state), {
|
947
947
|
data: __spreadValues(__spreadValues({}, state.data), action.data)
|
948
948
|
}),
|
949
949
|
appStore.config
|
950
950
|
);
|
951
951
|
}
|
952
|
-
return
|
952
|
+
return walkTree(
|
953
953
|
__spreadProps(__spreadValues({}, state), {
|
954
954
|
data: __spreadValues(__spreadValues({}, state.data), action.data(state.data))
|
955
955
|
}),
|
@@ -1220,7 +1220,7 @@ var import_react7 = require("react");
|
|
1220
1220
|
init_react_import();
|
1221
1221
|
var flattenData = (state, config) => {
|
1222
1222
|
const data = [];
|
1223
|
-
|
1223
|
+
walkTree(
|
1224
1224
|
state,
|
1225
1225
|
config,
|
1226
1226
|
(content) => content,
|
@@ -1632,7 +1632,7 @@ var createAppStore = (initialAppStore) => (0, import_zustand2.create)()(
|
|
1632
1632
|
}),
|
1633
1633
|
resolveAndCommitData: () => __async(void 0, null, function* () {
|
1634
1634
|
const { config, state, dispatch, resolveComponentData: resolveComponentData2 } = get();
|
1635
|
-
|
1635
|
+
walkTree(
|
1636
1636
|
state,
|
1637
1637
|
config,
|
1638
1638
|
(content) => content,
|
package/dist/rsc.mjs
CHANGED
package/package.json
CHANGED