@kyro-cms/admin 0.9.7 → 0.9.9
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.cjs +106 -13
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +107 -14
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
- package/src/components/GraphQLPlayground.tsx +315 -38
- package/src/components/blocks/BlockEditModal.tsx +12 -0
- package/src/components/blocks/ChildBlocksTree.tsx +3 -2
- package/src/components/fields/BlocksField.tsx +65 -13
- package/src/components/fields/extensions/blockComponents.tsx +6 -0
- package/src/components/fields/extensions/blocksStore.ts +1 -0
- package/src/kyro-cms.d.ts +1 -0
package/dist/index.cjs
CHANGED
|
@@ -5888,6 +5888,7 @@ function createNewBlock(type) {
|
|
|
5888
5888
|
return {
|
|
5889
5889
|
id: Math.random().toString(36).substr(2, 9),
|
|
5890
5890
|
type,
|
|
5891
|
+
name: "",
|
|
5891
5892
|
data,
|
|
5892
5893
|
options,
|
|
5893
5894
|
children,
|
|
@@ -7525,6 +7526,18 @@ var BlockEditModal = ({
|
|
|
7525
7526
|
accentClass: theme.border,
|
|
7526
7527
|
children: [
|
|
7527
7528
|
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "space-y-4", children: [
|
|
7529
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
|
|
7530
|
+
/* @__PURE__ */ jsxRuntime.jsx("label", { className: "text-[10px] font-medium text-[var(--kyro-text-muted)] mb-1 block", children: "Block Name" }),
|
|
7531
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
7532
|
+
"input",
|
|
7533
|
+
{
|
|
7534
|
+
value: blockData?.name || "",
|
|
7535
|
+
onChange: (e) => updateBlock(block3.id, { name: e.target.value }),
|
|
7536
|
+
placeholder: blockSchema?.label || block3.type,
|
|
7537
|
+
className: "w-full bg-[var(--kyro-bg-primary)] border border-[var(--kyro-border)] rounded-lg px-3 py-2 text-sm text-[var(--kyro-text-primary)] outline-none focus:border-[var(--kyro-primary)] transition-colors"
|
|
7538
|
+
}
|
|
7539
|
+
)
|
|
7540
|
+
] }),
|
|
7528
7541
|
renderFields(),
|
|
7529
7542
|
children.length > 0 && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "pt-4 border-t border-[var(--kyro-border)]", children: [
|
|
7530
7543
|
/* @__PURE__ */ jsxRuntime.jsxs("label", { className: "text-[10px] font-medium text-[var(--kyro-text-muted)] mb-1.5 block", children: [
|
|
@@ -7636,7 +7649,7 @@ var ChildBlocksTree = ({
|
|
|
7636
7649
|
blockIcons[child.type] && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "w-8 h-8 rounded bg-[var(--kyro-surface-accent)] flex items-center justify-center text-[var(--kyro-text-secondary)]", children: blockIcons[child.type] }),
|
|
7637
7650
|
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex-1 min-w-0", children: [
|
|
7638
7651
|
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "text-xs font-medium text-[var(--kyro-text-secondary)] truncate", children: [
|
|
7639
|
-
|
|
7652
|
+
getBlockDisplayLabel(child),
|
|
7640
7653
|
child.data?.text ? ` - ${child.data.text.slice(0, 30)}` : "",
|
|
7641
7654
|
child.data?.heading ? ` - ${child.data.heading.slice(0, 30)}` : ""
|
|
7642
7655
|
] }),
|
|
@@ -7857,7 +7870,7 @@ var NestedChildBlocks = ({
|
|
|
7857
7870
|
blockIcons[child.type] && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "w-8 h-8 rounded bg-[var(--kyro-surface-accent)] flex items-center justify-center text-[var(--kyro-text-secondary)]", children: blockIcons[child.type] }),
|
|
7858
7871
|
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex-1 min-w-0", children: [
|
|
7859
7872
|
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "text-xs font-medium text-[var(--kyro-text-secondary)] truncate", children: [
|
|
7860
|
-
|
|
7873
|
+
getBlockDisplayLabel(child),
|
|
7861
7874
|
child.data?.text ? ` - ${child.data.text.slice(0, 30)}` : "",
|
|
7862
7875
|
child.data?.heading ? ` - ${child.data.heading.slice(0, 30)}` : ""
|
|
7863
7876
|
] }),
|
|
@@ -8571,7 +8584,7 @@ var blockIcons = {
|
|
|
8571
8584
|
function getBlockComponent(type) {
|
|
8572
8585
|
return BLOCK_COMPONENTS[type] || null;
|
|
8573
8586
|
}
|
|
8574
|
-
function
|
|
8587
|
+
function getBlockLabel2(type) {
|
|
8575
8588
|
const labelMap = {
|
|
8576
8589
|
// Primitives
|
|
8577
8590
|
paragraph: "Paragraph",
|
|
@@ -8614,6 +8627,11 @@ function getBlockLabel(type) {
|
|
|
8614
8627
|
};
|
|
8615
8628
|
return labelMap[type] || type;
|
|
8616
8629
|
}
|
|
8630
|
+
function getBlockDisplayLabel(block3) {
|
|
8631
|
+
const name = block3.name;
|
|
8632
|
+
if (name && name.trim()) return name.trim();
|
|
8633
|
+
return getBlockLabel2(block3.type);
|
|
8634
|
+
}
|
|
8617
8635
|
function getBlockPreviewSnippet(data, blockSchema) {
|
|
8618
8636
|
if (blockSchema?.fields) {
|
|
8619
8637
|
for (const field3 of blockSchema.fields) {
|
|
@@ -8642,16 +8660,32 @@ var SortableBlockComponent = ({
|
|
|
8642
8660
|
transition,
|
|
8643
8661
|
isDragging
|
|
8644
8662
|
} = sortable.useSortable({ id: block3.id });
|
|
8645
|
-
const { removeBlock } = useBlockActions();
|
|
8663
|
+
const { removeBlock, updateBlock } = useBlockActions();
|
|
8646
8664
|
const isEditing = editingBlockId === block3.id;
|
|
8647
8665
|
const [showDeleteConfirm, setShowDeleteConfirm] = React.useState(false);
|
|
8666
|
+
const [editingName, setEditingName] = React.useState(false);
|
|
8667
|
+
const [nameDraft, setNameDraft] = React.useState(block3.name || "");
|
|
8668
|
+
const nameInputRef = React.useRef(null);
|
|
8669
|
+
React.useEffect(() => {
|
|
8670
|
+
if (editingName && nameInputRef.current) {
|
|
8671
|
+
nameInputRef.current.focus();
|
|
8672
|
+
nameInputRef.current.select();
|
|
8673
|
+
}
|
|
8674
|
+
}, [editingName]);
|
|
8675
|
+
const commitName = React.useCallback(() => {
|
|
8676
|
+
setEditingName(false);
|
|
8677
|
+
const trimmed = nameDraft.trim();
|
|
8678
|
+
if (trimmed !== (block3.name || "").trim()) {
|
|
8679
|
+
updateBlock(block3.id, { name: trimmed || "" });
|
|
8680
|
+
}
|
|
8681
|
+
}, [nameDraft, block3.name, block3.id, updateBlock]);
|
|
8648
8682
|
const style = {
|
|
8649
8683
|
transform: utilities.CSS.Transform.toString(transform),
|
|
8650
8684
|
transition,
|
|
8651
8685
|
zIndex: isDragging ? 10 : 1,
|
|
8652
8686
|
opacity: isDragging ? 0.8 : 1
|
|
8653
8687
|
};
|
|
8654
|
-
const itemLabel =
|
|
8688
|
+
const itemLabel = getBlockDisplayLabel(block3);
|
|
8655
8689
|
const data = block3.data || {};
|
|
8656
8690
|
const previewSnippet = getBlockPreviewSnippet(data, blockSchema);
|
|
8657
8691
|
if (compact) {
|
|
@@ -8673,7 +8707,36 @@ var SortableBlockComponent = ({
|
|
|
8673
8707
|
}
|
|
8674
8708
|
),
|
|
8675
8709
|
blockIcons[block3.type] && /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-[var(--kyro-text-secondary)] flex-shrink-0", children: blockIcons[block3.type] }),
|
|
8676
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
8710
|
+
editingName ? /* @__PURE__ */ jsxRuntime.jsx(
|
|
8711
|
+
"input",
|
|
8712
|
+
{
|
|
8713
|
+
ref: nameInputRef,
|
|
8714
|
+
value: nameDraft,
|
|
8715
|
+
onChange: (e) => setNameDraft(e.target.value),
|
|
8716
|
+
onBlur: commitName,
|
|
8717
|
+
onKeyDown: (e) => {
|
|
8718
|
+
if (e.key === "Enter") commitName();
|
|
8719
|
+
if (e.key === "Escape") {
|
|
8720
|
+
setNameDraft(block3.name || "");
|
|
8721
|
+
setEditingName(false);
|
|
8722
|
+
}
|
|
8723
|
+
},
|
|
8724
|
+
onClick: (e) => e.stopPropagation(),
|
|
8725
|
+
className: "flex-1 min-w-0 bg-[var(--kyro-surface-accent)] border border-[var(--kyro-primary)] rounded px-1.5 py-0.5 text-[10px] font-medium text-[var(--kyro-text-primary)] outline-none"
|
|
8726
|
+
}
|
|
8727
|
+
) : /* @__PURE__ */ jsxRuntime.jsx(
|
|
8728
|
+
"span",
|
|
8729
|
+
{
|
|
8730
|
+
onClick: (e) => {
|
|
8731
|
+
e.stopPropagation();
|
|
8732
|
+
setNameDraft(block3.name || "");
|
|
8733
|
+
setEditingName(true);
|
|
8734
|
+
},
|
|
8735
|
+
className: "font-medium text-[var(--kyro-text-secondary)] truncate max-w-[120px] cursor-text hover:text-[var(--kyro-text-primary)] transition-colors",
|
|
8736
|
+
title: "Click to rename",
|
|
8737
|
+
children: itemLabel
|
|
8738
|
+
}
|
|
8739
|
+
),
|
|
8677
8740
|
showDeleteConfirm ? /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center gap-0.5", onClick: (e) => e.stopPropagation(), children: [
|
|
8678
8741
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
8679
8742
|
"button",
|
|
@@ -8755,13 +8818,43 @@ var SortableBlockComponent = ({
|
|
|
8755
8818
|
children: [
|
|
8756
8819
|
blockIcons[block3.type] && /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-[var(--kyro-text-secondary)]", children: blockIcons[block3.type] }),
|
|
8757
8820
|
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex-1 min-w-0", children: [
|
|
8758
|
-
/* @__PURE__ */ jsxRuntime.
|
|
8759
|
-
|
|
8760
|
-
|
|
8761
|
-
|
|
8762
|
-
|
|
8763
|
-
|
|
8764
|
-
|
|
8821
|
+
editingName ? /* @__PURE__ */ jsxRuntime.jsx(
|
|
8822
|
+
"input",
|
|
8823
|
+
{
|
|
8824
|
+
ref: nameInputRef,
|
|
8825
|
+
value: nameDraft,
|
|
8826
|
+
onChange: (e) => setNameDraft(e.target.value),
|
|
8827
|
+
onBlur: commitName,
|
|
8828
|
+
onKeyDown: (e) => {
|
|
8829
|
+
if (e.key === "Enter") commitName();
|
|
8830
|
+
if (e.key === "Escape") {
|
|
8831
|
+
setNameDraft(block3.name || "");
|
|
8832
|
+
setEditingName(false);
|
|
8833
|
+
}
|
|
8834
|
+
},
|
|
8835
|
+
onClick: (e) => e.stopPropagation(),
|
|
8836
|
+
placeholder: getBlockLabel2(block3.type),
|
|
8837
|
+
className: "w-full bg-[var(--kyro-surface-accent)] border border-[var(--kyro-primary)] rounded px-2 py-0.5 text-xs font-semibold text-[var(--kyro-text-primary)] outline-none"
|
|
8838
|
+
}
|
|
8839
|
+
) : /* @__PURE__ */ jsxRuntime.jsxs(
|
|
8840
|
+
"div",
|
|
8841
|
+
{
|
|
8842
|
+
onClick: (e) => {
|
|
8843
|
+
e.stopPropagation();
|
|
8844
|
+
setNameDraft(block3.name || "");
|
|
8845
|
+
setEditingName(true);
|
|
8846
|
+
},
|
|
8847
|
+
className: "text-xs font-semibold text-[var(--kyro-text-secondary)] truncate cursor-text hover:text-[var(--kyro-text-primary)] transition-colors",
|
|
8848
|
+
title: "Click to rename",
|
|
8849
|
+
children: [
|
|
8850
|
+
itemLabel,
|
|
8851
|
+
previewSnippet && typeof previewSnippet === "string" && /* @__PURE__ */ jsxRuntime.jsxs("span", { className: "text-[var(--kyro-text-muted)] font-normal ml-1.5", children: [
|
|
8852
|
+
"- ",
|
|
8853
|
+
previewSnippet.length > 40 ? `${previewSnippet.slice(0, 40)}...` : previewSnippet
|
|
8854
|
+
] })
|
|
8855
|
+
]
|
|
8856
|
+
}
|
|
8857
|
+
),
|
|
8765
8858
|
blockSchema?.admin?.description && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "text-[10px] text-[var(--kyro-text-muted)] mt-0.5 truncate opacity-80", children: blockSchema.admin.description })
|
|
8766
8859
|
] }),
|
|
8767
8860
|
block3.children && Array.isArray(block3.children) && block3.children.length > 0 && /* @__PURE__ */ jsxRuntime.jsxs("span", { className: "text-[10px] bg-[var(--kyro-surface-accent)] px-2 py-0.5 rounded text-[var(--kyro-text-muted)] font-medium", children: [
|