@watermarkinsights/ripple 3.5.2 → 3.6.0-0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (172) hide show
  1. package/README.md +3 -3
  2. package/dist/cjs/{functions-8fb310fe.js → functions-653e695c.js} +442 -442
  3. package/dist/cjs/{global-fe8e4bb7.js → global-e676a97a.js} +65 -65
  4. package/dist/cjs/{http-service-9e8c4dd5.js → http-service-494d81de.js} +49 -49
  5. package/dist/cjs/{interfaces-30a74c1f.js → interfaces-a3338581.js} +29 -29
  6. package/dist/cjs/loader.cjs.js +2 -2
  7. package/dist/cjs/priv-chart-popover.cjs.entry.js +78 -78
  8. package/dist/cjs/priv-datepicker.cjs.entry.js +667 -667
  9. package/dist/cjs/priv-navigator-button.cjs.entry.js +18 -18
  10. package/dist/cjs/priv-navigator-item.cjs.entry.js +23 -23
  11. package/dist/cjs/ripple.cjs.js +2 -2
  12. package/dist/cjs/wm-action-menu_2.cjs.entry.js +341 -341
  13. package/dist/cjs/wm-button.cjs.entry.js +218 -218
  14. package/dist/cjs/wm-chart-slice.cjs.entry.js +13 -13
  15. package/dist/cjs/wm-chart.cjs.entry.js +474 -474
  16. package/dist/cjs/wm-datepicker.cjs.entry.js +256 -256
  17. package/dist/cjs/wm-input.cjs.entry.js +133 -133
  18. package/dist/cjs/wm-modal-footer.cjs.entry.js +31 -31
  19. package/dist/cjs/wm-modal-header.cjs.entry.js +34 -34
  20. package/dist/cjs/wm-modal.cjs.entry.js +161 -161
  21. package/dist/cjs/wm-navigator.cjs.entry.js +268 -268
  22. package/dist/cjs/wm-network-uploader.cjs.entry.js +420 -420
  23. package/dist/cjs/wm-option_2.cjs.entry.js +492 -492
  24. package/dist/cjs/wm-pagination.cjs.entry.js +167 -167
  25. package/dist/cjs/wm-search.cjs.entry.js +231 -231
  26. package/dist/cjs/wm-snackbar.cjs.entry.js +170 -170
  27. package/dist/cjs/wm-tab-item_3.cjs.entry.js +300 -300
  28. package/dist/cjs/wm-tag-input.cjs.entry.js +556 -556
  29. package/dist/cjs/wm-timepicker.cjs.entry.js +379 -379
  30. package/dist/cjs/wm-toggletip.cjs.entry.js +124 -124
  31. package/dist/cjs/wm-uploader.cjs.entry.js +356 -347
  32. package/dist/cjs/wm-wrapper.cjs.entry.js +12 -12
  33. package/dist/collection/components/wm-action-menu/wm-action-menu.js +460 -460
  34. package/dist/collection/components/wm-button/wm-button.js +485 -485
  35. package/dist/collection/components/wm-chart/priv-chart-popover/priv-chart-popover.js +232 -232
  36. package/dist/collection/components/wm-chart/wm-chart-slice.js +64 -64
  37. package/dist/collection/components/wm-chart/wm-chart.js +719 -719
  38. package/dist/collection/components/wm-datepicker/priv-datepicker/priv-datepicker.js +1015 -1015
  39. package/dist/collection/components/wm-datepicker/wm-datepicker.js +462 -462
  40. package/dist/collection/components/wm-input/wm-input.js +423 -423
  41. package/dist/collection/components/wm-menuitem/wm-menuitem.js +444 -444
  42. package/dist/collection/components/wm-modal/wm-modal-footer.js +141 -141
  43. package/dist/collection/components/wm-modal/wm-modal-header.js +92 -92
  44. package/dist/collection/components/wm-modal/wm-modal.js +459 -459
  45. package/dist/collection/components/wm-navigator/priv-navigator-button/priv-navigator-button.js +97 -97
  46. package/dist/collection/components/wm-navigator/priv-navigator-item/priv-navigator-item.js +114 -114
  47. package/dist/collection/components/wm-navigator/wm-navigator.js +468 -468
  48. package/dist/collection/components/wm-option/wm-option.js +422 -422
  49. package/dist/collection/components/wm-pagination/wm-pagination.js +368 -368
  50. package/dist/collection/components/wm-search/wm-search.js +479 -479
  51. package/dist/collection/components/wm-select/wm-select.js +718 -718
  52. package/dist/collection/components/wm-snackbar/wm-snackbar.js +297 -297
  53. package/dist/collection/components/wm-tabs/wm-tab-item/wm-tab-item.js +219 -219
  54. package/dist/collection/components/wm-tabs/wm-tab-list/wm-tab-list.js +331 -331
  55. package/dist/collection/components/wm-tabs/wm-tab-panel/wm-tab-panel.js +104 -104
  56. package/dist/collection/components/wm-tag-input/wm-tag-input.js +787 -787
  57. package/dist/collection/components/wm-timepicker/wm-timepicker.js +579 -579
  58. package/dist/collection/components/wm-toggletip/wm-toggletip.js +241 -241
  59. package/dist/collection/components/wm-uploader/wm-network-uploader/wm-network-uploader.js +753 -753
  60. package/dist/collection/components/wm-uploader/wm-uploader.css +16 -9
  61. package/dist/collection/components/wm-uploader/wm-uploader.js +790 -748
  62. package/dist/collection/components/wm-wrapper/wm-wrapper.js +27 -27
  63. package/dist/collection/dev/scripts.js +20 -20
  64. package/dist/collection/global/__mocks__/functions.js +6 -6
  65. package/dist/collection/global/functions.js +445 -445
  66. package/dist/collection/global/global.js +72 -72
  67. package/dist/collection/global/interfaces.js +49 -49
  68. package/dist/collection/global/services/__mocks__/http-service.js +130 -130
  69. package/dist/collection/global/services/http-service.js +50 -50
  70. package/dist/collection/lang/lang.js +5 -5
  71. package/dist/collection/lang/piglatin.js +93 -93
  72. package/dist/esm/{functions-c315390d.js → functions-e528c934.js} +442 -442
  73. package/dist/esm/{global-169de013.js → global-39a2f585.js} +65 -65
  74. package/dist/esm/{http-service-5d037e16.js → http-service-3dc3b3e7.js} +49 -49
  75. package/dist/esm/{interfaces-61c6305b.js → interfaces-2b97fab2.js} +29 -29
  76. package/dist/esm/loader.js +2 -2
  77. package/dist/esm/polyfills/core-js.js +0 -0
  78. package/dist/esm/polyfills/dom.js +0 -0
  79. package/dist/esm/polyfills/es5-html-element.js +0 -0
  80. package/dist/esm/polyfills/index.js +0 -0
  81. package/dist/esm/polyfills/system.js +0 -0
  82. package/dist/esm/priv-chart-popover.entry.js +78 -78
  83. package/dist/esm/priv-datepicker.entry.js +667 -667
  84. package/dist/esm/priv-navigator-button.entry.js +18 -18
  85. package/dist/esm/priv-navigator-item.entry.js +23 -23
  86. package/dist/esm/ripple.js +2 -2
  87. package/dist/esm/wm-action-menu_2.entry.js +341 -341
  88. package/dist/esm/wm-button.entry.js +218 -218
  89. package/dist/esm/wm-chart-slice.entry.js +13 -13
  90. package/dist/esm/wm-chart.entry.js +474 -474
  91. package/dist/esm/wm-datepicker.entry.js +256 -256
  92. package/dist/esm/wm-input.entry.js +133 -133
  93. package/dist/esm/wm-modal-footer.entry.js +31 -31
  94. package/dist/esm/wm-modal-header.entry.js +34 -34
  95. package/dist/esm/wm-modal.entry.js +161 -161
  96. package/dist/esm/wm-navigator.entry.js +268 -268
  97. package/dist/esm/wm-network-uploader.entry.js +420 -420
  98. package/dist/esm/wm-option_2.entry.js +492 -492
  99. package/dist/esm/wm-pagination.entry.js +167 -167
  100. package/dist/esm/wm-search.entry.js +231 -231
  101. package/dist/esm/wm-snackbar.entry.js +170 -170
  102. package/dist/esm/wm-tab-item_3.entry.js +300 -300
  103. package/dist/esm/wm-tag-input.entry.js +556 -556
  104. package/dist/esm/wm-timepicker.entry.js +379 -379
  105. package/dist/esm/wm-toggletip.entry.js +124 -124
  106. package/dist/esm/wm-uploader.entry.js +356 -347
  107. package/dist/esm/wm-wrapper.entry.js +12 -12
  108. package/dist/ripple/{p-c5e44367.entry.js → p-092b01f3.entry.js} +1 -1
  109. package/dist/ripple/{p-5ffa983b.entry.js → p-1e0c41a9.entry.js} +1 -1
  110. package/dist/ripple/{p-374b4fa6.entry.js → p-33524565.entry.js} +1 -1
  111. package/dist/ripple/{p-888bec42.js → p-43f1298b.js} +0 -0
  112. package/dist/ripple/{p-dea72d46.entry.js → p-4cc71463.entry.js} +1 -1
  113. package/dist/ripple/{p-e60fe2f5.js → p-588b4475.js} +0 -0
  114. package/dist/ripple/{p-b03382ea.entry.js → p-65e3a656.entry.js} +1 -1
  115. package/dist/ripple/{p-a50439f1.entry.js → p-67e288fe.entry.js} +1 -1
  116. package/dist/ripple/{p-31fde2c6.entry.js → p-690b4f41.entry.js} +1 -1
  117. package/dist/ripple/{p-75a9ba2f.entry.js → p-754d3d41.entry.js} +1 -1
  118. package/dist/ripple/{p-7bbd123c.entry.js → p-8923b7d0.entry.js} +1 -1
  119. package/dist/ripple/{p-ba9d3069.entry.js → p-8cd1396e.entry.js} +1 -1
  120. package/dist/ripple/p-a53165df.entry.js +1 -0
  121. package/dist/ripple/{p-e574fb73.entry.js → p-aa973691.entry.js} +1 -1
  122. package/dist/ripple/{p-b4a8c8d3.entry.js → p-b3d5ea85.entry.js} +1 -1
  123. package/dist/ripple/p-c9dcb2ef.js +1 -0
  124. package/dist/ripple/{p-d69c1688.entry.js → p-d8ecd974.entry.js} +1 -1
  125. package/dist/ripple/{p-41f39509.entry.js → p-dc9c9fda.entry.js} +1 -1
  126. package/dist/ripple/{p-34694011.entry.js → p-e7616311.entry.js} +1 -1
  127. package/dist/ripple/{p-36da5d4a.entry.js → p-e9e8334e.entry.js} +1 -1
  128. package/dist/ripple/{p-ec5db255.entry.js → p-ec9697db.entry.js} +1 -1
  129. package/dist/ripple/{p-c724ce54.entry.js → p-efdaf3b6.entry.js} +1 -1
  130. package/dist/ripple/{p-042d6449.entry.js → p-fcdc6395.entry.js} +1 -1
  131. package/dist/ripple/{p-a6d6eae7.js → p-fd8070fb.js} +0 -0
  132. package/dist/ripple/ripple.esm.js +1 -1
  133. package/dist/types/components/wm-action-menu/wm-action-menu.d.ts +48 -48
  134. package/dist/types/components/wm-button/wm-button.d.ts +44 -44
  135. package/dist/types/components/wm-chart/priv-chart-popover/priv-chart-popover.d.ts +23 -23
  136. package/dist/types/components/wm-chart/wm-chart-slice.d.ts +8 -8
  137. package/dist/types/components/wm-chart/wm-chart.d.ts +82 -82
  138. package/dist/types/components/wm-datepicker/priv-datepicker/priv-datepicker.d.ts +76 -76
  139. package/dist/types/components/wm-datepicker/wm-datepicker.d.ts +41 -41
  140. package/dist/types/components/wm-input/wm-input.d.ts +46 -46
  141. package/dist/types/components/wm-menuitem/wm-menuitem.d.ts +34 -34
  142. package/dist/types/components/wm-modal/wm-modal-footer.d.ts +15 -15
  143. package/dist/types/components/wm-modal/wm-modal-header.d.ts +12 -12
  144. package/dist/types/components/wm-modal/wm-modal.d.ts +41 -41
  145. package/dist/types/components/wm-navigator/priv-navigator-button/priv-navigator-button.d.ts +10 -10
  146. package/dist/types/components/wm-navigator/priv-navigator-item/priv-navigator-item.d.ts +13 -13
  147. package/dist/types/components/wm-navigator/wm-navigator.d.ts +61 -61
  148. package/dist/types/components/wm-option/wm-option.d.ts +32 -32
  149. package/dist/types/components/wm-pagination/wm-pagination.d.ts +32 -32
  150. package/dist/types/components/wm-search/wm-search.d.ts +86 -86
  151. package/dist/types/components/wm-select/wm-select.d.ts +66 -66
  152. package/dist/types/components/wm-snackbar/wm-snackbar.d.ts +35 -35
  153. package/dist/types/components/wm-tabs/wm-tab-item/wm-tab-item.d.ts +38 -38
  154. package/dist/types/components/wm-tabs/wm-tab-list/wm-tab-list.d.ts +53 -53
  155. package/dist/types/components/wm-tabs/wm-tab-panel/wm-tab-panel.d.ts +20 -20
  156. package/dist/types/components/wm-tag-input/wm-tag-input.d.ts +91 -91
  157. package/dist/types/components/wm-timepicker/wm-timepicker.d.ts +61 -61
  158. package/dist/types/components/wm-toggletip/wm-toggletip.d.ts +27 -27
  159. package/dist/types/components/wm-uploader/wm-network-uploader/wm-network-uploader.d.ts +85 -85
  160. package/dist/types/components/wm-uploader/wm-uploader.d.ts +82 -80
  161. package/dist/types/components/wm-wrapper/wm-wrapper.d.ts +7 -7
  162. package/dist/types/components.d.ts +28 -24
  163. package/dist/types/global/__mocks__/functions.d.ts +6 -6
  164. package/dist/types/global/functions.d.ts +40 -40
  165. package/dist/types/global/global.d.ts +1 -1
  166. package/dist/types/global/interfaces.d.ts +34 -34
  167. package/dist/types/global/services/__mocks__/http-service.d.ts +6 -6
  168. package/dist/types/global/services/http-service.d.ts +4 -4
  169. package/dist/types/lang/lang.d.ts +5 -5
  170. package/package.json +46 -46
  171. package/dist/ripple/p-5ff97329.js +0 -1
  172. package/dist/ripple/p-d5fafa9c.entry.js +0 -1
