@cratis/scene.react 4.28.0 → 4.30.0

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 (193) hide show
  1. package/core/CoreToolbar.tsx +37 -6
  2. package/core/coreComponentMetadata.ts +1 -0
  3. package/core/coreComponents.ts +2 -0
  4. package/core/coreDescriptors.ts +13 -0
  5. package/core/corePackage.ts +1 -0
  6. package/dist/cjs/core/CoreToolbar.js +44 -4
  7. package/dist/cjs/core/CoreToolbar.js.map +1 -1
  8. package/dist/cjs/core/coreComponentMetadata.js +6 -0
  9. package/dist/cjs/core/coreComponentMetadata.js.map +1 -1
  10. package/dist/cjs/core/coreComponents.js +3 -1
  11. package/dist/cjs/core/coreComponents.js.map +1 -1
  12. package/dist/cjs/core/coreDescriptors.js +27 -0
  13. package/dist/cjs/core/coreDescriptors.js.map +1 -1
  14. package/dist/cjs/core/corePackage.js +2 -1
  15. package/dist/cjs/core/corePackage.js.map +1 -1
  16. package/dist/cjs/index.js +36 -0
  17. package/dist/cjs/index.js.map +1 -1
  18. package/dist/cjs/navigation/SceneNavigationContext.js.map +1 -1
  19. package/dist/cjs/navigation/SceneNavigationHost.js +34 -18
  20. package/dist/cjs/navigation/SceneNavigationHost.js.map +1 -1
  21. package/dist/cjs/navigation/region/NavigationRegionClassNames.js +21 -0
  22. package/dist/cjs/navigation/region/NavigationRegionClassNames.js.map +1 -0
  23. package/dist/cjs/navigation/region/NavigationRegionView.js +283 -0
  24. package/dist/cjs/navigation/region/NavigationRegionView.js.map +1 -0
  25. package/dist/cjs/navigation/region/SceneNavigationModelContext.js +22 -0
  26. package/dist/cjs/navigation/region/SceneNavigationModelContext.js.map +1 -0
  27. package/dist/cjs/navigation/region/currentModuleOf.js +15 -0
  28. package/dist/cjs/navigation/region/currentModuleOf.js.map +1 -0
  29. package/dist/cjs/navigation/region/navigationDestinations.js +46 -0
  30. package/dist/cjs/navigation/region/navigationDestinations.js.map +1 -0
  31. package/dist/cjs/navigation/region/navigationItemActive.js +31 -0
  32. package/dist/cjs/navigation/region/navigationItemActive.js.map +1 -0
  33. package/dist/cjs/navigation/region/navigationItemDestination.js +34 -0
  34. package/dist/cjs/navigation/region/navigationItemDestination.js.map +1 -0
  35. package/dist/cjs/navigation/useSceneHistoryNavigation.js +3 -1
  36. package/dist/cjs/navigation/useSceneHistoryNavigation.js.map +1 -1
  37. package/dist/cjs/slices/CoreSliceDialog.js +21 -0
  38. package/dist/cjs/slices/CoreSliceDialog.js.map +1 -0
  39. package/dist/cjs/slices/SliceCommandFieldsContext.js +22 -0
  40. package/dist/cjs/slices/SliceCommandFieldsContext.js.map +1 -0
  41. package/dist/cjs/slices/SliceDialogView.js +254 -0
  42. package/dist/cjs/slices/SliceDialogView.js.map +1 -0
  43. package/dist/cjs/slices/SliceInvokerContext.js +40 -0
  44. package/dist/cjs/slices/SliceInvokerContext.js.map +1 -0
  45. package/dist/cjs/slices/createAnnouncingInvoker.js +27 -0
  46. package/dist/cjs/slices/createAnnouncingInvoker.js.map +1 -0
  47. package/dist/cjs/slices/createDryRunInvoker.js +38 -0
  48. package/dist/cjs/slices/createDryRunInvoker.js.map +1 -0
  49. package/dist/cjs/slices/sliceDialogDestination.js +41 -0
  50. package/dist/cjs/slices/sliceDialogDestination.js.map +1 -0
  51. package/dist/esm/core/CoreToolbar.d.ts.map +1 -1
  52. package/dist/esm/core/CoreToolbar.js +47 -7
  53. package/dist/esm/core/CoreToolbar.js.map +1 -1
  54. package/dist/esm/core/coreComponentMetadata.d.ts.map +1 -1
  55. package/dist/esm/core/coreComponentMetadata.js +6 -0
  56. package/dist/esm/core/coreComponentMetadata.js.map +1 -1
  57. package/dist/esm/core/coreComponents.d.ts.map +1 -1
  58. package/dist/esm/core/coreComponents.js +3 -1
  59. package/dist/esm/core/coreComponents.js.map +1 -1
  60. package/dist/esm/core/coreDescriptors.d.ts.map +1 -1
  61. package/dist/esm/core/coreDescriptors.js +27 -0
  62. package/dist/esm/core/coreDescriptors.js.map +1 -1
  63. package/dist/esm/core/corePackage.d.ts.map +1 -1
  64. package/dist/esm/core/corePackage.js +2 -1
  65. package/dist/esm/core/corePackage.js.map +1 -1
  66. package/dist/esm/index.d.ts +1 -0
  67. package/dist/esm/index.d.ts.map +1 -1
  68. package/dist/esm/index.js +14 -0
  69. package/dist/esm/index.js.map +1 -1
  70. package/dist/esm/navigation/SceneNavigationContext.d.ts +1 -0
  71. package/dist/esm/navigation/SceneNavigationContext.d.ts.map +1 -1
  72. package/dist/esm/navigation/SceneNavigationContext.js.map +1 -1
  73. package/dist/esm/navigation/SceneNavigationHost.d.ts +5 -1
  74. package/dist/esm/navigation/SceneNavigationHost.d.ts.map +1 -1
  75. package/dist/esm/navigation/SceneNavigationHost.js +35 -19
  76. package/dist/esm/navigation/SceneNavigationHost.js.map +1 -1
  77. package/dist/esm/navigation/SceneNavigationState.d.ts +1 -0
  78. package/dist/esm/navigation/SceneNavigationState.d.ts.map +1 -1
  79. package/dist/esm/navigation/index.d.ts +8 -0
  80. package/dist/esm/navigation/index.d.ts.map +1 -1
  81. package/dist/esm/navigation/index.js +8 -0
  82. package/dist/esm/navigation/index.js.map +1 -1
  83. package/dist/esm/navigation/region/NavigationRegionClassNames.d.ts +12 -0
  84. package/dist/esm/navigation/region/NavigationRegionClassNames.d.ts.map +1 -0
  85. package/dist/esm/navigation/region/NavigationRegionClassNames.js +19 -0
  86. package/dist/esm/navigation/region/NavigationRegionClassNames.js.map +1 -0
  87. package/dist/esm/navigation/region/NavigationRegionView.d.ts +20 -0
  88. package/dist/esm/navigation/region/NavigationRegionView.d.ts.map +1 -0
  89. package/dist/esm/navigation/region/NavigationRegionView.js +281 -0
  90. package/dist/esm/navigation/region/NavigationRegionView.js.map +1 -0
  91. package/dist/esm/navigation/region/SceneNavigationModel.d.ts +9 -0
  92. package/dist/esm/navigation/region/SceneNavigationModel.d.ts.map +1 -0
  93. package/dist/esm/navigation/region/SceneNavigationModel.js +2 -0
  94. package/dist/esm/navigation/region/SceneNavigationModel.js.map +1 -0
  95. package/dist/esm/navigation/region/SceneNavigationModelContext.d.ts +9 -0
  96. package/dist/esm/navigation/region/SceneNavigationModelContext.d.ts.map +1 -0
  97. package/dist/esm/navigation/region/SceneNavigationModelContext.js +19 -0
  98. package/dist/esm/navigation/region/SceneNavigationModelContext.js.map +1 -0
  99. package/dist/esm/navigation/region/currentModuleOf.d.ts +3 -0
  100. package/dist/esm/navigation/region/currentModuleOf.d.ts.map +1 -0
  101. package/dist/esm/navigation/region/currentModuleOf.js +13 -0
  102. package/dist/esm/navigation/region/currentModuleOf.js.map +1 -0
  103. package/dist/esm/navigation/region/navigationDestinations.d.ts +4 -0
  104. package/dist/esm/navigation/region/navigationDestinations.d.ts.map +1 -0
  105. package/dist/esm/navigation/region/navigationDestinations.js +44 -0
  106. package/dist/esm/navigation/region/navigationDestinations.js.map +1 -0
  107. package/dist/esm/navigation/region/navigationItemActive.d.ts +5 -0
  108. package/dist/esm/navigation/region/navigationItemActive.d.ts.map +1 -0
  109. package/dist/esm/navigation/region/navigationItemActive.js +29 -0
  110. package/dist/esm/navigation/region/navigationItemActive.js.map +1 -0
  111. package/dist/esm/navigation/region/navigationItemDestination.d.ts +5 -0
  112. package/dist/esm/navigation/region/navigationItemDestination.d.ts.map +1 -0
  113. package/dist/esm/navigation/region/navigationItemDestination.js +31 -0
  114. package/dist/esm/navigation/region/navigationItemDestination.js.map +1 -0
  115. package/dist/esm/navigation/useSceneHistoryNavigation.d.ts.map +1 -1
  116. package/dist/esm/navigation/useSceneHistoryNavigation.js +3 -1
  117. package/dist/esm/navigation/useSceneHistoryNavigation.js.map +1 -1
  118. package/dist/esm/slices/CoreSliceDialog.d.ts +3 -0
  119. package/dist/esm/slices/CoreSliceDialog.d.ts.map +1 -0
  120. package/dist/esm/slices/CoreSliceDialog.js +19 -0
  121. package/dist/esm/slices/CoreSliceDialog.js.map +1 -0
  122. package/dist/esm/slices/InvocationResult.d.ts +10 -0
  123. package/dist/esm/slices/InvocationResult.d.ts.map +1 -0
  124. package/dist/esm/slices/InvocationResult.js +2 -0
  125. package/dist/esm/slices/InvocationResult.js.map +1 -0
  126. package/dist/esm/slices/InvocationValidationError.d.ts +5 -0
  127. package/dist/esm/slices/InvocationValidationError.d.ts.map +1 -0
  128. package/dist/esm/slices/InvocationValidationError.js +2 -0
  129. package/dist/esm/slices/InvocationValidationError.js.map +1 -0
  130. package/dist/esm/slices/SliceCommandField.d.ts +7 -0
  131. package/dist/esm/slices/SliceCommandField.d.ts.map +1 -0
  132. package/dist/esm/slices/SliceCommandField.js +2 -0
  133. package/dist/esm/slices/SliceCommandField.js.map +1 -0
  134. package/dist/esm/slices/SliceCommandFieldsContext.d.ts +10 -0
  135. package/dist/esm/slices/SliceCommandFieldsContext.d.ts.map +1 -0
  136. package/dist/esm/slices/SliceCommandFieldsContext.js +19 -0
  137. package/dist/esm/slices/SliceCommandFieldsContext.js.map +1 -0
  138. package/dist/esm/slices/SliceDialogView.d.ts +12 -0
  139. package/dist/esm/slices/SliceDialogView.d.ts.map +1 -0
  140. package/dist/esm/slices/SliceDialogView.js +250 -0
  141. package/dist/esm/slices/SliceDialogView.js.map +1 -0
  142. package/dist/esm/slices/SliceInvoker.d.ts +5 -0
  143. package/dist/esm/slices/SliceInvoker.d.ts.map +1 -0
  144. package/dist/esm/slices/SliceInvoker.js +2 -0
  145. package/dist/esm/slices/SliceInvoker.js.map +1 -0
  146. package/dist/esm/slices/SliceInvokerContext.d.ts +11 -0
  147. package/dist/esm/slices/SliceInvokerContext.d.ts.map +1 -0
  148. package/dist/esm/slices/SliceInvokerContext.js +36 -0
  149. package/dist/esm/slices/SliceInvokerContext.js.map +1 -0
  150. package/dist/esm/slices/createAnnouncingInvoker.d.ts +3 -0
  151. package/dist/esm/slices/createAnnouncingInvoker.d.ts.map +1 -0
  152. package/dist/esm/slices/createAnnouncingInvoker.js +25 -0
  153. package/dist/esm/slices/createAnnouncingInvoker.js.map +1 -0
  154. package/dist/esm/slices/createDryRunInvoker.d.ts +15 -0
  155. package/dist/esm/slices/createDryRunInvoker.d.ts.map +1 -0
  156. package/dist/esm/slices/createDryRunInvoker.js +36 -0
  157. package/dist/esm/slices/createDryRunInvoker.js.map +1 -0
  158. package/dist/esm/slices/index.d.ts +12 -0
  159. package/dist/esm/slices/index.d.ts.map +1 -0
  160. package/dist/esm/slices/index.js +12 -0
  161. package/dist/esm/slices/index.js.map +1 -0
  162. package/dist/esm/slices/sliceDialogDestination.d.ts +10 -0
  163. package/dist/esm/slices/sliceDialogDestination.d.ts.map +1 -0
  164. package/dist/esm/slices/sliceDialogDestination.js +38 -0
  165. package/dist/esm/slices/sliceDialogDestination.js.map +1 -0
  166. package/dist/esm/tsconfig.tsbuildinfo +1 -1
  167. package/index.ts +1 -0
  168. package/navigation/SceneNavigationContext.tsx +3 -0
  169. package/navigation/SceneNavigationHost.tsx +35 -9
  170. package/navigation/SceneNavigationState.ts +3 -0
  171. package/navigation/index.ts +8 -0
  172. package/navigation/region/NavigationRegionClassNames.ts +46 -0
  173. package/navigation/region/NavigationRegionView.tsx +234 -0
  174. package/navigation/region/SceneNavigationModel.ts +29 -0
  175. package/navigation/region/SceneNavigationModelContext.tsx +25 -0
  176. package/navigation/region/currentModuleOf.ts +14 -0
  177. package/navigation/region/navigationDestinations.ts +41 -0
  178. package/navigation/region/navigationItemActive.ts +39 -0
  179. package/navigation/region/navigationItemDestination.ts +29 -0
  180. package/navigation/useSceneHistoryNavigation.ts +2 -1
  181. package/package.json +5 -5
  182. package/slices/CoreSliceDialog.tsx +14 -0
  183. package/slices/InvocationResult.ts +27 -0
  184. package/slices/InvocationValidationError.ts +13 -0
  185. package/slices/SliceCommandField.ts +19 -0
  186. package/slices/SliceCommandFieldsContext.tsx +28 -0
  187. package/slices/SliceDialogView.tsx +176 -0
  188. package/slices/SliceInvoker.ts +19 -0
  189. package/slices/SliceInvokerContext.tsx +47 -0
  190. package/slices/createAnnouncingInvoker.ts +17 -0
  191. package/slices/createDryRunInvoker.ts +43 -0
  192. package/slices/index.ts +14 -0
  193. package/slices/sliceDialogDestination.ts +40 -0
