@qoretechnologies/reqraft 0.10.25 → 0.10.26

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 (310) hide show
  1. package/.claude/CLAUDE.md +52 -23
  2. package/design/COMPACT_ENGINE_REDESIGN.md +156 -0
  3. package/design/FORM_ENGINE_COMPACT_UX_PLAN.md +353 -0
  4. package/dist/components/FocusedEditing/index.d.ts +9 -1
  5. package/dist/components/FocusedEditing/index.d.ts.map +1 -1
  6. package/dist/components/FocusedEditing/index.js +2 -2
  7. package/dist/components/FocusedEditing/index.js.map +1 -1
  8. package/dist/components/composer/Composer.d.ts +108 -0
  9. package/dist/components/composer/Composer.d.ts.map +1 -0
  10. package/dist/components/composer/Composer.js +238 -0
  11. package/dist/components/composer/Composer.js.map +1 -0
  12. package/dist/components/composer/helpers.d.ts +21 -0
  13. package/dist/components/composer/helpers.d.ts.map +1 -0
  14. package/dist/components/composer/helpers.js +75 -0
  15. package/dist/components/composer/helpers.js.map +1 -0
  16. package/dist/components/composer/index.d.ts +3 -0
  17. package/dist/components/composer/index.d.ts.map +1 -0
  18. package/dist/components/composer/index.js +19 -0
  19. package/dist/components/composer/index.js.map +1 -0
  20. package/dist/components/form/engine/CompactRow.d.ts.map +1 -1
  21. package/dist/components/form/engine/CompactRow.js +307 -110
  22. package/dist/components/form/engine/CompactRow.js.map +1 -1
  23. package/dist/components/form/engine/CompactToolbar.d.ts.map +1 -1
  24. package/dist/components/form/engine/CompactToolbar.js +123 -106
  25. package/dist/components/form/engine/CompactToolbar.js.map +1 -1
  26. package/dist/components/form/engine/FormEngine.d.ts +107 -11
  27. package/dist/components/form/engine/FormEngine.d.ts.map +1 -1
  28. package/dist/components/form/engine/FormEngine.js +618 -179
  29. package/dist/components/form/engine/FormEngine.js.map +1 -1
  30. package/dist/components/form/engine/compactRowContext.d.ts +9 -0
  31. package/dist/components/form/engine/compactRowContext.d.ts.map +1 -1
  32. package/dist/components/form/engine/compactRowContext.js.map +1 -1
  33. package/dist/components/form/engine/compactRowStyles.d.ts +7 -3
  34. package/dist/components/form/engine/compactRowStyles.d.ts.map +1 -1
  35. package/dist/components/form/engine/compactRowStyles.js +88 -51
  36. package/dist/components/form/engine/compactRowStyles.js.map +1 -1
  37. package/dist/components/form/engine/compactToolbarContext.d.ts +1 -0
  38. package/dist/components/form/engine/compactToolbarContext.d.ts.map +1 -1
  39. package/dist/components/form/engine/compactToolbarContext.js.map +1 -1
  40. package/dist/components/form/engine/optionActions.d.ts +28 -0
  41. package/dist/components/form/engine/optionActions.d.ts.map +1 -0
  42. package/dist/components/form/engine/optionActions.js +18 -0
  43. package/dist/components/form/engine/optionActions.js.map +1 -0
  44. package/dist/components/form/engine/readFirst.d.ts +63 -2
  45. package/dist/components/form/engine/readFirst.d.ts.map +1 -1
  46. package/dist/components/form/engine/readFirst.js +121 -6
  47. package/dist/components/form/engine/readFirst.js.map +1 -1
  48. package/dist/components/form/engine/rendererTypes.d.ts +35 -0
  49. package/dist/components/form/engine/rendererTypes.d.ts.map +1 -0
  50. package/dist/components/form/engine/rendererTypes.js +63 -0
  51. package/dist/components/form/engine/rendererTypes.js.map +1 -0
  52. package/dist/components/form/engine/variants/VariantCalmTable.d.ts +6 -0
  53. package/dist/components/form/engine/variants/VariantCalmTable.d.ts.map +1 -0
  54. package/dist/components/form/engine/variants/VariantCalmTable.js +94 -0
  55. package/dist/components/form/engine/variants/VariantCalmTable.js.map +1 -0
  56. package/dist/components/form/engine/variants/VariantCards.d.ts +6 -0
  57. package/dist/components/form/engine/variants/VariantCards.d.ts.map +1 -0
  58. package/dist/components/form/engine/variants/VariantCards.js +80 -0
  59. package/dist/components/form/engine/variants/VariantCards.js.map +1 -0
  60. package/dist/components/form/engine/variants/VariantFocus.d.ts +7 -0
  61. package/dist/components/form/engine/variants/VariantFocus.d.ts.map +1 -0
  62. package/dist/components/form/engine/variants/VariantFocus.js +138 -0
  63. package/dist/components/form/engine/variants/VariantFocus.js.map +1 -0
  64. package/dist/components/form/engine/variants/VariantMinimal.d.ts +6 -0
  65. package/dist/components/form/engine/variants/VariantMinimal.d.ts.map +1 -0
  66. package/dist/components/form/engine/variants/VariantMinimal.js +73 -0
  67. package/dist/components/form/engine/variants/VariantMinimal.js.map +1 -0
  68. package/dist/components/form/engine/variants/focusDemo.d.ts +13 -0
  69. package/dist/components/form/engine/variants/focusDemo.d.ts.map +1 -0
  70. package/dist/components/form/engine/variants/focusDemo.js +139 -0
  71. package/dist/components/form/engine/variants/focusDemo.js.map +1 -0
  72. package/dist/components/form/engine/variants/variantModel.d.ts +70 -0
  73. package/dist/components/form/engine/variants/variantModel.d.ts.map +1 -0
  74. package/dist/components/form/engine/variants/variantModel.js +133 -0
  75. package/dist/components/form/engine/variants/variantModel.js.map +1 -0
  76. package/dist/components/form/engine/variants/variantParts.d.ts +79 -0
  77. package/dist/components/form/engine/variants/variantParts.d.ts.map +1 -0
  78. package/dist/components/form/engine/variants/variantParts.js +191 -0
  79. package/dist/components/form/engine/variants/variantParts.js.map +1 -0
  80. package/dist/components/form/expressions/builder/index.d.ts.map +1 -1
  81. package/dist/components/form/expressions/builder/index.js +13 -2
  82. package/dist/components/form/expressions/builder/index.js.map +1 -1
  83. package/dist/components/form/expressions/useExpressions.d.ts.map +1 -1
  84. package/dist/components/form/expressions/useExpressions.js +4 -1
  85. package/dist/components/form/expressions/useExpressions.js.map +1 -1
  86. package/dist/components/form/fields/Field.d.ts.map +1 -1
  87. package/dist/components/form/fields/Field.js +5 -3
  88. package/dist/components/form/fields/Field.js.map +1 -1
  89. package/dist/components/form/fields/allowed-values/AllowedValues.d.ts +2 -1
  90. package/dist/components/form/fields/allowed-values/AllowedValues.d.ts.map +1 -1
  91. package/dist/components/form/fields/allowed-values/AllowedValues.js +8 -26
  92. package/dist/components/form/fields/allowed-values/AllowedValues.js.map +1 -1
  93. package/dist/components/form/fields/auto/AutoFormField.d.ts +3 -0
  94. package/dist/components/form/fields/auto/AutoFormField.d.ts.map +1 -1
  95. package/dist/components/form/fields/auto/AutoFormField.js +42 -8
  96. package/dist/components/form/fields/auto/AutoFormField.js.map +1 -1
  97. package/dist/components/form/fields/binary/Binary.d.ts +15 -0
  98. package/dist/components/form/fields/binary/Binary.d.ts.map +1 -0
  99. package/dist/components/form/fields/binary/Binary.js +74 -0
  100. package/dist/components/form/fields/binary/Binary.js.map +1 -0
  101. package/dist/components/form/fields/boolean/Boolean.js +1 -1
  102. package/dist/components/form/fields/boolean/Boolean.js.map +1 -1
  103. package/dist/components/form/fields/multi-select/MultiSelectFormField.d.ts.map +1 -1
  104. package/dist/components/form/fields/multi-select/MultiSelectFormField.js +5 -4
  105. package/dist/components/form/fields/multi-select/MultiSelectFormField.js.map +1 -1
  106. package/dist/components/form/fields/select/Select.d.ts.map +1 -1
  107. package/dist/components/form/fields/select/Select.js +29 -12
  108. package/dist/components/form/fields/select/Select.js.map +1 -1
  109. package/dist/components/form/fields/select/SelectCollection.d.ts +8 -2
  110. package/dist/components/form/fields/select/SelectCollection.d.ts.map +1 -1
  111. package/dist/components/form/fields/select/SelectCollection.js +52 -16
  112. package/dist/components/form/fields/select/SelectCollection.js.map +1 -1
  113. package/dist/components/form/index.d.ts +2 -0
  114. package/dist/components/form/index.d.ts.map +1 -1
  115. package/dist/components/form/index.js +2 -0
  116. package/dist/components/form/index.js.map +1 -1
  117. package/dist/components/imageLightbox/ImageLightbox.d.ts +21 -0
  118. package/dist/components/imageLightbox/ImageLightbox.d.ts.map +1 -0
  119. package/dist/components/imageLightbox/ImageLightbox.js +169 -0
  120. package/dist/components/imageLightbox/ImageLightbox.js.map +1 -0
  121. package/dist/components/imageLightbox/index.d.ts +2 -0
  122. package/dist/components/imageLightbox/index.d.ts.map +1 -0
  123. package/dist/components/imageLightbox/index.js +18 -0
  124. package/dist/components/imageLightbox/index.js.map +1 -0
  125. package/dist/components/searchFilterBar/SearchFilterBar.d.ts +33 -0
  126. package/dist/components/searchFilterBar/SearchFilterBar.d.ts.map +1 -0
  127. package/dist/components/searchFilterBar/SearchFilterBar.js +76 -0
  128. package/dist/components/searchFilterBar/SearchFilterBar.js.map +1 -0
  129. package/dist/components/searchFilterBar/index.d.ts +2 -0
  130. package/dist/components/searchFilterBar/index.d.ts.map +1 -0
  131. package/dist/components/searchFilterBar/index.js +18 -0
  132. package/dist/components/searchFilterBar/index.js.map +1 -0
  133. package/dist/components/supportTicket/AttachmentChips.d.ts +10 -0
  134. package/dist/components/supportTicket/AttachmentChips.d.ts.map +1 -0
  135. package/dist/components/supportTicket/AttachmentChips.js +122 -0
  136. package/dist/components/supportTicket/AttachmentChips.js.map +1 -0
  137. package/dist/components/supportTicket/InterfaceReferenceTags.d.ts +43 -0
  138. package/dist/components/supportTicket/InterfaceReferenceTags.d.ts.map +1 -0
  139. package/dist/components/supportTicket/InterfaceReferenceTags.js +31 -0
  140. package/dist/components/supportTicket/InterfaceReferenceTags.js.map +1 -0
  141. package/dist/components/supportTicket/ReferencePicker.d.ts +87 -0
  142. package/dist/components/supportTicket/ReferencePicker.d.ts.map +1 -0
  143. package/dist/components/supportTicket/ReferencePicker.js +295 -0
  144. package/dist/components/supportTicket/ReferencePicker.js.map +1 -0
  145. package/dist/components/supportTicket/TicketHeader.d.ts +86 -0
  146. package/dist/components/supportTicket/TicketHeader.d.ts.map +1 -0
  147. package/dist/components/supportTicket/TicketHeader.js +149 -0
  148. package/dist/components/supportTicket/TicketHeader.js.map +1 -0
  149. package/dist/components/supportTicket/TicketMetaTags.d.ts +32 -0
  150. package/dist/components/supportTicket/TicketMetaTags.d.ts.map +1 -0
  151. package/dist/components/supportTicket/TicketMetaTags.js +21 -0
  152. package/dist/components/supportTicket/TicketMetaTags.js.map +1 -0
  153. package/dist/components/supportTicket/TicketReplyBox.d.ts +63 -0
  154. package/dist/components/supportTicket/TicketReplyBox.d.ts.map +1 -0
  155. package/dist/components/supportTicket/TicketReplyBox.js +115 -0
  156. package/dist/components/supportTicket/TicketReplyBox.js.map +1 -0
  157. package/dist/components/supportTicket/attachmentAccess.d.ts +37 -0
  158. package/dist/components/supportTicket/attachmentAccess.d.ts.map +1 -0
  159. package/dist/components/supportTicket/attachmentAccess.js +132 -0
  160. package/dist/components/supportTicket/attachmentAccess.js.map +1 -0
  161. package/dist/components/supportTicket/fileToAttachment.d.ts +9 -0
  162. package/dist/components/supportTicket/fileToAttachment.d.ts.map +1 -0
  163. package/dist/components/supportTicket/fileToAttachment.js +28 -0
  164. package/dist/components/supportTicket/fileToAttachment.js.map +1 -0
  165. package/dist/components/supportTicket/index.d.ts +11 -0
  166. package/dist/components/supportTicket/index.d.ts.map +1 -0
  167. package/dist/components/supportTicket/index.js +27 -0
  168. package/dist/components/supportTicket/index.js.map +1 -0
  169. package/dist/components/supportTicket/meta.d.ts +71 -0
  170. package/dist/components/supportTicket/meta.d.ts.map +1 -0
  171. package/dist/components/supportTicket/meta.js +115 -0
  172. package/dist/components/supportTicket/meta.js.map +1 -0
  173. package/dist/components/supportTicket/ticketModel.d.ts +102 -0
  174. package/dist/components/supportTicket/ticketModel.d.ts.map +1 -0
  175. package/dist/components/supportTicket/ticketModel.js +3 -0
  176. package/dist/components/supportTicket/ticketModel.js.map +1 -0
  177. package/dist/components/ticketReferences/TicketReferences.d.ts +52 -0
  178. package/dist/components/ticketReferences/TicketReferences.d.ts.map +1 -0
  179. package/dist/components/ticketReferences/TicketReferences.js +492 -0
  180. package/dist/components/ticketReferences/TicketReferences.js.map +1 -0
  181. package/dist/components/ticketReferences/index.d.ts +3 -0
  182. package/dist/components/ticketReferences/index.d.ts.map +1 -0
  183. package/dist/components/ticketReferences/index.js +6 -0
  184. package/dist/components/ticketReferences/index.js.map +1 -0
  185. package/dist/components/ticketThread/TicketThread.d.ts +57 -0
  186. package/dist/components/ticketThread/TicketThread.d.ts.map +1 -0
  187. package/dist/components/ticketThread/TicketThread.js +299 -0
  188. package/dist/components/ticketThread/TicketThread.js.map +1 -0
  189. package/dist/components/ticketThread/index.d.ts +3 -0
  190. package/dist/components/ticketThread/index.d.ts.map +1 -0
  191. package/dist/components/ticketThread/index.js +7 -0
  192. package/dist/components/ticketThread/index.js.map +1 -0
  193. package/dist/helpers/common.d.ts +5 -0
  194. package/dist/helpers/common.d.ts.map +1 -1
  195. package/dist/helpers/common.js +20 -1
  196. package/dist/helpers/common.js.map +1 -1
  197. package/dist/helpers/scrollbar.d.ts +2 -0
  198. package/dist/helpers/scrollbar.d.ts.map +1 -0
  199. package/dist/helpers/scrollbar.js +25 -0
  200. package/dist/helpers/scrollbar.js.map +1 -0
  201. package/dist/index.d.ts +8 -1
  202. package/dist/index.d.ts.map +1 -1
  203. package/dist/index.js +10 -1
  204. package/dist/index.js.map +1 -1
  205. package/dist/providers/StorageProvider.d.ts +13 -0
  206. package/dist/providers/StorageProvider.d.ts.map +1 -1
  207. package/dist/providers/StorageProvider.js +29 -5
  208. package/dist/providers/StorageProvider.js.map +1 -1
  209. package/package.json +6 -5
  210. package/src/components/FocusedEditing/index.tsx +17 -2
  211. package/src/components/composer/Composer.stories.tsx +238 -0
  212. package/src/components/composer/Composer.tsx +545 -0
  213. package/src/components/composer/helpers.ts +74 -0
  214. package/src/components/composer/index.ts +2 -0
  215. package/src/components/dpqlEditor/DpqlEditor.stories.tsx +74 -2
  216. package/src/components/form/engine/CompactRow.tsx +561 -283
  217. package/src/components/form/engine/CompactToolbar.tsx +216 -182
  218. package/src/components/form/engine/FormEngine.stories.tsx +1736 -162
  219. package/src/components/form/engine/FormEngine.tsx +886 -170
  220. package/src/components/form/engine/FormEngineRemote.stories.tsx +377 -0
  221. package/src/components/form/engine/_structuredData/StructuredDataView.stories.tsx +8 -0
  222. package/src/components/form/engine/compactRowContext.ts +14 -0
  223. package/src/components/form/engine/compactRowStyles.ts +273 -146
  224. package/src/components/form/engine/compactToolbarContext.ts +1 -0
  225. package/src/components/form/engine/optionActions.ts +40 -0
  226. package/src/components/form/engine/readFirst.ts +169 -10
  227. package/src/components/form/engine/rendererTypes.ts +55 -0
  228. package/src/components/form/engine/variants/FormEngineVariants.stories.tsx +159 -0
  229. package/src/components/form/engine/variants/VariantCalmTable.tsx +242 -0
  230. package/src/components/form/engine/variants/VariantCards.tsx +212 -0
  231. package/src/components/form/engine/variants/VariantFocus.tsx +382 -0
  232. package/src/components/form/engine/variants/VariantMinimal.tsx +170 -0
  233. package/src/components/form/engine/variants/focusDemo.ts +145 -0
  234. package/src/components/form/engine/variants/variantModel.ts +216 -0
  235. package/src/components/form/engine/variants/variantParts.tsx +313 -0
  236. package/src/components/form/expressions/ExpressionField.stories.tsx +84 -2
  237. package/src/components/form/expressions/builder/ExpressionBuilder.stories.tsx +213 -19
  238. package/src/components/form/expressions/builder/index.tsx +12 -1
  239. package/src/components/form/expressions/useExpressions.ts +4 -1
  240. package/src/components/form/fields/Field.stories.tsx +40 -0
  241. package/src/components/form/fields/Field.tsx +10 -1
  242. package/src/components/form/fields/allowed-values/AllowedValues.tsx +13 -36
  243. package/src/components/form/fields/array/ArrayAutoField.stories.tsx +64 -0
  244. package/src/components/form/fields/auto/AutoFormField.stories.tsx +146 -2
  245. package/src/components/form/fields/auto/AutoFormField.tsx +42 -1
  246. package/src/components/form/fields/binary/Binary.stories.tsx +122 -0
  247. package/src/components/form/fields/binary/Binary.tsx +81 -0
  248. package/src/components/form/fields/boolean/Boolean.stories.tsx +58 -0
  249. package/src/components/form/fields/boolean/Boolean.tsx +1 -1
  250. package/src/components/form/fields/byte-size/ByteSize.stories.tsx +24 -0
  251. package/src/components/form/fields/color/Color.stories.tsx +30 -0
  252. package/src/components/form/fields/cron/Cron.stories.tsx +8 -0
  253. package/src/components/form/fields/date/Date.stories.tsx +22 -0
  254. package/src/components/form/fields/file/File.stories.tsx +48 -0
  255. package/src/components/form/fields/long-string/LongString.stories.tsx +24 -0
  256. package/src/components/form/fields/markdown/Markdown.stories.tsx +8 -0
  257. package/src/components/form/fields/multi-select/MultiSelectFormField.tsx +14 -10
  258. package/src/components/form/fields/number/Number.stories.tsx +31 -0
  259. package/src/components/form/fields/object/Object.stories.tsx +88 -0
  260. package/src/components/form/fields/radio-group/RadioGroup.stories.tsx +24 -0
  261. package/src/components/form/fields/rich-text/RichText.stories.tsx +23 -0
  262. package/src/components/form/fields/schema-definition/SchemaDefinitionField.stories.tsx +72 -0
  263. package/src/components/form/fields/select/Select.stories.tsx +108 -0
  264. package/src/components/form/fields/select/Select.tsx +38 -12
  265. package/src/components/form/fields/select/SelectCollection.tsx +78 -17
  266. package/src/components/form/fields/string/String.stories.tsx +16 -0
  267. package/src/components/form/fields/template/TemplateField.stories.tsx +160 -0
  268. package/src/components/form/fields/url/Url.stories.tsx +24 -0
  269. package/src/components/form/index.tsx +2 -0
  270. package/src/components/imageLightbox/ImageLightbox.stories.tsx +238 -0
  271. package/src/components/imageLightbox/ImageLightbox.tsx +236 -0
  272. package/src/components/imageLightbox/index.ts +1 -0
  273. package/src/components/log/Log.stories.tsx +96 -0
  274. package/src/components/menu/Menu.stories.tsx +54 -0
  275. package/src/components/qonsoleSmartInput/QonsoleSmartInput.stories.tsx +83 -37
  276. package/src/components/searchFilterBar/SearchFilterBar.tsx +131 -0
  277. package/src/components/searchFilterBar/index.ts +1 -0
  278. package/src/components/smartEditor/SmartEditor.stories.tsx +32 -0
  279. package/src/components/supportTicket/AttachmentChips.stories.tsx +171 -0
  280. package/src/components/supportTicket/AttachmentChips.tsx +147 -0
  281. package/src/components/supportTicket/InterfaceReferenceTags.stories.tsx +171 -0
  282. package/src/components/supportTicket/InterfaceReferenceTags.tsx +96 -0
  283. package/src/components/supportTicket/ReferencePicker.stories.tsx +519 -0
  284. package/src/components/supportTicket/ReferencePicker.tsx +563 -0
  285. package/src/components/supportTicket/TicketConversation.stories.tsx +121 -0
  286. package/src/components/supportTicket/TicketHeader.stories.tsx +183 -0
  287. package/src/components/supportTicket/TicketHeader.tsx +247 -0
  288. package/src/components/supportTicket/TicketMetaTags.stories.tsx +103 -0
  289. package/src/components/supportTicket/TicketMetaTags.tsx +85 -0
  290. package/src/components/supportTicket/TicketReplyBox.stories.tsx +351 -0
  291. package/src/components/supportTicket/TicketReplyBox.tsx +146 -0
  292. package/src/components/supportTicket/attachmentAccess.ts +97 -0
  293. package/src/components/supportTicket/fileToAttachment.ts +24 -0
  294. package/src/components/supportTicket/index.ts +10 -0
  295. package/src/components/supportTicket/meta.ts +185 -0
  296. package/src/components/supportTicket/ticketModel.ts +131 -0
  297. package/src/components/ticketReferences/TicketReferences.stories.tsx +315 -0
  298. package/src/components/ticketReferences/TicketReferences.tsx +886 -0
  299. package/src/components/ticketReferences/index.ts +2 -0
  300. package/src/components/ticketThread/TicketThread.stories.tsx +828 -0
  301. package/src/components/ticketThread/TicketThread.tsx +704 -0
  302. package/src/components/ticketThread/index.ts +6 -0
  303. package/src/helpers/common.ts +19 -0
  304. package/src/helpers/scrollbar.ts +32 -0
  305. package/src/hooks/useFetch/useFetch.stories.tsx +30 -0
  306. package/src/hooks/useStorage/useStorage.stories.tsx +82 -0
  307. package/src/hooks/useWebSocket/useWebsocket.stories.tsx +127 -1
  308. package/src/index.tsx +8 -1
  309. package/src/providers/StorageProvider.tsx +30 -4
  310. package/src/stores/currentUser/currentUser.stories.tsx +49 -0
