@watermarkinsights/ripple 3.27.0 → 3.27.1

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