@@ -1 +1 @@
1
- {"version":3,"file":"SceneNavigationContext.js","sources":["../../../navigation/SceneNavigationContext.tsx"],"sourcesContent":["// Copyright (c) Cratis. All rights reserved.\n// Licensed under the MIT license. See LICENSE file in the project root for full license information.\n\nimport { ReactNode, createContext, useContext } from 'react';\nimport { BindingScope } from '@cratis/scene.engine';\nimport { DestinationReference } from '@cratis/scene.model';\nimport { DestinationResolution } from './DestinationResolution';\nimport { DialogResult } from './DialogResult';\n\nexport interface SceneNavigationContextValue {\n /** The screen the last navigation opened. */\n currentScreen: string;\n\n /** The screen in the primary region. */\n primaryScreen: string;\n\n /** Which screen each nested outlet shows, by outlet name. */\n outlets: Record<string, string>;\n currentUrl?: string;\n currentOutlet?: string;\n currentDialog?: string;\n\n /** The route parameters of the current entry - from the destination that opened it, or the deep link. */\n currentParameters: Record<string, string>;\n\n /** What the last dialog returned when it closed. */\n dialogResult?: DialogResult;\n\n /** A deep link that matched no route; the host fell back to its initial screen. */\n unresolvedUrl?: string;\n bindingScope: BindingScope;\n navigate(destination: DestinationReference): DestinationResolution;\n\n /** Closes the open dialog, returning to the entry that opened it, and records its result. */\n closeDialog(result?: unknown): void;\n\n /** Goes back one history entry. */\n back(): void;\n}\n\nconst Context = createContext<SceneNavigationContextValue | undefined>(undefined);\n\n/** The navigation context itself, for components that render outside a host as well as inside one. */\nexport const SceneNavigationContextInternal = Context;\n\nexport interface SceneNavigationProviderProps {\n value: SceneNavigationContextValue;\n children: ReactNode;\n}\n\nexport function SceneNavigationProvider({ value, children }: SceneNavigationProviderProps) {\n return <Context.Provider value={value}>{children}</Context.Provider>;\n}\n\nexport function useSceneNavigation(): SceneNavigationContextValue {\n const context = useContext(Context);\n if (!context) throw new Error('No Scene navigation context is available.');\n return context;\n}\n"],"names":["Context","createContext","undefined","SceneNavigationContextInternal","SceneNavigationProvider","value","children","_jsx","Provider","useSceneNavigation","context","useContext","Error"],"mappings":";;;;;AAwCA,MAAMA,wBAAUC,mBAAAA,CAAuDC,SAAAA,CAAAA;AAEvE,uGACO,MAAMC,8BAAAA,GAAiCH;AAOvC,SAASI,uBAAAA,CAAwB,EAAEC,KAAK,EAAEC,QAAQ,EAAgC,EAAA;IACrF,qBAAOC,cAAA,CAACP,QAAQQ,QAAQ,EAAA;QAACH,KAAAA,EAAOA,KAAAA;AAAQC,QAAAA,QAAAA,EAAAA;;AAC5C;AAEO,SAASG,kBAAAA,GAAAA;AACZ,IAAA,MAAMC,UAAUC,gBAAAA,CAAWX,OAAAA,CAAAA;AAC3B,IAAA,IAAI,CAACU,OAAAA,EAAS,MAAM,IAAIE,KAAAA,CAAM,2CAAA,CAAA;IAC9B,OAAOF,OAAAA;AACX;;;;"}
1
+ {"version":3,"file":"SceneNavigationContext.js","sources":["../../../navigation/SceneNavigationContext.tsx"],"sourcesContent":["// Copyright (c) Cratis. All rights reserved.\n// Licensed under the MIT license. See LICENSE file in the project root for full license information.\n\nimport { ReactNode, createContext, useContext } from 'react';\nimport { BindingScope } from '@cratis/scene.engine';\nimport { DestinationReference } from '@cratis/scene.model';\nimport { DestinationResolution } from './DestinationResolution';\nimport { DialogResult } from './DialogResult';\n\nexport interface SceneNavigationContextValue {\n /** The screen the last navigation opened. */\n currentScreen: string;\n\n /** The screen in the primary region. */\n primaryScreen: string;\n\n /** Which screen each nested outlet shows, by outlet name. */\n outlets: Record<string, string>;\n currentUrl?: string;\n currentOutlet?: string;\n currentDialog?: string;\n\n /** The parameters the open dialog was opened with - a slice dialog carries its slice, command and title. */\n currentDialogParameters?: Record<string, string>;\n\n /** The route parameters of the current entry - from the destination that opened it, or the deep link. */\n currentParameters: Record<string, string>;\n\n /** What the last dialog returned when it closed. */\n dialogResult?: DialogResult;\n\n /** A deep link that matched no route; the host fell back to its initial screen. */\n unresolvedUrl?: string;\n bindingScope: BindingScope;\n navigate(destination: DestinationReference): DestinationResolution;\n\n /** Closes the open dialog, returning to the entry that opened it, and records its result. */\n closeDialog(result?: unknown): void;\n\n /** Goes back one history entry. */\n back(): void;\n}\n\nconst Context = createContext<SceneNavigationContextValue | undefined>(undefined);\n\n/** The navigation context itself, for components that render outside a host as well as inside one. */\nexport const SceneNavigationContextInternal = Context;\n\nexport interface SceneNavigationProviderProps {\n value: SceneNavigationContextValue;\n children: ReactNode;\n}\n\nexport function SceneNavigationProvider({ value, children }: SceneNavigationProviderProps) {\n return <Context.Provider value={value}>{children}</Context.Provider>;\n}\n\nexport function useSceneNavigation(): SceneNavigationContextValue {\n const context = useContext(Context);\n if (!context) throw new Error('No Scene navigation context is available.');\n return context;\n}\n"],"names":["Context","createContext","undefined","SceneNavigationContextInternal","SceneNavigationProvider","value","children","_jsx","Provider","useSceneNavigation","context","useContext","Error"],"mappings":";;;;;AA2CA,MAAMA,wBAAUC,mBAAAA,CAAuDC,SAAAA,CAAAA;AAEvE,uGACO,MAAMC,8BAAAA,GAAiCH;AAOvC,SAASI,uBAAAA,CAAwB,EAAEC,KAAK,EAAEC,QAAQ,EAAgC,EAAA;IACrF,qBAAOC,cAAA,CAACP,QAAQQ,QAAQ,EAAA;QAACH,KAAAA,EAAOA,KAAAA;AAAQC,QAAAA,QAAAA,EAAAA;;AAC5C;AAEO,SAASG,kBAAAA,GAAAA;AACZ,IAAA,MAAMC,UAAUC,gBAAAA,CAAWX,OAAAA,CAAAA;AAC3B,IAAA,IAAI,CAACU,OAAAA,EAAS,MAAM,IAAIE,KAAAA,CAAM,2CAAA,CAAA;IAC9B,OAAOF,OAAAA;AACX;;;;"}
@@ -9,14 +9,23 @@ var sceneRoutesFrom = require('./sceneRoutesFrom.js');
9
9
  var collectOutletOwners = require('./collectOutletOwners.js');
