@actuate-media/cms-admin 0.66.0 → 0.67.0

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.
Files changed (105) hide show
  1. package/CHANGELOG.md +21 -0
  2. package/dist/AdminRoot.d.ts.map +1 -1
  3. package/dist/AdminRoot.js +7 -4
  4. package/dist/AdminRoot.js.map +1 -1
  5. package/dist/__tests__/components/inspector-pane.test.d.ts +2 -0
  6. package/dist/__tests__/components/inspector-pane.test.d.ts.map +1 -0
  7. package/dist/__tests__/components/inspector-pane.test.js +31 -0
  8. package/dist/__tests__/components/inspector-pane.test.js.map +1 -0
  9. package/dist/__tests__/lib/pages-tree.test.d.ts +2 -0
  10. package/dist/__tests__/lib/pages-tree.test.d.ts.map +1 -0
  11. package/dist/__tests__/lib/pages-tree.test.js +173 -0
  12. package/dist/__tests__/lib/pages-tree.test.js.map +1 -0
  13. package/dist/__tests__/views/dashboard.test.js +7 -3
  14. package/dist/__tests__/views/dashboard.test.js.map +1 -1
  15. package/dist/__tests__/views/media-seo-audit.render.test.d.ts +2 -0
  16. package/dist/__tests__/views/media-seo-audit.render.test.d.ts.map +1 -0
  17. package/dist/__tests__/views/media-seo-audit.render.test.js +102 -0
  18. package/dist/__tests__/views/media-seo-audit.render.test.js.map +1 -0
  19. package/dist/__tests__/views/onboarding-block.render.test.d.ts +2 -0
  20. package/dist/__tests__/views/onboarding-block.render.test.d.ts.map +1 -0
  21. package/dist/__tests__/views/onboarding-block.render.test.js +146 -0
  22. package/dist/__tests__/views/onboarding-block.render.test.js.map +1 -0
  23. package/dist/__tests__/views/pages-list-view.test.js +77 -1
  24. package/dist/__tests__/views/pages-list-view.test.js.map +1 -1
  25. package/dist/actuate-admin.css +1 -1
  26. package/dist/components/script-tags/ScriptTagEditorPane.d.ts +26 -0
  27. package/dist/components/script-tags/ScriptTagEditorPane.d.ts.map +1 -0
  28. package/dist/components/script-tags/ScriptTagEditorPane.js +160 -0
  29. package/dist/components/script-tags/ScriptTagEditorPane.js.map +1 -0
  30. package/dist/components/ui/InspectorPane.d.ts +51 -0
  31. package/dist/components/ui/InspectorPane.d.ts.map +1 -0
  32. package/dist/components/ui/InspectorPane.js +42 -0
  33. package/dist/components/ui/InspectorPane.js.map +1 -0
  34. package/dist/components/ui/index.d.ts +2 -0
  35. package/dist/components/ui/index.d.ts.map +1 -1
  36. package/dist/components/ui/index.js +1 -0
  37. package/dist/components/ui/index.js.map +1 -1
  38. package/dist/lib/page-editor-service.d.ts +11 -2
  39. package/dist/lib/page-editor-service.d.ts.map +1 -1
  40. package/dist/lib/page-editor-service.js +8 -2
  41. package/dist/lib/page-editor-service.js.map +1 -1
  42. package/dist/lib/pages-tree.d.ts +44 -0
  43. package/dist/lib/pages-tree.d.ts.map +1 -0
  44. package/dist/lib/pages-tree.js +106 -0
  45. package/dist/lib/pages-tree.js.map +1 -0
  46. package/dist/views/Dashboard.d.ts.map +1 -1
  47. package/dist/views/Dashboard.js +31 -2
  48. package/dist/views/Dashboard.js.map +1 -1
  49. package/dist/views/MediaBrowser.d.ts.map +1 -1
  50. package/dist/views/MediaBrowser.js +28 -2
  51. package/dist/views/MediaBrowser.js.map +1 -1
  52. package/dist/views/MediaSeoAudit.d.ts +25 -0
  53. package/dist/views/MediaSeoAudit.d.ts.map +1 -0
  54. package/dist/views/MediaSeoAudit.js +97 -0
  55. package/dist/views/MediaSeoAudit.js.map +1 -0
  56. package/dist/views/Pages/PagesListView.d.ts.map +1 -1
  57. package/dist/views/Pages/PagesListView.js +90 -10
  58. package/dist/views/Pages/PagesListView.js.map +1 -1
  59. package/dist/views/Pages/PagesTreeTable.d.ts +35 -0
  60. package/dist/views/Pages/PagesTreeTable.d.ts.map +1 -0
  61. package/dist/views/Pages/PagesTreeTable.js +28 -0
  62. package/dist/views/Pages/PagesTreeTable.js.map +1 -0
  63. package/dist/views/ScriptTags.d.ts +5 -1
  64. package/dist/views/ScriptTags.d.ts.map +1 -1
  65. package/dist/views/ScriptTags.js +32 -7
  66. package/dist/views/ScriptTags.js.map +1 -1
  67. package/dist/views/dashboard/OnboardingBlock.d.ts +29 -0
  68. package/dist/views/dashboard/OnboardingBlock.d.ts.map +1 -0
  69. package/dist/views/dashboard/OnboardingBlock.js +71 -0
  70. package/dist/views/dashboard/OnboardingBlock.js.map +1 -0
  71. package/dist/views/page-editor/PageSectionEditor.d.ts +7 -1
  72. package/dist/views/page-editor/PageSectionEditor.d.ts.map +1 -1
  73. package/dist/views/page-editor/PageSectionEditor.js +3 -3
  74. package/dist/views/page-editor/PageSectionEditor.js.map +1 -1
  75. package/dist/views/page-editor/PageSettingsModal.d.ts +1 -1
  76. package/dist/views/page-editor/PageSettingsModal.d.ts.map +1 -1
  77. package/dist/views/page-editor/PageSettingsModal.js +42 -3
  78. package/dist/views/page-editor/PageSettingsModal.js.map +1 -1
  79. package/package.json +2 -2
  80. package/src/AdminRoot.tsx +7 -3
  81. package/src/__tests__/components/inspector-pane.test.tsx +64 -0
  82. package/src/__tests__/lib/pages-tree.test.ts +197 -0
  83. package/src/__tests__/views/dashboard.test.tsx +7 -3
  84. package/src/__tests__/views/media-seo-audit.render.test.tsx +117 -0
  85. package/src/__tests__/views/onboarding-block.render.test.tsx +193 -0
  86. package/src/__tests__/views/pages-list-view.test.tsx +93 -1
  87. package/src/components/script-tags/ScriptTagEditorPane.tsx +474 -0
  88. package/src/components/ui/InspectorPane.tsx +129 -0
  89. package/src/components/ui/index.ts +10 -0
  90. package/src/lib/page-editor-service.ts +16 -2
  91. package/src/lib/pages-tree.ts +145 -0
  92. package/src/views/Dashboard.tsx +238 -196
  93. package/src/views/MediaBrowser.tsx +641 -511
  94. package/src/views/MediaSeoAudit.tsx +320 -0
  95. package/src/views/Pages/PagesListView.tsx +352 -183
  96. package/src/views/Pages/PagesTreeTable.tsx +339 -0
  97. package/src/views/ScriptTags.tsx +204 -129
  98. package/src/views/dashboard/OnboardingBlock.tsx +233 -0
  99. package/src/views/page-editor/PageSectionEditor.tsx +9 -2
  100. package/src/views/page-editor/PageSettingsModal.tsx +75 -2
  101. package/dist/views/ScriptTagEditor.d.ts +0 -6
  102. package/dist/views/ScriptTagEditor.d.ts.map +0 -1
  103. package/dist/views/ScriptTagEditor.js +0 -111
  104. package/dist/views/ScriptTagEditor.js.map +0 -1
  105. package/src/views/ScriptTagEditor.tsx +0 -353
