@flanksource/clicky-ui 0.2.13 → 0.2.15

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 (466) hide show
  1. package/dist/chat.cjs +20 -0
  2. package/dist/chat.cjs.map +1 -0
  3. package/dist/chat.d.ts +2 -0
  4. package/dist/chat.d.ts.map +1 -0
  5. package/dist/chat.js +20 -0
  6. package/dist/chat.js.map +1 -0
  7. package/dist/components/Combobox.cjs +5 -3
  8. package/dist/components/Combobox.cjs.map +1 -1
  9. package/dist/components/Combobox.d.ts +2 -0
  10. package/dist/components/Combobox.d.ts.map +1 -1
  11. package/dist/components/Combobox.js +5 -3
  12. package/dist/components/Combobox.js.map +1 -1
  13. package/dist/components/DateTimePicker.cjs +3 -1
  14. package/dist/components/DateTimePicker.cjs.map +1 -1
  15. package/dist/components/DateTimePicker.d.ts +5 -1
  16. package/dist/components/DateTimePicker.d.ts.map +1 -1
  17. package/dist/components/DateTimePicker.js +3 -1
  18. package/dist/components/DateTimePicker.js.map +1 -1
  19. package/dist/components/FilterBar.cjs +8 -41
  20. package/dist/components/FilterBar.cjs.map +1 -1
  21. package/dist/components/FilterBar.d.ts +0 -2
  22. package/dist/components/FilterBar.d.ts.map +1 -1
  23. package/dist/components/FilterBar.js +3 -36
  24. package/dist/components/FilterBar.js.map +1 -1
  25. package/dist/components/FormatOptionsDropdown.cjs +2 -18
  26. package/dist/components/FormatOptionsDropdown.cjs.map +1 -1
  27. package/dist/components/FormatOptionsDropdown.d.ts +1 -17
  28. package/dist/components/FormatOptionsDropdown.d.ts.map +1 -1
  29. package/dist/components/FormatOptionsDropdown.js +1 -17
  30. package/dist/components/FormatOptionsDropdown.js.map +1 -1
  31. package/dist/components/JsonSchemaForm.cjs +128 -12
  32. package/dist/components/JsonSchemaForm.cjs.map +1 -1
  33. package/dist/components/JsonSchemaForm.d.ts +1 -1
  34. package/dist/components/JsonSchemaForm.d.ts.map +1 -1
  35. package/dist/components/JsonSchemaForm.js +131 -15
  36. package/dist/components/JsonSchemaForm.js.map +1 -1
  37. package/dist/components/SecretKeySelector.cjs +1 -2
  38. package/dist/components/SecretKeySelector.cjs.map +1 -1
  39. package/dist/components/SecretKeySelector.d.ts +5 -3
  40. package/dist/components/SecretKeySelector.d.ts.map +1 -1
  41. package/dist/components/SecretKeySelector.js +2 -3
  42. package/dist/components/SecretKeySelector.js.map +1 -1
  43. package/dist/components/TreePickerField.cjs +137 -0
  44. package/dist/components/TreePickerField.cjs.map +1 -0
  45. package/dist/components/TreePickerField.d.ts +30 -0
  46. package/dist/components/TreePickerField.d.ts.map +1 -0
  47. package/dist/components/TreePickerField.js +137 -0
  48. package/dist/components/TreePickerField.js.map +1 -0
  49. package/dist/components/WorkloadPicker.cjs +6 -81
  50. package/dist/components/WorkloadPicker.cjs.map +1 -1
  51. package/dist/components/WorkloadPicker.d.ts +1 -20
  52. package/dist/components/WorkloadPicker.d.ts.map +1 -1
  53. package/dist/components/WorkloadPicker.js +3 -78
  54. package/dist/components/WorkloadPicker.js.map +1 -1
  55. package/dist/components/button-variants.cjs +30 -0
  56. package/dist/components/button-variants.cjs.map +1 -0
  57. package/dist/components/button-variants.d.ts +5 -0
  58. package/dist/components/button-variants.d.ts.map +1 -0
  59. package/dist/components/button-variants.js +30 -0
  60. package/dist/components/button-variants.js.map +1 -0
  61. package/dist/components/button.cjs +11 -82
  62. package/dist/components/button.cjs.map +1 -1
  63. package/dist/components/button.d.ts +1 -5
  64. package/dist/components/button.d.ts.map +1 -1
  65. package/dist/components/button.js +5 -76
  66. package/dist/components/button.js.map +1 -1
  67. package/dist/components/filter-bar-utils.cjs +37 -0
  68. package/dist/components/filter-bar-utils.cjs.map +1 -0
  69. package/dist/components/filter-bar-utils.d.ts +4 -0
  70. package/dist/components/filter-bar-utils.d.ts.map +1 -0
  71. package/dist/components/filter-bar-utils.js +37 -0
  72. package/dist/components/filter-bar-utils.js.map +1 -0
  73. package/dist/components/format-options.cjs +20 -0
  74. package/dist/components/format-options.cjs.map +1 -0
  75. package/dist/components/format-options.d.ts +18 -0
  76. package/dist/components/format-options.d.ts.map +1 -0
  77. package/dist/components/format-options.js +20 -0
  78. package/dist/components/format-options.js.map +1 -0
  79. package/dist/components/json-schema-form-array.cjs +13 -17
  80. package/dist/components/json-schema-form-array.cjs.map +1 -1
  81. package/dist/components/json-schema-form-array.d.ts +1 -2
  82. package/dist/components/json-schema-form-array.d.ts.map +1 -1
  83. package/dist/components/json-schema-form-array.js +3 -7
  84. package/dist/components/json-schema-form-array.js.map +1 -1
  85. package/dist/components/json-schema-form-fields.cjs +90 -232
  86. package/dist/components/json-schema-form-fields.cjs.map +1 -1
  87. package/dist/components/json-schema-form-fields.d.ts +51 -6
  88. package/dist/components/json-schema-form-fields.d.ts.map +1 -1
  89. package/dist/components/json-schema-form-fields.js +82 -224
  90. package/dist/components/json-schema-form-fields.js.map +1 -1
  91. package/dist/components/json-schema-form-object.cjs +149 -0
  92. package/dist/components/json-schema-form-object.cjs.map +1 -0
  93. package/dist/components/json-schema-form-object.d.ts +10 -0
  94. package/dist/components/json-schema-form-object.d.ts.map +1 -0
  95. package/dist/components/json-schema-form-object.js +149 -0
  96. package/dist/components/json-schema-form-object.js.map +1 -0
  97. package/dist/components/json-schema-form-preferences.cjs +41 -0
  98. package/dist/components/json-schema-form-preferences.cjs.map +1 -0
  99. package/dist/components/json-schema-form-preferences.d.ts +10 -0
  100. package/dist/components/json-schema-form-preferences.d.ts.map +1 -0
  101. package/dist/components/json-schema-form-preferences.js +41 -0
  102. package/dist/components/json-schema-form-preferences.js.map +1 -0
  103. package/dist/components/json-schema-form-render.cjs +43 -72
  104. package/dist/components/json-schema-form-render.cjs.map +1 -1
  105. package/dist/components/json-schema-form-render.d.ts +5 -33
  106. package/dist/components/json-schema-form-render.d.ts.map +1 -1
  107. package/dist/components/json-schema-form-render.js +41 -70
  108. package/dist/components/json-schema-form-render.js.map +1 -1
  109. package/dist/components/json-schema-form-resolve.cjs +9 -1
  110. package/dist/components/json-schema-form-resolve.cjs.map +1 -1
  111. package/dist/components/json-schema-form-resolve.d.ts.map +1 -1
  112. package/dist/components/json-schema-form-resolve.js +9 -1
  113. package/dist/components/json-schema-form-resolve.js.map +1 -1
  114. package/dist/components/json-schema-form-types.d.ts +58 -1
  115. package/dist/components/json-schema-form-types.d.ts.map +1 -1
  116. package/dist/components/json-schema-form-utils.cjs +96 -0
  117. package/dist/components/json-schema-form-utils.cjs.map +1 -0
  118. package/dist/components/json-schema-form-utils.d.ts +17 -0
  119. package/dist/components/json-schema-form-utils.d.ts.map +1 -0
  120. package/dist/components/json-schema-form-utils.js +96 -0
  121. package/dist/components/json-schema-form-utils.js.map +1 -0
  122. package/dist/components/loading.cjs +109 -0
  123. package/dist/components/loading.cjs.map +1 -0
  124. package/dist/components/loading.d.ts +27 -0
  125. package/dist/components/loading.d.ts.map +1 -0
  126. package/dist/components/loading.js +109 -0
  127. package/dist/components/loading.js.map +1 -0
  128. package/dist/components/workload-picker-utils.cjs +88 -0
  129. package/dist/components/workload-picker-utils.cjs.map +1 -0
  130. package/dist/components/workload-picker-utils.d.ts +34 -0
  131. package/dist/components/workload-picker-utils.d.ts.map +1 -0
  132. package/dist/components/workload-picker-utils.js +88 -0
  133. package/dist/components/workload-picker-utils.js.map +1 -0
  134. package/dist/components.cjs +18 -6
  135. package/dist/components.cjs.map +1 -1
  136. package/dist/components.d.ts +10 -3
  137. package/dist/components.d.ts.map +1 -1
  138. package/dist/components.js +16 -4
  139. package/dist/components.js.map +1 -1
  140. package/dist/data/Badge.cjs +11 -91
  141. package/dist/data/Badge.cjs.map +1 -1
  142. package/dist/data/Badge.d.ts +1 -5
  143. package/dist/data/Badge.d.ts.map +1 -1
  144. package/dist/data/Badge.js +11 -91
  145. package/dist/data/Badge.js.map +1 -1
  146. package/dist/data/Clicky.cjs +4 -3
  147. package/dist/data/Clicky.cjs.map +1 -1
  148. package/dist/data/Clicky.d.ts.map +1 -1
  149. package/dist/data/Clicky.js +4 -3
  150. package/dist/data/Clicky.js.map +1 -1
  151. package/dist/data/DataTable.cjs +161 -156
  152. package/dist/data/DataTable.cjs.map +1 -1
  153. package/dist/data/DataTable.d.ts +25 -4
  154. package/dist/data/DataTable.d.ts.map +1 -1
  155. package/dist/data/DataTable.js +140 -135
  156. package/dist/data/DataTable.js.map +1 -1
  157. package/dist/data/FilterPill.cjs +3 -0
  158. package/dist/data/FilterPill.cjs.map +1 -1
  159. package/dist/data/FilterPill.d.ts.map +1 -1
  160. package/dist/data/FilterPill.js +3 -0
  161. package/dist/data/FilterPill.js.map +1 -1
  162. package/dist/data/Icon.cjs +7 -7
  163. package/dist/data/Icon.cjs.map +1 -1
  164. package/dist/data/Icon.js +7 -7
  165. package/dist/data/Icon.js.map +1 -1
  166. package/dist/data/LogDetails.cjs +5 -14
  167. package/dist/data/LogDetails.cjs.map +1 -1
  168. package/dist/data/LogDetails.d.ts +8 -4
  169. package/dist/data/LogDetails.d.ts.map +1 -1
  170. package/dist/data/LogDetails.js +4 -13
  171. package/dist/data/LogDetails.js.map +1 -1
  172. package/dist/data/LogsTable.cjs +6 -165
  173. package/dist/data/LogsTable.cjs.map +1 -1
  174. package/dist/data/LogsTable.d.ts +2 -15
  175. package/dist/data/LogsTable.d.ts.map +1 -1
  176. package/dist/data/LogsTable.js +6 -165
  177. package/dist/data/LogsTable.js.map +1 -1
  178. package/dist/data/TimeseriesCoreBars.cjs +8 -1
  179. package/dist/data/TimeseriesCoreBars.cjs.map +1 -1
  180. package/dist/data/TimeseriesCoreBars.d.ts.map +1 -1
  181. package/dist/data/TimeseriesCoreBars.js +8 -1
  182. package/dist/data/TimeseriesCoreBars.js.map +1 -1
  183. package/dist/data/TimeseriesPanel.axes.cjs.map +1 -1
  184. package/dist/data/TimeseriesPanel.axes.js.map +1 -1
  185. package/dist/data/TreeNode.cjs +13 -7
  186. package/dist/data/TreeNode.cjs.map +1 -1
  187. package/dist/data/TreeNode.d.ts.map +1 -1
  188. package/dist/data/TreeNode.js +13 -7
  189. package/dist/data/TreeNode.js.map +1 -1
  190. package/dist/data/badge-variants.cjs +85 -0
  191. package/dist/data/badge-variants.cjs.map +1 -0
  192. package/dist/data/badge-variants.d.ts +6 -0
  193. package/dist/data/badge-variants.d.ts.map +1 -0
  194. package/dist/data/badge-variants.js +85 -0
  195. package/dist/data/badge-variants.js.map +1 -0
  196. package/dist/data/cache-browser/CacheBrowser.cjs +59 -0
  197. package/dist/data/cache-browser/CacheBrowser.cjs.map +1 -0
  198. package/dist/data/cache-browser/CacheBrowser.d.ts +26 -0
  199. package/dist/data/cache-browser/CacheBrowser.d.ts.map +1 -0
  200. package/dist/data/cache-browser/CacheBrowser.js +59 -0
  201. package/dist/data/cache-browser/CacheBrowser.js.map +1 -0
  202. package/dist/data/cache-browser/CacheDetailPanel.cjs +193 -0
  203. package/dist/data/cache-browser/CacheDetailPanel.cjs.map +1 -0
  204. package/dist/data/cache-browser/CacheDetailPanel.d.ts +20 -0
  205. package/dist/data/cache-browser/CacheDetailPanel.d.ts.map +1 -0
  206. package/dist/data/cache-browser/CacheDetailPanel.js +193 -0
  207. package/dist/data/cache-browser/CacheDetailPanel.js.map +1 -0
  208. package/dist/data/cache-browser/CacheStatsOverview.cjs +126 -0
  209. package/dist/data/cache-browser/CacheStatsOverview.cjs.map +1 -0
  210. package/dist/data/cache-browser/CacheStatsOverview.d.ts +17 -0
  211. package/dist/data/cache-browser/CacheStatsOverview.d.ts.map +1 -0
  212. package/dist/data/cache-browser/CacheStatsOverview.js +126 -0
  213. package/dist/data/cache-browser/CacheStatsOverview.js.map +1 -0
  214. package/dist/data/cache-browser/CacheTree.cjs +189 -0
  215. package/dist/data/cache-browser/CacheTree.cjs.map +1 -0
  216. package/dist/data/cache-browser/CacheTree.d.ts +27 -0
  217. package/dist/data/cache-browser/CacheTree.d.ts.map +1 -0
  218. package/dist/data/cache-browser/CacheTree.js +189 -0
  219. package/dist/data/cache-browser/CacheTree.js.map +1 -0
  220. package/dist/data/cache-browser/CacheValue.cjs +86 -0
  221. package/dist/data/cache-browser/CacheValue.cjs.map +1 -0
  222. package/dist/data/cache-browser/CacheValue.d.ts +11 -0
  223. package/dist/data/cache-browser/CacheValue.d.ts.map +1 -0
  224. package/dist/data/cache-browser/CacheValue.js +86 -0
  225. package/dist/data/cache-browser/CacheValue.js.map +1 -0
  226. package/dist/data/cache-browser/adapter.cjs +52 -0
  227. package/dist/data/cache-browser/adapter.cjs.map +1 -0
  228. package/dist/data/cache-browser/adapter.d.ts +48 -0
  229. package/dist/data/cache-browser/adapter.d.ts.map +1 -0
  230. package/dist/data/cache-browser/adapter.js +52 -0
  231. package/dist/data/cache-browser/adapter.js.map +1 -0
  232. package/dist/data/cache-browser/api.cjs +42 -0
  233. package/dist/data/cache-browser/api.cjs.map +1 -0
  234. package/dist/data/cache-browser/api.d.ts +33 -0
  235. package/dist/data/cache-browser/api.d.ts.map +1 -0
  236. package/dist/data/cache-browser/api.js +42 -0
  237. package/dist/data/cache-browser/api.js.map +1 -0
  238. package/dist/data/cache-browser/index.d.ts +9 -0
  239. package/dist/data/cache-browser/index.d.ts.map +1 -0
  240. package/dist/data/cache-browser/types.cjs +7 -0
  241. package/dist/data/cache-browser/types.cjs.map +1 -0
  242. package/dist/data/cache-browser/types.d.ts +78 -0
  243. package/dist/data/cache-browser/types.d.ts.map +1 -0
  244. package/dist/data/cache-browser/types.js +7 -0
  245. package/dist/data/cache-browser/types.js.map +1 -0
  246. package/dist/data/cells/TagList.cjs +4 -101
  247. package/dist/data/cells/TagList.cjs.map +1 -1
  248. package/dist/data/cells/TagList.d.ts +1 -49
  249. package/dist/data/cells/TagList.d.ts.map +1 -1
  250. package/dist/data/cells/TagList.js +3 -100
  251. package/dist/data/cells/TagList.js.map +1 -1
  252. package/dist/data/cells/Timestamp.cjs +3 -192
  253. package/dist/data/cells/Timestamp.cjs.map +1 -1
  254. package/dist/data/cells/Timestamp.d.ts +1 -50
  255. package/dist/data/cells/Timestamp.d.ts.map +1 -1
  256. package/dist/data/cells/Timestamp.js +2 -191
  257. package/dist/data/cells/Timestamp.js.map +1 -1
  258. package/dist/data/cells/tag-utils.cjs +103 -0
  259. package/dist/data/cells/tag-utils.cjs.map +1 -0
  260. package/dist/data/cells/tag-utils.d.ts +51 -0
  261. package/dist/data/cells/tag-utils.d.ts.map +1 -0
  262. package/dist/data/cells/tag-utils.js +103 -0
  263. package/dist/data/cells/tag-utils.js.map +1 -0
  264. package/dist/data/cells/timestamp-format.cjs +193 -0
  265. package/dist/data/cells/timestamp-format.cjs.map +1 -0
  266. package/dist/data/cells/timestamp-format.d.ts +51 -0
  267. package/dist/data/cells/timestamp-format.d.ts.map +1 -0
  268. package/dist/data/cells/timestamp-format.js +193 -0
  269. package/dist/data/cells/timestamp-format.js.map +1 -0
  270. package/dist/data/chat/Chat.cjs +48 -0
  271. package/dist/data/chat/Chat.cjs.map +1 -0
  272. package/dist/data/chat/Chat.d.ts +26 -0
  273. package/dist/data/chat/Chat.d.ts.map +1 -0
  274. package/dist/data/chat/Chat.fixtures.d.ts +6 -0
  275. package/dist/data/chat/Chat.fixtures.d.ts.map +1 -0
  276. package/dist/data/chat/Chat.js +48 -0
  277. package/dist/data/chat/Chat.js.map +1 -0
  278. package/dist/data/chat/Conversation.cjs +34 -0
  279. package/dist/data/chat/Conversation.cjs.map +1 -0
  280. package/dist/data/chat/Conversation.d.ts +11 -0
  281. package/dist/data/chat/Conversation.d.ts.map +1 -0
  282. package/dist/data/chat/Conversation.js +34 -0
  283. package/dist/data/chat/Conversation.js.map +1 -0
  284. package/dist/data/chat/Message.cjs +44 -0
  285. package/dist/data/chat/Message.cjs.map +1 -0
  286. package/dist/data/chat/Message.d.ts +10 -0
  287. package/dist/data/chat/Message.d.ts.map +1 -0
  288. package/dist/data/chat/Message.js +44 -0
  289. package/dist/data/chat/Message.js.map +1 -0
  290. package/dist/data/chat/PromptInput.cjs +61 -0
  291. package/dist/data/chat/PromptInput.cjs.map +1 -0
  292. package/dist/data/chat/PromptInput.d.ts +16 -0
  293. package/dist/data/chat/PromptInput.d.ts.map +1 -0
  294. package/dist/data/chat/PromptInput.js +61 -0
  295. package/dist/data/chat/PromptInput.js.map +1 -0
  296. package/dist/data/chat/ToolCall.cjs +92 -0
  297. package/dist/data/chat/ToolCall.cjs.map +1 -0
  298. package/dist/data/chat/ToolCall.d.ts +14 -0
  299. package/dist/data/chat/ToolCall.d.ts.map +1 -0
  300. package/dist/data/chat/ToolCall.js +92 -0
  301. package/dist/data/chat/ToolCall.js.map +1 -0
  302. package/dist/data/chat/clickyOperationsToTools.cjs +73 -0
  303. package/dist/data/chat/clickyOperationsToTools.cjs.map +1 -0
  304. package/dist/data/chat/clickyOperationsToTools.d.ts +10 -0
  305. package/dist/data/chat/clickyOperationsToTools.d.ts.map +1 -0
  306. package/dist/data/chat/clickyOperationsToTools.js +73 -0
  307. package/dist/data/chat/clickyOperationsToTools.js.map +1 -0
  308. package/dist/data/chat/index.d.ts +8 -0
  309. package/dist/data/chat/index.d.ts.map +1 -0
  310. package/dist/data/chat/types.cjs +18 -0
  311. package/dist/data/chat/types.cjs.map +1 -0
  312. package/dist/data/chat/types.d.ts +41 -0
  313. package/dist/data/chat/types.d.ts.map +1 -0
  314. package/dist/data/chat/types.js +18 -0
  315. package/dist/data/chat/types.js.map +1 -0
  316. package/dist/data/data-table-utils.cjs +55 -0
  317. package/dist/data/data-table-utils.cjs.map +1 -0
  318. package/dist/data/data-table-utils.d.ts +24 -0
  319. package/dist/data/data-table-utils.d.ts.map +1 -0
  320. package/dist/data/data-table-utils.js +55 -0
  321. package/dist/data/data-table-utils.js.map +1 -0
  322. package/dist/data/diagnostics/DiagnosticsDetailPanel.cjs +2 -1
  323. package/dist/data/diagnostics/DiagnosticsDetailPanel.cjs.map +1 -1
  324. package/dist/data/diagnostics/DiagnosticsDetailPanel.d.ts.map +1 -1
  325. package/dist/data/diagnostics/DiagnosticsDetailPanel.js +3 -2
  326. package/dist/data/diagnostics/DiagnosticsDetailPanel.js.map +1 -1
  327. package/dist/data/diagnostics/GoroutineCard.cjs +3 -22
  328. package/dist/data/diagnostics/GoroutineCard.cjs.map +1 -1
  329. package/dist/data/diagnostics/GoroutineCard.d.ts +0 -2
  330. package/dist/data/diagnostics/GoroutineCard.d.ts.map +1 -1
  331. package/dist/data/diagnostics/GoroutineCard.js +2 -21
  332. package/dist/data/diagnostics/GoroutineCard.js.map +1 -1
  333. package/dist/data/diagnostics/ThreadCard.cjs +3 -38
  334. package/dist/data/diagnostics/ThreadCard.cjs.map +1 -1
  335. package/dist/data/diagnostics/ThreadCard.d.ts +0 -2
  336. package/dist/data/diagnostics/ThreadCard.d.ts.map +1 -1
  337. package/dist/data/diagnostics/ThreadCard.js +2 -37
  338. package/dist/data/diagnostics/ThreadCard.js.map +1 -1
  339. package/dist/data/diagnostics/state-styles.cjs +59 -0
  340. package/dist/data/diagnostics/state-styles.cjs.map +1 -0
  341. package/dist/data/diagnostics/state-styles.d.ts +5 -0
  342. package/dist/data/diagnostics/state-styles.d.ts.map +1 -0
  343. package/dist/data/diagnostics/state-styles.js +59 -0
  344. package/dist/data/diagnostics/state-styles.js.map +1 -0
  345. package/dist/data/logs-normalize.cjs +166 -0
  346. package/dist/data/logs-normalize.cjs.map +1 -0
  347. package/dist/data/logs-normalize.d.ts +16 -0
  348. package/dist/data/logs-normalize.d.ts.map +1 -0
  349. package/dist/data/logs-normalize.js +166 -0
  350. package/dist/data/logs-normalize.js.map +1 -0
  351. package/dist/data/task-status.cjs +19 -19
  352. package/dist/data/task-status.cjs.map +1 -1
  353. package/dist/data/task-status.js +19 -19
  354. package/dist/data/task-status.js.map +1 -1
  355. package/dist/data/version-info.cjs +3 -3
  356. package/dist/data/version-info.js +3 -3
  357. package/dist/data.cjs +43 -18
  358. package/dist/data.cjs.map +1 -1
  359. package/dist/data.d.ts +11 -5
  360. package/dist/data.d.ts.map +1 -1
  361. package/dist/data.js +30 -5
  362. package/dist/data.js.map +1 -1
  363. package/dist/hooks/density-provider.cjs +38 -0
  364. package/dist/hooks/density-provider.cjs.map +1 -0
  365. package/dist/hooks/density-provider.d.ts +20 -0
  366. package/dist/hooks/density-provider.d.ts.map +1 -0
  367. package/dist/hooks/density-provider.js +38 -0
  368. package/dist/hooks/density-provider.js.map +1 -0
  369. package/dist/hooks/theme-provider.cjs +43 -0
  370. package/dist/hooks/theme-provider.cjs.map +1 -0
  371. package/dist/hooks/theme-provider.d.ts +9 -0
  372. package/dist/hooks/theme-provider.d.ts.map +1 -0
  373. package/dist/hooks/theme-provider.js +43 -0
  374. package/dist/hooks/theme-provider.js.map +1 -0
  375. package/dist/hooks/use-density.cjs +8 -37
  376. package/dist/hooks/use-density.cjs.map +1 -1
  377. package/dist/hooks/use-density.d.ts +5 -20
  378. package/dist/hooks/use-density.d.ts.map +1 -1
  379. package/dist/hooks/use-density.js +9 -38
  380. package/dist/hooks/use-density.js.map +1 -1
  381. package/dist/hooks/use-theme.cjs +10 -43
  382. package/dist/hooks/use-theme.cjs.map +1 -1
  383. package/dist/hooks/use-theme.d.ts +6 -9
  384. package/dist/hooks/use-theme.d.ts.map +1 -1
  385. package/dist/hooks/use-theme.js +11 -44
  386. package/dist/hooks/use-theme.js.map +1 -1
  387. package/dist/hooks.cjs +5 -2
  388. package/dist/hooks.cjs.map +1 -1
  389. package/dist/hooks.d.ts +4 -2
  390. package/dist/hooks.d.ts.map +1 -1
  391. package/dist/hooks.js +5 -2
  392. package/dist/hooks.js.map +1 -1
  393. package/dist/icons/changeIconAliases.cjs +13 -13
  394. package/dist/icons/changeIconAliases.cjs.map +1 -1
  395. package/dist/icons/changeIconAliases.d.ts.map +1 -1
  396. package/dist/icons/changeIconAliases.js +13 -13
  397. package/dist/icons/changeIconAliases.js.map +1 -1
  398. package/dist/index.cjs +71 -30
  399. package/dist/index.cjs.map +1 -1
  400. package/dist/index.js +53 -12
  401. package/dist/index.js.map +1 -1
  402. package/dist/overlay/DropdownMenu.cjs +2 -0
  403. package/dist/overlay/DropdownMenu.cjs.map +1 -1
  404. package/dist/overlay/DropdownMenu.d.ts +3 -1
  405. package/dist/overlay/DropdownMenu.d.ts.map +1 -1
  406. package/dist/overlay/DropdownMenu.js +2 -0
  407. package/dist/overlay/DropdownMenu.js.map +1 -1
  408. package/dist/overlay/Modal.cjs +11 -4
  409. package/dist/overlay/Modal.cjs.map +1 -1
  410. package/dist/overlay/Modal.d.ts +1 -1
  411. package/dist/overlay/Modal.d.ts.map +1 -1
  412. package/dist/overlay/Modal.js +11 -4
  413. package/dist/overlay/Modal.js.map +1 -1
  414. package/dist/overlay/modalStack.cjs +35 -0
  415. package/dist/overlay/modalStack.cjs.map +1 -0
  416. package/dist/overlay/modalStack.d.ts +13 -0
  417. package/dist/overlay/modalStack.d.ts.map +1 -0
  418. package/dist/overlay/modalStack.js +35 -0
  419. package/dist/overlay/modalStack.js.map +1 -0
  420. package/dist/rpc/AcceptPicker.cjs +2 -18
  421. package/dist/rpc/AcceptPicker.cjs.map +1 -1
  422. package/dist/rpc/AcceptPicker.d.ts +1 -41
  423. package/dist/rpc/AcceptPicker.d.ts.map +1 -1
  424. package/dist/rpc/AcceptPicker.js +2 -18
  425. package/dist/rpc/AcceptPicker.js.map +1 -1
  426. package/dist/rpc/CommandOutput.cjs +1 -1
  427. package/dist/rpc/CommandOutput.cjs.map +1 -1
  428. package/dist/rpc/CommandOutput.js +1 -1
  429. package/dist/rpc/CommandOutput.js.map +1 -1
  430. package/dist/rpc/EndpointList.cjs +1 -1
  431. package/dist/rpc/EndpointList.cjs.map +1 -1
  432. package/dist/rpc/EndpointList.js +1 -1
  433. package/dist/rpc/EndpointList.js.map +1 -1
  434. package/dist/rpc/OperationCatalog.cjs +23 -41
  435. package/dist/rpc/OperationCatalog.cjs.map +1 -1
  436. package/dist/rpc/OperationCatalog.d.ts.map +1 -1
  437. package/dist/rpc/OperationCatalog.js +24 -42
  438. package/dist/rpc/OperationCatalog.js.map +1 -1
  439. package/dist/rpc/OperationCommandPage.cjs.map +1 -1
  440. package/dist/rpc/OperationCommandPage.d.ts.map +1 -1
  441. package/dist/rpc/OperationCommandPage.js.map +1 -1
  442. package/dist/rpc/accept-options.cjs +20 -0
  443. package/dist/rpc/accept-options.cjs.map +1 -0
  444. package/dist/rpc/accept-options.d.ts +42 -0
  445. package/dist/rpc/accept-options.d.ts.map +1 -0
  446. package/dist/rpc/accept-options.js +20 -0
  447. package/dist/rpc/accept-options.js.map +1 -0
  448. package/dist/rpc/classify.cjs +15 -4
  449. package/dist/rpc/classify.cjs.map +1 -1
  450. package/dist/rpc/classify.d.ts.map +1 -1
  451. package/dist/rpc/classify.js +15 -4
  452. package/dist/rpc/classify.js.map +1 -1
  453. package/dist/rpc/clickyMetadata.cjs +13 -3
  454. package/dist/rpc/clickyMetadata.cjs.map +1 -1
  455. package/dist/rpc/clickyMetadata.d.ts +2 -0
  456. package/dist/rpc/clickyMetadata.d.ts.map +1 -1
  457. package/dist/rpc/clickyMetadata.js +14 -4
  458. package/dist/rpc/clickyMetadata.js.map +1 -1
  459. package/dist/rpc.cjs +3 -2
  460. package/dist/rpc.cjs.map +1 -1
  461. package/dist/rpc.d.ts +2 -1
  462. package/dist/rpc.d.ts.map +1 -1
  463. package/dist/rpc.js +2 -1
  464. package/dist/rpc.js.map +1 -1
  465. package/dist/styles.css +1 -1
  466. package/package.json +16 -1
