@hashicorp/mds-react 0.9.3 → 0.9.5

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 (371) hide show
  1. package/components/accordion/index.js +9 -0
  2. package/components/accordion/index.js.map +1 -0
  3. package/components/accordion/item/button.js +44 -0
  4. package/components/accordion/item/button.js.map +1 -0
  5. package/components/accordion/item/index.js +59 -0
  6. package/components/accordion/item/index.js.map +1 -0
  7. package/components/accordion/style.module.scss.js +24 -0
  8. package/components/accordion/style.module.scss.js.map +1 -0
  9. package/components/alert/alert.module.scss.js +29 -0
  10. package/components/alert/alert.module.scss.js.map +1 -0
  11. package/components/alert/icon.js +34 -0
  12. package/components/alert/icon.js.map +1 -0
  13. package/components/alert/index.js +97 -0
  14. package/components/alert/index.js.map +1 -0
  15. package/components/badge/index.js +50 -0
  16. package/components/badge/index.js.map +1 -0
  17. package/components/badge/style.module.scss +8 -6
  18. package/components/badge/style.module.scss.js +22 -0
  19. package/components/badge/style.module.scss.js.map +1 -0
  20. package/components/badge-count/index.js +29 -0
  21. package/components/badge-count/index.js.map +1 -0
  22. package/components/badge-count/style.module.scss +7 -6
  23. package/components/badge-count/style.module.scss.js +15 -0
  24. package/components/badge-count/style.module.scss.js.map +1 -0
  25. package/components/breadcrumbs/index.js +38 -0
  26. package/components/breadcrumbs/index.js.map +1 -0
  27. package/components/breadcrumbs/item/index.js +32 -0
  28. package/components/breadcrumbs/item/index.js.map +1 -0
  29. package/components/breadcrumbs/style.module.scss.js +27 -0
  30. package/components/breadcrumbs/style.module.scss.js.map +1 -0
  31. package/components/breadcrumbs/truncation-button/index.js +25 -0
  32. package/components/breadcrumbs/truncation-button/index.js.map +1 -0
  33. package/components/button/button-primitive.d.ts +5 -0
  34. package/components/button/button-primitive.js +59 -0
  35. package/components/button/button-primitive.js.map +1 -0
  36. package/components/button/index.d.ts +4 -5
  37. package/components/button/index.js +69 -0
  38. package/components/button/index.js.map +1 -0
  39. package/components/button/styles.module.scss.js +32 -0
  40. package/components/button/styles.module.scss.js.map +1 -0
  41. package/components/card/card-thumbnail/card-thumbnail.module.css.js +8 -0
  42. package/components/card/card-thumbnail/card-thumbnail.module.css.js.map +1 -0
  43. package/components/card/card-thumbnail/index.js +23 -0
  44. package/components/card/card-thumbnail/index.js.map +1 -0
  45. package/components/card/index.d.ts +2 -1
  46. package/components/card/index.js +160 -0
  47. package/components/card/index.js.map +1 -0
  48. package/components/card/styles.module.css.js +29 -0
  49. package/components/card/styles.module.css.js.map +1 -0
  50. package/components/card/types.d.ts +1 -0
  51. package/components/code-block/code-block.module.scss.js +34 -0
  52. package/components/code-block/code-block.module.scss.js.map +1 -0
  53. package/components/code-block/code-lines/index.js +59 -0
  54. package/components/code-block/code-lines/index.js.map +1 -0
  55. package/components/code-block/code-lines/utils/split-html-into-lines.js +19 -0
  56. package/components/code-block/code-lines/utils/split-html-into-lines.js.map +1 -0
  57. package/components/code-block/code-lines/utils/split-jsx-into-lines.js +31 -0
  58. package/components/code-block/code-lines/utils/split-jsx-into-lines.js.map +1 -0
  59. package/components/code-block/hidden-copy-content/index.js +13 -0
  60. package/components/code-block/hidden-copy-content/index.js.map +1 -0
  61. package/components/code-block/index.js +88 -0
  62. package/components/code-block/index.js.map +1 -0
  63. package/components/code-block/utils/parse-highlighted-lines.js +39 -0
  64. package/components/code-block/utils/parse-highlighted-lines.js.map +1 -0
  65. package/components/code-block/utils/process-snippet.js +20 -0
  66. package/components/code-block/utils/process-snippet.js.map +1 -0
  67. package/components/code-block/utils/shellwords.js +33 -0
  68. package/components/code-block/utils/shellwords.js.map +1 -0
  69. package/components/combo-box-primitive/index.js +302 -0
  70. package/components/combo-box-primitive/index.js.map +1 -0
  71. package/components/dialog-primitive/dialog.module.scss.js +12 -0
  72. package/components/dialog-primitive/dialog.module.scss.js.map +1 -0
  73. package/components/dialog-primitive/index.js +15 -0
  74. package/components/dialog-primitive/index.js.map +1 -0
  75. package/components/disclosure-primitive/index.js +57 -0
  76. package/components/disclosure-primitive/index.js.map +1 -0
  77. package/components/disclosure-primitive/styles.module.css.js +7 -0
  78. package/components/disclosure-primitive/styles.module.css.js.map +1 -0
  79. package/components/disclosure-primitive/use-disclosure-primitive.js +17 -0
  80. package/components/disclosure-primitive/use-disclosure-primitive.js.map +1 -0
  81. package/components/dismiss-button/index.js +22 -0
  82. package/components/dismiss-button/index.js.map +1 -0
  83. package/components/dismiss-button/styles.module.scss.js +7 -0
  84. package/components/dismiss-button/styles.module.scss.js.map +1 -0
  85. package/components/dropdown/index.js +79 -0
  86. package/components/dropdown/index.js.map +1 -0
  87. package/components/dropdown/list-item/custom.js +9 -0
  88. package/components/dropdown/list-item/custom.js.map +1 -0
  89. package/components/dropdown/list-item/index.js +14 -0
  90. package/components/dropdown/list-item/index.js.map +1 -0
  91. package/components/dropdown/list-item/interactive.js +49 -0
  92. package/components/dropdown/list-item/interactive.js.map +1 -0
  93. package/components/dropdown/list-item/separator.js +17 -0
  94. package/components/dropdown/list-item/separator.js.map +1 -0
  95. package/components/dropdown/list-item/styles.module.css.js +26 -0
  96. package/components/dropdown/list-item/styles.module.css.js.map +1 -0
  97. package/components/dropdown/list-item/title.js +9 -0
  98. package/components/dropdown/list-item/title.js.map +1 -0
  99. package/components/dropdown/styles.module.css.js +24 -0
  100. package/components/dropdown/styles.module.css.js.map +1 -0
  101. package/components/dropdown/toggle-button/index.js +54 -0
  102. package/components/dropdown/toggle-button/index.js.map +1 -0
  103. package/components/dropdown/toggle-button/styles.module.scss.js +14 -0
  104. package/components/dropdown/toggle-button/styles.module.scss.js.map +1 -0
  105. package/components/flight-icon/flight-icon.module.css.js +12 -0
  106. package/components/flight-icon/flight-icon.module.css.js.map +1 -0
  107. package/components/flight-icon/index.js +58 -0
  108. package/components/flight-icon/index.js.map +1 -0
  109. package/components/form/checkbox/form-checkbox.module.css.js +8 -0
  110. package/components/form/checkbox/form-checkbox.module.css.js.map +1 -0
  111. package/components/form/checkbox/index.js +109 -0
  112. package/components/form/checkbox/index.js.map +1 -0
  113. package/components/form/error/form-error.module.css.js +14 -0
  114. package/components/form/error/form-error.module.css.js.map +1 -0
  115. package/components/form/error/index.js +22 -0
  116. package/components/form/error/index.js.map +1 -0
  117. package/components/form/field/form-field.module.css.js +17 -0
  118. package/components/form/field/form-field.module.css.js.map +1 -0
  119. package/components/form/field/index.js +46 -0
  120. package/components/form/field/index.js.map +1 -0
  121. package/components/form/fieldset/form-fieldset.module.css.js +19 -0
  122. package/components/form/fieldset/form-fieldset.module.css.js.map +1 -0
  123. package/components/form/fieldset/index.d.ts +1 -2
  124. package/components/form/fieldset/index.js +65 -0
  125. package/components/form/fieldset/index.js.map +1 -0
  126. package/components/form/file-input/form-file-input.module.scss +2 -2
  127. package/components/form/file-input/form-file-input.module.scss.js +7 -0
  128. package/components/form/file-input/form-file-input.module.scss.js.map +1 -0
  129. package/components/form/file-input/index.js +68 -0
  130. package/components/form/file-input/index.js.map +1 -0
  131. package/components/form/helper-text/form-helper-text.module.css.js +7 -0
  132. package/components/form/helper-text/form-helper-text.module.css.js.map +1 -0
  133. package/components/form/helper-text/index.js +22 -0
  134. package/components/form/helper-text/index.js.map +1 -0
  135. package/components/form/indicator/form-indicator.module.css.js +8 -0
  136. package/components/form/indicator/form-indicator.module.css.js.map +1 -0
  137. package/components/form/indicator/index.js +23 -0
  138. package/components/form/indicator/index.js.map +1 -0
  139. package/components/form/label/form-label.module.css.js +10 -0
  140. package/components/form/label/form-label.module.css.js.map +1 -0
  141. package/components/form/label/index.js +33 -0
  142. package/components/form/label/index.js.map +1 -0
  143. package/components/form/legend/form-legend.module.css.js +10 -0
  144. package/components/form/legend/form-legend.module.css.js.map +1 -0
  145. package/components/form/legend/index.js +19 -0
  146. package/components/form/legend/index.js.map +1 -0
  147. package/components/form/radio/form-radio.module.scss.js +8 -0
  148. package/components/form/radio/form-radio.module.scss.js.map +1 -0
  149. package/components/form/radio/index.d.ts +3 -5
  150. package/components/form/radio/index.js +100 -0
  151. package/components/form/radio/index.js.map +1 -0
  152. package/components/form/radio-card/RadioCardStory.css +21 -0
  153. package/components/form/radio-card/description.js +10 -0
  154. package/components/form/radio-card/description.js.map +1 -0
  155. package/components/form/radio-card/form-radio-card.module.css.js +30 -0
  156. package/components/form/radio-card/form-radio-card.module.css.js.map +1 -0
  157. package/components/form/radio-card/group.js +31 -0
  158. package/components/form/radio-card/group.js.map +1 -0
  159. package/components/form/radio-card/index.js +67 -0
  160. package/components/form/radio-card/index.js.map +1 -0
  161. package/components/form/radio-card/label.js +10 -0
  162. package/components/form/radio-card/label.js.map +1 -0
  163. package/components/form/select/form-select.module.css.js +14 -0
  164. package/components/form/select/form-select.module.css.js.map +1 -0
  165. package/components/form/select/index.js +79 -0
  166. package/components/form/select/index.js.map +1 -0
  167. package/components/form/super-select/form-super-select.module.css.js +22 -0
  168. package/components/form/super-select/form-super-select.module.css.js.map +1 -0
  169. package/components/form/super-select/index.js +170 -0
  170. package/components/form/super-select/index.js.map +1 -0
  171. package/components/form/text-input/index.js +91 -0
  172. package/components/form/text-input/index.js.map +1 -0
  173. package/components/form/text-input/styles.module.css.js +15 -0
  174. package/components/form/text-input/styles.module.css.js.map +1 -0
  175. package/components/form/textarea/form-textarea.module.css.js +14 -0
  176. package/components/form/textarea/form-textarea.module.css.js.map +1 -0
  177. package/components/form/textarea/index.js +74 -0
  178. package/components/form/textarea/index.js.map +1 -0
  179. package/components/form/toggle/form-toggle.module.scss.js +12 -0
  180. package/components/form/toggle/form-toggle.module.scss.js.map +1 -0
  181. package/components/form/toggle/index.js +102 -0
  182. package/components/form/toggle/index.js.map +1 -0
  183. package/components/hds/wrappers/tooltip.js +51 -0
  184. package/components/hds/wrappers/tooltip.js.map +1 -0
  185. package/components/icon-tile/index.js +50 -0
  186. package/components/icon-tile/index.js.map +1 -0
  187. package/components/icon-tile/style.module.scss +12 -10
  188. package/components/icon-tile/style.module.scss.js +29 -0
  189. package/components/icon-tile/style.module.scss.js.map +1 -0
  190. package/components/index.d.ts +1 -1
  191. package/components/index.js +116 -73
  192. package/components/index.js.map +1 -1
  193. package/components/inline-link/index.js +34 -0
  194. package/components/inline-link/index.js.map +1 -0
  195. package/components/inline-link/inline-link.module.css.js +11 -0
  196. package/components/inline-link/inline-link.module.css.js.map +1 -0
  197. package/components/interactive/index.js +59 -0
  198. package/components/interactive/index.js.map +1 -0
  199. package/components/legacy-button/index.js +65 -0
  200. package/components/legacy-button/index.js.map +1 -0
  201. package/components/legacy-button/utils.js +39 -0
  202. package/components/legacy-button/utils.js.map +1 -0
  203. package/components/menu-primitive/index.js +68 -0
  204. package/components/menu-primitive/index.js.map +1 -0
  205. package/components/menu-primitive/styles.module.css.js +12 -0
  206. package/components/menu-primitive/styles.module.css.js.map +1 -0
  207. package/components/menu-primitive/use-menu-primitive.js +17 -0
  208. package/components/menu-primitive/use-menu-primitive.js.map +1 -0
  209. package/components/modal/index.js +61 -0
  210. package/components/modal/index.js.map +1 -0
  211. package/components/modal/modal.module.css +5 -0
  212. package/components/modal/modal.module.css.js +8 -0
  213. package/components/modal/modal.module.css.js.map +1 -0
  214. package/components/modal/use-modal.js +17 -0
  215. package/components/modal/use-modal.js.map +1 -0
  216. package/components/separator/index.js +15 -0
  217. package/components/separator/index.js.map +1 -0
  218. package/components/separator/separator.module.css.js +10 -0
  219. package/components/separator/separator.module.css.js.map +1 -0
  220. package/components/standalone-link/index.js +54 -0
  221. package/components/standalone-link/index.js.map +1 -0
  222. package/components/standalone-link/styles.module.scss.js +17 -0
  223. package/components/standalone-link/styles.module.scss.js.map +1 -0
  224. package/components/table/index.js +52 -0
  225. package/components/table/index.js.map +1 -0
  226. package/components/table/table.module.scss.js +33 -0
  227. package/components/table/table.module.scss.js.map +1 -0
  228. package/components/table/td.js +28 -0
  229. package/components/table/td.js.map +1 -0
  230. package/components/table/th-button-tooltip.js +24 -0
  231. package/components/table/th-button-tooltip.js.map +1 -0
  232. package/components/table/th.js +43 -0
  233. package/components/table/th.js.map +1 -0
  234. package/components/table/tr.js +9 -0
  235. package/components/table/tr.js.map +1 -0
  236. package/components/table/utils.js +28 -0
  237. package/components/table/utils.js.map +1 -0
  238. package/components/tabs/index.js +115 -0
  239. package/components/tabs/index.js.map +1 -0
  240. package/components/tabs/tab-panel.js +35 -0
  241. package/components/tabs/tab-panel.js.map +1 -0
  242. package/components/tabs/tab.js +70 -0
  243. package/components/tabs/tab.js.map +1 -0
  244. package/components/tabs/tabs.module.scss.js +22 -0
  245. package/components/tabs/tabs.module.scss.js.map +1 -0
  246. package/components/tabs/use-tabs-context.js +16 -0
  247. package/components/tabs/use-tabs-context.js.map +1 -0
  248. package/components/text/index.js +112 -0
  249. package/components/text/index.js.map +1 -0
  250. package/components/text/style.module.scss.js +9 -0
  251. package/components/text/style.module.scss.js.map +1 -0
  252. package/components/visualizations/bar-chart/horizontal-chart/dataset-value/index.js +62 -0
  253. package/components/visualizations/bar-chart/horizontal-chart/dataset-value/index.js.map +1 -0
  254. package/components/visualizations/bar-chart/horizontal-chart/dataset-value/style.module.css.js +20 -0
  255. package/components/visualizations/bar-chart/horizontal-chart/dataset-value/style.module.css.js.map +1 -0
  256. package/components/visualizations/bar-chart/horizontal-chart/index.js +104 -0
  257. package/components/visualizations/bar-chart/horizontal-chart/index.js.map +1 -0
  258. package/components/visualizations/bar-chart/horizontal-chart/legend/index.js +13 -0
  259. package/components/visualizations/bar-chart/horizontal-chart/legend/index.js.map +1 -0
  260. package/components/visualizations/bar-chart/horizontal-chart/legend/style.module.css.js +14 -0
  261. package/components/visualizations/bar-chart/horizontal-chart/legend/style.module.css.js.map +1 -0
  262. package/components/visualizations/bar-chart/horizontal-chart/style.module.css.js +28 -0
  263. package/components/visualizations/bar-chart/horizontal-chart/style.module.css.js.map +1 -0
  264. package/components/visualizations/bar-chart/index.js +37 -0
  265. package/components/visualizations/bar-chart/index.js.map +1 -0
  266. package/components/visualizations/bar-chart/style.module.css.js +12 -0
  267. package/components/visualizations/bar-chart/style.module.css.js.map +1 -0
  268. package/components/visualizations/donut-chart/components/arc-tooltip/index.js +14 -0
  269. package/components/visualizations/donut-chart/components/arc-tooltip/index.js.map +1 -0
  270. package/components/visualizations/donut-chart/components/arc-tooltip/styles.module.css.js +10 -0
  271. package/components/visualizations/donut-chart/components/arc-tooltip/styles.module.css.js.map +1 -0
  272. package/components/visualizations/donut-chart/components/external-arc-label/index.js +58 -0
  273. package/components/visualizations/donut-chart/components/external-arc-label/index.js.map +1 -0
  274. package/components/visualizations/donut-chart/components/external-arc-label/styles.module.css.js +16 -0
  275. package/components/visualizations/donut-chart/components/external-arc-label/styles.module.css.js.map +1 -0
  276. package/components/visualizations/donut-chart/components/internal-arc-label/index.js +42 -0
  277. package/components/visualizations/donut-chart/components/internal-arc-label/index.js.map +1 -0
  278. package/components/visualizations/donut-chart/components/internal-arc-label/styles.module.css.js +14 -0
  279. package/components/visualizations/donut-chart/components/internal-arc-label/styles.module.css.js.map +1 -0
  280. package/components/visualizations/donut-chart/index.js +90 -0
  281. package/components/visualizations/donut-chart/index.js.map +1 -0
  282. package/components/visualizations/donut-chart/styles.module.css.js +20 -0
  283. package/components/visualizations/donut-chart/styles.module.css.js.map +1 -0
  284. package/hooks/use-media-query/index.js +16 -0
  285. package/hooks/use-media-query/index.js.map +1 -0
  286. package/index.js +155 -101
  287. package/index.js.map +1 -1
  288. package/package.json +1 -1
  289. package/patterns/card/newsroom-card/index.js +26 -0
  290. package/patterns/card/newsroom-card/index.js.map +1 -0
  291. package/patterns/card/newsroom-card/style.module.css.js +8 -0
  292. package/patterns/card/newsroom-card/style.module.css.js.map +1 -0
  293. package/patterns/card/partner-card/index.js +42 -0
  294. package/patterns/card/partner-card/index.js.map +1 -0
  295. package/patterns/card/partner-card/style.module.css.js +12 -0
  296. package/patterns/card/partner-card/style.module.css.js.map +1 -0
  297. package/patterns/card/person-card/index.js +54 -0
  298. package/patterns/card/person-card/index.js.map +1 -0
  299. package/patterns/card/person-card/style.module.css.js +12 -0
  300. package/patterns/card/person-card/style.module.css.js.map +1 -0
  301. package/patterns/card/primitives.js +77 -0
  302. package/patterns/card/primitives.js.map +1 -0
  303. package/patterns/card/promo-card/index.js +36 -0
  304. package/patterns/card/promo-card/index.js.map +1 -0
  305. package/patterns/card/resource-card/index.js +26 -0
  306. package/patterns/card/resource-card/index.js.map +1 -0
  307. package/patterns/card/style.module.css.js +30 -0
  308. package/patterns/card/style.module.css.js.map +1 -0
  309. package/patterns/card/thumbnails/index.js +25 -0
  310. package/patterns/card/thumbnails/index.js.map +1 -0
  311. package/patterns/card/unified-card/index.js +37 -0
  312. package/patterns/card/unified-card/index.js.map +1 -0
  313. package/patterns/copy-button/clipboard.js +78 -0
  314. package/patterns/copy-button/clipboard.js.map +1 -0
  315. package/patterns/copy-button/index.js +57 -0
  316. package/patterns/copy-button/index.js.map +1 -0
  317. package/patterns/copy-button/style.module.css.js +13 -0
  318. package/patterns/copy-button/style.module.css.js.map +1 -0
  319. package/patterns/index.js +32 -22
  320. package/patterns/index.js.map +1 -1
  321. package/patterns/layout/index.js +47 -0
  322. package/patterns/layout/index.js.map +1 -0
  323. package/patterns/layout/layout.module.css.js +20 -0
  324. package/patterns/layout/layout.module.css.js.map +1 -0
  325. package/patterns/product-badge/index.js +22 -0
  326. package/patterns/product-badge/index.js.map +1 -0
  327. package/patterns/product-badge/style.module.css.js +8 -0
  328. package/patterns/product-badge/style.module.css.js.map +1 -0
  329. package/patterns/product-logo/index.js +130 -0
  330. package/patterns/product-logo/index.js.map +1 -0
  331. package/patterns/product-logo/product-logo.module.css.js +13 -0
  332. package/patterns/product-logo/product-logo.module.css.js.map +1 -0
  333. package/patterns/related-content/index.js +65 -0
  334. package/patterns/related-content/index.js.map +1 -0
  335. package/patterns/related-content/style.module.css.js +22 -0
  336. package/patterns/related-content/style.module.css.js.map +1 -0
  337. package/style.css +1 -1
  338. package/utils/get-contrast-yiq.js +13 -0
  339. package/utils/get-contrast-yiq.js.map +1 -0
  340. package/utils/hooks/use-screen-size.js +10 -0
  341. package/utils/hooks/use-screen-size.js.map +1 -0
  342. package/utils/i18n/constants/index.js +98 -0
  343. package/utils/i18n/constants/index.js.map +1 -0
  344. package/utils/i18n/helpers/locale-provider.js +9 -0
  345. package/utils/i18n/helpers/locale-provider.js.map +1 -0
  346. package/utils/i18n/helpers/to-smart-sentence-case.js +12 -0
  347. package/utils/i18n/helpers/to-smart-sentence-case.js.map +1 -0
  348. package/utils/i18n/helpers/to-smart-title-case.js +10 -0
  349. package/utils/i18n/helpers/to-smart-title-case.js.map +1 -0
  350. package/utils/i18n/helpers/use-locale.js +14 -0
  351. package/utils/i18n/helpers/use-locale.js.map +1 -0
  352. package/utils/i18n/index.js +41 -0
  353. package/utils/i18n/index.js.map +1 -0
  354. package/utils/i18n/index2.js +33 -0
  355. package/utils/i18n/index2.js.map +1 -0
  356. package/utils/index.js +7 -7
  357. package/utils/make-normalizer/index.js +34 -0
  358. package/utils/make-normalizer/index.js.map +1 -0
  359. package/{index-DBjAbGt7.js → utils/mds-context/index.js} +20 -19
  360. package/utils/mds-context/index.js.map +1 -0
  361. package/index-B9mPJh9w.js +0 -579
  362. package/index-B9mPJh9w.js.map +0 -1
  363. package/index-BHBlMMNF.js +0 -16
  364. package/index-BHBlMMNF.js.map +0 -1
  365. package/index-C4GBbW3N.js +0 -3567
  366. package/index-C4GBbW3N.js.map +0 -1
  367. package/index-DBjAbGt7.js.map +0 -1
  368. package/index-WkGIywHj.js +0 -767
  369. package/index-WkGIywHj.js.map +0 -1
  370. package/use-screen-size-BOnkX_K-.js +0 -9
  371. package/use-screen-size-BOnkX_K-.js.map +0 -1
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sources":["../../../src/components/text/index.tsx"],"sourcesContent":["import classNames from 'classnames'\nimport {\n\tcreateElement,\n\ttype ComponentPropsWithRef,\n\ttype ElementType,\n} from 'react'\nimport s from './style.module.scss'\n\nconst TEXT_COLORS = [\n\t'primary',\n\t'strong',\n\t'faint',\n\t'disabled',\n\t'high-contrast',\n\t'action',\n\t'action-hover',\n\t'action-active',\n\t'highlight',\n\t'highlight-on-surface',\n\t'highlight-high-contrast',\n\t'success',\n\t'success-on-surface',\n\t'success-high-contrast',\n\t'warning',\n\t'warning-on-surface',\n\t'warning-high-contrast',\n\t'critical',\n\t'critical-on-surface',\n\t'critical-high-contrast',\n] as const\n\nconst TEXT_GROUPS = [\n\t'hds-body',\n\t'code',\n\t'body',\n\t'display-expressive',\n\t'label',\n] as const\n\nconst TEXT_SIZES = [\n\t'100',\n\t'200',\n\t'300',\n\t'400',\n\t'500',\n\t'600',\n\t'700',\n\t'800',\n] as const\n\nconst TEXT_WEIGHTS = ['regular', 'medium', 'semibold', 'bold'] as const\n\ntype TextColor = (typeof TEXT_COLORS)[number]\ntype TextWeight = (typeof TEXT_WEIGHTS)[number]\ntype TextGroup = (typeof TEXT_GROUPS)[number]\ntype TextSize = (typeof TEXT_SIZES)[number]\n\n// small typescript hack to support autocomplete and arbitrary strings\ntype HexColor = string & { hexish?: unknown }\n\ninterface BaseTextProps<T extends ElementType> {\n\ttag?: T\n\tsize?: TextSize\n\tweight?: TextWeight\n\talign?: 'left' | 'center' | 'right'\n\tcolor?: TextColor | HexColor\n\tclassName?: string\n}\n\ninterface TextImplProps<T extends ElementType> extends BaseTextProps<T> {\n\tgroup: TextGroup\n}\n\nfunction getTypographyToken(group: TextGroup, size: TextSize): string {\n\tconst groupToTokenMap: Record<TextGroup, string> = {\n\t\t'hds-body': `mds-typography-legacy-body-${size}`,\n\t\tcode: `mds-typography-code-${size}`,\n\t\t'display-expressive': `mds-typography-display-expressive-${size}`,\n\t\tlabel: `mds-typography-label`,\n\t\tbody: `mds-typography-body-${size}`,\n\t}\n\n\treturn groupToTokenMap[group]\n}\n\nconst TextImpl = <T extends ElementType = 'span'>({\n\ttag,\n\tgroup,\n\tsize = '200',\n\tweight,\n\talign,\n\tcolor,\n\tchildren,\n\tclassName,\n\t...rest\n}: TextImplProps<T> &\n\tOmit<ComponentPropsWithRef<T>, keyof TextImplProps<T>>) => {\n\tconst Component = tag ?? 'span'\n\tconst variant = getTypographyToken(group, size)\n\n\tconst usesPredefinedColor = TEXT_COLORS.includes(color as TextColor)\n\n\treturn (\n\t\t<Component\n\t\t\tclassName={classNames(\n\t\t\t\tvariant,\n\t\t\t\t{\n\t\t\t\t\t[s[`align-${align}`]]: align,\n\t\t\t\t\t[`mds-typography-font-weight-${weight}`]: weight,\n\t\t\t\t\t[`mds-foreground-${color}`]: color && usesPredefinedColor,\n\t\t\t\t},\n\t\t\t\tclassName\n\t\t\t)}\n\t\t\tstyle={color && !usesPredefinedColor ? { color } : {}}\n\t\t\t{...rest}\n\t\t>\n\t\t\t{children}\n\t\t</Component>\n\t)\n}\n\ninterface BodyProps<T extends ElementType> extends BaseTextProps<T> {\n\tsize?: '200' | '300' | '400'\n}\n\nconst Body = <T extends ElementType>({\n\tsize = '300',\n\t...rest\n}: BodyProps<T> & Omit<ComponentPropsWithRef<T>, keyof BodyProps<T>>) => {\n\treturn createElement(TextImpl, {\n\t\t...rest,\n\t\tsize,\n\t\tgroup: 'body',\n\t})\n}\n\ninterface DisplayExpressiveProps<T extends ElementType>\n\textends BaseTextProps<T> {\n\tsize?: '100' | '200' | '300' | '400' | '500' | '600' | '700' | '800'\n}\n\nconst DisplayExpressive = <T extends ElementType>({\n\tsize = '200',\n\t...rest\n}: DisplayExpressiveProps<T> &\n\tOmit<ComponentPropsWithRef<T>, keyof DisplayExpressiveProps<T>>) => {\n\treturn createElement(TextImpl, {\n\t\t...rest,\n\t\tsize,\n\t\tgroup: 'display-expressive',\n\t})\n}\n\ntype LabelProps<T extends ElementType> = Omit<BaseTextProps<T>, 'size'>\n\nconst Label = <T extends ElementType>(\n\tprops: LabelProps<T> & Omit<ComponentPropsWithRef<T>, keyof LabelProps<T>>\n) => {\n\treturn createElement(TextImpl, {\n\t\t...props,\n\t\tgroup: 'label',\n\t})\n}\n\ninterface HDSBodyProps<T extends ElementType> extends BaseTextProps<T> {\n\tsize?: '100' | '200' | '300'\n}\n\nconst HDSBody = <T extends ElementType>({\n\tsize = '200',\n\tweight = 'regular',\n\t...rest\n}: HDSBodyProps<T> & Omit<ComponentPropsWithRef<T>, keyof HDSBodyProps<T>>) => {\n\treturn createElement(TextImpl, {\n\t\t...rest,\n\t\tsize,\n\t\tweight,\n\t\tgroup: 'hds-body',\n\t})\n}\n\ninterface CodeProps<T extends ElementType> extends BaseTextProps<T> {\n\tsize?: '100' | '200' | '300'\n}\n\nconst Code = <T extends ElementType>({\n\tsize = '200',\n\tweight = 'regular',\n\t...rest\n}: CodeProps<T> & Omit<ComponentPropsWithRef<T>, keyof CodeProps<T>>) => {\n\treturn createElement(TextImpl, {\n\t\t...rest,\n\t\tsize,\n\t\tweight,\n\t\tgroup: 'code',\n\t})\n}\n\nconst Text = {\n\tBody,\n\tDisplayExpressive,\n\tLabel,\n\tHDSBody,\n\tCode,\n}\n\nexport { Text, TEXT_COLORS, TEXT_WEIGHTS }\n"],"names":["TEXT_COLORS","TEXT_WEIGHTS","getTypographyToken","group","size","TextImpl","tag","weight","align","color","children","className","rest","Component","variant","usesPredefinedColor","jsx","classNames","s","Body","createElement","DisplayExpressive","Label","props","HDSBody","Code","Text"],"mappings":";;;;AAQA,MAAMA,IAAc;AAAA,EACnB;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACD,GAqBMC,IAAe,CAAC,WAAW,UAAU,YAAY,MAAM;AAuB7D,SAASC,EAAmBC,GAAkBC,GAAwB;AASrE,SARmD;AAAA,IAClD,YAAY,8BAA8BA,CAAI;AAAA,IAC9C,MAAM,uBAAuBA,CAAI;AAAA,IACjC,sBAAsB,qCAAqCA,CAAI;AAAA,IAC/D,OAAO;AAAA,IACP,MAAM,uBAAuBA,CAAI;AAAA,EAAA,EAGXD,CAAK;AAC7B;AAEA,MAAME,IAAW,CAAiC;AAAA,EACjD,KAAAC;AAAA,EACA,OAAAH;AAAA,EACA,MAAAC,IAAO;AAAA,EACP,QAAAG;AAAA,EACA,OAAAC;AAAA,EACA,OAAAC;AAAA,EACA,UAAAC;AAAA,EACA,WAAAC;AAAA,EACA,GAAGC;AACJ,MAC4D;AAC3D,QAAMC,IAAYP,KAAO,QACnBQ,IAAUZ,EAAmBC,GAAOC,CAAI,GAExCW,IAAsBf,EAAY,SAASS,CAAkB;AAEnE,SACC,gBAAAO;AAAA,IAACH;AAAA,IAAA;AAAA,MACA,WAAWI;AAAA,QACVH;AAAA,QACA;AAAA,UACC,CAACI,EAAE,SAASV,CAAK,EAAE,CAAC,GAAGA;AAAA,UACvB,CAAC,8BAA8BD,CAAM,EAAE,GAAGA;AAAA,UAC1C,CAAC,kBAAkBE,CAAK,EAAE,GAAGA,KAASM;AAAA,QAAA;AAAA,QAEvCJ;AAAA,MAAA;AAAA,MAED,OAAOF,KAAS,CAACM,IAAsB,EAAE,OAAAN,EAAA,IAAU,CAAA;AAAA,MAClD,GAAGG;AAAA,MAEH,UAAAF;AAAA,IAAA;AAAA,EAAA;AAGJ,GAMMS,IAAO,CAAwB;AAAA,EACpC,MAAAf,IAAO;AAAA,EACP,GAAGQ;AACJ,MACQQ,EAAcf,GAAU;AAAA,EAC9B,GAAGO;AAAA,EACH,MAAAR;AAAA,EACA,OAAO;AAAA,CACP,GAQIiB,IAAoB,CAAwB;AAAA,EACjD,MAAAjB,IAAO;AAAA,EACP,GAAGQ;AACJ,MAEQQ,EAAcf,GAAU;AAAA,EAC9B,GAAGO;AAAA,EACH,MAAAR;AAAA,EACA,OAAO;AAAA,CACP,GAKIkB,IAAQ,CACbC,MAEOH,EAAcf,GAAU;AAAA,EAC9B,GAAGkB;AAAA,EACH,OAAO;AAAA,CACP,GAOIC,IAAU,CAAwB;AAAA,EACvC,MAAApB,IAAO;AAAA,EACP,QAAAG,IAAS;AAAA,EACT,GAAGK;AACJ,MACQQ,EAAcf,GAAU;AAAA,EAC9B,GAAGO;AAAA,EACH,MAAAR;AAAA,EACA,QAAAG;AAAA,EACA,OAAO;AAAA,CACP,GAOIkB,IAAO,CAAwB;AAAA,EACpC,MAAArB,IAAO;AAAA,EACP,QAAAG,IAAS;AAAA,EACT,GAAGK;AACJ,MACQQ,EAAcf,GAAU;AAAA,EAC9B,GAAGO;AAAA,EACH,MAAAR;AAAA,EACA,QAAAG;AAAA,EACA,OAAO;AAAA,CACP,GAGImB,IAAO;AAAA,EACZ,MAAAP;AAAA,EACA,mBAAAE;AAAA,EACA,OAAAC;AAAA,EACA,SAAAE;AAAA,EACA,MAAAC;AACD;"}
@@ -0,0 +1,9 @@
1
+ const l = {
2
+ "align-left": "align-left__Twy3l",
3
+ "align-center": "align-center__iK1pm",
4
+ "align-right": "align-right__YgPRT"
5
+ };
6
+ export {
7
+ l as default
8
+ };
9
+ //# sourceMappingURL=style.module.scss.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"style.module.scss.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;"}
@@ -0,0 +1,62 @@
1
+ "use client";
2
+ import { jsxs as f, jsx as u } from "react/jsx-runtime";
3
+ import { useState as g } from "react";
4
+ import i from "classnames";
5
+ import h from "use-resize-observer";
6
+ import { getContrastYIQ as b, hexToRgb as x } from "../../../../../utils/get-contrast-yiq.js";
7
+ import { Text as V } from "../../../../text/index.js";
8
+ import s from "./style.module.css.js";
9
+ function j({
10
+ value: e,
11
+ highestValue: l,
12
+ color: a,
13
+ stackable: m
14
+ }) {
15
+ const [n, r] = g(!1), { ref: c } = h({
16
+ onResize: ({ width: o }) => {
17
+ e === 0 && (e = 0.5);
18
+ let t = 32;
19
+ e >= 10 && e <= 99 ? t = 40 : e >= 100 && (t = 48), o && o < t ? r(!0) : r(!1);
20
+ }
21
+ }), d = b(x(a)), p = e / l * 100;
22
+ return /* @__PURE__ */ f(
23
+ "div",
24
+ {
25
+ ref: c,
26
+ className: i(s.datasetValue, s[d]),
27
+ style: {
28
+ "--width": p
29
+ },
30
+ children: [
31
+ /* @__PURE__ */ u(
32
+ "div",
33
+ {
34
+ className: s.datasetValueBar,
35
+ style: {
36
+ "--bar-background": a
37
+ }
38
+ }
39
+ ),
40
+ /* @__PURE__ */ f(
41
+ V.Body,
42
+ {
43
+ tag: "span",
44
+ size: "200",
45
+ className: i(s.datasetValuePercent, {
46
+ [s.offset]: n,
47
+ [s.stackable]: m
48
+ }),
49
+ children: [
50
+ e,
51
+ "%"
52
+ ]
53
+ }
54
+ )
55
+ ]
56
+ }
57
+ );
58
+ }
59
+ export {
60
+ j as default
61
+ };
62
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sources":["../../../../../../src/components/visualizations/bar-chart/horizontal-chart/dataset-value/index.tsx"],"sourcesContent":["'use client'\n\nimport { useState } from 'react'\nimport classNames from 'classnames'\nimport useResizeObserver from 'use-resize-observer'\nimport { getContrastYIQ, hexToRgb } from '../../../../../utils/get-contrast-yiq'\nimport { Text } from '../../../../../components/text'\nimport s from './style.module.css'\n\ninterface DatasetValueProps {\n\tvalue: number\n\thighestValue: number\n\tcolor: string\n\tstackable: boolean\n}\n\nexport default function DatasetValue({\n\tvalue,\n\thighestValue,\n\tcolor,\n\tstackable,\n}: DatasetValueProps) {\n\tconst [valueIsOffset, setValueIsOffset] = useState(false)\n\tconst { ref } = useResizeObserver<HTMLDivElement>({\n\t\tonResize: ({ width }) => {\n\t\t\t// If the value is 0, we want to show a 0.5% bar\n\t\t\tif (value === 0) {\n\t\t\t\tvalue = 0.5\n\t\t\t}\n\n\t\t\t/**\n\t\t\t * The logic below determines the threshold (in `px`)\n\t\t\t * a bar's width needs to reach for the value to be offset\n\t\t\t * by moving it to the right of the bar.\n\t\t\t *\n\t\t\t * The default below is for single-digit values.\n\t\t\t */\n\t\t\tlet offsetThreshold = 32\n\n\t\t\tif (value >= 10 && value <= 99) {\n\t\t\t\t// Offset threshold for 2 digit values\n\t\t\t\toffsetThreshold = 40\n\t\t\t} else if (value >= 100) {\n\t\t\t\t// Offset threshold for 3+ digit values\n\t\t\t\toffsetThreshold = 48\n\t\t\t}\n\n\t\t\tif (width && width < offsetThreshold) {\n\t\t\t\tsetValueIsOffset(true)\n\t\t\t} else {\n\t\t\t\tsetValueIsOffset(false)\n\t\t\t}\n\t\t},\n\t})\n\n\tconst valueColor = getContrastYIQ(hexToRgb(color))\n\n\t/**\n\t * The actual width of the bar, however, should be\n\t * a percentage of the highest value in the chart\n\t */\n\tconst percentageOfHighest = (value / highestValue) * 100\n\n\treturn (\n\t\t<div\n\t\t\tref={ref}\n\t\t\tclassName={classNames(s.datasetValue, s[valueColor])}\n\t\t\tstyle={\n\t\t\t\t{\n\t\t\t\t\t'--width': percentageOfHighest,\n\t\t\t\t} as React.CSSProperties\n\t\t\t}\n\t\t>\n\t\t\t<div\n\t\t\t\tclassName={s.datasetValueBar}\n\t\t\t\tstyle={\n\t\t\t\t\t{\n\t\t\t\t\t\t'--bar-background': color,\n\t\t\t\t\t} as React.CSSProperties\n\t\t\t\t}\n\t\t\t/>\n\t\t\t<Text.Body\n\t\t\t\ttag=\"span\"\n\t\t\t\tsize=\"200\"\n\t\t\t\tclassName={classNames(s.datasetValuePercent, {\n\t\t\t\t\t[s.offset]: valueIsOffset,\n\t\t\t\t\t[s.stackable]: stackable,\n\t\t\t\t})}\n\t\t\t>\n\t\t\t\t{value}%\n\t\t\t</Text.Body>\n\t\t</div>\n\t)\n}\n"],"names":["DatasetValue","value","highestValue","color","stackable","valueIsOffset","useState","useResizeObserver","offsetThreshold","width","setValueIsOffset","valueColor","getContrastYIQ","jsxs","ref","classNames","percentageOfHighest","jsx","Text"],"mappings":";;;;;;;;AAgBqC,SACpCA,EAAA;AAAA,EACA,OAAAC;AAAA,EACA,cAAAC;AAAA,EACA,OAAAC;AAAA,EACD,WAAAC;AACC,GAAA;AACA,QAAM,CAAAC,IAA4C,IAAAC,EAAA,EAAA,YACvC,IAAGC,EAAY;AAAA,IAExB,UAAI,YAAa,MAAA;AAChB,MAAAN,MAAQ,MACTA,IAAA;AAWA,UAAIO,IAAe;AAElB,MAAAP,KAAA,WAAkB,KACnBO,IAAoB,KAEnBP,KAAkB,QACnBO,IAAA,KAGCC,KAAAA,IAAiBD,IAClBE,EAAO,EAAA,IAEPA,EAAA,EAAA;AAAA,IAED;AAAA,EAED,CAAA,GAMMC,IAAAC,IAA+BT,CAAA,QAGpCF,IAAAC,IAAA;AAAA,SAAC,gBAAAW;AAAA,IAAA;AAAA,IAAA;AAAA,MAEA,KAAAC;AAAA,MACA,WACCC,EAAA,EAAA,cAAA,EAAAJ,CAAA,CAAA;AAAA,MAAA;QAEA,WAAAK;AAAA,MAGD;AAAA,MAAA,UAAA;AAAA,QAAC,gBAAAC;AAAA,UAAA;AAAA,UAAA;AAAA,YAEA,WACC,EAAA;AAAA,YAAA;cACqB,oBAAAd;AAAA,YACrB;AAAA,UAEF;AAAA,QAAA;AAAA,QACM,gBAAAU;AAAA,UAALK,EAAA;AAAA,UAAA;AAAA,YAEA;YACA;YAA6C,WACnCH,EAAG,EAAA,qBAAA;AAAA,cACZ,CAAC,EAAE,MAAA,GAASV;AAAA,cACZ,CAAA,EAAA,SAAA,GAAAD;AAAA,YAEA;YAAA,UAAA;AAAA,cAAMH;AAAA,cAAA;AAAA,YAAA;AAAA,UAAA;AAAA,QACR;AAAA,MAAA;AAAA,IACD;AAAA,EAEF;;"}
@@ -0,0 +1,20 @@
1
+ const a = "datasetValue__7Cgnp", t = "datasetValueBar__XH-zW", e = "datasetValuePercent__5-Ofn", s = "offset__5sIB1", l = "stackable__EL-7z", c = "light__bf-WO", _ = "dark__grmLH", d = {
2
+ datasetValue: a,
3
+ datasetValueBar: t,
4
+ datasetValuePercent: e,
5
+ offset: s,
6
+ stackable: l,
7
+ light: c,
8
+ dark: _
9
+ };
10
+ export {
11
+ _ as dark,
12
+ a as datasetValue,
13
+ t as datasetValueBar,
14
+ e as datasetValuePercent,
15
+ d as default,
16
+ c as light,
17
+ s as offset,
18
+ l as stackable
19
+ };
20
+ //# sourceMappingURL=style.module.css.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"style.module.css.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;"}
@@ -0,0 +1,104 @@
1
+ "use client";
2
+ import { jsxs as c, jsx as a } from "react/jsx-runtime";
3
+ import { useState as T, useMemo as f } from "react";
4
+ import C from "classnames";
5
+ import S from "react-wrap-balancer";
6
+ import y from "./dataset-value/index.js";
7
+ import B from "./legend/index.js";
8
+ import { useMediaQuery as k } from "../../../../hooks/use-media-query/index.js";
9
+ import { MDSButton as v } from "../../../legacy-button/index.js";
10
+ import { Text as w } from "../../../text/index.js";
11
+ import l from "./style.module.css.js";
12
+ function O({
13
+ categories: n,
14
+ datasets: r,
15
+ // Default this to virtually unlimited
16
+ maxInitialDatasets: i = 999,
17
+ stacked: o = !1
18
+ }) {
19
+ const h = k("(min-width: 560px)"), d = r.length > i, [m, p] = T(d), N = f(() => m ? r.slice(0, i) : r, [m, r, i]), g = f(() => {
20
+ let e = 0;
21
+ return r.forEach((s) => {
22
+ if (o) {
23
+ const t = b(s.values);
24
+ h ? t > e && (e = t) : s.values.forEach(({ value: u }) => {
25
+ u > e && (e = u);
26
+ });
27
+ } else
28
+ s.values.forEach(({ value: t }) => {
29
+ t > e && (e = t);
30
+ });
31
+ }), e;
32
+ }, [r, h]);
33
+ return /* @__PURE__ */ c("div", { className: l.barChart, children: [
34
+ /* @__PURE__ */ a("div", { className: l.chart, children: N.map((e) => /* @__PURE__ */ c("div", { className: l.dataset, children: [
35
+ /* @__PURE__ */ a("div", { className: l.datasetLabel, children: /* @__PURE__ */ a(S, { children: e.label }) }),
36
+ /* @__PURE__ */ c(
37
+ "div",
38
+ {
39
+ className: C(l.datasetValues, {
40
+ [l.datasetValuesStacked]: o
41
+ }),
42
+ children: [
43
+ e.values.map(({ value: s, color: t }, u) => /* @__PURE__ */ a(
44
+ y,
45
+ {
46
+ value: s,
47
+ highestValue: g,
48
+ color: t,
49
+ stackable: o
50
+ },
51
+ `dataset-${e.label}-${s}-${u}`
52
+ )),
53
+ o ? /* @__PURE__ */ a("div", { children: /* @__PURE__ */ c(w.Body, { size: "200", tag: "p", className: l.datasetTotal, children: [
54
+ /* @__PURE__ */ a("span", { className: l.datasetTotalText, children: "Total:" }),
55
+ /* @__PURE__ */ c("span", { className: l.datasetTotalPercent, children: [
56
+ e.total || b(e.values),
57
+ "%"
58
+ ] })
59
+ ] }) }) : null
60
+ ]
61
+ }
62
+ )
63
+ ] }, e.label)) }),
64
+ d && (m ? /* @__PURE__ */ a(
65
+ v,
66
+ {
67
+ className: l.showAllButton,
68
+ title: "Show all",
69
+ theme: {
70
+ brand: "neutral",
71
+ variant: "secondary",
72
+ background: "light"
73
+ },
74
+ onClick: () => p(!1)
75
+ }
76
+ ) : /* @__PURE__ */ a(
77
+ v,
78
+ {
79
+ className: l.showAllButton,
80
+ title: "Show less",
81
+ theme: {
82
+ brand: "neutral",
83
+ variant: "secondary",
84
+ background: "light"
85
+ },
86
+ onClick: () => p(!0)
87
+ }
88
+ )),
89
+ n && n.length > 1 && /* @__PURE__ */ a(B, { className: l.legend, keys: n })
90
+ ] });
91
+ }
92
+ function b(n) {
93
+ return n.reduce(
94
+ (i, o) => ({ value: i.value + o.value, color: "" }),
95
+ {
96
+ value: 0,
97
+ color: ""
98
+ }
99
+ ).value;
100
+ }
101
+ export {
102
+ O as default
103
+ };
104
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sources":["../../../../../src/components/visualizations/bar-chart/horizontal-chart/index.tsx"],"sourcesContent":["'use client'\n\nimport { useMemo, useState } from 'react'\nimport classNames from 'classnames'\nimport Balancer from 'react-wrap-balancer'\nimport DatasetValue from './dataset-value'\nimport Legend from './legend'\nimport { useMediaQuery } from '@web/hooks/use-media-query'\nimport { MDSButton } from '../../../legacy-button'\nimport { Text } from '../../../../components/text'\nimport s from './style.module.css'\n\ninterface Dataset {\n\tlabel: string\n\tvalues: Array<{\n\t\tvalue: number\n\t\tcolor: string\n\t}>\n\ttotal?: number\n}\n\ninterface Category {\n\tlabel: string\n\tcolor: string\n}\n\nexport interface HorizontalBarChartProps {\n\t/**\n\t * Passing more than one category causes\n\t * the Key to be displayed.\n\t *\n\t * If no categories are passed, the default\n\t * color is Blue.\n\t */\n\tcategories?: Array<Category>\n\t/**\n\t * All group.values.length must be equal\n\t * to the length of the number of groups\n\t * passed. If no groups are passed, each\n\t * group.values.length must equal one.\n\t */\n\tdatasets: Array<Dataset>\n\t/**\n\t * The total number of groups to display\n\t * initially before the user hits the\n\t * \"Show all\" button. Default unlimited.\n\t * */\n\tmaxInitialDatasets?: number\n\t/**\n\t * If true, values in each `group` will\n\t * be stacked together to form a single\n\t * bar.\n\t */\n\tstacked?: boolean\n}\n\nexport default function HorizontalBarChart({\n\tcategories,\n\tdatasets,\n\t// Default this to virtually unlimited\n\tmaxInitialDatasets = 999,\n\tstacked = false,\n}: HorizontalBarChartProps): JSX.Element {\n\t/**\n\t * If screen width is higher than 560px,\n\t * and this is a stacked bar chart,\n\t * we can stack the bars\n\t */\n\tconst isStackable = useMediaQuery('(min-width: 560px)')\n\tconst initialClipped = datasets.length > maxInitialDatasets\n\t/**\n\t * If true, the chart only shows datasets\n\t * up to `maxInitialDatasets`.\n\t */\n\tconst [isClipped, setIsClipped] = useState(initialClipped)\n\n\tconst datasetsToDisplay = useMemo(() => {\n\t\treturn isClipped ? datasets.slice(0, maxInitialDatasets) : datasets\n\t}, [isClipped, datasets, maxInitialDatasets])\n\n\t/**\n\t * Calculate the largest value to calculate % widths\n\t *\n\t * We make this calculation on `datasets`, rather than\n\t * `datasetsToDisplay` to prevent any resizing after\n\t * 'Show All' is clicked\n\t */\n\tconst highestValue = useMemo(() => {\n\t\tlet valueToReturn = 0\n\t\tdatasets.forEach((dataset) => {\n\t\t\tif (stacked) {\n\t\t\t\t/**\n\t\t\t\t * If we're using a stacked bar chart, we want to add\n\t\t\t\t * up the dataset values to calculate our `valueToReturn`,\n\t\t\t\t * as these will be presented together.\n\t\t\t\t *\n\t\t\t\t * The largest stack will be 100% width.\n\t\t\t\t *\n\t\t\t\t * P.S.: The `color` key in this variable's `.reduce()`\n\t\t\t\t * calculation is just here for proper TS typing;\n\t\t\t\t * `color` isn't otherwise used or necessary for\n\t\t\t\t * `summedObj`.\n\t\t\t\t */\n\t\t\t\tconst valueSum = getDatasetTotal(dataset.values)\n\n\t\t\t\t/**\n\t\t\t\t * If the bars are stackable (i.e. we're above 560px screen width)\n\t\t\t\t * then we use the valueSum calculated above to determine the\n\t\t\t\t * highestValue to return.\n\t\t\t\t *\n\t\t\t\t * Otherwise, we want the chart to behave like the unstacked\n\t\t\t\t * bar chart, so we use the same logic unstacked charts do for\n\t\t\t\t * determining highestValue.\n\t\t\t\t */\n\t\t\t\tif (isStackable) {\n\t\t\t\t\tif (valueSum > valueToReturn) {\n\t\t\t\t\t\tvalueToReturn = valueSum\n\t\t\t\t\t}\n\t\t\t\t} else {\n\t\t\t\t\tdataset.values.forEach(({ value }) => {\n\t\t\t\t\t\tif (value > valueToReturn) {\n\t\t\t\t\t\t\tvalueToReturn = value\n\t\t\t\t\t\t}\n\t\t\t\t\t})\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\t/**\n\t\t\t\t * In the event that we don't have a stacked bar chart,\n\t\t\t\t * we simply want to find the highest value out of all\n\t\t\t\t * of our values that is set (as that will be 100% width)\n\t\t\t\t */\n\t\t\t\tdataset.values.forEach(({ value }) => {\n\t\t\t\t\tif (value > valueToReturn) {\n\t\t\t\t\t\tvalueToReturn = value\n\t\t\t\t\t}\n\t\t\t\t})\n\t\t\t}\n\t\t})\n\n\t\treturn valueToReturn\n\t}, [datasets, isStackable])\n\n\treturn (\n\t\t<div className={s.barChart}>\n\t\t\t<div className={s.chart}>\n\t\t\t\t{datasetsToDisplay.map((dataset) => (\n\t\t\t\t\t<div className={s.dataset} key={dataset.label}>\n\t\t\t\t\t\t<div className={s.datasetLabel}>\n\t\t\t\t\t\t\t<Balancer>{dataset.label}</Balancer>\n\t\t\t\t\t\t</div>\n\t\t\t\t\t\t<div\n\t\t\t\t\t\t\tclassName={classNames(s.datasetValues, {\n\t\t\t\t\t\t\t\t[s.datasetValuesStacked]: stacked,\n\t\t\t\t\t\t\t})}\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t{dataset.values.map(({ value, color }, barIndex) => {\n\t\t\t\t\t\t\t\treturn (\n\t\t\t\t\t\t\t\t\t<DatasetValue\n\t\t\t\t\t\t\t\t\t\tkey={`dataset-${dataset.label}-${value}-${barIndex}`}\n\t\t\t\t\t\t\t\t\t\tvalue={value}\n\t\t\t\t\t\t\t\t\t\thighestValue={highestValue}\n\t\t\t\t\t\t\t\t\t\tcolor={color}\n\t\t\t\t\t\t\t\t\t\tstackable={stacked}\n\t\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t})}\n\t\t\t\t\t\t\t{stacked ? (\n\t\t\t\t\t\t\t\t<div>\n\t\t\t\t\t\t\t\t\t<Text.Body size=\"200\" tag=\"p\" className={s.datasetTotal}>\n\t\t\t\t\t\t\t\t\t\t<span className={s.datasetTotalText}>Total:</span>\n\t\t\t\t\t\t\t\t\t\t<span className={s.datasetTotalPercent}>\n\t\t\t\t\t\t\t\t\t\t\t{dataset.total || getDatasetTotal(dataset.values)}%\n\t\t\t\t\t\t\t\t\t\t</span>\n\t\t\t\t\t\t\t\t\t</Text.Body>\n\t\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t\t) : null}\n\t\t\t\t\t\t</div>\n\t\t\t\t\t</div>\n\t\t\t\t))}\n\t\t\t</div>\n\t\t\t{initialClipped &&\n\t\t\t\t(isClipped ? (\n\t\t\t\t\t<MDSButton\n\t\t\t\t\t\tclassName={s.showAllButton}\n\t\t\t\t\t\ttitle=\"Show all\"\n\t\t\t\t\t\ttheme={{\n\t\t\t\t\t\t\tbrand: 'neutral',\n\t\t\t\t\t\t\tvariant: 'secondary',\n\t\t\t\t\t\t\tbackground: 'light',\n\t\t\t\t\t\t}}\n\t\t\t\t\t\tonClick={() => setIsClipped(false)}\n\t\t\t\t\t/>\n\t\t\t\t) : (\n\t\t\t\t\t<MDSButton\n\t\t\t\t\t\tclassName={s.showAllButton}\n\t\t\t\t\t\ttitle=\"Show less\"\n\t\t\t\t\t\ttheme={{\n\t\t\t\t\t\t\tbrand: 'neutral',\n\t\t\t\t\t\t\tvariant: 'secondary',\n\t\t\t\t\t\t\tbackground: 'light',\n\t\t\t\t\t\t}}\n\t\t\t\t\t\tonClick={() => setIsClipped(true)}\n\t\t\t\t\t/>\n\t\t\t\t))}\n\t\t\t{categories && categories.length > 1 && (\n\t\t\t\t<Legend className={s.legend} keys={categories} />\n\t\t\t)}\n\t\t</div>\n\t)\n}\n\nfunction getDatasetTotal(values: Dataset['values']): number {\n\tconst totalObj = values.reduce(\n\t\t(a, b) => {\n\t\t\treturn { value: a.value + b.value, color: '' }\n\t\t},\n\t\t{\n\t\t\tvalue: 0,\n\t\t\tcolor: '',\n\t\t}\n\t)\n\n\treturn totalObj.value\n}\n"],"names":["HorizontalBarChart","categories","datasets","maxInitialDatasets","stacked","isStackable","useMediaQuery","initialClipped","isClipped","setIsClipped","useState","datasetsToDisplay","useMemo","highestValue","dataset","getDatasetTotal","valueSum","valueToReturn","value","jsxs","s","jsx","Balancer","classNames","color","barIndex","DatasetValue","Text","MDSButton","Legend","values","a","b"],"mappings":";;;;;;;;;;;AAwD2C,SAC1CA,EAAA;AAAA,EACA,YAAAC;AAAA,EAAA,UAAAC;AAAA;AAAA,EAGA,oBAAAC,IAAU;AAAA,EACX,SAAAC,IAAyC;AAMxC;AACA,QAAMC,IAAAC,EAA0B,oBAAS,GAKnCC,IAAYL,EAAY,SAAIC,GAE5B,CAAAK,GAAAC,CAAoB,IAAQC,EAAMH,CAAA,GACvCI,IAAmBC,EAAS,MACzBJ,IAAWN,EAAU,MAAA,GAAAC,CAAmB,IAAAD,GAS5C,CAAAM,GAAMN,GAAeC,CAAc,CAAA,GAC9BU,IAAAD,EAAgB,MAAA;AACpB;AACC,WAAAV,UAAa,CAAAY,MAAA;AAaZ,UAAAV;AAWA,kBAAiBW,EAAAD,EAAA,MAAA;AAChB,QAAAT,IACCW,IAAAC,MACDA,IAAAD,KAGCF,EAAI,OAAQ,QAAA,CAAA,EAAA,OAAAI,EAAe,MAAA;AAC1B,UAAAA,IAAAD,MACDA,IAAAC;AAAA,QAEF,CAAA;AAAA,MAOA;AACC,QAAAJ,EAAI,OAAQ,QAAA,CAAA,EAAA,OAAAI,EAAe,MAAA;AAC1B,UAAAA,IAAAD,MACDA,IAAAC;AAAA,QAEF,CAAA;AAAA,IAGD;EAGD,GAAA,CAAAhB,GAAAG,CACC,CAAA;AACC,SAAC,gBAAAc,EAAA,OAAI,EAAA,WAAaC,EAAA,UAChB;IAEC,gBAAAC,EAAA,OAAC,EAAA,aAAe,OAAE,UACjBV,aAAW,gBAAAQ,EAAA,OAAQ,aACpBC,EAAA,SAAA,UAAA;AAAA,MACA,gBAAAC,EAAA,OAAA,EAAA,WAAAD,EAAA,cAAA,UAAA,gBAAAC,EAAAC,GAAA,EAAA,UAAAR,EAAA,MAAA,CAAA,EAAA,CAAA;AAAA,MAAC,gBAAAK;AAAA,QAAA;AAAA,QAAA;AAAA,UACuC,WACnCI,EAAAH,EAAA,eAAuB;AAAA,YAC1B,CAAAA,EAAA,oBAAA,GAAAhB;AAAA,UAEA;UAAA,UAAQ;AAAA,YACRU,0BACC,OAAAU,EAAA,GAAAC,MAAC,gBAAAJ;AAAA,cAAAK;AAAA,cAAA;AAAA,gBAGA,OAAAR;AAAA,gBACA,cAAAL;AAAA,gBACA,OAAAW;AAAA,gBAAW,WAAApB;AAAA,cAJN;AAAA,cAKN,WAAAU,EAAA,KAAA,IAAAI,CAAA,IAAAO,CAAA;AAAA,YAED,CACA;AAAA,YAGErB,IAAC,gBAAAiB,EAAA,OAAK,EAAA,UAA+B,gBAAAF,EAAAQ,EAAA,MAAA,EAAM,MAAA,OAAA,KAAA,KAAA,WAAAP,EAAA,cAAA,UAAA;AAAA,cAC3C,gBAAAC,EAAA,QAAC,EAAA,WAAKD,EAAW,kBAAE,UACjB,SAAA,CAAA;AAAA,cAAQ,gBAAAD,uBAAyBC,EAAQ,qBAAM,UAAA;AAAA,gBAAEN,EAAA,SAAAC,EAAAD,EAAA,MAAA;AAAA,gBAAA;AAAA,cACnD;YAGC,EAAA,CAAA,EAAA,CAAA,IAAA;AAAA,UAAA;AAAA,QAAA;AAAA,MACL;AAAA,IAIF,EAAA,GAAAA,EAAA,MACC,EAAA,CAAA;AAAA,IACAP,MAACC,IAAA,gBAAAa;AAAA,MAAAO;AAAA,MAAA;AAAA,QAEA,WAAMR,EAAA;AAAA,QACN,OAAO;AAAA,QAAA,OACN;AAAA,UACA,OAAA;AAAA,UACA;UACD,YAAA;AAAA,QACA;AAAA,QAAiC,SAAA,MAAAX,EAAA,EAAA;AAAA;IAGlC,IAAC,gBAAAY;AAAA,MAAAO;AAAA,MAAA;AAAA,QAEA,WAAMR,EAAA;AAAA,QACN,OAAO;AAAA,QAAA,OACN;AAAA,UACA,OAAA;AAAA,UACA;UACD,YAAA;AAAA,QACA;AAAA,QAAgC,SAAA,MAAAX,EAAA,EAAA;AAAA,MACjC;AAAA,IAED;AAAA,SAGFR,EAAA,SAAA,KAAA,gBAAAoB,EAAAQ,GAAA,EAAA,WAAAT,EAAA,QAAA,MAAAnB,EAAA,CAAA;AAAA,EAEF,EAAA,CAAA;AAEA;AACC,SAAMc,EAAWe,GAAO;AAWzB,SAVYA,EAAA;AAAA,IACT,CAAAC,GAAAC,OACD,EAAA,OAAAD,EAAA,QAAAC,EAAA,OAAA,OAAA,GAAA;AAAA,IACA;AAAA,MAEC,OAAO;AAAA,MAAA,OAAA;AAAA,IAET;AAAA,EAEA,EACD;;"}
@@ -0,0 +1,13 @@
1
+ import { jsx as s, jsxs as n } from "react/jsx-runtime";
2
+ import c from "classnames";
3
+ import e from "./style.module.css.js";
4
+ function t({ keys: r, className: m }) {
5
+ return /* @__PURE__ */ s("div", { className: c(e.legend, m), children: /* @__PURE__ */ s("div", { className: e.keyWrapper, children: r.map(({ label: a, color: d }) => /* @__PURE__ */ n("div", { className: e.key, children: [
6
+ /* @__PURE__ */ s("div", { className: e.dot, style: { background: d } }),
7
+ /* @__PURE__ */ s("span", { className: e.name, children: a })
8
+ ] }, a)) }) });
9
+ }
10
+ export {
11
+ t as default
12
+ };
13
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sources":["../../../../../../src/components/visualizations/bar-chart/horizontal-chart/legend/index.tsx"],"sourcesContent":["import classNames from 'classnames'\nimport s from './style.module.css'\n\ninterface Key {\n\tlabel: string\n\tcolor: string\n}\n\ninterface LegendProps {\n\tclassName?: string\n\tkeys: Array<Key>\n}\n\nexport default function Legend({ keys, className }: LegendProps) {\n\treturn (\n\t\t<div className={classNames(s.legend, className)}>\n\t\t\t<div className={s.keyWrapper}>\n\t\t\t\t{keys.map(({ label, color }: Key) => {\n\t\t\t\t\treturn (\n\t\t\t\t\t\t<div className={s.key} key={label}>\n\t\t\t\t\t\t\t<div className={s.dot} style={{ background: color }} />\n\t\t\t\t\t\t\t<span className={s.name}>{label}</span>\n\t\t\t\t\t\t</div>\n\t\t\t\t\t)\n\t\t\t\t})}\n\t\t\t</div>\n\t\t</div>\n\t)\n}\n"],"names":["Legend","keys","className","classNames","s","jsx","label","color","jsxs"],"mappings":";;;AAaA,SAAwBA,EAAO,EAAE,MAAAC,GAAM,WAAAC,KAA0B;AAChE,2BACE,OAAA,EAAI,WAAWC,EAAWC,EAAE,QAAQF,CAAS,GAC7C,UAAA,gBAAAG,EAAC,SAAI,WAAWD,EAAE,YAChB,UAAAH,EAAK,IAAI,CAAC,EAAE,OAAAK,GAAO,OAAAC,QAElB,gBAAAC,EAAC,OAAA,EAAI,WAAWJ,EAAE,KACjB,UAAA;AAAA,IAAA,gBAAAC,EAAC,OAAA,EAAI,WAAWD,EAAE,KAAK,OAAO,EAAE,YAAYG,KAAS;AAAA,IACrD,gBAAAF,EAAC,QAAA,EAAK,WAAWD,EAAE,MAAO,UAAAE,EAAA,CAAM;AAAA,EAAA,EAAA,GAFLA,CAG5B,CAED,GACF,GACD;AAEF;"}
@@ -0,0 +1,14 @@
1
+ const e = "keyWrapper__g36GJ", a = "key__EbmRa", o = "dot__S1lki", t = "name__L7cad mds-typography-body-200", p = {
2
+ keyWrapper: e,
3
+ key: a,
4
+ dot: o,
5
+ name: t
6
+ };
7
+ export {
8
+ p as default,
9
+ o as dot,
10
+ a as key,
11
+ e as keyWrapper,
12
+ t as name
13
+ };
14
+ //# sourceMappingURL=style.module.css.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"style.module.css.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;"}
@@ -0,0 +1,28 @@
1
+ const t = "barChart__uC3IV", a = "chart__uI9kg", e = "dataset__13eXi", s = "datasetLabel__HjzY7 mds-typography-body-200", o = "datasetValues__HZ-9o", d = "datasetValuesStacked__og5RC", l = "datasetTotal__0BJyu", _ = "datasetTotalText__-0bYa", c = "datasetTotalPercent__vCmWD", n = "showAllButton__bY4-d", r = "legend__-b7yq", u = {
2
+ barChart: t,
3
+ chart: a,
4
+ dataset: e,
5
+ datasetLabel: s,
6
+ datasetValues: o,
7
+ datasetValuesStacked: d,
8
+ datasetTotal: l,
9
+ datasetTotalText: _,
10
+ datasetTotalPercent: c,
11
+ showAllButton: n,
12
+ legend: r
13
+ };
14
+ export {
15
+ t as barChart,
16
+ a as chart,
17
+ e as dataset,
18
+ s as datasetLabel,
19
+ l as datasetTotal,
20
+ c as datasetTotalPercent,
21
+ _ as datasetTotalText,
22
+ o as datasetValues,
23
+ d as datasetValuesStacked,
24
+ u as default,
25
+ r as legend,
26
+ n as showAllButton
27
+ };
28
+ //# sourceMappingURL=style.module.css.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"style.module.css.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;"}
@@ -0,0 +1,37 @@
1
+ "use client";
2
+ import { jsx as a, jsxs as n } from "react/jsx-runtime";
3
+ import c from "./horizontal-chart/index.js";
4
+ import { useTabsContext as m } from "../../tabs/use-tabs-context.js";
5
+ import { Tabs as s } from "../../tabs/index.js";
6
+ import h from "classnames";
7
+ import i from "./style.module.css.js";
8
+ const p = ({ data: e }) => /* @__PURE__ */ a("div", { className: i.root, children: e.length > 1 ? /* @__PURE__ */ n(s.Provider, { size: "large", children: [
9
+ /* @__PURE__ */ a(s.TabList, { children: e.map((r, t) => /* @__PURE__ */ a(s.Tab, { className: i.tab, children: r.name }, t)) }),
10
+ /* @__PURE__ */ a(b, { data: e })
11
+ ] }) : /* @__PURE__ */ a(l, { data: e }) });
12
+ p.displayName = "BarChart";
13
+ const b = ({ data: e }) => {
14
+ const { selectedTabIndex: r, tabIds: t } = m(), o = t[r];
15
+ return /* @__PURE__ */ a(l, { tabId: o, data: e, chartIndex: r });
16
+ }, l = ({ tabId: e, data: r, chartIndex: t = 0 }) => {
17
+ const o = r[t].name;
18
+ return /* @__PURE__ */ n(
19
+ "figure",
20
+ {
21
+ className: h(i.chartContainer, r.length > 1 && i.multiple),
22
+ id: o.toLowerCase(),
23
+ role: "tabpanel",
24
+ tabIndex: 0,
25
+ "aria-label": e ? void 0 : o,
26
+ "aria-labelledby": e || void 0,
27
+ children: [
28
+ /* @__PURE__ */ a(c, { ...r[t] }),
29
+ /* @__PURE__ */ a("div", { className: i.chart, children: r[t].caption && /* @__PURE__ */ a("figcaption", { className: i.caption, children: r[t].caption }) })
30
+ ]
31
+ }
32
+ );
33
+ };
34
+ export {
35
+ p as BarChart
36
+ };
37
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sources":["../../../../src/components/visualizations/bar-chart/index.tsx"],"sourcesContent":["'use client'\n\nimport HorizontalBarChart, {\n\ttype HorizontalBarChartProps,\n} from './horizontal-chart'\nimport { useTabsContext } from '../../tabs/use-tabs-context'\nimport { Tabs } from '../../tabs'\nimport classNames from 'classnames'\nimport s from './style.module.css'\n\ninterface HorizontalBarChart extends HorizontalBarChartProps {\n\tname: string\n\tcaption: string\n}\n\nexport interface BarChartProps {\n\tdata: HorizontalBarChart[]\n}\n\nexport const BarChart = ({ data }: BarChartProps) => {\n\treturn (\n\t\t<div className={s.root}>\n\t\t\t{data.length > 1 ? (\n\t\t\t\t<Tabs.Provider size=\"large\">\n\t\t\t\t\t<Tabs.TabList>\n\t\t\t\t\t\t{data.map((chart, i) => (\n\t\t\t\t\t\t\t<Tabs.Tab key={i} className={s.tab}>\n\t\t\t\t\t\t\t\t{chart.name}\n\t\t\t\t\t\t\t</Tabs.Tab>\n\t\t\t\t\t\t))}\n\t\t\t\t\t</Tabs.TabList>\n\t\t\t\t\t<BarChartPanelWithTabCtx data={data} />\n\t\t\t\t</Tabs.Provider>\n\t\t\t) : (\n\t\t\t\t<BarChartPanel data={data} />\n\t\t\t)}\n\t\t</div>\n\t)\n}\n\nBarChart.displayName = 'BarChart'\n\nconst BarChartPanelWithTabCtx = ({ data }: { data: BarChartProps['data'] }) => {\n\tconst { selectedTabIndex, tabIds } = useTabsContext()\n\n\tconst tabId = tabIds[selectedTabIndex]\n\n\treturn (\n\t\t<BarChartPanel tabId={tabId} data={data} chartIndex={selectedTabIndex} />\n\t)\n}\n\ninterface BarChartPanelProps {\n\ttabId?: string\n\tdata: BarChartProps['data']\n\tchartIndex?: number\n}\n\nconst BarChartPanel = ({ tabId, data, chartIndex = 0 }: BarChartPanelProps) => {\n\tconst chartName = data[chartIndex].name\n\n\treturn (\n\t\t<figure\n\t\t\tclassName={classNames(s.chartContainer, data.length > 1 && s.multiple)}\n\t\t\tid={chartName.toLowerCase()}\n\t\t\trole=\"tabpanel\"\n\t\t\ttabIndex={0}\n\t\t\taria-label={tabId ? undefined : chartName}\n\t\t\taria-labelledby={tabId || undefined}\n\t\t>\n\t\t\t<HorizontalBarChart {...data[chartIndex]} />\n\t\t\t<div className={s.chart}>\n\t\t\t\t{data[chartIndex].caption && (\n\t\t\t\t\t<figcaption className={s.caption}>\n\t\t\t\t\t\t{data[chartIndex].caption}\n\t\t\t\t\t</figcaption>\n\t\t\t\t)}\n\t\t\t</div>\n\t\t</figure>\n\t)\n}\n"],"names":["BarChart","data","jsx","jsxs","Tabs","chart","i","s","BarChartPanelWithTabCtx","BarChartPanel","selectedTabIndex","useTabsContext","tabId","tabIds","chartIndex","classNames","chartName","HorizontalBarChart"],"mappings":";;;;;;;AAoBC,MAAAA,IAAA,CAAA,EAAA,MAAAC,EACC,MAGI,gBAAAC,EAAK,OAAA,EAAL,mBACM,UAAYD,EAAA,SAAA,IACX,gBAAAE,EAAYC,EAAA,UAAa,EAC7B,MAAA,mBACF;AAAA,EAGF,gBAAAF,EAACE,EAAA,SAAA,EAAA,YAAwB,IAAY,CAAAC,GAAAC,MAAA,gBAAAJ,EAAAE,EAAA,KAAA,EAAA,WAAAG,EAAA,KAAA,UAAAF,EAAA,KAAA,GAAAC,CAAA,CAAA,EAAA,CAAA;AAAA,EACtC,gBAAAJ,EAAAM,GAEe,EAAA,MAAAP,EAEjB,CAAA;AAEF,EAAA,CAAA,IAAA,gBAAAC,EAAAO,GAAA,EAAA,MAAAR,EAAA,CAAA,EAAA,CAAA;AAIAD;AACC,MAAAQ,OAA0B,MAAAP;AAE1B,QAAM,EAAA,kBAAAS,iBAA+BC,EAAA,GAErCC,IAAAC,EAAAH,CACE;AAEH,SAAA,gBAAAR,EAAAO,GAAA,EAAA,OAAAG,GAAA,MAAAX,GAAA,YAAAS,EAAA,CAAA;AAQA,GACCD,IAAkB,CAAA,EAAK,OAAAG,GAAA,MAAAX,GAAY,YAAAa,IAAA,EAAA,MAAA;AAEnC,cACCA,CAAA,EAAA;AAAA,SAAC,gBAAAX;AAAA,IAAA;AAAA,IAAA;AAAA,MAEA,WAAIY,oBAAsBd,EAAA,SAAA,KAAAM,EAAA,QAAA;AAAA,MAC1B,IAAAS,EAAK,YAAA;AAAA,MACL,MAAA;AAAA,MACA;MACA,cAAAJ,IAAiB,SAASI;AAAA,MAE1B,mBAAAJ,KAAA;AAAA,MAAA,UAAA;AAAA,0BACCK,GAAe,EAAE,GAAAhB,GAChB,EAAA,CAAA;AAAA,QAKF,gBAAAC,EAAA,OAAA,EAAA,WAAAK,EAAA,OAAA,UAAAN,EAAAa,CAAA,EAAA,WAAA,gBAAAZ,EAAA,cAAA,EAAA,WAAAK,EAAA,SAAA,UAAAN,EAAAa,CAAA,EAAA,QAAA,CAAA,EAAA,CAAA;AAAA,MAAA;AAAA,IACD;AAAA,EAEF;;"}
@@ -0,0 +1,12 @@
1
+ const t = "chartContainer__6A5KV", n = "multiple__rU9qF", a = "caption__F3uLb", o = {
2
+ chartContainer: t,
3
+ multiple: n,
4
+ caption: a
5
+ };
6
+ export {
7
+ a as caption,
8
+ t as chartContainer,
9
+ o as default,
10
+ n as multiple
11
+ };
12
+ //# sourceMappingURL=style.module.css.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"style.module.css.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;"}
@@ -0,0 +1,14 @@
1
+ import { jsx as a, jsxs as e } from "react/jsx-runtime";
2
+ import l from "./styles.module.css.js";
3
+ const i = (r) => /* @__PURE__ */ a("div", { className: l.container, children: /* @__PURE__ */ e("div", { className: l.label, children: [
4
+ r.datum.label,
5
+ ": ",
6
+ /* @__PURE__ */ e("strong", { children: [
7
+ r.datum.value,
8
+ "%"
9
+ ] })
10
+ ] }) });
11
+ export {
12
+ i as renderArcTooltip
13
+ };
14
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sources":["../../../../../../src/components/visualizations/donut-chart/components/arc-tooltip/index.tsx"],"sourcesContent":["import type { FC } from 'react'\nimport type { DefaultRawDatum, PieTooltipProps } from '@nivo/pie'\nimport s from './styles.module.css'\n\nexport const renderArcTooltip: FC<PieTooltipProps<DefaultRawDatum>> = (d) => (\n\t<div className={s.container}>\n\t\t<div className={s.label}>\n\t\t\t{d.datum.label}: <strong>{d.datum.value}%</strong>\n\t\t</div>\n\t</div>\n)\n"],"names":["renderArcTooltip","d","jsx","s","jsxs"],"mappings":";;AAIO,MAAMA,IAAyD,CAACC,MACtE,gBAAAC,EAAC,OAAA,EAAI,WAAWC,EAAE,WACjB,UAAA,gBAAAC,EAAC,OAAA,EAAI,WAAWD,EAAE,OAChB,UAAA;AAAA,EAAAF,EAAE,MAAM;AAAA,EAAM;AAAA,oBAAG,UAAA,EAAQ,UAAA;AAAA,IAAAA,EAAE,MAAM;AAAA,IAAM;AAAA,EAAA,EAAA,CAAC;AAAA,EAAA,CAC1C,EAAA,CACD;"}
@@ -0,0 +1,10 @@
1
+ const n = "container__BPIK5", a = "label__oFZK-", e = {
2
+ container: n,
3
+ label: a
4
+ };
5
+ export {
6
+ n as container,
7
+ e as default,
8
+ a as label
9
+ };
10
+ //# sourceMappingURL=styles.module.css.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"styles.module.css.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;"}
@@ -0,0 +1,58 @@
1
+ "use client";
2
+ import { jsxs as r, jsx as t } from "react/jsx-runtime";
3
+ import { useRef as a, useState as h, useEffect as m } from "react";
4
+ import { animated as s } from "@react-spring/web";
5
+ import n from "./styles.module.css.js";
6
+ const l = 180, g = (e) => {
7
+ const i = a(null), [o, c] = h(0);
8
+ return m(() => {
9
+ i.current && c(i.current.offsetHeight);
10
+ }, []), /* @__PURE__ */ r(s.g, { opacity: e.style.opacity, children: [
11
+ /* @__PURE__ */ t(
12
+ s.path,
13
+ {
14
+ fill: "none",
15
+ d: e.style.path,
16
+ stroke: e.style.linkColor,
17
+ strokeWidth: e.style.thickness
18
+ }
19
+ ),
20
+ /* @__PURE__ */ t(
21
+ s.g,
22
+ {
23
+ transform: e.style.textPosition,
24
+ textAnchor: e.style.textAnchor,
25
+ className: n.containerWrapper,
26
+ children: /* @__PURE__ */ t(
27
+ "g",
28
+ {
29
+ className: n.container,
30
+ style: {
31
+ "--container-width": `${l}px`,
32
+ "--container-height": `${o}px`
33
+ },
34
+ children: /* @__PURE__ */ t(
35
+ "foreignObject",
36
+ {
37
+ dominantBaseline: "central",
38
+ width: l,
39
+ height: o,
40
+ children: /* @__PURE__ */ r("div", { ref: i, className: n.lockup, children: [
41
+ /* @__PURE__ */ r("div", { className: n.value, children: [
42
+ e.datum.value,
43
+ "%"
44
+ ] }),
45
+ /* @__PURE__ */ t("div", { className: n.label, children: e.datum.label })
46
+ ] })
47
+ }
48
+ )
49
+ }
50
+ )
51
+ }
52
+ )
53
+ ] });
54
+ };
55
+ export {
56
+ g as useRenderArcLinkLabelComponent
57
+ };
58
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sources":["../../../../../../src/components/visualizations/donut-chart/components/external-arc-label/index.tsx"],"sourcesContent":["'use client'\n\nimport { useEffect, useRef, useState } from 'react'\nimport { animated } from '@react-spring/web'\nimport type { ComputedDatum, DefaultRawDatum } from '@nivo/pie'\nimport type { ArcLinkLabelComponent } from '@nivo/arcs'\nimport s from './styles.module.css'\n\nconst FOREIGN_OBJECT_WIDTH = 180\n\nexport const useRenderArcLinkLabelComponent: typeof ArcLinkLabelComponent<\n\tComputedDatum<DefaultRawDatum>\n> = (d) => {\n\tconst lockupRef = useRef<HTMLDivElement>(null)\n\tconst [foreignObjectHeight, setForeignObjectHeight] = useState(0)\n\n\tuseEffect(() => {\n\t\tif (lockupRef.current) {\n\t\t\tsetForeignObjectHeight(lockupRef.current.offsetHeight)\n\t\t}\n\t}, [])\n\n\treturn (\n\t\t<animated.g opacity={d.style.opacity}>\n\t\t\t<animated.path\n\t\t\t\tfill=\"none\"\n\t\t\t\td={d.style.path}\n\t\t\t\tstroke={d.style.linkColor}\n\t\t\t\tstrokeWidth={d.style.thickness}\n\t\t\t/>\n\t\t\t<animated.g\n\t\t\t\ttransform={d.style.textPosition}\n\t\t\t\ttextAnchor={d.style.textAnchor}\n\t\t\t\tclassName={s.containerWrapper}\n\t\t\t>\n\t\t\t\t<g\n\t\t\t\t\tclassName={s.container}\n\t\t\t\t\tstyle={{\n\t\t\t\t\t\t['--container-width' as string]: `${FOREIGN_OBJECT_WIDTH}px`,\n\t\t\t\t\t\t['--container-height' as string]: `${foreignObjectHeight}px`,\n\t\t\t\t\t}}\n\t\t\t\t>\n\t\t\t\t\t<foreignObject\n\t\t\t\t\t\tdominantBaseline=\"central\"\n\t\t\t\t\t\twidth={FOREIGN_OBJECT_WIDTH}\n\t\t\t\t\t\theight={foreignObjectHeight}\n\t\t\t\t\t>\n\t\t\t\t\t\t<div ref={lockupRef} className={s.lockup}>\n\t\t\t\t\t\t\t<div className={s.value}>{d.datum.value}%</div>\n\t\t\t\t\t\t\t<div className={s.label}>{d.datum.label}</div>\n\t\t\t\t\t\t</div>\n\t\t\t\t\t</foreignObject>\n\t\t\t\t</g>\n\t\t\t</animated.g>\n\t\t</animated.g>\n\t)\n}\n"],"names":["FOREIGN_OBJECT_WIDTH","d","lockupRef","useRef","foreignObjectHeight","setForeignObjectHeight","useState","useEffect","jsxs","animated","jsx","s"],"mappings":";;;;;AAUO,MAAMA,IAAA,SAGiC,CAAAC,MAAA;AAC7C,QAAMC,IAACC,EAAA,IAAqB,GAE5B,CAAAC,GAAgBC,CAAA,IAAAC,EAAA,CAAA;AACf,SAAAC,EAAI,MAAU;AACb,iBACDF,EAAAH,EAAA,QAAA,YAAA;AAAA,EAGD,QAEE,gBAAAM,EAAAC,EAAA,GAAA,EAAA,SAAAR,EAAA,MAAA,SAAA,UAAA;AAAA,IAAU,gBAAAS;AAAA,MAATD,EAAA;AAAA,MAAA;AAAA,QAEA,MAAK;AAAA,QACL,WAAU;AAAA,QACV,QAAAR,EAAA;QAAqB,aAAAA,EAAA,MAAA;AAAA,MACtB;AAAA,IAAA;AAAA,IACU,gBAAAS;AAAA,MAATD,EAAA;AAAA,MAAA;AAAA,QAEA,WAAAR,QAAc;AAAA,QACd,YAAWA,EAAE,MAAA;AAAA,QAEb;QAAA,UAAC,gBAAAS;AAAA,UAAA;AAAA,UAAA;AAAA,YAEA,WAAOC,EAAA;AAAA,YAAA;cAEL,qBAA8B,GAAGX,CAAsB;AAAA,cACzD,sBAAA,GAAAI,CAAA;AAAA,YAEA;AAAA,YAAA,UAAC,gBAAAM;AAAA,cAAA;AAAA,cAAA;AAAA,gBAEA,kBAAO;AAAA,gBACP;gBAEA;gBACC,UAAC,gBAAAF,EAAA,OAAI,EAAA,KAAaN,GAAQ,WAAAS,EAAA,QAAA,UAAA;AAAA,kBAAQ,gBAAAH,EAAA,OAAA,EAAA,WAAAG,EAAA,OAAA,UAAA;AAAA,oBAAMV,EAAA,MAAA;AAAA;kBAAC,EAAA,CAAA;AAAA,kBAE1C,gBAAAS,EAAA,OAAA,EAAA,WAAAC,EAAA,OAAA,UAAAV,EAAA,MAAA,MAAA,CAAA;AAAA,gBAAA,EAAA,CAAA;AAAA,cAAA;AAAA,YACD;AAAA,UAAA;AAAA,QACD;AAAA,MAAA;AAAA;EAIJ,EAAA,CAAA;;"}
@@ -0,0 +1,16 @@
1
+ const a = "containerWrapper__L6jJb", n = "container__0ahUu", e = "lockup__7l75G", o = "value__AL9Ol", c = "label__oG0LT", l = {
2
+ containerWrapper: a,
3
+ container: n,
4
+ lockup: e,
5
+ value: o,
6
+ label: c
7
+ };
8
+ export {
9
+ n as container,
10
+ a as containerWrapper,
11
+ l as default,
12
+ c as label,
13
+ e as lockup,
14
+ o as value
15
+ };
16
+ //# sourceMappingURL=styles.module.css.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"styles.module.css.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;"}
@@ -0,0 +1,42 @@
1
+ "use client";
2
+ import { jsxs as s, Fragment as h, jsx as e } from "react/jsx-runtime";
3
+ import { useRef as g, useState as c, useEffect as d } from "react";
4
+ import { animated as a } from "@react-spring/web";
5
+ import p from "classnames";
6
+ import o from "./styles.module.css.js";
7
+ import { getContrastYIQ as u, hexToRgb as b } from "../../../../../utils/get-contrast-yiq.js";
8
+ const C = (t) => {
9
+ const r = g(null), [i, l] = c(0), [n, m] = c(0);
10
+ d(() => {
11
+ r.current && (l(r.current.offsetWidth), m(r.current.offsetHeight));
12
+ }, []);
13
+ const f = u(b(t.datum.color));
14
+ return /* @__PURE__ */ s(h, { children: [
15
+ /* @__PURE__ */ e("path", {}),
16
+ /* @__PURE__ */ e(a.g, { transform: t.style.transform, opacity: t.style.progress, children: /* @__PURE__ */ e(
17
+ "g",
18
+ {
19
+ className: o.container,
20
+ style: {
21
+ "--container-width": `${i}px`,
22
+ "--container-height": `${n}px`
23
+ },
24
+ children: /* @__PURE__ */ e(
25
+ a.foreignObject,
26
+ {
27
+ width: i,
28
+ height: n,
29
+ children: /* @__PURE__ */ e("div", { className: p(o.label, o[f]), children: /* @__PURE__ */ s("div", { ref: r, children: [
30
+ t.datum.value,
31
+ "%"
32
+ ] }) })
33
+ }
34
+ )
35
+ }
36
+ ) })
37
+ ] });
38
+ };
39
+ export {
40
+ C as useRenderArcLabelComponent
41
+ };
42
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sources":["../../../../../../src/components/visualizations/donut-chart/components/internal-arc-label/index.tsx"],"sourcesContent":["'use client'\n\nimport { useEffect, useRef, useState } from 'react'\nimport { animated } from '@react-spring/web'\nimport type { ComputedDatum, DefaultRawDatum } from '@nivo/pie'\nimport type { ArcLabelComponent } from '@nivo/arcs'\nimport classNames from 'classnames'\nimport s from './styles.module.css'\nimport { getContrastYIQ, hexToRgb } from '../../../../../utils/get-contrast-yiq'\n\nexport const useRenderArcLabelComponent: typeof ArcLabelComponent<\n\tComputedDatum<DefaultRawDatum>\n> = (d) => {\n\tconst labelRef = useRef<HTMLDivElement>(null)\n\tconst [foreignObjectWidth, setForeignObjectWidth] = useState(0)\n\tconst [foreignObjectHeight, setForeignObjectHeight] = useState(0)\n\n\tuseEffect(() => {\n\t\tif (labelRef.current) {\n\t\t\tsetForeignObjectWidth(labelRef.current.offsetWidth)\n\t\t\tsetForeignObjectHeight(labelRef.current.offsetHeight)\n\t\t}\n\t}, [])\n\n\tconst textColor = getContrastYIQ(hexToRgb(d.datum.color))\n\treturn (\n\t\t<>\n\t\t\t<path />\n\t\t\t<animated.g transform={d.style.transform} opacity={d.style.progress}>\n\t\t\t\t<g\n\t\t\t\t\tclassName={s.container}\n\t\t\t\t\tstyle={{\n\t\t\t\t\t\t['--container-width' as string]: `${foreignObjectWidth}px`,\n\t\t\t\t\t\t['--container-height' as string]: `${foreignObjectHeight}px`,\n\t\t\t\t\t}}\n\t\t\t\t>\n\t\t\t\t\t<animated.foreignObject\n\t\t\t\t\t\twidth={foreignObjectWidth}\n\t\t\t\t\t\theight={foreignObjectHeight}\n\t\t\t\t\t>\n\t\t\t\t\t\t<div className={classNames(s.label, s[textColor])}>\n\t\t\t\t\t\t\t<div ref={labelRef}>{d.datum.value}%</div>\n\t\t\t\t\t\t</div>\n\t\t\t\t\t</animated.foreignObject>\n\t\t\t\t</g>\n\t\t\t</animated.g>\n\t\t</>\n\t)\n}\n"],"names":["d","labelRef","useRef","foreignObjectWidth","setForeignObjectWidth","useState","foreignObjectHeight","setForeignObjectHeight","useEffect","jsxs","Fragment","jsx","animated","s","classNames","textColor"],"mappings":";;;;;;;AAaC,UAA4C,CAAAA,MAAA;AAC5C,QAAMC,IAACC,EAAA,IAAoB,GACrB,CAACC,GAAAC,CAAqB,IAAsBC,EAAI,IAEtD,CAAAC,GAAgBC,CAAA,IAAAF,EAAA,CAAA;AACf,EAAAG,EAAI,MAAS;AACZ,kBACAJ,EAAAH,EAAuB,sBACxBM,EAAAN,EAAA,QAAA,YAAA;AAAA,EAGD,GAAA,CAAA,CAAA;AACA,wBAEE,KAAA,CAAA;AAAA,SAAC,gBAAAQ,EAAAC,GAAK,EAAA,UAAA;AAAA,IACN,gBAAAC,EAAC,QAAA,CAAS,CAAA;AAAA,IACR,gBAAAA,EAAAC,EAAA,GAAA,EAAA,WAAAZ,EAAA,MAAA,WAAA,SAAAA,EAAA,MAAA,UAAA,UAAA,gBAAAW;AAAA,MAAA;AAAA,MAAA;AAAA,QAEA,WAAOE,EAAA;AAAA,QAAA;UAEL,qBAA8B,GAAGV,CAAG;AAAA,UACtC,sBAAA,GAAAG,CAAA;AAAA,QAEA;AAAA,QAAA,UAAU,gBAAAK;AAAA,UAATC,EAAA;AAAA,UAAA;AAAA,YAEA;YAEA,QAAAN;AAAA,YACsB,UAAQ,gBAAAK,EAAA,OAAA,EAAA,WAAAG,EAAAD,EAAA,OAAAA,EAAAE,CAAA,CAAA,GAAA,UAAA,gBAAAN,EAAA,OAAA,EAAA,KAAAR,GAAA,UAAA;AAAA,cAAMD,EAAA,MAAA;AAAA,cAAA;AAAA,YACpC,EAAA,CAAA,EAAA,CAAA;AAAA,UAAA;AAAA,QACD;AAAA,MACD;AAAA,MAEF,CAAA;AAAA,EAEF,EAAA,CAAA;;"}
@@ -0,0 +1,14 @@
1
+ const t = "container__zNSm3", a = "label__lanZz", l = "light__cA0lL", n = "dark__tX3sL", c = {
2
+ container: t,
3
+ label: a,
4
+ light: l,
5
+ dark: n
6
+ };
7
+ export {
8
+ t as container,
9
+ n as dark,
10
+ c as default,
11
+ a as label,
12
+ l as light
13
+ };
14
+ //# sourceMappingURL=styles.module.css.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"styles.module.css.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;"}