@@ -0,0 +1,129 @@
1
+ 'use client'
2
+
3
+ import type { ReactNode } from 'react'
4
+ import { X } from 'lucide-react'
5
+
6
+ /**
7
+ * Design-system inline split-pane pattern: a list that shrinks while a
8
+ * fixed-width editor/detail pane slides in beside it (Script Tags 420px,
9
+ * Entries 400px, Forms 390px, SEO Content 380px in the handoff).
10
+ *
11
+ * Compose as:
12
+ *
13
+ * <SplitPaneLayout>
14
+ * <SplitPaneList>…table…</SplitPaneList>
15
+ * <InspectorPane open={!!selected} width={420} aria-label="Edit script">
16
+ * <InspectorPaneHeader onClose={close}>…</InspectorPaneHeader>
17
+ * <InspectorPaneBody>…sections…</InspectorPaneBody>
18
+ * <InspectorPaneFooter>…save…</InspectorPaneFooter>
19
+ * </InspectorPane>
20
+ * </SplitPaneLayout>
21
+ */
22
+ export function SplitPaneLayout({
23
+ children,
24
+ className,
25
+ }: {
26
+ children: ReactNode
27
+ className?: string
28
+ }) {
29
+ return <div className={`flex min-h-0 flex-1 overflow-hidden ${className ?? ''}`}>{children}</div>
30
+ }
31
+
32
+ export function SplitPaneList({
33
+ children,
34
+ className,
35
+ }: {
36
+ children: ReactNode
37
+ className?: string
38
+ }) {
39
+ return <div className={`min-w-0 flex-1 overflow-y-auto ${className ?? ''}`}>{children}</div>
40
+ }
41
+
42
+ export interface InspectorPaneProps {
43
+ open: boolean
44
+ /** Outer shell width in px when open (inner card fills it minus 12px gutters). */
45
+ width: number
46
+ children: ReactNode
47
+ 'aria-label': string
48
+ }
49
+
50
+ export function InspectorPane({
51
+ open,
52
+ width,
53
+ children,
54
+ 'aria-label': ariaLabel,
55
+ }: InspectorPaneProps) {
56
+ return (
57
+ <div
58
+ className="shrink-0 overflow-hidden bg-[var(--bg)] motion-safe:transition-[width] motion-safe:duration-200"
59
+ style={{ width: open ? width : 0 }}
60
+ aria-hidden={!open}
61
+ >
62
+ <div
63
+ role="region"
64
+ aria-label={ariaLabel}
65
+ className="my-3 mr-3 ml-4 flex h-[calc(100%-24px)] flex-col overflow-hidden rounded-[var(--r)] border border-[var(--bdr)] bg-[var(--sb)] shadow-[var(--shd2)]"
66
+ style={{ width: width - 28 }}
67
+ >
68
+ {open ? children : null}
69
+ </div>
70
+ </div>
71
+ )
72
+ }
73
+
74
+ export function InspectorPaneHeader({
75
+ children,
76
+ onClose,
77
+ closeLabel = 'Close panel',
78
+ }: {
79
+ children: ReactNode
80
+ onClose: () => void
81
+ closeLabel?: string
82
+ }) {
83
+ return (
84
+ <div className="flex items-start gap-2 border-b border-[var(--bdr)] px-4 py-3.5">
85
+ <div className="min-w-0 flex-1">{children}</div>
86
+ <button
87
+ type="button"
88
+ onClick={onClose}
89
+ aria-label={closeLabel}
90
+ className="flex h-7 w-7 shrink-0 items-center justify-center rounded-[6px] text-[var(--muted)] transition-colors duration-[var(--motion-fast)] hover:bg-[var(--bg)] hover:text-[var(--txt)] focus-visible:ring-2 focus-visible:ring-[var(--ring)] focus-visible:outline-none"
91
+ >
92
+ <X size={16} />
93
+ </button>
94
+ </div>
95
+ )
96
+ }
97
+
98
+ export function InspectorPaneBody({ children }: { children: ReactNode }) {
99
+ return <div className="min-h-0 flex-1 overflow-y-auto">{children}</div>
100
+ }
101
+
102
+ /** Bordered section with the design's uppercase 10.5px section title. */
103
+ export function InspectorPaneSection({
104
+ title,
105
+ subtitle,
106
+ children,
107
+ }: {
108
+ title?: string
109
+ subtitle?: string
110
+ children: ReactNode
111
+ }) {
112
+ return (
113
+ <div className="border-b border-[var(--bdr)] px-4 py-3.5 last:border-b-0">
114
+ {title && (
115
+ <div className="mb-2.5 flex items-baseline gap-2">
116
+ <span className="text-[10.5px] font-semibold tracking-[0.6px] text-[var(--muted)] uppercase">
117
+ {title}
118
+ </span>
119
+ {subtitle && <span className="text-[11px] text-[var(--muted)]">{subtitle}</span>}
120
+ </div>
121
+ )}
122
+ {children}
123
+ </div>
124
+ )
125
+ }
126
+
127
+ export function InspectorPaneFooter({ children }: { children: ReactNode }) {
128
+ return <div className="border-t border-[var(--bdr)] px-4 py-3.5">{children}</div>
129
+ }
@@ -44,6 +44,16 @@ export { StatPill } from './StatPill.js'
44
44
  export type { StatPillProps } from './StatPill.js'
