@salsita-ai/sdk 0.50.0-develop.f6390cb584 → 0.50.0-develop.fbe43b9a2d

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 (293) hide show
  1. package/dist/application-spec/errors/diagnostic-codes.d.ts +9 -0
  2. package/dist/application-spec/errors/diagnostic-codes.js +1 -1
  3. package/dist/application-spec/errors/diagnostic-messages.d.ts +10 -1
  4. package/dist/application-spec/errors/diagnostic-messages.js +1 -1
  5. package/dist/application-spec/generate-application/code/domain-runtime-files.js +1 -1
  6. package/dist/application-spec/generate-application/code/templates/application-types.js +6 -6
  7. package/dist/application-spec/generate-application/code/templates/common/doc-comment.d.ts +2 -0
  8. package/dist/application-spec/generate-application/code/templates/common/doc-comment.js +1 -0
  9. package/dist/application-spec/generate-application/code/templates/configurator-globals.d.ts +2 -1
  10. package/dist/application-spec/generate-application/code/templates/configurator-globals.js +19 -6
  11. package/dist/application-spec/generate-application/code/templates/global-definition/generate-action-types.js +7 -7
  12. package/dist/application-spec/generate-application/code/templates/global-definition/generate-assistant-form-element-types.d.ts +12 -0
  13. package/dist/application-spec/generate-application/code/templates/global-definition/generate-assistant-form-element-types.js +7 -0
  14. package/dist/application-spec/generate-application/code/templates/global-definition/generate-phx-types.js +24 -22
  15. package/dist/application-spec/generate-application/code/templates/global-definition/index.d.ts +1 -0
  16. package/dist/application-spec/generate-application/code/templates/global-definition/index.js +1 -1
  17. package/dist/application-spec/generate-application/code/templates/skills/sdk-content.d.ts +2 -1
  18. package/dist/application-spec/generate-application/code/templates/skills/sdk-content.js +2 -2
  19. package/dist/application-spec/parse-application-files/raw-spec/raw-assistant.d.ts +33 -3
  20. package/dist/application-spec/parse-application-files/raw-spec/raw-assistant.js +1 -1
  21. package/dist/application-spec/parse-application-files/spec/sections/assistant/assistant-form-elements.d.ts +9 -0
  22. package/dist/application-spec/parse-application-files/spec/sections/assistant/assistant-form-elements.js +1 -0
  23. package/dist/application-spec/parse-application-files/spec/sections/assistant/assistant-schema.d.ts +4 -1
  24. package/dist/application-spec/parse-application-files/spec/sections/assistant/assistant-schema.js +1 -1
  25. package/dist/configurator/application-runtime/extensions/selectors.js +1 -1
  26. package/dist/configurator/application-runtime/extensions/systems/assistant-system/assistant-system.js +1 -1
  27. package/dist/configurator/application-runtime/extensions/systems/assistant-system/graphql-tools.d.ts +12 -2
  28. package/dist/configurator/application-runtime/extensions/systems/assistant-system/graphql-tools.js +1 -1
  29. package/dist/configurator/application-runtime/extensions/systems/canvas-system.d.ts +8 -0
  30. package/dist/configurator/application-runtime/extensions/systems/canvas-system.js +1 -1
  31. package/dist/configurator/application-runtime/extensions/systems/export-system/export-busy-error.d.ts +8 -0
  32. package/dist/configurator/application-runtime/extensions/systems/export-system/export-busy-error.js +1 -0
  33. package/dist/configurator/application-runtime/extensions/systems/export-system/export-system.d.ts +23 -1
  34. package/dist/configurator/application-runtime/extensions/systems/export-system/export-system.js +1 -1
  35. package/dist/configurator/application-runtime/extensions/systems/graphql-system/entity-meta.d.ts +14 -1
  36. package/dist/configurator/application-runtime/extensions/systems/graphql-system/entity-meta.js +1 -1
  37. package/dist/configurator/application-runtime/extensions/systems/graphql-system/graphql-system.d.ts +45 -4
  38. package/dist/configurator/application-runtime/extensions/systems/graphql-system/graphql-system.js +1 -1
  39. package/dist/configurator/application-runtime/extensions/systems/image-rendering-system/image-rendering-system.d.ts +14 -5
  40. package/dist/configurator/application-runtime/extensions/systems/image-rendering-system/image-rendering-system.js +1 -1
  41. package/dist/configurator/application-runtime/extensions/systems/index.d.ts +1 -1
  42. package/dist/configurator/common/configurator-interface.d.ts +33 -2
  43. package/dist/configurator/common/configurator-interface.js +1 -1
  44. package/dist/configurator/configurator-context/configurator-hooks/layout-hooks.d.ts +4 -0
  45. package/dist/configurator/configurator-context/configurator-routing/ConfiguratorRoutingProvider.js +1 -1
  46. package/dist/configurator/pages/default-configurator-elements.d.ts +3 -2
  47. package/dist/configurator/pages/default-configurator-elements.js +1 -1
  48. package/dist/configurator/pages/default-elements/index.d.ts +1 -0
  49. package/dist/configurator/pages/default-elements/index.js +1 -1
  50. package/dist/configurator/pages/default-elements/scene-controls/BuiltInAddEntityFab.d.ts +3 -0
  51. package/dist/configurator/pages/default-elements/scene-controls/BuiltInAddEntityFab.js +1 -0
  52. package/dist/configurator/pages/default-elements/scene-controls/BuiltInDeleteEntityFab.d.ts +3 -0
  53. package/dist/configurator/pages/default-elements/scene-controls/BuiltInDeleteEntityFab.js +1 -0
  54. package/dist/configurator/pages/default-elements/scene-controls/BuiltInNavigationHotspot.d.ts +3 -0
  55. package/dist/configurator/pages/default-elements/scene-controls/BuiltInNavigationHotspot.js +1 -0
  56. package/dist/configurator/pages/default-elements/scene-controls/BuiltInSelectionHotspot.d.ts +3 -0
  57. package/dist/configurator/pages/default-elements/scene-controls/BuiltInSelectionHotspot.js +1 -0
  58. package/dist/configurator/pages/default-elements/scene-controls/BuiltInToolMenuFab.d.ts +3 -0
  59. package/dist/configurator/pages/default-elements/scene-controls/BuiltInToolMenuFab.js +1 -0
  60. package/dist/configurator/pages/default-elements/scene-controls/index.d.ts +6 -0
  61. package/dist/configurator/pages/default-elements/scene-controls/index.js +1 -0
  62. package/dist/configurator/pages/default-elements/scene-controls/scene-control-elements.d.ts +6 -0
  63. package/dist/configurator/pages/default-elements/scene-controls/scene-control-elements.js +1 -0
  64. package/dist/configurator/scene/index.d.ts +1 -0
  65. package/dist/configurator/scene/index.js +1 -1
  66. package/dist/configurator/scene/scene-controls/ToolFab.d.ts +4 -0
  67. package/dist/configurator/scene/scene-controls/ToolFab.js +1 -1
  68. package/dist/configurator/scene/scene-controls/use-scene-control-tooltip.d.ts +2 -1
  69. package/dist/configurator/scene/scene-entity/scene-controls/SceneEntityHtmlHotspots.js +1 -1
  70. package/dist/configurator/toolbar-actions/index.d.ts +1 -0
  71. package/dist/configurator/toolbar-actions/index.js +1 -1
  72. package/dist/configurator/toolbar-actions/use-toolbar-actions.d.ts +100 -0
  73. package/dist/configurator/toolbar-actions/use-toolbar-actions.js +1 -0
  74. package/dist/configurator/toolbar-actions/use-toolbar-help.d.ts +7 -0
  75. package/dist/configurator/toolbar-actions/use-toolbar-help.js +1 -0
  76. package/dist/configurator/ui/assistant/AssistantChips.d.ts +3 -2
  77. package/dist/configurator/ui/assistant/AssistantChips.js +1 -1
  78. package/dist/configurator/ui/assistant/AssistantMarkdown.d.ts +1 -1
  79. package/dist/configurator/ui/assistant/AssistantMarkdown.js +1 -1
  80. package/dist/configurator/ui/assistant/alert/AssistantAlert.d.ts +8 -0
  81. package/dist/configurator/ui/assistant/alert/AssistantAlert.js +1 -0
  82. package/dist/configurator/ui/assistant/alert/index.d.ts +2 -0
  83. package/dist/configurator/ui/assistant/alert/index.js +1 -0
  84. package/dist/configurator/ui/assistant/alert/remark-alerts.d.ts +10 -0
  85. package/dist/configurator/ui/assistant/alert/remark-alerts.js +1 -0
  86. package/dist/configurator/ui/assistant/form/AssistantForm.js +1 -1
  87. package/dist/configurator/ui/assistant/form/compose-answer.d.ts +1 -1
  88. package/dist/configurator/ui/assistant/form/compose-answer.js +1 -1
  89. package/dist/configurator/ui/assistant/form/form-model.d.ts +3 -4
  90. package/dist/configurator/ui/assistant/form/form-state.d.ts +1 -1
  91. package/dist/configurator/ui/assistant/form/index.d.ts +2 -0
  92. package/dist/configurator/ui/assistant/form/index.js +1 -1
  93. package/dist/configurator/ui/assistant/form/parse-form-block.d.ts +3 -2
  94. package/dist/configurator/ui/assistant/form/parse-form-block.js +1 -1
  95. package/dist/configurator/ui/assistant/form/read-form-attributes.d.ts +1 -1
  96. package/dist/configurator/ui/assistant/form/read-form-attributes.js +1 -1
  97. package/dist/configurator/ui/assistant/form/registry/built-in-form-elements.d.ts +3 -0
  98. package/dist/configurator/ui/assistant/form/registry/built-in-form-elements.js +1 -0
  99. package/dist/configurator/ui/assistant/form/registry/create-assistant-form-element.d.ts +31 -0
  100. package/dist/configurator/ui/assistant/form/registry/create-assistant-form-element.js +1 -0
  101. package/dist/configurator/ui/assistant/form/{form-element-definition.d.ts → registry/form-element-definition.d.ts} +3 -1
  102. package/dist/configurator/ui/assistant/form/registry/form-element-definition.js +1 -0
  103. package/dist/configurator/ui/assistant/form/{form-registry.d.ts → registry/form-registry.d.ts} +2 -2
  104. package/dist/configurator/ui/assistant/form/registry/form-registry.js +1 -0
  105. package/dist/configurator/ui/assistant/form/registry/index.d.ts +6 -0
  106. package/dist/configurator/ui/assistant/form/registry/index.js +1 -0
  107. package/dist/configurator/ui/assistant/form/registry/use-form-registry.d.ts +8 -0
  108. package/dist/configurator/ui/assistant/form/registry/use-form-registry.js +1 -0
  109. package/dist/configurator/ui/assistant/form-elements/FormCard.d.ts +9 -0
  110. package/dist/configurator/ui/assistant/form-elements/FormCard.js +1 -0
  111. package/dist/configurator/ui/assistant/form-elements/FormConfirm.d.ts +9 -0
  112. package/dist/configurator/ui/assistant/form-elements/FormConfirm.js +1 -0
  113. package/dist/configurator/ui/assistant/form-elements/FormGroup.d.ts +4 -1
  114. package/dist/configurator/ui/assistant/form-elements/FormNumber.d.ts +9 -0
  115. package/dist/configurator/ui/assistant/form-elements/FormNumber.js +1 -0
  116. package/dist/configurator/ui/assistant/form-elements/FormOptions.d.ts +4 -1
  117. package/dist/configurator/ui/assistant/form-elements/FormReply.d.ts +4 -1
  118. package/dist/configurator/ui/assistant/form-elements/FormReply.js +1 -1
  119. package/dist/configurator/ui/assistant/form-elements/FormSwatch.d.ts +10 -0
  120. package/dist/configurator/ui/assistant/form-elements/FormSwatch.js +1 -0
  121. package/dist/configurator/ui/assistant/form-elements/FormText.d.ts +4 -1
  122. package/dist/configurator/ui/assistant/form-elements/FormText.js +1 -1
  123. package/dist/configurator/ui/assistant/form-elements/clamp-form-number.d.ts +10 -0
  124. package/dist/configurator/ui/assistant/form-elements/clamp-form-number.js +1 -0
  125. package/dist/configurator/ui/assistant/form-elements/form-element-props.d.ts +20 -16
  126. package/dist/configurator/ui/assistant/form-elements/index.d.ts +4 -0
  127. package/dist/configurator/ui/assistant/form-elements/index.js +1 -1
  128. package/dist/configurator/ui/assistant/index.d.ts +3 -0
  129. package/dist/configurator/ui/assistant/index.js +1 -1
  130. package/dist/configurator/ui/assistant/resource-image/index.d.ts +1 -1
  131. package/dist/configurator/ui/assistant/resource-image/index.js +1 -1
  132. package/dist/configurator/ui/assistant/resource-image/resource-path.d.ts +0 -9
  133. package/dist/configurator/ui/assistant/resource-image/resource-path.js +1 -1
  134. package/dist/configurator/ui/assistant/screenshots/ScreenshotThumbnails.d.ts +9 -0
  135. package/dist/configurator/ui/assistant/screenshots/ScreenshotThumbnails.js +1 -0
  136. package/dist/configurator/ui/assistant/screenshots/index.d.ts +2 -0
  137. package/dist/configurator/ui/assistant/screenshots/index.js +1 -0
  138. package/dist/configurator/ui/assistant/screenshots/tool-screenshots.d.ts +14 -0
  139. package/dist/configurator/ui/assistant/screenshots/tool-screenshots.js +1 -0
  140. package/dist/configurator/ui/assistant/streamed-markdown.d.ts +2 -2
  141. package/dist/configurator/ui/assistant/streamed-markdown.js +2 -2
  142. package/dist/configurator/ui/assistant/tool-chip.js +1 -1
  143. package/dist/configurator/ui/configurator-layout/universal/ExportingOverlay.d.ts +5 -0
  144. package/dist/configurator/ui/configurator-layout/universal/ExportingOverlay.js +1 -0
  145. package/dist/configurator/ui/configurator-layout/universal/Layout.js +1 -1
  146. package/dist/configurator/ui/index.d.ts +1 -0
  147. package/dist/configurator/ui/index.js +1 -1
  148. package/dist/docs/complex-use-cases/focus-mode.mdx +2 -0
  149. package/dist/docs/fabs/basic.mdx +4 -0
  150. package/dist/docs/index.json +62 -1
  151. package/dist/docs/layouts/custom-layout.mdx +3 -1
  152. package/dist/docs/layouts/gallery/ardent-compressor.mdx +3515 -0
  153. package/dist/docs/layouts/gallery/fenwick-window.mdx +2732 -0
  154. package/dist/docs/layouts/gallery/ferrule-bar-station.mdx +6567 -0
  155. package/dist/docs/layouts/gallery/kestrel-kettle.mdx +1858 -0
  156. package/dist/docs/layouts/gallery/sunfold-solar.mdx +2671 -0
  157. package/dist/docs/other-features/client-side-rendering/declarative.mdx +1 -1
  158. package/dist/docs/other-features/navigation-hotspot.mdx +2 -0
  159. package/dist/docs/phoenix/configurator-interface.mdx +64 -8
  160. package/dist/docs/phoenix/sdk-builder-workflow.mdx +1 -1
  161. package/dist/docs/selection-and-highlight/hotspots.mdx +2 -0
  162. package/dist/domain/application/assistant/assistant-manifest.d.ts +16 -1
  163. package/dist/domain/application/assistant/assistant-resolved-manifest.d.ts +8 -1
  164. package/dist/domain/application/assistant/build-assistant-manifest.js +1 -1
  165. package/dist/domain/application/assistant/form/assistant-form-element-name.d.ts +11 -0
  166. package/dist/domain/application/assistant/form/assistant-form-element-name.js +8 -0
  167. package/dist/domain/application/assistant/form/assistant-form-elements.d.ts +174 -0
  168. package/dist/domain/application/assistant/form/assistant-form-elements.js +1 -0
  169. package/dist/domain/application/assistant/form/assistant-resource-path.d.ts +10 -0
  170. package/dist/domain/application/assistant/form/assistant-resource-path.js +1 -0
  171. package/dist/domain/application/assistant/form/index.d.ts +4 -0
  172. package/dist/domain/application/assistant/form/index.js +1 -0
  173. package/dist/domain/application/assistant/generate-assistant-prompt.d.ts +3 -0
  174. package/dist/domain/application/assistant/generate-assistant-prompt.js +1 -1
  175. package/dist/domain/application/assistant/index.d.ts +2 -3
  176. package/dist/domain/application/assistant/index.js +1 -1
  177. package/dist/domain/application/assistant/session-setup/apply-assistant-setup.js +1 -1
  178. package/dist/domain/application/assistant/session-setup/assistant-setup-manifest.d.ts +2 -0
  179. package/dist/domain/application/assistant/session-setup/assistant-setup-manifest.js +1 -1
  180. package/dist/domain/available-system-components.d.ts +1 -1
  181. package/dist/domain/available-system-components.js +1 -1
  182. package/dist/domain/domain-context/store-system/store-system.d.ts +5 -0
  183. package/dist/domain/domain-context/store-system/store-system.js +1 -1
  184. package/dist/domain/domain-runtime/domain-runtime.d.ts +4 -0
  185. package/dist/domain/domain-runtime/environment/types.d.ts +1 -1
  186. package/dist/domain/domain-runtime/spec/index.d.ts +1 -1
  187. package/dist/domain/domain-runtime/spec/index.js +1 -1
  188. package/dist/domain/domain-runtime/spec/initialize.js +1 -1
  189. package/dist/domain/domain-runtime/spec/module-checks/element-registration.d.ts +15 -1
  190. package/dist/domain/domain-runtime/spec/module-checks/element-registration.js +1 -1
  191. package/dist/domain/domain-runtime/spec/module-checks/find-assistant-form-element-errors.d.ts +12 -0
  192. package/dist/domain/domain-runtime/spec/module-checks/find-assistant-form-element-errors.js +1 -0
  193. package/dist/domain/domain-runtime/spec/module-checks/index.d.ts +2 -1
  194. package/dist/domain/domain-runtime/spec/module-checks/index.js +1 -1
  195. package/dist/domain/domain-runtime/spec/selectors.d.ts +3 -1
  196. package/dist/domain/domain-runtime/spec/selectors.js +1 -1
  197. package/dist/domain/extensions/export-images/agent-screenshot.d.ts +24 -0
  198. package/dist/domain/extensions/export-images/agent-screenshot.js +1 -0
  199. package/dist/domain/extensions/{client-side-image.d.ts → export-images/client-side-image.d.ts} +2 -2
  200. package/dist/domain/extensions/export-images/client-side-image.js +1 -0
  201. package/dist/domain/extensions/export-images/index.d.ts +3 -0
  202. package/dist/domain/extensions/export-images/index.js +1 -0
  203. package/dist/domain/extensions/{save-template-thumbnail.d.ts → export-images/save-template-thumbnail.d.ts} +2 -2
  204. package/dist/domain/extensions/export-images/save-template-thumbnail.js +1 -0
  205. package/dist/domain/extensions/index.d.ts +1 -2
  206. package/dist/domain/extensions/index.js +1 -1
  207. package/dist/domain/mocks/create-mock-domain-runtime.d.ts +2 -0
  208. package/dist/editor/domain-editors/DomainSpecContext.js +1 -1
  209. package/dist/editor/domain-editors/apply-spec-update.d.ts +8 -1
  210. package/dist/editor/domain-editors/apply-spec-update.js +1 -1
  211. package/dist/editor/domain-editors/use-implementation-files.js +1 -1
  212. package/dist/editor/screenshot/ScreenshotHandler.js +1 -1
  213. package/dist/i18n/locales/cs/messages.js +1 -1
  214. package/dist/i18n/locales/da/messages.js +1 -1
  215. package/dist/i18n/locales/de/messages.js +1 -1
  216. package/dist/i18n/locales/de-AT/messages.js +1 -1
  217. package/dist/i18n/locales/en/messages.js +1 -1
  218. package/dist/i18n/locales/en-AU/messages.js +1 -1
  219. package/dist/i18n/locales/en-GB/messages.js +1 -1
  220. package/dist/i18n/locales/es/messages.js +1 -1
  221. package/dist/i18n/locales/fr/messages.js +1 -1
  222. package/dist/i18n/locales/hu/messages.js +1 -1
  223. package/dist/i18n/locales/it/messages.js +1 -1
  224. package/dist/i18n/locales/nl/messages.js +1 -1
  225. package/dist/i18n/locales/pl/messages.js +1 -1
  226. package/dist/i18n/locales/pt/messages.js +1 -1
  227. package/dist/i18n/locales/ro/messages.js +1 -1
  228. package/dist/i18n/locales/sk/messages.js +1 -1
  229. package/dist/i18n/locales/tr/messages.js +1 -1
  230. package/dist/legacy/domain-spec/__generated/domain-schema.d.ts +16 -0
  231. package/dist/legacy/domain-spec/spec/domain-spec.js +1 -1
  232. package/dist/react-sdk/application-runtime/hooks/use-phoenix-element-slots.d.ts +2 -1
  233. package/dist/react-sdk/application-runtime/integration/initialize.d.ts +7 -6
  234. package/dist/react-sdk/application-runtime/integration/initialize.js +1 -1
  235. package/dist/react-sdk/application-runtime/integration/selectors.d.ts +11 -2
  236. package/dist/react-sdk/application-runtime/integration/selectors.js +1 -1
  237. package/dist/react-sdk/application-runtime/integration/types.d.ts +5 -2
  238. package/dist/react-sdk/application-runtime/mocks/create-mock-application-runtime.js +1 -1
  239. package/dist/react-sdk/application-runtime/routing/routing-service.d.ts +34 -2
  240. package/dist/react-sdk/application-runtime/routing/routing-service.js +1 -1
  241. package/dist/react-sdk/application-runtime/runtime/create-application-runtime.d.ts +4 -2
  242. package/dist/react-sdk/application-runtime/runtime/create-application-runtime.js +1 -1
  243. package/dist/react-sdk/domain-context/system-hooks/undo-redo-hooks.js +1 -1
  244. package/dist/react-sdk/index.d.ts +1 -0
  245. package/dist/react-sdk/index.js +1 -1
  246. package/dist/react-sdk/scene-control-elements/AddEntityFabElement.d.ts +36 -0
  247. package/dist/react-sdk/scene-control-elements/AddEntityFabElement.js +1 -0
  248. package/dist/react-sdk/scene-control-elements/DeleteEntityFabElement.d.ts +44 -0
  249. package/dist/react-sdk/scene-control-elements/DeleteEntityFabElement.js +1 -0
  250. package/dist/react-sdk/scene-control-elements/NavigationHotspotElement.d.ts +38 -0
  251. package/dist/react-sdk/scene-control-elements/NavigationHotspotElement.js +1 -0
  252. package/dist/react-sdk/scene-control-elements/SelectionHotspotElement.d.ts +30 -0
  253. package/dist/react-sdk/scene-control-elements/SelectionHotspotElement.js +1 -0
  254. package/dist/react-sdk/scene-control-elements/ToolMenuFabElement.d.ts +30 -0
  255. package/dist/react-sdk/scene-control-elements/ToolMenuFabElement.js +1 -0
  256. package/dist/react-sdk/scene-control-elements/create-add-entity-fab.d.ts +9 -0
  257. package/dist/react-sdk/scene-control-elements/create-add-entity-fab.js +1 -0
  258. package/dist/react-sdk/scene-control-elements/create-delete-entity-fab.d.ts +9 -0
  259. package/dist/react-sdk/scene-control-elements/create-delete-entity-fab.js +1 -0
  260. package/dist/react-sdk/scene-control-elements/create-navigation-hotspot.d.ts +10 -0
  261. package/dist/react-sdk/scene-control-elements/create-navigation-hotspot.js +1 -0
  262. package/dist/react-sdk/scene-control-elements/create-selection-hotspot.d.ts +9 -0
  263. package/dist/react-sdk/scene-control-elements/create-selection-hotspot.js +1 -0
  264. package/dist/react-sdk/scene-control-elements/create-tool-menu-fab.d.ts +9 -0
  265. package/dist/react-sdk/scene-control-elements/create-tool-menu-fab.js +1 -0
  266. package/dist/react-sdk/scene-control-elements/index.d.ts +11 -0
  267. package/dist/react-sdk/scene-control-elements/index.js +1 -0
  268. package/dist/react-sdk/scene-control-elements/scene-control-tooltip-visibility.d.ts +5 -0
  269. package/dist/react-sdk/web-component/create-web-component.js +1 -1
  270. package/dist/react-sdk/web-component/god-mode/god-mode-registry.d.ts +30 -0
  271. package/dist/react-sdk/web-component/god-mode/god-mode-registry.js +1 -0
  272. package/dist/react-sdk/web-component/god-mode/index.d.ts +1 -0
  273. package/dist/react-sdk/web-component/god-mode/index.js +1 -0
  274. package/dist/ui-sdk/icons/__generated/Lightbulb.d.ts +3 -0
  275. package/dist/ui-sdk/icons/__generated/Lightbulb.js +1 -0
  276. package/dist/ui-sdk/icons/__generated/XCircle.d.ts +3 -0
  277. package/dist/ui-sdk/icons/__generated/XCircle.js +1 -0
  278. package/dist/ui-sdk/icons/__generated/index.d.ts +4 -0
  279. package/dist/ui-sdk/icons/__generated/index.js +1 -1
  280. package/dist/ui-sdk/icons/icons-registry.js +1 -1
  281. package/dist/ui-sdk/theme/types.d.ts +5 -1
  282. package/package.json +13 -3
  283. package/schema/domain-spec.json +140 -0
  284. package/dist/configurator/ui/assistant/form/built-in-form-registry.d.ts +0 -10
  285. package/dist/configurator/ui/assistant/form/built-in-form-registry.js +0 -1
  286. package/dist/configurator/ui/assistant/form/form-registry.js +0 -8
  287. package/dist/domain/application/assistant/assistant-form-elements.d.ts +0 -28
  288. package/dist/domain/application/assistant/assistant-form-elements.js +0 -1
  289. package/dist/domain/extensions/client-side-image.js +0 -1
  290. package/dist/domain/extensions/save-template-thumbnail.js +0 -1
  291. package/dist/react-sdk/application-runtime/runtime/god-mode.d.ts +0 -19
  292. package/dist/react-sdk/application-runtime/runtime/god-mode.js +0 -1
  293. /package/dist/{configurator/ui/assistant/form/form-element-definition.js → react-sdk/scene-control-elements/scene-control-tooltip-visibility.js} +0 -0
