@watermarkinsights/ripple 3.16.0 → 3.17.0-2

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 (267) hide show
  1. package/README.md +3 -3
  2. package/dist/cjs/{chartFunctions-45d38ae4.js → chartFunctions-0c02a801.js} +425 -421
  3. package/dist/cjs/{functions-23309c38.js → functions-cb39693a.js} +483 -483
  4. package/dist/cjs/{global-5260837d.js → global-4e97582e.js} +62 -62
  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/loader.cjs.js +2 -2
  8. package/dist/cjs/priv-chart-popover.cjs.entry.js +86 -86
  9. package/dist/cjs/priv-datepicker.cjs.entry.js +657 -657
  10. package/dist/cjs/priv-navigator-button.cjs.entry.js +18 -18
  11. package/dist/cjs/priv-navigator-item.cjs.entry.js +23 -23
  12. package/dist/cjs/ripple.cjs.js +2 -2
  13. package/dist/cjs/wm-action-menu_2.cjs.entry.js +329 -329
  14. package/dist/cjs/wm-button.cjs.entry.js +248 -248
  15. package/dist/cjs/wm-chart-slice.cjs.entry.js +13 -13
  16. package/dist/cjs/wm-chart.cjs.entry.js +111 -111
  17. package/dist/cjs/wm-datepicker.cjs.entry.js +265 -265
  18. package/dist/cjs/wm-input.cjs.entry.js +134 -134
  19. package/dist/cjs/wm-modal-footer.cjs.entry.js +33 -33
  20. package/dist/cjs/wm-modal-header.cjs.entry.js +36 -36
  21. package/dist/cjs/wm-modal.cjs.entry.js +163 -163
  22. package/dist/cjs/wm-navigation_3.cjs.entry.js +227 -227
  23. package/dist/cjs/wm-navigator.cjs.entry.js +268 -268
  24. package/dist/cjs/wm-network-uploader.cjs.entry.js +455 -455
  25. package/dist/cjs/wm-option_2.cjs.entry.js +720 -720
  26. package/dist/cjs/wm-pagination.cjs.entry.js +167 -167
  27. package/dist/cjs/wm-progress-indicator_3.cjs.entry.js +139 -131
  28. package/dist/cjs/wm-search.cjs.entry.js +232 -232
  29. package/dist/cjs/wm-snackbar.cjs.entry.js +170 -170
  30. package/dist/cjs/wm-tab-item_3.cjs.entry.js +296 -296
  31. package/dist/cjs/wm-tag-input-row.cjs.entry.js +10 -10
  32. package/dist/cjs/wm-tag-input.cjs.entry.js +884 -884
  33. package/dist/cjs/wm-timepicker.cjs.entry.js +383 -383
  34. package/dist/cjs/wm-toggletip.cjs.entry.js +124 -124
  35. package/dist/cjs/wm-uploader.cjs.entry.js +556 -556
  36. package/dist/cjs/wm-wrapper.cjs.entry.js +12 -12
  37. package/dist/collection/components/charts/priv-chart-popover/priv-chart-popover.js +258 -258
  38. package/dist/collection/components/charts/wm-chart/wm-chart-slice.js +115 -115
  39. package/dist/collection/components/charts/wm-chart/wm-chart.css +81 -84
  40. package/dist/collection/components/charts/wm-chart/wm-chart.js +328 -328
  41. package/dist/collection/components/charts/wm-progress-monitor/wm-progress-indicator.css +81 -84
  42. package/dist/collection/components/charts/wm-progress-monitor/wm-progress-indicator.js +194 -195
  43. package/dist/collection/components/charts/wm-progress-monitor/wm-progress-monitor.css +86 -0
  44. package/dist/collection/components/charts/wm-progress-monitor/wm-progress-monitor.js +117 -88
  45. package/dist/collection/components/charts/wm-progress-monitor/wm-progress-slice.js +111 -111
  46. package/dist/collection/components/wm-action-menu/wm-action-menu.js +442 -442
  47. package/dist/collection/components/wm-button/wm-button.js +545 -545
  48. package/dist/collection/components/wm-datepicker/priv-datepicker/priv-datepicker.js +1024 -1024
  49. package/dist/collection/components/wm-datepicker/wm-datepicker.js +471 -471
  50. package/dist/collection/components/wm-input/wm-input.js +423 -423
  51. package/dist/collection/components/wm-menuitem/wm-menuitem.js +444 -444
  52. package/dist/collection/components/wm-modal/wm-modal-footer.js +136 -136
  53. package/dist/collection/components/wm-modal/wm-modal-header.js +87 -87
  54. package/dist/collection/components/wm-modal/wm-modal.js +461 -461
  55. package/dist/collection/components/wm-navigation/wm-navigation-hamburger.js +162 -162
  56. package/dist/collection/components/wm-navigation/wm-navigation-item.js +121 -121
  57. package/dist/collection/components/wm-navigation/wm-navigation.js +218 -218
  58. package/dist/collection/components/wm-navigator/priv-navigator-button/priv-navigator-button.js +97 -97
  59. package/dist/collection/components/wm-navigator/priv-navigator-item/priv-navigator-item.js +114 -114
  60. package/dist/collection/components/wm-navigator/wm-navigator.js +468 -468
  61. package/dist/collection/components/wm-option/wm-option.js +428 -428
  62. package/dist/collection/components/wm-pagination/wm-pagination.js +368 -368
  63. package/dist/collection/components/wm-search/wm-search.js +480 -480
  64. package/dist/collection/components/wm-select/wm-select.js +1001 -1001
  65. package/dist/collection/components/wm-snackbar/wm-snackbar.js +297 -297
  66. package/dist/collection/components/wm-tabs/wm-tab-item/wm-tab-item.js +216 -216
  67. package/dist/collection/components/wm-tabs/wm-tab-list/wm-tab-list.js +330 -330
  68. package/dist/collection/components/wm-tabs/wm-tab-panel/wm-tab-panel.js +104 -104
  69. package/dist/collection/components/wm-tag-input/wm-tag-input-row/wm-tag-input-row.js +115 -115
  70. package/dist/collection/components/wm-tag-input/wm-tag-input.js +1201 -1201
  71. package/dist/collection/components/wm-timepicker/wm-timepicker.js +583 -583
  72. package/dist/collection/components/wm-toggletip/wm-toggletip.js +241 -241
  73. package/dist/collection/components/wm-uploader/wm-network-uploader/wm-network-uploader.js +788 -788
  74. package/dist/collection/components/wm-uploader/wm-uploader.js +1000 -1000
  75. package/dist/collection/components/wm-wrapper/wm-wrapper.js +27 -27
  76. package/dist/collection/dev/scripts.js +20 -20
  77. package/dist/collection/global/__mocks__/functions.js +6 -6
  78. package/dist/collection/global/chartFunctions.js +426 -423
  79. package/dist/collection/global/functions.js +486 -486
  80. package/dist/collection/global/global.js +69 -69
  81. package/dist/collection/global/interfaces.js +49 -49
  82. package/dist/collection/global/services/__mocks__/http-service.js +130 -130
  83. package/dist/collection/global/services/http-service.js +50 -50
  84. package/dist/collection/lang/lang.js +5 -5
  85. package/dist/collection/lang/missing.js +43 -43
  86. package/dist/collection/lang/piglatin.js +93 -93
  87. package/dist/esm/{chartFunctions-4433cafc.js → chartFunctions-fe9af0f8.js} +425 -422
  88. package/dist/esm/{functions-14df5b8c.js → functions-478ab920.js} +483 -483
  89. package/dist/esm/{global-0087a2ea.js → global-32a33c56.js} +62 -62
  90. package/dist/esm/{http-service-5d037e16.js → http-service-3dc3b3e7.js} +49 -49
  91. package/dist/esm/{interfaces-61c6305b.js → interfaces-2b97fab2.js} +29 -29
  92. package/dist/esm/loader.js +2 -2
  93. package/dist/esm/polyfills/core-js.js +0 -0
  94. package/dist/esm/polyfills/dom.js +0 -0
  95. package/dist/esm/polyfills/es5-html-element.js +0 -0
  96. package/dist/esm/polyfills/index.js +0 -0
  97. package/dist/esm/polyfills/system.js +0 -0
  98. package/dist/esm/priv-chart-popover.entry.js +86 -86
  99. package/dist/esm/priv-datepicker.entry.js +657 -657
  100. package/dist/esm/priv-navigator-button.entry.js +18 -18
  101. package/dist/esm/priv-navigator-item.entry.js +23 -23
  102. package/dist/esm/ripple.js +2 -2
  103. package/dist/esm/wm-action-menu_2.entry.js +329 -329
  104. package/dist/esm/wm-button.entry.js +248 -248
  105. package/dist/esm/wm-chart-slice.entry.js +13 -13
  106. package/dist/esm/wm-chart.entry.js +111 -111
  107. package/dist/esm/wm-datepicker.entry.js +265 -265
  108. package/dist/esm/wm-input.entry.js +134 -134
  109. package/dist/esm/wm-modal-footer.entry.js +33 -33
  110. package/dist/esm/wm-modal-header.entry.js +36 -36
  111. package/dist/esm/wm-modal.entry.js +163 -163
  112. package/dist/esm/wm-navigation_3.entry.js +227 -227
  113. package/dist/esm/wm-navigator.entry.js +268 -268
  114. package/dist/esm/wm-network-uploader.entry.js +455 -455
  115. package/dist/esm/wm-option_2.entry.js +720 -720
  116. package/dist/esm/wm-pagination.entry.js +167 -167
  117. package/dist/esm/wm-progress-indicator_3.entry.js +139 -131
  118. package/dist/esm/wm-search.entry.js +232 -232
  119. package/dist/esm/wm-snackbar.entry.js +170 -170
  120. package/dist/esm/wm-tab-item_3.entry.js +296 -296
  121. package/dist/esm/wm-tag-input-row.entry.js +10 -10
  122. package/dist/esm/wm-tag-input.entry.js +884 -884
  123. package/dist/esm/wm-timepicker.entry.js +383 -383
  124. package/dist/esm/wm-toggletip.entry.js +124 -124
  125. package/dist/esm/wm-uploader.entry.js +556 -556
  126. package/dist/esm/wm-wrapper.entry.js +12 -12
  127. package/dist/esm-es5/{chartFunctions-4433cafc.js → chartFunctions-fe9af0f8.js} +1 -1
  128. package/dist/esm-es5/{functions-14df5b8c.js → functions-478ab920.js} +0 -0
  129. package/dist/esm-es5/global-32a33c56.js +1 -0
  130. package/dist/esm-es5/{http-service-5d037e16.js → http-service-3dc3b3e7.js} +0 -0
  131. package/dist/esm-es5/{interfaces-61c6305b.js → interfaces-2b97fab2.js} +0 -0
  132. package/dist/esm-es5/loader.js +1 -1
  133. package/dist/esm-es5/priv-chart-popover.entry.js +1 -1
  134. package/dist/esm-es5/priv-datepicker.entry.js +1 -1
  135. package/dist/esm-es5/ripple.js +1 -1
  136. package/dist/esm-es5/wm-action-menu_2.entry.js +1 -1
  137. package/dist/esm-es5/wm-button.entry.js +1 -1
  138. package/dist/esm-es5/wm-chart.entry.js +1 -1
  139. package/dist/esm-es5/wm-datepicker.entry.js +1 -1
  140. package/dist/esm-es5/wm-input.entry.js +1 -1
  141. package/dist/esm-es5/wm-modal-header.entry.js +1 -1
  142. package/dist/esm-es5/wm-modal.entry.js +1 -1
  143. package/dist/esm-es5/wm-navigation_3.entry.js +1 -1
  144. package/dist/esm-es5/wm-navigator.entry.js +1 -1
  145. package/dist/esm-es5/wm-network-uploader.entry.js +1 -1
  146. package/dist/esm-es5/wm-option_2.entry.js +1 -1
  147. package/dist/esm-es5/wm-pagination.entry.js +1 -1
  148. package/dist/esm-es5/wm-progress-indicator_3.entry.js +1 -1
  149. package/dist/esm-es5/wm-search.entry.js +1 -1
  150. package/dist/esm-es5/wm-snackbar.entry.js +1 -1
  151. package/dist/esm-es5/wm-tab-item_3.entry.js +1 -1
  152. package/dist/esm-es5/wm-tag-input.entry.js +1 -1
  153. package/dist/esm-es5/wm-timepicker.entry.js +1 -1
  154. package/dist/esm-es5/wm-toggletip.entry.js +1 -1
  155. package/dist/esm-es5/wm-uploader.entry.js +1 -1
  156. package/dist/ripple/{p-dfe38d43.system.entry.js → p-054ccfa1.system.entry.js} +1 -1
  157. package/dist/ripple/{p-ff011bf3.entry.js → p-09b2c614.entry.js} +1 -1
  158. package/dist/ripple/{p-d063e3e9.entry.js → p-0dd172c2.entry.js} +1 -1
  159. package/dist/ripple/{p-df2bd836.entry.js → p-10d6335d.entry.js} +1 -1
  160. package/dist/ripple/{p-923527d9.system.entry.js → p-1762bc51.system.entry.js} +1 -1
  161. package/dist/ripple/{p-d530a06f.system.entry.js → p-1a1a6d89.system.entry.js} +1 -1
  162. package/dist/ripple/{p-8707f00a.system.entry.js → p-29792d81.system.entry.js} +1 -1
  163. package/dist/ripple/{p-d24ecc0c.js → p-2b929b10.js} +1 -1
  164. package/dist/ripple/{p-aa0e1f8b.system.entry.js → p-2e6988e6.system.entry.js} +1 -1
  165. package/dist/ripple/{p-811380de.entry.js → p-34d6d1d2.entry.js} +1 -1
  166. package/dist/ripple/{p-85ea8ece.entry.js → p-3597b28b.entry.js} +1 -1
  167. package/dist/ripple/{p-1d61c7bd.system.entry.js → p-3efd31ef.system.entry.js} +1 -1
  168. package/dist/ripple/{p-6f7f1331.system.entry.js → p-3fbf3278.system.entry.js} +1 -1
  169. package/dist/ripple/{p-6b4bc7ed.system.entry.js → p-430183de.system.entry.js} +1 -1
  170. package/dist/ripple/{p-888bec42.js → p-43f1298b.js} +0 -0
  171. package/dist/ripple/{p-b545a4a1.entry.js → p-44da2057.entry.js} +1 -1
  172. package/dist/ripple/p-4a1498f7.system.js +1 -0
  173. package/dist/ripple/p-4f1bf7f5.entry.js +1 -0
  174. package/dist/ripple/{p-32c15757.entry.js → p-5bea2c87.entry.js} +1 -1
  175. package/dist/ripple/{p-0ec5e02c.system.js → p-63190f58.system.js} +0 -0
  176. package/dist/ripple/{p-959aa7ae.system.entry.js → p-695fba1d.system.entry.js} +1 -1
  177. package/dist/ripple/p-791c6577.js +1 -0
  178. package/dist/ripple/{p-2a18f87c.entry.js → p-7a654f2c.entry.js} +1 -1
  179. package/dist/ripple/p-7ce57c62.system.js +1 -0
  180. package/dist/ripple/p-7f621f1c.system.entry.js +1 -0
  181. package/dist/ripple/{p-e3114f71.entry.js → p-87edffcc.entry.js} +1 -1
  182. package/dist/ripple/p-8ee1416a.entry.js +1 -0
  183. package/dist/ripple/{p-47639d21.entry.js → p-9a603f75.entry.js} +1 -1
  184. package/dist/ripple/{p-313b6073.system.js → p-9d02957d.system.js} +0 -0
  185. package/dist/ripple/{p-6c5006d1.entry.js → p-a2663226.entry.js} +1 -1
  186. package/dist/ripple/{p-54fb8d84.entry.js → p-a60407e7.entry.js} +1 -1
  187. package/dist/ripple/{p-05d01f10.system.entry.js → p-b6eb9ed6.system.entry.js} +1 -1
  188. package/dist/ripple/p-bf4bbba3.system.js +1 -0
  189. package/dist/ripple/{p-475e8f32.entry.js → p-c56dc658.entry.js} +1 -1
  190. package/dist/ripple/{p-e62f5770.entry.js → p-c741ddb3.entry.js} +1 -1
  191. package/dist/ripple/{p-9e294a2a.system.entry.js → p-cb22eef3.system.entry.js} +1 -1
  192. package/dist/ripple/{p-fa36e7b3.js → p-cd73566d.js} +0 -0
  193. package/dist/ripple/{p-f48bf28e.system.entry.js → p-d25523dd.system.entry.js} +1 -1
  194. package/dist/ripple/{p-2f9a6860.system.entry.js → p-d872e221.system.entry.js} +1 -1
  195. package/dist/ripple/{p-4325dabd.entry.js → p-d8a12a04.entry.js} +1 -1
  196. package/dist/ripple/{p-31af715e.system.entry.js → p-d9978c48.system.entry.js} +1 -1
  197. package/dist/ripple/p-daec9ed7.system.entry.js +1 -0
  198. package/dist/ripple/{p-ebe7b4fb.entry.js → p-dc7b53bd.entry.js} +1 -1
  199. package/dist/ripple/{p-7d9920ea.system.entry.js → p-df895edb.system.entry.js} +1 -1
  200. package/dist/ripple/{p-5095fe0c.system.entry.js → p-e5a472c8.system.entry.js} +1 -1
  201. package/dist/ripple/{p-671b7adf.entry.js → p-e9b0eccc.entry.js} +1 -1
  202. package/dist/ripple/{p-2d285e1c.system.entry.js → p-ee3b6b4c.system.entry.js} +1 -1
  203. package/dist/ripple/{p-0e3e046c.system.entry.js → p-eea875ce.system.entry.js} +1 -1
  204. package/dist/ripple/{p-5b3a44fe.system.entry.js → p-f0b67d2f.system.entry.js} +1 -1
  205. package/dist/ripple/{p-08b7ec08.system.js → p-f5df5903.system.js} +0 -0
  206. package/dist/ripple/{p-cfea1f6e.entry.js → p-f62d01f9.entry.js} +1 -1
  207. package/dist/ripple/{p-0d0286c5.entry.js → p-f640448f.entry.js} +1 -1
  208. package/dist/ripple/{p-23c428dd.entry.js → p-fbd67b12.entry.js} +1 -1
  209. package/dist/ripple/{p-1a909e18.system.entry.js → p-fccab03d.system.entry.js} +1 -1
  210. package/dist/ripple/{p-a6d6eae7.js → p-fd8070fb.js} +0 -0
  211. package/dist/ripple/ripple.esm.js +1 -1
  212. package/dist/ripple/ripple.js +1 -1
  213. package/dist/types/components/charts/priv-chart-popover/priv-chart-popover.d.ts +27 -27
  214. package/dist/types/components/charts/wm-chart/wm-chart-slice.d.ts +11 -11
  215. package/dist/types/components/charts/wm-chart/wm-chart.d.ts +36 -36
  216. package/dist/types/components/charts/wm-progress-monitor/wm-progress-indicator.d.ts +27 -27
  217. package/dist/types/components/charts/wm-progress-monitor/wm-progress-monitor.d.ts +19 -17
  218. package/dist/types/components/charts/wm-progress-monitor/wm-progress-slice.d.ts +10 -10
  219. package/dist/types/components/wm-action-menu/wm-action-menu.d.ts +47 -47
  220. package/dist/types/components/wm-button/wm-button.d.ts +49 -49
  221. package/dist/types/components/wm-datepicker/priv-datepicker/priv-datepicker.d.ts +80 -80
  222. package/dist/types/components/wm-datepicker/wm-datepicker.d.ts +41 -41
  223. package/dist/types/components/wm-input/wm-input.d.ts +46 -46
  224. package/dist/types/components/wm-menuitem/wm-menuitem.d.ts +34 -34
  225. package/dist/types/components/wm-modal/wm-modal-footer.d.ts +14 -14
  226. package/dist/types/components/wm-modal/wm-modal-header.d.ts +11 -11
  227. package/dist/types/components/wm-modal/wm-modal.d.ts +41 -41
  228. package/dist/types/components/wm-navigation/wm-navigation-hamburger.d.ts +21 -21
  229. package/dist/types/components/wm-navigation/wm-navigation-item.d.ts +13 -13
  230. package/dist/types/components/wm-navigation/wm-navigation.d.ts +28 -28
  231. package/dist/types/components/wm-navigator/priv-navigator-button/priv-navigator-button.d.ts +10 -10
  232. package/dist/types/components/wm-navigator/priv-navigator-item/priv-navigator-item.d.ts +13 -13
  233. package/dist/types/components/wm-navigator/wm-navigator.d.ts +61 -61
  234. package/dist/types/components/wm-option/wm-option.d.ts +35 -35
  235. package/dist/types/components/wm-pagination/wm-pagination.d.ts +32 -32
  236. package/dist/types/components/wm-search/wm-search.d.ts +86 -86
  237. package/dist/types/components/wm-select/wm-select.d.ts +94 -94
  238. package/dist/types/components/wm-snackbar/wm-snackbar.d.ts +35 -35
  239. package/dist/types/components/wm-tabs/wm-tab-item/wm-tab-item.d.ts +38 -38
  240. package/dist/types/components/wm-tabs/wm-tab-list/wm-tab-list.d.ts +53 -53
  241. package/dist/types/components/wm-tabs/wm-tab-panel/wm-tab-panel.d.ts +20 -20
  242. package/dist/types/components/wm-tag-input/wm-tag-input-row/wm-tag-input-row.d.ts +11 -11
  243. package/dist/types/components/wm-tag-input/wm-tag-input.d.ts +126 -126
  244. package/dist/types/components/wm-timepicker/wm-timepicker.d.ts +61 -61
  245. package/dist/types/components/wm-toggletip/wm-toggletip.d.ts +27 -27
  246. package/dist/types/components/wm-uploader/wm-network-uploader/wm-network-uploader.d.ts +85 -85
  247. package/dist/types/components/wm-uploader/wm-uploader.d.ts +117 -117
  248. package/dist/types/components/wm-wrapper/wm-wrapper.d.ts +7 -7
  249. package/dist/types/components.d.ts +29 -27
  250. package/dist/types/global/__mocks__/functions.d.ts +6 -6
  251. package/dist/types/global/chartFunctions.d.ts +30 -29
  252. package/dist/types/global/functions.d.ts +46 -46
  253. package/dist/types/global/global.d.ts +1 -1
  254. package/dist/types/global/interfaces.d.ts +48 -44
  255. package/dist/types/global/services/__mocks__/http-service.d.ts +6 -6
  256. package/dist/types/global/services/http-service.d.ts +4 -4
  257. package/dist/types/lang/lang.d.ts +5 -5
  258. package/package.json +47 -47
  259. package/dist/esm-es5/global-0087a2ea.js +0 -1
  260. package/dist/ripple/p-09dca516.system.js +0 -1
  261. package/dist/ripple/p-20ad8577.entry.js +0 -1
  262. package/dist/ripple/p-276c88b5.system.entry.js +0 -1
  263. package/dist/ripple/p-4033dc2d.system.entry.js +0 -1
  264. package/dist/ripple/p-437c9944.system.js +0 -1
  265. package/dist/ripple/p-479b5d27.js +0 -1
  266. package/dist/ripple/p-71ac86cb.entry.js +0 -1
  267. package/dist/ripple/p-bbaec20d.system.js +0 -1