@@ -1 +1 @@
1
- {"version":3,"file":"TimeseriesCoreBars.cjs","sources":["../../src/data/TimeseriesCoreBars.tsx"],"sourcesContent":["import { useQueries } from \"@tanstack/react-query\";\nimport { useMemo } from \"react\";\nimport { cn } from \"../lib/utils\";\nimport { Icon, type StaticIconComponent } from \"./Icon\";\nimport type { GaugeSeries } from \"./TimeseriesGauge\";\nimport type { TimeseriesResponse } from \"./TimeseriesPanel\";\n\nexport interface TimeseriesCoreBarsProps {\n /** Common prefix; the value/max requests are `baseUrl + id`. */\n baseUrl?: string;\n /** The metric whose latest value (CPU millicores) fills the bars. */\n value: GaugeSeries;\n /**\n * The CPU capacity. Either a `.limit`-style metric series (its latest value in\n * millicores) or a fixed number of millicores. Determines the number of bars\n * (one per core). When omitted or 0, the bar count falls back to the ceiling of\n * the usage in cores so an unbounded reading still renders.\n */\n max?: GaugeSeries | number;\n title: string;\n /** Iconify name or static icon component shown beside the label. */\n icon?: string | StaticIconComponent;\n /** Look-back window passed as ?since=; defaults to \"1h\". */\n range?: string;\n /** Poll interval in ms; defaults to 5000. Pass 0 to disable polling. */\n refreshMs?: number;\n /**\n * Utilisation thresholds (percent of capacity) at which the fill turns amber\n * then red. Defaults to [75, 90].\n */\n thresholds?: [warning: number, danger: number];\n /** Override the default fetch (e.g. to route through an app's API client). */\n fetcher?: (url: string) => Promise<TimeseriesResponse>;\n className?: string;\n}\n\nconst defaultFetcher = async (url: string): Promise<TimeseriesResponse> => {\n const res = await fetch(url);\n if (!res.ok) throw new Error(`metrics request failed: ${res.status}`);\n return res.json();\n};\n\nfunction latestValue(resp: TimeseriesResponse | undefined): number | undefined {\n const points = resp?.points;\n if (!points || points.length === 0) return undefined;\n return points[points.length - 1]?.value;\n}\n\nfunction toneClass(pct: number, [warn, danger]: [number, number]): string {\n if (pct >= danger) return \"bg-red-500\";\n if (pct >= warn) return \"bg-amber-500\";\n return \"bg-emerald-500\";\n}\n\nexport interface CoreBar {\n /** Fraction of this core that is in use, in [0, 1]. */\n fill: number;\n}\n\nexport interface CoreBarsModel {\n /** Whether a usage reading was available. */\n hasUsage: boolean;\n /** Usage expressed in cores (millicores / 1000). */\n usageCores: number;\n /** Capacity in cores; undefined when no limit was resolved. */\n limitCores?: number;\n /** Number of bars rendered (one per core). */\n coreCount: number;\n /** Utilisation percentage of capacity; 0 when unbounded. */\n pct: number;\n /** Per-core fill fractions, left to right. */\n bars: CoreBar[];\n}\n\nconst clamp01 = (n: number): number => Math.min(1, Math.max(0, n));\n\n// deriveCoreBars turns the latest usage/limit millicore readings into a per-core\n// bar model: one bar per core (ceil of the limit), filled left to right by usage\n// so the bar straddling the usage boundary is partially filled and the remainder\n// stays empty. When the limit is missing or 0 the bar count falls back to the\n// ceiling of the usage so an unbounded reading still renders sensibly.\nexport function deriveCoreBars(\n usageMilli: number | undefined,\n limitMilli: number | undefined,\n): CoreBarsModel {\n const hasUsage = usageMilli !== undefined;\n const usageCores = (usageMilli ?? 0) / 1000;\n const hasLimit = limitMilli !== undefined && limitMilli > 0;\n const limitCores = hasLimit ? (limitMilli as number) / 1000 : undefined;\n\n const coreCount = Math.max(\n 1,\n Math.ceil(hasLimit ? (limitCores as number) : usageCores),\n );\n const pct = hasLimit\n ? Math.min(100, Math.round((usageCores / (limitCores as number)) * 100))\n : 0;\n\n const bars: CoreBar[] = Array.from({ length: coreCount }, (_, i) => ({\n fill: clamp01(usageCores - i),\n }));\n\n return { hasUsage, usageCores, limitCores, coreCount, pct, bars };\n}\n\nfunction CoreBarsIcon({ icon }: { icon: string | StaticIconComponent }) {\n if (typeof icon === \"string\") {\n return <Icon name={icon} width={14} height={14} className=\"text-muted-foreground\" />;\n }\n return <Icon icon={icon} width={14} height={14} className=\"text-muted-foreground\" />;\n}\n\nfunction formatCores(cores: number): string {\n return Number.isInteger(cores) ? String(cores) : cores.toFixed(1);\n}\n\n/**\n * TimeseriesCoreBars renders CPU utilisation as a row of vertical bars — one bar\n * per core (the ceiling of the CPU limit) — filled left to right by the latest\n * usage. The bar that straddles the usage boundary is partially filled (\"blocked\n * out\") to show the fractional core in use, and the trailing bars stay empty to\n * show headroom. Both usage and limit are read live from the timeseries store,\n * mirroring TimeseriesGauge's data plumbing; the bar colour crosses warning and\n * danger thresholds. A \"<used> / <cores>\" caption sits below with the icon+title.\n */\nexport function TimeseriesCoreBars({\n baseUrl = \"\",\n value,\n max,\n title,\n icon,\n range = \"1h\",\n refreshMs = 5000,\n thresholds = [75, 90],\n fetcher = defaultFetcher,\n className,\n}: TimeseriesCoreBarsProps) {\n const maxIsSeries = typeof max === \"object\";\n const maxSeries = maxIsSeries ? max : undefined;\n const ids = useMemo(() => {\n const list = [value.id];\n if (maxSeries) list.push(maxSeries.id);\n return list;\n }, [value.id, maxSeries]);\n\n const results = useQueries({\n queries: ids.map((id) => {\n const u = new URL(baseUrl + id, window.location.origin);\n if (range) u.searchParams.set(\"since\", range);\n const requestUrl = u.pathname + u.search;\n return {\n queryKey: [\"timeseries\", requestUrl],\n queryFn: () => fetcher(requestUrl),\n refetchInterval: refreshMs > 0 ? refreshMs : false,\n staleTime: 0,\n retry: 0,\n };\n }),\n });\n\n const rawValue = latestValue(results[0]?.data);\n const usage = rawValue === undefined ? undefined : value.transform ? value.transform(rawValue) : rawValue;\n\n let limit: number | undefined;\n if (typeof max === \"number\") {\n limit = max;\n } else if (maxSeries) {\n const rawMax = latestValue(results[1]?.data);\n limit = rawMax === undefined ? undefined : maxSeries.transform ? maxSeries.transform(rawMax) : rawMax;\n }\n\n const model = deriveCoreBars(usage, limit);\n const tone = toneClass(model.pct, thresholds);\n const caption = model.hasUsage\n ? `${formatCores(model.usageCores)} / ${model.limitCores !== undefined ? formatCores(model.limitCores) : \"?\"} cores`\n : \"—\";\n\n return (\n <div className={cn(\"flex flex-col items-center gap-1\", className)}>\n <div className=\"flex h-10 items-end gap-0.5\">\n {model.bars.map((bar, i) => {\n const corePct = Math.round(bar.fill * 100);\n return (\n <div\n key={i}\n className=\"relative h-full w-2 overflow-hidden rounded-sm bg-muted\"\n title={`core ${i + 1}: ${corePct}%`}\n aria-label={`core ${i + 1}: ${corePct}%`}\n data-fill={bar.fill}\n >\n <div\n className={cn(\"absolute inset-x-0 bottom-0 transition-all duration-300\", tone)}\n style={{ height: `${corePct}%` }}\n />\n </div>\n );\n })}\n </div>\n <span className=\"text-xs font-semibold text-foreground\">{caption}</span>\n <div className=\"flex items-center gap-1 text-xs text-muted-foreground\">\n {icon ? <CoreBarsIcon icon={icon} /> : null}\n <span>{title}</span>\n </div>\n </div>\n );\n}\n"],"names":["jsx","Icon","useMemo","useQueries","cn","jsxs"],"mappings":";;;;;;;AAoCA,MAAM,iBAAiB,OAAO,QAA6C;AACzE,QAAM,MAAM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AA,EAAA,GACF;AAEJ;;;"}
1
+ {"version":3,"file":"TimeseriesCoreBars.cjs","sources":["../../src/data/TimeseriesCoreBars.tsx"],"sourcesContent":["import { useQueries } from \"@tanstack/react-query\";\nimport { useMemo } from \"react\";\nimport { cn } from \"../lib/utils\";\nimport { Icon, type StaticIconComponent } from \"./Icon\";\nimport type { GaugeSeries } from \"./TimeseriesGauge\";\nimport type { TimeseriesResponse } from \"./TimeseriesPanel\";\n\nexport interface TimeseriesCoreBarsProps {\n /** Common prefix; the value/max requests are `baseUrl + id`. */\n baseUrl?: string;\n /** The metric whose latest value (CPU millicores) fills the bars. */\n value: GaugeSeries;\n /**\n * The CPU capacity. Either a `.limit`-style metric series (its latest value in\n * millicores) or a fixed number of millicores. Determines the number of bars\n * (one per core). When omitted or 0, the bar count falls back to the ceiling of\n * the usage in cores so an unbounded reading still renders.\n */\n max?: GaugeSeries | number;\n title: string;\n /** Iconify name or static icon component shown beside the label. */\n icon?: string | StaticIconComponent;\n /** Look-back window passed as ?since=; defaults to \"1h\". */\n range?: string;\n /** Poll interval in ms; defaults to 5000. Pass 0 to disable polling. */\n refreshMs?: number;\n /**\n * Utilisation thresholds (percent of capacity) at which the fill turns amber\n * then red. Defaults to [75, 90].\n */\n thresholds?: [warning: number, danger: number];\n /** Override the default fetch (e.g. to route through an app's API client). */\n fetcher?: (url: string) => Promise<TimeseriesResponse>;\n className?: string;\n}\n\nconst defaultFetcher = async (url: string): Promise<TimeseriesResponse> => {\n const res = await fetch(url);\n if (!res.ok) throw new Error(`metrics request failed: ${res.status}`);\n return res.json();\n};\n\nfunction latestValue(resp: TimeseriesResponse | undefined): number | undefined {\n const points = resp?.points;\n if (!points || points.length === 0) return undefined;\n return points[points.length - 1]?.value;\n}\n\nfunction toneClass(pct: number, [warn, danger]: [number, number]): string {\n if (pct >= danger) return \"bg-red-500\";\n if (pct >= warn) return \"bg-amber-500\";\n return \"bg-emerald-500\";\n}\n\nexport interface CoreBar {\n /** Fraction of this core that is in use, in [0, 1]. */\n fill: number;\n}\n\nexport interface CoreBarsModel {\n /** Whether a usage reading was available. */\n hasUsage: boolean;\n /** Usage expressed in cores (millicores / 1000). */\n usageCores: number;\n /** Capacity in cores; undefined when no limit was resolved. */\n limitCores?: number;\n /** Number of bars rendered (one per core). */\n coreCount: number;\n /** Utilisation percentage of capacity; 0 when unbounded. */\n pct: number;\n /** Per-core fill fractions, left to right. */\n bars: CoreBar[];\n}\n\nconst clamp01 = (n: number): number => Math.min(1, Math.max(0, n));\n\n// deriveCoreBars turns the latest usage/limit millicore readings into a per-core\n// bar model: one bar per core (ceil of the limit), filled left to right by usage\n// so the bar straddling the usage boundary is partially filled and the remainder\n// stays empty. When the limit is missing or 0 the bar count falls back to the\n// ceiling of the usage so an unbounded reading still renders sensibly.\nexport function deriveCoreBars(\n usageMilli: number | undefined,\n limitMilli: number | undefined,\n): CoreBarsModel {\n const hasUsage = usageMilli !== undefined;\n const usageCores = (usageMilli ?? 0) / 1000;\n const hasLimit = limitMilli !== undefined && limitMilli > 0;\n const limitCores = hasLimit ? (limitMilli as number) / 1000 : undefined;\n\n const coreCount = Math.max(\n 1,\n Math.ceil(hasLimit ? (limitCores as number) : usageCores),\n );\n const pct = hasLimit\n ? Math.min(100, Math.round((usageCores / (limitCores as number)) * 100))\n : 0;\n\n const bars: CoreBar[] = Array.from({ length: coreCount }, (_, i) => ({\n fill: clamp01(usageCores - i),\n }));\n\n // limitCores is an optional field under exactOptionalPropertyTypes — only set\n // the key when a limit resolved, rather than assigning an explicit undefined.\n return {\n hasUsage,\n usageCores,\n coreCount,\n pct,\n bars,\n ...(limitCores !== undefined && { limitCores }),\n };\n}\n\nfunction CoreBarsIcon({ icon }: { icon: string | StaticIconComponent }) {\n if (typeof icon === \"string\") {\n return <Icon name={icon} width={14} height={14} className=\"text-muted-foreground\" />;\n }\n return <Icon icon={icon} width={14} height={14} className=\"text-muted-foreground\" />;\n}\n\nfunction formatCores(cores: number): string {\n return Number.isInteger(cores) ? String(cores) : cores.toFixed(1);\n}\n\n/**\n * TimeseriesCoreBars renders CPU utilisation as a row of vertical bars — one bar\n * per core (the ceiling of the CPU limit) — filled left to right by the latest\n * usage. The bar that straddles the usage boundary is partially filled (\"blocked\n * out\") to show the fractional core in use, and the trailing bars stay empty to\n * show headroom. Both usage and limit are read live from the timeseries store,\n * mirroring TimeseriesGauge's data plumbing; the bar colour crosses warning and\n * danger thresholds. A \"<used> / <cores>\" caption sits below with the icon+title.\n */\nexport function TimeseriesCoreBars({\n baseUrl = \"\",\n value,\n max,\n title,\n icon,\n range = \"1h\",\n refreshMs = 5000,\n thresholds = [75, 90],\n fetcher = defaultFetcher,\n className,\n}: TimeseriesCoreBarsProps) {\n const maxIsSeries = typeof max === \"object\";\n const maxSeries = maxIsSeries ? max : undefined;\n const ids = useMemo(() => {\n const list = [value.id];\n if (maxSeries) list.push(maxSeries.id);\n return list;\n }, [value.id, maxSeries]);\n\n const results = useQueries({\n queries: ids.map((id) => {\n const u = new URL(baseUrl + id, window.location.origin);\n if (range) u.searchParams.set(\"since\", range);\n const requestUrl = u.pathname + u.search;\n return {\n queryKey: [\"timeseries\", requestUrl],\n queryFn: () => fetcher(requestUrl),\n refetchInterval: refreshMs > 0 ? refreshMs : false,\n staleTime: 0,\n retry: 0,\n };\n }),\n });\n\n const rawValue = latestValue(results[0]?.data);\n const usage = rawValue === undefined ? undefined : value.transform ? value.transform(rawValue) : rawValue;\n\n let limit: number | undefined;\n if (typeof max === \"number\") {\n limit = max;\n } else if (maxSeries) {\n const rawMax = latestValue(results[1]?.data);\n limit = rawMax === undefined ? undefined : maxSeries.transform ? maxSeries.transform(rawMax) : rawMax;\n }\n\n const model = deriveCoreBars(usage, limit);\n const tone = toneClass(model.pct, thresholds);\n const caption = model.hasUsage\n ? `${formatCores(model.usageCores)} / ${model.limitCores !== undefined ? formatCores(model.limitCores) : \"?\"} cores`\n : \"—\";\n\n return (\n <div className={cn(\"flex flex-col items-center gap-1\", className)}>\n <div className=\"flex h-10 items-end gap-0.5\">\n {model.bars.map((bar, i) => {\n const corePct = Math.round(bar.fill * 100);\n return (\n <div\n key={i}\n className=\"relative h-full w-2 overflow-hidden rounded-sm bg-muted\"\n title={`core ${i + 1}: ${corePct}%`}\n aria-label={`core ${i + 1}: ${corePct}%`}\n data-fill={bar.fill}\n >\n <div\n className={cn(\"absolute inset-x-0 bottom-0 transition-all duration-300\", tone)}\n style={{ height: `${corePct}%` }}\n />\n </div>\n );\n })}\n </div>\n <span className=\"text-xs font-semibold text-foreground\">{caption}</span>\n <div className=\"flex items-center gap-1 text-xs text-muted-foreground\">\n {icon ? <CoreBarsIcon icon={icon} /> : null}\n <span>{title}</span>\n </div>\n </div>\n );\n}\n"],"names":["jsx","Icon","useMemo","useQueries","cn","jsxs"],"mappings":";;;;;;;AAoCA,MAAM,iBAAiB,OAAO,QAA6C;AACzE,QAAM,MAAM,MAAM,MAAM,GAAG;AAC3B,MAAI,CAAC,IAAI,GAAI,OAAM,IAAI,MAAM,2BAA2B,IAAI,MAAM,EAAE;AACpE,SAAO,IAAI,KAAA;AACb;AAEA,SAAS,YAAY,MAA0D;;AAC7E,QAAM,SAAS,6BAAM;AACrB,MAAI,CAAC,UAAU,OAAO,WAAW,EAAG,QAAO;AAC3C,UAAO,YAAO,OAAO,SAAS,CAAC,MAAxB,mBAA2B;AACpC;AAEA,SAAS,UAAU,KAAa,CAAC,MAAM,MAAM,GAA6B;AACxE,MAAI,OAAO,OAAQ,QAAO;AAC1B,MAAI,OAAO,KAAM,QAAO;AACxB,SAAO;AACT;AAsBA,MAAM,UAAU,CAAC,MAAsB,KAAK,IAAI,GAAG,KAAK,IAAI,GAAG,CAAC,CAAC;AAO1D,SAAS,eACd,YACA,YACe;AACf,QAAM,WAAW,eAAe;AAChC,QAAM,cAAc,cAAc,KAAK;AACvC,QAAM,WAAW,eAAe,UAAa,aAAa;AAC1D,QAAM,aAAa,WAAY,aAAwB,MAAO;AAE9D,QAAM,YAAY,KAAK;AAAA,IACrB;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AC,EACjC,OAAY,EACZ,KAAK,EACL,GAAG,EACH,KAAK,EACL,IAAI,EACJ,KAAY,EACZ,SAAgB,EAChB,UAAqB,EACrB,OAAwB,EACxB,SAAS,GACV,EAAE,uBAAuB,2CAqEzB"}
@@ -33,7 +33,14 @@ function deriveCoreBars(usageMilli, limitMilli) {
33
33
  const bars = Array.from({ length: coreCount }, (_, i) => ({
34
34
  fill: clamp01(usageCores - i)
35
35
  }));
36
- return { hasUsage, usageCores, limitCores, coreCount, pct, bars };
36
+ return {
37
+ hasUsage,
38
+ usageCores,
39
+ coreCount,
40
+ pct,
41
+ bars,
42
+ ...limitCores !== void 0 && { limitCores }
43
+ };
37
44
  }
