@elytracms/studio 0.0.17 → 0.0.18
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/components/app-views/default-modules.d.ts +89 -26
- package/dist/components/app-views/default-modules.js +132 -49
- package/dist/components/app-views/default-modules.js.map +1 -1
- package/dist/components/app-views/module.d.ts +59 -50
- package/dist/components/app-views/module.js +25 -43
- package/dist/components/app-views/module.js.map +1 -1
- package/dist/components/app-views/sidebar.d.ts +54 -73
- package/dist/components/app-views/sidebar.js +92 -127
- package/dist/components/app-views/sidebar.js.map +1 -1
- package/dist/components/app-views/studio-config.d.ts +77 -0
- package/dist/components/app-views/studio-config.js +31 -0
- package/dist/components/app-views/studio-config.js.map +1 -0
- package/dist/components/cms/field-control.d.ts +8 -5
- package/dist/components/cms/field-control.js +21 -10
- package/dist/components/cms/field-control.js.map +1 -1
- package/dist/components/cms/field-renderer.d.ts +28 -30
- package/dist/components/cms/field-renderer.js +15 -20
- package/dist/components/cms/field-renderer.js.map +1 -1
- package/dist/components/section-nav.d.ts +8 -7
- package/dist/components/section-nav.js +27 -26
- package/dist/components/section-nav.js.map +1 -1
- package/dist/components/studio-project-screen.js +16 -16
- package/dist/components/studio-project-screen.js.map +1 -1
- package/dist/components/studio-shell.js +13 -13
- package/dist/components/studio-shell.js.map +1 -1
- package/dist/customization.d.ts +48 -0
- package/dist/customization.js +46 -0
- package/dist/customization.js.map +1 -0
- package/dist/lib/cms-views/view-model.d.ts +2 -2
- package/dist/lib/cms-views/views-store.d.ts +1 -1
- package/dist/lib/workspace/index.d.ts +32 -24
- package/dist/lib/workspace/index.js +35 -27
- package/dist/lib/workspace/index.js.map +1 -1
- package/dist/router/match.d.ts +16 -16
- package/dist/router/match.js +17 -17
- package/dist/router/match.js.map +1 -1
- package/dist/ui/badge.d.ts +1 -1
- package/package.json +6 -2
|
@@ -1,41 +1,104 @@
|
|
|
1
|
+
import type { ReactNode } from 'react';
|
|
1
2
|
import type { LucideIcon } from 'lucide-react';
|
|
2
3
|
import type { SectionId } from '@elytracms/core/studio-core';
|
|
3
|
-
import { type AppViewModule, type
|
|
4
|
+
import { type AppViewContext, type AppViewDeepLink, type AppViewModule, type SidebarViewNode } from './module';
|
|
4
5
|
/**
|
|
5
|
-
* EC-239 — the studio's
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
* {@link
|
|
10
|
-
*
|
|
11
|
-
*
|
|
6
|
+
* EC-237/239 — the studio's BUILT-IN views + the consumer-facing `nav` namespace,
|
|
7
|
+
* an instance of the EC-236 customization seam.
|
|
8
|
+
*
|
|
9
|
+
* Each built-in surface (the former `StudioSectionResolver` case body) is promoted
|
|
10
|
+
* to a self-contained {@link AppViewModule} factory. The `nav` namespace is the
|
|
11
|
+
* single, typed builder a consuming repo's `studio.config.tsx` uses to declare its
|
|
12
|
+
* section rail — `nav.cms(...)`, `nav.group(...)`, `nav.view(...)` — passing the
|
|
13
|
+
* view objects (and a focus config) DIRECTLY, never a string id. The CMS surface
|
|
14
|
+
* is a factory ({@link cmsView}) so a focused view ("Catalog", "Categories") is the
|
|
15
|
+
* SAME surface instantiated with config, not a copy — the EC-239 reuse proof.
|
|
12
16
|
*/
|
|
13
|
-
/** Config for a CMS-backed
|
|
14
|
-
export interface
|
|
15
|
-
id
|
|
16
|
-
|
|
17
|
+
/** Config for a CMS-backed view — `collections`/`collection` focus the lens (EC-239). */
|
|
18
|
+
export interface CmsViewConfig {
|
|
19
|
+
/** Explicit stable id (the route segment). Omitted → derived from the focus. */
|
|
20
|
+
id?: string;
|
|
21
|
+
label?: string;
|
|
17
22
|
description?: string;
|
|
18
23
|
icon?: LucideIcon;
|
|
19
|
-
/**
|
|
24
|
+
/** Focus the surface (sidebar + index) to these collection ids — a multi-collection lens. */
|
|
20
25
|
collections?: readonly string[];
|
|
21
|
-
/**
|
|
26
|
+
/** Single-collection lens: open straight into this collection's list (replaces the old deep-link). */
|
|
27
|
+
collection?: string;
|
|
28
|
+
/** The availability section this view rides on (EC-221); defaults to `cms`. */
|
|
29
|
+
availabilitySection?: SectionId;
|
|
30
|
+
}
|
|
31
|
+
/** Common label/icon overrides for a built-in view (`nav.routes({ label: 'URLs' })`). */
|
|
32
|
+
export interface BuiltinViewConfig {
|
|
33
|
+
label?: string;
|
|
34
|
+
icon?: LucideIcon;
|
|
35
|
+
}
|
|
36
|
+
/** Config for a fully custom view (`nav.view({...})`) — the net-new surface escape hatch. */
|
|
37
|
+
export interface CustomViewConfig {
|
|
38
|
+
/** Explicit stable id (the route segment). Omitted → a slug of the label. */
|
|
39
|
+
id?: string;
|
|
40
|
+
label: string;
|
|
41
|
+
description?: string;
|
|
42
|
+
icon?: LucideIcon;
|
|
43
|
+
render: (ctx: AppViewContext) => ReactNode;
|
|
44
|
+
parsePath?: (segments: string[]) => AppViewDeepLink | null;
|
|
22
45
|
availabilitySection?: SectionId;
|
|
23
46
|
}
|
|
24
47
|
/**
|
|
25
|
-
* Build a CMS
|
|
26
|
-
*
|
|
27
|
-
*
|
|
28
|
-
* '
|
|
48
|
+
* Build a CMS view — the default `cms` view, or a focused instance. Every instance
|
|
49
|
+
* shares one surface ({@link CmsScreen}); `collections` narrows the sidebar + index
|
|
50
|
+
* to a subset, `collection` is a single-collection lens that opens straight into
|
|
51
|
+
* that collection's list. The id is derived from the focus (deterministic, stable
|
|
52
|
+
* across rail reorders) unless `id` is given — so two focused views never collide.
|
|
29
53
|
*/
|
|
30
|
-
export declare function
|
|
54
|
+
export declare function cmsView(config?: CmsViewConfig): AppViewModule;
|
|
55
|
+
/** The components registry browser view. */
|
|
56
|
+
export declare function componentsView(config?: BuiltinViewConfig): AppViewModule;
|
|
57
|
+
/** The resolved routes & redirects view (read-only; routing is config-as-code). */
|
|
58
|
+
export declare function routesView(config?: BuiltinViewConfig): AppViewModule;
|
|
59
|
+
/** The asset library view. */
|
|
60
|
+
export declare function assetsView(config?: BuiltinViewConfig): AppViewModule;
|
|
61
|
+
/** The extensions marketplace view. */
|
|
62
|
+
export declare function extensionsView(config?: BuiltinViewConfig): AppViewModule;
|
|
63
|
+
/** The project settings view. */
|
|
64
|
+
export declare function settingsView(config?: BuiltinViewConfig): AppViewModule;
|
|
65
|
+
/** The legacy `builder` redirect — a hidden, routable view (so `/builder?page=` still lands). */
|
|
66
|
+
export declare function builderView(): AppViewModule;
|
|
67
|
+
/** Build a fully custom view (the `nav.view(...)` escape hatch). */
|
|
68
|
+
export declare function customView(config: CustomViewConfig): AppViewModule;
|
|
31
69
|
/**
|
|
32
|
-
* The studio's built-in
|
|
33
|
-
*
|
|
34
|
-
*
|
|
70
|
+
* The studio's built-in views in canonical rail order (components · CMS · routes ·
|
|
71
|
+
* assets · extensions · settings), plus the hidden `builder` redirect (routable but
|
|
72
|
+
* unlisted). The default rail (no `defineStudio({ sidebar })`) is these as plain
|
|
73
|
+
* entries; the router registry always includes them so deep-links resolve even
|
|
74
|
+
* when a consumer's rail omits one.
|
|
35
75
|
*/
|
|
36
|
-
export declare const
|
|
76
|
+
export declare const DEFAULT_VIEWS: readonly AppViewModule[];
|
|
37
77
|
/**
|
|
38
|
-
* The
|
|
39
|
-
*
|
|
78
|
+
* The `nav` namespace — the single typed builder for `studio.config.tsx`'s section
|
|
79
|
+
* rail. Each call returns a {@link SidebarViewNode} (or a group / separator) that
|
|
80
|
+
* carries its view DIRECTLY: `nav.cms({ collection })` is a focused CMS view,
|
|
81
|
+
* `nav.view({ render })` a net-new surface, `nav.group(label, [...])` a header with
|
|
82
|
+
* sub-views, `nav.separator()` a divider. No string ids, no `moduleId` — the rail
|
|
83
|
+
* is the views.
|
|
40
84
|
*/
|
|
41
|
-
export declare
|
|
85
|
+
export declare const nav: {
|
|
86
|
+
/** The CMS view (whole model, or focused via `collections` / `collection`). */
|
|
87
|
+
readonly cms: (config?: CmsViewConfig) => SidebarViewNode;
|
|
88
|
+
/** The component registry browser. */
|
|
89
|
+
readonly components: (config?: BuiltinViewConfig) => SidebarViewNode;
|
|
90
|
+
/** The asset library. */
|
|
91
|
+
readonly assets: (config?: BuiltinViewConfig) => SidebarViewNode;
|
|
92
|
+
/** The resolved routes & redirects. */
|
|
93
|
+
readonly routes: (config?: BuiltinViewConfig) => SidebarViewNode;
|
|
94
|
+
/** Project settings. */
|
|
95
|
+
readonly settings: (config?: BuiltinViewConfig) => SidebarViewNode;
|
|
96
|
+
/** The extensions marketplace. */
|
|
97
|
+
readonly extensions: (config?: BuiltinViewConfig) => SidebarViewNode;
|
|
98
|
+
/** A fully custom view — pass your own `render` (and optional `parsePath`). */
|
|
99
|
+
readonly view: (config: CustomViewConfig) => SidebarViewNode;
|
|
100
|
+
/** A labelled group of views (a header with sub-entries). */
|
|
101
|
+
readonly group: (label: string, children: SidebarViewNode[]) => import("./module").SidebarGroupNode;
|
|
102
|
+
/** A divider between rail sections. */
|
|
103
|
+
readonly separator: () => import("./module").SidebarSeparatorNode;
|
|
104
|
+
};
|
|
@@ -1,12 +1,11 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
import { useEffect
|
|
3
|
-
import { Blocks, Database, Image, Puzzle, Settings as SettingsIcon, Signpost } from 'lucide-react';
|
|
2
|
+
import { useEffect } from 'react';
|
|
3
|
+
import { Blocks, Database, Image, LayoutGrid, Puzzle, Settings as SettingsIcon, Signpost, } from 'lucide-react';
|
|
4
4
|
import { isSingleton, resolveSingletonDocument } from '@elytracms/core/cms-core';
|
|
5
5
|
import { Navigate, STUDIO_PROJECT_ROUTE, studioPath } from '@elytracms/studio/router';
|
|
6
6
|
import { Text } from '@elytracms/studio/ui';
|
|
7
7
|
import { getInstantiatedKit } from '@elytracms/studio/lib/starters/kit-session';
|
|
8
|
-
import {
|
|
9
|
-
import { cmsDeepLink, componentsDeepLink, resolveAppViews, } from './module';
|
|
8
|
+
import { cmsDeepLink, componentsDeepLink, groupNode, separatorNode, viewNode, } from './module';
|
|
10
9
|
import { SectionSurface } from '../section-surface';
|
|
11
10
|
import { SectionStateView } from '../section-state';
|
|
12
11
|
import { SettingsForm } from '../settings-form';
|
|
@@ -23,73 +22,108 @@ import { CmsIndex } from '../cms/cms-index';
|
|
|
23
22
|
import { CollectionTable } from '../cms/collection-table';
|
|
24
23
|
import { DetailEditor } from '../cms/detail-editor';
|
|
25
24
|
import { OperationErrorBanner } from '../operation-error';
|
|
25
|
+
function slugify(label) {
|
|
26
|
+
return label.trim().toLowerCase().replace(/[^a-z0-9]+/g, '-').replace(/^-+|-+$/g, '') || 'view';
|
|
27
|
+
}
|
|
28
|
+
/** Derive a stable, deterministic id from the CMS focus (overridable via `config.id`). */
|
|
29
|
+
function cmsViewId(config) {
|
|
30
|
+
if (config.id)
|
|
31
|
+
return config.id;
|
|
32
|
+
if (config.collection)
|
|
33
|
+
return `cms:${config.collection}`;
|
|
34
|
+
if (config.collections && config.collections.length > 0) {
|
|
35
|
+
return `cms:${[...config.collections].join('-')}`;
|
|
36
|
+
}
|
|
37
|
+
return 'cms';
|
|
38
|
+
}
|
|
26
39
|
/**
|
|
27
|
-
* Build a CMS
|
|
28
|
-
*
|
|
29
|
-
*
|
|
30
|
-
* '
|
|
40
|
+
* Build a CMS view — the default `cms` view, or a focused instance. Every instance
|
|
41
|
+
* shares one surface ({@link CmsScreen}); `collections` narrows the sidebar + index
|
|
42
|
+
* to a subset, `collection` is a single-collection lens that opens straight into
|
|
43
|
+
* that collection's list. The id is derived from the focus (deterministic, stable
|
|
44
|
+
* across rail reorders) unless `id` is given — so two focused views never collide.
|
|
31
45
|
*/
|
|
32
|
-
export function
|
|
46
|
+
export function cmsView(config = {}) {
|
|
47
|
+
const single = config.collection;
|
|
48
|
+
const focus = single ? [single] : config.collections;
|
|
33
49
|
return {
|
|
34
|
-
id: config
|
|
35
|
-
label: config.label,
|
|
50
|
+
id: cmsViewId(config),
|
|
51
|
+
label: config.label ?? 'CMS',
|
|
36
52
|
description: config.description ?? 'Model collections, fields, and documents.',
|
|
37
53
|
icon: config.icon ?? Database,
|
|
38
54
|
availabilitySection: config.availabilitySection ?? 'cms',
|
|
39
|
-
|
|
40
|
-
|
|
55
|
+
// A single-collection lens routes `[]`→that collection, `[d]`→its document;
|
|
56
|
+
// an unfocused / multi-collection view uses the full index/collection/document arity.
|
|
57
|
+
parsePath: single
|
|
58
|
+
? (segments) => segments.length === 0
|
|
59
|
+
? { collectionId: single, documentId: null }
|
|
60
|
+
: segments.length === 1
|
|
61
|
+
? { collectionId: single, documentId: segments[0] }
|
|
62
|
+
: null
|
|
63
|
+
: cmsDeepLink,
|
|
64
|
+
render: (ctx) => (_jsx(CmsScreen, { project: ctx.project, collectionId: ctx.deepLink.collectionId ?? null, documentId: ctx.deepLink.documentId ?? null, state: ctx.search.state, field: ctx.search.field, focusCollections: focus })),
|
|
41
65
|
};
|
|
42
66
|
}
|
|
43
|
-
/**
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
* hidden, routable module (so `/builder?page=` still lands on the page document).
|
|
47
|
-
*/
|
|
48
|
-
export const DEFAULT_APP_VIEWS = [
|
|
49
|
-
{
|
|
67
|
+
/** The components registry browser view. */
|
|
68
|
+
export function componentsView(config = {}) {
|
|
69
|
+
return {
|
|
50
70
|
id: 'components',
|
|
51
|
-
label: 'Components',
|
|
71
|
+
label: config.label ?? 'Components',
|
|
52
72
|
description: 'Browse the registry of primitives and project components.',
|
|
53
|
-
icon: Blocks,
|
|
73
|
+
icon: config.icon ?? Blocks,
|
|
54
74
|
availabilitySection: 'components',
|
|
55
75
|
parsePath: componentsDeepLink,
|
|
56
76
|
render: (ctx) => (_jsx(ComponentsScreen, { projectId: ctx.projectId, componentId: ctx.deepLink.componentId ?? null, state: ctx.search.state })),
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
|
|
77
|
+
};
|
|
78
|
+
}
|
|
79
|
+
/** The resolved routes & redirects view (read-only; routing is config-as-code). */
|
|
80
|
+
export function routesView(config = {}) {
|
|
81
|
+
return {
|
|
60
82
|
id: 'routes',
|
|
61
|
-
label: 'Routes',
|
|
83
|
+
label: config.label ?? 'Routes',
|
|
62
84
|
description: 'View the resolved URL routes & redirects (defined in elytra.config.ts).',
|
|
63
|
-
icon: Signpost,
|
|
85
|
+
icon: config.icon ?? Signpost,
|
|
64
86
|
// Routes/redirects are CMS routing concerns, so the surface rides on the CMS availability.
|
|
65
87
|
availabilitySection: 'cms',
|
|
66
88
|
render: (ctx) => ctx.search.state && ctx.search.state !== 'working' ? (_jsx(SectionStateView, { state: ctx.search.state, title: "Routes" })) : (_jsx(RoutesShell, { project: ctx.project })),
|
|
67
|
-
}
|
|
68
|
-
|
|
89
|
+
};
|
|
90
|
+
}
|
|
91
|
+
/** The asset library view. */
|
|
92
|
+
export function assetsView(config = {}) {
|
|
93
|
+
return {
|
|
69
94
|
id: 'assets',
|
|
70
|
-
label: 'Assets',
|
|
95
|
+
label: config.label ?? 'Assets',
|
|
71
96
|
description: 'Manage uploaded media and metadata.',
|
|
72
|
-
icon: Image,
|
|
97
|
+
icon: config.icon ?? Image,
|
|
73
98
|
availabilitySection: 'assets',
|
|
74
99
|
render: (ctx) => (_jsx(SectionSurface, { project: ctx.project, section: "assets", forcedState: ctx.search.state, children: _jsx(AssetLibrary, { projectId: ctx.projectId, focusAssetId: ctx.search.asset }) })),
|
|
75
|
-
}
|
|
76
|
-
|
|
100
|
+
};
|
|
101
|
+
}
|
|
102
|
+
/** The extensions marketplace view. */
|
|
103
|
+
export function extensionsView(config = {}) {
|
|
104
|
+
return {
|
|
77
105
|
id: 'extensions',
|
|
78
|
-
label: 'Extensions',
|
|
106
|
+
label: config.label ?? 'Extensions',
|
|
79
107
|
description: 'Install components, field types, adapters, and templates from the marketplace.',
|
|
80
|
-
icon: Puzzle,
|
|
108
|
+
icon: config.icon ?? Puzzle,
|
|
81
109
|
availabilitySection: 'extensions',
|
|
82
110
|
render: (ctx) => ctx.search.state && ctx.search.state !== 'working' ? (_jsx(SectionStateView, { state: ctx.search.state, title: "Extensions" })) : (_jsx(ExtensionsView, {})),
|
|
83
|
-
}
|
|
84
|
-
|
|
111
|
+
};
|
|
112
|
+
}
|
|
113
|
+
/** The project settings view. */
|
|
114
|
+
export function settingsView(config = {}) {
|
|
115
|
+
return {
|
|
85
116
|
id: 'settings',
|
|
86
|
-
label: 'Settings',
|
|
117
|
+
label: config.label ?? 'Settings',
|
|
87
118
|
description: 'Configure project metadata and locales.',
|
|
88
|
-
icon: SettingsIcon,
|
|
119
|
+
icon: config.icon ?? SettingsIcon,
|
|
89
120
|
availabilitySection: 'settings',
|
|
90
121
|
render: (ctx) => (_jsx(SectionSurface, { project: ctx.project, section: "settings", forcedState: ctx.search.state, children: _jsx(SettingsForm, { project: ctx.project }) })),
|
|
91
|
-
}
|
|
92
|
-
|
|
122
|
+
};
|
|
123
|
+
}
|
|
124
|
+
/** The legacy `builder` redirect — a hidden, routable view (so `/builder?page=` still lands). */
|
|
125
|
+
export function builderView() {
|
|
126
|
+
return {
|
|
93
127
|
id: 'builder',
|
|
94
128
|
label: 'Builder',
|
|
95
129
|
description: 'Legacy builder route — redirects to the page document editor.',
|
|
@@ -104,16 +138,65 @@ export const DEFAULT_APP_VIEWS = [
|
|
|
104
138
|
? studioPath.cmsDocument('page', ctx.search.page)
|
|
105
139
|
: studioPath.cmsCollection('page'),
|
|
106
140
|
}, replace: true })),
|
|
107
|
-
}
|
|
141
|
+
};
|
|
142
|
+
}
|
|
143
|
+
/** Build a fully custom view (the `nav.view(...)` escape hatch). */
|
|
144
|
+
export function customView(config) {
|
|
145
|
+
return {
|
|
146
|
+
id: config.id ?? slugify(config.label),
|
|
147
|
+
label: config.label,
|
|
148
|
+
description: config.description ?? config.label,
|
|
149
|
+
icon: config.icon ?? LayoutGrid,
|
|
150
|
+
render: config.render,
|
|
151
|
+
...(config.parsePath ? { parsePath: config.parsePath } : {}),
|
|
152
|
+
...(config.availabilitySection ? { availabilitySection: config.availabilitySection } : {}),
|
|
153
|
+
};
|
|
154
|
+
}
|
|
155
|
+
/**
|
|
156
|
+
* The studio's built-in views in canonical rail order (components · CMS · routes ·
|
|
157
|
+
* assets · extensions · settings), plus the hidden `builder` redirect (routable but
|
|
158
|
+
* unlisted). The default rail (no `defineStudio({ sidebar })`) is these as plain
|
|
159
|
+
* entries; the router registry always includes them so deep-links resolve even
|
|
160
|
+
* when a consumer's rail omits one.
|
|
161
|
+
*/
|
|
162
|
+
export const DEFAULT_VIEWS = [
|
|
163
|
+
componentsView(),
|
|
164
|
+
cmsView(),
|
|
165
|
+
routesView(),
|
|
166
|
+
assetsView(),
|
|
167
|
+
extensionsView(),
|
|
168
|
+
settingsView(),
|
|
169
|
+
builderView(),
|
|
108
170
|
];
|
|
109
171
|
/**
|
|
110
|
-
* The
|
|
111
|
-
*
|
|
172
|
+
* The `nav` namespace — the single typed builder for `studio.config.tsx`'s section
|
|
173
|
+
* rail. Each call returns a {@link SidebarViewNode} (or a group / separator) that
|
|
174
|
+
* carries its view DIRECTLY: `nav.cms({ collection })` is a focused CMS view,
|
|
175
|
+
* `nav.view({ render })` a net-new surface, `nav.group(label, [...])` a header with
|
|
176
|
+
* sub-views, `nav.separator()` a divider. No string ids, no `moduleId` — the rail
|
|
177
|
+
* is the views.
|
|
112
178
|
*/
|
|
113
|
-
export
|
|
114
|
-
|
|
115
|
-
}
|
|
116
|
-
|
|
179
|
+
export const nav = {
|
|
180
|
+
/** The CMS view (whole model, or focused via `collections` / `collection`). */
|
|
181
|
+
cms: (config = {}) => viewNode(cmsView(config)),
|
|
182
|
+
/** The component registry browser. */
|
|
183
|
+
components: (config = {}) => viewNode(componentsView(config)),
|
|
184
|
+
/** The asset library. */
|
|
185
|
+
assets: (config = {}) => viewNode(assetsView(config)),
|
|
186
|
+
/** The resolved routes & redirects. */
|
|
187
|
+
routes: (config = {}) => viewNode(routesView(config)),
|
|
188
|
+
/** Project settings. */
|
|
189
|
+
settings: (config = {}) => viewNode(settingsView(config)),
|
|
190
|
+
/** The extensions marketplace. */
|
|
191
|
+
extensions: (config = {}) => viewNode(extensionsView(config)),
|
|
192
|
+
/** A fully custom view — pass your own `render` (and optional `parsePath`). */
|
|
193
|
+
view: (config) => viewNode(customView(config)),
|
|
194
|
+
/** A labelled group of views (a header with sub-entries). */
|
|
195
|
+
group: (label, children) => groupNode(label, children),
|
|
196
|
+
/** A divider between rail sections. */
|
|
197
|
+
separator: () => separatorNode(),
|
|
198
|
+
};
|
|
199
|
+
// --- Surfaces (the view render bodies; CMS gains a focus lens) ---
|
|
117
200
|
/**
|
|
118
201
|
* Components section (EC-050): a registry-browser sidebar beside the active
|
|
119
202
|
* screen — the index (no selection) or a component's detail. Forced states
|
|
@@ -130,7 +213,7 @@ function ComponentsScreen({ projectId, componentId, state, }) {
|
|
|
130
213
|
* then renders the collections sidebar beside the active screen (index, a
|
|
131
214
|
* collection table, or a document editor). Forced states (?state=) replace the
|
|
132
215
|
* whole surface. `focusCollections` (EC-239) narrows the sidebar + index to a
|
|
133
|
-
* subset, so a focused
|
|
216
|
+
* subset, so a focused view ("Catalog") reuses this surface with config.
|
|
134
217
|
*/
|
|
135
218
|
function CmsScreen({ project, collectionId, documentId, state, field, focusCollections, }) {
|
|
136
219
|
const projectId = project.id;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"default-modules.js","sourceRoot":"","sources":["../../../src/components/app-views/default-modules.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,SAAS,EAAE,OAAO,EAAE,MAAM,OAAO,CAAA;AAE1C,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,EAAE,QAAQ,IAAI,YAAY,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAA;AAClG,OAAO,EAAE,WAAW,EAAE,wBAAwB,EAAE,MAAM,0BAA0B,CAAA;AAEhF,OAAO,EAAE,QAAQ,EAAE,oBAAoB,EAAE,UAAU,EAAE,MAAM,0BAA0B,CAAA;AACrF,OAAO,EAAE,IAAI,EAAE,MAAM,sBAAsB,CAAA;AAC3C,OAAO,EAAE,kBAAkB,EAAE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,EAAC,IAAI,EAAC,IAAI,EAAC,OAAO,yBACjB,UAAU,EAAE,IAAI,EAAE,KAAK,IAAI,YAAY,cAC3C,GACH,CACP,CAAA;AACH,CAAC;AAED,yEAAyE;AACzE,SAAS,qBAAqB;IAC5B,MAAM,GAAG,GAAG,MAAM,EAAE,CAAA;IACpB,IAAI,CAAC,GAAG,CAAC,YAAY;QAAE,OAAO,IAAI,CAAA;IAClC,OAAO,CACL,cAAK,SAAS,EAAC,qCAAqC,YAClD,KAAC,oBAAoB,IAAC,KAAK,EAAE,GAAG,CAAC,YAAY,EAAE,SAAS,EAAE,GAAG,CAAC,iBAAiB,GAAI,GAC/E,CACP,CAAA;AACH,CAAC","sourcesContent":["import { useEffect, useMemo } from 'react'\nimport type { LucideIcon } from 'lucide-react'\nimport { Blocks, Database, Image, Puzzle, Settings as SettingsIcon, Signpost } from 'lucide-react'\nimport { isSingleton, resolveSingletonDocument } from '@elytracms/core/cms-core'\nimport type { Project, SectionId, SectionState } from '@elytracms/core/studio-core'\nimport { Navigate, STUDIO_PROJECT_ROUTE, studioPath } from '@elytracms/studio/router'\nimport { Text } from '@elytracms/studio/ui'\nimport { getInstantiatedKit } from '@elytracms/studio/lib/starters/kit-session'\nimport { resolveDeploymentAppViews } from '@elytracms/studio/lib/workspace'\nimport {\n cmsDeepLink,\n componentsDeepLink,\n resolveAppViews,\n type AppViewModule,\n type ResolvedAppViews,\n} from './module'\nimport { SectionSurface } from '../section-surface'\nimport { SectionStateView } from '../section-state'\nimport { SettingsForm } from '../settings-form'\nimport { AssetLibrary } from '../assets/asset-library'\nimport { RoutesShell } from '../routes/routes-shell'\nimport { ExtensionsView } from '../extensions/extensions-view'\nimport { RegistryBrowser } from '../components/registry-browser'\nimport { ComponentsIndex } from '../components/components-index'\nimport { ComponentDetail } from '../components/component-detail'\nimport { CmsSessionGate } from '../project-session'\nimport { CmsProvider, useCms } from '../cms/cms-store'\nimport { CollectionsSidebar } from '../cms/collections-sidebar'\nimport { CmsIndex } from '../cms/cms-index'\nimport { CollectionTable } from '../cms/collection-table'\nimport { DetailEditor } from '../cms/detail-editor'\nimport { OperationErrorBanner } from '../operation-error'\n\n/**\n * EC-239 — the studio's DEFAULT app-view module registry, plus the surfaces the\n * modules render. Each module here is the former `StudioSectionResolver` case body\n * promoted to a self-contained, config-mountable unit; a consuming repo adds or\n * replaces modules through `config.appViews` (resolved over this registry by\n * {@link resolveAppViews}). The CMS surface is exposed as a factory\n * ({@link cmsAppView}) so a focused view (\"Taxonomy\", \"Pages\") is the SAME module\n * instantiated with config, not a copy — the EC-239 reuse proof.\n */\n\n// --- The CMS surface, reusable via a config factory (the EC-239 reuse seam) ---\n\n/** Config for a CMS-backed module instance — `collections` focuses the lens (EC-239). */\nexport interface CmsAppViewConfig {\n id: string\n label: string\n description?: string\n icon?: LucideIcon\n /** Restrict the surface to these collection ids (a focused \"Taxonomy\"/\"Pages\" lens). Omitted → all. */\n collections?: readonly string[]\n /** The availability section this instance rides on (EC-221); defaults to `cms`. */\n availabilitySection?: SectionId\n}\n\n/**\n * Build a CMS app-view module — the default `cms` view, or a focused instance.\n * Every instance shares one surface ({@link CmsScreen}); `collections` narrows the\n * collections sidebar + index to a subset, so \"Taxonomy\" is `cmsAppView({ id:\n * 'taxonomy', collections: ['category', 'tag'] })`, not a forked screen.\n */\nexport function cmsAppView(config: CmsAppViewConfig): AppViewModule {\n return {\n id: config.id,\n label: config.label,\n description: config.description ?? 'Model collections, fields, and documents.',\n icon: config.icon ?? Database,\n availabilitySection: config.availabilitySection ?? 'cms',\n parsePath: cmsDeepLink,\n render: (ctx) => (\n <CmsScreen\n project={ctx.project}\n collectionId={ctx.deepLink.collectionId ?? null}\n documentId={ctx.deepLink.documentId ?? null}\n state={ctx.search.state}\n field={ctx.search.field}\n focusCollections={config.collections}\n />\n ),\n }\n}\n\n/**\n * The studio's built-in modules in canonical rail order (components · CMS · routes\n * · assets · extensions · settings), with the legacy `builder` redirect kept as a\n * hidden, routable module (so `/builder?page=` still lands on the page document).\n */\nexport const DEFAULT_APP_VIEWS: readonly AppViewModule[] = [\n {\n id: 'components',\n label: 'Components',\n description: 'Browse the registry of primitives and project components.',\n icon: Blocks,\n availabilitySection: 'components',\n parsePath: componentsDeepLink,\n render: (ctx) => (\n <ComponentsScreen\n projectId={ctx.projectId}\n componentId={ctx.deepLink.componentId ?? null}\n state={ctx.search.state}\n />\n ),\n },\n cmsAppView({ id: 'cms', label: 'CMS' }),\n {\n id: 'routes',\n label: 'Routes',\n description: 'View the resolved URL routes & redirects (defined in elytra.config.ts).',\n icon: Signpost,\n // Routes/redirects are CMS routing concerns, so the surface rides on the CMS availability.\n availabilitySection: 'cms',\n render: (ctx) =>\n ctx.search.state && ctx.search.state !== 'working' ? (\n <SectionStateView state={ctx.search.state} title=\"Routes\" />\n ) : (\n <RoutesShell project={ctx.project} />\n ),\n },\n {\n id: 'assets',\n label: 'Assets',\n description: 'Manage uploaded media and metadata.',\n icon: Image,\n availabilitySection: 'assets',\n render: (ctx) => (\n <SectionSurface project={ctx.project} section=\"assets\" forcedState={ctx.search.state}>\n {/* The AssetsProvider is mounted at the project level (EC-195). */}\n <AssetLibrary projectId={ctx.projectId} focusAssetId={ctx.search.asset} />\n </SectionSurface>\n ),\n },\n {\n id: 'extensions',\n label: 'Extensions',\n description: 'Install components, field types, adapters, and templates from the marketplace.',\n icon: Puzzle,\n availabilitySection: 'extensions',\n render: (ctx) =>\n ctx.search.state && ctx.search.state !== 'working' ? (\n <SectionStateView state={ctx.search.state} title=\"Extensions\" />\n ) : (\n <ExtensionsView />\n ),\n },\n {\n id: 'settings',\n label: 'Settings',\n description: 'Configure project metadata and locales.',\n icon: SettingsIcon,\n availabilitySection: 'settings',\n render: (ctx) => (\n <SectionSurface project={ctx.project} section=\"settings\" forcedState={ctx.search.state}>\n <SettingsForm project={ctx.project} />\n </SectionSurface>\n ),\n },\n {\n id: 'builder',\n label: 'Builder',\n description: 'Legacy builder route — redirects to the page document editor.',\n icon: Blocks,\n hidden: true,\n render: (ctx) => (\n // Retired surface (EC-187 slice 6): a page is a document in the `page`\n // collection. `?page=<id>` lands on that document; else the page list.\n <Navigate\n to={STUDIO_PROJECT_ROUTE}\n params={{\n projectId: ctx.projectId,\n _splat: ctx.search.page\n ? studioPath.cmsDocument('page', ctx.search.page)\n : studioPath.cmsCollection('page'),\n }}\n replace\n />\n ),\n },\n]\n\n/**\n * The active project's resolved app-view modules — the default registry composed\n * with `config.appViews` through the EC-236 seam (config is static per studio boot).\n */\nexport function useAppViews(): ResolvedAppViews {\n return useMemo(() => resolveAppViews(DEFAULT_APP_VIEWS, resolveDeploymentAppViews()), [])\n}\n\n// --- Surfaces (moved verbatim from the resolver; CMS gains a focus lens) ---\n\n/**\n * Components section (EC-050): a registry-browser sidebar beside the active\n * screen — the index (no selection) or a component's detail. Forced states\n * (?state=) replace the whole surface.\n */\nfunction ComponentsScreen({\n projectId,\n componentId,\n state,\n}: {\n projectId: string\n componentId: string | null\n state?: SectionState\n}) {\n if (state && state !== 'working') {\n return <SectionStateView state={state} title=\"Components\" />\n }\n return (\n <div className=\"flex h-full min-h-0\">\n <aside className=\"hidden h-full min-h-0 w-[300px] shrink-0 border-r border-border md:block\">\n <RegistryBrowser projectId={projectId} activeComponentId={componentId ?? undefined} />\n </aside>\n <div className=\"min-h-0 flex-1 overflow-auto\">\n {componentId === null ? (\n <ComponentsIndex projectId={projectId} />\n ) : (\n <ComponentDetail projectId={projectId} componentId={componentId} />\n )}\n </div>\n </div>\n )\n}\n\n/**\n * CMS section: hydrates the persisted (or kit-seeded) collections + documents,\n * then renders the collections sidebar beside the active screen (index, a\n * collection table, or a document editor). Forced states (?state=) replace the\n * whole surface. `focusCollections` (EC-239) narrows the sidebar + index to a\n * subset, so a focused module (\"Taxonomy\") reuses this surface with config.\n */\nfunction CmsScreen({\n project,\n collectionId,\n documentId,\n state,\n field,\n focusCollections,\n}: {\n project: Project\n collectionId: string | null\n documentId: string | null\n state?: SectionState\n field?: string\n focusCollections?: readonly string[]\n}) {\n const projectId = project.id\n if (state && state !== 'working') {\n return <SectionStateView state={state} title=\"CMS\" />\n }\n\n // A project created from a starter kit (EC-119) opens the CMS on the kit's schemas + content.\n const kit = getInstantiatedKit(projectId)\n\n return (\n // EC-177 gap 1: in Convex mode every CMS mount loads the CURRENT persisted\n // schema + documents (fixtures only when nothing is persisted — first run).\n // Playground renders synchronously with `null` → fixture seeds, as before.\n <CmsSessionGate>\n {(cms) => (\n <CmsProvider\n key={projectId}\n projectId={projectId}\n initialCollections={cms?.collections ?? kit?.collections}\n initialDocuments={cms?.documents ?? kit?.documents}\n initialPublishedKeys={cms?.publishedKeys}\n initialLocaleConfig={\n cms\n ? // Hydrated sessions follow the project's persisted locale settings.\n { default: project.settings.defaultLocale, locales: [...project.settings.locales] }\n : kit?.localeConfig\n }\n >\n <div className=\"flex h-full min-h-0 flex-col\">\n <CmsPersistErrorBanner />\n <div className=\"flex min-h-0 flex-1\">\n <aside className=\"hidden h-full min-h-0 w-[240px] shrink-0 border-r border-border md:block\">\n <CollectionsSidebar\n projectId={projectId}\n activeCollectionId={collectionId ?? undefined}\n focusCollections={focusCollections}\n />\n </aside>\n <div className=\"min-h-0 flex-1 overflow-hidden\">\n <CmsContent\n projectId={projectId}\n collectionId={collectionId}\n documentId={documentId}\n field={field}\n focusCollections={focusCollections}\n />\n </div>\n </div>\n </div>\n </CmsProvider>\n )}\n </CmsSessionGate>\n )\n}\n\n/** Resolves the active CMS screen inside the provider (needs the live store). */\nfunction CmsContent({\n projectId,\n collectionId,\n documentId,\n field,\n focusCollections,\n}: {\n projectId: string\n collectionId: string | null\n documentId: string | null\n field?: string\n focusCollections?: readonly string[]\n}) {\n const cms = useCms()\n\n if (collectionId === null) return <CmsIndex projectId={projectId} focusCollections={focusCollections} />\n\n if (documentId === null) {\n const collection = cms.getCollection(collectionId)\n // EC-274: a singleton is a UI lens — at the collection URL it opens its one\n // document directly *while in its expected shape*, but degrades to the list\n // (with a \"for review\" lane) on drift. SingletonGate decides per the data.\n if (collection && isSingleton(collection)) {\n return <SingletonGate projectId={projectId} collectionId={collectionId} />\n }\n return <CollectionTable projectId={projectId} collectionId={collectionId} />\n }\n\n return (\n <DetailEditor\n projectId={projectId}\n collectionId={collectionId}\n documentId={documentId}\n focusPath={field}\n />\n )\n}\n\n/**\n * EC-274 — the singleton lens gate. At a singleton collection's URL, resolve its\n * lone document and open it directly; on drift (> 1 document) fall back to the\n * list with the \"for review\" lane so an editor can resolve the conflict.\n */\nfunction SingletonGate({ projectId, collectionId }: { projectId: string; collectionId: string }) {\n const cms = useCms()\n const collection = cms.getCollection(collectionId)\n const docs = cms.documentsOf(collectionId)\n const resolution = collection\n ? resolveSingletonDocument(collection, docs)\n : ({ kind: 'empty' } as const)\n\n // Materialize the lone document on first visit (an empty draft, persisted like\n // any create). Idempotent in the store; only fires while genuinely empty.\n useEffect(() => {\n if (resolution.kind === 'empty') cms.ensureSingletonDocument(collectionId)\n }, [resolution.kind, cms, collectionId])\n\n if (resolution.kind === 'ready') {\n return (\n <DetailEditor projectId={projectId} collectionId={collectionId} documentId={resolution.doc.id} />\n )\n }\n if (resolution.kind === 'drift') {\n return <CollectionTable projectId={projectId} collectionId={collectionId} />\n }\n return (\n <div className=\"grid h-full place-items-center p-8\">\n <Text size=\"sm\" tone=\"muted\">\n Opening {collection?.form?.label ?? collectionId}…\n </Text>\n </div>\n )\n}\n\n/** Failed/denied persisted CMS mutations are always visible (EC-141). */\nfunction CmsPersistErrorBanner() {\n const cms = useCms()\n if (!cms.persistError) return null\n return (\n <div className=\"shrink-0 border-b border-border p-2\">\n <OperationErrorBanner error={cms.persistError} onDismiss={cms.clearPersistError} />\n </div>\n )\n}\n"]}
|
|
1
|
+
{"version":3,"file":"default-modules.js","sourceRoot":"","sources":["../../../src/components/app-views/default-modules.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,OAAO,CAAA;AAGjC,OAAO,EACL,MAAM,EACN,QAAQ,EACR,KAAK,EAC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,EAAC,IAAI,EAAC,IAAI,EAAC,OAAO,yBACjB,UAAU,EAAE,IAAI,EAAE,KAAK,IAAI,YAAY,cAC3C,GACH,CACP,CAAA;AACH,CAAC;AAED,yEAAyE;AACzE,SAAS,qBAAqB;IAC5B,MAAM,GAAG,GAAG,MAAM,EAAE,CAAA;IACpB,IAAI,CAAC,GAAG,CAAC,YAAY;QAAE,OAAO,IAAI,CAAA;IAClC,OAAO,CACL,cAAK,SAAS,EAAC,qCAAqC,YAClD,KAAC,oBAAoB,IAAC,KAAK,EAAE,GAAG,CAAC,YAAY,EAAE,SAAS,EAAE,GAAG,CAAC,iBAAiB,GAAI,GAC/E,CACP,CAAA;AACH,CAAC","sourcesContent":["import { useEffect } from 'react'\nimport type { ReactNode } from 'react'\nimport type { LucideIcon } from 'lucide-react'\nimport {\n Blocks,\n Database,\n Image,\n LayoutGrid,\n Puzzle,\n Settings as SettingsIcon,\n Signpost,\n} from 'lucide-react'\nimport { isSingleton, resolveSingletonDocument } from '@elytracms/core/cms-core'\nimport type { Project, SectionId, SectionState } from '@elytracms/core/studio-core'\nimport { Navigate, STUDIO_PROJECT_ROUTE, studioPath } from '@elytracms/studio/router'\nimport { Text } from '@elytracms/studio/ui'\nimport { getInstantiatedKit } from '@elytracms/studio/lib/starters/kit-session'\nimport {\n cmsDeepLink,\n componentsDeepLink,\n groupNode,\n separatorNode,\n viewNode,\n type AppViewContext,\n type AppViewDeepLink,\n type AppViewModule,\n type SidebarViewNode,\n} from './module'\nimport { SectionSurface } from '../section-surface'\nimport { SectionStateView } from '../section-state'\nimport { SettingsForm } from '../settings-form'\nimport { AssetLibrary } from '../assets/asset-library'\nimport { RoutesShell } from '../routes/routes-shell'\nimport { ExtensionsView } from '../extensions/extensions-view'\nimport { RegistryBrowser } from '../components/registry-browser'\nimport { ComponentsIndex } from '../components/components-index'\nimport { ComponentDetail } from '../components/component-detail'\nimport { CmsSessionGate } from '../project-session'\nimport { CmsProvider, useCms } from '../cms/cms-store'\nimport { CollectionsSidebar } from '../cms/collections-sidebar'\nimport { CmsIndex } from '../cms/cms-index'\nimport { CollectionTable } from '../cms/collection-table'\nimport { DetailEditor } from '../cms/detail-editor'\nimport { OperationErrorBanner } from '../operation-error'\n\n/**\n * EC-237/239 — the studio's BUILT-IN views + the consumer-facing `nav` namespace,\n * an instance of the EC-236 customization seam.\n *\n * Each built-in surface (the former `StudioSectionResolver` case body) is promoted\n * to a self-contained {@link AppViewModule} factory. The `nav` namespace is the\n * single, typed builder a consuming repo's `studio.config.tsx` uses to declare its\n * section rail — `nav.cms(...)`, `nav.group(...)`, `nav.view(...)` — passing the\n * view objects (and a focus config) DIRECTLY, never a string id. The CMS surface\n * is a factory ({@link cmsView}) so a focused view (\"Catalog\", \"Categories\") is the\n * SAME surface instantiated with config, not a copy — the EC-239 reuse proof.\n */\n\n// --- The CMS surface, reusable via a config factory (the EC-239 reuse seam) ---\n\n/** Config for a CMS-backed view — `collections`/`collection` focus the lens (EC-239). */\nexport interface CmsViewConfig {\n /** Explicit stable id (the route segment). Omitted → derived from the focus. */\n id?: string\n label?: string\n description?: string\n icon?: LucideIcon\n /** Focus the surface (sidebar + index) to these collection ids — a multi-collection lens. */\n collections?: readonly string[]\n /** Single-collection lens: open straight into this collection's list (replaces the old deep-link). */\n collection?: string\n /** The availability section this view rides on (EC-221); defaults to `cms`. */\n availabilitySection?: SectionId\n}\n\n/** Common label/icon overrides for a built-in view (`nav.routes({ label: 'URLs' })`). */\nexport interface BuiltinViewConfig {\n label?: string\n icon?: LucideIcon\n}\n\n/** Config for a fully custom view (`nav.view({...})`) — the net-new surface escape hatch. */\nexport interface CustomViewConfig {\n /** Explicit stable id (the route segment). Omitted → a slug of the label. */\n id?: string\n label: string\n description?: string\n icon?: LucideIcon\n render: (ctx: AppViewContext) => ReactNode\n parsePath?: (segments: string[]) => AppViewDeepLink | null\n availabilitySection?: SectionId\n}\n\nfunction slugify(label: string): string {\n return label.trim().toLowerCase().replace(/[^a-z0-9]+/g, '-').replace(/^-+|-+$/g, '') || 'view'\n}\n\n/** Derive a stable, deterministic id from the CMS focus (overridable via `config.id`). */\nfunction cmsViewId(config: CmsViewConfig): string {\n if (config.id) return config.id\n if (config.collection) return `cms:${config.collection}`\n if (config.collections && config.collections.length > 0) {\n return `cms:${[...config.collections].join('-')}`\n }\n return 'cms'\n}\n\n/**\n * Build a CMS view — the default `cms` view, or a focused instance. Every instance\n * shares one surface ({@link CmsScreen}); `collections` narrows the sidebar + index\n * to a subset, `collection` is a single-collection lens that opens straight into\n * that collection's list. The id is derived from the focus (deterministic, stable\n * across rail reorders) unless `id` is given — so two focused views never collide.\n */\nexport function cmsView(config: CmsViewConfig = {}): AppViewModule {\n const single = config.collection\n const focus = single ? [single] : config.collections\n return {\n id: cmsViewId(config),\n label: config.label ?? 'CMS',\n description: config.description ?? 'Model collections, fields, and documents.',\n icon: config.icon ?? Database,\n availabilitySection: config.availabilitySection ?? 'cms',\n // A single-collection lens routes `[]`→that collection, `[d]`→its document;\n // an unfocused / multi-collection view uses the full index/collection/document arity.\n parsePath: single\n ? (segments) =>\n segments.length === 0\n ? { collectionId: single, documentId: null }\n : segments.length === 1\n ? { collectionId: single, documentId: segments[0]! }\n : null\n : cmsDeepLink,\n render: (ctx) => (\n <CmsScreen\n project={ctx.project}\n collectionId={ctx.deepLink.collectionId ?? null}\n documentId={ctx.deepLink.documentId ?? null}\n state={ctx.search.state}\n field={ctx.search.field}\n focusCollections={focus}\n />\n ),\n }\n}\n\n/** The components registry browser view. */\nexport function componentsView(config: BuiltinViewConfig = {}): AppViewModule {\n return {\n id: 'components',\n label: config.label ?? 'Components',\n description: 'Browse the registry of primitives and project components.',\n icon: config.icon ?? Blocks,\n availabilitySection: 'components',\n parsePath: componentsDeepLink,\n render: (ctx) => (\n <ComponentsScreen\n projectId={ctx.projectId}\n componentId={ctx.deepLink.componentId ?? null}\n state={ctx.search.state}\n />\n ),\n }\n}\n\n/** The resolved routes & redirects view (read-only; routing is config-as-code). */\nexport function routesView(config: BuiltinViewConfig = {}): AppViewModule {\n return {\n id: 'routes',\n label: config.label ?? 'Routes',\n description: 'View the resolved URL routes & redirects (defined in elytra.config.ts).',\n icon: config.icon ?? Signpost,\n // Routes/redirects are CMS routing concerns, so the surface rides on the CMS availability.\n availabilitySection: 'cms',\n render: (ctx) =>\n ctx.search.state && ctx.search.state !== 'working' ? (\n <SectionStateView state={ctx.search.state} title=\"Routes\" />\n ) : (\n <RoutesShell project={ctx.project} />\n ),\n }\n}\n\n/** The asset library view. */\nexport function assetsView(config: BuiltinViewConfig = {}): AppViewModule {\n return {\n id: 'assets',\n label: config.label ?? 'Assets',\n description: 'Manage uploaded media and metadata.',\n icon: config.icon ?? Image,\n availabilitySection: 'assets',\n render: (ctx) => (\n <SectionSurface project={ctx.project} section=\"assets\" forcedState={ctx.search.state}>\n {/* The AssetsProvider is mounted at the project level (EC-195). */}\n <AssetLibrary projectId={ctx.projectId} focusAssetId={ctx.search.asset} />\n </SectionSurface>\n ),\n }\n}\n\n/** The extensions marketplace view. */\nexport function extensionsView(config: BuiltinViewConfig = {}): AppViewModule {\n return {\n id: 'extensions',\n label: config.label ?? 'Extensions',\n description: 'Install components, field types, adapters, and templates from the marketplace.',\n icon: config.icon ?? Puzzle,\n availabilitySection: 'extensions',\n render: (ctx) =>\n ctx.search.state && ctx.search.state !== 'working' ? (\n <SectionStateView state={ctx.search.state} title=\"Extensions\" />\n ) : (\n <ExtensionsView />\n ),\n }\n}\n\n/** The project settings view. */\nexport function settingsView(config: BuiltinViewConfig = {}): AppViewModule {\n return {\n id: 'settings',\n label: config.label ?? 'Settings',\n description: 'Configure project metadata and locales.',\n icon: config.icon ?? SettingsIcon,\n availabilitySection: 'settings',\n render: (ctx) => (\n <SectionSurface project={ctx.project} section=\"settings\" forcedState={ctx.search.state}>\n <SettingsForm project={ctx.project} />\n </SectionSurface>\n ),\n }\n}\n\n/** The legacy `builder` redirect — a hidden, routable view (so `/builder?page=` still lands). */\nexport function builderView(): AppViewModule {\n return {\n id: 'builder',\n label: 'Builder',\n description: 'Legacy builder route — redirects to the page document editor.',\n icon: Blocks,\n hidden: true,\n render: (ctx) => (\n // Retired surface (EC-187 slice 6): a page is a document in the `page`\n // collection. `?page=<id>` lands on that document; else the page list.\n <Navigate\n to={STUDIO_PROJECT_ROUTE}\n params={{\n projectId: ctx.projectId,\n _splat: ctx.search.page\n ? studioPath.cmsDocument('page', ctx.search.page)\n : studioPath.cmsCollection('page'),\n }}\n replace\n />\n ),\n }\n}\n\n/** Build a fully custom view (the `nav.view(...)` escape hatch). */\nexport function customView(config: CustomViewConfig): AppViewModule {\n return {\n id: config.id ?? slugify(config.label),\n label: config.label,\n description: config.description ?? config.label,\n icon: config.icon ?? LayoutGrid,\n render: config.render,\n ...(config.parsePath ? { parsePath: config.parsePath } : {}),\n ...(config.availabilitySection ? { availabilitySection: config.availabilitySection } : {}),\n }\n}\n\n/**\n * The studio's built-in views in canonical rail order (components · CMS · routes ·\n * assets · extensions · settings), plus the hidden `builder` redirect (routable but\n * unlisted). The default rail (no `defineStudio({ sidebar })`) is these as plain\n * entries; the router registry always includes them so deep-links resolve even\n * when a consumer's rail omits one.\n */\nexport const DEFAULT_VIEWS: readonly AppViewModule[] = [\n componentsView(),\n cmsView(),\n routesView(),\n assetsView(),\n extensionsView(),\n settingsView(),\n builderView(),\n]\n\n/**\n * The `nav` namespace — the single typed builder for `studio.config.tsx`'s section\n * rail. Each call returns a {@link SidebarViewNode} (or a group / separator) that\n * carries its view DIRECTLY: `nav.cms({ collection })` is a focused CMS view,\n * `nav.view({ render })` a net-new surface, `nav.group(label, [...])` a header with\n * sub-views, `nav.separator()` a divider. No string ids, no `moduleId` — the rail\n * is the views.\n */\nexport const nav = {\n /** The CMS view (whole model, or focused via `collections` / `collection`). */\n cms: (config: CmsViewConfig = {}): SidebarViewNode => viewNode(cmsView(config)),\n /** The component registry browser. */\n components: (config: BuiltinViewConfig = {}): SidebarViewNode => viewNode(componentsView(config)),\n /** The asset library. */\n assets: (config: BuiltinViewConfig = {}): SidebarViewNode => viewNode(assetsView(config)),\n /** The resolved routes & redirects. */\n routes: (config: BuiltinViewConfig = {}): SidebarViewNode => viewNode(routesView(config)),\n /** Project settings. */\n settings: (config: BuiltinViewConfig = {}): SidebarViewNode => viewNode(settingsView(config)),\n /** The extensions marketplace. */\n extensions: (config: BuiltinViewConfig = {}): SidebarViewNode => viewNode(extensionsView(config)),\n /** A fully custom view — pass your own `render` (and optional `parsePath`). */\n view: (config: CustomViewConfig): SidebarViewNode => viewNode(customView(config)),\n /** A labelled group of views (a header with sub-entries). */\n group: (label: string, children: SidebarViewNode[]) => groupNode(label, children),\n /** A divider between rail sections. */\n separator: () => separatorNode(),\n} as const\n\n// --- Surfaces (the view render bodies; CMS gains a focus lens) ---\n\n/**\n * Components section (EC-050): a registry-browser sidebar beside the active\n * screen — the index (no selection) or a component's detail. Forced states\n * (?state=) replace the whole surface.\n */\nfunction ComponentsScreen({\n projectId,\n componentId,\n state,\n}: {\n projectId: string\n componentId: string | null\n state?: SectionState\n}) {\n if (state && state !== 'working') {\n return <SectionStateView state={state} title=\"Components\" />\n }\n return (\n <div className=\"flex h-full min-h-0\">\n <aside className=\"hidden h-full min-h-0 w-[300px] shrink-0 border-r border-border md:block\">\n <RegistryBrowser projectId={projectId} activeComponentId={componentId ?? undefined} />\n </aside>\n <div className=\"min-h-0 flex-1 overflow-auto\">\n {componentId === null ? (\n <ComponentsIndex projectId={projectId} />\n ) : (\n <ComponentDetail projectId={projectId} componentId={componentId} />\n )}\n </div>\n </div>\n )\n}\n\n/**\n * CMS section: hydrates the persisted (or kit-seeded) collections + documents,\n * then renders the collections sidebar beside the active screen (index, a\n * collection table, or a document editor). Forced states (?state=) replace the\n * whole surface. `focusCollections` (EC-239) narrows the sidebar + index to a\n * subset, so a focused view (\"Catalog\") reuses this surface with config.\n */\nfunction CmsScreen({\n project,\n collectionId,\n documentId,\n state,\n field,\n focusCollections,\n}: {\n project: Project\n collectionId: string | null\n documentId: string | null\n state?: SectionState\n field?: string\n focusCollections?: readonly string[]\n}) {\n const projectId = project.id\n if (state && state !== 'working') {\n return <SectionStateView state={state} title=\"CMS\" />\n }\n\n // A project created from a starter kit (EC-119) opens the CMS on the kit's schemas + content.\n const kit = getInstantiatedKit(projectId)\n\n return (\n // EC-177 gap 1: in Convex mode every CMS mount loads the CURRENT persisted\n // schema + documents (fixtures only when nothing is persisted — first run).\n // Playground renders synchronously with `null` → fixture seeds, as before.\n <CmsSessionGate>\n {(cms) => (\n <CmsProvider\n key={projectId}\n projectId={projectId}\n initialCollections={cms?.collections ?? kit?.collections}\n initialDocuments={cms?.documents ?? kit?.documents}\n initialPublishedKeys={cms?.publishedKeys}\n initialLocaleConfig={\n cms\n ? // Hydrated sessions follow the project's persisted locale settings.\n { default: project.settings.defaultLocale, locales: [...project.settings.locales] }\n : kit?.localeConfig\n }\n >\n <div className=\"flex h-full min-h-0 flex-col\">\n <CmsPersistErrorBanner />\n <div className=\"flex min-h-0 flex-1\">\n <aside className=\"hidden h-full min-h-0 w-[240px] shrink-0 border-r border-border md:block\">\n <CollectionsSidebar\n projectId={projectId}\n activeCollectionId={collectionId ?? undefined}\n focusCollections={focusCollections}\n />\n </aside>\n <div className=\"min-h-0 flex-1 overflow-hidden\">\n <CmsContent\n projectId={projectId}\n collectionId={collectionId}\n documentId={documentId}\n field={field}\n focusCollections={focusCollections}\n />\n </div>\n </div>\n </div>\n </CmsProvider>\n )}\n </CmsSessionGate>\n )\n}\n\n/** Resolves the active CMS screen inside the provider (needs the live store). */\nfunction CmsContent({\n projectId,\n collectionId,\n documentId,\n field,\n focusCollections,\n}: {\n projectId: string\n collectionId: string | null\n documentId: string | null\n field?: string\n focusCollections?: readonly string[]\n}) {\n const cms = useCms()\n\n if (collectionId === null) return <CmsIndex projectId={projectId} focusCollections={focusCollections} />\n\n if (documentId === null) {\n const collection = cms.getCollection(collectionId)\n // EC-274: a singleton is a UI lens — at the collection URL it opens its one\n // document directly *while in its expected shape*, but degrades to the list\n // (with a \"for review\" lane) on drift. SingletonGate decides per the data.\n if (collection && isSingleton(collection)) {\n return <SingletonGate projectId={projectId} collectionId={collectionId} />\n }\n return <CollectionTable projectId={projectId} collectionId={collectionId} />\n }\n\n return (\n <DetailEditor\n projectId={projectId}\n collectionId={collectionId}\n documentId={documentId}\n focusPath={field}\n />\n )\n}\n\n/**\n * EC-274 — the singleton lens gate. At a singleton collection's URL, resolve its\n * lone document and open it directly; on drift (> 1 document) fall back to the\n * list with the \"for review\" lane so an editor can resolve the conflict.\n */\nfunction SingletonGate({ projectId, collectionId }: { projectId: string; collectionId: string }) {\n const cms = useCms()\n const collection = cms.getCollection(collectionId)\n const docs = cms.documentsOf(collectionId)\n const resolution = collection\n ? resolveSingletonDocument(collection, docs)\n : ({ kind: 'empty' } as const)\n\n // Materialize the lone document on first visit (an empty draft, persisted like\n // any create). Idempotent in the store; only fires while genuinely empty.\n useEffect(() => {\n if (resolution.kind === 'empty') cms.ensureSingletonDocument(collectionId)\n }, [resolution.kind, cms, collectionId])\n\n if (resolution.kind === 'ready') {\n return (\n <DetailEditor projectId={projectId} collectionId={collectionId} documentId={resolution.doc.id} />\n )\n }\n if (resolution.kind === 'drift') {\n return <CollectionTable projectId={projectId} collectionId={collectionId} />\n }\n return (\n <div className=\"grid h-full place-items-center p-8\">\n <Text size=\"sm\" tone=\"muted\">\n Opening {collection?.form?.label ?? collectionId}…\n </Text>\n </div>\n )\n}\n\n/** Failed/denied persisted CMS mutations are always visible (EC-141). */\nfunction CmsPersistErrorBanner() {\n const cms = useCms()\n if (!cms.persistError) return null\n return (\n <div className=\"shrink-0 border-b border-border p-2\">\n <OperationErrorBanner error={cms.persistError} onDismiss={cms.clearPersistError} />\n </div>\n )\n}\n"]}
|