@measured/puck 0.19.1-canary.85971053 → 0.19.1-canary.f9d3f0e9
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-AWVNXKQN.mjs → chunk-IM42S4YL.mjs} +251 -247
- package/dist/index.d.mts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +947 -925
- package/dist/index.mjs +21 -3
- package/dist/rsc.d.mts +2 -2
- package/dist/rsc.d.ts +2 -2
- package/dist/rsc.js +3 -2
- package/dist/rsc.mjs +1 -5
- package/dist/{walk-tree-DBd3aQ_5.d.mts → walk-tree-DrJNb8b-.d.mts} +2 -1
- package/dist/{walk-tree-DBd3aQ_5.d.ts → walk-tree-DrJNb8b-.d.ts} +2 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
@@ -167,7 +167,7 @@ __export(core_exports, {
|
|
167
167
|
IconButton: () => IconButton,
|
168
168
|
Label: () => Label,
|
169
169
|
Puck: () => Puck,
|
170
|
-
Render: () =>
|
170
|
+
Render: () => Render2,
|
171
171
|
createUsePuck: () => createUsePuck,
|
172
172
|
migrate: () => migrate,
|
173
173
|
overrideKeys: () => overrideKeys,
|
@@ -306,7 +306,7 @@ init_react_import();
|
|
306
306
|
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
307
|
|
308
308
|
// components/AutoField/index.tsx
|
309
|
-
var
|
309
|
+
var import_react24 = require("react");
|
310
310
|
|
311
311
|
// components/AutoField/fields/index.tsx
|
312
312
|
init_react_import();
|
@@ -766,7 +766,7 @@ var IconButton = ({
|
|
766
766
|
};
|
767
767
|
|
768
768
|
// components/AutoField/fields/ArrayField/index.tsx
|
769
|
-
var
|
769
|
+
var import_react16 = require("react");
|
770
770
|
|
771
771
|
// components/DragIcon/index.tsx
|
772
772
|
init_react_import();
|
@@ -970,7 +970,7 @@ function mapSlots(item, map, config, recurseSlots = false) {
|
|
970
970
|
|
971
971
|
// lib/data/flatten-node.ts
|
972
972
|
init_react_import();
|
973
|
-
var import_flat = require("flat");
|
973
|
+
var import_flat = __toESM(require("flat"));
|
974
974
|
|
975
975
|
// lib/data/strip-slots.ts
|
976
976
|
init_react_import();
|
@@ -979,13 +979,14 @@ var stripSlots = (data, config) => {
|
|
979
979
|
};
|
980
980
|
|
981
981
|
// lib/data/flatten-node.ts
|
982
|
+
var { flatten: flatten2, unflatten } = import_flat.default;
|
982
983
|
var flattenNode = (node, config) => {
|
983
984
|
return __spreadProps(__spreadValues({}, node), {
|
984
|
-
props: (
|
985
|
+
props: flatten2(stripSlots(node, config).props)
|
985
986
|
});
|
986
987
|
};
|
987
988
|
var expandNode = (node) => {
|
988
|
-
const props =
|
989
|
+
const props = unflatten(node.props);
|
989
990
|
return __spreadProps(__spreadValues({}, node), {
|
990
991
|
props
|
991
992
|
});
|
@@ -1252,157 +1253,611 @@ function insertAction(state, action, appStore) {
|
|
1252
1253
|
|
1253
1254
|
// reducer/actions/replace.ts
|
1254
1255
|
init_react_import();
|
1255
|
-
var replaceAction = (state, action, appStore) => {
|
1256
|
-
const [parentId] = action.destinationZone.split(":");
|
1257
|
-
const idsInPath = getIdsForParent(action.destinationZone, state);
|
1258
|
-
const originalId = state.indexes.zones[action.destinationZone].contentIds[action.destinationIndex];
|
1259
|
-
const idChanged = originalId !== action.data.props.id;
|
1260
|
-
if (idChanged) {
|
1261
|
-
throw new Error(
|
1262
|
-
`Can't change the id during a replace action. Please us "remove" and "insert" to define a new node.`
|
1263
|
-
);
|
1264
|
-
}
|
1265
|
-
const data = populateIds(action.data, appStore.config);
|
1266
|
-
return walkAppState(
|
1267
|
-
state,
|
1268
|
-
appStore.config,
|
1269
|
-
(content, zoneCompound) => {
|
1270
|
-
const newContent = [...content];
|
1271
|
-
if (zoneCompound === action.destinationZone) {
|
1272
|
-
newContent[action.destinationIndex] = data;
|
1273
|
-
}
|
1274
|
-
return newContent;
|
1275
|
-
},
|
1276
|
-
(childItem, path) => {
|
1277
|
-
const pathIds = path.map((p) => p.split(":")[0]);
|
1278
|
-
if (childItem.props.id === data.props.id) {
|
1279
|
-
return data;
|
1280
|
-
} else if (childItem.props.id === parentId) {
|
1281
|
-
return childItem;
|
1282
|
-
} else if (idsInPath.indexOf(childItem.props.id) > -1) {
|
1283
|
-
return childItem;
|
1284
|
-
} else if (pathIds.indexOf(data.props.id) > -1) {
|
1285
|
-
return childItem;
|
1286
|
-
}
|
1287
|
-
return null;
|
1288
|
-
}
|
1289
|
-
);
|
1290
|
-
};
|
1291
1256
|
|
1292
|
-
//
|
1257
|
+
// rsc.tsx
|
1293
1258
|
init_react_import();
|
1294
|
-
var replaceRootAction = (state, action, appStore) => {
|
1295
|
-
return walkAppState(
|
1296
|
-
state,
|
1297
|
-
appStore.config,
|
1298
|
-
(content) => content,
|
1299
|
-
(childItem) => {
|
1300
|
-
if (childItem.props.id === "root") {
|
1301
|
-
return __spreadProps(__spreadValues({}, childItem), {
|
1302
|
-
props: __spreadValues(__spreadValues({}, childItem.props), action.root.props),
|
1303
|
-
readOnly: action.root.readOnly
|
1304
|
-
});
|
1305
|
-
}
|
1306
|
-
return childItem;
|
1307
|
-
}
|
1308
|
-
);
|
1309
|
-
};
|
1310
1259
|
|
1311
|
-
//
|
1260
|
+
// components/ServerRender/index.tsx
|
1312
1261
|
init_react_import();
|
1313
1262
|
|
1314
|
-
// lib/data/
|
1263
|
+
// lib/data/setup-zone.ts
|
1315
1264
|
init_react_import();
|
1316
|
-
|
1317
|
-
|
1318
|
-
|
1319
|
-
|
1320
|
-
}
|
1265
|
+
var setupZone = (data, zoneKey) => {
|
1266
|
+
if (zoneKey === rootDroppableId) {
|
1267
|
+
return data;
|
1268
|
+
}
|
1269
|
+
const newData = __spreadProps(__spreadValues({}, data), {
|
1270
|
+
zones: data.zones ? __spreadValues({}, data.zones) : {}
|
1271
|
+
});
|
1272
|
+
newData.zones[zoneKey] = newData.zones[zoneKey] || [];
|
1273
|
+
return newData;
|
1274
|
+
};
|
1321
1275
|
|
1322
|
-
//
|
1323
|
-
|
1324
|
-
|
1325
|
-
|
1326
|
-
|
1276
|
+
// lib/use-slots.tsx
|
1277
|
+
init_react_import();
|
1278
|
+
var import_react5 = require("react");
|
1279
|
+
function useSlots(config, item, renderSlotEdit, renderSlotRender = renderSlotEdit, readOnly, forceReadOnly) {
|
1280
|
+
const slotProps = (0, import_react5.useMemo)(() => {
|
1281
|
+
const mapped = mapSlots(
|
1282
|
+
item,
|
1283
|
+
(content, _parentId, propName, field, propPath) => {
|
1284
|
+
const wildcardPath = propPath.replace(/\[\d+\]/g, "[*]");
|
1285
|
+
const isReadOnly = (readOnly == null ? void 0 : readOnly[propPath]) || (readOnly == null ? void 0 : readOnly[wildcardPath]) || forceReadOnly;
|
1286
|
+
const render = isReadOnly ? renderSlotRender : renderSlotEdit;
|
1287
|
+
const Slot = (dzProps) => render(__spreadProps(__spreadValues({
|
1288
|
+
allow: (field == null ? void 0 : field.type) === "slot" ? field.allow : [],
|
1289
|
+
disallow: (field == null ? void 0 : field.type) === "slot" ? field.disallow : []
|
1290
|
+
}, dzProps), {
|
1291
|
+
zone: propName,
|
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]
|
1327
1303
|
);
|
1328
|
-
|
1329
|
-
|
1330
|
-
|
1331
|
-
|
1304
|
+
return mergedProps;
|
1305
|
+
}
|
1306
|
+
|
1307
|
+
// components/SlotRender/server.tsx
|
1308
|
+
init_react_import();
|
1309
|
+
var import_react6 = require("react");
|
1310
|
+
var import_jsx_runtime5 = require("react/jsx-runtime");
|
1311
|
+
var SlotRenderPure = (props) => /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(SlotRender, __spreadValues({}, props));
|
1312
|
+
var Item = ({
|
1313
|
+
config,
|
1314
|
+
item,
|
1315
|
+
metadata
|
1316
|
+
}) => {
|
1317
|
+
const Component = config.components[item.type];
|
1318
|
+
const props = useSlots(config, item, (slotProps) => /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(SlotRenderPure, __spreadProps(__spreadValues({}, slotProps), { config, metadata })));
|
1319
|
+
return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
1320
|
+
Component.render,
|
1321
|
+
__spreadProps(__spreadValues({}, props), {
|
1322
|
+
puck: __spreadProps(__spreadValues({}, props.puck), {
|
1323
|
+
renderDropZone: DropZoneRender,
|
1324
|
+
metadata: metadata || {}
|
1325
|
+
})
|
1332
1326
|
})
|
1333
|
-
|
1334
|
-
|
1335
|
-
|
1336
|
-
|
1337
|
-
(
|
1338
|
-
if (
|
1339
|
-
return
|
1340
|
-
}
|
1341
|
-
return content;
|
1342
|
-
},
|
1343
|
-
(childItem, path, index) => {
|
1344
|
-
const zoneCompound = path[path.length - 1];
|
1345
|
-
const parents = path.map((p) => p.split(":")[0]);
|
1346
|
-
if (parents.indexOf(newItem.props.id) > -1) {
|
1347
|
-
return __spreadProps(__spreadValues({}, childItem), {
|
1348
|
-
props: __spreadProps(__spreadValues({}, childItem.props), {
|
1349
|
-
id: generateId(childItem.type)
|
1350
|
-
})
|
1351
|
-
});
|
1352
|
-
}
|
1353
|
-
if (zoneCompound === action.sourceZone && index === action.sourceIndex + 1) {
|
1354
|
-
return newItem;
|
1327
|
+
);
|
1328
|
+
};
|
1329
|
+
var SlotRender = (0, import_react6.forwardRef)(
|
1330
|
+
function SlotRenderInternal({ className, style, content, config, metadata }, ref) {
|
1331
|
+
return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", { className, style, ref, children: content.map((item) => {
|
1332
|
+
if (!config.components[item.type]) {
|
1333
|
+
return null;
|
1355
1334
|
}
|
1356
|
-
|
1357
|
-
|
1358
|
-
|
1335
|
+
return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
1336
|
+
Item,
|
1337
|
+
{
|
1338
|
+
config,
|
1339
|
+
item,
|
1340
|
+
metadata
|
1341
|
+
},
|
1342
|
+
item.props.id
|
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
|
1359
1383
|
}
|
1360
|
-
|
1384
|
+
});
|
1385
|
+
const renderItem = __spreadProps(__spreadValues({}, item), { props });
|
1386
|
+
const propsWithSlots = useSlots(config, renderItem, (props2) => /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(SlotRenderPure, __spreadProps(__spreadValues({}, props2), { config, metadata })));
|
1387
|
+
if (Component) {
|
1388
|
+
return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(Component.render, __spreadValues({}, propsWithSlots), renderItem.props.id);
|
1361
1389
|
}
|
1362
|
-
|
1363
|
-
|
1364
|
-
ui: __spreadProps(__spreadValues({}, modified.ui), {
|
1365
|
-
itemSelector: {
|
1366
|
-
index: action.sourceIndex + 1,
|
1367
|
-
zone: action.sourceZone
|
1368
|
-
}
|
1369
|
-
})
|
1370
|
-
});
|
1390
|
+
return null;
|
1391
|
+
}) });
|
1371
1392
|
}
|
1372
1393
|
|
1373
|
-
//
|
1394
|
+
// lib/resolve-all-data.ts
|
1374
1395
|
init_react_import();
|
1375
1396
|
|
1376
|
-
//
|
1397
|
+
// lib/resolve-component-data.ts
|
1377
1398
|
init_react_import();
|
1378
1399
|
|
1379
|
-
// lib/
|
1400
|
+
// lib/get-changed.ts
|
1380
1401
|
init_react_import();
|
1381
|
-
var
|
1382
|
-
|
1383
|
-
|
1384
|
-
|
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
|
+
}, {}) : {};
|
1385
1411
|
};
|
1386
1412
|
|
1387
|
-
//
|
1388
|
-
var
|
1389
|
-
|
1390
|
-
|
1391
|
-
|
1392
|
-
const
|
1393
|
-
|
1394
|
-
|
1395
|
-
)
|
1396
|
-
|
1397
|
-
|
1398
|
-
|
1399
|
-
|
1400
|
-
|
1401
|
-
|
1402
|
-
|
1403
|
-
|
1404
|
-
|
1405
|
-
|
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
|
1835
|
+
init_react_import();
|
1836
|
+
var remove = (list, index) => {
|
1837
|
+
const result = Array.from(list);
|
1838
|
+
result.splice(index, 1);
|
1839
|
+
return result;
|
1840
|
+
};
|
1841
|
+
|
1842
|
+
// reducer/actions/move.ts
|
1843
|
+
var moveAction = (state, action, appStore) => {
|
1844
|
+
if (action.sourceZone === action.destinationZone && action.sourceIndex === action.destinationIndex) {
|
1845
|
+
return state;
|
1846
|
+
}
|
1847
|
+
const item = getItem(
|
1848
|
+
{ zone: action.sourceZone, index: action.sourceIndex },
|
1849
|
+
state
|
1850
|
+
);
|
1851
|
+
if (!item) return state;
|
1852
|
+
const idsInSourcePath = getIdsForParent(action.sourceZone, state);
|
1853
|
+
const idsInDestinationPath = getIdsForParent(action.destinationZone, state);
|
1854
|
+
return walkAppState(
|
1855
|
+
state,
|
1856
|
+
appStore.config,
|
1857
|
+
(content, zoneCompound) => {
|
1858
|
+
if (zoneCompound === action.sourceZone && zoneCompound === action.destinationZone) {
|
1859
|
+
return insert(
|
1860
|
+
remove(content, action.sourceIndex),
|
1406
1861
|
action.destinationIndex,
|
1407
1862
|
item
|
1408
1863
|
);
|
@@ -1484,21 +1939,6 @@ var removeAction = (state, action, appStore) => {
|
|
1484
1939
|
|
1485
1940
|
// reducer/actions/register-zone.ts
|
1486
1941
|
init_react_import();
|
1487
|
-
|
1488
|
-
// lib/data/setup-zone.ts
|
1489
|
-
init_react_import();
|
1490
|
-
var setupZone = (data, zoneKey) => {
|
1491
|
-
if (zoneKey === rootDroppableId) {
|
1492
|
-
return data;
|
1493
|
-
}
|
1494
|
-
const newData = __spreadProps(__spreadValues({}, data), {
|
1495
|
-
zones: data.zones ? __spreadValues({}, data.zones) : {}
|
1496
|
-
});
|
1497
|
-
newData.zones[zoneKey] = newData.zones[zoneKey] || [];
|
1498
|
-
return newData;
|
1499
|
-
};
|
1500
|
-
|
1501
|
-
// reducer/actions/register-zone.ts
|
1502
1942
|
var zoneCache = {};
|
1503
1943
|
function registerZoneAction(state, action) {
|
1504
1944
|
if (zoneCache[action.zone]) {
|
@@ -1651,26 +2091,18 @@ function createReducer({
|
|
1651
2091
|
);
|
1652
2092
|
}
|
1653
2093
|
|
1654
|
-
// components/ViewportControls/default-viewports.ts
|
1655
|
-
init_react_import();
|
1656
|
-
var defaultViewports = [
|
1657
|
-
{ width: 360, height: "auto", icon: "Smartphone", label: "Small" },
|
1658
|
-
{ width: 768, height: "auto", icon: "Tablet", label: "Medium" },
|
1659
|
-
{ width: 1280, height: "auto", icon: "Monitor", label: "Large" }
|
1660
|
-
];
|
1661
|
-
|
1662
2094
|
// store/index.ts
|
1663
2095
|
var import_zustand2 = require("zustand");
|
1664
2096
|
var import_middleware2 = require("zustand/middleware");
|
1665
|
-
var
|
2097
|
+
var import_react11 = require("react");
|
1666
2098
|
|
1667
2099
|
// store/slices/history.ts
|
1668
2100
|
init_react_import();
|
1669
|
-
var
|
2101
|
+
var import_react8 = require("react");
|
1670
2102
|
|
1671
2103
|
// lib/use-hotkey.ts
|
1672
2104
|
init_react_import();
|
1673
|
-
var
|
2105
|
+
var import_react7 = require("react");
|
1674
2106
|
var import_zustand = require("zustand");
|
1675
2107
|
var import_middleware = require("zustand/middleware");
|
1676
2108
|
var keyCodeMap = {
|
@@ -1756,10 +2188,10 @@ var monitorHotkeys = (doc) => {
|
|
1756
2188
|
};
|
1757
2189
|
};
|
1758
2190
|
var useMonitorHotkeys = () => {
|
1759
|
-
(0,
|
2191
|
+
(0, import_react7.useEffect)(() => monitorHotkeys(document), []);
|
1760
2192
|
};
|
1761
2193
|
var useHotkey = (combo, cb) => {
|
1762
|
-
(0,
|
2194
|
+
(0, import_react7.useEffect)(
|
1763
2195
|
() => useHotkeyStore.setState((s) => ({
|
1764
2196
|
triggers: __spreadProps(__spreadValues({}, s.triggers), {
|
1765
2197
|
[`${Object.keys(combo).join("+")}`]: { combo, cb }
|
@@ -1868,7 +2300,7 @@ function useRegisterHistorySlice(appStore, {
|
|
1868
2300
|
index,
|
1869
2301
|
initialAppState
|
1870
2302
|
}) {
|
1871
|
-
(0,
|
2303
|
+
(0, import_react8.useEffect)(
|
1872
2304
|
() => appStore.setState({
|
1873
2305
|
history: __spreadProps(__spreadValues({}, appStore.getState().history), {
|
1874
2306
|
histories,
|
@@ -1935,7 +2367,7 @@ var createNodesSlice = (set, get) => ({
|
|
1935
2367
|
|
1936
2368
|
// store/slices/permissions.ts
|
1937
2369
|
init_react_import();
|
1938
|
-
var
|
2370
|
+
var import_react9 = require("react");
|
1939
2371
|
|
1940
2372
|
// lib/data/flatten-data.ts
|
1941
2373
|
init_react_import();
|
@@ -1953,19 +2385,6 @@ var flattenData = (state, config) => {
|
|
1953
2385
|
return data;
|
1954
2386
|
};
|
1955
2387
|
|
1956
|
-
// lib/get-changed.ts
|
1957
|
-
init_react_import();
|
1958
|
-
var import_fast_deep_equal = __toESM(require("fast-deep-equal"));
|
1959
|
-
var getChanged = (newItem, oldItem) => {
|
1960
|
-
return newItem ? Object.keys(newItem.props || {}).reduce((acc, item) => {
|
1961
|
-
const newItemProps = (newItem == null ? void 0 : newItem.props) || {};
|
1962
|
-
const oldItemProps = (oldItem == null ? void 0 : oldItem.props) || {};
|
1963
|
-
return __spreadProps(__spreadValues({}, acc), {
|
1964
|
-
[item]: !(0, import_fast_deep_equal.default)(oldItemProps[item], newItemProps[item])
|
1965
|
-
});
|
1966
|
-
}, {}) : {};
|
1967
|
-
};
|
1968
|
-
|
1969
2388
|
// store/slices/permissions.ts
|
1970
2389
|
var createPermissionsSlice = (set, get) => {
|
1971
2390
|
const resolvePermissions = (..._0) => __async(void 0, [..._0], function* (params = {}, force) {
|
@@ -2072,7 +2491,7 @@ var createPermissionsSlice = (set, get) => {
|
|
2072
2491
|
};
|
2073
2492
|
};
|
2074
2493
|
var useRegisterPermissionsSlice = (appStore, globalPermissions) => {
|
2075
|
-
(0,
|
2494
|
+
(0, import_react9.useEffect)(() => {
|
2076
2495
|
const { permissions } = appStore.getState();
|
2077
2496
|
const { globalPermissions: existingGlobalPermissions } = permissions;
|
2078
2497
|
appStore.setState({
|
@@ -2082,7 +2501,7 @@ var useRegisterPermissionsSlice = (appStore, globalPermissions) => {
|
|
2082
2501
|
});
|
2083
2502
|
permissions.resolvePermissions();
|
2084
2503
|
}, [globalPermissions]);
|
2085
|
-
(0,
|
2504
|
+
(0, import_react9.useEffect)(() => {
|
2086
2505
|
return appStore.subscribe(
|
2087
2506
|
(s) => s.state.data,
|
2088
2507
|
() => {
|
@@ -2090,7 +2509,7 @@ var useRegisterPermissionsSlice = (appStore, globalPermissions) => {
|
|
2090
2509
|
}
|
2091
2510
|
);
|
2092
2511
|
}, []);
|
2093
|
-
(0,
|
2512
|
+
(0, import_react9.useEffect)(() => {
|
2094
2513
|
return appStore.subscribe(
|
2095
2514
|
(s) => s.config,
|
2096
2515
|
() => {
|
@@ -2102,7 +2521,7 @@ var useRegisterPermissionsSlice = (appStore, globalPermissions) => {
|
|
2102
2521
|
|
2103
2522
|
// store/slices/fields.ts
|
2104
2523
|
init_react_import();
|
2105
|
-
var
|
2524
|
+
var import_react10 = require("react");
|
2106
2525
|
var createFieldsSlice = (_set, _get) => {
|
2107
2526
|
return {
|
2108
2527
|
fields: {},
|
@@ -2112,7 +2531,7 @@ var createFieldsSlice = (_set, _get) => {
|
|
2112
2531
|
};
|
2113
2532
|
};
|
2114
2533
|
var useRegisterFieldsSlice = (appStore, id) => {
|
2115
|
-
const resolveFields = (0,
|
2534
|
+
const resolveFields = (0, import_react10.useCallback)(
|
2116
2535
|
(reset) => __async(void 0, null, function* () {
|
2117
2536
|
var _a, _b;
|
2118
2537
|
const { fields, lastResolvedData } = appStore.getState().fields;
|
@@ -2169,120 +2588,30 @@ var useRegisterFieldsSlice = (appStore, id) => {
|
|
2169
2588
|
}),
|
2170
2589
|
[id]
|
2171
2590
|
);
|
2172
|
-
(0,
|
2591
|
+
(0, import_react10.useEffect)(() => {
|
2173
2592
|
resolveFields(true);
|
2174
2593
|
return appStore.subscribe(
|
2175
2594
|
(s) => s.state.indexes.nodes[id || "root"],
|
2176
|
-
() => resolveFields()
|
2177
|
-
);
|
2178
|
-
}, [id]);
|
2179
|
-
};
|
2180
|
-
|
2181
|
-
// lib/
|
2182
|
-
init_react_import();
|
2183
|
-
var
|
2184
|
-
|
2185
|
-
|
2186
|
-
|
2187
|
-
const
|
2188
|
-
|
2189
|
-
|
2190
|
-
|
2191
|
-
|
2192
|
-
|
2193
|
-
|
2194
|
-
}
|
2195
|
-
const changed = getChanged(item, oldItem);
|
2196
|
-
if (onResolveStart) {
|
2197
|
-
onResolveStart(item);
|
2198
|
-
}
|
2199
|
-
const { props: resolvedProps, readOnly = {} } = yield configForItem.resolveData(item, {
|
2200
|
-
changed,
|
2201
|
-
lastData: oldItem,
|
2202
|
-
metadata: __spreadValues(__spreadValues({}, metadata), configForItem.metadata),
|
2203
|
-
trigger
|
2204
|
-
});
|
2205
|
-
resolvedItem.props = __spreadValues(__spreadValues({}, item.props), resolvedProps);
|
2206
|
-
if (Object.keys(readOnly).length) {
|
2207
|
-
resolvedItem.readOnly = readOnly;
|
2208
|
-
}
|
2209
|
-
}
|
2210
|
-
let itemWithResolvedChildren = yield mapSlots(
|
2211
|
-
resolvedItem,
|
2212
|
-
(content) => __async(void 0, null, function* () {
|
2213
|
-
return yield Promise.all(
|
2214
|
-
content.map(
|
2215
|
-
(childItem) => __async(void 0, null, function* () {
|
2216
|
-
return (yield resolveComponentData(
|
2217
|
-
childItem,
|
2218
|
-
config,
|
2219
|
-
metadata,
|
2220
|
-
onResolveStart,
|
2221
|
-
onResolveEnd,
|
2222
|
-
trigger
|
2223
|
-
)).node;
|
2224
|
-
})
|
2225
|
-
)
|
2226
|
-
);
|
2227
|
-
}),
|
2228
|
-
config
|
2229
|
-
);
|
2230
|
-
if (shouldRunResolver && onResolveEnd) {
|
2231
|
-
onResolveEnd(resolvedItem);
|
2232
|
-
}
|
2233
|
-
cache.lastChange[id] = {
|
2234
|
-
item,
|
2235
|
-
resolved: itemWithResolvedChildren
|
2236
|
-
};
|
2237
|
-
return {
|
2238
|
-
node: itemWithResolvedChildren,
|
2239
|
-
didChange: !(0, import_fast_deep_equal2.default)(item, itemWithResolvedChildren)
|
2240
|
-
};
|
2241
|
-
});
|
2242
|
-
|
2243
|
-
// lib/data/to-root.ts
|
2244
|
-
init_react_import();
|
2245
|
-
var toRoot = (item) => {
|
2246
|
-
if ("type" in item && item.type !== "root") {
|
2247
|
-
throw new Error("Converting non-root item to root.");
|
2248
|
-
}
|
2249
|
-
const { readOnly } = item;
|
2250
|
-
if (item.props) {
|
2251
|
-
if ("id" in item.props) {
|
2252
|
-
const _a = item.props, { id } = _a, props = __objRest(_a, ["id"]);
|
2253
|
-
return { props, readOnly };
|
2254
|
-
}
|
2255
|
-
return { props: item.props, readOnly };
|
2256
|
-
}
|
2257
|
-
return { props: {}, readOnly };
|
2258
|
-
};
|
2259
|
-
|
2260
|
-
// store/default-app-state.ts
|
2261
|
-
init_react_import();
|
2262
|
-
var defaultAppState = {
|
2263
|
-
data: { content: [], root: {}, zones: {} },
|
2264
|
-
ui: {
|
2265
|
-
leftSideBarVisible: true,
|
2266
|
-
rightSideBarVisible: true,
|
2267
|
-
arrayState: {},
|
2268
|
-
itemSelector: null,
|
2269
|
-
componentList: {},
|
2270
|
-
isDragging: false,
|
2271
|
-
previewMode: "edit",
|
2272
|
-
viewports: {
|
2273
|
-
current: {
|
2274
|
-
width: defaultViewports[0].width,
|
2275
|
-
height: defaultViewports[0].height || "auto"
|
2276
|
-
},
|
2277
|
-
options: [],
|
2278
|
-
controlsVisible: true
|
2279
|
-
},
|
2280
|
-
field: { focus: null }
|
2281
|
-
},
|
2282
|
-
indexes: {
|
2283
|
-
nodes: {},
|
2284
|
-
zones: {}
|
2595
|
+
() => resolveFields()
|
2596
|
+
);
|
2597
|
+
}, [id]);
|
2598
|
+
};
|
2599
|
+
|
2600
|
+
// lib/data/to-root.ts
|
2601
|
+
init_react_import();
|
2602
|
+
var toRoot = (item) => {
|
2603
|
+
if ("type" in item && item.type !== "root") {
|
2604
|
+
throw new Error("Converting non-root item to root.");
|
2605
|
+
}
|
2606
|
+
const { readOnly } = item;
|
2607
|
+
if (item.props) {
|
2608
|
+
if ("id" in item.props) {
|
2609
|
+
const _a = item.props, { id } = _a, props = __objRest(_a, ["id"]);
|
2610
|
+
return { props, readOnly };
|
2611
|
+
}
|
2612
|
+
return { props: item.props, readOnly };
|
2285
2613
|
}
|
2614
|
+
return { props: {}, readOnly };
|
2286
2615
|
};
|
2287
2616
|
|
2288
2617
|
// store/index.ts
|
@@ -2461,23 +2790,23 @@ var createAppStore = (initialAppStore) => (0, import_zustand2.create)()(
|
|
2461
2790
|
});
|
2462
2791
|
})
|
2463
2792
|
);
|
2464
|
-
var appStoreContext = (0,
|
2793
|
+
var appStoreContext = (0, import_react11.createContext)(createAppStore());
|
2465
2794
|
function useAppStore(selector) {
|
2466
|
-
const context = (0,
|
2795
|
+
const context = (0, import_react11.useContext)(appStoreContext);
|
2467
2796
|
return (0, import_zustand2.useStore)(context, selector);
|
2468
2797
|
}
|
2469
2798
|
function useAppStoreApi() {
|
2470
|
-
return (0,
|
2799
|
+
return (0, import_react11.useContext)(appStoreContext);
|
2471
2800
|
}
|
2472
2801
|
|
2473
2802
|
// components/Sortable/index.tsx
|
2474
2803
|
init_react_import();
|
2475
|
-
var
|
2804
|
+
var import_react14 = require("@dnd-kit/react");
|
2476
2805
|
|
2477
2806
|
// lib/dnd/use-sensors.ts
|
2478
2807
|
init_react_import();
|
2479
|
-
var
|
2480
|
-
var
|
2808
|
+
var import_react12 = require("react");
|
2809
|
+
var import_react13 = require("@dnd-kit/react");
|
2481
2810
|
var import_utilities = require("@dnd-kit/dom/utilities");
|
2482
2811
|
var touchDefault = { delay: { value: 200, tolerance: 10 } };
|
2483
2812
|
var otherDefault = {
|
@@ -2492,8 +2821,8 @@ var useSensors = ({
|
|
2492
2821
|
touch: touchDefault,
|
2493
2822
|
other: otherDefault
|
2494
2823
|
}) => {
|
2495
|
-
const [sensors] = (0,
|
2496
|
-
|
2824
|
+
const [sensors] = (0, import_react12.useState)(() => [
|
2825
|
+
import_react13.PointerSensor.configure({
|
2497
2826
|
activationConstraints(event, source) {
|
2498
2827
|
var _a;
|
2499
2828
|
const { pointerType, target } = event;
|
@@ -2828,7 +3157,7 @@ var createDynamicCollisionDetector = (dragAxis, midpointOffset = 0.05) => (input
|
|
2828
3157
|
|
2829
3158
|
// components/Sortable/index.tsx
|
2830
3159
|
var import_sortable = require("@dnd-kit/react/sortable");
|
2831
|
-
var
|
3160
|
+
var import_jsx_runtime7 = require("react/jsx-runtime");
|
2832
3161
|
var SortableProvider = ({
|
2833
3162
|
children,
|
2834
3163
|
onDragStart,
|
@@ -2838,8 +3167,8 @@ var SortableProvider = ({
|
|
2838
3167
|
const sensors = useSensors({
|
2839
3168
|
mouse: { distance: { value: 5 } }
|
2840
3169
|
});
|
2841
|
-
return /* @__PURE__ */ (0,
|
2842
|
-
|
3170
|
+
return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
|
3171
|
+
import_react14.DragDropProvider,
|
2843
3172
|
{
|
2844
3173
|
sensors,
|
2845
3174
|
onDragStart: (event) => {
|
@@ -2903,11 +3232,11 @@ var Sortable = ({
|
|
2903
3232
|
|
2904
3233
|
// components/AutoField/context.tsx
|
2905
3234
|
init_react_import();
|
2906
|
-
var
|
2907
|
-
var
|
2908
|
-
var NestedFieldContext = (0,
|
3235
|
+
var import_react15 = require("react");
|
3236
|
+
var import_jsx_runtime8 = require("react/jsx-runtime");
|
3237
|
+
var NestedFieldContext = (0, import_react15.createContext)({});
|
2909
3238
|
var useNestedFieldContext = () => {
|
2910
|
-
const context = (0,
|
3239
|
+
const context = (0, import_react15.useContext)(NestedFieldContext);
|
2911
3240
|
return __spreadProps(__spreadValues({}, context), {
|
2912
3241
|
readOnlyFields: context.readOnlyFields || {}
|
2913
3242
|
});
|
@@ -2921,7 +3250,7 @@ var NestedFieldProvider = ({
|
|
2921
3250
|
}) => {
|
2922
3251
|
const subPath = `${name}.${subName}`;
|
2923
3252
|
const wildcardSubPath = `${wildcardName}.${subName}`;
|
2924
|
-
const subReadOnlyFields = (0,
|
3253
|
+
const subReadOnlyFields = (0, import_react15.useMemo)(
|
2925
3254
|
() => Object.keys(readOnlyFields).reduce((acc, readOnlyKey) => {
|
2926
3255
|
const isLocal = readOnlyKey.indexOf(subPath) > -1 || readOnlyKey.indexOf(wildcardSubPath) > -1;
|
2927
3256
|
if (isLocal) {
|
@@ -2937,7 +3266,7 @@ var NestedFieldProvider = ({
|
|
2937
3266
|
}, {}),
|
2938
3267
|
[name, subName, wildcardName, readOnlyFields]
|
2939
3268
|
);
|
2940
|
-
return /* @__PURE__ */ (0,
|
3269
|
+
return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
|
2941
3270
|
NestedFieldContext.Provider,
|
2942
3271
|
{
|
2943
3272
|
value: { readOnlyFields: subReadOnlyFields, localName: subName },
|
@@ -2947,7 +3276,7 @@ var NestedFieldProvider = ({
|
|
2947
3276
|
};
|
2948
3277
|
|
2949
3278
|
// components/AutoField/fields/ArrayField/index.tsx
|
2950
|
-
var
|
3279
|
+
var import_jsx_runtime9 = require("react/jsx-runtime");
|
2951
3280
|
var getClassName5 = get_class_name_factory_default("ArrayField", styles_module_default3);
|
2952
3281
|
var getClassNameItem = get_class_name_factory_default("ArrayFieldItem", styles_module_default3);
|
2953
3282
|
var ArrayField = ({
|
@@ -2959,7 +3288,7 @@ var ArrayField = ({
|
|
2959
3288
|
labelIcon,
|
2960
3289
|
readOnly,
|
2961
3290
|
id,
|
2962
|
-
Label: Label2 = (props) => /* @__PURE__ */ (0,
|
3291
|
+
Label: Label2 = (props) => /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("div", __spreadValues({}, props))
|
2963
3292
|
}) => {
|
2964
3293
|
const thisArrayState = useAppStore((s) => s.state.ui.arrayState[id]);
|
2965
3294
|
const setUi = useAppStore((s) => s.setUi);
|
@@ -2974,14 +3303,14 @@ var ArrayField = ({
|
|
2974
3303
|
}),
|
2975
3304
|
openId: ""
|
2976
3305
|
};
|
2977
|
-
const [localState, setLocalState] = (0,
|
2978
|
-
(0,
|
3306
|
+
const [localState, setLocalState] = (0, import_react16.useState)({ arrayState, value });
|
3307
|
+
(0, import_react16.useEffect)(() => {
|
2979
3308
|
var _a;
|
2980
3309
|
const _arrayState = (_a = appStore.getState().state.ui.arrayState[id]) != null ? _a : arrayState;
|
2981
3310
|
setLocalState({ arrayState: _arrayState, value });
|
2982
3311
|
}, [value]);
|
2983
3312
|
const appStore = useAppStoreApi();
|
2984
|
-
const mapArrayStateToUi = (0,
|
3313
|
+
const mapArrayStateToUi = (0, import_react16.useCallback)(
|
2985
3314
|
(partialArrayState) => {
|
2986
3315
|
const state = appStore.getState().state;
|
2987
3316
|
return {
|
@@ -2992,13 +3321,13 @@ var ArrayField = ({
|
|
2992
3321
|
},
|
2993
3322
|
[arrayState, appStore]
|
2994
3323
|
);
|
2995
|
-
const getHighestIndex = (0,
|
3324
|
+
const getHighestIndex = (0, import_react16.useCallback)(() => {
|
2996
3325
|
return arrayState.items.reduce(
|
2997
3326
|
(acc, item) => item._originalIndex > acc ? item._originalIndex : acc,
|
2998
3327
|
-1
|
2999
3328
|
);
|
3000
3329
|
}, [arrayState]);
|
3001
|
-
const regenerateArrayState = (0,
|
3330
|
+
const regenerateArrayState = (0, import_react16.useCallback)(
|
3002
3331
|
(value2) => {
|
3003
3332
|
let highestIndex = getHighestIndex();
|
3004
3333
|
const newItems = Array.from(value2 || []).map((item, idx) => {
|
@@ -3017,19 +3346,19 @@ var ArrayField = ({
|
|
3017
3346
|
},
|
3018
3347
|
[arrayState]
|
3019
3348
|
);
|
3020
|
-
(0,
|
3349
|
+
(0, import_react16.useEffect)(() => {
|
3021
3350
|
if (arrayState.items.length > 0) {
|
3022
3351
|
setUi(mapArrayStateToUi(arrayState));
|
3023
3352
|
}
|
3024
3353
|
}, []);
|
3025
|
-
const [draggedItem, setDraggedItem] = (0,
|
3354
|
+
const [draggedItem, setDraggedItem] = (0, import_react16.useState)("");
|
3026
3355
|
const isDraggingAny = !!draggedItem;
|
3027
3356
|
const canEdit = useAppStore(
|
3028
3357
|
(s) => s.permissions.getPermissions({ item: s.selectedItem }).edit
|
3029
3358
|
);
|
3030
3359
|
const forceReadOnly = !canEdit;
|
3031
|
-
const valueRef = (0,
|
3032
|
-
const uniqifyItem = (0,
|
3360
|
+
const valueRef = (0, import_react16.useRef)(value);
|
3361
|
+
const uniqifyItem = (0, import_react16.useCallback)(
|
3033
3362
|
(val) => {
|
3034
3363
|
if (field.type !== "array" || !field.arrayFields) return;
|
3035
3364
|
const config = appStore.getState().config;
|
@@ -3046,14 +3375,14 @@ var ArrayField = ({
|
|
3046
3375
|
return null;
|
3047
3376
|
}
|
3048
3377
|
const addDisabled = field.max !== void 0 && localState.arrayState.items.length >= field.max || readOnly;
|
3049
|
-
return /* @__PURE__ */ (0,
|
3378
|
+
return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
|
3050
3379
|
Label2,
|
3051
3380
|
{
|
3052
3381
|
label: label || name,
|
3053
|
-
icon: labelIcon || /* @__PURE__ */ (0,
|
3382
|
+
icon: labelIcon || /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(List, { size: 16 }),
|
3054
3383
|
el: "div",
|
3055
3384
|
readOnly,
|
3056
|
-
children: /* @__PURE__ */ (0,
|
3385
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
|
3057
3386
|
SortableProvider,
|
3058
3387
|
{
|
3059
3388
|
onDragStart: (id2) => setDraggedItem(id2),
|
@@ -3084,7 +3413,7 @@ var ArrayField = ({
|
|
3084
3413
|
});
|
3085
3414
|
valueRef.current = newValue;
|
3086
3415
|
},
|
3087
|
-
children: /* @__PURE__ */ (0,
|
3416
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)(
|
3088
3417
|
"div",
|
3089
3418
|
{
|
3090
3419
|
className: getClassName5({
|
@@ -3092,16 +3421,16 @@ var ArrayField = ({
|
|
3092
3421
|
addDisabled
|
3093
3422
|
}),
|
3094
3423
|
children: [
|
3095
|
-
localState.arrayState.items.length > 0 && /* @__PURE__ */ (0,
|
3424
|
+
localState.arrayState.items.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("div", { className: getClassName5("inner"), "data-dnd-container": true, children: localState.arrayState.items.map((item, i) => {
|
3096
3425
|
const { _arrayId = `${id}-${i}`, _originalIndex = i } = item;
|
3097
3426
|
const data = Array.from(localState.value || [])[i] || {};
|
3098
|
-
return /* @__PURE__ */ (0,
|
3427
|
+
return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
|
3099
3428
|
Sortable,
|
3100
3429
|
{
|
3101
3430
|
id: _arrayId,
|
3102
3431
|
index: i,
|
3103
3432
|
disabled: readOnly,
|
3104
|
-
children: ({ isDragging, ref, handleRef }) => /* @__PURE__ */ (0,
|
3433
|
+
children: ({ isDragging, ref, handleRef }) => /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)(
|
3105
3434
|
"div",
|
3106
3435
|
{
|
3107
3436
|
ref,
|
@@ -3111,7 +3440,7 @@ var ArrayField = ({
|
|
3111
3440
|
readOnly
|
3112
3441
|
}),
|
3113
3442
|
children: [
|
3114
|
-
/* @__PURE__ */ (0,
|
3443
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.jsxs)(
|
3115
3444
|
"div",
|
3116
3445
|
{
|
3117
3446
|
ref: handleRef,
|
@@ -3136,9 +3465,9 @@ var ArrayField = ({
|
|
3136
3465
|
className: getClassNameItem("summary"),
|
3137
3466
|
children: [
|
3138
3467
|
field.getItemSummary ? field.getItemSummary(data, i) : `Item #${_originalIndex}`,
|
3139
|
-
/* @__PURE__ */ (0,
|
3140
|
-
!readOnly && /* @__PURE__ */ (0,
|
3141
|
-
/* @__PURE__ */ (0,
|
3468
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { className: getClassNameItem("rhs"), children: [
|
3469
|
+
!readOnly && /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { className: getClassNameItem("actions"), children: [
|
3470
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.jsx)("div", { className: getClassNameItem("action"), children: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
|
3142
3471
|
IconButton,
|
3143
3472
|
{
|
3144
3473
|
type: "button",
|
@@ -3157,10 +3486,10 @@ var ArrayField = ({
|
|
3157
3486
|
onChange(existingValue);
|
3158
3487
|
},
|
3159
3488
|
title: "Duplicate",
|
3160
|
-
children: /* @__PURE__ */ (0,
|
3489
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(Copy, { size: 16 })
|
3161
3490
|
}
|
3162
3491
|
) }),
|
3163
|
-
/* @__PURE__ */ (0,
|
3492
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.jsx)("div", { className: getClassNameItem("action"), children: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
|
3164
3493
|
IconButton,
|
3165
3494
|
{
|
3166
3495
|
type: "button",
|
@@ -3182,16 +3511,16 @@ var ArrayField = ({
|
|
3182
3511
|
onChange(existingValue);
|
3183
3512
|
},
|
3184
3513
|
title: "Delete",
|
3185
|
-
children: /* @__PURE__ */ (0,
|
3514
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(Trash, { size: 16 })
|
3186
3515
|
}
|
3187
3516
|
) })
|
3188
3517
|
] }),
|
3189
|
-
/* @__PURE__ */ (0,
|
3518
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.jsx)("div", { children: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(DragIcon, {}) })
|
3190
3519
|
] })
|
3191
3520
|
]
|
3192
3521
|
}
|
3193
3522
|
),
|
3194
|
-
/* @__PURE__ */ (0,
|
3523
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.jsx)("div", { className: getClassNameItem("body"), children: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("fieldset", { className: getClassNameItem("fieldset"), children: Object.keys(field.arrayFields).map((subName) => {
|
3195
3524
|
const subField = field.arrayFields[subName];
|
3196
3525
|
const indexName = `${name}[${i}]`;
|
3197
3526
|
const subPath = `${indexName}.${subName}`;
|
@@ -3201,14 +3530,14 @@ var ArrayField = ({
|
|
3201
3530
|
const localWildcardSubPath = `${localWildcardName}.${subName}`;
|
3202
3531
|
const subReadOnly = forceReadOnly ? forceReadOnly : typeof readOnlyFields[subPath] !== "undefined" ? readOnlyFields[localSubPath] : readOnlyFields[localWildcardSubPath];
|
3203
3532
|
const label2 = subField.label || subName;
|
3204
|
-
return /* @__PURE__ */ (0,
|
3533
|
+
return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
|
3205
3534
|
NestedFieldProvider,
|
3206
3535
|
{
|
3207
3536
|
name: localIndexName,
|
3208
3537
|
wildcardName: localWildcardName,
|
3209
3538
|
subName,
|
3210
3539
|
readOnlyFields,
|
3211
|
-
children: /* @__PURE__ */ (0,
|
3540
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
|
3212
3541
|
AutoFieldPrivate,
|
3213
3542
|
{
|
3214
3543
|
name: subPath,
|
@@ -3241,7 +3570,7 @@ var ArrayField = ({
|
|
3241
3570
|
_arrayId
|
3242
3571
|
);
|
3243
3572
|
}) }),
|
3244
|
-
!addDisabled && /* @__PURE__ */ (0,
|
3573
|
+
!addDisabled && /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
|
3245
3574
|
"button",
|
3246
3575
|
{
|
3247
3576
|
type: "button",
|
@@ -3259,7 +3588,7 @@ var ArrayField = ({
|
|
3259
3588
|
setUi(mapArrayStateToUi(newArrayState), false);
|
3260
3589
|
onChange(newValue);
|
3261
3590
|
},
|
3262
|
-
children: /* @__PURE__ */ (0,
|
3591
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(Plus, { size: 21 })
|
3263
3592
|
}
|
3264
3593
|
)
|
3265
3594
|
]
|
@@ -3273,7 +3602,7 @@ var ArrayField = ({
|
|
3273
3602
|
|
3274
3603
|
// components/AutoField/fields/DefaultField/index.tsx
|
3275
3604
|
init_react_import();
|
3276
|
-
var
|
3605
|
+
var import_jsx_runtime10 = require("react/jsx-runtime");
|
3277
3606
|
var getClassName6 = get_class_name_factory_default("Input", styles_module_default2);
|
3278
3607
|
var DefaultField = ({
|
3279
3608
|
field,
|
@@ -3287,16 +3616,16 @@ var DefaultField = ({
|
|
3287
3616
|
id
|
3288
3617
|
}) => {
|
3289
3618
|
const value = _value;
|
3290
|
-
return /* @__PURE__ */ (0,
|
3619
|
+
return /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
|
3291
3620
|
Label2,
|
3292
3621
|
{
|
3293
3622
|
label: label || name,
|
3294
|
-
icon: labelIcon || /* @__PURE__ */ (0,
|
3295
|
-
field.type === "text" && /* @__PURE__ */ (0,
|
3296
|
-
field.type === "number" && /* @__PURE__ */ (0,
|
3623
|
+
icon: labelIcon || /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)(import_jsx_runtime10.Fragment, { children: [
|
3624
|
+
field.type === "text" && /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(Type, { size: 16 }),
|
3625
|
+
field.type === "number" && /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(Hash, { size: 16 })
|
3297
3626
|
] }),
|
3298
3627
|
readOnly,
|
3299
|
-
children: /* @__PURE__ */ (0,
|
3628
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
|
3300
3629
|
"input",
|
3301
3630
|
{
|
3302
3631
|
className: getClassName6("input"),
|
@@ -3334,11 +3663,11 @@ var DefaultField = ({
|
|
3334
3663
|
|
3335
3664
|
// components/AutoField/fields/ExternalField/index.tsx
|
3336
3665
|
init_react_import();
|
3337
|
-
var
|
3666
|
+
var import_react20 = require("react");
|
3338
3667
|
|
3339
3668
|
// components/ExternalInput/index.tsx
|
3340
3669
|
init_react_import();
|
3341
|
-
var
|
3670
|
+
var import_react19 = require("react");
|
3342
3671
|
|
3343
3672
|
// css-module:/home/runner/work/puck/puck/packages/core/components/ExternalInput/styles.module.css#css-module
|
3344
3673
|
init_react_import();
|
@@ -3346,7 +3675,7 @@ var styles_module_default6 = { "ExternalInput-actions": "_ExternalInput-actions_
|
|
3346
3675
|
|
3347
3676
|
// components/Modal/index.tsx
|
3348
3677
|
init_react_import();
|
3349
|
-
var
|
3678
|
+
var import_react17 = require("react");
|
3350
3679
|
|
3351
3680
|
// css-module:/home/runner/work/puck/puck/packages/core/components/Modal/styles.module.css#css-module
|
3352
3681
|
init_react_import();
|
@@ -3354,22 +3683,22 @@ var styles_module_default7 = { "Modal": "_Modal_ikbaj_1", "Modal--isOpen": "_Mod
|
|
3354
3683
|
|
3355
3684
|
// components/Modal/index.tsx
|
3356
3685
|
var import_react_dom = require("react-dom");
|
3357
|
-
var
|
3686
|
+
var import_jsx_runtime11 = require("react/jsx-runtime");
|
3358
3687
|
var getClassName7 = get_class_name_factory_default("Modal", styles_module_default7);
|
3359
3688
|
var Modal = ({
|
3360
3689
|
children,
|
3361
3690
|
onClose,
|
3362
3691
|
isOpen
|
3363
3692
|
}) => {
|
3364
|
-
const [rootEl, setRootEl] = (0,
|
3365
|
-
(0,
|
3693
|
+
const [rootEl, setRootEl] = (0, import_react17.useState)(null);
|
3694
|
+
(0, import_react17.useEffect)(() => {
|
3366
3695
|
setRootEl(document.getElementById("puck-portal-root"));
|
3367
3696
|
}, []);
|
3368
3697
|
if (!rootEl) {
|
3369
|
-
return /* @__PURE__ */ (0,
|
3698
|
+
return /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("div", {});
|
3370
3699
|
}
|
3371
3700
|
return (0, import_react_dom.createPortal)(
|
3372
|
-
/* @__PURE__ */ (0,
|
3701
|
+
/* @__PURE__ */ (0, import_jsx_runtime11.jsx)("div", { className: getClassName7({ isOpen }), onClick: onClose, children: /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
|
3373
3702
|
"div",
|
3374
3703
|
{
|
3375
3704
|
className: getClassName7("inner"),
|
@@ -3389,11 +3718,11 @@ init_react_import();
|
|
3389
3718
|
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" };
|
3390
3719
|
|
3391
3720
|
// components/Heading/index.tsx
|
3392
|
-
var
|
3721
|
+
var import_jsx_runtime12 = require("react/jsx-runtime");
|
3393
3722
|
var getClassName8 = get_class_name_factory_default("Heading", styles_module_default8);
|
3394
3723
|
var Heading = ({ children, rank, size = "m" }) => {
|
3395
3724
|
const Tag = rank ? `h${rank}` : "span";
|
3396
|
-
return /* @__PURE__ */ (0,
|
3725
|
+
return /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
|
3397
3726
|
Tag,
|
3398
3727
|
{
|
3399
3728
|
className: getClassName8({
|
@@ -3409,7 +3738,7 @@ init_react_import();
|
|
3409
3738
|
|
3410
3739
|
// components/Button/Button.tsx
|
3411
3740
|
init_react_import();
|
3412
|
-
var
|
3741
|
+
var import_react18 = require("react");
|
3413
3742
|
|
3414
3743
|
// css-module:/home/runner/work/puck/puck/packages/core/components/Button/Button.module.css#css-module
|
3415
3744
|
init_react_import();
|
@@ -3429,7 +3758,7 @@ var filterDataAttrs = (props) => {
|
|
3429
3758
|
};
|
3430
3759
|
|
3431
3760
|
// components/Button/Button.tsx
|
3432
|
-
var
|
3761
|
+
var import_jsx_runtime13 = require("react/jsx-runtime");
|
3433
3762
|
var getClassName9 = get_class_name_factory_default("Button", Button_module_default);
|
3434
3763
|
var Button = (_a) => {
|
3435
3764
|
var _b = _a, {
|
@@ -3459,11 +3788,11 @@ var Button = (_a) => {
|
|
3459
3788
|
"size",
|
3460
3789
|
"loading"
|
3461
3790
|
]);
|
3462
|
-
const [loading, setLoading] = (0,
|
3463
|
-
(0,
|
3791
|
+
const [loading, setLoading] = (0, import_react18.useState)(loadingProp);
|
3792
|
+
(0, import_react18.useEffect)(() => setLoading(loadingProp), [loadingProp]);
|
3464
3793
|
const ElementType = href ? "a" : type ? "button" : "span";
|
3465
3794
|
const dataAttrs = filterDataAttrs(props);
|
3466
|
-
const el = /* @__PURE__ */ (0,
|
3795
|
+
const el = /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)(
|
3467
3796
|
ElementType,
|
3468
3797
|
__spreadProps(__spreadValues({
|
3469
3798
|
className: getClassName9({
|
@@ -3488,9 +3817,9 @@ var Button = (_a) => {
|
|
3488
3817
|
href
|
3489
3818
|
}, dataAttrs), {
|
3490
3819
|
children: [
|
3491
|
-
icon && /* @__PURE__ */ (0,
|
3820
|
+
icon && /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("div", { className: getClassName9("icon"), children: icon }),
|
3492
3821
|
children,
|
3493
|
-
loading && /* @__PURE__ */ (0,
|
3822
|
+
loading && /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("div", { className: getClassName9("spinner"), children: /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(Loader, { size: 14 }) })
|
3494
3823
|
]
|
3495
3824
|
})
|
3496
3825
|
);
|
@@ -3498,7 +3827,7 @@ var Button = (_a) => {
|
|
3498
3827
|
};
|
3499
3828
|
|
3500
3829
|
// components/ExternalInput/index.tsx
|
3501
|
-
var
|
3830
|
+
var import_jsx_runtime14 = require("react/jsx-runtime");
|
3502
3831
|
var getClassName10 = get_class_name_factory_default("ExternalInput", styles_module_default6);
|
3503
3832
|
var getClassNameModal = get_class_name_factory_default("ExternalInputModal", styles_module_default6);
|
3504
3833
|
var dataCache = {};
|
@@ -3515,28 +3844,28 @@ var ExternalInput = ({
|
|
3515
3844
|
mapRow = (val) => val,
|
3516
3845
|
filterFields
|
3517
3846
|
} = field || {};
|
3518
|
-
const [data, setData] = (0,
|
3519
|
-
const [isOpen, setOpen] = (0,
|
3520
|
-
const [isLoading, setIsLoading] = (0,
|
3847
|
+
const [data, setData] = (0, import_react19.useState)([]);
|
3848
|
+
const [isOpen, setOpen] = (0, import_react19.useState)(false);
|
3849
|
+
const [isLoading, setIsLoading] = (0, import_react19.useState)(true);
|
3521
3850
|
const hasFilterFields = !!filterFields;
|
3522
|
-
const [filters, setFilters] = (0,
|
3523
|
-
const [filtersToggled, setFiltersToggled] = (0,
|
3524
|
-
const mappedData = (0,
|
3851
|
+
const [filters, setFilters] = (0, import_react19.useState)(field.initialFilters || {});
|
3852
|
+
const [filtersToggled, setFiltersToggled] = (0, import_react19.useState)(hasFilterFields);
|
3853
|
+
const mappedData = (0, import_react19.useMemo)(() => {
|
3525
3854
|
return data.map(mapRow);
|
3526
3855
|
}, [data]);
|
3527
|
-
const keys = (0,
|
3856
|
+
const keys = (0, import_react19.useMemo)(() => {
|
3528
3857
|
const validKeys = /* @__PURE__ */ new Set();
|
3529
3858
|
for (const item of mappedData) {
|
3530
3859
|
for (const key of Object.keys(item)) {
|
3531
|
-
if (typeof item[key] === "string" || typeof item[key] === "number" || (0,
|
3860
|
+
if (typeof item[key] === "string" || typeof item[key] === "number" || (0, import_react19.isValidElement)(item[key])) {
|
3532
3861
|
validKeys.add(key);
|
3533
3862
|
}
|
3534
3863
|
}
|
3535
3864
|
}
|
3536
3865
|
return Array.from(validKeys);
|
3537
3866
|
}, [mappedData]);
|
3538
|
-
const [searchQuery, setSearchQuery] = (0,
|
3539
|
-
const search = (0,
|
3867
|
+
const [searchQuery, setSearchQuery] = (0, import_react19.useState)(field.initialQuery || "");
|
3868
|
+
const search = (0, import_react19.useCallback)(
|
3540
3869
|
(query, filters2) => __async(void 0, null, function* () {
|
3541
3870
|
setIsLoading(true);
|
3542
3871
|
const cacheKey = `${id}-${query}-${JSON.stringify(filters2)}`;
|
@@ -3549,18 +3878,18 @@ var ExternalInput = ({
|
|
3549
3878
|
}),
|
3550
3879
|
[id, field]
|
3551
3880
|
);
|
3552
|
-
const Footer = (0,
|
3553
|
-
(props) => field.renderFooter ? field.renderFooter(props) : /* @__PURE__ */ (0,
|
3881
|
+
const Footer = (0, import_react19.useCallback)(
|
3882
|
+
(props) => field.renderFooter ? field.renderFooter(props) : /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)("span", { className: getClassNameModal("footer"), children: [
|
3554
3883
|
props.items.length,
|
3555
3884
|
" result",
|
3556
3885
|
props.items.length === 1 ? "" : "s"
|
3557
3886
|
] }),
|
3558
3887
|
[field.renderFooter]
|
3559
3888
|
);
|
3560
|
-
(0,
|
3889
|
+
(0, import_react19.useEffect)(() => {
|
3561
3890
|
search(searchQuery, filters);
|
3562
3891
|
}, []);
|
3563
|
-
return /* @__PURE__ */ (0,
|
3892
|
+
return /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)(
|
3564
3893
|
"div",
|
3565
3894
|
{
|
3566
3895
|
className: getClassName10({
|
@@ -3570,21 +3899,21 @@ var ExternalInput = ({
|
|
3570
3899
|
}),
|
3571
3900
|
id,
|
3572
3901
|
children: [
|
3573
|
-
/* @__PURE__ */ (0,
|
3574
|
-
/* @__PURE__ */ (0,
|
3902
|
+
/* @__PURE__ */ (0, import_jsx_runtime14.jsxs)("div", { className: getClassName10("actions"), children: [
|
3903
|
+
/* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
|
3575
3904
|
"button",
|
3576
3905
|
{
|
3577
3906
|
type: "button",
|
3578
3907
|
onClick: () => setOpen(true),
|
3579
3908
|
className: getClassName10("button"),
|
3580
3909
|
disabled: readOnly,
|
3581
|
-
children: value ? field.getItemSummary ? field.getItemSummary(value) : "External item" : /* @__PURE__ */ (0,
|
3582
|
-
/* @__PURE__ */ (0,
|
3583
|
-
/* @__PURE__ */ (0,
|
3910
|
+
children: value ? field.getItemSummary ? field.getItemSummary(value) : "External item" : /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)(import_jsx_runtime14.Fragment, { children: [
|
3911
|
+
/* @__PURE__ */ (0, import_jsx_runtime14.jsx)(Link, { size: "16" }),
|
3912
|
+
/* @__PURE__ */ (0, import_jsx_runtime14.jsx)("span", { children: field.placeholder })
|
3584
3913
|
] })
|
3585
3914
|
}
|
3586
3915
|
),
|
3587
|
-
value && /* @__PURE__ */ (0,
|
3916
|
+
value && /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
|
3588
3917
|
"button",
|
3589
3918
|
{
|
3590
3919
|
type: "button",
|
@@ -3593,11 +3922,11 @@ var ExternalInput = ({
|
|
3593
3922
|
onChange(null);
|
3594
3923
|
},
|
3595
3924
|
disabled: readOnly,
|
3596
|
-
children: /* @__PURE__ */ (0,
|
3925
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(LockOpen, { size: 16 })
|
3597
3926
|
}
|
3598
3927
|
)
|
3599
3928
|
] }),
|
3600
|
-
/* @__PURE__ */ (0,
|
3929
|
+
/* @__PURE__ */ (0, import_jsx_runtime14.jsx)(Modal, { onClose: () => setOpen(false), isOpen, children: /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)(
|
3601
3930
|
"form",
|
3602
3931
|
{
|
3603
3932
|
className: getClassNameModal({
|
@@ -3611,11 +3940,11 @@ var ExternalInput = ({
|
|
3611
3940
|
search(searchQuery, filters);
|
3612
3941
|
},
|
3613
3942
|
children: [
|
3614
|
-
/* @__PURE__ */ (0,
|
3615
|
-
/* @__PURE__ */ (0,
|
3616
|
-
/* @__PURE__ */ (0,
|
3617
|
-
/* @__PURE__ */ (0,
|
3618
|
-
/* @__PURE__ */ (0,
|
3943
|
+
/* @__PURE__ */ (0, import_jsx_runtime14.jsx)("div", { className: getClassNameModal("masthead"), children: field.showSearch ? /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)("div", { className: getClassNameModal("searchForm"), children: [
|
3944
|
+
/* @__PURE__ */ (0, import_jsx_runtime14.jsxs)("label", { className: getClassNameModal("search"), children: [
|
3945
|
+
/* @__PURE__ */ (0, import_jsx_runtime14.jsx)("span", { className: getClassNameModal("searchIconText"), children: "Search" }),
|
3946
|
+
/* @__PURE__ */ (0, import_jsx_runtime14.jsx)("div", { className: getClassNameModal("searchIcon"), children: /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(Search, { size: "18" }) }),
|
3947
|
+
/* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
|
3619
3948
|
"input",
|
3620
3949
|
{
|
3621
3950
|
className: getClassNameModal("searchInput"),
|
@@ -3630,9 +3959,9 @@ var ExternalInput = ({
|
|
3630
3959
|
}
|
3631
3960
|
)
|
3632
3961
|
] }),
|
3633
|
-
/* @__PURE__ */ (0,
|
3634
|
-
/* @__PURE__ */ (0,
|
3635
|
-
hasFilterFields && /* @__PURE__ */ (0,
|
3962
|
+
/* @__PURE__ */ (0, import_jsx_runtime14.jsxs)("div", { className: getClassNameModal("searchActions"), children: [
|
3963
|
+
/* @__PURE__ */ (0, import_jsx_runtime14.jsx)(Button, { type: "submit", loading: isLoading, fullWidth: true, children: "Search" }),
|
3964
|
+
hasFilterFields && /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("div", { className: getClassNameModal("searchActionIcon"), children: /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
|
3636
3965
|
IconButton,
|
3637
3966
|
{
|
3638
3967
|
title: "Toggle filters",
|
@@ -3641,19 +3970,19 @@ var ExternalInput = ({
|
|
3641
3970
|
e.stopPropagation();
|
3642
3971
|
setFiltersToggled(!filtersToggled);
|
3643
3972
|
},
|
3644
|
-
children: /* @__PURE__ */ (0,
|
3973
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(SlidersHorizontal, { size: 20 })
|
3645
3974
|
}
|
3646
3975
|
) })
|
3647
3976
|
] })
|
3648
|
-
] }) : /* @__PURE__ */ (0,
|
3649
|
-
/* @__PURE__ */ (0,
|
3650
|
-
hasFilterFields && /* @__PURE__ */ (0,
|
3977
|
+
] }) : /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(Heading, { rank: "2", size: "xs", children: field.placeholder || "Select data" }) }),
|
3978
|
+
/* @__PURE__ */ (0, import_jsx_runtime14.jsxs)("div", { className: getClassNameModal("grid"), children: [
|
3979
|
+
hasFilterFields && /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("div", { className: getClassNameModal("filters"), children: hasFilterFields && Object.keys(filterFields).map((fieldName) => {
|
3651
3980
|
const filterField = filterFields[fieldName];
|
3652
|
-
return /* @__PURE__ */ (0,
|
3981
|
+
return /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
|
3653
3982
|
"div",
|
3654
3983
|
{
|
3655
3984
|
className: getClassNameModal("field"),
|
3656
|
-
children: /* @__PURE__ */ (0,
|
3985
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
|
3657
3986
|
AutoFieldPrivate,
|
3658
3987
|
{
|
3659
3988
|
field: filterField,
|
@@ -3674,9 +4003,9 @@ var ExternalInput = ({
|
|
3674
4003
|
fieldName
|
3675
4004
|
);
|
3676
4005
|
}) }),
|
3677
|
-
/* @__PURE__ */ (0,
|
3678
|
-
/* @__PURE__ */ (0,
|
3679
|
-
/* @__PURE__ */ (0,
|
4006
|
+
/* @__PURE__ */ (0, import_jsx_runtime14.jsxs)("div", { className: getClassNameModal("tableWrapper"), children: [
|
4007
|
+
/* @__PURE__ */ (0, import_jsx_runtime14.jsxs)("table", { className: getClassNameModal("table"), children: [
|
4008
|
+
/* @__PURE__ */ (0, import_jsx_runtime14.jsx)("thead", { className: getClassNameModal("thead"), children: /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("tr", { className: getClassNameModal("tr"), children: keys.map((key) => /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
|
3680
4009
|
"th",
|
3681
4010
|
{
|
3682
4011
|
className: getClassNameModal("th"),
|
@@ -3685,8 +4014,8 @@ var ExternalInput = ({
|
|
3685
4014
|
},
|
3686
4015
|
key
|
3687
4016
|
)) }) }),
|
3688
|
-
/* @__PURE__ */ (0,
|
3689
|
-
return /* @__PURE__ */ (0,
|
4017
|
+
/* @__PURE__ */ (0, import_jsx_runtime14.jsx)("tbody", { className: getClassNameModal("tbody"), children: mappedData.map((item, i) => {
|
4018
|
+
return /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
|
3690
4019
|
"tr",
|
3691
4020
|
{
|
3692
4021
|
style: { whiteSpace: "nowrap" },
|
@@ -3695,16 +4024,16 @@ var ExternalInput = ({
|
|
3695
4024
|
onChange(mapProp(data[i]));
|
3696
4025
|
setOpen(false);
|
3697
4026
|
},
|
3698
|
-
children: keys.map((key) => /* @__PURE__ */ (0,
|
4027
|
+
children: keys.map((key) => /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("td", { className: getClassNameModal("td"), children: item[key] }, key))
|
3699
4028
|
},
|
3700
4029
|
i
|
3701
4030
|
);
|
3702
4031
|
}) })
|
3703
4032
|
] }),
|
3704
|
-
/* @__PURE__ */ (0,
|
4033
|
+
/* @__PURE__ */ (0, import_jsx_runtime14.jsx)("div", { className: getClassNameModal("loadingBanner"), children: /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(Loader, { size: 24 }) })
|
3705
4034
|
] })
|
3706
4035
|
] }),
|
3707
|
-
/* @__PURE__ */ (0,
|
4036
|
+
/* @__PURE__ */ (0, import_jsx_runtime14.jsx)("div", { className: getClassNameModal("footerContainer"), children: /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(Footer, { items: mappedData }) })
|
3708
4037
|
]
|
3709
4038
|
}
|
3710
4039
|
) })
|
@@ -3714,7 +4043,7 @@ var ExternalInput = ({
|
|
3714
4043
|
};
|
3715
4044
|
|
3716
4045
|
// components/AutoField/fields/ExternalField/index.tsx
|
3717
|
-
var
|
4046
|
+
var import_jsx_runtime15 = require("react/jsx-runtime");
|
3718
4047
|
var ExternalField = ({
|
3719
4048
|
field,
|
3720
4049
|
onChange,
|
@@ -3729,7 +4058,7 @@ var ExternalField = ({
|
|
3729
4058
|
var _a, _b, _c;
|
3730
4059
|
const validField = field;
|
3731
4060
|
const deprecatedField = field;
|
3732
|
-
(0,
|
4061
|
+
(0, import_react20.useEffect)(() => {
|
3733
4062
|
if (deprecatedField.adaptor) {
|
3734
4063
|
console.error(
|
3735
4064
|
"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."
|
@@ -3739,13 +4068,13 @@ var ExternalField = ({
|
|
3739
4068
|
if (field.type !== "external") {
|
3740
4069
|
return null;
|
3741
4070
|
}
|
3742
|
-
return /* @__PURE__ */ (0,
|
4071
|
+
return /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
|
3743
4072
|
Label2,
|
3744
4073
|
{
|
3745
4074
|
label: label || name,
|
3746
|
-
icon: labelIcon || /* @__PURE__ */ (0,
|
4075
|
+
icon: labelIcon || /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(Link, { size: 16 }),
|
3747
4076
|
el: "div",
|
3748
|
-
children: /* @__PURE__ */ (0,
|
4077
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
|
3749
4078
|
ExternalInput,
|
3750
4079
|
{
|
3751
4080
|
name,
|
@@ -3772,7 +4101,7 @@ var ExternalField = ({
|
|
3772
4101
|
|
3773
4102
|
// components/AutoField/fields/RadioField/index.tsx
|
3774
4103
|
init_react_import();
|
3775
|
-
var
|
4104
|
+
var import_react21 = require("react");
|
3776
4105
|
|
3777
4106
|
// lib/safe-json-parse.ts
|
3778
4107
|
init_react_import();
|
@@ -3786,7 +4115,7 @@ var safeJsonParse = (str) => {
|
|
3786
4115
|
};
|
3787
4116
|
|
3788
4117
|
// components/AutoField/fields/RadioField/index.tsx
|
3789
|
-
var
|
4118
|
+
var import_jsx_runtime16 = require("react/jsx-runtime");
|
3790
4119
|
var getClassName11 = get_class_name_factory_default("Input", styles_module_default2);
|
3791
4120
|
var RadioField = ({
|
3792
4121
|
field,
|
@@ -3799,26 +4128,26 @@ var RadioField = ({
|
|
3799
4128
|
labelIcon,
|
3800
4129
|
Label: Label2
|
3801
4130
|
}) => {
|
3802
|
-
const flatOptions = (0,
|
4131
|
+
const flatOptions = (0, import_react21.useMemo)(
|
3803
4132
|
() => field.type === "radio" ? field.options.map(({ value: value2 }) => value2) : [],
|
3804
4133
|
[field]
|
3805
4134
|
);
|
3806
4135
|
if (field.type !== "radio" || !field.options) {
|
3807
4136
|
return null;
|
3808
4137
|
}
|
3809
|
-
return /* @__PURE__ */ (0,
|
4138
|
+
return /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
|
3810
4139
|
Label2,
|
3811
4140
|
{
|
3812
|
-
icon: labelIcon || /* @__PURE__ */ (0,
|
4141
|
+
icon: labelIcon || /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(CircleCheckBig, { size: 16 }),
|
3813
4142
|
label: label || name,
|
3814
4143
|
readOnly,
|
3815
4144
|
el: "div",
|
3816
|
-
children: /* @__PURE__ */ (0,
|
4145
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime16.jsx)("div", { className: getClassName11("radioGroupItems"), id, children: field.options.map((option) => /* @__PURE__ */ (0, import_jsx_runtime16.jsxs)(
|
3817
4146
|
"label",
|
3818
4147
|
{
|
3819
4148
|
className: getClassName11("radio"),
|
3820
4149
|
children: [
|
3821
|
-
/* @__PURE__ */ (0,
|
4150
|
+
/* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
|
3822
4151
|
"input",
|
3823
4152
|
{
|
3824
4153
|
type: "radio",
|
@@ -3838,7 +4167,7 @@ var RadioField = ({
|
|
3838
4167
|
checked: value === option.value
|
3839
4168
|
}
|
3840
4169
|
),
|
3841
|
-
/* @__PURE__ */ (0,
|
4170
|
+
/* @__PURE__ */ (0, import_jsx_runtime16.jsx)("div", { className: getClassName11("radioInner"), children: option.label || option.value })
|
3842
4171
|
]
|
3843
4172
|
},
|
3844
4173
|
option.label + option.value
|
@@ -3849,8 +4178,8 @@ var RadioField = ({
|
|
3849
4178
|
|
3850
4179
|
// components/AutoField/fields/SelectField/index.tsx
|
3851
4180
|
init_react_import();
|
3852
|
-
var
|
3853
|
-
var
|
4181
|
+
var import_react22 = require("react");
|
4182
|
+
var import_jsx_runtime17 = require("react/jsx-runtime");
|
3854
4183
|
var getClassName12 = get_class_name_factory_default("Input", styles_module_default2);
|
3855
4184
|
var SelectField = ({
|
3856
4185
|
field,
|
@@ -3863,20 +4192,20 @@ var SelectField = ({
|
|
3863
4192
|
readOnly,
|
3864
4193
|
id
|
3865
4194
|
}) => {
|
3866
|
-
const flatOptions = (0,
|
4195
|
+
const flatOptions = (0, import_react22.useMemo)(
|
3867
4196
|
() => field.type === "select" ? field.options.map(({ value: value2 }) => value2) : [],
|
3868
4197
|
[field]
|
3869
4198
|
);
|
3870
4199
|
if (field.type !== "select" || !field.options) {
|
3871
4200
|
return null;
|
3872
4201
|
}
|
3873
|
-
return /* @__PURE__ */ (0,
|
4202
|
+
return /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
|
3874
4203
|
Label2,
|
3875
4204
|
{
|
3876
4205
|
label: label || name,
|
3877
|
-
icon: labelIcon || /* @__PURE__ */ (0,
|
4206
|
+
icon: labelIcon || /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(ChevronDown, { size: 16 }),
|
3878
4207
|
readOnly,
|
3879
|
-
children: /* @__PURE__ */ (0,
|
4208
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
|
3880
4209
|
"select",
|
3881
4210
|
{
|
3882
4211
|
id,
|
@@ -3893,7 +4222,7 @@ var SelectField = ({
|
|
3893
4222
|
}
|
3894
4223
|
},
|
3895
4224
|
value,
|
3896
|
-
children: field.options.map((option) => /* @__PURE__ */ (0,
|
4225
|
+
children: field.options.map((option) => /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
|
3897
4226
|
"option",
|
3898
4227
|
{
|
3899
4228
|
label: option.label,
|
@@ -3909,7 +4238,7 @@ var SelectField = ({
|
|
3909
4238
|
|
3910
4239
|
// components/AutoField/fields/TextareaField/index.tsx
|
3911
4240
|
init_react_import();
|
3912
|
-
var
|
4241
|
+
var import_jsx_runtime18 = require("react/jsx-runtime");
|
3913
4242
|
var getClassName13 = get_class_name_factory_default("Input", styles_module_default2);
|
3914
4243
|
var TextareaField = ({
|
3915
4244
|
field,
|
@@ -3922,13 +4251,13 @@ var TextareaField = ({
|
|
3922
4251
|
Label: Label2,
|
3923
4252
|
id
|
3924
4253
|
}) => {
|
3925
|
-
return /* @__PURE__ */ (0,
|
4254
|
+
return /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
|
3926
4255
|
Label2,
|
3927
4256
|
{
|
3928
4257
|
label: label || name,
|
3929
|
-
icon: labelIcon || /* @__PURE__ */ (0,
|
4258
|
+
icon: labelIcon || /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(Type, { size: 16 }),
|
3930
4259
|
readOnly,
|
3931
|
-
children: /* @__PURE__ */ (0,
|
4260
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
|
3932
4261
|
"textarea",
|
3933
4262
|
{
|
3934
4263
|
id,
|
@@ -3955,7 +4284,7 @@ init_react_import();
|
|
3955
4284
|
var styles_module_default9 = { "ObjectField": "_ObjectField_1ua3y_5", "ObjectField-fieldset": "_ObjectField-fieldset_1ua3y_13" };
|
3956
4285
|
|
3957
4286
|
// components/AutoField/fields/ObjectField/index.tsx
|
3958
|
-
var
|
4287
|
+
var import_jsx_runtime19 = require("react/jsx-runtime");
|
3959
4288
|
var getClassName14 = get_class_name_factory_default("ObjectField", styles_module_default9);
|
3960
4289
|
var ObjectField = ({
|
3961
4290
|
field,
|
@@ -3973,26 +4302,26 @@ var ObjectField = ({
|
|
3973
4302
|
return null;
|
3974
4303
|
}
|
3975
4304
|
const data = value || {};
|
3976
|
-
return /* @__PURE__ */ (0,
|
4305
|
+
return /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(
|
3977
4306
|
Label2,
|
3978
4307
|
{
|
3979
4308
|
label: label || name,
|
3980
|
-
icon: labelIcon || /* @__PURE__ */ (0,
|
4309
|
+
icon: labelIcon || /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(EllipsisVertical, { size: 16 }),
|
3981
4310
|
el: "div",
|
3982
4311
|
readOnly,
|
3983
|
-
children: /* @__PURE__ */ (0,
|
4312
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime19.jsx)("div", { className: getClassName14(), children: /* @__PURE__ */ (0, import_jsx_runtime19.jsx)("fieldset", { className: getClassName14("fieldset"), children: Object.keys(field.objectFields).map((subName) => {
|
3984
4313
|
const subField = field.objectFields[subName];
|
3985
4314
|
const subPath = `${name}.${subName}`;
|
3986
4315
|
const localSubPath = `${localName || name}.${subName}`;
|
3987
4316
|
const subReadOnly = readOnly ? readOnly : readOnlyFields[localSubPath];
|
3988
4317
|
const label2 = subField.label || subName;
|
3989
|
-
return /* @__PURE__ */ (0,
|
4318
|
+
return /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(
|
3990
4319
|
NestedFieldProvider,
|
3991
4320
|
{
|
3992
4321
|
name: localName || id,
|
3993
4322
|
subName,
|
3994
4323
|
readOnlyFields,
|
3995
|
-
children: /* @__PURE__ */ (0,
|
4324
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(
|
3996
4325
|
AutoFieldPrivate,
|
3997
4326
|
{
|
3998
4327
|
name: subPath,
|
@@ -4024,17 +4353,17 @@ var ObjectField = ({
|
|
4024
4353
|
|
4025
4354
|
// lib/use-safe-id.ts
|
4026
4355
|
init_react_import();
|
4027
|
-
var
|
4356
|
+
var import_react23 = __toESM(require("react"));
|
4028
4357
|
var useSafeId = () => {
|
4029
|
-
if (typeof
|
4030
|
-
return
|
4358
|
+
if (typeof import_react23.default.useId !== "undefined") {
|
4359
|
+
return import_react23.default.useId();
|
4031
4360
|
}
|
4032
|
-
const [id] = (0,
|
4361
|
+
const [id] = (0, import_react23.useState)(generateId());
|
4033
4362
|
return id;
|
4034
4363
|
};
|
4035
4364
|
|
4036
4365
|
// components/AutoField/index.tsx
|
4037
|
-
var
|
4366
|
+
var import_jsx_runtime20 = require("react/jsx-runtime");
|
4038
4367
|
var getClassName15 = get_class_name_factory_default("Input", styles_module_default2);
|
4039
4368
|
var getClassNameWrapper = get_class_name_factory_default("InputWrapper", styles_module_default2);
|
4040
4369
|
var FieldLabel = ({
|
@@ -4046,11 +4375,11 @@ var FieldLabel = ({
|
|
4046
4375
|
className
|
4047
4376
|
}) => {
|
4048
4377
|
const El = el;
|
4049
|
-
return /* @__PURE__ */ (0,
|
4050
|
-
/* @__PURE__ */ (0,
|
4051
|
-
icon ? /* @__PURE__ */ (0,
|
4378
|
+
return /* @__PURE__ */ (0, import_jsx_runtime20.jsxs)(El, { className, children: [
|
4379
|
+
/* @__PURE__ */ (0, import_jsx_runtime20.jsxs)("div", { className: getClassName15("label"), children: [
|
4380
|
+
icon ? /* @__PURE__ */ (0, import_jsx_runtime20.jsx)("div", { className: getClassName15("labelIcon"), children: icon }) : /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(import_jsx_runtime20.Fragment, {}),
|
4052
4381
|
label,
|
4053
|
-
readOnly && /* @__PURE__ */ (0,
|
4382
|
+
readOnly && /* @__PURE__ */ (0, import_jsx_runtime20.jsx)("div", { className: getClassName15("disabledIcon"), title: "Read-only", children: /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(Lock, { size: "12" }) })
|
4054
4383
|
] }),
|
4055
4384
|
children
|
4056
4385
|
] });
|
@@ -4063,14 +4392,14 @@ var FieldLabelInternal = ({
|
|
4063
4392
|
readOnly
|
4064
4393
|
}) => {
|
4065
4394
|
const overrides = useAppStore((s) => s.overrides);
|
4066
|
-
const Wrapper = (0,
|
4395
|
+
const Wrapper = (0, import_react24.useMemo)(
|
4067
4396
|
() => overrides.fieldLabel || FieldLabel,
|
4068
4397
|
[overrides]
|
4069
4398
|
);
|
4070
4399
|
if (!label) {
|
4071
|
-
return /* @__PURE__ */ (0,
|
4400
|
+
return /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(import_jsx_runtime20.Fragment, { children });
|
4072
4401
|
}
|
4073
|
-
return /* @__PURE__ */ (0,
|
4402
|
+
return /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(
|
4074
4403
|
Wrapper,
|
4075
4404
|
{
|
4076
4405
|
label,
|
@@ -4090,7 +4419,7 @@ function AutoFieldInternal(props) {
|
|
4090
4419
|
var _a2;
|
4091
4420
|
return (_a2 = s.selectedItem) == null ? void 0 : _a2.readOnly;
|
4092
4421
|
});
|
4093
|
-
const nestedFieldContext = (0,
|
4422
|
+
const nestedFieldContext = (0, import_react24.useContext)(NestedFieldContext);
|
4094
4423
|
const { id, Label: Label2 = FieldLabelInternal } = props;
|
4095
4424
|
const field = props.field;
|
4096
4425
|
const label = field.label;
|
@@ -4124,7 +4453,7 @@ function AutoFieldInternal(props) {
|
|
4124
4453
|
Label: Label2,
|
4125
4454
|
id: resolvedId
|
4126
4455
|
});
|
4127
|
-
const onFocus = (0,
|
4456
|
+
const onFocus = (0, import_react24.useCallback)(
|
4128
4457
|
(e) => {
|
4129
4458
|
if (mergedProps.name && (e.target.nodeName === "INPUT" || e.target.nodeName === "TEXTAREA")) {
|
4130
4459
|
e.stopPropagation();
|
@@ -4138,7 +4467,7 @@ function AutoFieldInternal(props) {
|
|
4138
4467
|
},
|
4139
4468
|
[mergedProps.name]
|
4140
4469
|
);
|
4141
|
-
const onBlur = (0,
|
4470
|
+
const onBlur = (0, import_react24.useCallback)((e) => {
|
4142
4471
|
if ("name" in e.target) {
|
4143
4472
|
dispatch({
|
4144
4473
|
type: "setUi",
|
@@ -4160,18 +4489,18 @@ function AutoFieldInternal(props) {
|
|
4160
4489
|
return null;
|
4161
4490
|
}
|
4162
4491
|
const CustomField = field.render;
|
4163
|
-
return /* @__PURE__ */ (0,
|
4492
|
+
return /* @__PURE__ */ (0, import_jsx_runtime20.jsx)("div", { className: getClassNameWrapper(), onFocus, onBlur, children: /* @__PURE__ */ (0, import_jsx_runtime20.jsx)("div", { className: getClassName15(), children: /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(CustomField, __spreadValues({}, mergedProps)) }) });
|
4164
4493
|
}
|
4165
4494
|
const children = defaultFields[field.type](mergedProps);
|
4166
|
-
const
|
4167
|
-
return /* @__PURE__ */ (0,
|
4495
|
+
const Render3 = render[field.type];
|
4496
|
+
return /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(
|
4168
4497
|
NestedFieldContext.Provider,
|
4169
4498
|
{
|
4170
4499
|
value: {
|
4171
4500
|
readOnlyFields: nestedFieldContext.readOnlyFields || readOnly || {},
|
4172
4501
|
localName: nestedFieldContext.localName
|
4173
4502
|
},
|
4174
|
-
children: /* @__PURE__ */ (0,
|
4503
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(
|
4175
4504
|
"div",
|
4176
4505
|
{
|
4177
4506
|
className: getClassNameWrapper(),
|
@@ -4180,7 +4509,7 @@ function AutoFieldInternal(props) {
|
|
4180
4509
|
onClick: (e) => {
|
4181
4510
|
e.stopPropagation();
|
4182
4511
|
},
|
4183
|
-
children: /* @__PURE__ */ (0,
|
4512
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(Render3, __spreadProps(__spreadValues({}, mergedProps), { children }))
|
4184
4513
|
}
|
4185
4514
|
)
|
4186
4515
|
}
|
@@ -4189,20 +4518,20 @@ function AutoFieldInternal(props) {
|
|
4189
4518
|
function AutoFieldPrivate(props) {
|
4190
4519
|
const isFocused = useAppStore((s) => s.state.ui.field.focus === props.name);
|
4191
4520
|
const { value, onChange } = props;
|
4192
|
-
const [localValue, setLocalValue] = (0,
|
4193
|
-
const onChangeLocal = (0,
|
4521
|
+
const [localValue, setLocalValue] = (0, import_react24.useState)(value);
|
4522
|
+
const onChangeLocal = (0, import_react24.useCallback)(
|
4194
4523
|
(val, ui) => {
|
4195
4524
|
setLocalValue(val);
|
4196
4525
|
onChange(val, ui);
|
4197
4526
|
},
|
4198
4527
|
[onChange]
|
4199
4528
|
);
|
4200
|
-
(0,
|
4529
|
+
(0, import_react24.useEffect)(() => {
|
4201
4530
|
if (!isFocused) {
|
4202
4531
|
setLocalValue(value);
|
4203
4532
|
}
|
4204
4533
|
}, [value]);
|
4205
|
-
(0,
|
4534
|
+
(0, import_react24.useEffect)(() => {
|
4206
4535
|
if (!isFocused) {
|
4207
4536
|
if (value !== localValue) {
|
4208
4537
|
setLocalValue(value);
|
@@ -4213,11 +4542,11 @@ function AutoFieldPrivate(props) {
|
|
4213
4542
|
value: localValue,
|
4214
4543
|
onChange: onChangeLocal
|
4215
4544
|
};
|
4216
|
-
return /* @__PURE__ */ (0,
|
4545
|
+
return /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(AutoFieldInternal, __spreadValues(__spreadValues({}, props), localProps));
|
4217
4546
|
}
|
4218
4547
|
function AutoField(props) {
|
4219
|
-
const DefaultLabel = (0,
|
4220
|
-
const DefaultLabel2 = (labelProps) => /* @__PURE__ */ (0,
|
4548
|
+
const DefaultLabel = (0, import_react24.useMemo)(() => {
|
4549
|
+
const DefaultLabel2 = (labelProps) => /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(
|
4221
4550
|
"div",
|
4222
4551
|
__spreadProps(__spreadValues({}, labelProps), {
|
4223
4552
|
className: getClassName15({ readOnly: props.readOnly })
|
@@ -4228,7 +4557,7 @@ function AutoField(props) {
|
|
4228
4557
|
if (props.field.type === "slot") {
|
4229
4558
|
return null;
|
4230
4559
|
}
|
4231
|
-
return /* @__PURE__ */ (0,
|
4560
|
+
return /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(AutoFieldInternal, __spreadProps(__spreadValues({}, props), { Label: DefaultLabel }));
|
4232
4561
|
}
|
4233
4562
|
|
4234
4563
|
// components/Drawer/index.tsx
|
@@ -4253,7 +4582,7 @@ var import_react35 = require("react");
|
|
4253
4582
|
|
4254
4583
|
// components/DraggableComponent/index.tsx
|
4255
4584
|
init_react_import();
|
4256
|
-
var
|
4585
|
+
var import_react28 = require("react");
|
4257
4586
|
|
4258
4587
|
// css-module:/home/runner/work/puck/puck/packages/core/components/DraggableComponent/styles.module.css#css-module
|
4259
4588
|
init_react_import();
|
@@ -4283,11 +4612,11 @@ function getDeepScrollPosition(element) {
|
|
4283
4612
|
|
4284
4613
|
// components/DropZone/context.tsx
|
4285
4614
|
init_react_import();
|
4286
|
-
var
|
4615
|
+
var import_react25 = require("react");
|
4287
4616
|
var import_zustand3 = require("zustand");
|
4288
|
-
var
|
4289
|
-
var dropZoneContext = (0,
|
4290
|
-
var ZoneStoreContext = (0,
|
4617
|
+
var import_jsx_runtime21 = require("react/jsx-runtime");
|
4618
|
+
var dropZoneContext = (0, import_react25.createContext)(null);
|
4619
|
+
var ZoneStoreContext = (0, import_react25.createContext)(
|
4291
4620
|
(0, import_zustand3.createStore)(() => ({
|
4292
4621
|
zoneDepthIndex: {},
|
4293
4622
|
nextZoneDepthIndex: {},
|
@@ -4303,14 +4632,14 @@ var ZoneStoreProvider = ({
|
|
4303
4632
|
children,
|
4304
4633
|
store
|
4305
4634
|
}) => {
|
4306
|
-
return /* @__PURE__ */ (0,
|
4635
|
+
return /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(ZoneStoreContext.Provider, { value: store, children });
|
4307
4636
|
};
|
4308
4637
|
var DropZoneProvider = ({
|
4309
4638
|
children,
|
4310
4639
|
value
|
4311
4640
|
}) => {
|
4312
4641
|
const dispatch = useAppStore((s) => s.dispatch);
|
4313
|
-
const registerZone = (0,
|
4642
|
+
const registerZone = (0, import_react25.useCallback)(
|
4314
4643
|
(zoneCompound) => {
|
4315
4644
|
dispatch({
|
4316
4645
|
type: "registerZone",
|
@@ -4319,7 +4648,7 @@ var DropZoneProvider = ({
|
|
4319
4648
|
},
|
4320
4649
|
[dispatch]
|
4321
4650
|
);
|
4322
|
-
const unregisterZone = (0,
|
4651
|
+
const unregisterZone = (0, import_react25.useCallback)(
|
4323
4652
|
(zoneCompound) => {
|
4324
4653
|
dispatch({
|
4325
4654
|
type: "unregisterZone",
|
@@ -4328,14 +4657,14 @@ var DropZoneProvider = ({
|
|
4328
4657
|
},
|
4329
4658
|
[dispatch]
|
4330
4659
|
);
|
4331
|
-
const memoValue = (0,
|
4660
|
+
const memoValue = (0, import_react25.useMemo)(
|
4332
4661
|
() => __spreadValues({
|
4333
4662
|
registerZone,
|
4334
4663
|
unregisterZone
|
4335
4664
|
}, value),
|
4336
4665
|
[value]
|
4337
4666
|
);
|
4338
|
-
return /* @__PURE__ */ (0,
|
4667
|
+
return /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(import_jsx_runtime21.Fragment, { children: memoValue && /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(dropZoneContext.Provider, { value: memoValue, children }) });
|
4339
4668
|
};
|
4340
4669
|
|
4341
4670
|
// components/DraggableComponent/index.tsx
|
@@ -4359,11 +4688,11 @@ function accumulateTransform(el) {
|
|
4359
4688
|
|
4360
4689
|
// lib/use-context-store.ts
|
4361
4690
|
init_react_import();
|
4362
|
-
var
|
4691
|
+
var import_react26 = require("react");
|
4363
4692
|
var import_zustand4 = require("zustand");
|
4364
4693
|
var import_shallow = require("zustand/react/shallow");
|
4365
4694
|
function useContextStore(context, selector) {
|
4366
|
-
const store = (0,
|
4695
|
+
const store = (0, import_react26.useContext)(context);
|
4367
4696
|
if (!store) {
|
4368
4697
|
throw new Error("useContextStore must be used inside context");
|
4369
4698
|
}
|
@@ -4372,10 +4701,10 @@ function useContextStore(context, selector) {
|
|
4372
4701
|
|
4373
4702
|
// lib/dnd/use-on-drag-finished.ts
|
4374
4703
|
init_react_import();
|
4375
|
-
var
|
4704
|
+
var import_react27 = require("react");
|
4376
4705
|
var useOnDragFinished = (cb, deps = []) => {
|
4377
4706
|
const appStore = useAppStoreApi();
|
4378
|
-
return (0,
|
4707
|
+
return (0, import_react27.useCallback)(() => {
|
4379
4708
|
let dispose = () => {
|
4380
4709
|
};
|
4381
4710
|
const processDragging = (isDragging2) => {
|
@@ -4403,7 +4732,7 @@ var useOnDragFinished = (cb, deps = []) => {
|
|
4403
4732
|
};
|
4404
4733
|
|
4405
4734
|
// components/DraggableComponent/index.tsx
|
4406
|
-
var
|
4735
|
+
var import_jsx_runtime22 = require("react/jsx-runtime");
|
4407
4736
|
var getClassName16 = get_class_name_factory_default("DraggableComponent", styles_module_default11);
|
4408
4737
|
var DEBUG2 = false;
|
4409
4738
|
var space = 8;
|
@@ -4414,12 +4743,12 @@ var DefaultActionBar = ({
|
|
4414
4743
|
label,
|
4415
4744
|
children,
|
4416
4745
|
parentAction
|
4417
|
-
}) => /* @__PURE__ */ (0,
|
4418
|
-
/* @__PURE__ */ (0,
|
4746
|
+
}) => /* @__PURE__ */ (0, import_jsx_runtime22.jsxs)(ActionBar, { children: [
|
4747
|
+
/* @__PURE__ */ (0, import_jsx_runtime22.jsxs)(ActionBar.Group, { children: [
|
4419
4748
|
parentAction,
|
4420
|
-
label && /* @__PURE__ */ (0,
|
4749
|
+
label && /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(ActionBar.Label, { label })
|
4421
4750
|
] }),
|
4422
|
-
/* @__PURE__ */ (0,
|
4751
|
+
/* @__PURE__ */ (0, import_jsx_runtime22.jsx)(ActionBar.Group, { children })
|
4423
4752
|
] });
|
4424
4753
|
var DraggableComponent = ({
|
4425
4754
|
children,
|
@@ -4445,9 +4774,9 @@ var DraggableComponent = ({
|
|
4445
4774
|
const overrides = useAppStore((s) => s.overrides);
|
4446
4775
|
const dispatch = useAppStore((s) => s.dispatch);
|
4447
4776
|
const iframe = useAppStore((s) => s.iframe);
|
4448
|
-
const ctx = (0,
|
4449
|
-
const [localZones, setLocalZones] = (0,
|
4450
|
-
const registerLocalZone = (0,
|
4777
|
+
const ctx = (0, import_react28.useContext)(dropZoneContext);
|
4778
|
+
const [localZones, setLocalZones] = (0, import_react28.useState)({});
|
4779
|
+
const registerLocalZone = (0, import_react28.useCallback)(
|
4451
4780
|
(zoneCompound2, active) => {
|
4452
4781
|
var _a;
|
4453
4782
|
(_a = ctx == null ? void 0 : ctx.registerLocalZone) == null ? void 0 : _a.call(ctx, zoneCompound2, active);
|
@@ -4457,7 +4786,7 @@ var DraggableComponent = ({
|
|
4457
4786
|
},
|
4458
4787
|
[setLocalZones]
|
4459
4788
|
);
|
4460
|
-
const unregisterLocalZone = (0,
|
4789
|
+
const unregisterLocalZone = (0, import_react28.useCallback)(
|
4461
4790
|
(zoneCompound2) => {
|
4462
4791
|
var _a;
|
4463
4792
|
(_a = ctx == null ? void 0 : ctx.unregisterLocalZone) == null ? void 0 : _a.call(ctx, zoneCompound2);
|
@@ -4480,9 +4809,9 @@ var DraggableComponent = ({
|
|
4480
4809
|
return s.permissions.getPermissions({ item });
|
4481
4810
|
})
|
4482
4811
|
);
|
4483
|
-
const zoneStore = (0,
|
4484
|
-
const [dragAxis, setDragAxis] = (0,
|
4485
|
-
const dynamicCollisionDetector = (0,
|
4812
|
+
const zoneStore = (0, import_react28.useContext)(ZoneStoreContext);
|
4813
|
+
const [dragAxis, setDragAxis] = (0, import_react28.useState)(userDragAxis || autoDragAxis);
|
4814
|
+
const dynamicCollisionDetector = (0, import_react28.useMemo)(
|
4486
4815
|
() => createDynamicCollisionDetector(dragAxis),
|
4487
4816
|
[dragAxis]
|
4488
4817
|
);
|
@@ -4514,7 +4843,7 @@ var DraggableComponent = ({
|
|
4514
4843
|
},
|
4515
4844
|
feedback: "clone"
|
4516
4845
|
});
|
4517
|
-
(0,
|
4846
|
+
(0, import_react28.useEffect)(() => {
|
4518
4847
|
const isEnabled = zoneStore.getState().enabledIndex[zoneCompound];
|
4519
4848
|
sortable.droppable.disabled = !isEnabled;
|
4520
4849
|
sortable.draggable.disabled = !permissions.drag;
|
@@ -4531,8 +4860,8 @@ var DraggableComponent = ({
|
|
4531
4860
|
}
|
4532
4861
|
return cleanup;
|
4533
4862
|
}, [permissions.drag, zoneCompound]);
|
4534
|
-
const ref = (0,
|
4535
|
-
const refSetter = (0,
|
4863
|
+
const ref = (0, import_react28.useRef)(null);
|
4864
|
+
const refSetter = (0, import_react28.useCallback)(
|
4536
4865
|
(el) => {
|
4537
4866
|
sortableRef(el);
|
4538
4867
|
if (el) {
|
@@ -4541,14 +4870,14 @@ var DraggableComponent = ({
|
|
4541
4870
|
},
|
4542
4871
|
[sortableRef]
|
4543
4872
|
);
|
4544
|
-
const [portalEl, setPortalEl] = (0,
|
4545
|
-
(0,
|
4873
|
+
const [portalEl, setPortalEl] = (0, import_react28.useState)();
|
4874
|
+
(0, import_react28.useEffect)(() => {
|
4546
4875
|
var _a, _b, _c;
|
4547
4876
|
setPortalEl(
|
4548
4877
|
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
|
4549
4878
|
);
|
4550
4879
|
}, [iframe.enabled, ref.current]);
|
4551
|
-
const getStyle = (0,
|
4880
|
+
const getStyle = (0, import_react28.useCallback)(() => {
|
4552
4881
|
var _a, _b, _c;
|
4553
4882
|
if (!ref.current) return;
|
4554
4883
|
const rect = ref.current.getBoundingClientRect();
|
@@ -4573,11 +4902,11 @@ var DraggableComponent = ({
|
|
4573
4902
|
};
|
4574
4903
|
return style2;
|
4575
4904
|
}, [ref.current]);
|
4576
|
-
const [style, setStyle] = (0,
|
4577
|
-
const sync = (0,
|
4905
|
+
const [style, setStyle] = (0, import_react28.useState)();
|
4906
|
+
const sync = (0, import_react28.useCallback)(() => {
|
4578
4907
|
setStyle(getStyle());
|
4579
4908
|
}, [ref.current, iframe]);
|
4580
|
-
(0,
|
4909
|
+
(0, import_react28.useEffect)(() => {
|
4581
4910
|
if (ref.current) {
|
4582
4911
|
const observer = new ResizeObserver(sync);
|
4583
4912
|
observer.observe(ref.current);
|
@@ -4587,13 +4916,13 @@ var DraggableComponent = ({
|
|
4587
4916
|
}
|
4588
4917
|
}, [ref.current]);
|
4589
4918
|
const registerNode = useAppStore((s) => s.nodes.registerNode);
|
4590
|
-
const hideOverlay = (0,
|
4919
|
+
const hideOverlay = (0, import_react28.useCallback)(() => {
|
4591
4920
|
setIsVisible(false);
|
4592
4921
|
}, []);
|
4593
|
-
const showOverlay = (0,
|
4922
|
+
const showOverlay = (0, import_react28.useCallback)(() => {
|
4594
4923
|
setIsVisible(true);
|
4595
4924
|
}, []);
|
4596
|
-
(0,
|
4925
|
+
(0, import_react28.useEffect)(() => {
|
4597
4926
|
var _a;
|
4598
4927
|
registerNode(id, {
|
4599
4928
|
methods: { sync, showOverlay, hideOverlay },
|
@@ -4610,11 +4939,11 @@ var DraggableComponent = ({
|
|
4610
4939
|
});
|
4611
4940
|
};
|
4612
4941
|
}, [id, zoneCompound, index, componentType, sync]);
|
4613
|
-
const CustomActionBar = (0,
|
4942
|
+
const CustomActionBar = (0, import_react28.useMemo)(
|
4614
4943
|
() => overrides.actionBar || DefaultActionBar,
|
4615
4944
|
[overrides.actionBar]
|
4616
4945
|
);
|
4617
|
-
const onClick = (0,
|
4946
|
+
const onClick = (0, import_react28.useCallback)(
|
4618
4947
|
(e) => {
|
4619
4948
|
e.stopPropagation();
|
4620
4949
|
dispatch({
|
@@ -4627,7 +4956,7 @@ var DraggableComponent = ({
|
|
4627
4956
|
[index, zoneCompound, id]
|
4628
4957
|
);
|
4629
4958
|
const appStore = useAppStoreApi();
|
4630
|
-
const onSelectParent = (0,
|
4959
|
+
const onSelectParent = (0, import_react28.useCallback)(() => {
|
4631
4960
|
const { nodes, zones } = appStore.getState().state.indexes;
|
4632
4961
|
const node = nodes[id];
|
4633
4962
|
const parentNode = (node == null ? void 0 : node.parentId) ? nodes[node == null ? void 0 : node.parentId] : null;
|
@@ -4648,26 +4977,26 @@ var DraggableComponent = ({
|
|
4648
4977
|
}
|
4649
4978
|
});
|
4650
4979
|
}, [ctx, path]);
|
4651
|
-
const onDuplicate = (0,
|
4980
|
+
const onDuplicate = (0, import_react28.useCallback)(() => {
|
4652
4981
|
dispatch({
|
4653
4982
|
type: "duplicate",
|
4654
4983
|
sourceIndex: index,
|
4655
4984
|
sourceZone: zoneCompound
|
4656
4985
|
});
|
4657
4986
|
}, [index, zoneCompound]);
|
4658
|
-
const onDelete = (0,
|
4987
|
+
const onDelete = (0, import_react28.useCallback)(() => {
|
4659
4988
|
dispatch({
|
4660
4989
|
type: "remove",
|
4661
4990
|
index,
|
4662
4991
|
zone: zoneCompound
|
4663
4992
|
});
|
4664
4993
|
}, [index, zoneCompound]);
|
4665
|
-
const [hover, setHover] = (0,
|
4994
|
+
const [hover, setHover] = (0, import_react28.useState)(false);
|
4666
4995
|
const indicativeHover = useContextStore(
|
4667
4996
|
ZoneStoreContext,
|
4668
4997
|
(s) => s.hoveringComponent === id
|
4669
4998
|
);
|
4670
|
-
(0,
|
4999
|
+
(0, import_react28.useEffect)(() => {
|
4671
5000
|
if (!ref.current) {
|
4672
5001
|
return;
|
4673
5002
|
}
|
@@ -4711,10 +5040,10 @@ var DraggableComponent = ({
|
|
4711
5040
|
thisIsDragging,
|
4712
5041
|
inDroppableZone
|
4713
5042
|
]);
|
4714
|
-
const [isVisible, setIsVisible] = (0,
|
4715
|
-
const [dragFinished, setDragFinished] = (0,
|
4716
|
-
const [_, startTransition] = (0,
|
4717
|
-
(0,
|
5043
|
+
const [isVisible, setIsVisible] = (0, import_react28.useState)(false);
|
5044
|
+
const [dragFinished, setDragFinished] = (0, import_react28.useState)(true);
|
5045
|
+
const [_, startTransition] = (0, import_react28.useTransition)();
|
5046
|
+
(0, import_react28.useEffect)(() => {
|
4718
5047
|
startTransition(() => {
|
4719
5048
|
if (hover || indicativeHover || isSelected) {
|
4720
5049
|
sync();
|
@@ -4725,7 +5054,7 @@ var DraggableComponent = ({
|
|
4725
5054
|
}
|
4726
5055
|
});
|
4727
5056
|
}, [hover, indicativeHover, isSelected, iframe]);
|
4728
|
-
const [thisWasDragging, setThisWasDragging] = (0,
|
5057
|
+
const [thisWasDragging, setThisWasDragging] = (0, import_react28.useState)(false);
|
4729
5058
|
const onDragFinished = useOnDragFinished((finished) => {
|
4730
5059
|
if (finished) {
|
4731
5060
|
startTransition(() => {
|
@@ -4736,15 +5065,15 @@ var DraggableComponent = ({
|
|
4736
5065
|
setDragFinished(false);
|
4737
5066
|
}
|
4738
5067
|
});
|
4739
|
-
(0,
|
5068
|
+
(0, import_react28.useEffect)(() => {
|
4740
5069
|
if (thisIsDragging) {
|
4741
5070
|
setThisWasDragging(true);
|
4742
5071
|
}
|
4743
5072
|
}, [thisIsDragging]);
|
4744
|
-
(0,
|
5073
|
+
(0, import_react28.useEffect)(() => {
|
4745
5074
|
if (thisWasDragging) return onDragFinished();
|
4746
5075
|
}, [thisWasDragging, onDragFinished]);
|
4747
|
-
const syncActionsPosition = (0,
|
5076
|
+
const syncActionsPosition = (0, import_react28.useCallback)(
|
4748
5077
|
(el) => {
|
4749
5078
|
if (el) {
|
4750
5079
|
const view = el.ownerDocument.defaultView;
|
@@ -4769,7 +5098,7 @@ var DraggableComponent = ({
|
|
4769
5098
|
},
|
4770
5099
|
[zoom]
|
4771
5100
|
);
|
4772
|
-
(0,
|
5101
|
+
(0, import_react28.useEffect)(() => {
|
4773
5102
|
if (userDragAxis) {
|
4774
5103
|
setDragAxis(userDragAxis);
|
4775
5104
|
return;
|
@@ -4783,11 +5112,11 @@ var DraggableComponent = ({
|
|
4783
5112
|
}
|
4784
5113
|
setDragAxis(autoDragAxis);
|
4785
5114
|
}, [ref, userDragAxis, autoDragAxis]);
|
4786
|
-
const parentAction = (0,
|
4787
|
-
() => (ctx == null ? void 0 : ctx.areaId) && (ctx == null ? void 0 : ctx.areaId) !== "root" && /* @__PURE__ */ (0,
|
5115
|
+
const parentAction = (0, import_react28.useMemo)(
|
5116
|
+
() => (ctx == null ? void 0 : ctx.areaId) && (ctx == null ? void 0 : ctx.areaId) !== "root" && /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(ActionBar.Action, { onClick: onSelectParent, label: "Select parent", children: /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(CornerLeftUp, { size: 16 }) }),
|
4788
5117
|
[ctx == null ? void 0 : ctx.areaId]
|
4789
5118
|
);
|
4790
|
-
const nextContextValue = (0,
|
5119
|
+
const nextContextValue = (0, import_react28.useMemo)(
|
4791
5120
|
() => __spreadProps(__spreadValues({}, ctx), {
|
4792
5121
|
areaId: id,
|
4793
5122
|
zoneCompound,
|
@@ -4806,9 +5135,9 @@ var DraggableComponent = ({
|
|
4806
5135
|
unregisterLocalZone
|
4807
5136
|
]
|
4808
5137
|
);
|
4809
|
-
return /* @__PURE__ */ (0,
|
5138
|
+
return /* @__PURE__ */ (0, import_jsx_runtime22.jsxs)(DropZoneProvider, { value: nextContextValue, children: [
|
4810
5139
|
dragFinished && isVisible && (0, import_react_dom2.createPortal)(
|
4811
|
-
/* @__PURE__ */ (0,
|
5140
|
+
/* @__PURE__ */ (0, import_jsx_runtime22.jsxs)(
|
4812
5141
|
"div",
|
4813
5142
|
{
|
4814
5143
|
className: getClassName16({
|
@@ -4820,15 +5149,15 @@ var DraggableComponent = ({
|
|
4820
5149
|
"data-puck-overlay": true,
|
4821
5150
|
children: [
|
4822
5151
|
debug,
|
4823
|
-
isLoading && /* @__PURE__ */ (0,
|
4824
|
-
/* @__PURE__ */ (0,
|
5152
|
+
isLoading && /* @__PURE__ */ (0, import_jsx_runtime22.jsx)("div", { className: getClassName16("loadingOverlay"), children: /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(Loader, {}) }),
|
5153
|
+
/* @__PURE__ */ (0, import_jsx_runtime22.jsx)(
|
4825
5154
|
"div",
|
4826
5155
|
{
|
4827
5156
|
className: getClassName16("actionsOverlay"),
|
4828
5157
|
style: {
|
4829
5158
|
top: actionsOverlayTop / zoom
|
4830
5159
|
},
|
4831
|
-
children: /* @__PURE__ */ (0,
|
5160
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(
|
4832
5161
|
"div",
|
4833
5162
|
{
|
4834
5163
|
className: getClassName16("actions"),
|
@@ -4840,14 +5169,14 @@ var DraggableComponent = ({
|
|
4840
5169
|
paddingRight: actionsSide
|
4841
5170
|
},
|
4842
5171
|
ref: syncActionsPosition,
|
4843
|
-
children: /* @__PURE__ */ (0,
|
5172
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime22.jsxs)(
|
4844
5173
|
CustomActionBar,
|
4845
5174
|
{
|
4846
5175
|
parentAction,
|
4847
5176
|
label: DEBUG2 ? id : label,
|
4848
5177
|
children: [
|
4849
|
-
permissions.duplicate && /* @__PURE__ */ (0,
|
4850
|
-
permissions.delete && /* @__PURE__ */ (0,
|
5178
|
+
permissions.duplicate && /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(ActionBar.Action, { onClick: onDuplicate, label: "Duplicate", children: /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(Copy, { size: 16 }) }),
|
5179
|
+
permissions.delete && /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(ActionBar.Action, { onClick: onDelete, label: "Delete", children: /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(Trash, { size: 16 }) })
|
4851
5180
|
]
|
4852
5181
|
}
|
4853
5182
|
)
|
@@ -4855,7 +5184,7 @@ var DraggableComponent = ({
|
|
4855
5184
|
)
|
4856
5185
|
}
|
4857
5186
|
),
|
4858
|
-
/* @__PURE__ */ (0,
|
5187
|
+
/* @__PURE__ */ (0, import_jsx_runtime22.jsx)("div", { className: getClassName16("overlay") })
|
4859
5188
|
]
|
4860
5189
|
}
|
4861
5190
|
),
|
@@ -4874,7 +5203,7 @@ var import_react36 = require("@dnd-kit/react");
|
|
4874
5203
|
|
4875
5204
|
// components/DropZone/lib/use-min-empty-height.ts
|
4876
5205
|
init_react_import();
|
4877
|
-
var
|
5206
|
+
var import_react29 = require("react");
|
4878
5207
|
var getNumItems = (appStore, zoneCompound) => appStore.getState().state.indexes.zones[zoneCompound].contentIds.length;
|
4879
5208
|
var useMinEmptyHeight = ({
|
4880
5209
|
zoneCompound,
|
@@ -4882,8 +5211,8 @@ var useMinEmptyHeight = ({
|
|
4882
5211
|
ref
|
4883
5212
|
}) => {
|
4884
5213
|
const appStore = useAppStoreApi();
|
4885
|
-
const [prevHeight, setPrevHeight] = (0,
|
4886
|
-
const [isAnimating, setIsAnimating] = (0,
|
5214
|
+
const [prevHeight, setPrevHeight] = (0, import_react29.useState)(0);
|
5215
|
+
const [isAnimating, setIsAnimating] = (0, import_react29.useState)(false);
|
4887
5216
|
const { draggedItem, isZone } = useContextStore(ZoneStoreContext, (s) => {
|
4888
5217
|
var _a, _b;
|
4889
5218
|
return {
|
@@ -4891,7 +5220,7 @@ var useMinEmptyHeight = ({
|
|
4891
5220
|
isZone: ((_b = s.draggedItem) == null ? void 0 : _b.data.zone) === zoneCompound
|
4892
5221
|
};
|
4893
5222
|
});
|
4894
|
-
const numItems = (0,
|
5223
|
+
const numItems = (0, import_react29.useRef)(0);
|
4895
5224
|
const onDragFinished = useOnDragFinished(
|
4896
5225
|
(finished) => {
|
4897
5226
|
var _a;
|
@@ -4926,7 +5255,7 @@ var useMinEmptyHeight = ({
|
|
4926
5255
|
},
|
4927
5256
|
[appStore, prevHeight, zoneCompound]
|
4928
5257
|
);
|
4929
|
-
(0,
|
5258
|
+
(0, import_react29.useEffect)(() => {
|
4930
5259
|
if (draggedItem && ref.current) {
|
4931
5260
|
if (isZone) {
|
4932
5261
|
const rect = ref.current.getBoundingClientRect();
|
@@ -4957,15 +5286,15 @@ function assignRefs(refs, node) {
|
|
4957
5286
|
|
4958
5287
|
// components/DropZone/lib/use-content-with-preview.ts
|
4959
5288
|
init_react_import();
|
4960
|
-
var
|
5289
|
+
var import_react32 = require("react");
|
4961
5290
|
|
4962
5291
|
// lib/dnd/use-rendered-callback.ts
|
4963
5292
|
init_react_import();
|
4964
|
-
var
|
4965
|
-
var
|
5293
|
+
var import_react30 = require("@dnd-kit/react");
|
5294
|
+
var import_react31 = require("react");
|
4966
5295
|
function useRenderedCallback(callback, deps) {
|
4967
|
-
const manager = (0,
|
4968
|
-
return (0,
|
5296
|
+
const manager = (0, import_react30.useDragDropManager)();
|
5297
|
+
return (0, import_react31.useCallback)(
|
4969
5298
|
(...args) => __async(this, null, function* () {
|
4970
5299
|
yield manager == null ? void 0 : manager.renderer.rendering;
|
4971
5300
|
return callback(...args);
|
@@ -4976,14 +5305,14 @@ function useRenderedCallback(callback, deps) {
|
|
4976
5305
|
|
4977
5306
|
// components/DropZone/lib/use-content-with-preview.ts
|
4978
5307
|
var useContentIdsWithPreview = (contentIds, zoneCompound) => {
|
4979
|
-
const zoneStore = (0,
|
5308
|
+
const zoneStore = (0, import_react32.useContext)(ZoneStoreContext);
|
4980
5309
|
const preview = useContextStore(
|
4981
5310
|
ZoneStoreContext,
|
4982
5311
|
(s) => s.previewIndex[zoneCompound]
|
4983
5312
|
);
|
4984
5313
|
const isDragging = useAppStore((s) => s.state.ui.isDragging);
|
4985
|
-
const [contentIdsWithPreview, setContentIdsWithPreview] = (0,
|
4986
|
-
const [localPreview, setLocalPreview] = (0,
|
5314
|
+
const [contentIdsWithPreview, setContentIdsWithPreview] = (0, import_react32.useState)(contentIds);
|
5315
|
+
const [localPreview, setLocalPreview] = (0, import_react32.useState)(
|
4987
5316
|
preview
|
4988
5317
|
);
|
4989
5318
|
const updateContent = useRenderedCallback(
|
@@ -5010,201 +5339,76 @@ var useContentIdsWithPreview = (contentIds, zoneCompound) => {
|
|
5010
5339
|
);
|
5011
5340
|
}
|
5012
5341
|
} else {
|
5013
|
-
setContentIdsWithPreview(
|
5014
|
-
previewExists ? contentIds2.filter((id) => id !== draggedItemId) : contentIds2
|
5015
|
-
);
|
5016
|
-
}
|
5017
|
-
setLocalPreview(preview2);
|
5018
|
-
},
|
5019
|
-
[]
|
5020
|
-
);
|
5021
|
-
(0, import_react30.useEffect)(() => {
|
5022
|
-
var _a;
|
5023
|
-
const s = zoneStore.getState();
|
5024
|
-
const draggedItemId = (_a = s.draggedItem) == null ? void 0 : _a.id;
|
5025
|
-
const previewExists = Object.keys(s.previewIndex || {}).length > 0;
|
5026
|
-
updateContent(
|
5027
|
-
contentIds,
|
5028
|
-
preview,
|
5029
|
-
isDragging,
|
5030
|
-
draggedItemId,
|
5031
|
-
previewExists
|
5032
|
-
);
|
5033
|
-
}, [contentIds, preview, isDragging]);
|
5034
|
-
return [contentIdsWithPreview, localPreview];
|
5035
|
-
};
|
5036
|
-
|
5037
|
-
// components/DropZone/lib/use-drag-axis.ts
|
5038
|
-
init_react_import();
|
5039
|
-
var import_react31 = require("react");
|
5040
|
-
var GRID_DRAG_AXIS = "dynamic";
|
5041
|
-
var FLEX_ROW_DRAG_AXIS = "x";
|
5042
|
-
var DEFAULT_DRAG_AXIS = "y";
|
5043
|
-
var useDragAxis = (ref, collisionAxis) => {
|
5044
|
-
const status = useAppStore((s) => s.status);
|
5045
|
-
const [dragAxis, setDragAxis] = (0, import_react31.useState)(
|
5046
|
-
collisionAxis || DEFAULT_DRAG_AXIS
|
5047
|
-
);
|
5048
|
-
const calculateDragAxis = (0, import_react31.useCallback)(() => {
|
5049
|
-
if (ref.current) {
|
5050
|
-
const computedStyle = window.getComputedStyle(ref.current);
|
5051
|
-
if (computedStyle.display === "grid") {
|
5052
|
-
setDragAxis(GRID_DRAG_AXIS);
|
5053
|
-
} else if (computedStyle.display === "flex" && computedStyle.flexDirection === "row") {
|
5054
|
-
setDragAxis(FLEX_ROW_DRAG_AXIS);
|
5055
|
-
} else {
|
5056
|
-
setDragAxis(DEFAULT_DRAG_AXIS);
|
5057
|
-
}
|
5058
|
-
}
|
5059
|
-
}, [ref.current]);
|
5060
|
-
(0, import_react31.useEffect)(() => {
|
5061
|
-
const onViewportChange = () => {
|
5062
|
-
calculateDragAxis();
|
5063
|
-
};
|
5064
|
-
window.addEventListener("viewportchange", onViewportChange);
|
5065
|
-
return () => {
|
5066
|
-
window.removeEventListener("viewportchange", onViewportChange);
|
5067
|
-
};
|
5068
|
-
}, []);
|
5069
|
-
(0, import_react31.useEffect)(calculateDragAxis, [status, collisionAxis]);
|
5070
|
-
return [dragAxis, calculateDragAxis];
|
5071
|
-
};
|
5072
|
-
|
5073
|
-
// components/DropZone/index.tsx
|
5074
|
-
var import_shallow4 = require("zustand/react/shallow");
|
5075
|
-
|
5076
|
-
// components/Render/index.tsx
|
5077
|
-
init_react_import();
|
5078
|
-
|
5079
|
-
// lib/use-slots.tsx
|
5080
|
-
init_react_import();
|
5081
|
-
var import_react32 = require("react");
|
5082
|
-
function useSlots(config, item, renderSlotEdit, renderSlotRender = renderSlotEdit, readOnly, forceReadOnly) {
|
5083
|
-
const slotProps = (0, import_react32.useMemo)(() => {
|
5084
|
-
const mapped = mapSlots(
|
5085
|
-
item,
|
5086
|
-
(content, _parentId, propName, field, propPath) => {
|
5087
|
-
const wildcardPath = propPath.replace(/\[\d+\]/g, "[*]");
|
5088
|
-
const isReadOnly = (readOnly == null ? void 0 : readOnly[propPath]) || (readOnly == null ? void 0 : readOnly[wildcardPath]) || forceReadOnly;
|
5089
|
-
const render = isReadOnly ? renderSlotRender : renderSlotEdit;
|
5090
|
-
const Slot = (dzProps) => render(__spreadProps(__spreadValues({
|
5091
|
-
allow: (field == null ? void 0 : field.type) === "slot" ? field.allow : [],
|
5092
|
-
disallow: (field == null ? void 0 : field.type) === "slot" ? field.disallow : []
|
5093
|
-
}, dzProps), {
|
5094
|
-
zone: propName,
|
5095
|
-
content
|
5096
|
-
}));
|
5097
|
-
return Slot;
|
5098
|
-
},
|
5099
|
-
config
|
5100
|
-
).props;
|
5101
|
-
return mapped;
|
5102
|
-
}, [config, item, readOnly, forceReadOnly]);
|
5103
|
-
const mergedProps = (0, import_react32.useMemo)(
|
5104
|
-
() => __spreadValues(__spreadValues({}, item.props), slotProps),
|
5105
|
-
[item.props, slotProps]
|
5106
|
-
);
|
5107
|
-
return mergedProps;
|
5108
|
-
}
|
5109
|
-
|
5110
|
-
// components/Render/index.tsx
|
5111
|
-
var import_react34 = __toESM(require("react"));
|
5112
|
-
|
5113
|
-
// components/SlotRender/index.tsx
|
5114
|
-
init_react_import();
|
5115
|
-
var import_shallow3 = require("zustand/react/shallow");
|
5116
|
-
|
5117
|
-
// components/SlotRender/server.tsx
|
5118
|
-
init_react_import();
|
5119
|
-
var import_react33 = require("react");
|
5120
|
-
|
5121
|
-
// components/ServerRender/index.tsx
|
5122
|
-
init_react_import();
|
5123
|
-
var import_jsx_runtime21 = require("react/jsx-runtime");
|
5124
|
-
function DropZoneRender({
|
5125
|
-
zone,
|
5126
|
-
data,
|
5127
|
-
areaId = "root",
|
5128
|
-
config,
|
5129
|
-
metadata = {}
|
5130
|
-
}) {
|
5131
|
-
let zoneCompound = rootDroppableId;
|
5132
|
-
let content = (data == null ? void 0 : data.content) || [];
|
5133
|
-
if (!data || !config) {
|
5134
|
-
return null;
|
5135
|
-
}
|
5136
|
-
if (areaId !== rootAreaId && zone !== rootZone) {
|
5137
|
-
zoneCompound = `${areaId}:${zone}`;
|
5138
|
-
content = setupZone(data, zoneCompound).zones[zoneCompound];
|
5139
|
-
}
|
5140
|
-
return /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(import_jsx_runtime21.Fragment, { children: content.map((item) => {
|
5141
|
-
const Component = config.components[item.type];
|
5142
|
-
const props = __spreadProps(__spreadValues({}, item.props), {
|
5143
|
-
puck: {
|
5144
|
-
renderDropZone: ({ zone: zone2 }) => /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(
|
5145
|
-
DropZoneRender,
|
5146
|
-
{
|
5147
|
-
zone: zone2,
|
5148
|
-
data,
|
5149
|
-
areaId: item.props.id,
|
5150
|
-
config,
|
5151
|
-
metadata
|
5152
|
-
}
|
5153
|
-
),
|
5154
|
-
metadata,
|
5155
|
-
dragRef: null,
|
5156
|
-
isEditing: false
|
5157
|
-
}
|
5158
|
-
});
|
5159
|
-
const renderItem = __spreadProps(__spreadValues({}, item), { props });
|
5160
|
-
const propsWithSlots = useSlots(config, renderItem, (props2) => /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(SlotRenderPure, __spreadProps(__spreadValues({}, props2), { config, metadata })));
|
5161
|
-
if (Component) {
|
5162
|
-
return /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(Component.render, __spreadValues({}, propsWithSlots), renderItem.props.id);
|
5163
|
-
}
|
5164
|
-
return null;
|
5165
|
-
}) });
|
5166
|
-
}
|
5167
|
-
|
5168
|
-
// components/SlotRender/server.tsx
|
5169
|
-
var import_jsx_runtime22 = require("react/jsx-runtime");
|
5170
|
-
var SlotRenderPure = (props) => /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(SlotRender, __spreadValues({}, props));
|
5171
|
-
var Item = ({
|
5172
|
-
config,
|
5173
|
-
item,
|
5174
|
-
metadata
|
5175
|
-
}) => {
|
5176
|
-
const Component = config.components[item.type];
|
5177
|
-
const props = useSlots(config, item, (slotProps) => /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(SlotRenderPure, __spreadProps(__spreadValues({}, slotProps), { config, metadata })));
|
5178
|
-
return /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(
|
5179
|
-
Component.render,
|
5180
|
-
__spreadProps(__spreadValues({}, props), {
|
5181
|
-
puck: __spreadProps(__spreadValues({}, props.puck), {
|
5182
|
-
renderDropZone: DropZoneRender,
|
5183
|
-
metadata: metadata || {}
|
5184
|
-
})
|
5185
|
-
})
|
5342
|
+
setContentIdsWithPreview(
|
5343
|
+
previewExists ? contentIds2.filter((id) => id !== draggedItemId) : contentIds2
|
5344
|
+
);
|
5345
|
+
}
|
5346
|
+
setLocalPreview(preview2);
|
5347
|
+
},
|
5348
|
+
[]
|
5186
5349
|
);
|
5350
|
+
(0, import_react32.useEffect)(() => {
|
5351
|
+
var _a;
|
5352
|
+
const s = zoneStore.getState();
|
5353
|
+
const draggedItemId = (_a = s.draggedItem) == null ? void 0 : _a.id;
|
5354
|
+
const previewExists = Object.keys(s.previewIndex || {}).length > 0;
|
5355
|
+
updateContent(
|
5356
|
+
contentIds,
|
5357
|
+
preview,
|
5358
|
+
isDragging,
|
5359
|
+
draggedItemId,
|
5360
|
+
previewExists
|
5361
|
+
);
|
5362
|
+
}, [contentIds, preview, isDragging]);
|
5363
|
+
return [contentIdsWithPreview, localPreview];
|
5187
5364
|
};
|
5188
|
-
|
5189
|
-
|
5190
|
-
|
5191
|
-
|
5192
|
-
|
5365
|
+
|
5366
|
+
// components/DropZone/lib/use-drag-axis.ts
|
5367
|
+
init_react_import();
|
5368
|
+
var import_react33 = require("react");
|
5369
|
+
var GRID_DRAG_AXIS = "dynamic";
|
5370
|
+
var FLEX_ROW_DRAG_AXIS = "x";
|
5371
|
+
var DEFAULT_DRAG_AXIS = "y";
|
5372
|
+
var useDragAxis = (ref, collisionAxis) => {
|
5373
|
+
const status = useAppStore((s) => s.status);
|
5374
|
+
const [dragAxis, setDragAxis] = (0, import_react33.useState)(
|
5375
|
+
collisionAxis || DEFAULT_DRAG_AXIS
|
5376
|
+
);
|
5377
|
+
const calculateDragAxis = (0, import_react33.useCallback)(() => {
|
5378
|
+
if (ref.current) {
|
5379
|
+
const computedStyle = window.getComputedStyle(ref.current);
|
5380
|
+
if (computedStyle.display === "grid") {
|
5381
|
+
setDragAxis(GRID_DRAG_AXIS);
|
5382
|
+
} else if (computedStyle.display === "flex" && computedStyle.flexDirection === "row") {
|
5383
|
+
setDragAxis(FLEX_ROW_DRAG_AXIS);
|
5384
|
+
} else {
|
5385
|
+
setDragAxis(DEFAULT_DRAG_AXIS);
|
5193
5386
|
}
|
5194
|
-
|
5195
|
-
|
5196
|
-
|
5197
|
-
|
5198
|
-
|
5199
|
-
|
5200
|
-
|
5201
|
-
|
5202
|
-
);
|
5203
|
-
}
|
5204
|
-
}
|
5205
|
-
);
|
5387
|
+
}
|
5388
|
+
}, [ref.current]);
|
5389
|
+
(0, import_react33.useEffect)(() => {
|
5390
|
+
const onViewportChange = () => {
|
5391
|
+
calculateDragAxis();
|
5392
|
+
};
|
5393
|
+
window.addEventListener("viewportchange", onViewportChange);
|
5394
|
+
return () => {
|
5395
|
+
window.removeEventListener("viewportchange", onViewportChange);
|
5396
|
+
};
|
5397
|
+
}, []);
|
5398
|
+
(0, import_react33.useEffect)(calculateDragAxis, [status, collisionAxis]);
|
5399
|
+
return [dragAxis, calculateDragAxis];
|
5400
|
+
};
|
5401
|
+
|
5402
|
+
// components/DropZone/index.tsx
|
5403
|
+
var import_shallow4 = require("zustand/react/shallow");
|
5404
|
+
|
5405
|
+
// components/Render/index.tsx
|
5406
|
+
init_react_import();
|
5407
|
+
var import_react34 = __toESM(require("react"));
|
5206
5408
|
|
5207
5409
|
// components/SlotRender/index.tsx
|
5410
|
+
init_react_import();
|
5411
|
+
var import_shallow3 = require("zustand/react/shallow");
|
5208
5412
|
var import_jsx_runtime23 = require("react/jsx-runtime");
|
5209
5413
|
var ContextSlotRender = ({
|
5210
5414
|
componentId,
|
@@ -5238,7 +5442,7 @@ var renderContext = import_react34.default.createContext({
|
|
5238
5442
|
data: { root: {}, content: [] },
|
5239
5443
|
metadata: {}
|
5240
5444
|
});
|
5241
|
-
function
|
5445
|
+
function Render2({
|
5242
5446
|
config,
|
5243
5447
|
data,
|
5244
5448
|
metadata = {}
|
@@ -5392,14 +5596,14 @@ var DropZoneChild = ({
|
|
5392
5596
|
isLoading
|
5393
5597
|
);
|
5394
5598
|
if (!item) return;
|
5395
|
-
let
|
5599
|
+
let Render3 = componentConfig ? componentConfig.render : () => /* @__PURE__ */ (0, import_jsx_runtime25.jsxs)("div", { style: { padding: 48, textAlign: "center" }, children: [
|
5396
5600
|
"No configuration for ",
|
5397
5601
|
item.type
|
5398
5602
|
] });
|
5399
5603
|
let componentType = item.type;
|
5400
5604
|
const isInserting = "previewType" in item ? item.previewType === "insert" : false;
|
5401
5605
|
if (isInserting) {
|
5402
|
-
|
5606
|
+
Render3 = renderPreview;
|
5403
5607
|
}
|
5404
5608
|
return /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(
|
5405
5609
|
DraggableComponent,
|
@@ -5416,13 +5620,13 @@ var DropZoneChild = ({
|
|
5416
5620
|
userDragAxis: collisionAxis,
|
5417
5621
|
inDroppableZone,
|
5418
5622
|
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)(
|
5419
|
-
|
5623
|
+
Render3,
|
5420
5624
|
__spreadProps(__spreadValues({}, defaultedPropsWithSlots), {
|
5421
5625
|
puck: __spreadProps(__spreadValues({}, defaultedPropsWithSlots.puck), {
|
5422
5626
|
dragRef
|
5423
5627
|
})
|
5424
5628
|
})
|
5425
|
-
) }) : /* @__PURE__ */ (0, import_jsx_runtime25.jsx)("div", { ref: dragRef, children: /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(
|
5629
|
+
) }) : /* @__PURE__ */ (0, import_jsx_runtime25.jsx)("div", { ref: dragRef, children: /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(Render3, __spreadValues({}, defaultedPropsWithSlots)) })
|
5426
5630
|
}
|
5427
5631
|
);
|
5428
5632
|
};
|
@@ -7330,7 +7534,7 @@ var Preview2 = ({ id = "puck-preview" }) => {
|
|
7330
7534
|
editMode: true,
|
7331
7535
|
children: /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(DropZonePure, { zone: rootDroppableId })
|
7332
7536
|
})
|
7333
|
-
) : /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(
|
7537
|
+
) : /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(Render2, { data: renderData, config });
|
7334
7538
|
(0, import_react46.useEffect)(() => {
|
7335
7539
|
if (!iframe.enabled) {
|
7336
7540
|
setStatus("READY");
|
@@ -8756,188 +8960,6 @@ Puck.Components = Components;
|
|
8756
8960
|
Puck.Fields = Fields;
|
8757
8961
|
Puck.Outline = Outline;
|
8758
8962
|
Puck.Preview = Preview2;
|
8759
|
-
|
8760
|
-
// lib/migrate.ts
|
8761
|
-
init_react_import();
|
8762
|
-
var migrations = [
|
8763
|
-
// Migrate root to root.props
|
8764
|
-
(data) => {
|
8765
|
-
const rootProps = data.root.props || data.root;
|
8766
|
-
if (Object.keys(data.root).length > 0 && !data.root.props) {
|
8767
|
-
console.warn(
|
8768
|
-
"Migration applied: Root props moved from `root` to `root.props`."
|
8769
|
-
);
|
8770
|
-
return __spreadProps(__spreadValues({}, data), {
|
8771
|
-
root: {
|
8772
|
-
props: __spreadValues({}, rootProps)
|
8773
|
-
}
|
8774
|
-
});
|
8775
|
-
}
|
8776
|
-
return data;
|
8777
|
-
},
|
8778
|
-
// Migrate zones to slots
|
8779
|
-
(data, config) => {
|
8780
|
-
var _a;
|
8781
|
-
if (!config) return data;
|
8782
|
-
console.log("Migrating DropZones to slots...");
|
8783
|
-
const updatedItems = {};
|
8784
|
-
const appState = __spreadProps(__spreadValues({}, defaultAppState), { data });
|
8785
|
-
const { indexes } = walkAppState(appState, config);
|
8786
|
-
const deletedCompounds = [];
|
8787
|
-
walkAppState(appState, config, (content, zoneCompound, zoneType) => {
|
8788
|
-
var _a2, _b, _c;
|
8789
|
-
if (zoneType === "dropzone") {
|
8790
|
-
const [id, slotName] = zoneCompound.split(":");
|
8791
|
-
const nodeData = indexes.nodes[id].data;
|
8792
|
-
const componentType = nodeData.type;
|
8793
|
-
const configForComponent = id === "root" ? config.root : config.components[componentType];
|
8794
|
-
if (((_b = (_a2 = configForComponent == null ? void 0 : configForComponent.fields) == null ? void 0 : _a2[slotName]) == null ? void 0 : _b.type) === "slot") {
|
8795
|
-
updatedItems[id] = __spreadProps(__spreadValues({}, nodeData), {
|
8796
|
-
props: __spreadProps(__spreadValues(__spreadValues({}, nodeData.props), (_c = updatedItems[id]) == null ? void 0 : _c.props), {
|
8797
|
-
[slotName]: content
|
8798
|
-
})
|
8799
|
-
});
|
8800
|
-
deletedCompounds.push(zoneCompound);
|
8801
|
-
}
|
8802
|
-
return content;
|
8803
|
-
}
|
8804
|
-
return content;
|
8805
|
-
});
|
8806
|
-
const updated = walkAppState(
|
8807
|
-
appState,
|
8808
|
-
config,
|
8809
|
-
(content) => content,
|
8810
|
-
(item) => {
|
8811
|
-
var _a2;
|
8812
|
-
return (_a2 = updatedItems[item.props.id]) != null ? _a2 : item;
|
8813
|
-
}
|
8814
|
-
);
|
8815
|
-
deletedCompounds.forEach((zoneCompound) => {
|
8816
|
-
var _a2;
|
8817
|
-
const [_, propName] = zoneCompound.split(":");
|
8818
|
-
console.log(
|
8819
|
-
`\u2713 Success: Migrated "${zoneCompound}" from DropZone to slot field "${propName}"`
|
8820
|
-
);
|
8821
|
-
(_a2 = updated.data.zones) == null ? true : delete _a2[zoneCompound];
|
8822
|
-
});
|
8823
|
-
Object.keys((_a = updated.data.zones) != null ? _a : {}).forEach((zoneCompound) => {
|
8824
|
-
const [_, propName] = zoneCompound.split(":");
|
8825
|
-
throw new Error(
|
8826
|
-
`Could not migrate DropZone "${zoneCompound}" to slot field. No slot exists with the name "${propName}".`
|
8827
|
-
);
|
8828
|
-
});
|
8829
|
-
delete updated.data.zones;
|
8830
|
-
return updated.data;
|
8831
|
-
}
|
8832
|
-
];
|
8833
|
-
function migrate(data, config) {
|
8834
|
-
return migrations == null ? void 0 : migrations.reduce(
|
8835
|
-
(acc, migration) => migration(acc, config),
|
8836
|
-
data
|
8837
|
-
);
|
8838
|
-
}
|
8839
|
-
|
8840
|
-
// lib/transform-props.ts
|
8841
|
-
init_react_import();
|
8842
|
-
|
8843
|
-
// lib/data/default-data.ts
|
8844
|
-
init_react_import();
|
8845
|
-
var defaultData = (data) => __spreadProps(__spreadValues({}, data), {
|
8846
|
-
root: data.root || {},
|
8847
|
-
content: data.content || []
|
8848
|
-
});
|
8849
|
-
|
8850
|
-
// lib/transform-props.ts
|
8851
|
-
function transformProps(data, propTransforms, config = { components: {} }) {
|
8852
|
-
const mapItem = (item) => {
|
8853
|
-
if (propTransforms[item.type]) {
|
8854
|
-
return __spreadProps(__spreadValues({}, item), {
|
8855
|
-
props: __spreadValues({
|
8856
|
-
id: item.props.id
|
8857
|
-
}, propTransforms[item.type](item.props))
|
8858
|
-
});
|
8859
|
-
}
|
8860
|
-
return item;
|
8861
|
-
};
|
8862
|
-
const defaultedData = defaultData(data);
|
8863
|
-
const rootProps = defaultedData.root.props || defaultedData.root;
|
8864
|
-
let newRoot = __spreadValues({}, defaultedData.root);
|
8865
|
-
if (propTransforms["root"]) {
|
8866
|
-
newRoot.props = propTransforms["root"](rootProps);
|
8867
|
-
}
|
8868
|
-
const dataWithUpdatedRoot = __spreadProps(__spreadValues({}, defaultedData), { root: newRoot });
|
8869
|
-
const updatedData = walkTree(
|
8870
|
-
dataWithUpdatedRoot,
|
8871
|
-
config,
|
8872
|
-
(content) => content.map(mapItem)
|
8873
|
-
);
|
8874
|
-
if (!defaultedData.root.props) {
|
8875
|
-
updatedData.root = updatedData.root.props;
|
8876
|
-
}
|
8877
|
-
return updatedData;
|
8878
|
-
}
|
8879
|
-
|
8880
|
-
// lib/resolve-all-data.ts
|
8881
|
-
init_react_import();
|
8882
|
-
|
8883
|
-
// lib/data/to-component.ts
|
8884
|
-
init_react_import();
|
8885
|
-
var toComponent = (item) => {
|
8886
|
-
return "type" in item ? item : __spreadProps(__spreadValues({}, item), {
|
8887
|
-
props: __spreadProps(__spreadValues({}, item.props), { id: "root" }),
|
8888
|
-
type: "root"
|
8889
|
-
});
|
8890
|
-
};
|
8891
|
-
|
8892
|
-
// lib/resolve-all-data.ts
|
8893
|
-
function resolveAllData(_0, _1) {
|
8894
|
-
return __async(this, arguments, function* (data, config, metadata = {}, onResolveStart, onResolveEnd) {
|
8895
|
-
var _a;
|
8896
|
-
const defaultedData = defaultData(data);
|
8897
|
-
const resolveNode = (_node) => __async(this, null, function* () {
|
8898
|
-
const node = toComponent(_node);
|
8899
|
-
onResolveStart == null ? void 0 : onResolveStart(node);
|
8900
|
-
const resolved = (yield resolveComponentData(
|
8901
|
-
node,
|
8902
|
-
config,
|
8903
|
-
metadata,
|
8904
|
-
() => {
|
8905
|
-
},
|
8906
|
-
() => {
|
8907
|
-
},
|
8908
|
-
"force"
|
8909
|
-
)).node;
|
8910
|
-
const resolvedDeep = yield mapSlots(
|
8911
|
-
resolved,
|
8912
|
-
processContent,
|
8913
|
-
config
|
8914
|
-
);
|
8915
|
-
onResolveEnd == null ? void 0 : onResolveEnd(toComponent(resolvedDeep));
|
8916
|
-
return resolvedDeep;
|
8917
|
-
});
|
8918
|
-
const processContent = (content) => __async(this, null, function* () {
|
8919
|
-
return Promise.all(content.map(resolveNode));
|
8920
|
-
});
|
8921
|
-
const processZones = () => __async(this, null, function* () {
|
8922
|
-
var _a2;
|
8923
|
-
const zones = (_a2 = data.zones) != null ? _a2 : {};
|
8924
|
-
Object.entries(zones).forEach((_02) => __async(this, [_02], function* ([zoneKey, content]) {
|
8925
|
-
zones[zoneKey] = yield Promise.all(content.map(resolveNode));
|
8926
|
-
}));
|
8927
|
-
return zones;
|
8928
|
-
});
|
8929
|
-
const dynamic = {
|
8930
|
-
root: yield resolveNode(defaultedData.root),
|
8931
|
-
content: yield processContent(defaultedData.content),
|
8932
|
-
zones: yield processZones()
|
8933
|
-
};
|
8934
|
-
Object.keys((_a = defaultedData.zones) != null ? _a : {}).forEach((zoneKey) => __async(this, null, function* () {
|
8935
|
-
const content = defaultedData.zones[zoneKey];
|
8936
|
-
dynamic.zones[zoneKey] = yield processContent(content);
|
8937
|
-
}), {});
|
8938
|
-
return dynamic;
|
8939
|
-
});
|
8940
|
-
}
|
8941
8963
|
// Annotate the CommonJS export names for ESM import in node:
|
8942
8964
|
0 && (module.exports = {
|
8943
8965
|
Action,
|