38
45
  function CoreBarsIcon({ icon }) {
39
46
  if (typeof icon === "string") {
@@ -1 +1 @@
1
- {"version":3,"file":"TimeseriesCoreBars.js","sources":["../../src/data/TimeseriesCoreBars.tsx"],"sourcesContent":["import { useQueries } from \"@tanstack/react-query\";\nimport { useMemo } from \"react\";\nimport { cn } from \"../lib/utils\";\nimport { Icon, type StaticIconComponent } from \"./Icon\";\nimport type { GaugeSeries } from \"./TimeseriesGauge\";\nimport type { TimeseriesResponse } from \"./TimeseriesPanel\";\n\nexport interface TimeseriesCoreBarsProps {\n /** Common prefix; the value/max requests are `baseUrl + id`. */\n baseUrl?: string;\n /** The metric whose latest value (CPU millicores) fills the bars. */\n value: GaugeSeries;\n /**\n * The CPU capacity. Either a `.limit`-style metric series (its latest value in\n * millicores) or a fixed number of millicores. Determines the number of bars\n * (one per core). When omitted or 0, the bar count falls back to the ceiling of\n * the usage in cores so an unbounded reading still renders.\n */\n max?: GaugeSeries | number;\n title: string;\n /** Iconify name or static icon component shown beside the label. */\n icon?: string | StaticIconComponent;\n /** Look-back window passed as ?since=; defaults to \"1h\". */\n range?: string;\n /** Poll interval in ms; defaults to 5000. Pass 0 to disable polling. */\n refreshMs?: number;\n /**\n * Utilisation thresholds (percent of capacity) at which the fill turns amber\n * then red. Defaults to [75, 90].\n */\n thresholds?: [warning: number, danger: number];\n /** Override the default fetch (e.g. to route through an app's API client). */\n fetcher?: (url: string) => Promise<TimeseriesResponse>;\n className?: string;\n}\n\nconst defaultFetcher = async (url: string): Promise<TimeseriesResponse> => {\n const res = await fetch(url);\n if (!res.ok) throw new Error(`metrics request failed: ${res.status}`);\n return res.json();\n};\n\nfunction latestValue(resp: TimeseriesResponse | undefined): number | undefined {\n const points = resp?.points;\n if (!points || points.length === 0) return undefined;\n return points[points.length - 1]?.value;\n}\n\nfunction toneClass(pct: number, [warn, danger]: [number, number]): string {\n if (pct >= danger) return \"bg-red-500\";\n if (pct >= warn) return \"bg-amber-500\";\n return \"bg-emerald-500\";\n}\n\nexport interface CoreBar {\n /** Fraction of this core that is in use, in [0, 1]. */\n fill: number;\n}\n\nexport interface CoreBarsModel {\n /** Whether a usage reading was available. */\n hasUsage: boolean;\n /** Usage expressed in cores (millicores / 1000). */\n usageCores: number;\n /** Capacity in cores; undefined when no limit was resolved. */\n limitCores?: number;\n /** Number of bars rendered (one per core). */\n coreCount: number;\n /** Utilisation percentage of capacity; 0 when unbounded. */\n pct: number;\n /** Per-core fill fractions, left to right. */\n bars: CoreBar[];\n}\n\nconst clamp01 = (n: number): number => Math.min(1, Math.max(0, n));\n\n// deriveCoreBars turns the latest usage/limit millicore readings into a per-core\n// bar model: one bar per core (ceil of the limit), filled left to right by usage\n// so the bar straddling the usage boundary is partially filled and the remainder\n// stays empty. When the limit is missing or 0 the bar count falls back to the\n// ceiling of the usage so an unbounded reading still renders sensibly.\nexport function deriveCoreBars(\n usageMilli: number | undefined,\n limitMilli: number | undefined,\n): CoreBarsModel {\n const hasUsage = usageMilli !== undefined;\n const usageCores = (usageMilli ?? 0) / 1000;\n const hasLimit = limitMilli !== undefined && limitMilli > 0;\n const limitCores = hasLimit ? (limitMilli as number) / 1000 : undefined;\n\n const coreCount = Math.max(\n 1,\n Math.ceil(hasLimit ? (limitCores as number) : usageCores),\n );\n const pct = hasLimit\n ? Math.min(100, Math.round((usageCores / (limitCores as number)) * 100))\n : 0;\n\n const bars: CoreBar[] = Array.from({ length: coreCount }, (_, i) => ({\n fill: clamp01(usageCores - i),\n }));\n\n return { hasUsage, usageCores, limitCores, coreCount, pct, bars };\n}\n\nfunction CoreBarsIcon({ icon }: { icon: string | StaticIconComponent }) {\n if (typeof icon === \"string\") {\n return <Icon name={icon} width={14} height={14} className=\"text-muted-foreground\" />;\n }\n return <Icon icon={icon} width={14} height={14} className=\"text-muted-foreground\" />;\n}\n\nfunction formatCores(cores: number): string {\n return Number.isInteger(cores) ? String(cores) : cores.toFixed(1);\n}\n\n/**\n * TimeseriesCoreBars renders CPU utilisation as a row of vertical bars — one bar\n * per core (the ceiling of the CPU limit) — filled left to right by the latest\n * usage. The bar that straddles the usage boundary is partially filled (\"blocked\n * out\") to show the fractional core in use, and the trailing bars stay empty to\n * show headroom. Both usage and limit are read live from the timeseries store,\n * mirroring TimeseriesGauge's data plumbing; the bar colour crosses warning and\n * danger thresholds. A \"<used> / <cores>\" caption sits below with the icon+title.\n */\nexport function TimeseriesCoreBars({\n baseUrl = \"\",\n value,\n max,\n title,\n icon,\n range = \"1h\",\n refreshMs = 5000,\n thresholds = [75, 90],\n fetcher = defaultFetcher,\n className,\n}: TimeseriesCoreBarsProps) {\n const maxIsSeries = typeof max === \"object\";\n const maxSeries = maxIsSeries ? max : undefined;\n const ids = useMemo(() => {\n const list = [value.id];\n if (maxSeries) list.push(maxSeries.id);\n return list;\n }, [value.id, maxSeries]);\n\n const results = useQueries({\n queries: ids.map((id) => {\n const u = new URL(baseUrl + id, window.location.origin);\n if (range) u.searchParams.set(\"since\", range);\n const requestUrl = u.pathname + u.search;\n return {\n queryKey: [\"timeseries\", requestUrl],\n queryFn: () => fetcher(requestUrl),\n refetchInterval: refreshMs > 0 ? refreshMs : false,\n staleTime: 0,\n retry: 0,\n };\n }),\n });\n\n const rawValue = latestValue(results[0]?.data);\n const usage = rawValue === undefined ? undefined : value.transform ? value.transform(rawValue) : rawValue;\n\n let limit: number | undefined;\n if (typeof max === \"number\") {\n limit = max;\n } else if (maxSeries) {\n const rawMax = latestValue(results[1]?.data);\n limit = rawMax === undefined ? undefined : maxSeries.transform ? maxSeries.transform(rawMax) : rawMax;\n }\n\n const model = deriveCoreBars(usage, limit);\n const tone = toneClass(model.pct, thresholds);\n const caption = model.hasUsage\n ? `${formatCores(model.usageCores)} / ${model.limitCores !== undefined ? formatCores(model.limitCores) : \"?\"} cores`\n : \"—\";\n\n return (\n <div className={cn(\"flex flex-col items-center gap-1\", className)}>\n <div className=\"flex h-10 items-end gap-0.5\">\n {model.bars.map((bar, i) => {\n const corePct = Math.round(bar.fill * 100);\n return (\n <div\n key={i}\n className=\"relative h-full w-2 overflow-hidden rounded-sm bg-muted\"\n title={`core ${i + 1}: ${corePct}%`}\n aria-label={`core ${i + 1}: ${corePct}%`}\n data-fill={bar.fill}\n >\n <div\n className={cn(\"absolute inset-x-0 bottom-0 transition-all duration-300\", tone)}\n style={{ height: `${corePct}%` }}\n />\n </div>\n );\n })}\n </div>\n <span className=\"text-xs font-semibold text-foreground\">{caption}</span>\n <div className=\"flex items-center gap-1 text-xs text-muted-foreground\">\n {icon ? <CoreBarsIcon icon={icon} /> : null}\n <span>{title}</span>\n </div>\n </div>\n );\n}\n"],"names":[],"mappings":";;;;;AAoCA,MAAM,iBAAiB,OAAO,QAA6C;AACzE,QAAM,MAAM,MAAM,MAAM,GAAG;AAC3B,MAAI,CAAC,IAAI,GAAI,OAAM,IAAI,MAAM,2BAA2B,IAAI,MAAM,EAAE;AACpE,SAAO,IAAI,KAAA;AACb;AAEA,SAAS,YAAY,MAA0D;;AAC7E,QAAM,SAAS,6BAAM;AACrB,MAAI,CAAC,UAAU,OAAO,WAAW,EAAG,QAAO;AAC3C,UAAO,YAAO,OAAO,SAAS,CAAC,MAAxB,mBAA2B;AACpC;AAEA,SAAS,UAAU,KAAa,CAAC,MAAM,MAAM,GAA6B;AACxE,MAAI,OAAO,OAAQ,QAAO;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A,oBAAC,OAAA,EAAI,WAAU,+BACZ,UAAA,MAAM,KAAK,IAAI,CAAC,KAAK,MAAM;AAC1B,YAAM,UAAU,KAAK,MAAM,IAAI,OAAO,GAAG;AACzC,aACE;AAAA,QAAC;AAAA,QAAA;AAAA,UAEC,WAAU;AAAA,UACV,OAAO,QAAQ,IAAI,CAAC,KAAK,OAAO;AAAA,UAChC,cAAY,QAAQ,IAAI,CAAC,KAAK,OAAO;AAAA,UACrC,aAAW,IAAI;AAAA,UAEf,UAAA;AAAA,YAAC;AAAA,YAAA;AAAA,cACC,WAAW,GAAG,2DAA2D,IAAI;AAAA,cAC7E,OAAO,EAAE,QAAQ,GAAG,OAAO,IAAA;AAAA,YAAI;AAAA,UAAA;AAAA,QACjC;AAAA,QATK;AAAA,MAAA;AAAA,IAYX,CAAC,EAAA,CACH;AAAA,IACA,oBAAC,QAAA,EAAK,WAAU,yCAAyC,UAAA,SAAQ;AAAA,IACjE,qBAAC,OAAA,EAAI,WAAU,yDACZ,UAAA;AAAA,MAAA,OAAO,oBAAC,cAAA,EAAa,KAAA,CAAY,IAAK;AAAA,MACvC,oBAAC,UAAM,UAAA,MAAA,CAAM;AAAA,IAAA,EAAA,CACf;AAAA,EAAA,GACF;AAEJ;"}
1
+ {"version":3,"file":"TimeseriesCoreBars.js","sources":["../../src/data/TimeseriesCoreBars.tsx"],"sourcesContent":["import { useQueries } from \"@tanstack/react-query\";\nimport { useMemo } from \"react\";\nimport { cn } from \"../lib/utils\";\nimport { Icon, type StaticIconComponent } from \"./Icon\";\nimport type { GaugeSeries } from \"./TimeseriesGauge\";\nimport type { TimeseriesResponse } from \"./TimeseriesPanel\";\n\nexport interface TimeseriesCoreBarsProps {\n /** Common prefix; the value/max requests are `baseUrl + id`. */\n baseUrl?: string;\n /** The metric whose latest value (CPU millicores) fills the bars. */\n value: GaugeSeries;\n /**\n * The CPU capacity. Either a `.limit`-style metric series (its latest value in\n * millicores) or a fixed number of millicores. Determines the number of bars\n * (one per core). When omitted or 0, the bar count falls back to the ceiling of\n * the usage in cores so an unbounded reading still renders.\n */\n max?: GaugeSeries | number;\n title: string;\n /** Iconify name or static icon component shown beside the label. */\n icon?: string | StaticIconComponent;\n /** Look-back window passed as ?since=; defaults to \"1h\". */\n range?: string;\n /** Poll interval in ms; defaults to 5000. Pass 0 to disable polling. */\n refreshMs?: number;\n /**\n * Utilisation thresholds (percent of capacity) at which the fill turns amber\n * then red. Defaults to [75, 90].\n */\n thresholds?: [warning: number, danger: number];\n /** Override the default fetch (e.g. to route through an app's API client). */\n fetcher?: (url: string) => Promise<TimeseriesResponse>;\n className?: string;\n}\n\nconst defaultFetcher = async (url: string): Promise<TimeseriesResponse> => {\n const res = await fetch(url);\n if (!res.ok) throw new Error(`metrics request failed: ${res.status}`);\n return res.json();\n};\n\nfunction latestValue(resp: TimeseriesResponse | undefined): number | undefined {\n const points = resp?.points;\n if (!points || points.length === 0) return undefined;\n return points[points.length - 1]?.value;\n}\n\nfunction toneClass(pct: number, [warn, danger]: [number, number]): string {\n if (pct >= danger) return \"bg-red-500\";\n if (pct >= warn) return \"bg-amber-500\";\n return \"bg-emerald-500\";\n}\n\nexport interface CoreBar {\n /** Fraction of this core that is in use, in [0, 1]. */\n fill: number;\n}\n\nexport interface CoreBarsModel {\n /** Whether a usage reading was available. */\n hasUsage: boolean;\n /** Usage expressed in cores (millicores / 1000). */\n usageCores: number;\n /** Capacity in cores; undefined when no limit was resolved. */\n limitCores?: number;\n /** Number of bars rendered (one per core). */\n coreCount: number;\n /** Utilisation percentage of capacity; 0 when unbounded. */\n pct: number;\n /** Per-core fill fractions, left to right. */\n bars: CoreBar[];\n}\n\nconst clamp01 = (n: number): number => Math.min(1, Math.max(0, n));\n\n// deriveCoreBars turns the latest usage/limit millicore readings into a per-core\n// bar model: one bar per core (ceil of the limit), filled left to right by usage\n// so the bar straddling the usage boundary is partially filled and the remainder\n// stays empty. When the limit is missing or 0 the bar count falls back to the\n// ceiling of the usage so an unbounded reading still renders sensibly.\nexport function deriveCoreBars(\n usageMilli: number | undefined,\n limitMilli: number | undefined,\n): CoreBarsModel {\n const hasUsage = usageMilli !== undefined;\n const usageCores = (usageMilli ?? 0) / 1000;\n const hasLimit = limitMilli !== undefined && limitMilli > 0;\n const limitCores = hasLimit ? (limitMilli as number) / 1000 : undefined;\n\n const coreCount = Math.max(\n 1,\n Math.ceil(hasLimit ? (limitCores as number) : usageCores),\n );\n const pct = hasLimit\n ? Math.min(100, Math.round((usageCores / (limitCores as number)) * 100))\n : 0;\n\n const bars: CoreBar[] = Array.from({ length: coreCount }, (_, i) => ({\n fill: clamp01(usageCores - i),\n }));\n\n // limitCores is an optional field under exactOptionalPropertyTypes — only set\n // the key when a limit resolved, rather than assigning an explicit undefined.\n return {\n hasUsage,\n usageCores,\n coreCount,\n pct,\n bars,\n ...(limitCores !== undefined && { limitCores }),\n };\n}\n\nfunction CoreBarsIcon({ icon }: { icon: string | StaticIconComponent }) {\n if (typeof icon === \"string\") {\n return <Icon name={icon} width={14} height={14} className=\"text-muted-foreground\" />;\n }\n return <Icon icon={icon} width={14} height={14} className=\"text-muted-foreground\" />;\n}\n\nfunction formatCores(cores: number): string {\n return Number.isInteger(cores) ? String(cores) : cores.toFixed(1);\n}\n\n/**\n * TimeseriesCoreBars renders CPU utilisation as a row of vertical bars — one bar\n * per core (the ceiling of the CPU limit) — filled left to right by the latest\n * usage. The bar that straddles the usage boundary is partially filled (\"blocked\n * out\") to show the fractional core in use, and the trailing bars stay empty to\n * show headroom. Both usage and limit are read live from the timeseries store,\n * mirroring TimeseriesGauge's data plumbing; the bar colour crosses warning and\n * danger thresholds. A \"<used> / <cores>\" caption sits below with the icon+title.\n */\nexport function TimeseriesCoreBars({\n baseUrl = \"\",\n value,\n max,\n title,\n icon,\n range = \"1h\",\n refreshMs = 5000,\n thresholds = [75, 90],\n fetcher = defaultFetcher,\n className,\n}: TimeseriesCoreBarsProps) {\n const maxIsSeries = typeof max === \"object\";\n const maxSeries = maxIsSeries ? max : undefined;\n const ids = useMemo(() => {\n const list = [value.id];\n if (maxSeries) list.push(maxSeries.id);\n return list;\n }, [value.id, maxSeries]);\n\n const results = useQueries({\n queries: ids.map((id) => {\n const u = new URL(baseUrl + id, window.location.origin);\n if (range) u.searchParams.set(\"since\", range);\n const requestUrl = u.pathname + u.search;\n return {\n queryKey: [\"timeseries\", requestUrl],\n queryFn: () => fetcher(requestUrl),\n refetchInterval: refreshMs > 0 ? refreshMs : false,\n staleTime: 0,\n retry: 0,\n };\n }),\n });\n\n const rawValue = latestValue(results[0]?.data);\n const usage = rawValue === undefined ? undefined : value.transform ? value.transform(rawValue) : rawValue;\n\n let limit: number | undefined;\n if (typeof max === \"number\") {\n limit = max;\n } else if (maxSeries) {\n const rawMax = latestValue(results[1]?.data);\n limit = rawMax === undefined ? undefined : maxSeries.transform ? maxSeries.transform(rawMax) : rawMax;\n }\n\n const model = deriveCoreBars(usage, limit);\n const tone = toneClass(model.pct, thresholds);\n const caption = model.hasUsage\n ? `${formatCores(model.usageCores)} / ${model.limitCores !== undefined ? formatCores(model.limitCores) : \"?\"} cores`\n : \"—\";\n\n return (\n <div className={cn(\"flex flex-col items-center gap-1\", className)}>\n <div className=\"flex h-10 items-end gap-0.5\">\n {model.bars.map((bar, i) => {\n const corePct = Math.round(bar.fill * 100);\n return (\n <div\n key={i}\n className=\"relative h-full w-2 overflow-hidden rounded-sm bg-muted\"\n title={`core ${i + 1}: ${corePct}%`}\n aria-label={`core ${i + 1}: ${corePct}%`}\n data-fill={bar.fill}\n >\n <div\n className={cn(\"absolute inset-x-0 bottom-0 transition-all duration-300\", tone)}\n style={{ height: `${corePct}%` }}\n />\n </div>\n );\n })}\n </div>\n <span className=\"text-xs font-semibold text-foreground\">{caption}</span>\n <div className=\"flex items-center gap-1 text-xs text-muted-foreground\">\n {icon ? <CoreBarsIcon icon={icon} /> : null}\n <span>{title}</span>\n </div>\n </div>\n );\n}\n"],"names":[],"mappings":";;;;;AAoCA,MAAM,iBAAiB,OAA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@@ -1 +1 @@
1
- {"version":3,"file":"TimeseriesPanel.axes.cjs","sources":["../../src/data/TimeseriesPanel.axes.ts"],"sourcesContent":["import type { MergedRow, ResolvedSeries } from \"./TimeseriesPanel\";\n\nexport type AxisOrientation = \"left\" | \"right\";\n\n/** A rendered Y-axis: its recharts id (== orientation) and the unit it formats with. */\nexport interface AxisSpec {\n id: AxisOrientation;\n orientation: AxisOrientation;\n /** Unit the axis ticks format with; undefined for a unitless axis. */\n unit?: string;\n}\n\nexport interface AxisAssignment {\n /** 1 or 2 axes in render order (left first). */\n axes: AxisSpec[];\n /** Maps each series.key to the axis it draws against. */\n axisOfKey: Map<string, AxisOrientation>;\n}\n\n/** Sentinel grouping unitless series; never surfaced as an AxisSpec.unit. */\nconst NO_UNIT = \"\u0000__noUnit\";\n\n/**\n * Assigns series to one or two Y-axes by distinct unit, in first-seen order:\n * the first distinct unit takes the left axis, the second takes the right.\n * A third-or-later distinct unit shares the right axis (its series still plot,\n * but the right ticks read in the second unit's scale — a known approximation;\n * true N-axis support is out of scope). A single distinct unit yields one left\n * axis only. Undefined units form their own bucket so unitless series still get\n * an axis (recharts drops any series whose yAxisId is missing). Pure.\n */\nexport function assignAxes(series: ResolvedSeries[]): AxisAssignment {\n const order: string[] = [];\n const seen = new Set<string>();\n for (const s of series) {\n const u = s.unit ?? NO_UNIT;\n if (!seen.has(u)) {\n seen.add(u);\n order.push(u);\n }\n }\n\n const unitToAxis = new Map<string, AxisOrientation>();\n const axes: AxisSpec[] = [];\n order.forEach((u, i) => {\n const orientation: AxisOrientation = i === 0 ? \"left\" : \"right\";\n unitToAxis.set(u, orientation);\n if (i <= 1) {\n axes.push({ id: orientation, orientation, ...(u !== NO_UNIT ? { unit: u } : {}) });\n }\n });\n\n const axisOfKey = new Map<string, AxisOrientation>();\n for (const s of series) {\n axisOfKey.set(s.key, unitToAxis.get(s.unit ?? NO_UNIT) ?? \"left\");\n }\n\n return { axes, axisOfKey };\n}\n\n/** Last numeric value for a series key, scanning from newest row; undefined if none. Pure. */\nexport function latestOf(rows: MergedRow[], key: string): number | undefined {\n for (let i = rows.length - 1; i >= 0; i--) {\n const v = rows[i]?.[key];\n if (typeof v === \"number\") return v;\n }\n return undefined;\n}\n"],"names":[],"mappings":";;AAoBA,MAAM,UAAU;AAWT,SAAS,WAAW,QAA0C;AACnE,QAAM,QAAkB,CAAA;AACxB,QAAM,2BAAW,IAAA;AACjB,aAAW,KAAK,QAAQ;AACtB,UAAM,IAAI,EAAE,QAAQ;AACpB,QAAI,CAAC,KAAK,IAAI,CAAC,GAAG;AAChB,WAAK,IAAI,CAAC;AACV,YAAM,KAAK,CAAC;AAAA,IACd;AAAA,EACF;AAEA,QAAM,iCAAiB,IAAA;AACvB,QAAM,OAAmB,CAAA;AACzB,QAAM,QAAQ,CAAC,GAAG,MAAM;AACtB,UAAM,cAA+B,MAAM,IAAI,SAAS;AACxD,eAAW,IAAI,GAAG,WAAW;AAC7B,QAAI,KAAK,GAAG;AACV,WAAK,KAAK,EAAE,IAAI,aAAa,aAAa,GAAI,MAAM,UAAU,EAAE,MAAM,EAAA,IAAM,CAAA,GAAK;AAAA,IACnF;AAAA,EACF,CAAC;AAED,QAAM,gCAAgB,IAAA;AACtB,aAAW,KAAK,QAAQ;AACtB,cAAU,IAAI,EAAE,KAAK,WAAW,IAAI,EAAE,QAAQ,OAAO,KAAK,MAAM;AAAA,EAClE;AAEA,SAAO,EAAE,MAAM,UAAA;AACjB;AAGO,SAAS,SAAS,MAAmB,KAAiC;;AAC3E,WAAS,IAAI,KAAK,SAAS,GAAG,KAAK,GAAG,KAAK;AACzC,UAAM,KAAI,UAAK,CAAC,MAAN,mBAAU;AACpB,QAAI,OAAO,MAAM,SAAU,QAAO;AAAA,EACpC;AACA,SAAO;AACT;;;"}
1
+ {"version":3,"file":"TimeseriesPanel.axes.cjs","sources":["../../src/data/TimeseriesPanel.axes.ts"],"sourcesContent":["import type { MergedRow, ResolvedSeries } from \"./TimeseriesPanel\";\n\nexport type AxisOrientation = \"left\" | \"right\";\n\n/** A rendered Y-axis: its recharts id (== orientation) and the unit it formats with. */\nexport interface AxisSpec {\n id: AxisOrientation;\n orientation: AxisOrientation;\n /** Unit the axis ticks format with; undefined for a unitless axis. */\n unit?: string;\n}\n\nexport interface AxisAssignment {\n /** 1 or 2 axes in render order (left first). */\n axes: AxisSpec[];\n /** Maps each series.key to the axis it draws against. */\n axisOfKey: Map<string, AxisOrientation>;\n}\n\n/** Sentinel grouping unitless series; never surfaced as an AxisSpec.unit. */\nconst NO_UNIT = \"\\u0000__noUnit\";\n\n/**\n * Assigns series to one or two Y-axes by distinct unit, in first-seen order:\n * the first distinct unit takes the left axis, the second takes the right.\n * A third-or-later distinct unit shares the right axis (its series still plot,\n * but the right ticks read in the second unit's scale — a known approximation;\n * true N-axis support is out of scope). A single distinct unit yields one left\n * axis only. Undefined units form their own bucket so unitless series still get\n * an axis (recharts drops any series whose yAxisId is missing). Pure.\n */\nexport function assignAxes(series: ResolvedSeries[]): AxisAssignment {\n const order: string[] = [];\n const seen = new Set<string>();\n for (const s of series) {\n const u = s.unit ?? NO_UNIT;\n if (!seen.has(u)) {\n seen.add(u);\n order.push(u);\n }\n }\n\n const unitToAxis = new Map<string, AxisOrientation>();\n const axes: AxisSpec[] = [];\n order.forEach((u, i) => {\n const orientation: AxisOrientation = i === 0 ? \"left\" : \"right\";\n unitToAxis.set(u, orientation);\n if (i <= 1) {\n axes.push({ id: orientation, orientation, ...(u !== NO_UNIT ? { unit: u } : {}) });\n }\n });\n\n const axisOfKey = new Map<string, AxisOrientation>();\n for (const s of series) {\n axisOfKey.set(s.key, unitToAxis.get(s.unit ?? NO_UNIT) ?? \"left\");\n }\n\n return { axes, axisOfKey };\n}\n\n/** Last numeric value for a series key, scanning from newest row; undefined if none. Pure. */\nexport function latestOf(rows: MergedRow[], key: string): number | undefined {\n for (let i = rows.length - 1; i >= 0; i--) {\n const v = rows[i]?.[key];\n if (typeof v === \"number\") return v;\n }\n return undefined;\n}\n"],"names":[],"mappings":";;AAoBA,MAAM,UAAU;AAWT,SAAS,WAAW,QAA0C;AACnE,QAAM,QAAkB,CAAA;AACxB,QAAM,2BAAW,IAAA;AACjB,aAAW,KAAK,QAAQ;AACtB,UAAM,IAAI,EAAE,QAAQ;AACpB,QAAI,CAAC,KAAK,IAAI,CAAC,GAAG;AAChB,WAAK,IAAI,CAAC;AACV,YAAM,KAAK,CAAC;AAAA,IACd;AAAA,EACF;AAEA,QAAM,iCAAiB,IAAA;AACvB,QAAM,OAAmB,CAAA;AACzB,QAAM,QAAQ,CAAC,GAAG,MAAM;AACtB,UAAM,cAA+B,MAAM,IAAI,SAAS;AACxD,eAAW,IAAI,GAAG,WAAW;AAC7B,QAAI,KAAK,GAAG;AACV,WAAK,KAAK,EAAE,IAAI,aAAa,aAAa,GAAI,MAAM,UAAU,EAAE,MAAM,EAAA,IAAM,CAAA,GAAK;AAAA,IACnF;AAAA,EACF,CAAC;AAED,QAAM,gCAAgB,IAAA;AACtB,aAAW,KAAK,QAAQ;AACtB,cAAU,IAAI,EAAE,KAAK,WAAW,IAAI,EAAE,QAAQ,OAAO,KAAK,MAAM;AAAA,EAClE;AAEA,SAAO,EAAE,MAAM,UAAA;AACjB;AAGO,SAAS,SAAS,MAAmB,KAAiC;;AAC3E,WAAS,IAAI,KAAK,SAAS,GAAG,KAAK,GAAG,KAAK;AACzC,UAAM,KAAI,UAAK,CAAC,MAAN,mBAAU;AACpB,QAAI,OAAO,MAAM,SAAU,QAAO;AAAA,EACpC;AACA,SAAO;AACT;;;"}
@@ -1 +1 @@
1
- {"version":3,"file":"TimeseriesPanel.axes.js","sources":["../../src/data/TimeseriesPanel.axes.ts"],"sourcesContent":["import type { MergedRow, ResolvedSeries } from \"./TimeseriesPanel\";\n\nexport type AxisOrientation = \"left\" | \"right\";\n\n/** A rendered Y-axis: its recharts id (== orientation) and the unit it formats with. */\nexport interface AxisSpec {\n id: AxisOrientation;\n orientation: AxisOrientation;\n /** Unit the axis ticks format with; undefined for a unitless axis. */\n unit?: string;\n}\n\nexport interface AxisAssignment {\n /** 1 or 2 axes in render order (left first). */\n axes: AxisSpec[];\n /** Maps each series.key to the axis it draws against. */\n axisOfKey: Map<string, AxisOrientation>;\n}\n\n/** Sentinel grouping unitless series; never surfaced as an AxisSpec.unit. */\nconst NO_UNIT = \"\u0000__noUnit\";\n\n/**\n * Assigns series to one or two Y-axes by distinct unit, in first-seen order:\n * the first distinct unit takes the left axis, the second takes the right.\n * A third-or-later distinct unit shares the right axis (its series still plot,\n * but the right ticks read in the second unit's scale — a known approximation;\n * true N-axis support is out of scope). A single distinct unit yields one left\n * axis only. Undefined units form their own bucket so unitless series still get\n * an axis (recharts drops any series whose yAxisId is missing). Pure.\n */\nexport function assignAxes(series: ResolvedSeries[]): AxisAssignment {\n const order: string[] = [];\n const seen = new Set<string>();\n for (const s of series) {\n const u = s.unit ?? NO_UNIT;\n if (!seen.has(u)) {\n seen.add(u);\n order.push(u);\n }\n }\n\n const unitToAxis = new Map<string, AxisOrientation>();\n const axes: AxisSpec[] = [];\n order.forEach((u, i) => {\n const orientation: AxisOrientation = i === 0 ? \"left\" : \"right\";\n unitToAxis.set(u, orientation);\n if (i <= 1) {\n axes.push({ id: orientation, orientation, ...(u !== NO_UNIT ? { unit: u } : {}) });\n }\n });\n\n const axisOfKey = new Map<string, AxisOrientation>();\n for (const s of series) {\n axisOfKey.set(s.key, unitToAxis.get(s.unit ?? NO_UNIT) ?? \"left\");\n }\n\n return { axes, axisOfKey };\n}\n\n/** Last numeric value for a series key, scanning from newest row; undefined if none. Pure. */\nexport function latestOf(rows: MergedRow[], key: string): number | undefined {\n for (let i = rows.length - 1; i >= 0; i--) {\n const v = rows[i]?.[key];\n if (typeof v === \"number\") return v;\n }\n return undefined;\n}\n"],"names":[],"mappings":"AAoBA,MAAM,UAAU;AAWT,SAAS,WAAW,QAA0C;AACnE,QAAM,QAAkB,CAAA;AACxB,QAAM,2BAAW,IAAA;AACjB,aAAW,KAAK,QAAQ;AACtB,UAAM,IAAI,EAAE,QAAQ;AACpB,QAAI,CAAC,KAAK,IAAI,CAAC,GAAG;AAChB,WAAK,IAAI,CAAC;AACV,YAAM,KAAK,CAAC;AAAA,IACd;AAAA,EACF;AAEA,QAAM,iCAAiB,IAAA;AACvB,QAAM,OAAmB,CAAA;AACzB,QAAM,QAAQ,CAAC,GAAG,MAAM;AACtB,UAAM,cAA+B,MAAM,IAAI,SAAS;AACxD,eAAW,IAAI,GAAG,WAAW;AAC7B,QAAI,KAAK,GAAG;AACV,WAAK,KAAK,EAAE,IAAI,aAAa,aAAa,GAAI,MAAM,UAAU,EAAE,MAAM,EAAA,IAAM,CAAA,GAAK;AAAA,IACnF;AAAA,EACF,CAAC;AAED,QAAM,gCAAgB,IAAA;AACtB,aAAW,KAAK,QAAQ;AACtB,cAAU,IAAI,EAAE,KAAK,WAAW,IAAI,EAAE,QAAQ,OAAO,KAAK,MAAM;AAAA,EAClE;AAEA,SAAO,EAAE,MAAM,UAAA;AACjB;AAGO,SAAS,SAAS,MAAmB,KAAiC;AAzC7E;AA0CE,WAAS,IAAI,KAAK,SAAS,GAAG,KAAK,GAAG,KAAK;AACzC,UAAM,KAAI,UAAK,CAAC,MAAN,mBAAU;AACpB,QAAI,OAAO,MAAM,SAAU,QAAO;AAAA,EACpC;AACA,SAAO;AACT;"}
1
+ {"version":3,"file":"TimeseriesPanel.axes.js","sources":["../../src/data/TimeseriesPanel.axes.ts"],"sourcesContent":["import type { MergedRow, ResolvedSeries } from \"./TimeseriesPanel\";\n\nexport type AxisOrientation = \"left\" | \"right\";\n\n/** A rendered Y-axis: its recharts id (== orientation) and the unit it formats with. */\nexport interface AxisSpec {\n id: AxisOrientation;\n orientation: AxisOrientation;\n /** Unit the axis ticks format with; undefined for a unitless axis. */\n unit?: string;\n}\n\nexport interface AxisAssignment {\n /** 1 or 2 axes in render order (left first). */\n axes: AxisSpec[];\n /** Maps each series.key to the axis it draws against. */\n axisOfKey: Map<string, AxisOrientation>;\n}\n\n/** Sentinel grouping unitless series; never surfaced as an AxisSpec.unit. */\nconst NO_UNIT = \"\\u0000__noUnit\";\n\n/**\n * Assigns series to one or two Y-axes by distinct unit, in first-seen order:\n * the first distinct unit takes the left axis, the second takes the right.\n * A third-or-later distinct unit shares the right axis (its series still plot,\n * but the right ticks read in the second unit's scale — a known approximation;\n * true N-axis support is out of scope). A single distinct unit yields one left\n * axis only. Undefined units form their own bucket so unitless series still get\n * an axis (recharts drops any series whose yAxisId is missing). Pure.\n */\nexport function assignAxes(series: ResolvedSeries[]): AxisAssignment {\n const order: string[] = [];\n const seen = new Set<string>();\n for (const s of series) {\n const u = s.unit ?? NO_UNIT;\n if (!seen.has(u)) {\n seen.add(u);\n order.push(u);\n }\n }\n\n const unitToAxis = new Map<string, AxisOrientation>();\n const axes: AxisSpec[] = [];\n order.forEach((u, i) => {\n const orientation: AxisOrientation = i === 0 ? \"left\" : \"right\";\n unitToAxis.set(u, orientation);\n if (i <= 1) {\n axes.push({ id: orientation, orientation, ...(u !== NO_UNIT ? { unit: u } : {}) });\n }\n });\n\n const axisOfKey = new Map<string, AxisOrientation>();\n for (const s of series) {\n axisOfKey.set(s.key, unitToAxis.get(s.unit ?? NO_UNIT) ?? \"left\");\n }\n\n return { axes, axisOfKey };\n}\n\n/** Last numeric value for a series key, scanning from newest row; undefined if none. Pure. */\nexport function latestOf(rows: MergedRow[], key: string): number | undefined {\n for (let i = rows.length - 1; i >= 0; i--) {\n const v = rows[i]?.[key];\n if (typeof v === \"number\") return v;\n }\n return undefined;\n}\n"],"names":[],"mappings":"AAoBA,MAAM,UAAU;AAWT,SAAS,WAAW,QAA0C;AACnE,QAAM,QAAkB,CAAA;AACxB,QAAM,2BAAW,IAAA;AACjB,aAAW,KAAK,QAAQ;AACtB,UAAM,IAAI,EAAE,QAAQ;AACpB,QAAI,CAAC,KAAK,IAAI,CAAC,GAAG;AAChB,WAAK,IAAI,CAAC;AACV,YAAM,KAAK,CAAC;AAAA,IACd;AAAA,EACF;AAEA,QAAM,iCAAiB,IAAA;AACvB,QAAM,OAAmB,CAAA;AACzB,QAAM,QAAQ,CAAC,GAAG,MAAM;AACtB,UAAM,cAA+B,MAAM,IAAI,SAAS;AACxD,eAAW,IAAI,GAAG,WAAW;AAC7B,QAAI,KAAK,GAAG;AACV,WAAK,KAAK,EAAE,IAAI,aAAa,aAAa,GAAI,MAAM,UAAU,EAAE,MAAM,EAAA,IAAM,CAAA,GAAK;AAAA,IACnF;AAAA,EACF,CAAC;AAED,QAAM,gCAAgB,IAAA;AACtB,aAAW,KAAK,QAAQ;AACtB,cAAU,IAAI,EAAE,KAAK,WAAW,IAAI,EAAE,QAAQ,OAAO,KAAK,MAAM;AAAA,EAClE;AAEA,SAAO,EAAE,MAAM,UAAA;AACjB;AAGO,SAAS,SAAS,MAAmB,KAAiC;AAzC7E;AA0CE,WAAS,IAAI,KAAK,SAAS,GAAG,KAAK,GAAG,KAAK;AACzC,UAAM,KAAI,UAAK,CAAC,MAAN,mBAAU;AACpB,QAAI,OAAO,MAAM,SAAU,QAAO;AAAA,EACpC;AACA,SAAO;AACT;"}
@@ -32,16 +32,16 @@ function TreeNode({
32
32
  const hasChildren = ((children == null ? void 0 : children.length) ?? 0) > 0;
33
33
  const lazyUnloaded = ((hasMoreChildren == null ? void 0 : hasMoreChildren(node)) ?? false) && loadedChildren === null;
34
34
  const expandable = hasChildren || lazyUnloaded;
35
- const initialOpen = defaultOpen ? defaultOpen(node, depth) : depth < 1;
35
+ const secondaryNode = (isSecondary == null ? void 0 : isSecondary(node)) ?? false;
36
+ const childrenAllSecondary = hasChildren && isSecondary != null && children.every((c) => isSecondary(c));
37
+ const skipExpandAll = secondaryNode || childrenAllSecondary;
38
+ const initialOpen = expandAll !== null && !skipExpandAll ? expandAll : defaultOpen ? defaultOpen(node, depth) : depth < 1;
36
39
  const [open, setOpen] = react.useState(initialOpen);
37
40
  const prevExpandAll = react.useRef(expandAll);
38
41
  const isSelected = selected === node;
39
42
  const key = getKey(node);
40
43
  const isForcedOpen = (forcedOpenKeys == null ? void 0 : forcedOpenKeys.has(key)) ?? false;
41
44
  const isOpen = isForcedOpen || open;
42
- const secondaryNode = (isSecondary == null ? void 0 : isSecondary(node)) ?? false;
43
- const childrenAllSecondary = hasChildren && isSecondary != null && children.every((c) => isSecondary(c));
44
- const skipExpandAll = secondaryNode || childrenAllSecondary;
45
45
  react.useEffect(() => {
46
46
  if (expandAll !== null && expandAll !== prevExpandAll.current && !skipExpandAll) {
47
47
  setOpen(expandAll);
@@ -97,10 +97,16 @@ function TreeNode({
97
97
  },
98
98
  children: [
99
99
  expandable ? /* @__PURE__ */ jsxRuntime.jsx(
100
- Icon.Icon,
100
+ "button",
101
101
  {
102
- icon: isOpen ? UiChevronDown.UiChevronDown : UiChevronRight.UiChevronRight,
103
- className: "text-muted-foreground text-xs w-3"
102
+ type: "button",
103
+ "aria-label": isOpen ? "Collapse" : "Expand",
104
+ onClick: (e) => {
105
+ e.stopPropagation();
106
+ toggle();
107
+ },
108
+ className: "flex shrink-0 items-center text-muted-foreground",
109
+ children: /* @__PURE__ */ jsxRuntime.jsx(Icon.Icon, { icon: isOpen ? UiChevronDown.UiChevronDown : UiChevronRight.UiChevronRight, className: "text-xs w-3" })
104
110
  }
105
111
  ) : /* @__PURE__ */ jsxRuntime.jsx("span", { className: "w-3 shrink-0", "aria-hidden": true }),
106
112
  renderRow({
@@ -1 +1 @@
1
- {"version":3,"file":"TreeNode.cjs","sources":["../../src/data/TreeNode.tsx"],"sourcesContent":["import { useEffect, useRef, useState, type ReactNode } from \"react\";\nimport { cn } from \"../lib/utils\";\nimport { Icon } from \"./Icon\";\nimport { UiChevronDown, UiChevronRight } from \"../icons\";\n\nexport type TreeRowContext<T> = {\n node: T;\n depth: number;\n open: boolean;\n selected: boolean;\n hasChildren: boolean;\n toggle: () => void;\n /** True while this node's lazy children are being fetched via loadChildren. */\n loading: boolean;\n /** The rejection value from loadChildren, or null when there was no error. */\n error: unknown;\n};\n\nexport type TreeNodeProps<T> = {\n node: T;\n depth?: number;\n expandAll?: boolean | null;\n forcedOpenKeys?: Set<string | number> | null;\n selected?: T | null;\n defaultOpen?: (node: T, depth: number) => boolean;\n getChildren: (node: T) => T[] | undefined;\n getKey: (node: T) => string | number;\n onSelect?: (node: T) => void;\n renderRow: (ctx: TreeRowContext<T>) => ReactNode;\n rowClass?: (node: T, selected: boolean) => string;\n indentPx?: number;\n basePaddingPx?: number;\n /**\n * Reports that a node has children that are not yet loaded — it renders an\n * expand chevron even when `getChildren` returns nothing. On the first open\n * the node fetches them via `loadChildren`. Without this (the default), a\n * node is expandable only when `getChildren` already returns children.\n */\n hasMoreChildren?: (node: T) => boolean;\n /**\n * Lazily fetch a node's children the first time it is opened. Resolves to the\n * child nodes (which may themselves be lazy). A rejection is surfaced to\n * `renderRow` via `ctx.error` and is not retried until the node is collapsed\n * and reopened. Required for any node `hasMoreChildren` returns true for.\n */\n loadChildren?: (node: T) => Promise<T[]>;\n /**\n * Marks a node as a **secondary child** of its parent. Secondary\n * children keep the full tree structure (they render, they can be\n * opened manually) but opt out of the bulk behaviours a caller\n * typically wants when they click the toolbar:\n *\n * - Tree-wide filter: their text is skipped during match detection\n * so typing in the search box never surfaces a row because one\n * of its secondary children happened to match.\n * - Expand all: secondary nodes stay at their default-open state\n * instead of being forced open, preventing 28k field rows from\n * flooding the viewport when an operator hits the button on a\n * schema with hundreds of tables.\n *\n * Default: every node is primary (returns false).\n */\n isSecondary?: (node: T) => boolean;\n};\n\nexport function TreeNode<T>({\n node,\n depth = 0,\n expandAll = null,\n forcedOpenKeys = null,\n selected = null,\n defaultOpen,\n getChildren,\n getKey,\n onSelect,\n renderRow,\n rowClass,\n indentPx = 16,\n basePaddingPx = 8,\n isSecondary,\n hasMoreChildren,\n loadChildren,\n}: TreeNodeProps<T>) {\n // Lazily-fetched children take precedence over the synchronous ones once a\n // load has resolved; until then `loadedChildren` is null and we fall back to\n // getChildren. A node can be \"lazy\" (hasMoreChildren) with no sync children.\n const [loadedChildren, setLoadedChildren] = useState<T[] | null>(null);\n const [loading, setLoading] = useState(false);\n const [error, setError] = useState<unknown>(null);\n const syncChildren = getChildren(node);\n const children = loadedChildren ?? syncChildren;\n const hasChildren = (children?.length ?? 0) > 0;\n const lazyUnloaded = (hasMoreChildren?.(node) ?? false) && loadedChildren === null;\n // The chevron shows when there is something to reveal: either real children\n // are present, or the node is lazy and has not been loaded yet.\n const expandable = hasChildren || lazyUnloaded;\n const initialOpen = defaultOpen ? defaultOpen(node, depth) : depth < 1;\n const [open, setOpen] = useState(initialOpen);\n const prevExpandAll = useRef(expandAll);\n const isSelected = selected === node;\n const key = getKey(node);\n const isForcedOpen = forcedOpenKeys?.has(key) ?? false;\n const isOpen = isForcedOpen || open;\n // A node opts out of bulk expand-all in two distinct cases:\n //\n // 1. The node itself is secondary (its edge from the parent is\n // secondary) — rare at the root, but the rule is symmetric.\n // 2. All of the node's children are secondary — the common case.\n // This is what keeps an \"Expand all\" on a schema tree from\n // flooding the viewport with every table's field rows: the\n // table opens to nothing structural worth seeing in bulk, so\n // we leave it closed until the operator clicks it manually.\n //\n // In both cases the manual toggle still works, and filter matches\n // still force the row open via forcedOpenKeys, so users never\n // lose access — they just don't get auto-flooded.\n const secondaryNode = isSecondary?.(node) ?? false;\n const childrenAllSecondary =\n hasChildren && isSecondary != null && children!.every((c) => isSecondary(c));\n const skipExpandAll = secondaryNode || childrenAllSecondary;\n\n useEffect(() => {\n if (expandAll !== null && expandAll !== prevExpandAll.current && !skipExpandAll) {\n setOpen(expandAll);\n }\n prevExpandAll.current = expandAll;\n }, [expandAll, skipExpandAll]);\n\n // Guards a lazy fetch so a node loads its children at most once per mount and\n // a resolution arriving after the node was reused (key changed) is ignored.\n const loadRequested = useRef(false);\n const nodeKey = getKey(node);\n const loadKeyRef = useRef(nodeKey);\n\n function loadLazyChildren() {\n if (!loadChildren || loadRequested.current) return;\n loadRequested.current = true;\n loadKeyRef.current = nodeKey;\n setLoading(true);\n setError(null);\n loadChildren(node)\n .then((kids) => {\n if (loadKeyRef.current !== nodeKey) return;\n setLoadedChildren(kids);\n setLoading(false);\n })\n .catch((err) => {\n if (loadKeyRef.current !== nodeKey) return;\n // Surfaced to renderRow via ctx.error; allow a retry on re-toggle.\n loadRequested.current = false;\n setError(err);\n setLoading(false);\n });\n }\n\n function toggle() {\n if (!expandable) return;\n setOpen((o) => {\n const next = !o;\n // Only fetch when transitioning into the open state, so collapsing a\n // not-yet-loaded (e.g. previously-failed) lazy node never triggers a load.\n if (next && lazyUnloaded) loadLazyChildren();\n return next;\n });\n }\n\n const defaultRowBg = isSelected ? \"bg-primary/10 border-l-2 border-primary\" : \"hover:bg-accent\";\n const rowClassName = rowClass ? rowClass(node, isSelected) : defaultRowBg;\n\n return (\n <div\n role=\"treeitem\"\n aria-expanded={expandable ? isOpen : undefined}\n aria-selected={isSelected}\n >\n <div\n className={cn(\"flex items-center gap-1.5 py-1 px-2 cursor-pointer text-sm\", rowClassName)}\n style={{ paddingLeft: `${depth * indentPx + basePaddingPx}px` }}\n onClick={(e) => {\n e.stopPropagation();\n onSelect?.(node);\n toggle();\n }}\n >\n {expandable ? (\n <Icon\n icon={isOpen ? UiChevronDown : UiChevronRight}\n className=\"text-muted-foreground text-xs w-3\"\n />\n ) : (\n <span className=\"w-3 shrink-0\" aria-hidden />\n )}\n {renderRow({\n node,\n depth,\n open: isOpen,\n selected: isSelected,\n hasChildren,\n toggle,\n loading,\n error,\n })}\n </div>\n {isOpen && hasChildren && (\n <div role=\"group\">\n {children!.map((child) => (\n <TreeNode\n key={getKey(child)}\n node={child}\n depth={depth + 1}\n expandAll={expandAll}\n forcedOpenKeys={forcedOpenKeys}\n selected={selected}\n getChildren={getChildren}\n getKey={getKey}\n renderRow={renderRow}\n indentPx={indentPx}\n basePaddingPx={basePaddingPx}\n {...(defaultOpen ? { defaultOpen } : {})}\n {...(onSelect ? { onSelect } : {})}\n {...(rowClass ? { rowClass } : {})}\n {...(isSecondary ? { isSecondary } : {})}\n {...(hasMoreChildren ? { hasMoreChildren } : {})}\n {...(loadChildren ? { loadChildren } : {})}\n />\n ))}\n </div>\n )}\n </div>\n );\n}\n"],"names":["useState","useRef","useEffect","jsxs","cn","jsx","Icon","UiChevronDown","UiChevronRight"],"mappings":";;;;;;;;AAiEO,SAAS,SAAY;AAAA,EAC1B;AAAA,EACA,QAAQ;AAAA,EACR,YAAY;AAAA,EACZ,iBAAiB;AAAA,EACjB,WAAW;AAAA,EACX;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA,WAAW;AAAA,EACX,gBAAgB;AAAA,EAChB;AAAA,EACA;AAAA,EACA;AACF,GAAqB;AAInB,QAAM,CAAC,gBAAgB,iBAAiB,IAAIA,MAAAA,SAAqB,IAAI;AACrE,QAAM,CAAC,SAAS,UAAU,IAAIA,MAAAA,SAAS,KAAK;AAC5C,QAAM,CAAC,OAAO,QAAQ,IAAIA,MAAAA,SAAkB,IAAI;AAChD,QAAM,eAAe,YAAY,IAAI;AACrC,QAAM,WAAW,kBAAkB;AACnC,QAAM,gBAAe,qCAAU,WAAU,KAAK;AAC9C,QAAM,iBAAgB,mDAAkB,UAAS,UAAU,mBAAmB;AAG9E,QAAM,aAAa,eAAe;AAClC,QAAM,cAAc,cAAc,YAAY,MAAM,KAAK,IAAI,QAAQ;AACrE,QAAM,CAAC,MAAM,OAAO,IAAIA,MAAAA,SAAS,WAAW;AAC5C,QAAM,gBAAgBC,MAAAA,OAAO,SAAS;AACtC,QAAM,aAAa,aAAa;AAChC,QAAM,MAAM,OAAO,IAAI;AACvB,QAAM,gBAAe,iDAAgB,IAAI,SAAQ;AACjD,QAAM,SAAS,gBAAgB;AAc/B,QAAM,iBAAgB,2CAAc,UAAS;AAC7C,QAAM,uBACJ,eAAe,eAAe,QAAQ,SAAU,MAAM,CAAC,MAAM,YAAY,CAAC,CAAC;AAC7E,QAAM,gBAAgB,iBAAiB;AAEvCC,QAAAA,UAAU,MAAM;AAC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gBAAA;AACF,mDAAW;AACX,qBAAA;AAAA,YACF;AAAA,YAEC,UAAA;AAAA,cAAA,aACCC,2BAAAA;AAAAA,gBAACC,KAAAA;AAAAA,gBAAA;AAAA,kBACC,MAAM,SAASC,cAAAA,gBAAgBC,eAAAA;AAAAA,kBAC/B,WAAU;AAAA,gBAAA;AAAA,cAAA,IAGZH,2BAAAA,IAAC,QAAA,EAAK,WAAU,gBAAe,eAAW,MAAC;AAAA,cAE5C,UAAU;AAAA,gBACT;AAAA,gBACA;AAAA,gBACA,MAAM;AAAA,gBACN,UAAU;AAAA,gBACV;AAAA,gBACA;AAAA,gBACA;AAAA,gBACA;AAAA,cAAA,CACD;AAAA,YAAA;AAAA,UAAA;AAAA,QAAA;AAAA,QAEF,UAAU,eACTA,+BAAC,OAAA,EAAI,MAAK,SACP,UAAA,SAAU,IAAI,CAAC,UACdA,2BAAAA;AAAAA,UAAC;AAAA,UAAA;AAAA,YAEC,MAAM;AAAA,YACN,OAAO,QAAQ;AAAA,YACf;AAAA,YACA;AAAA,YACA;AAAA,YACA;AAAA,YACA;AAAA,YACA;AAAA,YACA;AAAA,YACA;AAAA,YACC,GAAI,cAAc,EAAE,YAAA,IAAgB,CAAA;AAAA,YACpC,GAAI,WAAW,EAAE,SAAA,IAAa,CAAA;AAAA,YAC9B,GAAI,WAAW,EAAE,SAAA,IAAa,CAAA;AAAA,YAC9B,GAAI,cAAc,EAAE,YAAA,IAAgB,CAAA;AAAA,YACpC,GAAI,kBAAkB,EAAE,gBAAA,IAAoB,CAAA;AAAA,YAC5C,GAAI,eAAe,EAAE,iBAAiB,CAAA;AAAA,UAAC;AAAA,UAhBnC,OAAO,KAAK;AAAA,QAAA,CAkBpB,EAAA,CACH;AAAA,MAAA;AAAA,IAAA;AAAA,EAAA;AAIR;;"}
1
+ {"version":3,"file":"TreeNode.cjs","sources":["../../src/data/TreeNode.tsx"],"sourcesContent":["import { useEffect, useRef, useState, type ReactNode } from \"react\";\nimport { cn } from \"../lib/utils\";\nimport { Icon } from \"./Icon\";\nimport { UiChevronDown, UiChevronRight } from \"../icons\";\n\nexport type TreeRowContext<T> = {\n node: T;\n depth: number;\n open: boolean;\n selected: boolean;\n hasChildren: boolean;\n toggle: () => void;\n /** True while this node's lazy children are being fetched via loadChildren. */\n loading: boolean;\n /** The rejection value from loadChildren, or null when there was no error. */\n error: unknown;\n};\n\nexport type TreeNodeProps<T> = {\n node: T;\n depth?: number;\n expandAll?: boolean | null;\n forcedOpenKeys?: Set<string | number> | null;\n selected?: T | null;\n defaultOpen?: (node: T, depth: number) => boolean;\n getChildren: (node: T) => T[] | undefined;\n getKey: (node: T) => string | number;\n onSelect?: (node: T) => void;\n renderRow: (ctx: TreeRowContext<T>) => ReactNode;\n rowClass?: (node: T, selected: boolean) => string;\n indentPx?: number;\n basePaddingPx?: number;\n /**\n * Reports that a node has children that are not yet loaded — it renders an\n * expand chevron even when `getChildren` returns nothing. On the first open\n * the node fetches them via `loadChildren`. Without this (the default), a\n * node is expandable only when `getChildren` already returns children.\n */\n hasMoreChildren?: (node: T) => boolean;\n /**\n * Lazily fetch a node's children the first time it is opened. Resolves to the\n * child nodes (which may themselves be lazy). A rejection is surfaced to\n * `renderRow` via `ctx.error` and is not retried until the node is collapsed\n * and reopened. Required for any node `hasMoreChildren` returns true for.\n */\n loadChildren?: (node: T) => Promise<T[]>;\n /**\n * Marks a node as a **secondary child** of its parent. Secondary\n * children keep the full tree structure (they render, they can be\n * opened manually) but opt out of the bulk behaviours a caller\n * typically wants when they click the toolbar:\n *\n * - Tree-wide filter: their text is skipped during match detection\n * so typing in the search box never surfaces a row because one\n * of its secondary children happened to match.\n * - Expand all: secondary nodes stay at their default-open state\n * instead of being forced open, preventing 28k field rows from\n * flooding the viewport when an operator hits the button on a\n * schema with hundreds of tables.\n *\n * Default: every node is primary (returns false).\n */\n isSecondary?: (node: T) => boolean;\n};\n\nexport function TreeNode<T>({\n node,\n depth = 0,\n expandAll = null,\n forcedOpenKeys = null,\n selected = null,\n defaultOpen,\n getChildren,\n getKey,\n onSelect,\n renderRow,\n rowClass,\n indentPx = 16,\n basePaddingPx = 8,\n isSecondary,\n hasMoreChildren,\n loadChildren,\n}: TreeNodeProps<T>) {\n // Lazily-fetched children take precedence over the synchronous ones once a\n // load has resolved; until then `loadedChildren` is null and we fall back to\n // getChildren. A node can be \"lazy\" (hasMoreChildren) with no sync children.\n const [loadedChildren, setLoadedChildren] = useState<T[] | null>(null);\n const [loading, setLoading] = useState(false);\n const [error, setError] = useState<unknown>(null);\n const syncChildren = getChildren(node);\n const children = loadedChildren ?? syncChildren;\n const hasChildren = (children?.length ?? 0) > 0;\n const lazyUnloaded = (hasMoreChildren?.(node) ?? false) && loadedChildren === null;\n // The chevron shows when there is something to reveal: either real children\n // are present, or the node is lazy and has not been loaded yet.\n const expandable = hasChildren || lazyUnloaded;\n // A node opts out of bulk expand-all in two distinct cases:\n //\n // 1. The node itself is secondary (its edge from the parent is\n // secondary) — rare at the root, but the rule is symmetric.\n // 2. All of the node's children are secondary — the common case.\n // This is what keeps an \"Expand all\" on a schema tree from\n // flooding the viewport with every table's field rows: the\n // table opens to nothing structural worth seeing in bulk, so\n // we leave it closed until the operator clicks it manually.\n //\n // In both cases the manual toggle still works, and filter matches\n // still force the row open via forcedOpenKeys, so users never\n // lose access — they just don't get auto-flooded.\n const secondaryNode = isSecondary?.(node) ?? false;\n const childrenAllSecondary =\n hasChildren && isSecondary != null && children!.every((c) => isSecondary(c));\n const skipExpandAll = secondaryNode || childrenAllSecondary;\n // A non-null `expandAll` is a live bulk state, not just a one-off change\n // signal: a node mounted *while* expand-all is active (because an ancestor\n // just opened) inherits it as its initial open state, so opening a parent\n // cascades all the way down — expand/collapse-all are recursive. The\n // skipExpandAll guard keeps secondary subtrees from auto-flooding. When\n // expandAll is null (before any toolbar click) we fall back to defaultOpen.\n const initialOpen =\n expandAll !== null && !skipExpandAll\n ? expandAll\n : defaultOpen\n ? defaultOpen(node, depth)\n : depth < 1;\n const [open, setOpen] = useState(initialOpen);\n const prevExpandAll = useRef(expandAll);\n const isSelected = selected === node;\n const key = getKey(node);\n const isForcedOpen = forcedOpenKeys?.has(key) ?? false;\n const isOpen = isForcedOpen || open;\n\n useEffect(() => {\n if (expandAll !== null && expandAll !== prevExpandAll.current && !skipExpandAll) {\n setOpen(expandAll);\n }\n prevExpandAll.current = expandAll;\n }, [expandAll, skipExpandAll]);\n\n // Guards a lazy fetch so a node loads its children at most once per mount and\n // a resolution arriving after the node was reused (key changed) is ignored.\n const loadRequested = useRef(false);\n const nodeKey = getKey(node);\n const loadKeyRef = useRef(nodeKey);\n\n function loadLazyChildren() {\n if (!loadChildren || loadRequested.current) return;\n loadRequested.current = true;\n loadKeyRef.current = nodeKey;\n setLoading(true);\n setError(null);\n loadChildren(node)\n .then((kids) => {\n if (loadKeyRef.current !== nodeKey) return;\n setLoadedChildren(kids);\n setLoading(false);\n })\n .catch((err) => {\n if (loadKeyRef.current !== nodeKey) return;\n // Surfaced to renderRow via ctx.error; allow a retry on re-toggle.\n loadRequested.current = false;\n setError(err);\n setLoading(false);\n });\n }\n\n function toggle() {\n if (!expandable) return;\n setOpen((o) => {\n const next = !o;\n // Only fetch when transitioning into the open state, so collapsing a\n // not-yet-loaded (e.g. previously-failed) lazy node never triggers a load.\n if (next && lazyUnloaded) loadLazyChildren();\n return next;\n });\n }\n\n const defaultRowBg = isSelected ? \"bg-primary/10 border-l-2 border-primary\" : \"hover:bg-accent\";\n const rowClassName = rowClass ? rowClass(node, isSelected) : defaultRowBg;\n\n return (\n <div\n role=\"treeitem\"\n aria-expanded={expandable ? isOpen : undefined}\n aria-selected={isSelected}\n >\n <div\n className={cn(\"flex items-center gap-1.5 py-1 px-2 cursor-pointer text-sm\", rowClassName)}\n style={{ paddingLeft: `${depth * indentPx + basePaddingPx}px` }}\n onClick={(e) => {\n e.stopPropagation();\n onSelect?.(node);\n toggle();\n }}\n >\n {expandable ? (\n <button\n type=\"button\"\n aria-label={isOpen ? \"Collapse\" : \"Expand\"}\n // The caret only toggles expansion — stopPropagation keeps the row's\n // onClick (which selects) from firing, so expanding a node never\n // selects it.\n onClick={(e) => {\n e.stopPropagation();\n toggle();\n }}\n className=\"flex shrink-0 items-center text-muted-foreground\"\n >\n <Icon icon={isOpen ? UiChevronDown : UiChevronRight} className=\"text-xs w-3\" />\n </button>\n ) : (\n <span className=\"w-3 shrink-0\" aria-hidden />\n )}\n {renderRow({\n node,\n depth,\n open: isOpen,\n selected: isSelected,\n hasChildren,\n toggle,\n loading,\n error,\n })}\n </div>\n {isOpen && hasChildren && (\n <div role=\"group\">\n {children!.map((child) => (\n <TreeNode\n key={getKey(child)}\n node={child}\n depth={depth + 1}\n expandAll={expandAll}\n forcedOpenKeys={forcedOpenKeys}\n selected={selected}\n getChildren={getChildren}\n getKey={getKey}\n renderRow={renderRow}\n indentPx={indentPx}\n basePaddingPx={basePaddingPx}\n {...(defaultOpen ? { defaultOpen } : {})}\n {...(onSelect ? { onSelect } : {})}\n {...(rowClass ? { rowClass } : {})}\n {...(isSecondary ? { isSecondary } : {})}\n {...(hasMoreChildren ? { hasMoreChildren } : {})}\n {...(loadChildren ? { loadChildren } : {})}\n />\n ))}\n </div>\n )}\n </div>\n );\n}\n"],"names":["useState","useRef","useEffect","jsxs","cn","jsx","Icon","UiChevronDown","UiChevronRight"],"mappings":";;;;;;;;AAiEO,SAAS,SAAY;AAAA,EAC1B;AAAA,EACA,QAAQ;AAAA,EACR,YAAY;AAAA,EACZ,iBAAiB;AAAA,EACjB,WAAW;AAAA,EACX;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA,WAAW;AAAA,EACX,gBAAgB;AAAA,EAChB;AAAA,EACA;AAAA,EACA;AACF,GAAqB;AAInB,QAAM,CAAC,gBAAgB,iBAAiB,IAAIA,MAAAA,SAAqB,IAAI;AACrE,QAAM,CAAC,SAAS,UAAU,IAAIA,MAAAA,SAAS,KAAK;AAC5C,QAAM,CAAC,OAAO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AE,CAAC,GAAG,EAAE,cAAc,CAAC,CAAC,CAAC,KAAK,SAAS,CAAC;IACjD,QAAQ,CAAC,EAAE,CAAC,IAAI,EAAE,CAAC,EAAE,QAAQ,EAAE,OAAO,KAAK,MAAM,CAAC;IAClD,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB;;;;;OAKG;IACH,eAAe,CAAC,EAAE,CAAC,IAAI,EAAE,CAAC,KAAK,OAAO,CAAC;IACvC;;;;;OAKG;IACH,YAAY,CAAC,EAAE,CAAC,IAAI,EAAE,CAAC,KAAK,OAAO,CAAC,CAAC,EAAE,CAAC,CAAC;IACzC;;;;;;;;;;;;;;;OAeG;IACH,WAAW,CAAC,EAAE,CAAC,IAAI,EAAE,CAAC,KAAK,OAAO,CAAC;CACpC,CAAC;AAEF,wBAAgB,QAAQ,CAAC,CAAC,EAAE,EAC1B,IAAI,EACJ,KAAS,EACT,SAAgB,EAChB,cAAqB,EACrB,QAAe,EACf,WAAW,EACX,WAAW,EACX,MAAM,EACN,QAAQ,EACR,SAAS,EACT,QAAQ,EACR,QAAa,EACb,aAAiB,EACjB,WAAW,EACX,eAAe,EACf,YAAY,GACb,EAAE,aAAa,CAAC,CAAC,CAAC,2CAyKlB"}
@@ -30,16 +30,16 @@ function TreeNode({
30
30
  const hasChildren = ((children == null ? void 0 : children.length) ?? 0) > 0;
31
31
  const lazyUnloaded = ((hasMoreChildren == null ? void 0 : hasMoreChildren(node)) ?? false) && loadedChildren === null;
32
32
  const expandable = hasChildren || lazyUnloaded;
33
- const initialOpen = defaultOpen ? defaultOpen(node, depth) : depth < 1;
33
+ const secondaryNode = (isSecondary == null ? void 0 : isSecondary(node)) ?? false;
34
+ const childrenAllSecondary = hasChildren && isSecondary != null && children.every((c) => isSecondary(c));
35
+ const skipExpandAll = secondaryNode || childrenAllSecondary;
36
+ const initialOpen = expandAll !== null && !skipExpandAll ? expandAll : defaultOpen ? defaultOpen(node, depth) : depth < 1;
34
37
  const [open, setOpen] = useState(initialOpen);
35
38
  const prevExpandAll = useRef(expandAll);
36
39
  const isSelected = selected === node;
37
40
  const key = getKey(node);
38
41
  const isForcedOpen = (forcedOpenKeys == null ? void 0 : forcedOpenKeys.has(key)) ?? false;
39
42
  const isOpen = isForcedOpen || open;
40
- const secondaryNode = (isSecondary == null ? void 0 : isSecondary(node)) ?? false;
41
- const childrenAllSecondary = hasChildren && isSecondary != null && children.every((c) => isSecondary(c));
42
- const skipExpandAll = secondaryNode || childrenAllSecondary;
43
43
  useEffect(() => {
44
44
  if (expandAll !== null && expandAll !== prevExpandAll.current && !skipExpandAll) {
45
45
  setOpen(expandAll);
@@ -95,10 +95,16 @@ function TreeNode({
95
95
  },
96
96
  children: [
97
97
  expandable ? /* @__PURE__ */ jsx(
98
- Icon,
98
+ "button",
99
99
  {
100
- icon: isOpen ? UiChevronDown : UiChevronRight,
101
- className: "text-muted-foreground text-xs w-3"
100
+ type: "button",
101
+ "aria-label": isOpen ? "Collapse" : "Expand",
102
+ onClick: (e) => {
103
+ e.stopPropagation();
104
+ toggle();
105
+ },
106
+ className: "flex shrink-0 items-center text-muted-foreground",
107
+ children: /* @__PURE__ */ jsx(Icon, { icon: isOpen ? UiChevronDown : UiChevronRight, className: "text-xs w-3" })
102
108
  }
103
109
  ) : /* @__PURE__ */ jsx("span", { className: "w-3 shrink-0", "aria-hidden": true }),
104
110
  renderRow({
@@ -1 +1 @@
1
- {"version":3,"file":"TreeNode.js","sources":["../../src/data/TreeNode.tsx"],"sourcesContent":["import { useEffect, useRef, useState, type ReactNode } from \"react\";\nimport { cn } from \"../lib/utils\";\nimport { Icon } from \"./Icon\";\nimport { UiChevronDown, UiChevronRight } from \"../icons\";\n\nexport type TreeRowContext<T> = {\n node: T;\n depth: number;\n open: boolean;\n selected: boolean;\n hasChildren: boolean;\n toggle: () => void;\n /** True while this node's lazy children are being fetched via loadChildren. */\n loading: boolean;\n /** The rejection value from loadChildren, or null when there was no error. */\n error: unknown;\n};\n\nexport type TreeNodeProps<T> = {\n node: T;\n depth?: number;\n expandAll?: boolean | null;\n forcedOpenKeys?: Set<string | number> | null;\n selected?: T | null;\n defaultOpen?: (node: T, depth: number) => boolean;\n getChildren: (node: T) => T[] | undefined;\n getKey: (node: T) => string | number;\n onSelect?: (node: T) => void;\n renderRow: (ctx: TreeRowContext<T>) => ReactNode;\n rowClass?: (node: T, selected: boolean) => string;\n indentPx?: number;\n basePaddingPx?: number;\n /**\n * Reports that a node has children that are not yet loaded — it renders an\n * expand chevron even when `getChildren` returns nothing. On the first open\n * the node fetches them via `loadChildren`. Without this (the default), a\n * node is expandable only when `getChildren` already returns children.\n */\n hasMoreChildren?: (node: T) => boolean;\n /**\n * Lazily fetch a node's children the first time it is opened. Resolves to the\n * child nodes (which may themselves be lazy). A rejection is surfaced to\n * `renderRow` via `ctx.error` and is not retried until the node is collapsed\n * and reopened. Required for any node `hasMoreChildren` returns true for.\n */\n loadChildren?: (node: T) => Promise<T[]>;\n /**\n * Marks a node as a **secondary child** of its parent. Secondary\n * children keep the full tree structure (they render, they can be\n * opened manually) but opt out of the bulk behaviours a caller\n * typically wants when they click the toolbar:\n *\n * - Tree-wide filter: their text is skipped during match detection\n * so typing in the search box never surfaces a row because one\n * of its secondary children happened to match.\n * - Expand all: secondary nodes stay at their default-open state\n * instead of being forced open, preventing 28k field rows from\n * flooding the viewport when an operator hits the button on a\n * schema with hundreds of tables.\n *\n * Default: every node is primary (returns false).\n */\n isSecondary?: (node: T) => boolean;\n};\n\nexport function TreeNode<T>({\n node,\n depth = 0,\n expandAll = null,\n forcedOpenKeys = null,\n selected = null,\n defaultOpen,\n getChildren,\n getKey,\n onSelect,\n renderRow,\n rowClass,\n indentPx = 16,\n basePaddingPx = 8,\n isSecondary,\n hasMoreChildren,\n loadChildren,\n}: TreeNodeProps<T>) {\n // Lazily-fetched children take precedence over the synchronous ones once a\n // load has resolved; until then `loadedChildren` is null and we fall back to\n // getChildren. A node can be \"lazy\" (hasMoreChildren) with no sync children.\n const [loadedChildren, setLoadedChildren] = useState<T[] | null>(null);\n const [loading, setLoading] = useState(false);\n const [error, setError] = useState<unknown>(null);\n const syncChildren = getChildren(node);\n const children = loadedChildren ?? syncChildren;\n const hasChildren = (children?.length ?? 0) > 0;\n const lazyUnloaded = (hasMoreChildren?.(node) ?? false) && loadedChildren === null;\n // The chevron shows when there is something to reveal: either real children\n // are present, or the node is lazy and has not been loaded yet.\n const expandable = hasChildren || lazyUnloaded;\n const initialOpen = defaultOpen ? defaultOpen(node, depth) : depth < 1;\n const [open, setOpen] = useState(initialOpen);\n const prevExpandAll = useRef(expandAll);\n const isSelected = selected === node;\n const key = getKey(node);\n const isForcedOpen = forcedOpenKeys?.has(key) ?? false;\n const isOpen = isForcedOpen || open;\n // A node opts out of bulk expand-all in two distinct cases:\n //\n // 1. The node itself is secondary (its edge from the parent is\n // secondary) — rare at the root, but the rule is symmetric.\n // 2. All of the node's children are secondary — the common case.\n // This is what keeps an \"Expand all\" on a schema tree from\n // flooding the viewport with every table's field rows: the\n // table opens to nothing structural worth seeing in bulk, so\n // we leave it closed until the operator clicks it manually.\n //\n // In both cases the manual toggle still works, and filter matches\n // still force the row open via forcedOpenKeys, so users never\n // lose access — they just don't get auto-flooded.\n const secondaryNode = isSecondary?.(node) ?? false;\n const childrenAllSecondary =\n hasChildren && isSecondary != null && children!.every((c) => isSecondary(c));\n const skipExpandAll = secondaryNode || childrenAllSecondary;\n\n useEffect(() => {\n if (expandAll !== null && expandAll !== prevExpandAll.current && !skipExpandAll) {\n setOpen(expandAll);\n }\n prevExpandAll.current = expandAll;\n }, [expandAll, skipExpandAll]);\n\n // Guards a lazy fetch so a node loads its children at most once per mount and\n // a resolution arriving after the node was reused (key changed) is ignored.\n const loadRequested = useRef(false);\n const nodeKey = getKey(node);\n const loadKeyRef = useRef(nodeKey);\n\n function loadLazyChildren() {\n if (!loadChildren || loadRequested.current) return;\n loadRequested.current = true;\n loadKeyRef.current = nodeKey;\n setLoading(true);\n setError(null);\n loadChildren(node)\n .then((kids) => {\n if (loadKeyRef.current !== nodeKey) return;\n setLoadedChildren(kids);\n setLoading(false);\n })\n .catch((err) => {\n if (loadKeyRef.current !== nodeKey) return;\n // Surfaced to renderRow via ctx.error; allow a retry on re-toggle.\n loadRequested.current = false;\n setError(err);\n setLoading(false);\n });\n }\n\n function toggle() {\n if (!expandable) return;\n setOpen((o) => {\n const next = !o;\n // Only fetch when transitioning into the open state, so collapsing a\n // not-yet-loaded (e.g. previously-failed) lazy node never triggers a load.\n if (next && lazyUnloaded) loadLazyChildren();\n return next;\n });\n }\n\n const defaultRowBg = isSelected ? \"bg-primary/10 border-l-2 border-primary\" : \"hover:bg-accent\";\n const rowClassName = rowClass ? rowClass(node, isSelected) : defaultRowBg;\n\n return (\n <div\n role=\"treeitem\"\n aria-expanded={expandable ? isOpen : undefined}\n aria-selected={isSelected}\n >\n <div\n className={cn(\"flex items-center gap-1.5 py-1 px-2 cursor-pointer text-sm\", rowClassName)}\n style={{ paddingLeft: `${depth * indentPx + basePaddingPx}px` }}\n onClick={(e) => {\n e.stopPropagation();\n onSelect?.(node);\n toggle();\n }}\n >\n {expandable ? (\n <Icon\n icon={isOpen ? UiChevronDown : UiChevronRight}\n className=\"text-muted-foreground text-xs w-3\"\n />\n ) : (\n <span className=\"w-3 shrink-0\" aria-hidden />\n )}\n {renderRow({\n node,\n depth,\n open: isOpen,\n selected: isSelected,\n hasChildren,\n toggle,\n loading,\n error,\n })}\n </div>\n {isOpen && hasChildren && (\n <div role=\"group\">\n {children!.map((child) => (\n <TreeNode\n key={getKey(child)}\n node={child}\n depth={depth + 1}\n expandAll={expandAll}\n forcedOpenKeys={forcedOpenKeys}\n selected={selected}\n getChildren={getChildren}\n getKey={getKey}\n renderRow={renderRow}\n indentPx={indentPx}\n basePaddingPx={basePaddingPx}\n {...(defaultOpen ? { defaultOpen } : {})}\n {...(onSelect ? { onSelect } : {})}\n {...(rowClass ? { rowClass } : {})}\n {...(isSecondary ? { isSecondary } : {})}\n {...(hasMoreChildren ? { hasMoreChildren } : {})}\n {...(loadChildren ? { loadChildren } : {})}\n />\n ))}\n </div>\n )}\n </div>\n );\n}\n"],"names":[],"mappings":";;;;;;AAiEO,SAAS,SAAY;AAAA,EAC1B;AAAA,EACA,QAAQ;AAAA,EACR,YAAY;AAAA,EACZ,iBAAiB;AAAA,EACjB,WAAW;AAAA,EACX;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA,WAAW;AAAA,EACX,gBAAgB;AAAA,EAChB;AAAA,EACA;AAAA,EACA;AACF,GAAqB;AAInB,QAAM,CAAC,gBAAgB,iBAAiB,IAAI,SAAqB,IAAI;AACrE,QAAM,CAAC,SAAS,UAAU,IAAI,SAAS,KAAK;AAC5C,QAAM,CAAC,OAAO,QAAQ,IAAI,SAAkB,IAAI;AAChD,QAAM,eAAe,YAAY,IAAI;AACrC,QAAM,WAAW,kBAAkB;AACnC,QAAM,gBAAe,qCAAU,WAAU,KAAK;AAC9C,QAAM,iBAAgB,mDAAkB,UAAS,UAAU,mBAAmB;AAG9E,QAAM,aAAa,eAAe;AAClC,QAAM,cAAc,cAAc,YAAY,MAAM,KAAK,IAAI,QAAQ;AACrE,QAAM,CAAC,MAAM,OAAO,IAAI,SAAS,WAAW;AAC5C,QAAM,gBAAgB,OAAO,SAAS;AACtC,QAAM,aAAa,aAAa;AAChC,QAAM,MAAM,OAAO,IAAI;AACvB,QAAM,gBAAe,iDAAgB,IAAI,SAAQ;AACjD,QAAM,SAAS,gBAAgB;AAc/B,QAAM,iBAAgB,2CAAc,UAAS;AAC7C,QAAM,uBACJ,eAAe,eAAe,QAAQ,SAAU,MAAM,CAAC,MAAM,YAAY,CAAC,CAAC;AAC7E,QAAM,gBAAgB,iBAAiB;AAEvC,YAAU,MAAM;AACd,QAAI,cAAc,QAAQ,cAAc,cAAc,WAAW,CAAC,eAAe;AAC/E,cAAQ,SAAS;AAAA,IACnB;AAC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B;AAAA,kBAC/B,WAAU;AAAA,gBAAA;AAAA,cAAA,IAGZ,oBAAC,QAAA,EAAK,WAAU,gBAAe,eAAW,MAAC;AAAA,cAE5C,UAAU;AAAA,gBACT;AAAA,gBACA;AAAA,gBACA,MAAM;AAAA,gBACN,UAAU;AAAA,gBACV;AAAA,gBACA;AAAA,gBACA;AAAA,gBACA;AAAA,cAAA,CACD;AAAA,YAAA;AAAA,UAAA;AAAA,QAAA;AAAA,QAEF,UAAU,eACT,oBAAC,OAAA,EAAI,MAAK,SACP,UAAA,SAAU,IAAI,CAAC,UACd;AAAA,UAAC;AAAA,UAAA;AAAA,YAEC,MAAM;AAAA,YACN,OAAO,QAAQ;AAAA,YACf;AAAA,YACA;AAAA,YACA;AAAA,YACA;AAAA,YACA;AAAA,YACA;AAAA,YACA;AAAA,YACA;AAAA,YACC,GAAI,cAAc,EAAE,YAAA,IAAgB,CAAA;AAAA,YACpC,GAAI,WAAW,EAAE,SAAA,IAAa,CAAA;AAAA,YAC9B,GAAI,WAAW,EAAE,SAAA,IAAa,CAAA;AAAA,YAC9B,GAAI,cAAc,EAAE,YAAA,IAAgB,CAAA;AAAA,YACpC,GAAI,kBAAkB,EAAE,gBAAA,IAAoB,CAAA;AAAA,YAC5C,GAAI,eAAe,EAAE,iBAAiB,CAAA;AAAA,UAAC;AAAA,UAhBnC,OAAO,KAAK;AAAA,QAAA,CAkBpB,EAAA,CACH;AAAA,MAAA;AAAA,IAAA;AAAA,EAAA;AAIR;"}
1
+ {"version":3,"file":"TreeNode.js","sources":["../../src/data/TreeNode.tsx"],"sourcesContent":["import { useEffect, useRef, useState, type ReactNode } from \"react\";\nimport { cn } from \"../lib/utils\";\nimport { Icon } from \"./Icon\";\nimport { UiChevronDown, UiChevronRight } from \"../icons\";\n\nexport type TreeRowContext<T> = {\n node: T;\n depth: number;\n open: boolean;\n selected: boolean;\n hasChildren: boolean;\n toggle: () => void;\n /** True while this node's lazy children are being fetched via loadChildren. */\n loading: boolean;\n /** The rejection value from loadChildren, or null when there was no error. */\n error: unknown;\n};\n\nexport type TreeNodeProps<T> = {\n node: T;\n depth?: number;\n expandAll?: boolean | null;\n forcedOpenKeys?: Set<string | number> | null;\n selected?: T | null;\n defaultOpen?: (node: T, depth: number) => boolean;\n getChildren: (node: T) => T[] | undefined;\n getKey: (node: T) => string | number;\n onSelect?: (node: T) => void;\n renderRow: (ctx: TreeRowContext<T>) => ReactNode;\n rowClass?: (node: T, selected: boolean) => string;\n indentPx?: number;\n basePaddingPx?: number;\n /**\n * Reports that a node has children that are not yet loaded — it renders an\n * expand chevron even when `getChildren` returns nothing. On the first open\n * the node fetches them via `loadChildren`. Without this (the default), a\n * node is expandable only when `getChildren` already returns children.\n */\n hasMoreChildren?: (node: T) => boolean;\n /**\n * Lazily fetch a node's children the first time it is opened. Resolves to the\n * child nodes (which may themselves be lazy). A rejection is surfaced to\n * `renderRow` via `ctx.error` and is not retried until the node is collapsed\n * and reopened. Required for any node `hasMoreChildren` returns true for.\n */\n loadChildren?: (node: T) => Promise<T[]>;\n /**\n * Marks a node as a **secondary child** of its parent. Secondary\n * children keep the full tree structure (they render, they can be\n * opened manually) but opt out of the bulk behaviours a caller\n * typically wants when they click the toolbar:\n *\n * - Tree-wide filter: their text is skipped during match detection\n * so typing in the search box never surfaces a row because one\n * of its secondary children happened to match.\n * - Expand all: secondary nodes stay at their default-open state\n * instead of being forced open, preventing 28k field rows from\n * flooding the viewport when an operator hits the button on a\n * schema with hundreds of tables.\n *\n * Default: every node is primary (returns false).\n */\n isSecondary?: (node: T) => boolean;\n};\n\nexport function TreeNode<T>({\n node,\n depth = 0,\n expandAll = null,\n forcedOpenKeys = null,\n selected = null,\n defaultOpen,\n getChildren,\n getKey,\n onSelect,\n renderRow,\n rowClass,\n indentPx = 16,\n basePaddingPx = 8,\n isSecondary,\n hasMoreChildren,\n loadChildren,\n}: TreeNodeProps<T>) {\n // Lazily-fetched children take precedence over the synchronous ones once a\n // load has resolved; until then `loadedChildren` is null and we fall back to\n // getChildren. A node can be \"lazy\" (hasMoreChildren) with no sync children.\n const [loadedChildren, setLoadedChildren] = useState<T[] | null>(null);\n const [loading, setLoading] = useState(false);\n const [error, setError] = useState<unknown>(null);\n const syncChildren = getChildren(node);\n const children = loadedChildren ?? syncChildren;\n const hasChildren = (children?.length ?? 0) > 0;\n const lazyUnloaded = (hasMoreChildren?.(node) ?? false) && loadedChildren === null;\n // The chevron shows when there is something to reveal: either real children\n // are present, or the node is lazy and has not been loaded yet.\n const expandable = hasChildren || lazyUnloaded;\n // A node opts out of bulk expand-all in two distinct cases:\n //\n // 1. The node itself is secondary (its edge from the parent is\n // secondary) — rare at the root, but the rule is symmetric.\n // 2. All of the node's children are secondary — the common case.\n // This is what keeps an \"Expand all\" on a schema tree from\n // flooding the viewport with every table's field rows: the\n // table opens to nothing structural worth seeing in bulk, so\n // we leave it closed until the operator clicks it manually.\n //\n // In both cases the manual toggle still works, and filter matches\n // still force the row open via forcedOpenKeys, so users never\n // lose access — they just don't get auto-flooded.\n const secondaryNode = isSecondary?.(node) ?? false;\n const childrenAllSecondary =\n hasChildren && isSecondary != null && children!.every((c) => isSecondary(c));\n const skipExpandAll = secondaryNode || childrenAllSecondary;\n // A non-null `expandAll` is a live bulk state, not just a one-off change\n // signal: a node mounted *while* expand-all is active (because an ancestor\n // just opened) inherits it as its initial open state, so opening a parent\n // cascades all the way down — expand/collapse-all are recursive. The\n // skipExpandAll guard keeps secondary subtrees from auto-flooding. When\n // expandAll is null (before any toolbar click) we fall back to defaultOpen.\n const initialOpen =\n expandAll !== null && !skipExpandAll\n ? expandAll\n : defaultOpen\n ? defaultOpen(node, depth)\n : depth < 1;\n const [open, setOpen] = useState(initialOpen);\n const prevExpandAll = useRef(expandAll);\n const isSelected = selected === node;\n const key = getKey(node);\n const isForcedOpen = forcedOpenKeys?.has(key) ?? false;\n const isOpen = isForcedOpen || open;\n\n useEffect(() => {\n if (expandAll !== null && expandAll !== prevExpandAll.current && !skipExpandAll) {\n setOpen(expandAll);\n }\n prevExpandAll.current = expandAll;\n }, [expandAll, skipExpandAll]);\n\n // Guards a lazy fetch so a node loads its children at most once per mount and\n // a resolution arriving after the node was reused (key changed) is ignored.\n const loadRequested = useRef(false);\n const nodeKey = getKey(node);\n const loadKeyRef = useRef(nodeKey);\n\n function loadLazyChildren() {\n if (!loadChildren || loadRequested.current) return;\n loadRequested.current = true;\n loadKeyRef.current = nodeKey;\n setLoading(true);\n setError(null);\n loadChildren(node)\n .then((kids) => {\n if (loadKeyRef.current !== nodeKey) return;\n setLoadedChildren(kids);\n setLoading(false);\n })\n .catch((err) => {\n if (loadKeyRef.current !== nodeKey) return;\n // Surfaced to renderRow via ctx.error; allow a retry on re-toggle.\n loadRequested.current = false;\n setError(err);\n setLoading(false);\n });\n }\n\n function toggle() {\n if (!expandable) return;\n setOpen((o) => {\n const next = !o;\n // Only fetch when transitioning into the open state, so collapsing a\n // not-yet-loaded (e.g. previously-failed) lazy node never triggers a load.\n if (next && lazyUnloaded) loadLazyChildren();\n return next;\n });\n }\n\n const defaultRowBg = isSelected ? \"bg-primary/10 border-l-2 border-primary\" : \"hover:bg-accent\";\n const rowClassName = rowClass ? rowClass(node, isSelected) : defaultRowBg;\n\n return (\n <div\n role=\"treeitem\"\n aria-expanded={expandable ? isOpen : undefined}\n aria-selected={isSelected}\n >\n <div\n className={cn(\"flex items-center gap-1.5 py-1 px-2 cursor-pointer text-sm\", rowClassName)}\n style={{ paddingLeft: `${depth * indentPx + basePaddingPx}px` }}\n onClick={(e) => {\n e.stopPropagation();\n onSelect?.(node);\n toggle();\n }}\n >\n {expandable ? (\n <button\n type=\"button\"\n aria-label={isOpen ? \"Collapse\" : \"Expand\"}\n // The caret only toggles expansion — stopPropagation keeps the row's\n // onClick (which selects) from firing, so expanding a node never\n // selects it.\n onClick={(e) => {\n e.stopPropagation();\n toggle();\n }}\n className=\"flex shrink-0 items-center text-muted-foreground\"\n >\n <Icon icon={isOpen ? UiChevronDown : UiChevronRight} className=\"text-xs w-3\" />\n </button>\n ) : (\n <span className=\"w-3 shrink-0\" aria-hidden />\n )}\n {renderRow({\n node,\n depth,\n open: isOpen,\n selected: isSelected,\n hasChildren,\n toggle,\n loading,\n error,\n })}\n </div>\n {isOpen && hasChildren && (\n <div role=\"group\">\n {children!.map((child) => (\n <TreeNode\n key={getKey(child)}\n node={child}\n depth={depth + 1}\n expandAll={expandAll}\n forcedOpenKeys={forcedOpenKeys}\n selected={selected}\n getChildren={getChildren}\n getKey={getKey}\n renderRow={renderRow}\n indentPx={indentPx}\n basePaddingPx={basePaddingPx}\n {...(defaultOpen ? { defaultOpen } : {})}\n {...(onSelect ? { onSelect } : {})}\n {...(rowClass ? { rowClass } : {})}\n {...(isSecondary ? { isSecondary } : {})}\n {...(hasMoreChildren ? { hasMoreChildren } : {})}\n {...(loadChildren ? { loadChildren } : {})}\n />\n ))}\n </div>\n )}\n </div>\n );\n}\n"],"names":[],"mappings":";;;;;;AAiEO,SAAS,SAAY;AAAA,EAC1B;AAAA,EACA,QAAQ;AAAA,EACR,YAAY;AAAA,EACZ,iBAAiB;AAAA,EACjB,WAAW;AAAA,EACX;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA,WAAW;AAAA,EACX,gBAAgB;AAAA,EAChB;AAAA,EACA;AAAA,EACA;AACF,GAAqB;AAInB,QAAM,CAAC,gBAAgB,iBAAiB,IAAI,SAAqB,IAAI;AACrE,QAAM,CAAC,SAAS,UAAU,IAAI,SAAS,KAAK;AAC5C,QAAM,CAAC,OAAO,QAAQ,IAAI,SAAkB,IAAI;AAChD,QAAM,eAAe,YAAY,IAAI;AACrC,QAAM,WAAW,kBAAkB;AACnC,QAAM,gBAAe,qCAAU,WAAU,KAAK;AAC9C,QAAM,iBAAgB,mDAAkB,UAAS,UAAU,mBAAmB;AAG9E,QAAM,aAAa,eAAe;AAclC,QAAM,iBAAgB,2CAAc,UAAS;AAC7C,QAAM,uBACJ,eAAe,eAAe,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,EAAE,SAAA,IAAa,CAAA;AAAA,YAC9B,GAAI,WAAW,EAAE,SAAA,IAAa,CAAA;AAAA,YAC9B,GAAI,cAAc,EAAE,YAAA,IAAgB,CAAA;AAAA,YACpC,GAAI,kBAAkB,EAAE,gBAAA,IAAoB,CAAA;AAAA,YAC5C,GAAI,eAAe,EAAE,iBAAiB,CAAA;AAAA,UAAC;AAAA,UAhBnC,OAAO,KAAK;AAAA,QAAA,CAkBpB,EAAA,CACH;AAAA,MAAA;AAAA,IAAA;AAAA,EAAA;AAIR;"}
@@ -0,0 +1,85 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
+ const classVarianceAuthority = require("class-variance-authority");
4
+ const badgeVariants = classVarianceAuthority.cva(
5
+ "inline-flex items-center gap-1 rounded-full border border-transparent font-medium whitespace-nowrap align-middle",
6
+ {
7
+ variants: {
8
+ tone: {
9
+ neutral: "",
10
+ success: "",
11
+ danger: "",
12
+ warning: "",
13
+ info: ""
14
+ },
15
+ variant: {
16
+ soft: "",
17
+ solid: "",
18
+ outline: "bg-transparent"
19
+ },
20
+ size: {
21
+ xxs: "min-h-4 px-1.5 py-0.5 text-[9px] leading-none",
22
+ xs: "min-h-[18px] px-1.5 py-0.5 text-[10px] leading-none",
23
+ sm: "h-4 px-1.5 py-0 text-[10px] leading-none",
24
+ md: "px-2 py-0.5 text-xs",
25
+ lg: "px-2.5 py-1 text-sm"
26
+ }
27
+ },
28
+ compoundVariants: [
29
+ { tone: "neutral", variant: "soft", class: "bg-muted text-foreground" },
30
+ { tone: "neutral", variant: "solid", class: "bg-foreground text-background" },
31
+ { tone: "neutral", variant: "outline", class: "border-border text-foreground" },
32
+ {
33
+ tone: "success",
34
+ variant: "soft",
35
+ class: "bg-green-100 text-green-800 dark:bg-green-500/20 dark:text-green-300"
36
+ },
37
+ { tone: "success", variant: "solid", class: "bg-green-500 text-white" },
38
+ {
39
+ tone: "success",
40
+ variant: "outline",
41
+ class: "border-green-500 text-green-700 dark:text-green-400"
42
+ },
43
+ {
44
+ tone: "danger",
45
+ variant: "soft",
46
+ class: "bg-red-100 text-red-800 dark:bg-red-500/20 dark:text-red-300"
47
+ },
48
+ { tone: "danger", variant: "solid", class: "bg-red-500 text-white" },
49
+ {
50
+ tone: "danger",
51
+ variant: "outline",
52
+ class: "border-red-500 text-red-700 dark:text-red-400"
53
+ },
54
+ {
55
+ tone: "warning",
56
+ variant: "soft",
57
+ class: "bg-yellow-100 text-yellow-800 dark:bg-yellow-500/20 dark:text-yellow-300"
58
+ },
59
+ { tone: "warning", variant: "solid", class: "bg-yellow-400 text-yellow-950" },
60
+ {
61
+ tone: "warning",
62
+ variant: "outline",
63
+ class: "border-yellow-500 text-yellow-700 dark:text-yellow-400"
64
+ },
65
+ {
66
+ tone: "info",
67
+ variant: "soft",
68
+ class: "bg-blue-100 text-blue-800 dark:bg-blue-500/20 dark:text-blue-300"
69
+ },
70
+ { tone: "info", variant: "solid", class: "bg-blue-500 text-white" },
71
+ {
72
+ tone: "info",
73
+ variant: "outline",
74
+ class: "border-blue-500 text-blue-700 dark:text-blue-400"
75
+ }
76
+ ],
77
+ defaultVariants: {
78
+ tone: "neutral",
79
+ variant: "soft",
80
+ size: "md"
81
+ }
82
+ }
83
+ );
84
+ exports.badgeVariants = badgeVariants;
85
+ //# sourceMappingURL=badge-variants.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"badge-variants.cjs","sources":["../../src/data/badge-variants.ts"],"sourcesContent":["import { cva } from \"class-variance-authority\";\n\nexport const badgeVariants = cva(\n \"inline-flex items-center gap-1 rounded-full border border-transparent font-medium whitespace-nowrap align-middle\",\n {\n variants: {\n tone: {\n neutral: \"\",\n success: \"\",\n danger: \"\",\n warning: \"\",\n info: \"\",\n },\n variant: {\n soft: \"\",\n solid: \"\",\n outline: \"bg-transparent\",\n },\n size: {\n xxs: \"min-h-4 px-1.5 py-0.5 text-[9px] leading-none\",\n xs: \"min-h-[18px] px-1.5 py-0.5 text-[10px] leading-none\",\n sm: \"h-4 px-1.5 py-0 text-[10px] leading-none\",\n md: \"px-2 py-0.5 text-xs\",\n lg: \"px-2.5 py-1 text-sm\",\n },\n },\n compoundVariants: [\n { tone: \"neutral\", variant: \"soft\", class: \"bg-muted text-foreground\" },\n { tone: \"neutral\", variant: \"solid\", class: \"bg-foreground text-background\" },\n { tone: \"neutral\", variant: \"outline\", class: \"border-border text-foreground\" },\n\n {\n tone: \"success\",\n variant: \"soft\",\n class: \"bg-green-100 text-green-800 dark:bg-green-500/20 dark:text-green-300\",\n },\n { tone: \"success\", variant: \"solid\", class: \"bg-green-500 text-white\" },\n {\n tone: \"success\",\n variant: \"outline\",\n class: \"border-green-500 text-green-700 dark:text-green-400\",\n },\n\n {\n tone: \"danger\",\n variant: \"soft\",\n class: \"bg-red-100 text-red-800 dark:bg-red-500/20 dark:text-red-300\",\n },\n { tone: \"danger\", variant: \"solid\", class: \"bg-red-500 text-white\" },\n {\n tone: \"danger\",\n variant: \"outline\",\n class: \"border-red-500 text-red-700 dark:text-red-400\",\n },\n\n {\n tone: \"warning\",\n variant: \"soft\",\n class: \"bg-yellow-100 text-yellow-800 dark:bg-yellow-500/20 dark:text-yellow-300\",\n },\n { tone: \"warning\", variant: \"solid\", class: \"bg-yellow-400 text-yellow-950\" },\n {\n tone: \"warning\",\n variant: \"outline\",\n class: \"border-yellow-500 text-yellow-700 dark:text-yellow-400\",\n },\n\n {\n tone: \"info\",\n variant: \"soft\",\n class: \"bg-blue-100 text-blue-800 dark:bg-blue-500/20 dark:text-blue-300\",\n },\n { tone: \"info\", variant: \"solid\", class: \"bg-blue-500 text-white\" },\n {\n tone: \"info\",\n variant: \"outline\",\n class: \"border-blue-500 text-blue-700 dark:text-blue-400\",\n },\n ],\n defaultVariants: {\n tone: \"neutral\",\n variant: \"soft\",\n size: \"md\",\n },\n },\n);\n"],"names":["cva"],"mappings":";;;AAEO,MAAM,gBAAgBA,uBAAAA;AAAAA,EAC3B;AAAA,EACA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,EAAE,MAAM,QAAQ,SAAS,SAAS,OAAO,yBAAA;AAAA,MACzC;AAAA,QACE,MAAM;AAAA,QACN,SAAS;AAAA,QACT,OAAO;AAAA,MAAA;AAAA,IACT;AAAA,IAEF,iBAAiB;AAAA,MACf,MAAM;AAAA,MACN,SAAS;AAAA,MACT,MAAM;AAAA,IAAA;AAAA,EACR;AAEJ;;"}
@@ -0,0 +1,6 @@
1
+ export declare const badgeVariants: (props?: ({
2
+ tone?: "success" | "warning" | "neutral" | "info" | "danger" | null | undefined;
3
+ variant?: "outline" | "solid" | "soft" | null | undefined;
4
+ size?: "xs" | "sm" | "md" | "lg" | "xxs" | null | undefined;
5
+ } & import('class-variance-authority/types').ClassProp) | undefined) => string;
6
+ //# sourceMappingURL=badge-variants.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"badge-variants.d.ts","sourceRoot":"","sources":["../../src/data/badge-variants.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,aAAa;;;;8EAmFzB,CAAC"}
@@ -0,0 +1,85 @@
1
+ import { cva } from "class-variance-authority";
2
+ const badgeVariants = cva(
3
+ "inline-flex items-center gap-1 rounded-full border border-transparent font-medium whitespace-nowrap align-middle",
4
+ {
5
+ variants: {
6
+ tone: {
7
+ neutral: "",
8
+ success: "",
9
+ danger: "",
10
+ warning: "",
11
+ info: ""
12
+ },
13
+ variant: {
14
+ soft: "",
15
+ solid: "",
16
+ outline: "bg-transparent"
17
+ },
18
+ size: {
19
+ xxs: "min-h-4 px-1.5 py-0.5 text-[9px] leading-none",
20
+ xs: "min-h-[18px] px-1.5 py-0.5 text-[10px] leading-none",
21
+ sm: "h-4 px-1.5 py-0 text-[10px] leading-none",
22
+ md: "px-2 py-0.5 text-xs",
23
+ lg: "px-2.5 py-1 text-sm"
24
+ }
25
+ },
26
+ compoundVariants: [
27
+ { tone: "neutral", variant: "soft", class: "bg-muted text-foreground" },
28
+ { tone: "neutral", variant: "solid", class: "bg-foreground text-background" },
29
+ { tone: "neutral", variant: "outline", class: "border-border text-foreground" },
30
+ {
31
+ tone: "success",
32
+ variant: "soft",
33
+ class: "bg-green-100 text-green-800 dark:bg-green-500/20 dark:text-green-300"
34
+ },
35
+ { tone: "success", variant: "solid", class: "bg-green-500 text-white" },
36
+ {
37
+ tone: "success",
38
+ variant: "outline",
39
+ class: "border-green-500 text-green-700 dark:text-green-400"
40
+ },
41
+ {
42
+ tone: "danger",
43
+ variant: "soft",
44
+ class: "bg-red-100 text-red-800 dark:bg-red-500/20 dark:text-red-300"
45
+ },
46
+ { tone: "danger", variant: "solid", class: "bg-red-500 text-white" },
47
+ {
48
+ tone: "danger",
49
+ variant: "outline",
50
+ class: "border-red-500 text-red-700 dark:text-red-400"
51
+ },
52
+ {
53
+ tone: "warning",
54
+ variant: "soft",
55
+ class: "bg-yellow-100 text-yellow-800 dark:bg-yellow-500/20 dark:text-yellow-300"
56
+ },
57
+ { tone: "warning", variant: "solid", class: "bg-yellow-400 text-yellow-950" },
58
+ {
59
+ tone: "warning",
60
+ variant: "outline",
61
+ class: "border-yellow-500 text-yellow-700 dark:text-yellow-400"
62
+ },
63
+ {
64
+ tone: "info",
65
+ variant: "soft",
66
+ class: "bg-blue-100 text-blue-800 dark:bg-blue-500/20 dark:text-blue-300"
67
+ },
68
+ { tone: "info", variant: "solid", class: "bg-blue-500 text-white" },
69
+ {
70
+ tone: "info",
71
+ variant: "outline",
72
+ class: "border-blue-500 text-blue-700 dark:text-blue-400"
73
+ }
74
+ ],
75
+ defaultVariants: {
76
+ tone: "neutral",
77
+ variant: "soft",
78
+ size: "md"
79
+ }
80
+ }
81
+ );
82
+ export {
83
+ badgeVariants
84
+ };
85
+ //# sourceMappingURL=badge-variants.js.map