@cratis/scene.react 4.28.0 → 4.29.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.
- package/dist/cjs/index.js +16 -0
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/navigation/SceneNavigationHost.js +24 -13
- package/dist/cjs/navigation/SceneNavigationHost.js.map +1 -1
- package/dist/cjs/navigation/region/NavigationRegionClassNames.js +21 -0
- package/dist/cjs/navigation/region/NavigationRegionClassNames.js.map +1 -0
- package/dist/cjs/navigation/region/NavigationRegionView.js +283 -0
- package/dist/cjs/navigation/region/NavigationRegionView.js.map +1 -0
- package/dist/cjs/navigation/region/SceneNavigationModelContext.js +22 -0
- package/dist/cjs/navigation/region/SceneNavigationModelContext.js.map +1 -0
- package/dist/cjs/navigation/region/currentModuleOf.js +15 -0
- package/dist/cjs/navigation/region/currentModuleOf.js.map +1 -0
- package/dist/cjs/navigation/region/navigationDestinations.js +46 -0
- package/dist/cjs/navigation/region/navigationDestinations.js.map +1 -0
- package/dist/cjs/navigation/region/navigationItemActive.js +31 -0
- package/dist/cjs/navigation/region/navigationItemActive.js.map +1 -0
- package/dist/cjs/navigation/region/navigationItemDestination.js +34 -0
- package/dist/cjs/navigation/region/navigationItemDestination.js.map +1 -0
- package/dist/esm/index.js +7 -0
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/navigation/SceneNavigationHost.d.ts +5 -1
- package/dist/esm/navigation/SceneNavigationHost.d.ts.map +1 -1
- package/dist/esm/navigation/SceneNavigationHost.js +25 -14
- package/dist/esm/navigation/SceneNavigationHost.js.map +1 -1
- package/dist/esm/navigation/index.d.ts +8 -0
- package/dist/esm/navigation/index.d.ts.map +1 -1
- package/dist/esm/navigation/index.js +8 -0
- package/dist/esm/navigation/index.js.map +1 -1
- package/dist/esm/navigation/region/NavigationRegionClassNames.d.ts +12 -0
- package/dist/esm/navigation/region/NavigationRegionClassNames.d.ts.map +1 -0
- package/dist/esm/navigation/region/NavigationRegionClassNames.js +19 -0
- package/dist/esm/navigation/region/NavigationRegionClassNames.js.map +1 -0
- package/dist/esm/navigation/region/NavigationRegionView.d.ts +20 -0
- package/dist/esm/navigation/region/NavigationRegionView.d.ts.map +1 -0
- package/dist/esm/navigation/region/NavigationRegionView.js +281 -0
- package/dist/esm/navigation/region/NavigationRegionView.js.map +1 -0
- package/dist/esm/navigation/region/SceneNavigationModel.d.ts +9 -0
- package/dist/esm/navigation/region/SceneNavigationModel.d.ts.map +1 -0
- package/dist/esm/navigation/region/SceneNavigationModel.js +2 -0
- package/dist/esm/navigation/region/SceneNavigationModel.js.map +1 -0
- package/dist/esm/navigation/region/SceneNavigationModelContext.d.ts +9 -0
- package/dist/esm/navigation/region/SceneNavigationModelContext.d.ts.map +1 -0
- package/dist/esm/navigation/region/SceneNavigationModelContext.js +19 -0
- package/dist/esm/navigation/region/SceneNavigationModelContext.js.map +1 -0
- package/dist/esm/navigation/region/currentModuleOf.d.ts +3 -0
- package/dist/esm/navigation/region/currentModuleOf.d.ts.map +1 -0
- package/dist/esm/navigation/region/currentModuleOf.js +13 -0
- package/dist/esm/navigation/region/currentModuleOf.js.map +1 -0
- package/dist/esm/navigation/region/navigationDestinations.d.ts +4 -0
- package/dist/esm/navigation/region/navigationDestinations.d.ts.map +1 -0
- package/dist/esm/navigation/region/navigationDestinations.js +44 -0
- package/dist/esm/navigation/region/navigationDestinations.js.map +1 -0
- package/dist/esm/navigation/region/navigationItemActive.d.ts +5 -0
- package/dist/esm/navigation/region/navigationItemActive.d.ts.map +1 -0
- package/dist/esm/navigation/region/navigationItemActive.js +29 -0
- package/dist/esm/navigation/region/navigationItemActive.js.map +1 -0
- package/dist/esm/navigation/region/navigationItemDestination.d.ts +5 -0
- package/dist/esm/navigation/region/navigationItemDestination.d.ts.map +1 -0
- package/dist/esm/navigation/region/navigationItemDestination.js +31 -0
- package/dist/esm/navigation/region/navigationItemDestination.js.map +1 -0
- package/dist/esm/tsconfig.tsbuildinfo +1 -1
- package/navigation/SceneNavigationHost.tsx +27 -6
- package/navigation/index.ts +8 -0
- package/navigation/region/NavigationRegionClassNames.ts +46 -0
- package/navigation/region/NavigationRegionView.tsx +234 -0
- package/navigation/region/SceneNavigationModel.ts +29 -0
- package/navigation/region/SceneNavigationModelContext.tsx +25 -0
- package/navigation/region/currentModuleOf.ts +14 -0
- package/navigation/region/navigationDestinations.ts +41 -0
- package/navigation/region/navigationItemActive.ts +39 -0
- package/navigation/region/navigationItemDestination.ts +29 -0
- package/package.json +5 -5
package/dist/cjs/index.js
CHANGED
|
@@ -37,6 +37,13 @@ var CoreOutlet = require('./navigation/CoreOutlet.js');
|
|
|
37
37
|
var SceneOutletContext = require('./navigation/SceneOutletContext.js');
|
|
38
38
|
var collectOutletOwners = require('./navigation/collectOutletOwners.js');
|
|
39
39
|
var placeInOutlet = require('./navigation/placeInOutlet.js');
|
|
40
|
+
var SceneNavigationModelContext = require('./navigation/region/SceneNavigationModelContext.js');
|
|
41
|
+
var NavigationRegionClassNames = require('./navigation/region/NavigationRegionClassNames.js');
|
|
42
|
+
var NavigationRegionView = require('./navigation/region/NavigationRegionView.js');
|
|
43
|
+
var currentModuleOf = require('./navigation/region/currentModuleOf.js');
|
|
44
|
+
var navigationItemActive = require('./navigation/region/navigationItemActive.js');
|
|
45
|
+
var navigationItemDestination = require('./navigation/region/navigationItemDestination.js');
|
|
46
|
+
var navigationDestinations = require('./navigation/region/navigationDestinations.js');
|
|
40
47
|
var IconAdapterRegistry = require('./icons/IconAdapterRegistry.js');
|
|
41
48
|
var IconAdapterContext = require('./icons/IconAdapterContext.js');
|
|
42
49
|
var useIconGlyph = require('./icons/useIconGlyph.js');
|
|
@@ -134,6 +141,15 @@ exports.useSceneOutlets = SceneOutletContext.useSceneOutlets;
|
|
|
134
141
|
exports.collectOutletOwners = collectOutletOwners.collectOutletOwners;
|
|
135
142
|
exports.outletComponentName = collectOutletOwners.outletComponentName;
|
|
136
143
|
exports.placeInOutlet = placeInOutlet.placeInOutlet;
|
|
144
|
+
exports.SceneNavigationModelProvider = SceneNavigationModelContext.SceneNavigationModelProvider;
|
|
145
|
+
exports.useSceneNavigationModel = SceneNavigationModelContext.useSceneNavigationModel;
|
|
146
|
+
exports.defaultNavigationRegionClassNames = NavigationRegionClassNames.defaultNavigationRegionClassNames;
|
|
147
|
+
exports.NavigationRegionView = NavigationRegionView.NavigationRegionView;
|
|
148
|
+
exports.currentModuleOf = currentModuleOf.currentModuleOf;
|
|
149
|
+
exports.navigationItemActive = navigationItemActive.navigationItemActive;
|
|
150
|
+
exports.defaultScreenFor = navigationItemDestination.defaultScreenFor;
|
|
151
|
+
exports.navigationItemDestination = navigationItemDestination.navigationItemDestination;
|
|
152
|
+
exports.navigationDestinations = navigationDestinations.navigationDestinations;
|
|
137
153
|
exports.IconAdapterRegistry = IconAdapterRegistry.IconAdapterRegistry;
|
|
138
154
|
exports.createIconAdapterRegistry = IconAdapterRegistry.createIconAdapterRegistry;
|
|
139
155
|
exports.IconAdapterProvider = IconAdapterContext.IconAdapterProvider;
|
package/dist/cjs/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
|
@@ -9,6 +9,8 @@ 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');
|
|
12
14
|
|
|
13
15
|
/**
|
|
14
16
|
* Executes Scene destinations against an in-memory rendered hierarchy: a destination into a nested outlet -
|
|
@@ -16,7 +18,11 @@ var useSceneHistoryNavigation = require('./useSceneHistoryNavigation.js');
|
|
|
16
18
|
* depth; any other screen route replaces the primary region,
|
|
17
19
|
* dialog destinations render dialog content over the screen that opened them, and external destinations
|
|
18
20
|
* only report their resolved action. Every navigation is a history entry.
|
|
19
|
-
*/ function SceneNavigationHost({ screens, dialogs = {}, initialScreen, registry, bindingScope = {}, history, destinations, routes }) {
|
|
21
|
+
*/ function SceneNavigationHost({ screens, dialogs = {}, initialScreen, registry, bindingScope = {}, history, destinations: authoredDestinations, routes, navigationModel, frame }) {
|
|
22
|
+
const destinations = react.useMemo(()=>authoredDestinations ?? (navigationModel ? navigationDestinations.navigationDestinations(navigationModel.structure, navigationModel.navigation, navigationModel.screenFor) : undefined), [
|
|
23
|
+
authoredDestinations,
|
|
24
|
+
navigationModel
|
|
25
|
+
]);
|
|
20
26
|
const [memoryHistory] = react.useState(()=>createMemorySceneHistory.createMemorySceneHistory());
|
|
21
27
|
const routeTable = react.useMemo(()=>routes ?? sceneRoutesFrom.sceneRoutesFrom(Object.keys(screens), destinations), [
|
|
22
28
|
destinations,
|
|
@@ -36,22 +42,23 @@ var useSceneHistoryNavigation = require('./useSceneHistoryNavigation.js');
|
|
|
36
42
|
]);
|
|
37
43
|
const screen = screens[value.primaryScreen];
|
|
38
44
|
const dialog = value.currentDialog ? dialogs[value.currentDialog] : undefined;
|
|
39
|
-
|
|
45
|
+
const outlet = /*#__PURE__*/ jsxRuntime.jsx("div", {
|
|
46
|
+
"data-scene-outlet": value.primaryScreen === value.currentScreen ? value.currentOutlet ?? 'primary' : 'primary',
|
|
47
|
+
"data-scene-url": value.currentUrl,
|
|
48
|
+
children: screen && /*#__PURE__*/ jsxRuntime.jsx(SceneElementView.SceneElementView, {
|
|
49
|
+
element: screen,
|
|
50
|
+
registry: registry,
|
|
51
|
+
dataContext: bindingScope.dataContext,
|
|
52
|
+
queryResults: bindingScope.queryResults,
|
|
53
|
+
componentOutputs: bindingScope.componentOutputs
|
|
54
|
+
})
|
|
55
|
+
});
|
|
56
|
+
const page = /*#__PURE__*/ jsxRuntime.jsx(SceneNavigationContext.SceneNavigationProvider, {
|
|
40
57
|
value: value,
|
|
41
58
|
children: /*#__PURE__*/ jsxRuntime.jsxs(SceneOutletContext.SceneOutletContext.Provider, {
|
|
42
59
|
value: outletContext,
|
|
43
60
|
children: [
|
|
44
|
-
|
|
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
|
-
}),
|
|
61
|
+
frame ? frame(outlet) : outlet,
|
|
55
62
|
dialog && /*#__PURE__*/ jsxRuntime.jsx("div", {
|
|
56
63
|
role: "dialog",
|
|
57
64
|
"aria-modal": "true",
|
|
@@ -68,6 +75,10 @@ var useSceneHistoryNavigation = require('./useSceneHistoryNavigation.js');
|
|
|
68
75
|
]
|
|
69
76
|
})
|
|
70
77
|
});
|
|
78
|
+
return navigationModel ? /*#__PURE__*/ jsxRuntime.jsx(SceneNavigationModelContext.SceneNavigationModelProvider, {
|
|
79
|
+
model: navigationModel,
|
|
80
|
+
children: page
|
|
81
|
+
}) : page;
|
|
71
82
|
}
|
|
72
83
|
|
|
73
84
|
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
|
|
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';\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, 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\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 && <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 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","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","SceneNavigationModelProvider","model"],"mappings":";;;;;;;;;;;;;;AAoDA;;;;;;AAMC,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,cA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YAAAA,WAAAA,EAAavC,aAAauC,WAAW;AAAEC,YAAAA,YAAAA,EAAcxC,aAAawC,YAAY;AAAEC,YAAAA,gBAAAA,EAAkBzC,aAAayC;;;AAErL,IAAA,MAAMC,qBAAOZ,cAAA,CAACa,8CAAAA,EAAAA;QAAwBrB,KAAAA,EAAOA,KAAAA;gCAAOsB,eAAA,CAACC,sCAAmBC,QAAQ,EAAA;YAACxB,KAAAA,EAAOE,aAAAA;;AACnFlB,gBAAAA,KAAAA,GAAQA,MAAMuB,MAAAA,CAAAA,GAAUA,MAAAA;AACxBF,gBAAAA,MAAAA,kBAAUG,cAAA,CAACC,KAAAA,EAAAA;oBAAIgB,IAAAA,EAAK,QAAA;oBAASC,YAAAA,EAAW,MAAA;AAAOC,oBAAAA,YAAAA,EAAY3B,MAAMM,aAAa;AAAEsB,oBAAAA,mBAAAA,EAAmB5B,MAAMM,aAAa;AACnH,oBAAA,QAAA,gBAAAE,cAAA,CAACO,iCAAAA,EAAAA;wBAAiBC,OAAAA,EAASX,MAAAA;wBAAQ5B,QAAAA,EAAUA,QAAAA;AAAUwC,wBAAAA,WAAAA,EAAavC,aAAauC,WAAW;AAAEC,wBAAAA,YAAAA,EAAcxC,aAAawC,YAAY;AAAEC,wBAAAA,gBAAAA,EAAkBzC,aAAayC;;;;;;AAI9K,IAAA,OAAOpC,gCAAkByB,cAAA,CAACqB,wDAAAA,EAAAA;QAA6BC,KAAAA,EAAO/C,eAAAA;AAAkBqC,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;;;;;;;;;;;;;;AAcC,IACM,SAASI,oBAAAA,CAAqB,EAAEC,MAAM,EAAEC,MAAM,EAAEC,WAAAA,GAAc,KAAK,EAAEC,KAAAA,EAAOC,SAAS,EAAEC,KAAK,EAAEC,MAAAA,GAAS,QAAQ,EAAEC,UAAU,EAAEC,UAAU,EAAEC,eAAe,EAAEC,OAAO,EAAEC,UAAU,EAA6B,EAAA;AAC7M,IAAA,MAAMC,YAAAA,GAAeC,mDAAAA,EAAAA;AACrB,IAAA,MAAMV,QAAQC,SAAAA,IAAaQ,YAAAA;AAC3B,IAAA,IAAI,CAACT,K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EAAGhG,MAAM0I,IAAI,CAAC,CAAC,EAAE1I,KAAAA,CAAM2I,OAAO,CAAA,CAAE;AAAGxC,wBAAAA,QAAAA,EAAAA,WAAAA,CAAY3H,QAAAA,EAAU;AAAIL,4BAAAA,GAAAA,IAAAA;AAAMG,4BAAAA,IAAAA,CAAK+G;AAAG,yBAAA,EAAEe,KAAAA,GAAQ,CAAA;;;AAVnI9H,aAAAA,EAAAA,IAAAA,CAAK+G,EAAE,CAAA;AAY3B,QAAA,CAAA,CAAA;AAEA,IAAA,qBAAOQ,cAAA,CAAC+C,KAAAA,EAAAA;QAAIC,GAAAA,EAAKxG,IAAAA;AAAM2D,QAAAA,SAAAA,EAAWhG,MAAMqC,IAAI;AAAEmG,QAAAA,YAAAA,EAAYvJ,KAAAA,KAAUuB,OAAAA,GAAU,SAAA,GAAY,QAAO,CAAA;QAAIsI,uBAAAA,EAAuBlK,MAAAA;QACxHmK,wBAAAA,EAAwB9H,QAAAA,CAAS+H,OAAO,CAACC,IAAI;QAAEC,8BAAAA,EAA8BjI,QAAAA,CAAS+H,OAAO,CAAC/J,KAAK;QAAEkK,uBAAAA,EAAuBrI,KAAAA;AAC5HsI,QAAAA,qBAAAA,EAAqBnI,SAASoI,IAAI;QAAExF,SAAAA,EAAWA,SAAAA;AAC/C,QAAA,QAAA,gBAAAgC,cAAA,CAAC4C,IAAAA,EAAAA;AAAGzC,YAAAA,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;;"}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var scene_model = require('@cratis/scene.model');
|
|
4
|
+
var scene_engine = require('@cratis/scene.engine');
|
|
5
|
+
var navigationItemDestination = require('./navigationItemDestination.js');
|
|
6
|
+
|
|
7
|
+
// Copyright (c) Cratis. All rights reserved.
|
|
8
|
+
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
|
9
|
+
function flatten(items) {
|
|
10
|
+
return items.flatMap((item)=>[
|
|
11
|
+
item,
|
|
12
|
+
...flatten(item.children ?? [])
|
|
13
|
+
]);
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Every destination the navigation of the application and of each module can lead to, once each: what a
|
|
17
|
+
* `SceneNavigationHost` is given as `destinations` so deep links to a navigation item resolve, and an item that renders
|
|
18
|
+
* into a nested outlet is placed with the screen that declares the outlet.
|
|
19
|
+
*/ function navigationDestinations(structure, navigation, screenFor) {
|
|
20
|
+
const index = structure instanceof scene_engine.ApplicationStructureIndex ? structure : new scene_engine.ApplicationStructureIndex(structure);
|
|
21
|
+
const modules = [
|
|
22
|
+
undefined,
|
|
23
|
+
...index.structure.modules.map((module)=>module.id)
|
|
24
|
+
];
|
|
25
|
+
const seen = new Set();
|
|
26
|
+
const destinations = [];
|
|
27
|
+
for (const module of modules){
|
|
28
|
+
for (const region of [
|
|
29
|
+
scene_model.NavigationRegionKind.Topbar,
|
|
30
|
+
scene_model.NavigationRegionKind.Sidebar
|
|
31
|
+
]){
|
|
32
|
+
for (const item of flatten(scene_engine.effectiveNavigation(index, navigation, module, region).items)){
|
|
33
|
+
const destination = navigationItemDestination.navigationItemDestination(item, screenFor);
|
|
34
|
+
if (destination === undefined) continue;
|
|
35
|
+
const key = JSON.stringify(destination);
|
|
36
|
+
if (seen.has(key)) continue;
|
|
37
|
+
seen.add(key);
|
|
38
|
+
destinations.push(destination);
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
return destinations;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
exports.navigationDestinations = navigationDestinations;
|
|
46
|
+
//# sourceMappingURL=navigationDestinations.js.map
|