@giddaa-housing/ui 0.1.0 → 1.1.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 (315) hide show
  1. package/README.md +18 -6
  2. package/css/base.css +37 -0
  3. package/css/components.css +135 -0
  4. package/css/generated/shared.css +1 -0
  5. package/css/giddaa.css +402 -0
  6. package/css/preset.css +77 -0
  7. package/css/styles.css +2 -0
  8. package/css/theme.css +255 -0
  9. package/dist/accordion.d.ts +9 -10
  10. package/dist/accordion.js +41 -117
  11. package/dist/activity-timeline.d.ts +29 -0
  12. package/dist/activity-timeline.js +97 -0
  13. package/dist/alert.d.ts +8 -9
  14. package/dist/alert.js +53 -141
  15. package/dist/auth-layout.d.ts +23 -0
  16. package/dist/auth-layout.js +153 -0
  17. package/dist/avatar.d.ts +6 -6
  18. package/dist/avatar.js +40 -142
  19. package/dist/badge.d.ts +12 -13
  20. package/dist/badge.js +66 -114
  21. package/dist/bar-chart.d.ts +136 -114
  22. package/dist/bar-chart.js +244 -297
  23. package/dist/breadcrumb.d.ts +5 -5
  24. package/dist/breadcrumb.js +56 -148
  25. package/dist/bullet-chart.d.ts +33 -33
  26. package/dist/bullet-chart.js +123 -183
  27. package/dist/button-BZIeyUw6.d.ts +17 -0
  28. package/dist/button-group.d.ts +13 -16
  29. package/dist/button-group.js +38 -163
  30. package/dist/button.d.ts +2 -19
  31. package/dist/button.js +90 -142
  32. package/dist/calendar.d.ts +6 -6
  33. package/dist/calendar.js +134 -288
  34. package/dist/card.d.ts +14 -16
  35. package/dist/card.js +58 -174
  36. package/dist/carousel.d.ts +34 -35
  37. package/dist/carousel.js +319 -378
  38. package/dist/chart.d.ts +58 -59
  39. package/dist/chart.js +350 -466
  40. package/dist/checkbox.d.ts +10 -12
  41. package/dist/checkbox.js +84 -84
  42. package/dist/cn-BI_4DMBf.js +23 -0
  43. package/dist/collapsible.d.ts +7 -8
  44. package/dist/collapsible.js +23 -77
  45. package/dist/combobox.d.ts +10 -10
  46. package/dist/combobox.js +220 -696
  47. package/dist/cta.d.ts +64 -0
  48. package/dist/cta.js +192 -0
  49. package/dist/currency-selector.d.ts +41 -0
  50. package/dist/currency-selector.js +114 -0
  51. package/dist/data-table.d.ts +164 -0
  52. package/dist/data-table.js +673 -0
  53. package/dist/date-picker.d.ts +27 -20
  54. package/dist/date-picker.js +122 -520
  55. package/dist/details-card.d.ts +19 -0
  56. package/dist/details-card.js +118 -0
  57. package/dist/dialog.d.ts +13 -14
  58. package/dist/dialog.js +117 -320
  59. package/dist/dropdown-menu.d.ts +14 -14
  60. package/dist/dropdown-menu.js +170 -365
  61. package/dist/dropzone.d.ts +55 -55
  62. package/dist/dropzone.js +328 -467
  63. package/dist/editorial-card.d.ts +27 -0
  64. package/dist/editorial-card.js +144 -0
  65. package/dist/empty-state.d.ts +8 -9
  66. package/dist/empty-state.js +48 -135
  67. package/dist/field.d.ts +23 -25
  68. package/dist/field.js +111 -327
  69. package/dist/filter.d.ts +118 -0
  70. package/dist/filter.js +775 -0
  71. package/dist/footer.d.ts +40 -0
  72. package/dist/footer.js +227 -0
  73. package/dist/funnel-chart.d.ts +38 -41
  74. package/dist/funnel-chart.js +168 -563
  75. package/dist/gallery-indicator.d.ts +17 -0
  76. package/dist/gallery-indicator.js +75 -0
  77. package/dist/heatmap-chart.d.ts +95 -0
  78. package/dist/heatmap-chart.js +197 -0
  79. package/dist/infotip.d.ts +10 -0
  80. package/dist/infotip.js +40 -0
  81. package/dist/input-CfoEJ8A6.d.ts +12 -0
  82. package/dist/input-group.d.ts +16 -19
  83. package/dist/input-group.js +92 -372
  84. package/dist/input-size-context-C-SFx9sx.d.ts +10 -0
  85. package/dist/input-size-context.d.ts +2 -11
  86. package/dist/input-size-context.js +14 -20
  87. package/dist/input.d.ts +2 -13
  88. package/dist/input.js +23 -79
  89. package/dist/item.d.ts +7 -8
  90. package/dist/item.js +22 -89
  91. package/dist/kpi-card.d.ts +18 -20
  92. package/dist/kpi-card.js +84 -232
  93. package/dist/label.d.ts +6 -6
  94. package/dist/label.js +39 -66
  95. package/dist/line-chart.d.ts +88 -89
  96. package/dist/line-chart.js +143 -262
  97. package/dist/logo.d.ts +4 -4
  98. package/dist/logo.js +87 -141
  99. package/dist/map-indicator.d.ts +13 -0
  100. package/dist/map-indicator.js +83 -0
  101. package/dist/match.d.ts +15 -0
  102. package/dist/match.js +68 -0
  103. package/dist/media-gallery-hero.d.ts +58 -0
  104. package/dist/media-gallery-hero.js +201 -0
  105. package/dist/media-player.d.ts +60 -0
  106. package/dist/media-player.js +919 -0
  107. package/dist/multi-step-form.d.ts +56 -0
  108. package/dist/multi-step-form.js +342 -0
  109. package/dist/number-input.d.ts +34 -34
  110. package/dist/number-input.js +62 -413
  111. package/dist/page-header.d.ts +10 -11
  112. package/dist/page-header.js +34 -107
  113. package/dist/pagination.d.ts +17 -20
  114. package/dist/pagination.js +132 -341
  115. package/dist/password-input.d.ts +5 -12
  116. package/dist/password-input.js +32 -354
  117. package/dist/phone-input.d.ts +19 -19
  118. package/dist/phone-input.js +232 -561
  119. package/dist/photo-gallery.d.ts +20 -20
  120. package/dist/photo-gallery.js +314 -746
  121. package/dist/picker-lzgmsNfG.js +32 -0
  122. package/dist/pie-chart.d.ts +60 -60
  123. package/dist/pie-chart.js +141 -184
  124. package/dist/popover.d.ts +9 -9
  125. package/dist/popover.js +60 -156
  126. package/dist/price-tag.d.ts +34 -0
  127. package/dist/price-tag.js +118 -0
  128. package/dist/progress.d.ts +18 -16
  129. package/dist/progress.js +156 -300
  130. package/dist/property-listing-card.d.ts +29 -0
  131. package/dist/property-listing-card.js +117 -0
  132. package/dist/radar-chart.d.ts +108 -0
  133. package/dist/radar-chart.js +172 -0
  134. package/dist/radio-group.d.ts +11 -13
  135. package/dist/radio-group.js +47 -96
  136. package/dist/review-block.d.ts +18 -0
  137. package/dist/review-block.js +154 -0
  138. package/dist/rich-text-editor.d.ts +30 -14
  139. package/dist/rich-text-editor.js +594 -979
  140. package/dist/scatter-chart.d.ts +140 -0
  141. package/dist/scatter-chart.js +248 -0
  142. package/dist/search-input.d.ts +8 -15
  143. package/dist/search-input.js +58 -408
  144. package/dist/select.d.ts +8 -8
  145. package/dist/select.js +131 -291
  146. package/dist/separator.d.ts +8 -9
  147. package/dist/separator.js +31 -70
  148. package/dist/sheet.d.ts +11 -11
  149. package/dist/sheet.js +84 -262
  150. package/dist/sidebar.d.ts +32 -37
  151. package/dist/sidebar.js +380 -1055
  152. package/dist/size-context-D4mYvcg8.d.ts +10 -0
  153. package/dist/size-context.d.ts +2 -11
  154. package/dist/size-context.js +14 -18
  155. package/dist/skeleton.d.ts +4 -5
  156. package/dist/skeleton.js +9 -45
  157. package/dist/slider.d.ts +27 -0
  158. package/dist/slider.js +81 -0
  159. package/dist/sparkline.d.ts +43 -46
  160. package/dist/sparkline.js +223 -561
  161. package/dist/stepper.d.ts +23 -24
  162. package/dist/stepper.js +149 -276
  163. package/dist/styles.css +9995 -2
  164. package/dist/switch.d.ts +10 -12
  165. package/dist/switch.js +49 -106
  166. package/dist/table-card.d.ts +35 -0
  167. package/dist/table-card.js +125 -0
  168. package/dist/table.d.ts +18 -14
  169. package/dist/table.js +114 -182
  170. package/dist/tabs.d.ts +23 -15
  171. package/dist/tabs.js +62 -149
  172. package/dist/tag.d.ts +22 -23
  173. package/dist/tag.js +104 -156
  174. package/dist/testimonial-block.d.ts +33 -0
  175. package/dist/testimonial-block.js +208 -0
  176. package/dist/textarea-IS_D8pXf.d.ts +11 -0
  177. package/dist/textarea.d.ts +2 -12
  178. package/dist/textarea.js +20 -74
  179. package/dist/time-picker.d.ts +11 -11
  180. package/dist/time-picker.js +247 -464
  181. package/dist/toast.d.ts +16 -18
  182. package/dist/toast.js +154 -310
  183. package/dist/tooltip.d.ts +9 -10
  184. package/dist/tooltip.js +33 -91
  185. package/dist/tree-map.d.ts +54 -57
  186. package/dist/tree-map.js +231 -646
  187. package/dist/use-uncontrolled-CLfM1XbB.js +21 -0
  188. package/dist/waterfall-chart.d.ts +126 -0
  189. package/dist/waterfall-chart.js +480 -0
  190. package/package.json +123 -34
  191. package/dist/accordion.js.map +0 -1
  192. package/dist/alert.js.map +0 -1
  193. package/dist/avatar.js.map +0 -1
  194. package/dist/badge.js.map +0 -1
  195. package/dist/bar-chart.js.map +0 -1
  196. package/dist/base.css +0 -32
  197. package/dist/breadcrumb.js.map +0 -1
  198. package/dist/bullet-chart.js.map +0 -1
  199. package/dist/button-group.js.map +0 -1
  200. package/dist/button.js.map +0 -1
  201. package/dist/calendar.js.map +0 -1
  202. package/dist/card.js.map +0 -1
  203. package/dist/carousel.js.map +0 -1
  204. package/dist/chart.js.map +0 -1
  205. package/dist/checkbox.js.map +0 -1
  206. package/dist/collapsible.js.map +0 -1
  207. package/dist/combobox.js.map +0 -1
  208. package/dist/date-picker.js.map +0 -1
  209. package/dist/dialog.js.map +0 -1
  210. package/dist/dropdown-menu.js.map +0 -1
  211. package/dist/dropzone.js.map +0 -1
  212. package/dist/empty-state.js.map +0 -1
  213. package/dist/field.js.map +0 -1
  214. package/dist/files/red-hat-display-latin-300-italic.woff +0 -0
  215. package/dist/files/red-hat-display-latin-300-italic.woff2 +0 -0
  216. package/dist/files/red-hat-display-latin-300-normal.woff +0 -0
  217. package/dist/files/red-hat-display-latin-300-normal.woff2 +0 -0
  218. package/dist/files/red-hat-display-latin-400-italic.woff +0 -0
  219. package/dist/files/red-hat-display-latin-400-italic.woff2 +0 -0
  220. package/dist/files/red-hat-display-latin-400-normal.woff +0 -0
  221. package/dist/files/red-hat-display-latin-400-normal.woff2 +0 -0
  222. package/dist/files/red-hat-display-latin-500-italic.woff +0 -0
  223. package/dist/files/red-hat-display-latin-500-italic.woff2 +0 -0
  224. package/dist/files/red-hat-display-latin-500-normal.woff +0 -0
  225. package/dist/files/red-hat-display-latin-500-normal.woff2 +0 -0
  226. package/dist/files/red-hat-display-latin-600-italic.woff +0 -0
  227. package/dist/files/red-hat-display-latin-600-italic.woff2 +0 -0
  228. package/dist/files/red-hat-display-latin-600-normal.woff +0 -0
  229. package/dist/files/red-hat-display-latin-600-normal.woff2 +0 -0
  230. package/dist/files/red-hat-display-latin-700-italic.woff +0 -0
  231. package/dist/files/red-hat-display-latin-700-italic.woff2 +0 -0
  232. package/dist/files/red-hat-display-latin-700-normal.woff +0 -0
  233. package/dist/files/red-hat-display-latin-700-normal.woff2 +0 -0
  234. package/dist/files/red-hat-display-latin-800-italic.woff +0 -0
  235. package/dist/files/red-hat-display-latin-800-italic.woff2 +0 -0
  236. package/dist/files/red-hat-display-latin-800-normal.woff +0 -0
  237. package/dist/files/red-hat-display-latin-800-normal.woff2 +0 -0
  238. package/dist/files/red-hat-display-latin-900-italic.woff +0 -0
  239. package/dist/files/red-hat-display-latin-900-italic.woff2 +0 -0
  240. package/dist/files/red-hat-display-latin-900-normal.woff +0 -0
  241. package/dist/files/red-hat-display-latin-900-normal.woff2 +0 -0
  242. package/dist/files/red-hat-display-latin-ext-300-italic.woff +0 -0
  243. package/dist/files/red-hat-display-latin-ext-300-italic.woff2 +0 -0
  244. package/dist/files/red-hat-display-latin-ext-300-normal.woff +0 -0
  245. package/dist/files/red-hat-display-latin-ext-300-normal.woff2 +0 -0
  246. package/dist/files/red-hat-display-latin-ext-400-italic.woff +0 -0
  247. package/dist/files/red-hat-display-latin-ext-400-italic.woff2 +0 -0
  248. package/dist/files/red-hat-display-latin-ext-400-normal.woff +0 -0
  249. package/dist/files/red-hat-display-latin-ext-400-normal.woff2 +0 -0
  250. package/dist/files/red-hat-display-latin-ext-500-italic.woff +0 -0
  251. package/dist/files/red-hat-display-latin-ext-500-italic.woff2 +0 -0
  252. package/dist/files/red-hat-display-latin-ext-500-normal.woff +0 -0
  253. package/dist/files/red-hat-display-latin-ext-500-normal.woff2 +0 -0
  254. package/dist/files/red-hat-display-latin-ext-600-italic.woff +0 -0
  255. package/dist/files/red-hat-display-latin-ext-600-italic.woff2 +0 -0
  256. package/dist/files/red-hat-display-latin-ext-600-normal.woff +0 -0
  257. package/dist/files/red-hat-display-latin-ext-600-normal.woff2 +0 -0
  258. package/dist/files/red-hat-display-latin-ext-700-italic.woff +0 -0
  259. package/dist/files/red-hat-display-latin-ext-700-italic.woff2 +0 -0
  260. package/dist/files/red-hat-display-latin-ext-700-normal.woff +0 -0
  261. package/dist/files/red-hat-display-latin-ext-700-normal.woff2 +0 -0
  262. package/dist/files/red-hat-display-latin-ext-800-italic.woff +0 -0
  263. package/dist/files/red-hat-display-latin-ext-800-italic.woff2 +0 -0
  264. package/dist/files/red-hat-display-latin-ext-800-normal.woff +0 -0
  265. package/dist/files/red-hat-display-latin-ext-800-normal.woff2 +0 -0
  266. package/dist/files/red-hat-display-latin-ext-900-italic.woff +0 -0
  267. package/dist/files/red-hat-display-latin-ext-900-italic.woff2 +0 -0
  268. package/dist/files/red-hat-display-latin-ext-900-normal.woff +0 -0
  269. package/dist/files/red-hat-display-latin-ext-900-normal.woff2 +0 -0
  270. package/dist/funnel-chart.js.map +0 -1
  271. package/dist/index.d.ts +0 -87
  272. package/dist/index.js +0 -10448
  273. package/dist/index.js.map +0 -1
  274. package/dist/input-group.js.map +0 -1
  275. package/dist/input-size-context.js.map +0 -1
  276. package/dist/input.js.map +0 -1
  277. package/dist/item.js.map +0 -1
  278. package/dist/kpi-card.js.map +0 -1
  279. package/dist/label.js.map +0 -1
  280. package/dist/line-chart.js.map +0 -1
  281. package/dist/logo.js.map +0 -1
  282. package/dist/number-input.js.map +0 -1
  283. package/dist/page-header.js.map +0 -1
  284. package/dist/pagination.js.map +0 -1
  285. package/dist/password-input.js.map +0 -1
  286. package/dist/phone-input.js.map +0 -1
  287. package/dist/photo-gallery.js.map +0 -1
  288. package/dist/pie-chart.js.map +0 -1
  289. package/dist/popover.js.map +0 -1
  290. package/dist/progress.js.map +0 -1
  291. package/dist/radio-group.js.map +0 -1
  292. package/dist/red-hat-display.css +0 -2
  293. package/dist/rich-text-editor.js.map +0 -1
  294. package/dist/search-input.js.map +0 -1
  295. package/dist/select.js.map +0 -1
  296. package/dist/separator.js.map +0 -1
  297. package/dist/sheet.js.map +0 -1
  298. package/dist/sidebar.js.map +0 -1
  299. package/dist/size-context.js.map +0 -1
  300. package/dist/skeleton.js.map +0 -1
  301. package/dist/sparkline.js.map +0 -1
  302. package/dist/stepper.js.map +0 -1
  303. package/dist/switch.js.map +0 -1
  304. package/dist/tab-list.d.ts +0 -38
  305. package/dist/tab-list.js +0 -394
  306. package/dist/tab-list.js.map +0 -1
  307. package/dist/table.js.map +0 -1
  308. package/dist/tabs.js.map +0 -1
  309. package/dist/tag.js.map +0 -1
  310. package/dist/textarea.js.map +0 -1
  311. package/dist/theme/giddaa.css +0 -2
  312. package/dist/time-picker.js.map +0 -1
  313. package/dist/toast.js.map +0 -1
  314. package/dist/tooltip.js.map +0 -1
  315. package/dist/tree-map.js.map +0 -1
