@giddaa-housing/ui 0.1.0 → 1.0.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 (334) 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.js +5 -35
  10. package/dist/accordion.js.map +1 -1
  11. package/dist/activity-timeline.d.ts +33 -0
  12. package/dist/activity-timeline.js +212 -0
  13. package/dist/activity-timeline.js.map +1 -0
  14. package/dist/alert.js +5 -35
  15. package/dist/alert.js.map +1 -1
  16. package/dist/auth-layout.d.ts +23 -0
  17. package/dist/auth-layout.js +304 -0
  18. package/dist/auth-layout.js.map +1 -0
  19. package/dist/avatar.js +10 -142
  20. package/dist/avatar.js.map +1 -1
  21. package/dist/badge.d.ts +3 -2
  22. package/dist/badge.js +6 -114
  23. package/dist/badge.js.map +1 -1
  24. package/dist/bar-chart.d.ts +101 -77
  25. package/dist/bar-chart.js +142 -220
  26. package/dist/bar-chart.js.map +1 -1
  27. package/dist/breadcrumb.js +5 -35
  28. package/dist/breadcrumb.js.map +1 -1
  29. package/dist/bullet-chart.js +15 -48
  30. package/dist/bullet-chart.js.map +1 -1
  31. package/dist/button-group.js +14 -90
  32. package/dist/button-group.js.map +1 -1
  33. package/dist/button.d.ts +5 -5
  34. package/dist/button.js +7 -140
  35. package/dist/button.js.map +1 -1
  36. package/dist/calendar.js +12 -287
  37. package/dist/calendar.js.map +1 -1
  38. package/dist/card.js +5 -35
  39. package/dist/card.js.map +1 -1
  40. package/dist/carousel.js +12 -386
  41. package/dist/carousel.js.map +1 -1
  42. package/dist/chart.js +16 -480
  43. package/dist/chart.js.map +1 -1
  44. package/dist/checkbox.d.ts +1 -1
  45. package/dist/checkbox.js +13 -48
  46. package/dist/checkbox.js.map +1 -1
  47. package/dist/chunk-322YCNVL.js +278 -0
  48. package/dist/chunk-322YCNVL.js.map +1 -0
  49. package/dist/chunk-3ACQVT7A.js +25 -0
  50. package/dist/chunk-3ACQVT7A.js.map +1 -0
  51. package/dist/chunk-3T65TLJX.js +334 -0
  52. package/dist/chunk-3T65TLJX.js.map +1 -0
  53. package/dist/chunk-6ZSGQHH2.js +192 -0
  54. package/dist/chunk-6ZSGQHH2.js.map +1 -0
  55. package/dist/chunk-7TBMLFGW.js +41 -0
  56. package/dist/chunk-7TBMLFGW.js.map +1 -0
  57. package/dist/chunk-B4H6RNDH.js +135 -0
  58. package/dist/chunk-B4H6RNDH.js.map +1 -0
  59. package/dist/chunk-BUXCGZ6X.js +219 -0
  60. package/dist/chunk-BUXCGZ6X.js.map +1 -0
  61. package/dist/chunk-CHII2QHH.js +58 -0
  62. package/dist/chunk-CHII2QHH.js.map +1 -0
  63. package/dist/chunk-DMNOXRRW.js +147 -0
  64. package/dist/chunk-DMNOXRRW.js.map +1 -0
  65. package/dist/chunk-EFSOSSIC.js +130 -0
  66. package/dist/chunk-EFSOSSIC.js.map +1 -0
  67. package/dist/chunk-FZDSVMKY.js +363 -0
  68. package/dist/chunk-FZDSVMKY.js.map +1 -0
  69. package/dist/chunk-GJOFIJS3.js +246 -0
  70. package/dist/chunk-GJOFIJS3.js.map +1 -0
  71. package/dist/chunk-HL3ZSYES.js +23 -0
  72. package/dist/chunk-HL3ZSYES.js.map +1 -0
  73. package/dist/chunk-JVLUBAPB.js +129 -0
  74. package/dist/chunk-JVLUBAPB.js.map +1 -0
  75. package/dist/chunk-KDPYSOYZ.js +64 -0
  76. package/dist/chunk-KDPYSOYZ.js.map +1 -0
  77. package/dist/chunk-KSMDANKI.js +43 -0
  78. package/dist/chunk-KSMDANKI.js.map +1 -0
  79. package/dist/chunk-MEKCCOP5.js +46 -0
  80. package/dist/chunk-MEKCCOP5.js.map +1 -0
  81. package/dist/chunk-NOFXVRWL.js +451 -0
  82. package/dist/chunk-NOFXVRWL.js.map +1 -0
  83. package/dist/chunk-PC5MHNVA.js +171 -0
  84. package/dist/chunk-PC5MHNVA.js.map +1 -0
  85. package/dist/chunk-QKAQZ2GU.js +122 -0
  86. package/dist/chunk-QKAQZ2GU.js.map +1 -0
  87. package/dist/chunk-QZHSHSVV.js +26 -0
  88. package/dist/chunk-QZHSHSVV.js.map +1 -0
  89. package/dist/chunk-RBMK26XD.js +19 -0
  90. package/dist/chunk-RBMK26XD.js.map +1 -0
  91. package/dist/chunk-SFNJGF6M.js +262 -0
  92. package/dist/chunk-SFNJGF6M.js.map +1 -0
  93. package/dist/chunk-UJJNLGTM.js +112 -0
  94. package/dist/chunk-UJJNLGTM.js.map +1 -0
  95. package/dist/chunk-VGR4ZWJ3.js +418 -0
  96. package/dist/chunk-VGR4ZWJ3.js.map +1 -0
  97. package/dist/chunk-XG47P6D4.js +99 -0
  98. package/dist/chunk-XG47P6D4.js.map +1 -0
  99. package/dist/chunk-XZZAHNVM.js +21 -0
  100. package/dist/chunk-XZZAHNVM.js.map +1 -0
  101. package/dist/chunk-Y4TTYVNE.js +36 -0
  102. package/dist/chunk-Y4TTYVNE.js.map +1 -0
  103. package/dist/chunk-YDWIHW6Q.js +69 -0
  104. package/dist/chunk-YDWIHW6Q.js.map +1 -0
  105. package/dist/collapsible.js +6 -35
  106. package/dist/collapsible.js.map +1 -1
  107. package/dist/combobox.js +26 -694
  108. package/dist/combobox.js.map +1 -1
  109. package/dist/cta.d.ts +66 -0
  110. package/dist/cta.js +358 -0
  111. package/dist/cta.js.map +1 -0
  112. package/dist/currency-selector.d.ts +42 -0
  113. package/dist/currency-selector.js +192 -0
  114. package/dist/currency-selector.js.map +1 -0
  115. package/dist/date-picker.d.ts +18 -10
  116. package/dist/date-picker.js +105 -430
  117. package/dist/date-picker.js.map +1 -1
  118. package/dist/details-card.d.ts +19 -0
  119. package/dist/details-card.js +267 -0
  120. package/dist/details-card.js.map +1 -0
  121. package/dist/dialog.js +36 -146
  122. package/dist/dialog.js.map +1 -1
  123. package/dist/dropdown-menu.d.ts +1 -1
  124. package/dist/dropdown-menu.js +20 -358
  125. package/dist/dropdown-menu.js.map +1 -1
  126. package/dist/dropzone.js +13 -40
  127. package/dist/dropzone.js.map +1 -1
  128. package/dist/editorial-card.d.ts +29 -0
  129. package/dist/editorial-card.js +311 -0
  130. package/dist/editorial-card.js.map +1 -0
  131. package/dist/empty-state.js +5 -35
  132. package/dist/empty-state.js.map +1 -1
  133. package/dist/field.js +30 -135
  134. package/dist/field.js.map +1 -1
  135. package/dist/footer.d.ts +47 -0
  136. package/dist/footer.js +430 -0
  137. package/dist/footer.js.map +1 -0
  138. package/dist/funnel-chart.js +42 -415
  139. package/dist/funnel-chart.js.map +1 -1
  140. package/dist/gallery-indicator.d.ts +18 -0
  141. package/dist/gallery-indicator.js +12 -0
  142. package/dist/gallery-indicator.js.map +1 -0
  143. package/dist/heatmap-chart.d.ts +98 -0
  144. package/dist/heatmap-chart.js +248 -0
  145. package/dist/heatmap-chart.js.map +1 -0
  146. package/dist/infotip.d.ts +11 -0
  147. package/dist/infotip.js +66 -0
  148. package/dist/infotip.js.map +1 -0
  149. package/dist/input-group.d.ts +2 -1
  150. package/dist/input-group.js +15 -371
  151. package/dist/input-group.js.map +1 -1
  152. package/dist/input-size-context.js +5 -19
  153. package/dist/input-size-context.js.map +1 -1
  154. package/dist/input.js +6 -78
  155. package/dist/input.js.map +1 -1
  156. package/dist/item.js +5 -35
  157. package/dist/item.js.map +1 -1
  158. package/dist/kpi-card.js +12 -52
  159. package/dist/kpi-card.js.map +1 -1
  160. package/dist/label.js +5 -64
  161. package/dist/label.js.map +1 -1
  162. package/dist/line-chart.js +9 -166
  163. package/dist/line-chart.js.map +1 -1
  164. package/dist/logo.js +4 -141
  165. package/dist/logo.js.map +1 -1
  166. package/dist/map-indicator.d.ts +13 -0
  167. package/dist/map-indicator.js +109 -0
  168. package/dist/map-indicator.js.map +1 -0
  169. package/dist/match.d.ts +16 -0
  170. package/dist/match.js +113 -0
  171. package/dist/match.js.map +1 -0
  172. package/dist/media-gallery-hero.d.ts +60 -0
  173. package/dist/media-gallery-hero.js +362 -0
  174. package/dist/media-gallery-hero.js.map +1 -0
  175. package/dist/media-player.d.ts +60 -0
  176. package/dist/media-player.js +1394 -0
  177. package/dist/media-player.js.map +1 -0
  178. package/dist/number-input.js +30 -325
  179. package/dist/number-input.js.map +1 -1
  180. package/dist/page-header.js +4 -32
  181. package/dist/page-header.js.map +1 -1
  182. package/dist/pagination.d.ts +1 -0
  183. package/dist/pagination.js +27 -161
  184. package/dist/pagination.js.map +1 -1
  185. package/dist/password-input.d.ts +1 -0
  186. package/dist/password-input.js +21 -319
  187. package/dist/password-input.js.map +1 -1
  188. package/dist/phone-input.d.ts +2 -1
  189. package/dist/phone-input.js +148 -359
  190. package/dist/phone-input.js.map +1 -1
  191. package/dist/photo-gallery.d.ts +1 -1
  192. package/dist/photo-gallery.js +97 -393
  193. package/dist/photo-gallery.js.map +1 -1
  194. package/dist/pie-chart.js +17 -52
  195. package/dist/pie-chart.js.map +1 -1
  196. package/dist/popover.js +13 -158
  197. package/dist/popover.js.map +1 -1
  198. package/dist/price-tag.d.ts +35 -0
  199. package/dist/price-tag.js +178 -0
  200. package/dist/price-tag.js.map +1 -0
  201. package/dist/progress.d.ts +5 -2
  202. package/dist/progress.js +14 -303
  203. package/dist/progress.js.map +1 -1
  204. package/dist/property-listing-card.d.ts +32 -0
  205. package/dist/property-listing-card.js +235 -0
  206. package/dist/property-listing-card.js.map +1 -0
  207. package/dist/radar-chart.d.ts +110 -0
  208. package/dist/radar-chart.js +147 -0
  209. package/dist/radar-chart.js.map +1 -0
  210. package/dist/radio-group.js +15 -50
  211. package/dist/radio-group.js.map +1 -1
  212. package/dist/review-block.d.ts +20 -0
  213. package/dist/review-block.js +10 -0
  214. package/dist/review-block.js.map +1 -0
  215. package/dist/rich-text-editor.js +172 -433
  216. package/dist/rich-text-editor.js.map +1 -1
  217. package/dist/scatter-chart.d.ts +142 -0
  218. package/dist/scatter-chart.js +252 -0
  219. package/dist/scatter-chart.js.map +1 -0
  220. package/dist/search-input.d.ts +1 -0
  221. package/dist/search-input.js +22 -320
  222. package/dist/search-input.js.map +1 -1
  223. package/dist/select.js +15 -292
  224. package/dist/select.js.map +1 -1
  225. package/dist/separator.js +5 -68
  226. package/dist/separator.js.map +1 -1
  227. package/dist/sheet.js +14 -271
  228. package/dist/sheet.js.map +1 -1
  229. package/dist/sidebar.d.ts +1 -1
  230. package/dist/sidebar.js +89 -494
  231. package/dist/sidebar.js.map +1 -1
  232. package/dist/size-context.js +5 -17
  233. package/dist/size-context.js.map +1 -1
  234. package/dist/skeleton.js +4 -44
  235. package/dist/skeleton.js.map +1 -1
  236. package/dist/slider.d.ts +28 -0
  237. package/dist/slider.js +152 -0
  238. package/dist/slider.js.map +1 -0
  239. package/dist/sparkline.js +33 -341
  240. package/dist/sparkline.js.map +1 -1
  241. package/dist/stepper.js +5 -35
  242. package/dist/stepper.js.map +1 -1
  243. package/dist/styles.css +9593 -2
  244. package/dist/switch.js +13 -48
  245. package/dist/switch.js.map +1 -1
  246. package/dist/tab-list.js +35 -306
  247. package/dist/tab-list.js.map +1 -1
  248. package/dist/table.js +5 -32
  249. package/dist/table.js.map +1 -1
  250. package/dist/tabs.js +10 -150
  251. package/dist/tabs.js.map +1 -1
  252. package/dist/tag.d.ts +7 -6
  253. package/dist/tag.js +101 -97
  254. package/dist/tag.js.map +1 -1
  255. package/dist/testimonial-block.d.ts +34 -0
  256. package/dist/testimonial-block.js +377 -0
  257. package/dist/testimonial-block.js.map +1 -0
  258. package/dist/textarea.js +6 -73
  259. package/dist/textarea.js.map +1 -1
  260. package/dist/time-picker.js +119 -279
  261. package/dist/time-picker.js.map +1 -1
  262. package/dist/toast.js +27 -132
  263. package/dist/toast.js.map +1 -1
  264. package/dist/tooltip.d.ts +5 -5
  265. package/dist/tooltip.js +7 -90
  266. package/dist/tooltip.js.map +1 -1
  267. package/dist/tree-map.js +41 -414
  268. package/dist/tree-map.js.map +1 -1
  269. package/dist/waterfall-chart.d.ts +129 -0
  270. package/dist/waterfall-chart.js +577 -0
  271. package/dist/waterfall-chart.js.map +1 -0
  272. package/package.json +98 -28
  273. package/dist/base.css +0 -32
  274. package/dist/files/red-hat-display-latin-300-italic.woff +0 -0
  275. package/dist/files/red-hat-display-latin-300-italic.woff2 +0 -0
  276. package/dist/files/red-hat-display-latin-300-normal.woff +0 -0
  277. package/dist/files/red-hat-display-latin-300-normal.woff2 +0 -0
  278. package/dist/files/red-hat-display-latin-400-italic.woff +0 -0
  279. package/dist/files/red-hat-display-latin-400-italic.woff2 +0 -0
  280. package/dist/files/red-hat-display-latin-400-normal.woff +0 -0
  281. package/dist/files/red-hat-display-latin-400-normal.woff2 +0 -0
  282. package/dist/files/red-hat-display-latin-500-italic.woff +0 -0
  283. package/dist/files/red-hat-display-latin-500-italic.woff2 +0 -0
  284. package/dist/files/red-hat-display-latin-500-normal.woff +0 -0
  285. package/dist/files/red-hat-display-latin-500-normal.woff2 +0 -0
  286. package/dist/files/red-hat-display-latin-600-italic.woff +0 -0
  287. package/dist/files/red-hat-display-latin-600-italic.woff2 +0 -0
  288. package/dist/files/red-hat-display-latin-600-normal.woff +0 -0
  289. package/dist/files/red-hat-display-latin-600-normal.woff2 +0 -0
  290. package/dist/files/red-hat-display-latin-700-italic.woff +0 -0
  291. package/dist/files/red-hat-display-latin-700-italic.woff2 +0 -0
  292. package/dist/files/red-hat-display-latin-700-normal.woff +0 -0
  293. package/dist/files/red-hat-display-latin-700-normal.woff2 +0 -0
  294. package/dist/files/red-hat-display-latin-800-italic.woff +0 -0
  295. package/dist/files/red-hat-display-latin-800-italic.woff2 +0 -0
  296. package/dist/files/red-hat-display-latin-800-normal.woff +0 -0
  297. package/dist/files/red-hat-display-latin-800-normal.woff2 +0 -0
  298. package/dist/files/red-hat-display-latin-900-italic.woff +0 -0
  299. package/dist/files/red-hat-display-latin-900-italic.woff2 +0 -0
  300. package/dist/files/red-hat-display-latin-900-normal.woff +0 -0
  301. package/dist/files/red-hat-display-latin-900-normal.woff2 +0 -0
  302. package/dist/files/red-hat-display-latin-ext-300-italic.woff +0 -0
  303. package/dist/files/red-hat-display-latin-ext-300-italic.woff2 +0 -0
  304. package/dist/files/red-hat-display-latin-ext-300-normal.woff +0 -0
  305. package/dist/files/red-hat-display-latin-ext-300-normal.woff2 +0 -0
  306. package/dist/files/red-hat-display-latin-ext-400-italic.woff +0 -0
  307. package/dist/files/red-hat-display-latin-ext-400-italic.woff2 +0 -0
  308. package/dist/files/red-hat-display-latin-ext-400-normal.woff +0 -0
  309. package/dist/files/red-hat-display-latin-ext-400-normal.woff2 +0 -0
  310. package/dist/files/red-hat-display-latin-ext-500-italic.woff +0 -0
  311. package/dist/files/red-hat-display-latin-ext-500-italic.woff2 +0 -0
  312. package/dist/files/red-hat-display-latin-ext-500-normal.woff +0 -0
  313. package/dist/files/red-hat-display-latin-ext-500-normal.woff2 +0 -0
  314. package/dist/files/red-hat-display-latin-ext-600-italic.woff +0 -0
  315. package/dist/files/red-hat-display-latin-ext-600-italic.woff2 +0 -0
  316. package/dist/files/red-hat-display-latin-ext-600-normal.woff +0 -0
  317. package/dist/files/red-hat-display-latin-ext-600-normal.woff2 +0 -0
  318. package/dist/files/red-hat-display-latin-ext-700-italic.woff +0 -0
  319. package/dist/files/red-hat-display-latin-ext-700-italic.woff2 +0 -0
  320. package/dist/files/red-hat-display-latin-ext-700-normal.woff +0 -0
  321. package/dist/files/red-hat-display-latin-ext-700-normal.woff2 +0 -0
  322. package/dist/files/red-hat-display-latin-ext-800-italic.woff +0 -0
  323. package/dist/files/red-hat-display-latin-ext-800-italic.woff2 +0 -0
  324. package/dist/files/red-hat-display-latin-ext-800-normal.woff +0 -0
  325. package/dist/files/red-hat-display-latin-ext-800-normal.woff2 +0 -0
  326. package/dist/files/red-hat-display-latin-ext-900-italic.woff +0 -0
  327. package/dist/files/red-hat-display-latin-ext-900-italic.woff2 +0 -0
  328. package/dist/files/red-hat-display-latin-ext-900-normal.woff +0 -0
  329. package/dist/files/red-hat-display-latin-ext-900-normal.woff2 +0 -0
  330. package/dist/index.d.ts +0 -87
  331. package/dist/index.js +0 -10448
  332. package/dist/index.js.map +0 -1
  333. package/dist/red-hat-display.css +0 -2
  334. package/dist/theme/giddaa.css +0 -2
