@qoretechnologies/reqraft 0.10.55-pr.124.g77dd26c → 0.10.55

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 (375) hide show
  1. package/.claude/CLAUDE.md +25 -0
  2. package/.tasks/INDEX.md +1 -0
  3. package/.tasks/STORY_NETWORK_ISOLATION.md +98 -0
  4. package/README.md +1 -1
  5. package/design/FORM_ENGINE_COMPACT.md +34 -0
  6. package/design/FORM_ENGINE_EXPRESSIONS.md +110 -0
  7. package/design/FORM_ENGINE_FIELD_MIGRATION.md +155 -1
  8. package/design/IDE_INTEGRATION.md +13 -0
  9. package/design/RENDER_EXPRESSION_TRANSPORT.md +76 -10
  10. package/design/SELECT_DIALOG_FLOOR.md +86 -0
  11. package/design/SMART_EDITOR_UX.md +21 -0
  12. package/design/UNAVAILABLE_ALLOWED_VALUES.md +226 -0
  13. package/dist/components/composer/Composer.d.ts +8 -3
  14. package/dist/components/composer/Composer.d.ts.map +1 -1
  15. package/dist/components/composer/Composer.js.map +1 -1
  16. package/dist/components/dpqlEditor/DpqlEditor.d.ts.map +1 -1
  17. package/dist/components/dpqlEditor/DpqlEditor.js +3 -3
  18. package/dist/components/dpqlEditor/DpqlEditor.js.map +1 -1
  19. package/dist/components/dpqlEditor/dpqlHelpers.d.ts +6 -0
  20. package/dist/components/dpqlEditor/dpqlHelpers.d.ts.map +1 -1
  21. package/dist/components/dpqlEditor/dpqlHelpers.js +21 -2
  22. package/dist/components/dpqlEditor/dpqlHelpers.js.map +1 -1
  23. package/dist/components/dpqlEditor/dpqlProbe.d.ts +37 -0
  24. package/dist/components/dpqlEditor/dpqlProbe.d.ts.map +1 -0
  25. package/dist/components/dpqlEditor/dpqlProbe.js +203 -0
  26. package/dist/components/dpqlEditor/dpqlProbe.js.map +1 -0
  27. package/dist/components/dpqlEditor/dpqlTags.d.ts +8 -0
  28. package/dist/components/dpqlEditor/dpqlTags.d.ts.map +1 -1
  29. package/dist/components/dpqlEditor/dpqlTags.js +5 -1
  30. package/dist/components/dpqlEditor/dpqlTags.js.map +1 -1
  31. package/dist/components/dpqlEditor/index.d.ts +4 -0
  32. package/dist/components/dpqlEditor/index.d.ts.map +1 -1
  33. package/dist/components/dpqlEditor/index.js +5 -1
  34. package/dist/components/dpqlEditor/index.js.map +1 -1
  35. package/dist/components/dpqlEditor/types.d.ts +42 -2
  36. package/dist/components/dpqlEditor/types.d.ts.map +1 -1
  37. package/dist/components/dpqlEditor/types.js +0 -4
  38. package/dist/components/dpqlEditor/types.js.map +1 -1
  39. package/dist/components/dpqlEditor/useDpqlProbe.d.ts +4 -0
  40. package/dist/components/dpqlEditor/useDpqlProbe.d.ts.map +1 -0
  41. package/dist/components/dpqlEditor/useDpqlProbe.js +29 -0
  42. package/dist/components/dpqlEditor/useDpqlProbe.js.map +1 -0
  43. package/dist/components/dpqlEditor/useDpqlSession.d.ts +5 -2
  44. package/dist/components/dpqlEditor/useDpqlSession.d.ts.map +1 -1
  45. package/dist/components/dpqlEditor/useDpqlSession.js +8 -2
  46. package/dist/components/dpqlEditor/useDpqlSession.js.map +1 -1
  47. package/dist/components/form/engine/CompactRow.d.ts.map +1 -1
  48. package/dist/components/form/engine/CompactRow.js +414 -128
  49. package/dist/components/form/engine/CompactRow.js.map +1 -1
  50. package/dist/components/form/engine/CompactToolbar.d.ts.map +1 -1
  51. package/dist/components/form/engine/CompactToolbar.js +5 -2
  52. package/dist/components/form/engine/CompactToolbar.js.map +1 -1
  53. package/dist/components/form/engine/FormEngine.d.ts +273 -22
  54. package/dist/components/form/engine/FormEngine.d.ts.map +1 -1
  55. package/dist/components/form/engine/FormEngine.js +669 -192
  56. package/dist/components/form/engine/FormEngine.js.map +1 -1
  57. package/dist/components/form/engine/FormFieldsSkeleton.d.ts +48 -0
  58. package/dist/components/form/engine/FormFieldsSkeleton.d.ts.map +1 -0
  59. package/dist/components/form/engine/FormFieldsSkeleton.js +41 -0
  60. package/dist/components/form/engine/FormFieldsSkeleton.js.map +1 -0
  61. package/dist/components/form/engine/OptionFieldMessages.d.ts +108 -2
  62. package/dist/components/form/engine/OptionFieldMessages.d.ts.map +1 -1
  63. package/dist/components/form/engine/OptionFieldMessages.js +203 -13
  64. package/dist/components/form/engine/OptionFieldMessages.js.map +1 -1
  65. package/dist/components/form/engine/_structuredData/SchemaDataView.d.ts.map +1 -1
  66. package/dist/components/form/engine/_structuredData/SchemaDataView.js +68 -5
  67. package/dist/components/form/engine/_structuredData/SchemaDataView.js.map +1 -1
  68. package/dist/components/form/engine/compactRowContext.d.ts +15 -1
  69. package/dist/components/form/engine/compactRowContext.d.ts.map +1 -1
  70. package/dist/components/form/engine/compactRowContext.js.map +1 -1
  71. package/dist/components/form/engine/compactRowStyles.d.ts.map +1 -1
  72. package/dist/components/form/engine/compactRowStyles.js +55 -29
  73. package/dist/components/form/engine/compactRowStyles.js.map +1 -1
  74. package/dist/components/form/engine/compactToolbarContext.d.ts +1 -0
  75. package/dist/components/form/engine/compactToolbarContext.d.ts.map +1 -1
  76. package/dist/components/form/engine/optionActions.d.ts +37 -1
  77. package/dist/components/form/engine/optionActions.d.ts.map +1 -1
  78. package/dist/components/form/engine/optionActions.js +71 -1
  79. package/dist/components/form/engine/optionActions.js.map +1 -1
  80. package/dist/components/form/engine/optionsContext.d.ts +22 -0
  81. package/dist/components/form/engine/optionsContext.d.ts.map +1 -0
  82. package/dist/components/form/engine/optionsContext.js +20 -0
  83. package/dist/components/form/engine/optionsContext.js.map +1 -0
  84. package/dist/components/form/engine/readFirst.d.ts +42 -1
  85. package/dist/components/form/engine/readFirst.d.ts.map +1 -1
  86. package/dist/components/form/engine/readFirst.js +76 -8
  87. package/dist/components/form/engine/readFirst.js.map +1 -1
  88. package/dist/components/form/engine/rendererTypes.d.ts +42 -3
  89. package/dist/components/form/engine/rendererTypes.d.ts.map +1 -1
  90. package/dist/components/form/engine/rendererTypes.js +3 -1
  91. package/dist/components/form/engine/rendererTypes.js.map +1 -1
  92. package/dist/components/form/engine/rowFocus.d.ts +30 -0
  93. package/dist/components/form/engine/rowFocus.d.ts.map +1 -0
  94. package/dist/components/form/engine/rowFocus.js +93 -0
  95. package/dist/components/form/engine/rowFocus.js.map +1 -0
  96. package/dist/components/form/engine/rowMenuContext.d.ts +78 -0
  97. package/dist/components/form/engine/rowMenuContext.d.ts.map +1 -0
  98. package/dist/components/form/engine/rowMenuContext.js +103 -0
  99. package/dist/components/form/engine/rowMenuContext.js.map +1 -0
  100. package/dist/components/form/engine/rowOpenPicker.d.ts +27 -0
  101. package/dist/components/form/engine/rowOpenPicker.d.ts.map +1 -0
  102. package/dist/components/form/engine/rowOpenPicker.js +30 -0
  103. package/dist/components/form/engine/rowOpenPicker.js.map +1 -0
  104. package/dist/components/form/engine/typeChoices.d.ts +42 -0
  105. package/dist/components/form/engine/typeChoices.d.ts.map +1 -0
  106. package/dist/components/form/engine/typeChoices.js +33 -0
  107. package/dist/components/form/engine/typeChoices.js.map +1 -0
  108. package/dist/components/form/expressions/DpqlRendering.d.ts +26 -0
  109. package/dist/components/form/expressions/DpqlRendering.d.ts.map +1 -0
  110. package/dist/components/form/expressions/DpqlRendering.js +53 -0
  111. package/dist/components/form/expressions/DpqlRendering.js.map +1 -0
  112. package/dist/components/form/expressions/ExpressionField.d.ts +7 -1
  113. package/dist/components/form/expressions/ExpressionField.d.ts.map +1 -1
  114. package/dist/components/form/expressions/ExpressionField.js +203 -45
  115. package/dist/components/form/expressions/ExpressionField.js.map +1 -1
  116. package/dist/components/form/expressions/argumentPresence.d.ts +84 -0
  117. package/dist/components/form/expressions/argumentPresence.d.ts.map +1 -0
  118. package/dist/components/form/expressions/argumentPresence.js +217 -0
  119. package/dist/components/form/expressions/argumentPresence.js.map +1 -0
  120. package/dist/components/form/expressions/builder/argumentLabel.d.ts.map +1 -1
  121. package/dist/components/form/expressions/builder/argumentLabel.js +9 -4
  122. package/dist/components/form/expressions/builder/argumentLabel.js.map +1 -1
  123. package/dist/components/form/expressions/builder/index.d.ts +15 -2
  124. package/dist/components/form/expressions/builder/index.d.ts.map +1 -1
  125. package/dist/components/form/expressions/builder/index.js +21 -65
  126. package/dist/components/form/expressions/builder/index.js.map +1 -1
  127. package/dist/components/form/expressions/builder/renderTemplate.d.ts +4 -1
  128. package/dist/components/form/expressions/builder/renderTemplate.d.ts.map +1 -1
  129. package/dist/components/form/expressions/builder/renderTemplate.js +10 -67
  130. package/dist/components/form/expressions/builder/renderTemplate.js.map +1 -1
  131. package/dist/components/form/expressions/mockExpressions.d.ts.map +1 -1
  132. package/dist/components/form/expressions/mockExpressions.js +8 -4
  133. package/dist/components/form/expressions/mockExpressions.js.map +1 -1
  134. package/dist/components/form/expressions/renderExpressionToText.d.ts +1 -1
  135. package/dist/components/form/expressions/renderExpressionToText.d.ts.map +1 -1
  136. package/dist/components/form/expressions/renderExpressionToText.js +95 -19
  137. package/dist/components/form/expressions/renderExpressionToText.js.map +1 -1
  138. package/dist/components/form/expressions/types.d.ts +17 -2
  139. package/dist/components/form/expressions/types.d.ts.map +1 -1
  140. package/dist/components/form/expressions/useExpressions.d.ts.map +1 -1
  141. package/dist/components/form/expressions/useExpressions.js +5 -2
  142. package/dist/components/form/expressions/useExpressions.js.map +1 -1
  143. package/dist/components/form/expressions/useRenderExpression.d.ts +7 -16
  144. package/dist/components/form/expressions/useRenderExpression.d.ts.map +1 -1
  145. package/dist/components/form/expressions/useRenderExpression.js +50 -126
  146. package/dist/components/form/expressions/useRenderExpression.js.map +1 -1
  147. package/dist/components/form/fields/Field.d.ts +21 -0
  148. package/dist/components/form/fields/Field.d.ts.map +1 -1
  149. package/dist/components/form/fields/Field.js +54 -8
  150. package/dist/components/form/fields/Field.js.map +1 -1
  151. package/dist/components/form/fields/allowed-values/AllowedValues.d.ts +11 -1
  152. package/dist/components/form/fields/allowed-values/AllowedValues.d.ts.map +1 -1
  153. package/dist/components/form/fields/allowed-values/AllowedValues.js +52 -8
  154. package/dist/components/form/fields/allowed-values/AllowedValues.js.map +1 -1
  155. package/dist/components/form/fields/auto/AutoFormField.d.ts +7 -1
  156. package/dist/components/form/fields/auto/AutoFormField.d.ts.map +1 -1
  157. package/dist/components/form/fields/auto/AutoFormField.js +91 -28
  158. package/dist/components/form/fields/auto/AutoFormField.js.map +1 -1
  159. package/dist/components/form/fields/date/Date.d.ts +1 -1
  160. package/dist/components/form/fields/date/Date.d.ts.map +1 -1
  161. package/dist/components/form/fields/date/Date.js +16 -2
  162. package/dist/components/form/fields/date/Date.js.map +1 -1
  163. package/dist/components/form/fields/long-string/LongString.d.ts.map +1 -1
  164. package/dist/components/form/fields/long-string/LongString.js +14 -2
  165. package/dist/components/form/fields/long-string/LongString.js.map +1 -1
  166. package/dist/components/form/fields/multi-select/MultiSelectFormField.d.ts.map +1 -1
  167. package/dist/components/form/fields/multi-select/MultiSelectFormField.js +50 -4
  168. package/dist/components/form/fields/multi-select/MultiSelectFormField.js.map +1 -1
  169. package/dist/components/form/fields/number/Number.d.ts +12 -1
  170. package/dist/components/form/fields/number/Number.d.ts.map +1 -1
  171. package/dist/components/form/fields/number/Number.js +6 -3
  172. package/dist/components/form/fields/number/Number.js.map +1 -1
  173. package/dist/components/form/fields/rich-text/RichText.d.ts +47 -2
  174. package/dist/components/form/fields/rich-text/RichText.d.ts.map +1 -1
  175. package/dist/components/form/fields/rich-text/RichText.js +153 -12
  176. package/dist/components/form/fields/rich-text/RichText.js.map +1 -1
  177. package/dist/components/form/fields/select/Select.d.ts.map +1 -1
  178. package/dist/components/form/fields/select/Select.js +120 -20
  179. package/dist/components/form/fields/select/Select.js.map +1 -1
  180. package/dist/components/form/fields/select/SelectCollection.d.ts +166 -9
  181. package/dist/components/form/fields/select/SelectCollection.d.ts.map +1 -1
  182. package/dist/components/form/fields/select/SelectCollection.js +200 -7
  183. package/dist/components/form/fields/select/SelectCollection.js.map +1 -1
  184. package/dist/components/form/fields/template/ReadOnlyTemplateTag.d.ts +2 -1
  185. package/dist/components/form/fields/template/ReadOnlyTemplateTag.d.ts.map +1 -1
  186. package/dist/components/form/fields/template/ReadOnlyTemplateTag.js +3 -2
  187. package/dist/components/form/fields/template/ReadOnlyTemplateTag.js.map +1 -1
  188. package/dist/components/form/fields/template/TemplateField.d.ts +34 -2
  189. package/dist/components/form/fields/template/TemplateField.d.ts.map +1 -1
  190. package/dist/components/form/fields/template/TemplateField.js +606 -58
  191. package/dist/components/form/fields/template/TemplateField.js.map +1 -1
  192. package/dist/components/form/fields/template/TemplateText.d.ts +36 -0
  193. package/dist/components/form/fields/template/TemplateText.d.ts.map +1 -0
  194. package/dist/components/form/fields/template/TemplateText.js +80 -0
  195. package/dist/components/form/fields/template/TemplateText.js.map +1 -0
  196. package/dist/components/form/index.d.ts +2 -0
  197. package/dist/components/form/index.d.ts.map +1 -1
  198. package/dist/components/form/index.js +4 -0
  199. package/dist/components/form/index.js.map +1 -1
  200. package/dist/components/smartEditor/SmartEditor.d.ts.map +1 -1
  201. package/dist/components/smartEditor/SmartEditor.js +29 -8
  202. package/dist/components/smartEditor/SmartEditor.js.map +1 -1
  203. package/dist/components/smartEditor/useLspSession.d.ts +5 -1
  204. package/dist/components/smartEditor/useLspSession.d.ts.map +1 -1
  205. package/dist/components/smartEditor/useLspSession.js +16 -2
  206. package/dist/components/smartEditor/useLspSession.js.map +1 -1
  207. package/dist/components/supportTicket/TicketReplyBox.d.ts +8 -4
  208. package/dist/components/supportTicket/TicketReplyBox.d.ts.map +1 -1
  209. package/dist/components/supportTicket/TicketReplyBox.js.map +1 -1
  210. package/dist/helpers/common.d.ts.map +1 -1
  211. package/dist/helpers/common.js +7 -3
  212. package/dist/helpers/common.js.map +1 -1
  213. package/dist/helpers/dpqlDetection.d.ts +58 -0
  214. package/dist/helpers/dpqlDetection.d.ts.map +1 -0
  215. package/dist/helpers/dpqlDetection.js +164 -0
  216. package/dist/helpers/dpqlDetection.js.map +1 -0
  217. package/dist/helpers/optionUiTypes.d.ts +31 -3
  218. package/dist/helpers/optionUiTypes.d.ts.map +1 -1
  219. package/dist/helpers/optionUiTypes.js +36 -1
  220. package/dist/helpers/optionUiTypes.js.map +1 -1
  221. package/dist/helpers/options.d.ts +57 -0
  222. package/dist/helpers/options.d.ts.map +1 -1
  223. package/dist/helpers/options.js +97 -1
  224. package/dist/helpers/options.js.map +1 -1
  225. package/dist/helpers/templateItems.d.ts +47 -0
  226. package/dist/helpers/templateItems.d.ts.map +1 -0
  227. package/dist/helpers/templateItems.js +88 -0
  228. package/dist/helpers/templateItems.js.map +1 -0
  229. package/dist/helpers/templateText.d.ts +80 -0
  230. package/dist/helpers/templateText.d.ts.map +1 -0
  231. package/dist/helpers/templateText.js +291 -0
  232. package/dist/helpers/templateText.js.map +1 -0
  233. package/dist/helpers/templates.d.ts +30 -12
  234. package/dist/helpers/templates.d.ts.map +1 -1
  235. package/dist/helpers/templates.js +91 -33
  236. package/dist/helpers/templates.js.map +1 -1
  237. package/dist/helpers/validations.d.ts +35 -8
  238. package/dist/helpers/validations.d.ts.map +1 -1
  239. package/dist/helpers/validations.js +162 -25
  240. package/dist/helpers/validations.js.map +1 -1
  241. package/dist/hooks/useArgSchema.d.ts +2 -1
  242. package/dist/hooks/useArgSchema.d.ts.map +1 -1
  243. package/dist/hooks/useFetch/useFetch.d.ts +3 -1
  244. package/dist/hooks/useFetch/useFetch.d.ts.map +1 -1
  245. package/dist/hooks/useFetch/useFetch.js +47 -9
  246. package/dist/hooks/useFetch/useFetch.js.map +1 -1
  247. package/dist/hooks/useTemplates.d.ts +20 -0
  248. package/dist/hooks/useTemplates.d.ts.map +1 -1
  249. package/dist/hooks/useTemplates.js +34 -2
  250. package/dist/hooks/useTemplates.js.map +1 -1
  251. package/dist/index.d.ts +2 -1
  252. package/dist/index.d.ts.map +1 -1
  253. package/dist/index.js +5 -1
  254. package/dist/index.js.map +1 -1
  255. package/dist/utils/fetch.d.ts +151 -1
  256. package/dist/utils/fetch.d.ts.map +1 -1
  257. package/dist/utils/fetch.js +256 -44
  258. package/dist/utils/fetch.js.map +1 -1
  259. package/dist/utils/lspClient.d.ts +6 -0
  260. package/dist/utils/lspClient.d.ts.map +1 -1
  261. package/dist/utils/lspClient.js +62 -11
  262. package/dist/utils/lspClient.js.map +1 -1
  263. package/dist/utils/websocket.d.ts +6 -0
  264. package/dist/utils/websocket.d.ts.map +1 -1
  265. package/dist/utils/websocket.js +15 -7
  266. package/dist/utils/websocket.js.map +1 -1
  267. package/package.json +10 -6
  268. package/src/components/composer/Composer.tsx +7 -2
  269. package/src/components/dpqlEditor/DpqlEditor.stories.tsx +3 -119
  270. package/src/components/dpqlEditor/DpqlEditor.tsx +5 -2
  271. package/src/components/dpqlEditor/dpqlHelpers.ts +20 -1
  272. package/src/components/dpqlEditor/dpqlProbe.ts +165 -0
  273. package/src/components/dpqlEditor/dpqlTags.ts +13 -0
  274. package/src/components/dpqlEditor/index.ts +4 -0
  275. package/src/components/dpqlEditor/types.ts +38 -2
  276. package/src/components/dpqlEditor/useDpqlProbe.ts +33 -0
  277. package/src/components/dpqlEditor/useDpqlSession.ts +20 -4
  278. package/src/components/form/engine/CompactRow.tsx +487 -160
  279. package/src/components/form/engine/CompactToolbar.tsx +10 -3
  280. package/src/components/form/engine/FormEngine.stories.tsx +1269 -211
  281. package/src/components/form/engine/FormEngine.tsx +922 -270
  282. package/src/components/form/engine/FormEngineStickyHeaders.stories.tsx +331 -0
  283. package/src/components/form/engine/FormFieldsSkeleton.tsx +77 -0
  284. package/src/components/form/engine/OptionFieldMessages.tsx +300 -14
  285. package/src/components/form/engine/_structuredData/SchemaDataView.tsx +94 -3
  286. package/src/components/form/engine/compactRowContext.ts +15 -6
  287. package/src/components/form/engine/compactRowStyles.ts +56 -2
  288. package/src/components/form/engine/compactToolbarContext.ts +1 -1
  289. package/src/components/form/engine/optionActions.ts +89 -1
  290. package/src/components/form/engine/optionsContext.ts +24 -0
  291. package/src/components/form/engine/readFirst.ts +88 -8
  292. package/src/components/form/engine/rendererTypes.ts +48 -4
  293. package/src/components/form/engine/rowFocus.ts +101 -0
  294. package/src/components/form/engine/rowMenuContext.ts +159 -0
  295. package/src/components/form/engine/rowOpenPicker.ts +27 -0
  296. package/src/components/form/engine/typeChoices.ts +63 -0
  297. package/src/components/form/expressions/DpqlRendering.tsx +85 -0
  298. package/src/components/form/expressions/ExpressionField.stories.tsx +826 -48
  299. package/src/components/form/expressions/ExpressionField.tsx +269 -55
  300. package/src/components/form/expressions/argumentPresence.ts +213 -0
  301. package/src/components/form/expressions/builder/ExpressionBuilder.stories.tsx +38 -21
  302. package/src/components/form/expressions/builder/argumentLabel.tsx +10 -4
  303. package/src/components/form/expressions/builder/index.tsx +39 -81
  304. package/src/components/form/expressions/builder/renderTemplate.tsx +23 -56
  305. package/src/components/form/expressions/dpqlMockLanguage.ts +565 -0
  306. package/src/components/form/expressions/dpqlMockLsp.ts +109 -83
  307. package/src/components/form/expressions/mockExpressions.ts +8 -4
  308. package/src/components/form/expressions/renderExpressionToText.ts +112 -22
  309. package/src/components/form/expressions/types.ts +17 -2
  310. package/src/components/form/expressions/useExpressions.ts +5 -1
  311. package/src/components/form/expressions/useRenderExpression.ts +43 -127
  312. package/src/components/form/fields/Field.tsx +102 -20
  313. package/src/components/form/fields/allowed-values/AllowedValues.tsx +106 -44
  314. package/src/components/form/fields/auto/AutoFormField.stories.tsx +85 -18
  315. package/src/components/form/fields/auto/AutoFormField.tsx +97 -21
  316. package/src/components/form/fields/date/Date.tsx +17 -1
  317. package/src/components/form/fields/long-string/LongString.tsx +15 -3
  318. package/src/components/form/fields/multi-select/MultiSelectFormField.tsx +65 -6
  319. package/src/components/form/fields/number/Number.tsx +25 -0
  320. package/src/components/form/fields/rich-text/RichText.tsx +248 -30
  321. package/src/components/form/fields/select/Select.stories.tsx +392 -0
  322. package/src/components/form/fields/select/Select.tsx +164 -27
  323. package/src/components/form/fields/select/SelectCollection.tsx +350 -6
  324. package/src/components/form/fields/template/ReadOnlyTemplateTag.tsx +4 -2
  325. package/src/components/form/fields/template/TemplateField.stories.tsx +93 -14
  326. package/src/components/form/fields/template/TemplateField.tsx +825 -131
  327. package/src/components/form/fields/template/TemplateText.tsx +115 -0
  328. package/src/components/form/index.tsx +4 -0
  329. package/src/components/log/Log.stories.tsx +2 -1
  330. package/src/components/searchFilterBar/SearchFilterBar.stories.tsx +3 -3
  331. package/src/components/smartEditor/SmartEditor.tsx +41 -9
  332. package/src/components/smartEditor/__fixtures__/mockLspServer.ts +52 -3
  333. package/src/components/smartEditor/useLspSession.ts +21 -3
  334. package/src/components/supportTicket/TicketReplyBox.tsx +8 -4
  335. package/src/components/ticketThread/TicketThread.stories.tsx +1 -0
  336. package/src/helpers/common.ts +7 -3
  337. package/src/helpers/dpqlDetection.ts +209 -0
  338. package/src/helpers/optionUiTypes.ts +38 -0
  339. package/src/helpers/options.ts +96 -0
  340. package/src/helpers/templateItems.ts +81 -0
  341. package/src/helpers/templateText.ts +350 -0
  342. package/src/helpers/templates.ts +94 -41
  343. package/src/helpers/validations.ts +203 -51
  344. package/src/hooks/useFetch/useFetch.stories.tsx +6 -5
  345. package/src/hooks/useFetch/useFetch.tsx +53 -7
  346. package/src/hooks/useStorage/useStorage.stories.tsx +2 -1
  347. package/src/hooks/useTemplates.ts +41 -0
  348. package/src/hooks/useWebSocket/useWebsocket.stories.tsx +2 -1
  349. package/src/index.tsx +14 -1
  350. package/src/stores/currentUser/currentUser.stories.tsx +2 -1
  351. package/src/stories/storyNetwork.ts +92 -0
  352. package/src/utils/fetch.ts +311 -21
  353. package/src/utils/lspClient.ts +68 -11
  354. package/src/utils/websocket.ts +20 -9
  355. package/dist/components/form/engine/__fixtures__/basicFormOptions.d.ts +0 -73
  356. package/dist/components/form/engine/__fixtures__/basicFormOptions.d.ts.map +0 -1
  357. package/dist/components/form/engine/__fixtures__/basicFormOptions.js +0 -317
  358. package/dist/components/form/engine/__fixtures__/basicFormOptions.js.map +0 -1
  359. package/dist/components/form/engine/__fixtures__/fieldChromeOptions.d.ts +0 -41
  360. package/dist/components/form/engine/__fixtures__/fieldChromeOptions.d.ts.map +0 -1
  361. package/dist/components/form/engine/__fixtures__/fieldChromeOptions.js +0 -45
  362. package/dist/components/form/engine/__fixtures__/fieldChromeOptions.js.map +0 -1
  363. package/dist/components/form/expressions/dpqlMockLsp.d.ts +0 -3
  364. package/dist/components/form/expressions/dpqlMockLsp.d.ts.map +0 -1
  365. package/dist/components/form/expressions/dpqlMockLsp.js +0 -91
  366. package/dist/components/form/expressions/dpqlMockLsp.js.map +0 -1
  367. package/dist/components/form/fields/template/__fixtures__/longExampleValue.d.ts +0 -2
  368. package/dist/components/form/fields/template/__fixtures__/longExampleValue.d.ts.map +0 -1
  369. package/dist/components/form/fields/template/__fixtures__/longExampleValue.js +0 -9
  370. package/dist/components/form/fields/template/__fixtures__/longExampleValue.js.map +0 -1
  371. package/dist/components/smartEditor/__fixtures__/mockLspServer.d.ts +0 -55
  372. package/dist/components/smartEditor/__fixtures__/mockLspServer.d.ts.map +0 -1
  373. package/dist/components/smartEditor/__fixtures__/mockLspServer.js +0 -126
  374. package/dist/components/smartEditor/__fixtures__/mockLspServer.js.map +0 -1
  375. package/dist/stories/Data/fileFieldArgSchema.json +0 -86
