@watermarkinsights/ripple 3.26.0-9 → 3.26.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (278) hide show
  1. package/README.md +3 -3
  2. package/dist/cjs/{chartFunctions-d746b939.js → chartFunctions-b7452189.js} +596 -596
  3. package/dist/cjs/{functions-68f637b4.js → functions-a047a8ea.js} +503 -503
  4. package/dist/cjs/{global-0f60d748.js → global-21ae6c78.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-d9ffc76c.js → intl-47d63c8f.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 +260 -260
  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 +137 -137
  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 +225 -225
  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 +155 -155
  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 +939 -939
  36. package/dist/cjs/wm-timepicker.cjs.entry.js +385 -385
  37. package/dist/cjs/wm-toggletip.cjs.entry.js +130 -130
  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 +575 -575
  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.css +5 -1
  54. package/dist/collection/components/wm-input/wm-input.js +509 -509
  55. package/dist/collection/components/wm-menuitem/wm-menuitem.js +454 -454
  56. package/dist/collection/components/wm-modal/wm-modal-footer.js +138 -138
  57. package/dist/collection/components/wm-modal/wm-modal-header.js +82 -82
  58. package/dist/collection/components/wm-modal/wm-modal.js +462 -462
  59. package/dist/collection/components/wm-navigation/wm-navigation-hamburger.js +176 -176
  60. package/dist/collection/components/wm-navigation/wm-navigation-item.js +130 -130
  61. package/dist/collection/components/wm-navigation/wm-navigation.js +217 -217
  62. package/dist/collection/components/wm-navigator/priv-navigator-button/priv-navigator-button.js +106 -106
  63. package/dist/collection/components/wm-navigator/priv-navigator-item/priv-navigator-item.js +123 -123
  64. package/dist/collection/components/wm-navigator/wm-navigator.js +467 -467
  65. package/dist/collection/components/wm-option/wm-option.js +435 -435
  66. package/dist/collection/components/wm-pagination/wm-pagination.js +370 -370
  67. package/dist/collection/components/wm-search/wm-search.js +439 -439
  68. package/dist/collection/components/wm-select/wm-select.js +1054 -1054
  69. package/dist/collection/components/wm-snackbar/wm-snackbar.js +282 -282
  70. package/dist/collection/components/wm-tabs/wm-tab-item/wm-tab-item.js +211 -211
  71. package/dist/collection/components/wm-tabs/wm-tab-list/wm-tab-list.js +327 -327
  72. package/dist/collection/components/wm-tabs/wm-tab-panel/wm-tab-panel.js +108 -108
  73. package/dist/collection/components/wm-tag-input/wm-tag-input-row/wm-tag-input-row.js +122 -122
  74. package/dist/collection/components/wm-tag-input/wm-tag-input.js +1294 -1294
  75. package/dist/collection/components/wm-timepicker/wm-timepicker.js +605 -605
  76. package/dist/collection/components/wm-toggletip/wm-toggletip.js +253 -253
  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 +546 -546
  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-5c1ad085.js → chartFunctions-9d629e09.js} +596 -596
  92. package/dist/esm/{functions-b2582352.js → functions-3b813e0c.js} +503 -503
  93. package/dist/esm/{global-86bf0ca6.js → global-c7bb5530.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-6732dd5b.js → intl-d544f922.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 +260 -260
  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 +137 -137
  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 +225 -225
  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 +155 -155
  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 +939 -939
  130. package/dist/esm/wm-timepicker.entry.js +385 -385
  131. package/dist/esm/wm-toggletip.entry.js +130 -130
  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-5c1ad085.js → chartFunctions-9d629e09.js} +1 -1
  135. package/dist/esm-es5/global-c7bb5530.js +1 -0
  136. package/dist/esm-es5/{intl-6732dd5b.js → intl-d544f922.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-d5a420fa.entry.js → p-05563588.entry.js} +1 -1
  163. package/dist/ripple/{p-061914bf.system.entry.js → p-09a04f55.system.entry.js} +1 -1
  164. package/dist/ripple/{p-a2f10a77.entry.js → p-09bc0aa7.entry.js} +1 -1
  165. package/dist/ripple/{p-0414179c.entry.js → p-0cfc0d13.entry.js} +1 -1
  166. package/dist/ripple/{p-a9080b82.entry.js → p-0ef638b7.entry.js} +1 -1
  167. package/dist/ripple/{p-f740c48c.system.entry.js → p-12c70659.system.entry.js} +1 -1
  168. package/dist/ripple/p-169606b9.system.js +1 -0
  169. package/dist/ripple/{p-7ee31208.js → p-18c2f4fe.js} +1 -1
  170. package/dist/ripple/{p-462e7cf8.system.entry.js → p-236dab05.system.entry.js} +1 -1
  171. package/dist/ripple/{p-9baf62ae.entry.js → p-2cd5477a.entry.js} +1 -1
  172. package/dist/ripple/{p-2cef256c.system.entry.js → p-2cde4ade.system.entry.js} +1 -1
  173. package/dist/ripple/{p-076a8729.entry.js → p-2d46dbea.entry.js} +1 -1
  174. package/dist/ripple/{p-3313df40.system.entry.js → p-2dd5f5c3.system.entry.js} +1 -1
  175. package/dist/ripple/{p-64b64f40.system.entry.js → p-35790e4e.system.entry.js} +1 -1
  176. package/dist/ripple/{p-4e7489a3.system.entry.js → p-38819b27.system.entry.js} +1 -1
  177. package/dist/ripple/{p-926aab51.entry.js → p-3aa8e5f5.entry.js} +1 -1
  178. package/dist/ripple/{p-42739dba.entry.js → p-42f8f3ff.entry.js} +1 -1
  179. package/dist/ripple/{p-c1d814f8.system.entry.js → p-4444add0.system.entry.js} +1 -1
  180. package/dist/ripple/{p-0648aa61.system.entry.js → p-4f5a48dd.system.entry.js} +1 -1
  181. package/dist/ripple/{p-2948bf33.system.entry.js → p-4fb81a33.system.entry.js} +1 -1
  182. package/dist/ripple/{p-22b74491.entry.js → p-51b38033.entry.js} +1 -1
  183. package/dist/ripple/{p-9706537b.system.js → p-54a2b7d6.system.js} +1 -1
  184. package/dist/ripple/{p-00edfbc8.system.entry.js → p-56ba575c.system.entry.js} +1 -1
  185. package/dist/ripple/{p-b7f204e6.entry.js → p-5708349e.entry.js} +1 -1
  186. package/dist/ripple/{p-7dafc84b.system.entry.js → p-630bd6f5.system.entry.js} +1 -1
  187. package/dist/ripple/{p-b7982fab.system.js → p-6eb2c2d5.system.js} +1 -1
  188. package/dist/ripple/{p-a966a18c.entry.js → p-72b9b986.entry.js} +1 -1
  189. package/dist/ripple/p-76015762.js +1 -0
  190. package/dist/ripple/{p-3aaf86e4.entry.js → p-7f15df83.entry.js} +1 -1
  191. package/dist/ripple/{p-5ddb1660.entry.js → p-832910a0.entry.js} +1 -1
  192. package/dist/ripple/{p-66bb46e5.system.entry.js → p-84ce9b67.system.entry.js} +1 -1
  193. package/dist/ripple/{p-e6fde200.system.entry.js → p-8775e10b.system.entry.js} +1 -1
  194. package/dist/ripple/{p-6f96c28d.entry.js → p-8b23f32b.entry.js} +1 -1
  195. package/dist/ripple/{p-17490d32.entry.js → p-8c853762.entry.js} +1 -1
  196. package/dist/ripple/{p-81b26d3a.system.entry.js → p-8ff578ad.system.entry.js} +1 -1
  197. package/dist/ripple/{p-9b9e60aa.system.entry.js → p-95aa793b.system.entry.js} +1 -1
  198. package/dist/ripple/{p-9b28a31f.entry.js → p-95f4e5a1.entry.js} +1 -1
  199. package/dist/ripple/{p-accdf91c.system.entry.js → p-a006968b.system.entry.js} +1 -1
  200. package/dist/ripple/{p-2d33df00.system.js → p-a48e4f1a.system.js} +1 -1
  201. package/dist/ripple/{p-094388f1.entry.js → p-ae1e1db8.entry.js} +1 -1
  202. package/dist/ripple/{p-3b582301.entry.js → p-b3d97de8.entry.js} +1 -1
  203. package/dist/ripple/{p-f8418ac9.entry.js → p-bdecbb63.entry.js} +1 -1
  204. package/dist/ripple/{p-b805612a.system.entry.js → p-c3665c9f.system.entry.js} +1 -1
  205. package/dist/ripple/{p-d7f77b2c.js → p-d96b86c9.js} +1 -1
  206. package/dist/ripple/p-d973fe13.system.entry.js +1 -0
  207. package/dist/ripple/{p-0503e614.system.entry.js → p-ea99fb58.system.entry.js} +1 -1
  208. package/dist/ripple/{p-bd94e7c3.entry.js → p-eeeec290.entry.js} +1 -1
  209. package/dist/ripple/{p-a5662a2c.system.entry.js → p-f2bb38d0.system.entry.js} +1 -1
  210. package/dist/ripple/{p-043b4874.entry.js → p-f6c9c95f.entry.js} +1 -1
  211. package/dist/ripple/{p-731beaab.system.entry.js → p-f6f80b8d.system.entry.js} +1 -1
  212. package/dist/ripple/{p-49f7f1da.entry.js → p-fe76e568.entry.js} +1 -1
  213. package/dist/ripple/{p-60f58a39.system.entry.js → p-fea37751.system.entry.js} +1 -1
  214. package/dist/ripple/{p-5b7e1b5d.entry.js → p-ffb83b6f.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 +49 -49
  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 +21 -21
  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 +31 -31
  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 +136 -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 +28 -28
  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 +49 -49
  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/esm-es5/global-86bf0ca6.js +0 -1
  267. package/dist/ripple/p-233c8059.js +0 -1
  268. package/dist/ripple/p-9f9a5a1f.system.js +0 -1
  269. package/dist/ripple/p-e4cef02b.system.entry.js +0 -1
  270. /package/dist/esm-es5/{functions-b2582352.js → functions-3b813e0c.js} +0 -0
  271. /package/dist/esm-es5/{http-service-5d037e16.js → http-service-3dc3b3e7.js} +0 -0
  272. /package/dist/esm-es5/{interfaces-61c6305b.js → interfaces-2b97fab2.js} +0 -0
  273. /package/dist/ripple/{p-9e94ae94.system.js → p-190afa40.system.js} +0 -0
  274. /package/dist/ripple/{p-888bec42.js → p-43f1298b.js} +0 -0
  275. /package/dist/ripple/{p-5384856b.js → p-4a0e1d2d.js} +0 -0
  276. /package/dist/ripple/{p-313b6073.system.js → p-9d02957d.system.js} +0 -0
  277. /package/dist/ripple/{p-08b7ec08.system.js → p-f5df5903.system.js} +0 -0
  278. /package/dist/ripple/{p-a6d6eae7.js → p-fd8070fb.js} +0 -0
@@ -1,546 +1,546 @@
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
- export function getClosableElementMeasurements(fixedEl, closableEl) {
93
- const parent = findParentWithHiddenOverflow(fixedEl);
94
- // if parent is not found, measurements are checked against the viewport
95
- return {
96
- closableElHeight: closableEl.clientHeight,
97
- closableElWidth: closableEl.clientWidth,
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: parent
101
- ? fixedEl.getBoundingClientRect().top - parent.getBoundingClientRect().top
102
- : fixedEl.getBoundingClientRect().top,
103
- // NB boundingClientRect.bottom is space from top of viewport to bottom of el
104
- // to get space below the el -> height of viewport minus boundingClientRect.bottom
105
- spaceBelow: parent
106
- ? parent.getBoundingClientRect().bottom - fixedEl.getBoundingClientRect().bottom
107
- : document.documentElement.clientHeight - fixedEl.getBoundingClientRect().bottom,
108
- spaceLeft: parent
109
- ? fixedEl.getBoundingClientRect().left - parent.getBoundingClientRect().left
110
- : fixedEl.getBoundingClientRect().left,
111
- spaceRight: parent
112
- ? parent.getBoundingClientRect().right - fixedEl.getBoundingClientRect().right
113
- : document.documentElement.clientWidth - fixedEl.getBoundingClientRect().right,
114
- };
115
- }
116
- export function shouldOpenUp(fixedEl, //the element visible on the page when the component is closed
117
- closableEl, //the dropdown/popup/etc that becomes visible when the component is open
118
- offsetAbove = 0, // if closableEl covers a part of fixedEl, that part should be offset
119
- offsetBelow = 0 // if closableEl covers a part of fixedEl, that part should be offset
120
- ) {
121
- const { closableElHeight, spaceAbove, spaceBelow } = getClosableElementMeasurements(fixedEl, closableEl);
122
- //we want to open up only if there's not enough space below AND there is enough space above
123
- const openUp = closableElHeight > spaceBelow + offsetBelow && closableElHeight <= spaceAbove + offsetAbove;
124
- return openUp;
125
- }
126
- export function shouldOpenDown(fixedEl, //the element visible on the page when the component is closed
127
- closableEl, //the dropdown/popup/etc that becomes visible when the component is open
128
- offsetAbove = 0, // if closableEl covers a part of fixedEl, that part should be offset
129
- offsetBelow = 0 // if closableEl covers a part of fixedEl, that part should be offset
130
- ) {
131
- const { closableElHeight, spaceAbove, spaceBelow } = getClosableElementMeasurements(fixedEl, closableEl);
132
- //we want to open up only if there's not enough space below AND there is enough space above
133
- const openDown = closableElHeight > spaceAbove + offsetAbove && closableElHeight <= spaceBelow + offsetBelow;
134
- return openDown;
135
- }
136
- export function shouldShiftRight(fixedEl, closableEl) {
137
- const { closableElWidth, spaceLeft, spaceRight } = getClosableElementMeasurements(fixedEl, closableEl);
138
- const needsSpaceLeft = closableElWidth > spaceLeft && spaceRight > spaceLeft;
139
- return needsSpaceLeft;
140
- }
141
- export function shouldShiftLeft(fixedEl, closableEl) {
142
- const { closableElWidth, spaceLeft, spaceRight } = getClosableElementMeasurements(fixedEl, closableEl);
143
- const needsSpaceRight = closableElWidth > spaceRight && spaceLeft > spaceRight;
144
- return needsSpaceRight;
145
- }
146
- export function adjustTooltipPlacement(tPos, el, tooltipEl) {
147
- const { spaceLeft, spaceRight, spaceBelow, spaceAbove } = getClosableElementMeasurements(el, tooltipEl);
148
- const tooltipWidth = tooltipEl.getBoundingClientRect().width;
149
- const tooltipHeight = tooltipEl.getBoundingClientRect().height;
150
- const enoughSpaceAbove = spaceAbove > tooltipHeight;
151
- const enoughSpaceBelow = spaceBelow > tooltipHeight;
152
- // a tooltip should never be closer than 24px to the edge of a screen
153
- const enoughSpaceLeft = spaceLeft - 24 > tooltipWidth;
154
- const enoughSpaceRight = spaceRight - 24 > tooltipWidth;
155
- const swapAbove = (position) => {
156
- return !enoughSpaceAbove ? position.replace("top", "bottom") : position;
157
- };
158
- const swapBelow = (position) => {
159
- return !enoughSpaceBelow && enoughSpaceAbove ? position.replace("bottom", "top") : position;
160
- };
161
- const swapLeft = (position, centeredPosition) => {
162
- if (!enoughSpaceLeft && enoughSpaceRight) {
163
- position = position.replace("left", "right");
164
- }
165
- else if (!enoughSpaceLeft && !enoughSpaceRight) {
166
- position = centeredPosition;
167
- }
168
- return position;
169
- };
170
- const swapRight = (position, centeredPosition) => {
171
- if (!enoughSpaceRight && enoughSpaceLeft) {
172
- position = position.replace("right", "left");
173
- }
174
- else if (!enoughSpaceRight && !enoughSpaceLeft) {
175
- position = centeredPosition;
176
- }
177
- return position;
178
- };
179
- // horizontal checks must occur before vertical checks, because horizontal can affect vertical positioning but not vice versa
180
- switch (tPos) {
181
- case "left":
182
- tPos = swapLeft(tPos, "bottom");
183
- case "right":
184
- tPos = swapRight(tPos, "bottom");
185
- case "top-left":
186
- tPos = swapLeft(tPos, "top");
187
- tPos = swapAbove(tPos);
188
- case "top-right":
189
- tPos = swapRight(tPos, "top");
190
- tPos = swapAbove(tPos);
191
- case "bottom-left":
192
- tPos = swapLeft(tPos, "bottom");
193
- tPos = swapBelow(tPos);
194
- case "bottom-right":
195
- tPos = swapRight(tPos, "bottom");
196
- tPos = swapBelow(tPos);
197
- case "top":
198
- tPos = swapAbove(tPos);
199
- case "bottom":
200
- tPos = swapBelow(tPos);
201
- }
202
- return tPos;
203
- }
204
- export function showTooltip(position, anchorEl, tooltipText) {
205
- const tooltipEl = document.getElementById("wm-tooltip");
206
- tooltipEl.textContent = tooltipText;
207
- // tooltip only has a maxWidth if it contains whitespace and can break
208
- const hasNoWhitespace = tooltipText.match(/^[^\s]+$/);
209
- if (hasNoWhitespace) {
210
- tooltipEl.classList.add("single-word");
211
- tooltipEl.style.setProperty("--wmTooltipMaxWidth", "none");
212
- }
213
- else {
214
- tooltipEl.classList.remove("single-word");
215
- tooltipEl.style.removeProperty("--wmTooltipMaxWidth");
216
- }
217
- positionTooltip(position, anchorEl, tooltipEl);
218
- tooltipEl.classList.add("open");
219
- }
220
- export function hideTooltip() {
221
- const tooltipEl = document.getElementById("wm-tooltip");
222
- tooltipEl.classList.remove("open");
223
- }
224
- export function positionTooltip(tPos, anchorEl, tooltipEl) {
225
- const tooltipHeight = tooltipEl.getBoundingClientRect().height;
226
- const tooltipWidth = tooltipEl.getBoundingClientRect().width;
227
- // to get the center positions, calculate the difference between the button width and the tooltip width
228
- const verticalDiff = (anchorEl.getBoundingClientRect().height - tooltipHeight) / 2;
229
- const horizontalDiff = (anchorEl.getBoundingClientRect().width - tooltipWidth) / 2;
230
- // the naming convention defaults to center in the absence of a value
231
- // "top" and "bottom" imply centering horizontally; "right" and "left" imply centering vertically
232
- // therefore we first set to center and adjust accordingly
233
- let verticalPos = anchorEl.getBoundingClientRect().top + verticalDiff;
234
- let horizontalPos = anchorEl.getBoundingClientRect().left + horizontalDiff;
235
- if (tPos.includes("top")) {
236
- verticalPos = anchorEl.getBoundingClientRect().top - tooltipHeight - 8;
237
- }
238
- if (tPos.includes("bottom")) {
239
- verticalPos = anchorEl.getBoundingClientRect().bottom + 8;
240
- }
241
- if (tPos.includes("left")) {
242
- horizontalPos = anchorEl.getBoundingClientRect().left - tooltipWidth - 8;
243
- }
244
- if (tPos.includes("right")) {
245
- horizontalPos = anchorEl.getBoundingClientRect().right + 8;
246
- }
247
- // after all positioning has been calculated, if tooltip is off-screen or closer than 24px it is readjusted
248
- // this only occurs when the tooltip is overflowing to the left and is positioned top or bottom
249
- // (button placed too far left, or screen size under 268px)
250
- horizontalPos = Math.max(horizontalPos, 24);
251
- tooltipEl.style.setProperty("--wmTooltipTop", verticalPos + "px");
252
- tooltipEl.style.setProperty("--wmTooltipLeft", horizontalPos + "px");
253
- }
254
- export function hasRoomRight(x, spaceNeeded) {
255
- let horizOffset = 0;
256
- // if (getTextDir() === "ltr") {
257
- if (x.type === "click") {
258
- // if it's a mouse event, deal with mouse coords
259
- horizOffset = x.clientX;
260
- // if it's a focus event, the offset is 0
261
- }
262
- else if (x.type === "focus") {
263
- horizOffset = 0;
264
- }
265
- else {
266
- // otherwise an element was passed, calculate how far it is from the edge of the window
267
- let el = x; // re-assignment is for clarity
268
- while (el) {
269
- if (el.tagName == "BODY") {
270
- // deal with browser quirks with body/window/document and page scroll
271
- var xScroll = el.scrollLeft || document.documentElement.scrollLeft;
272
- horizOffset += el.offsetLeft - xScroll + el.clientLeft;
273
- }
274
- else {
275
- // for all other non-BODY elements
276
- horizOffset += el.offsetLeft - el.scrollLeft + el.clientLeft;
277
- }
278
- el = el.offsetParent;
279
- }
280
- // }
281
- }
282
- return window.innerWidth - horizOffset >= spaceNeeded;
283
- }
284
- export function checkForActiveElInShadow(element) {
285
- while (element && element.shadowRoot) {
286
- element = element.shadowRoot.activeElement;
287
- }
288
- return element;
289
- }
290
- export function checkForFocusableElInShadow(element) {
291
- const selectors = [
292
- "button",
293
- "a",
294
- "input",
295
- "select",
296
- "textarea",
297
- "wm-button",
298
- "wm-search",
299
- "wm-select",
300
- "wm-action-menu",
301
- "wm-tab-item",
302
- "wm-datepicker",
303
- ];
304
- let focusableEl = element;
305
- selectors.forEach((selector) => {
306
- if (focusableEl && focusableEl.shadowRoot) {
307
- let elInShadow = focusableEl.shadowRoot.querySelector(selector);
308
- if (elInShadow) {
309
- if (selector.startsWith("wm-")) {
310
- focusableEl = checkForFocusableElInShadow(elInShadow);
311
- }
312
- else {
313
- focusableEl = elInShadow;
314
- }
315
- }
316
- }
317
- });
318
- return focusableEl;
319
- }
320
- export function isFocusable(element) {
321
- if (element.tabIndex > 0 || (element.tabIndex === 0 && element.getAttribute("tabIndex") !== null)) {
322
- return true;
323
- }
324
- if (element.disabled) {
325
- return false;
326
- }
327
- switch (element.nodeName) {
328
- case "A":
329
- return !!element.href && element.rel != "ignore";
330
- case "INPUT":
331
- return element.type != "hidden" && element.type != "file";
332
- case "BUTTON":
333
- case "SELECT":
334
- case "TEXTAREA":
335
- case "WM-BUTTON":
336
- case "WM-SELECT":
337
- case "WM-ACTION-MENU":
338
- case "WM-DATEPICKER":
339
- case "WM-TIMEPICKER":
340
- case "WM-INPUT":
341
- case "WM-TAG-INPUT":
342
- case "WM-TAB-ITEM":
343
- case "WM-SEARCH":
344
- return true;
345
- default:
346
- return false;
347
- }
348
- }
349
- export function getFirstFocusableDescendant(element) {
350
- if (isFocusable(element)) {
351
- return checkForFocusableElInShadow(element);
352
- }
353
- else if (element.childNodes.length > 0) {
354
- element.childNodes.forEach((i) => {
355
- const childEl = getFirstFocusableDescendant(i);
356
- return childEl && checkForFocusableElInShadow(childEl);
357
- });
358
- }
359
- }
360
- export function hasValidType(file, types) {
361
- const acceptedExtensions = types.split(" ");
362
- const parts = file.name && file.name.split(".");
363
- const ext = parts && parts.length > 1 && parts[parts.length - 1];
364
- return ext
365
- ? acceptedExtensions.includes(ext.toLowerCase())
366
- : // fallback: if we couldn't obtain an extension,
367
- // validate based on MIME type...
368
- !!file.type
369
- ? getAcceptedMimeTypesList(acceptedExtensions).includes(file.type)
370
- : // ...and if that failed too, accept the file
371
- // as it's preferable to accept an invalid file
372
- // than refusing a valid one (back-end will take care of what slips through)
373
- true;
374
- }
375
- // takes a string (space separated list of extensions), returns an array of strings (corresponding MIME types)
376
- export function getAcceptedMimeTypesList(acceptedExtensions) {
377
- // this is just a list of common file types (regardless of whether they are/can be valid or not)
378
- // front end checks are just a convenience to users, independent of security.
379
- // it allows users to be notified of an invalid type as soon as they select the file, rather than when it gets uploaded
380
- const lookupTable = {
381
- aac: ["audio/aac"],
382
- abw: ["application/x-abiword"],
383
- arc: ["application/x-freearc"],
384
- avi: ["video/x-msvideo"],
385
- azw: ["application/vnd.amazon.ebook"],
386
- bin: ["application/octet-stream"],
387
- bmp: ["image/bmp"],
388
- bz: ["application/x-bzip"],
389
- bz2: ["application/x-bzip2"],
390
- csh: ["application/x-csh"],
391
- css: ["text/css"],
392
- csv: ["text/csv"],
393
- doc: ["application/msword"],
394
- docx: ["application/vnd.openxmlformats-officedocument.wordprocessingml.document"],
395
- eot: ["application/vnd.ms-fontobject"],
396
- epub: ["application/epub+zip"],
397
- gz: ["application/gzip"],
398
- gif: ["image/gif"],
399
- htm: ["text/html"],
400
- html: ["text/html"],
401
- ico: ["image/vnd.microsoft.icon"],
402
- ics: ["text/calendar"],
403
- jar: ["application/java-archive"],
404
- jpeg: ["image/jpeg"],
405
- jpg: ["image/jpeg"],
406
- js: ["text/javascript"],
407
- json: ["application/json"],
408
- jsonld: ["application/ld+json"],
409
- log: ["text/plain"],
410
- mid: ["audio/x-midi"],
411
- midi: ["audio/x-midi"],
412
- mjs: ["text/javascript"],
413
- mp3: ["audio/mpeg"],
414
- mpeg: ["video/mpeg"],
415
- mpkg: ["application/vnd.apple.installer+xml"],
416
- odp: ["application/vnd.oasis.opendocument.presentation"],
417
- ods: ["application/vnd.oasis.opendocument.spreadsheet"],
418
- odt: ["application/vnd.oasis.opendocument.text"],
419
- oga: ["audio/ogg"],
420
- ogv: ["video/ogg"],
421
- ogx: ["application/ogg"],
422
- opus: ["audio/opus"],
423
- otf: ["font/otf"],
424
- png: ["image/png"],
425
- pdf: ["application/pdf"],
426
- php: ["application/php"],
427
- ppt: ["application/vnd.ms-powerpoint"],
428
- pptx: ["application/vnd.openxmlformats-officedocument.presentationml.presentation"],
429
- rar: ["application/vnd.rar", "application/x-rar", "application/x-rar-compressed"],
430
- rtf: ["application/rtf"],
431
- sh: ["application/x-sh"],
432
- svg: ["image/svg+xml"],
433
- swf: ["application/x-shockwave-flash"],
434
- tar: ["application/x-tar"],
435
- tif: ["image/tiff"],
436
- tiff: ["image/tiff"],
437
- ts: ["video/mp2t"],
438
- ttf: ["font/ttf"],
439
- txt: ["text/plain"],
440
- vsd: ["application/vnd.visio"],
441
- wav: ["audio/wav"],
442
- weba: ["audio/webm"],
443
- webm: ["video/webm"],
444
- webp: ["image/webp"],
445
- woff: ["font/woff"],
446
- woff2: ["font/woff2"],
447
- xhtml: ["application/xhtml+xml"],
448
- xls: ["application/vnd.ms-excel"],
449
- xlsx: ["application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"],
450
- xml: ["application/xml", "text/xml"],
451
- xul: ["application/vnd.mozilla.xul+xml"],
452
- zip: ["application/zip", "application/x-zip-compressed", "multipart/x-zip"],
453
- "3gp": ["video/3gpp", "audio/3gpp"],
454
- "3g2": ["video/3gpp2", "audio/3gpp2"],
455
- "7z": ["application/x-7z-compressed"],
456
- };
457
- return acceptedExtensions.reduce((acc, ext) => acc.concat(lookupTable[ext]), []);
458
- }
459
- export function snakeCaseToCamelCase(str) {
460
- const snakeCaseRegexp = /^([a-z0-9]*)(_[a-z0-9]*)*$/g;
461
- if (snakeCaseRegexp.test(str)) {
462
- let camelCase = "";
463
- let arr = str.split("_");
464
- arr.forEach((word, idx) => {
465
- camelCase += idx === 0 ? word.toLowerCase() : word.charAt(0).toUpperCase() + word.slice(1);
466
- });
467
- return camelCase;
468
- }
469
- else {
470
- return str;
471
- }
472
- }
473
- export function csvToArray(csv) {
474
- return csv ? csv.split(/, ?/) : [];
475
- }
476
- export function getNewIndexToFocus(currentIndex, direction, listLength) {
477
- let newIndex = currentIndex;
478
- if (direction === "ArrowDown") {
479
- newIndex = (currentIndex + 1) % listLength;
480
- }
481
- if (direction === "ArrowUp") {
482
- newIndex = currentIndex === 0 ? listLength - 1 : currentIndex - 1;
483
- }
484
- return newIndex;
485
- }
486
- export function isRelatedTarget(ev, id) {
487
- // used for onBlur events to check the element that has been clicked
488
- const ids = id.split(" ");
489
- return ev.relatedTarget && ids.includes(ev.relatedTarget.id);
490
- }
491
- export function toBool(val) {
492
- // string "false" needs to be treated as bool False because react wrappers convert bool to string.
493
- return val == "false" ? false : !!val;
494
- }
495
- export function measureText(originEl, placeholderText) {
496
- const measurementEl = document.createElement("div");
497
- const originStyles = getComputedStyle(originEl);
498
- measurementEl.style.position = "absolute";
499
- measurementEl.style.top = "-100vh";
500
- measurementEl.style.fontFamily = originStyles.fontFamily;
501
- measurementEl.style.fontWeight = originStyles.fontWeight;
502
- measurementEl.style.fontSize = originStyles.fontSize;
503
- measurementEl.textContent = placeholderText;
504
- document.body.appendChild(measurementEl);
505
- const boundingClientRect = measurementEl.getBoundingClientRect();
506
- document.body.removeChild(measurementEl);
507
- return boundingClientRect;
508
- }
509
- export function safeParseJSON(toParse) {
510
- // JSON.parse will throw an exception if the string provided is not in the proper format
511
- // instead of the exception, just return null and let other logic check
512
- try {
513
- return JSON.parse(toParse);
514
- }
515
- catch (e) {
516
- return null;
517
- }
518
- }
519
- export function truncateText(textEl, text, availableSpace, endAmt) {
520
- const cloneEl = document.createElement("div");
521
- cloneEl.style.visibility = "hidden";
522
- cloneEl.style.position = "absolute";
523
- cloneEl.style.top = "-200vh";
524
- cloneEl.style.left = "-200vh";
525
- cloneEl.textContent = text;
526
- textEl.appendChild(cloneEl);
527
- const ellipses = "...";
528
- const minimumLength = 2 + ellipses.length + endAmt;
529
- let canFitText = availableSpace > cloneEl.clientWidth;
530
- if (!canFitText && text.length > minimumLength) {
531
- let frontChars = text.slice(0, text.length - endAmt - ellipses.length).trim();
532
- let endChars = text.slice(-endAmt).trim();
533
- let truncatedText = frontChars + ellipses + endChars;
534
- cloneEl.textContent = truncatedText;
535
- canFitText = availableSpace > cloneEl.clientWidth;
536
- while (!canFitText && truncatedText.length > minimumLength) {
537
- frontChars = frontChars.slice(0, -1).trim();
538
- truncatedText = frontChars + ellipses + endChars;
539
- cloneEl.textContent = truncatedText;
540
- canFitText = availableSpace > cloneEl.clientWidth;
541
- }
542
- }
543
- const truncatedText = cloneEl.textContent;
544
- cloneEl.remove();
545
- return truncatedText;
546
- }
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
+ export function getClosableElementMeasurements(fixedEl, closableEl) {
93
+ const parent = findParentWithHiddenOverflow(fixedEl);
94
+ // if parent is not found, measurements are checked against the viewport
95
+ return {
96
+ closableElHeight: closableEl.clientHeight,
97
+ closableElWidth: closableEl.clientWidth,
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: parent
101
+ ? fixedEl.getBoundingClientRect().top - parent.getBoundingClientRect().top
102
+ : fixedEl.getBoundingClientRect().top,
103
+ // NB boundingClientRect.bottom is space from top of viewport to bottom of el
104
+ // to get space below the el -> height of viewport minus boundingClientRect.bottom
105
+ spaceBelow: parent
106
+ ? parent.getBoundingClientRect().bottom - fixedEl.getBoundingClientRect().bottom
107
+ : document.documentElement.clientHeight - fixedEl.getBoundingClientRect().bottom,
108
+ spaceLeft: parent
109
+ ? fixedEl.getBoundingClientRect().left - parent.getBoundingClientRect().left
110
+ : fixedEl.getBoundingClientRect().left,
111
+ spaceRight: parent
112
+ ? parent.getBoundingClientRect().right - fixedEl.getBoundingClientRect().right
113
+ : document.documentElement.clientWidth - fixedEl.getBoundingClientRect().right,
114
+ };
115
+ }
116
+ export function shouldOpenUp(fixedEl, //the element visible on the page when the component is closed
117
+ closableEl, //the dropdown/popup/etc that becomes visible when the component is open
118
+ offsetAbove = 0, // if closableEl covers a part of fixedEl, that part should be offset
119
+ offsetBelow = 0 // if closableEl covers a part of fixedEl, that part should be offset
120
+ ) {
121
+ const { closableElHeight, spaceAbove, spaceBelow } = getClosableElementMeasurements(fixedEl, closableEl);
122
+ //we want to open up only if there's not enough space below AND there is enough space above
123
+ const openUp = closableElHeight > spaceBelow + offsetBelow && closableElHeight <= spaceAbove + offsetAbove;
124
+ return openUp;
125
+ }
126
+ export function shouldOpenDown(fixedEl, //the element visible on the page when the component is closed
127
+ closableEl, //the dropdown/popup/etc that becomes visible when the component is open
128
+ offsetAbove = 0, // if closableEl covers a part of fixedEl, that part should be offset
129
+ offsetBelow = 0 // if closableEl covers a part of fixedEl, that part should be offset
130
+ ) {
131
+ const { closableElHeight, spaceAbove, spaceBelow } = getClosableElementMeasurements(fixedEl, closableEl);
132
+ //we want to open up only if there's not enough space below AND there is enough space above
133
+ const openDown = closableElHeight > spaceAbove + offsetAbove && closableElHeight <= spaceBelow + offsetBelow;
134
+ return openDown;
135
+ }
136
+ export function shouldShiftRight(fixedEl, closableEl) {
137
+ const { closableElWidth, spaceLeft, spaceRight } = getClosableElementMeasurements(fixedEl, closableEl);
138
+ const needsSpaceLeft = closableElWidth > spaceLeft && spaceRight > spaceLeft;
139
+ return needsSpaceLeft;
140
+ }
141
+ export function shouldShiftLeft(fixedEl, closableEl) {
142
+ const { closableElWidth, spaceLeft, spaceRight } = getClosableElementMeasurements(fixedEl, closableEl);
143
+ const needsSpaceRight = closableElWidth > spaceRight && spaceLeft > spaceRight;
144
+ return needsSpaceRight;
145
+ }
146
+ export function adjustTooltipPlacement(tPos, el, tooltipEl) {
147
+ const { spaceLeft, spaceRight, spaceBelow, spaceAbove } = getClosableElementMeasurements(el, tooltipEl);
148
+ const tooltipWidth = tooltipEl.getBoundingClientRect().width;
149
+ const tooltipHeight = tooltipEl.getBoundingClientRect().height;
150
+ const enoughSpaceAbove = spaceAbove > tooltipHeight;
151
+ const enoughSpaceBelow = spaceBelow > tooltipHeight;
152
+ // a tooltip should never be closer than 24px to the edge of a screen
153
+ const enoughSpaceLeft = spaceLeft - 24 > tooltipWidth;
154
+ const enoughSpaceRight = spaceRight - 24 > tooltipWidth;
155
+ const swapAbove = (position) => {
156
+ return !enoughSpaceAbove ? position.replace("top", "bottom") : position;
157
+ };
158
+ const swapBelow = (position) => {
159
+ return !enoughSpaceBelow && enoughSpaceAbove ? position.replace("bottom", "top") : position;
160
+ };
161
+ const swapLeft = (position, centeredPosition) => {
162
+ if (!enoughSpaceLeft && enoughSpaceRight) {
163
+ position = position.replace("left", "right");
164
+ }
165
+ else if (!enoughSpaceLeft && !enoughSpaceRight) {
166
+ position = centeredPosition;
167
+ }
168
+ return position;
169
+ };
170
+ const swapRight = (position, centeredPosition) => {
171
+ if (!enoughSpaceRight && enoughSpaceLeft) {
172
+ position = position.replace("right", "left");
173
+ }
174
+ else if (!enoughSpaceRight && !enoughSpaceLeft) {
175
+ position = centeredPosition;
176
+ }
177
+ return position;
178
+ };
179
+ // horizontal checks must occur before vertical checks, because horizontal can affect vertical positioning but not vice versa
180
+ switch (tPos) {
181
+ case "left":
182
+ tPos = swapLeft(tPos, "bottom");
183
+ case "right":
184
+ tPos = swapRight(tPos, "bottom");
185
+ case "top-left":
186
+ tPos = swapLeft(tPos, "top");
187
+ tPos = swapAbove(tPos);
188
+ case "top-right":
189
+ tPos = swapRight(tPos, "top");
190
+ tPos = swapAbove(tPos);
191
+ case "bottom-left":
192
+ tPos = swapLeft(tPos, "bottom");
193
+ tPos = swapBelow(tPos);
194
+ case "bottom-right":
195
+ tPos = swapRight(tPos, "bottom");
196
+ tPos = swapBelow(tPos);
197
+ case "top":
198
+ tPos = swapAbove(tPos);
199
+ case "bottom":
200
+ tPos = swapBelow(tPos);
201
+ }
202
+ return tPos;
203
+ }
204
+ export function showTooltip(position, anchorEl, tooltipText) {
205
+ const tooltipEl = document.getElementById("wm-tooltip");
206
+ tooltipEl.textContent = tooltipText;
207
+ // tooltip only has a maxWidth if it contains whitespace and can break
208
+ const hasNoWhitespace = tooltipText.match(/^[^\s]+$/);
209
+ if (hasNoWhitespace) {
210
+ tooltipEl.classList.add("single-word");
211
+ tooltipEl.style.setProperty("--wmTooltipMaxWidth", "none");
212
+ }
213
+ else {
214
+ tooltipEl.classList.remove("single-word");
215
+ tooltipEl.style.removeProperty("--wmTooltipMaxWidth");
216
+ }
217
+ positionTooltip(position, anchorEl, tooltipEl);
218
+ tooltipEl.classList.add("open");
219
+ }
220
+ export function hideTooltip() {
221
+ const tooltipEl = document.getElementById("wm-tooltip");
222
+ tooltipEl.classList.remove("open");
223
+ }
224
+ export function positionTooltip(tPos, anchorEl, tooltipEl) {
225
+ const tooltipHeight = tooltipEl.getBoundingClientRect().height;
226
+ const tooltipWidth = tooltipEl.getBoundingClientRect().width;
227
+ // to get the center positions, calculate the difference between the button width and the tooltip width
228
+ const verticalDiff = (anchorEl.getBoundingClientRect().height - tooltipHeight) / 2;
229
+ const horizontalDiff = (anchorEl.getBoundingClientRect().width - tooltipWidth) / 2;
230
+ // the naming convention defaults to center in the absence of a value
231
+ // "top" and "bottom" imply centering horizontally; "right" and "left" imply centering vertically
232
+ // therefore we first set to center and adjust accordingly
233
+ let verticalPos = anchorEl.getBoundingClientRect().top + verticalDiff;
234
+ let horizontalPos = anchorEl.getBoundingClientRect().left + horizontalDiff;
235
+ if (tPos.includes("top")) {
236
+ verticalPos = anchorEl.getBoundingClientRect().top - tooltipHeight - 8;
237
+ }
238
+ if (tPos.includes("bottom")) {
239
+ verticalPos = anchorEl.getBoundingClientRect().bottom + 8;
240
+ }
241
+ if (tPos.includes("left")) {
242
+ horizontalPos = anchorEl.getBoundingClientRect().left - tooltipWidth - 8;
243
+ }
244
+ if (tPos.includes("right")) {
245
+ horizontalPos = anchorEl.getBoundingClientRect().right + 8;
246
+ }
247
+ // after all positioning has been calculated, if tooltip is off-screen or closer than 24px it is readjusted
248
+ // this only occurs when the tooltip is overflowing to the left and is positioned top or bottom
249
+ // (button placed too far left, or screen size under 268px)
250
+ horizontalPos = Math.max(horizontalPos, 24);
251
+ tooltipEl.style.setProperty("--wmTooltipTop", verticalPos + "px");
252
+ tooltipEl.style.setProperty("--wmTooltipLeft", horizontalPos + "px");
253
+ }
254
+ export function hasRoomRight(x, spaceNeeded) {
255
+ let horizOffset = 0;
256
+ // if (getTextDir() === "ltr") {
257
+ if (x.type === "click") {
258
+ // if it's a mouse event, deal with mouse coords
259
+ horizOffset = x.clientX;
260
+ // if it's a focus event, the offset is 0
261
+ }
262
+ else if (x.type === "focus") {
263
+ horizOffset = 0;
264
+ }
265
+ else {
266
+ // otherwise an element was passed, calculate how far it is from the edge of the window
267
+ let el = x; // re-assignment is for clarity
268
+ while (el) {
269
+ if (el.tagName == "BODY") {
270
+ // deal with browser quirks with body/window/document and page scroll
271
+ var xScroll = el.scrollLeft || document.documentElement.scrollLeft;
272
+ horizOffset += el.offsetLeft - xScroll + el.clientLeft;
273
+ }
274
+ else {
275
+ // for all other non-BODY elements
276
+ horizOffset += el.offsetLeft - el.scrollLeft + el.clientLeft;
277
+ }
278
+ el = el.offsetParent;
279
+ }
280
+ // }
281
+ }
282
+ return window.innerWidth - horizOffset >= spaceNeeded;
283
+ }
284
+ export function checkForActiveElInShadow(element) {
285
+ while (element && element.shadowRoot) {
286
+ element = element.shadowRoot.activeElement;
287
+ }
288
+ return element;
289
+ }
290
+ export function checkForFocusableElInShadow(element) {
291
+ const selectors = [
292
+ "button",
293
+ "a",
294
+ "input",
295
+ "select",
296
+ "textarea",
297
+ "wm-button",
298
+ "wm-search",
299
+ "wm-select",
300
+ "wm-action-menu",
301
+ "wm-tab-item",
302
+ "wm-datepicker",
303
+ ];
304
+ let focusableEl = element;
305
+ selectors.forEach((selector) => {
306
+ if (focusableEl && focusableEl.shadowRoot) {
307
+ let elInShadow = focusableEl.shadowRoot.querySelector(selector);
308
+ if (elInShadow) {
309
+ if (selector.startsWith("wm-")) {
310
+ focusableEl = checkForFocusableElInShadow(elInShadow);
311
+ }
312
+ else {
313
+ focusableEl = elInShadow;
314
+ }
315
+ }
316
+ }
317
+ });
318
+ return focusableEl;
319
+ }
320
+ export function isFocusable(element) {
321
+ if (element.tabIndex > 0 || (element.tabIndex === 0 && element.getAttribute("tabIndex") !== null)) {
322
+ return true;
323
+ }
324
+ if (element.disabled) {
325
+ return false;
326
+ }
327
+ switch (element.nodeName) {
328
+ case "A":
329
+ return !!element.href && element.rel != "ignore";
330
+ case "INPUT":
331
+ return element.type != "hidden" && element.type != "file";
332
+ case "BUTTON":
333
+ case "SELECT":
334
+ case "TEXTAREA":
335
+ case "WM-BUTTON":
336
+ case "WM-SELECT":
337
+ case "WM-ACTION-MENU":
338
+ case "WM-DATEPICKER":
339
+ case "WM-TIMEPICKER":
340
+ case "WM-INPUT":
341
+ case "WM-TAG-INPUT":
342
+ case "WM-TAB-ITEM":
343
+ case "WM-SEARCH":
344
+ return true;
345
+ default:
346
+ return false;
347
+ }
348
+ }
349
+ export function getFirstFocusableDescendant(element) {
350
+ if (isFocusable(element)) {
351
+ return checkForFocusableElInShadow(element);
352
+ }
353
+ else if (element.childNodes.length > 0) {
354
+ element.childNodes.forEach((i) => {
355
+ const childEl = getFirstFocusableDescendant(i);
356
+ return childEl && checkForFocusableElInShadow(childEl);
357
+ });
358
+ }
359
+ }
360
+ export function hasValidType(file, types) {
361
+ const acceptedExtensions = types.split(" ");
362
+ const parts = file.name && file.name.split(".");
363
+ const ext = parts && parts.length > 1 && parts[parts.length - 1];
364
+ return ext
365
+ ? acceptedExtensions.includes(ext.toLowerCase())
366
+ : // fallback: if we couldn't obtain an extension,
367
+ // validate based on MIME type...
368
+ !!file.type
369
+ ? getAcceptedMimeTypesList(acceptedExtensions).includes(file.type)
370
+ : // ...and if that failed too, accept the file
371
+ // as it's preferable to accept an invalid file
372
+ // than refusing a valid one (back-end will take care of what slips through)
373
+ true;
374
+ }
375
+ // takes a string (space separated list of extensions), returns an array of strings (corresponding MIME types)
376
+ export function getAcceptedMimeTypesList(acceptedExtensions) {
377
+ // this is just a list of common file types (regardless of whether they are/can be valid or not)
378
+ // front end checks are just a convenience to users, independent of security.
379
+ // it allows users to be notified of an invalid type as soon as they select the file, rather than when it gets uploaded
380
+ const lookupTable = {
381
+ aac: ["audio/aac"],
382
+ abw: ["application/x-abiword"],
383
+ arc: ["application/x-freearc"],
384
+ avi: ["video/x-msvideo"],
385
+ azw: ["application/vnd.amazon.ebook"],
386
+ bin: ["application/octet-stream"],
387
+ bmp: ["image/bmp"],
388
+ bz: ["application/x-bzip"],
389
+ bz2: ["application/x-bzip2"],
390
+ csh: ["application/x-csh"],
391
+ css: ["text/css"],
392
+ csv: ["text/csv"],
393
+ doc: ["application/msword"],
394
+ docx: ["application/vnd.openxmlformats-officedocument.wordprocessingml.document"],
395
+ eot: ["application/vnd.ms-fontobject"],
396
+ epub: ["application/epub+zip"],
397
+ gz: ["application/gzip"],
398
+ gif: ["image/gif"],
399
+ htm: ["text/html"],
400
+ html: ["text/html"],
401
+ ico: ["image/vnd.microsoft.icon"],
402
+ ics: ["text/calendar"],
403
+ jar: ["application/java-archive"],
404
+ jpeg: ["image/jpeg"],
405
+ jpg: ["image/jpeg"],
406
+ js: ["text/javascript"],
407
+ json: ["application/json"],
408
+ jsonld: ["application/ld+json"],
409
+ log: ["text/plain"],
410
+ mid: ["audio/x-midi"],
411
+ midi: ["audio/x-midi"],
412
+ mjs: ["text/javascript"],
413
+ mp3: ["audio/mpeg"],
414
+ mpeg: ["video/mpeg"],
415
+ mpkg: ["application/vnd.apple.installer+xml"],
416
+ odp: ["application/vnd.oasis.opendocument.presentation"],
417
+ ods: ["application/vnd.oasis.opendocument.spreadsheet"],
418
+ odt: ["application/vnd.oasis.opendocument.text"],
419
+ oga: ["audio/ogg"],
420
+ ogv: ["video/ogg"],
421
+ ogx: ["application/ogg"],
422
+ opus: ["audio/opus"],
423
+ otf: ["font/otf"],
424
+ png: ["image/png"],
425
+ pdf: ["application/pdf"],
426
+ php: ["application/php"],
427
+ ppt: ["application/vnd.ms-powerpoint"],
428
+ pptx: ["application/vnd.openxmlformats-officedocument.presentationml.presentation"],
429
+ rar: ["application/vnd.rar", "application/x-rar", "application/x-rar-compressed"],
430
+ rtf: ["application/rtf"],
431
+ sh: ["application/x-sh"],
432
+ svg: ["image/svg+xml"],
433
+ swf: ["application/x-shockwave-flash"],
434
+ tar: ["application/x-tar"],
435
+ tif: ["image/tiff"],
436
+ tiff: ["image/tiff"],
437
+ ts: ["video/mp2t"],
438
+ ttf: ["font/ttf"],
439
+ txt: ["text/plain"],
440
+ vsd: ["application/vnd.visio"],
441
+ wav: ["audio/wav"],
442
+ weba: ["audio/webm"],
443
+ webm: ["video/webm"],
444
+ webp: ["image/webp"],
445
+ woff: ["font/woff"],
446
+ woff2: ["font/woff2"],
447
+ xhtml: ["application/xhtml+xml"],
448
+ xls: ["application/vnd.ms-excel"],
449
+ xlsx: ["application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"],
450
+ xml: ["application/xml", "text/xml"],
451
+ xul: ["application/vnd.mozilla.xul+xml"],
452
+ zip: ["application/zip", "application/x-zip-compressed", "multipart/x-zip"],
453
+ "3gp": ["video/3gpp", "audio/3gpp"],
454
+ "3g2": ["video/3gpp2", "audio/3gpp2"],
455
+ "7z": ["application/x-7z-compressed"],
456
+ };
457
+ return acceptedExtensions.reduce((acc, ext) => acc.concat(lookupTable[ext]), []);
458
+ }
459
+ export function snakeCaseToCamelCase(str) {
460
+ const snakeCaseRegexp = /^([a-z0-9]*)(_[a-z0-9]*)*$/g;
461
+ if (snakeCaseRegexp.test(str)) {
462
+ let camelCase = "";
463
+ let arr = str.split("_");
464
+ arr.forEach((word, idx) => {
465
+ camelCase += idx === 0 ? word.toLowerCase() : word.charAt(0).toUpperCase() + word.slice(1);
466
+ });
467
+ return camelCase;
468
+ }
469
+ else {
470
+ return str;
471
+ }
472
+ }
473
+ export function csvToArray(csv) {
474
+ return csv ? csv.split(/, ?/) : [];
475
+ }
476
+ export function getNewIndexToFocus(currentIndex, direction, listLength) {
477
+ let newIndex = currentIndex;
478
+ if (direction === "ArrowDown") {
479
+ newIndex = (currentIndex + 1) % listLength;
480
+ }
481
+ if (direction === "ArrowUp") {
482
+ newIndex = currentIndex === 0 ? listLength - 1 : currentIndex - 1;
483
+ }
484
+ return newIndex;
485
+ }
486
+ export function isRelatedTarget(ev, id) {
487
+ // used for onBlur events to check the element that has been clicked
488
+ const ids = id.split(" ");
489
+ return ev.relatedTarget && ids.includes(ev.relatedTarget.id);
490
+ }
491
+ export function toBool(val) {
492
+ // string "false" needs to be treated as bool False because react wrappers convert bool to string.
493
+ return val == "false" ? false : !!val;
494
+ }
495
+ export function measureText(originEl, placeholderText) {
496
+ const measurementEl = document.createElement("div");
497
+ const originStyles = getComputedStyle(originEl);
498
+ measurementEl.style.position = "absolute";
499
+ measurementEl.style.top = "-100vh";
500
+ measurementEl.style.fontFamily = originStyles.fontFamily;
501
+ measurementEl.style.fontWeight = originStyles.fontWeight;
502
+ measurementEl.style.fontSize = originStyles.fontSize;
503
+ measurementEl.textContent = placeholderText;
504
+ document.body.appendChild(measurementEl);
505
+ const boundingClientRect = measurementEl.getBoundingClientRect();
506
+ document.body.removeChild(measurementEl);
507
+ return boundingClientRect;
508
+ }
509
+ export function safeParseJSON(toParse) {
510
+ // JSON.parse will throw an exception if the string provided is not in the proper format
511
+ // instead of the exception, just return null and let other logic check
512
+ try {
513
+ return JSON.parse(toParse);
514
+ }
515
+ catch (e) {
516
+ return null;
517
+ }
518
+ }
519
+ export function truncateText(textEl, text, availableSpace, endAmt) {
520
+ const cloneEl = document.createElement("div");
521
+ cloneEl.style.visibility = "hidden";
522
+ cloneEl.style.position = "absolute";
523
+ cloneEl.style.top = "-200vh";
524
+ cloneEl.style.left = "-200vh";
525
+ cloneEl.textContent = text;
526
+ textEl.appendChild(cloneEl);
527
+ const ellipses = "...";
528
+ const minimumLength = 2 + ellipses.length + endAmt;
529
+ let canFitText = availableSpace > cloneEl.clientWidth;
530
+ if (!canFitText && text.length > minimumLength) {
531
+ let frontChars = text.slice(0, text.length - endAmt - ellipses.length).trim();
532
+ let endChars = text.slice(-endAmt).trim();
533
+ let truncatedText = frontChars + ellipses + endChars;
534
+ cloneEl.textContent = truncatedText;
535
+ canFitText = availableSpace > cloneEl.clientWidth;
536
+ while (!canFitText && truncatedText.length > minimumLength) {
537
+ frontChars = frontChars.slice(0, -1).trim();
538
+ truncatedText = frontChars + ellipses + endChars;
539
+ cloneEl.textContent = truncatedText;
540
+ canFitText = availableSpace > cloneEl.clientWidth;
541
+ }
542
+ }
543
+ const truncatedText = cloneEl.textContent;
544
+ cloneEl.remove();
545
+ return truncatedText;
546
+ }