@cratis/scene.react 0.1.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 (175) hide show
  1. package/.storybook/main.ts +31 -0
  2. package/.storybook/preview.ts +12 -0
  3. package/NavBar/NavBar.tsx +53 -0
  4. package/NavBar/extractNavigationItem.ts +40 -0
  5. package/NavBar/for_NavBar/when_rendering_navigation_contributions.tsx +62 -0
  6. package/NavBar/for_extractNavigationItem/when_extracting_from_a_navigation_contribution.ts +53 -0
  7. package/NavBar/index.ts +5 -0
  8. package/README.md +40 -0
  9. package/SceneElementView.stories.tsx +67 -0
  10. package/SceneElementView.tsx +22 -0
  11. package/core/CoreButton.tsx +17 -0
  12. package/core/CoreCard.tsx +15 -0
  13. package/core/CoreText.tsx +13 -0
  14. package/core/coreComponents.ts +18 -0
  15. package/core/corePackage.ts +36 -0
  16. package/core/index.ts +8 -0
  17. package/dist/cjs/NavBar/NavBar.js +47 -0
  18. package/dist/cjs/NavBar/NavBar.js.map +1 -0
  19. package/dist/cjs/NavBar/extractNavigationItem.js +38 -0
  20. package/dist/cjs/NavBar/extractNavigationItem.js.map +1 -0
  21. package/dist/cjs/SceneElementView.js +21 -0
  22. package/dist/cjs/SceneElementView.js.map +1 -0
  23. package/dist/cjs/core/CoreButton.js +22 -0
  24. package/dist/cjs/core/CoreButton.js.map +1 -0
  25. package/dist/cjs/core/CoreCard.js +22 -0
  26. package/dist/cjs/core/CoreCard.js.map +1 -0
  27. package/dist/cjs/core/CoreText.js +19 -0
  28. package/dist/cjs/core/CoreText.js.map +1 -0
  29. package/dist/cjs/core/coreComponents.js +20 -0
  30. package/dist/cjs/core/coreComponents.js.map +1 -0
  31. package/dist/cjs/core/corePackage.js +41 -0
  32. package/dist/cjs/core/corePackage.js.map +1 -0
  33. package/dist/cjs/index.js +38 -0
  34. package/dist/cjs/index.js.map +1 -0
  35. package/dist/cjs/package.json +3 -0
  36. package/dist/cjs/packages/ScenePackageBundle.js +76 -0
  37. package/dist/cjs/packages/ScenePackageBundle.js.map +1 -0
  38. package/dist/cjs/renderer/UnresolvedComponent.js +28 -0
  39. package/dist/cjs/renderer/UnresolvedComponent.js.map +1 -0
  40. package/dist/cjs/renderer/createReactRenderer.js +48 -0
  41. package/dist/cjs/renderer/createReactRenderer.js.map +1 -0
  42. package/dist/cjs/theme/SceneThemeProvider.js +44 -0
  43. package/dist/cjs/theme/SceneThemeProvider.js.map +1 -0
  44. package/dist/cjs/theme/themeTokens.js +52 -0
  45. package/dist/cjs/theme/themeTokens.js.map +1 -0
  46. package/dist/esm/NavBar/NavBar.d.ts +7 -0
  47. package/dist/esm/NavBar/NavBar.d.ts.map +1 -0
  48. package/dist/esm/NavBar/NavBar.js +45 -0
  49. package/dist/esm/NavBar/NavBar.js.map +1 -0
  50. package/dist/esm/NavBar/extractNavigationItem.d.ts +3 -0
  51. package/dist/esm/NavBar/extractNavigationItem.d.ts.map +1 -0
  52. package/dist/esm/NavBar/extractNavigationItem.js +36 -0
  53. package/dist/esm/NavBar/extractNavigationItem.js.map +1 -0
  54. package/dist/esm/NavBar/for_NavBar/when_rendering_navigation_contributions.d.ts +2 -0
  55. package/dist/esm/NavBar/for_NavBar/when_rendering_navigation_contributions.d.ts.map +1 -0
  56. package/dist/esm/NavBar/for_NavBar/when_rendering_navigation_contributions.js +53 -0
  57. package/dist/esm/NavBar/for_NavBar/when_rendering_navigation_contributions.js.map +1 -0
  58. package/dist/esm/NavBar/for_extractNavigationItem/when_extracting_from_a_navigation_contribution.d.ts +2 -0
  59. package/dist/esm/NavBar/for_extractNavigationItem/when_extracting_from_a_navigation_contribution.d.ts.map +1 -0
  60. package/dist/esm/NavBar/for_extractNavigationItem/when_extracting_from_a_navigation_contribution.js +45 -0
  61. package/dist/esm/NavBar/for_extractNavigationItem/when_extracting_from_a_navigation_contribution.js.map +1 -0
  62. package/dist/esm/NavBar/index.d.ts +3 -0
  63. package/dist/esm/NavBar/index.d.ts.map +1 -0
  64. package/dist/esm/NavBar/index.js +3 -0
  65. package/dist/esm/NavBar/index.js.map +1 -0
  66. package/dist/esm/SceneElementView.d.ts +10 -0
  67. package/dist/esm/SceneElementView.d.ts.map +1 -0
  68. package/dist/esm/SceneElementView.js +19 -0
  69. package/dist/esm/SceneElementView.js.map +1 -0
  70. package/dist/esm/SceneElementView.stories.d.ts +15 -0
  71. package/dist/esm/SceneElementView.stories.d.ts.map +1 -0
  72. package/dist/esm/SceneElementView.stories.js +54 -0
  73. package/dist/esm/SceneElementView.stories.js.map +1 -0
  74. package/dist/esm/core/CoreButton.d.ts +3 -0
  75. package/dist/esm/core/CoreButton.d.ts.map +1 -0
  76. package/dist/esm/core/CoreButton.js +20 -0
  77. package/dist/esm/core/CoreButton.js.map +1 -0
  78. package/dist/esm/core/CoreCard.d.ts +3 -0
  79. package/dist/esm/core/CoreCard.d.ts.map +1 -0
  80. package/dist/esm/core/CoreCard.js +20 -0
  81. package/dist/esm/core/CoreCard.js.map +1 -0
  82. package/dist/esm/core/CoreText.d.ts +3 -0
  83. package/dist/esm/core/CoreText.d.ts.map +1 -0
  84. package/dist/esm/core/CoreText.js +17 -0
  85. package/dist/esm/core/CoreText.js.map +1 -0
  86. package/dist/esm/core/coreComponents.d.ts +3 -0
  87. package/dist/esm/core/coreComponents.d.ts.map +1 -0
  88. package/dist/esm/core/coreComponents.js +18 -0
  89. package/dist/esm/core/coreComponents.js.map +1 -0
  90. package/dist/esm/core/corePackage.d.ts +5 -0
  91. package/dist/esm/core/corePackage.d.ts.map +1 -0
  92. package/dist/esm/core/corePackage.js +38 -0
  93. package/dist/esm/core/corePackage.js.map +1 -0
  94. package/dist/esm/core/index.d.ts +6 -0
  95. package/dist/esm/core/index.d.ts.map +1 -0
  96. package/dist/esm/core/index.js +6 -0
  97. package/dist/esm/core/index.js.map +1 -0
  98. package/dist/esm/for_SceneElementView/when_rendering_a_tree.d.ts +2 -0
  99. package/dist/esm/for_SceneElementView/when_rendering_a_tree.d.ts.map +1 -0
  100. package/dist/esm/for_SceneElementView/when_rendering_a_tree.js +44 -0
  101. package/dist/esm/for_SceneElementView/when_rendering_a_tree.js.map +1 -0
  102. package/dist/esm/for_applyThemeTokens/when_switching_themes.d.ts +2 -0
  103. package/dist/esm/for_applyThemeTokens/when_switching_themes.d.ts.map +1 -0
  104. package/dist/esm/for_applyThemeTokens/when_switching_themes.js +59 -0
  105. package/dist/esm/for_applyThemeTokens/when_switching_themes.js.map +1 -0
  106. package/dist/esm/for_themeTokens/when_converting_a_token_name.d.ts +2 -0
  107. package/dist/esm/for_themeTokens/when_converting_a_token_name.d.ts.map +1 -0
  108. package/dist/esm/for_themeTokens/when_converting_a_token_name.js +16 -0
  109. package/dist/esm/for_themeTokens/when_converting_a_token_name.js.map +1 -0
  110. package/dist/esm/for_validatePackageBundle/when_the_bundle_and_manifest_disagree.d.ts +2 -0
  111. package/dist/esm/for_validatePackageBundle/when_the_bundle_and_manifest_disagree.d.ts.map +1 -0
  112. package/dist/esm/for_validatePackageBundle/when_the_bundle_and_manifest_disagree.js +59 -0
  113. package/dist/esm/for_validatePackageBundle/when_the_bundle_and_manifest_disagree.js.map +1 -0
  114. package/dist/esm/for_validatePackageBundle/when_the_bundle_matches_its_manifest.d.ts +2 -0
  115. package/dist/esm/for_validatePackageBundle/when_the_bundle_matches_its_manifest.d.ts.map +1 -0
  116. package/dist/esm/for_validatePackageBundle/when_the_bundle_matches_its_manifest.js +8 -0
  117. package/dist/esm/for_validatePackageBundle/when_the_bundle_matches_its_manifest.js.map +1 -0
  118. package/dist/esm/index.d.ts +7 -0
  119. package/dist/esm/index.d.ts.map +1 -0
  120. package/dist/esm/index.js +14 -0
  121. package/dist/esm/index.js.map +1 -0
  122. package/dist/esm/package.json +3 -0
  123. package/dist/esm/packages/ScenePackageBundle.d.ts +15 -0
  124. package/dist/esm/packages/ScenePackageBundle.d.ts.map +1 -0
  125. package/dist/esm/packages/ScenePackageBundle.js +72 -0
  126. package/dist/esm/packages/ScenePackageBundle.js.map +1 -0
  127. package/dist/esm/packages/index.d.ts +2 -0
  128. package/dist/esm/packages/index.d.ts.map +1 -0
  129. package/dist/esm/packages/index.js +2 -0
  130. package/dist/esm/packages/index.js.map +1 -0
  131. package/dist/esm/renderer/ComponentRegistry.d.ts +8 -0
  132. package/dist/esm/renderer/ComponentRegistry.d.ts.map +1 -0
  133. package/dist/esm/renderer/ComponentRegistry.js +2 -0
  134. package/dist/esm/renderer/ComponentRegistry.js.map +1 -0
  135. package/dist/esm/renderer/UnresolvedComponent.d.ts +3 -0
  136. package/dist/esm/renderer/UnresolvedComponent.d.ts.map +1 -0
  137. package/dist/esm/renderer/UnresolvedComponent.js +26 -0
  138. package/dist/esm/renderer/UnresolvedComponent.js.map +1 -0
  139. package/dist/esm/renderer/createReactRenderer.d.ts +5 -0
  140. package/dist/esm/renderer/createReactRenderer.d.ts.map +1 -0
  141. package/dist/esm/renderer/createReactRenderer.js +46 -0
  142. package/dist/esm/renderer/createReactRenderer.js.map +1 -0
  143. package/dist/esm/renderer/index.d.ts +4 -0
  144. package/dist/esm/renderer/index.d.ts.map +1 -0
  145. package/dist/esm/renderer/index.js +4 -0
  146. package/dist/esm/renderer/index.js.map +1 -0
  147. package/dist/esm/theme/SceneThemeProvider.d.ts +10 -0
  148. package/dist/esm/theme/SceneThemeProvider.d.ts.map +1 -0
  149. package/dist/esm/theme/SceneThemeProvider.js +41 -0
  150. package/dist/esm/theme/SceneThemeProvider.js.map +1 -0
  151. package/dist/esm/theme/index.d.ts +3 -0
  152. package/dist/esm/theme/index.d.ts.map +1 -0
  153. package/dist/esm/theme/index.js +3 -0
  154. package/dist/esm/theme/index.js.map +1 -0
  155. package/dist/esm/theme/themeTokens.d.ts +5 -0
  156. package/dist/esm/theme/themeTokens.d.ts.map +1 -0
  157. package/dist/esm/theme/themeTokens.js +48 -0
  158. package/dist/esm/theme/themeTokens.js.map +1 -0
  159. package/dist/esm/tsconfig.tsbuildinfo +1 -0
  160. package/for_SceneElementView/when_rendering_a_tree.tsx +53 -0
  161. package/for_applyThemeTokens/when_switching_themes.ts +74 -0
  162. package/for_themeTokens/when_converting_a_token_name.ts +22 -0
  163. package/for_validatePackageBundle/when_the_bundle_and_manifest_disagree.ts +72 -0
  164. package/for_validatePackageBundle/when_the_bundle_matches_its_manifest.ts +12 -0
  165. package/index.ts +9 -0
  166. package/package.json +60 -0
  167. package/packages/ScenePackageBundle.ts +137 -0
  168. package/packages/index.ts +4 -0
  169. package/renderer/ComponentRegistry.ts +23 -0
  170. package/renderer/UnresolvedComponent.tsx +20 -0
  171. package/renderer/createReactRenderer.tsx +35 -0
  172. package/renderer/index.ts +6 -0
  173. package/theme/SceneThemeProvider.tsx +58 -0
  174. package/theme/index.ts +5 -0
  175. package/theme/themeTokens.ts +59 -0