@@ -0,0 +1 @@
1
+ import{jsx as t}from"react/jsx-runtime";import{SceneHotspot as i}from"../../../scene/index.js";export const BuiltInSelectionHotspot=o=>{let{title:e,tooltipVisibility:r,onSelect:n}=o;return t(i,{onClick:n,title:e,tooltipVisibility:r})};
@@ -0,0 +1,3 @@
1
+ import type { ToolMenuFabElementProps } from '#package/react-sdk';
2
+ /** The default of the `ToolMenuFab` element: the SDK's FAB with its menu of tools. */
3
+ export declare const BuiltInToolMenuFab: (props: ToolMenuFabElementProps) => import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1 @@
1
+ import{jsx as o}from"react/jsx-runtime";import{ToolMenuFab as t}from"../../../scene/index.js";export const BuiltInToolMenuFab=i=>{let{options:e,icon:n,title:r,tooltipVisibility:l,onSelectTool:s}=i;return o(t,{options:e,icon:n,title:r,tooltipVisibility:l,onSelectTool:s})};
@@ -0,0 +1,6 @@
1
+ export { BuiltInAddEntityFab } from './BuiltInAddEntityFab.js';
2
+ export { BuiltInDeleteEntityFab } from './BuiltInDeleteEntityFab.js';
3
+ export { BuiltInNavigationHotspot } from './BuiltInNavigationHotspot.js';
4
+ export { BuiltInSelectionHotspot } from './BuiltInSelectionHotspot.js';
5
+ export { BuiltInToolMenuFab } from './BuiltInToolMenuFab.js';
6
+ export { sceneControlElements } from './scene-control-elements.js';
@@ -0,0 +1 @@
1
+ export{BuiltInAddEntityFab}from"./BuiltInAddEntityFab.js";export{BuiltInDeleteEntityFab}from"./BuiltInDeleteEntityFab.js";export{BuiltInNavigationHotspot}from"./BuiltInNavigationHotspot.js";export{BuiltInSelectionHotspot}from"./BuiltInSelectionHotspot.js";export{BuiltInToolMenuFab}from"./BuiltInToolMenuFab.js";export{sceneControlElements}from"./scene-control-elements.js";
@@ -0,0 +1,6 @@
1
+ import type { ElementRegistration } from '#package/domain';
2
+ /**
3
+ * The SDK's in-scene entity controls, registered under the element names the scene renders them by:
4
+ * `AddEntityFab`, `DeleteEntityFab`, `SelectionHotspot`, `NavigationHotspot` and `ToolMenuFab`.
5
+ */
6
+ export declare const sceneControlElements: readonly ElementRegistration[];
@@ -0,0 +1 @@
1
+ import{createAddEntityFab as t,createDeleteEntityFab as o,createNavigationHotspot as i,createSelectionHotspot as r,createToolMenuFab as n}from"#package/react-sdk";import{BuiltInAddEntityFab as e}from"./BuiltInAddEntityFab.js";import{BuiltInDeleteEntityFab as m}from"./BuiltInDeleteEntityFab.js";import{BuiltInNavigationHotspot as s}from"./BuiltInNavigationHotspot.js";import{BuiltInSelectionHotspot as l}from"./BuiltInSelectionHotspot.js";import{BuiltInToolMenuFab as p}from"./BuiltInToolMenuFab.js";export const sceneControlElements=[t(e),o(m),r(l),i(s),n(p)];
@@ -32,6 +32,7 @@ export { usePixelWorldSize } from './three/use-pixel-world-size.js';
32
32
  export { addSceneDebugNode } from './SceneDebugNodes.js';
