@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
@@ -0,0 +1,29 @@
1
+ import { primarySlot } from '@cratis/scene.engine';
2
+ import { defaultScreenFor } from './navigationItemDestination.js';
3
+
4
+ // Copyright (c) Cratis. All rights reserved.
5
+ // Licensed under the MIT license. See LICENSE file in the project root for full license information.
6
+ /**
7
+ * Whether a navigation item is the one the page shows.
8
+ *
9
+ * An item is active when the screen it opens is the one in the slot it renders into: the primary region for the
10
+ * `content` slot, the nested outlet of that name otherwise. So several items can be active at once - each is shown in
11
+ * its own slot - and closing a slot's screen un-highlights its item. With `matchModule` - a topbar - an item that targets
12
+ * a module without a feature is also active while any screen of that module is in its slot.
13
+ *
14
+ * @param item The effective item.
15
+ * @param placement What the host currently shows.
16
+ * @param screenFor Names the screen an item opens; the feature the item resolves to when absent.
17
+ * @param matchModule Whether a module item is active on any screen of the module; a topbar's are, a sidebar's are not.
18
+ */ function navigationItemActive(item, placement, screenFor = defaultScreenFor, matchModule = false) {
19
+ const screen = screenFor(item);
20
+ if (screen === undefined) return false;
21
+ const shown = item.slot === primarySlot ? placement.primaryScreen : placement.outlets[item.slot];
22
+ if (shown === undefined) return false;
23
+ if (shown === screen) return true;
24
+ const target = item.target;
25
+ return matchModule && target !== undefined && target.feature === undefined && shown.startsWith(`${target.module}.`);
26
+ }
27
+
28
+ export { navigationItemActive };
29
+ //# sourceMappingURL=navigationItemActive.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"navigationItemActive.js","sources":["../../../../navigation/region/navigationItemActive.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 { EffectiveNavItem, primarySlot } from '@cratis/scene.engine';\nimport { defaultScreenFor } from './navigationItemDestination';\nimport { SceneNavigationContextValue } from '../SceneNavigationContext';\n\n/** Where the navigation host is: the part of {@link SceneNavigationContextValue} that says what is on the page. */\nexport type NavigationPlacement = Pick<SceneNavigationContextValue, 'primaryScreen' | 'outlets'>;\n\n/**\n * Whether a navigation item is the one the page shows.\n *\n * An item is active when the screen it opens is the one in the slot it renders into: the primary region for the\n * `content` slot, the nested outlet of that name otherwise. So several items can be active at once - each is shown in\n * its own slot - and closing a slot's screen un-highlights its item. With `matchModule` - a topbar - an item that targets\n * a module without a feature is also active while any screen of that module is in its slot.\n *\n * @param item The effective item.\n * @param placement What the host currently shows.\n * @param screenFor Names the screen an item opens; the feature the item resolves to when absent.\n * @param matchModule Whether a module item is active on any screen of the module; a topbar's are, a sidebar's are not.\n */\nexport function navigationItemActive(\n item: EffectiveNavItem,\n placement: NavigationPlacement,\n screenFor: (item: EffectiveNavItem) => string | undefined = defaultScreenFor,\n matchModule = false,\n): boolean {\n const screen = screenFor(item);\n if (screen === undefined) return false;\n\n const shown = item.slot === primarySlot ? placement.primaryScreen : placement.outlets[item.slot];\n if (shown === undefined) return false;\n if (shown === screen) return true;\n\n const target = item.target;\n return matchModule && target !== undefined && target.feature === undefined && shown.startsWith(`${target.module}.`);\n}\n"],"names":["navigationItemActive","item","placement","screenFor","defaultScreenFor","matchModule","screen","undefined","shown","slot","primarySlot","primaryScreen","outlets","target","feature","startsWith","module"],"mappings":";;;AAAA;AACA;AASA;;;;;;;;;;;;IAaO,SAASA,oBAAAA,CACZC,IAAsB,EACtBC,SAA8B,EAC9BC,SAAAA,GAA4DC,gBAAgB,EAC5EC,WAAAA,GAAc,KAAK,EAAA;AAEnB,IAAA,MAAMC,SAASH,SAAAA,CAAUF,IAAAA,CAAAA;IACzB,IAAIK,MAAAA,KAAWC,WAAW,OAAO,KAAA;AAEjC,IAAA,MAAMC,KAAAA,GAAQP,IAAAA,CAAKQ,IAAI,KAAKC,WAAAA,GAAcR,SAAAA,CAAUS,aAAa,GAAGT,SAAAA,CAAUU,OAAO,CAACX,IAAAA,CAAKQ,IAAI,CAAC;IAChG,IAAID,KAAAA,KAAUD,WAAW,OAAO,KAAA;IAChC,IAAIC,KAAAA,KAAUF,QAAQ,OAAO,IAAA;IAE7B,MAAMO,MAAAA,GAASZ,KAAKY,MAAM;AAC1B,IAAA,OAAOR,WAAAA,IAAeQ,MAAAA,KAAWN,SAAAA,IAAaM,MAAAA,CAAOC,OAAO,KAAKP,SAAAA,IAAaC,KAAAA,CAAMO,UAAU,CAAC,CAAA,EAAGF,MAAAA,CAAOG,MAAM,CAAC,CAAC,CAAC,CAAA;AACtH;;"}
@@ -0,0 +1,5 @@
1
+ import { DestinationReference } from '@cratis/scene.model';
2
+ import { EffectiveNavItem } from '@cratis/scene.engine';
3
+ export declare function defaultScreenFor(item: EffectiveNavItem): string | undefined;
4
+ export declare function navigationItemDestination(item: EffectiveNavItem, screenFor?: (item: EffectiveNavItem) => string | undefined): DestinationReference | undefined;
5
+ //# sourceMappingURL=navigationItemDestination.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"navigationItemDestination.d.ts","sourceRoot":"","sources":["../../../../navigation/region/navigationItemDestination.ts"],"names":[],"mappings":"AAGA,OAAO,EAAmB,oBAAoB,EAAE,MAAM,qBAAqB,CAAC;AAC5E,OAAO,EAAE,gBAAgB,EAAe,MAAM,sBAAsB,CAAC;AAGrE,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,gBAAgB,GAAG,MAAM,GAAG,SAAS,CAE3E;AAUD,wBAAgB,yBAAyB,CAAC,IAAI,EAAE,gBAAgB,EAAE,SAAS,GAAE,CAAC,IAAI,EAAE,gBAAgB,KAAK,MAAM,GAAG,SAA4B,GAAG,oBAAoB,GAAG,SAAS,CAShL"}
@@ -0,0 +1,31 @@
1
+ import { DestinationKind } from '@cratis/scene.model';
2
+ import { primarySlot } from '@cratis/scene.engine';
3
+
4
+ // Copyright (c) Cratis. All rights reserved.
5
+ // Licensed under the MIT license. See LICENSE file in the project root for full license information.
6
+ /** The screen an item opens by default: the qualified id of the feature it resolves to. */ function defaultScreenFor(item) {
7
+ return item.target?.resolvedFeature;
8
+ }
9
+ /**
10
+ * Where activating a navigation item goes: its stable module/feature identity, the screen it opens, and the slot it
11
+ * renders into as the outlet - the primary `content` slot is the host's primary outlet.
12
+ *
13
+ * @param item The effective item.
14
+ * @param screenFor Names the screen an item opens; {@link defaultScreenFor} when absent.
15
+ * @returns The destination, or undefined when the item leads nowhere.
16
+ */ function navigationItemDestination(item, screenFor = defaultScreenFor) {
17
+ const screen = screenFor(item);
18
+ if (screen === undefined || item.target === undefined) return undefined;
19
+ const resolved = item.target.resolvedFeature;
20
+ const destination = {
21
+ kind: DestinationKind.Outlet,
22
+ module: item.target.module,
23
+ screen
24
+ };
25
+ if (resolved !== undefined && resolved.startsWith(`${item.target.module}.`)) destination.feature = resolved.substring(item.target.module.length + 1);
26
+ if (item.slot !== primarySlot) destination.outlet = item.slot;
27
+ return destination;
28
+ }
29
+
30
+ export { defaultScreenFor, navigationItemDestination };
31
+ //# sourceMappingURL=navigationItemDestination.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"navigationItemDestination.js","sources":["../../../../navigation/region/navigationItemDestination.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 { DestinationKind, DestinationReference } from '@cratis/scene.model';\nimport { EffectiveNavItem, primarySlot } from '@cratis/scene.engine';\n\n/** The screen an item opens by default: the qualified id of the feature it resolves to. */\nexport function defaultScreenFor(item: EffectiveNavItem): string | undefined {\n return item.target?.resolvedFeature;\n}\n\n/**\n * Where activating a navigation item goes: its stable module/feature identity, the screen it opens, and the slot it\n * renders into as the outlet - the primary `content` slot is the host's primary outlet.\n *\n * @param item The effective item.\n * @param screenFor Names the screen an item opens; {@link defaultScreenFor} when absent.\n * @returns The destination, or undefined when the item leads nowhere.\n */\nexport function navigationItemDestination(item: EffectiveNavItem, screenFor: (item: EffectiveNavItem) => string | undefined = defaultScreenFor): DestinationReference | undefined {\n const screen = screenFor(item);\n if (screen === undefined || item.target === undefined) return undefined;\n\n const resolved = item.target.resolvedFeature;\n const destination: DestinationReference = { kind: DestinationKind.Outlet, module: item.target.module, screen };\n if (resolved !== undefined && resolved.startsWith(`${item.target.module}.`)) destination.feature = resolved.substring(item.target.module.length + 1);\n if (item.slot !== primarySlot) destination.outlet = item.slot;\n return destination;\n}\n"],"names":["defaultScreenFor","item","target","resolvedFeature","navigationItemDestination","screenFor","screen","undefined","resolved","destination","kind","DestinationKind","Outlet","module","startsWith","feature","substring","length","slot","primarySlot","outlet"],"mappings":";;;AAAA;AACA;AAKA,4FACO,SAASA,gBAAAA,CAAiBC,IAAsB,EAAA;IACnD,OAAOA,IAAAA,CAAKC,MAAM,EAAEC,eAAAA;AACxB;AAEA;;;;;;;AAOC,IACM,SAASC,yBAAAA,CAA0BH,IAAsB,EAAEI,YAA4DL,gBAAgB,EAAA;AAC1I,IAAA,MAAMM,SAASD,SAAAA,CAAUJ,IAAAA,CAAAA;AACzB,IAAA,IAAIK,WAAWC,SAAAA,IAAaN,IAAAA,CAAKC,MAAM,KAAKK,WAAW,OAAOA,SAAAA;AAE9D,IAAA,MAAMC,QAAAA,GAAWP,IAAAA,CAAKC,MAAM,CAACC,eAAe;AAC5C,IAAA,MAAMM,WAAAA,GAAoC;AAAEC,QAAAA,IAAAA,EAAMC,gBAAgBC,MAAM;QAAEC,MAAAA,EAAQZ,IAAAA,CAAKC,MAAM,CAACW,MAAM;AAAEP,QAAAA;AAAO,KAAA;IAC7G,IAAIE,QAAAA,KAAaD,SAAAA,IAAaC,QAAAA,CAASM,UAAU,CAAC,CAAA,EAAGb,IAAAA,CAAKC,MAAM,CAACW,MAAM,CAAC,CAAC,CAAC,GAAGJ,WAAAA,CAAYM,OAAO,GAAGP,QAAAA,CAASQ,SAAS,CAACf,IAAAA,CAAKC,MAAM,CAACW,MAAM,CAACI,MAAM,GAAG,CAAA,CAAA;IAClJ,IAAIhB,IAAAA,CAAKiB,IAAI,KAAKC,WAAAA,EAAaV,YAAYW,MAAM,GAAGnB,KAAKiB,IAAI;IAC7D,OAAOT,WAAAA;AACX;;"}