@watermarkinsights/ripple 3.27.0 → 3.27.1

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 (277) hide show
  1. package/README.md +3 -3
  2. package/dist/cjs/{chartFunctions-b2e0cb4e.js → chartFunctions-42cfb4d3.js} +596 -596
  3. package/dist/cjs/{functions-9807717e.js → functions-85c3c557.js} +498 -498
  4. package/dist/cjs/{global-42a24725.js → global-9982752f.js} +72 -72
  5. package/dist/cjs/{http-service-9e8c4dd5.js → http-service-494d81de.js} +49 -49
  6. package/dist/cjs/{interfaces-30a74c1f.js → interfaces-a3338581.js} +29 -29
  7. package/dist/cjs/{intl-526c75ec.js → intl-1c36fe38.js} +131 -131
  8. package/dist/cjs/loader.cjs.js +1 -1
  9. package/dist/cjs/priv-chart-popover.cjs.entry.js +91 -91
  10. package/dist/cjs/priv-datepicker.cjs.entry.js +657 -657
  11. package/dist/cjs/priv-navigator-button.cjs.entry.js +19 -19
  12. package/dist/cjs/priv-navigator-item.cjs.entry.js +23 -23
  13. package/dist/cjs/ripple.cjs.js +1 -1
  14. package/dist/cjs/wm-action-menu_2.cjs.entry.js +334 -334
  15. package/dist/cjs/wm-button.cjs.entry.js +189 -189
  16. package/dist/cjs/wm-chart-slice.cjs.entry.js +18 -18
  17. package/dist/cjs/wm-chart.cjs.entry.js +183 -183
  18. package/dist/cjs/wm-datepicker.cjs.entry.js +263 -263
  19. package/dist/cjs/wm-file-list.cjs.entry.js +35 -35
  20. package/dist/cjs/wm-file.cjs.entry.js +181 -181
  21. package/dist/cjs/wm-input.cjs.entry.js +136 -136
  22. package/dist/cjs/wm-modal-footer.cjs.entry.js +33 -33
  23. package/dist/cjs/wm-modal-header.cjs.entry.js +32 -32
  24. package/dist/cjs/wm-modal.cjs.entry.js +152 -152
  25. package/dist/cjs/wm-navigation_3.cjs.entry.js +186 -186
  26. package/dist/cjs/wm-navigator.cjs.entry.js +264 -264
  27. package/dist/cjs/wm-network-uploader.cjs.entry.js +465 -465
  28. package/dist/cjs/wm-option_2.cjs.entry.js +768 -768
  29. package/dist/cjs/wm-pagination.cjs.entry.js +179 -179
  30. package/dist/cjs/wm-progress-indicator_3.cjs.entry.js +155 -155
  31. package/dist/cjs/wm-search.cjs.entry.js +184 -184
  32. package/dist/cjs/wm-snackbar.cjs.entry.js +134 -134
  33. package/dist/cjs/wm-tab-item_3.cjs.entry.js +264 -264
  34. package/dist/cjs/wm-tag-input-row.cjs.entry.js +14 -14
  35. package/dist/cjs/wm-tag-input.cjs.entry.js +948 -941
  36. package/dist/cjs/wm-timepicker.cjs.entry.js +385 -385
  37. package/dist/cjs/wm-toggletip.cjs.entry.js +120 -120
  38. package/dist/cjs/wm-uploader.cjs.entry.js +441 -441
  39. package/dist/cjs/wm-wrapper.cjs.entry.js +12 -12
  40. package/dist/collection/components/charts/chartFunctions.js +562 -562
  41. package/dist/collection/components/charts/priv-chart-popover/priv-chart-popover.js +267 -267
  42. package/dist/collection/components/charts/wm-chart/wm-chart-slice.js +125 -125
  43. package/dist/collection/components/charts/wm-chart/wm-chart.js +450 -450
  44. package/dist/collection/components/charts/wm-progress-monitor/wm-progress-indicator.js +207 -207
  45. package/dist/collection/components/charts/wm-progress-monitor/wm-progress-monitor.js +143 -143
  46. package/dist/collection/components/charts/wm-progress-monitor/wm-progress-slice.js +121 -121
  47. package/dist/collection/components/wm-action-menu/wm-action-menu.js +472 -472
  48. package/dist/collection/components/wm-button/wm-button.js +486 -486
  49. package/dist/collection/components/wm-datepicker/priv-datepicker/priv-datepicker.js +983 -983
  50. package/dist/collection/components/wm-datepicker/wm-datepicker.js +491 -491
  51. package/dist/collection/components/wm-file/wm-file.js +313 -313
  52. package/dist/collection/components/wm-file-list/wm-file-list.js +152 -152
  53. package/dist/collection/components/wm-input/wm-input.js +509 -509
  54. package/dist/collection/components/wm-menuitem/wm-menuitem.js +454 -454
  55. package/dist/collection/components/wm-modal/wm-modal-footer.js +138 -138
  56. package/dist/collection/components/wm-modal/wm-modal-header.js +82 -82
  57. package/dist/collection/components/wm-modal/wm-modal.js +462 -462
  58. package/dist/collection/components/wm-navigation/wm-navigation-hamburger.js +119 -119
  59. package/dist/collection/components/wm-navigation/wm-navigation-item.js +130 -130
  60. package/dist/collection/components/wm-navigation/wm-navigation.js +217 -217
  61. package/dist/collection/components/wm-navigator/priv-navigator-button/priv-navigator-button.js +106 -106
  62. package/dist/collection/components/wm-navigator/priv-navigator-item/priv-navigator-item.js +123 -123
  63. package/dist/collection/components/wm-navigator/wm-navigator.js +467 -467
  64. package/dist/collection/components/wm-option/wm-option.js +435 -435
  65. package/dist/collection/components/wm-pagination/wm-pagination.js +362 -362
  66. package/dist/collection/components/wm-search/wm-search.js +439 -439
  67. package/dist/collection/components/wm-select/wm-select.js +1054 -1054
  68. package/dist/collection/components/wm-snackbar/wm-snackbar.js +267 -267
  69. package/dist/collection/components/wm-tabs/wm-tab-item/wm-tab-item.js +211 -211
  70. package/dist/collection/components/wm-tabs/wm-tab-list/wm-tab-list.js +327 -327
  71. package/dist/collection/components/wm-tabs/wm-tab-panel/wm-tab-panel.js +108 -108
  72. package/dist/collection/components/wm-tag-input/wm-tag-input-row/wm-tag-input-row.js +122 -122
  73. package/dist/collection/components/wm-tag-input/wm-tag-input.css +21 -17
  74. package/dist/collection/components/wm-tag-input/wm-tag-input.js +1302 -1295
  75. package/dist/collection/components/wm-timepicker/wm-timepicker.js +605 -605
  76. package/dist/collection/components/wm-toggletip/wm-toggletip.js +243 -243
  77. package/dist/collection/components/wm-uploader/wm-network-uploader/wm-network-uploader.js +772 -772
  78. package/dist/collection/components/wm-uploader/wm-uploader.js +964 -964
  79. package/dist/collection/components/wm-wrapper/wm-wrapper.js +28 -28
  80. package/dist/collection/dev/scripts.js +20 -20
  81. package/dist/collection/global/__mocks__/functions.js +6 -6
  82. package/dist/collection/global/functions.js +541 -541
  83. package/dist/collection/global/global.js +79 -79
  84. package/dist/collection/global/interfaces.js +49 -49
  85. package/dist/collection/global/intl.js +132 -132
  86. package/dist/collection/global/services/__mocks__/http-service.js +130 -130
  87. package/dist/collection/global/services/http-service.js +50 -50
  88. package/dist/collection/lang/lang.js +5 -5
  89. package/dist/collection/lang/missing.js +43 -43
  90. package/dist/collection/lang/piglatin.js +93 -93
  91. package/dist/esm/{chartFunctions-dd9eb9ac.js → chartFunctions-0b53b301.js} +596 -596
  92. package/dist/esm/{functions-f32b1ca4.js → functions-cbb19d50.js} +498 -498
  93. package/dist/esm/{global-7ee0d78d.js → global-2c7bbfe6.js} +72 -72
  94. package/dist/esm/{http-service-5d037e16.js → http-service-3dc3b3e7.js} +49 -49
  95. package/dist/esm/{interfaces-61c6305b.js → interfaces-2b97fab2.js} +29 -29
  96. package/dist/esm/{intl-d101e1a9.js → intl-ffbca53d.js} +131 -131
  97. package/dist/esm/loader.js +1 -1
  98. package/dist/esm/polyfills/core-js.js +0 -0
  99. package/dist/esm/polyfills/dom.js +0 -0
  100. package/dist/esm/polyfills/es5-html-element.js +0 -0
  101. package/dist/esm/polyfills/index.js +0 -0
  102. package/dist/esm/polyfills/system.js +0 -0
  103. package/dist/esm/priv-chart-popover.entry.js +91 -91
  104. package/dist/esm/priv-datepicker.entry.js +657 -657
  105. package/dist/esm/priv-navigator-button.entry.js +19 -19
  106. package/dist/esm/priv-navigator-item.entry.js +23 -23
  107. package/dist/esm/ripple.js +1 -1
  108. package/dist/esm/wm-action-menu_2.entry.js +334 -334
  109. package/dist/esm/wm-button.entry.js +189 -189
  110. package/dist/esm/wm-chart-slice.entry.js +18 -18
  111. package/dist/esm/wm-chart.entry.js +183 -183
  112. package/dist/esm/wm-datepicker.entry.js +263 -263
  113. package/dist/esm/wm-file-list.entry.js +35 -35
  114. package/dist/esm/wm-file.entry.js +181 -181
  115. package/dist/esm/wm-input.entry.js +136 -136
  116. package/dist/esm/wm-modal-footer.entry.js +33 -33
  117. package/dist/esm/wm-modal-header.entry.js +32 -32
  118. package/dist/esm/wm-modal.entry.js +152 -152
  119. package/dist/esm/wm-navigation_3.entry.js +186 -186
  120. package/dist/esm/wm-navigator.entry.js +264 -264
  121. package/dist/esm/wm-network-uploader.entry.js +465 -465
  122. package/dist/esm/wm-option_2.entry.js +768 -768
  123. package/dist/esm/wm-pagination.entry.js +179 -179
  124. package/dist/esm/wm-progress-indicator_3.entry.js +155 -155
  125. package/dist/esm/wm-search.entry.js +184 -184
  126. package/dist/esm/wm-snackbar.entry.js +134 -134
  127. package/dist/esm/wm-tab-item_3.entry.js +264 -264
  128. package/dist/esm/wm-tag-input-row.entry.js +14 -14
  129. package/dist/esm/wm-tag-input.entry.js +948 -941
  130. package/dist/esm/wm-timepicker.entry.js +385 -385
  131. package/dist/esm/wm-toggletip.entry.js +120 -120
  132. package/dist/esm/wm-uploader.entry.js +441 -441
  133. package/dist/esm/wm-wrapper.entry.js +12 -12
  134. package/dist/esm-es5/{chartFunctions-dd9eb9ac.js → chartFunctions-0b53b301.js} +1 -1
  135. package/dist/esm-es5/{global-7ee0d78d.js → global-2c7bbfe6.js} +1 -1
  136. package/dist/esm-es5/{intl-d101e1a9.js → intl-ffbca53d.js} +1 -1
  137. package/dist/esm-es5/loader.js +1 -1
  138. package/dist/esm-es5/priv-chart-popover.entry.js +1 -1
  139. package/dist/esm-es5/priv-datepicker.entry.js +1 -1
  140. package/dist/esm-es5/ripple.js +1 -1
  141. package/dist/esm-es5/wm-action-menu_2.entry.js +1 -1
  142. package/dist/esm-es5/wm-button.entry.js +1 -1
  143. package/dist/esm-es5/wm-chart.entry.js +1 -1
  144. package/dist/esm-es5/wm-datepicker.entry.js +1 -1
  145. package/dist/esm-es5/wm-file.entry.js +1 -1
  146. package/dist/esm-es5/wm-input.entry.js +1 -1
  147. package/dist/esm-es5/wm-modal-header.entry.js +1 -1
  148. package/dist/esm-es5/wm-modal.entry.js +1 -1
  149. package/dist/esm-es5/wm-navigation_3.entry.js +1 -1
  150. package/dist/esm-es5/wm-navigator.entry.js +1 -1
  151. package/dist/esm-es5/wm-network-uploader.entry.js +1 -1
  152. package/dist/esm-es5/wm-option_2.entry.js +1 -1
  153. package/dist/esm-es5/wm-pagination.entry.js +1 -1
  154. package/dist/esm-es5/wm-progress-indicator_3.entry.js +1 -1
  155. package/dist/esm-es5/wm-search.entry.js +1 -1
  156. package/dist/esm-es5/wm-snackbar.entry.js +1 -1
  157. package/dist/esm-es5/wm-tab-item_3.entry.js +1 -1
  158. package/dist/esm-es5/wm-tag-input.entry.js +1 -1
  159. package/dist/esm-es5/wm-timepicker.entry.js +1 -1
  160. package/dist/esm-es5/wm-toggletip.entry.js +1 -1
  161. package/dist/esm-es5/wm-uploader.entry.js +1 -1
  162. package/dist/ripple/{p-725c14b0.system.entry.js → p-00022d17.system.entry.js} +1 -1
  163. package/dist/ripple/{p-b97de06f.system.entry.js → p-0450cdbe.system.entry.js} +1 -1
  164. package/dist/ripple/{p-bfe1062d.entry.js → p-05a17658.entry.js} +1 -1
  165. package/dist/ripple/p-0b6a7b77.system.entry.js +1 -0
  166. package/dist/ripple/{p-b6bf2866.entry.js → p-0e789be7.entry.js} +1 -1
  167. package/dist/ripple/{p-b617b64f.system.entry.js → p-15779c22.system.entry.js} +1 -1
  168. package/dist/ripple/{p-04faca6b.entry.js → p-17487f1b.entry.js} +1 -1
  169. package/dist/ripple/{p-122da0d1.system.entry.js → p-197c83de.system.entry.js} +1 -1
  170. package/dist/ripple/{p-11d98b00.system.entry.js → p-1bad4efe.system.entry.js} +1 -1
  171. package/dist/ripple/{p-252ba295.system.entry.js → p-2ff923ee.system.entry.js} +1 -1
  172. package/dist/ripple/{p-a6afe65a.entry.js → p-31712996.entry.js} +1 -1
  173. package/dist/ripple/{p-f69276d5.system.entry.js → p-31c18f5e.system.entry.js} +1 -1
  174. package/dist/ripple/{p-df28f438.system.js → p-32944b70.system.js} +1 -1
  175. package/dist/ripple/{p-73d277ba.system.entry.js → p-36effc40.system.entry.js} +1 -1
  176. package/dist/ripple/{p-0be94e77.entry.js → p-3807bcae.entry.js} +1 -1
  177. package/dist/ripple/{p-88d17f6b.system.entry.js → p-3aa48fad.system.entry.js} +1 -1
  178. package/dist/ripple/{p-82a97531.system.entry.js → p-419f133c.system.entry.js} +1 -1
  179. package/dist/ripple/{p-13ec8ac0.entry.js → p-438a1e8e.entry.js} +1 -1
  180. package/dist/ripple/{p-19689aac.js → p-4698b365.js} +1 -1
  181. package/dist/ripple/{p-f8d45250.system.entry.js → p-54086f7b.system.entry.js} +1 -1
  182. package/dist/ripple/{p-47f53321.entry.js → p-5497694c.entry.js} +1 -1
  183. package/dist/ripple/{p-fb370a69.entry.js → p-58fbf116.entry.js} +1 -1
  184. package/dist/ripple/{p-14dfc4e7.entry.js → p-65a741c1.entry.js} +1 -1
  185. package/dist/ripple/{p-ac63b3aa.entry.js → p-7e74274b.entry.js} +1 -1
  186. package/dist/ripple/{p-81752607.system.js → p-81ad3fe5.system.js} +1 -1
  187. package/dist/ripple/{p-f3e42327.system.entry.js → p-89db9c27.system.entry.js} +1 -1
  188. package/dist/ripple/{p-4753fbfc.system.entry.js → p-947f01e2.system.entry.js} +1 -1
  189. package/dist/ripple/{p-3aee75e7.entry.js → p-978429f9.entry.js} +1 -1
  190. package/dist/ripple/{p-2c8fd902.system.entry.js → p-97d5b4bd.system.entry.js} +1 -1
  191. package/dist/ripple/{p-67c0ad56.system.entry.js → p-9d6a574b.system.entry.js} +1 -1
  192. package/dist/ripple/{p-c545fe1c.entry.js → p-a3ba2bdd.entry.js} +1 -1
  193. package/dist/ripple/{p-c7567fd3.entry.js → p-a42f5231.entry.js} +1 -1
  194. package/dist/ripple/p-a51aec3f.entry.js +1 -0
  195. package/dist/ripple/{p-b831988d.entry.js → p-a5b86b47.entry.js} +1 -1
  196. package/dist/ripple/{p-4cadf985.entry.js → p-a90b8a08.entry.js} +1 -1
  197. package/dist/ripple/{p-d9b66dca.system.entry.js → p-aabe172c.system.entry.js} +1 -1
  198. package/dist/ripple/{p-69121ad1.entry.js → p-ab2a0aee.entry.js} +1 -1
  199. package/dist/ripple/{p-5fb0aa58.js → p-aed93a25.js} +1 -1
  200. package/dist/ripple/{p-f39ee84b.entry.js → p-b2d75e7d.entry.js} +1 -1
  201. package/dist/ripple/{p-19b897ce.js → p-b410c675.js} +1 -1
  202. package/dist/ripple/{p-4809e419.system.entry.js → p-b6f558f7.system.entry.js} +1 -1
  203. package/dist/ripple/p-bb048fe7.entry.js +1 -0
  204. package/dist/ripple/{p-2805fed6.system.entry.js → p-bced37cf.system.entry.js} +1 -1
  205. package/dist/ripple/{p-c9a1834d.system.entry.js → p-bd0c1e7c.system.entry.js} +1 -1
  206. package/dist/ripple/{p-89f1991f.entry.js → p-c0e183f4.entry.js} +1 -1
  207. package/dist/ripple/{p-7eca18bd.system.entry.js → p-c27eda00.system.entry.js} +1 -1
  208. package/dist/ripple/{p-894bc6c4.system.entry.js → p-cd3e0b8b.system.entry.js} +1 -1
  209. package/dist/ripple/{p-f6b2e4ac.system.js → p-d1af63b5.system.js} +1 -1
  210. package/dist/ripple/{p-30572b71.system.js → p-d41ba263.system.js} +1 -1
  211. package/dist/ripple/{p-db7e6e89.entry.js → p-d8993992.entry.js} +1 -1
  212. package/dist/ripple/{p-f13b239c.system.entry.js → p-da525ed1.system.entry.js} +1 -1
  213. package/dist/ripple/{p-33af1eee.entry.js → p-e6f46289.entry.js} +1 -1
  214. package/dist/ripple/{p-e928f350.entry.js → p-fc967b2c.entry.js} +1 -1
  215. package/dist/ripple/ripple.esm.js +1 -1
  216. package/dist/ripple/ripple.js +1 -1
  217. package/dist/types/components/charts/chartFunctions.d.ts +37 -37
  218. package/dist/types/components/charts/priv-chart-popover/priv-chart-popover.d.ts +27 -27
  219. package/dist/types/components/charts/wm-chart/wm-chart-slice.d.ts +11 -11
  220. package/dist/types/components/charts/wm-chart/wm-chart.d.ts +47 -47
  221. package/dist/types/components/charts/wm-progress-monitor/wm-progress-indicator.d.ts +29 -29
  222. package/dist/types/components/charts/wm-progress-monitor/wm-progress-monitor.d.ts +20 -20
  223. package/dist/types/components/charts/wm-progress-monitor/wm-progress-slice.d.ts +10 -10
  224. package/dist/types/components/wm-action-menu/wm-action-menu.d.ts +49 -49
  225. package/dist/types/components/wm-button/wm-button.d.ts +44 -44
  226. package/dist/types/components/wm-datepicker/priv-datepicker/priv-datepicker.d.ts +80 -80
  227. package/dist/types/components/wm-datepicker/wm-datepicker.d.ts +42 -42
  228. package/dist/types/components/wm-file/wm-file.d.ts +40 -40
  229. package/dist/types/components/wm-file-list/wm-file-list.d.ts +16 -16
  230. package/dist/types/components/wm-input/wm-input.d.ts +57 -57
  231. package/dist/types/components/wm-menuitem/wm-menuitem.d.ts +34 -34
  232. package/dist/types/components/wm-modal/wm-modal-footer.d.ts +14 -14
  233. package/dist/types/components/wm-modal/wm-modal-header.d.ts +10 -10
  234. package/dist/types/components/wm-modal/wm-modal.d.ts +40 -40
  235. package/dist/types/components/wm-navigation/wm-navigation-hamburger.d.ts +16 -16
  236. package/dist/types/components/wm-navigation/wm-navigation-item.d.ts +13 -13
  237. package/dist/types/components/wm-navigation/wm-navigation.d.ts +26 -26
  238. package/dist/types/components/wm-navigator/priv-navigator-button/priv-navigator-button.d.ts +10 -10
  239. package/dist/types/components/wm-navigator/priv-navigator-item/priv-navigator-item.d.ts +13 -13
  240. package/dist/types/components/wm-navigator/wm-navigator.d.ts +61 -61
  241. package/dist/types/components/wm-option/wm-option.d.ts +34 -34
  242. package/dist/types/components/wm-pagination/wm-pagination.d.ts +32 -32
  243. package/dist/types/components/wm-search/wm-search.d.ts +77 -77
  244. package/dist/types/components/wm-select/wm-select.d.ts +101 -101
  245. package/dist/types/components/wm-snackbar/wm-snackbar.d.ts +30 -30
  246. package/dist/types/components/wm-tabs/wm-tab-item/wm-tab-item.d.ts +37 -37
  247. package/dist/types/components/wm-tabs/wm-tab-list/wm-tab-list.d.ts +52 -52
  248. package/dist/types/components/wm-tabs/wm-tab-panel/wm-tab-panel.d.ts +20 -20
  249. package/dist/types/components/wm-tag-input/wm-tag-input-row/wm-tag-input-row.d.ts +11 -11
  250. package/dist/types/components/wm-tag-input/wm-tag-input.d.ts +137 -136
  251. package/dist/types/components/wm-timepicker/wm-timepicker.d.ts +62 -62
  252. package/dist/types/components/wm-toggletip/wm-toggletip.d.ts +25 -25
  253. package/dist/types/components/wm-uploader/wm-network-uploader/wm-network-uploader.d.ts +85 -85
  254. package/dist/types/components/wm-uploader/wm-uploader.d.ts +99 -99
  255. package/dist/types/components/wm-wrapper/wm-wrapper.d.ts +7 -7
  256. package/dist/types/components.d.ts +27 -27
  257. package/dist/types/global/__mocks__/functions.d.ts +6 -6
  258. package/dist/types/global/functions.d.ts +40 -40
  259. package/dist/types/global/global.d.ts +1 -1
  260. package/dist/types/global/interfaces.d.ts +74 -74
  261. package/dist/types/global/intl.d.ts +29 -29
  262. package/dist/types/global/services/__mocks__/http-service.d.ts +6 -6
  263. package/dist/types/global/services/http-service.d.ts +4 -4
  264. package/dist/types/lang/lang.d.ts +5 -5
  265. package/package.json +46 -46
  266. package/dist/ripple/p-37de8e2f.entry.js +0 -1
  267. package/dist/ripple/p-b378e064.system.entry.js +0 -1
  268. package/dist/ripple/p-d2037549.entry.js +0 -1
  269. /package/dist/esm-es5/{functions-f32b1ca4.js → functions-cbb19d50.js} +0 -0
  270. /package/dist/esm-es5/{http-service-5d037e16.js → http-service-3dc3b3e7.js} +0 -0
  271. /package/dist/esm-es5/{interfaces-61c6305b.js → interfaces-2b97fab2.js} +0 -0
  272. /package/dist/ripple/{p-888bec42.js → p-43f1298b.js} +0 -0
  273. /package/dist/ripple/{p-cfa80f5b.js → p-91480a89.js} +0 -0
  274. /package/dist/ripple/{p-313b6073.system.js → p-9d02957d.system.js} +0 -0
  275. /package/dist/ripple/{p-9eb5a71e.system.js → p-b267e710.system.js} +0 -0
  276. /package/dist/ripple/{p-08b7ec08.system.js → p-f5df5903.system.js} +0 -0
  277. /package/dist/ripple/{p-a6d6eae7.js → p-fd8070fb.js} +0 -0
