@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
@@ -3,948 +3,948 @@
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
5
  const index = require('./index-9f0e6656.js');
6
- const functions = require('./functions-68f637b4.js');
7
- const intl = require('./intl-d9ffc76c.js');
6
+ const functions = require('./functions-a047a8ea.js');
7
+ const intl = require('./intl-47d63c8f.js');
8
8
 
9
9
  const wmTagInputCss = ":host,wm-tag-input{font-family:inherit;width:100%;display:block;max-height:80vh}:host *,wm-tag-input *{-webkit-box-sizing:border-box;box-sizing:border-box;font-size:14px}:host .wrapper,wm-tag-input .wrapper{display:-webkit-box;display:-webkit-flex;display:-ms-flexbox;display:flex;-ms-flex-direction:column;flex-direction:column;font-size:0.875rem}:host .wrapper .label,wm-tag-input .wrapper .label{display:block;line-height:normal;font-weight:600;white-space:nowrap;margin-bottom:0.25rem}:host .wrapper .label .required,wm-tag-input .wrapper .label .required{color:#c0392b}:host .wrapper.label-left,wm-tag-input .wrapper.label-left{-ms-flex-direction:row;flex-direction:row}:host .wrapper.label-left .label-wrapper,wm-tag-input .wrapper.label-left .label-wrapper{line-height:2.5rem}:host .wrapper.label-left .label-wrapper .label,wm-tag-input .wrapper.label-left .label-wrapper .label{display:-ms-flexbox;display:flex;-ms-flex-align:center;align-items:center;min-height:2.5rem;white-space:normal;margin-bottom:0;margin-right:0.75rem}:host .wrapper.label-none label,wm-tag-input .wrapper.label-none label{position:absolute !important;width:1px !important;height:1px !important;padding:0 !important;border:0 !important;overflow:hidden !important;clip:rect(0, 0, 0, 0) !important;-webkit-clip-path:inset(50%) !important;clip-path:inset(50%) !important;white-space:nowrap !important;margin:-1px !important}:host .wrapper.invalid .label,wm-tag-input .wrapper.invalid .label{color:#c0392b}:host .wrapper.invalid .label:after,wm-tag-input .wrapper.invalid .label:after{display:inline-block;font:normal normal normal 24px/1 \"Material Design Icons\";font-size:inherit;text-rendering:auto;line-height:inherit;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale;content:\"\\f026\";margin-left:0.3125rem}[dir=RTL] :host .wrapper.invalid .label:after,[dir=RTL] wm-tag-input .wrapper.invalid .label:after{margin-left:0;margin-right:0.3125rem}:host .wrapper.rtl.label-left .label,wm-tag-input .wrapper.rtl.label-left .label{margin-right:0;margin-left:0.75rem}:host .wrapper,wm-tag-input .wrapper{width:100%;height:100%;max-height:inherit;min-height:inherit;position:relative}:host .field-wrapper,wm-tag-input .field-wrapper{position:relative;width:100%;border:1px solid #4a4a4a;-webkit-border-radius:3px;-moz-border-radius:3px;-ms-border-radius:3px;border-radius:3px}:host .field-wrapper.focused,wm-tag-input .field-wrapper.focused{-webkit-box-shadow:0 0 0 1px #19a1a9;-moz-box-shadow:0 0 0 1px #19a1a9;box-shadow:0 0 0 1px #19a1a9;outline:none;border-color:#19a1a9}:host .field-wrapper.invalid,wm-tag-input .field-wrapper.invalid{-webkit-box-shadow:0 0 0 1px #c0392b;-moz-box-shadow:0 0 0 1px #c0392b;box-shadow:0 0 0 1px #c0392b;border-color:#c0392b}:host .character-count,wm-tag-input .character-count{display:-ms-flexbox;display:flex;-ms-flex-align:center;align-items:center;-ms-flex-pack:center;justify-content:center;min-width:5rem;background-color:rgba(74, 74, 74, 0.05);font-size:0.875rem;font-weight:500;-ms-flex-item-align:stretch;align-self:stretch}:host .tags-and-input-wrapper,wm-tag-input .tags-and-input-wrapper{position:relative;width:100%;padding:0.5rem 0.25rem 0.5rem 0;margin-bottom:-0.5rem;overflow:hidden}:host .upper-row,wm-tag-input .upper-row{width:100%;display:-ms-flexbox;display:flex;-ms-flex:1;flex:1;-ms-flex-pack:justify;justify-content:space-between}:host .upper-row:before,wm-tag-input .upper-row:before{-ms-flex-item-align:start;align-self:flex-start;display:inline-block;font:normal normal normal 24px/1 \"Material Design Icons\";font-size:inherit;text-rendering:auto;line-height:inherit;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale;content:\"\\f349\";color:#b5b5b5;padding:0.75rem 0.5rem 0.75rem 0.75rem}:host .lower-row,wm-tag-input .lower-row{width:100%;min-height:1.875rem}:host #max-tags,wm-tag-input #max-tags{display:-ms-flexbox;display:flex;-ms-flex-align:center;align-items:center;min-height:1.875rem;background-color:#e6e6e6;padding:0.5rem 1rem;color:#4a4a4a;font-size:0.875rem;border-top:1px solid rgba(35, 35, 35, 0.6);border-radius:0 0 3px 3px}:host .tag-area,wm-tag-input .tag-area{display:-ms-flexbox;display:flex;-ms-flex-wrap:wrap;flex-wrap:wrap;margin:0;padding:0}:host .tag-area:focus,wm-tag-input .tag-area:focus{outline:none}:host .tag-area [role=option],wm-tag-input .tag-area [role=option]{display:-ms-inline-flexbox;display:inline-flex;-ms-flex-align:center;align-items:center;height:1.75rem;list-style:none;color:#4a4a4a;background-color:rgba(3, 0, 0, 0.1);padding:0.5rem 0.625rem;margin-bottom:0.5rem;margin-right:0.25rem;margin-left:0.25rem;-webkit-transition:background-color 0.3s cubic-bezier(0.4, 0, 0.2, 1);transition:background-color 0.3s cubic-bezier(0.4, 0, 0.2, 1);white-space:pre}:host .tag-area [role=option].highlight,wm-tag-input .tag-area [role=option].highlight{-webkit-animation:fadeIn 1s;animation:fadeIn 1s}@-webkit-keyframes fadeIn{0%{background-color:rgba(3, 0, 0, 0.1)}50%{background-color:#c8dfcc}100%{background-color:rgba(3, 0, 0, 0.1)}}@keyframes fadeIn{0%{background-color:rgba(3, 0, 0, 0.1)}50%{background-color:#c8dfcc}100%{background-color:rgba(3, 0, 0, 0.1)}}:host .tag-area [role=option].focused,wm-tag-input .tag-area [role=option].focused{background-color:#d1d1d1}:host .tag-area [role=option].locked,wm-tag-input .tag-area [role=option].locked{background-color:#6b6b6b;color:white}:host .tag-area [role=option] .icon,wm-tag-input .tag-area [role=option] .icon{display:-ms-inline-flexbox;display:inline-flex;-ms-flex-pack:center;justify-content:center;-ms-flex-align:center;align-items:center;height:1.25rem;width:1.25rem;padding:0;margin-left:0.5rem}:host .tag-area [role=option] .icon.remove-btn,wm-tag-input .tag-area [role=option] .icon.remove-btn{border:1px solid #575195;color:#575195;border-radius:50%;cursor:pointer;-webkit-transition:background-color 500ms cubic-bezier(0.4, 0, 0.2, 1), color 500ms cubic-bezier(0.4, 0, 0.2, 1);transition:background-color 500ms cubic-bezier(0.4, 0, 0.2, 1), color 500ms cubic-bezier(0.4, 0, 0.2, 1)}:host .tag-area [role=option] .icon.remove-btn:hover,wm-tag-input .tag-area [role=option] .icon.remove-btn:hover{color:white;background-color:#575195}:host .tag-area [role=option] .icon.remove-btn:before,wm-tag-input .tag-area [role=option] .icon.remove-btn:before{display:inline-block;font:normal normal normal 24px/1 \"Material Design Icons\";font-size:inherit;text-rendering:auto;line-height:inherit;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale;content:\"\\f156\"}:host .tag-area [role=option] .icon.lock,wm-tag-input .tag-area [role=option] .icon.lock{color:white}:host .tag-area [role=option] .icon.lock:before,wm-tag-input .tag-area [role=option] .icon.lock:before{display:inline-block;font:normal normal normal 24px/1 \"Material Design Icons\";font-size:inherit;text-rendering:auto;line-height:inherit;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale;content:\"\\f341\"}:host input,wm-tag-input input{font-family:inherit;border:none;height:1.75rem;padding:0;margin-bottom:0.5rem;margin-right:0.25rem;padding-left:0.5rem;right:0px}:host input.hidden,wm-tag-input input.hidden{display:none}:host input:focus,wm-tag-input input:focus{outline:none}:host .dropdown-wrapper,wm-tag-input .dropdown-wrapper{margin:0;padding:0;-webkit-box-shadow:0 4px 15px 0 rgba(0, 0, 0, 0.2);-moz-box-shadow:0 4px 15px 0 rgba(0, 0, 0, 0.2);box-shadow:0 4px 15px 0 rgba(0, 0, 0, 0.2);-ms-transition:transform 0.25s ease;-webkit-transition:transform 0.25s ease;-moz-transition:transform 0.25s ease;-webkit-transition:-webkit-transform 0.25s ease;transition:-webkit-transform 0.25s ease;transition:transform 0.25s ease;transition:transform 0.25s ease, -webkit-transform 0.25s ease;-ms-transform:scale(1, 0);-webkit-transform:scale(1, 0);-moz-transform:scale(1, 0);transform:scale(1, 0);-ms-transform-origin:center top;-webkit-transform-origin:center top;-moz-transform-origin:center top;transform-origin:center top;-webkit-border-radius:3px;-moz-border-radius:3px;-ms-border-radius:3px;border-radius:3px;position:absolute;top:calc(100% + 2px);right:0;background:#fff;z-index:100;width:100%;font-size:0.875rem}:host .dropdown-wrapper .dropdown,wm-tag-input .dropdown-wrapper .dropdown{-webkit-overflow-scrolling:touch;overflow:auto;max-height:12.5rem;margin:0;padding:0}:host .dropdown-wrapper.open,wm-tag-input .dropdown-wrapper.open{-ms-transform:scale(1, 1);-webkit-transform:scale(1, 1);-moz-transform:scale(1, 1);transform:scale(1, 1)}:host .dropdown-wrapper.upwards,wm-tag-input .dropdown-wrapper.upwards{top:unset;bottom:calc(100% + 2px);-ms-transform-origin:center bottom;-webkit-transform-origin:center bottom;-moz-transform-origin:center bottom;transform-origin:center bottom}:host .dropdown-wrapper li,:host .dropdown-wrapper div,wm-tag-input .dropdown-wrapper li,wm-tag-input .dropdown-wrapper div{display:-ms-flexbox;display:flex;-ms-flex-align:center;align-items:center;padding:0 1rem;background:#fff;list-style:none;min-height:2.6875rem;white-space:pre-wrap;overflow-wrap:anywhere}:host .dropdown-wrapper li[role=option],:host .dropdown-wrapper li.add-new-btn,:host .dropdown-wrapper div[role=option],:host .dropdown-wrapper div.add-new-btn,wm-tag-input .dropdown-wrapper li[role=option],wm-tag-input .dropdown-wrapper li.add-new-btn,wm-tag-input .dropdown-wrapper div[role=option],wm-tag-input .dropdown-wrapper div.add-new-btn{cursor:pointer;color:#575195;font-weight:bold;width:100%;border:none}:host .dropdown-wrapper li[role=option][aria-selected=true],:host .dropdown-wrapper li.add-new-btn[aria-selected=true],:host .dropdown-wrapper div[role=option][aria-selected=true],:host .dropdown-wrapper div.add-new-btn[aria-selected=true],wm-tag-input .dropdown-wrapper li[role=option][aria-selected=true],wm-tag-input .dropdown-wrapper li.add-new-btn[aria-selected=true],wm-tag-input .dropdown-wrapper div[role=option][aria-selected=true],wm-tag-input .dropdown-wrapper div.add-new-btn[aria-selected=true]{color:#6b6b6b;font-style:italic;font-weight:normal;cursor:unset}:host .dropdown-wrapper li[role=option]:hover:not([aria-selected=true]),:host .dropdown-wrapper li[role=option].focused,:host .dropdown-wrapper li.add-new-btn:hover:not([aria-selected=true]),:host .dropdown-wrapper li.add-new-btn.focused,:host .dropdown-wrapper div[role=option]:hover:not([aria-selected=true]),:host .dropdown-wrapper div[role=option].focused,:host .dropdown-wrapper div.add-new-btn:hover:not([aria-selected=true]),:host .dropdown-wrapper div.add-new-btn.focused,wm-tag-input .dropdown-wrapper li[role=option]:hover:not([aria-selected=true]),wm-tag-input .dropdown-wrapper li[role=option].focused,wm-tag-input .dropdown-wrapper li.add-new-btn:hover:not([aria-selected=true]),wm-tag-input .dropdown-wrapper li.add-new-btn.focused,wm-tag-input .dropdown-wrapper div[role=option]:hover:not([aria-selected=true]),wm-tag-input .dropdown-wrapper div[role=option].focused,wm-tag-input .dropdown-wrapper div.add-new-btn:hover:not([aria-selected=true]),wm-tag-input .dropdown-wrapper div.add-new-btn.focused{outline:none;background:#f4f4f4}:host .dropdown-wrapper li.help-text,:host .dropdown-wrapper div.help-text,wm-tag-input .dropdown-wrapper li.help-text,wm-tag-input .dropdown-wrapper div.help-text{color:#4a4a4a;height:auto;min-height:2.6875rem;padding-top:0.25rem;padding-bottom:0.25rem;white-space:normal}:host .dropdown-wrapper li:not(:last-child),:host .dropdown-wrapper div:not(:last-child),wm-tag-input .dropdown-wrapper li:not(:last-child),wm-tag-input .dropdown-wrapper div:not(:last-child){border-bottom:2px solid rgba(46, 27, 70, 0.05)}:host .info-text,wm-tag-input .info-text{font-style:italic;margin-top:0.25rem}:host .table-wrapper,wm-tag-input .table-wrapper{overflow:auto;margin-top:1.5rem}:host .table-wrapper #table,wm-tag-input .table-wrapper #table{width:100%;border-spacing:0px}:host .table-wrapper #table.fixed-widths,wm-tag-input .table-wrapper #table.fixed-widths{table-layout:fixed}:host .table-wrapper #table .headers,wm-tag-input .table-wrapper #table .headers{height:2.5rem;background-color:#eeedf4}:host .table-wrapper #table .headers th,wm-tag-input .table-wrapper #table .headers th{text-align:left;font-size:0.75rem;font-weight:700;text-transform:uppercase;padding:0 1.5rem}:host .table-wrapper tr:nth-child(even),wm-tag-input .table-wrapper tr:nth-child(even){background-color:#fafafa}:host .table-wrapper tr.selected,wm-tag-input .table-wrapper tr.selected{background-color:rgba(25, 161, 169, 0.2);-webkit-box-shadow:inset 0 0 0 1px #19a1a9;box-shadow:inset 0 0 0 1px #19a1a9;font-weight:500}:host .table-wrapper tr.focused:not(.locked),:host .table-wrapper tr:hover:not(.locked),wm-tag-input .table-wrapper tr.focused:not(.locked),wm-tag-input .table-wrapper tr:hover:not(.locked){background-color:#e9e7ec;-webkit-box-shadow:none;box-shadow:none}:host .table-wrapper tr.locked td,wm-tag-input .table-wrapper tr.locked td{cursor:auto}:host .table-wrapper tr.locked td:first-child .cell-content-wrapper:before,wm-tag-input .table-wrapper tr.locked td:first-child .cell-content-wrapper:before{display:inline-block;font:normal normal normal 24px/1 \"Material Design Icons\";font-size:inherit;text-rendering:auto;line-height:inherit;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale;content:\"\\f33e\";margin-right:0.5rem;color:#4a4a4a}:host .table-wrapper td,wm-tag-input .table-wrapper td{height:3.75rem;vertical-align:middle;padding:0 1.5rem;cursor:pointer}:host .table-wrapper td.focused,wm-tag-input .table-wrapper td.focused{-webkit-box-shadow:inset 0 2px 2px 0 rgba(244, 243, 246, 0.2), inset 0 2px 2px 0 rgba(0, 0, 0, 0.1), inset 0 0 4px 3px #61279e;box-shadow:inset 0 2px 2px 0 rgba(244, 243, 246, 0.2), inset 0 2px 2px 0 rgba(0, 0, 0, 0.1), inset 0 0 4px 3px #61279e}:host .table-wrapper td .cell-content-wrapper.trunc,wm-tag-input .table-wrapper td .cell-content-wrapper.trunc{white-space:nowrap;overflow:hidden;text-overflow:ellipsis}:host .table-wrapper td .description,wm-tag-input .table-wrapper td .description{display:none}:host .no-results,wm-tag-input .no-results{padding:1.25rem 1.5rem}:host .sr-only,wm-tag-input .sr-only{position:absolute !important;width:1px !important;height:1px !important;padding:0 !important;border:0 !important;overflow:hidden !important;clip:rect(0, 0, 0, 0) !important;-webkit-clip-path:inset(50%) !important;clip-path:inset(50%) !important;white-space:nowrap !important;margin:-1px !important}:host #error,wm-tag-input #error{display:block;font-style:italic;color:#c0392b;font-size:0.875rem;margin-top:0.25rem}";
