@measured/puck 0.20.0-canary.d2e09bdc → 0.20.0-canary.d405985b
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-DBSNJT3R.mjs +8468 -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 +917 -906
- 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 +9347 -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-Bp8tnkJS.d.mts} +3 -2
- package/dist/{walk-tree-BOSl1o0G.d.ts → walk-tree-Bp8tnkJS.d.ts} +3 -2
- 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_react22 = 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;
|
|
@@ -2635,16 +2196,78 @@ var useRegisterFieldsSlice = (appStore, id) => {
|
|
|
2635
2196
|
}));
|
|
2636
2197
|
}
|
|
2637
2198
|
}),
|
|
2638
|
-
[id]
|
|
2199
|
+
[id]
|
|
2200
|
+
);
|
|
2201
|
+
(0, import_react8.useEffect)(() => {
|
|
2202
|
+
resolveFields(true);
|
|
2203
|
+
return appStore.subscribe(
|
|
2204
|
+
(s) => s.state.indexes.nodes[id || "root"],
|
|
2205
|
+
() => resolveFields()
|
|
2206
|
+
);
|
|
2207
|
+
}, [id]);
|
|
2208
|
+
};
|
|
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
|
|
2639
2258
|
);
|
|
2640
|
-
(
|
|
2641
|
-
|
|
2642
|
-
|
|
2643
|
-
|
|
2644
|
-
|
|
2645
|
-
|
|
2646
|
-
}
|
|
2647
|
-
|
|
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
|
+
});
|
|
2648
2271
|
|
|
2649
2272
|
// lib/data/to-root.ts
|
|
2650
2273
|
init_react_import();
|
|
@@ -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,7 +3802,7 @@ var ExternalField = ({
|
|
|
4151
3802
|
|
|
4152
3803
|
// components/AutoField/fields/RadioField/index.tsx
|
|
4153
3804
|
init_react_import();
|
|
4154
|
-
var
|
|
3805
|
+
var import_react19 = require("react");
|
|
4155
3806
|
|
|
4156
3807
|
// lib/safe-json-parse.ts
|
|
4157
3808
|
init_react_import();
|
|
@@ -4165,7 +3816,7 @@ var safeJsonParse = (str) => {
|
|
|
4165
3816
|
};
|
|
4166
3817
|
|
|
4167
3818
|
// components/AutoField/fields/RadioField/index.tsx
|
|
4168
|
-
var
|
|
3819
|
+
var import_jsx_runtime14 = require("react/jsx-runtime");
|
|
4169
3820
|
var getClassName11 = get_class_name_factory_default("Input", styles_module_default2);
|
|
4170
3821
|
var RadioField = ({
|
|
4171
3822
|
field,
|
|
@@ -4178,26 +3829,26 @@ var RadioField = ({
|
|
|
4178
3829
|
labelIcon,
|
|
4179
3830
|
Label: Label2
|
|
4180
3831
|
}) => {
|
|
4181
|
-
const flatOptions = (0,
|
|
3832
|
+
const flatOptions = (0, import_react19.useMemo)(
|
|
4182
3833
|
() => field.type === "radio" ? field.options.map(({ value: value2 }) => value2) : [],
|
|
4183
3834
|
[field]
|
|
4184
3835
|
);
|
|
4185
3836
|
if (field.type !== "radio" || !field.options) {
|
|
4186
3837
|
return null;
|
|
4187
3838
|
}
|
|
4188
|
-
return /* @__PURE__ */ (0,
|
|
3839
|
+
return /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
|
|
4189
3840
|
Label2,
|
|
4190
3841
|
{
|
|
4191
|
-
icon: labelIcon || /* @__PURE__ */ (0,
|
|
3842
|
+
icon: labelIcon || /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(CircleCheckBig, { size: 16 }),
|
|
4192
3843
|
label: label || name,
|
|
4193
3844
|
readOnly,
|
|
4194
3845
|
el: "div",
|
|
4195
|
-
children: /* @__PURE__ */ (0,
|
|
3846
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("div", { className: getClassName11("radioGroupItems"), id, children: field.options.map((option) => /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)(
|
|
4196
3847
|
"label",
|
|
4197
3848
|
{
|
|
4198
3849
|
className: getClassName11("radio"),
|
|
4199
3850
|
children: [
|
|
4200
|
-
/* @__PURE__ */ (0,
|
|
3851
|
+
/* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
|
|
4201
3852
|
"input",
|
|
4202
3853
|
{
|
|
4203
3854
|
type: "radio",
|
|
@@ -4217,7 +3868,7 @@ var RadioField = ({
|
|
|
4217
3868
|
checked: value === option.value
|
|
4218
3869
|
}
|
|
4219
3870
|
),
|
|
4220
|
-
/* @__PURE__ */ (0,
|
|
3871
|
+
/* @__PURE__ */ (0, import_jsx_runtime14.jsx)("div", { className: getClassName11("radioInner"), children: option.label || option.value })
|
|
4221
3872
|
]
|
|
4222
3873
|
},
|
|
4223
3874
|
option.label + option.value
|
|
@@ -4228,8 +3879,8 @@ var RadioField = ({
|
|
|
4228
3879
|
|
|
4229
3880
|
// components/AutoField/fields/SelectField/index.tsx
|
|
4230
3881
|
init_react_import();
|
|
4231
|
-
var
|
|
4232
|
-
var
|
|
3882
|
+
var import_react20 = require("react");
|
|
3883
|
+
var import_jsx_runtime15 = require("react/jsx-runtime");
|
|
4233
3884
|
var getClassName12 = get_class_name_factory_default("Input", styles_module_default2);
|
|
4234
3885
|
var SelectField = ({
|
|
4235
3886
|
field,
|
|
@@ -4242,20 +3893,20 @@ var SelectField = ({
|
|
|
4242
3893
|
readOnly,
|
|
4243
3894
|
id
|
|
4244
3895
|
}) => {
|
|
4245
|
-
const flatOptions = (0,
|
|
3896
|
+
const flatOptions = (0, import_react20.useMemo)(
|
|
4246
3897
|
() => field.type === "select" ? field.options.map(({ value: value2 }) => value2) : [],
|
|
4247
3898
|
[field]
|
|
4248
3899
|
);
|
|
4249
3900
|
if (field.type !== "select" || !field.options) {
|
|
4250
3901
|
return null;
|
|
4251
3902
|
}
|
|
4252
|
-
return /* @__PURE__ */ (0,
|
|
3903
|
+
return /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
|
|
4253
3904
|
Label2,
|
|
4254
3905
|
{
|
|
4255
3906
|
label: label || name,
|
|
4256
|
-
icon: labelIcon || /* @__PURE__ */ (0,
|
|
3907
|
+
icon: labelIcon || /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(ChevronDown, { size: 16 }),
|
|
4257
3908
|
readOnly,
|
|
4258
|
-
children: /* @__PURE__ */ (0,
|
|
3909
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
|
|
4259
3910
|
"select",
|
|
4260
3911
|
{
|
|
4261
3912
|
id,
|
|
@@ -4272,7 +3923,7 @@ var SelectField = ({
|
|
|
4272
3923
|
}
|
|
4273
3924
|
},
|
|
4274
3925
|
value,
|
|
4275
|
-
children: field.options.map((option) => /* @__PURE__ */ (0,
|
|
3926
|
+
children: field.options.map((option) => /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
|
|
4276
3927
|
"option",
|
|
4277
3928
|
{
|
|
4278
3929
|
label: option.label,
|
|
@@ -4288,7 +3939,7 @@ var SelectField = ({
|
|
|
4288
3939
|
|
|
4289
3940
|
// components/AutoField/fields/TextareaField/index.tsx
|
|
4290
3941
|
init_react_import();
|
|
4291
|
-
var
|
|
3942
|
+
var import_jsx_runtime16 = require("react/jsx-runtime");
|
|
4292
3943
|
var getClassName13 = get_class_name_factory_default("Input", styles_module_default2);
|
|
4293
3944
|
var TextareaField = ({
|
|
4294
3945
|
field,
|
|
@@ -4301,13 +3952,13 @@ var TextareaField = ({
|
|
|
4301
3952
|
Label: Label2,
|
|
4302
3953
|
id
|
|
4303
3954
|
}) => {
|
|
4304
|
-
return /* @__PURE__ */ (0,
|
|
3955
|
+
return /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
|
|
4305
3956
|
Label2,
|
|
4306
3957
|
{
|
|
4307
3958
|
label: label || name,
|
|
4308
|
-
icon: labelIcon || /* @__PURE__ */ (0,
|
|
3959
|
+
icon: labelIcon || /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(Type, { size: 16 }),
|
|
4309
3960
|
readOnly,
|
|
4310
|
-
children: /* @__PURE__ */ (0,
|
|
3961
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
|
|
4311
3962
|
"textarea",
|
|
4312
3963
|
{
|
|
4313
3964
|
id,
|
|
@@ -4334,7 +3985,7 @@ init_react_import();
|
|
|
4334
3985
|
var styles_module_default9 = { "ObjectField": "_ObjectField_1ua3y_5", "ObjectField-fieldset": "_ObjectField-fieldset_1ua3y_13" };
|
|
4335
3986
|
|
|
4336
3987
|
// components/AutoField/fields/ObjectField/index.tsx
|
|
4337
|
-
var
|
|
3988
|
+
var import_jsx_runtime17 = require("react/jsx-runtime");
|
|
4338
3989
|
var getClassName14 = get_class_name_factory_default("ObjectField", styles_module_default9);
|
|
4339
3990
|
var ObjectField = ({
|
|
4340
3991
|
field,
|
|
@@ -4352,25 +4003,25 @@ var ObjectField = ({
|
|
|
4352
4003
|
return null;
|
|
4353
4004
|
}
|
|
4354
4005
|
const data = value || {};
|
|
4355
|
-
return /* @__PURE__ */ (0,
|
|
4006
|
+
return /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
|
|
4356
4007
|
Label2,
|
|
4357
4008
|
{
|
|
4358
4009
|
label: label || name,
|
|
4359
|
-
icon: labelIcon || /* @__PURE__ */ (0,
|
|
4010
|
+
icon: labelIcon || /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(EllipsisVertical, { size: 16 }),
|
|
4360
4011
|
el: "div",
|
|
4361
4012
|
readOnly,
|
|
4362
|
-
children: /* @__PURE__ */ (0,
|
|
4013
|
+
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
4014
|
const subField = field.objectFields[subName];
|
|
4364
4015
|
const subPath = `${localName}.${subName}`;
|
|
4365
4016
|
const subReadOnly = readOnly ? readOnly : readOnlyFields[subPath];
|
|
4366
4017
|
const label2 = subField.label || subName;
|
|
4367
|
-
return /* @__PURE__ */ (0,
|
|
4018
|
+
return /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
|
|
4368
4019
|
NestedFieldProvider,
|
|
4369
4020
|
{
|
|
4370
4021
|
name: localName || id,
|
|
4371
4022
|
subName,
|
|
4372
4023
|
readOnlyFields,
|
|
4373
|
-
children: /* @__PURE__ */ (0,
|
|
4024
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
|
|
4374
4025
|
AutoFieldPrivate,
|
|
4375
4026
|
{
|
|
4376
4027
|
name: subPath,
|
|
@@ -4402,17 +4053,17 @@ var ObjectField = ({
|
|
|
4402
4053
|
|
|
4403
4054
|
// lib/use-safe-id.ts
|
|
4404
4055
|
init_react_import();
|
|
4405
|
-
var
|
|
4056
|
+
var import_react21 = __toESM(require("react"));
|
|
4406
4057
|
var useSafeId = () => {
|
|
4407
|
-
if (typeof
|
|
4408
|
-
return
|
|
4058
|
+
if (typeof import_react21.default.useId !== "undefined") {
|
|
4059
|
+
return import_react21.default.useId();
|
|
4409
4060
|
}
|
|
4410
|
-
const [id] = (0,
|
|
4061
|
+
const [id] = (0, import_react21.useState)(generateId());
|
|
4411
4062
|
return id;
|
|
4412
4063
|
};
|
|
4413
4064
|
|
|
4414
4065
|
// components/AutoField/index.tsx
|
|
4415
|
-
var
|
|
4066
|
+
var import_jsx_runtime18 = require("react/jsx-runtime");
|
|
4416
4067
|
var getClassName15 = get_class_name_factory_default("Input", styles_module_default2);
|
|
4417
4068
|
var getClassNameWrapper = get_class_name_factory_default("InputWrapper", styles_module_default2);
|
|
4418
4069
|
var FieldLabel = ({
|
|
@@ -4424,11 +4075,11 @@ var FieldLabel = ({
|
|
|
4424
4075
|
className
|
|
4425
4076
|
}) => {
|
|
4426
4077
|
const El = el;
|
|
4427
|
-
return /* @__PURE__ */ (0,
|
|
4428
|
-
/* @__PURE__ */ (0,
|
|
4429
|
-
icon ? /* @__PURE__ */ (0,
|
|
4078
|
+
return /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)(El, { className, children: [
|
|
4079
|
+
/* @__PURE__ */ (0, import_jsx_runtime18.jsxs)("div", { className: getClassName15("label"), children: [
|
|
4080
|
+
icon ? /* @__PURE__ */ (0, import_jsx_runtime18.jsx)("div", { className: getClassName15("labelIcon"), children: icon }) : /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(import_jsx_runtime18.Fragment, {}),
|
|
4430
4081
|
label,
|
|
4431
|
-
readOnly && /* @__PURE__ */ (0,
|
|
4082
|
+
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
4083
|
] }),
|
|
4433
4084
|
children
|
|
4434
4085
|
] });
|
|
@@ -4441,14 +4092,14 @@ var FieldLabelInternal = ({
|
|
|
4441
4092
|
readOnly
|
|
4442
4093
|
}) => {
|
|
4443
4094
|
const overrides = useAppStore((s) => s.overrides);
|
|
4444
|
-
const Wrapper = (0,
|
|
4095
|
+
const Wrapper = (0, import_react22.useMemo)(
|
|
4445
4096
|
() => overrides.fieldLabel || FieldLabel,
|
|
4446
4097
|
[overrides]
|
|
4447
4098
|
);
|
|
4448
4099
|
if (!label) {
|
|
4449
|
-
return /* @__PURE__ */ (0,
|
|
4100
|
+
return /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(import_jsx_runtime18.Fragment, { children });
|
|
4450
4101
|
}
|
|
4451
|
-
return /* @__PURE__ */ (0,
|
|
4102
|
+
return /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
|
|
4452
4103
|
Wrapper,
|
|
4453
4104
|
{
|
|
4454
4105
|
label,
|
|
@@ -4468,7 +4119,7 @@ function AutoFieldInternal(props) {
|
|
|
4468
4119
|
var _a2;
|
|
4469
4120
|
return (_a2 = s.selectedItem) == null ? void 0 : _a2.readOnly;
|
|
4470
4121
|
});
|
|
4471
|
-
const nestedFieldContext = (0,
|
|
4122
|
+
const nestedFieldContext = (0, import_react22.useContext)(NestedFieldContext);
|
|
4472
4123
|
const { id, Label: Label2 = FieldLabelInternal } = props;
|
|
4473
4124
|
const field = props.field;
|
|
4474
4125
|
const label = field.label;
|
|
@@ -4502,7 +4153,7 @@ function AutoFieldInternal(props) {
|
|
|
4502
4153
|
Label: Label2,
|
|
4503
4154
|
id: resolvedId
|
|
4504
4155
|
});
|
|
4505
|
-
const onFocus = (0,
|
|
4156
|
+
const onFocus = (0, import_react22.useCallback)(
|
|
4506
4157
|
(e) => {
|
|
4507
4158
|
if (mergedProps.name && (e.target.nodeName === "INPUT" || e.target.nodeName === "TEXTAREA")) {
|
|
4508
4159
|
e.stopPropagation();
|
|
@@ -4516,7 +4167,7 @@ function AutoFieldInternal(props) {
|
|
|
4516
4167
|
},
|
|
4517
4168
|
[mergedProps.name]
|
|
4518
4169
|
);
|
|
4519
|
-
const onBlur = (0,
|
|
4170
|
+
const onBlur = (0, import_react22.useCallback)((e) => {
|
|
4520
4171
|
if ("name" in e.target) {
|
|
4521
4172
|
dispatch({
|
|
4522
4173
|
type: "setUi",
|
|
@@ -4544,14 +4195,14 @@ function AutoFieldInternal(props) {
|
|
|
4544
4195
|
children = defaultFields[field.type](mergedProps);
|
|
4545
4196
|
FieldComponent = render[field.type];
|
|
4546
4197
|
}
|
|
4547
|
-
return /* @__PURE__ */ (0,
|
|
4198
|
+
return /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
|
|
4548
4199
|
NestedFieldContext.Provider,
|
|
4549
4200
|
{
|
|
4550
4201
|
value: {
|
|
4551
4202
|
readOnlyFields: nestedFieldContext.readOnlyFields || readOnly || {},
|
|
4552
4203
|
localName: (_i = nestedFieldContext.localName) != null ? _i : mergedProps.name
|
|
4553
4204
|
},
|
|
4554
|
-
children: /* @__PURE__ */ (0,
|
|
4205
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
|
|
4555
4206
|
"div",
|
|
4556
4207
|
{
|
|
4557
4208
|
className: getClassNameWrapper(),
|
|
@@ -4560,7 +4211,7 @@ function AutoFieldInternal(props) {
|
|
|
4560
4211
|
onClick: (e) => {
|
|
4561
4212
|
e.stopPropagation();
|
|
4562
4213
|
},
|
|
4563
|
-
children: /* @__PURE__ */ (0,
|
|
4214
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(FieldComponent, __spreadProps(__spreadValues({}, mergedProps), { children }))
|
|
4564
4215
|
}
|
|
4565
4216
|
)
|
|
4566
4217
|
}
|
|
@@ -4569,20 +4220,20 @@ function AutoFieldInternal(props) {
|
|
|
4569
4220
|
function AutoFieldPrivate(props) {
|
|
4570
4221
|
const isFocused = useAppStore((s) => s.state.ui.field.focus === props.name);
|
|
4571
4222
|
const { value, onChange } = props;
|
|
4572
|
-
const [localValue, setLocalValue] = (0,
|
|
4573
|
-
const onChangeLocal = (0,
|
|
4223
|
+
const [localValue, setLocalValue] = (0, import_react22.useState)(value);
|
|
4224
|
+
const onChangeLocal = (0, import_react22.useCallback)(
|
|
4574
4225
|
(val, ui) => {
|
|
4575
4226
|
setLocalValue(val);
|
|
4576
4227
|
onChange(val, ui);
|
|
4577
4228
|
},
|
|
4578
4229
|
[onChange]
|
|
4579
4230
|
);
|
|
4580
|
-
(0,
|
|
4231
|
+
(0, import_react22.useEffect)(() => {
|
|
4581
4232
|
if (!isFocused) {
|
|
4582
4233
|
setLocalValue(value);
|
|
4583
4234
|
}
|
|
4584
4235
|
}, [value]);
|
|
4585
|
-
(0,
|
|
4236
|
+
(0, import_react22.useEffect)(() => {
|
|
4586
4237
|
if (!isFocused) {
|
|
4587
4238
|
if (value !== localValue) {
|
|
4588
4239
|
setLocalValue(value);
|
|
@@ -4593,11 +4244,11 @@ function AutoFieldPrivate(props) {
|
|
|
4593
4244
|
value: localValue,
|
|
4594
4245
|
onChange: onChangeLocal
|
|
4595
4246
|
};
|
|
4596
|
-
return /* @__PURE__ */ (0,
|
|
4247
|
+
return /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(AutoFieldInternal, __spreadValues(__spreadValues({}, props), localProps));
|
|
4597
4248
|
}
|
|
4598
4249
|
function AutoField(props) {
|
|
4599
|
-
const DefaultLabel = (0,
|
|
4600
|
-
const DefaultLabel2 = (labelProps) => /* @__PURE__ */ (0,
|
|
4250
|
+
const DefaultLabel = (0, import_react22.useMemo)(() => {
|
|
4251
|
+
const DefaultLabel2 = (labelProps) => /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
|
|
4601
4252
|
"div",
|
|
4602
4253
|
__spreadProps(__spreadValues({}, labelProps), {
|
|
4603
4254
|
className: getClassName15({ readOnly: props.readOnly })
|
|
@@ -4608,7 +4259,7 @@ function AutoField(props) {
|
|
|
4608
4259
|
if (props.field.type === "slot") {
|
|
4609
4260
|
return null;
|
|
4610
4261
|
}
|
|
4611
|
-
return /* @__PURE__ */ (0,
|
|
4262
|
+
return /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(AutoFieldInternal, __spreadProps(__spreadValues({}, props), { Label: DefaultLabel }));
|
|
4612
4263
|
}
|
|
4613
4264
|
|
|
4614
4265
|
// components/Drawer/index.tsx
|
|
@@ -4633,7 +4284,7 @@ var import_react35 = require("react");
|
|
|
4633
4284
|
|
|
4634
4285
|
// components/DraggableComponent/index.tsx
|
|
4635
4286
|
init_react_import();
|
|
4636
|
-
var
|
|
4287
|
+
var import_react26 = require("react");
|
|
4637
4288
|
|
|
4638
4289
|
// css-module:/home/runner/work/puck/puck/packages/core/components/DraggableComponent/styles.module.css#css-module
|
|
4639
4290
|
init_react_import();
|
|
@@ -4663,11 +4314,11 @@ function getDeepScrollPosition(element) {
|
|
|
4663
4314
|
|
|
4664
4315
|
// components/DropZone/context.tsx
|
|
4665
4316
|
init_react_import();
|
|
4666
|
-
var
|
|
4317
|
+
var import_react23 = require("react");
|
|
4667
4318
|
var import_zustand3 = require("zustand");
|
|
4668
|
-
var
|
|
4669
|
-
var dropZoneContext = (0,
|
|
4670
|
-
var ZoneStoreContext = (0,
|
|
4319
|
+
var import_jsx_runtime19 = require("react/jsx-runtime");
|
|
4320
|
+
var dropZoneContext = (0, import_react23.createContext)(null);
|
|
4321
|
+
var ZoneStoreContext = (0, import_react23.createContext)(
|
|
4671
4322
|
(0, import_zustand3.createStore)(() => ({
|
|
4672
4323
|
zoneDepthIndex: {},
|
|
4673
4324
|
nextZoneDepthIndex: {},
|
|
@@ -4683,14 +4334,14 @@ var ZoneStoreProvider = ({
|
|
|
4683
4334
|
children,
|
|
4684
4335
|
store
|
|
4685
4336
|
}) => {
|
|
4686
|
-
return /* @__PURE__ */ (0,
|
|
4337
|
+
return /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(ZoneStoreContext.Provider, { value: store, children });
|
|
4687
4338
|
};
|
|
4688
4339
|
var DropZoneProvider = ({
|
|
4689
4340
|
children,
|
|
4690
4341
|
value
|
|
4691
4342
|
}) => {
|
|
4692
4343
|
const dispatch = useAppStore((s) => s.dispatch);
|
|
4693
|
-
const registerZone = (0,
|
|
4344
|
+
const registerZone = (0, import_react23.useCallback)(
|
|
4694
4345
|
(zoneCompound) => {
|
|
4695
4346
|
dispatch({
|
|
4696
4347
|
type: "registerZone",
|
|
@@ -4699,13 +4350,13 @@ var DropZoneProvider = ({
|
|
|
4699
4350
|
},
|
|
4700
4351
|
[dispatch]
|
|
4701
4352
|
);
|
|
4702
|
-
const memoValue = (0,
|
|
4353
|
+
const memoValue = (0, import_react23.useMemo)(
|
|
4703
4354
|
() => __spreadValues({
|
|
4704
4355
|
registerZone
|
|
4705
4356
|
}, value),
|
|
4706
4357
|
[value]
|
|
4707
4358
|
);
|
|
4708
|
-
return /* @__PURE__ */ (0,
|
|
4359
|
+
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
4360
|
};
|
|
4710
4361
|
|
|
4711
4362
|
// components/DraggableComponent/index.tsx
|
|
@@ -4729,11 +4380,11 @@ function accumulateTransform(el) {
|
|
|
4729
4380
|
|
|
4730
4381
|
// lib/use-context-store.ts
|
|
4731
4382
|
init_react_import();
|
|
4732
|
-
var
|
|
4383
|
+
var import_react24 = require("react");
|
|
4733
4384
|
var import_zustand4 = require("zustand");
|
|
4734
4385
|
var import_shallow = require("zustand/react/shallow");
|
|
4735
4386
|
function useContextStore(context, selector) {
|
|
4736
|
-
const store = (0,
|
|
4387
|
+
const store = (0, import_react24.useContext)(context);
|
|
4737
4388
|
if (!store) {
|
|
4738
4389
|
throw new Error("useContextStore must be used inside context");
|
|
4739
4390
|
}
|
|
@@ -4742,10 +4393,10 @@ function useContextStore(context, selector) {
|
|
|
4742
4393
|
|
|
4743
4394
|
// lib/dnd/use-on-drag-finished.ts
|
|
4744
4395
|
init_react_import();
|
|
4745
|
-
var
|
|
4396
|
+
var import_react25 = require("react");
|
|
4746
4397
|
var useOnDragFinished = (cb, deps = []) => {
|
|
4747
4398
|
const appStore = useAppStoreApi();
|
|
4748
|
-
return (0,
|
|
4399
|
+
return (0, import_react25.useCallback)(() => {
|
|
4749
4400
|
let dispose = () => {
|
|
4750
4401
|
};
|
|
4751
4402
|
const processDragging = (isDragging2) => {
|
|
@@ -4773,7 +4424,7 @@ var useOnDragFinished = (cb, deps = []) => {
|
|
|
4773
4424
|
};
|
|
4774
4425
|
|
|
4775
4426
|
// components/DraggableComponent/index.tsx
|
|
4776
|
-
var
|
|
4427
|
+
var import_jsx_runtime20 = require("react/jsx-runtime");
|
|
4777
4428
|
var getClassName16 = get_class_name_factory_default("DraggableComponent", styles_module_default11);
|
|
4778
4429
|
var DEBUG2 = false;
|
|
4779
4430
|
var space = 8;
|
|
@@ -4784,12 +4435,12 @@ var DefaultActionBar = ({
|
|
|
4784
4435
|
label,
|
|
4785
4436
|
children,
|
|
4786
4437
|
parentAction
|
|
4787
|
-
}) => /* @__PURE__ */ (0,
|
|
4788
|
-
/* @__PURE__ */ (0,
|
|
4438
|
+
}) => /* @__PURE__ */ (0, import_jsx_runtime20.jsxs)(ActionBar, { children: [
|
|
4439
|
+
/* @__PURE__ */ (0, import_jsx_runtime20.jsxs)(ActionBar.Group, { children: [
|
|
4789
4440
|
parentAction,
|
|
4790
|
-
label && /* @__PURE__ */ (0,
|
|
4441
|
+
label && /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(ActionBar.Label, { label })
|
|
4791
4442
|
] }),
|
|
4792
|
-
/* @__PURE__ */ (0,
|
|
4443
|
+
/* @__PURE__ */ (0, import_jsx_runtime20.jsx)(ActionBar.Group, { children })
|
|
4793
4444
|
] });
|
|
4794
4445
|
var DraggableComponent = ({
|
|
4795
4446
|
children,
|
|
@@ -4815,9 +4466,9 @@ var DraggableComponent = ({
|
|
|
4815
4466
|
const overrides = useAppStore((s) => s.overrides);
|
|
4816
4467
|
const dispatch = useAppStore((s) => s.dispatch);
|
|
4817
4468
|
const iframe = useAppStore((s) => s.iframe);
|
|
4818
|
-
const ctx = (0,
|
|
4819
|
-
const [localZones, setLocalZones] = (0,
|
|
4820
|
-
const registerLocalZone = (0,
|
|
4469
|
+
const ctx = (0, import_react26.useContext)(dropZoneContext);
|
|
4470
|
+
const [localZones, setLocalZones] = (0, import_react26.useState)({});
|
|
4471
|
+
const registerLocalZone = (0, import_react26.useCallback)(
|
|
4821
4472
|
(zoneCompound2, active) => {
|
|
4822
4473
|
var _a;
|
|
4823
4474
|
(_a = ctx == null ? void 0 : ctx.registerLocalZone) == null ? void 0 : _a.call(ctx, zoneCompound2, active);
|
|
@@ -4827,7 +4478,7 @@ var DraggableComponent = ({
|
|
|
4827
4478
|
},
|
|
4828
4479
|
[setLocalZones]
|
|
4829
4480
|
);
|
|
4830
|
-
const unregisterLocalZone = (0,
|
|
4481
|
+
const unregisterLocalZone = (0, import_react26.useCallback)(
|
|
4831
4482
|
(zoneCompound2) => {
|
|
4832
4483
|
var _a;
|
|
4833
4484
|
(_a = ctx == null ? void 0 : ctx.unregisterLocalZone) == null ? void 0 : _a.call(ctx, zoneCompound2);
|
|
@@ -4850,9 +4501,9 @@ var DraggableComponent = ({
|
|
|
4850
4501
|
return s.permissions.getPermissions({ item });
|
|
4851
4502
|
})
|
|
4852
4503
|
);
|
|
4853
|
-
const zoneStore = (0,
|
|
4854
|
-
const [dragAxis, setDragAxis] = (0,
|
|
4855
|
-
const dynamicCollisionDetector = (0,
|
|
4504
|
+
const zoneStore = (0, import_react26.useContext)(ZoneStoreContext);
|
|
4505
|
+
const [dragAxis, setDragAxis] = (0, import_react26.useState)(userDragAxis || autoDragAxis);
|
|
4506
|
+
const dynamicCollisionDetector = (0, import_react26.useMemo)(
|
|
4856
4507
|
() => createDynamicCollisionDetector(dragAxis),
|
|
4857
4508
|
[dragAxis]
|
|
4858
4509
|
);
|
|
@@ -4884,7 +4535,7 @@ var DraggableComponent = ({
|
|
|
4884
4535
|
},
|
|
4885
4536
|
feedback: "clone"
|
|
4886
4537
|
});
|
|
4887
|
-
(0,
|
|
4538
|
+
(0, import_react26.useEffect)(() => {
|
|
4888
4539
|
const isEnabled = zoneStore.getState().enabledIndex[zoneCompound];
|
|
4889
4540
|
sortable.droppable.disabled = !isEnabled;
|
|
4890
4541
|
sortable.draggable.disabled = !permissions.drag;
|
|
@@ -4901,8 +4552,8 @@ var DraggableComponent = ({
|
|
|
4901
4552
|
}
|
|
4902
4553
|
return cleanup;
|
|
4903
4554
|
}, [permissions.drag, zoneCompound]);
|
|
4904
|
-
const ref = (0,
|
|
4905
|
-
const refSetter = (0,
|
|
4555
|
+
const ref = (0, import_react26.useRef)(null);
|
|
4556
|
+
const refSetter = (0, import_react26.useCallback)(
|
|
4906
4557
|
(el) => {
|
|
4907
4558
|
sortableRef(el);
|
|
4908
4559
|
if (el) {
|
|
@@ -4911,14 +4562,14 @@ var DraggableComponent = ({
|
|
|
4911
4562
|
},
|
|
4912
4563
|
[sortableRef]
|
|
4913
4564
|
);
|
|
4914
|
-
const [portalEl, setPortalEl] = (0,
|
|
4915
|
-
(0,
|
|
4565
|
+
const [portalEl, setPortalEl] = (0, import_react26.useState)();
|
|
4566
|
+
(0, import_react26.useEffect)(() => {
|
|
4916
4567
|
var _a, _b, _c;
|
|
4917
4568
|
setPortalEl(
|
|
4918
4569
|
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
4570
|
);
|
|
4920
4571
|
}, [iframe.enabled, ref.current]);
|
|
4921
|
-
const getStyle = (0,
|
|
4572
|
+
const getStyle = (0, import_react26.useCallback)(() => {
|
|
4922
4573
|
var _a, _b, _c;
|
|
4923
4574
|
if (!ref.current) return;
|
|
4924
4575
|
const rect = ref.current.getBoundingClientRect();
|
|
@@ -4943,11 +4594,11 @@ var DraggableComponent = ({
|
|
|
4943
4594
|
};
|
|
4944
4595
|
return style2;
|
|
4945
4596
|
}, [ref.current]);
|
|
4946
|
-
const [style, setStyle] = (0,
|
|
4947
|
-
const sync = (0,
|
|
4597
|
+
const [style, setStyle] = (0, import_react26.useState)();
|
|
4598
|
+
const sync = (0, import_react26.useCallback)(() => {
|
|
4948
4599
|
setStyle(getStyle());
|
|
4949
4600
|
}, [ref.current, iframe]);
|
|
4950
|
-
(0,
|
|
4601
|
+
(0, import_react26.useEffect)(() => {
|
|
4951
4602
|
if (ref.current) {
|
|
4952
4603
|
const observer = new ResizeObserver(sync);
|
|
4953
4604
|
observer.observe(ref.current);
|
|
@@ -4957,13 +4608,13 @@ var DraggableComponent = ({
|
|
|
4957
4608
|
}
|
|
4958
4609
|
}, [ref.current]);
|
|
4959
4610
|
const registerNode = useAppStore((s) => s.nodes.registerNode);
|
|
4960
|
-
const hideOverlay = (0,
|
|
4611
|
+
const hideOverlay = (0, import_react26.useCallback)(() => {
|
|
4961
4612
|
setIsVisible(false);
|
|
4962
4613
|
}, []);
|
|
4963
|
-
const showOverlay = (0,
|
|
4614
|
+
const showOverlay = (0, import_react26.useCallback)(() => {
|
|
4964
4615
|
setIsVisible(true);
|
|
4965
4616
|
}, []);
|
|
4966
|
-
(0,
|
|
4617
|
+
(0, import_react26.useEffect)(() => {
|
|
4967
4618
|
var _a;
|
|
4968
4619
|
registerNode(id, {
|
|
4969
4620
|
methods: { sync, showOverlay, hideOverlay },
|
|
@@ -4980,11 +4631,11 @@ var DraggableComponent = ({
|
|
|
4980
4631
|
});
|
|
4981
4632
|
};
|
|
4982
4633
|
}, [id, zoneCompound, index, componentType, sync]);
|
|
4983
|
-
const CustomActionBar = (0,
|
|
4634
|
+
const CustomActionBar = (0, import_react26.useMemo)(
|
|
4984
4635
|
() => overrides.actionBar || DefaultActionBar,
|
|
4985
4636
|
[overrides.actionBar]
|
|
4986
4637
|
);
|
|
4987
|
-
const onClick = (0,
|
|
4638
|
+
const onClick = (0, import_react26.useCallback)(
|
|
4988
4639
|
(e) => {
|
|
4989
4640
|
e.stopPropagation();
|
|
4990
4641
|
dispatch({
|
|
@@ -4997,7 +4648,7 @@ var DraggableComponent = ({
|
|
|
4997
4648
|
[index, zoneCompound, id]
|
|
4998
4649
|
);
|
|
4999
4650
|
const appStore = useAppStoreApi();
|
|
5000
|
-
const onSelectParent = (0,
|
|
4651
|
+
const onSelectParent = (0, import_react26.useCallback)(() => {
|
|
5001
4652
|
const { nodes, zones } = appStore.getState().state.indexes;
|
|
5002
4653
|
const node = nodes[id];
|
|
5003
4654
|
const parentNode = (node == null ? void 0 : node.parentId) ? nodes[node == null ? void 0 : node.parentId] : null;
|
|
@@ -5018,26 +4669,26 @@ var DraggableComponent = ({
|
|
|
5018
4669
|
}
|
|
5019
4670
|
});
|
|
5020
4671
|
}, [ctx, path]);
|
|
5021
|
-
const onDuplicate = (0,
|
|
4672
|
+
const onDuplicate = (0, import_react26.useCallback)(() => {
|
|
5022
4673
|
dispatch({
|
|
5023
4674
|
type: "duplicate",
|
|
5024
4675
|
sourceIndex: index,
|
|
5025
4676
|
sourceZone: zoneCompound
|
|
5026
4677
|
});
|
|
5027
4678
|
}, [index, zoneCompound]);
|
|
5028
|
-
const onDelete = (0,
|
|
4679
|
+
const onDelete = (0, import_react26.useCallback)(() => {
|
|
5029
4680
|
dispatch({
|
|
5030
4681
|
type: "remove",
|
|
5031
4682
|
index,
|
|
5032
4683
|
zone: zoneCompound
|
|
5033
4684
|
});
|
|
5034
4685
|
}, [index, zoneCompound]);
|
|
5035
|
-
const [hover, setHover] = (0,
|
|
4686
|
+
const [hover, setHover] = (0, import_react26.useState)(false);
|
|
5036
4687
|
const indicativeHover = useContextStore(
|
|
5037
4688
|
ZoneStoreContext,
|
|
5038
4689
|
(s) => s.hoveringComponent === id
|
|
5039
4690
|
);
|
|
5040
|
-
(0,
|
|
4691
|
+
(0, import_react26.useEffect)(() => {
|
|
5041
4692
|
if (!ref.current) {
|
|
5042
4693
|
return;
|
|
5043
4694
|
}
|
|
@@ -5073,7 +4724,8 @@ var DraggableComponent = ({
|
|
|
5073
4724
|
el.removeEventListener("mouseout", _onMouseOut);
|
|
5074
4725
|
};
|
|
5075
4726
|
}, [
|
|
5076
|
-
ref,
|
|
4727
|
+
ref.current,
|
|
4728
|
+
// Remount attributes if the element changes
|
|
5077
4729
|
onClick,
|
|
5078
4730
|
containsActiveZone,
|
|
5079
4731
|
zoneCompound,
|
|
@@ -5081,10 +4733,10 @@ var DraggableComponent = ({
|
|
|
5081
4733
|
thisIsDragging,
|
|
5082
4734
|
inDroppableZone
|
|
5083
4735
|
]);
|
|
5084
|
-
const [isVisible, setIsVisible] = (0,
|
|
5085
|
-
const [dragFinished, setDragFinished] = (0,
|
|
5086
|
-
const [_, startTransition] = (0,
|
|
5087
|
-
(0,
|
|
4736
|
+
const [isVisible, setIsVisible] = (0, import_react26.useState)(false);
|
|
4737
|
+
const [dragFinished, setDragFinished] = (0, import_react26.useState)(true);
|
|
4738
|
+
const [_, startTransition] = (0, import_react26.useTransition)();
|
|
4739
|
+
(0, import_react26.useEffect)(() => {
|
|
5088
4740
|
startTransition(() => {
|
|
5089
4741
|
if (hover || indicativeHover || isSelected) {
|
|
5090
4742
|
sync();
|
|
@@ -5095,7 +4747,7 @@ var DraggableComponent = ({
|
|
|
5095
4747
|
}
|
|
5096
4748
|
});
|
|
5097
4749
|
}, [hover, indicativeHover, isSelected, iframe]);
|
|
5098
|
-
const [thisWasDragging, setThisWasDragging] = (0,
|
|
4750
|
+
const [thisWasDragging, setThisWasDragging] = (0, import_react26.useState)(false);
|
|
5099
4751
|
const onDragFinished = useOnDragFinished((finished) => {
|
|
5100
4752
|
if (finished) {
|
|
5101
4753
|
startTransition(() => {
|
|
@@ -5106,15 +4758,15 @@ var DraggableComponent = ({
|
|
|
5106
4758
|
setDragFinished(false);
|
|
5107
4759
|
}
|
|
5108
4760
|
});
|
|
5109
|
-
(0,
|
|
4761
|
+
(0, import_react26.useEffect)(() => {
|
|
5110
4762
|
if (thisIsDragging) {
|
|
5111
4763
|
setThisWasDragging(true);
|
|
5112
4764
|
}
|
|
5113
4765
|
}, [thisIsDragging]);
|
|
5114
|
-
(0,
|
|
4766
|
+
(0, import_react26.useEffect)(() => {
|
|
5115
4767
|
if (thisWasDragging) return onDragFinished();
|
|
5116
4768
|
}, [thisWasDragging, onDragFinished]);
|
|
5117
|
-
const syncActionsPosition = (0,
|
|
4769
|
+
const syncActionsPosition = (0, import_react26.useCallback)(
|
|
5118
4770
|
(el) => {
|
|
5119
4771
|
if (el) {
|
|
5120
4772
|
const view = el.ownerDocument.defaultView;
|
|
@@ -5139,7 +4791,7 @@ var DraggableComponent = ({
|
|
|
5139
4791
|
},
|
|
5140
4792
|
[zoom]
|
|
5141
4793
|
);
|
|
5142
|
-
(0,
|
|
4794
|
+
(0, import_react26.useEffect)(() => {
|
|
5143
4795
|
if (userDragAxis) {
|
|
5144
4796
|
setDragAxis(userDragAxis);
|
|
5145
4797
|
return;
|
|
@@ -5153,11 +4805,11 @@ var DraggableComponent = ({
|
|
|
5153
4805
|
}
|
|
5154
4806
|
setDragAxis(autoDragAxis);
|
|
5155
4807
|
}, [ref, userDragAxis, autoDragAxis]);
|
|
5156
|
-
const parentAction = (0,
|
|
5157
|
-
() => (ctx == null ? void 0 : ctx.areaId) && (ctx == null ? void 0 : ctx.areaId) !== "root" && /* @__PURE__ */ (0,
|
|
4808
|
+
const parentAction = (0, import_react26.useMemo)(
|
|
4809
|
+
() => (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
4810
|
[ctx == null ? void 0 : ctx.areaId]
|
|
5159
4811
|
);
|
|
5160
|
-
const nextContextValue = (0,
|
|
4812
|
+
const nextContextValue = (0, import_react26.useMemo)(
|
|
5161
4813
|
() => __spreadProps(__spreadValues({}, ctx), {
|
|
5162
4814
|
areaId: id,
|
|
5163
4815
|
zoneCompound,
|
|
@@ -5176,9 +4828,9 @@ var DraggableComponent = ({
|
|
|
5176
4828
|
unregisterLocalZone
|
|
5177
4829
|
]
|
|
5178
4830
|
);
|
|
5179
|
-
return /* @__PURE__ */ (0,
|
|
4831
|
+
return /* @__PURE__ */ (0, import_jsx_runtime20.jsxs)(DropZoneProvider, { value: nextContextValue, children: [
|
|
5180
4832
|
dragFinished && isVisible && (0, import_react_dom2.createPortal)(
|
|
5181
|
-
/* @__PURE__ */ (0,
|
|
4833
|
+
/* @__PURE__ */ (0, import_jsx_runtime20.jsxs)(
|
|
5182
4834
|
"div",
|
|
5183
4835
|
{
|
|
5184
4836
|
className: getClassName16({
|
|
@@ -5190,15 +4842,15 @@ var DraggableComponent = ({
|
|
|
5190
4842
|
"data-puck-overlay": true,
|
|
5191
4843
|
children: [
|
|
5192
4844
|
debug,
|
|
5193
|
-
isLoading && /* @__PURE__ */ (0,
|
|
5194
|
-
/* @__PURE__ */ (0,
|
|
4845
|
+
isLoading && /* @__PURE__ */ (0, import_jsx_runtime20.jsx)("div", { className: getClassName16("loadingOverlay"), children: /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(Loader, {}) }),
|
|
4846
|
+
/* @__PURE__ */ (0, import_jsx_runtime20.jsx)(
|
|
5195
4847
|
"div",
|
|
5196
4848
|
{
|
|
5197
4849
|
className: getClassName16("actionsOverlay"),
|
|
5198
4850
|
style: {
|
|
5199
4851
|
top: actionsOverlayTop / zoom
|
|
5200
4852
|
},
|
|
5201
|
-
children: /* @__PURE__ */ (0,
|
|
4853
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(
|
|
5202
4854
|
"div",
|
|
5203
4855
|
{
|
|
5204
4856
|
className: getClassName16("actions"),
|
|
@@ -5210,14 +4862,14 @@ var DraggableComponent = ({
|
|
|
5210
4862
|
paddingRight: actionsSide
|
|
5211
4863
|
},
|
|
5212
4864
|
ref: syncActionsPosition,
|
|
5213
|
-
children: /* @__PURE__ */ (0,
|
|
4865
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime20.jsxs)(
|
|
5214
4866
|
CustomActionBar,
|
|
5215
4867
|
{
|
|
5216
4868
|
parentAction,
|
|
5217
4869
|
label: DEBUG2 ? id : label,
|
|
5218
4870
|
children: [
|
|
5219
|
-
permissions.duplicate && /* @__PURE__ */ (0,
|
|
5220
|
-
permissions.delete && /* @__PURE__ */ (0,
|
|
4871
|
+
permissions.duplicate && /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(ActionBar.Action, { onClick: onDuplicate, label: "Duplicate", children: /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(Copy, { size: 16 }) }),
|
|
4872
|
+
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
4873
|
]
|
|
5222
4874
|
}
|
|
5223
4875
|
)
|
|
@@ -5225,7 +4877,7 @@ var DraggableComponent = ({
|
|
|
5225
4877
|
)
|
|
5226
4878
|
}
|
|
5227
4879
|
),
|
|
5228
|
-
/* @__PURE__ */ (0,
|
|
4880
|
+
/* @__PURE__ */ (0, import_jsx_runtime20.jsx)("div", { className: getClassName16("overlay") })
|
|
5229
4881
|
]
|
|
5230
4882
|
}
|
|
5231
4883
|
),
|
|
@@ -5244,7 +4896,7 @@ var import_react36 = require("@dnd-kit/react");
|
|
|
5244
4896
|
|
|
5245
4897
|
// components/DropZone/lib/use-min-empty-height.ts
|
|
5246
4898
|
init_react_import();
|
|
5247
|
-
var
|
|
4899
|
+
var import_react27 = require("react");
|
|
5248
4900
|
var getNumItems = (appStore, zoneCompound) => appStore.getState().state.indexes.zones[zoneCompound].contentIds.length;
|
|
5249
4901
|
var useMinEmptyHeight = ({
|
|
5250
4902
|
zoneCompound,
|
|
@@ -5252,8 +4904,8 @@ var useMinEmptyHeight = ({
|
|
|
5252
4904
|
ref
|
|
5253
4905
|
}) => {
|
|
5254
4906
|
const appStore = useAppStoreApi();
|
|
5255
|
-
const [prevHeight, setPrevHeight] = (0,
|
|
5256
|
-
const [isAnimating, setIsAnimating] = (0,
|
|
4907
|
+
const [prevHeight, setPrevHeight] = (0, import_react27.useState)(0);
|
|
4908
|
+
const [isAnimating, setIsAnimating] = (0, import_react27.useState)(false);
|
|
5257
4909
|
const { draggedItem, isZone } = useContextStore(ZoneStoreContext, (s) => {
|
|
5258
4910
|
var _a, _b;
|
|
5259
4911
|
return {
|
|
@@ -5261,7 +4913,7 @@ var useMinEmptyHeight = ({
|
|
|
5261
4913
|
isZone: ((_b = s.draggedItem) == null ? void 0 : _b.data.zone) === zoneCompound
|
|
5262
4914
|
};
|
|
5263
4915
|
});
|
|
5264
|
-
const numItems = (0,
|
|
4916
|
+
const numItems = (0, import_react27.useRef)(0);
|
|
5265
4917
|
const onDragFinished = useOnDragFinished(
|
|
5266
4918
|
(finished) => {
|
|
5267
4919
|
var _a;
|
|
@@ -5296,7 +4948,7 @@ var useMinEmptyHeight = ({
|
|
|
5296
4948
|
},
|
|
5297
4949
|
[appStore, prevHeight, zoneCompound]
|
|
5298
4950
|
);
|
|
5299
|
-
(0,
|
|
4951
|
+
(0, import_react27.useEffect)(() => {
|
|
5300
4952
|
if (draggedItem && ref.current) {
|
|
5301
4953
|
if (isZone) {
|
|
5302
4954
|
const rect = ref.current.getBoundingClientRect();
|
|
@@ -5327,15 +4979,15 @@ function assignRefs(refs, node) {
|
|
|
5327
4979
|
|
|
5328
4980
|
// components/DropZone/lib/use-content-with-preview.ts
|
|
5329
4981
|
init_react_import();
|
|
5330
|
-
var
|
|
4982
|
+
var import_react30 = require("react");
|
|
5331
4983
|
|
|
5332
4984
|
// lib/dnd/use-rendered-callback.ts
|
|
5333
4985
|
init_react_import();
|
|
5334
|
-
var
|
|
5335
|
-
var
|
|
4986
|
+
var import_react28 = require("@dnd-kit/react");
|
|
4987
|
+
var import_react29 = require("react");
|
|
5336
4988
|
function useRenderedCallback(callback, deps) {
|
|
5337
|
-
const manager = (0,
|
|
5338
|
-
return (0,
|
|
4989
|
+
const manager = (0, import_react28.useDragDropManager)();
|
|
4990
|
+
return (0, import_react29.useCallback)(
|
|
5339
4991
|
(...args) => __async(this, null, function* () {
|
|
5340
4992
|
yield manager == null ? void 0 : manager.renderer.rendering;
|
|
5341
4993
|
return callback(...args);
|
|
@@ -5346,14 +4998,14 @@ function useRenderedCallback(callback, deps) {
|
|
|
5346
4998
|
|
|
5347
4999
|
// components/DropZone/lib/use-content-with-preview.ts
|
|
5348
5000
|
var useContentIdsWithPreview = (contentIds, zoneCompound) => {
|
|
5349
|
-
const zoneStore = (0,
|
|
5001
|
+
const zoneStore = (0, import_react30.useContext)(ZoneStoreContext);
|
|
5350
5002
|
const preview = useContextStore(
|
|
5351
5003
|
ZoneStoreContext,
|
|
5352
5004
|
(s) => s.previewIndex[zoneCompound]
|
|
5353
5005
|
);
|
|
5354
5006
|
const isDragging = useAppStore((s) => s.state.ui.isDragging);
|
|
5355
|
-
const [contentIdsWithPreview, setContentIdsWithPreview] = (0,
|
|
5356
|
-
const [localPreview, setLocalPreview] = (0,
|
|
5007
|
+
const [contentIdsWithPreview, setContentIdsWithPreview] = (0, import_react30.useState)(contentIds);
|
|
5008
|
+
const [localPreview, setLocalPreview] = (0, import_react30.useState)(
|
|
5357
5009
|
preview
|
|
5358
5010
|
);
|
|
5359
5011
|
const updateContent = useRenderedCallback(
|
|
@@ -5388,7 +5040,7 @@ var useContentIdsWithPreview = (contentIds, zoneCompound) => {
|
|
|
5388
5040
|
},
|
|
5389
5041
|
[]
|
|
5390
5042
|
);
|
|
5391
|
-
(0,
|
|
5043
|
+
(0, import_react30.useEffect)(() => {
|
|
5392
5044
|
var _a;
|
|
5393
5045
|
const s = zoneStore.getState();
|
|
5394
5046
|
const draggedItemId = (_a = s.draggedItem) == null ? void 0 : _a.id;
|
|
@@ -5406,16 +5058,16 @@ var useContentIdsWithPreview = (contentIds, zoneCompound) => {
|
|
|
5406
5058
|
|
|
5407
5059
|
// components/DropZone/lib/use-drag-axis.ts
|
|
5408
5060
|
init_react_import();
|
|
5409
|
-
var
|
|
5061
|
+
var import_react31 = require("react");
|
|
5410
5062
|
var GRID_DRAG_AXIS = "dynamic";
|
|
5411
5063
|
var FLEX_ROW_DRAG_AXIS = "x";
|
|
5412
5064
|
var DEFAULT_DRAG_AXIS = "y";
|
|
5413
5065
|
var useDragAxis = (ref, collisionAxis) => {
|
|
5414
5066
|
const status = useAppStore((s) => s.status);
|
|
5415
|
-
const [dragAxis, setDragAxis] = (0,
|
|
5067
|
+
const [dragAxis, setDragAxis] = (0, import_react31.useState)(
|
|
5416
5068
|
collisionAxis || DEFAULT_DRAG_AXIS
|
|
5417
5069
|
);
|
|
5418
|
-
const calculateDragAxis = (0,
|
|
5070
|
+
const calculateDragAxis = (0, import_react31.useCallback)(() => {
|
|
5419
5071
|
if (ref.current) {
|
|
5420
5072
|
const computedStyle = window.getComputedStyle(ref.current);
|
|
5421
5073
|
if (computedStyle.display === "grid") {
|
|
@@ -5427,7 +5079,7 @@ var useDragAxis = (ref, collisionAxis) => {
|
|
|
5427
5079
|
}
|
|
5428
5080
|
}
|
|
5429
5081
|
}, [ref.current]);
|
|
5430
|
-
(0,
|
|
5082
|
+
(0, import_react31.useEffect)(() => {
|
|
5431
5083
|
const onViewportChange = () => {
|
|
5432
5084
|
calculateDragAxis();
|
|
5433
5085
|
};
|
|
@@ -5436,20 +5088,145 @@ var useDragAxis = (ref, collisionAxis) => {
|
|
|
5436
5088
|
window.removeEventListener("viewportchange", onViewportChange);
|
|
5437
5089
|
};
|
|
5438
5090
|
}, []);
|
|
5439
|
-
(0,
|
|
5091
|
+
(0, import_react31.useEffect)(calculateDragAxis, [status, collisionAxis]);
|
|
5440
5092
|
return [dragAxis, calculateDragAxis];
|
|
5441
5093
|
};
|
|
5442
|
-
|
|
5443
|
-
// components/DropZone/index.tsx
|
|
5444
|
-
var import_shallow4 = require("zustand/react/shallow");
|
|
5445
|
-
|
|
5446
|
-
// components/Render/index.tsx
|
|
5447
|
-
init_react_import();
|
|
5448
|
-
|
|
5094
|
+
|
|
5095
|
+
// components/DropZone/index.tsx
|
|
5096
|
+
var import_shallow4 = require("zustand/react/shallow");
|
|
5097
|
+
|
|
5098
|
+
// components/Render/index.tsx
|
|
5099
|
+
init_react_import();
|
|
5100
|
+
|
|
5101
|
+
// lib/use-slots.tsx
|
|
5102
|
+
init_react_import();
|
|
5103
|
+
var import_react32 = require("react");
|
|
5104
|
+
function useSlots(config, item, renderSlotEdit, renderSlotRender = renderSlotEdit, readOnly, forceReadOnly) {
|
|
5105
|
+
const slotProps = (0, import_react32.useMemo)(() => {
|
|
5106
|
+
const mapped = mapSlots(
|
|
5107
|
+
item,
|
|
5108
|
+
(content, _parentId, propName, field, propPath) => {
|
|
5109
|
+
const wildcardPath = propPath.replace(/\[\d+\]/g, "[*]");
|
|
5110
|
+
const isReadOnly = (readOnly == null ? void 0 : readOnly[propPath]) || (readOnly == null ? void 0 : readOnly[wildcardPath]) || forceReadOnly;
|
|
5111
|
+
const render = isReadOnly ? renderSlotRender : renderSlotEdit;
|
|
5112
|
+
const Slot = (dzProps) => render(__spreadProps(__spreadValues({
|
|
5113
|
+
allow: (field == null ? void 0 : field.type) === "slot" ? field.allow : [],
|
|
5114
|
+
disallow: (field == null ? void 0 : field.type) === "slot" ? field.disallow : []
|
|
5115
|
+
}, dzProps), {
|
|
5116
|
+
zone: propName,
|
|
5117
|
+
content
|
|
5118
|
+
}));
|
|
5119
|
+
return Slot;
|
|
5120
|
+
},
|
|
5121
|
+
config
|
|
5122
|
+
).props;
|
|
5123
|
+
return mapped;
|
|
5124
|
+
}, [config, item, readOnly, forceReadOnly]);
|
|
5125
|
+
const mergedProps = (0, import_react32.useMemo)(
|
|
5126
|
+
() => __spreadValues(__spreadValues({}, item.props), slotProps),
|
|
5127
|
+
[item.props, slotProps]
|
|
5128
|
+
);
|
|
5129
|
+
return mergedProps;
|
|
5130
|
+
}
|
|
5131
|
+
|
|
5132
|
+
// components/Render/index.tsx
|
|
5133
|
+
var import_react34 = __toESM(require("react"));
|
|
5134
|
+
|
|
5135
|
+
// components/SlotRender/index.tsx
|
|
5136
|
+
init_react_import();
|
|
5137
|
+
var import_shallow3 = require("zustand/react/shallow");
|
|
5138
|
+
|
|
5139
|
+
// components/SlotRender/server.tsx
|
|
5140
|
+
init_react_import();
|
|
5141
|
+
var import_react33 = require("react");
|
|
5142
|
+
|
|
5143
|
+
// components/ServerRender/index.tsx
|
|
5144
|
+
init_react_import();
|
|
5145
|
+
var import_jsx_runtime21 = require("react/jsx-runtime");
|
|
5146
|
+
function DropZoneRender({
|
|
5147
|
+
zone,
|
|
5148
|
+
data,
|
|
5149
|
+
areaId = "root",
|
|
5150
|
+
config,
|
|
5151
|
+
metadata = {}
|
|
5152
|
+
}) {
|
|
5153
|
+
let zoneCompound = rootDroppableId;
|
|
5154
|
+
let content = (data == null ? void 0 : data.content) || [];
|
|
5155
|
+
if (!data || !config) {
|
|
5156
|
+
return null;
|
|
5157
|
+
}
|
|
5158
|
+
if (areaId !== rootAreaId && zone !== rootZone) {
|
|
5159
|
+
zoneCompound = `${areaId}:${zone}`;
|
|
5160
|
+
content = setupZone(data, zoneCompound).zones[zoneCompound];
|
|
5161
|
+
}
|
|
5162
|
+
return /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(import_jsx_runtime21.Fragment, { children: content.map((item) => {
|
|
5163
|
+
const Component = config.components[item.type];
|
|
5164
|
+
const props = __spreadProps(__spreadValues({}, item.props), {
|
|
5165
|
+
puck: {
|
|
5166
|
+
renderDropZone: ({ zone: zone2 }) => /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(
|
|
5167
|
+
DropZoneRender,
|
|
5168
|
+
{
|
|
5169
|
+
zone: zone2,
|
|
5170
|
+
data,
|
|
5171
|
+
areaId: item.props.id,
|
|
5172
|
+
config,
|
|
5173
|
+
metadata
|
|
5174
|
+
}
|
|
5175
|
+
),
|
|
5176
|
+
metadata,
|
|
5177
|
+
dragRef: null,
|
|
5178
|
+
isEditing: false
|
|
5179
|
+
}
|
|
5180
|
+
});
|
|
5181
|
+
const renderItem = __spreadProps(__spreadValues({}, item), { props });
|
|
5182
|
+
const propsWithSlots = useSlots(config, renderItem, (props2) => /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(SlotRenderPure, __spreadProps(__spreadValues({}, props2), { config, metadata })));
|
|
5183
|
+
if (Component) {
|
|
5184
|
+
return /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(Component.render, __spreadValues({}, propsWithSlots), renderItem.props.id);
|
|
5185
|
+
}
|
|
5186
|
+
return null;
|
|
5187
|
+
}) });
|
|
5188
|
+
}
|
|
5189
|
+
|
|
5190
|
+
// components/SlotRender/server.tsx
|
|
5191
|
+
var import_jsx_runtime22 = require("react/jsx-runtime");
|
|
5192
|
+
var SlotRenderPure = (props) => /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(SlotRender, __spreadValues({}, props));
|
|
5193
|
+
var Item = ({
|
|
5194
|
+
config,
|
|
5195
|
+
item,
|
|
5196
|
+
metadata
|
|
5197
|
+
}) => {
|
|
5198
|
+
const Component = config.components[item.type];
|
|
5199
|
+
const props = useSlots(config, item, (slotProps) => /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(SlotRenderPure, __spreadProps(__spreadValues({}, slotProps), { config, metadata })));
|
|
5200
|
+
return /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(
|
|
5201
|
+
Component.render,
|
|
5202
|
+
__spreadProps(__spreadValues({}, props), {
|
|
5203
|
+
puck: __spreadProps(__spreadValues({}, props.puck), {
|
|
5204
|
+
renderDropZone: DropZoneRender,
|
|
5205
|
+
metadata: metadata || {}
|
|
5206
|
+
})
|
|
5207
|
+
})
|
|
5208
|
+
);
|
|
5209
|
+
};
|
|
5210
|
+
var SlotRender = (0, import_react33.forwardRef)(
|
|
5211
|
+
function SlotRenderInternal({ className, style, content, config, metadata }, ref) {
|
|
5212
|
+
return /* @__PURE__ */ (0, import_jsx_runtime22.jsx)("div", { className, style, ref, children: content.map((item) => {
|
|
5213
|
+
if (!config.components[item.type]) {
|
|
5214
|
+
return null;
|
|
5215
|
+
}
|
|
5216
|
+
return /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(
|
|
5217
|
+
Item,
|
|
5218
|
+
{
|
|
5219
|
+
config,
|
|
5220
|
+
item,
|
|
5221
|
+
metadata
|
|
5222
|
+
},
|
|
5223
|
+
item.props.id
|
|
5224
|
+
);
|
|
5225
|
+
}) });
|
|
5226
|
+
}
|
|
5227
|
+
);
|
|
5449
5228
|
|
|
5450
5229
|
// components/SlotRender/index.tsx
|
|
5451
|
-
init_react_import();
|
|
5452
|
-
var import_shallow3 = require("zustand/react/shallow");
|
|
5453
5230
|
var import_jsx_runtime23 = require("react/jsx-runtime");
|
|
5454
5231
|
var ContextSlotRender = ({
|
|
5455
5232
|
componentId,
|
|
@@ -5483,7 +5260,7 @@ var renderContext = import_react34.default.createContext({
|
|
|
5483
5260
|
data: { root: {}, content: [] },
|
|
5484
5261
|
metadata: {}
|
|
5485
5262
|
});
|
|
5486
|
-
function
|
|
5263
|
+
function Render({
|
|
5487
5264
|
config,
|
|
5488
5265
|
data,
|
|
5489
5266
|
metadata = {}
|
|
@@ -5575,7 +5352,8 @@ var DropZoneChild = ({
|
|
|
5575
5352
|
return {
|
|
5576
5353
|
type: preview.componentType,
|
|
5577
5354
|
props: preview.props,
|
|
5578
|
-
previewType: preview.type
|
|
5355
|
+
previewType: preview.type,
|
|
5356
|
+
element: preview.element
|
|
5579
5357
|
};
|
|
5580
5358
|
}
|
|
5581
5359
|
return null;
|
|
@@ -5608,6 +5386,12 @@ var DropZoneChild = ({
|
|
|
5608
5386
|
let label = (_b = (_a = componentConfig == null ? void 0 : componentConfig.label) != null ? _a : item == null ? void 0 : item.type.toString()) != null ? _b : "Component";
|
|
5609
5387
|
const renderPreview = (0, import_react35.useMemo)(
|
|
5610
5388
|
() => function Preview3() {
|
|
5389
|
+
if (item && "element" in item && item.element) {
|
|
5390
|
+
return (
|
|
5391
|
+
// Safe to use this since the HTML is set by the user
|
|
5392
|
+
/* @__PURE__ */ (0, import_jsx_runtime25.jsx)("div", { dangerouslySetInnerHTML: { __html: item.element.outerHTML } })
|
|
5393
|
+
);
|
|
5394
|
+
}
|
|
5611
5395
|
return /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(DrawerItemInner, { name: label, children: overrides.componentItem });
|
|
5612
5396
|
},
|
|
5613
5397
|
[componentId, label, overrides]
|
|
@@ -5637,14 +5421,14 @@ var DropZoneChild = ({
|
|
|
5637
5421
|
isLoading
|
|
5638
5422
|
);
|
|
5639
5423
|
if (!item) return;
|
|
5640
|
-
let
|
|
5424
|
+
let Render2 = componentConfig ? componentConfig.render : () => /* @__PURE__ */ (0, import_jsx_runtime25.jsxs)("div", { style: { padding: 48, textAlign: "center" }, children: [
|
|
5641
5425
|
"No configuration for ",
|
|
5642
5426
|
item.type
|
|
5643
5427
|
] });
|
|
5644
5428
|
let componentType = item.type;
|
|
5645
5429
|
const isInserting = "previewType" in item ? item.previewType === "insert" : false;
|
|
5646
5430
|
if (isInserting) {
|
|
5647
|
-
|
|
5431
|
+
Render2 = renderPreview;
|
|
5648
5432
|
}
|
|
5649
5433
|
return /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(
|
|
5650
5434
|
DraggableComponent,
|
|
@@ -5661,13 +5445,13 @@ var DropZoneChild = ({
|
|
|
5661
5445
|
userDragAxis: collisionAxis,
|
|
5662
5446
|
inDroppableZone,
|
|
5663
5447
|
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
|
-
|
|
5448
|
+
Render2,
|
|
5665
5449
|
__spreadProps(__spreadValues({}, defaultedPropsWithSlots), {
|
|
5666
5450
|
puck: __spreadProps(__spreadValues({}, defaultedPropsWithSlots.puck), {
|
|
5667
5451
|
dragRef
|
|
5668
5452
|
})
|
|
5669
5453
|
})
|
|
5670
|
-
) }) : /* @__PURE__ */ (0, import_jsx_runtime25.jsx)("div", { ref: dragRef, children: /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(
|
|
5454
|
+
) }) : /* @__PURE__ */ (0, import_jsx_runtime25.jsx)("div", { ref: dragRef, children: /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(Render2, __spreadValues({}, defaultedPropsWithSlots)) })
|
|
5671
5455
|
}
|
|
5672
5456
|
);
|
|
5673
5457
|
};
|
|
@@ -6563,6 +6347,7 @@ var DragDropContextClient = ({
|
|
|
6563
6347
|
type: "insert",
|
|
6564
6348
|
index: targetIndex,
|
|
6565
6349
|
zone: targetZone,
|
|
6350
|
+
element: source.element,
|
|
6566
6351
|
props: {
|
|
6567
6352
|
id: source.id.toString()
|
|
6568
6353
|
}
|
|
@@ -6588,7 +6373,8 @@ var DragDropContextClient = ({
|
|
|
6588
6373
|
type: "move",
|
|
6589
6374
|
index: targetIndex,
|
|
6590
6375
|
zone: targetZone,
|
|
6591
|
-
props: item.props
|
|
6376
|
+
props: item.props,
|
|
6377
|
+
element: source.element
|
|
6592
6378
|
}
|
|
6593
6379
|
}
|
|
6594
6380
|
});
|
|
@@ -6618,7 +6404,8 @@ var DragDropContextClient = ({
|
|
|
6618
6404
|
type: "move",
|
|
6619
6405
|
index: sourceData.index,
|
|
6620
6406
|
zone: sourceData.zone,
|
|
6621
|
-
props: item.props
|
|
6407
|
+
props: item.props,
|
|
6408
|
+
element: source.element
|
|
6622
6409
|
}
|
|
6623
6410
|
}
|
|
6624
6411
|
});
|
|
@@ -7573,7 +7360,7 @@ var Preview2 = ({ id = "puck-preview" }) => {
|
|
|
7573
7360
|
editMode: true,
|
|
7574
7361
|
children: /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(DropZonePure, { zone: rootDroppableId })
|
|
7575
7362
|
})
|
|
7576
|
-
) : /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(
|
|
7363
|
+
) : /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(Render, { data: renderData, config, metadata });
|
|
7577
7364
|
(0, import_react46.useEffect)(() => {
|
|
7578
7365
|
if (!iframe.enabled) {
|
|
7579
7366
|
setStatus("READY");
|
|
@@ -9029,6 +8816,230 @@ Puck.Components = Components;
|
|
|
9029
8816
|
Puck.Fields = Fields;
|
|
9030
8817
|
Puck.Outline = Outline;
|
|
9031
8818
|
Puck.Preview = Preview2;
|
|
8819
|
+
|
|
8820
|
+
// lib/migrate.ts
|
|
8821
|
+
init_react_import();
|
|
8822
|
+
var migrations = [
|
|
8823
|
+
// Migrate root to root.props
|
|
8824
|
+
(data) => {
|
|
8825
|
+
const rootProps = data.root.props || data.root;
|
|
8826
|
+
if (Object.keys(data.root).length > 0 && !data.root.props) {
|
|
8827
|
+
console.warn(
|
|
8828
|
+
"Migration applied: Root props moved from `root` to `root.props`."
|
|
8829
|
+
);
|
|
8830
|
+
return __spreadProps(__spreadValues({}, data), {
|
|
8831
|
+
root: {
|
|
8832
|
+
props: __spreadValues({}, rootProps)
|
|
8833
|
+
}
|
|
8834
|
+
});
|
|
8835
|
+
}
|
|
8836
|
+
return data;
|
|
8837
|
+
},
|
|
8838
|
+
// Migrate zones to slots
|
|
8839
|
+
(data, config, migrationOptions) => {
|
|
8840
|
+
var _a, _b;
|
|
8841
|
+
if (!config) return data;
|
|
8842
|
+
console.log("Migrating DropZones to slots...");
|
|
8843
|
+
const updatedItems = {};
|
|
8844
|
+
const appState = __spreadProps(__spreadValues({}, defaultAppState), { data });
|
|
8845
|
+
const { indexes } = walkAppState(appState, config);
|
|
8846
|
+
const deletedCompounds = [];
|
|
8847
|
+
walkAppState(appState, config, (content, zoneCompound, zoneType) => {
|
|
8848
|
+
var _a2, _b2, _c;
|
|
8849
|
+
if (zoneType === "dropzone") {
|
|
8850
|
+
const [id, slotName] = zoneCompound.split(":");
|
|
8851
|
+
const nodeData = indexes.nodes[id].data;
|
|
8852
|
+
const componentType = nodeData.type;
|
|
8853
|
+
const configForComponent = id === "root" ? config.root : config.components[componentType];
|
|
8854
|
+
if (((_b2 = (_a2 = configForComponent == null ? void 0 : configForComponent.fields) == null ? void 0 : _a2[slotName]) == null ? void 0 : _b2.type) === "slot") {
|
|
8855
|
+
updatedItems[id] = __spreadProps(__spreadValues({}, nodeData), {
|
|
8856
|
+
props: __spreadProps(__spreadValues(__spreadValues({}, nodeData.props), (_c = updatedItems[id]) == null ? void 0 : _c.props), {
|
|
8857
|
+
[slotName]: content
|
|
8858
|
+
})
|
|
8859
|
+
});
|
|
8860
|
+
deletedCompounds.push(zoneCompound);
|
|
8861
|
+
}
|
|
8862
|
+
return content;
|
|
8863
|
+
}
|
|
8864
|
+
return content;
|
|
8865
|
+
});
|
|
8866
|
+
const updated = walkAppState(
|
|
8867
|
+
appState,
|
|
8868
|
+
config,
|
|
8869
|
+
(content) => content,
|
|
8870
|
+
(item) => {
|
|
8871
|
+
var _a2;
|
|
8872
|
+
return (_a2 = updatedItems[item.props.id]) != null ? _a2 : item;
|
|
8873
|
+
}
|
|
8874
|
+
);
|
|
8875
|
+
deletedCompounds.forEach((zoneCompound) => {
|
|
8876
|
+
var _a2;
|
|
8877
|
+
const [_, propName] = zoneCompound.split(":");
|
|
8878
|
+
console.log(
|
|
8879
|
+
`\u2713 Success: Migrated "${zoneCompound}" from DropZone to slot field "${propName}"`
|
|
8880
|
+
);
|
|
8881
|
+
(_a2 = updated.data.zones) == null ? true : delete _a2[zoneCompound];
|
|
8882
|
+
});
|
|
8883
|
+
if (migrationOptions == null ? void 0 : migrationOptions.migrateDynamicZonesForComponent) {
|
|
8884
|
+
const unmigratedZonesGrouped = {};
|
|
8885
|
+
Object.keys((_a = updated.data.zones) != null ? _a : {}).forEach((zoneCompound) => {
|
|
8886
|
+
var _a2;
|
|
8887
|
+
const [componentId, propName] = zoneCompound.split(":");
|
|
8888
|
+
const content = (_a2 = updated.data.zones) == null ? void 0 : _a2[zoneCompound];
|
|
8889
|
+
if (!content) {
|
|
8890
|
+
return;
|
|
8891
|
+
}
|
|
8892
|
+
if (!unmigratedZonesGrouped[componentId]) {
|
|
8893
|
+
unmigratedZonesGrouped[componentId] = {};
|
|
8894
|
+
}
|
|
8895
|
+
if (!unmigratedZonesGrouped[componentId][propName]) {
|
|
8896
|
+
unmigratedZonesGrouped[componentId][propName] = content;
|
|
8897
|
+
}
|
|
8898
|
+
});
|
|
8899
|
+
Object.keys(unmigratedZonesGrouped).forEach((componentId) => {
|
|
8900
|
+
updated.data = walkTree(updated.data, config, (content) => {
|
|
8901
|
+
return content.map((child) => {
|
|
8902
|
+
var _a2;
|
|
8903
|
+
if (child.props.id !== componentId) {
|
|
8904
|
+
return child;
|
|
8905
|
+
}
|
|
8906
|
+
const migrateFn = (_a2 = migrationOptions == null ? void 0 : migrationOptions.migrateDynamicZonesForComponent) == null ? void 0 : _a2[child.type];
|
|
8907
|
+
if (!migrateFn) {
|
|
8908
|
+
return child;
|
|
8909
|
+
}
|
|
8910
|
+
const zones = unmigratedZonesGrouped[componentId];
|
|
8911
|
+
const migratedProps = migrateFn(child.props, zones);
|
|
8912
|
+
Object.keys(zones).forEach((propName) => {
|
|
8913
|
+
var _a3;
|
|
8914
|
+
const zoneCompound = `${componentId}:${propName}`;
|
|
8915
|
+
console.log(`\u2713 Success: Migrated "${zoneCompound}" DropZone`);
|
|
8916
|
+
(_a3 = updated.data.zones) == null ? true : delete _a3[zoneCompound];
|
|
8917
|
+
});
|
|
8918
|
+
return __spreadProps(__spreadValues({}, child), {
|
|
8919
|
+
props: migratedProps
|
|
8920
|
+
});
|
|
8921
|
+
});
|
|
8922
|
+
});
|
|
8923
|
+
});
|
|
8924
|
+
}
|
|
8925
|
+
Object.keys((_b = updated.data.zones) != null ? _b : {}).forEach((zoneCompound) => {
|
|
8926
|
+
const [_, propName] = zoneCompound.split(":");
|
|
8927
|
+
throw new Error(
|
|
8928
|
+
`Could not migrate DropZone "${zoneCompound}" to slot field. No slot exists with the name "${propName}".`
|
|
8929
|
+
);
|
|
8930
|
+
});
|
|
8931
|
+
delete updated.data.zones;
|
|
8932
|
+
return updated.data;
|
|
8933
|
+
}
|
|
8934
|
+
];
|
|
8935
|
+
function migrate(data, config, migrationOptions) {
|
|
8936
|
+
return migrations == null ? void 0 : migrations.reduce(
|
|
8937
|
+
(acc, migration) => migration(acc, config, migrationOptions),
|
|
8938
|
+
data
|
|
8939
|
+
);
|
|
8940
|
+
}
|
|
8941
|
+
|
|
8942
|
+
// lib/transform-props.ts
|
|
8943
|
+
init_react_import();
|
|
8944
|
+
|
|
8945
|
+
// lib/data/default-data.ts
|
|
8946
|
+
init_react_import();
|
|
8947
|
+
var defaultData = (data) => __spreadProps(__spreadValues({}, data), {
|
|
8948
|
+
root: data.root || {},
|
|
8949
|
+
content: data.content || []
|
|
8950
|
+
});
|
|
8951
|
+
|
|
8952
|
+
// lib/transform-props.ts
|
|
8953
|
+
function transformProps(data, propTransforms, config = { components: {} }) {
|
|
8954
|
+
const mapItem = (item) => {
|
|
8955
|
+
if (propTransforms[item.type]) {
|
|
8956
|
+
return __spreadProps(__spreadValues({}, item), {
|
|
8957
|
+
props: __spreadValues({
|
|
8958
|
+
id: item.props.id
|
|
8959
|
+
}, propTransforms[item.type](item.props))
|
|
8960
|
+
});
|
|
8961
|
+
}
|
|
8962
|
+
return item;
|
|
8963
|
+
};
|
|
8964
|
+
const defaultedData = defaultData(data);
|
|
8965
|
+
const rootProps = defaultedData.root.props || defaultedData.root;
|
|
8966
|
+
let newRoot = __spreadValues({}, defaultedData.root);
|
|
8967
|
+
if (propTransforms["root"]) {
|
|
8968
|
+
newRoot.props = propTransforms["root"](rootProps);
|
|
8969
|
+
}
|
|
8970
|
+
const dataWithUpdatedRoot = __spreadProps(__spreadValues({}, defaultedData), { root: newRoot });
|
|
8971
|
+
const updatedData = walkTree(
|
|
8972
|
+
dataWithUpdatedRoot,
|
|
8973
|
+
config,
|
|
8974
|
+
(content) => content.map(mapItem)
|
|
8975
|
+
);
|
|
8976
|
+
if (!defaultedData.root.props) {
|
|
8977
|
+
updatedData.root = updatedData.root.props;
|
|
8978
|
+
}
|
|
8979
|
+
return updatedData;
|
|
8980
|
+
}
|
|
8981
|
+
|
|
8982
|
+
// lib/resolve-all-data.ts
|
|
8983
|
+
init_react_import();
|
|
8984
|
+
|
|
8985
|
+
// lib/data/to-component.ts
|
|
8986
|
+
init_react_import();
|
|
8987
|
+
var toComponent = (item) => {
|
|
8988
|
+
return "type" in item ? item : __spreadProps(__spreadValues({}, item), {
|
|
8989
|
+
props: __spreadProps(__spreadValues({}, item.props), { id: "root" }),
|
|
8990
|
+
type: "root"
|
|
8991
|
+
});
|
|
8992
|
+
};
|
|
8993
|
+
|
|
8994
|
+
// lib/resolve-all-data.ts
|
|
8995
|
+
function resolveAllData(_0, _1) {
|
|
8996
|
+
return __async(this, arguments, function* (data, config, metadata = {}, onResolveStart, onResolveEnd) {
|
|
8997
|
+
var _a;
|
|
8998
|
+
const defaultedData = defaultData(data);
|
|
8999
|
+
const resolveNode = (_node) => __async(this, null, function* () {
|
|
9000
|
+
const node = toComponent(_node);
|
|
9001
|
+
onResolveStart == null ? void 0 : onResolveStart(node);
|
|
9002
|
+
const resolved = (yield resolveComponentData(
|
|
9003
|
+
node,
|
|
9004
|
+
config,
|
|
9005
|
+
metadata,
|
|
9006
|
+
() => {
|
|
9007
|
+
},
|
|
9008
|
+
() => {
|
|
9009
|
+
},
|
|
9010
|
+
"force"
|
|
9011
|
+
)).node;
|
|
9012
|
+
const resolvedDeep = yield mapSlots(
|
|
9013
|
+
resolved,
|
|
9014
|
+
processContent,
|
|
9015
|
+
config
|
|
9016
|
+
);
|
|
9017
|
+
onResolveEnd == null ? void 0 : onResolveEnd(toComponent(resolvedDeep));
|
|
9018
|
+
return resolvedDeep;
|
|
9019
|
+
});
|
|
9020
|
+
const processContent = (content) => __async(this, null, function* () {
|
|
9021
|
+
return Promise.all(content.map(resolveNode));
|
|
9022
|
+
});
|
|
9023
|
+
const processZones = () => __async(this, null, function* () {
|
|
9024
|
+
var _a2;
|
|
9025
|
+
const zones = (_a2 = data.zones) != null ? _a2 : {};
|
|
9026
|
+
Object.entries(zones).forEach((_02) => __async(this, [_02], function* ([zoneKey, content]) {
|
|
9027
|
+
zones[zoneKey] = yield Promise.all(content.map(resolveNode));
|
|
9028
|
+
}));
|
|
9029
|
+
return zones;
|
|
9030
|
+
});
|
|
9031
|
+
const dynamic = {
|
|
9032
|
+
root: yield resolveNode(defaultedData.root),
|
|
9033
|
+
content: yield processContent(defaultedData.content),
|
|
9034
|
+
zones: yield processZones()
|
|
9035
|
+
};
|
|
9036
|
+
Object.keys((_a = defaultedData.zones) != null ? _a : {}).forEach((zoneKey) => __async(this, null, function* () {
|
|
9037
|
+
const content = defaultedData.zones[zoneKey];
|
|
9038
|
+
dynamic.zones[zoneKey] = yield processContent(content);
|
|
9039
|
+
}), {});
|
|
9040
|
+
return dynamic;
|
|
9041
|
+
});
|
|
9042
|
+
}
|
|
9032
9043
|
// Annotate the CommonJS export names for ESM import in node:
|
|
9033
9044
|
0 && (module.exports = {
|
|
9034
9045
|
Action,
|