@watermarkinsights/ripple 3.26.0-9 → 3.26.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (278) hide show
  1. package/README.md +3 -3
  2. package/dist/cjs/{chartFunctions-d746b939.js → chartFunctions-b7452189.js} +596 -596
  3. package/dist/cjs/{functions-68f637b4.js → functions-a047a8ea.js} +503 -503
  4. package/dist/cjs/{global-0f60d748.js → global-21ae6c78.js} +72 -72
  5. package/dist/cjs/{http-service-9e8c4dd5.js → http-service-494d81de.js} +49 -49
  6. package/dist/cjs/{interfaces-30a74c1f.js → interfaces-a3338581.js} +29 -29
  7. package/dist/cjs/{intl-d9ffc76c.js → intl-47d63c8f.js} +131 -131
  8. package/dist/cjs/loader.cjs.js +1 -1
  9. package/dist/cjs/priv-chart-popover.cjs.entry.js +91 -91
  10. package/dist/cjs/priv-datepicker.cjs.entry.js +657 -657
  11. package/dist/cjs/priv-navigator-button.cjs.entry.js +19 -19
  12. package/dist/cjs/priv-navigator-item.cjs.entry.js +23 -23
  13. package/dist/cjs/ripple.cjs.js +1 -1
  14. package/dist/cjs/wm-action-menu_2.cjs.entry.js +334 -334
  15. package/dist/cjs/wm-button.cjs.entry.js +260 -260
  16. package/dist/cjs/wm-chart-slice.cjs.entry.js +18 -18
  17. package/dist/cjs/wm-chart.cjs.entry.js +183 -183
  18. package/dist/cjs/wm-datepicker.cjs.entry.js +263 -263
  19. package/dist/cjs/wm-file-list.cjs.entry.js +35 -35
  20. package/dist/cjs/wm-file.cjs.entry.js +181 -181
  21. package/dist/cjs/wm-input.cjs.entry.js +137 -137
  22. package/dist/cjs/wm-modal-footer.cjs.entry.js +33 -33
  23. package/dist/cjs/wm-modal-header.cjs.entry.js +32 -32
  24. package/dist/cjs/wm-modal.cjs.entry.js +152 -152
  25. package/dist/cjs/wm-navigation_3.cjs.entry.js +225 -225
  26. package/dist/cjs/wm-navigator.cjs.entry.js +264 -264
  27. package/dist/cjs/wm-network-uploader.cjs.entry.js +465 -465
  28. package/dist/cjs/wm-option_2.cjs.entry.js +768 -768
  29. package/dist/cjs/wm-pagination.cjs.entry.js +179 -179
  30. package/dist/cjs/wm-progress-indicator_3.cjs.entry.js +155 -155
  31. package/dist/cjs/wm-search.cjs.entry.js +184 -184
  32. package/dist/cjs/wm-snackbar.cjs.entry.js +155 -155
  33. package/dist/cjs/wm-tab-item_3.cjs.entry.js +264 -264
  34. package/dist/cjs/wm-tag-input-row.cjs.entry.js +14 -14
  35. package/dist/cjs/wm-tag-input.cjs.entry.js +939 -939
  36. package/dist/cjs/wm-timepicker.cjs.entry.js +385 -385
  37. package/dist/cjs/wm-toggletip.cjs.entry.js +130 -130
  38. package/dist/cjs/wm-uploader.cjs.entry.js +441 -441
  39. package/dist/cjs/wm-wrapper.cjs.entry.js +12 -12
  40. package/dist/collection/components/charts/chartFunctions.js +562 -562
  41. package/dist/collection/components/charts/priv-chart-popover/priv-chart-popover.js +267 -267
  42. package/dist/collection/components/charts/wm-chart/wm-chart-slice.js +125 -125
  43. package/dist/collection/components/charts/wm-chart/wm-chart.js +450 -450
  44. package/dist/collection/components/charts/wm-progress-monitor/wm-progress-indicator.js +207 -207
  45. package/dist/collection/components/charts/wm-progress-monitor/wm-progress-monitor.js +143 -143
  46. package/dist/collection/components/charts/wm-progress-monitor/wm-progress-slice.js +121 -121
  47. package/dist/collection/components/wm-action-menu/wm-action-menu.js +472 -472
  48. package/dist/collection/components/wm-button/wm-button.js +575 -575
  49. package/dist/collection/components/wm-datepicker/priv-datepicker/priv-datepicker.js +983 -983
  50. package/dist/collection/components/wm-datepicker/wm-datepicker.js +491 -491
  51. package/dist/collection/components/wm-file/wm-file.js +313 -313
  52. package/dist/collection/components/wm-file-list/wm-file-list.js +152 -152
  53. package/dist/collection/components/wm-input/wm-input.css +5 -1
  54. package/dist/collection/components/wm-input/wm-input.js +509 -509
  55. package/dist/collection/components/wm-menuitem/wm-menuitem.js +454 -454
  56. package/dist/collection/components/wm-modal/wm-modal-footer.js +138 -138
  57. package/dist/collection/components/wm-modal/wm-modal-header.js +82 -82
  58. package/dist/collection/components/wm-modal/wm-modal.js +462 -462
  59. package/dist/collection/components/wm-navigation/wm-navigation-hamburger.js +176 -176
  60. package/dist/collection/components/wm-navigation/wm-navigation-item.js +130 -130
  61. package/dist/collection/components/wm-navigation/wm-navigation.js +217 -217
  62. package/dist/collection/components/wm-navigator/priv-navigator-button/priv-navigator-button.js +106 -106
  63. package/dist/collection/components/wm-navigator/priv-navigator-item/priv-navigator-item.js +123 -123
  64. package/dist/collection/components/wm-navigator/wm-navigator.js +467 -467
  65. package/dist/collection/components/wm-option/wm-option.js +435 -435
  66. package/dist/collection/components/wm-pagination/wm-pagination.js +370 -370
  67. package/dist/collection/components/wm-search/wm-search.js +439 -439
  68. package/dist/collection/components/wm-select/wm-select.js +1054 -1054
  69. package/dist/collection/components/wm-snackbar/wm-snackbar.js +282 -282
  70. package/dist/collection/components/wm-tabs/wm-tab-item/wm-tab-item.js +211 -211
  71. package/dist/collection/components/wm-tabs/wm-tab-list/wm-tab-list.js +327 -327
  72. package/dist/collection/components/wm-tabs/wm-tab-panel/wm-tab-panel.js +108 -108
  73. package/dist/collection/components/wm-tag-input/wm-tag-input-row/wm-tag-input-row.js +122 -122
  74. package/dist/collection/components/wm-tag-input/wm-tag-input.js +1294 -1294
  75. package/dist/collection/components/wm-timepicker/wm-timepicker.js +605 -605
  76. package/dist/collection/components/wm-toggletip/wm-toggletip.js +253 -253
  77. package/dist/collection/components/wm-uploader/wm-network-uploader/wm-network-uploader.js +772 -772
  78. package/dist/collection/components/wm-uploader/wm-uploader.js +964 -964
  79. package/dist/collection/components/wm-wrapper/wm-wrapper.js +28 -28
  80. package/dist/collection/dev/scripts.js +20 -20
  81. package/dist/collection/global/__mocks__/functions.js +6 -6
  82. package/dist/collection/global/functions.js +546 -546
  83. package/dist/collection/global/global.js +79 -79
  84. package/dist/collection/global/interfaces.js +49 -49
  85. package/dist/collection/global/intl.js +132 -132
  86. package/dist/collection/global/services/__mocks__/http-service.js +130 -130
  87. package/dist/collection/global/services/http-service.js +50 -50
  88. package/dist/collection/lang/lang.js +5 -5
  89. package/dist/collection/lang/missing.js +43 -43
  90. package/dist/collection/lang/piglatin.js +93 -93
  91. package/dist/esm/{chartFunctions-5c1ad085.js → chartFunctions-9d629e09.js} +596 -596
  92. package/dist/esm/{functions-b2582352.js → functions-3b813e0c.js} +503 -503
  93. package/dist/esm/{global-86bf0ca6.js → global-c7bb5530.js} +72 -72
  94. package/dist/esm/{http-service-5d037e16.js → http-service-3dc3b3e7.js} +49 -49
  95. package/dist/esm/{interfaces-61c6305b.js → interfaces-2b97fab2.js} +29 -29
  96. package/dist/esm/{intl-6732dd5b.js → intl-d544f922.js} +131 -131
  97. package/dist/esm/loader.js +1 -1
  98. package/dist/esm/polyfills/core-js.js +0 -0
  99. package/dist/esm/polyfills/dom.js +0 -0
  100. package/dist/esm/polyfills/es5-html-element.js +0 -0
  101. package/dist/esm/polyfills/index.js +0 -0
  102. package/dist/esm/polyfills/system.js +0 -0
  103. package/dist/esm/priv-chart-popover.entry.js +91 -91
  104. package/dist/esm/priv-datepicker.entry.js +657 -657
  105. package/dist/esm/priv-navigator-button.entry.js +19 -19
  106. package/dist/esm/priv-navigator-item.entry.js +23 -23
  107. package/dist/esm/ripple.js +1 -1
  108. package/dist/esm/wm-action-menu_2.entry.js +334 -334
  109. package/dist/esm/wm-button.entry.js +260 -260
  110. package/dist/esm/wm-chart-slice.entry.js +18 -18
  111. package/dist/esm/wm-chart.entry.js +183 -183
  112. package/dist/esm/wm-datepicker.entry.js +263 -263
  113. package/dist/esm/wm-file-list.entry.js +35 -35
  114. package/dist/esm/wm-file.entry.js +181 -181
  115. package/dist/esm/wm-input.entry.js +137 -137
  116. package/dist/esm/wm-modal-footer.entry.js +33 -33
  117. package/dist/esm/wm-modal-header.entry.js +32 -32
  118. package/dist/esm/wm-modal.entry.js +152 -152
  119. package/dist/esm/wm-navigation_3.entry.js +225 -225
  120. package/dist/esm/wm-navigator.entry.js +264 -264
  121. package/dist/esm/wm-network-uploader.entry.js +465 -465
  122. package/dist/esm/wm-option_2.entry.js +768 -768
  123. package/dist/esm/wm-pagination.entry.js +179 -179
  124. package/dist/esm/wm-progress-indicator_3.entry.js +155 -155
  125. package/dist/esm/wm-search.entry.js +184 -184
  126. package/dist/esm/wm-snackbar.entry.js +155 -155
  127. package/dist/esm/wm-tab-item_3.entry.js +264 -264
  128. package/dist/esm/wm-tag-input-row.entry.js +14 -14
  129. package/dist/esm/wm-tag-input.entry.js +939 -939
  130. package/dist/esm/wm-timepicker.entry.js +385 -385
  131. package/dist/esm/wm-toggletip.entry.js +130 -130
  132. package/dist/esm/wm-uploader.entry.js +441 -441
  133. package/dist/esm/wm-wrapper.entry.js +12 -12
  134. package/dist/esm-es5/{chartFunctions-5c1ad085.js → chartFunctions-9d629e09.js} +1 -1
  135. package/dist/esm-es5/global-c7bb5530.js +1 -0
  136. package/dist/esm-es5/{intl-6732dd5b.js → intl-d544f922.js} +1 -1
  137. package/dist/esm-es5/loader.js +1 -1
  138. package/dist/esm-es5/priv-chart-popover.entry.js +1 -1
  139. package/dist/esm-es5/priv-datepicker.entry.js +1 -1
  140. package/dist/esm-es5/ripple.js +1 -1
  141. package/dist/esm-es5/wm-action-menu_2.entry.js +1 -1
  142. package/dist/esm-es5/wm-button.entry.js +1 -1
  143. package/dist/esm-es5/wm-chart.entry.js +1 -1
  144. package/dist/esm-es5/wm-datepicker.entry.js +1 -1
  145. package/dist/esm-es5/wm-file.entry.js +1 -1
  146. package/dist/esm-es5/wm-input.entry.js +1 -1
  147. package/dist/esm-es5/wm-modal-header.entry.js +1 -1
  148. package/dist/esm-es5/wm-modal.entry.js +1 -1
  149. package/dist/esm-es5/wm-navigation_3.entry.js +1 -1
  150. package/dist/esm-es5/wm-navigator.entry.js +1 -1
  151. package/dist/esm-es5/wm-network-uploader.entry.js +1 -1
  152. package/dist/esm-es5/wm-option_2.entry.js +1 -1
  153. package/dist/esm-es5/wm-pagination.entry.js +1 -1
  154. package/dist/esm-es5/wm-progress-indicator_3.entry.js +1 -1
  155. package/dist/esm-es5/wm-search.entry.js +1 -1
  156. package/dist/esm-es5/wm-snackbar.entry.js +1 -1
  157. package/dist/esm-es5/wm-tab-item_3.entry.js +1 -1
  158. package/dist/esm-es5/wm-tag-input.entry.js +1 -1
  159. package/dist/esm-es5/wm-timepicker.entry.js +1 -1
  160. package/dist/esm-es5/wm-toggletip.entry.js +1 -1
  161. package/dist/esm-es5/wm-uploader.entry.js +1 -1
  162. package/dist/ripple/{p-d5a420fa.entry.js → p-05563588.entry.js} +1 -1
  163. package/dist/ripple/{p-061914bf.system.entry.js → p-09a04f55.system.entry.js} +1 -1
  164. package/dist/ripple/{p-a2f10a77.entry.js → p-09bc0aa7.entry.js} +1 -1
  165. package/dist/ripple/{p-0414179c.entry.js → p-0cfc0d13.entry.js} +1 -1
  166. package/dist/ripple/{p-a9080b82.entry.js → p-0ef638b7.entry.js} +1 -1
  167. package/dist/ripple/{p-f740c48c.system.entry.js → p-12c70659.system.entry.js} +1 -1
  168. package/dist/ripple/p-169606b9.system.js +1 -0
  169. package/dist/ripple/{p-7ee31208.js → p-18c2f4fe.js} +1 -1
  170. package/dist/ripple/{p-462e7cf8.system.entry.js → p-236dab05.system.entry.js} +1 -1
  171. package/dist/ripple/{p-9baf62ae.entry.js → p-2cd5477a.entry.js} +1 -1
  172. package/dist/ripple/{p-2cef256c.system.entry.js → p-2cde4ade.system.entry.js} +1 -1
  173. package/dist/ripple/{p-076a8729.entry.js → p-2d46dbea.entry.js} +1 -1
  174. package/dist/ripple/{p-3313df40.system.entry.js → p-2dd5f5c3.system.entry.js} +1 -1
  175. package/dist/ripple/{p-64b64f40.system.entry.js → p-35790e4e.system.entry.js} +1 -1
  176. package/dist/ripple/{p-4e7489a3.system.entry.js → p-38819b27.system.entry.js} +1 -1
  177. package/dist/ripple/{p-926aab51.entry.js → p-3aa8e5f5.entry.js} +1 -1
  178. package/dist/ripple/{p-42739dba.entry.js → p-42f8f3ff.entry.js} +1 -1
  179. package/dist/ripple/{p-c1d814f8.system.entry.js → p-4444add0.system.entry.js} +1 -1
  180. package/dist/ripple/{p-0648aa61.system.entry.js → p-4f5a48dd.system.entry.js} +1 -1
  181. package/dist/ripple/{p-2948bf33.system.entry.js → p-4fb81a33.system.entry.js} +1 -1
  182. package/dist/ripple/{p-22b74491.entry.js → p-51b38033.entry.js} +1 -1
  183. package/dist/ripple/{p-9706537b.system.js → p-54a2b7d6.system.js} +1 -1
  184. package/dist/ripple/{p-00edfbc8.system.entry.js → p-56ba575c.system.entry.js} +1 -1
  185. package/dist/ripple/{p-b7f204e6.entry.js → p-5708349e.entry.js} +1 -1
  186. package/dist/ripple/{p-7dafc84b.system.entry.js → p-630bd6f5.system.entry.js} +1 -1
  187. package/dist/ripple/{p-b7982fab.system.js → p-6eb2c2d5.system.js} +1 -1
  188. package/dist/ripple/{p-a966a18c.entry.js → p-72b9b986.entry.js} +1 -1
  189. package/dist/ripple/p-76015762.js +1 -0
  190. package/dist/ripple/{p-3aaf86e4.entry.js → p-7f15df83.entry.js} +1 -1
  191. package/dist/ripple/{p-5ddb1660.entry.js → p-832910a0.entry.js} +1 -1
  192. package/dist/ripple/{p-66bb46e5.system.entry.js → p-84ce9b67.system.entry.js} +1 -1
  193. package/dist/ripple/{p-e6fde200.system.entry.js → p-8775e10b.system.entry.js} +1 -1
  194. package/dist/ripple/{p-6f96c28d.entry.js → p-8b23f32b.entry.js} +1 -1
  195. package/dist/ripple/{p-17490d32.entry.js → p-8c853762.entry.js} +1 -1
  196. package/dist/ripple/{p-81b26d3a.system.entry.js → p-8ff578ad.system.entry.js} +1 -1
  197. package/dist/ripple/{p-9b9e60aa.system.entry.js → p-95aa793b.system.entry.js} +1 -1
  198. package/dist/ripple/{p-9b28a31f.entry.js → p-95f4e5a1.entry.js} +1 -1
  199. package/dist/ripple/{p-accdf91c.system.entry.js → p-a006968b.system.entry.js} +1 -1
  200. package/dist/ripple/{p-2d33df00.system.js → p-a48e4f1a.system.js} +1 -1
  201. package/dist/ripple/{p-094388f1.entry.js → p-ae1e1db8.entry.js} +1 -1
  202. package/dist/ripple/{p-3b582301.entry.js → p-b3d97de8.entry.js} +1 -1
  203. package/dist/ripple/{p-f8418ac9.entry.js → p-bdecbb63.entry.js} +1 -1
  204. package/dist/ripple/{p-b805612a.system.entry.js → p-c3665c9f.system.entry.js} +1 -1
  205. package/dist/ripple/{p-d7f77b2c.js → p-d96b86c9.js} +1 -1
  206. package/dist/ripple/p-d973fe13.system.entry.js +1 -0
  207. package/dist/ripple/{p-0503e614.system.entry.js → p-ea99fb58.system.entry.js} +1 -1
  208. package/dist/ripple/{p-bd94e7c3.entry.js → p-eeeec290.entry.js} +1 -1
  209. package/dist/ripple/{p-a5662a2c.system.entry.js → p-f2bb38d0.system.entry.js} +1 -1
  210. package/dist/ripple/{p-043b4874.entry.js → p-f6c9c95f.entry.js} +1 -1
  211. package/dist/ripple/{p-731beaab.system.entry.js → p-f6f80b8d.system.entry.js} +1 -1
  212. package/dist/ripple/{p-49f7f1da.entry.js → p-fe76e568.entry.js} +1 -1
  213. package/dist/ripple/{p-60f58a39.system.entry.js → p-fea37751.system.entry.js} +1 -1
  214. package/dist/ripple/{p-5b7e1b5d.entry.js → p-ffb83b6f.entry.js} +1 -1
  215. package/dist/ripple/ripple.esm.js +1 -1
  216. package/dist/ripple/ripple.js +1 -1
  217. package/dist/types/components/charts/chartFunctions.d.ts +37 -37
  218. package/dist/types/components/charts/priv-chart-popover/priv-chart-popover.d.ts +27 -27
  219. package/dist/types/components/charts/wm-chart/wm-chart-slice.d.ts +11 -11
  220. package/dist/types/components/charts/wm-chart/wm-chart.d.ts +47 -47
  221. package/dist/types/components/charts/wm-progress-monitor/wm-progress-indicator.d.ts +29 -29
  222. package/dist/types/components/charts/wm-progress-monitor/wm-progress-monitor.d.ts +20 -20
  223. package/dist/types/components/charts/wm-progress-monitor/wm-progress-slice.d.ts +10 -10
  224. package/dist/types/components/wm-action-menu/wm-action-menu.d.ts +49 -49
  225. package/dist/types/components/wm-button/wm-button.d.ts +49 -49
  226. package/dist/types/components/wm-datepicker/priv-datepicker/priv-datepicker.d.ts +80 -80
  227. package/dist/types/components/wm-datepicker/wm-datepicker.d.ts +42 -42
  228. package/dist/types/components/wm-file/wm-file.d.ts +40 -40
  229. package/dist/types/components/wm-file-list/wm-file-list.d.ts +16 -16
  230. package/dist/types/components/wm-input/wm-input.d.ts +57 -57
  231. package/dist/types/components/wm-menuitem/wm-menuitem.d.ts +34 -34
  232. package/dist/types/components/wm-modal/wm-modal-footer.d.ts +14 -14
  233. package/dist/types/components/wm-modal/wm-modal-header.d.ts +10 -10
  234. package/dist/types/components/wm-modal/wm-modal.d.ts +40 -40
  235. package/dist/types/components/wm-navigation/wm-navigation-hamburger.d.ts +21 -21
  236. package/dist/types/components/wm-navigation/wm-navigation-item.d.ts +13 -13
  237. package/dist/types/components/wm-navigation/wm-navigation.d.ts +26 -26
  238. package/dist/types/components/wm-navigator/priv-navigator-button/priv-navigator-button.d.ts +10 -10
  239. package/dist/types/components/wm-navigator/priv-navigator-item/priv-navigator-item.d.ts +13 -13
  240. package/dist/types/components/wm-navigator/wm-navigator.d.ts +61 -61
  241. package/dist/types/components/wm-option/wm-option.d.ts +34 -34
  242. package/dist/types/components/wm-pagination/wm-pagination.d.ts +32 -32
  243. package/dist/types/components/wm-search/wm-search.d.ts +77 -77
  244. package/dist/types/components/wm-select/wm-select.d.ts +101 -101
  245. package/dist/types/components/wm-snackbar/wm-snackbar.d.ts +31 -31
  246. package/dist/types/components/wm-tabs/wm-tab-item/wm-tab-item.d.ts +37 -37
  247. package/dist/types/components/wm-tabs/wm-tab-list/wm-tab-list.d.ts +52 -52
  248. package/dist/types/components/wm-tabs/wm-tab-panel/wm-tab-panel.d.ts +20 -20
  249. package/dist/types/components/wm-tag-input/wm-tag-input-row/wm-tag-input-row.d.ts +11 -11
  250. package/dist/types/components/wm-tag-input/wm-tag-input.d.ts +136 -136
  251. package/dist/types/components/wm-timepicker/wm-timepicker.d.ts +62 -62
  252. package/dist/types/components/wm-toggletip/wm-toggletip.d.ts +28 -28
  253. package/dist/types/components/wm-uploader/wm-network-uploader/wm-network-uploader.d.ts +85 -85
  254. package/dist/types/components/wm-uploader/wm-uploader.d.ts +99 -99
  255. package/dist/types/components/wm-wrapper/wm-wrapper.d.ts +7 -7
  256. package/dist/types/components.d.ts +27 -27
  257. package/dist/types/global/__mocks__/functions.d.ts +6 -6
  258. package/dist/types/global/functions.d.ts +49 -49
  259. package/dist/types/global/global.d.ts +1 -1
  260. package/dist/types/global/interfaces.d.ts +74 -74
  261. package/dist/types/global/intl.d.ts +29 -29
  262. package/dist/types/global/services/__mocks__/http-service.d.ts +6 -6
  263. package/dist/types/global/services/http-service.d.ts +4 -4
  264. package/dist/types/lang/lang.d.ts +5 -5
  265. package/package.json +46 -46
  266. package/dist/esm-es5/global-86bf0ca6.js +0 -1
  267. package/dist/ripple/p-233c8059.js +0 -1
  268. package/dist/ripple/p-9f9a5a1f.system.js +0 -1
  269. package/dist/ripple/p-e4cef02b.system.entry.js +0 -1
  270. /package/dist/esm-es5/{functions-b2582352.js → functions-3b813e0c.js} +0 -0
  271. /package/dist/esm-es5/{http-service-5d037e16.js → http-service-3dc3b3e7.js} +0 -0
  272. /package/dist/esm-es5/{interfaces-61c6305b.js → interfaces-2b97fab2.js} +0 -0
  273. /package/dist/ripple/{p-9e94ae94.system.js → p-190afa40.system.js} +0 -0
  274. /package/dist/ripple/{p-888bec42.js → p-43f1298b.js} +0 -0
  275. /package/dist/ripple/{p-5384856b.js → p-4a0e1d2d.js} +0 -0
  276. /package/dist/ripple/{p-313b6073.system.js → p-9d02957d.system.js} +0 -0
  277. /package/dist/ripple/{p-08b7ec08.system.js → p-f5df5903.system.js} +0 -0
  278. /package/dist/ripple/{p-a6d6eae7.js → p-fd8070fb.js} +0 -0