@@ -1,563 +1,563 @@
1
1
  import { r as registerInstance, c as createEvent, h, H as Host, g as getElement } from './index-66f8130e.js';
2
- import { g as generateId, i as intl, d as debounce, l as shouldOpenUp } from './functions-c315390d.js';
2
+ import { g as generateId, i as intl, d as debounce, l as shouldOpenUp } from './functions-e528c934.js';
3
3
 
4
4
  const wmTagInputCss = "@charset \"UTF-8\";:host,wm-tag-input{font-family:inherit;width:100%}:host *,wm-tag-input *{box-sizing:border-box;font-size:14px}:host .wrapper,wm-tag-input .wrapper{display:-webkit-box;display:-webkit-flex;display:-ms-flexbox;display:flex;flex-direction:column;font-size:0.875rem}:host .wrapper .label,wm-tag-input .wrapper .label{display:block;line-height:normal;font-weight:600;white-space:nowrap;margin-bottom:0.25rem}:host .wrapper .label .required,wm-tag-input .wrapper .label .required{color:#c0392b}:host .wrapper.label-left,wm-tag-input .wrapper.label-left{flex-direction:row}:host .wrapper.label-left .label-wrapper,wm-tag-input .wrapper.label-left .label-wrapper{line-height:2.5rem}:host .wrapper.label-left .label-wrapper .label,wm-tag-input .wrapper.label-left .label-wrapper .label{display:flex;align-items:center;min-height:2.5rem;white-space:normal;margin-bottom:0;margin-right:0.75rem}:host .wrapper.label-none label,wm-tag-input .wrapper.label-none label{position:absolute !important;width:1px !important;height:1px !important;padding:0 !important;border:0 !important;overflow:hidden !important;clip:rect(0, 0, 0, 0) !important;clip-path:inset(50%) !important;white-space:nowrap !important;margin:-1px !important}:host .wrapper.invalid .label,wm-tag-input .wrapper.invalid .label{color:#c0392b}:host .wrapper.invalid .label:after,wm-tag-input .wrapper.invalid .label:after{display:inline-block;font:normal normal normal 24px/1 \"Material Design Icons\";font-size:inherit;text-rendering:auto;line-height:inherit;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale;content:\"\";margin-left:0.3125rem}[dir=RTL] :host .wrapper.invalid .label:after,[dir=RTL] wm-tag-input .wrapper.invalid .label:after{margin-left:0;margin-right:0.3125rem}:host .wrapper.rtl.label-left .label,wm-tag-input .wrapper.rtl.label-left .label{margin-right:0;margin-left:0.75rem}:host .wrapper,wm-tag-input .wrapper{width:100%;position:relative}:host .field-wrapper,wm-tag-input .field-wrapper{position:relative;width:100%;min-height:2.5rem;border:1px solid #4a4a4a;-webkit-border-radius:3px;-moz-border-radius:3px;-ms-border-radius:3px;border-radius:3px}:host .field-wrapper.focused,wm-tag-input .field-wrapper.focused{-webkit-box-shadow:0 0 0 1px #20cbd4;-moz-box-shadow:0 0 0 1px #20cbd4;box-shadow:0 0 0 1px #20cbd4;outline:none;border-color:#20cbd4}:host .character-count,wm-tag-input .character-count{display:flex;align-items:center;justify-content:center;min-width:5rem;background-color:rgba(74, 74, 74, 0.05);font-size:0.875rem;font-weight:500;align-self:stretch}:host .tags-and-input-wrapper,wm-tag-input .tags-and-input-wrapper{position:relative;width:100%;padding:0.5rem 0.25rem;margin-bottom:-0.5rem}:host .upper-row,wm-tag-input .upper-row{width:100%;display:flex;flex:1;justify-content:space-between;align-items:center}:host .lower-row,wm-tag-input .lower-row{width:100%;border-radius:0 0 3px 3px}:host #max-tags,wm-tag-input #max-tags{display:flex;align-items:center;height:1.875rem;background-color:#6b6b6b;padding:0.5rem 1rem;color:white;font-size:0.875rem}:host .tag-area,wm-tag-input .tag-area{display:flex;flex-wrap:wrap;margin:0;padding:0}:host .tag-area:focus,wm-tag-input .tag-area:focus{outline:none}:host .tag-area [role=option],wm-tag-input .tag-area [role=option]{display:inline-flex;align-items:center;height:1.75rem;list-style:none;color:#4a4a4a;background-color:rgba(3, 0, 0, 0.1);padding:0.5rem 0.625rem;margin-bottom:0.5rem;margin-right:0.25rem;margin-left:0.25rem;transition:background-color 0.3s cubic-bezier(0.4, 0, 0.2, 1);white-space:pre}:host .tag-area [role=option].highlight,wm-tag-input .tag-area [role=option].highlight{animation:fadeIn 1s}@keyframes fadeIn{0%{background-color:rgba(3, 0, 0, 0.1)}50%{background-color:#c8dfcc}100%{background-color:rgba(3, 0, 0, 0.1)}}:host .tag-area [role=option].focused,wm-tag-input .tag-area [role=option].focused{background-color:#d1d1d1}:host .tag-area [role=option] .remove-btn,wm-tag-input .tag-area [role=option] .remove-btn{display:inline-flex;justify-content:center;align-items:center;height:1.25rem;width:1.25rem;border:1px solid #575195;color:#575195;border-radius:50%;padding:0;margin-left:0.5rem;cursor:pointer;transition:background-color 500ms cubic-bezier(0.4, 0, 0.2, 1), color 500ms cubic-bezier(0.4, 0, 0.2, 1)}:host .tag-area [role=option] .remove-btn:hover,wm-tag-input .tag-area [role=option] .remove-btn:hover{color:white;background-color:#575195}:host .tag-area [role=option] .remove-btn:before,wm-tag-input .tag-area [role=option] .remove-btn:before{display:inline-block;font:normal normal normal 24px/1 \"Material Design Icons\";font-size:inherit;text-rendering:auto;line-height:inherit;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale;content:\"\"}:host input,wm-tag-input input{font-family:inherit;border:none;height:1.75rem;padding:0;margin-bottom:0.5rem;margin-right:0.25rem;padding-left:0.5rem;right:0px}:host input.hidden,wm-tag-input input.hidden{display:none}:host input:focus,wm-tag-input input:focus{outline:none}:host .dropdown-wrapper,wm-tag-input .dropdown-wrapper{margin:0;padding:0;-webkit-box-shadow:0 4px 15px 0 rgba(0, 0, 0, 0.2);-moz-box-shadow:0 4px 15px 0 rgba(0, 0, 0, 0.2);box-shadow:0 4px 15px 0 rgba(0, 0, 0, 0.2);-ms-transition:transform 0.25s ease;-webkit-transition:transform 0.25s ease;-moz-transition:transform 0.25s ease;transition:transform 0.25s ease;-ms-transform:scale(1, 0);-webkit-transform:scale(1, 0);-moz-transform:scale(1, 0);transform:scale(1, 0);-ms-transform-origin:center top;-webkit-transform-origin:center top;-moz-transform-origin:center top;transform-origin:center top;-webkit-border-radius:3px;-moz-border-radius:3px;-ms-border-radius:3px;border-radius:3px;position:absolute;top:calc(100% + 2px);right:0;background:#fff;z-index:100;width:100%;font-size:0.875rem}:host .dropdown-wrapper .dropdown,wm-tag-input .dropdown-wrapper .dropdown{-webkit-overflow-scrolling:touch;overflow:auto;max-height:12.5rem;margin:0;padding:0}:host .dropdown-wrapper.open,wm-tag-input .dropdown-wrapper.open{-ms-transform:scale(1, 1);-webkit-transform:scale(1, 1);-moz-transform:scale(1, 1);transform:scale(1, 1)}:host .dropdown-wrapper.upwards,wm-tag-input .dropdown-wrapper.upwards{top:unset;bottom:calc(100% + 2px);-ms-transform-origin:center bottom;-webkit-transform-origin:center bottom;-moz-transform-origin:center bottom;transform-origin:center bottom}:host .dropdown-wrapper li,:host .dropdown-wrapper div,wm-tag-input .dropdown-wrapper li,wm-tag-input .dropdown-wrapper div{display:flex;align-items:center;padding:0 1rem;background:#fff;list-style:none;height:2.6875rem;white-space:pre}:host .dropdown-wrapper li[role=option],:host .dropdown-wrapper li.add-new-btn,:host .dropdown-wrapper div[role=option],:host .dropdown-wrapper div.add-new-btn,wm-tag-input .dropdown-wrapper li[role=option],wm-tag-input .dropdown-wrapper li.add-new-btn,wm-tag-input .dropdown-wrapper div[role=option],wm-tag-input .dropdown-wrapper div.add-new-btn{cursor:pointer;color:#575195;font-weight:bold;width:100%;border:none}:host .dropdown-wrapper li[role=option][aria-selected=true],:host .dropdown-wrapper li.add-new-btn[aria-selected=true],:host .dropdown-wrapper div[role=option][aria-selected=true],:host .dropdown-wrapper div.add-new-btn[aria-selected=true],wm-tag-input .dropdown-wrapper li[role=option][aria-selected=true],wm-tag-input .dropdown-wrapper li.add-new-btn[aria-selected=true],wm-tag-input .dropdown-wrapper div[role=option][aria-selected=true],wm-tag-input .dropdown-wrapper div.add-new-btn[aria-selected=true]{color:#6b6b6b;font-style:italic;font-weight:normal;cursor:unset}:host .dropdown-wrapper li[role=option]:hover:not([aria-selected=true]),:host .dropdown-wrapper li[role=option].focused,:host .dropdown-wrapper li.add-new-btn:hover:not([aria-selected=true]),:host .dropdown-wrapper li.add-new-btn.focused,:host .dropdown-wrapper div[role=option]:hover:not([aria-selected=true]),:host .dropdown-wrapper div[role=option].focused,:host .dropdown-wrapper div.add-new-btn:hover:not([aria-selected=true]),:host .dropdown-wrapper div.add-new-btn.focused,wm-tag-input .dropdown-wrapper li[role=option]:hover:not([aria-selected=true]),wm-tag-input .dropdown-wrapper li[role=option].focused,wm-tag-input .dropdown-wrapper li.add-new-btn:hover:not([aria-selected=true]),wm-tag-input .dropdown-wrapper li.add-new-btn.focused,wm-tag-input .dropdown-wrapper div[role=option]:hover:not([aria-selected=true]),wm-tag-input .dropdown-wrapper div[role=option].focused,wm-tag-input .dropdown-wrapper div.add-new-btn:hover:not([aria-selected=true]),wm-tag-input .dropdown-wrapper div.add-new-btn.focused{outline:none;background:#f4f4f4}:host .dropdown-wrapper li.help-text,:host .dropdown-wrapper div.help-text,wm-tag-input .dropdown-wrapper li.help-text,wm-tag-input .dropdown-wrapper div.help-text{color:#4a4a4a;min-height:2.6875rem;padding-top:0.25rem;padding-bottom:0.25rem}:host .dropdown-wrapper li:not(:last-child),:host .dropdown-wrapper div:not(:last-child),wm-tag-input .dropdown-wrapper li:not(:last-child),wm-tag-input .dropdown-wrapper div:not(:last-child){border-bottom:2px solid rgba(46, 27, 70, 0.05)}:host .info-text,wm-tag-input .info-text{font-style:italic;margin-top:0.25rem}:host .sr-only,wm-tag-input .sr-only{position:absolute !important;width:1px !important;height:1px !important;padding:0 !important;border:0 !important;overflow:hidden !important;clip:rect(0, 0, 0, 0) !important;clip-path:inset(50%) !important;white-space:nowrap !important;margin:-1px !important}";
