@cratis/scene.components 3.5.0 → 3.7.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 (162) hide show
  1. package/README.md +56 -5
  2. package/bindings/bindingRegistry.ts +52 -4
  3. package/bindings/for_bindingRegistry/when_registering_query_identities.ts +81 -0
  4. package/bindings/for_requireArcProxy/when_mounting_bound_adapters.tsx +4 -2
  5. package/cratisComponents.ts +2 -0
  6. package/cratisComponentsPackage.ts +2 -1
  7. package/data/SingleResultRuntime.tsx +17 -3
  8. package/data/for_SceneDataTable/when_forwarding_query_arguments.tsx +19 -0
  9. package/dist/cjs/bindings/bindingRegistry.js +52 -4
  10. package/dist/cjs/bindings/bindingRegistry.js.map +1 -1
  11. package/dist/cjs/cratisComponents.js +2 -0
  12. package/dist/cjs/cratisComponents.js.map +1 -1
  13. package/dist/cjs/cratisComponentsPackage.js +2 -1
  14. package/dist/cjs/cratisComponentsPackage.js.map +1 -1
  15. package/dist/cjs/data/SingleResultRuntime.js +16 -1
  16. package/dist/cjs/data/SingleResultRuntime.js.map +1 -1
  17. package/dist/cjs/forms/CommandFormRuntime.js +81 -0
  18. package/dist/cjs/forms/CommandFormRuntime.js.map +1 -0
  19. package/dist/cjs/forms/CommandFormSubmit.js +19 -0
  20. package/dist/cjs/forms/CommandFormSubmit.js.map +1 -0
  21. package/dist/cjs/forms/ExplicitCommandField.js +109 -0
  22. package/dist/cjs/forms/ExplicitCommandField.js.map +1 -0
  23. package/dist/cjs/forms/SceneCommandForm.js +26 -21
  24. package/dist/cjs/forms/SceneCommandForm.js.map +1 -1
  25. package/dist/cjs/forms/SceneQueryInputForm.js +141 -0
  26. package/dist/cjs/forms/SceneQueryInputForm.js.map +1 -0
  27. package/dist/cjs/forms/commandInputs.js +35 -0
  28. package/dist/cjs/forms/commandInputs.js.map +1 -0
  29. package/dist/cjs/forms/queryInputs.js +50 -0
  30. package/dist/cjs/forms/queryInputs.js.map +1 -0
  31. package/dist/cjs/index.js +6 -0
  32. package/dist/cjs/index.js.map +1 -1
  33. package/dist/esm/bindings/bindingRegistry.d.ts +4 -0
  34. package/dist/esm/bindings/bindingRegistry.d.ts.map +1 -1
  35. package/dist/esm/bindings/bindingRegistry.js +49 -5
  36. package/dist/esm/bindings/bindingRegistry.js.map +1 -1
  37. package/dist/esm/bindings/for_bindingRegistry/when_registering_query_identities.d.ts +2 -0
  38. package/dist/esm/bindings/for_bindingRegistry/when_registering_query_identities.d.ts.map +1 -0
  39. package/dist/esm/bindings/for_bindingRegistry/when_registering_query_identities.js +73 -0
  40. package/dist/esm/bindings/for_bindingRegistry/when_registering_query_identities.js.map +1 -0
  41. package/dist/esm/bindings/for_requireArcProxy/when_mounting_bound_adapters.js +2 -2
  42. package/dist/esm/bindings/for_requireArcProxy/when_mounting_bound_adapters.js.map +1 -1
  43. package/dist/esm/cratisComponents.d.ts.map +1 -1
  44. package/dist/esm/cratisComponents.js +2 -0
  45. package/dist/esm/cratisComponents.js.map +1 -1
  46. package/dist/esm/cratisComponentsPackage.d.ts.map +1 -1
  47. package/dist/esm/cratisComponentsPackage.js +2 -1
  48. package/dist/esm/cratisComponentsPackage.js.map +1 -1
  49. package/dist/esm/data/SingleResultRuntime.d.ts +2 -1
  50. package/dist/esm/data/SingleResultRuntime.d.ts.map +1 -1
  51. package/dist/esm/data/SingleResultRuntime.js +16 -1
  52. package/dist/esm/data/SingleResultRuntime.js.map +1 -1
  53. package/dist/esm/data/for_SceneDataTable/when_forwarding_query_arguments.js +17 -0
  54. package/dist/esm/data/for_SceneDataTable/when_forwarding_query_arguments.js.map +1 -1
  55. package/dist/esm/for_cratisComponentsPackage/when_declaring_command_form_peers.d.ts +2 -0
  56. package/dist/esm/for_cratisComponentsPackage/when_declaring_command_form_peers.d.ts.map +1 -0
  57. package/dist/esm/for_cratisComponentsPackage/when_declaring_command_form_peers.js +16 -0
  58. package/dist/esm/for_cratisComponentsPackage/when_declaring_command_form_peers.js.map +1 -0
  59. package/dist/esm/for_cratisComponentsPackage/when_describing_query_input_form.d.ts +2 -0
  60. package/dist/esm/for_cratisComponentsPackage/when_describing_query_input_form.d.ts.map +1 -0
  61. package/dist/esm/for_cratisComponentsPackage/when_describing_query_input_form.js +14 -0
  62. package/dist/esm/for_cratisComponentsPackage/when_describing_query_input_form.js.map +1 -0
  63. package/dist/esm/forms/CommandFormRuntime.d.ts +11 -0
  64. package/dist/esm/forms/CommandFormRuntime.d.ts.map +1 -0
  65. package/dist/esm/forms/CommandFormRuntime.js +77 -0
  66. package/dist/esm/forms/CommandFormRuntime.js.map +1 -0
  67. package/dist/esm/forms/CommandFormSubmit.d.ts +6 -0
  68. package/dist/esm/forms/CommandFormSubmit.d.ts.map +1 -0
  69. package/dist/esm/forms/CommandFormSubmit.js +17 -0
  70. package/dist/esm/forms/CommandFormSubmit.js.map +1 -0
  71. package/dist/esm/forms/ExplicitCommandField.d.ts +5 -0
  72. package/dist/esm/forms/ExplicitCommandField.d.ts.map +1 -0
  73. package/dist/esm/forms/ExplicitCommandField.js +107 -0
  74. package/dist/esm/forms/ExplicitCommandField.js.map +1 -0
  75. package/dist/esm/forms/SceneCommandForm.d.ts.map +1 -1
  76. package/dist/esm/forms/SceneCommandForm.js +27 -22
  77. package/dist/esm/forms/SceneCommandForm.js.map +1 -1
  78. package/dist/esm/forms/SceneQueryInputForm.d.ts +3 -0
  79. package/dist/esm/forms/SceneQueryInputForm.d.ts.map +1 -0
  80. package/dist/esm/forms/SceneQueryInputForm.js +139 -0
  81. package/dist/esm/forms/SceneQueryInputForm.js.map +1 -0
  82. package/dist/esm/forms/commandInputs.d.ts +7 -0
  83. package/dist/esm/forms/commandInputs.d.ts.map +1 -0
  84. package/dist/esm/forms/commandInputs.js +33 -0
  85. package/dist/esm/forms/commandInputs.js.map +1 -0
  86. package/dist/esm/forms/for_SceneCommandForm/given/RecordNote.d.ts +22 -0
  87. package/dist/esm/forms/for_SceneCommandForm/given/RecordNote.d.ts.map +1 -0
  88. package/dist/esm/forms/for_SceneCommandForm/given/RecordNote.js +30 -0
  89. package/dist/esm/forms/for_SceneCommandForm/given/RecordNote.js.map +1 -0
  90. package/dist/esm/forms/for_SceneCommandForm/given/StartProject.d.ts +32 -0
  91. package/dist/esm/forms/for_SceneCommandForm/given/StartProject.d.ts.map +1 -0
  92. package/dist/esm/forms/for_SceneCommandForm/given/StartProject.js +32 -0
  93. package/dist/esm/forms/for_SceneCommandForm/given/StartProject.js.map +1 -0
  94. package/dist/esm/forms/for_SceneCommandForm/when_forwarding_to_the_lazy_runtime.d.ts +2 -0
  95. package/dist/esm/forms/for_SceneCommandForm/when_forwarding_to_the_lazy_runtime.d.ts.map +1 -0
  96. package/dist/esm/forms/for_SceneCommandForm/when_forwarding_to_the_lazy_runtime.js +66 -0
  97. package/dist/esm/forms/for_SceneCommandForm/when_forwarding_to_the_lazy_runtime.js.map +1 -0
  98. package/dist/esm/forms/for_SceneCommandForm/when_native_custom_field_errors_block_submission.d.ts +2 -0
  99. package/dist/esm/forms/for_SceneCommandForm/when_native_custom_field_errors_block_submission.d.ts.map +1 -0
  100. package/dist/esm/forms/for_SceneCommandForm/when_native_custom_field_errors_block_submission.js +26 -0
  101. package/dist/esm/forms/for_SceneCommandForm/when_native_custom_field_errors_block_submission.js.map +1 -0
  102. package/dist/esm/forms/for_SceneCommandForm/when_preserving_guid_error_ownership.d.ts +2 -0
  103. package/dist/esm/forms/for_SceneCommandForm/when_preserving_guid_error_ownership.d.ts.map +1 -0
  104. package/dist/esm/forms/for_SceneCommandForm/when_preserving_guid_error_ownership.js +44 -0
  105. package/dist/esm/forms/for_SceneCommandForm/when_preserving_guid_error_ownership.js.map +1 -0
  106. package/dist/esm/forms/for_SceneCommandForm/when_rendering_submit_in_native_context.d.ts +2 -0
  107. package/dist/esm/forms/for_SceneCommandForm/when_rendering_submit_in_native_context.d.ts.map +1 -0
  108. package/dist/esm/forms/for_SceneCommandForm/when_rendering_submit_in_native_context.js +49 -0
  109. package/dist/esm/forms/for_SceneCommandForm/when_rendering_submit_in_native_context.js.map +1 -0
  110. package/dist/esm/forms/for_SceneCommandForm/when_submitting_explicit_inputs.d.ts +2 -0
  111. package/dist/esm/forms/for_SceneCommandForm/when_submitting_explicit_inputs.d.ts.map +1 -0
  112. package/dist/esm/forms/for_SceneCommandForm/when_submitting_explicit_inputs.js +176 -0
  113. package/dist/esm/forms/for_SceneCommandForm/when_submitting_explicit_inputs.js.map +1 -0
  114. package/dist/esm/forms/for_SceneCommandForm/when_submitting_the_native_form.d.ts +2 -0
  115. package/dist/esm/forms/for_SceneCommandForm/when_submitting_the_native_form.d.ts.map +1 -0
  116. package/dist/esm/forms/for_SceneCommandForm/when_submitting_the_native_form.js +110 -0
  117. package/dist/esm/forms/for_SceneCommandForm/when_submitting_the_native_form.js.map +1 -0
  118. package/dist/esm/forms/for_SceneQueryInputForm/ProjectLookup.d.ts +26 -0
  119. package/dist/esm/forms/for_SceneQueryInputForm/ProjectLookup.d.ts.map +1 -0
  120. package/dist/esm/forms/for_SceneQueryInputForm/ProjectLookup.js +44 -0
  121. package/dist/esm/forms/for_SceneQueryInputForm/ProjectLookup.js.map +1 -0
  122. package/dist/esm/forms/for_SceneQueryInputForm/when_submitting_generated_guid_parameters.d.ts +2 -0
  123. package/dist/esm/forms/for_SceneQueryInputForm/when_submitting_generated_guid_parameters.d.ts.map +1 -0
  124. package/dist/esm/forms/for_SceneQueryInputForm/when_submitting_generated_guid_parameters.js +175 -0
  125. package/dist/esm/forms/for_SceneQueryInputForm/when_submitting_generated_guid_parameters.js.map +1 -0
  126. package/dist/esm/forms/for_SceneQueryInputForm/when_submitting_native_queries.d.ts +2 -0
  127. package/dist/esm/forms/for_SceneQueryInputForm/when_submitting_native_queries.d.ts.map +1 -0
  128. package/dist/esm/forms/for_SceneQueryInputForm/when_submitting_native_queries.js +413 -0
  129. package/dist/esm/forms/for_SceneQueryInputForm/when_submitting_native_queries.js.map +1 -0
  130. package/dist/esm/forms/index.d.ts +2 -0
  131. package/dist/esm/forms/index.d.ts.map +1 -1
  132. package/dist/esm/forms/index.js +1 -0
  133. package/dist/esm/forms/index.js.map +1 -1
  134. package/dist/esm/forms/queryInputs.d.ts +10 -0
  135. package/dist/esm/forms/queryInputs.d.ts.map +1 -0
  136. package/dist/esm/forms/queryInputs.js +47 -0
  137. package/dist/esm/forms/queryInputs.js.map +1 -0
  138. package/dist/esm/index.js +2 -1
  139. package/dist/esm/index.js.map +1 -1
  140. package/dist/esm/tsconfig.tsbuildinfo +1 -1
  141. package/for_cratisComponentsPackage/when_declaring_command_form_peers.ts +26 -0
  142. package/for_cratisComponentsPackage/when_describing_query_input_form.ts +17 -0
  143. package/forms/CommandFormRuntime.tsx +71 -0
  144. package/forms/CommandFormSubmit.tsx +16 -0
  145. package/forms/ExplicitCommandField.tsx +86 -0
  146. package/forms/SceneCommandForm.tsx +30 -27
  147. package/forms/SceneQueryInputForm.tsx +79 -0
  148. package/forms/commandInputs.ts +29 -0
  149. package/forms/for_SceneCommandForm/given/RecordNote.ts +37 -0
  150. package/forms/for_SceneCommandForm/given/StartProject.ts +41 -0
  151. package/forms/for_SceneCommandForm/when_forwarding_to_the_lazy_runtime.tsx +69 -0
  152. package/forms/for_SceneCommandForm/when_native_custom_field_errors_block_submission.tsx +33 -0
  153. package/forms/for_SceneCommandForm/when_preserving_guid_error_ownership.tsx +50 -0
  154. package/forms/for_SceneCommandForm/when_rendering_submit_in_native_context.tsx +56 -0
  155. package/forms/for_SceneCommandForm/when_submitting_explicit_inputs.tsx +189 -0
  156. package/forms/for_SceneCommandForm/when_submitting_the_native_form.tsx +120 -0
  157. package/forms/for_SceneQueryInputForm/ProjectLookup.ts +54 -0
  158. package/forms/for_SceneQueryInputForm/when_submitting_generated_guid_parameters.tsx +188 -0
  159. package/forms/for_SceneQueryInputForm/when_submitting_native_queries.tsx +423 -0
  160. package/forms/index.ts +2 -0
  161. package/forms/queryInputs.ts +50 -0
  162. package/package.json +17 -13
