@measured/puck 0.19.0-canary.39958756 → 0.19.0-canary.427e686f
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 -4
- package/dist/{chunk-ZOHJNF5K.mjs → chunk-LKVFR7SK.mjs} +75 -79
- package/dist/index.d.mts +4 -4
- package/dist/index.d.ts +4 -4
- package/dist/index.js +59 -33
- package/dist/index.mjs +44 -10
- package/dist/rsc.js +14 -14
- package/dist/rsc.mjs +1 -1
- package/package.json +2 -2
package/README.md
CHANGED
@@ -3,9 +3,6 @@
|
|
3
3
|
The visual editor for React.
|
4
4
|
|
5
5
|
<p align="left">
|
6
|
-
<a aria-label="Measured logo" href="https://measured.co">
|
7
|
-
<img src="https://img.shields.io/badge/MADE%20BY%20Measured-000000.svg?style=for-the-badge&labelColor=000">
|
8
|
-
</a>
|
9
6
|
<a aria-label="NPM version" href="https://www.npmjs.com/package/@measured/puck">
|
10
7
|
<img alt="" src="https://img.shields.io/npm/v/@measured/puck.svg?style=for-the-badge&labelColor=000000">
|
11
8
|
</a>
|
@@ -110,4 +107,4 @@ Or [book a discovery call](https://app.cal.com/chrisvxd/puck-enquiry/) for hands
|
|
110
107
|
|
111
108
|
## License
|
112
109
|
|
113
|
-
MIT © [
|
110
|
+
MIT © [The Puck Contributors](https://github.com/measuredco/puck/graphs/contributors)
|
@@ -226,68 +226,6 @@ 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
|
-
|
291
229
|
// components/Render/index.tsx
|
292
230
|
init_react_import();
|
293
231
|
|
@@ -689,11 +627,26 @@ init_react_import();
|
|
689
627
|
// reducer/actions/set.ts
|
690
628
|
init_react_import();
|
691
629
|
|
692
|
-
// lib/data/walk-
|
630
|
+
// lib/data/walk-app-state.ts
|
693
631
|
init_react_import();
|
694
632
|
|
695
633
|
// lib/data/for-each-slot.ts
|
696
634
|
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
|
697
650
|
var forEachSlot = (item, cb, recursive = false, isSlot2 = isSlot) => {
|
698
651
|
const props = item.props || {};
|
699
652
|
const propKeys = Object.keys(props);
|
@@ -755,8 +708,8 @@ var stripSlots = (data) => {
|
|
755
708
|
});
|
756
709
|
};
|
757
710
|
|
758
|
-
// lib/data/walk-
|
759
|
-
function
|
711
|
+
// lib/data/walk-app-state.ts
|
712
|
+
function walkAppState(state, config, mapContent = (content) => content, mapNodeOrSkip = (item) => item) {
|
760
713
|
var _a;
|
761
714
|
let newZones = {};
|
762
715
|
const newZoneIndex = {};
|
@@ -889,7 +842,7 @@ var setAction = (state, action, appStore) => {
|
|
889
842
|
console.warn(
|
890
843
|
"`set` is expensive and may cause unnecessary re-renders. Consider using a more atomic action instead."
|
891
844
|
);
|
892
|
-
return
|
845
|
+
return walkAppState(newState, appStore.config);
|
893
846
|
}
|
894
847
|
return __spreadValues(__spreadValues({}, state), action.state(state));
|
895
848
|
};
|
@@ -929,7 +882,7 @@ function insertAction(state, action, appStore) {
|
|
929
882
|
};
|
930
883
|
const [parentId] = action.destinationZone.split(":");
|
931
884
|
const idsInPath = getIdsForParent(action.destinationZone, state);
|
932
|
-
return
|
885
|
+
return walkAppState(
|
933
886
|
state,
|
934
887
|
appStore.config,
|
935
888
|
(content, zoneCompound) => {
|
@@ -967,7 +920,7 @@ var replaceAction = (state, action, appStore) => {
|
|
967
920
|
`Can't change the id during a replace action. Please us "remove" and "insert" to define a new node.`
|
968
921
|
);
|
969
922
|
}
|
970
|
-
return
|
923
|
+
return walkAppState(
|
971
924
|
state,
|
972
925
|
appStore.config,
|
973
926
|
(content, zoneCompound) => {
|
@@ -996,7 +949,7 @@ var replaceAction = (state, action, appStore) => {
|
|
996
949
|
// reducer/actions/replace-root.ts
|
997
950
|
init_react_import();
|
998
951
|
var replaceRootAction = (state, action, appStore) => {
|
999
|
-
return
|
952
|
+
return walkAppState(
|
1000
953
|
state,
|
1001
954
|
appStore.config,
|
1002
955
|
(content) => content,
|
@@ -1035,7 +988,7 @@ function duplicateAction(state, action, appStore) {
|
|
1035
988
|
id: generateId(item.type)
|
1036
989
|
})
|
1037
990
|
});
|
1038
|
-
const modified =
|
991
|
+
const modified = walkAppState(
|
1039
992
|
state,
|
1040
993
|
appStore.config,
|
1041
994
|
(content, zoneCompound) => {
|
@@ -1100,7 +1053,7 @@ var moveAction = (state, action, appStore) => {
|
|
1100
1053
|
if (!item) return state;
|
1101
1054
|
const idsInSourcePath = getIdsForParent(action.sourceZone, state);
|
1102
1055
|
const idsInDestinationPath = getIdsForParent(action.destinationZone, state);
|
1103
|
-
return
|
1056
|
+
return walkAppState(
|
1104
1057
|
state,
|
1105
1058
|
appStore.config,
|
1106
1059
|
(content, zoneCompound) => {
|
@@ -1158,7 +1111,7 @@ var removeAction = (state, action, appStore) => {
|
|
1158
1111
|
},
|
1159
1112
|
[item.props.id]
|
1160
1113
|
);
|
1161
|
-
const newState =
|
1114
|
+
const newState = walkAppState(
|
1162
1115
|
state,
|
1163
1116
|
appStore.config,
|
1164
1117
|
(content, zoneCompound) => {
|
@@ -1249,14 +1202,14 @@ var setDataAction = (state, action, appStore) => {
|
|
1249
1202
|
console.warn(
|
1250
1203
|
"`setData` is expensive and may cause unnecessary re-renders. Consider using a more atomic action instead."
|
1251
1204
|
);
|
1252
|
-
return
|
1205
|
+
return walkAppState(
|
1253
1206
|
__spreadProps(__spreadValues({}, state), {
|
1254
1207
|
data: __spreadValues(__spreadValues({}, state.data), action.data)
|
1255
1208
|
}),
|
1256
1209
|
appStore.config
|
1257
1210
|
);
|
1258
1211
|
}
|
1259
|
-
return
|
1212
|
+
return walkAppState(
|
1260
1213
|
__spreadProps(__spreadValues({}, state), {
|
1261
1214
|
data: __spreadValues(__spreadValues({}, state.data), action.data(state.data))
|
1262
1215
|
}),
|
@@ -1641,7 +1594,7 @@ import { useEffect as useEffect3 } from "react";
|
|
1641
1594
|
init_react_import();
|
1642
1595
|
var flattenData = (state, config) => {
|
1643
1596
|
const data = [];
|
1644
|
-
|
1597
|
+
walkAppState(
|
1645
1598
|
state,
|
1646
1599
|
config,
|
1647
1600
|
(content) => content,
|
@@ -1877,6 +1830,48 @@ var useRegisterFieldsSlice = (appStore, id) => {
|
|
1877
1830
|
|
1878
1831
|
// lib/resolve-component-data.ts
|
1879
1832
|
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
|
1880
1875
|
import fdeq from "fast-deep-equal";
|
1881
1876
|
var cache = { lastChange: {} };
|
1882
1877
|
var resolveComponentData = (_0, _1, ..._2) => __async(void 0, [_0, _1, ..._2], function* (item, config, metadata = {}, onResolveStart, onResolveEnd, trigger = "replace", recursive = true) {
|
@@ -2121,7 +2116,7 @@ var createAppStore = (initialAppStore) => create2()(
|
|
2121
2116
|
}),
|
2122
2117
|
resolveAndCommitData: () => __async(void 0, null, function* () {
|
2123
2118
|
const { config, state, dispatch, resolveComponentData: resolveComponentData2 } = get();
|
2124
|
-
|
2119
|
+
walkAppState(
|
2125
2120
|
state,
|
2126
2121
|
config,
|
2127
2122
|
(content) => content,
|
@@ -3190,7 +3185,7 @@ var GlobalPosition = class {
|
|
3190
3185
|
var _a;
|
3191
3186
|
this.target = target;
|
3192
3187
|
this.original = original;
|
3193
|
-
this.frameEl = document.querySelector("
|
3188
|
+
this.frameEl = document.querySelector("#preview-frame");
|
3194
3189
|
if (this.frameEl) {
|
3195
3190
|
this.frameRect = this.frameEl.getBoundingClientRect();
|
3196
3191
|
this.scaleFactor = this.frameRect.width / (((_a = this.frameEl.contentWindow) == null ? void 0 : _a.innerWidth) || 1);
|
@@ -5105,10 +5100,11 @@ export {
|
|
5105
5100
|
replace,
|
5106
5101
|
Loader,
|
5107
5102
|
DragIcon,
|
5103
|
+
createIsSlotConfig,
|
5108
5104
|
rootAreaId,
|
5109
5105
|
rootZone,
|
5110
5106
|
rootDroppableId,
|
5111
|
-
|
5107
|
+
walkAppState,
|
5112
5108
|
getItem,
|
5113
5109
|
setupZone,
|
5114
5110
|
makeStatePublic,
|
@@ -5119,7 +5115,7 @@ export {
|
|
5119
5115
|
useRegisterHistorySlice,
|
5120
5116
|
useRegisterPermissionsSlice,
|
5121
5117
|
useRegisterFieldsSlice,
|
5122
|
-
|
5118
|
+
mapSlotsSync,
|
5123
5119
|
defaultAppState,
|
5124
5120
|
createAppStore,
|
5125
5121
|
appStoreContext,
|
package/dist/index.d.mts
CHANGED
@@ -248,18 +248,18 @@ 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 WalkTreeOptions = {
|
252
252
|
parentId: string;
|
253
253
|
propName: string;
|
254
254
|
};
|
255
|
-
declare function
|
255
|
+
declare function walkTree<T extends ComponentData | RootData | G["UserData"], UserConfig extends Config = Config, G extends UserGenerics<UserConfig> = UserGenerics<UserConfig>>(data: T, config: UserConfig, callbackFn: (data: Content, options: WalkTreeOptions) => Content | null | void): T;
|
256
256
|
|
257
257
|
type WithGet<T> = T & {
|
258
258
|
get: () => T;
|
259
259
|
};
|
260
260
|
type UsePuckData<UserConfig extends Config = Config, G extends UserGenerics<UserConfig> = UserGenerics<UserConfig>> = {
|
261
261
|
appState: AppState;
|
262
|
-
config:
|
262
|
+
config: UserConfig;
|
263
263
|
dispatch: AppStore["dispatch"];
|
264
264
|
getPermissions: GetPermissions<UserConfig>;
|
265
265
|
refreshPermissions: RefreshPermissions<UserConfig>;
|
@@ -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,
|
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, walkTree };
|
package/dist/index.d.ts
CHANGED
@@ -248,18 +248,18 @@ 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 WalkTreeOptions = {
|
252
252
|
parentId: string;
|
253
253
|
propName: string;
|
254
254
|
};
|
255
|
-
declare function
|
255
|
+
declare function walkTree<T extends ComponentData | RootData | G["UserData"], UserConfig extends Config = Config, G extends UserGenerics<UserConfig> = UserGenerics<UserConfig>>(data: T, config: UserConfig, callbackFn: (data: Content, options: WalkTreeOptions) => Content | null | void): T;
|
256
256
|
|
257
257
|
type WithGet<T> = T & {
|
258
258
|
get: () => T;
|
259
259
|
};
|
260
260
|
type UsePuckData<UserConfig extends Config = Config, G extends UserGenerics<UserConfig> = UserGenerics<UserConfig>> = {
|
261
261
|
appState: AppState;
|
262
|
-
config:
|
262
|
+
config: UserConfig;
|
263
263
|
dispatch: AppStore["dispatch"];
|
264
264
|
getPermissions: GetPermissions<UserConfig>;
|
265
265
|
refreshPermissions: RefreshPermissions<UserConfig>;
|
@@ -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,
|
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, walkTree };
|
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,
|
180
179
|
migrate: () => migrate,
|
181
180
|
overrideKeys: () => overrideKeys,
|
182
181
|
renderContext: () => renderContext,
|
183
182
|
resolveAllData: () => resolveAllData,
|
184
183
|
transformProps: () => transformProps,
|
185
|
-
usePuck: () => usePuck
|
184
|
+
usePuck: () => usePuck,
|
185
|
+
walkTree: () => walkTree
|
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-app-state.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-app-state.ts
|
888
|
+
function walkAppState(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 walkAppState(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 walkAppState(
|
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 walkAppState(
|
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 walkAppState(
|
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 = walkAppState(
|
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 walkAppState(
|
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 = walkAppState(
|
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 walkAppState(
|
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 walkAppState(
|
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
|
+
walkAppState(
|
1774
1774
|
state,
|
1775
1775
|
config,
|
1776
1776
|
(content) => content,
|
@@ -2030,6 +2030,7 @@ function mapSlotsAsync(_0, _1) {
|
|
2030
2030
|
});
|
2031
2031
|
}
|
2032
2032
|
function mapSlotsSync(item, map, isSlot2 = isSlot) {
|
2033
|
+
var _a, _b;
|
2033
2034
|
const props = __spreadValues({}, item.props);
|
2034
2035
|
const propKeys = Object.keys(props);
|
2035
2036
|
for (let i = 0; i < propKeys.length; i++) {
|
@@ -2040,19 +2041,11 @@ function mapSlotsSync(item, map, isSlot2 = isSlot) {
|
|
2040
2041
|
const mappedContent = content.map((item2) => {
|
2041
2042
|
return mapSlotsSync(item2, map, isSlot2);
|
2042
2043
|
});
|
2043
|
-
props[propKey] = map(mappedContent, props.id, propKey);
|
2044
|
+
props[propKey] = (_b = map(mappedContent, (_a = props.id) != null ? _a : "root", propKey)) != null ? _b : mappedContent;
|
2044
2045
|
}
|
2045
2046
|
}
|
2046
2047
|
return __spreadProps(__spreadValues({}, item), { props });
|
2047
2048
|
}
|
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
|
-
}
|
2056
2049
|
|
2057
2050
|
// lib/resolve-component-data.ts
|
2058
2051
|
var import_fast_deep_equal = __toESM(require("fast-deep-equal"));
|
@@ -2299,7 +2292,7 @@ var createAppStore = (initialAppStore) => (0, import_zustand2.create)()(
|
|
2299
2292
|
}),
|
2300
2293
|
resolveAndCommitData: () => __async(void 0, null, function* () {
|
2301
2294
|
const { config, state, dispatch, resolveComponentData: resolveComponentData2 } = get();
|
2302
|
-
|
2295
|
+
walkAppState(
|
2303
2296
|
state,
|
2304
2297
|
config,
|
2305
2298
|
(content) => content,
|
@@ -5695,7 +5688,7 @@ var GlobalPosition = class {
|
|
5695
5688
|
var _a;
|
5696
5689
|
this.target = target;
|
5697
5690
|
this.original = original;
|
5698
|
-
this.frameEl = document.querySelector("
|
5691
|
+
this.frameEl = document.querySelector("#preview-frame");
|
5699
5692
|
if (this.frameEl) {
|
5700
5693
|
this.frameRect = this.frameEl.getBoundingClientRect();
|
5701
5694
|
this.scaleFactor = this.frameRect.width / (((_a = this.frameEl.contentWindow) == null ? void 0 : _a.innerWidth) || 1);
|
@@ -8280,7 +8273,7 @@ function PuckProvider({ children }) {
|
|
8280
8273
|
) : {}
|
8281
8274
|
})
|
8282
8275
|
});
|
8283
|
-
return
|
8276
|
+
return walkAppState(newAppState, config);
|
8284
8277
|
});
|
8285
8278
|
const { appendData = true } = _initialHistory || {};
|
8286
8279
|
const [blendedHistories] = (0, import_react52.useState)(
|
@@ -8290,7 +8283,7 @@ function PuckProvider({ children }) {
|
|
8290
8283
|
].map((history) => {
|
8291
8284
|
let newState = __spreadValues(__spreadValues({}, generatedAppState), history.state);
|
8292
8285
|
if (!history.state.indexes) {
|
8293
|
-
newState =
|
8286
|
+
newState = walkAppState(newState, config);
|
8294
8287
|
}
|
8295
8288
|
return __spreadProps(__spreadValues({}, history), {
|
8296
8289
|
state: newState
|
@@ -8631,9 +8624,9 @@ var migrations = [
|
|
8631
8624
|
console.log("Migrating DropZones to slots...");
|
8632
8625
|
const updatedItems = {};
|
8633
8626
|
const appState = __spreadProps(__spreadValues({}, defaultAppState), { data });
|
8634
|
-
const { indexes } =
|
8627
|
+
const { indexes } = walkAppState(appState, config);
|
8635
8628
|
const deletedCompounds = [];
|
8636
|
-
|
8629
|
+
walkAppState(appState, config, (content, zoneCompound, zoneType) => {
|
8637
8630
|
var _a2, _b;
|
8638
8631
|
if (zoneType === "dropzone") {
|
8639
8632
|
const [id, slotName] = zoneCompound.split(":");
|
@@ -8652,7 +8645,7 @@ var migrations = [
|
|
8652
8645
|
}
|
8653
8646
|
return content;
|
8654
8647
|
});
|
8655
|
-
const updated =
|
8648
|
+
const updated = walkAppState(
|
8656
8649
|
appState,
|
8657
8650
|
config,
|
8658
8651
|
(content) => content,
|
@@ -8791,6 +8784,39 @@ function resolveAllData(_0, _1) {
|
|
8791
8784
|
return dynamic;
|
8792
8785
|
});
|
8793
8786
|
}
|
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
|
+
}
|
8794
8820
|
// Annotate the CommonJS export names for ESM import in node:
|
8795
8821
|
0 && (module.exports = {
|
8796
8822
|
Action,
|
@@ -8806,13 +8832,13 @@ function resolveAllData(_0, _1) {
|
|
8806
8832
|
Puck,
|
8807
8833
|
Render,
|
8808
8834
|
createUsePuck,
|
8809
|
-
mapSlots,
|
8810
8835
|
migrate,
|
8811
8836
|
overrideKeys,
|
8812
8837
|
renderContext,
|
8813
8838
|
resolveAllData,
|
8814
8839
|
transformProps,
|
8815
|
-
usePuck
|
8840
|
+
usePuck,
|
8841
|
+
walkTree
|
8816
8842
|
});
|
8817
8843
|
/*! Bundled license information:
|
8818
8844
|
|
package/dist/index.mjs
CHANGED
@@ -47,6 +47,7 @@ import {
|
|
47
47
|
appStoreContext,
|
48
48
|
createAppStore,
|
49
49
|
createDynamicCollisionDetector,
|
50
|
+
createIsSlotConfig,
|
50
51
|
defaultAppState,
|
51
52
|
defaultViewports,
|
52
53
|
dropZoneContext,
|
@@ -55,7 +56,7 @@ import {
|
|
55
56
|
get_class_name_factory_default,
|
56
57
|
init_react_import,
|
57
58
|
makeStatePublic,
|
58
|
-
|
59
|
+
mapSlotsSync,
|
59
60
|
monitorHotkeys,
|
60
61
|
renderContext,
|
61
62
|
reorder,
|
@@ -74,8 +75,8 @@ import {
|
|
74
75
|
useSensors,
|
75
76
|
useSlots,
|
76
77
|
useSortableSafe,
|
77
|
-
|
78
|
-
} from "./chunk-
|
78
|
+
walkAppState
|
79
|
+
} from "./chunk-LKVFR7SK.mjs";
|
79
80
|
|
80
81
|
// index.ts
|
81
82
|
init_react_import();
|
@@ -3435,7 +3436,7 @@ function PuckProvider({ children }) {
|
|
3435
3436
|
) : {}
|
3436
3437
|
})
|
3437
3438
|
});
|
3438
|
-
return
|
3439
|
+
return walkAppState(newAppState, config);
|
3439
3440
|
});
|
3440
3441
|
const { appendData = true } = _initialHistory || {};
|
3441
3442
|
const [blendedHistories] = useState13(
|
@@ -3445,7 +3446,7 @@ function PuckProvider({ children }) {
|
|
3445
3446
|
].map((history) => {
|
3446
3447
|
let newState = __spreadValues(__spreadValues({}, generatedAppState), history.state);
|
3447
3448
|
if (!history.state.indexes) {
|
3448
|
-
newState =
|
3449
|
+
newState = walkAppState(newState, config);
|
3449
3450
|
}
|
3450
3451
|
return __spreadProps(__spreadValues({}, history), {
|
3451
3452
|
state: newState
|
@@ -3786,9 +3787,9 @@ var migrations = [
|
|
3786
3787
|
console.log("Migrating DropZones to slots...");
|
3787
3788
|
const updatedItems = {};
|
3788
3789
|
const appState = __spreadProps(__spreadValues({}, defaultAppState), { data });
|
3789
|
-
const { indexes } =
|
3790
|
+
const { indexes } = walkAppState(appState, config);
|
3790
3791
|
const deletedCompounds = [];
|
3791
|
-
|
3792
|
+
walkAppState(appState, config, (content, zoneCompound, zoneType) => {
|
3792
3793
|
var _a2, _b;
|
3793
3794
|
if (zoneType === "dropzone") {
|
3794
3795
|
const [id, slotName] = zoneCompound.split(":");
|
@@ -3807,7 +3808,7 @@ var migrations = [
|
|
3807
3808
|
}
|
3808
3809
|
return content;
|
3809
3810
|
});
|
3810
|
-
const updated =
|
3811
|
+
const updated = walkAppState(
|
3811
3812
|
appState,
|
3812
3813
|
config,
|
3813
3814
|
(content) => content,
|
@@ -3840,6 +3841,39 @@ function migrate(data, config) {
|
|
3840
3841
|
data
|
3841
3842
|
);
|
3842
3843
|
}
|
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
|
+
}
|
3843
3877
|
export {
|
3844
3878
|
Action,
|
3845
3879
|
ActionBar,
|
@@ -3854,11 +3888,11 @@ export {
|
|
3854
3888
|
Puck,
|
3855
3889
|
Render,
|
3856
3890
|
createUsePuck,
|
3857
|
-
mapSlotsPublic as mapSlots,
|
3858
3891
|
migrate,
|
3859
3892
|
overrideKeys,
|
3860
3893
|
renderContext,
|
3861
3894
|
resolveAllData,
|
3862
3895
|
transformProps,
|
3863
|
-
usePuck
|
3896
|
+
usePuck,
|
3897
|
+
walkTree
|
3864
3898
|
};
|
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-app-state.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-app-state.ts
|
467
|
+
function walkAppState(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 walkAppState(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 walkAppState(
|
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 walkAppState(
|
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 walkAppState(
|
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 = walkAppState(
|
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 walkAppState(
|
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 = walkAppState(
|
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 walkAppState(
|
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 walkAppState(
|
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
|
+
walkAppState(
|
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
|
+
walkAppState(
|
1636
1636
|
state,
|
1637
1637
|
config,
|
1638
1638
|
(content) => content,
|
package/dist/rsc.mjs
CHANGED
package/package.json
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
{
|
2
2
|
"name": "@measured/puck",
|
3
|
-
"version": "0.19.0-canary.
|
4
|
-
"author": "
|
3
|
+
"version": "0.19.0-canary.427e686f",
|
4
|
+
"author": "Chris Villa <chris@puckeditor.com>",
|
5
5
|
"repository": "measuredco/puck",
|
6
6
|
"bugs": "https://github.com/measuredco/puck/issues",
|
7
7
|
"homepage": "https://puckeditor.com",
|