@@ -1,428 +1,431 @@
1
1
  'use strict';
2
2
 
3
3
  const index = require('./index-df6a3611.js');
4
- const functions = require('./functions-23309c38.js');
4
+ const functions = require('./functions-cb39693a.js');
5
5
 
6
- // Components wm-chart and wm-progress-indicator share a significant
7
- // portion of their code. It has been extracted here
8
- const colors = {
9
- salmon: "#ff5f4e",
10
- cyan: "#19a1a9",
11
- forest: "#088000",
12
- sleet: "#7f97ad",
13
- midnight: "#2e1b46",
14
- lavender: "#8b86ca",
15
- periwinkle: "#575195",
16
- gray: "#6b6b6b",
17
- };
18
- const types = {
19
- doughnut: {
20
- size: 155,
21
- colors: [colors.forest, colors.gray],
22
- thickness: 0.73,
23
- padding: 25,
24
- isBar: false,
25
- },
26
- // deprecated hybrid chart type, should use Progress Indicator's "doughnut" instead
27
- doughnut0: {
28
- size: 155,
29
- colors: [colors.forest, colors.gray],
30
- thickness: 0.73,
31
- padding: 25,
32
- isBar: false,
33
- },
34
- doughnut1: {
35
- size: 130,
36
- colors: [colors.lavender, colors.midnight, colors.gray],
37
- thickness: 0.5,
38
- padding: 90,
39
- isBar: false,
40
- },
41
- doughnut2: {
42
- size: 130,
43
- colors: [colors.cyan, colors.salmon, colors.gray],
44
- thickness: 0.5,
45
- padding: 90,
46
- isBar: false,
47
- },
48
- doughnut3: {
49
- size: 130,
50
- colors: [colors.lavender, colors.midnight, "#0089e4", colors.forest, "#ea8500", "#d54f41", "#146ca9"],
51
- thickness: 0.5,
52
- padding: 90,
53
- isBar: false,
54
- },
55
- bar: {
56
- size: 350,
57
- colors: [colors.forest, colors.gray],
58
- padding: 0,
59
- isBar: true,
60
- },
61
- // deprecated hybrid chart type, should use Progress Indicator's "bar" instead
62
- bar1: {
63
- size: 350,
64
- colors: [colors.forest, colors.gray],
65
- padding: 0,
66
- isBar: true,
67
- },
68
- bar2: {
69
- size: 400,
70
- colors: [colors.gray, colors.periwinkle, colors.cyan, colors.salmon],
71
- padding: 0,
72
- isBar: true,
73
- },
74
- bar3: {
75
- size: 300,
76
- colors: ["#0d696e", colors.cyan, "#8e4129", colors.salmon],
77
- padding: 0,
78
- isBar: true,
79
- },
80
- bar4: {
81
- size: 400,
82
- colors: [colors.salmon, colors.cyan, colors.periwinkle],
83
- padding: 0,
84
- isBar: true,
85
- },
86
- bar5: {
87
- size: 400,
88
- colors: [
89
- colors.gray,
90
- colors.lavender,
91
- colors.midnight,
92
- "#0089e4",
93
- colors.forest,
94
- "#ea8500",
95
- "#d54f41",
96
- "#146ca9",
97
- ],
98
- padding: 0,
99
- isBar: true,
100
- },
101
- };
102
- function amountToPercent(val, total, asInt) {
103
- return asInt ? Math.round((val * 100) / total) : Math.round((val * 10000) / total) / 100; // with 2 decimals
104
- }
105
- function amountToDegree(val, total) {
106
- // In a circle of {total}, determine degrees of slice {val}
107
- return (val * 360) / total;
108
- }
109
- function toFixed(number) {
110
- return parseFloat((Math.floor(number * 100) / 100).toFixed(2));
111
- }
112
- function polarToCartesian(half, radius, startAngle, endAngle) {
113
- var x = toFixed(half + half * radius * Math.cos((Math.PI * startAngle) / 180));
114
- var y = toFixed(half + half * radius * Math.sin((Math.PI * startAngle) / 180));
115
- if (endAngle !== undefined) {
116
- // if a 2nd angle value was passed, return 2 pairs of coords
117
- var x2 = toFixed(half + half * radius * Math.cos((Math.PI * endAngle) / 180));
118
- var y2 = toFixed(half + half * radius * Math.sin((Math.PI * endAngle) / 180));
119
- return { x1: x, y1: y, x2, y2 };
120
- }
121
- return { x, y };
122
- }
123
- function getArc(radius, largeArcFlag, x, y, chartSize) {
124
- var z = toFixed((chartSize / 2) * radius);
125
- return `A ${z}, ${z} 0 ${largeArcFlag} ${toFixed(x)}, ${toFixed(y)}`;
126
- }
127
- function handleSliceKeyDown(ev) {
128
- if (this.popoverEl && this.popoverEl.open && ev.key === "Enter") {
129
- const popoverBtn = this.popoverEl.querySelector("button");
130
- popoverBtn && popoverBtn.click();
131
- }
132
- }
133
- function handleSliceClick(ev, s) {
134
- if (this.popoverEl && !this.isTabbing) {
135
- s.coords = { x: ev.clientX, y: ev.clientY };
136
- openPopover.call(this, s);
137
- }
138
- }
139
- function handleSliceFocus(ev, s) {
140
- if (this.popoverEl && this.isTabbing) {
141
- s.coords = functions.getPosition(ev.target);
142
- openPopover.call(this, s);
143
- }
144
- }
145
- function handleChartKeydown(ev) {
146
- switch (ev.key) {
147
- // arrow up / left
148
- case "ArrowUp":
149
- case "ArrowLeft":
150
- ev.preventDefault();
151
- this.isTabbing = true; // shd already be true. just in case user clicked on chart then pressed an arrow key
152
- focusPrevious.call(this);
153
- break;
154
- // arrow right / down
155
- case "ArrowRight":
156
- case "ArrowDown":
157
- ev.preventDefault();
158
- this.isTabbing = true; // shd already be true. just in case user clicked on chart then pressed an arrow key
159
- focusNext.call(this);
160
- break;
161
- // tab
162
- case "Tab":
163
- exitChart.call(this);
164
- break;
165
- case "Escape":
166
- this.popoverEl.open = false;
167
- this.userIsNavigating = false;
168
- break;
169
- }
170
- }
171
- function openPopover(s) {
172
- if (!!this.popoverEl && !!s.title && !!s.text) {
173
- this.popoverEl.popoverTitle = s.title;
174
- this.popoverEl.popoverText = s.text;
175
- this.popoverEl.buttonText = s.buttonText;
176
- this.popoverEl.coords = s.coords;
177
- this.popoverEl.sliceRef = s.sliceRef;
178
- window.setTimeout(() => {
179
- if (this.popoverEl) {
180
- this.popoverEl.open = true;
181
- }
182
- }, 30);
183
- const debouncedClosePopover = functions.debounce(async () => {
184
- this.popoverEl.open = false;
185
- }, 10);
186
- // set up event listeners for scrolling
187
- // to close popover on page scroll
188
- document.addEventListener("scroll", () => {
189
- debouncedClosePopover();
190
- });
191
- // ... and on parent scroll
192
- const scrollableParent = functions.findParentWithScrollbar(this.el);
193
- if (!!scrollableParent) {
194
- scrollableParent.addEventListener("scroll", () => {
195
- debouncedClosePopover();
196
- });
197
- }
198
- }
199
- }
200
- function focusNext() {
201
- const activeEl = functions.checkForActiveElInShadow(document.activeElement);
202
- const index =
203
- // if the active el is not in the array the first element gets focused
204
- (this.sliceEls.indexOf(activeEl) + 1) % this.sliceEls.length;
205
- focusSlice.call(this, index);
206
- }
207
- function focusPrevious() {
208
- if (this.sliceEls) {
209
- const activeEl = functions.checkForActiveElInShadow(document.activeElement);
210
- let index = this.sliceEls.indexOf(activeEl);
211
- if (index === -1) {
212
- // not in the array : focus the first slice
213
- index = 0;
214
- }
215
- else if (index === 0) {
216
- // first slice : focus the last slice
217
- index = this.sliceEls.length - 1;
218
- }
219
- else {
220
- // anything else: focus previous
221
- index -= 1;
222
- }
223
- focusSlice.call(this, index);
224
- }
225
- }
226
- function focusSlice(index) {
227
- if (this.sliceEls && this.el) {
228
- this.userIsNavigating = true;
229
- if (this.popoverEl) {
230
- this.popoverEl.open = false;
231
- }
232
- this.el.tabIndex = -1;
233
- // @ts-ignore
234
- this.el.focusable = false; // for Edge
235
- this.sliceEls.map((p) => {
236
- p.tabIndex = -1;
237
- // @ts-ignore
238
- p.focusable = false; // for Edge
239
- });
240
- this.sliceEls[index].tabIndex = 0;
241
- // @ts-ignore
242
- this.sliceEls[index].focusable = true; // for Edge
243
- this.sliceEls[index].focus();
244
- window.setTimeout(() => {
245
- if (this.popoverEl) {
246
- this.popoverEl.open = true;
247
- }
248
- }, 10);
249
- }
250
- }
251
- function exitChart() {
252
- this.sliceEls &&
253
- this.sliceEls.map((p) => {
254
- p.tabIndex = -1;
255
- // @ts-ignore
256
- p.focusable = false; // for Edge
257
- });
258
- this.userIsNavigating = false;
259
- // delay so that we can tab out of component before chart becomes focusable again
260
- // and in case user was still pressing an arrow key when they pressed tab
261
- window.setTimeout(() => {
262
- if (this.el) {
263
- this.el.tabIndex = 0;
264
- // @ts-ignore
265
- this.el.focusable = true; // for Edge
266
- if (this.popoverEl) {
267
- this.popoverEl.open = false;
268
- }
269
- }
270
- }, 100);
271
- }
272
- async function getData(chartType) {
273
- this.slicesData = [];
274
- let acc = 0;
275
- const children = Array.from(this.el.children);
276
- this.total = children.reduce((total, slice) => (total += parseInt(slice.getAttribute("amount") || "0")), 0);
277
- children.forEach((c, i) => {
278
- const amount = parseInt(c.getAttribute("amount") || "0");
279
- const perc = amountToPercent(amount, this.total, true);
280
- // determine whether the slice is in a cluster of small values
281
- // to avoid percentage text overlap for small values
282
- const prev = children[i === 0 ? children.length - 1 : i - 1];
283
- const prevPerc = amountToPercent(parseInt(prev.getAttribute("amount") || "0"), this.total, true);
284
- const next = children[i === children.length - 1 ? 0 : i + 1];
285
- const nextPerc = amountToPercent(parseInt(next.getAttribute("amount") || "0"), this.total, true);
286
- const isSmall = perc < 4;
287
- const prevIsSmall = prevPerc < 5;
288
- const nextIsSmall = nextPerc < 5;
289
- let inSmallCluster = isSmall && (prevIsSmall || nextIsSmall);
290
- // because <1% slice percentage text has an additional character
291
- // the inSmallCluster threshold needs to be widened for that slice only
292
- const lessThanOnePerc = perc === 0 && amount > 0;
293
- if (lessThanOnePerc && (nextPerc < 8 || prevPerc < 8)) {
294
- inSmallCluster = true;
295
- }
296
- // for bar5, first color should be skipped unless notStartedColor is set to true
297
- const ind = chartType === "bar5" ? (this.notStartedColor ? i : i + 1) : i;
298
- const color = types[chartType].colors[ind];
299
- const sliceData = {
300
- amount: amount,
301
- perc: perc,
302
- legend: c.getAttribute("legend"),
303
- color: color || colors.gray,
304
- offset: acc,
305
- id: `${this.uid}-${i + 1}`,
306
- title: c.getAttribute("popover-title"),
307
- text: c.getAttribute("popover-text"),
308
- buttonText: c.getAttribute("popover-button-text"),
309
- sliceRef: c,
310
- inSmallCluster: inSmallCluster,
311
- };
312
- acc += amount;
313
- this.slicesData.push(sliceData);
314
- });
315
- }
316
- function getPathData(amount, offset, chartType) {
317
- const startAngle = amountToDegree(offset, this.total) - 90; // start at noon, not at 3 o'clock
318
- const activeAngle = (amount / this.total) * 360;
319
- let endAngle = startAngle + activeAngle;
320
- const largeArcFlagOuter = activeAngle > 180 ? "1 1" : "0 1";
321
- const largeArcFlagInner = activeAngle > 180 ? "1 0" : "0 0";
322
- const half = this.chartData.size / 2;
323
- const innerRadius = this.chartData.thickness;
324
- const outerRadius = 1;
325
- const isHybridDoughnut = chartType === "doughnut0" || chartType === "doughnut";
326
- const outerSeparatorOffset = 1.5;
327
- const innerSeparatorOffset = isHybridDoughnut ? 2.25 : 3;
328
- if (activeAngle === 360) {
329
- // fix to avoid bad svg shape when the path goes all around (100%)
330
- endAngle -= 0.01;
331
- }
332
- const outerCoords = polarToCartesian(half, outerRadius, startAngle + outerSeparatorOffset, // Addition for slice separator
333
- endAngle);
334
- const innerCoords = polarToCartesian(half, innerRadius, startAngle + innerSeparatorOffset, // Addition for slice separator
335
- endAngle);
336
- const moveTo = `M ${outerCoords.x1}, ${outerCoords.y1} `;
337
- const arc1 = getArc(outerRadius, largeArcFlagOuter, outerCoords.x2, outerCoords.y2, this.chartData.size);
338
- const line = ` L ${innerCoords.x2}, ${innerCoords.y2} `;
339
- const arc2 = getArc(innerRadius, largeArcFlagInner, innerCoords.x1, innerCoords.y1, this.chartData.size);
340
- return moveTo + arc1 + line + arc2 + " z";
341
- }
342
- function renderFilter() {
343
- return (index.h("defs", null,
344
- index.h("filter", { id: "wmHoverDropShadow" },
345
- index.h("feGaussianBlur", { stdDeviation: "3" }),
346
- index.h("feOffset", { result: "offsetblur" }),
347
- index.h("feFlood", { "flood-color": "#333" }),
348
- index.h("feComposite", { operator: "in", in2: "offsetblur" }),
349
- index.h("feMerge", null,
350
- index.h("feMergeNode", null),
351
- index.h("feMergeNode", { in: "SourceGraphic" })))));
352
- }
353
- function renderDoughnut(chartType) {
354
- const outerSize = this.chartData.size + this.chartData.padding;
355
- const isHybridDoughnut = chartType === "doughnut0" || chartType === "doughnut";
356
- return (index.h("div", { class: "chart-wrapper doughnut-wrapper" },
357
- index.h("svg", { width: outerSize + "px", height: outerSize + "px", id: `graphic-${this.uid}`, class: "doughnut-svg" },
358
- renderFilter(),
359
- this.slicesData.map((s) => renderPath.call(this, s, chartType)),
360
- isHybridDoughnut ? (index.h("text", { class: "value", x: "50%", y: "50%", "font-size": "1.5rem", "font-weight": "500", "text-anchor": "middle", "dominant-baseline": "middle" }, amountToPercent(this.slicesData[0].amount, this.total, true) + "%")) : (index.h("g", { transform: `translate(${this.chartData.padding / 2}, ${this.chartData.padding / 2})`, "text-anchor": "middle", "dominant-baseline": "middle" }, this.slicesData.map((s) => (s.amount > 0 ? renderDoughnutText.call(this, s) : "")))))));
361
- }
362
- function renderPath(s, chartType) {
363
- return (index.h("g", { transform: `translate(${this.chartData.padding / 2}, ${this.chartData.padding / 2})` },
364
- index.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 })));
365
- }
366
- function renderDoughnutText(s) {
367
- if (!s.inSmallCluster) {
368
- const arcMiddle = amountToDegree(s.offset + s.amount / 2, this.total);
369
- let { x, y } = polarToCartesian(this.chartData.size / 2, 1.4, arcMiddle - 90);
370
- return (index.h("text", { class: "value", x: x + "px", y: y + "px" }, `${s.perc > 0 ? s.perc : "<1"}%`));
371
- }
372
- }
373
- function renderBar(chartType) {
374
- const isHybridBar = chartType === "bar1" || chartType === "bar";
375
- return (index.h("div", { class: "chart-wrapper bar-wrapper" },
376
- isHybridBar ? (index.h("div", { class: "single-perc" }, amountToPercent(this.slicesData[0].amount, this.total, true) + "%")) : (""),
377
- this.chartType === "bar3" && this.drawAxis(),
378
- index.h("div", { class: {
379
- "inner-bar-wrapper": true,
380
- "show-values": this.tempValueFormat === "percentage" || this.tempValueFormat === "amount",
381
- } },
382
- !isHybridBar ? (index.h("div", { class: "values" }, this.slicesData.map((s, idx) => (s.perc > 0 ? this.renderBarText(s, idx) : "")))) : (""),
383
- index.h("div", { class: "bar-segments-wrapper" }, this.slicesData.map((s, idx) => renderBarSegment.call(this, s, idx))),
384
- isHybridBar ? renderCompletionMessage.call(this) : "")));
385
- }
386
- function renderBarSegment(s, idx) {
387
- const isLastSlice = idx !== this.slicesData.length - 1;
388
- const width = `calc(${amountToPercent(s.amount, this.total, false)}%${isLastSlice ? " - 2px" : ""})`;
389
- return (index.h("div", { class: `segment bar-segment ${amountToPercent(s.amount, this.total, false) === 0 ? "zero" : ""}`, style: {
390
- backgroundColor: s.color,
391
- width: width,
392
- }, onClick: (ev) => handleSliceClick.call(this, ev, s), onFocus: (ev) => handleSliceFocus.call(this, ev, s), onKeyDown: (ev) => handleSliceKeyDown.call(this, ev) },
393
- index.h("span", { class: "sr-only" }, s.legend)));
394
- }
395
- function renderLegend() {
396
- // legend is hidden for bar1 type regardless of showLegend value
397
- if (this.showLegend) {
398
- const hasCluster = this.slicesData.reduce((hasCluster, cur) => (hasCluster = cur.inSmallCluster ? true : hasCluster), false);
399
- return (index.h("div", { class: "legend-wrapper" },
400
- index.h("div", { class: `legend ${this.mode === "bar" ? "--top" : "--bottom"}`, "aria-hidden": "true" }, this.total > 0
401
- ? this.slicesData.map((s) => {
402
- // when both legend and amount are omitted, the legend is not shown for that particular option (it's been deactivated by the user)
403
- if (!!s.amount || !!s.legend) {
404
- return (index.h("div", { class: "legend-item" },
405
- index.h("div", { class: "legend-color", style: { "background-color": s.color } }),
406
- index.h("div", { class: "legend-text" }, s.legend)));
407
- }
408
- })
409
- : ""),
410
- !this.chartData.isBar && hasCluster ? (index.h("div", { class: "cluster-warning" },
411
- functions.intl.formatMessage({
412
- id: "chart.hiddenPercentages",
413
- defaultMessage: "Percentages smaller than 5% are not shown when too close to each other.",
414
- }),
415
- index.h("br", null),
416
- functions.intl.formatMessage({
417
- id: "chart.clickToSeeDetails",
418
- defaultMessage: "Click or use arrow keys to see details.",
419
- }))) : ("")));
420
- }
421
- }
422
- function renderCompletionMessage() {
423
- if (this.completionMessage) {
424
- return index.h("div", { class: "completion-message" }, this.completionMessage);
425
- }
6
+ // Components wm-chart and wm-progress-indicator share a significant
7
+ // portion of their code. It has been extracted here
8
+ const colors = {
9
+ salmon: "#ff5f4e",
10
+ cyan: "#19a1a9",
11
+ forest: "#088000",
12
+ sleet: "#7f97ad",
13
+ midnight: "#2e1b46",
14
+ lavender: "#8b86ca",
15
+ periwinkle: "#575195",
16
+ gray: "#6b6b6b",
17
+ };
18
+ const types = {
19
+ doughnut: {
20
+ size: 155,
21
+ colors: [colors.forest, colors.gray],
22
+ thickness: 0.73,
23
+ padding: 25,
24
+ isBar: false,
25
+ },
26
+ // deprecated hybrid chart type, should use Progress Indicator's "doughnut" instead
27
+ doughnut0: {
28
+ size: 155,
29
+ colors: [colors.forest, colors.gray],
30
+ thickness: 0.73,
31
+ padding: 25,
32
+ isBar: false,
33
+ },
34
+ doughnut1: {
35
+ size: 130,
36
+ colors: [colors.lavender, colors.midnight, colors.gray],
37
+ thickness: 0.5,
38
+ padding: 90,
39
+ isBar: false,
40
+ },
41
+ doughnut2: {
42
+ size: 130,
43
+ colors: [colors.cyan, colors.salmon, colors.gray],
44
+ thickness: 0.5,
45
+ padding: 90,
46
+ isBar: false,
47
+ },
48
+ doughnut3: {
49
+ size: 130,
50
+ colors: [colors.lavender, colors.midnight, "#0089e4", colors.forest, "#ea8500", "#d54f41", "#146ca9"],
51
+ thickness: 0.5,
52
+ padding: 90,
53
+ isBar: false,
54
+ },
55
+ bar: {
56
+ size: 350,
57
+ colors: [colors.forest, colors.gray],
58
+ padding: 0,
59
+ isBar: true,
60
+ },
61
+ // deprecated hybrid chart type, should use Progress Indicator's "bar" instead
62
+ bar1: {
63
+ size: 350,
64
+ colors: [colors.forest, colors.gray],
65
+ padding: 0,
66
+ isBar: true,
67
+ },
68
+ bar2: {
69
+ size: 400,
70
+ colors: [colors.gray, colors.periwinkle, colors.cyan, colors.salmon],
71
+ padding: 0,
72
+ isBar: true,
73
+ },
74
+ bar3: {
75
+ size: 300,
76
+ colors: ["#0d696e", colors.cyan, "#8e4129", colors.salmon],
77
+ padding: 0,
78
+ isBar: true,
79
+ },
80
+ bar4: {
81
+ size: 400,
82
+ colors: [colors.salmon, colors.cyan, colors.periwinkle],
83
+ padding: 0,
84
+ isBar: true,
85
+ },
86
+ bar5: {
87
+ size: 400,
88
+ colors: [
89
+ colors.gray,
90
+ colors.lavender,
91
+ colors.midnight,
92
+ "#0089e4",
93
+ colors.forest,
94
+ "#ea8500",
95
+ "#d54f41",
96
+ "#146ca9",
97
+ ],
98
+ padding: 0,
99
+ isBar: true,
100
+ },
101
+ };
102
+ function amountToPercent(val, total, asInt) {
103
+ return asInt ? Math.round((val * 100) / total) : Math.round((val * 10000) / total) / 100; // with 2 decimals
104
+ }
105
+ function amountToDegree(val, total) {
106
+ // In a circle of {total}, determine degrees of slice {val}
107
+ return (val * 360) / total;
108
+ }
109
+ function toFixed(number) {
110
+ return parseFloat((Math.floor(number * 100) / 100).toFixed(2));
111
+ }
112
+ function polarToCartesian(half, radius, startAngle, endAngle) {
113
+ var x = toFixed(half + half * radius * Math.cos((Math.PI * startAngle) / 180));
114
+ var y = toFixed(half + half * radius * Math.sin((Math.PI * startAngle) / 180));
115
+ if (endAngle !== undefined) {
116
+ // if a 2nd angle value was passed, return 2 pairs of coords
117
+ var x2 = toFixed(half + half * radius * Math.cos((Math.PI * endAngle) / 180));
118
+ var y2 = toFixed(half + half * radius * Math.sin((Math.PI * endAngle) / 180));
119
+ return { x1: x, y1: y, x2, y2 };
120
+ }
121
+ return { x, y };
122
+ }
123
+ function getArc(radius, largeArcFlag, x, y, chartSize) {
124
+ var z = toFixed((chartSize / 2) * radius);
125
+ return `A ${z}, ${z} 0 ${largeArcFlag} ${toFixed(x)}, ${toFixed(y)}`;
126
+ }
127
+ function handleSliceKeyDown(ev) {
128
+ if (this.popoverEl && this.popoverEl.open && ev.key === "Enter") {
129
+ const popoverBtn = this.popoverEl.querySelector("button");
130
+ popoverBtn && popoverBtn.click();
131
+ }
132
+ }
133
+ function handleSliceClick(ev, s) {
134
+ if (this.popoverEl && !this.isTabbing) {
135
+ s.coords = { x: ev.clientX, y: ev.clientY };
136
+ openPopover.call(this, s);
137
+ }
138
+ }
139
+ function handleSliceFocus(ev, s) {
140
+ if (this.popoverEl && this.isTabbing) {
141
+ s.coords = functions.getPosition(ev.target);
142
+ openPopover.call(this, s);
143
+ }
144
+ }
145
+ function handleChartKeydown(ev) {
146
+ switch (ev.key) {
147
+ // arrow up / left
148
+ case "ArrowUp":
149
+ case "ArrowLeft":
150
+ ev.preventDefault();
151
+ this.isTabbing = true; // shd already be true. just in case user clicked on chart then pressed an arrow key
152
+ focusPrevious.call(this);
153
+ break;
154
+ // arrow right / down
155
+ case "ArrowRight":
156
+ case "ArrowDown":
157
+ ev.preventDefault();
158
+ this.isTabbing = true; // shd already be true. just in case user clicked on chart then pressed an arrow key
159
+ focusNext.call(this);
160
+ break;
161
+ // tab
162
+ case "Tab":
163
+ exitChart.call(this);
164
+ break;
165
+ case "Escape":
166
+ this.popoverEl.open = false;
167
+ this.userIsNavigating = false;
168
+ break;
169
+ }
170
+ }
171
+ function openPopover(s) {
172
+ if (!!this.popoverEl && !!s.title && !!s.text) {
173
+ this.popoverEl.popoverTitle = s.title;
174
+ this.popoverEl.popoverText = s.text;
175
+ this.popoverEl.buttonText = s.buttonText;
176
+ this.popoverEl.coords = s.coords;
177
+ this.popoverEl.sliceRef = s.sliceRef;
178
+ window.setTimeout(() => {
179
+ if (this.popoverEl) {
180
+ this.popoverEl.open = true;
181
+ }
182
+ }, 30);
183
+ const debouncedClosePopover = functions.debounce(async () => {
184
+ this.popoverEl.open = false;
185
+ }, 10);
186
+ // set up event listeners for scrolling
187
+ // to close popover on page scroll
188
+ document.addEventListener("scroll", () => {
189
+ debouncedClosePopover();
190
+ });
191
+ // ... and on parent scroll
192
+ const scrollableParent = functions.findParentWithScrollbar(this.el);
193
+ if (!!scrollableParent) {
194
+ scrollableParent.addEventListener("scroll", () => {
195
+ debouncedClosePopover();
196
+ });
197
+ }
198
+ }
199
+ }
200
+ function focusNext() {
201
+ const activeEl = functions.checkForActiveElInShadow(document.activeElement);
202
+ const index =
203
+ // if the active el is not in the array the first element gets focused
204
+ (this.sliceEls.indexOf(activeEl) + 1) % this.sliceEls.length;
205
+ focusSlice.call(this, index);
206
+ }
207
+ function focusPrevious() {
208
+ if (this.sliceEls) {
209
+ const activeEl = functions.checkForActiveElInShadow(document.activeElement);
210
+ let index = this.sliceEls.indexOf(activeEl);
211
+ if (index === -1) {
212
+ // not in the array : focus the first slice
213
+ index = 0;
214
+ }
215
+ else if (index === 0) {
216
+ // first slice : focus the last slice
217
+ index = this.sliceEls.length - 1;
218
+ }
219
+ else {
220
+ // anything else: focus previous
221
+ index -= 1;
222
+ }
223
+ focusSlice.call(this, index);
224
+ }
225
+ }
226
+ function focusSlice(index) {
227
+ if (this.sliceEls && this.el) {
228
+ this.userIsNavigating = true;
229
+ if (this.popoverEl) {
230
+ this.popoverEl.open = false;
231
+ }
232
+ this.el.tabIndex = -1;
233
+ // @ts-ignore
234
+ this.el.focusable = false; // for Edge
235
+ this.sliceEls.map((p) => {
236
+ p.tabIndex = -1;
237
+ // @ts-ignore
238
+ p.focusable = false; // for Edge
239
+ });
240
+ this.sliceEls[index].tabIndex = 0;
241
+ // @ts-ignore
242
+ this.sliceEls[index].focusable = true; // for Edge
243
+ this.sliceEls[index].focus();
244
+ window.setTimeout(() => {
245
+ if (this.popoverEl) {
246
+ this.popoverEl.open = true;
247
+ }
248
+ }, 10);
249
+ }
250
+ }
251
+ function exitChart() {
252
+ this.sliceEls &&
253
+ this.sliceEls.map((p) => {
254
+ p.tabIndex = -1;
255
+ // @ts-ignore
256
+ p.focusable = false; // for Edge
257
+ });
258
+ this.userIsNavigating = false;
259
+ // delay so that we can tab out of component before chart becomes focusable again
260
+ // and in case user was still pressing an arrow key when they pressed tab
261
+ window.setTimeout(() => {
262
+ if (this.el) {
263
+ this.el.tabIndex = 0;
264
+ // @ts-ignore
265
+ this.el.focusable = true; // for Edge
266
+ if (this.popoverEl) {
267
+ this.popoverEl.open = false;
268
+ }
269
+ }
270
+ }, 100);
271
+ }
272
+ async function getData(chartType) {
273
+ this.slicesData = [];
274
+ let acc = 0;
275
+ const children = Array.from(this.el.children);
276
+ this.total = children.reduce((total, slice) => (total += parseInt(slice.getAttribute("amount") || "0")), 0);
277
+ children.forEach((c, i) => {
278
+ const amount = parseInt(c.getAttribute("amount") || "0");
279
+ const perc = amountToPercent(amount, this.total, true);
280
+ // determine whether the slice is in a cluster of small values
281
+ // to avoid percentage text overlap for small values
282
+ const prev = children[i === 0 ? children.length - 1 : i - 1];
283
+ const prevPerc = amountToPercent(parseInt(prev.getAttribute("amount") || "0"), this.total, true);
284
+ const next = children[i === children.length - 1 ? 0 : i + 1];
285
+ const nextPerc = amountToPercent(parseInt(next.getAttribute("amount") || "0"), this.total, true);
286
+ const isSmall = perc < 4;
287
+ const prevIsSmall = prevPerc < 5;
288
+ const nextIsSmall = nextPerc < 5;
289
+ let inSmallCluster = isSmall && (prevIsSmall || nextIsSmall);
290
+ // because <1% slice percentage text has an additional character
291
+ // the inSmallCluster threshold needs to be widened for that slice only
292
+ const lessThanOnePerc = perc === 0 && amount > 0;
293
+ if (lessThanOnePerc && (nextPerc < 8 || prevPerc < 8)) {
294
+ inSmallCluster = true;
295
+ }
296
+ // for bar5, first color should be skipped unless notStartedColor is set to true
297
+ const ind = chartType === "bar5" ? (this.notStartedColor ? i : i + 1) : i;
298
+ const color = types[chartType].colors[ind];
299
+ const sliceData = {
300
+ amount: amount,
301
+ perc: perc,
302
+ legend: c.getAttribute("legend"),
303
+ color: color || colors.gray,
304
+ offset: acc,
305
+ id: `${this.uid}-${i + 1}`,
306
+ title: c.getAttribute("popover-title"),
307
+ text: c.getAttribute("popover-text"),
308
+ buttonText: c.getAttribute("popover-button-text"),
309
+ sliceRef: c,
310
+ inSmallCluster: inSmallCluster,
311
+ };
312
+ acc += amount;
313
+ this.slicesData.push(sliceData);
314
+ });
315
+ }
316
+ function getPathData(amount, offset, chartType) {
317
+ const startAngle = amountToDegree(offset, this.total) - 90; // start at noon, not at 3 o'clock
318
+ const activeAngle = (amount / this.total) * 360;
319
+ let endAngle = startAngle + activeAngle;
320
+ const largeArcFlagOuter = activeAngle > 180 ? "1 1" : "0 1";
321
+ const largeArcFlagInner = activeAngle > 180 ? "1 0" : "0 0";
322
+ const half = this.chartData.size / 2;
323
+ const innerRadius = this.chartData.thickness;
324
+ const outerRadius = 1;
325
+ const isHybridDoughnut = chartType === "doughnut0" || chartType === "doughnut";
326
+ const outerSeparatorOffset = 1.5;
327
+ const innerSeparatorOffset = isHybridDoughnut ? 2.25 : 3;
328
+ if (activeAngle === 360) {
329
+ // fix to avoid bad svg shape when the path goes all around (100%)
330
+ endAngle -= 0.01;
331
+ }
332
+ const outerCoords = polarToCartesian(half, outerRadius, startAngle + outerSeparatorOffset, // Addition for slice separator
333
+ endAngle);
334
+ const innerCoords = polarToCartesian(half, innerRadius, startAngle + innerSeparatorOffset, // Addition for slice separator
335
+ endAngle);
336
+ const moveTo = `M ${outerCoords.x1}, ${outerCoords.y1} `;
337
+ const arc1 = getArc(outerRadius, largeArcFlagOuter, outerCoords.x2, outerCoords.y2, this.chartData.size);
338
+ const line = ` L ${innerCoords.x2}, ${innerCoords.y2} `;
339
+ const arc2 = getArc(innerRadius, largeArcFlagInner, innerCoords.x1, innerCoords.y1, this.chartData.size);
340
+ return moveTo + arc1 + line + arc2 + " z";
341
+ }
342
+ function renderFilter() {
343
+ return (index.h("defs", null,
344
+ index.h("filter", { id: "wmHoverDropShadow" },
345
+ index.h("feGaussianBlur", { stdDeviation: "3" }),
346
+ index.h("feOffset", { result: "offsetblur" }),
347
+ index.h("feFlood", { "flood-color": "#333" }),
348
+ index.h("feComposite", { operator: "in", in2: "offsetblur" }),
349
+ index.h("feMerge", null,
350
+ index.h("feMergeNode", null),
351
+ index.h("feMergeNode", { in: "SourceGraphic" })))));
352
+ }
353
+ function renderDoughnut(chartType) {
354
+ const outerSize = this.chartData.size + this.chartData.padding;
355
+ const isHybridDoughnut = chartType === "doughnut0" || chartType === "doughnut";
356
+ return (index.h("div", { class: "chart-wrapper doughnut-wrapper" },
357
+ index.h("svg", { width: outerSize + "px", height: outerSize + "px", id: `graphic-${this.uid}`, class: "doughnut-svg" },
358
+ renderFilter(),
359
+ this.slicesData.map((s) => renderPath.call(this, s, chartType)),
360
+ isHybridDoughnut ? (index.h("text", { class: "value", x: "50%", y: "50%", "font-size": "1.5rem", "font-weight": "500", "text-anchor": "middle", "dominant-baseline": "middle" }, amountToPercent(this.slicesData[0].amount, this.total, true) + "%")) : (index.h("g", { transform: `translate(${this.chartData.padding / 2}, ${this.chartData.padding / 2})`, "text-anchor": "middle", "dominant-baseline": "middle" }, this.slicesData.map((s) => (s.amount > 0 ? renderDoughnutText.call(this, s) : "")))))));
361
+ }
362
+ function renderPath(s, chartType) {
363
+ return (index.h("g", { transform: `translate(${this.chartData.padding / 2}, ${this.chartData.padding / 2})` },
364
+ index.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 })));
365
+ }
366
+ function renderDoughnutText(s) {
367
+ if (!s.inSmallCluster) {
368
+ const arcMiddle = amountToDegree(s.offset + s.amount / 2, this.total);
369
+ let { x, y } = polarToCartesian(this.chartData.size / 2, 1.4, arcMiddle - 90);
370
+ return (index.h("text", { class: "value", x: x + "px", y: y + "px" }, `${s.perc > 0 ? s.perc : "<1"}%`));
371
+ }
372
+ }
373
+ function renderBar(chartType) {
374
+ const isHybridBar = chartType === "bar1" || chartType === "bar";
375
+ return (index.h("div", { class: "chart-wrapper bar-wrapper" },
376
+ isHybridBar ? (index.h("div", { class: "single-perc" }, amountToPercent(this.slicesData[0].amount, this.total, true) + "%")) : (""),
377
+ this.chartType === "bar3" && this.drawAxis(),
378
+ index.h("div", { class: {
379
+ "inner-bar-wrapper": true,
380
+ "show-values": this.tempValueFormat === "percentage" || this.tempValueFormat === "amount",
381
+ } },
382
+ !isHybridBar ? (index.h("div", { class: "values" }, this.slicesData.map((s, idx) => (s.perc > 0 ? this.renderBarText(s, idx) : "")))) : (""),
383
+ index.h("div", { class: "bar-segments-wrapper" }, this.slicesData.map((s, idx) => renderBarSegment.call(this, s, idx))),
384
+ isHybridBar ? renderCompletionMessage.call(this) : "")));
385
+ }
386
+ function renderBarSegment(s, idx) {
387
+ const isLastSlice = idx !== this.slicesData.length - 1;
388
+ const width = `calc(${amountToPercent(s.amount, this.total, false)}%${isLastSlice ? " - 2px" : ""})`;
389
+ return (index.h("div", { class: `segment bar-segment ${amountToPercent(s.amount, this.total, false) === 0 ? "zero" : ""}`, style: {
390
+ backgroundColor: s.color,
391
+ width: width,
392
+ }, onClick: (ev) => handleSliceClick.call(this, ev, s), onFocus: (ev) => handleSliceFocus.call(this, ev, s), onKeyDown: (ev) => handleSliceKeyDown.call(this, ev) },
393
+ index.h("span", { class: "sr-only" }, s.legend)));
394
+ }
395
+ function renderLegend(chartType) {
396
+ // legend is hidden for bar1 type regardless of showLegend value
397
+ if (this.showLegend) {
398
+ const hasCluster = this.slicesData.reduce((hasCluster, cur) => (hasCluster = cur.inSmallCluster ? true : hasCluster), false);
399
+ return (index.h("div", { class: "legend-wrapper" },
400
+ index.h("div", { class: `legend ${chartType} ${this.mode === "bar" ? "--top" : "--bottom"}`, "aria-hidden": "true" }, this.total > 0
401
+ ? this.slicesData.map((s) => {
402
+ // when both legend and amount are omitted, the legend is not shown for that particular option (it's been deactivated by the user)
403
+ if (!!s.amount || !!s.legend) {
404
+ return renderLegendItem({ key: s.legend, color: s.color });
405
+ }
406
+ })
407
+ : ""),
408
+ !this.chartData.isBar && hasCluster ? (index.h("div", { class: "cluster-warning" },
409
+ functions.intl.formatMessage({
410
+ id: "chart.hiddenPercentages",
411
+ defaultMessage: "Percentages smaller than 5% are not shown when too close to each other.",
412
+ }),
413
+ index.h("br", null),
414
+ functions.intl.formatMessage({
415
+ id: "chart.clickToSeeDetails",
416
+ defaultMessage: "Click or use arrow keys to see details.",
417
+ }))) : ("")));
418
+ }
419
+ }
420
+ function renderLegendItem(legendItem) {
421
+ return (index.h("div", { class: "legend-item" },
422
+ index.h("div", { class: "legend-color", style: { backgroundColor: legendItem.color } }),
423
+ index.h("div", { class: "legend-text" }, legendItem.key)));
424
+ }
425
+ function renderCompletionMessage() {
426
+ if (this.completionMessage) {
427
+ return index.h("div", { class: "completion-message" }, this.completionMessage);
428
+ }
426
429
  }
427
430
 
428
431
  exports.amountToPercent = amountToPercent;
@@ -433,4 +436,5 @@ exports.renderBar = renderBar;
433
436
  exports.renderCompletionMessage = renderCompletionMessage;
434
437
  exports.renderDoughnut = renderDoughnut;
435
438
  exports.renderLegend = renderLegend;
439
+ exports.renderLegendItem = renderLegendItem;
436
440
  exports.types = types;