@@ -42,6 +42,7 @@ var cratisComponents = require('./cratisComponents.js');
42
42
  'dataPage',
43
43
  'formElement',
44
44
  'singleResult',
45
+ 'queryInputForm',
45
46
  'dataTable',
46
47
  'table',
47
48
  'observableDataTable',
@@ -91,7 +92,7 @@ var cratisComponents = require('./cratisComponents.js');
91
92
  // Shipping a theme here would be this library asserting a look it was specifically built not to have.
92
93
  themes: [],
93
94
  displayName: 'Cratis Components',
94
- description: "Cratis' Arc-bound data, form and dialog composites, built on PrimeReact and Tailwind. dataTable and table accept optional object-valued queryArguments for collection queries. singleResult displays one read-only scalar own resultField of an optional model using an explicit query, object queryArguments and enabled: true.",
95
+ description: "Cratis' Arc-bound data, form and dialog composites, built on PrimeReact and Tailwind. dataTable and table accept optional object-valued queryArguments for collection queries. singleResult displays one read-only scalar own resultField of an optional model using an explicit query, object queryArguments and enabled: true. queryInputForm commits explicit string inputs on submit to the same optional-single runtime; drafts never execute a query.",
95
96
  module: '@cratis/scene.components',
96
97
  license: 'MIT',
97
98
  licenseUrl: 'https://github.com/Cratis/Scene/blob/main/LICENSE'
