@cohesivesystems/presentation-react 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/collection-chrome-slot-renderer-registry.d.ts +12 -0
- package/dist/collection-chrome-slot-renderer-registry.d.ts.map +1 -0
- package/dist/collection-chrome-slot-renderer-registry.js +12 -0
- package/dist/collection-chrome-slot-renderer-registry.js.map +1 -0
- package/dist/collection-selection-state-context.d.ts +6 -0
- package/dist/collection-selection-state-context.d.ts.map +1 -0
- package/dist/collection-selection-state-context.js +25 -0
- package/dist/collection-selection-state-context.js.map +1 -0
- package/dist/collection-selection-state.d.ts +3 -0
- package/dist/collection-selection-state.d.ts.map +1 -0
- package/dist/collection-selection-state.js +52 -0
- package/dist/collection-selection-state.js.map +1 -0
- package/dist/document-workspace-runtime.d.ts +262 -0
- package/dist/document-workspace-runtime.d.ts.map +1 -0
- package/dist/document-workspace-runtime.js +699 -0
- package/dist/document-workspace-runtime.js.map +1 -0
- package/dist/index.d.ts +51 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +51 -0
- package/dist/index.js.map +1 -0
- package/dist/input-form-endpoint-runtime.d.ts +140 -0
- package/dist/input-form-endpoint-runtime.d.ts.map +1 -0
- package/dist/input-form-endpoint-runtime.js +280 -0
- package/dist/input-form-endpoint-runtime.js.map +1 -0
- package/dist/local-flow-state-data-source-projection.d.ts +21 -0
- package/dist/local-flow-state-data-source-projection.d.ts.map +1 -0
- package/dist/local-flow-state-data-source-projection.js +65 -0
- package/dist/local-flow-state-data-source-projection.js.map +1 -0
- package/dist/navigation-runtime-context.d.ts +22 -0
- package/dist/navigation-runtime-context.d.ts.map +1 -0
- package/dist/navigation-runtime-context.js +23 -0
- package/dist/navigation-runtime-context.js.map +1 -0
- package/dist/navigation-shell-frame-renderer-registry.d.ts +20 -0
- package/dist/navigation-shell-frame-renderer-registry.d.ts.map +1 -0
- package/dist/navigation-shell-frame-renderer-registry.js +9 -0
- package/dist/navigation-shell-frame-renderer-registry.js.map +1 -0
- package/dist/navigation-shell-region-component-registry.d.ts +50 -0
- package/dist/navigation-shell-region-component-registry.d.ts.map +1 -0
- package/dist/navigation-shell-region-component-registry.js +44 -0
- package/dist/navigation-shell-region-component-registry.js.map +1 -0
- package/dist/navigation-shell-slot-renderer-registry.d.ts +22 -0
- package/dist/navigation-shell-slot-renderer-registry.d.ts.map +1 -0
- package/dist/navigation-shell-slot-renderer-registry.js +9 -0
- package/dist/navigation-shell-slot-renderer-registry.js.map +1 -0
- package/dist/page-host-projection.d.ts +127 -0
- package/dist/page-host-projection.d.ts.map +1 -0
- package/dist/page-host-projection.js +59 -0
- package/dist/page-host-projection.js.map +1 -0
- package/dist/page-host-renderer-registry.d.ts +72 -0
- package/dist/page-host-renderer-registry.d.ts.map +1 -0
- package/dist/page-host-renderer-registry.js +63 -0
- package/dist/page-host-renderer-registry.js.map +1 -0
- package/dist/presentation-action-group-runtime-options.d.ts +36 -0
- package/dist/presentation-action-group-runtime-options.d.ts.map +1 -0
- package/dist/presentation-action-group-runtime-options.js +50 -0
- package/dist/presentation-action-group-runtime-options.js.map +1 -0
- package/dist/presentation-action-runtime.d.ts +52 -0
- package/dist/presentation-action-runtime.d.ts.map +1 -0
- package/dist/presentation-action-runtime.js +78 -0
- package/dist/presentation-action-runtime.js.map +1 -0
- package/dist/presentation-data-source-binding-runtime.d.ts +3 -0
- package/dist/presentation-data-source-binding-runtime.d.ts.map +1 -0
- package/dist/presentation-data-source-binding-runtime.js +65 -0
- package/dist/presentation-data-source-binding-runtime.js.map +1 -0
- package/dist/presentation-data-source-binding.d.ts +12 -0
- package/dist/presentation-data-source-binding.d.ts.map +1 -0
- package/dist/presentation-data-source-binding.js +13 -0
- package/dist/presentation-data-source-binding.js.map +1 -0
- package/dist/presentation-flow-runtime.d.ts +139 -0
- package/dist/presentation-flow-runtime.d.ts.map +1 -0
- package/dist/presentation-flow-runtime.js +514 -0
- package/dist/presentation-flow-runtime.js.map +1 -0
- package/dist/presentation-module-context.d.ts +4 -0
- package/dist/presentation-module-context.d.ts.map +1 -0
- package/dist/presentation-module-context.js +6 -0
- package/dist/presentation-module-context.js.map +1 -0
- package/dist/presentation-module-provider.d.ts +7 -0
- package/dist/presentation-module-provider.d.ts.map +1 -0
- package/dist/presentation-module-provider.js +7 -0
- package/dist/presentation-module-provider.js.map +1 -0
- package/dist/presentation-projection-diagnostics-context.d.ts +8 -0
- package/dist/presentation-projection-diagnostics-context.d.ts.map +1 -0
- package/dist/presentation-projection-diagnostics-context.js +3 -0
- package/dist/presentation-projection-diagnostics-context.js.map +1 -0
- package/dist/presentation-projection-diagnostics-hooks.d.ts +4 -0
- package/dist/presentation-projection-diagnostics-hooks.d.ts.map +1 -0
- package/dist/presentation-projection-diagnostics-hooks.js +17 -0
- package/dist/presentation-projection-diagnostics-hooks.js.map +1 -0
- package/dist/presentation-projection-diagnostics-runtime.d.ts +12 -0
- package/dist/presentation-projection-diagnostics-runtime.d.ts.map +1 -0
- package/dist/presentation-projection-diagnostics-runtime.js +54 -0
- package/dist/presentation-projection-diagnostics-runtime.js.map +1 -0
- package/dist/presentation-projection-trace.d.ts +27 -0
- package/dist/presentation-projection-trace.d.ts.map +1 -0
- package/dist/presentation-projection-trace.js +54 -0
- package/dist/presentation-projection-trace.js.map +1 -0
- package/dist/presentation-query-form-runtime.d.ts +30 -0
- package/dist/presentation-query-form-runtime.d.ts.map +1 -0
- package/dist/presentation-query-form-runtime.js +75 -0
- package/dist/presentation-query-form-runtime.js.map +1 -0
- package/dist/presentation-query-form-state-adapter-registry.d.ts +4 -0
- package/dist/presentation-query-form-state-adapter-registry.d.ts.map +1 -0
- package/dist/presentation-query-form-state-adapter-registry.js +13 -0
- package/dist/presentation-query-form-state-adapter-registry.js.map +1 -0
- package/dist/presentation-query-form-state-context.d.ts +20 -0
- package/dist/presentation-query-form-state-context.d.ts.map +1 -0
- package/dist/presentation-query-form-state-context.js +20 -0
- package/dist/presentation-query-form-state-context.js.map +1 -0
- package/dist/presentation-query-form-state.d.ts +29 -0
- package/dist/presentation-query-form-state.d.ts.map +1 -0
- package/dist/presentation-query-form-state.js +99 -0
- package/dist/presentation-query-form-state.js.map +1 -0
- package/dist/presentation-renderer-registry.d.ts +109 -0
- package/dist/presentation-renderer-registry.d.ts.map +1 -0
- package/dist/presentation-renderer-registry.js +25 -0
- package/dist/presentation-renderer-registry.js.map +1 -0
- package/dist/presentation-standards-context.d.ts +4 -0
- package/dist/presentation-standards-context.d.ts.map +1 -0
- package/dist/presentation-standards-context.js +12 -0
- package/dist/presentation-standards-context.js.map +1 -0
- package/dist/presentation-standards-provider.d.ts +14 -0
- package/dist/presentation-standards-provider.d.ts.map +1 -0
- package/dist/presentation-standards-provider.js +16 -0
- package/dist/presentation-standards-provider.js.map +1 -0
- package/dist/projected-document-action-runtime-bindings.d.ts +20 -0
- package/dist/projected-document-action-runtime-bindings.d.ts.map +1 -0
- package/dist/projected-document-action-runtime-bindings.js +88 -0
- package/dist/projected-document-action-runtime-bindings.js.map +1 -0
- package/dist/projected-document-action-runtime.d.ts +76 -0
- package/dist/projected-document-action-runtime.d.ts.map +1 -0
- package/dist/projected-document-action-runtime.js +224 -0
- package/dist/projected-document-action-runtime.js.map +1 -0
- package/dist/projected-document-process-preview-action-runtime-bindings.d.ts +26 -0
- package/dist/projected-document-process-preview-action-runtime-bindings.d.ts.map +1 -0
- package/dist/projected-document-process-preview-action-runtime-bindings.js +106 -0
- package/dist/projected-document-process-preview-action-runtime-bindings.js.map +1 -0
- package/dist/projected-document-process-preview-action-runtime.d.ts +321 -0
- package/dist/projected-document-process-preview-action-runtime.d.ts.map +1 -0
- package/dist/projected-document-process-preview-action-runtime.js +729 -0
- package/dist/projected-document-process-preview-action-runtime.js.map +1 -0
- package/dist/projected-document-process-preview-capability-runtime.d.ts +47 -0
- package/dist/projected-document-process-preview-capability-runtime.d.ts.map +1 -0
- package/dist/projected-document-process-preview-capability-runtime.js +49 -0
- package/dist/projected-document-process-preview-capability-runtime.js.map +1 -0
- package/dist/projected-document-workspace-action-runtime.d.ts +87 -0
- package/dist/projected-document-workspace-action-runtime.d.ts.map +1 -0
- package/dist/projected-document-workspace-action-runtime.js +150 -0
- package/dist/projected-document-workspace-action-runtime.js.map +1 -0
- package/dist/projected-document-workspace-projection-renderer-diagnostics.d.ts +18 -0
- package/dist/projected-document-workspace-projection-renderer-diagnostics.d.ts.map +1 -0
- package/dist/projected-document-workspace-projection-renderer-diagnostics.js +207 -0
- package/dist/projected-document-workspace-projection-renderer-diagnostics.js.map +1 -0
- package/dist/projected-document-workspace-runtime-binding-diagnostics.d.ts +19 -0
- package/dist/projected-document-workspace-runtime-binding-diagnostics.d.ts.map +1 -0
- package/dist/projected-document-workspace-runtime-binding-diagnostics.js +124 -0
- package/dist/projected-document-workspace-runtime-binding-diagnostics.js.map +1 -0
- package/dist/projected-navigation-provider.d.ts +16 -0
- package/dist/projected-navigation-provider.d.ts.map +1 -0
- package/dist/projected-navigation-provider.js +51 -0
- package/dist/projected-navigation-provider.js.map +1 -0
- package/dist/projected-presentation-flow-host.d.ts +16 -0
- package/dist/projected-presentation-flow-host.d.ts.map +1 -0
- package/dist/projected-presentation-flow-host.js +14 -0
- package/dist/projected-presentation-flow-host.js.map +1 -0
- package/dist/projected-query-form-state-adapter.d.ts +12 -0
- package/dist/projected-query-form-state-adapter.d.ts.map +1 -0
- package/dist/projected-query-form-state-adapter.js +361 -0
- package/dist/projected-query-form-state-adapter.js.map +1 -0
- package/dist/react-router-binding.d.ts +133 -0
- package/dist/react-router-binding.d.ts.map +1 -0
- package/dist/react-router-binding.js +76 -0
- package/dist/react-router-binding.js.map +1 -0
- package/dist/react-router-path.d.ts +4 -0
- package/dist/react-router-path.d.ts.map +1 -0
- package/dist/react-router-path.js +11 -0
- package/dist/react-router-path.js.map +1 -0
- package/dist/scope-selection-context.d.ts +28 -0
- package/dist/scope-selection-context.d.ts.map +1 -0
- package/dist/scope-selection-context.js +13 -0
- package/dist/scope-selection-context.js.map +1 -0
- package/dist/scope-selection-provider.d.ts +33 -0
- package/dist/scope-selection-provider.d.ts.map +1 -0
- package/dist/scope-selection-provider.js +162 -0
- package/dist/scope-selection-provider.js.map +1 -0
- package/dist/scope-selection-request.d.ts +6 -0
- package/dist/scope-selection-request.d.ts.map +1 -0
- package/dist/scope-selection-request.js +12 -0
- package/dist/scope-selection-request.js.map +1 -0
- package/dist/standard-navigation-shell-frame-renderers.d.ts +15 -0
- package/dist/standard-navigation-shell-frame-renderers.d.ts.map +1 -0
- package/dist/standard-navigation-shell-frame-renderers.js +22 -0
- package/dist/standard-navigation-shell-frame-renderers.js.map +1 -0
- package/dist/standard-navigation-shell-slot-renderers.d.ts +59 -0
- package/dist/standard-navigation-shell-slot-renderers.d.ts.map +1 -0
- package/dist/standard-navigation-shell-slot-renderers.js +67 -0
- package/dist/standard-navigation-shell-slot-renderers.js.map +1 -0
- package/dist/view-chrome-slot-renderer-registry.d.ts +12 -0
- package/dist/view-chrome-slot-renderer-registry.d.ts.map +1 -0
- package/dist/view-chrome-slot-renderer-registry.js +12 -0
- package/dist/view-chrome-slot-renderer-registry.js.map +1 -0
- package/package.json +60 -0
- package/src/collection-chrome-slot-renderer-registry.ts +66 -0
- package/src/collection-selection-state-context.ts +51 -0
- package/src/collection-selection-state.tsx +101 -0
- package/src/document-workspace-runtime.tsx +1505 -0
- package/src/index.ts +50 -0
- package/src/input-form-endpoint-runtime.ts +632 -0
- package/src/local-flow-state-data-source-projection.ts +133 -0
- package/src/navigation-runtime-context.ts +40 -0
- package/src/navigation-shell-frame-renderer-registry.ts +54 -0
- package/src/navigation-shell-region-component-registry.tsx +127 -0
- package/src/navigation-shell-slot-renderer-registry.ts +88 -0
- package/src/page-host-projection.ts +356 -0
- package/src/page-host-renderer-registry.tsx +353 -0
- package/src/presentation-action-group-runtime-options.ts +121 -0
- package/src/presentation-action-runtime.ts +190 -0
- package/src/presentation-data-source-binding-runtime.ts +109 -0
- package/src/presentation-data-source-binding.tsx +24 -0
- package/src/presentation-flow-runtime.tsx +835 -0
- package/src/presentation-module-context.ts +10 -0
- package/src/presentation-module-provider.tsx +19 -0
- package/src/presentation-projection-diagnostics-context.ts +17 -0
- package/src/presentation-projection-diagnostics-hooks.ts +29 -0
- package/src/presentation-projection-diagnostics-runtime.tsx +95 -0
- package/src/presentation-projection-trace.ts +117 -0
- package/src/presentation-query-form-runtime.ts +148 -0
- package/src/presentation-query-form-state-adapter-registry.ts +25 -0
- package/src/presentation-query-form-state-context.ts +56 -0
- package/src/presentation-query-form-state.tsx +250 -0
- package/src/presentation-renderer-registry.ts +214 -0
- package/src/presentation-standards-context.ts +21 -0
- package/src/presentation-standards-provider.tsx +44 -0
- package/src/projected-document-action-runtime-bindings.ts +132 -0
- package/src/projected-document-action-runtime.ts +414 -0
- package/src/projected-document-process-preview-action-runtime-bindings.ts +231 -0
- package/src/projected-document-process-preview-action-runtime.ts +1725 -0
- package/src/projected-document-process-preview-capability-runtime.ts +216 -0
- package/src/projected-document-workspace-action-runtime.ts +402 -0
- package/src/projected-document-workspace-projection-renderer-diagnostics.ts +342 -0
- package/src/projected-document-workspace-runtime-binding-diagnostics.ts +208 -0
- package/src/projected-navigation-provider.tsx +104 -0
- package/src/projected-presentation-flow-host.tsx +46 -0
- package/src/projected-query-form-state-adapter.ts +578 -0
- package/src/react-router-binding.tsx +417 -0
- package/src/react-router-path.ts +16 -0
- package/src/scope-selection-context.ts +58 -0
- package/src/scope-selection-provider.tsx +324 -0
- package/src/scope-selection-request.ts +21 -0
- package/src/standard-navigation-shell-frame-renderers.tsx +106 -0
- package/src/standard-navigation-shell-slot-renderers.tsx +289 -0
- package/src/view-chrome-slot-renderer-registry.ts +66 -0
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
import {
|
|
2
|
+
createPresentationEnumDiscriminator,
|
|
3
|
+
findPresentationView,
|
|
4
|
+
matchesPresentationEnum,
|
|
5
|
+
presentationDataSourceBindings,
|
|
6
|
+
resolvePresentationViewDataSourceIds,
|
|
7
|
+
type PresentationDataSourceAuthorizationRequirement,
|
|
8
|
+
type PresentationDataSourceBinding,
|
|
9
|
+
type PresentationModuleDefinition,
|
|
10
|
+
type ViewDefinition,
|
|
11
|
+
} from '@cohesivesystems/presentation-core'
|
|
12
|
+
import type { PresentationFlowRuntimeEntry } from './presentation-flow-runtime'
|
|
13
|
+
import { viewSubjectKinds } from '@cohesivesystems/presentation-contracts'
|
|
14
|
+
|
|
15
|
+
export interface LocalFlowStateDataSourceState {
|
|
16
|
+
readonly data?: unknown
|
|
17
|
+
readonly error?: unknown
|
|
18
|
+
readonly isFetching?: boolean
|
|
19
|
+
readonly isPending?: boolean
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export function createLocalFlowStateDataSourceBindings({
|
|
23
|
+
activeEntries,
|
|
24
|
+
authorization,
|
|
25
|
+
module,
|
|
26
|
+
state,
|
|
27
|
+
statesByFlowId,
|
|
28
|
+
}: {
|
|
29
|
+
readonly activeEntries: readonly PresentationFlowRuntimeEntry[]
|
|
30
|
+
readonly authorization: PresentationDataSourceAuthorizationRequirement
|
|
31
|
+
readonly module: PresentationModuleDefinition | null
|
|
32
|
+
readonly state?: LocalFlowStateDataSourceState | null
|
|
33
|
+
readonly statesByFlowId?: Readonly<Record<string, LocalFlowStateDataSourceState | null | undefined>>
|
|
34
|
+
}): readonly PresentationDataSourceBinding[] {
|
|
35
|
+
return activeEntries.flatMap((entry) => {
|
|
36
|
+
const flowState = statesByFlowId?.[entry.flow.Id] ?? state
|
|
37
|
+
const dataSourceIds = resolveLocalFlowStateDataSourceIds({
|
|
38
|
+
flowId: entry.flow.Id,
|
|
39
|
+
module,
|
|
40
|
+
view: entry.view,
|
|
41
|
+
})
|
|
42
|
+
|
|
43
|
+
return dataSourceIds.map((dataSourceId) =>
|
|
44
|
+
presentationDataSourceBindings.localValue({
|
|
45
|
+
authorization,
|
|
46
|
+
data: flowState?.data ?? null,
|
|
47
|
+
dataSourceId,
|
|
48
|
+
error: flowState?.error,
|
|
49
|
+
isFetching: flowState?.isFetching,
|
|
50
|
+
isPending: flowState?.isPending,
|
|
51
|
+
}),
|
|
52
|
+
)
|
|
53
|
+
})
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
export function resolveLocalFlowStateDataSourceIds({
|
|
57
|
+
flowId,
|
|
58
|
+
module,
|
|
59
|
+
view,
|
|
60
|
+
}: {
|
|
61
|
+
readonly flowId: string
|
|
62
|
+
readonly module: PresentationModuleDefinition | null
|
|
63
|
+
readonly view: ViewDefinition | null
|
|
64
|
+
}) {
|
|
65
|
+
if (!module || !view) {
|
|
66
|
+
return []
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
const dataSourceIds = new Set<string>()
|
|
70
|
+
const visitedViewIds = new Set<string>()
|
|
71
|
+
collectLocalFlowStateDataSourceIds({
|
|
72
|
+
dataSourceIds,
|
|
73
|
+
flowId,
|
|
74
|
+
module,
|
|
75
|
+
view,
|
|
76
|
+
visitedViewIds,
|
|
77
|
+
})
|
|
78
|
+
return Array.from(dataSourceIds)
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
function collectLocalFlowStateDataSourceIds({
|
|
82
|
+
dataSourceIds,
|
|
83
|
+
flowId,
|
|
84
|
+
module,
|
|
85
|
+
view,
|
|
86
|
+
visitedViewIds,
|
|
87
|
+
}: {
|
|
88
|
+
readonly dataSourceIds: Set<string>
|
|
89
|
+
readonly flowId: string
|
|
90
|
+
readonly module: PresentationModuleDefinition
|
|
91
|
+
readonly view: ViewDefinition
|
|
92
|
+
readonly visitedViewIds: Set<string>
|
|
93
|
+
}) {
|
|
94
|
+
if (visitedViewIds.has(view.Id)) {
|
|
95
|
+
return
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
visitedViewIds.add(view.Id)
|
|
99
|
+
if (isLocalFlowStateView(view, flowId)) {
|
|
100
|
+
for (const dataSourceId of resolvePresentationViewDataSourceIds(view)) {
|
|
101
|
+
dataSourceIds.add(dataSourceId)
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
for (const region of view.Regions) {
|
|
106
|
+
for (const viewId of region.ViewIds) {
|
|
107
|
+
const childView = findPresentationView<ViewDefinition>(module, viewId)
|
|
108
|
+
if (childView) {
|
|
109
|
+
collectLocalFlowStateDataSourceIds({
|
|
110
|
+
dataSourceIds,
|
|
111
|
+
flowId,
|
|
112
|
+
module,
|
|
113
|
+
view: childView,
|
|
114
|
+
visitedViewIds,
|
|
115
|
+
})
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
function isLocalFlowStateView(view: ViewDefinition, flowId: string) {
|
|
122
|
+
return (
|
|
123
|
+
view.Subject.FlowId === flowId &&
|
|
124
|
+
matchesPresentationEnum(
|
|
125
|
+
view.Subject.Kind,
|
|
126
|
+
createPresentationEnumDiscriminator(
|
|
127
|
+
viewSubjectKinds,
|
|
128
|
+
'localFlowState',
|
|
129
|
+
'LocalFlowState',
|
|
130
|
+
),
|
|
131
|
+
)
|
|
132
|
+
)
|
|
133
|
+
}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { createContext, useContext } from 'react'
|
|
2
|
+
|
|
3
|
+
import type {
|
|
4
|
+
PresentationNavigationRuntime,
|
|
5
|
+
} from '@cohesivesystems/presentation-core'
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Re-exports the core navigation runtime contracts used by React navigation
|
|
9
|
+
* providers and projected components.
|
|
10
|
+
*/
|
|
11
|
+
export type {
|
|
12
|
+
PresentationHrefNavigator,
|
|
13
|
+
PresentationNavigationHrefFactory,
|
|
14
|
+
PresentationNavigationRuntime,
|
|
15
|
+
PresentationRouteNavigator,
|
|
16
|
+
} from '@cohesivesystems/presentation-core'
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* React context carrying navigation services for projected presentation
|
|
20
|
+
* components.
|
|
21
|
+
*
|
|
22
|
+
* The default runtime is intentionally inert so components can render in tests,
|
|
23
|
+
* previews, and partially wired hosts without failing at context-read time.
|
|
24
|
+
*/
|
|
25
|
+
export const PresentationNavigationRuntimeContext =
|
|
26
|
+
createContext<PresentationNavigationRuntime>({
|
|
27
|
+
createHref: () => null,
|
|
28
|
+
navigateHref: () => undefined,
|
|
29
|
+
navigateRoute: () => undefined,
|
|
30
|
+
})
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* Reads the active presentation navigation runtime from React context.
|
|
34
|
+
*
|
|
35
|
+
* Components should use this hook instead of importing a concrete router so the
|
|
36
|
+
* same projected UI can run under different host navigation adapters.
|
|
37
|
+
*/
|
|
38
|
+
export function usePresentationNavigationRuntime() {
|
|
39
|
+
return useContext(PresentationNavigationRuntimeContext)
|
|
40
|
+
}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import type { ReactNode } from 'react'
|
|
2
|
+
|
|
3
|
+
import type {
|
|
4
|
+
NavigationDefinition,
|
|
5
|
+
NavigationNodeDefinition,
|
|
6
|
+
NavigationShellKind,
|
|
7
|
+
NavigationShellRegionDefinition,
|
|
8
|
+
NavigationShellSlotDefinition,
|
|
9
|
+
} from '@cohesivesystems/presentation-contracts'
|
|
10
|
+
import {
|
|
11
|
+
createNavigationShellFrameRendererRegistry as createCoreNavigationShellFrameRendererRegistry,
|
|
12
|
+
resolveNavigationShellFrameRenderer as resolveCoreNavigationShellFrameRenderer,
|
|
13
|
+
type NavigationShellFrameRendererBinding as CoreNavigationShellFrameRendererBinding,
|
|
14
|
+
type NavigationShellFrameRendererRegistry as CoreNavigationShellFrameRendererRegistry,
|
|
15
|
+
} from '@cohesivesystems/presentation-core'
|
|
16
|
+
export {
|
|
17
|
+
createNavigationShellFrameRendererKey,
|
|
18
|
+
getNavigationShellFrameRendererRegistryKeys,
|
|
19
|
+
hasNavigationShellFrameRendererBinding,
|
|
20
|
+
} from '@cohesivesystems/presentation-core'
|
|
21
|
+
|
|
22
|
+
export interface ProjectedNavigationShellFrameRenderContext<TLayout = unknown> {
|
|
23
|
+
readonly activePath: string
|
|
24
|
+
readonly children: ReactNode
|
|
25
|
+
readonly layout: TLayout
|
|
26
|
+
readonly navigation: NavigationDefinition
|
|
27
|
+
readonly renderNodeIcon?: (node: NavigationNodeDefinition) => ReactNode
|
|
28
|
+
readonly renderShellIcon?: (icon: string) => ReactNode
|
|
29
|
+
readonly renderShellRegion?: (region: NavigationShellRegionDefinition) => ReactNode
|
|
30
|
+
readonly renderSlot: (slot: NavigationShellSlotDefinition | null) => ReactNode
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
export type NavigationShellFrameRenderer<TLayout = unknown> = (
|
|
34
|
+
context: ProjectedNavigationShellFrameRenderContext<TLayout>,
|
|
35
|
+
) => ReactNode
|
|
36
|
+
|
|
37
|
+
export type NavigationShellFrameRendererRegistry<TLayout = unknown> =
|
|
38
|
+
CoreNavigationShellFrameRendererRegistry<NavigationShellFrameRenderer<TLayout>>
|
|
39
|
+
|
|
40
|
+
export type NavigationShellFrameRendererBinding<TLayout = unknown> =
|
|
41
|
+
CoreNavigationShellFrameRendererBinding<NavigationShellFrameRenderer<TLayout>>
|
|
42
|
+
|
|
43
|
+
export function createNavigationShellFrameRendererRegistry<TLayout>(
|
|
44
|
+
bindings: readonly NavigationShellFrameRendererBinding<TLayout>[],
|
|
45
|
+
): NavigationShellFrameRendererRegistry<TLayout> {
|
|
46
|
+
return createCoreNavigationShellFrameRendererRegistry(bindings)
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
export function resolveNavigationShellFrameRenderer<TLayout>(
|
|
50
|
+
registry: NavigationShellFrameRendererRegistry<TLayout> | null | undefined,
|
|
51
|
+
kind: NavigationShellKind | string | number,
|
|
52
|
+
) {
|
|
53
|
+
return resolveCoreNavigationShellFrameRenderer(registry, kind)
|
|
54
|
+
}
|
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
import type { ComponentType, ReactNode } from 'react'
|
|
2
|
+
|
|
3
|
+
import {
|
|
4
|
+
presentationTargetKinds,
|
|
5
|
+
type NavigationShellRegionDefinition,
|
|
6
|
+
} from '@cohesivesystems/presentation-contracts'
|
|
7
|
+
import {
|
|
8
|
+
createPresentationEnumDiscriminator,
|
|
9
|
+
createNavigationShellRegionComponentRegistry as createCoreNavigationShellRegionComponentRegistry,
|
|
10
|
+
getNavigationShellRegionComponentRegistryKeys,
|
|
11
|
+
hasNavigationShellRegionComponentBinding,
|
|
12
|
+
hasNavigationShellRegionComponentTargetBinding as hasCoreNavigationShellRegionComponentTargetBinding,
|
|
13
|
+
resolveNavigationShellRegionComponent as resolveCoreNavigationShellRegionComponent,
|
|
14
|
+
type NavigationShellRegionComponentModuleProjection,
|
|
15
|
+
type NavigationShellRegionComponentRegistry as CoreNavigationShellRegionComponentRegistry,
|
|
16
|
+
type NavigationShellRegionComponentResolution as CoreNavigationShellRegionComponentResolution,
|
|
17
|
+
type ResolveNavigationShellRegionComponentOptions as CoreResolveNavigationShellRegionComponentOptions,
|
|
18
|
+
} from '@cohesivesystems/presentation-core'
|
|
19
|
+
|
|
20
|
+
export {
|
|
21
|
+
getNavigationShellRegionComponentRegistryKeys,
|
|
22
|
+
hasNavigationShellRegionComponentBinding,
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export type { NavigationShellRegionComponentModuleProjection }
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* Props passed to a React component that renders a navigation shell region.
|
|
29
|
+
*/
|
|
30
|
+
export interface NavigationShellRegionComponentProps {
|
|
31
|
+
/** Navigation shell region definition selected by the shell runtime. */
|
|
32
|
+
readonly region: NavigationShellRegionDefinition
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* React component type used to render one navigation shell region.
|
|
37
|
+
*/
|
|
38
|
+
export type NavigationShellRegionComponentRenderer =
|
|
39
|
+
ComponentType<NavigationShellRegionComponentProps>
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* React renderer registry for navigation shell regions.
|
|
43
|
+
*/
|
|
44
|
+
export type NavigationShellRegionComponentRegistry =
|
|
45
|
+
CoreNavigationShellRegionComponentRegistry<NavigationShellRegionComponentRenderer>
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
* React-specific shell region component resolution.
|
|
49
|
+
*/
|
|
50
|
+
export type NavigationShellRegionComponentResolution =
|
|
51
|
+
CoreNavigationShellRegionComponentResolution<NavigationShellRegionComponentRenderer>
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
* Inputs used to resolve a React navigation shell region renderer.
|
|
55
|
+
*
|
|
56
|
+
* The React wrapper supplies the React target discriminator internally.
|
|
57
|
+
*/
|
|
58
|
+
export type ResolveNavigationShellRegionComponentOptions =
|
|
59
|
+
Omit<
|
|
60
|
+
CoreResolveNavigationShellRegionComponentOptions<
|
|
61
|
+
NavigationShellRegionComponentRenderer
|
|
62
|
+
>,
|
|
63
|
+
'targetKind'
|
|
64
|
+
>
|
|
65
|
+
|
|
66
|
+
/**
|
|
67
|
+
* Creates a typed React navigation shell region component registry.
|
|
68
|
+
*/
|
|
69
|
+
export function createNavigationShellRegionComponentRegistry(
|
|
70
|
+
registry: NavigationShellRegionComponentRegistry,
|
|
71
|
+
) {
|
|
72
|
+
return createCoreNavigationShellRegionComponentRegistry(registry)
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
/**
|
|
76
|
+
* Tests whether a React shell region resolves to a renderer through the active
|
|
77
|
+
* target bindings and registry.
|
|
78
|
+
*/
|
|
79
|
+
export function hasNavigationShellRegionComponentTargetBinding(
|
|
80
|
+
options: ResolveNavigationShellRegionComponentOptions,
|
|
81
|
+
) {
|
|
82
|
+
return hasCoreNavigationShellRegionComponentTargetBinding({
|
|
83
|
+
...options,
|
|
84
|
+
targetKind: reactPresentationTargetKind,
|
|
85
|
+
})
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
/**
|
|
89
|
+
* Host component that resolves and renders a projected navigation shell region.
|
|
90
|
+
*/
|
|
91
|
+
export function ProjectedNavigationShellRegionComponentHost({
|
|
92
|
+
componentSet,
|
|
93
|
+
fallback = null,
|
|
94
|
+
module,
|
|
95
|
+
region,
|
|
96
|
+
registry,
|
|
97
|
+
}: ResolveNavigationShellRegionComponentOptions & {
|
|
98
|
+
readonly fallback?: ReactNode
|
|
99
|
+
}) {
|
|
100
|
+
const resolution = resolveNavigationShellRegionComponent({
|
|
101
|
+
componentSet,
|
|
102
|
+
module,
|
|
103
|
+
region,
|
|
104
|
+
registry,
|
|
105
|
+
})
|
|
106
|
+
const Renderer = resolution.renderer
|
|
107
|
+
|
|
108
|
+
return Renderer ? <Renderer region={region} /> : fallback
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
/**
|
|
112
|
+
* Resolves the React renderer for a projected navigation shell region.
|
|
113
|
+
*/
|
|
114
|
+
export function resolveNavigationShellRegionComponent(
|
|
115
|
+
options: ResolveNavigationShellRegionComponentOptions,
|
|
116
|
+
): NavigationShellRegionComponentResolution {
|
|
117
|
+
return resolveCoreNavigationShellRegionComponent({
|
|
118
|
+
...options,
|
|
119
|
+
targetKind: reactPresentationTargetKind,
|
|
120
|
+
})
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
const reactPresentationTargetKind = createPresentationEnumDiscriminator(
|
|
124
|
+
presentationTargetKinds,
|
|
125
|
+
'react',
|
|
126
|
+
'React',
|
|
127
|
+
)
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
import type { ReactNode } from 'react'
|
|
2
|
+
|
|
3
|
+
import type {
|
|
4
|
+
NavigationDefinition,
|
|
5
|
+
NavigationNodeDefinition,
|
|
6
|
+
NavigationShellRegionDefinition,
|
|
7
|
+
NavigationShellSlotDefinition,
|
|
8
|
+
NavigationShellSlotKind,
|
|
9
|
+
} from '@cohesivesystems/presentation-contracts'
|
|
10
|
+
import {
|
|
11
|
+
createNavigationShellSlotRendererRegistry as createCoreNavigationShellSlotRendererRegistry,
|
|
12
|
+
resolveNavigationShellSlotRenderer as resolveCoreNavigationShellSlotRenderer,
|
|
13
|
+
type NavigationShellSlotRendererBinding as CoreNavigationShellSlotRendererBinding,
|
|
14
|
+
type NavigationShellSlotRendererRegistry as CoreNavigationShellSlotRendererRegistry,
|
|
15
|
+
} from '@cohesivesystems/presentation-core'
|
|
16
|
+
export {
|
|
17
|
+
createNavigationShellSlotRendererKey,
|
|
18
|
+
getNavigationShellSlotRendererCandidateKeys,
|
|
19
|
+
getNavigationShellSlotRendererRegistryKeys,
|
|
20
|
+
hasNavigationShellSlotRendererBinding,
|
|
21
|
+
navigationShellSlotAnyPlacement,
|
|
22
|
+
} from '@cohesivesystems/presentation-core'
|
|
23
|
+
|
|
24
|
+
export interface ProjectedNavigationShellSlotRenderContext<
|
|
25
|
+
TSlotLayout = unknown,
|
|
26
|
+
TComponentSystem = unknown,
|
|
27
|
+
> {
|
|
28
|
+
readonly activePath: string
|
|
29
|
+
readonly children: ReactNode
|
|
30
|
+
readonly componentSystem: TComponentSystem
|
|
31
|
+
readonly navigation: NavigationDefinition
|
|
32
|
+
readonly renderNodeIcon?: (node: NavigationNodeDefinition) => ReactNode
|
|
33
|
+
readonly renderShellIcon?: (icon: string) => ReactNode
|
|
34
|
+
readonly renderShellRegion?: (region: NavigationShellRegionDefinition) => ReactNode
|
|
35
|
+
readonly slot: NavigationShellSlotDefinition
|
|
36
|
+
readonly slotLayout: TSlotLayout
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
export type NavigationShellSlotRenderer<
|
|
40
|
+
TSlotLayout = unknown,
|
|
41
|
+
TComponentSystem = unknown,
|
|
42
|
+
> = (
|
|
43
|
+
context: ProjectedNavigationShellSlotRenderContext<
|
|
44
|
+
TSlotLayout,
|
|
45
|
+
TComponentSystem
|
|
46
|
+
>,
|
|
47
|
+
) => ReactNode
|
|
48
|
+
|
|
49
|
+
export type NavigationShellSlotRendererRegistry<
|
|
50
|
+
TSlotLayout = unknown,
|
|
51
|
+
TComponentSystem = unknown,
|
|
52
|
+
> = CoreNavigationShellSlotRendererRegistry<
|
|
53
|
+
NavigationShellSlotRenderer<TSlotLayout, TComponentSystem>
|
|
54
|
+
>
|
|
55
|
+
|
|
56
|
+
export type NavigationShellSlotRendererBinding<
|
|
57
|
+
TSlotLayout = unknown,
|
|
58
|
+
TComponentSystem = unknown,
|
|
59
|
+
> = CoreNavigationShellSlotRendererBinding<
|
|
60
|
+
NavigationShellSlotRenderer<TSlotLayout, TComponentSystem>
|
|
61
|
+
>
|
|
62
|
+
|
|
63
|
+
export function createNavigationShellSlotRendererRegistry<
|
|
64
|
+
TSlotLayout,
|
|
65
|
+
TComponentSystem,
|
|
66
|
+
>(
|
|
67
|
+
bindings: readonly NavigationShellSlotRendererBinding<
|
|
68
|
+
TSlotLayout,
|
|
69
|
+
TComponentSystem
|
|
70
|
+
>[],
|
|
71
|
+
): NavigationShellSlotRendererRegistry<TSlotLayout, TComponentSystem> {
|
|
72
|
+
return createCoreNavigationShellSlotRendererRegistry(bindings)
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
export function resolveNavigationShellSlotRenderer<
|
|
76
|
+
TSlotLayout,
|
|
77
|
+
TComponentSystem,
|
|
78
|
+
>(
|
|
79
|
+
registry: NavigationShellSlotRendererRegistry<
|
|
80
|
+
TSlotLayout,
|
|
81
|
+
TComponentSystem
|
|
82
|
+
> | null | undefined,
|
|
83
|
+
slot: NavigationShellSlotDefinition,
|
|
84
|
+
) {
|
|
85
|
+
return resolveCoreNavigationShellSlotRenderer(registry, slot)
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
export type { NavigationShellSlotKind }
|