admin-lib-cms 1.2.1 → 1.2.3
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-Y6FXYEAI.mjs +10 -0
- package/dist/index.d.mts +11 -2
- package/dist/index.d.ts +11 -2
- package/dist/index.js +647 -183
- package/dist/index.mjs +697 -232
- package/dist/types.d.mts +10 -1
- package/dist/types.d.ts +10 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -28,6 +28,7 @@ __export(index_exports, {
|
|
|
28
28
|
EditableImage: () => EditableImage,
|
|
29
29
|
EditableLink: () => EditableLink,
|
|
30
30
|
EditableList: () => EditableList,
|
|
31
|
+
EditableReference: () => EditableReference,
|
|
31
32
|
EditableText: () => EditableText,
|
|
32
33
|
SubscriptionPage: () => SubscriptionPage,
|
|
33
34
|
SubscriptionProvider: () => SubscriptionProvider,
|
|
@@ -451,13 +452,13 @@ function useSubmit(formId) {
|
|
|
451
452
|
// src/editable.tsx
|
|
452
453
|
var import_react4 = require("react");
|
|
453
454
|
var import_jsx_runtime4 = require("react/jsx-runtime");
|
|
454
|
-
function useRegister(id, type, label, section, pageId, defaultValue, itemSchema, fixedLength, search) {
|
|
455
|
+
function useRegister(id, type, label, section, pageId, defaultValue, itemSchema, fixedLength, search, collection, max, displayField) {
|
|
455
456
|
const ctx = useCmsOptional();
|
|
456
457
|
(0, import_react4.useEffect)(() => {
|
|
457
458
|
if (!ctx) return;
|
|
458
|
-
ctx.registerEditable({ id, type, label, section, pageId, defaultValue, itemSchema, fixedLength, search });
|
|
459
|
+
ctx.registerEditable({ id, type, label, section, pageId, defaultValue, itemSchema, fixedLength, search, collection, max, displayField });
|
|
459
460
|
return () => ctx.unregisterEditable(id);
|
|
460
|
-
}, [ctx?.registerEditable, ctx?.unregisterEditable, id, type, label, section, pageId, defaultValue, itemSchema, fixedLength, search]);
|
|
461
|
+
}, [ctx?.registerEditable, ctx?.unregisterEditable, id, type, label, section, pageId, defaultValue, itemSchema, fixedLength, search, collection, max, displayField]);
|
|
461
462
|
return ctx;
|
|
462
463
|
}
|
|
463
464
|
function editableClasses(active, selected) {
|
|
@@ -474,9 +475,10 @@ function EditableText({
|
|
|
474
475
|
pageId,
|
|
475
476
|
children,
|
|
476
477
|
as = "span",
|
|
477
|
-
className
|
|
478
|
+
className,
|
|
479
|
+
type = "text"
|
|
478
480
|
}) {
|
|
479
|
-
const ctx = useRegister(id,
|
|
481
|
+
const ctx = useRegister(id, type, label, section, pageId, children);
|
|
480
482
|
const value = ctx && Object.prototype.hasOwnProperty.call(ctx.overrides, id) ? String(ctx.overrides[id] ?? "") : children;
|
|
481
483
|
const active = !!ctx?.editMode;
|
|
482
484
|
const selected = ctx?.selectedId === id;
|
|
@@ -488,6 +490,13 @@ function EditableText({
|
|
|
488
490
|
e.stopPropagation();
|
|
489
491
|
ctx.setSelectedId(id);
|
|
490
492
|
};
|
|
493
|
+
let finalChildren = renderValue;
|
|
494
|
+
if (typeof renderValue === "string" && renderValue.includes("\n")) {
|
|
495
|
+
finalChildren = renderValue.split("\n").map((line, i, arr) => /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(import_react4.Fragment, { children: [
|
|
496
|
+
line,
|
|
497
|
+
i < arr.length - 1 && /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("br", {})
|
|
498
|
+
] }, i));
|
|
499
|
+
}
|
|
491
500
|
return (0, import_react4.createElement)(
|
|
492
501
|
as,
|
|
493
502
|
{
|
|
@@ -499,7 +508,7 @@ function EditableText({
|
|
|
499
508
|
"data-cms-id": id,
|
|
500
509
|
onClick: active ? onClick : void 0
|
|
501
510
|
},
|
|
502
|
-
|
|
511
|
+
finalChildren
|
|
503
512
|
);
|
|
504
513
|
}
|
|
505
514
|
function EditableImage({
|
|
@@ -526,7 +535,7 @@ function EditableImage({
|
|
|
526
535
|
return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
|
|
527
536
|
"img",
|
|
528
537
|
{
|
|
529
|
-
src: value,
|
|
538
|
+
src: value || void 0,
|
|
530
539
|
alt,
|
|
531
540
|
width,
|
|
532
541
|
height,
|
|
@@ -674,6 +683,58 @@ function EditableList({
|
|
|
674
683
|
}
|
|
675
684
|
);
|
|
676
685
|
}
|
|
686
|
+
function EditableReference({
|
|
687
|
+
id,
|
|
688
|
+
label,
|
|
689
|
+
section,
|
|
690
|
+
pageId,
|
|
691
|
+
collection,
|
|
692
|
+
max,
|
|
693
|
+
displayField,
|
|
694
|
+
className,
|
|
695
|
+
children
|
|
696
|
+
}) {
|
|
697
|
+
const ctx = useRegister(id, "reference", label, section, pageId, max === 1 ? "" : [], void 0, void 0, void 0, collection, max, displayField);
|
|
698
|
+
const active = !!ctx?.editMode;
|
|
699
|
+
const selected = ctx?.selectedId === id;
|
|
700
|
+
const value = ctx && Object.prototype.hasOwnProperty.call(ctx.overrides, id) ? ctx.overrides[id] : void 0;
|
|
701
|
+
const [resolvedItems, setResolvedItems] = (0, import_react4.useState)([]);
|
|
702
|
+
(0, import_react4.useEffect)(() => {
|
|
703
|
+
if (!ctx) return;
|
|
704
|
+
const ids = Array.isArray(value) ? value : value ? [value] : [];
|
|
705
|
+
if (ids.length === 0) {
|
|
706
|
+
setResolvedItems([]);
|
|
707
|
+
return;
|
|
708
|
+
}
|
|
709
|
+
ctx.adapter.listEntries(collection).then((res) => {
|
|
710
|
+
setResolvedItems(res.filter((r) => ids.includes(r.id)));
|
|
711
|
+
}).catch(() => {
|
|
712
|
+
});
|
|
713
|
+
}, [value, collection, ctx]);
|
|
714
|
+
const onClick = (e) => {
|
|
715
|
+
if (!active || !ctx) return;
|
|
716
|
+
e.preventDefault();
|
|
717
|
+
e.stopPropagation();
|
|
718
|
+
ctx.setSelectedId(id);
|
|
719
|
+
};
|
|
720
|
+
const childContent = typeof children === "function" ? children(resolvedItems) : children;
|
|
721
|
+
return /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(
|
|
722
|
+
"div",
|
|
723
|
+
{
|
|
724
|
+
"data-cms-id": id,
|
|
725
|
+
onClick: active ? onClick : void 0,
|
|
726
|
+
className: [className, editableClasses(active, selected)].filter(Boolean).join(" "),
|
|
727
|
+
children: [
|
|
728
|
+
childContent,
|
|
729
|
+
active && (!resolvedItems || resolvedItems.length === 0) && /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("div", { style: { padding: "2rem", textAlign: "center", fontSize: "0.875rem", color: "#737373", backgroundColor: "rgba(245, 245, 245, 0.5)", border: "2px dashed #d4d4d4", borderRadius: "0.75rem", width: "100%", cursor: "pointer" }, children: [
|
|
730
|
+
"Empty Reference ",
|
|
731
|
+
label ? `(${label})` : "",
|
|
732
|
+
" \u2014 Click to select"
|
|
733
|
+
] })
|
|
734
|
+
]
|
|
735
|
+
}
|
|
736
|
+
);
|
|
737
|
+
}
|
|
677
738
|
|
|
678
739
|
// src/admin/AdminApp.tsx
|
|
679
740
|
var import_react5 = require("react");
|
|
@@ -1233,6 +1294,74 @@ function FieldListItem({ meta, onSelect }) {
|
|
|
1233
1294
|
}
|
|
1234
1295
|
) });
|
|
1235
1296
|
}
|
|
1297
|
+
function SidebarReferenceSelect({ meta, value, onChange }) {
|
|
1298
|
+
const ctx = useCmsContext();
|
|
1299
|
+
const collection = ctx.config.collections?.find((c) => c.id === meta.collection);
|
|
1300
|
+
const [items, setItems] = (0, import_react5.useState)([]);
|
|
1301
|
+
const [search, setSearch] = (0, import_react5.useState)("");
|
|
1302
|
+
const [loading, setLoading] = (0, import_react5.useState)(true);
|
|
1303
|
+
(0, import_react5.useEffect)(() => {
|
|
1304
|
+
if (!meta.collection) return;
|
|
1305
|
+
setLoading(true);
|
|
1306
|
+
ctx.adapter.listEntries(meta.collection).then((res) => {
|
|
1307
|
+
setItems(res);
|
|
1308
|
+
setLoading(false);
|
|
1309
|
+
});
|
|
1310
|
+
}, [meta.collection, ctx.adapter]);
|
|
1311
|
+
const selectedIds = Array.isArray(value) ? value : value ? [value] : [];
|
|
1312
|
+
const max = meta.max ?? 1;
|
|
1313
|
+
const toggle = (id) => {
|
|
1314
|
+
if (max === 1) {
|
|
1315
|
+
onChange([id]);
|
|
1316
|
+
} else {
|
|
1317
|
+
if (selectedIds.includes(id)) {
|
|
1318
|
+
onChange(selectedIds.filter((s) => s !== id));
|
|
1319
|
+
} else if (selectedIds.length < max) {
|
|
1320
|
+
onChange([...selectedIds, id]);
|
|
1321
|
+
}
|
|
1322
|
+
}
|
|
1323
|
+
};
|
|
1324
|
+
const imgField = collection?.fields.find((f) => f.type === "image");
|
|
1325
|
+
const txtField = collection?.fields.find((f) => f.type === "text" || f.type === "textarea" || f.type === "richtext");
|
|
1326
|
+
const filtered = items.filter((it) => {
|
|
1327
|
+
if (!search) return true;
|
|
1328
|
+
const q = search.toLowerCase();
|
|
1329
|
+
const txt = String(it[txtField?.id || "id"] || "");
|
|
1330
|
+
return txt.toLowerCase().includes(q);
|
|
1331
|
+
});
|
|
1332
|
+
return /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className: "space-y-3", children: [
|
|
1333
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
1334
|
+
"input",
|
|
1335
|
+
{
|
|
1336
|
+
placeholder: "Search...",
|
|
1337
|
+
value: search,
|
|
1338
|
+
onChange: (e) => setSearch(e.target.value),
|
|
1339
|
+
className: "w-full rounded-lg border border-slate-200 px-3 py-2 text-sm text-slate-800 shadow-sm focus:border-indigo-500 focus:outline-none focus:ring-2 focus:ring-indigo-500/20"
|
|
1340
|
+
}
|
|
1341
|
+
),
|
|
1342
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className: "space-y-2 max-h-60 overflow-y-auto pr-1", children: [
|
|
1343
|
+
loading ? /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("p", { className: "text-xs text-slate-500", children: "Loading..." }) : filtered.map((it) => {
|
|
1344
|
+
const isSelected = selectedIds.includes(it.id);
|
|
1345
|
+
const imgSrc = imgField ? it[imgField.id] : null;
|
|
1346
|
+
const label = txtField ? it[txtField.id] : it.id;
|
|
1347
|
+
return /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(
|
|
1348
|
+
"div",
|
|
1349
|
+
{
|
|
1350
|
+
onClick: () => toggle(it.id),
|
|
1351
|
+
className: `flex items-center gap-3 p-2 rounded-xl cursor-pointer border ${isSelected ? "border-indigo-500 bg-indigo-50" : "border-slate-100 bg-slate-50 hover:border-slate-300"}`,
|
|
1352
|
+
children: [
|
|
1353
|
+
!!imgSrc && /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("img", { src: Array.isArray(imgSrc) ? String(imgSrc[0]) : String(imgSrc), alt: "", className: "w-10 h-10 rounded-lg object-cover bg-white border border-slate-200" }),
|
|
1354
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)("span", { className: `text-sm ${isSelected ? "font-semibold text-indigo-900" : "text-slate-700"}`, children: String(label) }),
|
|
1355
|
+
isSelected && /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_lucide_react2.Check, { className: "w-4 h-4 text-indigo-600 ml-auto" })
|
|
1356
|
+
]
|
|
1357
|
+
},
|
|
1358
|
+
it.id
|
|
1359
|
+
);
|
|
1360
|
+
}),
|
|
1361
|
+
!loading && filtered.length === 0 && /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("p", { className: "text-xs text-slate-500 text-center py-4", children: "No items found." })
|
|
1362
|
+
] })
|
|
1363
|
+
] });
|
|
1364
|
+
}
|
|
1236
1365
|
function FieldEditor({
|
|
1237
1366
|
meta,
|
|
1238
1367
|
value,
|
|
@@ -1243,6 +1372,8 @@ function FieldEditor({
|
|
|
1243
1372
|
const ctx = useCmsContext();
|
|
1244
1373
|
const [expandedItems, setExpandedItems] = (0, import_react5.useState)({});
|
|
1245
1374
|
const [searchQuery, setSearchQuery] = (0, import_react5.useState)("");
|
|
1375
|
+
const [listDragIdx, setListDragIdx] = (0, import_react5.useState)(null);
|
|
1376
|
+
const [listDragOverIdx, setListDragOverIdx] = (0, import_react5.useState)(null);
|
|
1246
1377
|
return /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className: "p-5 animate-in slide-in-from-right-4 duration-200", children: [
|
|
1247
1378
|
/* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className: "mb-5", children: [
|
|
1248
1379
|
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", { className: "inline-flex items-center gap-1.5 px-2 py-1 rounded bg-indigo-50 text-indigo-700 text-[10px] font-bold uppercase tracking-wider mb-2", children: meta.type }),
|
|
@@ -1432,163 +1563,245 @@ function FieldEditor({
|
|
|
1432
1563
|
if (!title.includes(searchQuery.toLowerCase())) return null;
|
|
1433
1564
|
}
|
|
1434
1565
|
const isExpanded = expandedItems[idx] ?? false;
|
|
1435
|
-
return /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(
|
|
1436
|
-
|
|
1437
|
-
|
|
1438
|
-
|
|
1439
|
-
|
|
1440
|
-
|
|
1441
|
-
|
|
1442
|
-
|
|
1443
|
-
|
|
1444
|
-
|
|
1445
|
-
|
|
1566
|
+
return /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(
|
|
1567
|
+
"div",
|
|
1568
|
+
{
|
|
1569
|
+
draggable: true,
|
|
1570
|
+
onDragStart: (e) => {
|
|
1571
|
+
setListDragIdx(idx);
|
|
1572
|
+
e.dataTransfer.effectAllowed = "move";
|
|
1573
|
+
},
|
|
1574
|
+
onDragOver: (e) => {
|
|
1575
|
+
e.preventDefault();
|
|
1576
|
+
e.dataTransfer.dropEffect = "move";
|
|
1577
|
+
setListDragOverIdx(idx);
|
|
1578
|
+
},
|
|
1579
|
+
onDragEnd: () => {
|
|
1580
|
+
setListDragIdx(null);
|
|
1581
|
+
setListDragOverIdx(null);
|
|
1582
|
+
},
|
|
1583
|
+
onDrop: (e) => {
|
|
1584
|
+
e.preventDefault();
|
|
1585
|
+
if (listDragIdx === null || listDragIdx === idx) {
|
|
1586
|
+
setListDragOverIdx(null);
|
|
1587
|
+
return;
|
|
1446
1588
|
}
|
|
1447
|
-
|
|
1448
|
-
|
|
1449
|
-
|
|
1450
|
-
|
|
1451
|
-
|
|
1452
|
-
|
|
1453
|
-
|
|
1454
|
-
|
|
1455
|
-
|
|
1456
|
-
|
|
1457
|
-
|
|
1458
|
-
const arr = Array.isArray(value) ? [...value] : [];
|
|
1459
|
-
arr[idx] = { ...arr[idx] || {}, [schemaField.key]: val };
|
|
1460
|
-
onChange(arr);
|
|
1461
|
-
}
|
|
1462
|
-
}
|
|
1463
|
-
) : schemaField.type === "textarea" ? /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
1464
|
-
"textarea",
|
|
1589
|
+
const arr = Array.isArray(value) ? [...value] : [];
|
|
1590
|
+
const [moved] = arr.splice(listDragIdx, 1);
|
|
1591
|
+
arr.splice(idx, 0, moved);
|
|
1592
|
+
onChange(arr);
|
|
1593
|
+
setListDragIdx(null);
|
|
1594
|
+
setListDragOverIdx(null);
|
|
1595
|
+
},
|
|
1596
|
+
className: `bg-slate-50 p-3 rounded-xl border transition-all relative group ${listDragOverIdx === idx ? "border-indigo-500 border-2 bg-indigo-50/40" : "border-slate-200 hover:border-slate-300"} ${listDragIdx === idx ? "opacity-40" : ""}`,
|
|
1597
|
+
children: [
|
|
1598
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(
|
|
1599
|
+
"div",
|
|
1465
1600
|
{
|
|
1466
|
-
|
|
1467
|
-
|
|
1468
|
-
|
|
1469
|
-
|
|
1470
|
-
|
|
1471
|
-
|
|
1472
|
-
|
|
1473
|
-
|
|
1601
|
+
className: "absolute left-3 top-3.5 z-10 flex items-center gap-1 text-slate-400 opacity-0 group-hover:opacity-100 transition-opacity pointer-events-none group-hover:pointer-events-auto select-none",
|
|
1602
|
+
title: "Drag or use arrows to reorder",
|
|
1603
|
+
children: [
|
|
1604
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_lucide_react2.GripVertical, { className: "w-4 h-4 cursor-grab active:cursor-grabbing hover:text-indigo-600" }),
|
|
1605
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className: "flex items-center gap-1", children: [
|
|
1606
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
1607
|
+
"button",
|
|
1608
|
+
{
|
|
1609
|
+
type: "button",
|
|
1610
|
+
disabled: idx === 0,
|
|
1611
|
+
onClick: (e) => {
|
|
1612
|
+
e.stopPropagation();
|
|
1613
|
+
if (idx === 0) return;
|
|
1614
|
+
const arr = Array.isArray(value) ? [...value] : [];
|
|
1615
|
+
const [moved] = arr.splice(idx, 1);
|
|
1616
|
+
arr.splice(idx - 1, 0, moved);
|
|
1617
|
+
onChange(arr);
|
|
1618
|
+
},
|
|
1619
|
+
className: "p-0.5 hover:text-indigo-600 disabled:opacity-20 transition-colors",
|
|
1620
|
+
title: "Move Up",
|
|
1621
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_lucide_react2.ChevronUp, { className: "w-3.5 h-3.5" })
|
|
1622
|
+
}
|
|
1623
|
+
),
|
|
1624
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
1625
|
+
"button",
|
|
1626
|
+
{
|
|
1627
|
+
type: "button",
|
|
1628
|
+
disabled: idx === (Array.isArray(value) ? value.length - 1 : 0),
|
|
1629
|
+
onClick: (e) => {
|
|
1630
|
+
e.stopPropagation();
|
|
1631
|
+
const arr = Array.isArray(value) ? [...value] : [];
|
|
1632
|
+
if (idx >= arr.length - 1) return;
|
|
1633
|
+
const [moved] = arr.splice(idx, 1);
|
|
1634
|
+
arr.splice(idx + 1, 0, moved);
|
|
1635
|
+
onChange(arr);
|
|
1636
|
+
},
|
|
1637
|
+
className: "p-0.5 hover:text-indigo-600 disabled:opacity-20 transition-colors",
|
|
1638
|
+
title: "Move Down",
|
|
1639
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_lucide_react2.ChevronDown, { className: "w-3.5 h-3.5" })
|
|
1640
|
+
}
|
|
1641
|
+
)
|
|
1642
|
+
] })
|
|
1643
|
+
]
|
|
1474
1644
|
}
|
|
1475
|
-
)
|
|
1476
|
-
|
|
1477
|
-
|
|
1645
|
+
),
|
|
1646
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className: "space-y-3 w-full min-w-0", children: [
|
|
1647
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(
|
|
1648
|
+
"div",
|
|
1478
1649
|
{
|
|
1479
|
-
|
|
1480
|
-
|
|
1481
|
-
|
|
1482
|
-
|
|
1483
|
-
|
|
1484
|
-
|
|
1485
|
-
},
|
|
1486
|
-
className: "w-4 h-4 text-indigo-600 border-slate-300 rounded focus:ring-indigo-500"
|
|
1650
|
+
className: "flex items-center justify-between cursor-pointer py-1 select-none",
|
|
1651
|
+
onClick: () => setExpandedItems((prev) => ({ ...prev, [idx]: !isExpanded })),
|
|
1652
|
+
children: [
|
|
1653
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", { className: "font-semibold text-slate-700 text-sm flex-1 truncate pr-6 pl-0.5 group-hover:pl-20 transition-all duration-200", children: meta.itemSchema ? item?.title || item?.name || `Item ${idx + 1}` : String(item) }),
|
|
1654
|
+
isExpanded ? /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_lucide_react2.ChevronUp, { className: "w-4 h-4 text-slate-500 shrink-0" }) : /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_lucide_react2.ChevronDown, { className: "w-4 h-4 text-slate-500 shrink-0" })
|
|
1655
|
+
]
|
|
1487
1656
|
}
|
|
1488
1657
|
),
|
|
1489
|
-
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)("
|
|
1490
|
-
|
|
1491
|
-
|
|
1492
|
-
|
|
1493
|
-
"input",
|
|
1658
|
+
isExpanded && /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", { className: "pt-3 border-t border-slate-200 mt-2 space-y-3", children: meta.itemSchema ? meta.itemSchema.map((schemaField) => /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { children: [
|
|
1659
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)("label", { className: "block text-[10px] font-bold text-slate-500 uppercase mb-1", children: schemaField.label || schemaField.key }),
|
|
1660
|
+
schemaField.type === "icon" ? /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
1661
|
+
SearchableSelect,
|
|
1494
1662
|
{
|
|
1495
|
-
|
|
1663
|
+
value: String(item?.[schemaField.key] ?? ""),
|
|
1664
|
+
options: schemaField.options ?? [],
|
|
1665
|
+
placeholder: "Search icon...",
|
|
1666
|
+
iconMap: ctx.iconMap,
|
|
1667
|
+
onChange: (val) => {
|
|
1668
|
+
const arr = Array.isArray(value) ? [...value] : [];
|
|
1669
|
+
arr[idx] = { ...arr[idx] || {}, [schemaField.key]: val };
|
|
1670
|
+
onChange(arr);
|
|
1671
|
+
}
|
|
1672
|
+
}
|
|
1673
|
+
) : schemaField.type === "textarea" ? /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
1674
|
+
"textarea",
|
|
1675
|
+
{
|
|
1676
|
+
rows: 3,
|
|
1496
1677
|
value: String(item?.[schemaField.key] ?? ""),
|
|
1497
1678
|
onChange: (e) => {
|
|
1498
1679
|
const arr = Array.isArray(value) ? [...value] : [];
|
|
1499
1680
|
arr[idx] = { ...arr[idx] || {}, [schemaField.key]: e.target.value };
|
|
1500
1681
|
onChange(arr);
|
|
1501
1682
|
},
|
|
1502
|
-
placeholder: "https://...",
|
|
1503
1683
|
className: "w-full rounded-lg border border-slate-200 px-3 py-2 text-sm text-slate-800 shadow-sm focus:border-indigo-500 focus:outline-none focus:ring-2 focus:ring-indigo-500/20"
|
|
1504
1684
|
}
|
|
1505
|
-
),
|
|
1506
|
-
/* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("label", { className: "flex-shrink-0 cursor-pointer rounded-lg bg-slate-100 px-3 py-2 text-sm font-medium text-slate-700 hover:bg-slate-200 transition-colors border border-slate-200 flex items-center justify-center", children: [
|
|
1507
|
-
"Upload",
|
|
1685
|
+
) : schemaField.type === "boolean" ? /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("label", { className: "flex items-center gap-2 mt-1 cursor-pointer", children: [
|
|
1508
1686
|
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
1509
1687
|
"input",
|
|
1510
1688
|
{
|
|
1511
|
-
type: "
|
|
1512
|
-
|
|
1513
|
-
className: "hidden",
|
|
1689
|
+
type: "checkbox",
|
|
1690
|
+
checked: !!item?.[schemaField.key],
|
|
1514
1691
|
onChange: (e) => {
|
|
1515
|
-
const
|
|
1516
|
-
|
|
1517
|
-
|
|
1518
|
-
|
|
1519
|
-
|
|
1520
|
-
|
|
1521
|
-
|
|
1522
|
-
|
|
1523
|
-
|
|
1524
|
-
|
|
1525
|
-
|
|
1526
|
-
|
|
1692
|
+
const arr = Array.isArray(value) ? [...value] : [];
|
|
1693
|
+
arr[idx] = { ...arr[idx] || {}, [schemaField.key]: e.target.checked };
|
|
1694
|
+
onChange(arr);
|
|
1695
|
+
},
|
|
1696
|
+
className: "w-4 h-4 text-indigo-600 border-slate-300 rounded focus:ring-indigo-500"
|
|
1697
|
+
}
|
|
1698
|
+
),
|
|
1699
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)("span", { className: "text-sm text-slate-700", children: schemaField.label || schemaField.key })
|
|
1700
|
+
] }) : schemaField.type === "image" ? /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className: "space-y-3 mt-1", children: [
|
|
1701
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className: "flex gap-2", children: [
|
|
1702
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
1703
|
+
"input",
|
|
1704
|
+
{
|
|
1705
|
+
type: "url",
|
|
1706
|
+
value: String(item?.[schemaField.key] ?? ""),
|
|
1707
|
+
onChange: (e) => {
|
|
1708
|
+
const arr = Array.isArray(value) ? [...value] : [];
|
|
1709
|
+
arr[idx] = { ...arr[idx] || {}, [schemaField.key]: e.target.value };
|
|
1710
|
+
onChange(arr);
|
|
1711
|
+
},
|
|
1712
|
+
placeholder: "https://...",
|
|
1713
|
+
className: "w-full rounded-lg border border-slate-200 px-3 py-2 text-sm text-slate-800 shadow-sm focus:border-indigo-500 focus:outline-none focus:ring-2 focus:ring-indigo-500/20"
|
|
1527
1714
|
}
|
|
1715
|
+
),
|
|
1716
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("label", { className: "flex-shrink-0 cursor-pointer rounded-lg bg-slate-100 px-3 py-2 text-sm font-medium text-slate-700 hover:bg-slate-200 transition-colors border border-slate-200 flex items-center justify-center", children: [
|
|
1717
|
+
"Upload",
|
|
1718
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
1719
|
+
"input",
|
|
1720
|
+
{
|
|
1721
|
+
type: "file",
|
|
1722
|
+
accept: "image/*",
|
|
1723
|
+
className: "hidden",
|
|
1724
|
+
onChange: (e) => {
|
|
1725
|
+
const file = e.target.files?.[0];
|
|
1726
|
+
if (file) {
|
|
1727
|
+
void handleImageFile(
|
|
1728
|
+
file,
|
|
1729
|
+
(url) => {
|
|
1730
|
+
const arr = Array.isArray(value) ? [...value] : [];
|
|
1731
|
+
arr[idx] = { ...arr[idx] || {}, [schemaField.key]: url };
|
|
1732
|
+
onChange(arr);
|
|
1733
|
+
},
|
|
1734
|
+
ctx.uploadImage
|
|
1735
|
+
);
|
|
1736
|
+
}
|
|
1737
|
+
}
|
|
1738
|
+
}
|
|
1739
|
+
)
|
|
1740
|
+
] })
|
|
1741
|
+
] }),
|
|
1742
|
+
item?.[schemaField.key] ? /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", { className: "rounded-lg border border-slate-200 p-1 bg-slate-50 overflow-hidden relative group max-w-xs", children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
1743
|
+
"img",
|
|
1744
|
+
{
|
|
1745
|
+
src: String(item?.[schemaField.key]),
|
|
1746
|
+
alt: "",
|
|
1747
|
+
className: "w-full h-auto max-h-32 object-contain rounded-md"
|
|
1528
1748
|
}
|
|
1529
|
-
)
|
|
1530
|
-
] })
|
|
1531
|
-
|
|
1532
|
-
|
|
1533
|
-
|
|
1749
|
+
) }) : null
|
|
1750
|
+
] }) : schemaField.type === "select" ? /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
1751
|
+
"select",
|
|
1752
|
+
{
|
|
1753
|
+
value: String(item?.[schemaField.key] ?? ""),
|
|
1754
|
+
onChange: (e) => {
|
|
1755
|
+
const arr = Array.isArray(value) ? [...value] : [];
|
|
1756
|
+
arr[idx] = { ...arr[idx] || {}, [schemaField.key]: e.target.value };
|
|
1757
|
+
onChange(arr);
|
|
1758
|
+
},
|
|
1759
|
+
className: "w-full rounded-lg border border-slate-200 px-3 py-2 text-sm text-slate-800 shadow-sm focus:border-indigo-500 focus:outline-none focus:ring-2 focus:ring-indigo-500/20 bg-white",
|
|
1760
|
+
children: schemaField.options?.map((opt) => /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("option", { value: opt, children: opt }, opt))
|
|
1761
|
+
}
|
|
1762
|
+
) : /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
1763
|
+
"input",
|
|
1764
|
+
{
|
|
1765
|
+
type: "text",
|
|
1766
|
+
value: String(item?.[schemaField.key] ?? ""),
|
|
1767
|
+
onChange: (e) => {
|
|
1768
|
+
const arr = Array.isArray(value) ? [...value] : [];
|
|
1769
|
+
arr[idx] = { ...arr[idx] || {}, [schemaField.key]: e.target.value };
|
|
1770
|
+
onChange(arr);
|
|
1771
|
+
},
|
|
1772
|
+
className: "w-full rounded-lg border border-slate-200 px-3 py-2 text-sm text-slate-800 shadow-sm focus:border-indigo-500 focus:outline-none focus:ring-2 focus:ring-indigo-500/20"
|
|
1773
|
+
}
|
|
1774
|
+
)
|
|
1775
|
+
] }, schemaField.key)) : /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
1776
|
+
"input",
|
|
1534
1777
|
{
|
|
1535
|
-
|
|
1536
|
-
|
|
1537
|
-
|
|
1778
|
+
type: "text",
|
|
1779
|
+
value: String(item),
|
|
1780
|
+
onChange: (e) => {
|
|
1781
|
+
const arr = Array.isArray(value) ? [...value] : [];
|
|
1782
|
+
arr[idx] = e.target.value;
|
|
1783
|
+
onChange(arr);
|
|
1784
|
+
},
|
|
1785
|
+
className: "w-full rounded-lg border border-slate-200 px-3 py-2 text-sm text-slate-800 shadow-sm focus:border-indigo-500 focus:outline-none focus:ring-2 focus:ring-indigo-500/20"
|
|
1538
1786
|
}
|
|
1539
|
-
) })
|
|
1540
|
-
] })
|
|
1541
|
-
|
|
1542
|
-
|
|
1543
|
-
value: String(item?.[schemaField.key] ?? ""),
|
|
1544
|
-
onChange: (e) => {
|
|
1545
|
-
const arr = Array.isArray(value) ? [...value] : [];
|
|
1546
|
-
arr[idx] = { ...arr[idx] || {}, [schemaField.key]: e.target.value };
|
|
1547
|
-
onChange(arr);
|
|
1548
|
-
},
|
|
1549
|
-
className: "w-full rounded-lg border border-slate-200 px-3 py-2 text-sm text-slate-800 shadow-sm focus:border-indigo-500 focus:outline-none focus:ring-2 focus:ring-indigo-500/20 bg-white",
|
|
1550
|
-
children: schemaField.options?.map((opt) => /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("option", { value: opt, children: opt }, opt))
|
|
1551
|
-
}
|
|
1552
|
-
) : /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
1553
|
-
"input",
|
|
1787
|
+
) })
|
|
1788
|
+
] }),
|
|
1789
|
+
!meta.fixedLength && /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
1790
|
+
"button",
|
|
1554
1791
|
{
|
|
1555
|
-
|
|
1556
|
-
value: String(item?.[schemaField.key] ?? ""),
|
|
1557
|
-
onChange: (e) => {
|
|
1792
|
+
onClick: () => {
|
|
1558
1793
|
const arr = Array.isArray(value) ? [...value] : [];
|
|
1559
|
-
arr
|
|
1794
|
+
arr.splice(idx, 1);
|
|
1560
1795
|
onChange(arr);
|
|
1561
1796
|
},
|
|
1562
|
-
className: "
|
|
1797
|
+
className: "p-1.5 text-slate-400 hover:text-red-500 hover:bg-red-50 rounded-lg transition-colors absolute top-2 right-2 opacity-0 group-hover:opacity-100",
|
|
1798
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_lucide_react2.Trash2, { className: "w-4 h-4" })
|
|
1563
1799
|
}
|
|
1564
1800
|
)
|
|
1565
|
-
]
|
|
1566
|
-
|
|
1567
|
-
|
|
1568
|
-
|
|
1569
|
-
value: String(item),
|
|
1570
|
-
onChange: (e) => {
|
|
1571
|
-
const arr = Array.isArray(value) ? [...value] : [];
|
|
1572
|
-
arr[idx] = e.target.value;
|
|
1573
|
-
onChange(arr);
|
|
1574
|
-
},
|
|
1575
|
-
className: "w-full rounded-lg border border-slate-200 px-3 py-2 text-sm text-slate-800 shadow-sm focus:border-indigo-500 focus:outline-none focus:ring-2 focus:ring-indigo-500/20"
|
|
1576
|
-
}
|
|
1577
|
-
) })
|
|
1578
|
-
] }),
|
|
1579
|
-
!meta.fixedLength && /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
1580
|
-
"button",
|
|
1581
|
-
{
|
|
1582
|
-
onClick: () => {
|
|
1583
|
-
const arr = Array.isArray(value) ? [...value] : [];
|
|
1584
|
-
arr.splice(idx, 1);
|
|
1585
|
-
onChange(arr);
|
|
1586
|
-
},
|
|
1587
|
-
className: "p-1.5 text-slate-400 hover:text-red-500 hover:bg-red-50 rounded-lg transition-colors absolute top-2 right-2 opacity-0 group-hover:opacity-100",
|
|
1588
|
-
children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_lucide_react2.Trash2, { className: "w-4 h-4" })
|
|
1589
|
-
}
|
|
1590
|
-
)
|
|
1591
|
-
] }, idx);
|
|
1801
|
+
]
|
|
1802
|
+
},
|
|
1803
|
+
idx
|
|
1804
|
+
);
|
|
1592
1805
|
}),
|
|
1593
1806
|
!meta.fixedLength && /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(
|
|
1594
1807
|
"button",
|
|
@@ -1614,7 +1827,7 @@ function FieldEditor({
|
|
|
1614
1827
|
}
|
|
1615
1828
|
)
|
|
1616
1829
|
] }),
|
|
1617
|
-
"
|
|
1830
|
+
meta.type === "reference" && /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(SidebarReferenceSelect, { meta, value, onChange })
|
|
1618
1831
|
] }),
|
|
1619
1832
|
/* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className: "flex items-center justify-between pt-6 mt-6 border-t border-slate-100", children: [
|
|
1620
1833
|
/* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(
|
|
@@ -1689,6 +1902,10 @@ function CollectionEditor({ collection }) {
|
|
|
1689
1902
|
const [loadingEntries, setLoadingEntries] = (0, import_react5.useState)(true);
|
|
1690
1903
|
const [draggedIdx, setDraggedIdx] = (0, import_react5.useState)(null);
|
|
1691
1904
|
const [dragOverIdx, setDragOverIdx] = (0, import_react5.useState)(null);
|
|
1905
|
+
const [search, setSearch] = (0, import_react5.useState)("");
|
|
1906
|
+
const [filters, setFilters] = (0, import_react5.useState)({});
|
|
1907
|
+
const [page, setPage] = (0, import_react5.useState)(1);
|
|
1908
|
+
const itemsPerPage = 10;
|
|
1692
1909
|
const load = (0, import_react5.useCallback)(() => {
|
|
1693
1910
|
setLoadingEntries(true);
|
|
1694
1911
|
ctx.adapter.listEntries(collection.id).then((res) => {
|
|
@@ -1721,7 +1938,16 @@ function CollectionEditor({ collection }) {
|
|
|
1721
1938
|
if (!editing) return;
|
|
1722
1939
|
setSaving(true);
|
|
1723
1940
|
try {
|
|
1724
|
-
|
|
1941
|
+
const finalEditing = { ...editing };
|
|
1942
|
+
collection.fields.forEach((f) => {
|
|
1943
|
+
if (f.type === "slug" && !finalEditing[f.id]) {
|
|
1944
|
+
const sourceField = f.source || "title";
|
|
1945
|
+
let val = String(finalEditing[sourceField] || finalEditing.id || "");
|
|
1946
|
+
val = val.toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/(^-|-$)+/g, "");
|
|
1947
|
+
finalEditing[f.id] = val;
|
|
1948
|
+
}
|
|
1949
|
+
});
|
|
1950
|
+
await ctx.adapter.putEntry(collection.id, finalEditing);
|
|
1725
1951
|
ctx.notifyCollectionChanged();
|
|
1726
1952
|
setEditing(null);
|
|
1727
1953
|
load();
|
|
@@ -1774,7 +2000,7 @@ function CollectionEditor({ collection }) {
|
|
|
1774
2000
|
setDraggedIdx(null);
|
|
1775
2001
|
setDragOverIdx(null);
|
|
1776
2002
|
};
|
|
1777
|
-
const visibleFields = collection.fields.filter((f) => !["richtext", "list", "password"].includes(f.type) && f.id !== "order").slice(0, 5);
|
|
2003
|
+
const visibleFields = collection.fields.filter((f) => !["richtext", "list", "password"].includes(f.type) && f.id !== "order" && !f.hidden).slice(0, 5);
|
|
1778
2004
|
return /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className: "mx-auto max-w-5xl", children: [
|
|
1779
2005
|
/* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className: "mb-8 flex items-center justify-between", children: [
|
|
1780
2006
|
/* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { children: [
|
|
@@ -1793,12 +2019,56 @@ function CollectionEditor({ collection }) {
|
|
|
1793
2019
|
}
|
|
1794
2020
|
)
|
|
1795
2021
|
] }),
|
|
2022
|
+
!editing && (collection.searchBy?.length || collection.filterBy?.length) && /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className: "mb-6 flex flex-wrap gap-4 items-center p-4 bg-white rounded-2xl border border-slate-200 shadow-sm animate-in fade-in slide-in-from-top-2", children: [
|
|
2023
|
+
collection.searchBy?.length ? /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className: "relative flex-1 min-w-[200px]", children: [
|
|
2024
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_lucide_react2.Search, { className: "absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-slate-400 pointer-events-none" }),
|
|
2025
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
2026
|
+
"input",
|
|
2027
|
+
{
|
|
2028
|
+
type: "text",
|
|
2029
|
+
placeholder: `Search by ${collection.searchBy.join(", ")}...`,
|
|
2030
|
+
value: search,
|
|
2031
|
+
onChange: (e) => {
|
|
2032
|
+
setSearch(e.target.value);
|
|
2033
|
+
setPage(1);
|
|
2034
|
+
},
|
|
2035
|
+
className: "w-full rounded-xl border border-slate-200 bg-slate-50 py-2.5 pl-10 pr-4 text-sm focus:border-indigo-500 focus:bg-white focus:ring-4 focus:ring-indigo-500/10 outline-none transition-all"
|
|
2036
|
+
}
|
|
2037
|
+
)
|
|
2038
|
+
] }) : null,
|
|
2039
|
+
collection.filterBy?.map((f) => {
|
|
2040
|
+
const fieldDef = collection.fields.find((cf) => cf.id === f);
|
|
2041
|
+
const uniqueVals = Array.from(new Set(entries.map((e) => String(e[f] || "")))).filter(Boolean);
|
|
2042
|
+
if (!fieldDef || uniqueVals.length === 0) return null;
|
|
2043
|
+
return /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className: "min-w-[150px] relative", children: [
|
|
2044
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(
|
|
2045
|
+
"select",
|
|
2046
|
+
{
|
|
2047
|
+
value: filters[f] || "",
|
|
2048
|
+
onChange: (e) => {
|
|
2049
|
+
setFilters((prev) => ({ ...prev, [f]: e.target.value }));
|
|
2050
|
+
setPage(1);
|
|
2051
|
+
},
|
|
2052
|
+
className: "w-full rounded-xl border border-slate-200 bg-slate-50 py-2.5 px-4 pr-10 text-sm focus:border-indigo-500 focus:bg-white focus:ring-4 focus:ring-indigo-500/10 outline-none transition-all appearance-none",
|
|
2053
|
+
children: [
|
|
2054
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("option", { value: "", children: [
|
|
2055
|
+
"All ",
|
|
2056
|
+
fieldDef.label
|
|
2057
|
+
] }),
|
|
2058
|
+
uniqueVals.map((v) => /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("option", { value: v, children: v }, v))
|
|
2059
|
+
]
|
|
2060
|
+
}
|
|
2061
|
+
),
|
|
2062
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_lucide_react2.ChevronDown, { className: "absolute right-3 top-1/2 -translate-y-1/2 h-4 w-4 text-slate-400 pointer-events-none" })
|
|
2063
|
+
] }, f);
|
|
2064
|
+
})
|
|
2065
|
+
] }),
|
|
1796
2066
|
editing && /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className: "mb-8 rounded-2xl border border-indigo-100 bg-white p-6 shadow-xl shadow-indigo-100/50 animate-in fade-in slide-in-from-top-4", children: [
|
|
1797
2067
|
/* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className: "flex items-center gap-2 mb-6", children: [
|
|
1798
2068
|
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", { className: "w-8 h-8 rounded-full bg-indigo-100 flex items-center justify-center text-indigo-600", children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_lucide_react2.Pencil, { className: "w-4 h-4" }) }),
|
|
1799
2069
|
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)("h3", { className: "text-lg font-bold text-slate-900", children: "Edit Entry" })
|
|
1800
2070
|
] }),
|
|
1801
|
-
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", { className: "grid gap-5 md:grid-cols-2", children: collection.fields.filter((f) => f.id !== "order").map((f) => /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("label", { className: `block ${f.type === "richtext" ? "md:col-span-2" : ""}`, children: [
|
|
2071
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", { className: "grid gap-5 md:grid-cols-2", children: collection.fields.filter((f) => f.id !== "order" && !f.hidden).map((f) => /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("label", { className: `block ${f.type === "richtext" ? "md:col-span-2" : ""}`, children: [
|
|
1802
2072
|
/* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("span", { className: "text-xs font-bold text-slate-500 uppercase tracking-wide flex items-center justify-between mb-1.5", children: [
|
|
1803
2073
|
f.label,
|
|
1804
2074
|
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)("span", { className: "text-[10px] font-mono text-slate-300 bg-slate-50 px-1.5 py-0.5 rounded", children: f.type })
|
|
@@ -1860,7 +2130,15 @@ function CollectionEditor({ collection }) {
|
|
|
1860
2130
|
children: "Generate"
|
|
1861
2131
|
}
|
|
1862
2132
|
)
|
|
1863
|
-
] }) : f.type === "
|
|
2133
|
+
] }) : f.type === "reference" ? /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
2134
|
+
ReferenceSelect,
|
|
2135
|
+
{
|
|
2136
|
+
collectionId: f.collection,
|
|
2137
|
+
displayField: f.displayField,
|
|
2138
|
+
value: String(editing[f.id] ?? ""),
|
|
2139
|
+
onChange: (val) => setEditing({ ...editing, [f.id]: val })
|
|
2140
|
+
}
|
|
2141
|
+
) : f.type === "select" ? /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { children: [
|
|
1864
2142
|
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
1865
2143
|
"input",
|
|
1866
2144
|
{
|
|
@@ -1875,7 +2153,71 @@ function CollectionEditor({ collection }) {
|
|
|
1875
2153
|
const lab = typeof opt === "string" ? opt : opt.label;
|
|
1876
2154
|
return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("option", { value: val, children: lab }, val);
|
|
1877
2155
|
}) })
|
|
1878
|
-
] }) : f.type === "image" ? /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className: "space-y-3", children: [
|
|
2156
|
+
] }) : f.type === "image" ? f.multiple ? /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className: "space-y-3", children: [
|
|
2157
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", { className: "flex flex-wrap gap-3", children: (editing[f.id] || []).map((url, i) => /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className: "rounded-xl border border-slate-200 p-1 bg-slate-50 overflow-hidden relative group w-32 h-32", children: [
|
|
2158
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)("img", { src: url, alt: "", className: "w-full h-full object-cover rounded-lg" }),
|
|
2159
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
2160
|
+
"button",
|
|
2161
|
+
{
|
|
2162
|
+
type: "button",
|
|
2163
|
+
onClick: () => {
|
|
2164
|
+
const arr = [...editing[f.id] || []];
|
|
2165
|
+
arr.splice(i, 1);
|
|
2166
|
+
setEditing({ ...editing, [f.id]: arr });
|
|
2167
|
+
},
|
|
2168
|
+
className: "absolute top-2 right-2 bg-red-500/80 text-white rounded-full p-1 opacity-0 group-hover:opacity-100 transition-opacity hover:bg-red-500",
|
|
2169
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_lucide_react2.X, { className: "w-3 h-3" })
|
|
2170
|
+
}
|
|
2171
|
+
)
|
|
2172
|
+
] }, i)) }),
|
|
2173
|
+
(!f.max || (editing[f.id] || []).length < f.max) && /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className: "flex gap-2", children: [
|
|
2174
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
2175
|
+
"input",
|
|
2176
|
+
{
|
|
2177
|
+
type: "url",
|
|
2178
|
+
placeholder: "Add image URL and press Enter...",
|
|
2179
|
+
onKeyDown: (e) => {
|
|
2180
|
+
if (e.key === "Enter" && e.currentTarget.value) {
|
|
2181
|
+
e.preventDefault();
|
|
2182
|
+
const arr = [...editing[f.id] || [], e.currentTarget.value];
|
|
2183
|
+
setEditing({ ...editing, [f.id]: arr });
|
|
2184
|
+
e.currentTarget.value = "";
|
|
2185
|
+
}
|
|
2186
|
+
},
|
|
2187
|
+
className: "w-full rounded-xl border border-slate-200 px-4 py-2.5 text-sm text-slate-800 shadow-sm focus:border-indigo-500 focus:outline-none focus:ring-4 focus:ring-indigo-500/10 transition-all"
|
|
2188
|
+
}
|
|
2189
|
+
),
|
|
2190
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("label", { className: "flex-shrink-0 cursor-pointer rounded-xl bg-slate-100 px-4 py-2.5 text-sm font-medium text-slate-700 hover:bg-slate-200 transition-colors border border-slate-200 flex items-center justify-center", children: [
|
|
2191
|
+
"Upload",
|
|
2192
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
2193
|
+
"input",
|
|
2194
|
+
{
|
|
2195
|
+
type: "file",
|
|
2196
|
+
accept: "image/*",
|
|
2197
|
+
multiple: true,
|
|
2198
|
+
className: "hidden",
|
|
2199
|
+
onChange: (e) => {
|
|
2200
|
+
const files = Array.from(e.target.files || []);
|
|
2201
|
+
files.forEach((file) => {
|
|
2202
|
+
void handleImageFile(
|
|
2203
|
+
file,
|
|
2204
|
+
(url) => {
|
|
2205
|
+
setEditing((prev) => {
|
|
2206
|
+
if (!prev) return prev;
|
|
2207
|
+
const current = prev[f.id] || [];
|
|
2208
|
+
if (f.max && current.length >= f.max) return prev;
|
|
2209
|
+
return { ...prev, [f.id]: [...current, url] };
|
|
2210
|
+
});
|
|
2211
|
+
},
|
|
2212
|
+
ctx.uploadImage
|
|
2213
|
+
);
|
|
2214
|
+
});
|
|
2215
|
+
}
|
|
2216
|
+
}
|
|
2217
|
+
)
|
|
2218
|
+
] })
|
|
2219
|
+
] })
|
|
2220
|
+
] }) : /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className: "space-y-3", children: [
|
|
1879
2221
|
/* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className: "flex gap-2", children: [
|
|
1880
2222
|
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
1881
2223
|
"input",
|
|
@@ -2113,47 +2455,63 @@ function CollectionEditor({ collection }) {
|
|
|
2113
2455
|
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)("td", { className: "px-6 py-4 sticky right-0 bg-white border-l border-slate-100", children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", { className: "h-4 w-16 bg-slate-100 rounded animate-pulse ml-auto" }) })
|
|
2114
2456
|
] }, i))
|
|
2115
2457
|
) : /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(import_jsx_runtime5.Fragment, { children: [
|
|
2116
|
-
|
|
2117
|
-
|
|
2118
|
-
{
|
|
2119
|
-
|
|
2120
|
-
|
|
2121
|
-
|
|
2122
|
-
|
|
2123
|
-
|
|
2124
|
-
|
|
2125
|
-
|
|
2126
|
-
|
|
2127
|
-
|
|
2128
|
-
|
|
2129
|
-
|
|
2130
|
-
|
|
2131
|
-
|
|
2132
|
-
|
|
2133
|
-
|
|
2134
|
-
|
|
2135
|
-
|
|
2136
|
-
|
|
2137
|
-
|
|
2138
|
-
|
|
2139
|
-
|
|
2140
|
-
|
|
2141
|
-
|
|
2142
|
-
|
|
2143
|
-
|
|
2144
|
-
|
|
2145
|
-
|
|
2146
|
-
|
|
2147
|
-
|
|
2148
|
-
|
|
2149
|
-
|
|
2150
|
-
|
|
2151
|
-
|
|
2152
|
-
|
|
2153
|
-
|
|
2154
|
-
|
|
2155
|
-
|
|
2156
|
-
|
|
2458
|
+
(() => {
|
|
2459
|
+
let res = entries;
|
|
2460
|
+
if (search && collection.searchBy?.length) {
|
|
2461
|
+
const q = search.toLowerCase();
|
|
2462
|
+
res = res.filter((e) => collection.searchBy.some((field) => String(e[field] || "").toLowerCase().includes(q)));
|
|
2463
|
+
}
|
|
2464
|
+
if (Object.keys(filters).length > 0) {
|
|
2465
|
+
res = res.filter((e) => {
|
|
2466
|
+
for (const [k, v] of Object.entries(filters)) {
|
|
2467
|
+
if (v && String(e[k] || "") !== v) return false;
|
|
2468
|
+
}
|
|
2469
|
+
return true;
|
|
2470
|
+
});
|
|
2471
|
+
}
|
|
2472
|
+
const paginatedRes = res.slice((page - 1) * itemsPerPage, page * itemsPerPage);
|
|
2473
|
+
return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_jsx_runtime5.Fragment, { children: paginatedRes.map((e, idx) => /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(
|
|
2474
|
+
"tr",
|
|
2475
|
+
{
|
|
2476
|
+
draggable: true,
|
|
2477
|
+
onDragStart: (evt) => onDragStart(evt, idx),
|
|
2478
|
+
onDragOver: (evt) => onDragOver(evt, idx),
|
|
2479
|
+
onDrop: (evt) => onDrop(evt, idx),
|
|
2480
|
+
onDragEnd,
|
|
2481
|
+
className: `hover:bg-slate-50/50 transition-colors group cursor-grab active:cursor-grabbing ${deletingId === e.id ? "opacity-50" : ""} ${dragOverIdx === idx ? "border-t-2 border-t-indigo-500" : ""}`,
|
|
2482
|
+
children: [
|
|
2483
|
+
visibleFields.map((f) => /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("td", { className: "px-6 py-4 text-slate-700 max-w-[200px] truncate", children: f.type === "boolean" ? e[f.id] ? /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("span", { className: "inline-flex px-2 py-1 rounded bg-green-100 text-green-700 text-xs font-bold", children: "Yes" }) : /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("span", { className: "inline-flex px-2 py-1 rounded bg-slate-100 text-slate-500 text-xs font-bold", children: "No" }) : f.type === "image" && (Array.isArray(e[f.id]) ? e[f.id].length > 0 : !!e[f.id]) ? /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("img", { src: Array.isArray(e[f.id]) ? String(e[f.id][0]) : String(e[f.id]), alt: "", className: "h-8 w-8 object-cover rounded shadow-sm ring-1 ring-slate-200" }) : f.type === "image" ? /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", { className: "h-8 w-8 rounded bg-slate-100 ring-1 ring-slate-200/50 flex items-center justify-center text-slate-300", children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("svg", { className: "w-4 h-4", fill: "none", stroke: "currentColor", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("path", { strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: "2", d: "M4 16l4.586-4.586a2 2 0 012.828 0L16 16m-2-2l1.586-1.586a2 2 0 012.828 0L20 14m-6-6h.01M6 20h12a2 2 0 002-2V6a2 2 0 00-2-2H6a2 2 0 00-2 2v12a2 2 0 002 2z" }) }) }) : f.type === "reference" && e[f.id] ? /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(ReferenceTableCell, { collectionId: f.collection, entryId: String(e[f.id]), displayField: f.displayField }) : String(e[f.id] ?? "") }, f.id)),
|
|
2484
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)("td", { className: "px-6 py-4 text-right sticky right-0 bg-white border-l border-slate-100 group-hover:bg-slate-50/50 transition-colors", children: /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className: "flex items-center justify-end gap-2", children: [
|
|
2485
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", { className: "p-2 text-slate-300 cursor-grab active:cursor-grabbing", title: "Drag to reorder", children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("svg", { width: "15", height: "15", viewBox: "0 0 15 15", fill: "none", xmlns: "http://www.w3.org/2000/svg", className: "w-4 h-4", children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("path", { d: "M5.5 3C6.32843 3 7 3.67157 7 4.5C7 5.32843 6.32843 6 5.5 6C4.67157 6 4 5.32843 4 4.5C4 3.67157 4.67157 3 5.5 3ZM9.5 3C10.3284 3 11 3.67157 11 4.5C11 5.32843 10.3284 6 9.5 6C8.67157 6 8 5.32843 8 4.5C8 3.67157 8.67157 3 9.5 3ZM5.5 7.5C6.32843 7.5 7 8.17157 7 9C7 9.82843 6.32843 10.5 5.5 10.5C4.67157 10.5 4 9.82843 4 9C4 8.17157 4.67157 7.5 5.5 7.5ZM9.5 7.5C10.3284 7.5 11 8.17157 11 9C11 9.82843 10.3284 10.5 9.5 10.5C8.67157 10.5 8 9.82843 8 9C8 8.17157 8.67157 7.5 9.5 7.5ZM5.5 12C6.32843 12 7 12.6716 7 13.5C7 14.3284 6.32843 15 5.5 15C4.67157 15 4 14.3284 4 13.5C4 12.6716 4.67157 12 5.5 12ZM9.5 12C10.3284 12 11 12.6716 11 13.5C11 14.3284 10.3284 15 9.5 15C8.67157 15 8 14.3284 8 13.5C8 12.6716 8.67157 12 9.5 12Z", fill: "currentColor", fillRule: "evenodd", clipRule: "evenodd" }) }) }),
|
|
2486
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
2487
|
+
"button",
|
|
2488
|
+
{
|
|
2489
|
+
onClick: () => setEditing(e),
|
|
2490
|
+
className: "p-2 rounded-lg text-slate-400 hover:text-indigo-600 hover:bg-indigo-50 transition-colors",
|
|
2491
|
+
title: "Edit",
|
|
2492
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_lucide_react2.Pencil, { className: "h-4 w-4" })
|
|
2493
|
+
}
|
|
2494
|
+
),
|
|
2495
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
2496
|
+
"button",
|
|
2497
|
+
{
|
|
2498
|
+
onClick: () => remove(e.id),
|
|
2499
|
+
disabled: deletingId === e.id,
|
|
2500
|
+
className: "p-2 rounded-lg text-slate-400 hover:text-red-600 hover:bg-red-50 transition-colors disabled:opacity-50",
|
|
2501
|
+
title: "Delete",
|
|
2502
|
+
children: deletingId === e.id ? /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("svg", { className: "animate-spin h-4 w-4", xmlns: "http://www.w3.org/2000/svg", fill: "none", viewBox: "0 0 24 24", children: [
|
|
2503
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)("circle", { className: "opacity-25", cx: "12", cy: "12", r: "10", stroke: "currentColor", strokeWidth: "4" }),
|
|
2504
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)("path", { className: "opacity-75", fill: "currentColor", d: "M4 12a8 8 0 018-8v8H4z" })
|
|
2505
|
+
] }) : /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_lucide_react2.Trash2, { className: "h-4 w-4" })
|
|
2506
|
+
}
|
|
2507
|
+
)
|
|
2508
|
+
] }) })
|
|
2509
|
+
]
|
|
2510
|
+
},
|
|
2511
|
+
e.id
|
|
2512
|
+
)) });
|
|
2513
|
+
})(),
|
|
2514
|
+
entries.length === 0 && !search && Object.values(filters).every((v) => !v) && /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("tr", { children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
2157
2515
|
"td",
|
|
2158
2516
|
{
|
|
2159
2517
|
colSpan: visibleFields.length + 1,
|
|
@@ -2165,7 +2523,68 @@ function CollectionEditor({ collection }) {
|
|
|
2165
2523
|
}
|
|
2166
2524
|
) })
|
|
2167
2525
|
] }) })
|
|
2168
|
-
] }) })
|
|
2526
|
+
] }) }),
|
|
2527
|
+
!loadingEntries && entries.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className: "flex items-center justify-between text-sm text-slate-500 mt-4 px-2", children: [
|
|
2528
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)("span", { children: (() => {
|
|
2529
|
+
let res = entries;
|
|
2530
|
+
if (search && collection.searchBy?.length) {
|
|
2531
|
+
const q = search.toLowerCase();
|
|
2532
|
+
res = res.filter((e) => collection.searchBy.some((field) => String(e[field] || "").toLowerCase().includes(q)));
|
|
2533
|
+
}
|
|
2534
|
+
if (Object.keys(filters).length > 0) {
|
|
2535
|
+
res = res.filter((e) => {
|
|
2536
|
+
for (const [k, v] of Object.entries(filters)) {
|
|
2537
|
+
if (v && String(e[k] || "") !== v) return false;
|
|
2538
|
+
}
|
|
2539
|
+
return true;
|
|
2540
|
+
});
|
|
2541
|
+
}
|
|
2542
|
+
return `${res.length} item${res.length !== 1 ? "s" : ""}`;
|
|
2543
|
+
})() }),
|
|
2544
|
+
(() => {
|
|
2545
|
+
let res = entries;
|
|
2546
|
+
if (search && collection.searchBy?.length) {
|
|
2547
|
+
const q = search.toLowerCase();
|
|
2548
|
+
res = res.filter((e) => collection.searchBy.some((field) => String(e[field] || "").toLowerCase().includes(q)));
|
|
2549
|
+
}
|
|
2550
|
+
if (Object.keys(filters).length > 0) {
|
|
2551
|
+
res = res.filter((e) => {
|
|
2552
|
+
for (const [k, v] of Object.entries(filters)) {
|
|
2553
|
+
if (v && String(e[k] || "") !== v) return false;
|
|
2554
|
+
}
|
|
2555
|
+
return true;
|
|
2556
|
+
});
|
|
2557
|
+
}
|
|
2558
|
+
const totalPages = Math.max(1, Math.ceil(res.length / itemsPerPage));
|
|
2559
|
+
if (totalPages <= 1) return null;
|
|
2560
|
+
return /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className: "flex items-center gap-2", children: [
|
|
2561
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
2562
|
+
"button",
|
|
2563
|
+
{
|
|
2564
|
+
onClick: () => setPage((p) => Math.max(1, p - 1)),
|
|
2565
|
+
disabled: page === 1,
|
|
2566
|
+
className: "p-2 rounded-lg hover:bg-slate-100 disabled:opacity-30 transition-colors",
|
|
2567
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_lucide_react2.ChevronLeft, { className: "h-4 w-4" })
|
|
2568
|
+
}
|
|
2569
|
+
),
|
|
2570
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("span", { className: "font-medium text-slate-700", children: [
|
|
2571
|
+
"Page ",
|
|
2572
|
+
page,
|
|
2573
|
+
" of ",
|
|
2574
|
+
totalPages
|
|
2575
|
+
] }),
|
|
2576
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
2577
|
+
"button",
|
|
2578
|
+
{
|
|
2579
|
+
onClick: () => setPage((p) => Math.min(totalPages, p + 1)),
|
|
2580
|
+
disabled: page === totalPages,
|
|
2581
|
+
className: "p-2 rounded-lg hover:bg-slate-100 disabled:opacity-30 transition-colors",
|
|
2582
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_lucide_react2.ChevronRight, { className: "h-4 w-4" })
|
|
2583
|
+
}
|
|
2584
|
+
)
|
|
2585
|
+
] });
|
|
2586
|
+
})()
|
|
2587
|
+
] })
|
|
2169
2588
|
] });
|
|
2170
2589
|
}
|
|
2171
2590
|
var PAGE_SIZE = 10;
|
|
@@ -2707,6 +3126,50 @@ function PasswordField({ value, onChange }) {
|
|
|
2707
3126
|
)
|
|
2708
3127
|
] });
|
|
2709
3128
|
}
|
|
3129
|
+
function ReferenceSelect({ collectionId, displayField = "id", value, onChange }) {
|
|
3130
|
+
const ctx = useCmsContext();
|
|
3131
|
+
const [options, setOptions] = (0, import_react5.useState)([]);
|
|
3132
|
+
const [loading, setLoading] = (0, import_react5.useState)(true);
|
|
3133
|
+
(0, import_react5.useEffect)(() => {
|
|
3134
|
+
if (!collectionId) {
|
|
3135
|
+
setLoading(false);
|
|
3136
|
+
return;
|
|
3137
|
+
}
|
|
3138
|
+
setLoading(true);
|
|
3139
|
+
ctx.adapter.listEntries(collectionId).then((res) => {
|
|
3140
|
+
setOptions(res.map((r) => ({ id: r.id, label: String(r[displayField] || r.id) })));
|
|
3141
|
+
setLoading(false);
|
|
3142
|
+
}).catch(() => setLoading(false));
|
|
3143
|
+
}, [collectionId, displayField, ctx.adapter]);
|
|
3144
|
+
return /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className: "relative", children: [
|
|
3145
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(
|
|
3146
|
+
"select",
|
|
3147
|
+
{
|
|
3148
|
+
value,
|
|
3149
|
+
onChange: (e) => onChange(e.target.value),
|
|
3150
|
+
className: "w-full rounded-xl border border-slate-200 px-4 py-2.5 text-sm shadow-sm focus:border-indigo-500 focus:ring-4 focus:ring-indigo-500/10 transition-all bg-white appearance-none pr-10",
|
|
3151
|
+
children: [
|
|
3152
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)("option", { value: "", children: loading ? "Loading..." : "Select..." }),
|
|
3153
|
+
options.map((o) => /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("option", { value: o.id, children: o.label }, o.id))
|
|
3154
|
+
]
|
|
3155
|
+
}
|
|
3156
|
+
),
|
|
3157
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_lucide_react2.ChevronDown, { className: "absolute right-3 top-1/2 -translate-y-1/2 h-4 w-4 text-slate-400 pointer-events-none" })
|
|
3158
|
+
] });
|
|
3159
|
+
}
|
|
3160
|
+
function ReferenceTableCell({ collectionId, entryId, displayField = "id" }) {
|
|
3161
|
+
const ctx = useCmsContext();
|
|
3162
|
+
const [label, setLabel] = (0, import_react5.useState)(entryId);
|
|
3163
|
+
(0, import_react5.useEffect)(() => {
|
|
3164
|
+
if (!collectionId || !entryId) return;
|
|
3165
|
+
ctx.adapter.listEntries(collectionId).then((res) => {
|
|
3166
|
+
const match = res.find((r) => r.id === entryId);
|
|
3167
|
+
if (match) setLabel(String(match[displayField] || match.id));
|
|
3168
|
+
}).catch(() => {
|
|
3169
|
+
});
|
|
3170
|
+
}, [collectionId, entryId, displayField, ctx.adapter]);
|
|
3171
|
+
return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("span", { children: label });
|
|
3172
|
+
}
|
|
2710
3173
|
|
|
2711
3174
|
// src/admin/AdminLogin.tsx
|
|
2712
3175
|
var import_react6 = require("react");
|
|
@@ -2972,6 +3435,7 @@ async function sendEmailNotification(content, apiUrl) {
|
|
|
2972
3435
|
EditableImage,
|
|
2973
3436
|
EditableLink,
|
|
2974
3437
|
EditableList,
|
|
3438
|
+
EditableReference,
|
|
2975
3439
|
EditableText,
|
|
2976
3440
|
SubscriptionPage,
|
|
2977
3441
|
SubscriptionProvider,
|