@cratis/scene.engine 4.11.0 → 4.13.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 (218) hide show
  1. package/dist/cjs/forms/CommandFormLayoutDiagnosticCode.js +20 -0
  2. package/dist/cjs/forms/CommandFormLayoutDiagnosticCode.js.map +1 -0
  3. package/dist/cjs/forms/commitCommandFormLayoutDraft.js +12 -0
  4. package/dist/cjs/forms/commitCommandFormLayoutDraft.js.map +1 -0
  5. package/dist/cjs/forms/defaultCommandFormLayout.js +23 -0
  6. package/dist/cjs/forms/defaultCommandFormLayout.js.map +1 -0
  7. package/dist/cjs/forms/formWidthToCss.js +24 -0
  8. package/dist/cjs/forms/formWidthToCss.js.map +1 -0
  9. package/dist/cjs/forms/normalizeCommandFormLayout.js +42 -0
  10. package/dist/cjs/forms/normalizeCommandFormLayout.js.map +1 -0
  11. package/dist/cjs/forms/parseFormWidth.js +34 -0
  12. package/dist/cjs/forms/parseFormWidth.js.map +1 -0
  13. package/dist/cjs/forms/preserveDirtyCommandValues.js +15 -0
  14. package/dist/cjs/forms/preserveDirtyCommandValues.js.map +1 -0
  15. package/dist/cjs/forms/resizeCommandFormColumn.js +27 -0
  16. package/dist/cjs/forms/resizeCommandFormColumn.js.map +1 -0
  17. package/dist/cjs/forms/updateCommandFormFieldPlacement.js +27 -0
  18. package/dist/cjs/forms/updateCommandFormFieldPlacement.js.map +1 -0
  19. package/dist/cjs/forms/validateCommandFormLayout.js +72 -0
  20. package/dist/cjs/forms/validateCommandFormLayout.js.map +1 -0
  21. package/dist/cjs/index.js +40 -0
  22. package/dist/cjs/index.js.map +1 -1
  23. package/dist/cjs/navigation/NavigationDiagnosticCode.js +19 -0
  24. package/dist/cjs/navigation/NavigationDiagnosticCode.js.map +1 -0
  25. package/dist/cjs/navigation/collectOutlets.js +45 -0
  26. package/dist/cjs/navigation/collectOutlets.js.map +1 -0
  27. package/dist/cjs/navigation/diagnoseNavigation.js +116 -0
  28. package/dist/cjs/navigation/diagnoseNavigation.js.map +1 -0
  29. package/dist/cjs/navigation/findHostingCycles.js +43 -0
  30. package/dist/cjs/navigation/findHostingCycles.js.map +1 -0
  31. package/dist/cjs/navigation/navigationEntriesFrom.js +19 -0
  32. package/dist/cjs/navigation/navigationEntriesFrom.js.map +1 -0
  33. package/dist/cjs/navigation/navigationRoute.js +25 -0
  34. package/dist/cjs/navigation/navigationRoute.js.map +1 -0
  35. package/dist/cjs/packageVersionRange.js +16 -0
  36. package/dist/cjs/packageVersionRange.js.map +1 -1
  37. package/dist/cjs/templates/TemplateCatalogKind.js +15 -0
  38. package/dist/cjs/templates/TemplateCatalogKind.js.map +1 -0
  39. package/dist/cjs/templates/describeTemplateCatalog.js +89 -0
  40. package/dist/cjs/templates/describeTemplateCatalog.js.map +1 -0
  41. package/dist/cjs/templates/templateMetadataRules.js +32 -0
  42. package/dist/cjs/templates/templateMetadataRules.js.map +1 -0
  43. package/dist/cjs/templates/validateTemplateMetadata.js +50 -0
  44. package/dist/cjs/templates/validateTemplateMetadata.js.map +1 -0
  45. package/dist/cjs/validateNavigationDestinations.js +12 -38
  46. package/dist/cjs/validateNavigationDestinations.js.map +1 -1
  47. package/dist/esm/forms/CommandFormLayoutDiagnostic.d.ts +7 -0
  48. package/dist/esm/forms/CommandFormLayoutDiagnostic.d.ts.map +1 -0
  49. package/dist/esm/forms/CommandFormLayoutDiagnostic.js +2 -0
  50. package/dist/esm/forms/CommandFormLayoutDiagnostic.js.map +1 -0
  51. package/dist/esm/forms/CommandFormLayoutDiagnosticCode.d.ts +11 -0
  52. package/dist/esm/forms/CommandFormLayoutDiagnosticCode.d.ts.map +1 -0
  53. package/dist/esm/forms/CommandFormLayoutDiagnosticCode.js +18 -0
  54. package/dist/esm/forms/CommandFormLayoutDiagnosticCode.js.map +1 -0
  55. package/dist/esm/forms/CommandFormLayoutDraft.d.ts +9 -0
  56. package/dist/esm/forms/CommandFormLayoutDraft.d.ts.map +1 -0
  57. package/dist/esm/forms/CommandFormLayoutDraft.js +2 -0
  58. package/dist/esm/forms/CommandFormLayoutDraft.js.map +1 -0
  59. package/dist/esm/forms/commitCommandFormLayoutDraft.d.ts +4 -0
  60. package/dist/esm/forms/commitCommandFormLayoutDraft.d.ts.map +1 -0
  61. package/dist/esm/forms/commitCommandFormLayoutDraft.js +10 -0
  62. package/dist/esm/forms/commitCommandFormLayoutDraft.js.map +1 -0
  63. package/dist/esm/forms/defaultCommandFormLayout.d.ts +3 -0
  64. package/dist/esm/forms/defaultCommandFormLayout.d.ts.map +1 -0
  65. package/dist/esm/forms/defaultCommandFormLayout.js +21 -0
  66. package/dist/esm/forms/defaultCommandFormLayout.js.map +1 -0
  67. package/dist/esm/forms/formWidthToCss.d.ts +3 -0
  68. package/dist/esm/forms/formWidthToCss.d.ts.map +1 -0
  69. package/dist/esm/forms/formWidthToCss.js +22 -0
  70. package/dist/esm/forms/formWidthToCss.js.map +1 -0
  71. package/dist/esm/forms/index.d.ts +13 -0
  72. package/dist/esm/forms/index.d.ts.map +1 -0
  73. package/dist/esm/forms/index.js +13 -0
  74. package/dist/esm/forms/index.js.map +1 -0
  75. package/dist/esm/forms/normalizeCommandFormLayout.d.ts +8 -0
  76. package/dist/esm/forms/normalizeCommandFormLayout.d.ts.map +1 -0
  77. package/dist/esm/forms/normalizeCommandFormLayout.js +40 -0
  78. package/dist/esm/forms/normalizeCommandFormLayout.js.map +1 -0
  79. package/dist/esm/forms/parseFormWidth.d.ts +3 -0
  80. package/dist/esm/forms/parseFormWidth.d.ts.map +1 -0
  81. package/dist/esm/forms/parseFormWidth.js +32 -0
  82. package/dist/esm/forms/parseFormWidth.js.map +1 -0
  83. package/dist/esm/forms/preserveDirtyCommandValues.d.ts +2 -0
  84. package/dist/esm/forms/preserveDirtyCommandValues.d.ts.map +1 -0
  85. package/dist/esm/forms/preserveDirtyCommandValues.js +13 -0
  86. package/dist/esm/forms/preserveDirtyCommandValues.js.map +1 -0
  87. package/dist/esm/forms/resizeCommandFormColumn.d.ts +4 -0
  88. package/dist/esm/forms/resizeCommandFormColumn.d.ts.map +1 -0
  89. package/dist/esm/forms/resizeCommandFormColumn.js +25 -0
  90. package/dist/esm/forms/resizeCommandFormColumn.js.map +1 -0
  91. package/dist/esm/forms/updateCommandFormFieldPlacement.d.ts +4 -0
  92. package/dist/esm/forms/updateCommandFormFieldPlacement.d.ts.map +1 -0
  93. package/dist/esm/forms/updateCommandFormFieldPlacement.js +25 -0
  94. package/dist/esm/forms/updateCommandFormFieldPlacement.js.map +1 -0
  95. package/dist/esm/forms/validateCommandFormLayout.d.ts +4 -0
  96. package/dist/esm/forms/validateCommandFormLayout.d.ts.map +1 -0
  97. package/dist/esm/forms/validateCommandFormLayout.js +70 -0
  98. package/dist/esm/forms/validateCommandFormLayout.js.map +1 -0
  99. package/dist/esm/index.d.ts +3 -0
  100. package/dist/esm/index.d.ts.map +1 -1
  101. package/dist/esm/index.js +19 -1
  102. package/dist/esm/index.js.map +1 -1
  103. package/dist/esm/navigation/NavigationDiagnostic.d.ts +7 -0
  104. package/dist/esm/navigation/NavigationDiagnostic.d.ts.map +1 -0
  105. package/dist/esm/navigation/NavigationDiagnostic.js +2 -0
  106. package/dist/esm/navigation/NavigationDiagnostic.js.map +1 -0
  107. package/dist/esm/navigation/NavigationDiagnosticCode.d.ts +9 -0
  108. package/dist/esm/navigation/NavigationDiagnosticCode.d.ts.map +1 -0
  109. package/dist/esm/navigation/NavigationDiagnosticCode.js +17 -0
  110. package/dist/esm/navigation/NavigationDiagnosticCode.js.map +1 -0
  111. package/dist/esm/navigation/NavigationEntry.d.ts +6 -0
  112. package/dist/esm/navigation/NavigationEntry.d.ts.map +1 -0
  113. package/dist/esm/navigation/NavigationEntry.js +2 -0
  114. package/dist/esm/navigation/NavigationEntry.js.map +1 -0
  115. package/dist/esm/navigation/NavigationGraph.d.ts +10 -0
  116. package/dist/esm/navigation/NavigationGraph.d.ts.map +1 -0
  117. package/dist/esm/navigation/NavigationGraph.js +2 -0
  118. package/dist/esm/navigation/NavigationGraph.js.map +1 -0
  119. package/dist/esm/navigation/OutletOwner.d.ts +7 -0
  120. package/dist/esm/navigation/OutletOwner.d.ts.map +1 -0
  121. package/dist/esm/navigation/OutletOwner.js +2 -0
  122. package/dist/esm/navigation/OutletOwner.js.map +1 -0
  123. package/dist/esm/navigation/collectOutlets.d.ts +5 -0
  124. package/dist/esm/navigation/collectOutlets.d.ts.map +1 -0
  125. package/dist/esm/navigation/collectOutlets.js +43 -0
  126. package/dist/esm/navigation/collectOutlets.js.map +1 -0
  127. package/dist/esm/navigation/diagnoseNavigation.d.ts +5 -0
  128. package/dist/esm/navigation/diagnoseNavigation.d.ts.map +1 -0
  129. package/dist/esm/navigation/diagnoseNavigation.js +114 -0
  130. package/dist/esm/navigation/diagnoseNavigation.js.map +1 -0
  131. package/dist/esm/navigation/findHostingCycles.d.ts +2 -0
  132. package/dist/esm/navigation/findHostingCycles.d.ts.map +1 -0
  133. package/dist/esm/navigation/findHostingCycles.js +41 -0
  134. package/dist/esm/navigation/findHostingCycles.js.map +1 -0
  135. package/dist/esm/navigation/index.d.ts +8 -0
  136. package/dist/esm/navigation/index.d.ts.map +1 -0
  137. package/dist/esm/navigation/index.js +8 -0
  138. package/dist/esm/navigation/index.js.map +1 -0
  139. package/dist/esm/navigation/navigationEntriesFrom.d.ts +4 -0
  140. package/dist/esm/navigation/navigationEntriesFrom.d.ts.map +1 -0
  141. package/dist/esm/navigation/navigationEntriesFrom.js +17 -0
  142. package/dist/esm/navigation/navigationEntriesFrom.js.map +1 -0
  143. package/dist/esm/navigation/navigationRoute.d.ts +5 -0
  144. package/dist/esm/navigation/navigationRoute.d.ts.map +1 -0
  145. package/dist/esm/navigation/navigationRoute.js +22 -0
  146. package/dist/esm/navigation/navigationRoute.js.map +1 -0
  147. package/dist/esm/packageVersionRange.d.ts +2 -0
  148. package/dist/esm/packageVersionRange.d.ts.map +1 -1
  149. package/dist/esm/packageVersionRange.js +15 -1
  150. package/dist/esm/packageVersionRange.js.map +1 -1
  151. package/dist/esm/templates/TemplateCatalogEntry.d.ts +20 -0
  152. package/dist/esm/templates/TemplateCatalogEntry.d.ts.map +1 -0
  153. package/dist/esm/templates/TemplateCatalogEntry.js +2 -0
  154. package/dist/esm/templates/TemplateCatalogEntry.js.map +1 -0
  155. package/dist/esm/templates/TemplateCatalogKind.d.ts +6 -0
  156. package/dist/esm/templates/TemplateCatalogKind.d.ts.map +1 -0
  157. package/dist/esm/templates/TemplateCatalogKind.js +13 -0
  158. package/dist/esm/templates/TemplateCatalogKind.js.map +1 -0
  159. package/dist/esm/templates/TemplateSource.d.ts +8 -0
  160. package/dist/esm/templates/TemplateSource.d.ts.map +1 -0
  161. package/dist/esm/templates/TemplateSource.js +2 -0
  162. package/dist/esm/templates/TemplateSource.js.map +1 -0
  163. package/dist/esm/templates/describeTemplateCatalog.d.ts +4 -0
  164. package/dist/esm/templates/describeTemplateCatalog.d.ts.map +1 -0
  165. package/dist/esm/templates/describeTemplateCatalog.js +87 -0
  166. package/dist/esm/templates/describeTemplateCatalog.js.map +1 -0
  167. package/dist/esm/templates/index.d.ts +7 -0
  168. package/dist/esm/templates/index.d.ts.map +1 -0
  169. package/dist/esm/templates/index.js +7 -0
  170. package/dist/esm/templates/index.js.map +1 -0
  171. package/dist/esm/templates/templateMetadataRules.d.ts +3 -0
  172. package/dist/esm/templates/templateMetadataRules.d.ts.map +1 -0
  173. package/dist/esm/templates/templateMetadataRules.js +29 -0
  174. package/dist/esm/templates/templateMetadataRules.js.map +1 -0
  175. package/dist/esm/templates/validateTemplateMetadata.d.ts +3 -0
  176. package/dist/esm/templates/validateTemplateMetadata.d.ts.map +1 -0
  177. package/dist/esm/templates/validateTemplateMetadata.js +48 -0
  178. package/dist/esm/templates/validateTemplateMetadata.js.map +1 -0
  179. package/dist/esm/tsconfig.tsbuildinfo +1 -1
  180. package/dist/esm/validateNavigationDestinations.d.ts +5 -5
  181. package/dist/esm/validateNavigationDestinations.d.ts.map +1 -1
  182. package/dist/esm/validateNavigationDestinations.js +12 -38
  183. package/dist/esm/validateNavigationDestinations.js.map +1 -1
  184. package/forms/CommandFormLayoutDiagnostic.ts +13 -0
  185. package/forms/CommandFormLayoutDiagnosticCode.ts +16 -0
  186. package/forms/CommandFormLayoutDraft.ts +15 -0
  187. package/forms/commitCommandFormLayoutDraft.ts +12 -0
  188. package/forms/defaultCommandFormLayout.ts +12 -0
  189. package/forms/formWidthToCss.ts +21 -0
  190. package/forms/index.ts +15 -0
  191. package/forms/normalizeCommandFormLayout.ts +39 -0
  192. package/forms/parseFormWidth.ts +20 -0
  193. package/forms/preserveDirtyCommandValues.ts +13 -0
  194. package/forms/resizeCommandFormColumn.ts +23 -0
  195. package/forms/updateCommandFormFieldPlacement.ts +22 -0
  196. package/forms/validateCommandFormLayout.ts +74 -0
  197. package/index.ts +3 -0
  198. package/navigation/NavigationDiagnostic.ts +18 -0
  199. package/navigation/NavigationDiagnosticCode.ts +26 -0
  200. package/navigation/NavigationEntry.ts +16 -0
  201. package/navigation/NavigationGraph.ts +26 -0
  202. package/navigation/OutletOwner.ts +13 -0
  203. package/navigation/collectOutlets.ts +36 -0
  204. package/navigation/diagnoseNavigation.ts +136 -0
  205. package/navigation/findHostingCycles.ts +41 -0
  206. package/navigation/index.ts +10 -0
  207. package/navigation/navigationEntriesFrom.ts +16 -0
  208. package/navigation/navigationRoute.ts +25 -0
  209. package/package.json +3 -3
  210. package/packageVersionRange.ts +18 -0
  211. package/templates/TemplateCatalogEntry.ts +35 -0
  212. package/templates/TemplateCatalogKind.ts +11 -0
  213. package/templates/TemplateSource.ts +15 -0
  214. package/templates/describeTemplateCatalog.ts +92 -0
  215. package/templates/index.ts +9 -0
  216. package/templates/templateMetadataRules.ts +25 -0
  217. package/templates/validateTemplateMetadata.ts +55 -0
  218. package/validateNavigationDestinations.ts +12 -32