@@ -0,0 +1,22 @@
1
+ 'use strict';
2
+
3
+ var jsxRuntime = require('react/jsx-runtime');
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
+ /**
8
+ * The `core:button` component - part of the minimum vocabulary a `ui profile` can always fall back to.
9
+ */ function CoreButton({ element, slots }) {
10
+ const label = typeof element.properties.label === 'string' ? element.properties.label : '';
11
+ return /*#__PURE__*/ jsxRuntime.jsxs("button", {
12
+ type: "button",
13
+ "data-scene-id": element.id,
14
+ children: [
15
+ label,
16
+ slots.content
17
+ ]
18
+ });
19
+ }
20
+
21
+ exports.CoreButton = CoreButton;
22
+ //# sourceMappingURL=CoreButton.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"CoreButton.js","sources":["../../../core/CoreButton.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 { RegisteredComponentProps } from '../renderer';\n\n/**\n * The `core:button` component - part of the minimum vocabulary a `ui profile` can always fall back to.\n */\nexport function CoreButton({ element, slots }: RegisteredComponentProps) {\n const label = typeof element.properties.label === 'string' ? element.properties.label : '';\n return (\n <button type=\"button\" data-scene-id={element.id}>\n {label}\n {slots.content}\n </button>\n );\n}\n"],"names":["CoreButton","element","slots","label","properties","_jsxs","button","type","data-scene-id","id","content"],"mappings":";;;;AAAA;AACA;AAIA;;AAEC,IACM,SAASA,UAAAA,CAAW,EAAEC,OAAO,EAAEC,KAAK,EAA4B,EAAA;AACnE,IAAA,MAAMC,KAAAA,GAAQ,OAAOF,OAAAA,CAAQG,UAAU,CAACD,KAAK,KAAK,QAAA,GAAWF,OAAAA,CAAQG,UAAU,CAACD,KAAK,GAAG,EAAA;AACxF,IAAA,qBACIE,eAAA,CAACC,QAAAA,EAAAA;QAAOC,IAAAA,EAAK,QAAA;AAASC,QAAAA,eAAAA,EAAeP,QAAQQ,EAAE;;AAC1CN,YAAAA,KAAAA;AACAD,YAAAA,KAAAA,CAAMQ;;;AAGnB;;;;"}
@@ -0,0 +1,22 @@
1
+ 'use strict';
2
+
3
+ var jsxRuntime = require('react/jsx-runtime');
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
+ /**
8
+ * The `core:card` component - part of the minimum vocabulary a `ui profile` can always fall back to.
9
+ */ function CoreCard({ element, slots }) {
10
+ return /*#__PURE__*/ jsxRuntime.jsx("section", {
11
+ "data-scene-id": element.id,
12
+ style: {
13
+ border: '1px solid #ccc',
14
+ borderRadius: 4,
15
+ padding: '0.75rem'
16
+ },
17
+ children: slots.content
18
+ });
19
+ }
20
+
21
+ exports.CoreCard = CoreCard;
22
+ //# sourceMappingURL=CoreCard.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"CoreCard.js","sources":["../../../core/CoreCard.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 { RegisteredComponentProps } from '../renderer';\n\n/**\n * The `core:card` component - part of the minimum vocabulary a `ui profile` can always fall back to.\n */\nexport function CoreCard({ element, slots }: RegisteredComponentProps) {\n return (\n <section data-scene-id={element.id} style={{ border: '1px solid #ccc', borderRadius: 4, padding: '0.75rem' }}>\n {slots.content}\n </section>\n );\n}\n"],"names":["CoreCard","element","slots","_jsx","section","data-scene-id","id","style","border","borderRadius","padding","content"],"mappings":";;;;AAAA;AACA;AAIA;;AAEC,IACM,SAASA,QAAAA,CAAS,EAAEC,OAAO,EAAEC,KAAK,EAA4B,EAAA;AACjE,IAAA,qBACIC,cAAA,CAACC,SAAAA,EAAAA;AAAQC,QAAAA,eAAAA,EAAeJ,QAAQK,EAAE;QAAEC,KAAAA,EAAO;YAAEC,MAAAA,EAAQ,gBAAA;YAAkBC,YAAAA,EAAc,CAAA;YAAGC,OAAAA,EAAS;AAAU,SAAA;AACtGR,QAAAA,QAAAA,EAAAA,KAAAA,CAAMS;;AAGnB;;;;"}
@@ -0,0 +1,19 @@
1
+ 'use strict';
2
+
3
+ var jsxRuntime = require('react/jsx-runtime');
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
+ /**
8
+ * The `core:text` component - the minimum vocabulary a `ui profile` can always fall back to, regardless
9
+ * of which packages it lists, per Scene#3's `core` fallback guarantee.
10
+ */ function CoreText({ element }) {
11
+ const text = typeof element.properties.text === 'string' ? element.properties.text : '';
12
+ return /*#__PURE__*/ jsxRuntime.jsx("span", {
13
+ "data-scene-id": element.id,
14
+ children: text
15
+ });
16
+ }
17
+
18
+ exports.CoreText = CoreText;
19
+ //# sourceMappingURL=CoreText.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"CoreText.js","sources":["../../../core/CoreText.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 { RegisteredComponentProps } from '../renderer';\n\n/**\n * The `core:text` component - the minimum vocabulary a `ui profile` can always fall back to, regardless\n * of which packages it lists, per Scene#3's `core` fallback guarantee.\n */\nexport function CoreText({ element }: RegisteredComponentProps) {\n const text = typeof element.properties.text === 'string' ? element.properties.text : '';\n return <span data-scene-id={element.id}>{text}</span>;\n}\n"],"names":["CoreText","element","text","properties","_jsx","span","data-scene-id","id"],"mappings":";;;;AAAA;AACA;AAIA;;;AAGC,IACM,SAASA,QAAAA,CAAS,EAAEC,OAAO,EAA4B,EAAA;AAC1D,IAAA,MAAMC,IAAAA,GAAO,OAAOD,OAAAA,CAAQE,UAAU,CAACD,IAAI,KAAK,QAAA,GAAWD,OAAAA,CAAQE,UAAU,CAACD,IAAI,GAAG,EAAA;AACrF,IAAA,qBAAOE,cAAA,CAACC,MAAAA,EAAAA;AAAKC,QAAAA,eAAAA,EAAeL,QAAQM,EAAE;AAAGL,QAAAA,QAAAA,EAAAA;;AAC7C;;;;"}
@@ -0,0 +1,20 @@
1
+ 'use strict';
2
+
3
+ var ScenePackageBundle = require('../packages/ScenePackageBundle.js');
4
+ var CoreText = require('./CoreText.js');
5
+ var CoreButton = require('./CoreButton.js');
6
+ var CoreCard = require('./CoreCard.js');
7
+
8
+ // Copyright (c) Cratis. All rights reserved.
9
+ // Licensed under the MIT license. See LICENSE file in the project root for full license information.
10
+ /**
11
+ * The `core` package's component registry - the final fallback every `ui profile` resolves against
12
+ * regardless of which other packages it lists (Scene#3).
13
+ */ const coreComponents = {
14
+ [ScenePackageBundle.componentRegistryKey('core', 'text')]: CoreText.CoreText,
15
+ [ScenePackageBundle.componentRegistryKey('core', 'button')]: CoreButton.CoreButton,
16
+ [ScenePackageBundle.componentRegistryKey('core', 'card')]: CoreCard.CoreCard
17
+ };
18
+
19
+ exports.coreComponents = coreComponents;
20
+ //# sourceMappingURL=coreComponents.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"coreComponents.js","sources":["../../../core/coreComponents.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 { ComponentRegistry } from '../renderer';\nimport { componentRegistryKey } from '../packages';\nimport { CoreText } from './CoreText';\nimport { CoreButton } from './CoreButton';\nimport { CoreCard } from './CoreCard';\n\n/**\n * The `core` package's component registry - the final fallback every `ui profile` resolves against\n * regardless of which other packages it lists (Scene#3).\n */\nexport const coreComponents: ComponentRegistry = {\n [componentRegistryKey('core', 'text')]: CoreText,\n [componentRegistryKey('core', 'button')]: CoreButton,\n [componentRegistryKey('core', 'card')]: CoreCard,\n};\n"],"names":["coreComponents","componentRegistryKey","CoreText","CoreButton","CoreCard"],"mappings":";;;;;;;AAAA;AACA;AAQA;;;UAIaA,cAAAA,GAAoC;IAC7C,CAACC,uCAAAA,CAAqB,MAAA,EAAQ,MAAA,CAAA,GAAUC,iBAAAA;IACxC,CAACD,uCAAAA,CAAqB,MAAA,EAAQ,QAAA,CAAA,GAAYE,qBAAAA;IAC1C,CAACF,uCAAAA,CAAqB,MAAA,EAAQ,MAAA,CAAA,GAAUG;AAC5C;;;;"}
@@ -0,0 +1,41 @@
1
+ 'use strict';
2
+
3
+ var scene_model = require('@cratis/scene.model');
4
+ var coreComponents = require('./coreComponents.js');
5
+
6
+ // Copyright (c) Cratis. All rights reserved.
7
+ // Licensed under the MIT license. See LICENSE file in the project root for full license information.
8
+ /**
9
+ * The `core` package's declaration. Every other package is loaded by a host that reads its manifest;
10
+ * `core` ships inside the renderer itself, because Scene#3 guarantees a bare name always has somewhere to
11
+ * resolve regardless of which packages a profile lists. It is still declared the same way as any other -
12
+ * a package picker should be able to show it, and the dependency resolver should be able to reason about
13
+ * it, without a special case.
14
+ */ const corePackageManifest = {
15
+ name: 'core',
16
+ version: '1.0.0',
17
+ kind: scene_model.PackageKind.ComponentLibrary,
18
+ dependencies: [],
19
+ components: [
20
+ 'text',
21
+ 'button',
22
+ 'card'
23
+ ],
24
+ layouts: [],
25
+ screenTemplates: [],
26
+ dialogTemplates: [],
27
+ themes: [],
28
+ displayName: 'Core',
29
+ description: 'The built-in fallback vocabulary every ui profile resolves against.',
30
+ module: '@cratis/scene.react'
31
+ };
32
+ /**
33
+ * The `core` package as a loadable bundle.
34
+ */ const corePackage = {
35
+ manifest: corePackageManifest,
36
+ components: coreComponents.coreComponents
37
+ };
38
+
39
+ exports.corePackage = corePackage;
40
+ exports.corePackageManifest = corePackageManifest;
41
+ //# sourceMappingURL=corePackage.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"corePackage.js","sources":["../../../core/corePackage.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 { PackageKind, ScenePackage } from '@cratis/scene.model';\nimport { ScenePackageBundle } from '../packages';\nimport { coreComponents } from './coreComponents';\n\n/**\n * The `core` package's declaration. Every other package is loaded by a host that reads its manifest;\n * `core` ships inside the renderer itself, because Scene#3 guarantees a bare name always has somewhere to\n * resolve regardless of which packages a profile lists. It is still declared the same way as any other -\n * a package picker should be able to show it, and the dependency resolver should be able to reason about\n * it, without a special case.\n */\nexport const corePackageManifest: ScenePackage = {\n name: 'core',\n version: '1.0.0',\n kind: PackageKind.ComponentLibrary,\n dependencies: [],\n components: ['text', 'button', 'card'],\n layouts: [],\n screenTemplates: [],\n dialogTemplates: [],\n themes: [],\n displayName: 'Core',\n description: 'The built-in fallback vocabulary every ui profile resolves against.',\n module: '@cratis/scene.react',\n};\n\n/**\n * The `core` package as a loadable bundle.\n */\nexport const corePackage: ScenePackageBundle = {\n manifest: corePackageManifest,\n components: coreComponents,\n};\n"],"names":["corePackageManifest","name","version","kind","PackageKind","ComponentLibrary","dependencies","components","layouts","screenTemplates","dialogTemplates","themes","displayName","description","module","corePackage","manifest","coreComponents"],"mappings":";;;;;AAAA;AACA;AAMA;;;;;;UAOaA,mBAAAA,GAAoC;IAC7CC,IAAAA,EAAM,MAAA;IACNC,OAAAA,EAAS,OAAA;AACTC,IAAAA,IAAAA,EAAMC,wBAAYC,gBAAgB;AAClCC,IAAAA,YAAAA,EAAc,EAAE;IAChBC,UAAAA,EAAY;AAAC,QAAA,MAAA;AAAQ,QAAA,QAAA;AAAU,QAAA;AAAO,KAAA;AACtCC,IAAAA,OAAAA,EAAS,EAAE;AACXC,IAAAA,eAAAA,EAAiB,EAAE;AACnBC,IAAAA,eAAAA,EAAiB,EAAE;AACnBC,IAAAA,MAAAA,EAAQ,EAAE;IACVC,WAAAA,EAAa,MAAA;IACbC,WAAAA,EAAa,qEAAA;IACbC,MAAAA,EAAQ;AACZ;AAEA;;UAGaC,WAAAA,GAAkC;IAC3CC,QAAAA,EAAUhB,mBAAAA;IACVO,UAAAA,EAAYU;AAChB;;;;;"}
@@ -0,0 +1,38 @@
1
+ 'use strict';
2
+
3
+ var SceneElementView = require('./SceneElementView.js');
4
+ var UnresolvedComponent = require('./renderer/UnresolvedComponent.js');
5
+ var createReactRenderer = require('./renderer/createReactRenderer.js');
6
+ var CoreText = require('./core/CoreText.js');
7
+ var CoreButton = require('./core/CoreButton.js');
8
+ var CoreCard = require('./core/CoreCard.js');
9
+ var coreComponents = require('./core/coreComponents.js');
10
+ var corePackage = require('./core/corePackage.js');
11
+ var NavBar = require('./NavBar/NavBar.js');
12
+ var extractNavigationItem = require('./NavBar/extractNavigationItem.js');
13
+ var ScenePackageBundle = require('./packages/ScenePackageBundle.js');
14
+ var themeTokens = require('./theme/themeTokens.js');
15
+ var SceneThemeProvider = require('./theme/SceneThemeProvider.js');
16
+
17
+
18
+
19
+ exports.SceneElementView = SceneElementView.SceneElementView;
20
+ exports.UnresolvedComponent = UnresolvedComponent.UnresolvedComponent;
21
+ exports.createReactRenderer = createReactRenderer.createReactRenderer;
22
+ exports.CoreText = CoreText.CoreText;
23
+ exports.CoreButton = CoreButton.CoreButton;
24
+ exports.CoreCard = CoreCard.CoreCard;
25
+ exports.coreComponents = coreComponents.coreComponents;
26
+ exports.corePackage = corePackage.corePackage;
27
+ exports.corePackageManifest = corePackage.corePackageManifest;
28
+ exports.NavBar = NavBar.NavBar;
29
+ exports.extractNavigationItem = extractNavigationItem.extractNavigationItem;
30
+ exports.componentRegistryKey = ScenePackageBundle.componentRegistryKey;
31
+ exports.mergePackageRegistries = ScenePackageBundle.mergePackageRegistries;
32
+ exports.validatePackageBundle = ScenePackageBundle.validatePackageBundle;
33
+ exports.applyThemeTokens = themeTokens.applyThemeTokens;
34
+ exports.themeTokenPrefix = themeTokens.themeTokenPrefix;
35
+ exports.themeTokenProperty = themeTokens.themeTokenProperty;
36
+ exports.SceneThemeProvider = SceneThemeProvider.SceneThemeProvider;
37
+ exports.useSceneTheme = SceneThemeProvider.useSceneTheme;
38
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
@@ -0,0 +1,3 @@
1
+ {
2
+ "type": "commonjs"
3
+ }
@@ -0,0 +1,76 @@
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 key a component is registered and looked up under: the package that provides it, then the bare name
7
+ * a screen refers to it by.
8
+ *
9
+ * A screen writes a bare name (`button`) or a package-qualified one (`PrimeReact.button`);
10
+ * `resolveComponentName` turns either into a `{ name, package }` pair, and this turns that pair into the
11
+ * registry key. Nothing should build this string by hand — the separator is an implementation detail of
12
+ * the registry, deliberately not the `.` used for qualification in a screen, so a package name containing
13
+ * dots stays unambiguous.
14
+ */ function componentRegistryKey(packageName, componentName) {
15
+ return `${packageName}:${componentName}`;
16
+ }
17
+ /**
18
+ * Checks that a bundle provides everything its manifest declares, and declares everything it provides.
19
+ *
20
+ * A manifest that promises a component the bundle does not register renders as `UnresolvedComponent` at
21
+ * runtime — a blank box, far from where the mistake was made. A component registered but not declared is
22
+ * invisible to `resolveComponentName`, so a screen can never name it. Both are silent failures, which is
23
+ * why every package's specs run this.
24
+ */ function validatePackageBundle(bundle) {
25
+ const problems = [];
26
+ const { manifest } = bundle;
27
+ for (const name of manifest.components){
28
+ if (!(componentRegistryKey(manifest.name, name) in bundle.components)) {
29
+ problems.push(`declares the component '${name}' but registers no implementation for it`);
30
+ }
31
+ }
32
+ const declared = new Set(manifest.components.map((name)=>componentRegistryKey(manifest.name, name)));
33
+ for (const key of Object.keys(bundle.components)){
34
+ if (!declared.has(key)) {
35
+ problems.push(`registers '${key}', which the manifest does not declare`);
36
+ }
37
+ }
38
+ const providedLayouts = new Set((bundle.layouts ?? []).map((layout)=>layout.name));
39
+ for (const name of manifest.layouts){
40
+ if (!providedLayouts.has(name)) {
41
+ problems.push(`declares the layout '${name}' but provides no definition for it`);
42
+ }
43
+ }
44
+ const providedScreenTemplates = new Set((bundle.screenTemplates ?? []).map((template)=>template.name));
45
+ for (const name of manifest.screenTemplates){
46
+ if (!providedScreenTemplates.has(name)) {
47
+ problems.push(`declares the screen template '${name}' but provides no definition for it`);
48
+ }
49
+ }
50
+ const providedDialogTemplates = new Set((bundle.dialogTemplates ?? []).map((template)=>template.name));
51
+ for (const name of manifest.dialogTemplates){
52
+ if (!providedDialogTemplates.has(name)) {
53
+ problems.push(`declares the dialog template '${name}' but provides no definition for it`);
54
+ }
55
+ }
56
+ const providedThemes = new Set((bundle.themes ?? []).map((theme)=>theme.name));
57
+ for (const name of manifest.themes){
58
+ if (!providedThemes.has(name)) {
59
+ problems.push(`declares the theme '${name}' but provides no definition for it`);
60
+ }
61
+ }
62
+ return problems;
63
+ }
64
+ /**
65
+ * Merges the component registries of several bundles into the single registry a renderer consumes.
66
+ *
67
+ * Keys carry their package name, so nothing collides and merge order does not matter — which package wins
68
+ * a *bare* name is decided earlier, by `resolveComponentName` walking the profile's priority order.
69
+ */ function mergePackageRegistries(bundles) {
70
+ return Object.assign({}, ...bundles.map((bundle)=>bundle.components));
71
+ }
72
+
73
+ exports.componentRegistryKey = componentRegistryKey;
74
+ exports.mergePackageRegistries = mergePackageRegistries;
75
+ exports.validatePackageBundle = validatePackageBundle;
76
+ //# sourceMappingURL=ScenePackageBundle.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ScenePackageBundle.js","sources":["../../../packages/ScenePackageBundle.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 { DialogTemplate, Layout, ScenePackage, Screen, ScreenTemplate, Theme } from '@cratis/scene.model';\nimport { ComponentRegistry } from '../renderer';\n\n/**\n * What a package actually ships to a React renderer, as opposed to what it *declares*.\n *\n * `ScenePackage` is the declaration — a name, a kind, dependencies, and the names of what it\n * contributes. It is deliberately platform-agnostic and lives in `Scene.Model`, because Stage's build and\n * Studio's design-time queries both read it without ever loading a component. A bundle is the other half:\n * the real React components, layouts, screens and themes behind those names, which only a renderer needs.\n *\n * A package publishes exactly one bundle, as a named export following its own name —\n * `primeReactPackage`, `cratisComponentsPackage`, `corePackage`. A host loads it from the module the\n * declaration's `ScenePackage.module` names.\n */\nexport interface ScenePackageBundle {\n /**\n * The package's own declaration. Its `components`, `layouts` and `themes` name lists must agree with\n * what this bundle actually provides — {@link validatePackageBundle} is what proves they do.\n */\n manifest: ScenePackage;\n\n /**\n * The components this package provides, keyed by {@link componentRegistryKey}.\n */\n components: ComponentRegistry;\n\n /**\n * The application shells this package provides, if any. Only a blueprint has these.\n */\n layouts?: Layout[];\n\n /**\n * The screen templates this package provides — the shapes that go inside a layout, each declaring\n * which of its parent's slots it fills.\n */\n screenTemplates?: ScreenTemplate[];\n\n /**\n * The dialog templates this package provides.\n */\n dialogTemplates?: DialogTemplate[];\n\n /**\n * Sample screens this package ships — a layout package's gallery, so a preview has real content to\n * put through the real engine rather than a mockup.\n */\n screens?: Screen[];\n\n /**\n * The themes this package ships, if any.\n */\n themes?: Theme[];\n}\n\n/**\n * The key a component is registered and looked up under: the package that provides it, then the bare name\n * a screen refers to it by.\n *\n * A screen writes a bare name (`button`) or a package-qualified one (`PrimeReact.button`);\n * `resolveComponentName` turns either into a `{ name, package }` pair, and this turns that pair into the\n * registry key. Nothing should build this string by hand — the separator is an implementation detail of\n * the registry, deliberately not the `.` used for qualification in a screen, so a package name containing\n * dots stays unambiguous.\n */\nexport function componentRegistryKey(packageName: string, componentName: string): string {\n return `${packageName}:${componentName}`;\n}\n\n/**\n * Checks that a bundle provides everything its manifest declares, and declares everything it provides.\n *\n * A manifest that promises a component the bundle does not register renders as `UnresolvedComponent` at\n * runtime — a blank box, far from where the mistake was made. A component registered but not declared is\n * invisible to `resolveComponentName`, so a screen can never name it. Both are silent failures, which is\n * why every package's specs run this.\n */\nexport function validatePackageBundle(bundle: ScenePackageBundle): string[] {\n const problems: string[] = [];\n const { manifest } = bundle;\n\n for (const name of manifest.components) {\n if (!(componentRegistryKey(manifest.name, name) in bundle.components)) {\n problems.push(`declares the component '${name}' but registers no implementation for it`);\n }\n }\n\n const declared = new Set(manifest.components.map((name) => componentRegistryKey(manifest.name, name)));\n for (const key of Object.keys(bundle.components)) {\n if (!declared.has(key)) {\n problems.push(`registers '${key}', which the manifest does not declare`);\n }\n }\n\n const providedLayouts = new Set((bundle.layouts ?? []).map((layout) => layout.name));\n for (const name of manifest.layouts) {\n if (!providedLayouts.has(name)) {\n problems.push(`declares the layout '${name}' but provides no definition for it`);\n }\n }\n\n const providedScreenTemplates = new Set((bundle.screenTemplates ?? []).map((template) => template.name));\n for (const name of manifest.screenTemplates) {\n if (!providedScreenTemplates.has(name)) {\n problems.push(`declares the screen template '${name}' but provides no definition for it`);\n }\n }\n\n const providedDialogTemplates = new Set((bundle.dialogTemplates ?? []).map((template) => template.name));\n for (const name of manifest.dialogTemplates) {\n if (!providedDialogTemplates.has(name)) {\n problems.push(`declares the dialog template '${name}' but provides no definition for it`);\n }\n }\n\n const providedThemes = new Set((bundle.themes ?? []).map((theme) => theme.name));\n for (const name of manifest.themes) {\n if (!providedThemes.has(name)) {\n problems.push(`declares the theme '${name}' but provides no definition for it`);\n }\n }\n\n return problems;\n}\n\n/**\n * Merges the component registries of several bundles into the single registry a renderer consumes.\n *\n * Keys carry their package name, so nothing collides and merge order does not matter — which package wins\n * a *bare* name is decided earlier, by `resolveComponentName` walking the profile's priority order.\n */\nexport function mergePackageRegistries(bundles: ScenePackageBundle[]): ComponentRegistry {\n return Object.assign({}, ...bundles.map((bundle) => bundle.components)) as ComponentRegistry;\n}\n"],"names":["componentRegistryKey","packageName","componentName","validatePackageBundle","bundle","problems","manifest","name","components","push","declared","Set","map","key","Object","keys","has","providedLayouts","layouts","layout","providedScreenTemplates","screenTemplates","template","providedDialogTemplates","dialogTemplates","providedThemes","themes","theme","mergePackageRegistries","bundles","assign"],"mappings":";;AAAA;AACA;AAyDA;;;;;;;;;AASC,IACM,SAASA,oBAAAA,CAAqBC,WAAmB,EAAEC,aAAqB,EAAA;AAC3E,IAAA,OAAO,CAAA,EAAGD,WAAAA,CAAY,CAAC,EAAEC,aAAAA,CAAAA,CAAe;AAC5C;AAEA;;;;;;;IAQO,SAASC,qBAAAA,CAAsBC,MAA0B,EAAA;AAC5D,IAAA,MAAMC,WAAqB,EAAE;IAC7B,MAAM,EAAEC,QAAQ,EAAE,GAAGF,MAAAA;AAErB,IAAA,KAAK,MAAMG,IAAAA,IAAQD,QAAAA,CAASE,UAAU,CAAE;QACpC,IAAI,EAAER,oBAAAA,CAAqBM,QAAAA,CAASC,IAAI,EAAEA,IAAAA,CAAAA,IAASH,MAAAA,CAAOI,UAAS,CAAA,EAAI;AACnEH,YAAAA,QAAAA,CAASI,IAAI,CAAC,CAAC,wBAAwB,EAAEF,IAAAA,CAAK,wCAAwC,CAAC,CAAA;AAC3F,QAAA;AACJ,IAAA;AAEA,IAAA,MAAMG,QAAAA,GAAW,IAAIC,GAAAA,CAAIL,QAAAA,CAASE,UAAU,CAACI,GAAG,CAAC,CAACL,IAAAA,GAASP,oBAAAA,CAAqBM,QAAAA,CAASC,IAAI,EAAEA,IAAAA,CAAAA,CAAAA,CAAAA;AAC/F,IAAA,KAAK,MAAMM,GAAAA,IAAOC,MAAAA,CAAOC,IAAI,CAACX,MAAAA,CAAOI,UAAU,CAAA,CAAG;AAC9C,QAAA,IAAI,CAACE,QAAAA,CAASM,GAAG,CAACH,GAAAA,CAAAA,EAAM;AACpBR,YAAAA,QAAAA,CAASI,IAAI,CAAC,CAAC,WAAW,EAAEI,GAAAA,CAAI,sCAAsC,CAAC,CAAA;AAC3E,QAAA;AACJ,IAAA;AAEA,IAAA,MAAMI,kBAAkB,IAAIN,GAAAA,CAAI,CAACP,OAAOc,OAAO,IAAI,EAAC,EAAGN,GAAG,CAAC,CAACO,MAAAA,GAAWA,OAAOZ,IAAI,CAAA,CAAA;AAClF,IAAA,KAAK,MAAMA,IAAAA,IAAQD,QAAAA,CAASY,OAAO,CAAE;AACjC,QAAA,IAAI,CAACD,eAAAA,CAAgBD,GAAG,CAACT,IAAAA,CAAAA,EAAO;AAC5BF,YAAAA,QAAAA,CAASI,IAAI,CAAC,CAAC,qBAAqB,EAAEF,IAAAA,CAAK,mCAAmC,CAAC,CAAA;AACnF,QAAA;AACJ,IAAA;AAEA,IAAA,MAAMa,0BAA0B,IAAIT,GAAAA,CAAI,CAACP,OAAOiB,eAAe,IAAI,EAAC,EAAGT,GAAG,CAAC,CAACU,QAAAA,GAAaA,SAASf,IAAI,CAAA,CAAA;AACtG,IAAA,KAAK,MAAMA,IAAAA,IAAQD,QAAAA,CAASe,eAAe,CAAE;AACzC,QAAA,IAAI,CAACD,uBAAAA,CAAwBJ,GAAG,CAACT,IAAAA,CAAAA,EAAO;AACpCF,YAAAA,QAAAA,CAASI,IAAI,CAAC,CAAC,8BAA8B,EAAEF,IAAAA,CAAK,mCAAmC,CAAC,CAAA;AAC5F,QAAA;AACJ,IAAA;AAEA,IAAA,MAAMgB,0BAA0B,IAAIZ,GAAAA,CAAI,CAACP,OAAOoB,eAAe,IAAI,EAAC,EAAGZ,GAAG,CAAC,CAACU,QAAAA,GAAaA,SAASf,IAAI,CAAA,CAAA;AACtG,IAAA,KAAK,MAAMA,IAAAA,IAAQD,QAAAA,CAASkB,eAAe,CAAE;AACzC,QAAA,IAAI,CAACD,uBAAAA,CAAwBP,GAAG,CAACT,IAAAA,CAAAA,EAAO;AACpCF,YAAAA,QAAAA,CAASI,IAAI,CAAC,CAAC,8BAA8B,EAAEF,IAAAA,CAAK,mCAAmC,CAAC,CAAA;AAC5F,QAAA;AACJ,IAAA;AAEA,IAAA,MAAMkB,iBAAiB,IAAId,GAAAA,CAAI,CAACP,OAAOsB,MAAM,IAAI,EAAC,EAAGd,GAAG,CAAC,CAACe,KAAAA,GAAUA,MAAMpB,IAAI,CAAA,CAAA;AAC9E,IAAA,KAAK,MAAMA,IAAAA,IAAQD,QAAAA,CAASoB,MAAM,CAAE;AAChC,QAAA,IAAI,CAACD,cAAAA,CAAeT,GAAG,CAACT,IAAAA,CAAAA,EAAO;AAC3BF,YAAAA,QAAAA,CAASI,IAAI,CAAC,CAAC,oBAAoB,EAAEF,IAAAA,CAAK,mCAAmC,CAAC,CAAA;AAClF,QAAA;AACJ,IAAA;IAEA,OAAOF,QAAAA;AACX;AAEA;;;;;IAMO,SAASuB,sBAAAA,CAAuBC,OAA6B,EAAA;IAChE,OAAOf,MAAAA,CAAOgB,MAAM,CAAC,EAAC,EAAA,GAAMD,OAAAA,CAAQjB,GAAG,CAAC,CAACR,MAAAA,GAAWA,MAAAA,CAAOI,UAAU,CAAA,CAAA;AACzE;;;;;;"}
@@ -0,0 +1,28 @@
1
+ 'use strict';
2
+
3
+ var jsxRuntime = require('react/jsx-runtime');
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
+ /**
8
+ * The fallback rendered for an {@link ExternalComponent} whose `componentName` is not in the active
9
+ * {@link ComponentRegistry} - a visibly broken placeholder, never a silent blank, since a missing
10
+ * component is a real configuration gap the renderer should surface, not hide.
11
+ */ function UnresolvedComponent({ element }) {
12
+ return /*#__PURE__*/ jsxRuntime.jsxs("div", {
13
+ "data-scene-unresolved-component": element.componentName,
14
+ style: {
15
+ border: '1px dashed red',
16
+ color: 'red',
17
+ padding: '0.25rem 0.5rem',
18
+ fontFamily: 'monospace'
19
+ },
20
+ children: [
21
+ "Unresolved component: ",
22
+ element.componentName
23
+ ]
24
+ });
25
+ }
26
+
27
+ exports.UnresolvedComponent = UnresolvedComponent;
28
+ //# sourceMappingURL=UnresolvedComponent.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"UnresolvedComponent.js","sources":["../../../renderer/UnresolvedComponent.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 { RegisteredComponentProps } from './ComponentRegistry';\n\n/**\n * The fallback rendered for an {@link ExternalComponent} whose `componentName` is not in the active\n * {@link ComponentRegistry} - a visibly broken placeholder, never a silent blank, since a missing\n * component is a real configuration gap the renderer should surface, not hide.\n */\nexport function UnresolvedComponent({ element }: RegisteredComponentProps) {\n return (\n <div\n data-scene-unresolved-component={element.componentName}\n style={{ border: '1px dashed red', color: 'red', padding: '0.25rem 0.5rem', fontFamily: 'monospace' }}\n >\n Unresolved component: {element.componentName}\n </div>\n );\n}\n"],"names":["UnresolvedComponent","element","_jsxs","div","data-scene-unresolved-component","componentName","style","border","color","padding","fontFamily"],"mappings":";;;;AAAA;AACA;AAIA;;;;AAIC,IACM,SAASA,mBAAAA,CAAoB,EAAEC,OAAO,EAA4B,EAAA;AACrE,IAAA,qBACIC,eAAA,CAACC,KAAAA,EAAAA;AACGC,QAAAA,iCAAAA,EAAiCH,QAAQI,aAAa;QACtDC,KAAAA,EAAO;YAAEC,MAAAA,EAAQ,gBAAA;YAAkBC,KAAAA,EAAO,KAAA;YAAOC,OAAAA,EAAS,gBAAA;YAAkBC,UAAAA,EAAY;AAAY,SAAA;;AACvG,YAAA,wBAAA;AAC0BT,YAAAA,OAAAA,CAAQI;;;AAG3C;;;;"}
@@ -0,0 +1,48 @@
1
+ 'use strict';
2
+
3
+ var react = require('react');
4
+ var UnresolvedComponent = require('./UnresolvedComponent.js');
5
+
6
+ // Copyright (c) Cratis. All rights reserved.
7
+ // Licensed under the MIT license. See LICENSE file in the project root for full license information.
8
+ /**
9
+ * Creates a {@link Renderer} that turns a Scene element tree into React elements. `Panel`, `ItemsControl`
10
+ * and `ContentControl` render as plain wrapping `div`s here - arranging them according to a layout's
11
+ * `flow`/`freeform` arrangement is Scene#4's job, layered on top of this renderer rather than folded
12
+ * into it.
13
+ */ function createReactRenderer(registry) {
14
+ return {
15
+ renderContentControl (element, content) {
16
+ return /*#__PURE__*/ react.createElement('div', {
17
+ key: element.id,
18
+ 'data-scene-id': element.id,
19
+ 'data-scene-kind': 'ContentControl'
20
+ }, content);
21
+ },
22
+ renderItemsControl (element, items) {
23
+ return /*#__PURE__*/ react.createElement('div', {
24
+ key: element.id,
25
+ 'data-scene-id': element.id,
26
+ 'data-scene-kind': 'ItemsControl'
27
+ }, items);
28
+ },
29
+ renderExternalComponent (element, slots) {
30
+ const Component = registry[element.componentName] ?? UnresolvedComponent.UnresolvedComponent;
31
+ return /*#__PURE__*/ react.createElement(Component, {
32
+ key: element.id,
33
+ element,
34
+ slots
35
+ });
36
+ },
37
+ renderPanel (element, children) {
38
+ return /*#__PURE__*/ react.createElement('div', {
39
+ key: element.id,
40
+ 'data-scene-id': element.id,
41
+ 'data-scene-kind': 'Panel'
42
+ }, children);
43
+ }
44
+ };
45
+ }
46
+
47
+ exports.createReactRenderer = createReactRenderer;
48
+ //# sourceMappingURL=createReactRenderer.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"createReactRenderer.js","sources":["../../../renderer/createReactRenderer.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, createElement } from 'react';\nimport { Renderer } from '@cratis/scene.engine';\nimport { ContentControl, ExternalComponent, ItemsControl, Panel } from '@cratis/scene.model';\nimport { ComponentRegistry } from './ComponentRegistry';\nimport { UnresolvedComponent } from './UnresolvedComponent';\n\n/**\n * Creates a {@link Renderer} that turns a Scene element tree into React elements. `Panel`, `ItemsControl`\n * and `ContentControl` render as plain wrapping `div`s here - arranging them according to a layout's\n * `flow`/`freeform` arrangement is Scene#4's job, layered on top of this renderer rather than folded\n * into it.\n */\nexport function createReactRenderer(registry: ComponentRegistry): Renderer<ReactNode> {\n return {\n renderContentControl(element: ContentControl, content: ReactNode): ReactNode {\n return createElement('div', { key: element.id, 'data-scene-id': element.id, 'data-scene-kind': 'ContentControl' }, content);\n },\n\n renderItemsControl(element: ItemsControl, items: ReactNode[]): ReactNode {\n return createElement('div', { key: element.id, 'data-scene-id': element.id, 'data-scene-kind': 'ItemsControl' }, items);\n },\n\n renderExternalComponent(element: ExternalComponent, slots: Record<string, ReactNode[]>): ReactNode {\n const Component = registry[element.componentName] ?? UnresolvedComponent;\n return createElement(Component, { key: element.id, element, slots });\n },\n\n renderPanel(element: Panel, children: ReactNode[]): ReactNode {\n return createElement('div', { key: element.id, 'data-scene-id': element.id, 'data-scene-kind': 'Panel' }, children);\n },\n };\n}\n"],"names":["createReactRenderer","registry","renderContentControl","element","content","createElement","key","id","renderItemsControl","items","renderExternalComponent","slots","Component","componentName","UnresolvedComponent","renderPanel","children"],"mappings":";;;;;AAAA;AACA;AAQA;;;;;IAMO,SAASA,mBAAAA,CAAoBC,QAA2B,EAAA;IAC3D,OAAO;QACHC,oBAAAA,CAAAA,CAAqBC,OAAuB,EAAEC,OAAkB,EAAA;AAC5D,YAAA,qBAAOC,oBAAc,KAAA,EAAO;AAAEC,gBAAAA,GAAAA,EAAKH,QAAQI,EAAE;AAAE,gBAAA,eAAA,EAAiBJ,QAAQI,EAAE;gBAAE,iBAAA,EAAmB;aAAiB,EAAGH,OAAAA,CAAAA;AACvH,QAAA,CAAA;QAEAI,kBAAAA,CAAAA,CAAmBL,OAAqB,EAAEM,KAAkB,EAAA;AACxD,YAAA,qBAAOJ,oBAAc,KAAA,EAAO;AAAEC,gBAAAA,GAAAA,EAAKH,QAAQI,EAAE;AAAE,gBAAA,eAAA,EAAiBJ,QAAQI,EAAE;gBAAE,iBAAA,EAAmB;aAAe,EAAGE,KAAAA,CAAAA;AACrH,QAAA,CAAA;QAEAC,uBAAAA,CAAAA,CAAwBP,OAA0B,EAAEQ,KAAkC,EAAA;AAClF,YAAA,MAAMC,YAAYX,QAAQ,CAACE,OAAAA,CAAQU,aAAa,CAAC,IAAIC,uCAAAA;AACrD,YAAA,qBAAOT,oBAAcO,SAAAA,EAAW;AAAEN,gBAAAA,GAAAA,EAAKH,QAAQI,EAAE;AAAEJ,gBAAAA,OAAAA;AAASQ,gBAAAA;AAAM,aAAA,CAAA;AACtE,QAAA,CAAA;QAEAI,WAAAA,CAAAA,CAAYZ,OAAc,EAAEa,QAAqB,EAAA;AAC7C,YAAA,qBAAOX,oBAAc,KAAA,EAAO;AAAEC,gBAAAA,GAAAA,EAAKH,QAAQI,EAAE;AAAE,gBAAA,eAAA,EAAiBJ,QAAQI,EAAE;gBAAE,iBAAA,EAAmB;aAAQ,EAAGS,QAAAA,CAAAA;AAC9G,QAAA;AACJ,KAAA;AACJ;;;;"}
@@ -0,0 +1,44 @@
1
+ 'use strict';
2
+
3
+ var jsxRuntime = require('react/jsx-runtime');
4
+ var react = require('react');
5
+ var themeTokens = require('./themeTokens.js');
6
+
7
+ const SceneThemeContext = /*#__PURE__*/ react.createContext(undefined);
8
+ /**
9
+ * The theme currently applied by the nearest {@link SceneThemeProvider}, for a package component that has
10
+ * to make a decision a token cannot express - picking a light or dark logo asset, say.
11
+ */ function useSceneTheme() {
12
+ return react.useContext(SceneThemeContext);
13
+ }
14
+ /**
15
+ * Applies a {@link Theme}'s tokens to a wrapping element and makes the theme available to everything
16
+ * inside it.
17
+ *
18
+ * Theme switching is live re-resolution: the tokens are written onto the same element rather than
19
+ * swapping a stylesheet, so a preview changes theme without a flash and without losing any state below
20
+ * it. That is what lets Studio's gallery switch themes as fast as you can click.
21
+ */ function SceneThemeProvider({ theme, children, className }) {
22
+ const elementRef = react.useRef(null);
23
+ const previousRef = react.useRef(undefined);
24
+ react.useLayoutEffect(()=>{
25
+ if (!elementRef.current) return;
26
+ themeTokens.applyThemeTokens(elementRef.current, theme, previousRef.current);
27
+ previousRef.current = theme;
28
+ }, [
29
+ theme
30
+ ]);
31
+ return /*#__PURE__*/ jsxRuntime.jsx("div", {
32
+ ref: elementRef,
33
+ className: className,
34
+ "data-scene-theme-root": "",
35
+ children: /*#__PURE__*/ jsxRuntime.jsx(SceneThemeContext.Provider, {
36
+ value: theme,
37
+ children: children
38
+ })
39
+ });
40
+ }
41
+
42
+ exports.SceneThemeProvider = SceneThemeProvider;
43
+ exports.useSceneTheme = useSceneTheme;
44
+ //# sourceMappingURL=SceneThemeProvider.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"SceneThemeProvider.js","sources":["../../../theme/SceneThemeProvider.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, useLayoutEffect, useRef } from 'react';\nimport { Theme } from '@cratis/scene.model';\nimport { applyThemeTokens } from './themeTokens';\n\nconst SceneThemeContext = createContext<Theme | undefined>(undefined);\n\n/**\n * The theme currently applied by the nearest {@link SceneThemeProvider}, for a package component that has\n * to make a decision a token cannot express - picking a light or dark logo asset, say.\n */\nexport function useSceneTheme(): Theme | undefined {\n return useContext(SceneThemeContext);\n}\n\nexport interface SceneThemePropsBase {\n /**\n * The theme to apply. Changing it re-resolves in place - no reload, no remount of the subtree.\n */\n theme?: Theme;\n\n /**\n * The content the theme applies to.\n */\n children?: ReactNode;\n\n /**\n * A class name for the element the tokens land on.\n */\n className?: string;\n}\n\n/**\n * Applies a {@link Theme}'s tokens to a wrapping element and makes the theme available to everything\n * inside it.\n *\n * Theme switching is live re-resolution: the tokens are written onto the same element rather than\n * swapping a stylesheet, so a preview changes theme without a flash and without losing any state below\n * it. That is what lets Studio's gallery switch themes as fast as you can click.\n */\nexport function SceneThemeProvider({ theme, children, className }: SceneThemePropsBase) {\n const elementRef = useRef<HTMLDivElement>(null);\n const previousRef = useRef<Theme | undefined>(undefined);\n\n useLayoutEffect(() => {\n if (!elementRef.current) return;\n applyThemeTokens(elementRef.current, theme, previousRef.current);\n previousRef.current = theme;\n }, [theme]);\n\n return (\n <div ref={elementRef} className={className} data-scene-theme-root=''>\n <SceneThemeContext.Provider value={theme}>{children}</SceneThemeContext.Provider>\n </div>\n );\n}\n"],"names":["SceneThemeContext","createContext","undefined","useSceneTheme","useContext","SceneThemeProvider","theme","children","className","elementRef","useRef","previousRef","useLayoutEffect","current","applyThemeTokens","_jsx","div","ref","data-scene-theme-root","Provider","value"],"mappings":";;;;;;AAOA,MAAMA,kCAAoBC,mBAAAA,CAAiCC,SAAAA,CAAAA;AAE3D;;;AAGC,IACM,SAASC,aAAAA,GAAAA;AACZ,IAAA,OAAOC,gBAAAA,CAAWJ,iBAAAA,CAAAA;AACtB;AAmBA;;;;;;;IAQO,SAASK,kBAAAA,CAAmB,EAAEC,KAAK,EAAEC,QAAQ,EAAEC,SAAS,EAAuB,EAAA;AAClF,IAAA,MAAMC,aAAaC,YAAAA,CAAuB,IAAA,CAAA;AAC1C,IAAA,MAAMC,cAAcD,YAAAA,CAA0BR,SAAAA,CAAAA;IAE9CU,qBAAAA,CAAgB,IAAA;QACZ,IAAI,CAACH,UAAAA,CAAWI,OAAO,EAAE;AACzBC,QAAAA,4BAAAA,CAAiBL,UAAAA,CAAWI,OAAO,EAAEP,KAAAA,EAAOK,YAAYE,OAAO,CAAA;AAC/DF,QAAAA,WAAAA,CAAYE,OAAO,GAAGP,KAAAA;IAC1B,CAAA,EAAG;AAACA,QAAAA;AAAM,KAAA,CAAA;AAEV,IAAA,qBACIS,cAAA,CAACC,KAAAA,EAAAA;QAAIC,GAAAA,EAAKR,UAAAA;QAAYD,SAAAA,EAAWA,SAAAA;QAAWU,uBAAAA,EAAsB,EAAA;gCAC9DH,cAAA,CAACf,kBAAkBmB,QAAQ,EAAA;YAACC,KAAAA,EAAOd,KAAAA;AAAQC,YAAAA,QAAAA,EAAAA;;;AAGvD;;;;;"}
@@ -0,0 +1,52 @@
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 prefix every Scene design token gets as a CSS custom property. A package adapts these to whatever
7
+ * its own component library expects — the PrimeReact package maps them onto PrimeReact's variables, the
8
+ * same indirection `@cratis/components` uses for its `--cratis-*` layer — so layout and component CSS
9
+ * never hardcodes one library's variable names.
10
+ */ const themeTokenPrefix = '--scene';
11
+ /**
12
+ * Turns a semantic token name into its CSS custom property name: `primary.color` becomes
13
+ * `--scene-primary-color`, `surface.borderColor` becomes `--scene-surface-border-color`.
14
+ *
15
+ * Token names are semantic and platform-neutral in `Scene.Model` on purpose; this is the one place that
16
+ * decides what they look like in CSS, so a non-DOM renderer can make an entirely different choice.
17
+ */ function themeTokenProperty(token) {
18
+ const kebab = token.split('.').map((part)=>part.replace(/([a-z0-9])([A-Z])/g, '$1-$2').toLowerCase()).join('-');
19
+ return `${themeTokenPrefix}-${kebab}`;
20
+ }
21
+ /**
22
+ * Applies a theme to an element, in place.
23
+ *
24
+ * Every token becomes a custom property on the element, and the element is marked with the theme's name
25
+ * and colour scheme so CSS can key off either. Tokens the previous theme set and this one does not are
26
+ * removed, so switching themes cannot leave a stale value behind.
27
+ *
28
+ * This is deliberately a mutation of an existing element rather than a re-render: switching theme has to
29
+ * be live re-resolution against the running profile, with no reload and no remount, or a gallery preview
30
+ * flickers every time someone tries a different theme.
31
+ */ function applyThemeTokens(element, theme, previous) {
32
+ for (const token of Object.keys(previous?.tokens ?? {})){
33
+ if (!theme?.tokens || !(token in theme.tokens)) {
34
+ element.style.removeProperty(themeTokenProperty(token));
35
+ }
36
+ }
37
+ if (!theme) {
38
+ element.removeAttribute('data-scene-theme');
39
+ element.removeAttribute('data-scene-color-scheme');
40
+ return;
41
+ }
42
+ for (const [token, value] of Object.entries(theme.tokens ?? {})){
43
+ element.style.setProperty(themeTokenProperty(token), value);
44
+ }
45
+ element.setAttribute('data-scene-theme', theme.name);
46
+ element.setAttribute('data-scene-color-scheme', theme.isDark ? 'dark' : 'light');
47
+ }
48
+
49
+ exports.applyThemeTokens = applyThemeTokens;
50
+ exports.themeTokenPrefix = themeTokenPrefix;
51
+ exports.themeTokenProperty = themeTokenProperty;
52
+ //# sourceMappingURL=themeTokens.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"themeTokens.js","sources":["../../../theme/themeTokens.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 { Theme } from '@cratis/scene.model';\n\n/**\n * The prefix every Scene design token gets as a CSS custom property. A package adapts these to whatever\n * its own component library expects — the PrimeReact package maps them onto PrimeReact's variables, the\n * same indirection `@cratis/components` uses for its `--cratis-*` layer — so layout and component CSS\n * never hardcodes one library's variable names.\n */\nexport const themeTokenPrefix = '--scene';\n\n/**\n * Turns a semantic token name into its CSS custom property name: `primary.color` becomes\n * `--scene-primary-color`, `surface.borderColor` becomes `--scene-surface-border-color`.\n *\n * Token names are semantic and platform-neutral in `Scene.Model` on purpose; this is the one place that\n * decides what they look like in CSS, so a non-DOM renderer can make an entirely different choice.\n */\nexport function themeTokenProperty(token: string): string {\n const kebab = token\n .split('.')\n .map((part) => part.replace(/([a-z0-9])([A-Z])/g, '$1-$2').toLowerCase())\n .join('-');\n return `${themeTokenPrefix}-${kebab}`;\n}\n\n/**\n * Applies a theme to an element, in place.\n *\n * Every token becomes a custom property on the element, and the element is marked with the theme's name\n * and colour scheme so CSS can key off either. Tokens the previous theme set and this one does not are\n * removed, so switching themes cannot leave a stale value behind.\n *\n * This is deliberately a mutation of an existing element rather than a re-render: switching theme has to\n * be live re-resolution against the running profile, with no reload and no remount, or a gallery preview\n * flickers every time someone tries a different theme.\n */\nexport function applyThemeTokens(element: HTMLElement, theme: Theme | undefined, previous?: Theme): void {\n for (const token of Object.keys(previous?.tokens ?? {})) {\n if (!theme?.tokens || !(token in theme.tokens)) {\n element.style.removeProperty(themeTokenProperty(token));\n }\n }\n\n if (!theme) {\n element.removeAttribute('data-scene-theme');\n element.removeAttribute('data-scene-color-scheme');\n return;\n }\n\n for (const [token, value] of Object.entries(theme.tokens ?? {})) {\n element.style.setProperty(themeTokenProperty(token), value);\n }\n\n element.setAttribute('data-scene-theme', theme.name);\n element.setAttribute('data-scene-color-scheme', theme.isDark ? 'dark' : 'light');\n}\n"],"names":["themeTokenPrefix","themeTokenProperty","token","kebab","split","map","part","replace","toLowerCase","join","applyThemeTokens","element","theme","previous","Object","keys","tokens","style","removeProperty","removeAttribute","value","entries","setProperty","setAttribute","name","isDark"],"mappings":";;AAAA;AACA;AAIA;;;;;IAMO,MAAMA,gBAAAA,GAAmB;AAEhC;;;;;;IAOO,SAASC,kBAAAA,CAAmBC,KAAa,EAAA;AAC5C,IAAA,MAAMC,QAAQD,KAAAA,CACTE,KAAK,CAAC,GAAA,CAAA,CACNC,GAAG,CAAC,CAACC,IAAAA,GAASA,IAAAA,CAAKC,OAAO,CAAC,oBAAA,EAAsB,SAASC,WAAW,EAAA,CAAA,CACrEC,IAAI,CAAC,GAAA,CAAA;AACV,IAAA,OAAO,CAAA,EAAGT,gBAAAA,CAAiB,CAAC,EAAEG,KAAAA,CAAAA,CAAO;AACzC;AAEA;;;;;;;;;;AAUC,IACM,SAASO,gBAAAA,CAAiBC,OAAoB,EAAEC,KAAwB,EAAEC,QAAgB,EAAA;IAC7F,KAAK,MAAMX,SAASY,MAAAA,CAAOC,IAAI,CAACF,QAAAA,EAAUG,MAAAA,IAAU,EAAC,CAAA,CAAI;QACrD,IAAI,CAACJ,OAAOI,MAAAA,IAAU,EAAEd,KAAAA,IAASU,KAAAA,CAAMI,MAAK,CAAA,EAAI;AAC5CL,YAAAA,OAAAA,CAAQM,KAAK,CAACC,cAAc,CAACjB,kBAAAA,CAAmBC,KAAAA,CAAAA,CAAAA;AACpD,QAAA;AACJ,IAAA;AAEA,IAAA,IAAI,CAACU,KAAAA,EAAO;AACRD,QAAAA,OAAAA,CAAQQ,eAAe,CAAC,kBAAA,CAAA;AACxBR,QAAAA,OAAAA,CAAQQ,eAAe,CAAC,yBAAA,CAAA;AACxB,QAAA;AACJ,IAAA;AAEA,IAAA,KAAK,MAAM,CAACjB,KAAAA,EAAOkB,KAAAA,CAAM,IAAIN,MAAAA,CAAOO,OAAO,CAACT,KAAAA,CAAMI,MAAM,IAAI,EAAC,CAAA,CAAI;AAC7DL,QAAAA,OAAAA,CAAQM,KAAK,CAACK,WAAW,CAACrB,mBAAmBC,KAAAA,CAAAA,EAAQkB,KAAAA,CAAAA;AACzD,IAAA;AAEAT,IAAAA,OAAAA,CAAQY,YAAY,CAAC,kBAAA,EAAoBX,KAAAA,CAAMY,IAAI,CAAA;AACnDb,IAAAA,OAAAA,CAAQY,YAAY,CAAC,yBAAA,EAA2BX,KAAAA,CAAMa,MAAM,GAAG,MAAA,GAAS,OAAA,CAAA;AAC5E;;;;;;"}
@@ -0,0 +1,7 @@
1
+ import { Contribution, NavigationItem } from '@cratis/scene.model';
2
+ export interface NavBarProps {
3
+ contributions: Contribution[];
4
+ renderRoute: (item: NavigationItem) => string;
5
+ }
6
+ export declare function NavBar({ contributions, renderRoute }: NavBarProps): import("react").JSX.Element;
7
+ //# sourceMappingURL=NavBar.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"NavBar.d.ts","sourceRoot":"","sources":["../../../NavBar/NavBar.tsx"],"names":[],"mappings":"AAGA,OAAO,EAAE,YAAY,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAInE,MAAM,WAAW,WAAW;IAExB,aAAa,EAAE,YAAY,EAAE,CAAC;IAO9B,WAAW,EAAE,CAAC,IAAI,EAAE,cAAc,KAAK,MAAM,CAAC;CACjD;AAOD,wBAAgB,MAAM,CAAC,EAAE,aAAa,EAAE,WAAW,EAAE,EAAE,WAAW,+BAwBjE"}
@@ -0,0 +1,45 @@
1
+ import { jsx } from 'react/jsx-runtime';
2
+ import { aggregateContributions } from '@cratis/scene.engine';
3
+ import { extractNavigationItem } from './extractNavigationItem.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
+ /**
8
+ * Renders the aggregated `Navigation` contributions from across the current element tree - part of
9
+ * Cratis/Scene#2. `NavBar` is not wired to a fixed source: pass it whatever contributions are currently
10
+ * in scope and it recomputes, the same way any contribution-point consumer does.
11
+ */ function NavBar({ contributions, renderRoute }) {
12
+ const items = aggregateContributions(contributions, 'Navigation').map(extractNavigationItem).filter((item)=>item !== undefined);
13
+ const hasGroups = items.some((item)=>item.group !== undefined);
14
+ if (!hasGroups) {
15
+ return /*#__PURE__*/ jsx("nav", {
16
+ "data-scene-navbar": "",
17
+ children: items.map((item)=>/*#__PURE__*/ jsx(NavBarItem, {
18
+ item: item,
19
+ href: renderRoute(item)
20
+ }, item.targetScreen))
21
+ });
22
+ }
23
+ const groupNames = [
24
+ ...new Set(items.map((item)=>item.group ?? ''))
25
+ ];
26
+ return /*#__PURE__*/ jsx("nav", {
27
+ "data-scene-navbar": "",
28
+ children: groupNames.map((groupName)=>/*#__PURE__*/ jsx("section", {
29
+ "data-scene-navbar-group": groupName,
30
+ children: items.filter((item)=>(item.group ?? '') === groupName).map((item)=>/*#__PURE__*/ jsx(NavBarItem, {
31
+ item: item,
32
+ href: renderRoute(item)
33
+ }, item.targetScreen))
34
+ }, groupName))
35
+ });
36
+ }
37
+ function NavBarItem({ item, href }) {
38
+ return /*#__PURE__*/ jsx("a", {
39
+ href: href,
40
+ children: item.label
41
+ });
42
+ }
43
+
44
+ export { NavBar };
45
+ //# sourceMappingURL=NavBar.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"NavBar.js","sources":["../../../NavBar/NavBar.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 { Contribution, NavigationItem } from '@cratis/scene.model';\nimport { aggregateContributions } from '@cratis/scene.engine';\nimport { extractNavigationItem } from './extractNavigationItem';\n\nexport interface NavBarProps {\n /** Every contribution in scope - `NavBar` aggregates the ones targeting `Navigation` itself. */\n contributions: Contribution[];\n\n /**\n * Turns a {@link NavigationItem}'s target screen and route parameters into a concrete route - a URL\n * path, a query string, or a native deep link. Owning this as a caller-supplied function, rather than\n * a fixed URL scheme, is what makes `NavBar` usable unmodified across renderers (Cratis/Scene#2).\n */\n renderRoute: (item: NavigationItem) => string;\n}\n\n/**\n * Renders the aggregated `Navigation` contributions from across the current element tree - part of\n * Cratis/Scene#2. `NavBar` is not wired to a fixed source: pass it whatever contributions are currently\n * in scope and it recomputes, the same way any contribution-point consumer does.\n */\nexport function NavBar({ contributions, renderRoute }: NavBarProps) {\n const items = aggregateContributions(contributions, 'Navigation')\n .map(extractNavigationItem)\n .filter((item): item is NavigationItem => item !== undefined);\n\n const hasGroups = items.some(item => item.group !== undefined);\n if (!hasGroups) {\n return (\n <nav data-scene-navbar=\"\">\n {items.map(item => <NavBarItem key={item.targetScreen} item={item} href={renderRoute(item)} />)}\n </nav>\n );\n }\n\n const groupNames = [...new Set(items.map(item => item.group ?? ''))];\n return (\n <nav data-scene-navbar=\"\">\n {groupNames.map(groupName => (\n <section key={groupName} data-scene-navbar-group={groupName}>\n {items.filter(item => (item.group ?? '') === groupName).map(item => <NavBarItem key={item.targetScreen} item={item} href={renderRoute(item)} />)}\n </section>\n ))}\n </nav>\n );\n}\n\nfunction NavBarItem({ item, href }: { item: NavigationItem; href: string }) {\n return <a href={href}>{item.label}</a>;\n}\n"],"names":["NavBar","contributions","renderRoute","items","aggregateContributions","map","extractNavigationItem","filter","item","undefined","hasGroups","some","group","_jsx","nav","data-scene-navbar","NavBarItem","href","targetScreen","groupNames","Set","groupName","section","data-scene-navbar-group","a","label"],"mappings":";;;;AAAA;AACA;AAkBA;;;;AAIC,IACM,SAASA,MAAAA,CAAO,EAAEC,aAAa,EAAEC,WAAW,EAAe,EAAA;IAC9D,MAAMC,KAAAA,GAAQC,sBAAAA,CAAuBH,aAAAA,EAAe,YAAA,CAAA,CAC/CI,GAAG,CAACC,qBAAAA,CAAAA,CACJC,MAAM,CAAC,CAACC,IAAAA,GAAiCA,IAAAA,KAASC,SAAAA,CAAAA;IAEvD,MAAMC,SAAAA,GAAYP,MAAMQ,IAAI,CAACH,CAAAA,IAAAA,GAAQA,IAAAA,CAAKI,KAAK,KAAKH,SAAAA,CAAAA;AACpD,IAAA,IAAI,CAACC,SAAAA,EAAW;AACZ,QAAA,qBACIG,GAAA,CAACC,KAAAA,EAAAA;YAAIC,mBAAAA,EAAkB,EAAA;AAClBZ,YAAAA,QAAAA,EAAAA,KAAAA,CAAME,GAAG,CAACG,CAAAA,IAAAA,iBAAQK,GAAA,CAACG,UAAAA,EAAAA;oBAAmCR,IAAAA,EAAMA,IAAAA;AAAMS,oBAAAA,IAAAA,EAAMf,WAAAA,CAAYM,IAAAA;AAAjDA,iBAAAA,EAAAA,IAAAA,CAAKU,YAAY,CAAA;;AAGjE,IAAA;AAEA,IAAA,MAAMC,UAAAA,GAAa;WAAI,IAAIC,GAAAA,CAAIjB,MAAME,GAAG,CAACG,CAAAA,IAAAA,GAAQA,IAAAA,CAAKI,KAAK,IAAI,EAAA,CAAA;AAAK,KAAA;AACpE,IAAA,qBACIC,GAAA,CAACC,KAAAA,EAAAA;QAAIC,mBAAAA,EAAkB,EAAA;AAClBI,QAAAA,QAAAA,EAAAA,UAAAA,CAAWd,GAAG,CAACgB,CAAAA,SAAAA,iBACZR,GAAA,CAACS,SAAAA,EAAAA;gBAAwBC,yBAAAA,EAAyBF,SAAAA;AAC7ClB,gBAAAA,QAAAA,EAAAA,KAAAA,CAAMI,MAAM,CAACC,CAAAA,IAAAA,GAASA,CAAAA,IAAAA,CAAKI,KAAK,IAAI,EAAC,MAAOS,SAAAA,CAAAA,CAAWhB,GAAG,CAACG,CAAAA,qBAAQK,GAAA,CAACG,UAAAA,EAAAA;wBAAmCR,IAAAA,EAAMA,IAAAA;AAAMS,wBAAAA,IAAAA,EAAMf,WAAAA,CAAYM,IAAAA;AAAjDA,qBAAAA,EAAAA,IAAAA,CAAKU,YAAY,CAAA;AAD5FG,aAAAA,EAAAA,SAAAA,CAAAA;;AAM9B;AAEA,SAASL,UAAAA,CAAW,EAAER,IAAI,EAAES,IAAI,EAA0C,EAAA;AACtE,IAAA,qBAAOJ,GAAA,CAACW,GAAAA,EAAAA;QAAEP,IAAAA,EAAMA,IAAAA;AAAOT,QAAAA,QAAAA,EAAAA,IAAAA,CAAKiB;;AAChC;;;;"}
@@ -0,0 +1,3 @@
1
+ import { Contribution, NavigationItem } from '@cratis/scene.model';
2
+ export declare function extractNavigationItem(contribution: Contribution): NavigationItem | undefined;
3
+ //# sourceMappingURL=extractNavigationItem.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"extractNavigationItem.d.ts","sourceRoot":"","sources":["../../../NavBar/extractNavigationItem.ts"],"names":[],"mappings":"AAGA,OAAO,EAAqB,YAAY,EAAqB,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAczG,wBAAgB,qBAAqB,CAAC,YAAY,EAAE,YAAY,GAAG,cAAc,GAAG,SAAS,CAkB5F"}