@@ -0,0 +1,563 @@
1
+ import {
2
+ ReqoreInput,
3
+ ReqoreMenu,
4
+ ReqoreMenuItem,
5
+ ReqoreModal,
6
+ ReqoreSpinner,
7
+ } from '@qoretechnologies/reqore';
8
+ import { TReqoreBadge } from '@qoretechnologies/reqore/dist/components/Button';
9
+ import { IReqoreIconName } from '@qoretechnologies/reqore/dist/types/icons';
10
+ import { ReactNode, useCallback, useEffect, useMemo, useState } from 'react';
11
+ import styled from 'styled-components';
12
+ import { thinScrollbar } from '../../helpers/scrollbar';
13
+ import {
14
+ defaultInterfaceIcon,
15
+ defaultInterfaceKindLabel,
16
+ IInterfaceReference,
17
+ } from './meta';
18
+
19
+ /*
20
+ * The interface browser: kinds on one side, the selected kind's interfaces on the
21
+ * other, and one search field that scopes both. Sits above a ticket composer, toggled
22
+ * by the composer's "Reference interfaces" action.
23
+ *
24
+ * The host owns the data. Which kinds exist and what lives under one are questions only
25
+ * the surrounding app can answer — the IDE lists them off the customer's live instance,
26
+ * a story hands over fixtures — so this component takes `kinds` and the selected kind's
27
+ * `items` and does the rest: selection, search, and turning a click into a reference.
28
+ * Nothing here fetches; `kind` is the only contract, and the host maps it onto whatever
29
+ * transport it has.
30
+ *
31
+ * Three rules the layout follows, in order of how often they bite:
32
+ *
33
+ * - Search filters the kind list down to what matches, and keeps ONE extra row: the
34
+ * selected kind, dimmed, when the query doesn't match it. That row is what stops the
35
+ * right-hand results outliving the kind they belong to — without it you'd see three
36
+ * interfaces and no way to tell what they were. Everything else goes, because a match
37
+ * that survives only by scrolling past nine dimmed rows isn't a match the user found.
38
+ * - A picked interface STAYS in the list, selected. Dropping it on pick was a
39
+ * disappearing act with no undo inside the picker; now the row toggles.
40
+ * - Below `STACK_BREAKPOINT` of its OWN width — not the viewport's, since this thing
41
+ * lives inside composers and drawers — the two panes collapse into one column and the
42
+ * selected kind's interfaces render directly beneath it. On a phone it goes further
43
+ * and lifts into a modal, because inline it would own the whole screen.
44
+ */
45
+
46
+ /** How tall the panes get before they scroll: side by side, stacked, and in the modal. */
47
+ const COLUMNS_MAX_HEIGHT = '220px';
48
+ const STACKED_MAX_HEIGHT = '280px';
49
+ const MODAL_MAX_HEIGHT = '60vh';
50
+ const KIND_PANE_WIDTH = 150;
51
+ /** Container width (not viewport) below which the panes stack into one column. */
52
+ const STACK_BREAKPOINT = 420;
53
+ const BORDER = 'rgba(123, 104, 238, 0.25)';
54
+ /*
55
+ * Marks the selected kind when the search doesn't match it — it's only still on the
56
+ * list to say what the interfaces on the right are. Quiet, but pickable.
57
+ */
58
+ const DIMMED_CLASS = 'reqore-reference-picker-dimmed';
59
+ /*
60
+ * Marks an already-referenced row. Reqore paints `selected` purely through styled
61
+ * props — no class, no aria state — so "is this row picked" is unobservable from the
62
+ * outside without a marker of our own. Stable, so a host can style on it too.
63
+ */
64
+ const PICKED_CLASS = 'reqore-reference-picker-picked';
65
+
66
+ /*
67
+ * A scroll pane with the thin, unobtrusive scrollbar the Qonsole surfaces use
68
+ * (transparent track, translucent rounded thumb) rather than the raw browser one.
69
+ * webkit-only, like those surfaces: setting `scrollbar-width` as well would let
70
+ * Chromium override this custom 6px with its own, wider, "thin".
71
+ */
72
+ const Pane = styled.div<{ $right?: boolean; $maxHeight: string }>`
73
+ ${({ $right }) =>
74
+ $right
75
+ ? 'flex: 1; min-width: 0;'
76
+ : `width: ${KIND_PANE_WIDTH}px; flex: none; border-right: 1px solid ${BORDER};`}
77
+ max-height: ${({ $maxHeight }) => $maxHeight};
78
+ overflow-y: auto;
79
+ padding: 4px;
80
+
81
+ ${thinScrollbar}
82
+ `;
83
+
84
+ /** The stacked counterpart of `Pane` — one column, so one scroll region. */
85
+ const Stack = styled.div<{ $maxHeight: string }>`
86
+ max-height: ${({ $maxHeight }) => $maxHeight};
87
+ overflow-y: auto;
88
+ padding: 4px;
89
+
90
+ ${thinScrollbar}
91
+ `;
92
+
93
+ /*
94
+ * The selected kind's interfaces once the panes have collapsed. The indent and the
95
+ * rule are the only things left saying "these belong to the row above" — in the
96
+ * two-pane layout the divider between the panes says it.
97
+ */
98
+ const Nested = styled.div`
99
+ margin: 2px 0 4px 10px;
100
+ padding-left: 8px;
101
+ border-left: 1px solid ${BORDER};
102
+ `;
103
+
104
+ const Frame = styled.div<{ $bare?: boolean }>`
105
+ ${({ $bare }) => ($bare ? '' : `border: 1px solid ${BORDER}; border-radius: 8px;`)}
106
+ overflow: hidden;
107
+
108
+ /* Rows the search doesn't match. Set here rather than per row so the rule is
109
+ stated once, and on the row itself (not a wrapper) so it can't disturb the
110
+ menu's own flex layout. */
111
+ .${DIMMED_CLASS} {
112
+ opacity: 0.35;
113
+ }
114
+ `;
115
+
116
+ const Panes = styled.div`
117
+ display: flex;
118
+ `;
119
+
120
+ /*
121
+ * An underline search field. The input itself is borderless (`flat transparent`) and
122
+ * this wrapper carries the single bottom border, so the search reads as a line rather
123
+ * than a full grey box — including on focus, where Reqore's default is a 2px outline
124
+ * around the whole control. Suppressing that outline and brightening the underline
125
+ * instead keeps a focus cue without the box. The selector is scoped under this wrapper,
126
+ * so it outranks Reqore's without `!important`.
127
+ *
128
+ * `$active` (the field has a query) holds the underline at full accent, so a filtered
129
+ * list is legible as filtered at a glance — the same signal `intent='info'` carries on
130
+ * a plain filter control, spoken in this surface's own accent.
131
+ */
132
+ const Search = styled.div<{ $accent: string; $active?: boolean }>`
133
+ padding: 6px 4px 4px;
134
+ border-bottom: 1px solid
135
+ ${({ $accent, $active }) => ($active ? $accent : `${$accent}80`)};
136
+ transition: border-color 0.15s ease-out;
137
+
138
+ .reqore-control-wrapper:focus-within {
139
+ outline: none;
140
+ }
141
+ &:focus-within {
142
+ border-bottom-color: ${({ $accent }) => $accent};
143
+ }
144
+ `;
145
+
146
+ const Note = styled.div`
147
+ opacity: 0.4;
148
+ padding: 8px 6px;
149
+ font-size: 12px;
150
+ `;
151
+
152
+ const DEFAULT_ACCENT = '#762f7e';
153
+
154
+ /*
155
+ * How a picked row reads: `info`, tinted rather than filled.
156
+ *
157
+ * Two Reqore details make this less obvious than `selected` + `intent`:
158
+ *
159
+ * - `selected` becomes `active` on the button, and the active branch paints a solid
160
+ * background from the intent while ignoring `minimal` and `transparent` outright.
161
+ * So `selected` can't be softened — it has to go, and `minimal` carries the state.
162
+ * - `ReqoreMenuItem` sets `transparent` on every row, and `transparent` short-circuits
163
+ * `minimal`'s tint to nothing. Turning it off for picked rows is what lets the tint
164
+ * land, and it's only spread when the row IS picked — a `transparent: undefined` on
165
+ * the others would override the menu item's own default and flatten them all.
166
+ *
167
+ * The point of the tint: a solid blue bar is too much weight for "this one's already
168
+ * in your list". The rows still up for choosing are what the user is reading, and they
169
+ * should stay the loudest thing in the pane.
170
+ */
171
+ const pickedItemProps = (isPicked: boolean) =>
172
+ isPicked ? ({ intent: 'info', minimal: true, transparent: false } as const) : {};
173
+
174
+ /**
175
+ * One interface in the list. A bare string is the name and nothing else — the common
176
+ * case, and what a host that has only names can keep passing. The object form adds the
177
+ * two things a name alone can't disambiguate: a `description` second line (what the
178
+ * thing is for, an owning group, a path) and a `badge` (a version, a run count, a
179
+ * status tag). Search reads both the name and the description, since both are on screen.
180
+ */
181
+ export interface IReferencePickerItem {
182
+ /** the interface name — this is what gets stored on the reference */
183
+ name: string;
184
+ /** a muted second line under the name */
185
+ description?: string;
186
+ /** trailing badge, before the add/remove icon */
187
+ badge?: TReqoreBadge | TReqoreBadge[];
188
+ }
189
+
190
+ export type TReferencePickerItem = string | IReferencePickerItem;
191
+
192
+ /** `auto` picks `stacked` from the picker's own measured width. */
193
+ export type TReferencePickerLayout = 'auto' | 'columns' | 'stacked';
194
+ /** `auto` lifts into a modal on a phone-sized viewport, when `onClose` is given. */
195
+ export type TReferencePickerPresentation = 'auto' | 'inline' | 'modal';
196
+
197
+ export interface IReferencePickerProps {
198
+ /** the interface kinds listed down the left pane */
199
+ kinds: string[];
200
+ /** the kind whose interfaces `items` holds */
201
+ kind: string;
202
+ onKindChange: (kind: string) => void;
203
+ /**
204
+ * The selected kind's interfaces — bare names, or objects carrying a description
205
+ * and a badge. Fetching is the host's job; it knows where they come from and how
206
+ * to cache them.
207
+ */
208
+ items: TReferencePickerItem[];
209
+ /** `items` is still being fetched, so the right pane shows a spinner rather than
210
+ * claiming the kind is empty */
211
+ loading?: boolean;
212
+ /**
213
+ * The host's fetch for this kind failed. Shown in place of the list, because an
214
+ * empty pane would otherwise read as "this instance has no workflows" — which is a
215
+ * different and much more alarming statement than "we couldn't ask".
216
+ */
217
+ error?: string;
218
+ /** Retry the failed fetch. The error state is pressable when given. */
219
+ onRetry?: () => void;
220
+ /** Already-picked references. Anything of the current kind that is already picked
221
+ * renders selected in place — never removed from the list. */
222
+ picked?: IInterfaceReference[];
223
+ onAdd: (reference: IInterfaceReference) => void;
224
+ /** Un-pick a reference from inside the picker. Without it a picked row still shows
225
+ * as picked, it just can't be toggled back off here. */
226
+ onRemove?: (reference: IInterfaceReference) => void;
227
+ /** the whole picker is inert (e.g. a reply is in flight) */
228
+ disabled?: boolean;
229
+ /** Per-kind icon. Consumers with their own icon vocabulary (the IDE) pass one; the
230
+ * built-in per-kind default is used when omitted. */
231
+ resolveInterfaceIcon?: (kind: string) => IReqoreIconName;
232
+ /**
233
+ * Per-kind reading name — "Value maps" for `value-map`. The kind id is a wire value
234
+ * and never reaches the user; this is what does. Search matches both, so typing
235
+ * either the id or the label finds the kind. Defaults to the built-in Qorus
236
+ * vocabulary.
237
+ */
238
+ resolveKindLabel?: (kind: string) => string;
239
+ /** the underline / selected-kind colour. Defaults to the support surfaces' violet. */
240
+ accent?: string;
241
+ /** shown above the panes — the composer's picked-reference chips, typically */
242
+ header?: ReactNode;
243
+ /**
244
+ * Dismiss the picker. Required for the modal presentation (a modal with no way out
245
+ * is a trap); the inline presentation ignores it, since the host's own toggle is
246
+ * what closes the picker there.
247
+ */
248
+ onClose?: () => void;
249
+ /** Modal heading. */
250
+ title?: string;
251
+ /** How the panes arrange. `auto` (default) stacks below `STACK_BREAKPOINT` of the
252
+ * picker's own width; the explicit values are what stories pin. */
253
+ layout?: TReferencePickerLayout;
254
+ /** Where the picker renders. `auto` (default) goes to a modal on a phone-sized
255
+ * viewport when `onClose` is given, and stays inline otherwise. */
256
+ presentation?: TReferencePickerPresentation;
257
+ }
258
+
259
+ /**
260
+ * Watches an element's own width, because the viewport's is the wrong question for
261
+ * anything that lives inside a composer, a drawer or a side panel — those stay narrow
262
+ * on a 2560px screen. A callback ref rather than `useRef` so the observer attaches the
263
+ * moment the node mounts; a ref that never gets attached silently reports "wide"
264
+ * forever, which is exactly the bug this is meant to catch.
265
+ */
266
+ const useIsNarrow = (enabled: boolean): [(node: HTMLDivElement | null) => void, boolean] => {
267
+ const [node, setNode] = useState<HTMLDivElement | null>(null);
268
+ const [narrow, setNarrow] = useState<boolean>(false);
269
+
270
+ useEffect(() => {
271
+ if (!enabled || !node || typeof ResizeObserver === 'undefined') {
272
+ return undefined;
273
+ }
274
+
275
+ const observer = new ResizeObserver(([entry]) => {
276
+ setNarrow(entry.contentRect.width < STACK_BREAKPOINT);
277
+ });
278
+
279
+ observer.observe(node);
280
+
281
+ return () => observer.disconnect();
282
+ }, [enabled, node]);
283
+
284
+ return [setNode, narrow];
285
+ };
286
+
287
+ /** Phone-sized viewport. Its own media query rather than reqore's `isMobile`, which
288
+ * is pinned to `false` under NODE_ENV=test and so never fires in a story run. */
289
+ const usePhoneViewport = (enabled: boolean): boolean => {
290
+ const [phone, setPhone] = useState<boolean>(false);
291
+
292
+ useEffect(() => {
293
+ if (!enabled || typeof window === 'undefined' || !window.matchMedia) {
294
+ return undefined;
295
+ }
296
+
297
+ const query = window.matchMedia('(max-width: 480px)');
298
+ const sync = () => setPhone(query.matches);
299
+
300
+ sync();
301
+ query.addEventListener('change', sync);
302
+
303
+ return () => query.removeEventListener('change', sync);
304
+ }, [enabled]);
305
+
306
+ return phone;
307
+ };
308
+
309
+ export const ReferencePicker = ({
310
+ kinds,
311
+ kind,
312
+ onKindChange,
313
+ items,
314
+ loading,
315
+ error,
316
+ onRetry,
317
+ picked,
318
+ onAdd,
319
+ onRemove,
320
+ disabled,
321
+ resolveInterfaceIcon = defaultInterfaceIcon,
322
+ resolveKindLabel = defaultInterfaceKindLabel,
323
+ accent = DEFAULT_ACCENT,
324
+ header,
325
+ onClose,
326
+ title = 'Reference interfaces',
327
+ layout = 'auto',
328
+ presentation = 'auto',
329
+ }: IReferencePickerProps) => {
330
+ const [query, setQuery] = useState<string>('');
331
+ const needle = query.trim().toLowerCase();
332
+
333
+ const [frameRef, narrow] = useIsNarrow(layout === 'auto');
334
+ const phone = usePhoneViewport(presentation === 'auto');
335
+
336
+ const asModal = presentation === 'modal' || (presentation === 'auto' && phone && !!onClose);
337
+ const stacked = layout === 'stacked' || (layout === 'auto' && narrow);
338
+ const label = resolveKindLabel(kind);
339
+
340
+ /* A kind matches on its id or its reading name, so "value map" and `value-map`
341
+ * both find it. */
342
+ const matchesKind = useCallback(
343
+ (candidate: string) =>
344
+ !needle ||
345
+ candidate.toLowerCase().includes(needle) ||
346
+ resolveKindLabel(candidate).toLowerCase().includes(needle),
347
+ [needle, resolveKindLabel]
348
+ );
349
+
350
+ /* The matches, plus the selected kind whether or not it matched — it keeps its
351
+ * natural position rather than jumping to the top, so the list a user is reading
352
+ * doesn't reorder under them mid-keystroke. */
353
+ const visibleKinds = useMemo(
354
+ () => kinds.filter((candidate) => candidate === kind || matchesKind(candidate)),
355
+ [kinds, kind, matchesKind]
356
+ );
357
+
358
+ const pickedNames = useMemo(
359
+ () =>
360
+ new Set(
361
+ (picked ?? [])
362
+ .filter((reference) => reference.interface_kind === kind)
363
+ .map((reference) => reference.interface_name)
364
+ ),
365
+ [picked, kind]
366
+ );
367
+
368
+ /** One shape from here down, whichever of the two the host passed. */
369
+ const normalizedItems = useMemo(
370
+ () => items.map((item) => (typeof item === 'string' ? { name: item } : item)),
371
+ [items]
372
+ );
373
+
374
+ /*
375
+ * The interfaces the search leaves standing. When the KIND itself matches
376
+ * ("workflow"), its interfaces all stay — you searched for the kind, so you want to
377
+ * see what's in it. Otherwise the name and the description are both fair game,
378
+ * because both are text the user can see.
379
+ */
380
+ const visibleItems = useMemo(() => {
381
+ const kindMatches = matchesKind(kind);
382
+
383
+ return normalizedItems.filter(
384
+ (item) =>
385
+ !needle ||
386
+ kindMatches ||
387
+ item.name.toLowerCase().includes(needle) ||
388
+ !!item.description?.toLowerCase().includes(needle)
389
+ );
390
+ }, [normalizedItems, kind, needle, matchesKind]);
391
+
392
+ /* Drives the "…but other types do" hint: with the kind list now always on screen,
393
+ * an empty result is only puzzling when the answer is sitting in another row. */
394
+ const otherKindsMatch = useMemo(
395
+ () => !!needle && kinds.some((candidate) => candidate !== kind && matchesKind(candidate)),
396
+ [kinds, kind, needle, matchesKind]
397
+ );
398
+
399
+ const toggle = (name: string) => {
400
+ const reference: IInterfaceReference = { interface_kind: kind, interface_name: name };
401
+
402
+ if (pickedNames.has(name)) {
403
+ onRemove?.(reference);
404
+ } else {
405
+ onAdd(reference);
406
+ }
407
+ };
408
+
409
+ const emptyNote = () => {
410
+ if (!needle) {
411
+ return `No ${label.toLowerCase()} on this instance`;
412
+ }
413
+
414
+ return otherKindsMatch
415
+ ? `No ${label.toLowerCase()} match “${query.trim()}” — other types do`
416
+ : `Nothing matches “${query.trim()}”`;
417
+ };
418
+
419
+ /* Both panes are `ReqoreMenu`s of `ReqoreMenuItem`s — a vertical selectable list is
420
+ exactly what Menu is, so the selection (`selected`), the left-icon + right-icon,
421
+ and the item chrome come from reqore rather than hand-styled buttons. The wrappers
422
+ still own the scroll and the layout; the menus render transparent inside them.
423
+ Only menu items go inside a `ReqoreMenu`: it clones every child with its own props,
424
+ so a spinner or a note nested in one would be handed props it can't take. */
425
+ const kindItems = visibleKinds.map((option) => (
426
+ <ReqoreMenuItem
427
+ key={option}
428
+ className={matchesKind(option) ? undefined : DIMMED_CLASS}
429
+ icon={resolveInterfaceIcon(option)}
430
+ label={resolveKindLabel(option)}
431
+ selected={option === kind}
432
+ disabled={disabled}
433
+ onClick={() => onKindChange(option)}
434
+ />
435
+ ));
436
+
437
+ const interfaces = (() => {
438
+ if (error) {
439
+ return (
440
+ <ReqoreMenu transparent flat padded={false} width='100%' size='small'>
441
+ <ReqoreMenuItem
442
+ icon='ErrorWarningLine'
443
+ rightIcon={onRetry ? 'RefreshLine' : undefined}
444
+ intent='danger'
445
+ label={`Couldn't load ${label.toLowerCase()}`}
446
+ /* the specific failure is the tooltip — the pane states the outcome */
447
+ tooltip={error}
448
+ onClick={onRetry}
449
+ />
450
+ </ReqoreMenu>
451
+ );
452
+ }
453
+
454
+ if (loading) {
455
+ return (
456
+ <ReqoreSpinner iconColor='info' size='small' centered>
457
+ Loading {label.toLowerCase()}…
458
+ </ReqoreSpinner>
459
+ );
460
+ }
461
+
462
+ if (!visibleItems.length) {
463
+ return <Note>{emptyNote()}</Note>;
464
+ }
465
+
466
+ return (
467
+ <ReqoreMenu transparent flat padded={false} width='100%' size='small'>
468
+ {visibleItems.map(({ name, description, badge }) => {
469
+ const isPicked = pickedNames.has(name);
470
+ const removable = isPicked && !!onRemove;
471
+
472
+ return (
473
+ <ReqoreMenuItem
474
+ key={name}
475
+ className={isPicked ? PICKED_CLASS : undefined}
476
+ icon={resolveInterfaceIcon(kind)}
477
+ rightIcon={isPicked ? 'CheckLine' : 'AddLine'}
478
+ label={name}
479
+ description={description}
480
+ badge={badge}
481
+ disabled={disabled}
482
+ tooltip={
483
+ isPicked
484
+ ? removable
485
+ ? `Remove “${name}”`
486
+ : `“${name}” is already referenced`
487
+ : `Reference “${name}”`
488
+ }
489
+ onClick={!isPicked || removable ? () => toggle(name) : undefined}
490
+ {...pickedItemProps(isPicked)}
491
+ />
492
+ );
493
+ })}
494
+ </ReqoreMenu>
495
+ );
496
+ })();
497
+
498
+ const maxHeight = asModal
499
+ ? MODAL_MAX_HEIGHT
500
+ : stacked
501
+ ? STACKED_MAX_HEIGHT
502
+ : COLUMNS_MAX_HEIGHT;
503
+
504
+ /* Stacked: one column, with the selected kind's interfaces spliced in directly
505
+ under its row. A kind the host hasn't listed puts them at the end rather than
506
+ dropping them. */
507
+ const selectedIndex = visibleKinds.indexOf(kind);
508
+ const splitAt = selectedIndex === -1 ? visibleKinds.length : selectedIndex + 1;
509
+
510
+ const body = (
511
+ <Frame ref={frameRef} $bare={asModal}>
512
+ {header}
513
+ <Search $accent={accent} $active={!!needle}>
514
+ <ReqoreInput
515
+ value={query}
516
+ onChange={(event) => setQuery((event.target as HTMLInputElement).value)}
517
+ placeholder='Search types and interfaces…'
518
+ icon='SearchLine'
519
+ minimal
520
+ flat
521
+ transparent
522
+ fluid
523
+ disabled={disabled}
524
+ onClearClick={query ? () => setQuery('') : undefined}
525
+ />
526
+ </Search>
527
+ {stacked ? (
528
+ <Stack $maxHeight={maxHeight}>
529
+ <ReqoreMenu transparent flat padded={false} width='100%' size='small'>
530
+ {kindItems.slice(0, splitAt)}
531
+ </ReqoreMenu>
532
+ <Nested>{interfaces}</Nested>
533
+ {splitAt < kindItems.length ? (
534
+ <ReqoreMenu transparent flat padded={false} width='100%' size='small'>
535
+ {kindItems.slice(splitAt)}
536
+ </ReqoreMenu>
537
+ ) : null}
538
+ </Stack>
539
+ ) : (
540
+ <Panes>
541
+ <Pane $maxHeight={maxHeight}>
542
+ <ReqoreMenu transparent flat padded={false} width='100%' size='small'>
543
+ {kindItems}
544
+ </ReqoreMenu>
545
+ </Pane>
546
+ <Pane $right $maxHeight={maxHeight}>
547
+ {interfaces}
548
+ </Pane>
549
+ </Panes>
550
+ )}
551
+ </Frame>
552
+ );
553
+
554
+ if (!asModal) {
555
+ return body;
556
+ }
557
+
558
+ return (
559
+ <ReqoreModal isOpen icon='LinksLine' label={title} width='100%' blur={3} onClose={onClose}>
560
+ {body}
561
+ </ReqoreModal>
562
+ );
563
+ };
@@ -0,0 +1,121 @@
1
+ import { ReqoreUIProvider } from '@qoretechnologies/reqore';
2
+ import { StoryObj } from '@storybook/react-vite';
3
+ import { expect, fn } from 'storybook/test';
4
+ import { ReactNode } from 'react';
5
+ import { StoryMeta } from '../../types';
6
+ import { ITicketThreadMessage, TicketThread } from '../ticketThread/TicketThread';
7
+ import { InterfaceReferenceTags } from './InterfaceReferenceTags';
8
+ import { TicketReplyBox } from './TicketReplyBox';
9
+
10
+ /**
11
+ * The full ticket surface — the shared `<TicketThread>` conversation above the
12
+ * `<TicketReplyBox>` composer, the way a ticket detail (customer) or the staff
13
+ * drawer stacks them. Shown under the Qorus theme so the `custom1` accent renders.
14
+ */
15
+ const meta = {
16
+ component: TicketReplyBox,
17
+ title: 'Components/TicketConversation',
18
+ args: { onSend: fn() },
19
+ } as StoryMeta<typeof TicketReplyBox>;
20
+
21
+ export default meta;
22
+ type Story = StoryObj<typeof meta>;
23
+
24
+ const CUSTOMER: ITicketThreadMessage = {
25
+ message_id: 'm1',
26
+ author_type: 'customer',
27
+ author_id: 'ops@acme.io',
28
+ body: 'Since upgrading to 3.2 our nightly SFTP transfer to the partner endpoint times out after about 30 seconds. It ran fine on 3.1 with the same connection config.',
29
+ created: '2026-07-16T09:12:00Z',
30
+ referenced_interfaces: [{ interface_kind: 'connection', interface_name: 'sftp-partner' }],
31
+ };
32
+ const STAFF: ITicketThreadMessage = {
33
+ message_id: 'm2',
34
+ author_type: 'staff',
35
+ author_id: 'nick',
36
+ body: "Thanks for the detailed report — we've reproduced the timeout and a fix is in review. In the meantime, can you confirm the datasource pool size configured for the sftp-partner connection?",
37
+ created: '2026-07-16T10:03:00Z',
38
+ };
39
+ const INTERNAL: ITicketThreadMessage = {
40
+ message_id: 'm3',
41
+ author_type: 'staff',
42
+ author_id: 'nick',
43
+ internal: true,
44
+ body: 'Root cause: the connection-pool default silently dropped from 4 to 1 in the 3.2 migration. Patch is in review against develop.',
45
+ created: '2026-07-16T10:05:00Z',
46
+ };
47
+
48
+ const themed = (node: ReactNode) => (
49
+ <ReqoreUIProvider theme={{ main: '#121212', intents: { custom1: '#762f7e' } }}>
50
+ <div style={{ padding: 20, background: '#121212', maxWidth: 780 }}>{node}</div>
51
+ </ReqoreUIProvider>
52
+ );
53
+
54
+ const refs = (
55
+ <InterfaceReferenceTags
56
+ customTheme={{ main: 'custom1' }}
57
+ references={[{ interface_kind: 'connection', interface_name: 'sftp-partner' }]}
58
+ />
59
+ );
60
+
61
+ /**
62
+ * Staff view — the thread with `viewerRole='staff'` (internal notes show, amber)
63
+ * above the staff composer with the split send.
64
+ */
65
+ export const StaffConversation: Story = {
66
+ parameters: {
67
+ docs: {
68
+ description: {
69
+ story:
70
+ "Renders the staff view — the thread with viewerRole='staff' (internal notes visible, amber) stacked above the staff composer with its split send.",
71
+ },
72
+ },
73
+ },
74
+ render: () =>
75
+ themed(
76
+ <>
77
+ <TicketThread viewerRole='staff' messages={[CUSTOMER, STAFF, INTERNAL]} />
78
+ <div style={{ marginTop: 16 }}>
79
+ <TicketReplyBox allowInternalNote onSend={fn()} aboveInput={refs} />
80
+ </div>
81
+ </>
82
+ ),
83
+ async play({ canvasElement }) {
84
+ await expect(canvasElement.textContent).toContain('reproduced the timeout');
85
+ // the internal note is visible to staff
86
+ await expect(canvasElement.textContent).toContain('Root cause');
87
+ // the composer (rich editor) renders below the thread
88
+ await expect(canvasElement.querySelector('[contenteditable="true"]')).not.toBeNull();
89
+ },
90
+ };
91
+
92
+ /**
93
+ * Customer view — the same thread as the customer sees it (`viewerRole='customer'`,
94
+ * staff shown as "Qorus Support", no internal notes) above their reply composer.
95
+ */
96
+ export const CustomerConversation: Story = {
97
+ parameters: {
98
+ docs: {
99
+ description: {
100
+ story:
101
+ "Renders the customer view — the same thread with viewerRole='customer' (staff shown as 'Qorus Support', no internal notes) stacked above the customer's reply composer.",
102
+ },
103
+ },
104
+ },
105
+ render: () =>
106
+ themed(
107
+ <>
108
+ <TicketThread viewerRole='customer' messages={[CUSTOMER, STAFF]} />
109
+ <div style={{ marginTop: 16 }}>
110
+ <TicketReplyBox onSend={fn()} aboveInput={refs} />
111
+ </div>
112
+ </>
113
+ ),
114
+ async play({ canvasElement }) {
115
+ await expect(canvasElement.textContent).toContain('reproduced the timeout');
116
+ // the internal note is not in the customer's messages
117
+ await expect(canvasElement.textContent).not.toContain('Root cause');
118
+ // the composer (rich editor) renders below the thread
119
+ await expect(canvasElement.querySelector('[contenteditable="true"]')).not.toBeNull();
120
+ },
121
+ };