@@ -1,47 +1,21 @@
1
1
  'use strict';
2
2
 
3
+ var diagnoseNavigation = require('./navigation/diagnoseNavigation.js');
4
+
3
5
  // Copyright (c) Cratis. All rights reserved.
4
6
  // Licensed under the MIT license. See LICENSE file in the project root for full license information.
5
7
  /**
6
- * Validates destinations against the outlet/route declarations owned by layouts and templates.
8
+ * Validates destinations against the outlet/route declarations owned by layouts and templates, and - when
9
+ * the screens and dialog templates are given - against the targets that actually exist.
10
+ *
11
+ * A shorthand for {@link diagnoseNavigation} over destinations without entry identities.
7
12
  */ function validateNavigationDestinations(destinations, surfaces = {}) {
8
- const diagnostics = [];
9
- const outlets = new Set();
10
- const routes = new Set();
11
- for (const surface of [
12
- ...surfaces.layouts ?? [],
13
- ...surfaces.screenTemplates ?? []
14
- ]){
15
- for (const outlet of surface.outlets ?? []){
16
- if (outlets.has(outlet.name)) diagnostics.push({
17
- code: 'duplicateOutlet',
18
- message: `Outlet '${outlet.name}' is declared more than once.`
19
- });
20
- outlets.add(outlet.name);
21
- }
22
- }
23
- for (const destination of destinations){
24
- if (destination.outlet && !outlets.has(destination.outlet)) {
25
- diagnostics.push({
26
- code: 'missingOutlet',
27
- message: `Destination targets missing outlet '${destination.outlet}'.`
28
- });
29
- }
30
- if (destination.route) {
31
- if (routes.has(destination.route)) diagnostics.push({
32
- code: 'duplicateRoute',
33
- message: `Route '${destination.route}' is used by more than one destination.`
34
- });
35
- routes.add(destination.route);
36
- }
37
- if (!destination.screen && !destination.module && !destination.route && !destination.dialog) {
38
- diagnostics.push({
39
- code: 'unavailableTarget',
40
- message: 'Destination must name a screen, stable identity, route or dialog.'
41
- });
42
- }
43
- }
44
- return diagnostics;
13
+ return diagnoseNavigation.diagnoseNavigation({
14
+ entries: destinations.map((destination)=>({
15
+ destination
16
+ })),
17
+ ...surfaces
18
+ });
45
19
  }