@@ -1,1294 +1,1294 @@
1
- import { h, Host, forceUpdate, } from "@stencil/core";
2
- import { csvToArray, debounce, generateId, hideTooltip, intl, measureText, safeParseJSON, shouldOpenUp, showTooltip, truncateText, } from "../../global/functions";
3
- import { globalMessages } from "../../global/intl";
4
- export class TagInput {
5
- constructor() {
6
- this.uid = this.el.id ? this.el.id : generateId();
7
- this.openUp = false;
8
- this.debouncedUpdate = debounce(() => forceUpdate(this.el), 30);
9
- this.label = undefined;
10
- this.labelPosition = "top";
11
- this.options = "";
12
- this.selectedTags = "";
13
- this.info = undefined;
14
- this.errorMessage = undefined;
15
- this.addNew = true;
16
- this.placeholder = undefined;
17
- this.requiredField = false;
18
- this.characterLimit = 50;
19
- this.maxTags = undefined;
20
- this.tagInputType = "dropdown";
21
- this.colHeaders = undefined;
22
- this.colWidths = undefined;
23
- this.colWrap = undefined;
24
- this.messageConfig = "";
25
- this.focusedListItem = undefined;
26
- this.focusedTag = null;
27
- this.tablePosition = { row: 0, column: 1 };
28
- this.isExpanded = false;
29
- this.tagsList = csvToArray(this.selectedTags);
30
- this.optionsList = csvToArray(this.options);
31
- this.charCount = 0;
32
- this.liveRegionMessage = "";
33
- }
34
- get tooltipVisible() {
35
- return document.getElementById("wm-tooltip").classList.contains("open");
36
- }
37
- get focusedElement() {
38
- return this.el.shadowRoot.activeElement;
39
- }
40
- get listItemEls() {
41
- return Array.from(this.dropdownEl.querySelectorAll("li"));
42
- }
43
- get tagEls() {
44
- return this.tagAreaEl ? Array.from(this.tagAreaEl.querySelectorAll(".tag")) : [];
45
- }
46
- get nonLockedTagEls() {
47
- return this.tagEls.filter((tag) => !tag.classList.contains("locked"));
48
- }
49
- get optionEls() {
50
- return Array.from(this.dropdownEl.querySelectorAll(".option"));
51
- }
52
- get wmRowEls() {
53
- return Array.from(this.el.querySelectorAll("wm-tag-input-row"));
54
- }
55
- get localRowEls() {
56
- return Array.from(this.el.shadowRoot.querySelectorAll("tr"));
57
- }
58
- get filteredRows() {
59
- return this.wmRowEls.filter((row) => {
60
- const colValues = [row.col1, row.col2, row.col3, row.col4].join("").toLowerCase();
61
- return this.inputEl && this.inputEl.value ? colValues.includes(this.inputEl.value.toLowerCase()) : true;
62
- });
63
- }
64
- get nonLockedTagsList() {
65
- let list = [];
66
- if (this.tagInputType === "table") {
67
- this.tagsList.forEach((id) => {
68
- const correspondingRowEl = this.wmRowEls.filter((row) => id === row.id)[0];
69
- if (!correspondingRowEl.locked) {
70
- list.push(id);
71
- }
72
- });
73
- }
74
- else if (this.tagInputType === "dropdown") {
75
- list = this.tagsList;
76
- }
77
- return list;
78
- }
79
- get tagLimitReached() {
80
- return !!(this.maxTags && this.tagsList.length >= this.maxTags);
81
- }
82
- get noResultsMessage() {
83
- return intl.formatMessage({
84
- id: "tagInput.noResults",
85
- defaultMessage: "No results match your search.",
86
- description: "Message displayed when a user's search returns empty.",
87
- });
88
- }
89
- get componentMessages() {
90
- const addNewHelpText = intl.formatMessage({
91
- id: "tagInput.addNewHelpText",
92
- defaultMessage: "Press the Enter or Comma key to add a new tag.",
93
- description: "Help text appearing in a dropdown. Use imperative",
94
- });
95
- const selectionHelpText = intl.formatMessage({
96
- id: "tagInput.selectionHelpText",
97
- defaultMessage: "Search and select a tag.",
98
- description: "Help text appearing in a dropdown. Use imperative",
99
- });
100
- const maxTagsReachedMessage = intl.formatMessage({
101
- id: "tagInput.maxTagsReached",
102
- defaultMessage: "No more tags can be added because the limit has been reached.",
103
- });
104
- const tagAreaInstructions = intl.formatMessage({
105
- id: "tagInput.tagAreaInstructions",
106
- defaultMessage: "tag selection. Press Backspace or Delete to remove a tag.",
107
- });
108
- const tagsAddedMessage = intl.formatMessage({
109
- id: "tagInput.tagsAdded",
110
- defaultMessage: "Tags added",
111
- description: "For the user to understand how close they are to the tag limit, followed by x/y count",
112
- });
113
- const defaultConfig = {
114
- addNewHelpText: addNewHelpText,
115
- selectionHelpText: selectionHelpText,
116
- maxTagsReached: maxTagsReachedMessage,
117
- tagAreaInstructions: tagAreaInstructions,
118
- tagsAdded: tagsAddedMessage,
119
- };
120
- const userProvidedConfig = safeParseJSON(this.messageConfig);
121
- return userProvidedConfig ? Object.assign(Object.assign({}, defaultConfig), userProvidedConfig) : defaultConfig;
122
- }
123
- get inputMinimumWidth() {
124
- // 150px is the minimum width of the input field, or the length of the placeholder text
125
- const inputElStyles = getComputedStyle(this.inputEl);
126
- const tagElStyles = getComputedStyle(this.tagEls[this.tagEls.length - 1]);
127
- const inputElBuffer = [
128
- inputElStyles.paddingLeft,
129
- inputElStyles.paddingRight,
130
- inputElStyles.marginLeft,
131
- inputElStyles.marginRight,
132
- tagElStyles.marginRight,
133
- ].reduce((prev, curr) => prev + parseInt(curr.replace("px", "")), 0);
134
- const minimumWidth = Math.max(150, measureText(this.inputEl, this.placeholder).width + inputElBuffer);
135
- return minimumWidth;
136
- }
137
- generateTagAddedMessage(tag) {
138
- return intl.formatMessage({
139
- id: "tagInput.tagAdded",
140
- defaultMessage: "{tagName} added.",
141
- description: "A confirmation for adding a tag.",
142
- }, { tagName: tag });
143
- }
144
- generateTagAlreadyAddedMessage(tag) {
145
- return intl.formatMessage({
146
- id: "tagInput.tagAlreadyAdded",
147
- defaultMessage: "{tagName} has already been added.",
148
- description: "An alert for adding a tag that is already present.",
149
- }, { tagName: tag });
150
- }
151
- componentWillLoad() {
152
- if (!this.placeholder) {
153
- this.placeholder = this.createPlaceholderDefault(this.addNew, !!this.options);
154
- }
155
- if (!this.label) {
156
- console.error("wm-tag-input must have a label property");
157
- }
158
- this.consolidateSelectedTags();
159
- this.el.focus = () => {
160
- const firstFocusableTag = this.nonLockedTagEls[0];
161
- if (firstFocusableTag) {
162
- this.tagAreaEl.focus();
163
- this.focusTag(firstFocusableTag);
164
- }
165
- else {
166
- this.inputEl.focus();
167
- }
168
- };
169
- // on resize of component, trigger componentDidRender -> positionInput
170
- const resizeObserver = new ResizeObserver(() => this.debouncedUpdate());
171
- resizeObserver.observe(this.el);
172
- }
173
- componentDidLoad() {
174
- // prevent highlighting of pre-selected tags
175
- this.tagEls.forEach((el) => el.classList.remove("highlight"));
176
- }
177
- componentDidRender() {
178
- this.positionInput();
179
- // check each tag if truncation is needed
180
- this.tagEls.forEach((tag) => {
181
- const textEl = tag.querySelector(".tag-text");
182
- const wrapper = this.el.shadowRoot.querySelector(".tags-and-input-wrapper");
183
- const leftBound = textEl.getBoundingClientRect().left;
184
- // the numbers represent spacing values for padding, margin, and delete icon
185
- const rightBound = wrapper.getBoundingClientRect().right - 10 - 8 - 28;
186
- let displayText = tag.dataset.tag;
187
- if (this.tagInputType === "table") {
188
- // table variant doesn't display the tag id, but the contents of the first column
189
- const referencedRow = this.el.querySelector(`#${displayText}`);
190
- displayText = referencedRow ? referencedRow.col1 : "";
191
- }
192
- textEl.textContent = truncateText(textEl, displayText, rightBound - leftBound, 5);
193
- });
194
- }
195
- consolidateSelectedTags() {
196
- this.tagsList.forEach((tag) => {
197
- if (!this.includesCaseInsensitive(this.optionsList, tag)) {
198
- this.options += `${this.options.length > 0 ? "," : ""}${tag}`;
199
- }
200
- });
201
- this.optionsList = csvToArray(this.options);
202
- }
203
- createPlaceholderDefault(addNew, hasOptions) {
204
- const addAndSearchPlaceholder = intl.formatMessage({
205
- id: "tagInput.placeholderAddAndSearch",
206
- defaultMessage: "Add or search for a tag",
207
- description: "Placeholder text. Use imperative",
208
- });
209
- const searchPlaceholder = intl.formatMessage({
210
- id: "tagInput.placeholderSearch",
211
- defaultMessage: "Search and select a tag",
212
- description: "Placeholder text. Use imperative",
213
- });
214
- const addPlaceholder = intl.formatMessage({
215
- id: "tagInput.placeholderAdd",
216
- defaultMessage: "Add a new tag",
217
- description: "Placeholder text. Use imperative",
218
- });
219
- let placeholder = "";
220
- if (addNew && hasOptions) {
221
- placeholder = addAndSearchPlaceholder;
222
- }
223
- else if (!addNew && hasOptions) {
224
- placeholder = searchPlaceholder;
225
- }
226
- else if (addNew) {
227
- placeholder = addPlaceholder;
228
- }
229
- return placeholder;
230
- }
231
- reflectSelectedTags(newValue, oldValue) {
232
- const isAddition = newValue.length > oldValue.length;
233
- let changedTag = "";
234
- let selectedTags = this.tagsList;
235
- if (isAddition) {
236
- changedTag = newValue.filter((val) => !oldValue.includes(val))[0];
237
- }
238
- else {
239
- changedTag = oldValue.filter((val) => !newValue.includes(val))[0];
240
- }
241
- // event emitted by type table uses element references instead of strings
242
- if (this.tagInputType === "table") {
243
- changedTag = this.wmRowEls.filter((row) => row.id === changedTag)[0];
244
- selectedTags = this.tagsList.map((id) => this.el.querySelector(`#${id}`));
245
- }
246
- this.selectedTags = this.listToCSV(this.tagsList);
247
- let detail = { value: selectedTags, tagChanged: changedTag };
248
- this.wmTagInputChanged.emit(detail);
249
- }
250
- handleErrorMessageChange() {
251
- if (this.errorMessage) {
252
- this.announce(this.errorMessage);
253
- }
254
- }
255
- handleRowUpdate() {
256
- forceUpdate(this.el);
257
- }
258
- closeIfNotElOrChild(ev) {
259
- const isntElOrChild = ev.target !== this.el && !this.el.shadowRoot.contains(ev.target);
260
- if (this.tagInputType === "dropdown" && isntElOrChild && this.isExpanded) {
261
- this.closeDropdown();
262
- }
263
- }
264
- // From wm-button
265
- // we need to listen for scroll events during the capture phase because they do not bubble up
266
- // there can be layouts where the main content has 100vh and overflows
267
- // in these cases window will register no scroll events unless we catch on they way down
268
- dismissTooltip() {
269
- if (this.tooltipVisible) {
270
- hideTooltip();
271
- }
272
- }
273
- handleInputKeyDown(ev) {
274
- if (/^.$/.test(ev.key) && this.inputEl.value.length >= this.characterLimit) {
275
- this.announce(this.generateCharacterLimitWarning(this.inputEl.value.length, this.characterLimit));
276
- }
277
- // prevent keydown triggering on tag area
278
- ev.stopPropagation();
279
- switch (ev.key) {
280
- case "Enter":
281
- case ",":
282
- ev.preventDefault();
283
- this.handleInputEnter();
284
- break;
285
- case "ArrowDown":
286
- ev.preventDefault();
287
- this.handleInputArrowDown();
288
- break;
289
- case "ArrowUp":
290
- ev.preventDefault();
291
- this.handleInputArrowUp();
292
- break;
293
- case "ArrowLeft":
294
- if (this.tagInputType === "table" && this.tablePosition.row) {
295
- ev.preventDefault();
296
- this.moveLeftCell();
297
- }
298
- break;
299
- case "ArrowRight":
300
- if (this.tagInputType === "table" && this.tablePosition.row) {
301
- ev.preventDefault();
302
- this.moveRightCell();
303
- }
304
- break;
305
- case "Escape":
306
- if (this.tagInputType === "dropdown" && this.isExpanded) {
307
- this.closeDropdown();
308
- }
309
- break;
310
- case "ArrowLeft":
311
- case "Backspace":
312
- this.handleInputBackspace();
313
- break;
314
- }
315
- }
316
- handleInputFocus() {
317
- if (this.tagInputType === "dropdown") {
318
- this.openDropdown();
319
- this.clearListItemFocus();
320
- }
321
- // force update needed to apply styled state of field-wrapper el
322
- forceUpdate(this.el);
323
- }
324
- handleInputChanged(value) {
325
- this.charCount = value.length;
326
- if (this.tagInputType === "dropdown") {
327
- this.clearListItemFocus();
328
- if (this.charCount >= this.characterLimit - 5) {
329
- this.announce(this.generateCharacterLimitWarning(this.charCount, this.characterLimit));
330
- }
331
- if (!this.isExpanded) {
332
- this.openDropdown();
333
- }
334
- }
335
- else if (this.tagInputType === "table") {
336
- this.clearCellFocus();
337
- }
338
- this.announceExistingOptions();
339
- }
340
- handleInputEnter() {
341
- if (this.tagInputType === "dropdown") {
342
- if (this.focusedListItem) {
343
- this.handleListItemClick(this.focusedListItem);
344
- }
345
- else {
346
- this.submitInput(this.addNew, this.inputEl.value.trim());
347
- }
348
- }
349
- else if (this.tagInputType === "table" && this.tablePosition.row > 0) {
350
- this.handleTableRowClick(this.localRowEls[this.tablePosition.row].id);
351
- }
352
- }
353
- submitInput(canAddNew, value) {
354
- const hasNonWhiteSpaceCharacters = value.match(/\S/);
355
- if (canAddNew && hasNonWhiteSpaceCharacters) {
356
- this.addTag(value);
357
- this.optionsList = this.addOption(value);
358
- this.resetInput();
359
- }
360
- }
361
- handleInputArrowDown() {
362
- if (this.tagInputType === "table") {
363
- this.moveDownRow();
364
- }
365
- else if (this.tagInputType === "dropdown" && this.isExpanded) {
366
- this.moveDownListItem();
367
- }
368
- else if (this.tagInputType === "dropdown") {
369
- this.openDropdown();
370
- }
371
- }
372
- handleInputArrowUp() {
373
- if (this.tagInputType === "table") {
374
- this.moveUpRow();
375
- }
376
- else if (this.tagInputType === "dropdown" && this.isExpanded) {
377
- this.moveUpListItem();
378
- }
379
- else if (this.tagInputType === "dropdown") {
380
- this.openDropdown();
381
- }
382
- }
383
- handleInputBackspace() {
384
- if (this.inputEl.value === "" && this.tagsList.length > 0) {
385
- // wait for events to finish firing before redirecting focus
386
- // prevents double input in input area and tag area
387
- window.requestAnimationFrame(() => {
388
- if (this.nonLockedTagsList.length > 0) {
389
- this.tagAreaEl.focus();
390
- this.focusTag(this.tagEls[this.tagEls.length - 1]);
391
- }
392
- });
393
- }
394
- }
395
- handleListItemKeyDown(ev) {
396
- const typedEvTarget = ev.target;
397
- switch (ev.key) {
398
- case "Enter":
399
- case " ":
400
- ev.preventDefault();
401
- typedEvTarget.click();
402
- break;
403
- case "ArrowDown":
404
- ev.preventDefault();
405
- this.moveDownListItem();
406
- break;
407
- case "ArrowUp":
408
- ev.preventDefault();
409
- this.moveUpListItem();
410
- break;
411
- case "Escape":
412
- if (this.focusedElement !== this.inputEl) {
413
- this.inputEl.focus();
414
- }
415
- else if (this.tagInputType === "dropdown") {
416
- this.closeDropdown();
417
- }
418
- break;
419
- }
420
- }
421
- handleListItemClick(item) {
422
- const tag = item.dataset.option.trim() || "";
423
- if (this.includesCaseInsensitive(this.tagsList, tag)) {
424
- this.announce(this.generateTagAlreadyAddedMessage(tag));
425
- }
426
- else {
427
- this.resetInput();
428
- this.addTag(tag);
429
- this.optionsList = this.addOption(tag);
430
- this.focusedListItem = null;
431
- }
432
- }
433
- handleTableRowClick(rowId) {
434
- const referencedRow = this.el.querySelector(`#${rowId}`);
435
- const isLocked = referencedRow.locked;
436
- if (!isLocked) {
437
- if (this.includesCaseInsensitive(this.tagsList, rowId)) {
438
- this.removeTag(rowId);
439
- }
440
- else if (!this.tagLimitReached) {
441
- this.addTag(rowId);
442
- this.resetInput();
443
- }
444
- }
445
- }
446
- handleTagAreaKeyDown(ev) {
447
- switch (ev.key) {
448
- case "ArrowLeft":
449
- case "ArrowUp":
450
- ev.preventDefault();
451
- this.moveLeftTag();
452
- break;
453
- case "ArrowRight":
454
- case "ArrowDown":
455
- ev.preventDefault();
456
- this.moveRightTag();
457
- break;
458
- case "Backspace":
459
- case "Delete":
460
- this.handleTagAreaDelete();
461
- break;
462
- }
463
- }
464
- handleTagAreaDelete() {
465
- const isLocked = this.focusedTag && this.focusedTag.classList.contains("locked");
466
- if (this.focusedTag && !isLocked) {
467
- this.removeTag(this.focusedTag.dataset.tag);
468
- if (this.nonLockedTagsList.length === 0) {
469
- // focus input if no tags are left
470
- this.inputEl.focus();
471
- }
472
- else {
473
- const removingLastTag = this.focusedTag === this.tagEls[this.tagEls.length - 1];
474
- // if removing the last tag, reassign focused tag to previous task
475
- this.focusedTag = removingLastTag ? this.tagEls[this.tagEls.length - 2] : this.focusedTag;
476
- this.focusTag(this.focusedTag);
477
- }
478
- }
479
- }
480
- handleBlur(ev, component) {
481
- const isntElOrChild = ev.relatedTarget !== component && !this.el.shadowRoot.contains(ev.relatedTarget);
482
- this.dismissTooltip();
483
- this.clearCellFocus();
484
- if (isntElOrChild) {
485
- this.fieldWrapperEl.classList.remove("focused");
486
- if (this.tagInputType === "dropdown") {
487
- this.closeDropdown();
488
- }
489
- }
490
- }
491
- handleCellMouseEnter(ev) {
492
- const cell = ev.target;
493
- const contentWrapper = cell.querySelector(".cell-content-wrapper");
494
- const isTruncated = contentWrapper.scrollWidth > contentWrapper.clientWidth;
495
- if (isTruncated) {
496
- // innerText is necessary vs textContent, as innerText ignores sr-only / display: none text
497
- showTooltip("bottom", cell, cell.innerText);
498
- }
499
- }
500
- handleTagAreaFocus() {
501
- if (this.tagInputType === "dropdown") {
502
- this.closeDropdown();
503
- }
504
- const firstFocusableTag = this.nonLockedTagEls[0];
505
- firstFocusableTag && this.focusTag(firstFocusableTag);
506
- }
507
- handleRemoveButtonClick(tag) {
508
- this.moveLeftTag();
509
- this.removeTag(tag);
510
- }
511
- moveDownListItem() {
512
- if (this.listItemEls.length > 0) {
513
- const firstListItem = this.listItemEls[0];
514
- if (!this.focusedListItem) {
515
- this.focusListItem(firstListItem);
516
- }
517
- else if (this.focusedListItem.nextElementSibling) {
518
- this.focusListItem(this.focusedListItem.nextElementSibling);
519
- }
520
- else {
521
- this.focusListItem(firstListItem);
522
- }
523
- }
524
- }
525
- moveUpListItem() {
526
- if (this.listItemEls.length > 0) {
527
- const lastListItem = this.listItemEls[this.listItemEls.length - 1];
528
- if (!this.focusedListItem) {
529
- this.focusListItem(lastListItem);
530
- }
531
- else if (this.focusedListItem.previousElementSibling) {
532
- this.focusListItem(this.focusedListItem.previousElementSibling);
533
- }
534
- else {
535
- this.clearListItemFocus();
536
- }
537
- }
538
- }
539
- moveDownRow() {
540
- if (this.filteredRows.length > 0) {
541
- if (this.tablePosition.row === 0) {
542
- this.tablePosition.row = 1;
543
- }
544
- else if (this.tablePosition.row === this.filteredRows.length) {
545
- this.tablePosition.row = 1;
546
- }
547
- else {
548
- this.tablePosition.row++;
549
- }
550
- // skip locked rows
551
- const rowToFocus = this.wmRowEls[this.tablePosition.row - 1];
552
- if (rowToFocus.locked) {
553
- this.moveDownRow();
554
- }
555
- else {
556
- this.focusCell(this.tablePosition);
557
- }
558
- }
559
- }
560
- moveUpRow() {
561
- if (this.filteredRows.length > 0) {
562
- if (this.tablePosition.row === 0) {
563
- this.tablePosition.row = this.filteredRows.length;
564
- }
565
- else if (this.tablePosition.row === 1) {
566
- this.tablePosition.row = 0;
567
- }
568
- else {
569
- this.tablePosition.row--;
570
- }
571
- // skip locked rows
572
- const rowToFocus = this.wmRowEls[this.tablePosition.row - 1];
573
- if (rowToFocus && rowToFocus.locked) {
574
- this.moveUpRow();
575
- }
576
- else if (rowToFocus) {
577
- this.focusCell(this.tablePosition);
578
- }
579
- else {
580
- this.clearCellFocus();
581
- }
582
- }
583
- }
584
- moveLeftCell() {
585
- if (this.tablePosition.column != 1) {
586
- this.tablePosition.column--;
587
- this.focusCell(this.tablePosition);
588
- }
589
- }
590
- moveRightCell() {
591
- const numCols = csvToArray(this.colHeaders).length;
592
- if (this.tablePosition.column < numCols) {
593
- this.tablePosition.column++;
594
- this.focusCell(this.tablePosition);
595
- }
596
- }
597
- moveLeftTag() {
598
- const lastTag = this.tagEls[this.tagEls.length - 1];
599
- if (this.focusedTag && this.tagEls.includes(this.focusedTag.previousElementSibling)) {
600
- this.focusedTag = this.focusedTag.previousElementSibling;
601
- }
602
- else {
603
- this.focusedTag = lastTag;
604
- }
605
- // skip locked tags
606
- if (this.focusedTag.classList.contains("locked") && this.nonLockedTagEls.length > 0) {
607
- this.moveLeftTag();
608
- }
609
- else {
610
- this.focusTag(this.focusedTag);
611
- }
612
- }
613
- moveRightTag() {
614
- const firstTag = this.tagEls[0];
615
- if (this.focusedTag && this.tagEls.includes(this.focusedTag.nextElementSibling)) {
616
- this.focusedTag = this.focusedTag.nextElementSibling;
617
- }
618
- else {
619
- this.focusedTag = firstTag;
620
- }
621
- // skip locked tags
622
- if (this.focusedTag.classList.contains("locked")) {
623
- this.moveRightTag();
624
- }
625
- else {
626
- this.focusTag(this.focusedTag);
627
- }
628
- }
629
- addOption(option) {
630
- let newOptionsList = this.optionsList;
631
- const optionAlreadyExists = this.includesCaseInsensitive(this.optionsList, option);
632
- if (!optionAlreadyExists) {
633
- newOptionsList = newOptionsList.concat(option);
634
- }
635
- return newOptionsList;
636
- }
637
- removeOption(option) {
638
- this.optionsList = this.filterCaseInsensitive(this.optionsList, option);
639
- }
640
- addTag(tag) {
641
- let newTagsList = this.tagsList;
642
- const tagAlreadyAdded = this.includesCaseInsensitive(this.tagsList, tag);
643
- const tagExistsAsOption = this.optionsList.filter((x) => x.toLowerCase() === tag.toLowerCase())[0];
644
- if (!tagAlreadyAdded) {
645
- let textToAnnounce = tag;
646
- if (this.tagInputType === "table") {
647
- const referencedRow = this.el.querySelector(`#${tag}`);
648
- textToAnnounce = referencedRow.col1;
649
- }
650
- this.announce(this.generateTagAddedMessage(textToAnnounce));
651
- this.tagsList = newTagsList.concat(tagExistsAsOption || tag);
652
- // if maxTags has been reached, focus should go to the tagArea
653
- if (this.tagLimitReached) {
654
- this.tagAreaEl.focus();
655
- }
656
- }
657
- }
658
- removeTag(tag) {
659
- let textToAnnounce = tag;
660
- if (this.tagInputType === "table") {
661
- const referencedRow = this.el.querySelector(`#${tag}`);
662
- textToAnnounce = referencedRow.col1;
663
- }
664
- const tagRemovedMessage = intl.formatMessage({ id: "tagInput.tagRemoved", defaultMessage: "{tag} removed" }, { tag: textToAnnounce });
665
- this.announce(tagRemovedMessage);
666
- this.tagsList = this.filterCaseInsensitive(this.tagsList, tag);
667
- if (this.tagInputType === "dropdown") {
668
- // if a tag was introduced by the user, also remove it from the dropdown options
669
- const devOptionsList = csvToArray(this.options);
670
- if (this.includesCaseInsensitive(this.optionsList, tag) && !this.includesCaseInsensitive(devOptionsList, tag)) {
671
- this.removeOption(tag);
672
- }
673
- }
674
- }
675
- focusListItem(item) {
676
- this.focusedListItem = item;
677
- this.inputEl.setAttribute("aria-activedescendant", this.focusedListItem.id);
678
- item.scrollIntoView({ block: "nearest" });
679
- }
680
- focusTag(element) {
681
- if (element.classList.contains("locked")) {
682
- this.focusedTag = null;
683
- this.tagAreaEl.setAttribute("aria-activedescendant", "");
684
- }
685
- else {
686
- this.focusedTag = element;
687
- this.tagAreaEl.setAttribute("aria-activedescendant", this.focusedTag.id);
688
- }
689
- window.requestAnimationFrame(() => {
690
- hideTooltip();
691
- const textEl = element.querySelector(".tag-text");
692
- const fullText = element.dataset.tag;
693
- const isTruncated = fullText !== textEl.textContent && textEl.textContent.includes("...");
694
- isTruncated && showTooltip("bottom", element, fullText);
695
- });
696
- }
697
- focusCell(position) {
698
- this.clearCellFocus(false);
699
- if (position.row) {
700
- const rowToFocus = this.localRowEls[position.row];
701
- const rowCells = rowToFocus.querySelectorAll("td");
702
- const cellToFocus = rowCells[position.column - 1];
703
- const contentWrapper = cellToFocus.querySelector(".cell-content-wrapper");
704
- const isTruncated = contentWrapper.scrollWidth > contentWrapper.clientWidth;
705
- rowToFocus.classList.add("focused");
706
- cellToFocus.classList.add("focused");
707
- cellToFocus.scrollIntoView({ block: "nearest" });
708
- this.inputEl.setAttribute("aria-activedescendant", cellToFocus.id);
709
- this.dismissTooltip();
710
- if (isTruncated) {
711
- // innerText is necessary vs textContent, as innerText ignores sr-only / display: none text
712
- showTooltip("bottom", cellToFocus, cellToFocus.innerText);
713
- }
714
- }
715
- }
716
- clearTagFocus() {
717
- this.tagAreaEl.setAttribute("aria-activedescendant", "");
718
- this.focusedTag = null;
719
- }
720
- clearCellFocus(resetPosition = true) {
721
- this.inputEl.setAttribute("aria-activedescendant", "");
722
- if (resetPosition) {
723
- this.tablePosition = { row: 0, column: 1 };
724
- }
725
- this.localRowEls.forEach((row) => {
726
- row.classList.remove("focused");
727
- row.querySelectorAll("td").forEach((cell) => {
728
- cell.classList.remove("focused");
729
- });
730
- });
731
- }
732
- openDropdown() {
733
- // given an offset of -2px because the dropdown is transformed downwards to avoid overlapping the focus border
734
- this.openUp = shouldOpenUp(this.el, this.dropdownEl, this.el.clientHeight, -2);
735
- this.isExpanded = true;
736
- }
737
- closeDropdown() {
738
- this.clearListItemFocus();
739
- this.isExpanded = false;
740
- }
741
- clearListItemFocus() {
742
- this.focusedListItem = null;
743
- this.inputEl.setAttribute("aria-activedescendant", "");
744
- this.listItemEls.forEach((el) => {
745
- el.classList.remove("focused");
746
- });
747
- }
748
- resetInput() {
749
- this.charCount = 0;
750
- this.inputEl.value = "";
751
- }
752
- announce(message) {
753
- // \u00A0 is a non-breaking space character, which causes the message to be read as a new one
754
- if (this.liveRegionEl.textContent === message) {
755
- message += "\u00A0";
756
- }
757
- this.liveRegionMessage = message;
758
- }
759
- announceExistingOptions() {
760
- // request animation frame to wait for re-rendering of filtered options
761
- window.requestAnimationFrame(() => {
762
- let numResults = 0;
763
- if (this.tagInputType === "dropdown") {
764
- numResults = this.optionEls.length;
765
- }
766
- else if (this.tagInputType === "table") {
767
- numResults = this.filteredRows.length;
768
- }
769
- const existingOptionsMessage = intl.formatMessage({
770
- id: "tagInput.existingOptions",
771
- defaultMessage: "{num, plural, one {1 existing option.} other {# existing options.}}",
772
- }, { num: numResults });
773
- this.announce(existingOptionsMessage);
774
- });
775
- }
776
- generateCharacterLimitWarning(charCount, charLimit) {
777
- let message = globalMessages.getCharactersEntered(charCount, charLimit);
778
- if (charCount >= charLimit) {
779
- message += ` ${globalMessages.characterLimitReached}`;
780
- }
781
- return message;
782
- }
783
- positionInput() {
784
- const lastTag = this.tagEls[this.tagEls.length - 1];
785
- // default placement to fall back to when no tags are present, or not enough space is available
786
- this.inputEl.style.position = "static";
787
- this.inputEl.style.width = "100%";
788
- if (lastTag) {
789
- const spaceAvailable = this.tagAreaEl.getBoundingClientRect().right - lastTag.getBoundingClientRect().right;
790
- if (spaceAvailable >= this.inputMinimumWidth) {
791
- // because the input has right: 0px
792
- // all thats needed to properly place it is setting position: absolute, top, and width
793
- this.inputEl.style.position = "absolute";
794
- this.inputEl.style.top = lastTag.offsetTop.toString() + "px";
795
- this.inputEl.style.width =
796
- (this.tagAreaEl.getBoundingClientRect().right - lastTag.getBoundingClientRect().right - 8).toString() + "px";
797
- }
798
- }
799
- }
800
- handleTagMouseEnter(ev) {
801
- const displayedText = ev.target.querySelector(".tag-text").textContent;
802
- const fullText = ev.target.dataset.tag;
803
- const isTruncated = displayedText !== fullText && displayedText.includes("...");
804
- isTruncated && showTooltip("bottom", ev.target, fullText);
805
- }
806
- /// Helpers
807
- listToCSV(list) {
808
- return list.join(",");
809
- }
810
- includesCaseInsensitive(list, element) {
811
- const lowercaseList = list.map((str) => str.toLowerCase());
812
- return lowercaseList.includes(element.toLowerCase());
813
- }
814
- filterCaseInsensitive(list, element) {
815
- return list.filter((x) => x.toLowerCase() !== element.toLowerCase());
816
- }
817
- sortCaseInsensitive(list) {
818
- // The vanilla .sort method places words that start with capital letters above others (ASCII order)
819
- // so we need to pass in our own compare function to sort case-insensitive
820
- return list.sort((a, b) => {
821
- a = a.toLowerCase();
822
- b = b.toLowerCase();
823
- return a > b ? 1 : a < b ? -1 : 0;
824
- });
825
- }
826
- /// Renders
827
- renderTags() {
828
- let lockedTags = [];
829
- let unlockedTags = [];
830
- this.tagsList.forEach((tag, idx) => {
831
- const id = `tag${idx + 1}`;
832
- let tagText = "";
833
- let isLocked = false;
834
- if (this.tagInputType === "dropdown") {
835
- tagText = tag;
836
- }
837
- else if (this.tagInputType === "table") {
838
- // display table tags using col1 of the row with the same id
839
- // if one can't be found, display as empty
840
- const referencedRow = this.el.querySelector(`#${tag}`);
841
- tagText = referencedRow ? referencedRow.col1 : "";
842
- isLocked = referencedRow ? referencedRow.locked : false;
843
- }
844
- // make sure locked tags always appear in front of list
845
- const targetList = isLocked ? lockedTags : unlockedTags;
846
- targetList.push(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: hideTooltip }, h("span", { class: "sr-only" }, tag), h("span", { class: "tag-text", "aria-hidden": "true" }, tagText), isLocked ? (h("div", { class: "icon lock" })) : (h("button", { class: "icon remove-btn", tabIndex: -1, onClick: () => this.handleRemoveButtonClick(tag) }))));
847
- });
848
- return [...lockedTags, ...unlockedTags];
849
- }
850
- renderDropdown() {
851
- return (h("div", { class: `dropdown-wrapper ${this.isExpanded ? "open" : ""} ${this.openUp ? "upwards" : ""}`, ref: (el) => (this.dropdownEl = el) }, h("div", { id: "help-text", class: "help-text" }, this.renderHelpText()), 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))));
852
- }
853
- renderListItems(optionsList) {
854
- optionsList = this.sortCaseInsensitive(optionsList);
855
- // filter by input
856
- if (this.inputEl && this.inputEl.value) {
857
- optionsList = this.optionsList.filter((option) => option.toLowerCase().includes(this.inputEl.value.toLowerCase()));
858
- }
859
- return optionsList.map((option, idx) => {
860
- const id = `option${idx + 1}`;
861
- const isFocused = this.focusedListItem && this.focusedListItem.id === id;
862
- const isSelected = this.includesCaseInsensitive(this.tagsList, option);
863
- return (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));
864
- });
865
- }
866
- renderAddNewButton() {
867
- const hasNonWhiteSpaceCharacters = this.inputEl.value.match(/\S/);
868
- const optionAlreadyExists = this.includesCaseInsensitive(this.optionsList, this.inputEl.value.trim());
869
- if (this.addNew && hasNonWhiteSpaceCharacters && !optionAlreadyExists) {
870
- const id = `add-new-btn`;
871
- const isFocused = this.focusedListItem && this.focusedListItem.id === id;
872
- return (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()}"`));
873
- }
874
- else
875
- return "";
876
- }
877
- renderHelpText() {
878
- let helpText = "";
879
- if (this.optionsList.length > 0) {
880
- helpText += this.componentMessages.selectionHelpText;
881
- }
882
- if (this.addNew) {
883
- helpText += " " + this.componentMessages.addNewHelpText;
884
- }
885
- return helpText;
886
- }
887
- renderTagCounter() {
888
- if (this.maxTags) {
889
- return (h("div", { class: "lower-row" }, h("div", { id: "max-tags" }, `${this.componentMessages.tagsAdded}: ${this.tagsList.length}/${this.maxTags}`, this.tagLimitReached && ` - ${this.componentMessages.maxTagsReached}`)));
890
- }
891
- }
892
- renderTable() {
893
- return (h("div", { class: "table-wrapper", onScroll: () => this.dismissTooltip() }, 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() : h("div", { class: "no-results" }, this.noResultsMessage))));
894
- }
895
- renderTableHeaders() {
896
- return (h("tr", { class: "headers", role: "row" }, csvToArray(this.colHeaders).map((header, idx) => {
897
- let overflowRule = "wrap";
898
- if (this.colWrap && csvToArray(this.colWrap)[idx]) {
899
- overflowRule = csvToArray(this.colWrap)[idx];
900
- }
901
- return (h("th", { class: `header-cell ${overflowRule}`, role: "columnheader",
902
- // @ts-ignore
903
- width: this.colWidths ? csvToArray(this.colWidths)[idx] : "" }, header));
904
- })));
905
- }
906
- renderTableRows() {
907
- return this.filteredRows.map((row) => {
908
- const isSelected = this.includesCaseInsensitive(this.tagsList, row.id);
909
- return (h("tr", { id: row.id, class: `${row.locked ? "locked" : ""} ${isSelected ? "selected" : ""}`, role: "row", onClick: () => this.handleTableRowClick(row.id) }, this.renderTableCells(row)));
910
- });
911
- }
912
- renderTableCells(row) {
913
- const colValues = [row.col1, row.col2, row.col3, row.col4].filter((val) => !!val);
914
- const isSelected = this.includesCaseInsensitive(this.tagsList, row.id);
915
- return colValues.map((val, idx) => {
916
- const localId = `${row.id}-col${idx + 1}`;
917
- let overflowRule = "wrap";
918
- if (this.colWrap && csvToArray(this.colWrap)[idx]) {
919
- overflowRule = csvToArray(this.colWrap)[idx];
920
- }
921
- return (h("td", { id: localId, role: "gridcell", "aria-describedby": `${localId}-description`, "aria-selected": isSelected.toString(), onMouseEnter: (ev) => this.handleCellMouseEnter(ev), onMouseLeave: () => this.dismissTooltip() }, h("div", { class: `cell-content-wrapper ${overflowRule}` }, val), h("div", { class: "description", id: `${localId}-description` }, row.locked ? "locked" : "")));
922
- });
923
- }
924
- render() {
925
- return (h(Host, { id: this.uid }, h("div", { class: `wrapper label-${this.labelPosition} ${this.errorMessage ? "invalid" : ""}` }, h("div", { class: "label-wrapper" }, h("label", { class: "label", htmlFor: `input${this.uid}` }, this.label, this.requiredField && (h("span", { class: "required", "aria-hidden": "true" }, "*")))), h("div", { class: `field-wrapper ${this.focusedElement ? "focused" : ""} ${this.errorMessage ? "invalid" : ""}`, ref: (el) => (this.fieldWrapperEl = el) }, h("div", { class: "upper-row" }, h("div", { class: "tags-and-input-wrapper" }, this.tagsList.length > 0 && (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) => {
926
- this.clearTagFocus();
927
- this.handleBlur(ev, this.el);
928
- }, onKeyDown: (ev) => this.handleTagAreaKeyDown(ev) }, this.renderTags())), 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" ? 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) => {
929
- this.handleBlur(ev, this.el);
930
- }, onFocus: () => this.handleInputFocus(), onKeyDown: (ev) => this.handleInputKeyDown(ev) })), this.tagInputType === "dropdown" && (h("div", { class: "character-count" }, this.charCount, "/", this.characterLimit))), this.renderTagCounter(), this.tagInputType === "dropdown" && this.renderDropdown()), this.info && (h("div", { id: "info", class: "info-text" }, this.info)), this.errorMessage && h("div", { id: "error" }, this.errorMessage), h("div", { class: "sr-only", "aria-live": "assertive", ref: (el) => (this.liveRegionEl = el), "aria-atomic": "true" }, this.liveRegionMessage), this.tagInputType === "table" && this.renderTable())));
931
- }
932
- static get is() { return "wm-tag-input"; }
933
- static get encapsulation() { return "shadow"; }
934
- static get delegatesFocus() { return true; }
935
- static get originalStyleUrls() {
936
- return {
937
- "$": ["wm-tag-input.scss"]
938
- };
939
- }
940
- static get styleUrls() {
941
- return {
942
- "$": ["wm-tag-input.css"]
943
- };
944
- }
945
- static get properties() {
946
- return {
947
- "label": {
948
- "type": "string",
949
- "mutable": false,
950
- "complexType": {
951
- "original": "string",
952
- "resolved": "string",
953
- "references": {}
954
- },
955
- "required": true,
956
- "optional": false,
957
- "docs": {
958
- "tags": [],
959
- "text": ""
960
- },
961
- "attribute": "label",
962
- "reflect": false
963
- },
964
- "labelPosition": {
965
- "type": "string",
966
- "mutable": false,
967
- "complexType": {
968
- "original": "\"top\" | \"left\" | \"none\"",
969
- "resolved": "\"left\" | \"none\" | \"top\"",
970
- "references": {}
971
- },
972
- "required": false,
973
- "optional": false,
974
- "docs": {
975
- "tags": [],
976
- "text": ""
977
- },
978
- "attribute": "label-position",
979
- "reflect": false,
980
- "defaultValue": "\"top\""
981
- },
982
- "options": {
983
- "type": "string",
984
- "mutable": true,
985
- "complexType": {
986
- "original": "string",
987
- "resolved": "string",
988
- "references": {}
989
- },
990
- "required": false,
991
- "optional": false,
992
- "docs": {
993
- "tags": [],
994
- "text": ""
995
- },
996
- "attribute": "options",
997
- "reflect": false,
998
- "defaultValue": "\"\""
999
- },
1000
- "selectedTags": {
1001
- "type": "string",
1002
- "mutable": true,
1003
- "complexType": {
1004
- "original": "string",
1005
- "resolved": "string",
1006
- "references": {}
1007
- },
1008
- "required": false,
1009
- "optional": false,
1010
- "docs": {
1011
- "tags": [],
1012
- "text": ""
1013
- },
1014
- "attribute": "selected-tags",
1015
- "reflect": true,
1016
- "defaultValue": "\"\""
1017
- },
1018
- "info": {
1019
- "type": "string",
1020
- "mutable": false,
1021
- "complexType": {
1022
- "original": "string",
1023
- "resolved": "string | undefined",
1024
- "references": {}
1025
- },
1026
- "required": false,
1027
- "optional": true,
1028
- "docs": {
1029
- "tags": [],
1030
- "text": ""
1031
- },
1032
- "attribute": "info",
1033
- "reflect": false
1034
- },
1035
- "errorMessage": {
1036
- "type": "string",
1037
- "mutable": false,
1038
- "complexType": {
1039
- "original": "string",
1040
- "resolved": "string | undefined",
1041
- "references": {}
1042
- },
1043
- "required": false,
1044
- "optional": true,
1045
- "docs": {
1046
- "tags": [],
1047
- "text": ""
1048
- },
1049
- "attribute": "error-message",
1050
- "reflect": false
1051
- },
1052
- "addNew": {
1053
- "type": "boolean",
1054
- "mutable": false,
1055
- "complexType": {
1056
- "original": "boolean",
1057
- "resolved": "boolean",
1058
- "references": {}
1059
- },
1060
- "required": false,
1061
- "optional": false,
1062
- "docs": {
1063
- "tags": [],
1064
- "text": ""
1065
- },
1066
- "attribute": "add-new",
1067
- "reflect": false,
1068
- "defaultValue": "true"
1069
- },
1070
- "placeholder": {
1071
- "type": "string",
1072
- "mutable": true,
1073
- "complexType": {
1074
- "original": "string",
1075
- "resolved": "string | undefined",
1076
- "references": {}
1077
- },
1078
- "required": false,
1079
- "optional": true,
1080
- "docs": {
1081
- "tags": [],
1082
- "text": ""
1083
- },
1084
- "attribute": "placeholder",
1085
- "reflect": false
1086
- },
1087
- "requiredField": {
1088
- "type": "boolean",
1089
- "mutable": false,
1090
- "complexType": {
1091
- "original": "boolean",
1092
- "resolved": "boolean",
1093
- "references": {}
1094
- },
1095
- "required": false,
1096
- "optional": false,
1097
- "docs": {
1098
- "tags": [],
1099
- "text": ""
1100
- },
1101
- "attribute": "required-field",
1102
- "reflect": false,
1103
- "defaultValue": "false"
1104
- },
1105
- "characterLimit": {
1106
- "type": "number",
1107
- "mutable": false,
1108
- "complexType": {
1109
- "original": "number",
1110
- "resolved": "number",
1111
- "references": {}
1112
- },
1113
- "required": false,
1114
- "optional": false,
1115
- "docs": {
1116
- "tags": [],
1117
- "text": ""
1118
- },
1119
- "attribute": "character-limit",
1120
- "reflect": false,
1121
- "defaultValue": "50"
1122
- },
1123
- "maxTags": {
1124
- "type": "number",
1125
- "mutable": false,
1126
- "complexType": {
1127
- "original": "number",
1128
- "resolved": "number | undefined",
1129
- "references": {}
1130
- },
1131
- "required": false,
1132
- "optional": true,
1133
- "docs": {
1134
- "tags": [],
1135
- "text": ""
1136
- },
1137
- "attribute": "max-tags",
1138
- "reflect": false
1139
- },
1140
- "tagInputType": {
1141
- "type": "string",
1142
- "mutable": false,
1143
- "complexType": {
1144
- "original": "\"dropdown\" | \"table\"",
1145
- "resolved": "\"dropdown\" | \"table\"",
1146
- "references": {}
1147
- },
1148
- "required": false,
1149
- "optional": false,
1150
- "docs": {
1151
- "tags": [],
1152
- "text": ""
1153
- },
1154
- "attribute": "tag-input-type",
1155
- "reflect": false,
1156
- "defaultValue": "\"dropdown\""
1157
- },
1158
- "colHeaders": {
1159
- "type": "string",
1160
- "mutable": false,
1161
- "complexType": {
1162
- "original": "string",
1163
- "resolved": "string",
1164
- "references": {}
1165
- },
1166
- "required": true,
1167
- "optional": false,
1168
- "docs": {
1169
- "tags": [],
1170
- "text": ""
1171
- },
1172
- "attribute": "col-headers",
1173
- "reflect": false
1174
- },
1175
- "colWidths": {
1176
- "type": "string",
1177
- "mutable": false,
1178
- "complexType": {
1179
- "original": "string",
1180
- "resolved": "string | undefined",
1181
- "references": {}
1182
- },
1183
- "required": false,
1184
- "optional": true,
1185
- "docs": {
1186
- "tags": [],
1187
- "text": ""
1188
- },
1189
- "attribute": "col-widths",
1190
- "reflect": false
1191
- },
1192
- "colWrap": {
1193
- "type": "string",
1194
- "mutable": false,
1195
- "complexType": {
1196
- "original": "string",
1197
- "resolved": "string | undefined",
1198
- "references": {}
1199
- },
1200
- "required": false,
1201
- "optional": true,
1202
- "docs": {
1203
- "tags": [],
1204
- "text": ""
1205
- },
1206
- "attribute": "col-wrap",
1207
- "reflect": false
1208
- },
1209
- "messageConfig": {
1210
- "type": "string",
1211
- "mutable": false,
1212
- "complexType": {
1213
- "original": "string",
1214
- "resolved": "string",
1215
- "references": {}
1216
- },
1217
- "required": false,
1218
- "optional": false,
1219
- "docs": {
1220
- "tags": [],
1221
- "text": ""
1222
- },
1223
- "attribute": "message-config",
1224
- "reflect": false,
1225
- "defaultValue": "\"\""
1226
- }
1227
- };
1228
- }
1229
- static get states() {
1230
- return {
1231
- "focusedListItem": {},
1232
- "focusedTag": {},
1233
- "tablePosition": {},
1234
- "isExpanded": {},
1235
- "tagsList": {},
1236
- "optionsList": {},
1237
- "charCount": {},
1238
- "liveRegionMessage": {}
1239
- };
1240
- }
1241
- static get events() {
1242
- return [{
1243
- "method": "wmTagInputChanged",
1244
- "name": "wmTagInputChanged",
1245
- "bubbles": true,
1246
- "cancelable": true,
1247
- "composed": true,
1248
- "docs": {
1249
- "tags": [],
1250
- "text": ""
1251
- },
1252
- "complexType": {
1253
- "original": "{\n value: string[] | HTMLWmTagInputRowElement[];\n tagChanged: string | HTMLWmTagInputRowElement;\n }",
1254
- "resolved": "{ value: string[] | HTMLWmTagInputRowElement[]; tagChanged: string | HTMLWmTagInputRowElement; }",
1255
- "references": {
1256
- "HTMLWmTagInputRowElement": {
1257
- "location": "global"
1258
- }
1259
- }
1260
- }
1261
- }];
1262
- }
1263
- static get elementRef() { return "el"; }
1264
- static get watchers() {
1265
- return [{
1266
- "propName": "tagsList",
1267
- "methodName": "reflectSelectedTags"
1268
- }, {
1269
- "propName": "errorMessage",
1270
- "methodName": "handleErrorMessageChange"
1271
- }];
1272
- }
1273
- static get listeners() {
1274
- return [{
1275
- "name": "wmTagInputRowUpdated",
1276
- "method": "handleRowUpdate",
1277
- "target": undefined,
1278
- "capture": false,
1279
- "passive": false
1280
- }, {
1281
- "name": "click",
1282
- "method": "closeIfNotElOrChild",
1283
- "target": "document",
1284
- "capture": false,
1285
- "passive": false
1286
- }, {
1287
- "name": "scroll",
1288
- "method": "dismissTooltip",
1289
- "target": "window",
1290
- "capture": true,
1291
- "passive": true
1292
- }];
1293
- }
1294
- }
1
+ import { h, Host, forceUpdate, } from "@stencil/core";
2
+ import { csvToArray, debounce, generateId, hideTooltip, intl, measureText, safeParseJSON, shouldOpenUp, showTooltip, truncateText, } from "../../global/functions";
3
+ import { globalMessages } from "../../global/intl";
4
+ export class TagInput {
5
+ constructor() {
6
+ this.uid = this.el.id ? this.el.id : generateId();
7
+ this.openUp = false;
8
+ this.debouncedUpdate = debounce(() => forceUpdate(this.el), 30);
9
+ this.label = undefined;
10
+ this.labelPosition = "top";
11
+ this.options = "";
12
+ this.selectedTags = "";
13
+ this.info = undefined;
14
+ this.errorMessage = undefined;
15
+ this.addNew = true;
16
+ this.placeholder = undefined;
17
+ this.requiredField = false;
18
+ this.characterLimit = 50;
19
+ this.maxTags = undefined;
20
+ this.tagInputType = "dropdown";
21
+ this.colHeaders = undefined;
22
+ this.colWidths = undefined;
23
+ this.colWrap = undefined;
24
+ this.messageConfig = "";
25
+ this.focusedListItem = undefined;
26
+ this.focusedTag = null;
27
+ this.tablePosition = { row: 0, column: 1 };
28
+ this.isExpanded = false;
29
+ this.tagsList = csvToArray(this.selectedTags);
30
+ this.optionsList = csvToArray(this.options);
31
+ this.charCount = 0;
32
+ this.liveRegionMessage = "";
33
+ }
34
+ get tooltipVisible() {
35
+ return document.getElementById("wm-tooltip").classList.contains("open");
36
+ }
37
+ get focusedElement() {
38
+ return this.el.shadowRoot.activeElement;
39
+ }
40
+ get listItemEls() {
41
+ return Array.from(this.dropdownEl.querySelectorAll("li"));
42
+ }
43
+ get tagEls() {
44
+ return this.tagAreaEl ? Array.from(this.tagAreaEl.querySelectorAll(".tag")) : [];
45
+ }
46
+ get nonLockedTagEls() {
47
+ return this.tagEls.filter((tag) => !tag.classList.contains("locked"));
48
+ }
49
+ get optionEls() {
50
+ return Array.from(this.dropdownEl.querySelectorAll(".option"));
51
+ }
52
+ get wmRowEls() {
53
+ return Array.from(this.el.querySelectorAll("wm-tag-input-row"));
54
+ }
55
+ get localRowEls() {
56
+ return Array.from(this.el.shadowRoot.querySelectorAll("tr"));
57
+ }
58
+ get filteredRows() {
59
+ return this.wmRowEls.filter((row) => {
60
+ const colValues = [row.col1, row.col2, row.col3, row.col4].join("").toLowerCase();
61
+ return this.inputEl && this.inputEl.value ? colValues.includes(this.inputEl.value.toLowerCase()) : true;
62
+ });
63
+ }
64
+ get nonLockedTagsList() {
65
+ let list = [];
66
+ if (this.tagInputType === "table") {
67
+ this.tagsList.forEach((id) => {
68
+ const correspondingRowEl = this.wmRowEls.filter((row) => id === row.id)[0];
69
+ if (!correspondingRowEl.locked) {
70
+ list.push(id);
71
+ }
72
+ });
73
+ }
74
+ else if (this.tagInputType === "dropdown") {
75
+ list = this.tagsList;
76
+ }
77
+ return list;
78
+ }
79
+ get tagLimitReached() {
80
+ return !!(this.maxTags && this.tagsList.length >= this.maxTags);
81
+ }
82
+ get noResultsMessage() {
83
+ return intl.formatMessage({
84
+ id: "tagInput.noResults",
85
+ defaultMessage: "No results match your search.",
86
+ description: "Message displayed when a user's search returns empty.",
87
+ });
88
+ }
89
+ get componentMessages() {
90
+ const addNewHelpText = intl.formatMessage({
91
+ id: "tagInput.addNewHelpText",
92
+ defaultMessage: "Press the Enter or Comma key to add a new tag.",
93
+ description: "Help text appearing in a dropdown. Use imperative",
94
+ });
95
+ const selectionHelpText = intl.formatMessage({
96
+ id: "tagInput.selectionHelpText",
97
+ defaultMessage: "Search and select a tag.",
98
+ description: "Help text appearing in a dropdown. Use imperative",
99
+ });
100
+ const maxTagsReachedMessage = intl.formatMessage({
101
+ id: "tagInput.maxTagsReached",
102
+ defaultMessage: "No more tags can be added because the limit has been reached.",
103
+ });
104
+ const tagAreaInstructions = intl.formatMessage({
105
+ id: "tagInput.tagAreaInstructions",
106
+ defaultMessage: "tag selection. Press Backspace or Delete to remove a tag.",
107
+ });
108
+ const tagsAddedMessage = intl.formatMessage({
109
+ id: "tagInput.tagsAdded",
110
+ defaultMessage: "Tags added",
111
+ description: "For the user to understand how close they are to the tag limit, followed by x/y count",
112
+ });
113
+ const defaultConfig = {
114
+ addNewHelpText: addNewHelpText,
115
+ selectionHelpText: selectionHelpText,
116
+ maxTagsReached: maxTagsReachedMessage,
117
+ tagAreaInstructions: tagAreaInstructions,
118
+ tagsAdded: tagsAddedMessage,
119
+ };
120
+ const userProvidedConfig = safeParseJSON(this.messageConfig);
121
+ return userProvidedConfig ? Object.assign(Object.assign({}, defaultConfig), userProvidedConfig) : defaultConfig;
122
+ }
123
+ get inputMinimumWidth() {
124
+ // 150px is the minimum width of the input field, or the length of the placeholder text
125
+ const inputElStyles = getComputedStyle(this.inputEl);
126
+ const tagElStyles = getComputedStyle(this.tagEls[this.tagEls.length - 1]);
127
+ const inputElBuffer = [
128
+ inputElStyles.paddingLeft,
129
+ inputElStyles.paddingRight,
130
+ inputElStyles.marginLeft,
131
+ inputElStyles.marginRight,
132
+ tagElStyles.marginRight,
133
+ ].reduce((prev, curr) => prev + parseInt(curr.replace("px", "")), 0);
134
+ const minimumWidth = Math.max(150, measureText(this.inputEl, this.placeholder).width + inputElBuffer);
135
+ return minimumWidth;
136
+ }
137
+ generateTagAddedMessage(tag) {
138
+ return intl.formatMessage({
139
+ id: "tagInput.tagAdded",
140
+ defaultMessage: "{tagName} added.",
141
+ description: "A confirmation for adding a tag.",
142
+ }, { tagName: tag });
143
+ }
144
+ generateTagAlreadyAddedMessage(tag) {
145
+ return intl.formatMessage({
146
+ id: "tagInput.tagAlreadyAdded",
147
+ defaultMessage: "{tagName} has already been added.",
148
+ description: "An alert for adding a tag that is already present.",
149
+ }, { tagName: tag });
150
+ }
151
+ componentWillLoad() {
152
+ if (!this.placeholder) {
153
+ this.placeholder = this.createPlaceholderDefault(this.addNew, !!this.options);
154
+ }
155
+ if (!this.label) {
156
+ console.error("wm-tag-input must have a label property");
157
+ }
158
+ this.consolidateSelectedTags();
159
+ this.el.focus = () => {
160
+ const firstFocusableTag = this.nonLockedTagEls[0];
161
+ if (firstFocusableTag) {
162
+ this.tagAreaEl.focus();
163
+ this.focusTag(firstFocusableTag);
164
+ }
165
+ else {
166
+ this.inputEl.focus();
167
+ }
168
+ };
169
+ // on resize of component, trigger componentDidRender -> positionInput
170
+ const resizeObserver = new ResizeObserver(() => this.debouncedUpdate());
171
+ resizeObserver.observe(this.el);
172
+ }
173
+ componentDidLoad() {
174
+ // prevent highlighting of pre-selected tags
175
+ this.tagEls.forEach((el) => el.classList.remove("highlight"));
176
+ }
177
+ componentDidRender() {
178
+ this.positionInput();
179
+ // check each tag if truncation is needed
180
+ this.tagEls.forEach((tag) => {
181
+ const textEl = tag.querySelector(".tag-text");
182
+ const wrapper = this.el.shadowRoot.querySelector(".tags-and-input-wrapper");
183
+ const leftBound = textEl.getBoundingClientRect().left;
184
+ // the numbers represent spacing values for padding, margin, and delete icon
185
+ const rightBound = wrapper.getBoundingClientRect().right - 10 - 8 - 28;
186
+ let displayText = tag.dataset.tag;
187
+ if (this.tagInputType === "table") {
188
+ // table variant doesn't display the tag id, but the contents of the first column
189
+ const referencedRow = this.el.querySelector(`#${displayText}`);
190
+ displayText = referencedRow ? referencedRow.col1 : "";
191
+ }
192
+ textEl.textContent = truncateText(textEl, displayText, rightBound - leftBound, 5);
193
+ });
194
+ }
195
+ consolidateSelectedTags() {
196
+ this.tagsList.forEach((tag) => {
197
+ if (!this.includesCaseInsensitive(this.optionsList, tag)) {
198
+ this.options += `${this.options.length > 0 ? "," : ""}${tag}`;
199
+ }
200
+ });
201
+ this.optionsList = csvToArray(this.options);
202
+ }
203
+ createPlaceholderDefault(addNew, hasOptions) {
204
+ const addAndSearchPlaceholder = intl.formatMessage({
205
+ id: "tagInput.placeholderAddAndSearch",
206
+ defaultMessage: "Add or search for a tag",
207
+ description: "Placeholder text. Use imperative",
208
+ });
209
+ const searchPlaceholder = intl.formatMessage({
210
+ id: "tagInput.placeholderSearch",
211
+ defaultMessage: "Search and select a tag",
212
+ description: "Placeholder text. Use imperative",
213
+ });
214
+ const addPlaceholder = intl.formatMessage({
215
+ id: "tagInput.placeholderAdd",
216
+ defaultMessage: "Add a new tag",
217
+ description: "Placeholder text. Use imperative",
218
+ });
219
+ let placeholder = "";
220
+ if (addNew && hasOptions) {
221
+ placeholder = addAndSearchPlaceholder;
222
+ }
223
+ else if (!addNew && hasOptions) {
224
+ placeholder = searchPlaceholder;
225
+ }
226
+ else if (addNew) {
227
+ placeholder = addPlaceholder;
228
+ }
229
+ return placeholder;
230
+ }
231
+ reflectSelectedTags(newValue, oldValue) {
232
+ const isAddition = newValue.length > oldValue.length;
233
+ let changedTag = "";
234
+ let selectedTags = this.tagsList;
235
+ if (isAddition) {
236
+ changedTag = newValue.filter((val) => !oldValue.includes(val))[0];
237
+ }
238
+ else {
239
+ changedTag = oldValue.filter((val) => !newValue.includes(val))[0];
240
+ }
241
+ // event emitted by type table uses element references instead of strings
242
+ if (this.tagInputType === "table") {
243
+ changedTag = this.wmRowEls.filter((row) => row.id === changedTag)[0];
244
+ selectedTags = this.tagsList.map((id) => this.el.querySelector(`#${id}`));
245
+ }
246
+ this.selectedTags = this.listToCSV(this.tagsList);
247
+ let detail = { value: selectedTags, tagChanged: changedTag };
248
+ this.wmTagInputChanged.emit(detail);
249
+ }
250
+ handleErrorMessageChange() {
251
+ if (this.errorMessage) {
252
+ this.announce(this.errorMessage);
253
+ }
254
+ }
255
+ handleRowUpdate() {
256
+ forceUpdate(this.el);
257
+ }
258
+ closeIfNotElOrChild(ev) {
259
+ const isntElOrChild = ev.target !== this.el && !this.el.shadowRoot.contains(ev.target);
260
+ if (this.tagInputType === "dropdown" && isntElOrChild && this.isExpanded) {
261
+ this.closeDropdown();
262
+ }
263
+ }
264
+ // From wm-button
265
+ // we need to listen for scroll events during the capture phase because they do not bubble up
266
+ // there can be layouts where the main content has 100vh and overflows
267
+ // in these cases window will register no scroll events unless we catch on they way down
268
+ dismissTooltip() {
269
+ if (this.tooltipVisible) {
270
+ hideTooltip();
271
+ }
272
+ }
273
+ handleInputKeyDown(ev) {
274
+ if (/^.$/.test(ev.key) && this.inputEl.value.length >= this.characterLimit) {
275
+ this.announce(this.generateCharacterLimitWarning(this.inputEl.value.length, this.characterLimit));
276
+ }
277
+ // prevent keydown triggering on tag area
278
+ ev.stopPropagation();
279
+ switch (ev.key) {
280
+ case "Enter":
281
+ case ",":
282
+ ev.preventDefault();
283
+ this.handleInputEnter();
284
+ break;
285
+ case "ArrowDown":
286
+ ev.preventDefault();
287
+ this.handleInputArrowDown();
288
+ break;
289
+ case "ArrowUp":
290
+ ev.preventDefault();
291
+ this.handleInputArrowUp();
292
+ break;
293
+ case "ArrowLeft":
294
+ if (this.tagInputType === "table" && this.tablePosition.row) {
295
+ ev.preventDefault();
296
+ this.moveLeftCell();
297
+ }
298
+ break;
299
+ case "ArrowRight":
300
+ if (this.tagInputType === "table" && this.tablePosition.row) {
301
+ ev.preventDefault();
302
+ this.moveRightCell();
303
+ }
304
+ break;
305
+ case "Escape":
306
+ if (this.tagInputType === "dropdown" && this.isExpanded) {
307
+ this.closeDropdown();
308
+ }
309
+ break;
310
+ case "ArrowLeft":
311
+ case "Backspace":
312
+ this.handleInputBackspace();
313
+ break;
314
+ }
315
+ }
316
+ handleInputFocus() {
317
+ if (this.tagInputType === "dropdown") {
318
+ this.openDropdown();
319
+ this.clearListItemFocus();
320
+ }
321
+ // force update needed to apply styled state of field-wrapper el
322
+ forceUpdate(this.el);
323
+ }
324
+ handleInputChanged(value) {
325
+ this.charCount = value.length;
326
+ if (this.tagInputType === "dropdown") {
327
+ this.clearListItemFocus();
328
+ if (this.charCount >= this.characterLimit - 5) {
329
+ this.announce(this.generateCharacterLimitWarning(this.charCount, this.characterLimit));
330
+ }
331
+ if (!this.isExpanded) {
332
+ this.openDropdown();
333
+ }
334
+ }
335
+ else if (this.tagInputType === "table") {
336
+ this.clearCellFocus();
337
+ }
338
+ this.announceExistingOptions();
339
+ }
340
+ handleInputEnter() {
341
+ if (this.tagInputType === "dropdown") {
342
+ if (this.focusedListItem) {
343
+ this.handleListItemClick(this.focusedListItem);
344
+ }
345
+ else {
346
+ this.submitInput(this.addNew, this.inputEl.value.trim());
347
+ }
348
+ }
349
+ else if (this.tagInputType === "table" && this.tablePosition.row > 0) {
350
+ this.handleTableRowClick(this.localRowEls[this.tablePosition.row].id);
351
+ }
352
+ }
353
+ submitInput(canAddNew, value) {
354
+ const hasNonWhiteSpaceCharacters = value.match(/\S/);
355
+ if (canAddNew && hasNonWhiteSpaceCharacters) {
356
+ this.addTag(value);
357
+ this.optionsList = this.addOption(value);
358
+ this.resetInput();
359
+ }
360
+ }
361
+ handleInputArrowDown() {
362
+ if (this.tagInputType === "table") {
363
+ this.moveDownRow();
364
+ }
365
+ else if (this.tagInputType === "dropdown" && this.isExpanded) {
366
+ this.moveDownListItem();
367
+ }
368
+ else if (this.tagInputType === "dropdown") {
369
+ this.openDropdown();
370
+ }
371
+ }
372
+ handleInputArrowUp() {
373
+ if (this.tagInputType === "table") {
374
+ this.moveUpRow();
375
+ }
376
+ else if (this.tagInputType === "dropdown" && this.isExpanded) {
377
+ this.moveUpListItem();
378
+ }
379
+ else if (this.tagInputType === "dropdown") {
380
+ this.openDropdown();
381
+ }
382
+ }
383
+ handleInputBackspace() {
384
+ if (this.inputEl.value === "" && this.tagsList.length > 0) {
385
+ // wait for events to finish firing before redirecting focus
386
+ // prevents double input in input area and tag area
387
+ window.requestAnimationFrame(() => {
388
+ if (this.nonLockedTagsList.length > 0) {
389
+ this.tagAreaEl.focus();
390
+ this.focusTag(this.tagEls[this.tagEls.length - 1]);
391
+ }
392
+ });
393
+ }
394
+ }
395
+ handleListItemKeyDown(ev) {
396
+ const typedEvTarget = ev.target;
397
+ switch (ev.key) {
398
+ case "Enter":
399
+ case " ":
400
+ ev.preventDefault();
401
+ typedEvTarget.click();
402
+ break;
403
+ case "ArrowDown":
404
+ ev.preventDefault();
405
+ this.moveDownListItem();
406
+ break;
407
+ case "ArrowUp":
408
+ ev.preventDefault();
409
+ this.moveUpListItem();
410
+ break;
411
+ case "Escape":
412
+ if (this.focusedElement !== this.inputEl) {
413
+ this.inputEl.focus();
414
+ }
415
+ else if (this.tagInputType === "dropdown") {
416
+ this.closeDropdown();
417
+ }
418
+ break;
419
+ }
420
+ }
421
+ handleListItemClick(item) {
422
+ const tag = item.dataset.option.trim() || "";
423
+ if (this.includesCaseInsensitive(this.tagsList, tag)) {
424
+ this.announce(this.generateTagAlreadyAddedMessage(tag));
425
+ }
426
+ else {
427
+ this.resetInput();
428
+ this.addTag(tag);
429
+ this.optionsList = this.addOption(tag);
430
+ this.focusedListItem = null;
431
+ }
432
+ }
433
+ handleTableRowClick(rowId) {
434
+ const referencedRow = this.el.querySelector(`#${rowId}`);
435
+ const isLocked = referencedRow.locked;
436
+ if (!isLocked) {
437
+ if (this.includesCaseInsensitive(this.tagsList, rowId)) {
438
+ this.removeTag(rowId);
439
+ }
440
+ else if (!this.tagLimitReached) {
441
+ this.addTag(rowId);
442
+ this.resetInput();
443
+ }
444
+ }
445
+ }
446
+ handleTagAreaKeyDown(ev) {
447
+ switch (ev.key) {
448
+ case "ArrowLeft":
449
+ case "ArrowUp":
450
+ ev.preventDefault();
451
+ this.moveLeftTag();
452
+ break;
453
+ case "ArrowRight":
454
+ case "ArrowDown":
455
+ ev.preventDefault();
456
+ this.moveRightTag();
457
+ break;
458
+ case "Backspace":
459
+ case "Delete":
460
+ this.handleTagAreaDelete();
461
+ break;
462
+ }
463
+ }
464
+ handleTagAreaDelete() {
465
+ const isLocked = this.focusedTag && this.focusedTag.classList.contains("locked");
466
+ if (this.focusedTag && !isLocked) {
467
+ this.removeTag(this.focusedTag.dataset.tag);
468
+ if (this.nonLockedTagsList.length === 0) {
469
+ // focus input if no tags are left
470
+ this.inputEl.focus();
471
+ }
472
+ else {
473
+ const removingLastTag = this.focusedTag === this.tagEls[this.tagEls.length - 1];
474
+ // if removing the last tag, reassign focused tag to previous task
475
+ this.focusedTag = removingLastTag ? this.tagEls[this.tagEls.length - 2] : this.focusedTag;
476
+ this.focusTag(this.focusedTag);
477
+ }
478
+ }
479
+ }
480
+ handleBlur(ev, component) {
481
+ const isntElOrChild = ev.relatedTarget !== component && !this.el.shadowRoot.contains(ev.relatedTarget);
482
+ this.dismissTooltip();
483
+ this.clearCellFocus();
484
+ if (isntElOrChild) {
485
+ this.fieldWrapperEl.classList.remove("focused");
486
+ if (this.tagInputType === "dropdown") {
487
+ this.closeDropdown();
488
+ }
489
+ }
490
+ }
491
+ handleCellMouseEnter(ev) {
492
+ const cell = ev.target;
493
+ const contentWrapper = cell.querySelector(".cell-content-wrapper");
494
+ const isTruncated = contentWrapper.scrollWidth > contentWrapper.clientWidth;
495
+ if (isTruncated) {
496
+ // innerText is necessary vs textContent, as innerText ignores sr-only / display: none text
497
+ showTooltip("bottom", cell, cell.innerText);
498
+ }
499
+ }
500
+ handleTagAreaFocus() {
501
+ if (this.tagInputType === "dropdown") {
502
+ this.closeDropdown();
503
+ }
504
+ const firstFocusableTag = this.nonLockedTagEls[0];
505
+ firstFocusableTag && this.focusTag(firstFocusableTag);
506
+ }
507
+ handleRemoveButtonClick(tag) {
508
+ this.moveLeftTag();
509
+ this.removeTag(tag);
510
+ }
511
+ moveDownListItem() {
512
+ if (this.listItemEls.length > 0) {
513
+ const firstListItem = this.listItemEls[0];
514
+ if (!this.focusedListItem) {
515
+ this.focusListItem(firstListItem);
516
+ }
517
+ else if (this.focusedListItem.nextElementSibling) {
518
+ this.focusListItem(this.focusedListItem.nextElementSibling);
519
+ }
520
+ else {
521
+ this.focusListItem(firstListItem);
522
+ }
523
+ }
524
+ }
525
+ moveUpListItem() {
526
+ if (this.listItemEls.length > 0) {
527
+ const lastListItem = this.listItemEls[this.listItemEls.length - 1];
528
+ if (!this.focusedListItem) {
529
+ this.focusListItem(lastListItem);
530
+ }
531
+ else if (this.focusedListItem.previousElementSibling) {
532
+ this.focusListItem(this.focusedListItem.previousElementSibling);
533
+ }
534
+ else {
535
+ this.clearListItemFocus();
536
+ }
537
+ }
538
+ }
539
+ moveDownRow() {
540
+ if (this.filteredRows.length > 0) {
541
+ if (this.tablePosition.row === 0) {
542
+ this.tablePosition.row = 1;
543
+ }
544
+ else if (this.tablePosition.row === this.filteredRows.length) {
545
+ this.tablePosition.row = 1;
546
+ }
547
+ else {
548
+ this.tablePosition.row++;
549
+ }
550
+ // skip locked rows
551
+ const rowToFocus = this.wmRowEls[this.tablePosition.row - 1];
552
+ if (rowToFocus.locked) {
553
+ this.moveDownRow();
554
+ }
555
+ else {
556
+ this.focusCell(this.tablePosition);
557
+ }
558
+ }
559
+ }
560
+ moveUpRow() {
561
+ if (this.filteredRows.length > 0) {
562
+ if (this.tablePosition.row === 0) {
563
+ this.tablePosition.row = this.filteredRows.length;
564
+ }
565
+ else if (this.tablePosition.row === 1) {
566
+ this.tablePosition.row = 0;
567
+ }
568
+ else {
569
+ this.tablePosition.row--;
570
+ }
571
+ // skip locked rows
572
+ const rowToFocus = this.wmRowEls[this.tablePosition.row - 1];
573
+ if (rowToFocus && rowToFocus.locked) {
574
+ this.moveUpRow();
575
+ }
576
+ else if (rowToFocus) {
577
+ this.focusCell(this.tablePosition);
578
+ }
579
+ else {
580
+ this.clearCellFocus();
581
+ }
582
+ }
583
+ }
584
+ moveLeftCell() {
585
+ if (this.tablePosition.column != 1) {
586
+ this.tablePosition.column--;
587
+ this.focusCell(this.tablePosition);
588
+ }
589
+ }
590
+ moveRightCell() {
591
+ const numCols = csvToArray(this.colHeaders).length;
592
+ if (this.tablePosition.column < numCols) {
593
+ this.tablePosition.column++;
594
+ this.focusCell(this.tablePosition);
595
+ }
596
+ }
597
+ moveLeftTag() {
598
+ const lastTag = this.tagEls[this.tagEls.length - 1];
599
+ if (this.focusedTag && this.tagEls.includes(this.focusedTag.previousElementSibling)) {
600
+ this.focusedTag = this.focusedTag.previousElementSibling;
601
+ }
602
+ else {
603
+ this.focusedTag = lastTag;
604
+ }
605
+ // skip locked tags
606
+ if (this.focusedTag.classList.contains("locked") && this.nonLockedTagEls.length > 0) {
607
+ this.moveLeftTag();
608
+ }
609
+ else {
610
+ this.focusTag(this.focusedTag);
611
+ }
612
+ }
613
+ moveRightTag() {
614
+ const firstTag = this.tagEls[0];
615
+ if (this.focusedTag && this.tagEls.includes(this.focusedTag.nextElementSibling)) {
616
+ this.focusedTag = this.focusedTag.nextElementSibling;
617
+ }
618
+ else {
619
+ this.focusedTag = firstTag;
620
+ }
621
+ // skip locked tags
622
+ if (this.focusedTag.classList.contains("locked")) {
623
+ this.moveRightTag();
624
+ }
625
+ else {
626
+ this.focusTag(this.focusedTag);
627
+ }
628
+ }
629
+ addOption(option) {
630
+ let newOptionsList = this.optionsList;
631
+ const optionAlreadyExists = this.includesCaseInsensitive(this.optionsList, option);
632
+ if (!optionAlreadyExists) {
633
+ newOptionsList = newOptionsList.concat(option);
634
+ }
635
+ return newOptionsList;
636
+ }
637
+ removeOption(option) {
638
+ this.optionsList = this.filterCaseInsensitive(this.optionsList, option);
639
+ }
640
+ addTag(tag) {
641
+ let newTagsList = this.tagsList;
642
+ const tagAlreadyAdded = this.includesCaseInsensitive(this.tagsList, tag);
643
+ const tagExistsAsOption = this.optionsList.filter((x) => x.toLowerCase() === tag.toLowerCase())[0];
644
+ if (!tagAlreadyAdded) {
645
+ let textToAnnounce = tag;
646
+ if (this.tagInputType === "table") {
647
+ const referencedRow = this.el.querySelector(`#${tag}`);
648
+ textToAnnounce = referencedRow.col1;
649
+ }
650
+ this.announce(this.generateTagAddedMessage(textToAnnounce));
651
+ this.tagsList = newTagsList.concat(tagExistsAsOption || tag);
652
+ // if maxTags has been reached, focus should go to the tagArea
653
+ if (this.tagLimitReached) {
654
+ this.tagAreaEl.focus();
655
+ }
656
+ }
657
+ }
658
+ removeTag(tag) {
659
+ let textToAnnounce = tag;
660
+ if (this.tagInputType === "table") {
661
+ const referencedRow = this.el.querySelector(`#${tag}`);
662
+ textToAnnounce = referencedRow.col1;
663
+ }
664
+ const tagRemovedMessage = intl.formatMessage({ id: "tagInput.tagRemoved", defaultMessage: "{tag} removed" }, { tag: textToAnnounce });
665
+ this.announce(tagRemovedMessage);
666
+ this.tagsList = this.filterCaseInsensitive(this.tagsList, tag);
667
+ if (this.tagInputType === "dropdown") {
668
+ // if a tag was introduced by the user, also remove it from the dropdown options
669
+ const devOptionsList = csvToArray(this.options);
670
+ if (this.includesCaseInsensitive(this.optionsList, tag) && !this.includesCaseInsensitive(devOptionsList, tag)) {
671
+ this.removeOption(tag);
672
+ }
673
+ }
674
+ }
675
+ focusListItem(item) {
676
+ this.focusedListItem = item;
677
+ this.inputEl.setAttribute("aria-activedescendant", this.focusedListItem.id);
678
+ item.scrollIntoView({ block: "nearest" });
679
+ }
680
+ focusTag(element) {
681
+ if (element.classList.contains("locked")) {
682
+ this.focusedTag = null;
683
+ this.tagAreaEl.setAttribute("aria-activedescendant", "");
684
+ }
685
+ else {
686
+ this.focusedTag = element;
687
+ this.tagAreaEl.setAttribute("aria-activedescendant", this.focusedTag.id);
688
+ }
689
+ window.requestAnimationFrame(() => {
690
+ hideTooltip();
691
+ const textEl = element.querySelector(".tag-text");
692
+ const fullText = element.dataset.tag;
693
+ const isTruncated = fullText !== textEl.textContent && textEl.textContent.includes("...");
694
+ isTruncated && showTooltip("bottom", element, fullText);
695
+ });
696
+ }
697
+ focusCell(position) {
698
+ this.clearCellFocus(false);
699
+ if (position.row) {
700
+ const rowToFocus = this.localRowEls[position.row];
701
+ const rowCells = rowToFocus.querySelectorAll("td");
702
+ const cellToFocus = rowCells[position.column - 1];
703
+ const contentWrapper = cellToFocus.querySelector(".cell-content-wrapper");
704
+ const isTruncated = contentWrapper.scrollWidth > contentWrapper.clientWidth;
705
+ rowToFocus.classList.add("focused");
706
+ cellToFocus.classList.add("focused");
707
+ cellToFocus.scrollIntoView({ block: "nearest" });
708
+ this.inputEl.setAttribute("aria-activedescendant", cellToFocus.id);
709
+ this.dismissTooltip();
710
+ if (isTruncated) {
711
+ // innerText is necessary vs textContent, as innerText ignores sr-only / display: none text
712
+ showTooltip("bottom", cellToFocus, cellToFocus.innerText);
713
+ }
714
+ }
715
+ }
716
+ clearTagFocus() {
717
+ this.tagAreaEl.setAttribute("aria-activedescendant", "");
718
+ this.focusedTag = null;
719
+ }
720
+ clearCellFocus(resetPosition = true) {
721
+ this.inputEl.setAttribute("aria-activedescendant", "");
722
+ if (resetPosition) {
723
+ this.tablePosition = { row: 0, column: 1 };
724
+ }
725
+ this.localRowEls.forEach((row) => {
726
+ row.classList.remove("focused");
727
+ row.querySelectorAll("td").forEach((cell) => {
728
+ cell.classList.remove("focused");
729
+ });
730
+ });
731
+ }
732
+ openDropdown() {
733
+ // given an offset of -2px because the dropdown is transformed downwards to avoid overlapping the focus border
734
+ this.openUp = shouldOpenUp(this.el, this.dropdownEl, this.el.clientHeight, -2);
735
+ this.isExpanded = true;
736
+ }
737
+ closeDropdown() {
738
+ this.clearListItemFocus();
739
+ this.isExpanded = false;
740
+ }
741
+ clearListItemFocus() {
742
+ this.focusedListItem = null;
743
+ this.inputEl.setAttribute("aria-activedescendant", "");
744
+ this.listItemEls.forEach((el) => {
745
+ el.classList.remove("focused");
746
+ });
747
+ }
748
+ resetInput() {
749
+ this.charCount = 0;
750
+ this.inputEl.value = "";
751
+ }
752
+ announce(message) {
753
+ // \u00A0 is a non-breaking space character, which causes the message to be read as a new one
754
+ if (this.liveRegionEl.textContent === message) {
755
+ message += "\u00A0";
756
+ }
757
+ this.liveRegionMessage = message;
758
+ }
759
+ announceExistingOptions() {
760
+ // request animation frame to wait for re-rendering of filtered options
761
+ window.requestAnimationFrame(() => {
762
+ let numResults = 0;
763
+ if (this.tagInputType === "dropdown") {
764
+ numResults = this.optionEls.length;
765
+ }
766
+ else if (this.tagInputType === "table") {
767
+ numResults = this.filteredRows.length;
768
+ }
769
+ const existingOptionsMessage = intl.formatMessage({
770
+ id: "tagInput.existingOptions",
771
+ defaultMessage: "{num, plural, one {1 existing option.} other {# existing options.}}",
772
+ }, { num: numResults });
773
+ this.announce(existingOptionsMessage);
774
+ });
775
+ }
776
+ generateCharacterLimitWarning(charCount, charLimit) {
777
+ let message = globalMessages.getCharactersEntered(charCount, charLimit);
778
+ if (charCount >= charLimit) {
779
+ message += ` ${globalMessages.characterLimitReached}`;
780
+ }
781
+ return message;
782
+ }
783
+ positionInput() {
784
+ const lastTag = this.tagEls[this.tagEls.length - 1];
785
+ // default placement to fall back to when no tags are present, or not enough space is available
786
+ this.inputEl.style.position = "static";
787
+ this.inputEl.style.width = "100%";
788
+ if (lastTag) {
789
+ const spaceAvailable = this.tagAreaEl.getBoundingClientRect().right - lastTag.getBoundingClientRect().right;
790
+ if (spaceAvailable >= this.inputMinimumWidth) {
791
+ // because the input has right: 0px
792
+ // all thats needed to properly place it is setting position: absolute, top, and width
793
+ this.inputEl.style.position = "absolute";
794
+ this.inputEl.style.top = lastTag.offsetTop.toString() + "px";
795
+ this.inputEl.style.width =
796
+ (this.tagAreaEl.getBoundingClientRect().right - lastTag.getBoundingClientRect().right - 8).toString() + "px";
797
+ }
798
+ }
799
+ }
800
+ handleTagMouseEnter(ev) {
801
+ const displayedText = ev.target.querySelector(".tag-text").textContent;
802
+ const fullText = ev.target.dataset.tag;
803
+ const isTruncated = displayedText !== fullText && displayedText.includes("...");
804
+ isTruncated && showTooltip("bottom", ev.target, fullText);
805
+ }
806
+ /// Helpers
807
+ listToCSV(list) {
808
+ return list.join(",");
809
+ }
810
+ includesCaseInsensitive(list, element) {
811
+ const lowercaseList = list.map((str) => str.toLowerCase());
812
+ return lowercaseList.includes(element.toLowerCase());
813
+ }
814
+ filterCaseInsensitive(list, element) {
815
+ return list.filter((x) => x.toLowerCase() !== element.toLowerCase());
816
+ }
817
+ sortCaseInsensitive(list) {
818
+ // The vanilla .sort method places words that start with capital letters above others (ASCII order)
819
+ // so we need to pass in our own compare function to sort case-insensitive
820
+ return list.sort((a, b) => {
821
+ a = a.toLowerCase();
822
+ b = b.toLowerCase();
823
+ return a > b ? 1 : a < b ? -1 : 0;
824
+ });
825
+ }
826
+ /// Renders
827
+ renderTags() {
828
+ let lockedTags = [];
829
+ let unlockedTags = [];
830
+ this.tagsList.forEach((tag, idx) => {
831
+ const id = `tag${idx + 1}`;
832
+ let tagText = "";
833
+ let isLocked = false;
834
+ if (this.tagInputType === "dropdown") {
835
+ tagText = tag;
836
+ }
837
+ else if (this.tagInputType === "table") {
838
+ // display table tags using col1 of the row with the same id
839
+ // if one can't be found, display as empty
840
+ const referencedRow = this.el.querySelector(`#${tag}`);
841
+ tagText = referencedRow ? referencedRow.col1 : "";
842
+ isLocked = referencedRow ? referencedRow.locked : false;
843
+ }
844
+ // make sure locked tags always appear in front of list
845
+ const targetList = isLocked ? lockedTags : unlockedTags;
846
+ targetList.push(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: hideTooltip }, h("span", { class: "sr-only" }, tag), h("span", { class: "tag-text", "aria-hidden": "true" }, tagText), isLocked ? (h("div", { class: "icon lock" })) : (h("button", { class: "icon remove-btn", tabIndex: -1, onClick: () => this.handleRemoveButtonClick(tag) }))));
847
+ });
848
+ return [...lockedTags, ...unlockedTags];
849
+ }
850
+ renderDropdown() {
851
+ return (h("div", { class: `dropdown-wrapper ${this.isExpanded ? "open" : ""} ${this.openUp ? "upwards" : ""}`, ref: (el) => (this.dropdownEl = el) }, h("div", { id: "help-text", class: "help-text" }, this.renderHelpText()), 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))));
852
+ }
853
+ renderListItems(optionsList) {
854
+ optionsList = this.sortCaseInsensitive(optionsList);
855
+ // filter by input
856
+ if (this.inputEl && this.inputEl.value) {
857
+ optionsList = this.optionsList.filter((option) => option.toLowerCase().includes(this.inputEl.value.toLowerCase()));
858
+ }
859
+ return optionsList.map((option, idx) => {
860
+ const id = `option${idx + 1}`;
861
+ const isFocused = this.focusedListItem && this.focusedListItem.id === id;
862
+ const isSelected = this.includesCaseInsensitive(this.tagsList, option);
863
+ return (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));
864
+ });
865
+ }
866
+ renderAddNewButton() {
867
+ const hasNonWhiteSpaceCharacters = this.inputEl.value.match(/\S/);
868
+ const optionAlreadyExists = this.includesCaseInsensitive(this.optionsList, this.inputEl.value.trim());
869
+ if (this.addNew && hasNonWhiteSpaceCharacters && !optionAlreadyExists) {
870
+ const id = `add-new-btn`;
871
+ const isFocused = this.focusedListItem && this.focusedListItem.id === id;
872
+ return (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()}"`));
873
+ }
874
+ else
875
+ return "";
876
+ }
877
+ renderHelpText() {
878
+ let helpText = "";
879
+ if (this.optionsList.length > 0) {
880
+ helpText += this.componentMessages.selectionHelpText;
881
+ }
882
+ if (this.addNew) {
883
+ helpText += " " + this.componentMessages.addNewHelpText;
884
+ }
885
+ return helpText;
886
+ }
887
+ renderTagCounter() {
888
+ if (this.maxTags) {
889
+ return (h("div", { class: "lower-row" }, h("div", { id: "max-tags" }, `${this.componentMessages.tagsAdded}: ${this.tagsList.length}/${this.maxTags}`, this.tagLimitReached && ` - ${this.componentMessages.maxTagsReached}`)));
890
+ }
891
+ }
892
+ renderTable() {
893
+ return (h("div", { class: "table-wrapper", onScroll: () => this.dismissTooltip() }, 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() : h("div", { class: "no-results" }, this.noResultsMessage))));
894
+ }
895
+ renderTableHeaders() {
896
+ return (h("tr", { class: "headers", role: "row" }, csvToArray(this.colHeaders).map((header, idx) => {
897
+ let overflowRule = "wrap";
898
+ if (this.colWrap && csvToArray(this.colWrap)[idx]) {
899
+ overflowRule = csvToArray(this.colWrap)[idx];
900
+ }
901
+ return (h("th", { class: `header-cell ${overflowRule}`, role: "columnheader",
902
+ // @ts-ignore
903
+ width: this.colWidths ? csvToArray(this.colWidths)[idx] : "" }, header));
904
+ })));
905
+ }
906
+ renderTableRows() {
907
+ return this.filteredRows.map((row) => {
908
+ const isSelected = this.includesCaseInsensitive(this.tagsList, row.id);
909
+ return (h("tr", { id: row.id, class: `${row.locked ? "locked" : ""} ${isSelected ? "selected" : ""}`, role: "row", onClick: () => this.handleTableRowClick(row.id) }, this.renderTableCells(row)));
910
+ });
911
+ }
912
+ renderTableCells(row) {
913
+ const colValues = [row.col1, row.col2, row.col3, row.col4].filter((val) => !!val);
914
+ const isSelected = this.includesCaseInsensitive(this.tagsList, row.id);
915
+ return colValues.map((val, idx) => {
916
+ const localId = `${row.id}-col${idx + 1}`;
917
+ let overflowRule = "wrap";
918
+ if (this.colWrap && csvToArray(this.colWrap)[idx]) {
919
+ overflowRule = csvToArray(this.colWrap)[idx];
920
+ }
921
+ return (h("td", { id: localId, role: "gridcell", "aria-describedby": `${localId}-description`, "aria-selected": isSelected.toString(), onMouseEnter: (ev) => this.handleCellMouseEnter(ev), onMouseLeave: () => this.dismissTooltip() }, h("div", { class: `cell-content-wrapper ${overflowRule}` }, val), h("div", { class: "description", id: `${localId}-description` }, row.locked ? "locked" : "")));
922
+ });
923
+ }
924
+ render() {
925
+ return (h(Host, { id: this.uid }, h("div", { class: `wrapper label-${this.labelPosition} ${this.errorMessage ? "invalid" : ""}` }, h("div", { class: "label-wrapper" }, h("label", { class: "label", htmlFor: `input${this.uid}` }, this.label, this.requiredField && (h("span", { class: "required", "aria-hidden": "true" }, "*")))), h("div", { class: `field-wrapper ${this.focusedElement ? "focused" : ""} ${this.errorMessage ? "invalid" : ""}`, ref: (el) => (this.fieldWrapperEl = el) }, h("div", { class: "upper-row" }, h("div", { class: "tags-and-input-wrapper" }, this.tagsList.length > 0 && (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) => {
926
+ this.clearTagFocus();
927
+ this.handleBlur(ev, this.el);
928
+ }, onKeyDown: (ev) => this.handleTagAreaKeyDown(ev) }, this.renderTags())), 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" ? 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) => {
929
+ this.handleBlur(ev, this.el);
930
+ }, onFocus: () => this.handleInputFocus(), onKeyDown: (ev) => this.handleInputKeyDown(ev) })), this.tagInputType === "dropdown" && (h("div", { class: "character-count" }, this.charCount, "/", this.characterLimit))), this.renderTagCounter(), this.tagInputType === "dropdown" && this.renderDropdown()), this.info && (h("div", { id: "info", class: "info-text" }, this.info)), this.errorMessage && h("div", { id: "error" }, this.errorMessage), h("div", { class: "sr-only", "aria-live": "assertive", ref: (el) => (this.liveRegionEl = el), "aria-atomic": "true" }, this.liveRegionMessage), this.tagInputType === "table" && this.renderTable())));
931
+ }
932
+ static get is() { return "wm-tag-input"; }
933
+ static get encapsulation() { return "shadow"; }
934
+ static get delegatesFocus() { return true; }
935
+ static get originalStyleUrls() {
936
+ return {
937
+ "$": ["wm-tag-input.scss"]
938
+ };
939
+ }
940
+ static get styleUrls() {
941
+ return {
942
+ "$": ["wm-tag-input.css"]
943
+ };
944
+ }
945
+ static get properties() {
946
+ return {
947
+ "label": {
948
+ "type": "string",
949
+ "mutable": false,
950
+ "complexType": {
951
+ "original": "string",
952
+ "resolved": "string",
953
+ "references": {}
954
+ },
955
+ "required": true,
956
+ "optional": false,
957
+ "docs": {
958
+ "tags": [],
959
+ "text": ""
960
+ },
961
+ "attribute": "label",
962
+ "reflect": false
963
+ },
964
+ "labelPosition": {
965
+ "type": "string",
966
+ "mutable": false,
967
+ "complexType": {
968
+ "original": "\"top\" | \"left\" | \"none\"",
969
+ "resolved": "\"left\" | \"none\" | \"top\"",
970
+ "references": {}
971
+ },
972
+ "required": false,
973
+ "optional": false,
974
+ "docs": {
975
+ "tags": [],
976
+ "text": ""
977
+ },
978
+ "attribute": "label-position",
979
+ "reflect": false,
980
+ "defaultValue": "\"top\""
981
+ },
982
+ "options": {
983
+ "type": "string",
984
+ "mutable": true,
985
+ "complexType": {
986
+ "original": "string",
987
+ "resolved": "string",
988
+ "references": {}
989
+ },
990
+ "required": false,
991
+ "optional": false,
992
+ "docs": {
993
+ "tags": [],
994
+ "text": ""
995
+ },
996
+ "attribute": "options",
997
+ "reflect": false,
998
+ "defaultValue": "\"\""
999
+ },
1000
+ "selectedTags": {
1001
+ "type": "string",
1002
+ "mutable": true,
1003
+ "complexType": {
1004
+ "original": "string",
1005
+ "resolved": "string",
1006
+ "references": {}
1007
+ },
1008
+ "required": false,
1009
+ "optional": false,
1010
+ "docs": {
1011
+ "tags": [],
1012
+ "text": ""
1013
+ },
1014
+ "attribute": "selected-tags",
1015
+ "reflect": true,
1016
+ "defaultValue": "\"\""
1017
+ },
1018
+ "info": {
1019
+ "type": "string",
1020
+ "mutable": false,
1021
+ "complexType": {
1022
+ "original": "string",
1023
+ "resolved": "string | undefined",
1024
+ "references": {}
1025
+ },
1026
+ "required": false,
1027
+ "optional": true,
1028
+ "docs": {
1029
+ "tags": [],
1030
+ "text": ""
1031
+ },
1032
+ "attribute": "info",
1033
+ "reflect": false
1034
+ },
1035
+ "errorMessage": {
1036
+ "type": "string",
1037
+ "mutable": false,
1038
+ "complexType": {
1039
+ "original": "string",
1040
+ "resolved": "string | undefined",
1041
+ "references": {}
1042
+ },
1043
+ "required": false,
1044
+ "optional": true,
1045
+ "docs": {
1046
+ "tags": [],
1047
+ "text": ""
1048
+ },
1049
+ "attribute": "error-message",
1050
+ "reflect": false
1051
+ },
1052
+ "addNew": {
1053
+ "type": "boolean",
1054
+ "mutable": false,
1055
+ "complexType": {
1056
+ "original": "boolean",
1057
+ "resolved": "boolean",
1058
+ "references": {}
1059
+ },
1060
+ "required": false,
1061
+ "optional": false,
1062
+ "docs": {
1063
+ "tags": [],
1064
+ "text": ""
1065
+ },
1066
+ "attribute": "add-new",
1067
+ "reflect": false,
1068
+ "defaultValue": "true"
1069
+ },
1070
+ "placeholder": {
1071
+ "type": "string",
1072
+ "mutable": true,
1073
+ "complexType": {
1074
+ "original": "string",
1075
+ "resolved": "string | undefined",
1076
+ "references": {}
1077
+ },
1078
+ "required": false,
1079
+ "optional": true,
1080
+ "docs": {
1081
+ "tags": [],
1082
+ "text": ""
1083
+ },
1084
+ "attribute": "placeholder",
1085
+ "reflect": false
1086
+ },
1087
+ "requiredField": {
1088
+ "type": "boolean",
1089
+ "mutable": false,
1090
+ "complexType": {
1091
+ "original": "boolean",
1092
+ "resolved": "boolean",
1093
+ "references": {}
1094
+ },
1095
+ "required": false,
1096
+ "optional": false,
1097
+ "docs": {
1098
+ "tags": [],
1099
+ "text": ""
1100
+ },
1101
+ "attribute": "required-field",
1102
+ "reflect": false,
1103
+ "defaultValue": "false"
1104
+ },
1105
+ "characterLimit": {
1106
+ "type": "number",
1107
+ "mutable": false,
1108
+ "complexType": {
1109
+ "original": "number",
1110
+ "resolved": "number",
1111
+ "references": {}
1112
+ },
1113
+ "required": false,
1114
+ "optional": false,
1115
+ "docs": {
1116
+ "tags": [],
1117
+ "text": ""
1118
+ },
1119
+ "attribute": "character-limit",
1120
+ "reflect": false,
1121
+ "defaultValue": "50"
1122
+ },
1123
+ "maxTags": {
1124
+ "type": "number",
1125
+ "mutable": false,
1126
+ "complexType": {
1127
+ "original": "number",
1128
+ "resolved": "number | undefined",
1129
+ "references": {}
1130
+ },
1131
+ "required": false,
1132
+ "optional": true,
1133
+ "docs": {
1134
+ "tags": [],
1135
+ "text": ""
1136
+ },
1137
+ "attribute": "max-tags",
1138
+ "reflect": false
1139
+ },
1140
+ "tagInputType": {
1141
+ "type": "string",
1142
+ "mutable": false,
1143
+ "complexType": {
1144
+ "original": "\"dropdown\" | \"table\"",
1145
+ "resolved": "\"dropdown\" | \"table\"",
1146
+ "references": {}
1147
+ },
1148
+ "required": false,
1149
+ "optional": false,
1150
+ "docs": {
1151
+ "tags": [],
1152
+ "text": ""
1153
+ },
1154
+ "attribute": "tag-input-type",
1155
+ "reflect": false,
1156
+ "defaultValue": "\"dropdown\""
1157
+ },
1158
+ "colHeaders": {
1159
+ "type": "string",
1160
+ "mutable": false,
1161
+ "complexType": {
1162
+ "original": "string",
1163
+ "resolved": "string",
1164
+ "references": {}
1165
+ },
1166
+ "required": true,
1167
+ "optional": false,
1168
+ "docs": {
1169
+ "tags": [],
1170
+ "text": ""
1171
+ },
1172
+ "attribute": "col-headers",
1173
+ "reflect": false
1174
+ },
1175
+ "colWidths": {
1176
+ "type": "string",
1177
+ "mutable": false,
1178
+ "complexType": {
1179
+ "original": "string",
1180
+ "resolved": "string | undefined",
1181
+ "references": {}
1182
+ },
1183
+ "required": false,
1184
+ "optional": true,
1185
+ "docs": {
1186
+ "tags": [],
1187
+ "text": ""
1188
+ },
1189
+ "attribute": "col-widths",
1190
+ "reflect": false
1191
+ },
1192
+ "colWrap": {
1193
+ "type": "string",
1194
+ "mutable": false,
1195
+ "complexType": {
1196
+ "original": "string",
1197
+ "resolved": "string | undefined",
1198
+ "references": {}
1199
+ },
1200
+ "required": false,
1201
+ "optional": true,
1202
+ "docs": {
1203
+ "tags": [],
1204
+ "text": ""
1205
+ },
1206
+ "attribute": "col-wrap",
1207
+ "reflect": false
1208
+ },
1209
+ "messageConfig": {
1210
+ "type": "string",
1211
+ "mutable": false,
1212
+ "complexType": {
1213
+ "original": "string",
1214
+ "resolved": "string",
1215
+ "references": {}
1216
+ },
1217
+ "required": false,
1218
+ "optional": false,
1219
+ "docs": {
1220
+ "tags": [],
1221
+ "text": ""
1222
+ },
1223
+ "attribute": "message-config",
1224
+ "reflect": false,
1225
+ "defaultValue": "\"\""
1226
+ }
1227
+ };
1228
+ }
1229
+ static get states() {
1230
+ return {
1231
+ "focusedListItem": {},
1232
+ "focusedTag": {},
1233
+ "tablePosition": {},
1234
+ "isExpanded": {},
1235
+ "tagsList": {},
1236
+ "optionsList": {},
1237
+ "charCount": {},
1238
+ "liveRegionMessage": {}
1239
+ };
1240
+ }
1241
+ static get events() {
1242
+ return [{
1243
+ "method": "wmTagInputChanged",
1244
+ "name": "wmTagInputChanged",
1245
+ "bubbles": true,
1246
+ "cancelable": true,
1247
+ "composed": true,
1248
+ "docs": {
1249
+ "tags": [],
1250
+ "text": ""
1251
+ },
1252
+ "complexType": {
1253
+ "original": "{\r\n value: string[] | HTMLWmTagInputRowElement[];\r\n tagChanged: string | HTMLWmTagInputRowElement;\r\n }",
1254
+ "resolved": "{ value: string[] | HTMLWmTagInputRowElement[]; tagChanged: string | HTMLWmTagInputRowElement; }",
1255
+ "references": {
1256
+ "HTMLWmTagInputRowElement": {
1257
+ "location": "global"
1258
+ }
1259
+ }
1260
+ }
1261
+ }];
1262
+ }
1263
+ static get elementRef() { return "el"; }
1264
+ static get watchers() {
1265
+ return [{
1266
+ "propName": "tagsList",
1267
+ "methodName": "reflectSelectedTags"
1268
+ }, {
1269
+ "propName": "errorMessage",
1270
+ "methodName": "handleErrorMessageChange"
1271
+ }];
1272
+ }
1273
+ static get listeners() {
1274
+ return [{
1275
+ "name": "wmTagInputRowUpdated",
1276
+ "method": "handleRowUpdate",
1277
+ "target": undefined,
1278
+ "capture": false,
1279
+ "passive": false
1280
+ }, {
1281
+ "name": "click",
1282
+ "method": "closeIfNotElOrChild",
1283
+ "target": "document",
1284
+ "capture": false,
1285
+ "passive": false
1286
+ }, {
1287
+ "name": "scroll",
1288
+ "method": "dismissTooltip",
1289
+ "target": "window",
1290
+ "capture": true,
1291
+ "passive": true
1292
+ }];
1293
+ }
1294
+ }