@health-samurai/react-components 0.0.0-alpha.2 → 0.0.0-alpha.21

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 (571) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +102 -1
  3. package/dist/bundle.css +2349 -754
  4. package/dist/src/components/button-dropdown.d.ts +10 -0
  5. package/dist/src/components/button-dropdown.d.ts.map +1 -0
  6. package/dist/src/components/button-dropdown.js +70 -0
  7. package/dist/src/components/button-dropdown.js.map +1 -0
  8. package/dist/src/components/button-dropdown.stories.js +48 -0
  9. package/dist/src/components/button-dropdown.stories.js.map +1 -0
  10. package/dist/src/components/code-editor/fhir-autocomplete.d.ts +70 -0
  11. package/dist/src/components/code-editor/fhir-autocomplete.d.ts.map +1 -0
  12. package/dist/src/components/code-editor/fhir-autocomplete.js +1850 -0
  13. package/dist/src/components/code-editor/fhir-autocomplete.js.map +1 -0
  14. package/dist/src/components/code-editor/fhir-autocomplete.test.js +1099 -0
  15. package/dist/src/components/code-editor/fhir-autocomplete.test.js.map +1 -0
  16. package/dist/src/components/code-editor/http/grammar/http.d.ts +3 -0
  17. package/dist/src/components/code-editor/http/grammar/http.d.ts.map +1 -0
  18. package/dist/src/components/code-editor/http/grammar/http.grammar +74 -0
  19. package/dist/src/components/code-editor/http/grammar/http.js +38 -0
  20. package/dist/src/components/code-editor/http/grammar/http.js.map +1 -0
  21. package/dist/src/components/code-editor/http/grammar/http.terms.d.ts +2 -0
  22. package/dist/src/components/code-editor/http/grammar/http.terms.d.ts.map +1 -0
  23. package/dist/src/components/code-editor/http/grammar/http.terms.js +4 -0
  24. package/dist/src/components/code-editor/http/grammar/http.terms.js.map +1 -0
  25. package/dist/src/components/code-editor/http/grammar/http.test.js +80 -0
  26. package/dist/src/components/code-editor/http/grammar/http.test.js.map +1 -0
  27. package/dist/src/components/code-editor/http/index.d.ts +12 -0
  28. package/dist/src/components/code-editor/http/index.d.ts.map +1 -0
  29. package/dist/src/components/code-editor/http/index.js +486 -0
  30. package/dist/src/components/code-editor/http/index.js.map +1 -0
  31. package/dist/src/components/code-editor/index.d.ts +39 -1
  32. package/dist/src/components/code-editor/index.d.ts.map +1 -1
  33. package/dist/src/components/code-editor/index.js +1792 -45
  34. package/dist/src/components/code-editor/index.js.map +1 -1
  35. package/dist/src/components/code-editor/json-ast.d.ts +46 -0
  36. package/dist/src/components/code-editor/json-ast.d.ts.map +1 -0
  37. package/dist/src/components/code-editor/json-ast.js +465 -0
  38. package/dist/src/components/code-editor/json-ast.js.map +1 -0
  39. package/dist/src/components/code-editor/json-ast.test.js +206 -0
  40. package/dist/src/components/code-editor/json-ast.test.js.map +1 -0
  41. package/dist/src/components/code-editor/sql-completion.d.ts +22 -0
  42. package/dist/src/components/code-editor/sql-completion.d.ts.map +1 -0
  43. package/dist/src/components/code-editor/sql-completion.js +897 -0
  44. package/dist/src/components/code-editor/sql-completion.js.map +1 -0
  45. package/dist/src/components/code-editor.stories.js +280 -3
  46. package/dist/src/components/code-editor.stories.js.map +1 -1
  47. package/dist/src/components/copy-icon.d.ts +5 -1
  48. package/dist/src/components/copy-icon.d.ts.map +1 -1
  49. package/dist/src/components/copy-icon.js +41 -3
  50. package/dist/src/components/copy-icon.js.map +1 -1
  51. package/dist/src/components/data-table.d.ts +9 -0
  52. package/dist/src/components/data-table.d.ts.map +1 -0
  53. package/dist/src/components/data-table.js +66 -0
  54. package/dist/src/components/data-table.js.map +1 -0
  55. package/dist/src/components/data-table.stories.js +240 -0
  56. package/dist/src/components/data-table.stories.js.map +1 -0
  57. package/dist/src/components/date-picker-input.d.ts +10 -0
  58. package/dist/src/components/date-picker-input.d.ts.map +1 -0
  59. package/dist/src/components/date-picker-input.js +90 -0
  60. package/dist/src/components/date-picker-input.js.map +1 -0
  61. package/dist/src/components/date-picker-input.stories.js +76 -0
  62. package/dist/src/components/date-picker-input.stories.js.map +1 -0
  63. package/dist/src/components/fhir-structure-view.d.ts +34 -0
  64. package/dist/src/components/fhir-structure-view.d.ts.map +1 -0
  65. package/dist/src/components/fhir-structure-view.js +230 -0
  66. package/dist/src/components/fhir-structure-view.js.map +1 -0
  67. package/dist/src/components/fhir-structure-view.stories.js +447 -0
  68. package/dist/src/components/fhir-structure-view.stories.js.map +1 -0
  69. package/dist/src/components/icon-button.d.ts +12 -0
  70. package/dist/src/components/icon-button.d.ts.map +1 -0
  71. package/dist/src/components/icon-button.js +41 -0
  72. package/dist/src/components/icon-button.js.map +1 -0
  73. package/dist/src/components/icon-button.stories.js +157 -0
  74. package/dist/src/components/icon-button.stories.js.map +1 -0
  75. package/dist/src/components/operation-outcome-view.d.ts +27 -0
  76. package/dist/src/components/operation-outcome-view.d.ts.map +1 -0
  77. package/dist/src/components/operation-outcome-view.js +198 -0
  78. package/dist/src/components/operation-outcome-view.js.map +1 -0
  79. package/dist/src/components/operation-outcome-view.stories.js +207 -0
  80. package/dist/src/components/operation-outcome-view.stories.js.map +1 -0
  81. package/dist/src/components/request-line-editor.d.ts +13 -35
  82. package/dist/src/components/request-line-editor.d.ts.map +1 -1
  83. package/dist/src/components/request-line-editor.js +73 -49
  84. package/dist/src/components/request-line-editor.js.map +1 -1
  85. package/dist/src/components/request-line-editor.stories.js +17 -53
  86. package/dist/src/components/request-line-editor.stories.js.map +1 -1
  87. package/dist/src/components/sandbox.d.ts +13 -0
  88. package/dist/src/components/sandbox.d.ts.map +1 -0
  89. package/dist/src/components/sandbox.js +107 -0
  90. package/dist/src/components/sandbox.js.map +1 -0
  91. package/dist/src/components/sandbox.stories.js +126 -0
  92. package/dist/src/components/sandbox.stories.js.map +1 -0
  93. package/dist/src/components/segment-control.d.ts +13 -0
  94. package/dist/src/components/segment-control.d.ts.map +1 -0
  95. package/dist/src/components/segment-control.js +33 -0
  96. package/dist/src/components/segment-control.js.map +1 -0
  97. package/dist/src/components/segment-control.stories.js +68 -0
  98. package/dist/src/components/segment-control.stories.js.map +1 -0
  99. package/dist/src/components/split-button.d.ts +12 -0
  100. package/dist/src/components/split-button.d.ts.map +1 -0
  101. package/dist/src/components/split-button.js +33 -0
  102. package/dist/src/components/split-button.js.map +1 -0
  103. package/dist/src/components/split-button.stories.js +84 -0
  104. package/dist/src/components/split-button.stories.js.map +1 -0
  105. package/dist/src/components/tag.d.ts +16 -0
  106. package/dist/src/components/tag.d.ts.map +1 -0
  107. package/dist/src/components/tag.js +198 -0
  108. package/dist/src/components/tag.js.map +1 -0
  109. package/dist/src/components/tag.stories.js +459 -0
  110. package/dist/src/components/tag.stories.js.map +1 -0
  111. package/dist/src/components/tile.d.ts +15 -0
  112. package/dist/src/components/tile.d.ts.map +1 -0
  113. package/dist/src/components/tile.js +76 -0
  114. package/dist/src/components/tile.js.map +1 -0
  115. package/dist/src/components/tile.stories.js +167 -0
  116. package/dist/src/components/tile.stories.js.map +1 -0
  117. package/dist/src/components/toolbar.d.ts +18 -0
  118. package/dist/src/components/toolbar.d.ts.map +1 -0
  119. package/dist/src/components/toolbar.js +61 -0
  120. package/dist/src/components/toolbar.js.map +1 -0
  121. package/dist/src/components/toolbar.stories.js +69 -0
  122. package/dist/src/components/toolbar.stories.js.map +1 -0
  123. package/dist/src/components/tree-view.d.ts +47 -0
  124. package/dist/src/components/tree-view.d.ts.map +1 -0
  125. package/dist/src/components/tree-view.js +122 -0
  126. package/dist/src/components/tree-view.js.map +1 -0
  127. package/dist/src/components/tree-view.stories.js +283 -0
  128. package/dist/src/components/tree-view.stories.js.map +1 -0
  129. package/dist/src/icons.d.ts +11 -0
  130. package/dist/src/icons.d.ts.map +1 -0
  131. package/dist/src/icons.js +328 -0
  132. package/dist/src/icons.js.map +1 -0
  133. package/dist/src/index.css +358 -74
  134. package/dist/src/index.d.ts +17 -1
  135. package/dist/src/index.d.ts.map +1 -1
  136. package/dist/src/index.js +17 -1
  137. package/dist/src/index.js.map +1 -1
  138. package/dist/src/shadcn/components/ui/accordion.d.ts +2 -2
  139. package/dist/src/shadcn/components/ui/accordion.d.ts.map +1 -1
  140. package/dist/src/shadcn/components/ui/accordion.js +35 -9
  141. package/dist/src/shadcn/components/ui/accordion.js.map +1 -1
  142. package/dist/src/shadcn/components/ui/alert-dialog.d.ts +12 -4
  143. package/dist/src/shadcn/components/ui/alert-dialog.d.ts.map +1 -1
  144. package/dist/src/shadcn/components/ui/alert-dialog.js +128 -18
  145. package/dist/src/shadcn/components/ui/alert-dialog.js.map +1 -1
  146. package/dist/src/shadcn/components/ui/alert-dialog.stories.js +269 -19
  147. package/dist/src/shadcn/components/ui/alert-dialog.stories.js.map +1 -1
  148. package/dist/src/shadcn/components/ui/alert.d.ts +29 -6
  149. package/dist/src/shadcn/components/ui/alert.d.ts.map +1 -1
  150. package/dist/src/shadcn/components/ui/alert.js +50 -19
  151. package/dist/src/shadcn/components/ui/alert.js.map +1 -1
  152. package/dist/src/shadcn/components/ui/alert.stories.js +140 -36
  153. package/dist/src/shadcn/components/ui/alert.stories.js.map +1 -1
  154. package/dist/src/shadcn/components/ui/aspect-ratio.d.ts.map +1 -1
  155. package/dist/src/shadcn/components/ui/aspect-ratio.js +1 -0
  156. package/dist/src/shadcn/components/ui/aspect-ratio.js.map +1 -1
  157. package/dist/src/shadcn/components/ui/avatar.d.ts.map +1 -1
  158. package/dist/src/shadcn/components/ui/avatar.js +4 -3
  159. package/dist/src/shadcn/components/ui/avatar.js.map +1 -1
  160. package/dist/src/shadcn/components/ui/avatar.stories.js +68 -2
  161. package/dist/src/shadcn/components/ui/avatar.stories.js.map +1 -1
  162. package/dist/src/shadcn/components/ui/badge.d.ts +1 -1
  163. package/dist/src/shadcn/components/ui/badge.d.ts.map +1 -1
  164. package/dist/src/shadcn/components/ui/badge.js +16 -5
  165. package/dist/src/shadcn/components/ui/badge.js.map +1 -1
  166. package/dist/src/shadcn/components/ui/breadcrumb.d.ts +5 -2
  167. package/dist/src/shadcn/components/ui/breadcrumb.d.ts.map +1 -1
  168. package/dist/src/shadcn/components/ui/breadcrumb.js +98 -13
  169. package/dist/src/shadcn/components/ui/breadcrumb.js.map +1 -1
  170. package/dist/src/shadcn/components/ui/breadcrumb.stories.js +205 -45
  171. package/dist/src/shadcn/components/ui/breadcrumb.stories.js.map +1 -1
  172. package/dist/src/shadcn/components/ui/button.d.ts.map +1 -1
  173. package/dist/src/shadcn/components/ui/button.js +65 -11
  174. package/dist/src/shadcn/components/ui/button.js.map +1 -1
  175. package/dist/src/shadcn/components/ui/button.stories.js +99 -17
  176. package/dist/src/shadcn/components/ui/button.stories.js.map +1 -1
  177. package/dist/src/shadcn/components/ui/calendar.d.ts +1 -1
  178. package/dist/src/shadcn/components/ui/calendar.d.ts.map +1 -1
  179. package/dist/src/shadcn/components/ui/calendar.js +1 -0
  180. package/dist/src/shadcn/components/ui/calendar.js.map +1 -1
  181. package/dist/src/shadcn/components/ui/card.d.ts +5 -1
  182. package/dist/src/shadcn/components/ui/card.d.ts.map +1 -1
  183. package/dist/src/shadcn/components/ui/card.js +28 -7
  184. package/dist/src/shadcn/components/ui/card.js.map +1 -1
  185. package/dist/src/shadcn/components/ui/card.stories.js +23 -2
  186. package/dist/src/shadcn/components/ui/card.stories.js.map +1 -1
  187. package/dist/src/shadcn/components/ui/carousel.d.ts +1 -1
  188. package/dist/src/shadcn/components/ui/carousel.d.ts.map +1 -1
  189. package/dist/src/shadcn/components/ui/carousel.js +1 -0
  190. package/dist/src/shadcn/components/ui/carousel.js.map +1 -1
  191. package/dist/src/shadcn/components/ui/chart.d.ts +5 -5
  192. package/dist/src/shadcn/components/ui/chart.d.ts.map +1 -1
  193. package/dist/src/shadcn/components/ui/chart.js +4 -3
  194. package/dist/src/shadcn/components/ui/chart.js.map +1 -1
  195. package/dist/src/shadcn/components/ui/checkbox.d.ts +5 -1
  196. package/dist/src/shadcn/components/ui/checkbox.d.ts.map +1 -1
  197. package/dist/src/shadcn/components/ui/checkbox.js +46 -6
  198. package/dist/src/shadcn/components/ui/checkbox.js.map +1 -1
  199. package/dist/src/shadcn/components/ui/checkbox.stories.js +156 -46
  200. package/dist/src/shadcn/components/ui/checkbox.stories.js.map +1 -1
  201. package/dist/src/shadcn/components/ui/combobox.d.ts +29 -0
  202. package/dist/src/shadcn/components/ui/combobox.d.ts.map +1 -0
  203. package/dist/src/shadcn/components/ui/combobox.js +226 -0
  204. package/dist/src/shadcn/components/ui/combobox.js.map +1 -0
  205. package/dist/src/shadcn/components/ui/combobox.stories.js +167 -0
  206. package/dist/src/shadcn/components/ui/combobox.stories.js.map +1 -0
  207. package/dist/src/shadcn/components/ui/command.d.ts +4 -2
  208. package/dist/src/shadcn/components/ui/command.d.ts.map +1 -1
  209. package/dist/src/shadcn/components/ui/command.js +75 -13
  210. package/dist/src/shadcn/components/ui/command.js.map +1 -1
  211. package/dist/src/shadcn/components/ui/command.stories.js +277 -57
  212. package/dist/src/shadcn/components/ui/command.stories.js.map +1 -1
  213. package/dist/src/shadcn/components/ui/context-menu.d.ts +7 -3
  214. package/dist/src/shadcn/components/ui/context-menu.d.ts.map +1 -1
  215. package/dist/src/shadcn/components/ui/context-menu.js +120 -13
  216. package/dist/src/shadcn/components/ui/context-menu.js.map +1 -1
  217. package/dist/src/shadcn/components/ui/dialog.d.ts.map +1 -1
  218. package/dist/src/shadcn/components/ui/dialog.js +35 -7
  219. package/dist/src/shadcn/components/ui/dialog.js.map +1 -1
  220. package/dist/src/shadcn/components/ui/drawer.d.ts.map +1 -1
  221. package/dist/src/shadcn/components/ui/drawer.js +27 -5
  222. package/dist/src/shadcn/components/ui/drawer.js.map +1 -1
  223. package/dist/src/shadcn/components/ui/dropdown-menu.d.ts +7 -3
  224. package/dist/src/shadcn/components/ui/dropdown-menu.d.ts.map +1 -1
  225. package/dist/src/shadcn/components/ui/dropdown-menu.js +122 -14
  226. package/dist/src/shadcn/components/ui/dropdown-menu.js.map +1 -1
  227. package/dist/src/shadcn/components/ui/dropdown-menu.stories.js +22 -5
  228. package/dist/src/shadcn/components/ui/dropdown-menu.stories.js.map +1 -1
  229. package/dist/src/shadcn/components/ui/form.d.ts +2 -2
  230. package/dist/src/shadcn/components/ui/form.d.ts.map +1 -1
  231. package/dist/src/shadcn/components/ui/form.js +17 -8
  232. package/dist/src/shadcn/components/ui/form.js.map +1 -1
  233. package/dist/src/shadcn/components/ui/hover-card.d.ts.map +1 -1
  234. package/dist/src/shadcn/components/ui/hover-card.js +2 -1
  235. package/dist/src/shadcn/components/ui/hover-card.js.map +1 -1
  236. package/dist/src/shadcn/components/ui/input-otp.d.ts.map +1 -1
  237. package/dist/src/shadcn/components/ui/input-otp.js +1 -0
  238. package/dist/src/shadcn/components/ui/input-otp.js.map +1 -1
  239. package/dist/src/shadcn/components/ui/input.d.ts +3 -1
  240. package/dist/src/shadcn/components/ui/input.d.ts.map +1 -1
  241. package/dist/src/shadcn/components/ui/input.js +126 -17
  242. package/dist/src/shadcn/components/ui/input.js.map +1 -1
  243. package/dist/src/shadcn/components/ui/input.stories.js +218 -29
  244. package/dist/src/shadcn/components/ui/input.stories.js.map +1 -1
  245. package/dist/src/shadcn/components/ui/label.d.ts.map +1 -1
  246. package/dist/src/shadcn/components/ui/label.js +9 -1
  247. package/dist/src/shadcn/components/ui/label.js.map +1 -1
  248. package/dist/src/shadcn/components/ui/menubar.d.ts.map +1 -1
  249. package/dist/src/shadcn/components/ui/menubar.js +35 -13
  250. package/dist/src/shadcn/components/ui/menubar.js.map +1 -1
  251. package/dist/src/shadcn/components/ui/pagination.d.ts +9 -2
  252. package/dist/src/shadcn/components/ui/pagination.d.ts.map +1 -1
  253. package/dist/src/shadcn/components/ui/pagination.js +41 -24
  254. package/dist/src/shadcn/components/ui/pagination.js.map +1 -1
  255. package/dist/src/shadcn/components/ui/pagination.stories.js +44 -37
  256. package/dist/src/shadcn/components/ui/pagination.stories.js.map +1 -1
  257. package/dist/src/shadcn/components/ui/popover.d.ts.map +1 -1
  258. package/dist/src/shadcn/components/ui/popover.js +13 -1
  259. package/dist/src/shadcn/components/ui/popover.js.map +1 -1
  260. package/dist/src/shadcn/components/ui/progress.d.ts.map +1 -1
  261. package/dist/src/shadcn/components/ui/progress.js +6 -2
  262. package/dist/src/shadcn/components/ui/progress.js.map +1 -1
  263. package/dist/src/shadcn/components/ui/radio-button-group.d.ts +21 -0
  264. package/dist/src/shadcn/components/ui/radio-button-group.d.ts.map +1 -0
  265. package/dist/src/shadcn/components/ui/radio-button-group.js +148 -0
  266. package/dist/src/shadcn/components/ui/radio-button-group.js.map +1 -0
  267. package/dist/src/shadcn/components/ui/radio-button-group.stories.js +283 -0
  268. package/dist/src/shadcn/components/ui/radio-button-group.stories.js.map +1 -0
  269. package/dist/src/shadcn/components/ui/radio-group.d.ts +5 -1
  270. package/dist/src/shadcn/components/ui/radio-group.d.ts.map +1 -1
  271. package/dist/src/shadcn/components/ui/radio-group.js +40 -7
  272. package/dist/src/shadcn/components/ui/radio-group.js.map +1 -1
  273. package/dist/src/shadcn/components/ui/radio-group.stories.js +107 -32
  274. package/dist/src/shadcn/components/ui/radio-group.stories.js.map +1 -1
  275. package/dist/src/shadcn/components/ui/resizable.d.ts.map +1 -1
  276. package/dist/src/shadcn/components/ui/resizable.js +2 -1
  277. package/dist/src/shadcn/components/ui/resizable.js.map +1 -1
  278. package/dist/src/shadcn/components/ui/resizable.stories.js +2 -2
  279. package/dist/src/shadcn/components/ui/resizable.stories.js.map +1 -1
  280. package/dist/src/shadcn/components/ui/scroll-area.d.ts.map +1 -1
  281. package/dist/src/shadcn/components/ui/scroll-area.js +10 -3
  282. package/dist/src/shadcn/components/ui/scroll-area.js.map +1 -1
  283. package/dist/src/shadcn/components/ui/select.d.ts +1 -2
  284. package/dist/src/shadcn/components/ui/select.d.ts.map +1 -1
  285. package/dist/src/shadcn/components/ui/select.js +49 -19
  286. package/dist/src/shadcn/components/ui/select.js.map +1 -1
  287. package/dist/src/shadcn/components/ui/select.stories.js +193 -70
  288. package/dist/src/shadcn/components/ui/select.stories.js.map +1 -1
  289. package/dist/src/shadcn/components/ui/separator.d.ts.map +1 -1
  290. package/dist/src/shadcn/components/ui/separator.js +8 -1
  291. package/dist/src/shadcn/components/ui/separator.js.map +1 -1
  292. package/dist/src/shadcn/components/ui/sheet.js +1 -1
  293. package/dist/src/shadcn/components/ui/sheet.js.map +1 -1
  294. package/dist/src/shadcn/components/ui/sidebar.d.ts +4 -4
  295. package/dist/src/shadcn/components/ui/sidebar.d.ts.map +1 -1
  296. package/dist/src/shadcn/components/ui/sidebar.js +21 -6
  297. package/dist/src/shadcn/components/ui/sidebar.js.map +1 -1
  298. package/dist/src/shadcn/components/ui/skeleton.d.ts.map +1 -1
  299. package/dist/src/shadcn/components/ui/skeleton.js +3 -1
  300. package/dist/src/shadcn/components/ui/skeleton.js.map +1 -1
  301. package/dist/src/shadcn/components/ui/slider.d.ts.map +1 -1
  302. package/dist/src/shadcn/components/ui/slider.js +35 -4
  303. package/dist/src/shadcn/components/ui/slider.js.map +1 -1
  304. package/dist/src/shadcn/components/ui/sonner.d.ts +24 -2
  305. package/dist/src/shadcn/components/ui/sonner.d.ts.map +1 -1
  306. package/dist/src/shadcn/components/ui/sonner.js +127 -9
  307. package/dist/src/shadcn/components/ui/sonner.js.map +1 -1
  308. package/dist/src/shadcn/components/ui/sonner.stories.js +251 -12
  309. package/dist/src/shadcn/components/ui/sonner.stories.js.map +1 -1
  310. package/dist/src/shadcn/components/ui/switch.d.ts +7 -1
  311. package/dist/src/shadcn/components/ui/switch.d.ts.map +1 -1
  312. package/dist/src/shadcn/components/ui/switch.js +55 -3
  313. package/dist/src/shadcn/components/ui/switch.js.map +1 -1
  314. package/dist/src/shadcn/components/ui/switch.stories.js +84 -9
  315. package/dist/src/shadcn/components/ui/switch.stories.js.map +1 -1
  316. package/dist/src/shadcn/components/ui/table.d.ts +23 -6
  317. package/dist/src/shadcn/components/ui/table.d.ts.map +1 -1
  318. package/dist/src/shadcn/components/ui/table.js +65 -20
  319. package/dist/src/shadcn/components/ui/table.js.map +1 -1
  320. package/dist/src/shadcn/components/ui/table.stories.js +217 -97
  321. package/dist/src/shadcn/components/ui/table.stories.js.map +1 -1
  322. package/dist/src/shadcn/components/ui/tabs.d.ts +30 -5
  323. package/dist/src/shadcn/components/ui/tabs.d.ts.map +1 -1
  324. package/dist/src/shadcn/components/ui/tabs.js +470 -23
  325. package/dist/src/shadcn/components/ui/tabs.js.map +1 -1
  326. package/dist/src/shadcn/components/ui/tabs.stories.js +405 -181
  327. package/dist/src/shadcn/components/ui/tabs.stories.js.map +1 -1
  328. package/dist/src/shadcn/components/ui/textarea.d.ts +8 -1
  329. package/dist/src/shadcn/components/ui/textarea.d.ts.map +1 -1
  330. package/dist/src/shadcn/components/ui/textarea.js +30 -2
  331. package/dist/src/shadcn/components/ui/textarea.js.map +1 -1
  332. package/dist/src/shadcn/components/ui/textarea.stories.js +85 -4
  333. package/dist/src/shadcn/components/ui/textarea.stories.js.map +1 -1
  334. package/dist/src/shadcn/components/ui/toggle-group.d.ts +3 -3
  335. package/dist/src/shadcn/components/ui/toggle-group.d.ts.map +1 -1
  336. package/dist/src/shadcn/components/ui/toggle-group.js +14 -12
  337. package/dist/src/shadcn/components/ui/toggle-group.js.map +1 -1
  338. package/dist/src/shadcn/components/ui/toggle.d.ts +3 -4
  339. package/dist/src/shadcn/components/ui/toggle.d.ts.map +1 -1
  340. package/dist/src/shadcn/components/ui/toggle.js +44 -16
  341. package/dist/src/shadcn/components/ui/toggle.js.map +1 -1
  342. package/dist/src/shadcn/components/ui/toggle.stories.js +130 -7
  343. package/dist/src/shadcn/components/ui/toggle.stories.js.map +1 -1
  344. package/dist/src/shadcn/components/ui/tooltip.d.ts.map +1 -1
  345. package/dist/src/shadcn/components/ui/tooltip.js +12 -1
  346. package/dist/src/shadcn/components/ui/tooltip.js.map +1 -1
  347. package/dist/src/shadcn/components/ui/tree.d.ts +29 -0
  348. package/dist/src/shadcn/components/ui/tree.d.ts.map +1 -0
  349. package/dist/src/shadcn/components/ui/tree.js +135 -0
  350. package/dist/src/shadcn/components/ui/tree.js.map +1 -0
  351. package/dist/src/shadcn/shadcn.css +4 -4
  352. package/dist/src/tokens.css +50 -20
  353. package/dist/src/typography.css +78 -15
  354. package/package.json +84 -64
  355. package/src/components/button-dropdown.stories.tsx +41 -0
  356. package/src/components/button-dropdown.tsx +97 -0
  357. package/src/components/code-editor/fhir-autocomplete.test.ts +993 -0
  358. package/src/components/code-editor/fhir-autocomplete.ts +2322 -0
  359. package/src/components/code-editor/http/grammar/http.grammar +74 -0
  360. package/src/components/code-editor/http/grammar/http.terms.ts +9 -0
  361. package/src/components/code-editor/http/grammar/http.test.ts +110 -0
  362. package/src/components/code-editor/http/grammar/http.ts +21 -0
  363. package/src/components/code-editor/http/index.ts +424 -0
  364. package/src/components/code-editor/index.tsx +1944 -42
  365. package/src/components/code-editor/json-ast.test.ts +230 -0
  366. package/src/components/code-editor/json-ast.ts +590 -0
  367. package/src/components/code-editor/sql-completion.ts +1112 -0
  368. package/src/components/code-editor.stories.tsx +325 -2
  369. package/src/components/copy-icon.tsx +57 -3
  370. package/src/components/data-table.stories.tsx +91 -0
  371. package/src/components/data-table.tsx +126 -0
  372. package/src/components/date-picker-input.stories.tsx +79 -0
  373. package/src/components/date-picker-input.tsx +104 -0
  374. package/src/components/fhir-structure-view.stories.tsx +439 -0
  375. package/src/components/fhir-structure-view.tsx +233 -0
  376. package/src/components/icon-button.stories.tsx +86 -0
  377. package/src/components/icon-button.tsx +57 -0
  378. package/src/components/operation-outcome-view.stories.tsx +163 -0
  379. package/src/components/operation-outcome-view.tsx +254 -0
  380. package/src/components/request-line-editor.stories.tsx +17 -27
  381. package/src/components/request-line-editor.tsx +103 -61
  382. package/src/components/sandbox.stories.tsx +131 -0
  383. package/src/components/sandbox.tsx +191 -0
  384. package/src/components/segment-control.stories.tsx +61 -0
  385. package/src/components/segment-control.tsx +83 -0
  386. package/src/components/split-button.stories.tsx +68 -0
  387. package/src/components/split-button.tsx +74 -0
  388. package/src/components/tag.stories.tsx +371 -0
  389. package/src/components/tag.tsx +236 -0
  390. package/src/components/tile.stories.tsx +149 -0
  391. package/src/components/tile.tsx +105 -0
  392. package/src/components/toolbar.stories.tsx +64 -0
  393. package/src/components/toolbar.tsx +98 -0
  394. package/src/components/tree-view.stories.tsx +265 -0
  395. package/src/components/tree-view.tsx +246 -0
  396. package/src/icons.tsx +331 -0
  397. package/src/index.css +358 -74
  398. package/src/index.tsx +17 -3
  399. package/src/shadcn/components/ui/accordion.tsx +91 -10
  400. package/src/shadcn/components/ui/alert-dialog.stories.tsx +209 -15
  401. package/src/shadcn/components/ui/alert-dialog.tsx +236 -26
  402. package/src/shadcn/components/ui/alert.stories.tsx +120 -21
  403. package/src/shadcn/components/ui/alert.tsx +125 -28
  404. package/src/shadcn/components/ui/aspect-ratio.tsx +1 -0
  405. package/src/shadcn/components/ui/avatar.stories.tsx +74 -1
  406. package/src/shadcn/components/ui/avatar.tsx +22 -6
  407. package/src/shadcn/components/ui/badge.tsx +67 -18
  408. package/src/shadcn/components/ui/breadcrumb.stories.tsx +161 -41
  409. package/src/shadcn/components/ui/breadcrumb.tsx +172 -23
  410. package/src/shadcn/components/ui/button.stories.tsx +106 -18
  411. package/src/shadcn/components/ui/button.tsx +151 -55
  412. package/src/shadcn/components/ui/calendar.tsx +1 -0
  413. package/src/shadcn/components/ui/card.stories.tsx +17 -3
  414. package/src/shadcn/components/ui/card.tsx +89 -14
  415. package/src/shadcn/components/ui/carousel.tsx +1 -0
  416. package/src/shadcn/components/ui/chart.tsx +9 -5
  417. package/src/shadcn/components/ui/checkbox.stories.tsx +78 -30
  418. package/src/shadcn/components/ui/checkbox.tsx +91 -8
  419. package/src/shadcn/components/ui/combobox.stories.tsx +148 -0
  420. package/src/shadcn/components/ui/combobox.tsx +324 -0
  421. package/src/shadcn/components/ui/command.stories.tsx +184 -39
  422. package/src/shadcn/components/ui/command.tsx +218 -37
  423. package/src/shadcn/components/ui/context-menu.tsx +333 -40
  424. package/src/shadcn/components/ui/dialog.tsx +101 -13
  425. package/src/shadcn/components/ui/drawer.tsx +94 -18
  426. package/src/shadcn/components/ui/dropdown-menu.stories.tsx +18 -2
  427. package/src/shadcn/components/ui/dropdown-menu.tsx +334 -68
  428. package/src/shadcn/components/ui/form.tsx +22 -11
  429. package/src/shadcn/components/ui/hover-card.tsx +2 -1
  430. package/src/shadcn/components/ui/input-otp.tsx +1 -0
  431. package/src/shadcn/components/ui/input.stories.tsx +235 -27
  432. package/src/shadcn/components/ui/input.tsx +400 -29
  433. package/src/shadcn/components/ui/label.tsx +22 -4
  434. package/src/shadcn/components/ui/menubar.tsx +188 -43
  435. package/src/shadcn/components/ui/pagination.stories.tsx +8 -2
  436. package/src/shadcn/components/ui/pagination.tsx +65 -8
  437. package/src/shadcn/components/ui/popover.tsx +36 -4
  438. package/src/shadcn/components/ui/progress.tsx +21 -5
  439. package/src/shadcn/components/ui/radio-button-group.stories.tsx +247 -0
  440. package/src/shadcn/components/ui/radio-button-group.tsx +188 -0
  441. package/src/shadcn/components/ui/radio-group.stories.tsx +70 -14
  442. package/src/shadcn/components/ui/radio-group.tsx +85 -9
  443. package/src/shadcn/components/ui/resizable.stories.tsx +2 -2
  444. package/src/shadcn/components/ui/resizable.tsx +2 -1
  445. package/src/shadcn/components/ui/scroll-area.tsx +34 -5
  446. package/src/shadcn/components/ui/select.stories.tsx +108 -32
  447. package/src/shadcn/components/ui/select.tsx +182 -36
  448. package/src/shadcn/components/ui/separator.tsx +16 -5
  449. package/src/shadcn/components/ui/sheet.tsx +1 -1
  450. package/src/shadcn/components/ui/sidebar.tsx +69 -26
  451. package/src/shadcn/components/ui/skeleton.tsx +4 -1
  452. package/src/shadcn/components/ui/slider.tsx +83 -11
  453. package/src/shadcn/components/ui/sonner.stories.tsx +238 -17
  454. package/src/shadcn/components/ui/sonner.tsx +254 -11
  455. package/src/shadcn/components/ui/switch.stories.tsx +52 -5
  456. package/src/shadcn/components/ui/switch.tsx +92 -7
  457. package/src/shadcn/components/ui/table.stories.tsx +252 -72
  458. package/src/shadcn/components/ui/table.tsx +204 -26
  459. package/src/shadcn/components/ui/tabs.stories.tsx +235 -123
  460. package/src/shadcn/components/ui/tabs.tsx +694 -36
  461. package/src/shadcn/components/ui/textarea.stories.tsx +94 -2
  462. package/src/shadcn/components/ui/textarea.tsx +70 -5
  463. package/src/shadcn/components/ui/toggle-group.tsx +35 -13
  464. package/src/shadcn/components/ui/toggle.stories.tsx +92 -5
  465. package/src/shadcn/components/ui/toggle.tsx +96 -23
  466. package/src/shadcn/components/ui/tooltip.tsx +34 -8
  467. package/src/shadcn/components/ui/tree.tsx +257 -0
  468. package/src/shadcn/shadcn.css +4 -4
  469. package/src/tokens.css +50 -20
  470. package/src/typography.css +78 -15
  471. package/dist/src/components/code-editor.stories.d.ts +0 -7
  472. package/dist/src/components/code-editor.stories.d.ts.map +0 -1
  473. package/dist/src/components/request-line-editor.stories.d.ts +0 -11
  474. package/dist/src/components/request-line-editor.stories.d.ts.map +0 -1
  475. package/dist/src/index.stories.d.ts +0 -14
  476. package/dist/src/index.stories.d.ts.map +0 -1
  477. package/dist/src/index.stories.js +0 -19
  478. package/dist/src/index.stories.js.map +0 -1
  479. package/dist/src/shadcn/components/ui/accordion.stories.d.ts +0 -8
  480. package/dist/src/shadcn/components/ui/accordion.stories.d.ts.map +0 -1
  481. package/dist/src/shadcn/components/ui/alert-dialog.stories.d.ts +0 -8
  482. package/dist/src/shadcn/components/ui/alert-dialog.stories.d.ts.map +0 -1
  483. package/dist/src/shadcn/components/ui/alert.stories.d.ts +0 -8
  484. package/dist/src/shadcn/components/ui/alert.stories.d.ts.map +0 -1
  485. package/dist/src/shadcn/components/ui/aspect-ratio.stories.d.ts +0 -8
  486. package/dist/src/shadcn/components/ui/aspect-ratio.stories.d.ts.map +0 -1
  487. package/dist/src/shadcn/components/ui/avatar.stories.d.ts +0 -8
  488. package/dist/src/shadcn/components/ui/avatar.stories.d.ts.map +0 -1
  489. package/dist/src/shadcn/components/ui/badge.stories.d.ts +0 -8
  490. package/dist/src/shadcn/components/ui/badge.stories.d.ts.map +0 -1
  491. package/dist/src/shadcn/components/ui/breadcrumb.stories.d.ts +0 -8
  492. package/dist/src/shadcn/components/ui/breadcrumb.stories.d.ts.map +0 -1
  493. package/dist/src/shadcn/components/ui/button.stories.d.ts +0 -23
  494. package/dist/src/shadcn/components/ui/button.stories.d.ts.map +0 -1
  495. package/dist/src/shadcn/components/ui/calendar.stories.d.ts +0 -8
  496. package/dist/src/shadcn/components/ui/calendar.stories.d.ts.map +0 -1
  497. package/dist/src/shadcn/components/ui/card.stories.d.ts +0 -8
  498. package/dist/src/shadcn/components/ui/card.stories.d.ts.map +0 -1
  499. package/dist/src/shadcn/components/ui/carousel.stories.d.ts +0 -8
  500. package/dist/src/shadcn/components/ui/carousel.stories.d.ts.map +0 -1
  501. package/dist/src/shadcn/components/ui/chart.stories.d.ts +0 -8
  502. package/dist/src/shadcn/components/ui/chart.stories.d.ts.map +0 -1
  503. package/dist/src/shadcn/components/ui/checkbox.stories.d.ts +0 -8
  504. package/dist/src/shadcn/components/ui/checkbox.stories.d.ts.map +0 -1
  505. package/dist/src/shadcn/components/ui/collapsible.stories.d.ts +0 -8
  506. package/dist/src/shadcn/components/ui/collapsible.stories.d.ts.map +0 -1
  507. package/dist/src/shadcn/components/ui/command.stories.d.ts +0 -8
  508. package/dist/src/shadcn/components/ui/command.stories.d.ts.map +0 -1
  509. package/dist/src/shadcn/components/ui/context-menu.stories.d.ts +0 -8
  510. package/dist/src/shadcn/components/ui/context-menu.stories.d.ts.map +0 -1
  511. package/dist/src/shadcn/components/ui/dialog.stories.d.ts +0 -8
  512. package/dist/src/shadcn/components/ui/dialog.stories.d.ts.map +0 -1
  513. package/dist/src/shadcn/components/ui/drawer.stories.d.ts +0 -8
  514. package/dist/src/shadcn/components/ui/drawer.stories.d.ts.map +0 -1
  515. package/dist/src/shadcn/components/ui/dropdown-menu.stories.d.ts +0 -8
  516. package/dist/src/shadcn/components/ui/dropdown-menu.stories.d.ts.map +0 -1
  517. package/dist/src/shadcn/components/ui/form.stories.d.ts +0 -8
  518. package/dist/src/shadcn/components/ui/form.stories.d.ts.map +0 -1
  519. package/dist/src/shadcn/components/ui/hover-card.stories.d.ts +0 -8
  520. package/dist/src/shadcn/components/ui/hover-card.stories.d.ts.map +0 -1
  521. package/dist/src/shadcn/components/ui/input-otp.stories.d.ts +0 -8
  522. package/dist/src/shadcn/components/ui/input-otp.stories.d.ts.map +0 -1
  523. package/dist/src/shadcn/components/ui/input.stories.d.ts +0 -18
  524. package/dist/src/shadcn/components/ui/input.stories.d.ts.map +0 -1
  525. package/dist/src/shadcn/components/ui/label.stories.d.ts +0 -8
  526. package/dist/src/shadcn/components/ui/label.stories.d.ts.map +0 -1
  527. package/dist/src/shadcn/components/ui/menubar.stories.d.ts +0 -8
  528. package/dist/src/shadcn/components/ui/menubar.stories.d.ts.map +0 -1
  529. package/dist/src/shadcn/components/ui/navigation-menu.stories.d.ts +0 -8
  530. package/dist/src/shadcn/components/ui/navigation-menu.stories.d.ts.map +0 -1
  531. package/dist/src/shadcn/components/ui/pagination.stories.d.ts +0 -8
  532. package/dist/src/shadcn/components/ui/pagination.stories.d.ts.map +0 -1
  533. package/dist/src/shadcn/components/ui/popover.stories.d.ts +0 -8
  534. package/dist/src/shadcn/components/ui/popover.stories.d.ts.map +0 -1
  535. package/dist/src/shadcn/components/ui/progress.stories.d.ts +0 -8
  536. package/dist/src/shadcn/components/ui/progress.stories.d.ts.map +0 -1
  537. package/dist/src/shadcn/components/ui/radio-group.stories.d.ts +0 -8
  538. package/dist/src/shadcn/components/ui/radio-group.stories.d.ts.map +0 -1
  539. package/dist/src/shadcn/components/ui/resizable.stories.d.ts +0 -8
  540. package/dist/src/shadcn/components/ui/resizable.stories.d.ts.map +0 -1
  541. package/dist/src/shadcn/components/ui/scroll-area.stories.d.ts +0 -8
  542. package/dist/src/shadcn/components/ui/scroll-area.stories.d.ts.map +0 -1
  543. package/dist/src/shadcn/components/ui/select.stories.d.ts +0 -11
  544. package/dist/src/shadcn/components/ui/select.stories.d.ts.map +0 -1
  545. package/dist/src/shadcn/components/ui/separator.stories.d.ts +0 -8
  546. package/dist/src/shadcn/components/ui/separator.stories.d.ts.map +0 -1
  547. package/dist/src/shadcn/components/ui/sheet.stories.d.ts +0 -8
  548. package/dist/src/shadcn/components/ui/sheet.stories.d.ts.map +0 -1
  549. package/dist/src/shadcn/components/ui/sidebar.stories.d.ts +0 -11
  550. package/dist/src/shadcn/components/ui/sidebar.stories.d.ts.map +0 -1
  551. package/dist/src/shadcn/components/ui/skeleton.stories.d.ts +0 -8
  552. package/dist/src/shadcn/components/ui/skeleton.stories.d.ts.map +0 -1
  553. package/dist/src/shadcn/components/ui/slider.stories.d.ts +0 -8
  554. package/dist/src/shadcn/components/ui/slider.stories.d.ts.map +0 -1
  555. package/dist/src/shadcn/components/ui/sonner.stories.d.ts +0 -8
  556. package/dist/src/shadcn/components/ui/sonner.stories.d.ts.map +0 -1
  557. package/dist/src/shadcn/components/ui/switch.stories.d.ts +0 -8
  558. package/dist/src/shadcn/components/ui/switch.stories.d.ts.map +0 -1
  559. package/dist/src/shadcn/components/ui/table.stories.d.ts +0 -8
  560. package/dist/src/shadcn/components/ui/table.stories.d.ts.map +0 -1
  561. package/dist/src/shadcn/components/ui/tabs.stories.d.ts +0 -32
  562. package/dist/src/shadcn/components/ui/tabs.stories.d.ts.map +0 -1
  563. package/dist/src/shadcn/components/ui/textarea.stories.d.ts +0 -8
  564. package/dist/src/shadcn/components/ui/textarea.stories.d.ts.map +0 -1
  565. package/dist/src/shadcn/components/ui/toggle-group.stories.d.ts +0 -8
  566. package/dist/src/shadcn/components/ui/toggle-group.stories.d.ts.map +0 -1
  567. package/dist/src/shadcn/components/ui/toggle.stories.d.ts +0 -8
  568. package/dist/src/shadcn/components/ui/toggle.stories.d.ts.map +0 -1
  569. package/dist/src/shadcn/components/ui/tooltip.stories.d.ts +0 -8
  570. package/dist/src/shadcn/components/ui/tooltip.stories.d.ts.map +0 -1
  571. package/src/index.stories.tsx +0 -21