10
10
  var SceneOutletContext = require('./SceneOutletContext.js');
11
11
  var useSceneHistoryNavigation = require('./useSceneHistoryNavigation.js');
12
+ var SceneNavigationModelContext = require('./region/SceneNavigationModelContext.js');
13
+ var navigationDestinations = require('./region/navigationDestinations.js');
14
+ var SliceDialogView = require('../slices/SliceDialogView.js');
15
+ var sliceDialogDestination = require('../slices/sliceDialogDestination.js');
12
16
 
13
17
  /**
14
18
  * Executes Scene destinations against an in-memory rendered hierarchy: a destination into a nested outlet -
15
19
  * one a screen declares with `core:outlet` - places its screen there and keeps the screens above it, to any
16
20
  * depth; any other screen route replaces the primary region,
17
- * dialog destinations render dialog content over the screen that opened them, and external destinations
21
+ * dialog destinations render dialog content over the screen that opened them - a toolbar slice button's dialog falls back to
22
+ * the built-in task dialog (`SliceDialogView`) when `dialogs` has no template of that name -, and external destinations
18
23
  * only report their resolved action. Every navigation is a history entry.
19
- */ function SceneNavigationHost({ screens, dialogs = {}, initialScreen, registry, bindingScope = {}, history, destinations, routes }) {
24
+ */ function SceneNavigationHost({ screens, dialogs = {}, initialScreen, registry, bindingScope = {}, history, destinations: authoredDestinations, routes, navigationModel, frame }) {
25
+ const destinations = react.useMemo(()=>authoredDestinations ?? (navigationModel ? navigationDestinations.navigationDestinations(navigationModel.structure, navigationModel.navigation, navigationModel.screenFor) : undefined), [
26
+ authoredDestinations,
27
+ navigationModel
28
+ ]);
20
29
  const [memoryHistory] = react.useState(()=>createMemorySceneHistory.createMemorySceneHistory());
21
30
  const routeTable = react.useMemo(()=>routes ?? sceneRoutesFrom.sceneRoutesFrom(Object.keys(screens), destinations), [
22
31
  destinations,
@@ -36,38 +45,45 @@ var useSceneHistoryNavigation = require('./useSceneHistoryNavigation.js');
36
45
  ]);
37
46
  const screen = screens[value.primaryScreen];
38
47
  const dialog = value.currentDialog ? dialogs[value.currentDialog] : undefined;
39
- return /*#__PURE__*/ jsxRuntime.jsx(SceneNavigationContext.SceneNavigationProvider, {
48
+ const sliceDialog = !dialog && value.currentDialog && sliceDialogDestination.sliceDialogParameters(value.currentDialogParameters) !== undefined;
49
+ const dialogName = sliceDialogDestination.sliceDialogParameters(value.currentDialogParameters)?.title ?? value.currentDialog;
50
+ const outlet = /*#__PURE__*/ jsxRuntime.jsx("div", {
51
+ "data-scene-outlet": value.primaryScreen === value.currentScreen ? value.currentOutlet ?? 'primary' : 'primary',
52
+ "data-scene-url": value.currentUrl,
53
+ children: screen && /*#__PURE__*/ jsxRuntime.jsx(SceneElementView.SceneElementView, {
54
+ element: screen,
55
+ registry: registry,
56
+ dataContext: bindingScope.dataContext,
57
+ queryResults: bindingScope.queryResults,
58
+ componentOutputs: bindingScope.componentOutputs
59
+ })
60
+ });
61
+ const page = /*#__PURE__*/ jsxRuntime.jsx(SceneNavigationContext.SceneNavigationProvider, {
40
62
  value: value,
41
63
  children: /*#__PURE__*/ jsxRuntime.jsxs(SceneOutletContext.SceneOutletContext.Provider, {
42
64
  value: outletContext,
43
65
  children: [
44
- /*#__PURE__*/ jsxRuntime.jsx("div", {
45
- "data-scene-outlet": value.primaryScreen === value.currentScreen ? value.currentOutlet ?? 'primary' : 'primary',
46
- "data-scene-url": value.currentUrl,
47
- children: screen && /*#__PURE__*/ jsxRuntime.jsx(SceneElementView.SceneElementView, {
48
- element: screen,
49
- registry: registry,
50
- dataContext: bindingScope.dataContext,
51
- queryResults: bindingScope.queryResults,
52
- componentOutputs: bindingScope.componentOutputs
53
- })
54
- }),
55
- dialog && /*#__PURE__*/ jsxRuntime.jsx("div", {
66
+ frame ? frame(outlet) : outlet,
67
+ (dialog || sliceDialog) && /*#__PURE__*/ jsxRuntime.jsx("div", {
56
68
  role: "dialog",
57
69
  "aria-modal": "true",
58
- "aria-label": value.currentDialog,
70
+ "aria-label": dialogName,
59
71
  "data-scene-dialog": value.currentDialog,
60
- children: /*#__PURE__*/ jsxRuntime.jsx(SceneElementView.SceneElementView, {
72
+ children: dialog ? /*#__PURE__*/ jsxRuntime.jsx(SceneElementView.SceneElementView, {
61
73
  element: dialog,
62
74
  registry: registry,
63
75
  dataContext: bindingScope.dataContext,
64
76
  queryResults: bindingScope.queryResults,
65
77
  componentOutputs: bindingScope.componentOutputs
66
- })
78
+ }) : /*#__PURE__*/ jsxRuntime.jsx(SliceDialogView.SliceDialogView, {})
67
79
  })
68
80
  ]
69
81
  })
70
82
  });
83
+ return navigationModel ? /*#__PURE__*/ jsxRuntime.jsx(SceneNavigationModelContext.SceneNavigationModelProvider, {
84
+ model: navigationModel,
85
+ children: page
86
+ }) : page;
71
87
  }
72
88
 
73
89
  exports.SceneNavigationHost = SceneNavigationHost;
@@ -1 +1 @@
1
- {"version":3,"file":"SceneNavigationHost.js","sources":["../../../navigation/SceneNavigationHost.tsx"],"sourcesContent":["// Copyright (c) Cratis. All rights reserved.\n// Licensed under the MIT license. See LICENSE file in the project root for full license information.\n\nimport { useMemo, useState } from 'react';\nimport { BindingScope } from '@cratis/scene.engine';\nimport { DestinationReference, SceneElement } from '@cratis/scene.model';\nimport { SceneElementView } from '../SceneElementView';\nimport { ComponentRegistry } from '../renderer';\nimport { createMemorySceneHistory } from './createMemorySceneHistory';\nimport { SceneHistory } from './SceneHistory';\nimport { SceneNavigationProvider } from './SceneNavigationContext';\nimport { SceneRoute } from './SceneRoute';\nimport { sceneRoutesFrom } from './sceneRoutesFrom';\nimport { collectOutletOwners } from './collectOutletOwners';\nimport { SceneOutletContext } from './SceneOutletContext';\nimport { useSceneHistoryNavigation } from './useSceneHistoryNavigation';\n\nexport interface SceneNavigationHostProps {\n screens: Record<string, SceneElement>;\n dialogs?: Record<string, SceneElement>;\n initialScreen: string;\n registry: ComponentRegistry;\n bindingScope?: BindingScope;\n\n /**\n * Where entries are recorded. `createBrowserSceneHistory()` drives the address bar, so deep links,\n * refresh and back/forward work; the default is an in-memory history for embedded hosts.\n */\n history?: SceneHistory;\n\n /** The destinations the application navigates to, so their route overrides can be deep linked. */\n destinations?: DestinationReference[];\n\n /** An explicit route table, used instead of the one derived from `screens` and `destinations`. */\n routes?: SceneRoute[];\n}\n\n/**\n * Executes Scene destinations against an in-memory rendered hierarchy: a destination into a nested outlet -\n * one a screen declares with `core:outlet` - places its screen there and keeps the screens above it, to any\n * depth; any other screen route replaces the primary region,\n * dialog destinations render dialog content over the screen that opened them, and external destinations\n * only report their resolved action. Every navigation is a history entry.\n */\nexport function SceneNavigationHost({ screens, dialogs = {}, initialScreen, registry, bindingScope = {}, history, destinations, routes }: SceneNavigationHostProps) {\n const [memoryHistory] = useState(() => createMemorySceneHistory());\n const routeTable = useMemo(() => routes ?? sceneRoutesFrom(Object.keys(screens), destinations), [destinations, routes, screens]);\n const outletOwners = useMemo(() => collectOutletOwners(screens), [screens]);\n const value = useSceneHistoryNavigation(history ?? memoryHistory, routeTable, initialScreen, bindingScope, outletOwners, destinations);\n const outletContext = useMemo(() => ({ screens, registry }), [registry, screens]);\n\n const screen = screens[value.primaryScreen];\n const dialog = value.currentDialog ? dialogs[value.currentDialog] : undefined;\n\n return <SceneNavigationProvider value={value}><SceneOutletContext.Provider value={outletContext}>\n <div data-scene-outlet={value.primaryScreen === value.currentScreen ? value.currentOutlet ?? 'primary' : 'primary'} data-scene-url={value.currentUrl}>\n {screen && <SceneElementView element={screen} registry={registry} dataContext={bindingScope.dataContext} queryResults={bindingScope.queryResults} componentOutputs={bindingScope.componentOutputs} />}\n </div>\n {dialog && <div role='dialog' aria-modal='true' aria-label={value.currentDialog} data-scene-dialog={value.currentDialog}>\n <SceneElementView element={dialog} registry={registry} dataContext={bindingScope.dataContext} queryResults={bindingScope.queryResults} componentOutputs={bindingScope.componentOutputs} />\n </div>}\n </SceneOutletContext.Provider></SceneNavigationProvider>;\n}\n"],"names":["SceneNavigationHost","screens","dialogs","initialScreen","registry","bindingScope","history","destinations","routes","memoryHistory","useState","createMemorySceneHistory","routeTable","useMemo","sceneRoutesFrom","Object","keys","outletOwners","collectOutletOwners","value","useSceneHistoryNavigation","outletContext","screen","primaryScreen","dialog","currentDialog","undefined","_jsx","SceneNavigationProvider","_jsxs","SceneOutletContext","Provider","div","data-scene-outlet","currentScreen","currentOutlet","data-scene-url","currentUrl","SceneElementView","element","dataContext","queryResults","componentOutputs","role","aria-modal","aria-label","data-scene-dialog"],"mappings":";;;;;;;;;;;;AAqCA;;;;;;IAOO,SAASA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AAA,CAACK,KAAAA,EAAAA;oBAAIC,mBAAAA,EAAmBd,KAAAA,CAAMI,aAAa,KAAKJ,KAAAA,CAAMe,aAAa,GAAGf,KAAAA,CAAMgB,aAAa,IAAI,SAAA,GAAY,SAAA;AAAWC,oBAAAA,gBAAAA,EAAgBjB,MAAMkB,UAAU;AAC/If,oBAAAA,QAAAA,EAAAA,MAAAA,kBAAUK,cAAA,CAACW,iCAAAA,EAAAA;wBAAiBC,OAAAA,EAASjB,MAAAA;wBAAQlB,QAAAA,EAAUA,QAAAA;AAAUoC,wBAAAA,WAAAA,EAAanC,aAAamC,WAAW;AAAEC,wBAAAA,YAAAA,EAAcpC,aAAaoC,YAAY;AAAEC,wBAAAA,gBAAAA,EAAkBrC,aAAaqC;;;AAEpLlB,gBAAAA,MAAAA,kBAAUG,cAAA,CAACK,KAAAA,EAAAA;oBAAIW,IAAAA,EAAK,QAAA;oBAASC,YAAAA,EAAW,MAAA;AAAOC,oBAAAA,YAAAA,EAAY1B,MAAMM,aAAa;AAAEqB,oBAAAA,mBAAAA,EAAmB3B,MAAMM,aAAa;AACnH,oBAAA,QAAA,gBAAAE,cAAA,CAACW,iCAAAA,EAAAA;wBAAiBC,OAAAA,EAASf,MAAAA;wBAAQpB,QAAAA,EAAUA,QAAAA;AAAUoC,wBAAAA,WAAAA,EAAanC,aAAamC,WAAW;AAAEC,wBAAAA,YAAAA,EAAcpC,aAAaoC,YAAY;AAAEC,wBAAAA,gBAAAA,EAAkBrC,aAAaqC;;;;;;AAGlL;;"}
1
+ {"version":3,"file":"SceneNavigationHost.js","sources":["../../../navigation/SceneNavigationHost.tsx"],"sourcesContent":["// Copyright (c) Cratis. All rights reserved.\n// Licensed under the MIT license. See LICENSE file in the project root for full license information.\n\nimport { ReactNode, useMemo, useState } from 'react';\nimport { BindingScope } from '@cratis/scene.engine';\nimport { DestinationReference, SceneElement } from '@cratis/scene.model';\nimport { SceneElementView } from '../SceneElementView';\nimport { ComponentRegistry } from '../renderer';\nimport { createMemorySceneHistory } from './createMemorySceneHistory';\nimport { SceneHistory } from './SceneHistory';\nimport { SceneNavigationProvider } from './SceneNavigationContext';\nimport { SceneRoute } from './SceneRoute';\nimport { sceneRoutesFrom } from './sceneRoutesFrom';\nimport { collectOutletOwners } from './collectOutletOwners';\nimport { SceneOutletContext } from './SceneOutletContext';\nimport { useSceneHistoryNavigation } from './useSceneHistoryNavigation';\nimport { SceneNavigationModel } from './region/SceneNavigationModel';\nimport { SceneNavigationModelProvider } from './region/SceneNavigationModelContext';\nimport { navigationDestinations } from './region/navigationDestinations';\nimport { SliceDialogView } from '../slices/SliceDialogView';\nimport { sliceDialogParameters } from '../slices/sliceDialogDestination';\n\nexport interface SceneNavigationHostProps {\n screens: Record<string, SceneElement>;\n dialogs?: Record<string, SceneElement>;\n initialScreen: string;\n registry: ComponentRegistry;\n bindingScope?: BindingScope;\n\n /**\n * Where entries are recorded. `createBrowserSceneHistory()` drives the address bar, so deep links,\n * refresh and back/forward work; the default is an in-memory history for embedded hosts.\n */\n history?: SceneHistory;\n\n /** The destinations the application navigates to, so their route overrides can be deep linked. */\n destinations?: DestinationReference[];\n\n /**\n * The application's structure and navigation. Navigation regions rendered inside the host (`NavigationRegionView`) read it,\n * and - when `destinations` is not given - the destinations of every navigation item become the deep-linkable ones.\n */\n navigationModel?: SceneNavigationModel;\n\n /**\n * Wraps the primary outlet in the application's chrome - a topbar, a sidebar, a toolbar. The chrome is part of the host,\n * so it stays mounted while the screens inside it change and navigation regions keep their state.\n */\n frame?(content: ReactNode): ReactNode;\n\n /** An explicit route table, used instead of the one derived from `screens` and `destinations`. */\n routes?: SceneRoute[];\n}\n\n/**\n * Executes Scene destinations against an in-memory rendered hierarchy: a destination into a nested outlet -\n * one a screen declares with `core:outlet` - places its screen there and keeps the screens above it, to any\n * depth; any other screen route replaces the primary region,\n * dialog destinations render dialog content over the screen that opened them - a toolbar slice button's dialog falls back to\n * the built-in task dialog (`SliceDialogView`) when `dialogs` has no template of that name -, and external destinations\n * only report their resolved action. Every navigation is a history entry.\n */\nexport function SceneNavigationHost({ screens, dialogs = {}, initialScreen, registry, bindingScope = {}, history, destinations: authoredDestinations, routes, navigationModel, frame }: SceneNavigationHostProps) {\n const destinations = useMemo(\n () => authoredDestinations ?? (navigationModel ? navigationDestinations(navigationModel.structure, navigationModel.navigation, navigationModel.screenFor) : undefined),\n [authoredDestinations, navigationModel]);\n const [memoryHistory] = useState(() => createMemorySceneHistory());\n const routeTable = useMemo(() => routes ?? sceneRoutesFrom(Object.keys(screens), destinations), [destinations, routes, screens]);\n const outletOwners = useMemo(() => collectOutletOwners(screens), [screens]);\n const value = useSceneHistoryNavigation(history ?? memoryHistory, routeTable, initialScreen, bindingScope, outletOwners, destinations);\n const outletContext = useMemo(() => ({ screens, registry }), [registry, screens]);\n\n const screen = screens[value.primaryScreen];\n const dialog = value.currentDialog ? dialogs[value.currentDialog] : undefined;\n const sliceDialog = !dialog && value.currentDialog && sliceDialogParameters(value.currentDialogParameters) !== undefined;\n const dialogName = sliceDialogParameters(value.currentDialogParameters)?.title ?? value.currentDialog;\n\n const outlet = <div data-scene-outlet={value.primaryScreen === value.currentScreen ? value.currentOutlet ?? 'primary' : 'primary'} data-scene-url={value.currentUrl}>\n {screen && <SceneElementView element={screen} registry={registry} dataContext={bindingScope.dataContext} queryResults={bindingScope.queryResults} componentOutputs={bindingScope.componentOutputs} />}\n </div>;\n const page = <SceneNavigationProvider value={value}><SceneOutletContext.Provider value={outletContext}>\n {frame ? frame(outlet) : outlet}\n {(dialog || sliceDialog) && <div role='dialog' aria-modal='true' aria-label={dialogName} data-scene-dialog={value.currentDialog}>\n {dialog ? <SceneElementView element={dialog} registry={registry} dataContext={bindingScope.dataContext} queryResults={bindingScope.queryResults} componentOutputs={bindingScope.componentOutputs} /> : <SliceDialogView />}\n </div>}\n </SceneOutletContext.Provider></SceneNavigationProvider>;\n\n return navigationModel ? <SceneNavigationModelProvider model={navigationModel}>{page}</SceneNavigationModelProvider> : page;\n}\n"],"names":["SceneNavigationHost","screens","dialogs","initialScreen","registry","bindingScope","history","destinations","authoredDestinations","routes","navigationModel","frame","useMemo","navigationDestinations","structure","navigation","screenFor","undefined","memoryHistory","useState","createMemorySceneHistory","routeTable","sceneRoutesFrom","Object","keys","outletOwners","collectOutletOwners","value","useSceneHistoryNavigation","outletContext","screen","primaryScreen","dialog","currentDialog","sliceDialog","sliceDialogParameters","currentDialogParameters","dialogName","title","outlet","_jsx","div","data-scene-outlet","currentScreen","currentOutlet","data-scene-url","currentUrl","SceneElementView","element","dataContext","queryResults","componentOutputs","page","SceneNavigationProvider","_jsxs","SceneOutletContext","Provider","role","aria-modal","aria-label","data-scene-dialog","SliceDialogView","SceneNavigationModelProvider","model"],"mappings":";;;;;;;;;;;;;;;;AAsDA;;;;;;;AAOC,IACM,SAASA,mBAAAA,CAAoB,EAAEC,OAAO,EAAEC,OAAAA,GAAU,EAAE,EAAEC,aAAa,EAAEC,QAAQ,EAAEC,YAAAA,GAAe,EAAE,EAAEC,OAAO,EAAEC,YAAAA,EAAcC,oBAAoB,EAAEC,MAAM,EAAEC,eAAe,EAAEC,KAAK,EAA4B,EAAA;AAC5M,IAAA,MAAMJ,eAAeK,aAAAA,CACjB,IAAMJ,oBAAAA,KAAyBE,kBAAkBG,6CAAAA,CAAuBH,eAAAA,CAAgBI,SAAS,EAAEJ,gBAAgBK,UAAU,EAAEL,gBAAgBM,SAAS,CAAA,GAAIC,SAAQ,CAAA,EACpK;AAACT,QAAAA,oBAAAA;AAAsBE,QAAAA;AAAgB,KAAA,CAAA;AAC3C,IAAA,MAAM,CAACQ,aAAAA,CAAc,GAAGC,cAAAA,CAAS,IAAMC,iDAAAA,EAAAA,CAAAA;IACvC,MAAMC,UAAAA,GAAaT,cAAQ,IAAMH,MAAAA,IAAUa,gCAAgBC,MAAAA,CAAOC,IAAI,CAACvB,OAAAA,CAAAA,EAAUM,YAAAA,CAAAA,EAAe;AAACA,QAAAA,YAAAA;AAAcE,QAAAA,MAAA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1B,QAAAA,EAAUA,QAAAA;AAAU6C,YAAAA,WAAAA,EAAa5C,aAAa4C,WAAW;AAAEC,YAAAA,YAAAA,EAAc7C,aAAa6C,YAAY;AAAEC,YAAAA,gBAAAA,EAAkB9C,aAAa8C;;;AAErL,IAAA,MAAMC,qBAAOZ,cAAA,CAACa,8CAAAA,EAAAA;QAAwB1B,KAAAA,EAAOA,KAAAA;gCAAO2B,eAAA,CAACC,sCAAmBC,QAAQ,EAAA;YAAC7B,KAAAA,EAAOE,aAAAA;;AACnFlB,gBAAAA,KAAAA,GAAQA,MAAM4B,MAAAA,CAAAA,GAAUA,MAAAA;gBACvBP,CAAAA,MAAAA,IAAUE,WAAU,mBAAMM,cAAA,CAACC,KAAAA,EAAAA;oBAAIgB,IAAAA,EAAK,QAAA;oBAASC,YAAAA,EAAW,MAAA;oBAAOC,YAAAA,EAAYtB,UAAAA;AAAYuB,oBAAAA,mBAAAA,EAAmBjC,MAAMM,aAAa;AAC1HD,oBAAAA,QAAAA,EAAAA,MAAAA,iBAASQ,cAAA,CAACO,iCAAAA,EAAAA;wBAAiBC,OAAAA,EAAShB,MAAAA;wBAAQ5B,QAAAA,EAAUA,QAAAA;AAAU6C,wBAAAA,WAAAA,EAAa5C,aAAa4C,WAAW;AAAEC,wBAAAA,YAAAA,EAAc7C,aAAa6C,YAAY;AAAEC,wBAAAA,gBAAAA,EAAkB9C,aAAa8C;uCAAuBX,cAAA,CAACqB,+BAAAA,EAAAA,EAAAA;;;;;AAIhN,IAAA,OAAOnD,gCAAkB8B,cAAA,CAACsB,wDAAAA,EAAAA;QAA6BC,KAAAA,EAAOrD,eAAAA;AAAkB0C,QAAAA,QAAAA,EAAAA;AAAuCA,KAAAA,CAAAA,GAAAA,IAAAA;AAC3H;;"}
@@ -0,0 +1,21 @@
1
+ 'use strict';
2
+
3
+ // Copyright (c) Cratis. All rights reserved.
4
+ // Licensed under the MIT license. See LICENSE file in the project root for full license information.
5
+ /**
6
+ * The class names a {@link NavigationRegionView} puts on its nodes. The renderer carries no look of its own: a package
7
+ * gives the nodes its vocabulary (`blueprint.default` uses its `layout-menu` classes) and a stylesheet does the rest.
8
+ * State is always on data attributes as well - `data-active`, `data-expanded`, `data-read-only`, `data-origin`.
9
+ */ /** The class names used when a host passes none. */ const defaultNavigationRegionClassNames = {
10
+ root: 'scene-nav',
11
+ list: 'scene-nav-list',
12
+ item: 'scene-nav-item',
13
+ link: 'scene-nav-link',
14
+ icon: 'scene-nav-icon',
15
+ label: 'scene-nav-label',
16
+ toggle: 'scene-nav-toggle',
17
+ submenu: 'scene-nav-submenu'
18
+ };
19
+
20
+ exports.defaultNavigationRegionClassNames = defaultNavigationRegionClassNames;
21
+ //# sourceMappingURL=NavigationRegionClassNames.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"NavigationRegionClassNames.js","sources":["../../../../navigation/region/NavigationRegionClassNames.ts"],"sourcesContent":["// Copyright (c) Cratis. All rights reserved.\n// Licensed under the MIT license. See LICENSE file in the project root for full license information.\n\n\n/**\n * The class names a {@link NavigationRegionView} puts on its nodes. The renderer carries no look of its own: a package\n * gives the nodes its vocabulary (`blueprint.default` uses its `layout-menu` classes) and a stylesheet does the rest.\n * State is always on data attributes as well - `data-active`, `data-expanded`, `data-read-only`, `data-origin`.\n */\nexport interface NavigationRegionClassNames {\n /** The `nav` landmark. */\n root: string;\n\n /** Each list of items. */\n list: string;\n\n /** Each item's `li`. */\n item: string;\n\n /** The link of an item. */\n link: string;\n\n /** The icon of an item. */\n icon: string;\n\n /** The title of an item. */\n label: string;\n\n /** The button that expands or collapses an item's sub-items. */\n toggle: string;\n\n /** The list of an item's sub-items. */\n submenu: string;\n}\n\n/** The class names used when a host passes none. */\nexport const defaultNavigationRegionClassNames: NavigationRegionClassNames = {\n root: 'scene-nav',\n list: 'scene-nav-list',\n item: 'scene-nav-item',\n link: 'scene-nav-link',\n icon: 'scene-nav-icon',\n label: 'scene-nav-label',\n toggle: 'scene-nav-toggle',\n submenu: 'scene-nav-submenu',\n};\n"],"names":["defaultNavigationRegionClassNames","root","list","item","link","icon","label","toggle","submenu"],"mappings":";;AAAA;AACA;AAGA;;;;AAIC,yDA4BM,MAAMA,iCAAAA,GAAgE;IACzEC,IAAAA,EAAM,WAAA;IACNC,IAAAA,EAAM,gBAAA;IACNC,IAAAA,EAAM,gBAAA;IACNC,IAAAA,EAAM,gBAAA;IACNC,IAAAA,EAAM,gBAAA;IACNC,KAAAA,EAAO,iBAAA;IACPC,MAAAA,EAAQ,kBAAA;IACRC,OAAAA,EAAS;AACb;;"}
@@ -0,0 +1,283 @@
1
+ 'use strict';
2
+
3
+ var jsxRuntime = require('react/jsx-runtime');
4
+ var react = require('react');
5
+ var scene_model = require('@cratis/scene.model');
6
+ var scene_engine = require('@cratis/scene.engine');
7
+ var SceneIcon = require('../../icons/SceneIcon.js');
8
+ var IconAdapterContext = require('../../icons/IconAdapterContext.js');
9
+ var resolveDestination = require('../resolveDestination.js');
10
+ var SceneNavigationContext = require('../SceneNavigationContext.js');
11
+ var NavigationRegionClassNames = require('./NavigationRegionClassNames.js');
12
+ var SceneNavigationModelContext = require('./SceneNavigationModelContext.js');
13
+ var currentModuleOf = require('./currentModuleOf.js');
14
+ var navigationItemActive = require('./navigationItemActive.js');
15
+ var navigationItemDestination = require('./navigationItemDestination.js');
16
+
17
+ function itemKey(path) {
18
+ return path.join('/');
19
+ }
20
+ function containsActive(item, isActive) {
21
+ return isActive(item) || (item.children ?? []).some((child)=>containsActive(child, isActive));
22
+ }
23
+ /**
24
+ * Renders the effective navigation of one region - a topbar or a sidebar - for the application or a module.
25
+ *
26
+ * - **Items** come from `effectiveNavigation`, so inherit/extend/override is already applied; nothing here re-implements
27
+ * it. A topbar is flat; a sidebar nests, collapses, and expands the parents of the active item.
28
+ * - **Active state** follows what the navigation host shows: an item is active (`aria-current`, `data-active`) when the
29
+ * screen it opens is the one in its slot, so items rendering into different slots are active at once.
30
+ * - **Activation** goes through the enclosing navigation host (`navigate`), which renders the target in the item's slot -
31
+ * the `outlet` of the destination; outside a host it announces `cratis.scene.navigate`.
32
+ * - **Authorization**: `isVisible` of the model hides items, it does not disable them.
33
+ * - **Keyboard**: arrows (left/right in a topbar, up/down in a sidebar), Home and End move between items; in a sidebar
34
+ * right expands and left collapses (or goes to the parent).
35
+ *
36
+ * Nothing here draws design chrome: items carry `data-read-only` and `data-origin` for a design layer to style.
37
+ */ function NavigationRegionView({ region, module, application = false, model: modelProp, label, expand = 'active', classNames, renderIcon, renderAdornment, hrefFor, onActivate }) {
38
+ const contextModel = SceneNavigationModelContext.useSceneNavigationModel();
39
+ const model = modelProp ?? contextModel;
40
+ if (!model) throw new Error('NavigationRegionView needs a navigation model: pass `model` or render it inside a SceneNavigationModelProvider.');
41
+ const navigation = react.useContext(SceneNavigationContext.SceneNavigationContextInternal);
42
+ const adapters = IconAdapterContext.useIconAdapters();
43
+ const names = {
44
+ ...NavigationRegionClassNames.defaultNavigationRegionClassNames,
45
+ ...classNames
46
+ };
47
+ const index = react.useMemo(()=>model.structure instanceof scene_engine.ApplicationStructureIndex ? model.structure : new scene_engine.ApplicationStructureIndex(model.structure), [
48
+ model.structure
49
+ ]);
50
+ const screenFor = model.screenFor ?? navigationItemDestination.defaultScreenFor;
51
+ const sidebar = region === scene_model.NavigationRegionKind.Sidebar;
52
+ const placement = react.useMemo(()=>({
53
+ primaryScreen: navigation?.primaryScreen,
54
+ outlets: navigation?.outlets ?? {}
55
+ }), [
56
+ navigation?.outlets,
57
+ navigation?.primaryScreen
58
+ ]);
59
+ const scope = application ? undefined : module ?? currentModuleOf.currentModuleOf(index, placement.primaryScreen);
60
+ const resolved = react.useMemo(()=>scene_engine.effectiveNavigation(index, model.navigation, scope, region), [
61
+ index,
62
+ model.navigation,
63
+ scope,
64
+ region
65
+ ]);
66
+ const isActive = (item)=>placement.primaryScreen !== undefined && navigationItemActive.navigationItemActive(item, {
67
+ primaryScreen: placement.primaryScreen,
68
+ outlets: placement.outlets
69
+ }, screenFor, !sidebar);
70
+ const isVisible = model.isVisible ?? (()=>true);
71
+ const visible = react.useMemo(()=>{
72
+ const keep = (items)=>items.filter(isVisible).map((item)=>item.children ? {
73
+ ...item,
74
+ children: keep(item.children)
75
+ } : item);
76
+ return keep(resolved.items);
77
+ }, [
78
+ resolved,
79
+ model.isVisible
80
+ ]);
81
+ const activeKey = JSON.stringify([
82
+ placement.primaryScreen,
83
+ placement.outlets,
84
+ scope
85
+ ]);
86
+ const [toggled, setToggled] = react.useState({
87
+ key: activeKey,
88
+ state: {}
89
+ });
90
+ const overrides = toggled.key === activeKey ? toggled.state : {};
91
+ const [focused, setFocused] = react.useState();
92
+ const root = react.useRef(null);
93
+ const isExpanded = (item, key)=>overrides[key] ?? (expand === 'all' || containsActive(item, isActive));
94
+ const toggle = (key, expanded)=>setToggled({
95
+ key: activeKey,
96
+ state: {
97
+ ...overrides,
98
+ [key]: expanded
99
+ }
100
+ });
101
+ const activate = (item)=>{
102
+ const destination = navigationItemDestination.navigationItemDestination(item, screenFor);
103
+ if (destination === undefined) return;
104
+ if (navigation) {
105
+ navigation.navigate(destination);
106
+ } else {
107
+ globalThis.dispatchEvent(new CustomEvent('cratis.scene.navigate', {
108
+ detail: {
109
+ targetScreen: destination.screen ?? '',
110
+ destination,
111
+ item
112
+ }
113
+ }));
114
+ }
115
+ onActivate?.(item, destination);
116
+ };
117
+ const links = ()=>Array.from(root.current?.querySelectorAll('[data-scene-nav-link]') ?? []);
118
+ const focusLink = (element)=>{
119
+ if (!element) return;
120
+ setFocused(element.getAttribute('data-scene-nav-link') ?? undefined);
121
+ element.focus();
122
+ };
123
+ const onKeyDown = (event)=>{
124
+ const all = links();
125
+ const position = all.findIndex((link)=>link === document.activeElement);
126
+ if (position < 0) return;
127
+ const next = sidebar ? 'ArrowDown' : 'ArrowRight';
128
+ const previous = sidebar ? 'ArrowUp' : 'ArrowLeft';
129
+ const current = all[position];
130
+ const key = current.getAttribute('data-scene-nav-link');
131
+ const owner = current.closest('[data-scene-nav-item]');
132
+ const hasChildren = owner?.getAttribute('data-scene-nav-parent') === 'true';
133
+ const expanded = owner?.getAttribute('data-expanded') === 'true';
134
+ let target;
135
+ if (event.key === next) target = all[Math.min(position + 1, all.length - 1)];
136
+ else if (event.key === previous) target = all[Math.max(position - 1, 0)];
137
+ else if (event.key === 'Home') target = all[0];
138
+ else if (event.key === 'End') target = all[all.length - 1];
139
+ else if (sidebar && event.key === 'ArrowRight' && hasChildren) {
140
+ if (!expanded) toggle(key, true);
141
+ else target = all[position + 1];
142
+ } else if (sidebar && event.key === 'ArrowLeft') {
143
+ if (hasChildren && expanded) toggle(key, false);
144
+ else {
145
+ const parent = owner?.parentElement?.closest('[data-scene-nav-item]')?.querySelector(':scope > [data-scene-nav-link]');
146
+ if (parent) target = parent;
147
+ }
148
+ } else return;
149
+ event.preventDefault();
150
+ focusLink(target);
151
+ };
152
+ const tabStop = focused ?? undefined;
153
+ const firstActive = (items, path)=>{
154
+ for (const item of items){
155
+ const key = itemKey([
156
+ ...path,
157
+ item.id
158
+ ]);
159
+ if (isActive(item)) return key;
160
+ const inner = firstActive(item.children ?? [], [
161
+ ...path,
162
+ item.id
163
+ ]);
164
+ if (inner !== undefined && isExpanded(item, key)) return inner;
165
+ }
166
+ return undefined;
167
+ };
168
+ const firstKey = visible.length > 0 ? itemKey([
169
+ visible[0].id
170
+ ]) : undefined;
171
+ const stop = tabStop ?? firstActive(visible, []) ?? firstKey;
172
+ const icon = (item)=>{
173
+ if (item.icon === undefined) return null;
174
+ const drawn = renderIcon ? renderIcon(item.icon) : adapters ? (()=>{
175
+ const reference = scene_model.parseIconReference(item.icon);
176
+ return reference ? /*#__PURE__*/ jsxRuntime.jsx(SceneIcon.SceneIcon, {
177
+ reference: reference,
178
+ adapters: adapters
179
+ }) : null;
180
+ })() : null;
181
+ return drawn === null ? null : /*#__PURE__*/ jsxRuntime.jsx("span", {
182
+ className: names.icon,
183
+ "aria-hidden": "true",
184
+ "data-scene-icon": item.icon,
185
+ children: drawn
186
+ });
187
+ };
188
+ const renderItems = (items, path, level)=>items.map((item)=>{
189
+ const key = itemKey([
190
+ ...path,
191
+ item.id
192
+ ]);
193
+ const destination = navigationItemDestination.navigationItemDestination(item, screenFor);
194
+ const active = isActive(item);
195
+ const children = item.children ?? [];
196
+ const parent = sidebar && children.length > 0;
197
+ const expanded = parent && isExpanded(item, key);
198
+ const url = destination ? resolveDestination.resolveDestination(destination).url : undefined;
199
+ const href = destination ? hrefFor ? hrefFor(destination, url) : url ? `#/${url}` : undefined : undefined;
200
+ const onClick = (event)=>{
201
+ if (event.metaKey || event.ctrlKey || event.shiftKey || event.button !== 0) return;
202
+ event.preventDefault();
203
+ if (destination) activate(item);
204
+ else if (parent) toggle(key, !expanded);
205
+ };
206
+ const content = /*#__PURE__*/ jsxRuntime.jsxs(jsxRuntime.Fragment, {
207
+ children: [
208
+ icon(item),
209
+ /*#__PURE__*/ jsxRuntime.jsx("span", {
210
+ className: names.label,
211
+ children: item.title
212
+ }),
213
+ renderAdornment?.(item)
214
+ ]
215
+ });
216
+ return /*#__PURE__*/ jsxRuntime.jsxs("li", {
217
+ className: names.item,
218
+ "data-scene-nav-item": item.id,
219
+ "data-scene-nav-parent": parent ? 'true' : undefined,
220
+ "data-active": active,
221
+ "data-active-descendant": !active && parent && children.some((child)=>containsActive(child, isActive)) ? true : undefined,
222
+ "data-expanded": parent ? expanded : undefined,
223
+ "data-origin": item.origin,
224
+ "data-read-only": item.readOnly,
225
+ "data-slot": item.slot,
226
+ "data-level": level,
227
+ children: [
228
+ destination || parent ? /*#__PURE__*/ jsxRuntime.jsx("a", {
229
+ className: names.link,
230
+ href: href ?? '#',
231
+ "data-scene-nav-link": key,
232
+ "aria-current": active ? 'page' : undefined,
233
+ "aria-expanded": parent && !destination ? expanded : undefined,
234
+ tabIndex: key === stop ? 0 : -1,
235
+ onClick: onClick,
236
+ onFocus: ()=>setFocused(key),
237
+ children: content
238
+ }) : /*#__PURE__*/ jsxRuntime.jsx("span", {
239
+ className: names.link,
240
+ "aria-disabled": "true",
241
+ "data-scene-nav-link": key,
242
+ tabIndex: -1,
243
+ children: content
244
+ }),
245
+ parent && /*#__PURE__*/ jsxRuntime.jsx("button", {
246
+ type: "button",
247
+ className: names.toggle,
248
+ tabIndex: -1,
249
+ "aria-expanded": expanded,
250
+ "aria-controls": `${key}-items`,
251
+ "aria-label": `${expanded ? 'Collapse' : 'Expand'} ${item.title}`,
252
+ onClick: ()=>toggle(key, !expanded)
253
+ }),
254
+ parent && expanded && /*#__PURE__*/ jsxRuntime.jsx("ul", {
255
+ id: `${key}-items`,
256
+ className: `${names.list} ${names.submenu}`,
257
+ children: renderItems(children, [
258
+ ...path,
259
+ item.id
260
+ ], level + 1)
261
+ })
262
+ ]
263
+ }, item.id);
264
+ });
265
+ return /*#__PURE__*/ jsxRuntime.jsx("nav", {
266
+ ref: root,
267
+ className: names.root,
268
+ "aria-label": label ?? (sidebar ? 'Sidebar' : 'Topbar'),
269
+ "data-scene-nav-region": region,
270
+ "data-scene-nav-sources": resolved.sources.kind,
271
+ "data-scene-nav-sources-label": resolved.sources.label,
272
+ "data-scene-nav-module": scope,
273
+ "data-scene-nav-mode": resolved.mode,
274
+ onKeyDown: onKeyDown,
275
+ children: /*#__PURE__*/ jsxRuntime.jsx("ul", {
276
+ className: names.list,
277
+ children: renderItems(visible, [], 0)
278
+ })
279
+ });
280
+ }
281
+
282
+ exports.NavigationRegionView = NavigationRegionView;
283
+ //# sourceMappingURL=NavigationRegionView.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"NavigationRegionView.js","sources":["../../../../navigation/region/NavigationRegionView.tsx"],"sourcesContent":["// Copyright (c) Cratis. All rights reserved.\n// Licensed under the MIT license. See LICENSE file in the project root for full license information.\n\nimport { KeyboardEvent, MouseEvent, ReactNode, useContext, useMemo, useRef, useState } from 'react';\nimport { DestinationReference, NavigationRegionKind, parseIconReference } from '@cratis/scene.model';\nimport { ApplicationStructureIndex, EffectiveNavItem, EffectiveNavigationRegion, effectiveNavigation } from '@cratis/scene.engine';\nimport { SceneIcon } from '../../icons/SceneIcon';\nimport { useIconAdapters } from '../../icons/IconAdapterContext';\nimport { resolveDestination } from '../resolveDestination';\nimport { SceneNavigationContextInternal } from '../SceneNavigationContext';\nimport { NavigationRegionClassNames, defaultNavigationRegionClassNames } from './NavigationRegionClassNames';\nimport { SceneNavigationModel } from './SceneNavigationModel';\nimport { useSceneNavigationModel } from './SceneNavigationModelContext';\nimport { currentModuleOf } from './currentModuleOf';\nimport { navigationItemActive } from './navigationItemActive';\nimport { defaultScreenFor, navigationItemDestination } from './navigationItemDestination';\n\nexport interface NavigationRegionViewProps {\n /** Which region to show. */\n region: NavigationRegionKind;\n\n /**\n * The module to show the region of. When absent the region follows the module of the screen on the page, so\n * navigating to another module recomputes the effective items in place; outside every module it is the application's.\n */\n module?: string;\n\n /** Pins the region to the application level, whatever screen is on the page. */\n application?: boolean;\n\n /** What to resolve against; the {@link SceneNavigationModelProvider}'s when absent. */\n model?: SceneNavigationModel;\n\n /**\n * Which sub-items of a sidebar show: only those of the parents of the active item and of items the user expanded\n * (`active`, the default), or all of them (`all`) - a design layer wants the whole hierarchy.\n */\n expand?: 'active' | 'all';\n\n /** The accessible name of the `nav` landmark. */\n label?: string;\n\n /** The class names to put on the nodes. */\n classNames?: Partial<NavigationRegionClassNames>;\n\n /**\n * Draws an item's icon from its qualified reference. By default the icon is drawn through the adapters of the\n * enclosing `IconAdapterProvider`, or not at all without one.\n */\n renderIcon?(icon: string): ReactNode;\n\n /**\n * Content a host adds to an item after its title - Studio design mode draws the lock of an inherited item here; Stage\n * ignores it. The item carries `origin` and `readOnly`.\n */\n renderAdornment?(item: EffectiveNavItem): ReactNode;\n\n /** The href of an item's link, for opening it in a new tab; the hash route of the destination by default. */\n hrefFor?(destination: DestinationReference, url: string | undefined): string | undefined;\n\n /** Called after an item has been activated and the host has navigated. */\n onActivate?(item: EffectiveNavItem, destination: DestinationReference): void;\n}\n\nfunction itemKey(path: string[]): string {\n return path.join('/');\n}\n\nfunction containsActive(item: EffectiveNavItem, isActive: (item: EffectiveNavItem) => boolean): boolean {\n return isActive(item) || (item.children ?? []).some(child => containsActive(child, isActive));\n}\n\n/**\n * Renders the effective navigation of one region - a topbar or a sidebar - for the application or a module.\n *\n * - **Items** come from `effectiveNavigation`, so inherit/extend/override is already applied; nothing here re-implements\n * it. A topbar is flat; a sidebar nests, collapses, and expands the parents of the active item.\n * - **Active state** follows what the navigation host shows: an item is active (`aria-current`, `data-active`) when the\n * screen it opens is the one in its slot, so items rendering into different slots are active at once.\n * - **Activation** goes through the enclosing navigation host (`navigate`), which renders the target in the item's slot -\n * the `outlet` of the destination; outside a host it announces `cratis.scene.navigate`.\n * - **Authorization**: `isVisible` of the model hides items, it does not disable them.\n * - **Keyboard**: arrows (left/right in a topbar, up/down in a sidebar), Home and End move between items; in a sidebar\n * right expands and left collapses (or goes to the parent).\n *\n * Nothing here draws design chrome: items carry `data-read-only` and `data-origin` for a design layer to style.\n */\nexport function NavigationRegionView({ region, module, application = false, model: modelProp, label, expand = 'active', classNames, renderIcon, renderAdornment, hrefFor, onActivate }: NavigationRegionViewProps) {\n const contextModel = useSceneNavigationModel();\n const model = modelProp ?? contextModel;\n if (!model) throw new Error('NavigationRegionView needs a navigation model: pass `model` or render it inside a SceneNavigationModelProvider.');\n\n const navigation = useContext(SceneNavigationContextInternal);\n const adapters = useIconAdapters();\n const names = { ...defaultNavigationRegionClassNames, ...classNames };\n const index = useMemo(() => model.structure instanceof ApplicationStructureIndex ? model.structure : new ApplicationStructureIndex(model.structure), [model.structure]);\n const screenFor = model.screenFor ?? defaultScreenFor;\n\n const sidebar = region === NavigationRegionKind.Sidebar;\n const placement = useMemo(() => ({ primaryScreen: navigation?.primaryScreen, outlets: navigation?.outlets ?? {} }), [navigation?.outlets, navigation?.primaryScreen]);\n const scope = application ? undefined : module ?? currentModuleOf(index, placement.primaryScreen);\n const resolved: EffectiveNavigationRegion = useMemo(() => effectiveNavigation(index, model.navigation, scope, region), [index, model.navigation, scope, region]);\n\n const isActive = (item: EffectiveNavItem) => placement.primaryScreen !== undefined && navigationItemActive(item, { primaryScreen: placement.primaryScreen, outlets: placement.outlets }, screenFor, !sidebar);\n const isVisible = model.isVisible ?? (() => true);\n const visible = useMemo(() => {\n const keep = (items: EffectiveNavItem[]): EffectiveNavItem[] => items.filter(isVisible).map(item => item.children ? { ...item, children: keep(item.children) } : item);\n return keep(resolved.items);\n }, [resolved, model.isVisible]);\n\n const activeKey = JSON.stringify([placement.primaryScreen, placement.outlets, scope]);\n const [toggled, setToggled] = useState<{ key: string; state: Record<string, boolean> }>({ key: activeKey, state: {} });\n const overrides = toggled.key === activeKey ? toggled.state : {};\n const [focused, setFocused] = useState<string>();\n const root = useRef<HTMLElement>(null);\n\n const isExpanded = (item: EffectiveNavItem, key: string) => overrides[key] ?? (expand === 'all' || containsActive(item, isActive));\n const toggle = (key: string, expanded: boolean) => setToggled({ key: activeKey, state: { ...overrides, [key]: expanded } });\n\n const activate = (item: EffectiveNavItem) => {\n const destination = navigationItemDestination(item, screenFor);\n if (destination === undefined) return;\n if (navigation) {\n navigation.navigate(destination);\n } else {\n globalThis.dispatchEvent(new CustomEvent('cratis.scene.navigate', { detail: { targetScreen: destination.screen ?? '', destination, item } }));\n }\n\n onActivate?.(item, destination);\n };\n\n const links = () => Array.from(root.current?.querySelectorAll<HTMLElement>('[data-scene-nav-link]') ?? []);\n const focusLink = (element: HTMLElement | undefined) => {\n if (!element) return;\n setFocused(element.getAttribute('data-scene-nav-link') ?? undefined);\n element.focus();\n };\n\n const onKeyDown = (event: KeyboardEvent<HTMLElement>) => {\n const all = links();\n const position = all.findIndex(link => link === document.activeElement);\n if (position < 0) return;\n const next = sidebar ? 'ArrowDown' : 'ArrowRight';\n const previous = sidebar ? 'ArrowUp' : 'ArrowLeft';\n const current = all[position];\n const key = current.getAttribute('data-scene-nav-link')!;\n const owner = current.closest('[data-scene-nav-item]') as HTMLElement | null;\n const hasChildren = owner?.getAttribute('data-scene-nav-parent') === 'true';\n const expanded = owner?.getAttribute('data-expanded') === 'true';\n\n let target: HTMLElement | undefined;\n if (event.key === next) target = all[Math.min(position + 1, all.length - 1)];\n else if (event.key === previous) target = all[Math.max(position - 1, 0)];\n else if (event.key === 'Home') target = all[0];\n else if (event.key === 'End') target = all[all.length - 1];\n else if (sidebar && event.key === 'ArrowRight' && hasChildren) {\n if (!expanded) toggle(key, true);\n else target = all[position + 1];\n } else if (sidebar && event.key === 'ArrowLeft') {\n if (hasChildren && expanded) toggle(key, false);\n else {\n const parent = owner?.parentElement?.closest('[data-scene-nav-item]')?.querySelector<HTMLElement>(':scope > [data-scene-nav-link]');\n if (parent) target = parent;\n }\n } else return;\n\n event.preventDefault();\n focusLink(target);\n };\n\n const tabStop = focused ?? undefined;\n const firstActive = (items: EffectiveNavItem[], path: string[]): string | undefined => {\n for (const item of items) {\n const key = itemKey([...path, item.id]);\n if (isActive(item)) return key;\n const inner = firstActive(item.children ?? [], [...path, item.id]);\n if (inner !== undefined && isExpanded(item, key)) return inner;\n }\n\n return undefined;\n };\n const firstKey = visible.length > 0 ? itemKey([visible[0].id]) : undefined;\n const stop = tabStop ?? firstActive(visible, []) ?? firstKey;\n\n const icon = (item: EffectiveNavItem) => {\n if (item.icon === undefined) return null;\n const drawn = renderIcon ? renderIcon(item.icon) : adapters ? (() => {\n const reference = parseIconReference(item.icon!);\n return reference ? <SceneIcon reference={reference} adapters={adapters} /> : null;\n })() : null;\n return drawn === null ? null : <span className={names.icon} aria-hidden='true' data-scene-icon={item.icon}>{drawn}</span>;\n };\n\n const renderItems = (items: EffectiveNavItem[], path: string[], level: number): ReactNode => items.map(item => {\n const key = itemKey([...path, item.id]);\n const destination = navigationItemDestination(item, screenFor);\n const active = isActive(item);\n const children = item.children ?? [];\n const parent = sidebar && children.length > 0;\n const expanded = parent && isExpanded(item, key);\n const url = destination ? resolveDestination(destination).url : undefined;\n const href = destination ? (hrefFor ? hrefFor(destination, url) : url ? `#/${url}` : undefined) : undefined;\n const onClick = (event: MouseEvent) => {\n if (event.metaKey || event.ctrlKey || event.shiftKey || event.button !== 0) return;\n event.preventDefault();\n if (destination) activate(item);\n else if (parent) toggle(key, !expanded);\n };\n const content = <>\n {icon(item)}\n <span className={names.label}>{item.title}</span>\n {renderAdornment?.(item)}\n </>;\n\n return <li key={item.id} className={names.item} data-scene-nav-item={item.id} data-scene-nav-parent={parent ? 'true' : undefined}\n data-active={active} data-active-descendant={!active && parent && children.some(child => containsActive(child, isActive)) ? true : undefined} data-expanded={parent ? expanded : undefined} data-origin={item.origin} data-read-only={item.readOnly}\n data-slot={item.slot} data-level={level}>\n {destination || parent\n ? <a className={names.link} href={href ?? '#'} data-scene-nav-link={key} aria-current={active ? 'page' : undefined}\n aria-expanded={parent && !destination ? expanded : undefined} tabIndex={key === stop ? 0 : -1}\n onClick={onClick} onFocus={() => setFocused(key)}>{content}</a>\n : <span className={names.link} aria-disabled='true' data-scene-nav-link={key} tabIndex={-1}>{content}</span>}\n {parent && <button type='button' className={names.toggle} tabIndex={-1} aria-expanded={expanded} aria-controls={`${key}-items`}\n aria-label={`${expanded ? 'Collapse' : 'Expand'} ${item.title}`} onClick={() => toggle(key, !expanded)} />}\n {parent && expanded && <ul id={`${key}-items`} className={`${names.list} ${names.submenu}`}>{renderItems(children, [...path, item.id], level + 1)}</ul>}\n </li>;\n });\n\n return <nav ref={root} className={names.root} aria-label={label ?? (sidebar ? 'Sidebar' : 'Topbar')} data-scene-nav-region={region}\n data-scene-nav-sources={resolved.sources.kind} data-scene-nav-sources-label={resolved.sources.label} data-scene-nav-module={scope}\n data-scene-nav-mode={resolved.mode} onKeyDown={onKeyDown}>\n <ul className={names.list}>{renderItems(visible, [], 0)}</ul>\n </nav>;\n}\n"],"names":["itemKey","path","join","containsActive","item","isActive","children","some","child","NavigationRegionView","region","module","application","model","modelProp","label","expand","classNames","renderIcon","renderAdornment","hrefFor","onActivate","contextModel","useSceneNavigationModel","Error","navigation","useContext","SceneNavigationContextInternal","adapters","useIconAdapters","names","defaultNavigationRegionClassNames","index","useMemo","structure","ApplicationStructureIndex","screenFor","defaultScreenFor","sidebar","NavigationRegionKind","Sidebar","placement","primaryScreen","outlets","scope","undefined","currentModuleOf","resolved","effectiveNavigation","navigationItemActive","isVisible","visible","keep","items","filter","map","activeKey","JSON","stringify","toggled","setToggled","useState","key","state","overrides","focused","setFocused","root","useRef","isExpanded","toggle","expanded","activate","destination","navigationItemDestination","navigate","globalThis","dispatchEvent","CustomEvent","detail","targetScreen","screen","links","Array","from","current","querySelectorAll","focusLink","element","getAttribute","focus","onKeyDown","event","all","position","findIndex","link","document","activeElement","next","previous","owner","closest","hasChildren","target","Math","min","length","max","parent","parentElement","querySelector","preventDefault","tabStop","firstActive","id","inner","firstKey","stop","icon","drawn","reference","parseIconReference","_jsx","SceneIcon","span","className","aria-hidden","data-scene-icon","renderItems","level","active","url","resolveDestination","href","onClick","metaKey","ctrlKey","shiftKey","button","content","_jsxs","_Fragment","title","li","data-scene-nav-item","data-scene-nav-parent","data-active","data-active-descendant","data-expanded","data-origin","origin","data-read-only","readOnly","data-slot","slot","data-level","a","data-scene-nav-link","aria-current","aria-expanded","tabIndex","onFocus","aria-disabled","type","aria-controls","aria-label","ul","list","submenu","nav","ref","data-scene-nav-region","data-scene-nav-sources","sources","kind","data-scene-nav-sources-label","data-scene-nav-module","data-scene-nav-mode","mode"],"mappings":";;;;;;;;;;;;;;;;AAgEA,SAASA,QAAQC,IAAc,EAAA;IAC3B,OAAOA,IAAAA,CAAKC,IAAI,CAAC,GAAA,CAAA;AACrB;AAEA,SAASC,cAAAA,CAAeC,IAAsB,EAAEC,QAA6C,EAAA;AACzF,IAAA,OAAOA,QAAAA,CAASD,IAAAA,CAAAA,IAAS,CAACA,KAAKE,QAAQ,IAAI,EAAC,EAAGC,IAAI,CAACC,CAAAA,KAAAA,GAASL,eAAeK,KAAAA,EAAOH,QAAAA,CAAAA,CAAAA;AACvF;AAEA;;;;;;;;;;;;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SAAAA,EAAWhG,MAAM0I,IAAI;sBAAGvC,WAAAA,CAAY9E,OAAAA,EAAS,EAAE,EAAE,CAAA;;;AAE7D;;"}
@@ -0,0 +1,22 @@
1
+ 'use strict';
2
+
3
+ var jsxRuntime = require('react/jsx-runtime');
4
+ var react = require('react');
5
+
6
+ const Context = /*#__PURE__*/ react.createContext(undefined);
7
+ /**
8
+ * Supplies the application structure and navigation every navigation region below it renders - the topbar and sidebar
9
+ * components of a shell find what to show here, so a screen document does not carry the application's navigation.
10
+ */ function SceneNavigationModelProvider({ model, children }) {
11
+ return /*#__PURE__*/ jsxRuntime.jsx(Context.Provider, {
12
+ value: model,
13
+ children: children
14
+ });
15
+ }
16
+ /** The navigation model in scope, or undefined outside a {@link SceneNavigationModelProvider}. */ function useSceneNavigationModel() {
17
+ return react.useContext(Context);
18
+ }
19
+
20
+ exports.SceneNavigationModelProvider = SceneNavigationModelProvider;
21
+ exports.useSceneNavigationModel = useSceneNavigationModel;
22
+ //# sourceMappingURL=SceneNavigationModelContext.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"SceneNavigationModelContext.js","sources":["../../../../navigation/region/SceneNavigationModelContext.tsx"],"sourcesContent":["// Copyright (c) Cratis. All rights reserved.\n// Licensed under the MIT license. See LICENSE file in the project root for full license information.\n\nimport { ReactNode, createContext, useContext } from 'react';\nimport { SceneNavigationModel } from './SceneNavigationModel';\n\nconst Context = createContext<SceneNavigationModel | undefined>(undefined);\n\nexport interface SceneNavigationModelProviderProps {\n model: SceneNavigationModel;\n children?: ReactNode;\n}\n\n/**\n * Supplies the application structure and navigation every navigation region below it renders - the topbar and sidebar\n * components of a shell find what to show here, so a screen document does not carry the application's navigation.\n */\nexport function SceneNavigationModelProvider({ model, children }: SceneNavigationModelProviderProps) {\n return <Context.Provider value={model}>{children}</Context.Provider>;\n}\n\n/** The navigation model in scope, or undefined outside a {@link SceneNavigationModelProvider}. */\nexport function useSceneNavigationModel(): SceneNavigationModel | undefined {\n return useContext(Context);\n}\n"],"names":["Context","createContext","undefined","SceneNavigationModelProvider","model","children","_jsx","Provider","value","useSceneNavigationModel","useContext"],"mappings":";;;;;AAMA,MAAMA,wBAAUC,mBAAAA,CAAgDC,SAAAA,CAAAA;AAOhE;;;AAGC,IACM,SAASC,4BAAAA,CAA6B,EAAEC,KAAK,EAAEC,QAAQ,EAAqC,EAAA;IAC/F,qBAAOC,cAAA,CAACN,QAAQO,QAAQ,EAAA;QAACC,KAAAA,EAAOJ,KAAAA;AAAQC,QAAAA,QAAAA,EAAAA;;AAC5C;AAEA,mGACO,SAASI,uBAAAA,GAAAA;AACZ,IAAA,OAAOC,gBAAAA,CAAWV,OAAAA,CAAAA;AACtB;;;"}
@@ -0,0 +1,15 @@
1
+ 'use strict';
2
+
3
+ // Copyright (c) Cratis. All rights reserved.
4
+ // Licensed under the MIT license. See LICENSE file in the project root for full license information.
5
+ /**
6
+ * The module the screen on the page belongs to: the screen's qualified id starts with its module id, so `sales.orders`
7
+ * is in `sales`. Undefined for a screen outside every module - the application level.
8
+ */ function currentModuleOf(index, screen) {
9
+ if (screen === undefined) return undefined;
10
+ const module = screen.split('.')[0];
11
+ return index.findModule(module) ? module : undefined;
12
+ }
13
+
14
+ exports.currentModuleOf = currentModuleOf;
15
+ //# sourceMappingURL=currentModuleOf.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"currentModuleOf.js","sources":["../../../../navigation/region/currentModuleOf.ts"],"sourcesContent":["// Copyright (c) Cratis. All rights reserved.\n// Licensed under the MIT license. See LICENSE file in the project root for full license information.\n\nimport { ApplicationStructureIndex } from '@cratis/scene.engine';\n\n/**\n * The module the screen on the page belongs to: the screen's qualified id starts with its module id, so `sales.orders`\n * is in `sales`. Undefined for a screen outside every module - the application level.\n */\nexport function currentModuleOf(index: ApplicationStructureIndex, screen: string | undefined): string | undefined {\n if (screen === undefined) return undefined;\n const module = screen.split('.')[0];\n return index.findModule(module) ? module : undefined;\n}\n"],"names":["currentModuleOf","index","screen","undefined","module","split","findModule"],"mappings":";;AAAA;AACA;AAIA;;;AAGC,IACM,SAASA,eAAAA,CAAgBC,KAAgC,EAAEC,MAA0B,EAAA;IACxF,IAAIA,MAAAA,KAAWC,WAAW,OAAOA,SAAAA;AACjC,IAAA,MAAMC,SAASF,MAAAA,CAAOG,KAAK,CAAC,GAAA,CAAI,CAAC,CAAA,CAAE;AACnC,IAAA,OAAOJ,KAAAA,CAAMK,UAAU,CAACF,MAAAA,CAAAA,GAAUA,MAAAA,GAASD,SAAAA;AAC/C;;"}