45
45
  export { RowActions, RowActionButton } from './RowActions.js'
46
46
  export type { RowActionButtonProps } from './RowActions.js'
47
+ export {
48
+ SplitPaneLayout,
49
+ SplitPaneList,
50
+ InspectorPane,
51
+ InspectorPaneHeader,
52
+ InspectorPaneBody,
53
+ InspectorPaneSection,
54
+ InspectorPaneFooter,
55
+ } from './InspectorPane.js'
56
+ export type { InspectorPaneProps } from './InspectorPane.js'
47
57
  export { formControlBase, formControlState } from './form-control.js'
48
58
  export { CommandPalette } from './CommandPalette.js'
49
59
  export type { CommandPaletteProps } from './CommandPalette.js'
@@ -64,6 +64,12 @@ export interface EditorPage {
64
64
  slug: string
65
65
  path: string
66
66
  status: PageStatus
67
+ /**
68
+ * Parent page for the tree hierarchy (`data.parentPageId`), or null for
69
+ * a top-level page. Preselected when arriving via "Add sub-page"
70
+ * (`/pages/new?parent=<id>`); editable in Page settings.
71
+ */
72
+ parentPageId: string | null
67
73
  sections: PageSection[]
68
74
  seoTitle: string
69
75
  seoDescription: string
@@ -192,6 +198,8 @@ function rowToEditorPage(doc: DocumentApiRow): EditorPage {
192
198
  slug,
193
199
  path: typeof data.path === 'string' && data.path ? data.path : slug ? `/${slug}` : '/',
194
200
  status: doc.status ?? 'DRAFT',
201
+ parentPageId:
202
+ typeof data.parentPageId === 'string' && data.parentPageId ? data.parentPageId : null,
195
203
  // Preserve unknown (externally-managed) sections so the editor can show
196
204
  // them read-only and round-trip them on save instead of dropping them.
197
205
  sections: coerceSectionsCore(data.sections, { onUnknown: 'preserve' }),
@@ -215,6 +223,7 @@ interface PageWritePayload {
215
223
  title: string
216
224
  slug: string
217
225
  path: string
226
+ parentPageId: string | null
218
227
  sections: PageSection[]
219
228
  metaTitle: string
220
229
  metaDescription: string
@@ -230,6 +239,7 @@ function toWriteBody(page: EditorPage, extra?: Record<string, unknown>): string
230
239
  title: page.title,
231
240
  slug: page.slug,
232
241
  path: page.path,
242
+ parentPageId: page.parentPageId,
233
243
  // Unmanaged sections are part of `page.sections`, so they round-trip on
234
244
  // every save (no data loss). Strip the derived `unmanaged` marker — it is
235
245
  // recomputed from the registry on read, so persisting it would only stale.
@@ -275,14 +285,18 @@ export async function publishPage(page: EditorPage): Promise<EditorPage> {
275
285
  return rowToEditorPage(res.data)
276
286
  }
277
287
 
278
- /** A blank page scaffold for `/pages/new`. */
279
- export function emptyPage(): EditorPage {
288
+ /**
289
+ * A blank page scaffold for `/pages/new`. `parentPageId` is preset when
290
+ * the flow was entered via "Add sub-page" in the Pages tree view.
291
+ */
292
+ export function emptyPage(parentPageId: string | null = null): EditorPage {
280
293
  return {
281
294
  id: null,
282
295
  title: '',
283
296
  slug: '',
284
297
  path: '',
285
298
  status: 'DRAFT',
299
+ parentPageId,
286
300
  sections: [],
287
301
  seoTitle: '',
288
302
  seoDescription: '',
@@ -0,0 +1,145 @@
1
+ /**
2
+ * Page hierarchy resolution for the Pages tree view.
3
+ *
4
+ * Parent resolution strategy (in priority order):
5
+ * 1. `parentPageId` — explicit link, used when it points at a page that
6
+ * exists in the set (and isn't the page itself).
7
+ * 2. Path-prefix derivation — for rows without a usable `parentPageId`,
8
+ * the longest existing path prefix wins: "/about/team" becomes a child
9
+ * of the page whose path is "/about". Missing intermediate levels are
10
+ * skipped ("/a/b/c" with no "/a/b" attaches to "/a"). The root path
11
+ * "/" is never treated as a prefix parent, so top-level pages stay
12
+ * siblings of the homepage.
13
+ *
14
+ * Safety guarantees:
15
+ * - Orphans (parent id not in the set) become roots.
16
+ * - Cycles (a → b → a) are broken deterministically: walking up from each
17
+ * page in input order, the edge that closes a cycle is severed and that
18
+ * page becomes a root. Every page appears in the tree exactly once.
19
+ * - Sibling ordering is stable: title (locale-aware), then path.
20
+ *
21
+ * Pure functions — no network, no React — so the view and the unit tests
22
+ * share one implementation.
23
+ */
24
+ import type { Page } from './pages-service.js'
25
+
26
+ export interface PageTreeNode {
27
+ page: Page
28
+ children: PageTreeNode[]
29
+ }
30
+
31
+ /** One visible row of the flattened tree table. */
32
+ export interface PageTreeRow {
33
+ page: Page
34
+ depth: number
35
+ hasChildren: boolean
36
+ }
37
+
38
+ function normalizePath(path: string): string {
39
+ let p = path.trim()
40
+ if (!p.startsWith('/')) p = `/${p}`
41
+ p = p.replace(/\/{2,}/g, '/')
42
+ if (p.length > 1) p = p.replace(/\/+$/, '')
43
+ return p
44
+ }
45
+
46
+ /**
47
+ * Longest existing path-prefix parent, or null. Only prefixes with at
48
+ * least one segment count — "/" (the homepage) is never a derived parent.
49
+ */
50
+ function derivePathParent(page: Page, idByPath: Map<string, string>): string | null {
51
+ const segments = normalizePath(page.path).split('/').filter(Boolean)
52
+ for (let i = segments.length - 1; i >= 1; i--) {
53
+ const prefix = `/${segments.slice(0, i).join('/')}`
54
+ const candidate = idByPath.get(prefix)
55
+ if (candidate !== undefined && candidate !== page.id) return candidate
56
+ }
57
+ return null
58
+ }
59
+
60
+ function compareSiblings(a: PageTreeNode, b: PageTreeNode): number {
61
+ return (
62
+ a.page.title.localeCompare(b.page.title) ||
63
+ a.page.path.localeCompare(b.page.path) ||
64
+ a.page.id.localeCompare(b.page.id)
65
+ )
66
+ }
67
+
68
+ /** Build the parent/child hierarchy for the tree view. Returns root nodes. */
69
+ export function buildPageTree(pages: Page[]): PageTreeNode[] {
70
+ const byId = new Map<string, Page>()
71
+ for (const p of pages) byId.set(p.id, p)
72
+
73
+ // First occurrence wins on duplicate paths, keeping resolution stable
74
+ // with respect to input order.
75
+ const idByPath = new Map<string, string>()
76
+ for (const p of pages) {
77
+ const norm = normalizePath(p.path)
78
+ if (!idByPath.has(norm)) idByPath.set(norm, p.id)
79
+ }
80
+
81
+ const parentOf = new Map<string, string | null>()
82
+ for (const p of pages) {
83
+ const explicit =
84
+ p.parentPageId && p.parentPageId !== p.id && byId.has(p.parentPageId) ? p.parentPageId : null
85
+ parentOf.set(p.id, explicit ?? derivePathParent(p, idByPath))
86
+ }
87
+
88
+ // Cycle guard: walk each page's ancestor chain; the edge that revisits a
89
+ // seen node is severed, rooting that page. Deterministic in input order.
90
+ for (const p of pages) {
91
+ const seen = new Set<string>([p.id])
92
+ let cur = p.id
93
+ for (;;) {
94
+ const parent = parentOf.get(cur) ?? null
95
+ if (parent === null) break
96
+ if (seen.has(parent)) {
97
+ parentOf.set(cur, null)
98
+ break
99
+ }
100
+ seen.add(parent)
101
+ cur = parent
102
+ }
103
+ }
104
+
105
+ const nodeById = new Map<string, PageTreeNode>()
106
+ for (const p of pages) nodeById.set(p.id, { page: p, children: [] })
107
+
108
+ const roots: PageTreeNode[] = []
109
+ for (const p of pages) {
110
+ const node = nodeById.get(p.id)!
111
+ const parentId = parentOf.get(p.id) ?? null
112
+ const parentNode = parentId !== null ? nodeById.get(parentId) : undefined
113
+ if (parentNode) parentNode.children.push(node)
114
+ else roots.push(node)
115
+ }
116
+
117
+ const sortRecursive = (nodes: PageTreeNode[]) => {
118
+ nodes.sort(compareSiblings)
119
+ for (const n of nodes) sortRecursive(n.children)
120
+ }
121
+ sortRecursive(roots)
122
+ return roots
123
+ }
124
+
125
+ /**
126
+ * Flatten the tree into visible rows: children render only when their
127
+ * parent's id is in `expanded`.
128
+ */
129
+ export function flattenPageTree(nodes: PageTreeNode[], expanded: Set<string>): PageTreeRow[] {
130
+ const rows: PageTreeRow[] = []
131
+ const walk = (list: PageTreeNode[], depth: number) => {
132
+ for (const node of list) {
133
+ const hasChildren = node.children.length > 0
134
+ rows.push({ page: node.page, depth, hasChildren })
135
+ if (hasChildren && expanded.has(node.page.id)) walk(node.children, depth + 1)
136
+ }
137
+ }
138
+ walk(nodes, 0)
139
+ return rows
140
+ }
141
+
142
+ /** Default expand state: every root node that has children starts open. */
143
+ export function defaultExpandedIds(roots: PageTreeNode[]): Set<string> {
144
+ return new Set(roots.filter((n) => n.children.length > 0).map((n) => n.page.id))
145
+ }