10
10
 
11
- const TagInput = class {
12
- constructor(hostRef) {
13
- index.registerInstance(this, hostRef);
14
- this.wmTagInputChanged = index.createEvent(this, "wmTagInputChanged", 7);
15
- this.uid = this.el.id ? this.el.id : functions.generateId();
16
- this.openUp = false;
17
- this.debouncedUpdate = functions.debounce(() => index.forceUpdate(this.el), 30);
18
- this.label = undefined;
19
- this.labelPosition = "top";
20
- this.options = "";
21
- this.selectedTags = "";
22
- this.info = undefined;
23
- this.errorMessage = undefined;
24
- this.addNew = true;
25
- this.placeholder = undefined;
26
- this.requiredField = false;
27
- this.characterLimit = 50;
28
- this.maxTags = undefined;
29
- this.tagInputType = "dropdown";
30
- this.colHeaders = undefined;
31
- this.colWidths = undefined;
32
- this.colWrap = undefined;
33
- this.messageConfig = "";
34
- this.focusedListItem = undefined;
35
- this.focusedTag = null;
36
- this.tablePosition = { row: 0, column: 1 };
37
- this.isExpanded = false;
38
- this.tagsList = functions.csvToArray(this.selectedTags);
39
- this.optionsList = functions.csvToArray(this.options);
40
- this.charCount = 0;
41
- this.liveRegionMessage = "";
42
- }
43
- get tooltipVisible() {
44
- return document.getElementById("wm-tooltip").classList.contains("open");
45
- }
46
- get focusedElement() {
47
- return this.el.shadowRoot.activeElement;
48
- }
49
- get listItemEls() {
50
- return Array.from(this.dropdownEl.querySelectorAll("li"));
51
- }
52
- get tagEls() {
53
- return this.tagAreaEl ? Array.from(this.tagAreaEl.querySelectorAll(".tag")) : [];
54
- }
55
- get nonLockedTagEls() {
56
- return this.tagEls.filter((tag) => !tag.classList.contains("locked"));
57
- }
58
- get optionEls() {
59
- return Array.from(this.dropdownEl.querySelectorAll(".option"));
60
- }
61
- get wmRowEls() {
62
- return Array.from(this.el.querySelectorAll("wm-tag-input-row"));
63
- }
64
- get localRowEls() {
65
- return Array.from(this.el.shadowRoot.querySelectorAll("tr"));
66
- }
67
- get filteredRows() {
68
- return this.wmRowEls.filter((row) => {
69
- const colValues = [row.col1, row.col2, row.col3, row.col4].join("").toLowerCase();
70
- return this.inputEl && this.inputEl.value ? colValues.includes(this.inputEl.value.toLowerCase()) : true;
71
- });
72
- }
73
- get nonLockedTagsList() {
74
- let list = [];
75
- if (this.tagInputType === "table") {
76
- this.tagsList.forEach((id) => {
77
- const correspondingRowEl = this.wmRowEls.filter((row) => id === row.id)[0];
78
- if (!correspondingRowEl.locked) {
79
- list.push(id);
80
- }
81
- });
82
- }
83
- else if (this.tagInputType === "dropdown") {
84
- list = this.tagsList;
85
- }
86
- return list;
87
- }
88
- get tagLimitReached() {
89
- return !!(this.maxTags && this.tagsList.length >= this.maxTags);
90
- }
91
- get noResultsMessage() {
92
- return functions.intl.formatMessage({
93
- id: "tagInput.noResults",
94
- defaultMessage: "No results match your search.",
95
- description: "Message displayed when a user's search returns empty.",
96
- });
97
- }
98
- get componentMessages() {
99
- const addNewHelpText = functions.intl.formatMessage({
100
- id: "tagInput.addNewHelpText",
101
- defaultMessage: "Press the Enter or Comma key to add a new tag.",
102
- description: "Help text appearing in a dropdown. Use imperative",
103
- });
104
- const selectionHelpText = functions.intl.formatMessage({
105
- id: "tagInput.selectionHelpText",
106
- defaultMessage: "Search and select a tag.",
107
- description: "Help text appearing in a dropdown. Use imperative",
108
- });
109
- const maxTagsReachedMessage = functions.intl.formatMessage({
110
- id: "tagInput.maxTagsReached",
111
- defaultMessage: "No more tags can be added because the limit has been reached.",
112
- });
113
- const tagAreaInstructions = functions.intl.formatMessage({
114
- id: "tagInput.tagAreaInstructions",
115
- defaultMessage: "tag selection. Press Backspace or Delete to remove a tag.",
116
- });
117
- const tagsAddedMessage = functions.intl.formatMessage({
118
- id: "tagInput.tagsAdded",
119
- defaultMessage: "Tags added",
120
- description: "For the user to understand how close they are to the tag limit, followed by x/y count",
121
- });
122
- const defaultConfig = {
123
- addNewHelpText: addNewHelpText,
124
- selectionHelpText: selectionHelpText,
125
- maxTagsReached: maxTagsReachedMessage,
126
- tagAreaInstructions: tagAreaInstructions,
127
- tagsAdded: tagsAddedMessage,
128
- };
129
- const userProvidedConfig = functions.safeParseJSON(this.messageConfig);
130
- return userProvidedConfig ? Object.assign(Object.assign({}, defaultConfig), userProvidedConfig) : defaultConfig;
131
- }
132
- get inputMinimumWidth() {
133
- // 150px is the minimum width of the input field, or the length of the placeholder text
134
- const inputElStyles = getComputedStyle(this.inputEl);
135
- const tagElStyles = getComputedStyle(this.tagEls[this.tagEls.length - 1]);
136
- const inputElBuffer = [
137
- inputElStyles.paddingLeft,
138
- inputElStyles.paddingRight,
139
- inputElStyles.marginLeft,
140
- inputElStyles.marginRight,
141
- tagElStyles.marginRight,
142
- ].reduce((prev, curr) => prev + parseInt(curr.replace("px", "")), 0);
143
- const minimumWidth = Math.max(150, functions.measureText(this.inputEl, this.placeholder).width + inputElBuffer);
144
- return minimumWidth;
145
- }
146
- generateTagAddedMessage(tag) {
147
- return functions.intl.formatMessage({
148
- id: "tagInput.tagAdded",
149
- defaultMessage: "{tagName} added.",
150
- description: "A confirmation for adding a tag.",
151
- }, { tagName: tag });
152
- }
153
- generateTagAlreadyAddedMessage(tag) {
154
- return functions.intl.formatMessage({
155
- id: "tagInput.tagAlreadyAdded",
156
- defaultMessage: "{tagName} has already been added.",
157
- description: "An alert for adding a tag that is already present.",
158
- }, { tagName: tag });
159
- }
160
- componentWillLoad() {
161
- if (!this.placeholder) {
162
- this.placeholder = this.createPlaceholderDefault(this.addNew, !!this.options);
163
- }
164
- if (!this.label) {
165
- console.error("wm-tag-input must have a label property");
166
- }
167
- this.consolidateSelectedTags();
168
- this.el.focus = () => {
169
- const firstFocusableTag = this.nonLockedTagEls[0];
170
- if (firstFocusableTag) {
171
- this.tagAreaEl.focus();
172
- this.focusTag(firstFocusableTag);
173
- }
174
- else {
175
- this.inputEl.focus();
176
- }
177
- };
178
- // on resize of component, trigger componentDidRender -> positionInput
179
- const resizeObserver = new ResizeObserver(() => this.debouncedUpdate());
180
- resizeObserver.observe(this.el);
181
- }
182
- componentDidLoad() {
183
- // prevent highlighting of pre-selected tags
184
- this.tagEls.forEach((el) => el.classList.remove("highlight"));
185
- }
186
- componentDidRender() {
187
- this.positionInput();
188
- // check each tag if truncation is needed
189
- this.tagEls.forEach((tag) => {
190
- const textEl = tag.querySelector(".tag-text");
191
- const wrapper = this.el.shadowRoot.querySelector(".tags-and-input-wrapper");
192
- const leftBound = textEl.getBoundingClientRect().left;
193
- // the numbers represent spacing values for padding, margin, and delete icon
194
- const rightBound = wrapper.getBoundingClientRect().right - 10 - 8 - 28;
195
- let displayText = tag.dataset.tag;
196
- if (this.tagInputType === "table") {
197
- // table variant doesn't display the tag id, but the contents of the first column
198
- const referencedRow = this.el.querySelector(`#${displayText}`);
199
- displayText = referencedRow ? referencedRow.col1 : "";
200
- }
201
- textEl.textContent = functions.truncateText(textEl, displayText, rightBound - leftBound, 5);
202
- });
203
- }
204
- consolidateSelectedTags() {
205
- this.tagsList.forEach((tag) => {
206
- if (!this.includesCaseInsensitive(this.optionsList, tag)) {
207
- this.options += `${this.options.length > 0 ? "," : ""}${tag}`;
208
- }
209
- });
210
- this.optionsList = functions.csvToArray(this.options);
211
- }
212
- createPlaceholderDefault(addNew, hasOptions) {
213
- const addAndSearchPlaceholder = functions.intl.formatMessage({
214
- id: "tagInput.placeholderAddAndSearch",
215
- defaultMessage: "Add or search for a tag",
216
- description: "Placeholder text. Use imperative",
217
- });
218
- const searchPlaceholder = functions.intl.formatMessage({
219
- id: "tagInput.placeholderSearch",
220
- defaultMessage: "Search and select a tag",
221
- description: "Placeholder text. Use imperative",
222
- });
223
- const addPlaceholder = functions.intl.formatMessage({
224
- id: "tagInput.placeholderAdd",
225
- defaultMessage: "Add a new tag",
226
- description: "Placeholder text. Use imperative",
227
- });
228
- let placeholder = "";
229
- if (addNew && hasOptions) {
230
- placeholder = addAndSearchPlaceholder;
231
- }
232
- else if (!addNew && hasOptions) {
233
- placeholder = searchPlaceholder;
234
- }
235
- else if (addNew) {
236
- placeholder = addPlaceholder;
237
- }
238
- return placeholder;
239
- }
240
- reflectSelectedTags(newValue, oldValue) {
241
- const isAddition = newValue.length > oldValue.length;
242
- let changedTag = "";
243
- let selectedTags = this.tagsList;
244
- if (isAddition) {
245
- changedTag = newValue.filter((val) => !oldValue.includes(val))[0];
246
- }
247
- else {
248
- changedTag = oldValue.filter((val) => !newValue.includes(val))[0];
249
- }
250
- // event emitted by type table uses element references instead of strings
251
- if (this.tagInputType === "table") {
252
- changedTag = this.wmRowEls.filter((row) => row.id === changedTag)[0];
253
- selectedTags = this.tagsList.map((id) => this.el.querySelector(`#${id}`));
254
- }
255
- this.selectedTags = this.listToCSV(this.tagsList);
256
- let detail = { value: selectedTags, tagChanged: changedTag };
257
- this.wmTagInputChanged.emit(detail);
258
- }
259
- handleErrorMessageChange() {
260
- if (this.errorMessage) {
261
- this.announce(this.errorMessage);
262
- }
263
- }
264
- handleRowUpdate() {
265
- index.forceUpdate(this.el);
266
- }
267
- closeIfNotElOrChild(ev) {
268
- const isntElOrChild = ev.target !== this.el && !this.el.shadowRoot.contains(ev.target);
269
- if (this.tagInputType === "dropdown" && isntElOrChild && this.isExpanded) {
270
- this.closeDropdown();
271
- }
272
- }
273
- // From wm-button
274
- // we need to listen for scroll events during the capture phase because they do not bubble up
275
- // there can be layouts where the main content has 100vh and overflows
276
- // in these cases window will register no scroll events unless we catch on they way down
277
- dismissTooltip() {
278
- if (this.tooltipVisible) {
279
- functions.hideTooltip();
280
- }
281
- }
282
- handleInputKeyDown(ev) {
283
- if (/^.$/.test(ev.key) && this.inputEl.value.length >= this.characterLimit) {
284
- this.announce(this.generateCharacterLimitWarning(this.inputEl.value.length, this.characterLimit));
285
- }
286
- // prevent keydown triggering on tag area
287
- ev.stopPropagation();
288
- switch (ev.key) {
289
- case "Enter":
290
- case ",":
291
- ev.preventDefault();
292
- this.handleInputEnter();
293
- break;
294
- case "ArrowDown":
295
- ev.preventDefault();
296
- this.handleInputArrowDown();
297
- break;
298
- case "ArrowUp":
299
- ev.preventDefault();
300
- this.handleInputArrowUp();
301
- break;
302
- case "ArrowLeft":
303
- if (this.tagInputType === "table" && this.tablePosition.row) {
304
- ev.preventDefault();
305
- this.moveLeftCell();
306
- }
307
- break;
308
- case "ArrowRight":
309
- if (this.tagInputType === "table" && this.tablePosition.row) {
310
- ev.preventDefault();
311
- this.moveRightCell();
312
- }
313
- break;
314
- case "Escape":
315
- if (this.tagInputType === "dropdown" && this.isExpanded) {
316
- this.closeDropdown();
317
- }
318
- break;
319
- case "ArrowLeft":
320
- case "Backspace":
321
- this.handleInputBackspace();
322
- break;
323
- }
324
- }
325
- handleInputFocus() {
326
- if (this.tagInputType === "dropdown") {
327
- this.openDropdown();
328
- this.clearListItemFocus();
329
- }
330
- // force update needed to apply styled state of field-wrapper el
331
- index.forceUpdate(this.el);
332
- }
333
- handleInputChanged(value) {
334
- this.charCount = value.length;
335
- if (this.tagInputType === "dropdown") {
336
- this.clearListItemFocus();
337
- if (this.charCount >= this.characterLimit - 5) {
338
- this.announce(this.generateCharacterLimitWarning(this.charCount, this.characterLimit));
339
- }
340
- if (!this.isExpanded) {
341
- this.openDropdown();
342
- }
343
- }
344
- else if (this.tagInputType === "table") {
345
- this.clearCellFocus();
346
- }
347
- this.announceExistingOptions();
348
- }
349
- handleInputEnter() {
350
- if (this.tagInputType === "dropdown") {
351
- if (this.focusedListItem) {
352
- this.handleListItemClick(this.focusedListItem);
353
- }
354
- else {
355
- this.submitInput(this.addNew, this.inputEl.value.trim());
356
- }
357
- }
358
- else if (this.tagInputType === "table" && this.tablePosition.row > 0) {
359
- this.handleTableRowClick(this.localRowEls[this.tablePosition.row].id);
360
- }
361
- }
362
- submitInput(canAddNew, value) {
363
- const hasNonWhiteSpaceCharacters = value.match(/\S/);
364
- if (canAddNew && hasNonWhiteSpaceCharacters) {
365
- this.addTag(value);
366
- this.optionsList = this.addOption(value);
367
- this.resetInput();
368
- }
369
- }
370
- handleInputArrowDown() {
371
- if (this.tagInputType === "table") {
372
- this.moveDownRow();
373
- }
374
- else if (this.tagInputType === "dropdown" && this.isExpanded) {
375
- this.moveDownListItem();
376
- }
377
- else if (this.tagInputType === "dropdown") {
378
- this.openDropdown();
379
- }
380
- }
381
- handleInputArrowUp() {
382
- if (this.tagInputType === "table") {
383
- this.moveUpRow();
384
- }
385
- else if (this.tagInputType === "dropdown" && this.isExpanded) {
386
- this.moveUpListItem();
387
- }
388
- else if (this.tagInputType === "dropdown") {
389
- this.openDropdown();
390
- }
391
- }
392
- handleInputBackspace() {
393
- if (this.inputEl.value === "" && this.tagsList.length > 0) {
394
- // wait for events to finish firing before redirecting focus
395
- // prevents double input in input area and tag area
396
- window.requestAnimationFrame(() => {
397
- if (this.nonLockedTagsList.length > 0) {
398
- this.tagAreaEl.focus();
399
- this.focusTag(this.tagEls[this.tagEls.length - 1]);
400
- }
401
- });
402
- }
403
- }
404
- handleListItemKeyDown(ev) {
405
- const typedEvTarget = ev.target;
406
- switch (ev.key) {
407
- case "Enter":
408
- case " ":
409
- ev.preventDefault();
410
- typedEvTarget.click();
411
- break;
412
- case "ArrowDown":
413
- ev.preventDefault();
414
- this.moveDownListItem();
415
- break;
416
- case "ArrowUp":
417
- ev.preventDefault();
418
- this.moveUpListItem();
419
- break;
420
- case "Escape":
421
- if (this.focusedElement !== this.inputEl) {
422
- this.inputEl.focus();
423
- }
424
- else if (this.tagInputType === "dropdown") {
425
- this.closeDropdown();
426
- }
427
- break;
428
- }
429
- }
430
- handleListItemClick(item) {
431
- const tag = item.dataset.option.trim() || "";
432
- if (this.includesCaseInsensitive(this.tagsList, tag)) {
433
- this.announce(this.generateTagAlreadyAddedMessage(tag));
434
- }
435
- else {
436
- this.resetInput();
437
- this.addTag(tag);
438
- this.optionsList = this.addOption(tag);
439
- this.focusedListItem = null;
440
- }
441
- }
442
- handleTableRowClick(rowId) {
443
- const referencedRow = this.el.querySelector(`#${rowId}`);
444
- const isLocked = referencedRow.locked;
445
- if (!isLocked) {
446
- if (this.includesCaseInsensitive(this.tagsList, rowId)) {
447
- this.removeTag(rowId);
448
- }
449
- else if (!this.tagLimitReached) {
450
- this.addTag(rowId);
451
- this.resetInput();
452
- }
453
- }
454
- }
455
- handleTagAreaKeyDown(ev) {
456
- switch (ev.key) {
457
- case "ArrowLeft":
458
- case "ArrowUp":
459
- ev.preventDefault();
460
- this.moveLeftTag();
461
- break;
462
- case "ArrowRight":
463
- case "ArrowDown":
464
- ev.preventDefault();
465
- this.moveRightTag();
466
- break;
467
- case "Backspace":
468
- case "Delete":
469
- this.handleTagAreaDelete();
470
- break;
471
- }
472
- }
473
- handleTagAreaDelete() {
474
- const isLocked = this.focusedTag && this.focusedTag.classList.contains("locked");
475
- if (this.focusedTag && !isLocked) {
476
- this.removeTag(this.focusedTag.dataset.tag);
477
- if (this.nonLockedTagsList.length === 0) {
478
- // focus input if no tags are left
479
- this.inputEl.focus();
480
- }
481
- else {
482
- const removingLastTag = this.focusedTag === this.tagEls[this.tagEls.length - 1];
483
- // if removing the last tag, reassign focused tag to previous task
484
- this.focusedTag = removingLastTag ? this.tagEls[this.tagEls.length - 2] : this.focusedTag;
485
- this.focusTag(this.focusedTag);
486
- }
487
- }
488
- }
489
- handleBlur(ev, component) {
490
- const isntElOrChild = ev.relatedTarget !== component && !this.el.shadowRoot.contains(ev.relatedTarget);
491
- this.dismissTooltip();
492
- this.clearCellFocus();
493
- if (isntElOrChild) {
494
- this.fieldWrapperEl.classList.remove("focused");
495
- if (this.tagInputType === "dropdown") {
496
- this.closeDropdown();
497
- }
498
- }
499
- }
500
- handleCellMouseEnter(ev) {
501
- const cell = ev.target;
502
- const contentWrapper = cell.querySelector(".cell-content-wrapper");
503
- const isTruncated = contentWrapper.scrollWidth > contentWrapper.clientWidth;
504
- if (isTruncated) {
505
- // innerText is necessary vs textContent, as innerText ignores sr-only / display: none text
506
- functions.showTooltip("bottom", cell, cell.innerText);
507
- }
508
- }
509
- handleTagAreaFocus() {
510
- if (this.tagInputType === "dropdown") {
511
- this.closeDropdown();
512
- }
513
- const firstFocusableTag = this.nonLockedTagEls[0];
514
- firstFocusableTag && this.focusTag(firstFocusableTag);
515
- }
516
- handleRemoveButtonClick(tag) {
517
- this.moveLeftTag();
518
- this.removeTag(tag);
519
- }
520
- moveDownListItem() {
521
- if (this.listItemEls.length > 0) {
522
- const firstListItem = this.listItemEls[0];
523
- if (!this.focusedListItem) {
524
- this.focusListItem(firstListItem);
525
- }
526
- else if (this.focusedListItem.nextElementSibling) {
527
- this.focusListItem(this.focusedListItem.nextElementSibling);
528
- }
529
- else {
530
- this.focusListItem(firstListItem);
531
- }
532
- }
533
- }
534
- moveUpListItem() {
535
- if (this.listItemEls.length > 0) {
536
- const lastListItem = this.listItemEls[this.listItemEls.length - 1];
537
- if (!this.focusedListItem) {
538
- this.focusListItem(lastListItem);
539
- }
540
- else if (this.focusedListItem.previousElementSibling) {
541
- this.focusListItem(this.focusedListItem.previousElementSibling);
542
- }
543
- else {
544
- this.clearListItemFocus();
545
- }
546
- }
547
- }
548
- moveDownRow() {
549
- if (this.filteredRows.length > 0) {
550
- if (this.tablePosition.row === 0) {
551
- this.tablePosition.row = 1;
552
- }
553
- else if (this.tablePosition.row === this.filteredRows.length) {
554
- this.tablePosition.row = 1;
555
- }
556
- else {
557
- this.tablePosition.row++;
558
- }
559
- // skip locked rows
560
- const rowToFocus = this.wmRowEls[this.tablePosition.row - 1];
561
- if (rowToFocus.locked) {
562
- this.moveDownRow();
563
- }
564
- else {
565
- this.focusCell(this.tablePosition);
566
- }
567
- }
568
- }
569
- moveUpRow() {
570
- if (this.filteredRows.length > 0) {
571
- if (this.tablePosition.row === 0) {
572
- this.tablePosition.row = this.filteredRows.length;
573
- }
574
- else if (this.tablePosition.row === 1) {
575
- this.tablePosition.row = 0;
576
- }
577
- else {
578
- this.tablePosition.row--;
579
- }
580
- // skip locked rows
581
- const rowToFocus = this.wmRowEls[this.tablePosition.row - 1];
582
- if (rowToFocus && rowToFocus.locked) {
583
- this.moveUpRow();
584
- }
585
- else if (rowToFocus) {
586
- this.focusCell(this.tablePosition);
587
- }
588
- else {
589
- this.clearCellFocus();
590
- }
591
- }
592
- }
593
- moveLeftCell() {
594
- if (this.tablePosition.column != 1) {
595
- this.tablePosition.column--;
596
- this.focusCell(this.tablePosition);
597
- }
598
- }
599
- moveRightCell() {
600
- const numCols = functions.csvToArray(this.colHeaders).length;
601
- if (this.tablePosition.column < numCols) {
602
- this.tablePosition.column++;
603
- this.focusCell(this.tablePosition);
604
- }
605
- }
606
- moveLeftTag() {
607
- const lastTag = this.tagEls[this.tagEls.length - 1];
608
- if (this.focusedTag && this.tagEls.includes(this.focusedTag.previousElementSibling)) {
609
- this.focusedTag = this.focusedTag.previousElementSibling;
610
- }
611
- else {
612
- this.focusedTag = lastTag;
613
- }
614
- // skip locked tags
615
- if (this.focusedTag.classList.contains("locked") && this.nonLockedTagEls.length > 0) {
616
- this.moveLeftTag();
617
- }
618
- else {
619
- this.focusTag(this.focusedTag);
620
- }
621
- }
622
- moveRightTag() {
623
- const firstTag = this.tagEls[0];
624
- if (this.focusedTag && this.tagEls.includes(this.focusedTag.nextElementSibling)) {
625
- this.focusedTag = this.focusedTag.nextElementSibling;
626
- }
627
- else {
628
- this.focusedTag = firstTag;
629
- }
630
- // skip locked tags
631
- if (this.focusedTag.classList.contains("locked")) {
632
- this.moveRightTag();
633
- }
634
- else {
635
- this.focusTag(this.focusedTag);
636
- }
637
- }
638
- addOption(option) {
639
- let newOptionsList = this.optionsList;
640
- const optionAlreadyExists = this.includesCaseInsensitive(this.optionsList, option);
641
- if (!optionAlreadyExists) {
642
- newOptionsList = newOptionsList.concat(option);
643
- }
644
- return newOptionsList;
645
- }
646
- removeOption(option) {
647
- this.optionsList = this.filterCaseInsensitive(this.optionsList, option);
648
- }
649
- addTag(tag) {
650
- let newTagsList = this.tagsList;
651
- const tagAlreadyAdded = this.includesCaseInsensitive(this.tagsList, tag);
652
- const tagExistsAsOption = this.optionsList.filter((x) => x.toLowerCase() === tag.toLowerCase())[0];
653
- if (!tagAlreadyAdded) {
654
- let textToAnnounce = tag;
655
- if (this.tagInputType === "table") {
656
- const referencedRow = this.el.querySelector(`#${tag}`);
657
- textToAnnounce = referencedRow.col1;
658
- }
659
- this.announce(this.generateTagAddedMessage(textToAnnounce));
660
- this.tagsList = newTagsList.concat(tagExistsAsOption || tag);
661
- // if maxTags has been reached, focus should go to the tagArea
662
- if (this.tagLimitReached) {
663
- this.tagAreaEl.focus();
664
- }
665
- }
666
- }
667
- removeTag(tag) {
668
- let textToAnnounce = tag;
669
- if (this.tagInputType === "table") {
670
- const referencedRow = this.el.querySelector(`#${tag}`);
671
- textToAnnounce = referencedRow.col1;
672
- }
673
- const tagRemovedMessage = functions.intl.formatMessage({ id: "tagInput.tagRemoved", defaultMessage: "{tag} removed" }, { tag: textToAnnounce });
674
- this.announce(tagRemovedMessage);
675
- this.tagsList = this.filterCaseInsensitive(this.tagsList, tag);
676
- if (this.tagInputType === "dropdown") {
677
- // if a tag was introduced by the user, also remove it from the dropdown options
678
- const devOptionsList = functions.csvToArray(this.options);
679
- if (this.includesCaseInsensitive(this.optionsList, tag) && !this.includesCaseInsensitive(devOptionsList, tag)) {
680
- this.removeOption(tag);
681
- }
682
- }
683
- }
684
- focusListItem(item) {
685
- this.focusedListItem = item;
686
- this.inputEl.setAttribute("aria-activedescendant", this.focusedListItem.id);
687
- item.scrollIntoView({ block: "nearest" });
688
- }
689
- focusTag(element) {
690
- if (element.classList.contains("locked")) {
691
- this.focusedTag = null;
692
- this.tagAreaEl.setAttribute("aria-activedescendant", "");
693
- }
694
- else {
695
- this.focusedTag = element;
696
- this.tagAreaEl.setAttribute("aria-activedescendant", this.focusedTag.id);
697
- }
698
- window.requestAnimationFrame(() => {
699
- functions.hideTooltip();
700
- const textEl = element.querySelector(".tag-text");
701
- const fullText = element.dataset.tag;
702
- const isTruncated = fullText !== textEl.textContent && textEl.textContent.includes("...");
703
- isTruncated && functions.showTooltip("bottom", element, fullText);
704
- });
705
- }
706
- focusCell(position) {
707
- this.clearCellFocus(false);
708
- if (position.row) {
709
- const rowToFocus = this.localRowEls[position.row];
710
- const rowCells = rowToFocus.querySelectorAll("td");
711
- const cellToFocus = rowCells[position.column - 1];
712
- const contentWrapper = cellToFocus.querySelector(".cell-content-wrapper");
713
- const isTruncated = contentWrapper.scrollWidth > contentWrapper.clientWidth;
714
- rowToFocus.classList.add("focused");
715
- cellToFocus.classList.add("focused");
716
- cellToFocus.scrollIntoView({ block: "nearest" });
717
- this.inputEl.setAttribute("aria-activedescendant", cellToFocus.id);
718
- this.dismissTooltip();
719
- if (isTruncated) {
720
- // innerText is necessary vs textContent, as innerText ignores sr-only / display: none text
721
- functions.showTooltip("bottom", cellToFocus, cellToFocus.innerText);
722
- }
723
- }
724
- }
725
- clearTagFocus() {
726
- this.tagAreaEl.setAttribute("aria-activedescendant", "");
727
- this.focusedTag = null;
728
- }
729
- clearCellFocus(resetPosition = true) {
730
- this.inputEl.setAttribute("aria-activedescendant", "");
731
- if (resetPosition) {
732
- this.tablePosition = { row: 0, column: 1 };
733
- }
734
- this.localRowEls.forEach((row) => {
735
- row.classList.remove("focused");
736
- row.querySelectorAll("td").forEach((cell) => {
737
- cell.classList.remove("focused");
738
- });
739
- });
740
- }
741
- openDropdown() {
742
- // given an offset of -2px because the dropdown is transformed downwards to avoid overlapping the focus border
743
- this.openUp = functions.shouldOpenUp(this.el, this.dropdownEl, this.el.clientHeight, -2);
744
- this.isExpanded = true;
745
- }
746
- closeDropdown() {
747
- this.clearListItemFocus();
748
- this.isExpanded = false;
749
- }
750
- clearListItemFocus() {
751
- this.focusedListItem = null;
752
- this.inputEl.setAttribute("aria-activedescendant", "");
753
- this.listItemEls.forEach((el) => {
754
- el.classList.remove("focused");
755
- });
756
- }
757
- resetInput() {
758
- this.charCount = 0;
759
- this.inputEl.value = "";
760
- }
761
- announce(message) {
762
- // \u00A0 is a non-breaking space character, which causes the message to be read as a new one
763
- if (this.liveRegionEl.textContent === message) {
764
- message += "\u00A0";
765
- }
766
- this.liveRegionMessage = message;
767
- }
768
- announceExistingOptions() {
769
- // request animation frame to wait for re-rendering of filtered options
770
- window.requestAnimationFrame(() => {
771
- let numResults = 0;
772
- if (this.tagInputType === "dropdown") {
773
- numResults = this.optionEls.length;
774
- }
775
- else if (this.tagInputType === "table") {
776
- numResults = this.filteredRows.length;
777
- }
778
- const existingOptionsMessage = functions.intl.formatMessage({
779
- id: "tagInput.existingOptions",
780
- defaultMessage: "{num, plural, one {1 existing option.} other {# existing options.}}",
781
- }, { num: numResults });
782
- this.announce(existingOptionsMessage);
783
- });
784
- }
785
- generateCharacterLimitWarning(charCount, charLimit) {
786
- let message = intl.globalMessages.getCharactersEntered(charCount, charLimit);
787
- if (charCount >= charLimit) {
788
- message += ` ${intl.globalMessages.characterLimitReached}`;
789
- }
790
- return message;
791
- }
792
- positionInput() {
793
- const lastTag = this.tagEls[this.tagEls.length - 1];
794
- // default placement to fall back to when no tags are present, or not enough space is available
795
- this.inputEl.style.position = "static";
796
- this.inputEl.style.width = "100%";
797
- if (lastTag) {
798
- const spaceAvailable = this.tagAreaEl.getBoundingClientRect().right - lastTag.getBoundingClientRect().right;
799
- if (spaceAvailable >= this.inputMinimumWidth) {
800
- // because the input has right: 0px
801
- // all thats needed to properly place it is setting position: absolute, top, and width
802
- this.inputEl.style.position = "absolute";
803
- this.inputEl.style.top = lastTag.offsetTop.toString() + "px";
804
- this.inputEl.style.width =
805
- (this.tagAreaEl.getBoundingClientRect().right - lastTag.getBoundingClientRect().right - 8).toString() + "px";
806
- }
807
- }
808
- }
809
- handleTagMouseEnter(ev) {
810
- const displayedText = ev.target.querySelector(".tag-text").textContent;
811
- const fullText = ev.target.dataset.tag;
812
- const isTruncated = displayedText !== fullText && displayedText.includes("...");
813
- isTruncated && functions.showTooltip("bottom", ev.target, fullText);
814
- }
815
- /// Helpers
816
- listToCSV(list) {
817
- return list.join(",");
818
- }
819
- includesCaseInsensitive(list, element) {
820
- const lowercaseList = list.map((str) => str.toLowerCase());
821
- return lowercaseList.includes(element.toLowerCase());
822
- }
823
- filterCaseInsensitive(list, element) {
824
- return list.filter((x) => x.toLowerCase() !== element.toLowerCase());
825
- }
826
- sortCaseInsensitive(list) {
827
- // The vanilla .sort method places words that start with capital letters above others (ASCII order)
828
- // so we need to pass in our own compare function to sort case-insensitive
829
- return list.sort((a, b) => {
830
- a = a.toLowerCase();
831
- b = b.toLowerCase();
832
- return a > b ? 1 : a < b ? -1 : 0;
833
- });
834
- }
835
- /// Renders
836
- renderTags() {
837
- let lockedTags = [];
838
- let unlockedTags = [];
839
- this.tagsList.forEach((tag, idx) => {
840
- const id = `tag${idx + 1}`;
841
- let tagText = "";
842
- let isLocked = false;
843
- if (this.tagInputType === "dropdown") {
844
- tagText = tag;
845
- }
846
- else if (this.tagInputType === "table") {
847
- // display table tags using col1 of the row with the same id
848
- // if one can't be found, display as empty
849
- const referencedRow = this.el.querySelector(`#${tag}`);
850
- tagText = referencedRow ? referencedRow.col1 : "";
851
- isLocked = referencedRow ? referencedRow.locked : false;
852
- }
853
- // make sure locked tags always appear in front of list
854
- const targetList = isLocked ? lockedTags : unlockedTags;
855
- targetList.push(index.h("li", { id: id, class: `tag highlight ${this.focusedTag && this.focusedTag.id === id ? "focused" : ""} ${isLocked ? "locked" : ""}`, "data-tag": tag, role: "option", onMouseEnter: (ev) => this.handleTagMouseEnter(ev), onMouseLeave: functions.hideTooltip }, index.h("span", { class: "sr-only" }, tag), index.h("span", { class: "tag-text", "aria-hidden": "true" }, tagText), isLocked ? (index.h("div", { class: "icon lock" })) : (index.h("button", { class: "icon remove-btn", tabIndex: -1, onClick: () => this.handleRemoveButtonClick(tag) }))));
856
- });
857
- return [...lockedTags, ...unlockedTags];
858
- }
859
- renderDropdown() {
860
- return (index.h("div", { class: `dropdown-wrapper ${this.isExpanded ? "open" : ""} ${this.openUp ? "upwards" : ""}`, ref: (el) => (this.dropdownEl = el) }, index.h("div", { id: "help-text", class: "help-text" }, this.renderHelpText()), index.h("ul", { class: "dropdown", id: "dropdown", role: "listbox", "aria-multiselectable": "true", "aria-expanded": this.isExpanded ? "true" : false, "aria-label": this.label, tabindex: -1 }, this.inputEl && this.renderAddNewButton(), this.renderListItems(this.optionsList))));
861
- }
862
- renderListItems(optionsList) {
863
- optionsList = this.sortCaseInsensitive(optionsList);
864
- // filter by input
865
- if (this.inputEl && this.inputEl.value) {
866
- optionsList = this.optionsList.filter((option) => option.toLowerCase().includes(this.inputEl.value.toLowerCase()));
867
- }
868
- return optionsList.map((option, idx) => {
869
- const id = `option${idx + 1}`;
870
- const isFocused = this.focusedListItem && this.focusedListItem.id === id;
871
- const isSelected = this.includesCaseInsensitive(this.tagsList, option);
872
- return (index.h("li", { class: `option ${isFocused ? "focused" : ""}`, role: "option", id: id, "data-option": option, "aria-selected": isSelected ? "true" : "false", "aria-disabled": isSelected ? "true" : "false", onKeyDown: (ev) => this.handleListItemKeyDown(ev), onBlur: (ev) => this.handleBlur(ev, this.el), onClick: (ev) => this.handleListItemClick(ev.target) }, option));
873
- });
874
- }
875
- renderAddNewButton() {
876
- const hasNonWhiteSpaceCharacters = this.inputEl.value.match(/\S/);
877
- const optionAlreadyExists = this.includesCaseInsensitive(this.optionsList, this.inputEl.value.trim());
878
- if (this.addNew && hasNonWhiteSpaceCharacters && !optionAlreadyExists) {
879
- const id = `add-new-btn`;
880
- const isFocused = this.focusedListItem && this.focusedListItem.id === id;
881
- return (index.h("li", { role: "option", class: `add-new-btn ${isFocused ? "focused" : ""}`, id: id, "data-option": this.inputEl.value, onKeyDown: (ev) => this.handleListItemKeyDown(ev), onBlur: (ev) => this.handleBlur(ev, this.el), onClick: (ev) => this.handleListItemClick(ev.target), tabIndex: isFocused ? 0 : -1 }, `Add "${this.inputEl.value.trim()}"`));
882
- }
883
- else
884
- return "";
885
- }
886
- renderHelpText() {
887
- let helpText = "";
888
- if (this.optionsList.length > 0) {
889
- helpText += this.componentMessages.selectionHelpText;
890
- }
891
- if (this.addNew) {
892
- helpText += " " + this.componentMessages.addNewHelpText;
893
- }
894
- return helpText;
895
- }
896
- renderTagCounter() {
897
- if (this.maxTags) {
898
- return (index.h("div", { class: "lower-row" }, index.h("div", { id: "max-tags" }, `${this.componentMessages.tagsAdded}: ${this.tagsList.length}/${this.maxTags}`, this.tagLimitReached && ` - ${this.componentMessages.maxTagsReached}`)));
899
- }
900
- }
901
- renderTable() {
902
- return (index.h("div", { class: "table-wrapper", onScroll: () => this.dismissTooltip() }, index.h("table", { id: "table", role: "grid", class: `${this.colWidths ? "fixed-widths" : ""}`, "aria-label": this.label, "aria-multiselectable": "true" }, this.renderTableHeaders(), this.filteredRows.length ? this.renderTableRows() : index.h("div", { class: "no-results" }, this.noResultsMessage))));
903
- }
904
- renderTableHeaders() {
905
- return (index.h("tr", { class: "headers", role: "row" }, functions.csvToArray(this.colHeaders).map((header, idx) => {
906
- let overflowRule = "wrap";
907
- if (this.colWrap && functions.csvToArray(this.colWrap)[idx]) {
908
- overflowRule = functions.csvToArray(this.colWrap)[idx];
909
- }
910
- return (index.h("th", { class: `header-cell ${overflowRule}`, role: "columnheader",
911
- // @ts-ignore
912
- width: this.colWidths ? functions.csvToArray(this.colWidths)[idx] : "" }, header));
913
- })));
914
- }
915
- renderTableRows() {
916
- return this.filteredRows.map((row) => {
917
- const isSelected = this.includesCaseInsensitive(this.tagsList, row.id);
918
- return (index.h("tr", { id: row.id, class: `${row.locked ? "locked" : ""} ${isSelected ? "selected" : ""}`, role: "row", onClick: () => this.handleTableRowClick(row.id) }, this.renderTableCells(row)));
919
- });
920
- }
921
- renderTableCells(row) {
922
- const colValues = [row.col1, row.col2, row.col3, row.col4].filter((val) => !!val);
923
- const isSelected = this.includesCaseInsensitive(this.tagsList, row.id);
924
- return colValues.map((val, idx) => {
925
- const localId = `${row.id}-col${idx + 1}`;
926
- let overflowRule = "wrap";
927
- if (this.colWrap && functions.csvToArray(this.colWrap)[idx]) {
928
- overflowRule = functions.csvToArray(this.colWrap)[idx];
929
- }
930
- return (index.h("td", { id: localId, role: "gridcell", "aria-describedby": `${localId}-description`, "aria-selected": isSelected.toString(), onMouseEnter: (ev) => this.handleCellMouseEnter(ev), onMouseLeave: () => this.dismissTooltip() }, index.h("div", { class: `cell-content-wrapper ${overflowRule}` }, val), index.h("div", { class: "description", id: `${localId}-description` }, row.locked ? "locked" : "")));
931
- });
932
- }
933
- render() {
934
- return (index.h(index.Host, { id: this.uid }, index.h("div", { class: `wrapper label-${this.labelPosition} ${this.errorMessage ? "invalid" : ""}` }, index.h("div", { class: "label-wrapper" }, index.h("label", { class: "label", htmlFor: `input${this.uid}` }, this.label, this.requiredField && (index.h("span", { class: "required", "aria-hidden": "true" }, "*")))), index.h("div", { class: `field-wrapper ${this.focusedElement ? "focused" : ""} ${this.errorMessage ? "invalid" : ""}`, ref: (el) => (this.fieldWrapperEl = el) }, index.h("div", { class: "upper-row" }, index.h("div", { class: "tags-and-input-wrapper" }, this.tagsList.length > 0 && (index.h("ul", { ref: (el) => (this.tagAreaEl = el), class: "tag-area", role: "listbox", "aria-activedescendant": "", "aria-orientation": "horizontal", "aria-label": `${this.label} ${this.tagsList.length > 0 ? this.componentMessages.tagAreaInstructions : ""}`, tabindex: this.nonLockedTagsList.length > 0 ? 0 : -1, "aria-describedby": `info max-tags`, onFocus: () => this.handleTagAreaFocus(), onBlur: (ev) => {
935
- this.clearTagFocus();
936
- this.handleBlur(ev, this.el);
937
- }, onKeyDown: (ev) => this.handleTagAreaKeyDown(ev) }, this.renderTags())), index.h("input", { id: `input${this.uid}`, class: this.tagLimitReached ? "hidden" : "", role: "combobox", ref: (el) => (this.inputEl = el), autocomplete: "off", "aria-required": this.requiredField ? "true" : null, "aria-controls": this.tagInputType, "aria-describedby": `help-text${this.errorMessage ? " error " : ""}`, "aria-label": `${this.label} ${this.tagInputType === "dropdown" ? intl.globalMessages.getCharacterLimit(this.characterLimit) : ""}`, "aria-expanded": this.tagInputType === "dropdown" ? this.isExpanded.toString() : null, placeholder: this.placeholder, maxLength: this.tagInputType === "dropdown" ? this.characterLimit : undefined, onInput: () => this.handleInputChanged(this.inputEl.value), onBlur: (ev) => {
938
- this.handleBlur(ev, this.el);
939
- }, onFocus: () => this.handleInputFocus(), onKeyDown: (ev) => this.handleInputKeyDown(ev) })), this.tagInputType === "dropdown" && (index.h("div", { class: "character-count" }, this.charCount, "/", this.characterLimit))), this.renderTagCounter(), this.tagInputType === "dropdown" && this.renderDropdown()), this.info && (index.h("div", { id: "info", class: "info-text" }, this.info)), this.errorMessage && index.h("div", { id: "error" }, this.errorMessage), index.h("div", { class: "sr-only", "aria-live": "assertive", ref: (el) => (this.liveRegionEl = el), "aria-atomic": "true" }, this.liveRegionMessage), this.tagInputType === "table" && this.renderTable())));
940
- }
941
- static get delegatesFocus() { return true; }
942
- get el() { return index.getElement(this); }
943
- static get watchers() { return {
944
- "tagsList": ["reflectSelectedTags"],
945
- "errorMessage": ["handleErrorMessageChange"]
946
- }; }
947
- };
11
+ const TagInput = class {
12
+ constructor(hostRef) {
13
+ index.registerInstance(this, hostRef);
14
+ this.wmTagInputChanged = index.createEvent(this, "wmTagInputChanged", 7);
15
+ this.uid = this.el.id ? this.el.id : functions.generateId();
16
+ this.openUp = false;
17
+ this.debouncedUpdate = functions.debounce(() => index.forceUpdate(this.el), 30);
18
+ this.label = undefined;
19
+ this.labelPosition = "top";
20
+ this.options = "";
21
+ this.selectedTags = "";
22
+ this.info = undefined;
23
+ this.errorMessage = undefined;
24
+ this.addNew = true;
25
+ this.placeholder = undefined;
26
+ this.requiredField = false;
27
+ this.characterLimit = 50;
28
+ this.maxTags = undefined;
29
+ this.tagInputType = "dropdown";
30
+ this.colHeaders = undefined;
31
+ this.colWidths = undefined;
32
+ this.colWrap = undefined;
33
+ this.messageConfig = "";
34
+ this.focusedListItem = undefined;
35
+ this.focusedTag = null;
36
+ this.tablePosition = { row: 0, column: 1 };
37
+ this.isExpanded = false;
38
+ this.tagsList = functions.csvToArray(this.selectedTags);
39
+ this.optionsList = functions.csvToArray(this.options);
40
+ this.charCount = 0;
41
+ this.liveRegionMessage = "";
42
+ }
43
+ get tooltipVisible() {
44
+ return document.getElementById("wm-tooltip").classList.contains("open");
45
+ }
46
+ get focusedElement() {
47
+ return this.el.shadowRoot.activeElement;
48
+ }
49
+ get listItemEls() {
50
+ return Array.from(this.dropdownEl.querySelectorAll("li"));
51
+ }
52
+ get tagEls() {
53
+ return this.tagAreaEl ? Array.from(this.tagAreaEl.querySelectorAll(".tag")) : [];
54
+ }
55
+ get nonLockedTagEls() {
56
+ return this.tagEls.filter((tag) => !tag.classList.contains("locked"));
57
+ }
58
+ get optionEls() {
59
+ return Array.from(this.dropdownEl.querySelectorAll(".option"));
60
+ }
61
+ get wmRowEls() {
62
+ return Array.from(this.el.querySelectorAll("wm-tag-input-row"));
63
+ }
64
+ get localRowEls() {
65
+ return Array.from(this.el.shadowRoot.querySelectorAll("tr"));
66
+ }
67
+ get filteredRows() {
68
+ return this.wmRowEls.filter((row) => {
69
+ const colValues = [row.col1, row.col2, row.col3, row.col4].join("").toLowerCase();
70
+ return this.inputEl && this.inputEl.value ? colValues.includes(this.inputEl.value.toLowerCase()) : true;
71
+ });
72
+ }
73
+ get nonLockedTagsList() {
74
+ let list = [];
75
+ if (this.tagInputType === "table") {
76
+ this.tagsList.forEach((id) => {
77
+ const correspondingRowEl = this.wmRowEls.filter((row) => id === row.id)[0];
78
+ if (!correspondingRowEl.locked) {
79
+ list.push(id);
80
+ }
81
+ });
82
+ }
83
+ else if (this.tagInputType === "dropdown") {
84
+ list = this.tagsList;
85
+ }
86
+ return list;
87
+ }
88
+ get tagLimitReached() {
89
+ return !!(this.maxTags && this.tagsList.length >= this.maxTags);
90
+ }
91
+ get noResultsMessage() {
92
+ return functions.intl.formatMessage({
93
+ id: "tagInput.noResults",
94
+ defaultMessage: "No results match your search.",
95
+ description: "Message displayed when a user's search returns empty.",
96
+ });
97
+ }
98
+ get componentMessages() {
99
+ const addNewHelpText = functions.intl.formatMessage({
100
+ id: "tagInput.addNewHelpText",
101
+ defaultMessage: "Press the Enter or Comma key to add a new tag.",
102
+ description: "Help text appearing in a dropdown. Use imperative",
103
+ });
104
+ const selectionHelpText = functions.intl.formatMessage({
105
+ id: "tagInput.selectionHelpText",
106
+ defaultMessage: "Search and select a tag.",
107
+ description: "Help text appearing in a dropdown. Use imperative",
108
+ });
109
+ const maxTagsReachedMessage = functions.intl.formatMessage({
110
+ id: "tagInput.maxTagsReached",
111
+ defaultMessage: "No more tags can be added because the limit has been reached.",
112
+ });
113
+ const tagAreaInstructions = functions.intl.formatMessage({
114
+ id: "tagInput.tagAreaInstructions",
115
+ defaultMessage: "tag selection. Press Backspace or Delete to remove a tag.",
116
+ });
117
+ const tagsAddedMessage = functions.intl.formatMessage({
118
+ id: "tagInput.tagsAdded",
119
+ defaultMessage: "Tags added",
120
+ description: "For the user to understand how close they are to the tag limit, followed by x/y count",
121
+ });
122
+ const defaultConfig = {
123
+ addNewHelpText: addNewHelpText,
124
+ selectionHelpText: selectionHelpText,
125
+ maxTagsReached: maxTagsReachedMessage,
126
+ tagAreaInstructions: tagAreaInstructions,
127
+ tagsAdded: tagsAddedMessage,
128
+ };
129
+ const userProvidedConfig = functions.safeParseJSON(this.messageConfig);
130
+ return userProvidedConfig ? Object.assign(Object.assign({}, defaultConfig), userProvidedConfig) : defaultConfig;
131
+ }
132
+ get inputMinimumWidth() {
133
+ // 150px is the minimum width of the input field, or the length of the placeholder text
134
+ const inputElStyles = getComputedStyle(this.inputEl);
135
+ const tagElStyles = getComputedStyle(this.tagEls[this.tagEls.length - 1]);
136
+ const inputElBuffer = [
137
+ inputElStyles.paddingLeft,
138
+ inputElStyles.paddingRight,
139
+ inputElStyles.marginLeft,
140
+ inputElStyles.marginRight,
141
+ tagElStyles.marginRight,
142
+ ].reduce((prev, curr) => prev + parseInt(curr.replace("px", "")), 0);
143
+ const minimumWidth = Math.max(150, functions.measureText(this.inputEl, this.placeholder).width + inputElBuffer);
144
+ return minimumWidth;
145
+ }
146
+ generateTagAddedMessage(tag) {
147
+ return functions.intl.formatMessage({
148
+ id: "tagInput.tagAdded",
149
+ defaultMessage: "{tagName} added.",
150
+ description: "A confirmation for adding a tag.",
151
+ }, { tagName: tag });
152
+ }
153
+ generateTagAlreadyAddedMessage(tag) {
154
+ return functions.intl.formatMessage({
155
+ id: "tagInput.tagAlreadyAdded",
156
+ defaultMessage: "{tagName} has already been added.",
157
+ description: "An alert for adding a tag that is already present.",
158
+ }, { tagName: tag });
159
+ }
160
+ componentWillLoad() {
161
+ if (!this.placeholder) {
162
+ this.placeholder = this.createPlaceholderDefault(this.addNew, !!this.options);
163
+ }
164
+ if (!this.label) {
165
+ console.error("wm-tag-input must have a label property");
166
+ }
167
+ this.consolidateSelectedTags();
168
+ this.el.focus = () => {
169
+ const firstFocusableTag = this.nonLockedTagEls[0];
170
+ if (firstFocusableTag) {
171
+ this.tagAreaEl.focus();
172
+ this.focusTag(firstFocusableTag);
173
+ }
174
+ else {
175
+ this.inputEl.focus();
176
+ }
177
+ };
178
+ // on resize of component, trigger componentDidRender -> positionInput
179
+ const resizeObserver = new ResizeObserver(() => this.debouncedUpdate());
180
+ resizeObserver.observe(this.el);
181
+ }
182
+ componentDidLoad() {
183
+ // prevent highlighting of pre-selected tags
184
+ this.tagEls.forEach((el) => el.classList.remove("highlight"));
185
+ }
186
+ componentDidRender() {
187
+ this.positionInput();
188
+ // check each tag if truncation is needed
189
+ this.tagEls.forEach((tag) => {
190
+ const textEl = tag.querySelector(".tag-text");
191
+ const wrapper = this.el.shadowRoot.querySelector(".tags-and-input-wrapper");
192
+ const leftBound = textEl.getBoundingClientRect().left;
193
+ // the numbers represent spacing values for padding, margin, and delete icon
194
+ const rightBound = wrapper.getBoundingClientRect().right - 10 - 8 - 28;
195
+ let displayText = tag.dataset.tag;
196
+ if (this.tagInputType === "table") {
197
+ // table variant doesn't display the tag id, but the contents of the first column
198
+ const referencedRow = this.el.querySelector(`#${displayText}`);
199
+ displayText = referencedRow ? referencedRow.col1 : "";
200
+ }
201
+ textEl.textContent = functions.truncateText(textEl, displayText, rightBound - leftBound, 5);
202
+ });
203
+ }
204
+ consolidateSelectedTags() {
205
+ this.tagsList.forEach((tag) => {
206
+ if (!this.includesCaseInsensitive(this.optionsList, tag)) {
207
+ this.options += `${this.options.length > 0 ? "," : ""}${tag}`;
208
+ }
209
+ });
210
+ this.optionsList = functions.csvToArray(this.options);
211
+ }
212
+ createPlaceholderDefault(addNew, hasOptions) {
213
+ const addAndSearchPlaceholder = functions.intl.formatMessage({
214
+ id: "tagInput.placeholderAddAndSearch",
215
+ defaultMessage: "Add or search for a tag",
216
+ description: "Placeholder text. Use imperative",
217
+ });
218
+ const searchPlaceholder = functions.intl.formatMessage({
219
+ id: "tagInput.placeholderSearch",
220
+ defaultMessage: "Search and select a tag",
221
+ description: "Placeholder text. Use imperative",
222
+ });
223
+ const addPlaceholder = functions.intl.formatMessage({
224
+ id: "tagInput.placeholderAdd",
225
+ defaultMessage: "Add a new tag",
226
+ description: "Placeholder text. Use imperative",
227
+ });
228
+ let placeholder = "";
229
+ if (addNew && hasOptions) {
230
+ placeholder = addAndSearchPlaceholder;
231
+ }
232
+ else if (!addNew && hasOptions) {
233
+ placeholder = searchPlaceholder;
234
+ }
235
+ else if (addNew) {
236
+ placeholder = addPlaceholder;
237
+ }
238
+ return placeholder;
239
+ }
240
+ reflectSelectedTags(newValue, oldValue) {
241
+ const isAddition = newValue.length > oldValue.length;
242
+ let changedTag = "";
243
+ let selectedTags = this.tagsList;
244
+ if (isAddition) {
245
+ changedTag = newValue.filter((val) => !oldValue.includes(val))[0];
246
+ }
247
+ else {
248
+ changedTag = oldValue.filter((val) => !newValue.includes(val))[0];
249
+ }
250
+ // event emitted by type table uses element references instead of strings
251
+ if (this.tagInputType === "table") {
252
+ changedTag = this.wmRowEls.filter((row) => row.id === changedTag)[0];
253
+ selectedTags = this.tagsList.map((id) => this.el.querySelector(`#${id}`));
254
+ }
255
+ this.selectedTags = this.listToCSV(this.tagsList);
256
+ let detail = { value: selectedTags, tagChanged: changedTag };
257
+ this.wmTagInputChanged.emit(detail);
258
+ }
259
+ handleErrorMessageChange() {
260
+ if (this.errorMessage) {
261
+ this.announce(this.errorMessage);
262
+ }
263
+ }
264
+ handleRowUpdate() {
265
+ index.forceUpdate(this.el);
266
+ }
267
+ closeIfNotElOrChild(ev) {
268
+ const isntElOrChild = ev.target !== this.el && !this.el.shadowRoot.contains(ev.target);
269
+ if (this.tagInputType === "dropdown" && isntElOrChild && this.isExpanded) {
270
+ this.closeDropdown();
271
+ }
272
+ }
273
+ // From wm-button
274
+ // we need to listen for scroll events during the capture phase because they do not bubble up
275
+ // there can be layouts where the main content has 100vh and overflows
276
+ // in these cases window will register no scroll events unless we catch on they way down
277
+ dismissTooltip() {
278
+ if (this.tooltipVisible) {
279
+ functions.hideTooltip();
280
+ }
281
+ }
282
+ handleInputKeyDown(ev) {
283
+ if (/^.$/.test(ev.key) && this.inputEl.value.length >= this.characterLimit) {
284
+ this.announce(this.generateCharacterLimitWarning(this.inputEl.value.length, this.characterLimit));
285
+ }
286
+ // prevent keydown triggering on tag area
287
+ ev.stopPropagation();
288
+ switch (ev.key) {
289
+ case "Enter":
290
+ case ",":
291
+ ev.preventDefault();
292
+ this.handleInputEnter();
293
+ break;
294
+ case "ArrowDown":
295
+ ev.preventDefault();
296
+ this.handleInputArrowDown();
297
+ break;
298
+ case "ArrowUp":
299
+ ev.preventDefault();
300
+ this.handleInputArrowUp();
301
+ break;
302
+ case "ArrowLeft":
303
+ if (this.tagInputType === "table" && this.tablePosition.row) {
304
+ ev.preventDefault();
305
+ this.moveLeftCell();
306
+ }
307
+ break;
308
+ case "ArrowRight":
309
+ if (this.tagInputType === "table" && this.tablePosition.row) {
310
+ ev.preventDefault();
311
+ this.moveRightCell();
312
+ }
313
+ break;
314
+ case "Escape":
315
+ if (this.tagInputType === "dropdown" && this.isExpanded) {
316
+ this.closeDropdown();
317
+ }
318
+ break;
319
+ case "ArrowLeft":
320
+ case "Backspace":
321
+ this.handleInputBackspace();
322
+ break;
323
+ }
324
+ }
325
+ handleInputFocus() {
326
+ if (this.tagInputType === "dropdown") {
327
+ this.openDropdown();
328
+ this.clearListItemFocus();
329
+ }
330
+ // force update needed to apply styled state of field-wrapper el
331
+ index.forceUpdate(this.el);
332
+ }
333
+ handleInputChanged(value) {
334
+ this.charCount = value.length;
335
+ if (this.tagInputType === "dropdown") {
336
+ this.clearListItemFocus();
337
+ if (this.charCount >= this.characterLimit - 5) {
338
+ this.announce(this.generateCharacterLimitWarning(this.charCount, this.characterLimit));
339
+ }
340
+ if (!this.isExpanded) {
341
+ this.openDropdown();
342
+ }
343
+ }
344
+ else if (this.tagInputType === "table") {
345
+ this.clearCellFocus();
346
+ }
347
+ this.announceExistingOptions();
348
+ }
349
+ handleInputEnter() {
350
+ if (this.tagInputType === "dropdown") {
351
+ if (this.focusedListItem) {
352
+ this.handleListItemClick(this.focusedListItem);
353
+ }
354
+ else {
355
+ this.submitInput(this.addNew, this.inputEl.value.trim());
356
+ }
357
+ }
358
+ else if (this.tagInputType === "table" && this.tablePosition.row > 0) {
359
+ this.handleTableRowClick(this.localRowEls[this.tablePosition.row].id);
360
+ }
361
+ }
362
+ submitInput(canAddNew, value) {
363
+ const hasNonWhiteSpaceCharacters = value.match(/\S/);
364
+ if (canAddNew && hasNonWhiteSpaceCharacters) {
365
+ this.addTag(value);
366
+ this.optionsList = this.addOption(value);
367
+ this.resetInput();
368
+ }
369
+ }
370
+ handleInputArrowDown() {
371
+ if (this.tagInputType === "table") {
372
+ this.moveDownRow();
373
+ }
374
+ else if (this.tagInputType === "dropdown" && this.isExpanded) {
375
+ this.moveDownListItem();
376
+ }
377
+ else if (this.tagInputType === "dropdown") {
378
+ this.openDropdown();
379
+ }
380
+ }
381
+ handleInputArrowUp() {
382
+ if (this.tagInputType === "table") {
383
+ this.moveUpRow();
384
+ }
385
+ else if (this.tagInputType === "dropdown" && this.isExpanded) {
386
+ this.moveUpListItem();
387
+ }
388
+ else if (this.tagInputType === "dropdown") {
389
+ this.openDropdown();
390
+ }
391
+ }
392
+ handleInputBackspace() {
393
+ if (this.inputEl.value === "" && this.tagsList.length > 0) {
394
+ // wait for events to finish firing before redirecting focus
395
+ // prevents double input in input area and tag area
396
+ window.requestAnimationFrame(() => {
397
+ if (this.nonLockedTagsList.length > 0) {
398
+ this.tagAreaEl.focus();
399
+ this.focusTag(this.tagEls[this.tagEls.length - 1]);
400
+ }
401
+ });
402
+ }
403
+ }
404
+ handleListItemKeyDown(ev) {
405
+ const typedEvTarget = ev.target;
406
+ switch (ev.key) {
407
+ case "Enter":
408
+ case " ":
409
+ ev.preventDefault();
410
+ typedEvTarget.click();
411
+ break;
412
+ case "ArrowDown":
413
+ ev.preventDefault();
414
+ this.moveDownListItem();
415
+ break;
416
+ case "ArrowUp":
417
+ ev.preventDefault();
418
+ this.moveUpListItem();
419
+ break;
420
+ case "Escape":
421
+ if (this.focusedElement !== this.inputEl) {
422
+ this.inputEl.focus();
423
+ }
424
+ else if (this.tagInputType === "dropdown") {
425
+ this.closeDropdown();
426
+ }
427
+ break;
428
+ }
429
+ }
430
+ handleListItemClick(item) {
431
+ const tag = item.dataset.option.trim() || "";
432
+ if (this.includesCaseInsensitive(this.tagsList, tag)) {
433
+ this.announce(this.generateTagAlreadyAddedMessage(tag));
434
+ }
435
+ else {
436
+ this.resetInput();
437
+ this.addTag(tag);
438
+ this.optionsList = this.addOption(tag);
439
+ this.focusedListItem = null;
440
+ }
441
+ }
442
+ handleTableRowClick(rowId) {
443
+ const referencedRow = this.el.querySelector(`#${rowId}`);
444
+ const isLocked = referencedRow.locked;
445
+ if (!isLocked) {
446
+ if (this.includesCaseInsensitive(this.tagsList, rowId)) {
447
+ this.removeTag(rowId);
448
+ }
449
+ else if (!this.tagLimitReached) {
450
+ this.addTag(rowId);
451
+ this.resetInput();
452
+ }
453
+ }
454
+ }
455
+ handleTagAreaKeyDown(ev) {
456
+ switch (ev.key) {
457
+ case "ArrowLeft":
458
+ case "ArrowUp":
459
+ ev.preventDefault();
460
+ this.moveLeftTag();
461
+ break;
462
+ case "ArrowRight":
463
+ case "ArrowDown":
464
+ ev.preventDefault();
465
+ this.moveRightTag();
466
+ break;
467
+ case "Backspace":
468
+ case "Delete":
469
+ this.handleTagAreaDelete();
470
+ break;
471
+ }
472
+ }
473
+ handleTagAreaDelete() {
474
+ const isLocked = this.focusedTag && this.focusedTag.classList.contains("locked");
475
+ if (this.focusedTag && !isLocked) {
476
+ this.removeTag(this.focusedTag.dataset.tag);
477
+ if (this.nonLockedTagsList.length === 0) {
478
+ // focus input if no tags are left
479
+ this.inputEl.focus();
480
+ }
481
+ else {
482
+ const removingLastTag = this.focusedTag === this.tagEls[this.tagEls.length - 1];
483
+ // if removing the last tag, reassign focused tag to previous task
484
+ this.focusedTag = removingLastTag ? this.tagEls[this.tagEls.length - 2] : this.focusedTag;
485
+ this.focusTag(this.focusedTag);
486
+ }
487
+ }
488
+ }
489
+ handleBlur(ev, component) {
490
+ const isntElOrChild = ev.relatedTarget !== component && !this.el.shadowRoot.contains(ev.relatedTarget);
491
+ this.dismissTooltip();
492
+ this.clearCellFocus();
493
+ if (isntElOrChild) {
494
+ this.fieldWrapperEl.classList.remove("focused");
495
+ if (this.tagInputType === "dropdown") {
496
+ this.closeDropdown();
497
+ }
498
+ }
499
+ }
500
+ handleCellMouseEnter(ev) {
501
+ const cell = ev.target;
502
+ const contentWrapper = cell.querySelector(".cell-content-wrapper");
503
+ const isTruncated = contentWrapper.scrollWidth > contentWrapper.clientWidth;
504
+ if (isTruncated) {
505
+ // innerText is necessary vs textContent, as innerText ignores sr-only / display: none text
506
+ functions.showTooltip("bottom", cell, cell.innerText);
507
+ }
508
+ }
509
+ handleTagAreaFocus() {
510
+ if (this.tagInputType === "dropdown") {
511
+ this.closeDropdown();
512
+ }
513
+ const firstFocusableTag = this.nonLockedTagEls[0];
514
+ firstFocusableTag && this.focusTag(firstFocusableTag);
515
+ }
516
+ handleRemoveButtonClick(tag) {
517
+ this.moveLeftTag();
518
+ this.removeTag(tag);
519
+ }
520
+ moveDownListItem() {
521
+ if (this.listItemEls.length > 0) {
522
+ const firstListItem = this.listItemEls[0];
523
+ if (!this.focusedListItem) {
524
+ this.focusListItem(firstListItem);
525
+ }
526
+ else if (this.focusedListItem.nextElementSibling) {
527
+ this.focusListItem(this.focusedListItem.nextElementSibling);
528
+ }
529
+ else {
530
+ this.focusListItem(firstListItem);
531
+ }
532
+ }
533
+ }
534
+ moveUpListItem() {
535
+ if (this.listItemEls.length > 0) {
536
+ const lastListItem = this.listItemEls[this.listItemEls.length - 1];
537
+ if (!this.focusedListItem) {
538
+ this.focusListItem(lastListItem);
539
+ }
540
+ else if (this.focusedListItem.previousElementSibling) {
541
+ this.focusListItem(this.focusedListItem.previousElementSibling);
542
+ }
543
+ else {
544
+ this.clearListItemFocus();
545
+ }
546
+ }
547
+ }
548
+ moveDownRow() {
549
+ if (this.filteredRows.length > 0) {
550
+ if (this.tablePosition.row === 0) {
551
+ this.tablePosition.row = 1;
552
+ }
553
+ else if (this.tablePosition.row === this.filteredRows.length) {
554
+ this.tablePosition.row = 1;
555
+ }
556
+ else {
557
+ this.tablePosition.row++;
558
+ }
559
+ // skip locked rows
560
+ const rowToFocus = this.wmRowEls[this.tablePosition.row - 1];
561
+ if (rowToFocus.locked) {
562
+ this.moveDownRow();
563
+ }
564
+ else {
565
+ this.focusCell(this.tablePosition);
566
+ }
567
+ }
568
+ }
569
+ moveUpRow() {
570
+ if (this.filteredRows.length > 0) {
571
+ if (this.tablePosition.row === 0) {
572
+ this.tablePosition.row = this.filteredRows.length;
573
+ }
574
+ else if (this.tablePosition.row === 1) {
575
+ this.tablePosition.row = 0;
576
+ }
577
+ else {
578
+ this.tablePosition.row--;
579
+ }
580
+ // skip locked rows
581
+ const rowToFocus = this.wmRowEls[this.tablePosition.row - 1];
582
+ if (rowToFocus && rowToFocus.locked) {
583
+ this.moveUpRow();
584
+ }
585
+ else if (rowToFocus) {
586
+ this.focusCell(this.tablePosition);
587
+ }
588
+ else {
589
+ this.clearCellFocus();
590
+ }
591
+ }
592
+ }
593
+ moveLeftCell() {
594
+ if (this.tablePosition.column != 1) {
595
+ this.tablePosition.column--;
596
+ this.focusCell(this.tablePosition);
597
+ }
598
+ }
599
+ moveRightCell() {
600
+ const numCols = functions.csvToArray(this.colHeaders).length;
601
+ if (this.tablePosition.column < numCols) {
602
+ this.tablePosition.column++;
603
+ this.focusCell(this.tablePosition);
604
+ }
605
+ }
606
+ moveLeftTag() {
607
+ const lastTag = this.tagEls[this.tagEls.length - 1];
608
+ if (this.focusedTag && this.tagEls.includes(this.focusedTag.previousElementSibling)) {
609
+ this.focusedTag = this.focusedTag.previousElementSibling;
610
+ }
611
+ else {
612
+ this.focusedTag = lastTag;
613
+ }
614
+ // skip locked tags
615
+ if (this.focusedTag.classList.contains("locked") && this.nonLockedTagEls.length > 0) {
616
+ this.moveLeftTag();
617
+ }
618
+ else {
619
+ this.focusTag(this.focusedTag);
620
+ }
621
+ }
622
+ moveRightTag() {
623
+ const firstTag = this.tagEls[0];
624
+ if (this.focusedTag && this.tagEls.includes(this.focusedTag.nextElementSibling)) {
625
+ this.focusedTag = this.focusedTag.nextElementSibling;
626
+ }
627
+ else {
628
+ this.focusedTag = firstTag;
629
+ }
630
+ // skip locked tags
631
+ if (this.focusedTag.classList.contains("locked")) {
632
+ this.moveRightTag();
633
+ }
634
+ else {
635
+ this.focusTag(this.focusedTag);
636
+ }
637
+ }
638
+ addOption(option) {
639
+ let newOptionsList = this.optionsList;
640
+ const optionAlreadyExists = this.includesCaseInsensitive(this.optionsList, option);
641
+ if (!optionAlreadyExists) {
642
+ newOptionsList = newOptionsList.concat(option);
643
+ }
644
+ return newOptionsList;
645
+ }
646
+ removeOption(option) {
647
+ this.optionsList = this.filterCaseInsensitive(this.optionsList, option);
648
+ }
649
+ addTag(tag) {
650
+ let newTagsList = this.tagsList;
651
+ const tagAlreadyAdded = this.includesCaseInsensitive(this.tagsList, tag);
652
+ const tagExistsAsOption = this.optionsList.filter((x) => x.toLowerCase() === tag.toLowerCase())[0];
653
+ if (!tagAlreadyAdded) {
654
+ let textToAnnounce = tag;
655
+ if (this.tagInputType === "table") {
656
+ const referencedRow = this.el.querySelector(`#${tag}`);
657
+ textToAnnounce = referencedRow.col1;
658
+ }
659
+ this.announce(this.generateTagAddedMessage(textToAnnounce));
660
+ this.tagsList = newTagsList.concat(tagExistsAsOption || tag);
661
+ // if maxTags has been reached, focus should go to the tagArea
662
+ if (this.tagLimitReached) {
663
+ this.tagAreaEl.focus();
664
+ }
665
+ }
666
+ }
667
+ removeTag(tag) {
668
+ let textToAnnounce = tag;
669
+ if (this.tagInputType === "table") {
670
+ const referencedRow = this.el.querySelector(`#${tag}`);
671
+ textToAnnounce = referencedRow.col1;
672
+ }
673
+ const tagRemovedMessage = functions.intl.formatMessage({ id: "tagInput.tagRemoved", defaultMessage: "{tag} removed" }, { tag: textToAnnounce });
674
+ this.announce(tagRemovedMessage);
675
+ this.tagsList = this.filterCaseInsensitive(this.tagsList, tag);
676
+ if (this.tagInputType === "dropdown") {
677
+ // if a tag was introduced by the user, also remove it from the dropdown options
678
+ const devOptionsList = functions.csvToArray(this.options);
679
+ if (this.includesCaseInsensitive(this.optionsList, tag) && !this.includesCaseInsensitive(devOptionsList, tag)) {
680
+ this.removeOption(tag);
681
+ }
682
+ }
683
+ }
684
+ focusListItem(item) {
685
+ this.focusedListItem = item;
686
+ this.inputEl.setAttribute("aria-activedescendant", this.focusedListItem.id);
687
+ item.scrollIntoView({ block: "nearest" });
688
+ }
689
+ focusTag(element) {
690
+ if (element.classList.contains("locked")) {
691
+ this.focusedTag = null;
692
+ this.tagAreaEl.setAttribute("aria-activedescendant", "");
693
+ }
694
+ else {
695
+ this.focusedTag = element;
696
+ this.tagAreaEl.setAttribute("aria-activedescendant", this.focusedTag.id);
697
+ }
698
+ window.requestAnimationFrame(() => {
699
+ functions.hideTooltip();
700
+ const textEl = element.querySelector(".tag-text");
701
+ const fullText = element.dataset.tag;
702
+ const isTruncated = fullText !== textEl.textContent && textEl.textContent.includes("...");
703
+ isTruncated && functions.showTooltip("bottom", element, fullText);
704
+ });
705
+ }
706
+ focusCell(position) {
707
+ this.clearCellFocus(false);
708
+ if (position.row) {
709
+ const rowToFocus = this.localRowEls[position.row];
710
+ const rowCells = rowToFocus.querySelectorAll("td");
711
+ const cellToFocus = rowCells[position.column - 1];
712
+ const contentWrapper = cellToFocus.querySelector(".cell-content-wrapper");
713
+ const isTruncated = contentWrapper.scrollWidth > contentWrapper.clientWidth;
714
+ rowToFocus.classList.add("focused");
715
+ cellToFocus.classList.add("focused");
716
+ cellToFocus.scrollIntoView({ block: "nearest" });
717
+ this.inputEl.setAttribute("aria-activedescendant", cellToFocus.id);
718
+ this.dismissTooltip();
719
+ if (isTruncated) {
720
+ // innerText is necessary vs textContent, as innerText ignores sr-only / display: none text
721
+ functions.showTooltip("bottom", cellToFocus, cellToFocus.innerText);
722
+ }
723
+ }
724
+ }
725
+ clearTagFocus() {
726
+ this.tagAreaEl.setAttribute("aria-activedescendant", "");
727
+ this.focusedTag = null;
728
+ }
729
+ clearCellFocus(resetPosition = true) {
730
+ this.inputEl.setAttribute("aria-activedescendant", "");
731
+ if (resetPosition) {
732
+ this.tablePosition = { row: 0, column: 1 };
733
+ }
734
+ this.localRowEls.forEach((row) => {
735
+ row.classList.remove("focused");
736
+ row.querySelectorAll("td").forEach((cell) => {
737
+ cell.classList.remove("focused");
738
+ });
739
+ });
740
+ }
741
+ openDropdown() {
742
+ // given an offset of -2px because the dropdown is transformed downwards to avoid overlapping the focus border
743
+ this.openUp = functions.shouldOpenUp(this.el, this.dropdownEl, this.el.clientHeight, -2);
744
+ this.isExpanded = true;
745
+ }
746
+ closeDropdown() {
747
+ this.clearListItemFocus();
748
+ this.isExpanded = false;
749
+ }
750
+ clearListItemFocus() {
751
+ this.focusedListItem = null;
752
+ this.inputEl.setAttribute("aria-activedescendant", "");
753
+ this.listItemEls.forEach((el) => {
754
+ el.classList.remove("focused");
755
+ });
756
+ }
757
+ resetInput() {
758
+ this.charCount = 0;
759
+ this.inputEl.value = "";
760
+ }
761
+ announce(message) {
762
+ // \u00A0 is a non-breaking space character, which causes the message to be read as a new one
763
+ if (this.liveRegionEl.textContent === message) {
764
+ message += "\u00A0";
765
+ }
766
+ this.liveRegionMessage = message;
767
+ }
768
+ announceExistingOptions() {
769
+ // request animation frame to wait for re-rendering of filtered options
770
+ window.requestAnimationFrame(() => {
771
+ let numResults = 0;
772
+ if (this.tagInputType === "dropdown") {
773
+ numResults = this.optionEls.length;
774
+ }
775
+ else if (this.tagInputType === "table") {
776
+ numResults = this.filteredRows.length;
777
+ }
778
+ const existingOptionsMessage = functions.intl.formatMessage({
779
+ id: "tagInput.existingOptions",
780
+ defaultMessage: "{num, plural, one {1 existing option.} other {# existing options.}}",
781
+ }, { num: numResults });
782
+ this.announce(existingOptionsMessage);
783
+ });
784
+ }
785
+ generateCharacterLimitWarning(charCount, charLimit) {
786
+ let message = intl.globalMessages.getCharactersEntered(charCount, charLimit);
787
+ if (charCount >= charLimit) {
788
+ message += ` ${intl.globalMessages.characterLimitReached}`;
789
+ }
790
+ return message;
791
+ }
792
+ positionInput() {
793
+ const lastTag = this.tagEls[this.tagEls.length - 1];
794
+ // default placement to fall back to when no tags are present, or not enough space is available
795
+ this.inputEl.style.position = "static";
796
+ this.inputEl.style.width = "100%";
797
+ if (lastTag) {
798
+ const spaceAvailable = this.tagAreaEl.getBoundingClientRect().right - lastTag.getBoundingClientRect().right;
799
+ if (spaceAvailable >= this.inputMinimumWidth) {
800
+ // because the input has right: 0px
801
+ // all thats needed to properly place it is setting position: absolute, top, and width
802
+ this.inputEl.style.position = "absolute";
803
+ this.inputEl.style.top = lastTag.offsetTop.toString() + "px";
804
+ this.inputEl.style.width =
805
+ (this.tagAreaEl.getBoundingClientRect().right - lastTag.getBoundingClientRect().right - 8).toString() + "px";
806
+ }
807
+ }
808
+ }
809
+ handleTagMouseEnter(ev) {
810
+ const displayedText = ev.target.querySelector(".tag-text").textContent;
811
+ const fullText = ev.target.dataset.tag;
812
+ const isTruncated = displayedText !== fullText && displayedText.includes("...");
813
+ isTruncated && functions.showTooltip("bottom", ev.target, fullText);
814
+ }
815
+ /// Helpers
816
+ listToCSV(list) {
817
+ return list.join(",");
818
+ }
819
+ includesCaseInsensitive(list, element) {
820
+ const lowercaseList = list.map((str) => str.toLowerCase());
821
+ return lowercaseList.includes(element.toLowerCase());
822
+ }
823
+ filterCaseInsensitive(list, element) {
824
+ return list.filter((x) => x.toLowerCase() !== element.toLowerCase());
825
+ }
826
+ sortCaseInsensitive(list) {
827
+ // The vanilla .sort method places words that start with capital letters above others (ASCII order)
828
+ // so we need to pass in our own compare function to sort case-insensitive
829
+ return list.sort((a, b) => {
830
+ a = a.toLowerCase();
831
+ b = b.toLowerCase();
832
+ return a > b ? 1 : a < b ? -1 : 0;
833
+ });
834
+ }
835
+ /// Renders
836
+ renderTags() {
837
+ let lockedTags = [];
838
+ let unlockedTags = [];
839
+ this.tagsList.forEach((tag, idx) => {
840
+ const id = `tag${idx + 1}`;
841
+ let tagText = "";
842
+ let isLocked = false;
843
+ if (this.tagInputType === "dropdown") {
844
+ tagText = tag;
845
+ }
846
+ else if (this.tagInputType === "table") {
847
+ // display table tags using col1 of the row with the same id
848
+ // if one can't be found, display as empty
849
+ const referencedRow = this.el.querySelector(`#${tag}`);
850
+ tagText = referencedRow ? referencedRow.col1 : "";
851
+ isLocked = referencedRow ? referencedRow.locked : false;
852
+ }
853
+ // make sure locked tags always appear in front of list
854
+ const targetList = isLocked ? lockedTags : unlockedTags;
855
+ targetList.push(index.h("li", { id: id, class: `tag highlight ${this.focusedTag && this.focusedTag.id === id ? "focused" : ""} ${isLocked ? "locked" : ""}`, "data-tag": tag, role: "option", onMouseEnter: (ev) => this.handleTagMouseEnter(ev), onMouseLeave: functions.hideTooltip }, index.h("span", { class: "sr-only" }, tag), index.h("span", { class: "tag-text", "aria-hidden": "true" }, tagText), isLocked ? (index.h("div", { class: "icon lock" })) : (index.h("button", { class: "icon remove-btn", tabIndex: -1, onClick: () => this.handleRemoveButtonClick(tag) }))));
856
+ });
857
+ return [...lockedTags, ...unlockedTags];
858
+ }
859
+ renderDropdown() {
860
+ return (index.h("div", { class: `dropdown-wrapper ${this.isExpanded ? "open" : ""} ${this.openUp ? "upwards" : ""}`, ref: (el) => (this.dropdownEl = el) }, index.h("div", { id: "help-text", class: "help-text" }, this.renderHelpText()), index.h("ul", { class: "dropdown", id: "dropdown", role: "listbox", "aria-multiselectable": "true", "aria-expanded": this.isExpanded ? "true" : false, "aria-label": this.label, tabindex: -1 }, this.inputEl && this.renderAddNewButton(), this.renderListItems(this.optionsList))));
861
+ }
862
+ renderListItems(optionsList) {
863
+ optionsList = this.sortCaseInsensitive(optionsList);
864
+ // filter by input
865
+ if (this.inputEl && this.inputEl.value) {
866
+ optionsList = this.optionsList.filter((option) => option.toLowerCase().includes(this.inputEl.value.toLowerCase()));
867
+ }
868
+ return optionsList.map((option, idx) => {
869
+ const id = `option${idx + 1}`;
870
+ const isFocused = this.focusedListItem && this.focusedListItem.id === id;
871
+ const isSelected = this.includesCaseInsensitive(this.tagsList, option);
872
+ return (index.h("li", { class: `option ${isFocused ? "focused" : ""}`, role: "option", id: id, "data-option": option, "aria-selected": isSelected ? "true" : "false", "aria-disabled": isSelected ? "true" : "false", onKeyDown: (ev) => this.handleListItemKeyDown(ev), onBlur: (ev) => this.handleBlur(ev, this.el), onClick: (ev) => this.handleListItemClick(ev.target) }, option));
873
+ });
874
+ }
875
+ renderAddNewButton() {
876
+ const hasNonWhiteSpaceCharacters = this.inputEl.value.match(/\S/);
877
+ const optionAlreadyExists = this.includesCaseInsensitive(this.optionsList, this.inputEl.value.trim());
878
+ if (this.addNew && hasNonWhiteSpaceCharacters && !optionAlreadyExists) {
879
+ const id = `add-new-btn`;
880
+ const isFocused = this.focusedListItem && this.focusedListItem.id === id;
881
+ return (index.h("li", { role: "option", class: `add-new-btn ${isFocused ? "focused" : ""}`, id: id, "data-option": this.inputEl.value, onKeyDown: (ev) => this.handleListItemKeyDown(ev), onBlur: (ev) => this.handleBlur(ev, this.el), onClick: (ev) => this.handleListItemClick(ev.target), tabIndex: isFocused ? 0 : -1 }, `Add "${this.inputEl.value.trim()}"`));
882
+ }
883
+ else
884
+ return "";
885
+ }
886
+ renderHelpText() {
887
+ let helpText = "";
888
+ if (this.optionsList.length > 0) {
889
+ helpText += this.componentMessages.selectionHelpText;
890
+ }
891
+ if (this.addNew) {
892
+ helpText += " " + this.componentMessages.addNewHelpText;
893
+ }
894
+ return helpText;
895
+ }
896
+ renderTagCounter() {
897
+ if (this.maxTags) {
898
+ return (index.h("div", { class: "lower-row" }, index.h("div", { id: "max-tags" }, `${this.componentMessages.tagsAdded}: ${this.tagsList.length}/${this.maxTags}`, this.tagLimitReached && ` - ${this.componentMessages.maxTagsReached}`)));
899
+ }
900
+ }
901
+ renderTable() {
902
+ return (index.h("div", { class: "table-wrapper", onScroll: () => this.dismissTooltip() }, index.h("table", { id: "table", role: "grid", class: `${this.colWidths ? "fixed-widths" : ""}`, "aria-label": this.label, "aria-multiselectable": "true" }, this.renderTableHeaders(), this.filteredRows.length ? this.renderTableRows() : index.h("div", { class: "no-results" }, this.noResultsMessage))));
903
+ }
904
+ renderTableHeaders() {
905
+ return (index.h("tr", { class: "headers", role: "row" }, functions.csvToArray(this.colHeaders).map((header, idx) => {
906
+ let overflowRule = "wrap";
907
+ if (this.colWrap && functions.csvToArray(this.colWrap)[idx]) {
908
+ overflowRule = functions.csvToArray(this.colWrap)[idx];
909
+ }
910
+ return (index.h("th", { class: `header-cell ${overflowRule}`, role: "columnheader",
911
+ // @ts-ignore
912
+ width: this.colWidths ? functions.csvToArray(this.colWidths)[idx] : "" }, header));
913
+ })));
914
+ }
915
+ renderTableRows() {
916
+ return this.filteredRows.map((row) => {
917
+ const isSelected = this.includesCaseInsensitive(this.tagsList, row.id);
918
+ return (index.h("tr", { id: row.id, class: `${row.locked ? "locked" : ""} ${isSelected ? "selected" : ""}`, role: "row", onClick: () => this.handleTableRowClick(row.id) }, this.renderTableCells(row)));
919
+ });
920
+ }
921
+ renderTableCells(row) {
922
+ const colValues = [row.col1, row.col2, row.col3, row.col4].filter((val) => !!val);
923
+ const isSelected = this.includesCaseInsensitive(this.tagsList, row.id);
924
+ return colValues.map((val, idx) => {
925
+ const localId = `${row.id}-col${idx + 1}`;
926
+ let overflowRule = "wrap";
927
+ if (this.colWrap && functions.csvToArray(this.colWrap)[idx]) {
928
+ overflowRule = functions.csvToArray(this.colWrap)[idx];
929
+ }
930
+ return (index.h("td", { id: localId, role: "gridcell", "aria-describedby": `${localId}-description`, "aria-selected": isSelected.toString(), onMouseEnter: (ev) => this.handleCellMouseEnter(ev), onMouseLeave: () => this.dismissTooltip() }, index.h("div", { class: `cell-content-wrapper ${overflowRule}` }, val), index.h("div", { class: "description", id: `${localId}-description` }, row.locked ? "locked" : "")));
931
+ });
932
+ }
933
+ render() {
934
+ return (index.h(index.Host, { id: this.uid }, index.h("div", { class: `wrapper label-${this.labelPosition} ${this.errorMessage ? "invalid" : ""}` }, index.h("div", { class: "label-wrapper" }, index.h("label", { class: "label", htmlFor: `input${this.uid}` }, this.label, this.requiredField && (index.h("span", { class: "required", "aria-hidden": "true" }, "*")))), index.h("div", { class: `field-wrapper ${this.focusedElement ? "focused" : ""} ${this.errorMessage ? "invalid" : ""}`, ref: (el) => (this.fieldWrapperEl = el) }, index.h("div", { class: "upper-row" }, index.h("div", { class: "tags-and-input-wrapper" }, this.tagsList.length > 0 && (index.h("ul", { ref: (el) => (this.tagAreaEl = el), class: "tag-area", role: "listbox", "aria-activedescendant": "", "aria-orientation": "horizontal", "aria-label": `${this.label} ${this.tagsList.length > 0 ? this.componentMessages.tagAreaInstructions : ""}`, tabindex: this.nonLockedTagsList.length > 0 ? 0 : -1, "aria-describedby": `info max-tags`, onFocus: () => this.handleTagAreaFocus(), onBlur: (ev) => {
935
+ this.clearTagFocus();
936
+ this.handleBlur(ev, this.el);
937
+ }, onKeyDown: (ev) => this.handleTagAreaKeyDown(ev) }, this.renderTags())), index.h("input", { id: `input${this.uid}`, class: this.tagLimitReached ? "hidden" : "", role: "combobox", ref: (el) => (this.inputEl = el), autocomplete: "off", "aria-required": this.requiredField ? "true" : null, "aria-controls": this.tagInputType, "aria-describedby": `help-text${this.errorMessage ? " error " : ""}`, "aria-label": `${this.label} ${this.tagInputType === "dropdown" ? intl.globalMessages.getCharacterLimit(this.characterLimit) : ""}`, "aria-expanded": this.tagInputType === "dropdown" ? this.isExpanded.toString() : null, placeholder: this.placeholder, maxLength: this.tagInputType === "dropdown" ? this.characterLimit : undefined, onInput: () => this.handleInputChanged(this.inputEl.value), onBlur: (ev) => {
938
+ this.handleBlur(ev, this.el);
939
+ }, onFocus: () => this.handleInputFocus(), onKeyDown: (ev) => this.handleInputKeyDown(ev) })), this.tagInputType === "dropdown" && (index.h("div", { class: "character-count" }, this.charCount, "/", this.characterLimit))), this.renderTagCounter(), this.tagInputType === "dropdown" && this.renderDropdown()), this.info && (index.h("div", { id: "info", class: "info-text" }, this.info)), this.errorMessage && index.h("div", { id: "error" }, this.errorMessage), index.h("div", { class: "sr-only", "aria-live": "assertive", ref: (el) => (this.liveRegionEl = el), "aria-atomic": "true" }, this.liveRegionMessage), this.tagInputType === "table" && this.renderTable())));
940
+ }
941
+ static get delegatesFocus() { return true; }
942
+ get el() { return index.getElement(this); }
943
+ static get watchers() { return {
944
+ "tagsList": ["reflectSelectedTags"],
945
+ "errorMessage": ["handleErrorMessageChange"]
946
+ }; }
947
+ };
948
948
  TagInput.style = wmTagInputCss;
949
949
 
950
950
  exports.wm_tag_input = TagInput;