@@ -1 +1 @@
1
- {"version":3,"file":"cratisComponentsPackage.js","sources":["../../cratisComponentsPackage.ts"],"sourcesContent":["// Copyright (c) Cratis. All rights reserved.\n// Licensed under the MIT license. See LICENSE file in the project root for full license information.\n\nimport { PackageKind, ScenePackage } from '@cratis/scene.model';\nimport { ScenePackageBundle } from '@cratis/scene.react';\nimport { cratisComponents, cratisComponentsPackageName } from './cratisComponents';\n\n/**\n * The `Cratis.Components` package's declaration - what a profile gets when it lists this package.\n *\n * This is the concrete case the whole package-dependency mechanism exists for. `@cratis/components` is\n * not a self-contained library: every component in it is a wrapper over a PrimeReact widget, and its own\n * styling is a `--cratis-*` token layer (`@cratis/components/tokens`) plus the component stylesheets and\n * compiled Tailwind utilities in `@cratis/components/styles`. Activate it in a profile without PrimeReact\n * and nothing renders; activate it without Tailwind and everything renders unstyled. Both are stated as\n * dependencies so a package picker can say so while the profile is being configured, instead of leaving\n * it to be discovered when the page opens.\n *\n * The version ranges are the real ones the library carries. `>=11.0.0` for PrimeReact: version 3.0.0\n * declares `primereact@^11` as a peer dependency and is built against version 11's component set, so the\n * span across the major boundary that the previous `>=10.9.0` range described is over. The `--cratis-*`\n * tokens still resolve a version 10 theme variable as their last fallback, but that is an upgrade-window\n * courtesy for an application with a compiled version 10 stylesheet still on the page - not a version of\n * PrimeReact this package can be activated against. `^4.0.0` for Tailwind, because the utility sheet is\n * compiled against Tailwind 4.\n */\nexport const cratisComponentsPackageManifest: ScenePackage = {\n name: cratisComponentsPackageName,\n version: '3.0.0',\n kind: PackageKind.ComponentLibrary,\n dependencies: [\n { name: 'PrimeReact', versionRange: '>=11.0.0' },\n { name: 'Tailwind', versionRange: '^4.0.0' },\n ],\n components: [\n 'page',\n 'dataPage',\n 'formElement',\n 'singleResult',\n 'dataTable',\n 'table',\n 'observableDataTable',\n 'commandForm',\n 'inputTextField',\n 'numberField',\n 'checkboxField',\n 'textAreaField',\n 'dropdownField',\n 'sliderField',\n 'calendarField',\n 'colorPickerField',\n 'multiSelectField',\n 'chipsField',\n 'radioButtonField',\n 'radioGroupField',\n 'dialog',\n 'confirmationDialog',\n 'busyIndicatorDialog',\n 'commandDialog',\n 'stepperCommandDialog',\n 'icon',\n 'tooltip',\n 'dropdown',\n 'errorBoundary',\n 'objectContentEditor',\n 'objectNavigationalBar',\n 'schemaEditor',\n 'timeMachine',\n 'filterPanel',\n 'toolbar',\n 'toolbarButton',\n 'toolbarGroup',\n 'toolbarSeparator',\n ],\n\n // A component library ships components, and nothing else. Layouts, screen templates and dialog\n // templates all belong to a Blueprint: they are decisions about what an application looks like as a\n // whole, and this package deliberately makes none of them - it provides the Arc-bound composites a\n // template is *built from*, so that a blueprint can place a `dataPage` in a slot and configure it,\n // rather than shipping one opinionated data page nobody can rearrange.\n layouts: [],\n screenTemplates: [],\n dialogTemplates: [],\n\n // No themes either, for a different reason: `@cratis/components` has no palette of its own. It reads\n // a `--cratis-*` variable layer that resolves whatever is in front of it - the `--p-*` properties a\n // PrimeReact 11 preset emits at runtime, or a Scene theme through this package's token bridge.\n // Shipping a theme here would be this library asserting a look it was specifically built not to have.\n themes: [],\n\n displayName: 'Cratis Components',\n description: \"Cratis' Arc-bound data, form and dialog composites, built on PrimeReact and Tailwind. dataTable and table accept optional object-valued queryArguments for collection queries. singleResult displays one read-only scalar own resultField of an optional model using an explicit query, object queryArguments and enabled: true.\",\n module: '@cratis/scene.components',\n license: 'MIT',\n licenseUrl: 'https://github.com/Cratis/Scene/blob/main/LICENSE',\n};\n\n/**\n * The `Cratis.Components` package as a loadable bundle - the manifest above, plus the React components\n * behind the names it declares.\n *\n * No `layouts`, `screenTemplates`, `dialogTemplates` or `themes` are provided, matching a manifest that\n * declares none of them; `validatePackageBundle` is what proves the two halves agree.\n */\nexport const cratisComponentsPackage: ScenePackageBundle = {\n manifest: cratisComponentsPackageManifest,\n components: cratisComponents,\n};\n"],"names":["cratisComponentsPackageManifest","name","cratisComponentsPackageName","version","kind","PackageKind","ComponentLibrary","dependencies","versionRange","components","layouts","screenTemplates","dialogTemplates","themes","displayName","description","module","license","licenseUrl","cratisComponentsPackage","manifest","cratisComponents"],"mappings":";;;;;AAAA;AACA;AAMA;;;;;;;;;;;;;;;;;;UAmBaA,+BAAAA,GAAgD;IACzDC,IAAAA,EAAMC,4CAAAA;IACNC,OAAAA,EAAS,OAAA;AACTC,IAAAA,IAAAA,EAAMC,wBAAYC,gBAAgB;IAClCC,YAAAA,EAAc;AACV,QAAA;YAAEN,IAAAA,EAAM,YAAA;YAAcO,YAAAA,EAAc;AAAW,SAAA;AAC/C,QAAA;YAAEP,IAAAA,EAAM,UAAA;YAAYO,YAAAA,EAAc;AAAS;AAC9C,KAAA;IACDC,UAAAA,EAAY;AACR,QAAA,MAAA;AACA,QAAA,UAAA;AACA,QAAA,aAAA;AACA,QAAA,cAAA;AACA,QAAA,WAAA;AACA,QAAA,OAAA;AACA,QAAA,qBAAA;AACA,QAAA,aAAA;AACA,QAAA,gBAAA;AACA,QAAA,aAAA;AACA,QAAA,eAAA;AACA,QAAA,eAAA;AACA,QAAA,eAAA;AACA,QAAA,aAAA;AACA,QAAA,eAAA;AACA,QAAA,kBAAA;AACA,QAAA,kBAAA;AACA,QAAA,YAAA;AACA,QAAA,kBAAA;AACA,QAAA,iBAAA;AACA,QAAA,QAAA;AACA,QAAA,oBAAA;AACA,QAAA,qBAAA;AACA,QAAA,eAAA;AACA,QAAA,sBAAA;AACA,QAAA,MAAA;AACA,QAAA,SAAA;AACA,QAAA,UAAA;AACA,QAAA,eAAA;AACA,QAAA,qBAAA;AACA,QAAA,uBAAA;AACA,QAAA,cAAA;AACA,QAAA,aAAA;AACA,QAAA,aAAA;AACA,QAAA,SAAA;AACA,QAAA,eAAA;AACA,QAAA,cAAA;AACA,QAAA;AACH,KAAA;;;;;;AAODC,IAAAA,OAAAA,EAAS,EAAE;AACXC,IAAAA,eAAAA,EAAiB,EAAE;AACnBC,IAAAA,eAAAA,EAAiB,EAAE;;;;;AAMnBC,IAAAA,MAAAA,EAAQ,EAAE;IAEVC,WAAAA,EAAa,mBAAA;IACbC,WAAAA,EAAa,kUAAA;IACbC,MAAAA,EAAQ,0BAAA;IACRC,OAAAA,EAAS,KAAA;IACTC,UAAAA,EAAY;AAChB;AAEA;;;;;;UAOaC,uBAAAA,GAA8C;IACvDC,QAAAA,EAAUpB,+BAAAA;IACVS,UAAAA,EAAYY;AAChB;;;"}
1
+ {"version":3,"file":"cratisComponentsPackage.js","sources":["../../cratisComponentsPackage.ts"],"sourcesContent":["// Copyright (c) Cratis. All rights reserved.\n// Licensed under the MIT license. See LICENSE file in the project root for full license information.\n\nimport { PackageKind, ScenePackage } from '@cratis/scene.model';\nimport { ScenePackageBundle } from '@cratis/scene.react';\nimport { cratisComponents, cratisComponentsPackageName } from './cratisComponents';\n\n/**\n * The `Cratis.Components` package's declaration - what a profile gets when it lists this package.\n *\n * This is the concrete case the whole package-dependency mechanism exists for. `@cratis/components` is\n * not a self-contained library: every component in it is a wrapper over a PrimeReact widget, and its own\n * styling is a `--cratis-*` token layer (`@cratis/components/tokens`) plus the component stylesheets and\n * compiled Tailwind utilities in `@cratis/components/styles`. Activate it in a profile without PrimeReact\n * and nothing renders; activate it without Tailwind and everything renders unstyled. Both are stated as\n * dependencies so a package picker can say so while the profile is being configured, instead of leaving\n * it to be discovered when the page opens.\n *\n * The version ranges are the real ones the library carries. `>=11.0.0` for PrimeReact: version 3.0.0\n * declares `primereact@^11` as a peer dependency and is built against version 11's component set, so the\n * span across the major boundary that the previous `>=10.9.0` range described is over. The `--cratis-*`\n * tokens still resolve a version 10 theme variable as their last fallback, but that is an upgrade-window\n * courtesy for an application with a compiled version 10 stylesheet still on the page - not a version of\n * PrimeReact this package can be activated against. `^4.0.0` for Tailwind, because the utility sheet is\n * compiled against Tailwind 4.\n */\nexport const cratisComponentsPackageManifest: ScenePackage = {\n name: cratisComponentsPackageName,\n version: '3.0.0',\n kind: PackageKind.ComponentLibrary,\n dependencies: [\n { name: 'PrimeReact', versionRange: '>=11.0.0' },\n { name: 'Tailwind', versionRange: '^4.0.0' },\n ],\n components: [\n 'page',\n 'dataPage',\n 'formElement',\n 'singleResult',\n 'queryInputForm',\n 'dataTable',\n 'table',\n 'observableDataTable',\n 'commandForm',\n 'inputTextField',\n 'numberField',\n 'checkboxField',\n 'textAreaField',\n 'dropdownField',\n 'sliderField',\n 'calendarField',\n 'colorPickerField',\n 'multiSelectField',\n 'chipsField',\n 'radioButtonField',\n 'radioGroupField',\n 'dialog',\n 'confirmationDialog',\n 'busyIndicatorDialog',\n 'commandDialog',\n 'stepperCommandDialog',\n 'icon',\n 'tooltip',\n 'dropdown',\n 'errorBoundary',\n 'objectContentEditor',\n 'objectNavigationalBar',\n 'schemaEditor',\n 'timeMachine',\n 'filterPanel',\n 'toolbar',\n 'toolbarButton',\n 'toolbarGroup',\n 'toolbarSeparator',\n ],\n\n // A component library ships components, and nothing else. Layouts, screen templates and dialog\n // templates all belong to a Blueprint: they are decisions about what an application looks like as a\n // whole, and this package deliberately makes none of them - it provides the Arc-bound composites a\n // template is *built from*, so that a blueprint can place a `dataPage` in a slot and configure it,\n // rather than shipping one opinionated data page nobody can rearrange.\n layouts: [],\n screenTemplates: [],\n dialogTemplates: [],\n\n // No themes either, for a different reason: `@cratis/components` has no palette of its own. It reads\n // a `--cratis-*` variable layer that resolves whatever is in front of it - the `--p-*` properties a\n // PrimeReact 11 preset emits at runtime, or a Scene theme through this package's token bridge.\n // Shipping a theme here would be this library asserting a look it was specifically built not to have.\n themes: [],\n\n displayName: 'Cratis Components',\n description: \"Cratis' Arc-bound data, form and dialog composites, built on PrimeReact and Tailwind. dataTable and table accept optional object-valued queryArguments for collection queries. singleResult displays one read-only scalar own resultField of an optional model using an explicit query, object queryArguments and enabled: true. queryInputForm commits explicit string inputs on submit to the same optional-single runtime; drafts never execute a query.\",\n module: '@cratis/scene.components',\n license: 'MIT',\n licenseUrl: 'https://github.com/Cratis/Scene/blob/main/LICENSE',\n};\n\n/**\n * The `Cratis.Components` package as a loadable bundle - the manifest above, plus the React components\n * behind the names it declares.\n *\n * No `layouts`, `screenTemplates`, `dialogTemplates` or `themes` are provided, matching a manifest that\n * declares none of them; `validatePackageBundle` is what proves the two halves agree.\n */\nexport const cratisComponentsPackage: ScenePackageBundle = {\n manifest: cratisComponentsPackageManifest,\n components: cratisComponents,\n};\n"],"names":["cratisComponentsPackageManifest","name","cratisComponentsPackageName","version","kind","PackageKind","ComponentLibrary","dependencies","versionRange","components","layouts","screenTemplates","dialogTemplates","themes","displayName","description","module","license","licenseUrl","cratisComponentsPackage","manifest","cratisComponents"],"mappings":";;;;;AAAA;AACA;AAMA;;;;;;;;;;;;;;;;;;UAmBaA,+BAAAA,GAAgD;IACzDC,IAAAA,EAAMC,4CAAAA;IACNC,OAAAA,EAAS,OAAA;AACTC,IAAAA,IAAAA,EAAMC,wBAAYC,gBAAgB;IAClCC,YAAAA,EAAc;AACV,QAAA;YAAEN,IAAAA,EAAM,YAAA;YA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5
5
  var jsxRuntime = require('react/jsx-runtime');
6
6
  var react = require('react');
7
7
  var arc_react = require('@cratis/arc.react');
8
+ var fundamentals = require('@cratis/fundamentals');
8
9
  var SingleResultStatus = require('./SingleResultStatus.js');
9
10
 
10
11
  /**
11
12
  * Private execution owner. Arc owns validation, routing, HTTP and deserialization; this component
12
13
  * owns only request lifetime and presentation. No shared cache can hand B the result belonging to A.
13
- */ function SingleResultRuntime({ query, queryArguments, resultField }) {
14
+ */ function SingleResultRuntime({ query, queryArguments, resultField, stringInputs = false }) {
14
15
  const arc = react.useContext(arc_react.ArcContext);
15
16
  const { microservice, apiBasePath, origin, httpHeadersCallback, queryVersion } = arc;
16
17
  // Identity is deliberate: hosts replace immutable committed arguments rather than mutating them.
@@ -18,6 +19,7 @@ var SingleResultStatus = require('./SingleResultStatus.js');
18
19
  query,
19
20
  queryArguments,
20
21
  resultField,
22
+ stringInputs,
21
23
  microservice,
22
24
  apiBasePath,
23
25
  origin,
@@ -27,6 +29,7 @@ var SingleResultStatus = require('./SingleResultStatus.js');
27
29
  query,
28
30
  queryArguments,
29
31
  resultField,
32
+ stringInputs,
30
33
  microservice,
31
34
  apiBasePath,
32
35
  origin,
@@ -54,6 +57,18 @@ var SingleResultStatus = require('./SingleResultStatus.js');
54
57
  });
55
58
  return;
56
59
  }
