@measured/puck 0.20.0-canary.68dd73b8 → 0.20.0-canary.6dace1cf
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-H6KSTNLT.mjs → chunk-32MJ3X3H.mjs} +246 -249
- package/dist/chunk-4KAREQPB.mjs +8436 -0
- package/dist/index.css +3 -1
- package/dist/index.d.mts +3 -3
- package/dist/index.d.ts +3 -3
- package/dist/index.js +1068 -1089
- package/dist/index.mjs +25 -8436
- package/dist/no-external.css +1895 -0
- package/dist/no-external.d.mts +4 -0
- package/dist/no-external.d.ts +4 -0
- package/dist/no-external.js +9315 -0
- package/dist/no-external.mjs +52 -0
- package/dist/rsc.d.mts +2 -2
- package/dist/rsc.d.ts +2 -2
- package/dist/rsc.js +1 -1
- package/dist/rsc.mjs +5 -1
- package/dist/{walk-tree-BOSl1o0G.d.mts → walk-tree-DrNRq2FV.d.mts} +4 -3
- package/dist/{walk-tree-BOSl1o0G.d.ts → walk-tree-DrNRq2FV.d.ts} +4 -3
- package/package.json +3 -2
package/dist/index.js
CHANGED
|
@@ -153,9 +153,9 @@ var require_classnames = __commonJS({
|
|
|
153
153
|
}
|
|
154
154
|
});
|
|
155
155
|
|
|
156
|
-
// index.ts
|
|
157
|
-
var
|
|
158
|
-
__export(
|
|
156
|
+
// bundle/index.ts
|
|
157
|
+
var bundle_exports = {};
|
|
158
|
+
__export(bundle_exports, {
|
|
159
159
|
Action: () => Action,
|
|
160
160
|
ActionBar: () => ActionBar,
|
|
161
161
|
AutoField: () => AutoField,
|
|
@@ -167,7 +167,7 @@ __export(core_exports, {
|
|
|
167
167
|
IconButton: () => IconButton,
|
|
168
168
|
Label: () => Label,
|
|
169
169
|
Puck: () => Puck,
|
|
170
|
-
Render: () =>
|
|
170
|
+
Render: () => Render,
|
|
171
171
|
createUsePuck: () => createUsePuck,
|
|
172
172
|
migrate: () => migrate,
|
|
173
173
|
overrideKeys: () => overrideKeys,
|
|
@@ -178,7 +178,10 @@ __export(core_exports, {
|
|
|
178
178
|
usePuck: () => usePuck,
|
|
179
179
|
walkTree: () => walkTree
|
|
180
180
|
});
|
|
181
|
-
module.exports = __toCommonJS(
|
|
181
|
+
module.exports = __toCommonJS(bundle_exports);
|
|
182
|
+
init_react_import();
|
|
183
|
+
|
|
184
|
+
// bundle/core.ts
|
|
182
185
|
init_react_import();
|
|
183
186
|
|
|
184
187
|
// types/API/index.ts
|
|
@@ -306,7 +309,7 @@ init_react_import();
|
|
|
306
309
|
var styles_module_default2 = { "InputWrapper": "_InputWrapper_py9hf_1", "Input-label": "_Input-label_py9hf_5", "Input-labelIcon": "_Input-labelIcon_py9hf_14", "Input-disabledIcon": "_Input-disabledIcon_py9hf_21", "Input-input": "_Input-input_py9hf_26", "Input": "_Input_py9hf_1", "Input--readOnly": "_Input--readOnly_py9hf_76", "Input-radioGroupItems": "_Input-radioGroupItems_py9hf_87", "Input-radio": "_Input-radio_py9hf_87", "Input-radioInner": "_Input-radioInner_py9hf_104", "Input-radioInput": "_Input-radioInput_py9hf_149" };
|
|
307
310
|
|
|
308
311
|
// components/AutoField/index.tsx
|
|
309
|
-
var
|
|
312
|
+
var import_react20 = require("react");
|
|
310
313
|
|
|
311
314
|
// components/AutoField/fields/index.tsx
|
|
312
315
|
init_react_import();
|
|
@@ -766,7 +769,7 @@ var IconButton = ({
|
|
|
766
769
|
};
|
|
767
770
|
|
|
768
771
|
// components/AutoField/fields/ArrayField/index.tsx
|
|
769
|
-
var
|
|
772
|
+
var import_react14 = require("react");
|
|
770
773
|
|
|
771
774
|
// components/DragIcon/index.tsx
|
|
772
775
|
init_react_import();
|
|
@@ -1253,627 +1256,149 @@ function insertAction(state, action, appStore) {
|
|
|
1253
1256
|
|
|
1254
1257
|
// reducer/actions/replace.ts
|
|
1255
1258
|
init_react_import();
|
|
1256
|
-
|
|
1257
|
-
|
|
1258
|
-
|
|
1259
|
-
|
|
1260
|
-
|
|
1261
|
-
|
|
1262
|
-
|
|
1263
|
-
|
|
1264
|
-
|
|
1265
|
-
var setupZone = (data, zoneKey) => {
|
|
1266
|
-
if (zoneKey === rootDroppableId) {
|
|
1267
|
-
return data;
|
|
1259
|
+
var replaceAction = (state, action, appStore) => {
|
|
1260
|
+
const [parentId] = action.destinationZone.split(":");
|
|
1261
|
+
const idsInPath = getIdsForParent(action.destinationZone, state);
|
|
1262
|
+
const originalId = state.indexes.zones[action.destinationZone].contentIds[action.destinationIndex];
|
|
1263
|
+
const idChanged = originalId !== action.data.props.id;
|
|
1264
|
+
if (idChanged) {
|
|
1265
|
+
throw new Error(
|
|
1266
|
+
`Can't change the id during a replace action. Please us "remove" and "insert" to define a new node.`
|
|
1267
|
+
);
|
|
1268
1268
|
}
|
|
1269
|
-
const
|
|
1270
|
-
|
|
1269
|
+
const newSlotIds = [];
|
|
1270
|
+
const data = walkTree(action.data, appStore.config, (contents, opts) => {
|
|
1271
|
+
newSlotIds.push(`${opts.parentId}:${opts.propName}`);
|
|
1272
|
+
return contents.map((item) => {
|
|
1273
|
+
const id = generateId(item.type);
|
|
1274
|
+
return __spreadProps(__spreadValues({}, item), {
|
|
1275
|
+
props: __spreadValues({ id }, item.props)
|
|
1276
|
+
});
|
|
1277
|
+
});
|
|
1271
1278
|
});
|
|
1272
|
-
|
|
1273
|
-
|
|
1279
|
+
const stateWithDeepSlotsRemoved = __spreadValues({}, state);
|
|
1280
|
+
Object.keys(state.indexes.zones).forEach((zoneCompound) => {
|
|
1281
|
+
const id = zoneCompound.split(":")[0];
|
|
1282
|
+
if (id === originalId) {
|
|
1283
|
+
if (!newSlotIds.includes(zoneCompound)) {
|
|
1284
|
+
delete stateWithDeepSlotsRemoved.indexes.zones[zoneCompound];
|
|
1285
|
+
}
|
|
1286
|
+
}
|
|
1287
|
+
});
|
|
1288
|
+
return walkAppState(
|
|
1289
|
+
stateWithDeepSlotsRemoved,
|
|
1290
|
+
appStore.config,
|
|
1291
|
+
(content, zoneCompound) => {
|
|
1292
|
+
const newContent = [...content];
|
|
1293
|
+
if (zoneCompound === action.destinationZone) {
|
|
1294
|
+
newContent[action.destinationIndex] = data;
|
|
1295
|
+
}
|
|
1296
|
+
return newContent;
|
|
1297
|
+
},
|
|
1298
|
+
(childItem, path) => {
|
|
1299
|
+
const pathIds = path.map((p) => p.split(":")[0]);
|
|
1300
|
+
if (childItem.props.id === data.props.id) {
|
|
1301
|
+
return data;
|
|
1302
|
+
} else if (childItem.props.id === parentId) {
|
|
1303
|
+
return childItem;
|
|
1304
|
+
} else if (idsInPath.indexOf(childItem.props.id) > -1) {
|
|
1305
|
+
return childItem;
|
|
1306
|
+
} else if (pathIds.indexOf(data.props.id) > -1) {
|
|
1307
|
+
return childItem;
|
|
1308
|
+
}
|
|
1309
|
+
return null;
|
|
1310
|
+
}
|
|
1311
|
+
);
|
|
1274
1312
|
};
|
|
1275
1313
|
|
|
1276
|
-
//
|
|
1314
|
+
// reducer/actions/replace-root.ts
|
|
1277
1315
|
init_react_import();
|
|
1278
|
-
var
|
|
1279
|
-
|
|
1280
|
-
|
|
1281
|
-
|
|
1282
|
-
|
|
1283
|
-
|
|
1284
|
-
|
|
1285
|
-
|
|
1286
|
-
|
|
1287
|
-
|
|
1288
|
-
|
|
1289
|
-
|
|
1290
|
-
|
|
1291
|
-
|
|
1292
|
-
content
|
|
1293
|
-
}));
|
|
1294
|
-
return Slot;
|
|
1295
|
-
},
|
|
1296
|
-
config
|
|
1297
|
-
).props;
|
|
1298
|
-
return mapped;
|
|
1299
|
-
}, [config, item, readOnly, forceReadOnly]);
|
|
1300
|
-
const mergedProps = (0, import_react5.useMemo)(
|
|
1301
|
-
() => __spreadValues(__spreadValues({}, item.props), slotProps),
|
|
1302
|
-
[item.props, slotProps]
|
|
1316
|
+
var replaceRootAction = (state, action, appStore) => {
|
|
1317
|
+
return walkAppState(
|
|
1318
|
+
state,
|
|
1319
|
+
appStore.config,
|
|
1320
|
+
(content) => content,
|
|
1321
|
+
(childItem) => {
|
|
1322
|
+
if (childItem.props.id === "root") {
|
|
1323
|
+
return __spreadProps(__spreadValues({}, childItem), {
|
|
1324
|
+
props: __spreadValues(__spreadValues({}, childItem.props), action.root.props),
|
|
1325
|
+
readOnly: action.root.readOnly
|
|
1326
|
+
});
|
|
1327
|
+
}
|
|
1328
|
+
return childItem;
|
|
1329
|
+
}
|
|
1303
1330
|
);
|
|
1304
|
-
|
|
1305
|
-
}
|
|
1331
|
+
};
|
|
1306
1332
|
|
|
1307
|
-
//
|
|
1333
|
+
// reducer/actions/duplicate.ts
|
|
1308
1334
|
init_react_import();
|
|
1309
|
-
|
|
1310
|
-
|
|
1311
|
-
|
|
1312
|
-
|
|
1313
|
-
|
|
1314
|
-
|
|
1315
|
-
|
|
1316
|
-
}
|
|
1317
|
-
|
|
1318
|
-
|
|
1319
|
-
|
|
1320
|
-
|
|
1321
|
-
|
|
1322
|
-
|
|
1323
|
-
renderDropZone: DropZoneRender,
|
|
1324
|
-
metadata: metadata || {}
|
|
1325
|
-
})
|
|
1326
|
-
})
|
|
1335
|
+
|
|
1336
|
+
// lib/data/get-item.ts
|
|
1337
|
+
init_react_import();
|
|
1338
|
+
function getItem(selector, state) {
|
|
1339
|
+
var _a, _b;
|
|
1340
|
+
const zone = (_a = state.indexes.zones) == null ? void 0 : _a[selector.zone || rootDroppableId];
|
|
1341
|
+
return zone ? (_b = state.indexes.nodes[zone.contentIds[selector.index]]) == null ? void 0 : _b.data : void 0;
|
|
1342
|
+
}
|
|
1343
|
+
|
|
1344
|
+
// reducer/actions/duplicate.ts
|
|
1345
|
+
function duplicateAction(state, action, appStore) {
|
|
1346
|
+
const item = getItem(
|
|
1347
|
+
{ index: action.sourceIndex, zone: action.sourceZone },
|
|
1348
|
+
state
|
|
1327
1349
|
);
|
|
1328
|
-
|
|
1329
|
-
|
|
1330
|
-
|
|
1331
|
-
|
|
1332
|
-
|
|
1333
|
-
|
|
1350
|
+
const idsInPath = getIdsForParent(action.sourceZone, state);
|
|
1351
|
+
const newItem = __spreadProps(__spreadValues({}, item), {
|
|
1352
|
+
props: __spreadProps(__spreadValues({}, item.props), {
|
|
1353
|
+
id: generateId(item.type)
|
|
1354
|
+
})
|
|
1355
|
+
});
|
|
1356
|
+
const modified = walkAppState(
|
|
1357
|
+
state,
|
|
1358
|
+
appStore.config,
|
|
1359
|
+
(content, zoneCompound) => {
|
|
1360
|
+
if (zoneCompound === action.sourceZone) {
|
|
1361
|
+
return insert(content, action.sourceIndex + 1, item);
|
|
1334
1362
|
}
|
|
1335
|
-
return
|
|
1336
|
-
|
|
1337
|
-
|
|
1338
|
-
|
|
1339
|
-
|
|
1340
|
-
|
|
1341
|
-
},
|
|
1342
|
-
|
|
1343
|
-
|
|
1344
|
-
|
|
1345
|
-
|
|
1346
|
-
);
|
|
1347
|
-
|
|
1348
|
-
// components/ServerRender/index.tsx
|
|
1349
|
-
var import_jsx_runtime6 = require("react/jsx-runtime");
|
|
1350
|
-
function DropZoneRender({
|
|
1351
|
-
zone,
|
|
1352
|
-
data,
|
|
1353
|
-
areaId = "root",
|
|
1354
|
-
config,
|
|
1355
|
-
metadata = {}
|
|
1356
|
-
}) {
|
|
1357
|
-
let zoneCompound = rootDroppableId;
|
|
1358
|
-
let content = (data == null ? void 0 : data.content) || [];
|
|
1359
|
-
if (!data || !config) {
|
|
1360
|
-
return null;
|
|
1361
|
-
}
|
|
1362
|
-
if (areaId !== rootAreaId && zone !== rootZone) {
|
|
1363
|
-
zoneCompound = `${areaId}:${zone}`;
|
|
1364
|
-
content = setupZone(data, zoneCompound).zones[zoneCompound];
|
|
1365
|
-
}
|
|
1366
|
-
return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_jsx_runtime6.Fragment, { children: content.map((item) => {
|
|
1367
|
-
const Component = config.components[item.type];
|
|
1368
|
-
const props = __spreadProps(__spreadValues({}, item.props), {
|
|
1369
|
-
puck: {
|
|
1370
|
-
renderDropZone: ({ zone: zone2 }) => /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
|
|
1371
|
-
DropZoneRender,
|
|
1372
|
-
{
|
|
1373
|
-
zone: zone2,
|
|
1374
|
-
data,
|
|
1375
|
-
areaId: item.props.id,
|
|
1376
|
-
config,
|
|
1377
|
-
metadata
|
|
1378
|
-
}
|
|
1379
|
-
),
|
|
1380
|
-
metadata,
|
|
1381
|
-
dragRef: null,
|
|
1382
|
-
isEditing: false
|
|
1363
|
+
return content;
|
|
1364
|
+
},
|
|
1365
|
+
(childItem, path, index) => {
|
|
1366
|
+
const zoneCompound = path[path.length - 1];
|
|
1367
|
+
const parents = path.map((p) => p.split(":")[0]);
|
|
1368
|
+
if (parents.indexOf(newItem.props.id) > -1) {
|
|
1369
|
+
return __spreadProps(__spreadValues({}, childItem), {
|
|
1370
|
+
props: __spreadProps(__spreadValues({}, childItem.props), {
|
|
1371
|
+
id: generateId(childItem.type)
|
|
1372
|
+
})
|
|
1373
|
+
});
|
|
1383
1374
|
}
|
|
1384
|
-
|
|
1385
|
-
|
|
1386
|
-
|
|
1387
|
-
|
|
1388
|
-
|
|
1375
|
+
if (zoneCompound === action.sourceZone && index === action.sourceIndex + 1) {
|
|
1376
|
+
return newItem;
|
|
1377
|
+
}
|
|
1378
|
+
const [sourceZoneParent] = action.sourceZone.split(":");
|
|
1379
|
+
if (sourceZoneParent === childItem.props.id || idsInPath.indexOf(childItem.props.id) > -1) {
|
|
1380
|
+
return childItem;
|
|
1381
|
+
}
|
|
1382
|
+
return null;
|
|
1389
1383
|
}
|
|
1390
|
-
|
|
1391
|
-
})
|
|
1384
|
+
);
|
|
1385
|
+
return __spreadProps(__spreadValues({}, modified), {
|
|
1386
|
+
ui: __spreadProps(__spreadValues({}, modified.ui), {
|
|
1387
|
+
itemSelector: {
|
|
1388
|
+
index: action.sourceIndex + 1,
|
|
1389
|
+
zone: action.sourceZone
|
|
1390
|
+
}
|
|
1391
|
+
})
|
|
1392
|
+
});
|
|
1392
1393
|
}
|
|
1393
1394
|
|
|
1394
|
-
//
|
|
1395
|
+
// reducer/actions/reorder.ts
|
|
1395
1396
|
init_react_import();
|
|
1396
1397
|
|
|
1397
|
-
//
|
|
1398
|
+
// reducer/actions/move.ts
|
|
1398
1399
|
init_react_import();
|
|
1399
1400
|
|
|
1400
|
-
// lib/
|
|
1401
|
-
init_react_import();
|
|
1402
|
-
var import_fast_deep_equal = __toESM(require("fast-deep-equal"));
|
|
1403
|
-
var getChanged = (newItem, oldItem) => {
|
|
1404
|
-
return newItem ? Object.keys(newItem.props || {}).reduce((acc, item) => {
|
|
1405
|
-
const newItemProps = (newItem == null ? void 0 : newItem.props) || {};
|
|
1406
|
-
const oldItemProps = (oldItem == null ? void 0 : oldItem.props) || {};
|
|
1407
|
-
return __spreadProps(__spreadValues({}, acc), {
|
|
1408
|
-
[item]: !(0, import_fast_deep_equal.default)(oldItemProps[item], newItemProps[item])
|
|
1409
|
-
});
|
|
1410
|
-
}, {}) : {};
|
|
1411
|
-
};
|
|
1412
|
-
|
|
1413
|
-
// lib/resolve-component-data.ts
|
|
1414
|
-
var import_fast_deep_equal2 = __toESM(require("fast-deep-equal"));
|
|
1415
|
-
var cache = { lastChange: {} };
|
|
1416
|
-
var resolveComponentData = (_0, _1, ..._2) => __async(void 0, [_0, _1, ..._2], function* (item, config, metadata = {}, onResolveStart, onResolveEnd, trigger = "replace") {
|
|
1417
|
-
const configForItem = "type" in item && item.type !== "root" ? config.components[item.type] : config.root;
|
|
1418
|
-
const resolvedItem = __spreadValues({}, item);
|
|
1419
|
-
const shouldRunResolver = (configForItem == null ? void 0 : configForItem.resolveData) && item.props;
|
|
1420
|
-
const id = "id" in item.props ? item.props.id : "root";
|
|
1421
|
-
if (shouldRunResolver) {
|
|
1422
|
-
const { item: oldItem = null, resolved = {} } = cache.lastChange[id] || {};
|
|
1423
|
-
if (item && (0, import_fast_deep_equal2.default)(item, oldItem)) {
|
|
1424
|
-
return { node: resolved, didChange: false };
|
|
1425
|
-
}
|
|
1426
|
-
const changed = getChanged(item, oldItem);
|
|
1427
|
-
if (onResolveStart) {
|
|
1428
|
-
onResolveStart(item);
|
|
1429
|
-
}
|
|
1430
|
-
const { props: resolvedProps, readOnly = {} } = yield configForItem.resolveData(item, {
|
|
1431
|
-
changed,
|
|
1432
|
-
lastData: oldItem,
|
|
1433
|
-
metadata: __spreadValues(__spreadValues({}, metadata), configForItem.metadata),
|
|
1434
|
-
trigger
|
|
1435
|
-
});
|
|
1436
|
-
resolvedItem.props = __spreadValues(__spreadValues({}, item.props), resolvedProps);
|
|
1437
|
-
if (Object.keys(readOnly).length) {
|
|
1438
|
-
resolvedItem.readOnly = readOnly;
|
|
1439
|
-
}
|
|
1440
|
-
}
|
|
1441
|
-
let itemWithResolvedChildren = yield mapSlots(
|
|
1442
|
-
resolvedItem,
|
|
1443
|
-
(content) => __async(void 0, null, function* () {
|
|
1444
|
-
return yield Promise.all(
|
|
1445
|
-
content.map(
|
|
1446
|
-
(childItem) => __async(void 0, null, function* () {
|
|
1447
|
-
return (yield resolveComponentData(
|
|
1448
|
-
childItem,
|
|
1449
|
-
config,
|
|
1450
|
-
metadata,
|
|
1451
|
-
onResolveStart,
|
|
1452
|
-
onResolveEnd,
|
|
1453
|
-
trigger
|
|
1454
|
-
)).node;
|
|
1455
|
-
})
|
|
1456
|
-
)
|
|
1457
|
-
);
|
|
1458
|
-
}),
|
|
1459
|
-
config
|
|
1460
|
-
);
|
|
1461
|
-
if (shouldRunResolver && onResolveEnd) {
|
|
1462
|
-
onResolveEnd(resolvedItem);
|
|
1463
|
-
}
|
|
1464
|
-
cache.lastChange[id] = {
|
|
1465
|
-
item,
|
|
1466
|
-
resolved: itemWithResolvedChildren
|
|
1467
|
-
};
|
|
1468
|
-
return {
|
|
1469
|
-
node: itemWithResolvedChildren,
|
|
1470
|
-
didChange: !(0, import_fast_deep_equal2.default)(item, itemWithResolvedChildren)
|
|
1471
|
-
};
|
|
1472
|
-
});
|
|
1473
|
-
|
|
1474
|
-
// lib/data/default-data.ts
|
|
1475
|
-
init_react_import();
|
|
1476
|
-
var defaultData = (data) => __spreadProps(__spreadValues({}, data), {
|
|
1477
|
-
root: data.root || {},
|
|
1478
|
-
content: data.content || []
|
|
1479
|
-
});
|
|
1480
|
-
|
|
1481
|
-
// lib/data/to-component.ts
|
|
1482
|
-
init_react_import();
|
|
1483
|
-
var toComponent = (item) => {
|
|
1484
|
-
return "type" in item ? item : __spreadProps(__spreadValues({}, item), {
|
|
1485
|
-
props: __spreadProps(__spreadValues({}, item.props), { id: "root" }),
|
|
1486
|
-
type: "root"
|
|
1487
|
-
});
|
|
1488
|
-
};
|
|
1489
|
-
|
|
1490
|
-
// lib/resolve-all-data.ts
|
|
1491
|
-
function resolveAllData(_0, _1) {
|
|
1492
|
-
return __async(this, arguments, function* (data, config, metadata = {}, onResolveStart, onResolveEnd) {
|
|
1493
|
-
var _a;
|
|
1494
|
-
const defaultedData = defaultData(data);
|
|
1495
|
-
const resolveNode = (_node) => __async(this, null, function* () {
|
|
1496
|
-
const node = toComponent(_node);
|
|
1497
|
-
onResolveStart == null ? void 0 : onResolveStart(node);
|
|
1498
|
-
const resolved = (yield resolveComponentData(
|
|
1499
|
-
node,
|
|
1500
|
-
config,
|
|
1501
|
-
metadata,
|
|
1502
|
-
() => {
|
|
1503
|
-
},
|
|
1504
|
-
() => {
|
|
1505
|
-
},
|
|
1506
|
-
"force"
|
|
1507
|
-
)).node;
|
|
1508
|
-
const resolvedDeep = yield mapSlots(
|
|
1509
|
-
resolved,
|
|
1510
|
-
processContent,
|
|
1511
|
-
config
|
|
1512
|
-
);
|
|
1513
|
-
onResolveEnd == null ? void 0 : onResolveEnd(toComponent(resolvedDeep));
|
|
1514
|
-
return resolvedDeep;
|
|
1515
|
-
});
|
|
1516
|
-
const processContent = (content) => __async(this, null, function* () {
|
|
1517
|
-
return Promise.all(content.map(resolveNode));
|
|
1518
|
-
});
|
|
1519
|
-
const processZones = () => __async(this, null, function* () {
|
|
1520
|
-
var _a2;
|
|
1521
|
-
const zones = (_a2 = data.zones) != null ? _a2 : {};
|
|
1522
|
-
Object.entries(zones).forEach((_02) => __async(this, [_02], function* ([zoneKey, content]) {
|
|
1523
|
-
zones[zoneKey] = yield Promise.all(content.map(resolveNode));
|
|
1524
|
-
}));
|
|
1525
|
-
return zones;
|
|
1526
|
-
});
|
|
1527
|
-
const dynamic = {
|
|
1528
|
-
root: yield resolveNode(defaultedData.root),
|
|
1529
|
-
content: yield processContent(defaultedData.content),
|
|
1530
|
-
zones: yield processZones()
|
|
1531
|
-
};
|
|
1532
|
-
Object.keys((_a = defaultedData.zones) != null ? _a : {}).forEach((zoneKey) => __async(this, null, function* () {
|
|
1533
|
-
const content = defaultedData.zones[zoneKey];
|
|
1534
|
-
dynamic.zones[zoneKey] = yield processContent(content);
|
|
1535
|
-
}), {});
|
|
1536
|
-
return dynamic;
|
|
1537
|
-
});
|
|
1538
|
-
}
|
|
1539
|
-
|
|
1540
|
-
// lib/transform-props.ts
|
|
1541
|
-
init_react_import();
|
|
1542
|
-
function transformProps(data, propTransforms, config = { components: {} }) {
|
|
1543
|
-
const mapItem = (item) => {
|
|
1544
|
-
if (propTransforms[item.type]) {
|
|
1545
|
-
return __spreadProps(__spreadValues({}, item), {
|
|
1546
|
-
props: __spreadValues({
|
|
1547
|
-
id: item.props.id
|
|
1548
|
-
}, propTransforms[item.type](item.props))
|
|
1549
|
-
});
|
|
1550
|
-
}
|
|
1551
|
-
return item;
|
|
1552
|
-
};
|
|
1553
|
-
const defaultedData = defaultData(data);
|
|
1554
|
-
const rootProps = defaultedData.root.props || defaultedData.root;
|
|
1555
|
-
let newRoot = __spreadValues({}, defaultedData.root);
|
|
1556
|
-
if (propTransforms["root"]) {
|
|
1557
|
-
newRoot.props = propTransforms["root"](rootProps);
|
|
1558
|
-
}
|
|
1559
|
-
const dataWithUpdatedRoot = __spreadProps(__spreadValues({}, defaultedData), { root: newRoot });
|
|
1560
|
-
const updatedData = walkTree(
|
|
1561
|
-
dataWithUpdatedRoot,
|
|
1562
|
-
config,
|
|
1563
|
-
(content) => content.map(mapItem)
|
|
1564
|
-
);
|
|
1565
|
-
if (!defaultedData.root.props) {
|
|
1566
|
-
updatedData.root = updatedData.root.props;
|
|
1567
|
-
}
|
|
1568
|
-
return updatedData;
|
|
1569
|
-
}
|
|
1570
|
-
|
|
1571
|
-
// lib/migrate.ts
|
|
1572
|
-
init_react_import();
|
|
1573
|
-
|
|
1574
|
-
// store/default-app-state.ts
|
|
1575
|
-
init_react_import();
|
|
1576
|
-
|
|
1577
|
-
// components/ViewportControls/default-viewports.ts
|
|
1578
|
-
init_react_import();
|
|
1579
|
-
var defaultViewports = [
|
|
1580
|
-
{ width: 360, height: "auto", icon: "Smartphone", label: "Small" },
|
|
1581
|
-
{ width: 768, height: "auto", icon: "Tablet", label: "Medium" },
|
|
1582
|
-
{ width: 1280, height: "auto", icon: "Monitor", label: "Large" }
|
|
1583
|
-
];
|
|
1584
|
-
|
|
1585
|
-
// store/default-app-state.ts
|
|
1586
|
-
var defaultAppState = {
|
|
1587
|
-
data: { content: [], root: {}, zones: {} },
|
|
1588
|
-
ui: {
|
|
1589
|
-
leftSideBarVisible: true,
|
|
1590
|
-
rightSideBarVisible: true,
|
|
1591
|
-
arrayState: {},
|
|
1592
|
-
itemSelector: null,
|
|
1593
|
-
componentList: {},
|
|
1594
|
-
isDragging: false,
|
|
1595
|
-
previewMode: "edit",
|
|
1596
|
-
viewports: {
|
|
1597
|
-
current: {
|
|
1598
|
-
width: defaultViewports[0].width,
|
|
1599
|
-
height: defaultViewports[0].height || "auto"
|
|
1600
|
-
},
|
|
1601
|
-
options: [],
|
|
1602
|
-
controlsVisible: true
|
|
1603
|
-
},
|
|
1604
|
-
field: { focus: null }
|
|
1605
|
-
},
|
|
1606
|
-
indexes: {
|
|
1607
|
-
nodes: {},
|
|
1608
|
-
zones: {}
|
|
1609
|
-
}
|
|
1610
|
-
};
|
|
1611
|
-
|
|
1612
|
-
// lib/migrate.ts
|
|
1613
|
-
var migrations = [
|
|
1614
|
-
// Migrate root to root.props
|
|
1615
|
-
(data) => {
|
|
1616
|
-
const rootProps = data.root.props || data.root;
|
|
1617
|
-
if (Object.keys(data.root).length > 0 && !data.root.props) {
|
|
1618
|
-
console.warn(
|
|
1619
|
-
"Migration applied: Root props moved from `root` to `root.props`."
|
|
1620
|
-
);
|
|
1621
|
-
return __spreadProps(__spreadValues({}, data), {
|
|
1622
|
-
root: {
|
|
1623
|
-
props: __spreadValues({}, rootProps)
|
|
1624
|
-
}
|
|
1625
|
-
});
|
|
1626
|
-
}
|
|
1627
|
-
return data;
|
|
1628
|
-
},
|
|
1629
|
-
// Migrate zones to slots
|
|
1630
|
-
(data, config, migrationOptions) => {
|
|
1631
|
-
var _a, _b;
|
|
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, _b2, _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 (((_b2 = (_a2 = configForComponent == null ? void 0 : configForComponent.fields) == null ? void 0 : _a2[slotName]) == null ? void 0 : _b2.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
|
-
if (migrationOptions == null ? void 0 : migrationOptions.migrateDynamicZonesForComponent) {
|
|
1675
|
-
const unmigratedZonesGrouped = {};
|
|
1676
|
-
Object.keys((_a = updated.data.zones) != null ? _a : {}).forEach((zoneCompound) => {
|
|
1677
|
-
var _a2;
|
|
1678
|
-
const [componentId, propName] = zoneCompound.split(":");
|
|
1679
|
-
const content = (_a2 = updated.data.zones) == null ? void 0 : _a2[zoneCompound];
|
|
1680
|
-
if (!content) {
|
|
1681
|
-
return;
|
|
1682
|
-
}
|
|
1683
|
-
if (!unmigratedZonesGrouped[componentId]) {
|
|
1684
|
-
unmigratedZonesGrouped[componentId] = {};
|
|
1685
|
-
}
|
|
1686
|
-
if (!unmigratedZonesGrouped[componentId][propName]) {
|
|
1687
|
-
unmigratedZonesGrouped[componentId][propName] = content;
|
|
1688
|
-
}
|
|
1689
|
-
});
|
|
1690
|
-
Object.keys(unmigratedZonesGrouped).forEach((componentId) => {
|
|
1691
|
-
updated.data = walkTree(updated.data, config, (content) => {
|
|
1692
|
-
return content.map((child) => {
|
|
1693
|
-
var _a2;
|
|
1694
|
-
if (child.props.id !== componentId) {
|
|
1695
|
-
return child;
|
|
1696
|
-
}
|
|
1697
|
-
const migrateFn = (_a2 = migrationOptions == null ? void 0 : migrationOptions.migrateDynamicZonesForComponent) == null ? void 0 : _a2[child.type];
|
|
1698
|
-
if (!migrateFn) {
|
|
1699
|
-
return child;
|
|
1700
|
-
}
|
|
1701
|
-
const zones = unmigratedZonesGrouped[componentId];
|
|
1702
|
-
const migratedProps = migrateFn(child.props, zones);
|
|
1703
|
-
Object.keys(zones).forEach((propName) => {
|
|
1704
|
-
var _a3;
|
|
1705
|
-
const zoneCompound = `${componentId}:${propName}`;
|
|
1706
|
-
console.log(`\u2713 Success: Migrated "${zoneCompound}" DropZone`);
|
|
1707
|
-
(_a3 = updated.data.zones) == null ? true : delete _a3[zoneCompound];
|
|
1708
|
-
});
|
|
1709
|
-
return __spreadProps(__spreadValues({}, child), {
|
|
1710
|
-
props: migratedProps
|
|
1711
|
-
});
|
|
1712
|
-
});
|
|
1713
|
-
});
|
|
1714
|
-
});
|
|
1715
|
-
}
|
|
1716
|
-
Object.keys((_b = updated.data.zones) != null ? _b : {}).forEach((zoneCompound) => {
|
|
1717
|
-
const [_, propName] = zoneCompound.split(":");
|
|
1718
|
-
throw new Error(
|
|
1719
|
-
`Could not migrate DropZone "${zoneCompound}" to slot field. No slot exists with the name "${propName}".`
|
|
1720
|
-
);
|
|
1721
|
-
});
|
|
1722
|
-
delete updated.data.zones;
|
|
1723
|
-
return updated.data;
|
|
1724
|
-
}
|
|
1725
|
-
];
|
|
1726
|
-
function migrate(data, config, migrationOptions) {
|
|
1727
|
-
return migrations == null ? void 0 : migrations.reduce(
|
|
1728
|
-
(acc, migration) => migration(acc, config, migrationOptions),
|
|
1729
|
-
data
|
|
1730
|
-
);
|
|
1731
|
-
}
|
|
1732
|
-
|
|
1733
|
-
// reducer/actions/replace.ts
|
|
1734
|
-
var replaceAction = (state, action, appStore) => {
|
|
1735
|
-
const [parentId] = action.destinationZone.split(":");
|
|
1736
|
-
const idsInPath = getIdsForParent(action.destinationZone, state);
|
|
1737
|
-
const originalId = state.indexes.zones[action.destinationZone].contentIds[action.destinationIndex];
|
|
1738
|
-
const idChanged = originalId !== action.data.props.id;
|
|
1739
|
-
if (idChanged) {
|
|
1740
|
-
throw new Error(
|
|
1741
|
-
`Can't change the id during a replace action. Please us "remove" and "insert" to define a new node.`
|
|
1742
|
-
);
|
|
1743
|
-
}
|
|
1744
|
-
const newSlotIds = [];
|
|
1745
|
-
const data = walkTree(action.data, appStore.config, (contents, opts) => {
|
|
1746
|
-
newSlotIds.push(`${opts.parentId}:${opts.propName}`);
|
|
1747
|
-
return contents.map((item) => {
|
|
1748
|
-
const id = generateId(item.type);
|
|
1749
|
-
return __spreadProps(__spreadValues({}, item), {
|
|
1750
|
-
props: __spreadValues({ id }, item.props)
|
|
1751
|
-
});
|
|
1752
|
-
});
|
|
1753
|
-
});
|
|
1754
|
-
const stateWithDeepSlotsRemoved = __spreadValues({}, state);
|
|
1755
|
-
Object.keys(state.indexes.zones).forEach((zoneCompound) => {
|
|
1756
|
-
const id = zoneCompound.split(":")[0];
|
|
1757
|
-
if (id === originalId) {
|
|
1758
|
-
if (!newSlotIds.includes(zoneCompound)) {
|
|
1759
|
-
delete stateWithDeepSlotsRemoved.indexes.zones[zoneCompound];
|
|
1760
|
-
}
|
|
1761
|
-
}
|
|
1762
|
-
});
|
|
1763
|
-
return walkAppState(
|
|
1764
|
-
stateWithDeepSlotsRemoved,
|
|
1765
|
-
appStore.config,
|
|
1766
|
-
(content, zoneCompound) => {
|
|
1767
|
-
const newContent = [...content];
|
|
1768
|
-
if (zoneCompound === action.destinationZone) {
|
|
1769
|
-
newContent[action.destinationIndex] = data;
|
|
1770
|
-
}
|
|
1771
|
-
return newContent;
|
|
1772
|
-
},
|
|
1773
|
-
(childItem, path) => {
|
|
1774
|
-
const pathIds = path.map((p) => p.split(":")[0]);
|
|
1775
|
-
if (childItem.props.id === data.props.id) {
|
|
1776
|
-
return data;
|
|
1777
|
-
} else if (childItem.props.id === parentId) {
|
|
1778
|
-
return childItem;
|
|
1779
|
-
} else if (idsInPath.indexOf(childItem.props.id) > -1) {
|
|
1780
|
-
return childItem;
|
|
1781
|
-
} else if (pathIds.indexOf(data.props.id) > -1) {
|
|
1782
|
-
return childItem;
|
|
1783
|
-
}
|
|
1784
|
-
return null;
|
|
1785
|
-
}
|
|
1786
|
-
);
|
|
1787
|
-
};
|
|
1788
|
-
|
|
1789
|
-
// reducer/actions/replace-root.ts
|
|
1790
|
-
init_react_import();
|
|
1791
|
-
var replaceRootAction = (state, action, appStore) => {
|
|
1792
|
-
return walkAppState(
|
|
1793
|
-
state,
|
|
1794
|
-
appStore.config,
|
|
1795
|
-
(content) => content,
|
|
1796
|
-
(childItem) => {
|
|
1797
|
-
if (childItem.props.id === "root") {
|
|
1798
|
-
return __spreadProps(__spreadValues({}, childItem), {
|
|
1799
|
-
props: __spreadValues(__spreadValues({}, childItem.props), action.root.props),
|
|
1800
|
-
readOnly: action.root.readOnly
|
|
1801
|
-
});
|
|
1802
|
-
}
|
|
1803
|
-
return childItem;
|
|
1804
|
-
}
|
|
1805
|
-
);
|
|
1806
|
-
};
|
|
1807
|
-
|
|
1808
|
-
// reducer/actions/duplicate.ts
|
|
1809
|
-
init_react_import();
|
|
1810
|
-
|
|
1811
|
-
// lib/data/get-item.ts
|
|
1812
|
-
init_react_import();
|
|
1813
|
-
function getItem(selector, state) {
|
|
1814
|
-
var _a, _b;
|
|
1815
|
-
const zone = (_a = state.indexes.zones) == null ? void 0 : _a[selector.zone || rootDroppableId];
|
|
1816
|
-
return zone ? (_b = state.indexes.nodes[zone.contentIds[selector.index]]) == null ? void 0 : _b.data : void 0;
|
|
1817
|
-
}
|
|
1818
|
-
|
|
1819
|
-
// reducer/actions/duplicate.ts
|
|
1820
|
-
function duplicateAction(state, action, appStore) {
|
|
1821
|
-
const item = getItem(
|
|
1822
|
-
{ index: action.sourceIndex, zone: action.sourceZone },
|
|
1823
|
-
state
|
|
1824
|
-
);
|
|
1825
|
-
const idsInPath = getIdsForParent(action.sourceZone, state);
|
|
1826
|
-
const newItem = __spreadProps(__spreadValues({}, item), {
|
|
1827
|
-
props: __spreadProps(__spreadValues({}, item.props), {
|
|
1828
|
-
id: generateId(item.type)
|
|
1829
|
-
})
|
|
1830
|
-
});
|
|
1831
|
-
const modified = walkAppState(
|
|
1832
|
-
state,
|
|
1833
|
-
appStore.config,
|
|
1834
|
-
(content, zoneCompound) => {
|
|
1835
|
-
if (zoneCompound === action.sourceZone) {
|
|
1836
|
-
return insert(content, action.sourceIndex + 1, item);
|
|
1837
|
-
}
|
|
1838
|
-
return content;
|
|
1839
|
-
},
|
|
1840
|
-
(childItem, path, index) => {
|
|
1841
|
-
const zoneCompound = path[path.length - 1];
|
|
1842
|
-
const parents = path.map((p) => p.split(":")[0]);
|
|
1843
|
-
if (parents.indexOf(newItem.props.id) > -1) {
|
|
1844
|
-
return __spreadProps(__spreadValues({}, childItem), {
|
|
1845
|
-
props: __spreadProps(__spreadValues({}, childItem.props), {
|
|
1846
|
-
id: generateId(childItem.type)
|
|
1847
|
-
})
|
|
1848
|
-
});
|
|
1849
|
-
}
|
|
1850
|
-
if (zoneCompound === action.sourceZone && index === action.sourceIndex + 1) {
|
|
1851
|
-
return newItem;
|
|
1852
|
-
}
|
|
1853
|
-
const [sourceZoneParent] = action.sourceZone.split(":");
|
|
1854
|
-
if (sourceZoneParent === childItem.props.id || idsInPath.indexOf(childItem.props.id) > -1) {
|
|
1855
|
-
return childItem;
|
|
1856
|
-
}
|
|
1857
|
-
return null;
|
|
1858
|
-
}
|
|
1859
|
-
);
|
|
1860
|
-
return __spreadProps(__spreadValues({}, modified), {
|
|
1861
|
-
ui: __spreadProps(__spreadValues({}, modified.ui), {
|
|
1862
|
-
itemSelector: {
|
|
1863
|
-
index: action.sourceIndex + 1,
|
|
1864
|
-
zone: action.sourceZone
|
|
1865
|
-
}
|
|
1866
|
-
})
|
|
1867
|
-
});
|
|
1868
|
-
}
|
|
1869
|
-
|
|
1870
|
-
// reducer/actions/reorder.ts
|
|
1871
|
-
init_react_import();
|
|
1872
|
-
|
|
1873
|
-
// reducer/actions/move.ts
|
|
1874
|
-
init_react_import();
|
|
1875
|
-
|
|
1876
|
-
// lib/data/remove.ts
|
|
1401
|
+
// lib/data/remove.ts
|
|
1877
1402
|
init_react_import();
|
|
1878
1403
|
var remove = (list, index) => {
|
|
1879
1404
|
const result = Array.from(list);
|
|
@@ -1981,6 +1506,21 @@ var removeAction = (state, action, appStore) => {
|
|
|
1981
1506
|
|
|
1982
1507
|
// reducer/actions/register-zone.ts
|
|
1983
1508
|
init_react_import();
|
|
1509
|
+
|
|
1510
|
+
// lib/data/setup-zone.ts
|
|
1511
|
+
init_react_import();
|
|
1512
|
+
var setupZone = (data, zoneKey) => {
|
|
1513
|
+
if (zoneKey === rootDroppableId) {
|
|
1514
|
+
return data;
|
|
1515
|
+
}
|
|
1516
|
+
const newData = __spreadProps(__spreadValues({}, data), {
|
|
1517
|
+
zones: data.zones ? __spreadValues({}, data.zones) : {}
|
|
1518
|
+
});
|
|
1519
|
+
newData.zones[zoneKey] = newData.zones[zoneKey] || [];
|
|
1520
|
+
return newData;
|
|
1521
|
+
};
|
|
1522
|
+
|
|
1523
|
+
// reducer/actions/register-zone.ts
|
|
1984
1524
|
var zoneCache = {};
|
|
1985
1525
|
function registerZoneAction(state, action) {
|
|
1986
1526
|
if (zoneCache[action.zone]) {
|
|
@@ -2133,18 +1673,26 @@ function createReducer({
|
|
|
2133
1673
|
);
|
|
2134
1674
|
}
|
|
2135
1675
|
|
|
1676
|
+
// components/ViewportControls/default-viewports.ts
|
|
1677
|
+
init_react_import();
|
|
1678
|
+
var defaultViewports = [
|
|
1679
|
+
{ width: 360, height: "auto", icon: "Smartphone", label: "Small" },
|
|
1680
|
+
{ width: 768, height: "auto", icon: "Tablet", label: "Medium" },
|
|
1681
|
+
{ width: 1280, height: "auto", icon: "Monitor", label: "Large" }
|
|
1682
|
+
];
|
|
1683
|
+
|
|
2136
1684
|
// store/index.ts
|
|
2137
1685
|
var import_zustand2 = require("zustand");
|
|
2138
1686
|
var import_middleware2 = require("zustand/middleware");
|
|
2139
|
-
var
|
|
1687
|
+
var import_react9 = require("react");
|
|
2140
1688
|
|
|
2141
1689
|
// store/slices/history.ts
|
|
2142
1690
|
init_react_import();
|
|
2143
|
-
var
|
|
1691
|
+
var import_react6 = require("react");
|
|
2144
1692
|
|
|
2145
1693
|
// lib/use-hotkey.ts
|
|
2146
1694
|
init_react_import();
|
|
2147
|
-
var
|
|
1695
|
+
var import_react5 = require("react");
|
|
2148
1696
|
var import_zustand = require("zustand");
|
|
2149
1697
|
var import_middleware = require("zustand/middleware");
|
|
2150
1698
|
var keyCodeMap = {
|
|
@@ -2237,10 +1785,10 @@ var monitorHotkeys = (doc) => {
|
|
|
2237
1785
|
};
|
|
2238
1786
|
};
|
|
2239
1787
|
var useMonitorHotkeys = () => {
|
|
2240
|
-
(0,
|
|
1788
|
+
(0, import_react5.useEffect)(() => monitorHotkeys(document), []);
|
|
2241
1789
|
};
|
|
2242
1790
|
var useHotkey = (combo, cb) => {
|
|
2243
|
-
(0,
|
|
1791
|
+
(0, import_react5.useEffect)(
|
|
2244
1792
|
() => useHotkeyStore.setState((s) => ({
|
|
2245
1793
|
triggers: __spreadProps(__spreadValues({}, s.triggers), {
|
|
2246
1794
|
[`${Object.keys(combo).join("+")}`]: { combo, cb }
|
|
@@ -2349,7 +1897,7 @@ function useRegisterHistorySlice(appStore, {
|
|
|
2349
1897
|
index,
|
|
2350
1898
|
initialAppState
|
|
2351
1899
|
}) {
|
|
2352
|
-
(0,
|
|
1900
|
+
(0, import_react6.useEffect)(
|
|
2353
1901
|
() => appStore.setState({
|
|
2354
1902
|
history: __spreadProps(__spreadValues({}, appStore.getState().history), {
|
|
2355
1903
|
histories,
|
|
@@ -2416,7 +1964,7 @@ var createNodesSlice = (set, get) => ({
|
|
|
2416
1964
|
|
|
2417
1965
|
// store/slices/permissions.ts
|
|
2418
1966
|
init_react_import();
|
|
2419
|
-
var
|
|
1967
|
+
var import_react7 = require("react");
|
|
2420
1968
|
|
|
2421
1969
|
// lib/data/flatten-data.ts
|
|
2422
1970
|
init_react_import();
|
|
@@ -2434,6 +1982,19 @@ var flattenData = (state, config) => {
|
|
|
2434
1982
|
return data;
|
|
2435
1983
|
};
|
|
2436
1984
|
|
|
1985
|
+
// lib/get-changed.ts
|
|
1986
|
+
init_react_import();
|
|
1987
|
+
var import_fast_deep_equal = __toESM(require("fast-deep-equal"));
|
|
1988
|
+
var getChanged = (newItem, oldItem) => {
|
|
1989
|
+
return newItem ? Object.keys(newItem.props || {}).reduce((acc, item) => {
|
|
1990
|
+
const newItemProps = (newItem == null ? void 0 : newItem.props) || {};
|
|
1991
|
+
const oldItemProps = (oldItem == null ? void 0 : oldItem.props) || {};
|
|
1992
|
+
return __spreadProps(__spreadValues({}, acc), {
|
|
1993
|
+
[item]: !(0, import_fast_deep_equal.default)(oldItemProps[item], newItemProps[item])
|
|
1994
|
+
});
|
|
1995
|
+
}, {}) : {};
|
|
1996
|
+
};
|
|
1997
|
+
|
|
2437
1998
|
// store/slices/permissions.ts
|
|
2438
1999
|
var createPermissionsSlice = (set, get) => {
|
|
2439
2000
|
const resolvePermissions = (..._0) => __async(void 0, [..._0], function* (params = {}, force) {
|
|
@@ -2540,7 +2101,7 @@ var createPermissionsSlice = (set, get) => {
|
|
|
2540
2101
|
};
|
|
2541
2102
|
};
|
|
2542
2103
|
var useRegisterPermissionsSlice = (appStore, globalPermissions) => {
|
|
2543
|
-
(0,
|
|
2104
|
+
(0, import_react7.useEffect)(() => {
|
|
2544
2105
|
const { permissions } = appStore.getState();
|
|
2545
2106
|
const { globalPermissions: existingGlobalPermissions } = permissions;
|
|
2546
2107
|
appStore.setState({
|
|
@@ -2550,7 +2111,7 @@ var useRegisterPermissionsSlice = (appStore, globalPermissions) => {
|
|
|
2550
2111
|
});
|
|
2551
2112
|
permissions.resolvePermissions();
|
|
2552
2113
|
}, [globalPermissions]);
|
|
2553
|
-
(0,
|
|
2114
|
+
(0, import_react7.useEffect)(() => {
|
|
2554
2115
|
return appStore.subscribe(
|
|
2555
2116
|
(s) => s.state.data,
|
|
2556
2117
|
() => {
|
|
@@ -2558,7 +2119,7 @@ var useRegisterPermissionsSlice = (appStore, globalPermissions) => {
|
|
|
2558
2119
|
}
|
|
2559
2120
|
);
|
|
2560
2121
|
}, []);
|
|
2561
|
-
(0,
|
|
2122
|
+
(0, import_react7.useEffect)(() => {
|
|
2562
2123
|
return appStore.subscribe(
|
|
2563
2124
|
(s) => s.config,
|
|
2564
2125
|
() => {
|
|
@@ -2570,7 +2131,7 @@ var useRegisterPermissionsSlice = (appStore, globalPermissions) => {
|
|
|
2570
2131
|
|
|
2571
2132
|
// store/slices/fields.ts
|
|
2572
2133
|
init_react_import();
|
|
2573
|
-
var
|
|
2134
|
+
var import_react8 = require("react");
|
|
2574
2135
|
var createFieldsSlice = (_set, _get) => {
|
|
2575
2136
|
return {
|
|
2576
2137
|
fields: {},
|
|
@@ -2580,7 +2141,7 @@ var createFieldsSlice = (_set, _get) => {
|
|
|
2580
2141
|
};
|
|
2581
2142
|
};
|
|
2582
2143
|
var useRegisterFieldsSlice = (appStore, id) => {
|
|
2583
|
-
const resolveFields = (0,
|
|
2144
|
+
const resolveFields = (0, import_react8.useCallback)(
|
|
2584
2145
|
(reset) => __async(void 0, null, function* () {
|
|
2585
2146
|
var _a, _b;
|
|
2586
2147
|
const { fields, lastResolvedData } = appStore.getState().fields;
|
|
@@ -2637,7 +2198,7 @@ var useRegisterFieldsSlice = (appStore, id) => {
|
|
|
2637
2198
|
}),
|
|
2638
2199
|
[id]
|
|
2639
2200
|
);
|
|
2640
|
-
(0,
|
|
2201
|
+
(0, import_react8.useEffect)(() => {
|
|
2641
2202
|
resolveFields(true);
|
|
2642
2203
|
return appStore.subscribe(
|
|
2643
2204
|
(s) => s.state.indexes.nodes[id || "root"],
|
|
@@ -2646,6 +2207,68 @@ var useRegisterFieldsSlice = (appStore, id) => {
|
|
|
2646
2207
|
}, [id]);
|
|
2647
2208
|
};
|
|
2648
2209
|
|
|
2210
|
+
// lib/resolve-component-data.ts
|
|
2211
|
+
init_react_import();
|
|
2212
|
+
var import_fast_deep_equal2 = __toESM(require("fast-deep-equal"));
|
|
2213
|
+
var cache = { lastChange: {} };
|
|
2214
|
+
var resolveComponentData = (_0, _1, ..._2) => __async(void 0, [_0, _1, ..._2], function* (item, config, metadata = {}, onResolveStart, onResolveEnd, trigger = "replace") {
|
|
2215
|
+
const configForItem = "type" in item && item.type !== "root" ? config.components[item.type] : config.root;
|
|
2216
|
+
const resolvedItem = __spreadValues({}, item);
|
|
2217
|
+
const shouldRunResolver = (configForItem == null ? void 0 : configForItem.resolveData) && item.props;
|
|
2218
|
+
const id = "id" in item.props ? item.props.id : "root";
|
|
2219
|
+
if (shouldRunResolver) {
|
|
2220
|
+
const { item: oldItem = null, resolved = {} } = cache.lastChange[id] || {};
|
|
2221
|
+
if (item && (0, import_fast_deep_equal2.default)(item, oldItem)) {
|
|
2222
|
+
return { node: resolved, didChange: false };
|
|
2223
|
+
}
|
|
2224
|
+
const changed = getChanged(item, oldItem);
|
|
2225
|
+
if (onResolveStart) {
|
|
2226
|
+
onResolveStart(item);
|
|
2227
|
+
}
|
|
2228
|
+
const { props: resolvedProps, readOnly = {} } = yield configForItem.resolveData(item, {
|
|
2229
|
+
changed,
|
|
2230
|
+
lastData: oldItem,
|
|
2231
|
+
metadata: __spreadValues(__spreadValues({}, metadata), configForItem.metadata),
|
|
2232
|
+
trigger
|
|
2233
|
+
});
|
|
2234
|
+
resolvedItem.props = __spreadValues(__spreadValues({}, item.props), resolvedProps);
|
|
2235
|
+
if (Object.keys(readOnly).length) {
|
|
2236
|
+
resolvedItem.readOnly = readOnly;
|
|
2237
|
+
}
|
|
2238
|
+
}
|
|
2239
|
+
let itemWithResolvedChildren = yield mapSlots(
|
|
2240
|
+
resolvedItem,
|
|
2241
|
+
(content) => __async(void 0, null, function* () {
|
|
2242
|
+
return yield Promise.all(
|
|
2243
|
+
content.map(
|
|
2244
|
+
(childItem) => __async(void 0, null, function* () {
|
|
2245
|
+
return (yield resolveComponentData(
|
|
2246
|
+
childItem,
|
|
2247
|
+
config,
|
|
2248
|
+
metadata,
|
|
2249
|
+
onResolveStart,
|
|
2250
|
+
onResolveEnd,
|
|
2251
|
+
trigger
|
|
2252
|
+
)).node;
|
|
2253
|
+
})
|
|
2254
|
+
)
|
|
2255
|
+
);
|
|
2256
|
+
}),
|
|
2257
|
+
config
|
|
2258
|
+
);
|
|
2259
|
+
if (shouldRunResolver && onResolveEnd) {
|
|
2260
|
+
onResolveEnd(resolvedItem);
|
|
2261
|
+
}
|
|
2262
|
+
cache.lastChange[id] = {
|
|
2263
|
+
item,
|
|
2264
|
+
resolved: itemWithResolvedChildren
|
|
2265
|
+
};
|
|
2266
|
+
return {
|
|
2267
|
+
node: itemWithResolvedChildren,
|
|
2268
|
+
didChange: !(0, import_fast_deep_equal2.default)(item, itemWithResolvedChildren)
|
|
2269
|
+
};
|
|
2270
|
+
});
|
|
2271
|
+
|
|
2649
2272
|
// lib/data/to-root.ts
|
|
2650
2273
|
init_react_import();
|
|
2651
2274
|
var toRoot = (item) => {
|
|
@@ -2663,6 +2286,34 @@ var toRoot = (item) => {
|
|
|
2663
2286
|
return { props: {}, readOnly };
|
|
2664
2287
|
};
|
|
2665
2288
|
|
|
2289
|
+
// store/default-app-state.ts
|
|
2290
|
+
init_react_import();
|
|
2291
|
+
var defaultAppState = {
|
|
2292
|
+
data: { content: [], root: {}, zones: {} },
|
|
2293
|
+
ui: {
|
|
2294
|
+
leftSideBarVisible: true,
|
|
2295
|
+
rightSideBarVisible: true,
|
|
2296
|
+
arrayState: {},
|
|
2297
|
+
itemSelector: null,
|
|
2298
|
+
componentList: {},
|
|
2299
|
+
isDragging: false,
|
|
2300
|
+
previewMode: "edit",
|
|
2301
|
+
viewports: {
|
|
2302
|
+
current: {
|
|
2303
|
+
width: defaultViewports[0].width,
|
|
2304
|
+
height: defaultViewports[0].height || "auto"
|
|
2305
|
+
},
|
|
2306
|
+
options: [],
|
|
2307
|
+
controlsVisible: true
|
|
2308
|
+
},
|
|
2309
|
+
field: { focus: null }
|
|
2310
|
+
},
|
|
2311
|
+
indexes: {
|
|
2312
|
+
nodes: {},
|
|
2313
|
+
zones: {}
|
|
2314
|
+
}
|
|
2315
|
+
};
|
|
2316
|
+
|
|
2666
2317
|
// store/index.ts
|
|
2667
2318
|
var defaultPageFields = {
|
|
2668
2319
|
title: { type: "text" }
|
|
@@ -2839,23 +2490,23 @@ var createAppStore = (initialAppStore) => (0, import_zustand2.create)()(
|
|
|
2839
2490
|
});
|
|
2840
2491
|
})
|
|
2841
2492
|
);
|
|
2842
|
-
var appStoreContext = (0,
|
|
2493
|
+
var appStoreContext = (0, import_react9.createContext)(createAppStore());
|
|
2843
2494
|
function useAppStore(selector) {
|
|
2844
|
-
const context = (0,
|
|
2495
|
+
const context = (0, import_react9.useContext)(appStoreContext);
|
|
2845
2496
|
return (0, import_zustand2.useStore)(context, selector);
|
|
2846
2497
|
}
|
|
2847
2498
|
function useAppStoreApi() {
|
|
2848
|
-
return (0,
|
|
2499
|
+
return (0, import_react9.useContext)(appStoreContext);
|
|
2849
2500
|
}
|
|
2850
2501
|
|
|
2851
2502
|
// components/Sortable/index.tsx
|
|
2852
2503
|
init_react_import();
|
|
2853
|
-
var
|
|
2504
|
+
var import_react12 = require("@dnd-kit/react");
|
|
2854
2505
|
|
|
2855
2506
|
// lib/dnd/use-sensors.ts
|
|
2856
2507
|
init_react_import();
|
|
2857
|
-
var
|
|
2858
|
-
var
|
|
2508
|
+
var import_react10 = require("react");
|
|
2509
|
+
var import_react11 = require("@dnd-kit/react");
|
|
2859
2510
|
var import_utilities = require("@dnd-kit/dom/utilities");
|
|
2860
2511
|
var touchDefault = { delay: { value: 200, tolerance: 10 } };
|
|
2861
2512
|
var otherDefault = {
|
|
@@ -2870,8 +2521,8 @@ var useSensors = ({
|
|
|
2870
2521
|
touch: touchDefault,
|
|
2871
2522
|
other: otherDefault
|
|
2872
2523
|
}) => {
|
|
2873
|
-
const [sensors] = (0,
|
|
2874
|
-
|
|
2524
|
+
const [sensors] = (0, import_react10.useState)(() => [
|
|
2525
|
+
import_react11.PointerSensor.configure({
|
|
2875
2526
|
activationConstraints(event, source) {
|
|
2876
2527
|
var _a;
|
|
2877
2528
|
const { pointerType, target } = event;
|
|
@@ -3206,7 +2857,7 @@ var createDynamicCollisionDetector = (dragAxis, midpointOffset = 0.05) => (input
|
|
|
3206
2857
|
|
|
3207
2858
|
// components/Sortable/index.tsx
|
|
3208
2859
|
var import_sortable = require("@dnd-kit/react/sortable");
|
|
3209
|
-
var
|
|
2860
|
+
var import_jsx_runtime5 = require("react/jsx-runtime");
|
|
3210
2861
|
var SortableProvider = ({
|
|
3211
2862
|
children,
|
|
3212
2863
|
onDragStart,
|
|
@@ -3216,8 +2867,8 @@ var SortableProvider = ({
|
|
|
3216
2867
|
const sensors = useSensors({
|
|
3217
2868
|
mouse: { distance: { value: 5 } }
|
|
3218
2869
|
});
|
|
3219
|
-
return /* @__PURE__ */ (0,
|
|
3220
|
-
|
|
2870
|
+
return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
2871
|
+
import_react12.DragDropProvider,
|
|
3221
2872
|
{
|
|
3222
2873
|
sensors,
|
|
3223
2874
|
onDragStart: (event) => {
|
|
@@ -3281,11 +2932,11 @@ var Sortable = ({
|
|
|
3281
2932
|
|
|
3282
2933
|
// components/AutoField/context.tsx
|
|
3283
2934
|
init_react_import();
|
|
3284
|
-
var
|
|
3285
|
-
var
|
|
3286
|
-
var NestedFieldContext = (0,
|
|
2935
|
+
var import_react13 = require("react");
|
|
2936
|
+
var import_jsx_runtime6 = require("react/jsx-runtime");
|
|
2937
|
+
var NestedFieldContext = (0, import_react13.createContext)({});
|
|
3287
2938
|
var useNestedFieldContext = () => {
|
|
3288
|
-
const context = (0,
|
|
2939
|
+
const context = (0, import_react13.useContext)(NestedFieldContext);
|
|
3289
2940
|
return __spreadProps(__spreadValues({}, context), {
|
|
3290
2941
|
readOnlyFields: context.readOnlyFields || {}
|
|
3291
2942
|
});
|
|
@@ -3299,7 +2950,7 @@ var NestedFieldProvider = ({
|
|
|
3299
2950
|
}) => {
|
|
3300
2951
|
const subPath = `${name}.${subName}`;
|
|
3301
2952
|
const wildcardSubPath = `${wildcardName}.${subName}`;
|
|
3302
|
-
const subReadOnlyFields = (0,
|
|
2953
|
+
const subReadOnlyFields = (0, import_react13.useMemo)(
|
|
3303
2954
|
() => Object.keys(readOnlyFields).reduce((acc, readOnlyKey) => {
|
|
3304
2955
|
const isLocal = readOnlyKey.indexOf(subPath) > -1 || readOnlyKey.indexOf(wildcardSubPath) > -1;
|
|
3305
2956
|
if (isLocal) {
|
|
@@ -3315,7 +2966,7 @@ var NestedFieldProvider = ({
|
|
|
3315
2966
|
}, {}),
|
|
3316
2967
|
[name, subName, wildcardName, readOnlyFields]
|
|
3317
2968
|
);
|
|
3318
|
-
return /* @__PURE__ */ (0,
|
|
2969
|
+
return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
|
|
3319
2970
|
NestedFieldContext.Provider,
|
|
3320
2971
|
{
|
|
3321
2972
|
value: { readOnlyFields: subReadOnlyFields, localName: subName },
|
|
@@ -3325,7 +2976,7 @@ var NestedFieldProvider = ({
|
|
|
3325
2976
|
};
|
|
3326
2977
|
|
|
3327
2978
|
// components/AutoField/fields/ArrayField/index.tsx
|
|
3328
|
-
var
|
|
2979
|
+
var import_jsx_runtime7 = require("react/jsx-runtime");
|
|
3329
2980
|
var getClassName5 = get_class_name_factory_default("ArrayField", styles_module_default3);
|
|
3330
2981
|
var getClassNameItem = get_class_name_factory_default("ArrayFieldItem", styles_module_default3);
|
|
3331
2982
|
var ArrayField = ({
|
|
@@ -3337,7 +2988,7 @@ var ArrayField = ({
|
|
|
3337
2988
|
labelIcon,
|
|
3338
2989
|
readOnly,
|
|
3339
2990
|
id,
|
|
3340
|
-
Label: Label2 = (props) => /* @__PURE__ */ (0,
|
|
2991
|
+
Label: Label2 = (props) => /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("div", __spreadValues({}, props))
|
|
3341
2992
|
}) => {
|
|
3342
2993
|
const thisArrayState = useAppStore((s) => s.state.ui.arrayState[id]);
|
|
3343
2994
|
const setUi = useAppStore((s) => s.setUi);
|
|
@@ -3352,14 +3003,14 @@ var ArrayField = ({
|
|
|
3352
3003
|
}),
|
|
3353
3004
|
openId: ""
|
|
3354
3005
|
};
|
|
3355
|
-
const [localState, setLocalState] = (0,
|
|
3356
|
-
(0,
|
|
3006
|
+
const [localState, setLocalState] = (0, import_react14.useState)({ arrayState, value });
|
|
3007
|
+
(0, import_react14.useEffect)(() => {
|
|
3357
3008
|
var _a;
|
|
3358
3009
|
const _arrayState = (_a = appStore.getState().state.ui.arrayState[id]) != null ? _a : arrayState;
|
|
3359
3010
|
setLocalState({ arrayState: _arrayState, value });
|
|
3360
3011
|
}, [value]);
|
|
3361
3012
|
const appStore = useAppStoreApi();
|
|
3362
|
-
const mapArrayStateToUi = (0,
|
|
3013
|
+
const mapArrayStateToUi = (0, import_react14.useCallback)(
|
|
3363
3014
|
(partialArrayState) => {
|
|
3364
3015
|
const state = appStore.getState().state;
|
|
3365
3016
|
return {
|
|
@@ -3370,13 +3021,13 @@ var ArrayField = ({
|
|
|
3370
3021
|
},
|
|
3371
3022
|
[arrayState, appStore]
|
|
3372
3023
|
);
|
|
3373
|
-
const getHighestIndex = (0,
|
|
3024
|
+
const getHighestIndex = (0, import_react14.useCallback)(() => {
|
|
3374
3025
|
return arrayState.items.reduce(
|
|
3375
3026
|
(acc, item) => item._originalIndex > acc ? item._originalIndex : acc,
|
|
3376
3027
|
-1
|
|
3377
3028
|
);
|
|
3378
3029
|
}, [arrayState]);
|
|
3379
|
-
const regenerateArrayState = (0,
|
|
3030
|
+
const regenerateArrayState = (0, import_react14.useCallback)(
|
|
3380
3031
|
(value2) => {
|
|
3381
3032
|
let highestIndex = getHighestIndex();
|
|
3382
3033
|
const newItems = Array.from(value2 || []).map((item, idx) => {
|
|
@@ -3395,19 +3046,19 @@ var ArrayField = ({
|
|
|
3395
3046
|
},
|
|
3396
3047
|
[arrayState]
|
|
3397
3048
|
);
|
|
3398
|
-
(0,
|
|
3049
|
+
(0, import_react14.useEffect)(() => {
|
|
3399
3050
|
if (arrayState.items.length > 0) {
|
|
3400
3051
|
setUi(mapArrayStateToUi(arrayState));
|
|
3401
3052
|
}
|
|
3402
3053
|
}, []);
|
|
3403
|
-
const [draggedItem, setDraggedItem] = (0,
|
|
3054
|
+
const [draggedItem, setDraggedItem] = (0, import_react14.useState)("");
|
|
3404
3055
|
const isDraggingAny = !!draggedItem;
|
|
3405
3056
|
const canEdit = useAppStore(
|
|
3406
3057
|
(s) => s.permissions.getPermissions({ item: s.selectedItem }).edit
|
|
3407
3058
|
);
|
|
3408
3059
|
const forceReadOnly = !canEdit;
|
|
3409
|
-
const valueRef = (0,
|
|
3410
|
-
const uniqifyItem = (0,
|
|
3060
|
+
const valueRef = (0, import_react14.useRef)(value);
|
|
3061
|
+
const uniqifyItem = (0, import_react14.useCallback)(
|
|
3411
3062
|
(val) => {
|
|
3412
3063
|
if (field.type !== "array" || !field.arrayFields) return;
|
|
3413
3064
|
const config = appStore.getState().config;
|
|
@@ -3424,14 +3075,14 @@ var ArrayField = ({
|
|
|
3424
3075
|
return null;
|
|
3425
3076
|
}
|
|
3426
3077
|
const addDisabled = field.max !== void 0 && localState.arrayState.items.length >= field.max || readOnly;
|
|
3427
|
-
return /* @__PURE__ */ (0,
|
|
3078
|
+
return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
|
|
3428
3079
|
Label2,
|
|
3429
3080
|
{
|
|
3430
3081
|
label: label || name,
|
|
3431
|
-
icon: labelIcon || /* @__PURE__ */ (0,
|
|
3082
|
+
icon: labelIcon || /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(List, { size: 16 }),
|
|
3432
3083
|
el: "div",
|
|
3433
3084
|
readOnly,
|
|
3434
|
-
children: /* @__PURE__ */ (0,
|
|
3085
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
|
|
3435
3086
|
SortableProvider,
|
|
3436
3087
|
{
|
|
3437
3088
|
onDragStart: (id2) => setDraggedItem(id2),
|
|
@@ -3462,7 +3113,7 @@ var ArrayField = ({
|
|
|
3462
3113
|
});
|
|
3463
3114
|
valueRef.current = newValue;
|
|
3464
3115
|
},
|
|
3465
|
-
children: /* @__PURE__ */ (0,
|
|
3116
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(
|
|
3466
3117
|
"div",
|
|
3467
3118
|
{
|
|
3468
3119
|
className: getClassName5({
|
|
@@ -3470,16 +3121,16 @@ var ArrayField = ({
|
|
|
3470
3121
|
addDisabled
|
|
3471
3122
|
}),
|
|
3472
3123
|
children: [
|
|
3473
|
-
localState.arrayState.items.length > 0 && /* @__PURE__ */ (0,
|
|
3124
|
+
localState.arrayState.items.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("div", { className: getClassName5("inner"), "data-dnd-container": true, children: localState.arrayState.items.map((item, i) => {
|
|
3474
3125
|
const { _arrayId = `${id}-${i}`, _originalIndex = i } = item;
|
|
3475
3126
|
const data = Array.from(localState.value || [])[i] || {};
|
|
3476
|
-
return /* @__PURE__ */ (0,
|
|
3127
|
+
return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
|
|
3477
3128
|
Sortable,
|
|
3478
3129
|
{
|
|
3479
3130
|
id: _arrayId,
|
|
3480
3131
|
index: i,
|
|
3481
3132
|
disabled: readOnly,
|
|
3482
|
-
children: ({ isDragging, ref, handleRef }) => /* @__PURE__ */ (0,
|
|
3133
|
+
children: ({ isDragging, ref, handleRef }) => /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(
|
|
3483
3134
|
"div",
|
|
3484
3135
|
{
|
|
3485
3136
|
ref,
|
|
@@ -3489,7 +3140,7 @@ var ArrayField = ({
|
|
|
3489
3140
|
readOnly
|
|
3490
3141
|
}),
|
|
3491
3142
|
children: [
|
|
3492
|
-
/* @__PURE__ */ (0,
|
|
3143
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(
|
|
3493
3144
|
"div",
|
|
3494
3145
|
{
|
|
3495
3146
|
ref: handleRef,
|
|
@@ -3514,9 +3165,9 @@ var ArrayField = ({
|
|
|
3514
3165
|
className: getClassNameItem("summary"),
|
|
3515
3166
|
children: [
|
|
3516
3167
|
field.getItemSummary ? field.getItemSummary(data, i) : `Item #${_originalIndex}`,
|
|
3517
|
-
/* @__PURE__ */ (0,
|
|
3518
|
-
!readOnly && /* @__PURE__ */ (0,
|
|
3519
|
-
/* @__PURE__ */ (0,
|
|
3168
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("div", { className: getClassNameItem("rhs"), children: [
|
|
3169
|
+
!readOnly && /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("div", { className: getClassNameItem("actions"), children: [
|
|
3170
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)("div", { className: getClassNameItem("action"), children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
|
|
3520
3171
|
IconButton,
|
|
3521
3172
|
{
|
|
3522
3173
|
type: "button",
|
|
@@ -3535,10 +3186,10 @@ var ArrayField = ({
|
|
|
3535
3186
|
onChange(existingValue);
|
|
3536
3187
|
},
|
|
3537
3188
|
title: "Duplicate",
|
|
3538
|
-
children: /* @__PURE__ */ (0,
|
|
3189
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(Copy, { size: 16 })
|
|
3539
3190
|
}
|
|
3540
3191
|
) }),
|
|
3541
|
-
/* @__PURE__ */ (0,
|
|
3192
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)("div", { className: getClassNameItem("action"), children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
|
|
3542
3193
|
IconButton,
|
|
3543
3194
|
{
|
|
3544
3195
|
type: "button",
|
|
@@ -3560,16 +3211,16 @@ var ArrayField = ({
|
|
|
3560
3211
|
onChange(existingValue);
|
|
3561
3212
|
},
|
|
3562
3213
|
title: "Delete",
|
|
3563
|
-
children: /* @__PURE__ */ (0,
|
|
3214
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(Trash, { size: 16 })
|
|
3564
3215
|
}
|
|
3565
3216
|
) })
|
|
3566
3217
|
] }),
|
|
3567
|
-
/* @__PURE__ */ (0,
|
|
3218
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)("div", { children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(DragIcon, {}) })
|
|
3568
3219
|
] })
|
|
3569
3220
|
]
|
|
3570
3221
|
}
|
|
3571
3222
|
),
|
|
3572
|
-
/* @__PURE__ */ (0,
|
|
3223
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)("div", { className: getClassNameItem("body"), children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("fieldset", { className: getClassNameItem("fieldset"), children: Object.keys(field.arrayFields).map((subName) => {
|
|
3573
3224
|
const subField = field.arrayFields[subName];
|
|
3574
3225
|
const indexName = `${name}[${i}]`;
|
|
3575
3226
|
const subPath = `${indexName}.${subName}`;
|
|
@@ -3579,14 +3230,14 @@ var ArrayField = ({
|
|
|
3579
3230
|
const localWildcardSubPath = `${localWildcardName}.${subName}`;
|
|
3580
3231
|
const subReadOnly = forceReadOnly ? forceReadOnly : typeof readOnlyFields[subPath] !== "undefined" ? readOnlyFields[localSubPath] : readOnlyFields[localWildcardSubPath];
|
|
3581
3232
|
const label2 = subField.label || subName;
|
|
3582
|
-
return /* @__PURE__ */ (0,
|
|
3233
|
+
return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
|
|
3583
3234
|
NestedFieldProvider,
|
|
3584
3235
|
{
|
|
3585
3236
|
name: localIndexName,
|
|
3586
3237
|
wildcardName: localWildcardName,
|
|
3587
3238
|
subName,
|
|
3588
3239
|
readOnlyFields,
|
|
3589
|
-
children: /* @__PURE__ */ (0,
|
|
3240
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
|
|
3590
3241
|
AutoFieldPrivate,
|
|
3591
3242
|
{
|
|
3592
3243
|
name: subPath,
|
|
@@ -3619,7 +3270,7 @@ var ArrayField = ({
|
|
|
3619
3270
|
_arrayId
|
|
3620
3271
|
);
|
|
3621
3272
|
}) }),
|
|
3622
|
-
!addDisabled && /* @__PURE__ */ (0,
|
|
3273
|
+
!addDisabled && /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
|
|
3623
3274
|
"button",
|
|
3624
3275
|
{
|
|
3625
3276
|
type: "button",
|
|
@@ -3637,7 +3288,7 @@ var ArrayField = ({
|
|
|
3637
3288
|
setUi(mapArrayStateToUi(newArrayState), false);
|
|
3638
3289
|
onChange(newValue);
|
|
3639
3290
|
},
|
|
3640
|
-
children: /* @__PURE__ */ (0,
|
|
3291
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(Plus, { size: 21 })
|
|
3641
3292
|
}
|
|
3642
3293
|
)
|
|
3643
3294
|
]
|
|
@@ -3651,7 +3302,7 @@ var ArrayField = ({
|
|
|
3651
3302
|
|
|
3652
3303
|
// components/AutoField/fields/DefaultField/index.tsx
|
|
3653
3304
|
init_react_import();
|
|
3654
|
-
var
|
|
3305
|
+
var import_jsx_runtime8 = require("react/jsx-runtime");
|
|
3655
3306
|
var getClassName6 = get_class_name_factory_default("Input", styles_module_default2);
|
|
3656
3307
|
var DefaultField = ({
|
|
3657
3308
|
field,
|
|
@@ -3665,16 +3316,16 @@ var DefaultField = ({
|
|
|
3665
3316
|
id
|
|
3666
3317
|
}) => {
|
|
3667
3318
|
const value = _value;
|
|
3668
|
-
return /* @__PURE__ */ (0,
|
|
3319
|
+
return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
|
|
3669
3320
|
Label2,
|
|
3670
3321
|
{
|
|
3671
3322
|
label: label || name,
|
|
3672
|
-
icon: labelIcon || /* @__PURE__ */ (0,
|
|
3673
|
-
field.type === "text" && /* @__PURE__ */ (0,
|
|
3674
|
-
field.type === "number" && /* @__PURE__ */ (0,
|
|
3323
|
+
icon: labelIcon || /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(import_jsx_runtime8.Fragment, { children: [
|
|
3324
|
+
field.type === "text" && /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(Type, { size: 16 }),
|
|
3325
|
+
field.type === "number" && /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(Hash, { size: 16 })
|
|
3675
3326
|
] }),
|
|
3676
3327
|
readOnly,
|
|
3677
|
-
children: /* @__PURE__ */ (0,
|
|
3328
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
|
|
3678
3329
|
"input",
|
|
3679
3330
|
{
|
|
3680
3331
|
className: getClassName6("input"),
|
|
@@ -3712,11 +3363,11 @@ var DefaultField = ({
|
|
|
3712
3363
|
|
|
3713
3364
|
// components/AutoField/fields/ExternalField/index.tsx
|
|
3714
3365
|
init_react_import();
|
|
3715
|
-
var
|
|
3366
|
+
var import_react18 = require("react");
|
|
3716
3367
|
|
|
3717
3368
|
// components/ExternalInput/index.tsx
|
|
3718
3369
|
init_react_import();
|
|
3719
|
-
var
|
|
3370
|
+
var import_react17 = require("react");
|
|
3720
3371
|
|
|
3721
3372
|
// css-module:/home/runner/work/puck/puck/packages/core/components/ExternalInput/styles.module.css#css-module
|
|
3722
3373
|
init_react_import();
|
|
@@ -3724,7 +3375,7 @@ var styles_module_default6 = { "ExternalInput-actions": "_ExternalInput-actions_
|
|
|
3724
3375
|
|
|
3725
3376
|
// components/Modal/index.tsx
|
|
3726
3377
|
init_react_import();
|
|
3727
|
-
var
|
|
3378
|
+
var import_react15 = require("react");
|
|
3728
3379
|
|
|
3729
3380
|
// css-module:/home/runner/work/puck/puck/packages/core/components/Modal/styles.module.css#css-module
|
|
3730
3381
|
init_react_import();
|
|
@@ -3732,22 +3383,22 @@ var styles_module_default7 = { "Modal": "_Modal_ikbaj_1", "Modal--isOpen": "_Mod
|
|
|
3732
3383
|
|
|
3733
3384
|
// components/Modal/index.tsx
|
|
3734
3385
|
var import_react_dom = require("react-dom");
|
|
3735
|
-
var
|
|
3386
|
+
var import_jsx_runtime9 = require("react/jsx-runtime");
|
|
3736
3387
|
var getClassName7 = get_class_name_factory_default("Modal", styles_module_default7);
|
|
3737
3388
|
var Modal = ({
|
|
3738
3389
|
children,
|
|
3739
3390
|
onClose,
|
|
3740
3391
|
isOpen
|
|
3741
3392
|
}) => {
|
|
3742
|
-
const [rootEl, setRootEl] = (0,
|
|
3743
|
-
(0,
|
|
3393
|
+
const [rootEl, setRootEl] = (0, import_react15.useState)(null);
|
|
3394
|
+
(0, import_react15.useEffect)(() => {
|
|
3744
3395
|
setRootEl(document.getElementById("puck-portal-root"));
|
|
3745
3396
|
}, []);
|
|
3746
3397
|
if (!rootEl) {
|
|
3747
|
-
return /* @__PURE__ */ (0,
|
|
3398
|
+
return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("div", {});
|
|
3748
3399
|
}
|
|
3749
3400
|
return (0, import_react_dom.createPortal)(
|
|
3750
|
-
/* @__PURE__ */ (0,
|
|
3401
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.jsx)("div", { className: getClassName7({ isOpen }), onClick: onClose, children: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
|
|
3751
3402
|
"div",
|
|
3752
3403
|
{
|
|
3753
3404
|
className: getClassName7("inner"),
|
|
@@ -3767,11 +3418,11 @@ init_react_import();
|
|
|
3767
3418
|
var styles_module_default8 = { "Heading": "_Heading_qxrry_1", "Heading--xxxxl": "_Heading--xxxxl_qxrry_12", "Heading--xxxl": "_Heading--xxxl_qxrry_18", "Heading--xxl": "_Heading--xxl_qxrry_22", "Heading--xl": "_Heading--xl_qxrry_26", "Heading--l": "_Heading--l_qxrry_30", "Heading--m": "_Heading--m_qxrry_34", "Heading--s": "_Heading--s_qxrry_38", "Heading--xs": "_Heading--xs_qxrry_42" };
|
|
3768
3419
|
|
|
3769
3420
|
// components/Heading/index.tsx
|
|
3770
|
-
var
|
|
3421
|
+
var import_jsx_runtime10 = require("react/jsx-runtime");
|
|
3771
3422
|
var getClassName8 = get_class_name_factory_default("Heading", styles_module_default8);
|
|
3772
3423
|
var Heading = ({ children, rank, size = "m" }) => {
|
|
3773
3424
|
const Tag = rank ? `h${rank}` : "span";
|
|
3774
|
-
return /* @__PURE__ */ (0,
|
|
3425
|
+
return /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
|
|
3775
3426
|
Tag,
|
|
3776
3427
|
{
|
|
3777
3428
|
className: getClassName8({
|
|
@@ -3787,7 +3438,7 @@ init_react_import();
|
|
|
3787
3438
|
|
|
3788
3439
|
// components/Button/Button.tsx
|
|
3789
3440
|
init_react_import();
|
|
3790
|
-
var
|
|
3441
|
+
var import_react16 = require("react");
|
|
3791
3442
|
|
|
3792
3443
|
// css-module:/home/runner/work/puck/puck/packages/core/components/Button/Button.module.css#css-module
|
|
3793
3444
|
init_react_import();
|
|
@@ -3807,7 +3458,7 @@ var filterDataAttrs = (props) => {
|
|
|
3807
3458
|
};
|
|
3808
3459
|
|
|
3809
3460
|
// components/Button/Button.tsx
|
|
3810
|
-
var
|
|
3461
|
+
var import_jsx_runtime11 = require("react/jsx-runtime");
|
|
3811
3462
|
var getClassName9 = get_class_name_factory_default("Button", Button_module_default);
|
|
3812
3463
|
var Button = (_a) => {
|
|
3813
3464
|
var _b = _a, {
|
|
@@ -3837,11 +3488,11 @@ var Button = (_a) => {
|
|
|
3837
3488
|
"size",
|
|
3838
3489
|
"loading"
|
|
3839
3490
|
]);
|
|
3840
|
-
const [loading, setLoading] = (0,
|
|
3841
|
-
(0,
|
|
3491
|
+
const [loading, setLoading] = (0, import_react16.useState)(loadingProp);
|
|
3492
|
+
(0, import_react16.useEffect)(() => setLoading(loadingProp), [loadingProp]);
|
|
3842
3493
|
const ElementType = href ? "a" : type ? "button" : "span";
|
|
3843
3494
|
const dataAttrs = filterDataAttrs(props);
|
|
3844
|
-
const el = /* @__PURE__ */ (0,
|
|
3495
|
+
const el = /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)(
|
|
3845
3496
|
ElementType,
|
|
3846
3497
|
__spreadProps(__spreadValues({
|
|
3847
3498
|
className: getClassName9({
|
|
@@ -3866,9 +3517,9 @@ var Button = (_a) => {
|
|
|
3866
3517
|
href
|
|
3867
3518
|
}, dataAttrs), {
|
|
3868
3519
|
children: [
|
|
3869
|
-
icon && /* @__PURE__ */ (0,
|
|
3520
|
+
icon && /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("div", { className: getClassName9("icon"), children: icon }),
|
|
3870
3521
|
children,
|
|
3871
|
-
loading && /* @__PURE__ */ (0,
|
|
3522
|
+
loading && /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("div", { className: getClassName9("spinner"), children: /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(Loader, { size: 14 }) })
|
|
3872
3523
|
]
|
|
3873
3524
|
})
|
|
3874
3525
|
);
|
|
@@ -3876,7 +3527,7 @@ var Button = (_a) => {
|
|
|
3876
3527
|
};
|
|
3877
3528
|
|
|
3878
3529
|
// components/ExternalInput/index.tsx
|
|
3879
|
-
var
|
|
3530
|
+
var import_jsx_runtime12 = require("react/jsx-runtime");
|
|
3880
3531
|
var getClassName10 = get_class_name_factory_default("ExternalInput", styles_module_default6);
|
|
3881
3532
|
var getClassNameModal = get_class_name_factory_default("ExternalInputModal", styles_module_default6);
|
|
3882
3533
|
var dataCache = {};
|
|
@@ -3893,28 +3544,28 @@ var ExternalInput = ({
|
|
|
3893
3544
|
mapRow = (val) => val,
|
|
3894
3545
|
filterFields
|
|
3895
3546
|
} = field || {};
|
|
3896
|
-
const [data, setData] = (0,
|
|
3897
|
-
const [isOpen, setOpen] = (0,
|
|
3898
|
-
const [isLoading, setIsLoading] = (0,
|
|
3547
|
+
const [data, setData] = (0, import_react17.useState)([]);
|
|
3548
|
+
const [isOpen, setOpen] = (0, import_react17.useState)(false);
|
|
3549
|
+
const [isLoading, setIsLoading] = (0, import_react17.useState)(true);
|
|
3899
3550
|
const hasFilterFields = !!filterFields;
|
|
3900
|
-
const [filters, setFilters] = (0,
|
|
3901
|
-
const [filtersToggled, setFiltersToggled] = (0,
|
|
3902
|
-
const mappedData = (0,
|
|
3551
|
+
const [filters, setFilters] = (0, import_react17.useState)(field.initialFilters || {});
|
|
3552
|
+
const [filtersToggled, setFiltersToggled] = (0, import_react17.useState)(hasFilterFields);
|
|
3553
|
+
const mappedData = (0, import_react17.useMemo)(() => {
|
|
3903
3554
|
return data.map(mapRow);
|
|
3904
3555
|
}, [data]);
|
|
3905
|
-
const keys = (0,
|
|
3556
|
+
const keys = (0, import_react17.useMemo)(() => {
|
|
3906
3557
|
const validKeys = /* @__PURE__ */ new Set();
|
|
3907
3558
|
for (const item of mappedData) {
|
|
3908
3559
|
for (const key of Object.keys(item)) {
|
|
3909
|
-
if (typeof item[key] === "string" || typeof item[key] === "number" || (0,
|
|
3560
|
+
if (typeof item[key] === "string" || typeof item[key] === "number" || (0, import_react17.isValidElement)(item[key])) {
|
|
3910
3561
|
validKeys.add(key);
|
|
3911
3562
|
}
|
|
3912
3563
|
}
|
|
3913
3564
|
}
|
|
3914
3565
|
return Array.from(validKeys);
|
|
3915
3566
|
}, [mappedData]);
|
|
3916
|
-
const [searchQuery, setSearchQuery] = (0,
|
|
3917
|
-
const search = (0,
|
|
3567
|
+
const [searchQuery, setSearchQuery] = (0, import_react17.useState)(field.initialQuery || "");
|
|
3568
|
+
const search = (0, import_react17.useCallback)(
|
|
3918
3569
|
(query, filters2) => __async(void 0, null, function* () {
|
|
3919
3570
|
setIsLoading(true);
|
|
3920
3571
|
const cacheKey = `${id}-${query}-${JSON.stringify(filters2)}`;
|
|
@@ -3927,18 +3578,18 @@ var ExternalInput = ({
|
|
|
3927
3578
|
}),
|
|
3928
3579
|
[id, field]
|
|
3929
3580
|
);
|
|
3930
|
-
const Footer = (0,
|
|
3931
|
-
(props) => field.renderFooter ? field.renderFooter(props) : /* @__PURE__ */ (0,
|
|
3581
|
+
const Footer = (0, import_react17.useCallback)(
|
|
3582
|
+
(props) => field.renderFooter ? field.renderFooter(props) : /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)("span", { className: getClassNameModal("footer"), children: [
|
|
3932
3583
|
props.items.length,
|
|
3933
3584
|
" result",
|
|
3934
3585
|
props.items.length === 1 ? "" : "s"
|
|
3935
3586
|
] }),
|
|
3936
3587
|
[field.renderFooter]
|
|
3937
3588
|
);
|
|
3938
|
-
(0,
|
|
3589
|
+
(0, import_react17.useEffect)(() => {
|
|
3939
3590
|
search(searchQuery, filters);
|
|
3940
3591
|
}, []);
|
|
3941
|
-
return /* @__PURE__ */ (0,
|
|
3592
|
+
return /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)(
|
|
3942
3593
|
"div",
|
|
3943
3594
|
{
|
|
3944
3595
|
className: getClassName10({
|
|
@@ -3948,21 +3599,21 @@ var ExternalInput = ({
|
|
|
3948
3599
|
}),
|
|
3949
3600
|
id,
|
|
3950
3601
|
children: [
|
|
3951
|
-
/* @__PURE__ */ (0,
|
|
3952
|
-
/* @__PURE__ */ (0,
|
|
3602
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsxs)("div", { className: getClassName10("actions"), children: [
|
|
3603
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
|
|
3953
3604
|
"button",
|
|
3954
3605
|
{
|
|
3955
3606
|
type: "button",
|
|
3956
3607
|
onClick: () => setOpen(true),
|
|
3957
3608
|
className: getClassName10("button"),
|
|
3958
3609
|
disabled: readOnly,
|
|
3959
|
-
children: value ? field.getItemSummary ? field.getItemSummary(value) : "External item" : /* @__PURE__ */ (0,
|
|
3960
|
-
/* @__PURE__ */ (0,
|
|
3961
|
-
/* @__PURE__ */ (0,
|
|
3610
|
+
children: value ? field.getItemSummary ? field.getItemSummary(value) : "External item" : /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)(import_jsx_runtime12.Fragment, { children: [
|
|
3611
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)(Link, { size: "16" }),
|
|
3612
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)("span", { children: field.placeholder })
|
|
3962
3613
|
] })
|
|
3963
3614
|
}
|
|
3964
3615
|
),
|
|
3965
|
-
value && /* @__PURE__ */ (0,
|
|
3616
|
+
value && /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
|
|
3966
3617
|
"button",
|
|
3967
3618
|
{
|
|
3968
3619
|
type: "button",
|
|
@@ -3971,11 +3622,11 @@ var ExternalInput = ({
|
|
|
3971
3622
|
onChange(null);
|
|
3972
3623
|
},
|
|
3973
3624
|
disabled: readOnly,
|
|
3974
|
-
children: /* @__PURE__ */ (0,
|
|
3625
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(LockOpen, { size: 16 })
|
|
3975
3626
|
}
|
|
3976
3627
|
)
|
|
3977
3628
|
] }),
|
|
3978
|
-
/* @__PURE__ */ (0,
|
|
3629
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)(Modal, { onClose: () => setOpen(false), isOpen, children: /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)(
|
|
3979
3630
|
"form",
|
|
3980
3631
|
{
|
|
3981
3632
|
className: getClassNameModal({
|
|
@@ -3989,11 +3640,11 @@ var ExternalInput = ({
|
|
|
3989
3640
|
search(searchQuery, filters);
|
|
3990
3641
|
},
|
|
3991
3642
|
children: [
|
|
3992
|
-
/* @__PURE__ */ (0,
|
|
3993
|
-
/* @__PURE__ */ (0,
|
|
3994
|
-
/* @__PURE__ */ (0,
|
|
3995
|
-
/* @__PURE__ */ (0,
|
|
3996
|
-
/* @__PURE__ */ (0,
|
|
3643
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)("div", { className: getClassNameModal("masthead"), children: field.showSearch ? /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)("div", { className: getClassNameModal("searchForm"), children: [
|
|
3644
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsxs)("label", { className: getClassNameModal("search"), children: [
|
|
3645
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)("span", { className: getClassNameModal("searchIconText"), children: "Search" }),
|
|
3646
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)("div", { className: getClassNameModal("searchIcon"), children: /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(Search, { size: "18" }) }),
|
|
3647
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
|
|
3997
3648
|
"input",
|
|
3998
3649
|
{
|
|
3999
3650
|
className: getClassNameModal("searchInput"),
|
|
@@ -4008,9 +3659,9 @@ var ExternalInput = ({
|
|
|
4008
3659
|
}
|
|
4009
3660
|
)
|
|
4010
3661
|
] }),
|
|
4011
|
-
/* @__PURE__ */ (0,
|
|
4012
|
-
/* @__PURE__ */ (0,
|
|
4013
|
-
hasFilterFields && /* @__PURE__ */ (0,
|
|
3662
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsxs)("div", { className: getClassNameModal("searchActions"), children: [
|
|
3663
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)(Button, { type: "submit", loading: isLoading, fullWidth: true, children: "Search" }),
|
|
3664
|
+
hasFilterFields && /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("div", { className: getClassNameModal("searchActionIcon"), children: /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
|
|
4014
3665
|
IconButton,
|
|
4015
3666
|
{
|
|
4016
3667
|
type: "button",
|
|
@@ -4020,19 +3671,19 @@ var ExternalInput = ({
|
|
|
4020
3671
|
e.stopPropagation();
|
|
4021
3672
|
setFiltersToggled(!filtersToggled);
|
|
4022
3673
|
},
|
|
4023
|
-
children: /* @__PURE__ */ (0,
|
|
3674
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(SlidersHorizontal, { size: 20 })
|
|
4024
3675
|
}
|
|
4025
3676
|
) })
|
|
4026
3677
|
] })
|
|
4027
|
-
] }) : /* @__PURE__ */ (0,
|
|
4028
|
-
/* @__PURE__ */ (0,
|
|
4029
|
-
hasFilterFields && /* @__PURE__ */ (0,
|
|
3678
|
+
] }) : /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(Heading, { rank: "2", size: "xs", children: field.placeholder || "Select data" }) }),
|
|
3679
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsxs)("div", { className: getClassNameModal("grid"), children: [
|
|
3680
|
+
hasFilterFields && /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("div", { className: getClassNameModal("filters"), children: hasFilterFields && Object.keys(filterFields).map((fieldName) => {
|
|
4030
3681
|
const filterField = filterFields[fieldName];
|
|
4031
|
-
return /* @__PURE__ */ (0,
|
|
3682
|
+
return /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
|
|
4032
3683
|
"div",
|
|
4033
3684
|
{
|
|
4034
3685
|
className: getClassNameModal("field"),
|
|
4035
|
-
children: /* @__PURE__ */ (0,
|
|
3686
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
|
|
4036
3687
|
AutoFieldPrivate,
|
|
4037
3688
|
{
|
|
4038
3689
|
field: filterField,
|
|
@@ -4053,9 +3704,9 @@ var ExternalInput = ({
|
|
|
4053
3704
|
fieldName
|
|
4054
3705
|
);
|
|
4055
3706
|
}) }),
|
|
4056
|
-
/* @__PURE__ */ (0,
|
|
4057
|
-
/* @__PURE__ */ (0,
|
|
4058
|
-
/* @__PURE__ */ (0,
|
|
3707
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsxs)("div", { className: getClassNameModal("tableWrapper"), children: [
|
|
3708
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsxs)("table", { className: getClassNameModal("table"), children: [
|
|
3709
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)("thead", { className: getClassNameModal("thead"), children: /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("tr", { className: getClassNameModal("tr"), children: keys.map((key) => /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
|
|
4059
3710
|
"th",
|
|
4060
3711
|
{
|
|
4061
3712
|
className: getClassNameModal("th"),
|
|
@@ -4064,8 +3715,8 @@ var ExternalInput = ({
|
|
|
4064
3715
|
},
|
|
4065
3716
|
key
|
|
4066
3717
|
)) }) }),
|
|
4067
|
-
/* @__PURE__ */ (0,
|
|
4068
|
-
return /* @__PURE__ */ (0,
|
|
3718
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)("tbody", { className: getClassNameModal("tbody"), children: mappedData.map((item, i) => {
|
|
3719
|
+
return /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
|
|
4069
3720
|
"tr",
|
|
4070
3721
|
{
|
|
4071
3722
|
style: { whiteSpace: "nowrap" },
|
|
@@ -4074,16 +3725,16 @@ var ExternalInput = ({
|
|
|
4074
3725
|
onChange(mapProp(data[i]));
|
|
4075
3726
|
setOpen(false);
|
|
4076
3727
|
},
|
|
4077
|
-
children: keys.map((key) => /* @__PURE__ */ (0,
|
|
3728
|
+
children: keys.map((key) => /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("td", { className: getClassNameModal("td"), children: item[key] }, key))
|
|
4078
3729
|
},
|
|
4079
3730
|
i
|
|
4080
3731
|
);
|
|
4081
3732
|
}) })
|
|
4082
3733
|
] }),
|
|
4083
|
-
/* @__PURE__ */ (0,
|
|
3734
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)("div", { className: getClassNameModal("loadingBanner"), children: /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(Loader, { size: 24 }) })
|
|
4084
3735
|
] })
|
|
4085
3736
|
] }),
|
|
4086
|
-
/* @__PURE__ */ (0,
|
|
3737
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)("div", { className: getClassNameModal("footerContainer"), children: /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(Footer, { items: mappedData }) })
|
|
4087
3738
|
]
|
|
4088
3739
|
}
|
|
4089
3740
|
) })
|
|
@@ -4093,7 +3744,7 @@ var ExternalInput = ({
|
|
|
4093
3744
|
};
|
|
4094
3745
|
|
|
4095
3746
|
// components/AutoField/fields/ExternalField/index.tsx
|
|
4096
|
-
var
|
|
3747
|
+
var import_jsx_runtime13 = require("react/jsx-runtime");
|
|
4097
3748
|
var ExternalField = ({
|
|
4098
3749
|
field,
|
|
4099
3750
|
onChange,
|
|
@@ -4108,7 +3759,7 @@ var ExternalField = ({
|
|
|
4108
3759
|
var _a, _b, _c;
|
|
4109
3760
|
const validField = field;
|
|
4110
3761
|
const deprecatedField = field;
|
|
4111
|
-
(0,
|
|
3762
|
+
(0, import_react18.useEffect)(() => {
|
|
4112
3763
|
if (deprecatedField.adaptor) {
|
|
4113
3764
|
console.error(
|
|
4114
3765
|
"Warning: The `adaptor` API is deprecated. Please use updated APIs on the `external` field instead. This will be a breaking change in a future release."
|
|
@@ -4118,13 +3769,13 @@ var ExternalField = ({
|
|
|
4118
3769
|
if (field.type !== "external") {
|
|
4119
3770
|
return null;
|
|
4120
3771
|
}
|
|
4121
|
-
return /* @__PURE__ */ (0,
|
|
3772
|
+
return /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
|
|
4122
3773
|
Label2,
|
|
4123
3774
|
{
|
|
4124
3775
|
label: label || name,
|
|
4125
|
-
icon: labelIcon || /* @__PURE__ */ (0,
|
|
3776
|
+
icon: labelIcon || /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(Link, { size: 16 }),
|
|
4126
3777
|
el: "div",
|
|
4127
|
-
children: /* @__PURE__ */ (0,
|
|
3778
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
|
|
4128
3779
|
ExternalInput,
|
|
4129
3780
|
{
|
|
4130
3781
|
name,
|
|
@@ -4151,21 +3802,7 @@ var ExternalField = ({
|
|
|
4151
3802
|
|
|
4152
3803
|
// components/AutoField/fields/RadioField/index.tsx
|
|
4153
3804
|
init_react_import();
|
|
4154
|
-
var
|
|
4155
|
-
|
|
4156
|
-
// lib/safe-json-parse.ts
|
|
4157
|
-
init_react_import();
|
|
4158
|
-
var safeJsonParse = (str) => {
|
|
4159
|
-
try {
|
|
4160
|
-
const jsonValue = JSON.parse(str);
|
|
4161
|
-
return jsonValue;
|
|
4162
|
-
} catch (e) {
|
|
4163
|
-
return str;
|
|
4164
|
-
}
|
|
4165
|
-
};
|
|
4166
|
-
|
|
4167
|
-
// components/AutoField/fields/RadioField/index.tsx
|
|
4168
|
-
var import_jsx_runtime16 = require("react/jsx-runtime");
|
|
3805
|
+
var import_jsx_runtime14 = require("react/jsx-runtime");
|
|
4169
3806
|
var getClassName11 = get_class_name_factory_default("Input", styles_module_default2);
|
|
4170
3807
|
var RadioField = ({
|
|
4171
3808
|
field,
|
|
@@ -4178,58 +3815,50 @@ var RadioField = ({
|
|
|
4178
3815
|
labelIcon,
|
|
4179
3816
|
Label: Label2
|
|
4180
3817
|
}) => {
|
|
4181
|
-
const flatOptions = (0, import_react21.useMemo)(
|
|
4182
|
-
() => field.type === "radio" ? field.options.map(({ value: value2 }) => value2) : [],
|
|
4183
|
-
[field]
|
|
4184
|
-
);
|
|
4185
3818
|
if (field.type !== "radio" || !field.options) {
|
|
4186
3819
|
return null;
|
|
4187
3820
|
}
|
|
4188
|
-
return /* @__PURE__ */ (0,
|
|
3821
|
+
return /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
|
|
4189
3822
|
Label2,
|
|
4190
3823
|
{
|
|
4191
|
-
icon: labelIcon || /* @__PURE__ */ (0,
|
|
3824
|
+
icon: labelIcon || /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(CircleCheckBig, { size: 16 }),
|
|
4192
3825
|
label: label || name,
|
|
4193
3826
|
readOnly,
|
|
4194
3827
|
el: "div",
|
|
4195
|
-
children: /* @__PURE__ */ (0,
|
|
4196
|
-
|
|
4197
|
-
|
|
4198
|
-
|
|
4199
|
-
|
|
4200
|
-
|
|
4201
|
-
|
|
4202
|
-
|
|
4203
|
-
|
|
4204
|
-
|
|
4205
|
-
|
|
4206
|
-
|
|
4207
|
-
|
|
4208
|
-
|
|
4209
|
-
|
|
4210
|
-
|
|
4211
|
-
|
|
4212
|
-
|
|
4213
|
-
|
|
4214
|
-
|
|
4215
|
-
|
|
4216
|
-
|
|
4217
|
-
|
|
4218
|
-
|
|
4219
|
-
|
|
4220
|
-
|
|
4221
|
-
|
|
4222
|
-
},
|
|
4223
|
-
option.label + option.value
|
|
4224
|
-
)) })
|
|
3828
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("div", { className: getClassName11("radioGroupItems"), id, children: field.options.map((option) => {
|
|
3829
|
+
var _a;
|
|
3830
|
+
return /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)(
|
|
3831
|
+
"label",
|
|
3832
|
+
{
|
|
3833
|
+
className: getClassName11("radio"),
|
|
3834
|
+
children: [
|
|
3835
|
+
/* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
|
|
3836
|
+
"input",
|
|
3837
|
+
{
|
|
3838
|
+
type: "radio",
|
|
3839
|
+
className: getClassName11("radioInput"),
|
|
3840
|
+
value: JSON.stringify({ value: option.value }),
|
|
3841
|
+
name,
|
|
3842
|
+
onChange: (e) => {
|
|
3843
|
+
onChange(JSON.parse(e.target.value).value);
|
|
3844
|
+
},
|
|
3845
|
+
disabled: readOnly,
|
|
3846
|
+
checked: value === option.value
|
|
3847
|
+
}
|
|
3848
|
+
),
|
|
3849
|
+
/* @__PURE__ */ (0, import_jsx_runtime14.jsx)("div", { className: getClassName11("radioInner"), children: option.label || ((_a = option.value) == null ? void 0 : _a.toString()) })
|
|
3850
|
+
]
|
|
3851
|
+
},
|
|
3852
|
+
option.label + option.value
|
|
3853
|
+
);
|
|
3854
|
+
}) })
|
|
4225
3855
|
}
|
|
4226
3856
|
);
|
|
4227
3857
|
};
|
|
4228
3858
|
|
|
4229
3859
|
// components/AutoField/fields/SelectField/index.tsx
|
|
4230
3860
|
init_react_import();
|
|
4231
|
-
var
|
|
4232
|
-
var import_jsx_runtime17 = require("react/jsx-runtime");
|
|
3861
|
+
var import_jsx_runtime15 = require("react/jsx-runtime");
|
|
4233
3862
|
var getClassName12 = get_class_name_factory_default("Input", styles_module_default2);
|
|
4234
3863
|
var SelectField = ({
|
|
4235
3864
|
field,
|
|
@@ -4242,20 +3871,16 @@ var SelectField = ({
|
|
|
4242
3871
|
readOnly,
|
|
4243
3872
|
id
|
|
4244
3873
|
}) => {
|
|
4245
|
-
const flatOptions = (0, import_react22.useMemo)(
|
|
4246
|
-
() => field.type === "select" ? field.options.map(({ value: value2 }) => value2) : [],
|
|
4247
|
-
[field]
|
|
4248
|
-
);
|
|
4249
3874
|
if (field.type !== "select" || !field.options) {
|
|
4250
3875
|
return null;
|
|
4251
3876
|
}
|
|
4252
|
-
return /* @__PURE__ */ (0,
|
|
3877
|
+
return /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
|
|
4253
3878
|
Label2,
|
|
4254
3879
|
{
|
|
4255
3880
|
label: label || name,
|
|
4256
|
-
icon: labelIcon || /* @__PURE__ */ (0,
|
|
3881
|
+
icon: labelIcon || /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(ChevronDown, { size: 16 }),
|
|
4257
3882
|
readOnly,
|
|
4258
|
-
children: /* @__PURE__ */ (0,
|
|
3883
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
|
|
4259
3884
|
"select",
|
|
4260
3885
|
{
|
|
4261
3886
|
id,
|
|
@@ -4263,22 +3888,16 @@ var SelectField = ({
|
|
|
4263
3888
|
className: getClassName12("input"),
|
|
4264
3889
|
disabled: readOnly,
|
|
4265
3890
|
onChange: (e) => {
|
|
4266
|
-
|
|
4267
|
-
const jsonValue = (_a = safeJsonParse(e.target.value)) != null ? _a : e.target.value;
|
|
4268
|
-
if (flatOptions.indexOf(jsonValue) > -1) {
|
|
4269
|
-
onChange(jsonValue);
|
|
4270
|
-
} else {
|
|
4271
|
-
onChange(e.target.value);
|
|
4272
|
-
}
|
|
3891
|
+
onChange(JSON.parse(e.target.value).value);
|
|
4273
3892
|
},
|
|
4274
|
-
value,
|
|
4275
|
-
children: field.options.map((option) => /* @__PURE__ */ (0,
|
|
3893
|
+
value: JSON.stringify({ value }),
|
|
3894
|
+
children: field.options.map((option) => /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
|
|
4276
3895
|
"option",
|
|
4277
3896
|
{
|
|
4278
3897
|
label: option.label,
|
|
4279
|
-
value: option.value
|
|
3898
|
+
value: JSON.stringify({ value: option.value })
|
|
4280
3899
|
},
|
|
4281
|
-
option.label + option.value
|
|
3900
|
+
option.label + JSON.stringify(option.value)
|
|
4282
3901
|
))
|
|
4283
3902
|
}
|
|
4284
3903
|
)
|
|
@@ -4288,7 +3907,7 @@ var SelectField = ({
|
|
|
4288
3907
|
|
|
4289
3908
|
// components/AutoField/fields/TextareaField/index.tsx
|
|
4290
3909
|
init_react_import();
|
|
4291
|
-
var
|
|
3910
|
+
var import_jsx_runtime16 = require("react/jsx-runtime");
|
|
4292
3911
|
var getClassName13 = get_class_name_factory_default("Input", styles_module_default2);
|
|
4293
3912
|
var TextareaField = ({
|
|
4294
3913
|
field,
|
|
@@ -4301,13 +3920,13 @@ var TextareaField = ({
|
|
|
4301
3920
|
Label: Label2,
|
|
4302
3921
|
id
|
|
4303
3922
|
}) => {
|
|
4304
|
-
return /* @__PURE__ */ (0,
|
|
3923
|
+
return /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
|
|
4305
3924
|
Label2,
|
|
4306
3925
|
{
|
|
4307
3926
|
label: label || name,
|
|
4308
|
-
icon: labelIcon || /* @__PURE__ */ (0,
|
|
3927
|
+
icon: labelIcon || /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(Type, { size: 16 }),
|
|
4309
3928
|
readOnly,
|
|
4310
|
-
children: /* @__PURE__ */ (0,
|
|
3929
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
|
|
4311
3930
|
"textarea",
|
|
4312
3931
|
{
|
|
4313
3932
|
id,
|
|
@@ -4334,7 +3953,7 @@ init_react_import();
|
|
|
4334
3953
|
var styles_module_default9 = { "ObjectField": "_ObjectField_1ua3y_5", "ObjectField-fieldset": "_ObjectField-fieldset_1ua3y_13" };
|
|
4335
3954
|
|
|
4336
3955
|
// components/AutoField/fields/ObjectField/index.tsx
|
|
4337
|
-
var
|
|
3956
|
+
var import_jsx_runtime17 = require("react/jsx-runtime");
|
|
4338
3957
|
var getClassName14 = get_class_name_factory_default("ObjectField", styles_module_default9);
|
|
4339
3958
|
var ObjectField = ({
|
|
4340
3959
|
field,
|
|
@@ -4352,25 +3971,25 @@ var ObjectField = ({
|
|
|
4352
3971
|
return null;
|
|
4353
3972
|
}
|
|
4354
3973
|
const data = value || {};
|
|
4355
|
-
return /* @__PURE__ */ (0,
|
|
3974
|
+
return /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
|
|
4356
3975
|
Label2,
|
|
4357
3976
|
{
|
|
4358
3977
|
label: label || name,
|
|
4359
|
-
icon: labelIcon || /* @__PURE__ */ (0,
|
|
3978
|
+
icon: labelIcon || /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(EllipsisVertical, { size: 16 }),
|
|
4360
3979
|
el: "div",
|
|
4361
3980
|
readOnly,
|
|
4362
|
-
children: /* @__PURE__ */ (0,
|
|
3981
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("div", { className: getClassName14(), children: /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("fieldset", { className: getClassName14("fieldset"), children: Object.keys(field.objectFields).map((subName) => {
|
|
4363
3982
|
const subField = field.objectFields[subName];
|
|
4364
3983
|
const subPath = `${localName}.${subName}`;
|
|
4365
3984
|
const subReadOnly = readOnly ? readOnly : readOnlyFields[subPath];
|
|
4366
3985
|
const label2 = subField.label || subName;
|
|
4367
|
-
return /* @__PURE__ */ (0,
|
|
3986
|
+
return /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
|
|
4368
3987
|
NestedFieldProvider,
|
|
4369
3988
|
{
|
|
4370
3989
|
name: localName || id,
|
|
4371
3990
|
subName,
|
|
4372
3991
|
readOnlyFields,
|
|
4373
|
-
children: /* @__PURE__ */ (0,
|
|
3992
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
|
|
4374
3993
|
AutoFieldPrivate,
|
|
4375
3994
|
{
|
|
4376
3995
|
name: subPath,
|
|
@@ -4402,17 +4021,17 @@ var ObjectField = ({
|
|
|
4402
4021
|
|
|
4403
4022
|
// lib/use-safe-id.ts
|
|
4404
4023
|
init_react_import();
|
|
4405
|
-
var
|
|
4024
|
+
var import_react19 = __toESM(require("react"));
|
|
4406
4025
|
var useSafeId = () => {
|
|
4407
|
-
if (typeof
|
|
4408
|
-
return
|
|
4026
|
+
if (typeof import_react19.default.useId !== "undefined") {
|
|
4027
|
+
return import_react19.default.useId();
|
|
4409
4028
|
}
|
|
4410
|
-
const [id] = (0,
|
|
4029
|
+
const [id] = (0, import_react19.useState)(generateId());
|
|
4411
4030
|
return id;
|
|
4412
4031
|
};
|
|
4413
4032
|
|
|
4414
4033
|
// components/AutoField/index.tsx
|
|
4415
|
-
var
|
|
4034
|
+
var import_jsx_runtime18 = require("react/jsx-runtime");
|
|
4416
4035
|
var getClassName15 = get_class_name_factory_default("Input", styles_module_default2);
|
|
4417
4036
|
var getClassNameWrapper = get_class_name_factory_default("InputWrapper", styles_module_default2);
|
|
4418
4037
|
var FieldLabel = ({
|
|
@@ -4424,11 +4043,11 @@ var FieldLabel = ({
|
|
|
4424
4043
|
className
|
|
4425
4044
|
}) => {
|
|
4426
4045
|
const El = el;
|
|
4427
|
-
return /* @__PURE__ */ (0,
|
|
4428
|
-
/* @__PURE__ */ (0,
|
|
4429
|
-
icon ? /* @__PURE__ */ (0,
|
|
4046
|
+
return /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)(El, { className, children: [
|
|
4047
|
+
/* @__PURE__ */ (0, import_jsx_runtime18.jsxs)("div", { className: getClassName15("label"), children: [
|
|
4048
|
+
icon ? /* @__PURE__ */ (0, import_jsx_runtime18.jsx)("div", { className: getClassName15("labelIcon"), children: icon }) : /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(import_jsx_runtime18.Fragment, {}),
|
|
4430
4049
|
label,
|
|
4431
|
-
readOnly && /* @__PURE__ */ (0,
|
|
4050
|
+
readOnly && /* @__PURE__ */ (0, import_jsx_runtime18.jsx)("div", { className: getClassName15("disabledIcon"), title: "Read-only", children: /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(Lock, { size: "12" }) })
|
|
4432
4051
|
] }),
|
|
4433
4052
|
children
|
|
4434
4053
|
] });
|
|
@@ -4441,14 +4060,14 @@ var FieldLabelInternal = ({
|
|
|
4441
4060
|
readOnly
|
|
4442
4061
|
}) => {
|
|
4443
4062
|
const overrides = useAppStore((s) => s.overrides);
|
|
4444
|
-
const Wrapper = (0,
|
|
4063
|
+
const Wrapper = (0, import_react20.useMemo)(
|
|
4445
4064
|
() => overrides.fieldLabel || FieldLabel,
|
|
4446
4065
|
[overrides]
|
|
4447
4066
|
);
|
|
4448
4067
|
if (!label) {
|
|
4449
|
-
return /* @__PURE__ */ (0,
|
|
4068
|
+
return /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(import_jsx_runtime18.Fragment, { children });
|
|
4450
4069
|
}
|
|
4451
|
-
return /* @__PURE__ */ (0,
|
|
4070
|
+
return /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
|
|
4452
4071
|
Wrapper,
|
|
4453
4072
|
{
|
|
4454
4073
|
label,
|
|
@@ -4468,7 +4087,7 @@ function AutoFieldInternal(props) {
|
|
|
4468
4087
|
var _a2;
|
|
4469
4088
|
return (_a2 = s.selectedItem) == null ? void 0 : _a2.readOnly;
|
|
4470
4089
|
});
|
|
4471
|
-
const nestedFieldContext = (0,
|
|
4090
|
+
const nestedFieldContext = (0, import_react20.useContext)(NestedFieldContext);
|
|
4472
4091
|
const { id, Label: Label2 = FieldLabelInternal } = props;
|
|
4473
4092
|
const field = props.field;
|
|
4474
4093
|
const label = field.label;
|
|
@@ -4502,7 +4121,7 @@ function AutoFieldInternal(props) {
|
|
|
4502
4121
|
Label: Label2,
|
|
4503
4122
|
id: resolvedId
|
|
4504
4123
|
});
|
|
4505
|
-
const onFocus = (0,
|
|
4124
|
+
const onFocus = (0, import_react20.useCallback)(
|
|
4506
4125
|
(e) => {
|
|
4507
4126
|
if (mergedProps.name && (e.target.nodeName === "INPUT" || e.target.nodeName === "TEXTAREA")) {
|
|
4508
4127
|
e.stopPropagation();
|
|
@@ -4516,7 +4135,7 @@ function AutoFieldInternal(props) {
|
|
|
4516
4135
|
},
|
|
4517
4136
|
[mergedProps.name]
|
|
4518
4137
|
);
|
|
4519
|
-
const onBlur = (0,
|
|
4138
|
+
const onBlur = (0, import_react20.useCallback)((e) => {
|
|
4520
4139
|
if ("name" in e.target) {
|
|
4521
4140
|
dispatch({
|
|
4522
4141
|
type: "setUi",
|
|
@@ -4544,14 +4163,14 @@ function AutoFieldInternal(props) {
|
|
|
4544
4163
|
children = defaultFields[field.type](mergedProps);
|
|
4545
4164
|
FieldComponent = render[field.type];
|
|
4546
4165
|
}
|
|
4547
|
-
return /* @__PURE__ */ (0,
|
|
4166
|
+
return /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
|
|
4548
4167
|
NestedFieldContext.Provider,
|
|
4549
4168
|
{
|
|
4550
4169
|
value: {
|
|
4551
4170
|
readOnlyFields: nestedFieldContext.readOnlyFields || readOnly || {},
|
|
4552
4171
|
localName: (_i = nestedFieldContext.localName) != null ? _i : mergedProps.name
|
|
4553
4172
|
},
|
|
4554
|
-
children: /* @__PURE__ */ (0,
|
|
4173
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
|
|
4555
4174
|
"div",
|
|
4556
4175
|
{
|
|
4557
4176
|
className: getClassNameWrapper(),
|
|
@@ -4560,7 +4179,7 @@ function AutoFieldInternal(props) {
|
|
|
4560
4179
|
onClick: (e) => {
|
|
4561
4180
|
e.stopPropagation();
|
|
4562
4181
|
},
|
|
4563
|
-
children: /* @__PURE__ */ (0,
|
|
4182
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(FieldComponent, __spreadProps(__spreadValues({}, mergedProps), { children }))
|
|
4564
4183
|
}
|
|
4565
4184
|
)
|
|
4566
4185
|
}
|
|
@@ -4569,20 +4188,20 @@ function AutoFieldInternal(props) {
|
|
|
4569
4188
|
function AutoFieldPrivate(props) {
|
|
4570
4189
|
const isFocused = useAppStore((s) => s.state.ui.field.focus === props.name);
|
|
4571
4190
|
const { value, onChange } = props;
|
|
4572
|
-
const [localValue, setLocalValue] = (0,
|
|
4573
|
-
const onChangeLocal = (0,
|
|
4191
|
+
const [localValue, setLocalValue] = (0, import_react20.useState)(value);
|
|
4192
|
+
const onChangeLocal = (0, import_react20.useCallback)(
|
|
4574
4193
|
(val, ui) => {
|
|
4575
4194
|
setLocalValue(val);
|
|
4576
4195
|
onChange(val, ui);
|
|
4577
4196
|
},
|
|
4578
4197
|
[onChange]
|
|
4579
4198
|
);
|
|
4580
|
-
(0,
|
|
4199
|
+
(0, import_react20.useEffect)(() => {
|
|
4581
4200
|
if (!isFocused) {
|
|
4582
4201
|
setLocalValue(value);
|
|
4583
4202
|
}
|
|
4584
4203
|
}, [value]);
|
|
4585
|
-
(0,
|
|
4204
|
+
(0, import_react20.useEffect)(() => {
|
|
4586
4205
|
if (!isFocused) {
|
|
4587
4206
|
if (value !== localValue) {
|
|
4588
4207
|
setLocalValue(value);
|
|
@@ -4593,11 +4212,11 @@ function AutoFieldPrivate(props) {
|
|
|
4593
4212
|
value: localValue,
|
|
4594
4213
|
onChange: onChangeLocal
|
|
4595
4214
|
};
|
|
4596
|
-
return /* @__PURE__ */ (0,
|
|
4215
|
+
return /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(AutoFieldInternal, __spreadValues(__spreadValues({}, props), localProps));
|
|
4597
4216
|
}
|
|
4598
4217
|
function AutoField(props) {
|
|
4599
|
-
const DefaultLabel = (0,
|
|
4600
|
-
const DefaultLabel2 = (labelProps) => /* @__PURE__ */ (0,
|
|
4218
|
+
const DefaultLabel = (0, import_react20.useMemo)(() => {
|
|
4219
|
+
const DefaultLabel2 = (labelProps) => /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
|
|
4601
4220
|
"div",
|
|
4602
4221
|
__spreadProps(__spreadValues({}, labelProps), {
|
|
4603
4222
|
className: getClassName15({ readOnly: props.readOnly })
|
|
@@ -4608,7 +4227,7 @@ function AutoField(props) {
|
|
|
4608
4227
|
if (props.field.type === "slot") {
|
|
4609
4228
|
return null;
|
|
4610
4229
|
}
|
|
4611
|
-
return /* @__PURE__ */ (0,
|
|
4230
|
+
return /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(AutoFieldInternal, __spreadProps(__spreadValues({}, props), { Label: DefaultLabel }));
|
|
4612
4231
|
}
|
|
4613
4232
|
|
|
4614
4233
|
// components/Drawer/index.tsx
|
|
@@ -4619,21 +4238,21 @@ init_react_import();
|
|
|
4619
4238
|
var styles_module_default10 = { "Drawer": "_Drawer_pl7z0_1", "Drawer-draggable": "_Drawer-draggable_pl7z0_8", "Drawer-draggableBg": "_Drawer-draggableBg_pl7z0_12", "DrawerItem-draggable": "_DrawerItem-draggable_pl7z0_22", "DrawerItem--disabled": "_DrawerItem--disabled_pl7z0_35", "DrawerItem": "_DrawerItem_pl7z0_22", "Drawer--isDraggingFrom": "_Drawer--isDraggingFrom_pl7z0_45", "DrawerItem-name": "_DrawerItem-name_pl7z0_63" };
|
|
4620
4239
|
|
|
4621
4240
|
// components/Drawer/index.tsx
|
|
4622
|
-
var
|
|
4241
|
+
var import_react37 = require("react");
|
|
4623
4242
|
|
|
4624
4243
|
// components/DragDropContext/index.tsx
|
|
4625
4244
|
init_react_import();
|
|
4626
|
-
var
|
|
4627
|
-
var
|
|
4245
|
+
var import_react35 = require("@dnd-kit/react");
|
|
4246
|
+
var import_react36 = require("react");
|
|
4628
4247
|
var import_dom = require("@dnd-kit/dom");
|
|
4629
4248
|
|
|
4630
4249
|
// components/DropZone/index.tsx
|
|
4631
4250
|
init_react_import();
|
|
4632
|
-
var
|
|
4251
|
+
var import_react33 = require("react");
|
|
4633
4252
|
|
|
4634
4253
|
// components/DraggableComponent/index.tsx
|
|
4635
4254
|
init_react_import();
|
|
4636
|
-
var
|
|
4255
|
+
var import_react24 = require("react");
|
|
4637
4256
|
|
|
4638
4257
|
// css-module:/home/runner/work/puck/puck/packages/core/components/DraggableComponent/styles.module.css#css-module
|
|
4639
4258
|
init_react_import();
|
|
@@ -4663,11 +4282,11 @@ function getDeepScrollPosition(element) {
|
|
|
4663
4282
|
|
|
4664
4283
|
// components/DropZone/context.tsx
|
|
4665
4284
|
init_react_import();
|
|
4666
|
-
var
|
|
4285
|
+
var import_react21 = require("react");
|
|
4667
4286
|
var import_zustand3 = require("zustand");
|
|
4668
|
-
var
|
|
4669
|
-
var dropZoneContext = (0,
|
|
4670
|
-
var ZoneStoreContext = (0,
|
|
4287
|
+
var import_jsx_runtime19 = require("react/jsx-runtime");
|
|
4288
|
+
var dropZoneContext = (0, import_react21.createContext)(null);
|
|
4289
|
+
var ZoneStoreContext = (0, import_react21.createContext)(
|
|
4671
4290
|
(0, import_zustand3.createStore)(() => ({
|
|
4672
4291
|
zoneDepthIndex: {},
|
|
4673
4292
|
nextZoneDepthIndex: {},
|
|
@@ -4683,14 +4302,14 @@ var ZoneStoreProvider = ({
|
|
|
4683
4302
|
children,
|
|
4684
4303
|
store
|
|
4685
4304
|
}) => {
|
|
4686
|
-
return /* @__PURE__ */ (0,
|
|
4305
|
+
return /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(ZoneStoreContext.Provider, { value: store, children });
|
|
4687
4306
|
};
|
|
4688
4307
|
var DropZoneProvider = ({
|
|
4689
4308
|
children,
|
|
4690
4309
|
value
|
|
4691
4310
|
}) => {
|
|
4692
4311
|
const dispatch = useAppStore((s) => s.dispatch);
|
|
4693
|
-
const registerZone = (0,
|
|
4312
|
+
const registerZone = (0, import_react21.useCallback)(
|
|
4694
4313
|
(zoneCompound) => {
|
|
4695
4314
|
dispatch({
|
|
4696
4315
|
type: "registerZone",
|
|
@@ -4699,13 +4318,13 @@ var DropZoneProvider = ({
|
|
|
4699
4318
|
},
|
|
4700
4319
|
[dispatch]
|
|
4701
4320
|
);
|
|
4702
|
-
const memoValue = (0,
|
|
4321
|
+
const memoValue = (0, import_react21.useMemo)(
|
|
4703
4322
|
() => __spreadValues({
|
|
4704
4323
|
registerZone
|
|
4705
4324
|
}, value),
|
|
4706
4325
|
[value]
|
|
4707
4326
|
);
|
|
4708
|
-
return /* @__PURE__ */ (0,
|
|
4327
|
+
return /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(import_jsx_runtime19.Fragment, { children: memoValue && /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(dropZoneContext.Provider, { value: memoValue, children }) });
|
|
4709
4328
|
};
|
|
4710
4329
|
|
|
4711
4330
|
// components/DraggableComponent/index.tsx
|
|
@@ -4729,11 +4348,11 @@ function accumulateTransform(el) {
|
|
|
4729
4348
|
|
|
4730
4349
|
// lib/use-context-store.ts
|
|
4731
4350
|
init_react_import();
|
|
4732
|
-
var
|
|
4351
|
+
var import_react22 = require("react");
|
|
4733
4352
|
var import_zustand4 = require("zustand");
|
|
4734
4353
|
var import_shallow = require("zustand/react/shallow");
|
|
4735
4354
|
function useContextStore(context, selector) {
|
|
4736
|
-
const store = (0,
|
|
4355
|
+
const store = (0, import_react22.useContext)(context);
|
|
4737
4356
|
if (!store) {
|
|
4738
4357
|
throw new Error("useContextStore must be used inside context");
|
|
4739
4358
|
}
|
|
@@ -4742,10 +4361,10 @@ function useContextStore(context, selector) {
|
|
|
4742
4361
|
|
|
4743
4362
|
// lib/dnd/use-on-drag-finished.ts
|
|
4744
4363
|
init_react_import();
|
|
4745
|
-
var
|
|
4364
|
+
var import_react23 = require("react");
|
|
4746
4365
|
var useOnDragFinished = (cb, deps = []) => {
|
|
4747
4366
|
const appStore = useAppStoreApi();
|
|
4748
|
-
return (0,
|
|
4367
|
+
return (0, import_react23.useCallback)(() => {
|
|
4749
4368
|
let dispose = () => {
|
|
4750
4369
|
};
|
|
4751
4370
|
const processDragging = (isDragging2) => {
|
|
@@ -4773,7 +4392,7 @@ var useOnDragFinished = (cb, deps = []) => {
|
|
|
4773
4392
|
};
|
|
4774
4393
|
|
|
4775
4394
|
// components/DraggableComponent/index.tsx
|
|
4776
|
-
var
|
|
4395
|
+
var import_jsx_runtime20 = require("react/jsx-runtime");
|
|
4777
4396
|
var getClassName16 = get_class_name_factory_default("DraggableComponent", styles_module_default11);
|
|
4778
4397
|
var DEBUG2 = false;
|
|
4779
4398
|
var space = 8;
|
|
@@ -4784,12 +4403,12 @@ var DefaultActionBar = ({
|
|
|
4784
4403
|
label,
|
|
4785
4404
|
children,
|
|
4786
4405
|
parentAction
|
|
4787
|
-
}) => /* @__PURE__ */ (0,
|
|
4788
|
-
/* @__PURE__ */ (0,
|
|
4406
|
+
}) => /* @__PURE__ */ (0, import_jsx_runtime20.jsxs)(ActionBar, { children: [
|
|
4407
|
+
/* @__PURE__ */ (0, import_jsx_runtime20.jsxs)(ActionBar.Group, { children: [
|
|
4789
4408
|
parentAction,
|
|
4790
|
-
label && /* @__PURE__ */ (0,
|
|
4409
|
+
label && /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(ActionBar.Label, { label })
|
|
4791
4410
|
] }),
|
|
4792
|
-
/* @__PURE__ */ (0,
|
|
4411
|
+
/* @__PURE__ */ (0, import_jsx_runtime20.jsx)(ActionBar.Group, { children })
|
|
4793
4412
|
] });
|
|
4794
4413
|
var DraggableComponent = ({
|
|
4795
4414
|
children,
|
|
@@ -4815,9 +4434,9 @@ var DraggableComponent = ({
|
|
|
4815
4434
|
const overrides = useAppStore((s) => s.overrides);
|
|
4816
4435
|
const dispatch = useAppStore((s) => s.dispatch);
|
|
4817
4436
|
const iframe = useAppStore((s) => s.iframe);
|
|
4818
|
-
const ctx = (0,
|
|
4819
|
-
const [localZones, setLocalZones] = (0,
|
|
4820
|
-
const registerLocalZone = (0,
|
|
4437
|
+
const ctx = (0, import_react24.useContext)(dropZoneContext);
|
|
4438
|
+
const [localZones, setLocalZones] = (0, import_react24.useState)({});
|
|
4439
|
+
const registerLocalZone = (0, import_react24.useCallback)(
|
|
4821
4440
|
(zoneCompound2, active) => {
|
|
4822
4441
|
var _a;
|
|
4823
4442
|
(_a = ctx == null ? void 0 : ctx.registerLocalZone) == null ? void 0 : _a.call(ctx, zoneCompound2, active);
|
|
@@ -4827,7 +4446,7 @@ var DraggableComponent = ({
|
|
|
4827
4446
|
},
|
|
4828
4447
|
[setLocalZones]
|
|
4829
4448
|
);
|
|
4830
|
-
const unregisterLocalZone = (0,
|
|
4449
|
+
const unregisterLocalZone = (0, import_react24.useCallback)(
|
|
4831
4450
|
(zoneCompound2) => {
|
|
4832
4451
|
var _a;
|
|
4833
4452
|
(_a = ctx == null ? void 0 : ctx.unregisterLocalZone) == null ? void 0 : _a.call(ctx, zoneCompound2);
|
|
@@ -4850,9 +4469,9 @@ var DraggableComponent = ({
|
|
|
4850
4469
|
return s.permissions.getPermissions({ item });
|
|
4851
4470
|
})
|
|
4852
4471
|
);
|
|
4853
|
-
const zoneStore = (0,
|
|
4854
|
-
const [dragAxis, setDragAxis] = (0,
|
|
4855
|
-
const dynamicCollisionDetector = (0,
|
|
4472
|
+
const zoneStore = (0, import_react24.useContext)(ZoneStoreContext);
|
|
4473
|
+
const [dragAxis, setDragAxis] = (0, import_react24.useState)(userDragAxis || autoDragAxis);
|
|
4474
|
+
const dynamicCollisionDetector = (0, import_react24.useMemo)(
|
|
4856
4475
|
() => createDynamicCollisionDetector(dragAxis),
|
|
4857
4476
|
[dragAxis]
|
|
4858
4477
|
);
|
|
@@ -4884,7 +4503,7 @@ var DraggableComponent = ({
|
|
|
4884
4503
|
},
|
|
4885
4504
|
feedback: "clone"
|
|
4886
4505
|
});
|
|
4887
|
-
(0,
|
|
4506
|
+
(0, import_react24.useEffect)(() => {
|
|
4888
4507
|
const isEnabled = zoneStore.getState().enabledIndex[zoneCompound];
|
|
4889
4508
|
sortable.droppable.disabled = !isEnabled;
|
|
4890
4509
|
sortable.draggable.disabled = !permissions.drag;
|
|
@@ -4901,8 +4520,8 @@ var DraggableComponent = ({
|
|
|
4901
4520
|
}
|
|
4902
4521
|
return cleanup;
|
|
4903
4522
|
}, [permissions.drag, zoneCompound]);
|
|
4904
|
-
const ref = (0,
|
|
4905
|
-
const refSetter = (0,
|
|
4523
|
+
const ref = (0, import_react24.useRef)(null);
|
|
4524
|
+
const refSetter = (0, import_react24.useCallback)(
|
|
4906
4525
|
(el) => {
|
|
4907
4526
|
sortableRef(el);
|
|
4908
4527
|
if (el) {
|
|
@@ -4911,14 +4530,14 @@ var DraggableComponent = ({
|
|
|
4911
4530
|
},
|
|
4912
4531
|
[sortableRef]
|
|
4913
4532
|
);
|
|
4914
|
-
const [portalEl, setPortalEl] = (0,
|
|
4915
|
-
(0,
|
|
4533
|
+
const [portalEl, setPortalEl] = (0, import_react24.useState)();
|
|
4534
|
+
(0, import_react24.useEffect)(() => {
|
|
4916
4535
|
var _a, _b, _c;
|
|
4917
4536
|
setPortalEl(
|
|
4918
4537
|
iframe.enabled ? (_a = ref.current) == null ? void 0 : _a.ownerDocument.body : (_c = (_b = ref.current) == null ? void 0 : _b.closest("[data-puck-preview]")) != null ? _c : document.body
|
|
4919
4538
|
);
|
|
4920
4539
|
}, [iframe.enabled, ref.current]);
|
|
4921
|
-
const getStyle = (0,
|
|
4540
|
+
const getStyle = (0, import_react24.useCallback)(() => {
|
|
4922
4541
|
var _a, _b, _c;
|
|
4923
4542
|
if (!ref.current) return;
|
|
4924
4543
|
const rect = ref.current.getBoundingClientRect();
|
|
@@ -4943,11 +4562,11 @@ var DraggableComponent = ({
|
|
|
4943
4562
|
};
|
|
4944
4563
|
return style2;
|
|
4945
4564
|
}, [ref.current]);
|
|
4946
|
-
const [style, setStyle] = (0,
|
|
4947
|
-
const sync = (0,
|
|
4565
|
+
const [style, setStyle] = (0, import_react24.useState)();
|
|
4566
|
+
const sync = (0, import_react24.useCallback)(() => {
|
|
4948
4567
|
setStyle(getStyle());
|
|
4949
4568
|
}, [ref.current, iframe]);
|
|
4950
|
-
(0,
|
|
4569
|
+
(0, import_react24.useEffect)(() => {
|
|
4951
4570
|
if (ref.current) {
|
|
4952
4571
|
const observer = new ResizeObserver(sync);
|
|
4953
4572
|
observer.observe(ref.current);
|
|
@@ -4957,13 +4576,13 @@ var DraggableComponent = ({
|
|
|
4957
4576
|
}
|
|
4958
4577
|
}, [ref.current]);
|
|
4959
4578
|
const registerNode = useAppStore((s) => s.nodes.registerNode);
|
|
4960
|
-
const hideOverlay = (0,
|
|
4579
|
+
const hideOverlay = (0, import_react24.useCallback)(() => {
|
|
4961
4580
|
setIsVisible(false);
|
|
4962
4581
|
}, []);
|
|
4963
|
-
const showOverlay = (0,
|
|
4582
|
+
const showOverlay = (0, import_react24.useCallback)(() => {
|
|
4964
4583
|
setIsVisible(true);
|
|
4965
4584
|
}, []);
|
|
4966
|
-
(0,
|
|
4585
|
+
(0, import_react24.useEffect)(() => {
|
|
4967
4586
|
var _a;
|
|
4968
4587
|
registerNode(id, {
|
|
4969
4588
|
methods: { sync, showOverlay, hideOverlay },
|
|
@@ -4980,11 +4599,11 @@ var DraggableComponent = ({
|
|
|
4980
4599
|
});
|
|
4981
4600
|
};
|
|
4982
4601
|
}, [id, zoneCompound, index, componentType, sync]);
|
|
4983
|
-
const CustomActionBar = (0,
|
|
4602
|
+
const CustomActionBar = (0, import_react24.useMemo)(
|
|
4984
4603
|
() => overrides.actionBar || DefaultActionBar,
|
|
4985
4604
|
[overrides.actionBar]
|
|
4986
4605
|
);
|
|
4987
|
-
const onClick = (0,
|
|
4606
|
+
const onClick = (0, import_react24.useCallback)(
|
|
4988
4607
|
(e) => {
|
|
4989
4608
|
e.stopPropagation();
|
|
4990
4609
|
dispatch({
|
|
@@ -4997,7 +4616,7 @@ var DraggableComponent = ({
|
|
|
4997
4616
|
[index, zoneCompound, id]
|
|
4998
4617
|
);
|
|
4999
4618
|
const appStore = useAppStoreApi();
|
|
5000
|
-
const onSelectParent = (0,
|
|
4619
|
+
const onSelectParent = (0, import_react24.useCallback)(() => {
|
|
5001
4620
|
const { nodes, zones } = appStore.getState().state.indexes;
|
|
5002
4621
|
const node = nodes[id];
|
|
5003
4622
|
const parentNode = (node == null ? void 0 : node.parentId) ? nodes[node == null ? void 0 : node.parentId] : null;
|
|
@@ -5018,26 +4637,26 @@ var DraggableComponent = ({
|
|
|
5018
4637
|
}
|
|
5019
4638
|
});
|
|
5020
4639
|
}, [ctx, path]);
|
|
5021
|
-
const onDuplicate = (0,
|
|
4640
|
+
const onDuplicate = (0, import_react24.useCallback)(() => {
|
|
5022
4641
|
dispatch({
|
|
5023
4642
|
type: "duplicate",
|
|
5024
4643
|
sourceIndex: index,
|
|
5025
4644
|
sourceZone: zoneCompound
|
|
5026
4645
|
});
|
|
5027
4646
|
}, [index, zoneCompound]);
|
|
5028
|
-
const onDelete = (0,
|
|
4647
|
+
const onDelete = (0, import_react24.useCallback)(() => {
|
|
5029
4648
|
dispatch({
|
|
5030
4649
|
type: "remove",
|
|
5031
4650
|
index,
|
|
5032
4651
|
zone: zoneCompound
|
|
5033
4652
|
});
|
|
5034
4653
|
}, [index, zoneCompound]);
|
|
5035
|
-
const [hover, setHover] = (0,
|
|
4654
|
+
const [hover, setHover] = (0, import_react24.useState)(false);
|
|
5036
4655
|
const indicativeHover = useContextStore(
|
|
5037
4656
|
ZoneStoreContext,
|
|
5038
4657
|
(s) => s.hoveringComponent === id
|
|
5039
4658
|
);
|
|
5040
|
-
(0,
|
|
4659
|
+
(0, import_react24.useEffect)(() => {
|
|
5041
4660
|
if (!ref.current) {
|
|
5042
4661
|
return;
|
|
5043
4662
|
}
|
|
@@ -5073,7 +4692,8 @@ var DraggableComponent = ({
|
|
|
5073
4692
|
el.removeEventListener("mouseout", _onMouseOut);
|
|
5074
4693
|
};
|
|
5075
4694
|
}, [
|
|
5076
|
-
ref,
|
|
4695
|
+
ref.current,
|
|
4696
|
+
// Remount attributes if the element changes
|
|
5077
4697
|
onClick,
|
|
5078
4698
|
containsActiveZone,
|
|
5079
4699
|
zoneCompound,
|
|
@@ -5081,10 +4701,10 @@ var DraggableComponent = ({
|
|
|
5081
4701
|
thisIsDragging,
|
|
5082
4702
|
inDroppableZone
|
|
5083
4703
|
]);
|
|
5084
|
-
const [isVisible, setIsVisible] = (0,
|
|
5085
|
-
const [dragFinished, setDragFinished] = (0,
|
|
5086
|
-
const [_, startTransition] = (0,
|
|
5087
|
-
(0,
|
|
4704
|
+
const [isVisible, setIsVisible] = (0, import_react24.useState)(false);
|
|
4705
|
+
const [dragFinished, setDragFinished] = (0, import_react24.useState)(true);
|
|
4706
|
+
const [_, startTransition] = (0, import_react24.useTransition)();
|
|
4707
|
+
(0, import_react24.useEffect)(() => {
|
|
5088
4708
|
startTransition(() => {
|
|
5089
4709
|
if (hover || indicativeHover || isSelected) {
|
|
5090
4710
|
sync();
|
|
@@ -5095,7 +4715,7 @@ var DraggableComponent = ({
|
|
|
5095
4715
|
}
|
|
5096
4716
|
});
|
|
5097
4717
|
}, [hover, indicativeHover, isSelected, iframe]);
|
|
5098
|
-
const [thisWasDragging, setThisWasDragging] = (0,
|
|
4718
|
+
const [thisWasDragging, setThisWasDragging] = (0, import_react24.useState)(false);
|
|
5099
4719
|
const onDragFinished = useOnDragFinished((finished) => {
|
|
5100
4720
|
if (finished) {
|
|
5101
4721
|
startTransition(() => {
|
|
@@ -5106,15 +4726,15 @@ var DraggableComponent = ({
|
|
|
5106
4726
|
setDragFinished(false);
|
|
5107
4727
|
}
|
|
5108
4728
|
});
|
|
5109
|
-
(0,
|
|
4729
|
+
(0, import_react24.useEffect)(() => {
|
|
5110
4730
|
if (thisIsDragging) {
|
|
5111
4731
|
setThisWasDragging(true);
|
|
5112
4732
|
}
|
|
5113
4733
|
}, [thisIsDragging]);
|
|
5114
|
-
(0,
|
|
4734
|
+
(0, import_react24.useEffect)(() => {
|
|
5115
4735
|
if (thisWasDragging) return onDragFinished();
|
|
5116
4736
|
}, [thisWasDragging, onDragFinished]);
|
|
5117
|
-
const syncActionsPosition = (0,
|
|
4737
|
+
const syncActionsPosition = (0, import_react24.useCallback)(
|
|
5118
4738
|
(el) => {
|
|
5119
4739
|
if (el) {
|
|
5120
4740
|
const view = el.ownerDocument.defaultView;
|
|
@@ -5139,7 +4759,7 @@ var DraggableComponent = ({
|
|
|
5139
4759
|
},
|
|
5140
4760
|
[zoom]
|
|
5141
4761
|
);
|
|
5142
|
-
(0,
|
|
4762
|
+
(0, import_react24.useEffect)(() => {
|
|
5143
4763
|
if (userDragAxis) {
|
|
5144
4764
|
setDragAxis(userDragAxis);
|
|
5145
4765
|
return;
|
|
@@ -5153,11 +4773,11 @@ var DraggableComponent = ({
|
|
|
5153
4773
|
}
|
|
5154
4774
|
setDragAxis(autoDragAxis);
|
|
5155
4775
|
}, [ref, userDragAxis, autoDragAxis]);
|
|
5156
|
-
const parentAction = (0,
|
|
5157
|
-
() => (ctx == null ? void 0 : ctx.areaId) && (ctx == null ? void 0 : ctx.areaId) !== "root" && /* @__PURE__ */ (0,
|
|
4776
|
+
const parentAction = (0, import_react24.useMemo)(
|
|
4777
|
+
() => (ctx == null ? void 0 : ctx.areaId) && (ctx == null ? void 0 : ctx.areaId) !== "root" && /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(ActionBar.Action, { onClick: onSelectParent, label: "Select parent", children: /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(CornerLeftUp, { size: 16 }) }),
|
|
5158
4778
|
[ctx == null ? void 0 : ctx.areaId]
|
|
5159
4779
|
);
|
|
5160
|
-
const nextContextValue = (0,
|
|
4780
|
+
const nextContextValue = (0, import_react24.useMemo)(
|
|
5161
4781
|
() => __spreadProps(__spreadValues({}, ctx), {
|
|
5162
4782
|
areaId: id,
|
|
5163
4783
|
zoneCompound,
|
|
@@ -5176,9 +4796,9 @@ var DraggableComponent = ({
|
|
|
5176
4796
|
unregisterLocalZone
|
|
5177
4797
|
]
|
|
5178
4798
|
);
|
|
5179
|
-
return /* @__PURE__ */ (0,
|
|
4799
|
+
return /* @__PURE__ */ (0, import_jsx_runtime20.jsxs)(DropZoneProvider, { value: nextContextValue, children: [
|
|
5180
4800
|
dragFinished && isVisible && (0, import_react_dom2.createPortal)(
|
|
5181
|
-
/* @__PURE__ */ (0,
|
|
4801
|
+
/* @__PURE__ */ (0, import_jsx_runtime20.jsxs)(
|
|
5182
4802
|
"div",
|
|
5183
4803
|
{
|
|
5184
4804
|
className: getClassName16({
|
|
@@ -5190,15 +4810,15 @@ var DraggableComponent = ({
|
|
|
5190
4810
|
"data-puck-overlay": true,
|
|
5191
4811
|
children: [
|
|
5192
4812
|
debug,
|
|
5193
|
-
isLoading && /* @__PURE__ */ (0,
|
|
5194
|
-
/* @__PURE__ */ (0,
|
|
4813
|
+
isLoading && /* @__PURE__ */ (0, import_jsx_runtime20.jsx)("div", { className: getClassName16("loadingOverlay"), children: /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(Loader, {}) }),
|
|
4814
|
+
/* @__PURE__ */ (0, import_jsx_runtime20.jsx)(
|
|
5195
4815
|
"div",
|
|
5196
4816
|
{
|
|
5197
4817
|
className: getClassName16("actionsOverlay"),
|
|
5198
4818
|
style: {
|
|
5199
4819
|
top: actionsOverlayTop / zoom
|
|
5200
4820
|
},
|
|
5201
|
-
children: /* @__PURE__ */ (0,
|
|
4821
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(
|
|
5202
4822
|
"div",
|
|
5203
4823
|
{
|
|
5204
4824
|
className: getClassName16("actions"),
|
|
@@ -5210,14 +4830,14 @@ var DraggableComponent = ({
|
|
|
5210
4830
|
paddingRight: actionsSide
|
|
5211
4831
|
},
|
|
5212
4832
|
ref: syncActionsPosition,
|
|
5213
|
-
children: /* @__PURE__ */ (0,
|
|
4833
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime20.jsxs)(
|
|
5214
4834
|
CustomActionBar,
|
|
5215
4835
|
{
|
|
5216
4836
|
parentAction,
|
|
5217
4837
|
label: DEBUG2 ? id : label,
|
|
5218
4838
|
children: [
|
|
5219
|
-
permissions.duplicate && /* @__PURE__ */ (0,
|
|
5220
|
-
permissions.delete && /* @__PURE__ */ (0,
|
|
4839
|
+
permissions.duplicate && /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(ActionBar.Action, { onClick: onDuplicate, label: "Duplicate", children: /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(Copy, { size: 16 }) }),
|
|
4840
|
+
permissions.delete && /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(ActionBar.Action, { onClick: onDelete, label: "Delete", children: /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(Trash, { size: 16 }) })
|
|
5221
4841
|
]
|
|
5222
4842
|
}
|
|
5223
4843
|
)
|
|
@@ -5225,7 +4845,7 @@ var DraggableComponent = ({
|
|
|
5225
4845
|
)
|
|
5226
4846
|
}
|
|
5227
4847
|
),
|
|
5228
|
-
/* @__PURE__ */ (0,
|
|
4848
|
+
/* @__PURE__ */ (0, import_jsx_runtime20.jsx)("div", { className: getClassName16("overlay") })
|
|
5229
4849
|
]
|
|
5230
4850
|
}
|
|
5231
4851
|
),
|
|
@@ -5240,11 +4860,11 @@ init_react_import();
|
|
|
5240
4860
|
var styles_module_default12 = { "DropZone": "_DropZone_1i2sv_1", "DropZone--hasChildren": "_DropZone--hasChildren_1i2sv_11", "DropZone--isAreaSelected": "_DropZone--isAreaSelected_1i2sv_24", "DropZone--hoveringOverArea": "_DropZone--hoveringOverArea_1i2sv_25", "DropZone--isRootZone": "_DropZone--isRootZone_1i2sv_25", "DropZone--isDestination": "_DropZone--isDestination_1i2sv_35", "DropZone-item": "_DropZone-item_1i2sv_47", "DropZone-hitbox": "_DropZone-hitbox_1i2sv_51", "DropZone--isEnabled": "_DropZone--isEnabled_1i2sv_59", "DropZone--isAnimating": "_DropZone--isAnimating_1i2sv_68" };
|
|
5241
4861
|
|
|
5242
4862
|
// components/DropZone/index.tsx
|
|
5243
|
-
var
|
|
4863
|
+
var import_react34 = require("@dnd-kit/react");
|
|
5244
4864
|
|
|
5245
4865
|
// components/DropZone/lib/use-min-empty-height.ts
|
|
5246
4866
|
init_react_import();
|
|
5247
|
-
var
|
|
4867
|
+
var import_react25 = require("react");
|
|
5248
4868
|
var getNumItems = (appStore, zoneCompound) => appStore.getState().state.indexes.zones[zoneCompound].contentIds.length;
|
|
5249
4869
|
var useMinEmptyHeight = ({
|
|
5250
4870
|
zoneCompound,
|
|
@@ -5252,8 +4872,8 @@ var useMinEmptyHeight = ({
|
|
|
5252
4872
|
ref
|
|
5253
4873
|
}) => {
|
|
5254
4874
|
const appStore = useAppStoreApi();
|
|
5255
|
-
const [prevHeight, setPrevHeight] = (0,
|
|
5256
|
-
const [isAnimating, setIsAnimating] = (0,
|
|
4875
|
+
const [prevHeight, setPrevHeight] = (0, import_react25.useState)(0);
|
|
4876
|
+
const [isAnimating, setIsAnimating] = (0, import_react25.useState)(false);
|
|
5257
4877
|
const { draggedItem, isZone } = useContextStore(ZoneStoreContext, (s) => {
|
|
5258
4878
|
var _a, _b;
|
|
5259
4879
|
return {
|
|
@@ -5261,7 +4881,7 @@ var useMinEmptyHeight = ({
|
|
|
5261
4881
|
isZone: ((_b = s.draggedItem) == null ? void 0 : _b.data.zone) === zoneCompound
|
|
5262
4882
|
};
|
|
5263
4883
|
});
|
|
5264
|
-
const numItems = (0,
|
|
4884
|
+
const numItems = (0, import_react25.useRef)(0);
|
|
5265
4885
|
const onDragFinished = useOnDragFinished(
|
|
5266
4886
|
(finished) => {
|
|
5267
4887
|
var _a;
|
|
@@ -5296,7 +4916,7 @@ var useMinEmptyHeight = ({
|
|
|
5296
4916
|
},
|
|
5297
4917
|
[appStore, prevHeight, zoneCompound]
|
|
5298
4918
|
);
|
|
5299
|
-
(0,
|
|
4919
|
+
(0, import_react25.useEffect)(() => {
|
|
5300
4920
|
if (draggedItem && ref.current) {
|
|
5301
4921
|
if (isZone) {
|
|
5302
4922
|
const rect = ref.current.getBoundingClientRect();
|
|
@@ -5327,15 +4947,15 @@ function assignRefs(refs, node) {
|
|
|
5327
4947
|
|
|
5328
4948
|
// components/DropZone/lib/use-content-with-preview.ts
|
|
5329
4949
|
init_react_import();
|
|
5330
|
-
var
|
|
4950
|
+
var import_react28 = require("react");
|
|
5331
4951
|
|
|
5332
4952
|
// lib/dnd/use-rendered-callback.ts
|
|
5333
4953
|
init_react_import();
|
|
5334
|
-
var
|
|
5335
|
-
var
|
|
4954
|
+
var import_react26 = require("@dnd-kit/react");
|
|
4955
|
+
var import_react27 = require("react");
|
|
5336
4956
|
function useRenderedCallback(callback, deps) {
|
|
5337
|
-
const manager = (0,
|
|
5338
|
-
return (0,
|
|
4957
|
+
const manager = (0, import_react26.useDragDropManager)();
|
|
4958
|
+
return (0, import_react27.useCallback)(
|
|
5339
4959
|
(...args) => __async(this, null, function* () {
|
|
5340
4960
|
yield manager == null ? void 0 : manager.renderer.rendering;
|
|
5341
4961
|
return callback(...args);
|
|
@@ -5346,14 +4966,14 @@ function useRenderedCallback(callback, deps) {
|
|
|
5346
4966
|
|
|
5347
4967
|
// components/DropZone/lib/use-content-with-preview.ts
|
|
5348
4968
|
var useContentIdsWithPreview = (contentIds, zoneCompound) => {
|
|
5349
|
-
const zoneStore = (0,
|
|
4969
|
+
const zoneStore = (0, import_react28.useContext)(ZoneStoreContext);
|
|
5350
4970
|
const preview = useContextStore(
|
|
5351
4971
|
ZoneStoreContext,
|
|
5352
4972
|
(s) => s.previewIndex[zoneCompound]
|
|
5353
4973
|
);
|
|
5354
4974
|
const isDragging = useAppStore((s) => s.state.ui.isDragging);
|
|
5355
|
-
const [contentIdsWithPreview, setContentIdsWithPreview] = (0,
|
|
5356
|
-
const [localPreview, setLocalPreview] = (0,
|
|
4975
|
+
const [contentIdsWithPreview, setContentIdsWithPreview] = (0, import_react28.useState)(contentIds);
|
|
4976
|
+
const [localPreview, setLocalPreview] = (0, import_react28.useState)(
|
|
5357
4977
|
preview
|
|
5358
4978
|
);
|
|
5359
4979
|
const updateContent = useRenderedCallback(
|
|
@@ -5388,7 +5008,7 @@ var useContentIdsWithPreview = (contentIds, zoneCompound) => {
|
|
|
5388
5008
|
},
|
|
5389
5009
|
[]
|
|
5390
5010
|
);
|
|
5391
|
-
(0,
|
|
5011
|
+
(0, import_react28.useEffect)(() => {
|
|
5392
5012
|
var _a;
|
|
5393
5013
|
const s = zoneStore.getState();
|
|
5394
5014
|
const draggedItemId = (_a = s.draggedItem) == null ? void 0 : _a.id;
|
|
@@ -5406,16 +5026,16 @@ var useContentIdsWithPreview = (contentIds, zoneCompound) => {
|
|
|
5406
5026
|
|
|
5407
5027
|
// components/DropZone/lib/use-drag-axis.ts
|
|
5408
5028
|
init_react_import();
|
|
5409
|
-
var
|
|
5029
|
+
var import_react29 = require("react");
|
|
5410
5030
|
var GRID_DRAG_AXIS = "dynamic";
|
|
5411
5031
|
var FLEX_ROW_DRAG_AXIS = "x";
|
|
5412
5032
|
var DEFAULT_DRAG_AXIS = "y";
|
|
5413
5033
|
var useDragAxis = (ref, collisionAxis) => {
|
|
5414
5034
|
const status = useAppStore((s) => s.status);
|
|
5415
|
-
const [dragAxis, setDragAxis] = (0,
|
|
5035
|
+
const [dragAxis, setDragAxis] = (0, import_react29.useState)(
|
|
5416
5036
|
collisionAxis || DEFAULT_DRAG_AXIS
|
|
5417
5037
|
);
|
|
5418
|
-
const calculateDragAxis = (0,
|
|
5038
|
+
const calculateDragAxis = (0, import_react29.useCallback)(() => {
|
|
5419
5039
|
if (ref.current) {
|
|
5420
5040
|
const computedStyle = window.getComputedStyle(ref.current);
|
|
5421
5041
|
if (computedStyle.display === "grid") {
|
|
@@ -5427,7 +5047,7 @@ var useDragAxis = (ref, collisionAxis) => {
|
|
|
5427
5047
|
}
|
|
5428
5048
|
}
|
|
5429
5049
|
}, [ref.current]);
|
|
5430
|
-
(0,
|
|
5050
|
+
(0, import_react29.useEffect)(() => {
|
|
5431
5051
|
const onViewportChange = () => {
|
|
5432
5052
|
calculateDragAxis();
|
|
5433
5053
|
};
|
|
@@ -5436,7 +5056,7 @@ var useDragAxis = (ref, collisionAxis) => {
|
|
|
5436
5056
|
window.removeEventListener("viewportchange", onViewportChange);
|
|
5437
5057
|
};
|
|
5438
5058
|
}, []);
|
|
5439
|
-
(0,
|
|
5059
|
+
(0, import_react29.useEffect)(calculateDragAxis, [status, collisionAxis]);
|
|
5440
5060
|
return [dragAxis, calculateDragAxis];
|
|
5441
5061
|
};
|
|
5442
5062
|
|
|
@@ -5445,11 +5065,136 @@ var import_shallow4 = require("zustand/react/shallow");
|
|
|
5445
5065
|
|
|
5446
5066
|
// components/Render/index.tsx
|
|
5447
5067
|
init_react_import();
|
|
5448
|
-
|
|
5068
|
+
|
|
5069
|
+
// lib/use-slots.tsx
|
|
5070
|
+
init_react_import();
|
|
5071
|
+
var import_react30 = require("react");
|
|
5072
|
+
function useSlots(config, item, renderSlotEdit, renderSlotRender = renderSlotEdit, readOnly, forceReadOnly) {
|
|
5073
|
+
const slotProps = (0, import_react30.useMemo)(() => {
|
|
5074
|
+
const mapped = mapSlots(
|
|
5075
|
+
item,
|
|
5076
|
+
(content, _parentId, propName, field, propPath) => {
|
|
5077
|
+
const wildcardPath = propPath.replace(/\[\d+\]/g, "[*]");
|
|
5078
|
+
const isReadOnly = (readOnly == null ? void 0 : readOnly[propPath]) || (readOnly == null ? void 0 : readOnly[wildcardPath]) || forceReadOnly;
|
|
5079
|
+
const render = isReadOnly ? renderSlotRender : renderSlotEdit;
|
|
5080
|
+
const Slot = (dzProps) => render(__spreadProps(__spreadValues({
|
|
5081
|
+
allow: (field == null ? void 0 : field.type) === "slot" ? field.allow : [],
|
|
5082
|
+
disallow: (field == null ? void 0 : field.type) === "slot" ? field.disallow : []
|
|
5083
|
+
}, dzProps), {
|
|
5084
|
+
zone: propName,
|
|
5085
|
+
content
|
|
5086
|
+
}));
|
|
5087
|
+
return Slot;
|
|
5088
|
+
},
|
|
5089
|
+
config
|
|
5090
|
+
).props;
|
|
5091
|
+
return mapped;
|
|
5092
|
+
}, [config, item, readOnly, forceReadOnly]);
|
|
5093
|
+
const mergedProps = (0, import_react30.useMemo)(
|
|
5094
|
+
() => __spreadValues(__spreadValues({}, item.props), slotProps),
|
|
5095
|
+
[item.props, slotProps]
|
|
5096
|
+
);
|
|
5097
|
+
return mergedProps;
|
|
5098
|
+
}
|
|
5099
|
+
|
|
5100
|
+
// components/Render/index.tsx
|
|
5101
|
+
var import_react32 = __toESM(require("react"));
|
|
5449
5102
|
|
|
5450
5103
|
// components/SlotRender/index.tsx
|
|
5451
5104
|
init_react_import();
|
|
5452
5105
|
var import_shallow3 = require("zustand/react/shallow");
|
|
5106
|
+
|
|
5107
|
+
// components/SlotRender/server.tsx
|
|
5108
|
+
init_react_import();
|
|
5109
|
+
var import_react31 = require("react");
|
|
5110
|
+
|
|
5111
|
+
// components/ServerRender/index.tsx
|
|
5112
|
+
init_react_import();
|
|
5113
|
+
var import_jsx_runtime21 = require("react/jsx-runtime");
|
|
5114
|
+
function DropZoneRender({
|
|
5115
|
+
zone,
|
|
5116
|
+
data,
|
|
5117
|
+
areaId = "root",
|
|
5118
|
+
config,
|
|
5119
|
+
metadata = {}
|
|
5120
|
+
}) {
|
|
5121
|
+
let zoneCompound = rootDroppableId;
|
|
5122
|
+
let content = (data == null ? void 0 : data.content) || [];
|
|
5123
|
+
if (!data || !config) {
|
|
5124
|
+
return null;
|
|
5125
|
+
}
|
|
5126
|
+
if (areaId !== rootAreaId && zone !== rootZone) {
|
|
5127
|
+
zoneCompound = `${areaId}:${zone}`;
|
|
5128
|
+
content = setupZone(data, zoneCompound).zones[zoneCompound];
|
|
5129
|
+
}
|
|
5130
|
+
return /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(import_jsx_runtime21.Fragment, { children: content.map((item) => {
|
|
5131
|
+
const Component = config.components[item.type];
|
|
5132
|
+
const props = __spreadProps(__spreadValues({}, item.props), {
|
|
5133
|
+
puck: {
|
|
5134
|
+
renderDropZone: ({ zone: zone2 }) => /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(
|
|
5135
|
+
DropZoneRender,
|
|
5136
|
+
{
|
|
5137
|
+
zone: zone2,
|
|
5138
|
+
data,
|
|
5139
|
+
areaId: item.props.id,
|
|
5140
|
+
config,
|
|
5141
|
+
metadata
|
|
5142
|
+
}
|
|
5143
|
+
),
|
|
5144
|
+
metadata,
|
|
5145
|
+
dragRef: null,
|
|
5146
|
+
isEditing: false
|
|
5147
|
+
}
|
|
5148
|
+
});
|
|
5149
|
+
const renderItem = __spreadProps(__spreadValues({}, item), { props });
|
|
5150
|
+
const propsWithSlots = useSlots(config, renderItem, (props2) => /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(SlotRenderPure, __spreadProps(__spreadValues({}, props2), { config, metadata })));
|
|
5151
|
+
if (Component) {
|
|
5152
|
+
return /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(Component.render, __spreadValues({}, propsWithSlots), renderItem.props.id);
|
|
5153
|
+
}
|
|
5154
|
+
return null;
|
|
5155
|
+
}) });
|
|
5156
|
+
}
|
|
5157
|
+
|
|
5158
|
+
// components/SlotRender/server.tsx
|
|
5159
|
+
var import_jsx_runtime22 = require("react/jsx-runtime");
|
|
5160
|
+
var SlotRenderPure = (props) => /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(SlotRender, __spreadValues({}, props));
|
|
5161
|
+
var Item = ({
|
|
5162
|
+
config,
|
|
5163
|
+
item,
|
|
5164
|
+
metadata
|
|
5165
|
+
}) => {
|
|
5166
|
+
const Component = config.components[item.type];
|
|
5167
|
+
const props = useSlots(config, item, (slotProps) => /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(SlotRenderPure, __spreadProps(__spreadValues({}, slotProps), { config, metadata })));
|
|
5168
|
+
return /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(
|
|
5169
|
+
Component.render,
|
|
5170
|
+
__spreadProps(__spreadValues({}, props), {
|
|
5171
|
+
puck: __spreadProps(__spreadValues({}, props.puck), {
|
|
5172
|
+
renderDropZone: DropZoneRender,
|
|
5173
|
+
metadata: metadata || {}
|
|
5174
|
+
})
|
|
5175
|
+
})
|
|
5176
|
+
);
|
|
5177
|
+
};
|
|
5178
|
+
var SlotRender = (0, import_react31.forwardRef)(
|
|
5179
|
+
function SlotRenderInternal({ className, style, content, config, metadata }, ref) {
|
|
5180
|
+
return /* @__PURE__ */ (0, import_jsx_runtime22.jsx)("div", { className, style, ref, children: content.map((item) => {
|
|
5181
|
+
if (!config.components[item.type]) {
|
|
5182
|
+
return null;
|
|
5183
|
+
}
|
|
5184
|
+
return /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(
|
|
5185
|
+
Item,
|
|
5186
|
+
{
|
|
5187
|
+
config,
|
|
5188
|
+
item,
|
|
5189
|
+
metadata
|
|
5190
|
+
},
|
|
5191
|
+
item.props.id
|
|
5192
|
+
);
|
|
5193
|
+
}) });
|
|
5194
|
+
}
|
|
5195
|
+
);
|
|
5196
|
+
|
|
5197
|
+
// components/SlotRender/index.tsx
|
|
5453
5198
|
var import_jsx_runtime23 = require("react/jsx-runtime");
|
|
5454
5199
|
var ContextSlotRender = ({
|
|
5455
5200
|
componentId,
|
|
@@ -5478,12 +5223,12 @@ var ContextSlotRender = ({
|
|
|
5478
5223
|
|
|
5479
5224
|
// components/Render/index.tsx
|
|
5480
5225
|
var import_jsx_runtime24 = require("react/jsx-runtime");
|
|
5481
|
-
var renderContext =
|
|
5226
|
+
var renderContext = import_react32.default.createContext({
|
|
5482
5227
|
config: { components: {} },
|
|
5483
5228
|
data: { root: {}, content: [] },
|
|
5484
5229
|
metadata: {}
|
|
5485
5230
|
});
|
|
5486
|
-
function
|
|
5231
|
+
function Render({
|
|
5487
5232
|
config,
|
|
5488
5233
|
data,
|
|
5489
5234
|
metadata = {}
|
|
@@ -5511,7 +5256,7 @@ function Render2({
|
|
|
5511
5256
|
{ type: "root", props: pageProps },
|
|
5512
5257
|
(props) => /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(SlotRender, __spreadProps(__spreadValues({}, props), { config, metadata }))
|
|
5513
5258
|
);
|
|
5514
|
-
const nextContextValue = (0,
|
|
5259
|
+
const nextContextValue = (0, import_react32.useMemo)(
|
|
5515
5260
|
() => ({
|
|
5516
5261
|
mode: "render",
|
|
5517
5262
|
depth: 0
|
|
@@ -5540,9 +5285,9 @@ var DropZoneChild = ({
|
|
|
5540
5285
|
}) => {
|
|
5541
5286
|
var _a, _b;
|
|
5542
5287
|
const metadata = useAppStore((s) => s.metadata);
|
|
5543
|
-
const ctx = (0,
|
|
5288
|
+
const ctx = (0, import_react33.useContext)(dropZoneContext);
|
|
5544
5289
|
const { depth = 1 } = ctx != null ? ctx : {};
|
|
5545
|
-
const zoneStore = (0,
|
|
5290
|
+
const zoneStore = (0, import_react33.useContext)(ZoneStoreContext);
|
|
5546
5291
|
const nodeProps = useAppStore(
|
|
5547
5292
|
(0, import_shallow4.useShallow)((s) => {
|
|
5548
5293
|
var _a2;
|
|
@@ -5562,7 +5307,7 @@ var DropZoneChild = ({
|
|
|
5562
5307
|
})
|
|
5563
5308
|
);
|
|
5564
5309
|
const appStore = useAppStoreApi();
|
|
5565
|
-
const item = (0,
|
|
5310
|
+
const item = (0, import_react33.useMemo)(() => {
|
|
5566
5311
|
if (nodeProps) {
|
|
5567
5312
|
const expanded = expandNode({
|
|
5568
5313
|
type: nodeType,
|
|
@@ -5575,7 +5320,8 @@ var DropZoneChild = ({
|
|
|
5575
5320
|
return {
|
|
5576
5321
|
type: preview.componentType,
|
|
5577
5322
|
props: preview.props,
|
|
5578
|
-
previewType: preview.type
|
|
5323
|
+
previewType: preview.type,
|
|
5324
|
+
element: preview.element
|
|
5579
5325
|
};
|
|
5580
5326
|
}
|
|
5581
5327
|
return null;
|
|
@@ -5583,7 +5329,7 @@ var DropZoneChild = ({
|
|
|
5583
5329
|
const componentConfig = useAppStore(
|
|
5584
5330
|
(s) => (item == null ? void 0 : item.type) ? s.config.components[item.type] : null
|
|
5585
5331
|
);
|
|
5586
|
-
const puckProps = (0,
|
|
5332
|
+
const puckProps = (0, import_react33.useMemo)(
|
|
5587
5333
|
() => ({
|
|
5588
5334
|
renderDropZone: DropZoneEditPure,
|
|
5589
5335
|
isEditing: true,
|
|
@@ -5606,13 +5352,19 @@ var DropZoneChild = ({
|
|
|
5606
5352
|
}
|
|
5607
5353
|
);
|
|
5608
5354
|
let label = (_b = (_a = componentConfig == null ? void 0 : componentConfig.label) != null ? _a : item == null ? void 0 : item.type.toString()) != null ? _b : "Component";
|
|
5609
|
-
const renderPreview = (0,
|
|
5355
|
+
const renderPreview = (0, import_react33.useMemo)(
|
|
5610
5356
|
() => function Preview3() {
|
|
5357
|
+
if (item && "element" in item && item.element) {
|
|
5358
|
+
return (
|
|
5359
|
+
// Safe to use this since the HTML is set by the user
|
|
5360
|
+
/* @__PURE__ */ (0, import_jsx_runtime25.jsx)("div", { dangerouslySetInnerHTML: { __html: item.element.outerHTML } })
|
|
5361
|
+
);
|
|
5362
|
+
}
|
|
5611
5363
|
return /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(DrawerItemInner, { name: label, children: overrides.componentItem });
|
|
5612
5364
|
},
|
|
5613
5365
|
[componentId, label, overrides]
|
|
5614
5366
|
);
|
|
5615
|
-
const defaultsProps = (0,
|
|
5367
|
+
const defaultsProps = (0, import_react33.useMemo)(
|
|
5616
5368
|
() => __spreadProps(__spreadValues(__spreadValues({}, componentConfig == null ? void 0 : componentConfig.defaultProps), item == null ? void 0 : item.props), {
|
|
5617
5369
|
puck: puckProps,
|
|
5618
5370
|
editMode: true
|
|
@@ -5620,7 +5372,7 @@ var DropZoneChild = ({
|
|
|
5620
5372
|
}),
|
|
5621
5373
|
[componentConfig == null ? void 0 : componentConfig.defaultProps, item == null ? void 0 : item.props, puckProps]
|
|
5622
5374
|
);
|
|
5623
|
-
const defaultedNode = (0,
|
|
5375
|
+
const defaultedNode = (0, import_react33.useMemo)(
|
|
5624
5376
|
() => {
|
|
5625
5377
|
var _a2;
|
|
5626
5378
|
return { type: (_a2 = item == null ? void 0 : item.type) != null ? _a2 : nodeType, props: defaultsProps };
|
|
@@ -5637,14 +5389,14 @@ var DropZoneChild = ({
|
|
|
5637
5389
|
isLoading
|
|
5638
5390
|
);
|
|
5639
5391
|
if (!item) return;
|
|
5640
|
-
let
|
|
5392
|
+
let Render2 = componentConfig ? componentConfig.render : () => /* @__PURE__ */ (0, import_jsx_runtime25.jsxs)("div", { style: { padding: 48, textAlign: "center" }, children: [
|
|
5641
5393
|
"No configuration for ",
|
|
5642
5394
|
item.type
|
|
5643
5395
|
] });
|
|
5644
5396
|
let componentType = item.type;
|
|
5645
5397
|
const isInserting = "previewType" in item ? item.previewType === "insert" : false;
|
|
5646
5398
|
if (isInserting) {
|
|
5647
|
-
|
|
5399
|
+
Render2 = renderPreview;
|
|
5648
5400
|
}
|
|
5649
5401
|
return /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(
|
|
5650
5402
|
DraggableComponent,
|
|
@@ -5661,18 +5413,18 @@ var DropZoneChild = ({
|
|
|
5661
5413
|
userDragAxis: collisionAxis,
|
|
5662
5414
|
inDroppableZone,
|
|
5663
5415
|
children: (dragRef) => (componentConfig == null ? void 0 : componentConfig.inline) && !isInserting ? /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(import_jsx_runtime25.Fragment, { children: /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(
|
|
5664
|
-
|
|
5416
|
+
Render2,
|
|
5665
5417
|
__spreadProps(__spreadValues({}, defaultedPropsWithSlots), {
|
|
5666
5418
|
puck: __spreadProps(__spreadValues({}, defaultedPropsWithSlots.puck), {
|
|
5667
5419
|
dragRef
|
|
5668
5420
|
})
|
|
5669
5421
|
})
|
|
5670
|
-
) }) : /* @__PURE__ */ (0, import_jsx_runtime25.jsx)("div", { ref: dragRef, children: /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(
|
|
5422
|
+
) }) : /* @__PURE__ */ (0, import_jsx_runtime25.jsx)("div", { ref: dragRef, children: /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(Render2, __spreadValues({}, defaultedPropsWithSlots)) })
|
|
5671
5423
|
}
|
|
5672
5424
|
);
|
|
5673
5425
|
};
|
|
5674
|
-
var DropZoneChildMemo = (0,
|
|
5675
|
-
var DropZoneEdit = (0,
|
|
5426
|
+
var DropZoneChildMemo = (0, import_react33.memo)(DropZoneChild);
|
|
5427
|
+
var DropZoneEdit = (0, import_react33.forwardRef)(
|
|
5676
5428
|
function DropZoneEditInternal({
|
|
5677
5429
|
zone,
|
|
5678
5430
|
allow,
|
|
@@ -5682,7 +5434,7 @@ var DropZoneEdit = (0, import_react35.forwardRef)(
|
|
|
5682
5434
|
minEmptyHeight: userMinEmptyHeight = 128,
|
|
5683
5435
|
collisionAxis
|
|
5684
5436
|
}, userRef) {
|
|
5685
|
-
const ctx = (0,
|
|
5437
|
+
const ctx = (0, import_react33.useContext)(dropZoneContext);
|
|
5686
5438
|
const appStoreApi = useAppStoreApi();
|
|
5687
5439
|
const {
|
|
5688
5440
|
// These all need setting via context
|
|
@@ -5720,14 +5472,14 @@ var DropZoneEdit = (0, import_react35.forwardRef)(
|
|
|
5720
5472
|
return (_a = s.state.indexes.zones[zoneCompound]) == null ? void 0 : _a.type;
|
|
5721
5473
|
})
|
|
5722
5474
|
);
|
|
5723
|
-
(0,
|
|
5475
|
+
(0, import_react33.useEffect)(() => {
|
|
5724
5476
|
if (!zoneType || zoneType === "dropzone") {
|
|
5725
5477
|
if (ctx == null ? void 0 : ctx.registerZone) {
|
|
5726
5478
|
ctx == null ? void 0 : ctx.registerZone(zoneCompound);
|
|
5727
5479
|
}
|
|
5728
5480
|
}
|
|
5729
5481
|
}, [zoneType, appStoreApi]);
|
|
5730
|
-
(0,
|
|
5482
|
+
(0, import_react33.useEffect)(() => {
|
|
5731
5483
|
if (zoneType === "dropzone") {
|
|
5732
5484
|
if (zoneCompound !== rootDroppableId) {
|
|
5733
5485
|
console.warn(
|
|
@@ -5736,11 +5488,11 @@ var DropZoneEdit = (0, import_react35.forwardRef)(
|
|
|
5736
5488
|
}
|
|
5737
5489
|
}
|
|
5738
5490
|
}, [zoneType]);
|
|
5739
|
-
const contentIds = (0,
|
|
5491
|
+
const contentIds = (0, import_react33.useMemo)(() => {
|
|
5740
5492
|
return zoneContentIds || [];
|
|
5741
5493
|
}, [zoneContentIds]);
|
|
5742
|
-
const ref = (0,
|
|
5743
|
-
const acceptsTarget = (0,
|
|
5494
|
+
const ref = (0, import_react33.useRef)(null);
|
|
5495
|
+
const acceptsTarget = (0, import_react33.useCallback)(
|
|
5744
5496
|
(componentType) => {
|
|
5745
5497
|
if (!componentType) {
|
|
5746
5498
|
return true;
|
|
@@ -5778,7 +5530,7 @@ var DropZoneEdit = (0, import_react35.forwardRef)(
|
|
|
5778
5530
|
}
|
|
5779
5531
|
return _isEnabled;
|
|
5780
5532
|
});
|
|
5781
|
-
(0,
|
|
5533
|
+
(0, import_react33.useEffect)(() => {
|
|
5782
5534
|
if (registerLocalZone) {
|
|
5783
5535
|
registerLocalZone(zoneCompound, targetAccepted || isEnabled);
|
|
5784
5536
|
}
|
|
@@ -5793,8 +5545,8 @@ var DropZoneEdit = (0, import_react35.forwardRef)(
|
|
|
5793
5545
|
zoneCompound
|
|
5794
5546
|
);
|
|
5795
5547
|
const isDropEnabled = isEnabled && (preview ? contentIdsWithPreview.length === 1 : contentIdsWithPreview.length === 0);
|
|
5796
|
-
const zoneStore = (0,
|
|
5797
|
-
(0,
|
|
5548
|
+
const zoneStore = (0, import_react33.useContext)(ZoneStoreContext);
|
|
5549
|
+
(0, import_react33.useEffect)(() => {
|
|
5798
5550
|
const { enabledIndex } = zoneStore.getState();
|
|
5799
5551
|
zoneStore.setState({
|
|
5800
5552
|
enabledIndex: __spreadProps(__spreadValues({}, enabledIndex), { [zoneCompound]: isEnabled })
|
|
@@ -5813,7 +5565,7 @@ var DropZoneEdit = (0, import_react35.forwardRef)(
|
|
|
5813
5565
|
path: path || []
|
|
5814
5566
|
}
|
|
5815
5567
|
};
|
|
5816
|
-
const { ref: dropRef } = (0,
|
|
5568
|
+
const { ref: dropRef } = (0, import_react34.useDroppable)(droppableConfig);
|
|
5817
5569
|
const isAreaSelected = useAppStore(
|
|
5818
5570
|
(s) => (s == null ? void 0 : s.selectedItem) && areaId === (s == null ? void 0 : s.selectedItem.props.id)
|
|
5819
5571
|
);
|
|
@@ -5868,7 +5620,7 @@ var DropZoneRenderItem = ({
|
|
|
5868
5620
|
}) => {
|
|
5869
5621
|
const Component = config.components[item.type];
|
|
5870
5622
|
const props = useSlots(config, item, (slotProps) => /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(SlotRenderPure, __spreadProps(__spreadValues({}, slotProps), { config, metadata })));
|
|
5871
|
-
const nextContextValue = (0,
|
|
5623
|
+
const nextContextValue = (0, import_react33.useMemo)(
|
|
5872
5624
|
() => ({
|
|
5873
5625
|
areaId: props.id,
|
|
5874
5626
|
depth: 1
|
|
@@ -5886,14 +5638,14 @@ var DropZoneRenderItem = ({
|
|
|
5886
5638
|
) }, props.id);
|
|
5887
5639
|
};
|
|
5888
5640
|
var DropZoneRenderPure = (props) => /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(DropZoneRender2, __spreadValues({}, props));
|
|
5889
|
-
var DropZoneRender2 = (0,
|
|
5641
|
+
var DropZoneRender2 = (0, import_react33.forwardRef)(
|
|
5890
5642
|
function DropZoneRenderInternal({ className, style, zone }, ref) {
|
|
5891
|
-
const ctx = (0,
|
|
5643
|
+
const ctx = (0, import_react33.useContext)(dropZoneContext);
|
|
5892
5644
|
const { areaId = "root" } = ctx || {};
|
|
5893
|
-
const { config, data, metadata } = (0,
|
|
5645
|
+
const { config, data, metadata } = (0, import_react33.useContext)(renderContext);
|
|
5894
5646
|
let zoneCompound = `${areaId}:${zone}`;
|
|
5895
5647
|
let content = (data == null ? void 0 : data.content) || [];
|
|
5896
|
-
(0,
|
|
5648
|
+
(0, import_react33.useEffect)(() => {
|
|
5897
5649
|
if (!content) {
|
|
5898
5650
|
if (ctx == null ? void 0 : ctx.registerZone) {
|
|
5899
5651
|
ctx == null ? void 0 : ctx.registerZone(zoneCompound);
|
|
@@ -5924,9 +5676,9 @@ var DropZoneRender2 = (0, import_react35.forwardRef)(
|
|
|
5924
5676
|
}
|
|
5925
5677
|
);
|
|
5926
5678
|
var DropZonePure = (props) => /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(DropZone, __spreadValues({}, props));
|
|
5927
|
-
var DropZone = (0,
|
|
5679
|
+
var DropZone = (0, import_react33.forwardRef)(
|
|
5928
5680
|
function DropZone2(props, ref) {
|
|
5929
|
-
const ctx = (0,
|
|
5681
|
+
const ctx = (0, import_react33.useContext)(dropZoneContext);
|
|
5930
5682
|
if ((ctx == null ? void 0 : ctx.mode) === "edit") {
|
|
5931
5683
|
return /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(import_jsx_runtime25.Fragment, { children: /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(DropZoneEdit, __spreadProps(__spreadValues({}, props), { ref })) });
|
|
5932
5684
|
}
|
|
@@ -6268,12 +6020,12 @@ function getDeepDir(el) {
|
|
|
6268
6020
|
var import_state = require("@dnd-kit/state");
|
|
6269
6021
|
var import_jsx_runtime26 = require("react/jsx-runtime");
|
|
6270
6022
|
var DEBUG3 = false;
|
|
6271
|
-
var dragListenerContext = (0,
|
|
6023
|
+
var dragListenerContext = (0, import_react36.createContext)({
|
|
6272
6024
|
dragListeners: {}
|
|
6273
6025
|
});
|
|
6274
6026
|
function useDragListener(type, fn, deps = []) {
|
|
6275
|
-
const { setDragListeners } = (0,
|
|
6276
|
-
(0,
|
|
6027
|
+
const { setDragListeners } = (0, import_react36.useContext)(dragListenerContext);
|
|
6028
|
+
(0, import_react36.useEffect)(() => {
|
|
6277
6029
|
if (setDragListeners) {
|
|
6278
6030
|
setDragListeners((old) => __spreadProps(__spreadValues({}, old), {
|
|
6279
6031
|
[type]: [...old[type] || [], fn]
|
|
@@ -6283,8 +6035,8 @@ function useDragListener(type, fn, deps = []) {
|
|
|
6283
6035
|
}
|
|
6284
6036
|
var AREA_CHANGE_DEBOUNCE_MS = 100;
|
|
6285
6037
|
var useTempDisableFallback = (timeout3) => {
|
|
6286
|
-
const lastFallbackDisable = (0,
|
|
6287
|
-
return (0,
|
|
6038
|
+
const lastFallbackDisable = (0, import_react36.useRef)(null);
|
|
6039
|
+
return (0, import_react36.useCallback)((manager) => {
|
|
6288
6040
|
collisionStore.setState({ fallbackEnabled: false });
|
|
6289
6041
|
const fallbackId = generateId();
|
|
6290
6042
|
lastFallbackDisable.current = fallbackId;
|
|
@@ -6303,9 +6055,9 @@ var DragDropContextClient = ({
|
|
|
6303
6055
|
const dispatch = useAppStore((s) => s.dispatch);
|
|
6304
6056
|
const appStore = useAppStoreApi();
|
|
6305
6057
|
const id = useSafeId();
|
|
6306
|
-
const debouncedParamsRef = (0,
|
|
6058
|
+
const debouncedParamsRef = (0, import_react36.useRef)(null);
|
|
6307
6059
|
const tempDisableFallback = useTempDisableFallback(100);
|
|
6308
|
-
const [zoneStore] = (0,
|
|
6060
|
+
const [zoneStore] = (0, import_react36.useState)(
|
|
6309
6061
|
() => (0, import_zustand5.createStore)(() => ({
|
|
6310
6062
|
zoneDepthIndex: {},
|
|
6311
6063
|
nextZoneDepthIndex: {},
|
|
@@ -6317,7 +6069,7 @@ var DragDropContextClient = ({
|
|
|
6317
6069
|
hoveringComponent: null
|
|
6318
6070
|
}))
|
|
6319
6071
|
);
|
|
6320
|
-
const getChanged2 = (0,
|
|
6072
|
+
const getChanged2 = (0, import_react36.useCallback)(
|
|
6321
6073
|
(params, id2) => {
|
|
6322
6074
|
const { zoneDepthIndex = {}, areaDepthIndex = {} } = zoneStore.getState() || {};
|
|
6323
6075
|
const stateHasZone = Object.keys(zoneDepthIndex).length > 0;
|
|
@@ -6338,7 +6090,7 @@ var DragDropContextClient = ({
|
|
|
6338
6090
|
},
|
|
6339
6091
|
[zoneStore]
|
|
6340
6092
|
);
|
|
6341
|
-
const setDeepestAndCollide = (0,
|
|
6093
|
+
const setDeepestAndCollide = (0, import_react36.useCallback)(
|
|
6342
6094
|
(params, manager) => {
|
|
6343
6095
|
const { zoneChanged, areaChanged } = getChanged2(params, id);
|
|
6344
6096
|
if (!zoneChanged && !areaChanged) return;
|
|
@@ -6362,7 +6114,7 @@ var DragDropContextClient = ({
|
|
|
6362
6114
|
setDeepestDb.cancel();
|
|
6363
6115
|
debouncedParamsRef.current = null;
|
|
6364
6116
|
};
|
|
6365
|
-
(0,
|
|
6117
|
+
(0, import_react36.useEffect)(() => {
|
|
6366
6118
|
if (DEBUG3) {
|
|
6367
6119
|
zoneStore.subscribe(
|
|
6368
6120
|
(s) => {
|
|
@@ -6376,7 +6128,7 @@ var DragDropContextClient = ({
|
|
|
6376
6128
|
);
|
|
6377
6129
|
}
|
|
6378
6130
|
}, []);
|
|
6379
|
-
const [plugins] = (0,
|
|
6131
|
+
const [plugins] = (0, import_react36.useState)(() => [
|
|
6380
6132
|
...disableAutoScroll ? import_dom.defaultPreset.plugins.filter((plugin) => plugin !== import_dom.AutoScroller) : import_dom.defaultPreset.plugins,
|
|
6381
6133
|
createNestedDroppablePlugin(
|
|
6382
6134
|
{
|
|
@@ -6424,10 +6176,10 @@ var DragDropContextClient = ({
|
|
|
6424
6176
|
)
|
|
6425
6177
|
]);
|
|
6426
6178
|
const sensors = useSensors();
|
|
6427
|
-
const [dragListeners, setDragListeners] = (0,
|
|
6428
|
-
const dragMode = (0,
|
|
6429
|
-
const initialSelector = (0,
|
|
6430
|
-
const nextContextValue = (0,
|
|
6179
|
+
const [dragListeners, setDragListeners] = (0, import_react36.useState)({});
|
|
6180
|
+
const dragMode = (0, import_react36.useRef)(null);
|
|
6181
|
+
const initialSelector = (0, import_react36.useRef)(void 0);
|
|
6182
|
+
const nextContextValue = (0, import_react36.useMemo)(
|
|
6431
6183
|
() => ({
|
|
6432
6184
|
mode: "edit",
|
|
6433
6185
|
areaId: "root",
|
|
@@ -6443,7 +6195,7 @@ var DragDropContextClient = ({
|
|
|
6443
6195
|
setDragListeners
|
|
6444
6196
|
},
|
|
6445
6197
|
children: /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(
|
|
6446
|
-
|
|
6198
|
+
import_react35.DragDropProvider,
|
|
6447
6199
|
{
|
|
6448
6200
|
plugins,
|
|
6449
6201
|
sensors,
|
|
@@ -6563,6 +6315,7 @@ var DragDropContextClient = ({
|
|
|
6563
6315
|
type: "insert",
|
|
6564
6316
|
index: targetIndex,
|
|
6565
6317
|
zone: targetZone,
|
|
6318
|
+
element: source.element,
|
|
6566
6319
|
props: {
|
|
6567
6320
|
id: source.id.toString()
|
|
6568
6321
|
}
|
|
@@ -6588,7 +6341,8 @@ var DragDropContextClient = ({
|
|
|
6588
6341
|
type: "move",
|
|
6589
6342
|
index: targetIndex,
|
|
6590
6343
|
zone: targetZone,
|
|
6591
|
-
props: item.props
|
|
6344
|
+
props: item.props,
|
|
6345
|
+
element: source.element
|
|
6592
6346
|
}
|
|
6593
6347
|
}
|
|
6594
6348
|
});
|
|
@@ -6618,7 +6372,8 @@ var DragDropContextClient = ({
|
|
|
6618
6372
|
type: "move",
|
|
6619
6373
|
index: sourceData.index,
|
|
6620
6374
|
zone: sourceData.zone,
|
|
6621
|
-
props: item.props
|
|
6375
|
+
props: item.props,
|
|
6376
|
+
element: source.element
|
|
6622
6377
|
}
|
|
6623
6378
|
}
|
|
6624
6379
|
});
|
|
@@ -6673,7 +6428,7 @@ var DragDropContext = ({
|
|
|
6673
6428
|
};
|
|
6674
6429
|
|
|
6675
6430
|
// components/Drawer/index.tsx
|
|
6676
|
-
var
|
|
6431
|
+
var import_react38 = require("@dnd-kit/react");
|
|
6677
6432
|
var import_jsx_runtime27 = require("react/jsx-runtime");
|
|
6678
6433
|
var getClassName18 = get_class_name_factory_default("Drawer", styles_module_default10);
|
|
6679
6434
|
var getClassNameItem2 = get_class_name_factory_default("DrawerItem", styles_module_default10);
|
|
@@ -6684,7 +6439,7 @@ var DrawerItemInner = ({
|
|
|
6684
6439
|
dragRef,
|
|
6685
6440
|
isDragDisabled
|
|
6686
6441
|
}) => {
|
|
6687
|
-
const CustomInner = (0,
|
|
6442
|
+
const CustomInner = (0, import_react37.useMemo)(
|
|
6688
6443
|
() => children || (({ children: children2 }) => /* @__PURE__ */ (0, import_jsx_runtime27.jsx)("div", { className: getClassNameItem2("default"), children: children2 })),
|
|
6689
6444
|
[children]
|
|
6690
6445
|
);
|
|
@@ -6710,7 +6465,7 @@ var DrawerItemDraggable = ({
|
|
|
6710
6465
|
id,
|
|
6711
6466
|
isDragDisabled
|
|
6712
6467
|
}) => {
|
|
6713
|
-
const { ref } = (0,
|
|
6468
|
+
const { ref } = (0, import_react38.useDraggable)({
|
|
6714
6469
|
id,
|
|
6715
6470
|
data: { componentType: name },
|
|
6716
6471
|
disabled: isDragDisabled,
|
|
@@ -6739,7 +6494,7 @@ var DrawerItem = ({
|
|
|
6739
6494
|
isDragDisabled
|
|
6740
6495
|
}) => {
|
|
6741
6496
|
const resolvedId = id || name;
|
|
6742
|
-
const [dynamicId, setDynamicId] = (0,
|
|
6497
|
+
const [dynamicId, setDynamicId] = (0, import_react37.useState)(generateId(resolvedId));
|
|
6743
6498
|
if (typeof index !== "undefined") {
|
|
6744
6499
|
console.error(
|
|
6745
6500
|
"Warning: The `index` prop on Drawer.Item is deprecated and no longer required."
|
|
@@ -6779,7 +6534,7 @@ var Drawer = ({
|
|
|
6779
6534
|
);
|
|
6780
6535
|
}
|
|
6781
6536
|
const id = useSafeId();
|
|
6782
|
-
const { ref } = (0,
|
|
6537
|
+
const { ref } = (0, import_react38.useDroppable)({
|
|
6783
6538
|
id,
|
|
6784
6539
|
type: "void",
|
|
6785
6540
|
collisionPriority: 0
|
|
@@ -6801,7 +6556,7 @@ Drawer.Item = DrawerItem;
|
|
|
6801
6556
|
|
|
6802
6557
|
// components/Puck/index.tsx
|
|
6803
6558
|
init_react_import();
|
|
6804
|
-
var
|
|
6559
|
+
var import_react54 = require("react");
|
|
6805
6560
|
|
|
6806
6561
|
// components/SidebarSection/index.tsx
|
|
6807
6562
|
init_react_import();
|
|
@@ -6812,7 +6567,7 @@ var styles_module_default13 = { "SidebarSection": "_SidebarSection_8boj8_1", "Si
|
|
|
6812
6567
|
|
|
6813
6568
|
// lib/use-breadcrumbs.ts
|
|
6814
6569
|
init_react_import();
|
|
6815
|
-
var
|
|
6570
|
+
var import_react39 = require("react");
|
|
6816
6571
|
var useBreadcrumbs = (renderCount) => {
|
|
6817
6572
|
const selectedId = useAppStore((s) => {
|
|
6818
6573
|
var _a;
|
|
@@ -6824,7 +6579,7 @@ var useBreadcrumbs = (renderCount) => {
|
|
|
6824
6579
|
return (_a = s.state.indexes.nodes[selectedId]) == null ? void 0 : _a.path;
|
|
6825
6580
|
});
|
|
6826
6581
|
const appStore = useAppStoreApi();
|
|
6827
|
-
return (0,
|
|
6582
|
+
return (0, import_react39.useMemo)(() => {
|
|
6828
6583
|
const breadcrumbs = (path == null ? void 0 : path.map((zoneCompound) => {
|
|
6829
6584
|
var _a, _b, _c;
|
|
6830
6585
|
const [componentId] = zoneCompound.split(":");
|
|
@@ -6908,7 +6663,7 @@ init_react_import();
|
|
|
6908
6663
|
var styles_module_default15 = { "PuckFields": "_PuckFields_10bh7_1", "PuckFields--isLoading": "_PuckFields--isLoading_10bh7_6", "PuckFields-loadingOverlay": "_PuckFields-loadingOverlay_10bh7_10", "PuckFields-loadingOverlayInner": "_PuckFields-loadingOverlayInner_10bh7_25", "PuckFields-field": "_PuckFields-field_10bh7_32", "PuckFields--wrapFields": "_PuckFields--wrapFields_10bh7_36" };
|
|
6909
6664
|
|
|
6910
6665
|
// components/Puck/components/Fields/index.tsx
|
|
6911
|
-
var
|
|
6666
|
+
var import_react40 = require("react");
|
|
6912
6667
|
var import_shallow5 = require("zustand/react/shallow");
|
|
6913
6668
|
var import_jsx_runtime29 = require("react/jsx-runtime");
|
|
6914
6669
|
var getClassName20 = get_class_name_factory_default("PuckFields", styles_module_default15);
|
|
@@ -6981,7 +6736,7 @@ var FieldsChild = ({ fieldName }) => {
|
|
|
6981
6736
|
})
|
|
6982
6737
|
);
|
|
6983
6738
|
const appStore = useAppStoreApi();
|
|
6984
|
-
const onChange = (0,
|
|
6739
|
+
const onChange = (0, import_react40.useCallback)(createOnChange(fieldName, appStore), [
|
|
6985
6740
|
fieldName
|
|
6986
6741
|
]);
|
|
6987
6742
|
const { visible = true } = field != null ? field : {};
|
|
@@ -6999,7 +6754,7 @@ var FieldsChild = ({ fieldName }) => {
|
|
|
6999
6754
|
}
|
|
7000
6755
|
) }, id);
|
|
7001
6756
|
};
|
|
7002
|
-
var FieldsChildMemo = (0,
|
|
6757
|
+
var FieldsChildMemo = (0, import_react40.memo)(FieldsChild);
|
|
7003
6758
|
var FieldsInternal = ({ wrapFields = true }) => {
|
|
7004
6759
|
const overrides = useAppStore((s) => s.overrides);
|
|
7005
6760
|
const componentResolving = useAppStore((s) => {
|
|
@@ -7024,7 +6779,7 @@ var FieldsInternal = ({ wrapFields = true }) => {
|
|
|
7024
6779
|
})
|
|
7025
6780
|
);
|
|
7026
6781
|
const isLoading = fieldsLoading || componentResolving;
|
|
7027
|
-
const Wrapper = (0,
|
|
6782
|
+
const Wrapper = (0, import_react40.useMemo)(() => overrides.fields || DefaultFields, [overrides]);
|
|
7028
6783
|
return /* @__PURE__ */ (0, import_jsx_runtime29.jsxs)(
|
|
7029
6784
|
"form",
|
|
7030
6785
|
{
|
|
@@ -7039,14 +6794,14 @@ var FieldsInternal = ({ wrapFields = true }) => {
|
|
|
7039
6794
|
}
|
|
7040
6795
|
);
|
|
7041
6796
|
};
|
|
7042
|
-
var Fields = (0,
|
|
6797
|
+
var Fields = (0, import_react40.memo)(FieldsInternal);
|
|
7043
6798
|
|
|
7044
6799
|
// components/Puck/components/Components/index.tsx
|
|
7045
6800
|
init_react_import();
|
|
7046
6801
|
|
|
7047
6802
|
// lib/use-component-list.tsx
|
|
7048
6803
|
init_react_import();
|
|
7049
|
-
var
|
|
6804
|
+
var import_react41 = require("react");
|
|
7050
6805
|
|
|
7051
6806
|
// components/ComponentList/index.tsx
|
|
7052
6807
|
init_react_import();
|
|
@@ -7117,10 +6872,10 @@ ComponentList.Item = ComponentListItem;
|
|
|
7117
6872
|
// lib/use-component-list.tsx
|
|
7118
6873
|
var import_jsx_runtime31 = require("react/jsx-runtime");
|
|
7119
6874
|
var useComponentList = () => {
|
|
7120
|
-
const [componentList, setComponentList] = (0,
|
|
6875
|
+
const [componentList, setComponentList] = (0, import_react41.useState)();
|
|
7121
6876
|
const config = useAppStore((s) => s.config);
|
|
7122
6877
|
const uiComponentList = useAppStore((s) => s.state.ui.componentList);
|
|
7123
|
-
(0,
|
|
6878
|
+
(0, import_react41.useEffect)(() => {
|
|
7124
6879
|
var _a, _b, _c;
|
|
7125
6880
|
if (Object.keys(uiComponentList).length > 0) {
|
|
7126
6881
|
const matchedComponents = [];
|
|
@@ -7189,22 +6944,22 @@ var useComponentList = () => {
|
|
|
7189
6944
|
};
|
|
7190
6945
|
|
|
7191
6946
|
// components/Puck/components/Components/index.tsx
|
|
7192
|
-
var
|
|
6947
|
+
var import_react42 = require("react");
|
|
7193
6948
|
var import_jsx_runtime32 = require("react/jsx-runtime");
|
|
7194
6949
|
var Components = () => {
|
|
7195
6950
|
const overrides = useAppStore((s) => s.overrides);
|
|
7196
6951
|
const componentList = useComponentList();
|
|
7197
|
-
const Wrapper = (0,
|
|
6952
|
+
const Wrapper = (0, import_react42.useMemo)(() => overrides.components || "div", [overrides]);
|
|
7198
6953
|
return /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(Wrapper, { children: componentList ? componentList : /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(ComponentList, { id: "all" }) });
|
|
7199
6954
|
};
|
|
7200
6955
|
|
|
7201
6956
|
// components/Puck/components/Preview/index.tsx
|
|
7202
6957
|
init_react_import();
|
|
7203
|
-
var
|
|
6958
|
+
var import_react44 = require("react");
|
|
7204
6959
|
|
|
7205
6960
|
// components/AutoFrame/index.tsx
|
|
7206
6961
|
init_react_import();
|
|
7207
|
-
var
|
|
6962
|
+
var import_react43 = require("react");
|
|
7208
6963
|
var import_object_hash = __toESM(require("object-hash"));
|
|
7209
6964
|
var import_react_dom3 = require("react-dom");
|
|
7210
6965
|
var import_jsx_runtime33 = require("react/jsx-runtime");
|
|
@@ -7257,7 +7012,7 @@ var CopyHostStyles = ({
|
|
|
7257
7012
|
onStylesLoaded = () => null
|
|
7258
7013
|
}) => {
|
|
7259
7014
|
const { document: doc, window: win } = useFrame();
|
|
7260
|
-
(0,
|
|
7015
|
+
(0, import_react43.useEffect)(() => {
|
|
7261
7016
|
if (!win || !doc) {
|
|
7262
7017
|
return () => {
|
|
7263
7018
|
};
|
|
@@ -7416,8 +7171,8 @@ var CopyHostStyles = ({
|
|
|
7416
7171
|
}, []);
|
|
7417
7172
|
return /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(import_jsx_runtime33.Fragment, { children });
|
|
7418
7173
|
};
|
|
7419
|
-
var autoFrameContext = (0,
|
|
7420
|
-
var useFrame = () => (0,
|
|
7174
|
+
var autoFrameContext = (0, import_react43.createContext)({});
|
|
7175
|
+
var useFrame = () => (0, import_react43.useContext)(autoFrameContext);
|
|
7421
7176
|
function AutoFrame(_a) {
|
|
7422
7177
|
var _b = _a, {
|
|
7423
7178
|
children,
|
|
@@ -7438,11 +7193,11 @@ function AutoFrame(_a) {
|
|
|
7438
7193
|
"onNotReady",
|
|
7439
7194
|
"frameRef"
|
|
7440
7195
|
]);
|
|
7441
|
-
const [loaded, setLoaded] = (0,
|
|
7442
|
-
const [ctx, setCtx] = (0,
|
|
7443
|
-
const [mountTarget, setMountTarget] = (0,
|
|
7444
|
-
const [stylesLoaded, setStylesLoaded] = (0,
|
|
7445
|
-
(0,
|
|
7196
|
+
const [loaded, setLoaded] = (0, import_react43.useState)(false);
|
|
7197
|
+
const [ctx, setCtx] = (0, import_react43.useState)({});
|
|
7198
|
+
const [mountTarget, setMountTarget] = (0, import_react43.useState)();
|
|
7199
|
+
const [stylesLoaded, setStylesLoaded] = (0, import_react43.useState)(false);
|
|
7200
|
+
(0, import_react43.useEffect)(() => {
|
|
7446
7201
|
var _a2;
|
|
7447
7202
|
if (frameRef.current) {
|
|
7448
7203
|
const doc = frameRef.current.contentDocument;
|
|
@@ -7494,7 +7249,7 @@ var import_jsx_runtime34 = require("react/jsx-runtime");
|
|
|
7494
7249
|
var getClassName22 = get_class_name_factory_default("PuckPreview", styles_module_default17);
|
|
7495
7250
|
var useBubbleIframeEvents = (ref) => {
|
|
7496
7251
|
const status = useAppStore((s) => s.status);
|
|
7497
|
-
(0,
|
|
7252
|
+
(0, import_react44.useEffect)(() => {
|
|
7498
7253
|
if (ref.current && status === "READY") {
|
|
7499
7254
|
const iframe = ref.current;
|
|
7500
7255
|
const handlePointerMove = (event) => {
|
|
@@ -7543,7 +7298,7 @@ var Preview2 = ({ id = "puck-preview" }) => {
|
|
|
7543
7298
|
const renderData = useAppStore(
|
|
7544
7299
|
(s) => s.state.ui.previewMode === "edit" ? null : s.state.data
|
|
7545
7300
|
);
|
|
7546
|
-
const Page = (0,
|
|
7301
|
+
const Page = (0, import_react44.useCallback)(
|
|
7547
7302
|
(pageProps) => {
|
|
7548
7303
|
var _a, _b;
|
|
7549
7304
|
const propsWithSlots = useSlots(
|
|
@@ -7557,9 +7312,9 @@ var Preview2 = ({ id = "puck-preview" }) => {
|
|
|
7557
7312
|
},
|
|
7558
7313
|
[config]
|
|
7559
7314
|
);
|
|
7560
|
-
const Frame = (0,
|
|
7315
|
+
const Frame = (0, import_react44.useMemo)(() => overrides.iframe, [overrides]);
|
|
7561
7316
|
const rootProps = root.props || root;
|
|
7562
|
-
const ref = (0,
|
|
7317
|
+
const ref = (0, import_react44.useRef)(null);
|
|
7563
7318
|
useBubbleIframeEvents(ref);
|
|
7564
7319
|
const inner = !renderData ? /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(
|
|
7565
7320
|
Page,
|
|
@@ -7573,8 +7328,8 @@ var Preview2 = ({ id = "puck-preview" }) => {
|
|
|
7573
7328
|
editMode: true,
|
|
7574
7329
|
children: /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(DropZonePure, { zone: rootDroppableId })
|
|
7575
7330
|
})
|
|
7576
|
-
) : /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(
|
|
7577
|
-
(0,
|
|
7331
|
+
) : /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(Render, { data: renderData, config, metadata });
|
|
7332
|
+
(0, import_react44.useEffect)(() => {
|
|
7578
7333
|
if (!iframe.enabled) {
|
|
7579
7334
|
setStatus("READY");
|
|
7580
7335
|
}
|
|
@@ -7644,7 +7399,7 @@ var scrollIntoView = (el) => {
|
|
|
7644
7399
|
};
|
|
7645
7400
|
|
|
7646
7401
|
// components/LayerTree/index.tsx
|
|
7647
|
-
var
|
|
7402
|
+
var import_react45 = require("react");
|
|
7648
7403
|
|
|
7649
7404
|
// lib/on-scroll-end.ts
|
|
7650
7405
|
init_react_import();
|
|
@@ -7679,7 +7434,7 @@ var Layer = ({
|
|
|
7679
7434
|
const config = useAppStore((s) => s.config);
|
|
7680
7435
|
const itemSelector = useAppStore((s) => s.state.ui.itemSelector);
|
|
7681
7436
|
const dispatch = useAppStore((s) => s.dispatch);
|
|
7682
|
-
const setItemSelector = (0,
|
|
7437
|
+
const setItemSelector = (0, import_react45.useCallback)(
|
|
7683
7438
|
(itemSelector2) => {
|
|
7684
7439
|
dispatch({ type: "setUi", ui: { itemSelector: itemSelector2 } });
|
|
7685
7440
|
},
|
|
@@ -7699,7 +7454,7 @@ var Layer = ({
|
|
|
7699
7454
|
)
|
|
7700
7455
|
);
|
|
7701
7456
|
const containsZone = zonesForItem.length > 0;
|
|
7702
|
-
const zoneStore = (0,
|
|
7457
|
+
const zoneStore = (0, import_react45.useContext)(ZoneStoreContext);
|
|
7703
7458
|
const isHovering = useContextStore(
|
|
7704
7459
|
ZoneStoreContext,
|
|
7705
7460
|
(s) => s.hoveringComponent === itemId
|
|
@@ -7826,7 +7581,7 @@ var LayerTree = ({
|
|
|
7826
7581
|
};
|
|
7827
7582
|
|
|
7828
7583
|
// components/Puck/components/Outline/index.tsx
|
|
7829
|
-
var
|
|
7584
|
+
var import_react46 = require("react");
|
|
7830
7585
|
|
|
7831
7586
|
// lib/data/find-zones-for-area.ts
|
|
7832
7587
|
init_react_import();
|
|
@@ -7844,7 +7599,7 @@ var Outline = () => {
|
|
|
7844
7599
|
const rootZones = useAppStore(
|
|
7845
7600
|
(0, import_shallow7.useShallow)((s) => findZonesForArea(s.state, "root"))
|
|
7846
7601
|
);
|
|
7847
|
-
const Wrapper = (0,
|
|
7602
|
+
const Wrapper = (0, import_react46.useMemo)(() => outlineOverride || "div", [outlineOverride]);
|
|
7848
7603
|
return /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(Wrapper, { children: rootZones.map((zoneCompound) => /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(
|
|
7849
7604
|
LayerTree,
|
|
7850
7605
|
{
|
|
@@ -7978,11 +7733,11 @@ var getBox = function getBox2(el) {
|
|
|
7978
7733
|
};
|
|
7979
7734
|
|
|
7980
7735
|
// components/Puck/components/Canvas/index.tsx
|
|
7981
|
-
var
|
|
7736
|
+
var import_react48 = require("react");
|
|
7982
7737
|
|
|
7983
7738
|
// components/ViewportControls/index.tsx
|
|
7984
7739
|
init_react_import();
|
|
7985
|
-
var
|
|
7740
|
+
var import_react47 = require("react");
|
|
7986
7741
|
|
|
7987
7742
|
// css-module:/home/runner/work/puck/puck/packages/core/components/ViewportControls/styles.module.css#css-module
|
|
7988
7743
|
init_react_import();
|
|
@@ -8005,8 +7760,8 @@ var ViewportButton = ({
|
|
|
8005
7760
|
onClick
|
|
8006
7761
|
}) => {
|
|
8007
7762
|
const viewports = useAppStore((s) => s.state.ui.viewports);
|
|
8008
|
-
const [isActive, setIsActive] = (0,
|
|
8009
|
-
(0,
|
|
7763
|
+
const [isActive, setIsActive] = (0, import_react47.useState)(false);
|
|
7764
|
+
(0, import_react47.useEffect)(() => {
|
|
8010
7765
|
setIsActive(width === viewports.current.width);
|
|
8011
7766
|
}, [width, viewports.current.width]);
|
|
8012
7767
|
return /* @__PURE__ */ (0, import_jsx_runtime37.jsx)("span", { className: getClassNameButton({ isActive }), children: /* @__PURE__ */ (0, import_jsx_runtime37.jsx)(
|
|
@@ -8043,7 +7798,7 @@ var ViewportControls = ({
|
|
|
8043
7798
|
const defaultsContainAutoZoom = defaultZoomOptions.find(
|
|
8044
7799
|
(option) => option.value === autoZoom
|
|
8045
7800
|
);
|
|
8046
|
-
const zoomOptions = (0,
|
|
7801
|
+
const zoomOptions = (0, import_react47.useMemo)(
|
|
8047
7802
|
() => [
|
|
8048
7803
|
...defaultZoomOptions,
|
|
8049
7804
|
...defaultsContainAutoZoom ? [] : [
|
|
@@ -8192,17 +7947,17 @@ var Canvas = () => {
|
|
|
8192
7947
|
viewports: s.state.ui.viewports
|
|
8193
7948
|
}))
|
|
8194
7949
|
);
|
|
8195
|
-
const frameRef = (0,
|
|
8196
|
-
const [showTransition, setShowTransition] = (0,
|
|
8197
|
-
const defaultRender = (0,
|
|
7950
|
+
const frameRef = (0, import_react48.useRef)(null);
|
|
7951
|
+
const [showTransition, setShowTransition] = (0, import_react48.useState)(false);
|
|
7952
|
+
const defaultRender = (0, import_react48.useMemo)(() => {
|
|
8198
7953
|
const PuckDefault = ({ children }) => /* @__PURE__ */ (0, import_jsx_runtime38.jsx)(import_jsx_runtime38.Fragment, { children });
|
|
8199
7954
|
return PuckDefault;
|
|
8200
7955
|
}, []);
|
|
8201
|
-
const CustomPreview = (0,
|
|
7956
|
+
const CustomPreview = (0, import_react48.useMemo)(
|
|
8202
7957
|
() => overrides.preview || defaultRender,
|
|
8203
7958
|
[overrides]
|
|
8204
7959
|
);
|
|
8205
|
-
const getFrameDimensions = (0,
|
|
7960
|
+
const getFrameDimensions = (0, import_react48.useCallback)(() => {
|
|
8206
7961
|
if (frameRef.current) {
|
|
8207
7962
|
const frame = frameRef.current;
|
|
8208
7963
|
const box = getBox(frame);
|
|
@@ -8210,7 +7965,7 @@ var Canvas = () => {
|
|
|
8210
7965
|
}
|
|
8211
7966
|
return { width: 0, height: 0 };
|
|
8212
7967
|
}, [frameRef]);
|
|
8213
|
-
const resetAutoZoom = (0,
|
|
7968
|
+
const resetAutoZoom = (0, import_react48.useCallback)(
|
|
8214
7969
|
(newViewports = viewports) => {
|
|
8215
7970
|
if (frameRef.current) {
|
|
8216
7971
|
setZoomConfig(
|
|
@@ -8224,11 +7979,11 @@ var Canvas = () => {
|
|
|
8224
7979
|
},
|
|
8225
7980
|
[frameRef, zoomConfig, viewports]
|
|
8226
7981
|
);
|
|
8227
|
-
(0,
|
|
7982
|
+
(0, import_react48.useEffect)(() => {
|
|
8228
7983
|
setShowTransition(false);
|
|
8229
7984
|
resetAutoZoom(viewports);
|
|
8230
7985
|
}, [frameRef, leftSideBarVisible, rightSideBarVisible]);
|
|
8231
|
-
(0,
|
|
7986
|
+
(0, import_react48.useEffect)(() => {
|
|
8232
7987
|
const { height: frameHeight } = getFrameDimensions();
|
|
8233
7988
|
if (viewports.current.height === "auto") {
|
|
8234
7989
|
setZoomConfig(__spreadProps(__spreadValues({}, zoomConfig), {
|
|
@@ -8236,13 +7991,13 @@ var Canvas = () => {
|
|
|
8236
7991
|
}));
|
|
8237
7992
|
}
|
|
8238
7993
|
}, [zoomConfig.zoom]);
|
|
8239
|
-
(0,
|
|
7994
|
+
(0, import_react48.useEffect)(() => {
|
|
8240
7995
|
if (ZOOM_ON_CHANGE) {
|
|
8241
7996
|
setShowTransition(true);
|
|
8242
7997
|
resetAutoZoom(viewports);
|
|
8243
7998
|
}
|
|
8244
7999
|
}, [viewports.current.width]);
|
|
8245
|
-
(0,
|
|
8000
|
+
(0, import_react48.useEffect)(() => {
|
|
8246
8001
|
const cb = () => {
|
|
8247
8002
|
setShowTransition(false);
|
|
8248
8003
|
resetAutoZoom();
|
|
@@ -8252,8 +8007,8 @@ var Canvas = () => {
|
|
|
8252
8007
|
window.removeEventListener("resize", cb);
|
|
8253
8008
|
};
|
|
8254
8009
|
}, []);
|
|
8255
|
-
const [showLoader, setShowLoader] = (0,
|
|
8256
|
-
(0,
|
|
8010
|
+
const [showLoader, setShowLoader] = (0, import_react48.useState)(false);
|
|
8011
|
+
(0, import_react48.useEffect)(() => {
|
|
8257
8012
|
setTimeout(() => {
|
|
8258
8013
|
setShowLoader(true);
|
|
8259
8014
|
}, 500);
|
|
@@ -8331,7 +8086,7 @@ var Canvas = () => {
|
|
|
8331
8086
|
|
|
8332
8087
|
// lib/use-loaded-overrides.ts
|
|
8333
8088
|
init_react_import();
|
|
8334
|
-
var
|
|
8089
|
+
var import_react49 = require("react");
|
|
8335
8090
|
|
|
8336
8091
|
// lib/load-overrides.ts
|
|
8337
8092
|
init_react_import();
|
|
@@ -8370,7 +8125,7 @@ var useLoadedOverrides = ({
|
|
|
8370
8125
|
overrides,
|
|
8371
8126
|
plugins
|
|
8372
8127
|
}) => {
|
|
8373
|
-
return (0,
|
|
8128
|
+
return (0, import_react49.useMemo)(() => {
|
|
8374
8129
|
return loadOverrides({ overrides, plugins });
|
|
8375
8130
|
}, [plugins, overrides]);
|
|
8376
8131
|
};
|
|
@@ -8382,14 +8137,14 @@ var DefaultOverride = ({ children }) => /* @__PURE__ */ (0, import_jsx_runtime39
|
|
|
8382
8137
|
|
|
8383
8138
|
// lib/use-inject-css.ts
|
|
8384
8139
|
init_react_import();
|
|
8385
|
-
var
|
|
8140
|
+
var import_react50 = require("react");
|
|
8386
8141
|
var styles = ``;
|
|
8387
8142
|
var useInjectStyleSheet = (initialStyles, iframeEnabled) => {
|
|
8388
|
-
const [el, setEl] = (0,
|
|
8389
|
-
(0,
|
|
8143
|
+
const [el, setEl] = (0, import_react50.useState)();
|
|
8144
|
+
(0, import_react50.useEffect)(() => {
|
|
8390
8145
|
setEl(document.createElement("style"));
|
|
8391
8146
|
}, []);
|
|
8392
|
-
(0,
|
|
8147
|
+
(0, import_react50.useEffect)(() => {
|
|
8393
8148
|
var _a;
|
|
8394
8149
|
if (!el || typeof window === "undefined") {
|
|
8395
8150
|
return;
|
|
@@ -8409,10 +8164,10 @@ var useInjectGlobalCss = (iframeEnabled) => {
|
|
|
8409
8164
|
|
|
8410
8165
|
// lib/use-preview-mode-hotkeys.ts
|
|
8411
8166
|
init_react_import();
|
|
8412
|
-
var
|
|
8167
|
+
var import_react51 = require("react");
|
|
8413
8168
|
var usePreviewModeHotkeys = () => {
|
|
8414
8169
|
const appStore = useAppStoreApi();
|
|
8415
|
-
const toggleInteractive = (0,
|
|
8170
|
+
const toggleInteractive = (0, import_react51.useCallback)(() => {
|
|
8416
8171
|
const dispatch = appStore.getState().dispatch;
|
|
8417
8172
|
dispatch({
|
|
8418
8173
|
type: "setUi",
|
|
@@ -8427,7 +8182,7 @@ var usePreviewModeHotkeys = () => {
|
|
|
8427
8182
|
|
|
8428
8183
|
// lib/use-puck.ts
|
|
8429
8184
|
init_react_import();
|
|
8430
|
-
var
|
|
8185
|
+
var import_react52 = require("react");
|
|
8431
8186
|
var import_zustand6 = require("zustand");
|
|
8432
8187
|
var generateUsePuck = (store) => {
|
|
8433
8188
|
const history = {
|
|
@@ -8460,7 +8215,7 @@ var generateUsePuck = (store) => {
|
|
|
8460
8215
|
};
|
|
8461
8216
|
return storeData;
|
|
8462
8217
|
};
|
|
8463
|
-
var UsePuckStoreContext = (0,
|
|
8218
|
+
var UsePuckStoreContext = (0, import_react52.createContext)(
|
|
8464
8219
|
null
|
|
8465
8220
|
);
|
|
8466
8221
|
var convertToPickedStore = (store) => {
|
|
@@ -8474,12 +8229,12 @@ var convertToPickedStore = (store) => {
|
|
|
8474
8229
|
};
|
|
8475
8230
|
};
|
|
8476
8231
|
var useRegisterUsePuckStore = (appStore) => {
|
|
8477
|
-
const [usePuckStore] = (0,
|
|
8232
|
+
const [usePuckStore] = (0, import_react52.useState)(
|
|
8478
8233
|
() => (0, import_zustand6.createStore)(
|
|
8479
8234
|
() => generateUsePuck(convertToPickedStore(appStore.getState()))
|
|
8480
8235
|
)
|
|
8481
8236
|
);
|
|
8482
|
-
(0,
|
|
8237
|
+
(0, import_react52.useEffect)(() => {
|
|
8483
8238
|
return appStore.subscribe(
|
|
8484
8239
|
(store) => convertToPickedStore(store),
|
|
8485
8240
|
(pickedStore) => {
|
|
@@ -8491,7 +8246,7 @@ var useRegisterUsePuckStore = (appStore) => {
|
|
|
8491
8246
|
};
|
|
8492
8247
|
function createUsePuck() {
|
|
8493
8248
|
return function usePuck2(selector) {
|
|
8494
|
-
const usePuckApi = (0,
|
|
8249
|
+
const usePuckApi = (0, import_react52.useContext)(UsePuckStoreContext);
|
|
8495
8250
|
if (!usePuckApi) {
|
|
8496
8251
|
throw new Error("usePuck must be used inside <Puck>.");
|
|
8497
8252
|
}
|
|
@@ -8503,7 +8258,7 @@ function createUsePuck() {
|
|
|
8503
8258
|
};
|
|
8504
8259
|
}
|
|
8505
8260
|
function usePuck() {
|
|
8506
|
-
(0,
|
|
8261
|
+
(0, import_react52.useEffect)(() => {
|
|
8507
8262
|
console.warn(
|
|
8508
8263
|
"You're using the `usePuck` method without a selector, which may cause unnecessary re-renders. Replace with `createUsePuck` and provide a selector for improved performance."
|
|
8509
8264
|
);
|
|
@@ -8511,7 +8266,7 @@ function usePuck() {
|
|
|
8511
8266
|
return createUsePuck()((s) => s);
|
|
8512
8267
|
}
|
|
8513
8268
|
function useGetPuck() {
|
|
8514
|
-
const usePuckApi = (0,
|
|
8269
|
+
const usePuckApi = (0, import_react52.useContext)(UsePuckStoreContext);
|
|
8515
8270
|
if (!usePuckApi) {
|
|
8516
8271
|
throw new Error("usePuckGet must be used inside <Puck>.");
|
|
8517
8272
|
}
|
|
@@ -8523,7 +8278,7 @@ var import_fast_deep_equal3 = __toESM(require("fast-deep-equal"));
|
|
|
8523
8278
|
|
|
8524
8279
|
// components/Puck/components/Header/index.tsx
|
|
8525
8280
|
init_react_import();
|
|
8526
|
-
var
|
|
8281
|
+
var import_react53 = require("react");
|
|
8527
8282
|
|
|
8528
8283
|
// components/MenuBar/index.tsx
|
|
8529
8284
|
init_react_import();
|
|
@@ -8605,7 +8360,7 @@ var HeaderInner = () => {
|
|
|
8605
8360
|
} = usePropsContext();
|
|
8606
8361
|
const dispatch = useAppStore((s) => s.dispatch);
|
|
8607
8362
|
const appStore = useAppStoreApi();
|
|
8608
|
-
const defaultHeaderRender = (0,
|
|
8363
|
+
const defaultHeaderRender = (0, import_react53.useMemo)(() => {
|
|
8609
8364
|
if (renderHeader) {
|
|
8610
8365
|
console.warn(
|
|
8611
8366
|
"`renderHeader` is deprecated. Please use `overrides.header` and the `usePuck` hook instead"
|
|
@@ -8620,7 +8375,7 @@ var HeaderInner = () => {
|
|
|
8620
8375
|
}
|
|
8621
8376
|
return DefaultOverride;
|
|
8622
8377
|
}, [renderHeader]);
|
|
8623
|
-
const defaultHeaderActionsRender = (0,
|
|
8378
|
+
const defaultHeaderActionsRender = (0, import_react53.useMemo)(() => {
|
|
8624
8379
|
if (renderHeaderActions) {
|
|
8625
8380
|
console.warn(
|
|
8626
8381
|
"`renderHeaderActions` is deprecated. Please use `overrides.headerActions` and the `usePuck` hook instead."
|
|
@@ -8640,7 +8395,7 @@ var HeaderInner = () => {
|
|
|
8640
8395
|
const CustomHeaderActions = useAppStore(
|
|
8641
8396
|
(s) => s.overrides.headerActions || defaultHeaderActionsRender
|
|
8642
8397
|
);
|
|
8643
|
-
const [menuOpen, setMenuOpen] = (0,
|
|
8398
|
+
const [menuOpen, setMenuOpen] = (0, import_react53.useState)(false);
|
|
8644
8399
|
const rootTitle = useAppStore((s) => {
|
|
8645
8400
|
var _a, _b;
|
|
8646
8401
|
const rootData = (_a = s.state.indexes.nodes["root"]) == null ? void 0 : _a.data;
|
|
@@ -8650,7 +8405,7 @@ var HeaderInner = () => {
|
|
|
8650
8405
|
const rightSideBarVisible = useAppStore(
|
|
8651
8406
|
(s) => s.state.ui.rightSideBarVisible
|
|
8652
8407
|
);
|
|
8653
|
-
const toggleSidebars = (0,
|
|
8408
|
+
const toggleSidebars = (0, import_react53.useCallback)(
|
|
8654
8409
|
(sidebar) => {
|
|
8655
8410
|
const widerViewport = window.matchMedia("(min-width: 638px)").matches;
|
|
8656
8411
|
const sideBarVisible = sidebar === "left" ? leftSideBarVisible : rightSideBarVisible;
|
|
@@ -8753,7 +8508,7 @@ var HeaderInner = () => {
|
|
|
8753
8508
|
}
|
|
8754
8509
|
);
|
|
8755
8510
|
};
|
|
8756
|
-
var Header = (0,
|
|
8511
|
+
var Header = (0, import_react53.memo)(HeaderInner);
|
|
8757
8512
|
|
|
8758
8513
|
// components/Puck/index.tsx
|
|
8759
8514
|
var import_jsx_runtime42 = require("react/jsx-runtime");
|
|
@@ -8768,11 +8523,11 @@ var FieldSideBar = () => {
|
|
|
8768
8523
|
);
|
|
8769
8524
|
return /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(SidebarSection, { noPadding: true, noBorderTop: true, showBreadcrumbs: true, title, children: /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(Fields, {}) });
|
|
8770
8525
|
};
|
|
8771
|
-
var propsContext = (0,
|
|
8526
|
+
var propsContext = (0, import_react54.createContext)({});
|
|
8772
8527
|
function PropsProvider(props) {
|
|
8773
8528
|
return /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(propsContext.Provider, { value: props, children: props.children });
|
|
8774
8529
|
}
|
|
8775
|
-
var usePropsContext = () => (0,
|
|
8530
|
+
var usePropsContext = () => (0, import_react54.useContext)(propsContext);
|
|
8776
8531
|
function PuckProvider({ children }) {
|
|
8777
8532
|
const {
|
|
8778
8533
|
config,
|
|
@@ -8788,14 +8543,14 @@ function PuckProvider({ children }) {
|
|
|
8788
8543
|
metadata,
|
|
8789
8544
|
onAction
|
|
8790
8545
|
} = usePropsContext();
|
|
8791
|
-
const iframe = (0,
|
|
8546
|
+
const iframe = (0, import_react54.useMemo)(
|
|
8792
8547
|
() => __spreadValues({
|
|
8793
8548
|
enabled: true,
|
|
8794
8549
|
waitForStyles: true
|
|
8795
8550
|
}, _iframe),
|
|
8796
8551
|
[_iframe]
|
|
8797
8552
|
);
|
|
8798
|
-
const [generatedAppState] = (0,
|
|
8553
|
+
const [generatedAppState] = (0, import_react54.useState)(() => {
|
|
8799
8554
|
var _a, _b, _c, _d, _e, _f, _g, _h, _i;
|
|
8800
8555
|
const initial = __spreadValues(__spreadValues({}, defaultAppState.ui), initialUi);
|
|
8801
8556
|
let clientUiState = {};
|
|
@@ -8855,7 +8610,7 @@ function PuckProvider({ children }) {
|
|
|
8855
8610
|
return walkAppState(newAppState, config);
|
|
8856
8611
|
});
|
|
8857
8612
|
const { appendData = true } = _initialHistory || {};
|
|
8858
|
-
const [blendedHistories] = (0,
|
|
8613
|
+
const [blendedHistories] = (0, import_react54.useState)(
|
|
8859
8614
|
[
|
|
8860
8615
|
...(_initialHistory == null ? void 0 : _initialHistory.histories) || [],
|
|
8861
8616
|
...appendData ? [{ state: generatedAppState }] : []
|
|
@@ -8875,7 +8630,7 @@ function PuckProvider({ children }) {
|
|
|
8875
8630
|
overrides,
|
|
8876
8631
|
plugins
|
|
8877
8632
|
});
|
|
8878
|
-
const generateAppStore = (0,
|
|
8633
|
+
const generateAppStore = (0, import_react54.useCallback)(
|
|
8879
8634
|
(state) => {
|
|
8880
8635
|
return {
|
|
8881
8636
|
state,
|
|
@@ -8899,15 +8654,15 @@ function PuckProvider({ children }) {
|
|
|
8899
8654
|
metadata
|
|
8900
8655
|
]
|
|
8901
8656
|
);
|
|
8902
|
-
const [appStore] = (0,
|
|
8657
|
+
const [appStore] = (0, import_react54.useState)(
|
|
8903
8658
|
() => createAppStore(generateAppStore(initialAppState))
|
|
8904
8659
|
);
|
|
8905
|
-
(0,
|
|
8660
|
+
(0, import_react54.useEffect)(() => {
|
|
8906
8661
|
if (process.env.NODE_ENV !== "production") {
|
|
8907
8662
|
window.__PUCK_INTERNAL_DO_NOT_USE = { appStore };
|
|
8908
8663
|
}
|
|
8909
8664
|
}, [appStore]);
|
|
8910
|
-
(0,
|
|
8665
|
+
(0, import_react54.useEffect)(() => {
|
|
8911
8666
|
const state = appStore.getState().state;
|
|
8912
8667
|
appStore.setState(__spreadValues({}, generateAppStore(state)));
|
|
8913
8668
|
}, [config, plugins, loadedOverrides, viewports, iframe, onAction, metadata]);
|
|
@@ -8916,8 +8671,8 @@ function PuckProvider({ children }) {
|
|
|
8916
8671
|
index: initialHistoryIndex,
|
|
8917
8672
|
initialAppState
|
|
8918
8673
|
});
|
|
8919
|
-
const previousData = (0,
|
|
8920
|
-
(0,
|
|
8674
|
+
const previousData = (0, import_react54.useRef)(null);
|
|
8675
|
+
(0, import_react54.useEffect)(() => {
|
|
8921
8676
|
appStore.subscribe(
|
|
8922
8677
|
(s) => s.state.data,
|
|
8923
8678
|
(data) => {
|
|
@@ -8931,7 +8686,7 @@ function PuckProvider({ children }) {
|
|
|
8931
8686
|
}, []);
|
|
8932
8687
|
useRegisterPermissionsSlice(appStore, permissions);
|
|
8933
8688
|
const uPuckStore = useRegisterUsePuckStore(appStore);
|
|
8934
|
-
(0,
|
|
8689
|
+
(0, import_react54.useEffect)(() => {
|
|
8935
8690
|
const { resolveAndCommitData } = appStore.getState();
|
|
8936
8691
|
resolveAndCommitData();
|
|
8937
8692
|
}, []);
|
|
@@ -8943,7 +8698,7 @@ function PuckLayout({ children }) {
|
|
|
8943
8698
|
dnd,
|
|
8944
8699
|
initialHistory: _initialHistory
|
|
8945
8700
|
} = usePropsContext();
|
|
8946
|
-
const iframe = (0,
|
|
8701
|
+
const iframe = (0, import_react54.useMemo)(
|
|
8947
8702
|
() => __spreadValues({
|
|
8948
8703
|
enabled: true,
|
|
8949
8704
|
waitForStyles: true
|
|
@@ -8956,7 +8711,7 @@ function PuckLayout({ children }) {
|
|
|
8956
8711
|
(s) => s.state.ui.rightSideBarVisible
|
|
8957
8712
|
);
|
|
8958
8713
|
const dispatch = useAppStore((s) => s.dispatch);
|
|
8959
|
-
(0,
|
|
8714
|
+
(0, import_react54.useEffect)(() => {
|
|
8960
8715
|
if (!window.matchMedia("(min-width: 638px)").matches) {
|
|
8961
8716
|
dispatch({
|
|
8962
8717
|
type: "setUi",
|
|
@@ -8980,17 +8735,17 @@ function PuckLayout({ children }) {
|
|
|
8980
8735
|
};
|
|
8981
8736
|
}, []);
|
|
8982
8737
|
const overrides = useAppStore((s) => s.overrides);
|
|
8983
|
-
const CustomPuck = (0,
|
|
8738
|
+
const CustomPuck = (0, import_react54.useMemo)(
|
|
8984
8739
|
() => overrides.puck || DefaultOverride,
|
|
8985
8740
|
[overrides]
|
|
8986
8741
|
);
|
|
8987
|
-
const [mounted, setMounted] = (0,
|
|
8988
|
-
(0,
|
|
8742
|
+
const [mounted, setMounted] = (0, import_react54.useState)(false);
|
|
8743
|
+
(0, import_react54.useEffect)(() => {
|
|
8989
8744
|
setMounted(true);
|
|
8990
8745
|
}, []);
|
|
8991
8746
|
const ready = useAppStore((s) => s.status === "READY");
|
|
8992
8747
|
useMonitorHotkeys();
|
|
8993
|
-
(0,
|
|
8748
|
+
(0, import_react54.useEffect)(() => {
|
|
8994
8749
|
if (ready && iframe.enabled) {
|
|
8995
8750
|
const frameDoc = getFrame();
|
|
8996
8751
|
if (frameDoc) {
|
|
@@ -9029,6 +8784,230 @@ Puck.Components = Components;
|
|
|
9029
8784
|
Puck.Fields = Fields;
|
|
9030
8785
|
Puck.Outline = Outline;
|
|
9031
8786
|
Puck.Preview = Preview2;
|
|
8787
|
+
|
|
8788
|
+
// lib/migrate.ts
|
|
8789
|
+
init_react_import();
|
|
8790
|
+
var migrations = [
|
|
8791
|
+
// Migrate root to root.props
|
|
8792
|
+
(data) => {
|
|
8793
|
+
const rootProps = data.root.props || data.root;
|
|
8794
|
+
if (Object.keys(data.root).length > 0 && !data.root.props) {
|
|
8795
|
+
console.warn(
|
|
8796
|
+
"Migration applied: Root props moved from `root` to `root.props`."
|
|
8797
|
+
);
|
|
8798
|
+
return __spreadProps(__spreadValues({}, data), {
|
|
8799
|
+
root: {
|
|
8800
|
+
props: __spreadValues({}, rootProps)
|
|
8801
|
+
}
|
|
8802
|
+
});
|
|
8803
|
+
}
|
|
8804
|
+
return data;
|
|
8805
|
+
},
|
|
8806
|
+
// Migrate zones to slots
|
|
8807
|
+
(data, config, migrationOptions) => {
|
|
8808
|
+
var _a, _b;
|
|
8809
|
+
if (!config) return data;
|
|
8810
|
+
console.log("Migrating DropZones to slots...");
|
|
8811
|
+
const updatedItems = {};
|
|
8812
|
+
const appState = __spreadProps(__spreadValues({}, defaultAppState), { data });
|
|
8813
|
+
const { indexes } = walkAppState(appState, config);
|
|
8814
|
+
const deletedCompounds = [];
|
|
8815
|
+
walkAppState(appState, config, (content, zoneCompound, zoneType) => {
|
|
8816
|
+
var _a2, _b2, _c;
|
|
8817
|
+
if (zoneType === "dropzone") {
|
|
8818
|
+
const [id, slotName] = zoneCompound.split(":");
|
|
8819
|
+
const nodeData = indexes.nodes[id].data;
|
|
8820
|
+
const componentType = nodeData.type;
|
|
8821
|
+
const configForComponent = id === "root" ? config.root : config.components[componentType];
|
|
8822
|
+
if (((_b2 = (_a2 = configForComponent == null ? void 0 : configForComponent.fields) == null ? void 0 : _a2[slotName]) == null ? void 0 : _b2.type) === "slot") {
|
|
8823
|
+
updatedItems[id] = __spreadProps(__spreadValues({}, nodeData), {
|
|
8824
|
+
props: __spreadProps(__spreadValues(__spreadValues({}, nodeData.props), (_c = updatedItems[id]) == null ? void 0 : _c.props), {
|
|
8825
|
+
[slotName]: content
|
|
8826
|
+
})
|
|
8827
|
+
});
|
|
8828
|
+
deletedCompounds.push(zoneCompound);
|
|
8829
|
+
}
|
|
8830
|
+
return content;
|
|
8831
|
+
}
|
|
8832
|
+
return content;
|
|
8833
|
+
});
|
|
8834
|
+
const updated = walkAppState(
|
|
8835
|
+
appState,
|
|
8836
|
+
config,
|
|
8837
|
+
(content) => content,
|
|
8838
|
+
(item) => {
|
|
8839
|
+
var _a2;
|
|
8840
|
+
return (_a2 = updatedItems[item.props.id]) != null ? _a2 : item;
|
|
8841
|
+
}
|
|
8842
|
+
);
|
|
8843
|
+
deletedCompounds.forEach((zoneCompound) => {
|
|
8844
|
+
var _a2;
|
|
8845
|
+
const [_, propName] = zoneCompound.split(":");
|
|
8846
|
+
console.log(
|
|
8847
|
+
`\u2713 Success: Migrated "${zoneCompound}" from DropZone to slot field "${propName}"`
|
|
8848
|
+
);
|
|
8849
|
+
(_a2 = updated.data.zones) == null ? true : delete _a2[zoneCompound];
|
|
8850
|
+
});
|
|
8851
|
+
if (migrationOptions == null ? void 0 : migrationOptions.migrateDynamicZonesForComponent) {
|
|
8852
|
+
const unmigratedZonesGrouped = {};
|
|
8853
|
+
Object.keys((_a = updated.data.zones) != null ? _a : {}).forEach((zoneCompound) => {
|
|
8854
|
+
var _a2;
|
|
8855
|
+
const [componentId, propName] = zoneCompound.split(":");
|
|
8856
|
+
const content = (_a2 = updated.data.zones) == null ? void 0 : _a2[zoneCompound];
|
|
8857
|
+
if (!content) {
|
|
8858
|
+
return;
|
|
8859
|
+
}
|
|
8860
|
+
if (!unmigratedZonesGrouped[componentId]) {
|
|
8861
|
+
unmigratedZonesGrouped[componentId] = {};
|
|
8862
|
+
}
|
|
8863
|
+
if (!unmigratedZonesGrouped[componentId][propName]) {
|
|
8864
|
+
unmigratedZonesGrouped[componentId][propName] = content;
|
|
8865
|
+
}
|
|
8866
|
+
});
|
|
8867
|
+
Object.keys(unmigratedZonesGrouped).forEach((componentId) => {
|
|
8868
|
+
updated.data = walkTree(updated.data, config, (content) => {
|
|
8869
|
+
return content.map((child) => {
|
|
8870
|
+
var _a2;
|
|
8871
|
+
if (child.props.id !== componentId) {
|
|
8872
|
+
return child;
|
|
8873
|
+
}
|
|
8874
|
+
const migrateFn = (_a2 = migrationOptions == null ? void 0 : migrationOptions.migrateDynamicZonesForComponent) == null ? void 0 : _a2[child.type];
|
|
8875
|
+
if (!migrateFn) {
|
|
8876
|
+
return child;
|
|
8877
|
+
}
|
|
8878
|
+
const zones = unmigratedZonesGrouped[componentId];
|
|
8879
|
+
const migratedProps = migrateFn(child.props, zones);
|
|
8880
|
+
Object.keys(zones).forEach((propName) => {
|
|
8881
|
+
var _a3;
|
|
8882
|
+
const zoneCompound = `${componentId}:${propName}`;
|
|
8883
|
+
console.log(`\u2713 Success: Migrated "${zoneCompound}" DropZone`);
|
|
8884
|
+
(_a3 = updated.data.zones) == null ? true : delete _a3[zoneCompound];
|
|
8885
|
+
});
|
|
8886
|
+
return __spreadProps(__spreadValues({}, child), {
|
|
8887
|
+
props: migratedProps
|
|
8888
|
+
});
|
|
8889
|
+
});
|
|
8890
|
+
});
|
|
8891
|
+
});
|
|
8892
|
+
}
|
|
8893
|
+
Object.keys((_b = updated.data.zones) != null ? _b : {}).forEach((zoneCompound) => {
|
|
8894
|
+
const [_, propName] = zoneCompound.split(":");
|
|
8895
|
+
throw new Error(
|
|
8896
|
+
`Could not migrate DropZone "${zoneCompound}" to slot field. No slot exists with the name "${propName}".`
|
|
8897
|
+
);
|
|
8898
|
+
});
|
|
8899
|
+
delete updated.data.zones;
|
|
8900
|
+
return updated.data;
|
|
8901
|
+
}
|
|
8902
|
+
];
|
|
8903
|
+
function migrate(data, config, migrationOptions) {
|
|
8904
|
+
return migrations == null ? void 0 : migrations.reduce(
|
|
8905
|
+
(acc, migration) => migration(acc, config, migrationOptions),
|
|
8906
|
+
data
|
|
8907
|
+
);
|
|
8908
|
+
}
|
|
8909
|
+
|
|
8910
|
+
// lib/transform-props.ts
|
|
8911
|
+
init_react_import();
|
|
8912
|
+
|
|
8913
|
+
// lib/data/default-data.ts
|
|
8914
|
+
init_react_import();
|
|
8915
|
+
var defaultData = (data) => __spreadProps(__spreadValues({}, data), {
|
|
8916
|
+
root: data.root || {},
|
|
8917
|
+
content: data.content || []
|
|
8918
|
+
});
|
|
8919
|
+
|
|
8920
|
+
// lib/transform-props.ts
|
|
8921
|
+
function transformProps(data, propTransforms, config = { components: {} }) {
|
|
8922
|
+
const mapItem = (item) => {
|
|
8923
|
+
if (propTransforms[item.type]) {
|
|
8924
|
+
return __spreadProps(__spreadValues({}, item), {
|
|
8925
|
+
props: __spreadValues({
|
|
8926
|
+
id: item.props.id
|
|
8927
|
+
}, propTransforms[item.type](item.props))
|
|
8928
|
+
});
|
|
8929
|
+
}
|
|
8930
|
+
return item;
|
|
8931
|
+
};
|
|
8932
|
+
const defaultedData = defaultData(data);
|
|
8933
|
+
const rootProps = defaultedData.root.props || defaultedData.root;
|
|
8934
|
+
let newRoot = __spreadValues({}, defaultedData.root);
|
|
8935
|
+
if (propTransforms["root"]) {
|
|
8936
|
+
newRoot.props = propTransforms["root"](rootProps);
|
|
8937
|
+
}
|
|
8938
|
+
const dataWithUpdatedRoot = __spreadProps(__spreadValues({}, defaultedData), { root: newRoot });
|
|
8939
|
+
const updatedData = walkTree(
|
|
8940
|
+
dataWithUpdatedRoot,
|
|
8941
|
+
config,
|
|
8942
|
+
(content) => content.map(mapItem)
|
|
8943
|
+
);
|
|
8944
|
+
if (!defaultedData.root.props) {
|
|
8945
|
+
updatedData.root = updatedData.root.props;
|
|
8946
|
+
}
|
|
8947
|
+
return updatedData;
|
|
8948
|
+
}
|
|
8949
|
+
|
|
8950
|
+
// lib/resolve-all-data.ts
|
|
8951
|
+
init_react_import();
|
|
8952
|
+
|
|
8953
|
+
// lib/data/to-component.ts
|
|
8954
|
+
init_react_import();
|
|
8955
|
+
var toComponent = (item) => {
|
|
8956
|
+
return "type" in item ? item : __spreadProps(__spreadValues({}, item), {
|
|
8957
|
+
props: __spreadProps(__spreadValues({}, item.props), { id: "root" }),
|
|
8958
|
+
type: "root"
|
|
8959
|
+
});
|
|
8960
|
+
};
|
|
8961
|
+
|
|
8962
|
+
// lib/resolve-all-data.ts
|
|
8963
|
+
function resolveAllData(_0, _1) {
|
|
8964
|
+
return __async(this, arguments, function* (data, config, metadata = {}, onResolveStart, onResolveEnd) {
|
|
8965
|
+
var _a;
|
|
8966
|
+
const defaultedData = defaultData(data);
|
|
8967
|
+
const resolveNode = (_node) => __async(this, null, function* () {
|
|
8968
|
+
const node = toComponent(_node);
|
|
8969
|
+
onResolveStart == null ? void 0 : onResolveStart(node);
|
|
8970
|
+
const resolved = (yield resolveComponentData(
|
|
8971
|
+
node,
|
|
8972
|
+
config,
|
|
8973
|
+
metadata,
|
|
8974
|
+
() => {
|
|
8975
|
+
},
|
|
8976
|
+
() => {
|
|
8977
|
+
},
|
|
8978
|
+
"force"
|
|
8979
|
+
)).node;
|
|
8980
|
+
const resolvedDeep = yield mapSlots(
|
|
8981
|
+
resolved,
|
|
8982
|
+
processContent,
|
|
8983
|
+
config
|
|
8984
|
+
);
|
|
8985
|
+
onResolveEnd == null ? void 0 : onResolveEnd(toComponent(resolvedDeep));
|
|
8986
|
+
return resolvedDeep;
|
|
8987
|
+
});
|
|
8988
|
+
const processContent = (content) => __async(this, null, function* () {
|
|
8989
|
+
return Promise.all(content.map(resolveNode));
|
|
8990
|
+
});
|
|
8991
|
+
const processZones = () => __async(this, null, function* () {
|
|
8992
|
+
var _a2;
|
|
8993
|
+
const zones = (_a2 = data.zones) != null ? _a2 : {};
|
|
8994
|
+
Object.entries(zones).forEach((_02) => __async(this, [_02], function* ([zoneKey, content]) {
|
|
8995
|
+
zones[zoneKey] = yield Promise.all(content.map(resolveNode));
|
|
8996
|
+
}));
|
|
8997
|
+
return zones;
|
|
8998
|
+
});
|
|
8999
|
+
const dynamic = {
|
|
9000
|
+
root: yield resolveNode(defaultedData.root),
|
|
9001
|
+
content: yield processContent(defaultedData.content),
|
|
9002
|
+
zones: yield processZones()
|
|
9003
|
+
};
|
|
9004
|
+
Object.keys((_a = defaultedData.zones) != null ? _a : {}).forEach((zoneKey) => __async(this, null, function* () {
|
|
9005
|
+
const content = defaultedData.zones[zoneKey];
|
|
9006
|
+
dynamic.zones[zoneKey] = yield processContent(content);
|
|
9007
|
+
}), {});
|
|
9008
|
+
return dynamic;
|
|
9009
|
+
});
|
|
9010
|
+
}
|
|
9032
9011
|
// Annotate the CommonJS export names for ESM import in node:
|
|
9033
9012
|
0 && (module.exports = {
|
|
9034
9013
|
Action,
|