@kanzo-tech/ui 0.0.1-alpha

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 (499) hide show
  1. package/README.md +60 -0
  2. package/dist/analytics.d.ts +36 -0
  3. package/dist/analytics.d.ts.map +1 -0
  4. package/dist/analytics.js +155 -0
  5. package/dist/analytics.js.map +1 -0
  6. package/dist/charts/arrow.d.ts +37 -0
  7. package/dist/charts/arrow.d.ts.map +1 -0
  8. package/dist/charts/arrow.js +29 -0
  9. package/dist/charts/arrow.js.map +1 -0
  10. package/dist/charts/chart-axes.d.ts +59 -0
  11. package/dist/charts/chart-axes.d.ts.map +1 -0
  12. package/dist/charts/chart-axes.js +39 -0
  13. package/dist/charts/chart-axes.js.map +1 -0
  14. package/dist/charts/chart-config.d.ts +52 -0
  15. package/dist/charts/chart-config.d.ts.map +1 -0
  16. package/dist/charts/chart-config.js +43 -0
  17. package/dist/charts/chart-config.js.map +1 -0
  18. package/dist/charts/chart-inputs.d.ts +174 -0
  19. package/dist/charts/chart-inputs.d.ts.map +1 -0
  20. package/dist/charts/chart-inputs.js +382 -0
  21. package/dist/charts/chart-inputs.js.map +1 -0
  22. package/dist/charts/chart-interactors.d.ts +75 -0
  23. package/dist/charts/chart-interactors.d.ts.map +1 -0
  24. package/dist/charts/chart-interactors.js +35 -0
  25. package/dist/charts/chart-interactors.js.map +1 -0
  26. package/dist/charts/chart-legend.d.ts +38 -0
  27. package/dist/charts/chart-legend.d.ts.map +1 -0
  28. package/dist/charts/chart-legend.js +49 -0
  29. package/dist/charts/chart-legend.js.map +1 -0
  30. package/dist/charts/chart-marks.d.ts +124 -0
  31. package/dist/charts/chart-marks.d.ts.map +1 -0
  32. package/dist/charts/chart-marks.js +109 -0
  33. package/dist/charts/chart-marks.js.map +1 -0
  34. package/dist/charts/chart-root.d.ts +90 -0
  35. package/dist/charts/chart-root.d.ts.map +1 -0
  36. package/dist/charts/chart-root.js +162 -0
  37. package/dist/charts/chart-root.js.map +1 -0
  38. package/dist/charts/chart-spec.d.ts +126 -0
  39. package/dist/charts/chart-spec.d.ts.map +1 -0
  40. package/dist/charts/chart-spec.js +133 -0
  41. package/dist/charts/chart-spec.js.map +1 -0
  42. package/dist/charts/chart-stat.d.ts +23 -0
  43. package/dist/charts/chart-stat.d.ts.map +1 -0
  44. package/dist/charts/chart-stat.js +24 -0
  45. package/dist/charts/chart-stat.js.map +1 -0
  46. package/dist/charts/id-set-client.d.ts +42 -0
  47. package/dist/charts/id-set-client.d.ts.map +1 -0
  48. package/dist/charts/id-set-client.js +43 -0
  49. package/dist/charts/id-set-client.js.map +1 -0
  50. package/dist/charts/mosaic-provider.d.ts +70 -0
  51. package/dist/charts/mosaic-provider.d.ts.map +1 -0
  52. package/dist/charts/mosaic-provider.js +53 -0
  53. package/dist/charts/mosaic-provider.js.map +1 -0
  54. package/dist/charts/query-client.d.ts +22 -0
  55. package/dist/charts/query-client.d.ts.map +1 -0
  56. package/dist/charts/query-client.js +26 -0
  57. package/dist/charts/query-client.js.map +1 -0
  58. package/dist/charts/tokenized-plot.d.ts +26 -0
  59. package/dist/charts/tokenized-plot.d.ts.map +1 -0
  60. package/dist/charts/tokenized-plot.js +41 -0
  61. package/dist/charts/tokenized-plot.js.map +1 -0
  62. package/dist/charts/use-chart-query.d.ts +30 -0
  63. package/dist/charts/use-chart-query.d.ts.map +1 -0
  64. package/dist/charts/use-chart-query.js +19 -0
  65. package/dist/charts/use-chart-query.js.map +1 -0
  66. package/dist/composites/CodeEditor.d.ts +64 -0
  67. package/dist/composites/CodeEditor.d.ts.map +1 -0
  68. package/dist/composites/CodeEditor.js +521 -0
  69. package/dist/composites/CodeEditor.js.map +1 -0
  70. package/dist/composites/MadeWith.d.ts +39 -0
  71. package/dist/composites/MadeWith.d.ts.map +1 -0
  72. package/dist/composites/MadeWith.js +30 -0
  73. package/dist/composites/MadeWith.js.map +1 -0
  74. package/dist/composites/Preferences.d.ts +155 -0
  75. package/dist/composites/Preferences.d.ts.map +1 -0
  76. package/dist/composites/Preferences.js +501 -0
  77. package/dist/composites/Preferences.js.map +1 -0
  78. package/dist/composites/Questionnaire.d.ts +215 -0
  79. package/dist/composites/Questionnaire.d.ts.map +1 -0
  80. package/dist/composites/Questionnaire.js +422 -0
  81. package/dist/composites/Questionnaire.js.map +1 -0
  82. package/dist/composites/SidebarIdentity.d.ts +63 -0
  83. package/dist/composites/SidebarIdentity.d.ts.map +1 -0
  84. package/dist/composites/SidebarIdentity.js +103 -0
  85. package/dist/composites/SidebarIdentity.js.map +1 -0
  86. package/dist/composites/code-editor-search.d.ts +40 -0
  87. package/dist/composites/code-editor-search.d.ts.map +1 -0
  88. package/dist/composites/code-editor-search.js +212 -0
  89. package/dist/composites/code-editor-search.js.map +1 -0
  90. package/dist/composites/sidebar.d.ts +129 -0
  91. package/dist/composites/sidebar.d.ts.map +1 -0
  92. package/dist/composites/sidebar.js +671 -0
  93. package/dist/composites/sidebar.js.map +1 -0
  94. package/dist/composites/theme-notice.d.ts +54 -0
  95. package/dist/composites/theme-notice.d.ts.map +1 -0
  96. package/dist/composites/theme-notice.js +19 -0
  97. package/dist/composites/theme-notice.js.map +1 -0
  98. package/dist/editor.d.ts +3 -0
  99. package/dist/editor.d.ts.map +1 -0
  100. package/dist/editor.js +6 -0
  101. package/dist/editor.js.map +1 -0
  102. package/dist/guard-corpus.d.ts +63 -0
  103. package/dist/guard-corpus.d.ts.map +1 -0
  104. package/dist/index.d.ts +112 -0
  105. package/dist/index.d.ts.map +1 -0
  106. package/dist/index.js +696 -0
  107. package/dist/index.js.map +1 -0
  108. package/dist/layouts/section.d.ts +166 -0
  109. package/dist/layouts/section.d.ts.map +1 -0
  110. package/dist/layouts/section.js +153 -0
  111. package/dist/layouts/section.js.map +1 -0
  112. package/dist/layouts/shell.d.ts +128 -0
  113. package/dist/layouts/shell.d.ts.map +1 -0
  114. package/dist/layouts/shell.js +107 -0
  115. package/dist/layouts/shell.js.map +1 -0
  116. package/dist/lib/cn.d.ts +4 -0
  117. package/dist/lib/cn.d.ts.map +1 -0
  118. package/dist/lib/cn.js +9 -0
  119. package/dist/lib/cn.js.map +1 -0
  120. package/dist/lib/is-active-path.d.ts +13 -0
  121. package/dist/lib/is-active-path.d.ts.map +1 -0
  122. package/dist/lib/is-active-path.js +7 -0
  123. package/dist/lib/is-active-path.js.map +1 -0
  124. package/dist/lib/theme-tick.d.ts +37 -0
  125. package/dist/lib/theme-tick.d.ts.map +1 -0
  126. package/dist/lib/theme-tick.js +30 -0
  127. package/dist/lib/theme-tick.js.map +1 -0
  128. package/dist/lib/token-color.d.ts +74 -0
  129. package/dist/lib/token-color.d.ts.map +1 -0
  130. package/dist/lib/token-color.js +35 -0
  131. package/dist/lib/token-color.js.map +1 -0
  132. package/dist/lib/use-is-mobile.d.ts +2 -0
  133. package/dist/lib/use-is-mobile.d.ts.map +1 -0
  134. package/dist/lib/use-is-mobile.js +17 -0
  135. package/dist/lib/use-is-mobile.js.map +1 -0
  136. package/dist/shark-parity.divergences.d.ts +104 -0
  137. package/dist/shark-parity.divergences.d.ts.map +1 -0
  138. package/dist/simples/FacetFilter.d.ts +57 -0
  139. package/dist/simples/FacetFilter.d.ts.map +1 -0
  140. package/dist/simples/FacetFilter.js +167 -0
  141. package/dist/simples/FacetFilter.js.map +1 -0
  142. package/dist/simples/FieldArray.d.ts +42 -0
  143. package/dist/simples/FieldArray.d.ts.map +1 -0
  144. package/dist/simples/FieldArray.js +76 -0
  145. package/dist/simples/FieldArray.js.map +1 -0
  146. package/dist/simples/Link.d.ts +38 -0
  147. package/dist/simples/Link.d.ts.map +1 -0
  148. package/dist/simples/Link.js +24 -0
  149. package/dist/simples/Link.js.map +1 -0
  150. package/dist/simples/accordion.d.ts +8 -0
  151. package/dist/simples/accordion.d.ts.map +1 -0
  152. package/dist/simples/accordion.js +78 -0
  153. package/dist/simples/accordion.js.map +1 -0
  154. package/dist/simples/action-bar.d.ts +101 -0
  155. package/dist/simples/action-bar.d.ts.map +1 -0
  156. package/dist/simples/action-bar.js +195 -0
  157. package/dist/simples/action-bar.js.map +1 -0
  158. package/dist/simples/alert-dialog.d.ts +24 -0
  159. package/dist/simples/alert-dialog.d.ts.map +1 -0
  160. package/dist/simples/alert-dialog.js +43 -0
  161. package/dist/simples/alert-dialog.js.map +1 -0
  162. package/dist/simples/alert.d.ts +36 -0
  163. package/dist/simples/alert.d.ts.map +1 -0
  164. package/dist/simples/alert.js +123 -0
  165. package/dist/simples/alert.js.map +1 -0
  166. package/dist/simples/avatar.d.ts +37 -0
  167. package/dist/simples/avatar.d.ts.map +1 -0
  168. package/dist/simples/avatar.js +133 -0
  169. package/dist/simples/avatar.js.map +1 -0
  170. package/dist/simples/badge.d.ts +66 -0
  171. package/dist/simples/badge.d.ts.map +1 -0
  172. package/dist/simples/badge.js +138 -0
  173. package/dist/simples/badge.js.map +1 -0
  174. package/dist/simples/breadcrumb.d.ts +19 -0
  175. package/dist/simples/breadcrumb.d.ts.map +1 -0
  176. package/dist/simples/breadcrumb.js +107 -0
  177. package/dist/simples/breadcrumb.js.map +1 -0
  178. package/dist/simples/button-group.d.ts +19 -0
  179. package/dist/simples/button-group.d.ts.map +1 -0
  180. package/dist/simples/button-group.js +69 -0
  181. package/dist/simples/button-group.js.map +1 -0
  182. package/dist/simples/button.d.ts +148 -0
  183. package/dist/simples/button.d.ts.map +1 -0
  184. package/dist/simples/button.js +157 -0
  185. package/dist/simples/button.js.map +1 -0
  186. package/dist/simples/calendar.d.ts +45 -0
  187. package/dist/simples/calendar.d.ts.map +1 -0
  188. package/dist/simples/calendar.js +342 -0
  189. package/dist/simples/calendar.js.map +1 -0
  190. package/dist/simples/card.d.ts +43 -0
  191. package/dist/simples/card.d.ts.map +1 -0
  192. package/dist/simples/card.js +151 -0
  193. package/dist/simples/card.js.map +1 -0
  194. package/dist/simples/checkbox.d.ts +25 -0
  195. package/dist/simples/checkbox.d.ts.map +1 -0
  196. package/dist/simples/checkbox.js +103 -0
  197. package/dist/simples/checkbox.js.map +1 -0
  198. package/dist/simples/client-only.d.ts +3 -0
  199. package/dist/simples/client-only.d.ts.map +1 -0
  200. package/dist/simples/client-only.js +7 -0
  201. package/dist/simples/client-only.js.map +1 -0
  202. package/dist/simples/clipboard.d.ts +11 -0
  203. package/dist/simples/clipboard.d.ts.map +1 -0
  204. package/dist/simples/clipboard.js +99 -0
  205. package/dist/simples/clipboard.js.map +1 -0
  206. package/dist/simples/collapsible.d.ts +8 -0
  207. package/dist/simples/collapsible.d.ts.map +1 -0
  208. package/dist/simples/collapsible.js +79 -0
  209. package/dist/simples/collapsible.js.map +1 -0
  210. package/dist/simples/color-picker.d.ts +62 -0
  211. package/dist/simples/color-picker.d.ts.map +1 -0
  212. package/dist/simples/color-picker.js +391 -0
  213. package/dist/simples/color-picker.js.map +1 -0
  214. package/dist/simples/combobox.d.ts +66 -0
  215. package/dist/simples/combobox.d.ts.map +1 -0
  216. package/dist/simples/combobox.js +230 -0
  217. package/dist/simples/combobox.js.map +1 -0
  218. package/dist/simples/command.d.ts +45 -0
  219. package/dist/simples/command.d.ts.map +1 -0
  220. package/dist/simples/command.js +180 -0
  221. package/dist/simples/command.js.map +1 -0
  222. package/dist/simples/data-list.d.ts +25 -0
  223. package/dist/simples/data-list.d.ts.map +1 -0
  224. package/dist/simples/data-list.js +62 -0
  225. package/dist/simples/data-list.js.map +1 -0
  226. package/dist/simples/date-picker.d.ts +16 -0
  227. package/dist/simples/date-picker.d.ts.map +1 -0
  228. package/dist/simples/date-picker.js +117 -0
  229. package/dist/simples/date-picker.js.map +1 -0
  230. package/dist/simples/diagnostic.d.ts +138 -0
  231. package/dist/simples/diagnostic.d.ts.map +1 -0
  232. package/dist/simples/diagnostic.js +288 -0
  233. package/dist/simples/diagnostic.js.map +1 -0
  234. package/dist/simples/dialog.d.ts +100 -0
  235. package/dist/simples/dialog.d.ts.map +1 -0
  236. package/dist/simples/dialog.js +267 -0
  237. package/dist/simples/dialog.js.map +1 -0
  238. package/dist/simples/download-trigger.d.ts +3 -0
  239. package/dist/simples/download-trigger.d.ts.map +1 -0
  240. package/dist/simples/download-trigger.js +7 -0
  241. package/dist/simples/download-trigger.js.map +1 -0
  242. package/dist/simples/editable.d.ts +23 -0
  243. package/dist/simples/editable.d.ts.map +1 -0
  244. package/dist/simples/editable.js +70 -0
  245. package/dist/simples/editable.js.map +1 -0
  246. package/dist/simples/field.d.ts +58 -0
  247. package/dist/simples/field.d.ts.map +1 -0
  248. package/dist/simples/field.js +285 -0
  249. package/dist/simples/field.js.map +1 -0
  250. package/dist/simples/file-upload.d.ts +19 -0
  251. package/dist/simples/file-upload.d.ts.map +1 -0
  252. package/dist/simples/file-upload.js +192 -0
  253. package/dist/simples/file-upload.js.map +1 -0
  254. package/dist/simples/float.d.ts +45 -0
  255. package/dist/simples/float.d.ts.map +1 -0
  256. package/dist/simples/float.js +40 -0
  257. package/dist/simples/float.js.map +1 -0
  258. package/dist/simples/floating-panel.d.ts +25 -0
  259. package/dist/simples/floating-panel.d.ts.map +1 -0
  260. package/dist/simples/floating-panel.js +95 -0
  261. package/dist/simples/floating-panel.js.map +1 -0
  262. package/dist/simples/highlight.d.ts +6 -0
  263. package/dist/simples/highlight.d.ts.map +1 -0
  264. package/dist/simples/highlight.js +24 -0
  265. package/dist/simples/highlight.js.map +1 -0
  266. package/dist/simples/hover-card.d.ts +11 -0
  267. package/dist/simples/hover-card.d.ts.map +1 -0
  268. package/dist/simples/hover-card.js +83 -0
  269. package/dist/simples/hover-card.js.map +1 -0
  270. package/dist/simples/image-cropper.d.ts +17 -0
  271. package/dist/simples/image-cropper.d.ts.map +1 -0
  272. package/dist/simples/image-cropper.js +139 -0
  273. package/dist/simples/image-cropper.js.map +1 -0
  274. package/dist/simples/input-group.d.ts +116 -0
  275. package/dist/simples/input-group.d.ts.map +1 -0
  276. package/dist/simples/input-group.js +245 -0
  277. package/dist/simples/input-group.js.map +1 -0
  278. package/dist/simples/input.d.ts +26 -0
  279. package/dist/simples/input.d.ts.map +1 -0
  280. package/dist/simples/input.js +60 -0
  281. package/dist/simples/input.js.map +1 -0
  282. package/dist/simples/item.d.ts +72 -0
  283. package/dist/simples/item.d.ts.map +1 -0
  284. package/dist/simples/item.js +180 -0
  285. package/dist/simples/item.js.map +1 -0
  286. package/dist/simples/json-tree-view.d.ts +7 -0
  287. package/dist/simples/json-tree-view.d.ts.map +1 -0
  288. package/dist/simples/json-tree-view.js +71 -0
  289. package/dist/simples/json-tree-view.js.map +1 -0
  290. package/dist/simples/kbd.d.ts +25 -0
  291. package/dist/simples/kbd.d.ts.map +1 -0
  292. package/dist/simples/kbd.js +50 -0
  293. package/dist/simples/kbd.js.map +1 -0
  294. package/dist/simples/listbox.d.ts +46 -0
  295. package/dist/simples/listbox.d.ts.map +1 -0
  296. package/dist/simples/listbox.js +218 -0
  297. package/dist/simples/listbox.js.map +1 -0
  298. package/dist/simples/menu.d.ts +60 -0
  299. package/dist/simples/menu.d.ts.map +1 -0
  300. package/dist/simples/menu.js +294 -0
  301. package/dist/simples/menu.js.map +1 -0
  302. package/dist/simples/native-select.d.ts +36 -0
  303. package/dist/simples/native-select.d.ts.map +1 -0
  304. package/dist/simples/native-select.js +77 -0
  305. package/dist/simples/native-select.js.map +1 -0
  306. package/dist/simples/number-input.d.ts +35 -0
  307. package/dist/simples/number-input.d.ts.map +1 -0
  308. package/dist/simples/number-input.js +142 -0
  309. package/dist/simples/number-input.js.map +1 -0
  310. package/dist/simples/pagination.d.ts +11 -0
  311. package/dist/simples/pagination.d.ts.map +1 -0
  312. package/dist/simples/pagination.js +78 -0
  313. package/dist/simples/pagination.js.map +1 -0
  314. package/dist/simples/password-input.d.ts +23 -0
  315. package/dist/simples/password-input.d.ts.map +1 -0
  316. package/dist/simples/password-input.js +90 -0
  317. package/dist/simples/password-input.js.map +1 -0
  318. package/dist/simples/pin-input.d.ts +30 -0
  319. package/dist/simples/pin-input.d.ts.map +1 -0
  320. package/dist/simples/pin-input.js +71 -0
  321. package/dist/simples/pin-input.js.map +1 -0
  322. package/dist/simples/popover.d.ts +42 -0
  323. package/dist/simples/popover.d.ts.map +1 -0
  324. package/dist/simples/popover.js +188 -0
  325. package/dist/simples/popover.js.map +1 -0
  326. package/dist/simples/progress.d.ts +23 -0
  327. package/dist/simples/progress.d.ts.map +1 -0
  328. package/dist/simples/progress.js +82 -0
  329. package/dist/simples/progress.js.map +1 -0
  330. package/dist/simples/prose.d.ts +17 -0
  331. package/dist/simples/prose.d.ts.map +1 -0
  332. package/dist/simples/prose.js +18 -0
  333. package/dist/simples/prose.js.map +1 -0
  334. package/dist/simples/radio-group.d.ts +23 -0
  335. package/dist/simples/radio-group.d.ts.map +1 -0
  336. package/dist/simples/radio-group.js +149 -0
  337. package/dist/simples/radio-group.js.map +1 -0
  338. package/dist/simples/rating.d.ts +10 -0
  339. package/dist/simples/rating.d.ts.map +1 -0
  340. package/dist/simples/rating.js +81 -0
  341. package/dist/simples/rating.js.map +1 -0
  342. package/dist/simples/resizable.d.ts +16 -0
  343. package/dist/simples/resizable.d.ts.map +1 -0
  344. package/dist/simples/resizable.js +57 -0
  345. package/dist/simples/resizable.js.map +1 -0
  346. package/dist/simples/scroll-area.d.ts +23 -0
  347. package/dist/simples/scroll-area.d.ts.map +1 -0
  348. package/dist/simples/scroll-area.js +88 -0
  349. package/dist/simples/scroll-area.js.map +1 -0
  350. package/dist/simples/segment-group.d.ts +27 -0
  351. package/dist/simples/segment-group.d.ts.map +1 -0
  352. package/dist/simples/segment-group.js +129 -0
  353. package/dist/simples/segment-group.js.map +1 -0
  354. package/dist/simples/select.d.ts +34 -0
  355. package/dist/simples/select.d.ts.map +1 -0
  356. package/dist/simples/select.js +258 -0
  357. package/dist/simples/select.js.map +1 -0
  358. package/dist/simples/separator.d.ts +12 -0
  359. package/dist/simples/separator.d.ts.map +1 -0
  360. package/dist/simples/separator.js +27 -0
  361. package/dist/simples/separator.js.map +1 -0
  362. package/dist/simples/sheet.d.ts +94 -0
  363. package/dist/simples/sheet.d.ts.map +1 -0
  364. package/dist/simples/sheet.js +172 -0
  365. package/dist/simples/sheet.js.map +1 -0
  366. package/dist/simples/show.d.ts +10 -0
  367. package/dist/simples/show.d.ts.map +1 -0
  368. package/dist/simples/show.js +9 -0
  369. package/dist/simples/show.js.map +1 -0
  370. package/dist/simples/skeleton.d.ts +3 -0
  371. package/dist/simples/skeleton.d.ts.map +1 -0
  372. package/dist/simples/skeleton.js +23 -0
  373. package/dist/simples/skeleton.js.map +1 -0
  374. package/dist/simples/skip-nav.d.ts +54 -0
  375. package/dist/simples/skip-nav.d.ts.map +1 -0
  376. package/dist/simples/skip-nav.js +42 -0
  377. package/dist/simples/skip-nav.js.map +1 -0
  378. package/dist/simples/slider.d.ts +29 -0
  379. package/dist/simples/slider.d.ts.map +1 -0
  380. package/dist/simples/slider.js +189 -0
  381. package/dist/simples/slider.js.map +1 -0
  382. package/dist/simples/spinner.d.ts +2 -0
  383. package/dist/simples/spinner.d.ts.map +1 -0
  384. package/dist/simples/spinner.js +20 -0
  385. package/dist/simples/spinner.js.map +1 -0
  386. package/dist/simples/stat-tile.d.ts +31 -0
  387. package/dist/simples/stat-tile.d.ts.map +1 -0
  388. package/dist/simples/stat-tile.js +64 -0
  389. package/dist/simples/stat-tile.js.map +1 -0
  390. package/dist/simples/status.d.ts +48 -0
  391. package/dist/simples/status.d.ts.map +1 -0
  392. package/dist/simples/status.js +57 -0
  393. package/dist/simples/status.js.map +1 -0
  394. package/dist/simples/steps.d.ts +20 -0
  395. package/dist/simples/steps.d.ts.map +1 -0
  396. package/dist/simples/steps.js +171 -0
  397. package/dist/simples/steps.js.map +1 -0
  398. package/dist/simples/suggestions.d.ts +43 -0
  399. package/dist/simples/suggestions.d.ts.map +1 -0
  400. package/dist/simples/suggestions.js +38 -0
  401. package/dist/simples/suggestions.js.map +1 -0
  402. package/dist/simples/swatch.d.ts +73 -0
  403. package/dist/simples/swatch.d.ts.map +1 -0
  404. package/dist/simples/swatch.js +35 -0
  405. package/dist/simples/swatch.js.map +1 -0
  406. package/dist/simples/switch.d.ts +5 -0
  407. package/dist/simples/switch.d.ts.map +1 -0
  408. package/dist/simples/switch.js +71 -0
  409. package/dist/simples/switch.js.map +1 -0
  410. package/dist/simples/table.d.ts +55 -0
  411. package/dist/simples/table.d.ts.map +1 -0
  412. package/dist/simples/table.js +166 -0
  413. package/dist/simples/table.js.map +1 -0
  414. package/dist/simples/tabs.d.ts +55 -0
  415. package/dist/simples/tabs.d.ts.map +1 -0
  416. package/dist/simples/tabs.js +133 -0
  417. package/dist/simples/tabs.js.map +1 -0
  418. package/dist/simples/tags-input.d.ts +64 -0
  419. package/dist/simples/tags-input.d.ts.map +1 -0
  420. package/dist/simples/tags-input.js +228 -0
  421. package/dist/simples/tags-input.js.map +1 -0
  422. package/dist/simples/textarea.d.ts +6 -0
  423. package/dist/simples/textarea.d.ts.map +1 -0
  424. package/dist/simples/textarea.js +34 -0
  425. package/dist/simples/textarea.js.map +1 -0
  426. package/dist/simples/toast.d.ts +20 -0
  427. package/dist/simples/toast.d.ts.map +1 -0
  428. package/dist/simples/toast.js +127 -0
  429. package/dist/simples/toast.js.map +1 -0
  430. package/dist/simples/toggle-group.d.ts +20 -0
  431. package/dist/simples/toggle-group.d.ts.map +1 -0
  432. package/dist/simples/toggle-group.js +82 -0
  433. package/dist/simples/toggle-group.js.map +1 -0
  434. package/dist/simples/toggle.d.ts +35 -0
  435. package/dist/simples/toggle.d.ts.map +1 -0
  436. package/dist/simples/toggle.js +57 -0
  437. package/dist/simples/toggle.js.map +1 -0
  438. package/dist/simples/tooltip.d.ts +8 -0
  439. package/dist/simples/tooltip.d.ts.map +1 -0
  440. package/dist/simples/tooltip.js +80 -0
  441. package/dist/simples/tooltip.js.map +1 -0
  442. package/dist/simples/tour.d.ts +81 -0
  443. package/dist/simples/tour.d.ts.map +1 -0
  444. package/dist/simples/tour.js +253 -0
  445. package/dist/simples/tour.js.map +1 -0
  446. package/dist/simples/tree-view.d.ts +64 -0
  447. package/dist/simples/tree-view.d.ts.map +1 -0
  448. package/dist/simples/tree-view.js +300 -0
  449. package/dist/simples/tree-view.js.map +1 -0
  450. package/dist/styles.css +2 -0
  451. package/dist/table/data-table-content.d.ts +18 -0
  452. package/dist/table/data-table-content.d.ts.map +1 -0
  453. package/dist/table/data-table-content.js +53 -0
  454. package/dist/table/data-table-content.js.map +1 -0
  455. package/dist/table/data-table-pagination.d.ts +8 -0
  456. package/dist/table/data-table-pagination.d.ts.map +1 -0
  457. package/dist/table/data-table-pagination.js +65 -0
  458. package/dist/table/data-table-pagination.js.map +1 -0
  459. package/dist/table/data-table-root.d.ts +10 -0
  460. package/dist/table/data-table-root.d.ts.map +1 -0
  461. package/dist/table/data-table-root.js +21 -0
  462. package/dist/table/data-table-root.js.map +1 -0
  463. package/dist/table/data-table-toolbar.d.ts +44 -0
  464. package/dist/table/data-table-toolbar.d.ts.map +1 -0
  465. package/dist/table/data-table-toolbar.js +87 -0
  466. package/dist/table/data-table-toolbar.js.map +1 -0
  467. package/dist/table/select-column.d.ts +16 -0
  468. package/dist/table/select-column.d.ts.map +1 -0
  469. package/dist/table/select-column.js +39 -0
  470. package/dist/table/select-column.js.map +1 -0
  471. package/dist/table/sortableHeader.d.ts +25 -0
  472. package/dist/table/sortableHeader.d.ts.map +1 -0
  473. package/dist/table/sortableHeader.js +43 -0
  474. package/dist/table/sortableHeader.js.map +1 -0
  475. package/dist/table/use-data-table.d.ts +40 -0
  476. package/dist/table/use-data-table.d.ts.map +1 -0
  477. package/dist/table/use-data-table.js +65 -0
  478. package/dist/table/use-data-table.js.map +1 -0
  479. package/dist/table.d.ts +15 -0
  480. package/dist/table.d.ts.map +1 -0
  481. package/dist/table.js +22 -0
  482. package/dist/table.js.map +1 -0
  483. package/dist/theme/KanzoTheme.d.ts +74 -0
  484. package/dist/theme/KanzoTheme.d.ts.map +1 -0
  485. package/dist/theme/KanzoTheme.js +61 -0
  486. package/dist/theme/KanzoTheme.js.map +1 -0
  487. package/dist/theme/KanzoThemeProvider.d.ts +144 -0
  488. package/dist/theme/KanzoThemeProvider.d.ts.map +1 -0
  489. package/dist/theme/KanzoThemeProvider.js +271 -0
  490. package/dist/theme/KanzoThemeProvider.js.map +1 -0
  491. package/dist/theme/theme-context.d.ts +146 -0
  492. package/dist/theme/theme-context.d.ts.map +1 -0
  493. package/dist/theme/theme-context.js +18 -0
  494. package/dist/theme/theme-context.js.map +1 -0
  495. package/dist/theme/theme-script.d.ts +17 -0
  496. package/dist/theme/theme-script.d.ts.map +1 -0
  497. package/dist/theme/theme-script.js +16 -0
  498. package/dist/theme/theme-script.js.map +1 -0
  499. package/package.json +201 -0