@@ -1,25 +1,346 @@
1
- import { jsx as _jsx } from "react/jsx-runtime";
2
- import { autocompletion, closeBrackets, closeBracketsKeymap, completionKeymap } from "@codemirror/autocomplete";
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { acceptCompletion, autocompletion, closeBrackets, closeBracketsKeymap, completionKeymap, completionStatus, moveCompletionSelection } from "@codemirror/autocomplete";
3
3
  import { defaultKeymap, history, historyKeymap } from "@codemirror/commands";
4
4
  import { json, jsonParseLinter } from "@codemirror/lang-json";
5
- import { bracketMatching, foldGutter, foldKeymap, HighlightStyle, indentOnInput, syntaxHighlighting } from "@codemirror/language";
6
- import { linter, lintGutter, lintKeymap } from "@codemirror/lint";
7
- import { highlightSelectionMatches, searchKeymap } from "@codemirror/search";
8
- import { EditorState } from "@codemirror/state";
9
- import { crosshairCursor, drawSelection, dropCursor, EditorView, highlightActiveLine, highlightActiveLineGutter, highlightSpecialChars, keymap, lineNumbers, rectangularSelection } from "@codemirror/view";
5
+ import { SQLDialect, sql } from "@codemirror/lang-sql";
6
+ import { yaml } from "@codemirror/lang-yaml";
7
+ import { bracketMatching, foldGutter, foldKeymap, HighlightStyle, indentOnInput, syntaxHighlighting, syntaxTree } from "@codemirror/language";
8
+ import { linter, lintKeymap } from "@codemirror/lint";
9
+ import { closeSearchPanel, findNext, findPrevious, getSearchQuery, highlightSelectionMatches, SearchQuery, search, searchKeymap, setSearchQuery } from "@codemirror/search";
10
+ import { Compartment, EditorState, Prec, RangeSet, StateEffect, StateField } from "@codemirror/state";
11
+ import { crosshairCursor, Decoration, drawSelection, dropCursor, EditorView, GutterMarker, gutterLineClass, highlightSpecialChars, keymap, lineNumbers, rectangularSelection } from "@codemirror/view";
10
12
  import { tags } from "@lezer/highlight";
