@cratis/scene.engine 4.26.0 → 4.28.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (193) hide show
  1. package/dist/cjs/editing/resolveEffectiveConfiguration.js +8 -0
  2. package/dist/cjs/editing/resolveEffectiveConfiguration.js.map +1 -1
  3. package/dist/cjs/index.js +38 -0
  4. package/dist/cjs/index.js.map +1 -1
  5. package/dist/cjs/navigation/NavigationDiagnosticCode.js +5 -0
  6. package/dist/cjs/navigation/NavigationDiagnosticCode.js.map +1 -1
  7. package/dist/cjs/navigation/NavigationEditKind.js +16 -0
  8. package/dist/cjs/navigation/NavigationEditKind.js.map +1 -0
  9. package/dist/cjs/navigation/NavigationItemOrigin.js +14 -0
  10. package/dist/cjs/navigation/NavigationItemOrigin.js.map +1 -0
  11. package/dist/cjs/navigation/NavigationSourcesKind.js +16 -0
  12. package/dist/cjs/navigation/NavigationSourcesKind.js.map +1 -0
  13. package/dist/cjs/navigation/diagnoseNavigation.js +8 -1
  14. package/dist/cjs/navigation/diagnoseNavigation.js.map +1 -1
  15. package/dist/cjs/navigation/diagnoseNavigationRegions.js +99 -0
  16. package/dist/cjs/navigation/diagnoseNavigationRegions.js.map +1 -0
  17. package/dist/cjs/navigation/effectiveNavigation.js +133 -0
  18. package/dist/cjs/navigation/effectiveNavigation.js.map +1 -0
  19. package/dist/cjs/navigation/navigationEdits.js +230 -0
  20. package/dist/cjs/navigation/navigationEdits.js.map +1 -0
  21. package/dist/cjs/navigation/navigationRegions.js +42 -0
  22. package/dist/cjs/navigation/navigationRegions.js.map +1 -0
  23. package/dist/cjs/structure/ApplicationStructureIndex.js +10 -0
  24. package/dist/cjs/structure/ApplicationStructureIndex.js.map +1 -1
  25. package/dist/cjs/toolbar/SliceDialogSource.js +14 -0
  26. package/dist/cjs/toolbar/SliceDialogSource.js.map +1 -0
  27. package/dist/cjs/toolbar/ToolbarDiagnosticCode.js +16 -0
  28. package/dist/cjs/toolbar/ToolbarDiagnosticCode.js.map +1 -0
  29. package/dist/cjs/toolbar/ToolbarDiagnosticSeverity.js +14 -0
  30. package/dist/cjs/toolbar/ToolbarDiagnosticSeverity.js.map +1 -0
  31. package/dist/cjs/toolbar/sliceDialogFor.js +38 -0
  32. package/dist/cjs/toolbar/sliceDialogFor.js.map +1 -0
  33. package/dist/cjs/toolbar/toolbarButtons.js +93 -0
  34. package/dist/cjs/toolbar/toolbarButtons.js.map +1 -0
  35. package/dist/cjs/toolbar/validateToolbarButtons.js +59 -0
  36. package/dist/cjs/toolbar/validateToolbarButtons.js.map +1 -0
  37. package/dist/cjs/validateNavigationDestinations.js +2 -0
  38. package/dist/cjs/validateNavigationDestinations.js.map +1 -1
  39. package/dist/esm/editing/resolveEffectiveConfiguration.d.ts.map +1 -1
  40. package/dist/esm/editing/resolveEffectiveConfiguration.js +8 -0
  41. package/dist/esm/editing/resolveEffectiveConfiguration.js.map +1 -1
  42. package/dist/esm/index.d.ts +1 -0
  43. package/dist/esm/index.d.ts.map +1 -1
  44. package/dist/esm/index.js +13 -0
  45. package/dist/esm/index.js.map +1 -1
  46. package/dist/esm/navigation/EffectiveNavItem.d.ts +14 -0
  47. package/dist/esm/navigation/EffectiveNavItem.d.ts.map +1 -0
  48. package/dist/esm/navigation/EffectiveNavItem.js +2 -0
  49. package/dist/esm/navigation/EffectiveNavItem.js.map +1 -0
  50. package/dist/esm/navigation/EffectiveNavigationRegion.d.ts +11 -0
  51. package/dist/esm/navigation/EffectiveNavigationRegion.d.ts.map +1 -0
  52. package/dist/esm/navigation/EffectiveNavigationRegion.js +2 -0
  53. package/dist/esm/navigation/EffectiveNavigationRegion.js.map +1 -0
  54. package/dist/esm/navigation/NavigationDiagnosticCode.d.ts +6 -1
  55. package/dist/esm/navigation/NavigationDiagnosticCode.d.ts.map +1 -1
  56. package/dist/esm/navigation/NavigationDiagnosticCode.js +5 -0
  57. package/dist/esm/navigation/NavigationDiagnosticCode.js.map +1 -1
  58. package/dist/esm/navigation/NavigationEdit.d.ts +13 -0
  59. package/dist/esm/navigation/NavigationEdit.d.ts.map +1 -0
  60. package/dist/esm/navigation/NavigationEdit.js +2 -0
  61. package/dist/esm/navigation/NavigationEdit.js.map +1 -0
  62. package/dist/esm/navigation/NavigationEditKind.d.ts +7 -0
  63. package/dist/esm/navigation/NavigationEditKind.d.ts.map +1 -0
  64. package/dist/esm/navigation/NavigationEditKind.js +14 -0
  65. package/dist/esm/navigation/NavigationEditKind.js.map +1 -0
  66. package/dist/esm/navigation/NavigationEditOutcome.d.ts +7 -0
  67. package/dist/esm/navigation/NavigationEditOutcome.d.ts.map +1 -0
  68. package/dist/esm/navigation/NavigationEditOutcome.js +2 -0
  69. package/dist/esm/navigation/NavigationEditOutcome.js.map +1 -0
  70. package/dist/esm/navigation/NavigationEditPlan.d.ts +6 -0
  71. package/dist/esm/navigation/NavigationEditPlan.d.ts.map +1 -0
  72. package/dist/esm/navigation/NavigationEditPlan.js +2 -0
  73. package/dist/esm/navigation/NavigationEditPlan.js.map +1 -0
  74. package/dist/esm/navigation/NavigationGraph.d.ts +4 -1
  75. package/dist/esm/navigation/NavigationGraph.d.ts.map +1 -1
  76. package/dist/esm/navigation/NavigationItemOrigin.d.ts +5 -0
  77. package/dist/esm/navigation/NavigationItemOrigin.d.ts.map +1 -0
  78. package/dist/esm/navigation/NavigationItemOrigin.js +12 -0
  79. package/dist/esm/navigation/NavigationItemOrigin.js.map +1 -0
  80. package/dist/esm/navigation/NavigationSources.d.ts +6 -0
  81. package/dist/esm/navigation/NavigationSources.d.ts.map +1 -0
  82. package/dist/esm/navigation/NavigationSources.js +2 -0
  83. package/dist/esm/navigation/NavigationSources.js.map +1 -0
  84. package/dist/esm/navigation/NavigationSourcesKind.d.ts +7 -0
  85. package/dist/esm/navigation/NavigationSourcesKind.d.ts.map +1 -0
  86. package/dist/esm/navigation/NavigationSourcesKind.js +14 -0
  87. package/dist/esm/navigation/NavigationSourcesKind.js.map +1 -0
  88. package/dist/esm/navigation/ResolvedNavigationTarget.d.ts +6 -0
  89. package/dist/esm/navigation/ResolvedNavigationTarget.d.ts.map +1 -0
  90. package/dist/esm/navigation/ResolvedNavigationTarget.js +2 -0
  91. package/dist/esm/navigation/ResolvedNavigationTarget.js.map +1 -0
  92. package/dist/esm/navigation/diagnoseNavigation.d.ts.map +1 -1
  93. package/dist/esm/navigation/diagnoseNavigation.js +8 -1
  94. package/dist/esm/navigation/diagnoseNavigation.js.map +1 -1
  95. package/dist/esm/navigation/diagnoseNavigationRegions.d.ts +8 -0
  96. package/dist/esm/navigation/diagnoseNavigationRegions.d.ts.map +1 -0
  97. package/dist/esm/navigation/diagnoseNavigationRegions.js +97 -0
  98. package/dist/esm/navigation/diagnoseNavigationRegions.js.map +1 -0
  99. package/dist/esm/navigation/effectiveNavigation.d.ts +5 -0
  100. package/dist/esm/navigation/effectiveNavigation.d.ts.map +1 -0
  101. package/dist/esm/navigation/effectiveNavigation.js +131 -0
  102. package/dist/esm/navigation/effectiveNavigation.js.map +1 -0
  103. package/dist/esm/navigation/index.d.ts +14 -0
  104. package/dist/esm/navigation/index.d.ts.map +1 -1
  105. package/dist/esm/navigation/index.js +14 -0
  106. package/dist/esm/navigation/index.js.map +1 -1
  107. package/dist/esm/navigation/navigationEdits.d.ts +11 -0
  108. package/dist/esm/navigation/navigationEdits.d.ts.map +1 -0
  109. package/dist/esm/navigation/navigationEdits.js +225 -0
  110. package/dist/esm/navigation/navigationEdits.js.map +1 -0
  111. package/dist/esm/navigation/navigationRegions.d.ts +9 -0
  112. package/dist/esm/navigation/navigationRegions.d.ts.map +1 -0
  113. package/dist/esm/navigation/navigationRegions.js +34 -0
  114. package/dist/esm/navigation/navigationRegions.js.map +1 -0
  115. package/dist/esm/structure/ApplicationStructureIndex.d.ts +1 -0
  116. package/dist/esm/structure/ApplicationStructureIndex.d.ts.map +1 -1
  117. package/dist/esm/structure/ApplicationStructureIndex.js +10 -0
  118. package/dist/esm/structure/ApplicationStructureIndex.js.map +1 -1
  119. package/dist/esm/toolbar/ResolvedToolbarButton.d.ts +13 -0
  120. package/dist/esm/toolbar/ResolvedToolbarButton.d.ts.map +1 -0
  121. package/dist/esm/toolbar/ResolvedToolbarButton.js +2 -0
  122. package/dist/esm/toolbar/ResolvedToolbarButton.js.map +1 -0
  123. package/dist/esm/toolbar/SliceDialog.d.ts +8 -0
  124. package/dist/esm/toolbar/SliceDialog.d.ts.map +1 -0
  125. package/dist/esm/toolbar/SliceDialog.js +2 -0
  126. package/dist/esm/toolbar/SliceDialog.js.map +1 -0
  127. package/dist/esm/toolbar/SliceDialogSource.d.ts +5 -0
  128. package/dist/esm/toolbar/SliceDialogSource.d.ts.map +1 -0
  129. package/dist/esm/toolbar/SliceDialogSource.js +12 -0
  130. package/dist/esm/toolbar/SliceDialogSource.js.map +1 -0
  131. package/dist/esm/toolbar/ToolbarDiagnostic.d.ts +9 -0
  132. package/dist/esm/toolbar/ToolbarDiagnostic.d.ts.map +1 -0
  133. package/dist/esm/toolbar/ToolbarDiagnostic.js +2 -0
  134. package/dist/esm/toolbar/ToolbarDiagnostic.js.map +1 -0
  135. package/dist/esm/toolbar/ToolbarDiagnosticCode.d.ts +6 -0
  136. package/dist/esm/toolbar/ToolbarDiagnosticCode.d.ts.map +1 -0
  137. package/dist/esm/toolbar/ToolbarDiagnosticCode.js +14 -0
  138. package/dist/esm/toolbar/ToolbarDiagnosticCode.js.map +1 -0
  139. package/dist/esm/toolbar/ToolbarDiagnosticSeverity.d.ts +5 -0
  140. package/dist/esm/toolbar/ToolbarDiagnosticSeverity.d.ts.map +1 -0
  141. package/dist/esm/toolbar/ToolbarDiagnosticSeverity.js +12 -0
  142. package/dist/esm/toolbar/ToolbarDiagnosticSeverity.js.map +1 -0
  143. package/dist/esm/toolbar/index.d.ts +10 -0
  144. package/dist/esm/toolbar/index.d.ts.map +1 -0
  145. package/dist/esm/toolbar/index.js +10 -0
  146. package/dist/esm/toolbar/index.js.map +1 -0
  147. package/dist/esm/toolbar/sliceDialogFor.d.ts +5 -0
  148. package/dist/esm/toolbar/sliceDialogFor.d.ts.map +1 -0
  149. package/dist/esm/toolbar/sliceDialogFor.js +35 -0
  150. package/dist/esm/toolbar/sliceDialogFor.js.map +1 -0
  151. package/dist/esm/toolbar/toolbarButtons.d.ts +10 -0
  152. package/dist/esm/toolbar/toolbarButtons.d.ts.map +1 -0
  153. package/dist/esm/toolbar/toolbarButtons.js +89 -0
  154. package/dist/esm/toolbar/toolbarButtons.js.map +1 -0
  155. package/dist/esm/toolbar/validateToolbarButtons.d.ts +5 -0
  156. package/dist/esm/toolbar/validateToolbarButtons.d.ts.map +1 -0
  157. package/dist/esm/toolbar/validateToolbarButtons.js +57 -0
  158. package/dist/esm/toolbar/validateToolbarButtons.js.map +1 -0
  159. package/dist/esm/tsconfig.tsbuildinfo +1 -1
  160. package/dist/esm/validateNavigationDestinations.js +2 -0
  161. package/dist/esm/validateNavigationDestinations.js.map +1 -1
  162. package/editing/resolveEffectiveConfiguration.ts +13 -0
  163. package/index.ts +1 -0
  164. package/navigation/EffectiveNavItem.ts +37 -0
  165. package/navigation/EffectiveNavigationRegion.ts +26 -0
  166. package/navigation/NavigationDiagnosticCode.ts +15 -0
  167. package/navigation/NavigationEdit.ts +36 -0
  168. package/navigation/NavigationEditKind.ts +19 -0
  169. package/navigation/NavigationEditOutcome.ts +18 -0
  170. package/navigation/NavigationEditPlan.ts +15 -0
  171. package/navigation/NavigationGraph.ts +10 -1
  172. package/navigation/NavigationItemOrigin.ts +13 -0
  173. package/navigation/NavigationSources.ts +15 -0
  174. package/navigation/NavigationSourcesKind.ts +19 -0
  175. package/navigation/ResolvedNavigationTarget.ts +19 -0
  176. package/navigation/diagnoseNavigation.ts +7 -1
  177. package/navigation/diagnoseNavigationRegions.ts +122 -0
  178. package/navigation/effectiveNavigation.ts +105 -0
  179. package/navigation/index.ts +14 -0
  180. package/navigation/navigationEdits.ts +176 -0
  181. package/navigation/navigationRegions.ts +39 -0
  182. package/package.json +3 -3
  183. package/structure/ApplicationStructureIndex.ts +11 -0
  184. package/toolbar/ResolvedToolbarButton.ts +34 -0
  185. package/toolbar/SliceDialog.ts +21 -0
  186. package/toolbar/SliceDialogSource.ts +13 -0
  187. package/toolbar/ToolbarDiagnostic.ts +22 -0
  188. package/toolbar/ToolbarDiagnosticCode.ts +17 -0
  189. package/toolbar/ToolbarDiagnosticSeverity.ts +13 -0
  190. package/toolbar/index.ts +12 -0
  191. package/toolbar/sliceDialogFor.ts +31 -0
  192. package/toolbar/toolbarButtons.ts +83 -0
  193. package/toolbar/validateToolbarButtons.ts +61 -0
