admin-lib-cms 1.2.3 → 1.2.4
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/index.d.mts +3 -1
- package/dist/index.d.ts +3 -1
- package/dist/index.js +81 -66
- package/dist/index.mjs +81 -66
- package/dist/types.d.mts +2 -0
- package/dist/types.d.ts +2 -0
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -95,8 +95,10 @@ interface EditableListProps<T = any> extends BaseProps {
|
|
|
95
95
|
className?: string;
|
|
96
96
|
listClassName?: string;
|
|
97
97
|
search?: boolean;
|
|
98
|
+
reorderable?: boolean;
|
|
99
|
+
sortable?: boolean;
|
|
98
100
|
}
|
|
99
|
-
declare function EditableList<T = any>({ id, label, section, pageId, initialItems, renderItem, renderList, itemSchema, fixedLength, className, listClassName, search, }: EditableListProps<T>): react.JSX.Element;
|
|
101
|
+
declare function EditableList<T = any>({ id, label, section, pageId, initialItems, renderItem, renderList, itemSchema, fixedLength, className, listClassName, search, reorderable, sortable, }: EditableListProps<T>): react.JSX.Element;
|
|
100
102
|
interface EditableReferenceProps extends BaseProps {
|
|
101
103
|
collection: string;
|
|
102
104
|
max?: number;
|
package/dist/index.d.ts
CHANGED
|
@@ -95,8 +95,10 @@ interface EditableListProps<T = any> extends BaseProps {
|
|
|
95
95
|
className?: string;
|
|
96
96
|
listClassName?: string;
|
|
97
97
|
search?: boolean;
|
|
98
|
+
reorderable?: boolean;
|
|
99
|
+
sortable?: boolean;
|
|
98
100
|
}
|
|
99
|
-
declare function EditableList<T = any>({ id, label, section, pageId, initialItems, renderItem, renderList, itemSchema, fixedLength, className, listClassName, search, }: EditableListProps<T>): react.JSX.Element;
|
|
101
|
+
declare function EditableList<T = any>({ id, label, section, pageId, initialItems, renderItem, renderList, itemSchema, fixedLength, className, listClassName, search, reorderable, sortable, }: EditableListProps<T>): react.JSX.Element;
|
|
100
102
|
interface EditableReferenceProps extends BaseProps {
|
|
101
103
|
collection: string;
|
|
102
104
|
max?: number;
|
package/dist/index.js
CHANGED
|
@@ -452,13 +452,13 @@ function useSubmit(formId) {
|
|
|
452
452
|
// src/editable.tsx
|
|
453
453
|
var import_react4 = require("react");
|
|
454
454
|
var import_jsx_runtime4 = require("react/jsx-runtime");
|
|
455
|
-
function useRegister(id, type, label, section, pageId, defaultValue, itemSchema, fixedLength, search, collection, max, displayField) {
|
|
455
|
+
function useRegister(id, type, label, section, pageId, defaultValue, itemSchema, fixedLength, search, collection, max, displayField, reorderable, sortable) {
|
|
456
456
|
const ctx = useCmsOptional();
|
|
457
457
|
(0, import_react4.useEffect)(() => {
|
|
458
458
|
if (!ctx) return;
|
|
459
|
-
ctx.registerEditable({ id, type, label, section, pageId, defaultValue, itemSchema, fixedLength, search, collection, max, displayField });
|
|
459
|
+
ctx.registerEditable({ id, type, label, section, pageId, defaultValue, itemSchema, fixedLength, search, collection, max, displayField, reorderable, sortable });
|
|
460
460
|
return () => ctx.unregisterEditable(id);
|
|
461
|
-
}, [ctx?.registerEditable, ctx?.unregisterEditable, id, type, label, section, pageId, defaultValue, itemSchema, fixedLength, search, collection, max, displayField]);
|
|
461
|
+
}, [ctx?.registerEditable, ctx?.unregisterEditable, id, type, label, section, pageId, defaultValue, itemSchema, fixedLength, search, collection, max, displayField, reorderable, sortable]);
|
|
462
462
|
return ctx;
|
|
463
463
|
}
|
|
464
464
|
function editableClasses(active, selected) {
|
|
@@ -653,9 +653,11 @@ function EditableList({
|
|
|
653
653
|
fixedLength,
|
|
654
654
|
className,
|
|
655
655
|
listClassName,
|
|
656
|
-
search
|
|
656
|
+
search,
|
|
657
|
+
reorderable,
|
|
658
|
+
sortable
|
|
657
659
|
}) {
|
|
658
|
-
const ctx = useRegister(id, "list", label, section, pageId, initialItems, itemSchema, fixedLength, search);
|
|
660
|
+
const ctx = useRegister(id, "list", label, section, pageId, initialItems, itemSchema, fixedLength, search, void 0, void 0, void 0, reorderable, sortable);
|
|
659
661
|
const rawValue = ctx && Object.prototype.hasOwnProperty.call(ctx.overrides, id) ? ctx.overrides[id] : initialItems;
|
|
660
662
|
const value = Array.isArray(rawValue) ? rawValue : initialItems;
|
|
661
663
|
const active = !!ctx?.editMode;
|
|
@@ -1563,24 +1565,25 @@ function FieldEditor({
|
|
|
1563
1565
|
if (!title.includes(searchQuery.toLowerCase())) return null;
|
|
1564
1566
|
}
|
|
1565
1567
|
const isExpanded = expandedItems[idx] ?? false;
|
|
1568
|
+
const isReorderable = !!(meta.reorderable || meta.sortable);
|
|
1566
1569
|
return /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(
|
|
1567
1570
|
"div",
|
|
1568
1571
|
{
|
|
1569
|
-
draggable:
|
|
1570
|
-
onDragStart: (e) => {
|
|
1572
|
+
draggable: isReorderable,
|
|
1573
|
+
onDragStart: isReorderable ? (e) => {
|
|
1571
1574
|
setListDragIdx(idx);
|
|
1572
1575
|
e.dataTransfer.effectAllowed = "move";
|
|
1573
|
-
},
|
|
1574
|
-
onDragOver: (e) => {
|
|
1576
|
+
} : void 0,
|
|
1577
|
+
onDragOver: isReorderable ? (e) => {
|
|
1575
1578
|
e.preventDefault();
|
|
1576
1579
|
e.dataTransfer.dropEffect = "move";
|
|
1577
1580
|
setListDragOverIdx(idx);
|
|
1578
|
-
},
|
|
1579
|
-
onDragEnd: () => {
|
|
1581
|
+
} : void 0,
|
|
1582
|
+
onDragEnd: isReorderable ? () => {
|
|
1580
1583
|
setListDragIdx(null);
|
|
1581
1584
|
setListDragOverIdx(null);
|
|
1582
|
-
},
|
|
1583
|
-
onDrop: (e) => {
|
|
1585
|
+
} : void 0,
|
|
1586
|
+
onDrop: isReorderable ? (e) => {
|
|
1584
1587
|
e.preventDefault();
|
|
1585
1588
|
if (listDragIdx === null || listDragIdx === idx) {
|
|
1586
1589
|
setListDragOverIdx(null);
|
|
@@ -1592,65 +1595,66 @@ function FieldEditor({
|
|
|
1592
1595
|
onChange(arr);
|
|
1593
1596
|
setListDragIdx(null);
|
|
1594
1597
|
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" : ""}`,
|
|
1598
|
+
} : void 0,
|
|
1599
|
+
className: `bg-slate-50 p-3 rounded-xl border transition-all relative group ${isReorderable && listDragOverIdx === idx ? "border-indigo-500 border-2 bg-indigo-50/40" : "border-slate-200 hover:border-slate-300"} ${isReorderable && listDragIdx === idx ? "opacity-40" : ""}`,
|
|
1597
1600
|
children: [
|
|
1598
|
-
/* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(
|
|
1599
|
-
"div",
|
|
1600
|
-
{
|
|
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
|
-
]
|
|
1644
|
-
}
|
|
1645
|
-
),
|
|
1646
1601
|
/* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className: "space-y-3 w-full min-w-0", children: [
|
|
1647
1602
|
/* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(
|
|
1648
1603
|
"div",
|
|
1649
1604
|
{
|
|
1650
|
-
className: "flex items-center justify-between cursor-pointer py-1 select-none",
|
|
1605
|
+
className: "flex items-center justify-between cursor-pointer py-1 select-none gap-2",
|
|
1651
1606
|
onClick: () => setExpandedItems((prev) => ({ ...prev, [idx]: !isExpanded })),
|
|
1652
1607
|
children: [
|
|
1653
|
-
/* @__PURE__ */ (0, import_jsx_runtime5.
|
|
1608
|
+
isReorderable && /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(
|
|
1609
|
+
"div",
|
|
1610
|
+
{
|
|
1611
|
+
className: "flex items-center gap-1 text-slate-400 select-none shrink-0",
|
|
1612
|
+
title: "Drag or use arrows to reorder",
|
|
1613
|
+
onClick: (e) => e.stopPropagation(),
|
|
1614
|
+
children: [
|
|
1615
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_lucide_react2.GripVertical, { className: "w-4 h-4 cursor-grab active:cursor-grabbing hover:text-indigo-600" }),
|
|
1616
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className: "flex items-center gap-0.5", children: [
|
|
1617
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
1618
|
+
"button",
|
|
1619
|
+
{
|
|
1620
|
+
type: "button",
|
|
1621
|
+
disabled: idx === 0,
|
|
1622
|
+
onClick: (e) => {
|
|
1623
|
+
e.stopPropagation();
|
|
1624
|
+
if (idx === 0) return;
|
|
1625
|
+
const arr = Array.isArray(value) ? [...value] : [];
|
|
1626
|
+
const [moved] = arr.splice(idx, 1);
|
|
1627
|
+
arr.splice(idx - 1, 0, moved);
|
|
1628
|
+
onChange(arr);
|
|
1629
|
+
},
|
|
1630
|
+
className: "p-0.5 hover:text-indigo-600 disabled:opacity-20 transition-colors",
|
|
1631
|
+
title: "Move Up",
|
|
1632
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_lucide_react2.ChevronUp, { className: "w-3.5 h-3.5" })
|
|
1633
|
+
}
|
|
1634
|
+
),
|
|
1635
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
1636
|
+
"button",
|
|
1637
|
+
{
|
|
1638
|
+
type: "button",
|
|
1639
|
+
disabled: idx === (Array.isArray(value) ? value.length - 1 : 0),
|
|
1640
|
+
onClick: (e) => {
|
|
1641
|
+
e.stopPropagation();
|
|
1642
|
+
const arr = Array.isArray(value) ? [...value] : [];
|
|
1643
|
+
if (idx >= arr.length - 1) return;
|
|
1644
|
+
const [moved] = arr.splice(idx, 1);
|
|
1645
|
+
arr.splice(idx + 1, 0, moved);
|
|
1646
|
+
onChange(arr);
|
|
1647
|
+
},
|
|
1648
|
+
className: "p-0.5 hover:text-indigo-600 disabled:opacity-20 transition-colors",
|
|
1649
|
+
title: "Move Down",
|
|
1650
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_lucide_react2.ChevronDown, { className: "w-3.5 h-3.5" })
|
|
1651
|
+
}
|
|
1652
|
+
)
|
|
1653
|
+
] })
|
|
1654
|
+
]
|
|
1655
|
+
}
|
|
1656
|
+
),
|
|
1657
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", { className: "font-semibold text-slate-700 text-sm flex-1 truncate pr-4", children: meta.itemSchema ? item?.title || item?.name || `Item ${idx + 1}` : String(item) }),
|
|
1654
1658
|
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
1659
|
]
|
|
1656
1660
|
}
|
|
@@ -1810,9 +1814,20 @@ function FieldEditor({
|
|
|
1810
1814
|
const arr = Array.isArray(value) ? [...value] : [];
|
|
1811
1815
|
if (meta.itemSchema) {
|
|
1812
1816
|
const newItem = {};
|
|
1817
|
+
const now = /* @__PURE__ */ new Date();
|
|
1818
|
+
const month = now.toLocaleDateString("en-US", { month: "short" }).toUpperCase();
|
|
1819
|
+
const day = String(now.getDate()).padStart(2, "0");
|
|
1820
|
+
const year = now.getFullYear();
|
|
1821
|
+
const autoDate = `${month} ${day}, ${year}`;
|
|
1813
1822
|
meta.itemSchema.forEach((s) => {
|
|
1814
|
-
|
|
1823
|
+
if (s.key === "publishedAt" || s.key === "date") {
|
|
1824
|
+
newItem[s.key] = autoDate;
|
|
1825
|
+
} else {
|
|
1826
|
+
newItem[s.key] = "";
|
|
1827
|
+
}
|
|
1815
1828
|
});
|
|
1829
|
+
newItem.publishedAt = autoDate;
|
|
1830
|
+
newItem.createdAt = now.toISOString();
|
|
1816
1831
|
arr.push(newItem);
|
|
1817
1832
|
} else {
|
|
1818
1833
|
arr.push("New Item");
|
package/dist/index.mjs
CHANGED
|
@@ -423,13 +423,13 @@ function useSubmit(formId) {
|
|
|
423
423
|
// src/editable.tsx
|
|
424
424
|
import { createElement, useEffect as useEffect3, useState as useState4, Fragment as Fragment2 } from "react";
|
|
425
425
|
import { jsx as jsx4, jsxs as jsxs3 } from "react/jsx-runtime";
|
|
426
|
-
function useRegister(id, type, label, section, pageId, defaultValue, itemSchema, fixedLength, search, collection, max, displayField) {
|
|
426
|
+
function useRegister(id, type, label, section, pageId, defaultValue, itemSchema, fixedLength, search, collection, max, displayField, reorderable, sortable) {
|
|
427
427
|
const ctx = useCmsOptional();
|
|
428
428
|
useEffect3(() => {
|
|
429
429
|
if (!ctx) return;
|
|
430
|
-
ctx.registerEditable({ id, type, label, section, pageId, defaultValue, itemSchema, fixedLength, search, collection, max, displayField });
|
|
430
|
+
ctx.registerEditable({ id, type, label, section, pageId, defaultValue, itemSchema, fixedLength, search, collection, max, displayField, reorderable, sortable });
|
|
431
431
|
return () => ctx.unregisterEditable(id);
|
|
432
|
-
}, [ctx?.registerEditable, ctx?.unregisterEditable, id, type, label, section, pageId, defaultValue, itemSchema, fixedLength, search, collection, max, displayField]);
|
|
432
|
+
}, [ctx?.registerEditable, ctx?.unregisterEditable, id, type, label, section, pageId, defaultValue, itemSchema, fixedLength, search, collection, max, displayField, reorderable, sortable]);
|
|
433
433
|
return ctx;
|
|
434
434
|
}
|
|
435
435
|
function editableClasses(active, selected) {
|
|
@@ -624,9 +624,11 @@ function EditableList({
|
|
|
624
624
|
fixedLength,
|
|
625
625
|
className,
|
|
626
626
|
listClassName,
|
|
627
|
-
search
|
|
627
|
+
search,
|
|
628
|
+
reorderable,
|
|
629
|
+
sortable
|
|
628
630
|
}) {
|
|
629
|
-
const ctx = useRegister(id, "list", label, section, pageId, initialItems, itemSchema, fixedLength, search);
|
|
631
|
+
const ctx = useRegister(id, "list", label, section, pageId, initialItems, itemSchema, fixedLength, search, void 0, void 0, void 0, reorderable, sortable);
|
|
630
632
|
const rawValue = ctx && Object.prototype.hasOwnProperty.call(ctx.overrides, id) ? ctx.overrides[id] : initialItems;
|
|
631
633
|
const value = Array.isArray(rawValue) ? rawValue : initialItems;
|
|
632
634
|
const active = !!ctx?.editMode;
|
|
@@ -1563,24 +1565,25 @@ function FieldEditor({
|
|
|
1563
1565
|
if (!title.includes(searchQuery.toLowerCase())) return null;
|
|
1564
1566
|
}
|
|
1565
1567
|
const isExpanded = expandedItems[idx] ?? false;
|
|
1568
|
+
const isReorderable = !!(meta.reorderable || meta.sortable);
|
|
1566
1569
|
return /* @__PURE__ */ jsxs4(
|
|
1567
1570
|
"div",
|
|
1568
1571
|
{
|
|
1569
|
-
draggable:
|
|
1570
|
-
onDragStart: (e) => {
|
|
1572
|
+
draggable: isReorderable,
|
|
1573
|
+
onDragStart: isReorderable ? (e) => {
|
|
1571
1574
|
setListDragIdx(idx);
|
|
1572
1575
|
e.dataTransfer.effectAllowed = "move";
|
|
1573
|
-
},
|
|
1574
|
-
onDragOver: (e) => {
|
|
1576
|
+
} : void 0,
|
|
1577
|
+
onDragOver: isReorderable ? (e) => {
|
|
1575
1578
|
e.preventDefault();
|
|
1576
1579
|
e.dataTransfer.dropEffect = "move";
|
|
1577
1580
|
setListDragOverIdx(idx);
|
|
1578
|
-
},
|
|
1579
|
-
onDragEnd: () => {
|
|
1581
|
+
} : void 0,
|
|
1582
|
+
onDragEnd: isReorderable ? () => {
|
|
1580
1583
|
setListDragIdx(null);
|
|
1581
1584
|
setListDragOverIdx(null);
|
|
1582
|
-
},
|
|
1583
|
-
onDrop: (e) => {
|
|
1585
|
+
} : void 0,
|
|
1586
|
+
onDrop: isReorderable ? (e) => {
|
|
1584
1587
|
e.preventDefault();
|
|
1585
1588
|
if (listDragIdx === null || listDragIdx === idx) {
|
|
1586
1589
|
setListDragOverIdx(null);
|
|
@@ -1592,65 +1595,66 @@ function FieldEditor({
|
|
|
1592
1595
|
onChange(arr);
|
|
1593
1596
|
setListDragIdx(null);
|
|
1594
1597
|
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" : ""}`,
|
|
1598
|
+
} : void 0,
|
|
1599
|
+
className: `bg-slate-50 p-3 rounded-xl border transition-all relative group ${isReorderable && listDragOverIdx === idx ? "border-indigo-500 border-2 bg-indigo-50/40" : "border-slate-200 hover:border-slate-300"} ${isReorderable && listDragIdx === idx ? "opacity-40" : ""}`,
|
|
1597
1600
|
children: [
|
|
1598
|
-
/* @__PURE__ */ jsxs4(
|
|
1599
|
-
"div",
|
|
1600
|
-
{
|
|
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__ */ jsx5(GripVertical, { className: "w-4 h-4 cursor-grab active:cursor-grabbing hover:text-indigo-600" }),
|
|
1605
|
-
/* @__PURE__ */ jsxs4("div", { className: "flex items-center gap-1", children: [
|
|
1606
|
-
/* @__PURE__ */ jsx5(
|
|
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__ */ jsx5(ChevronUp, { className: "w-3.5 h-3.5" })
|
|
1622
|
-
}
|
|
1623
|
-
),
|
|
1624
|
-
/* @__PURE__ */ jsx5(
|
|
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__ */ jsx5(ChevronDown, { className: "w-3.5 h-3.5" })
|
|
1640
|
-
}
|
|
1641
|
-
)
|
|
1642
|
-
] })
|
|
1643
|
-
]
|
|
1644
|
-
}
|
|
1645
|
-
),
|
|
1646
1601
|
/* @__PURE__ */ jsxs4("div", { className: "space-y-3 w-full min-w-0", children: [
|
|
1647
1602
|
/* @__PURE__ */ jsxs4(
|
|
1648
1603
|
"div",
|
|
1649
1604
|
{
|
|
1650
|
-
className: "flex items-center justify-between cursor-pointer py-1 select-none",
|
|
1605
|
+
className: "flex items-center justify-between cursor-pointer py-1 select-none gap-2",
|
|
1651
1606
|
onClick: () => setExpandedItems((prev) => ({ ...prev, [idx]: !isExpanded })),
|
|
1652
1607
|
children: [
|
|
1653
|
-
/* @__PURE__ */
|
|
1608
|
+
isReorderable && /* @__PURE__ */ jsxs4(
|
|
1609
|
+
"div",
|
|
1610
|
+
{
|
|
1611
|
+
className: "flex items-center gap-1 text-slate-400 select-none shrink-0",
|
|
1612
|
+
title: "Drag or use arrows to reorder",
|
|
1613
|
+
onClick: (e) => e.stopPropagation(),
|
|
1614
|
+
children: [
|
|
1615
|
+
/* @__PURE__ */ jsx5(GripVertical, { className: "w-4 h-4 cursor-grab active:cursor-grabbing hover:text-indigo-600" }),
|
|
1616
|
+
/* @__PURE__ */ jsxs4("div", { className: "flex items-center gap-0.5", children: [
|
|
1617
|
+
/* @__PURE__ */ jsx5(
|
|
1618
|
+
"button",
|
|
1619
|
+
{
|
|
1620
|
+
type: "button",
|
|
1621
|
+
disabled: idx === 0,
|
|
1622
|
+
onClick: (e) => {
|
|
1623
|
+
e.stopPropagation();
|
|
1624
|
+
if (idx === 0) return;
|
|
1625
|
+
const arr = Array.isArray(value) ? [...value] : [];
|
|
1626
|
+
const [moved] = arr.splice(idx, 1);
|
|
1627
|
+
arr.splice(idx - 1, 0, moved);
|
|
1628
|
+
onChange(arr);
|
|
1629
|
+
},
|
|
1630
|
+
className: "p-0.5 hover:text-indigo-600 disabled:opacity-20 transition-colors",
|
|
1631
|
+
title: "Move Up",
|
|
1632
|
+
children: /* @__PURE__ */ jsx5(ChevronUp, { className: "w-3.5 h-3.5" })
|
|
1633
|
+
}
|
|
1634
|
+
),
|
|
1635
|
+
/* @__PURE__ */ jsx5(
|
|
1636
|
+
"button",
|
|
1637
|
+
{
|
|
1638
|
+
type: "button",
|
|
1639
|
+
disabled: idx === (Array.isArray(value) ? value.length - 1 : 0),
|
|
1640
|
+
onClick: (e) => {
|
|
1641
|
+
e.stopPropagation();
|
|
1642
|
+
const arr = Array.isArray(value) ? [...value] : [];
|
|
1643
|
+
if (idx >= arr.length - 1) return;
|
|
1644
|
+
const [moved] = arr.splice(idx, 1);
|
|
1645
|
+
arr.splice(idx + 1, 0, moved);
|
|
1646
|
+
onChange(arr);
|
|
1647
|
+
},
|
|
1648
|
+
className: "p-0.5 hover:text-indigo-600 disabled:opacity-20 transition-colors",
|
|
1649
|
+
title: "Move Down",
|
|
1650
|
+
children: /* @__PURE__ */ jsx5(ChevronDown, { className: "w-3.5 h-3.5" })
|
|
1651
|
+
}
|
|
1652
|
+
)
|
|
1653
|
+
] })
|
|
1654
|
+
]
|
|
1655
|
+
}
|
|
1656
|
+
),
|
|
1657
|
+
/* @__PURE__ */ jsx5("div", { className: "font-semibold text-slate-700 text-sm flex-1 truncate pr-4", children: meta.itemSchema ? item?.title || item?.name || `Item ${idx + 1}` : String(item) }),
|
|
1654
1658
|
isExpanded ? /* @__PURE__ */ jsx5(ChevronUp, { className: "w-4 h-4 text-slate-500 shrink-0" }) : /* @__PURE__ */ jsx5(ChevronDown, { className: "w-4 h-4 text-slate-500 shrink-0" })
|
|
1655
1659
|
]
|
|
1656
1660
|
}
|
|
@@ -1810,9 +1814,20 @@ function FieldEditor({
|
|
|
1810
1814
|
const arr = Array.isArray(value) ? [...value] : [];
|
|
1811
1815
|
if (meta.itemSchema) {
|
|
1812
1816
|
const newItem = {};
|
|
1817
|
+
const now = /* @__PURE__ */ new Date();
|
|
1818
|
+
const month = now.toLocaleDateString("en-US", { month: "short" }).toUpperCase();
|
|
1819
|
+
const day = String(now.getDate()).padStart(2, "0");
|
|
1820
|
+
const year = now.getFullYear();
|
|
1821
|
+
const autoDate = `${month} ${day}, ${year}`;
|
|
1813
1822
|
meta.itemSchema.forEach((s) => {
|
|
1814
|
-
|
|
1823
|
+
if (s.key === "publishedAt" || s.key === "date") {
|
|
1824
|
+
newItem[s.key] = autoDate;
|
|
1825
|
+
} else {
|
|
1826
|
+
newItem[s.key] = "";
|
|
1827
|
+
}
|
|
1815
1828
|
});
|
|
1829
|
+
newItem.publishedAt = autoDate;
|
|
1830
|
+
newItem.createdAt = now.toISOString();
|
|
1816
1831
|
arr.push(newItem);
|
|
1817
1832
|
} else {
|
|
1818
1833
|
arr.push("New Item");
|
package/dist/types.d.mts
CHANGED
package/dist/types.d.ts
CHANGED