60
+ // Arc perform does not validate argument-to-descriptor types. The form supports only
61
+ // scalar String/Guid inputs, matched by exact name and constructor, never by naming
62
+ // convention. This check is lazy and form-only; singleResult's host contract is intact.
63
+ if (request.stringInputs && !Object.entries(request.queryArguments).every(([name, value])=>{
64
+ const descriptors = instance.parameterDescriptors.filter((descriptor)=>descriptor.name === name);
65
+ return typeof value === 'string' && descriptors.length === 1 && !descriptors[0].isEnumerable && (descriptors[0].type === String || descriptors[0].type === fundamentals.Guid);
66
+ })) {
67
+ publish({
68
+ state: 'failure'
69
+ });
70
+ return;
71
+ }
57
72
  instance.setMicroservice(request.microservice);
58
73
  instance.setApiBasePath(request.apiBasePath ?? '');
59
74
  instance.setOrigin(request.origin ?? '');
@@ -1 +1 @@
1
- {"version":3,"file":"SingleResultRuntime.js","sources":["../../../data/SingleResultRuntime.tsx"],"sourcesContent":["// Copyright (c) Cratis. All rights reserved.\n// Licensed under the MIT license. See LICENSE file in the project root for full license information.\n\nimport { useContext, useEffect, useMemo, useState } from 'react';\nimport { ArcContext } from '@cratis/arc.react';\nimport type { QueryFor } from '@cratis/arc/queries';\nimport type { BoundConstructor } from '../bindings/BoundConstructor';\nimport { SingleResultStatus } from './SingleResultStatus';\n\ninterface Props {\n query: BoundConstructor;\n queryArguments: Record<string, unknown>;\n resultField: string;\n}\n\ntype Outcome = { state: 'failure' | 'notFound' } | { state: 'success'; value: string };\n\n/**\n * Private execution owner. Arc owns validation, routing, HTTP and deserialization; this component\n * owns only request lifetime and presentation. No shared cache can hand B the result belonging to A.\n */\nexport default function SingleResultRuntime({ query, queryArguments, resultField }: Props) {\n const arc = useContext(ArcContext);\n const { microservice, apiBasePath, origin, httpHeadersCallback, queryVersion } = arc;\n // Identity is deliberate: hosts replace immutable committed arguments rather than mutating them.\n const request = useMemo(() => ({ query, queryArguments, resultField, microservice, apiBasePath, origin, httpHeadersCallback, queryVersion }),\n [query, queryArguments, resultField, microservice, apiBasePath, origin, httpHeadersCallback, queryVersion]);\n const [settled, setSettled] = useState<{ request: typeof request; outcome: Outcome }>();\n\n useEffect(() => {\n // Each effect setup is a generation, including StrictMode's setup/cleanup/setup replay.\n let current = true;\n let instance: QueryFor<unknown, Record<string, unknown>> | undefined;\n const publish = (outcome: Outcome) => {\n if (current) setSettled({ request, outcome });\n };\n const execute = async () => {\n try {\n // The registry intentionally stores constructors without an eager Arc dependency.\n instance = new request.query() as QueryFor<unknown, Record<string, unknown>>;\n if (instance.enumerable !== false) {\n publish({ state: 'failure' });\n return;\n }\n instance.setMicroservice(request.microservice);\n instance.setApiBasePath(request.apiBasePath ?? '');\n instance.setOrigin(request.origin ?? '');\n instance.setHttpHeadersCallback(request.httpHeadersCallback ?? (() => ({})));\n // Native perform validates required arguments and proxy rules before HTTP. No copying,\n // defaults, business validation, route construction or array wrapping happens here.\n const result = await instance.perform(request.queryArguments);\n if (!current) return;\n if (result.isSuccess !== true || result.isAuthorized !== true || result.isValid !== true || result.hasExceptions !== false || result.isReady === false) {\n publish({ state: 'failure' });\n return;\n }\n if (result.data === null || result.data === undefined) {\n publish({ state: 'notFound' });\n return;\n }\n if (typeof result.data !== 'object' || Array.isArray(result.data)) {\n publish({ state: 'failure' });\n return;\n }\n // Only one own data field, never a path, inherited member, getter or expression.\n const descriptor = Object.getOwnPropertyDescriptor(result.data, request.resultField);\n const value: unknown = descriptor && 'value' in descriptor ? descriptor.value : undefined;\n if (typeof value === 'string' || typeof value === 'boolean' || (typeof value === 'number' && Number.isFinite(value))) {\n publish({ state: 'success', value: String(value) });\n } else {\n publish({ state: 'failure' });\n }\n } catch {\n // Includes native AbortError rejections. Disposed generations cannot publish or leak\n // an unhandled promise, even when the HTTP boundary ignores cancellation.\n publish({ state: 'failure' });\n }\n };\n void execute();\n return () => {\n current = false;\n instance?.abortController?.abort();\n };\n }, [request]);\n\n // Mask old data during the render that changes inputs, before effect cleanup/setup runs.\n if (settled?.request !== request) return <SingleResultStatus state='loading' />;\n return <SingleResultStatus {...settled.outcome} />;\n}\n"],"names":["SingleResultRuntime","query","queryArguments","resultField","arc","useContext","ArcContext","microservice","apiBasePath","origin","httpHeadersCallback","queryVersion","request","useMemo","settled","setSettled","useState","useEffect","current","instance","publish","outcome","execute","enumerable","state","setMicroservice","setApiBasePath","setOrigin","setHttpHeadersCallback","result","perform","isSuccess","isAuthorized","isValid","hasExceptions","isReady","data","undefined","Array","isArray","descriptor","Object","getOwnPropertyDescriptor","value","Number","isFinite","String","abortController","abort","_jsx","SingleResultStatus"],"mappings":";;;;;;;;;AAiBA;;;IAIe,SAASA,mBAAAA,CAAoB,EAAEC,KAAK,EAAEC,cAAc,EAAEC,WAAW,EAAS,EAAA;AACrF,IAAA,MAAM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OM,KAAAA,KAAU,QAAA,IAAY,OAAOA,KAAAA,KAAU,SAAA,IAAc,OAAOA,KAAAA,KAAU,QAAA,IAAYC,MAAAA,CAAOC,QAAQ,CAACF,KAAAA,CAAAA,EAAS;oBAClHvB,OAAAA,CAAQ;wBAAEI,KAAAA,EAAO,SAAA;AAAWmB,wBAAAA,KAAAA,EAAOG,MAAAA,CAAOH,KAAAA;AAAO,qBAAA,CAAA;gBACrD,CAAA,MAAO;oBACHvB,OAAAA,CAAQ;wBAAEI,KAAAA,EAAO;AAAU,qBAAA,CAAA;AAC/B,gBAAA;AACJ,YAAA,CAAA,CAAE,OAAM;;;gBAGJJ,OAAAA,CAAQ;oBAAEI,KAAAA,EAAO;AAAU,iBAAA,CAAA;AAC/B,YAAA;AACJ,QAAA,CAAA;QACA,KAAKF,OAAAA,EAAAA;QACL,OAAO,IAAA;YACHJ,OAAAA,GAAU,KAAA;AACVC,YAAAA,QAAAA,EAAU4B,eAAAA,EAAiBC,KAAAA,EAAAA;AAC/B,QAAA,CAAA;IACJ,CAAA,EAAG;AAACpC,QAAAA;AAAQ,KAAA,CAAA;;AAGZ,IAAA,IAAIE,OAAAA,EAASF,OAAAA,KAAYA,OAAAA,EAAS,qBAAOqC,cAAA,CAACC,qCAAAA,EAAAA;QAAmB1B,KAAAA,EAAM;;AACnE,IAAA,qBAAOyB,cAAA,CAACC,qCAAAA,EAAAA;AAAoB,QAAA,GAAGpC,QAAQO;;AAC3C;;"}
1
+ {"version":3,"file":"SingleResultRuntime.js","sources":["../../../data/SingleResultRuntime.tsx"],"sourcesContent":["// Copyright (c) Cratis. All rights reserved.\n// Licensed under the MIT license. See LICENSE file in the project root for full license information.\n\nimport { useContext, useEffect, useMemo, useState } from 'react';\nimport { ArcContext } from '@cratis/arc.react';\nimport type { QueryFor } from '@cratis/arc/queries';\nimport { Guid } from '@cratis/fundamentals';\nimport type { BoundConstructor } from '../bindings/BoundConstructor';\nimport { SingleResultStatus } from './SingleResultStatus';\n\ninterface Props {\n query: BoundConstructor;\n queryArguments: Record<string, unknown>;\n resultField: string;\n /** queryInputForm alone opts into scalar String/Guid descriptor mapping; no value conversion. */\n stringInputs?: boolean;\n}\n\ntype Outcome = { state: 'failure' | 'notFound' } | { state: 'success'; value: string };\n\n/**\n * Private execution owner. Arc owns validation, routing, HTTP and deserialization; this component\n * owns only request lifetime and presentation. No shared cache can hand B the result belonging to A.\n */\nexport default function SingleResultRuntime({ query, queryArguments, resultField, stringInputs = false }: Props) {\n const arc = useContext(ArcContext);\n const { microservice, apiBasePath, origin, httpHeadersCallback, queryVersion } = arc;\n // Identity is deliberate: hosts replace immutable committed arguments rather than mutating them.\n const request = useMemo(() => ({ query, queryArguments, resultField, stringInputs, microservice, apiBasePath, origin, httpHeadersCallback, queryVersion }),\n [query, queryArguments, resultField, stringInputs, microservice, apiBasePath, origin, httpHeadersCallback, queryVersion]);\n const [settled, setSettled] = useState<{ request: typeof request; outcome: Outcome }>();\n\n useEffect(() => {\n // Each effect setup is a generation, including StrictMode's setup/cleanup/setup replay.\n let current = true;\n let instance: QueryFor<unknown, Record<string, unknown>> | undefined;\n const publish = (outcome: Outcome) => {\n if (current) setSettled({ request, outcome });\n };\n const execute = async () => {\n try {\n // The registry intentionally stores constructors without an eager Arc dependency.\n instance = new request.query() as QueryFor<unknown, Record<string, unknown>>;\n if (instance.enumerable !== false) {\n publish({ state: 'failure' });\n return;\n }\n // Arc perform does not validate argument-to-descriptor types. The form supports only\n // scalar String/Guid inputs, matched by exact name and constructor, never by naming\n // convention. This check is lazy and form-only; singleResult's host contract is intact.\n if (request.stringInputs && !Object.entries(request.queryArguments).every(([name, value]) => {\n const descriptors = instance!.parameterDescriptors.filter(descriptor => descriptor.name === name);\n return typeof value === 'string' && descriptors.length === 1 && !descriptors[0].isEnumerable\n && (descriptors[0].type === String || descriptors[0].type === Guid);\n })) {\n publish({ state: 'failure' });\n return;\n }\n instance.setMicroservice(request.microservice);\n instance.setApiBasePath(request.apiBasePath ?? '');\n instance.setOrigin(request.origin ?? '');\n instance.setHttpHeadersCallback(request.httpHeadersCallback ?? (() => ({})));\n // Native perform validates required arguments and proxy rules before HTTP. No copying,\n // defaults, business validation, route construction or array wrapping happens here.\n const result = await instance.perform(request.queryArguments);\n if (!current) return;\n if (result.isSuccess !== true || result.isAuthorized !== true || result.isValid !== true || result.hasExceptions !== false || result.isReady === false) {\n publish({ state: 'failure' });\n return;\n }\n if (result.data === null || result.data === undefined) {\n publish({ state: 'notFound' });\n return;\n }\n if (typeof result.data !== 'object' || Array.isArray(result.data)) {\n publish({ state: 'failure' });\n return;\n }\n // Only one own data field, never a path, inherited member, getter or expression.\n const descriptor = Object.getOwnPropertyDescriptor(result.data, request.resultField);\n const value: unknown = descriptor && 'value' in descriptor ? descriptor.value : undefined;\n if (typeof value === 'string' || typeof value === 'boolean' || (typeof value === 'number' && Number.isFinite(value))) {\n publish({ state: 'success', value: String(value) });\n } else {\n publish({ state: 'failure' });\n }\n } catch {\n // Includes native AbortError rejections. Disposed generations cannot publish or leak\n // an unhandled promise, even when the HTTP boundary ignores cancellation.\n publish({ state: 'failure' });\n }\n };\n void execute();\n return () => {\n current = false;\n instance?.abortController?.abort();\n };\n }, [request]);\n\n // Mask old data during the render that changes inputs, before effect cleanup/setup runs.\n if (settled?.request !== request) return <SingleResultStatus state='loading' />;\n return <SingleResultStatus {...settled.outcome} />;\n}\n"],"names":["SingleResultRuntime","query","queryArguments","resultField","stringInputs","arc","useContext","ArcContext","microservice","apiBasePath","origin","httpHeadersCallback","queryVersion","request","useMemo","settled","setSettled","useState","useEffect","current","instance","publish","outcome","execute","enumerable","state","Object","entries","every","name","value","descriptors","parameterDescriptors","filter","descriptor","length","isEnumerable","type","String","Guid","setMicroservice","setApiBasePath","setOrigin","setHttpHeadersCallback","result","perform","isSuccess","isAuthorized","isValid","hasExceptions","isReady","data","undefined","Array","isArray","getOwnPropertyDescriptor","Number","isFinite","abortController","abort","_jsx","SingleResultStatus"],"mappings":";;;;;;;;;;AA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A;AACJ,YAAA,CAAA,CAAE,OAAM;;;gBAGJJ,OAAAA,CAAQ;oBAAEI,KAAAA,EAAO;AAAU,iBAAA,CAAA;AAC/B,YAAA;AACJ,QAAA,CAAA;QACA,KAAKF,OAAAA,EAAAA;QACL,OAAO,IAAA;YACHJ,OAAAA,GAAU,KAAA;AACVC,YAAAA,QAAAA,EAAUsC,eAAAA,EAAiBC,KAAAA,EAAAA;AAC/B,QAAA,CAAA;IACJ,CAAA,EAAG;AAAC9C,QAAAA;AAAQ,KAAA,CAAA;;AAGZ,IAAA,IAAIE,OAAAA,EAASF,OAAAA,KAAYA,OAAAA,EAAS,qBAAO+C,cAAA,CAACC,qCAAAA,EAAAA;QAAmBpC,KAAAA,EAAM;;AACnE,IAAA,qBAAOmC,cAAA,CAACC,qCAAAA,EAAAA;AAAoB,QAAA,GAAG9C,QAAQO;;AAC3C;;"}
@@ -0,0 +1,81 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ var jsxRuntime = require('react/jsx-runtime');
6
+ var CommandForm = require('@cratis/components/CommandForm');
7
+ var commands = require('@cratis/arc.react/commands');
8
+ var fundamentals = require('@cratis/fundamentals');
9
+ var CommandFormSubmit = require('./CommandFormSubmit.js');
10
+ var ExplicitCommandField = require('./ExplicitCommandField.js');
11
+
12
+ // Copyright (c) Cratis. All rights reserved.
13
+ // Licensed under the MIT license. See LICENSE file in the project root for full license information.
14
+ // Runtime bindings erase the proxy's keys; the optional footer is a Components >=4.13 contract.
15
+ const NativeAutoCommandForm = CommandForm.AutoCommandForm;
16
+ /** Verify the whole command before mounting any native form: partial forms must never execute. */ function capability(command, inputs, exclude) {
17
+ let descriptors;
18
+ try {
19
+ descriptors = new command().propertyDescriptors;
20
+ } catch {
21
+ return 'Unable to inspect command proxy';
22
+ }
23
+ if (!Array.isArray(descriptors)) return 'Command proxy has no property descriptors';
24
+ const byName = new Map();
25
+ for (const descriptor of descriptors){
26
+ if (!descriptor || typeof descriptor.name !== 'string' || !descriptor.name || typeof descriptor.isOptional !== 'boolean' || byName.has(descriptor.name)) return 'Ambiguous or invalid command property descriptors';
27
+ byName.set(descriptor.name, descriptor);
28
+ }
29
+ if (inputs) {
30
+ for (const input of inputs){
31
+ const descriptor = byName.get(input.property);
32
+ if (!descriptor) return `Unknown command property '${input.property}'`;
33
+ if (descriptor.type !== (input.type === 'guid' ? fundamentals.Guid : String)) return `Command property '${input.property}' type does not match '${input.type}'`;
34
+ }
35
+ for (const descriptor of byName.values()){
36
+ if (!descriptor.isOptional && !inputs.some((input)=>input.property === descriptor.name)) return `Required command property '${descriptor.name}' has no input`;
37
+ }
38
+ } else {
39
+ for (const descriptor of byName.values()){
40
+ if (!descriptor.isOptional && (exclude?.includes(descriptor.name) || ![
41
+ String,
42
+ Number,
43
+ Boolean,
44
+ Date
45
+ ].includes(descriptor.type))) {
46
+ return `Required command property '${descriptor.name}' has no supported automatic field; declare inputs`;
47
+ }
48
+ }
49
+ }
50
+ return undefined;
51
+ }
52
+ /** Private lazy entry point: importing the Scene registry must not import Arc. */ function CommandFormRuntime({ command, inputs, exclude, submitLabel }) {
53
+ const error = capability(command, inputs, exclude);
54
+ if (error) return /*#__PURE__*/ jsxRuntime.jsx("div", {
55
+ role: "alert",
56
+ children: error
57
+ });
58
+ // The registry's never-argument constructor is erased; Arc creates this checked proxy with no args.
59
+ if (inputs) return /*#__PURE__*/ jsxRuntime.jsxs(commands.CommandForm, {
60
+ command: command,
61
+ showTitles: false,
62
+ children: [
63
+ inputs.map((input)=>/*#__PURE__*/ jsxRuntime.jsx(ExplicitCommandField.ExplicitCommandField, {
64
+ input: input
65
+ }, input.property)),
66
+ /*#__PURE__*/ jsxRuntime.jsx(CommandFormSubmit.CommandFormSubmit, {
67
+ label: submitLabel
68
+ })
69
+ ]
70
+ });
71
+ return /*#__PURE__*/ jsxRuntime.jsx(NativeAutoCommandForm, {
72
+ command: command,
73
+ exclude: exclude,
74
+ footer: /*#__PURE__*/ jsxRuntime.jsx(CommandFormSubmit.CommandFormSubmit, {
75
+ label: submitLabel
76
+ })
77
+ });
78
+ }
79
+
80
+ exports.default = CommandFormRuntime;
81
+ //# sourceMappingURL=CommandFormRuntime.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"CommandFormRuntime.js","sources":["../../../forms/CommandFormRuntime.tsx"],"sourcesContent":["// Copyright (c) Cratis. All rights reserved.\n// Licensed under the MIT license. See LICENSE file in the project root for full license information.\n\nimport type { ComponentType, ReactNode } from 'react';\nimport { AutoCommandForm } from '@cratis/components/CommandForm';\nimport { CommandForm } from '@cratis/arc.react/commands';\nimport { Guid } from '@cratis/fundamentals';\nimport type { BoundConstructor } from '../bindings';\nimport type { CommandInput } from './commandInputs';\nimport { CommandFormSubmit } from './CommandFormSubmit';\nimport { ExplicitCommandField } from './ExplicitCommandField';\n\ninterface CommandFormRuntimeProps {\n command: BoundConstructor;\n inputs?: CommandInput[];\n exclude?: string[];\n submitLabel: string;\n}\n\n// Runtime bindings erase the proxy's keys; the optional footer is a Components >=4.13 contract.\nconst NativeAutoCommandForm = AutoCommandForm as unknown as ComponentType<{\n command: BoundConstructor;\n exclude?: string[];\n footer?: ReactNode;\n}>;\n\ntype Descriptor = { name: string; type: unknown; isOptional: boolean };\n\n/** Verify the whole command before mounting any native form: partial forms must never execute. */\nfunction capability(command: BoundConstructor, inputs?: CommandInput[], exclude?: string[]): string | undefined {\n let descriptors: unknown;\n try { descriptors = (new command() as { propertyDescriptors?: unknown }).propertyDescriptors; }\n catch { return 'Unable to inspect command proxy'; }\n if (!Array.isArray(descriptors)) return 'Command proxy has no property descriptors';\n const byName = new Map<string, Descriptor>();\n for (const descriptor of descriptors) {\n if (!descriptor || typeof descriptor.name !== 'string' || !descriptor.name ||\n typeof descriptor.isOptional !== 'boolean' || byName.has(descriptor.name)) return 'Ambiguous or invalid command property descriptors';\n byName.set(descriptor.name, descriptor);\n }\n if (inputs) {\n for (const input of inputs) {\n const descriptor = byName.get(input.property);\n if (!descriptor) return `Unknown command property '${input.property}'`;\n if (descriptor.type !== (input.type === 'guid' ? Guid : String)) return `Command property '${input.property}' type does not match '${input.type}'`;\n }\n for (const descriptor of byName.values()) {\n if (!descriptor.isOptional && !inputs.some(input => input.property === descriptor.name)) return `Required command property '${descriptor.name}' has no input`;\n }\n } else {\n for (const descriptor of byName.values()) {\n if (!descriptor.isOptional && (exclude?.includes(descriptor.name) ||\n ![String, Number, Boolean, Date].includes(descriptor.type as typeof String))) {\n return `Required command property '${descriptor.name}' has no supported automatic field; declare inputs`;\n }\n }\n }\n return undefined;\n}\n\n/** Private lazy entry point: importing the Scene registry must not import Arc. */\nexport default function CommandFormRuntime({ command, inputs, exclude, submitLabel }: CommandFormRuntimeProps) {\n const error = capability(command, inputs, exclude);\n if (error) return <div role='alert'>{error}</div>;\n // The registry's never-argument constructor is erased; Arc creates this checked proxy with no args.\n if (inputs) return <CommandForm command={command as unknown as new () => object} showTitles={false}>\n {inputs.map(input => <ExplicitCommandField key={input.property} input={input} />)}\n <CommandFormSubmit label={submitLabel} />\n </CommandForm>;\n return <NativeAutoCommandForm command={command} exclude={exclude} footer={<CommandFormSubmit label={submitLabel} />} />;\n}\n"],"names":["NativeAutoCommandForm","AutoCommandForm","capability","command","inputs","exclude","descriptors","propertyDescriptors","Array","isArray","byName","Map","descriptor","name","isOptional","has","set","input","get","property","type","Guid","String","values","some","includes","Number","Boolean","Date","undefined","CommandFormRuntime","submitLabel","error","_jsx","div","role","_jsxs","CommandForm","showTitles","map","ExplicitCommandField","CommandFormSubmit","label","footer"],"mappings":";;;;;;;;;;;AAAA;AACA;AAkBA;AACA,MAAMA,qBAAAA,GAAwBC,2BAAAA;AAQ9B,mGACA,SAASC,UAAAA,CAAWC,OAAyB,EAAEC,MAAuB,EAAEC,OAAkB,EAAA;IACtF,IAAIC,WAAAA;IACJ,IAAI;QAAEA,WAAAA,GAAe,IAAIH,OAAAA,EAAAA,CAAgDI,mBAAmB;AAAE,IAAA,CAAA,CAC9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;;AAE9B,IAAA,qBAAOE,cAAA,CAACjC,qBAAAA,EAAAA;QAAsBG,OAAAA,EAASA,OAAAA;QAASE,OAAAA,EAASA,OAAAA;AAASsC,QAAAA,MAAAA,gBAAQV,cAAA,CAACQ,mCAAAA,EAAAA;YAAkBC,KAAAA,EAAOX;;;AACxG;;"}
@@ -0,0 +1,19 @@
1
+ 'use strict';
2
+
3
+ var jsxRuntime = require('react/jsx-runtime');
4
+ var commands = require('@cratis/arc.react/commands');
5
+
6
+ /** Internal footer child; only rendered under the native form's context. */ function CommandFormSubmit({ label }) {
7
+ const { isExecuting, isAuthorized } = commands.useCommandFormContext();
8
+ // Do not gate on isValid: submitting untouched invalid fields must reveal native validation.
9
+ // No click handler: the containing Arc form owns submission, validation and execution.
10
+ return /*#__PURE__*/ jsxRuntime.jsx("button", {
11
+ type: "submit",
12
+ disabled: isExecuting || !isAuthorized,
13
+ "aria-busy": isExecuting,
14
+ children: label
15
+ });
16
+ }
17
+
18
+ exports.CommandFormSubmit = CommandFormSubmit;
19
+ //# sourceMappingURL=CommandFormSubmit.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"CommandFormSubmit.js","sources":["../../../forms/CommandFormSubmit.tsx"],"sourcesContent":["// Copyright (c) Cratis. All rights reserved.\n// Licensed under the MIT license. See LICENSE file in the project root for full license information.\n\nimport { useCommandFormContext } from '@cratis/arc.react/commands';\n\ninterface CommandFormSubmitProps {\n label: string;\n}\n\n/** Internal footer child; only rendered under the native form's context. */\nexport function CommandFormSubmit({ label }: CommandFormSubmitProps) {\n const { isExecuting, isAuthorized } = useCommandFormContext();\n // Do not gate on isValid: submitting untouched invalid fields must reveal native validation.\n // No click handler: the containing Arc form owns submission, validation and execution.\n return <button type='submit' disabled={isExecuting || !isAuthorized} aria-busy={isExecuting}>{label}</button>;\n}\n"],"names":["CommandFormSubmit","label","isExecuting","isAuthorized","useCommandFormContext","_jsx","button","type","disabled","aria-busy"],"mappings":";;;;;AASA,6EACO,SAASA,iBAAAA,CAAkB,EAAEC,KAAK,EAA0B,EAAA;AAC/D,IAAA,MAAM,EAAEC,WAAW,EAAEC,YAAY,EAAE,GAAGC,8BAAAA,EAAAA;;;AAGtC,IAAA,qBAAOC,cAAA,CAACC,QAAAA,EAAAA;QAAOC,IAAAA,EAAK,QAAA;AAASC,QAAAA,QAAAA,EAAUN,eAAe,CAACC,YAAAA;QAAcM,WAAAA,EAAWP,WAAAA;AAAcD,QAAAA,QAAAA,EAAAA;;AAClG;;"}
@@ -0,0 +1,109 @@
1
+ 'use strict';
2
+
3
+ var jsxRuntime = require('react/jsx-runtime');
4
+ var react = require('react');
5
+ var commands = require('@cratis/arc.react/commands');
6
+ var fundamentals = require('@cratis/fundamentals');
7
+
8
+ function TextControl({ value, onChange, onBlur, invalid, required, errors, label, property, guid }) {
9
+ const id = react.useId();
10
+ const context = commands.useCommandFormContext();
11
+ const { setCustomFieldError } = context;
12
+ // Keep the latest native getter: the context snapshot can be stale when another field sets an
13
+ // error and this field unmounts in the same event.
14
+ const contextRef = react.useRef(context);
15
+ contextRef.current = context;
16
+ // The draft is intentionally independent of the typed proxy value: malformed text must never
17
+ // reappear as a stale previously valid Guid in the command's serialized payload.
18
+ const [draft, setDraft] = react.useState(()=>value instanceof fundamentals.Guid && !value.equals(fundamentals.Guid.empty) ? value.toString() : '');
19
+ const draftRef = react.useRef(draft);
20
+ const ownedError = react.useRef(undefined);
21
+ const updateError = (error)=>{
22
+ const current = contextRef.current.getFieldError(property);
23
+ // Do not replace or erase another producer's error for this field.
24
+ if (ownedError.current !== undefined && current !== ownedError.current) {
25
+ ownedError.current = undefined;
26
+ return;
27
+ }
28
+ if (ownedError.current === undefined && Object.hasOwn(contextRef.current.customFieldErrors, property)) return;
29
+ if (error === undefined && ownedError.current === undefined) return;
30
+ ownedError.current = error;
31
+ setCustomFieldError(property, error);
32
+ };
33
+ // A label/required change must recalculate the message without disposing the field's error.
34
+ // Only a different field/type or an actual unmount relinquishes ownership.
35
+ react.useLayoutEffect(()=>()=>{
36
+ if (ownedError.current !== undefined && contextRef.current.getFieldError(property) === ownedError.current) {
37
+ contextRef.current.setCustomFieldError(property, undefined);
38
+ }
39
+ ownedError.current = undefined;
40
+ }, [
41
+ property,
42
+ guid
43
+ ]);
44
+ react.useLayoutEffect(()=>{
45
+ if (guid) {
46
+ const current = draftRef.current || (value instanceof fundamentals.Guid && !value.equals(fundamentals.Guid.empty) ? value.toString() : '');
47
+ updateError(!current ? required ? `${label} is required` : undefined : !fundamentals.Guid.isGuid(current) ? `${label} must be a valid GUID` : undefined);
48
+ }
49
+ }, [
50
+ guid,
51
+ required,
52
+ property,
53
+ label,
54
+ setCustomFieldError
55
+ ]);
56
+ const text = guid ? draft : typeof value === 'string' ? value : '';
57
+ return /*#__PURE__*/ jsxRuntime.jsxs("div", {
58
+ children: [
59
+ /*#__PURE__*/ jsxRuntime.jsx("label", {
60
+ htmlFor: id,
61
+ children: label
62
+ }),
63
+ /*#__PURE__*/ jsxRuntime.jsx("input", {
64
+ id: id,
65
+ name: property,
66
+ type: "text",
67
+ required: required,
68
+ value: text,
69
+ "aria-invalid": invalid,
70
+ "aria-describedby": errors.length ? `${id}-error` : undefined,
71
+ onBlur: onBlur,
72
+ onChange: (event)=>{
73
+ const next = event.currentTarget.value;
74
+ if (!guid) {
75
+ onChange(next);
76
+ return;
77
+ }
78
+ draftRef.current = next;
79
+ setDraft(next);
80
+ const error = !next ? required ? `${label} is required` : undefined : !fundamentals.Guid.isGuid(next) ? `${label} must be a valid GUID` : undefined;
81
+ // A malformed draft clears the previously typed value, not just its display.
82
+ onChange(error || !next ? undefined : fundamentals.Guid.parse(next));
83
+ updateError(error);
84
+ }
85
+ }),
86
+ errors.length > 0 && /*#__PURE__*/ jsxRuntime.jsx("div", {
87
+ id: `${id}-error`,
88
+ role: "alert",
89
+ children: errors[0]
90
+ })
91
+ ]
92
+ });
93
+ }
94
+ const NativeTextField = commands.asCommandFormField(TextControl, {
95
+ defaultValue: ''
96
+ });
97
+ /** Opaque child is self-bound by Arc's native runtime binding, with an exact fieldName. */ function ExplicitCommandField({ input }) {
98
+ return /*#__PURE__*/ jsxRuntime.jsx(NativeTextField, {
99
+ fieldName: input.property,
100
+ value: (command)=>command[input.property],
101
+ property: input.property,
102
+ guid: input.type === 'guid',
103
+ label: input.label,
104
+ title: input.label
105
+ });
106
+ }
107
+
108
+ exports.ExplicitCommandField = ExplicitCommandField;
109
+ //# sourceMappingURL=ExplicitCommandField.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ExplicitCommandField.js","sources":["../../../forms/ExplicitCommandField.tsx"],"sourcesContent":["// Copyright (c) Cratis. All rights reserved.\n// Licensed under the MIT license. See LICENSE file in the project root for full license information.\n\nimport { useId, useLayoutEffect, useRef, useState } from 'react';\nimport { asCommandFormField, useCommandFormContext } from '@cratis/arc.react/commands';\nimport { Guid } from '@cratis/fundamentals';\nimport type { CommandInput } from './commandInputs';\n\ninterface TextProps {\n value: unknown;\n onChange: (value: unknown) => void;\n onBlur?: () => void;\n invalid: boolean;\n required: boolean;\n errors: string[];\n label: string;\n property: string;\n guid: boolean;\n}\n\nfunction TextControl({ value, onChange, onBlur, invalid, required, errors, label, property, guid }: TextProps) {\n const id = useId();\n const context = useCommandFormContext();\n const { setCustomFieldError } = context;\n // Keep the latest native getter: the context snapshot can be stale when another field sets an\n // error and this field unmounts in the same event.\n const contextRef = useRef(context);\n contextRef.current = context;\n // The draft is intentionally independent of the typed proxy value: malformed text must never\n // reappear as a stale previously valid Guid in the command's serialized payload.\n const [draft, setDraft] = useState(() => value instanceof Guid && !value.equals(Guid.empty) ? value.toString() : '');\n const draftRef = useRef(draft);\n const ownedError = useRef<string | undefined>(undefined);\n const updateError = (error: string | undefined) => {\n const current = contextRef.current.getFieldError(property);\n // Do not replace or erase another producer's error for this field.\n if (ownedError.current !== undefined && current !== ownedError.current) {\n ownedError.current = undefined;\n return;\n }\n if (ownedError.current === undefined && Object.hasOwn(contextRef.current.customFieldErrors, property)) return;\n if (error === undefined && ownedError.current === undefined) return;\n ownedError.current = error;\n setCustomFieldError(property, error);\n };\n // A label/required change must recalculate the message without disposing the field's error.\n // Only a different field/type or an actual unmount relinquishes ownership.\n useLayoutEffect(() => () => {\n if (ownedError.current !== undefined && contextRef.current.getFieldError(property) === ownedError.current) {\n contextRef.current.setCustomFieldError(property, undefined);\n }\n ownedError.current = undefined;\n }, [property, guid]);\n useLayoutEffect(() => {\n if (guid) {\n const current = draftRef.current || (value instanceof Guid && !value.equals(Guid.empty) ? value.toString() : '');\n updateError(!current ? required ? `${label} is required` : undefined :\n !Guid.isGuid(current) ? `${label} must be a valid GUID` : undefined);\n }\n }, [guid, required, property, label, setCustomFieldError]);\n const text = guid ? draft : typeof value === 'string' ? value : '';\n return <div>\n <label htmlFor={id}>{label}</label>\n <input id={id} name={property} type='text' required={required} value={text}\n aria-invalid={invalid} aria-describedby={errors.length ? `${id}-error` : undefined}\n onBlur={onBlur} onChange={event => {\n const next = event.currentTarget.value;\n if (!guid) { onChange(next); return; }\n draftRef.current = next;\n setDraft(next);\n const error = !next ? required ? `${label} is required` : undefined : !Guid.isGuid(next) ? `${label} must be a valid GUID` : undefined;\n // A malformed draft clears the previously typed value, not just its display.\n onChange(error || !next ? undefined : Guid.parse(next));\n updateError(error);\n }} />\n {errors.length > 0 && <div id={`${id}-error`} role='alert'>{errors[0]}</div>}\n </div>;\n}\n\nconst NativeTextField = asCommandFormField<TextProps>(TextControl, { defaultValue: '' });\n\n/** Opaque child is self-bound by Arc's native runtime binding, with an exact fieldName. */\nexport function ExplicitCommandField({ input }: { input: CommandInput }) {\n return <NativeTextField fieldName={input.property} value={(command: Record<string, unknown>) => command[input.property]}\n property={input.property} guid={input.type === 'guid'} label={input.label} title={input.label} />;\n}\n"],"names":["TextControl","value","onChange","onBlur","invalid","required","errors","label","property","guid","id","useId","context","useCommandFormContext","setCustomFieldError","contextRef","useRef","current","draft","setDraft","useState","Guid","equals","empty","toString","draftRef","ownedError","undefined","updateError","error","getFieldError","Object","hasOwn","customFieldErrors","useLayoutEffect","isGuid","text","_jsxs","div","_jsx","htmlFor","input","name","type","aria-invalid","aria-describedby","length","event","next","currentTarget","parse","role","NativeTextField","asCommandFormField","defaultValue","ExplicitCommandField","fieldName","command","title"],"mappings":";;;;;;;AAoBA,SAASA,YAAY,EAAEC,KAAK,EAAEC,QAAQ,EAAEC,MAAM,EAAEC,OAAO,EAAEC,QAAQ,EAAEC,MAAM,EAAEC,KAAK,EAAEC,QAAQ,EAAEC,IAAI,EAAa,EAAA;AACzG,IAAA,MAAMC,EAAAA,GAAKC,WAAAA,EAAAA;AACX,IAAA,MAAMC,OAAAA,GAAUC,8BAAAA,EAAAA;IAChB,MAAM,EAAEC,mBAAmB,EAAE,GAAGF,OAAAA;;;AAGhC,IAAA,MAAMG,aAAaC,YAAAA,CAAOJ,OAAAA,CAAAA;AAC1BG,IAAAA,UAAAA,CAAWE,OAAO,GAAGL,OAAAA;;;AAGrB,IAAA,MAAM,CAACM,KAAAA,EAAOC,QAAAA,CAAS,GAAGC,cAAAA,CAAS,IAAMnB,KAAAA,YAAiBoB,iBAAAA,IAAQ,CAACpB,KAAAA,CAAMqB,MAAM,CAACD,iBAAAA,CAAKE,KAAK,CAAA,GAAItB,KAAAA,CAAMuB,QAAQ,EAAA,GAAK,EAAA,CAAA;AACjH,IAAA,MAAMC,WAAWT,YAAAA,CAAOE,KAAAA,CAAAA;AACxB,IAAA,MAAMQ,aAAaV,YAAAA,CAA2BW,SAAAA,CAAAA;AAC9C,IAAA,MAAMC,cAAc,CAACC,KAAAA,GAAAA;AACjB,QAAA,MAAMZ,OAAAA,GAAUF,UAAAA,CAAWE,OAAO,CAACa,aAAa,CAACtB,QAAAA,CAAAA;;AAEjD,QAAA,IAAIkB,WAAWT,OAAO,KAAKU,aAAaV,OAAAA,KAAYS,UAAAA,CAAWT,OAAO,EAAE;AACpES,YAAAA,UAAAA,CAAWT,OAAO,GAAGU,SAAAA;AACrB,YAAA;AACJ,QAAA;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iBAAAA,CAAKc,MAAM,CAACa,IAAAA,CAAAA,GAAQ,GAAGzC,KAAAA,CAAM,qBAAqB,CAAC,GAAGoB,SAAAA;;AAE7HzB,oBAAAA,QAAAA,CAAS2B,SAAS,CAACmB,IAAAA,GAAOrB,SAAAA,GAAYN,iBAAAA,CAAK6B,KAAK,CAACF,IAAAA,CAAAA,CAAAA;oBACjDpB,WAAAA,CAAYC,KAAAA,CAAAA;AAChB,gBAAA;;YACHvB,MAAAA,CAAOwC,MAAM,GAAG,CAAA,kBAAKP,cAAA,CAACD,KAAAA,EAAAA;gBAAI5B,EAAAA,EAAI,CAAA,EAAGA,EAAAA,CAAG,MAAM,CAAC;gBAAEyC,IAAAA,EAAK,OAAA;AAAS7C,gBAAAA,QAAAA,EAAAA,MAAM,CAAC,CAAA;;;;AAE3E;AAEA,MAAM8C,eAAAA,GAAkBC,4BAA8BrD,WAAAA,EAAa;IAAEsD,YAAAA,EAAc;AAAG,CAAA,CAAA;AAEtF,4FACO,SAASC,oBAAAA,CAAqB,EAAEd,KAAK,EAA2B,EAAA;AACnE,IAAA,qBAAOF,cAAA,CAACa,eAAAA,EAAAA;AAAgBI,QAAAA,SAAAA,EAAWf,MAAMjC,QAAQ;AAAEP,QAAAA,KAAAA,EAAO,CAACwD,OAAAA,GAAqCA,OAAO,CAAChB,KAAAA,CAAMjC,QAAQ,CAAC;AACnHA,QAAAA,QAAAA,EAAUiC,MAAMjC,QAAQ;QAAEC,IAAAA,EAAMgC,KAAAA,CAAME,IAAI,KAAK,MAAA;AAAQpC,QAAAA,KAAAA,EAAOkC,MAAMlC,KAAK;AAAEmD,QAAAA,KAAAA,EAAOjB,MAAMlC;;AAChG;;"}
@@ -7,26 +7,24 @@ var resolveElementBinding = require('../bindings/resolveElementBinding.js');
7
7
  var MissingBinding = require('../bindings/MissingBinding.js');
