@measured/puck 0.19.4-canary.f09540db → 0.20.0-canary.167a8f71
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-IM42S4YL.mjs → chunk-32MJ3X3H.mjs} +295 -256
- package/dist/chunk-4KAREQPB.mjs +8436 -0
- package/dist/index.css +3 -1
- package/dist/index.d.mts +4 -7
- package/dist/index.d.ts +4 -7
- package/dist/index.js +1076 -1074
- package/dist/index.mjs +25 -8455
- package/dist/no-external.css +1895 -0
- package/dist/no-external.d.mts +4 -0
- package/dist/no-external.d.ts +4 -0
- package/dist/no-external.js +9315 -0
- package/dist/no-external.mjs +52 -0
- package/dist/rsc.d.mts +2 -2
- package/dist/rsc.d.ts +2 -2
- package/dist/rsc.js +50 -8
- package/dist/rsc.mjs +5 -1
- package/dist/{walk-tree-DrJNb8b-.d.mts → walk-tree-DrNRq2FV.d.mts} +22 -29
- package/dist/{walk-tree-DrJNb8b-.d.ts → walk-tree-DrNRq2FV.d.ts} +22 -29
- package/package.json +3 -2
package/dist/index.js
CHANGED
|
@@ -153,9 +153,9 @@ var require_classnames = __commonJS({
|
|
|
153
153
|
}
|
|
154
154
|
});
|
|
155
155
|
|
|
156
|
-
// index.ts
|
|
157
|
-
var
|
|
158
|
-
__export(
|
|
156
|
+
// bundle/index.ts
|
|
157
|
+
var bundle_exports = {};
|
|
158
|
+
__export(bundle_exports, {
|
|
159
159
|
Action: () => Action,
|
|
160
160
|
ActionBar: () => ActionBar,
|
|
161
161
|
AutoField: () => AutoField,
|
|
@@ -167,7 +167,7 @@ __export(core_exports, {
|
|
|
167
167
|
IconButton: () => IconButton,
|
|
168
168
|
Label: () => Label,
|
|
169
169
|
Puck: () => Puck,
|
|
170
|
-
Render: () =>
|
|
170
|
+
Render: () => Render,
|
|
171
171
|
createUsePuck: () => createUsePuck,
|
|
172
172
|
migrate: () => migrate,
|
|
173
173
|
overrideKeys: () => overrideKeys,
|
|
@@ -178,7 +178,10 @@ __export(core_exports, {
|
|
|
178
178
|
usePuck: () => usePuck,
|
|
179
179
|
walkTree: () => walkTree
|
|
180
180
|
});
|
|
181
|
-
module.exports = __toCommonJS(
|
|
181
|
+
module.exports = __toCommonJS(bundle_exports);
|
|
182
|
+
init_react_import();
|
|
183
|
+
|
|
184
|
+
// bundle/core.ts
|
|
182
185
|
init_react_import();
|
|
183
186
|
|
|
184
187
|
// types/API/index.ts
|
|
@@ -306,7 +309,7 @@ init_react_import();
|
|
|
306
309
|
var styles_module_default2 = { "InputWrapper": "_InputWrapper_py9hf_1", "Input-label": "_Input-label_py9hf_5", "Input-labelIcon": "_Input-labelIcon_py9hf_14", "Input-disabledIcon": "_Input-disabledIcon_py9hf_21", "Input-input": "_Input-input_py9hf_26", "Input": "_Input_py9hf_1", "Input--readOnly": "_Input--readOnly_py9hf_76", "Input-radioGroupItems": "_Input-radioGroupItems_py9hf_87", "Input-radio": "_Input-radio_py9hf_87", "Input-radioInner": "_Input-radioInner_py9hf_104", "Input-radioInput": "_Input-radioInput_py9hf_149" };
|
|
307
310
|
|
|
308
311
|
// components/AutoField/index.tsx
|
|
309
|
-
var
|
|
312
|
+
var import_react20 = require("react");
|
|
310
313
|
|
|
311
314
|
// components/AutoField/fields/index.tsx
|
|
312
315
|
init_react_import();
|
|
@@ -766,7 +769,7 @@ var IconButton = ({
|
|
|
766
769
|
};
|
|
767
770
|
|
|
768
771
|
// components/AutoField/fields/ArrayField/index.tsx
|
|
769
|
-
var
|
|
772
|
+
var import_react14 = require("react");
|
|
770
773
|
|
|
771
774
|
// components/DragIcon/index.tsx
|
|
772
775
|
init_react_import();
|
|
@@ -1253,585 +1256,149 @@ function insertAction(state, action, appStore) {
|
|
|
1253
1256
|
|
|
1254
1257
|
// reducer/actions/replace.ts
|
|
1255
1258
|
init_react_import();
|
|
1256
|
-
|
|
1257
|
-
|
|
1258
|
-
|
|
1259
|
-
|
|
1260
|
-
|
|
1261
|
-
|
|
1262
|
-
|
|
1263
|
-
|
|
1264
|
-
|
|
1265
|
-
var setupZone = (data, zoneKey) => {
|
|
1266
|
-
if (zoneKey === rootDroppableId) {
|
|
1267
|
-
return data;
|
|
1259
|
+
var replaceAction = (state, action, appStore) => {
|
|
1260
|
+
const [parentId] = action.destinationZone.split(":");
|
|
1261
|
+
const idsInPath = getIdsForParent(action.destinationZone, state);
|
|
1262
|
+
const originalId = state.indexes.zones[action.destinationZone].contentIds[action.destinationIndex];
|
|
1263
|
+
const idChanged = originalId !== action.data.props.id;
|
|
1264
|
+
if (idChanged) {
|
|
1265
|
+
throw new Error(
|
|
1266
|
+
`Can't change the id during a replace action. Please us "remove" and "insert" to define a new node.`
|
|
1267
|
+
);
|
|
1268
1268
|
}
|
|
1269
|
-
const
|
|
1270
|
-
|
|
1269
|
+
const newSlotIds = [];
|
|
1270
|
+
const data = walkTree(action.data, appStore.config, (contents, opts) => {
|
|
1271
|
+
newSlotIds.push(`${opts.parentId}:${opts.propName}`);
|
|
1272
|
+
return contents.map((item) => {
|
|
1273
|
+
const id = generateId(item.type);
|
|
1274
|
+
return __spreadProps(__spreadValues({}, item), {
|
|
1275
|
+
props: __spreadValues({ id }, item.props)
|
|
1276
|
+
});
|
|
1277
|
+
});
|
|
1271
1278
|
});
|
|
1272
|
-
|
|
1273
|
-
|
|
1279
|
+
const stateWithDeepSlotsRemoved = __spreadValues({}, state);
|
|
1280
|
+
Object.keys(state.indexes.zones).forEach((zoneCompound) => {
|
|
1281
|
+
const id = zoneCompound.split(":")[0];
|
|
1282
|
+
if (id === originalId) {
|
|
1283
|
+
if (!newSlotIds.includes(zoneCompound)) {
|
|
1284
|
+
delete stateWithDeepSlotsRemoved.indexes.zones[zoneCompound];
|
|
1285
|
+
}
|
|
1286
|
+
}
|
|
1287
|
+
});
|
|
1288
|
+
return walkAppState(
|
|
1289
|
+
stateWithDeepSlotsRemoved,
|
|
1290
|
+
appStore.config,
|
|
1291
|
+
(content, zoneCompound) => {
|
|
1292
|
+
const newContent = [...content];
|
|
1293
|
+
if (zoneCompound === action.destinationZone) {
|
|
1294
|
+
newContent[action.destinationIndex] = data;
|
|
1295
|
+
}
|
|
1296
|
+
return newContent;
|
|
1297
|
+
},
|
|
1298
|
+
(childItem, path) => {
|
|
1299
|
+
const pathIds = path.map((p) => p.split(":")[0]);
|
|
1300
|
+
if (childItem.props.id === data.props.id) {
|
|
1301
|
+
return data;
|
|
1302
|
+
} else if (childItem.props.id === parentId) {
|
|
1303
|
+
return childItem;
|
|
1304
|
+
} else if (idsInPath.indexOf(childItem.props.id) > -1) {
|
|
1305
|
+
return childItem;
|
|
1306
|
+
} else if (pathIds.indexOf(data.props.id) > -1) {
|
|
1307
|
+
return childItem;
|
|
1308
|
+
}
|
|
1309
|
+
return null;
|
|
1310
|
+
}
|
|
1311
|
+
);
|
|
1274
1312
|
};
|
|
1275
1313
|
|
|
1276
|
-
//
|
|
1314
|
+
// reducer/actions/replace-root.ts
|
|
1277
1315
|
init_react_import();
|
|
1278
|
-
var
|
|
1279
|
-
|
|
1280
|
-
|
|
1281
|
-
|
|
1282
|
-
|
|
1283
|
-
|
|
1284
|
-
|
|
1285
|
-
|
|
1286
|
-
|
|
1287
|
-
|
|
1288
|
-
|
|
1289
|
-
|
|
1290
|
-
|
|
1291
|
-
|
|
1292
|
-
content
|
|
1293
|
-
}));
|
|
1294
|
-
return Slot;
|
|
1295
|
-
},
|
|
1296
|
-
config
|
|
1297
|
-
).props;
|
|
1298
|
-
return mapped;
|
|
1299
|
-
}, [config, item, readOnly, forceReadOnly]);
|
|
1300
|
-
const mergedProps = (0, import_react5.useMemo)(
|
|
1301
|
-
() => __spreadValues(__spreadValues({}, item.props), slotProps),
|
|
1302
|
-
[item.props, slotProps]
|
|
1316
|
+
var replaceRootAction = (state, action, appStore) => {
|
|
1317
|
+
return walkAppState(
|
|
1318
|
+
state,
|
|
1319
|
+
appStore.config,
|
|
1320
|
+
(content) => content,
|
|
1321
|
+
(childItem) => {
|
|
1322
|
+
if (childItem.props.id === "root") {
|
|
1323
|
+
return __spreadProps(__spreadValues({}, childItem), {
|
|
1324
|
+
props: __spreadValues(__spreadValues({}, childItem.props), action.root.props),
|
|
1325
|
+
readOnly: action.root.readOnly
|
|
1326
|
+
});
|
|
1327
|
+
}
|
|
1328
|
+
return childItem;
|
|
1329
|
+
}
|
|
1303
1330
|
);
|
|
1304
|
-
|
|
1305
|
-
}
|
|
1331
|
+
};
|
|
1306
1332
|
|
|
1307
|
-
//
|
|
1333
|
+
// reducer/actions/duplicate.ts
|
|
1308
1334
|
init_react_import();
|
|
1309
|
-
|
|
1310
|
-
|
|
1311
|
-
|
|
1312
|
-
|
|
1313
|
-
|
|
1314
|
-
|
|
1315
|
-
|
|
1316
|
-
}
|
|
1317
|
-
|
|
1318
|
-
|
|
1319
|
-
|
|
1320
|
-
|
|
1321
|
-
|
|
1322
|
-
|
|
1323
|
-
renderDropZone: DropZoneRender,
|
|
1324
|
-
metadata: metadata || {}
|
|
1325
|
-
})
|
|
1326
|
-
})
|
|
1335
|
+
|
|
1336
|
+
// lib/data/get-item.ts
|
|
1337
|
+
init_react_import();
|
|
1338
|
+
function getItem(selector, state) {
|
|
1339
|
+
var _a, _b;
|
|
1340
|
+
const zone = (_a = state.indexes.zones) == null ? void 0 : _a[selector.zone || rootDroppableId];
|
|
1341
|
+
return zone ? (_b = state.indexes.nodes[zone.contentIds[selector.index]]) == null ? void 0 : _b.data : void 0;
|
|
1342
|
+
}
|
|
1343
|
+
|
|
1344
|
+
// reducer/actions/duplicate.ts
|
|
1345
|
+
function duplicateAction(state, action, appStore) {
|
|
1346
|
+
const item = getItem(
|
|
1347
|
+
{ index: action.sourceIndex, zone: action.sourceZone },
|
|
1348
|
+
state
|
|
1327
1349
|
);
|
|
1328
|
-
|
|
1329
|
-
|
|
1330
|
-
|
|
1331
|
-
|
|
1332
|
-
|
|
1333
|
-
|
|
1350
|
+
const idsInPath = getIdsForParent(action.sourceZone, state);
|
|
1351
|
+
const newItem = __spreadProps(__spreadValues({}, item), {
|
|
1352
|
+
props: __spreadProps(__spreadValues({}, item.props), {
|
|
1353
|
+
id: generateId(item.type)
|
|
1354
|
+
})
|
|
1355
|
+
});
|
|
1356
|
+
const modified = walkAppState(
|
|
1357
|
+
state,
|
|
1358
|
+
appStore.config,
|
|
1359
|
+
(content, zoneCompound) => {
|
|
1360
|
+
if (zoneCompound === action.sourceZone) {
|
|
1361
|
+
return insert(content, action.sourceIndex + 1, item);
|
|
1334
1362
|
}
|
|
1335
|
-
return
|
|
1336
|
-
|
|
1337
|
-
|
|
1338
|
-
|
|
1339
|
-
|
|
1340
|
-
|
|
1341
|
-
},
|
|
1342
|
-
|
|
1343
|
-
|
|
1344
|
-
|
|
1345
|
-
|
|
1346
|
-
);
|
|
1347
|
-
|
|
1348
|
-
// components/ServerRender/index.tsx
|
|
1349
|
-
var import_jsx_runtime6 = require("react/jsx-runtime");
|
|
1350
|
-
function DropZoneRender({
|
|
1351
|
-
zone,
|
|
1352
|
-
data,
|
|
1353
|
-
areaId = "root",
|
|
1354
|
-
config,
|
|
1355
|
-
metadata = {}
|
|
1356
|
-
}) {
|
|
1357
|
-
let zoneCompound = rootDroppableId;
|
|
1358
|
-
let content = (data == null ? void 0 : data.content) || [];
|
|
1359
|
-
if (!data || !config) {
|
|
1360
|
-
return null;
|
|
1361
|
-
}
|
|
1362
|
-
if (areaId !== rootAreaId && zone !== rootZone) {
|
|
1363
|
-
zoneCompound = `${areaId}:${zone}`;
|
|
1364
|
-
content = setupZone(data, zoneCompound).zones[zoneCompound];
|
|
1365
|
-
}
|
|
1366
|
-
return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_jsx_runtime6.Fragment, { children: content.map((item) => {
|
|
1367
|
-
const Component = config.components[item.type];
|
|
1368
|
-
const props = __spreadProps(__spreadValues({}, item.props), {
|
|
1369
|
-
puck: {
|
|
1370
|
-
renderDropZone: ({ zone: zone2 }) => /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
|
|
1371
|
-
DropZoneRender,
|
|
1372
|
-
{
|
|
1373
|
-
zone: zone2,
|
|
1374
|
-
data,
|
|
1375
|
-
areaId: item.props.id,
|
|
1376
|
-
config,
|
|
1377
|
-
metadata
|
|
1378
|
-
}
|
|
1379
|
-
),
|
|
1380
|
-
metadata,
|
|
1381
|
-
dragRef: null,
|
|
1382
|
-
isEditing: false
|
|
1363
|
+
return content;
|
|
1364
|
+
},
|
|
1365
|
+
(childItem, path, index) => {
|
|
1366
|
+
const zoneCompound = path[path.length - 1];
|
|
1367
|
+
const parents = path.map((p) => p.split(":")[0]);
|
|
1368
|
+
if (parents.indexOf(newItem.props.id) > -1) {
|
|
1369
|
+
return __spreadProps(__spreadValues({}, childItem), {
|
|
1370
|
+
props: __spreadProps(__spreadValues({}, childItem.props), {
|
|
1371
|
+
id: generateId(childItem.type)
|
|
1372
|
+
})
|
|
1373
|
+
});
|
|
1383
1374
|
}
|
|
1384
|
-
|
|
1385
|
-
|
|
1386
|
-
|
|
1387
|
-
|
|
1388
|
-
|
|
1375
|
+
if (zoneCompound === action.sourceZone && index === action.sourceIndex + 1) {
|
|
1376
|
+
return newItem;
|
|
1377
|
+
}
|
|
1378
|
+
const [sourceZoneParent] = action.sourceZone.split(":");
|
|
1379
|
+
if (sourceZoneParent === childItem.props.id || idsInPath.indexOf(childItem.props.id) > -1) {
|
|
1380
|
+
return childItem;
|
|
1381
|
+
}
|
|
1382
|
+
return null;
|
|
1389
1383
|
}
|
|
1390
|
-
|
|
1391
|
-
})
|
|
1384
|
+
);
|
|
1385
|
+
return __spreadProps(__spreadValues({}, modified), {
|
|
1386
|
+
ui: __spreadProps(__spreadValues({}, modified.ui), {
|
|
1387
|
+
itemSelector: {
|
|
1388
|
+
index: action.sourceIndex + 1,
|
|
1389
|
+
zone: action.sourceZone
|
|
1390
|
+
}
|
|
1391
|
+
})
|
|
1392
|
+
});
|
|
1392
1393
|
}
|
|
1393
1394
|
|
|
1394
|
-
//
|
|
1395
|
+
// reducer/actions/reorder.ts
|
|
1395
1396
|
init_react_import();
|
|
1396
1397
|
|
|
1397
|
-
//
|
|
1398
|
+
// reducer/actions/move.ts
|
|
1398
1399
|
init_react_import();
|
|
1399
1400
|
|
|
1400
|
-
// lib/
|
|
1401
|
-
init_react_import();
|
|
1402
|
-
var import_fast_deep_equal = __toESM(require("fast-deep-equal"));
|
|
1403
|
-
var getChanged = (newItem, oldItem) => {
|
|
1404
|
-
return newItem ? Object.keys(newItem.props || {}).reduce((acc, item) => {
|
|
1405
|
-
const newItemProps = (newItem == null ? void 0 : newItem.props) || {};
|
|
1406
|
-
const oldItemProps = (oldItem == null ? void 0 : oldItem.props) || {};
|
|
1407
|
-
return __spreadProps(__spreadValues({}, acc), {
|
|
1408
|
-
[item]: !(0, import_fast_deep_equal.default)(oldItemProps[item], newItemProps[item])
|
|
1409
|
-
});
|
|
1410
|
-
}, {}) : {};
|
|
1411
|
-
};
|
|
1412
|
-
|
|
1413
|
-
// lib/resolve-component-data.ts
|
|
1414
|
-
var import_fast_deep_equal2 = __toESM(require("fast-deep-equal"));
|
|
1415
|
-
var cache = { lastChange: {} };
|
|
1416
|
-
var resolveComponentData = (_0, _1, ..._2) => __async(void 0, [_0, _1, ..._2], function* (item, config, metadata = {}, onResolveStart, onResolveEnd, trigger = "replace") {
|
|
1417
|
-
const configForItem = "type" in item && item.type !== "root" ? config.components[item.type] : config.root;
|
|
1418
|
-
const resolvedItem = __spreadValues({}, item);
|
|
1419
|
-
const shouldRunResolver = (configForItem == null ? void 0 : configForItem.resolveData) && item.props;
|
|
1420
|
-
const id = "id" in item.props ? item.props.id : "root";
|
|
1421
|
-
if (shouldRunResolver) {
|
|
1422
|
-
const { item: oldItem = null, resolved = {} } = cache.lastChange[id] || {};
|
|
1423
|
-
if (item && (0, import_fast_deep_equal2.default)(item, oldItem)) {
|
|
1424
|
-
return { node: resolved, didChange: false };
|
|
1425
|
-
}
|
|
1426
|
-
const changed = getChanged(item, oldItem);
|
|
1427
|
-
if (onResolveStart) {
|
|
1428
|
-
onResolveStart(item);
|
|
1429
|
-
}
|
|
1430
|
-
const { props: resolvedProps, readOnly = {} } = yield configForItem.resolveData(item, {
|
|
1431
|
-
changed,
|
|
1432
|
-
lastData: oldItem,
|
|
1433
|
-
metadata: __spreadValues(__spreadValues({}, metadata), configForItem.metadata),
|
|
1434
|
-
trigger
|
|
1435
|
-
});
|
|
1436
|
-
resolvedItem.props = __spreadValues(__spreadValues({}, item.props), resolvedProps);
|
|
1437
|
-
if (Object.keys(readOnly).length) {
|
|
1438
|
-
resolvedItem.readOnly = readOnly;
|
|
1439
|
-
}
|
|
1440
|
-
}
|
|
1441
|
-
let itemWithResolvedChildren = yield mapSlots(
|
|
1442
|
-
resolvedItem,
|
|
1443
|
-
(content) => __async(void 0, null, function* () {
|
|
1444
|
-
return yield Promise.all(
|
|
1445
|
-
content.map(
|
|
1446
|
-
(childItem) => __async(void 0, null, function* () {
|
|
1447
|
-
return (yield resolveComponentData(
|
|
1448
|
-
childItem,
|
|
1449
|
-
config,
|
|
1450
|
-
metadata,
|
|
1451
|
-
onResolveStart,
|
|
1452
|
-
onResolveEnd,
|
|
1453
|
-
trigger
|
|
1454
|
-
)).node;
|
|
1455
|
-
})
|
|
1456
|
-
)
|
|
1457
|
-
);
|
|
1458
|
-
}),
|
|
1459
|
-
config
|
|
1460
|
-
);
|
|
1461
|
-
if (shouldRunResolver && onResolveEnd) {
|
|
1462
|
-
onResolveEnd(resolvedItem);
|
|
1463
|
-
}
|
|
1464
|
-
cache.lastChange[id] = {
|
|
1465
|
-
item,
|
|
1466
|
-
resolved: itemWithResolvedChildren
|
|
1467
|
-
};
|
|
1468
|
-
return {
|
|
1469
|
-
node: itemWithResolvedChildren,
|
|
1470
|
-
didChange: !(0, import_fast_deep_equal2.default)(item, itemWithResolvedChildren)
|
|
1471
|
-
};
|
|
1472
|
-
});
|
|
1473
|
-
|
|
1474
|
-
// lib/data/default-data.ts
|
|
1475
|
-
init_react_import();
|
|
1476
|
-
var defaultData = (data) => __spreadProps(__spreadValues({}, data), {
|
|
1477
|
-
root: data.root || {},
|
|
1478
|
-
content: data.content || []
|
|
1479
|
-
});
|
|
1480
|
-
|
|
1481
|
-
// lib/data/to-component.ts
|
|
1482
|
-
init_react_import();
|
|
1483
|
-
var toComponent = (item) => {
|
|
1484
|
-
return "type" in item ? item : __spreadProps(__spreadValues({}, item), {
|
|
1485
|
-
props: __spreadProps(__spreadValues({}, item.props), { id: "root" }),
|
|
1486
|
-
type: "root"
|
|
1487
|
-
});
|
|
1488
|
-
};
|
|
1489
|
-
|
|
1490
|
-
// lib/resolve-all-data.ts
|
|
1491
|
-
function resolveAllData(_0, _1) {
|
|
1492
|
-
return __async(this, arguments, function* (data, config, metadata = {}, onResolveStart, onResolveEnd) {
|
|
1493
|
-
var _a;
|
|
1494
|
-
const defaultedData = defaultData(data);
|
|
1495
|
-
const resolveNode = (_node) => __async(this, null, function* () {
|
|
1496
|
-
const node = toComponent(_node);
|
|
1497
|
-
onResolveStart == null ? void 0 : onResolveStart(node);
|
|
1498
|
-
const resolved = (yield resolveComponentData(
|
|
1499
|
-
node,
|
|
1500
|
-
config,
|
|
1501
|
-
metadata,
|
|
1502
|
-
() => {
|
|
1503
|
-
},
|
|
1504
|
-
() => {
|
|
1505
|
-
},
|
|
1506
|
-
"force"
|
|
1507
|
-
)).node;
|
|
1508
|
-
const resolvedDeep = yield mapSlots(
|
|
1509
|
-
resolved,
|
|
1510
|
-
processContent,
|
|
1511
|
-
config
|
|
1512
|
-
);
|
|
1513
|
-
onResolveEnd == null ? void 0 : onResolveEnd(toComponent(resolvedDeep));
|
|
1514
|
-
return resolvedDeep;
|
|
1515
|
-
});
|
|
1516
|
-
const processContent = (content) => __async(this, null, function* () {
|
|
1517
|
-
return Promise.all(content.map(resolveNode));
|
|
1518
|
-
});
|
|
1519
|
-
const processZones = () => __async(this, null, function* () {
|
|
1520
|
-
var _a2;
|
|
1521
|
-
const zones = (_a2 = data.zones) != null ? _a2 : {};
|
|
1522
|
-
Object.entries(zones).forEach((_02) => __async(this, [_02], function* ([zoneKey, content]) {
|
|
1523
|
-
zones[zoneKey] = yield Promise.all(content.map(resolveNode));
|
|
1524
|
-
}));
|
|
1525
|
-
return zones;
|
|
1526
|
-
});
|
|
1527
|
-
const dynamic = {
|
|
1528
|
-
root: yield resolveNode(defaultedData.root),
|
|
1529
|
-
content: yield processContent(defaultedData.content),
|
|
1530
|
-
zones: yield processZones()
|
|
1531
|
-
};
|
|
1532
|
-
Object.keys((_a = defaultedData.zones) != null ? _a : {}).forEach((zoneKey) => __async(this, null, function* () {
|
|
1533
|
-
const content = defaultedData.zones[zoneKey];
|
|
1534
|
-
dynamic.zones[zoneKey] = yield processContent(content);
|
|
1535
|
-
}), {});
|
|
1536
|
-
return dynamic;
|
|
1537
|
-
});
|
|
1538
|
-
}
|
|
1539
|
-
|
|
1540
|
-
// lib/transform-props.ts
|
|
1541
|
-
init_react_import();
|
|
1542
|
-
function transformProps(data, propTransforms, config = { components: {} }) {
|
|
1543
|
-
const mapItem = (item) => {
|
|
1544
|
-
if (propTransforms[item.type]) {
|
|
1545
|
-
return __spreadProps(__spreadValues({}, item), {
|
|
1546
|
-
props: __spreadValues({
|
|
1547
|
-
id: item.props.id
|
|
1548
|
-
}, propTransforms[item.type](item.props))
|
|
1549
|
-
});
|
|
1550
|
-
}
|
|
1551
|
-
return item;
|
|
1552
|
-
};
|
|
1553
|
-
const defaultedData = defaultData(data);
|
|
1554
|
-
const rootProps = defaultedData.root.props || defaultedData.root;
|
|
1555
|
-
let newRoot = __spreadValues({}, defaultedData.root);
|
|
1556
|
-
if (propTransforms["root"]) {
|
|
1557
|
-
newRoot.props = propTransforms["root"](rootProps);
|
|
1558
|
-
}
|
|
1559
|
-
const dataWithUpdatedRoot = __spreadProps(__spreadValues({}, defaultedData), { root: newRoot });
|
|
1560
|
-
const updatedData = walkTree(
|
|
1561
|
-
dataWithUpdatedRoot,
|
|
1562
|
-
config,
|
|
1563
|
-
(content) => content.map(mapItem)
|
|
1564
|
-
);
|
|
1565
|
-
if (!defaultedData.root.props) {
|
|
1566
|
-
updatedData.root = updatedData.root.props;
|
|
1567
|
-
}
|
|
1568
|
-
return updatedData;
|
|
1569
|
-
}
|
|
1570
|
-
|
|
1571
|
-
// lib/migrate.ts
|
|
1572
|
-
init_react_import();
|
|
1573
|
-
|
|
1574
|
-
// store/default-app-state.ts
|
|
1575
|
-
init_react_import();
|
|
1576
|
-
|
|
1577
|
-
// components/ViewportControls/default-viewports.ts
|
|
1578
|
-
init_react_import();
|
|
1579
|
-
var defaultViewports = [
|
|
1580
|
-
{ width: 360, height: "auto", icon: "Smartphone", label: "Small" },
|
|
1581
|
-
{ width: 768, height: "auto", icon: "Tablet", label: "Medium" },
|
|
1582
|
-
{ width: 1280, height: "auto", icon: "Monitor", label: "Large" }
|
|
1583
|
-
];
|
|
1584
|
-
|
|
1585
|
-
// store/default-app-state.ts
|
|
1586
|
-
var defaultAppState = {
|
|
1587
|
-
data: { content: [], root: {}, zones: {} },
|
|
1588
|
-
ui: {
|
|
1589
|
-
leftSideBarVisible: true,
|
|
1590
|
-
rightSideBarVisible: true,
|
|
1591
|
-
arrayState: {},
|
|
1592
|
-
itemSelector: null,
|
|
1593
|
-
componentList: {},
|
|
1594
|
-
isDragging: false,
|
|
1595
|
-
previewMode: "edit",
|
|
1596
|
-
viewports: {
|
|
1597
|
-
current: {
|
|
1598
|
-
width: defaultViewports[0].width,
|
|
1599
|
-
height: defaultViewports[0].height || "auto"
|
|
1600
|
-
},
|
|
1601
|
-
options: [],
|
|
1602
|
-
controlsVisible: true
|
|
1603
|
-
},
|
|
1604
|
-
field: { focus: null }
|
|
1605
|
-
},
|
|
1606
|
-
indexes: {
|
|
1607
|
-
nodes: {},
|
|
1608
|
-
zones: {}
|
|
1609
|
-
}
|
|
1610
|
-
};
|
|
1611
|
-
|
|
1612
|
-
// lib/migrate.ts
|
|
1613
|
-
var migrations = [
|
|
1614
|
-
// Migrate root to root.props
|
|
1615
|
-
(data) => {
|
|
1616
|
-
const rootProps = data.root.props || data.root;
|
|
1617
|
-
if (Object.keys(data.root).length > 0 && !data.root.props) {
|
|
1618
|
-
console.warn(
|
|
1619
|
-
"Migration applied: Root props moved from `root` to `root.props`."
|
|
1620
|
-
);
|
|
1621
|
-
return __spreadProps(__spreadValues({}, data), {
|
|
1622
|
-
root: {
|
|
1623
|
-
props: __spreadValues({}, rootProps)
|
|
1624
|
-
}
|
|
1625
|
-
});
|
|
1626
|
-
}
|
|
1627
|
-
return data;
|
|
1628
|
-
},
|
|
1629
|
-
// Migrate zones to slots
|
|
1630
|
-
(data, config) => {
|
|
1631
|
-
var _a;
|
|
1632
|
-
if (!config) return data;
|
|
1633
|
-
console.log("Migrating DropZones to slots...");
|
|
1634
|
-
const updatedItems = {};
|
|
1635
|
-
const appState = __spreadProps(__spreadValues({}, defaultAppState), { data });
|
|
1636
|
-
const { indexes } = walkAppState(appState, config);
|
|
1637
|
-
const deletedCompounds = [];
|
|
1638
|
-
walkAppState(appState, config, (content, zoneCompound, zoneType) => {
|
|
1639
|
-
var _a2, _b, _c;
|
|
1640
|
-
if (zoneType === "dropzone") {
|
|
1641
|
-
const [id, slotName] = zoneCompound.split(":");
|
|
1642
|
-
const nodeData = indexes.nodes[id].data;
|
|
1643
|
-
const componentType = nodeData.type;
|
|
1644
|
-
const configForComponent = id === "root" ? config.root : config.components[componentType];
|
|
1645
|
-
if (((_b = (_a2 = configForComponent == null ? void 0 : configForComponent.fields) == null ? void 0 : _a2[slotName]) == null ? void 0 : _b.type) === "slot") {
|
|
1646
|
-
updatedItems[id] = __spreadProps(__spreadValues({}, nodeData), {
|
|
1647
|
-
props: __spreadProps(__spreadValues(__spreadValues({}, nodeData.props), (_c = updatedItems[id]) == null ? void 0 : _c.props), {
|
|
1648
|
-
[slotName]: content
|
|
1649
|
-
})
|
|
1650
|
-
});
|
|
1651
|
-
deletedCompounds.push(zoneCompound);
|
|
1652
|
-
}
|
|
1653
|
-
return content;
|
|
1654
|
-
}
|
|
1655
|
-
return content;
|
|
1656
|
-
});
|
|
1657
|
-
const updated = walkAppState(
|
|
1658
|
-
appState,
|
|
1659
|
-
config,
|
|
1660
|
-
(content) => content,
|
|
1661
|
-
(item) => {
|
|
1662
|
-
var _a2;
|
|
1663
|
-
return (_a2 = updatedItems[item.props.id]) != null ? _a2 : item;
|
|
1664
|
-
}
|
|
1665
|
-
);
|
|
1666
|
-
deletedCompounds.forEach((zoneCompound) => {
|
|
1667
|
-
var _a2;
|
|
1668
|
-
const [_, propName] = zoneCompound.split(":");
|
|
1669
|
-
console.log(
|
|
1670
|
-
`\u2713 Success: Migrated "${zoneCompound}" from DropZone to slot field "${propName}"`
|
|
1671
|
-
);
|
|
1672
|
-
(_a2 = updated.data.zones) == null ? true : delete _a2[zoneCompound];
|
|
1673
|
-
});
|
|
1674
|
-
Object.keys((_a = updated.data.zones) != null ? _a : {}).forEach((zoneCompound) => {
|
|
1675
|
-
const [_, propName] = zoneCompound.split(":");
|
|
1676
|
-
throw new Error(
|
|
1677
|
-
`Could not migrate DropZone "${zoneCompound}" to slot field. No slot exists with the name "${propName}".`
|
|
1678
|
-
);
|
|
1679
|
-
});
|
|
1680
|
-
delete updated.data.zones;
|
|
1681
|
-
return updated.data;
|
|
1682
|
-
}
|
|
1683
|
-
];
|
|
1684
|
-
function migrate(data, config) {
|
|
1685
|
-
return migrations == null ? void 0 : migrations.reduce(
|
|
1686
|
-
(acc, migration) => migration(acc, config),
|
|
1687
|
-
data
|
|
1688
|
-
);
|
|
1689
|
-
}
|
|
1690
|
-
|
|
1691
|
-
// reducer/actions/replace.ts
|
|
1692
|
-
var replaceAction = (state, action, appStore) => {
|
|
1693
|
-
const [parentId] = action.destinationZone.split(":");
|
|
1694
|
-
const idsInPath = getIdsForParent(action.destinationZone, state);
|
|
1695
|
-
const originalId = state.indexes.zones[action.destinationZone].contentIds[action.destinationIndex];
|
|
1696
|
-
const idChanged = originalId !== action.data.props.id;
|
|
1697
|
-
if (idChanged) {
|
|
1698
|
-
throw new Error(
|
|
1699
|
-
`Can't change the id during a replace action. Please us "remove" and "insert" to define a new node.`
|
|
1700
|
-
);
|
|
1701
|
-
}
|
|
1702
|
-
const newSlotIds = [];
|
|
1703
|
-
const data = walkTree(action.data, appStore.config, (contents, opts) => {
|
|
1704
|
-
newSlotIds.push(`${opts.parentId}:${opts.propName}`);
|
|
1705
|
-
return contents.map((item) => {
|
|
1706
|
-
const id = generateId(item.type);
|
|
1707
|
-
return __spreadProps(__spreadValues({}, item), {
|
|
1708
|
-
props: __spreadValues({ id }, item.props)
|
|
1709
|
-
});
|
|
1710
|
-
});
|
|
1711
|
-
});
|
|
1712
|
-
const stateWithDeepSlotsRemoved = __spreadValues({}, state);
|
|
1713
|
-
Object.keys(state.indexes.zones).forEach((zoneCompound) => {
|
|
1714
|
-
const id = zoneCompound.split(":")[0];
|
|
1715
|
-
if (id === originalId) {
|
|
1716
|
-
if (!newSlotIds.includes(zoneCompound)) {
|
|
1717
|
-
delete stateWithDeepSlotsRemoved.indexes.zones[zoneCompound];
|
|
1718
|
-
}
|
|
1719
|
-
}
|
|
1720
|
-
});
|
|
1721
|
-
return walkAppState(
|
|
1722
|
-
stateWithDeepSlotsRemoved,
|
|
1723
|
-
appStore.config,
|
|
1724
|
-
(content, zoneCompound) => {
|
|
1725
|
-
const newContent = [...content];
|
|
1726
|
-
if (zoneCompound === action.destinationZone) {
|
|
1727
|
-
newContent[action.destinationIndex] = data;
|
|
1728
|
-
}
|
|
1729
|
-
return newContent;
|
|
1730
|
-
},
|
|
1731
|
-
(childItem, path) => {
|
|
1732
|
-
const pathIds = path.map((p) => p.split(":")[0]);
|
|
1733
|
-
if (childItem.props.id === data.props.id) {
|
|
1734
|
-
return data;
|
|
1735
|
-
} else if (childItem.props.id === parentId) {
|
|
1736
|
-
return childItem;
|
|
1737
|
-
} else if (idsInPath.indexOf(childItem.props.id) > -1) {
|
|
1738
|
-
return childItem;
|
|
1739
|
-
} else if (pathIds.indexOf(data.props.id) > -1) {
|
|
1740
|
-
return childItem;
|
|
1741
|
-
}
|
|
1742
|
-
return null;
|
|
1743
|
-
}
|
|
1744
|
-
);
|
|
1745
|
-
};
|
|
1746
|
-
|
|
1747
|
-
// reducer/actions/replace-root.ts
|
|
1748
|
-
init_react_import();
|
|
1749
|
-
var replaceRootAction = (state, action, appStore) => {
|
|
1750
|
-
return walkAppState(
|
|
1751
|
-
state,
|
|
1752
|
-
appStore.config,
|
|
1753
|
-
(content) => content,
|
|
1754
|
-
(childItem) => {
|
|
1755
|
-
if (childItem.props.id === "root") {
|
|
1756
|
-
return __spreadProps(__spreadValues({}, childItem), {
|
|
1757
|
-
props: __spreadValues(__spreadValues({}, childItem.props), action.root.props),
|
|
1758
|
-
readOnly: action.root.readOnly
|
|
1759
|
-
});
|
|
1760
|
-
}
|
|
1761
|
-
return childItem;
|
|
1762
|
-
}
|
|
1763
|
-
);
|
|
1764
|
-
};
|
|
1765
|
-
|
|
1766
|
-
// reducer/actions/duplicate.ts
|
|
1767
|
-
init_react_import();
|
|
1768
|
-
|
|
1769
|
-
// lib/data/get-item.ts
|
|
1770
|
-
init_react_import();
|
|
1771
|
-
function getItem(selector, state) {
|
|
1772
|
-
var _a, _b;
|
|
1773
|
-
const zone = (_a = state.indexes.zones) == null ? void 0 : _a[selector.zone || rootDroppableId];
|
|
1774
|
-
return zone ? (_b = state.indexes.nodes[zone.contentIds[selector.index]]) == null ? void 0 : _b.data : void 0;
|
|
1775
|
-
}
|
|
1776
|
-
|
|
1777
|
-
// reducer/actions/duplicate.ts
|
|
1778
|
-
function duplicateAction(state, action, appStore) {
|
|
1779
|
-
const item = getItem(
|
|
1780
|
-
{ index: action.sourceIndex, zone: action.sourceZone },
|
|
1781
|
-
state
|
|
1782
|
-
);
|
|
1783
|
-
const idsInPath = getIdsForParent(action.sourceZone, state);
|
|
1784
|
-
const newItem = __spreadProps(__spreadValues({}, item), {
|
|
1785
|
-
props: __spreadProps(__spreadValues({}, item.props), {
|
|
1786
|
-
id: generateId(item.type)
|
|
1787
|
-
})
|
|
1788
|
-
});
|
|
1789
|
-
const modified = walkAppState(
|
|
1790
|
-
state,
|
|
1791
|
-
appStore.config,
|
|
1792
|
-
(content, zoneCompound) => {
|
|
1793
|
-
if (zoneCompound === action.sourceZone) {
|
|
1794
|
-
return insert(content, action.sourceIndex + 1, item);
|
|
1795
|
-
}
|
|
1796
|
-
return content;
|
|
1797
|
-
},
|
|
1798
|
-
(childItem, path, index) => {
|
|
1799
|
-
const zoneCompound = path[path.length - 1];
|
|
1800
|
-
const parents = path.map((p) => p.split(":")[0]);
|
|
1801
|
-
if (parents.indexOf(newItem.props.id) > -1) {
|
|
1802
|
-
return __spreadProps(__spreadValues({}, childItem), {
|
|
1803
|
-
props: __spreadProps(__spreadValues({}, childItem.props), {
|
|
1804
|
-
id: generateId(childItem.type)
|
|
1805
|
-
})
|
|
1806
|
-
});
|
|
1807
|
-
}
|
|
1808
|
-
if (zoneCompound === action.sourceZone && index === action.sourceIndex + 1) {
|
|
1809
|
-
return newItem;
|
|
1810
|
-
}
|
|
1811
|
-
const [sourceZoneParent] = action.sourceZone.split(":");
|
|
1812
|
-
if (sourceZoneParent === childItem.props.id || idsInPath.indexOf(childItem.props.id) > -1) {
|
|
1813
|
-
return childItem;
|
|
1814
|
-
}
|
|
1815
|
-
return null;
|
|
1816
|
-
}
|
|
1817
|
-
);
|
|
1818
|
-
return __spreadProps(__spreadValues({}, modified), {
|
|
1819
|
-
ui: __spreadProps(__spreadValues({}, modified.ui), {
|
|
1820
|
-
itemSelector: {
|
|
1821
|
-
index: action.sourceIndex + 1,
|
|
1822
|
-
zone: action.sourceZone
|
|
1823
|
-
}
|
|
1824
|
-
})
|
|
1825
|
-
});
|
|
1826
|
-
}
|
|
1827
|
-
|
|
1828
|
-
// reducer/actions/reorder.ts
|
|
1829
|
-
init_react_import();
|
|
1830
|
-
|
|
1831
|
-
// reducer/actions/move.ts
|
|
1832
|
-
init_react_import();
|
|
1833
|
-
|
|
1834
|
-
// lib/data/remove.ts
|
|
1401
|
+
// lib/data/remove.ts
|
|
1835
1402
|
init_react_import();
|
|
1836
1403
|
var remove = (list, index) => {
|
|
1837
1404
|
const result = Array.from(list);
|
|
@@ -1939,6 +1506,21 @@ var removeAction = (state, action, appStore) => {
|
|
|
1939
1506
|
|
|
1940
1507
|
// reducer/actions/register-zone.ts
|
|
1941
1508
|
init_react_import();
|
|
1509
|
+
|
|
1510
|
+
// lib/data/setup-zone.ts
|
|
1511
|
+
init_react_import();
|
|
1512
|
+
var setupZone = (data, zoneKey) => {
|
|
1513
|
+
if (zoneKey === rootDroppableId) {
|
|
1514
|
+
return data;
|
|
1515
|
+
}
|
|
1516
|
+
const newData = __spreadProps(__spreadValues({}, data), {
|
|
1517
|
+
zones: data.zones ? __spreadValues({}, data.zones) : {}
|
|
1518
|
+
});
|
|
1519
|
+
newData.zones[zoneKey] = newData.zones[zoneKey] || [];
|
|
1520
|
+
return newData;
|
|
1521
|
+
};
|
|
1522
|
+
|
|
1523
|
+
// reducer/actions/register-zone.ts
|
|
1942
1524
|
var zoneCache = {};
|
|
1943
1525
|
function registerZoneAction(state, action) {
|
|
1944
1526
|
if (zoneCache[action.zone]) {
|
|
@@ -2091,18 +1673,26 @@ function createReducer({
|
|
|
2091
1673
|
);
|
|
2092
1674
|
}
|
|
2093
1675
|
|
|
1676
|
+
// components/ViewportControls/default-viewports.ts
|
|
1677
|
+
init_react_import();
|
|
1678
|
+
var defaultViewports = [
|
|
1679
|
+
{ width: 360, height: "auto", icon: "Smartphone", label: "Small" },
|
|
1680
|
+
{ width: 768, height: "auto", icon: "Tablet", label: "Medium" },
|
|
1681
|
+
{ width: 1280, height: "auto", icon: "Monitor", label: "Large" }
|
|
1682
|
+
];
|
|
1683
|
+
|
|
2094
1684
|
// store/index.ts
|
|
2095
1685
|
var import_zustand2 = require("zustand");
|
|
2096
1686
|
var import_middleware2 = require("zustand/middleware");
|
|
2097
|
-
var
|
|
1687
|
+
var import_react9 = require("react");
|
|
2098
1688
|
|
|
2099
1689
|
// store/slices/history.ts
|
|
2100
1690
|
init_react_import();
|
|
2101
|
-
var
|
|
1691
|
+
var import_react6 = require("react");
|
|
2102
1692
|
|
|
2103
1693
|
// lib/use-hotkey.ts
|
|
2104
1694
|
init_react_import();
|
|
2105
|
-
var
|
|
1695
|
+
var import_react5 = require("react");
|
|
2106
1696
|
var import_zustand = require("zustand");
|
|
2107
1697
|
var import_middleware = require("zustand/middleware");
|
|
2108
1698
|
var keyCodeMap = {
|
|
@@ -2195,10 +1785,10 @@ var monitorHotkeys = (doc) => {
|
|
|
2195
1785
|
};
|
|
2196
1786
|
};
|
|
2197
1787
|
var useMonitorHotkeys = () => {
|
|
2198
|
-
(0,
|
|
1788
|
+
(0, import_react5.useEffect)(() => monitorHotkeys(document), []);
|
|
2199
1789
|
};
|
|
2200
1790
|
var useHotkey = (combo, cb) => {
|
|
2201
|
-
(0,
|
|
1791
|
+
(0, import_react5.useEffect)(
|
|
2202
1792
|
() => useHotkeyStore.setState((s) => ({
|
|
2203
1793
|
triggers: __spreadProps(__spreadValues({}, s.triggers), {
|
|
2204
1794
|
[`${Object.keys(combo).join("+")}`]: { combo, cb }
|
|
@@ -2307,7 +1897,7 @@ function useRegisterHistorySlice(appStore, {
|
|
|
2307
1897
|
index,
|
|
2308
1898
|
initialAppState
|
|
2309
1899
|
}) {
|
|
2310
|
-
(0,
|
|
1900
|
+
(0, import_react6.useEffect)(
|
|
2311
1901
|
() => appStore.setState({
|
|
2312
1902
|
history: __spreadProps(__spreadValues({}, appStore.getState().history), {
|
|
2313
1903
|
histories,
|
|
@@ -2374,7 +1964,7 @@ var createNodesSlice = (set, get) => ({
|
|
|
2374
1964
|
|
|
2375
1965
|
// store/slices/permissions.ts
|
|
2376
1966
|
init_react_import();
|
|
2377
|
-
var
|
|
1967
|
+
var import_react7 = require("react");
|
|
2378
1968
|
|
|
2379
1969
|
// lib/data/flatten-data.ts
|
|
2380
1970
|
init_react_import();
|
|
@@ -2392,6 +1982,19 @@ var flattenData = (state, config) => {
|
|
|
2392
1982
|
return data;
|
|
2393
1983
|
};
|
|
2394
1984
|
|
|
1985
|
+
// lib/get-changed.ts
|
|
1986
|
+
init_react_import();
|
|
1987
|
+
var import_fast_deep_equal = __toESM(require("fast-deep-equal"));
|
|
1988
|
+
var getChanged = (newItem, oldItem) => {
|
|
1989
|
+
return newItem ? Object.keys(newItem.props || {}).reduce((acc, item) => {
|
|
1990
|
+
const newItemProps = (newItem == null ? void 0 : newItem.props) || {};
|
|
1991
|
+
const oldItemProps = (oldItem == null ? void 0 : oldItem.props) || {};
|
|
1992
|
+
return __spreadProps(__spreadValues({}, acc), {
|
|
1993
|
+
[item]: !(0, import_fast_deep_equal.default)(oldItemProps[item], newItemProps[item])
|
|
1994
|
+
});
|
|
1995
|
+
}, {}) : {};
|
|
1996
|
+
};
|
|
1997
|
+
|
|
2395
1998
|
// store/slices/permissions.ts
|
|
2396
1999
|
var createPermissionsSlice = (set, get) => {
|
|
2397
2000
|
const resolvePermissions = (..._0) => __async(void 0, [..._0], function* (params = {}, force) {
|
|
@@ -2498,7 +2101,7 @@ var createPermissionsSlice = (set, get) => {
|
|
|
2498
2101
|
};
|
|
2499
2102
|
};
|
|
2500
2103
|
var useRegisterPermissionsSlice = (appStore, globalPermissions) => {
|
|
2501
|
-
(0,
|
|
2104
|
+
(0, import_react7.useEffect)(() => {
|
|
2502
2105
|
const { permissions } = appStore.getState();
|
|
2503
2106
|
const { globalPermissions: existingGlobalPermissions } = permissions;
|
|
2504
2107
|
appStore.setState({
|
|
@@ -2508,7 +2111,7 @@ var useRegisterPermissionsSlice = (appStore, globalPermissions) => {
|
|
|
2508
2111
|
});
|
|
2509
2112
|
permissions.resolvePermissions();
|
|
2510
2113
|
}, [globalPermissions]);
|
|
2511
|
-
(0,
|
|
2114
|
+
(0, import_react7.useEffect)(() => {
|
|
2512
2115
|
return appStore.subscribe(
|
|
2513
2116
|
(s) => s.state.data,
|
|
2514
2117
|
() => {
|
|
@@ -2516,7 +2119,7 @@ var useRegisterPermissionsSlice = (appStore, globalPermissions) => {
|
|
|
2516
2119
|
}
|
|
2517
2120
|
);
|
|
2518
2121
|
}, []);
|
|
2519
|
-
(0,
|
|
2122
|
+
(0, import_react7.useEffect)(() => {
|
|
2520
2123
|
return appStore.subscribe(
|
|
2521
2124
|
(s) => s.config,
|
|
2522
2125
|
() => {
|
|
@@ -2528,7 +2131,7 @@ var useRegisterPermissionsSlice = (appStore, globalPermissions) => {
|
|
|
2528
2131
|
|
|
2529
2132
|
// store/slices/fields.ts
|
|
2530
2133
|
init_react_import();
|
|
2531
|
-
var
|
|
2134
|
+
var import_react8 = require("react");
|
|
2532
2135
|
var createFieldsSlice = (_set, _get) => {
|
|
2533
2136
|
return {
|
|
2534
2137
|
fields: {},
|
|
@@ -2538,7 +2141,7 @@ var createFieldsSlice = (_set, _get) => {
|
|
|
2538
2141
|
};
|
|
2539
2142
|
};
|
|
2540
2143
|
var useRegisterFieldsSlice = (appStore, id) => {
|
|
2541
|
-
const resolveFields = (0,
|
|
2144
|
+
const resolveFields = (0, import_react8.useCallback)(
|
|
2542
2145
|
(reset) => __async(void 0, null, function* () {
|
|
2543
2146
|
var _a, _b;
|
|
2544
2147
|
const { fields, lastResolvedData } = appStore.getState().fields;
|
|
@@ -2595,7 +2198,7 @@ var useRegisterFieldsSlice = (appStore, id) => {
|
|
|
2595
2198
|
}),
|
|
2596
2199
|
[id]
|
|
2597
2200
|
);
|
|
2598
|
-
(0,
|
|
2201
|
+
(0, import_react8.useEffect)(() => {
|
|
2599
2202
|
resolveFields(true);
|
|
2600
2203
|
return appStore.subscribe(
|
|
2601
2204
|
(s) => s.state.indexes.nodes[id || "root"],
|
|
@@ -2604,6 +2207,68 @@ var useRegisterFieldsSlice = (appStore, id) => {
|
|
|
2604
2207
|
}, [id]);
|
|
2605
2208
|
};
|
|
2606
2209
|
|
|
2210
|
+
// lib/resolve-component-data.ts
|
|
2211
|
+
init_react_import();
|
|
2212
|
+
var import_fast_deep_equal2 = __toESM(require("fast-deep-equal"));
|
|
2213
|
+
var cache = { lastChange: {} };
|
|
2214
|
+
var resolveComponentData = (_0, _1, ..._2) => __async(void 0, [_0, _1, ..._2], function* (item, config, metadata = {}, onResolveStart, onResolveEnd, trigger = "replace") {
|
|
2215
|
+
const configForItem = "type" in item && item.type !== "root" ? config.components[item.type] : config.root;
|
|
2216
|
+
const resolvedItem = __spreadValues({}, item);
|
|
2217
|
+
const shouldRunResolver = (configForItem == null ? void 0 : configForItem.resolveData) && item.props;
|
|
2218
|
+
const id = "id" in item.props ? item.props.id : "root";
|
|
2219
|
+
if (shouldRunResolver) {
|
|
2220
|
+
const { item: oldItem = null, resolved = {} } = cache.lastChange[id] || {};
|
|
2221
|
+
if (item && (0, import_fast_deep_equal2.default)(item, oldItem)) {
|
|
2222
|
+
return { node: resolved, didChange: false };
|
|
2223
|
+
}
|
|
2224
|
+
const changed = getChanged(item, oldItem);
|
|
2225
|
+
if (onResolveStart) {
|
|
2226
|
+
onResolveStart(item);
|
|
2227
|
+
}
|
|
2228
|
+
const { props: resolvedProps, readOnly = {} } = yield configForItem.resolveData(item, {
|
|
2229
|
+
changed,
|
|
2230
|
+
lastData: oldItem,
|
|
2231
|
+
metadata: __spreadValues(__spreadValues({}, metadata), configForItem.metadata),
|
|
2232
|
+
trigger
|
|
2233
|
+
});
|
|
2234
|
+
resolvedItem.props = __spreadValues(__spreadValues({}, item.props), resolvedProps);
|
|
2235
|
+
if (Object.keys(readOnly).length) {
|
|
2236
|
+
resolvedItem.readOnly = readOnly;
|
|
2237
|
+
}
|
|
2238
|
+
}
|
|
2239
|
+
let itemWithResolvedChildren = yield mapSlots(
|
|
2240
|
+
resolvedItem,
|
|
2241
|
+
(content) => __async(void 0, null, function* () {
|
|
2242
|
+
return yield Promise.all(
|
|
2243
|
+
content.map(
|
|
2244
|
+
(childItem) => __async(void 0, null, function* () {
|
|
2245
|
+
return (yield resolveComponentData(
|
|
2246
|
+
childItem,
|
|
2247
|
+
config,
|
|
2248
|
+
metadata,
|
|
2249
|
+
onResolveStart,
|
|
2250
|
+
onResolveEnd,
|
|
2251
|
+
trigger
|
|
2252
|
+
)).node;
|
|
2253
|
+
})
|
|
2254
|
+
)
|
|
2255
|
+
);
|
|
2256
|
+
}),
|
|
2257
|
+
config
|
|
2258
|
+
);
|
|
2259
|
+
if (shouldRunResolver && onResolveEnd) {
|
|
2260
|
+
onResolveEnd(resolvedItem);
|
|
2261
|
+
}
|
|
2262
|
+
cache.lastChange[id] = {
|
|
2263
|
+
item,
|
|
2264
|
+
resolved: itemWithResolvedChildren
|
|
2265
|
+
};
|
|
2266
|
+
return {
|
|
2267
|
+
node: itemWithResolvedChildren,
|
|
2268
|
+
didChange: !(0, import_fast_deep_equal2.default)(item, itemWithResolvedChildren)
|
|
2269
|
+
};
|
|
2270
|
+
});
|
|
2271
|
+
|
|
2607
2272
|
// lib/data/to-root.ts
|
|
2608
2273
|
init_react_import();
|
|
2609
2274
|
var toRoot = (item) => {
|
|
@@ -2618,7 +2283,35 @@ var toRoot = (item) => {
|
|
|
2618
2283
|
}
|
|
2619
2284
|
return { props: item.props, readOnly };
|
|
2620
2285
|
}
|
|
2621
|
-
return { props: {}, readOnly };
|
|
2286
|
+
return { props: {}, readOnly };
|
|
2287
|
+
};
|
|
2288
|
+
|
|
2289
|
+
// store/default-app-state.ts
|
|
2290
|
+
init_react_import();
|
|
2291
|
+
var defaultAppState = {
|
|
2292
|
+
data: { content: [], root: {}, zones: {} },
|
|
2293
|
+
ui: {
|
|
2294
|
+
leftSideBarVisible: true,
|
|
2295
|
+
rightSideBarVisible: true,
|
|
2296
|
+
arrayState: {},
|
|
2297
|
+
itemSelector: null,
|
|
2298
|
+
componentList: {},
|
|
2299
|
+
isDragging: false,
|
|
2300
|
+
previewMode: "edit",
|
|
2301
|
+
viewports: {
|
|
2302
|
+
current: {
|
|
2303
|
+
width: defaultViewports[0].width,
|
|
2304
|
+
height: defaultViewports[0].height || "auto"
|
|
2305
|
+
},
|
|
2306
|
+
options: [],
|
|
2307
|
+
controlsVisible: true
|
|
2308
|
+
},
|
|
2309
|
+
field: { focus: null }
|
|
2310
|
+
},
|
|
2311
|
+
indexes: {
|
|
2312
|
+
nodes: {},
|
|
2313
|
+
zones: {}
|
|
2314
|
+
}
|
|
2622
2315
|
};
|
|
2623
2316
|
|
|
2624
2317
|
// store/index.ts
|
|
@@ -2797,23 +2490,23 @@ var createAppStore = (initialAppStore) => (0, import_zustand2.create)()(
|
|
|
2797
2490
|
});
|
|
2798
2491
|
})
|
|
2799
2492
|
);
|
|
2800
|
-
var appStoreContext = (0,
|
|
2493
|
+
var appStoreContext = (0, import_react9.createContext)(createAppStore());
|
|
2801
2494
|
function useAppStore(selector) {
|
|
2802
|
-
const context = (0,
|
|
2495
|
+
const context = (0, import_react9.useContext)(appStoreContext);
|
|
2803
2496
|
return (0, import_zustand2.useStore)(context, selector);
|
|
2804
2497
|
}
|
|
2805
2498
|
function useAppStoreApi() {
|
|
2806
|
-
return (0,
|
|
2499
|
+
return (0, import_react9.useContext)(appStoreContext);
|
|
2807
2500
|
}
|
|
2808
2501
|
|
|
2809
2502
|
// components/Sortable/index.tsx
|
|
2810
2503
|
init_react_import();
|
|
2811
|
-
var
|
|
2504
|
+
var import_react12 = require("@dnd-kit/react");
|
|
2812
2505
|
|
|
2813
2506
|
// lib/dnd/use-sensors.ts
|
|
2814
2507
|
init_react_import();
|
|
2815
|
-
var
|
|
2816
|
-
var
|
|
2508
|
+
var import_react10 = require("react");
|
|
2509
|
+
var import_react11 = require("@dnd-kit/react");
|
|
2817
2510
|
var import_utilities = require("@dnd-kit/dom/utilities");
|
|
2818
2511
|
var touchDefault = { delay: { value: 200, tolerance: 10 } };
|
|
2819
2512
|
var otherDefault = {
|
|
@@ -2828,8 +2521,8 @@ var useSensors = ({
|
|
|
2828
2521
|
touch: touchDefault,
|
|
2829
2522
|
other: otherDefault
|
|
2830
2523
|
}) => {
|
|
2831
|
-
const [sensors] = (0,
|
|
2832
|
-
|
|
2524
|
+
const [sensors] = (0, import_react10.useState)(() => [
|
|
2525
|
+
import_react11.PointerSensor.configure({
|
|
2833
2526
|
activationConstraints(event, source) {
|
|
2834
2527
|
var _a;
|
|
2835
2528
|
const { pointerType, target } = event;
|
|
@@ -3164,7 +2857,7 @@ var createDynamicCollisionDetector = (dragAxis, midpointOffset = 0.05) => (input
|
|
|
3164
2857
|
|
|
3165
2858
|
// components/Sortable/index.tsx
|
|
3166
2859
|
var import_sortable = require("@dnd-kit/react/sortable");
|
|
3167
|
-
var
|
|
2860
|
+
var import_jsx_runtime5 = require("react/jsx-runtime");
|
|
3168
2861
|
var SortableProvider = ({
|
|
3169
2862
|
children,
|
|
3170
2863
|
onDragStart,
|
|
@@ -3174,8 +2867,8 @@ var SortableProvider = ({
|
|
|
3174
2867
|
const sensors = useSensors({
|
|
3175
2868
|
mouse: { distance: { value: 5 } }
|
|
3176
2869
|
});
|
|
3177
|
-
return /* @__PURE__ */ (0,
|
|
3178
|
-
|
|
2870
|
+
return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
2871
|
+
import_react12.DragDropProvider,
|
|
3179
2872
|
{
|
|
3180
2873
|
sensors,
|
|
3181
2874
|
onDragStart: (event) => {
|
|
@@ -3239,11 +2932,11 @@ var Sortable = ({
|
|
|
3239
2932
|
|
|
3240
2933
|
// components/AutoField/context.tsx
|
|
3241
2934
|
init_react_import();
|
|
3242
|
-
var
|
|
3243
|
-
var
|
|
3244
|
-
var NestedFieldContext = (0,
|
|
2935
|
+
var import_react13 = require("react");
|
|
2936
|
+
var import_jsx_runtime6 = require("react/jsx-runtime");
|
|
2937
|
+
var NestedFieldContext = (0, import_react13.createContext)({});
|
|
3245
2938
|
var useNestedFieldContext = () => {
|
|
3246
|
-
const context = (0,
|
|
2939
|
+
const context = (0, import_react13.useContext)(NestedFieldContext);
|
|
3247
2940
|
return __spreadProps(__spreadValues({}, context), {
|
|
3248
2941
|
readOnlyFields: context.readOnlyFields || {}
|
|
3249
2942
|
});
|
|
@@ -3257,7 +2950,7 @@ var NestedFieldProvider = ({
|
|
|
3257
2950
|
}) => {
|
|
3258
2951
|
const subPath = `${name}.${subName}`;
|
|
3259
2952
|
const wildcardSubPath = `${wildcardName}.${subName}`;
|
|
3260
|
-
const subReadOnlyFields = (0,
|
|
2953
|
+
const subReadOnlyFields = (0, import_react13.useMemo)(
|
|
3261
2954
|
() => Object.keys(readOnlyFields).reduce((acc, readOnlyKey) => {
|
|
3262
2955
|
const isLocal = readOnlyKey.indexOf(subPath) > -1 || readOnlyKey.indexOf(wildcardSubPath) > -1;
|
|
3263
2956
|
if (isLocal) {
|
|
@@ -3273,7 +2966,7 @@ var NestedFieldProvider = ({
|
|
|
3273
2966
|
}, {}),
|
|
3274
2967
|
[name, subName, wildcardName, readOnlyFields]
|
|
3275
2968
|
);
|
|
3276
|
-
return /* @__PURE__ */ (0,
|
|
2969
|
+
return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
|
|
3277
2970
|
NestedFieldContext.Provider,
|
|
3278
2971
|
{
|
|
3279
2972
|
value: { readOnlyFields: subReadOnlyFields, localName: subName },
|
|
@@ -3283,7 +2976,7 @@ var NestedFieldProvider = ({
|
|
|
3283
2976
|
};
|
|
3284
2977
|
|
|
3285
2978
|
// components/AutoField/fields/ArrayField/index.tsx
|
|
3286
|
-
var
|
|
2979
|
+
var import_jsx_runtime7 = require("react/jsx-runtime");
|
|
3287
2980
|
var getClassName5 = get_class_name_factory_default("ArrayField", styles_module_default3);
|
|
3288
2981
|
var getClassNameItem = get_class_name_factory_default("ArrayFieldItem", styles_module_default3);
|
|
3289
2982
|
var ArrayField = ({
|
|
@@ -3295,7 +2988,7 @@ var ArrayField = ({
|
|
|
3295
2988
|
labelIcon,
|
|
3296
2989
|
readOnly,
|
|
3297
2990
|
id,
|
|
3298
|
-
Label: Label2 = (props) => /* @__PURE__ */ (0,
|
|
2991
|
+
Label: Label2 = (props) => /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("div", __spreadValues({}, props))
|
|
3299
2992
|
}) => {
|
|
3300
2993
|
const thisArrayState = useAppStore((s) => s.state.ui.arrayState[id]);
|
|
3301
2994
|
const setUi = useAppStore((s) => s.setUi);
|
|
@@ -3310,14 +3003,14 @@ var ArrayField = ({
|
|
|
3310
3003
|
}),
|
|
3311
3004
|
openId: ""
|
|
3312
3005
|
};
|
|
3313
|
-
const [localState, setLocalState] = (0,
|
|
3314
|
-
(0,
|
|
3006
|
+
const [localState, setLocalState] = (0, import_react14.useState)({ arrayState, value });
|
|
3007
|
+
(0, import_react14.useEffect)(() => {
|
|
3315
3008
|
var _a;
|
|
3316
3009
|
const _arrayState = (_a = appStore.getState().state.ui.arrayState[id]) != null ? _a : arrayState;
|
|
3317
3010
|
setLocalState({ arrayState: _arrayState, value });
|
|
3318
3011
|
}, [value]);
|
|
3319
3012
|
const appStore = useAppStoreApi();
|
|
3320
|
-
const mapArrayStateToUi = (0,
|
|
3013
|
+
const mapArrayStateToUi = (0, import_react14.useCallback)(
|
|
3321
3014
|
(partialArrayState) => {
|
|
3322
3015
|
const state = appStore.getState().state;
|
|
3323
3016
|
return {
|
|
@@ -3328,13 +3021,13 @@ var ArrayField = ({
|
|
|
3328
3021
|
},
|
|
3329
3022
|
[arrayState, appStore]
|
|
3330
3023
|
);
|
|
3331
|
-
const getHighestIndex = (0,
|
|
3024
|
+
const getHighestIndex = (0, import_react14.useCallback)(() => {
|
|
3332
3025
|
return arrayState.items.reduce(
|
|
3333
3026
|
(acc, item) => item._originalIndex > acc ? item._originalIndex : acc,
|
|
3334
3027
|
-1
|
|
3335
3028
|
);
|
|
3336
3029
|
}, [arrayState]);
|
|
3337
|
-
const regenerateArrayState = (0,
|
|
3030
|
+
const regenerateArrayState = (0, import_react14.useCallback)(
|
|
3338
3031
|
(value2) => {
|
|
3339
3032
|
let highestIndex = getHighestIndex();
|
|
3340
3033
|
const newItems = Array.from(value2 || []).map((item, idx) => {
|
|
@@ -3353,19 +3046,19 @@ var ArrayField = ({
|
|
|
3353
3046
|
},
|
|
3354
3047
|
[arrayState]
|
|
3355
3048
|
);
|
|
3356
|
-
(0,
|
|
3049
|
+
(0, import_react14.useEffect)(() => {
|
|
3357
3050
|
if (arrayState.items.length > 0) {
|
|
3358
3051
|
setUi(mapArrayStateToUi(arrayState));
|
|
3359
3052
|
}
|
|
3360
3053
|
}, []);
|
|
3361
|
-
const [draggedItem, setDraggedItem] = (0,
|
|
3054
|
+
const [draggedItem, setDraggedItem] = (0, import_react14.useState)("");
|
|
3362
3055
|
const isDraggingAny = !!draggedItem;
|
|
3363
3056
|
const canEdit = useAppStore(
|
|
3364
3057
|
(s) => s.permissions.getPermissions({ item: s.selectedItem }).edit
|
|
3365
3058
|
);
|
|
3366
3059
|
const forceReadOnly = !canEdit;
|
|
3367
|
-
const valueRef = (0,
|
|
3368
|
-
const uniqifyItem = (0,
|
|
3060
|
+
const valueRef = (0, import_react14.useRef)(value);
|
|
3061
|
+
const uniqifyItem = (0, import_react14.useCallback)(
|
|
3369
3062
|
(val) => {
|
|
3370
3063
|
if (field.type !== "array" || !field.arrayFields) return;
|
|
3371
3064
|
const config = appStore.getState().config;
|
|
@@ -3382,14 +3075,14 @@ var ArrayField = ({
|
|
|
3382
3075
|
return null;
|
|
3383
3076
|
}
|
|
3384
3077
|
const addDisabled = field.max !== void 0 && localState.arrayState.items.length >= field.max || readOnly;
|
|
3385
|
-
return /* @__PURE__ */ (0,
|
|
3078
|
+
return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
|
|
3386
3079
|
Label2,
|
|
3387
3080
|
{
|
|
3388
3081
|
label: label || name,
|
|
3389
|
-
icon: labelIcon || /* @__PURE__ */ (0,
|
|
3082
|
+
icon: labelIcon || /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(List, { size: 16 }),
|
|
3390
3083
|
el: "div",
|
|
3391
3084
|
readOnly,
|
|
3392
|
-
children: /* @__PURE__ */ (0,
|
|
3085
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
|
|
3393
3086
|
SortableProvider,
|
|
3394
3087
|
{
|
|
3395
3088
|
onDragStart: (id2) => setDraggedItem(id2),
|
|
@@ -3420,7 +3113,7 @@ var ArrayField = ({
|
|
|
3420
3113
|
});
|
|
3421
3114
|
valueRef.current = newValue;
|
|
3422
3115
|
},
|
|
3423
|
-
children: /* @__PURE__ */ (0,
|
|
3116
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(
|
|
3424
3117
|
"div",
|
|
3425
3118
|
{
|
|
3426
3119
|
className: getClassName5({
|
|
@@ -3428,16 +3121,16 @@ var ArrayField = ({
|
|
|
3428
3121
|
addDisabled
|
|
3429
3122
|
}),
|
|
3430
3123
|
children: [
|
|
3431
|
-
localState.arrayState.items.length > 0 && /* @__PURE__ */ (0,
|
|
3124
|
+
localState.arrayState.items.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("div", { className: getClassName5("inner"), "data-dnd-container": true, children: localState.arrayState.items.map((item, i) => {
|
|
3432
3125
|
const { _arrayId = `${id}-${i}`, _originalIndex = i } = item;
|
|
3433
3126
|
const data = Array.from(localState.value || [])[i] || {};
|
|
3434
|
-
return /* @__PURE__ */ (0,
|
|
3127
|
+
return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
|
|
3435
3128
|
Sortable,
|
|
3436
3129
|
{
|
|
3437
3130
|
id: _arrayId,
|
|
3438
3131
|
index: i,
|
|
3439
3132
|
disabled: readOnly,
|
|
3440
|
-
children: ({ isDragging, ref, handleRef }) => /* @__PURE__ */ (0,
|
|
3133
|
+
children: ({ isDragging, ref, handleRef }) => /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(
|
|
3441
3134
|
"div",
|
|
3442
3135
|
{
|
|
3443
3136
|
ref,
|
|
@@ -3447,7 +3140,7 @@ var ArrayField = ({
|
|
|
3447
3140
|
readOnly
|
|
3448
3141
|
}),
|
|
3449
3142
|
children: [
|
|
3450
|
-
/* @__PURE__ */ (0,
|
|
3143
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(
|
|
3451
3144
|
"div",
|
|
3452
3145
|
{
|
|
3453
3146
|
ref: handleRef,
|
|
@@ -3472,9 +3165,9 @@ var ArrayField = ({
|
|
|
3472
3165
|
className: getClassNameItem("summary"),
|
|
3473
3166
|
children: [
|
|
3474
3167
|
field.getItemSummary ? field.getItemSummary(data, i) : `Item #${_originalIndex}`,
|
|
3475
|
-
/* @__PURE__ */ (0,
|
|
3476
|
-
!readOnly && /* @__PURE__ */ (0,
|
|
3477
|
-
/* @__PURE__ */ (0,
|
|
3168
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("div", { className: getClassNameItem("rhs"), children: [
|
|
3169
|
+
!readOnly && /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("div", { className: getClassNameItem("actions"), children: [
|
|
3170
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)("div", { className: getClassNameItem("action"), children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
|
|
3478
3171
|
IconButton,
|
|
3479
3172
|
{
|
|
3480
3173
|
type: "button",
|
|
@@ -3493,10 +3186,10 @@ var ArrayField = ({
|
|
|
3493
3186
|
onChange(existingValue);
|
|
3494
3187
|
},
|
|
3495
3188
|
title: "Duplicate",
|
|
3496
|
-
children: /* @__PURE__ */ (0,
|
|
3189
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(Copy, { size: 16 })
|
|
3497
3190
|
}
|
|
3498
3191
|
) }),
|
|
3499
|
-
/* @__PURE__ */ (0,
|
|
3192
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)("div", { className: getClassNameItem("action"), children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
|
|
3500
3193
|
IconButton,
|
|
3501
3194
|
{
|
|
3502
3195
|
type: "button",
|
|
@@ -3518,16 +3211,16 @@ var ArrayField = ({
|
|
|
3518
3211
|
onChange(existingValue);
|
|
3519
3212
|
},
|
|
3520
3213
|
title: "Delete",
|
|
3521
|
-
children: /* @__PURE__ */ (0,
|
|
3214
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(Trash, { size: 16 })
|
|
3522
3215
|
}
|
|
3523
3216
|
) })
|
|
3524
3217
|
] }),
|
|
3525
|
-
/* @__PURE__ */ (0,
|
|
3218
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)("div", { children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(DragIcon, {}) })
|
|
3526
3219
|
] })
|
|
3527
3220
|
]
|
|
3528
3221
|
}
|
|
3529
3222
|
),
|
|
3530
|
-
/* @__PURE__ */ (0,
|
|
3223
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)("div", { className: getClassNameItem("body"), children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("fieldset", { className: getClassNameItem("fieldset"), children: Object.keys(field.arrayFields).map((subName) => {
|
|
3531
3224
|
const subField = field.arrayFields[subName];
|
|
3532
3225
|
const indexName = `${name}[${i}]`;
|
|
3533
3226
|
const subPath = `${indexName}.${subName}`;
|
|
@@ -3537,14 +3230,14 @@ var ArrayField = ({
|
|
|
3537
3230
|
const localWildcardSubPath = `${localWildcardName}.${subName}`;
|
|
3538
3231
|
const subReadOnly = forceReadOnly ? forceReadOnly : typeof readOnlyFields[subPath] !== "undefined" ? readOnlyFields[localSubPath] : readOnlyFields[localWildcardSubPath];
|
|
3539
3232
|
const label2 = subField.label || subName;
|
|
3540
|
-
return /* @__PURE__ */ (0,
|
|
3233
|
+
return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
|
|
3541
3234
|
NestedFieldProvider,
|
|
3542
3235
|
{
|
|
3543
3236
|
name: localIndexName,
|
|
3544
3237
|
wildcardName: localWildcardName,
|
|
3545
3238
|
subName,
|
|
3546
3239
|
readOnlyFields,
|
|
3547
|
-
children: /* @__PURE__ */ (0,
|
|
3240
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
|
|
3548
3241
|
AutoFieldPrivate,
|
|
3549
3242
|
{
|
|
3550
3243
|
name: subPath,
|
|
@@ -3577,7 +3270,7 @@ var ArrayField = ({
|
|
|
3577
3270
|
_arrayId
|
|
3578
3271
|
);
|
|
3579
3272
|
}) }),
|
|
3580
|
-
!addDisabled && /* @__PURE__ */ (0,
|
|
3273
|
+
!addDisabled && /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
|
|
3581
3274
|
"button",
|
|
3582
3275
|
{
|
|
3583
3276
|
type: "button",
|
|
@@ -3595,7 +3288,7 @@ var ArrayField = ({
|
|
|
3595
3288
|
setUi(mapArrayStateToUi(newArrayState), false);
|
|
3596
3289
|
onChange(newValue);
|
|
3597
3290
|
},
|
|
3598
|
-
children: /* @__PURE__ */ (0,
|
|
3291
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(Plus, { size: 21 })
|
|
3599
3292
|
}
|
|
3600
3293
|
)
|
|
3601
3294
|
]
|
|
@@ -3609,7 +3302,7 @@ var ArrayField = ({
|
|
|
3609
3302
|
|
|
3610
3303
|
// components/AutoField/fields/DefaultField/index.tsx
|
|
3611
3304
|
init_react_import();
|
|
3612
|
-
var
|
|
3305
|
+
var import_jsx_runtime8 = require("react/jsx-runtime");
|
|
3613
3306
|
var getClassName6 = get_class_name_factory_default("Input", styles_module_default2);
|
|
3614
3307
|
var DefaultField = ({
|
|
3615
3308
|
field,
|
|
@@ -3623,16 +3316,16 @@ var DefaultField = ({
|
|
|
3623
3316
|
id
|
|
3624
3317
|
}) => {
|
|
3625
3318
|
const value = _value;
|
|
3626
|
-
return /* @__PURE__ */ (0,
|
|
3319
|
+
return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
|
|
3627
3320
|
Label2,
|
|
3628
3321
|
{
|
|
3629
3322
|
label: label || name,
|
|
3630
|
-
icon: labelIcon || /* @__PURE__ */ (0,
|
|
3631
|
-
field.type === "text" && /* @__PURE__ */ (0,
|
|
3632
|
-
field.type === "number" && /* @__PURE__ */ (0,
|
|
3323
|
+
icon: labelIcon || /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(import_jsx_runtime8.Fragment, { children: [
|
|
3324
|
+
field.type === "text" && /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(Type, { size: 16 }),
|
|
3325
|
+
field.type === "number" && /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(Hash, { size: 16 })
|
|
3633
3326
|
] }),
|
|
3634
3327
|
readOnly,
|
|
3635
|
-
children: /* @__PURE__ */ (0,
|
|
3328
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
|
|
3636
3329
|
"input",
|
|
3637
3330
|
{
|
|
3638
3331
|
className: getClassName6("input"),
|
|
@@ -3670,11 +3363,11 @@ var DefaultField = ({
|
|
|
3670
3363
|
|
|
3671
3364
|
// components/AutoField/fields/ExternalField/index.tsx
|
|
3672
3365
|
init_react_import();
|
|
3673
|
-
var
|
|
3366
|
+
var import_react18 = require("react");
|
|
3674
3367
|
|
|
3675
3368
|
// components/ExternalInput/index.tsx
|
|
3676
3369
|
init_react_import();
|
|
3677
|
-
var
|
|
3370
|
+
var import_react17 = require("react");
|
|
3678
3371
|
|
|
3679
3372
|
// css-module:/home/runner/work/puck/puck/packages/core/components/ExternalInput/styles.module.css#css-module
|
|
3680
3373
|
init_react_import();
|
|
@@ -3682,7 +3375,7 @@ var styles_module_default6 = { "ExternalInput-actions": "_ExternalInput-actions_
|
|
|
3682
3375
|
|
|
3683
3376
|
// components/Modal/index.tsx
|
|
3684
3377
|
init_react_import();
|
|
3685
|
-
var
|
|
3378
|
+
var import_react15 = require("react");
|
|
3686
3379
|
|
|
3687
3380
|
// css-module:/home/runner/work/puck/puck/packages/core/components/Modal/styles.module.css#css-module
|
|
3688
3381
|
init_react_import();
|
|
@@ -3690,22 +3383,22 @@ var styles_module_default7 = { "Modal": "_Modal_ikbaj_1", "Modal--isOpen": "_Mod
|
|
|
3690
3383
|
|
|
3691
3384
|
// components/Modal/index.tsx
|
|
3692
3385
|
var import_react_dom = require("react-dom");
|
|
3693
|
-
var
|
|
3386
|
+
var import_jsx_runtime9 = require("react/jsx-runtime");
|
|
3694
3387
|
var getClassName7 = get_class_name_factory_default("Modal", styles_module_default7);
|
|
3695
3388
|
var Modal = ({
|
|
3696
3389
|
children,
|
|
3697
3390
|
onClose,
|
|
3698
3391
|
isOpen
|
|
3699
3392
|
}) => {
|
|
3700
|
-
const [rootEl, setRootEl] = (0,
|
|
3701
|
-
(0,
|
|
3393
|
+
const [rootEl, setRootEl] = (0, import_react15.useState)(null);
|
|
3394
|
+
(0, import_react15.useEffect)(() => {
|
|
3702
3395
|
setRootEl(document.getElementById("puck-portal-root"));
|
|
3703
3396
|
}, []);
|
|
3704
3397
|
if (!rootEl) {
|
|
3705
|
-
return /* @__PURE__ */ (0,
|
|
3398
|
+
return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("div", {});
|
|
3706
3399
|
}
|
|
3707
3400
|
return (0, import_react_dom.createPortal)(
|
|
3708
|
-
/* @__PURE__ */ (0,
|
|
3401
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.jsx)("div", { className: getClassName7({ isOpen }), onClick: onClose, children: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
|
|
3709
3402
|
"div",
|
|
3710
3403
|
{
|
|
3711
3404
|
className: getClassName7("inner"),
|
|
@@ -3725,11 +3418,11 @@ init_react_import();
|
|
|
3725
3418
|
var styles_module_default8 = { "Heading": "_Heading_qxrry_1", "Heading--xxxxl": "_Heading--xxxxl_qxrry_12", "Heading--xxxl": "_Heading--xxxl_qxrry_18", "Heading--xxl": "_Heading--xxl_qxrry_22", "Heading--xl": "_Heading--xl_qxrry_26", "Heading--l": "_Heading--l_qxrry_30", "Heading--m": "_Heading--m_qxrry_34", "Heading--s": "_Heading--s_qxrry_38", "Heading--xs": "_Heading--xs_qxrry_42" };
|
|
3726
3419
|
|
|
3727
3420
|
// components/Heading/index.tsx
|
|
3728
|
-
var
|
|
3421
|
+
var import_jsx_runtime10 = require("react/jsx-runtime");
|
|
3729
3422
|
var getClassName8 = get_class_name_factory_default("Heading", styles_module_default8);
|
|
3730
3423
|
var Heading = ({ children, rank, size = "m" }) => {
|
|
3731
3424
|
const Tag = rank ? `h${rank}` : "span";
|
|
3732
|
-
return /* @__PURE__ */ (0,
|
|
3425
|
+
return /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
|
|
3733
3426
|
Tag,
|
|
3734
3427
|
{
|
|
3735
3428
|
className: getClassName8({
|
|
@@ -3745,7 +3438,7 @@ init_react_import();
|
|
|
3745
3438
|
|
|
3746
3439
|
// components/Button/Button.tsx
|
|
3747
3440
|
init_react_import();
|
|
3748
|
-
var
|
|
3441
|
+
var import_react16 = require("react");
|
|
3749
3442
|
|
|
3750
3443
|
// css-module:/home/runner/work/puck/puck/packages/core/components/Button/Button.module.css#css-module
|
|
3751
3444
|
init_react_import();
|
|
@@ -3765,7 +3458,7 @@ var filterDataAttrs = (props) => {
|
|
|
3765
3458
|
};
|
|
3766
3459
|
|
|
3767
3460
|
// components/Button/Button.tsx
|
|
3768
|
-
var
|
|
3461
|
+
var import_jsx_runtime11 = require("react/jsx-runtime");
|
|
3769
3462
|
var getClassName9 = get_class_name_factory_default("Button", Button_module_default);
|
|
3770
3463
|
var Button = (_a) => {
|
|
3771
3464
|
var _b = _a, {
|
|
@@ -3795,11 +3488,11 @@ var Button = (_a) => {
|
|
|
3795
3488
|
"size",
|
|
3796
3489
|
"loading"
|
|
3797
3490
|
]);
|
|
3798
|
-
const [loading, setLoading] = (0,
|
|
3799
|
-
(0,
|
|
3491
|
+
const [loading, setLoading] = (0, import_react16.useState)(loadingProp);
|
|
3492
|
+
(0, import_react16.useEffect)(() => setLoading(loadingProp), [loadingProp]);
|
|
3800
3493
|
const ElementType = href ? "a" : type ? "button" : "span";
|
|
3801
3494
|
const dataAttrs = filterDataAttrs(props);
|
|
3802
|
-
const el = /* @__PURE__ */ (0,
|
|
3495
|
+
const el = /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)(
|
|
3803
3496
|
ElementType,
|
|
3804
3497
|
__spreadProps(__spreadValues({
|
|
3805
3498
|
className: getClassName9({
|
|
@@ -3824,9 +3517,9 @@ var Button = (_a) => {
|
|
|
3824
3517
|
href
|
|
3825
3518
|
}, dataAttrs), {
|
|
3826
3519
|
children: [
|
|
3827
|
-
icon && /* @__PURE__ */ (0,
|
|
3520
|
+
icon && /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("div", { className: getClassName9("icon"), children: icon }),
|
|
3828
3521
|
children,
|
|
3829
|
-
loading && /* @__PURE__ */ (0,
|
|
3522
|
+
loading && /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("div", { className: getClassName9("spinner"), children: /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(Loader, { size: 14 }) })
|
|
3830
3523
|
]
|
|
3831
3524
|
})
|
|
3832
3525
|
);
|
|
@@ -3834,7 +3527,7 @@ var Button = (_a) => {
|
|
|
3834
3527
|
};
|
|
3835
3528
|
|
|
3836
3529
|
// components/ExternalInput/index.tsx
|
|
3837
|
-
var
|
|
3530
|
+
var import_jsx_runtime12 = require("react/jsx-runtime");
|
|
3838
3531
|
var getClassName10 = get_class_name_factory_default("ExternalInput", styles_module_default6);
|
|
3839
3532
|
var getClassNameModal = get_class_name_factory_default("ExternalInputModal", styles_module_default6);
|
|
3840
3533
|
var dataCache = {};
|
|
@@ -3851,28 +3544,28 @@ var ExternalInput = ({
|
|
|
3851
3544
|
mapRow = (val) => val,
|
|
3852
3545
|
filterFields
|
|
3853
3546
|
} = field || {};
|
|
3854
|
-
const [data, setData] = (0,
|
|
3855
|
-
const [isOpen, setOpen] = (0,
|
|
3856
|
-
const [isLoading, setIsLoading] = (0,
|
|
3547
|
+
const [data, setData] = (0, import_react17.useState)([]);
|
|
3548
|
+
const [isOpen, setOpen] = (0, import_react17.useState)(false);
|
|
3549
|
+
const [isLoading, setIsLoading] = (0, import_react17.useState)(true);
|
|
3857
3550
|
const hasFilterFields = !!filterFields;
|
|
3858
|
-
const [filters, setFilters] = (0,
|
|
3859
|
-
const [filtersToggled, setFiltersToggled] = (0,
|
|
3860
|
-
const mappedData = (0,
|
|
3551
|
+
const [filters, setFilters] = (0, import_react17.useState)(field.initialFilters || {});
|
|
3552
|
+
const [filtersToggled, setFiltersToggled] = (0, import_react17.useState)(hasFilterFields);
|
|
3553
|
+
const mappedData = (0, import_react17.useMemo)(() => {
|
|
3861
3554
|
return data.map(mapRow);
|
|
3862
3555
|
}, [data]);
|
|
3863
|
-
const keys = (0,
|
|
3556
|
+
const keys = (0, import_react17.useMemo)(() => {
|
|
3864
3557
|
const validKeys = /* @__PURE__ */ new Set();
|
|
3865
3558
|
for (const item of mappedData) {
|
|
3866
3559
|
for (const key of Object.keys(item)) {
|
|
3867
|
-
if (typeof item[key] === "string" || typeof item[key] === "number" || (0,
|
|
3560
|
+
if (typeof item[key] === "string" || typeof item[key] === "number" || (0, import_react17.isValidElement)(item[key])) {
|
|
3868
3561
|
validKeys.add(key);
|
|
3869
3562
|
}
|
|
3870
3563
|
}
|
|
3871
3564
|
}
|
|
3872
3565
|
return Array.from(validKeys);
|
|
3873
3566
|
}, [mappedData]);
|
|
3874
|
-
const [searchQuery, setSearchQuery] = (0,
|
|
3875
|
-
const search = (0,
|
|
3567
|
+
const [searchQuery, setSearchQuery] = (0, import_react17.useState)(field.initialQuery || "");
|
|
3568
|
+
const search = (0, import_react17.useCallback)(
|
|
3876
3569
|
(query, filters2) => __async(void 0, null, function* () {
|
|
3877
3570
|
setIsLoading(true);
|
|
3878
3571
|
const cacheKey = `${id}-${query}-${JSON.stringify(filters2)}`;
|
|
@@ -3885,18 +3578,18 @@ var ExternalInput = ({
|
|
|
3885
3578
|
}),
|
|
3886
3579
|
[id, field]
|
|
3887
3580
|
);
|
|
3888
|
-
const Footer = (0,
|
|
3889
|
-
(props) => field.renderFooter ? field.renderFooter(props) : /* @__PURE__ */ (0,
|
|
3581
|
+
const Footer = (0, import_react17.useCallback)(
|
|
3582
|
+
(props) => field.renderFooter ? field.renderFooter(props) : /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)("span", { className: getClassNameModal("footer"), children: [
|
|
3890
3583
|
props.items.length,
|
|
3891
3584
|
" result",
|
|
3892
3585
|
props.items.length === 1 ? "" : "s"
|
|
3893
3586
|
] }),
|
|
3894
3587
|
[field.renderFooter]
|
|
3895
3588
|
);
|
|
3896
|
-
(0,
|
|
3589
|
+
(0, import_react17.useEffect)(() => {
|
|
3897
3590
|
search(searchQuery, filters);
|
|
3898
3591
|
}, []);
|
|
3899
|
-
return /* @__PURE__ */ (0,
|
|
3592
|
+
return /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)(
|
|
3900
3593
|
"div",
|
|
3901
3594
|
{
|
|
3902
3595
|
className: getClassName10({
|
|
@@ -3906,21 +3599,21 @@ var ExternalInput = ({
|
|
|
3906
3599
|
}),
|
|
3907
3600
|
id,
|
|
3908
3601
|
children: [
|
|
3909
|
-
/* @__PURE__ */ (0,
|
|
3910
|
-
/* @__PURE__ */ (0,
|
|
3602
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsxs)("div", { className: getClassName10("actions"), children: [
|
|
3603
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
|
|
3911
3604
|
"button",
|
|
3912
3605
|
{
|
|
3913
3606
|
type: "button",
|
|
3914
3607
|
onClick: () => setOpen(true),
|
|
3915
3608
|
className: getClassName10("button"),
|
|
3916
3609
|
disabled: readOnly,
|
|
3917
|
-
children: value ? field.getItemSummary ? field.getItemSummary(value) : "External item" : /* @__PURE__ */ (0,
|
|
3918
|
-
/* @__PURE__ */ (0,
|
|
3919
|
-
/* @__PURE__ */ (0,
|
|
3610
|
+
children: value ? field.getItemSummary ? field.getItemSummary(value) : "External item" : /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)(import_jsx_runtime12.Fragment, { children: [
|
|
3611
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)(Link, { size: "16" }),
|
|
3612
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)("span", { children: field.placeholder })
|
|
3920
3613
|
] })
|
|
3921
3614
|
}
|
|
3922
3615
|
),
|
|
3923
|
-
value && /* @__PURE__ */ (0,
|
|
3616
|
+
value && /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
|
|
3924
3617
|
"button",
|
|
3925
3618
|
{
|
|
3926
3619
|
type: "button",
|
|
@@ -3929,11 +3622,11 @@ var ExternalInput = ({
|
|
|
3929
3622
|
onChange(null);
|
|
3930
3623
|
},
|
|
3931
3624
|
disabled: readOnly,
|
|
3932
|
-
children: /* @__PURE__ */ (0,
|
|
3625
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(LockOpen, { size: 16 })
|
|
3933
3626
|
}
|
|
3934
3627
|
)
|
|
3935
3628
|
] }),
|
|
3936
|
-
/* @__PURE__ */ (0,
|
|
3629
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)(Modal, { onClose: () => setOpen(false), isOpen, children: /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)(
|
|
3937
3630
|
"form",
|
|
3938
3631
|
{
|
|
3939
3632
|
className: getClassNameModal({
|
|
@@ -3947,11 +3640,11 @@ var ExternalInput = ({
|
|
|
3947
3640
|
search(searchQuery, filters);
|
|
3948
3641
|
},
|
|
3949
3642
|
children: [
|
|
3950
|
-
/* @__PURE__ */ (0,
|
|
3951
|
-
/* @__PURE__ */ (0,
|
|
3952
|
-
/* @__PURE__ */ (0,
|
|
3953
|
-
/* @__PURE__ */ (0,
|
|
3954
|
-
/* @__PURE__ */ (0,
|
|
3643
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)("div", { className: getClassNameModal("masthead"), children: field.showSearch ? /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)("div", { className: getClassNameModal("searchForm"), children: [
|
|
3644
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsxs)("label", { className: getClassNameModal("search"), children: [
|
|
3645
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)("span", { className: getClassNameModal("searchIconText"), children: "Search" }),
|
|
3646
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)("div", { className: getClassNameModal("searchIcon"), children: /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(Search, { size: "18" }) }),
|
|
3647
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
|
|
3955
3648
|
"input",
|
|
3956
3649
|
{
|
|
3957
3650
|
className: getClassNameModal("searchInput"),
|
|
@@ -3966,9 +3659,9 @@ var ExternalInput = ({
|
|
|
3966
3659
|
}
|
|
3967
3660
|
)
|
|
3968
3661
|
] }),
|
|
3969
|
-
/* @__PURE__ */ (0,
|
|
3970
|
-
/* @__PURE__ */ (0,
|
|
3971
|
-
hasFilterFields && /* @__PURE__ */ (0,
|
|
3662
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsxs)("div", { className: getClassNameModal("searchActions"), children: [
|
|
3663
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)(Button, { type: "submit", loading: isLoading, fullWidth: true, children: "Search" }),
|
|
3664
|
+
hasFilterFields && /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("div", { className: getClassNameModal("searchActionIcon"), children: /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
|
|
3972
3665
|
IconButton,
|
|
3973
3666
|
{
|
|
3974
3667
|
type: "button",
|
|
@@ -3978,19 +3671,19 @@ var ExternalInput = ({
|
|
|
3978
3671
|
e.stopPropagation();
|
|
3979
3672
|
setFiltersToggled(!filtersToggled);
|
|
3980
3673
|
},
|
|
3981
|
-
children: /* @__PURE__ */ (0,
|
|
3674
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(SlidersHorizontal, { size: 20 })
|
|
3982
3675
|
}
|
|
3983
3676
|
) })
|
|
3984
3677
|
] })
|
|
3985
|
-
] }) : /* @__PURE__ */ (0,
|
|
3986
|
-
/* @__PURE__ */ (0,
|
|
3987
|
-
hasFilterFields && /* @__PURE__ */ (0,
|
|
3678
|
+
] }) : /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(Heading, { rank: "2", size: "xs", children: field.placeholder || "Select data" }) }),
|
|
3679
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsxs)("div", { className: getClassNameModal("grid"), children: [
|
|
3680
|
+
hasFilterFields && /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("div", { className: getClassNameModal("filters"), children: hasFilterFields && Object.keys(filterFields).map((fieldName) => {
|
|
3988
3681
|
const filterField = filterFields[fieldName];
|
|
3989
|
-
return /* @__PURE__ */ (0,
|
|
3682
|
+
return /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
|
|
3990
3683
|
"div",
|
|
3991
3684
|
{
|
|
3992
3685
|
className: getClassNameModal("field"),
|
|
3993
|
-
children: /* @__PURE__ */ (0,
|
|
3686
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
|
|
3994
3687
|
AutoFieldPrivate,
|
|
3995
3688
|
{
|
|
3996
3689
|
field: filterField,
|
|
@@ -4011,9 +3704,9 @@ var ExternalInput = ({
|
|
|
4011
3704
|
fieldName
|
|
4012
3705
|
);
|
|
4013
3706
|
}) }),
|
|
4014
|
-
/* @__PURE__ */ (0,
|
|
4015
|
-
/* @__PURE__ */ (0,
|
|
4016
|
-
/* @__PURE__ */ (0,
|
|
3707
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsxs)("div", { className: getClassNameModal("tableWrapper"), children: [
|
|
3708
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsxs)("table", { className: getClassNameModal("table"), children: [
|
|
3709
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)("thead", { className: getClassNameModal("thead"), children: /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("tr", { className: getClassNameModal("tr"), children: keys.map((key) => /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
|
|
4017
3710
|
"th",
|
|
4018
3711
|
{
|
|
4019
3712
|
className: getClassNameModal("th"),
|
|
@@ -4022,8 +3715,8 @@ var ExternalInput = ({
|
|
|
4022
3715
|
},
|
|
4023
3716
|
key
|
|
4024
3717
|
)) }) }),
|
|
4025
|
-
/* @__PURE__ */ (0,
|
|
4026
|
-
return /* @__PURE__ */ (0,
|
|
3718
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)("tbody", { className: getClassNameModal("tbody"), children: mappedData.map((item, i) => {
|
|
3719
|
+
return /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
|
|
4027
3720
|
"tr",
|
|
4028
3721
|
{
|
|
4029
3722
|
style: { whiteSpace: "nowrap" },
|
|
@@ -4032,16 +3725,16 @@ var ExternalInput = ({
|
|
|
4032
3725
|
onChange(mapProp(data[i]));
|
|
4033
3726
|
setOpen(false);
|
|
4034
3727
|
},
|
|
4035
|
-
children: keys.map((key) => /* @__PURE__ */ (0,
|
|
3728
|
+
children: keys.map((key) => /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("td", { className: getClassNameModal("td"), children: item[key] }, key))
|
|
4036
3729
|
},
|
|
4037
3730
|
i
|
|
4038
3731
|
);
|
|
4039
3732
|
}) })
|
|
4040
3733
|
] }),
|
|
4041
|
-
/* @__PURE__ */ (0,
|
|
3734
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)("div", { className: getClassNameModal("loadingBanner"), children: /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(Loader, { size: 24 }) })
|
|
4042
3735
|
] })
|
|
4043
3736
|
] }),
|
|
4044
|
-
/* @__PURE__ */ (0,
|
|
3737
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)("div", { className: getClassNameModal("footerContainer"), children: /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(Footer, { items: mappedData }) })
|
|
4045
3738
|
]
|
|
4046
3739
|
}
|
|
4047
3740
|
) })
|
|
@@ -4051,7 +3744,7 @@ var ExternalInput = ({
|
|
|
4051
3744
|
};
|
|
4052
3745
|
|
|
4053
3746
|
// components/AutoField/fields/ExternalField/index.tsx
|
|
4054
|
-
var
|
|
3747
|
+
var import_jsx_runtime13 = require("react/jsx-runtime");
|
|
4055
3748
|
var ExternalField = ({
|
|
4056
3749
|
field,
|
|
4057
3750
|
onChange,
|
|
@@ -4066,7 +3759,7 @@ var ExternalField = ({
|
|
|
4066
3759
|
var _a, _b, _c;
|
|
4067
3760
|
const validField = field;
|
|
4068
3761
|
const deprecatedField = field;
|
|
4069
|
-
(0,
|
|
3762
|
+
(0, import_react18.useEffect)(() => {
|
|
4070
3763
|
if (deprecatedField.adaptor) {
|
|
4071
3764
|
console.error(
|
|
4072
3765
|
"Warning: The `adaptor` API is deprecated. Please use updated APIs on the `external` field instead. This will be a breaking change in a future release."
|
|
@@ -4076,13 +3769,13 @@ var ExternalField = ({
|
|
|
4076
3769
|
if (field.type !== "external") {
|
|
4077
3770
|
return null;
|
|
4078
3771
|
}
|
|
4079
|
-
return /* @__PURE__ */ (0,
|
|
3772
|
+
return /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
|
|
4080
3773
|
Label2,
|
|
4081
3774
|
{
|
|
4082
3775
|
label: label || name,
|
|
4083
|
-
icon: labelIcon || /* @__PURE__ */ (0,
|
|
3776
|
+
icon: labelIcon || /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(Link, { size: 16 }),
|
|
4084
3777
|
el: "div",
|
|
4085
|
-
children: /* @__PURE__ */ (0,
|
|
3778
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
|
|
4086
3779
|
ExternalInput,
|
|
4087
3780
|
{
|
|
4088
3781
|
name,
|
|
@@ -4109,21 +3802,7 @@ var ExternalField = ({
|
|
|
4109
3802
|
|
|
4110
3803
|
// components/AutoField/fields/RadioField/index.tsx
|
|
4111
3804
|
init_react_import();
|
|
4112
|
-
var
|
|
4113
|
-
|
|
4114
|
-
// lib/safe-json-parse.ts
|
|
4115
|
-
init_react_import();
|
|
4116
|
-
var safeJsonParse = (str) => {
|
|
4117
|
-
try {
|
|
4118
|
-
const jsonValue = JSON.parse(str);
|
|
4119
|
-
return jsonValue;
|
|
4120
|
-
} catch (e) {
|
|
4121
|
-
return str;
|
|
4122
|
-
}
|
|
4123
|
-
};
|
|
4124
|
-
|
|
4125
|
-
// components/AutoField/fields/RadioField/index.tsx
|
|
4126
|
-
var import_jsx_runtime16 = require("react/jsx-runtime");
|
|
3805
|
+
var import_jsx_runtime14 = require("react/jsx-runtime");
|
|
4127
3806
|
var getClassName11 = get_class_name_factory_default("Input", styles_module_default2);
|
|
4128
3807
|
var RadioField = ({
|
|
4129
3808
|
field,
|
|
@@ -4136,58 +3815,50 @@ var RadioField = ({
|
|
|
4136
3815
|
labelIcon,
|
|
4137
3816
|
Label: Label2
|
|
4138
3817
|
}) => {
|
|
4139
|
-
const flatOptions = (0, import_react21.useMemo)(
|
|
4140
|
-
() => field.type === "radio" ? field.options.map(({ value: value2 }) => value2) : [],
|
|
4141
|
-
[field]
|
|
4142
|
-
);
|
|
4143
3818
|
if (field.type !== "radio" || !field.options) {
|
|
4144
3819
|
return null;
|
|
4145
3820
|
}
|
|
4146
|
-
return /* @__PURE__ */ (0,
|
|
3821
|
+
return /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
|
|
4147
3822
|
Label2,
|
|
4148
3823
|
{
|
|
4149
|
-
icon: labelIcon || /* @__PURE__ */ (0,
|
|
3824
|
+
icon: labelIcon || /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(CircleCheckBig, { size: 16 }),
|
|
4150
3825
|
label: label || name,
|
|
4151
3826
|
readOnly,
|
|
4152
3827
|
el: "div",
|
|
4153
|
-
children: /* @__PURE__ */ (0,
|
|
4154
|
-
|
|
4155
|
-
|
|
4156
|
-
|
|
4157
|
-
|
|
4158
|
-
|
|
4159
|
-
|
|
4160
|
-
|
|
4161
|
-
|
|
4162
|
-
|
|
4163
|
-
|
|
4164
|
-
|
|
4165
|
-
|
|
4166
|
-
|
|
4167
|
-
|
|
4168
|
-
|
|
4169
|
-
|
|
4170
|
-
|
|
4171
|
-
|
|
4172
|
-
|
|
4173
|
-
|
|
4174
|
-
|
|
4175
|
-
|
|
4176
|
-
|
|
4177
|
-
|
|
4178
|
-
|
|
4179
|
-
|
|
4180
|
-
},
|
|
4181
|
-
option.label + option.value
|
|
4182
|
-
)) })
|
|
3828
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("div", { className: getClassName11("radioGroupItems"), id, children: field.options.map((option) => {
|
|
3829
|
+
var _a;
|
|
3830
|
+
return /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)(
|
|
3831
|
+
"label",
|
|
3832
|
+
{
|
|
3833
|
+
className: getClassName11("radio"),
|
|
3834
|
+
children: [
|
|
3835
|
+
/* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
|
|
3836
|
+
"input",
|
|
3837
|
+
{
|
|
3838
|
+
type: "radio",
|
|
3839
|
+
className: getClassName11("radioInput"),
|
|
3840
|
+
value: JSON.stringify({ value: option.value }),
|
|
3841
|
+
name,
|
|
3842
|
+
onChange: (e) => {
|
|
3843
|
+
onChange(JSON.parse(e.target.value).value);
|
|
3844
|
+
},
|
|
3845
|
+
disabled: readOnly,
|
|
3846
|
+
checked: value === option.value
|
|
3847
|
+
}
|
|
3848
|
+
),
|
|
3849
|
+
/* @__PURE__ */ (0, import_jsx_runtime14.jsx)("div", { className: getClassName11("radioInner"), children: option.label || ((_a = option.value) == null ? void 0 : _a.toString()) })
|
|
3850
|
+
]
|
|
3851
|
+
},
|
|
3852
|
+
option.label + option.value
|
|
3853
|
+
);
|
|
3854
|
+
}) })
|
|
4183
3855
|
}
|
|
4184
3856
|
);
|
|
4185
3857
|
};
|
|
4186
3858
|
|
|
4187
3859
|
// components/AutoField/fields/SelectField/index.tsx
|
|
4188
3860
|
init_react_import();
|
|
4189
|
-
var
|
|
4190
|
-
var import_jsx_runtime17 = require("react/jsx-runtime");
|
|
3861
|
+
var import_jsx_runtime15 = require("react/jsx-runtime");
|
|
4191
3862
|
var getClassName12 = get_class_name_factory_default("Input", styles_module_default2);
|
|
4192
3863
|
var SelectField = ({
|
|
4193
3864
|
field,
|
|
@@ -4200,20 +3871,16 @@ var SelectField = ({
|
|
|
4200
3871
|
readOnly,
|
|
4201
3872
|
id
|
|
4202
3873
|
}) => {
|
|
4203
|
-
const flatOptions = (0, import_react22.useMemo)(
|
|
4204
|
-
() => field.type === "select" ? field.options.map(({ value: value2 }) => value2) : [],
|
|
4205
|
-
[field]
|
|
4206
|
-
);
|
|
4207
3874
|
if (field.type !== "select" || !field.options) {
|
|
4208
3875
|
return null;
|
|
4209
3876
|
}
|
|
4210
|
-
return /* @__PURE__ */ (0,
|
|
3877
|
+
return /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
|
|
4211
3878
|
Label2,
|
|
4212
3879
|
{
|
|
4213
3880
|
label: label || name,
|
|
4214
|
-
icon: labelIcon || /* @__PURE__ */ (0,
|
|
3881
|
+
icon: labelIcon || /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(ChevronDown, { size: 16 }),
|
|
4215
3882
|
readOnly,
|
|
4216
|
-
children: /* @__PURE__ */ (0,
|
|
3883
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
|
|
4217
3884
|
"select",
|
|
4218
3885
|
{
|
|
4219
3886
|
id,
|
|
@@ -4221,22 +3888,16 @@ var SelectField = ({
|
|
|
4221
3888
|
className: getClassName12("input"),
|
|
4222
3889
|
disabled: readOnly,
|
|
4223
3890
|
onChange: (e) => {
|
|
4224
|
-
|
|
4225
|
-
const jsonValue = (_a = safeJsonParse(e.target.value)) != null ? _a : e.target.value;
|
|
4226
|
-
if (flatOptions.indexOf(jsonValue) > -1) {
|
|
4227
|
-
onChange(jsonValue);
|
|
4228
|
-
} else {
|
|
4229
|
-
onChange(e.target.value);
|
|
4230
|
-
}
|
|
3891
|
+
onChange(JSON.parse(e.target.value).value);
|
|
4231
3892
|
},
|
|
4232
|
-
value,
|
|
4233
|
-
children: field.options.map((option) => /* @__PURE__ */ (0,
|
|
3893
|
+
value: JSON.stringify({ value }),
|
|
3894
|
+
children: field.options.map((option) => /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
|
|
4234
3895
|
"option",
|
|
4235
3896
|
{
|
|
4236
3897
|
label: option.label,
|
|
4237
|
-
value: option.value
|
|
3898
|
+
value: JSON.stringify({ value: option.value })
|
|
4238
3899
|
},
|
|
4239
|
-
option.label + option.value
|
|
3900
|
+
option.label + JSON.stringify(option.value)
|
|
4240
3901
|
))
|
|
4241
3902
|
}
|
|
4242
3903
|
)
|
|
@@ -4246,7 +3907,7 @@ var SelectField = ({
|
|
|
4246
3907
|
|
|
4247
3908
|
// components/AutoField/fields/TextareaField/index.tsx
|
|
4248
3909
|
init_react_import();
|
|
4249
|
-
var
|
|
3910
|
+
var import_jsx_runtime16 = require("react/jsx-runtime");
|
|
4250
3911
|
var getClassName13 = get_class_name_factory_default("Input", styles_module_default2);
|
|
4251
3912
|
var TextareaField = ({
|
|
4252
3913
|
field,
|
|
@@ -4259,13 +3920,13 @@ var TextareaField = ({
|
|
|
4259
3920
|
Label: Label2,
|
|
4260
3921
|
id
|
|
4261
3922
|
}) => {
|
|
4262
|
-
return /* @__PURE__ */ (0,
|
|
3923
|
+
return /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
|
|
4263
3924
|
Label2,
|
|
4264
3925
|
{
|
|
4265
3926
|
label: label || name,
|
|
4266
|
-
icon: labelIcon || /* @__PURE__ */ (0,
|
|
3927
|
+
icon: labelIcon || /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(Type, { size: 16 }),
|
|
4267
3928
|
readOnly,
|
|
4268
|
-
children: /* @__PURE__ */ (0,
|
|
3929
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
|
|
4269
3930
|
"textarea",
|
|
4270
3931
|
{
|
|
4271
3932
|
id,
|
|
@@ -4292,7 +3953,7 @@ init_react_import();
|
|
|
4292
3953
|
var styles_module_default9 = { "ObjectField": "_ObjectField_1ua3y_5", "ObjectField-fieldset": "_ObjectField-fieldset_1ua3y_13" };
|
|
4293
3954
|
|
|
4294
3955
|
// components/AutoField/fields/ObjectField/index.tsx
|
|
4295
|
-
var
|
|
3956
|
+
var import_jsx_runtime17 = require("react/jsx-runtime");
|
|
4296
3957
|
var getClassName14 = get_class_name_factory_default("ObjectField", styles_module_default9);
|
|
4297
3958
|
var ObjectField = ({
|
|
4298
3959
|
field,
|
|
@@ -4310,25 +3971,25 @@ var ObjectField = ({
|
|
|
4310
3971
|
return null;
|
|
4311
3972
|
}
|
|
4312
3973
|
const data = value || {};
|
|
4313
|
-
return /* @__PURE__ */ (0,
|
|
3974
|
+
return /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
|
|
4314
3975
|
Label2,
|
|
4315
3976
|
{
|
|
4316
3977
|
label: label || name,
|
|
4317
|
-
icon: labelIcon || /* @__PURE__ */ (0,
|
|
3978
|
+
icon: labelIcon || /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(EllipsisVertical, { size: 16 }),
|
|
4318
3979
|
el: "div",
|
|
4319
3980
|
readOnly,
|
|
4320
|
-
children: /* @__PURE__ */ (0,
|
|
3981
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("div", { className: getClassName14(), children: /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("fieldset", { className: getClassName14("fieldset"), children: Object.keys(field.objectFields).map((subName) => {
|
|
4321
3982
|
const subField = field.objectFields[subName];
|
|
4322
3983
|
const subPath = `${localName}.${subName}`;
|
|
4323
3984
|
const subReadOnly = readOnly ? readOnly : readOnlyFields[subPath];
|
|
4324
3985
|
const label2 = subField.label || subName;
|
|
4325
|
-
return /* @__PURE__ */ (0,
|
|
3986
|
+
return /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
|
|
4326
3987
|
NestedFieldProvider,
|
|
4327
3988
|
{
|
|
4328
3989
|
name: localName || id,
|
|
4329
3990
|
subName,
|
|
4330
3991
|
readOnlyFields,
|
|
4331
|
-
children: /* @__PURE__ */ (0,
|
|
3992
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
|
|
4332
3993
|
AutoFieldPrivate,
|
|
4333
3994
|
{
|
|
4334
3995
|
name: subPath,
|
|
@@ -4360,17 +4021,17 @@ var ObjectField = ({
|
|
|
4360
4021
|
|
|
4361
4022
|
// lib/use-safe-id.ts
|
|
4362
4023
|
init_react_import();
|
|
4363
|
-
var
|
|
4024
|
+
var import_react19 = __toESM(require("react"));
|
|
4364
4025
|
var useSafeId = () => {
|
|
4365
|
-
if (typeof
|
|
4366
|
-
return
|
|
4026
|
+
if (typeof import_react19.default.useId !== "undefined") {
|
|
4027
|
+
return import_react19.default.useId();
|
|
4367
4028
|
}
|
|
4368
|
-
const [id] = (0,
|
|
4029
|
+
const [id] = (0, import_react19.useState)(generateId());
|
|
4369
4030
|
return id;
|
|
4370
4031
|
};
|
|
4371
4032
|
|
|
4372
4033
|
// components/AutoField/index.tsx
|
|
4373
|
-
var
|
|
4034
|
+
var import_jsx_runtime18 = require("react/jsx-runtime");
|
|
4374
4035
|
var getClassName15 = get_class_name_factory_default("Input", styles_module_default2);
|
|
4375
4036
|
var getClassNameWrapper = get_class_name_factory_default("InputWrapper", styles_module_default2);
|
|
4376
4037
|
var FieldLabel = ({
|
|
@@ -4382,11 +4043,11 @@ var FieldLabel = ({
|
|
|
4382
4043
|
className
|
|
4383
4044
|
}) => {
|
|
4384
4045
|
const El = el;
|
|
4385
|
-
return /* @__PURE__ */ (0,
|
|
4386
|
-
/* @__PURE__ */ (0,
|
|
4387
|
-
icon ? /* @__PURE__ */ (0,
|
|
4046
|
+
return /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)(El, { className, children: [
|
|
4047
|
+
/* @__PURE__ */ (0, import_jsx_runtime18.jsxs)("div", { className: getClassName15("label"), children: [
|
|
4048
|
+
icon ? /* @__PURE__ */ (0, import_jsx_runtime18.jsx)("div", { className: getClassName15("labelIcon"), children: icon }) : /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(import_jsx_runtime18.Fragment, {}),
|
|
4388
4049
|
label,
|
|
4389
|
-
readOnly && /* @__PURE__ */ (0,
|
|
4050
|
+
readOnly && /* @__PURE__ */ (0, import_jsx_runtime18.jsx)("div", { className: getClassName15("disabledIcon"), title: "Read-only", children: /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(Lock, { size: "12" }) })
|
|
4390
4051
|
] }),
|
|
4391
4052
|
children
|
|
4392
4053
|
] });
|
|
@@ -4399,14 +4060,14 @@ var FieldLabelInternal = ({
|
|
|
4399
4060
|
readOnly
|
|
4400
4061
|
}) => {
|
|
4401
4062
|
const overrides = useAppStore((s) => s.overrides);
|
|
4402
|
-
const Wrapper = (0,
|
|
4063
|
+
const Wrapper = (0, import_react20.useMemo)(
|
|
4403
4064
|
() => overrides.fieldLabel || FieldLabel,
|
|
4404
4065
|
[overrides]
|
|
4405
4066
|
);
|
|
4406
4067
|
if (!label) {
|
|
4407
|
-
return /* @__PURE__ */ (0,
|
|
4068
|
+
return /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(import_jsx_runtime18.Fragment, { children });
|
|
4408
4069
|
}
|
|
4409
|
-
return /* @__PURE__ */ (0,
|
|
4070
|
+
return /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
|
|
4410
4071
|
Wrapper,
|
|
4411
4072
|
{
|
|
4412
4073
|
label,
|
|
@@ -4426,7 +4087,7 @@ function AutoFieldInternal(props) {
|
|
|
4426
4087
|
var _a2;
|
|
4427
4088
|
return (_a2 = s.selectedItem) == null ? void 0 : _a2.readOnly;
|
|
4428
4089
|
});
|
|
4429
|
-
const nestedFieldContext = (0,
|
|
4090
|
+
const nestedFieldContext = (0, import_react20.useContext)(NestedFieldContext);
|
|
4430
4091
|
const { id, Label: Label2 = FieldLabelInternal } = props;
|
|
4431
4092
|
const field = props.field;
|
|
4432
4093
|
const label = field.label;
|
|
@@ -4460,7 +4121,7 @@ function AutoFieldInternal(props) {
|
|
|
4460
4121
|
Label: Label2,
|
|
4461
4122
|
id: resolvedId
|
|
4462
4123
|
});
|
|
4463
|
-
const onFocus = (0,
|
|
4124
|
+
const onFocus = (0, import_react20.useCallback)(
|
|
4464
4125
|
(e) => {
|
|
4465
4126
|
if (mergedProps.name && (e.target.nodeName === "INPUT" || e.target.nodeName === "TEXTAREA")) {
|
|
4466
4127
|
e.stopPropagation();
|
|
@@ -4474,7 +4135,7 @@ function AutoFieldInternal(props) {
|
|
|
4474
4135
|
},
|
|
4475
4136
|
[mergedProps.name]
|
|
4476
4137
|
);
|
|
4477
|
-
const onBlur = (0,
|
|
4138
|
+
const onBlur = (0, import_react20.useCallback)((e) => {
|
|
4478
4139
|
if ("name" in e.target) {
|
|
4479
4140
|
dispatch({
|
|
4480
4141
|
type: "setUi",
|
|
@@ -4502,14 +4163,14 @@ function AutoFieldInternal(props) {
|
|
|
4502
4163
|
children = defaultFields[field.type](mergedProps);
|
|
4503
4164
|
FieldComponent = render[field.type];
|
|
4504
4165
|
}
|
|
4505
|
-
return /* @__PURE__ */ (0,
|
|
4166
|
+
return /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
|
|
4506
4167
|
NestedFieldContext.Provider,
|
|
4507
4168
|
{
|
|
4508
4169
|
value: {
|
|
4509
4170
|
readOnlyFields: nestedFieldContext.readOnlyFields || readOnly || {},
|
|
4510
4171
|
localName: (_i = nestedFieldContext.localName) != null ? _i : mergedProps.name
|
|
4511
4172
|
},
|
|
4512
|
-
children: /* @__PURE__ */ (0,
|
|
4173
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
|
|
4513
4174
|
"div",
|
|
4514
4175
|
{
|
|
4515
4176
|
className: getClassNameWrapper(),
|
|
@@ -4518,7 +4179,7 @@ function AutoFieldInternal(props) {
|
|
|
4518
4179
|
onClick: (e) => {
|
|
4519
4180
|
e.stopPropagation();
|
|
4520
4181
|
},
|
|
4521
|
-
children: /* @__PURE__ */ (0,
|
|
4182
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(FieldComponent, __spreadProps(__spreadValues({}, mergedProps), { children }))
|
|
4522
4183
|
}
|
|
4523
4184
|
)
|
|
4524
4185
|
}
|
|
@@ -4527,20 +4188,20 @@ function AutoFieldInternal(props) {
|
|
|
4527
4188
|
function AutoFieldPrivate(props) {
|
|
4528
4189
|
const isFocused = useAppStore((s) => s.state.ui.field.focus === props.name);
|
|
4529
4190
|
const { value, onChange } = props;
|
|
4530
|
-
const [localValue, setLocalValue] = (0,
|
|
4531
|
-
const onChangeLocal = (0,
|
|
4191
|
+
const [localValue, setLocalValue] = (0, import_react20.useState)(value);
|
|
4192
|
+
const onChangeLocal = (0, import_react20.useCallback)(
|
|
4532
4193
|
(val, ui) => {
|
|
4533
4194
|
setLocalValue(val);
|
|
4534
4195
|
onChange(val, ui);
|
|
4535
4196
|
},
|
|
4536
4197
|
[onChange]
|
|
4537
4198
|
);
|
|
4538
|
-
(0,
|
|
4199
|
+
(0, import_react20.useEffect)(() => {
|
|
4539
4200
|
if (!isFocused) {
|
|
4540
4201
|
setLocalValue(value);
|
|
4541
4202
|
}
|
|
4542
4203
|
}, [value]);
|
|
4543
|
-
(0,
|
|
4204
|
+
(0, import_react20.useEffect)(() => {
|
|
4544
4205
|
if (!isFocused) {
|
|
4545
4206
|
if (value !== localValue) {
|
|
4546
4207
|
setLocalValue(value);
|
|
@@ -4551,11 +4212,11 @@ function AutoFieldPrivate(props) {
|
|
|
4551
4212
|
value: localValue,
|
|
4552
4213
|
onChange: onChangeLocal
|
|
4553
4214
|
};
|
|
4554
|
-
return /* @__PURE__ */ (0,
|
|
4215
|
+
return /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(AutoFieldInternal, __spreadValues(__spreadValues({}, props), localProps));
|
|
4555
4216
|
}
|
|
4556
4217
|
function AutoField(props) {
|
|
4557
|
-
const DefaultLabel = (0,
|
|
4558
|
-
const DefaultLabel2 = (labelProps) => /* @__PURE__ */ (0,
|
|
4218
|
+
const DefaultLabel = (0, import_react20.useMemo)(() => {
|
|
4219
|
+
const DefaultLabel2 = (labelProps) => /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
|
|
4559
4220
|
"div",
|
|
4560
4221
|
__spreadProps(__spreadValues({}, labelProps), {
|
|
4561
4222
|
className: getClassName15({ readOnly: props.readOnly })
|
|
@@ -4566,7 +4227,7 @@ function AutoField(props) {
|
|
|
4566
4227
|
if (props.field.type === "slot") {
|
|
4567
4228
|
return null;
|
|
4568
4229
|
}
|
|
4569
|
-
return /* @__PURE__ */ (0,
|
|
4230
|
+
return /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(AutoFieldInternal, __spreadProps(__spreadValues({}, props), { Label: DefaultLabel }));
|
|
4570
4231
|
}
|
|
4571
4232
|
|
|
4572
4233
|
// components/Drawer/index.tsx
|
|
@@ -4577,21 +4238,21 @@ init_react_import();
|
|
|
4577
4238
|
var styles_module_default10 = { "Drawer": "_Drawer_pl7z0_1", "Drawer-draggable": "_Drawer-draggable_pl7z0_8", "Drawer-draggableBg": "_Drawer-draggableBg_pl7z0_12", "DrawerItem-draggable": "_DrawerItem-draggable_pl7z0_22", "DrawerItem--disabled": "_DrawerItem--disabled_pl7z0_35", "DrawerItem": "_DrawerItem_pl7z0_22", "Drawer--isDraggingFrom": "_Drawer--isDraggingFrom_pl7z0_45", "DrawerItem-name": "_DrawerItem-name_pl7z0_63" };
|
|
4578
4239
|
|
|
4579
4240
|
// components/Drawer/index.tsx
|
|
4580
|
-
var
|
|
4241
|
+
var import_react37 = require("react");
|
|
4581
4242
|
|
|
4582
4243
|
// components/DragDropContext/index.tsx
|
|
4583
4244
|
init_react_import();
|
|
4584
|
-
var
|
|
4585
|
-
var
|
|
4245
|
+
var import_react35 = require("@dnd-kit/react");
|
|
4246
|
+
var import_react36 = require("react");
|
|
4586
4247
|
var import_dom = require("@dnd-kit/dom");
|
|
4587
4248
|
|
|
4588
4249
|
// components/DropZone/index.tsx
|
|
4589
4250
|
init_react_import();
|
|
4590
|
-
var
|
|
4251
|
+
var import_react33 = require("react");
|
|
4591
4252
|
|
|
4592
4253
|
// components/DraggableComponent/index.tsx
|
|
4593
4254
|
init_react_import();
|
|
4594
|
-
var
|
|
4255
|
+
var import_react24 = require("react");
|
|
4595
4256
|
|
|
4596
4257
|
// css-module:/home/runner/work/puck/puck/packages/core/components/DraggableComponent/styles.module.css#css-module
|
|
4597
4258
|
init_react_import();
|
|
@@ -4621,11 +4282,11 @@ function getDeepScrollPosition(element) {
|
|
|
4621
4282
|
|
|
4622
4283
|
// components/DropZone/context.tsx
|
|
4623
4284
|
init_react_import();
|
|
4624
|
-
var
|
|
4285
|
+
var import_react21 = require("react");
|
|
4625
4286
|
var import_zustand3 = require("zustand");
|
|
4626
|
-
var
|
|
4627
|
-
var dropZoneContext = (0,
|
|
4628
|
-
var ZoneStoreContext = (0,
|
|
4287
|
+
var import_jsx_runtime19 = require("react/jsx-runtime");
|
|
4288
|
+
var dropZoneContext = (0, import_react21.createContext)(null);
|
|
4289
|
+
var ZoneStoreContext = (0, import_react21.createContext)(
|
|
4629
4290
|
(0, import_zustand3.createStore)(() => ({
|
|
4630
4291
|
zoneDepthIndex: {},
|
|
4631
4292
|
nextZoneDepthIndex: {},
|
|
@@ -4641,14 +4302,14 @@ var ZoneStoreProvider = ({
|
|
|
4641
4302
|
children,
|
|
4642
4303
|
store
|
|
4643
4304
|
}) => {
|
|
4644
|
-
return /* @__PURE__ */ (0,
|
|
4305
|
+
return /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(ZoneStoreContext.Provider, { value: store, children });
|
|
4645
4306
|
};
|
|
4646
4307
|
var DropZoneProvider = ({
|
|
4647
4308
|
children,
|
|
4648
4309
|
value
|
|
4649
4310
|
}) => {
|
|
4650
4311
|
const dispatch = useAppStore((s) => s.dispatch);
|
|
4651
|
-
const registerZone = (0,
|
|
4312
|
+
const registerZone = (0, import_react21.useCallback)(
|
|
4652
4313
|
(zoneCompound) => {
|
|
4653
4314
|
dispatch({
|
|
4654
4315
|
type: "registerZone",
|
|
@@ -4657,23 +4318,13 @@ var DropZoneProvider = ({
|
|
|
4657
4318
|
},
|
|
4658
4319
|
[dispatch]
|
|
4659
4320
|
);
|
|
4660
|
-
const
|
|
4661
|
-
(zoneCompound) => {
|
|
4662
|
-
dispatch({
|
|
4663
|
-
type: "unregisterZone",
|
|
4664
|
-
zone: zoneCompound
|
|
4665
|
-
});
|
|
4666
|
-
},
|
|
4667
|
-
[dispatch]
|
|
4668
|
-
);
|
|
4669
|
-
const memoValue = (0, import_react25.useMemo)(
|
|
4321
|
+
const memoValue = (0, import_react21.useMemo)(
|
|
4670
4322
|
() => __spreadValues({
|
|
4671
|
-
registerZone
|
|
4672
|
-
unregisterZone
|
|
4323
|
+
registerZone
|
|
4673
4324
|
}, value),
|
|
4674
4325
|
[value]
|
|
4675
4326
|
);
|
|
4676
|
-
return /* @__PURE__ */ (0,
|
|
4327
|
+
return /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(import_jsx_runtime19.Fragment, { children: memoValue && /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(dropZoneContext.Provider, { value: memoValue, children }) });
|
|
4677
4328
|
};
|
|
4678
4329
|
|
|
4679
4330
|
// components/DraggableComponent/index.tsx
|
|
@@ -4697,11 +4348,11 @@ function accumulateTransform(el) {
|
|
|
4697
4348
|
|
|
4698
4349
|
// lib/use-context-store.ts
|
|
4699
4350
|
init_react_import();
|
|
4700
|
-
var
|
|
4351
|
+
var import_react22 = require("react");
|
|
4701
4352
|
var import_zustand4 = require("zustand");
|
|
4702
4353
|
var import_shallow = require("zustand/react/shallow");
|
|
4703
4354
|
function useContextStore(context, selector) {
|
|
4704
|
-
const store = (0,
|
|
4355
|
+
const store = (0, import_react22.useContext)(context);
|
|
4705
4356
|
if (!store) {
|
|
4706
4357
|
throw new Error("useContextStore must be used inside context");
|
|
4707
4358
|
}
|
|
@@ -4710,10 +4361,10 @@ function useContextStore(context, selector) {
|
|
|
4710
4361
|
|
|
4711
4362
|
// lib/dnd/use-on-drag-finished.ts
|
|
4712
4363
|
init_react_import();
|
|
4713
|
-
var
|
|
4364
|
+
var import_react23 = require("react");
|
|
4714
4365
|
var useOnDragFinished = (cb, deps = []) => {
|
|
4715
4366
|
const appStore = useAppStoreApi();
|
|
4716
|
-
return (0,
|
|
4367
|
+
return (0, import_react23.useCallback)(() => {
|
|
4717
4368
|
let dispose = () => {
|
|
4718
4369
|
};
|
|
4719
4370
|
const processDragging = (isDragging2) => {
|
|
@@ -4741,7 +4392,7 @@ var useOnDragFinished = (cb, deps = []) => {
|
|
|
4741
4392
|
};
|
|
4742
4393
|
|
|
4743
4394
|
// components/DraggableComponent/index.tsx
|
|
4744
|
-
var
|
|
4395
|
+
var import_jsx_runtime20 = require("react/jsx-runtime");
|
|
4745
4396
|
var getClassName16 = get_class_name_factory_default("DraggableComponent", styles_module_default11);
|
|
4746
4397
|
var DEBUG2 = false;
|
|
4747
4398
|
var space = 8;
|
|
@@ -4752,12 +4403,12 @@ var DefaultActionBar = ({
|
|
|
4752
4403
|
label,
|
|
4753
4404
|
children,
|
|
4754
4405
|
parentAction
|
|
4755
|
-
}) => /* @__PURE__ */ (0,
|
|
4756
|
-
/* @__PURE__ */ (0,
|
|
4406
|
+
}) => /* @__PURE__ */ (0, import_jsx_runtime20.jsxs)(ActionBar, { children: [
|
|
4407
|
+
/* @__PURE__ */ (0, import_jsx_runtime20.jsxs)(ActionBar.Group, { children: [
|
|
4757
4408
|
parentAction,
|
|
4758
|
-
label && /* @__PURE__ */ (0,
|
|
4409
|
+
label && /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(ActionBar.Label, { label })
|
|
4759
4410
|
] }),
|
|
4760
|
-
/* @__PURE__ */ (0,
|
|
4411
|
+
/* @__PURE__ */ (0, import_jsx_runtime20.jsx)(ActionBar.Group, { children })
|
|
4761
4412
|
] });
|
|
4762
4413
|
var DraggableComponent = ({
|
|
4763
4414
|
children,
|
|
@@ -4783,9 +4434,9 @@ var DraggableComponent = ({
|
|
|
4783
4434
|
const overrides = useAppStore((s) => s.overrides);
|
|
4784
4435
|
const dispatch = useAppStore((s) => s.dispatch);
|
|
4785
4436
|
const iframe = useAppStore((s) => s.iframe);
|
|
4786
|
-
const ctx = (0,
|
|
4787
|
-
const [localZones, setLocalZones] = (0,
|
|
4788
|
-
const registerLocalZone = (0,
|
|
4437
|
+
const ctx = (0, import_react24.useContext)(dropZoneContext);
|
|
4438
|
+
const [localZones, setLocalZones] = (0, import_react24.useState)({});
|
|
4439
|
+
const registerLocalZone = (0, import_react24.useCallback)(
|
|
4789
4440
|
(zoneCompound2, active) => {
|
|
4790
4441
|
var _a;
|
|
4791
4442
|
(_a = ctx == null ? void 0 : ctx.registerLocalZone) == null ? void 0 : _a.call(ctx, zoneCompound2, active);
|
|
@@ -4795,7 +4446,7 @@ var DraggableComponent = ({
|
|
|
4795
4446
|
},
|
|
4796
4447
|
[setLocalZones]
|
|
4797
4448
|
);
|
|
4798
|
-
const unregisterLocalZone = (0,
|
|
4449
|
+
const unregisterLocalZone = (0, import_react24.useCallback)(
|
|
4799
4450
|
(zoneCompound2) => {
|
|
4800
4451
|
var _a;
|
|
4801
4452
|
(_a = ctx == null ? void 0 : ctx.unregisterLocalZone) == null ? void 0 : _a.call(ctx, zoneCompound2);
|
|
@@ -4818,9 +4469,9 @@ var DraggableComponent = ({
|
|
|
4818
4469
|
return s.permissions.getPermissions({ item });
|
|
4819
4470
|
})
|
|
4820
4471
|
);
|
|
4821
|
-
const zoneStore = (0,
|
|
4822
|
-
const [dragAxis, setDragAxis] = (0,
|
|
4823
|
-
const dynamicCollisionDetector = (0,
|
|
4472
|
+
const zoneStore = (0, import_react24.useContext)(ZoneStoreContext);
|
|
4473
|
+
const [dragAxis, setDragAxis] = (0, import_react24.useState)(userDragAxis || autoDragAxis);
|
|
4474
|
+
const dynamicCollisionDetector = (0, import_react24.useMemo)(
|
|
4824
4475
|
() => createDynamicCollisionDetector(dragAxis),
|
|
4825
4476
|
[dragAxis]
|
|
4826
4477
|
);
|
|
@@ -4852,7 +4503,7 @@ var DraggableComponent = ({
|
|
|
4852
4503
|
},
|
|
4853
4504
|
feedback: "clone"
|
|
4854
4505
|
});
|
|
4855
|
-
(0,
|
|
4506
|
+
(0, import_react24.useEffect)(() => {
|
|
4856
4507
|
const isEnabled = zoneStore.getState().enabledIndex[zoneCompound];
|
|
4857
4508
|
sortable.droppable.disabled = !isEnabled;
|
|
4858
4509
|
sortable.draggable.disabled = !permissions.drag;
|
|
@@ -4869,8 +4520,8 @@ var DraggableComponent = ({
|
|
|
4869
4520
|
}
|
|
4870
4521
|
return cleanup;
|
|
4871
4522
|
}, [permissions.drag, zoneCompound]);
|
|
4872
|
-
const ref = (0,
|
|
4873
|
-
const refSetter = (0,
|
|
4523
|
+
const ref = (0, import_react24.useRef)(null);
|
|
4524
|
+
const refSetter = (0, import_react24.useCallback)(
|
|
4874
4525
|
(el) => {
|
|
4875
4526
|
sortableRef(el);
|
|
4876
4527
|
if (el) {
|
|
@@ -4879,14 +4530,14 @@ var DraggableComponent = ({
|
|
|
4879
4530
|
},
|
|
4880
4531
|
[sortableRef]
|
|
4881
4532
|
);
|
|
4882
|
-
const [portalEl, setPortalEl] = (0,
|
|
4883
|
-
(0,
|
|
4533
|
+
const [portalEl, setPortalEl] = (0, import_react24.useState)();
|
|
4534
|
+
(0, import_react24.useEffect)(() => {
|
|
4884
4535
|
var _a, _b, _c;
|
|
4885
4536
|
setPortalEl(
|
|
4886
4537
|
iframe.enabled ? (_a = ref.current) == null ? void 0 : _a.ownerDocument.body : (_c = (_b = ref.current) == null ? void 0 : _b.closest("[data-puck-preview]")) != null ? _c : document.body
|
|
4887
4538
|
);
|
|
4888
4539
|
}, [iframe.enabled, ref.current]);
|
|
4889
|
-
const getStyle = (0,
|
|
4540
|
+
const getStyle = (0, import_react24.useCallback)(() => {
|
|
4890
4541
|
var _a, _b, _c;
|
|
4891
4542
|
if (!ref.current) return;
|
|
4892
4543
|
const rect = ref.current.getBoundingClientRect();
|
|
@@ -4911,11 +4562,11 @@ var DraggableComponent = ({
|
|
|
4911
4562
|
};
|
|
4912
4563
|
return style2;
|
|
4913
4564
|
}, [ref.current]);
|
|
4914
|
-
const [style, setStyle] = (0,
|
|
4915
|
-
const sync = (0,
|
|
4565
|
+
const [style, setStyle] = (0, import_react24.useState)();
|
|
4566
|
+
const sync = (0, import_react24.useCallback)(() => {
|
|
4916
4567
|
setStyle(getStyle());
|
|
4917
4568
|
}, [ref.current, iframe]);
|
|
4918
|
-
(0,
|
|
4569
|
+
(0, import_react24.useEffect)(() => {
|
|
4919
4570
|
if (ref.current) {
|
|
4920
4571
|
const observer = new ResizeObserver(sync);
|
|
4921
4572
|
observer.observe(ref.current);
|
|
@@ -4925,13 +4576,13 @@ var DraggableComponent = ({
|
|
|
4925
4576
|
}
|
|
4926
4577
|
}, [ref.current]);
|
|
4927
4578
|
const registerNode = useAppStore((s) => s.nodes.registerNode);
|
|
4928
|
-
const hideOverlay = (0,
|
|
4579
|
+
const hideOverlay = (0, import_react24.useCallback)(() => {
|
|
4929
4580
|
setIsVisible(false);
|
|
4930
4581
|
}, []);
|
|
4931
|
-
const showOverlay = (0,
|
|
4582
|
+
const showOverlay = (0, import_react24.useCallback)(() => {
|
|
4932
4583
|
setIsVisible(true);
|
|
4933
4584
|
}, []);
|
|
4934
|
-
(0,
|
|
4585
|
+
(0, import_react24.useEffect)(() => {
|
|
4935
4586
|
var _a;
|
|
4936
4587
|
registerNode(id, {
|
|
4937
4588
|
methods: { sync, showOverlay, hideOverlay },
|
|
@@ -4948,11 +4599,11 @@ var DraggableComponent = ({
|
|
|
4948
4599
|
});
|
|
4949
4600
|
};
|
|
4950
4601
|
}, [id, zoneCompound, index, componentType, sync]);
|
|
4951
|
-
const CustomActionBar = (0,
|
|
4602
|
+
const CustomActionBar = (0, import_react24.useMemo)(
|
|
4952
4603
|
() => overrides.actionBar || DefaultActionBar,
|
|
4953
4604
|
[overrides.actionBar]
|
|
4954
4605
|
);
|
|
4955
|
-
const onClick = (0,
|
|
4606
|
+
const onClick = (0, import_react24.useCallback)(
|
|
4956
4607
|
(e) => {
|
|
4957
4608
|
e.stopPropagation();
|
|
4958
4609
|
dispatch({
|
|
@@ -4965,7 +4616,7 @@ var DraggableComponent = ({
|
|
|
4965
4616
|
[index, zoneCompound, id]
|
|
4966
4617
|
);
|
|
4967
4618
|
const appStore = useAppStoreApi();
|
|
4968
|
-
const onSelectParent = (0,
|
|
4619
|
+
const onSelectParent = (0, import_react24.useCallback)(() => {
|
|
4969
4620
|
const { nodes, zones } = appStore.getState().state.indexes;
|
|
4970
4621
|
const node = nodes[id];
|
|
4971
4622
|
const parentNode = (node == null ? void 0 : node.parentId) ? nodes[node == null ? void 0 : node.parentId] : null;
|
|
@@ -4986,26 +4637,26 @@ var DraggableComponent = ({
|
|
|
4986
4637
|
}
|
|
4987
4638
|
});
|
|
4988
4639
|
}, [ctx, path]);
|
|
4989
|
-
const onDuplicate = (0,
|
|
4640
|
+
const onDuplicate = (0, import_react24.useCallback)(() => {
|
|
4990
4641
|
dispatch({
|
|
4991
4642
|
type: "duplicate",
|
|
4992
4643
|
sourceIndex: index,
|
|
4993
4644
|
sourceZone: zoneCompound
|
|
4994
4645
|
});
|
|
4995
4646
|
}, [index, zoneCompound]);
|
|
4996
|
-
const onDelete = (0,
|
|
4647
|
+
const onDelete = (0, import_react24.useCallback)(() => {
|
|
4997
4648
|
dispatch({
|
|
4998
4649
|
type: "remove",
|
|
4999
4650
|
index,
|
|
5000
4651
|
zone: zoneCompound
|
|
5001
4652
|
});
|
|
5002
4653
|
}, [index, zoneCompound]);
|
|
5003
|
-
const [hover, setHover] = (0,
|
|
4654
|
+
const [hover, setHover] = (0, import_react24.useState)(false);
|
|
5004
4655
|
const indicativeHover = useContextStore(
|
|
5005
4656
|
ZoneStoreContext,
|
|
5006
4657
|
(s) => s.hoveringComponent === id
|
|
5007
4658
|
);
|
|
5008
|
-
(0,
|
|
4659
|
+
(0, import_react24.useEffect)(() => {
|
|
5009
4660
|
if (!ref.current) {
|
|
5010
4661
|
return;
|
|
5011
4662
|
}
|
|
@@ -5041,7 +4692,8 @@ var DraggableComponent = ({
|
|
|
5041
4692
|
el.removeEventListener("mouseout", _onMouseOut);
|
|
5042
4693
|
};
|
|
5043
4694
|
}, [
|
|
5044
|
-
ref,
|
|
4695
|
+
ref.current,
|
|
4696
|
+
// Remount attributes if the element changes
|
|
5045
4697
|
onClick,
|
|
5046
4698
|
containsActiveZone,
|
|
5047
4699
|
zoneCompound,
|
|
@@ -5049,10 +4701,10 @@ var DraggableComponent = ({
|
|
|
5049
4701
|
thisIsDragging,
|
|
5050
4702
|
inDroppableZone
|
|
5051
4703
|
]);
|
|
5052
|
-
const [isVisible, setIsVisible] = (0,
|
|
5053
|
-
const [dragFinished, setDragFinished] = (0,
|
|
5054
|
-
const [_, startTransition] = (0,
|
|
5055
|
-
(0,
|
|
4704
|
+
const [isVisible, setIsVisible] = (0, import_react24.useState)(false);
|
|
4705
|
+
const [dragFinished, setDragFinished] = (0, import_react24.useState)(true);
|
|
4706
|
+
const [_, startTransition] = (0, import_react24.useTransition)();
|
|
4707
|
+
(0, import_react24.useEffect)(() => {
|
|
5056
4708
|
startTransition(() => {
|
|
5057
4709
|
if (hover || indicativeHover || isSelected) {
|
|
5058
4710
|
sync();
|
|
@@ -5063,7 +4715,7 @@ var DraggableComponent = ({
|
|
|
5063
4715
|
}
|
|
5064
4716
|
});
|
|
5065
4717
|
}, [hover, indicativeHover, isSelected, iframe]);
|
|
5066
|
-
const [thisWasDragging, setThisWasDragging] = (0,
|
|
4718
|
+
const [thisWasDragging, setThisWasDragging] = (0, import_react24.useState)(false);
|
|
5067
4719
|
const onDragFinished = useOnDragFinished((finished) => {
|
|
5068
4720
|
if (finished) {
|
|
5069
4721
|
startTransition(() => {
|
|
@@ -5074,15 +4726,15 @@ var DraggableComponent = ({
|
|
|
5074
4726
|
setDragFinished(false);
|
|
5075
4727
|
}
|
|
5076
4728
|
});
|
|
5077
|
-
(0,
|
|
4729
|
+
(0, import_react24.useEffect)(() => {
|
|
5078
4730
|
if (thisIsDragging) {
|
|
5079
4731
|
setThisWasDragging(true);
|
|
5080
4732
|
}
|
|
5081
4733
|
}, [thisIsDragging]);
|
|
5082
|
-
(0,
|
|
4734
|
+
(0, import_react24.useEffect)(() => {
|
|
5083
4735
|
if (thisWasDragging) return onDragFinished();
|
|
5084
4736
|
}, [thisWasDragging, onDragFinished]);
|
|
5085
|
-
const syncActionsPosition = (0,
|
|
4737
|
+
const syncActionsPosition = (0, import_react24.useCallback)(
|
|
5086
4738
|
(el) => {
|
|
5087
4739
|
if (el) {
|
|
5088
4740
|
const view = el.ownerDocument.defaultView;
|
|
@@ -5107,7 +4759,7 @@ var DraggableComponent = ({
|
|
|
5107
4759
|
},
|
|
5108
4760
|
[zoom]
|
|
5109
4761
|
);
|
|
5110
|
-
(0,
|
|
4762
|
+
(0, import_react24.useEffect)(() => {
|
|
5111
4763
|
if (userDragAxis) {
|
|
5112
4764
|
setDragAxis(userDragAxis);
|
|
5113
4765
|
return;
|
|
@@ -5121,11 +4773,11 @@ var DraggableComponent = ({
|
|
|
5121
4773
|
}
|
|
5122
4774
|
setDragAxis(autoDragAxis);
|
|
5123
4775
|
}, [ref, userDragAxis, autoDragAxis]);
|
|
5124
|
-
const parentAction = (0,
|
|
5125
|
-
() => (ctx == null ? void 0 : ctx.areaId) && (ctx == null ? void 0 : ctx.areaId) !== "root" && /* @__PURE__ */ (0,
|
|
4776
|
+
const parentAction = (0, import_react24.useMemo)(
|
|
4777
|
+
() => (ctx == null ? void 0 : ctx.areaId) && (ctx == null ? void 0 : ctx.areaId) !== "root" && /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(ActionBar.Action, { onClick: onSelectParent, label: "Select parent", children: /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(CornerLeftUp, { size: 16 }) }),
|
|
5126
4778
|
[ctx == null ? void 0 : ctx.areaId]
|
|
5127
4779
|
);
|
|
5128
|
-
const nextContextValue = (0,
|
|
4780
|
+
const nextContextValue = (0, import_react24.useMemo)(
|
|
5129
4781
|
() => __spreadProps(__spreadValues({}, ctx), {
|
|
5130
4782
|
areaId: id,
|
|
5131
4783
|
zoneCompound,
|
|
@@ -5144,9 +4796,9 @@ var DraggableComponent = ({
|
|
|
5144
4796
|
unregisterLocalZone
|
|
5145
4797
|
]
|
|
5146
4798
|
);
|
|
5147
|
-
return /* @__PURE__ */ (0,
|
|
4799
|
+
return /* @__PURE__ */ (0, import_jsx_runtime20.jsxs)(DropZoneProvider, { value: nextContextValue, children: [
|
|
5148
4800
|
dragFinished && isVisible && (0, import_react_dom2.createPortal)(
|
|
5149
|
-
/* @__PURE__ */ (0,
|
|
4801
|
+
/* @__PURE__ */ (0, import_jsx_runtime20.jsxs)(
|
|
5150
4802
|
"div",
|
|
5151
4803
|
{
|
|
5152
4804
|
className: getClassName16({
|
|
@@ -5158,15 +4810,15 @@ var DraggableComponent = ({
|
|
|
5158
4810
|
"data-puck-overlay": true,
|
|
5159
4811
|
children: [
|
|
5160
4812
|
debug,
|
|
5161
|
-
isLoading && /* @__PURE__ */ (0,
|
|
5162
|
-
/* @__PURE__ */ (0,
|
|
4813
|
+
isLoading && /* @__PURE__ */ (0, import_jsx_runtime20.jsx)("div", { className: getClassName16("loadingOverlay"), children: /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(Loader, {}) }),
|
|
4814
|
+
/* @__PURE__ */ (0, import_jsx_runtime20.jsx)(
|
|
5163
4815
|
"div",
|
|
5164
4816
|
{
|
|
5165
4817
|
className: getClassName16("actionsOverlay"),
|
|
5166
4818
|
style: {
|
|
5167
4819
|
top: actionsOverlayTop / zoom
|
|
5168
4820
|
},
|
|
5169
|
-
children: /* @__PURE__ */ (0,
|
|
4821
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(
|
|
5170
4822
|
"div",
|
|
5171
4823
|
{
|
|
5172
4824
|
className: getClassName16("actions"),
|
|
@@ -5178,14 +4830,14 @@ var DraggableComponent = ({
|
|
|
5178
4830
|
paddingRight: actionsSide
|
|
5179
4831
|
},
|
|
5180
4832
|
ref: syncActionsPosition,
|
|
5181
|
-
children: /* @__PURE__ */ (0,
|
|
4833
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime20.jsxs)(
|
|
5182
4834
|
CustomActionBar,
|
|
5183
4835
|
{
|
|
5184
4836
|
parentAction,
|
|
5185
4837
|
label: DEBUG2 ? id : label,
|
|
5186
4838
|
children: [
|
|
5187
|
-
permissions.duplicate && /* @__PURE__ */ (0,
|
|
5188
|
-
permissions.delete && /* @__PURE__ */ (0,
|
|
4839
|
+
permissions.duplicate && /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(ActionBar.Action, { onClick: onDuplicate, label: "Duplicate", children: /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(Copy, { size: 16 }) }),
|
|
4840
|
+
permissions.delete && /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(ActionBar.Action, { onClick: onDelete, label: "Delete", children: /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(Trash, { size: 16 }) })
|
|
5189
4841
|
]
|
|
5190
4842
|
}
|
|
5191
4843
|
)
|
|
@@ -5193,7 +4845,7 @@ var DraggableComponent = ({
|
|
|
5193
4845
|
)
|
|
5194
4846
|
}
|
|
5195
4847
|
),
|
|
5196
|
-
/* @__PURE__ */ (0,
|
|
4848
|
+
/* @__PURE__ */ (0, import_jsx_runtime20.jsx)("div", { className: getClassName16("overlay") })
|
|
5197
4849
|
]
|
|
5198
4850
|
}
|
|
5199
4851
|
),
|
|
@@ -5208,11 +4860,11 @@ init_react_import();
|
|
|
5208
4860
|
var styles_module_default12 = { "DropZone": "_DropZone_1i2sv_1", "DropZone--hasChildren": "_DropZone--hasChildren_1i2sv_11", "DropZone--isAreaSelected": "_DropZone--isAreaSelected_1i2sv_24", "DropZone--hoveringOverArea": "_DropZone--hoveringOverArea_1i2sv_25", "DropZone--isRootZone": "_DropZone--isRootZone_1i2sv_25", "DropZone--isDestination": "_DropZone--isDestination_1i2sv_35", "DropZone-item": "_DropZone-item_1i2sv_47", "DropZone-hitbox": "_DropZone-hitbox_1i2sv_51", "DropZone--isEnabled": "_DropZone--isEnabled_1i2sv_59", "DropZone--isAnimating": "_DropZone--isAnimating_1i2sv_68" };
|
|
5209
4861
|
|
|
5210
4862
|
// components/DropZone/index.tsx
|
|
5211
|
-
var
|
|
4863
|
+
var import_react34 = require("@dnd-kit/react");
|
|
5212
4864
|
|
|
5213
4865
|
// components/DropZone/lib/use-min-empty-height.ts
|
|
5214
4866
|
init_react_import();
|
|
5215
|
-
var
|
|
4867
|
+
var import_react25 = require("react");
|
|
5216
4868
|
var getNumItems = (appStore, zoneCompound) => appStore.getState().state.indexes.zones[zoneCompound].contentIds.length;
|
|
5217
4869
|
var useMinEmptyHeight = ({
|
|
5218
4870
|
zoneCompound,
|
|
@@ -5220,8 +4872,8 @@ var useMinEmptyHeight = ({
|
|
|
5220
4872
|
ref
|
|
5221
4873
|
}) => {
|
|
5222
4874
|
const appStore = useAppStoreApi();
|
|
5223
|
-
const [prevHeight, setPrevHeight] = (0,
|
|
5224
|
-
const [isAnimating, setIsAnimating] = (0,
|
|
4875
|
+
const [prevHeight, setPrevHeight] = (0, import_react25.useState)(0);
|
|
4876
|
+
const [isAnimating, setIsAnimating] = (0, import_react25.useState)(false);
|
|
5225
4877
|
const { draggedItem, isZone } = useContextStore(ZoneStoreContext, (s) => {
|
|
5226
4878
|
var _a, _b;
|
|
5227
4879
|
return {
|
|
@@ -5229,7 +4881,7 @@ var useMinEmptyHeight = ({
|
|
|
5229
4881
|
isZone: ((_b = s.draggedItem) == null ? void 0 : _b.data.zone) === zoneCompound
|
|
5230
4882
|
};
|
|
5231
4883
|
});
|
|
5232
|
-
const numItems = (0,
|
|
4884
|
+
const numItems = (0, import_react25.useRef)(0);
|
|
5233
4885
|
const onDragFinished = useOnDragFinished(
|
|
5234
4886
|
(finished) => {
|
|
5235
4887
|
var _a;
|
|
@@ -5264,7 +4916,7 @@ var useMinEmptyHeight = ({
|
|
|
5264
4916
|
},
|
|
5265
4917
|
[appStore, prevHeight, zoneCompound]
|
|
5266
4918
|
);
|
|
5267
|
-
(0,
|
|
4919
|
+
(0, import_react25.useEffect)(() => {
|
|
5268
4920
|
if (draggedItem && ref.current) {
|
|
5269
4921
|
if (isZone) {
|
|
5270
4922
|
const rect = ref.current.getBoundingClientRect();
|
|
@@ -5295,15 +4947,15 @@ function assignRefs(refs, node) {
|
|
|
5295
4947
|
|
|
5296
4948
|
// components/DropZone/lib/use-content-with-preview.ts
|
|
5297
4949
|
init_react_import();
|
|
5298
|
-
var
|
|
4950
|
+
var import_react28 = require("react");
|
|
5299
4951
|
|
|
5300
4952
|
// lib/dnd/use-rendered-callback.ts
|
|
5301
4953
|
init_react_import();
|
|
5302
|
-
var
|
|
5303
|
-
var
|
|
4954
|
+
var import_react26 = require("@dnd-kit/react");
|
|
4955
|
+
var import_react27 = require("react");
|
|
5304
4956
|
function useRenderedCallback(callback, deps) {
|
|
5305
|
-
const manager = (0,
|
|
5306
|
-
return (0,
|
|
4957
|
+
const manager = (0, import_react26.useDragDropManager)();
|
|
4958
|
+
return (0, import_react27.useCallback)(
|
|
5307
4959
|
(...args) => __async(this, null, function* () {
|
|
5308
4960
|
yield manager == null ? void 0 : manager.renderer.rendering;
|
|
5309
4961
|
return callback(...args);
|
|
@@ -5314,14 +4966,14 @@ function useRenderedCallback(callback, deps) {
|
|
|
5314
4966
|
|
|
5315
4967
|
// components/DropZone/lib/use-content-with-preview.ts
|
|
5316
4968
|
var useContentIdsWithPreview = (contentIds, zoneCompound) => {
|
|
5317
|
-
const zoneStore = (0,
|
|
4969
|
+
const zoneStore = (0, import_react28.useContext)(ZoneStoreContext);
|
|
5318
4970
|
const preview = useContextStore(
|
|
5319
4971
|
ZoneStoreContext,
|
|
5320
4972
|
(s) => s.previewIndex[zoneCompound]
|
|
5321
4973
|
);
|
|
5322
4974
|
const isDragging = useAppStore((s) => s.state.ui.isDragging);
|
|
5323
|
-
const [contentIdsWithPreview, setContentIdsWithPreview] = (0,
|
|
5324
|
-
const [localPreview, setLocalPreview] = (0,
|
|
4975
|
+
const [contentIdsWithPreview, setContentIdsWithPreview] = (0, import_react28.useState)(contentIds);
|
|
4976
|
+
const [localPreview, setLocalPreview] = (0, import_react28.useState)(
|
|
5325
4977
|
preview
|
|
5326
4978
|
);
|
|
5327
4979
|
const updateContent = useRenderedCallback(
|
|
@@ -5356,7 +5008,7 @@ var useContentIdsWithPreview = (contentIds, zoneCompound) => {
|
|
|
5356
5008
|
},
|
|
5357
5009
|
[]
|
|
5358
5010
|
);
|
|
5359
|
-
(0,
|
|
5011
|
+
(0, import_react28.useEffect)(() => {
|
|
5360
5012
|
var _a;
|
|
5361
5013
|
const s = zoneStore.getState();
|
|
5362
5014
|
const draggedItemId = (_a = s.draggedItem) == null ? void 0 : _a.id;
|
|
@@ -5374,16 +5026,16 @@ var useContentIdsWithPreview = (contentIds, zoneCompound) => {
|
|
|
5374
5026
|
|
|
5375
5027
|
// components/DropZone/lib/use-drag-axis.ts
|
|
5376
5028
|
init_react_import();
|
|
5377
|
-
var
|
|
5029
|
+
var import_react29 = require("react");
|
|
5378
5030
|
var GRID_DRAG_AXIS = "dynamic";
|
|
5379
5031
|
var FLEX_ROW_DRAG_AXIS = "x";
|
|
5380
5032
|
var DEFAULT_DRAG_AXIS = "y";
|
|
5381
5033
|
var useDragAxis = (ref, collisionAxis) => {
|
|
5382
5034
|
const status = useAppStore((s) => s.status);
|
|
5383
|
-
const [dragAxis, setDragAxis] = (0,
|
|
5035
|
+
const [dragAxis, setDragAxis] = (0, import_react29.useState)(
|
|
5384
5036
|
collisionAxis || DEFAULT_DRAG_AXIS
|
|
5385
5037
|
);
|
|
5386
|
-
const calculateDragAxis = (0,
|
|
5038
|
+
const calculateDragAxis = (0, import_react29.useCallback)(() => {
|
|
5387
5039
|
if (ref.current) {
|
|
5388
5040
|
const computedStyle = window.getComputedStyle(ref.current);
|
|
5389
5041
|
if (computedStyle.display === "grid") {
|
|
@@ -5395,7 +5047,7 @@ var useDragAxis = (ref, collisionAxis) => {
|
|
|
5395
5047
|
}
|
|
5396
5048
|
}
|
|
5397
5049
|
}, [ref.current]);
|
|
5398
|
-
(0,
|
|
5050
|
+
(0, import_react29.useEffect)(() => {
|
|
5399
5051
|
const onViewportChange = () => {
|
|
5400
5052
|
calculateDragAxis();
|
|
5401
5053
|
};
|
|
@@ -5404,7 +5056,7 @@ var useDragAxis = (ref, collisionAxis) => {
|
|
|
5404
5056
|
window.removeEventListener("viewportchange", onViewportChange);
|
|
5405
5057
|
};
|
|
5406
5058
|
}, []);
|
|
5407
|
-
(0,
|
|
5059
|
+
(0, import_react29.useEffect)(calculateDragAxis, [status, collisionAxis]);
|
|
5408
5060
|
return [dragAxis, calculateDragAxis];
|
|
5409
5061
|
};
|
|
5410
5062
|
|
|
@@ -5413,11 +5065,136 @@ var import_shallow4 = require("zustand/react/shallow");
|
|
|
5413
5065
|
|
|
5414
5066
|
// components/Render/index.tsx
|
|
5415
5067
|
init_react_import();
|
|
5416
|
-
|
|
5068
|
+
|
|
5069
|
+
// lib/use-slots.tsx
|
|
5070
|
+
init_react_import();
|
|
5071
|
+
var import_react30 = require("react");
|
|
5072
|
+
function useSlots(config, item, renderSlotEdit, renderSlotRender = renderSlotEdit, readOnly, forceReadOnly) {
|
|
5073
|
+
const slotProps = (0, import_react30.useMemo)(() => {
|
|
5074
|
+
const mapped = mapSlots(
|
|
5075
|
+
item,
|
|
5076
|
+
(content, _parentId, propName, field, propPath) => {
|
|
5077
|
+
const wildcardPath = propPath.replace(/\[\d+\]/g, "[*]");
|
|
5078
|
+
const isReadOnly = (readOnly == null ? void 0 : readOnly[propPath]) || (readOnly == null ? void 0 : readOnly[wildcardPath]) || forceReadOnly;
|
|
5079
|
+
const render = isReadOnly ? renderSlotRender : renderSlotEdit;
|
|
5080
|
+
const Slot = (dzProps) => render(__spreadProps(__spreadValues({
|
|
5081
|
+
allow: (field == null ? void 0 : field.type) === "slot" ? field.allow : [],
|
|
5082
|
+
disallow: (field == null ? void 0 : field.type) === "slot" ? field.disallow : []
|
|
5083
|
+
}, dzProps), {
|
|
5084
|
+
zone: propName,
|
|
5085
|
+
content
|
|
5086
|
+
}));
|
|
5087
|
+
return Slot;
|
|
5088
|
+
},
|
|
5089
|
+
config
|
|
5090
|
+
).props;
|
|
5091
|
+
return mapped;
|
|
5092
|
+
}, [config, item, readOnly, forceReadOnly]);
|
|
5093
|
+
const mergedProps = (0, import_react30.useMemo)(
|
|
5094
|
+
() => __spreadValues(__spreadValues({}, item.props), slotProps),
|
|
5095
|
+
[item.props, slotProps]
|
|
5096
|
+
);
|
|
5097
|
+
return mergedProps;
|
|
5098
|
+
}
|
|
5099
|
+
|
|
5100
|
+
// components/Render/index.tsx
|
|
5101
|
+
var import_react32 = __toESM(require("react"));
|
|
5102
|
+
|
|
5103
|
+
// components/SlotRender/index.tsx
|
|
5104
|
+
init_react_import();
|
|
5105
|
+
var import_shallow3 = require("zustand/react/shallow");
|
|
5106
|
+
|
|
5107
|
+
// components/SlotRender/server.tsx
|
|
5108
|
+
init_react_import();
|
|
5109
|
+
var import_react31 = require("react");
|
|
5110
|
+
|
|
5111
|
+
// components/ServerRender/index.tsx
|
|
5112
|
+
init_react_import();
|
|
5113
|
+
var import_jsx_runtime21 = require("react/jsx-runtime");
|
|
5114
|
+
function DropZoneRender({
|
|
5115
|
+
zone,
|
|
5116
|
+
data,
|
|
5117
|
+
areaId = "root",
|
|
5118
|
+
config,
|
|
5119
|
+
metadata = {}
|
|
5120
|
+
}) {
|
|
5121
|
+
let zoneCompound = rootDroppableId;
|
|
5122
|
+
let content = (data == null ? void 0 : data.content) || [];
|
|
5123
|
+
if (!data || !config) {
|
|
5124
|
+
return null;
|
|
5125
|
+
}
|
|
5126
|
+
if (areaId !== rootAreaId && zone !== rootZone) {
|
|
5127
|
+
zoneCompound = `${areaId}:${zone}`;
|
|
5128
|
+
content = setupZone(data, zoneCompound).zones[zoneCompound];
|
|
5129
|
+
}
|
|
5130
|
+
return /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(import_jsx_runtime21.Fragment, { children: content.map((item) => {
|
|
5131
|
+
const Component = config.components[item.type];
|
|
5132
|
+
const props = __spreadProps(__spreadValues({}, item.props), {
|
|
5133
|
+
puck: {
|
|
5134
|
+
renderDropZone: ({ zone: zone2 }) => /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(
|
|
5135
|
+
DropZoneRender,
|
|
5136
|
+
{
|
|
5137
|
+
zone: zone2,
|
|
5138
|
+
data,
|
|
5139
|
+
areaId: item.props.id,
|
|
5140
|
+
config,
|
|
5141
|
+
metadata
|
|
5142
|
+
}
|
|
5143
|
+
),
|
|
5144
|
+
metadata,
|
|
5145
|
+
dragRef: null,
|
|
5146
|
+
isEditing: false
|
|
5147
|
+
}
|
|
5148
|
+
});
|
|
5149
|
+
const renderItem = __spreadProps(__spreadValues({}, item), { props });
|
|
5150
|
+
const propsWithSlots = useSlots(config, renderItem, (props2) => /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(SlotRenderPure, __spreadProps(__spreadValues({}, props2), { config, metadata })));
|
|
5151
|
+
if (Component) {
|
|
5152
|
+
return /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(Component.render, __spreadValues({}, propsWithSlots), renderItem.props.id);
|
|
5153
|
+
}
|
|
5154
|
+
return null;
|
|
5155
|
+
}) });
|
|
5156
|
+
}
|
|
5157
|
+
|
|
5158
|
+
// components/SlotRender/server.tsx
|
|
5159
|
+
var import_jsx_runtime22 = require("react/jsx-runtime");
|
|
5160
|
+
var SlotRenderPure = (props) => /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(SlotRender, __spreadValues({}, props));
|
|
5161
|
+
var Item = ({
|
|
5162
|
+
config,
|
|
5163
|
+
item,
|
|
5164
|
+
metadata
|
|
5165
|
+
}) => {
|
|
5166
|
+
const Component = config.components[item.type];
|
|
5167
|
+
const props = useSlots(config, item, (slotProps) => /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(SlotRenderPure, __spreadProps(__spreadValues({}, slotProps), { config, metadata })));
|
|
5168
|
+
return /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(
|
|
5169
|
+
Component.render,
|
|
5170
|
+
__spreadProps(__spreadValues({}, props), {
|
|
5171
|
+
puck: __spreadProps(__spreadValues({}, props.puck), {
|
|
5172
|
+
renderDropZone: DropZoneRender,
|
|
5173
|
+
metadata: metadata || {}
|
|
5174
|
+
})
|
|
5175
|
+
})
|
|
5176
|
+
);
|
|
5177
|
+
};
|
|
5178
|
+
var SlotRender = (0, import_react31.forwardRef)(
|
|
5179
|
+
function SlotRenderInternal({ className, style, content, config, metadata }, ref) {
|
|
5180
|
+
return /* @__PURE__ */ (0, import_jsx_runtime22.jsx)("div", { className, style, ref, children: content.map((item) => {
|
|
5181
|
+
if (!config.components[item.type]) {
|
|
5182
|
+
return null;
|
|
5183
|
+
}
|
|
5184
|
+
return /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(
|
|
5185
|
+
Item,
|
|
5186
|
+
{
|
|
5187
|
+
config,
|
|
5188
|
+
item,
|
|
5189
|
+
metadata
|
|
5190
|
+
},
|
|
5191
|
+
item.props.id
|
|
5192
|
+
);
|
|
5193
|
+
}) });
|
|
5194
|
+
}
|
|
5195
|
+
);
|
|
5417
5196
|
|
|
5418
5197
|
// components/SlotRender/index.tsx
|
|
5419
|
-
init_react_import();
|
|
5420
|
-
var import_shallow3 = require("zustand/react/shallow");
|
|
5421
5198
|
var import_jsx_runtime23 = require("react/jsx-runtime");
|
|
5422
5199
|
var ContextSlotRender = ({
|
|
5423
5200
|
componentId,
|
|
@@ -5446,12 +5223,12 @@ var ContextSlotRender = ({
|
|
|
5446
5223
|
|
|
5447
5224
|
// components/Render/index.tsx
|
|
5448
5225
|
var import_jsx_runtime24 = require("react/jsx-runtime");
|
|
5449
|
-
var renderContext =
|
|
5226
|
+
var renderContext = import_react32.default.createContext({
|
|
5450
5227
|
config: { components: {} },
|
|
5451
5228
|
data: { root: {}, content: [] },
|
|
5452
5229
|
metadata: {}
|
|
5453
5230
|
});
|
|
5454
|
-
function
|
|
5231
|
+
function Render({
|
|
5455
5232
|
config,
|
|
5456
5233
|
data,
|
|
5457
5234
|
metadata = {}
|
|
@@ -5479,7 +5256,7 @@ function Render2({
|
|
|
5479
5256
|
{ type: "root", props: pageProps },
|
|
5480
5257
|
(props) => /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(SlotRender, __spreadProps(__spreadValues({}, props), { config, metadata }))
|
|
5481
5258
|
);
|
|
5482
|
-
const nextContextValue = (0,
|
|
5259
|
+
const nextContextValue = (0, import_react32.useMemo)(
|
|
5483
5260
|
() => ({
|
|
5484
5261
|
mode: "render",
|
|
5485
5262
|
depth: 0
|
|
@@ -5508,9 +5285,9 @@ var DropZoneChild = ({
|
|
|
5508
5285
|
}) => {
|
|
5509
5286
|
var _a, _b;
|
|
5510
5287
|
const metadata = useAppStore((s) => s.metadata);
|
|
5511
|
-
const ctx = (0,
|
|
5288
|
+
const ctx = (0, import_react33.useContext)(dropZoneContext);
|
|
5512
5289
|
const { depth = 1 } = ctx != null ? ctx : {};
|
|
5513
|
-
const zoneStore = (0,
|
|
5290
|
+
const zoneStore = (0, import_react33.useContext)(ZoneStoreContext);
|
|
5514
5291
|
const nodeProps = useAppStore(
|
|
5515
5292
|
(0, import_shallow4.useShallow)((s) => {
|
|
5516
5293
|
var _a2;
|
|
@@ -5530,7 +5307,7 @@ var DropZoneChild = ({
|
|
|
5530
5307
|
})
|
|
5531
5308
|
);
|
|
5532
5309
|
const appStore = useAppStoreApi();
|
|
5533
|
-
const item = (0,
|
|
5310
|
+
const item = (0, import_react33.useMemo)(() => {
|
|
5534
5311
|
if (nodeProps) {
|
|
5535
5312
|
const expanded = expandNode({
|
|
5536
5313
|
type: nodeType,
|
|
@@ -5543,7 +5320,8 @@ var DropZoneChild = ({
|
|
|
5543
5320
|
return {
|
|
5544
5321
|
type: preview.componentType,
|
|
5545
5322
|
props: preview.props,
|
|
5546
|
-
previewType: preview.type
|
|
5323
|
+
previewType: preview.type,
|
|
5324
|
+
element: preview.element
|
|
5547
5325
|
};
|
|
5548
5326
|
}
|
|
5549
5327
|
return null;
|
|
@@ -5551,7 +5329,7 @@ var DropZoneChild = ({
|
|
|
5551
5329
|
const componentConfig = useAppStore(
|
|
5552
5330
|
(s) => (item == null ? void 0 : item.type) ? s.config.components[item.type] : null
|
|
5553
5331
|
);
|
|
5554
|
-
const puckProps = (0,
|
|
5332
|
+
const puckProps = (0, import_react33.useMemo)(
|
|
5555
5333
|
() => ({
|
|
5556
5334
|
renderDropZone: DropZoneEditPure,
|
|
5557
5335
|
isEditing: true,
|
|
@@ -5574,13 +5352,19 @@ var DropZoneChild = ({
|
|
|
5574
5352
|
}
|
|
5575
5353
|
);
|
|
5576
5354
|
let label = (_b = (_a = componentConfig == null ? void 0 : componentConfig.label) != null ? _a : item == null ? void 0 : item.type.toString()) != null ? _b : "Component";
|
|
5577
|
-
const renderPreview = (0,
|
|
5355
|
+
const renderPreview = (0, import_react33.useMemo)(
|
|
5578
5356
|
() => function Preview3() {
|
|
5357
|
+
if (item && "element" in item && item.element) {
|
|
5358
|
+
return (
|
|
5359
|
+
// Safe to use this since the HTML is set by the user
|
|
5360
|
+
/* @__PURE__ */ (0, import_jsx_runtime25.jsx)("div", { dangerouslySetInnerHTML: { __html: item.element.outerHTML } })
|
|
5361
|
+
);
|
|
5362
|
+
}
|
|
5579
5363
|
return /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(DrawerItemInner, { name: label, children: overrides.componentItem });
|
|
5580
5364
|
},
|
|
5581
5365
|
[componentId, label, overrides]
|
|
5582
5366
|
);
|
|
5583
|
-
const defaultsProps = (0,
|
|
5367
|
+
const defaultsProps = (0, import_react33.useMemo)(
|
|
5584
5368
|
() => __spreadProps(__spreadValues(__spreadValues({}, componentConfig == null ? void 0 : componentConfig.defaultProps), item == null ? void 0 : item.props), {
|
|
5585
5369
|
puck: puckProps,
|
|
5586
5370
|
editMode: true
|
|
@@ -5588,7 +5372,7 @@ var DropZoneChild = ({
|
|
|
5588
5372
|
}),
|
|
5589
5373
|
[componentConfig == null ? void 0 : componentConfig.defaultProps, item == null ? void 0 : item.props, puckProps]
|
|
5590
5374
|
);
|
|
5591
|
-
const defaultedNode = (0,
|
|
5375
|
+
const defaultedNode = (0, import_react33.useMemo)(
|
|
5592
5376
|
() => {
|
|
5593
5377
|
var _a2;
|
|
5594
5378
|
return { type: (_a2 = item == null ? void 0 : item.type) != null ? _a2 : nodeType, props: defaultsProps };
|
|
@@ -5605,14 +5389,14 @@ var DropZoneChild = ({
|
|
|
5605
5389
|
isLoading
|
|
5606
5390
|
);
|
|
5607
5391
|
if (!item) return;
|
|
5608
|
-
let
|
|
5392
|
+
let Render2 = componentConfig ? componentConfig.render : () => /* @__PURE__ */ (0, import_jsx_runtime25.jsxs)("div", { style: { padding: 48, textAlign: "center" }, children: [
|
|
5609
5393
|
"No configuration for ",
|
|
5610
5394
|
item.type
|
|
5611
5395
|
] });
|
|
5612
5396
|
let componentType = item.type;
|
|
5613
5397
|
const isInserting = "previewType" in item ? item.previewType === "insert" : false;
|
|
5614
5398
|
if (isInserting) {
|
|
5615
|
-
|
|
5399
|
+
Render2 = renderPreview;
|
|
5616
5400
|
}
|
|
5617
5401
|
return /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(
|
|
5618
5402
|
DraggableComponent,
|
|
@@ -5629,18 +5413,18 @@ var DropZoneChild = ({
|
|
|
5629
5413
|
userDragAxis: collisionAxis,
|
|
5630
5414
|
inDroppableZone,
|
|
5631
5415
|
children: (dragRef) => (componentConfig == null ? void 0 : componentConfig.inline) && !isInserting ? /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(import_jsx_runtime25.Fragment, { children: /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(
|
|
5632
|
-
|
|
5416
|
+
Render2,
|
|
5633
5417
|
__spreadProps(__spreadValues({}, defaultedPropsWithSlots), {
|
|
5634
5418
|
puck: __spreadProps(__spreadValues({}, defaultedPropsWithSlots.puck), {
|
|
5635
5419
|
dragRef
|
|
5636
5420
|
})
|
|
5637
5421
|
})
|
|
5638
|
-
) }) : /* @__PURE__ */ (0, import_jsx_runtime25.jsx)("div", { ref: dragRef, children: /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(
|
|
5422
|
+
) }) : /* @__PURE__ */ (0, import_jsx_runtime25.jsx)("div", { ref: dragRef, children: /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(Render2, __spreadValues({}, defaultedPropsWithSlots)) })
|
|
5639
5423
|
}
|
|
5640
5424
|
);
|
|
5641
5425
|
};
|
|
5642
|
-
var DropZoneChildMemo = (0,
|
|
5643
|
-
var DropZoneEdit = (0,
|
|
5426
|
+
var DropZoneChildMemo = (0, import_react33.memo)(DropZoneChild);
|
|
5427
|
+
var DropZoneEdit = (0, import_react33.forwardRef)(
|
|
5644
5428
|
function DropZoneEditInternal({
|
|
5645
5429
|
zone,
|
|
5646
5430
|
allow,
|
|
@@ -5650,7 +5434,8 @@ var DropZoneEdit = (0, import_react35.forwardRef)(
|
|
|
5650
5434
|
minEmptyHeight: userMinEmptyHeight = 128,
|
|
5651
5435
|
collisionAxis
|
|
5652
5436
|
}, userRef) {
|
|
5653
|
-
const ctx = (0,
|
|
5437
|
+
const ctx = (0, import_react33.useContext)(dropZoneContext);
|
|
5438
|
+
const appStoreApi = useAppStoreApi();
|
|
5654
5439
|
const {
|
|
5655
5440
|
// These all need setting via context
|
|
5656
5441
|
areaId,
|
|
@@ -5687,19 +5472,14 @@ var DropZoneEdit = (0, import_react35.forwardRef)(
|
|
|
5687
5472
|
return (_a = s.state.indexes.zones[zoneCompound]) == null ? void 0 : _a.type;
|
|
5688
5473
|
})
|
|
5689
5474
|
);
|
|
5690
|
-
(0,
|
|
5475
|
+
(0, import_react33.useEffect)(() => {
|
|
5691
5476
|
if (!zoneType || zoneType === "dropzone") {
|
|
5692
5477
|
if (ctx == null ? void 0 : ctx.registerZone) {
|
|
5693
5478
|
ctx == null ? void 0 : ctx.registerZone(zoneCompound);
|
|
5694
5479
|
}
|
|
5695
|
-
return () => {
|
|
5696
|
-
if (ctx == null ? void 0 : ctx.unregisterZone) {
|
|
5697
|
-
ctx == null ? void 0 : ctx.unregisterZone(zoneCompound);
|
|
5698
|
-
}
|
|
5699
|
-
};
|
|
5700
5480
|
}
|
|
5701
|
-
}, [zoneType]);
|
|
5702
|
-
(0,
|
|
5481
|
+
}, [zoneType, appStoreApi]);
|
|
5482
|
+
(0, import_react33.useEffect)(() => {
|
|
5703
5483
|
if (zoneType === "dropzone") {
|
|
5704
5484
|
if (zoneCompound !== rootDroppableId) {
|
|
5705
5485
|
console.warn(
|
|
@@ -5708,11 +5488,11 @@ var DropZoneEdit = (0, import_react35.forwardRef)(
|
|
|
5708
5488
|
}
|
|
5709
5489
|
}
|
|
5710
5490
|
}, [zoneType]);
|
|
5711
|
-
const contentIds = (0,
|
|
5491
|
+
const contentIds = (0, import_react33.useMemo)(() => {
|
|
5712
5492
|
return zoneContentIds || [];
|
|
5713
5493
|
}, [zoneContentIds]);
|
|
5714
|
-
const ref = (0,
|
|
5715
|
-
const acceptsTarget = (0,
|
|
5494
|
+
const ref = (0, import_react33.useRef)(null);
|
|
5495
|
+
const acceptsTarget = (0, import_react33.useCallback)(
|
|
5716
5496
|
(componentType) => {
|
|
5717
5497
|
if (!componentType) {
|
|
5718
5498
|
return true;
|
|
@@ -5750,7 +5530,7 @@ var DropZoneEdit = (0, import_react35.forwardRef)(
|
|
|
5750
5530
|
}
|
|
5751
5531
|
return _isEnabled;
|
|
5752
5532
|
});
|
|
5753
|
-
(0,
|
|
5533
|
+
(0, import_react33.useEffect)(() => {
|
|
5754
5534
|
if (registerLocalZone) {
|
|
5755
5535
|
registerLocalZone(zoneCompound, targetAccepted || isEnabled);
|
|
5756
5536
|
}
|
|
@@ -5765,8 +5545,8 @@ var DropZoneEdit = (0, import_react35.forwardRef)(
|
|
|
5765
5545
|
zoneCompound
|
|
5766
5546
|
);
|
|
5767
5547
|
const isDropEnabled = isEnabled && (preview ? contentIdsWithPreview.length === 1 : contentIdsWithPreview.length === 0);
|
|
5768
|
-
const zoneStore = (0,
|
|
5769
|
-
(0,
|
|
5548
|
+
const zoneStore = (0, import_react33.useContext)(ZoneStoreContext);
|
|
5549
|
+
(0, import_react33.useEffect)(() => {
|
|
5770
5550
|
const { enabledIndex } = zoneStore.getState();
|
|
5771
5551
|
zoneStore.setState({
|
|
5772
5552
|
enabledIndex: __spreadProps(__spreadValues({}, enabledIndex), { [zoneCompound]: isEnabled })
|
|
@@ -5785,7 +5565,7 @@ var DropZoneEdit = (0, import_react35.forwardRef)(
|
|
|
5785
5565
|
path: path || []
|
|
5786
5566
|
}
|
|
5787
5567
|
};
|
|
5788
|
-
const { ref: dropRef } = (0,
|
|
5568
|
+
const { ref: dropRef } = (0, import_react34.useDroppable)(droppableConfig);
|
|
5789
5569
|
const isAreaSelected = useAppStore(
|
|
5790
5570
|
(s) => (s == null ? void 0 : s.selectedItem) && areaId === (s == null ? void 0 : s.selectedItem.props.id)
|
|
5791
5571
|
);
|
|
@@ -5840,7 +5620,7 @@ var DropZoneRenderItem = ({
|
|
|
5840
5620
|
}) => {
|
|
5841
5621
|
const Component = config.components[item.type];
|
|
5842
5622
|
const props = useSlots(config, item, (slotProps) => /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(SlotRenderPure, __spreadProps(__spreadValues({}, slotProps), { config, metadata })));
|
|
5843
|
-
const nextContextValue = (0,
|
|
5623
|
+
const nextContextValue = (0, import_react33.useMemo)(
|
|
5844
5624
|
() => ({
|
|
5845
5625
|
areaId: props.id,
|
|
5846
5626
|
depth: 1
|
|
@@ -5858,23 +5638,18 @@ var DropZoneRenderItem = ({
|
|
|
5858
5638
|
) }, props.id);
|
|
5859
5639
|
};
|
|
5860
5640
|
var DropZoneRenderPure = (props) => /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(DropZoneRender2, __spreadValues({}, props));
|
|
5861
|
-
var DropZoneRender2 = (0,
|
|
5641
|
+
var DropZoneRender2 = (0, import_react33.forwardRef)(
|
|
5862
5642
|
function DropZoneRenderInternal({ className, style, zone }, ref) {
|
|
5863
|
-
const ctx = (0,
|
|
5643
|
+
const ctx = (0, import_react33.useContext)(dropZoneContext);
|
|
5864
5644
|
const { areaId = "root" } = ctx || {};
|
|
5865
|
-
const { config, data, metadata } = (0,
|
|
5645
|
+
const { config, data, metadata } = (0, import_react33.useContext)(renderContext);
|
|
5866
5646
|
let zoneCompound = `${areaId}:${zone}`;
|
|
5867
5647
|
let content = (data == null ? void 0 : data.content) || [];
|
|
5868
|
-
(0,
|
|
5648
|
+
(0, import_react33.useEffect)(() => {
|
|
5869
5649
|
if (!content) {
|
|
5870
5650
|
if (ctx == null ? void 0 : ctx.registerZone) {
|
|
5871
5651
|
ctx == null ? void 0 : ctx.registerZone(zoneCompound);
|
|
5872
5652
|
}
|
|
5873
|
-
return () => {
|
|
5874
|
-
if (ctx == null ? void 0 : ctx.unregisterZone) {
|
|
5875
|
-
ctx == null ? void 0 : ctx.unregisterZone(zoneCompound);
|
|
5876
|
-
}
|
|
5877
|
-
};
|
|
5878
5653
|
}
|
|
5879
5654
|
}, [content]);
|
|
5880
5655
|
if (!data || !config) {
|
|
@@ -5901,9 +5676,9 @@ var DropZoneRender2 = (0, import_react35.forwardRef)(
|
|
|
5901
5676
|
}
|
|
5902
5677
|
);
|
|
5903
5678
|
var DropZonePure = (props) => /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(DropZone, __spreadValues({}, props));
|
|
5904
|
-
var DropZone = (0,
|
|
5679
|
+
var DropZone = (0, import_react33.forwardRef)(
|
|
5905
5680
|
function DropZone2(props, ref) {
|
|
5906
|
-
const ctx = (0,
|
|
5681
|
+
const ctx = (0, import_react33.useContext)(dropZoneContext);
|
|
5907
5682
|
if ((ctx == null ? void 0 : ctx.mode) === "edit") {
|
|
5908
5683
|
return /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(import_jsx_runtime25.Fragment, { children: /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(DropZoneEdit, __spreadProps(__spreadValues({}, props), { ref })) });
|
|
5909
5684
|
}
|
|
@@ -6135,6 +5910,7 @@ var findDeepestCandidate = (position, manager) => {
|
|
|
6135
5910
|
});
|
|
6136
5911
|
filteredCandidates.reverse();
|
|
6137
5912
|
const primaryCandidate = filteredCandidates[0];
|
|
5913
|
+
if (!primaryCandidate) return { zone: null, area: null };
|
|
6138
5914
|
const primaryCandidateData = primaryCandidate.data;
|
|
6139
5915
|
const primaryCandidateIsComponent = "containsActiveZone" in primaryCandidateData;
|
|
6140
5916
|
const zone = getZoneId2(primaryCandidate);
|
|
@@ -6244,12 +6020,12 @@ function getDeepDir(el) {
|
|
|
6244
6020
|
var import_state = require("@dnd-kit/state");
|
|
6245
6021
|
var import_jsx_runtime26 = require("react/jsx-runtime");
|
|
6246
6022
|
var DEBUG3 = false;
|
|
6247
|
-
var dragListenerContext = (0,
|
|
6023
|
+
var dragListenerContext = (0, import_react36.createContext)({
|
|
6248
6024
|
dragListeners: {}
|
|
6249
6025
|
});
|
|
6250
6026
|
function useDragListener(type, fn, deps = []) {
|
|
6251
|
-
const { setDragListeners } = (0,
|
|
6252
|
-
(0,
|
|
6027
|
+
const { setDragListeners } = (0, import_react36.useContext)(dragListenerContext);
|
|
6028
|
+
(0, import_react36.useEffect)(() => {
|
|
6253
6029
|
if (setDragListeners) {
|
|
6254
6030
|
setDragListeners((old) => __spreadProps(__spreadValues({}, old), {
|
|
6255
6031
|
[type]: [...old[type] || [], fn]
|
|
@@ -6259,8 +6035,8 @@ function useDragListener(type, fn, deps = []) {
|
|
|
6259
6035
|
}
|
|
6260
6036
|
var AREA_CHANGE_DEBOUNCE_MS = 100;
|
|
6261
6037
|
var useTempDisableFallback = (timeout3) => {
|
|
6262
|
-
const lastFallbackDisable = (0,
|
|
6263
|
-
return (0,
|
|
6038
|
+
const lastFallbackDisable = (0, import_react36.useRef)(null);
|
|
6039
|
+
return (0, import_react36.useCallback)((manager) => {
|
|
6264
6040
|
collisionStore.setState({ fallbackEnabled: false });
|
|
6265
6041
|
const fallbackId = generateId();
|
|
6266
6042
|
lastFallbackDisable.current = fallbackId;
|
|
@@ -6279,9 +6055,9 @@ var DragDropContextClient = ({
|
|
|
6279
6055
|
const dispatch = useAppStore((s) => s.dispatch);
|
|
6280
6056
|
const appStore = useAppStoreApi();
|
|
6281
6057
|
const id = useSafeId();
|
|
6282
|
-
const debouncedParamsRef = (0,
|
|
6058
|
+
const debouncedParamsRef = (0, import_react36.useRef)(null);
|
|
6283
6059
|
const tempDisableFallback = useTempDisableFallback(100);
|
|
6284
|
-
const [zoneStore] = (0,
|
|
6060
|
+
const [zoneStore] = (0, import_react36.useState)(
|
|
6285
6061
|
() => (0, import_zustand5.createStore)(() => ({
|
|
6286
6062
|
zoneDepthIndex: {},
|
|
6287
6063
|
nextZoneDepthIndex: {},
|
|
@@ -6293,7 +6069,7 @@ var DragDropContextClient = ({
|
|
|
6293
6069
|
hoveringComponent: null
|
|
6294
6070
|
}))
|
|
6295
6071
|
);
|
|
6296
|
-
const getChanged2 = (0,
|
|
6072
|
+
const getChanged2 = (0, import_react36.useCallback)(
|
|
6297
6073
|
(params, id2) => {
|
|
6298
6074
|
const { zoneDepthIndex = {}, areaDepthIndex = {} } = zoneStore.getState() || {};
|
|
6299
6075
|
const stateHasZone = Object.keys(zoneDepthIndex).length > 0;
|
|
@@ -6314,7 +6090,7 @@ var DragDropContextClient = ({
|
|
|
6314
6090
|
},
|
|
6315
6091
|
[zoneStore]
|
|
6316
6092
|
);
|
|
6317
|
-
const setDeepestAndCollide = (0,
|
|
6093
|
+
const setDeepestAndCollide = (0, import_react36.useCallback)(
|
|
6318
6094
|
(params, manager) => {
|
|
6319
6095
|
const { zoneChanged, areaChanged } = getChanged2(params, id);
|
|
6320
6096
|
if (!zoneChanged && !areaChanged) return;
|
|
@@ -6338,7 +6114,7 @@ var DragDropContextClient = ({
|
|
|
6338
6114
|
setDeepestDb.cancel();
|
|
6339
6115
|
debouncedParamsRef.current = null;
|
|
6340
6116
|
};
|
|
6341
|
-
(0,
|
|
6117
|
+
(0, import_react36.useEffect)(() => {
|
|
6342
6118
|
if (DEBUG3) {
|
|
6343
6119
|
zoneStore.subscribe(
|
|
6344
6120
|
(s) => {
|
|
@@ -6352,7 +6128,7 @@ var DragDropContextClient = ({
|
|
|
6352
6128
|
);
|
|
6353
6129
|
}
|
|
6354
6130
|
}, []);
|
|
6355
|
-
const [plugins] = (0,
|
|
6131
|
+
const [plugins] = (0, import_react36.useState)(() => [
|
|
6356
6132
|
...disableAutoScroll ? import_dom.defaultPreset.plugins.filter((plugin) => plugin !== import_dom.AutoScroller) : import_dom.defaultPreset.plugins,
|
|
6357
6133
|
createNestedDroppablePlugin(
|
|
6358
6134
|
{
|
|
@@ -6400,10 +6176,10 @@ var DragDropContextClient = ({
|
|
|
6400
6176
|
)
|
|
6401
6177
|
]);
|
|
6402
6178
|
const sensors = useSensors();
|
|
6403
|
-
const [dragListeners, setDragListeners] = (0,
|
|
6404
|
-
const dragMode = (0,
|
|
6405
|
-
const initialSelector = (0,
|
|
6406
|
-
const nextContextValue = (0,
|
|
6179
|
+
const [dragListeners, setDragListeners] = (0, import_react36.useState)({});
|
|
6180
|
+
const dragMode = (0, import_react36.useRef)(null);
|
|
6181
|
+
const initialSelector = (0, import_react36.useRef)(void 0);
|
|
6182
|
+
const nextContextValue = (0, import_react36.useMemo)(
|
|
6407
6183
|
() => ({
|
|
6408
6184
|
mode: "edit",
|
|
6409
6185
|
areaId: "root",
|
|
@@ -6419,7 +6195,7 @@ var DragDropContextClient = ({
|
|
|
6419
6195
|
setDragListeners
|
|
6420
6196
|
},
|
|
6421
6197
|
children: /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(
|
|
6422
|
-
|
|
6198
|
+
import_react35.DragDropProvider,
|
|
6423
6199
|
{
|
|
6424
6200
|
plugins,
|
|
6425
6201
|
sensors,
|
|
@@ -6539,6 +6315,7 @@ var DragDropContextClient = ({
|
|
|
6539
6315
|
type: "insert",
|
|
6540
6316
|
index: targetIndex,
|
|
6541
6317
|
zone: targetZone,
|
|
6318
|
+
element: source.element,
|
|
6542
6319
|
props: {
|
|
6543
6320
|
id: source.id.toString()
|
|
6544
6321
|
}
|
|
@@ -6564,7 +6341,8 @@ var DragDropContextClient = ({
|
|
|
6564
6341
|
type: "move",
|
|
6565
6342
|
index: targetIndex,
|
|
6566
6343
|
zone: targetZone,
|
|
6567
|
-
props: item.props
|
|
6344
|
+
props: item.props,
|
|
6345
|
+
element: source.element
|
|
6568
6346
|
}
|
|
6569
6347
|
}
|
|
6570
6348
|
});
|
|
@@ -6594,7 +6372,8 @@ var DragDropContextClient = ({
|
|
|
6594
6372
|
type: "move",
|
|
6595
6373
|
index: sourceData.index,
|
|
6596
6374
|
zone: sourceData.zone,
|
|
6597
|
-
props: item.props
|
|
6375
|
+
props: item.props,
|
|
6376
|
+
element: source.element
|
|
6598
6377
|
}
|
|
6599
6378
|
}
|
|
6600
6379
|
});
|
|
@@ -6649,7 +6428,7 @@ var DragDropContext = ({
|
|
|
6649
6428
|
};
|
|
6650
6429
|
|
|
6651
6430
|
// components/Drawer/index.tsx
|
|
6652
|
-
var
|
|
6431
|
+
var import_react38 = require("@dnd-kit/react");
|
|
6653
6432
|
var import_jsx_runtime27 = require("react/jsx-runtime");
|
|
6654
6433
|
var getClassName18 = get_class_name_factory_default("Drawer", styles_module_default10);
|
|
6655
6434
|
var getClassNameItem2 = get_class_name_factory_default("DrawerItem", styles_module_default10);
|
|
@@ -6660,7 +6439,7 @@ var DrawerItemInner = ({
|
|
|
6660
6439
|
dragRef,
|
|
6661
6440
|
isDragDisabled
|
|
6662
6441
|
}) => {
|
|
6663
|
-
const CustomInner = (0,
|
|
6442
|
+
const CustomInner = (0, import_react37.useMemo)(
|
|
6664
6443
|
() => children || (({ children: children2 }) => /* @__PURE__ */ (0, import_jsx_runtime27.jsx)("div", { className: getClassNameItem2("default"), children: children2 })),
|
|
6665
6444
|
[children]
|
|
6666
6445
|
);
|
|
@@ -6686,7 +6465,7 @@ var DrawerItemDraggable = ({
|
|
|
6686
6465
|
id,
|
|
6687
6466
|
isDragDisabled
|
|
6688
6467
|
}) => {
|
|
6689
|
-
const { ref } = (0,
|
|
6468
|
+
const { ref } = (0, import_react38.useDraggable)({
|
|
6690
6469
|
id,
|
|
6691
6470
|
data: { componentType: name },
|
|
6692
6471
|
disabled: isDragDisabled,
|
|
@@ -6715,7 +6494,7 @@ var DrawerItem = ({
|
|
|
6715
6494
|
isDragDisabled
|
|
6716
6495
|
}) => {
|
|
6717
6496
|
const resolvedId = id || name;
|
|
6718
|
-
const [dynamicId, setDynamicId] = (0,
|
|
6497
|
+
const [dynamicId, setDynamicId] = (0, import_react37.useState)(generateId(resolvedId));
|
|
6719
6498
|
if (typeof index !== "undefined") {
|
|
6720
6499
|
console.error(
|
|
6721
6500
|
"Warning: The `index` prop on Drawer.Item is deprecated and no longer required."
|
|
@@ -6755,7 +6534,7 @@ var Drawer = ({
|
|
|
6755
6534
|
);
|
|
6756
6535
|
}
|
|
6757
6536
|
const id = useSafeId();
|
|
6758
|
-
const { ref } = (0,
|
|
6537
|
+
const { ref } = (0, import_react38.useDroppable)({
|
|
6759
6538
|
id,
|
|
6760
6539
|
type: "void",
|
|
6761
6540
|
collisionPriority: 0
|
|
@@ -6777,7 +6556,7 @@ Drawer.Item = DrawerItem;
|
|
|
6777
6556
|
|
|
6778
6557
|
// components/Puck/index.tsx
|
|
6779
6558
|
init_react_import();
|
|
6780
|
-
var
|
|
6559
|
+
var import_react54 = require("react");
|
|
6781
6560
|
|
|
6782
6561
|
// components/SidebarSection/index.tsx
|
|
6783
6562
|
init_react_import();
|
|
@@ -6788,7 +6567,7 @@ var styles_module_default13 = { "SidebarSection": "_SidebarSection_8boj8_1", "Si
|
|
|
6788
6567
|
|
|
6789
6568
|
// lib/use-breadcrumbs.ts
|
|
6790
6569
|
init_react_import();
|
|
6791
|
-
var
|
|
6570
|
+
var import_react39 = require("react");
|
|
6792
6571
|
var useBreadcrumbs = (renderCount) => {
|
|
6793
6572
|
const selectedId = useAppStore((s) => {
|
|
6794
6573
|
var _a;
|
|
@@ -6800,7 +6579,7 @@ var useBreadcrumbs = (renderCount) => {
|
|
|
6800
6579
|
return (_a = s.state.indexes.nodes[selectedId]) == null ? void 0 : _a.path;
|
|
6801
6580
|
});
|
|
6802
6581
|
const appStore = useAppStoreApi();
|
|
6803
|
-
return (0,
|
|
6582
|
+
return (0, import_react39.useMemo)(() => {
|
|
6804
6583
|
const breadcrumbs = (path == null ? void 0 : path.map((zoneCompound) => {
|
|
6805
6584
|
var _a, _b, _c;
|
|
6806
6585
|
const [componentId] = zoneCompound.split(":");
|
|
@@ -6884,7 +6663,7 @@ init_react_import();
|
|
|
6884
6663
|
var styles_module_default15 = { "PuckFields": "_PuckFields_10bh7_1", "PuckFields--isLoading": "_PuckFields--isLoading_10bh7_6", "PuckFields-loadingOverlay": "_PuckFields-loadingOverlay_10bh7_10", "PuckFields-loadingOverlayInner": "_PuckFields-loadingOverlayInner_10bh7_25", "PuckFields-field": "_PuckFields-field_10bh7_32", "PuckFields--wrapFields": "_PuckFields--wrapFields_10bh7_36" };
|
|
6885
6664
|
|
|
6886
6665
|
// components/Puck/components/Fields/index.tsx
|
|
6887
|
-
var
|
|
6666
|
+
var import_react40 = require("react");
|
|
6888
6667
|
var import_shallow5 = require("zustand/react/shallow");
|
|
6889
6668
|
var import_jsx_runtime29 = require("react/jsx-runtime");
|
|
6890
6669
|
var getClassName20 = get_class_name_factory_default("PuckFields", styles_module_default15);
|
|
@@ -6957,7 +6736,7 @@ var FieldsChild = ({ fieldName }) => {
|
|
|
6957
6736
|
})
|
|
6958
6737
|
);
|
|
6959
6738
|
const appStore = useAppStoreApi();
|
|
6960
|
-
const onChange = (0,
|
|
6739
|
+
const onChange = (0, import_react40.useCallback)(createOnChange(fieldName, appStore), [
|
|
6961
6740
|
fieldName
|
|
6962
6741
|
]);
|
|
6963
6742
|
const { visible = true } = field != null ? field : {};
|
|
@@ -6975,7 +6754,7 @@ var FieldsChild = ({ fieldName }) => {
|
|
|
6975
6754
|
}
|
|
6976
6755
|
) }, id);
|
|
6977
6756
|
};
|
|
6978
|
-
var FieldsChildMemo = (0,
|
|
6757
|
+
var FieldsChildMemo = (0, import_react40.memo)(FieldsChild);
|
|
6979
6758
|
var FieldsInternal = ({ wrapFields = true }) => {
|
|
6980
6759
|
const overrides = useAppStore((s) => s.overrides);
|
|
6981
6760
|
const componentResolving = useAppStore((s) => {
|
|
@@ -7000,7 +6779,7 @@ var FieldsInternal = ({ wrapFields = true }) => {
|
|
|
7000
6779
|
})
|
|
7001
6780
|
);
|
|
7002
6781
|
const isLoading = fieldsLoading || componentResolving;
|
|
7003
|
-
const Wrapper = (0,
|
|
6782
|
+
const Wrapper = (0, import_react40.useMemo)(() => overrides.fields || DefaultFields, [overrides]);
|
|
7004
6783
|
return /* @__PURE__ */ (0, import_jsx_runtime29.jsxs)(
|
|
7005
6784
|
"form",
|
|
7006
6785
|
{
|
|
@@ -7015,14 +6794,14 @@ var FieldsInternal = ({ wrapFields = true }) => {
|
|
|
7015
6794
|
}
|
|
7016
6795
|
);
|
|
7017
6796
|
};
|
|
7018
|
-
var Fields = (0,
|
|
6797
|
+
var Fields = (0, import_react40.memo)(FieldsInternal);
|
|
7019
6798
|
|
|
7020
6799
|
// components/Puck/components/Components/index.tsx
|
|
7021
6800
|
init_react_import();
|
|
7022
6801
|
|
|
7023
6802
|
// lib/use-component-list.tsx
|
|
7024
6803
|
init_react_import();
|
|
7025
|
-
var
|
|
6804
|
+
var import_react41 = require("react");
|
|
7026
6805
|
|
|
7027
6806
|
// components/ComponentList/index.tsx
|
|
7028
6807
|
init_react_import();
|
|
@@ -7093,10 +6872,10 @@ ComponentList.Item = ComponentListItem;
|
|
|
7093
6872
|
// lib/use-component-list.tsx
|
|
7094
6873
|
var import_jsx_runtime31 = require("react/jsx-runtime");
|
|
7095
6874
|
var useComponentList = () => {
|
|
7096
|
-
const [componentList, setComponentList] = (0,
|
|
6875
|
+
const [componentList, setComponentList] = (0, import_react41.useState)();
|
|
7097
6876
|
const config = useAppStore((s) => s.config);
|
|
7098
6877
|
const uiComponentList = useAppStore((s) => s.state.ui.componentList);
|
|
7099
|
-
(0,
|
|
6878
|
+
(0, import_react41.useEffect)(() => {
|
|
7100
6879
|
var _a, _b, _c;
|
|
7101
6880
|
if (Object.keys(uiComponentList).length > 0) {
|
|
7102
6881
|
const matchedComponents = [];
|
|
@@ -7165,22 +6944,22 @@ var useComponentList = () => {
|
|
|
7165
6944
|
};
|
|
7166
6945
|
|
|
7167
6946
|
// components/Puck/components/Components/index.tsx
|
|
7168
|
-
var
|
|
6947
|
+
var import_react42 = require("react");
|
|
7169
6948
|
var import_jsx_runtime32 = require("react/jsx-runtime");
|
|
7170
6949
|
var Components = () => {
|
|
7171
6950
|
const overrides = useAppStore((s) => s.overrides);
|
|
7172
6951
|
const componentList = useComponentList();
|
|
7173
|
-
const Wrapper = (0,
|
|
6952
|
+
const Wrapper = (0, import_react42.useMemo)(() => overrides.components || "div", [overrides]);
|
|
7174
6953
|
return /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(Wrapper, { children: componentList ? componentList : /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(ComponentList, { id: "all" }) });
|
|
7175
6954
|
};
|
|
7176
6955
|
|
|
7177
6956
|
// components/Puck/components/Preview/index.tsx
|
|
7178
6957
|
init_react_import();
|
|
7179
|
-
var
|
|
6958
|
+
var import_react44 = require("react");
|
|
7180
6959
|
|
|
7181
6960
|
// components/AutoFrame/index.tsx
|
|
7182
6961
|
init_react_import();
|
|
7183
|
-
var
|
|
6962
|
+
var import_react43 = require("react");
|
|
7184
6963
|
var import_object_hash = __toESM(require("object-hash"));
|
|
7185
6964
|
var import_react_dom3 = require("react-dom");
|
|
7186
6965
|
var import_jsx_runtime33 = require("react/jsx-runtime");
|
|
@@ -7233,7 +7012,7 @@ var CopyHostStyles = ({
|
|
|
7233
7012
|
onStylesLoaded = () => null
|
|
7234
7013
|
}) => {
|
|
7235
7014
|
const { document: doc, window: win } = useFrame();
|
|
7236
|
-
(0,
|
|
7015
|
+
(0, import_react43.useEffect)(() => {
|
|
7237
7016
|
if (!win || !doc) {
|
|
7238
7017
|
return () => {
|
|
7239
7018
|
};
|
|
@@ -7392,8 +7171,8 @@ var CopyHostStyles = ({
|
|
|
7392
7171
|
}, []);
|
|
7393
7172
|
return /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(import_jsx_runtime33.Fragment, { children });
|
|
7394
7173
|
};
|
|
7395
|
-
var autoFrameContext = (0,
|
|
7396
|
-
var useFrame = () => (0,
|
|
7174
|
+
var autoFrameContext = (0, import_react43.createContext)({});
|
|
7175
|
+
var useFrame = () => (0, import_react43.useContext)(autoFrameContext);
|
|
7397
7176
|
function AutoFrame(_a) {
|
|
7398
7177
|
var _b = _a, {
|
|
7399
7178
|
children,
|
|
@@ -7414,11 +7193,11 @@ function AutoFrame(_a) {
|
|
|
7414
7193
|
"onNotReady",
|
|
7415
7194
|
"frameRef"
|
|
7416
7195
|
]);
|
|
7417
|
-
const [loaded, setLoaded] = (0,
|
|
7418
|
-
const [ctx, setCtx] = (0,
|
|
7419
|
-
const [mountTarget, setMountTarget] = (0,
|
|
7420
|
-
const [stylesLoaded, setStylesLoaded] = (0,
|
|
7421
|
-
(0,
|
|
7196
|
+
const [loaded, setLoaded] = (0, import_react43.useState)(false);
|
|
7197
|
+
const [ctx, setCtx] = (0, import_react43.useState)({});
|
|
7198
|
+
const [mountTarget, setMountTarget] = (0, import_react43.useState)();
|
|
7199
|
+
const [stylesLoaded, setStylesLoaded] = (0, import_react43.useState)(false);
|
|
7200
|
+
(0, import_react43.useEffect)(() => {
|
|
7422
7201
|
var _a2;
|
|
7423
7202
|
if (frameRef.current) {
|
|
7424
7203
|
const doc = frameRef.current.contentDocument;
|
|
@@ -7470,7 +7249,7 @@ var import_jsx_runtime34 = require("react/jsx-runtime");
|
|
|
7470
7249
|
var getClassName22 = get_class_name_factory_default("PuckPreview", styles_module_default17);
|
|
7471
7250
|
var useBubbleIframeEvents = (ref) => {
|
|
7472
7251
|
const status = useAppStore((s) => s.status);
|
|
7473
|
-
(0,
|
|
7252
|
+
(0, import_react44.useEffect)(() => {
|
|
7474
7253
|
if (ref.current && status === "READY") {
|
|
7475
7254
|
const iframe = ref.current;
|
|
7476
7255
|
const handlePointerMove = (event) => {
|
|
@@ -7519,7 +7298,7 @@ var Preview2 = ({ id = "puck-preview" }) => {
|
|
|
7519
7298
|
const renderData = useAppStore(
|
|
7520
7299
|
(s) => s.state.ui.previewMode === "edit" ? null : s.state.data
|
|
7521
7300
|
);
|
|
7522
|
-
const Page = (0,
|
|
7301
|
+
const Page = (0, import_react44.useCallback)(
|
|
7523
7302
|
(pageProps) => {
|
|
7524
7303
|
var _a, _b;
|
|
7525
7304
|
const propsWithSlots = useSlots(
|
|
@@ -7533,9 +7312,9 @@ var Preview2 = ({ id = "puck-preview" }) => {
|
|
|
7533
7312
|
},
|
|
7534
7313
|
[config]
|
|
7535
7314
|
);
|
|
7536
|
-
const Frame = (0,
|
|
7315
|
+
const Frame = (0, import_react44.useMemo)(() => overrides.iframe, [overrides]);
|
|
7537
7316
|
const rootProps = root.props || root;
|
|
7538
|
-
const ref = (0,
|
|
7317
|
+
const ref = (0, import_react44.useRef)(null);
|
|
7539
7318
|
useBubbleIframeEvents(ref);
|
|
7540
7319
|
const inner = !renderData ? /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(
|
|
7541
7320
|
Page,
|
|
@@ -7549,8 +7328,8 @@ var Preview2 = ({ id = "puck-preview" }) => {
|
|
|
7549
7328
|
editMode: true,
|
|
7550
7329
|
children: /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(DropZonePure, { zone: rootDroppableId })
|
|
7551
7330
|
})
|
|
7552
|
-
) : /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(
|
|
7553
|
-
(0,
|
|
7331
|
+
) : /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(Render, { data: renderData, config, metadata });
|
|
7332
|
+
(0, import_react44.useEffect)(() => {
|
|
7554
7333
|
if (!iframe.enabled) {
|
|
7555
7334
|
setStatus("READY");
|
|
7556
7335
|
}
|
|
@@ -7620,7 +7399,7 @@ var scrollIntoView = (el) => {
|
|
|
7620
7399
|
};
|
|
7621
7400
|
|
|
7622
7401
|
// components/LayerTree/index.tsx
|
|
7623
|
-
var
|
|
7402
|
+
var import_react45 = require("react");
|
|
7624
7403
|
|
|
7625
7404
|
// lib/on-scroll-end.ts
|
|
7626
7405
|
init_react_import();
|
|
@@ -7655,7 +7434,7 @@ var Layer = ({
|
|
|
7655
7434
|
const config = useAppStore((s) => s.config);
|
|
7656
7435
|
const itemSelector = useAppStore((s) => s.state.ui.itemSelector);
|
|
7657
7436
|
const dispatch = useAppStore((s) => s.dispatch);
|
|
7658
|
-
const setItemSelector = (0,
|
|
7437
|
+
const setItemSelector = (0, import_react45.useCallback)(
|
|
7659
7438
|
(itemSelector2) => {
|
|
7660
7439
|
dispatch({ type: "setUi", ui: { itemSelector: itemSelector2 } });
|
|
7661
7440
|
},
|
|
@@ -7675,7 +7454,7 @@ var Layer = ({
|
|
|
7675
7454
|
)
|
|
7676
7455
|
);
|
|
7677
7456
|
const containsZone = zonesForItem.length > 0;
|
|
7678
|
-
const zoneStore = (0,
|
|
7457
|
+
const zoneStore = (0, import_react45.useContext)(ZoneStoreContext);
|
|
7679
7458
|
const isHovering = useContextStore(
|
|
7680
7459
|
ZoneStoreContext,
|
|
7681
7460
|
(s) => s.hoveringComponent === itemId
|
|
@@ -7802,7 +7581,7 @@ var LayerTree = ({
|
|
|
7802
7581
|
};
|
|
7803
7582
|
|
|
7804
7583
|
// components/Puck/components/Outline/index.tsx
|
|
7805
|
-
var
|
|
7584
|
+
var import_react46 = require("react");
|
|
7806
7585
|
|
|
7807
7586
|
// lib/data/find-zones-for-area.ts
|
|
7808
7587
|
init_react_import();
|
|
@@ -7820,7 +7599,7 @@ var Outline = () => {
|
|
|
7820
7599
|
const rootZones = useAppStore(
|
|
7821
7600
|
(0, import_shallow7.useShallow)((s) => findZonesForArea(s.state, "root"))
|
|
7822
7601
|
);
|
|
7823
|
-
const Wrapper = (0,
|
|
7602
|
+
const Wrapper = (0, import_react46.useMemo)(() => outlineOverride || "div", [outlineOverride]);
|
|
7824
7603
|
return /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(Wrapper, { children: rootZones.map((zoneCompound) => /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(
|
|
7825
7604
|
LayerTree,
|
|
7826
7605
|
{
|
|
@@ -7954,11 +7733,11 @@ var getBox = function getBox2(el) {
|
|
|
7954
7733
|
};
|
|
7955
7734
|
|
|
7956
7735
|
// components/Puck/components/Canvas/index.tsx
|
|
7957
|
-
var
|
|
7736
|
+
var import_react48 = require("react");
|
|
7958
7737
|
|
|
7959
7738
|
// components/ViewportControls/index.tsx
|
|
7960
7739
|
init_react_import();
|
|
7961
|
-
var
|
|
7740
|
+
var import_react47 = require("react");
|
|
7962
7741
|
|
|
7963
7742
|
// css-module:/home/runner/work/puck/puck/packages/core/components/ViewportControls/styles.module.css#css-module
|
|
7964
7743
|
init_react_import();
|
|
@@ -7981,8 +7760,8 @@ var ViewportButton = ({
|
|
|
7981
7760
|
onClick
|
|
7982
7761
|
}) => {
|
|
7983
7762
|
const viewports = useAppStore((s) => s.state.ui.viewports);
|
|
7984
|
-
const [isActive, setIsActive] = (0,
|
|
7985
|
-
(0,
|
|
7763
|
+
const [isActive, setIsActive] = (0, import_react47.useState)(false);
|
|
7764
|
+
(0, import_react47.useEffect)(() => {
|
|
7986
7765
|
setIsActive(width === viewports.current.width);
|
|
7987
7766
|
}, [width, viewports.current.width]);
|
|
7988
7767
|
return /* @__PURE__ */ (0, import_jsx_runtime37.jsx)("span", { className: getClassNameButton({ isActive }), children: /* @__PURE__ */ (0, import_jsx_runtime37.jsx)(
|
|
@@ -8019,7 +7798,7 @@ var ViewportControls = ({
|
|
|
8019
7798
|
const defaultsContainAutoZoom = defaultZoomOptions.find(
|
|
8020
7799
|
(option) => option.value === autoZoom
|
|
8021
7800
|
);
|
|
8022
|
-
const zoomOptions = (0,
|
|
7801
|
+
const zoomOptions = (0, import_react47.useMemo)(
|
|
8023
7802
|
() => [
|
|
8024
7803
|
...defaultZoomOptions,
|
|
8025
7804
|
...defaultsContainAutoZoom ? [] : [
|
|
@@ -8168,17 +7947,17 @@ var Canvas = () => {
|
|
|
8168
7947
|
viewports: s.state.ui.viewports
|
|
8169
7948
|
}))
|
|
8170
7949
|
);
|
|
8171
|
-
const frameRef = (0,
|
|
8172
|
-
const [showTransition, setShowTransition] = (0,
|
|
8173
|
-
const defaultRender = (0,
|
|
7950
|
+
const frameRef = (0, import_react48.useRef)(null);
|
|
7951
|
+
const [showTransition, setShowTransition] = (0, import_react48.useState)(false);
|
|
7952
|
+
const defaultRender = (0, import_react48.useMemo)(() => {
|
|
8174
7953
|
const PuckDefault = ({ children }) => /* @__PURE__ */ (0, import_jsx_runtime38.jsx)(import_jsx_runtime38.Fragment, { children });
|
|
8175
7954
|
return PuckDefault;
|
|
8176
7955
|
}, []);
|
|
8177
|
-
const CustomPreview = (0,
|
|
7956
|
+
const CustomPreview = (0, import_react48.useMemo)(
|
|
8178
7957
|
() => overrides.preview || defaultRender,
|
|
8179
7958
|
[overrides]
|
|
8180
7959
|
);
|
|
8181
|
-
const getFrameDimensions = (0,
|
|
7960
|
+
const getFrameDimensions = (0, import_react48.useCallback)(() => {
|
|
8182
7961
|
if (frameRef.current) {
|
|
8183
7962
|
const frame = frameRef.current;
|
|
8184
7963
|
const box = getBox(frame);
|
|
@@ -8186,7 +7965,7 @@ var Canvas = () => {
|
|
|
8186
7965
|
}
|
|
8187
7966
|
return { width: 0, height: 0 };
|
|
8188
7967
|
}, [frameRef]);
|
|
8189
|
-
const resetAutoZoom = (0,
|
|
7968
|
+
const resetAutoZoom = (0, import_react48.useCallback)(
|
|
8190
7969
|
(newViewports = viewports) => {
|
|
8191
7970
|
if (frameRef.current) {
|
|
8192
7971
|
setZoomConfig(
|
|
@@ -8200,11 +7979,11 @@ var Canvas = () => {
|
|
|
8200
7979
|
},
|
|
8201
7980
|
[frameRef, zoomConfig, viewports]
|
|
8202
7981
|
);
|
|
8203
|
-
(0,
|
|
7982
|
+
(0, import_react48.useEffect)(() => {
|
|
8204
7983
|
setShowTransition(false);
|
|
8205
7984
|
resetAutoZoom(viewports);
|
|
8206
7985
|
}, [frameRef, leftSideBarVisible, rightSideBarVisible]);
|
|
8207
|
-
(0,
|
|
7986
|
+
(0, import_react48.useEffect)(() => {
|
|
8208
7987
|
const { height: frameHeight } = getFrameDimensions();
|
|
8209
7988
|
if (viewports.current.height === "auto") {
|
|
8210
7989
|
setZoomConfig(__spreadProps(__spreadValues({}, zoomConfig), {
|
|
@@ -8212,13 +7991,13 @@ var Canvas = () => {
|
|
|
8212
7991
|
}));
|
|
8213
7992
|
}
|
|
8214
7993
|
}, [zoomConfig.zoom]);
|
|
8215
|
-
(0,
|
|
7994
|
+
(0, import_react48.useEffect)(() => {
|
|
8216
7995
|
if (ZOOM_ON_CHANGE) {
|
|
8217
7996
|
setShowTransition(true);
|
|
8218
7997
|
resetAutoZoom(viewports);
|
|
8219
7998
|
}
|
|
8220
7999
|
}, [viewports.current.width]);
|
|
8221
|
-
(0,
|
|
8000
|
+
(0, import_react48.useEffect)(() => {
|
|
8222
8001
|
const cb = () => {
|
|
8223
8002
|
setShowTransition(false);
|
|
8224
8003
|
resetAutoZoom();
|
|
@@ -8228,8 +8007,8 @@ var Canvas = () => {
|
|
|
8228
8007
|
window.removeEventListener("resize", cb);
|
|
8229
8008
|
};
|
|
8230
8009
|
}, []);
|
|
8231
|
-
const [showLoader, setShowLoader] = (0,
|
|
8232
|
-
(0,
|
|
8010
|
+
const [showLoader, setShowLoader] = (0, import_react48.useState)(false);
|
|
8011
|
+
(0, import_react48.useEffect)(() => {
|
|
8233
8012
|
setTimeout(() => {
|
|
8234
8013
|
setShowLoader(true);
|
|
8235
8014
|
}, 500);
|
|
@@ -8307,7 +8086,7 @@ var Canvas = () => {
|
|
|
8307
8086
|
|
|
8308
8087
|
// lib/use-loaded-overrides.ts
|
|
8309
8088
|
init_react_import();
|
|
8310
|
-
var
|
|
8089
|
+
var import_react49 = require("react");
|
|
8311
8090
|
|
|
8312
8091
|
// lib/load-overrides.ts
|
|
8313
8092
|
init_react_import();
|
|
@@ -8346,7 +8125,7 @@ var useLoadedOverrides = ({
|
|
|
8346
8125
|
overrides,
|
|
8347
8126
|
plugins
|
|
8348
8127
|
}) => {
|
|
8349
|
-
return (0,
|
|
8128
|
+
return (0, import_react49.useMemo)(() => {
|
|
8350
8129
|
return loadOverrides({ overrides, plugins });
|
|
8351
8130
|
}, [plugins, overrides]);
|
|
8352
8131
|
};
|
|
@@ -8358,14 +8137,14 @@ var DefaultOverride = ({ children }) => /* @__PURE__ */ (0, import_jsx_runtime39
|
|
|
8358
8137
|
|
|
8359
8138
|
// lib/use-inject-css.ts
|
|
8360
8139
|
init_react_import();
|
|
8361
|
-
var
|
|
8140
|
+
var import_react50 = require("react");
|
|
8362
8141
|
var styles = ``;
|
|
8363
8142
|
var useInjectStyleSheet = (initialStyles, iframeEnabled) => {
|
|
8364
|
-
const [el, setEl] = (0,
|
|
8365
|
-
(0,
|
|
8143
|
+
const [el, setEl] = (0, import_react50.useState)();
|
|
8144
|
+
(0, import_react50.useEffect)(() => {
|
|
8366
8145
|
setEl(document.createElement("style"));
|
|
8367
8146
|
}, []);
|
|
8368
|
-
(0,
|
|
8147
|
+
(0, import_react50.useEffect)(() => {
|
|
8369
8148
|
var _a;
|
|
8370
8149
|
if (!el || typeof window === "undefined") {
|
|
8371
8150
|
return;
|
|
@@ -8385,10 +8164,10 @@ var useInjectGlobalCss = (iframeEnabled) => {
|
|
|
8385
8164
|
|
|
8386
8165
|
// lib/use-preview-mode-hotkeys.ts
|
|
8387
8166
|
init_react_import();
|
|
8388
|
-
var
|
|
8167
|
+
var import_react51 = require("react");
|
|
8389
8168
|
var usePreviewModeHotkeys = () => {
|
|
8390
8169
|
const appStore = useAppStoreApi();
|
|
8391
|
-
const toggleInteractive = (0,
|
|
8170
|
+
const toggleInteractive = (0, import_react51.useCallback)(() => {
|
|
8392
8171
|
const dispatch = appStore.getState().dispatch;
|
|
8393
8172
|
dispatch({
|
|
8394
8173
|
type: "setUi",
|
|
@@ -8403,7 +8182,7 @@ var usePreviewModeHotkeys = () => {
|
|
|
8403
8182
|
|
|
8404
8183
|
// lib/use-puck.ts
|
|
8405
8184
|
init_react_import();
|
|
8406
|
-
var
|
|
8185
|
+
var import_react52 = require("react");
|
|
8407
8186
|
var import_zustand6 = require("zustand");
|
|
8408
8187
|
var generateUsePuck = (store) => {
|
|
8409
8188
|
const history = {
|
|
@@ -8434,10 +8213,9 @@ var generateUsePuck = (store) => {
|
|
|
8434
8213
|
return { zone: zoneCompound, index };
|
|
8435
8214
|
}
|
|
8436
8215
|
};
|
|
8437
|
-
|
|
8438
|
-
return __spreadProps(__spreadValues({}, storeData), { get });
|
|
8216
|
+
return storeData;
|
|
8439
8217
|
};
|
|
8440
|
-
var UsePuckStoreContext = (0,
|
|
8218
|
+
var UsePuckStoreContext = (0, import_react52.createContext)(
|
|
8441
8219
|
null
|
|
8442
8220
|
);
|
|
8443
8221
|
var convertToPickedStore = (store) => {
|
|
@@ -8451,12 +8229,12 @@ var convertToPickedStore = (store) => {
|
|
|
8451
8229
|
};
|
|
8452
8230
|
};
|
|
8453
8231
|
var useRegisterUsePuckStore = (appStore) => {
|
|
8454
|
-
const [usePuckStore] = (0,
|
|
8232
|
+
const [usePuckStore] = (0, import_react52.useState)(
|
|
8455
8233
|
() => (0, import_zustand6.createStore)(
|
|
8456
8234
|
() => generateUsePuck(convertToPickedStore(appStore.getState()))
|
|
8457
8235
|
)
|
|
8458
8236
|
);
|
|
8459
|
-
(0,
|
|
8237
|
+
(0, import_react52.useEffect)(() => {
|
|
8460
8238
|
return appStore.subscribe(
|
|
8461
8239
|
(store) => convertToPickedStore(store),
|
|
8462
8240
|
(pickedStore) => {
|
|
@@ -8468,7 +8246,7 @@ var useRegisterUsePuckStore = (appStore) => {
|
|
|
8468
8246
|
};
|
|
8469
8247
|
function createUsePuck() {
|
|
8470
8248
|
return function usePuck2(selector) {
|
|
8471
|
-
const usePuckApi = (0,
|
|
8249
|
+
const usePuckApi = (0, import_react52.useContext)(UsePuckStoreContext);
|
|
8472
8250
|
if (!usePuckApi) {
|
|
8473
8251
|
throw new Error("usePuck must be used inside <Puck>.");
|
|
8474
8252
|
}
|
|
@@ -8480,7 +8258,7 @@ function createUsePuck() {
|
|
|
8480
8258
|
};
|
|
8481
8259
|
}
|
|
8482
8260
|
function usePuck() {
|
|
8483
|
-
(0,
|
|
8261
|
+
(0, import_react52.useEffect)(() => {
|
|
8484
8262
|
console.warn(
|
|
8485
8263
|
"You're using the `usePuck` method without a selector, which may cause unnecessary re-renders. Replace with `createUsePuck` and provide a selector for improved performance."
|
|
8486
8264
|
);
|
|
@@ -8488,7 +8266,7 @@ function usePuck() {
|
|
|
8488
8266
|
return createUsePuck()((s) => s);
|
|
8489
8267
|
}
|
|
8490
8268
|
function useGetPuck() {
|
|
8491
|
-
const usePuckApi = (0,
|
|
8269
|
+
const usePuckApi = (0, import_react52.useContext)(UsePuckStoreContext);
|
|
8492
8270
|
if (!usePuckApi) {
|
|
8493
8271
|
throw new Error("usePuckGet must be used inside <Puck>.");
|
|
8494
8272
|
}
|
|
@@ -8500,7 +8278,7 @@ var import_fast_deep_equal3 = __toESM(require("fast-deep-equal"));
|
|
|
8500
8278
|
|
|
8501
8279
|
// components/Puck/components/Header/index.tsx
|
|
8502
8280
|
init_react_import();
|
|
8503
|
-
var
|
|
8281
|
+
var import_react53 = require("react");
|
|
8504
8282
|
|
|
8505
8283
|
// components/MenuBar/index.tsx
|
|
8506
8284
|
init_react_import();
|
|
@@ -8582,7 +8360,7 @@ var HeaderInner = () => {
|
|
|
8582
8360
|
} = usePropsContext();
|
|
8583
8361
|
const dispatch = useAppStore((s) => s.dispatch);
|
|
8584
8362
|
const appStore = useAppStoreApi();
|
|
8585
|
-
const defaultHeaderRender = (0,
|
|
8363
|
+
const defaultHeaderRender = (0, import_react53.useMemo)(() => {
|
|
8586
8364
|
if (renderHeader) {
|
|
8587
8365
|
console.warn(
|
|
8588
8366
|
"`renderHeader` is deprecated. Please use `overrides.header` and the `usePuck` hook instead"
|
|
@@ -8597,7 +8375,7 @@ var HeaderInner = () => {
|
|
|
8597
8375
|
}
|
|
8598
8376
|
return DefaultOverride;
|
|
8599
8377
|
}, [renderHeader]);
|
|
8600
|
-
const defaultHeaderActionsRender = (0,
|
|
8378
|
+
const defaultHeaderActionsRender = (0, import_react53.useMemo)(() => {
|
|
8601
8379
|
if (renderHeaderActions) {
|
|
8602
8380
|
console.warn(
|
|
8603
8381
|
"`renderHeaderActions` is deprecated. Please use `overrides.headerActions` and the `usePuck` hook instead."
|
|
@@ -8617,7 +8395,7 @@ var HeaderInner = () => {
|
|
|
8617
8395
|
const CustomHeaderActions = useAppStore(
|
|
8618
8396
|
(s) => s.overrides.headerActions || defaultHeaderActionsRender
|
|
8619
8397
|
);
|
|
8620
|
-
const [menuOpen, setMenuOpen] = (0,
|
|
8398
|
+
const [menuOpen, setMenuOpen] = (0, import_react53.useState)(false);
|
|
8621
8399
|
const rootTitle = useAppStore((s) => {
|
|
8622
8400
|
var _a, _b;
|
|
8623
8401
|
const rootData = (_a = s.state.indexes.nodes["root"]) == null ? void 0 : _a.data;
|
|
@@ -8627,7 +8405,7 @@ var HeaderInner = () => {
|
|
|
8627
8405
|
const rightSideBarVisible = useAppStore(
|
|
8628
8406
|
(s) => s.state.ui.rightSideBarVisible
|
|
8629
8407
|
);
|
|
8630
|
-
const toggleSidebars = (0,
|
|
8408
|
+
const toggleSidebars = (0, import_react53.useCallback)(
|
|
8631
8409
|
(sidebar) => {
|
|
8632
8410
|
const widerViewport = window.matchMedia("(min-width: 638px)").matches;
|
|
8633
8411
|
const sideBarVisible = sidebar === "left" ? leftSideBarVisible : rightSideBarVisible;
|
|
@@ -8730,7 +8508,7 @@ var HeaderInner = () => {
|
|
|
8730
8508
|
}
|
|
8731
8509
|
);
|
|
8732
8510
|
};
|
|
8733
|
-
var Header = (0,
|
|
8511
|
+
var Header = (0, import_react53.memo)(HeaderInner);
|
|
8734
8512
|
|
|
8735
8513
|
// components/Puck/index.tsx
|
|
8736
8514
|
var import_jsx_runtime42 = require("react/jsx-runtime");
|
|
@@ -8745,11 +8523,11 @@ var FieldSideBar = () => {
|
|
|
8745
8523
|
);
|
|
8746
8524
|
return /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(SidebarSection, { noPadding: true, noBorderTop: true, showBreadcrumbs: true, title, children: /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(Fields, {}) });
|
|
8747
8525
|
};
|
|
8748
|
-
var propsContext = (0,
|
|
8526
|
+
var propsContext = (0, import_react54.createContext)({});
|
|
8749
8527
|
function PropsProvider(props) {
|
|
8750
8528
|
return /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(propsContext.Provider, { value: props, children: props.children });
|
|
8751
8529
|
}
|
|
8752
|
-
var usePropsContext = () => (0,
|
|
8530
|
+
var usePropsContext = () => (0, import_react54.useContext)(propsContext);
|
|
8753
8531
|
function PuckProvider({ children }) {
|
|
8754
8532
|
const {
|
|
8755
8533
|
config,
|
|
@@ -8765,14 +8543,14 @@ function PuckProvider({ children }) {
|
|
|
8765
8543
|
metadata,
|
|
8766
8544
|
onAction
|
|
8767
8545
|
} = usePropsContext();
|
|
8768
|
-
const iframe = (0,
|
|
8546
|
+
const iframe = (0, import_react54.useMemo)(
|
|
8769
8547
|
() => __spreadValues({
|
|
8770
8548
|
enabled: true,
|
|
8771
8549
|
waitForStyles: true
|
|
8772
8550
|
}, _iframe),
|
|
8773
8551
|
[_iframe]
|
|
8774
8552
|
);
|
|
8775
|
-
const [generatedAppState] = (0,
|
|
8553
|
+
const [generatedAppState] = (0, import_react54.useState)(() => {
|
|
8776
8554
|
var _a, _b, _c, _d, _e, _f, _g, _h, _i;
|
|
8777
8555
|
const initial = __spreadValues(__spreadValues({}, defaultAppState.ui), initialUi);
|
|
8778
8556
|
let clientUiState = {};
|
|
@@ -8832,7 +8610,7 @@ function PuckProvider({ children }) {
|
|
|
8832
8610
|
return walkAppState(newAppState, config);
|
|
8833
8611
|
});
|
|
8834
8612
|
const { appendData = true } = _initialHistory || {};
|
|
8835
|
-
const [blendedHistories] = (0,
|
|
8613
|
+
const [blendedHistories] = (0, import_react54.useState)(
|
|
8836
8614
|
[
|
|
8837
8615
|
...(_initialHistory == null ? void 0 : _initialHistory.histories) || [],
|
|
8838
8616
|
...appendData ? [{ state: generatedAppState }] : []
|
|
@@ -8852,7 +8630,7 @@ function PuckProvider({ children }) {
|
|
|
8852
8630
|
overrides,
|
|
8853
8631
|
plugins
|
|
8854
8632
|
});
|
|
8855
|
-
const generateAppStore = (0,
|
|
8633
|
+
const generateAppStore = (0, import_react54.useCallback)(
|
|
8856
8634
|
(state) => {
|
|
8857
8635
|
return {
|
|
8858
8636
|
state,
|
|
@@ -8876,15 +8654,15 @@ function PuckProvider({ children }) {
|
|
|
8876
8654
|
metadata
|
|
8877
8655
|
]
|
|
8878
8656
|
);
|
|
8879
|
-
const [appStore] = (0,
|
|
8657
|
+
const [appStore] = (0, import_react54.useState)(
|
|
8880
8658
|
() => createAppStore(generateAppStore(initialAppState))
|
|
8881
8659
|
);
|
|
8882
|
-
(0,
|
|
8660
|
+
(0, import_react54.useEffect)(() => {
|
|
8883
8661
|
if (process.env.NODE_ENV !== "production") {
|
|
8884
8662
|
window.__PUCK_INTERNAL_DO_NOT_USE = { appStore };
|
|
8885
8663
|
}
|
|
8886
8664
|
}, [appStore]);
|
|
8887
|
-
(0,
|
|
8665
|
+
(0, import_react54.useEffect)(() => {
|
|
8888
8666
|
const state = appStore.getState().state;
|
|
8889
8667
|
appStore.setState(__spreadValues({}, generateAppStore(state)));
|
|
8890
8668
|
}, [config, plugins, loadedOverrides, viewports, iframe, onAction, metadata]);
|
|
@@ -8893,8 +8671,8 @@ function PuckProvider({ children }) {
|
|
|
8893
8671
|
index: initialHistoryIndex,
|
|
8894
8672
|
initialAppState
|
|
8895
8673
|
});
|
|
8896
|
-
const previousData = (0,
|
|
8897
|
-
(0,
|
|
8674
|
+
const previousData = (0, import_react54.useRef)(null);
|
|
8675
|
+
(0, import_react54.useEffect)(() => {
|
|
8898
8676
|
appStore.subscribe(
|
|
8899
8677
|
(s) => s.state.data,
|
|
8900
8678
|
(data) => {
|
|
@@ -8908,7 +8686,7 @@ function PuckProvider({ children }) {
|
|
|
8908
8686
|
}, []);
|
|
8909
8687
|
useRegisterPermissionsSlice(appStore, permissions);
|
|
8910
8688
|
const uPuckStore = useRegisterUsePuckStore(appStore);
|
|
8911
|
-
(0,
|
|
8689
|
+
(0, import_react54.useEffect)(() => {
|
|
8912
8690
|
const { resolveAndCommitData } = appStore.getState();
|
|
8913
8691
|
resolveAndCommitData();
|
|
8914
8692
|
}, []);
|
|
@@ -8920,7 +8698,7 @@ function PuckLayout({ children }) {
|
|
|
8920
8698
|
dnd,
|
|
8921
8699
|
initialHistory: _initialHistory
|
|
8922
8700
|
} = usePropsContext();
|
|
8923
|
-
const iframe = (0,
|
|
8701
|
+
const iframe = (0, import_react54.useMemo)(
|
|
8924
8702
|
() => __spreadValues({
|
|
8925
8703
|
enabled: true,
|
|
8926
8704
|
waitForStyles: true
|
|
@@ -8933,7 +8711,7 @@ function PuckLayout({ children }) {
|
|
|
8933
8711
|
(s) => s.state.ui.rightSideBarVisible
|
|
8934
8712
|
);
|
|
8935
8713
|
const dispatch = useAppStore((s) => s.dispatch);
|
|
8936
|
-
(0,
|
|
8714
|
+
(0, import_react54.useEffect)(() => {
|
|
8937
8715
|
if (!window.matchMedia("(min-width: 638px)").matches) {
|
|
8938
8716
|
dispatch({
|
|
8939
8717
|
type: "setUi",
|
|
@@ -8957,17 +8735,17 @@ function PuckLayout({ children }) {
|
|
|
8957
8735
|
};
|
|
8958
8736
|
}, []);
|
|
8959
8737
|
const overrides = useAppStore((s) => s.overrides);
|
|
8960
|
-
const CustomPuck = (0,
|
|
8738
|
+
const CustomPuck = (0, import_react54.useMemo)(
|
|
8961
8739
|
() => overrides.puck || DefaultOverride,
|
|
8962
8740
|
[overrides]
|
|
8963
8741
|
);
|
|
8964
|
-
const [mounted, setMounted] = (0,
|
|
8965
|
-
(0,
|
|
8742
|
+
const [mounted, setMounted] = (0, import_react54.useState)(false);
|
|
8743
|
+
(0, import_react54.useEffect)(() => {
|
|
8966
8744
|
setMounted(true);
|
|
8967
8745
|
}, []);
|
|
8968
8746
|
const ready = useAppStore((s) => s.status === "READY");
|
|
8969
8747
|
useMonitorHotkeys();
|
|
8970
|
-
(0,
|
|
8748
|
+
(0, import_react54.useEffect)(() => {
|
|
8971
8749
|
if (ready && iframe.enabled) {
|
|
8972
8750
|
const frameDoc = getFrame();
|
|
8973
8751
|
if (frameDoc) {
|
|
@@ -9006,6 +8784,230 @@ Puck.Components = Components;
|
|
|
9006
8784
|
Puck.Fields = Fields;
|
|
9007
8785
|
Puck.Outline = Outline;
|
|
9008
8786
|
Puck.Preview = Preview2;
|
|
8787
|
+
|
|
8788
|
+
// lib/migrate.ts
|
|
8789
|
+
init_react_import();
|
|
8790
|
+
var migrations = [
|
|
8791
|
+
// Migrate root to root.props
|
|
8792
|
+
(data) => {
|
|
8793
|
+
const rootProps = data.root.props || data.root;
|
|
8794
|
+
if (Object.keys(data.root).length > 0 && !data.root.props) {
|
|
8795
|
+
console.warn(
|
|
8796
|
+
"Migration applied: Root props moved from `root` to `root.props`."
|
|
8797
|
+
);
|
|
8798
|
+
return __spreadProps(__spreadValues({}, data), {
|
|
8799
|
+
root: {
|
|
8800
|
+
props: __spreadValues({}, rootProps)
|
|
8801
|
+
}
|
|
8802
|
+
});
|
|
8803
|
+
}
|
|
8804
|
+
return data;
|
|
8805
|
+
},
|
|
8806
|
+
// Migrate zones to slots
|
|
8807
|
+
(data, config, migrationOptions) => {
|
|
8808
|
+
var _a, _b;
|
|
8809
|
+
if (!config) return data;
|
|
8810
|
+
console.log("Migrating DropZones to slots...");
|
|
8811
|
+
const updatedItems = {};
|
|
8812
|
+
const appState = __spreadProps(__spreadValues({}, defaultAppState), { data });
|
|
8813
|
+
const { indexes } = walkAppState(appState, config);
|
|
8814
|
+
const deletedCompounds = [];
|
|
8815
|
+
walkAppState(appState, config, (content, zoneCompound, zoneType) => {
|
|
8816
|
+
var _a2, _b2, _c;
|
|
8817
|
+
if (zoneType === "dropzone") {
|
|
8818
|
+
const [id, slotName] = zoneCompound.split(":");
|
|
8819
|
+
const nodeData = indexes.nodes[id].data;
|
|
8820
|
+
const componentType = nodeData.type;
|
|
8821
|
+
const configForComponent = id === "root" ? config.root : config.components[componentType];
|
|
8822
|
+
if (((_b2 = (_a2 = configForComponent == null ? void 0 : configForComponent.fields) == null ? void 0 : _a2[slotName]) == null ? void 0 : _b2.type) === "slot") {
|
|
8823
|
+
updatedItems[id] = __spreadProps(__spreadValues({}, nodeData), {
|
|
8824
|
+
props: __spreadProps(__spreadValues(__spreadValues({}, nodeData.props), (_c = updatedItems[id]) == null ? void 0 : _c.props), {
|
|
8825
|
+
[slotName]: content
|
|
8826
|
+
})
|
|
8827
|
+
});
|
|
8828
|
+
deletedCompounds.push(zoneCompound);
|
|
8829
|
+
}
|
|
8830
|
+
return content;
|
|
8831
|
+
}
|
|
8832
|
+
return content;
|
|
8833
|
+
});
|
|
8834
|
+
const updated = walkAppState(
|
|
8835
|
+
appState,
|
|
8836
|
+
config,
|
|
8837
|
+
(content) => content,
|
|
8838
|
+
(item) => {
|
|
8839
|
+
var _a2;
|
|
8840
|
+
return (_a2 = updatedItems[item.props.id]) != null ? _a2 : item;
|
|
8841
|
+
}
|
|
8842
|
+
);
|
|
8843
|
+
deletedCompounds.forEach((zoneCompound) => {
|
|
8844
|
+
var _a2;
|
|
8845
|
+
const [_, propName] = zoneCompound.split(":");
|
|
8846
|
+
console.log(
|
|
8847
|
+
`\u2713 Success: Migrated "${zoneCompound}" from DropZone to slot field "${propName}"`
|
|
8848
|
+
);
|
|
8849
|
+
(_a2 = updated.data.zones) == null ? true : delete _a2[zoneCompound];
|
|
8850
|
+
});
|
|
8851
|
+
if (migrationOptions == null ? void 0 : migrationOptions.migrateDynamicZonesForComponent) {
|
|
8852
|
+
const unmigratedZonesGrouped = {};
|
|
8853
|
+
Object.keys((_a = updated.data.zones) != null ? _a : {}).forEach((zoneCompound) => {
|
|
8854
|
+
var _a2;
|
|
8855
|
+
const [componentId, propName] = zoneCompound.split(":");
|
|
8856
|
+
const content = (_a2 = updated.data.zones) == null ? void 0 : _a2[zoneCompound];
|
|
8857
|
+
if (!content) {
|
|
8858
|
+
return;
|
|
8859
|
+
}
|
|
8860
|
+
if (!unmigratedZonesGrouped[componentId]) {
|
|
8861
|
+
unmigratedZonesGrouped[componentId] = {};
|
|
8862
|
+
}
|
|
8863
|
+
if (!unmigratedZonesGrouped[componentId][propName]) {
|
|
8864
|
+
unmigratedZonesGrouped[componentId][propName] = content;
|
|
8865
|
+
}
|
|
8866
|
+
});
|
|
8867
|
+
Object.keys(unmigratedZonesGrouped).forEach((componentId) => {
|
|
8868
|
+
updated.data = walkTree(updated.data, config, (content) => {
|
|
8869
|
+
return content.map((child) => {
|
|
8870
|
+
var _a2;
|
|
8871
|
+
if (child.props.id !== componentId) {
|
|
8872
|
+
return child;
|
|
8873
|
+
}
|
|
8874
|
+
const migrateFn = (_a2 = migrationOptions == null ? void 0 : migrationOptions.migrateDynamicZonesForComponent) == null ? void 0 : _a2[child.type];
|
|
8875
|
+
if (!migrateFn) {
|
|
8876
|
+
return child;
|
|
8877
|
+
}
|
|
8878
|
+
const zones = unmigratedZonesGrouped[componentId];
|
|
8879
|
+
const migratedProps = migrateFn(child.props, zones);
|
|
8880
|
+
Object.keys(zones).forEach((propName) => {
|
|
8881
|
+
var _a3;
|
|
8882
|
+
const zoneCompound = `${componentId}:${propName}`;
|
|
8883
|
+
console.log(`\u2713 Success: Migrated "${zoneCompound}" DropZone`);
|
|
8884
|
+
(_a3 = updated.data.zones) == null ? true : delete _a3[zoneCompound];
|
|
8885
|
+
});
|
|
8886
|
+
return __spreadProps(__spreadValues({}, child), {
|
|
8887
|
+
props: migratedProps
|
|
8888
|
+
});
|
|
8889
|
+
});
|
|
8890
|
+
});
|
|
8891
|
+
});
|
|
8892
|
+
}
|
|
8893
|
+
Object.keys((_b = updated.data.zones) != null ? _b : {}).forEach((zoneCompound) => {
|
|
8894
|
+
const [_, propName] = zoneCompound.split(":");
|
|
8895
|
+
throw new Error(
|
|
8896
|
+
`Could not migrate DropZone "${zoneCompound}" to slot field. No slot exists with the name "${propName}".`
|
|
8897
|
+
);
|
|
8898
|
+
});
|
|
8899
|
+
delete updated.data.zones;
|
|
8900
|
+
return updated.data;
|
|
8901
|
+
}
|
|
8902
|
+
];
|
|
8903
|
+
function migrate(data, config, migrationOptions) {
|
|
8904
|
+
return migrations == null ? void 0 : migrations.reduce(
|
|
8905
|
+
(acc, migration) => migration(acc, config, migrationOptions),
|
|
8906
|
+
data
|
|
8907
|
+
);
|
|
8908
|
+
}
|
|
8909
|
+
|
|
8910
|
+
// lib/transform-props.ts
|
|
8911
|
+
init_react_import();
|
|
8912
|
+
|
|
8913
|
+
// lib/data/default-data.ts
|
|
8914
|
+
init_react_import();
|
|
8915
|
+
var defaultData = (data) => __spreadProps(__spreadValues({}, data), {
|
|
8916
|
+
root: data.root || {},
|
|
8917
|
+
content: data.content || []
|
|
8918
|
+
});
|
|
8919
|
+
|
|
8920
|
+
// lib/transform-props.ts
|
|
8921
|
+
function transformProps(data, propTransforms, config = { components: {} }) {
|
|
8922
|
+
const mapItem = (item) => {
|
|
8923
|
+
if (propTransforms[item.type]) {
|
|
8924
|
+
return __spreadProps(__spreadValues({}, item), {
|
|
8925
|
+
props: __spreadValues({
|
|
8926
|
+
id: item.props.id
|
|
8927
|
+
}, propTransforms[item.type](item.props))
|
|
8928
|
+
});
|
|
8929
|
+
}
|
|
8930
|
+
return item;
|
|
8931
|
+
};
|
|
8932
|
+
const defaultedData = defaultData(data);
|
|
8933
|
+
const rootProps = defaultedData.root.props || defaultedData.root;
|
|
8934
|
+
let newRoot = __spreadValues({}, defaultedData.root);
|
|
8935
|
+
if (propTransforms["root"]) {
|
|
8936
|
+
newRoot.props = propTransforms["root"](rootProps);
|
|
8937
|
+
}
|
|
8938
|
+
const dataWithUpdatedRoot = __spreadProps(__spreadValues({}, defaultedData), { root: newRoot });
|
|
8939
|
+
const updatedData = walkTree(
|
|
8940
|
+
dataWithUpdatedRoot,
|
|
8941
|
+
config,
|
|
8942
|
+
(content) => content.map(mapItem)
|
|
8943
|
+
);
|
|
8944
|
+
if (!defaultedData.root.props) {
|
|
8945
|
+
updatedData.root = updatedData.root.props;
|
|
8946
|
+
}
|
|
8947
|
+
return updatedData;
|
|
8948
|
+
}
|
|
8949
|
+
|
|
8950
|
+
// lib/resolve-all-data.ts
|
|
8951
|
+
init_react_import();
|
|
8952
|
+
|
|
8953
|
+
// lib/data/to-component.ts
|
|
8954
|
+
init_react_import();
|
|
8955
|
+
var toComponent = (item) => {
|
|
8956
|
+
return "type" in item ? item : __spreadProps(__spreadValues({}, item), {
|
|
8957
|
+
props: __spreadProps(__spreadValues({}, item.props), { id: "root" }),
|
|
8958
|
+
type: "root"
|
|
8959
|
+
});
|
|
8960
|
+
};
|
|
8961
|
+
|
|
8962
|
+
// lib/resolve-all-data.ts
|
|
8963
|
+
function resolveAllData(_0, _1) {
|
|
8964
|
+
return __async(this, arguments, function* (data, config, metadata = {}, onResolveStart, onResolveEnd) {
|
|
8965
|
+
var _a;
|
|
8966
|
+
const defaultedData = defaultData(data);
|
|
8967
|
+
const resolveNode = (_node) => __async(this, null, function* () {
|
|
8968
|
+
const node = toComponent(_node);
|
|
8969
|
+
onResolveStart == null ? void 0 : onResolveStart(node);
|
|
8970
|
+
const resolved = (yield resolveComponentData(
|
|
8971
|
+
node,
|
|
8972
|
+
config,
|
|
8973
|
+
metadata,
|
|
8974
|
+
() => {
|
|
8975
|
+
},
|
|
8976
|
+
() => {
|
|
8977
|
+
},
|
|
8978
|
+
"force"
|
|
8979
|
+
)).node;
|
|
8980
|
+
const resolvedDeep = yield mapSlots(
|
|
8981
|
+
resolved,
|
|
8982
|
+
processContent,
|
|
8983
|
+
config
|
|
8984
|
+
);
|
|
8985
|
+
onResolveEnd == null ? void 0 : onResolveEnd(toComponent(resolvedDeep));
|
|
8986
|
+
return resolvedDeep;
|
|
8987
|
+
});
|
|
8988
|
+
const processContent = (content) => __async(this, null, function* () {
|
|
8989
|
+
return Promise.all(content.map(resolveNode));
|
|
8990
|
+
});
|
|
8991
|
+
const processZones = () => __async(this, null, function* () {
|
|
8992
|
+
var _a2;
|
|
8993
|
+
const zones = (_a2 = data.zones) != null ? _a2 : {};
|
|
8994
|
+
Object.entries(zones).forEach((_02) => __async(this, [_02], function* ([zoneKey, content]) {
|
|
8995
|
+
zones[zoneKey] = yield Promise.all(content.map(resolveNode));
|
|
8996
|
+
}));
|
|
8997
|
+
return zones;
|
|
8998
|
+
});
|
|
8999
|
+
const dynamic = {
|
|
9000
|
+
root: yield resolveNode(defaultedData.root),
|
|
9001
|
+
content: yield processContent(defaultedData.content),
|
|
9002
|
+
zones: yield processZones()
|
|
9003
|
+
};
|
|
9004
|
+
Object.keys((_a = defaultedData.zones) != null ? _a : {}).forEach((zoneKey) => __async(this, null, function* () {
|
|
9005
|
+
const content = defaultedData.zones[zoneKey];
|
|
9006
|
+
dynamic.zones[zoneKey] = yield processContent(content);
|
|
9007
|
+
}), {});
|
|
9008
|
+
return dynamic;
|
|
9009
|
+
});
|
|
9010
|
+
}
|
|
9009
9011
|
// Annotate the CommonJS export names for ESM import in node:
|
|
9010
9012
|
0 && (module.exports = {
|
|
9011
9013
|
Action,
|