46
20
 
47
21
  exports.validateNavigationDestinations = validateNavigationDestinations;
@@ -1 +1 @@
1
- {"version":3,"file":"validateNavigationDestinations.js","sources":["../../validateNavigationDestinations.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 { DestinationReference, Layout, ScreenTemplate } from '@cratis/scene.model';\n\nexport interface NavigationDestinationDiagnostic {\n code: string;\n message: string;\n}\n\n/**\n * Validates destinations against the outlet/route declarations owned by layouts and templates.\n */\nexport function validateNavigationDestinations(\n destinations: DestinationReference[],\n surfaces: { layouts?: Layout[]; screenTemplates?: ScreenTemplate[] } = {},\n): NavigationDestinationDiagnostic[] {\n const diagnostics: NavigationDestinationDiagnostic[] = [];\n const outlets = new Set<string>();\n const routes = new Set<string>();\n\n for (const surface of [...(surfaces.layouts ?? []), ...(surfaces.screenTemplates ?? [])]) {\n for (const outlet of surface.outlets ?? []) {\n if (outlets.has(outlet.name)) diagnostics.push({ code: 'duplicateOutlet', message: `Outlet '${outlet.name}' is declared more than once.` });\n outlets.add(outlet.name);\n }\n }\n\n for (const destination of destinations) {\n if (destination.outlet && !outlets.has(destination.outlet)) {\n diagnostics.push({ code: 'missingOutlet', message: `Destination targets missing outlet '${destination.outlet}'.` });\n }\n if (destination.route) {\n if (routes.has(destination.route)) diagnostics.push({ code: 'duplicateRoute', message: `Route '${destination.route}' is used by more than one destination.` });\n routes.add(destination.route);\n }\n if (!destination.screen && !destination.module && !destination.route && !destination.dialog) {\n diagnostics.push({ code: 'unavailableTarget', message: 'Destination must name a screen, stable identity, route or dialog.' });\n }\n }\n\n return diagnostics;\n}\n"],"names":["validateNavigationDestinations","destinations","surfaces","diagnostics","outlets","Set","routes","surface","layouts","screenTemplates","outlet","has","name","push","code","message","add","destination","route","screen","module","dialog"],"mappings":";;AAAA;AACA;AASA;;AAEC,IACM,SAASA,8BAAAA,CACZC,YAAoC,EACpCC,QAAAA,GAAuE,EAAE,EAAA;AAEzE,IAAA,MAAMC,cAAiD,EAAE;AACzD,IAAA,MAAMC,UAAU,IAAIC,GAAAA,EAAAA;AACpB,IAAA,MAAMC,SAAS,IAAID,GAAAA,EAAAA;AAEnB,IAAA,KAAK,MAAME,OAAAA,IAAW;WAAKL,QAAAA,CAASM,OAAO,IAAI,EAAE;WAAON,QAAAA,CAASO,eAAe,IAAI;KAAI,CAAE;AACtF,QAAA,KAAK,MAAMC,MAAAA,IAAUH,OAAAA,CAAQH,OAAO,IAAI,EAAE,CAAE;YACxC,IAAIA,OAAAA,CAAQO,GAAG,CAACD,MAAAA,CAAOE,IAAI,CAAA,EAAGT,WAAAA,CAAYU,IAAI,CAAC;gBAAEC,IAAAA,EAAM,iBAAA;AAAmBC,gBAAAA,OAAAA,EAAS,CAAC,QAAQ,EAAEL,OAAOE,IAAI,CAAC,6BAA6B;AAAE,aAAA,CAAA;YACzIR,OAAAA,CAAQY,GAAG,CAACN,MAAAA,CAAOE,IAAI,CAAA;AAC3B,QAAA;AACJ,IAAA;IAEA,KAAK,MAAMK,eAAehB,YAAAA,CAAc;QACpC,IAAIgB,WAAAA,CAAYP,MAAM,IAAI,CAACN,QAAQO,GAAG,CAACM,WAAAA,CAAYP,MAAM,CAAA,EAAG;AACxDP,YAAAA,WAAAA,CAAYU,IAAI,CAAC;gBAAEC,IAAAA,EAAM,eAAA;AAAiBC,gBAAAA,OAAAA,EAAS,CAAC,oCAAoC,EAAEE,YAAYP,MAAM,CAAC,EAAE;AAAE,aAAA,CAAA;AACrH,QAAA;QACA,IAAIO,WAAAA,CAAYC,KAAK,EAAE;YACnB,IAAIZ,MAAAA,CAAOK,GAAG,CAACM,WAAAA,CAAYC,KAAK,CAAA,EAAGf,WAAAA,CAAYU,IAAI,CAAC;gBAAEC,IAAAA,EAAM,gBAAA;AAAkBC,gBAAAA,OAAAA,EAAS,CAAC,OAAO,EAAEE,YAAYC,KAAK,CAAC,uCAAuC;AAAE,aAAA,CAAA;YAC5JZ,MAAAA,CAAOU,GAAG,CAACC,WAAAA,CAAYC,KAAK,CAAA;AAChC,QAAA;AACA,QAAA,IAAI,CAACD,WAAAA,CAAYE,MAAM,IAAI,CAACF,WAAAA,CAAYG,MAAM,IAAI,CAACH,YAAYC,KAAK,IAAI,CAACD,WAAAA,CAAYI,MAAM,EAAE;AACzFlB,YAAAA,WAAAA,CAAYU,IAAI,CAAC;gBAAEC,IAAAA,EAAM,mBAAA;gBAAqBC,OAAAA,EAAS;AAAoE,aAAA,CAAA;AAC/H,QAAA;AACJ,IAAA;IAEA,OAAOZ,WAAAA;AACX;;"}
1
+ {"version":3,"file":"validateNavigationDestinations.js","sources":["../../validateNavigationDestinations.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 { DestinationReference, DialogTemplate, Layout, Screen, ScreenTemplate } from '@cratis/scene.model';\nimport { NavigationDiagnostic, diagnoseNavigation } from './navigation';\n\n/**\n * A navigation problem as {@link validateNavigationDestinations} reports it.\n */\nexport type NavigationDestinationDiagnostic = NavigationDiagnostic;\n\n/**\n * Validates destinations against the outlet/route declarations owned by layouts and templates, and - when\n * the screens and dialog templates are given - against the targets that actually exist.\n *\n * A shorthand for {@link diagnoseNavigation} over destinations without entry identities.\n */\nexport function validateNavigationDestinations(\n destinations: DestinationReference[],\n surfaces: { layouts?: Layout[]; screenTemplates?: ScreenTemplate[]; screens?: Screen[]; dialogTemplates?: DialogTemplate[] } = {},\n): NavigationDestinationDiagnostic[] {\n return diagnoseNavigation({ entries: destinations.map(destination => ({ destination })), ...surfaces });\n}\n"],"names":["validateNavigationDestinations","destinations","surfaces","diagnoseNavigation","entries","map","destination"],"mappings":";;;;AAAA;AACA;AAUA;;;;;AAKC,IACM,SAASA,8BAAAA,CACZC,YAAoC,EACpCC,QAAAA,GAA+H,EAAE,EAAA;AAEjI,IAAA,OAAOC,qCAAAA,CAAmB;AAAEC,QAAAA,OAAAA,EAASH,YAAAA,CAAaI,GAAG,CAACC,CAAAA,eAAgB;AAAEA,gBAAAA;aAAY,CAAA,CAAA;AAAK,QAAA,GAAGJ;AAAS,KAAA,CAAA;AACzG;;"}
@@ -0,0 +1,7 @@
1
+ import { CommandFormLayoutDiagnosticCode } from './CommandFormLayoutDiagnosticCode';
2
+ export interface CommandFormLayoutDiagnostic {
3
+ code: CommandFormLayoutDiagnosticCode;
4
+ message: string;
5
+ path: string;
6
+ }
7
+ //# sourceMappingURL=CommandFormLayoutDiagnostic.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"CommandFormLayoutDiagnostic.d.ts","sourceRoot":"","sources":["../../../forms/CommandFormLayoutDiagnostic.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,+BAA+B,EAAE,MAAM,mCAAmC,CAAC;AAKpF,MAAM,WAAW,2BAA2B;IACxC,IAAI,EAAE,+BAA+B,CAAC;IACtC,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,EAAE,MAAM,CAAC;CAChB"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=CommandFormLayoutDiagnostic.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"CommandFormLayoutDiagnostic.js","sourceRoot":"","sources":["../../../forms/CommandFormLayoutDiagnostic.ts"],"names":[],"mappings":""}
@@ -0,0 +1,11 @@
1
+ export declare enum CommandFormLayoutDiagnosticCode {
2
+ EmptyColumns = "emptyColumns",
3
+ DuplicateColumn = "duplicateColumn",
4
+ InvalidColumnIndex = "invalidColumnIndex",
5
+ InvalidWidth = "invalidWidth",
6
+ DuplicatePlacement = "duplicatePlacement",
7
+ InvalidPlacement = "invalidPlacement",
8
+ MissingField = "missingField",
9
+ OutOfBoundsPlacement = "outOfBoundsPlacement"
10
+ }
11
+ //# sourceMappingURL=CommandFormLayoutDiagnosticCode.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"CommandFormLayoutDiagnosticCode.d.ts","sourceRoot":"","sources":["../../../forms/CommandFormLayoutDiagnosticCode.ts"],"names":[],"mappings":"AAMA,oBAAY,+BAA+B;IACvC,YAAY,iBAAiB;IAC7B,eAAe,oBAAoB;IACnC,kBAAkB,uBAAuB;IACzC,YAAY,iBAAiB;IAC7B,kBAAkB,uBAAuB;IACzC,gBAAgB,qBAAqB;IACrC,YAAY,iBAAiB;IAC7B,oBAAoB,yBAAyB;CAChD"}
@@ -0,0 +1,18 @@
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
+ * Diagnostic codes for command-form geometry validation.
5
+ */ var CommandFormLayoutDiagnosticCode = /*#__PURE__*/ function(CommandFormLayoutDiagnosticCode) {
6
+ CommandFormLayoutDiagnosticCode["EmptyColumns"] = "emptyColumns";
7
+ CommandFormLayoutDiagnosticCode["DuplicateColumn"] = "duplicateColumn";
8
+ CommandFormLayoutDiagnosticCode["InvalidColumnIndex"] = "invalidColumnIndex";
9
+ CommandFormLayoutDiagnosticCode["InvalidWidth"] = "invalidWidth";
10
+ CommandFormLayoutDiagnosticCode["DuplicatePlacement"] = "duplicatePlacement";
11
+ CommandFormLayoutDiagnosticCode["InvalidPlacement"] = "invalidPlacement";
12
+ CommandFormLayoutDiagnosticCode["MissingField"] = "missingField";
13
+ CommandFormLayoutDiagnosticCode["OutOfBoundsPlacement"] = "outOfBoundsPlacement";
14
+ return CommandFormLayoutDiagnosticCode;
15
+ }({});
16
+
17
+ export { CommandFormLayoutDiagnosticCode };
18
+ //# sourceMappingURL=CommandFormLayoutDiagnosticCode.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"CommandFormLayoutDiagnosticCode.js","sources":["../../../forms/CommandFormLayoutDiagnosticCode.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 * Diagnostic codes for command-form geometry validation.\n */\nexport enum CommandFormLayoutDiagnosticCode {\n EmptyColumns = 'emptyColumns',\n DuplicateColumn = 'duplicateColumn',\n InvalidColumnIndex = 'invalidColumnIndex',\n InvalidWidth = 'invalidWidth',\n DuplicatePlacement = 'duplicatePlacement',\n InvalidPlacement = 'invalidPlacement',\n MissingField = 'missingField',\n OutOfBoundsPlacement = 'outOfBoundsPlacement',\n}\n"],"names":["CommandFormLayoutDiagnosticCode"],"mappings":"AAAA;AACA;AAEA;;IAGO,IAAKA,+BAAAA,iBAAAA,SAAAA,+BAAAA,EAAAA;;;;;;;;;AAAAA,IAAAA,OAAAA,+BAAAA;AASX,CAAA,CAAA,EAAA;;"}
@@ -0,0 +1,9 @@
1
+ import { CommandFormLayout } from '@cratis/scene.model';
2
+ import { CommandFormLayoutDiagnostic } from './CommandFormLayoutDiagnostic';
3
+ export interface CommandFormLayoutDraft {
4
+ committed: CommandFormLayout;
5
+ draft: CommandFormLayout;
6
+ diagnostics: CommandFormLayoutDiagnostic[];
7
+ isValid: boolean;
8
+ }
9
+ //# sourceMappingURL=CommandFormLayoutDraft.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"CommandFormLayoutDraft.d.ts","sourceRoot":"","sources":["../../../forms/CommandFormLayoutDraft.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AACxD,OAAO,EAAE,2BAA2B,EAAE,MAAM,+BAA+B,CAAC;AAK5E,MAAM,WAAW,sBAAsB;IACnC,SAAS,EAAE,iBAAiB,CAAC;IAC7B,KAAK,EAAE,iBAAiB,CAAC;IACzB,WAAW,EAAE,2BAA2B,EAAE,CAAC;IAC3C,OAAO,EAAE,OAAO,CAAC;CACpB"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=CommandFormLayoutDraft.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"CommandFormLayoutDraft.js","sourceRoot":"","sources":["../../../forms/CommandFormLayoutDraft.ts"],"names":[],"mappings":""}
@@ -0,0 +1,4 @@
1
+ import { CommandFormLayout } from '@cratis/scene.model';
2
+ import { CommandFormLayoutDraft } from './CommandFormLayoutDraft';
3
+ export declare function commitCommandFormLayoutDraft(draft: CommandFormLayoutDraft): CommandFormLayout;
4
+ //# sourceMappingURL=commitCommandFormLayoutDraft.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"commitCommandFormLayoutDraft.d.ts","sourceRoot":"","sources":["../../../forms/commitCommandFormLayoutDraft.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AACxD,OAAO,EAAE,sBAAsB,EAAE,MAAM,0BAA0B,CAAC;AAKlE,wBAAgB,4BAA4B,CAAC,KAAK,EAAE,sBAAsB,GAAG,iBAAiB,CAE7F"}
@@ -0,0 +1,10 @@
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
+ * Commits a draft layout only when it is valid; otherwise returns the previous committed metadata.
5
+ */ function commitCommandFormLayoutDraft(draft) {
6
+ return draft.isValid ? draft.draft : draft.committed;
7
+ }
8
+
9
+ export { commitCommandFormLayoutDraft };
10
+ //# sourceMappingURL=commitCommandFormLayoutDraft.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"commitCommandFormLayoutDraft.js","sources":["../../../forms/commitCommandFormLayoutDraft.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 { CommandFormLayout } from '@cratis/scene.model';\nimport { CommandFormLayoutDraft } from './CommandFormLayoutDraft';\n\n/**\n * Commits a draft layout only when it is valid; otherwise returns the previous committed metadata.\n */\nexport function commitCommandFormLayoutDraft(draft: CommandFormLayoutDraft): CommandFormLayout {\n return draft.isValid ? draft.draft : draft.committed;\n}\n"],"names":["commitCommandFormLayoutDraft","draft","isValid","committed"],"mappings":"AAAA;AACA;AAKA;;IAGO,SAASA,4BAAAA,CAA6BC,KAA6B,EAAA;AACtE,IAAA,OAAOA,MAAMC,OAAO,GAAGD,MAAMA,KAAK,GAAGA,MAAME,SAAS;AACxD;;"}
@@ -0,0 +1,3 @@
1
+ import { CommandFormLayout } from '@cratis/scene.model';
2
+ export declare const defaultCommandFormLayout: CommandFormLayout;
3
+ //# sourceMappingURL=defaultCommandFormLayout.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"defaultCommandFormLayout.d.ts","sourceRoot":"","sources":["../../../forms/defaultCommandFormLayout.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,iBAAiB,EAAiB,MAAM,qBAAqB,CAAC;AAKvE,eAAO,MAAM,wBAAwB,EAAE,iBAGtC,CAAC"}
@@ -0,0 +1,21 @@
1
+ import { FormWidthUnit } 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
+ /**
6
+ * Backward-compatible command form geometry: one flexible column and no authored placements.
7
+ */ const defaultCommandFormLayout = {
8
+ columns: [
9
+ {
10
+ index: 1,
11
+ width: {
12
+ unit: FormWidthUnit.Fraction,
13
+ value: 1
14
+ }
15
+ }
16
+ ],
17
+ placements: []
18
+ };
19
+
20
+ export { defaultCommandFormLayout };
21
+ //# sourceMappingURL=defaultCommandFormLayout.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"defaultCommandFormLayout.js","sources":["../../../forms/defaultCommandFormLayout.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 { CommandFormLayout, FormWidthUnit } from '@cratis/scene.model';\n\n/**\n * Backward-compatible command form geometry: one flexible column and no authored placements.\n */\nexport const defaultCommandFormLayout: CommandFormLayout = {\n columns: [{ index: 1, width: { unit: FormWidthUnit.Fraction, value: 1 } }],\n placements: [],\n};\n"],"names":["defaultCommandFormLayout","columns","index","width","unit","FormWidthUnit","Fraction","value","placements"],"mappings":";;AAAA;AACA;AAIA;;UAGaA,wBAAAA,GAA8C;IACvDC,OAAAA,EAAS;AAAC,QAAA;YAAEC,KAAAA,EAAO,CAAA;YAAGC,KAAAA,EAAO;AAAEC,gBAAAA,IAAAA,EAAMC,cAAcC,QAAQ;gBAAEC,KAAAA,EAAO;AAAE;AAAE;AAAE,KAAA;AAC1EC,IAAAA,UAAAA,EAAY;AAChB;;"}
@@ -0,0 +1,3 @@
1
+ import { FormWidth } from '@cratis/scene.model';
2
+ export declare function formWidthToCss(width: FormWidth | undefined): string | undefined;
3
+ //# sourceMappingURL=formWidthToCss.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"formWidthToCss.d.ts","sourceRoot":"","sources":["../../../forms/formWidthToCss.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,SAAS,EAAiB,MAAM,qBAAqB,CAAC;AAK/D,wBAAgB,cAAc,CAAC,KAAK,EAAE,SAAS,GAAG,SAAS,GAAG,MAAM,GAAG,SAAS,CAY/E"}
@@ -0,0 +1,22 @@
1
+ import { FormWidthUnit } 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
+ /**
6
+ * Converts a platform-neutral form width to a browser CSS width token.
7
+ */ function formWidthToCss(width) {
8
+ if (!width) return undefined;
9
+ switch(width.unit){
10
+ case FormWidthUnit.Auto:
11
+ return 'auto';
12
+ case FormWidthUnit.Fraction:
13
+ return `${width.value ?? 1}fr`;
14
+ case FormWidthUnit.Pixels:
15
+ return `${width.value ?? 0}px`;
16
+ case FormWidthUnit.Percent:
17
+ return `${width.value ?? 0}%`;
18
+ }
19
+ }
20
+
21
+ export { formWidthToCss };
22
+ //# sourceMappingURL=formWidthToCss.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"formWidthToCss.js","sources":["../../../forms/formWidthToCss.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 { FormWidth, FormWidthUnit } from '@cratis/scene.model';\n\n/**\n * Converts a platform-neutral form width to a browser CSS width token.\n */\nexport function formWidthToCss(width: FormWidth | undefined): string | undefined {\n if (!width) return undefined;\n switch (width.unit) {\n case FormWidthUnit.Auto:\n return 'auto';\n case FormWidthUnit.Fraction:\n return `${width.value ?? 1}fr`;\n case FormWidthUnit.Pixels:\n return `${width.value ?? 0}px`;\n case FormWidthUnit.Percent:\n return `${width.value ?? 0}%`;\n }\n}\n"],"names":["formWidthToCss","width","undefined","unit","FormWidthUnit","Auto","Fraction","value","Pixels","Percent"],"mappings":";;AAAA;AACA;AAIA;;IAGO,SAASA,cAAAA,CAAeC,KAA4B,EAAA;IACvD,IAAI,CAACA,OAAO,OAAOC,SAAAA;AACnB,IAAA,OAAQD,MAAME,IAAI;AACd,QAAA,KAAKC,cAAcC,IAAI;YACnB,OAAO,MAAA;AACX,QAAA,KAAKD,cAAcE,QAAQ;AACvB,YAAA,OAAO,GAAGL,KAAAA,CAAMM,KAAK,IAAI,CAAA,CAAE,EAAE,CAAC;AAClC,QAAA,KAAKH,cAAcI,MAAM;AACrB,YAAA,OAAO,GAAGP,KAAAA,CAAMM,KAAK,IAAI,CAAA,CAAE,EAAE,CAAC;AAClC,QAAA,KAAKH,cAAcK,OAAO;AACtB,YAAA,OAAO,GAAGR,KAAAA,CAAMM,KAAK,IAAI,CAAA,CAAE,CAAC,CAAC;AACrC;AACJ;;"}
@@ -0,0 +1,13 @@
1
+ export * from './CommandFormLayoutDiagnostic';
2
+ export * from './CommandFormLayoutDiagnosticCode';
3
+ export * from './CommandFormLayoutDraft';
4
+ export * from './commitCommandFormLayoutDraft';
5
+ export * from './defaultCommandFormLayout';
6
+ export * from './formWidthToCss';
7
+ export * from './normalizeCommandFormLayout';
8
+ export * from './parseFormWidth';
9
+ export * from './preserveDirtyCommandValues';
10
+ export * from './resizeCommandFormColumn';
11
+ export * from './updateCommandFormFieldPlacement';
12
+ export * from './validateCommandFormLayout';
13
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../forms/index.ts"],"names":[],"mappings":"AAGA,cAAc,+BAA+B,CAAC;AAC9C,cAAc,mCAAmC,CAAC;AAClD,cAAc,0BAA0B,CAAC;AACzC,cAAc,gCAAgC,CAAC;AAC/C,cAAc,4BAA4B,CAAC;AAC3C,cAAc,kBAAkB,CAAC;AACjC,cAAc,8BAA8B,CAAC;AAC7C,cAAc,kBAAkB,CAAC;AACjC,cAAc,8BAA8B,CAAC;AAC7C,cAAc,2BAA2B,CAAC;AAC1C,cAAc,mCAAmC,CAAC;AAClD,cAAc,6BAA6B,CAAC"}
@@ -0,0 +1,13 @@
1
+ export * from './CommandFormLayoutDiagnostic';
2
+ export * from './CommandFormLayoutDiagnosticCode';
3
+ export * from './CommandFormLayoutDraft';
4
+ export * from './commitCommandFormLayoutDraft';
5
+ export * from './defaultCommandFormLayout';
6
+ export * from './formWidthToCss';
7
+ export * from './normalizeCommandFormLayout';
8
+ export * from './parseFormWidth';
9
+ export * from './preserveDirtyCommandValues';
10
+ export * from './resizeCommandFormColumn';
11
+ export * from './updateCommandFormFieldPlacement';
12
+ export * from './validateCommandFormLayout';
13
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../forms/index.ts"],"names":[],"mappings":"AAGA,cAAc,+BAA+B,CAAC;AAC9C,cAAc,mCAAmC,CAAC;AAClD,cAAc,0BAA0B,CAAC;AACzC,cAAc,gCAAgC,CAAC;AAC/C,cAAc,4BAA4B,CAAC;AAC3C,cAAc,kBAAkB,CAAC;AACjC,cAAc,8BAA8B,CAAC;AAC7C,cAAc,kBAAkB,CAAC;AACjC,cAAc,8BAA8B,CAAC;AAC7C,cAAc,2BAA2B,CAAC;AAC1C,cAAc,mCAAmC,CAAC;AAClD,cAAc,6BAA6B,CAAC"}
@@ -0,0 +1,8 @@
1
+ import { CommandFormLayout } from '@cratis/scene.model';
2
+ export interface LegacyCommandFormInputGeometry {
3
+ property: string;
4
+ column?: number;
5
+ width?: string;
6
+ }
7
+ export declare function normalizeCommandFormLayout(layout: CommandFormLayout | undefined, inputs?: readonly LegacyCommandFormInputGeometry[]): CommandFormLayout;
8
+ //# sourceMappingURL=normalizeCommandFormLayout.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"normalizeCommandFormLayout.d.ts","sourceRoot":"","sources":["../../../forms/normalizeCommandFormLayout.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,iBAAiB,EAA4D,MAAM,qBAAqB,CAAC;AAIlH,MAAM,WAAW,8BAA8B;IAC3C,QAAQ,EAAE,MAAM,CAAC;IACjB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,KAAK,CAAC,EAAE,MAAM,CAAC;CAClB;AAKD,wBAAgB,0BAA0B,CAAC,MAAM,EAAE,iBAAiB,GAAG,SAAS,EAAE,MAAM,GAAE,SAAS,8BAA8B,EAAO,GAAG,iBAAiB,CAc3J"}
@@ -0,0 +1,40 @@
1
+ import { FormWidthUnit } from '@cratis/scene.model';
2
+ import { defaultCommandFormLayout } from './defaultCommandFormLayout.js';
3
+ import { parseFormWidth } from './parseFormWidth.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
+ * Normalizes authored command form layout, including legacy per-input column/width metadata.
9
+ */ function normalizeCommandFormLayout(layout, inputs = []) {
10
+ if (layout) return layout;
11
+ if (!inputs.length) return defaultCommandFormLayout;
12
+ const placements = inputs.map((input, index)=>({
13
+ field: input.property,
14
+ row: index + 1,
15
+ column: positiveInteger(input.column) ?? 1,
16
+ width: parseFormWidth(input.width)
17
+ }));
18
+ const columnCount = Math.max(1, ...placements.map((placement)=>placement.column));
19
+ return {
20
+ columns: Array.from({
21
+ length: columnCount
22
+ }, (_, index)=>({
23
+ index: index + 1,
24
+ width: fraction(1)
25
+ })),
26
+ placements
27
+ };
28
+ }
29
+ function fraction(value) {
30
+ return {
31
+ unit: FormWidthUnit.Fraction,
32
+ value
33
+ };
34
+ }
35
+ function positiveInteger(value) {
36
+ return value !== undefined && Number.isInteger(value) && value > 0 ? value : undefined;
37
+ }
38
+
39
+ export { normalizeCommandFormLayout };
40
+ //# sourceMappingURL=normalizeCommandFormLayout.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"normalizeCommandFormLayout.js","sources":["../../../forms/normalizeCommandFormLayout.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 { CommandFormLayout, FormColumn, FormFieldPlacement, FormWidth, FormWidthUnit } from '@cratis/scene.model';\nimport { defaultCommandFormLayout } from './defaultCommandFormLayout';\nimport { parseFormWidth } from './parseFormWidth';\n\nexport interface LegacyCommandFormInputGeometry {\n property: string;\n column?: number;\n width?: string;\n}\n\n/**\n * Normalizes authored command form layout, including legacy per-input column/width metadata.\n */\nexport function normalizeCommandFormLayout(layout: CommandFormLayout | undefined, inputs: readonly LegacyCommandFormInputGeometry[] = []): CommandFormLayout {\n if (layout) return layout;\n if (!inputs.length) return defaultCommandFormLayout;\n const placements = inputs.map((input, index): FormFieldPlacement => ({\n field: input.property,\n row: index + 1,\n column: positiveInteger(input.column) ?? 1,\n width: parseFormWidth(input.width),\n }));\n const columnCount = Math.max(1, ...placements.map(placement => placement.column));\n return {\n columns: Array.from({ length: columnCount }, (_, index): FormColumn => ({ index: index + 1, width: fraction(1) })),\n placements,\n };\n}\n\nfunction fraction(value: number): FormWidth {\n return { unit: FormWidthUnit.Fraction, value };\n}\n\nfunction positiveInteger(value: number | undefined): number | undefined {\n return value !== undefined && Number.isInteger(value) && value > 0 ? value : undefined;\n}\n"],"names":["normalizeCommandFormLayout","layout","inputs","length","defaultCommandFormLayout","placements","map","input","index","field","property","row","column","positiveInteger","width","parseFormWidth","columnCount","Math","max","placement","columns","Array","from","_","fraction","value","unit","FormWidthUnit","Fraction","undefined","Number","isInteger"],"mappings":";;;;AAAA;AACA;AAYA;;AAEC,IACM,SAASA,0BAAAA,CAA2BC,MAAqC,EAAEC,SAAoD,EAAE,EAAA;AACpI,IAAA,IAAID,QAAQ,OAAOA,MAAAA;AACnB,IAAA,IAAI,CAACC,MAAAA,CAAOC,MAAM,EAAE,OAAOC,wBAAAA;AAC3B,IAAA,MAAMC,aAAaH,MAAAA,CAAOI,GAAG,CAAC,CAACC,KAAAA,EAAOC,SAA+B;AACjEC,YAAAA,KAAAA,EAAOF,MAAMG,QAAQ;AACrBC,YAAAA,GAAAA,EAAKH,KAAAA,GAAQ,CAAA;YACbI,MAAAA,EAAQC,eAAAA,CAAgBN,KAAAA,CAAMK,MAAM,CAAA,IAAK,CAAA;YACzCE,KAAAA,EAAOC,cAAAA,CAAeR,MAAMO,KAAK;SACrC,CAAA,CAAA;IACA,MAAME,WAAAA,GAAcC,IAAAA,CAAKC,GAAG,CAAC,CAAA,EAAA,GAAMb,UAAAA,CAAWC,GAAG,CAACa,CAAAA,SAAAA,GAAaA,SAAAA,CAAUP,MAAM,CAAA,CAAA;IAC/E,OAAO;QACHQ,OAAAA,EAASC,KAAAA,CAAMC,IAAI,CAAC;YAAEnB,MAAAA,EAAQa;SAAY,EAAG,CAACO,CAAAA,EAAGf,KAAAA,IAAuB;AAAEA,gBAAAA,KAAAA,EAAOA,KAAAA,GAAQ,CAAA;AAAGM,gBAAAA,KAAAA,EAAOU,QAAAA,CAAS,CAAA;aAAG,CAAA,CAAA;AAC/GnB,QAAAA;AACJ,KAAA;AACJ;AAEA,SAASmB,SAASC,KAAa,EAAA;IAC3B,OAAO;AAAEC,QAAAA,IAAAA,EAAMC,cAAcC,QAAQ;AAAEH,QAAAA;AAAM,KAAA;AACjD;AAEA,SAASZ,gBAAgBY,KAAyB,EAAA;IAC9C,OAAOA,KAAAA,KAAUI,aAAaC,MAAAA,CAAOC,SAAS,CAACN,KAAAA,CAAAA,IAAUA,KAAAA,GAAQ,IAAIA,KAAAA,GAAQI,SAAAA;AACjF;;"}
@@ -0,0 +1,3 @@
1
+ import { FormWidth } from '@cratis/scene.model';
2
+ export declare function parseFormWidth(value: unknown): FormWidth | undefined;
3
+ //# sourceMappingURL=parseFormWidth.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"parseFormWidth.d.ts","sourceRoot":"","sources":["../../../forms/parseFormWidth.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,SAAS,EAAiB,MAAM,qBAAqB,CAAC;AAK/D,wBAAgB,cAAc,CAAC,KAAK,EAAE,OAAO,GAAG,SAAS,GAAG,SAAS,CAWpE"}
@@ -0,0 +1,32 @@
1
+ import { FormWidthUnit } 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
+ /**
6
+ * Parses a legacy width token into typed form geometry. Arbitrary strings are intentionally rejected.
7
+ */ function parseFormWidth(value) {
8
+ if (!value || typeof value !== 'string') return undefined;
9
+ const trimmed = value.trim();
10
+ if (trimmed === 'auto') return {
11
+ unit: FormWidthUnit.Auto
12
+ };
13
+ const match = /^([0-9]+(?:\.[0-9]+)?)(fr|px|%)$/.exec(trimmed);
14
+ if (!match) return undefined;
15
+ const widthValue = Number(match[1]);
16
+ if (!Number.isFinite(widthValue) || widthValue < 0) return undefined;
17
+ if (match[2] === 'fr') return {
18
+ unit: FormWidthUnit.Fraction,
19
+ value: widthValue
20
+ };
21
+ if (match[2] === 'px') return {
22
+ unit: FormWidthUnit.Pixels,
23
+ value: widthValue
24
+ };
25
+ return {
26
+ unit: FormWidthUnit.Percent,
27
+ value: widthValue
28
+ };
29
+ }
30
+
31
+ export { parseFormWidth };
32
+ //# sourceMappingURL=parseFormWidth.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"parseFormWidth.js","sources":["../../../forms/parseFormWidth.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 { FormWidth, FormWidthUnit } from '@cratis/scene.model';\n\n/**\n * Parses a legacy width token into typed form geometry. Arbitrary strings are intentionally rejected.\n */\nexport function parseFormWidth(value: unknown): FormWidth | undefined {\n if (!value || typeof value !== 'string') return undefined;\n const trimmed = value.trim();\n if (trimmed === 'auto') return { unit: FormWidthUnit.Auto };\n const match = /^([0-9]+(?:\\.[0-9]+)?)(fr|px|%)$/.exec(trimmed);\n if (!match) return undefined;\n const widthValue = Number(match[1]);\n if (!Number.isFinite(widthValue) || widthValue < 0) return undefined;\n if (match[2] === 'fr') return { unit: FormWidthUnit.Fraction, value: widthValue };\n if (match[2] === 'px') return { unit: FormWidthUnit.Pixels, value: widthValue };\n return { unit: FormWidthUnit.Percent, value: widthValue };\n}\n"],"names":["parseFormWidth","value","undefined","trimmed","trim","unit","FormWidthUnit","Auto","match","exec","widthValue","Number","isFinite","Fraction","Pixels","Percent"],"mappings":";;AAAA;AACA;AAIA;;IAGO,SAASA,cAAAA,CAAeC,KAAc,EAAA;AACzC,IAAA,IAAI,CAACA,KAAAA,IAAS,OAAOA,KAAAA,KAAU,UAAU,OAAOC,SAAAA;IAChD,MAAMC,OAAAA,GAAUF,MAAMG,IAAI,EAAA;IAC1B,IAAID,OAAAA,KAAY,QAAQ,OAAO;AAAEE,QAAAA,IAAAA,EAAMC,cAAcC;AAAK,KAAA;IAC1D,MAAMC,KAAAA,GAAQ,kCAAA,CAAmCC,IAAI,CAACN,OAAAA,CAAAA;IACtD,IAAI,CAACK,OAAO,OAAON,SAAAA;AACnB,IAAA,MAAMQ,UAAAA,GAAaC,MAAAA,CAAOH,KAAK,CAAC,CAAA,CAAE,CAAA;AAClC,IAAA,IAAI,CAACG,MAAAA,CAAOC,QAAQ,CAACF,UAAAA,CAAAA,IAAeA,UAAAA,GAAa,GAAG,OAAOR,SAAAA;AAC3D,IAAA,IAAIM,KAAK,CAAC,CAAA,CAAE,KAAK,MAAM,OAAO;AAAEH,QAAAA,IAAAA,EAAMC,cAAcO,QAAQ;QAAEZ,KAAAA,EAAOS;AAAW,KAAA;AAChF,IAAA,IAAIF,KAAK,CAAC,CAAA,CAAE,KAAK,MAAM,OAAO;AAAEH,QAAAA,IAAAA,EAAMC,cAAcQ,MAAM;QAAEb,KAAAA,EAAOS;AAAW,KAAA;IAC9E,OAAO;AAAEL,QAAAA,IAAAA,EAAMC,cAAcS,OAAO;QAAEd,KAAAA,EAAOS;AAAW,KAAA;AAC5D;;"}
@@ -0,0 +1,2 @@
1
+ export declare function preserveDirtyCommandValues(current: Record<string, unknown>, refreshed: Record<string, unknown>, dirtyFields: ReadonlySet<string>): Record<string, unknown>;
2
+ //# sourceMappingURL=preserveDirtyCommandValues.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"preserveDirtyCommandValues.d.ts","sourceRoot":"","sources":["../../../forms/preserveDirtyCommandValues.ts"],"names":[],"mappings":"AAMA,wBAAgB,0BAA0B,CACtC,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAChC,SAAS,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAClC,WAAW,EAAE,WAAW,CAAC,MAAM,CAAC,GACjC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAEzB"}
@@ -0,0 +1,13 @@
1
+ // Copyright (c) Cratis. All rights reserved.
2
+ // Licensed under the MIT license. See LICENSE file in the project root for full license information.
3
+ /**
4
+ * Merges refreshed command values without overwriting dirty fields a user is editing.
5
+ */ function preserveDirtyCommandValues(current, refreshed, dirtyFields) {
6
+ return Object.fromEntries(Object.entries(refreshed).map(([field, value])=>[
7
+ field,
8
+ dirtyFields.has(field) ? current[field] : value
9
+ ]));
10
+ }
11
+
12
+ export { preserveDirtyCommandValues };
13
+ //# sourceMappingURL=preserveDirtyCommandValues.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"preserveDirtyCommandValues.js","sources":["../../../forms/preserveDirtyCommandValues.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 * Merges refreshed command values without overwriting dirty fields a user is editing.\n */\nexport function preserveDirtyCommandValues(\n current: Record<string, unknown>,\n refreshed: Record<string, unknown>,\n dirtyFields: ReadonlySet<string>,\n): Record<string, unknown> {\n return Object.fromEntries(Object.entries(refreshed).map(([field, value]) => [field, dirtyFields.has(field) ? current[field] : value]));\n}\n"],"names":["preserveDirtyCommandValues","current","refreshed","dirtyFields","Object","fromEntries","entries","map","field","value","has"],"mappings":"AAAA;AACA;AAEA;;AAEC,IACM,SAASA,0BAAAA,CACZC,OAAgC,EAChCC,SAAkC,EAClCC,WAAgC,EAAA;AAEhC,IAAA,OAAOC,MAAAA,CAAOC,WAAW,CAACD,MAAAA,CAAOE,OAAO,CAACJ,SAAAA,CAAAA,CAAWK,GAAG,CAAC,CAAC,CAACC,KAAAA,EAAOC,MAAM,GAAK;AAACD,YAAAA,KAAAA;AAAOL,YAAAA,WAAAA,CAAYO,GAAG,CAACF,KAAAA,CAAAA,GAASP,OAAO,CAACO,MAAM,GAAGC;AAAM,SAAA,CAAA,CAAA;AACxI;;"}
@@ -0,0 +1,4 @@
1
+ import { CommandFormLayout, FormWidth } from '@cratis/scene.model';
2
+ import { CommandFormLayoutDraft } from './CommandFormLayoutDraft';
3
+ export declare function resizeCommandFormColumn(committed: CommandFormLayout, columnIndex: number, width: FormWidth, fields?: readonly string[]): CommandFormLayoutDraft;
4
+ //# sourceMappingURL=resizeCommandFormColumn.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"resizeCommandFormColumn.d.ts","sourceRoot":"","sources":["../../../forms/resizeCommandFormColumn.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,iBAAiB,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AACnE,OAAO,EAAE,sBAAsB,EAAE,MAAM,0BAA0B,CAAC;AAMlE,wBAAgB,uBAAuB,CACnC,SAAS,EAAE,iBAAiB,EAC5B,WAAW,EAAE,MAAM,EACnB,KAAK,EAAE,SAAS,EAChB,MAAM,GAAE,SAAS,MAAM,EAAO,GAC/B,sBAAsB,CAOxB"}
@@ -0,0 +1,25 @@
1
+ import { validateCommandFormLayout } from './validateCommandFormLayout.js';
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
+ * Resizes a column as draft geometry, keeping the last committed layout separate when invalid.
7
+ */ function resizeCommandFormColumn(committed, columnIndex, width, fields = []) {
8
+ const draft = {
9
+ ...committed,
10
+ columns: committed.columns.map((column)=>column.index === columnIndex ? {
11
+ ...column,
12
+ width
13
+ } : column)
14
+ };
15
+ const diagnostics = validateCommandFormLayout(draft, fields);
16
+ return {
17
+ committed,
18
+ draft,
19
+ diagnostics,
20
+ isValid: diagnostics.length === 0
21
+ };
22
+ }
23
+
24
+ export { resizeCommandFormColumn };
25
+ //# sourceMappingURL=resizeCommandFormColumn.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"resizeCommandFormColumn.js","sources":["../../../forms/resizeCommandFormColumn.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 { CommandFormLayout, FormWidth } from '@cratis/scene.model';\nimport { CommandFormLayoutDraft } from './CommandFormLayoutDraft';\nimport { validateCommandFormLayout } from './validateCommandFormLayout';\n\n/**\n * Resizes a column as draft geometry, keeping the last committed layout separate when invalid.\n */\nexport function resizeCommandFormColumn(\n committed: CommandFormLayout,\n columnIndex: number,\n width: FormWidth,\n fields: readonly string[] = [],\n): CommandFormLayoutDraft {\n const draft: CommandFormLayout = {\n ...committed,\n columns: committed.columns.map(column => column.index === columnIndex ? { ...column, width } : column),\n };\n const diagnostics = validateCommandFormLayout(draft, fields);\n return { committed, draft, diagnostics, isValid: diagnostics.length === 0 };\n}\n"],"names":["resizeCommandFormColumn","committed","columnIndex","width","fields","draft","columns","map","column","index","diagnostics","validateCommandFormLayout","isValid","length"],"mappings":";;AAAA;AACA;AAMA;;IAGO,SAASA,uBAAAA,CACZC,SAA4B,EAC5BC,WAAmB,EACnBC,KAAgB,EAChBC,MAAAA,GAA4B,EAAE,EAAA;AAE9B,IAAA,MAAMC,KAAAA,GAA2B;AAC7B,QAAA,GAAGJ,SAAS;QACZK,OAAAA,EAASL,SAAAA,CAAUK,OAAO,CAACC,GAAG,CAACC,CAAAA,MAAAA,GAAUA,MAAAA,CAAOC,KAAK,KAAKP,WAAAA,GAAc;AAAE,gBAAA,GAAGM,MAAM;AAAEL,gBAAAA;aAAM,GAAIK,MAAAA;AACnG,KAAA;IACA,MAAME,WAAAA,GAAcC,0BAA0BN,KAAAA,EAAOD,MAAAA,CAAAA;IACrD,OAAO;AAAEH,QAAAA,SAAAA;AAAWI,QAAAA,KAAAA;AAAOK,QAAAA,WAAAA;QAAaE,OAAAA,EAASF,WAAAA,CAAYG,MAAM,KAAK;AAAE,KAAA;AAC9E;;"}
@@ -0,0 +1,4 @@
1
+ import { CommandFormLayout, FormFieldPlacement } from '@cratis/scene.model';
2
+ import { CommandFormLayoutDraft } from './CommandFormLayoutDraft';
3
+ export declare function updateCommandFormFieldPlacement(committed: CommandFormLayout, placement: FormFieldPlacement, fields?: readonly string[]): CommandFormLayoutDraft;
4
+ //# sourceMappingURL=updateCommandFormFieldPlacement.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"updateCommandFormFieldPlacement.d.ts","sourceRoot":"","sources":["../../../forms/updateCommandFormFieldPlacement.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,iBAAiB,EAAE,kBAAkB,EAAE,MAAM,qBAAqB,CAAC;AAC5E,OAAO,EAAE,sBAAsB,EAAE,MAAM,0BAA0B,CAAC;AAMlE,wBAAgB,+BAA+B,CAC3C,SAAS,EAAE,iBAAiB,EAC5B,SAAS,EAAE,kBAAkB,EAC7B,MAAM,GAAE,SAAS,MAAM,EAAO,GAC/B,sBAAsB,CAOxB"}
@@ -0,0 +1,25 @@
1
+ import { validateCommandFormLayout } from './validateCommandFormLayout.js';
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
+ * Updates a field placement as draft geometry, keeping the committed layout separate when invalid.
7
+ */ function updateCommandFormFieldPlacement(committed, placement, fields = []) {
8
+ const draft = {
9
+ ...committed,
10
+ placements: [
11
+ ...committed.placements.filter((existing)=>existing.field !== placement.field),
12
+ placement
13
+ ]
14
+ };
15
+ const diagnostics = validateCommandFormLayout(draft, fields);
16
+ return {
17
+ committed,
18
+ draft,
19
+ diagnostics,
20
+ isValid: diagnostics.length === 0
21
+ };
22
+ }
23
+
24
+ export { updateCommandFormFieldPlacement };
25
+ //# sourceMappingURL=updateCommandFormFieldPlacement.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"updateCommandFormFieldPlacement.js","sources":["../../../forms/updateCommandFormFieldPlacement.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 { CommandFormLayout, FormFieldPlacement } from '@cratis/scene.model';\nimport { CommandFormLayoutDraft } from './CommandFormLayoutDraft';\nimport { validateCommandFormLayout } from './validateCommandFormLayout';\n\n/**\n * Updates a field placement as draft geometry, keeping the committed layout separate when invalid.\n */\nexport function updateCommandFormFieldPlacement(\n committed: CommandFormLayout,\n placement: FormFieldPlacement,\n fields: readonly string[] = [],\n): CommandFormLayoutDraft {\n const draft: CommandFormLayout = {\n ...committed,\n placements: [...committed.placements.filter(existing => existing.field !== placement.field), placement],\n };\n const diagnostics = validateCommandFormLayout(draft, fields);\n return { committed, draft, diagnostics, isValid: diagnostics.length === 0 };\n}\n"],"names":["updateCommandFormFieldPlacement","committed","placement","fields","draft","placements","filter","existing","field","diagnostics","validateCommandFormLayout","isValid","length"],"mappings":";;AAAA;AACA;AAMA;;IAGO,SAASA,+BAAAA,CACZC,SAA4B,EAC5BC,SAA6B,EAC7BC,SAA4B,EAAE,EAAA;AAE9B,IAAA,MAAMC,KAAAA,GAA2B;AAC7B,QAAA,GAAGH,SAAS;QACZI,UAAAA,EAAY;eAAIJ,SAAAA,CAAUI,UAAU,CAACC,MAAM,CAACC,CAAAA,WAAYA,QAAAA,CAASC,KAAK,KAAKN,SAAAA,CAAUM,KAAK,CAAA;AAAGN,YAAAA;AAAU;AAC3G,KAAA;IACA,MAAMO,WAAAA,GAAcC,0BAA0BN,KAAAA,EAAOD,MAAAA,CAAAA;IACrD,OAAO;AAAEF,QAAAA,SAAAA;AAAWG,QAAAA,KAAAA;AAAOK,QAAAA,WAAAA;QAAaE,OAAAA,EAASF,WAAAA,CAAYG,MAAM,KAAK;AAAE,KAAA;AAC9E;;"}
@@ -0,0 +1,4 @@
1
+ import { CommandFormLayout } from '@cratis/scene.model';
2
+ import { CommandFormLayoutDiagnostic } from './CommandFormLayoutDiagnostic';
3
+ export declare function validateCommandFormLayout(layout: CommandFormLayout, fields?: readonly string[]): CommandFormLayoutDiagnostic[];
4
+ //# sourceMappingURL=validateCommandFormLayout.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"validateCommandFormLayout.d.ts","sourceRoot":"","sources":["../../../forms/validateCommandFormLayout.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,iBAAiB,EAA4B,MAAM,qBAAqB,CAAC;AAClF,OAAO,EAAE,2BAA2B,EAAE,MAAM,+BAA+B,CAAC;AAM5E,wBAAgB,yBAAyB,CAAC,MAAM,EAAE,iBAAiB,EAAE,MAAM,GAAE,SAAS,MAAM,EAAO,GAAG,2BAA2B,EAAE,CA6ClI"}