8
8
  var ArcRuntimeBoundary = require('../bindings/ArcRuntimeBoundary.js');
9
9
  var properties = require('../properties.js');
10
+ var commandInputs = require('./commandInputs.js');
10
11
 
12
+ const CommandFormRuntime = /*#__PURE__*/ react.lazy(()=>Promise.resolve().then(function () { return require('./CommandFormRuntime.js'); }));
13
+ // Arc's useCommand constructs the proxy only on mount. Key by the actual registered class,
14
+ // not its Scene name (which may be re-registered with a different route or roles).
15
+ const commandKeys = new WeakMap();
16
+ let nextCommandKey = 0;
17
+ function commandKey(command) {
18
+ let key = commandKeys.get(command);
19
+ if (key === undefined) {
20
+ key = ++nextCommandKey;
21
+ commandKeys.set(command, key);
22
+ }
23
+ return key;
24
+ }
11
25
  /**
12
- * `AutoCommandForm` types `exclude` as `(keyof TCommand)[]`, which collapses to `never[]` when the
13
- * command type is only known at runtime - as it always is here, since the class arrives from the binding
14
- * registry rather than from a type annotation. The conversion states the shape this adapter actually
15
- * passes; the underlying component reads `exclude` as property names either way.
16
- */ const AutoCommandForm = /*#__PURE__*/ react.lazy(async ()=>({
17
- default: (await import('@cratis/components/CommandForm')).AutoCommandForm
18
- }));
19
- /**
20
- * The `Cratis.Components:commandForm` component - `AutoCommandForm` from `@cratis/components/CommandForm`.
21
- *
22
- * `AutoCommandForm` rather than `CommandForm`, because a screen that had to list every field by hand
23
- * would go stale the moment a property is added to the command on the backend. `AutoCommandForm` reads
24
- * the command's own property descriptors and picks a field component per property type, so the form
25
- * follows the command - which is the same guarantee Arc's generated proxies give the rest of the stack.
26
- *
27
- * A screen that does want to place fields itself puts the field components from this package in the
28
- * `content` slot and names them individually; `exclude` keeps `AutoCommandForm` from generating a second
29
- * copy of anything placed that way.
26
+ * Auto mode follows supported native proxy descriptors; opt-in inputs bind exactly named fields
27
+ * inside a single native Arc form. Neither mode consumes the content slot.
30
28
  */ function SceneCommandForm({ element }) {
31
29
  const { name, target } = resolveElementBinding.resolveElementBinding(element, BindingKind.BindingKind.Command);
32
30
  if (!target) return /*#__PURE__*/ jsxRuntime.jsx(MissingBinding.MissingBinding, {
@@ -34,11 +32,18 @@ var properties = require('../properties.js');
34
32
  kind: BindingKind.BindingKind.Command,
35
33
  name: name
36
34
  });
35
+ const inputs = Object.hasOwn(element.properties, 'inputs') ? commandInputs.commandInputs(element.properties) : undefined;
36
+ if (Object.hasOwn(element.properties, 'inputs') && !inputs) return /*#__PURE__*/ jsxRuntime.jsx("div", {
37
+ role: "alert",
38
+ children: "Invalid command form inputs declaration"
39
+ });
37
40
  return /*#__PURE__*/ jsxRuntime.jsx(ArcRuntimeBoundary.ArcRuntimeBoundary, {
38
- children: /*#__PURE__*/ jsxRuntime.jsx(AutoCommandForm, {
41
+ children: /*#__PURE__*/ jsxRuntime.jsx(CommandFormRuntime, {
39
42
  command: target,
40
- exclude: properties.stringArrayProperty(element.properties, 'exclude')
41
- })
43
+ inputs: inputs,
44
+ exclude: properties.stringArrayProperty(element.properties, 'exclude'),
45
+ submitLabel: properties.stringProperty(element.properties, 'submitLabel') ?? 'Submit'
46
+ }, commandKey(target))
42
47
  });
43
48
  }
