@watermarkinsights/ripple 5.6.0 → 5.7.0-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 (212) hide show
  1. package/dist/cjs/{chartFunctions-6fd43417.js → chartFunctions-995023b1.js} +1 -1
  2. package/dist/cjs/{functions-04149f6d.js → functions-e24249e6.js} +6 -0
  3. package/dist/cjs/{global-4a315ae6.js → global-d996c674.js} +1 -1
  4. package/dist/cjs/index-e86c28b6.js +12 -0
  5. package/dist/cjs/{intl-b1e99809.js → intl-5aeba788.js} +1 -1
  6. package/dist/cjs/loader.cjs.js +2 -2
  7. package/dist/cjs/priv-calendar.cjs.entry.js +1 -1
  8. package/dist/cjs/priv-chart-popover.cjs.entry.js +1 -1
  9. package/dist/cjs/priv-option-list.cjs.entry.js +410 -0
  10. package/dist/cjs/ripple.cjs.js +2 -2
  11. package/dist/cjs/wm-action-menu_2.cjs.entry.js +1 -1
  12. package/dist/cjs/wm-button.cjs.entry.js +1 -1
  13. package/dist/cjs/wm-chart.cjs.entry.js +3 -3
  14. package/dist/cjs/wm-date-range.cjs.entry.js +1 -1
  15. package/dist/cjs/wm-datepicker.cjs.entry.js +1 -1
  16. package/dist/cjs/wm-file.cjs.entry.js +1 -1
  17. package/dist/cjs/wm-input.cjs.entry.js +2 -2
  18. package/dist/cjs/wm-line-chart.cjs.entry.js +3 -3
  19. package/dist/cjs/wm-modal-header.cjs.entry.js +2 -2
  20. package/dist/cjs/wm-modal.cjs.entry.js +2 -2
  21. package/dist/cjs/wm-navigation_3.cjs.entry.js +2 -2
  22. package/dist/cjs/wm-navigator.cjs.entry.js +1 -1
  23. package/dist/cjs/wm-nested-select.cjs.entry.js +308 -0
  24. package/dist/cjs/wm-optgroup.cjs.entry.js +67 -0
  25. package/dist/cjs/wm-option_2.cjs.entry.js +38 -343
  26. package/dist/cjs/wm-pagination.cjs.entry.js +1 -1
  27. package/dist/cjs/wm-progress-indicator_3.cjs.entry.js +2 -2
  28. package/dist/cjs/wm-search.cjs.entry.js +2 -2
  29. package/dist/cjs/wm-snackbar.cjs.entry.js +2 -2
  30. package/dist/cjs/wm-tab-item_3.cjs.entry.js +1 -1
  31. package/dist/cjs/wm-tag-input.cjs.entry.js +2 -2
  32. package/dist/cjs/wm-tag-option.cjs.entry.js +1 -1
  33. package/dist/cjs/wm-textarea.cjs.entry.js +2 -2
  34. package/dist/cjs/wm-timepicker.cjs.entry.js +1 -1
  35. package/dist/cjs/wm-toggletip.cjs.entry.js +1 -1
  36. package/dist/cjs/wm-uploader.cjs.entry.js +2 -2
  37. package/dist/collection/collection-manifest.json +5 -2
  38. package/dist/collection/components/selects/priv-option-list/priv-option-list.css +131 -0
  39. package/dist/collection/components/selects/priv-option-list/priv-option-list.js +785 -0
  40. package/dist/collection/components/selects/wm-nested-select/wm-nested-select.css +420 -0
  41. package/dist/collection/components/selects/wm-nested-select/wm-nested-select.js +588 -0
  42. package/dist/collection/components/selects/wm-optgroup/wm-optgroup.css +51 -0
  43. package/dist/collection/components/selects/wm-optgroup/wm-optgroup.js +235 -0
  44. package/dist/collection/components/{wm-option → selects/wm-option}/wm-option.css +1 -1
  45. package/dist/collection/components/{wm-option → selects/wm-option}/wm-option.js +30 -9
  46. package/dist/collection/components/{wm-select → selects/wm-select}/wm-select.css +5 -72
  47. package/dist/collection/components/{wm-select → selects/wm-select}/wm-select.js +20 -387
  48. package/dist/collection/components/{wm-select → selects/wm-select}/wm-select.spec.js +61 -61
  49. package/dist/collection/components/wm-modal/wm-modal.js +1 -1
  50. package/dist/collection/dev/nested-select.js +36 -0
  51. package/dist/collection/global/functions.js +5 -0
  52. package/dist/esm/{chartFunctions-f5eb7f59.js → chartFunctions-dfcb1edf.js} +1 -1
  53. package/dist/esm/{functions-cf37f81f.js → functions-b791a892.js} +6 -1
  54. package/dist/esm/{global-016b76a8.js → global-dcf80bdb.js} +1 -1
  55. package/dist/esm/index-558b5a82.js +12 -0
  56. package/dist/esm/{intl-c72b75dc.js → intl-f2f7ce8b.js} +1 -1
  57. package/dist/esm/loader.js +2 -2
  58. package/dist/esm/priv-calendar.entry.js +1 -1
  59. package/dist/esm/priv-chart-popover.entry.js +1 -1
  60. package/dist/esm/priv-option-list.entry.js +406 -0
  61. package/dist/esm/ripple.js +2 -2
  62. package/dist/esm/wm-action-menu_2.entry.js +1 -1
  63. package/dist/esm/wm-button.entry.js +1 -1
  64. package/dist/esm/wm-chart.entry.js +3 -3
  65. package/dist/esm/wm-date-range.entry.js +1 -1
  66. package/dist/esm/wm-datepicker.entry.js +1 -1
  67. package/dist/esm/wm-file.entry.js +1 -1
  68. package/dist/esm/wm-input.entry.js +2 -2
  69. package/dist/esm/wm-line-chart.entry.js +3 -3
  70. package/dist/esm/wm-modal-header.entry.js +2 -2
  71. package/dist/esm/wm-modal.entry.js +2 -2
  72. package/dist/esm/wm-navigation_3.entry.js +2 -2
  73. package/dist/esm/wm-navigator.entry.js +1 -1
  74. package/dist/esm/wm-nested-select.entry.js +304 -0
  75. package/dist/esm/wm-optgroup.entry.js +63 -0
  76. package/dist/esm/wm-option_2.entry.js +38 -343
  77. package/dist/esm/wm-pagination.entry.js +1 -1
  78. package/dist/esm/wm-progress-indicator_3.entry.js +2 -2
  79. package/dist/esm/wm-search.entry.js +2 -2
  80. package/dist/esm/wm-snackbar.entry.js +2 -2
  81. package/dist/esm/wm-tab-item_3.entry.js +1 -1
  82. package/dist/esm/wm-tag-input.entry.js +2 -2
  83. package/dist/esm/wm-tag-option.entry.js +1 -1
  84. package/dist/esm/wm-textarea.entry.js +2 -2
  85. package/dist/esm/wm-timepicker.entry.js +1 -1
  86. package/dist/esm/wm-toggletip.entry.js +1 -1
  87. package/dist/esm/wm-uploader.entry.js +2 -2
  88. package/dist/esm-es5/{chartFunctions-f5eb7f59.js → chartFunctions-dfcb1edf.js} +1 -1
  89. package/dist/esm-es5/{functions-cf37f81f.js → functions-b791a892.js} +1 -1
  90. package/dist/esm-es5/global-dcf80bdb.js +1 -0
  91. package/dist/esm-es5/index-558b5a82.js +1 -1
  92. package/dist/esm-es5/{intl-c72b75dc.js → intl-f2f7ce8b.js} +1 -1
  93. package/dist/esm-es5/loader.js +1 -1
  94. package/dist/esm-es5/priv-calendar.entry.js +1 -1
  95. package/dist/esm-es5/priv-chart-popover.entry.js +1 -1
  96. package/dist/esm-es5/priv-option-list.entry.js +1 -0
  97. package/dist/esm-es5/ripple.js +1 -1
  98. package/dist/esm-es5/wm-action-menu_2.entry.js +1 -1
  99. package/dist/esm-es5/wm-button.entry.js +1 -1
  100. package/dist/esm-es5/wm-chart.entry.js +1 -1
  101. package/dist/esm-es5/wm-date-range.entry.js +1 -1
  102. package/dist/esm-es5/wm-datepicker.entry.js +1 -1
  103. package/dist/esm-es5/wm-file.entry.js +1 -1
  104. package/dist/esm-es5/wm-input.entry.js +1 -1
  105. package/dist/esm-es5/wm-line-chart.entry.js +1 -1
  106. package/dist/esm-es5/wm-modal-header.entry.js +1 -1
  107. package/dist/esm-es5/wm-modal.entry.js +1 -1
  108. package/dist/esm-es5/wm-navigation_3.entry.js +1 -1
  109. package/dist/esm-es5/wm-navigator.entry.js +1 -1
  110. package/dist/esm-es5/wm-nested-select.entry.js +1 -0
  111. package/dist/esm-es5/wm-optgroup.entry.js +1 -0
  112. package/dist/esm-es5/wm-option_2.entry.js +1 -1
  113. package/dist/esm-es5/wm-pagination.entry.js +1 -1
  114. package/dist/esm-es5/wm-progress-indicator_3.entry.js +1 -1
  115. package/dist/esm-es5/wm-search.entry.js +1 -1
  116. package/dist/esm-es5/wm-snackbar.entry.js +1 -1
  117. package/dist/esm-es5/wm-tab-item_3.entry.js +1 -1
  118. package/dist/esm-es5/wm-tag-input.entry.js +1 -1
  119. package/dist/esm-es5/wm-tag-option.entry.js +1 -1
  120. package/dist/esm-es5/wm-textarea.entry.js +1 -1
  121. package/dist/esm-es5/wm-timepicker.entry.js +1 -1
  122. package/dist/esm-es5/wm-toggletip.entry.js +1 -1
  123. package/dist/esm-es5/wm-uploader.entry.js +1 -1
  124. package/dist/ripple/{p-2d0e4020.system.entry.js → p-0b1c6965.system.entry.js} +1 -1
  125. package/dist/ripple/p-0c259c1a.system.entry.js +1 -0
  126. package/dist/ripple/{p-2ccf8450.system.entry.js → p-1389302e.system.entry.js} +1 -1
  127. package/dist/ripple/{p-20a800a7.entry.js → p-13f51c06.entry.js} +1 -1
  128. package/dist/ripple/{p-f4b64ded.entry.js → p-149a22bf.entry.js} +1 -1
  129. package/dist/ripple/{p-76825602.js → p-16f65bf4.js} +1 -1
  130. package/dist/ripple/p-1c170fb3.entry.js +1 -0
  131. package/dist/ripple/{p-3ea0e27c.entry.js → p-1e625a5e.entry.js} +1 -1
  132. package/dist/ripple/{p-31094930.entry.js → p-215793a4.entry.js} +1 -1
  133. package/dist/ripple/{p-fb229776.js → p-21d372ed.js} +1 -1
  134. package/dist/ripple/{p-24103be5.entry.js → p-236af552.entry.js} +1 -1
  135. package/dist/ripple/{p-f177d841.entry.js → p-2e79fa49.entry.js} +1 -1
  136. package/dist/ripple/{p-ed1971ff.system.entry.js → p-30b905eb.system.entry.js} +1 -1
  137. package/dist/ripple/{p-86d81e42.entry.js → p-3d50db36.entry.js} +1 -1
  138. package/dist/ripple/{p-53519eed.system.entry.js → p-3deaf4d9.system.entry.js} +1 -1
  139. package/dist/ripple/{p-5f793375.system.entry.js → p-3e415c49.system.entry.js} +1 -1
  140. package/dist/ripple/{p-0b570b66.entry.js → p-41550baa.entry.js} +1 -1
  141. package/dist/ripple/p-45dc49e8.entry.js +1 -0
  142. package/dist/ripple/{p-508362c5.entry.js → p-45f9ad09.entry.js} +1 -1
  143. package/dist/ripple/p-50388b6f.system.entry.js +1 -0
  144. package/dist/ripple/{p-dc7a6037.system.entry.js → p-505eca1c.system.entry.js} +1 -1
  145. package/dist/ripple/{p-762429a8.entry.js → p-5284791c.entry.js} +1 -1
  146. package/dist/ripple/{p-0d05b4a9.entry.js → p-5300b15d.entry.js} +1 -1
  147. package/dist/ripple/p-54d9e467.system.entry.js +1 -0
  148. package/dist/ripple/p-54f7d3d4.system.entry.js +1 -0
  149. package/dist/ripple/{p-5db92638.system.entry.js → p-5a9e3108.system.entry.js} +1 -1
  150. package/dist/ripple/p-618300c1.entry.js +1 -0
  151. package/dist/ripple/{p-2d0bcc88.system.entry.js → p-6cc07645.system.entry.js} +1 -1
  152. package/dist/ripple/{p-cd51ee87.system.entry.js → p-6d129ef8.system.entry.js} +1 -1
  153. package/dist/ripple/{p-451433a6.entry.js → p-72165bd2.entry.js} +1 -1
  154. package/dist/ripple/{p-5967bd2a.system.entry.js → p-725230dd.system.entry.js} +1 -1
  155. package/dist/ripple/{p-984287f7.system.entry.js → p-749597da.system.entry.js} +1 -1
  156. package/dist/ripple/p-76ff5d91.entry.js +1 -0
  157. package/dist/ripple/{p-fb751343.system.js → p-81c2df85.system.js} +1 -1
  158. package/dist/ripple/{p-74032162.system.js → p-828adbf1.system.js} +1 -1
  159. package/dist/ripple/{p-db8917e4.entry.js → p-83be63f6.entry.js} +1 -1
  160. package/dist/ripple/{p-ce8c6180.system.entry.js → p-84603f1f.system.entry.js} +1 -1
  161. package/dist/ripple/{p-d0387d35.entry.js → p-84ba5b74.entry.js} +1 -1
  162. package/dist/ripple/p-99058787.entry.js +1 -0
  163. package/dist/ripple/{p-9df3574d.system.entry.js → p-a0ecb6d7.system.entry.js} +1 -1
  164. package/dist/ripple/{p-7fdcce90.system.entry.js → p-a3c01e10.system.entry.js} +1 -1
  165. package/dist/ripple/p-ae82b3d2.system.js +1 -0
  166. package/dist/ripple/{p-c61366fd.entry.js → p-aea13873.entry.js} +1 -1
  167. package/dist/ripple/{p-120dbdc8.system.entry.js → p-b01f9998.system.entry.js} +1 -1
  168. package/dist/ripple/p-b176c143.system.entry.js +1 -0
  169. package/dist/ripple/{p-bd142645.entry.js → p-b9dbf1f4.entry.js} +1 -1
  170. package/dist/ripple/{p-04f9a60a.entry.js → p-c1e3c2fb.entry.js} +1 -1
  171. package/dist/ripple/{p-8b272d80.system.entry.js → p-c2e00d4a.system.entry.js} +1 -1
  172. package/dist/ripple/{p-76d53189.entry.js → p-c47fab48.entry.js} +1 -1
  173. package/dist/ripple/p-c6a336d6.system.js +1 -0
  174. package/dist/ripple/{p-ffa15c47.system.entry.js → p-c853e185.system.entry.js} +1 -1
  175. package/dist/ripple/{p-c9200deb.system.entry.js → p-ca971eac.system.entry.js} +1 -1
  176. package/dist/ripple/{p-8008f0f2.system.entry.js → p-cad0c5f9.system.entry.js} +1 -1
  177. package/dist/ripple/{p-446e0b2c.system.entry.js → p-db9657eb.system.entry.js} +1 -1
  178. package/dist/ripple/{p-e3899e1f.entry.js → p-df157138.entry.js} +1 -1
  179. package/dist/ripple/{p-ae4460f2.system.entry.js → p-e081fdc2.system.entry.js} +1 -1
  180. package/dist/ripple/p-e209a933.js +1 -0
  181. package/dist/ripple/{p-dfd1b720.entry.js → p-e687176d.entry.js} +1 -1
  182. package/dist/ripple/{p-d8994408.system.entry.js → p-ed1f6b8d.system.entry.js} +1 -1
  183. package/dist/ripple/{p-db190563.js → p-eddbcb21.js} +1 -1
  184. package/dist/ripple/p-ee4fee7d.system.js +1 -0
  185. package/dist/ripple/{p-8a11ee6f.entry.js → p-f2101a0d.entry.js} +1 -1
  186. package/dist/ripple/{p-1aef4b40.entry.js → p-f24572f5.entry.js} +1 -1
  187. package/dist/ripple/{p-97f276aa.system.entry.js → p-f40e1468.system.entry.js} +1 -1
  188. package/dist/ripple/{p-6f4c4231.entry.js → p-f90e4094.entry.js} +1 -1
  189. package/dist/ripple/{p-7f483c55.system.entry.js → p-fa4f1030.system.entry.js} +1 -1
  190. package/dist/ripple/{p-9b75d56c.entry.js → p-ff1ed90f.entry.js} +1 -1
  191. package/dist/ripple/ripple.esm.js +1 -1
  192. package/dist/ripple/ripple.js +1 -1
  193. package/dist/types/components/{wm-select/wm-select.d.ts → selects/priv-option-list/priv-option-list.d.ts} +42 -65
  194. package/dist/types/components/selects/wm-nested-select/wm-nested-select.d.ts +58 -0
  195. package/dist/types/components/selects/wm-optgroup/wm-optgroup.d.ts +20 -0
  196. package/dist/types/components/{wm-option → selects/wm-option}/wm-option.d.ts +3 -2
  197. package/dist/types/components/selects/wm-select/wm-select.d.ts +54 -0
  198. package/dist/types/components.d.ts +156 -2
  199. package/dist/types/global/functions.d.ts +1 -0
  200. package/package.json +1 -1
  201. package/dist/esm-es5/global-016b76a8.js +0 -1
  202. package/dist/ripple/p-11aaef56.system.entry.js +0 -1
  203. package/dist/ripple/p-481a9e2f.system.js +0 -1
  204. package/dist/ripple/p-55668879.system.js +0 -1
  205. package/dist/ripple/p-6636a40b.system.entry.js +0 -1
  206. package/dist/ripple/p-9603168d.entry.js +0 -1
  207. package/dist/ripple/p-a40b0af9.system.js +0 -1
  208. package/dist/ripple/p-a895f1ef.entry.js +0 -1
  209. package/dist/ripple/p-f9494a9d.js +0 -1
  210. /package/dist/collection/components/{wm-option → selects/wm-option}/wm-option.e2e.js +0 -0
  211. /package/dist/collection/components/{wm-option → selects/wm-option}/wm-option.spec.js +0 -0
  212. /package/dist/collection/components/{wm-select → selects/wm-select}/wm-select.e2e.js +0 -0
