@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,263 @@
|
|
|
1
|
+
import { useCallback, useMemo, type ReactNode } from 'react'
|
|
2
|
+
|
|
3
|
+
import {
|
|
4
|
+
createPresentationDataSourceResolver,
|
|
5
|
+
defaultPresentationComponentSet,
|
|
6
|
+
findPresentationView,
|
|
7
|
+
getRegionViewIds,
|
|
8
|
+
type PresentationModuleDefinition,
|
|
9
|
+
type PresentationDataSourceResolver,
|
|
10
|
+
type PresentationDataSourceStateMap,
|
|
11
|
+
type PresentationSurface,
|
|
12
|
+
type ViewDefinition,
|
|
13
|
+
} from '@cohesivesystems/presentation-core'
|
|
14
|
+
import {
|
|
15
|
+
usePresentationModule,
|
|
16
|
+
resolvePresentationViewRenderer,
|
|
17
|
+
type PresentationRendererRegistry,
|
|
18
|
+
type PresentationViewRegionRenderOptions,
|
|
19
|
+
type PresentationViewRendererResolution,
|
|
20
|
+
} from '@cohesivesystems/presentation-react'
|
|
21
|
+
import { ProjectedStatusBlock } from './projected-activity-state'
|
|
22
|
+
|
|
23
|
+
export interface PresentationSurfaceRendererProps<TContext> {
|
|
24
|
+
readonly componentSet?: string
|
|
25
|
+
readonly context: TContext
|
|
26
|
+
readonly dataSources: PresentationDataSourceStateMap
|
|
27
|
+
readonly rendererRegistry: PresentationRendererRegistry<TContext>
|
|
28
|
+
readonly renderUnknownView?: PresentationUnknownViewRenderer<TContext>
|
|
29
|
+
readonly surface: PresentationSurface | null
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
export interface PresentationUnknownViewRenderContext<TContext> {
|
|
33
|
+
readonly context: TContext
|
|
34
|
+
readonly module: PresentationModuleDefinition | null
|
|
35
|
+
readonly reason:
|
|
36
|
+
| 'missing-module'
|
|
37
|
+
| 'missing-renderer'
|
|
38
|
+
| 'missing-root-view'
|
|
39
|
+
| 'missing-surface'
|
|
40
|
+
| 'missing-view'
|
|
41
|
+
readonly resolution?: PresentationViewRendererResolution<TContext>
|
|
42
|
+
readonly surface: PresentationSurface | null
|
|
43
|
+
readonly view: ViewDefinition | null
|
|
44
|
+
readonly viewId: string | null
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
export type PresentationUnknownViewRenderer<TContext> = (
|
|
48
|
+
context: PresentationUnknownViewRenderContext<TContext>,
|
|
49
|
+
) => ReactNode
|
|
50
|
+
|
|
51
|
+
interface PresentationSurfaceViewRendererProps<TContext> {
|
|
52
|
+
readonly componentSet: string
|
|
53
|
+
readonly context: TContext
|
|
54
|
+
readonly dataSourceResolver: PresentationDataSourceResolver
|
|
55
|
+
readonly module: PresentationModuleDefinition
|
|
56
|
+
readonly rendererRegistry: PresentationRendererRegistry<TContext>
|
|
57
|
+
readonly renderUnknownView: PresentationUnknownViewRenderer<TContext>
|
|
58
|
+
readonly surface: PresentationSurface
|
|
59
|
+
readonly viewId: string
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
export function PresentationSurfaceRenderer<TContext>({
|
|
63
|
+
componentSet = defaultPresentationComponentSet,
|
|
64
|
+
context,
|
|
65
|
+
dataSources,
|
|
66
|
+
rendererRegistry,
|
|
67
|
+
renderUnknownView = renderDefaultUnknownView,
|
|
68
|
+
surface,
|
|
69
|
+
}: PresentationSurfaceRendererProps<TContext>) {
|
|
70
|
+
const module = usePresentationModule()
|
|
71
|
+
const dataSourceResolver = useMemo(
|
|
72
|
+
() => createPresentationDataSourceResolver(dataSources),
|
|
73
|
+
[dataSources],
|
|
74
|
+
)
|
|
75
|
+
|
|
76
|
+
if (!module) {
|
|
77
|
+
return renderUnknownView({
|
|
78
|
+
context,
|
|
79
|
+
module,
|
|
80
|
+
reason: 'missing-module',
|
|
81
|
+
surface,
|
|
82
|
+
view: null,
|
|
83
|
+
viewId: surface?.rootViewId ?? null,
|
|
84
|
+
})
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
if (!surface) {
|
|
88
|
+
return renderUnknownView({
|
|
89
|
+
context,
|
|
90
|
+
module,
|
|
91
|
+
reason: 'missing-surface',
|
|
92
|
+
surface,
|
|
93
|
+
view: null,
|
|
94
|
+
viewId: null,
|
|
95
|
+
})
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
const rootViewId = surface.rootView?.Id ?? surface.rootViewId
|
|
99
|
+
if (!rootViewId) {
|
|
100
|
+
return renderUnknownView({
|
|
101
|
+
context,
|
|
102
|
+
module,
|
|
103
|
+
reason: 'missing-root-view',
|
|
104
|
+
surface,
|
|
105
|
+
view: null,
|
|
106
|
+
viewId: null,
|
|
107
|
+
})
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
return (
|
|
111
|
+
<PresentationSurfaceViewRenderer
|
|
112
|
+
componentSet={componentSet}
|
|
113
|
+
context={context}
|
|
114
|
+
dataSourceResolver={dataSourceResolver}
|
|
115
|
+
module={module}
|
|
116
|
+
rendererRegistry={rendererRegistry}
|
|
117
|
+
renderUnknownView={renderUnknownView}
|
|
118
|
+
surface={surface}
|
|
119
|
+
viewId={rootViewId}
|
|
120
|
+
/>
|
|
121
|
+
)
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
function PresentationSurfaceViewRenderer<TContext>({
|
|
125
|
+
componentSet,
|
|
126
|
+
context,
|
|
127
|
+
dataSourceResolver,
|
|
128
|
+
module,
|
|
129
|
+
rendererRegistry,
|
|
130
|
+
renderUnknownView,
|
|
131
|
+
surface,
|
|
132
|
+
viewId,
|
|
133
|
+
}: PresentationSurfaceViewRendererProps<TContext>) {
|
|
134
|
+
const view = findPresentationView<ViewDefinition>(module, viewId)
|
|
135
|
+
const renderView = useCallback(
|
|
136
|
+
(childViewId: string) => (
|
|
137
|
+
<PresentationSurfaceViewRenderer
|
|
138
|
+
componentSet={componentSet}
|
|
139
|
+
context={context}
|
|
140
|
+
dataSourceResolver={dataSourceResolver}
|
|
141
|
+
module={module}
|
|
142
|
+
rendererRegistry={rendererRegistry}
|
|
143
|
+
renderUnknownView={renderUnknownView}
|
|
144
|
+
surface={surface}
|
|
145
|
+
viewId={childViewId}
|
|
146
|
+
/>
|
|
147
|
+
),
|
|
148
|
+
[
|
|
149
|
+
componentSet,
|
|
150
|
+
context,
|
|
151
|
+
dataSourceResolver,
|
|
152
|
+
module,
|
|
153
|
+
rendererRegistry,
|
|
154
|
+
renderUnknownView,
|
|
155
|
+
surface,
|
|
156
|
+
],
|
|
157
|
+
)
|
|
158
|
+
const renderRegions = useCallback(
|
|
159
|
+
(
|
|
160
|
+
regionHostView: ViewDefinition,
|
|
161
|
+
options?: PresentationViewRegionRenderOptions,
|
|
162
|
+
) =>
|
|
163
|
+
renderPresentationViewRegions({
|
|
164
|
+
includeRegionIds: options?.includeRegionIds,
|
|
165
|
+
renderView,
|
|
166
|
+
view: regionHostView,
|
|
167
|
+
}),
|
|
168
|
+
[renderView],
|
|
169
|
+
)
|
|
170
|
+
|
|
171
|
+
if (!view) {
|
|
172
|
+
return renderUnknownView({
|
|
173
|
+
context,
|
|
174
|
+
module,
|
|
175
|
+
reason: 'missing-view',
|
|
176
|
+
surface,
|
|
177
|
+
view,
|
|
178
|
+
viewId,
|
|
179
|
+
})
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
const resolution = resolvePresentationViewRenderer({
|
|
183
|
+
componentSet,
|
|
184
|
+
module,
|
|
185
|
+
registry: rendererRegistry,
|
|
186
|
+
routeId: surface.navigationTarget.route.Id,
|
|
187
|
+
view,
|
|
188
|
+
})
|
|
189
|
+
if (!resolution.renderer) {
|
|
190
|
+
return renderUnknownView({
|
|
191
|
+
context,
|
|
192
|
+
module,
|
|
193
|
+
reason: 'missing-renderer',
|
|
194
|
+
resolution,
|
|
195
|
+
surface,
|
|
196
|
+
view,
|
|
197
|
+
viewId,
|
|
198
|
+
})
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
return resolution.renderer({
|
|
202
|
+
componentKey: resolution.componentKey,
|
|
203
|
+
componentRole: resolution.componentRole,
|
|
204
|
+
context,
|
|
205
|
+
dataSourceResolver,
|
|
206
|
+
module,
|
|
207
|
+
renderRegions,
|
|
208
|
+
renderView,
|
|
209
|
+
surface,
|
|
210
|
+
view,
|
|
211
|
+
})
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
function renderPresentationViewRegions({
|
|
215
|
+
includeRegionIds,
|
|
216
|
+
renderView,
|
|
217
|
+
view,
|
|
218
|
+
}: {
|
|
219
|
+
readonly includeRegionIds?: readonly string[]
|
|
220
|
+
readonly renderView: (viewId: string) => ReactNode
|
|
221
|
+
readonly view: ViewDefinition
|
|
222
|
+
}) {
|
|
223
|
+
const regions = includeRegionIds
|
|
224
|
+
? view.Regions.filter((region) => includeRegionIds.includes(region.Id))
|
|
225
|
+
: view.Regions
|
|
226
|
+
|
|
227
|
+
return regions.flatMap((region) =>
|
|
228
|
+
getRegionViewIds(region).map((childViewId) => (
|
|
229
|
+
<div className="min-h-0 w-full min-w-0" key={`${region.Id}:${childViewId}`}>
|
|
230
|
+
{renderView(childViewId)}
|
|
231
|
+
</div>
|
|
232
|
+
)),
|
|
233
|
+
)
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
function renderDefaultUnknownView<TContext>({
|
|
237
|
+
reason,
|
|
238
|
+
resolution,
|
|
239
|
+
view,
|
|
240
|
+
viewId,
|
|
241
|
+
}: PresentationUnknownViewRenderContext<TContext>) {
|
|
242
|
+
if (reason === 'missing-module') {
|
|
243
|
+
return <ProjectedStatusBlock label="Presentation module is not available." />
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
if (reason === 'missing-surface') {
|
|
247
|
+
return <ProjectedStatusBlock label="Presentation surface is not available." />
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
if (reason === 'missing-root-view') {
|
|
251
|
+
return <ProjectedStatusBlock label="Presentation surface has no root view." />
|
|
252
|
+
}
|
|
253
|
+
|
|
254
|
+
if (reason === 'missing-view') {
|
|
255
|
+
return <ProjectedStatusBlock label={`Presentation view '${viewId ?? 'unknown'}' is not available.`} />
|
|
256
|
+
}
|
|
257
|
+
|
|
258
|
+
return (
|
|
259
|
+
<ProjectedStatusBlock
|
|
260
|
+
label={`Presentation view '${view?.Name ?? viewId ?? 'unknown'}' has no renderer for semantic role '${resolution?.semanticRole ?? 'unknown'}'.`}
|
|
261
|
+
/>
|
|
262
|
+
)
|
|
263
|
+
}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import type { ReactNode } from 'react'
|
|
2
|
+
|
|
3
|
+
export type PresentationValueBadgeTone = 'accent' | 'danger' | 'info' | 'neutral'
|
|
4
|
+
|
|
5
|
+
export interface PresentationValueBadgeProps {
|
|
6
|
+
readonly children?: ReactNode
|
|
7
|
+
readonly className?: string
|
|
8
|
+
readonly label?: string
|
|
9
|
+
readonly tone?: PresentationValueBadgeTone
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
const presentationValueBadgeToneClass = {
|
|
13
|
+
accent: 'border-teal-700/15 bg-teal-50 text-teal-700',
|
|
14
|
+
danger: 'border-red-700/15 bg-red-50 text-red-700',
|
|
15
|
+
info: 'border-sky-700/15 bg-sky-50 text-sky-700',
|
|
16
|
+
neutral: 'border-slate-950/10 bg-slate-100 text-slate-700',
|
|
17
|
+
} satisfies Record<PresentationValueBadgeTone, string>
|
|
18
|
+
|
|
19
|
+
export function PresentationValueBadge({
|
|
20
|
+
children,
|
|
21
|
+
className,
|
|
22
|
+
label,
|
|
23
|
+
tone = 'neutral',
|
|
24
|
+
}: PresentationValueBadgeProps) {
|
|
25
|
+
return (
|
|
26
|
+
<span
|
|
27
|
+
className={cn(
|
|
28
|
+
'inline-flex items-center rounded-md border px-2 py-0.5 text-xs font-medium',
|
|
29
|
+
presentationValueBadgeToneClass[tone],
|
|
30
|
+
className,
|
|
31
|
+
)}
|
|
32
|
+
>
|
|
33
|
+
{children ?? label}
|
|
34
|
+
</span>
|
|
35
|
+
)
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
function cn(...values: readonly (false | null | string | undefined)[]) {
|
|
39
|
+
return values.filter(Boolean).join(' ')
|
|
40
|
+
}
|
|
@@ -0,0 +1,258 @@
|
|
|
1
|
+
import type { ReactNode } from 'react'
|
|
2
|
+
|
|
3
|
+
import type {
|
|
4
|
+
DocumentProcessTaskNoticeDefinition,
|
|
5
|
+
FieldPresentationDefinition,
|
|
6
|
+
PresentationIconDiagnosticSubject,
|
|
7
|
+
ProcessTask,
|
|
8
|
+
} from '@cohesivesystems/presentation-core'
|
|
9
|
+
import {
|
|
10
|
+
resolvePresentationFieldValueIcon,
|
|
11
|
+
} from '@cohesivesystems/presentation-core'
|
|
12
|
+
import type {
|
|
13
|
+
PresentationIconModuleProjection,
|
|
14
|
+
} from './presentation-icon-registry'
|
|
15
|
+
import {
|
|
16
|
+
renderPresentationIcon,
|
|
17
|
+
} from './presentation-icon-registry'
|
|
18
|
+
|
|
19
|
+
export const processIconIds = {
|
|
20
|
+
metricCompleted: 'process.metric.completed',
|
|
21
|
+
metricFailed: 'process.metric.failed',
|
|
22
|
+
metricInProgress: 'process.metric.in-progress',
|
|
23
|
+
metricLoaded: 'process.metric.loaded',
|
|
24
|
+
noticeOpenDetails: 'process-task.notice.open-details',
|
|
25
|
+
statusError: 'process.status.error',
|
|
26
|
+
statusInfo: 'process.status.info',
|
|
27
|
+
statusRunning: 'process.status.running',
|
|
28
|
+
statusSuccess: 'process.status.success',
|
|
29
|
+
statusWarning: 'process.status.warning',
|
|
30
|
+
toastDismiss: 'process-task.toast.dismiss',
|
|
31
|
+
toastOpen: 'process-task.toast.open',
|
|
32
|
+
} as const
|
|
33
|
+
|
|
34
|
+
export type ProcessStatusTone =
|
|
35
|
+
| 'danger'
|
|
36
|
+
| 'default'
|
|
37
|
+
| 'info'
|
|
38
|
+
| 'success'
|
|
39
|
+
| 'warning'
|
|
40
|
+
|
|
41
|
+
export type ProcessToastTone =
|
|
42
|
+
| 'error'
|
|
43
|
+
| 'info'
|
|
44
|
+
| 'success'
|
|
45
|
+
|
|
46
|
+
export function renderProcessIcon({
|
|
47
|
+
className,
|
|
48
|
+
fallbackIcon,
|
|
49
|
+
icon,
|
|
50
|
+
module,
|
|
51
|
+
}: {
|
|
52
|
+
readonly className: string
|
|
53
|
+
readonly fallbackIcon: string
|
|
54
|
+
readonly icon: string
|
|
55
|
+
readonly module?: PresentationIconModuleProjection | null
|
|
56
|
+
}) {
|
|
57
|
+
return renderPresentationIcon({
|
|
58
|
+
className,
|
|
59
|
+
icon,
|
|
60
|
+
module,
|
|
61
|
+
}) ?? renderPresentationIcon({
|
|
62
|
+
className,
|
|
63
|
+
icon: fallbackIcon,
|
|
64
|
+
})
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
export function renderProcessStatusIcon({
|
|
68
|
+
className = 'size-4 shrink-0',
|
|
69
|
+
module,
|
|
70
|
+
status,
|
|
71
|
+
tone,
|
|
72
|
+
}: {
|
|
73
|
+
readonly className?: string
|
|
74
|
+
readonly module?: PresentationIconModuleProjection | null
|
|
75
|
+
readonly status?: ProcessTask['lifecycleStatus'] | string | null
|
|
76
|
+
readonly tone?: ProcessStatusTone | string | null
|
|
77
|
+
}): ReactNode {
|
|
78
|
+
const icon = resolveProcessStatusIconId({ status, tone })
|
|
79
|
+
return renderProcessIcon({
|
|
80
|
+
className: `${className} ${resolveProcessStatusIconToneClass(icon)}`,
|
|
81
|
+
fallbackIcon: resolveProcessStatusFallbackIcon(icon),
|
|
82
|
+
icon,
|
|
83
|
+
module,
|
|
84
|
+
})
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
export function renderProjectedProcessStatusIcon({
|
|
88
|
+
className = 'size-4 shrink-0',
|
|
89
|
+
field,
|
|
90
|
+
module,
|
|
91
|
+
value,
|
|
92
|
+
}: {
|
|
93
|
+
readonly className?: string
|
|
94
|
+
readonly field: FieldPresentationDefinition
|
|
95
|
+
readonly module?: PresentationIconModuleProjection | null
|
|
96
|
+
readonly value: unknown
|
|
97
|
+
}): ReactNode {
|
|
98
|
+
const icon = resolvePresentationFieldValueIcon(field, value)
|
|
99
|
+
if (!icon) {
|
|
100
|
+
return null
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
return renderProcessIcon({
|
|
104
|
+
className: `${className} ${resolveProcessStatusIconToneClass(icon)}`,
|
|
105
|
+
fallbackIcon: resolveProcessStatusFallbackIcon(icon),
|
|
106
|
+
icon,
|
|
107
|
+
module,
|
|
108
|
+
})
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
export function renderProcessToastToneIcon({
|
|
112
|
+
className = 'mt-0.5 size-4 shrink-0',
|
|
113
|
+
module,
|
|
114
|
+
tone,
|
|
115
|
+
}: {
|
|
116
|
+
readonly className?: string
|
|
117
|
+
readonly module?: PresentationIconModuleProjection | null
|
|
118
|
+
readonly tone: ProcessToastTone
|
|
119
|
+
}) {
|
|
120
|
+
const icon = resolveProcessToastToneIconId(tone)
|
|
121
|
+
return renderProcessIcon({
|
|
122
|
+
className: `${className} ${resolveProcessStatusIconToneClass(icon)}`,
|
|
123
|
+
fallbackIcon: resolveProcessStatusFallbackIcon(icon),
|
|
124
|
+
icon,
|
|
125
|
+
module,
|
|
126
|
+
})
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
export function resolveProcessStatusIconId({
|
|
130
|
+
status,
|
|
131
|
+
tone,
|
|
132
|
+
}: {
|
|
133
|
+
readonly status?: ProcessTask['lifecycleStatus'] | string | null
|
|
134
|
+
readonly tone?: ProcessStatusTone | string | null
|
|
135
|
+
}) {
|
|
136
|
+
if (tone === 'success' || status === 'success') {
|
|
137
|
+
return processIconIds.statusSuccess
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
if (tone === 'danger' || tone === 'error' || status === 'error') {
|
|
141
|
+
return processIconIds.statusError
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
if (
|
|
145
|
+
tone === 'warning' ||
|
|
146
|
+
status === 'paused' ||
|
|
147
|
+
status === 'waiting'
|
|
148
|
+
) {
|
|
149
|
+
return processIconIds.statusWarning
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
if (tone === 'info') {
|
|
153
|
+
return processIconIds.statusInfo
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
return processIconIds.statusRunning
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
export function resolveProcessToastToneIconId(tone: ProcessToastTone) {
|
|
160
|
+
if (tone === 'success') {
|
|
161
|
+
return processIconIds.statusSuccess
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
if (tone === 'error') {
|
|
165
|
+
return processIconIds.statusError
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
return processIconIds.statusInfo
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
export function resolveProcessTaskNoticeIconSubjects(
|
|
172
|
+
task: ProcessTask,
|
|
173
|
+
statusField?: FieldPresentationDefinition | null,
|
|
174
|
+
notice?: DocumentProcessTaskNoticeDefinition | null,
|
|
175
|
+
): readonly PresentationIconDiagnosticSubject[] {
|
|
176
|
+
const statusIcon = statusField
|
|
177
|
+
? resolvePresentationFieldValueIcon(statusField, task.status)
|
|
178
|
+
: resolveProcessStatusIconId({ status: task.lifecycleStatus })
|
|
179
|
+
const subjects: PresentationIconDiagnosticSubject[] = [
|
|
180
|
+
...(statusIcon ? [{
|
|
181
|
+
details: {
|
|
182
|
+
processTaskId: task.id,
|
|
183
|
+
status: task.status,
|
|
184
|
+
statusFieldId: statusField?.Id,
|
|
185
|
+
},
|
|
186
|
+
icon: statusIcon,
|
|
187
|
+
id: `${task.id}:status`,
|
|
188
|
+
kind: 'process-task-status-icon',
|
|
189
|
+
label: task.statusLabel,
|
|
190
|
+
}] : []),
|
|
191
|
+
]
|
|
192
|
+
|
|
193
|
+
const actionSubjects = (notice?.Actions ?? []).flatMap((action) => {
|
|
194
|
+
const icon = action.Placement.Icon
|
|
195
|
+
if (!icon) {
|
|
196
|
+
return []
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
return [{
|
|
200
|
+
details: {
|
|
201
|
+
actionId: action.Placement.ActionId,
|
|
202
|
+
processTaskId: task.id,
|
|
203
|
+
},
|
|
204
|
+
icon,
|
|
205
|
+
id: `${task.id}:${action.Placement.ActionId}`,
|
|
206
|
+
kind: 'process-task-notice-icon',
|
|
207
|
+
label: action.Placement.Label ?? action.Placement.ActionId,
|
|
208
|
+
}]
|
|
209
|
+
})
|
|
210
|
+
|
|
211
|
+
subjects.push(...actionSubjects)
|
|
212
|
+
|
|
213
|
+
if (actionSubjects.length === 0 && (task.detailsHref ?? task.targetHref ?? task.sourceHref)) {
|
|
214
|
+
subjects.push({
|
|
215
|
+
details: {
|
|
216
|
+
processTaskId: task.id,
|
|
217
|
+
},
|
|
218
|
+
icon: processIconIds.noticeOpenDetails,
|
|
219
|
+
id: `${task.id}:open-details`,
|
|
220
|
+
kind: 'process-task-notice-icon',
|
|
221
|
+
label: 'Open process details',
|
|
222
|
+
})
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
return subjects
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
function resolveProcessStatusIconToneClass(icon: string) {
|
|
229
|
+
if (icon === processIconIds.statusSuccess) {
|
|
230
|
+
return 'text-teal-700'
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
if (icon === processIconIds.statusError) {
|
|
234
|
+
return 'text-red-700'
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
if (icon === processIconIds.statusWarning) {
|
|
238
|
+
return 'text-amber-700'
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
return 'text-sky-700'
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
function resolveProcessStatusFallbackIcon(icon: string) {
|
|
245
|
+
if (icon === processIconIds.statusSuccess) {
|
|
246
|
+
return 'check-circle-2'
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
if (icon === processIconIds.statusError) {
|
|
250
|
+
return 'alert-circle'
|
|
251
|
+
}
|
|
252
|
+
|
|
253
|
+
if (icon === processIconIds.statusWarning || icon === processIconIds.statusInfo) {
|
|
254
|
+
return 'clock-3'
|
|
255
|
+
}
|
|
256
|
+
|
|
257
|
+
return 'loader-circle'
|
|
258
|
+
}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import type { ReactNode } from 'react'
|
|
2
|
+
|
|
3
|
+
import type {
|
|
4
|
+
PresentationShadcnComponentSystem as PresentationComponentSystem,
|
|
5
|
+
} from './presentation-shadcn-component-system'
|
|
6
|
+
import type { ProjectedActivityState } from '@cohesivesystems/presentation-core'
|
|
7
|
+
|
|
8
|
+
export interface ProjectedActivityStateBoundaryProps {
|
|
9
|
+
readonly children: ReactNode
|
|
10
|
+
readonly componentSystem?: PresentationComponentSystem
|
|
11
|
+
readonly state: ProjectedActivityState
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export function ProjectedActivityStateBoundary({
|
|
15
|
+
children,
|
|
16
|
+
componentSystem,
|
|
17
|
+
state,
|
|
18
|
+
}: ProjectedActivityStateBoundaryProps) {
|
|
19
|
+
if (state.kind === 'ready') {
|
|
20
|
+
return children
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
return (
|
|
24
|
+
<ProjectedStatusBlock
|
|
25
|
+
componentSystem={componentSystem}
|
|
26
|
+
label={state.label}
|
|
27
|
+
tone={state.kind === 'error' ? 'error' : 'default'}
|
|
28
|
+
/>
|
|
29
|
+
)
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
export interface ProjectedStatusBlockProps {
|
|
33
|
+
readonly className?: string
|
|
34
|
+
readonly componentSystem?: PresentationComponentSystem
|
|
35
|
+
readonly label: ReactNode
|
|
36
|
+
readonly tone?: 'default' | 'error'
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
export function ProjectedStatusBlock({
|
|
40
|
+
className,
|
|
41
|
+
componentSystem,
|
|
42
|
+
label,
|
|
43
|
+
tone = 'default',
|
|
44
|
+
}: ProjectedStatusBlockProps) {
|
|
45
|
+
if (componentSystem) {
|
|
46
|
+
return componentSystem.feedback.StatusBlock({ className, label, tone })
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
const toneClassName = tone === 'error'
|
|
50
|
+
? 'border-red-200 bg-red-50 text-red-800'
|
|
51
|
+
: 'border-slate-200 bg-slate-50 text-slate-700'
|
|
52
|
+
const resolvedClassName = [
|
|
53
|
+
'rounded-md border px-3 py-2 text-sm',
|
|
54
|
+
toneClassName,
|
|
55
|
+
className,
|
|
56
|
+
].filter(Boolean).join(' ')
|
|
57
|
+
|
|
58
|
+
return (
|
|
59
|
+
<div className={resolvedClassName} role={tone === 'error' ? 'alert' : 'status'}>
|
|
60
|
+
{label}
|
|
61
|
+
</div>
|
|
62
|
+
)
|
|
63
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import {
|
|
2
|
+
projectProjectedCollectionActionRuntimeDiagnostics as projectCoreProjectedCollectionActionRuntimeDiagnostics,
|
|
3
|
+
type ProjectProjectedCollectionActionRuntimeDiagnosticsOptions,
|
|
4
|
+
} from '@cohesivesystems/presentation-core'
|
|
5
|
+
|
|
6
|
+
import {
|
|
7
|
+
projectPresentationActionIconDiagnostics,
|
|
8
|
+
} from './presentation-icon-diagnostics'
|
|
9
|
+
|
|
10
|
+
export type {
|
|
11
|
+
ProjectProjectedCollectionActionIconDiagnosticsOptions,
|
|
12
|
+
ProjectProjectedCollectionActionRuntimeDiagnosticsOptions,
|
|
13
|
+
} from '@cohesivesystems/presentation-core'
|
|
14
|
+
|
|
15
|
+
export function projectProjectedCollectionActionRuntimeDiagnostics<TData extends object>(
|
|
16
|
+
options: ProjectProjectedCollectionActionRuntimeDiagnosticsOptions<TData>,
|
|
17
|
+
) {
|
|
18
|
+
return projectCoreProjectedCollectionActionRuntimeDiagnostics({
|
|
19
|
+
...options,
|
|
20
|
+
projectActionIconDiagnostics: projectPresentationActionIconDiagnostics,
|
|
21
|
+
})
|
|
22
|
+
}
|