13
+ import { vim } from "@replit/codemirror-vim";
14
+ import { ChevronDown, ChevronsRight, ChevronUp, Columns2, Heading, Table2, Terminal, X } from "lucide-react";
11
15
  import * as React from "react";
12
- const baseTheme = EditorView.baseTheme({
16
+ import { flushSync } from "react-dom";
17
+ import { createRoot } from "react-dom/client";
18
+ import { ComplexTypeIcon, ResourceIcon, SquareFunctionIcon, TypCodeIcon } from "../../icons.js";
19
+ import { buildFhirCompletionExtension, fhirDiagnosticsField } from "./fhir-autocomplete.js";
20
+ import { http } from "./http/index.js";
21
+ import { buildSqlCompletionExtensions, fetchSqlMetadata } from "./sql-completion.js";
22
+ class ErrorLineGutterMarker extends GutterMarker {
23
+ elementClass = "cm-errorLineGutter";
24
+ }
25
+ const errorLineMarker = new ErrorLineGutterMarker();
26
+ const errorLineDecoration = Decoration.line({
27
+ class: "cm-errorLine"
28
+ });
29
+ const setIssueLinesEffect = StateEffect.define();
30
+ let errorTooltipEl = null;
31
+ function formatErrorTypeTitle(code) {
32
+ return code.split("-").map((w)=>w.charAt(0).toUpperCase() + w.slice(1)).join(" ");
33
+ }
34
+ function renderErrorCard(msg) {
35
+ const card = document.createElement("div");
36
+ Object.assign(card.style, {
37
+ backgroundColor: "var(--color-bg-primary)",
38
+ border: "1px solid var(--color-border-primary)",
39
+ borderRadius: "var(--radius-md)",
40
+ padding: "6px 10px",
41
+ boxShadow: "0 2px 6px rgba(0, 0, 0, 0.08)"
42
+ });
43
+ const newlineIdx = msg.indexOf("\n");
44
+ if (newlineIdx !== -1) {
45
+ const title = msg.slice(0, newlineIdx);
46
+ const body = msg.slice(newlineIdx + 1);
47
+ const titleEl = document.createElement("div");
48
+ titleEl.textContent = formatErrorTypeTitle(title);
49
+ Object.assign(titleEl.style, {
50
+ fontWeight: "600"
51
+ });
52
+ const hr = document.createElement("div");
53
+ Object.assign(hr.style, {
54
+ borderTop: "1px solid var(--color-border-primary)",
55
+ margin: "4px 0"
56
+ });
57
+ const bodyEl = document.createElement("div");
58
+ bodyEl.textContent = body;
59
+ Object.assign(bodyEl.style, {
60
+ whiteSpace: "pre-wrap"
61
+ });
62
+ card.append(titleEl, hr, bodyEl);
63
+ } else {
64
+ card.textContent = msg;
65
+ card.style.whiteSpace = "pre-wrap";
66
+ }
67
+ return card;
68
+ }
69
+ function showErrorTooltip(message, x, y) {
70
+ hideErrorTooltip();
71
+ const tooltip = document.createElement("div");
72
+ Object.assign(tooltip.style, {
73
+ position: "fixed",
74
+ fontSize: "12px",
75
+ lineHeight: "1.4",
76
+ color: "var(--color-text-error-primary)",
77
+ fontFamily: "var(--font-family-sans)",
78
+ zIndex: "1000",
79
+ pointerEvents: "none",
80
+ maxWidth: "400px",
81
+ display: "flex",
82
+ flexDirection: "column",
83
+ gap: "6px"
84
+ });
85
+ const parts = message.split("\n\x00\n");
86
+ for (const part of parts){
87
+ tooltip.append(renderErrorCard(part ?? ""));
88
+ }
89
+ document.body.appendChild(tooltip);
90
+ errorTooltipEl = tooltip;
91
+ const tooltipRect = tooltip.getBoundingClientRect();
92
+ let top = y - tooltipRect.height - 8;
93
+ // If tooltip goes above viewport, show below cursor instead
94
+ if (top < 4) {
95
+ top = y + 20;
96
+ }
97
+ // If it still goes below viewport, clamp to bottom
98
+ if (top + tooltipRect.height > window.innerHeight - 4) {
99
+ top = window.innerHeight - tooltipRect.height - 4;
100
+ }
101
+ // Final clamp to top
102
+ if (top < 4) top = 4;
103
+ tooltip.style.left = `${x}px`;
104
+ tooltip.style.top = `${top}px`;
105
+ }
106
+ function hideErrorTooltip() {
107
+ errorTooltipEl?.remove();
108
+ errorTooltipEl = null;
109
+ }
110
+ const issueLinesField = StateField.define({
111
+ create () {
112
+ return {
113
+ gutterMarkers: RangeSet.empty,
114
+ lineDecorations: Decoration.none,
115
+ messages: new Map()
116
+ };
117
+ },
118
+ update (state, tr) {
119
+ for (const effect of tr.effects){
120
+ if (effect.is(setIssueLinesEffect)) {
121
+ const markers = [];
122
+ const lineDecos = [];
123
+ const messages = new Map();
124
+ const doc = tr.state.doc;
125
+ for (const issue of effect.value){
126
+ if (issue.line >= 1 && issue.line <= doc.lines) {
127
+ const line = doc.line(issue.line);
128
+ markers.push(errorLineMarker.range(line.from));
129
+ lineDecos.push(errorLineDecoration.range(line.from));
130
+ if (issue.message) {
131
+ messages.set(issue.line, issue.message);
132
+ }
133
+ }
134
+ }
135
+ return {
136
+ gutterMarkers: RangeSet.of(markers, true),
137
+ lineDecorations: Decoration.set(lineDecos, true),
138
+ messages
139
+ };
140
+ }
141
+ }
142
+ if (tr.docChanged) {
143
+ try {
144
+ return {
145
+ gutterMarkers: state.gutterMarkers.map(tr.changes),
146
+ lineDecorations: state.lineDecorations.map(tr.changes),
147
+ messages: state.messages
148
+ };
149
+ } catch {
150
+ return {
151
+ gutterMarkers: RangeSet.empty,
152
+ lineDecorations: Decoration.none,
153
+ messages: new Map()
154
+ };
155
+ }
156
+ }
157
+ return state;
158
+ },
159
+ provide (field) {
160
+ return [
161
+ gutterLineClass.from(field, (val)=>val.gutterMarkers),
162
+ EditorView.decorations.from(field, (val)=>val.lineDecorations)
163
+ ];
164
+ }
165
+ });
166
+ function getErrorMessageForLine(view, lineNo) {
167
+ const issueMsg = view.state.field(issueLinesField).messages.get(lineNo);
168
+ if (issueMsg) return issueMsg;
169
+ try {
170
+ return view.state.field(fhirDiagnosticsField).messages.get(lineNo);
171
+ } catch {
172
+ return undefined;
173
+ }
174
+ }
175
+ function handleErrorTooltipMove(event, view) {
176
+ const target = event.target;
177
+ const mouseEvent = event;
178
+ // Check gutter line number
179
+ const gutterEl = target.closest(".cm-lineNumbers .cm-gutterElement");
180
+ if (gutterEl) {
181
+ const lineNo = Number.parseInt(gutterEl.textContent ?? "", 10);
182
+ if (!Number.isNaN(lineNo)) {
183
+ const message = getErrorMessageForLine(view, lineNo);
184
+ if (message) {
185
+ showErrorTooltip(message, mouseEvent.clientX, mouseEvent.clientY);
186
+ return false;
187
+ }
188
+ }
189
+ hideErrorTooltip();
190
+ return false;
191
+ }
192
+ // Check content line (cm-line) — follow cursor
193
+ const lineEl = target.closest(".cm-line");
194
+ if (lineEl) {
195
+ const pos = view.posAtDOM(lineEl);
196
+ const lineNo = view.state.doc.lineAt(pos).number;
197
+ const message = getErrorMessageForLine(view, lineNo);
198
+ if (message) {
199
+ showErrorTooltip(message, mouseEvent.clientX, mouseEvent.clientY);
200
+ return false;
201
+ }
202
+ }
203
+ hideErrorTooltip();
204
+ return false;
205
+ }
206
+ const errorTooltipHandler = EditorView.domEventHandlers({
207
+ mouseover: handleErrorTooltipMove,
208
+ mousemove: handleErrorTooltipMove,
209
+ mouseleave () {
210
+ hideErrorTooltip();
211
+ return false;
212
+ }
213
+ });
214
+ const baseTheme = EditorView.theme({
13
215
  "&": {
14
216
  backgroundColor: "var(--color-bg-primary)",
15
217
  height: "100%",
16
218
  width: "100%",
17
- fontSize: "14px",
219
+ fontSize: "14px"
220
+ },
221
+ "&.cm-editor": {
222
+ paddingTop: "0 !important",
223
+ paddingBottom: "0 !important"
224
+ },
225
+ ".cm-scroller": {
226
+ overflow: "auto",
18
227
  paddingTop: "8px",
19
228
  paddingBottom: "8px"
20
229
  },
230
+ ".cm-content": {
231
+ fontFamily: "var(--font-family-mono)",
232
+ padding: "0"
233
+ },
234
+ "&.cm-focused": {
235
+ outline: "none"
236
+ },
237
+ ".cm-cursor, .cm-dropCursor": {
238
+ borderLeftColor: "var(--color-text-primary)"
239
+ },
240
+ ".cm-gutter": {
241
+ fontFamily: "var(--font-family-mono)"
242
+ },
243
+ ".cm-gutters": {
244
+ backgroundColor: "transparent",
245
+ border: "none"
246
+ },
247
+ ".cm-lineNumbers": {
248
+ minWidth: "3.5ch"
249
+ },
250
+ ".cm-lineNumbers .cm-gutterElement": {
251
+ minWidth: "3.5ch",
252
+ paddingRight: "4px",
253
+ color: "var(--color-text-quaternary)"
254
+ },
255
+ ".cm-lineNumbers .cm-gutterElement.cm-activeLineGutter": {
256
+ backgroundColor: "var(--color-bg-primary)",
257
+ color: "var(--color-text-secondary)"
258
+ },
259
+ ".cm-activeLineGutter": {
260
+ backgroundColor: "transparent !important"
261
+ },
262
+ ".cm-activeLine": {
263
+ backgroundColor: "transparent !important"
264
+ },
265
+ ".cm-lineNumbers .cm-gutterElement.cm-errorLineGutter": {
266
+ color: "var(--color-text-error-primary)",
267
+ backgroundColor: "color-mix(in srgb, var(--color-text-error-primary) 7%, transparent)"
268
+ },
269
+ ".cm-foldGutter .cm-gutterElement.cm-errorLineGutter": {
270
+ color: "var(--color-text-error-primary)",
271
+ backgroundColor: "color-mix(in srgb, var(--color-text-error-primary) 7%, transparent)",
272
+ display: "flex",
273
+ alignItems: "center",
274
+ justifyContent: "center"
275
+ },
276
+ ".cm-errorLine": {
277
+ backgroundColor: "color-mix(in srgb, var(--color-text-error-primary) 7%, transparent)"
278
+ }
279
+ });
280
+ const completionTheme = EditorView.theme({
281
+ ".cm-tooltip.cm-tooltip-autocomplete > ul": {
282
+ maxHeight: "400px"
283
+ },
284
+ ".cm-tooltip.cm-tooltip-autocomplete > ul > li": {
285
+ display: "flex",
286
+ alignItems: "center",
287
+ gap: "8px"
288
+ },
289
+ ".cm-completionLabel": {
290
+ flex: "1",
291
+ minWidth: "0",
292
+ fontFamily: "var(--font-family-mono)",
293
+ fontSize: "var(--font-size-sm)",
294
+ lineHeight: "var(--font-leading-5)"
295
+ },
296
+ ".cm-completionMatchedText": {
297
+ textDecoration: "none",
298
+ fontWeight: "600",
299
+ color: "var(--color-text-link)"
300
+ },
301
+ ".cm-completionDetail": {
302
+ color: "var(--color-text-tertiary)",
303
+ fontSize: "12px",
304
+ marginLeft: "auto",
305
+ whiteSpace: "nowrap"
306
+ },
307
+ ".cm-completionInfo": {
308
+ backgroundColor: "var(--color-bg-primary)",
309
+ border: "1px solid var(--color-border-primary)",
310
+ borderRadius: "var(--radius-md)",
311
+ color: "var(--color-text-secondary)",
312
+ fontFamily: "var(--font-family-mono)",
313
+ fontSize: "14px",
314
+ padding: "8px 12px",
315
+ marginLeft: "8px",
316
+ lineHeight: "1.4",
317
+ whiteSpace: "normal",
318
+ maxWidth: "300px"
319
+ },
320
+ ".cm-completion-icon": {
321
+ display: "flex",
322
+ alignItems: "center",
323
+ justifyContent: "center",
324
+ width: "16px",
325
+ height: "16px",
326
+ flexShrink: "0"
327
+ }
328
+ });
329
+ const readOnlyTheme = EditorView.theme({
330
+ "&": {
331
+ backgroundColor: "var(--color-bg-secondary)",
332
+ height: "100%",
333
+ width: "100%",
334
+ fontSize: "14px"
335
+ },
336
+ "&.cm-editor": {
337
+ paddingTop: "0 !important",
338
+ paddingBottom: "0 !important"
339
+ },
21
340
  ".cm-scroller": {
22
- overflow: "auto"
341
+ overflow: "auto",
342
+ paddingTop: "8px",
343
+ paddingBottom: "8px"
23
344
  },
24
345
  ".cm-content": {
25
346
  fontFamily: "var(--font-family-mono)",
@@ -32,101 +353,1527 @@ const baseTheme = EditorView.baseTheme({
32
353
  fontFamily: "var(--font-family-mono)"
33
354
  },
34
355
  ".cm-gutters": {
35
- backgroundColor: "var(--color-bg-primary)",
356
+ backgroundColor: "var(--color-bg-secondary)",
36
357
  border: "none"
37
358
  },
38
359
  ".cm-lineNumbers": {
39
- paddingLeft: "16px"
360
+ minWidth: "3.5ch"
361
+ },
362
+ ".cm-lineNumbers .cm-gutterElement": {
363
+ minWidth: "3.5ch",
364
+ paddingRight: "4px",
365
+ color: "var(--color-text-quaternary)"
366
+ },
367
+ ".cm-lineNumbers .cm-gutterElement.cm-activeLineGutter": {
368
+ backgroundColor: "var(--color-bg-secondary)",
369
+ color: "var(--color-text-secondary)"
40
370
  },
41
371
  ".cm-activeLineGutter": {
42
- backgroundColor: "var(--color-bg-primary)",
43
- color: "var(--color-text-primary)"
372
+ backgroundColor: "transparent !important"
44
373
  },
45
374
  ".cm-activeLine": {
46
- backgroundColor: "rgba(255, 255, 255, 0)"
375
+ backgroundColor: "transparent !important"
376
+ },
377
+ ".cm-lineNumbers .cm-gutterElement.cm-errorLineGutter": {
378
+ color: "var(--color-text-error-primary)",
379
+ backgroundColor: "color-mix(in srgb, var(--color-text-error-primary) 7%, transparent)"
380
+ },
381
+ ".cm-foldGutter .cm-gutterElement.cm-errorLineGutter": {
382
+ color: "var(--color-text-error-primary)",
383
+ backgroundColor: "color-mix(in srgb, var(--color-text-error-primary) 7%, transparent)",
384
+ display: "flex",
385
+ alignItems: "center",
386
+ justifyContent: "center"
387
+ },
388
+ ".cm-errorLine": {
389
+ backgroundColor: "color-mix(in srgb, var(--color-text-error-primary) 7%, transparent)"
47
390
  }
48
391
  });
392
+ const iconButtonStyle = {
393
+ display: "flex",
394
+ alignItems: "center",
395
+ justifyContent: "center",
396
+ width: "28px",
397
+ height: "28px",
398
+ border: "none",
399
+ borderRadius: "var(--radius-sm)",
400
+ background: "transparent",
401
+ color: "var(--color-text-secondary)",
402
+ cursor: "pointer",
403
+ padding: 0
404
+ };
405
+ function getMatchInfo(state, searchText) {
406
+ if (!searchText) return {
407
+ current: 0,
408
+ total: 0
409
+ };
410
+ const doc = state.doc.toString();
411
+ const sel = state.selection.main;
412
+ const lowerDoc = doc.toLowerCase();
413
+ const lowerSearch = searchText.toLowerCase();
414
+ const searchLen = searchText.length;
415
+ let total = 0;
416
+ let current = 0;
417
+ let pos = 0;
418
+ for(;;){
419
+ const idx = lowerDoc.indexOf(lowerSearch, pos);
420
+ if (idx === -1) break;
421
+ total++;
422
+ if (idx === sel.from && idx + searchLen === sel.to) {
423
+ current = total;
424
+ }
425
+ pos = idx + 1;
426
+ }
427
+ return {
428
+ current,
429
+ total
430
+ };
431
+ }
432
+ function createSearchPanel(view) {
433
+ const dom = document.createElement("div");
434
+ const root = createRoot(dom);
435
+ const panelRef = {
436
+ setSearch: null,
437
+ setMatch: null,
438
+ lastSearch: "",
439
+ lastCurrent: 0,
440
+ lastTotal: 0
441
+ };
442
+ function Panel() {
443
+ const [value, setValue] = React.useState(()=>getSearchQuery(view.state).search);
444
+ const [match, setMatchState] = React.useState({
445
+ current: 0,
446
+ total: 0
447
+ });
448
+ panelRef.setSearch = setValue;
449
+ panelRef.setMatch = setMatchState;
450
+ const handleChange = (newValue)=>{
451
+ setValue(newValue);
452
+ view.dispatch({
453
+ effects: setSearchQuery.of(new SearchQuery({
454
+ search: newValue
455
+ }))
456
+ });
457
+ };
458
+ return /*#__PURE__*/ _jsxs("div", {
459
+ style: {
460
+ display: "flex",
461
+ alignItems: "center",
462
+ gap: "2px",
463
+ padding: "6px 8px",
464
+ marginTop: "4px",
465
+ backgroundColor: "var(--color-bg-primary)",
466
+ border: "1px solid var(--color-border-primary)",
467
+ borderRadius: "var(--radius-md)",
468
+ boxShadow: "0 2px 8px rgba(0, 0, 0, 0.12)"
469
+ },
470
+ children: [
471
+ /*#__PURE__*/ _jsx("input", {
472
+ value: value,
473
+ onChange: (e)=>handleChange(e.target.value),
474
+ onKeyDown: (e)=>{
475
+ if (e.key === "Enter") {
476
+ e.preventDefault();
477
+ if (e.shiftKey) findPrevious(view);
478
+ else findNext(view);
479
+ }
480
+ if (e.key === "Escape") {
481
+ e.preventDefault();
482
+ closeSearchPanel(view);
483
+ view.focus();
484
+ }
485
+ },
486
+ placeholder: "Find...",
487
+ style: {
488
+ height: "28px",
489
+ padding: "0 8px",
490
+ border: "1px solid var(--color-border-primary)",
491
+ borderRadius: "var(--radius-md)",
492
+ fontSize: "13px",
493
+ fontFamily: "var(--font-family-sans)",
494
+ backgroundColor: "var(--color-bg-primary)",
495
+ color: "var(--color-text-primary)",
496
+ outline: "none",
497
+ flex: "0 0 200px"
498
+ }
499
+ }),
500
+ /*#__PURE__*/ _jsx("span", {
501
+ style: {
502
+ fontSize: "12px",
503
+ fontFamily: "var(--font-family-sans)",
504
+ color: "var(--color-text-secondary)",
505
+ whiteSpace: "nowrap",
506
+ minWidth: "70px",
507
+ textAlign: "center",
508
+ visibility: value ? "visible" : "hidden"
509
+ },
510
+ children: value ? match.total > 0 ? `${match.current} of ${match.total}` : "No results" : "No results"
511
+ }),
512
+ /*#__PURE__*/ _jsx("button", {
513
+ type: "button",
514
+ onClick: ()=>findPrevious(view),
515
+ title: "Previous match",
516
+ style: iconButtonStyle,
517
+ children: /*#__PURE__*/ _jsx(ChevronUp, {
518
+ size: 16
519
+ })
520
+ }),
521
+ /*#__PURE__*/ _jsx("button", {
522
+ type: "button",
523
+ onClick: ()=>findNext(view),
524
+ title: "Next match",
525
+ style: iconButtonStyle,
526
+ children: /*#__PURE__*/ _jsx(ChevronDown, {
527
+ size: 16
528
+ })
529
+ }),
530
+ /*#__PURE__*/ _jsx("button", {
531
+ type: "button",
532
+ onClick: ()=>{
533
+ closeSearchPanel(view);
534
+ view.focus();
535
+ },
536
+ title: "Close",
537
+ style: iconButtonStyle,
538
+ children: /*#__PURE__*/ _jsx(X, {
539
+ size: 14
540
+ })
541
+ })
542
+ ]
543
+ });
544
+ }
545
+ flushSync(()=>{
546
+ root.render(/*#__PURE__*/ _jsx(Panel, {}));
547
+ });
548
+ const input = dom.querySelector("input");
549
+ if (input) input.setAttribute("main-field", "true");
550
+ // Compute initial match info
551
+ const q = getSearchQuery(view.state);
552
+ panelRef.lastSearch = q.search;
553
+ if (q.search) {
554
+ const info = getMatchInfo(view.state, q.search);
555
+ panelRef.lastCurrent = info.current;
556
+ panelRef.lastTotal = info.total;
557
+ panelRef.setMatch?.(info);
558
+ }
559
+ return {
560
+ dom,
561
+ top: true,
562
+ mount () {
563
+ const el = dom.querySelector("input");
564
+ if (el) {
565
+ el.focus();
566
+ el.select();
567
+ }
568
+ },
569
+ update (update) {
570
+ const query = getSearchQuery(update.state);
571
+ if (query.search !== panelRef.lastSearch) {
572
+ panelRef.setSearch?.(query.search);
573
+ }
574
+ panelRef.lastSearch = query.search;
575
+ const info = getMatchInfo(update.state, query.search);
576
+ if (info.current !== panelRef.lastCurrent || info.total !== panelRef.lastTotal) {
577
+ panelRef.lastCurrent = info.current;
578
+ panelRef.lastTotal = info.total;
579
+ panelRef.setMatch?.(info);
580
+ }
581
+ },
582
+ destroy () {
583
+ root.unmount();
584
+ panelRef.setSearch = null;
585
+ panelRef.setMatch = null;
586
+ }
587
+ };
588
+ }
589
+ const searchPanelTheme = EditorView.theme({
590
+ "& .cm-panels-top": {
591
+ position: "absolute",
592
+ top: "8px",
593
+ right: "4px",
594
+ left: "auto",
595
+ zIndex: "10",
596
+ backgroundColor: "transparent",
597
+ border: "none"
598
+ },
599
+ ".cm-searchMatch": {
600
+ backgroundColor: "var(--color-blue-200) !important"
601
+ },
602
+ ".cm-searchMatch-selected": {
603
+ backgroundColor: "var(--color-blue-400) !important"
604
+ },
605
+ ".cm-selectionMatch": {
606
+ backgroundColor: "var(--color-blue-100) !important"
607
+ }
608
+ });
609
+ const customSearchExtension = [
610
+ search({
611
+ createPanel: createSearchPanel
612
+ }),
613
+ searchPanelTheme
614
+ ];
49
615
  const customHighlightStyle = HighlightStyle.define([
50
616
  {
51
617
  tag: tags.propertyName,
52
- color: "#EA4A35"
618
+ color: "var(--hs-syntax-property)"
53
619
  },
54
620
  {
55
621
  tag: tags.string,
56
- color: "#405CBF"
622
+ color: "var(--hs-syntax-string)"
57
623
  },
58
624
  {
59
625
  tag: tags.number,
60
- color: "#00A984"
626
+ color: "var(--hs-syntax-number)"
61
627
  },
62
628
  {
63
629
  tag: tags.bool,
64
- color: "#569cd6"
630
+ color: "var(--hs-syntax-keyword)"
65
631
  },
66
632
  {
67
633
  tag: tags.null,
68
- color: "#569cd6"
634
+ color: "var(--hs-syntax-keyword)"
635
+ },
636
+ {
637
+ tag: tags.keyword,
638
+ color: "var(--hs-syntax-keyword)"
639
+ },
640
+ {
641
+ tag: tags.operatorKeyword,
642
+ color: "var(--hs-syntax-string)"
643
+ },
644
+ {
645
+ tag: tags.controlKeyword,
646
+ color: "var(--hs-syntax-property)"
647
+ },
648
+ {
649
+ tag: tags.typeName,
650
+ color: "var(--hs-syntax-number)"
651
+ },
652
+ {
653
+ tag: tags.variableName,
654
+ color: "var(--hs-syntax-property)"
655
+ },
656
+ {
657
+ tag: tags.operator,
658
+ color: "var(--hs-syntax-string)"
659
+ },
660
+ {
661
+ tag: tags.comment,
662
+ color: "var(--hs-syntax-comment)"
663
+ },
664
+ {
665
+ tag: tags.lineComment,
666
+ color: "var(--hs-syntax-comment)"
667
+ },
668
+ {
669
+ tag: tags.blockComment,
670
+ color: "var(--hs-syntax-comment)"
69
671
  }
70
672
  ]);
71
- export function CodeEditor({ defaultValue, onChange }) {
72
- const editorRef = React.useRef(null);
673
+ const SQL_KEYWORDS = [
674
+ "select",
675
+ "from",
676
+ "where",
677
+ "and",
678
+ "or",
679
+ "not",
680
+ "in",
681
+ "between",
682
+ "like",
683
+ "ilike",
684
+ "similar",
685
+ "insert",
686
+ "update",
687
+ "delete",
688
+ "create",
689
+ "drop",
690
+ "alter",
691
+ "table",
692
+ "index",
693
+ "view",
694
+ "materialized",
695
+ "schema",
696
+ "sequence",
697
+ "type",
698
+ "extension",
699
+ "function",
700
+ "procedure",
701
+ "trigger",
702
+ "join",
703
+ "inner",
704
+ "left",
705
+ "right",
706
+ "outer",
707
+ "full",
708
+ "cross",
709
+ "lateral",
710
+ "natural",
711
+ "on",
712
+ "using",
713
+ "as",
714
+ "order",
715
+ "by",
716
+ "group",
717
+ "having",
718
+ "limit",
719
+ "offset",
720
+ "fetch",
721
+ "first",
722
+ "next",
723
+ "rows",
724
+ "only",
725
+ "union",
726
+ "intersect",
727
+ "except",
728
+ "distinct",
729
+ "all",
730
+ "exists",
731
+ "any",
732
+ "some",
733
+ "case",
734
+ "when",
735
+ "then",
736
+ "else",
737
+ "end",
738
+ "null",
739
+ "true",
740
+ "false",
741
+ "is",
742
+ "isnull",
743
+ "notnull",
744
+ "asc",
745
+ "desc",
746
+ "nulls",
747
+ "with",
748
+ "recursive",
749
+ "returning",
750
+ "into",
751
+ "values",
752
+ "set",
753
+ "default",
754
+ "begin",
755
+ "commit",
756
+ "rollback",
757
+ "savepoint",
758
+ "release",
759
+ "transaction",
760
+ "explain",
761
+ "analyze",
762
+ "verbose",
763
+ "costs",
764
+ "buffers",
765
+ "format",
766
+ "grant",
767
+ "revoke",
768
+ "truncate",
769
+ "cascade",
770
+ "restrict",
771
+ "vacuum",
772
+ "reindex",
773
+ "cluster",
774
+ "copy",
775
+ "do",
776
+ "perform",
777
+ "raise",
778
+ "notice",
779
+ "exception",
780
+ "if",
781
+ "elsif",
782
+ "loop",
783
+ "while",
784
+ "for",
785
+ "foreach",
786
+ "return",
787
+ "returns",
788
+ "language",
789
+ "plpgsql",
790
+ "declare",
791
+ "primary",
792
+ "key",
793
+ "foreign",
794
+ "references",
795
+ "unique",
796
+ "check",
797
+ "constraint",
798
+ "not",
799
+ "null",
800
+ "add",
801
+ "column",
802
+ "rename",
803
+ "to",
804
+ "owner",
805
+ "tablespace",
806
+ "temporary",
807
+ "temp",
808
+ "unlogged",
809
+ "if",
810
+ "replace",
811
+ "or",
812
+ "conflict",
813
+ "nothing",
814
+ "window",
815
+ "partition",
816
+ "over",
817
+ "range",
818
+ "unbounded",
819
+ "preceding",
820
+ "following",
821
+ "current",
822
+ "row",
823
+ "groups",
824
+ "exclude",
825
+ "ties",
826
+ "filter",
827
+ "within"
828
+ ];
829
+ const SQL_BUILTIN = [
830
+ // types
831
+ "varchar",
832
+ "char",
833
+ "text",
834
+ "integer",
835
+ "int",
836
+ "smallint",
837
+ "bigint",
838
+ "decimal",
839
+ "numeric",
840
+ "float",
841
+ "real",
842
+ "double",
843
+ "precision",
844
+ "boolean",
845
+ "bool",
846
+ "date",
847
+ "time",
848
+ "timestamp",
849
+ "timestamptz",
850
+ "interval",
851
+ "uuid",
852
+ "json",
853
+ "jsonb",
854
+ "bytea",
855
+ "serial",
856
+ "bigserial",
857
+ "smallserial",
858
+ "money",
859
+ "inet",
860
+ "cidr",
861
+ "macaddr",
862
+ "point",
863
+ "line",
864
+ "lseg",
865
+ "box",
866
+ "path",
867
+ "polygon",
868
+ "circle",
869
+ "tsquery",
870
+ "tsvector",
871
+ "xml",
872
+ "oid",
873
+ "regclass",
874
+ "regtype",
875
+ // aggregate functions
876
+ "count",
877
+ "sum",
878
+ "avg",
879
+ "min",
880
+ "max",
881
+ "array_agg",
882
+ "string_agg",
883
+ "json_agg",
884
+ "jsonb_agg",
885
+ "json_object_agg",
886
+ "jsonb_object_agg",
887
+ "bool_and",
888
+ "bool_or",
889
+ "every",
890
+ "bit_and",
891
+ "bit_or",
892
+ // window functions
893
+ "row_number",
894
+ "rank",
895
+ "dense_rank",
896
+ "percent_rank",
897
+ "cume_dist",
898
+ "ntile",
899
+ "lag",
900
+ "lead",
901
+ "first_value",
902
+ "last_value",
903
+ "nth_value",
904
+ // string functions
905
+ "coalesce",
906
+ "nullif",
907
+ "greatest",
908
+ "least",
909
+ "concat",
910
+ "concat_ws",
911
+ "substring",
912
+ "upper",
913
+ "lower",
914
+ "trim",
915
+ "ltrim",
916
+ "rtrim",
917
+ "length",
918
+ "char_length",
919
+ "octet_length",
920
+ "position",
921
+ "replace",
922
+ "translate",
923
+ "left",
924
+ "right",
925
+ "repeat",
926
+ "reverse",
927
+ "split_part",
928
+ "regexp_match",
929
+ "regexp_matches",
930
+ "regexp_replace",
931
+ "regexp_split_to_array",
932
+ "regexp_split_to_table",
933
+ "format",
934
+ "encode",
935
+ "decode",
936
+ "md5",
937
+ "starts_with",
938
+ // date/time functions
939
+ "now",
940
+ "current_date",
941
+ "current_time",
942
+ "current_timestamp",
943
+ "localtime",
944
+ "localtimestamp",
945
+ "clock_timestamp",
946
+ "statement_timestamp",
947
+ "transaction_timestamp",
948
+ "timeofday",
949
+ "age",
950
+ "date_part",
951
+ "date_trunc",
952
+ "extract",
953
+ "make_date",
954
+ "make_time",
955
+ "make_timestamp",
956
+ "make_timestamptz",
957
+ "make_interval",
958
+ "to_char",
959
+ "to_date",
960
+ "to_timestamp",
961
+ "to_number",
962
+ // json/jsonb functions
963
+ "json_build_object",
964
+ "jsonb_build_object",
965
+ "json_build_array",
966
+ "jsonb_build_array",
967
+ "json_extract_path",
968
+ "jsonb_extract_path",
969
+ "json_extract_path_text",
970
+ "jsonb_extract_path_text",
971
+ "jsonb_set",
972
+ "jsonb_insert",
973
+ "jsonb_strip_nulls",
974
+ "jsonb_pretty",
975
+ "jsonb_typeof",
976
+ "jsonb_each",
977
+ "jsonb_each_text",
978
+ "jsonb_array_elements",
979
+ "jsonb_array_elements_text",
980
+ "jsonb_array_length",
981
+ "jsonb_object_keys",
982
+ "jsonb_to_record",
983
+ "jsonb_to_recordset",
984
+ "jsonb_populate_record",
985
+ "jsonb_populate_recordset",
986
+ "jsonb_path_query",
987
+ "jsonb_path_query_array",
988
+ "jsonb_path_query_first",
989
+ "jsonb_path_exists",
990
+ "to_json",
991
+ "to_jsonb",
992
+ "row_to_json",
993
+ // array functions
994
+ "array_length",
995
+ "array_dims",
996
+ "array_lower",
997
+ "array_upper",
998
+ "array_append",
999
+ "array_prepend",
1000
+ "array_cat",
1001
+ "array_remove",
1002
+ "array_replace",
1003
+ "array_position",
1004
+ "array_positions",
1005
+ "array_to_string",
1006
+ "string_to_array",
1007
+ "unnest",
1008
+ "cardinality",
1009
+ // set-returning functions
1010
+ "generate_series",
1011
+ "generate_subscripts",
1012
+ // math functions
1013
+ "abs",
1014
+ "ceil",
1015
+ "ceiling",
1016
+ "floor",
1017
+ "round",
1018
+ "trunc",
1019
+ "sign",
1020
+ "sqrt",
1021
+ "cbrt",
1022
+ "power",
1023
+ "exp",
1024
+ "ln",
1025
+ "log",
1026
+ "mod",
1027
+ "random",
1028
+ "setseed",
1029
+ "pi",
1030
+ "degrees",
1031
+ "radians",
1032
+ // system functions
1033
+ "pg_typeof",
1034
+ "pg_size_pretty",
1035
+ "pg_table_size",
1036
+ "pg_indexes_size",
1037
+ "pg_total_relation_size",
1038
+ "pg_relation_size",
1039
+ "pg_database_size",
1040
+ "pg_cancel_backend",
1041
+ "pg_terminate_backend",
1042
+ "pg_stat_activity",
1043
+ "pg_stat_statements",
1044
+ "pg_advisory_lock",
1045
+ "pg_advisory_unlock",
1046
+ "pg_try_advisory_lock",
1047
+ // cast/conversion
1048
+ "cast",
1049
+ "pg_get_functiondef",
1050
+ "pg_get_viewdef",
1051
+ "pg_get_indexdef",
1052
+ // misc
1053
+ "exists",
1054
+ "in",
1055
+ "between",
1056
+ "like",
1057
+ "ilike",
1058
+ "similar",
1059
+ "any",
1060
+ "some",
1061
+ "row",
1062
+ "array",
1063
+ "nextval",
1064
+ "currval",
1065
+ "setval",
1066
+ "lastval",
1067
+ "txid_current"
1068
+ ];
1069
+ const customSQLDialect = SQLDialect.define({
1070
+ keywords: SQL_KEYWORDS.join(" "),
1071
+ builtin: SQL_BUILTIN.join(" ")
1072
+ });
1073
+ function computeYamlNewlineIndent(lineText) {
1074
+ const indent = lineText.match(/^(\s*)/)?.[1] ?? "";
1075
+ const trimmed = lineText.trimEnd();
1076
+ if (trimmed.endsWith(":")) {
1077
+ // After "key:" with no value — increase indent
1078
+ // For " - key:", base indent is at the dash content level
1079
+ const dashMatch = trimmed.match(/^(\s*-\s+)/);
1080
+ const baseIndent = dashMatch?.[1] ? " ".repeat(dashMatch[1].length) : indent;
1081
+ return `${baseIndent} `;
1082
+ }
1083
+ if (/^\s*-\s*$/.test(trimmed)) {
1084
+ // After bare "- " (array item marker only) — align to content after dash
1085
+ const dashMatch = trimmed.match(/^(\s*-\s*)/);
1086
+ return dashMatch?.[1] ? " ".repeat(dashMatch[1].length) : indent;
1087
+ }
1088
+ // Preserve current indent; for " - key: val" align to key level
1089
+ const dashKeyMatch = trimmed.match(/^(\s*-\s+)\S/);
1090
+ return dashKeyMatch?.[1] ? " ".repeat(dashKeyMatch[1].length) : indent;
1091
+ }
1092
+ function yamlEnterKeymap() {
1093
+ return keymap.of([
1094
+ {
1095
+ key: "Enter",
1096
+ run: (view)=>{
1097
+ const { state } = view;
1098
+ const pos = state.selection.main.head;
1099
+ const line = state.doc.lineAt(pos);
1100
+ const newIndent = computeYamlNewlineIndent(line.text);
1101
+ view.dispatch({
1102
+ changes: {
1103
+ from: pos,
1104
+ insert: `\n${newIndent}`
1105
+ },
1106
+ selection: {
1107
+ anchor: pos + 1 + newIndent.length
1108
+ }
1109
+ });
1110
+ return true;
1111
+ }
1112
+ }
1113
+ ]);
1114
+ }
1115
+ function httpYamlEnterKeymap() {
1116
+ return keymap.of([
1117
+ {
1118
+ key: "Enter",
1119
+ run: (view)=>{
1120
+ const { state } = view;
1121
+ const pos = state.selection.main.head;
1122
+ const doc = state.doc.toString();
1123
+ // Only handle if cursor is in YAML body (after blank line separator)
1124
+ const textBeforeCursor = doc.slice(0, pos);
1125
+ const blankLineIdx = textBeforeCursor.indexOf("\n\n");
1126
+ if (blankLineIdx === -1 || pos <= blankLineIdx + 1) return false;
1127
+ // Check if the body looks like YAML (not JSON)
1128
+ const bodyStart = blankLineIdx + 2;
1129
+ const bodyPrefix = doc.slice(bodyStart, bodyStart + 20).trimStart();
1130
+ if (bodyPrefix.startsWith("{") || bodyPrefix.startsWith("[")) return false;
1131
+ const line = state.doc.lineAt(pos);
1132
+ const newIndent = computeYamlNewlineIndent(line.text);
1133
+ view.dispatch({
1134
+ changes: {
1135
+ from: pos,
1136
+ insert: `\n${newIndent}`
1137
+ },
1138
+ selection: {
1139
+ anchor: pos + 1 + newIndent.length
1140
+ }
1141
+ });
1142
+ return true;
1143
+ }
1144
+ }
1145
+ ]);
1146
+ }
1147
+ function languageExtensions(mode, sqlExtraBuiltins, getUrlSuggestions) {
1148
+ if (mode === "http") {
1149
+ const jsonLang = json();
1150
+ const yamlLang = yaml();
1151
+ return [
1152
+ http((ct)=>ct === "application/json" ? jsonLang.language : ct === "text/yaml" || ct === "application/yaml" || ct === "application/x-yaml" ? yamlLang.language : null, getUrlSuggestions),
1153
+ syntaxHighlighting(customHighlightStyle),
1154
+ jsonAutoExpandBraces(),
1155
+ httpYamlEnterKeymap()
1156
+ ];
1157
+ } else if (mode === "sql") {
1158
+ let dialect = customSQLDialect;
1159
+ if (sqlExtraBuiltins && sqlExtraBuiltins.length > 0) {
1160
+ dialect = SQLDialect.define({
1161
+ keywords: SQL_KEYWORDS.join(" "),
1162
+ builtin: [
1163
+ ...SQL_BUILTIN,
1164
+ ...sqlExtraBuiltins
1165
+ ].join(" ")
1166
+ });
1167
+ }
1168
+ return [
1169
+ sql({
1170
+ dialect
1171
+ }),
1172
+ syntaxHighlighting(customHighlightStyle)
1173
+ ];
1174
+ } else if (mode === "yaml") {
1175
+ return [
1176
+ yaml(),
1177
+ syntaxHighlighting(customHighlightStyle),
1178
+ yamlEnterKeymap()
1179
+ ];
1180
+ } else {
1181
+ return [
1182
+ json(),
1183
+ linter((view)=>{
1184
+ if (!view.state.doc.toString().trim()) return [];
1185
+ return jsonParseLinter()(view);
1186
+ }, {
1187
+ delay: 300
1188
+ }),
1189
+ syntaxHighlighting(customHighlightStyle),
1190
+ jsonAutoExpandBraces()
1191
+ ];
1192
+ }
1193
+ }
1194
+ function jsonAutoExpandBraces() {
1195
+ return EditorState.transactionFilter.of((tr)=>{
1196
+ if (!tr.docChanged) return tr;
1197
+ let braceFrom = -1;
1198
+ let braceTo = -1;
1199
+ let changeCount = 0;
1200
+ tr.changes.iterChanges((fromA, toA, _fromB, _toB, inserted)=>{
1201
+ changeCount++;
1202
+ if (inserted.toString() === "{}") {
1203
+ braceFrom = fromA;
1204
+ braceTo = toA;
1205
+ }
1206
+ });
1207
+ if (changeCount !== 1 || braceFrom === -1) return tr;
1208
+ const tree = syntaxTree(tr.startState);
1209
+ const nodeBefore = tree.resolveInner(braceFrom, -1);
1210
+ if (nodeBefore.name === "String" || nodeBefore.parent?.name === "String") {
1211
+ return tr;
1212
+ }
1213
+ const line = tr.startState.doc.lineAt(braceFrom);
1214
+ const indent = line.text.match(/^(\s*)/)?.[1] ?? "";
1215
+ const inner = `${indent} `;
1216
+ // Check if { is inside an extension array — insert {"url": ""} snippet
1217
+ const docText = tr.startState.doc.toString();
1218
+ const textBefore = docText.slice(0, braceFrom);
1219
+ const isInExtArray = /"(?:extension|modifierExtension)"\s*:\s*\[\s*(?:\{[\s\S]*?\}\s*,?\s*)*$/s.test(textBefore);
1220
+ if (isInExtArray) {
1221
+ const insert = `{\n${inner}"url": ""\n${indent}}`;
1222
+ return {
1223
+ changes: {
1224
+ from: braceFrom,
1225
+ to: braceTo,
1226
+ insert
1227
+ },
1228
+ selection: {
1229
+ anchor: braceFrom + insert.lastIndexOf('""') + 1
1230
+ }
1231
+ };
1232
+ }
1233
+ return {
1234
+ changes: {
1235
+ from: braceFrom,
1236
+ to: braceTo,
1237
+ insert: `{\n${inner}\n${indent}}`
1238
+ },
1239
+ selection: {
1240
+ anchor: braceFrom + 2 + inner.length
1241
+ }
1242
+ };
1243
+ });
1244
+ }
1245
+ export function CodeEditor({ defaultValue, currentValue, onChange, onUpdate, viewCallback, readOnly = false, id, mode = "json", isReadOnlyTheme = false, additionalExtensions, issueLineNumbers, foldGutter: enableFoldGutter = true, lineNumbers: enableLineNumbers = true, sql, getStructureDefinitions, resourceTypeHint, expandValueSet, getUrlSuggestions, vimMode = false }) {
1246
+ const domRef = React.useRef(null);
1247
+ const [view, setView] = React.useState(null);
1248
+ const safeDispatch = React.useCallback((spec)=>{
1249
+ try {
1250
+ view?.dispatch(spec);
1251
+ } catch {
1252
+ // Ignore RangeError from stale decoration positions during reconfigure
1253
+ }
1254
+ }, [
1255
+ view
1256
+ ]);
1257
+ const initialValue = React.useRef(defaultValue ?? "");
1258
+ const onChangeComparment = React.useRef(new Compartment());
1259
+ const onUpdateComparment = React.useRef(new Compartment());
1260
+ const languageCompartment = React.useRef(new Compartment());
1261
+ const readOnlyCompartment = React.useRef(new Compartment());
1262
+ const themeCompartment = React.useRef(new Compartment());
1263
+ const additionalExtensionsCompartment = React.useRef(new Compartment());
1264
+ const sqlCompletionCompartment = React.useRef(new Compartment());
1265
+ const fhirCompletionCompartment = React.useRef(new Compartment());
1266
+ const vimCompartment = React.useRef(new Compartment());
1267
+ const [sqlFunctions, setSqlFunctions] = React.useState();
1268
+ const executeSqlRef = React.useRef(sql?.executeSql);
73
1269
  React.useEffect(()=>{
74
- if (!editorRef.current) {
1270
+ if (!domRef.current) {
75
1271
  return;
76
1272
  }
77
1273
  const view = new EditorView({
78
- parent: editorRef.current,
1274
+ parent: domRef.current,
79
1275
  state: EditorState.create({
80
- doc: defaultValue ?? "",
1276
+ doc: initialValue.current,
81
1277
  extensions: [
82
- lineNumbers(),
83
- foldGutter(),
1278
+ vimCompartment.current.of(vimMode ? vim() : []),
1279
+ EditorView.contentAttributes.of({
1280
+ "data-gramm": "false"
1281
+ }),
1282
+ readOnlyCompartment.current.of(EditorState.readOnly.of(false)),
1283
+ ...enableLineNumbers ? [
1284
+ lineNumbers()
1285
+ ] : [],
1286
+ ...enableFoldGutter ? [
1287
+ foldGutter({
1288
+ markerDOM: (open)=>{
1289
+ const el = document.createElement("span");
1290
+ el.style.display = "flex";
1291
+ el.style.alignItems = "center";
1292
+ el.style.justifyContent = "center";
1293
+ el.style.width = "100%";
1294
+ el.style.height = "100%";
1295
+ el.innerHTML = open ? '<svg xmlns="http://www.w3.org/2000/svg" width="12" height="12" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="m6 9 6 6 6-6"/></svg>' : '<svg xmlns="http://www.w3.org/2000/svg" width="12" height="12" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="m9 18 6-6-6-6"/></svg>';
1296
+ return el;
1297
+ }
1298
+ })
1299
+ ] : [],
84
1300
  highlightSpecialChars(),
85
1301
  history(),
86
1302
  drawSelection(),
87
1303
  dropCursor(),
88
1304
  EditorState.allowMultipleSelections.of(true),
89
1305
  indentOnInput(),
90
- json(),
91
- syntaxHighlighting(customHighlightStyle),
1306
+ languageCompartment.current.of([]),
92
1307
  bracketMatching(),
93
1308
  closeBrackets(),
94
- autocompletion(),
1309
+ autocompletion({
1310
+ icons: false,
1311
+ maxRenderedOptions: 1000,
1312
+ defaultKeymap: false,
1313
+ addToOptions: [
1314
+ {
1315
+ render: renderCompletionIcon,
1316
+ position: 20
1317
+ }
1318
+ ],
1319
+ optionClass: (_completion)=>"!px-2 !py-1 rounded-md aria-selected:!bg-bg-quaternary aria-selected:!text-text-primary hover:!bg-bg-secondary flex items-center gap-2",
1320
+ tooltipClass: (_state)=>"!bg-bg-primary rounded-md p-2 shadow-md !border-border-primary !typo-body",
1321
+ compareCompletions: (a, b)=>{
1322
+ const aIsProperty = a.type === "property" ? 0 : 1;
1323
+ const bIsProperty = b.type === "property" ? 0 : 1;
1324
+ return aIsProperty - bIsProperty;
1325
+ }
1326
+ }),
95
1327
  rectangularSelection(),
96
1328
  crosshairCursor(),
97
- highlightActiveLine(),
98
- highlightActiveLineGutter(),
99
1329
  highlightSelectionMatches(),
100
- baseTheme,
1330
+ Prec.highest(keymap.of([
1331
+ {
1332
+ key: "Tab",
1333
+ run: (v)=>{
1334
+ if (completionStatus(v.state) === "active") {
1335
+ return moveCompletionSelection(true)(v);
1336
+ }
1337
+ return false;
1338
+ }
1339
+ },
1340
+ {
1341
+ key: "Shift-Tab",
1342
+ run: (v)=>{
1343
+ if (completionStatus(v.state) === "active") {
1344
+ return moveCompletionSelection(false)(v);
1345
+ }
1346
+ return false;
1347
+ }
1348
+ },
1349
+ {
1350
+ key: "Enter",
1351
+ run: (v)=>{
1352
+ if (completionStatus(v.state) === "active") {
1353
+ return acceptCompletion(v);
1354
+ }
1355
+ return false;
1356
+ }
1357
+ }
1358
+ ])),
1359
+ themeCompartment.current.of(baseTheme),
1360
+ completionTheme,
101
1361
  keymap.of([
102
1362
  ...closeBracketsKeymap,
1363
+ ...completionKeymap.filter((b)=>b.key !== "Enter"),
103
1364
  ...defaultKeymap,
104
1365
  ...searchKeymap,
105
1366
  ...historyKeymap,
106
1367
  ...foldKeymap,
107
- ...completionKeymap,
108
1368
  ...lintKeymap
109
1369
  ]),
110
- linter(jsonParseLinter(), {
111
- delay: 300
112
- }),
113
- lintGutter(),
114
- EditorView.updateListener.of((update)=>{
115
- if (update.docChanged && onChange) {
116
- onChange(update.view.state.doc.toString());
1370
+ issueLinesField,
1371
+ errorTooltipHandler,
1372
+ EditorView.exceptionSink.of(()=>{}),
1373
+ ...customSearchExtension,
1374
+ onChangeComparment.current.of([]),
1375
+ onUpdateComparment.current.of([]),
1376
+ additionalExtensionsCompartment.current.of([]),
1377
+ sqlCompletionCompartment.current.of([]),
1378
+ fhirCompletionCompartment.current.of([])
1379
+ ]
1380
+ })
1381
+ });
1382
+ setView(()=>view);
1383
+ return ()=>{
1384
+ view.destroy();
1385
+ setView(()=>null);
1386
+ };
1387
+ }, [
1388
+ enableFoldGutter,
1389
+ enableLineNumbers,
1390
+ vimMode
1391
+ ]);
1392
+ React.useEffect(()=>{
1393
+ executeSqlRef.current = sql?.executeSql;
1394
+ });
1395
+ React.useEffect(()=>{
1396
+ if (!view || !sql) {
1397
+ if (view) {
1398
+ safeDispatch({
1399
+ effects: sqlCompletionCompartment.current.reconfigure([])
1400
+ });
1401
+ }
1402
+ setSqlFunctions(undefined);
1403
+ return;
1404
+ }
1405
+ let cancelled = false;
1406
+ fetchSqlMetadata(sql.executeSql).then((metadata)=>{
1407
+ if (cancelled) return;
1408
+ setSqlFunctions(metadata.functions);
1409
+ const extensions = buildSqlCompletionExtensions(metadata, (query, type)=>executeSqlRef.current?.(query, type) ?? Promise.resolve([]));
1410
+ safeDispatch({
1411
+ effects: sqlCompletionCompartment.current.reconfigure(extensions)
1412
+ });
1413
+ }).catch(()=>{});
1414
+ return ()=>{
1415
+ cancelled = true;
1416
+ };
1417
+ }, [
1418
+ view,
1419
+ sql,
1420
+ safeDispatch
1421
+ ]);
1422
+ React.useEffect(()=>{
1423
+ if (!view) return;
1424
+ if (getStructureDefinitions) {
1425
+ safeDispatch({
1426
+ effects: fhirCompletionCompartment.current.reconfigure(buildFhirCompletionExtension(getStructureDefinitions, resourceTypeHint, expandValueSet))
1427
+ });
1428
+ } else {
1429
+ safeDispatch({
1430
+ effects: fhirCompletionCompartment.current.reconfigure([])
1431
+ });
1432
+ }
1433
+ }, [
1434
+ view,
1435
+ getStructureDefinitions,
1436
+ resourceTypeHint,
1437
+ expandValueSet,
1438
+ safeDispatch
1439
+ ]);
1440
+ React.useEffect(()=>{
1441
+ if (viewCallback && view) {
1442
+ viewCallback(view);
1443
+ }
1444
+ }, [
1445
+ view,
1446
+ viewCallback
1447
+ ]);
1448
+ React.useEffect(()=>{
1449
+ safeDispatch({
1450
+ effects: onChangeComparment.current.reconfigure([
1451
+ EditorView.updateListener.of((update)=>{
1452
+ if (update.docChanged && onChange) {
1453
+ onChange(update.view.state.doc.toString());
1454
+ }
1455
+ })
1456
+ ])
1457
+ });
1458
+ }, [
1459
+ onChange,
1460
+ safeDispatch
1461
+ ]);
1462
+ React.useEffect(()=>{
1463
+ safeDispatch({
1464
+ effects: onUpdateComparment.current.reconfigure([
1465
+ EditorView.updateListener.of((update)=>{
1466
+ if (onUpdate) {
1467
+ onUpdate(update);
1468
+ }
1469
+ })
1470
+ ])
1471
+ });
1472
+ }, [
1473
+ onUpdate,
1474
+ safeDispatch
1475
+ ]);
1476
+ // FIXME: it is probably better to have CM manage its state.
1477
+ React.useEffect(()=>{
1478
+ if (!view || currentValue === undefined) {
1479
+ return;
1480
+ }
1481
+ const currentDoc = view.state.doc.toString();
1482
+ if (currentDoc !== currentValue) {
1483
+ safeDispatch({
1484
+ changes: {
1485
+ from: 0,
1486
+ to: currentDoc.length,
1487
+ insert: currentValue
1488
+ }
1489
+ });
1490
+ }
1491
+ }, [
1492
+ currentValue,
1493
+ view,
1494
+ safeDispatch
1495
+ ]);
1496
+ const getUrlSuggestionsRef = React.useRef(getUrlSuggestions);
1497
+ getUrlSuggestionsRef.current = getUrlSuggestions;
1498
+ const stableGetUrlSuggestions = React.useMemo(()=>{
1499
+ if (!getUrlSuggestions) return undefined;
1500
+ return (path, method)=>getUrlSuggestionsRef.current?.(path, method) ?? [];
1501
+ }, [
1502
+ getUrlSuggestions
1503
+ ]);
1504
+ React.useEffect(()=>{
1505
+ if (view === null) {
1506
+ return;
1507
+ }
1508
+ safeDispatch({
1509
+ effects: languageCompartment.current.reconfigure(languageExtensions(mode, sqlFunctions, stableGetUrlSuggestions))
1510
+ });
1511
+ }, [
1512
+ mode,
1513
+ view,
1514
+ sqlFunctions,
1515
+ stableGetUrlSuggestions,
1516
+ safeDispatch
1517
+ ]);
1518
+ React.useEffect(()=>{
1519
+ if (view === null) {
1520
+ return;
1521
+ }
1522
+ safeDispatch({
1523
+ effects: [
1524
+ readOnlyCompartment.current.reconfigure(EditorState.readOnly.of(readOnly))
1525
+ ]
1526
+ });
1527
+ }, [
1528
+ readOnly,
1529
+ view,
1530
+ safeDispatch
1531
+ ]);
1532
+ React.useEffect(()=>{
1533
+ if (view === null) {
1534
+ return;
1535
+ }
1536
+ safeDispatch({
1537
+ effects: [
1538
+ themeCompartment.current.reconfigure(isReadOnlyTheme ? readOnlyTheme : baseTheme)
1539
+ ]
1540
+ });
1541
+ }, [
1542
+ isReadOnlyTheme,
1543
+ view,
1544
+ safeDispatch
1545
+ ]);
1546
+ React.useEffect(()=>{
1547
+ if (view === null) {
1548
+ return;
1549
+ }
1550
+ safeDispatch({
1551
+ effects: [
1552
+ vimCompartment.current.reconfigure(vimMode ? vim() : [])
1553
+ ]
1554
+ });
1555
+ }, [
1556
+ vimMode,
1557
+ view,
1558
+ safeDispatch
1559
+ ]);
1560
+ React.useEffect(()=>{
1561
+ if (view === null) {
1562
+ return;
1563
+ }
1564
+ safeDispatch({
1565
+ effects: [
1566
+ additionalExtensionsCompartment.current.reconfigure(additionalExtensions ?? [])
1567
+ ]
1568
+ });
1569
+ }, [
1570
+ additionalExtensions,
1571
+ view,
1572
+ safeDispatch
1573
+ ]);
1574
+ React.useEffect(()=>{
1575
+ if (view === null) {
1576
+ return;
1577
+ }
1578
+ safeDispatch({
1579
+ effects: setIssueLinesEffect.of(issueLineNumbers ?? [])
1580
+ });
1581
+ }, [
1582
+ issueLineNumbers,
1583
+ view,
1584
+ safeDispatch
1585
+ ]);
1586
+ return /*#__PURE__*/ _jsx("div", {
1587
+ className: "h-full w-full",
1588
+ ref: domRef,
1589
+ id: id
1590
+ });
1591
+ }
1592
+ const editorInputTheme = EditorView.theme({
1593
+ ".cm-content": {
1594
+ backgroundColor: "var(--color-bg-primary)",
1595
+ border: "1px solid var(--color-border-primary)",
1596
+ borderRadius: "var(--radius-md)",
1597
+ fontFamily: "var(--font-family-sans)",
1598
+ fontWeight: "var(--font-weight-normal)",
1599
+ height: "36px",
1600
+ padding: "8px 12px 8px 12px",
1601
+ fontSize: "14px"
1602
+ },
1603
+ ".cm-editor": {
1604
+ fontSize: "var(--font-size-sm)",
1605
+ color: "var(--color-text-primary)"
1606
+ },
1607
+ ".cm-cursor, .cm-dropCursor": {
1608
+ borderLeftColor: "var(--color-text-primary)"
1609
+ },
1610
+ "&.cm-editor.cm-focused": {
1611
+ outline: "none"
1612
+ },
1613
+ "&.cm-editor.cm-focused .cm-content": {
1614
+ border: "1px solid var(--color-border-link)",
1615
+ borderRadius: "var(--radius-md)"
1616
+ },
1617
+ ".cm-line": {
1618
+ padding: "0"
1619
+ },
1620
+ ".cm-tooltip.cm-tooltip-autocomplete > ul": {
1621
+ maxHeight: "400px"
1622
+ },
1623
+ ".cm-completionInfo": {
1624
+ display: "none",
1625
+ fontFamily: "var(--font-family-sans)"
1626
+ },
1627
+ ".cm-completionLabel": {
1628
+ color: "var(--color-text-link)",
1629
+ fontSize: "14px"
1630
+ },
1631
+ ".cm-completionDetail": {
1632
+ display: "none"
1633
+ },
1634
+ ".cm-completion-icon": {
1635
+ display: "flex",
1636
+ alignItems: "center",
1637
+ justifyContent: "center",
1638
+ width: "16px",
1639
+ height: "16px",
1640
+ flexShrink: "0"
1641
+ }
1642
+ });
1643
+ const KeywordIcon = ()=>/*#__PURE__*/ _jsx(Terminal, {
1644
+ size: 16,
1645
+ color: "#717684"
1646
+ });
1647
+ const OperatorIcon = ()=>/*#__PURE__*/ _jsx(ChevronsRight, {
1648
+ size: 16,
1649
+ color: "#717684"
1650
+ });
1651
+ const TableIcon = ()=>/*#__PURE__*/ _jsx(Table2, {
1652
+ size: 16,
1653
+ color: "#717684"
1654
+ });
1655
+ const HeaderIcon = ()=>/*#__PURE__*/ _jsx(Heading, {
1656
+ size: 16,
1657
+ color: "#717684"
1658
+ });
1659
+ const ColumnIcon = ()=>/*#__PURE__*/ _jsx(Columns2, {
1660
+ size: 16,
1661
+ color: "#717684"
1662
+ });
1663
+ function getCompletionIcon(completion) {
1664
+ if (completion.type === "function") return SquareFunctionIcon;
1665
+ if (completion.type === "keyword") return KeywordIcon;
1666
+ if (completion.type === "operator") return OperatorIcon;
1667
+ if (completion.type === "table") return TableIcon;
1668
+ if (completion.type === "header") return HeaderIcon;
1669
+ if (completion.type === "text") return TypCodeIcon;
1670
+ if (completion.type === "type") return ResourceIcon;
1671
+ if (completion.type === "search-param") return null;
1672
+ const detail = completion.detail;
1673
+ if (!detail) {
1674
+ if (completion.type === "variable") return ColumnIcon;
1675
+ return TypCodeIcon;
1676
+ }
1677
+ if (completion.type === "variable") return ColumnIcon;
1678
+ const typeName = detail.replace(/\[\]$/, "");
1679
+ if (!typeName) return TypCodeIcon;
1680
+ // Search param types (TOKEN, REFERENCE) — no icon
1681
+ if (typeName === typeName.toUpperCase()) return null;
1682
+ const firstChar = typeName[0];
1683
+ if (!firstChar) return TypCodeIcon;
1684
+ const isComplex = firstChar === firstChar.toUpperCase();
1685
+ return isComplex ? ComplexTypeIcon : TypCodeIcon;
1686
+ }
1687
+ function renderCompletionIcon(completion) {
1688
+ const container = document.createElement("div");
1689
+ container.className = "cm-completion-icon";
1690
+ const Icon = getCompletionIcon(completion);
1691
+ if (Icon) {
1692
+ flushSync(()=>{
1693
+ createRoot(container).render(/*#__PURE__*/ _jsx(Icon, {}));
1694
+ });
1695
+ } else {
1696
+ container.style.display = "none";
1697
+ }
1698
+ return container;
1699
+ }
1700
+ let activeTooltip = null;
1701
+ let activeRafId = null;
1702
+ function cleanupActiveTooltip() {
1703
+ activeTooltip?.remove();
1704
+ activeTooltip = null;
1705
+ if (activeRafId !== null) {
1706
+ cancelAnimationFrame(activeRafId);
1707
+ activeRafId = null;
1708
+ }
1709
+ }
1710
+ function renderCompletionDetail(completion) {
1711
+ const detail = completion.detail;
1712
+ if (!detail) return null;
1713
+ const anchor = document.createElement("span");
1714
+ anchor.style.display = "none";
1715
+ const showTooltip = ()=>{
1716
+ cleanupActiveTooltip();
1717
+ const tooltip = document.createElement("div");
1718
+ tooltip.textContent = detail;
1719
+ Object.assign(tooltip.style, {
1720
+ position: "fixed",
1721
+ backgroundColor: "var(--color-bg-primary)",
1722
+ border: "1px solid var(--color-border-primary)",
1723
+ borderRadius: "var(--radius-md)",
1724
+ padding: "8px 12px",
1725
+ fontSize: "12px",
1726
+ lineHeight: "1.4",
1727
+ color: "var(--color-text-secondary)",
1728
+ fontFamily: "var(--font-family-sans)",
1729
+ whiteSpace: "normal",
1730
+ width: "280px",
1731
+ boxShadow: "0 4px 12px rgba(0, 0, 0, 0.1)",
1732
+ zIndex: "1000",
1733
+ pointerEvents: "none"
1734
+ });
1735
+ document.body.appendChild(tooltip);
1736
+ activeTooltip = tooltip;
1737
+ const autocompleteEl = anchor.closest(".cm-tooltip-autocomplete");
1738
+ const anchorRect = autocompleteEl ? autocompleteEl.getBoundingClientRect() : anchor.getBoundingClientRect();
1739
+ tooltip.style.top = `${anchorRect.top}px`;
1740
+ tooltip.style.left = `${anchorRect.right + 8}px`;
1741
+ const checkAlive = ()=>{
1742
+ if (!anchor.isConnected) {
1743
+ cleanupActiveTooltip();
1744
+ return;
1745
+ }
1746
+ activeRafId = requestAnimationFrame(checkAlive);
1747
+ };
1748
+ activeRafId = requestAnimationFrame(checkAlive);
1749
+ };
1750
+ requestAnimationFrame(()=>{
1751
+ const option = anchor.closest("li");
1752
+ if (!option) return;
1753
+ option.addEventListener("mouseenter", showTooltip);
1754
+ option.addEventListener("mouseleave", cleanupActiveTooltip);
1755
+ });
1756
+ return anchor;
1757
+ }
1758
+ export function EditorInput({ additionalExtensions, id, defaultValue, currentValue, onChange }) {
1759
+ const domRef = React.useRef(null);
1760
+ const [view, setView] = React.useState(null);
1761
+ const additionalExtensionsCompartment = React.useRef(new Compartment());
1762
+ const onChangeCompartment = React.useRef(new Compartment());
1763
+ const initialValue = React.useRef(defaultValue ?? "");
1764
+ React.useEffect(()=>{
1765
+ if (!domRef.current) {
1766
+ return;
1767
+ }
1768
+ const view = new EditorView({
1769
+ parent: domRef.current,
1770
+ state: EditorState.create({
1771
+ doc: initialValue.current,
1772
+ extensions: [
1773
+ autocompletion({
1774
+ icons: false,
1775
+ maxRenderedOptions: 1000,
1776
+ closeOnBlur: false,
1777
+ addToOptions: [
1778
+ {
1779
+ render: renderCompletionIcon,
1780
+ position: 20
1781
+ },
1782
+ {
1783
+ render: renderCompletionDetail,
1784
+ position: 80
1785
+ }
1786
+ ],
1787
+ optionClass: (_completion)=>"!px-2 !py-1 rounded-md aria-selected:!bg-bg-quaternary aria-selected:!text-text-primary hover:!bg-bg-secondary grid grid-cols-[16px_1fr] items-center gap-2",
1788
+ tooltipClass: (_state)=>"!bg-bg-primary rounded-md p-2 shadow-md !border-border-primary !typo-body",
1789
+ compareCompletions: (a, b)=>{
1790
+ const aIsProperty = a.type === "property" ? 0 : 1;
1791
+ const bIsProperty = b.type === "property" ? 0 : 1;
1792
+ return aIsProperty - bIsProperty;
117
1793
  }
118
- })
1794
+ }),
1795
+ closeBrackets(),
1796
+ history(),
1797
+ indentOnInput(),
1798
+ editorInputTheme,
1799
+ EditorView.contentAttributes.of({
1800
+ "data-gramm": "false"
1801
+ }),
1802
+ ...customSearchExtension,
1803
+ additionalExtensionsCompartment.current.of([]),
1804
+ onChangeCompartment.current.of([]),
1805
+ keymap.of([
1806
+ {
1807
+ key: "Tab",
1808
+ preventDefault: true,
1809
+ run: acceptCompletion
1810
+ },
1811
+ ...closeBracketsKeymap,
1812
+ ...defaultKeymap,
1813
+ ...searchKeymap,
1814
+ ...historyKeymap,
1815
+ ...foldKeymap,
1816
+ ...completionKeymap,
1817
+ ...lintKeymap
1818
+ ])
119
1819
  ]
120
1820
  })
121
1821
  });
122
- return ()=>view.destroy();
1822
+ setView(()=>view);
1823
+ return ()=>{
1824
+ view.destroy();
1825
+ setView(()=>null);
1826
+ };
1827
+ }, []);
1828
+ React.useEffect(()=>{
1829
+ if (view === null) {
1830
+ return;
1831
+ }
1832
+ view.dispatch({
1833
+ effects: [
1834
+ additionalExtensionsCompartment.current.reconfigure(additionalExtensions ?? [])
1835
+ ]
1836
+ });
1837
+ }, [
1838
+ additionalExtensions,
1839
+ view
1840
+ ]);
1841
+ React.useEffect(()=>{
1842
+ view?.dispatch({
1843
+ effects: onChangeCompartment.current.reconfigure([
1844
+ EditorView.updateListener.of((update)=>{
1845
+ if (update.docChanged && onChange) {
1846
+ onChange(update.view.state.doc.toString());
1847
+ }
1848
+ })
1849
+ ])
1850
+ });
123
1851
  }, [
124
- defaultValue,
1852
+ view,
125
1853
  onChange
126
1854
  ]);
1855
+ React.useEffect(()=>{
1856
+ if (!view || currentValue === undefined) {
1857
+ return;
1858
+ }
1859
+ const currentDoc = view.state.doc.toString();
1860
+ if (currentDoc !== currentValue) {
1861
+ view.dispatch({
1862
+ changes: {
1863
+ from: 0,
1864
+ to: currentDoc.length,
1865
+ insert: currentValue
1866
+ }
1867
+ });
1868
+ }
1869
+ }, [
1870
+ currentValue,
1871
+ view
1872
+ ]);
127
1873
  return /*#__PURE__*/ _jsx("div", {
128
1874
  className: "h-full w-full",
129
- ref: editorRef
1875
+ ref: domRef,
1876
+ id: id
130
1877
  });
131
1878
  }
132
1879