@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,541 +1,541 @@
1
- import * as lang from "../lang/lang";
2
- import { createIntl, createIntlCache } from "@formatjs/intl";
3
- const DEFAULT_LANGUAGE = "en";
4
- function getBrowserLang() {
5
- const langAttr = document.documentElement.getAttribute("lang");
6
- if (!!langAttr) {
7
- return langAttr;
8
- }
9
- else if (window.navigator && window.navigator.language) {
10
- const lang = window.navigator.languages ? window.navigator.languages[0] : window.navigator.language;
11
- return lang.slice(0, 2);
12
- }
13
- else {
14
- return DEFAULT_LANGUAGE;
15
- }
16
- }
17
- // prevents memory leak
18
- const cache = createIntlCache();
19
- const locale = getBrowserLang();
20
- export const intl = createIntl({
21
- locale: locale,
22
- defaultLocale: "en",
23
- messages: lang[locale] || lang.en,
24
- }, cache);
25
- export function generateId() {
26
- return "wmcl-" + Math.random().toString(36).substr(2, 10);
27
- }
28
- // limits how many times a function fires
29
- // use when the function should run periodically, but not too often (e.g. window resize)
30
- export function throttle(fn, wait) {
31
- let timeout;
32
- let shouldWait = false;
33
- return function () {
34
- const context = this;
35
- if (!shouldWait) {
36
- fn.apply(context, arguments);
37
- shouldWait = true;
38
- clearTimeout(timeout);
39
- timeout = setTimeout(function () {
40
- shouldWait = false;
41
- }, wait);
42
- }
43
- };
44
- }
45
- // waits until it hasn't been called for [timeout] ms.
46
- // use when the function should run only after something (event) is done firing
47
- export function debounce(fn, wait) {
48
- let timeout;
49
- return function () {
50
- const context = this;
51
- const functionCall = () => fn.apply(context, arguments);
52
- clearTimeout(timeout);
53
- timeout = setTimeout(functionCall, wait);
54
- };
55
- }
56
- export function getTextDir() {
57
- const dir = document.querySelector("html").getAttribute("dir");
58
- return dir ? dir.toLowerCase() : "";
59
- }
60
- export function getPosition(el) {
61
- const coords = el.getBoundingClientRect();
62
- let x = coords.x;
63
- let y = coords.y;
64
- // Edge doesn't have x and y
65
- if (!x) {
66
- if (getTextDir() === "rtl") {
67
- x = coords.right;
68
- }
69
- else {
70
- x = coords.left;
71
- }
72
- y = coords.top;
73
- }
74
- return { x, y };
75
- }
76
- export function findParentWithScrollbar(el) {
77
- while (!!el) {
78
- if (el.scrollHeight > el.clientHeight && ["scroll", "auto"].includes(window.getComputedStyle(el).overflowY)) {
79
- return el;
80
- }
81
- el = el.parentElement;
82
- }
83
- }
84
- export function findParentWithHiddenOverflow(el) {
85
- while (!!el) {
86
- if (window.getComputedStyle(el).overflowY !== "visible") {
87
- return el;
88
- }
89
- el = el.parentElement;
90
- }
91
- }
92
- function getContextMeasurements(el) {
93
- const fixedRect = el.getBoundingClientRect();
94
- const parentEl = findParentWithHiddenOverflow(el);
95
- const parentRect = parentEl && parentEl.getBoundingClientRect();
96
- // if parentEl is not found, measurements are checked against the viewport
97
- return {
98
- // NB boundingClientRect.bottom is space from top of viewport to bottom of el
99
- // to get space below the el -> height of viewport minus boundingClientRect.bottom
100
- spaceAbove: parentRect ? fixedRect.top - parentRect.top : fixedRect.top,
101
- // NB boundingClientRect.bottom is space from top of viewport to bottom of el
102
- // to get space below the el -> height of viewport minus boundingClientRect.bottom
103
- spaceBelow: parentRect
104
- ? parentRect.bottom - fixedRect.bottom
105
- : document.documentElement.clientHeight - fixedRect.bottom,
106
- spaceLeft: parentRect ? fixedRect.left - parentRect.left : fixedRect.left,
107
- spaceRight: parentRect
108
- ? parentRect.right - fixedRect.right
109
- : document.documentElement.clientWidth - fixedRect.right,
110
- };
111
- }
112
- export function shouldOpenUp(fixedEl, //the element visible on the page when the component is closed
113
- closableElHeight, //the dropdown/popup/etc that becomes visible when the component is open
114
- offsetAbove = 0, // if closableEl covers a part of fixedEl, that part should be offset
115
- offsetBelow = 0) {
116
- const { spaceAbove, spaceBelow } = getContextMeasurements(fixedEl);
117
- //we want to open up only if there's not enough space below AND there is enough space above
118
- const openUp = closableElHeight > spaceBelow + offsetBelow && closableElHeight <= spaceAbove + offsetAbove;
119
- return openUp;
120
- }
121
- export function shouldOpenDown(fixedEl, //the element visible on the page when the component is closed
122
- closableElHeight, //the dropdown/popup/etc that becomes visible when the component is open
123
- offsetAbove = 0, // if closableEl covers a part of fixedEl, that part should be offset
124
- offsetBelow = 0) {
125
- const { spaceAbove, spaceBelow } = getContextMeasurements(fixedEl);
126
- //we want to open up only if there's not enough space below AND there is enough space above
127
- const openDown = closableElHeight > spaceAbove + offsetAbove && closableElHeight <= spaceBelow + offsetBelow;
128
- return openDown;
129
- }
130
- export function shouldShiftRight(fixedEl, closableElWidth) {
131
- const { spaceLeft, spaceRight } = getContextMeasurements(fixedEl);
132
- const needsSpaceLeft = closableElWidth > spaceLeft && spaceRight > spaceLeft;
133
- return needsSpaceLeft;
134
- }
135
- export function shouldShiftLeft(fixedEl, closableElWidth) {
136
- const { spaceLeft, spaceRight } = getContextMeasurements(fixedEl);
137
- const needsSpaceRight = closableElWidth > spaceRight && spaceLeft > spaceRight;
138
- return needsSpaceRight;
139
- }
140
- export function adjustTooltipPlacement(placement, anchorEl, tooltipHeight, tooltipWidth) {
141
- const { spaceLeft, spaceRight, spaceBelow, spaceAbove } = getContextMeasurements(anchorEl);
142
- const enoughSpaceAbove = spaceAbove > tooltipHeight;
143
- const enoughSpaceBelow = spaceBelow > tooltipHeight;
144
- // a tooltip should never be closer than 24px to the edge of a screen
145
- const enoughSpaceLeft = spaceLeft - 24 > tooltipWidth;
146
- const enoughSpaceRight = spaceRight - 24 > tooltipWidth;
147
- const swapAbove = (placement) => {
148
- return !enoughSpaceAbove ? placement.replace("top", "bottom") : placement;
149
- };
150
- const swapBelow = (placement) => {
151
- return !enoughSpaceBelow && enoughSpaceAbove ? placement.replace("bottom", "top") : placement;
152
- };
153
- const swapLeft = (placement, centeredPosition) => {
154
- if (!enoughSpaceLeft && enoughSpaceRight) {
155
- placement = placement.replace("left", "right");
156
- }
157
- else if (!enoughSpaceLeft && !enoughSpaceRight) {
158
- placement = centeredPosition;
159
- }
160
- return placement;
161
- };
162
- const swapRight = (placement, centeredPosition) => {
163
- if (!enoughSpaceRight && enoughSpaceLeft) {
164
- placement = placement.replace("right", "left");
165
- }
166
- else if (!enoughSpaceRight && !enoughSpaceLeft) {
167
- placement = centeredPosition;
168
- }
169
- return placement;
170
- };
171
- // horizontal checks must occur before vertical checks, because horizontal can affect vertical placement but not vice versa
172
- switch (placement) {
173
- case "left":
174
- placement = swapLeft(placement, "bottom");
175
- case "right":
176
- placement = swapRight(placement, "bottom");
177
- case "top-left":
178
- placement = swapLeft(placement, "top");
179
- placement = swapAbove(placement);
180
- case "top-right":
181
- placement = swapRight(placement, "top");
182
- placement = swapAbove(placement);
183
- case "bottom-left":
184
- placement = swapLeft(placement, "bottom");
185
- placement = swapBelow(placement);
186
- case "bottom-right":
187
- placement = swapRight(placement, "bottom");
188
- placement = swapBelow(placement);
189
- case "top":
190
- placement = swapAbove(placement);
191
- case "bottom":
192
- placement = swapBelow(placement);
193
- }
194
- return placement;
195
- }
196
- export function showTooltip(placement, anchorEl, tooltipText) {
197
- const tooltipEl = document.getElementById("wm-tooltip");
198
- tooltipEl.textContent = tooltipText;
199
- // tooltip only has a maxWidth if it contains whitespace and can break
200
- const hasNoWhitespace = tooltipText.match(/^[^\s]+$/);
201
- if (hasNoWhitespace) {
202
- tooltipEl.classList.add("single-word");
203
- tooltipEl.style.setProperty("--wmTooltipMaxWidth", "none");
204
- }
205
- else {
206
- tooltipEl.classList.remove("single-word");
207
- tooltipEl.style.removeProperty("--wmTooltipMaxWidth");
208
- }
209
- const tooltipRect = tooltipEl.getBoundingClientRect();
210
- const anchorRect = anchorEl.getBoundingClientRect();
211
- const adjustedPlacement = adjustTooltipPlacement(placement, anchorEl, tooltipRect.height, tooltipRect.width);
212
- let verticalPos, horizontalPos;
213
- [verticalPos, horizontalPos] = positionTooltip(adjustedPlacement, anchorRect, tooltipRect.height, tooltipRect.width);
214
- tooltipEl.style.setProperty("--wmTooltipTop", verticalPos + "px");
215
- tooltipEl.style.setProperty("--wmTooltipLeft", horizontalPos + "px");
216
- tooltipEl.classList.add("show");
217
- }
218
- export function hideTooltip() {
219
- const tooltipEl = document.getElementById("wm-tooltip");
220
- tooltipEl.classList.remove("show");
221
- }
222
- function positionTooltip(placement, anchorRect, tooltipHeight, tooltipWidth) {
223
- // to get the center positions, calculate the difference between the button width and the tooltip width
224
- const verticalDiff = (anchorRect.height - tooltipHeight) / 2;
225
- const horizontalDiff = (anchorRect.width - tooltipWidth) / 2;
226
- // the naming convention defaults to center in the absence of a value
227
- // "top" and "bottom" imply centering horizontally; "right" and "left" imply centering vertically
228
- // therefore we first set to center and adjust accordingly
229
- let verticalPos = anchorRect.top + verticalDiff;
230
- let horizontalPos = anchorRect.left + horizontalDiff;
231
- if (placement.includes("top")) {
232
- verticalPos = anchorRect.top - tooltipHeight - 8;
233
- }
234
- if (placement.includes("bottom")) {
235
- verticalPos = anchorRect.bottom + 8;
236
- }
237
- if (placement.includes("left")) {
238
- horizontalPos = anchorRect.left - tooltipWidth - 8;
239
- }
240
- if (placement.includes("right")) {
241
- horizontalPos = anchorRect.right + 8;
242
- }
243
- // after all positioning has been calculated, if tooltip is off-screen or closer than 24px it is readjusted
244
- // this only occurs when the tooltip is overflowing to the left and is placed top or bottom
245
- // (button placed too far left, or screen size under 268px)
246
- horizontalPos = Math.max(horizontalPos, 24);
247
- return [verticalPos, horizontalPos];
248
- }
249
- export function hasRoomRight(x, spaceNeeded) {
250
- let horizOffset = 0;
251
- // if (getTextDir() === "ltr") {
252
- if (x.type === "click") {
253
- // if it's a mouse event, deal with mouse coords
254
- horizOffset = x.clientX;
255
- // if it's a focus event, the offset is 0
256
- }
257
- else if (x.type === "focus") {
258
- horizOffset = 0;
259
- }
260
- else {
261
- // otherwise an element was passed, calculate how far it is from the edge of the window
262
- let el = x; // re-assignment is for clarity
263
- while (el) {
264
- if (el.tagName == "BODY") {
265
- // deal with browser quirks with body/window/document and page scroll
266
- var xScroll = el.scrollLeft || document.documentElement.scrollLeft;
267
- horizOffset += el.offsetLeft - xScroll + el.clientLeft;
268
- }
269
- else {
270
- // for all other non-BODY elements
271
- horizOffset += el.offsetLeft - el.scrollLeft + el.clientLeft;
272
- }
273
- el = el.offsetParent;
274
- }
275
- // }
276
- }
277
- return window.innerWidth - horizOffset >= spaceNeeded;
278
- }
279
- export function checkForActiveElInShadow(element) {
280
- while (element && element.shadowRoot) {
281
- element = element.shadowRoot.activeElement;
282
- }
283
- return element;
284
- }
285
- export function checkForFocusableElInShadow(element) {
286
- const selectors = [
287
- "button",
288
- "a",
289
- "input",
290
- "select",
291
- "textarea",
292
- "wm-button",
293
- "wm-search",
294
- "wm-select",
295
- "wm-action-menu",
296
- "wm-tab-item",
297
- "wm-datepicker",
298
- ];
299
- let focusableEl = element;
300
- selectors.forEach((selector) => {
301
- if (focusableEl && focusableEl.shadowRoot) {
302
- let elInShadow = focusableEl.shadowRoot.querySelector(selector);
303
- if (elInShadow) {
304
- if (selector.startsWith("wm-")) {
305
- focusableEl = checkForFocusableElInShadow(elInShadow);
306
- }
307
- else {
308
- focusableEl = elInShadow;
309
- }
310
- }
311
- }
312
- });
313
- return focusableEl;
314
- }
315
- export function isFocusable(element) {
316
- if (element.tabIndex > 0 || (element.tabIndex === 0 && element.getAttribute("tabIndex") !== null)) {
317
- return true;
318
- }
319
- if (element.disabled) {
320
- return false;
321
- }
322
- switch (element.nodeName) {
323
- case "A":
324
- return !!element.href && element.rel != "ignore";
325
- case "INPUT":
326
- return element.type != "hidden" && element.type != "file";
327
- case "BUTTON":
328
- case "SELECT":
329
- case "TEXTAREA":
330
- case "WM-BUTTON":
331
- case "WM-SELECT":
332
- case "WM-ACTION-MENU":
333
- case "WM-DATEPICKER":
334
- case "WM-TIMEPICKER":
335
- case "WM-INPUT":
336
- case "WM-TAG-INPUT":
337
- case "WM-TAB-ITEM":
338
- case "WM-SEARCH":
339
- return true;
340
- default:
341
- return false;
342
- }
343
- }
344
- export function getFirstFocusableDescendant(element) {
345
- if (isFocusable(element)) {
346
- return checkForFocusableElInShadow(element);
347
- }
348
- else if (element.childNodes.length > 0) {
349
- element.childNodes.forEach((i) => {
350
- const childEl = getFirstFocusableDescendant(i);
351
- return childEl && checkForFocusableElInShadow(childEl);
352
- });
353
- }
354
- }
355
- export function hasValidType(file, types) {
356
- const acceptedExtensions = types.split(" ");
357
- const parts = file.name && file.name.split(".");
358
- const ext = parts && parts.length > 1 && parts[parts.length - 1];
359
- return ext
360
- ? acceptedExtensions.includes(ext.toLowerCase())
361
- : // fallback: if we couldn't obtain an extension,
362
- // validate based on MIME type...
363
- !!file.type
364
- ? getAcceptedMimeTypesList(acceptedExtensions).includes(file.type)
365
- : // ...and if that failed too, accept the file
366
- // as it's preferable to accept an invalid file
367
- // than refusing a valid one (back-end will take care of what slips through)
368
- true;
369
- }
370
- // takes a string (space separated list of extensions), returns an array of strings (corresponding MIME types)
371
- export function getAcceptedMimeTypesList(acceptedExtensions) {
372
- // this is just a list of common file types (regardless of whether they are/can be valid or not)
373
- // front end checks are just a convenience to users, independent of security.
374
- // it allows users to be notified of an invalid type as soon as they select the file, rather than when it gets uploaded
375
- const lookupTable = {
376
- aac: ["audio/aac"],
377
- abw: ["application/x-abiword"],
378
- arc: ["application/x-freearc"],
379
- avi: ["video/x-msvideo"],
380
- azw: ["application/vnd.amazon.ebook"],
381
- bin: ["application/octet-stream"],
382
- bmp: ["image/bmp"],
383
- bz: ["application/x-bzip"],
384
- bz2: ["application/x-bzip2"],
385
- csh: ["application/x-csh"],
386
- css: ["text/css"],
387
- csv: ["text/csv"],
388
- doc: ["application/msword"],
389
- docx: ["application/vnd.openxmlformats-officedocument.wordprocessingml.document"],
390
- eot: ["application/vnd.ms-fontobject"],
391
- epub: ["application/epub+zip"],
392
- gz: ["application/gzip"],
393
- gif: ["image/gif"],
394
- htm: ["text/html"],
395
- html: ["text/html"],
396
- ico: ["image/vnd.microsoft.icon"],
397
- ics: ["text/calendar"],
398
- jar: ["application/java-archive"],
399
- jpeg: ["image/jpeg"],
400
- jpg: ["image/jpeg"],
401
- js: ["text/javascript"],
402
- json: ["application/json"],
403
- jsonld: ["application/ld+json"],
404
- log: ["text/plain"],
405
- mid: ["audio/x-midi"],
406
- midi: ["audio/x-midi"],
407
- mjs: ["text/javascript"],
408
- mp3: ["audio/mpeg"],
409
- mpeg: ["video/mpeg"],
410
- mpkg: ["application/vnd.apple.installer+xml"],
411
- odp: ["application/vnd.oasis.opendocument.presentation"],
412
- ods: ["application/vnd.oasis.opendocument.spreadsheet"],
413
- odt: ["application/vnd.oasis.opendocument.text"],
414
- oga: ["audio/ogg"],
415
- ogv: ["video/ogg"],
416
- ogx: ["application/ogg"],
417
- opus: ["audio/opus"],
418
- otf: ["font/otf"],
419
- png: ["image/png"],
420
- pdf: ["application/pdf"],
421
- php: ["application/php"],
422
- ppt: ["application/vnd.ms-powerpoint"],
423
- pptx: ["application/vnd.openxmlformats-officedocument.presentationml.presentation"],
424
- rar: ["application/vnd.rar", "application/x-rar", "application/x-rar-compressed"],
425
- rtf: ["application/rtf"],
426
- sh: ["application/x-sh"],
427
- svg: ["image/svg+xml"],
428
- swf: ["application/x-shockwave-flash"],
429
- tar: ["application/x-tar"],
430
- tif: ["image/tiff"],
431
- tiff: ["image/tiff"],
432
- ts: ["video/mp2t"],
433
- ttf: ["font/ttf"],
434
- txt: ["text/plain"],
435
- vsd: ["application/vnd.visio"],
436
- wav: ["audio/wav"],
437
- weba: ["audio/webm"],
438
- webm: ["video/webm"],
439
- webp: ["image/webp"],
440
- woff: ["font/woff"],
441
- woff2: ["font/woff2"],
442
- xhtml: ["application/xhtml+xml"],
443
- xls: ["application/vnd.ms-excel"],
444
- xlsx: ["application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"],
445
- xml: ["application/xml", "text/xml"],
446
- xul: ["application/vnd.mozilla.xul+xml"],
447
- zip: ["application/zip", "application/x-zip-compressed", "multipart/x-zip"],
448
- "3gp": ["video/3gpp", "audio/3gpp"],
449
- "3g2": ["video/3gpp2", "audio/3gpp2"],
450
- "7z": ["application/x-7z-compressed"],
451
- };
452
- return acceptedExtensions.reduce((acc, ext) => acc.concat(lookupTable[ext]), []);
453
- }
454
- export function snakeCaseToCamelCase(str) {
455
- const snakeCaseRegexp = /^([a-z0-9]*)(_[a-z0-9]*)*$/g;
456
- if (snakeCaseRegexp.test(str)) {
457
- let camelCase = "";
458
- let arr = str.split("_");
459
- arr.forEach((word, idx) => {
460
- camelCase += idx === 0 ? word.toLowerCase() : word.charAt(0).toUpperCase() + word.slice(1);
461
- });
462
- return camelCase;
463
- }
464
- else {
465
- return str;
466
- }
467
- }
468
- export function csvToArray(csv) {
469
- return csv ? csv.split(/, ?/) : [];
470
- }
471
- export function getNewIndexToFocus(currentIndex, direction, listLength) {
472
- let newIndex = currentIndex;
473
- if (direction === "ArrowDown") {
474
- newIndex = (currentIndex + 1) % listLength;
475
- }
476
- if (direction === "ArrowUp") {
477
- newIndex = currentIndex === 0 ? listLength - 1 : currentIndex - 1;
478
- }
479
- return newIndex;
480
- }
481
- export function isRelatedTarget(ev, id) {
482
- // used for onBlur events to check the element that has been clicked
483
- const ids = id.split(" ");
484
- return ev.relatedTarget && ids.includes(ev.relatedTarget.id);
485
- }
486
- export function toBool(val) {
487
- // string "false" needs to be treated as bool False because react wrappers convert bool to string.
488
- return val == "false" ? false : !!val;
489
- }
490
- export function measureText(originEl, placeholderText) {
491
- const measurementEl = document.createElement("div");
492
- const originStyles = getComputedStyle(originEl);
493
- measurementEl.style.position = "absolute";
494
- measurementEl.style.top = "-100vh";
495
- measurementEl.style.fontFamily = originStyles.fontFamily;
496
- measurementEl.style.fontWeight = originStyles.fontWeight;
497
- measurementEl.style.fontSize = originStyles.fontSize;
498
- measurementEl.textContent = placeholderText;
499
- document.body.appendChild(measurementEl);
500
- const boundingClientRect = measurementEl.getBoundingClientRect();
501
- document.body.removeChild(measurementEl);
502
- return boundingClientRect;
503
- }
504
- export function safeParseJSON(toParse) {
505
- // JSON.parse will throw an exception if the string provided is not in the proper format
506
- // instead of the exception, just return null and let other logic check
507
- try {
508
- return JSON.parse(toParse);
509
- }
510
- catch (e) {
511
- return null;
512
- }
513
- }
514
- export function truncateText(textEl, text, availableSpace, endAmt) {
515
- const cloneEl = document.createElement("div");
516
- cloneEl.style.visibility = "hidden";
517
- cloneEl.style.position = "absolute";
518
- cloneEl.style.top = "-200vh";
519
- cloneEl.style.left = "-200vh";
520
- cloneEl.textContent = text;
521
- textEl.appendChild(cloneEl);
522
- const ellipses = "...";
523
- const minimumLength = 2 + ellipses.length + endAmt;
524
- let canFitText = availableSpace > cloneEl.clientWidth;
525
- if (!canFitText && text.length > minimumLength) {
526
- let frontChars = text.slice(0, text.length - endAmt - ellipses.length).trim();
527
- let endChars = text.slice(-endAmt).trim();
528
- let truncatedText = frontChars + ellipses + endChars;
529
- cloneEl.textContent = truncatedText;
530
- canFitText = availableSpace > cloneEl.clientWidth;
531
- while (!canFitText && truncatedText.length > minimumLength) {
532
- frontChars = frontChars.slice(0, -1).trim();
533
- truncatedText = frontChars + ellipses + endChars;
534
- cloneEl.textContent = truncatedText;
535
- canFitText = availableSpace > cloneEl.clientWidth;
536
- }
537
- }
538
- const truncatedText = cloneEl.textContent;
539
- cloneEl.remove();
540
- return truncatedText;
541
- }
1
+ import * as lang from "../lang/lang";
2
+ import { createIntl, createIntlCache } from "@formatjs/intl";
3
+ const DEFAULT_LANGUAGE = "en";
4
+ function getBrowserLang() {
5
+ const langAttr = document.documentElement.getAttribute("lang");
6
+ if (!!langAttr) {
7
+ return langAttr;
8
+ }
9
+ else if (window.navigator && window.navigator.language) {
10
+ const lang = window.navigator.languages ? window.navigator.languages[0] : window.navigator.language;
11
+ return lang.slice(0, 2);
12
+ }
13
+ else {
14
+ return DEFAULT_LANGUAGE;
15
+ }
16
+ }
17
+ // prevents memory leak
18
+ const cache = createIntlCache();
19
+ const locale = getBrowserLang();
20
+ export const intl = createIntl({
21
+ locale: locale,
22
+ defaultLocale: "en",
23
+ messages: lang[locale] || lang.en,
24
+ }, cache);
25
+ export function generateId() {
26
+ return "wmcl-" + Math.random().toString(36).substr(2, 10);
27
+ }
28
+ // limits how many times a function fires
29
+ // use when the function should run periodically, but not too often (e.g. window resize)
30
+ export function throttle(fn, wait) {
31
+ let timeout;
32
+ let shouldWait = false;
33
+ return function () {
34
+ const context = this;
35
+ if (!shouldWait) {
36
+ fn.apply(context, arguments);
37
+ shouldWait = true;
38
+ clearTimeout(timeout);
39
+ timeout = setTimeout(function () {
40
+ shouldWait = false;
41
+ }, wait);
42
+ }
43
+ };
44
+ }
45
+ // waits until it hasn't been called for [timeout] ms.
46
+ // use when the function should run only after something (event) is done firing
47
+ export function debounce(fn, wait) {
48
+ let timeout;
49
+ return function () {
50
+ const context = this;
51
+ const functionCall = () => fn.apply(context, arguments);
52
+ clearTimeout(timeout);
53
+ timeout = setTimeout(functionCall, wait);
54
+ };
55
+ }
56
+ export function getTextDir() {
57
+ const dir = document.querySelector("html").getAttribute("dir");
58
+ return dir ? dir.toLowerCase() : "";
59
+ }
60
+ export function getPosition(el) {
61
+ const coords = el.getBoundingClientRect();
62
+ let x = coords.x;
63
+ let y = coords.y;
64
+ // Edge doesn't have x and y
65
+ if (!x) {
66
+ if (getTextDir() === "rtl") {
67
+ x = coords.right;
68
+ }
69
+ else {
70
+ x = coords.left;
71
+ }
72
+ y = coords.top;
73
+ }
74
+ return { x, y };
75
+ }
76
+ export function findParentWithScrollbar(el) {
77
+ while (!!el) {
78
+ if (el.scrollHeight > el.clientHeight && ["scroll", "auto"].includes(window.getComputedStyle(el).overflowY)) {
79
+ return el;
80
+ }
81
+ el = el.parentElement;
82
+ }
83
+ }
84
+ export function findParentWithHiddenOverflow(el) {
85
+ while (!!el) {
86
+ if (window.getComputedStyle(el).overflowY !== "visible") {
87
+ return el;
88
+ }
89
+ el = el.parentElement;
90
+ }
91
+ }
92
+ function getContextMeasurements(el) {
93
+ const fixedRect = el.getBoundingClientRect();
94
+ const parentEl = findParentWithHiddenOverflow(el);
95
+ const parentRect = parentEl && parentEl.getBoundingClientRect();
96
+ // if parentEl is not found, measurements are checked against the viewport
97
+ return {
98
+ // NB boundingClientRect.bottom is space from top of viewport to bottom of el
99
+ // to get space below the el -> height of viewport minus boundingClientRect.bottom
100
+ spaceAbove: parentRect ? fixedRect.top - parentRect.top : fixedRect.top,
101
+ // NB boundingClientRect.bottom is space from top of viewport to bottom of el
102
+ // to get space below the el -> height of viewport minus boundingClientRect.bottom
103
+ spaceBelow: parentRect
104
+ ? parentRect.bottom - fixedRect.bottom
105
+ : document.documentElement.clientHeight - fixedRect.bottom,
106
+ spaceLeft: parentRect ? fixedRect.left - parentRect.left : fixedRect.left,
107
+ spaceRight: parentRect
108
+ ? parentRect.right - fixedRect.right
109
+ : document.documentElement.clientWidth - fixedRect.right,
110
+ };
111
+ }
112
+ export function shouldOpenUp(fixedEl, //the element visible on the page when the component is closed
113
+ closableElHeight, //the dropdown/popup/etc that becomes visible when the component is open
114
+ offsetAbove = 0, // if closableEl covers a part of fixedEl, that part should be offset
115
+ offsetBelow = 0) {
116
+ const { spaceAbove, spaceBelow } = getContextMeasurements(fixedEl);
117
+ //we want to open up only if there's not enough space below AND there is enough space above
118
+ const openUp = closableElHeight > spaceBelow + offsetBelow && closableElHeight <= spaceAbove + offsetAbove;
119
+ return openUp;
120
+ }
121
+ export function shouldOpenDown(fixedEl, //the element visible on the page when the component is closed
122
+ closableElHeight, //the dropdown/popup/etc that becomes visible when the component is open
123
+ offsetAbove = 0, // if closableEl covers a part of fixedEl, that part should be offset
124
+ offsetBelow = 0) {
125
+ const { spaceAbove, spaceBelow } = getContextMeasurements(fixedEl);
126
+ //we want to open up only if there's not enough space below AND there is enough space above
127
+ const openDown = closableElHeight > spaceAbove + offsetAbove && closableElHeight <= spaceBelow + offsetBelow;
128
+ return openDown;
129
+ }
130
+ export function shouldShiftRight(fixedEl, closableElWidth) {
131
+ const { spaceLeft, spaceRight } = getContextMeasurements(fixedEl);
132
+ const needsSpaceLeft = closableElWidth > spaceLeft && spaceRight > spaceLeft;
133
+ return needsSpaceLeft;
134
+ }
135
+ export function shouldShiftLeft(fixedEl, closableElWidth) {
136
+ const { spaceLeft, spaceRight } = getContextMeasurements(fixedEl);
137
+ const needsSpaceRight = closableElWidth > spaceRight && spaceLeft > spaceRight;
138
+ return needsSpaceRight;
139
+ }
140
+ export function adjustTooltipPlacement(placement, anchorEl, tooltipHeight, tooltipWidth) {
141
+ const { spaceLeft, spaceRight, spaceBelow, spaceAbove } = getContextMeasurements(anchorEl);
142
+ const enoughSpaceAbove = spaceAbove > tooltipHeight;
143
+ const enoughSpaceBelow = spaceBelow > tooltipHeight;
144
+ // a tooltip should never be closer than 24px to the edge of a screen
145
+ const enoughSpaceLeft = spaceLeft - 24 > tooltipWidth;
146
+ const enoughSpaceRight = spaceRight - 24 > tooltipWidth;
147
+ const swapAbove = (placement) => {
148
+ return !enoughSpaceAbove ? placement.replace("top", "bottom") : placement;
149
+ };
150
+ const swapBelow = (placement) => {
151
+ return !enoughSpaceBelow && enoughSpaceAbove ? placement.replace("bottom", "top") : placement;
152
+ };
153
+ const swapLeft = (placement, centeredPosition) => {
154
+ if (!enoughSpaceLeft && enoughSpaceRight) {
155
+ placement = placement.replace("left", "right");
156
+ }
157
+ else if (!enoughSpaceLeft && !enoughSpaceRight) {
158
+ placement = centeredPosition;
159
+ }
160
+ return placement;
161
+ };
162
+ const swapRight = (placement, centeredPosition) => {
163
+ if (!enoughSpaceRight && enoughSpaceLeft) {
164
+ placement = placement.replace("right", "left");
165
+ }
166
+ else if (!enoughSpaceRight && !enoughSpaceLeft) {
167
+ placement = centeredPosition;
168
+ }
169
+ return placement;
170
+ };
171
+ // horizontal checks must occur before vertical checks, because horizontal can affect vertical placement but not vice versa
172
+ switch (placement) {
173
+ case "left":
174
+ placement = swapLeft(placement, "bottom");
175
+ case "right":
176
+ placement = swapRight(placement, "bottom");
177
+ case "top-left":
178
+ placement = swapLeft(placement, "top");
179
+ placement = swapAbove(placement);
180
+ case "top-right":
181
+ placement = swapRight(placement, "top");
182
+ placement = swapAbove(placement);
183
+ case "bottom-left":
184
+ placement = swapLeft(placement, "bottom");
185
+ placement = swapBelow(placement);
186
+ case "bottom-right":
187
+ placement = swapRight(placement, "bottom");
188
+ placement = swapBelow(placement);
189
+ case "top":
190
+ placement = swapAbove(placement);
191
+ case "bottom":
192
+ placement = swapBelow(placement);
193
+ }
194
+ return placement;
195
+ }
196
+ export function showTooltip(placement, anchorEl, tooltipText) {
197
+ const tooltipEl = document.getElementById("wm-tooltip");
198
+ tooltipEl.textContent = tooltipText;
199
+ // tooltip only has a maxWidth if it contains whitespace and can break
200
+ const hasNoWhitespace = tooltipText.match(/^[^\s]+$/);
201
+ if (hasNoWhitespace) {
202
+ tooltipEl.classList.add("single-word");
203
+ tooltipEl.style.setProperty("--wmTooltipMaxWidth", "none");
204
+ }
205
+ else {
206
+ tooltipEl.classList.remove("single-word");
207
+ tooltipEl.style.removeProperty("--wmTooltipMaxWidth");
208
+ }
209
+ const tooltipRect = tooltipEl.getBoundingClientRect();
210
+ const anchorRect = anchorEl.getBoundingClientRect();
211
+ const adjustedPlacement = adjustTooltipPlacement(placement, anchorEl, tooltipRect.height, tooltipRect.width);
212
+ let verticalPos, horizontalPos;
213
+ [verticalPos, horizontalPos] = positionTooltip(adjustedPlacement, anchorRect, tooltipRect.height, tooltipRect.width);
214
+ tooltipEl.style.setProperty("--wmTooltipTop", verticalPos + "px");
215
+ tooltipEl.style.setProperty("--wmTooltipLeft", horizontalPos + "px");
216
+ tooltipEl.classList.add("show");
217
+ }
218
+ export function hideTooltip() {
219
+ const tooltipEl = document.getElementById("wm-tooltip");
220
+ tooltipEl.classList.remove("show");
221
+ }
222
+ function positionTooltip(placement, anchorRect, tooltipHeight, tooltipWidth) {
223
+ // to get the center positions, calculate the difference between the button width and the tooltip width
224
+ const verticalDiff = (anchorRect.height - tooltipHeight) / 2;
225
+ const horizontalDiff = (anchorRect.width - tooltipWidth) / 2;
226
+ // the naming convention defaults to center in the absence of a value
227
+ // "top" and "bottom" imply centering horizontally; "right" and "left" imply centering vertically
228
+ // therefore we first set to center and adjust accordingly
229
+ let verticalPos = anchorRect.top + verticalDiff;
230
+ let horizontalPos = anchorRect.left + horizontalDiff;
231
+ if (placement.includes("top")) {
232
+ verticalPos = anchorRect.top - tooltipHeight - 8;
233
+ }
234
+ if (placement.includes("bottom")) {
235
+ verticalPos = anchorRect.bottom + 8;
236
+ }
237
+ if (placement.includes("left")) {
238
+ horizontalPos = anchorRect.left - tooltipWidth - 8;
239
+ }
240
+ if (placement.includes("right")) {
241
+ horizontalPos = anchorRect.right + 8;
242
+ }
243
+ // after all positioning has been calculated, if tooltip is off-screen or closer than 24px it is readjusted
244
+ // this only occurs when the tooltip is overflowing to the left and is placed top or bottom
245
+ // (button placed too far left, or screen size under 268px)
246
+ horizontalPos = Math.max(horizontalPos, 24);
247
+ return [verticalPos, horizontalPos];
248
+ }
249
+ export function hasRoomRight(x, spaceNeeded) {
250
+ let horizOffset = 0;
251
+ // if (getTextDir() === "ltr") {
252
+ if (x.type === "click") {
253
+ // if it's a mouse event, deal with mouse coords
254
+ horizOffset = x.clientX;
255
+ // if it's a focus event, the offset is 0
256
+ }
257
+ else if (x.type === "focus") {
258
+ horizOffset = 0;
259
+ }
260
+ else {
261
+ // otherwise an element was passed, calculate how far it is from the edge of the window
262
+ let el = x; // re-assignment is for clarity
263
+ while (el) {
264
+ if (el.tagName == "BODY") {
265
+ // deal with browser quirks with body/window/document and page scroll
266
+ var xScroll = el.scrollLeft || document.documentElement.scrollLeft;
267
+ horizOffset += el.offsetLeft - xScroll + el.clientLeft;
268
+ }
269
+ else {
270
+ // for all other non-BODY elements
271
+ horizOffset += el.offsetLeft - el.scrollLeft + el.clientLeft;
272
+ }
273
+ el = el.offsetParent;
274
+ }
275
+ // }
276
+ }
277
+ return window.innerWidth - horizOffset >= spaceNeeded;
278
+ }
279
+ export function checkForActiveElInShadow(element) {
280
+ while (element && element.shadowRoot) {
281
+ element = element.shadowRoot.activeElement;
282
+ }
283
+ return element;
284
+ }
285
+ export function checkForFocusableElInShadow(element) {
286
+ const selectors = [
287
+ "button",
288
+ "a",
289
+ "input",
290
+ "select",
291
+ "textarea",
292
+ "wm-button",
293
+ "wm-search",
294
+ "wm-select",
295
+ "wm-action-menu",
296
+ "wm-tab-item",
297
+ "wm-datepicker",
298
+ ];
299
+ let focusableEl = element;
300
+ selectors.forEach((selector) => {
301
+ if (focusableEl && focusableEl.shadowRoot) {
302
+ let elInShadow = focusableEl.shadowRoot.querySelector(selector);
303
+ if (elInShadow) {
304
+ if (selector.startsWith("wm-")) {
305
+ focusableEl = checkForFocusableElInShadow(elInShadow);
306
+ }
307
+ else {
308
+ focusableEl = elInShadow;
309
+ }
310
+ }
311
+ }
312
+ });
313
+ return focusableEl;
314
+ }
315
+ export function isFocusable(element) {
316
+ if (element.tabIndex > 0 || (element.tabIndex === 0 && element.getAttribute("tabIndex") !== null)) {
317
+ return true;
318
+ }
319
+ if (element.disabled) {
320
+ return false;
321
+ }
322
+ switch (element.nodeName) {
323
+ case "A":
324
+ return !!element.href && element.rel != "ignore";
325
+ case "INPUT":
326
+ return element.type != "hidden" && element.type != "file";
327
+ case "BUTTON":
328
+ case "SELECT":
329
+ case "TEXTAREA":
330
+ case "WM-BUTTON":
331
+ case "WM-SELECT":
332
+ case "WM-ACTION-MENU":
333
+ case "WM-DATEPICKER":
334
+ case "WM-TIMEPICKER":
335
+ case "WM-INPUT":
336
+ case "WM-TAG-INPUT":
337
+ case "WM-TAB-ITEM":
338
+ case "WM-SEARCH":
339
+ return true;
340
+ default:
341
+ return false;
342
+ }
343
+ }
344
+ export function getFirstFocusableDescendant(element) {
345
+ if (isFocusable(element)) {
346
+ return checkForFocusableElInShadow(element);
347
+ }
348
+ else if (element.childNodes.length > 0) {
349
+ element.childNodes.forEach((i) => {
350
+ const childEl = getFirstFocusableDescendant(i);
351
+ return childEl && checkForFocusableElInShadow(childEl);
352
+ });
353
+ }
354
+ }
355
+ export function hasValidType(file, types) {
356
+ const acceptedExtensions = types.split(" ");
357
+ const parts = file.name && file.name.split(".");
358
+ const ext = parts && parts.length > 1 && parts[parts.length - 1];
359
+ return ext
360
+ ? acceptedExtensions.includes(ext.toLowerCase())
361
+ : // fallback: if we couldn't obtain an extension,
362
+ // validate based on MIME type...
363
+ !!file.type
364
+ ? getAcceptedMimeTypesList(acceptedExtensions).includes(file.type)
365
+ : // ...and if that failed too, accept the file
366
+ // as it's preferable to accept an invalid file
367
+ // than refusing a valid one (back-end will take care of what slips through)
368
+ true;
369
+ }
370
+ // takes a string (space separated list of extensions), returns an array of strings (corresponding MIME types)
371
+ export function getAcceptedMimeTypesList(acceptedExtensions) {
372
+ // this is just a list of common file types (regardless of whether they are/can be valid or not)
373
+ // front end checks are just a convenience to users, independent of security.
374
+ // it allows users to be notified of an invalid type as soon as they select the file, rather than when it gets uploaded
375
+ const lookupTable = {
376
+ aac: ["audio/aac"],
377
+ abw: ["application/x-abiword"],
378
+ arc: ["application/x-freearc"],
379
+ avi: ["video/x-msvideo"],
380
+ azw: ["application/vnd.amazon.ebook"],
381
+ bin: ["application/octet-stream"],
382
+ bmp: ["image/bmp"],
383
+ bz: ["application/x-bzip"],
384
+ bz2: ["application/x-bzip2"],
385
+ csh: ["application/x-csh"],
386
+ css: ["text/css"],
387
+ csv: ["text/csv"],
388
+ doc: ["application/msword"],
389
+ docx: ["application/vnd.openxmlformats-officedocument.wordprocessingml.document"],
390
+ eot: ["application/vnd.ms-fontobject"],
391
+ epub: ["application/epub+zip"],
392
+ gz: ["application/gzip"],
393
+ gif: ["image/gif"],
394
+ htm: ["text/html"],
395
+ html: ["text/html"],
396
+ ico: ["image/vnd.microsoft.icon"],
397
+ ics: ["text/calendar"],
398
+ jar: ["application/java-archive"],
399
+ jpeg: ["image/jpeg"],
400
+ jpg: ["image/jpeg"],
401
+ js: ["text/javascript"],
402
+ json: ["application/json"],
403
+ jsonld: ["application/ld+json"],
404
+ log: ["text/plain"],
405
+ mid: ["audio/x-midi"],
406
+ midi: ["audio/x-midi"],
407
+ mjs: ["text/javascript"],
408
+ mp3: ["audio/mpeg"],
409
+ mpeg: ["video/mpeg"],
410
+ mpkg: ["application/vnd.apple.installer+xml"],
411
+ odp: ["application/vnd.oasis.opendocument.presentation"],
412
+ ods: ["application/vnd.oasis.opendocument.spreadsheet"],
413
+ odt: ["application/vnd.oasis.opendocument.text"],
414
+ oga: ["audio/ogg"],
415
+ ogv: ["video/ogg"],
416
+ ogx: ["application/ogg"],
417
+ opus: ["audio/opus"],
418
+ otf: ["font/otf"],
419
+ png: ["image/png"],
420
+ pdf: ["application/pdf"],
421
+ php: ["application/php"],
422
+ ppt: ["application/vnd.ms-powerpoint"],
423
+ pptx: ["application/vnd.openxmlformats-officedocument.presentationml.presentation"],
424
+ rar: ["application/vnd.rar", "application/x-rar", "application/x-rar-compressed"],
425
+ rtf: ["application/rtf"],
426
+ sh: ["application/x-sh"],
427
+ svg: ["image/svg+xml"],
428
+ swf: ["application/x-shockwave-flash"],
429
+ tar: ["application/x-tar"],
430
+ tif: ["image/tiff"],
431
+ tiff: ["image/tiff"],
432
+ ts: ["video/mp2t"],
433
+ ttf: ["font/ttf"],
434
+ txt: ["text/plain"],
435
+ vsd: ["application/vnd.visio"],
436
+ wav: ["audio/wav"],
437
+ weba: ["audio/webm"],
438
+ webm: ["video/webm"],
439
+ webp: ["image/webp"],
440
+ woff: ["font/woff"],
441
+ woff2: ["font/woff2"],
442
+ xhtml: ["application/xhtml+xml"],
443
+ xls: ["application/vnd.ms-excel"],
444
+ xlsx: ["application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"],
445
+ xml: ["application/xml", "text/xml"],
446
+ xul: ["application/vnd.mozilla.xul+xml"],
447
+ zip: ["application/zip", "application/x-zip-compressed", "multipart/x-zip"],
448
+ "3gp": ["video/3gpp", "audio/3gpp"],
449
+ "3g2": ["video/3gpp2", "audio/3gpp2"],
450
+ "7z": ["application/x-7z-compressed"],
451
+ };
452
+ return acceptedExtensions.reduce((acc, ext) => acc.concat(lookupTable[ext]), []);
453
+ }
454
+ export function snakeCaseToCamelCase(str) {
455
+ const snakeCaseRegexp = /^([a-z0-9]*)(_[a-z0-9]*)*$/g;
456
+ if (snakeCaseRegexp.test(str)) {
457
+ let camelCase = "";
458
+ let arr = str.split("_");
459
+ arr.forEach((word, idx) => {
460
+ camelCase += idx === 0 ? word.toLowerCase() : word.charAt(0).toUpperCase() + word.slice(1);
461
+ });
462
+ return camelCase;
463
+ }
464
+ else {
465
+ return str;
466
+ }
467
+ }
468
+ export function csvToArray(csv) {
469
+ return csv ? csv.split(/, ?/) : [];
470
+ }
471
+ export function getNewIndexToFocus(currentIndex, direction, listLength) {
472
+ let newIndex = currentIndex;
473
+ if (direction === "ArrowDown") {
474
+ newIndex = (currentIndex + 1) % listLength;
475
+ }
476
+ if (direction === "ArrowUp") {
477
+ newIndex = currentIndex === 0 ? listLength - 1 : currentIndex - 1;
478
+ }
479
+ return newIndex;
480
+ }
481
+ export function isRelatedTarget(ev, id) {
482
+ // used for onBlur events to check the element that has been clicked
483
+ const ids = id.split(" ");
484
+ return ev.relatedTarget && ids.includes(ev.relatedTarget.id);
485
+ }
486
+ export function toBool(val) {
487
+ // string "false" needs to be treated as bool False because react wrappers convert bool to string.
488
+ return val == "false" ? false : !!val;
489
+ }
490
+ export function measureText(originEl, placeholderText) {
491
+ const measurementEl = document.createElement("div");
492
+ const originStyles = getComputedStyle(originEl);
493
+ measurementEl.style.position = "absolute";
494
+ measurementEl.style.top = "-100vh";
495
+ measurementEl.style.fontFamily = originStyles.fontFamily;
496
+ measurementEl.style.fontWeight = originStyles.fontWeight;
497
+ measurementEl.style.fontSize = originStyles.fontSize;
498
+ measurementEl.textContent = placeholderText;
499
+ document.body.appendChild(measurementEl);
500
+ const boundingClientRect = measurementEl.getBoundingClientRect();
501
+ document.body.removeChild(measurementEl);
502
+ return boundingClientRect;
503
+ }
504
+ export function safeParseJSON(toParse) {
505
+ // JSON.parse will throw an exception if the string provided is not in the proper format
506
+ // instead of the exception, just return null and let other logic check
507
+ try {
508
+ return JSON.parse(toParse);
509
+ }
510
+ catch (e) {
511
+ return null;
512
+ }
513
+ }
514
+ export function truncateText(textEl, text, availableSpace, endAmt) {
515
+ const cloneEl = document.createElement("div");
516
+ cloneEl.style.visibility = "hidden";
517
+ cloneEl.style.position = "absolute";
518
+ cloneEl.style.top = "-200vh";
519
+ cloneEl.style.left = "-200vh";
520
+ cloneEl.textContent = text;
521
+ textEl.appendChild(cloneEl);
522
+ const ellipses = "...";
523
+ const minimumLength = 2 + ellipses.length + endAmt;
524
+ let canFitText = availableSpace > cloneEl.clientWidth;
525
+ if (!canFitText && text.length > minimumLength) {
526
+ let frontChars = text.slice(0, text.length - endAmt - ellipses.length).trim();
527
+ let endChars = text.slice(-endAmt).trim();
528
+ let truncatedText = frontChars + ellipses + endChars;
529
+ cloneEl.textContent = truncatedText;
530
+ canFitText = availableSpace > cloneEl.clientWidth;
531
+ while (!canFitText && truncatedText.length > minimumLength) {
532
+ frontChars = frontChars.slice(0, -1).trim();
533
+ truncatedText = frontChars + ellipses + endChars;
534
+ cloneEl.textContent = truncatedText;
535
+ canFitText = availableSpace > cloneEl.clientWidth;
536
+ }
537
+ }
538
+ const truncatedText = cloneEl.textContent;
539
+ cloneEl.remove();
540
+ return truncatedText;
541
+ }