@@ -0,0 +1,47 @@
1
+ import type { TMarkdownRenderer } from '../components/Description/markdownRendererContext';
2
+ /**
3
+ * What a template picker should actually list.
4
+ *
5
+ * Pickers group templates by category, which is what makes a long catalogue
6
+ * scannable. A LONE category buys nothing and costs a click: the author opens
7
+ * the picker, sees one row naming the category, clicks it, and only then sees
8
+ * the values — with a back arrow as the only other thing on offer. So a single
9
+ * category is opened for them.
10
+ *
11
+ * Two or more categories keep the grouping, because there the headers are doing
12
+ * real work. This only ever removes a step that could not have gone any other
13
+ * way.
14
+ *
15
+ * Lives here rather than beside either picker: `TemplateField` renders the
16
+ * "Select Template" dropdown and `RichText` renders the in-editor `$` list, and
17
+ * `TemplateField` already imports `RichText` — so a shared home is the only one
18
+ * that does not close an import cycle.
19
+ */
20
+ export declare const templateItemsToShow: <T>(items: T[] | undefined) => T[] | undefined;
21
+ /**
22
+ * A picker row's description, DRAWN.
23
+ *
24
+ * A description is prose, and a host that writes prose writes markdown: the
25
+ * same author, in the same dialect, as the field descriptions and schema
26
+ * messages this package already draws through the host's renderer. Left as a
27
+ * string, a row explaining that a step needs a **Fixture Output** printed the
28
+ * asterisks at the reader.
29
+ *
30
+ * WHERE THIS MAY BE CALLED, and why it is not simply done at the source: the
31
+ * template list is a memo KEY in several places — `TemplateField` stringifies
32
+ * both the incoming `templates` and the resolved `filteredTemplates`, and the
33
+ * list is handed down to nested fields that stringify it again. `JSON.stringify`
34
+ * throws on a React element's circular `_owner`, so an element anywhere in the
35
+ * list takes the whole form down to a blank panel.
36
+ *
37
+ * So this runs at the LAST hop only — the call that hands items to a Reqore
38
+ * control, after every key has been computed — and its result is never passed
39
+ * on to anything that might stringify it. Reqore itself does not: it draws the
40
+ * description into a `ReqoreTextEffect` and styled-components filters the prop
41
+ * off the DOM.
42
+ *
43
+ * Without a host renderer the items are returned untouched, so a host that has
44
+ * no markdown keeps exactly what it had.
45
+ */
46
+ export declare const renderTemplateItemDescriptions: <T>(items: T[] | undefined, render: TMarkdownRenderer | undefined) => T[] | undefined;
47
+ //# sourceMappingURL=templateItems.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"templateItems.d.ts","sourceRoot":"","sources":["../../src/helpers/templateItems.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,mDAAmD,CAAC;AAE3F;;;;;;;;;;;;;;;;;GAiBG;AACH,eAAO,MAAM,mBAAmB,aAAe,CAAC,EAAE,GAAG,SAAS,KAAG,CAAC,EAAE,GAAG,SAMtE,CAAC;AAEF;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,eAAO,MAAM,8BAA8B,aAClC,CAAC,EAAE,GAAG,SAAS,UACd,iBAAiB,GAAG,SAAS,KACpC,CAAC,EAAE,GAAG,SAwBR,CAAC"}
@@ -0,0 +1,88 @@
1
+ "use strict";
2
+ var __assign = (this && this.__assign) || function () {
3
+ __assign = Object.assign || function(t) {
4
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
5
+ s = arguments[i];
6
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
7
+ t[p] = s[p];
8
+ }
9
+ return t;
10
+ };
11
+ return __assign.apply(this, arguments);
12
+ };
13
+ Object.defineProperty(exports, "__esModule", { value: true });
14
+ exports.renderTemplateItemDescriptions = exports.templateItemsToShow = void 0;
15
+ /**
16
+ * What a template picker should actually list.
17
+ *
18
+ * Pickers group templates by category, which is what makes a long catalogue
19
+ * scannable. A LONE category buys nothing and costs a click: the author opens
20
+ * the picker, sees one row naming the category, clicks it, and only then sees
21
+ * the values — with a back arrow as the only other thing on offer. So a single
22
+ * category is opened for them.
23
+ *
24
+ * Two or more categories keep the grouping, because there the headers are doing
25
+ * real work. This only ever removes a step that could not have gone any other
26
+ * way.
27
+ *
28
+ * Lives here rather than beside either picker: `TemplateField` renders the
29
+ * "Select Template" dropdown and `RichText` renders the in-editor `$` list, and
30
+ * `TemplateField` already imports `RichText` — so a shared home is the only one
31
+ * that does not close an import cycle.
32
+ */
33
+ var templateItemsToShow = function (items) {
34
+ if ((items === null || items === void 0 ? void 0 : items.length) !== 1) {
35
+ return items;
36
+ }
37
+ var only = items[0];
38
+ return Array.isArray(only.items) && only.items.length ? only.items : items;
39
+ };
40
+ exports.templateItemsToShow = templateItemsToShow;
41
+ /**
42
+ * A picker row's description, DRAWN.
43
+ *
44
+ * A description is prose, and a host that writes prose writes markdown: the
45
+ * same author, in the same dialect, as the field descriptions and schema
46
+ * messages this package already draws through the host's renderer. Left as a
47
+ * string, a row explaining that a step needs a **Fixture Output** printed the
48
+ * asterisks at the reader.
49
+ *
50
+ * WHERE THIS MAY BE CALLED, and why it is not simply done at the source: the
51
+ * template list is a memo KEY in several places — `TemplateField` stringifies
52
+ * both the incoming `templates` and the resolved `filteredTemplates`, and the
53
+ * list is handed down to nested fields that stringify it again. `JSON.stringify`
54
+ * throws on a React element's circular `_owner`, so an element anywhere in the
55
+ * list takes the whole form down to a blank panel.
56
+ *
57
+ * So this runs at the LAST hop only — the call that hands items to a Reqore
58
+ * control, after every key has been computed — and its result is never passed
59
+ * on to anything that might stringify it. Reqore itself does not: it draws the
60
+ * description into a `ReqoreTextEffect` and styled-components filters the prop
61
+ * off the DOM.
62
+ *
63
+ * Without a host renderer the items are returned untouched, so a host that has
64
+ * no markdown keeps exactly what it had.
65
+ */
66
+ var renderTemplateItemDescriptions = function (items, render) {
67
+ if (!render || !(items === null || items === void 0 ? void 0 : items.length)) {
68
+ return items;
69
+ }
70
+ return items.map(function (item) {
71
+ var entry = item;
72
+ var next = __assign({}, entry);
73
+ if (typeof entry.description === 'string' && entry.description.trim()) {
74
+ /* `compact`, for the reason the context gives: a row is a constrained
75
+ container, and markdown authored as a document opens with a heading
76
+ that would outgrow the label above it. */
77
+ next.description = render({ value: entry.description, compact: true });
78
+ }
79
+ // Only when the item HAS children — writing the key unconditionally would
80
+ // give every leaf an `items` a picker could read as an empty submenu.
81
+ if (Array.isArray(entry.items)) {
82
+ next.items = (0, exports.renderTemplateItemDescriptions)(entry.items, render);
83
+ }
84
+ return next;
85
+ });
86
+ };
87
+ exports.renderTemplateItemDescriptions = renderTemplateItemDescriptions;
88
+ //# sourceMappingURL=templateItems.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"templateItems.js","sourceRoot":"","sources":["../../src/helpers/templateItems.ts"],"names":[],"mappings":";;;;;;;;;;;;;;AAEA;;;;;;;;;;;;;;;;;GAiBG;AACI,IAAM,mBAAmB,GAAG,UAAK,KAAsB;IAC5D,IAAI,CAAA,KAAK,aAAL,KAAK,uBAAL,KAAK,CAAE,MAAM,MAAK,CAAC,EAAE,CAAC;QACxB,OAAO,KAAK,CAAC;IACf,CAAC;IACD,IAAM,IAAI,GAAG,KAAK,CAAC,CAAC,CAA0B,CAAC;IAC/C,OAAO,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,CAAE,IAAI,CAAC,KAAa,CAAC,CAAC,CAAC,KAAK,CAAC;AACtF,CAAC,CAAC;AANW,QAAA,mBAAmB,uBAM9B;AAEF;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACI,IAAM,8BAA8B,GAAG,UAC5C,KAAsB,EACtB,MAAqC;IAErC,IAAI,CAAC,MAAM,IAAI,CAAC,CAAA,KAAK,aAAL,KAAK,uBAAL,KAAK,CAAE,MAAM,CAAA,EAAE,CAAC;QAC9B,OAAO,KAAK,CAAC;IACf,CAAC;IAED,OAAO,KAAK,CAAC,GAAG,CAAC,UAAC,IAAI;QACpB,IAAM,KAAK,GAAG,IAAkD,CAAC;QACjE,IAAM,IAAI,GAAG,aAAK,KAAK,CAA6B,CAAC;QAErD,IAAI,OAAO,KAAK,CAAC,WAAW,KAAK,QAAQ,IAAI,KAAK,CAAC,WAAW,CAAC,IAAI,EAAE,EAAE,CAAC;YACtE;;wDAE4C;YAC5C,IAAI,CAAC,WAAW,GAAG,MAAM,CAAC,EAAE,KAAK,EAAE,KAAK,CAAC,WAAW,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC,CAAC;QACzE,CAAC;QAED,0EAA0E;QAC1E,sEAAsE;QACtE,IAAI,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,KAAK,CAAC,EAAE,CAAC;YAC/B,IAAI,CAAC,KAAK,GAAG,IAAA,sCAA8B,EAAC,KAAK,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC;QACnE,CAAC;QAED,OAAO,IAAS,CAAC;IACnB,CAAC,CAAC,CAAC;AACL,CAAC,CAAC;AA3BW,QAAA,8BAA8B,kCA2BzC"}
@@ -0,0 +1,80 @@
1
+ import { IReqoreFormTemplates } from '@qoretechnologies/reqore/dist/components/Textarea';
2
+ import { IRichtextSegment } from './common';
3
+ /** A run of text. */
4
+ export interface ITemplateTextLeaf {
5
+ text: string;
6
+ }
7
+ /** A template reference, drawn as a chip. */
8
+ export interface ITemplateTextTag {
9
+ type: 'tag';
10
+ value: string;
11
+ label: string;
12
+ metadata?: unknown;
13
+ children: ITemplateTextLeaf[];
14
+ }
15
+ /** One line of the string. */
16
+ export interface ITemplateTextParagraph {
17
+ type: 'paragraph';
18
+ children: Array<ITemplateTextLeaf | ITemplateTextTag>;
19
+ }
20
+ /**
21
+ * What a reference chip says: the name the catalogue gives the reference, else
22
+ * the reference as the DPQL Text view labels it (`local: name`), so the same
23
+ * reference reads alike in the Visual builder and the Text view.
24
+ *
25
+ * `getTagLabel` only where the token IS reqraft's grammar. It reads a token as
26
+ * `<key>: <path>` and drops the leading `$`, which is right for `$local:name`
27
+ * and nonsense for a host's own spelling: an unnamed `$._case.mode` came out as
28
+ * `._case.mode`, a string that is neither the reference nor a name for it. With
29
+ * nothing to call it, the reference itself is the honest answer — the same
30
+ * floor `describeTemplateReference` documents.
31
+ */
32
+ export declare const templateChipLabel: (templates: IReqoreFormTemplates | undefined, value: string) => string;
33
+ /**
34
+ * `text` as paragraphs, one per line, with each template reference a chip.
35
+ *
36
+ * A chip is an inline VOID and holds no text of its own, so a cursor can only
37
+ * sit in the text nodes around it; one is kept on each side even when empty.
38
+ * The chip's label is `templateChipLabel`.
39
+ *
40
+ * `tokenGrammar` is the field's own `templateToken`, and it is the reason this
41
+ * takes a third argument at all: without it the editor knew only reqraft's
42
+ * built-in `$key:{path}` and drew a host's own spelling (`$._case.mode`) as raw
43
+ * text, while the collapsed row that opens it — which IS given the grammar —
44
+ * drew the same reference as a named chip. The two surfaces have to recognise
45
+ * the same references, so they resolve them with the same
46
+ * `lineReferenceSpans`.
47
+ */
48
+ export declare const templateTextToNodes: (text: string, templates?: IReqoreFormTemplates, tokenGrammar?: RegExp | string) => ITemplateTextParagraph[];
49
+ /** The string the paragraphs stand for: each chip written as its reference. */
50
+ export declare const templateNodesToText: (nodes?: ReadonlyArray<{
51
+ children?: unknown[];
52
+ }>) => string;
53
+ /**
54
+ * `text` as prose runs and reference chips.
55
+ *
56
+ * The read-only twin of {@link templateTextToNodes}: the editor turns the same
57
+ * string into chips a cursor can move around, this turns it into segments a row
58
+ * can draw. A value is very often a reference INSIDE something the author
59
+ * wrote — `$._case.mode != 'simulate'` — and the comparison is theirs and stays
60
+ * exactly as typed; only the reference becomes a chip.
61
+ *
62
+ * Three ways a reference is recognised, in the order a longer match wins:
63
+ *
64
+ * 1. the grammar the FIELD declares (`templateToken`), which is the only thing
65
+ * that knows the extent of a host's own spelling;
66
+ * 2. reqraft's own token grammar, so `$local:name` embedded in prose is drawn
67
+ * the way the template picker would name it;
68
+ * 3. any value the field's catalogue actually offers, so a host that declares
69
+ * no grammar still gets the references it named drawn as names.
70
+ *
71
+ * Which references are recognised, and how overlaps resolve, is
72
+ * `lineReferenceSpans` — the same answer {@link templateTextToNodes} builds the
73
+ * editor's chips from.
74
+ */
75
+ export declare const templateTextSegments: (text: string, templates?: IReqoreFormTemplates, tokenGrammar?: RegExp | string) => IRichtextSegment[];
76
+ /** Does this text hold a reference at all? The one question a caller asks
77
+ * before deciding whether the chipped rendering applies — answered by the
78
+ * same pass that would draw it, so the two cannot disagree. */
79
+ export declare const hasTemplateText: (text: string, templates?: IReqoreFormTemplates, tokenGrammar?: RegExp | string) => boolean;
80
+ //# sourceMappingURL=templateText.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"templateText.d.ts","sourceRoot":"","sources":["../../src/helpers/templateText.ts"],"names":[],"mappings":"AAQA,OAAO,EAAE,oBAAoB,EAAE,MAAM,mDAAmD,CAAC;AAEzF,OAAO,EAAE,gBAAgB,EAAE,MAAM,UAAU,CAAC;AAO5C,qBAAqB;AACrB,MAAM,WAAW,iBAAiB;IAChC,IAAI,EAAE,MAAM,CAAC;CACd;AAED,6CAA6C;AAC7C,MAAM,WAAW,gBAAgB;IAC/B,IAAI,EAAE,KAAK,CAAC;IACZ,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,QAAQ,EAAE,iBAAiB,EAAE,CAAC;CAC/B;AAED,8BAA8B;AAC9B,MAAM,WAAW,sBAAsB;IACrC,IAAI,EAAE,WAAW,CAAC;IAClB,QAAQ,EAAE,KAAK,CAAC,iBAAiB,GAAG,gBAAgB,CAAC,CAAC;CACvD;AAED;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,iBAAiB,cAAe,oBAAoB,GAAG,SAAS,SAAS,MAAM,KAAG,MAM9F,CAAC;AAqKF;;;;;;;;;;;;;;GAcG;AACH,eAAO,MAAM,mBAAmB,SACxB,MAAM,cACA,oBAAoB,iBACjB,MAAM,GAAG,MAAM,KAC7B,sBAAsB,EAmBrB,CAAC;AAEL,+EAA+E;AAC/E,eAAO,MAAM,mBAAmB,WAAY,cAAc;IAAE,QAAQ,CAAC,EAAE,OAAO,EAAE,CAAA;CAAE,CAAC,KAAG,MAWvE,CAAC;AAMhB;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,eAAO,MAAM,oBAAoB,SACzB,MAAM,cACA,oBAAoB,iBACjB,MAAM,GAAG,MAAM,KAC7B,gBAAgB,EAmClB,CAAC;AAEF;;gEAEgE;AAChE,eAAO,MAAM,eAAe,SACpB,MAAM,cACA,oBAAoB,iBACjB,MAAM,GAAG,MAAM,KAC7B,OAC4F,CAAC"}
@@ -0,0 +1,291 @@
1
+ "use strict";
2
+ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
3
+ if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
4
+ if (ar || !(i in from)) {
5
+ if (!ar) ar = Array.prototype.slice.call(from, 0, i);
6
+ ar[i] = from[i];
7
+ }
8
+ }
9
+ return to.concat(ar || Array.prototype.slice.call(from));
10
+ };
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.hasTemplateText = exports.templateTextSegments = exports.templateNodesToText = exports.templateTextToNodes = exports.templateChipLabel = void 0;
13
+ var dpqlHelpers_1 = require("../components/dpqlEditor/dpqlHelpers");
14
+ var templates_1 = require("./templates");
15
+ /**
16
+ * What a reference chip says: the name the catalogue gives the reference, else
17
+ * the reference as the DPQL Text view labels it (`local: name`), so the same
18
+ * reference reads alike in the Visual builder and the Text view.
19
+ *
20
+ * `getTagLabel` only where the token IS reqraft's grammar. It reads a token as
21
+ * `<key>: <path>` and drops the leading `$`, which is right for `$local:name`
22
+ * and nonsense for a host's own spelling: an unnamed `$._case.mode` came out as
23
+ * `._case.mode`, a string that is neither the reference nor a name for it. With
24
+ * nothing to call it, the reference itself is the honest answer — the same
25
+ * floor `describeTemplateReference` documents.
26
+ */
27
+ var templateChipLabel = function (templates, value) {
28
+ var _a = (0, templates_1.describeTemplateReference)(templates, value), label = _a.label, item = _a.item;
29
+ if (item) {
30
+ return label;
31
+ }
32
+ return value.includes(':') ? (0, dpqlHelpers_1.getTagLabel)(value) : value;
33
+ };
34
+ exports.templateChipLabel = templateChipLabel;
35
+ // ---------------------------------------------------------------------------
36
+ // Finding the references in a string. ONE pass, used by both the editor's
37
+ // document and the read-only row: the two disagreeing about what counts as a
38
+ // reference is the whole defect this file exists to close, and the only way
39
+ // they cannot disagree is by asking the same question of the same code.
40
+ // ---------------------------------------------------------------------------
41
+ /**
42
+ * Every value the catalogue offers, longest first.
43
+ *
44
+ * A host may write its references in a grammar reqraft has never seen — a Qorus
45
+ * test spells one `$._case.mode`, which `TEMPLATE_TOKEN_SOURCE` cannot match
46
+ * because it has no `$key:` at all. Asking the field's own list which strings
47
+ * it NAMES settles that without reqraft guessing at anybody's syntax, and it is
48
+ * the same question the whole-value branch of the read row already asks
49
+ * (`findTemplate`).
50
+ *
51
+ * Longest first so `$.result.status` is recognised before `$.result`, which is
52
+ * a prefix of it; `aliasValues` are included because a catalogue may spell the
53
+ * same reference two ways (see `matchesTemplateValue`).
54
+ */
55
+ /* Keyed on the catalogue's identity, because a form hands the SAME object to
56
+ every row it draws and a row draws on every keystroke elsewhere in the form.
57
+ Walking a 29-item catalogue per row per render is work with one answer. */
58
+ var catalogueValueCache = new WeakMap();
59
+ var catalogueValues = function (templates) {
60
+ if (!templates) {
61
+ return [];
62
+ }
63
+ var cached = catalogueValueCache.get(templates);
64
+ if (cached) {
65
+ return cached;
66
+ }
67
+ var values = new Set();
68
+ var walk = function (items) {
69
+ items === null || items === void 0 ? void 0 : items.forEach(function (item) {
70
+ var _a, _b;
71
+ if (typeof (item === null || item === void 0 ? void 0 : item.value) === 'string' && item.value) {
72
+ values.add(item.value);
73
+ }
74
+ (_b = (_a = item === null || item === void 0 ? void 0 : item.metadata) === null || _a === void 0 ? void 0 : _a.aliasValues) === null || _b === void 0 ? void 0 : _b.forEach(function (alias) {
75
+ if (typeof alias === 'string' && alias) {
76
+ values.add(alias);
77
+ }
78
+ });
79
+ walk(item === null || item === void 0 ? void 0 : item.items);
80
+ });
81
+ };
82
+ walk(templates === null || templates === void 0 ? void 0 : templates.items);
83
+ // `Array.from`, not a spread: this file is emitted by `tsconfig.prod.json`,
84
+ // which targets ES5 and cannot down-level a Set spread without `downlevelIteration`.
85
+ var sorted = Array.from(values).sort(function (a, b) { return b.length - a.length; });
86
+ catalogueValueCache.set(templates, sorted);
87
+ return sorted;
88
+ };
89
+ /**
90
+ * Where a literal catalogue value occurs in `line`, as whole references only.
91
+ *
92
+ * The boundary check is what stops `$.result` being chipped out of the middle
93
+ * of `$.result.status` when the catalogue names only the shorter one: a
94
+ * reference that continues into a further path step is not the reference the
95
+ * catalogue named, and half a path drawn as a name would be a lie about what
96
+ * the value reads.
97
+ */
98
+ var literalSpans = function (line, literal) {
99
+ var spans = [];
100
+ var from = 0;
101
+ for (;;) {
102
+ var start = line.indexOf(literal, from);
103
+ if (start === -1) {
104
+ break;
105
+ }
106
+ var end = start + literal.length;
107
+ var before = start > 0 ? line[start - 1] : '';
108
+ var after = end < line.length ? line[end] : '';
109
+ if (!/[\w$]/.test(before) && !/[\w.[]/.test(after)) {
110
+ spans.push({ start: start, end: end });
111
+ }
112
+ from = start + 1;
113
+ }
114
+ return spans;
115
+ };
116
+ /** Where a grammar matches in `line`. A fresh expression each time: a shared
117
+ * `/g` instance carries `lastIndex` between calls. */
118
+ var patternSpans = function (line, source) {
119
+ var spans = [];
120
+ var pattern = new RegExp(source, 'g');
121
+ var match;
122
+ while ((match = pattern.exec(line)) !== null) {
123
+ if (match[0] === '') {
124
+ pattern.lastIndex += 1;
125
+ continue;
126
+ }
127
+ spans.push({ start: match.index, end: match.index + match[0].length });
128
+ }
129
+ return spans;
130
+ };
131
+ /** A grammar as a source string, however the field declared it. */
132
+ var grammarSource = function (grammar) {
133
+ if (grammar instanceof RegExp) {
134
+ return grammar.source;
135
+ }
136
+ return typeof grammar === 'string' && grammar ? grammar : undefined;
137
+ };
138
+ /**
139
+ * The references one line holds, in order and non-overlapping.
140
+ *
141
+ * Three ways a reference is recognised, in the order a longer match wins:
142
+ *
143
+ * 1. the grammar the FIELD declares (`templateToken`), which is the only thing
144
+ * that knows the extent of a host's own spelling;
145
+ * 2. reqraft's own token grammar, so `$local:name` embedded in prose is drawn
146
+ * the way the template picker would name it;
147
+ * 3. any value the field's catalogue actually offers, so a host that declares
148
+ * no grammar still gets the references it named drawn as names.
149
+ *
150
+ * Overlaps resolve to the longest span starting earliest, so a catalogue entry
151
+ * never carves a shorter name out of a longer reference.
152
+ */
153
+ var lineReferenceSpans = function (line, templates, tokenGrammar) {
154
+ var declared = grammarSource(tokenGrammar);
155
+ var candidates = __spreadArray(__spreadArray(__spreadArray([], (declared ? patternSpans(line, declared) : []), true), patternSpans(line, templates_1.TEMPLATE_TOKEN_SOURCE), true), catalogueValues(templates).flatMap(function (literal) { return literalSpans(line, literal); }), true).sort(function (a, b) { return a.start - b.start || b.end - a.end; });
156
+ var spans = [];
157
+ var cursor = 0;
158
+ candidates.forEach(function (span) {
159
+ if (span.start < cursor) {
160
+ // Already inside a reference that started earlier, or covered by a longer
161
+ // one at the same position — either way it is not its own token.
162
+ return;
163
+ }
164
+ spans.push(span);
165
+ cursor = span.end;
166
+ });
167
+ return spans;
168
+ };
169
+ // ---------------------------------------------------------------------------
170
+ // The string as the EDITOR's document.
171
+ // ---------------------------------------------------------------------------
172
+ /**
173
+ * `text` as paragraphs, one per line, with each template reference a chip.
174
+ *
175
+ * A chip is an inline VOID and holds no text of its own, so a cursor can only
176
+ * sit in the text nodes around it; one is kept on each side even when empty.
177
+ * The chip's label is `templateChipLabel`.
178
+ *
179
+ * `tokenGrammar` is the field's own `templateToken`, and it is the reason this
180
+ * takes a third argument at all: without it the editor knew only reqraft's
181
+ * built-in `$key:{path}` and drew a host's own spelling (`$._case.mode`) as raw
182
+ * text, while the collapsed row that opens it — which IS given the grammar —
183
+ * drew the same reference as a named chip. The two surfaces have to recognise
184
+ * the same references, so they resolve them with the same
185
+ * `lineReferenceSpans`.
186
+ */
187
+ var templateTextToNodes = function (text, templates, tokenGrammar) {
188
+ return (text !== null && text !== void 0 ? text : '').split('\n').map(function (line) {
189
+ var children = [];
190
+ var last = 0;
191
+ lineReferenceSpans(line, templates, tokenGrammar).forEach(function (span) {
192
+ var value = line.slice(span.start, span.end);
193
+ var item = (0, templates_1.describeTemplateReference)(templates, value).item;
194
+ children.push({ text: line.slice(last, span.start) });
195
+ children.push({
196
+ type: 'tag',
197
+ value: value,
198
+ label: (0, exports.templateChipLabel)(templates, value),
199
+ metadata: item === null || item === void 0 ? void 0 : item.metadata,
200
+ children: [{ text: '' }],
201
+ });
202
+ last = span.end;
203
+ });
204
+ children.push({ text: line.slice(last) });
205
+ return { type: 'paragraph', children: children };
206
+ });
207
+ };
208
+ exports.templateTextToNodes = templateTextToNodes;
209
+ /** The string the paragraphs stand for: each chip written as its reference. */
210
+ var templateNodesToText = function (nodes) {
211
+ return (nodes !== null && nodes !== void 0 ? nodes : [])
212
+ .map(function (paragraph) {
213
+ var _a;
214
+ return ((_a = paragraph === null || paragraph === void 0 ? void 0 : paragraph.children) !== null && _a !== void 0 ? _a : [])
215
+ .map(function (node) {
216
+ var _a;
217
+ return typeof (node === null || node === void 0 ? void 0 : node.text) === 'string' ? node.text
218
+ : (node === null || node === void 0 ? void 0 : node.type) === 'tag' ? String((_a = node.value) !== null && _a !== void 0 ? _a : '')
219
+ : '';
220
+ })
221
+ .join('');
222
+ })
223
+ .join('\n');
224
+ };
225
+ exports.templateNodesToText = templateNodesToText;
226
+ // ---------------------------------------------------------------------------
227
+ // The same string, drawn for READING rather than edited.
228
+ // ---------------------------------------------------------------------------
229
+ /**
230
+ * `text` as prose runs and reference chips.
231
+ *
232
+ * The read-only twin of {@link templateTextToNodes}: the editor turns the same
233
+ * string into chips a cursor can move around, this turns it into segments a row
234
+ * can draw. A value is very often a reference INSIDE something the author
235
+ * wrote — `$._case.mode != 'simulate'` — and the comparison is theirs and stays
236
+ * exactly as typed; only the reference becomes a chip.
237
+ *
238
+ * Three ways a reference is recognised, in the order a longer match wins:
239
+ *
240
+ * 1. the grammar the FIELD declares (`templateToken`), which is the only thing
241
+ * that knows the extent of a host's own spelling;
242
+ * 2. reqraft's own token grammar, so `$local:name` embedded in prose is drawn
243
+ * the way the template picker would name it;
244
+ * 3. any value the field's catalogue actually offers, so a host that declares
245
+ * no grammar still gets the references it named drawn as names.
246
+ *
247
+ * Which references are recognised, and how overlaps resolve, is
248
+ * `lineReferenceSpans` — the same answer {@link templateTextToNodes} builds the
249
+ * editor's chips from.
250
+ */
251
+ var templateTextSegments = function (text, templates, tokenGrammar) {
252
+ var source = String(text !== null && text !== void 0 ? text : '');
253
+ if (!source) {
254
+ return [];
255
+ }
256
+ var segments = [];
257
+ var pushText = function (value) {
258
+ if (!value)
259
+ return;
260
+ var last = segments[segments.length - 1];
261
+ if ((last === null || last === void 0 ? void 0 : last.kind) === 'text') {
262
+ last.text += value;
263
+ }
264
+ else {
265
+ segments.push({ kind: 'text', text: value });
266
+ }
267
+ };
268
+ source.split('\n').forEach(function (line, lineIndex) {
269
+ if (lineIndex) {
270
+ pushText('\n');
271
+ }
272
+ var cursor = 0;
273
+ lineReferenceSpans(line, templates, tokenGrammar).forEach(function (span) {
274
+ pushText(line.slice(cursor, span.start));
275
+ var value = line.slice(span.start, span.end);
276
+ segments.push({ kind: 'tag', value: value, text: (0, exports.templateChipLabel)(templates, value) });
277
+ cursor = span.end;
278
+ });
279
+ pushText(line.slice(cursor));
280
+ });
281
+ return segments;
282
+ };
283
+ exports.templateTextSegments = templateTextSegments;
284
+ /** Does this text hold a reference at all? The one question a caller asks
285
+ * before deciding whether the chipped rendering applies — answered by the
286
+ * same pass that would draw it, so the two cannot disagree. */
287
+ var hasTemplateText = function (text, templates, tokenGrammar) {
288
+ return (0, exports.templateTextSegments)(text, templates, tokenGrammar).some(function (segment) { return segment.kind === 'tag'; });
289
+ };
290
+ exports.hasTemplateText = hasTemplateText;
291
+ //# sourceMappingURL=templateText.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"templateText.js","sourceRoot":"","sources":["../../src/helpers/templateText.ts"],"names":[],"mappings":";;;;;;;;;;;;AASA,oEAAmE;AAEnE,yCAA+E;AA0B/E;;;;;;;;;;;GAWG;AACI,IAAM,iBAAiB,GAAG,UAAC,SAA2C,EAAE,KAAa;IACpF,IAAA,KAAkB,IAAA,qCAAyB,EAAC,SAAS,EAAE,KAAK,CAAC,EAA3D,KAAK,WAAA,EAAE,IAAI,UAAgD,CAAC;IACpE,IAAI,IAAI,EAAE,CAAC;QACT,OAAO,KAAK,CAAC;IACf,CAAC;IACD,OAAO,KAAK,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,IAAA,yBAAW,EAAC,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC;AAC1D,CAAC,CAAC;AANW,QAAA,iBAAiB,qBAM5B;AAEF,8EAA8E;AAC9E,0EAA0E;AAC1E,6EAA6E;AAC7E,4EAA4E;AAC5E,wEAAwE;AACxE,8EAA8E;AAE9E;;;;;;;;;;;;;GAaG;AACH;;6EAE6E;AAC7E,IAAM,mBAAmB,GAAG,IAAI,OAA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I,CAAC,KAAK,CAAC,CAAC,CAAC;YACzC,IAAM,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,KAAK,EAAE,IAAI,CAAC,GAAG,CAAC,CAAC;YAC/C,QAAQ,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,KAAK,EAAE,KAAK,OAAA,EAAE,IAAI,EAAE,IAAA,yBAAiB,EAAC,SAAS,EAAE,KAAK,CAAC,EAAE,CAAC,CAAC;YACjF,MAAM,GAAG,IAAI,CAAC,GAAG,CAAC;QACpB,CAAC,CAAC,CAAC;QAEH,QAAQ,CAAC,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC;IAC/B,CAAC,CAAC,CAAC;IAEH,OAAO,QAAQ,CAAC;AAClB,CAAC,CAAC;AAvCW,QAAA,oBAAoB,wBAuC/B;AAEF;;gEAEgE;AACzD,IAAM,eAAe,GAAG,UAC7B,IAAY,EACZ,SAAgC,EAChC,YAA8B;IAE9B,OAAA,IAAA,4BAAoB,EAAC,IAAI,EAAE,SAAS,EAAE,YAAY,CAAC,CAAC,IAAI,CAAC,UAAC,OAAO,IAAK,OAAA,OAAO,CAAC,IAAI,KAAK,KAAK,EAAtB,CAAsB,CAAC;AAA7F,CAA6F,CAAC;AALnF,QAAA,eAAe,mBAKoE"}
@@ -1,3 +1,4 @@
1
+ import { TReqoreTooltipProp } from '@qoretechnologies/reqore/dist/types/global';
1
2
  import { IReqoreFormTemplates } from '@qoretechnologies/reqore/dist/components/Textarea';
2
3
  import { TReqoreDropdownItem } from '@qoretechnologies/reqore/dist/components/Dropdown/list';
3
4
  /**
@@ -62,7 +63,12 @@ export declare const isBracedTemplateToken: (value?: unknown) => value is string
62
63
  *
63
64
  * The match must break at a path boundary (`.` or `[`) so `choicesOther` is
64
65
  * never named after `choices`, and the token keys must agree so a `$config:`
65
- * item never names a `$data:` value.
66
+ * item never names a `$data:` value — "no key" included, so the key-less
67
+ * grammar and the keyed one never name each other's references.
68
+ *
69
+ * Both grammars arrive here: `$data:{create.choices[0]}` and the key-less
70
+ * `$.create.status` are the same question asked in two spellings, and a
71
+ * catalogue written in either one names the walks its author took past it.
66
72
  */
67
73
  export declare const findTemplateByPath: (templates: IReqoreFormTemplates, value: string) => {
68
74
  item: TReqoreDropdownItem;
@@ -90,6 +96,11 @@ export declare const resolveTemplateLabel: (templates: IReqoreFormTemplates | un
90
96
  * never fetches one), and there the raw token is the only thing left to show.
91
97
  * Showing it as `$data:{…}` renders a value as code; showing the path renders
92
98
  * it as a name, which is the honest floor.
99
+ *
100
+ * Only a BRACED wrapper is stripped, because only a braced wrapper is one.
101
+ * A key-less `$._case.mode` stripped of its `$` reads as `._case.mode`, which
102
+ * is neither the reference nor a name for it; with nothing to call it, the
103
+ * reference as written is the honest answer.
93
104
  */
94
105
  export declare const getTemplateReferencePath: (value: string) => string;
95
106
  /**
@@ -103,19 +114,26 @@ export declare const describeTemplateReference: (templates: IReqoreFormTemplates
103
114
  label: string;
104
115
  item?: TReqoreDropdownItem;
105
116
  };
106
- export type TTemplateTextSegment = {
107
- kind: 'text';
108
- text: string;
109
- } | {
110
- kind: 'token';
111
- text: string;
112
- };
113
117
  /**
114
- * Splits prose that embeds template tokens into its literal and token parts —
115
- * `trim("$data:{…}")` becomes `trim("`, the token, `")`. Used to chip the
116
- * references inside a rendered expression instead of printing them raw.
118
+ * What a chosen template's hover should say.
119
+ *
120
+ * The reference itself — `$._case.title`, `$data:{dc_ai_reply.choices[0]…}` —
121
+ * is an implementation detail of the grammar, and it was what every template
122
+ * chip put in its tooltip. An author hovering a chip wants to know WHAT VALUE
123
+ * this is, and the catalogue already carries that: the entry's `description`
124
+ * is the prose the picker lists it under, written from the schema that declares
125
+ * it, with its type appended.
126
+ *
127
+ * So the hover reads as a small card — the value's name as the title, its
128
+ * description as the body — and the path stays where it is genuinely needed:
129
+ * the field's own help, which teaches the grammar with a worked example, and
130
+ * the picker, for the walks no list can hold.
131
+ *
132
+ * Falls back to the resolved label (itself the stripped path when the catalogue
133
+ * explains nothing), because a surface with no catalogue must still say what
134
+ * the value is rather than nothing at all.
117
135
  */
118
- export declare const splitTemplateTokens: (text?: string) => TTemplateTextSegment[];
136
+ export declare const templateTooltip: (templates: IReqoreFormTemplates | undefined, value: string) => TReqoreTooltipProp;
119
137
  export declare const filterTemplatesByType: (templates?: IReqoreFormTemplates, fieldType?: string, hasArgSchema?: boolean) => IReqoreFormTemplates;
120
138
  interface ITemplateItemPayload {
121
139
  display_name?: string;
@@ -1 +1 @@
1
- {"version":3,"file":"templates.d.ts","sourceRoot":"","sources":["../../src/helpers/templates.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,oBAAoB,EAAE,MAAM,mDAAmD,CAAC;AACzF,OAAO,EACL,mBAAmB,EAEpB,MAAM,wDAAwD,CAAC;AAMhE;;;;;;;;GAQG;AACH,eAAO,MAAM,+BAA+B,MAAM,CAAC;AAEnD;;;GAGG;AAEH,MAAM,MAAM,aAAa,GAAG;IAAE,KAAK,CAAC,EAAE,MAAM,CAAC;IAAC,OAAO,CAAC,EAAE,OAAO,CAAC;IAAC,cAAc,CAAC,EAAE,OAAO,CAAA;CAAE,CAAC;AAE5F,eAAO,MAAM,mBAAmB,UACvB,aAAa,KACnB;IAAE,MAAM,EAAE,SAAS,GAAG,MAAM,GAAG,SAAS,CAAA;CAI1C,CAAC;AAEF,eAAO,MAAM,eAAe,UAAW,MAAM,KAAG,OAK/C,CAAC;AAEF,eAAO,MAAM,cAAc,UAAW,MAAM,KAAG,MAG9C,CAAC;AAEF,eAAO,MAAM,gBAAgB,UAAW,MAAM,KAAG,MAGhD,CAAC;AAEF;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,qBAAqB,8DAC2B,CAAC;AAI9D;;+DAE+D;AAC/D,eAAO,MAAM,uBAAuB,WAAY,OAAO,oBACW,CAAC;AAEnE;;;;;2EAK2E;AAC3E,eAAO,MAAM,qBAAqB,WAAY,OAAO,oBACG,CAAC;AA6BzD;;;;;;;;;;;;;;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