@@ -0,0 +1,785 @@
1
+ import { h, forceUpdate } from "@stencil/core";
2
+ import { intl, debounce, isElOrChild } from "../../../global/functions";
3
+ export class PrivOptionList {
4
+ constructor() {
5
+ this.searchIndex = 0;
6
+ this.keysSoFar = "";
7
+ this.selectAllMessage = intl.formatMessage({
8
+ id: "select.selectAll",
9
+ defaultMessage: "Select All",
10
+ });
11
+ this.deselectAllMessage = intl.formatMessage({
12
+ id: "select.deselectAll",
13
+ defaultMessage: "Deselect All",
14
+ });
15
+ this.allOptionsSelectedMessage = intl.formatMessage({
16
+ id: "select.allOptionsSelected",
17
+ defaultMessage: "All options selected",
18
+ });
19
+ this.allOptionsDeselectedMessage = intl.formatMessage({
20
+ id: "select.allOptionsDeselected",
21
+ defaultMessage: "All options deselected",
22
+ });
23
+ this.debouncedSearch = debounce(() => {
24
+ this.searchTerm = this.searchFieldEl.value;
25
+ this.optionListSearchChanged.emit({ searchTerm: this.searchTerm });
26
+ if (this.filteredOptions.length) {
27
+ this.announce(this.resultsFoundMessage);
28
+ }
29
+ else {
30
+ this.announce(this.noResultsFoundMessage);
31
+ }
32
+ }, 150);
33
+ this.debouncedClearKeysSoFar = debounce(() => {
34
+ this.keysSoFar = "";
35
+ }, 500);
36
+ this.multiple = false;
37
+ this.search = false;
38
+ this.selectAll = false;
39
+ this.searchPlaceholder = undefined;
40
+ this.maxHeight = undefined;
41
+ this.optgroupLabel = undefined;
42
+ this.announcement = "";
43
+ this.searchTerm = "";
44
+ }
45
+ get childOptions() {
46
+ return Array.from(this.el.getRootNode().host.querySelectorAll("wm-option"));
47
+ }
48
+ get cloneOptions() {
49
+ return Array.from(this.el.querySelectorAll("wm-option"));
50
+ }
51
+ get allOptionEls() {
52
+ // this includes both slotted wm-options and internally created wm-options
53
+ return this.cloneOptions.concat(this.childOptions);
54
+ }
55
+ get visibleOptionEls() {
56
+ return this.allOptionEls.filter((option) => !option.classList.contains("hidden") && !option.classList.contains("filtered-out"));
57
+ }
58
+ //////////////////////////////////////
59
+ // for search variants
60
+ get filteredOptions() {
61
+ return this.childOptions.filter((option) => { var _a; return (_a = option.textContent) === null || _a === void 0 ? void 0 : _a.toLowerCase().includes(this.searchTerm.toLowerCase()); });
62
+ }
63
+ //////////////////////////////////////
64
+ //////////////////////////////////////
65
+ // for multiselect button text
66
+ get selectedOptions() {
67
+ return Array.from(this.el.querySelectorAll("wm-option")).filter((x) => x.selected);
68
+ }
69
+ get visibleSelectAllButton() {
70
+ return this.selectAll && this.multiple && this.searchTerm === "";
71
+ }
72
+ get allSelected() {
73
+ return this.childOptions.every((option) => option.selected);
74
+ }
75
+ //////////////////////////////////////
76
+ get resultsFoundMessage() {
77
+ return intl.formatMessage({
78
+ id: "select.searchResultsFound",
79
+ defaultMessage: "{numResults, plural, one {1 option found} other {# options found}}",
80
+ description: "The message read by the screen reader, indicating how many results a search returned",
81
+ }, { numResults: this.filteredOptions.length });
82
+ }
83
+ get noResultsFoundMessage() {
84
+ return intl.formatMessage({
85
+ id: "select.noSearchResults",
86
+ defaultMessage: "No results found. Please try your search again.",
87
+ description: "The message displayed when no options pass the search filter",
88
+ });
89
+ }
90
+ findAndFocusOption(ev) {
91
+ const letterPressed = ev.detail.letter.toLowerCase();
92
+ const optionPressed = ev.detail.optionEl;
93
+ if (!this.keysSoFar && letterPressed == " ") {
94
+ // if the first key entered is space, treat as a click. Otherwise include in
95
+ optionPressed.click();
96
+ }
97
+ else {
98
+ if (!this.keysSoFar) {
99
+ // if first character entered, set currently focused option as the starting index for the search
100
+ this.visibleOptionEls.forEach((option, idx) => {
101
+ if (option.focused) {
102
+ this.searchIndex = idx;
103
+ }
104
+ });
105
+ }
106
+ this.keysSoFar += letterPressed;
107
+ let nextMatch = this.findMatchInRange(this.visibleOptionEls, this.searchIndex + 1, this.visibleOptionEls.length);
108
+ if (!nextMatch) {
109
+ // if match can't be found from starting option downwards, search from top
110
+ nextMatch = this.findMatchInRange(this.visibleOptionEls, 0, this.searchIndex);
111
+ }
112
+ if (nextMatch) {
113
+ // findMatchInRange still might have returned null, only focus if match found
114
+ this.focusOption(nextMatch);
115
+ }
116
+ this.debouncedClearKeysSoFar();
117
+ }
118
+ }
119
+ handleOptionSelection(ev) {
120
+ this.focusOption(ev.detail);
121
+ }
122
+ handleChildUp(ev) {
123
+ this.moveUp(ev.detail);
124
+ }
125
+ handleChildDown(ev) {
126
+ this.moveDown(ev.detail);
127
+ }
128
+ moveToFirstOption() {
129
+ this.focusOption(this.visibleOptionEls[0]);
130
+ }
131
+ moveToLastOption() {
132
+ this.focusOption(this.visibleOptionEls[this.visibleOptionEls.length - 1]);
133
+ }
134
+ handleOptionCloneSelection(ev) {
135
+ const correspondingOption = this.findCorrespondingOption(ev.detail);
136
+ correspondingOption.click();
137
+ }
138
+ componentDidLoad() {
139
+ if (this.multiple) {
140
+ this.updateOptionVisibility();
141
+ }
142
+ // Dev can overwrite the max-height rule set in the Sass file
143
+ if (this.maxHeight) {
144
+ // this.listboxEl.style.maxHeight = this.maxHeight;
145
+ this.listboxEl.style.maxHeight = this.maxHeight;
146
+ }
147
+ }
148
+ async handleChildChange(_) {
149
+ if (this.multiple) {
150
+ // on update of wm-options selected state, rerender to update clones state
151
+ forceUpdate(this.el);
152
+ }
153
+ }
154
+ async clearSearch() {
155
+ if (this.search) {
156
+ this.searchFieldEl.value = "";
157
+ this.searchTerm = "";
158
+ this.optionListSearchChanged.emit({ searchTerm: this.searchTerm });
159
+ }
160
+ }
161
+ async focusOption(option) {
162
+ this.allOptionEls.forEach((i) => (i.focused = i === option));
163
+ // option must be scrolledIntoView before focused
164
+ // if focus is called first the option might be positioned incorrectly (in the center of the dropdown) and scrollIntoView didload do nothing as the option will already be in view
165
+ option.scrollIntoView({ block: "nearest" });
166
+ // scrollIntoView does not work when the container of the element it's called on is not rendered to the page (in our case the dropdown is still closed and has transform: scaleY(0))
167
+ // when opening the dropdown, scrollIntoView must be delayed to a point where the browser recognizes content within it as able to be scrolled to
168
+ // in Safari in particular, the soonest this seems to happen is 20ms. The longest we can wait before any jumping in the open dropdown is noticeable is 60ms
169
+ window.setTimeout(() => option.scrollIntoView({ block: "nearest" }), 60);
170
+ option.focus();
171
+ }
172
+ async handleInitialFocus(optionToSelect) {
173
+ switch (optionToSelect) {
174
+ case "next":
175
+ // search variant focuses search field
176
+ // all others focus option "after" last selected option (this can be the first option)
177
+ if (this.search) {
178
+ this.searchFieldEl.focus();
179
+ this.listboxEl.scrollTop = 0;
180
+ }
181
+ else {
182
+ this.moveDown(this.visibleOptionEls.filter((x) => x.selected).slice(-1)[0]);
183
+ }
184
+ break;
185
+ case "previous":
186
+ // search variant focuses last option
187
+ // all others focus option "above" first selected option (this can be the last option)
188
+ if (this.search) {
189
+ this.focusOption(this.visibleOptionEls[this.visibleOptionEls.length - 1]);
190
+ }
191
+ else {
192
+ this.moveUp(this.visibleOptionEls.filter((x) => x.selected)[0]);
193
+ }
194
+ break;
195
+ default:
196
+ // search variant focuses search field
197
+ // all others focus the selected option
198
+ // if no option is selected (empty multiselect), focuses first option
199
+ if (this.search) {
200
+ this.searchFieldEl.focus();
201
+ this.listboxEl.scrollTop = 0;
202
+ }
203
+ else if (this.selectedOptions.length > 0) {
204
+ this.focusOption(this.visibleOptionEls.filter((x) => x.selected)[0]);
205
+ }
206
+ else {
207
+ this.focusOption(this.visibleOptionEls[0]);
208
+ }
209
+ break;
210
+ }
211
+ }
212
+ async unfocusAll() {
213
+ this.allOptionEls.map((i) => (i.focused = false));
214
+ }
215
+ findMatchInRange(list, startIndex, endIndex) {
216
+ let match = null;
217
+ let optionsInRange = list.slice(startIndex, endIndex);
218
+ // Find the first option starting with the keysSoFar substring, searching in
219
+ // the specified range of options
220
+ optionsInRange.forEach((option) => {
221
+ const label = option.textContent;
222
+ if (!match && label && label.toLowerCase().startsWith(this.keysSoFar)) {
223
+ match = option;
224
+ }
225
+ });
226
+ return match;
227
+ }
228
+ findCorrespondingOption(el) {
229
+ // if clone, returns the child wm-option
230
+ // if child wm-option, returns clone
231
+ const isClone = el.classList.contains("clone");
232
+ return isClone
233
+ ? this.childOptions[this.cloneOptions.indexOf(el)]
234
+ : this.cloneOptions[this.childOptions.indexOf(el)];
235
+ }
236
+ handleSearchFieldBlur(ev) {
237
+ this.searchFieldWrapperEl.classList.remove("focus");
238
+ if (isElOrChild(this.el, ev.relatedTarget)) {
239
+ // do not emit a blur event when moving from searchfield to options
240
+ ev.stopPropagation();
241
+ }
242
+ }
243
+ // on search field or select all. keydown on options is handled via events.
244
+ handleKeyDown(ev) {
245
+ const el = ev.target;
246
+ switch (ev.key) {
247
+ case "ArrowDown":
248
+ ev.preventDefault();
249
+ this.moveDown(ev.target);
250
+ break;
251
+ case "ArrowUp":
252
+ ev.preventDefault();
253
+ this.moveUp(ev.target);
254
+ break;
255
+ case "ArrowLeft":
256
+ // if an optgroupLabel was passed, we are within a Nested Select
257
+ if (!!this.optgroupLabel) {
258
+ ev.preventDefault();
259
+ this.wmKeyLeftPressed.emit();
260
+ }
261
+ break;
262
+ case "Escape":
263
+ ev.preventDefault();
264
+ this.wmEscKeyPressed.emit();
265
+ break;
266
+ case "Enter":
267
+ if (el === this.selectAllEl) {
268
+ ev.preventDefault();
269
+ this.handleSelectAllClick();
270
+ this.close();
271
+ }
272
+ break;
273
+ case " ":
274
+ if (el === this.selectAllEl) {
275
+ ev.preventDefault();
276
+ this.handleSelectAllClick();
277
+ }
278
+ break;
279
+ }
280
+ }
281
+ close() {
282
+ if (this.multiple) {
283
+ this.updateOptionVisibility();
284
+ }
285
+ this.optionListCloseRequested.emit(); // what actually happens when a close is requested is determined by the parent
286
+ }
287
+ handleSelectAllClick() {
288
+ this.allSelected ? this.deselectAllOptions() : this.selectAllOptions();
289
+ }
290
+ selectAllOptions() {
291
+ this.announce(this.allOptionsSelectedMessage);
292
+ this.optionListAllSelected.emit();
293
+ }
294
+ deselectAllOptions() {
295
+ this.announce(this.allOptionsDeselectedMessage);
296
+ this.optionListAllDeselected.emit();
297
+ }
298
+ moveUp(el) {
299
+ const focusableEls = this.visibleOptionEls;
300
+ if (this.selectAllEl) {
301
+ focusableEls.unshift(this.selectAllEl);
302
+ }
303
+ if (this.searchFieldEl) {
304
+ focusableEls.unshift(this.searchFieldEl);
305
+ }
306
+ // if an optgroupLabel was passed, we are is within a Nested Select
307
+ if (!!this.optgroupLabel) {
308
+ focusableEls.unshift(this.returnBtnEl);
309
+ }
310
+ const prevEl = focusableEls[focusableEls.indexOf(el) - 1] || focusableEls[focusableEls.length - 1];
311
+ if (prevEl) {
312
+ this.focusOption(prevEl);
313
+ }
314
+ }
315
+ moveDown(el) {
316
+ const focusableEls = this.visibleOptionEls;
317
+ if (this.selectAllEl) {
318
+ focusableEls.unshift(this.selectAllEl);
319
+ }
320
+ if (this.searchFieldEl) {
321
+ focusableEls.unshift(this.searchFieldEl);
322
+ }
323
+ // if an optgroupLabel was passed, we are is within a Nested Select
324
+ if (!!this.optgroupLabel) {
325
+ focusableEls.unshift(this.returnBtnEl);
326
+ }
327
+ const nextEl = focusableEls[focusableEls.indexOf(el) + 1] || focusableEls[0];
328
+ if (nextEl) {
329
+ this.focusOption(nextEl);
330
+ }
331
+ }
332
+ async updateOptionVisibility() {
333
+ // this runs for search multiselects, where selected options are rendered at the top of the dropdown list
334
+ // slotted wm-options are hidden if selected, and clone wm-options are made visible if selected
335
+ this.childOptions.forEach((option, idx) => {
336
+ const cloneOption = this.cloneOptions[idx];
337
+ if (option.selected) {
338
+ option.classList.add("hidden");
339
+ cloneOption.classList.remove("hidden");
340
+ }
341
+ else {
342
+ option.classList.remove("hidden");
343
+ cloneOption.classList.add("hidden");
344
+ }
345
+ });
346
+ // find last visible clone option and apply .last class
347
+ const visibleCloneOptions = this.visibleOptionEls.filter((option) => option.classList.contains("clone"));
348
+ // if all options are clones, nothing to separate from
349
+ const allClones = visibleCloneOptions.length === this.visibleOptionEls.length;
350
+ visibleCloneOptions.forEach((option, idx) => {
351
+ if (!allClones && idx === visibleCloneOptions.length - 1) {
352
+ option.classList.add("last");
353
+ }
354
+ else {
355
+ option.classList.remove("last");
356
+ }
357
+ });
358
+ }
359
+ announce(message) {
360
+ // \u00A0 is a non-breaking space character, which causes the message to be read as a new one
361
+ if (this.liveRegionEl.textContent === message) {
362
+ message += "\u00A0";
363
+ }
364
+ this.announcement = message;
365
+ }
366
+ renderReturnBtn() {
367
+ return (h("button", { ref: (el) => (this.returnBtnEl = el), id: "return-btn", class: "return-btn", onKeyDown: (ev) => this.handleKeyDown(ev), onClick: () => {
368
+ //@ts-ignore -- Check out this one weird trick TypeScript doesn't want you to know about
369
+ this.el.getRootNode().host.isExpanded = false;
370
+ } }, this.optgroupLabel));
371
+ }
372
+ renderSearchField() {
373
+ return (h("div", { class: "search" }, h("div", { class: "searchfield-wrapper", ref: (el) => (this.searchFieldWrapperEl = el) }, h("div", { class: "icon" }), h("input", { ref: (el) => (this.searchFieldEl = el), class: "searchfield", role: "combobox", "aria-controls": "list",
374
+ // aria-expanded={this.isExpanded ? "true" : "false"}
375
+ onKeyDown: (ev) => this.handleKeyDown(ev), onFocus: () => this.searchFieldWrapperEl.classList.add("focus"), onBlur: (ev) => this.handleSearchFieldBlur(ev), onInput: () => this.debouncedSearch(), placeholder: this.searchPlaceholder }))));
376
+ }
377
+ renderSearchFailedMessage() {
378
+ return h("div", { class: "search-results-message" }, this.noResultsFoundMessage);
379
+ }
380
+ renderSelectAllButton() {
381
+ return (h("button", { ref: (el) => (this.selectAllEl = el), class: "select-all", onClick: () => this.handleSelectAllClick(), onKeyDown: (ev) => this.handleKeyDown(ev), tabindex: "-1" }, this.allSelected ? this.deselectAllMessage : this.selectAllMessage));
382
+ }
383
+ renderCloneOptions() {
384
+ return Array.from(this.childOptions).map((o) => {
385
+ const option = o;
386
+ return (h("wm-option", { class: "clone", subinfo: option.subinfo, selected: option.selected }, option.textContent));
387
+ });
388
+ }
389
+ render() {
390
+ return (h("div", { class: "list-wrapper" }, !!this.optgroupLabel && this.renderReturnBtn(), this.search && this.renderSearchField(), this.visibleSelectAllButton && this.renderSelectAllButton(), h("div", { id: "list", class: "options-wrapper", tabindex: -1, role: "listbox", "aria-multiselectable": this.multiple ? "true" : null, "aria-labelledby": "label", ref: (el) => (this.listboxEl = el) }, this.searchTerm && this.filteredOptions.length === 0 && this.renderSearchFailedMessage(), this.multiple && this.renderCloneOptions(), h("slot", null)), h("div", { id: "optionlist-announcement", "aria-live": "polite", "aria-atomic": "true", class: "sr-only", ref: (el) => (this.liveRegionEl = el) }, this.announcement)));
391
+ }
392
+ static get is() { return "priv-option-list"; }
393
+ static get originalStyleUrls() {
394
+ return {
395
+ "$": ["priv-option-list.scss"]
396
+ };
397
+ }
398
+ static get styleUrls() {
399
+ return {
400
+ "$": ["priv-option-list.css"]
401
+ };
402
+ }
403
+ static get properties() {
404
+ return {
405
+ "multiple": {
406
+ "type": "boolean",
407
+ "mutable": false,
408
+ "complexType": {
409
+ "original": "boolean",
410
+ "resolved": "boolean",
411
+ "references": {}
412
+ },
413
+ "required": false,
414
+ "optional": false,
415
+ "docs": {
416
+ "tags": [],
417
+ "text": ""
418
+ },
419
+ "attribute": "multiple",
420
+ "reflect": false,
421
+ "defaultValue": "false"
422
+ },
423
+ "search": {
424
+ "type": "boolean",
425
+ "mutable": false,
426
+ "complexType": {
427
+ "original": "boolean",
428
+ "resolved": "boolean",
429
+ "references": {}
430
+ },
431
+ "required": false,
432
+ "optional": false,
433
+ "docs": {
434
+ "tags": [],
435
+ "text": ""
436
+ },
437
+ "attribute": "search",
438
+ "reflect": false,
439
+ "defaultValue": "false"
440
+ },
441
+ "selectAll": {
442
+ "type": "boolean",
443
+ "mutable": false,
444
+ "complexType": {
445
+ "original": "boolean",
446
+ "resolved": "boolean",
447
+ "references": {}
448
+ },
449
+ "required": false,
450
+ "optional": false,
451
+ "docs": {
452
+ "tags": [],
453
+ "text": ""
454
+ },
455
+ "attribute": "select-all",
456
+ "reflect": false,
457
+ "defaultValue": "false"
458
+ },
459
+ "searchPlaceholder": {
460
+ "type": "string",
461
+ "mutable": false,
462
+ "complexType": {
463
+ "original": "string",
464
+ "resolved": "string | undefined",
465
+ "references": {}
466
+ },
467
+ "required": false,
468
+ "optional": true,
469
+ "docs": {
470
+ "tags": [],
471
+ "text": ""
472
+ },
473
+ "attribute": "search-placeholder",
474
+ "reflect": false
475
+ },
476
+ "maxHeight": {
477
+ "type": "string",
478
+ "mutable": false,
479
+ "complexType": {
480
+ "original": "string",
481
+ "resolved": "string | undefined",
482
+ "references": {}
483
+ },
484
+ "required": false,
485
+ "optional": true,
486
+ "docs": {
487
+ "tags": [],
488
+ "text": ""
489
+ },
490
+ "attribute": "max-height",
491
+ "reflect": false
492
+ },
493
+ "optgroupLabel": {
494
+ "type": "string",
495
+ "mutable": false,
496
+ "complexType": {
497
+ "original": "string",
498
+ "resolved": "string | undefined",
499
+ "references": {}
500
+ },
501
+ "required": false,
502
+ "optional": true,
503
+ "docs": {
504
+ "tags": [],
505
+ "text": ""
506
+ },
507
+ "attribute": "optgroup-label",
508
+ "reflect": false
509
+ }
510
+ };
511
+ }
512
+ static get states() {
513
+ return {
514
+ "announcement": {},
515
+ "searchTerm": {}
516
+ };
517
+ }
518
+ static get events() {
519
+ return [{
520
+ "method": "optionListSearchChanged",
521
+ "name": "optionListSearchChanged",
522
+ "bubbles": true,
523
+ "cancelable": true,
524
+ "composed": true,
525
+ "docs": {
526
+ "tags": [],
527
+ "text": ""
528
+ },
529
+ "complexType": {
530
+ "original": "Object",
531
+ "resolved": "Object",
532
+ "references": {
533
+ "Object": {
534
+ "location": "global",
535
+ "id": "global::Object"
536
+ }
537
+ }
538
+ }
539
+ }, {
540
+ "method": "optionListCloseRequested",
541
+ "name": "optionListCloseRequested",
542
+ "bubbles": true,
543
+ "cancelable": true,
544
+ "composed": true,
545
+ "docs": {
546
+ "tags": [],
547
+ "text": ""
548
+ },
549
+ "complexType": {
550
+ "original": "any",
551
+ "resolved": "any",
552
+ "references": {}
553
+ }
554
+ }, {
555
+ "method": "optionListAllSelected",
556
+ "name": "optionListAllSelected",
557
+ "bubbles": true,
558
+ "cancelable": true,
559
+ "composed": true,
560
+ "docs": {
561
+ "tags": [],
562
+ "text": ""
563
+ },
564
+ "complexType": {
565
+ "original": "any",
566
+ "resolved": "any",
567
+ "references": {}
568
+ }
569
+ }, {
570
+ "method": "optionListAllDeselected",
571
+ "name": "optionListAllDeselected",
572
+ "bubbles": true,
573
+ "cancelable": true,
574
+ "composed": true,
575
+ "docs": {
576
+ "tags": [],
577
+ "text": ""
578
+ },
579
+ "complexType": {
580
+ "original": "any",
581
+ "resolved": "any",
582
+ "references": {}
583
+ }
584
+ }, {
585
+ "method": "wmEscKeyPressed",
586
+ "name": "wmEscKeyPressed",
587
+ "bubbles": true,
588
+ "cancelable": true,
589
+ "composed": true,
590
+ "docs": {
591
+ "tags": [],
592
+ "text": ""
593
+ },
594
+ "complexType": {
595
+ "original": "any",
596
+ "resolved": "any",
597
+ "references": {}
598
+ }
599
+ }, {
600
+ "method": "wmKeyLeftPressed",
601
+ "name": "wmKeyLeftPressed",
602
+ "bubbles": true,
603
+ "cancelable": true,
604
+ "composed": true,
605
+ "docs": {
606
+ "tags": [],
607
+ "text": ""
608
+ },
609
+ "complexType": {
610
+ "original": "any",
611
+ "resolved": "any",
612
+ "references": {}
613
+ }
614
+ }];
615
+ }
616
+ static get methods() {
617
+ return {
618
+ "handleChildChange": {
619
+ "complexType": {
620
+ "signature": "(_: MutationRecord) => Promise<void>",
621
+ "parameters": [{
622
+ "tags": [],
623
+ "text": ""
624
+ }],
625
+ "references": {
626
+ "Promise": {
627
+ "location": "global",
628
+ "id": "global::Promise"
629
+ },
630
+ "MutationRecord": {
631
+ "location": "global",
632
+ "id": "global::MutationRecord"
633
+ }
634
+ },
635
+ "return": "Promise<void>"
636
+ },
637
+ "docs": {
638
+ "text": "",
639
+ "tags": []
640
+ }
641
+ },
642
+ "clearSearch": {
643
+ "complexType": {
644
+ "signature": "() => Promise<void>",
645
+ "parameters": [],
646
+ "references": {
647
+ "Promise": {
648
+ "location": "global",
649
+ "id": "global::Promise"
650
+ }
651
+ },
652
+ "return": "Promise<void>"
653
+ },
654
+ "docs": {
655
+ "text": "",
656
+ "tags": []
657
+ }
658
+ },
659
+ "focusOption": {
660
+ "complexType": {
661
+ "signature": "(option: HTMLElement) => Promise<void>",
662
+ "parameters": [{
663
+ "tags": [],
664
+ "text": ""
665
+ }],
666
+ "references": {
667
+ "Promise": {
668
+ "location": "global",
669
+ "id": "global::Promise"
670
+ },
671
+ "HTMLElement": {
672
+ "location": "global",
673
+ "id": "global::HTMLElement"
674
+ }
675
+ },
676
+ "return": "Promise<void>"
677
+ },
678
+ "docs": {
679
+ "text": "",
680
+ "tags": []
681
+ }
682
+ },
683
+ "handleInitialFocus": {
684
+ "complexType": {
685
+ "signature": "(optionToSelect?: \"next\" | \"previous\") => Promise<void>",
686
+ "parameters": [{
687
+ "tags": [],
688
+ "text": ""
689
+ }],
690
+ "references": {
691
+ "Promise": {
692
+ "location": "global",
693
+ "id": "global::Promise"
694
+ }
695
+ },
696
+ "return": "Promise<void>"
697
+ },
698
+ "docs": {
699
+ "text": "",
700
+ "tags": []
701
+ }
702
+ },
703
+ "unfocusAll": {
704
+ "complexType": {
705
+ "signature": "() => Promise<void>",
706
+ "parameters": [],
707
+ "references": {
708
+ "Promise": {
709
+ "location": "global",
710
+ "id": "global::Promise"
711
+ }
712
+ },
713
+ "return": "Promise<void>"
714
+ },
715
+ "docs": {
716
+ "text": "",
717
+ "tags": []
718
+ }
719
+ },
720
+ "updateOptionVisibility": {
721
+ "complexType": {
722
+ "signature": "() => Promise<void>",
723
+ "parameters": [],
724
+ "references": {
725
+ "Promise": {
726
+ "location": "global",
727
+ "id": "global::Promise"
728
+ }
729
+ },
730
+ "return": "Promise<void>"
731
+ },
732
+ "docs": {
733
+ "text": "",
734
+ "tags": []
735
+ }
736
+ }
737
+ };
738
+ }
739
+ static get elementRef() { return "el"; }
740
+ static get listeners() {
741
+ return [{
742
+ "name": "wmLetterPressed",
743
+ "method": "findAndFocusOption",
744
+ "target": undefined,
745
+ "capture": false,
746
+ "passive": false
747
+ }, {
748
+ "name": "wmOptionSelected",
749
+ "method": "handleOptionSelection",
750
+ "target": undefined,
751
+ "capture": false,
752
+ "passive": false
753
+ }, {
754
+ "name": "wmKeyUpPressed",
755
+ "method": "handleChildUp",
756
+ "target": undefined,
757
+ "capture": false,
758
+ "passive": false
759
+ }, {
760
+ "name": "wmKeyDownPressed",
761
+ "method": "handleChildDown",
762
+ "target": undefined,
763
+ "capture": false,
764
+ "passive": false
765
+ }, {
766
+ "name": "wmHomeKeyPressed",
767
+ "method": "moveToFirstOption",
768
+ "target": undefined,
769
+ "capture": false,
770
+ "passive": false
771
+ }, {
772
+ "name": "wmEndKeyPressed",
773
+ "method": "moveToLastOption",
774
+ "target": undefined,
775
+ "capture": false,
776
+ "passive": false
777
+ }, {
778
+ "name": "intCloneClicked",
779
+ "method": "handleOptionCloneSelection",
780
+ "target": undefined,
781
+ "capture": false,
782
+ "passive": false
783
+ }];
784
+ }
785
+ }