@cohesivesystems/presentation-react-shadcn 0.1.0-alpha.1
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/LICENSE +55 -0
- package/dist/document-workspace-surface-slot-renderers.d.ts +58 -0
- package/dist/document-workspace-surface-slot-renderers.d.ts.map +1 -0
- package/dist/document-workspace-surface-slot-renderers.js +206 -0
- package/dist/document-workspace-surface-slot-renderers.js.map +1 -0
- package/dist/index.d.ts +53 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +53 -0
- package/dist/index.js.map +1 -0
- package/dist/navigation-shell-frame-renderer-registry.d.ts +8 -0
- package/dist/navigation-shell-frame-renderer-registry.d.ts.map +1 -0
- package/dist/navigation-shell-frame-renderer-registry.js +2 -0
- package/dist/navigation-shell-frame-renderer-registry.js.map +1 -0
- package/dist/navigation-shell-slot-renderer-registry.d.ts +9 -0
- package/dist/navigation-shell-slot-renderer-registry.d.ts.map +1 -0
- package/dist/navigation-shell-slot-renderer-registry.js +2 -0
- package/dist/navigation-shell-slot-renderer-registry.js.map +1 -0
- package/dist/page-host-unavailable-renderer.d.ts +10 -0
- package/dist/page-host-unavailable-renderer.d.ts.map +1 -0
- package/dist/page-host-unavailable-renderer.js +27 -0
- package/dist/page-host-unavailable-renderer.js.map +1 -0
- package/dist/presentation-action-group.d.ts +99 -0
- package/dist/presentation-action-group.d.ts.map +1 -0
- package/dist/presentation-action-group.js +214 -0
- package/dist/presentation-action-group.js.map +1 -0
- package/dist/presentation-badge-target-interpreter.d.ts +26 -0
- package/dist/presentation-badge-target-interpreter.d.ts.map +1 -0
- package/dist/presentation-badge-target-interpreter.js +17 -0
- package/dist/presentation-badge-target-interpreter.js.map +1 -0
- package/dist/presentation-component-groups.d.ts +968 -0
- package/dist/presentation-component-groups.d.ts.map +1 -0
- package/dist/presentation-component-groups.js +505 -0
- package/dist/presentation-component-groups.js.map +1 -0
- package/dist/presentation-component-system-diagnostics.d.ts +27 -0
- package/dist/presentation-component-system-diagnostics.d.ts.map +1 -0
- package/dist/presentation-component-system-diagnostics.js +399 -0
- package/dist/presentation-component-system-diagnostics.js.map +1 -0
- package/dist/presentation-component-system.d.ts +31 -0
- package/dist/presentation-component-system.d.ts.map +1 -0
- package/dist/presentation-component-system.js +61 -0
- package/dist/presentation-component-system.js.map +1 -0
- package/dist/presentation-icon-diagnostics.d.ts +12 -0
- package/dist/presentation-icon-diagnostics.d.ts.map +1 -0
- package/dist/presentation-icon-diagnostics.js +17 -0
- package/dist/presentation-icon-diagnostics.js.map +1 -0
- package/dist/presentation-icon-registry.d.ts +28 -0
- package/dist/presentation-icon-registry.d.ts.map +1 -0
- package/dist/presentation-icon-registry.js +80 -0
- package/dist/presentation-icon-registry.js.map +1 -0
- package/dist/presentation-projection-trace-panel.d.ts +10 -0
- package/dist/presentation-projection-trace-panel.d.ts.map +1 -0
- package/dist/presentation-projection-trace-panel.js +48 -0
- package/dist/presentation-projection-trace-panel.js.map +1 -0
- package/dist/presentation-routed-surface-host.d.ts +19 -0
- package/dist/presentation-routed-surface-host.d.ts.map +1 -0
- package/dist/presentation-routed-surface-host.js +12 -0
- package/dist/presentation-routed-surface-host.js.map +1 -0
- package/dist/presentation-shadcn-component-system.d.ts +22 -0
- package/dist/presentation-shadcn-component-system.d.ts.map +1 -0
- package/dist/presentation-shadcn-component-system.js +2 -0
- package/dist/presentation-shadcn-component-system.js.map +1 -0
- package/dist/presentation-standard-renderers.d.ts +168 -0
- package/dist/presentation-standard-renderers.d.ts.map +1 -0
- package/dist/presentation-standard-renderers.js +440 -0
- package/dist/presentation-standard-renderers.js.map +1 -0
- package/dist/presentation-surface-renderer.d.ts +23 -0
- package/dist/presentation-surface-renderer.d.ts.map +1 -0
- package/dist/presentation-surface-renderer.js +119 -0
- package/dist/presentation-surface-renderer.js.map +1 -0
- package/dist/presentation-value-renderers.d.ts +10 -0
- package/dist/presentation-value-renderers.d.ts.map +1 -0
- package/dist/presentation-value-renderers.js +14 -0
- package/dist/presentation-value-renderers.js.map +1 -0
- package/dist/process-task-icons.d.ts +49 -0
- package/dist/process-task-icons.d.ts.map +1 -0
- package/dist/process-task-icons.js +154 -0
- package/dist/process-task-icons.js.map +1 -0
- package/dist/projected-activity-state.d.ts +17 -0
- package/dist/projected-activity-state.d.ts.map +1 -0
- package/dist/projected-activity-state.js +22 -0
- package/dist/projected-activity-state.js.map +1 -0
- package/dist/projected-collection-action-runtime-diagnostics.d.ts +4 -0
- package/dist/projected-collection-action-runtime-diagnostics.d.ts.map +1 -0
- package/dist/projected-collection-action-runtime-diagnostics.js +9 -0
- package/dist/projected-collection-action-runtime-diagnostics.js.map +1 -0
- package/dist/projected-collection-view.d.ts +90 -0
- package/dist/projected-collection-view.d.ts.map +1 -0
- package/dist/projected-collection-view.js +532 -0
- package/dist/projected-collection-view.js.map +1 -0
- package/dist/projected-document-action-status-notices.d.ts +15 -0
- package/dist/projected-document-action-status-notices.d.ts.map +1 -0
- package/dist/projected-document-action-status-notices.js +33 -0
- package/dist/projected-document-action-status-notices.js.map +1 -0
- package/dist/projected-document-badges.d.ts +24 -0
- package/dist/projected-document-badges.d.ts.map +1 -0
- package/dist/projected-document-badges.js +53 -0
- package/dist/projected-document-badges.js.map +1 -0
- package/dist/projected-document-editor-surface.d.ts +46 -0
- package/dist/projected-document-editor-surface.d.ts.map +1 -0
- package/dist/projected-document-editor-surface.js +399 -0
- package/dist/projected-document-editor-surface.js.map +1 -0
- package/dist/projected-document-workspace-notices.d.ts +24 -0
- package/dist/projected-document-workspace-notices.d.ts.map +1 -0
- package/dist/projected-document-workspace-notices.js +14 -0
- package/dist/projected-document-workspace-notices.js.map +1 -0
- package/dist/projected-document-workspace-prompt-child-view-registry.d.ts +25 -0
- package/dist/projected-document-workspace-prompt-child-view-registry.d.ts.map +1 -0
- package/dist/projected-document-workspace-prompt-child-view-registry.js +41 -0
- package/dist/projected-document-workspace-prompt-child-view-registry.js.map +1 -0
- package/dist/projected-document-workspace-prompt-child-view-renderers.d.ts +32 -0
- package/dist/projected-document-workspace-prompt-child-view-renderers.d.ts.map +1 -0
- package/dist/projected-document-workspace-prompt-child-view-renderers.js +77 -0
- package/dist/projected-document-workspace-prompt-child-view-renderers.js.map +1 -0
- package/dist/projected-document-workspace-shell.d.ts +100 -0
- package/dist/projected-document-workspace-shell.d.ts.map +1 -0
- package/dist/projected-document-workspace-shell.js +153 -0
- package/dist/projected-document-workspace-shell.js.map +1 -0
- package/dist/projected-document-workspace.d.ts +39 -0
- package/dist/projected-document-workspace.d.ts.map +1 -0
- package/dist/projected-document-workspace.js +63 -0
- package/dist/projected-document-workspace.js.map +1 -0
- package/dist/projected-field-value-rendering.d.ts +94 -0
- package/dist/projected-field-value-rendering.d.ts.map +1 -0
- package/dist/projected-field-value-rendering.js +377 -0
- package/dist/projected-field-value-rendering.js.map +1 -0
- package/dist/projected-inline-list.d.ts +20 -0
- package/dist/projected-inline-list.d.ts.map +1 -0
- package/dist/projected-inline-list.js +149 -0
- package/dist/projected-inline-list.js.map +1 -0
- package/dist/projected-input-form.d.ts +143 -0
- package/dist/projected-input-form.d.ts.map +1 -0
- package/dist/projected-input-form.js +612 -0
- package/dist/projected-input-form.js.map +1 -0
- package/dist/projected-metric-dashboard.d.ts +26 -0
- package/dist/projected-metric-dashboard.d.ts.map +1 -0
- package/dist/projected-metric-dashboard.js +20 -0
- package/dist/projected-metric-dashboard.js.map +1 -0
- package/dist/projected-metric-strip.d.ts +20 -0
- package/dist/projected-metric-strip.d.ts.map +1 -0
- package/dist/projected-metric-strip.js +131 -0
- package/dist/projected-metric-strip.js.map +1 -0
- package/dist/projected-navigation-shell-view-host.d.ts +34 -0
- package/dist/projected-navigation-shell-view-host.d.ts.map +1 -0
- package/dist/projected-navigation-shell-view-host.js +75 -0
- package/dist/projected-navigation-shell-view-host.js.map +1 -0
- package/dist/projected-navigation-shell.d.ts +33 -0
- package/dist/projected-navigation-shell.d.ts.map +1 -0
- package/dist/projected-navigation-shell.js +112 -0
- package/dist/projected-navigation-shell.js.map +1 -0
- package/dist/projected-presentation-badges.d.ts +34 -0
- package/dist/projected-presentation-badges.d.ts.map +1 -0
- package/dist/projected-presentation-badges.js +22 -0
- package/dist/projected-presentation-badges.js.map +1 -0
- package/dist/projected-presentation-diagnostics.d.ts +10 -0
- package/dist/projected-presentation-diagnostics.d.ts.map +1 -0
- package/dist/projected-presentation-diagnostics.js +40 -0
- package/dist/projected-presentation-diagnostics.js.map +1 -0
- package/dist/projected-presentation-flow-layer.d.ts +33 -0
- package/dist/projected-presentation-flow-layer.d.ts.map +1 -0
- package/dist/projected-presentation-flow-layer.js +71 -0
- package/dist/projected-presentation-flow-layer.js.map +1 -0
- package/dist/projected-process-task-notices.d.ts +37 -0
- package/dist/projected-process-task-notices.d.ts.map +1 -0
- package/dist/projected-process-task-notices.js +225 -0
- package/dist/projected-process-task-notices.js.map +1 -0
- package/dist/projected-prompt-child-view-renderer.d.ts +101 -0
- package/dist/projected-prompt-child-view-renderer.d.ts.map +1 -0
- package/dist/projected-prompt-child-view-renderer.js +442 -0
- package/dist/projected-prompt-child-view-renderer.js.map +1 -0
- package/dist/projected-prompt-document-preview.d.ts +39 -0
- package/dist/projected-prompt-document-preview.d.ts.map +1 -0
- package/dist/projected-prompt-document-preview.js +50 -0
- package/dist/projected-prompt-document-preview.js.map +1 -0
- package/dist/projected-prompt-view.d.ts +35 -0
- package/dist/projected-prompt-view.d.ts.map +1 -0
- package/dist/projected-prompt-view.js +292 -0
- package/dist/projected-prompt-view.js.map +1 -0
- package/dist/projected-query-form.d.ts +56 -0
- package/dist/projected-query-form.d.ts.map +1 -0
- package/dist/projected-query-form.js +100 -0
- package/dist/projected-query-form.js.map +1 -0
- package/dist/projected-record-details.d.ts +20 -0
- package/dist/projected-record-details.d.ts.map +1 -0
- package/dist/projected-record-details.js +60 -0
- package/dist/projected-record-details.js.map +1 -0
- package/dist/projected-routed-surface-runtime.d.ts +86 -0
- package/dist/projected-routed-surface-runtime.d.ts.map +1 -0
- package/dist/projected-routed-surface-runtime.js +332 -0
- package/dist/projected-routed-surface-runtime.js.map +1 -0
- package/dist/projected-tabs-view.d.ts +21 -0
- package/dist/projected-tabs-view.d.ts.map +1 -0
- package/dist/projected-tabs-view.js +140 -0
- package/dist/projected-tabs-view.js.map +1 -0
- package/dist/projected-view-chrome.d.ts +15 -0
- package/dist/projected-view-chrome.d.ts.map +1 -0
- package/dist/projected-view-chrome.js +67 -0
- package/dist/projected-view-chrome.js.map +1 -0
- package/dist/projected-view-surface.d.ts +34 -0
- package/dist/projected-view-surface.d.ts.map +1 -0
- package/dist/projected-view-surface.js +40 -0
- package/dist/projected-view-surface.js.map +1 -0
- package/dist/standard-collection-chrome-slot-renderers.d.ts +26 -0
- package/dist/standard-collection-chrome-slot-renderers.d.ts.map +1 -0
- package/dist/standard-collection-chrome-slot-renderers.js +250 -0
- package/dist/standard-collection-chrome-slot-renderers.js.map +1 -0
- package/dist/standard-view-chrome-slot-renderers.d.ts +57 -0
- package/dist/standard-view-chrome-slot-renderers.d.ts.map +1 -0
- package/dist/standard-view-chrome-slot-renderers.js +614 -0
- package/dist/standard-view-chrome-slot-renderers.js.map +1 -0
- package/package.json +68 -0
- package/src/document-workspace-surface-slot-renderers.tsx +395 -0
- package/src/index.ts +53 -0
- package/src/navigation-shell-frame-renderer-registry.ts +29 -0
- package/src/navigation-shell-slot-renderer-registry.ts +46 -0
- package/src/page-host-unavailable-renderer.tsx +79 -0
- package/src/presentation-action-group.tsx +475 -0
- package/src/presentation-badge-target-interpreter.ts +54 -0
- package/src/presentation-component-groups.ts +2505 -0
- package/src/presentation-component-system-diagnostics.ts +848 -0
- package/src/presentation-component-system.ts +365 -0
- package/src/presentation-icon-diagnostics.ts +53 -0
- package/src/presentation-icon-registry.tsx +181 -0
- package/src/presentation-projection-trace-panel.tsx +140 -0
- package/src/presentation-routed-surface-host.tsx +48 -0
- package/src/presentation-shadcn-component-system.ts +102 -0
- package/src/presentation-standard-renderers.tsx +1290 -0
- package/src/presentation-surface-renderer.tsx +263 -0
- package/src/presentation-value-renderers.tsx +40 -0
- package/src/process-task-icons.tsx +258 -0
- package/src/projected-activity-state.tsx +63 -0
- package/src/projected-collection-action-runtime-diagnostics.ts +22 -0
- package/src/projected-collection-view.tsx +1273 -0
- package/src/projected-document-action-status-notices.tsx +66 -0
- package/src/projected-document-badges.tsx +134 -0
- package/src/projected-document-editor-surface.tsx +808 -0
- package/src/projected-document-workspace-notices.tsx +77 -0
- package/src/projected-document-workspace-prompt-child-view-registry.ts +99 -0
- package/src/projected-document-workspace-prompt-child-view-renderers.tsx +205 -0
- package/src/projected-document-workspace-shell.tsx +427 -0
- package/src/projected-document-workspace.tsx +216 -0
- package/src/projected-field-value-rendering.tsx +704 -0
- package/src/projected-inline-list.tsx +434 -0
- package/src/projected-input-form.tsx +1218 -0
- package/src/projected-metric-dashboard.tsx +106 -0
- package/src/projected-metric-strip.tsx +244 -0
- package/src/projected-navigation-shell-view-host.tsx +177 -0
- package/src/projected-navigation-shell.tsx +219 -0
- package/src/projected-presentation-badges.tsx +95 -0
- package/src/projected-presentation-diagnostics.tsx +120 -0
- package/src/projected-presentation-flow-layer.tsx +186 -0
- package/src/projected-process-task-notices.tsx +501 -0
- package/src/projected-prompt-child-view-renderer.tsx +698 -0
- package/src/projected-prompt-document-preview.tsx +197 -0
- package/src/projected-prompt-view.tsx +592 -0
- package/src/projected-query-form.tsx +286 -0
- package/src/projected-record-details.tsx +133 -0
- package/src/projected-routed-surface-runtime.tsx +713 -0
- package/src/projected-tabs-view.tsx +308 -0
- package/src/projected-view-chrome.tsx +148 -0
- package/src/projected-view-surface.tsx +131 -0
- package/src/standard-collection-chrome-slot-renderers.tsx +391 -0
- package/src/standard-view-chrome-slot-renderers.tsx +1064 -0
|
@@ -0,0 +1,808 @@
|
|
|
1
|
+
import { Fragment, useMemo, type CSSProperties, type ReactNode } from 'react'
|
|
2
|
+
|
|
3
|
+
import {
|
|
4
|
+
findPresentationView,
|
|
5
|
+
formatPresentationValue,
|
|
6
|
+
isViewChromeSlotKind,
|
|
7
|
+
documentWorkspaceSurfaceSlotRoleKeys,
|
|
8
|
+
projectDocumentWorkspaceSurfaceSlotDiagnostics,
|
|
9
|
+
resolveDocumentWorkspaceSurfaceSlotRoleKey,
|
|
10
|
+
resolveDocumentWorkspaceSurfaceSlots,
|
|
11
|
+
resolvePresentationContent,
|
|
12
|
+
resolvePresentationValue,
|
|
13
|
+
type DocumentEditorLayout,
|
|
14
|
+
type LayoutNodeDefinition,
|
|
15
|
+
type PresentationDataSourceResolver,
|
|
16
|
+
type ProjectionDefinition,
|
|
17
|
+
type ResolvedDocumentWorkspaceSurfaceSlot,
|
|
18
|
+
type ViewChromeSlotDefinition,
|
|
19
|
+
type ViewChromeSlotKind,
|
|
20
|
+
type ViewDefinition,
|
|
21
|
+
type WorkspaceDefinition,
|
|
22
|
+
type WorkspaceLayoutDefinition,
|
|
23
|
+
} from '@cohesivesystems/presentation-core'
|
|
24
|
+
import {
|
|
25
|
+
type PresentationActionGroupOptions,
|
|
26
|
+
} from './presentation-action-group'
|
|
27
|
+
import type {
|
|
28
|
+
PresentationShadcnComponentSystem as PresentationComponentSystem,
|
|
29
|
+
} from './presentation-shadcn-component-system'
|
|
30
|
+
import type {
|
|
31
|
+
PresentationDesignSystem,
|
|
32
|
+
} from '@cohesivesystems/presentation-tailwind'
|
|
33
|
+
import type { ProjectedMetricValue } from './projected-metric-strip'
|
|
34
|
+
import {
|
|
35
|
+
resolvePresentationRoutedSurfaceClassName,
|
|
36
|
+
resolvePresentationRoutedSurfaceContentClassName,
|
|
37
|
+
} from '@cohesivesystems/presentation-tailwind'
|
|
38
|
+
import {
|
|
39
|
+
layoutNodeKindLabels,
|
|
40
|
+
layoutNodeKinds,
|
|
41
|
+
layoutOrientationLabels,
|
|
42
|
+
layoutOrientations,
|
|
43
|
+
viewChromeSlotKinds,
|
|
44
|
+
viewRegionKindLabels,
|
|
45
|
+
viewRegionKinds,
|
|
46
|
+
} from '@cohesivesystems/presentation-contracts'
|
|
47
|
+
import type {
|
|
48
|
+
PresentationBadgeTargetInterpreterRegistry,
|
|
49
|
+
} from './presentation-badge-target-interpreter'
|
|
50
|
+
import {
|
|
51
|
+
renderStandardViewChromeSlot,
|
|
52
|
+
type ProjectedViewChromeSlotRenderContext,
|
|
53
|
+
} from './standard-view-chrome-slot-renderers'
|
|
54
|
+
import {
|
|
55
|
+
mergeDocumentWorkspaceSurfaceSlotRendererRegistries,
|
|
56
|
+
projectDocumentWorkspaceSurfaceSlotRendererDiagnostics,
|
|
57
|
+
resolveDocumentWorkspaceSurfaceSlotRenderer,
|
|
58
|
+
standardDocumentWorkspaceSurfaceSlotRenderers,
|
|
59
|
+
type DocumentWorkspaceSurfaceSlotRendererRegistry,
|
|
60
|
+
type DocumentWorkspaceSurfaceSlotRenderContext,
|
|
61
|
+
} from './document-workspace-surface-slot-renderers'
|
|
62
|
+
import {
|
|
63
|
+
usePresentationModule,
|
|
64
|
+
useRegisterPresentationProjectionDiagnostics,
|
|
65
|
+
} from '@cohesivesystems/presentation-react'
|
|
66
|
+
|
|
67
|
+
export type {
|
|
68
|
+
DocumentEditorLayout,
|
|
69
|
+
} from '@cohesivesystems/presentation-core'
|
|
70
|
+
|
|
71
|
+
type ProjectedDocumentModuleLike = ReturnType<typeof usePresentationModule>
|
|
72
|
+
|
|
73
|
+
export interface ProjectedDocumentEditorSurfaceProps<TActionContext> {
|
|
74
|
+
readonly actionContext: TActionContext
|
|
75
|
+
readonly actionGroupOptions?: PresentationActionGroupOptions<TActionContext>
|
|
76
|
+
readonly activeLayoutModeId?: string | null
|
|
77
|
+
readonly activeViewId: string
|
|
78
|
+
readonly children?: ReactNode
|
|
79
|
+
readonly className?: string
|
|
80
|
+
readonly componentSystem: PresentationComponentSystem
|
|
81
|
+
readonly dataSourceResolver: PresentationDataSourceResolver
|
|
82
|
+
readonly designSystem: PresentationDesignSystem
|
|
83
|
+
readonly documentViewIds?: readonly string[]
|
|
84
|
+
readonly fallbackDescription: string
|
|
85
|
+
readonly fallbackTitle: string
|
|
86
|
+
readonly fallbackViewIds: readonly string[]
|
|
87
|
+
readonly headerContent?: ReactNode
|
|
88
|
+
readonly layout: DocumentEditorLayout
|
|
89
|
+
readonly metadataBadgeInterpreters?: PresentationBadgeTargetInterpreterRegistry
|
|
90
|
+
readonly metadataEntityReferenceRole?: string | null
|
|
91
|
+
readonly metricMessage?: ReactNode
|
|
92
|
+
readonly metricValues?: Readonly<Record<string, ProjectedMetricValue>>
|
|
93
|
+
readonly onActiveViewIdChange: (viewId: string) => void
|
|
94
|
+
readonly onLayoutChange: (layout: DocumentEditorLayout) => void
|
|
95
|
+
readonly pageViewId: string
|
|
96
|
+
readonly projections?: readonly ProjectionDefinition[]
|
|
97
|
+
readonly renderDocumentView: (viewId: string) => ReactNode
|
|
98
|
+
readonly renderDocumentViewState?: (content: ReactNode) => ReactNode
|
|
99
|
+
readonly renderViewChromeSlot?: (
|
|
100
|
+
context: ProjectedViewChromeSlotRenderContext<TActionContext>,
|
|
101
|
+
) => ReactNode
|
|
102
|
+
readonly readMetadataBadgeRole?:
|
|
103
|
+
ProjectedViewChromeSlotRenderContext<TActionContext>['readMetadataBadgeRole']
|
|
104
|
+
readonly readMetadataFieldRole?:
|
|
105
|
+
ProjectedViewChromeSlotRenderContext<TActionContext>['readMetadataFieldRole']
|
|
106
|
+
readonly resource: unknown
|
|
107
|
+
readonly surfaceSlotRenderers?: DocumentWorkspaceSurfaceSlotRendererRegistry<TActionContext>
|
|
108
|
+
readonly workspace?: WorkspaceDefinition | null
|
|
109
|
+
readonly workspaceLayout?: WorkspaceLayoutDefinition | null
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
const emptyMetricValues: Readonly<Record<string, ProjectedMetricValue>> = {}
|
|
113
|
+
|
|
114
|
+
export function ProjectedDocumentEditorSurface<TActionContext>({
|
|
115
|
+
actionContext,
|
|
116
|
+
actionGroupOptions,
|
|
117
|
+
activeLayoutModeId,
|
|
118
|
+
activeViewId,
|
|
119
|
+
children,
|
|
120
|
+
className,
|
|
121
|
+
componentSystem,
|
|
122
|
+
dataSourceResolver,
|
|
123
|
+
designSystem,
|
|
124
|
+
documentViewIds: documentViewIdsOverride,
|
|
125
|
+
fallbackDescription,
|
|
126
|
+
fallbackTitle,
|
|
127
|
+
fallbackViewIds,
|
|
128
|
+
headerContent,
|
|
129
|
+
layout,
|
|
130
|
+
metadataBadgeInterpreters,
|
|
131
|
+
metadataEntityReferenceRole,
|
|
132
|
+
metricMessage,
|
|
133
|
+
metricValues = emptyMetricValues,
|
|
134
|
+
onActiveViewIdChange,
|
|
135
|
+
onLayoutChange,
|
|
136
|
+
pageViewId,
|
|
137
|
+
projections = [],
|
|
138
|
+
renderDocumentView,
|
|
139
|
+
renderDocumentViewState,
|
|
140
|
+
renderViewChromeSlot = renderStandardViewChromeSlot,
|
|
141
|
+
readMetadataBadgeRole,
|
|
142
|
+
readMetadataFieldRole,
|
|
143
|
+
resource,
|
|
144
|
+
surfaceSlotRenderers: surfaceSlotRendererOverrides,
|
|
145
|
+
workspace,
|
|
146
|
+
workspaceLayout,
|
|
147
|
+
}: ProjectedDocumentEditorSurfaceProps<TActionContext>) {
|
|
148
|
+
const module = usePresentationModule()
|
|
149
|
+
const pageView = findPresentationView(module, pageViewId)
|
|
150
|
+
const surfaceSlots = useMemo(
|
|
151
|
+
() => resolveDocumentWorkspaceSurfaceSlots(module, pageView, workspace),
|
|
152
|
+
[module, pageView, workspace],
|
|
153
|
+
)
|
|
154
|
+
const headerSlot = surfaceSlots.header
|
|
155
|
+
const primarySurfaceSlot = surfaceSlots.primarySurface
|
|
156
|
+
const headerView = headerSlot.view
|
|
157
|
+
const workspaceView = primarySurfaceSlot.view
|
|
158
|
+
const surfaceSlotRenderers = useMemo(
|
|
159
|
+
() => mergeDocumentWorkspaceSurfaceSlotRendererRegistries(
|
|
160
|
+
standardDocumentWorkspaceSurfaceSlotRenderers,
|
|
161
|
+
surfaceSlotRendererOverrides,
|
|
162
|
+
),
|
|
163
|
+
[surfaceSlotRendererOverrides],
|
|
164
|
+
)
|
|
165
|
+
const renderedSurfaceSlots = useMemo(
|
|
166
|
+
() => surfaceSlots.all.filter((slot) =>
|
|
167
|
+
Boolean(resolveDocumentWorkspaceSurfaceSlotRenderer(slot, surfaceSlotRenderers))),
|
|
168
|
+
[surfaceSlotRenderers, surfaceSlots],
|
|
169
|
+
)
|
|
170
|
+
const surfaceSlotDiagnostics = useMemo(
|
|
171
|
+
() => {
|
|
172
|
+
const sourceId = `document-workspace-surface-slots:${pageView?.Id ?? pageViewId}`
|
|
173
|
+
return [
|
|
174
|
+
...projectDocumentWorkspaceSurfaceSlotDiagnostics({
|
|
175
|
+
declaredSlots: surfaceSlots.all,
|
|
176
|
+
pageView,
|
|
177
|
+
renderedSlots: renderedSurfaceSlots,
|
|
178
|
+
sourceId,
|
|
179
|
+
}),
|
|
180
|
+
...projectDocumentWorkspaceSurfaceSlotRendererDiagnostics({
|
|
181
|
+
renderers: surfaceSlotRenderers,
|
|
182
|
+
slots: surfaceSlots.all,
|
|
183
|
+
sourceId,
|
|
184
|
+
}),
|
|
185
|
+
]
|
|
186
|
+
},
|
|
187
|
+
[
|
|
188
|
+
pageView,
|
|
189
|
+
pageViewId,
|
|
190
|
+
renderedSurfaceSlots,
|
|
191
|
+
surfaceSlotRenderers,
|
|
192
|
+
surfaceSlots,
|
|
193
|
+
],
|
|
194
|
+
)
|
|
195
|
+
useRegisterPresentationProjectionDiagnostics(
|
|
196
|
+
`document-workspace-surface-slots:${pageView?.Id ?? pageViewId}`,
|
|
197
|
+
surfaceSlotDiagnostics,
|
|
198
|
+
)
|
|
199
|
+
const headerChrome = headerView?.Chrome ?? null
|
|
200
|
+
const workspaceChrome = workspaceView?.Chrome ?? null
|
|
201
|
+
const headerChromeContent = resolvePresentationContent(headerChrome?.Content, resource)
|
|
202
|
+
const workspaceChromeContent = resolvePresentationContent(workspaceChrome?.Content, resource)
|
|
203
|
+
const viewSwitchSlot = findChromeSlot(workspaceView, viewChromeSlotKinds.viewSwitch)
|
|
204
|
+
const documentViewIds =
|
|
205
|
+
documentViewIdsOverride && documentViewIdsOverride.length > 0
|
|
206
|
+
? documentViewIdsOverride
|
|
207
|
+
: resolveDocumentViewIds(viewSwitchSlot, fallbackViewIds)
|
|
208
|
+
const resolvedActiveViewId = documentViewIds.includes(activeViewId)
|
|
209
|
+
? activeViewId
|
|
210
|
+
: documentViewIds[0]
|
|
211
|
+
const headerTitle =
|
|
212
|
+
headerChromeContent.title ??
|
|
213
|
+
formatResolvedPresentationValue(resolvePresentationValue(headerChrome?.Title, resource)) ??
|
|
214
|
+
fallbackTitle
|
|
215
|
+
const headerDescription =
|
|
216
|
+
headerChromeContent.description ??
|
|
217
|
+
headerChromeContent.subtitle ??
|
|
218
|
+
formatResolvedPresentationValue(resolvePresentationValue(headerChrome?.Subtitle, resource)) ??
|
|
219
|
+
fallbackDescription
|
|
220
|
+
const workspaceTitle =
|
|
221
|
+
workspaceChromeContent.title ??
|
|
222
|
+
formatResolvedPresentationValue(resolvePresentationValue(workspaceChrome?.Title, resource)) ??
|
|
223
|
+
workspaceView?.Name ??
|
|
224
|
+
'Document'
|
|
225
|
+
const pageClassName = resolvePresentationRoutedSurfaceClassName(
|
|
226
|
+
pageView?.Design,
|
|
227
|
+
designSystem,
|
|
228
|
+
)
|
|
229
|
+
const contentClassName = resolveDocumentWorkspaceContentClassName(
|
|
230
|
+
pageView?.Design,
|
|
231
|
+
designSystem,
|
|
232
|
+
)
|
|
233
|
+
const documentContent = renderDocumentWorkspaceContent({
|
|
234
|
+
activeLayoutModeId,
|
|
235
|
+
activeViewId: resolvedActiveViewId,
|
|
236
|
+
componentSystem,
|
|
237
|
+
documentViewIds,
|
|
238
|
+
layout,
|
|
239
|
+
module,
|
|
240
|
+
projections,
|
|
241
|
+
renderDocumentView,
|
|
242
|
+
workspaceLayout,
|
|
243
|
+
workspaceView,
|
|
244
|
+
})
|
|
245
|
+
const renderChromeSlot = (
|
|
246
|
+
slot: ViewChromeSlotDefinition,
|
|
247
|
+
view: ViewDefinition | null,
|
|
248
|
+
) =>
|
|
249
|
+
renderViewChromeSlot({
|
|
250
|
+
actionContext,
|
|
251
|
+
actionGroupOptions,
|
|
252
|
+
activeViewId: resolvedActiveViewId,
|
|
253
|
+
componentSystem,
|
|
254
|
+
dataSourceResolver,
|
|
255
|
+
designSystem,
|
|
256
|
+
documentViewIds,
|
|
257
|
+
badgeInterpreters: resolveDocumentChromeSlotBadgeInterpreters(slot, {
|
|
258
|
+
metadataBadgeInterpreters,
|
|
259
|
+
}),
|
|
260
|
+
layout,
|
|
261
|
+
metadataEntityReferenceRole,
|
|
262
|
+
metricMessage: isViewChromeSlotKind(slot, viewChromeSlotKinds.metricStrip)
|
|
263
|
+
? metricMessage
|
|
264
|
+
: undefined,
|
|
265
|
+
metricValues,
|
|
266
|
+
module,
|
|
267
|
+
onActiveViewIdChange,
|
|
268
|
+
onLayoutChange,
|
|
269
|
+
readMetadataBadgeRole,
|
|
270
|
+
readMetadataFieldRole,
|
|
271
|
+
resource,
|
|
272
|
+
slot,
|
|
273
|
+
view,
|
|
274
|
+
workspaceView,
|
|
275
|
+
})
|
|
276
|
+
|
|
277
|
+
const surfaceSlotRenderContext = {
|
|
278
|
+
actionContext,
|
|
279
|
+
auxiliaryContent: children,
|
|
280
|
+
componentSystem,
|
|
281
|
+
documentContent,
|
|
282
|
+
headerContent,
|
|
283
|
+
headerDescription,
|
|
284
|
+
headerTitle,
|
|
285
|
+
pageView,
|
|
286
|
+
pageViewId,
|
|
287
|
+
renderChromeSlot,
|
|
288
|
+
renderDocumentViewState,
|
|
289
|
+
workspaceTitle,
|
|
290
|
+
workspaceView,
|
|
291
|
+
} satisfies Omit<DocumentWorkspaceSurfaceSlotRenderContext<TActionContext>, 'slot'>
|
|
292
|
+
const renderedSlotNodes = surfaceSlots.all.flatMap((slot) => {
|
|
293
|
+
const renderer = resolveDocumentWorkspaceSurfaceSlotRenderer(
|
|
294
|
+
slot,
|
|
295
|
+
surfaceSlotRenderers,
|
|
296
|
+
)
|
|
297
|
+
if (!renderer?.renderer) {
|
|
298
|
+
return []
|
|
299
|
+
}
|
|
300
|
+
|
|
301
|
+
return [{
|
|
302
|
+
id: slot.id,
|
|
303
|
+
node: (
|
|
304
|
+
<Fragment key={slot.id}>
|
|
305
|
+
{renderer.renderer({
|
|
306
|
+
...surfaceSlotRenderContext,
|
|
307
|
+
slot,
|
|
308
|
+
})}
|
|
309
|
+
</Fragment>
|
|
310
|
+
),
|
|
311
|
+
roleKey: resolveDocumentWorkspaceSurfaceSlotRoleKey(slot.role, slot.roleLabel),
|
|
312
|
+
slot,
|
|
313
|
+
}]
|
|
314
|
+
})
|
|
315
|
+
const headerSlotNode = renderedSlotNodes.find((slot) =>
|
|
316
|
+
slot.roleKey === documentWorkspaceSurfaceSlotRoleKeys.header)
|
|
317
|
+
const primarySurfaceSlotNode = renderedSlotNodes.find((slot) =>
|
|
318
|
+
slot.roleKey === documentWorkspaceSurfaceSlotRoleKeys.primarySurface)
|
|
319
|
+
const auxiliarySlotNode = hasRenderableNode(children)
|
|
320
|
+
? renderedSlotNodes.find((slot) =>
|
|
321
|
+
slot.roleKey === documentWorkspaceSurfaceSlotRoleKeys.auxiliary)
|
|
322
|
+
: undefined
|
|
323
|
+
const shouldRenderAuxiliarySidecar =
|
|
324
|
+
primarySurfaceSlotNode &&
|
|
325
|
+
auxiliarySlotNode &&
|
|
326
|
+
isDocumentWorkspaceAuxiliarySidecarSlot(auxiliarySlotNode.slot)
|
|
327
|
+
const groupedSlotIds = new Set(
|
|
328
|
+
[headerSlotNode, primarySurfaceSlotNode, auxiliarySlotNode]
|
|
329
|
+
.flatMap((slot) => (slot ? [slot.id] : [])),
|
|
330
|
+
)
|
|
331
|
+
const remainingSlotNodes = renderedSlotNodes.filter((slot) => !groupedSlotIds.has(slot.id))
|
|
332
|
+
|
|
333
|
+
return componentSystem.documentWorkspaces.DocumentWorkspaceShell({
|
|
334
|
+
className: cn(pageClassName, className),
|
|
335
|
+
contentClassName,
|
|
336
|
+
viewId: pageView?.Id ?? pageViewId,
|
|
337
|
+
children: (
|
|
338
|
+
<div className="grid min-h-0 gap-5">
|
|
339
|
+
{headerSlotNode?.node}
|
|
340
|
+
{shouldRenderAuxiliarySidecar ? (
|
|
341
|
+
<div className="grid min-h-0 gap-y-5 lg:grid-cols-[minmax(0,1fr)_auto] lg:items-start lg:gap-x-0 lg:has-[>aside:not(:empty)]:gap-x-5">
|
|
342
|
+
<div className="min-w-0">{primarySurfaceSlotNode.node}</div>
|
|
343
|
+
<aside className="min-w-0 empty:hidden lg:sticky lg:top-20 lg:w-[clamp(18rem,25vw,24rem)]">
|
|
344
|
+
{auxiliarySlotNode.node}
|
|
345
|
+
</aside>
|
|
346
|
+
</div>
|
|
347
|
+
) : (
|
|
348
|
+
<>
|
|
349
|
+
{primarySurfaceSlotNode?.node}
|
|
350
|
+
{auxiliarySlotNode?.node}
|
|
351
|
+
</>
|
|
352
|
+
)}
|
|
353
|
+
{remainingSlotNodes.map((slot) => slot.node)}
|
|
354
|
+
</div>
|
|
355
|
+
),
|
|
356
|
+
})
|
|
357
|
+
}
|
|
358
|
+
|
|
359
|
+
function findChromeSlot(
|
|
360
|
+
view: ViewDefinition | null,
|
|
361
|
+
slotKind: ViewChromeSlotKind | string | number,
|
|
362
|
+
) {
|
|
363
|
+
return view?.Chrome?.Slots?.find((slot) => isViewChromeSlotKind(slot, slotKind)) ?? null
|
|
364
|
+
}
|
|
365
|
+
|
|
366
|
+
function resolveDocumentViewIds(
|
|
367
|
+
slot: ViewChromeSlotDefinition | null,
|
|
368
|
+
fallbackViewIds: readonly string[],
|
|
369
|
+
) {
|
|
370
|
+
return slot?.ViewIds && slot.ViewIds.length > 0 ? slot.ViewIds : fallbackViewIds
|
|
371
|
+
}
|
|
372
|
+
|
|
373
|
+
function resolveDocumentChromeSlotBadgeInterpreters(
|
|
374
|
+
slot: ViewChromeSlotDefinition,
|
|
375
|
+
{
|
|
376
|
+
metadataBadgeInterpreters,
|
|
377
|
+
}: {
|
|
378
|
+
readonly metadataBadgeInterpreters?: PresentationBadgeTargetInterpreterRegistry
|
|
379
|
+
},
|
|
380
|
+
) {
|
|
381
|
+
if (isViewChromeSlotKind(slot, viewChromeSlotKinds.badgeStrip)) {
|
|
382
|
+
return metadataBadgeInterpreters
|
|
383
|
+
}
|
|
384
|
+
|
|
385
|
+
return undefined
|
|
386
|
+
}
|
|
387
|
+
|
|
388
|
+
function renderDocumentWorkspaceContent({
|
|
389
|
+
activeLayoutModeId,
|
|
390
|
+
activeViewId,
|
|
391
|
+
componentSystem,
|
|
392
|
+
documentViewIds,
|
|
393
|
+
layout,
|
|
394
|
+
module,
|
|
395
|
+
projections,
|
|
396
|
+
renderDocumentView,
|
|
397
|
+
workspaceLayout,
|
|
398
|
+
workspaceView,
|
|
399
|
+
}: {
|
|
400
|
+
readonly activeLayoutModeId?: string | null
|
|
401
|
+
readonly activeViewId: string
|
|
402
|
+
readonly componentSystem: PresentationComponentSystem
|
|
403
|
+
readonly documentViewIds: readonly string[]
|
|
404
|
+
readonly layout: DocumentEditorLayout
|
|
405
|
+
readonly module: ProjectedDocumentModuleLike | null
|
|
406
|
+
readonly projections: readonly ProjectionDefinition[]
|
|
407
|
+
readonly renderDocumentView: (viewId: string) => ReactNode
|
|
408
|
+
readonly workspaceLayout?: WorkspaceLayoutDefinition | null
|
|
409
|
+
readonly workspaceView: ViewDefinition | null
|
|
410
|
+
}) {
|
|
411
|
+
const layoutMode = resolveDocumentWorkspaceLayoutMode({
|
|
412
|
+
activeLayoutModeId,
|
|
413
|
+
layout,
|
|
414
|
+
workspaceLayout,
|
|
415
|
+
})
|
|
416
|
+
if (layoutMode?.Root) {
|
|
417
|
+
return renderDocumentWorkspaceLayoutNode(layoutMode.Root, {
|
|
418
|
+
activeViewId,
|
|
419
|
+
componentSystem,
|
|
420
|
+
documentViewIds,
|
|
421
|
+
module,
|
|
422
|
+
projections,
|
|
423
|
+
renderDocumentView,
|
|
424
|
+
workspaceView,
|
|
425
|
+
})
|
|
426
|
+
}
|
|
427
|
+
|
|
428
|
+
if (layout !== 'split') {
|
|
429
|
+
return renderDocumentView(activeViewId)
|
|
430
|
+
}
|
|
431
|
+
|
|
432
|
+
const jsonViewId = findJsonViewId(module, documentViewIds) ?? documentViewIds[0]
|
|
433
|
+
const secondaryViewId =
|
|
434
|
+
activeViewId !== jsonViewId
|
|
435
|
+
? activeViewId
|
|
436
|
+
: documentViewIds.find((viewId) => viewId !== jsonViewId)
|
|
437
|
+
|
|
438
|
+
if (!jsonViewId || !secondaryViewId) {
|
|
439
|
+
return renderDocumentView(activeViewId)
|
|
440
|
+
}
|
|
441
|
+
|
|
442
|
+
return componentSystem.documentWorkspaces.DocumentWorkspaceLayoutGroup({
|
|
443
|
+
className: 'grid min-h-0 items-stretch gap-4 lg:grid-cols-2',
|
|
444
|
+
orientation: layoutOrientations.horizontal,
|
|
445
|
+
workspaceViewId: workspaceView?.Id ?? null,
|
|
446
|
+
children: (
|
|
447
|
+
<>
|
|
448
|
+
{renderDocumentWorkspacePane({
|
|
449
|
+
children: renderDocumentView(jsonViewId),
|
|
450
|
+
componentSystem,
|
|
451
|
+
title: getDocumentViewLabel(module, workspaceView, jsonViewId),
|
|
452
|
+
viewId: jsonViewId,
|
|
453
|
+
workspaceView,
|
|
454
|
+
})}
|
|
455
|
+
{renderDocumentWorkspacePane({
|
|
456
|
+
children: renderDocumentView(secondaryViewId),
|
|
457
|
+
componentSystem,
|
|
458
|
+
title: getDocumentViewLabel(module, workspaceView, secondaryViewId),
|
|
459
|
+
viewId: secondaryViewId,
|
|
460
|
+
workspaceView,
|
|
461
|
+
})}
|
|
462
|
+
</>
|
|
463
|
+
),
|
|
464
|
+
})
|
|
465
|
+
}
|
|
466
|
+
|
|
467
|
+
interface DocumentWorkspaceLayoutRenderContext {
|
|
468
|
+
readonly activeViewId: string
|
|
469
|
+
readonly componentSystem: PresentationComponentSystem
|
|
470
|
+
readonly documentViewIds: readonly string[]
|
|
471
|
+
readonly module: ProjectedDocumentModuleLike | null
|
|
472
|
+
readonly projections: readonly ProjectionDefinition[]
|
|
473
|
+
readonly renderDocumentView: (viewId: string) => ReactNode
|
|
474
|
+
readonly workspaceView: ViewDefinition | null
|
|
475
|
+
}
|
|
476
|
+
|
|
477
|
+
function renderDocumentWorkspaceLayoutNode(
|
|
478
|
+
node: LayoutNodeDefinition,
|
|
479
|
+
context: DocumentWorkspaceLayoutRenderContext,
|
|
480
|
+
): ReactNode {
|
|
481
|
+
if (isLayoutNodeKind(node.Kind, layoutNodeKinds.splitGroup)) {
|
|
482
|
+
return renderDocumentWorkspaceSplitGroup(node, context)
|
|
483
|
+
}
|
|
484
|
+
|
|
485
|
+
if (isLayoutNodeKind(node.Kind, layoutNodeKinds.tabGroup)) {
|
|
486
|
+
const selectedChild = selectLayoutTabChild(node, context)
|
|
487
|
+
return selectedChild ? renderDocumentWorkspaceLayoutNode(selectedChild, context) : null
|
|
488
|
+
}
|
|
489
|
+
|
|
490
|
+
const viewId = resolveLayoutNodeViewId(node, context)
|
|
491
|
+
if (viewId) {
|
|
492
|
+
return context.renderDocumentView(viewId)
|
|
493
|
+
}
|
|
494
|
+
|
|
495
|
+
const firstChild = node.Children?.[0]
|
|
496
|
+
return firstChild ? renderDocumentWorkspaceLayoutNode(firstChild, context) : null
|
|
497
|
+
}
|
|
498
|
+
|
|
499
|
+
function renderDocumentWorkspaceSplitGroup(
|
|
500
|
+
node: LayoutNodeDefinition,
|
|
501
|
+
context: DocumentWorkspaceLayoutRenderContext,
|
|
502
|
+
) {
|
|
503
|
+
const children = (node.Children ?? []).filter((child) =>
|
|
504
|
+
Boolean(resolveLayoutNodeViewId(child, context) ?? child.Children?.length),
|
|
505
|
+
)
|
|
506
|
+
if (children.length === 0) {
|
|
507
|
+
return null
|
|
508
|
+
}
|
|
509
|
+
|
|
510
|
+
const isHorizontal = isLayoutOrientation(node.Orientation, layoutOrientations.horizontal)
|
|
511
|
+
const gridStyle = createSplitGroupGridStyle(children, isHorizontal)
|
|
512
|
+
|
|
513
|
+
return (
|
|
514
|
+
context.componentSystem.documentWorkspaces.DocumentWorkspaceLayoutGroup({
|
|
515
|
+
className: cn(
|
|
516
|
+
'grid min-h-0 items-stretch gap-4',
|
|
517
|
+
isHorizontal
|
|
518
|
+
? 'lg:grid-cols-[var(--document-workspace-layout-columns)]'
|
|
519
|
+
: 'grid-rows-[var(--document-workspace-layout-rows)]',
|
|
520
|
+
),
|
|
521
|
+
layoutNodeId: node.Id,
|
|
522
|
+
orientation: node.Orientation,
|
|
523
|
+
style: gridStyle,
|
|
524
|
+
workspaceViewId: context.workspaceView?.Id ?? null,
|
|
525
|
+
children: children.map((child) => (
|
|
526
|
+
<Fragment key={child.Id}>
|
|
527
|
+
{renderDocumentWorkspacePane({
|
|
528
|
+
children: renderDocumentWorkspaceLayoutNode(child, context),
|
|
529
|
+
componentSystem: context.componentSystem,
|
|
530
|
+
layoutNodeId: child.Id,
|
|
531
|
+
title: resolveLayoutNodeTitle(child, context),
|
|
532
|
+
viewId: resolveLayoutNodeViewId(child, context),
|
|
533
|
+
workspaceView: context.workspaceView,
|
|
534
|
+
})}
|
|
535
|
+
</Fragment>
|
|
536
|
+
)),
|
|
537
|
+
})
|
|
538
|
+
)
|
|
539
|
+
}
|
|
540
|
+
|
|
541
|
+
function resolveDocumentWorkspaceLayoutMode({
|
|
542
|
+
activeLayoutModeId,
|
|
543
|
+
layout,
|
|
544
|
+
workspaceLayout,
|
|
545
|
+
}: {
|
|
546
|
+
readonly activeLayoutModeId?: string | null
|
|
547
|
+
readonly layout: DocumentEditorLayout
|
|
548
|
+
readonly workspaceLayout?: WorkspaceLayoutDefinition | null
|
|
549
|
+
}) {
|
|
550
|
+
const modes = workspaceLayout?.Modes ?? []
|
|
551
|
+
const requestedModeId =
|
|
552
|
+
activeLayoutModeId ??
|
|
553
|
+
(layout === 'split' ? 'split' : workspaceLayout?.DefaultModeId ?? 'tabs')
|
|
554
|
+
|
|
555
|
+
return (
|
|
556
|
+
modes.find((mode) => mode.Id === requestedModeId) ??
|
|
557
|
+
modes.find((mode) => mode.Id === workspaceLayout?.DefaultModeId) ??
|
|
558
|
+
modes[0] ??
|
|
559
|
+
null
|
|
560
|
+
)
|
|
561
|
+
}
|
|
562
|
+
|
|
563
|
+
function selectLayoutTabChild(
|
|
564
|
+
node: LayoutNodeDefinition,
|
|
565
|
+
context: DocumentWorkspaceLayoutRenderContext,
|
|
566
|
+
) {
|
|
567
|
+
const children = node.Children ?? []
|
|
568
|
+
return (
|
|
569
|
+
children.find((child) => {
|
|
570
|
+
const viewIds = resolveLayoutNodeViewIds(child, context)
|
|
571
|
+
return viewIds.includes(context.activeViewId)
|
|
572
|
+
}) ??
|
|
573
|
+
children.find((child) => {
|
|
574
|
+
const viewId = resolveLayoutNodeViewId(child, context)
|
|
575
|
+
return viewId && context.documentViewIds.includes(viewId)
|
|
576
|
+
}) ??
|
|
577
|
+
children[0] ??
|
|
578
|
+
null
|
|
579
|
+
)
|
|
580
|
+
}
|
|
581
|
+
|
|
582
|
+
function resolveLayoutNodeTitle(
|
|
583
|
+
node: LayoutNodeDefinition,
|
|
584
|
+
context: DocumentWorkspaceLayoutRenderContext,
|
|
585
|
+
) {
|
|
586
|
+
const selectedNode = isLayoutNodeKind(node.Kind, layoutNodeKinds.tabGroup)
|
|
587
|
+
? selectLayoutTabChild(node, context) ?? node
|
|
588
|
+
: node
|
|
589
|
+
const viewId = resolveLayoutNodeViewId(selectedNode, context)
|
|
590
|
+
return viewId
|
|
591
|
+
? getDocumentViewLabel(context.module, context.workspaceView, viewId)
|
|
592
|
+
: selectedNode.Id
|
|
593
|
+
}
|
|
594
|
+
|
|
595
|
+
function resolveLayoutNodeViewId(
|
|
596
|
+
node: LayoutNodeDefinition,
|
|
597
|
+
context: DocumentWorkspaceLayoutRenderContext,
|
|
598
|
+
) {
|
|
599
|
+
return resolveLayoutNodeViewIds(node, context)[0] ?? null
|
|
600
|
+
}
|
|
601
|
+
|
|
602
|
+
function resolveLayoutNodeViewIds(
|
|
603
|
+
node: LayoutNodeDefinition,
|
|
604
|
+
context: DocumentWorkspaceLayoutRenderContext,
|
|
605
|
+
) {
|
|
606
|
+
const projectionViewIds = (node.ProjectionIds ?? [])
|
|
607
|
+
.map((projectionId) => {
|
|
608
|
+
const projection = context.projections.find(
|
|
609
|
+
(candidate) => candidate.Id === projectionId,
|
|
610
|
+
)
|
|
611
|
+
return projection?.ViewId ?? projection?.Id ?? null
|
|
612
|
+
})
|
|
613
|
+
.filter((viewId): viewId is string => Boolean(viewId))
|
|
614
|
+
|
|
615
|
+
return [...projectionViewIds, ...(node.ViewIds ?? [])]
|
|
616
|
+
}
|
|
617
|
+
|
|
618
|
+
function createSplitGroupGridStyle(
|
|
619
|
+
children: readonly LayoutNodeDefinition[],
|
|
620
|
+
isHorizontal: boolean,
|
|
621
|
+
) {
|
|
622
|
+
if (children.length <= 1) {
|
|
623
|
+
return undefined
|
|
624
|
+
}
|
|
625
|
+
|
|
626
|
+
const trackSizes = children.map((child) => {
|
|
627
|
+
const fraction = typeof child.Size === 'number' && child.Size > 0
|
|
628
|
+
? child.Size
|
|
629
|
+
: 1
|
|
630
|
+
return `minmax(0, ${fraction}fr)`
|
|
631
|
+
})
|
|
632
|
+
|
|
633
|
+
return isHorizontal
|
|
634
|
+
? ({
|
|
635
|
+
'--document-workspace-layout-columns': trackSizes.join(' '),
|
|
636
|
+
} as CSSProperties)
|
|
637
|
+
: ({
|
|
638
|
+
'--document-workspace-layout-rows': trackSizes.join(' '),
|
|
639
|
+
} as CSSProperties)
|
|
640
|
+
}
|
|
641
|
+
|
|
642
|
+
function renderDocumentWorkspacePane({
|
|
643
|
+
children,
|
|
644
|
+
componentSystem,
|
|
645
|
+
layoutNodeId,
|
|
646
|
+
title,
|
|
647
|
+
viewId,
|
|
648
|
+
workspaceView,
|
|
649
|
+
}: {
|
|
650
|
+
readonly children: ReactNode
|
|
651
|
+
readonly componentSystem: PresentationComponentSystem
|
|
652
|
+
readonly layoutNodeId?: string | null
|
|
653
|
+
readonly title: string
|
|
654
|
+
readonly viewId?: string | null
|
|
655
|
+
readonly workspaceView: ViewDefinition | null
|
|
656
|
+
}) {
|
|
657
|
+
return componentSystem.documentWorkspaces.DocumentWorkspaceLayoutPane({
|
|
658
|
+
children,
|
|
659
|
+
layoutNodeId,
|
|
660
|
+
title,
|
|
661
|
+
viewId,
|
|
662
|
+
workspaceViewId: workspaceView?.Id ?? null,
|
|
663
|
+
})
|
|
664
|
+
}
|
|
665
|
+
|
|
666
|
+
function findJsonViewId(
|
|
667
|
+
module: ProjectedDocumentModuleLike | null,
|
|
668
|
+
viewIds: readonly string[],
|
|
669
|
+
) {
|
|
670
|
+
return (
|
|
671
|
+
viewIds.find((viewId) => {
|
|
672
|
+
const view = findPresentationView(module, viewId)
|
|
673
|
+
const label = `${view?.Name ?? ''} ${viewId}`.toLowerCase()
|
|
674
|
+
return label.includes('json')
|
|
675
|
+
}) ?? null
|
|
676
|
+
)
|
|
677
|
+
}
|
|
678
|
+
|
|
679
|
+
function getDocumentViewLabel(
|
|
680
|
+
module: ProjectedDocumentModuleLike | null,
|
|
681
|
+
workspaceView: ViewDefinition | null,
|
|
682
|
+
viewId: string,
|
|
683
|
+
) {
|
|
684
|
+
const region = workspaceView?.Regions?.find((candidate) =>
|
|
685
|
+
candidate.ViewIds?.includes(viewId),
|
|
686
|
+
)
|
|
687
|
+
return (
|
|
688
|
+
region?.Name ??
|
|
689
|
+
findPresentationView(module, viewId)?.Name ??
|
|
690
|
+
getDocumentViewFallbackLabel(viewId)
|
|
691
|
+
)
|
|
692
|
+
}
|
|
693
|
+
|
|
694
|
+
function getDocumentViewFallbackLabel(viewId: string) {
|
|
695
|
+
const normalized = viewId.toLocaleLowerCase()
|
|
696
|
+
if (normalized.includes('json')) {
|
|
697
|
+
return 'JSON'
|
|
698
|
+
}
|
|
699
|
+
|
|
700
|
+
if (normalized.includes('structure')) {
|
|
701
|
+
return 'Structure'
|
|
702
|
+
}
|
|
703
|
+
|
|
704
|
+
if (normalized.includes('types')) {
|
|
705
|
+
return 'Types'
|
|
706
|
+
}
|
|
707
|
+
|
|
708
|
+
return viewId
|
|
709
|
+
}
|
|
710
|
+
|
|
711
|
+
function formatResolvedPresentationValue(value: unknown) {
|
|
712
|
+
return value === null || value === undefined ? null : formatPresentationValue(value)
|
|
713
|
+
}
|
|
714
|
+
|
|
715
|
+
function isLayoutNodeKind(
|
|
716
|
+
value: string | number,
|
|
717
|
+
expected: keyof typeof layoutNodeKindLabels,
|
|
718
|
+
) {
|
|
719
|
+
return isEnumDiscriminator(value, expected, layoutNodeKindLabels[expected])
|
|
720
|
+
}
|
|
721
|
+
|
|
722
|
+
function isLayoutOrientation(
|
|
723
|
+
value: string | number,
|
|
724
|
+
expected: keyof typeof layoutOrientationLabels,
|
|
725
|
+
) {
|
|
726
|
+
return isEnumDiscriminator(value, expected, layoutOrientationLabels[expected])
|
|
727
|
+
}
|
|
728
|
+
|
|
729
|
+
function isEnumDiscriminator(
|
|
730
|
+
value: string | number,
|
|
731
|
+
expected: string | number,
|
|
732
|
+
expectedLabel: string,
|
|
733
|
+
) {
|
|
734
|
+
return (
|
|
735
|
+
value === expected ||
|
|
736
|
+
normalizeEnumDiscriminator(value) === normalizeEnumDiscriminator(expectedLabel)
|
|
737
|
+
)
|
|
738
|
+
}
|
|
739
|
+
|
|
740
|
+
function normalizeEnumDiscriminator(value: string | number) {
|
|
741
|
+
return String(value).replace(/[-_\s]/g, '').toLocaleLowerCase()
|
|
742
|
+
}
|
|
743
|
+
|
|
744
|
+
function resolveDocumentWorkspaceContentClassName(
|
|
745
|
+
design: ViewDefinition['Design'] | null | undefined,
|
|
746
|
+
designSystem: PresentationDesignSystem,
|
|
747
|
+
) {
|
|
748
|
+
return cn(
|
|
749
|
+
withoutTailwindMaxWidthClassNames(
|
|
750
|
+
resolvePresentationRoutedSurfaceContentClassName(design, designSystem),
|
|
751
|
+
),
|
|
752
|
+
'w-full max-w-none',
|
|
753
|
+
)
|
|
754
|
+
}
|
|
755
|
+
|
|
756
|
+
function withoutTailwindMaxWidthClassNames(className: string) {
|
|
757
|
+
return className
|
|
758
|
+
.split(/\s+/)
|
|
759
|
+
.filter((token) => token.length > 0 && !isTailwindMaxWidthClassName(token))
|
|
760
|
+
.join(' ')
|
|
761
|
+
}
|
|
762
|
+
|
|
763
|
+
function isTailwindMaxWidthClassName(token: string) {
|
|
764
|
+
const utilityName = token.slice(token.lastIndexOf(':') + 1)
|
|
765
|
+
return utilityName.startsWith('max-w-')
|
|
766
|
+
}
|
|
767
|
+
|
|
768
|
+
function isDocumentWorkspaceAuxiliarySidecarSlot(
|
|
769
|
+
slot: ResolvedDocumentWorkspaceSurfaceSlot,
|
|
770
|
+
) {
|
|
771
|
+
return slot.descriptor.regionKind !== null &&
|
|
772
|
+
slot.descriptor.regionKind !== undefined &&
|
|
773
|
+
(isEnumDiscriminator(
|
|
774
|
+
slot.descriptor.regionKind,
|
|
775
|
+
viewRegionKinds.sidebar,
|
|
776
|
+
viewRegionKindLabels[viewRegionKinds.sidebar],
|
|
777
|
+
) ||
|
|
778
|
+
isEnumDiscriminator(
|
|
779
|
+
slot.descriptor.regionKind,
|
|
780
|
+
viewRegionKinds.panel,
|
|
781
|
+
viewRegionKindLabels[viewRegionKinds.panel],
|
|
782
|
+
) ||
|
|
783
|
+
isEnumDiscriminator(
|
|
784
|
+
slot.descriptor.regionKind,
|
|
785
|
+
viewRegionKinds.inspector,
|
|
786
|
+
viewRegionKindLabels[viewRegionKinds.inspector],
|
|
787
|
+
))
|
|
788
|
+
}
|
|
789
|
+
|
|
790
|
+
function hasRenderableNode(node: ReactNode): boolean {
|
|
791
|
+
if (
|
|
792
|
+
node === null ||
|
|
793
|
+
node === undefined ||
|
|
794
|
+
typeof node === 'boolean'
|
|
795
|
+
) {
|
|
796
|
+
return false
|
|
797
|
+
}
|
|
798
|
+
|
|
799
|
+
if (Array.isArray(node)) {
|
|
800
|
+
return node.some(hasRenderableNode)
|
|
801
|
+
}
|
|
802
|
+
|
|
803
|
+
return true
|
|
804
|
+
}
|
|
805
|
+
|
|
806
|
+
function cn(...values: readonly (false | null | string | undefined)[]) {
|
|
807
|
+
return values.filter(Boolean).join(' ')
|
|
808
|
+
}
|