44
49
 
@@ -1 +1 @@
1
- {"version":3,"file":"SceneCommandForm.js","sources":["../../../forms/SceneCommandForm.tsx"],"sourcesContent":["// Copyright (c) Cratis. All rights reserved.\n// Licensed under the MIT license. See LICENSE file in the project root for full license information.\n\nimport { ComponentType, lazy } from 'react';\nimport { RegisteredComponentProps } from '@cratis/scene.react';\nimport { ArcRuntimeBoundary, BindingKind, BoundConstructor, MissingBinding, resolveElementBinding } from '../bindings';\nimport { stringArrayProperty } from '../properties';\n\ninterface AutoCommandFormElementProps {\n command: BoundConstructor;\n exclude?: string[];\n}\n\n/**\n * `AutoCommandForm` types `exclude` as `(keyof TCommand)[]`, which collapses to `never[]` when the\n * command type is only known at runtime - as it always is here, since the class arrives from the binding\n * registry rather than from a type annotation. The conversion states the shape this adapter actually\n * passes; the underlying component reads `exclude` as property names either way.\n */\nconst AutoCommandForm = lazy(async () => ({\n default: (await import('@cratis/components/CommandForm')).AutoCommandForm as unknown as ComponentType<AutoCommandFormElementProps>,\n}));\n\n/**\n * The `Cratis.Components:commandForm` component - `AutoCommandForm` from `@cratis/components/CommandForm`.\n *\n * `AutoCommandForm` rather than `CommandForm`, because a screen that had to list every field by hand\n * would go stale the moment a property is added to the command on the backend. `AutoCommandForm` reads\n * the command's own property descriptors and picks a field component per property type, so the form\n * follows the command - which is the same guarantee Arc's generated proxies give the rest of the stack.\n *\n * A screen that does want to place fields itself puts the field components from this package in the\n * `content` slot and names them individually; `exclude` keeps `AutoCommandForm` from generating a second\n * copy of anything placed that way.\n */\nexport function SceneCommandForm({ element }: RegisteredComponentProps) {\n const { name, target } = resolveElementBinding(element, BindingKind.Command);\n if (!target) return <MissingBinding element={element} kind={BindingKind.Command} name={name} />;\n\n return (\n <ArcRuntimeBoundary>\n <AutoCommandForm command={target} exclude={stringArrayProperty(element.properties, 'exclude')} />\n </ArcRuntimeBoundary>\n );\n}\n"],"names":["AutoCommandForm","lazy","default","SceneCommandForm","element","name","target","resolveElementBinding","BindingKind","Command","_jsx","MissingBinding","kind","ArcRuntimeBoundary","command","exclude","stringArrayProperty","properties"],"mappings":";;;;;;;;;;AAaA;;;;;AAKC,IACD,MAAMA,eAAAA,iBAAkBC,UAAAA,CAAK,WAAa;AACtCC,QAAAA,OAAAA,EAAS,CAAC,MAAM,OAAO,gCAAA,CAAgC,EAAGF;KAC9D,CAAA,CAAA;AAEA;;;;;;;;;;;AAWC,IACM,SAASG,gBAAAA,CAAiB,EAAEC,OAAO,EAA4B,EAAA;IAClE,MAAM,EAAEC,IAAI,EAAEC,MAAM,EAAE,GAAGC,2CAAAA,CAAsBH,OAAAA,EAASI,uBAAAA,CAAYC,OAAO,CAAA;IAC3E,IAAI,CAACH,MAAAA,EAAQ,qBAAOI,cAAA,CAACC,6BAAAA,EAAAA;QAAeP,OAAAA,EAASA,OAAAA;AAASQ,QAAAA,IAAAA,EAAMJ,wBAAYC,OAAO;QAAEJ,IAAAA,EAAMA;;AAEvF,IAAA,qBACIK,cAAA,CAACG,qCAAAA,EAAAA;AACG,QAAA,QAAA,gBAAAH,cAAA,CAACV,eAAAA,EAAAA;YAAgBc,OAAAA,EAASR,MAAAA;YAAQS,OAAAA,EAASC,8BAAAA,CAAoBZ,OAAAA,CAAQa,UAAU,EAAE,SAAA;;;AAG/F;;"}
1
+ {"version":3,"file":"SceneCommandForm.js","sources":["../../../forms/SceneCommandForm.tsx"],"sourcesContent":["// Copyright (c) Cratis. All rights reserved.\n// Licensed under the MIT license. See LICENSE file in the project root for full license information.\n\nimport { lazy } from 'react';\nimport { RegisteredComponentProps } from '@cratis/scene.react';\nimport { ArcRuntimeBoundary, BindingKind, MissingBinding, resolveElementBinding } from '../bindings';\nimport type { BoundConstructor } from '../bindings';\nimport { stringArrayProperty, stringProperty } from '../properties';\nimport { commandInputs } from './commandInputs';\n\nconst CommandFormRuntime = lazy(() => import('./CommandFormRuntime'));\n\n// Arc's useCommand constructs the proxy only on mount. Key by the actual registered class,\n// not its Scene name (which may be re-registered with a different route or roles).\nconst commandKeys = new WeakMap<BoundConstructor, number>();\nlet nextCommandKey = 0;\nfunction commandKey(command: BoundConstructor): number {\n let key = commandKeys.get(command);\n if (key === undefined) {\n key = ++nextCommandKey;\n commandKeys.set(command, key);\n }\n return key;\n}\n\n/**\n * Auto mode follows supported native proxy descriptors; opt-in inputs bind exactly named fields\n * inside a single native Arc form. Neither mode consumes the content slot.\n */\nexport function SceneCommandForm({ element }: RegisteredComponentProps) {\n const { name, target } = resolveElementBinding(element, BindingKind.Command);\n if (!target) return <MissingBinding element={element} kind={BindingKind.Command} name={name} />;\n\n const inputs = Object.hasOwn(element.properties, 'inputs') ? commandInputs(element.properties) : undefined;\n if (Object.hasOwn(element.properties, 'inputs') && !inputs) return <div role='alert'>Invalid command form inputs declaration</div>;\n\n return (\n <ArcRuntimeBoundary>\n <CommandFormRuntime\n key={commandKey(target)}\n command={target}\n inputs={inputs}\n exclude={stringArrayProperty(element.properties, 'exclude')}\n submitLabel={stringProperty(element.properties, 'submitLabel') ?? 'Submit'}\n />\n </ArcRuntimeBoundary>\n );\n}\n"],"names":["CommandFormRuntime","lazy","commandKeys","WeakMap","nextCommandKey","commandKey","command","key","get","undefined","set","SceneCommandForm","element","name","target","resolveElementBinding","BindingKind","Command","_jsx","MissingBinding","kind","inputs","Object","hasOwn","properties","commandInputs","div","role","ArcRuntimeBoundary","exclude","stringArrayProperty","submitLabel","stringProperty"],"mappings":";;;;;;;;;;;AAUA,MAAMA,kBAAAA,iBAAqBC,UAAAA,CAAK,IAAM,oDAAO,yBAAA,KAAA,CAAA;AAE7C;AACA;AACA,MAAMC,cAAc,IAAIC,OAAAA,EAAAA;AACxB,IAAIC,cAAAA,GAAiB,CAAA;AACrB,SAASC,WAAWC,OAAyB,EAAA;IACzC,IAAIC,GAAAA,GAAML,WAAAA,CAAYM,GAAG,CAACF,OAAAA,CAAAA;AAC1B,IAAA,IAAIC,QAAQE,SAAAA,EAAW;AACnBF,QAAAA,GAAAA,GAAM,EAAEH,cAAAA;QACRF,WAAAA,CAAYQ,GAAG,CAACJ,OAAAA,EAASC,GAAAA,CAAAA;AAC7B,IAAA;IACA,OAAOA,GAAAA;AACX;AAEA;;;AAGC,IACM,SAASI,gBAAAA,CAAiB,EAAEC,OAAO,EAA4B,EAAA;IAClE,MAAM,EAAEC,IAAI,EAAEC,MAAM,EAAE,GAAGC,2CAAAA,CAAsBH,OAAAA,EAASI,uBAAAA,CAAYC,OAAO,CAAA;IAC3E,IAAI,CAACH,MAAAA,EAAQ,qBAAOI,cAAA,CAACC,6BAAAA,EAAAA;QAAeP,OAAAA,EAASA,OAAAA;AAASQ,QAAAA,IAAAA,EAAMJ,wBAAYC,OAAO;QAAEJ,IAAAA,EAAMA;;IAEvF,MAAMQ,MAAAA,GAASC,MAAAA,CAAOC,MAAM,CAACX,OAAAA,CAAQY,UAAU,EAAE,QAAA,CAAA,GAAYC,2BAAAA,CAAcb,OAAAA,CAAQY,UAAU,CAAA,GAAIf,SAAAA;IACjG,IAAIa,MAAAA,CAAOC,MAAM,CAACX,OAAAA,CAAQY,UAAU,EAAE,QAAA,CAAA,IAAa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