package/dist/sparkline.js CHANGED
@@ -1,568 +1,230 @@
1
- // src/components/ui/sparkline.tsx
2
- import {
3
- Area,
4
- AreaChart,
5
- Bar,
6
- BarChart,
7
- Line,
8
- LineChart,
9
- XAxis
10
- } from "recharts";
11
-
12
- // src/lib/cn.ts
13
- import { clsx } from "clsx";
14
- import { extendTailwindMerge } from "tailwind-merge";
15
- var twMerge = extendTailwindMerge({
16
- extend: {
17
- classGroups: {
18
- "font-size": [
19
- {
20
- text: [
21
- "gdt-display",
22
- "gdt-h1",
23
- "gdt-h2",
24
- "gdt-h3",
25
- "gdt-h4",
26
- "gdt-h5",
27
- "gdt-xl",
28
- "gdt-lg",
29
- "gdt-md",
30
- "gdt-sm",
31
- "gdt-xs",
32
- "gdt-subtext",
33
- "gdt-capitalized"
34
- ]
35
- }
36
- ]
37
- }
38
- }
39
- });
40
- function cn(...inputs) {
41
- return twMerge(clsx(inputs));
42
- }
43
-
44
- // src/components/ui/chart.tsx
45
- import { cva } from "class-variance-authority";
46
- import * as React from "react";
47
- import * as RechartsPrimitive from "recharts";
48
-
49
- // src/components/ui/size-context.tsx
50
- import { createContext, useContext } from "react";
51
- import { Fragment, jsx } from "react/jsx-runtime";
52
- var SizeContext = createContext(void 0);
53
- function useComponentSize(size, fallback = "md") {
54
- const inheritedSize = useContext(SizeContext);
55
- return size ?? inheritedSize ?? fallback;
56
- }
57
-
58
- // src/components/ui/chart.tsx
59
- import { Fragment as Fragment2, jsx as jsx2, jsxs } from "react/jsx-runtime";
60
- var SERIES_COLOR_PLACEHOLDER = "var(--color-surface-brand)";
61
- function formatChartValue(value, type) {
62
- if (Array.isArray(value)) {
63
- return value.join(", ");
64
- }
65
- if (typeof value !== "number") {
66
- return value == null ? "" : String(value);
67
- }
68
- switch (type) {
69
- case "currency":
70
- return `\u20A6${value.toLocaleString("en-NG")}`;
71
- case "percentage":
72
- return `${value.toLocaleString("en-NG", {
73
- minimumFractionDigits: 1,
74
- maximumFractionDigits: 1
75
- })}%`;
76
- default:
77
- return value.toLocaleString("en-NG");
78
- }
79
- }
80
- var THEMES = { light: "", dark: ".dark" };
81
- var INITIAL_DIMENSION = { width: 320, height: 200 };
82
- var ChartContext = React.createContext(null);
83
- function useChart() {
84
- const context = React.useContext(ChartContext);
85
- if (!context) {
86
- throw new Error("useChart must be used within a <ChartContainer />");
87
- }
88
- return context;
89
- }
90
- var chartCardVariants = cva(
91
- "flex w-full min-w-0 flex-col rounded-2xl border border-line-subtle bg-surface-raised text-fg-primary shadow-1",
92
- {
93
- variants: {
94
- size: {
95
- sm: "gap-3 p-4",
96
- md: "gap-4 p-5",
97
- lg: "gap-5 p-6"
98
- }
99
- },
100
- defaultVariants: { size: "md" }
101
- }
102
- );
103
- var chartTitleVariants = cva("min-w-0 font-bold text-fg-primary", {
104
- variants: {
105
- size: {
106
- sm: "text-gdt-md",
107
- md: "text-gdt-lg",
108
- lg: "text-gdt-h5"
109
- }
110
- },
111
- defaultVariants: { size: "md" }
112
- });
113
- var chartDescriptionVariants = cva("min-w-0 font-normal text-fg-secondary", {
114
- variants: {
115
- size: {
116
- sm: "text-gdt-xs",
117
- md: "text-gdt-sm",
118
- lg: "text-gdt-sm"
119
- }
120
- },
121
- defaultVariants: { size: "md" }
122
- });
123
- function ChartContainer({
124
- id,
125
- className,
126
- children,
127
- config,
128
- initialDimension = INITIAL_DIMENSION,
129
- ...props
130
- }) {
131
- const uniqueId = React.useId();
132
- const chartId = `chart-${id ?? uniqueId.replace(/:/g, "")}`;
133
- return /* @__PURE__ */ jsx2(ChartContext.Provider, { value: { config }, children: /* @__PURE__ */ jsxs(
134
- "div",
135
- {
136
- "data-slot": "chart",
137
- "data-chart": chartId,
138
- className: cn(
139
- "flex aspect-video justify-center text-xs [&_.recharts-cartesian-axis-tick_text]:fill-muted-foreground [&_.recharts-cartesian-grid_line[stroke='#ccc']]:stroke-border/50 [&_.recharts-curve.recharts-tooltip-cursor]:stroke-border [&_.recharts-dot[stroke='#fff']]:stroke-transparent [&_.recharts-layer]:outline-hidden [&_.recharts-polar-grid_[stroke='#ccc']]:stroke-border [&_.recharts-radial-bar-background-sector]:fill-muted [&_.recharts-rectangle.recharts-tooltip-cursor]:fill-muted [&_.recharts-reference-line_[stroke='#ccc']]:stroke-border [&_.recharts-sector]:outline-hidden [&_.recharts-sector[stroke='#fff']]:stroke-transparent [&_.recharts-surface]:outline-hidden",
140
- className
141
- ),
142
- ...props,
143
- children: [
144
- /* @__PURE__ */ jsx2(ChartStyle, { id: chartId, config }),
145
- /* @__PURE__ */ jsx2(
146
- RechartsPrimitive.ResponsiveContainer,
147
- {
148
- initialDimension,
149
- children
150
- }
151
- )
152
- ]
153
- }
154
- ) });
155
- }
156
- var ChartStyle = ({ id, config }) => {
157
- const colorConfig = Object.entries(config).filter(
158
- ([, config2]) => config2.theme ?? config2.color
159
- );
160
- if (!colorConfig.length) {
161
- return null;
162
- }
163
- const styleContent = Object.entries(THEMES).map(
164
- ([theme, prefix]) => `
165
- ${prefix} [data-chart=${id}] {
166
- ${colorConfig.map(([key, itemConfig]) => {
167
- const color = itemConfig.theme?.[theme] ?? itemConfig.color;
168
- return color ? ` --color-${key}: ${color};` : null;
169
- }).join("\n")}
170
- }
171
- `
172
- ).join("\n");
173
- return /* @__PURE__ */ jsx2("style", { children: styleContent });
1
+ "use client";
2
+ import { t as cn } from "./cn-BI_4DMBf.js";
3
+ import { useComponentSize } from "./size-context.js";
4
+ import { ChartContainer, ChartTooltip, ChartTooltipContent } from "./chart.js";
5
+ import { jsx, jsxs } from "react/jsx-runtime";
6
+ import { Area, AreaChart, Bar, BarChart, Line, LineChart, XAxis } from "recharts";
7
+ //#region src/sparkline.tsx
8
+ const SPARKLINE_LAYOUT = {
9
+ sm: {
10
+ width: 72,
11
+ height: 24,
12
+ strokeWidth: 1.5,
13
+ dotRadius: 2,
14
+ margin: {
15
+ top: 4,
16
+ right: 4,
17
+ bottom: 2,
18
+ left: 2
19
+ },
20
+ barRadius: 1,
21
+ maxBarSize: 6
22
+ },
23
+ md: {
24
+ width: 104,
25
+ height: 32,
26
+ strokeWidth: 2,
27
+ dotRadius: 2.5,
28
+ margin: {
29
+ top: 5,
30
+ right: 5,
31
+ bottom: 2,
32
+ left: 2
33
+ },
34
+ barRadius: 2,
35
+ maxBarSize: 8
36
+ },
37
+ lg: {
38
+ width: 144,
39
+ height: 44,
40
+ strokeWidth: 2,
41
+ dotRadius: 3,
42
+ margin: {
43
+ top: 6,
44
+ right: 6,
45
+ bottom: 3,
46
+ left: 3
47
+ },
48
+ barRadius: 2,
49
+ maxBarSize: 10
50
+ }
174
51
  };
175
- var ChartTooltip = RechartsPrimitive.Tooltip;
176
- var chartTooltipVariants = cva(
177
- "flex flex-col bg-surface-overlay border border-line-subtle shadow-2",
178
- {
179
- variants: {
180
- size: {
181
- xs: "gap-0.5 rounded-md p-2",
182
- sm: "gap-0.5 rounded-md p-2.5",
183
- md: "gap-1 rounded-lg p-3",
184
- lg: "gap-1 rounded-xl p-3.5"
185
- }
186
- },
187
- defaultVariants: {
188
- size: "md"
189
- }
190
- }
191
- );
192
- var chartTooltipDotVariants = cva("shrink-0 rounded-full", {
193
- variants: {
194
- size: {
195
- xs: "size-1.5",
196
- sm: "size-2",
197
- md: "size-2.5",
198
- lg: "size-2.5"
199
- }
200
- },
201
- defaultVariants: {
202
- size: "md"
203
- }
204
- });
205
- var chartTooltipLabelVariants = cva("font-medium text-fg-secondary", {
206
- variants: {
207
- size: {
208
- xs: "text-gdt-xs",
209
- sm: "text-gdt-xs",
210
- md: "text-gdt-sm",
211
- lg: "text-gdt-sm"
212
- }
213
- },
214
- defaultVariants: { size: "md" }
215
- });
216
- var chartTooltipValueVariants = cva(
217
- "font-extrabold text-fg-primary tabular-nums",
218
- {
219
- variants: {
220
- size: {
221
- xs: "text-gdt-sm",
222
- sm: "text-gdt-md",
223
- md: "text-gdt-lg",
224
- lg: "text-gdt-xl"
225
- }
226
- },
227
- defaultVariants: { size: "md" }
228
- }
229
- );
230
- function ChartTooltipContent({
231
- active,
232
- payload,
233
- className,
234
- hideIndicator = false,
235
- label,
236
- labelFormatter,
237
- formatter,
238
- color,
239
- nameKey,
240
- valueType = "number",
241
- size = "md"
242
- }) {
243
- const { config } = useChart();
244
- if (!active || !payload?.length) {
245
- return null;
246
- }
247
- const [item] = payload.filter((entry) => entry.type !== "none");
248
- if (!item) {
249
- return null;
250
- }
251
- const key = `${nameKey ?? item.name ?? item.dataKey ?? "value"}`;
252
- const itemConfig = getPayloadConfigFromPayload(config, item, key);
253
- const dotColor = color ?? item.payload?.fill ?? item.color ?? SERIES_COLOR_PLACEHOLDER;
254
- const metricLabel = itemConfig?.label ?? item.name;
255
- const heroValue = formatter ? formatter(item.value, item.name ?? "", item, 0, item.payload) : formatChartValue(item.value, valueType);
256
- const periodCaption = labelFormatter ? labelFormatter(label, payload) : (typeof label === "string" ? config[label]?.label : null) ?? label;
257
- return /* @__PURE__ */ jsxs("div", { className: cn(chartTooltipVariants({ size }), className), children: [
258
- metricLabel != null && /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-1.5 [&>svg]:size-3 [&>svg]:shrink-0", children: [
259
- !hideIndicator && (itemConfig?.icon ? /* @__PURE__ */ jsx2(itemConfig.icon, {}) : /* @__PURE__ */ jsx2(
260
- "span",
261
- {
262
- "aria-hidden": "true",
263
- className: cn(chartTooltipDotVariants({ size })),
264
- style: { backgroundColor: dotColor }
265
- }
266
- )),
267
- /* @__PURE__ */ jsx2("span", { className: cn(chartTooltipLabelVariants({ size })), children: metricLabel })
268
- ] }),
269
- /* @__PURE__ */ jsx2("p", { className: cn(chartTooltipValueVariants({ size })), children: heroValue }),
270
- periodCaption != null && periodCaption !== "" && /* @__PURE__ */ jsx2("p", { className: "text-gdt-xs text-fg-caption-placeholder", children: periodCaption })
271
- ] });
272
- }
273
- var chartLegendItemVariants = cva(
274
- "group/legend-item flex items-center rounded-md leading-none text-fg-primary transition-colors [&>svg]:shrink-0",
275
- {
276
- variants: {
277
- size: {
278
- sm: "gap-1.5 px-2 py-1 text-gdt-xs [&>svg]:size-3",
279
- md: "gap-2 px-2.5 py-1.5 text-gdt-sm [&>svg]:size-3.5"
280
- },
281
- interactive: {
282
- true: "cursor-pointer outline-none hover:bg-surface-raised focus-visible:bg-surface-raised",
283
- false: ""
284
- },
285
- inactive: {
286
- true: "text-fg-caption-placeholder line-through",
287
- false: ""
288
- }
289
- },
290
- defaultVariants: {
291
- size: "md",
292
- interactive: false,
293
- inactive: false
294
- }
295
- }
296
- );
297
- var chartLegendMarkerSizeVariants = cva("shrink-0", {
298
- variants: {
299
- marker: {
300
- dot: "rounded-full",
301
- square: "rounded-[2px]",
302
- line: "rounded-full"
303
- },
304
- size: {
305
- sm: "",
306
- md: ""
307
- }
308
- },
309
- compoundVariants: [
310
- { marker: ["dot", "square"], size: "sm", className: "size-2" },
311
- { marker: ["dot", "square"], size: "md", className: "size-2.5" },
312
- { marker: "line", size: "sm", className: "h-[3px] w-3" },
313
- { marker: "line", size: "md", className: "h-[3px] w-3.5" }
314
- ],
315
- defaultVariants: { marker: "dot", size: "md" }
316
- });
317
- function getPayloadConfigFromPayload(config, payload, key) {
318
- if (typeof payload !== "object" || payload === null) {
319
- return void 0;
320
- }
321
- const payloadPayload = "payload" in payload && typeof payload.payload === "object" && payload.payload !== null ? payload.payload : void 0;
322
- let configLabelKey = key;
323
- if (key in payload && typeof payload[key] === "string") {
324
- configLabelKey = payload[key];
325
- } else if (payloadPayload && key in payloadPayload && typeof payloadPayload[key] === "string") {
326
- configLabelKey = payloadPayload[key];
327
- }
328
- return configLabelKey in config ? config[configLabelKey] : config[key];
329
- }
330
-
331
- // src/components/ui/sparkline.tsx
332
- import { jsx as jsx3, jsxs as jsxs2 } from "react/jsx-runtime";
333
- var SPARKLINE_LAYOUT = {
334
- sm: {
335
- width: 72,
336
- height: 24,
337
- strokeWidth: 1.5,
338
- dotRadius: 2,
339
- margin: { top: 4, right: 4, bottom: 2, left: 2 },
340
- barRadius: 1,
341
- maxBarSize: 6
342
- },
343
- md: {
344
- width: 104,
345
- height: 32,
346
- strokeWidth: 2,
347
- dotRadius: 2.5,
348
- margin: { top: 5, right: 5, bottom: 2, left: 2 },
349
- barRadius: 2,
350
- maxBarSize: 8
351
- },
352
- lg: {
353
- width: 144,
354
- height: 44,
355
- strokeWidth: 2,
356
- dotRadius: 3,
357
- margin: { top: 6, right: 6, bottom: 3, left: 3 },
358
- barRadius: 2,
359
- maxBarSize: 10
360
- }
361
- };
362
- var TREND_COLOR = {
363
- up: "var(--color-status-success)",
364
- down: "var(--color-status-danger)",
365
- flat: "var(--color-fg-secondary)"
52
+ const TREND_COLOR = {
53
+ up: "var(--color-status-success)",
54
+ down: "var(--color-status-danger)",
55
+ flat: "var(--color-fg-secondary)"
366
56
  };
57
+ /**
58
+ * Derive sentiment from the series: compare the last value to the first and
59
+ * read flat when the change is a small fraction of the overall range.
60
+ */
367
61
  function resolveTrend(data) {
368
- if (data.length < 2) return "flat";
369
- const first = data[0];
370
- const last = data[data.length - 1];
371
- const min = Math.min(...data);
372
- const max = Math.max(...data);
373
- const range = max - min || 1;
374
- const delta = last - first;
375
- if (Math.abs(delta) / range < 0.05) return "flat";
376
- return delta > 0 ? "up" : "down";
62
+ if (data.length < 2) return "flat";
63
+ const first = data[0];
64
+ const last = data[data.length - 1];
65
+ const min = Math.min(...data);
66
+ const range = Math.max(...data) - min || 1;
67
+ const delta = last - first;
68
+ if (Math.abs(delta) / range < .05) return "flat";
69
+ return delta > 0 ? "up" : "down";
377
70
  }
378
- function SparklineEndDot({
379
- cx,
380
- cy,
381
- index,
382
- lastIndex,
383
- radius
384
- }) {
385
- if (cx == null || cy == null || index !== lastIndex) {
386
- return null;
387
- }
388
- return /* @__PURE__ */ jsx3(
389
- "circle",
390
- {
391
- cx,
392
- cy,
393
- r: radius,
394
- fill: "var(--color-value)",
395
- stroke: "var(--color-surface)",
396
- strokeWidth: 2
397
- }
398
- );
71
+ /**
72
+ * Custom dot passed to recharts as `dot={<SparklineEndDot ... />}`. recharts
73
+ * clones it for every point, injecting `cx`/`cy`/`index`; we only paint the
74
+ * latest point so the series carries a single end-point marker.
75
+ */
76
+ function SparklineEndDot({ cx, cy, index, lastIndex, radius }) {
77
+ if (cx == null || cy == null || index !== lastIndex) return null;
78
+ return /* @__PURE__ */ jsx("circle", {
79
+ cx,
80
+ cy,
81
+ r: radius,
82
+ fill: "var(--color-value)",
83
+ stroke: "var(--color-surface)",
84
+ strokeWidth: 2
85
+ });
399
86
  }
400
- function SparklineBarShape({
401
- x,
402
- y,
403
- width,
404
- height,
405
- index,
406
- value,
407
- lastIndex,
408
- radius,
409
- dotRadius
410
- }) {
411
- if (x == null || y == null || width == null || height == null) {
412
- return null;
413
- }
414
- const markerY = typeof value === "number" && value < 0 ? y + height : y;
415
- return /* @__PURE__ */ jsxs2("g", { children: [
416
- /* @__PURE__ */ jsx3(
417
- "rect",
418
- {
419
- x,
420
- y,
421
- width,
422
- height,
423
- rx: radius,
424
- ry: radius,
425
- fill: "var(--color-value)"
426
- }
427
- ),
428
- index === lastIndex ? /* @__PURE__ */ jsx3(
429
- "circle",
430
- {
431
- cx: x + width / 2,
432
- cy: markerY,
433
- r: dotRadius,
434
- fill: "var(--color-value)",
435
- stroke: "var(--color-surface)",
436
- strokeWidth: 2
437
- }
438
- ) : null
439
- ] });
87
+ /**
88
+ * Bars do not support `dot`, so the marker is rendered as part of a custom bar
89
+ * shape. Only the latest bar receives the end-point marker.
90
+ */
91
+ function SparklineBarShape({ x, y, width, height, index, value, lastIndex, radius, dotRadius }) {
92
+ if (x == null || y == null || width == null || height == null) return null;
93
+ const markerY = typeof value === "number" && value < 0 ? y + height : y;
94
+ return /* @__PURE__ */ jsxs("g", { children: [/* @__PURE__ */ jsx("rect", {
95
+ x,
96
+ y,
97
+ width,
98
+ height,
99
+ rx: radius,
100
+ ry: radius,
101
+ fill: "var(--color-value)"
102
+ }), index === lastIndex ? /* @__PURE__ */ jsx("circle", {
103
+ cx: x + width / 2,
104
+ cy: markerY,
105
+ r: dotRadius,
106
+ fill: "var(--color-value)",
107
+ stroke: "var(--color-surface)",
108
+ strokeWidth: 2
109
+ }) : null] });
440
110
  }
441
- function Sparkline({
442
- data,
443
- type = "line",
444
- size,
445
- trend,
446
- showMarker = true,
447
- tooltip = false,
448
- label = "Value",
449
- labels,
450
- valueType = "number",
451
- className,
452
- style,
453
- ...props
454
- }) {
455
- const layout = SPARKLINE_LAYOUT[useComponentSize(size)];
456
- const resolvedTrend = trend ?? resolveTrend(data);
457
- const color = TREND_COLOR[resolvedTrend];
458
- const chartData = data.map((value, i) => ({
459
- x: labels?.[i] ?? `${i + 1}`,
460
- value
461
- }));
462
- const lastIndex = data.length - 1;
463
- const config = {
464
- value: { label, color }
465
- };
466
- const showDot = showMarker && data.length >= 2;
467
- const endDot = showDot ? /* @__PURE__ */ jsx3(SparklineEndDot, { lastIndex, radius: layout.dotRadius }) : false;
468
- const barShape = showDot ? /* @__PURE__ */ jsx3(
469
- SparklineBarShape,
470
- {
471
- lastIndex,
472
- radius: layout.barRadius,
473
- dotRadius: layout.dotRadius
474
- }
475
- ) : void 0;
476
- const activeDot = tooltip ? {
477
- r: layout.dotRadius + 0.5,
478
- fill: "var(--color-value)",
479
- stroke: "var(--color-surface)",
480
- strokeWidth: 2
481
- } : false;
482
- const tooltipNode = tooltip ? /* @__PURE__ */ jsx3(
483
- ChartTooltip,
484
- {
485
- cursor: false,
486
- content: /* @__PURE__ */ jsx3(ChartTooltipContent, { size: "xs", valueType })
487
- }
488
- ) : null;
489
- const ariaLabel = props["aria-label"] ?? `${label} sparkline, trend ${resolvedTrend}`;
490
- if (data.length < 2) {
491
- return /* @__PURE__ */ jsx3(
492
- "div",
493
- {
494
- ...props,
495
- "aria-label": ariaLabel,
496
- role: "img",
497
- className: cn("w-full", className),
498
- style: { height: layout.height, ...style }
499
- }
500
- );
501
- }
502
- return /* @__PURE__ */ jsx3(
503
- ChartContainer,
504
- {
505
- ...props,
506
- "aria-label": ariaLabel,
507
- role: "img",
508
- config,
509
- className: cn("aspect-auto w-full", className),
510
- style: { height: layout.height, ...style },
511
- children: type === "bar" ? /* @__PURE__ */ jsxs2(BarChart, { accessibilityLayer: true, data: chartData, margin: layout.margin, children: [
512
- tooltipNode,
513
- /* @__PURE__ */ jsx3(
514
- Bar,
515
- {
516
- dataKey: "value",
517
- fill: "var(--color-value)",
518
- radius: layout.barRadius,
519
- maxBarSize: layout.maxBarSize,
520
- shape: barShape,
521
- isAnimationActive: false
522
- }
523
- )
524
- ] }) : type === "area" ? /* @__PURE__ */ jsxs2(AreaChart, { accessibilityLayer: true, data: chartData, margin: layout.margin, children: [
525
- tooltip ? /* @__PURE__ */ jsx3(XAxis, { dataKey: "x", hide: true }) : null,
526
- tooltipNode,
527
- /* @__PURE__ */ jsx3(
528
- Area,
529
- {
530
- type: "monotone",
531
- dataKey: "value",
532
- stroke: "var(--color-value)",
533
- strokeWidth: layout.strokeWidth,
534
- strokeLinejoin: "round",
535
- strokeLinecap: "round",
536
- fill: "var(--color-value)",
537
- fillOpacity: 0.14,
538
- dot: endDot,
539
- activeDot,
540
- isAnimationActive: false
541
- }
542
- )
543
- ] }) : /* @__PURE__ */ jsxs2(LineChart, { accessibilityLayer: true, data: chartData, margin: layout.margin, children: [
544
- tooltip ? /* @__PURE__ */ jsx3(XAxis, { dataKey: "x", hide: true }) : null,
545
- tooltipNode,
546
- /* @__PURE__ */ jsx3(
547
- Line,
548
- {
549
- type: "monotone",
550
- dataKey: "value",
551
- stroke: "var(--color-value)",
552
- strokeWidth: layout.strokeWidth,
553
- strokeLinejoin: "round",
554
- strokeLinecap: "round",
555
- dot: endDot,
556
- activeDot,
557
- isAnimationActive: false
558
- }
559
- )
560
- ] })
561
- }
562
- );
111
+ function Sparkline({ data, type = "line", size, trend, showMarker = true, tooltip = false, label = "Value", labels, valueType = "number", className, style, ...props }) {
112
+ const layout = SPARKLINE_LAYOUT[useComponentSize(size)];
113
+ const resolvedTrend = trend ?? resolveTrend(data);
114
+ const color = TREND_COLOR[resolvedTrend];
115
+ const chartData = data.map((value, i) => ({
116
+ x: labels?.[i] ?? `${i + 1}`,
117
+ value
118
+ }));
119
+ const lastIndex = data.length - 1;
120
+ const config = { value: {
121
+ label,
122
+ color
123
+ } };
124
+ const showDot = showMarker && data.length >= 2;
125
+ const endDot = showDot ? /* @__PURE__ */ jsx(SparklineEndDot, {
126
+ lastIndex,
127
+ radius: layout.dotRadius
128
+ }) : false;
129
+ const barShape = showDot ? /* @__PURE__ */ jsx(SparklineBarShape, {
130
+ lastIndex,
131
+ radius: layout.barRadius,
132
+ dotRadius: layout.dotRadius
133
+ }) : void 0;
134
+ const activeDot = tooltip ? {
135
+ r: layout.dotRadius + .5,
136
+ fill: "var(--color-value)",
137
+ stroke: "var(--color-surface)",
138
+ strokeWidth: 2
139
+ } : false;
140
+ const tooltipNode = tooltip ? /* @__PURE__ */ jsx(ChartTooltip, {
141
+ cursor: false,
142
+ content: /* @__PURE__ */ jsx(ChartTooltipContent, {
143
+ size: "xs",
144
+ valueType
145
+ })
146
+ }) : null;
147
+ const ariaLabel = props["aria-label"] ?? `${label} sparkline, trend ${resolvedTrend}`;
148
+ if (data.length < 2) return /* @__PURE__ */ jsx("div", {
149
+ ...props,
150
+ "aria-label": ariaLabel,
151
+ role: "img",
152
+ className: cn("w-full", className),
153
+ style: {
154
+ height: layout.height,
155
+ ...style
156
+ }
157
+ });
158
+ return /* @__PURE__ */ jsx(ChartContainer, {
159
+ ...props,
160
+ "aria-label": ariaLabel,
161
+ role: "img",
162
+ config,
163
+ className: cn("aspect-auto w-full", className),
164
+ style: {
165
+ height: layout.height,
166
+ ...style
167
+ },
168
+ children: type === "bar" ? /* @__PURE__ */ jsxs(BarChart, {
169
+ accessibilityLayer: true,
170
+ data: chartData,
171
+ margin: layout.margin,
172
+ children: [tooltipNode, /* @__PURE__ */ jsx(Bar, {
173
+ dataKey: "value",
174
+ fill: "var(--color-value)",
175
+ radius: layout.barRadius,
176
+ maxBarSize: layout.maxBarSize,
177
+ shape: barShape,
178
+ isAnimationActive: false
179
+ })]
180
+ }) : type === "area" ? /* @__PURE__ */ jsxs(AreaChart, {
181
+ accessibilityLayer: true,
182
+ data: chartData,
183
+ margin: layout.margin,
184
+ children: [
185
+ tooltip ? /* @__PURE__ */ jsx(XAxis, {
186
+ dataKey: "x",
187
+ hide: true
188
+ }) : null,
189
+ tooltipNode,
190
+ /* @__PURE__ */ jsx(Area, {
191
+ type: "monotone",
192
+ dataKey: "value",
193
+ stroke: "var(--color-value)",
194
+ strokeWidth: layout.strokeWidth,
195
+ strokeLinejoin: "round",
196
+ strokeLinecap: "round",
197
+ fill: "var(--color-value)",
198
+ fillOpacity: .14,
199
+ dot: endDot,
200
+ activeDot,
201
+ isAnimationActive: false
202
+ })
203
+ ]
204
+ }) : /* @__PURE__ */ jsxs(LineChart, {
205
+ accessibilityLayer: true,
206
+ data: chartData,
207
+ margin: layout.margin,
208
+ children: [
209
+ tooltip ? /* @__PURE__ */ jsx(XAxis, {
210
+ dataKey: "x",
211
+ hide: true
212
+ }) : null,
213
+ tooltipNode,
214
+ /* @__PURE__ */ jsx(Line, {
215
+ type: "monotone",
216
+ dataKey: "value",
217
+ stroke: "var(--color-value)",
218
+ strokeWidth: layout.strokeWidth,
219
+ strokeLinejoin: "round",
220
+ strokeLinecap: "round",
221
+ dot: endDot,
222
+ activeDot,
223
+ isAnimationActive: false
224
+ })
225
+ ]
226
+ })
227
+ });
563
228
  }
564
- export {
565
- SPARKLINE_LAYOUT,
566
- Sparkline
567
- };
568
- //# sourceMappingURL=sparkline.js.map
229
+ //#endregion
230
+ export { SPARKLINE_LAYOUT, Sparkline };