@@ -1,601 +1,601 @@
1
1
  import { h } from './index-e887b1ce.js';
2
- import { i as intl, c as checkForActiveElInShadow, a as getPosition, f as findParentWithScrollbar, d as debounce } from './functions-f32b1ca4.js';
2
+ import { i as intl, c as checkForActiveElInShadow, a as getPosition, f as findParentWithScrollbar, d as debounce } from './functions-cbb19d50.js';
3
3
 
4
- const colors = {
5
- salmon: "#ff5f4e",
6
- cyan: "#19a1a9",
7
- forest: "#088000",
8
- sleet: "#7f97ad",
9
- midnight: "#2e1b46",
10
- lavender: "#8b86ca",
11
- periwinkle: "#575195",
12
- gray: "#6b6b6b",
13
- };
14
- const allChartsDetails = {
15
- // for progress monitor
16
- doughnut: {
17
- size: 155,
18
- colors: [colors.forest, colors.gray],
19
- thickness: 0.73,
20
- padding: 25,
21
- category: "doughnut",
22
- },
23
- // deprecated hybrid chart type, should use Progress Indicator's "doughnut" instead
24
- doughnut0: {
25
- size: 155,
26
- colors: [colors.forest, colors.gray],
27
- thickness: 0.73,
28
- padding: 25,
29
- category: "doughnut",
30
- },
31
- doughnut1: {
32
- size: 130,
33
- colors: [colors.lavender, colors.midnight, colors.gray],
34
- thickness: 0.5,
35
- padding: 90,
36
- category: "doughnut",
37
- },
38
- doughnut2: {
39
- size: 130,
40
- colors: [colors.cyan, colors.salmon, colors.gray],
41
- thickness: 0.5,
42
- padding: 90,
43
- category: "doughnut",
44
- },
45
- // an internal type only for use when doughnut 2 is populated with 4 slices
46
- // in this case, the first slice is colored purple
47
- doughnut2b: {
48
- size: 130,
49
- colors: [colors.periwinkle, colors.cyan, colors.salmon, colors.gray],
50
- thickness: 0.5,
51
- padding: 90,
52
- category: "doughnut",
53
- },
54
- doughnut3: {
55
- size: 130,
56
- colors: [colors.lavender, colors.midnight, "#0089e4", colors.forest, "#ea8500", "#d54f41", "#146ca9"],
57
- thickness: 0.5,
58
- padding: 90,
59
- category: "doughnut",
60
- },
61
- // for progress monitor
62
- bar: {
63
- size: 350,
64
- colors: [colors.forest, colors.gray],
65
- padding: 0,
66
- category: "stackedBar",
67
- },
68
- // deprecated hybrid chart type, should use Progress Indicator's "bar" instead
69
- bar1: {
70
- size: 350,
71
- colors: [colors.forest, colors.gray],
72
- padding: 0,
73
- category: "stackedBar",
74
- },
75
- bar2: {
76
- size: 400,
77
- colors: [colors.gray, colors.periwinkle, colors.cyan, colors.salmon],
78
- padding: 0,
79
- category: "stackedBar",
80
- },
81
- bar2b: {
82
- size: 400,
83
- colors: [colors.gray, colors.periwinkle, colors.midnight, colors.cyan, colors.salmon],
84
- padding: 0,
85
- category: "stackedBar",
86
- },
87
- bar3: {
88
- size: 300,
89
- colors: ["#0d696e", colors.cyan, "#8e4129", colors.salmon],
90
- padding: 0,
91
- category: "stackedBar",
92
- },
93
- bar4: {
94
- size: 400,
95
- colors: [colors.salmon, colors.cyan, colors.periwinkle],
96
- padding: 0,
97
- category: "stackedBar",
98
- },
99
- bar5: {
100
- size: 400,
101
- colors: [
102
- colors.gray,
103
- colors.lavender,
104
- colors.midnight,
105
- "#0089e4",
106
- colors.forest,
107
- "#ea8500",
108
- "#d54f41",
109
- "#146ca9",
110
- ],
111
- padding: 0,
112
- category: "stackedBar",
113
- },
114
- bar6: {
115
- size: 400,
116
- colors: [colors.lavender],
117
- padding: 0,
118
- category: "simpleBar",
119
- },
120
- bar7: {
121
- size: 400,
122
- colors: [colors.periwinkle, colors.cyan, colors.salmon, colors.gray],
123
- padding: 0,
124
- category: "simpleBar",
125
- },
126
- };
127
- function showValue(valueFormat) {
128
- return valueFormat === "percentage" || valueFormat === "amount" ? "show-values" : "";
129
- }
130
- const textHiddenMessage = intl.formatMessage({
131
- id: "chart.hiddenValues",
132
- defaultMessage: "Values are not shown when too close to each other.",
133
- description: "Text displayed when a chart has some values hidden",
134
- });
135
- const seeDetailsMessage = intl.formatMessage({
136
- id: "chart.clickToSeeDetails",
137
- defaultMessage: "Click or use arrow keys to see details.",
138
- description: "Text displayed, guiding user to interact to see more details.",
139
- });
140
- function abbrNumber(num) {
141
- return num > 999 ? Math.round(num / 100) / 10 + "K" : num;
142
- }
143
- function amountToPercent(val, total, asInt) {
144
- return asInt ? Math.round((val * 100) / total) : Math.round((val * 10000) / total) / 100; // with 2 decimals
145
- }
146
- function amountToDegree(val, total) {
147
- // In a circle of {total}, determine degrees of slice {val}
148
- return (val * 360) / total;
149
- }
150
- function toFixed(number) {
151
- return parseFloat((Math.floor(number * 100) / 100).toFixed(2));
152
- }
153
- function polarToCartesian(half, radius, startAngle, endAngle) {
154
- var x = toFixed(half + half * radius * Math.cos((Math.PI * startAngle) / 180));
155
- var y = toFixed(half + half * radius * Math.sin((Math.PI * startAngle) / 180));
156
- if (endAngle !== undefined) {
157
- // if a 2nd angle value was passed, return 2 pairs of coords
158
- var x2 = toFixed(half + half * radius * Math.cos((Math.PI * endAngle) / 180));
159
- var y2 = toFixed(half + half * radius * Math.sin((Math.PI * endAngle) / 180));
160
- return { x1: x, y1: y, x2, y2 };
161
- }
162
- return { x, y };
163
- }
164
- function getArc(radius, largeArcFlag, x, y, chartSize) {
165
- var z = toFixed((chartSize / 2) * radius);
166
- return `A ${z}, ${z} 0 ${largeArcFlag} ${toFixed(x)}, ${toFixed(y)}`;
167
- }
168
- function scale(val, inMin, inMax, outMin, outMax) {
169
- let scaled = ((val - inMin) * (outMax - outMin)) / (inMax - inMin) + outMin;
170
- // clip the values so that whatever is passed in the output is never smaller than outMin or greater than outMax
171
- return scaled < outMin ? outMin : scaled > outMax ? outMax : scaled;
172
- }
173
- function minSpacing(width) {
174
- // minimum spacing between 2 ticks, in px
175
- return scale(width, 300, 900, 70, 150);
176
- }
177
- function getMaxTicks(width) {
178
- return Math.round(width / minSpacing(width));
179
- }
180
- function getInterval(largest, maxticks) {
181
- const minimum = largest / maxticks;
182
- const magnitude = 10 ** Math.floor(Math.log10(minimum));
183
- const residual = minimum / magnitude;
184
- let interval;
185
- if (residual > 5) {
186
- interval = 10 * magnitude;
187
- }
188
- else if (residual > 3) {
189
- interval = 5 * magnitude;
190
- }
191
- else if (residual > 2) {
192
- interval = 3 * magnitude;
193
- }
194
- else if (residual > 1.5) {
195
- interval = 2 * magnitude;
196
- }
197
- else if (residual > 1) {
198
- interval = 1.5 * magnitude;
199
- }
200
- else {
201
- interval = magnitude;
202
- }
203
- return interval;
204
- }
205
- function handleSliceKeyDown(ev) {
206
- if (this.popoverEl && this.popoverEl.open && ev.key === "Enter") {
207
- const popoverBtn = this.popoverEl.querySelector("button");
208
- popoverBtn && popoverBtn.click();
209
- }
210
- }
211
- function handleSliceClick(ev, s) {
212
- if (this.popoverEl && !this.isTabbing) {
213
- s.coords = { x: ev.clientX, y: ev.clientY };
214
- openPopover.call(this, s);
215
- }
216
- }
217
- function handleSliceFocus(ev, s) {
218
- if (this.popoverEl && this.isTabbing) {
219
- s.coords = getPosition(ev.target);
220
- openPopover.call(this, s);
221
- }
222
- }
223
- function handleChartKeydown(ev) {
224
- switch (ev.key) {
225
- // arrow up / left
226
- case "ArrowUp":
227
- case "ArrowLeft":
228
- ev.preventDefault();
229
- this.isTabbing = true; // shd already be true. just in case user clicked on chart then pressed an arrow key
230
- focusPrevious.call(this);
231
- break;
232
- // arrow right / down
233
- case "ArrowRight":
234
- case "ArrowDown":
235
- ev.preventDefault();
236
- this.isTabbing = true; // shd already be true. just in case user clicked on chart then pressed an arrow key
237
- focusNext.call(this);
238
- break;
239
- // tab
240
- case "Tab":
241
- exitChart.call(this);
242
- break;
243
- case "Escape":
244
- this.popoverEl.open = false;
245
- this.userIsNavigating = false;
246
- break;
247
- }
248
- }
249
- function openPopover(s) {
250
- if (!!this.popoverEl && !!s.title && !!s.text) {
251
- this.popoverEl.popoverTitle = s.title;
252
- this.popoverEl.popoverText = s.text;
253
- this.popoverEl.buttonText = s.buttonText;
254
- this.popoverEl.coords = s.coords;
255
- this.popoverEl.sliceRef = s.sliceRef;
256
- window.setTimeout(() => {
257
- if (this.popoverEl) {
258
- this.popoverEl.open = true;
259
- }
260
- }, 30);
261
- const debouncedClosePopover = debounce(async () => {
262
- this.popoverEl.open = false;
263
- }, 10);
264
- // set up event listeners for scrolling
265
- // to close popover on page scroll
266
- document.addEventListener("scroll", () => {
267
- debouncedClosePopover();
268
- });
269
- // ... and on parent scroll
270
- const scrollableParent = findParentWithScrollbar(this.el);
271
- if (!!scrollableParent) {
272
- scrollableParent.addEventListener("scroll", () => {
273
- debouncedClosePopover();
274
- });
275
- }
276
- }
277
- }
278
- function focusNext() {
279
- const activeEl = checkForActiveElInShadow(document.activeElement);
280
- const index =
281
- // if the active el is not in the array the first element gets focused
282
- (this.sliceEls.indexOf(activeEl) + 1) % this.sliceEls.length;
283
- focusSlice.call(this, index);
284
- }
285
- function focusPrevious() {
286
- if (this.sliceEls) {
287
- const activeEl = checkForActiveElInShadow(document.activeElement);
288
- let index = this.sliceEls.indexOf(activeEl);
289
- if (index === -1) {
290
- // not in the array : focus the first slice
291
- index = 0;
292
- }
293
- else if (index === 0) {
294
- // first slice : focus the last slice
295
- index = this.sliceEls.length - 1;
296
- }
297
- else {
298
- // anything else: focus previous
299
- index -= 1;
300
- }
301
- focusSlice.call(this, index);
302
- }
303
- }
304
- function focusSlice(index) {
305
- if (this.sliceEls && this.el) {
306
- this.userIsNavigating = true;
307
- if (this.popoverEl) {
308
- this.popoverEl.open = false;
309
- }
310
- // set tabindex of the wrapper to -1 while slices are being focused, to allow for shft-tabbing out of the component directly
311
- this.componentWrapperEl.tabIndex = -1;
312
- // @ts-ignore
313
- this.el.focusable = false; // for Edge
314
- this.sliceEls.map((p) => {
315
- p.tabIndex = -1;
316
- // @ts-ignore
317
- p.focusable = false; // for Edge
318
- });
319
- this.sliceEls[index].tabIndex = 0;
320
- // @ts-ignore
321
- this.sliceEls[index].focusable = true; // for Edge
322
- this.sliceEls[index].focus();
323
- window.setTimeout(() => {
324
- if (this.popoverEl) {
325
- this.popoverEl.open = true;
326
- }
327
- }, 10);
328
- }
329
- }
330
- function exitChart() {
331
- this.sliceEls &&
332
- this.sliceEls.map((p) => {
333
- p.tabIndex = -1;
334
- // @ts-ignore
335
- p.focusable = false; // for Edge
336
- });
337
- this.userIsNavigating = false;
338
- // delay so that we can tab out of component before chart becomes focusable again
339
- // and in case user was still pressing an arrow key when they pressed tab
340
- window.setTimeout(() => {
341
- this.componentWrapperEl.tabIndex = 0;
342
- // @ts-ignore
343
- this.el.focusable = true; // for Edge
344
- if (this.popoverEl) {
345
- this.popoverEl.open = false;
346
- }
347
- }, 100);
348
- }
349
- async function getDetails(chartType) {
350
- this.slicesDetails = [];
351
- let acc = 0;
352
- const children = Array.from(this.el.children);
353
- this.total = children.reduce((total, slice) => (total += parseInt(slice.getAttribute("amount") || "0")), 0);
354
- children.forEach((c, i) => {
355
- const amount = parseInt(c.getAttribute("amount") || "0");
356
- const perc = amountToPercent(amount, this.total, true);
357
- let colorIndex = i;
358
- // for bar5, first color should be skipped unless notStartedColor is set to true
359
- if (chartType === "bar5") {
360
- colorIndex = this.notStartedColor ? i : i + 1;
361
- }
362
- // bars in bar6 are all the same color
363
- if (chartType === "bar6") {
364
- colorIndex = 0;
365
- }
366
- const color = allChartsDetails[chartType].colors[colorIndex];
367
- const sliceDetails = {
368
- amount: amount,
369
- perc: perc,
370
- legend: c.getAttribute("legend"),
371
- color: color || colors.gray,
372
- offset: acc,
373
- id: `${this.uid}-${i + 1}`,
374
- title: c.getAttribute("popover-title"),
375
- text: c.getAttribute("popover-text"),
376
- buttonText: c.getAttribute("popover-button-text"),
377
- sliceRef: c,
378
- inSmallCluster: false,
379
- };
380
- acc += amount;
381
- this.slicesDetails.push(sliceDetails);
382
- });
383
- }
384
- function sortSlicesDetails(slicesDetails, total) {
385
- // sort slices by decreasing amount
386
- let sortedSlicesDetails = [...slicesDetails].sort((a, b) => a.amount === b.amount ? 0 : a.amount > b.amount ? -1 : 1);
387
- let acc = 0;
388
- sortedSlicesDetails.forEach((s, idx) => {
389
- const prev = sortedSlicesDetails[idx === 0 ? sortedSlicesDetails.length - 1 : idx - 1];
390
- const next = sortedSlicesDetails[idx === sortedSlicesDetails.length - 1 ? 0 : idx + 1];
391
- const prevPerc = amountToPercent(prev.amount, total, true);
392
- const nextPerc = amountToPercent(next.amount, total, true);
393
- s.offset = acc;
394
- acc += s.amount;
395
- s.inSmallCluster = isInSmallCluster(prevPerc, s.perc, s.amount, nextPerc);
396
- });
397
- return sortedSlicesDetails;
398
- }
399
- function isInSmallCluster(prevPerc, perc, amount, nextPerc) {
400
- // determine whether the slice is in a cluster of small values
401
- // to avoid percentage text overlap for small values
402
- const isSmall = perc < 4;
403
- const prevIsSmall = prevPerc < 5;
404
- const nextIsSmall = nextPerc < 5;
405
- let inSmallCluster = isSmall && (prevIsSmall || nextIsSmall);
406
- // because <1% slice percentage text has an additional character
407
- // the inSmallCluster threshold needs to be widened for that slice only
408
- const lessThanOnePerc = perc === 0 && amount > 0;
409
- if (lessThanOnePerc && (nextPerc < 8 || prevPerc < 8)) {
410
- inSmallCluster = true;
411
- }
412
- return inSmallCluster;
413
- }
414
- function getPathData(amount, offset, chartType) {
415
- const startAngle = amountToDegree(offset, this.total) - 90; // start at noon, not at 3 o'clock
416
- const activeAngle = (amount / this.total) * 360;
417
- let endAngle = startAngle + activeAngle;
418
- const largeArcFlagOuter = activeAngle > 180 ? "1 1" : "0 1";
419
- const largeArcFlagInner = activeAngle > 180 ? "1 0" : "0 0";
420
- const half = this.chartDetails.size / 2;
421
- const innerRadius = this.chartDetails.thickness;
422
- const outerRadius = 1;
423
- const isHybridDoughnut = chartType === "doughnut0" || chartType === "doughnut";
424
- const outerSeparatorOffset = 1.5;
425
- const innerSeparatorOffset = isHybridDoughnut ? 2.25 : 3;
426
- if (activeAngle === 360) {
427
- // fix to avoid bad svg shape when the path goes all around (100%)
428
- endAngle -= 0.01;
429
- }
430
- const outerCoords = polarToCartesian(half, outerRadius, startAngle + outerSeparatorOffset, // Addition for slice separator
431
- endAngle);
432
- const innerCoords = polarToCartesian(half, innerRadius, startAngle + innerSeparatorOffset, // Addition for slice separator
433
- endAngle);
434
- const moveTo = `M ${outerCoords.x1}, ${outerCoords.y1} `;
435
- const arc1 = getArc(outerRadius, largeArcFlagOuter, outerCoords.x2, outerCoords.y2, this.chartDetails.size);
436
- const line = ` L ${innerCoords.x2}, ${innerCoords.y2} `;
437
- const arc2 = getArc(innerRadius, largeArcFlagInner, innerCoords.x1, innerCoords.y1, this.chartDetails.size);
438
- return moveTo + arc1 + line + arc2 + " z";
439
- }
440
- function renderInstructionsText() {
441
- const chartInstructions = intl.formatMessage({
442
- id: "chart.instructions",
443
- defaultMessage: "Use arrow keys to browse elements, press Tab to exit.",
444
- description: "For screen readers only, instructions on how to interact with the chart component",
445
- });
446
- return h("div", { id: "chart-instructions" }, chartInstructions);
447
- }
448
- function renderFilter() {
449
- return (h("defs", null,
450
- h("filter", { id: "wmHoverDropShadow" },
451
- h("feGaussianBlur", { stdDeviation: "3" }),
452
- h("feOffset", { result: "offsetblur" }),
453
- h("feFlood", { "flood-color": "#333" }),
454
- h("feComposite", { operator: "in", in2: "offsetblur" }),
455
- h("feMerge", null,
456
- h("feMergeNode", null),
457
- h("feMergeNode", { in: "SourceGraphic" })))));
458
- }
459
- function renderDoughnut(chartType) {
460
- const outerSize = this.chartDetails.size + this.chartDetails.padding;
461
- const isHybridDoughnut = chartType === "doughnut0" || chartType === "doughnut";
462
- // no sorting in progress indicators
463
- let slicesDetails = isHybridDoughnut ? this.slicesDetails : sortSlicesDetails(this.slicesDetails, this.total);
464
- return (h("div", { class: "chart-wrapper doughnut-wrapper" },
465
- h("svg", { width: outerSize + "px", height: outerSize + "px", id: `graphic-${this.uid}`, class: "doughnut-svg" },
466
- renderFilter(),
467
- slicesDetails.map((s) => renderPath.call(this, s, chartType)),
468
- isHybridDoughnut ? (h("text", { class: "value", x: "50%", y: "50%", "font-size": "1.5rem", "font-weight": "500", "text-anchor": "middle", "dominant-baseline": "middle" }, amountToPercent(slicesDetails[0].amount, this.total, true) + "%")) : (h("g", { transform: `translate(${this.chartDetails.padding / 2}, ${this.chartDetails.padding / 2})`, "text-anchor": "middle", "dominant-baseline": "middle" }, slicesDetails.map((s) => s.amount > 0 && !s.inSmallCluster ? renderDoughnutText.call(this, s) : ""))))));
469
- }
470
- function renderPath(s, chartType) {
471
- return (h("g", { transform: `translate(${this.chartDetails.padding / 2}, ${this.chartDetails.padding / 2})` },
472
- h("path", { id: s.id, class: "segment doughnut-segment", fill: s.amount ? s.color : "transparent", d: getPathData.call(this, s.amount, s.offset, chartType), onClick: (ev) => handleSliceClick.call(this, ev, s), onFocus: (ev) => handleSliceFocus.call(this, ev, s), onKeyDown: (ev) => handleSliceKeyDown.call(this, ev), role: "img", "aria-label": s.legend })));
473
- }
474
- function renderDoughnutText(s) {
475
- const arcMiddle = amountToDegree(s.offset + s.amount / 2, this.total);
476
- let { x, y } = polarToCartesian(this.chartDetails.size / 2, 1.4, arcMiddle - 90);
477
- return (h("text", { class: "value", x: x + "px", y: y + "px" }, `${s.perc > 0 ? s.perc : "<1"}%`));
478
- }
479
- function renderStackedBar(chartType) {
480
- const isHybridBar = chartType === "bar1" || chartType === "bar";
481
- return (h("div", { class: "chart-wrapper bar-wrapper" },
482
- isHybridBar ? (h("div", { class: "single-perc" }, amountToPercent(this.slicesDetails[0].amount, this.total, true) + "%")) : (""),
483
- this.chartType === "bar3" && this.drawAxis(),
484
- h("div", { class: `inner-stacked-bar-wrapper ${showValue(this.tempValueFormat)}` },
485
- !isHybridBar ? (h("div", { class: "values" }, this.slicesDetails.map((s, idx) => this.renderBarText(s, idx)))) : (""),
486
- h("div", { class: "stacked-bar-segments-wrapper" }, this.slicesDetails.map((s, idx) => renderStackedBarSegment.call(this, s, idx))),
487
- isHybridBar ? renderCompletionMessage.call(this) : "")));
488
- }
489
- function renderStackedBarSegment(s, idx) {
490
- const isLastSlice = idx !== this.slicesDetails.length - 1;
491
- const width = `calc(${amountToPercent(s.amount, this.total, false)}%${isLastSlice ? " - 2px" : ""})`;
492
- return (h("div", { class: `segment stacked-bar-segment ${amountToPercent(s.amount, this.total, false) === 0 ? "zero" : ""}`, style: {
493
- backgroundColor: s.color,
494
- width: width,
495
- }, onClick: (ev) => handleSliceClick.call(this, ev, s), onFocus: (ev) => handleSliceFocus.call(this, ev, s), onKeyDown: (ev) => handleSliceKeyDown.call(this, ev) },
496
- h("span", { class: "sr-only" }, s.legend)));
497
- }
498
- function renderSimpleBar(chartType) {
499
- // find largest number and get interval, numTicks, chartMaxVal for all.
500
- const largest = this.slicesDetails
501
- .map((s) => s.amount)
502
- .reduce((a, b) => {
503
- return a > b ? a : b;
504
- });
505
- const labelWidth = parseInt(getComputedStyle(this.el).getPropertyValue("--labelWidth"), 10);
506
- const chartPadding = 48;
507
- const componentWidth = this.el.getBoundingClientRect().width;
508
- const chartWidth = componentWidth - labelWidth - chartPadding;
509
- let numTicks = getMaxTicks(chartWidth);
510
- let interval = getInterval(largest, numTicks);
511
- // after the algorithm finds an interval, remove extra ticks so that the greater number is always between the last tick and the one before that
512
- const lastTickVal = numTicks * interval;
513
- const extraTicks = Math.floor((lastTickVal - largest) / interval);
514
- numTicks -= extraTicks;
515
- this.el.style.setProperty("--backgroundSize", 100 / numTicks + "%");
516
- this.el.style.setProperty("--labelWidth", this.labelWidth);
517
- if (chartType === "bar7" && !this.showBarLegend) {
518
- this.el.style.setProperty("--labelWidth", "0px");
519
- }
520
- // we have to prep the data here rather than iterate directly in the return statement
521
- // because CSS grid needs a flat structure, and return functions must
522
- // have a single parent element
523
- const rows = [];
524
- this.slicesDetails.forEach((s) => {
525
- s.legend && rows.push(renderSimpleBarLegend(s.legend, this.showBarLegend, chartType));
526
- rows.push(renderSimpleBarItem.call(this, s, interval, numTicks, largest));
527
- });
528
- const ticks = [];
529
- for (let i = 1; i <= numTicks; i++) {
530
- const tickVal = abbrNumber(i * interval);
531
- ticks.push(h("div", { class: "tick" },
532
- h("span", null, tickVal)));
533
- }
534
- const showGrid = chartType === "bar6" && this.showGrid && this.el.getBoundingClientRect().width > 300;
535
- return (h("div", { class: "chart-wrapper simple-bar-wrapper" },
536
- h("div", { class: `chart ${showValue(this.tempValueFormat)}` },
537
- showGrid && h("div", { class: "gridlines" }),
538
- h("div", { class: "rows" }, rows)),
539
- showGrid && (h("div", { class: "x-axis", "aria-hidden": "true" },
540
- h("div", { class: "zero" },
541
- h("span", null, "0")),
542
- ticks))));
543
- }
544
- function renderSimpleBarLegend(legend, show, chartType) {
545
- // not sure how to collapse the left column to 0 width with CSS grid. text should still be available to SR.
546
- const hidden = chartType === "bar7" && !show ? " hidden" : "";
547
- return h("label", { class: `label${hidden}` }, legend);
548
- }
549
- function renderSimpleBarItem(s, interval, ticks, largest) {
550
- const chartMaxVal = this.currentChartType === "bar6" ? interval * ticks : largest;
551
- const width = amountToPercent(s.amount, chartMaxVal, false);
552
- const cssWidth = width ? width + "%" : "1px";
553
- const amt = abbrNumber(s.amount);
554
- let displayValue = this.tempValueFormat === "amount" ? amt : "";
555
- if (this.currentChartType === "bar6" && this.tempValueFormat === "percentage") {
556
- displayValue = s.amount + "%";
557
- }
558
- else if (this.currentChartType === "bar7" && this.tempValueFormat === "percentage") {
559
- displayValue = amountToPercent(s.amount, this.total, true) + "%";
560
- }
561
- return (h("div", { class: "bar segment", style: {
562
- backgroundColor: s.color,
563
- width: cssWidth,
564
- }, onClick: (ev) => handleSliceClick.call(this, ev, s), onFocus: (ev) => handleSliceFocus.call(this, ev, s), onKeyDown: (ev) => handleSliceKeyDown.call(this, ev) },
565
- h("div", { class: "value" }, displayValue)));
566
- }
567
- function renderLegend(chartType) {
568
- // legend is hidden for bar1 and bar6 types regardless of showLegend value
569
- if (this.showLegend) {
570
- const hasCluster = !this.chartDetails.isBar &&
571
- this.slicesDetails.reduce((hasCluster, cur) => (hasCluster = cur.inSmallCluster ? true : hasCluster), false);
572
- return (h("div", { class: "legend-wrapper" },
573
- h("div", { class: `legend ${chartType} ${this.mode === "bar" ? "--top" : "--bottom"}`, "aria-hidden": "true" }, this.total > 0
574
- ? this.slicesDetails.map((s) => {
575
- // when both legend and amount are omitted, the legend is not shown for that particular option (it's been deactivated by the user)
576
- if (!!s.amount || !!s.legend) {
577
- return renderLegendItem({ key: s.legend, color: s.color });
578
- }
579
- })
580
- : ""),
581
- hasCluster && renderHiddenValuesMessage()));
582
- }
583
- }
584
- function renderLegendItem(legendItem) {
585
- return (h("div", { class: "legend-item" },
586
- h("div", { class: "legend-color", style: { backgroundColor: legendItem.color } }),
587
- h("div", { class: "legend-text" }, legendItem.key)));
588
- }
589
- function renderCompletionMessage() {
590
- if (this.completionMessage) {
591
- return h("div", { class: "completion-message" }, this.completionMessage);
592
- }
593
- }
594
- function renderHiddenValuesMessage() {
595
- return (h("div", { class: "hidden-values-warning" },
596
- textHiddenMessage,
597
- h("br", null),
598
- seeDetailsMessage));
4
+ const colors = {
5
+ salmon: "#ff5f4e",
6
+ cyan: "#19a1a9",
7
+ forest: "#088000",
8
+ sleet: "#7f97ad",
9
+ midnight: "#2e1b46",
10
+ lavender: "#8b86ca",
11
+ periwinkle: "#575195",
12
+ gray: "#6b6b6b",
13
+ };
14
+ const allChartsDetails = {
15
+ // for progress monitor
16
+ doughnut: {
17
+ size: 155,
18
+ colors: [colors.forest, colors.gray],
19
+ thickness: 0.73,
20
+ padding: 25,
21
+ category: "doughnut",
22
+ },
23
+ // deprecated hybrid chart type, should use Progress Indicator's "doughnut" instead
24
+ doughnut0: {
25
+ size: 155,
26
+ colors: [colors.forest, colors.gray],
27
+ thickness: 0.73,
28
+ padding: 25,
29
+ category: "doughnut",
30
+ },
31
+ doughnut1: {
32
+ size: 130,
33
+ colors: [colors.lavender, colors.midnight, colors.gray],
34
+ thickness: 0.5,
35
+ padding: 90,
36
+ category: "doughnut",
37
+ },
38
+ doughnut2: {
39
+ size: 130,
40
+ colors: [colors.cyan, colors.salmon, colors.gray],
41
+ thickness: 0.5,
42
+ padding: 90,
43
+ category: "doughnut",
44
+ },
45
+ // an internal type only for use when doughnut 2 is populated with 4 slices
46
+ // in this case, the first slice is colored purple
47
+ doughnut2b: {
48
+ size: 130,
49
+ colors: [colors.periwinkle, colors.cyan, colors.salmon, colors.gray],
50
+ thickness: 0.5,
51
+ padding: 90,
52
+ category: "doughnut",
53
+ },
54
+ doughnut3: {
55
+ size: 130,
56
+ colors: [colors.lavender, colors.midnight, "#0089e4", colors.forest, "#ea8500", "#d54f41", "#146ca9"],
57
+ thickness: 0.5,
58
+ padding: 90,
59
+ category: "doughnut",
60
+ },
61
+ // for progress monitor
62
+ bar: {
63
+ size: 350,
64
+ colors: [colors.forest, colors.gray],
65
+ padding: 0,
66
+ category: "stackedBar",
67
+ },
68
+ // deprecated hybrid chart type, should use Progress Indicator's "bar" instead
69
+ bar1: {
70
+ size: 350,
71
+ colors: [colors.forest, colors.gray],
72
+ padding: 0,
73
+ category: "stackedBar",
74
+ },
75
+ bar2: {
76
+ size: 400,
77
+ colors: [colors.gray, colors.periwinkle, colors.cyan, colors.salmon],
78
+ padding: 0,
79
+ category: "stackedBar",
80
+ },
81
+ bar2b: {
82
+ size: 400,
83
+ colors: [colors.gray, colors.periwinkle, colors.midnight, colors.cyan, colors.salmon],
84
+ padding: 0,
85
+ category: "stackedBar",
86
+ },
87
+ bar3: {
88
+ size: 300,
89
+ colors: ["#0d696e", colors.cyan, "#8e4129", colors.salmon],
90
+ padding: 0,
91
+ category: "stackedBar",
92
+ },
93
+ bar4: {
94
+ size: 400,
95
+ colors: [colors.salmon, colors.cyan, colors.periwinkle],
96
+ padding: 0,
97
+ category: "stackedBar",
98
+ },
99
+ bar5: {
100
+ size: 400,
101
+ colors: [
102
+ colors.gray,
103
+ colors.lavender,
104
+ colors.midnight,
105
+ "#0089e4",
106
+ colors.forest,
107
+ "#ea8500",
108
+ "#d54f41",
109
+ "#146ca9",
110
+ ],
111
+ padding: 0,
112
+ category: "stackedBar",
113
+ },
114
+ bar6: {
115
+ size: 400,
116
+ colors: [colors.lavender],
117
+ padding: 0,
118
+ category: "simpleBar",
119
+ },
120
+ bar7: {
121
+ size: 400,
122
+ colors: [colors.periwinkle, colors.cyan, colors.salmon, colors.gray],
123
+ padding: 0,
124
+ category: "simpleBar",
125
+ },
126
+ };
127
+ function showValue(valueFormat) {
128
+ return valueFormat === "percentage" || valueFormat === "amount" ? "show-values" : "";
129
+ }
130
+ const textHiddenMessage = intl.formatMessage({
131
+ id: "chart.hiddenValues",
132
+ defaultMessage: "Values are not shown when too close to each other.",
133
+ description: "Text displayed when a chart has some values hidden",
134
+ });
135
+ const seeDetailsMessage = intl.formatMessage({
136
+ id: "chart.clickToSeeDetails",
137
+ defaultMessage: "Click or use arrow keys to see details.",
138
+ description: "Text displayed, guiding user to interact to see more details.",
139
+ });
140
+ function abbrNumber(num) {
141
+ return num > 999 ? Math.round(num / 100) / 10 + "K" : num;
142
+ }
143
+ function amountToPercent(val, total, asInt) {
144
+ return asInt ? Math.round((val * 100) / total) : Math.round((val * 10000) / total) / 100; // with 2 decimals
145
+ }
146
+ function amountToDegree(val, total) {
147
+ // In a circle of {total}, determine degrees of slice {val}
148
+ return (val * 360) / total;
149
+ }
150
+ function toFixed(number) {
151
+ return parseFloat((Math.floor(number * 100) / 100).toFixed(2));
152
+ }
153
+ function polarToCartesian(half, radius, startAngle, endAngle) {
154
+ var x = toFixed(half + half * radius * Math.cos((Math.PI * startAngle) / 180));
155
+ var y = toFixed(half + half * radius * Math.sin((Math.PI * startAngle) / 180));
156
+ if (endAngle !== undefined) {
157
+ // if a 2nd angle value was passed, return 2 pairs of coords
158
+ var x2 = toFixed(half + half * radius * Math.cos((Math.PI * endAngle) / 180));
159
+ var y2 = toFixed(half + half * radius * Math.sin((Math.PI * endAngle) / 180));
160
+ return { x1: x, y1: y, x2, y2 };
161
+ }
162
+ return { x, y };
163
+ }
164
+ function getArc(radius, largeArcFlag, x, y, chartSize) {
165
+ var z = toFixed((chartSize / 2) * radius);
166
+ return `A ${z}, ${z} 0 ${largeArcFlag} ${toFixed(x)}, ${toFixed(y)}`;
167
+ }
168
+ function scale(val, inMin, inMax, outMin, outMax) {
169
+ let scaled = ((val - inMin) * (outMax - outMin)) / (inMax - inMin) + outMin;
170
+ // clip the values so that whatever is passed in the output is never smaller than outMin or greater than outMax
171
+ return scaled < outMin ? outMin : scaled > outMax ? outMax : scaled;
172
+ }
173
+ function minSpacing(width) {
174
+ // minimum spacing between 2 ticks, in px
175
+ return scale(width, 300, 900, 70, 150);
176
+ }
177
+ function getMaxTicks(width) {
178
+ return Math.round(width / minSpacing(width));
179
+ }
180
+ function getInterval(largest, maxticks) {
181
+ const minimum = largest / maxticks;
182
+ const magnitude = 10 ** Math.floor(Math.log10(minimum));
183
+ const residual = minimum / magnitude;
184
+ let interval;
185
+ if (residual > 5) {
186
+ interval = 10 * magnitude;
187
+ }
188
+ else if (residual > 3) {
189
+ interval = 5 * magnitude;
190
+ }
191
+ else if (residual > 2) {
192
+ interval = 3 * magnitude;
193
+ }
194
+ else if (residual > 1.5) {
195
+ interval = 2 * magnitude;
196
+ }
197
+ else if (residual > 1) {
198
+ interval = 1.5 * magnitude;
199
+ }
200
+ else {
201
+ interval = magnitude;
202
+ }
203
+ return interval;
204
+ }
205
+ function handleSliceKeyDown(ev) {
206
+ if (this.popoverEl && this.popoverEl.open && ev.key === "Enter") {
207
+ const popoverBtn = this.popoverEl.querySelector("button");
208
+ popoverBtn && popoverBtn.click();
209
+ }
210
+ }
211
+ function handleSliceClick(ev, s) {
212
+ if (this.popoverEl && !this.isTabbing) {
213
+ s.coords = { x: ev.clientX, y: ev.clientY };
214
+ openPopover.call(this, s);
215
+ }
216
+ }
217
+ function handleSliceFocus(ev, s) {
218
+ if (this.popoverEl && this.isTabbing) {
219
+ s.coords = getPosition(ev.target);
220
+ openPopover.call(this, s);
221
+ }
222
+ }
223
+ function handleChartKeydown(ev) {
224
+ switch (ev.key) {
225
+ // arrow up / left
226
+ case "ArrowUp":
227
+ case "ArrowLeft":
228
+ ev.preventDefault();
229
+ this.isTabbing = true; // shd already be true. just in case user clicked on chart then pressed an arrow key
230
+ focusPrevious.call(this);
231
+ break;
232
+ // arrow right / down
233
+ case "ArrowRight":
234
+ case "ArrowDown":
235
+ ev.preventDefault();
236
+ this.isTabbing = true; // shd already be true. just in case user clicked on chart then pressed an arrow key
237
+ focusNext.call(this);
238
+ break;
239
+ // tab
240
+ case "Tab":
241
+ exitChart.call(this);
242
+ break;
243
+ case "Escape":
244
+ this.popoverEl.open = false;
245
+ this.userIsNavigating = false;
246
+ break;
247
+ }
248
+ }
249
+ function openPopover(s) {
250
+ if (!!this.popoverEl && !!s.title && !!s.text) {
251
+ this.popoverEl.popoverTitle = s.title;
252
+ this.popoverEl.popoverText = s.text;
253
+ this.popoverEl.buttonText = s.buttonText;
254
+ this.popoverEl.coords = s.coords;
255
+ this.popoverEl.sliceRef = s.sliceRef;
256
+ window.setTimeout(() => {
257
+ if (this.popoverEl) {
258
+ this.popoverEl.open = true;
259
+ }
260
+ }, 30);
261
+ const debouncedClosePopover = debounce(async () => {
262
+ this.popoverEl.open = false;
263
+ }, 10);
264
+ // set up event listeners for scrolling
265
+ // to close popover on page scroll
266
+ document.addEventListener("scroll", () => {
267
+ debouncedClosePopover();
268
+ });
269
+ // ... and on parent scroll
270
+ const scrollableParent = findParentWithScrollbar(this.el);
271
+ if (!!scrollableParent) {
272
+ scrollableParent.addEventListener("scroll", () => {
273
+ debouncedClosePopover();
274
+ });
275
+ }
276
+ }
277
+ }
278
+ function focusNext() {
279
+ const activeEl = checkForActiveElInShadow(document.activeElement);
280
+ const index =
281
+ // if the active el is not in the array the first element gets focused
282
+ (this.sliceEls.indexOf(activeEl) + 1) % this.sliceEls.length;
283
+ focusSlice.call(this, index);
284
+ }
285
+ function focusPrevious() {
286
+ if (this.sliceEls) {
287
+ const activeEl = checkForActiveElInShadow(document.activeElement);
288
+ let index = this.sliceEls.indexOf(activeEl);
289
+ if (index === -1) {
290
+ // not in the array : focus the first slice
291
+ index = 0;
292
+ }
293
+ else if (index === 0) {
294
+ // first slice : focus the last slice
295
+ index = this.sliceEls.length - 1;
296
+ }
297
+ else {
298
+ // anything else: focus previous
299
+ index -= 1;
300
+ }
301
+ focusSlice.call(this, index);
302
+ }
303
+ }
304
+ function focusSlice(index) {
305
+ if (this.sliceEls && this.el) {
306
+ this.userIsNavigating = true;
307
+ if (this.popoverEl) {
308
+ this.popoverEl.open = false;
309
+ }
310
+ // set tabindex of the wrapper to -1 while slices are being focused, to allow for shft-tabbing out of the component directly
311
+ this.componentWrapperEl.tabIndex = -1;
312
+ // @ts-ignore
313
+ this.el.focusable = false; // for Edge
314
+ this.sliceEls.map((p) => {
315
+ p.tabIndex = -1;
316
+ // @ts-ignore
317
+ p.focusable = false; // for Edge
318
+ });
319
+ this.sliceEls[index].tabIndex = 0;
320
+ // @ts-ignore
321
+ this.sliceEls[index].focusable = true; // for Edge
322
+ this.sliceEls[index].focus();
323
+ window.setTimeout(() => {
324
+ if (this.popoverEl) {
325
+ this.popoverEl.open = true;
326
+ }
327
+ }, 10);
328
+ }
329
+ }
330
+ function exitChart() {
331
+ this.sliceEls &&
332
+ this.sliceEls.map((p) => {
333
+ p.tabIndex = -1;
334
+ // @ts-ignore
335
+ p.focusable = false; // for Edge
336
+ });
337
+ this.userIsNavigating = false;
338
+ // delay so that we can tab out of component before chart becomes focusable again
339
+ // and in case user was still pressing an arrow key when they pressed tab
340
+ window.setTimeout(() => {
341
+ this.componentWrapperEl.tabIndex = 0;
342
+ // @ts-ignore
343
+ this.el.focusable = true; // for Edge
344
+ if (this.popoverEl) {
345
+ this.popoverEl.open = false;
346
+ }
347
+ }, 100);
348
+ }
349
+ async function getDetails(chartType) {
350
+ this.slicesDetails = [];
351
+ let acc = 0;
352
+ const children = Array.from(this.el.children);
353
+ this.total = children.reduce((total, slice) => (total += parseInt(slice.getAttribute("amount") || "0")), 0);
354
+ children.forEach((c, i) => {
355
+ const amount = parseInt(c.getAttribute("amount") || "0");
356
+ const perc = amountToPercent(amount, this.total, true);
357
+ let colorIndex = i;
358
+ // for bar5, first color should be skipped unless notStartedColor is set to true
359
+ if (chartType === "bar5") {
360
+ colorIndex = this.notStartedColor ? i : i + 1;
361
+ }
362
+ // bars in bar6 are all the same color
363
+ if (chartType === "bar6") {
364
+ colorIndex = 0;
365
+ }
366
+ const color = allChartsDetails[chartType].colors[colorIndex];
367
+ const sliceDetails = {
368
+ amount: amount,
369
+ perc: perc,
370
+ legend: c.getAttribute("legend"),
371
+ color: color || colors.gray,
372
+ offset: acc,
373
+ id: `${this.uid}-${i + 1}`,
374
+ title: c.getAttribute("popover-title"),
375
+ text: c.getAttribute("popover-text"),
376
+ buttonText: c.getAttribute("popover-button-text"),
377
+ sliceRef: c,
378
+ inSmallCluster: false,
379
+ };
380
+ acc += amount;
381
+ this.slicesDetails.push(sliceDetails);
382
+ });
383
+ }
384
+ function sortSlicesDetails(slicesDetails, total) {
385
+ // sort slices by decreasing amount
386
+ let sortedSlicesDetails = [...slicesDetails].sort((a, b) => a.amount === b.amount ? 0 : a.amount > b.amount ? -1 : 1);
387
+ let acc = 0;
388
+ sortedSlicesDetails.forEach((s, idx) => {
389
+ const prev = sortedSlicesDetails[idx === 0 ? sortedSlicesDetails.length - 1 : idx - 1];
390
+ const next = sortedSlicesDetails[idx === sortedSlicesDetails.length - 1 ? 0 : idx + 1];
391
+ const prevPerc = amountToPercent(prev.amount, total, true);
392
+ const nextPerc = amountToPercent(next.amount, total, true);
393
+ s.offset = acc;
394
+ acc += s.amount;
395
+ s.inSmallCluster = isInSmallCluster(prevPerc, s.perc, s.amount, nextPerc);
396
+ });
397
+ return sortedSlicesDetails;
398
+ }
399
+ function isInSmallCluster(prevPerc, perc, amount, nextPerc) {
400
+ // determine whether the slice is in a cluster of small values
401
+ // to avoid percentage text overlap for small values
402
+ const isSmall = perc < 4;
403
+ const prevIsSmall = prevPerc < 5;
404
+ const nextIsSmall = nextPerc < 5;
405
+ let inSmallCluster = isSmall && (prevIsSmall || nextIsSmall);
406
+ // because <1% slice percentage text has an additional character
407
+ // the inSmallCluster threshold needs to be widened for that slice only
408
+ const lessThanOnePerc = perc === 0 && amount > 0;
409
+ if (lessThanOnePerc && (nextPerc < 8 || prevPerc < 8)) {
410
+ inSmallCluster = true;
411
+ }
412
+ return inSmallCluster;
413
+ }
414
+ function getPathData(amount, offset, chartType) {
415
+ const startAngle = amountToDegree(offset, this.total) - 90; // start at noon, not at 3 o'clock
416
+ const activeAngle = (amount / this.total) * 360;
417
+ let endAngle = startAngle + activeAngle;
418
+ const largeArcFlagOuter = activeAngle > 180 ? "1 1" : "0 1";
419
+ const largeArcFlagInner = activeAngle > 180 ? "1 0" : "0 0";
420
+ const half = this.chartDetails.size / 2;
421
+ const innerRadius = this.chartDetails.thickness;
422
+ const outerRadius = 1;
423
+ const isHybridDoughnut = chartType === "doughnut0" || chartType === "doughnut";
424
+ const outerSeparatorOffset = 1.5;
425
+ const innerSeparatorOffset = isHybridDoughnut ? 2.25 : 3;
426
+ if (activeAngle === 360) {
427
+ // fix to avoid bad svg shape when the path goes all around (100%)
428
+ endAngle -= 0.01;
429
+ }
430
+ const outerCoords = polarToCartesian(half, outerRadius, startAngle + outerSeparatorOffset, // Addition for slice separator
431
+ endAngle);
432
+ const innerCoords = polarToCartesian(half, innerRadius, startAngle + innerSeparatorOffset, // Addition for slice separator
433
+ endAngle);
434
+ const moveTo = `M ${outerCoords.x1}, ${outerCoords.y1} `;
435
+ const arc1 = getArc(outerRadius, largeArcFlagOuter, outerCoords.x2, outerCoords.y2, this.chartDetails.size);
436
+ const line = ` L ${innerCoords.x2}, ${innerCoords.y2} `;
437
+ const arc2 = getArc(innerRadius, largeArcFlagInner, innerCoords.x1, innerCoords.y1, this.chartDetails.size);
438
+ return moveTo + arc1 + line + arc2 + " z";
439
+ }
440
+ function renderInstructionsText() {
441
+ const chartInstructions = intl.formatMessage({
442
+ id: "chart.instructions",
443
+ defaultMessage: "Use arrow keys to browse elements, press Tab to exit.",
444
+ description: "For screen readers only, instructions on how to interact with the chart component",
445
+ });
446
+ return h("div", { id: "chart-instructions" }, chartInstructions);
447
+ }
448
+ function renderFilter() {
449
+ return (h("defs", null,
450
+ h("filter", { id: "wmHoverDropShadow" },
451
+ h("feGaussianBlur", { stdDeviation: "3" }),
452
+ h("feOffset", { result: "offsetblur" }),
453
+ h("feFlood", { "flood-color": "#333" }),
454
+ h("feComposite", { operator: "in", in2: "offsetblur" }),
455
+ h("feMerge", null,
456
+ h("feMergeNode", null),
457
+ h("feMergeNode", { in: "SourceGraphic" })))));
458
+ }
459
+ function renderDoughnut(chartType) {
460
+ const outerSize = this.chartDetails.size + this.chartDetails.padding;
461
+ const isHybridDoughnut = chartType === "doughnut0" || chartType === "doughnut";
462
+ // no sorting in progress indicators
463
+ let slicesDetails = isHybridDoughnut ? this.slicesDetails : sortSlicesDetails(this.slicesDetails, this.total);
464
+ return (h("div", { class: "chart-wrapper doughnut-wrapper" },
465
+ h("svg", { width: outerSize + "px", height: outerSize + "px", id: `graphic-${this.uid}`, class: "doughnut-svg" },
466
+ renderFilter(),
467
+ slicesDetails.map((s) => renderPath.call(this, s, chartType)),
468
+ isHybridDoughnut ? (h("text", { class: "value", x: "50%", y: "50%", "font-size": "1.5rem", "font-weight": "500", "text-anchor": "middle", "dominant-baseline": "middle" }, amountToPercent(slicesDetails[0].amount, this.total, true) + "%")) : (h("g", { transform: `translate(${this.chartDetails.padding / 2}, ${this.chartDetails.padding / 2})`, "text-anchor": "middle", "dominant-baseline": "middle" }, slicesDetails.map((s) => s.amount > 0 && !s.inSmallCluster ? renderDoughnutText.call(this, s) : ""))))));
469
+ }
470
+ function renderPath(s, chartType) {
471
+ return (h("g", { transform: `translate(${this.chartDetails.padding / 2}, ${this.chartDetails.padding / 2})` },
472
+ h("path", { id: s.id, class: "segment doughnut-segment", fill: s.amount ? s.color : "transparent", d: getPathData.call(this, s.amount, s.offset, chartType), onClick: (ev) => handleSliceClick.call(this, ev, s), onFocus: (ev) => handleSliceFocus.call(this, ev, s), onKeyDown: (ev) => handleSliceKeyDown.call(this, ev), role: "img", "aria-label": s.legend })));
473
+ }
474
+ function renderDoughnutText(s) {
475
+ const arcMiddle = amountToDegree(s.offset + s.amount / 2, this.total);
476
+ let { x, y } = polarToCartesian(this.chartDetails.size / 2, 1.4, arcMiddle - 90);
477
+ return (h("text", { class: "value", x: x + "px", y: y + "px" }, `${s.perc > 0 ? s.perc : "<1"}%`));
478
+ }
479
+ function renderStackedBar(chartType) {
480
+ const isHybridBar = chartType === "bar1" || chartType === "bar";
481
+ return (h("div", { class: "chart-wrapper bar-wrapper" },
482
+ isHybridBar ? (h("div", { class: "single-perc" }, amountToPercent(this.slicesDetails[0].amount, this.total, true) + "%")) : (""),
483
+ this.chartType === "bar3" && this.drawAxis(),
484
+ h("div", { class: `inner-stacked-bar-wrapper ${showValue(this.tempValueFormat)}` },
485
+ !isHybridBar ? (h("div", { class: "values" }, this.slicesDetails.map((s, idx) => this.renderBarText(s, idx)))) : (""),
486
+ h("div", { class: "stacked-bar-segments-wrapper" }, this.slicesDetails.map((s, idx) => renderStackedBarSegment.call(this, s, idx))),
487
+ isHybridBar ? renderCompletionMessage.call(this) : "")));
488
+ }
489
+ function renderStackedBarSegment(s, idx) {
490
+ const isLastSlice = idx !== this.slicesDetails.length - 1;
491
+ const width = `calc(${amountToPercent(s.amount, this.total, false)}%${isLastSlice ? " - 2px" : ""})`;
492
+ return (h("div", { class: `segment stacked-bar-segment ${amountToPercent(s.amount, this.total, false) === 0 ? "zero" : ""}`, style: {
493
+ backgroundColor: s.color,
494
+ width: width,
495
+ }, onClick: (ev) => handleSliceClick.call(this, ev, s), onFocus: (ev) => handleSliceFocus.call(this, ev, s), onKeyDown: (ev) => handleSliceKeyDown.call(this, ev) },
496
+ h("span", { class: "sr-only" }, s.legend)));
497
+ }
498
+ function renderSimpleBar(chartType) {
499
+ // find largest number and get interval, numTicks, chartMaxVal for all.
500
+ const largest = this.slicesDetails
501
+ .map((s) => s.amount)
502
+ .reduce((a, b) => {
503
+ return a > b ? a : b;
504
+ });
505
+ const labelWidth = parseInt(getComputedStyle(this.el).getPropertyValue("--labelWidth"), 10);
506
+ const chartPadding = 48;
507
+ const componentWidth = this.el.getBoundingClientRect().width;
508
+ const chartWidth = componentWidth - labelWidth - chartPadding;
509
+ let numTicks = getMaxTicks(chartWidth);
510
+ let interval = getInterval(largest, numTicks);
511
+ // after the algorithm finds an interval, remove extra ticks so that the greater number is always between the last tick and the one before that
512
+ const lastTickVal = numTicks * interval;
513
+ const extraTicks = Math.floor((lastTickVal - largest) / interval);
514
+ numTicks -= extraTicks;
515
+ this.el.style.setProperty("--backgroundSize", 100 / numTicks + "%");
516
+ this.el.style.setProperty("--labelWidth", this.labelWidth);
517
+ if (chartType === "bar7" && !this.showBarLegend) {
518
+ this.el.style.setProperty("--labelWidth", "0px");
519
+ }
520
+ // we have to prep the data here rather than iterate directly in the return statement
521
+ // because CSS grid needs a flat structure, and return functions must
522
+ // have a single parent element
523
+ const rows = [];
524
+ this.slicesDetails.forEach((s) => {
525
+ s.legend && rows.push(renderSimpleBarLegend(s.legend, this.showBarLegend, chartType));
526
+ rows.push(renderSimpleBarItem.call(this, s, interval, numTicks, largest));
527
+ });
528
+ const ticks = [];
529
+ for (let i = 1; i <= numTicks; i++) {
530
+ const tickVal = abbrNumber(i * interval);
531
+ ticks.push(h("div", { class: "tick" },
532
+ h("span", null, tickVal)));
533
+ }
534
+ const showGrid = chartType === "bar6" && this.showGrid && this.el.getBoundingClientRect().width > 300;
535
+ return (h("div", { class: "chart-wrapper simple-bar-wrapper" },
536
+ h("div", { class: `chart ${showValue(this.tempValueFormat)}` },
537
+ showGrid && h("div", { class: "gridlines" }),
538
+ h("div", { class: "rows" }, rows)),
539
+ showGrid && (h("div", { class: "x-axis", "aria-hidden": "true" },
540
+ h("div", { class: "zero" },
541
+ h("span", null, "0")),
542
+ ticks))));
543
+ }
544
+ function renderSimpleBarLegend(legend, show, chartType) {
545
+ // not sure how to collapse the left column to 0 width with CSS grid. text should still be available to SR.
546
+ const hidden = chartType === "bar7" && !show ? " hidden" : "";
547
+ return h("label", { class: `label${hidden}` }, legend);
548
+ }
549
+ function renderSimpleBarItem(s, interval, ticks, largest) {
550
+ const chartMaxVal = this.currentChartType === "bar6" ? interval * ticks : largest;
551
+ const width = amountToPercent(s.amount, chartMaxVal, false);
552
+ const cssWidth = width ? width + "%" : "1px";
553
+ const amt = abbrNumber(s.amount);
554
+ let displayValue = this.tempValueFormat === "amount" ? amt : "";
555
+ if (this.currentChartType === "bar6" && this.tempValueFormat === "percentage") {
556
+ displayValue = s.amount + "%";
557
+ }
558
+ else if (this.currentChartType === "bar7" && this.tempValueFormat === "percentage") {
559
+ displayValue = amountToPercent(s.amount, this.total, true) + "%";
560
+ }
561
+ return (h("div", { class: "bar segment", style: {
562
+ backgroundColor: s.color,
563
+ width: cssWidth,
564
+ }, onClick: (ev) => handleSliceClick.call(this, ev, s), onFocus: (ev) => handleSliceFocus.call(this, ev, s), onKeyDown: (ev) => handleSliceKeyDown.call(this, ev) },
565
+ h("div", { class: "value" }, displayValue)));
566
+ }
567
+ function renderLegend(chartType) {
568
+ // legend is hidden for bar1 and bar6 types regardless of showLegend value
569
+ if (this.showLegend) {
570
+ const hasCluster = !this.chartDetails.isBar &&
571
+ this.slicesDetails.reduce((hasCluster, cur) => (hasCluster = cur.inSmallCluster ? true : hasCluster), false);
572
+ return (h("div", { class: "legend-wrapper" },
573
+ h("div", { class: `legend ${chartType} ${this.mode === "bar" ? "--top" : "--bottom"}`, "aria-hidden": "true" }, this.total > 0
574
+ ? this.slicesDetails.map((s) => {
575
+ // when both legend and amount are omitted, the legend is not shown for that particular option (it's been deactivated by the user)
576
+ if (!!s.amount || !!s.legend) {
577
+ return renderLegendItem({ key: s.legend, color: s.color });
578
+ }
579
+ })
580
+ : ""),
581
+ hasCluster && renderHiddenValuesMessage()));
582
+ }
583
+ }
584
+ function renderLegendItem(legendItem) {
585
+ return (h("div", { class: "legend-item" },
586
+ h("div", { class: "legend-color", style: { backgroundColor: legendItem.color } }),
587
+ h("div", { class: "legend-text" }, legendItem.key)));
588
+ }
589
+ function renderCompletionMessage() {
590
+ if (this.completionMessage) {
591
+ return h("div", { class: "completion-message" }, this.completionMessage);
592
+ }
593
+ }
594
+ function renderHiddenValuesMessage() {
595
+ return (h("div", { class: "hidden-values-warning" },
596
+ textHiddenMessage,
597
+ h("br", null),
598
+ seeDetailsMessage));
599
599
  }
600
600
 
601
601
  export { allChartsDetails as a, amountToPercent as b, renderSimpleBar as c, renderDoughnut as d, renderInstructionsText as e, renderLegend as f, getDetails as g, handleChartKeydown as h, renderCompletionMessage as i, renderHiddenValuesMessage as j, exitChart as k, renderLegendItem as l, renderStackedBar as r };