@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.
Files changed (252) hide show
  1. package/LICENSE +55 -0
  2. package/dist/collection-chrome-slot-renderer-registry.d.ts +12 -0
  3. package/dist/collection-chrome-slot-renderer-registry.d.ts.map +1 -0
  4. package/dist/collection-chrome-slot-renderer-registry.js +12 -0
  5. package/dist/collection-chrome-slot-renderer-registry.js.map +1 -0
  6. package/dist/collection-selection-state-context.d.ts +6 -0
  7. package/dist/collection-selection-state-context.d.ts.map +1 -0
  8. package/dist/collection-selection-state-context.js +25 -0
  9. package/dist/collection-selection-state-context.js.map +1 -0
  10. package/dist/collection-selection-state.d.ts +3 -0
  11. package/dist/collection-selection-state.d.ts.map +1 -0
  12. package/dist/collection-selection-state.js +52 -0
  13. package/dist/collection-selection-state.js.map +1 -0
  14. package/dist/document-workspace-runtime.d.ts +262 -0
  15. package/dist/document-workspace-runtime.d.ts.map +1 -0
  16. package/dist/document-workspace-runtime.js +699 -0
  17. package/dist/document-workspace-runtime.js.map +1 -0
  18. package/dist/index.d.ts +51 -0
  19. package/dist/index.d.ts.map +1 -0
  20. package/dist/index.js +51 -0
  21. package/dist/index.js.map +1 -0
  22. package/dist/input-form-endpoint-runtime.d.ts +140 -0
  23. package/dist/input-form-endpoint-runtime.d.ts.map +1 -0
  24. package/dist/input-form-endpoint-runtime.js +280 -0
  25. package/dist/input-form-endpoint-runtime.js.map +1 -0
  26. package/dist/local-flow-state-data-source-projection.d.ts +21 -0
  27. package/dist/local-flow-state-data-source-projection.d.ts.map +1 -0
  28. package/dist/local-flow-state-data-source-projection.js +65 -0
  29. package/dist/local-flow-state-data-source-projection.js.map +1 -0
  30. package/dist/navigation-runtime-context.d.ts +22 -0
  31. package/dist/navigation-runtime-context.d.ts.map +1 -0
  32. package/dist/navigation-runtime-context.js +23 -0
  33. package/dist/navigation-runtime-context.js.map +1 -0
  34. package/dist/navigation-shell-frame-renderer-registry.d.ts +20 -0
  35. package/dist/navigation-shell-frame-renderer-registry.d.ts.map +1 -0
  36. package/dist/navigation-shell-frame-renderer-registry.js +9 -0
  37. package/dist/navigation-shell-frame-renderer-registry.js.map +1 -0
  38. package/dist/navigation-shell-region-component-registry.d.ts +50 -0
  39. package/dist/navigation-shell-region-component-registry.d.ts.map +1 -0
  40. package/dist/navigation-shell-region-component-registry.js +44 -0
  41. package/dist/navigation-shell-region-component-registry.js.map +1 -0
  42. package/dist/navigation-shell-slot-renderer-registry.d.ts +22 -0
  43. package/dist/navigation-shell-slot-renderer-registry.d.ts.map +1 -0
  44. package/dist/navigation-shell-slot-renderer-registry.js +9 -0
  45. package/dist/navigation-shell-slot-renderer-registry.js.map +1 -0
  46. package/dist/page-host-projection.d.ts +127 -0
  47. package/dist/page-host-projection.d.ts.map +1 -0
  48. package/dist/page-host-projection.js +59 -0
  49. package/dist/page-host-projection.js.map +1 -0
  50. package/dist/page-host-renderer-registry.d.ts +72 -0
  51. package/dist/page-host-renderer-registry.d.ts.map +1 -0
  52. package/dist/page-host-renderer-registry.js +63 -0
  53. package/dist/page-host-renderer-registry.js.map +1 -0
  54. package/dist/presentation-action-group-runtime-options.d.ts +36 -0
  55. package/dist/presentation-action-group-runtime-options.d.ts.map +1 -0
  56. package/dist/presentation-action-group-runtime-options.js +50 -0
  57. package/dist/presentation-action-group-runtime-options.js.map +1 -0
  58. package/dist/presentation-action-runtime.d.ts +52 -0
  59. package/dist/presentation-action-runtime.d.ts.map +1 -0
  60. package/dist/presentation-action-runtime.js +78 -0
  61. package/dist/presentation-action-runtime.js.map +1 -0
  62. package/dist/presentation-data-source-binding-runtime.d.ts +3 -0
  63. package/dist/presentation-data-source-binding-runtime.d.ts.map +1 -0
  64. package/dist/presentation-data-source-binding-runtime.js +65 -0
  65. package/dist/presentation-data-source-binding-runtime.js.map +1 -0
  66. package/dist/presentation-data-source-binding.d.ts +12 -0
  67. package/dist/presentation-data-source-binding.d.ts.map +1 -0
  68. package/dist/presentation-data-source-binding.js +13 -0
  69. package/dist/presentation-data-source-binding.js.map +1 -0
  70. package/dist/presentation-flow-runtime.d.ts +139 -0
  71. package/dist/presentation-flow-runtime.d.ts.map +1 -0
  72. package/dist/presentation-flow-runtime.js +514 -0
  73. package/dist/presentation-flow-runtime.js.map +1 -0
  74. package/dist/presentation-module-context.d.ts +4 -0
  75. package/dist/presentation-module-context.d.ts.map +1 -0
  76. package/dist/presentation-module-context.js +6 -0
  77. package/dist/presentation-module-context.js.map +1 -0
  78. package/dist/presentation-module-provider.d.ts +7 -0
  79. package/dist/presentation-module-provider.d.ts.map +1 -0
  80. package/dist/presentation-module-provider.js +7 -0
  81. package/dist/presentation-module-provider.js.map +1 -0
  82. package/dist/presentation-projection-diagnostics-context.d.ts +8 -0
  83. package/dist/presentation-projection-diagnostics-context.d.ts.map +1 -0
  84. package/dist/presentation-projection-diagnostics-context.js +3 -0
  85. package/dist/presentation-projection-diagnostics-context.js.map +1 -0
  86. package/dist/presentation-projection-diagnostics-hooks.d.ts +4 -0
  87. package/dist/presentation-projection-diagnostics-hooks.d.ts.map +1 -0
  88. package/dist/presentation-projection-diagnostics-hooks.js +17 -0
  89. package/dist/presentation-projection-diagnostics-hooks.js.map +1 -0
  90. package/dist/presentation-projection-diagnostics-runtime.d.ts +12 -0
  91. package/dist/presentation-projection-diagnostics-runtime.d.ts.map +1 -0
  92. package/dist/presentation-projection-diagnostics-runtime.js +54 -0
  93. package/dist/presentation-projection-diagnostics-runtime.js.map +1 -0
  94. package/dist/presentation-projection-trace.d.ts +27 -0
  95. package/dist/presentation-projection-trace.d.ts.map +1 -0
  96. package/dist/presentation-projection-trace.js +54 -0
  97. package/dist/presentation-projection-trace.js.map +1 -0
  98. package/dist/presentation-query-form-runtime.d.ts +30 -0
  99. package/dist/presentation-query-form-runtime.d.ts.map +1 -0
  100. package/dist/presentation-query-form-runtime.js +75 -0
  101. package/dist/presentation-query-form-runtime.js.map +1 -0
  102. package/dist/presentation-query-form-state-adapter-registry.d.ts +4 -0
  103. package/dist/presentation-query-form-state-adapter-registry.d.ts.map +1 -0
  104. package/dist/presentation-query-form-state-adapter-registry.js +13 -0
  105. package/dist/presentation-query-form-state-adapter-registry.js.map +1 -0
  106. package/dist/presentation-query-form-state-context.d.ts +20 -0
  107. package/dist/presentation-query-form-state-context.d.ts.map +1 -0
  108. package/dist/presentation-query-form-state-context.js +20 -0
  109. package/dist/presentation-query-form-state-context.js.map +1 -0
  110. package/dist/presentation-query-form-state.d.ts +29 -0
  111. package/dist/presentation-query-form-state.d.ts.map +1 -0
  112. package/dist/presentation-query-form-state.js +99 -0
  113. package/dist/presentation-query-form-state.js.map +1 -0
  114. package/dist/presentation-renderer-registry.d.ts +109 -0
  115. package/dist/presentation-renderer-registry.d.ts.map +1 -0
  116. package/dist/presentation-renderer-registry.js +25 -0
  117. package/dist/presentation-renderer-registry.js.map +1 -0
  118. package/dist/presentation-standards-context.d.ts +4 -0
  119. package/dist/presentation-standards-context.d.ts.map +1 -0
  120. package/dist/presentation-standards-context.js +12 -0
  121. package/dist/presentation-standards-context.js.map +1 -0
  122. package/dist/presentation-standards-provider.d.ts +14 -0
  123. package/dist/presentation-standards-provider.d.ts.map +1 -0
  124. package/dist/presentation-standards-provider.js +16 -0
  125. package/dist/presentation-standards-provider.js.map +1 -0
  126. package/dist/projected-document-action-runtime-bindings.d.ts +20 -0
  127. package/dist/projected-document-action-runtime-bindings.d.ts.map +1 -0
  128. package/dist/projected-document-action-runtime-bindings.js +88 -0
  129. package/dist/projected-document-action-runtime-bindings.js.map +1 -0
  130. package/dist/projected-document-action-runtime.d.ts +76 -0
  131. package/dist/projected-document-action-runtime.d.ts.map +1 -0
  132. package/dist/projected-document-action-runtime.js +224 -0
  133. package/dist/projected-document-action-runtime.js.map +1 -0
  134. package/dist/projected-document-process-preview-action-runtime-bindings.d.ts +26 -0
  135. package/dist/projected-document-process-preview-action-runtime-bindings.d.ts.map +1 -0
  136. package/dist/projected-document-process-preview-action-runtime-bindings.js +106 -0
  137. package/dist/projected-document-process-preview-action-runtime-bindings.js.map +1 -0
  138. package/dist/projected-document-process-preview-action-runtime.d.ts +321 -0
  139. package/dist/projected-document-process-preview-action-runtime.d.ts.map +1 -0
  140. package/dist/projected-document-process-preview-action-runtime.js +729 -0
  141. package/dist/projected-document-process-preview-action-runtime.js.map +1 -0
  142. package/dist/projected-document-process-preview-capability-runtime.d.ts +47 -0
  143. package/dist/projected-document-process-preview-capability-runtime.d.ts.map +1 -0
  144. package/dist/projected-document-process-preview-capability-runtime.js +49 -0
  145. package/dist/projected-document-process-preview-capability-runtime.js.map +1 -0
  146. package/dist/projected-document-workspace-action-runtime.d.ts +87 -0
  147. package/dist/projected-document-workspace-action-runtime.d.ts.map +1 -0
  148. package/dist/projected-document-workspace-action-runtime.js +150 -0
  149. package/dist/projected-document-workspace-action-runtime.js.map +1 -0
  150. package/dist/projected-document-workspace-projection-renderer-diagnostics.d.ts +18 -0
  151. package/dist/projected-document-workspace-projection-renderer-diagnostics.d.ts.map +1 -0
  152. package/dist/projected-document-workspace-projection-renderer-diagnostics.js +207 -0
  153. package/dist/projected-document-workspace-projection-renderer-diagnostics.js.map +1 -0
  154. package/dist/projected-document-workspace-runtime-binding-diagnostics.d.ts +19 -0
  155. package/dist/projected-document-workspace-runtime-binding-diagnostics.d.ts.map +1 -0
  156. package/dist/projected-document-workspace-runtime-binding-diagnostics.js +124 -0
  157. package/dist/projected-document-workspace-runtime-binding-diagnostics.js.map +1 -0
  158. package/dist/projected-navigation-provider.d.ts +16 -0
  159. package/dist/projected-navigation-provider.d.ts.map +1 -0
  160. package/dist/projected-navigation-provider.js +51 -0
  161. package/dist/projected-navigation-provider.js.map +1 -0
  162. package/dist/projected-presentation-flow-host.d.ts +16 -0
  163. package/dist/projected-presentation-flow-host.d.ts.map +1 -0
  164. package/dist/projected-presentation-flow-host.js +14 -0
  165. package/dist/projected-presentation-flow-host.js.map +1 -0
  166. package/dist/projected-query-form-state-adapter.d.ts +12 -0
  167. package/dist/projected-query-form-state-adapter.d.ts.map +1 -0
  168. package/dist/projected-query-form-state-adapter.js +361 -0
  169. package/dist/projected-query-form-state-adapter.js.map +1 -0
  170. package/dist/react-router-binding.d.ts +133 -0
  171. package/dist/react-router-binding.d.ts.map +1 -0
  172. package/dist/react-router-binding.js +76 -0
  173. package/dist/react-router-binding.js.map +1 -0
  174. package/dist/react-router-path.d.ts +4 -0
  175. package/dist/react-router-path.d.ts.map +1 -0
  176. package/dist/react-router-path.js +11 -0
  177. package/dist/react-router-path.js.map +1 -0
  178. package/dist/scope-selection-context.d.ts +28 -0
  179. package/dist/scope-selection-context.d.ts.map +1 -0
  180. package/dist/scope-selection-context.js +13 -0
  181. package/dist/scope-selection-context.js.map +1 -0
  182. package/dist/scope-selection-provider.d.ts +33 -0
  183. package/dist/scope-selection-provider.d.ts.map +1 -0
  184. package/dist/scope-selection-provider.js +162 -0
  185. package/dist/scope-selection-provider.js.map +1 -0
  186. package/dist/scope-selection-request.d.ts +6 -0
  187. package/dist/scope-selection-request.d.ts.map +1 -0
  188. package/dist/scope-selection-request.js +12 -0
  189. package/dist/scope-selection-request.js.map +1 -0
  190. package/dist/standard-navigation-shell-frame-renderers.d.ts +15 -0
  191. package/dist/standard-navigation-shell-frame-renderers.d.ts.map +1 -0
  192. package/dist/standard-navigation-shell-frame-renderers.js +22 -0
  193. package/dist/standard-navigation-shell-frame-renderers.js.map +1 -0
  194. package/dist/standard-navigation-shell-slot-renderers.d.ts +59 -0
  195. package/dist/standard-navigation-shell-slot-renderers.d.ts.map +1 -0
  196. package/dist/standard-navigation-shell-slot-renderers.js +67 -0
  197. package/dist/standard-navigation-shell-slot-renderers.js.map +1 -0
  198. package/dist/view-chrome-slot-renderer-registry.d.ts +12 -0
  199. package/dist/view-chrome-slot-renderer-registry.d.ts.map +1 -0
  200. package/dist/view-chrome-slot-renderer-registry.js +12 -0
  201. package/dist/view-chrome-slot-renderer-registry.js.map +1 -0
  202. package/package.json +60 -0
  203. package/src/collection-chrome-slot-renderer-registry.ts +66 -0
  204. package/src/collection-selection-state-context.ts +51 -0
  205. package/src/collection-selection-state.tsx +101 -0
  206. package/src/document-workspace-runtime.tsx +1505 -0
  207. package/src/index.ts +50 -0
  208. package/src/input-form-endpoint-runtime.ts +632 -0
  209. package/src/local-flow-state-data-source-projection.ts +133 -0
  210. package/src/navigation-runtime-context.ts +40 -0
  211. package/src/navigation-shell-frame-renderer-registry.ts +54 -0
  212. package/src/navigation-shell-region-component-registry.tsx +127 -0
  213. package/src/navigation-shell-slot-renderer-registry.ts +88 -0
  214. package/src/page-host-projection.ts +356 -0
  215. package/src/page-host-renderer-registry.tsx +353 -0
  216. package/src/presentation-action-group-runtime-options.ts +121 -0
  217. package/src/presentation-action-runtime.ts +190 -0
  218. package/src/presentation-data-source-binding-runtime.ts +109 -0
  219. package/src/presentation-data-source-binding.tsx +24 -0
  220. package/src/presentation-flow-runtime.tsx +835 -0
  221. package/src/presentation-module-context.ts +10 -0
  222. package/src/presentation-module-provider.tsx +19 -0
  223. package/src/presentation-projection-diagnostics-context.ts +17 -0
  224. package/src/presentation-projection-diagnostics-hooks.ts +29 -0
  225. package/src/presentation-projection-diagnostics-runtime.tsx +95 -0
  226. package/src/presentation-projection-trace.ts +117 -0
  227. package/src/presentation-query-form-runtime.ts +148 -0
  228. package/src/presentation-query-form-state-adapter-registry.ts +25 -0
  229. package/src/presentation-query-form-state-context.ts +56 -0
  230. package/src/presentation-query-form-state.tsx +250 -0
  231. package/src/presentation-renderer-registry.ts +214 -0
  232. package/src/presentation-standards-context.ts +21 -0
  233. package/src/presentation-standards-provider.tsx +44 -0
  234. package/src/projected-document-action-runtime-bindings.ts +132 -0
  235. package/src/projected-document-action-runtime.ts +414 -0
  236. package/src/projected-document-process-preview-action-runtime-bindings.ts +231 -0
  237. package/src/projected-document-process-preview-action-runtime.ts +1725 -0
  238. package/src/projected-document-process-preview-capability-runtime.ts +216 -0
  239. package/src/projected-document-workspace-action-runtime.ts +402 -0
  240. package/src/projected-document-workspace-projection-renderer-diagnostics.ts +342 -0
  241. package/src/projected-document-workspace-runtime-binding-diagnostics.ts +208 -0
  242. package/src/projected-navigation-provider.tsx +104 -0
  243. package/src/projected-presentation-flow-host.tsx +46 -0
  244. package/src/projected-query-form-state-adapter.ts +578 -0
  245. package/src/react-router-binding.tsx +417 -0
  246. package/src/react-router-path.ts +16 -0
  247. package/src/scope-selection-context.ts +58 -0
  248. package/src/scope-selection-provider.tsx +324 -0
  249. package/src/scope-selection-request.ts +21 -0
  250. package/src/standard-navigation-shell-frame-renderers.tsx +106 -0
  251. package/src/standard-navigation-shell-slot-renderers.tsx +289 -0
  252. 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 }