@cratis/scene.react 4.27.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.
Files changed (78) hide show
  1. package/core/coreDescriptors.ts +28 -1
  2. package/dist/cjs/core/coreDescriptors.js +64 -0
  3. package/dist/cjs/core/coreDescriptors.js.map +1 -1
  4. package/dist/cjs/index.js +16 -0
  5. package/dist/cjs/index.js.map +1 -1
  6. package/dist/cjs/navigation/SceneNavigationHost.js +24 -13
  7. package/dist/cjs/navigation/SceneNavigationHost.js.map +1 -1
  8. package/dist/cjs/navigation/region/NavigationRegionClassNames.js +21 -0
  9. package/dist/cjs/navigation/region/NavigationRegionClassNames.js.map +1 -0
  10. package/dist/cjs/navigation/region/NavigationRegionView.js +283 -0
  11. package/dist/cjs/navigation/region/NavigationRegionView.js.map +1 -0
  12. package/dist/cjs/navigation/region/SceneNavigationModelContext.js +22 -0
  13. package/dist/cjs/navigation/region/SceneNavigationModelContext.js.map +1 -0
  14. package/dist/cjs/navigation/region/currentModuleOf.js +15 -0
  15. package/dist/cjs/navigation/region/currentModuleOf.js.map +1 -0
  16. package/dist/cjs/navigation/region/navigationDestinations.js +46 -0
  17. package/dist/cjs/navigation/region/navigationDestinations.js.map +1 -0
  18. package/dist/cjs/navigation/region/navigationItemActive.js +31 -0
  19. package/dist/cjs/navigation/region/navigationItemActive.js.map +1 -0
  20. package/dist/cjs/navigation/region/navigationItemDestination.js +34 -0
  21. package/dist/cjs/navigation/region/navigationItemDestination.js.map +1 -0
  22. package/dist/esm/core/coreDescriptors.d.ts.map +1 -1
  23. package/dist/esm/core/coreDescriptors.js +65 -1
  24. package/dist/esm/core/coreDescriptors.js.map +1 -1
  25. package/dist/esm/index.js +7 -0
  26. package/dist/esm/index.js.map +1 -1
  27. package/dist/esm/navigation/SceneNavigationHost.d.ts +5 -1
  28. package/dist/esm/navigation/SceneNavigationHost.d.ts.map +1 -1
  29. package/dist/esm/navigation/SceneNavigationHost.js +25 -14
  30. package/dist/esm/navigation/SceneNavigationHost.js.map +1 -1
  31. package/dist/esm/navigation/index.d.ts +8 -0
  32. package/dist/esm/navigation/index.d.ts.map +1 -1
  33. package/dist/esm/navigation/index.js +8 -0
  34. package/dist/esm/navigation/index.js.map +1 -1
  35. package/dist/esm/navigation/region/NavigationRegionClassNames.d.ts +12 -0
  36. package/dist/esm/navigation/region/NavigationRegionClassNames.d.ts.map +1 -0
  37. package/dist/esm/navigation/region/NavigationRegionClassNames.js +19 -0
  38. package/dist/esm/navigation/region/NavigationRegionClassNames.js.map +1 -0
  39. package/dist/esm/navigation/region/NavigationRegionView.d.ts +20 -0
  40. package/dist/esm/navigation/region/NavigationRegionView.d.ts.map +1 -0
  41. package/dist/esm/navigation/region/NavigationRegionView.js +281 -0
  42. package/dist/esm/navigation/region/NavigationRegionView.js.map +1 -0
  43. package/dist/esm/navigation/region/SceneNavigationModel.d.ts +9 -0
  44. package/dist/esm/navigation/region/SceneNavigationModel.d.ts.map +1 -0
  45. package/dist/esm/navigation/region/SceneNavigationModel.js +2 -0
  46. package/dist/esm/navigation/region/SceneNavigationModel.js.map +1 -0
  47. package/dist/esm/navigation/region/SceneNavigationModelContext.d.ts +9 -0
  48. package/dist/esm/navigation/region/SceneNavigationModelContext.d.ts.map +1 -0
  49. package/dist/esm/navigation/region/SceneNavigationModelContext.js +19 -0
  50. package/dist/esm/navigation/region/SceneNavigationModelContext.js.map +1 -0
  51. package/dist/esm/navigation/region/currentModuleOf.d.ts +3 -0
  52. package/dist/esm/navigation/region/currentModuleOf.d.ts.map +1 -0
  53. package/dist/esm/navigation/region/currentModuleOf.js +13 -0
  54. package/dist/esm/navigation/region/currentModuleOf.js.map +1 -0
  55. package/dist/esm/navigation/region/navigationDestinations.d.ts +4 -0
  56. package/dist/esm/navigation/region/navigationDestinations.d.ts.map +1 -0
  57. package/dist/esm/navigation/region/navigationDestinations.js +44 -0
  58. package/dist/esm/navigation/region/navigationDestinations.js.map +1 -0
  59. package/dist/esm/navigation/region/navigationItemActive.d.ts +5 -0
  60. package/dist/esm/navigation/region/navigationItemActive.d.ts.map +1 -0
  61. package/dist/esm/navigation/region/navigationItemActive.js +29 -0
  62. package/dist/esm/navigation/region/navigationItemActive.js.map +1 -0
  63. package/dist/esm/navigation/region/navigationItemDestination.d.ts +5 -0
  64. package/dist/esm/navigation/region/navigationItemDestination.d.ts.map +1 -0
  65. package/dist/esm/navigation/region/navigationItemDestination.js +31 -0
  66. package/dist/esm/navigation/region/navigationItemDestination.js.map +1 -0
  67. package/dist/esm/tsconfig.tsbuildinfo +1 -1
  68. package/navigation/SceneNavigationHost.tsx +27 -6
  69. package/navigation/index.ts +8 -0
  70. package/navigation/region/NavigationRegionClassNames.ts +46 -0
  71. package/navigation/region/NavigationRegionView.tsx +234 -0
  72. package/navigation/region/SceneNavigationModel.ts +29 -0
  73. package/navigation/region/SceneNavigationModelContext.tsx +25 -0
  74. package/navigation/region/currentModuleOf.ts +14 -0
  75. package/navigation/region/navigationDestinations.ts +41 -0
  76. package/navigation/region/navigationItemActive.ts +39 -0
  77. package/navigation/region/navigationItemDestination.ts +29 -0
  78. package/package.json +5 -5
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../navigation/index.ts"],"names":[],"mappings":"AAGA,cAAc,yBAAyB,CAAC;AACxC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,0BAA0B,CAAC;AACzC,cAAc,uBAAuB,CAAC;AACtC,cAAc,wBAAwB,CAAC;AACvC,cAAc,cAAc,CAAC;AAC7B,cAAc,6BAA6B,CAAC;AAC5C,cAAc,0BAA0B,CAAC;AACzC,cAAc,4BAA4B,CAAC;AAC3C,cAAc,8BAA8B,CAAC;AAC7C,cAAc,iBAAiB,CAAC;AAChC,cAAc,mBAAmB,CAAC;AAClC,cAAc,sBAAsB,CAAC;AACrC,cAAc,sBAAsB,CAAC;AACrC,cAAc,mBAAmB,CAAC;AAClC,cAAc,6BAA6B,CAAC;AAC5C,cAAc,cAAc,CAAC;AAC7B,cAAc,sBAAsB,CAAC;AACrC,cAAc,uBAAuB,CAAC;AACtC,cAAc,iBAAiB,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../navigation/index.ts"],"names":[],"mappings":"AAGA,cAAc,yBAAyB,CAAC;AACxC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,0BAA0B,CAAC;AACzC,cAAc,uBAAuB,CAAC;AACtC,cAAc,wBAAwB,CAAC;AACvC,cAAc,cAAc,CAAC;AAC7B,cAAc,6BAA6B,CAAC;AAC5C,cAAc,0BAA0B,CAAC;AACzC,cAAc,4BAA4B,CAAC;AAC3C,cAAc,8BAA8B,CAAC;AAC7C,cAAc,iBAAiB,CAAC;AAChC,cAAc,mBAAmB,CAAC;AAClC,cAAc,sBAAsB,CAAC;AACrC,cAAc,sBAAsB,CAAC;AACrC,cAAc,mBAAmB,CAAC;AAClC,cAAc,6BAA6B,CAAC;AAC5C,cAAc,cAAc,CAAC;AAC7B,cAAc,sBAAsB,CAAC;AACrC,cAAc,uBAAuB,CAAC;AACtC,cAAc,iBAAiB,CAAC;AAChC,cAAc,+BAA+B,CAAC;AAC9C,cAAc,sCAAsC,CAAC;AACrD,cAAc,qCAAqC,CAAC;AACpD,cAAc,+BAA+B,CAAC;AAC9C,cAAc,0BAA0B,CAAC;AACzC,cAAc,+BAA+B,CAAC;AAC9C,cAAc,oCAAoC,CAAC;AACnD,cAAc,iCAAiC,CAAC"}
@@ -0,0 +1,12 @@
1
+ export interface NavigationRegionClassNames {
2
+ root: string;
3
+ list: string;
4
+ item: string;
5
+ link: string;
6
+ icon: string;
7
+ label: string;
8
+ toggle: string;
9
+ submenu: string;
10
+ }
11
+ export declare const defaultNavigationRegionClassNames: NavigationRegionClassNames;
12
+ //# sourceMappingURL=NavigationRegionClassNames.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"NavigationRegionClassNames.d.ts","sourceRoot":"","sources":["../../../../navigation/region/NavigationRegionClassNames.ts"],"names":[],"mappings":"AASA,MAAM,WAAW,0BAA0B;IAEvC,IAAI,EAAE,MAAM,CAAC;IAGb,IAAI,EAAE,MAAM,CAAC;IAGb,IAAI,EAAE,MAAM,CAAC;IAGb,IAAI,EAAE,MAAM,CAAC;IAGb,IAAI,EAAE,MAAM,CAAC;IAGb,KAAK,EAAE,MAAM,CAAC;IAGd,MAAM,EAAE,MAAM,CAAC;IAGf,OAAO,EAAE,MAAM,CAAC;CACnB;AAGD,eAAO,MAAM,iCAAiC,EAAE,0BAS/C,CAAC"}
@@ -0,0 +1,19 @@
1
+ // Copyright (c) Cratis. All rights reserved.
2
+ // Licensed under the MIT license. See LICENSE file in the project root for full license information.
3
+ /**
4
+ * The class names a {@link NavigationRegionView} puts on its nodes. The renderer carries no look of its own: a package
5
+ * gives the nodes its vocabulary (`blueprint.default` uses its `layout-menu` classes) and a stylesheet does the rest.
6
+ * State is always on data attributes as well - `data-active`, `data-expanded`, `data-read-only`, `data-origin`.
7
+ */ /** The class names used when a host passes none. */ const defaultNavigationRegionClassNames = {
8
+ root: 'scene-nav',
9
+ list: 'scene-nav-list',
10
+ item: 'scene-nav-item',
11
+ link: 'scene-nav-link',
12
+ icon: 'scene-nav-icon',
13
+ label: 'scene-nav-label',
14
+ toggle: 'scene-nav-toggle',
15
+ submenu: 'scene-nav-submenu'
16
+ };
17
+
18
+ export { defaultNavigationRegionClassNames };
19
+ //# 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,20 @@
1
+ import { ReactNode } from 'react';
2
+ import { DestinationReference, NavigationRegionKind } from '@cratis/scene.model';
3
+ import { EffectiveNavItem } from '@cratis/scene.engine';
4
+ import { NavigationRegionClassNames } from './NavigationRegionClassNames';
5
+ import { SceneNavigationModel } from './SceneNavigationModel';
6
+ export interface NavigationRegionViewProps {
7
+ region: NavigationRegionKind;
8
+ module?: string;
9
+ application?: boolean;
10
+ model?: SceneNavigationModel;
11
+ expand?: 'active' | 'all';
12
+ label?: string;
13
+ classNames?: Partial<NavigationRegionClassNames>;
14
+ renderIcon?(icon: string): ReactNode;
15
+ renderAdornment?(item: EffectiveNavItem): ReactNode;
16
+ hrefFor?(destination: DestinationReference, url: string | undefined): string | undefined;
17
+ onActivate?(item: EffectiveNavItem, destination: DestinationReference): void;
18
+ }
19
+ export declare function NavigationRegionView({ region, module, application, model: modelProp, label, expand, classNames, renderIcon, renderAdornment, hrefFor, onActivate }: NavigationRegionViewProps): import("react").JSX.Element;
20
+ //# sourceMappingURL=NavigationRegionView.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"NavigationRegionView.d.ts","sourceRoot":"","sources":["../../../../navigation/region/NavigationRegionView.tsx"],"names":[],"mappings":"AAGA,OAAO,EAA6B,SAAS,EAAyC,MAAM,OAAO,CAAC;AACpG,OAAO,EAAE,oBAAoB,EAAE,oBAAoB,EAAsB,MAAM,qBAAqB,CAAC;AACrG,OAAO,EAA6B,gBAAgB,EAAkD,MAAM,sBAAsB,CAAC;AAKnI,OAAO,EAAE,0BAA0B,EAAqC,MAAM,8BAA8B,CAAC;AAC7G,OAAO,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAC;AAM9D,MAAM,WAAW,yBAAyB;IAEtC,MAAM,EAAE,oBAAoB,CAAC;IAM7B,MAAM,CAAC,EAAE,MAAM,CAAC;IAGhB,WAAW,CAAC,EAAE,OAAO,CAAC;IAGtB,KAAK,CAAC,EAAE,oBAAoB,CAAC;IAM7B,MAAM,CAAC,EAAE,QAAQ,GAAG,KAAK,CAAC;IAG1B,KAAK,CAAC,EAAE,MAAM,CAAC;IAGf,UAAU,CAAC,EAAE,OAAO,CAAC,0BAA0B,CAAC,CAAC;IAMjD,UAAU,CAAC,CAAC,IAAI,EAAE,MAAM,GAAG,SAAS,CAAC;IAMrC,eAAe,CAAC,CAAC,IAAI,EAAE,gBAAgB,GAAG,SAAS,CAAC;IAGpD,OAAO,CAAC,CAAC,WAAW,EAAE,oBAAoB,EAAE,GAAG,EAAE,MAAM,GAAG,SAAS,GAAG,MAAM,GAAG,SAAS,CAAC;IAGzF,UAAU,CAAC,CAAC,IAAI,EAAE,gBAAgB,EAAE,WAAW,EAAE,oBAAoB,GAAG,IAAI,CAAC;CAChF;AAyBD,wBAAgB,oBAAoB,CAAC,EAAE,MAAM,EAAE,MAAM,EAAE,WAAmB,EAAE,KAAK,EAAE,SAAS,EAAE,KAAK,EAAE,MAAiB,EAAE,UAAU,EAAE,UAAU,EAAE,eAAe,EAAE,OAAO,EAAE,UAAU,EAAE,EAAE,yBAAyB,+BAkJhN"}
@@ -0,0 +1,281 @@
1
+ import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
2
+ import { useContext, useMemo, useState, useRef } from 'react';
3
+ import { NavigationRegionKind, parseIconReference } from '@cratis/scene.model';
4
+ import { ApplicationStructureIndex, effectiveNavigation } from '@cratis/scene.engine';
5
+ import { SceneIcon } from '../../icons/SceneIcon.js';
6
+ import { useIconAdapters } from '../../icons/IconAdapterContext.js';
7
+ import { resolveDestination } from '../resolveDestination.js';
8
+ import { SceneNavigationContextInternal } from '../SceneNavigationContext.js';
9
+ import { defaultNavigationRegionClassNames } from './NavigationRegionClassNames.js';
10
+ import { useSceneNavigationModel } from './SceneNavigationModelContext.js';
11
+ import { currentModuleOf } from './currentModuleOf.js';
12
+ import { navigationItemActive } from './navigationItemActive.js';
13
+ import { defaultScreenFor, navigationItemDestination } from './navigationItemDestination.js';
14
+
15
+ function itemKey(path) {
16
+ return path.join('/');
17
+ }
18
+ function containsActive(item, isActive) {
19
+ return isActive(item) || (item.children ?? []).some((child)=>containsActive(child, isActive));
20
+ }
21
+ /**
22
+ * Renders the effective navigation of one region - a topbar or a sidebar - for the application or a module.
23
+ *
24
+ * - **Items** come from `effectiveNavigation`, so inherit/extend/override is already applied; nothing here re-implements
25
+ * it. A topbar is flat; a sidebar nests, collapses, and expands the parents of the active item.
26
+ * - **Active state** follows what the navigation host shows: an item is active (`aria-current`, `data-active`) when the
27
+ * screen it opens is the one in its slot, so items rendering into different slots are active at once.
28
+ * - **Activation** goes through the enclosing navigation host (`navigate`), which renders the target in the item's slot -
29
+ * the `outlet` of the destination; outside a host it announces `cratis.scene.navigate`.
30
+ * - **Authorization**: `isVisible` of the model hides items, it does not disable them.
31
+ * - **Keyboard**: arrows (left/right in a topbar, up/down in a sidebar), Home and End move between items; in a sidebar
32
+ * right expands and left collapses (or goes to the parent).
33
+ *
34
+ * Nothing here draws design chrome: items carry `data-read-only` and `data-origin` for a design layer to style.
35
+ */ function NavigationRegionView({ region, module, application = false, model: modelProp, label, expand = 'active', classNames, renderIcon, renderAdornment, hrefFor, onActivate }) {
36
+ const contextModel = useSceneNavigationModel();
37
+ const model = modelProp ?? contextModel;
38
+ if (!model) throw new Error('NavigationRegionView needs a navigation model: pass `model` or render it inside a SceneNavigationModelProvider.');
39
+ const navigation = useContext(SceneNavigationContextInternal);
40
+ const adapters = useIconAdapters();
41
+ const names = {
42
+ ...defaultNavigationRegionClassNames,
43
+ ...classNames
44
+ };
45
+ const index = useMemo(()=>model.structure instanceof ApplicationStructureIndex ? model.structure : new ApplicationStructureIndex(model.structure), [
46
+ model.structure
47
+ ]);
48
+ const screenFor = model.screenFor ?? defaultScreenFor;
49
+ const sidebar = region === NavigationRegionKind.Sidebar;
50
+ const placement = useMemo(()=>({
51
+ primaryScreen: navigation?.primaryScreen,
52
+ outlets: navigation?.outlets ?? {}
53
+ }), [
54
+ navigation?.outlets,
55
+ navigation?.primaryScreen
56
+ ]);
57
+ const scope = application ? undefined : module ?? currentModuleOf(index, placement.primaryScreen);
58
+ const resolved = useMemo(()=>effectiveNavigation(index, model.navigation, scope, region), [
59
+ index,
60
+ model.navigation,
61
+ scope,
62
+ region
63
+ ]);
64
+ const isActive = (item)=>placement.primaryScreen !== undefined && navigationItemActive(item, {
65
+ primaryScreen: placement.primaryScreen,
66
+ outlets: placement.outlets
67
+ }, screenFor, !sidebar);
68
+ const isVisible = model.isVisible ?? (()=>true);
69
+ const visible = useMemo(()=>{
70
+ const keep = (items)=>items.filter(isVisible).map((item)=>item.children ? {
71
+ ...item,
72
+ children: keep(item.children)
73
+ } : item);
74
+ return keep(resolved.items);
75
+ }, [
76
+ resolved,
77
+ model.isVisible
78
+ ]);
79
+ const activeKey = JSON.stringify([
80
+ placement.primaryScreen,
81
+ placement.outlets,
82
+ scope
83
+ ]);
84
+ const [toggled, setToggled] = useState({
85
+ key: activeKey,
86
+ state: {}
87
+ });
88
+ const overrides = toggled.key === activeKey ? toggled.state : {};
89
+ const [focused, setFocused] = useState();
90
+ const root = useRef(null);
91
+ const isExpanded = (item, key)=>overrides[key] ?? (expand === 'all' || containsActive(item, isActive));
92
+ const toggle = (key, expanded)=>setToggled({
93
+ key: activeKey,
94
+ state: {
95
+ ...overrides,
96
+ [key]: expanded
97
+ }
98
+ });
99
+ const activate = (item)=>{
100
+ const destination = navigationItemDestination(item, screenFor);
101
+ if (destination === undefined) return;
102
+ if (navigation) {
103
+ navigation.navigate(destination);
104
+ } else {
105
+ globalThis.dispatchEvent(new CustomEvent('cratis.scene.navigate', {
106
+ detail: {
107
+ targetScreen: destination.screen ?? '',
108
+ destination,
109
+ item
110
+ }
111
+ }));
112
+ }
113
+ onActivate?.(item, destination);
114
+ };
115
+ const links = ()=>Array.from(root.current?.querySelectorAll('[data-scene-nav-link]') ?? []);
116
+ const focusLink = (element)=>{
117
+ if (!element) return;
118
+ setFocused(element.getAttribute('data-scene-nav-link') ?? undefined);
119
+ element.focus();
120
+ };
121
+ const onKeyDown = (event)=>{
122
+ const all = links();
123
+ const position = all.findIndex((link)=>link === document.activeElement);
124
+ if (position < 0) return;
125
+ const next = sidebar ? 'ArrowDown' : 'ArrowRight';
126
+ const previous = sidebar ? 'ArrowUp' : 'ArrowLeft';
127
+ const current = all[position];
128
+ const key = current.getAttribute('data-scene-nav-link');
129
+ const owner = current.closest('[data-scene-nav-item]');
130
+ const hasChildren = owner?.getAttribute('data-scene-nav-parent') === 'true';
131
+ const expanded = owner?.getAttribute('data-expanded') === 'true';
132
+ let target;
133
+ if (event.key === next) target = all[Math.min(position + 1, all.length - 1)];
134
+ else if (event.key === previous) target = all[Math.max(position - 1, 0)];
135
+ else if (event.key === 'Home') target = all[0];
136
+ else if (event.key === 'End') target = all[all.length - 1];
137
+ else if (sidebar && event.key === 'ArrowRight' && hasChildren) {
138
+ if (!expanded) toggle(key, true);
139
+ else target = all[position + 1];
140
+ } else if (sidebar && event.key === 'ArrowLeft') {
141
+ if (hasChildren && expanded) toggle(key, false);
142
+ else {
143
+ const parent = owner?.parentElement?.closest('[data-scene-nav-item]')?.querySelector(':scope > [data-scene-nav-link]');
144
+ if (parent) target = parent;
145
+ }
146
+ } else return;
147
+ event.preventDefault();
148
+ focusLink(target);
149
+ };
150
+ const tabStop = focused ?? undefined;
151
+ const firstActive = (items, path)=>{
152
+ for (const item of items){
153
+ const key = itemKey([
154
+ ...path,
155
+ item.id
156
+ ]);
157
+ if (isActive(item)) return key;
158
+ const inner = firstActive(item.children ?? [], [
159
+ ...path,
160
+ item.id
161
+ ]);
162
+ if (inner !== undefined && isExpanded(item, key)) return inner;
163
+ }
164
+ return undefined;
165
+ };
166
+ const firstKey = visible.length > 0 ? itemKey([
167
+ visible[0].id
168
+ ]) : undefined;
169
+ const stop = tabStop ?? firstActive(visible, []) ?? firstKey;
170
+ const icon = (item)=>{
171
+ if (item.icon === undefined) return null;
172
+ const drawn = renderIcon ? renderIcon(item.icon) : adapters ? (()=>{
173
+ const reference = parseIconReference(item.icon);
174
+ return reference ? /*#__PURE__*/ jsx(SceneIcon, {
175
+ reference: reference,
176
+ adapters: adapters
177
+ }) : null;
178
+ })() : null;
179
+ return drawn === null ? null : /*#__PURE__*/ jsx("span", {
180
+ className: names.icon,
181
+ "aria-hidden": "true",
182
+ "data-scene-icon": item.icon,
183
+ children: drawn
184
+ });
185
+ };
186
+ const renderItems = (items, path, level)=>items.map((item)=>{
187
+ const key = itemKey([
188
+ ...path,
189
+ item.id
190
+ ]);
191
+ const destination = navigationItemDestination(item, screenFor);
192
+ const active = isActive(item);
193
+ const children = item.children ?? [];
194
+ const parent = sidebar && children.length > 0;
195
+ const expanded = parent && isExpanded(item, key);
196
+ const url = destination ? resolveDestination(destination).url : undefined;
197
+ const href = destination ? hrefFor ? hrefFor(destination, url) : url ? `#/${url}` : undefined : undefined;
198
+ const onClick = (event)=>{
199
+ if (event.metaKey || event.ctrlKey || event.shiftKey || event.button !== 0) return;
200
+ event.preventDefault();
201
+ if (destination) activate(item);
202
+ else if (parent) toggle(key, !expanded);
203
+ };
204
+ const content = /*#__PURE__*/ jsxs(Fragment, {
205
+ children: [
206
+ icon(item),
207
+ /*#__PURE__*/ jsx("span", {
208
+ className: names.label,
209
+ children: item.title
210
+ }),
211
+ renderAdornment?.(item)
212
+ ]
213
+ });
214
+ return /*#__PURE__*/ jsxs("li", {
215
+ className: names.item,
216
+ "data-scene-nav-item": item.id,
217
+ "data-scene-nav-parent": parent ? 'true' : undefined,
218
+ "data-active": active,
219
+ "data-active-descendant": !active && parent && children.some((child)=>containsActive(child, isActive)) ? true : undefined,
220
+ "data-expanded": parent ? expanded : undefined,
221
+ "data-origin": item.origin,
222
+ "data-read-only": item.readOnly,
223
+ "data-slot": item.slot,
224
+ "data-level": level,
225
+ children: [
226
+ destination || parent ? /*#__PURE__*/ jsx("a", {
227
+ className: names.link,
228
+ href: href ?? '#',
229
+ "data-scene-nav-link": key,
230
+ "aria-current": active ? 'page' : undefined,
231
+ "aria-expanded": parent && !destination ? expanded : undefined,
232
+ tabIndex: key === stop ? 0 : -1,
233
+ onClick: onClick,
234
+ onFocus: ()=>setFocused(key),
235
+ children: content
236
+ }) : /*#__PURE__*/ jsx("span", {
237
+ className: names.link,
238
+ "aria-disabled": "true",
239
+ "data-scene-nav-link": key,
240
+ tabIndex: -1,
241
+ children: content
242
+ }),
243
+ parent && /*#__PURE__*/ jsx("button", {
244
+ type: "button",
245
+ className: names.toggle,
246
+ tabIndex: -1,
247
+ "aria-expanded": expanded,
248
+ "aria-controls": `${key}-items`,
249
+ "aria-label": `${expanded ? 'Collapse' : 'Expand'} ${item.title}`,
250
+ onClick: ()=>toggle(key, !expanded)
251
+ }),
252
+ parent && expanded && /*#__PURE__*/ jsx("ul", {
253
+ id: `${key}-items`,
254
+ className: `${names.list} ${names.submenu}`,
255
+ children: renderItems(children, [
256
+ ...path,
257
+ item.id
258
+ ], level + 1)
259
+ })
260
+ ]
261
+ }, item.id);
262
+ });
263
+ return /*#__PURE__*/ jsx("nav", {
264
+ ref: root,
265
+ className: names.root,
266
+ "aria-label": label ?? (sidebar ? 'Sidebar' : 'Topbar'),
267
+ "data-scene-nav-region": region,
268
+ "data-scene-nav-sources": resolved.sources.kind,
269
+ "data-scene-nav-sources-label": resolved.sources.label,
270
+ "data-scene-nav-module": scope,
271
+ "data-scene-nav-mode": resolved.mode,
272
+ onKeyDown: onKeyDown,
273
+ children: /*#__PURE__*/ jsx("ul", {
274
+ className: names.list,
275
+ children: renderItems(visible, [], 0)
276
+ })
277
+ });
278
+ }
279
+
280
+ export { NavigationRegionView };
281
+ //# 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,uBAAAA,EAAAA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I,CAAA,EAAGrD,GAAAA,CAAI,MAAM,CAAC;wBAAEgE,SAAAA,EAAW,CAAA,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,GAAA,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,GAAA,CAAC4C,IAAAA,EAAAA;AAAGzC,YAAAA,SAAAA,EAAWhG,MAAM0I,IAAI;sBAAGvC,WAAAA,CAAY9E,OAAAA,EAAS,EAAE,EAAE,CAAA;;;AAE7D;;"}
@@ -0,0 +1,9 @@
1
+ import { ApplicationStructure, NavigationModel } from '@cratis/scene.model';
2
+ import { ApplicationStructureIndex, EffectiveNavItem } from '@cratis/scene.engine';
3
+ export interface SceneNavigationModel {
4
+ structure: ApplicationStructure | ApplicationStructureIndex;
5
+ navigation: NavigationModel;
6
+ screenFor?(item: EffectiveNavItem): string | undefined;
7
+ isVisible?(item: EffectiveNavItem): boolean;
8
+ }
9
+ //# sourceMappingURL=SceneNavigationModel.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"SceneNavigationModel.d.ts","sourceRoot":"","sources":["../../../../navigation/region/SceneNavigationModel.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,oBAAoB,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AAC5E,OAAO,EAAE,yBAAyB,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AAMnF,MAAM,WAAW,oBAAoB;IAEjC,SAAS,EAAE,oBAAoB,GAAG,yBAAyB,CAAC;IAG5D,UAAU,EAAE,eAAe,CAAC;IAM5B,SAAS,CAAC,CAAC,IAAI,EAAE,gBAAgB,GAAG,MAAM,GAAG,SAAS,CAAC;IAMvD,SAAS,CAAC,CAAC,IAAI,EAAE,gBAAgB,GAAG,OAAO,CAAC;CAC/C"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=SceneNavigationModel.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"SceneNavigationModel.js","sourceRoot":"","sources":["../../../../navigation/region/SceneNavigationModel.ts"],"names":[],"mappings":""}
@@ -0,0 +1,9 @@
1
+ import { ReactNode } from 'react';
2
+ import { SceneNavigationModel } from './SceneNavigationModel';
3
+ export interface SceneNavigationModelProviderProps {
4
+ model: SceneNavigationModel;
5
+ children?: ReactNode;
6
+ }
7
+ export declare function SceneNavigationModelProvider({ model, children }: SceneNavigationModelProviderProps): import("react").JSX.Element;
8
+ export declare function useSceneNavigationModel(): SceneNavigationModel | undefined;
9
+ //# sourceMappingURL=SceneNavigationModelContext.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"SceneNavigationModelContext.d.ts","sourceRoot":"","sources":["../../../../navigation/region/SceneNavigationModelContext.tsx"],"names":[],"mappings":"AAGA,OAAO,EAAE,SAAS,EAA6B,MAAM,OAAO,CAAC;AAC7D,OAAO,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAC;AAI9D,MAAM,WAAW,iCAAiC;IAC9C,KAAK,EAAE,oBAAoB,CAAC;IAC5B,QAAQ,CAAC,EAAE,SAAS,CAAC;CACxB;AAMD,wBAAgB,4BAA4B,CAAC,EAAE,KAAK,EAAE,QAAQ,EAAE,EAAE,iCAAiC,+BAElG;AAGD,wBAAgB,uBAAuB,IAAI,oBAAoB,GAAG,SAAS,CAE1E"}
@@ -0,0 +1,19 @@
1
+ import { jsx } from 'react/jsx-runtime';
2
+ import { useContext, createContext } from 'react';
3
+
4
+ const Context = /*#__PURE__*/ createContext(undefined);
5
+ /**
6
+ * Supplies the application structure and navigation every navigation region below it renders - the topbar and sidebar
7
+ * components of a shell find what to show here, so a screen document does not carry the application's navigation.
8
+ */ function SceneNavigationModelProvider({ model, children }) {
9
+ return /*#__PURE__*/ jsx(Context.Provider, {
10
+ value: model,
11
+ children: children
12
+ });
13
+ }
14
+ /** The navigation model in scope, or undefined outside a {@link SceneNavigationModelProvider}. */ function useSceneNavigationModel() {
15
+ return useContext(Context);
16
+ }
17
+
18
+ export { SceneNavigationModelProvider, useSceneNavigationModel };
19
+ //# 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,aAAAA,CAAgDC,SAAAA,CAAAA;AAOhE;;;AAGC,IACM,SAASC,4BAAAA,CAA6B,EAAEC,KAAK,EAAEC,QAAQ,EAAqC,EAAA;IAC/F,qBAAOC,GAAA,CAACN,QAAQO,QAAQ,EAAA;QAACC,KAAAA,EAAOJ,KAAAA;AAAQC,QAAAA,QAAAA,EAAAA;;AAC5C;AAEA,mGACO,SAASI,uBAAAA,GAAAA;AACZ,IAAA,OAAOC,UAAAA,CAAWV,OAAAA,CAAAA;AACtB;;"}
@@ -0,0 +1,3 @@
1
+ import { ApplicationStructureIndex } from '@cratis/scene.engine';
2
+ export declare function currentModuleOf(index: ApplicationStructureIndex, screen: string | undefined): string | undefined;
3
+ //# sourceMappingURL=currentModuleOf.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"currentModuleOf.d.ts","sourceRoot":"","sources":["../../../../navigation/region/currentModuleOf.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,yBAAyB,EAAE,MAAM,sBAAsB,CAAC;AAMjE,wBAAgB,eAAe,CAAC,KAAK,EAAE,yBAAyB,EAAE,MAAM,EAAE,MAAM,GAAG,SAAS,GAAG,MAAM,GAAG,SAAS,CAIhH"}
@@ -0,0 +1,13 @@
1
+ // Copyright (c) Cratis. All rights reserved.
2
+ // Licensed under the MIT license. See LICENSE file in the project root for full license information.
3
+ /**
4
+ * The module the screen on the page belongs to: the screen's qualified id starts with its module id, so `sales.orders`
5
+ * is in `sales`. Undefined for a screen outside every module - the application level.
6
+ */ function currentModuleOf(index, screen) {
7
+ if (screen === undefined) return undefined;
8
+ const module = screen.split('.')[0];
9
+ return index.findModule(module) ? module : undefined;
10
+ }
11
+
12
+ export { currentModuleOf };
13
+ //# 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,4 @@
1
+ import { ApplicationStructure, DestinationReference, NavigationModel } from '@cratis/scene.model';
2
+ import { ApplicationStructureIndex, EffectiveNavItem } from '@cratis/scene.engine';
3
+ export declare function navigationDestinations(structure: ApplicationStructure | ApplicationStructureIndex, navigation: NavigationModel, screenFor?: (item: EffectiveNavItem) => string | undefined): DestinationReference[];
4
+ //# sourceMappingURL=navigationDestinations.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"navigationDestinations.d.ts","sourceRoot":"","sources":["../../../../navigation/region/navigationDestinations.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,oBAAoB,EAAE,oBAAoB,EAAwB,eAAe,EAAE,MAAM,qBAAqB,CAAC;AACxH,OAAO,EAAE,yBAAyB,EAAE,gBAAgB,EAAuB,MAAM,sBAAsB,CAAC;AAYxG,wBAAgB,sBAAsB,CAClC,SAAS,EAAE,oBAAoB,GAAG,yBAAyB,EAC3D,UAAU,EAAE,eAAe,EAC3B,SAAS,CAAC,EAAE,CAAC,IAAI,EAAE,gBAAgB,KAAK,MAAM,GAAG,SAAS,GAC3D,oBAAoB,EAAE,CAoBxB"}
@@ -0,0 +1,44 @@
1
+ import { NavigationRegionKind } from '@cratis/scene.model';
2
+ import { ApplicationStructureIndex, effectiveNavigation } from '@cratis/scene.engine';
3
+ import { navigationItemDestination } from './navigationItemDestination.js';
4
+
5
+ // Copyright (c) Cratis. All rights reserved.
6
+ // Licensed under the MIT license. See LICENSE file in the project root for full license information.
7
+ function flatten(items) {
8
+ return items.flatMap((item)=>[
9
+ item,
10
+ ...flatten(item.children ?? [])
11
+ ]);
12
+ }
13
+ /**
14
+ * Every destination the navigation of the application and of each module can lead to, once each: what a
15
+ * `SceneNavigationHost` is given as `destinations` so deep links to a navigation item resolve, and an item that renders
16
+ * into a nested outlet is placed with the screen that declares the outlet.
17
+ */ function navigationDestinations(structure, navigation, screenFor) {
18
+ const index = structure instanceof ApplicationStructureIndex ? structure : new ApplicationStructureIndex(structure);
19
+ const modules = [
20
+ undefined,
21
+ ...index.structure.modules.map((module)=>module.id)
22
+ ];
23
+ const seen = new Set();
24
+ const destinations = [];
25
+ for (const module of modules){
26
+ for (const region of [
27
+ NavigationRegionKind.Topbar,
28
+ NavigationRegionKind.Sidebar
29
+ ]){
30
+ for (const item of flatten(effectiveNavigation(index, navigation, module, region).items)){
31
+ const destination = navigationItemDestination(item, screenFor);
32
+ if (destination === undefined) continue;
33
+ const key = JSON.stringify(destination);
34
+ if (seen.has(key)) continue;
35
+ seen.add(key);
36
+ destinations.push(destination);
37
+ }
38
+ }
39
+ }
40
+ return destinations;
41
+ }
42
+
43
+ export { navigationDestinations };
44
+ //# sourceMappingURL=navigationDestinations.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"navigationDestinations.js","sources":["../../../../navigation/region/navigationDestinations.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 { ApplicationStructure, DestinationReference, NavigationRegionKind, NavigationModel } from '@cratis/scene.model';\nimport { ApplicationStructureIndex, EffectiveNavItem, effectiveNavigation } from '@cratis/scene.engine';\nimport { navigationItemDestination } from './navigationItemDestination';\n\nfunction flatten(items: EffectiveNavItem[]): EffectiveNavItem[] {\n return items.flatMap(item => [item, ...flatten(item.children ?? [])]);\n}\n\n/**\n * Every destination the navigation of the application and of each module can lead to, once each: what a\n * `SceneNavigationHost` is given as `destinations` so deep links to a navigation item resolve, and an item that renders\n * into a nested outlet is placed with the screen that declares the outlet.\n */\nexport function navigationDestinations(\n structure: ApplicationStructure | ApplicationStructureIndex,\n navigation: NavigationModel,\n screenFor?: (item: EffectiveNavItem) => string | undefined,\n): DestinationReference[] {\n const index = structure instanceof ApplicationStructureIndex ? structure : new ApplicationStructureIndex(structure);\n const modules = [undefined, ...index.structure.modules.map(module => module.id)];\n const seen = new Set<string>();\n const destinations: DestinationReference[] = [];\n\n for (const module of modules) {\n for (const region of [NavigationRegionKind.Topbar, NavigationRegionKind.Sidebar]) {\n for (const item of flatten(effectiveNavigation(index, navigation, module, region).items)) {\n const destination = navigationItemDestination(item, screenFor);\n if (destination === undefined) continue;\n const key = JSON.stringify(destination);\n if (seen.has(key)) continue;\n seen.add(key);\n destinations.push(destination);\n }\n }\n }\n\n return destinations;\n}\n"],"names":["flatten","items","flatMap","item","children","navigationDestinations","structure","navigation","screenFor","index","ApplicationStructureIndex","modules","undefined","map","module","id","seen","Set","destinations","region","NavigationRegionKind","Topbar","Sidebar","effectiveNavigation","destination","navigationItemDestination","key","JSON","stringify","has","add","push"],"m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A,IAAAA,CAAKc,GAAG,CAACJ,GAAAA,CAAAA;AACTR,gBAAAA,YAAAA,CAAaa,IAAI,CAACP,WAAAA,CAAAA;AACtB,YAAA;AACJ,QAAA;AACJ,IAAA;IAEA,OAAON,YAAAA;AACX;;"}
@@ -0,0 +1,5 @@
1
+ import { EffectiveNavItem } from '@cratis/scene.engine';
2
+ import { SceneNavigationContextValue } from '../SceneNavigationContext';
3
+ export type NavigationPlacement = Pick<SceneNavigationContextValue, 'primaryScreen' | 'outlets'>;
4
+ export declare function navigationItemActive(item: EffectiveNavItem, placement: NavigationPlacement, screenFor?: (item: EffectiveNavItem) => string | undefined, matchModule?: boolean): boolean;
5
+ //# sourceMappingURL=navigationItemActive.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"navigationItemActive.d.ts","sourceRoot":"","sources":["../../../../navigation/region/navigationItemActive.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,gBAAgB,EAAe,MAAM,sBAAsB,CAAC;AAErE,OAAO,EAAE,2BAA2B,EAAE,MAAM,2BAA2B,CAAC;AAGxE,MAAM,MAAM,mBAAmB,GAAG,IAAI,CAAC,2BAA2B,EAAE,eAAe,GAAG,SAAS,CAAC,CAAC;AAejG,wBAAgB,oBAAoB,CAChC,IAAI,EAAE,gBAAgB,EACtB,SAAS,EAAE,mBAAmB,EAC9B,SAAS,GAAE,CAAC,IAAI,EAAE,gBAAgB,KAAK,MAAM,GAAG,SAA4B,EAC5E,WAAW,UAAQ,GACpB,OAAO,CAUT"}