@@ -5,4 +5,18 @@ export * from './NavigationGraph';
5
5
  export * from './diagnoseNavigation';
6
6
  export * from './navigationEntriesFrom';
7
7
  export * from './navigationRoute';
8
+ export * from './navigationRegions';
9
+ export * from './NavigationItemOrigin';
10
+ export * from './NavigationSourcesKind';
11
+ export * from './NavigationSources';
12
+ export * from './ResolvedNavigationTarget';
13
+ export * from './EffectiveNavItem';
14
+ export * from './EffectiveNavigationRegion';
15
+ export * from './effectiveNavigation';
16
+ export * from './diagnoseNavigationRegions';
17
+ export * from './NavigationEditKind';
18
+ export * from './NavigationEdit';
19
+ export * from './NavigationEditPlan';
20
+ export * from './NavigationEditOutcome';
21
+ export * from './navigationEdits';
8
22
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../navigation/index.ts"],"names":[],"mappings":"AAGA,cAAc,wBAAwB,CAAC;AACvC,cAAc,4BAA4B,CAAC;AAC3C,cAAc,mBAAmB,CAAC;AAClC,cAAc,mBAAmB,CAAC;AAClC,cAAc,sBAAsB,CAAC;AACrC,cAAc,yBAAyB,CAAC;AACxC,cAAc,mBAAmB,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../navigation/index.ts"],"names":[],"mappings":"AAGA,cAAc,wBAAwB,CAAC;AACvC,cAAc,4BAA4B,CAAC;AAC3C,cAAc,mBAAmB,CAAC;AAClC,cAAc,mBAAmB,CAAC;AAClC,cAAc,sBAAsB,CAAC;AACrC,cAAc,yBAAyB,CAAC;AACxC,cAAc,mBAAmB,CAAC;AAClC,cAAc,qBAAqB,CAAC;AACpC,cAAc,wBAAwB,CAAC;AACvC,cAAc,yBAAyB,CAAC;AACxC,cAAc,qBAAqB,CAAC;AACpC,cAAc,4BAA4B,CAAC;AAC3C,cAAc,oBAAoB,CAAC;AACnC,cAAc,6BAA6B,CAAC;AAC5C,cAAc,uBAAuB,CAAC;AACtC,cAAc,6BAA6B,CAAC;AAC5C,cAAc,sBAAsB,CAAC;AACrC,cAAc,kBAAkB,CAAC;AACjC,cAAc,sBAAsB,CAAC;AACrC,cAAc,yBAAyB,CAAC;AACxC,cAAc,mBAAmB,CAAC"}
@@ -0,0 +1,11 @@
1
+ import { ApplicationLogo, NavigationModel, NavigationRegionKind, NavigationRegionMode, NavItem } from '@cratis/scene.model';
2
+ import { NavigationEdit } from './NavigationEdit';
3
+ import { NavigationEditOutcome } from './NavigationEditOutcome';
4
+ import { NavigationEditPlan } from './NavigationEditPlan';
5
+ export declare function switchRegionMode(navigation: NavigationModel, module: string | undefined, region: NavigationRegionKind, mode: NavigationRegionMode, options?: {
6
+ copy?: boolean;
7
+ }): NavigationEditPlan;
8
+ export declare function addNavItem(navigation: NavigationModel, module: string | undefined, region: NavigationRegionKind, item: NavItem, parent?: string): NavigationEditPlan;
9
+ export declare function setApplicationLogo(navigation: NavigationModel, module: string | undefined, logo: ApplicationLogo): NavigationEditPlan;
10
+ export declare function applyNavigationEdits(navigation: NavigationModel, edits: NavigationEdit[]): NavigationEditOutcome;
11
+ //# sourceMappingURL=navigationEdits.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"navigationEdits.d.ts","sourceRoot":"","sources":["../../../navigation/navigationEdits.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,eAAe,EAAE,eAAe,EAAoB,oBAAoB,EAAE,oBAAoB,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAC;AAC9I,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAElD,OAAO,EAAE,qBAAqB,EAAE,MAAM,yBAAyB,CAAC;AAChE,OAAO,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAgB1D,wBAAgB,gBAAgB,CAC5B,UAAU,EAAE,eAAe,EAC3B,MAAM,EAAE,MAAM,GAAG,SAAS,EAC1B,MAAM,EAAE,oBAAoB,EAC5B,IAAI,EAAE,oBAAoB,EAC1B,OAAO,GAAE;IAAE,IAAI,CAAC,EAAE,OAAO,CAAA;CAAO,GACjC,kBAAkB,CAgBpB;AAWD,wBAAgB,UAAU,CACtB,UAAU,EAAE,eAAe,EAC3B,MAAM,EAAE,MAAM,GAAG,SAAS,EAC1B,MAAM,EAAE,oBAAoB,EAC5B,IAAI,EAAE,OAAO,EACb,MAAM,CAAC,EAAE,MAAM,GAChB,kBAAkB,CAepB;AAQD,wBAAgB,kBAAkB,CAAC,UAAU,EAAE,eAAe,EAAE,MAAM,EAAE,MAAM,GAAG,SAAS,EAAE,IAAI,EAAE,eAAe,GAAG,kBAAkB,CAGrI;AAOD,wBAAgB,oBAAoB,CAAC,UAAU,EAAE,eAAe,EAAE,KAAK,EAAE,cAAc,EAAE,GAAG,qBAAqB,CAQhH"}
@@ -0,0 +1,225 @@
1
+ import { NavigationRegionKind, NavigationRegionMode } from '@cratis/scene.model';
2
+ import { NavigationEditKind } from './NavigationEditKind.js';
3
+ import { collectItemIds, modeOfModuleRegion, applicationItems, findNavigationRegion, findModuleNavigation } from './navigationRegions.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
+ const noMode = 'The application is the base of the navigation and has no region mode.';
8
+ const logoLevel = 'The logo is defined at the application level only.';
9
+ const flatTopbar = 'A topbar is flat; only a sidebar item has sub-items.';
10
+ /**
11
+ * Plans a change of a module region's mode. Switching to `inherit` clears the module's items (NAV3); switching from
12
+ * `inherit` to `override` with `copy` first copies the application's items so the module starts from them (NAV5).
13
+ * @param navigation The navigation as it is.
14
+ * @param module The module whose region changes; the application has no mode and is refused.
15
+ * @param region The region.
16
+ * @param mode The mode to switch to.
17
+ * @param options `copy` copies the application items when switching from inherit to override.
18
+ */ function switchRegionMode(navigation, module, region, mode, options = {}) {
19
+ if (module === undefined) return {
20
+ edits: [],
21
+ rejected: noMode
22
+ };
23
+ const current = modeOfModuleRegion(navigation, module, region);
24
+ if (current === mode) return {
25
+ edits: []
26
+ };
27
+ const setMode = {
28
+ kind: NavigationEditKind.SetRegionMode,
29
+ module,
30
+ region,
31
+ mode
32
+ };
33
+ if (mode === NavigationRegionMode.Inherit) {
34
+ return {
35
+ edits: [
36
+ {
37
+ kind: NavigationEditKind.SetRegionItems,
38
+ module,
39
+ region,
40
+ items: []
41
+ },
42
+ setMode
43
+ ]
44
+ };
45
+ }
46
+ if (mode === NavigationRegionMode.Override && current === NavigationRegionMode.Inherit && options.copy === true) {
47
+ return {
48
+ edits: [
49
+ {
50
+ kind: NavigationEditKind.SetRegionItems,
51
+ module,
52
+ region,
53
+ items: structuredClone(applicationItems(navigation.application, region))
54
+ },
55
+ setMode
56
+ ]
57
+ };
58
+ }
59
+ return {
60
+ edits: [
61
+ setMode
62
+ ]
63
+ };
64
+ }
65
+ /**
66
+ * Plans adding an item to a region, after the ones already there. Adding to an inheriting module region first
67
+ * switches it to `extend` (NAV6), so the application's items stay and the new item follows them.
68
+ * @param navigation The navigation as it is.
69
+ * @param module The module that gets the item; undefined for the application.
70
+ * @param region The region.
71
+ * @param item The item to add.
72
+ * @param parent The id of the item it becomes a sub-item of; sidebar only.
73
+ */ function addNavItem(navigation, module, region, item, parent) {
74
+ if (parent !== undefined && region !== NavigationRegionKind.Sidebar) return {
75
+ edits: [],
76
+ rejected: flatTopbar
77
+ };
78
+ const own = ownItems(navigation, module, region);
79
+ const ids = collectItemIds(own, region);
80
+ if (ids.includes(item.id)) return {
81
+ edits: [],
82
+ rejected: `Navigation item id '${item.id}' is already used in this region.`
83
+ };
84
+ if (parent !== undefined && !ids.includes(parent)) return {
85
+ edits: [],
86
+ rejected: `There is no item '${parent}' to add a sub-item to.`
87
+ };
88
+ const add = {
89
+ kind: NavigationEditKind.AddItem,
90
+ module,
91
+ region,
92
+ item: structuredClone(item)
93
+ };
94
+ if (parent !== undefined) add.parent = parent;
95
+ if (module !== undefined && modeOfModuleRegion(navigation, module, region) === NavigationRegionMode.Inherit) {
96
+ return {
97
+ edits: [
98
+ {
99
+ kind: NavigationEditKind.SetRegionMode,
100
+ module,
101
+ region,
102
+ mode: NavigationRegionMode.Extend
103
+ },
104
+ add
105
+ ]
106
+ };
107
+ }
108
+ return {
109
+ edits: [
110
+ add
111
+ ]
112
+ };
113
+ }
114
+ /**
115
+ * Plans setting the logo. The logo is defined at the application level only, so a module is refused.
116
+ * @param navigation The navigation as it is.
117
+ * @param module The module asking; only undefined (the application) is allowed.
118
+ * @param logo The logo.
119
+ */ function setApplicationLogo(navigation, module, logo) {
120
+ return module === undefined ? {
121
+ edits: [
122
+ {
123
+ kind: NavigationEditKind.SetLogo,
124
+ logo: {
125
+ ...logo
126
+ }
127
+ }
128
+ ]
129
+ } : {
130
+ edits: [],
131
+ rejected: logoLevel
132
+ };
133
+ }
134
+ /**
135
+ * Applies navigation edits to a copy of the model. Either every edit applies, or none does.
136
+ * @param navigation The navigation as it is; never changed.
137
+ * @param edits The edits, in order.
138
+ */ function applyNavigationEdits(navigation, edits) {
139
+ const model = structuredClone(navigation);
140
+ for (const edit of edits){
141
+ const rejected = apply(model, edit);
142
+ if (rejected !== undefined) return {
143
+ applied: false,
144
+ model: navigation,
145
+ rejected
146
+ };
147
+ }
148
+ return {
149
+ applied: true,
150
+ model
151
+ };
152
+ }
153
+ function ownItems(navigation, module, region) {
154
+ return module === undefined ? applicationItems(navigation.application, region) : findNavigationRegion(findModuleNavigation(navigation, module)?.regions, region)?.items ?? [];
155
+ }
156
+ function regionOf(model, module, region) {
157
+ let regions;
158
+ if (module === undefined) {
159
+ regions = model.application.regions;
160
+ } else {
161
+ let block = findModuleNavigation(model, module);
162
+ if (!block) {
163
+ block = {
164
+ module,
165
+ regions: []
166
+ };
167
+ model.modules.push(block);
168
+ }
169
+ regions = block.regions;
170
+ }
171
+ let found = findNavigationRegion(regions, region);
172
+ if (!found) {
173
+ found = {
174
+ region,
175
+ items: []
176
+ };
177
+ regions.push(found);
178
+ }
179
+ return found;
180
+ }
181
+ function apply(model, edit) {
182
+ switch(edit.kind){
183
+ case NavigationEditKind.SetRegionMode:
184
+ if (edit.module === undefined) return noMode;
185
+ regionOf(model, edit.module, edit.region).mode = edit.mode;
186
+ return undefined;
187
+ case NavigationEditKind.SetRegionItems:
188
+ regionOf(model, edit.module, edit.region).items = structuredClone(edit.items ?? []);
189
+ return undefined;
190
+ case NavigationEditKind.AddItem:
191
+ {
192
+ const target = regionOf(model, edit.module, edit.region);
193
+ const item = structuredClone(edit.item);
194
+ if (collectItemIds(target.items, target.region).includes(item.id)) return `Navigation item id '${item.id}' is already used in this region.`;
195
+ if (edit.parent === undefined) {
196
+ target.items.push(item);
197
+ return undefined;
198
+ }
199
+ if (target.region !== NavigationRegionKind.Sidebar) return flatTopbar;
200
+ const owner = findItem(target.items, edit.parent);
201
+ if (!owner) return `There is no item '${edit.parent}' to add a sub-item to.`;
202
+ (owner.children ??= []).push(item);
203
+ return undefined;
204
+ }
205
+ case NavigationEditKind.SetLogo:
206
+ if (edit.module !== undefined) return logoLevel;
207
+ model.application.logo = {
208
+ ...edit.logo
209
+ };
210
+ return undefined;
211
+ default:
212
+ return `'${String(edit.kind)}' is not a navigation edit.`;
213
+ }
214
+ }
215
+ function findItem(items, id) {
216
+ for (const item of items){
217
+ if (item.id === id) return item;
218
+ const nested = findItem(item.children ?? [], id);
219
+ if (nested) return nested;
220
+ }
221
+ return undefined;
222
+ }
223
+
224
+ export { addNavItem, applyNavigationEdits, setApplicationLogo, switchRegionMode };
225
+ //# sourceMappingURL=navigationEdits.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"navigationEdits.js","sources":["../../../navigation/navigationEdits.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 { ApplicationLogo, NavigationModel, NavigationRegion, NavigationRegionKind, NavigationRegionMode, NavItem } from '@cratis/scene.model';\nimport { NavigationEdit } from './NavigationEdit';\nimport { NavigationEditKind } from './NavigationEditKind';\nimport { NavigationEditOutcome } from './NavigationEditOutcome';\nimport { NavigationEditPlan } from './NavigationEditPlan';\nimport { applicationItems, collectItemIds, findModuleNavigation, findNavigationRegion, modeOfModuleRegion } from './navigationRegions';\n\nconst noMode = 'The application is the base of the navigation and has no region mode.';\nconst logoLevel = 'The logo is defined at the application level only.';\nconst flatTopbar = 'A topbar is flat; only a sidebar item has sub-items.';\n\n/**\n * Plans a change of a module region's mode. Switching to `inherit` clears the module's items (NAV3); switching from\n * `inherit` to `override` with `copy` first copies the application's items so the module starts from them (NAV5).\n * @param navigation The navigation as it is.\n * @param module The module whose region changes; the application has no mode and is refused.\n * @param region The region.\n * @param mode The mode to switch to.\n * @param options `copy` copies the application items when switching from inherit to override.\n */\nexport function switchRegionMode(\n navigation: NavigationModel,\n module: string | undefined,\n region: NavigationRegionKind,\n mode: NavigationRegionMode,\n options: { copy?: boolean } = {},\n): NavigationEditPlan {\n if (module === undefined) return { edits: [], rejected: noMode };\n\n const current = modeOfModuleRegion(navigation, module, region);\n if (current === mode) return { edits: [] };\n\n const setMode: NavigationEdit = { kind: NavigationEditKind.SetRegionMode, module, region, mode };\n if (mode === NavigationRegionMode.Inherit) {\n return { edits: [{ kind: NavigationEditKind.SetRegionItems, module, region, items: [] }, setMode] };\n }\n\n if (mode === NavigationRegionMode.Override && current === NavigationRegionMode.Inherit && options.copy === true) {\n return { edits: [{ kind: NavigationEditKind.SetRegionItems, module, region, items: structuredClone(applicationItems(navigation.application, region)) }, setMode] };\n }\n\n return { edits: [setMode] };\n}\n\n/**\n * Plans adding an item to a region, after the ones already there. Adding to an inheriting module region first\n * switches it to `extend` (NAV6), so the application's items stay and the new item follows them.\n * @param navigation The navigation as it is.\n * @param module The module that gets the item; undefined for the application.\n * @param region The region.\n * @param item The item to add.\n * @param parent The id of the item it becomes a sub-item of; sidebar only.\n */\nexport function addNavItem(\n navigation: NavigationModel,\n module: string | undefined,\n region: NavigationRegionKind,\n item: NavItem,\n parent?: string,\n): NavigationEditPlan {\n if (parent !== undefined && region !== NavigationRegionKind.Sidebar) return { edits: [], rejected: flatTopbar };\n\n const own = ownItems(navigation, module, region);\n const ids = collectItemIds(own, region);\n if (ids.includes(item.id)) return { edits: [], rejected: `Navigation item id '${item.id}' is already used in this region.` };\n if (parent !== undefined && !ids.includes(parent)) return { edits: [], rejected: `There is no item '${parent}' to add a sub-item to.` };\n\n const add: NavigationEdit = { kind: NavigationEditKind.AddItem, module, region, item: structuredClone(item) };\n if (parent !== undefined) add.parent = parent;\n if (module !== undefined && modeOfModuleRegion(navigation, module, region) === NavigationRegionMode.Inherit) {\n return { edits: [{ kind: NavigationEditKind.SetRegionMode, module, region, mode: NavigationRegionMode.Extend }, add] };\n }\n\n return { edits: [add] };\n}\n\n/**\n * Plans setting the logo. The logo is defined at the application level only, so a module is refused.\n * @param navigation The navigation as it is.\n * @param module The module asking; only undefined (the application) is allowed.\n * @param logo The logo.\n */\nexport function setApplicationLogo(navigation: NavigationModel, module: string | undefined, logo: ApplicationLogo): NavigationEditPlan {\n void navigation;\n return module === undefined ? { edits: [{ kind: NavigationEditKind.SetLogo, logo: { ...logo } }] } : { edits: [], rejected: logoLevel };\n}\n\n/**\n * Applies navigation edits to a copy of the model. Either every edit applies, or none does.\n * @param navigation The navigation as it is; never changed.\n * @param edits The edits, in order.\n */\nexport function applyNavigationEdits(navigation: NavigationModel, edits: NavigationEdit[]): NavigationEditOutcome {\n const model = structuredClone(navigation);\n for (const edit of edits) {\n const rejected = apply(model, edit);\n if (rejected !== undefined) return { applied: false, model: navigation, rejected };\n }\n\n return { applied: true, model };\n}\n\nfunction ownItems(navigation: NavigationModel, module: string | undefined, region: NavigationRegionKind): NavItem[] {\n return module === undefined\n ? applicationItems(navigation.application, region)\n : findNavigationRegion(findModuleNavigation(navigation, module)?.regions, region)?.items ?? [];\n}\n\nfunction regionOf(model: NavigationModel, module: string | undefined, region: NavigationRegionKind): NavigationRegion {\n let regions: NavigationRegion[];\n if (module === undefined) {\n regions = model.application.regions;\n } else {\n let block = findModuleNavigation(model, module);\n if (!block) {\n block = { module, regions: [] };\n model.modules.push(block);\n }\n\n regions = block.regions;\n }\n\n let found = findNavigationRegion(regions, region);\n if (!found) {\n found = { region, items: [] };\n regions.push(found);\n }\n\n return found;\n}\n\nfunction apply(model: NavigationModel, edit: NavigationEdit): string | undefined {\n switch (edit.kind) {\n case NavigationEditKind.SetRegionMode:\n if (edit.module === undefined) return noMode;\n regionOf(model, edit.module, edit.region!).mode = edit.mode;\n return undefined;\n case NavigationEditKind.SetRegionItems:\n regionOf(model, edit.module, edit.region!).items = structuredClone(edit.items ?? []);\n return undefined;\n case NavigationEditKind.AddItem: {\n const target = regionOf(model, edit.module, edit.region!);\n const item = structuredClone(edit.item!);\n if (collectItemIds(target.items, target.region).includes(item.id)) return `Navigation item id '${item.id}' is already used in this region.`;\n if (edit.parent === undefined) {\n target.items.push(item);\n return undefined;\n }\n\n if (target.region !== NavigationRegionKind.Sidebar) return flatTopbar;\n const owner = findItem(target.items, edit.parent);\n if (!owner) return `There is no item '${edit.parent}' to add a sub-item to.`;\n (owner.children ??= []).push(item);\n return undefined;\n }\n case NavigationEditKind.SetLogo:\n if (edit.module !== undefined) return logoLevel;\n model.application.logo = { ...edit.logo! };\n return undefined;\n default:\n return `'${String((edit as NavigationEdit).kind)}' is not a navigation edit.`;\n }\n}\n\nfunction findItem(items: NavItem[], id: string): NavItem | undefined {\n for (const item of items) {\n if (item.id === id) return item;\n const nested = findItem(item.children ?? [], id);\n if (nested) return nested;\n }\n\n return undefined;\n}\n"],"names":["noMode","logoLevel","flatTopbar","switchRegionMode","navigation","module","region","mode","options","undefined","edits","rejected","current","modeOfModuleRegion","setMode","kind","NavigationEditKind","SetRegionMode","NavigationRegionMode","Inherit","SetRegionItems","items","Override","copy","structuredClone","applicationItems","application","addNavItem","item","parent","NavigationRegionKind","Sidebar","own","ownItems","ids","collectItemIds","includes","id","add","AddItem","Extend","setApplicationLogo","logo","SetLogo","applyNavigationEdits","model","edit","apply","applied","findNavigationRegion","findModuleNavigation","regions","regionOf","block","modules","push","found","target","owner","findItem","children","String","nested"],"mappings":";;;;AAAA;AACA;AASA,MAAMA,MAAAA,GAAS,uEAAA;AACf,MAAMC,SAAAA,GAAY,oDAAA;AAClB,MAAMC,UAAAA,GAAa,sDAAA;AAEnB;;;;;;;;AAQC,IACM,SAASC,gBAAAA,CACZC,UAA2B,EAC3BC,MAA0B,EAC1BC,MAA4B,EAC5BC,IAA0B,EAC1BC,OAAAA,GAA8B,EAAE,EAAA;IAEhC,IAAIH,MAAAA,KAAWI,WAAW,OAAO;AAAEC,QAAAA,KAAAA,EAAO,EAAE;QAAEC,QAAAA,EAAUX;AAAO,KAAA;IAE/D,MAAMY,OAAAA,GAAUC,kBAAAA,CAAmBT,UAAAA,EAAYC,MAAAA,EAAQC,MAAAA,CAAAA;IACvD,IAAIM,OAAAA,KAAYL,MAAM,OAAO;AAAEG,QAAAA,KAAAA,EAAO;AAAG,KAAA;AAEzC,IAAA,MAAMI,OAAAA,GAA0B;AAAEC,QAAAA,IAAAA,EAAMC,mBAAmBC,aAAa;AAAEZ,QAAAA,MAAAA;AAAQC,QAAAA,MAAAA;AAAQC,QAAAA;AAAK,KAAA;IAC/F,IAAIA,IAAAA,KAASW,oBAAAA,CAAqBC,OAAO,EAAE;QACvC,OAAO;YAAET,KAAAA,EAAO;AAAC,gBAAA;AAAEK,oBAAAA,IAAAA,EAAMC,mBAAmBI,cAAc;AAAEf,oBAAAA,MAAAA;AAA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,KAAKA,EAAAA,EAAI,OAAOT,IAAAA;AAC3B,QAAA,MAAMkC,SAASH,QAAAA,CAAS/B,IAAAA,CAAKgC,QAAQ,IAAI,EAAE,EAAEvB,EAAAA,CAAAA;AAC7C,QAAA,IAAIyB,QAAQ,OAAOA,MAAAA;AACvB,IAAA;IAEA,OAAOrD,SAAAA;AACX;;"}
@@ -0,0 +1,9 @@
1
+ import { ApplicationNavigation, ModuleNavigation, NavigationModel, NavigationRegion, NavigationRegionKind, NavigationRegionMode, NavItem } from '@cratis/scene.model';
2
+ export declare const navigationRegionOrder: NavigationRegionKind[];
3
+ export declare const primarySlot = "content";
4
+ export declare function findNavigationRegion(regions: NavigationRegion[] | undefined, region: NavigationRegionKind): NavigationRegion | undefined;
5
+ export declare function findModuleNavigation(navigation: NavigationModel, module: string): ModuleNavigation | undefined;
6
+ export declare function modeOfModuleRegion(navigation: NavigationModel, module: string, region: NavigationRegionKind): NavigationRegionMode;
7
+ export declare function applicationItems(application: ApplicationNavigation, region: NavigationRegionKind): NavItem[];
8
+ export declare function collectItemIds(items: NavItem[], region: NavigationRegionKind): string[];
9
+ //# sourceMappingURL=navigationRegions.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"navigationRegions.d.ts","sourceRoot":"","sources":["../../../navigation/navigationRegions.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,qBAAqB,EAAE,gBAAgB,EAAE,eAAe,EAAE,gBAAgB,EAAE,oBAAoB,EAAE,oBAAoB,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAC;AAGtK,eAAO,MAAM,qBAAqB,EAAE,oBAAoB,EAAgE,CAAC;AAGzH,eAAO,MAAM,WAAW,YAAY,CAAC;AAOrC,wBAAgB,oBAAoB,CAAC,OAAO,EAAE,gBAAgB,EAAE,GAAG,SAAS,EAAE,MAAM,EAAE,oBAAoB,GAAG,gBAAgB,GAAG,SAAS,CAExI;AAGD,wBAAgB,oBAAoB,CAAC,UAAU,EAAE,eAAe,EAAE,MAAM,EAAE,MAAM,GAAG,gBAAgB,GAAG,SAAS,CAE9G;AAGD,wBAAgB,kBAAkB,CAAC,UAAU,EAAE,eAAe,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,oBAAoB,GAAG,oBAAoB,CAElI;AAGD,wBAAgB,gBAAgB,CAAC,WAAW,EAAE,qBAAqB,EAAE,MAAM,EAAE,oBAAoB,GAAG,OAAO,EAAE,CAE5G;AAGD,wBAAgB,cAAc,CAAC,KAAK,EAAE,OAAO,EAAE,EAAE,MAAM,EAAE,oBAAoB,GAAG,MAAM,EAAE,CAEvF"}
@@ -0,0 +1,34 @@
1
+ import { NavigationRegionKind, NavigationRegionMode } from '@cratis/scene.model';
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
+ /** The regions in the order every result lists them. */ const navigationRegionOrder = [
6
+ NavigationRegionKind.Topbar,
7
+ NavigationRegionKind.Sidebar
8
+ ];
9
+ /** The slot an item renders into when it names none: the primary outlet. */ const primarySlot = 'content';
10
+ /**
11
+ * Finds the items a level defines for a region.
12
+ * @param regions The regions of the application or of a module.
13
+ * @param region The region to look for.
14
+ */ function findNavigationRegion(regions, region) {
15
+ return regions?.find((candidate)=>candidate.region === region);
16
+ }
17
+ /** Finds what a module declares; undefined when it declares nothing. */ function findModuleNavigation(navigation, module) {
18
+ return navigation.modules.find((candidate)=>candidate.module === module);
19
+ }
20
+ /** The mode of a module's region: `inherit` when the module does not declare the region or its mode. */ function modeOfModuleRegion(navigation, module, region) {
21
+ return findNavigationRegion(findModuleNavigation(navigation, module)?.regions, region)?.mode ?? NavigationRegionMode.Inherit;
22
+ }
23
+ /** The application-level items of a region. */ function applicationItems(application, region) {
24
+ return findNavigationRegion(application.regions, region)?.items ?? [];
25
+ }
26
+ /** Every id in a list of items, depth first. Sub-items count only in the sidebar. */ function collectItemIds(items, region) {
27
+ return items.flatMap((item)=>[
28
+ item.id,
29
+ ...region === NavigationRegionKind.Sidebar ? collectItemIds(item.children ?? [], region) : []
30
+ ]);
31
+ }
32
+
33
+ export { applicationItems, collectItemIds, findModuleNavigation, findNavigationRegion, modeOfModuleRegion, navigationRegionOrder, primarySlot };
34
+ //# sourceMappingURL=navigationRegions.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"navigationRegions.js","sources":["../../../navigation/navigationRegions.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 { ApplicationNavigation, ModuleNavigation, NavigationModel, NavigationRegion, NavigationRegionKind, NavigationRegionMode, NavItem } from '@cratis/scene.model';\n\n/** The regions in the order every result lists them. */\nexport const navigationRegionOrder: NavigationRegionKind[] = [NavigationRegionKind.Topbar, NavigationRegionKind.Sidebar];\n\n/** The slot an item renders into when it names none: the primary outlet. */\nexport const primarySlot = 'content';\n\n/**\n * Finds the items a level defines for a region.\n * @param regions The regions of the application or of a module.\n * @param region The region to look for.\n */\nexport function findNavigationRegion(regions: NavigationRegion[] | undefined, region: NavigationRegionKind): NavigationRegion | undefined {\n return regions?.find(candidate => candidate.region === region);\n}\n\n/** Finds what a module declares; undefined when it declares nothing. */\nexport function findModuleNavigation(navigation: NavigationModel, module: string): ModuleNavigation | undefined {\n return navigation.modules.find(candidate => candidate.module === module);\n}\n\n/** The mode of a module's region: `inherit` when the module does not declare the region or its mode. */\nexport function modeOfModuleRegion(navigation: NavigationModel, module: string, region: NavigationRegionKind): NavigationRegionMode {\n return findNavigationRegion(findModuleNavigation(navigation, module)?.regions, region)?.mode ?? NavigationRegionMode.Inherit;\n}\n\n/** The application-level items of a region. */\nexport function applicationItems(application: ApplicationNavigation, region: NavigationRegionKind): NavItem[] {\n return findNavigationRegion(application.regions, region)?.items ?? [];\n}\n\n/** Every id in a list of items, depth first. Sub-items count only in the sidebar. */\nexport function collectItemIds(items: NavItem[], region: NavigationRegionKind): string[] {\n return items.flatMap(item => [item.id, ...(region === NavigationRegionKind.Sidebar ? collectItemIds(item.children ?? [], region) : [])]);\n}\n"],"names":["navigationRegionOrder","NavigationRegionKind","Topbar","Sidebar","primarySlot","findNavigationRegion","regions","region","find","candidate","findModuleNavigation","navigation","module","modules","modeOfModuleRegion","mode","NavigationRegionMode","Inherit","applicationItems","application","items","collectItemIds","flatMap","item","id","children"],"mappings":";;AAAA;AACA;AAIA,yDACO,MAAMA,qBAAAA,GAAgD;AAACC,IAAAA,oBAAAA,CAAqBC,MAAM;AAAED,IAAAA,oBAAAA,CAAqBE;;AAEhH,6EACO,MAAMC,WAAAA,GAAc;AAE3B;;;;AAIC,IACM,SAASC,oBAAAA,CAAqBC,OAAuC,EAAEC,MAA4B,EAAA;AACtG,IAAA,OAAOD,SAASE,IAAAA,CAAKC,CAAAA,SAAAA,GAAaA,SAAAA,CAAUF,MAAM,KAAKA,MAAAA,CAAAA;AAC3D;AAEA,yEACO,SAASG,oBAAAA,CAAqBC,UAA2B,EAAEC,MAAc,EAAA;IAC5E,OAAOD,UAAAA,CAAWE,OAAO,CAACL,IAAI,CAACC,CAAAA,SAAAA,GAAaA,SAAAA,CAAUG,MAAM,KAAKA,MAAAA,CAAAA;AACrE;AAEA,yGACO,SAASE,kBAAAA,CAAmBH,UAA2B,EAAEC,MAAc,EAAEL,MAA4B,EAAA;IACxG,OAAOF,oBAAAA,CAAqBK,qBAAqBC,UAAAA,EAAYC,MAAAA,CAAAA,EAASN,SAASC,MAAAA,CAAAA,EAASQ,IAAAA,IAAQC,qBAAqBC,OAAO;AAChI;AAEA,gDACO,SAASC,gBAAAA,CAAiBC,WAAkC,EAAEZ,MAA4B,EAAA;AAC7F,IAAA,OAAOF,qBAAqBc,WAAAA,CAAYb,OAAO,EAAEC,MAAAA,CAAAA,EAASa,SAAS,EAAE;AACzE;AAEA,sFACO,SAASC,cAAAA,CAAeD,KAAgB,EAAEb,MAA4B,EAAA;AACzE,IAAA,OAAOa,KAAAA,CAAME,OAAO,CAACC,CAAAA,IAAAA,GAAQ;AAACA,YAAAA,IAAAA,CAAKC,EAAE;eAAMjB,MAAAA,KAAWN,oBAAAA,CAAqBE,OAAO,GAAGkB,cAAAA,CAAeE,IAAAA,CAAKE,QAAQ,IAAI,EAAE,EAAElB,MAAAA,CAAAA,GAAU;AAAI,SAAA,CAAA;AAC3I;;"}
@@ -15,6 +15,7 @@ export declare class ApplicationStructureIndex {
15
15
  findSlice(qualifiedId: string): SliceNode | undefined;
16
16
  kindOf(sliceId: string): SliceKind | undefined;
17
17
  findFeaturesByName(name: string): string[];
18
+ findSlicesByCommand(command: string): string[];
18
19
  private indexContainer;
19
20
  private claim;
20
21
  private reportAmbiguousName;
@@ -1 +1 @@
1
- {"version":3,"file":"ApplicationStructureIndex.d.ts","sourceRoot":"","sources":["../../../structure/ApplicationStructureIndex.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,oBAAoB,EAAE,WAAW,EAAE,UAAU,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AAC1G,OAAO,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAW5D,qBAAa,yBAAyB;IAatB,QAAQ,CAAC,SAAS,EAAE,oBAAoB;IAZpD,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAiC;IACzD,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAkC;IAC3D,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAgC;IACvD,OAAO,CAAC,QAAQ,CAAC,cAAc,CAA+B;IAG9D,QAAQ,CAAC,WAAW,EAAE,mBAAmB,EAAE,CAAM;IAMjD,YAAqB,SAAS,EAAE,oBAAoB,EAYnD;IAOD,UAAU,CAAC,QAAQ,EAAE,MAAM,GAAG,UAAU,GAAG,SAAS,CAEnD;IAOD,WAAW,CAAC,WAAW,EAAE,MAAM,GAAG,WAAW,GAAG,SAAS,CAExD;IAOD,YAAY,CAAC,QAAQ,EAAE,MAAM,GAAG,WAAW,GAAG,SAAS,CAEtD;IAOD,cAAc,CAAC,QAAQ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AS,GAAG,SAAS,CAEpD;IAOD,MAAM,CAAC,OAAO,EAAE,MAAM,GAAG,SAAS,GAAG,SAAS,CAE7C;IAOD,kBAAkB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,EAAE,CAEzC;IAOD,mBAAmB,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,EAAE,CAI7C;IAED,OAAO,CAAC,cAAc;IA2BtB,OAAO,CAAC,KAAK;IAeb,OAAO,CAAC,mBAAmB;CAc9B"}
@@ -1,3 +1,4 @@
1
+ import { SliceKind } from '@cratis/scene.model';
1
2
  import { StructureDiagnosticCode } from './StructureDiagnosticCode.js';
2
3
 
3
4
  // Copyright (c) Cratis. All rights reserved.
@@ -83,6 +84,15 @@ import { StructureDiagnosticCode } from './StructureDiagnosticCode.js';
83
84
  ...this.featuresByName.get(name.toLowerCase()) ?? []
84
85
  ];
85
86
  }