@@ -0,0 +1,162 @@
1
+ "use client";
2
+ import { jsx as v, jsxs as Q } from "react/jsx-runtime";
3
+ import { useState as U, useRef as D, useEffect as X, useMemo as Z, useContext as K, createContext as tt } from "react";
4
+ import { ark as ot } from "@ark-ui/react/factory";
5
+ import { Selection as rt } from "@uwdata/mosaic-core";
6
+ import * as C from "@uwdata/vgplot";
7
+ import { cn as nt } from "../lib/cn.js";
8
+ import { chartSeriesColor as et, isColorToken as st, colorTokenName as G, chartColorScale as at } from "./chart-config.js";
9
+ import { compileChartSpec as ct, chartSpecSignature as lt, chartSpecWarnings as ut, buildChartSpec as it } from "./chart-spec.js";
10
+ import { useMosaic as ft } from "./mosaic-provider.js";
11
+ import { resolveTokenColor as I } from "../lib/token-color.js";
12
+ import { TokenizedPlot as mt } from "./tokenized-plot.js";
13
+ const a = C;
14
+ function pt(t) {
15
+ var o, c;
16
+ switch (t.kind) {
17
+ case "mark": {
18
+ const l = a[t.mark];
19
+ if (!l) return null;
20
+ if (t.source === null) return l(t.options);
21
+ const e = t.source.kind === "values" ? [...t.source.values] : C.from(t.source.table, t.source.filterBy ? { filterBy: t.source.filterBy } : void 0);
22
+ return l(e, t.options);
23
+ }
24
+ case "interactor":
25
+ return ((o = a[t.interactor]) == null ? void 0 : o.call(a, t.options)) ?? null;
26
+ case "attribute":
27
+ return ((c = a[t.name]) == null ? void 0 : c.call(a, t.value)) ?? null;
28
+ case "raw":
29
+ return t.value;
30
+ }
31
+ }
32
+ const g = tt(null);
33
+ function Rt() {
34
+ const t = K(g);
35
+ if (!t) throw new Error("useChartContext must be used within a <ChartRoot>.");
36
+ return t;
37
+ }
38
+ function Mt() {
39
+ return K(g);
40
+ }
41
+ const ht = {};
42
+ function Tt(t) {
43
+ const {
44
+ table: o,
45
+ filterBy: c,
46
+ as: l,
47
+ config: e = ht,
48
+ height: y = 200,
49
+ margin: x,
50
+ aspectRatio: N,
51
+ facetMargin: S,
52
+ facetGrid: d,
53
+ facetLabel: w,
54
+ attributes: b,
55
+ locale: k,
56
+ numberFormat: B,
57
+ children: i,
58
+ className: V,
59
+ plotClassName: _,
60
+ ref: z,
61
+ slot: L,
62
+ ...W
63
+ } = t, { coordinator: O, crossfilter: E, selected: Y, registerSelection: R } = ft(), [f] = U(() => rt.union()), s = l ?? f, u = c === void 0 ? E : c, M = D(null);
64
+ X(
65
+ // Only the selection this root minted is relayed: a caller-supplied `as` was wired by the
66
+ // caller (`include`, or another root), and relaying it again would double every clause.
67
+ () => R(s, { relay: s === f }),
68
+ [R, s, f]
69
+ );
70
+ const $ = JSON.stringify(B ?? null), q = Z(
71
+ () => ({
72
+ coordinator: O,
73
+ config: e,
74
+ table: o,
75
+ filterBy: u,
76
+ as: s,
77
+ color: (r) => {
78
+ const n = et(e, r);
79
+ return n === void 0 || !st(n) || typeof document > "u" ? n : I(M.current ?? document.documentElement, G(n));
80
+ },
81
+ formatNumber: (r, n) => new Intl.NumberFormat(k, n ?? B).format(r)
82
+ }),
83
+ // `numberKey` stands in for the options object's identity; `numberFormat` itself is read fresh.
84
+ // eslint-disable-next-line react-hooks/exhaustive-deps
85
+ [O, e, o, u, s, k, $]
86
+ ), T = ct(i, {
87
+ table: o,
88
+ filterBy: u,
89
+ as: s,
90
+ config: e,
91
+ resolveColor: Ct
92
+ }), m = lt(T), A = JSON.stringify(at(e)), J = D(null);
93
+ if (process.env.NODE_ENV !== "production" && J.current !== m) {
94
+ J.current = m;
95
+ const r = { shared: [E, Y] };
96
+ for (const n of ut(T, r)) console.warn(`[ChartRoot] ${n}`);
97
+ }
98
+ return /* @__PURE__ */ v(g.Provider, { value: q, children: /* @__PURE__ */ Q(
99
+ ot.div,
100
+ {
101
+ className: nt("flex w-full flex-col gap-2", V),
102
+ ref: (r) => {
103
+ M.current = r, gt(z, r);
104
+ },
105
+ ...W,
106
+ "data-slot": L ?? "chart-root",
107
+ children: [
108
+ /* @__PURE__ */ v(
109
+ mt,
110
+ {
111
+ className: _,
112
+ deps: [
113
+ m,
114
+ A,
115
+ o,
116
+ u,
117
+ s,
118
+ y,
119
+ N,
120
+ JSON.stringify(x ?? null),
121
+ JSON.stringify(S ?? null),
122
+ d,
123
+ w,
124
+ b
125
+ ],
126
+ render: (r, n) => {
127
+ const F = /* @__PURE__ */ new Map(), H = it(
128
+ { children: i, width: r, height: y, margin: x, aspectRatio: N, facetMargin: S, facetGrid: d, facetLabel: w, attributes: b },
129
+ {
130
+ table: o,
131
+ filterBy: u,
132
+ as: s,
133
+ config: e,
134
+ resolveColor: (p) => {
135
+ const h = G(p), P = F.get(h);
136
+ if (P !== void 0) return P;
137
+ const j = I(n, h);
138
+ return F.set(h, j), j;
139
+ }
140
+ }
141
+ );
142
+ return C.plot(...H.map(pt).filter((p) => p !== null));
143
+ }
144
+ }
145
+ ),
146
+ i
147
+ ]
148
+ }
149
+ ) });
150
+ }
151
+ function Ct(t) {
152
+ return t;
153
+ }
154
+ function gt(t, o) {
155
+ typeof t == "function" ? t(o) : t && (t.current = o);
156
+ }
157
+ export {
158
+ Tt as ChartRoot,
159
+ Rt as useChartContext,
160
+ Mt as useChartContextOptional
161
+ };
162
+ //# sourceMappingURL=chart-root.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"chart-root.js","sources":["../../src/charts/chart-root.tsx"],"sourcesContent":["\"use client\";\n\nimport { createContext, useContext, useEffect, useMemo, useRef, useState, type ReactNode, type Ref } from \"react\";\nimport type React from \"react\";\nimport { ark } from \"@ark-ui/react/factory\";\nimport { Selection, type Coordinator } from \"@uwdata/mosaic-core\";\nimport * as vg from \"@uwdata/vgplot\";\nimport { cn } from \"../lib/cn.js\";\nimport { chartColorScale, chartSeriesColor, colorTokenName, isColorToken, type ChartConfig } from \"./chart-config.js\";\nimport {\n buildChartSpec,\n chartSpecSignature,\n chartSpecWarnings,\n compileChartSpec,\n type ChartDirective,\n type ChartFacetOptions,\n type ChartMargin,\n type ChartSpecContext,\n} from \"./chart-spec.js\";\nimport { useMosaic } from \"./mosaic-provider.js\";\nimport { resolveTokenColor } from \"../lib/token-color.js\";\nimport { TokenizedPlot } from \"./tokenized-plot.js\";\n\n/** vgplot ships `any` for every directive; this is the one place we pin a shape to it. */\ntype VgDirective = (plot: unknown) => void;\nconst directives = vg as unknown as Record<string, ((...args: unknown[]) => VgDirective) | undefined>;\n\nfunction toVgDirective(directive: ChartDirective): VgDirective | null {\n switch (directive.kind) {\n case \"mark\": {\n const fn = directives[directive.mark];\n if (!fn) return null;\n // A decorator takes options only; everything else takes (data, options).\n if (directive.source === null) return fn(directive.options);\n const data =\n directive.source.kind === \"values\"\n ? [...directive.source.values]\n : vg.from(directive.source.table, directive.source.filterBy ? { filterBy: directive.source.filterBy } : undefined);\n return fn(data, directive.options);\n }\n case \"interactor\":\n return directives[directive.interactor]?.(directive.options) ?? null;\n case \"attribute\":\n return directives[directive.name]?.(directive.value) ?? null;\n case \"raw\":\n return directive.value as VgDirective;\n }\n}\n\nexport interface ChartContextValue {\n /** The active Mosaic coordinator, for a consumer that queries alongside the plot. */\n coordinator: Coordinator;\n config: ChartConfig;\n table?: string;\n /** What the marks filter by; `null` = the full relation. */\n filterBy: Selection | null;\n /** Where the interactors publish. */\n as: Selection;\n /**\n * The series colour, normalised to `rgb(...)` so it is safe for both CSS and Plot. `undefined`\n * for a key the config does not name.\n *\n * Normalising is what makes it dual-purpose and is also what makes it a **snapshot**: the answer\n * is read off the DOM when you call it, and nothing re-calls it when the theme or the scheme\n * changes. `ChartLegend` deliberately does not use this — its only sink is a `style`, so it\n * passes `var(--chart-N)` through and lets the browser follow the theme for free. Take the same\n * route for anything that only ends up in CSS; pair this with `useThemeTick` when you need the\n * literal, which is to say when you are handing it to Plot.\n */\n color: (key: string) => string | undefined;\n /** The chart's locale number formatter — one vocabulary for axes, legend and tooltip. */\n formatNumber: (value: number, options?: Intl.NumberFormatOptions) => string;\n}\n\nconst ChartContext = createContext<ChartContextValue | null>(null);\n\n/**\n * The chart context — config, selections, coordinator, and the `color` / `formatNumber` helpers\n * that keep a series' identity in one place. Throws outside a `<ChartRoot>`.\n *\n * Available to DOM parts (`ChartLegend`, a custom tooltip, a readout). **Not** to descriptors:\n * `ChartRoot` reads their props off the element before React renders them, so a mark cannot pull\n * anything out of context — pass the value down from the component that owns the `<ChartRoot>`.\n */\nexport function useChartContext(): ChartContextValue {\n const ctx = useContext(ChartContext);\n if (!ctx) throw new Error(\"useChartContext must be used within a <ChartRoot>.\");\n return ctx;\n}\n\n/** The chart context, or `null` — for parts that also work standalone, like `ChartLegend`. */\nexport function useChartContextOptional(): ChartContextValue | null {\n return useContext(ChartContext);\n}\n\nexport interface ChartRootProps\n extends Omit<React.ComponentProps<typeof ark.div>, \"children\">,\n ChartFacetOptions {\n /** The relation registered in the coordinator. Omit it when every mark carries its own `data`. */\n table?: string;\n /** What the marks filter by. Defaults to the `<MosaicProvider>` crossfilter; `null` = unfiltered. */\n filterBy?: Selection | null;\n /**\n * Where the child interactors publish, and what `ChartHighlight` reads back. Defaults to a\n * selection this root owns, relayed into the provider — see the note on `ChartRoot`. Pass one and\n * you own its wiring: nothing is relayed for you, though the provider's `reset()` still clears it.\n */\n as?: Selection;\n /** Series key → `{ label, color, icon }`. A non-empty config pins the plot's colour scale. */\n config?: ChartConfig;\n /** Plot height in px; the width is measured from the container. Default 200. */\n height?: number;\n margin?: number | ChartMargin;\n aspectRatio?: number;\n /**\n * Raw `vg.*` directives for anything the layer does not wrap. Applied last, so they win.\n * Keep the array referentially stable — a new array rebuilds the plot.\n */\n attributes?: readonly unknown[];\n /** BCP-47 tag for `formatNumber`. Defaults to the runtime locale. */\n locale?: string;\n /** Default options for `formatNumber` — the chart's number vocabulary in one place. */\n numberFormat?: Intl.NumberFormatOptions;\n /** Descriptors (marks, interactors, axes) plus real DOM parts such as `ChartLegend`. */\n children?: ReactNode;\n /** Class for the plot host itself, inside the root. */\n plotClassName?: string;\n}\n\nconst EMPTY_CONFIG: ChartConfig = {};\n\n/**\n * Why every chart owns a selection instead of sharing the page's.\n *\n * `ChartHighlight` does not filter — it asks the mark's **own** query which rows are selected, by\n * appending the predicate as an extra output column: `q._groupby.length ? q.select({__: pred})`.\n * On an aggregating mark that query has a `GROUP BY`, so a predicate naming a column this plot does\n * not group by is `Binder Error: column \"provider\" must appear in the GROUP BY clause`. The query\n * dies, vgplot swallows it, and **the plot keeps its previous render** — no error, no empty state,\n * nothing but a console line. It costs hours to find, because the symptom looks like a broken\n * crossfilter three components away.\n *\n * A page-wide publish target guarantees that failure the moment a second chart filters by a second\n * column. So each root publishes into a union of its own: those clauses, by construction, name only\n * columns this plot's own interactors could produce — which are the columns its marks group by. The\n * clauses are relayed on into the provider (`selected` → `crossfilter`) with `source` and `clients`\n * intact, so every other chart filters exactly as before and this one still does not filter itself.\n */\nexport function ChartRoot(props: ChartRootProps) {\n const {\n table,\n filterBy,\n as,\n config = EMPTY_CONFIG,\n height = 200,\n margin,\n aspectRatio,\n facetMargin,\n facetGrid,\n facetLabel,\n attributes,\n locale,\n numberFormat,\n children,\n className,\n plotClassName,\n ref,\n slot,\n ...rest\n } = props;\n const { coordinator, crossfilter, selected, registerSelection } = useMosaic();\n // A plain union, so it hides nothing from its own publisher — a crossfilter would, and\n // `ChartHighlight` would read an empty predicate and dim nothing.\n const [own] = useState(() => Selection.union());\n const target = as ?? own;\n const source = filterBy === undefined ? crossfilter : filterBy;\n const host = useRef<HTMLDivElement | null>(null);\n\n useEffect(\n // Only the selection this root minted is relayed: a caller-supplied `as` was wired by the\n // caller (`include`, or another root), and relaying it again would double every clause.\n () => registerSelection(target, { relay: target === own }),\n [registerSelection, target, own],\n );\n\n const numberKey = JSON.stringify(numberFormat ?? null);\n const context = useMemo<ChartContextValue>(\n () => ({\n coordinator,\n config,\n table,\n filterBy: source,\n as: target,\n color: (key) => {\n const value = chartSeriesColor(config, key);\n if (value === undefined || !isColorToken(value) || typeof document === \"undefined\") return value;\n // Resolve against the element the chart lives in, so a scoped theme override wins.\n return resolveTokenColor(host.current ?? document.documentElement, colorTokenName(value));\n },\n formatNumber: (value, options) =>\n new Intl.NumberFormat(locale, options ?? numberFormat).format(value),\n }),\n // `numberKey` stands in for the options object's identity; `numberFormat` itself is read fresh.\n // eslint-disable-next-line react-hooks/exhaustive-deps\n [coordinator, config, table, source, target, locale, numberKey],\n );\n\n // Compiled twice on purpose: once here with an identity colour resolver, purely to fingerprint\n // the grammar for `deps`, and once inside the render below against the live DOM. The pure pass\n // is what keeps a re-render from re-running every query.\n const pure = compileChartSpec(children, {\n table, filterBy: source, as: target, config, resolveColor: identity,\n });\n const signature = chartSpecSignature(pure);\n const colorKey = JSON.stringify(chartColorScale(config));\n\n // Keyed by signature so an unchanged chart warns once, not on every render.\n const warned = useRef<string | null>(null);\n if (process.env.NODE_ENV !== \"production\" && warned.current !== signature) {\n warned.current = signature;\n const context = { shared: [crossfilter, selected] };\n for (const warning of chartSpecWarnings(pure, context)) console.warn(`[ChartRoot] ${warning}`);\n }\n\n return (\n <ChartContext.Provider value={context}>\n <ark.div\n className={cn(\"flex w-full flex-col gap-2\", className)}\n ref={(node: HTMLDivElement | null) => {\n host.current = node;\n assignRef(ref, node);\n }}\n {...rest}\n data-slot={slot ?? \"chart-root\"}\n >\n <TokenizedPlot\n className={plotClassName}\n deps={[\n signature,\n colorKey,\n table,\n source,\n target,\n height,\n aspectRatio,\n JSON.stringify(margin ?? null),\n JSON.stringify(facetMargin ?? null),\n facetGrid,\n facetLabel,\n attributes,\n ]}\n render={(width, plotHost) => {\n const cache = new Map<string, string>();\n const ctx: ChartSpecContext = {\n table,\n filterBy: source,\n as: target,\n config,\n resolveColor: (token) => {\n const name = colorTokenName(token);\n const hit = cache.get(name);\n if (hit !== undefined) return hit;\n const resolved = resolveTokenColor(plotHost, name);\n cache.set(name, resolved);\n return resolved;\n },\n };\n const spec = buildChartSpec(\n { children, width, height, margin, aspectRatio, facetMargin, facetGrid, facetLabel, attributes },\n ctx,\n );\n return vg.plot(...spec.map(toVgDirective).filter((d): d is VgDirective => d !== null));\n }}\n />\n {children}\n </ark.div>\n </ChartContext.Provider>\n );\n}\n\nfunction identity(token: string): string {\n return token;\n}\n\n/** The root keeps its own handle on the host (for token resolution) without stealing the caller's. */\nfunction assignRef(ref: Ref<HTMLDivElement> | undefined, node: HTMLDivElement | null): void {\n if (typeof ref === \"function\") ref(node);\n else if (ref) ref.current = node;\n}\n"],"names":[],"mappings":";;;;;;;;;;;;AAyBA;AAEA;;AACE;AAAkB;AAEd;AACA;AAEA;AACA;AAIA;AAAiC;AACnC;AAEE;AAAgE;AAEhE;AAAwD;AAExD;AAAiB;AAEvB;AA2BA;AAUO;AACL;AACA;AACA;AACF;AAGO;AACL;AACF;AAoCA;AAmBO;AACL;AAAM;AACJ;AACA;AACA;AACS;AACA;AACT;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACG;AAUL;AAAA;AAAA;AAAA;AAG2D;AAC1B;AAGjC;AACgB;AACP;AACL;AACA;AACA;AACU;AACN;AAEF;AACA;AAEwF;AAC1F;AAEqE;AAAA;AAAA;AAAA;AAIT;AAMxB;AACtC;AAAiB;AAAY;AAAQ;AAAsB;AAO7D;AACE;AACA;AACA;AAA6F;AAG/F;AAEI;AAAK;AAAJ;AACsD;AAEnD;AACmB;AACrB;AACI;AACe;AAEnB;AAAA;AAAC;AAAA;AACY;AACL;AACJ;AACA;AACA;AACA;AACA;AACA;AACA;AAC6B;AACK;AAClC;AACA;AACA;AAAA;AAGA;AAea;AACyE;AAfxD;AAC5B;AACU;AACN;AACJ;AAEE;AAEA;AACA;AACA;AACO;AACT;AAAA;AAMF;AAAqF;AACvF;AAAA;AAAA;AAED;AAAA;AAAA;AAIT;AAEA;AACE;AACF;AAGA;AACE;AAEF;;;;;;"}
@@ -0,0 +1,126 @@
1
+ import { ReactNode } from 'react';
2
+ import { Selection } from '@uwdata/mosaic-core';
3
+ import { ChartConfig } from './chart-config.js';
4
+ /**
5
+ * The plot spec as plain data.
6
+ *
7
+ * `ChartRoot` compiles its descriptor children to this list and only then maps it onto `vg.*`.
8
+ * The indirection is what makes the compiler pure: no coordinator, no DOM, no vgplot — so the
9
+ * grammar is unit-testable and the vgplot binding is a single switch. (`isAggregateExpression` is
10
+ * the one import, a pure AST predicate mosaic-sql exports for exactly this question.)
11
+ */
12
+ export type ChartMarkSource = {
13
+ readonly kind: "table";
14
+ readonly table: string;
15
+ readonly filterBy: Selection | null;
16
+ } | {
17
+ readonly kind: "values";
18
+ readonly values: readonly unknown[];
19
+ }
20
+ /** A decorator mark (`frame`, `gridX`, `gridY`) — takes options only, never data. */
21
+ | null;
22
+ export interface ChartMarkDirective {
23
+ readonly kind: "mark";
24
+ readonly mark: string;
25
+ readonly source: ChartMarkSource;
26
+ readonly options: Readonly<Record<string, unknown>>;
27
+ }
28
+ export interface ChartInteractorDirective {
29
+ readonly kind: "interactor";
30
+ readonly interactor: string;
31
+ readonly options: Readonly<Record<string, unknown>>;
32
+ }
33
+ export interface ChartAttributeDirective {
34
+ readonly kind: "attribute";
35
+ readonly name: string;
36
+ readonly value: unknown;
37
+ }
38
+ /** The escape hatch: a `vg.*` directive the layer does not wrap, passed through untouched. */
39
+ export interface ChartRawDirective {
40
+ readonly kind: "raw";
41
+ readonly value: unknown;
42
+ }
43
+ export type ChartDirective = ChartMarkDirective | ChartInteractorDirective | ChartAttributeDirective | ChartRawDirective;
44
+ export interface ChartSpecContext {
45
+ /** The relation every table-backed mark reads from. */
46
+ readonly table?: string;
47
+ /** What marks filter by; `null` means "the full relation". */
48
+ readonly filterBy: Selection | null;
49
+ /** Where interactors publish. */
50
+ readonly as: Selection | null;
51
+ readonly config: ChartConfig;
52
+ /** Turns a `var(--token)` / `--token` reference into a Plot-safe colour. */
53
+ readonly resolveColor: (token: string) => string;
54
+ }
55
+ export type ChartCompile<P> = (props: P, ctx: ChartSpecContext) => ChartDirective | ChartDirective[];
56
+ /** An inert child: renders nothing, carries its compilation on a static. */
57
+ export interface ChartDescriptor<P> {
58
+ (props: P): null;
59
+ readonly displayName: string;
60
+ readonly __chart: ChartCompile<P>;
61
+ }
62
+ export declare function chartDescriptor<P>(displayName: string, compile: ChartCompile<P>): ChartDescriptor<P>;
63
+ /** The descriptor children, in source order. Fragments and arrays flatten; `null`/`false` vanish. */
64
+ export declare function compileChartSpec(children: ReactNode, ctx: ChartSpecContext): ChartDirective[];
65
+ export interface ChartMargin {
66
+ top?: number;
67
+ right?: number;
68
+ bottom?: number;
69
+ left?: number;
70
+ }
71
+ /**
72
+ * The plot-wide half of faceting. The panels themselves come from a mark's `fx` / `fy` channels
73
+ * (`<ChartBarY fx="region" />`); per-scale options go on `ChartFacetX` / `ChartFacetY`.
74
+ */
75
+ export interface ChartFacetOptions {
76
+ /**
77
+ * Space around each facet panel — the gutter *between* small multiples.
78
+ *
79
+ * Not where the panel titles go: those are drawn in the **plot's** top margin, so a `margin`
80
+ * with a small `top` renders them into nothing and the panels come out anonymous. Leave ~26px.
81
+ */
82
+ facetMargin?: number | ChartMargin;
83
+ /** Draw the grid across the facet panels. */
84
+ facetGrid?: boolean;
85
+ /** The shared label for the facet axes; `null` removes it. */
86
+ facetLabel?: string | null;
87
+ }
88
+ export interface ChartSpecOptions extends ChartFacetOptions {
89
+ children: ReactNode;
90
+ /** Measured from the container by `TokenizedPlot`; vgplot defaults to 640 without it. */
91
+ width: number;
92
+ height: number;
93
+ margin?: number | ChartMargin;
94
+ aspectRatio?: number;
95
+ attributes?: readonly unknown[];
96
+ }
97
+ /**
98
+ * The whole plot: frame attributes, the config's colour scale, the children, then the raw
99
+ * escape hatch last so a consumer directive can override anything the layer decided.
100
+ */
101
+ export declare function buildChartSpec(options: ChartSpecOptions, ctx: ChartSpecContext): ChartDirective[];
102
+ export interface ChartSpecWarningContext {
103
+ /**
104
+ * Selections shared by the whole `<MosaicProvider>` — anyone's clause can land in these, so they
105
+ * are never safe as a `ChartHighlight` target on an aggregating mark.
106
+ */
107
+ readonly shared?: readonly unknown[];
108
+ }
109
+ /**
110
+ * Combinations that fail at *runtime*, reported at build time.
111
+ *
112
+ * Both entries here are silent failures — the kind that costs an afternoon because nothing on
113
+ * screen says anything is wrong.
114
+ *
115
+ * 1. An interval brush over a band scale throws `Unrecognized scale type: band` from Mosaic's
116
+ * pre-aggregator on pointer-enter — and because that pre-aggregator is coordinator-scoped, the
117
+ * blast radius is every other chart on the page, which go blank with no error of their own.
118
+ * 2. A `ChartHighlight` pointed at a page-wide selection over an aggregating mark. The highlight
119
+ * appends its predicate as an extra column on the mark's own `GROUP BY` query, so the first
120
+ * clause naming a column this plot does not group by is a DuckDB binder error; the query dies
121
+ * and the plot silently keeps its previous render. The default `by` is the root's own selection
122
+ * and cannot hit this — only an explicit `by`/`as` naming a shared selection can.
123
+ */
124
+ export declare function chartSpecWarnings(spec: ChartDirective[], context?: ChartSpecWarningContext): string[];
125
+ export declare function chartSpecSignature(directives: readonly ChartDirective[]): string;
126
+ //# sourceMappingURL=chart-spec.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"chart-spec.d.ts","sourceRoot":"","sources":["../../src/charts/chart-spec.ts"],"names":[],"mappings":"AAAA,OAAO,EAA4B,KAAK,SAAS,EAAE,MAAM,OAAO,CAAC;AACjE,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AAErD,OAAO,EAAiC,KAAK,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAEpF;;;;;;;GAOG;AAEH,MAAM,MAA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C9D,UAAU,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;CAC5B;AAED,MAAM,WAAW,gBAAiB,SAAQ,iBAAiB;IACzD,QAAQ,EAAE,SAAS,CAAC;IACpB,yFAAyF;IACzF,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,CAAC,EAAE,MAAM,GAAG,WAAW,CAAC;IAC9B,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,UAAU,CAAC,EAAE,SAAS,OAAO,EAAE,CAAC;CACjC;AAgBD;;;GAGG;AACH,wBAAgB,cAAc,CAAC,OAAO,EAAE,gBAAgB,EAAE,GAAG,EAAE,gBAAgB,GAAG,cAAc,EAAE,CA4BjG;AA0BD,MAAM,WAAW,uBAAuB;IACtC;;;OAGG;IACH,QAAQ,CAAC,MAAM,CAAC,EAAE,SAAS,OAAO,EAAE,CAAC;CACtC;AAED;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,cAAc,EAAE,EAAE,OAAO,CAAC,EAAE,uBAAuB,GAAG,MAAM,EAAE,CA8CrG;AAuCD,wBAAgB,kBAAkB,CAAC,UAAU,EAAE,SAAS,cAAc,EAAE,GAAG,MAAM,CAEhF"}
@@ -0,0 +1,133 @@
1
+ import { isValidElement as y, Fragment as k } from "react";
2
+ import { isAggregateExpression as v } from "@uwdata/mosaic-sql";
3
+ import { chartColorScale as w, isColorToken as $ } from "./chart-config.js";
4
+ function B(t, e) {
5
+ return Object.assign(() => null, { displayName: t, __chart: e });
6
+ }
7
+ function C(t) {
8
+ return typeof t == "function" && typeof t.__chart == "function";
9
+ }
10
+ const m = 16;
11
+ function f(t, e, r, i) {
12
+ if (t == null || typeof t == "boolean" || i > m) return;
13
+ if (Array.isArray(t)) {
14
+ for (const o of t) f(o, e, r, i + 1);
15
+ return;
16
+ }
17
+ if (!y(t)) return;
18
+ if (t.type === k) {
19
+ f(t.props.children, e, r, i + 1);
20
+ return;
21
+ }
22
+ if (!C(t.type)) return;
23
+ const n = t.type.__chart(t.props, e);
24
+ Array.isArray(n) ? r.push(...n) : r.push(n);
25
+ }
26
+ function A(t, e) {
27
+ const r = [];
28
+ return f(t, e, r, 0), r;
29
+ }
30
+ const d = { top: "Top", right: "Right", bottom: "Bottom", left: "Left" };
31
+ function g(t, e) {
32
+ if (e === void 0) return [];
33
+ const r = typeof e == "number" ? { top: e, right: e, bottom: e, left: e } : e;
34
+ return Object.keys(d).filter((i) => r[i] !== void 0).map((i) => ({ kind: "attribute", name: `${t}${d[i]}`, value: r[i] }));
35
+ }
36
+ function G(t, e) {
37
+ const r = [
38
+ { kind: "attribute", name: "width", value: t.width },
39
+ { kind: "attribute", name: "height", value: t.height },
40
+ ...g("margin", t.margin),
41
+ ...g("facetMargin", t.facetMargin)
42
+ ];
43
+ t.aspectRatio !== void 0 && r.push({ kind: "attribute", name: "aspectRatio", value: t.aspectRatio }), t.facetGrid !== void 0 && r.push({ kind: "attribute", name: "facetGrid", value: t.facetGrid }), t.facetLabel !== void 0 && r.push({ kind: "attribute", name: "facetLabel", value: t.facetLabel });
44
+ const i = w(e.config);
45
+ i && (r.push({ kind: "attribute", name: "colorDomain", value: i.domain }), r.push({
46
+ kind: "attribute",
47
+ name: "colorRange",
48
+ value: i.range.map((n) => $(n) ? e.resolveColor(n) : n)
49
+ })), r.push(...A(t.children, e));
50
+ for (const n of t.attributes ?? []) r.push({ kind: "raw", value: n });
51
+ return r;
52
+ }
53
+ const O = {
54
+ barY: "x",
55
+ waffleY: "x",
56
+ cellX: "x",
57
+ barX: "y",
58
+ waffleX: "y",
59
+ cellY: "y"
60
+ };
61
+ function c(t) {
62
+ return `<Chart${t[0].toUpperCase()}${t.slice(1)}>`;
63
+ }
64
+ function S(t) {
65
+ return Object.values(t.options).some(
66
+ (e) => v(e) !== 0
67
+ );
68
+ }
69
+ function j(t) {
70
+ var e;
71
+ return !!((e = t.resolver) != null && e.cross);
72
+ }
73
+ function U(t, e) {
74
+ const r = [], i = t.filter((o) => o.kind === "mark"), n = (e == null ? void 0 : e.shared) ?? [];
75
+ for (const o of t) {
76
+ if (o.kind !== "interactor") continue;
77
+ if (o.interactor === "highlight") {
78
+ const s = o.options.by;
79
+ if (!s) continue;
80
+ if (j(s)) {
81
+ r.push(
82
+ "<ChartHighlight> reads a cross-filtered selection, which by definition hides a clause from the client that published it — so the predicate comes back empty and nothing is ever dimmed. Drop `by` to use the root's own selection, or point it at a plain union."
83
+ );
84
+ continue;
85
+ }
86
+ const p = i.find(S);
87
+ n.includes(s) && p && r.push(
88
+ `<ChartHighlight by={…}> targets a selection shared by the whole <MosaicProvider>, and ${c(p.mark)} aggregates. The highlight appends its predicate as a column on that GROUP BY query, so as soon as another chart publishes a clause over a column this plot does not group by, DuckDB answers "must appear in the GROUP BY clause", the query dies and this plot silently keeps its previous render. Drop \`by\` — the root's own selection only ever names columns this plot groups by.`
89
+ );
90
+ continue;
91
+ }
92
+ const a = o.interactor === "intervalX" ? "x" : o.interactor === "intervalY" ? "y" : null;
93
+ if (!a) continue;
94
+ const h = i.find((s) => O[s.mark] === a);
95
+ h && r.push(
96
+ `${c(o.interactor)} brushes a band scale (${c(h.mark)} makes ${a} categorical). Mosaic throws "Unrecognized scale type: band" on hover and blanks every other chart sharing the coordinator. Use <ChartToggle${a.toUpperCase()}> for categories, or bin ${a} first.`
97
+ );
98
+ }
99
+ return r;
100
+ }
101
+ const b = /* @__PURE__ */ new WeakMap();
102
+ let D = 0;
103
+ function u(t) {
104
+ let e = b.get(t);
105
+ return e === void 0 && (e = ++D, b.set(t, e)), e;
106
+ }
107
+ function l(t, e) {
108
+ if (typeof t == "function") return `fn#${u(t)}`;
109
+ if (typeof t == "symbol") return `sym#${String(t.description)}`;
110
+ if (t === null || typeof t != "object") return t;
111
+ if (e > m) return `deep#${u(t)}`;
112
+ if (Array.isArray(t)) return t.map((n) => l(n, e + 1));
113
+ const r = Object.getPrototypeOf(t);
114
+ if (r === Object.prototype || r === null)
115
+ return Object.fromEntries(Object.entries(t).map(([n, o]) => [n, l(o, e + 1)]));
116
+ let i = "[object]";
117
+ try {
118
+ i = String(t);
119
+ } catch {
120
+ }
121
+ return i.startsWith("[object") ? `obj#${u(t)}` : i;
122
+ }
123
+ function Y(t) {
124
+ return JSON.stringify(l(t, 0));
125
+ }
126
+ export {
127
+ G as buildChartSpec,
128
+ B as chartDescriptor,
129
+ Y as chartSpecSignature,
130
+ U as chartSpecWarnings,
131
+ A as compileChartSpec
132
+ };
133
+ //# sourceMappingURL=chart-spec.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"chart-spec.js","sources":["../../src/charts/chart-spec.ts"],"sourcesContent":["import { Fragment, isValidElement, type ReactNode } from \"react\";\nimport type { Selection } from \"@uwdata/mosaic-core\";\nimport { isAggregateExpression } from \"@uwdata/mosaic-sql\";\nimport { chartColorScale, isColorToken, type ChartConfig } from \"./chart-config.js\";\n\n/**\n * The plot spec as plain data.\n *\n * `ChartRoot` compiles its descriptor children to this list and only then maps it onto `vg.*`.\n * The indirection is what makes the compiler pure: no coordinator, no DOM, no vgplot — so the\n * grammar is unit-testable and the vgplot binding is a single switch. (`isAggregateExpression` is\n * the one import, a pure AST predicate mosaic-sql exports for exactly this question.)\n */\n\nexport type ChartMarkSource =\n | { readonly kind: \"table\"; readonly table: string; readonly filterBy: Selection | null }\n | { readonly kind: \"values\"; readonly values: readonly unknown[] }\n /** A decorator mark (`frame`, `gridX`, `gridY`) — takes options only, never data. */\n | null;\n\nexport interface ChartMarkDirective {\n readonly kind: \"mark\";\n readonly mark: string;\n readonly source: ChartMarkSource;\n readonly options: Readonly<Record<string, unknown>>;\n}\n\nexport interface ChartInteractorDirective {\n readonly kind: \"interactor\";\n readonly interactor: string;\n readonly options: Readonly<Record<string, unknown>>;\n}\n\nexport interface ChartAttributeDirective {\n readonly kind: \"attribute\";\n readonly name: string;\n readonly value: unknown;\n}\n\n/** The escape hatch: a `vg.*` directive the layer does not wrap, passed through untouched. */\nexport interface ChartRawDirective {\n readonly kind: \"raw\";\n readonly value: unknown;\n}\n\nexport type ChartDirective =\n | ChartMarkDirective\n | ChartInteractorDirective\n | ChartAttributeDirective\n | ChartRawDirective;\n\nexport interface ChartSpecContext {\n /** The relation every table-backed mark reads from. */\n readonly table?: string;\n /** What marks filter by; `null` means \"the full relation\". */\n readonly filterBy: Selection | null;\n /** Where interactors publish. */\n readonly as: Selection | null;\n readonly config: ChartConfig;\n /** Turns a `var(--token)` / `--token` reference into a Plot-safe colour. */\n readonly resolveColor: (token: string) => string;\n}\n\nexport type ChartCompile<P> = (props: P, ctx: ChartSpecContext) => ChartDirective | ChartDirective[];\n\n/** An inert child: renders nothing, carries its compilation on a static. */\nexport interface ChartDescriptor<P> {\n (props: P): null;\n readonly displayName: string;\n readonly __chart: ChartCompile<P>;\n}\n\nexport function chartDescriptor<P>(displayName: string, compile: ChartCompile<P>): ChartDescriptor<P> {\n return Object.assign(() => null, { displayName, __chart: compile }) as ChartDescriptor<P>;\n}\n\nfunction isChartDescriptor(type: unknown): type is ChartDescriptor<unknown> {\n return typeof type === \"function\" && typeof (type as { __chart?: unknown }).__chart === \"function\";\n}\n\n/** Guards against a pathological tree; nothing legitimate nests fragments this deep. */\nconst MAX_DEPTH = 16;\n\nfunction collect(node: ReactNode, ctx: ChartSpecContext, out: ChartDirective[], depth: number): void {\n if (node == null || typeof node === \"boolean\" || depth > MAX_DEPTH) return;\n if (Array.isArray(node)) {\n for (const child of node) collect(child as ReactNode, ctx, out, depth + 1);\n return;\n }\n if (!isValidElement(node)) return;\n if (node.type === Fragment) {\n collect((node.props as { children?: ReactNode }).children, ctx, out, depth + 1);\n return;\n }\n // Anything else is a DOM child (ChartLegend, a caption…) — rendered, never compiled. A\n // descriptor hidden inside a consumer's own component is invisible here, as in Recharts.\n if (!isChartDescriptor(node.type)) return;\n const produced = node.type.__chart(node.props, ctx);\n if (Array.isArray(produced)) out.push(...produced);\n else out.push(produced);\n}\n\n/** The descriptor children, in source order. Fragments and arrays flatten; `null`/`false` vanish. */\nexport function compileChartSpec(children: ReactNode, ctx: ChartSpecContext): ChartDirective[] {\n const out: ChartDirective[] = [];\n collect(children, ctx, out, 0);\n return out;\n}\n\nexport interface ChartMargin {\n top?: number;\n right?: number;\n bottom?: number;\n left?: number;\n}\n\n/**\n * The plot-wide half of faceting. The panels themselves come from a mark's `fx` / `fy` channels\n * (`<ChartBarY fx=\"region\" />`); per-scale options go on `ChartFacetX` / `ChartFacetY`.\n */\nexport interface ChartFacetOptions {\n /**\n * Space around each facet panel — the gutter *between* small multiples.\n *\n * Not where the panel titles go: those are drawn in the **plot's** top margin, so a `margin`\n * with a small `top` renders them into nothing and the panels come out anonymous. Leave ~26px.\n */\n facetMargin?: number | ChartMargin;\n /** Draw the grid across the facet panels. */\n facetGrid?: boolean;\n /** The shared label for the facet axes; `null` removes it. */\n facetLabel?: string | null;\n}\n\nexport interface ChartSpecOptions extends ChartFacetOptions {\n children: ReactNode;\n /** Measured from the container by `TokenizedPlot`; vgplot defaults to 640 without it. */\n width: number;\n height: number;\n margin?: number | ChartMargin;\n aspectRatio?: number;\n attributes?: readonly unknown[];\n}\n\nconst MARGIN_SIDES = { top: \"Top\", right: \"Right\", bottom: \"Bottom\", left: \"Left\" } as const;\n\nfunction marginDirectives(\n prefix: \"margin\" | \"facetMargin\",\n margin: number | ChartMargin | undefined,\n): ChartAttributeDirective[] {\n if (margin === undefined) return [];\n const sides: ChartMargin =\n typeof margin === \"number\" ? { top: margin, right: margin, bottom: margin, left: margin } : margin;\n return (Object.keys(MARGIN_SIDES) as (keyof ChartMargin)[])\n .filter((side) => sides[side] !== undefined)\n .map((side) => ({ kind: \"attribute\", name: `${prefix}${MARGIN_SIDES[side]}`, value: sides[side] }));\n}\n\n/**\n * The whole plot: frame attributes, the config's colour scale, the children, then the raw\n * escape hatch last so a consumer directive can override anything the layer decided.\n */\nexport function buildChartSpec(options: ChartSpecOptions, ctx: ChartSpecContext): ChartDirective[] {\n const directives: ChartDirective[] = [\n { kind: \"attribute\", name: \"width\", value: options.width },\n { kind: \"attribute\", name: \"height\", value: options.height },\n ...marginDirectives(\"margin\", options.margin),\n ...marginDirectives(\"facetMargin\", options.facetMargin),\n ];\n if (options.aspectRatio !== undefined) {\n directives.push({ kind: \"attribute\", name: \"aspectRatio\", value: options.aspectRatio });\n }\n if (options.facetGrid !== undefined) {\n directives.push({ kind: \"attribute\", name: \"facetGrid\", value: options.facetGrid });\n }\n if (options.facetLabel !== undefined) {\n directives.push({ kind: \"attribute\", name: \"facetLabel\", value: options.facetLabel });\n }\n const scale = chartColorScale(ctx.config);\n if (scale) {\n directives.push({ kind: \"attribute\", name: \"colorDomain\", value: scale.domain });\n directives.push({\n kind: \"attribute\",\n name: \"colorRange\",\n value: scale.range.map((c) => (isColorToken(c) ? ctx.resolveColor(c) : c)),\n });\n }\n directives.push(...compileChartSpec(options.children, ctx));\n for (const raw of options.attributes ?? []) directives.push({ kind: \"raw\", value: raw });\n return directives;\n}\n\n/** Marks whose primary channel is a band scale, which an interval brush cannot read. */\nconst BAND_MARKS: Record<string, \"x\" | \"y\"> = {\n barY: \"x\", waffleY: \"x\", cellX: \"x\",\n barX: \"y\", waffleX: \"y\", cellY: \"y\",\n};\n\nfunction component(name: string): string {\n return `<Chart${name[0]!.toUpperCase()}${name.slice(1)}>`;\n}\n\n/** A mark whose query carries a `GROUP BY` — any channel holding an aggregate expression. */\nfunction isAggregating(mark: ChartMarkDirective): boolean {\n // `isAggregateExpression` walks a SQL AST and answers 0 for anything that is not a node, so a\n // plain `y=\"region\"` costs one type check rather than a guard here.\n return Object.values(mark.options).some(\n (value) => isAggregateExpression(value as Parameters<typeof isAggregateExpression>[0]) !== 0,\n );\n}\n\n/** A cross-filtered selection never reports its own clause back to the client that published it. */\nfunction isCross(selection: Selection): boolean {\n return Boolean(selection.resolver?.cross);\n}\n\nexport interface ChartSpecWarningContext {\n /**\n * Selections shared by the whole `<MosaicProvider>` — anyone's clause can land in these, so they\n * are never safe as a `ChartHighlight` target on an aggregating mark.\n */\n readonly shared?: readonly unknown[];\n}\n\n/**\n * Combinations that fail at *runtime*, reported at build time.\n *\n * Both entries here are silent failures — the kind that costs an afternoon because nothing on\n * screen says anything is wrong.\n *\n * 1. An interval brush over a band scale throws `Unrecognized scale type: band` from Mosaic's\n * pre-aggregator on pointer-enter — and because that pre-aggregator is coordinator-scoped, the\n * blast radius is every other chart on the page, which go blank with no error of their own.\n * 2. A `ChartHighlight` pointed at a page-wide selection over an aggregating mark. The highlight\n * appends its predicate as an extra column on the mark's own `GROUP BY` query, so the first\n * clause naming a column this plot does not group by is a DuckDB binder error; the query dies\n * and the plot silently keeps its previous render. The default `by` is the root's own selection\n * and cannot hit this — only an explicit `by`/`as` naming a shared selection can.\n */\nexport function chartSpecWarnings(spec: ChartDirective[], context?: ChartSpecWarningContext): string[] {\n const warnings: string[] = [];\n const marks = spec.filter((d): d is ChartMarkDirective => d.kind === \"mark\");\n const shared = context?.shared ?? [];\n\n for (const d of spec) {\n if (d.kind !== \"interactor\") continue;\n\n if (d.interactor === \"highlight\") {\n const by = d.options.by as Selection | null | undefined;\n if (!by) continue;\n if (isCross(by)) {\n warnings.push(\n \"<ChartHighlight> reads a cross-filtered selection, which by definition hides a clause \" +\n \"from the client that published it — so the predicate comes back empty and nothing is \" +\n \"ever dimmed. Drop `by` to use the root's own selection, or point it at a plain union.\",\n );\n continue;\n }\n const aggregating = marks.find(isAggregating);\n if (shared.includes(by) && aggregating) {\n warnings.push(\n `<ChartHighlight by={…}> targets a selection shared by the whole <MosaicProvider>, and ` +\n `${component(aggregating.mark)} aggregates. The highlight appends its predicate as a ` +\n \"column on that GROUP BY query, so as soon as another chart publishes a clause over a \" +\n \"column this plot does not group by, DuckDB answers \\\"must appear in the GROUP BY \" +\n \"clause\\\", the query dies and this plot silently keeps its previous render. Drop `by` \" +\n \"— the root's own selection only ever names columns this plot groups by.\",\n );\n }\n continue;\n }\n\n const axis = d.interactor === \"intervalX\" ? \"x\" : d.interactor === \"intervalY\" ? \"y\" : null;\n if (!axis) continue;\n const clash = marks.find((m) => BAND_MARKS[m.mark] === axis);\n if (clash) {\n warnings.push(\n `${component(d.interactor)} brushes a band scale ` +\n `(${component(clash.mark)} makes ${axis} categorical). ` +\n \"Mosaic throws \\\"Unrecognized scale type: band\\\" on hover and blanks every other chart \" +\n `sharing the coordinator. Use <ChartToggle${axis.toUpperCase()}> for categories, or bin ${axis} first.`,\n );\n }\n }\n return warnings;\n}\n\n/**\n * A stable fingerprint of a compiled spec, for `TokenizedPlot`'s dependency list — the plot is\n * rebuilt (and its queries re-run) only when the grammar actually changed, not on every render.\n * SQL expression nodes (`count()`, `bin(x)`) stringify to their SQL; selections, params and\n * functions fall back to identity, which is stable as long as the caller does not rebuild them.\n */\nconst identities = new WeakMap<object, number>();\nlet nextIdentity = 0;\n\nfunction identityOf(value: object): number {\n let id = identities.get(value);\n if (id === undefined) {\n id = ++nextIdentity;\n identities.set(value, id);\n }\n return id;\n}\n\nfunction tag(value: unknown, depth: number): unknown {\n if (typeof value === \"function\") return `fn#${identityOf(value)}`;\n if (typeof value === \"symbol\") return `sym#${String(value.description)}`;\n if (value === null || typeof value !== \"object\") return value;\n if (depth > MAX_DEPTH) return `deep#${identityOf(value)}`;\n if (Array.isArray(value)) return value.map((v) => tag(v, depth + 1));\n const proto: unknown = Object.getPrototypeOf(value);\n if (proto === Object.prototype || proto === null) {\n return Object.fromEntries(Object.entries(value).map(([k, v]) => [k, tag(v, depth + 1)]));\n }\n let text = \"[object]\";\n try {\n text = String(value);\n } catch {\n /* a toString that throws is no worse than no toString */\n }\n return text.startsWith(\"[object\") ? `obj#${identityOf(value)}` : text;\n}\n\nexport function chartSpecSignature(directives: readonly ChartDirective[]): string {\n return JSON.stringify(tag(directives, 0));\n}\n"],"names":["chartDescriptor","displayName","compile","isChartDescriptor","type","MAX_DEPTH","collect","node","ctx","out","depth","child","isValidElement","Fragment","produced","compileChartSpec","children","MARGIN_SIDES","marginDirectives","prefix","margin","sides","side","buildChartSpec","options","directives","scale","chartColorScale","c","isColorToken","raw","BAND_MARKS","component","name","isAggregating","mark","value","isAggregateExpression","isCross","selection","_a","chartSpecWarnings","spec","context","warnings","marks","d","shared","by","aggregating","axis","clash","m","identities","nextIdentity","identityOf","id","tag","v","proto","k","text","chartSpecSignature"],"mappings":";;;AAwEO,SAASA,EAAmBC,GAAqBC,GAA8C;AACpG,SAAO,OAAO,OAAO,MAAM,MAAM,EAAE,aAAAD,GAAa,SAASC,GAAS;AACpE;AAEA,SAASC,EAAkBC,GAAiD;AAC1E,SAAO,OAAOA,KAAS,cAAc,OAAQA,EAA+B,WAAY;AAC1F;AAGA,MAAMC,IAAY;AAElB,SAASC,EAAQC,GAAiBC,GAAuBC,GAAuBC,GAAqB;AACnG,MAAIH,KAAQ,QAAQ,OAAOA,KAAS,aAAaG,IAAQL,EAAW;AACpE,MAAI,MAAM,QAAQE,CAAI,GAAG;AACvB,eAAWI,KAASJ,EAAM,CAAAD,EAAQK,GAAoBH,GAAKC,GAAKC,IAAQ,CAAC;AACzE;AAAA,EACF;AACA,MAAI,CAACE,EAAeL,CAAI,EAAG;AAC3B,MAAIA,EAAK,SAASM,GAAU;AAC1B,IAAAP,EAASC,EAAK,MAAmC,UAAUC,GAAKC,GAAKC,IAAQ,CAAC;AAC9E;AAAA,EACF;AAGA,MAAI,CAACP,EAAkBI,EAAK,IAAI,EAAG;AACnC,QAAMO,IAAWP,EAAK,KAAK,QAAQA,EAAK,OAAOC,CAAG;AAClD,EAAI,MAAM,QAAQM,CAAQ,IAAGL,EAAI,KAAK,GAAGK,CAAQ,IAC5CL,EAAI,KAAKK,CAAQ;AACxB;AAGO,SAASC,EAAiBC,GAAqBR,GAAyC;AAC7F,QAAMC,IAAwB,CAAA;AAC9B,SAAAH,EAAQU,GAAUR,GAAKC,GAAK,CAAC,GACtBA;AACT;AAqCA,MAAMQ,IAAe,EAAE,KAAK,OAAO,OAAO,SAAS,QAAQ,UAAU,MAAM,OAAA;AAE3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,IAAO;AACX,MAAI;AACF,IAAAA,IAAO,OAAOzB,CAAK;AAAA,EACrB,QAAQ;AAAA,EAER;AACA,SAAOyB,EAAK,WAAW,SAAS,IAAI,OAAON,EAAWnB,CAAK,CAAC,KAAKyB;AACnE;AAEO,SAASC,EAAmBrC,GAA+C;AAChF,SAAO,KAAK,UAAUgC,EAAIhC,GAAY,CAAC,CAAC;AAC1C;"}
@@ -0,0 +1,23 @@
1
+ import { ExprValue } from '@uwdata/mosaic-sql';
2
+ import { ReactNode } from 'react';
3
+ import { StatTileProps } from '../simples/stat-tile.js';
4
+ /**
5
+ * `StatTile` with the figure it shows read from the relation, under the same crossfilter as the
6
+ * plots. The connected half of the pair, which is the engine rule: `StatTile` takes a number and
7
+ * lives in the root barrel, this one queries for it and lives here.
8
+ */
9
+ export interface ChartStatProps extends Omit<StatTileProps, "value" | "trend"> {
10
+ /** The relation. Defaults to the enclosing `ChartRoot`'s table. */
11
+ table?: string;
12
+ /** The aggregate to show — `count()`, `avg("latency")`, any `mosaic-sql` expression. */
13
+ value: ExprValue;
14
+ /** Formats the number for display. Defaults to the chart's `formatNumber`. */
15
+ format?: (value: number) => string;
16
+ /** Shown while the first query is in flight. */
17
+ fallback?: ReactNode;
18
+ }
19
+ export declare function ChartStat(props: ChartStatProps): string | number | bigint | boolean | Iterable<ReactNode> | Promise<string | number | bigint | boolean | import('react').ReactPortal | import('react').ReactElement<unknown, string | import('react').JSXElementConstructor<any>> | Iterable<ReactNode> | null | undefined> | import("react").JSX.Element;
20
+ export declare namespace ChartStat {
21
+ var displayName: string;
22
+ }
23
+ //# sourceMappingURL=chart-stat.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"chart-stat.d.ts","sourceRoot":"","sources":["../../src/charts/chart-stat.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAEpD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAEvC,OAAO,EAAY,KAAK,aAAa,EAAE,MAAM,yBAAyB,CAAC;AAIvE;;;;GAIG;AAEH,MAAM,WAAW,cAAe,SAAQ,IAAI,CAAC,aAAa,EAAE,OAAO,GAAG,OAAO,CAAC;IAC5E,mEAAmE;IACnE,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,wFAAwF;IACxF,KAAK,EAAE,SAAS,CAAC;IACjB,8EAA8E;IAC9E,MAAM,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,MAAM,CAAC;IACnC,gDAAgD;IAChD,QAAQ,CAAC,EAAE,SAAS,CAAC;CACtB;AAED,wBAAgB,SAAS,CAAC,KAAK,EAAE,cAAc,4SAoB9C;yBApBe,SAAS"}
@@ -0,0 +1,24 @@
1
+ "use client";
2
+ import { jsx as m } from "react/jsx-runtime";
3
+ import { Query as p } from "@uwdata/mosaic-sql";
4
+ import { Skeleton as c } from "../simples/skeleton.js";
5
+ import { StatTile as h } from "../simples/stat-tile.js";
6
+ import { useChartContextOptional as C } from "./chart-root.js";
7
+ import { useChartQuery as b } from "./use-chart-query.js";
8
+ function w(n) {
9
+ const { table: i, value: o, format: e, fallback: u, ...s } = n, r = C(), t = i ?? (r == null ? void 0 : r.table), { row: a } = b({
10
+ query: (f) => t ? p.from(t).select({ value: o }).where(f) : null,
11
+ deps: [t, o]
12
+ });
13
+ if (!t)
14
+ throw new Error("ChartStat needs a `table`, or a <ChartRoot table> around it.");
15
+ if (a === void 0)
16
+ return u ?? /* @__PURE__ */ m(c, { className: "h-24 w-full" });
17
+ const l = Number(a.value ?? 0);
18
+ return /* @__PURE__ */ m(h, { ...s, value: e ? e(l) : l });
19
+ }
20
+ w.displayName = "ChartStat";
21
+ export {
22
+ w as ChartStat
23
+ };
24
+ //# sourceMappingURL=chart-stat.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"chart-stat.js","sources":["../../src/charts/chart-stat.tsx"],"sourcesContent":["\"use client\";\n\nimport type { ExprValue } from \"@uwdata/mosaic-sql\";\nimport { Query } from \"@uwdata/mosaic-sql\";\nimport type { ReactNode } from \"react\";\nimport { Skeleton } from \"../simples/skeleton.js\";\nimport { StatTile, type StatTileProps } from \"../simples/stat-tile.js\";\nimport { useChartContextOptional } from \"./chart-root.js\";\nimport { useChartQuery } from \"./use-chart-query.js\";\n\n/**\n * `StatTile` with the figure it shows read from the relation, under the same crossfilter as the\n * plots. The connected half of the pair, which is the engine rule: `StatTile` takes a number and\n * lives in the root barrel, this one queries for it and lives here.\n */\n\nexport interface ChartStatProps extends Omit<StatTileProps, \"value\" | \"trend\"> {\n /** The relation. Defaults to the enclosing `ChartRoot`'s table. */\n table?: string;\n /** The aggregate to show — `count()`, `avg(\"latency\")`, any `mosaic-sql` expression. */\n value: ExprValue;\n /** Formats the number for display. Defaults to the chart's `formatNumber`. */\n format?: (value: number) => string;\n /** Shown while the first query is in flight. */\n fallback?: ReactNode;\n}\n\nexport function ChartStat(props: ChartStatProps) {\n const { table, value, format, fallback, ...tile } = props;\n const chart = useChartContextOptional();\n const relation = table ?? chart?.table;\n\n const { row } = useChartQuery({\n query: (filter) =>\n relation ? Query.from(relation).select({ value }).where(filter) : null,\n deps: [relation, value],\n });\n\n if (!relation) {\n throw new Error(\"ChartStat needs a `table`, or a <ChartRoot table> around it.\");\n }\n if (row === undefined) {\n return fallback ?? <Skeleton className=\"h-24 w-full\" />;\n }\n\n const raw = Number(row.value ?? 0);\n return <StatTile {...tile} value={format ? format(raw) : raw} />;\n}\n\n// The chart context is optional: a tile sits in a dashboard grid, outside any plot.\nChartStat.displayName = \"ChartStat\";\n"],"names":["ChartStat"],"mappings":";;;;;;;AA2BO;AACL;AAI8B;AAEwC;AAC9C;AAGxB;AACE;AAEF;AACE;AAGF;AACA;AACF;AAGAA;;;;"}
@@ -0,0 +1,42 @@
1
+ import { MosaicClient, Selection } from '@uwdata/mosaic-core';
2
+ import { FilterExpr } from '@uwdata/mosaic-sql';
3
+ /**
4
+ * The crossfilter adapter for a view whose positions are not in the database.
5
+ *
6
+ * A `MosaicClient` asks for two things, and this is both:
7
+ *
8
+ * `query(filter)` — which rows survive the page's filters? The coordinator answers with a column
9
+ * of ids, and the view fades everything else. The **observable** half.
10
+ * `publish(ids)` — the user selected these. A points clause, `id IN (…)`, which every other chart
11
+ * on the page filters by. The **controllable** half.
12
+ *
13
+ * The id list is not a shortcut, it is the only thing such a view can say. A Plot brush publishes
14
+ * `weight BETWEEN …`, an interval in data space, because Plot's `x` IS a column. A GPU simulation's
15
+ * `x` exists nowhere in the database, so no predicate over columns can describe the loop the user
16
+ * drew. Enumerating what was hit is the honest translation — and its cost is the length of the `IN`
17
+ * list, which is the real ceiling on the whole approach.
18
+ *
19
+ * Nothing here knows what draws. It is named for what it exchanges rather than for the renderer it
20
+ * was first written against, because a canvas, a map and an imperative widget all reach the
21
+ * crossfilter through exactly this shape.
22
+ */
23
+ export interface IdSetClientOptions {
24
+ /** The relation. Its `idField` column is what gets published and matched. */
25
+ table: string;
26
+ idField: string;
27
+ /** What the view fades by. */
28
+ filterBy: Selection;
29
+ /** Where the selection publishes. */
30
+ as: Selection;
31
+ /** The surviving ids, in relation order, on every filter change. */
32
+ onSurvivors: (ids: readonly unknown[]) => void;
33
+ }
34
+ export declare class IdSetClient extends MosaicClient {
35
+ #private;
36
+ constructor(options: IdSetClientOptions);
37
+ query(filter?: FilterExpr): import('@uwdata/mosaic-sql').SelectQuery;
38
+ queryResult(data: unknown): this;
39
+ /** `null` retracts the selection: an empty clause has a null predicate, which the resolver drops. */
40
+ publish(ids: readonly unknown[] | null): void;
41
+ }
42
+ //# sourceMappingURL=id-set-client.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"id-set-client.d.ts","sourceRoot":"","sources":["../../src/charts/id-set-client.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAgB,KAAK,SAAS,EAAE,MAAM,qBAAqB,CAAC;AACjF,OAAO,EAAS,KAAK,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAG5D;;;;;;;;;;;;;;;;;;;GAmBG;AAEH,MAAM,WAAW,kBAAkB;IACjC,6EAA6E;IAC7E,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,EAAE,MAAM,CAAC;IAChB,8BAA8B;IAC9B,QAAQ,EAAE,SAAS,CAAC;IACpB,qCAAqC;IACrC,EAAE,EAAE,SAAS,CAAC;IACd,oEAAoE;IACpE,WAAW,EAAE,CAAC,GAAG,EAAE,SAAS,OAAO,EAAE,KAAK,IAAI,CAAC;CAChD;AAED,qBAAa,WAAY,SAAQ,YAAY;;gBAM/B,OAAO,EAAE,kBAAkB;IAQ9B,KAAK,CAAC,MAAM,GAAE,UAAe;IAI7B,WAAW,CAAC,IAAI,EAAE,OAAO,GAAG,IAAI;IAKzC,qGAAqG;IACrG,OAAO,CAAC,GAAG,EAAE,SAAS,OAAO,EAAE,GAAG,IAAI,GAAG,IAAI;CAY9C"}