33
33
  export * from './scene-html/index.js';
34
34
  export * from './scene-controls/index.js';
35
+ export { createAddEntityFab, createDeleteEntityFab, createNavigationHotspot, createSelectionHotspot, createToolMenuFab, type AddEntityFabElementProps, type CreateAddEntityFab, type CreateDeleteEntityFab, type CreateNavigationHotspot, type CreateSelectionHotspot, type CreateToolMenuFab, type DeleteEntityFabElementProps, type NavigationHotspotElementProps, type SelectionHotspotElementProps, type ToolMenuFabElementProps, } from '#package/react-sdk';
35
36
  export * from './postprocessing/index.js';
36
37
  export * from './sketching/index.js';
37
38
  export * from './export/index.js';
@@ -1 +1 @@
1
- export{Scene}from"./Scene.js";export{SceneEnvironment}from"./SceneEnvironment.js";export{CameraControls}from"./cameras/CameraControls.js";export{CameraPadding}from"./cameras/CameraPadding.js";export{useEntityCameraDrivenOpacity}from"./cameras/use-entity-camera-driven-opacity.js";export{Animations}from"./animations/Animations.js";export{SceneEntityDimensionIndicators}from"./scene-entity/dimension-indicators/SceneEntityDimensionIndicators.js";export{DimensionIndicator}from"./scene-entity/dimension-indicators/DimensionIndicator.js";export{SceneEntityHtmlHotspots}from"./scene-entity/scene-controls/SceneEntityHtmlHotspots.js";export{SceneEntityControls}from"./scene-entity/scene-controls/SceneEntityControls.js";export{SceneEntity}from"./scene-entity/SceneEntity.js";export{SceneEntityHighlightedObject}from"./scene-entity/objects/SceneEntityHighlightedObject.js";export{SceneEntityObject}from"./scene-entity/objects/SceneEntityObject.js";export{SceneEntityObjectClip}from"./scene-entity/objects/SceneEntityObjectClip.js";export{SceneEntityObjectDecal}from"./scene-entity/objects/SceneEntityObjectDecal.js";export{SceneEntityObjectTextDecal}from"./scene-entity/objects/SceneEntityObjectTextDecal.js";export{SceneEntityPrimitiveObject}from"./scene-entity/objects/SceneEntityPrimitiveObject.js";export{SceneEntityRemoteObject}from"./scene-entity/objects/SceneEntityRemoteObject.js";export{SceneRootEntity}from"./scene-entity/SceneRootEntity.js";export{SceneEntityObjectTransformer}from"./scene-entity/objects/SceneEntityObjectTransformer.js";export{SceneEntityObjectMaterials}from"./scene-entity/materials/SceneEntityObjectMaterials.js";export{ReplacedMaterialTransition}from"./scene-entity/materials/ReplacedMaterialTransition.js";export{ReplacedMaterialTransformer}from"./scene-entity/materials/ReplacedMaterialTransformer.js";export{useSceneEntityHighlight}from"./scene-entity/entity-hooks/use-scene-entity-highlight.js";export{useSceneEntityObjectMorphing}from"./scene-entity/entity-hooks/use-scene-entity-object-morphing.js";export{useSceneEntityRemoteObject}from"./scene-entity/entity-hooks/use-scene-entity-remote-object.js";export{useSceneEntityInteractions}from"./scene-entity/drag-and-drop/use-scene-entity-interactions.js";export{useRotateHandle}from"./scene-entity/drag-and-drop/use-rotate-handle.js";export{isStandardMaterial,isWithMaterial}from"./three/with-material.js";export{usePixelWorldSize}from"./three/use-pixel-world-size.js";export{addSceneDebugNode}from"./SceneDebugNodes.js";export*from"./scene-html/index.js";export*from"./scene-controls/index.js";export*from"./postprocessing/index.js";export*from"./sketching/index.js";export*from"./export/index.js";export*from"./resources/index.js";export*from"./cameras/index.js";export*from"./scene-entity/index.js";
1
+ export{Scene}from"./Scene.js";export{SceneEnvironment}from"./SceneEnvironment.js";export{CameraControls}from"./cameras/CameraControls.js";export{CameraPadding}from"./cameras/CameraPadding.js";export{useEntityCameraDrivenOpacity}from"./cameras/use-entity-camera-driven-opacity.js";export{Animations}from"./animations/Animations.js";export{SceneEntityDimensionIndicators}from"./scene-entity/dimension-indicators/SceneEntityDimensionIndicators.js";export{DimensionIndicator}from"./scene-entity/dimension-indicators/DimensionIndicator.js";export{SceneEntityHtmlHotspots}from"./scene-entity/scene-controls/SceneEntityHtmlHotspots.js";export{SceneEntityControls}from"./scene-entity/scene-controls/SceneEntityControls.js";export{SceneEntity}from"./scene-entity/SceneEntity.js";export{SceneEntityHighlightedObject}from"./scene-entity/objects/SceneEntityHighlightedObject.js";export{SceneEntityObject}from"./scene-entity/objects/SceneEntityObject.js";export{SceneEntityObjectClip}from"./scene-entity/objects/SceneEntityObjectClip.js";export{SceneEntityObjectDecal}from"./scene-entity/objects/SceneEntityObjectDecal.js";export{SceneEntityObjectTextDecal}from"./scene-entity/objects/SceneEntityObjectTextDecal.js";export{SceneEntityPrimitiveObject}from"./scene-entity/objects/SceneEntityPrimitiveObject.js";export{SceneEntityRemoteObject}from"./scene-entity/objects/SceneEntityRemoteObject.js";export{SceneRootEntity}from"./scene-entity/SceneRootEntity.js";export{SceneEntityObjectTransformer}from"./scene-entity/objects/SceneEntityObjectTransformer.js";export{SceneEntityObjectMaterials}from"./scene-entity/materials/SceneEntityObjectMaterials.js";export{ReplacedMaterialTransition}from"./scene-entity/materials/ReplacedMaterialTransition.js";export{ReplacedMaterialTransformer}from"./scene-entity/materials/ReplacedMaterialTransformer.js";export{useSceneEntityHighlight}from"./scene-entity/entity-hooks/use-scene-entity-highlight.js";export{useSceneEntityObjectMorphing}from"./scene-entity/entity-hooks/use-scene-entity-object-morphing.js";export{useSceneEntityRemoteObject}from"./scene-entity/entity-hooks/use-scene-entity-remote-object.js";export{useSceneEntityInteractions}from"./scene-entity/drag-and-drop/use-scene-entity-interactions.js";export{useRotateHandle}from"./scene-entity/drag-and-drop/use-rotate-handle.js";export{isStandardMaterial,isWithMaterial}from"./three/with-material.js";export{usePixelWorldSize}from"./three/use-pixel-world-size.js";export{addSceneDebugNode}from"./SceneDebugNodes.js";export*from"./scene-html/index.js";export*from"./scene-controls/index.js";export{createAddEntityFab,createDeleteEntityFab,createNavigationHotspot,createSelectionHotspot,createToolMenuFab}from"#package/react-sdk";export*from"./postprocessing/index.js";export*from"./sketching/index.js";export*from"./export/index.js";export*from"./resources/index.js";export*from"./cameras/index.js";export*from"./scene-entity/index.js";
@@ -3,5 +3,9 @@ import { type SceneFabProps } from './SceneFab.js';
3
3
  export interface ToolMenuFabProps extends Pick<SceneFabProps, 'title' | 'tooltipVisibility'> {
4
4
  readonly options: readonly ToolMenuFabOption[];
5
5
  readonly icon?: string;
6
+ /**
7
+ * Switches to the tool state of the chosen option. Without it, the menu switches the tool itself.
8
+ */
9
+ readonly onSelectTool?: (toolState: string) => void;
6
10
  }
7
11
  export declare const ToolMenuFab: (props: ToolMenuFabProps) => import("react/jsx-runtime").JSX.Element;