@@ -1,39 +1,50 @@
1
1
  import * as React from 'react';
2
+ import { BarChart as BarChart$1, CartesianGrid, Bar, XAxis, YAxis } from 'recharts';
3
+ import { ChartConfig } from './chart.js';
2
4
  import { ComponentSize } from './size-context.js';
5
+ import 'class-variance-authority/types';
6
+ import 'class-variance-authority';
3
7
 
4
8
  /**
5
- * Bar charts are composed from recharts plot primitives directly — recharts
6
- * identifies `Bar`, `XAxis`, `YAxis`, `CartesianGrid`, and `LabelList` by
7
- * component identity, so they cannot be wrapped without breaking the chart.
8
- * This module supplies the giddaa-specific defaults that would otherwise be
9
- * copy-pasted into every bar chart: per-size layout numbers and a value-label
10
- * renderer. Pair them with the shared frame and overlays from `./chart`.
9
+ * Bar charts are composable wrappers over the recharts cartesian primitives.
10
+ * recharts 3 registers graphical items through context when they render, so the
11
+ * primitives CAN be wrapped in our own components. Each wrapper bakes in the
12
+ * giddaa defaults (tokens, size-scaled type, mark specs) and forwards every
13
+ * recharts prop, so anything can be overridden in place or replaced with the
14
+ * raw recharts element.
15
+ *
16
+ * Anatomy: `BarChart` is the plot root (frame + responsive box + recharts
17
+ * chart); compose the grid, axes, series, and the shared overlays from
18
+ * `./chart` as children:
11
19
  *
12
20
  * @example
13
- * const chart = useBarChartLayout();
14
21
  * <ChartCard size="md">
15
22
  * <ChartHeader>
16
23
  * <ChartTitle>Revenue Overview</ChartTitle>
17
- * <ChartDescription>Monthly revenue · JanJul</ChartDescription>
24
+ * <ChartDescription>Monthly revenue - Jan-Jul</ChartDescription>
18
25
  * </ChartHeader>
19
- * <ChartContainer config={config} {...chart.container}>
20
- * <BarChart data={data} {...chart.chart}>
21
- * <CartesianGrid vertical={false} stroke="var(--color-line-subtle)" />
22
- * <XAxis dataKey="month" {...chart.xAxis} />
23
- * <YAxis {...chart.yAxis} />
24
- * <ChartLegend verticalAlign="top" content={<ChartLegendContent />} />
25
- * <ChartTooltip content={<ChartTooltipContent />} />
26
- * <Bar dataKey="revenue" fill="var(--color-revenue)" {...chart.bar}>
27
- * <LabelList dataKey="revenue" content={<BarValueLabel />} />
28
- * </Bar>
29
- * </BarChart>
30
- * </ChartContainer>
26
+ * <BarChart config={config} data={data}>
27
+ * <BarChartGrid />
28
+ * <BarChartXAxis dataKey="month" />
29
+ * <BarChartYAxis domain={[0, 120]} />
30
+ * <ChartTooltip content={<ChartTooltipContent />} />
31
+ * <BarChartSeries dataKey="revenue" name="Revenue">
32
+ * <LabelList dataKey="revenue" content={<BarValueLabel />} />
33
+ * </BarChartSeries>
34
+ * </BarChart>
31
35
  * </ChartCard>
32
36
  */
