@devalok/shilp-sutra 0.38.0 → 0.40.0

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 (361) hide show
  1. package/AGENTS.md +151 -0
  2. package/MIGRATION.md +255 -0
  3. package/README.md +3 -0
  4. package/dist/_chunks/badge-group.js +76 -75
  5. package/dist/_chunks/badge-group.js.map +1 -1
  6. package/dist/_chunks/chart-container.js +50 -0
  7. package/dist/_chunks/chart-container.js.map +1 -0
  8. package/dist/_chunks/chat.js +236 -228
  9. package/dist/_chunks/chat.js.map +1 -1
  10. package/dist/_chunks/colors.js +30 -0
  11. package/dist/_chunks/colors.js.map +1 -0
  12. package/dist/_chunks/document-preview.js +2 -2
  13. package/dist/_chunks/document-preview.js.map +1 -1
  14. package/dist/_chunks/emoji-data.js +45 -0
  15. package/dist/_chunks/emoji-data.js.map +1 -0
  16. package/dist/_chunks/grid-lines.js +72 -0
  17. package/dist/_chunks/grid-lines.js.map +1 -0
  18. package/dist/_chunks/image-preview.js +2 -2
  19. package/dist/_chunks/image-preview.js.map +1 -1
  20. package/dist/_chunks/mention-suggestion.js +35 -263
  21. package/dist/_chunks/mention-suggestion.js.map +1 -1
  22. package/dist/_chunks/normalize-icon.js +18 -0
  23. package/dist/_chunks/normalize-icon.js.map +1 -0
  24. package/dist/_chunks/oauth-button.js +227 -0
  25. package/dist/_chunks/oauth-button.js.map +1 -0
  26. package/dist/_chunks/popover.js +3 -3
  27. package/dist/_chunks/popover.js.map +1 -1
  28. package/dist/_chunks/primitives.js +107 -107
  29. package/dist/_chunks/primitives.js.map +1 -1
  30. package/dist/_chunks/shared.js +5 -5
  31. package/dist/_chunks/shared.js.map +1 -1
  32. package/dist/_chunks/{text.js → success.js} +26 -63
  33. package/dist/_chunks/success.js.map +1 -0
  34. package/dist/_chunks/tiptap.js +1952 -1949
  35. package/dist/_chunks/tiptap.js.map +1 -1
  36. package/dist/_chunks/tooltip.js +58 -0
  37. package/dist/_chunks/tooltip.js.map +1 -0
  38. package/dist/_chunks/tree-view.js +101 -96
  39. package/dist/_chunks/tree-view.js.map +1 -1
  40. package/dist/_chunks/use-calendar.js +5 -5
  41. package/dist/_chunks/use-calendar.js.map +1 -1
  42. package/dist/ai/ai-command-provider.d.ts +3 -2
  43. package/dist/ai/ai-command-provider.d.ts.map +1 -1
  44. package/dist/ai/ai-command-provider.js.map +1 -1
  45. package/dist/ai/block-renderer.js +11 -9
  46. package/dist/ai/block-renderer.js.map +1 -1
  47. package/dist/ai/blocks/error.js +31 -0
  48. package/dist/ai/blocks/error.js.map +1 -0
  49. package/dist/ai/blocks/index.d.ts +0 -2
  50. package/dist/ai/blocks/index.d.ts.map +1 -1
  51. package/dist/ai/blocks/index.js +2 -2
  52. package/dist/ai/blocks/text.js +19 -0
  53. package/dist/ai/blocks/text.js.map +1 -0
  54. package/dist/ai/command-bar.d.ts.map +1 -1
  55. package/dist/ai/command-bar.js +198 -193
  56. package/dist/ai/command-bar.js.map +1 -1
  57. package/dist/ai/conversation.d.ts +2 -1
  58. package/dist/ai/conversation.d.ts.map +1 -1
  59. package/dist/ai/conversation.js +92 -87
  60. package/dist/ai/conversation.js.map +1 -1
  61. package/dist/ai/index.d.ts +0 -4
  62. package/dist/ai/index.d.ts.map +1 -1
  63. package/dist/ai/index.js +45 -46
  64. package/dist/ai/index.js.map +1 -1
  65. package/dist/composed/activity-feed.d.ts +2 -1
  66. package/dist/composed/activity-feed.d.ts.map +1 -1
  67. package/dist/composed/activity-feed.js +5 -5
  68. package/dist/composed/activity-feed.js.map +1 -1
  69. package/dist/composed/avatar-group.js +4 -4
  70. package/dist/composed/avatar-group.js.map +1 -1
  71. package/dist/composed/bulk-action-bar.d.ts +2 -2
  72. package/dist/composed/bulk-action-bar.d.ts.map +1 -1
  73. package/dist/composed/bulk-action-bar.js +12 -12
  74. package/dist/composed/bulk-action-bar.js.map +1 -1
  75. package/dist/composed/command-palette.d.ts +2 -1
  76. package/dist/composed/command-palette.d.ts.map +1 -1
  77. package/dist/composed/command-palette.js +106 -101
  78. package/dist/composed/command-palette.js.map +1 -1
  79. package/dist/composed/content-card.js +1 -1
  80. package/dist/composed/content-card.js.map +1 -1
  81. package/dist/composed/date-picker/index.js +747 -3
  82. package/dist/composed/date-picker/index.js.map +1 -0
  83. package/dist/composed/emoji-picker.js +4 -4
  84. package/dist/composed/emoji-picker.js.map +1 -1
  85. package/dist/composed/empty-state.d.ts +3 -3
  86. package/dist/composed/empty-state.d.ts.map +1 -1
  87. package/dist/composed/empty-state.js +40 -31
  88. package/dist/composed/empty-state.js.map +1 -1
  89. package/dist/composed/error-boundary.js +3 -3
  90. package/dist/composed/error-boundary.js.map +1 -1
  91. package/dist/composed/extensions/emoji-node.js +81 -0
  92. package/dist/composed/extensions/emoji-node.js.map +1 -0
  93. package/dist/composed/extensions/emoji-suggestion.js +117 -0
  94. package/dist/composed/extensions/emoji-suggestion.js.map +1 -0
  95. package/dist/composed/file-preview.js +498 -2
  96. package/dist/composed/file-preview.js.map +1 -0
  97. package/dist/composed/filter-bar.js +1 -1
  98. package/dist/composed/filter-bar.js.map +1 -1
  99. package/dist/composed/index.d.ts +0 -15
  100. package/dist/composed/index.d.ts.map +1 -1
  101. package/dist/composed/index.js +16 -24
  102. package/dist/composed/inline-edit.js +1 -1
  103. package/dist/composed/inline-edit.js.map +1 -1
  104. package/dist/composed/loading-skeleton.js +9 -9
  105. package/dist/composed/loading-skeleton.js.map +1 -1
  106. package/dist/composed/markdown-viewer.js +3 -3
  107. package/dist/composed/markdown-viewer.js.map +1 -1
  108. package/dist/composed/multi-select-popover.js +1 -1
  109. package/dist/composed/multi-select-popover.js.map +1 -1
  110. package/dist/composed/page-header.js +1 -1
  111. package/dist/composed/page-header.js.map +1 -1
  112. package/dist/composed/page-skeletons.js +15 -15
  113. package/dist/composed/page-skeletons.js.map +1 -1
  114. package/dist/composed/priority-indicator.js +3 -3
  115. package/dist/composed/priority-indicator.js.map +1 -1
  116. package/dist/composed/rich-chat-input.js +2073 -2
  117. package/dist/composed/rich-chat-input.js.map +1 -0
  118. package/dist/composed/rich-text-editor.js +75 -72
  119. package/dist/composed/rich-text-editor.js.map +1 -1
  120. package/dist/composed/schedule-view.js +3 -3
  121. package/dist/composed/schedule-view.js.map +1 -1
  122. package/dist/composed/status-badge.d.ts +3 -2
  123. package/dist/composed/status-badge.d.ts.map +1 -1
  124. package/dist/composed/status-badge.js +58 -53
  125. package/dist/composed/status-badge.js.map +1 -1
  126. package/dist/shell/app-command-palette.d.ts +2 -1
  127. package/dist/shell/app-command-palette.d.ts.map +1 -1
  128. package/dist/shell/app-command-palette.js.map +1 -1
  129. package/dist/shell/bottom-navbar.d.ts +3 -1
  130. package/dist/shell/bottom-navbar.d.ts.map +1 -1
  131. package/dist/shell/bottom-navbar.js +94 -86
  132. package/dist/shell/bottom-navbar.js.map +1 -1
  133. package/dist/shell/command-registry.d.ts +2 -1
  134. package/dist/shell/command-registry.d.ts.map +1 -1
  135. package/dist/shell/command-registry.js.map +1 -1
  136. package/dist/shell/notification-center.js +8 -8
  137. package/dist/shell/notification-center.js.map +1 -1
  138. package/dist/shell/notification-preferences.js +1 -1
  139. package/dist/shell/notification-preferences.js.map +1 -1
  140. package/dist/shell/sidebar.d.ts +7 -4
  141. package/dist/shell/sidebar.d.ts.map +1 -1
  142. package/dist/shell/sidebar.js +148 -134
  143. package/dist/shell/sidebar.js.map +1 -1
  144. package/dist/shell/top-bar.d.ts +4 -3
  145. package/dist/shell/top-bar.d.ts.map +1 -1
  146. package/dist/shell/top-bar.js +116 -108
  147. package/dist/shell/top-bar.js.map +1 -1
  148. package/dist/tokens/semantic.css +82 -9
  149. package/dist/ui/accordion.js +1 -1
  150. package/dist/ui/accordion.js.map +1 -1
  151. package/dist/ui/alert-dialog.js +3 -3
  152. package/dist/ui/alert-dialog.js.map +1 -1
  153. package/dist/ui/alert.js +2 -2
  154. package/dist/ui/alert.js.map +1 -1
  155. package/dist/ui/autocomplete.js +2 -2
  156. package/dist/ui/autocomplete.js.map +1 -1
  157. package/dist/ui/avatar.js +11 -11
  158. package/dist/ui/avatar.js.map +1 -1
  159. package/dist/ui/badge-indicator.js +1 -1
  160. package/dist/ui/badge-indicator.js.map +1 -1
  161. package/dist/ui/badge.d.ts +3 -2
  162. package/dist/ui/badge.d.ts.map +1 -1
  163. package/dist/ui/banner.js +1 -1
  164. package/dist/ui/banner.js.map +1 -1
  165. package/dist/ui/breadcrumb.js +1 -1
  166. package/dist/ui/breadcrumb.js.map +1 -1
  167. package/dist/ui/button.d.ts +5 -4
  168. package/dist/ui/button.d.ts.map +1 -1
  169. package/dist/ui/button.js +66 -65
  170. package/dist/ui/button.js.map +1 -1
  171. package/dist/ui/card.js +5 -5
  172. package/dist/ui/card.js.map +1 -1
  173. package/dist/ui/charts/area-chart.js +177 -0
  174. package/dist/ui/charts/area-chart.js.map +1 -0
  175. package/dist/ui/charts/bar-chart.js +127 -0
  176. package/dist/ui/charts/bar-chart.js.map +1 -0
  177. package/dist/ui/charts/chart-container.js +3 -0
  178. package/dist/ui/charts/gauge-chart.js +72 -0
  179. package/dist/ui/charts/gauge-chart.js.map +1 -0
  180. package/dist/ui/charts/index.js +10 -1035
  181. package/dist/ui/charts/line-chart.js +135 -0
  182. package/dist/ui/charts/line-chart.js.map +1 -0
  183. package/dist/ui/charts/pie-chart.js +111 -0
  184. package/dist/ui/charts/pie-chart.js.map +1 -0
  185. package/dist/ui/charts/radar-chart.js +170 -0
  186. package/dist/ui/charts/radar-chart.js.map +1 -0
  187. package/dist/ui/charts/sparkline.js +119 -0
  188. package/dist/ui/charts/sparkline.js.map +1 -0
  189. package/dist/ui/chat/message.d.ts +3 -3
  190. package/dist/ui/chat/message.d.ts.map +1 -1
  191. package/dist/ui/chat/system-message.d.ts +2 -1
  192. package/dist/ui/chat/system-message.d.ts.map +1 -1
  193. package/dist/ui/checkbox.js +1 -1
  194. package/dist/ui/checkbox.js.map +1 -1
  195. package/dist/ui/code.js +2 -2
  196. package/dist/ui/code.js.map +1 -1
  197. package/dist/ui/color-input.js +10 -10
  198. package/dist/ui/color-input.js.map +1 -1
  199. package/dist/ui/color-swatch.js +3 -3
  200. package/dist/ui/color-swatch.js.map +1 -1
  201. package/dist/ui/combobox.d.ts +2 -1
  202. package/dist/ui/combobox.d.ts.map +1 -1
  203. package/dist/ui/combobox.js +100 -95
  204. package/dist/ui/combobox.js.map +1 -1
  205. package/dist/ui/container.d.ts +6 -1
  206. package/dist/ui/container.d.ts.map +1 -1
  207. package/dist/ui/container.js +2 -1
  208. package/dist/ui/container.js.map +1 -1
  209. package/dist/ui/context-menu.js +6 -6
  210. package/dist/ui/context-menu.js.map +1 -1
  211. package/dist/ui/data-table-body.js +1 -1
  212. package/dist/ui/data-table-body.js.map +1 -1
  213. package/dist/ui/data-table-bulk-actions.js +2 -2
  214. package/dist/ui/data-table-bulk-actions.js.map +1 -1
  215. package/dist/ui/data-table-card.js +2 -2
  216. package/dist/ui/data-table-card.js.map +1 -1
  217. package/dist/ui/data-table-header.js +2 -2
  218. package/dist/ui/data-table-header.js.map +1 -1
  219. package/dist/ui/data-table-pagination.js +3 -3
  220. package/dist/ui/data-table-pagination.js.map +1 -1
  221. package/dist/ui/data-table-toolbar.js +1 -1
  222. package/dist/ui/data-table-toolbar.js.map +1 -1
  223. package/dist/ui/data-table.js +1 -1
  224. package/dist/ui/data-table.js.map +1 -1
  225. package/dist/ui/devalok-grain.d.ts +1 -1
  226. package/dist/ui/devalok-grain.js.map +1 -1
  227. package/dist/ui/dialog.js +2 -2
  228. package/dist/ui/dialog.js.map +1 -1
  229. package/dist/ui/dropdown-menu.js +6 -6
  230. package/dist/ui/dropdown-menu.js.map +1 -1
  231. package/dist/ui/file-upload.js +4 -4
  232. package/dist/ui/file-upload.js.map +1 -1
  233. package/dist/ui/hover-card.js +1 -1
  234. package/dist/ui/hover-card.js.map +1 -1
  235. package/dist/ui/icon-button.d.ts +9 -2
  236. package/dist/ui/icon-button.d.ts.map +1 -1
  237. package/dist/ui/icon-button.js +14 -13
  238. package/dist/ui/icon-button.js.map +1 -1
  239. package/dist/ui/index.d.ts +1 -3
  240. package/dist/ui/index.d.ts.map +1 -1
  241. package/dist/ui/index.js +31 -33
  242. package/dist/ui/index.js.map +1 -1
  243. package/dist/ui/input-otp.js +1 -1
  244. package/dist/ui/input-otp.js.map +1 -1
  245. package/dist/ui/input.js +2 -2
  246. package/dist/ui/input.js.map +1 -1
  247. package/dist/ui/lib/icon-input.d.ts +42 -0
  248. package/dist/ui/lib/icon-input.d.ts.map +1 -0
  249. package/dist/ui/lib/normalize-icon.d.ts +39 -0
  250. package/dist/ui/lib/normalize-icon.d.ts.map +1 -0
  251. package/dist/ui/link.js +1 -1
  252. package/dist/ui/link.js.map +1 -1
  253. package/dist/ui/menubar.js +8 -8
  254. package/dist/ui/menubar.js.map +1 -1
  255. package/dist/ui/navigation-menu.js +3 -3
  256. package/dist/ui/navigation-menu.js.map +1 -1
  257. package/dist/ui/number-input.js +3 -3
  258. package/dist/ui/number-input.js.map +1 -1
  259. package/dist/ui/oauth-button/index.d.ts +3 -0
  260. package/dist/ui/oauth-button/index.d.ts.map +1 -0
  261. package/dist/ui/oauth-button/index.js +3 -0
  262. package/dist/ui/oauth-button/oauth-button.d.ts +208 -0
  263. package/dist/ui/oauth-button/oauth-button.d.ts.map +1 -0
  264. package/dist/ui/pagination.js +1 -1
  265. package/dist/ui/pagination.js.map +1 -1
  266. package/dist/ui/progress.js +2 -2
  267. package/dist/ui/progress.js.map +1 -1
  268. package/dist/ui/radio.js +1 -1
  269. package/dist/ui/radio.js.map +1 -1
  270. package/dist/ui/segmented-control.d.ts +3 -4
  271. package/dist/ui/segmented-control.d.ts.map +1 -1
  272. package/dist/ui/segmented-control.js +53 -45
  273. package/dist/ui/segmented-control.js.map +1 -1
  274. package/dist/ui/select.js +3 -3
  275. package/dist/ui/select.js.map +1 -1
  276. package/dist/ui/sheet.js +2 -2
  277. package/dist/ui/sheet.js.map +1 -1
  278. package/dist/ui/sidebar.js +11 -11
  279. package/dist/ui/sidebar.js.map +1 -1
  280. package/dist/ui/skeleton.js +9 -9
  281. package/dist/ui/skeleton.js.map +1 -1
  282. package/dist/ui/slider.js +2 -2
  283. package/dist/ui/slider.js.map +1 -1
  284. package/dist/ui/split-button.js +7 -7
  285. package/dist/ui/split-button.js.map +1 -1
  286. package/dist/ui/stack.d.ts +6 -1
  287. package/dist/ui/stack.d.ts.map +1 -1
  288. package/dist/ui/stack.js +2 -1
  289. package/dist/ui/stack.js.map +1 -1
  290. package/dist/ui/stat-card.d.ts +2 -3
  291. package/dist/ui/stat-card.d.ts.map +1 -1
  292. package/dist/ui/stat-card.js +118 -116
  293. package/dist/ui/stat-card.js.map +1 -1
  294. package/dist/ui/status-dot.js +2 -2
  295. package/dist/ui/status-dot.js.map +1 -1
  296. package/dist/ui/stepper.d.ts +2 -1
  297. package/dist/ui/stepper.d.ts.map +1 -1
  298. package/dist/ui/stepper.js +74 -69
  299. package/dist/ui/stepper.js.map +1 -1
  300. package/dist/ui/switch.js +2 -2
  301. package/dist/ui/switch.js.map +1 -1
  302. package/dist/ui/tabs.js +3 -3
  303. package/dist/ui/tabs.js.map +1 -1
  304. package/dist/ui/text.d.ts +7 -2
  305. package/dist/ui/text.d.ts.map +1 -1
  306. package/dist/ui/text.js +2 -1
  307. package/dist/ui/text.js.map +1 -1
  308. package/dist/ui/textarea.js +1 -1
  309. package/dist/ui/textarea.js.map +1 -1
  310. package/dist/ui/toast.js +8 -8
  311. package/dist/ui/toast.js.map +1 -1
  312. package/dist/ui/toaster.d.ts +11 -2
  313. package/dist/ui/toaster.d.ts.map +1 -1
  314. package/dist/ui/toaster.js.map +1 -1
  315. package/dist/ui/toggle.js +1 -1
  316. package/dist/ui/toggle.js.map +1 -1
  317. package/dist/ui/tooltip.js +12 -12
  318. package/dist/ui/tooltip.js.map +1 -1
  319. package/dist/ui/tree-view/tree-item.d.ts +3 -2
  320. package/dist/ui/tree-view/tree-item.d.ts.map +1 -1
  321. package/dist/ui/tree-view/use-tree.d.ts +2 -1
  322. package/dist/ui/tree-view/use-tree.d.ts.map +1 -1
  323. package/docs/components/_header.md +90 -1
  324. package/docs/components/ui/oauth-button.md +86 -0
  325. package/docs/recipes/customize-brand.md +100 -4
  326. package/docs/recipes/index.md +5 -1
  327. package/docs/recipes/install-astro.md +15 -0
  328. package/docs/recipes/install-next-app-router.md +21 -5
  329. package/docs/recipes/install-next-pages.md +2 -0
  330. package/docs/recipes/install-remix.md +15 -0
  331. package/docs/recipes/install-tanstack-start.md +15 -0
  332. package/docs/recipes/install-vite.md +15 -0
  333. package/docs/recipes/troubleshoot.md +22 -0
  334. package/llms-full.txt +177 -2
  335. package/llms-quick.txt +247 -0
  336. package/llms.txt +116 -3
  337. package/package.json +80 -2
  338. package/scripts/welcome.mjs +219 -0
  339. package/skill/README.md +99 -0
  340. package/skill/SKILL.md +163 -0
  341. package/skill/install.sh +59 -0
  342. package/skill/references/components-full.md +7083 -0
  343. package/skill/references/components.md +778 -0
  344. package/skill/references/customize-brand.md +314 -0
  345. package/skill/references/server-components.md +211 -0
  346. package/skill/references/setup-astro.md +195 -0
  347. package/skill/references/setup-next-app-router.md +248 -0
  348. package/skill/references/setup-next-pages.md +127 -0
  349. package/skill/references/setup-remix.md +188 -0
  350. package/skill/references/setup-tanstack-start.md +160 -0
  351. package/skill/references/setup-vite.md +187 -0
  352. package/skill/references/troubleshoot.md +241 -0
  353. package/dist/_chunks/date-picker.js +0 -748
  354. package/dist/_chunks/date-picker.js.map +0 -1
  355. package/dist/_chunks/file-preview.js +0 -499
  356. package/dist/_chunks/file-preview.js.map +0 -1
  357. package/dist/_chunks/rich-chat-input.js +0 -2071
  358. package/dist/_chunks/rich-chat-input.js.map +0 -1
  359. package/dist/_chunks/text.js.map +0 -1
  360. package/dist/ui/charts/index.js.map +0 -1
  361. /package/{LICENSE → skill/LICENSE} +0 -0