87
+ /**
88
+ * Finds the state change slices that accept a command, so a command named by hand can be turned into the slice that owns it.
89
+ * @param command A command name - the slice's `command`, or its `id` when it names none - or a slice's qualified id.
90
+ * @returns The qualified ids of the matching state change slices, in declaration order.
91
+ */ findSlicesByCommand(command) {
92
+ return [
93
+ ...this.slices.entries()
94
+ ].filter(([qualified, slice])=>slice.kind === SliceKind.StateChange && (qualified === command || (slice.command ?? slice.id) === command)).map(([qualified])=>qualified);
95
+ }
86
96
  indexContainer(path, features, slices) {
87
97
  const seen = new Map();
88
98
  const featureNames = new Map();
@@ -1 +1 @@
1
- {"version":3,"file":"ApplicationStructureIndex.js","sources":["../../../structure/ApplicationStructureIndex.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, FeatureNode, ModuleNode, SliceKind, SliceNode } from '@cratis/scene.model';\nimport { StructureDiagnostic } from './StructureDiagnostic';\nimport { StructureDiagnosticCode } from './StructureDiagnosticCode';\n\n/**\n * Answers the questions navigation, toolbar and template applicability ask of an {@link ApplicationStructure}:\n * does this module, feature or slice exist, which feature comes first in a module, and what kind of slice is it.\n * Pure and read-only; when ids are duplicated the first declaration wins and {@link diagnostics} reports the rest.\n *\n * The C# engine (`ApplicationStructureIndex`) answers the same questions the same way; both are asserted\n * against `application-structure-fixtures.json`.\n */\nexport class ApplicationStructureIndex {\n private readonly modules = new Map<string, ModuleNode>();\n private readonly features = new Map<string, FeatureNode>();\n private readonly slices = new Map<string, SliceNode>();\n private readonly featuresByName = new Map<string, string[]>();\n\n /** The problems found while indexing, in declaration order. */\n readonly diagnostics: StructureDiagnostic[] = [];\n\n /**\n * Initializes a new instance of the {@link ApplicationStructureIndex} class.\n * @param structure The application structure to index.\n */\n constructor(readonly structure: ApplicationStructure) {\n const seen = new Map<string, string>();\n const names = new Map<string, string>();\n\n for (const module of structure.modules) {\n const qualified = module.id;\n if (!this.claim(seen, qualified, 'module')) continue;\n\n this.modules.set(qualified, module);\n this.reportAmbiguousName(names, 'module', module.name, qualified);\n this.indexContainer(qualified, module.features, module.slices ?? []);\n }\n }\n\n /**\n * Finds a module by its id.\n * @param moduleId The module id, for example `sales`.\n * @returns The module, or undefined when there is none.\n */\n findModule(moduleId: string): ModuleNode | undefined {\n return this.modules.get(moduleId);\n }\n\n /**\n * Finds a feature by its qualified id.\n * @param qualifiedId The dotted id from the module down, for example `sales.orders` or `sales.orders.returns`.\n * @returns The feature, or undefined when there is none.\n */\n findFeature(qualifiedId: string): FeatureNode | undefined {\n return this.features.get(qualifiedId);\n }\n\n /**\n * Gets the first feature of a module - the one a navigation target that names only the module goes to.\n * @param moduleId The module id.\n * @returns The module's first top-level feature, or undefined when the module is unknown or has no features.\n */\n firstFeature(moduleId: string): FeatureNode | undefined {\n return this.findModule(moduleId)?.features[0];\n }\n\n /**\n * Gets the qualified id of the first feature of a module.\n * @param moduleId The module id.\n * @returns The qualified id, or undefined when the module is unknown or has no features.\n */\n firstFeatureId(moduleId: string): string | undefined {\n const feature = this.firstFeature(moduleId);\n return feature ? `${moduleId}.${feature.id}` : undefined;\n }\n\n /**\n * Finds a slice by its qualified id.\n * @param qualifiedId The dotted id from the module down, for example `sales.orders.PlaceOrder`.\n * @returns The slice, or undefined when there is none.\n */\n findSlice(qualifiedId: string): SliceNode | undefined {\n return this.slices.get(qualifiedId);\n }\n\n /**\n * Gets what kind a slice is.\n * @param sliceId The slice's qualified id.\n * @returns The kind, or undefined when there is no such slice.\n */\n kindOf(sliceId: string): SliceKind | undefined {\n return this.findSlice(sliceId)?.kind;\n }\n\n /**\n * Finds every feature that has a given display name, in every module, so a caller can tell when a bare name is ambiguous.\n * @param name The display name, compared without regard to case.\n * @returns The qualified ids of the features with that name, in declaration order.\n */\n findFeaturesByName(name: string): string[] {\n return [...(this.featuresByName.get(name.toLowerCase()) ?? [])];\n }\n\n private indexContainer(path: string, features: FeatureNode[], slices: SliceNode[]): void {\n const seen = new Map<string, string>();\n const featureNames = new Map<string, string>();\n const sliceNames = new Map<string, string>();\n\n for (const feature of features) {\n const qualified = `${path}.${feature.id}`;\n if (!this.claim(seen, qualified, 'feature')) continue;\n\n this.features.set(qualified, feature);\n const key = feature.name.toLowerCase();\n const byName = this.featuresByName.get(key) ?? [];\n byName.push(qualified);\n this.featuresByName.set(key, byName);\n this.reportAmbiguousName(featureNames, 'feature', feature.name, qualified);\n this.indexContainer(qualified, feature.features, feature.slices);\n }\n\n for (const slice of slices) {\n const qualified = `${path}.${slice.id}`;\n if (!this.claim(seen, qualified, 'slice')) continue;\n\n this.slices.set(qualified, slice);\n this.reportAmbiguousName(sliceNames, 'slice', slice.name, qualified);\n }\n }\n\n private claim(seen: Map<string, string>, qualified: string, kind: string): boolean {\n const first = seen.get(qualified);\n if (first === undefined) {\n seen.set(qualified, kind);\n return true;\n }\n\n this.diagnostics.push({\n code: StructureDiagnosticCode.StructureDuplicateId,\n message: `Id '${qualified}' is declared more than once; the first ${first} wins.`,\n id: qualified,\n });\n return false;\n }\n\n private reportAmbiguousName(names: Map<string, string>, kind: string, name: string, qualified: string): void {\n const key = name.toLowerCase();\n const first = names.get(key);\n if (first !== undefined) {\n this.diagnostics.push({\n code: StructureDiagnosticCode.StructureAmbiguousName,\n message: `The ${kind} name '${name}' is used by both '${first}' and '${qualified}'.`,\n id: qualified,\n });\n return;\n }\n\n names.set(key, qualified);\n }\n}\n"],"names":["ApplicationStructureIndex","modules","Map","features","slices","featuresByName","diagnostics","structure","seen","names","module","qualified","id","claim","set","reportAmbiguousName","name","indexContainer","findModule","moduleId","get","findFeature","qualifiedId","firstFeature","firstFeatureId","feature","undefined","findSlice","kindOf","sliceId","kind","findFeaturesByName","toLowerCase","path","featureNames","sliceNames","key","byName","push","slice","first","code","StructureDiagnosticCode","StructureDuplicateId","message","StructureAmbiguousName"],"mappings":";;AAAA;AACA;AAMA;;;;;;;AAOC,IACM,MAAMA,yBAAAA,CAAAA;;AACQC,IAAAA,OAAAA,GAAU,IAAIC,GAAAA,EAAAA;AACdC,IAAAA,QAAAA,GAAW,IAAID,GAAAA,EAAAA;AACfE,IAAAA,MAAAA,GAAS,IAAIF,GAAAA,EAAAA;AACbG,IAAAA,cAAAA,GAAiB,IAAIH,GAAAA,EAAAA;AAEtC,oEACSI,WAAAA,GAAqC,EAAE;AAEhD;;;QAIA,WAAA,CAAY,SAAwC,CAAE;aAAjCC,SAAAA,GAAAA,SAAAA;AACjB,QAAA,MAAMC,OAAO,IAAIN,GAAAA,EAAAA;AACjB,QAAA,MAAMO,QAAQ,IAAIP,GAAAA,EAAAA;AAElB,QAAA,KAAK,MAAMQ,MAAAA,IAAUH,SAAAA,CAAUN,OAAO,CAAE;YACpC,MAAMU,SAAAA,GAAYD,OAAOE,EAAE;AAC3B,YAAA,IAAI,CAAC,IAAI,CAACC,KAAK,CAACL,IAAAA,EAAMG,WAAW,QAAA,CAAA,EAAW;AAE5C,YAAA,IAAI,CAACV,OAAO,CAACa,GAAG,CAACH,SAAAA,EAAWD,MAAAA,CAAAA;AAC5B,YAAA,IAAI,CAACK,mBAAmB,CAACN,OAAO,QAA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AAM,OAAO,EAAE7B,SAAAA,CAAU,EAAE,CAAC;gBACpFC,EAAAA,EAAID;AACR,aAAA,CAAA;AACA,YAAA;AACJ,QAAA;QAEAF,KAAAA,CAAMK,GAAG,CAACsB,GAAAA,EAAKzB,SAAAA,CAAAA;AACnB,IAAA;AACJ;;"}
1
+ {"version":3,"file":"ApplicationStructureIndex.js","sources":["../../../structure/ApplicationStructureIndex.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, FeatureNode, ModuleNode, SliceKind, SliceNode } from '@cratis/scene.model';\nimport { StructureDiagnostic } from './StructureDiagnostic';\nimport { StructureDiagnosticCode } from './StructureDiagnosticCode';\n\n/**\n * Answers the questions navigation, toolbar and template applicability ask of an {@link ApplicationStructure}:\n * does this module, feature or slice exist, which feature comes first in a module, and what kind of slice is it.\n * Pure and read-only; when ids are duplicated the first declaration wins and {@link diagnostics} reports the rest.\n *\n * The C# engine (`ApplicationStructureIndex`) answers the same questions the same way; both are asserted\n * against `application-structure-fixtures.json`.\n */\nexport class ApplicationStructureIndex {\n private readonly modules = new Map<string, ModuleNode>();\n private readonly features = new Map<string, FeatureNode>();\n private readonly slices = new Map<string, SliceNode>();\n private readonly featuresByName = new Map<string, string[]>();\n\n /** The problems found while indexing, in declaration order. */\n readonly diagnostics: StructureDiagnostic[] = [];\n\n /**\n * Initializes a new instance of the {@link ApplicationStructureIndex} class.\n * @param structure The application structure to index.\n */\n constructor(readonly structure: ApplicationStructure) {\n const seen = new Map<string, string>();\n const names = new Map<string, string>();\n\n for (const module of structure.modules) {\n const qualified = module.id;\n if (!this.claim(seen, qualified, 'module')) continue;\n\n this.modules.set(qualified, module);\n this.reportAmbiguousName(names, 'module', module.name, qualified);\n this.indexContainer(qualified, module.features, module.slices ?? []);\n }\n }\n\n /**\n * Finds a module by its id.\n * @param moduleId The module id, for example `sales`.\n * @returns The module, or undefined when there is none.\n */\n findModule(moduleId: string): ModuleNode | undefined {\n return this.modules.get(moduleId);\n }\n\n /**\n * Finds a feature by its qualified id.\n * @param qualifiedId The dotted id from the module down, for example `sales.orders` or `sales.orders.returns`.\n * @returns The feature, or undefined when there is none.\n */\n findFeature(qualifiedId: string): FeatureNode | undefined {\n return this.features.get(qualifiedId);\n }\n\n /**\n * Gets the first feature of a module - the one a navigation target that names only the module goes to.\n * @param moduleId The module id.\n * @returns The module's first top-level feature, or undefined when the module is unknown or has no features.\n */\n firstFeature(moduleId: string): FeatureNode | undefined {\n return this.findModule(moduleId)?.features[0];\n }\n\n /**\n * Gets the qualified id of the first feature of a module.\n * @param moduleId The module id.\n * @returns The qualified id, or undefined when the module is unknown or has no features.\n */\n firstFeatureId(moduleId: string): string | undefined {\n const feature = this.firstFeature(moduleId);\n return feature ? `${moduleId}.${feature.id}` : undefined;\n }\n\n /**\n * Finds a slice by its qualified id.\n * @param qualifiedId The dotted id from the module down, for example `sales.orders.PlaceOrder`.\n * @returns The slice, or undefined when there is none.\n */\n findSlice(qualifiedId: string): SliceNode | undefined {\n return this.slices.get(qualifiedId);\n }\n\n /**\n * Gets what kind a slice is.\n * @param sliceId The slice's qualified id.\n * @returns The kind, or undefined when there is no such slice.\n */\n kindOf(sliceId: string): SliceKind | undefined {\n return this.findSlice(sliceId)?.kind;\n }\n\n /**\n * Finds every feature that has a given display name, in every module, so a caller can tell when a bare name is ambiguous.\n * @param name The display name, compared without regard to case.\n * @returns The qualified ids of the features with that name, in declaration order.\n */\n findFeaturesByName(name: string): string[] {\n return [...(this.featuresByName.get(name.toLowerCase()) ?? [])];\n }\n\n /**\n * Finds the state change slices that accept a command, so a command named by hand can be turned into the slice that owns it.\n * @param command A command name - the slice's `command`, or its `id` when it names none - or a slice's qualified id.\n * @returns The qualified ids of the matching state change slices, in declaration order.\n */\n findSlicesByCommand(command: string): string[] {\n return [...this.slices.entries()]\n .filter(([qualified, slice]) => slice.kind === SliceKind.StateChange && (qualified === command || (slice.command ?? slice.id) === command))\n .map(([qualified]) => qualified);\n }\n\n private indexContainer(path: string, features: FeatureNode[], slices: SliceNode[]): void {\n const seen = new Map<string, string>();\n const featureNames = new Map<string, string>();\n const sliceNames = new Map<string, string>();\n\n for (const feature of features) {\n const qualified = `${path}.${feature.id}`;\n if (!this.claim(seen, qualified, 'feature')) continue;\n\n this.features.set(qualified, feature);\n const key = feature.name.toLowerCase();\n const byName = this.featuresByName.get(key) ?? [];\n byName.push(qualified);\n this.featuresByName.set(key, byName);\n this.reportAmbiguousName(featureNames, 'feature', feature.name, qualified);\n this.indexContainer(qualified, feature.features, feature.slices);\n }\n\n for (const slice of slices) {\n const qualified = `${path}.${slice.id}`;\n if (!this.claim(seen, qualified, 'slice')) continue;\n\n this.slices.set(qualified, slice);\n this.reportAmbiguousName(sliceNames, 'slice', slice.name, qualified);\n }\n }\n\n private claim(seen: Map<string, string>, qualified: string, kind: string): boolean {\n const first = seen.get(qualified);\n if (first === undefined) {\n seen.set(qualified, kind);\n return true;\n }\n\n this.diagnostics.push({\n code: StructureDiagnosticCode.StructureDuplicateId,\n message: `Id '${qualified}' is declared more than once; the first ${first} wins.`,\n id: qualified,\n });\n return false;\n }\n\n private reportAmbiguousName(names: Map<string, string>, kind: string, name: string, qualified: string): void {\n const key = name.toLowerCase();\n const first = names.get(key);\n if (first !== undefined) {\n this.diagnostics.push({\n code: StructureDiagnosticCode.StructureAmbiguousName,\n message: `The ${kind} name '${name}' is used by both '${first}' and '${qualified}'.`,\n id: qualified,\n });\n return;\n }\n\n names.set(key, qualified);\n }\n}\n"],"names":["ApplicationStructureIndex","modules","Map","features","slices","featuresByName","diagnostics","structure","seen","names","module","qualified","id","claim","set","reportAmbiguousName","name","indexContainer","findModule","moduleId","get","findFeature","qualifiedId","firstFeature","firstFeatureId","feature","undefined","findSlice","kindOf","sliceId","kind","findFeaturesByName","toLowerCase","findSlicesByCommand","command","entries","filter","slice","SliceKind","StateChange","map","path","featureNames","sliceNames","key","byName","push","first","code","StructureDiagnos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EAAE+B,KAAAA,CAAM,OAAO,EAAEpC,SAAAA,CAAU,EAAE,CAAC;gBACpFC,EAAAA,EAAID;AACR,aAAA,CAAA;AACA,YAAA;AACJ,QAAA;QAEAF,KAAAA,CAAMK,GAAG,CAAC8B,GAAAA,EAAKjC,SAAAA,CAAAA;AACnB,IAAA;AACJ;;"}
@@ -0,0 +1,13 @@
1
+ import { ToolbarEmphasis } from '@cratis/scene.model';
2
+ import { SliceDialog } from './SliceDialog';
3
+ export interface ResolvedToolbarButton {
4
+ id: string;
5
+ title: string;
6
+ emphasis: ToolbarEmphasis;
7
+ icon?: string;
8
+ slice?: string;
9
+ converted: boolean;
10
+ command?: string;
11
+ dialog?: SliceDialog;
12
+ }
13
+ //# sourceMappingURL=ResolvedToolbarButton.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ResolvedToolbarButton.d.ts","sourceRoot":"","sources":["../../../toolbar/ResolvedToolbarButton.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AACtD,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAK5C,MAAM,WAAW,qBAAqB;IAElC,EAAE,EAAE,MAAM,CAAC;IAGX,KAAK,EAAE,MAAM,CAAC;IAGd,QAAQ,EAAE,eAAe,CAAC;IAG1B,IAAI,CAAC,EAAE,MAAM,CAAC;IAGd,KAAK,CAAC,EAAE,MAAM,CAAC;IAGf,SAAS,EAAE,OAAO,CAAC;IAGnB,OAAO,CAAC,EAAE,MAAM,CAAC;IAGjB,MAAM,CAAC,EAAE,WAAW,CAAC;CACxB"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=ResolvedToolbarButton.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ResolvedToolbarButton.js","sourceRoot":"","sources":["../../../toolbar/ResolvedToolbarButton.ts"],"names":[],"mappings":""}
@@ -0,0 +1,8 @@
1
+ import { SliceDialogSource } from './SliceDialogSource';
2
+ export interface SliceDialog {
3
+ slice: string;
4
+ command: string;
5
+ template: string;
6
+ source: SliceDialogSource;
7
+ }
8
+ //# sourceMappingURL=SliceDialog.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"SliceDialog.d.ts","sourceRoot":"","sources":["../../../toolbar/SliceDialog.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AAKxD,MAAM,WAAW,WAAW;IAExB,KAAK,EAAE,MAAM,CAAC;IAGd,OAAO,EAAE,MAAM,CAAC;IAGhB,QAAQ,EAAE,MAAM,CAAC;IAGjB,MAAM,EAAE,iBAAiB,CAAC;CAC7B"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=SliceDialog.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"SliceDialog.js","sourceRoot":"","sources":["../../../toolbar/SliceDialog.ts"],"names":[],"mappings":""}
@@ -0,0 +1,5 @@
1
+ export declare enum SliceDialogSource {
2
+ Slice = "slice",
3
+ Default = "default"
4
+ }
5
+ //# sourceMappingURL=SliceDialogSource.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"SliceDialogSource.d.ts","sourceRoot":"","sources":["../../../toolbar/SliceDialogSource.ts"],"names":[],"mappings":"AAMA,oBAAY,iBAAiB;IAEzB,KAAK,UAAU;IAGf,OAAO,YAAY;CACtB"}
@@ -0,0 +1,12 @@
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
+ * Where a slice's dialog template comes from.
5
+ */ var SliceDialogSource = /*#__PURE__*/ function(SliceDialogSource) {
6
+ /** The slice names its own dialog template. */ SliceDialogSource["Slice"] = "slice";
7
+ /** The slice names none, so the default form dialog is used. */ SliceDialogSource["Default"] = "default";
8
+ return SliceDialogSource;
9
+ }({});
10
+
11
+ export { SliceDialogSource };
12
+ //# sourceMappingURL=SliceDialogSource.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"SliceDialogSource.js","sources":["../../../toolbar/SliceDialogSource.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 * Where a slice's dialog template comes from.\n */\nexport enum SliceDialogSource {\n /** The slice names its own dialog template. */\n Slice = 'slice',\n\n /** The slice names none, so the default form dialog is used. */\n Default = 'default',\n}\n"],"names":["SliceDialogSource"],"mappings":"AAAA;AACA;AAEA;;IAGO,IAAKA,iBAAAA,iBAAAA,SAAAA,iBAAAA,EAAAA;oDACqC,iBAAA,CAAA,OAAA,CAAA,GAAA,OAAA;qEAGiB,iBAAA,CAAA,SAAA,CAAA,GAAA,SAAA;AAJtDA,IAAAA,OAAAA,iBAAAA;AAMX,CAAA,CAAA,EAAA;;"}
@@ -0,0 +1,9 @@
1
+ import { ToolbarDiagnosticCode } from './ToolbarDiagnosticCode';
2
+ import { ToolbarDiagnosticSeverity } from './ToolbarDiagnosticSeverity';
3
+ export interface ToolbarDiagnostic {
4
+ code: ToolbarDiagnosticCode;
5
+ severity: ToolbarDiagnosticSeverity;
6
+ message: string;
7
+ button: string;
8
+ }
9
+ //# sourceMappingURL=ToolbarDiagnostic.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ToolbarDiagnostic.d.ts","sourceRoot":"","sources":["../../../toolbar/ToolbarDiagnostic.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,qBAAqB,EAAE,MAAM,yBAAyB,CAAC;AAChE,OAAO,EAAE,yBAAyB,EAAE,MAAM,6BAA6B,CAAC;AAKxE,MAAM,WAAW,iBAAiB;IAE9B,IAAI,EAAE,qBAAqB,CAAC;IAG5B,QAAQ,EAAE,yBAAyB,CAAC;IAGpC,OAAO,EAAE,MAAM,CAAC;IAGhB,MAAM,EAAE,MAAM,CAAC;CAClB"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=ToolbarDiagnostic.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ToolbarDiagnostic.js","sourceRoot":"","sources":["../../../toolbar/ToolbarDiagnostic.ts"],"names":[],"mappings":""}
@@ -0,0 +1,6 @@
1
+ export declare enum ToolbarDiagnosticCode {
2
+ ToolbarButtonSliceNotFound = "toolbarButtonSliceNotFound",
3
+ ToolbarButtonSliceNotStateChange = "toolbarButtonSliceNotStateChange",
4
+ ToolbarButtonSliceEmpty = "toolbarButtonSliceEmpty"
5
+ }
6
+ //# sourceMappingURL=ToolbarDiagnosticCode.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ToolbarDiagnosticCode.d.ts","sourceRoot":"","sources":["../../../toolbar/ToolbarDiagnosticCode.ts"],"names":[],"mappings":"AAOA,oBAAY,qBAAqB;IAE7B,0BAA0B,+BAA+B;IAGzD,gCAAgC,qCAAqC;IAGrE,uBAAuB,4BAA4B;CACtD"}
@@ -0,0 +1,14 @@
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
+ * What is wrong with a toolbar button. The values are shared with the C# engine so both report the same code for
5
+ * the same toolbar.
6
+ */ var ToolbarDiagnosticCode = /*#__PURE__*/ function(ToolbarDiagnosticCode) {
7
+ /** A button invokes a slice the application structure does not have. */ ToolbarDiagnosticCode["ToolbarButtonSliceNotFound"] = "toolbarButtonSliceNotFound";
8
+ /** A button invokes a slice that is not a state change; state views and automations never take user input. */ ToolbarDiagnosticCode["ToolbarButtonSliceNotStateChange"] = "toolbarButtonSliceNotStateChange";
9
+ /** A button has no slice yet. It is allowed while designing, and flagged. */ ToolbarDiagnosticCode["ToolbarButtonSliceEmpty"] = "toolbarButtonSliceEmpty";
10
+ return ToolbarDiagnosticCode;
11
+ }({});
12
+
13
+ export { ToolbarDiagnosticCode };
14
+ //# sourceMappingURL=ToolbarDiagnosticCode.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ToolbarDiagnosticCode.js","sources":["../../../toolbar/ToolbarDiagnosticCode.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 * What is wrong with a toolbar button. The values are shared with the C# engine so both report the same code for\n * the same toolbar.\n */\nexport enum ToolbarDiagnosticCode {\n /** A button invokes a slice the application structure does not have. */\n ToolbarButtonSliceNotFound = 'toolbarButtonSliceNotFound',\n\n /** A button invokes a slice that is not a state change; state views and automations never take user input. */\n ToolbarButtonSliceNotStateChange = 'toolbarButtonSliceNotStateChange',\n\n /** A button has no slice yet. It is allowed while designing, and flagged. */\n ToolbarButtonSliceEmpty = 'toolbarButtonSliceEmpty',\n}\n"],"names":["ToolbarDiagnosticCode"],"mappings":"AAAA;AACA;AAEA;;;IAIO,IAAKA,qBAAAA,iBAAAA,SAAAA,qBAAAA,EAAAA;6EAC8D,qBAAA,CAAA,4BAAA,CAAA,GAAA,4BAAA;mHAGsC,qBAAA,CAAA,kCAAA,CAAA,GAAA,kCAAA;kFAGjC,qBAAA,CAAA,yBAAA,CAAA,GAAA,yBAAA;AAPnEA,IAAAA,OAAAA,qBAAAA;AASX,CAAA,CAAA,EAAA;;"}
@@ -0,0 +1,5 @@
1
+ export declare enum ToolbarDiagnosticSeverity {
2
+ Error = "error",
3
+ Warning = "warning"
4
+ }
5
+ //# sourceMappingURL=ToolbarDiagnosticSeverity.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ToolbarDiagnosticSeverity.d.ts","sourceRoot":"","sources":["../../../toolbar/ToolbarDiagnosticSeverity.ts"],"names":[],"mappings":"AAMA,oBAAY,yBAAyB;IAEjC,KAAK,UAAU;IAGf,OAAO,YAAY;CACtB"}