37
+ /**
38
+ * Categorical series palette - the theme-aware `chart-1`...`chart-3` tokens.
39
+ * Assign colours in this fixed order, never cycled: a fourth series folds into
40
+ * "Other" or becomes a second chart.
41
+ */
42
+ declare const BAR_CHART_PALETTE: readonly ["var(--color-chart-1)", "var(--color-chart-2)", "var(--color-chart-3)"];
43
+ type BarChartOrientation = "vertical" | "horizontal";
33
44
  type BarChartLayout = {
34
45
  /** Plot height in px. Width stays fluid via the ResponsiveContainer. */
35
46
  height: number;
36
- /** Outer margin top leaves room for value labels above the tallest bar. */
47
+ /** Outer margin - top leaves room for value labels above the tallest bar. */
37
48
  margin: {
38
49
  top: number;
39
50
  right: number;
@@ -58,72 +69,85 @@ type BarChartLayout = {
58
69
  tickMargin: number;
59
70
  };
60
71
  declare const BAR_CHART_LAYOUT: Record<ComponentSize, BarChartLayout>;
72
+ type BarChartProps = Omit<React.ComponentProps<typeof BarChart$1>, "width" | "height"> & {
73
+ /** Series labels/icons for the shared tooltip and legend (see `ChartConfig`). */
74
+ config?: ChartConfig;
75
+ /** Plot scale; inherited from the nearest `SizeProvider` when omitted. */
76
+ size?: ComponentSize;
77
+ /** Applied to the responsive plot box, e.g. to override its height. */
78
+ className?: string;
79
+ /** Visual bar direction. `horizontal` maps to recharts `layout="vertical"`. */
80
+ orientation?: BarChartOrientation;
81
+ };
61
82
  /**
62
- * Resolve the bar-chart layout for an explicit or inherited component size. The
63
- * returned object groups the giddaa defaults by the recharts component they
64
- * belong to spread each onto its element, then pass the data-specific props
65
- * (`config`, `data`, `dataKey`, `fill`, …) directly afterwards to add or
66
- * override anything:
67
- *
68
- * const chart = useBarChartLayout(size);
69
- * <ChartContainer config={config} {...chart.container}>
70
- * <BarChart data={data} {...chart.chart}>
71
- * <XAxis dataKey="month" {...chart.xAxis} />
72
- * <YAxis {...chart.yAxis} />
73
- * <Bar dataKey="revenue" fill="var(--color-revenue)" {...chart.bar} />
83
+ * Plot root - wraps the shared `ChartContainer` (tooltip/legend theming,
84
+ * responsive box) around the recharts `BarChart` with size-scaled height,
85
+ * margin, and bar gaps. `size` also flows to the child primitives through
86
+ * `SizeProvider`. Extra props reach the recharts chart (`data`, `syncId`,
87
+ * `layout`, ...); passing `layout` directly overrides `orientation`.
74
88
  */
75
- declare function useBarChartLayout(size?: ComponentSize): {
76
- container: {
77
- className: string;
78
- style: {
79
- height: number;
80
- };
81
- };
82
- chart: {
83
- accessibilityLayer: boolean;
84
- margin: {
85
- top: number;
86
- right: number;
87
- bottom: number;
88
- left: number;
89
- };
90
- barCategoryGap: string;
91
- barGap: number;
92
- };
93
- xAxis: {
94
- readonly tickLine: false;
95
- readonly axisLine: false;
96
- readonly tickMargin: number;
97
- readonly tick: {
98
- fontSize: number;
99
- };
100
- };
101
- yAxis: {
102
- readonly tickLine: false;
103
- readonly axisLine: false;
104
- readonly width: number;
105
- readonly tick: {
106
- fontSize: number;
107
- };
108
- };
109
- bar: {
110
- radius: [number, number, number, number];
111
- maxBarSize: number;
112
- };
89
+ declare function BarChart({ config, size, className, children, orientation, layout, ...props }: BarChartProps): React.JSX.Element;
90
+ type BarChartGridProps = React.ComponentProps<typeof CartesianGrid>;
91
+ /**
92
+ * Value reference lines - recharts `CartesianGrid` with vertical lines hidden
93
+ * and the visible grid painted with the `line` token (`line-subtle` matches the
94
+ * chart card surface in both themes, so it would vanish). For horizontal bar
95
+ * charts, pass `horizontal={false} vertical`.
96
+ */
97
+ declare function BarChartGrid(props: BarChartGridProps): React.JSX.Element;
98
+ type BarChartXAxisProps = React.ComponentProps<typeof XAxis> & {
99
+ /** Explicit axis scale; otherwise inherited from the chart's `size`. */
100
+ size?: ComponentSize;
101
+ };
102
+ /**
103
+ * Category/value axis - recharts `XAxis` with no axis/tick lines,
104
+ * size-scaled tick margin, and caption-placeholder tick ink. Passing your own
105
+ * `tick` replaces the default styling entirely.
106
+ */
107
+ declare function BarChartXAxis({ size, tick, ...props }: BarChartXAxisProps): React.JSX.Element;
108
+ type BarChartYAxisProps = React.ComponentProps<typeof YAxis> & {
109
+ /** Explicit axis scale; otherwise inherited from the chart's `size`. */
110
+ size?: ComponentSize;
113
111
  };
112
+ /**
113
+ * Value/category axis - recharts `YAxis` with no axis/tick lines,
114
+ * size-scaled tick type, and reserved width for value labels. Override `width`
115
+ * for long horizontal-category labels.
116
+ */
117
+ declare function BarChartYAxis({ size, tick, ...props }: BarChartYAxisProps): React.JSX.Element;
118
+ type BarChartSeriesProps = React.ComponentProps<typeof Bar> & {
119
+ /** Series colour for the bar. Defaults to the first categorical chart token. */
120
+ color?: string;
121
+ /** Explicit mark scale; otherwise inherited from the chart's `size`. */
122
+ size?: ComponentSize;
123
+ /** Override visual direction for radius when the root orientation is absent. */
124
+ orientation?: BarChartOrientation;
125
+ };
126
+ /**
127
+ * One data series - recharts `Bar` with the giddaa mark spec: a theme-aware
128
+ * series colour, size-scaled max thickness, and a small radius only on the
129
+ * leading edge (top for vertical bars, right for horizontal bars). `color`
130
+ * drives `fill`; `fill`, `radius`, and `maxBarSize` still win when passed
131
+ * directly.
132
+ */
133
+ declare function BarChartSeries({ color, size, orientation, ...props }: BarChartSeriesProps): React.JSX.Element;
114
134
  /**
115
135
  * Renderer for recharts `<LabelList content={<BarValueLabel />} />`. recharts
116
136
  * injects the bar geometry (`x`, `y`, `width`, `height`, `value`); the rest are
117
137
  * caller props. For a vertical bar the label sits above the bar; for a
118
- * horizontal bar (`orientation="horizontal"`) it sits to the right of the bar.
138
+ * horizontal bar it sits to the right of the bar. When used inside `BarChart`,
139
+ * the root `orientation` is inherited unless this component receives an
140
+ * explicit `orientation`.
119
141
  */
120
142
  type BarValueLabelProps = {
121
- /** Bar layout direction drives where the label is placed. */
122
- orientation?: "vertical" | "horizontal";
143
+ /** Bar visual direction - drives where the label is placed. */
144
+ orientation?: BarChartOrientation;
123
145
  /** Override the on-bar font size (defaults to the size-scaled value). */
124
146
  fontSize?: number;
125
- /** Format the raw value before display, e.g. `(v) => `₦${v}``. */
147
+ /** Format the raw value before display, e.g. `(v) => String(v)`. */
126
148
  formatter?: (value: React.ReactNode) => React.ReactNode;
149
+ /** Explicit label scale; otherwise inherited from the chart's `size`. */
150
+ size?: ComponentSize;
127
151
  className?: string;
128
152
  x?: string | number;
129
153
  y?: string | number;
@@ -131,6 +155,6 @@ type BarValueLabelProps = {
131
155
  height?: string | number;
132
156
  value?: React.ReactNode;
133
157
  };
134
- declare function BarValueLabel({ orientation, fontSize, formatter, className, x, y, width, height, value, }: BarValueLabelProps): React.JSX.Element | null;
158
+ declare function BarValueLabel({ orientation, fontSize, formatter, size, className, x, y, width, height, value, }: BarValueLabelProps): React.JSX.Element | null;
135
159
 
136
- export { BAR_CHART_LAYOUT, type BarChartLayout, BarValueLabel, type BarValueLabelProps, useBarChartLayout };
160
+ export { BAR_CHART_LAYOUT, BAR_CHART_PALETTE, BarChart, BarChartGrid, type BarChartGridProps, type BarChartLayout, type BarChartOrientation, type BarChartProps, BarChartSeries, type BarChartSeriesProps, BarChartXAxis, type BarChartXAxisProps, BarChartYAxis, type BarChartYAxisProps, BarValueLabel, type BarValueLabelProps };
package/dist/bar-chart.js CHANGED
@@ -1,203 +1,32 @@
1
- // src/lib/cn.ts
2
- import { clsx } from "clsx";
3
- import { extendTailwindMerge } from "tailwind-merge";
4
- var twMerge = extendTailwindMerge({
5
- extend: {
6
- classGroups: {
7
- "font-size": [
8
- {
9
- text: [
10
- "gdt-display",
11
- "gdt-h1",
12
- "gdt-h2",
13
- "gdt-h3",
14
- "gdt-h4",
15
- "gdt-h5",
16
- "gdt-xl",
17
- "gdt-lg",
18
- "gdt-md",
19
- "gdt-sm",
20
- "gdt-xs",
21
- "gdt-subtext",
22
- "gdt-capitalized"
23
- ]
24
- }
25
- ]
26
- }
27
- }
28
- });
29
- function cn(...inputs) {
30
- return twMerge(clsx(inputs));
31
- }
1
+ "use client";
2
+ import {
3
+ ChartContainer,
4
+ cartesianAxisProps
5
+ } from "./chunk-NOFXVRWL.js";
6
+ import {
7
+ SizeProvider,
8
+ useComponentSize
9
+ } from "./chunk-HL3ZSYES.js";
10
+ import {
11
+ cn
12
+ } from "./chunk-Y4TTYVNE.js";
32
13
 
33
- // src/components/ui/chart.tsx
34
- import { cva } from "class-variance-authority";
14
+ // src/bar-chart.tsx
35
15
  import * as React from "react";
36
- import * as RechartsPrimitive from "recharts";
37
-
38
- // src/components/ui/size-context.tsx
39
- import { createContext, useContext } from "react";
40
- import { Fragment, jsx } from "react/jsx-runtime";
41
- var SizeContext = createContext(void 0);
42
- function useComponentSize(size, fallback = "md") {
43
- const inheritedSize = useContext(SizeContext);
44
- return size ?? inheritedSize ?? fallback;
45
- }
46
-
47
- // src/components/ui/chart.tsx
48
- import { Fragment as Fragment2, jsx as jsx2, jsxs } from "react/jsx-runtime";
49
- var ChartContext = React.createContext(null);
50
- var chartCardVariants = cva(
51
- "flex w-full min-w-0 flex-col rounded-2xl border border-line-subtle bg-surface-raised text-fg-primary shadow-1",
52
- {
53
- variants: {
54
- size: {
55
- sm: "gap-3 p-4",
56
- md: "gap-4 p-5",
57
- lg: "gap-5 p-6"
58
- }
59
- },
60
- defaultVariants: { size: "md" }
61
- }
62
- );
63
- var chartTitleVariants = cva("min-w-0 font-bold text-fg-primary", {
64
- variants: {
65
- size: {
66
- sm: "text-gdt-md",
67
- md: "text-gdt-lg",
68
- lg: "text-gdt-h5"
69
- }
70
- },
71
- defaultVariants: { size: "md" }
72
- });
73
- var chartDescriptionVariants = cva("min-w-0 font-normal text-fg-secondary", {
74
- variants: {
75
- size: {
76
- sm: "text-gdt-xs",
77
- md: "text-gdt-sm",
78
- lg: "text-gdt-sm"
79
- }
80
- },
81
- defaultVariants: { size: "md" }
82
- });
83
- var chartTooltipVariants = cva(
84
- "flex flex-col bg-surface-overlay border border-line-subtle shadow-2",
85
- {
86
- variants: {
87
- size: {
88
- xs: "gap-0.5 rounded-md p-2",
89
- sm: "gap-0.5 rounded-md p-2.5",
90
- md: "gap-1 rounded-lg p-3",
91
- lg: "gap-1 rounded-xl p-3.5"
92
- }
93
- },
94
- defaultVariants: {
95
- size: "md"
96
- }
97
- }
98
- );
99
- var chartTooltipDotVariants = cva("shrink-0 rounded-full", {
100
- variants: {
101
- size: {
102
- xs: "size-1.5",
103
- sm: "size-2",
104
- md: "size-2.5",
105
- lg: "size-2.5"
106
- }
107
- },
108
- defaultVariants: {
109
- size: "md"
110
- }
111
- });
112
- var chartTooltipLabelVariants = cva("font-medium text-fg-secondary", {
113
- variants: {
114
- size: {
115
- xs: "text-gdt-xs",
116
- sm: "text-gdt-xs",
117
- md: "text-gdt-sm",
118
- lg: "text-gdt-sm"
119
- }
120
- },
121
- defaultVariants: { size: "md" }
122
- });
123
- var chartTooltipValueVariants = cva(
124
- "font-extrabold text-fg-primary tabular-nums",
125
- {
126
- variants: {
127
- size: {
128
- xs: "text-gdt-sm",
129
- sm: "text-gdt-md",
130
- md: "text-gdt-lg",
131
- lg: "text-gdt-xl"
132
- }
133
- },
134
- defaultVariants: { size: "md" }
135
- }
136
- );
137
- var chartLegendItemVariants = cva(
138
- "group/legend-item flex items-center rounded-md leading-none text-fg-primary transition-colors [&>svg]:shrink-0",
139
- {
140
- variants: {
141
- size: {
142
- sm: "gap-1.5 px-2 py-1 text-gdt-xs [&>svg]:size-3",
143
- md: "gap-2 px-2.5 py-1.5 text-gdt-sm [&>svg]:size-3.5"
144
- },
145
- interactive: {
146
- true: "cursor-pointer outline-none hover:bg-surface-raised focus-visible:bg-surface-raised",
147
- false: ""
148
- },
149
- inactive: {
150
- true: "text-fg-caption-placeholder line-through",
151
- false: ""
152
- }
153
- },
154
- defaultVariants: {
155
- size: "md",
156
- interactive: false,
157
- inactive: false
158
- }
159
- }
160
- );
161
- var chartLegendMarkerSizeVariants = cva("shrink-0", {
162
- variants: {
163
- marker: {
164
- dot: "rounded-full",
165
- square: "rounded-[2px]",
166
- line: "rounded-full"
167
- },
168
- size: {
169
- sm: "",
170
- md: ""
171
- }
172
- },
173
- compoundVariants: [
174
- { marker: ["dot", "square"], size: "sm", className: "size-2" },
175
- { marker: ["dot", "square"], size: "md", className: "size-2.5" },
176
- { marker: "line", size: "sm", className: "h-[3px] w-3" },
177
- { marker: "line", size: "md", className: "h-[3px] w-3.5" }
178
- ],
179
- defaultVariants: { marker: "dot", size: "md" }
180
- });
181
- function cartesianAxisProps(layout) {
182
- const tick = { fontSize: layout.tickFontSize };
183
- return {
184
- xAxis: {
185
- tickLine: false,
186
- axisLine: false,
187
- tickMargin: layout.tickMargin,
188
- tick
189
- },
190
- yAxis: {
191
- tickLine: false,
192
- axisLine: false,
193
- width: layout.yAxisWidth,
194
- tick
195
- }
196
- };
197
- }
198
-
199
- // src/components/ui/bar-chart.tsx
200
- import { jsx as jsx3 } from "react/jsx-runtime";
16
+ import {
17
+ Bar,
18
+ BarChart as BarChartPrimitive,
19
+ CartesianGrid,
20
+ XAxis,
21
+ YAxis
22
+ } from "recharts";
23
+ import { jsx } from "react/jsx-runtime";
24
+ var BAR_CHART_PALETTE = [
25
+ "var(--color-chart-1)",
26
+ "var(--color-chart-2)",
27
+ "var(--color-chart-3)"
28
+ ];
29
+ var DEFAULT_SERIES_COLOR = BAR_CHART_PALETTE[0];
201
30
  var BAR_CHART_LAYOUT = {
202
31
  sm: {
203
32
  height: 180,
@@ -236,32 +65,116 @@ var BAR_CHART_LAYOUT = {
236
65
  tickMargin: 10
237
66
  }
238
67
  };
239
- function useBarChartLayout(size) {
240
- const layout = BAR_CHART_LAYOUT[useComponentSize(size)];
68
+ var BarChartContext = React.createContext(null);
69
+ function useBarChartOrientation(orientation) {
70
+ const context = React.useContext(BarChartContext);
71
+ return orientation ?? context?.orientation ?? "vertical";
72
+ }
73
+ function barChartAxisProps(layout) {
241
74
  const axes = cartesianAxisProps(layout);
75
+ const tick = {
76
+ ...axes.xAxis.tick,
77
+ fill: "var(--color-fg-caption-placeholder)"
78
+ };
242
79
  return {
243
- container: {
244
- className: "aspect-auto w-full",
245
- style: { height: layout.height }
246
- },
247
- chart: {
248
- accessibilityLayer: true,
249
- margin: layout.margin,
250
- barCategoryGap: layout.barCategoryGap,
251
- barGap: layout.barGap
80
+ xAxis: {
81
+ ...axes.xAxis,
82
+ tick
252
83
  },
253
- xAxis: axes.xAxis,
254
- yAxis: axes.yAxis,
255
- bar: {
256
- radius: [layout.barRadius, layout.barRadius, 0, 0],
257
- maxBarSize: layout.maxBarSize
84
+ yAxis: {
85
+ ...axes.yAxis,
86
+ tick
258
87
  }
259
88
  };
260
89
  }
261
- function BarValueLabel({
90
+ function BarChart({
91
+ config = {},
92
+ size,
93
+ className,
94
+ children,
262
95
  orientation = "vertical",
96
+ layout,
97
+ ...props
98
+ }) {
99
+ const resolvedSize = useComponentSize(size);
100
+ const chartLayout = BAR_CHART_LAYOUT[resolvedSize];
101
+ const rechartsLayout = layout ?? (orientation === "horizontal" ? "vertical" : "horizontal");
102
+ return /* @__PURE__ */ jsx(SizeProvider, { size: resolvedSize, children: /* @__PURE__ */ jsx(BarChartContext.Provider, { value: { orientation }, children: /* @__PURE__ */ jsx(
103
+ ChartContainer,
104
+ {
105
+ config,
106
+ className: cn("aspect-auto w-full", className),
107
+ style: { height: chartLayout.height },
108
+ children: /* @__PURE__ */ jsx(
109
+ BarChartPrimitive,
110
+ {
111
+ accessibilityLayer: true,
112
+ margin: chartLayout.margin,
113
+ barCategoryGap: chartLayout.barCategoryGap,
114
+ barGap: chartLayout.barGap,
115
+ layout: rechartsLayout,
116
+ ...props,
117
+ children
118
+ }
119
+ )
120
+ }
121
+ ) }) });
122
+ }
123
+ function BarChartGrid(props) {
124
+ return /* @__PURE__ */ jsx(CartesianGrid, { vertical: false, stroke: "var(--color-line)", ...props });
125
+ }
126
+ function BarChartXAxis({ size, tick, ...props }) {
127
+ const layout = BAR_CHART_LAYOUT[useComponentSize(size)];
128
+ const axes = barChartAxisProps(layout);
129
+ return /* @__PURE__ */ jsx(
130
+ XAxis,
131
+ {
132
+ tickLine: axes.xAxis.tickLine,
133
+ axisLine: axes.xAxis.axisLine,
134
+ tickMargin: axes.xAxis.tickMargin,
135
+ tick: tick ?? axes.xAxis.tick,
136
+ ...props
137
+ }
138
+ );
139
+ }
140
+ function BarChartYAxis({ size, tick, ...props }) {
141
+ const layout = BAR_CHART_LAYOUT[useComponentSize(size)];
142
+ const axes = barChartAxisProps(layout);
143
+ return /* @__PURE__ */ jsx(
144
+ YAxis,
145
+ {
146
+ tickLine: axes.yAxis.tickLine,
147
+ axisLine: axes.yAxis.axisLine,
148
+ width: axes.yAxis.width,
149
+ tick: tick ?? axes.yAxis.tick,
150
+ ...props
151
+ }
152
+ );
153
+ }
154
+ function BarChartSeries({
155
+ color = DEFAULT_SERIES_COLOR,
156
+ size,
157
+ orientation,
158
+ ...props
159
+ }) {
160
+ const layout = BAR_CHART_LAYOUT[useComponentSize(size)];
161
+ const resolvedOrientation = useBarChartOrientation(orientation);
162
+ const radius = resolvedOrientation === "horizontal" ? [0, layout.barRadius, layout.barRadius, 0] : [layout.barRadius, layout.barRadius, 0, 0];
163
+ return /* @__PURE__ */ jsx(
164
+ Bar,
165
+ {
166
+ fill: color,
167
+ radius,
168
+ maxBarSize: layout.maxBarSize,
169
+ ...props
170
+ }
171
+ );
172
+ }
173
+ function BarValueLabel({
174
+ orientation,
263
175
  fontSize,
264
176
  formatter,
177
+ size,
265
178
  className,
266
179
  x,
267
180
  y,
@@ -269,7 +182,8 @@ function BarValueLabel({
269
182
  height,
270
183
  value
271
184
  }) {
272
- const valueFontSize = BAR_CHART_LAYOUT[useComponentSize()].valueFontSize;
185
+ const resolvedOrientation = useBarChartOrientation(orientation);
186
+ const valueFontSize = BAR_CHART_LAYOUT[useComponentSize(size)].valueFontSize;
273
187
  if (value == null || x == null || y == null || width == null) {
274
188
  return null;
275
189
  }
@@ -278,10 +192,13 @@ function BarValueLabel({
278
192
  const numWidth = Number(width);
279
193
  const numHeight = Number(height ?? 0);
280
194
  const gap = 6;
281
- const isHorizontal = orientation === "horizontal";
195
+ if (!Number.isFinite(numX) || !Number.isFinite(numY) || !Number.isFinite(numWidth) || !Number.isFinite(numHeight)) {
196
+ return null;
197
+ }
198
+ const isHorizontal = resolvedOrientation === "horizontal";
282
199
  const labelX = isHorizontal ? numX + numWidth + gap : numX + numWidth / 2;
283
200
  const labelY = isHorizontal ? numY + numHeight / 2 : numY - gap;
284
- return /* @__PURE__ */ jsx3(
201
+ return /* @__PURE__ */ jsx(
285
202
  "text",
286
203
  {
287
204
  x: labelX,
@@ -296,7 +213,12 @@ function BarValueLabel({
296
213
  }
297
214
  export {
298
215
  BAR_CHART_LAYOUT,
299
- BarValueLabel,
300
- useBarChartLayout
216
+ BAR_CHART_PALETTE,
217
+ BarChart,
218
+ BarChartGrid,
219
+ BarChartSeries,
220
+ BarChartXAxis,
221
+ BarChartYAxis,
222
+ BarValueLabel
301
223
  };
302
224
  //# sourceMappingURL=bar-chart.js.map