5
5
 
6
- const TagInput = class {
7
- constructor(hostRef) {
8
- registerInstance(this, hostRef);
9
- this.wmTagInputChanged = createEvent(this, "wmTagInputChanged", 7);
10
- this.labelPosition = "top";
11
- this.options = ""; // csv
12
- this.selectedTags = ""; // csv
13
- this.addNew = true;
14
- this.characterLimit = 50;
15
- this.uid = this.el.id ? this.el.id : generateId();
16
- this.openUp = false;
17
- this.isExpanded = false;
18
- this.tagsList = this.csvToArray(this.selectedTags);
19
- this.optionsList = this.csvToArray(this.options);
20
- this.charCount = 0;
21
- this.liveRegionMessage = "";
22
- this.tagAreaInstructions = intl.formatMessage({
23
- id: "tagInput.tagAreaInstructions",
24
- defaultMessage: "tag selection. Press Backspace or Delete to remove a tag.",
25
- });
26
- this.maxTagsReachedMessage = intl.formatMessage({
27
- id: "tagInput.maxTagsReached",
28
- defaultMessage: "The maximum amount of tags has been reached, no additional tags can be added.",
29
- });
30
- this.debouncedResize = debounce(() => {
31
- this.positionInput();
32
- }, 30);
33
- }
34
- get focusedElement() {
35
- return this.el.shadowRoot.activeElement;
36
- }
37
- get listItemEls() {
38
- return Array.from(this.dropdownEl.querySelectorAll("li"));
39
- }
40
- get tagEls() {
41
- return Array.from(this.tagAreaEl.querySelectorAll(".tag"));
42
- }
43
- get optionEls() {
44
- return Array.from(this.dropdownEl.querySelectorAll(".option"));
45
- }
46
- generateTagAddedMessage(tag) {
47
- return intl.formatMessage({
48
- id: "tagInput.tagAdded",
49
- defaultMessage: "{tagName} added.",
50
- description: "A confirmation for adding a tag.",
51
- }, { tagName: tag });
52
- }
53
- generateTagAlreadyAddedMessage(tag) {
54
- return intl.formatMessage({
55
- id: "tagInput.tagAlreadyAdded",
56
- defaultMessage: "{tagName} has already been added.",
57
- description: "An alert for adding a tag that is already present.",
58
- }, { tagName: tag });
59
- }
60
- generateTagCounterMessage(x, y) {
61
- return intl.formatMessage({
62
- id: "tagInput.tagsAddedCounter",
63
- defaultMessage: "Tags added: {x, number}/{y, number}",
64
- description: "For the user to understand how close they are to the tag limit.",
65
- }, {
66
- x: x,
67
- y: y,
68
- });
69
- }
70
- componentWillLoad() {
71
- if (!this.placeholder) {
72
- this.placeholder = this.createPlaceholderDefault(this.addNew, !!this.options);
73
- }
74
- if (!this.label) {
75
- console.error("wm-tag-input must have a label property");
76
- }
77
- this.consolidateSelectedTags();
78
- }
79
- componentDidLoad() {
80
- // prevent highlighting of pre-selected tags
81
- this.tagEls.forEach((el) => el.classList.remove("highlight"));
82
- }
83
- componentDidRender() {
84
- this.positionInput();
85
- }
86
- consolidateSelectedTags() {
87
- this.tagsList.forEach((tag) => {
88
- if (!this.includesCaseInsensitive(this.optionsList, tag)) {
89
- this.options += `${this.options.length > 0 ? "," : ""}${tag}`;
90
- }
91
- });
92
- this.optionsList = this.csvToArray(this.options);
93
- }
94
- createPlaceholderDefault(addNew, hasOptions) {
95
- const addAndSearchPlaceholder = intl.formatMessage({
96
- id: "tagInput.placeholderAddAndSearch",
97
- defaultMessage: "Add or search for a tag",
98
- });
99
- const searchPlaceholder = intl.formatMessage({
100
- id: "tagInput.placeholderSearch",
101
- defaultMessage: "Search and select a tag",
102
- });
103
- const addPlaceholder = intl.formatMessage({
104
- id: "tagInput.placeholderAdd",
105
- defaultMessage: "Add a new tag",
106
- });
107
- let placeholder = "";
108
- if (addNew && hasOptions) {
109
- placeholder = addAndSearchPlaceholder;
110
- }
111
- else if (!addNew && hasOptions) {
112
- placeholder = searchPlaceholder;
113
- }
114
- else if (addNew) {
115
- placeholder = addPlaceholder;
116
- }
117
- return placeholder;
118
- }
119
- reflectSelectedTags() {
120
- this.selectedTags = this.listToCSV(this.tagsList);
121
- this.wmTagInputChanged.emit({ value: this.tagsList });
122
- }
123
- closeIfNotElOrChild(ev) {
124
- const isntElOrChild = ev.target !== this.el && !this.el.shadowRoot.contains(ev.target);
125
- if (isntElOrChild && this.isExpanded) {
126
- this.closeDropdown();
127
- }
128
- }
129
- handleResize() {
130
- this.debouncedResize();
131
- }
132
- handleInputKeyDown(ev) {
133
- if (/^.$/.test(ev.key) && this.inputEl.value.length >= this.characterLimit) {
134
- this.announceCharacterLimitWarning(this.inputEl.value.length, this.characterLimit);
135
- }
136
- // prevent keydown triggering on tag area
137
- ev.stopPropagation();
138
- switch (ev.key) {
139
- case "Enter":
140
- case ",":
141
- ev.preventDefault();
142
- this.submitInput(this.addNew, this.inputEl.value.trim());
143
- break;
144
- case "ArrowDown":
145
- ev.preventDefault();
146
- this.handleInputArrowDown();
147
- break;
148
- case "ArrowUp":
149
- ev.preventDefault();
150
- this.handleInputArrowUp();
151
- break;
152
- case "Escape":
153
- if (this.isExpanded) {
154
- this.closeDropdown();
155
- }
156
- break;
157
- case "ArrowLeft":
158
- case "Backspace":
159
- this.handleInputBackspace();
160
- break;
161
- }
162
- }
163
- handleInputChanged(value) {
164
- this.charCount = value.length;
165
- if (this.charCount >= this.characterLimit - 5) {
166
- this.announceCharacterLimitWarning(this.charCount, this.characterLimit);
167
- }
168
- this.announceExistingOptions();
169
- if (!this.isExpanded) {
170
- this.openDropdown();
171
- }
172
- }
173
- submitInput(canAddNew, value) {
174
- const hasNonWhiteSpaceCharacters = value.match(/\S/);
175
- if (canAddNew && hasNonWhiteSpaceCharacters) {
176
- this.tagsList = this.addTag(value);
177
- this.optionsList = this.addOption(value);
178
- this.resetInput();
179
- // if maxTags has been reached, focus should go to the tagArea instead of the input
180
- if (this.maxTags && this.tagsList.length >= this.maxTags) {
181
- this.tagAreaEl.focus();
182
- }
183
- }
184
- }
185
- handleInputArrowDown() {
186
- if (this.isExpanded) {
187
- this.moveDownListItem();
188
- }
189
- else {
190
- this.openDropdown();
191
- }
192
- }
193
- handleInputArrowUp() {
194
- if (this.isExpanded) {
195
- this.moveUpListItem();
196
- }
197
- else {
198
- this.openDropdown();
199
- }
200
- }
201
- handleInputBackspace() {
202
- if (this.inputEl.value === "" && this.tagsList.length > 0) {
203
- // wait for events to finish firing before redirecting focus
204
- // prevents double input in input area and tag area
205
- window.requestAnimationFrame(() => {
206
- this.tagAreaEl.focus();
207
- this.focusTag(this.tagEls[this.tagEls.length - 1]);
208
- });
209
- }
210
- }
211
- handleListItemKeyDown(ev) {
212
- const typedEvTarget = ev.target;
213
- switch (ev.key) {
214
- case "Enter":
215
- case " ":
216
- ev.preventDefault();
217
- typedEvTarget.click();
218
- break;
219
- case "ArrowDown":
220
- ev.preventDefault();
221
- this.moveDownListItem();
222
- break;
223
- case "ArrowUp":
224
- ev.preventDefault();
225
- this.moveUpListItem();
226
- break;
227
- case "Escape":
228
- if (this.focusedElement !== this.inputEl) {
229
- this.inputEl.focus();
230
- }
231
- else {
232
- this.closeDropdown();
233
- }
234
- break;
235
- }
236
- }
237
- handleListItemClick(ev) {
238
- const typedEvTarget = ev.target;
239
- const tag = typedEvTarget.dataset.option.trim() || "";
240
- if (this.includesCaseInsensitive(this.tagsList, tag)) {
241
- this.announce(this.generateTagAlreadyAddedMessage(tag));
242
- }
243
- else {
244
- this.announce(this.generateTagAddedMessage(tag));
245
- this.resetInput();
246
- this.tagsList = this.addTag(tag);
247
- this.optionsList = this.addOption(tag);
248
- this.focusedListItem = null;
249
- // if maxTags has been reached, focus should go to the tagArea instead of the input
250
- const elementToFocus = this.maxTags && this.tagsList.length >= this.maxTags ? this.tagAreaEl : this.inputEl;
251
- elementToFocus.focus();
252
- }
253
- }
254
- handleTagAreaKeyDown(ev) {
255
- switch (ev.key) {
256
- case "ArrowLeft":
257
- case "ArrowUp":
258
- ev.preventDefault();
259
- this.moveLeftTag();
260
- break;
261
- case "ArrowRight":
262
- case "ArrowDown":
263
- ev.preventDefault();
264
- this.moveRightTag();
265
- break;
266
- case "Backspace":
267
- case "Delete":
268
- this.handleTagAreaDelete();
269
- break;
270
- }
271
- }
272
- handleTagAreaDelete() {
273
- if (this.focusedTag && this.focusedTag.dataset.tag) {
274
- this.removeTag(this.focusedTag.dataset.tag);
275
- if (this.tagsList.length === 0) {
276
- // focus input if no tags are left
277
- this.inputEl.focus();
278
- }
279
- else if (this.focusedTag === this.tagEls[this.tagEls.length - 1]) {
280
- // reassign focus if removing the last tag but there are still tags remaining
281
- this.focusedTag = this.tagEls[this.tagEls.length - 2];
282
- this.focusTag(this.focusedTag);
283
- }
284
- }
285
- }
286
- handleBlur(ev, component) {
287
- const isntElOrChild = ev.relatedTarget !== component && !this.el.shadowRoot.contains(ev.relatedTarget);
288
- if (isntElOrChild) {
289
- this.closeDropdown();
290
- this.fieldWrapperEl.classList.remove("focused");
291
- }
292
- }
293
- handleTagAreaFocus() {
294
- this.closeDropdown();
295
- if (!this.focusedTag) {
296
- this.focusedTag = this.tagEls[0];
297
- }
298
- this.focusTag(this.focusedTag);
299
- }
300
- handleRemoveButtonClick(tag) {
301
- this.moveLeftTag();
302
- this.removeTag(tag);
303
- }
304
- moveDownListItem() {
305
- if (this.listItemEls.length > 0) {
306
- const firstListItem = this.listItemEls[0];
307
- if (!this.focusedListItem) {
308
- this.focusListItem(firstListItem);
309
- }
310
- else if (this.focusedListItem.nextElementSibling) {
311
- this.focusListItem(this.focusedListItem.nextElementSibling);
312
- }
313
- else {
314
- this.focusListItem(firstListItem);
315
- }
316
- }
317
- }
318
- moveUpListItem() {
319
- if (this.listItemEls.length > 0) {
320
- const lastListItem = this.listItemEls[this.listItemEls.length - 1];
321
- if (!this.focusedListItem) {
322
- this.focusListItem(lastListItem);
323
- }
324
- else if (this.focusedListItem.previousElementSibling) {
325
- this.focusListItem(this.focusedListItem.previousElementSibling);
326
- }
327
- else {
328
- this.focusedListItem = null;
329
- this.inputEl.focus();
330
- }
331
- }
332
- }
333
- moveLeftTag() {
334
- const lastTag = this.tagEls[this.tagEls.length - 1];
335
- if (this.focusedTag && this.tagEls.includes(this.focusedTag.previousElementSibling)) {
336
- this.focusedTag = this.focusedTag.previousElementSibling;
337
- }
338
- else {
339
- this.focusedTag = lastTag;
340
- }
341
- this.focusTag(this.focusedTag);
342
- }
343
- moveRightTag() {
344
- const firstTag = this.tagEls[0];
345
- if (this.focusedTag && this.tagEls.includes(this.focusedTag.nextElementSibling)) {
346
- this.focusedTag = this.focusedTag.nextElementSibling;
347
- }
348
- else {
349
- this.focusedTag = firstTag;
350
- }
351
- this.focusTag(this.focusedTag);
352
- }
353
- addOption(option) {
354
- let newOptionsList = this.optionsList;
355
- const optionAlreadyExists = this.includesCaseInsensitive(this.optionsList, option);
356
- if (!optionAlreadyExists) {
357
- newOptionsList = newOptionsList.concat(option);
358
- }
359
- return newOptionsList;
360
- }
361
- removeOption(option) {
362
- this.optionsList = this.filterCaseInsensitive(this.optionsList, option);
363
- }
364
- addTag(tag) {
365
- let newTagsList = this.tagsList;
366
- const tagAlreadyAdded = this.includesCaseInsensitive(this.tagsList, tag);
367
- const tagExistsAsOption = this.optionsList.filter((x) => x.toLowerCase() === tag.toLowerCase())[0];
368
- if (!tagAlreadyAdded) {
369
- this.announce(this.generateTagAddedMessage(tag));
370
- newTagsList = newTagsList.concat(tagExistsAsOption || tag);
371
- }
372
- return newTagsList;
373
- }
374
- removeTag(tag) {
375
- const tagRemovedMessage = intl.formatMessage({ id: "tagInput.tagRemoved", defaultMessage: "{tag} removed" }, { tag: tag });
376
- this.announce(tagRemovedMessage);
377
- this.tagsList = this.filterCaseInsensitive(this.tagsList, tag);
378
- const devOptionsList = this.csvToArray(this.options);
379
- if (this.includesCaseInsensitive(this.optionsList, tag) && !this.includesCaseInsensitive(devOptionsList, tag)) {
380
- this.removeOption(tag);
381
- }
382
- }
383
- focusListItem(item) {
384
- this.focusedListItem = item;
385
- item.focus();
386
- }
387
- focusTag(element) {
388
- this.focusedTag = element;
389
- this.tagAreaEl.setAttribute("aria-activedescendant", this.focusedTag.id);
390
- }
391
- clearTagFocus() {
392
- this.tagAreaEl.removeAttribute("aria-activedescendant");
393
- this.focusedTag = null;
394
- }
395
- openDropdown() {
396
- // given an offset of -2px because the dropdown is transformed downwards to avoid overlapping the focus border
397
- this.openUp = shouldOpenUp(this.el, this.dropdownEl, this.el.clientHeight, -2);
398
- this.isExpanded = true;
399
- }
400
- closeDropdown() {
401
- this.focusedListItem = null;
402
- this.isExpanded = false;
403
- }
404
- clearListItemFocus() {
405
- this.focusedListItem = null;
406
- this.listItemEls.forEach((el) => {
407
- el.tabIndex = -1;
408
- el.classList.remove("focused");
409
- });
410
- }
411
- resetInput() {
412
- this.charCount = 0;
413
- this.inputEl.value = "";
414
- }
415
- announce(message) {
416
- // \u00A0 is a non-breaking space character, which causes the message to be read as a new one
417
- if (this.liveRegionEl.textContent === message) {
418
- message += "\u00A0";
419
- }
420
- this.liveRegionMessage = message;
421
- }
422
- announceExistingOptions() {
423
- // request animation frame to wait for re-rendering of filtered options
424
- window.requestAnimationFrame(() => {
425
- const existingOptionsMessage = intl.formatMessage({
426
- id: "tagInput.existingOptions",
427
- defaultMessage: "{num, plural, one {1 existing option.} other {# existing options.}}",
428
- }, { num: this.optionEls.length });
429
- if (this.optionEls.length > 0) {
430
- this.announce(existingOptionsMessage);
431
- }
432
- });
433
- }
434
- announceCharacterLimitWarning(charCount, charLimit) {
435
- const charactersEnteredMessage = intl.formatMessage({
436
- id: "tagInput.charactersEntered",
437
- defaultMessage: "{x, number} of {y, number} characters entered.",
438
- }, { x: charCount, y: charLimit });
439
- const characterLimitReachedMessage = intl.formatMessage({
440
- id: "tagInput.characterLimitReached",
441
- defaultMessage: "No additional characters will be entered.",
442
- });
443
- this.announce(`${charactersEnteredMessage}${charCount >= charLimit ? " " + characterLimitReachedMessage : ""}`);
444
- }
445
- positionInput() {
446
- const lastTag = this.tagEls[this.tagEls.length - 1];
447
- // default placement to fall back to when no tags are present, or not enough space is available
448
- this.inputEl.style.position = "static";
449
- this.inputEl.style.width = "100%";
450
- if (lastTag) {
451
- const spaceAvailable = this.tagAreaEl.getBoundingClientRect().right - lastTag.getBoundingClientRect().right;
452
- // 150px is the minimum width of the input field
453
- if (spaceAvailable >= 150) {
454
- // because the input has right: 0px
455
- // all thats needed to properly place it is setting position: absolute, top, and width
456
- this.inputEl.style.position = "absolute";
457
- this.inputEl.style.top = lastTag.offsetTop.toString() + "px";
458
- this.inputEl.style.width =
459
- (this.tagAreaEl.getBoundingClientRect().right - lastTag.getBoundingClientRect().right - 8).toString() + "px";
460
- }
461
- }
462
- }
463
- /// Helpers
464
- listToCSV(list) {
465
- return list.join(",");
466
- }
467
- csvToArray(csv) {
468
- return csv ? csv.split(/, ?/) : [];
469
- }
470
- includesCaseInsensitive(list, element) {
471
- const lowercaseList = list.map((str) => str.toLowerCase());
472
- return lowercaseList.includes(element.toLowerCase());
473
- }
474
- filterCaseInsensitive(list, element) {
475
- return list.filter((x) => x.toLowerCase() !== element.toLowerCase());
476
- }
477
- sortCaseInsensitive(list) {
478
- // The vanilla .sort method places words that start with capital letters above others (ASCII order)
479
- // so we need to pass in our own compare function to sort case-insensitive
480
- return list.sort((a, b) => {
481
- a = a.toLowerCase();
482
- b = b.toLowerCase();
483
- return a > b ? 1 : a < b ? -1 : 0;
484
- });
485
- }
486
- /// Renders
487
- renderTags() {
488
- return this.tagsList.map((tag, idx) => {
489
- const id = `tag${idx + 1}`;
490
- return (h("li", { id: id, class: `tag highlight ${this.focusedTag && this.focusedTag.id === id ? "focused" : ""}`, "data-tag": tag, role: "option" }, tag, h("button", { class: "remove-btn", tabIndex: -1, onClick: () => this.handleRemoveButtonClick(tag) })));
491
- });
492
- }
493
- renderListItems(optionsList) {
494
- optionsList = this.sortCaseInsensitive(optionsList);
495
- // filter by input
496
- if (this.inputEl && this.inputEl.value) {
497
- optionsList = this.optionsList.filter((option) => option.toLowerCase().includes(this.inputEl.value.toLowerCase()));
498
- }
499
- return optionsList.map((option, idx) => {
500
- const id = `option${idx + 1}`;
501
- const isFocused = this.focusedListItem && this.focusedListItem.id === id;
502
- const isSelected = this.includesCaseInsensitive(this.tagsList, option);
503
- return (h("li", { class: `option ${isFocused ? "focused" : ""}`, role: "option", id: id, "data-option": option, tabIndex: isFocused ? 0 : -1, "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) }, option));
504
- });
505
- }
506
- renderAddNewButton() {
507
- const hasNonWhiteSpaceCharacters = this.inputEl.value.match(/\S/);
508
- const optionAlreadyExists = this.includesCaseInsensitive(this.optionsList, this.inputEl.value.trim());
509
- if (this.addNew && hasNonWhiteSpaceCharacters && !optionAlreadyExists) {
510
- const id = `add-new-btn`;
511
- const isFocused = this.focusedListItem && this.focusedListItem.id === id;
512
- 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), tabIndex: isFocused ? 0 : -1 }, `Add "${this.inputEl.value.trim()}"`));
513
- }
514
- else
515
- return "";
516
- }
517
- renderHelpText() {
518
- const helpTextHasOptions = intl.formatMessage({
519
- id: "tagInput.helpTextCanSelect",
520
- defaultMessage: "Search and select a tag.",
521
- });
522
- const helpTextEditable = intl.formatMessage({
523
- id: "tagInput.helpTextEditable",
524
- defaultMessage: "Press the Enter or Comma key to add a new tag.",
525
- });
526
- let helpText = "";
527
- if (this.optionsList.length > 0) {
528
- helpText += helpTextHasOptions;
529
- }
530
- if (this.addNew) {
531
- helpText += " " + helpTextEditable;
532
- }
533
- return helpText;
534
- }
535
- renderTagCounter() {
536
- if (this.maxTags) {
537
- return (h("div", { class: "lower-row" }, h("div", { id: "max-tags" }, this.generateTagCounterMessage(this.tagsList.length, this.maxTags), this.tagsList.length >= this.maxTags && h("span", { class: "sr-only" }, this.maxTagsReachedMessage))));
538
- }
539
- }
540
- render() {
541
- const isFocused = this.focusedElement &&
542
- (this.focusedElement === this.inputEl ||
543
- this.focusedElement === this.tagAreaEl ||
544
- this.focusedElement.classList.contains("add-new-btn") ||
545
- (this.optionsList.length > 0 && this.listItemEls.includes(this.focusedElement)));
546
- return (h(Host, { id: this.uid }, h("div", { class: `wrapper label-${this.labelPosition}` }, h("div", { class: "label-wrapper" }, h("label", { class: "label", htmlFor: `input${this.uid}` }, this.label)), h("div", { class: `field-wrapper ${isFocused ? "focused" : ""}`, ref: (el) => (this.fieldWrapperEl = el) }, h("div", { class: "upper-row" }, h("div", { class: "tags-and-input-wrapper" }, h("ul", { ref: (el) => (this.tagAreaEl = el), class: "tag-area", role: "listbox", "aria-orientation": "horizontal", "aria-label": `${this.label} ${this.tagsList.length > 0 ? this.tagAreaInstructions : ""}`, tabindex: this.tagsList.length > 0 ? 0 : -1, "aria-describedby": `info max-tags`, onFocus: () => this.handleTagAreaFocus(), onBlur: (ev) => {
547
- this.clearTagFocus();
548
- this.handleBlur(ev, this.el);
549
- }, onKeyDown: (ev) => this.handleTagAreaKeyDown(ev) }, this.renderTags()), h("input", { id: `input${this.uid}`, class: this.maxTags && this.tagsList.length >= this.maxTags ? "hidden" : "", role: "combobox", ref: (el) => (this.inputEl = el), autocomplete: "off", "aria-controls": "dropdown", "aria-describedby": "help-text", "aria-label": this.label, "aria-expanded": this.isExpanded ? "true" : "false", placeholder: this.placeholder, maxLength: this.characterLimit, onInput: () => this.handleInputChanged(this.inputEl.value), onBlur: (ev) => {
550
- this.handleBlur(ev, this.el);
551
- }, onFocus: () => {
552
- this.openDropdown();
553
- this.clearListItemFocus();
554
- }, onKeyDown: (ev) => this.handleInputKeyDown(ev) })), h("div", { class: "character-count" }, this.charCount, "/", this.characterLimit)), this.renderTagCounter(), 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)))), this.info ? (h("div", { id: "info", class: "info-text" }, this.info)) : (""), h("div", { class: "sr-only", "aria-live": "assertive", ref: (el) => (this.liveRegionEl = el), "aria-atomic": "true" }, this.liveRegionMessage))));
555
- }
556
- get el() { return getElement(this); }
557
- static get watchers() { return {
558
- "tagsList": ["reflectSelectedTags"]
559
- }; }
560
- };
6
+ const TagInput = class {
7
+ constructor(hostRef) {
8
+ registerInstance(this, hostRef);
9
+ this.wmTagInputChanged = createEvent(this, "wmTagInputChanged", 7);
10
+ this.labelPosition = "top";
11
+ this.options = ""; // csv
12
+ this.selectedTags = ""; // csv
13
+ this.addNew = true;
14
+ this.characterLimit = 50;
15
+ this.uid = this.el.id ? this.el.id : generateId();
16
+ this.openUp = false;
17
+ this.isExpanded = false;
18
+ this.tagsList = this.csvToArray(this.selectedTags);
19
+ this.optionsList = this.csvToArray(this.options);
20
+ this.charCount = 0;
21
+ this.liveRegionMessage = "";
22
+ this.tagAreaInstructions = intl.formatMessage({
23
+ id: "tagInput.tagAreaInstructions",
24
+ defaultMessage: "tag selection. Press Backspace or Delete to remove a tag.",
25
+ });
26
+ this.maxTagsReachedMessage = intl.formatMessage({
27
+ id: "tagInput.maxTagsReached",
28
+ defaultMessage: "The maximum amount of tags has been reached, no additional tags can be added.",
29
+ });
30
+ this.debouncedResize = debounce(() => {
31
+ this.positionInput();
32
+ }, 30);
33
+ }
34
+ get focusedElement() {
35
+ return this.el.shadowRoot.activeElement;
36
+ }
37
+ get listItemEls() {
38
+ return Array.from(this.dropdownEl.querySelectorAll("li"));
39
+ }
40
+ get tagEls() {
41
+ return Array.from(this.tagAreaEl.querySelectorAll(".tag"));
42
+ }
43
+ get optionEls() {
44
+ return Array.from(this.dropdownEl.querySelectorAll(".option"));
45
+ }
46
+ generateTagAddedMessage(tag) {
47
+ return intl.formatMessage({
48
+ id: "tagInput.tagAdded",
49
+ defaultMessage: "{tagName} added.",
50
+ description: "A confirmation for adding a tag.",
51
+ }, { tagName: tag });
52
+ }
53
+ generateTagAlreadyAddedMessage(tag) {
54
+ return intl.formatMessage({
55
+ id: "tagInput.tagAlreadyAdded",
56
+ defaultMessage: "{tagName} has already been added.",
57
+ description: "An alert for adding a tag that is already present.",
58
+ }, { tagName: tag });
59
+ }
60
+ generateTagCounterMessage(x, y) {
61
+ return intl.formatMessage({
62
+ id: "tagInput.tagsAddedCounter",
63
+ defaultMessage: "Tags added: {x, number}/{y, number}",
64
+ description: "For the user to understand how close they are to the tag limit.",
65
+ }, {
66
+ x: x,
67
+ y: y,
68
+ });
69
+ }
70
+ componentWillLoad() {
71
+ if (!this.placeholder) {
72
+ this.placeholder = this.createPlaceholderDefault(this.addNew, !!this.options);
73
+ }
74
+ if (!this.label) {
75
+ console.error("wm-tag-input must have a label property");
76
+ }
77
+ this.consolidateSelectedTags();
78
+ }
79
+ componentDidLoad() {
80
+ // prevent highlighting of pre-selected tags
81
+ this.tagEls.forEach((el) => el.classList.remove("highlight"));
82
+ }
83
+ componentDidRender() {
84
+ this.positionInput();
85
+ }
86
+ consolidateSelectedTags() {
87
+ this.tagsList.forEach((tag) => {
88
+ if (!this.includesCaseInsensitive(this.optionsList, tag)) {
89
+ this.options += `${this.options.length > 0 ? "," : ""}${tag}`;
90
+ }
91
+ });
92
+ this.optionsList = this.csvToArray(this.options);
93
+ }
94
+ createPlaceholderDefault(addNew, hasOptions) {
95
+ const addAndSearchPlaceholder = intl.formatMessage({
96
+ id: "tagInput.placeholderAddAndSearch",
97
+ defaultMessage: "Add or search for a tag",
98
+ });
99
+ const searchPlaceholder = intl.formatMessage({
100
+ id: "tagInput.placeholderSearch",
101
+ defaultMessage: "Search and select a tag",
102
+ });
103
+ const addPlaceholder = intl.formatMessage({
104
+ id: "tagInput.placeholderAdd",
105
+ defaultMessage: "Add a new tag",
106
+ });
107
+ let placeholder = "";
108
+ if (addNew && hasOptions) {
109
+ placeholder = addAndSearchPlaceholder;
110
+ }
111
+ else if (!addNew && hasOptions) {
112
+ placeholder = searchPlaceholder;
113
+ }
114
+ else if (addNew) {
115
+ placeholder = addPlaceholder;
116
+ }
117
+ return placeholder;
118
+ }
119
+ reflectSelectedTags() {
120
+ this.selectedTags = this.listToCSV(this.tagsList);
121
+ this.wmTagInputChanged.emit({ value: this.tagsList });
122
+ }
123
+ closeIfNotElOrChild(ev) {
124
+ const isntElOrChild = ev.target !== this.el && !this.el.shadowRoot.contains(ev.target);
125
+ if (isntElOrChild && this.isExpanded) {
126
+ this.closeDropdown();
127
+ }
128
+ }
129
+ handleResize() {
130
+ this.debouncedResize();
131
+ }
132
+ handleInputKeyDown(ev) {
133
+ if (/^.$/.test(ev.key) && this.inputEl.value.length >= this.characterLimit) {
134
+ this.announceCharacterLimitWarning(this.inputEl.value.length, this.characterLimit);
135
+ }
136
+ // prevent keydown triggering on tag area
137
+ ev.stopPropagation();
138
+ switch (ev.key) {
139
+ case "Enter":
140
+ case ",":
141
+ ev.preventDefault();
142
+ this.submitInput(this.addNew, this.inputEl.value.trim());
143
+ break;
144
+ case "ArrowDown":
145
+ ev.preventDefault();
146
+ this.handleInputArrowDown();
147
+ break;
148
+ case "ArrowUp":
149
+ ev.preventDefault();
150
+ this.handleInputArrowUp();
151
+ break;
152
+ case "Escape":
153
+ if (this.isExpanded) {
154
+ this.closeDropdown();
155
+ }
156
+ break;
157
+ case "ArrowLeft":
158
+ case "Backspace":
159
+ this.handleInputBackspace();
160
+ break;
161
+ }
162
+ }
163
+ handleInputChanged(value) {
164
+ this.charCount = value.length;
165
+ if (this.charCount >= this.characterLimit - 5) {
166
+ this.announceCharacterLimitWarning(this.charCount, this.characterLimit);
167
+ }
168
+ this.announceExistingOptions();
169
+ if (!this.isExpanded) {
170
+ this.openDropdown();
171
+ }
172
+ }
173
+ submitInput(canAddNew, value) {
174
+ const hasNonWhiteSpaceCharacters = value.match(/\S/);
175
+ if (canAddNew && hasNonWhiteSpaceCharacters) {
176
+ this.tagsList = this.addTag(value);
177
+ this.optionsList = this.addOption(value);
178
+ this.resetInput();
179
+ // if maxTags has been reached, focus should go to the tagArea instead of the input
180
+ if (this.maxTags && this.tagsList.length >= this.maxTags) {
181
+ this.tagAreaEl.focus();
182
+ }
183
+ }
184
+ }
185
+ handleInputArrowDown() {
186
+ if (this.isExpanded) {
187
+ this.moveDownListItem();
188
+ }
189
+ else {
190
+ this.openDropdown();
191
+ }
192
+ }
193
+ handleInputArrowUp() {
194
+ if (this.isExpanded) {
195
+ this.moveUpListItem();
196
+ }
197
+ else {
198
+ this.openDropdown();
199
+ }
200
+ }
201
+ handleInputBackspace() {
202
+ if (this.inputEl.value === "" && this.tagsList.length > 0) {
203
+ // wait for events to finish firing before redirecting focus
204
+ // prevents double input in input area and tag area
205
+ window.requestAnimationFrame(() => {
206
+ this.tagAreaEl.focus();
207
+ this.focusTag(this.tagEls[this.tagEls.length - 1]);
208
+ });
209
+ }
210
+ }
211
+ handleListItemKeyDown(ev) {
212
+ const typedEvTarget = ev.target;
213
+ switch (ev.key) {
214
+ case "Enter":
215
+ case " ":
216
+ ev.preventDefault();
217
+ typedEvTarget.click();
218
+ break;
219
+ case "ArrowDown":
220
+ ev.preventDefault();
221
+ this.moveDownListItem();
222
+ break;
223
+ case "ArrowUp":
224
+ ev.preventDefault();
225
+ this.moveUpListItem();
226
+ break;
227
+ case "Escape":
228
+ if (this.focusedElement !== this.inputEl) {
229
+ this.inputEl.focus();
230
+ }
231
+ else {
232
+ this.closeDropdown();
233
+ }
234
+ break;
235
+ }
236
+ }
237
+ handleListItemClick(ev) {
238
+ const typedEvTarget = ev.target;
239
+ const tag = typedEvTarget.dataset.option.trim() || "";
240
+ if (this.includesCaseInsensitive(this.tagsList, tag)) {
241
+ this.announce(this.generateTagAlreadyAddedMessage(tag));
242
+ }
243
+ else {
244
+ this.announce(this.generateTagAddedMessage(tag));
245
+ this.resetInput();
246
+ this.tagsList = this.addTag(tag);
247
+ this.optionsList = this.addOption(tag);
248
+ this.focusedListItem = null;
249
+ // if maxTags has been reached, focus should go to the tagArea instead of the input
250
+ const elementToFocus = this.maxTags && this.tagsList.length >= this.maxTags ? this.tagAreaEl : this.inputEl;
251
+ elementToFocus.focus();
252
+ }
253
+ }
254
+ handleTagAreaKeyDown(ev) {
255
+ switch (ev.key) {
256
+ case "ArrowLeft":
257
+ case "ArrowUp":
258
+ ev.preventDefault();
259
+ this.moveLeftTag();
260
+ break;
261
+ case "ArrowRight":
262
+ case "ArrowDown":
263
+ ev.preventDefault();
264
+ this.moveRightTag();
265
+ break;
266
+ case "Backspace":
267
+ case "Delete":
268
+ this.handleTagAreaDelete();
269
+ break;
270
+ }
271
+ }
272
+ handleTagAreaDelete() {
273
+ if (this.focusedTag && this.focusedTag.dataset.tag) {
274
+ this.removeTag(this.focusedTag.dataset.tag);
275
+ if (this.tagsList.length === 0) {
276
+ // focus input if no tags are left
277
+ this.inputEl.focus();
278
+ }
279
+ else if (this.focusedTag === this.tagEls[this.tagEls.length - 1]) {
280
+ // reassign focus if removing the last tag but there are still tags remaining
281
+ this.focusedTag = this.tagEls[this.tagEls.length - 2];
282
+ this.focusTag(this.focusedTag);
283
+ }
284
+ }
285
+ }
286
+ handleBlur(ev, component) {
287
+ const isntElOrChild = ev.relatedTarget !== component && !this.el.shadowRoot.contains(ev.relatedTarget);
288
+ if (isntElOrChild) {
289
+ this.closeDropdown();
290
+ this.fieldWrapperEl.classList.remove("focused");
291
+ }
292
+ }
293
+ handleTagAreaFocus() {
294
+ this.closeDropdown();
295
+ if (!this.focusedTag) {
296
+ this.focusedTag = this.tagEls[0];
297
+ }
298
+ this.focusTag(this.focusedTag);
299
+ }
300
+ handleRemoveButtonClick(tag) {
301
+ this.moveLeftTag();
302
+ this.removeTag(tag);
303
+ }
304
+ moveDownListItem() {
305
+ if (this.listItemEls.length > 0) {
306
+ const firstListItem = this.listItemEls[0];
307
+ if (!this.focusedListItem) {
308
+ this.focusListItem(firstListItem);
309
+ }
310
+ else if (this.focusedListItem.nextElementSibling) {
311
+ this.focusListItem(this.focusedListItem.nextElementSibling);
312
+ }
313
+ else {
314
+ this.focusListItem(firstListItem);
315
+ }
316
+ }
317
+ }
318
+ moveUpListItem() {
319
+ if (this.listItemEls.length > 0) {
320
+ const lastListItem = this.listItemEls[this.listItemEls.length - 1];
321
+ if (!this.focusedListItem) {
322
+ this.focusListItem(lastListItem);
323
+ }
324
+ else if (this.focusedListItem.previousElementSibling) {
325
+ this.focusListItem(this.focusedListItem.previousElementSibling);
326
+ }
327
+ else {
328
+ this.focusedListItem = null;
329
+ this.inputEl.focus();
330
+ }
331
+ }
332
+ }
333
+ moveLeftTag() {
334
+ const lastTag = this.tagEls[this.tagEls.length - 1];
335
+ if (this.focusedTag && this.tagEls.includes(this.focusedTag.previousElementSibling)) {
336
+ this.focusedTag = this.focusedTag.previousElementSibling;
337
+ }
338
+ else {
339
+ this.focusedTag = lastTag;
340
+ }
341
+ this.focusTag(this.focusedTag);
342
+ }
343
+ moveRightTag() {
344
+ const firstTag = this.tagEls[0];
345
+ if (this.focusedTag && this.tagEls.includes(this.focusedTag.nextElementSibling)) {
346
+ this.focusedTag = this.focusedTag.nextElementSibling;
347
+ }
348
+ else {
349
+ this.focusedTag = firstTag;
350
+ }
351
+ this.focusTag(this.focusedTag);
352
+ }
353
+ addOption(option) {
354
+ let newOptionsList = this.optionsList;
355
+ const optionAlreadyExists = this.includesCaseInsensitive(this.optionsList, option);
356
+ if (!optionAlreadyExists) {
357
+ newOptionsList = newOptionsList.concat(option);
358
+ }
359
+ return newOptionsList;
360
+ }
361
+ removeOption(option) {
362
+ this.optionsList = this.filterCaseInsensitive(this.optionsList, option);
363
+ }
364
+ addTag(tag) {
365
+ let newTagsList = this.tagsList;
366
+ const tagAlreadyAdded = this.includesCaseInsensitive(this.tagsList, tag);
367
+ const tagExistsAsOption = this.optionsList.filter((x) => x.toLowerCase() === tag.toLowerCase())[0];
368
+ if (!tagAlreadyAdded) {
369
+ this.announce(this.generateTagAddedMessage(tag));
370
+ newTagsList = newTagsList.concat(tagExistsAsOption || tag);
371
+ }
372
+ return newTagsList;
373
+ }
374
+ removeTag(tag) {
375
+ const tagRemovedMessage = intl.formatMessage({ id: "tagInput.tagRemoved", defaultMessage: "{tag} removed" }, { tag: tag });
376
+ this.announce(tagRemovedMessage);
377
+ this.tagsList = this.filterCaseInsensitive(this.tagsList, tag);
378
+ const devOptionsList = this.csvToArray(this.options);
379
+ if (this.includesCaseInsensitive(this.optionsList, tag) && !this.includesCaseInsensitive(devOptionsList, tag)) {
380
+ this.removeOption(tag);
381
+ }
382
+ }
383
+ focusListItem(item) {
384
+ this.focusedListItem = item;
385
+ item.focus();
386
+ }
387
+ focusTag(element) {
388
+ this.focusedTag = element;
389
+ this.tagAreaEl.setAttribute("aria-activedescendant", this.focusedTag.id);
390
+ }
391
+ clearTagFocus() {
392
+ this.tagAreaEl.removeAttribute("aria-activedescendant");
393
+ this.focusedTag = null;
394
+ }
395
+ openDropdown() {
396
+ // given an offset of -2px because the dropdown is transformed downwards to avoid overlapping the focus border
397
+ this.openUp = shouldOpenUp(this.el, this.dropdownEl, this.el.clientHeight, -2);
398
+ this.isExpanded = true;
399
+ }
400
+ closeDropdown() {
401
+ this.focusedListItem = null;
402
+ this.isExpanded = false;
403
+ }
404
+ clearListItemFocus() {
405
+ this.focusedListItem = null;
406
+ this.listItemEls.forEach((el) => {
407
+ el.tabIndex = -1;
408
+ el.classList.remove("focused");
409
+ });
410
+ }
411
+ resetInput() {
412
+ this.charCount = 0;
413
+ this.inputEl.value = "";
414
+ }
415
+ announce(message) {
416
+ // \u00A0 is a non-breaking space character, which causes the message to be read as a new one
417
+ if (this.liveRegionEl.textContent === message) {
418
+ message += "\u00A0";
419
+ }
420
+ this.liveRegionMessage = message;
421
+ }
422
+ announceExistingOptions() {
423
+ // request animation frame to wait for re-rendering of filtered options
424
+ window.requestAnimationFrame(() => {
425
+ const existingOptionsMessage = intl.formatMessage({
426
+ id: "tagInput.existingOptions",
427
+ defaultMessage: "{num, plural, one {1 existing option.} other {# existing options.}}",
428
+ }, { num: this.optionEls.length });
429
+ if (this.optionEls.length > 0) {
430
+ this.announce(existingOptionsMessage);
431
+ }
432
+ });
433
+ }
434
+ announceCharacterLimitWarning(charCount, charLimit) {
435
+ const charactersEnteredMessage = intl.formatMessage({
436
+ id: "tagInput.charactersEntered",
437
+ defaultMessage: "{x, number} of {y, number} characters entered.",
438
+ }, { x: charCount, y: charLimit });
439
+ const characterLimitReachedMessage = intl.formatMessage({
440
+ id: "tagInput.characterLimitReached",
441
+ defaultMessage: "No additional characters will be entered.",
442
+ });
443
+ this.announce(`${charactersEnteredMessage}${charCount >= charLimit ? " " + characterLimitReachedMessage : ""}`);
444
+ }
445
+ positionInput() {
446
+ const lastTag = this.tagEls[this.tagEls.length - 1];
447
+ // default placement to fall back to when no tags are present, or not enough space is available
448
+ this.inputEl.style.position = "static";
449
+ this.inputEl.style.width = "100%";
450
+ if (lastTag) {
451
+ const spaceAvailable = this.tagAreaEl.getBoundingClientRect().right - lastTag.getBoundingClientRect().right;
452
+ // 150px is the minimum width of the input field
453
+ if (spaceAvailable >= 150) {
454
+ // because the input has right: 0px
455
+ // all thats needed to properly place it is setting position: absolute, top, and width
456
+ this.inputEl.style.position = "absolute";
457
+ this.inputEl.style.top = lastTag.offsetTop.toString() + "px";
458
+ this.inputEl.style.width =
459
+ (this.tagAreaEl.getBoundingClientRect().right - lastTag.getBoundingClientRect().right - 8).toString() + "px";
460
+ }
461
+ }
462
+ }
463
+ /// Helpers
464
+ listToCSV(list) {
465
+ return list.join(",");
466
+ }
467
+ csvToArray(csv) {
468
+ return csv ? csv.split(/, ?/) : [];
469
+ }
470
+ includesCaseInsensitive(list, element) {
471
+ const lowercaseList = list.map((str) => str.toLowerCase());
472
+ return lowercaseList.includes(element.toLowerCase());
473
+ }
474
+ filterCaseInsensitive(list, element) {
475
+ return list.filter((x) => x.toLowerCase() !== element.toLowerCase());
476
+ }
477
+ sortCaseInsensitive(list) {
478
+ // The vanilla .sort method places words that start with capital letters above others (ASCII order)
479
+ // so we need to pass in our own compare function to sort case-insensitive
480
+ return list.sort((a, b) => {
481
+ a = a.toLowerCase();
482
+ b = b.toLowerCase();
483
+ return a > b ? 1 : a < b ? -1 : 0;
484
+ });
485
+ }
486
+ /// Renders
487
+ renderTags() {
488
+ return this.tagsList.map((tag, idx) => {
489
+ const id = `tag${idx + 1}`;
490
+ return (h("li", { id: id, class: `tag highlight ${this.focusedTag && this.focusedTag.id === id ? "focused" : ""}`, "data-tag": tag, role: "option" }, tag, h("button", { class: "remove-btn", tabIndex: -1, onClick: () => this.handleRemoveButtonClick(tag) })));
491
+ });
492
+ }
493
+ renderListItems(optionsList) {
494
+ optionsList = this.sortCaseInsensitive(optionsList);
495
+ // filter by input
496
+ if (this.inputEl && this.inputEl.value) {
497
+ optionsList = this.optionsList.filter((option) => option.toLowerCase().includes(this.inputEl.value.toLowerCase()));
498
+ }
499
+ return optionsList.map((option, idx) => {
500
+ const id = `option${idx + 1}`;
501
+ const isFocused = this.focusedListItem && this.focusedListItem.id === id;
502
+ const isSelected = this.includesCaseInsensitive(this.tagsList, option);
503
+ return (h("li", { class: `option ${isFocused ? "focused" : ""}`, role: "option", id: id, "data-option": option, tabIndex: isFocused ? 0 : -1, "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) }, option));
504
+ });
505
+ }
506
+ renderAddNewButton() {
507
+ const hasNonWhiteSpaceCharacters = this.inputEl.value.match(/\S/);
508
+ const optionAlreadyExists = this.includesCaseInsensitive(this.optionsList, this.inputEl.value.trim());
509
+ if (this.addNew && hasNonWhiteSpaceCharacters && !optionAlreadyExists) {
510
+ const id = `add-new-btn`;
511
+ const isFocused = this.focusedListItem && this.focusedListItem.id === id;
512
+ 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), tabIndex: isFocused ? 0 : -1 }, `Add "${this.inputEl.value.trim()}"`));
513
+ }
514
+ else
515
+ return "";
516
+ }
517
+ renderHelpText() {
518
+ const helpTextHasOptions = intl.formatMessage({
519
+ id: "tagInput.helpTextCanSelect",
520
+ defaultMessage: "Search and select a tag.",
521
+ });
522
+ const helpTextEditable = intl.formatMessage({
523
+ id: "tagInput.helpTextEditable",
524
+ defaultMessage: "Press the Enter or Comma key to add a new tag.",
525
+ });
526
+ let helpText = "";
527
+ if (this.optionsList.length > 0) {
528
+ helpText += helpTextHasOptions;
529
+ }
530
+ if (this.addNew) {
531
+ helpText += " " + helpTextEditable;
532
+ }
533
+ return helpText;
534
+ }
535
+ renderTagCounter() {
536
+ if (this.maxTags) {
537
+ return (h("div", { class: "lower-row" }, h("div", { id: "max-tags" }, this.generateTagCounterMessage(this.tagsList.length, this.maxTags), this.tagsList.length >= this.maxTags && h("span", { class: "sr-only" }, this.maxTagsReachedMessage))));
538
+ }
539
+ }
540
+ render() {
541
+ const isFocused = this.focusedElement &&
542
+ (this.focusedElement === this.inputEl ||
543
+ this.focusedElement === this.tagAreaEl ||
544
+ this.focusedElement.classList.contains("add-new-btn") ||
545
+ (this.optionsList.length > 0 && this.listItemEls.includes(this.focusedElement)));
546
+ return (h(Host, { id: this.uid }, h("div", { class: `wrapper label-${this.labelPosition}` }, h("div", { class: "label-wrapper" }, h("label", { class: "label", htmlFor: `input${this.uid}` }, this.label)), h("div", { class: `field-wrapper ${isFocused ? "focused" : ""}`, ref: (el) => (this.fieldWrapperEl = el) }, h("div", { class: "upper-row" }, h("div", { class: "tags-and-input-wrapper" }, h("ul", { ref: (el) => (this.tagAreaEl = el), class: "tag-area", role: "listbox", "aria-orientation": "horizontal", "aria-label": `${this.label} ${this.tagsList.length > 0 ? this.tagAreaInstructions : ""}`, tabindex: this.tagsList.length > 0 ? 0 : -1, "aria-describedby": `info max-tags`, onFocus: () => this.handleTagAreaFocus(), onBlur: (ev) => {
547
+ this.clearTagFocus();
548
+ this.handleBlur(ev, this.el);
549
+ }, onKeyDown: (ev) => this.handleTagAreaKeyDown(ev) }, this.renderTags()), h("input", { id: `input${this.uid}`, class: this.maxTags && this.tagsList.length >= this.maxTags ? "hidden" : "", role: "combobox", ref: (el) => (this.inputEl = el), autocomplete: "off", "aria-controls": "dropdown", "aria-describedby": "help-text", "aria-label": this.label, "aria-expanded": this.isExpanded ? "true" : "false", placeholder: this.placeholder, maxLength: this.characterLimit, onInput: () => this.handleInputChanged(this.inputEl.value), onBlur: (ev) => {
550
+ this.handleBlur(ev, this.el);
551
+ }, onFocus: () => {
552
+ this.openDropdown();
553
+ this.clearListItemFocus();
554
+ }, onKeyDown: (ev) => this.handleInputKeyDown(ev) })), h("div", { class: "character-count" }, this.charCount, "/", this.characterLimit)), this.renderTagCounter(), 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)))), this.info ? (h("div", { id: "info", class: "info-text" }, this.info)) : (""), h("div", { class: "sr-only", "aria-live": "assertive", ref: (el) => (this.liveRegionEl = el), "aria-atomic": "true" }, this.liveRegionMessage))));
555
+ }
556
+ get el() { return getElement(this); }
557
+ static get watchers() { return {
558
+ "tagsList": ["reflectSelectedTags"]
559
+ }; }
560
+ };
561
561
  TagInput.style = wmTagInputCss;
562
562
 
563
563
  export { TagInput as wm_tag_input };