@@ -1 +1 @@
1
- import{jsx as e,jsxs as o,Fragment as r}from"react/jsx-runtime";import{Trans as t}from"@lingui/react";import{ListItemIcon as i,ListSubheader as n,MenuItem as l,menuClasses as a}from"@mui/material";import{memo as c,useCallback as m,useState as s}from"react";import{LocalizableMessage as p,useDomain as g}from"#package/react-sdk";import{PhxIcon as d,ResponsiveMenu as h}from"#package/ui-sdk";import{SceneFab as u}from"./SceneFab.js";let f=c(r=>{let{options:c,title:s,open:u,anchorEl:f,onClose:k}=r,{navigationSystem:b,storeSystem:C}=g(),x=m(e=>{C.stageAndCommit([b.getToolUpdate(e.toolState)]),k()},[b,C,k]);return o(h,{closeLabel:e(t,{id:"sdk.controls.tool.close.label",message:"Close"}),open:u,anchorEl:f,onClose:k,menuProps:{anchorOrigin:{vertical:"center",horizontal:"right"},transformOrigin:{vertical:"center",horizontal:"left"},sx:{[`.${a.paper}`]:{minInlineSize:220,marginLeft:2,marginRight:1}}},children:[e(n,{children:e(p,{children:s})}),c.map(r=>o(l,{onClick:()=>{x(r)},children:[e(i,{children:r.icon&&e(d,{name:r.icon})}),e(p,{children:r.label})]},r.toolState))]})});export const ToolMenuFab=t=>{let{options:i,icon:n,title:l,tooltipVisibility:a}=t,[c,p]=s(null),g=null!==c,h=m(e=>{p(e.currentTarget),e.stopPropagation()},[]),k=m(()=>{p(null)},[]);return o(r,{children:[e(u,{title:l,icon:e(d,{name:n??"PencilSimpleBold"}),tooltipVisibility:a,onClick:h}),g&&e(f,{anchorEl:c,open:g,onClose:k,options:i,title:l})]})};
1
+ import{jsx as e,jsxs as o,Fragment as t}from"react/jsx-runtime";import{Trans as r}from"@lingui/react";import{ListItemIcon as l,ListSubheader as i,MenuItem as n,menuClasses as a}from"@mui/material";import{memo as c,useCallback as m,useState as s}from"react";import{LocalizableMessage as p,useDomain as g}from"#package/react-sdk";import{PhxIcon as d,ResponsiveMenu as h}from"#package/ui-sdk";import{SceneFab as u}from"./SceneFab.js";let f=c(t=>{let{options:c,title:s,open:u,anchorEl:f,onClose:k,onSelectTool:S}=t,{navigationSystem:b,storeSystem:C}=g(),x=m(e=>{S?S(e.toolState):C.stageAndCommit([b.getToolUpdate(e.toolState)]),k()},[b,C,k,S]);return o(h,{closeLabel:e(r,{id:"sdk.controls.tool.close.label",message:"Close"}),open:u,anchorEl:f,onClose:k,menuProps:{anchorOrigin:{vertical:"center",horizontal:"right"},transformOrigin:{vertical:"center",horizontal:"left"},sx:{[`.${a.paper}`]:{minInlineSize:220,marginLeft:2,marginRight:1}}},children:[e(i,{children:e(p,{children:s})}),c.map(t=>o(n,{onClick:()=>{x(t)},children:[e(l,{children:t.icon&&e(d,{name:t.icon})}),e(p,{children:t.label})]},t.toolState))]})});export const ToolMenuFab=r=>{let{options:l,icon:i,title:n,tooltipVisibility:a,onSelectTool:c}=r,[p,g]=s(null),h=null!==p,k=m(e=>{g(e.currentTarget),e.stopPropagation()},[]),S=m(()=>{g(null)},[]);return o(t,{children:[e(u,{title:n,icon:e(d,{name:i??"PencilSimpleBold"}),tooltipVisibility:a,onClick:k}),h&&e(f,{anchorEl:p,open:h,onClose:S,options:l,title:n,onSelectTool:c})]})};
@@ -1,4 +1,5 @@
1
- export type SceneControlTooltipVisibility = 'on-hover' | 'forced' | 'forced-when-still' | 'hidden';
1
+ import type { SceneControlTooltipVisibility } from '#package/react-sdk';
2
+ export type { SceneControlTooltipVisibility };
2
3
  export interface SceneControlTooltip {
3
4
  /**
4
5
  * Whether tooltip is open (undefined = uncontrolled hover behavior)
@@ -1 +1 @@
1
- import{jsx as t,jsxs as e,Fragment as n}from"react/jsx-runtime";import{memo as o}from"react";import{match as i}from"ts-pattern";import{htmlHotspotComponent as s,isHtmlHotspotComponentSnapshot as a,isSceneEntityAddFabComponentSnapshot as c,isSceneEntityDeleteFabComponentSnapshot as l,isSceneEntityNavigationHotspotComponentSnapshot as r,isSceneEntitySelectHotspotComponentSnapshot as p,isToolMenuFabComponentSnapshot as m,sceneEntityAddFabComponent as h,sceneEntityDeleteFabComponent as d,sceneEntityNavigationHotspotComponent as f,sceneEntitySelectHotspotComponent as y,toolMenuFabComponent as u}from"#package/domain";import{PhoenixEntityElementWithChildren as w,useRenderedComponents as I}from"#package/react-sdk";import{PhxIcon as W}from"#package/ui-sdk";import{AddEntityFab as b,DeleteEntityFab as g,NavigationHotspot as V,SelectionHotspot as k,ToolMenuFab as v}from"../../scene-controls/index.js";import{SceneEntityHtml as O}from"../../scene-html/index.js";import{SuspendedBoundary as $}from"../SuspendedBoundary.js";export const SceneEntityHtmlHotspots=o(o=>{let{id:H}=o;return t(n,{children:I({entityIds:[H],componentTypes:[h,s,d,y,u,f]}).map(n=>{let o={entityId:H,showWhen:n.state.showWhen},s={offsetX:n.state.offsetX,offsetY:n.state.offsetY,offsetZ:n.state.offsetZ,screenOffsetHorizontal:n.state.screenOffsetHorizontal,screenOffsetVertical:n.state.screenOffsetVertical},h={polarAngleLimits:n.state.polarAngleLimits,azimuthAngleLimits:n.state.azimuthAngleLimits,distanceLimits:n.state.distanceLimits,minInteractiveOpacity:n.state.minInteractiveOpacity},d={hideWhileDragging:n.state.hideWhileDragging,occlude:n.state.occlude};return i(n).when(c,e=>t($,{children:t(O,{...o,...s,...h,...d,showWhen:e.state.showWhen??["selected"],controlHotspot:!0,children:t(b,{parentEntityId:H,instanceNames:e.state.instanceNames,fixableViolations:e.state.hiddenViolations,icon:e.state.icon?t(W,{name:e.state.icon}):void 0,title:e.state.title,tooltipVisibility:e.state.tooltipVisibility??"on-hover",label:e.state.label,skipMenuWhenOnlyOne:e.state.skipMenuWhenOnlyOne,hideWhenNone:e.state.hideWhenNone})})},`${e.componentInstance.componentType.name}-${e.componentInstance.instanceName}`)).when(l,e=>t($,{children:t(O,{...o,...s,...h,...d,showWhen:e.state.showWhen??["selected"],controlHotspot:!0,children:t(g,{entityId:H,fixableViolations:e.state.hiddenViolations,icon:e.state.icon?t(W,{name:e.state.icon}):void 0,title:e.state.title,tooltipVisibility:e.state.tooltipVisibility??"on-hover",label:e.state.label})})},`${e.componentInstance.componentType.name}-${e.componentInstance.instanceName}`)).when(p,e=>t($,{children:t(O,{...o,...s,...h,...d,showWhen:e.state.showWhen??["unselected"],controlHotspot:!1,children:t(k,{id:H,title:e.state.title,tooltipVisibility:e.state.tooltipVisibility??"on-hover"})})},`${e.componentInstance.componentType.name}-${e.componentInstance.instanceName}`)).when(r,e=>t($,{children:t(O,{...o,...s,...h,...d,showWhen:e.state.showWhen??["unselected"],controlHotspot:!1,children:t(V,{navigationState:e.state.navigationState,pushToStack:e.state.pushToStack,canStackOnto:e.state.canStackOnto,title:e.state.title,tooltipVisibility:e.state.tooltipVisibility??"on-hover"})})},`${e.componentInstance.componentType.name}-${e.componentInstance.instanceName}`)).when(m,e=>t($,{children:t(O,{...o,...s,...h,...d,showWhen:e.state.showWhen??["unselected"],controlHotspot:!1,children:t(v,{options:e.state.options,icon:e.state.icon,title:e.state.title,tooltipVisibility:e.state.tooltipVisibility??"on-hover"})})},`${e.componentInstance.componentType.name}-${e.componentInstance.instanceName}`)).when(a,n=>t($,{children:e(O,{...o,...s,...h,...d,controlHotspot:n.state.controlHotspot,pointerEvents:n.state.inert?"none":"auto",children:[n.state.node,n.state.name&&t(w,{kind:n.state.name,entityId:H})]})},`${n.componentInstance.componentType.name}-${n.componentInstance.instanceName}`)).otherwise(()=>null)})})});
1
+ import{jsx as t,jsxs as e,Fragment as n}from"react/jsx-runtime";import{memo as o}from"react";import{match as i}from"ts-pattern";import{htmlHotspotComponent as s,isHtmlHotspotComponentSnapshot as a,isSceneEntityAddFabComponentSnapshot as c,isSceneEntityDeleteFabComponentSnapshot as l,isSceneEntityNavigationHotspotComponentSnapshot as p,isSceneEntitySelectHotspotComponentSnapshot as r,isToolMenuFabComponentSnapshot as h,sceneEntityAddFabComponent as m,sceneEntityDeleteFabComponent as d,sceneEntityNavigationHotspotComponent as y,sceneEntitySelectHotspotComponent as f,toolMenuFabComponent as I}from"#package/domain";import{AddEntityFabElement as w,DeleteEntityFabElement as u,NavigationHotspotElement as W,PhoenixEntityElementWithChildren as b,SelectionHotspotElement as V,ToolMenuFabElement as g,useRenderedComponents as O}from"#package/react-sdk";import{SceneEntityHtml as $}from"../../scene-html/index.js";import{SuspendedBoundary as H}from"../SuspendedBoundary.js";export const SceneEntityHtmlHotspots=o(o=>{let{id:k}=o;return t(n,{children:O({entityIds:[k],componentTypes:[m,s,d,f,I,y]}).map(n=>{let o={entityId:k,showWhen:n.state.showWhen},s={offsetX:n.state.offsetX,offsetY:n.state.offsetY,offsetZ:n.state.offsetZ,screenOffsetHorizontal:n.state.screenOffsetHorizontal,screenOffsetVertical:n.state.screenOffsetVertical},m={polarAngleLimits:n.state.polarAngleLimits,azimuthAngleLimits:n.state.azimuthAngleLimits,distanceLimits:n.state.distanceLimits,minInteractiveOpacity:n.state.minInteractiveOpacity},d={hideWhileDragging:n.state.hideWhileDragging,occlude:n.state.occlude};return i(n).when(c,e=>t(H,{children:t($,{...o,...s,...m,...d,showWhen:e.state.showWhen??["selected"],controlHotspot:!0,children:t(w,{entityId:k,instanceNames:e.state.instanceNames,fixableViolations:e.state.hiddenViolations,icon:e.state.icon,title:e.state.title,tooltipVisibility:e.state.tooltipVisibility??"on-hover",label:e.state.label,skipMenuWhenOnlyOne:e.state.skipMenuWhenOnlyOne,hideWhenNone:e.state.hideWhenNone})})},`${e.componentInstance.componentType.name}-${e.componentInstance.instanceName}`)).when(l,e=>t(H,{children:t($,{...o,...s,...m,...d,showWhen:e.state.showWhen??["selected"],controlHotspot:!0,children:t(u,{entityId:k,fixableViolations:e.state.hiddenViolations,icon:e.state.icon,title:e.state.title,tooltipVisibility:e.state.tooltipVisibility??"on-hover",label:e.state.label})})},`${e.componentInstance.componentType.name}-${e.componentInstance.instanceName}`)).when(r,e=>t(H,{children:t($,{...o,...s,...m,...d,showWhen:e.state.showWhen??["unselected"],controlHotspot:!1,children:t(V,{entityId:k,title:e.state.title,tooltipVisibility:e.state.tooltipVisibility??"on-hover"})})},`${e.componentInstance.componentType.name}-${e.componentInstance.instanceName}`)).when(p,e=>t(H,{children:t($,{...o,...s,...m,...d,showWhen:e.state.showWhen??["unselected"],controlHotspot:!1,children:t(W,{entityId:k,navigationState:e.state.navigationState,pushToStack:e.state.pushToStack,canStackOnto:e.state.canStackOnto,title:e.state.title,tooltipVisibility:e.state.tooltipVisibility??"on-hover"})})},`${e.componentInstance.componentType.name}-${e.componentInstance.instanceName}`)).when(h,e=>t(H,{children:t($,{...o,...s,...m,...d,showWhen:e.state.showWhen??["unselected"],controlHotspot:!1,children:t(g,{entityId:k,options:e.state.options,icon:e.state.icon,title:e.state.title,tooltipVisibility:e.state.tooltipVisibility??"on-hover"})})},`${e.componentInstance.componentType.name}-${e.componentInstance.instanceName}`)).when(a,n=>t(H,{children:e($,{...o,...s,...m,...d,controlHotspot:n.state.controlHotspot,pointerEvents:n.state.inert?"none":"auto",children:[n.state.node,n.state.name&&t(b,{kind:n.state.name,entityId:k})]})},`${n.componentInstance.componentType.name}-${n.componentInstance.instanceName}`)).otherwise(()=>null)})})});
@@ -1,2 +1,3 @@
1
1
  export { useMeasurements, type UseMeasurements, type UseMeasurementsOptions, type UseMeasurementsResult, } from './use-measurements.js';
2
2
  export { useAssistantPanel, type UseAssistantPanel, type UseAssistantPanelResult } from './use-assistant-panel.js';
3
+ export { useToolbarActions, type UseToolbarActions, type UseToolbarActionsResult, type ToolbarAction, type ToolbarPlacement, } from './use-toolbar-actions.js';
@@ -1 +1 @@
1
- export{useMeasurements}from"./use-measurements.js";export{useAssistantPanel}from"./use-assistant-panel.js";
1
+ export{useMeasurements}from"./use-measurements.js";export{useAssistantPanel}from"./use-assistant-panel.js";export{useToolbarActions}from"./use-toolbar-actions.js";
@@ -0,0 +1,100 @@
1
+ import { type ComponentType } from 'react';
2
+ import type { DimensionUnit } from '#package/domain';
3
+ import { type UseLocaleSwitchResult } from '#package/react-sdk';
4
+ import { type UseAssistantPanelResult } from './use-assistant-panel.js';
5
+ import { type UseMeasurementsResult } from './use-measurements.js';
6
+ /** Which of the spec's toolbar lists to read: `toolbar.desktop`, `toolbar.mobile` or `toolbar.mobileMenu`. */
7
+ export type ToolbarPlacement = 'desktop' | 'mobile' | 'mobileMenu';
8
+ interface ToolbarEntryBase {
9
+ /** Stable for the entry's placement, group and position, to key the rendered list */
10
+ readonly key: string;
11
+ /** The element's `icon` prop, when its kind has one and the spec sets it */
12
+ readonly icon: string | undefined;
13
+ /**
14
+ * The element's `showTitle` prop, else the built-in button's default: `true` for the assistant, else `false`. The
15
+ * built-in assistant button also hides its title on a phone or tablet-sized layout; the layout decides that here.
16
+ */
17
+ readonly showTitle: boolean;
18
+ /** The built-in button's title in the current language, such as "Undo" or "Share"; a custom entry's `name` */
19
+ readonly label: string;
20
+ }
21
+ /**
22
+ * One entry of the toolbar, by `kind`:
23
+ * - `undo`, `redo`: `run` undoes or redoes as `useUndoRedo` does; `disabled` while there is nothing to undo or redo.
24
+ * - `fullscreen`: `active` is the fullscreen flag, `run` toggles it and pushes the built-in button's analytics event.
25
+ * - `resetCamera`: `run` resets the camera as `useResetCamera` does.
26
+ * - `share`: the layout opens its own share dialog, which calls `useShareLinks`.
27
+ * - `measurements`: the layout opens its own settings over `measurements`, the result of `useMeasurements` with the
28
+ * element's `showIndicatorSwitch` applied; `icons` is the element's icon per unit, when the spec sets it.
29
+ * - `language`: the layout opens its own language list over `language`, the result of `useLocaleSwitch`.
30
+ * - `help`: `Content` renders the help, the element's children or else the help registered with
31
+ * `createToolbarHelp`, for the layout's own dialog. The built-in menu action falls back to nothing instead.
32
+ * - `assistant`: `run` opens or closes the assistant panel; `assistant` is the result of `useAssistantPanel`.
33
+ * - `custom`: `Element` renders the project element the spec's `customLayoutElement` names.
34
+ */
35
+ export type ToolbarAction = (ToolbarEntryBase & {
36
+ readonly kind: 'undo';
37
+ readonly disabled: boolean;
38
+ readonly run: () => void;
39
+ }) | (ToolbarEntryBase & {
40
+ readonly kind: 'redo';
41
+ readonly disabled: boolean;
42
+ readonly run: () => void;
43
+ }) | (ToolbarEntryBase & {
44
+ readonly kind: 'fullscreen';
45
+ readonly active: boolean;
46
+ readonly run: () => void;
47
+ }) | (ToolbarEntryBase & {
48
+ readonly kind: 'resetCamera';
49
+ readonly run: () => void;
50
+ }) | (ToolbarEntryBase & {
51
+ readonly kind: 'share';
52
+ }) | (ToolbarEntryBase & {
53
+ readonly kind: 'measurements';
54
+ readonly measurements: UseMeasurementsResult;
55
+ readonly icons: Partial<Record<DimensionUnit, string>> | undefined;
56
+ }) | (ToolbarEntryBase & {
57
+ readonly kind: 'language';
58
+ readonly language: UseLocaleSwitchResult;
59
+ }) | (ToolbarEntryBase & {
60
+ readonly kind: 'help';
61
+ readonly Content: ComponentType;
62
+ }) | (ToolbarEntryBase & {
63
+ readonly kind: 'assistant';
64
+ readonly assistant: UseAssistantPanelResult;
65
+ readonly run: () => void;
66
+ }) | (ToolbarEntryBase & {
67
+ readonly kind: 'custom';
68
+ readonly name: string;
69
+ readonly Element: ComponentType;
70
+ });
71
+ export interface UseToolbarActionsResult {
72
+ /**
73
+ * The spec's groups (`toolbarButtonGroup`), each a list of entries; an entry outside a group is a group of one, and
74
+ * a group nested in a group is flattened into it, where the built-in toolbar nests it
75
+ */
76
+ readonly groups: readonly (readonly ToolbarAction[])[];
77
+ /** The same entries, flattened */
78
+ readonly actions: readonly ToolbarAction[];
79
+ }
80
+ export type UseToolbarActions = (placement?: ToolbarPlacement) => UseToolbarActionsResult;
81
+ /**
82
+ * Hook to build a project layout's toolbar from the spec's `toolbar`, as the built-in `LayoutSlots.DesktopToolbar`,
83
+ * `LayoutSlots.MobileToolbar` and `LayoutSlots.MobileHamburgerMenu` do, as runnable entries instead of buttons.
84
+ * - It reads the first active root `toolbar` component's list for `placement` (`'desktop'` by default). Without
85
+ * one, it reads the default toolbar, which follows fullscreen and, for a viewer, leaves out share, undo and redo.
86
+ * - It leaves out an entry with nothing to offer: share when sharing is disabled, measurements or language with
87
+ * nothing to choose, help without content, the assistant without one in the spec. It leaves out an element that is
88
+ * not a toolbar entry, with a warning in development.
89
+ * - A project element registered under a built-in kind, such as `undoToolbarButton`, replaces that button in the
90
+ * built-in toolbar but not here: the entry stays the built-in action.
91
+ * - It differs from the built-in toolbar in four ways: the entries keep the spec's order for every placement, where
92
+ * `LayoutSlots.MobileToolbar` renders the `mobile` list reversed; a group nested in a group is flattened into it;
93
+ * the assistant's `showTitle` is the spec's, where the built-in button also hides its title on a phone or
94
+ * tablet-sized layout; and a `helpMenuAction` without children shows the registered help.
95
+ *
96
+ * The actions push the analytics events of the built-in buttons. Opening and closing the layout's own dialogs and
97
+ * popovers push none; the layout pushes its own through `useAnalytics`.
98
+ */
99
+ export declare const useToolbarActions: UseToolbarActions;
100
+ export {};
@@ -0,0 +1 @@
1
+ import{jsx as e}from"react/jsx-runtime";import{useCallback as t,useEffect as n,useMemo as a,useRef as o}from"react";import{P as r,match as s}from"ts-pattern";import{FrontendAnalyticsFactory as l,PhoenixLayoutElementWithChildren as i,PhoenixLayoutElements as u,useAnalyticsService as d,useIsDev as m,useIsFullscreenActive as p,useLocaleSwitch as b,useResolveLocalizable as c,useSetFullscreen as g,useShareLinks as h,useStoreSelector as k,useUndoRedo as T}from"#package/react-sdk";import{useConfigurator as B}from"../application-runtime/index.js";import{useAssistantPanel as f}from"./use-assistant-panel.js";import{useMeasurements as w}from"./use-measurements.js";import{useToolbarHelp as A}from"./use-toolbar-help.js";let v={undo:{id:"sdk.toolbar.undoRedo.undo.label",message:"Undo"},redo:{id:"sdk.toolbar.undoRedo.redo.label",message:"Redo"},enterFullscreen:{id:"sdk.toolbar.fullscreen.enter.label",message:"Open fullscreen"},exitFullscreen:{id:"sdk.toolbar.fullscreen.exit.label",message:"Exit fullscreen"},resetCamera:{id:"sdk.toolbar.camera.reset.label",message:"Reset camera"},shareToolbarButton:{id:"sdk.toolbar.share.open.label",message:"Share"},shareMenuAction:{id:"sdk.layout.menu.hamburger.share.label",message:"Share configuration"},measurementsToolbarButton:{id:"sdk.measurements",message:"Change measure"},measurementsMenuAction:{id:"sdk.layout.menu.measurements.label",message:"Change measure"},languageToolbarButton:{id:"sdk.toolbar.language.title",message:"Switch language"},languageMenuAction:{id:"sdk.layout.hamburgerMenu.language.label",message:"Change Language"},helpToolbarButton:{id:"sdk.toolbar.help.label",message:"Help"},helpMenuAction:{id:"sdk.layout.menu.hamburger.help.label",message:"Show help"},assistant:{id:"sdk.assistant.toolbarButton.label",message:"Assistant"}},C=(e,t,n=!1)=>({key:e,icon:t?.icon,showTitle:t?.showTitle??n});export const useToolbarActions=(M="desktop")=>{let{layoutSystem:P,cameraControlSystem:x}=B(),S=k(e=>P.getToolbarState(e.state),[P])[M],y=d(),$=c(),F=m(),R=T(),j=p(),L=g(),E=h({enabled:!1}),G=w(),D=b(),I=f(),O=A(),U=t(()=>{y.push(l.FullScreenModeToggled()),L(!j)},[y,L,j]),H=t(()=>{x.resetCamera()},[x]),W=t(()=>{I.setOpen(!I.open)},[I]),q=o(new WeakMap),z=t((e,t)=>{let n=q.current.get(e);if(n)return n;let a=()=>t();return q.current.set(e,a),a},[]),J=a(()=>{let t=[],n=(n,a)=>s(n).returnType().with({kind:"undoToolbarButton"},e=>({...C(a,e.props),kind:"undo",label:$(v.undo),disabled:!R.canUndo,run:R.undo})).with({kind:"redoToolbarButton"},e=>({...C(a,e.props),kind:"redo",label:$(v.redo),disabled:!R.canRedo,run:R.redo})).with({kind:r.union("enterFullscreenToolbarButton","exitFullscreenToolbarButton")},e=>({...C(a,e.props),kind:"fullscreen",label:$(j?v.exitFullscreen:v.enterFullscreen),active:j,run:U})).with({kind:"resetCameraToolbarButton"},e=>({...C(a,e.props),kind:"resetCamera",label:$(v.resetCamera),run:H})).with({kind:r.union("shareToolbarButton","shareMenuAction")},e=>E.available?{...C(a,e.props),kind:"share",label:$(v[e.kind])}:null).with({kind:r.union("measurementsToolbarButton","measurementsMenuAction")},e=>{let t=e.props?.showIndicatorSwitch??G.hasIndicatorSwitch,n=G.units.length>1||t;return n?{...C(a,void 0),kind:"measurements",label:$(v[e.kind]),measurements:{...G,hasIndicatorSwitch:t,available:n},icons:e.props?.icons}:null}).with({kind:r.union("languageToolbarButton","languageMenuAction")},e=>D.available?{...C(a,void 0),kind:"language",label:$(v[e.kind]),language:D}:null).with({kind:r.union("helpToolbarButton","helpMenuAction")},t=>{let{children:n}=t,o=void 0!==n?z(t,()=>e(u,{elements:n})):O;return o?{...C(a,t.props),kind:"help",label:$(v[t.kind]),Content:o}:null}).with({kind:"assistantToolbarButton"},e=>I.available?{...C(a,e.props,!0),kind:"assistant",label:$(v.assistant),assistant:I,run:W}:null).with({kind:"customLayoutElement"},t=>({...C(a,void 0),kind:"custom",label:t.props.name,name:t.props.name,Element:z(t,()=>e(i,{kind:t.kind,elementProps:t.props,children:t.children}))})).with({kind:r.union("toolbarButtonGroup","adminConnectedResourcePage","adminDataTableActions","adminDataTablePage","adminPresetActions","adminPresetCategoryActions","adminPresetCategoryPage","adminPresetListPage","adminRecipeActions","adminRecipeCollectionPage","enterSummaryButton","footerPrice","mainFooterActions","nextStepButton","otherActions","previousStepButton","saveTemplateButton","stepLabel","stepProgress")},e=>(t.push(e.kind),null)).exhaustive(),a=(e,t)=>{if("toolbarButtonGroup"!==e.kind){let a=n(e,`${t}-0`);return a?[a]:[]}return(e.children??[]).flatMap((e,o)=>"toolbarButtonGroup"===e.kind?a(e,`${t}-${o}`):n(e,`${t}-${o}`)??[])},o=(S??[]).map((e,t)=>a(e,`${M}-${t}`)).filter(e=>e.length>0);return{groups:o,actions:o.flat(),unsupported:t}},[S,M,$,R,j,U,H,E.available,G,D,I,W,O,z]),K=J.unsupported.join(", ");return n(()=>{F&&K&&console.warn(`useToolbarActions('${M}') leaves out elements that are not toolbar entries: ${K}.`)},[F,M,K]),a(()=>({groups:J.groups,actions:J.actions}),[J])};
@@ -0,0 +1,7 @@
1
+ import type { ComponentType } from 'react';
2
+ export type UseToolbarHelp = () => ComponentType | null;
3
+ /**
4
+ * Internal to `useToolbarActions`, not public: the help the project registers with the deprecated
5
+ * `createToolbarHelp`, which the default toolbar's help button shows, as a component, or `null` without one.
6
+ */
7
+ export declare const useToolbarHelp: UseToolbarHelp;
@@ -0,0 +1 @@
1
+ import{jsx as e}from"react/jsx-runtime";import{PhoenixLayoutElement as t,usePhoenixLayoutElementExists as o}from"#package/react-sdk";import{toolbarHelpElementName as r}from"../application-runtime/index.js";let l=()=>e(t,{name:r,elementProps:{},defaultSlot:()=>null});export const useToolbarHelp=()=>o(r)?l:null;
@@ -9,8 +9,9 @@ export interface AssistantToolChipsProps {
9
9
  readonly onUndo: (toolCallIds: ReadonlySet<string>) => void;
10
10
  }
11
11
  /**
12
- * A row of notes on what the assistant did in a reply, one per tool call. A click on a note logs
13
- * the input and the result of its call to the console. While one of the row's changes is the step
12
+ * A row of notes on what the assistant did in a reply, one per tool call, and one for the
13
+ * screenshots of a call that took any. A click on a call's note logs the input and the result of
14
+ * its call to the console. While one of the row's changes is the step
14
15
  * of the undo history the configuration is at, an Undo after the notes takes the row's changes
15
16
  * back, up to a change the user made in between.
16
17
  */
@@ -1 +1 @@
1
- import{jsx as e,jsxs as t}from"react/jsx-runtime";import{ButtonBase as i,Tooltip as a,styled as n}from"@mui/material";import{memo as o,useCallback as s}from"react";import{match as r}from"ts-pattern";import{useLocalizable as d}from"#package/react-sdk";import{PhxIcon as l}from"#package/ui-sdk";import{AssistantPanelName as m}from"./theme.js";let c={id:"sdk.assistant.tool.updateDesign.label",message:"Update design"},p={id:"sdk.assistant.tool.readDesign.label",message:"Read design"},h={id:"sdk.assistant.tool.mistake.hint",message:"The assistant made a mistake."},u={id:"sdk.assistant.tool.cancelled.hint",message:"Stopped before it finished."},f={id:"sdk.assistant.tool.noResult.hint",message:"The result of this step was lost. It may or may not have been done."},g={id:"sdk.assistant.tool.toolBudget.hint",message:"Not done: the assistant reached its limit of steps for one message."},k={id:"sdk.assistant.tool.undo.label",message:"Undo"},x=n("div",{name:m,slot:"chips"})(({theme:{palette:e,spacing:t,typography:i}})=>({...i.caption,alignItems:"start",color:e.text.secondary,display:"grid",gap:t(.75),gridTemplateColumns:"min-content minmax(0, 1fr)"})),y=n("span",{name:m,slot:"activity"})(({theme:{typography:e}})=>({blockSize:`calc(${e.caption.lineHeight} * 1em)`,display:"grid",placeItems:"center"})),w=n(l,{name:m,slot:"activityIcon"})({fontSize:14,'[data-chips="active"] &':{animation:"phx-assistant-turn 2.4s linear infinite","@media (prefers-reduced-motion: reduce)":{animation:"none"}},"@keyframes phx-assistant-turn":{to:{rotate:"360deg"}}}),b=n("span",{name:m,slot:"chip"})(({theme:{palette:e,spacing:t}})=>({cursor:"default",display:"inline-block",whiteSpace:"nowrap","&:not(:last-of-type)::after":{color:e.text.secondary,content:'"\xb7"',display:"inline-block",marginInline:t(.75),textDecoration:"none"},'&[data-chip="failed"]':{color:e.error.main},'&[data-chip="flawed"]':{textDecoration:"line-through",textDecorationColor:e.error.main}})),v=n(i,{name:m,slot:"undoButton"})(({theme:{palette:e,shape:t,spacing:i}})=>({alignItems:"center",animation:"phx-assistant-undo-in 150ms ease-out",borderRadius:t.borderRadius,color:e.primary.main,display:"inline-flex",font:"inherit",gap:i(.5),marginInlineStart:i(1),verticalAlign:"top","&:hover":{textDecoration:"underline"},"@media (prefers-reduced-motion: reduce)":{animation:"none"},"@keyframes phx-assistant-undo-in":{from:{opacity:0}}})),C=o(({tool:t})=>{let{chip:i,input:n,result:o}=t,l=d(c),m=d(p),k=d(h),x=d(u),y=d(f),w=d(g),v=r(i.label).with({kind:"text"},({text:e})=>e).with({kind:"updateDesign"},()=>l).with({kind:"readDesign"},()=>m).exhaustive(),C=s(()=>{console.info(`Assistant tool call "${v}"`,{input:n,result:o})},[n,v,o]);return e(a,{title:r(i).with({errorCode:"cancelled"},()=>x).with({errorCode:"no_result"},()=>y).with({errorCode:"tool_budget"},()=>w).with({state:"failed"},{state:"flawed"},()=>k).otherwise(()=>""),placement:"top-start",children:e(b,{onClick:C,"data-chip":i.state,children:v})})});export const AssistantToolChips=o(({tools:i,isActive:a,canUndo:n,onUndo:o})=>{let r=d(k),m=s(()=>{o(new Set(i.map(({id:e})=>e)))},[o,i]);return t(x,{"data-chips":a?"active":"done","aria-busy":a,children:[e(y,{children:e(w,{name:"Gear"})}),t("div",{children:[i.map(t=>e(C,{tool:t},t.id)),n&&t(v,{onClick:m,children:[e(l,{name:"ArrowCounterClockwise",fontSize:"inherit"}),r]})]})]})});
1
+ import{jsx as e,jsxs as t,Fragment as n}from"react/jsx-runtime";import{ButtonBase as o,ClickAwayListener as i,Tooltip as a,styled as s}from"@mui/material";import{memo as r,useCallback as l,useMemo as d,useRef as c,useState as m}from"react";import{match as p}from"ts-pattern";import{useLocalizable as h}from"#package/react-sdk";import{PhxIcon as u}from"#package/ui-sdk";import{assistantReferenceStyles as g}from"./reference-link/index.js";import{ScreenshotThumbnails as f,readToolScreenshots as k}from"./screenshots/index.js";import{AssistantPanelName as x}from"./theme.js";let y={id:"sdk.assistant.tool.updateDesign.label",message:"Update design"},b={id:"sdk.assistant.tool.readDesign.label",message:"Read design"},w={id:"sdk.assistant.tool.mistake.hint",message:"The assistant made a mistake."},C={id:"sdk.assistant.tool.cancelled.hint",message:"Stopped before it finished."},v={id:"sdk.assistant.tool.noResult.hint",message:"The result of this step was lost. It may or may not have been done."},D={id:"sdk.assistant.tool.toolBudget.hint",message:"Not done: the assistant reached its limit of steps for one message."},I={id:"sdk.assistant.tool.undo.label",message:"Undo"},S={id:"sdk.assistant.tool.screenshots.label",message:"{count, plural, one {# screenshot} other {# screenshots}}"},j=s("div",{name:x,slot:"chips"})(({theme:{palette:e,spacing:t,typography:n}})=>({...n.caption,alignItems:"start",color:e.text.secondary,display:"grid",gap:t(.75),gridTemplateColumns:"min-content minmax(0, 1fr)"})),T=s("span",{name:x,slot:"activity"})(({theme:{typography:e}})=>({blockSize:`calc(${e.caption.lineHeight} * 1em)`,display:"grid",placeItems:"center"})),A=s(u,{name:x,slot:"activityIcon"})({fontSize:14,'[data-chips="active"] &':{animation:"phx-assistant-turn 2.4s linear infinite","@media (prefers-reduced-motion: reduce)":{animation:"none"}},"@keyframes phx-assistant-turn":{to:{rotate:"360deg"}}}),R=s("span",{name:x,slot:"chip"})(({theme:{palette:e,spacing:t}})=>({cursor:"default",display:"inline-block",whiteSpace:"nowrap","&:not(:last-of-type)::after":{color:e.text.secondary,content:'"\xb7"',display:"inline-block",marginInline:t(.75),textDecoration:"none"},'&[data-chip="failed"]':{color:e.error.main},'&[data-chip="flawed"]':{textDecoration:"line-through",textDecorationColor:e.error.main}})),z=s("span",{name:x,slot:"screenshotsLink"})(g),E=s(o,{name:x,slot:"undoButton"})(({theme:{palette:e,shape:t,spacing:n}})=>({alignItems:"center",animation:"phx-assistant-undo-in 150ms ease-out",borderRadius:t.borderRadius,color:e.primary.main,display:"inline-flex",font:"inherit",gap:n(.5),marginInlineStart:n(1),verticalAlign:"top","&:hover":{textDecoration:"underline"},"@media (prefers-reduced-motion: reduce)":{animation:"none"},"@keyframes phx-assistant-undo-in":{from:{opacity:0}}})),L=r(({tool:t})=>{let{chip:n,input:o,result:i}=t,s=h(y),r=h(b),d=h(w),c=h(C),m=h(v),u=h(D),g=p(n.label).with({kind:"text"},({text:e})=>e).with({kind:"updateDesign"},()=>s).with({kind:"readDesign"},()=>r).exhaustive(),f=l(()=>{console.info(`Assistant tool call "${g}"`,{input:o,result:i})},[o,g,i]);return e(a,{title:p(n).with({errorCode:"cancelled"},()=>c).with({errorCode:"no_result"},()=>m).with({errorCode:"tool_budget"},()=>u).with({state:"failed"},{state:"flawed"},()=>d).otherwise(()=>""),placement:"top-start",children:e(R,{onClick:f,"data-chip":n.state,children:g})})}),P=r(({screenshots:t})=>{let n=h({...S,values:{count:t.length}}),[o,s]=m(!1),r=l(()=>s(!0),[]),d=l(()=>s(!1),[]),p=c(null),u=l(e=>{p.current=e},[]),g=l(()=>{p.current?.update()},[]),k=l(e=>{("Enter"===e.key||" "===e.key)&&(e.preventDefault(),s(!0))},[]);return e(R,{"data-chip":"screenshots",children:e(i,{onClickAway:d,mouseEvent:!!o&&"onClick",touchEvent:!!o&&"onTouchEnd",children:e(a,{open:o,onOpen:r,onClose:d,title:e(f,{screenshots:t,onImageLoad:g}),placement:"top-start",describeChild:!0,disableTouchListener:!0,PopperProps:{popperRef:u},slotProps:{tooltip:{sx:{background:"none",maxInlineSize:"none",padding:0}}},children:e(z,{role:"button",tabIndex:0,"aria-expanded":o,onClick:r,onKeyDown:k,children:n})})})})}),B=({tool:o})=>{let i=d(()=>k(o.result),[o.result]);return t(n,{children:[e(L,{tool:o}),i.length>0&&e(P,{screenshots:i})]})};export const AssistantToolChips=r(({tools:n,isActive:o,canUndo:i,onUndo:a})=>{let s=h(I),r=l(()=>{a(new Set(n.map(({id:e})=>e)))},[a,n]);return t(j,{"data-chips":o?"active":"done","aria-busy":o,children:[e(T,{children:e(A,{name:"Gear"})}),t("div",{children:[n.map(t=>e(B,{tool:t},t.id)),i&&t(E,{onClick:r,children:[e(u,{name:"ArrowCounterClockwise",fontSize:"inherit"}),s]})]})]})});
@@ -6,7 +6,7 @@ export interface AssistantMarkdownProps {
6
6
  readonly forms: AssistantFormsVisibility;
7
7
  }
8
8
  /**
9
- * Assistant text of the thread: Markdown with lists, tables, links, entity links, references, images, code and forms,
9
+ * Assistant text of the thread: Markdown with lists, tables, alerts, links, entity links, references, images, code and forms,
10
10
  * without a bubble. A form fence the model is still writing shows a placeholder.
11
11
  */
12
12
  export declare const AssistantMarkdown: import("react").MemoExoticComponent<({ markdown, isStreaming, forms }: AssistantMarkdownProps) => import("react/jsx-runtime").JSX.Element>;
@@ -1 +1 @@
1
- import{jsx as e,Fragment as r}from"react/jsx-runtime";import{styled as n}from"@mui/material";import{createContext as i,memo as o,useContext as t,useMemo as l}from"react";import a,{defaultUrlTransform as d}from"react-markdown";import m from"remark-gfm";import{AssistantEntityLink as s}from"./entity-link/index.js";import{AssistantForm as c}from"./form/index.js";import{AssistantReferenceLink as u,isAssistantLinkHref as p,parseAssistantLinkTarget as g}from"./reference-link/index.js";import{AssistantImage as f}from"./resource-image/index.js";import{completeStreamedMarkdown as h,hasOpenFence as k}from"./streamed-markdown.js";import{AssistantPanelName as b}from"./theme.js";let v=n("div",{name:b,slot:"assistantMessage"})(({theme:{palette:e,shape:r,spacing:n,typography:i}})=>({overflowWrap:"anywhere","& > :first-child":{marginBlockStart:0},"& > :last-child":{marginBlockEnd:0},"p, ul, ol, pre, blockquote":{marginBlock:n(1)},"h1, h2, h3, h4, h5, h6":{...i.subtitle2,marginBlock:n(1.5,.5)},"ul, ol":{paddingInlineStart:n(2.5)},a:{color:e.primary.main},code:{background:e.action.hover,borderRadius:r.borderRadius/2,fontFamily:"ui-monospace, Menlo, monospace",fontSize:"0.9em",paddingInline:n(.5)},pre:{background:e.action.hover,borderRadius:r.borderRadius,overflowX:"auto",padding:n(1),code:{background:"none",padding:0}},blockquote:{borderInlineStart:`2px solid ${e.divider}`,color:e.text.secondary,marginInline:0,paddingInlineStart:n(1.5)},"th, td":{borderBlockEnd:`1px solid ${e.divider}`,padding:n(.5,1),textAlign:"start",verticalAlign:"top"}})),x=n("div")({overflowX:"auto",table:{borderCollapse:"collapse",inlineSize:"100%"}}),y=i({forms:"hidden",openFenceEnd:void 0,isStreaming:!1}),j=({source:r,end:n})=>{let{forms:i,openFenceEnd:o,isStreaming:l}=t(y);return"hidden"===i?null:null!=n&&n===o?l?e(c,{source:r,status:"writing"}):null:e(c,{source:r,status:"disabled"===i?"waiting":"ready"})},w={a:({node:n,children:i,href:o,...t})=>{if(null==o||!p(o))return e("a",{...t,href:o,target:"_blank",rel:"noopener noreferrer",children:i});let l=g(o);return null==l?e(r,{children:i}):"entity"===l.kind?e(s,{id:l.id,children:i}):e(u,{target:l,children:i})},img:({src:r,alt:n})=>e(f,{src:r,alt:n}),pre:({node:r,children:n,...i})=>{let o=(e=>{let[r]=e?.children??[];if(r?.type!=="element"||"code"!==r.tagName)return;let{className:n}=r.properties;if(Array.isArray(n)&&n.includes("language-form"))return r.children.map(e=>"text"===e.type?e.value:"").join("")})(r);return null==o?e("pre",{...i,children:n}):e(j,{source:o,end:r?.position?.end.offset})},table:({node:r,children:n,...i})=>e(x,{children:e("table",{...i,children:n})})},S=[m],A=e=>p(e)?e:d(e);export const AssistantMarkdown=o(({markdown:r,isStreaming:n,forms:i})=>{let o=n?h(r):r,t=k(r)?o.length:void 0,d=l(()=>({forms:i,openFenceEnd:t,isStreaming:n}),[i,t,n]);return e(v,{children:e(y.Provider,{value:d,children:e(a,{components:w,remarkPlugins:S,urlTransform:A,children:o})})})});
1
+ import{jsx as e,Fragment as r}from"react/jsx-runtime";import{styled as n}from"@mui/material";import{createContext as i,memo as o,useContext as t,useMemo as l}from"react";import a,{defaultUrlTransform as d}from"react-markdown";import m from"remark-gfm";import{AssistantAlert as s,isAlertKind as c,remarkAlerts as u}from"./alert/index.js";import{AssistantEntityLink as p}from"./entity-link/index.js";import{AssistantForm as h}from"./form/index.js";import{AssistantReferenceLink as f,isAssistantLinkHref as g,parseAssistantLinkTarget as k}from"./reference-link/index.js";import{AssistantImage as b}from"./resource-image/index.js";import{completeStreamedMarkdown as v,hasOpenFence as x}from"./streamed-markdown.js";import{AssistantPanelName as y}from"./theme.js";let j=n("div",{name:y,slot:"assistantMessage"})(({theme:{palette:e,shape:r,spacing:n,typography:i}})=>({overflowWrap:"anywhere","& > :first-child":{marginBlockStart:0},"& > :last-child":{marginBlockEnd:0},"p, ul, ol, pre, blockquote":{marginBlock:n(1)},"h1, h2, h3, h4, h5, h6":{...i.subtitle2,marginBlock:n(1.5,.5)},"ul, ol":{paddingInlineStart:n(2.5)},a:{color:e.primary.main},code:{background:e.action.hover,borderRadius:r.borderRadius/2,fontFamily:"ui-monospace, Menlo, monospace",fontSize:"0.9em",paddingInline:n(.5)},pre:{background:e.action.hover,borderRadius:r.borderRadius,overflowX:"auto",padding:n(1),code:{background:"none",padding:0}},blockquote:{borderInlineStart:`2px solid ${e.divider}`,color:e.text.secondary,marginInline:0,paddingInlineStart:n(1.5)},"th, td":{borderBlockEnd:`1px solid ${e.divider}`,padding:n(.5,1),textAlign:"start",verticalAlign:"top"}})),w=n("div")({overflowX:"auto",table:{borderCollapse:"collapse",inlineSize:"100%"}}),S=i({forms:"hidden",openFenceEnd:void 0,isStreaming:!1}),A=({source:r,end:n})=>{let{forms:i,openFenceEnd:o,isStreaming:l}=t(S);return"hidden"===i?null:null!=n&&n===o?l?e(h,{source:r,status:"writing"}):null:e(h,{source:r,status:"disabled"===i?"waiting":"ready"})},B={a:({node:n,children:i,href:o,...t})=>{if(null==o||!g(o))return e("a",{...t,href:o,target:"_blank",rel:"noopener noreferrer",children:i});let l=k(o);return null==l?e(r,{children:i}):"entity"===l.kind?e(p,{id:l.id,children:i}):e(f,{target:l,children:i})},blockquote:({node:r,children:n,...i})=>{let o=r?.properties.dataAlert;return c(o)?e(s,{kind:o,children:n}):e("blockquote",{...i,children:n})},img:({src:r,alt:n})=>e(b,{src:r,alt:n}),pre:({node:r,children:n,...i})=>{let o=(e=>{let[r]=e?.children??[];if(r?.type!=="element"||"code"!==r.tagName)return;let{className:n}=r.properties;if(Array.isArray(n)&&n.includes("language-form"))return r.children.map(e=>"text"===e.type?e.value:"").join("")})(r);return null==o?e("pre",{...i,children:n}):e(A,{source:o,end:r?.position?.end.offset})},table:({node:r,children:n,...i})=>e(w,{children:e("table",{...i,children:n})})},I=[m,u],q=e=>g(e)?e:d(e);export const AssistantMarkdown=o(({markdown:r,isStreaming:n,forms:i})=>{let o=n?v(r):r,t=x(r)?o.length:void 0,d=l(()=>({forms:i,openFenceEnd:t,isStreaming:n}),[i,t,n]);return e(j,{children:e(S.Provider,{value:d,children:e(a,{components:B,remarkPlugins:I,urlTransform:q,children:o})})})});
@@ -0,0 +1,8 @@
1
+ import { type ReactNode } from 'react';
2
+ import type { AlertKind } from './remark-alerts.js';
3
+ export interface AssistantAlertProps {
4
+ readonly kind: AlertKind;
5
+ readonly children: ReactNode;
6
+ }
7
+ /** A GitHub alert in a reply: its content as Markdown, marked by the colour and icon of its kind. */
8
+ export declare const AssistantAlert: import("react").MemoExoticComponent<({ kind, children }: AssistantAlertProps) => import("react/jsx-runtime").JSX.Element>;
@@ -0,0 +1 @@
1
+ import{jsx as r,jsxs as i}from"react/jsx-runtime";import{alpha as o,styled as t}from"@mui/material";import{memo as n}from"react";import{PhxIcon as a}from"#package/ui-sdk";import{AssistantPanelName as e}from"../theme.js";let l={note:{color:"info",icon:"Info"},tip:{color:"success",icon:"Lightbulb"},important:{color:"primary",icon:"WarningCircle"},warning:{color:"warning",icon:"Warning"},caution:{color:"error",icon:"XCircle"}},c=t("div",{name:e,slot:"alert"})(({theme:{palette:r,shape:i,spacing:t,typography:n}})=>({borderInlineStart:"3px solid",borderRadius:i.borderRadius,display:"grid",gap:t(1),gridTemplateColumns:"min-content minmax(0, 1fr)",marginBlock:t(1),padding:t(1,1.5),...Object.fromEntries(Object.entries(l).map(([i,{color:t}])=>[`&[data-alert="${i}"]`,{background:o(r[t].main,.08),borderInlineStartColor:r[t].main,"& > :first-child":{color:r[t].main}}])),"& > :last-child > :first-child":{marginBlockStart:0},"& > :last-child > :last-child":{marginBlockEnd:0},"& > :first-child":{blockSize:`calc(${n.body2.lineHeight} * 1em)`,display:"grid",placeItems:"center"}}));export const AssistantAlert=n(({kind:o,children:t})=>i(c,{role:"note","data-alert":o,children:[r("span",{children:r(a,{name:l[o].icon})}),r("div",{children:t})]}));
@@ -0,0 +1,2 @@
1
+ export { AssistantAlert } from './AssistantAlert.js';
2
+ export { isAlertKind, remarkAlerts } from './remark-alerts.js';
@@ -0,0 +1 @@
1
+ export{AssistantAlert}from"./AssistantAlert.js";export{isAlertKind,remarkAlerts}from"./remark-alerts.js";
@@ -0,0 +1,10 @@
1
+ import type { Root } from 'mdast';
2
+ /** The kinds of GitHub alerts a reply can write, each with its own colour and icon. */
3
+ export type AlertKind = 'note' | 'tip' | 'important' | 'warning' | 'caution';
4
+ export declare const isAlertKind: (value: unknown) => value is AlertKind;
5
+ /**
6
+ * Remark plugin for GitHub alerts: a blockquote whose first line is a marker such as `[!WARNING]`
7
+ * loses the marker and carries its kind as the `dataAlert` property (`data-alert` in the page), for the `blockquote` override to render as a
8
+ * callout. A blockquote with an unknown marker stays as it is.
9
+ */
10
+ export declare const remarkAlerts: () => (tree: Root) => void;
@@ -0,0 +1 @@
1
+ let e=["note","tip","important","warning","caution"],t=/^\[!([a-z]+)\][ \t]*(?:\n|$)/i;export const isAlertKind=t=>"string"==typeof t&&e.some(e=>e===t);let r=e=>{let[r]=e.children;if(r?.type!=="paragraph")return;let[n,l]=r.children;if(n?.type!=="text")return;let i=t.exec(n.value),a=i?.[1]?.toLowerCase();if(null==i||!isAlertKind(a))return;let o=n.value.slice(i[0].length),c=!i[0].endsWith("\n")&&l?.type==="break";if(i[0].endsWith("\n")||null==l||c)return""===o?r.children.splice(0,c?2:1):n.value=o,0===r.children.length&&e.children.shift(),a},n=e=>{for(let t of e){if("blockquote"===t.type){let e=r(t);if(null!=e){t.data={...t.data,hProperties:{...t.data?.hProperties,dataAlert:e}};continue}}"children"in t&&n(t.children)}};export const remarkAlerts=()=>e=>{n(e.children)};
@@ -1 +1 @@
1
- import{jsx as e,jsxs as i}from"react/jsx-runtime";import{Trans as r}from"@lingui/react";import{Button as t,styled as o}from"@mui/material";import{memo as n,useCallback as a,useEffect as s,useMemo as l,useState as d}from"react";import{match as m}from"ts-pattern";import{useConfigurator as c}from"../../../application-runtime/index.js";import{AssistantPanelName as p}from"../theme.js";import{getBuiltInFormRegistry as u}from"./built-in-form-registry.js";import{composeAnswer as b}from"./compose-answer.js";import{describeBuildErrors as f}from"./describe-build-errors.js";import{parseFormBlock as g}from"./parse-form-block.js";let h=o("form",{name:p,slot:"form"})(({theme:{spacing:e}})=>({display:"flex",flexDirection:"column",gap:e(1.5),marginBlock:e(1)})),k=o(t,{name:p,slot:"formSubmit"})(({theme:{palette:e,spacing:i,typography:r}})=>({...r.body2,alignSelf:"end",background:e.primary.main,border:"none",borderRadius:8,color:e.primary.contrastText,fontWeight:r.fontWeightMedium,letterSpacing:"normal",minBlockSize:0,minInlineSize:0,paddingBlock:i(.5),paddingInline:i(2),textTransform:"none","&:hover":{background:e.primary.dark,border:"none"},"&.Mui-disabled":{background:e.action.disabledBackground,border:"none",color:e.action.disabled}})),w=o("div",{name:p,slot:"formNote"})(({theme:{palette:e,shape:i,spacing:r,typography:t}})=>({...t.caption,alignItems:"center",background:e.action.hover,borderRadius:i.borderRadius,color:e.text.secondary,display:"flex",flexWrap:"wrap",gap:r(1),justifyContent:"space-between",marginBlock:r(1),paddingBlock:r(1),paddingInline:r(1.5)})),x=({model:t,disabled:o,send:n})=>{let[a,s]=d(()=>new Map),[l,c]=d(()=>new Map),p=(i,r)=>{let{id:d,definition:u,label:f,value:g,attributes:h}=i;return m(u).with({role:"option"},({component:m})=>e(m,{attributes:h,label:f,disabled:o,selected:!0===a.get(d),onSelect:()=>{t.isQuick?n(b(t,new Map([[i.id,!0]]),l)):s(e=>{let t=new Map(e);if("choice"===r.definition.role){for(let e of r.children)t.delete(e.id);t.set(i.id,!0)}else t.set(i.id,!0!==e.get(i.id));return t})}},d)).with({role:"input"},({component:r})=>e(r,{attributes:h,label:f,value:g,disabled:o,state:a.get(d),onChange:(e,r)=>{s(r=>new Map(r).set(i.id,e)),c(e=>new Map(e).set(i.id,r))}},d)).with({role:"group"},{role:"choice"},{role:"choices"},({component:r})=>e(r,{attributes:h,label:f,disabled:o,children:i.children.map(e=>p(e,i))},d)).exhaustive()};return i(h,{onSubmit:e=>{e.preventDefault(),o||t.isQuick||n(b(t,a,l))},children:[t.root.children.map(e=>p(e,t.root)),!t.isQuick&&e(k,{type:"submit",variant:"contained",disabled:o,disableElevation:!0,children:e(r,{id:"sdk.assistant.form.submit.label",message:"Submit"})})]})};export const AssistantForm=n(({source:o,status:n})=>{let{assistantSystem:m}=c(),[p,b]=d(!1),h="writing"===n,k=l(()=>h?void 0:g(o,u()),[o,h]),y="ready"!==n||p,j=a(e=>{b(!0),m.send(e).finally(()=>b(!1))},[m]);return(s(()=>{k?.ok===!1&&console.warn("The assistant wrote a form that could not be built.",k.errors)},[k]),k)?k.ok?0===k.root.children.length?null:e(x,{model:k,disabled:y,send:j}):i(w,{role:"alert",children:[e("span",{children:e(r,{id:"sdk.assistant.form.failure",message:"The assistant couldn't build this form."})}),e(t,{size:"small",variant:"outlined",color:"inherit",disabled:y,onClick:()=>j(f(k.errors)),children:e(r,{id:"sdk.assistant.form.fix.label",message:"Fix it"})})]}):e(w,{children:e(r,{id:"sdk.assistant.form.writing",message:"Preparing a form…"})})});
1
+ import{jsx as e,jsxs as i}from"react/jsx-runtime";import{Trans as r}from"@lingui/react";import{Button as o,styled as t}from"@mui/material";import{memo as n,useCallback as a,useEffect as s,useMemo as l,useState as d}from"react";import{match as m}from"ts-pattern";import{useConfigurator as c}from"../../../application-runtime/index.js";import{AssistantPanelName as p}from"../theme.js";import{composeAnswer as u}from"./compose-answer.js";import{describeBuildErrors as b}from"./describe-build-errors.js";import{parseFormBlock as f}from"./parse-form-block.js";import{useFormRegistry as g}from"./registry/index.js";let h=t("div",{name:p,slot:"form"})(({theme:{spacing:e}})=>({display:"flex",flexDirection:"column",gap:e(1.5),marginBlock:e(1)})),k=t(o,{name:p,slot:"formSubmit"})(({theme:{palette:e,spacing:i,typography:r}})=>({...r.body2,alignSelf:"end",background:e.primary.main,border:"none",borderRadius:8,color:e.primary.contrastText,fontWeight:r.fontWeightMedium,letterSpacing:"normal",minBlockSize:0,minInlineSize:0,paddingBlock:i(.5),paddingInline:i(2),textTransform:"none","&:hover":{background:e.primary.dark,border:"none"},"&.Mui-disabled":{background:e.action.disabledBackground,border:"none",color:e.action.disabled}})),w=t("div",{name:p,slot:"formNote"})(({theme:{palette:e,shape:i,spacing:r,typography:o}})=>({...o.caption,alignItems:"center",background:e.action.hover,borderRadius:i.borderRadius,color:e.text.secondary,display:"flex",flexWrap:"wrap",gap:r(1),justifyContent:"space-between",marginBlock:r(1),paddingBlock:r(1),paddingInline:r(1.5)})),x=({model:o,disabled:t,send:n})=>{let[a,s]=d(()=>new Map),[l,c]=d(()=>new Map),p=(i,r)=>{let{id:l,definition:d,label:b,attributes:f}=i;return m(d).with({role:"option"},({component:d})=>e(d,{attributes:f,label:b,disabled:t,selected:!0===a.get(l),onSelect:e=>{o.isQuick?n(u(o,new Map([[i.id,!0]]),new Map([[i.id,e]]))):(c(r=>new Map(r).set(i.id,e)),s(e=>{let o=new Map(e);if("choice"===r.definition.role){for(let e of r.children)o.delete(e.id);o.set(i.id,!0)}else o.set(i.id,!0!==e.get(i.id));return o}))}},l)).with({role:"input"},({component:r})=>e(r,{attributes:f,label:b,disabled:t,state:a.get(l),onChange:(e,r)=>{o.isQuick?n(u(o,new Map([[i.id,e]]),new Map([[i.id,r]]))):(s(r=>new Map(r).set(i.id,e)),c(e=>new Map(e).set(i.id,r)))}},l)).with({role:"group"},{role:"choice"},{role:"choices"},({component:r})=>e(r,{attributes:f,label:b,disabled:t,children:i.children.map(e=>p(e,i))},l)).exhaustive()};return i(h,{children:[o.root.children.map(e=>p(e,o.root)),!o.isQuick&&e(k,{variant:"contained",disabled:t,disableElevation:!0,onClick:()=>{t||o.isQuick||n(u(o,a,l))},children:e(r,{id:"sdk.assistant.form.submit.label",message:"Submit"})})]})};export const AssistantForm=n(({source:t,status:n})=>{let{assistantSystem:m}=c(),[p,u]=d(!1),h="writing"===n,k=g(),M=l(()=>h?void 0:f(t,k),[t,h,k]),y="ready"!==n||p,j=a(e=>{u(!0),m.send(e).finally(()=>u(!1))},[m]);return(s(()=>{M?.ok===!1&&console.warn("The assistant wrote a form that could not be built.",M.errors)},[M]),M)?M.ok?0===M.root.children.length?null:e(x,{model:M,disabled:y,send:j}):i(w,{role:"alert",children:[e("span",{children:e(r,{id:"sdk.assistant.form.failure",message:"The assistant couldn't build this form."})}),e(o,{size:"small",variant:"outlined",color:"inherit",disabled:y,onClick:()=>j(b(M.errors)),children:e(r,{id:"sdk.assistant.form.fix.label",message:"Fix it"})})]}):e(w,{children:e(r,{id:"sdk.assistant.form.writing",message:"Preparing a form…"})})});
@@ -6,6 +6,6 @@ export declare const FORM_PLACEHOLDER = "\u2014";
6
6
  * The user's answer to a form, sent as their message: one line per labelled container or input as
7
7
  * `Label: value`, a bare line for an unlabelled one, two spaces of indentation per labelled
8
8
  * container, and the placeholder for anything unanswered. Unlabelled groups are flattened into
9
- * their parent, and a picked option answers with its value, or its label without one.
9
+ * their parent, and a picked option, as an input, answers with what it reported.
10
10
  */
11
11
  export declare const composeAnswer: (model: BuiltFormModel, state: FormState, answers: FormAnswers) => string;
@@ -1 +1 @@
1
- import{match as t}from"ts-pattern";export const FORM_PLACEHOLDER="—";let e=(t,e)=>`${" ".repeat(t)}${e}`,n=(t,e)=>null==t?e:`${t}: ${e}`,r=({value:t,label:e})=>t??e??"",i=({children:t},{state:e})=>t.filter(({id:t})=>!0===e.get(t)).map(r),o=(r,l,p)=>{let{label:h}=r;return t(r.definition.role).with("group",()=>{if(null==h)return r.children.flatMap(t=>o(t,l,p));let t=r.children.flatMap(t=>o(t,l+1,p));return t.length>0?[e(l,`${h}:`),...t]:[e(l,`${h}: —`)]}).with("choice",()=>[e(l,n(h,i(r,p)[0]??"—"))]).with("choices",()=>{let t=i(r,p);return 0===t.length?[e(l,n(h,"—"))]:null==h?t.map(t=>e(l,t)):[e(l,`${h}:`),...t.map(t=>e(l+1,t))]}).with("input",()=>[e(l,n(h,(({id:t,value:e},{answers:n})=>n.has(t)?n.get(t):""===e?void 0:e)(r,p)??"—"))]).with("option",()=>[]).exhaustive()};export const composeAnswer=(t,e,n)=>o(t.root,0,{state:e,answers:n}).join("\n");
1
+ import{match as t}from"ts-pattern";export const FORM_PLACEHOLDER="—";let e=(t,e)=>`${" ".repeat(t)}${e}`,n=(t,e)=>null==t?e:`${t}: ${e}`,r=({children:t},{state:e,answers:n})=>t.flatMap(({id:t})=>{let r=n.get(t);return!0===e.get(t)&&null!=r&&""!==r?[r]:[]}),l=(i,o,p)=>{let{label:a}=i;return t(i.definition.role).with("group",()=>{if(null==a)return i.children.flatMap(t=>l(t,o,p));let t=i.children.flatMap(t=>l(t,o+1,p));return t.length>0?[e(o,`${a}:`),...t]:[e(o,`${a}: —`)]}).with("choice",()=>[e(o,n(a,r(i,p)[0]??"—"))]).with("choices",()=>{let t=r(i,p);return 0===t.length?[e(o,n(a,"—"))]:null==a?t.map(t=>e(o,t)):[e(o,`${a}:`),...t.map(t=>e(o+1,t))]}).with("input",()=>[e(o,n(a,p.answers.get(i.id)??"—"))]).with("option",()=>[]).exhaustive()};export const composeAnswer=(t,e,n)=>l(t.root,0,{state:e,answers:n}).join("\n");
@@ -1,4 +1,4 @@
1
- import type { FormElementDefinition } from './form-element-definition.js';
1
+ import type { FormElementDefinition } from './registry/index.js';
2
2
  /**
3
3
  * An element of a parsed form. Options outside a `choice` or `choices` are already wrapped in an
4
4
  * implicit container, and the top level of the block is an implicit group without a label.
@@ -8,7 +8,6 @@ export interface FormNode {
8
8
  readonly id: string;
9
9
  readonly definition: FormElementDefinition;
10
10
  readonly label?: string;
11
- readonly value?: string;
12
11
  readonly attributes: Readonly<Record<string, unknown>>;
13
12
  readonly children: readonly FormNode[];
14
13
  }
@@ -21,8 +20,8 @@ export interface FormBuildError {
21
20
  readonly message: string;
22
21
  }
23
22
  /**
24
- * A form fence as the panel renders it, or every reason it cannot. A quick form asks one question:
25
- * the first pick sends it, and it has no submit button.
23
+ * A form fence as the panel renders it, or every reason it cannot. A quick form asks one question,
24
+ * a choice or a quick input: the first pick or action sends it, and it has no submit button.
26
25
  */
27
26
  export type FormModel = {
28
27
  readonly ok: true;
@@ -1,4 +1,4 @@
1
1
  /** What the user did in a form, by node id: `true` for a picked option, the input's own state for an input. */
2
2
  export type FormState = ReadonlyMap<string, unknown>;
3
- /** The answer text each input reported, by node id; an input that never reported is missing. */
3
+ /** The answer text each option or input reported, by node id; one that never reported is missing. */
4
4
  export type FormAnswers = ReadonlyMap<string, string | undefined>;
@@ -1,2 +1,4 @@
1
1
  export { AssistantForm } from './AssistantForm.js';
2
2
  export type { AssistantFormStatus } from './AssistantForm.js';
3
+ export type { AssistantFormElementRoleProps, AssistantFormElementType, CreateAssistantFormElement, } from './registry/index.js';
4
+ export { createAssistantFormElementFactory } from './registry/index.js';
@@ -1 +1 @@
1
- export{AssistantForm}from"./AssistantForm.js";
1
+ export{AssistantForm}from"./AssistantForm.js";export{createAssistantFormElementFactory}from"./registry/index.js";
@@ -1,9 +1,10 @@
1
1
  import type { FormModel } from './form-model.js';
2
- import type { FormRegistry } from './form-registry.js';
2
+ import type { FormRegistry } from './registry/index.js';
3
3
  /**
4
4
  * Builds a form from the markup of a ```` ```form ```` fence. A block whose only content is loose
5
5
  * options asks one question, so they form an implicit `choice`; elsewhere loose options form an
6
- * implicit `choices`. A block with any unknown element, invalid attribute or misplaced element is
6
+ * implicit `choices`. A block that asks one question, a choice or a quick input, is quick. A block
7
+ * with any unknown element, invalid attribute, misplaced element or option with nothing to show is
7
8
  * not built at all, and every such error is returned.
8
9
  */
9
10
  export declare const parseFormBlock: (source: string, registry: FormRegistry) => FormModel;
@@ -1 +1 @@
1
- import{Parser as e}from"htmlparser2";import{readFormAttributes as o}from"./read-form-attributes.js";let r=({name:e,attributes:o,position:r})=>({element:e,label:o.label,position:r}),t=({definition:e},o,r)=>({id:o,definition:e,attributes:{},children:r}),i=(e,o)=>{let r=[],i=[],n=()=>{i.length>0&&(r.push(t(o.registry.choices,`choices-${i[0]?.id}`,i)),i=[])};for(let o of e)"option"===o.definition.role?i.push(o):(n(),r.push(o));return n(),r},n=(e,t,l)=>e.flatMap(e=>((e,t,l)=>{var s;let a=l.registry.get(e.name);if(!a){l.errors.push({...r(e),message:"not a form element"}),n(e.children,void 0,l);return}let{definition:h}=a,p=(s=h.role,t?.role==="option"||t?.role==="input"?`cannot be inside <${t.name}>, which holds no elements`:(t?.role==="choice"||t?.role==="choices")&&"option"!==s?`cannot be inside <${t.name}>, which holds only options`:void 0);p&&l.errors.push({...r(e),message:p});let{attributes:c,errors:u}=o(a,e.attributes);for(let o of u)l.errors.push({...r(e),message:o});let{label:d,value:g,...m}=c,f=n(e.children,{name:e.name,role:h.role},l);return{id:String(e.position),definition:h,label:"string"==typeof d?d:void 0,value:"string"==typeof g?g:void 0,attributes:m,children:"group"===h.role?i(f,l):f}})(e,t,l)??[]),l=e=>{if("choice"===e.definition.role)return!0;let[o,...r]=e.children;return"group"===e.definition.role&&null!=o&&0===r.length&&l(o)};export const parseFormBlock=(o,r)=>{let s,a,h,p,c={registry:r,errors:[]},u={name:r.group.definition.name,role:"group"},d=n((a=[s=[]],h=0,(p=new e({onopentag:(e,o)=>{let r={name:e,attributes:o,position:h+=1,children:[]};a.at(-1)?.push(r),a.push(r.children)},onclosetag:()=>{a.length>1&&a.pop()}},{xmlMode:!0,lowerCaseTags:!0,lowerCaseAttributeNames:!0,recognizeSelfClosing:!0})).write(o),p.end(),s),u,c);if(c.errors.length>0)return{ok:!1,errors:c.errors};let g=d.length>0&&d.every(e=>"option"===e.definition.role)?[t(r.choice,"choice",d)]:i(d,c),m=t(r.group,"root",g);return{ok:!0,root:m,isQuick:l(m)}};
1
+ import{Parser as e}from"htmlparser2";import{readFormAttributes as r}from"./read-form-attributes.js";let o=({name:e,attributes:r,position:o})=>({element:e,label:r.label,position:o}),t=({definition:e},r,o)=>({id:r,definition:e,attributes:{},children:o}),i=(e,r)=>{let o=[],i=[],n=()=>{i.length>0&&(o.push(t(r.registry.choices,`choices-${i[0]?.id}`,i)),i=[])};for(let r of e)"option"===r.definition.role?i.push(r):(n(),o.push(r));return n(),o},n=(e,t,l)=>e.flatMap(e=>((e,t,l)=>{var s;let a,h=l.registry.get(e.name);if(!h){l.errors.push({...o(e),message:"not a form element"}),n(e.children,void 0,l);return}let{definition:u}=h,p=(s=u.role,t?.role==="option"||t?.role==="input"?`cannot be inside <${t.name}>, which holds no elements`:(t?.role==="choice"||t?.role==="choices")&&"option"!==s?`cannot be inside <${t.name}>, which holds only options`:void 0);p&&l.errors.push({...o(e),message:p});let{attributes:c,errors:g}=r(h,e.attributes);for(let r of g)l.errors.push({...o(e),message:r});let{label:d,...m}=c;null!=u.identity&&["label",...u.identity].every(r=>{let o;return null==(o=e.attributes[r])||""===o})&&l.errors.push({...o(e),message:(a=u.identity,`has nothing to show: give it one of the attributes ${["label",...a].map(e=>`"${e}"`).join(", ")}`)});let f=n(e.children,{name:e.name,role:u.role},l);return{id:String(e.position),definition:u,label:"string"==typeof d?d:void 0,attributes:m,children:"group"===u.role?i(f,l):f}})(e,t,l)??[]),l=e=>{let{definition:r}=e;if("choice"===r.role||"input"===r.role&&!0===r.quick)return!0;let[o,...t]=e.children;return"group"===r.role&&null!=o&&0===t.length&&l(o)};export const parseFormBlock=(r,o)=>{let s,a,h,u,p={registry:o,errors:[]},c={name:o.group.definition.name,role:"group"},g=n((a=[s=[]],h=0,(u=new e({onopentag:(e,r)=>{let o={name:e,attributes:r,position:h+=1,children:[]};a.at(-1)?.push(o),a.push(o.children)},onclosetag:()=>{a.length>1&&a.pop()}},{xmlMode:!0,lowerCaseTags:!0,lowerCaseAttributeNames:!0,recognizeSelfClosing:!0})).write(r),u.end(),s),c,p);if(p.errors.length>0)return{ok:!1,errors:p.errors};let d=g.length>0&&g.every(e=>"option"===e.definition.role)?[t(o.choice,"choice",g)]:i(g,p),m=t(o.group,"root",d);return{ok:!0,root:m,isQuick:l(m)}};
@@ -1,4 +1,4 @@
1
- import type { RegisteredFormElement } from './form-registry.js';
1
+ import type { RegisteredFormElement } from './registry/index.js';
2
2
  /** The attributes of an element converted to their declared types, and what was wrong with them. */
3
3
  export interface FormAttributesReading {
4
4
  readonly attributes: Readonly<Record<string, unknown>>;
@@ -1 +1 @@
1
- import{match as t}from"ts-pattern";let e=t=>{if(""===t.trim())return;let e=Number(t);return Number.isFinite(e)?e:void 0},r=(r,{type:i})=>t(i).with("string",()=>r).with("number",()=>e(r)??r).with("integer",()=>{let t=e(r);return null!=t&&Number.isInteger(t)?t:r}).with("boolean",()=>""===r||"true"===r||"false"!==r&&r).exhaustive(),i={string:"a string",number:"a number",integer:"an integer",boolean:"true or false"},u=(t,{type:e,enum:r})=>r?`the attribute "${t}" must be one of ${r.map(t=>`"${t}"`).join(", ")}`:`the attribute "${t}" must be ${i[e]}`;export const readFormAttributes=({definition:t,attributes:e},i)=>{let n={},a=[];for(let[t,o]of Object.entries(i)){let i=e.get(t);if(!i){a.push(`the attribute "${t}" is not declared`);continue}let s=r(o,i.attribute);i.validate(s)?n[t]=s:a.push(u(t,i.attribute))}for(let e of t.required??[])e in i||a.push(`the attribute "${e}" is required`);return{attributes:n,errors:a}};
1
+ import{match as t}from"ts-pattern";let e=t=>{if(""===t.trim())return;let e=Number(t);return Number.isFinite(e)?e:void 0},r=(r,{type:u})=>t(u).with("string",()=>r).with("number",()=>e(r)??r).with("integer",()=>{let t=e(r);return null!=t&&Number.isInteger(t)?t:r}).with("boolean",()=>""===r||"true"===r||"false"!==r&&r).exhaustive(),u={string:"a string",number:"a number",integer:"an integer",boolean:"true or false"},n=(t,e,r)=>null!=t&&null!=e?`between ${t} and ${e}${r}`:null!=t?`at least ${t}${r}`:`at most ${e}${r}`,i=(t,e,r)=>{let{type:i,enum:l,pattern:a,minimum:s,maximum:b,minLength:o,maxLength:$}=e;if(l)return`the attribute "${t}" must be one of ${l.map(t=>`"${t}"`).join(", ")}`;if("string"===i){if(null!=o||null!=$){let e="string"==typeof r?[...r].length:0;if(null!=o&&e<o||null!=$&&e>$)return`the attribute "${t}" must be ${n(o,$," characters long")}`}return null==a?`the attribute "${t}" must be ${u[i]}`:`the attribute "${t}" must match the pattern ${a}`}return"number"==typeof r&&(null!=s||null!=b)?`the attribute "${t}" must be ${u[i]} ${n(s,b,"")}`:`the attribute "${t}" must be ${u[i]}`};export const readFormAttributes=({definition:t,attributes:e},u)=>{let n={},l=[];for(let[t,a]of Object.entries(u)){let u=e.get(t);if(!u){l.push(`the attribute "${t}" is not declared`);continue}let s=r(a,u.attribute);u.validate(s)?n[t]=s:l.push(i(t,u.attribute,s))}for(let e of t.required??[])e in u||l.push(`the attribute "${e}" is required`);return{attributes:n,errors:l}};
@@ -0,0 +1,3 @@
1
+ import { type FormElementDefinition } from './form-element-definition.js';
2
+ /** The elements of every assistant form: the built-ins the SDK prompt lists, with their components. */
3
+ export declare const BUILT_IN_FORM_ELEMENTS: readonly FormElementDefinition[];
@@ -0,0 +1 @@
1
+ import{ASSISTANT_BUILT_IN_FORM_ELEMENTS as e}from"#package/domain";import{FormCard as o,FormConfirm as m,FormGroup as r,FormNumber as t,FormOptions as i,FormReply as n,FormSwatch as c,FormText as p}from"../../form-elements/index.js";import{createFormElementDefinition as a}from"./form-element-definition.js";let f={group:r,choice:i,choices:i,reply:n,card:o,swatch:c,text:p,number:t,confirm:m};export const BUILT_IN_FORM_ELEMENTS=e.map(e=>a(e,f[e.name]));
@@ -0,0 +1,31 @@
1
+ import type { ReactNode } from 'react';
2
+ import { type AssistantFormElementRegistration, type AssistantFormRole } from '#package/domain';
3
+ import type { FormContainerProps, FormInputProps, FormOptionProps } from '../../form-elements/index.js';
4
+ /**
5
+ * What a project's generated types say of one of its assistant form elements: its role and the
6
+ * attributes its component gets, typed from its declaration under `assistant.formElements`.
7
+ */
8
+ export interface AssistantFormElementType {
9
+ readonly role: AssistantFormRole;
10
+ readonly attributes: object;
11
+ }
12
+ /**
13
+ * The props of the component of a project's form element, by its role: a container's, an option's
14
+ * or an input's, with the element's typed attributes. An input's `STATE` is its own and is inferred
15
+ * from the component.
16
+ */
17
+ export type AssistantFormElementRoleProps<TYPE extends AssistantFormElementType, STATE = unknown> = TYPE extends {
18
+ readonly role: 'option';
19
+ } ? FormOptionProps<TYPE['attributes']> : TYPE extends {
20
+ readonly role: 'input';
21
+ } ? FormInputProps<STATE, TYPE['attributes']> : FormContainerProps<TYPE['attributes']>;
22
+ /**
23
+ * Registers the component of one of the project's assistant form elements, under the name its YAML
24
+ * declares it by in `assistant.formElements`. The name picks the props the component gets.
25
+ */
26
+ export type CreateAssistantFormElement<TYPES extends object> = <NAME extends keyof TYPES & string, STATE = unknown>(name: NAME, component: (props: TYPES[NAME] extends AssistantFormElementType ? AssistantFormElementRoleProps<TYPES[NAME], STATE> : never) => ReactNode) => AssistantFormElementRegistration;
27
+ /**
28
+ * `createAssistantFormElement` typed by a project's form elements, for the generated code to put
29
+ * on `phx.frontend`.
30
+ */
31
+ export declare const createAssistantFormElementFactory: <TYPES extends object>() => CreateAssistantFormElement<TYPES>;
@@ -0,0 +1 @@
1
+ import{createAssistantFormElement as t}from"#package/domain";export const createAssistantFormElementFactory=()=>t;
@@ -1,6 +1,6 @@
1
1
  import type { ComponentType } from 'react';
2
2
  import type { AssistantFormElementDescriptor } from '#package/domain';
3
- import type { FormContainerProps, FormInputProps, FormOptionProps } from '../form-elements/index.js';
3
+ import type { FormContainerProps, FormInputProps, FormOptionProps } from '../../form-elements/index.js';
4
4
  /** An element a form can render: what the prompt knows of it, and the component that renders it for its role. */
5
5
  export type FormElementDefinition = (AssistantFormElementDescriptor & {
6
6
  readonly role: 'group' | 'choice' | 'choices';
@@ -12,3 +12,5 @@ export type FormElementDefinition = (AssistantFormElementDescriptor & {
12
12
  readonly role: 'input';
13
13
  readonly component: ComponentType<FormInputProps>;
14
14
  });
15
+ /** Pairs an element's descriptor with the component written for it, a built-in's or the project's own. */
16
+ export declare const createFormElementDefinition: (descriptor: AssistantFormElementDescriptor, component: ComponentType<never>) => FormElementDefinition;
@@ -0,0 +1 @@
1
+ import{match as o}from"ts-pattern";export const createFormElementDefinition=(t,e)=>o(t.role).with("group","choice","choices",o=>({...t,role:o,component:e})).with("option",o=>({...t,role:o,component:e})).with("input",o=>({...t,role:o,component:e})).exhaustive();