@@ -1,1036 +1,11 @@
1
1
  "use client";
2
- import { motionProps as e, tweens as t } from "../lib/motion.js";
3
- import { cn as n } from "../lib/utils.js";
4
- import { n as r } from "../../_chunks/motion-provider.js";
5
- import * as i from "react";
6
- import { useCallback as a, useEffect as o, useRef as s, useState as c } from "react";
7
- import { Fragment as l, jsx as u, jsxs as d } from "react/jsx-runtime";
8
- import { motion as f } from "framer-motion";
9
- import { scaleBand as p, scaleLinear as m, scalePoint as h } from "d3-scale";
10
- import { arc as g, area as _, curveLinear as v, curveLinearClosed as y, curveMonotoneX as b, line as x, lineRadial as S, pie as C, stack as w, stackOffsetNone as T, stackOrderNone as E } from "d3-shape";
11
- import { axisBottom as D, axisLeft as O, axisRight as k, axisTop as A } from "d3-axis";
12
- import { select as j } from "d3-selection";
13
- //#region src/ui/charts/_internal/legend.tsx
14
- function M({ items: e, position: t = "bottom", className: r }) {
15
- return /* @__PURE__ */ u("div", {
16
- className: n("flex gap-ds-04 text-ds-sm text-surface-fg-muted", t === "left" || t === "right" ? "flex-col" : "flex-row flex-wrap justify-center", r),
17
- children: e.map((e) => /* @__PURE__ */ d("div", {
18
- className: "flex items-center gap-ds-02",
19
- children: [/* @__PURE__ */ u("span", {
20
- className: "inline-block h-3 w-3 shrink-0 rounded-ds-sm",
21
- style: { backgroundColor: e.color }
22
- }), /* @__PURE__ */ u("span", { children: e.label })]
23
- }, e.label))
24
- });
25
- }
26
- M.displayName = "Legend";
27
- //#endregion
28
- //#region src/ui/charts/_internal/animation.ts
29
- function N() {
30
- let { reducedMotion: e } = r();
31
- return e;
32
- }
33
- function P(e, t = 300) {
34
- return e ? 0 : t;
35
- }
36
- //#endregion
37
- //#region src/ui/charts/_internal/axes.tsx
38
- function F({ scale: e, orientation: t, transform: n, tickCount: r, tickFormat: i, label: a, className: c }) {
39
- let l = s(null);
40
- return o(() => {
41
- if (!l.current) return;
42
- let n = {
43
- top: A,
44
- right: k,
45
- bottom: D,
46
- left: O
47
- }[t], a = n(e);
48
- r && (a = a.ticks(r)), i && (a = a.tickFormat(i));
49
- let o = j(l.current);
50
- o.call(a), o.selectAll(".tick line").attr("stroke", "var(--color-surface-border)"), o.selectAll(".tick text").attr("fill", "var(--color-surface-fg-muted)").attr("font-size", "var(--text-ds-xs)"), o.selectAll(".domain").attr("stroke", "var(--color-surface-border-strong)");
51
- }, [
52
- e,
53
- t,
54
- r,
55
- i
56
- ]), /* @__PURE__ */ u("g", {
57
- ref: l,
58
- transform: n,
59
- className: c,
60
- children: a && /* @__PURE__ */ u("text", {
61
- textAnchor: "middle",
62
- fill: "var(--color-surface-fg-muted)",
63
- fontSize: "var(--text-ds-sm)",
64
- ...t === "bottom" ? {
65
- x: "50%",
66
- dy: 35
67
- } : t === "left" ? {
68
- transform: "rotate(-90)",
69
- y: -40,
70
- x: 0
71
- } : {},
72
- children: a
73
- })
74
- });
75
- }
76
- F.displayName = "Axis";
77
- //#endregion
78
- //#region src/ui/charts/_internal/colors.ts
79
- var I = [
80
- "chart-1",
81
- "chart-2",
82
- "chart-3",
83
- "chart-4",
84
- "chart-5",
85
- "chart-6",
86
- "chart-7",
87
- "chart-8"
88
- ];
89
- function L(e) {
90
- return `var(--${e})`;
91
- }
92
- function R(e, t = 0) {
93
- return e ? I.includes(e) ? L(e) : e : L(I[t % I.length]);
94
- }
95
- //#endregion
96
- //#region src/ui/charts/_internal/grid-lines.tsx
97
- function z({ width: e, height: t, xScale: n, yScale: r, horizontal: i = !0, vertical: a = !1 }) {
98
- return /* @__PURE__ */ d("g", {
99
- className: "grid-lines",
100
- children: [i && r?.ticks && r.ticks().map((t, n) => /* @__PURE__ */ u("line", {
101
- x1: 0,
102
- x2: e,
103
- y1: r(t),
104
- y2: r(t),
105
- stroke: "var(--color-surface-border)",
106
- strokeDasharray: "3,3",
107
- opacity: .6
108
- }, `h-${n}`)), a && n?.ticks && n.ticks().map((e, r) => /* @__PURE__ */ u("line", {
109
- x1: n(e),
110
- x2: n(e),
111
- y1: 0,
112
- y2: t,
113
- stroke: "var(--color-surface-border)",
114
- strokeDasharray: "3,3",
115
- opacity: .6
116
- }, `v-${r}`))]
117
- });
118
- }
119
- z.displayName = "GridLines";
120
- //#endregion
121
- //#region src/ui/charts/_internal/tooltip.tsx
122
- function B({ state: e, className: t }) {
123
- return e.visible ? /* @__PURE__ */ u("div", {
124
- className: n("pointer-events-none absolute z-tooltip", "rounded-ds-md border border-surface-border-strong", "bg-surface-overlay px-ds-03 py-ds-02", "shadow-raised-hover", "text-ds-sm text-surface-fg", t),
125
- style: {
126
- left: e.x + 12,
127
- top: e.y - 12
128
- },
129
- children: e.content
130
- }) : null;
131
- }
132
- B.displayName = "ChartTooltip";
133
- function V() {
134
- let [e, t] = c({
135
- visible: !1,
136
- x: 0,
137
- y: 0,
138
- content: null
139
- });
140
- return {
141
- tooltip: e,
142
- show: a((e, n, r) => {
143
- t({
144
- visible: !0,
145
- x: e,
146
- y: n,
147
- content: r
148
- });
149
- }, []),
150
- hide: a(() => {
151
- t((e) => ({
152
- ...e,
153
- visible: !1
154
- }));
155
- }, [])
156
- };
157
- }
158
- //#endregion
159
- //#region src/ui/charts/_internal/types.ts
160
- var H = {
161
- top: 20,
162
- right: 20,
163
- bottom: 40,
164
- left: 50
165
- }, U = i.forwardRef(({ height: e = 300, margin: t, className: r, ariaLabel: i = "Chart", ariaDescription: a, children: l, ...f }, p) => {
166
- let m = s(null), [h, g] = c(0), _ = {
167
- ...H,
168
- ...t
169
- };
170
- o(() => {
171
- if (!m.current) return;
172
- let e = new ResizeObserver((e) => {
173
- let t = e[0];
174
- t && g(t.contentRect.width);
175
- });
176
- return e.observe(m.current), () => e.disconnect();
177
- }, []);
178
- let v = Math.max(0, h - _.left - _.right), y = Math.max(0, e - _.top - _.bottom);
179
- return /* @__PURE__ */ u("div", {
180
- ref: (e) => {
181
- m.current = e, typeof p == "function" ? p(e) : p && (p.current = e);
182
- },
183
- className: n("relative w-full", r),
184
- ...f,
185
- children: h > 0 && /* @__PURE__ */ d("svg", {
186
- width: h,
187
- height: e,
188
- role: "img",
189
- "aria-label": i,
190
- children: [a && /* @__PURE__ */ u("desc", { children: a }), /* @__PURE__ */ u("g", {
191
- transform: `translate(${_.left},${_.top})`,
192
- children: l({
193
- width: v,
194
- height: y,
195
- margin: _
196
- })
197
- })]
198
- })
199
- });
200
- });
201
- U.displayName = "ChartContainer";
202
- //#endregion
203
- //#region src/ui/charts/area-chart.tsx
204
- var W = i.forwardRef(({ data: r, xKey: a, series: o, curved: s = !1, stacked: c = !1, fillOpacity: p = .3, gradient: g = !1, strokeWidth: y = 2, height: S = 300, showGrid: C = !0, showTooltip: D = !0, showLegend: O = !1, animate: k = !0, xLabel: A, yLabel: j, ariaLabel: P, className: I, ...L }, H) => {
205
- let { tooltip: W, show: G, hide: K } = V(), q = N(), J = k && !q, Y = o.map((e, t) => R(e.color, t)), X = i.useId();
206
- return /* @__PURE__ */ d(f.div, {
207
- ref: H,
208
- className: n("relative", I),
209
- ...J ? {
210
- initial: {
211
- opacity: 0,
212
- scale: .96
213
- },
214
- animate: {
215
- opacity: 1,
216
- scale: 1
217
- },
218
- transition: t.fade
219
- } : {},
220
- ...e(L),
221
- children: [
222
- /* @__PURE__ */ u(U, {
223
- height: S,
224
- ariaLabel: P ?? "Area chart",
225
- children: ({ width: e, height: t, margin: n }) => {
226
- let i = r.map((e) => e[a]), f = i.every((e) => typeof e == "number"), S, O, k;
227
- if (f) {
228
- let t = i, n = Math.min(...t), o = Math.max(...t), s = m().domain([n, o]).range([0, e]);
229
- S = s, O = (e) => s(Number(e[a])), k = (e) => s(Number(r[e][a]));
230
- } else {
231
- let t = i.map(String), n = h().domain(t).range([0, e]).padding(.5);
232
- S = n, O = (e) => n(String(e[a])) ?? 0, k = (e) => n(String(r[e][a])) ?? 0;
233
- }
234
- let M;
235
- M = Math.max(...c ? r.map((e) => o.reduce((t, n) => t + (Number(e[n.key]) || 0), 0)) : r.flatMap((e) => o.map((t) => Number(e[t.key]) || 0)));
236
- let N = m().domain([0, M * 1.1]).range([t, 0]).nice(), P = s ? b : v, I = () => r.map((n, i) => {
237
- let s = O(n), c = e / Math.max(r.length - 1, 1);
238
- return /* @__PURE__ */ u("rect", {
239
- x: s - c / 2,
240
- y: 0,
241
- width: c,
242
- height: t,
243
- fill: "transparent",
244
- onMouseMove: (e) => {
245
- let t = e.currentTarget.closest("div")?.getBoundingClientRect();
246
- G(e.clientX - (t?.left ?? 0), e.clientY - (t?.top ?? 0), /* @__PURE__ */ d("div", { children: [/* @__PURE__ */ u("div", {
247
- className: "font-medium",
248
- children: String(n[a])
249
- }), o.map((e, t) => /* @__PURE__ */ d("div", {
250
- className: "flex items-center gap-ds-02",
251
- children: [
252
- /* @__PURE__ */ u("span", {
253
- className: "inline-block h-2 w-2 rounded-ds-full",
254
- style: { backgroundColor: Y[t] }
255
- }),
256
- /* @__PURE__ */ d("span", {
257
- className: "text-surface-fg-muted",
258
- children: [e.label, ":"]
259
- }),
260
- " ",
261
- Number(n[e.key]).toLocaleString()
262
- ]
263
- }, e.key))] }));
264
- },
265
- onMouseLeave: K
266
- }, `hover-${i}`);
267
- }), L = () => g ? /* @__PURE__ */ u("defs", { children: o.map((e, t) => /* @__PURE__ */ d("linearGradient", {
268
- id: `${X}-gradient-${t}`,
269
- x1: "0",
270
- y1: "0",
271
- x2: "0",
272
- y2: "1",
273
- children: [/* @__PURE__ */ u("stop", {
274
- offset: "0%",
275
- stopColor: Y[t],
276
- stopOpacity: p
277
- }), /* @__PURE__ */ u("stop", {
278
- offset: "100%",
279
- stopColor: Y[t],
280
- stopOpacity: .05
281
- })]
282
- }, `grad-${t}`)) }) : null, R = () => /* @__PURE__ */ d(l, { children: [/* @__PURE__ */ u(F, {
283
- scale: S,
284
- orientation: "bottom",
285
- transform: `translate(0,${t})`,
286
- label: A
287
- }), /* @__PURE__ */ u(F, {
288
- scale: N,
289
- orientation: "left",
290
- label: j
291
- })] });
292
- if (c) {
293
- let n = o.map((e) => e.key), i = w().keys(n).order(E).offset(T)(r.map((e) => {
294
- let t = { [a]: String(e[a]) };
295
- for (let n of o) t[n.key] = Number(e[n.key]) || 0;
296
- return t;
297
- })), s = _().curve(P).x((e, t) => k(t)).y0((e) => N(e[0])).y1((e) => N(e[1])), c = x().curve(P).x((e, t) => k(t)).y((e) => N(e[1]));
298
- return /* @__PURE__ */ d(l, { children: [
299
- L(),
300
- C && /* @__PURE__ */ u(z, {
301
- width: e,
302
- height: t,
303
- yScale: N,
304
- horizontal: !0
305
- }),
306
- [...i].reverse().map((e, t) => {
307
- let n = i.length - 1 - t, r = e, a = s(r) ?? "", l = c(r) ?? "";
308
- return /* @__PURE__ */ d("g", { children: [/* @__PURE__ */ u("path", {
309
- d: a,
310
- fill: g ? `url(#${X}-gradient-${n})` : Y[n],
311
- opacity: g ? 1 : p
312
- }), /* @__PURE__ */ u("path", {
313
- d: l,
314
- fill: "none",
315
- stroke: Y[n],
316
- strokeWidth: y,
317
- strokeLinejoin: "round",
318
- strokeLinecap: "round"
319
- })] }, o[n].key);
320
- }),
321
- D && I(),
322
- R()
323
- ] });
324
- }
325
- let B = _().curve(P).defined((e) => e != null), V = x().curve(P).defined((e) => e != null);
326
- return /* @__PURE__ */ d(l, { children: [
327
- L(),
328
- C && /* @__PURE__ */ u(z, {
329
- width: e,
330
- height: t,
331
- yScale: N,
332
- horizontal: !0
333
- }),
334
- [...o].reverse().map((e, n) => {
335
- let i = o.length - 1 - n, a = B.x((e) => O(e)).y0(t).y1((t) => N(Number(t[e.key]) || 0)), s = V.x((e) => O(e)).y((t) => N(Number(t[e.key]) || 0)), c = a(r) ?? "", l = s(r) ?? "";
336
- return /* @__PURE__ */ d("g", { children: [/* @__PURE__ */ u("path", {
337
- d: c,
338
- fill: g ? `url(#${X}-gradient-${i})` : Y[i],
339
- opacity: g ? 1 : p
340
- }), /* @__PURE__ */ u("path", {
341
- d: l,
342
- fill: "none",
343
- stroke: Y[i],
344
- strokeWidth: y,
345
- strokeLinejoin: "round",
346
- strokeLinecap: "round"
347
- })] }, e.key);
348
- }),
349
- D && I(),
350
- R()
351
- ] });
352
- }
353
- }),
354
- D && /* @__PURE__ */ u(B, { state: W }),
355
- O && o.length > 1 && /* @__PURE__ */ u(M, {
356
- items: o.map((e, t) => ({
357
- label: e.label,
358
- color: Y[t]
359
- })),
360
- className: "mt-ds-04"
361
- })
362
- ]
363
- });
364
- });
365
- W.displayName = "AreaChart";
366
- //#endregion
367
- //#region src/ui/charts/bar-chart.tsx
368
- var G = i.forwardRef(({ data: r, xKey: i, yKey: a, orientation: o = "vertical", stacked: s = !1, grouped: c = !1, color: h, height: g = 300, showGrid: _ = !0, showTooltip: v = !0, showLegend: y = !1, animate: b = !0, barRadius: x = 4, xLabel: S, yLabel: C, seriesLabels: w, ariaLabel: T, className: E, ...D }, O) => {
369
- let { tooltip: k, show: A, hide: j } = V(), P = N(), I = o === "vertical", L = b && !P, H = Array.isArray(a) ? a : [a], W = H.length > 1, G = W ? H.map((e, t) => R(Array.isArray(h) ? h[t] : typeof h == "string" ? h : void 0, t)) : [R(typeof h == "string" ? h : Array.isArray(h) ? h[0] : void 0, 0)];
370
- return /* @__PURE__ */ d(f.div, {
371
- ref: O,
372
- className: n("relative", E),
373
- ...L ? {
374
- initial: {
375
- opacity: 0,
376
- scale: .96
377
- },
378
- animate: {
379
- opacity: 1,
380
- scale: 1
381
- },
382
- transition: t.fade
383
- } : {},
384
- ...e(D),
385
- children: [
386
- /* @__PURE__ */ u(U, {
387
- height: g,
388
- ariaLabel: T ?? "Bar chart",
389
- children: ({ width: e, height: t, margin: n }) => {
390
- let a = r.map((e) => String(e[i])), o = r.map((e) => `${String(e[i])} — ${H.map((t, n) => `${w?.[n] ?? t}: ${Number(e[t]).toLocaleString()}`).join(", ")}`).join(". "), f;
391
- f = Math.max(...s ? r.map((e) => H.reduce((t, n) => t + (Number(e[n]) || 0), 0)) : r.flatMap((e) => H.map((t) => Number(e[t]) || 0)));
392
- let h = p().domain(a).range(I ? [0, e] : [0, t]).padding(.2), g = m().domain([0, f * 1.1]).range(I ? [t, 0] : [0, e]).nice(), y = h.bandwidth(), b = W && c ? y / H.length : y;
393
- return /* @__PURE__ */ d(l, { children: [
394
- /* @__PURE__ */ u("desc", { children: o }),
395
- _ && /* @__PURE__ */ u(z, {
396
- width: e,
397
- height: t,
398
- yScale: I ? g : void 0,
399
- xScale: I ? void 0 : g,
400
- horizontal: I,
401
- vertical: !I
402
- }),
403
- r.map((e) => {
404
- let n = String(e[i]), r = 0;
405
- return H.map((i, a) => {
406
- let o = Number(e[i]) || 0, l = G[a] || G[0], f, p, m, _;
407
- I ? (f = (h(n) ?? 0) + (c && W ? a * b : 0), p = g(s ? r + o : o), m = b, _ = s ? g(r) - g(r + o) : t - g(o)) : (f = s ? g(r) : 0, p = (h(n) ?? 0) + (c && W ? a * b : 0), m = s ? g(r + o) - g(r) : g(o), _ = b), s && (r += o);
408
- let y = w?.[a] ?? i, S = W ? `${n}, ${y}: ${o.toLocaleString()}` : `${n}: ${o.toLocaleString()}`, C = /* @__PURE__ */ d("div", { children: [
409
- /* @__PURE__ */ u("div", {
410
- className: "font-medium",
411
- children: n
412
- }),
413
- W && /* @__PURE__ */ u("div", {
414
- className: "text-surface-fg-muted",
415
- children: y
416
- }),
417
- /* @__PURE__ */ u("div", { children: o.toLocaleString() })
418
- ] });
419
- return /* @__PURE__ */ u("rect", {
420
- x: f,
421
- y: p,
422
- width: Math.max(0, m),
423
- height: Math.max(0, _),
424
- rx: x,
425
- fill: l,
426
- className: "transition-opacity hover:opacity-80 focus-visible:outline-hidden focus-visible:opacity-80",
427
- tabIndex: v ? 0 : void 0,
428
- role: v ? "graphics-symbol" : void 0,
429
- "aria-label": S,
430
- onMouseMove: (e) => {
431
- if (v) {
432
- let t = e.currentTarget.closest("div")?.getBoundingClientRect();
433
- A(e.clientX - (t?.left ?? 0), e.clientY - (t?.top ?? 0), C);
434
- }
435
- },
436
- onMouseLeave: j,
437
- onFocus: (e) => {
438
- if (v) {
439
- let t = e.currentTarget.closest("div")?.getBoundingClientRect(), n = e.currentTarget.getBoundingClientRect();
440
- A(n.left + n.width / 2 - (t?.left ?? 0), n.top - (t?.top ?? 0), C);
441
- }
442
- },
443
- onBlur: j
444
- }, `${n}-${i}`);
445
- });
446
- }),
447
- I ? /* @__PURE__ */ d(l, { children: [/* @__PURE__ */ u(F, {
448
- scale: h,
449
- orientation: "bottom",
450
- transform: `translate(0,${t})`,
451
- label: S
452
- }), /* @__PURE__ */ u(F, {
453
- scale: g,
454
- orientation: "left",
455
- label: C
456
- })] }) : /* @__PURE__ */ d(l, { children: [/* @__PURE__ */ u(F, {
457
- scale: g,
458
- orientation: "bottom",
459
- transform: `translate(0,${t})`,
460
- label: S
461
- }), /* @__PURE__ */ u(F, {
462
- scale: h,
463
- orientation: "left",
464
- label: C
465
- })] })
466
- ] });
467
- }
468
- }),
469
- v && /* @__PURE__ */ u(B, { state: k }),
470
- y && W && /* @__PURE__ */ u(M, {
471
- items: H.map((e, t) => ({
472
- label: w?.[t] ?? e,
473
- color: G[t]
474
- })),
475
- className: "mt-ds-04"
476
- })
477
- ]
478
- });
479
- });
480
- G.displayName = "BarChart";
481
- //#endregion
482
- //#region src/ui/charts/gauge-chart.tsx
483
- var K = (e) => e * Math.PI / 180, q = i.forwardRef(({ value: r, max: i = 100, min: a = 0, label: o, valueLabel: s, color: c, trackColor: l = "var(--color-surface-border)", height: p = 200, startAngle: m = -120, endAngle: h = 120, thickness: _ = 16, animate: v = !0, className: y, ...b }, x) => {
484
- let S = N(), C = P(S, v ? 600 : 0), w = v && !S, T = R(c, 0), E = p, D = E / 2, O = Math.min(Math.max(r, a), i), k = i === a ? 0 : (O - a) / (i - a), A = m + (h - m) * k, j = typeof s == "function" ? s(O) : typeof s == "string" ? s : String(O), M = g().innerRadius(D - _).outerRadius(D).startAngle(K(m)).endAngle(K(h)).cornerRadius(_ / 2), F = g().innerRadius(D - _).outerRadius(D).startAngle(K(m)).endAngle(K(A)).cornerRadius(_ / 2), I = M(null) ?? "", L = F(null) ?? "";
485
- return /* @__PURE__ */ u(f.div, {
486
- ref: x,
487
- className: n("inline-flex flex-col items-center", y),
488
- ...w ? {
489
- initial: {
490
- opacity: 0,
491
- scale: .96
492
- },
493
- animate: {
494
- opacity: 1,
495
- scale: 1
496
- },
497
- transition: t.fade
498
- } : {},
499
- ...e(b),
500
- role: "meter",
501
- "aria-valuenow": O,
502
- "aria-valuemin": a,
503
- "aria-valuemax": i,
504
- "aria-label": o ?? "Gauge chart",
505
- children: /* @__PURE__ */ u("svg", {
506
- width: E,
507
- height: E,
508
- role: "img",
509
- "aria-hidden": "true",
510
- children: /* @__PURE__ */ d("g", {
511
- transform: `translate(${D},${D})`,
512
- children: [
513
- /* @__PURE__ */ u("path", {
514
- d: I,
515
- fill: l
516
- }),
517
- /* @__PURE__ */ u("path", {
518
- d: L,
519
- fill: T,
520
- style: C > 0 ? { transition: `d ${C}ms ease-out` } : void 0
521
- }),
522
- /* @__PURE__ */ u("text", {
523
- x: 0,
524
- y: o ? -4 : 0,
525
- textAnchor: "middle",
526
- dominantBaseline: "central",
527
- className: "fill-surface-fg text-ds-2xl font-semibold",
528
- children: j
529
- }),
530
- o && /* @__PURE__ */ u("text", {
531
- x: 0,
532
- y: 20,
533
- textAnchor: "middle",
534
- dominantBaseline: "central",
535
- className: "fill-surface-fg-muted text-ds-xs",
536
- children: o
537
- })
538
- ]
539
- })
540
- })
541
- });
542
- });
543
- q.displayName = "GaugeChart";
544
- //#endregion
545
- //#region src/ui/charts/line-chart.tsx
546
- var J = i.forwardRef(({ data: r, xKey: i, series: a, curved: o = !1, showDots: s = !1, dotSize: c = 4, strokeWidth: p = 2, height: g = 300, showGrid: _ = !0, showTooltip: y = !0, showLegend: S = !1, animate: C = !0, xLabel: w, yLabel: T, ariaLabel: E, className: D, ...O }, k) => {
547
- let { tooltip: A, show: j, hide: P } = V(), I = N(), L = C && !I, H = a.map((e, t) => R(e.color, t));
548
- return /* @__PURE__ */ d(f.div, {
549
- ref: k,
550
- className: n("relative", D),
551
- ...L ? {
552
- initial: {
553
- opacity: 0,
554
- scale: .96
555
- },
556
- animate: {
557
- opacity: 1,
558
- scale: 1
559
- },
560
- transition: t.fade
561
- } : {},
562
- ...e(O),
563
- children: [
564
- /* @__PURE__ */ u(U, {
565
- height: g,
566
- ariaLabel: E ?? "Line chart",
567
- children: ({ width: e, height: t, margin: n }) => {
568
- let f = r.map((e) => e[i]), g = f.every((e) => typeof e == "number"), S, C;
569
- if (g) {
570
- let t = f, n = Math.min(...t), r = Math.max(...t), a = m().domain([n, r]).range([0, e]);
571
- S = a, C = (e) => a(Number(e[i]));
572
- } else {
573
- let t = f.map(String), n = h().domain(t).range([0, e]).padding(.5);
574
- S = n, C = (e) => n(String(e[i])) ?? 0;
575
- }
576
- let E = r.flatMap((e) => a.map((t) => Number(e[t.key]) || 0)), D = Math.max(...E), O = m().domain([0, D * 1.1]).range([t, 0]).nice(), k = o ? b : v, A = x().curve(k).defined((e) => e != null);
577
- return /* @__PURE__ */ d(l, { children: [
578
- /* @__PURE__ */ u("desc", { children: r.map((e) => `${String(e[i])} — ${a.map((t) => `${t.label}: ${Number(e[t.key]).toLocaleString()}`).join(", ")}`).join(". ") }),
579
- _ && /* @__PURE__ */ u(z, {
580
- width: e,
581
- height: t,
582
- yScale: O,
583
- horizontal: !0
584
- }),
585
- a.map((e, t) => /* @__PURE__ */ d("g", { children: [/* @__PURE__ */ u("path", {
586
- d: A.x((e) => C(e)).y((t) => O(Number(t[e.key]) || 0))(r) ?? "",
587
- fill: "none",
588
- stroke: H[t],
589
- strokeWidth: p,
590
- strokeLinejoin: "round",
591
- strokeLinecap: "round"
592
- }), s && r.map((n, r) => /* @__PURE__ */ u("circle", {
593
- cx: C(n),
594
- cy: O(Number(n[e.key]) || 0),
595
- r: c,
596
- fill: H[t],
597
- className: "transition-opacity hover:opacity-80"
598
- }, `${e.key}-dot-${r}`))] }, e.key)),
599
- y && r.map((n, o) => {
600
- let s = C(n), c = e / Math.max(r.length - 1, 1), l = String(n[i]), f = `${l}: ${a.map((e) => `${e.label} ${Number(n[e.key]).toLocaleString()}`).join(", ")}`, p = /* @__PURE__ */ d("div", { children: [/* @__PURE__ */ u("div", {
601
- className: "font-medium",
602
- children: l
603
- }), a.map((e, t) => /* @__PURE__ */ d("div", {
604
- className: "flex items-center gap-ds-02",
605
- children: [
606
- /* @__PURE__ */ u("span", {
607
- className: "inline-block h-2 w-2 rounded-ds-full",
608
- style: { backgroundColor: H[t] }
609
- }),
610
- /* @__PURE__ */ d("span", {
611
- className: "text-surface-fg-muted",
612
- children: [e.label, ":"]
613
- }),
614
- " ",
615
- Number(n[e.key]).toLocaleString()
616
- ]
617
- }, e.key))] });
618
- return /* @__PURE__ */ u("rect", {
619
- x: s - c / 2,
620
- y: 0,
621
- width: c,
622
- height: t,
623
- fill: "transparent",
624
- tabIndex: 0,
625
- role: "graphics-symbol",
626
- "aria-label": f,
627
- className: "focus-visible:outline-hidden",
628
- onMouseMove: (e) => {
629
- let t = e.currentTarget.closest("div")?.getBoundingClientRect();
630
- j(e.clientX - (t?.left ?? 0), e.clientY - (t?.top ?? 0), p);
631
- },
632
- onMouseLeave: P,
633
- onFocus: (e) => {
634
- let t = e.currentTarget.closest("div")?.getBoundingClientRect(), n = e.currentTarget.getBoundingClientRect();
635
- j(n.left + n.width / 2 - (t?.left ?? 0), n.top + n.height / 2 - (t?.top ?? 0), p);
636
- },
637
- onBlur: P
638
- }, `hover-${o}`);
639
- }),
640
- /* @__PURE__ */ u(F, {
641
- scale: S,
642
- orientation: "bottom",
643
- transform: `translate(0,${t})`,
644
- label: w
645
- }),
646
- /* @__PURE__ */ u(F, {
647
- scale: O,
648
- orientation: "left",
649
- label: T
650
- })
651
- ] });
652
- }
653
- }),
654
- y && /* @__PURE__ */ u(B, { state: A }),
655
- S && a.length > 1 && /* @__PURE__ */ u(M, {
656
- items: a.map((e, t) => ({
657
- label: e.label,
658
- color: H[t]
659
- })),
660
- className: "mt-ds-04"
661
- })
662
- ]
663
- });
664
- });
665
- J.displayName = "LineChart";
666
- //#endregion
667
- //#region src/ui/charts/pie-chart.tsx
668
- var Y = i.forwardRef(({ data: r, variant: i = "pie", innerRadius: a = .6, padAngle: p = 0, cornerRadius: m = 0, height: h = 300, showTooltip: _ = !0, showLegend: v = !1, showLabels: y = !1, animate: b = !0, className: x, centerLabel: S, ariaLabel: w, ...T }, E) => {
669
- let D = s(null), [O, k] = c(0), [A, j] = c(null), { tooltip: P, show: F, hide: I } = V(), L = N(), z = b && !L;
670
- o(() => {
671
- if (!D.current) return;
672
- let e = new ResizeObserver((e) => {
673
- let t = e[0];
674
- t && k(t.contentRect.width);
675
- });
676
- return e.observe(D.current), () => e.disconnect();
677
- }, []);
678
- let H = (O > 0 ? Math.min(O, h) : h) / 2, U = i === "donut" ? H * a : 0, W = r.map((e, t) => R(e.color, t)), G = r.reduce((e, t) => e + t.value, 0), K = C().value((e) => e.value).padAngle(p).sort(null)(r), q = g().innerRadius(U).outerRadius(H - 2).cornerRadius(m), J = U + (H - 2 - U) * .7, Y = g().innerRadius(J).outerRadius(J);
679
- return /* @__PURE__ */ d(f.div, {
680
- ref: (e) => {
681
- D.current = e, typeof E == "function" ? E(e) : E && (E.current = e);
682
- },
683
- className: n("relative w-full", x),
684
- ...z ? {
685
- initial: {
686
- opacity: 0,
687
- scale: .96
688
- },
689
- animate: {
690
- opacity: 1,
691
- scale: 1
692
- },
693
- transition: t.fade
694
- } : {},
695
- ...e(T),
696
- children: [O > 0 && /* @__PURE__ */ d(l, { children: [/* @__PURE__ */ u("svg", {
697
- width: O,
698
- height: h,
699
- role: "img",
700
- "aria-label": w ?? "Pie chart",
701
- children: /* @__PURE__ */ d("g", {
702
- transform: `translate(${O / 2},${h / 2})`,
703
- children: [
704
- K.map((e, t) => {
705
- let n = q(e);
706
- if (!n) return null;
707
- let [r, i] = q.centroid(e), a = Math.atan2(i, r), o = Math.cos(a) * 4, s = Math.sin(a) * 4, c = A === t;
708
- return /* @__PURE__ */ u("path", {
709
- d: n,
710
- fill: W[t],
711
- className: "cursor-pointer transition-transform",
712
- style: { transform: c ? `translate(${o}px, ${s}px)` : void 0 },
713
- onMouseEnter: () => j(t),
714
- onMouseMove: (t) => {
715
- if (_) {
716
- let n = t.currentTarget.closest("div")?.getBoundingClientRect(), r = G > 0 ? (e.data.value / G * 100).toFixed(1) : "0";
717
- F(t.clientX - (n?.left ?? 0), t.clientY - (n?.top ?? 0), /* @__PURE__ */ d("div", { children: [/* @__PURE__ */ u("div", {
718
- className: "font-medium",
719
- children: e.data.label
720
- }), /* @__PURE__ */ d("div", { children: [
721
- e.data.value.toLocaleString(),
722
- " (",
723
- r,
724
- "%)"
725
- ] })] }));
726
- }
727
- },
728
- onMouseLeave: () => {
729
- j(null), I();
730
- }
731
- }, `slice-${e.data.label}-${t}`);
732
- }),
733
- y && K.map((e, t) => {
734
- let [n, r] = Y.centroid(e), i = G > 0 ? (e.data.value / G * 100).toFixed(0) : "0";
735
- return G > 0 && e.data.value / G < .03 ? null : /* @__PURE__ */ d("text", {
736
- x: n,
737
- y: r,
738
- textAnchor: "middle",
739
- dominantBaseline: "central",
740
- className: "pointer-events-none fill-accent-fg text-ds-xs font-medium",
741
- children: [i, "%"]
742
- }, `label-${e.data.label}-${t}`);
743
- }),
744
- i === "donut" && S && U > 0 && /* @__PURE__ */ u("foreignObject", {
745
- x: -U * .7,
746
- y: -U * .7,
747
- width: U * 1.4,
748
- height: U * 1.4,
749
- children: /* @__PURE__ */ u("div", {
750
- className: "flex h-full w-full items-center justify-center text-center text-surface-fg",
751
- children: S
752
- })
753
- })
754
- ]
755
- })
756
- }), _ && /* @__PURE__ */ u(B, { state: P })] }), v && /* @__PURE__ */ u(M, {
757
- items: r.map((e, t) => ({
758
- label: e.label,
759
- color: W[t]
760
- })),
761
- className: "mt-ds-04"
762
- })]
763
- });
764
- });
765
- Y.displayName = "PieChart";
766
- //#endregion
767
- //#region src/ui/charts/radar-chart.tsx
768
- var X = i.forwardRef(({ data: r, axes: i, series: a, maxValue: p, levels: m = 5, fillOpacity: h = .25, showDots: g = !1, height: _ = 300, showTooltip: v = !0, showLegend: b = !1, animate: x = !0, ariaLabel: C, className: w, ...T }, E) => {
769
- let D = s(null), [O, k] = c(0), { tooltip: A, show: j, hide: P } = V(), F = N(), I = x && !F;
770
- o(() => {
771
- if (!D.current) return;
772
- let e = new ResizeObserver((e) => {
773
- let t = e[0];
774
- t && k(t.contentRect.width);
775
- });
776
- return e.observe(D.current), () => e.disconnect();
777
- }, []);
778
- let L = (O > 0 ? Math.min(O, _) : _) / 2 - 40, z = a.map((e, t) => R(e.color, t)), H = p ?? Math.max(...r.flatMap((e) => a.map((t) => Number(e[t.key]) || 0)), 1), U = 2 * Math.PI / i.length, W = S().radius((e) => L * e / H).angle((e, t) => t * U).curve(y), G = (e) => i.map((t, n) => Number(r[n]?.[e]) || 0), K = (e, t) => {
779
- let n = U * e - Math.PI / 2, r = L * t / H;
780
- return {
781
- x: r * Math.cos(n),
782
- y: r * Math.sin(n)
783
- };
784
- };
785
- return /* @__PURE__ */ d(f.div, {
786
- ref: (e) => {
787
- D.current = e, typeof E == "function" ? E(e) : E && (E.current = e);
788
- },
789
- className: n("relative w-full", w),
790
- ...I ? {
791
- initial: {
792
- opacity: 0,
793
- scale: .96
794
- },
795
- animate: {
796
- opacity: 1,
797
- scale: 1
798
- },
799
- transition: t.fade
800
- } : {},
801
- ...e(T),
802
- children: [O > 0 && /* @__PURE__ */ d(l, { children: [/* @__PURE__ */ u("svg", {
803
- width: O,
804
- height: _,
805
- role: "img",
806
- "aria-label": C ?? "Radar chart",
807
- children: /* @__PURE__ */ d("g", {
808
- transform: `translate(${O / 2},${_ / 2})`,
809
- children: [
810
- Array.from({ length: m }, (e, t) => {
811
- let n = L / m * (t + 1);
812
- return /* @__PURE__ */ u("polygon", {
813
- points: i.map((e, t) => {
814
- let r = U * t - Math.PI / 2;
815
- return `${n * Math.cos(r)},${n * Math.sin(r)}`;
816
- }).join(" "),
817
- fill: "none",
818
- stroke: "var(--color-surface-border)",
819
- strokeDasharray: "3,3",
820
- strokeWidth: 1
821
- }, `grid-${t}`);
822
- }),
823
- i.map((e, t) => {
824
- let n = U * t - Math.PI / 2;
825
- return /* @__PURE__ */ u("line", {
826
- x1: 0,
827
- y1: 0,
828
- x2: L * Math.cos(n),
829
- y2: L * Math.sin(n),
830
- stroke: "var(--color-surface-border)",
831
- strokeWidth: 1
832
- }, `axis-${t}`);
833
- }),
834
- i.map((e, t) => {
835
- let n = U * t - Math.PI / 2, r = L + 18, i = r * Math.cos(n), a = r * Math.sin(n), o = "middle";
836
- return Math.abs(Math.cos(n)) > .1 && (o = Math.cos(n) > 0 ? "start" : "end"), /* @__PURE__ */ u("text", {
837
- x: i,
838
- y: a,
839
- textAnchor: o,
840
- dominantBaseline: "central",
841
- className: "fill-surface-fg-muted text-ds-xs",
842
- children: e
843
- }, `label-${t}`);
844
- }),
845
- Array.from({ length: m }, (e, t) => {
846
- let n = Math.round(H / m * (t + 1)), r = L / m * (t + 1), i = -Math.PI / 2;
847
- return /* @__PURE__ */ u("text", {
848
- x: r * Math.cos(i) + 4,
849
- y: r * Math.sin(i),
850
- textAnchor: "start",
851
- dominantBaseline: "auto",
852
- className: "fill-surface-fg-subtle text-ds-xs",
853
- children: n
854
- }, `level-label-${t}`);
855
- }),
856
- a.map((e, t) => {
857
- let n = G(e.key), r = W(n);
858
- return r ? /* @__PURE__ */ d("g", { children: [/* @__PURE__ */ u("path", {
859
- d: r,
860
- fill: z[t],
861
- fillOpacity: h,
862
- stroke: z[t],
863
- strokeWidth: 2,
864
- strokeLinejoin: "round"
865
- }), g && n.map((n, r) => {
866
- let { x: i, y: a } = K(r, n);
867
- return /* @__PURE__ */ u("circle", {
868
- cx: i,
869
- cy: a,
870
- r: 4,
871
- fill: z[t],
872
- stroke: "var(--color-surface-base)",
873
- strokeWidth: 2,
874
- className: "transition-opacity"
875
- }, `dot-${e.key}-${r}`);
876
- })] }, e.key) : null;
877
- }),
878
- v && i.map((e, t) => {
879
- let n = U * t - Math.PI / 2;
880
- return /* @__PURE__ */ u("circle", {
881
- cx: L * Math.cos(n),
882
- cy: L * Math.sin(n),
883
- r: 16,
884
- fill: "transparent",
885
- className: "cursor-pointer",
886
- onMouseMove: (n) => {
887
- let i = n.currentTarget.closest("div")?.getBoundingClientRect();
888
- j(n.clientX - (i?.left ?? 0), n.clientY - (i?.top ?? 0), /* @__PURE__ */ d("div", { children: [/* @__PURE__ */ u("div", {
889
- className: "font-medium",
890
- children: e
891
- }), a.map((e, n) => {
892
- let i = Number(r[t]?.[e.key]) || 0;
893
- return /* @__PURE__ */ d("div", {
894
- className: "flex items-center gap-ds-02",
895
- children: [
896
- /* @__PURE__ */ u("span", {
897
- className: "inline-block h-2 w-2 rounded-ds-full",
898
- style: { backgroundColor: z[n] }
899
- }),
900
- /* @__PURE__ */ d("span", {
901
- className: "text-surface-fg-muted",
902
- children: [e.label, ":"]
903
- }),
904
- " ",
905
- i.toLocaleString()
906
- ]
907
- }, e.key);
908
- })] }));
909
- },
910
- onMouseLeave: P
911
- }, `hover-${t}`);
912
- })
913
- ]
914
- })
915
- }), v && /* @__PURE__ */ u(B, { state: A })] }), b && /* @__PURE__ */ u(M, {
916
- items: a.map((e, t) => ({
917
- label: e.label,
918
- color: z[t]
919
- })),
920
- className: "mt-ds-04"
921
- })]
922
- });
923
- });
924
- X.displayName = "RadarChart";
925
- //#endregion
926
- //#region src/ui/charts/sparkline.tsx
927
- var Z = {
928
- duration: 1,
929
- ease: "easeOut"
930
- }, Q = i.forwardRef(({ data: e, variant: t = "line", width: r = 120, height: i = 32, color: a, showLastDot: o = !1, strokeWidth: s = 1.5, animate: c = !0, className: l, ...p }, h) => {
931
- let g = R(a, 0), v = N(), y = c && !v;
932
- if (!e.length) return null;
933
- let S = t === "bar" ? 1 : s, C = r - S * 2, w = i - S * 2, T = m().domain([0, Math.max(e.length - 1, 1)]).range([S, S + C]), E = Math.min(...e), D = Math.max(...e), O = E === D ? [E - 1, D + 1] : [E, D], k = m().domain(O).range([S + w, S]);
934
- if (t === "bar") {
935
- let t = Math.max(1, (C - 1 * (e.length - 1)) / e.length), a = S + w;
936
- return /* @__PURE__ */ u("svg", {
937
- ref: h,
938
- width: r,
939
- height: i,
940
- role: "img",
941
- "aria-label": "Sparkline bar chart",
942
- className: n("inline-block align-middle", l),
943
- ...p,
944
- children: e.map((e, n) => {
945
- let r = S + n * (t + 1), i = k(e);
946
- return /* @__PURE__ */ u("rect", {
947
- x: r,
948
- y: i,
949
- width: t,
950
- height: Math.max(1, a - i),
951
- rx: Math.min(1, t / 2),
952
- fill: g
953
- }, n);
954
- })
955
- });
956
- }
957
- if (t === "area") {
958
- let t = _().curve(b).x((e, t) => T(t)).y0(S + w).y1((e) => k(e)), a = x().curve(b).x((e, t) => T(t)).y((e) => k(e)), c = t(e) ?? "", m = a(e) ?? "", v = T(e.length - 1), C = k(e[e.length - 1]);
959
- return /* @__PURE__ */ d("svg", {
960
- ref: h,
961
- width: r,
962
- height: i,
963
- role: "img",
964
- "aria-label": "Sparkline area chart",
965
- className: n("inline-block align-middle", l),
966
- ...p,
967
- children: [
968
- /* @__PURE__ */ u("path", {
969
- d: c,
970
- fill: g,
971
- opacity: .2
972
- }),
973
- y ? /* @__PURE__ */ u(f.path, {
974
- d: m,
975
- fill: "none",
976
- stroke: g,
977
- strokeWidth: s,
978
- strokeLinejoin: "round",
979
- strokeLinecap: "round",
980
- initial: { pathLength: 0 },
981
- animate: { pathLength: 1 },
982
- transition: Z
983
- }) : /* @__PURE__ */ u("path", {
984
- d: m,
985
- fill: "none",
986
- stroke: g,
987
- strokeWidth: s,
988
- strokeLinejoin: "round",
989
- strokeLinecap: "round"
990
- }),
991
- o && /* @__PURE__ */ u("circle", {
992
- cx: v,
993
- cy: C,
994
- r: s + 1,
995
- fill: g
996
- })
997
- ]
998
- });
999
- }
1000
- let A = x().curve(b).x((e, t) => T(t)).y((e) => k(e))(e) ?? "", j = T(e.length - 1), M = k(e[e.length - 1]);
1001
- return /* @__PURE__ */ d("svg", {
1002
- ref: h,
1003
- width: r,
1004
- height: i,
1005
- role: "img",
1006
- "aria-label": "Sparkline chart",
1007
- className: n("inline-block align-middle", l),
1008
- ...p,
1009
- children: [y ? /* @__PURE__ */ u(f.path, {
1010
- d: A,
1011
- fill: "none",
1012
- stroke: g,
1013
- strokeWidth: s,
1014
- strokeLinejoin: "round",
1015
- strokeLinecap: "round",
1016
- initial: { pathLength: 0 },
1017
- animate: { pathLength: 1 },
1018
- transition: Z
1019
- }) : /* @__PURE__ */ u("path", {
1020
- d: A,
1021
- fill: "none",
1022
- stroke: g,
1023
- strokeWidth: s,
1024
- strokeLinejoin: "round",
1025
- strokeLinecap: "round"
1026
- }), o && /* @__PURE__ */ u("circle", {
1027
- cx: j,
1028
- cy: M,
1029
- r: s + 1,
1030
- fill: g
1031
- })]
1032
- });
1033
- });
1034
- Q.displayName = "Sparkline";
1035
- //#endregion
1036
- export { W as AreaChart, G as BarChart, U as ChartContainer, q as GaugeChart, M as Legend, J as LineChart, Y as PieChart, X as RadarChart, Q as Sparkline };
2
+ import { r as e } from "../../_chunks/tooltip.js";
3
+ import { t } from "../../_chunks/chart-container.js";
4
+ import { AreaChart as n } from "./area-chart.js";
5
+ import { BarChart as r } from "./bar-chart.js";
6
+ import { GaugeChart as i } from "./gauge-chart.js";
7
+ import { LineChart as a } from "./line-chart.js";
8
+ import { PieChart as o } from "./pie-chart.js";
9
+ import { RadarChart as s } from "./radar-chart.js";
10
+ import { Sparkline as c } from "./sparkline.js";
11
+ export { n as AreaChart, r as BarChart, t as ChartContainer, i as GaugeChart, e as Legend, a as LineChart, o as PieChart, s as RadarChart, c as Sparkline };