@refinitiv-ui/elements 0.0.0-build.1957399501.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 (619) hide show
  1. package/CHANGELOG.md +412 -0
  2. package/LICENSE +13 -0
  3. package/README.md +70 -0
  4. package/lib/accordion/custom-elements.json +49 -0
  5. package/lib/accordion/custom-elements.md +18 -0
  6. package/lib/accordion/index.d.ts +76 -0
  7. package/lib/accordion/index.js +136 -0
  8. package/lib/accordion/themes/halo/dark/index.js +3 -0
  9. package/lib/accordion/themes/halo/light/index.js +3 -0
  10. package/lib/accordion/themes/solar/charcoal/index.js +3 -0
  11. package/lib/accordion/themes/solar/pearl/index.js +3 -0
  12. package/lib/appstate-bar/custom-elements.json +49 -0
  13. package/lib/appstate-bar/custom-elements.md +22 -0
  14. package/lib/appstate-bar/index.d.ts +65 -0
  15. package/lib/appstate-bar/index.js +100 -0
  16. package/lib/appstate-bar/themes/halo/dark/index.js +3 -0
  17. package/lib/appstate-bar/themes/halo/light/index.js +3 -0
  18. package/lib/appstate-bar/themes/solar/charcoal/index.js +3 -0
  19. package/lib/appstate-bar/themes/solar/pearl/index.js +3 -0
  20. package/lib/autosuggest/custom-elements.json +243 -0
  21. package/lib/autosuggest/custom-elements.md +54 -0
  22. package/lib/autosuggest/helpers/types.d.ts +54 -0
  23. package/lib/autosuggest/helpers/types.js +1 -0
  24. package/lib/autosuggest/helpers/utils.d.ts +39 -0
  25. package/lib/autosuggest/helpers/utils.js +75 -0
  26. package/lib/autosuggest/index.d.ts +538 -0
  27. package/lib/autosuggest/index.js +1254 -0
  28. package/lib/autosuggest/themes/halo/dark/index.js +5 -0
  29. package/lib/autosuggest/themes/halo/light/index.js +5 -0
  30. package/lib/autosuggest/themes/solar/charcoal/index.js +5 -0
  31. package/lib/autosuggest/themes/solar/pearl/index.js +5 -0
  32. package/lib/button/custom-elements.json +119 -0
  33. package/lib/button/custom-elements.md +23 -0
  34. package/lib/button/index.d.ts +138 -0
  35. package/lib/button/index.js +241 -0
  36. package/lib/button/themes/halo/dark/index.js +3 -0
  37. package/lib/button/themes/halo/light/index.js +3 -0
  38. package/lib/button/themes/solar/charcoal/index.js +3 -0
  39. package/lib/button/themes/solar/pearl/index.js +3 -0
  40. package/lib/button-bar/custom-elements.json +26 -0
  41. package/lib/button-bar/custom-elements.md +9 -0
  42. package/lib/button-bar/index.d.ts +125 -0
  43. package/lib/button-bar/index.js +294 -0
  44. package/lib/button-bar/themes/halo/dark/index.js +3 -0
  45. package/lib/button-bar/themes/halo/light/index.js +3 -0
  46. package/lib/button-bar/themes/solar/charcoal/index.js +3 -0
  47. package/lib/button-bar/themes/solar/pearl/index.js +3 -0
  48. package/lib/calendar/constants.d.ts +26 -0
  49. package/lib/calendar/constants.js +28 -0
  50. package/lib/calendar/custom-elements.json +201 -0
  51. package/lib/calendar/custom-elements.md +35 -0
  52. package/lib/calendar/index.d.ts +412 -0
  53. package/lib/calendar/index.js +1297 -0
  54. package/lib/calendar/locales.d.ts +1 -0
  55. package/lib/calendar/locales.js +41 -0
  56. package/lib/calendar/themes/halo/dark/index.js +3 -0
  57. package/lib/calendar/themes/halo/light/index.js +3 -0
  58. package/lib/calendar/themes/solar/charcoal/index.js +3 -0
  59. package/lib/calendar/themes/solar/pearl/index.js +3 -0
  60. package/lib/calendar/types.d.ts +32 -0
  61. package/lib/calendar/types.js +1 -0
  62. package/lib/calendar/utils.d.ts +42 -0
  63. package/lib/calendar/utils.js +120 -0
  64. package/lib/canvas/custom-elements.json +71 -0
  65. package/lib/canvas/custom-elements.md +27 -0
  66. package/lib/canvas/index.d.ts +101 -0
  67. package/lib/canvas/index.js +172 -0
  68. package/lib/canvas/themes/halo/dark/index.js +2 -0
  69. package/lib/canvas/themes/halo/light/index.js +2 -0
  70. package/lib/canvas/themes/solar/charcoal/index.js +2 -0
  71. package/lib/canvas/themes/solar/pearl/index.js +2 -0
  72. package/lib/card/custom-elements.json +61 -0
  73. package/lib/card/custom-elements.md +24 -0
  74. package/lib/card/helpers/types.d.ts +12 -0
  75. package/lib/card/helpers/types.js +1 -0
  76. package/lib/card/index.d.ts +142 -0
  77. package/lib/card/index.js +247 -0
  78. package/lib/card/themes/halo/dark/index.js +5 -0
  79. package/lib/card/themes/halo/light/index.js +5 -0
  80. package/lib/card/themes/solar/charcoal/index.js +5 -0
  81. package/lib/card/themes/solar/pearl/index.js +5 -0
  82. package/lib/chart/custom-elements.json +42 -0
  83. package/lib/chart/custom-elements.md +16 -0
  84. package/lib/chart/helpers/index.d.ts +2 -0
  85. package/lib/chart/helpers/index.js +2 -0
  86. package/lib/chart/helpers/legend.d.ts +5 -0
  87. package/lib/chart/helpers/legend.js +78 -0
  88. package/lib/chart/helpers/merge.d.ts +15 -0
  89. package/lib/chart/helpers/merge.js +28 -0
  90. package/lib/chart/helpers/types.d.ts +69 -0
  91. package/lib/chart/helpers/types.js +1 -0
  92. package/lib/chart/index.d.ts +187 -0
  93. package/lib/chart/index.js +484 -0
  94. package/lib/chart/plugins/doughnut-center-label.d.ts +3 -0
  95. package/lib/chart/plugins/doughnut-center-label.js +191 -0
  96. package/lib/chart/themes/halo/dark/index.js +4 -0
  97. package/lib/chart/themes/halo/light/index.js +4 -0
  98. package/lib/chart/themes/solar/charcoal/index.js +4 -0
  99. package/lib/chart/themes/solar/pearl/index.js +4 -0
  100. package/lib/checkbox/custom-elements.json +71 -0
  101. package/lib/checkbox/custom-elements.md +18 -0
  102. package/lib/checkbox/index.d.ts +97 -0
  103. package/lib/checkbox/index.js +194 -0
  104. package/lib/checkbox/themes/halo/dark/index.js +4 -0
  105. package/lib/checkbox/themes/halo/light/index.js +4 -0
  106. package/lib/checkbox/themes/solar/charcoal/index.js +4 -0
  107. package/lib/checkbox/themes/solar/pearl/index.js +4 -0
  108. package/lib/clock/custom-elements.json +125 -0
  109. package/lib/clock/custom-elements.md +28 -0
  110. package/lib/clock/index.d.ts +321 -0
  111. package/lib/clock/index.js +583 -0
  112. package/lib/clock/themes/halo/dark/index.js +2 -0
  113. package/lib/clock/themes/halo/light/index.js +2 -0
  114. package/lib/clock/themes/solar/charcoal/index.js +2 -0
  115. package/lib/clock/themes/solar/pearl/index.js +2 -0
  116. package/lib/clock/utils/TickManager.d.ts +14 -0
  117. package/lib/clock/utils/TickManager.js +66 -0
  118. package/lib/clock/utils/timestamps.d.ts +6 -0
  119. package/lib/clock/utils/timestamps.js +6 -0
  120. package/lib/collapse/custom-elements.json +81 -0
  121. package/lib/collapse/custom-elements.md +27 -0
  122. package/lib/collapse/index.d.ts +123 -0
  123. package/lib/collapse/index.js +225 -0
  124. package/lib/collapse/themes/halo/dark/index.js +5 -0
  125. package/lib/collapse/themes/halo/light/index.js +5 -0
  126. package/lib/collapse/themes/solar/charcoal/index.js +5 -0
  127. package/lib/collapse/themes/solar/pearl/index.js +5 -0
  128. package/lib/color-dialog/custom-elements.json +206 -0
  129. package/lib/color-dialog/custom-elements.md +39 -0
  130. package/lib/color-dialog/elements/color-palettes.d.ts +52 -0
  131. package/lib/color-dialog/elements/color-palettes.js +101 -0
  132. package/lib/color-dialog/elements/grayscale-palettes.d.ts +67 -0
  133. package/lib/color-dialog/elements/grayscale-palettes.js +161 -0
  134. package/lib/color-dialog/elements/palettes.d.ts +65 -0
  135. package/lib/color-dialog/elements/palettes.js +131 -0
  136. package/lib/color-dialog/helpers/color-helpers.d.ts +16 -0
  137. package/lib/color-dialog/helpers/color-helpers.js +161 -0
  138. package/lib/color-dialog/helpers/value-model.d.ts +75 -0
  139. package/lib/color-dialog/helpers/value-model.js +141 -0
  140. package/lib/color-dialog/index.d.ts +232 -0
  141. package/lib/color-dialog/index.js +459 -0
  142. package/lib/color-dialog/themes/halo/dark/index.js +7 -0
  143. package/lib/color-dialog/themes/halo/light/index.js +7 -0
  144. package/lib/color-dialog/themes/solar/charcoal/index.js +7 -0
  145. package/lib/color-dialog/themes/solar/pearl/index.js +7 -0
  146. package/lib/combo-box/custom-elements.json +241 -0
  147. package/lib/combo-box/custom-elements.md +42 -0
  148. package/lib/combo-box/helpers/filter.d.ts +10 -0
  149. package/lib/combo-box/helpers/filter.js +29 -0
  150. package/lib/combo-box/helpers/keyboard-event.d.ts +17 -0
  151. package/lib/combo-box/helpers/keyboard-event.js +19 -0
  152. package/lib/combo-box/helpers/renderer.d.ts +8 -0
  153. package/lib/combo-box/helpers/renderer.js +24 -0
  154. package/lib/combo-box/helpers/types.d.ts +11 -0
  155. package/lib/combo-box/helpers/types.js +1 -0
  156. package/lib/combo-box/index.d.ts +551 -0
  157. package/lib/combo-box/index.js +1199 -0
  158. package/lib/combo-box/themes/halo/dark/index.js +7 -0
  159. package/lib/combo-box/themes/halo/light/index.js +7 -0
  160. package/lib/combo-box/themes/solar/charcoal/index.js +7 -0
  161. package/lib/combo-box/themes/solar/pearl/index.js +7 -0
  162. package/lib/counter/custom-elements.json +39 -0
  163. package/lib/counter/custom-elements.md +11 -0
  164. package/lib/counter/index.d.ts +91 -0
  165. package/lib/counter/index.js +154 -0
  166. package/lib/counter/themes/halo/dark/index.js +3 -0
  167. package/lib/counter/themes/halo/light/index.js +3 -0
  168. package/lib/counter/themes/solar/charcoal/index.js +3 -0
  169. package/lib/counter/themes/solar/pearl/index.js +3 -0
  170. package/lib/counter/utils.d.ts +13 -0
  171. package/lib/counter/utils.js +52 -0
  172. package/lib/datetime-picker/custom-elements.json +362 -0
  173. package/lib/datetime-picker/custom-elements.md +57 -0
  174. package/lib/datetime-picker/index.d.ts +509 -0
  175. package/lib/datetime-picker/index.js +1174 -0
  176. package/lib/datetime-picker/locales.d.ts +8 -0
  177. package/lib/datetime-picker/locales.js +57 -0
  178. package/lib/datetime-picker/themes/halo/dark/index.js +7 -0
  179. package/lib/datetime-picker/themes/halo/light/index.js +7 -0
  180. package/lib/datetime-picker/themes/solar/charcoal/index.js +7 -0
  181. package/lib/datetime-picker/themes/solar/pearl/index.js +7 -0
  182. package/lib/datetime-picker/types.d.ts +3 -0
  183. package/lib/datetime-picker/types.js +1 -0
  184. package/lib/datetime-picker/utils.d.ts +55 -0
  185. package/lib/datetime-picker/utils.js +92 -0
  186. package/lib/dialog/custom-elements.json +169 -0
  187. package/lib/dialog/custom-elements.md +48 -0
  188. package/lib/dialog/draggable-element.d.ts +14 -0
  189. package/lib/dialog/draggable-element.js +220 -0
  190. package/lib/dialog/index.d.ts +213 -0
  191. package/lib/dialog/index.js +353 -0
  192. package/lib/dialog/themes/halo/dark/index.js +7 -0
  193. package/lib/dialog/themes/halo/light/index.js +7 -0
  194. package/lib/dialog/themes/solar/charcoal/index.js +7 -0
  195. package/lib/dialog/themes/solar/pearl/index.js +7 -0
  196. package/lib/email-field/custom-elements.json +186 -0
  197. package/lib/email-field/custom-elements.md +37 -0
  198. package/lib/email-field/index.d.ts +80 -0
  199. package/lib/email-field/index.js +91 -0
  200. package/lib/email-field/themes/halo/dark/index.js +3 -0
  201. package/lib/email-field/themes/halo/light/index.js +3 -0
  202. package/lib/email-field/themes/solar/charcoal/index.js +3 -0
  203. package/lib/email-field/themes/solar/pearl/index.js +3 -0
  204. package/lib/events.d.ts +121 -0
  205. package/lib/events.js +1 -0
  206. package/lib/flag/custom-elements.json +35 -0
  207. package/lib/flag/custom-elements.md +10 -0
  208. package/lib/flag/index.d.ts +96 -0
  209. package/lib/flag/index.js +168 -0
  210. package/lib/flag/themes/halo/dark/index.js +2 -0
  211. package/lib/flag/themes/halo/light/index.js +2 -0
  212. package/lib/flag/themes/solar/charcoal/index.js +2 -0
  213. package/lib/flag/themes/solar/pearl/index.js +2 -0
  214. package/lib/flag/utils/FlagLoader.d.ts +47 -0
  215. package/lib/flag/utils/FlagLoader.js +86 -0
  216. package/lib/header/custom-elements.json +36 -0
  217. package/lib/header/custom-elements.md +18 -0
  218. package/lib/header/index.d.ts +46 -0
  219. package/lib/header/index.js +73 -0
  220. package/lib/header/themes/halo/dark/index.js +2 -0
  221. package/lib/header/themes/halo/light/index.js +2 -0
  222. package/lib/header/themes/solar/charcoal/index.js +2 -0
  223. package/lib/header/themes/solar/pearl/index.js +2 -0
  224. package/lib/heatmap/custom-elements.json +151 -0
  225. package/lib/heatmap/custom-elements.md +26 -0
  226. package/lib/heatmap/helpers/color.d.ts +30 -0
  227. package/lib/heatmap/helpers/color.js +66 -0
  228. package/lib/heatmap/helpers/text.d.ts +26 -0
  229. package/lib/heatmap/helpers/text.js +91 -0
  230. package/lib/heatmap/helpers/track.d.ts +102 -0
  231. package/lib/heatmap/helpers/track.js +160 -0
  232. package/lib/heatmap/helpers/types.d.ts +40 -0
  233. package/lib/heatmap/helpers/types.js +1 -0
  234. package/lib/heatmap/index.d.ts +453 -0
  235. package/lib/heatmap/index.js +1094 -0
  236. package/lib/heatmap/themes/halo/dark/index.js +4 -0
  237. package/lib/heatmap/themes/halo/light/index.js +4 -0
  238. package/lib/heatmap/themes/solar/charcoal/index.js +4 -0
  239. package/lib/heatmap/themes/solar/pearl/index.js +4 -0
  240. package/lib/icon/custom-elements.json +36 -0
  241. package/lib/icon/custom-elements.md +8 -0
  242. package/lib/icon/index.d.ts +90 -0
  243. package/lib/icon/index.js +171 -0
  244. package/lib/icon/themes/halo/dark/index.js +2 -0
  245. package/lib/icon/themes/halo/light/index.js +2 -0
  246. package/lib/icon/themes/solar/charcoal/index.js +2 -0
  247. package/lib/icon/themes/solar/pearl/index.js +2 -0
  248. package/lib/icon/utils/IconLoader.d.ts +52 -0
  249. package/lib/icon/utils/IconLoader.js +93 -0
  250. package/lib/index.d.ts +3 -0
  251. package/lib/index.js +3 -0
  252. package/lib/interactive-chart/custom-elements.json +82 -0
  253. package/lib/interactive-chart/custom-elements.md +31 -0
  254. package/lib/interactive-chart/helpers/merge.d.ts +15 -0
  255. package/lib/interactive-chart/helpers/merge.js +28 -0
  256. package/lib/interactive-chart/helpers/types.d.ts +45 -0
  257. package/lib/interactive-chart/helpers/types.js +6 -0
  258. package/lib/interactive-chart/index.d.ts +383 -0
  259. package/lib/interactive-chart/index.js +1089 -0
  260. package/lib/interactive-chart/themes/halo/dark/index.js +3 -0
  261. package/lib/interactive-chart/themes/halo/light/index.js +3 -0
  262. package/lib/interactive-chart/themes/solar/charcoal/index.js +3 -0
  263. package/lib/interactive-chart/themes/solar/pearl/index.js +3 -0
  264. package/lib/item/custom-elements.json +153 -0
  265. package/lib/item/custom-elements.md +29 -0
  266. package/lib/item/helpers/types.d.ts +57 -0
  267. package/lib/item/helpers/types.js +1 -0
  268. package/lib/item/index.d.ts +159 -0
  269. package/lib/item/index.js +269 -0
  270. package/lib/item/themes/halo/dark/index.js +4 -0
  271. package/lib/item/themes/halo/light/index.js +4 -0
  272. package/lib/item/themes/solar/charcoal/index.js +4 -0
  273. package/lib/item/themes/solar/pearl/index.js +4 -0
  274. package/lib/jsx.d.ts +223 -0
  275. package/lib/label/custom-elements.json +52 -0
  276. package/lib/label/custom-elements.md +11 -0
  277. package/lib/label/index.d.ts +102 -0
  278. package/lib/label/index.js +245 -0
  279. package/lib/label/themes/halo/dark/index.js +3 -0
  280. package/lib/label/themes/halo/light/index.js +3 -0
  281. package/lib/label/themes/solar/charcoal/index.js +3 -0
  282. package/lib/label/themes/solar/pearl/index.js +3 -0
  283. package/lib/layout/custom-elements.json +163 -0
  284. package/lib/layout/custom-elements.md +26 -0
  285. package/lib/layout/index.d.ts +107 -0
  286. package/lib/layout/index.js +212 -0
  287. package/lib/layout/themes/halo/dark/index.js +2 -0
  288. package/lib/layout/themes/halo/light/index.js +2 -0
  289. package/lib/layout/themes/solar/charcoal/index.js +2 -0
  290. package/lib/layout/themes/solar/pearl/index.js +2 -0
  291. package/lib/led-gauge/custom-elements.json +113 -0
  292. package/lib/led-gauge/custom-elements.md +17 -0
  293. package/lib/led-gauge/index.d.ts +144 -0
  294. package/lib/led-gauge/index.js +438 -0
  295. package/lib/led-gauge/themes/halo/dark/index.js +3 -0
  296. package/lib/led-gauge/themes/halo/light/index.js +3 -0
  297. package/lib/led-gauge/themes/solar/charcoal/index.js +3 -0
  298. package/lib/led-gauge/themes/solar/pearl/index.js +3 -0
  299. package/lib/list/custom-elements.json +137 -0
  300. package/lib/list/custom-elements.md +33 -0
  301. package/lib/list/extensible-function.d.ts +8 -0
  302. package/lib/list/extensible-function.js +13 -0
  303. package/lib/list/helpers/list-renderer.d.ts +9 -0
  304. package/lib/list/helpers/list-renderer.js +37 -0
  305. package/lib/list/helpers/types.d.ts +3 -0
  306. package/lib/list/helpers/types.js +1 -0
  307. package/lib/list/index.d.ts +313 -0
  308. package/lib/list/index.js +640 -0
  309. package/lib/list/renderer.d.ts +36 -0
  310. package/lib/list/renderer.js +9 -0
  311. package/lib/list/themes/halo/dark/index.js +3 -0
  312. package/lib/list/themes/halo/light/index.js +3 -0
  313. package/lib/list/themes/solar/charcoal/index.js +3 -0
  314. package/lib/list/themes/solar/pearl/index.js +3 -0
  315. package/lib/loader/custom-elements.json +9 -0
  316. package/lib/loader/custom-elements.md +5 -0
  317. package/lib/loader/index.d.ts +41 -0
  318. package/lib/loader/index.js +61 -0
  319. package/lib/loader/themes/halo/dark/index.js +2 -0
  320. package/lib/loader/themes/halo/light/index.js +2 -0
  321. package/lib/loader/themes/solar/charcoal/index.js +2 -0
  322. package/lib/loader/themes/solar/pearl/index.js +2 -0
  323. package/lib/multi-input/custom-elements.json +239 -0
  324. package/lib/multi-input/custom-elements.md +43 -0
  325. package/lib/multi-input/helpers/types.d.ts +11 -0
  326. package/lib/multi-input/helpers/types.js +1 -0
  327. package/lib/multi-input/index.d.ts +301 -0
  328. package/lib/multi-input/index.js +593 -0
  329. package/lib/multi-input/themes/halo/dark/index.js +4 -0
  330. package/lib/multi-input/themes/halo/light/index.js +4 -0
  331. package/lib/multi-input/themes/solar/charcoal/index.js +4 -0
  332. package/lib/multi-input/themes/solar/pearl/index.js +4 -0
  333. package/lib/notification/custom-elements.json +95 -0
  334. package/lib/notification/custom-elements.md +26 -0
  335. package/lib/notification/elements/notification-tray.d.ts +97 -0
  336. package/lib/notification/elements/notification-tray.js +167 -0
  337. package/lib/notification/elements/notification.d.ts +90 -0
  338. package/lib/notification/elements/notification.js +154 -0
  339. package/lib/notification/helpers/status.d.ts +30 -0
  340. package/lib/notification/helpers/status.js +130 -0
  341. package/lib/notification/helpers/types.d.ts +10 -0
  342. package/lib/notification/helpers/types.js +1 -0
  343. package/lib/notification/index.d.ts +2 -0
  344. package/lib/notification/index.js +2 -0
  345. package/lib/notification/themes/halo/dark/index.js +5 -0
  346. package/lib/notification/themes/halo/light/index.js +5 -0
  347. package/lib/notification/themes/solar/charcoal/index.js +5 -0
  348. package/lib/notification/themes/solar/pearl/index.js +5 -0
  349. package/lib/number-field/custom-elements.json +245 -0
  350. package/lib/number-field/custom-elements.md +42 -0
  351. package/lib/number-field/index.d.ts +339 -0
  352. package/lib/number-field/index.js +751 -0
  353. package/lib/number-field/themes/halo/dark/index.js +3 -0
  354. package/lib/number-field/themes/halo/light/index.js +3 -0
  355. package/lib/number-field/themes/solar/charcoal/index.js +3 -0
  356. package/lib/number-field/themes/solar/pearl/index.js +3 -0
  357. package/lib/overlay/custom-elements.json +355 -0
  358. package/lib/overlay/custom-elements.md +54 -0
  359. package/lib/overlay/elements/overlay-backdrop.d.ts +46 -0
  360. package/lib/overlay/elements/overlay-backdrop.js +64 -0
  361. package/lib/overlay/elements/overlay-viewport.d.ts +40 -0
  362. package/lib/overlay/elements/overlay-viewport.js +52 -0
  363. package/lib/overlay/elements/overlay.d.ts +408 -0
  364. package/lib/overlay/elements/overlay.js +1428 -0
  365. package/lib/overlay/helpers/functions.d.ts +13 -0
  366. package/lib/overlay/helpers/functions.js +16 -0
  367. package/lib/overlay/helpers/types.d.ts +97 -0
  368. package/lib/overlay/helpers/types.js +16 -0
  369. package/lib/overlay/index.d.ts +2 -0
  370. package/lib/overlay/index.js +1 -0
  371. package/lib/overlay/managers/backdrop-manager.d.ts +45 -0
  372. package/lib/overlay/managers/backdrop-manager.js +96 -0
  373. package/lib/overlay/managers/close-manager.d.ts +54 -0
  374. package/lib/overlay/managers/close-manager.js +138 -0
  375. package/lib/overlay/managers/focus-manager.d.ts +71 -0
  376. package/lib/overlay/managers/focus-manager.js +227 -0
  377. package/lib/overlay/managers/interaction-lock-manager.d.ts +138 -0
  378. package/lib/overlay/managers/interaction-lock-manager.js +375 -0
  379. package/lib/overlay/managers/viewport-manager.d.ts +93 -0
  380. package/lib/overlay/managers/viewport-manager.js +210 -0
  381. package/lib/overlay/managers/zindex-manager.d.ts +80 -0
  382. package/lib/overlay/managers/zindex-manager.js +195 -0
  383. package/lib/overlay/themes/halo/dark/index.js +4 -0
  384. package/lib/overlay/themes/halo/light/index.js +4 -0
  385. package/lib/overlay/themes/solar/charcoal/index.js +4 -0
  386. package/lib/overlay/themes/solar/pearl/index.js +4 -0
  387. package/lib/overlay-menu/custom-elements.json +246 -0
  388. package/lib/overlay-menu/custom-elements.md +44 -0
  389. package/lib/overlay-menu/helpers/types.d.ts +8 -0
  390. package/lib/overlay-menu/helpers/types.js +1 -0
  391. package/lib/overlay-menu/index.d.ts +387 -0
  392. package/lib/overlay-menu/index.js +932 -0
  393. package/lib/overlay-menu/managers/menu-manager.d.ts +98 -0
  394. package/lib/overlay-menu/managers/menu-manager.js +240 -0
  395. package/lib/overlay-menu/themes/halo/dark/index.js +5 -0
  396. package/lib/overlay-menu/themes/halo/light/index.js +5 -0
  397. package/lib/overlay-menu/themes/solar/charcoal/index.js +5 -0
  398. package/lib/overlay-menu/themes/solar/pearl/index.js +5 -0
  399. package/lib/pagination/custom-elements.json +76 -0
  400. package/lib/pagination/custom-elements.md +26 -0
  401. package/lib/pagination/index.d.ts +275 -0
  402. package/lib/pagination/index.js +551 -0
  403. package/lib/pagination/themes/halo/dark/index.js +6 -0
  404. package/lib/pagination/themes/halo/light/index.js +6 -0
  405. package/lib/pagination/themes/solar/charcoal/index.js +6 -0
  406. package/lib/pagination/themes/solar/pearl/index.js +6 -0
  407. package/lib/panel/custom-elements.json +39 -0
  408. package/lib/panel/custom-elements.md +11 -0
  409. package/lib/panel/index.d.ts +48 -0
  410. package/lib/panel/index.js +74 -0
  411. package/lib/panel/themes/halo/dark/index.js +2 -0
  412. package/lib/panel/themes/halo/light/index.js +2 -0
  413. package/lib/panel/themes/solar/charcoal/index.js +2 -0
  414. package/lib/panel/themes/solar/pearl/index.js +2 -0
  415. package/lib/password-field/custom-elements.json +151 -0
  416. package/lib/password-field/custom-elements.md +39 -0
  417. package/lib/password-field/index.d.ts +89 -0
  418. package/lib/password-field/index.js +115 -0
  419. package/lib/password-field/themes/halo/dark/index.js +3 -0
  420. package/lib/password-field/themes/halo/light/index.js +3 -0
  421. package/lib/password-field/themes/solar/charcoal/index.js +3 -0
  422. package/lib/password-field/themes/solar/pearl/index.js +3 -0
  423. package/lib/pill/custom-elements.json +97 -0
  424. package/lib/pill/custom-elements.md +22 -0
  425. package/lib/pill/index.d.ts +113 -0
  426. package/lib/pill/index.js +191 -0
  427. package/lib/pill/themes/halo/dark/index.js +3 -0
  428. package/lib/pill/themes/halo/light/index.js +3 -0
  429. package/lib/pill/themes/solar/charcoal/index.js +3 -0
  430. package/lib/pill/themes/solar/pearl/index.js +3 -0
  431. package/lib/progress-bar/custom-elements.json +58 -0
  432. package/lib/progress-bar/custom-elements.md +18 -0
  433. package/lib/progress-bar/index.d.ts +82 -0
  434. package/lib/progress-bar/index.js +157 -0
  435. package/lib/progress-bar/themes/halo/dark/index.js +2 -0
  436. package/lib/progress-bar/themes/halo/light/index.js +2 -0
  437. package/lib/progress-bar/themes/solar/charcoal/index.js +2 -0
  438. package/lib/progress-bar/themes/solar/pearl/index.js +2 -0
  439. package/lib/radio-button/custom-elements.json +84 -0
  440. package/lib/radio-button/custom-elements.md +19 -0
  441. package/lib/radio-button/index.d.ts +123 -0
  442. package/lib/radio-button/index.js +261 -0
  443. package/lib/radio-button/radio-button-registry.d.ts +22 -0
  444. package/lib/radio-button/radio-button-registry.js +95 -0
  445. package/lib/radio-button/themes/halo/dark/index.js +3 -0
  446. package/lib/radio-button/themes/halo/light/index.js +3 -0
  447. package/lib/radio-button/themes/solar/charcoal/index.js +3 -0
  448. package/lib/radio-button/themes/solar/pearl/index.js +3 -0
  449. package/lib/rating/custom-elements.json +58 -0
  450. package/lib/rating/custom-elements.md +17 -0
  451. package/lib/rating/index.d.ts +91 -0
  452. package/lib/rating/index.js +157 -0
  453. package/lib/rating/themes/halo/dark/index.js +2 -0
  454. package/lib/rating/themes/halo/light/index.js +2 -0
  455. package/lib/rating/themes/solar/charcoal/index.js +2 -0
  456. package/lib/rating/themes/solar/pearl/index.js +2 -0
  457. package/lib/search-field/custom-elements.json +169 -0
  458. package/lib/search-field/custom-elements.md +41 -0
  459. package/lib/search-field/index.d.ts +77 -0
  460. package/lib/search-field/index.js +88 -0
  461. package/lib/search-field/themes/halo/dark/index.js +3 -0
  462. package/lib/search-field/themes/halo/light/index.js +3 -0
  463. package/lib/search-field/themes/solar/charcoal/index.js +3 -0
  464. package/lib/search-field/themes/solar/pearl/index.js +3 -0
  465. package/lib/select/custom-elements.json +104 -0
  466. package/lib/select/custom-elements.md +24 -0
  467. package/lib/select/helpers/types.d.ts +3 -0
  468. package/lib/select/helpers/types.js +1 -0
  469. package/lib/select/index.d.ts +396 -0
  470. package/lib/select/index.js +978 -0
  471. package/lib/select/themes/halo/dark/index.js +5 -0
  472. package/lib/select/themes/halo/light/index.js +5 -0
  473. package/lib/select/themes/solar/charcoal/index.js +5 -0
  474. package/lib/select/themes/solar/pearl/index.js +5 -0
  475. package/lib/sidebar-layout/custom-elements.json +68 -0
  476. package/lib/sidebar-layout/custom-elements.md +21 -0
  477. package/lib/sidebar-layout/index.d.ts +70 -0
  478. package/lib/sidebar-layout/index.js +134 -0
  479. package/lib/sidebar-layout/themes/halo/dark/index.js +3 -0
  480. package/lib/sidebar-layout/themes/halo/light/index.js +3 -0
  481. package/lib/sidebar-layout/themes/solar/charcoal/index.js +3 -0
  482. package/lib/sidebar-layout/themes/solar/pearl/index.js +3 -0
  483. package/lib/slider/custom-elements.json +181 -0
  484. package/lib/slider/custom-elements.md +28 -0
  485. package/lib/slider/index.d.ts +409 -0
  486. package/lib/slider/index.js +1195 -0
  487. package/lib/slider/themes/halo/dark/index.js +3 -0
  488. package/lib/slider/themes/halo/light/index.js +3 -0
  489. package/lib/slider/themes/solar/charcoal/index.js +3 -0
  490. package/lib/slider/themes/solar/pearl/index.js +3 -0
  491. package/lib/sparkline/custom-elements.json +59 -0
  492. package/lib/sparkline/custom-elements.md +16 -0
  493. package/lib/sparkline/index.d.ts +109 -0
  494. package/lib/sparkline/index.js +187 -0
  495. package/lib/sparkline/themes/halo/dark/index.js +2 -0
  496. package/lib/sparkline/themes/halo/light/index.js +2 -0
  497. package/lib/sparkline/themes/solar/charcoal/index.js +2 -0
  498. package/lib/sparkline/themes/solar/pearl/index.js +2 -0
  499. package/lib/swing-gauge/const.d.ts +22 -0
  500. package/lib/swing-gauge/const.js +26 -0
  501. package/lib/swing-gauge/custom-elements.json +111 -0
  502. package/lib/swing-gauge/custom-elements.md +17 -0
  503. package/lib/swing-gauge/helpers.d.ts +8 -0
  504. package/lib/swing-gauge/helpers.js +105 -0
  505. package/lib/swing-gauge/index.d.ts +296 -0
  506. package/lib/swing-gauge/index.js +770 -0
  507. package/lib/swing-gauge/themes/halo/dark/index.js +3 -0
  508. package/lib/swing-gauge/themes/halo/light/index.js +3 -0
  509. package/lib/swing-gauge/themes/solar/charcoal/index.js +3 -0
  510. package/lib/swing-gauge/themes/solar/pearl/index.js +3 -0
  511. package/lib/swing-gauge/types.d.ts +34 -0
  512. package/lib/swing-gauge/types.js +1 -0
  513. package/lib/tab/custom-elements.json +136 -0
  514. package/lib/tab/custom-elements.md +23 -0
  515. package/lib/tab/index.d.ts +136 -0
  516. package/lib/tab/index.js +236 -0
  517. package/lib/tab/themes/halo/dark/index.js +4 -0
  518. package/lib/tab/themes/halo/light/index.js +4 -0
  519. package/lib/tab/themes/solar/charcoal/index.js +4 -0
  520. package/lib/tab/themes/solar/pearl/index.js +4 -0
  521. package/lib/tab-bar/custom-elements.json +64 -0
  522. package/lib/tab-bar/custom-elements.md +18 -0
  523. package/lib/tab-bar/helpers/animate.d.ts +16 -0
  524. package/lib/tab-bar/helpers/animate.js +53 -0
  525. package/lib/tab-bar/index.d.ts +198 -0
  526. package/lib/tab-bar/index.js +428 -0
  527. package/lib/tab-bar/themes/halo/dark/index.js +4 -0
  528. package/lib/tab-bar/themes/halo/light/index.js +4 -0
  529. package/lib/tab-bar/themes/solar/charcoal/index.js +4 -0
  530. package/lib/tab-bar/themes/solar/pearl/index.js +4 -0
  531. package/lib/text-field/custom-elements.json +199 -0
  532. package/lib/text-field/custom-elements.md +35 -0
  533. package/lib/text-field/index.d.ts +164 -0
  534. package/lib/text-field/index.js +284 -0
  535. package/lib/text-field/themes/halo/dark/index.js +3 -0
  536. package/lib/text-field/themes/halo/light/index.js +3 -0
  537. package/lib/text-field/themes/solar/charcoal/index.js +3 -0
  538. package/lib/text-field/themes/solar/pearl/index.js +3 -0
  539. package/lib/time-picker/custom-elements.json +122 -0
  540. package/lib/time-picker/custom-elements.md +28 -0
  541. package/lib/time-picker/index.d.ts +412 -0
  542. package/lib/time-picker/index.js +897 -0
  543. package/lib/time-picker/themes/halo/dark/index.js +4 -0
  544. package/lib/time-picker/themes/halo/light/index.js +4 -0
  545. package/lib/time-picker/themes/solar/charcoal/index.js +4 -0
  546. package/lib/time-picker/themes/solar/pearl/index.js +4 -0
  547. package/lib/toggle/custom-elements.json +84 -0
  548. package/lib/toggle/custom-elements.md +19 -0
  549. package/lib/toggle/index.d.ts +87 -0
  550. package/lib/toggle/index.js +153 -0
  551. package/lib/toggle/themes/halo/dark/index.js +2 -0
  552. package/lib/toggle/themes/halo/light/index.js +2 -0
  553. package/lib/toggle/themes/solar/charcoal/index.js +2 -0
  554. package/lib/toggle/themes/solar/pearl/index.js +2 -0
  555. package/lib/tooltip/custom-elements.json +62 -0
  556. package/lib/tooltip/custom-elements.md +14 -0
  557. package/lib/tooltip/elements/title-tooltip.d.ts +1 -0
  558. package/lib/tooltip/elements/title-tooltip.js +18 -0
  559. package/lib/tooltip/elements/tooltip-element.d.ts +21 -0
  560. package/lib/tooltip/elements/tooltip-element.js +54 -0
  561. package/lib/tooltip/helpers/overflow-tooltip.d.ts +9 -0
  562. package/lib/tooltip/helpers/overflow-tooltip.js +19 -0
  563. package/lib/tooltip/helpers/renderer.d.ts +8 -0
  564. package/lib/tooltip/helpers/renderer.js +11 -0
  565. package/lib/tooltip/helpers/types.d.ts +23 -0
  566. package/lib/tooltip/helpers/types.js +1 -0
  567. package/lib/tooltip/index.d.ts +232 -0
  568. package/lib/tooltip/index.js +475 -0
  569. package/lib/tooltip/managers/tooltip-manager.d.ts +15 -0
  570. package/lib/tooltip/managers/tooltip-manager.js +140 -0
  571. package/lib/tooltip/themes/halo/dark/index.js +3 -0
  572. package/lib/tooltip/themes/halo/light/index.js +3 -0
  573. package/lib/tooltip/themes/solar/charcoal/index.js +3 -0
  574. package/lib/tooltip/themes/solar/pearl/index.js +3 -0
  575. package/lib/tornado-chart/custom-elements.json +45 -0
  576. package/lib/tornado-chart/custom-elements.md +18 -0
  577. package/lib/tornado-chart/elements/tornado-chart.d.ts +78 -0
  578. package/lib/tornado-chart/elements/tornado-chart.js +122 -0
  579. package/lib/tornado-chart/elements/tornado-item.d.ts +110 -0
  580. package/lib/tornado-chart/elements/tornado-item.js +207 -0
  581. package/lib/tornado-chart/index.d.ts +2 -0
  582. package/lib/tornado-chart/index.js +2 -0
  583. package/lib/tornado-chart/themes/halo/dark/index.js +6 -0
  584. package/lib/tornado-chart/themes/halo/light/index.js +6 -0
  585. package/lib/tornado-chart/themes/solar/charcoal/index.js +6 -0
  586. package/lib/tornado-chart/themes/solar/pearl/index.js +6 -0
  587. package/lib/tree/custom-elements.json +114 -0
  588. package/lib/tree/custom-elements.md +32 -0
  589. package/lib/tree/elements/tree-item.d.ts +129 -0
  590. package/lib/tree/elements/tree-item.js +238 -0
  591. package/lib/tree/elements/tree.d.ts +203 -0
  592. package/lib/tree/elements/tree.js +414 -0
  593. package/lib/tree/helpers/filter.d.ts +8 -0
  594. package/lib/tree/helpers/filter.js +33 -0
  595. package/lib/tree/helpers/renderer.d.ts +5 -0
  596. package/lib/tree/helpers/renderer.js +33 -0
  597. package/lib/tree/helpers/types.d.ts +25 -0
  598. package/lib/tree/helpers/types.js +1 -0
  599. package/lib/tree/index.d.ts +4 -0
  600. package/lib/tree/index.js +3 -0
  601. package/lib/tree/managers/tree-manager.d.ts +248 -0
  602. package/lib/tree/managers/tree-manager.js +395 -0
  603. package/lib/tree/themes/halo/dark/index.js +7 -0
  604. package/lib/tree/themes/halo/light/index.js +7 -0
  605. package/lib/tree/themes/solar/charcoal/index.js +7 -0
  606. package/lib/tree/themes/solar/pearl/index.js +7 -0
  607. package/lib/tree-select/custom-elements.json +111 -0
  608. package/lib/tree-select/custom-elements.md +26 -0
  609. package/lib/tree-select/helpers/types.d.ts +4 -0
  610. package/lib/tree-select/helpers/types.js +1 -0
  611. package/lib/tree-select/index.d.ts +404 -0
  612. package/lib/tree-select/index.js +895 -0
  613. package/lib/tree-select/themes/halo/dark/index.js +11 -0
  614. package/lib/tree-select/themes/halo/light/index.js +11 -0
  615. package/lib/tree-select/themes/solar/charcoal/index.js +11 -0
  616. package/lib/tree-select/themes/solar/pearl/index.js +11 -0
  617. package/lib/version.d.ts +1 -0
  618. package/lib/version.js +1 -0
  619. package/package.json +355 -0
@@ -0,0 +1,1199 @@
1
+ import { __decorate } from "tslib";
2
+ import { FormFieldElement, css, html, WarningNotice, FocusedPropertyKey } from '@refinitiv-ui/core';
3
+ import { customElement } from '@refinitiv-ui/core/decorators/custom-element.js';
4
+ import { property } from '@refinitiv-ui/core/decorators/property.js';
5
+ import { query } from '@refinitiv-ui/core/decorators/query.js';
6
+ import { eventOptions } from '@refinitiv-ui/core/decorators/event-options.js';
7
+ import { styleMap } from '@refinitiv-ui/core/directives/style-map.js';
8
+ import { ifDefined } from '@refinitiv-ui/core/directives/if-defined.js';
9
+ import { VERSION } from '../version.js';
10
+ import { CollectionComposer } from '@refinitiv-ui/utils/collection.js';
11
+ import { AnimationTaskRunner, TimeoutTaskRunner } from '@refinitiv-ui/utils/async.js';
12
+ import { ComboBoxRenderer } from './helpers/renderer.js';
13
+ import { defaultFilter } from './helpers/filter.js';
14
+ import { CustomKeyboardEvent } from './helpers/keyboard-event.js';
15
+ import '../icon/index.js';
16
+ import '../overlay/index.js';
17
+ import '../list/index.js';
18
+ import '../counter/index.js';
19
+ import { translate } from '@refinitiv-ui/translate';
20
+ import '@refinitiv-ui/phrasebook/locale/en/combo-box.js';
21
+ export { ComboBoxRenderer };
22
+ const QUERY_DEBOUNCE_RATE = 0;
23
+ // Maximum number of characters to display in multiple mode
24
+ const MULTIPLE_LABEL_MAX_SIZE = 250;
25
+ // Separator for labels in multiple mode
26
+ // Double space is expected
27
+ const MULTIPLE_LABEL_SEPARATOR = '; ';
28
+ const POPUP_POSITION = ['bottom-start', 'top-start'];
29
+ const valueFormatWarning = new WarningNotice('The specified \'values\' format does not conform to the required format.');
30
+ const freeTextMultipleWarning = new WarningNotice('"free-text" mode is not compatible with "multiple" mode');
31
+ /**
32
+ * Combines a popup with a filterable selection list
33
+ *
34
+ * @attr {boolean} readonly - Set readonly state
35
+ * @prop {boolean} [readonly=false] - Set readonly state
36
+ *
37
+ * @attr {boolean} disabled - Set disabled state
38
+ * @prop {boolean} [disabled=false] - Set disabled state
39
+ *
40
+ * @attr {string} name - Set name of the element
41
+ * @prop {string} [name=''] - Set name of the element
42
+ *
43
+ * @fires value-changed - Dispatched when value changes
44
+ * @fires query-changed - Dispatched when query changes
45
+ * @fires opened-changed - Dispatched when opened state changes
46
+ */
47
+ let ComboBox = class ComboBox extends FormFieldElement {
48
+ constructor() {
49
+ super(...arguments);
50
+ /**
51
+ * Custom filter for static data
52
+ * Set this to null when data is filtered externally, eg XHR
53
+ * @type {ComboBoxFilter<T> | null}
54
+ */
55
+ this.filter = defaultFilter(this);
56
+ /**
57
+ * Renderer used to render list item elements
58
+ * @type {ComboBoxRenderer}
59
+ */
60
+ this.renderer = new ComboBoxRenderer(this);
61
+ this._multiple = false;
62
+ /**
63
+ * Track opened state of popup
64
+ */
65
+ this.opened = false;
66
+ /**
67
+ * Placeholder for input field
68
+ */
69
+ this.placeholder = '';
70
+ /**
71
+ * Show clears button
72
+ */
73
+ this.clears = false;
74
+ this._freeText = false;
75
+ /**
76
+ * Set state to error
77
+ */
78
+ this.error = false;
79
+ /**
80
+ * Set state to warning
81
+ */
82
+ this.warning = false;
83
+ // Internal reference to debounce rate
84
+ this._queryDebounceRate = QUERY_DEBOUNCE_RATE;
85
+ // Debounces the query using queryDebounceRate
86
+ this.queryDebouncer = new TimeoutTaskRunner(this._queryDebounceRate);
87
+ this._data = []; // Local data object set through data setter
88
+ /**
89
+ * `value` always initialised before `data`, so it cannot query and select items when using attribute.
90
+ * This variable is to store value for selecting a data item after data has been initialised.
91
+ */
92
+ this.cachedValue = '';
93
+ this._query = null; // Internally set and store query value
94
+ /**
95
+ * Composer used to query and modify item state.
96
+ */
97
+ this.composer = new CollectionComposer([]);
98
+ /**
99
+ * Initiate one time popup rendering
100
+ */
101
+ this.lazyRendered = false;
102
+ /**
103
+ * Throttle popup resizing
104
+ */
105
+ this.resizeThrottler = new AnimationTaskRunner();
106
+ /**
107
+ * Input text to display in text field while typing
108
+ * Use because of query debouncer to avoid input to be not in sync with query
109
+ */
110
+ this.inputText = '';
111
+ /**
112
+ * Used to store free text value
113
+ * If freeText mode is defined
114
+ */
115
+ this.freeTextValue = '';
116
+ /**
117
+ * Hold popup styling applied on open
118
+ */
119
+ this.popupDynamicStyles = {};
120
+ /**
121
+ * Use to call request update when CC changes its value
122
+ * @returns {void}
123
+ */
124
+ this.modificationHandler = () => this.modificationUpdate();
125
+ this._resolvedData = [];
126
+ this.dataPromiseCounter = 0; // A counter to detect that the promise resolved is the last promise set
127
+ /**
128
+ * Mark combobox with loading flag
129
+ * Used in conjunction with data promise
130
+ */
131
+ this.loading = false;
132
+ this.shouldOpenOnFocus = false;
133
+ }
134
+ /**
135
+ * Element version number
136
+ * @returns version number
137
+ */
138
+ static get version() {
139
+ return VERSION;
140
+ }
141
+ /**
142
+ * A `CSSResultGroup` that will be used
143
+ * to style the host, slotted children
144
+ * and the internal template of the element.
145
+ * @return CSS template
146
+ */
147
+ static get styles() {
148
+ return css `
149
+ :host {
150
+ display: inline-flex;
151
+ flex-flow: row nowrap;
152
+ user-select: none;
153
+ outline: none;
154
+ }
155
+ [part~=input-wrapper] {
156
+ cursor: pointer;
157
+ }
158
+ [part~=input] {
159
+ cursor: text;
160
+ }
161
+ [part~=input]::-ms-clear {
162
+ display: none;
163
+ }
164
+ [hidden] {
165
+ display: none !important;
166
+ }
167
+ `;
168
+ }
169
+ /**
170
+ * Multiple selection mode
171
+ * @param multiple true to set multiple mode
172
+ * @default false
173
+ */
174
+ set multiple(multiple) {
175
+ if (multiple && this.freeText) {
176
+ freeTextMultipleWarning.show();
177
+ multiple = false;
178
+ }
179
+ const oldMultiple = this._multiple;
180
+ this._multiple = multiple;
181
+ this.requestUpdate('multiple', oldMultiple);
182
+ }
183
+ get multiple() {
184
+ return this._multiple;
185
+ }
186
+ /**
187
+ * Allow to enter any value
188
+ * @param freeText true to set freeText mode
189
+ * @default false
190
+ */
191
+ set freeText(freeText) {
192
+ if (this.multiple && freeText) {
193
+ freeTextMultipleWarning.show();
194
+ freeText = false;
195
+ }
196
+ if (!freeText) {
197
+ this.freeTextValue = '';
198
+ }
199
+ const oldFreeText = this._freeText;
200
+ this._freeText = freeText;
201
+ this.requestUpdate('freeText', oldFreeText);
202
+ }
203
+ get freeText() {
204
+ return this._freeText;
205
+ }
206
+ /**
207
+ * Control query rate, defaults to 0
208
+ */
209
+ get queryDebounceRate() {
210
+ return this._queryDebounceRate;
211
+ }
212
+ set queryDebounceRate(value) {
213
+ const oldValue = this._queryDebounceRate;
214
+ if (value !== oldValue) {
215
+ this._queryDebounceRate = value;
216
+ this.queryDebouncer = new TimeoutTaskRunner(this._queryDebounceRate);
217
+ // no need to update as this is called for input changes
218
+ }
219
+ }
220
+ /**
221
+ * Data array to be displayed
222
+ * @type {ComboBoxData<T>}
223
+ * @default []
224
+ */
225
+ get data() {
226
+ return this._data;
227
+ }
228
+ set data(value) {
229
+ this._data = value;
230
+ void this.resolveDataPromise(value);
231
+ }
232
+ /**
233
+ * Returns the first selected item value.
234
+ * Use `values` when multiple selection mode is enabled.
235
+ * @default -
236
+ */
237
+ get value() {
238
+ return this.values[0] || '';
239
+ }
240
+ set value(value) {
241
+ /**
242
+ * Set the value if the data is ready,
243
+ * otherwise cache it for later.
244
+ */
245
+ if (this.composer.size) {
246
+ this.values = [value];
247
+ }
248
+ else {
249
+ this.cachedValue = value;
250
+ }
251
+ }
252
+ /**
253
+ * Returns a values collection of the currently
254
+ * selected item values
255
+ * @type {string[]}
256
+ * @default []
257
+ */
258
+ get values() {
259
+ // In free text mode, compare selected to values
260
+ return this.freeTextValue ? [this.freeTextValue] : this.composerValues;
261
+ }
262
+ set values(values) {
263
+ if (!Array.isArray(values)) {
264
+ valueFormatWarning.show();
265
+ this.values = [];
266
+ }
267
+ else {
268
+ // Clone value arrays
269
+ const newValues = values.slice(0, this.multiple ? values.length : 1);
270
+ const oldValues = this.values.slice();
271
+ // Create comparison strings to check for differences
272
+ const newComparison = newValues.sort().toString();
273
+ const oldComparison = oldValues.sort().toString();
274
+ // Update the selection state when found new value
275
+ if (newComparison !== oldComparison) {
276
+ this.updateComposerValues(newValues);
277
+ if (this.freeText) {
278
+ // free text mode is only supported in single selection mode
279
+ // so if there is no valid selection in the composer, we can assume
280
+ // the first item can be used as the free text item.
281
+ this.freeTextValue = !this.composerValues.length ? newValues[0] : '';
282
+ }
283
+ this.requestUpdate('values', oldValues);
284
+ }
285
+ }
286
+ }
287
+ /**
288
+ * Update composer values.
289
+ * @param newValues new values
290
+ * @returns {void}
291
+ */
292
+ updateComposerValues(newValues) {
293
+ this.queryItems((item, composer) => {
294
+ if (newValues.includes(composer.getItemPropertyValue(item, 'value'))) {
295
+ composer.setItemPropertyValue(item, 'selected', true);
296
+ return true;
297
+ }
298
+ composer.setItemPropertyValue(item, 'selected', false);
299
+ return false;
300
+ });
301
+ }
302
+ /**
303
+ * Query string applied to combo-box
304
+ * Set via internal input
305
+ * @readonly
306
+ * @default null
307
+ */
308
+ get query() {
309
+ return this._query;
310
+ }
311
+ set query(query) {
312
+ const oldVal = this._query;
313
+ this._query = query;
314
+ this.queryDebouncer.cancel();
315
+ if (oldVal !== this._query) {
316
+ this.clearHighlighted();
317
+ this.filterItems();
318
+ this.requestUpdate('query', oldVal);
319
+ }
320
+ }
321
+ /**
322
+ * Label of selected value
323
+ * @returns Label to use, defaults to empty string
324
+ * @default -
325
+ * @readonly
326
+ */
327
+ get label() {
328
+ const labels = this.selectedLabels;
329
+ if (labels.length <= 1) {
330
+ return labels[0] || '';
331
+ }
332
+ // multiple mode, do according to UX specs
333
+ const output = labels.join(MULTIPLE_LABEL_SEPARATOR);
334
+ return output.length > MULTIPLE_LABEL_MAX_SIZE ? `${output.slice(0, MULTIPLE_LABEL_MAX_SIZE - 3)}...` : output;
335
+ }
336
+ /**
337
+ * Get resolved data (if possible)
338
+ */
339
+ get resolvedData() {
340
+ return this._resolvedData;
341
+ }
342
+ /**
343
+ * Set resolved data
344
+ * @param value resolved data
345
+ */
346
+ set resolvedData(value) {
347
+ const oldValue = this._resolvedData;
348
+ if (value !== oldValue) {
349
+ if (Array.isArray(value)) {
350
+ this.composer = new CollectionComposer(value);
351
+ }
352
+ else {
353
+ this.composer = new CollectionComposer([]);
354
+ }
355
+ this.listenToComposer();
356
+ this._resolvedData = value;
357
+ /**
358
+ * Select using initialised the value once from attribute/property,
359
+ * only when there is no existing selections.
360
+ */
361
+ if (this.cachedValue && this.selection.length === 0) {
362
+ this.value = this.cachedValue;
363
+ this.cachedValue = ''; // Reset as it's only needed for initialisation
364
+ }
365
+ this.requestUpdate('data', oldValue);
366
+ }
367
+ }
368
+ /**
369
+ * Used to resolve data when set as a promise
370
+ * @param data Data promise
371
+ * @returns Promise<void>
372
+ */
373
+ async resolveDataPromise(data) {
374
+ const dataPromiseCounter = this.dataPromiseCounter += 1;
375
+ let resolvedData;
376
+ if (data instanceof Promise) {
377
+ this.loading = true;
378
+ try {
379
+ resolvedData = await data;
380
+ }
381
+ catch (error) {
382
+ resolvedData = [];
383
+ }
384
+ }
385
+ else {
386
+ resolvedData = data;
387
+ }
388
+ if (dataPromiseCounter === this.dataPromiseCounter) {
389
+ this.resolvedData = resolvedData;
390
+ this.loading = false;
391
+ }
392
+ }
393
+ /**
394
+ * The the values from composer ignoring freeTextValue
395
+ */
396
+ get composerValues() {
397
+ return this.queryItemsByPropertyValue('selected', true)
398
+ .map(item => this.getItemPropertyValue(item, 'value'));
399
+ }
400
+ /**
401
+ * Get the first value of highlighted item
402
+ */
403
+ get highlightedItemValue() {
404
+ if (!this.opened) {
405
+ return null;
406
+ }
407
+ return this.highlightedItems.map(item => this.getItemPropertyValue(item, 'value'))[0] || '';
408
+ }
409
+ /**
410
+ * Return currently selected items
411
+ * This is distinct from values as for controls with persistence features
412
+ * it can be used to show current selection count and get the selection labels
413
+ * @returns List of selected items
414
+ */
415
+ get selection() {
416
+ return this.queryItemsByPropertyValue('selected', true).slice();
417
+ }
418
+ /**
419
+ * Count of selected items
420
+ * @returns Has selection
421
+ */
422
+ get selectionCount() {
423
+ return this.selection.length;
424
+ }
425
+ /**
426
+ * Determine if list has visible items
427
+ * @returns List has visible items or not
428
+ */
429
+ get listHasVisibleItems() {
430
+ return this.resolvedData.some(item => !this.getItemPropertyValue(item, 'hidden'));
431
+ }
432
+ /**
433
+ * Selected item
434
+ * @returns Has selection
435
+ */
436
+ get selectedItem() {
437
+ return this.queryItemsByPropertyValue('selected', true)[0];
438
+ }
439
+ /**
440
+ * Get a list of selected item labels
441
+ * @returns Has selection
442
+ */
443
+ get selectedLabels() {
444
+ return this.selection.map(selected => this.getItemPropertyValue(selected, 'label') || '');
445
+ }
446
+ /**
447
+ * Utility method - ensures correct composer is being listened to
448
+ * @returns {void}
449
+ */
450
+ listenToComposer() {
451
+ this.composer.on('modification', // Listen for modifications
452
+ this.modificationHandler // Update the template
453
+ );
454
+ }
455
+ /**
456
+ * Updates the element
457
+ * @param changedProperties Properties that has changed
458
+ * @returns {void}
459
+ */
460
+ update(changedProperties) {
461
+ const focusedChanged = changedProperties.has(FocusedPropertyKey);
462
+ // the opened logic is bound to focus state
463
+ if (focusedChanged) {
464
+ // When focus changes the popup can open only on tapstart
465
+ if (this.focused && this.shouldOpenOnFocus) {
466
+ this.setOpened(true);
467
+ }
468
+ else if (!this.focused) {
469
+ this.setOpened(false);
470
+ }
471
+ this.shouldOpenOnFocus = false;
472
+ }
473
+ /*
474
+ * data can be visible and opened changed = open
475
+ * or, opened is true and data; and contains visible data = open
476
+ * queries local properties first to short circuit querying map iteration
477
+ */
478
+ if (changedProperties.has('opened')) {
479
+ if (this.opened) {
480
+ // fulfil any queries if opened is changed
481
+ // this is the case if keyboard navigation is used
482
+ this.queryDebouncer.fulfil();
483
+ this.opening();
484
+ }
485
+ else {
486
+ this.clearHighlighted();
487
+ }
488
+ }
489
+ // combo-box may be opened programmatically (via opened attribute)
490
+ // make sure that the element correctly reacts on this change
491
+ if ((changedProperties.has('data') && this.opened && !this.focused) || focusedChanged) {
492
+ this.resetInput();
493
+ }
494
+ // If label is defined it means that there is an actual value
495
+ // Select input text to simplify clearing the value
496
+ if (focusedChanged && this.focused && this.label && this.inputElement) {
497
+ this.inputElement.focus();
498
+ this.inputElement.select();
499
+ }
500
+ // Make sure that the first item is always highlighted
501
+ if (this.opened && (changedProperties.has('opened') || changedProperties.has('data') || changedProperties.has('query'))) {
502
+ this.highlightFirstItem();
503
+ }
504
+ // If data is set asynchronously while popup is opened
505
+ // list might not trigger popup update
506
+ if (changedProperties.has('data') && this.opened) {
507
+ this.forcePopupLayout();
508
+ }
509
+ super.update(changedProperties);
510
+ }
511
+ /**
512
+ * Called once after the component is first rendered
513
+ * @param changedProperties map of changed properties with old values
514
+ * @returns {void}
515
+ */
516
+ firstUpdated(changedProperties) {
517
+ super.firstUpdated(changedProperties);
518
+ this.addEventListener('keydown', this.onKeyDown);
519
+ this.addEventListener('tapstart', this.onTapStart);
520
+ }
521
+ /**
522
+ * Sets opened state and fires event
523
+ * Use this to set opened state when user interacts to the component
524
+ * @param opened True if opened
525
+ * @returns {void}
526
+ */
527
+ setOpened(opened) {
528
+ if (this.opened !== opened && this.notifyPropertyChange('opened', opened, true)) {
529
+ this.opened = opened;
530
+ }
531
+ }
532
+ /**
533
+ * Requests an update after a composer modification.
534
+ * @returns {void}
535
+ */
536
+ modificationUpdate() {
537
+ this.requestUpdate();
538
+ }
539
+ /**
540
+ * Queries the composer for data items
541
+ * @param engine Composer query engine
542
+ * @returns Collection of matched items
543
+ */
544
+ queryItems(engine) {
545
+ return this.composer.queryItems(engine);
546
+ }
547
+ /**
548
+ * Queries the composer for data items,
549
+ * matching by property value.
550
+ * @param property Property name to query
551
+ * @param value Property value to match against
552
+ * @returns Collection of matched items
553
+ */
554
+ queryItemsByPropertyValue(property, value) {
555
+ return this.composer.queryItemsByPropertyValue(property, value, 0);
556
+ }
557
+ /**
558
+ * Gets the property value of an item
559
+ * @param item Original data item
560
+ * @param property Property name to get the value of
561
+ * @returns Value of the property
562
+ */
563
+ getItemPropertyValue(item, property) {
564
+ return this.composer.getItemPropertyValue(item, property);
565
+ }
566
+ /**
567
+ * Sets the property value of an item
568
+ * @param item Original data item
569
+ * @param property Property name to set the value of
570
+ * @param value New value of the property
571
+ * @returns {void}
572
+ */
573
+ setItemPropertyValue(item, property, value) {
574
+ this.composer.setItemPropertyValue(item, property, value);
575
+ }
576
+ /**
577
+ * Set width on popup using parent and --list-max-width if set
578
+ * @returns {void}
579
+ */
580
+ opening() {
581
+ this.lazyRendered = true;
582
+ this.restrictPopupWidth();
583
+ }
584
+ /**
585
+ * Scrolls to the currently selected item
586
+ * @returns {void}
587
+ */
588
+ scrollToSelected() {
589
+ const item = this.selectedItem;
590
+ if (item) {
591
+ this.listEl?.scrollToItem(item);
592
+ }
593
+ }
594
+ /**
595
+ * Get a list of highlighted items
596
+ */
597
+ get highlightedItems() {
598
+ return this.queryItemsByPropertyValue('highlighted', true);
599
+ }
600
+ /**
601
+ * Highlights the item
602
+ * @param item data item to highlight
603
+ * @returns {void}
604
+ */
605
+ highlightItem(item) {
606
+ this.clearHighlighted();
607
+ this.setItemPropertyValue(item, 'highlighted', true);
608
+ }
609
+ /**
610
+ * Clears any highlighted items
611
+ * @returns {void}
612
+ */
613
+ clearHighlighted() {
614
+ this.highlightedItems.forEach(item => this.setItemPropertyValue(item, 'highlighted', false));
615
+ }
616
+ /**
617
+ * Popup has to use max width if --list-max-width specified
618
+ * otherwise, popup should have same width as control or wider
619
+ * @returns {void}
620
+ */
621
+ restrictPopupWidth() {
622
+ /* istanbul ignore next */
623
+ if (this.offsetWidth === 0) {
624
+ // this code might happen only when opened has been set during initialisation
625
+ // or when display is set to none
626
+ this.resizeThrottler.schedule(() => {
627
+ if (this.offsetWidth) { /* must be here to avoid infinitive loop */
628
+ this.restrictPopupWidth();
629
+ this.requestUpdate();
630
+ }
631
+ });
632
+ return;
633
+ }
634
+ const maxWidth = parseFloat(this.getComputedVariable('--list-max-width', 'none'));
635
+ let minWidth = this.offsetWidth;
636
+ // reset min-width if max-width less than min-width, otherwise browser won't apply max-width
637
+ if (maxWidth < minWidth) {
638
+ minWidth = 0;
639
+ }
640
+ this.popupDynamicStyles.minWidth = `${minWidth}px`;
641
+ }
642
+ /**
643
+ * Set the query string and run `query-change` event
644
+ * @param query query
645
+ * @returns void
646
+ */
647
+ setQuery(query) {
648
+ const oldQuery = this.query;
649
+ this.query = query; // reset debouncer here
650
+ if (oldQuery !== query) {
651
+ this.notifyPropertyChange('query', this.query);
652
+ }
653
+ }
654
+ /**
655
+ * Reset the input text to match label
656
+ * @returns {void}
657
+ */
658
+ resetInput() {
659
+ this.setQuery('');
660
+ this.inputText = this.multiple ? '' : (this.freeTextValue || this.label);
661
+ }
662
+ /**
663
+ * Filter the internal items by query
664
+ * Changes items' hidden state
665
+ * @returns {void}
666
+ */
667
+ filterItems() {
668
+ // if filter is null, it is off and external app is responsible
669
+ if (this.filter) {
670
+ // we do not produce a new list as it will loose all association with this composer
671
+ // unless we spent time re-applying this composer to a new list/composer
672
+ // instead we change the hidden state
673
+ // by list applying a queryItems itself and does not render hidden items
674
+ // filter declared here to avoid the possibility of being null if used directly in the callback
675
+ const filter = this.filter;
676
+ let groupHeaderItem = null;
677
+ this.queryItems((item, composer) => {
678
+ // do not filter hidden items
679
+ if (item.hidden) {
680
+ return false;
681
+ }
682
+ let result = false;
683
+ // support groups
684
+ if (composer.getItemPropertyValue(item, 'type') === 'header') {
685
+ groupHeaderItem = item;
686
+ }
687
+ else {
688
+ result = filter(item);
689
+ }
690
+ composer.setItemPropertyValue(item, 'hidden', !result);
691
+ composer.updateItemTimestamp(item);
692
+ if (result && groupHeaderItem && composer.getItemParent(groupHeaderItem) === composer.getItemParent(item)) {
693
+ composer.setItemPropertyValue(groupHeaderItem, 'hidden', false);
694
+ composer.updateItemTimestamp(groupHeaderItem);
695
+ groupHeaderItem = null;
696
+ }
697
+ return result;
698
+ });
699
+ }
700
+ this.forcePopupLayout();
701
+ }
702
+ /**
703
+ * Highlight the selected item or the first available item
704
+ * @returns {void}
705
+ */
706
+ highlightFirstItem() {
707
+ let selectedItem = null;
708
+ const highlightItem = this.queryItems((item, composer) => {
709
+ if (selectedItem || !this.canHighlightItem(item, composer)) {
710
+ return false;
711
+ }
712
+ if (composer.getItemPropertyValue(item, 'selected') === true) {
713
+ selectedItem = item;
714
+ }
715
+ return true;
716
+ })[0];
717
+ (selectedItem || highlightItem) && this.highlightItem(selectedItem || highlightItem);
718
+ }
719
+ /**
720
+ * Check if an item can be highlighted
721
+ * @param item Collection composer item
722
+ * @param composer Collection composer
723
+ * @returns can highlight
724
+ */
725
+ canHighlightItem(item, composer) {
726
+ let canHighlight = !(composer.getItemPropertyValue(item, 'hidden') === true
727
+ || (composer.getItemPropertyValue(item, 'type') || 'text') !== 'text'
728
+ || composer.getItemPropertyValue(item, 'disabled') === true
729
+ || composer.isItemLocked(item) === true);
730
+ // check ancestors
731
+ if (canHighlight) {
732
+ const parent = composer.getItemParent(item);
733
+ canHighlight = !parent || this.canHighlightItem(parent, composer);
734
+ }
735
+ return canHighlight;
736
+ }
737
+ /**
738
+ * https://github.com/juggle/resize-observer/issues/42
739
+ *
740
+ * This event ensures that ResizeObserver picks up resize events
741
+ * when popup is deeply nested inside shadow root.
742
+ * TODO: remove this workaround once ResizeObserver handles shadow root scenario
743
+ * @returns {void}
744
+ */
745
+ forcePopupLayout() {
746
+ window.dispatchEvent(new Event('animationiteration'));
747
+ }
748
+ /**
749
+ * Shift focus back to input.
750
+ * This method is required to prevent popup from focusing
751
+ * @returns {void}
752
+ */
753
+ shiftFocus() {
754
+ this.focus({
755
+ preventScroll: true
756
+ });
757
+ }
758
+ /**
759
+ * Runs on input element `input` event
760
+ * @param event `input` event
761
+ * @returns {void}
762
+ */
763
+ onInputInput(event) {
764
+ this.onInputValueChanged(event);
765
+ }
766
+ /**
767
+ * Runs on input element `change` event
768
+ * @param event `change` event
769
+ * @returns {void}
770
+ */
771
+ onInputChange(event) {
772
+ this.onInputValueChanged(event);
773
+ }
774
+ /**
775
+ * Handle text value change from input field
776
+ * @param event Custom Event fired from input field
777
+ * @returns {void}
778
+ */
779
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
780
+ onInputValueChanged(event) {
781
+ const inputText = this.inputValue;
782
+ /**
783
+ * Query is used to track if there is a query
784
+ * We always use it so the absence of it can be used to reapply the
785
+ * selected item's label, if applicable
786
+ */
787
+ this.queryDebouncer.schedule(() => {
788
+ this.setQuery(inputText);
789
+ });
790
+ // Reset text when clearing the value
791
+ if (!this.multiple && !inputText) {
792
+ this.setValueAndNotify('');
793
+ }
794
+ // always ensure that internal val matches input val
795
+ this.inputText = inputText;
796
+ // Used for free input. Never set it unless in free text mode
797
+ if (this.freeText) {
798
+ this.value = ''; // make sure that composer does not have selected
799
+ this.freeTextValue = inputText;
800
+ this.notifyPropertyChange('value', inputText);
801
+ }
802
+ this.setOpened(true);
803
+ }
804
+ /**
805
+ * Handle list value changed
806
+ * @returns {void}
807
+ */
808
+ onListValueChanged() {
809
+ // cascade value changed event
810
+ this.notifyPropertyChange('value', this.value);
811
+ this.onListInteraction();
812
+ }
813
+ /**
814
+ * Handle popup opened event
815
+ *
816
+ * Scrolls the current selection into view
817
+ * @returns {void}
818
+ */
819
+ onPopupOpened() {
820
+ this.scrollToSelected();
821
+ }
822
+ /**
823
+ * Handle popup closed event
824
+ *
825
+ * Ensures that popup state equals combo box opened prop
826
+ * @returns {void}
827
+ */
828
+ onPopupClosed() {
829
+ this.setOpened(false);
830
+ }
831
+ /**
832
+ * Run when input-wrapper is tapped
833
+ * @param event Tap event
834
+ * @returns {void}
835
+ */
836
+ onTapStart(event) {
837
+ // do nothing if disabled or readonly
838
+ if (this.readonly || this.disabled) {
839
+ return;
840
+ }
841
+ const path = event.composedPath();
842
+ if (this.clearsButtonEl && path.includes(this.clearsButtonEl)) {
843
+ this.onClearsButtonTap();
844
+ return;
845
+ }
846
+ if (path.includes(this.toggleButtonEl)) {
847
+ this.onToggleButtonTap();
848
+ return;
849
+ }
850
+ this.onInputWrapperTap();
851
+ }
852
+ /**
853
+ * Run when tap event happens on toggle button
854
+ * @returns {void}
855
+ */
856
+ onToggleButtonTap() {
857
+ if (this.opened) {
858
+ this.setOpened(false);
859
+ }
860
+ else {
861
+ this.openOnFocus();
862
+ }
863
+ }
864
+ /**
865
+ * Run when tap event happens on clears button
866
+ * @returns {void}
867
+ */
868
+ onClearsButtonTap() {
869
+ this.freeTextValue = '';
870
+ this.inputText = '';
871
+ this.setQuery('');
872
+ this.setValueAndNotify('');
873
+ this.openOnFocus();
874
+ }
875
+ /**
876
+ * Run when tap event happens on input wrapper
877
+ * excluding clears and toggles buttons
878
+ * @returns {void}
879
+ */
880
+ onInputWrapperTap() {
881
+ this.openOnFocus();
882
+ }
883
+ /**
884
+ * This flag is required to remove the frame gap
885
+ * between tap start and opening the popup
886
+ * @returns {void}
887
+ */
888
+ openOnFocus() {
889
+ if (this.opened) {
890
+ return;
891
+ }
892
+ if (this.focused) {
893
+ this.setOpened(true);
894
+ return;
895
+ }
896
+ this.shouldOpenOnFocus = true;
897
+ }
898
+ /**
899
+ * Handles key input
900
+ * @param event Key down event object
901
+ * @returns {void}
902
+ */
903
+ onKeyDown(event) {
904
+ // Check if the event is already handle by list or it set to 'readonly'
905
+ if (event.defaultPrevented || this.readonly) {
906
+ return;
907
+ }
908
+ switch (event.key) {
909
+ case 'Enter':
910
+ this.enter(event);
911
+ break;
912
+ case 'Up':
913
+ case 'ArrowUp':
914
+ this.up(event);
915
+ break;
916
+ case 'Down':
917
+ case 'ArrowDown':
918
+ this.down(event);
919
+ break;
920
+ default:
921
+ return;
922
+ }
923
+ event.preventDefault();
924
+ }
925
+ /**
926
+ * Run when tap event or enter
927
+ * happened on the list
928
+ * @returns {void}
929
+ */
930
+ onListInteraction() {
931
+ this.freeTextValue = ''; // when the item has been selected, reset the freeText
932
+ if (!this.multiple) {
933
+ this.resetInput();
934
+ const label = this.label;
935
+ this.setOpened(false);
936
+ // make sure that focus is kept withing an element
937
+ // and the cursor is positioned at the end of input
938
+ // Wait before the update cycle completes
939
+ void this.updateComplete.then(() => {
940
+ if (this.inputElement) {
941
+ this.inputElement.focus();
942
+ this.inputElement.setSelectionRange(label.length, label.length);
943
+ }
944
+ });
945
+ }
946
+ }
947
+ /**
948
+ * Handles action keys, either opening the list,
949
+ * or, selecting a highlighted item.
950
+ * @param event keyboard event
951
+ * @returns {void}
952
+ */
953
+ enter(event) {
954
+ if (this.opened && this.listEl) {
955
+ this.reTargetEvent(event, this.listEl);
956
+ this.onListInteraction();
957
+ }
958
+ else {
959
+ this.setOpened(true);
960
+ }
961
+ }
962
+ /**
963
+ * Navigates up the list.
964
+ * Opens the list if closed.
965
+ * @param event keyboard event
966
+ * @returns {void}
967
+ */
968
+ up(event) {
969
+ if (this.opened && this.listEl) {
970
+ this.reTargetEvent(event, this.listEl);
971
+ }
972
+ else {
973
+ this.setOpened(true);
974
+ }
975
+ }
976
+ /**
977
+ * Navigates down the list.
978
+ * Opens the list if closed.
979
+ * @param event keyboard event
980
+ * @returns {void}
981
+ */
982
+ down(event) {
983
+ if (this.opened && this.listEl) {
984
+ this.reTargetEvent(event, this.listEl);
985
+ }
986
+ else {
987
+ this.setOpened(true);
988
+ }
989
+ }
990
+ /**
991
+ * Retarget event to target element
992
+ * @param event keyboard event
993
+ * @param target new target element
994
+ * @returns re-targeted event or the passed event if target is invalid
995
+ */
996
+ reTargetEvent(event, target) {
997
+ const path = event.composedPath();
998
+ /* istanbul ignore next */
999
+ if (path[0] === target) {
1000
+ // this must not happen, but keep it here to avoid infinitive loop
1001
+ return event;
1002
+ }
1003
+ const keyboardEvent = new CustomKeyboardEvent(event.type, event);
1004
+ target.dispatchEvent(keyboardEvent);
1005
+ if (keyboardEvent.defaultPrevented) {
1006
+ event.preventDefault();
1007
+ }
1008
+ return keyboardEvent;
1009
+ }
1010
+ /**
1011
+ * Template for clear button
1012
+ * Rendered when `clears` attribute is set
1013
+ * @returns Popup template or undefined
1014
+ */
1015
+ get clearButtonTemplate() {
1016
+ if (this.clears) {
1017
+ return html `
1018
+ <div
1019
+ id="clears-button"
1020
+ part="button button-clear"
1021
+ ?hidden=${!this.label && !this.query && !this.freeTextValue && !this.inputText}><ef-icon part="icon icon-clear" icon="cross"></ef-icon>
1022
+ </div>
1023
+ `;
1024
+ }
1025
+ }
1026
+ /**
1027
+ * Template for selection badge in multiple mode
1028
+ * @returns Selection badge template or undefined
1029
+ */
1030
+ get selectionBadgeTemplate() {
1031
+ if (this.multiple) {
1032
+ const selectionLength = this.selectionCount;
1033
+ // TODO Make this a short format number using i18n which has specific support for this +
1034
+ // benefit of being localised too
1035
+ if (this.focused || selectionLength > 1) {
1036
+ return html `
1037
+ <ef-counter part="selection-badge" tabindex="-1" .value=${selectionLength} title=${ifDefined(selectionLength > 999 ? selectionLength.toLocaleString() : undefined)} max="999"></ef-counter>
1038
+ `;
1039
+ }
1040
+ }
1041
+ }
1042
+ /**
1043
+ * Returns a list template
1044
+ */
1045
+ get listTemplate() {
1046
+ return html `
1047
+ <ef-list
1048
+ id="internal-list"
1049
+ @value-changed="${this.onListValueChanged}"
1050
+ .data="${this.composer}"
1051
+ .multiple="${this.multiple}"
1052
+ .renderer="${this.renderer}"
1053
+ ></ef-list>
1054
+ `;
1055
+ }
1056
+ /**
1057
+ * Returns a template showing no options text
1058
+ * Called when freeText mode is off and all items are filtered out
1059
+ */
1060
+ get noItemsTemplate() {
1061
+ if (!this.freeText) {
1062
+ return html `<ef-item disabled>${this.t('NO_OPTIONS')}</ef-item>`;
1063
+ }
1064
+ }
1065
+ /**
1066
+ * Returns template for popup
1067
+ * Lazy loads the popup
1068
+ * @returns Popup template or undefined
1069
+ */
1070
+ get popupTemplate() {
1071
+ if (this.lazyRendered) {
1072
+ const hasVisibleItems = this.listHasVisibleItems;
1073
+ return html `<ef-overlay
1074
+ part="list"
1075
+ style="${styleMap(this.popupDynamicStyles)}"
1076
+ @opened="${this.onPopupOpened}"
1077
+ @closed="${this.onPopupClosed}"
1078
+ .focusBoundary="${this}"
1079
+ .opened="${this.opened && (hasVisibleItems || !this.freeText)}"
1080
+ .positionTarget="${this}"
1081
+ .position="${POPUP_POSITION}"
1082
+ with-shadow
1083
+ no-overlap
1084
+ no-focus-management
1085
+ no-autofocus
1086
+ @focusin="${this.shiftFocus}"
1087
+ >${hasVisibleItems ? this.listTemplate : this.noItemsTemplate}</ef-overlay>`;
1088
+ }
1089
+ }
1090
+ /**
1091
+ * Decorate `<input>` element with common properties extended from combobox input
1092
+ * @returns template map
1093
+ */
1094
+ get decorateInputMap() {
1095
+ return {
1096
+ ...super.decorateInputMap,
1097
+ 'part': 'input',
1098
+ 'type': 'text',
1099
+ 'role': 'combobox',
1100
+ '.value': this.focused ? this.inputText : this.freeTextValue || this.label,
1101
+ 'aria-expanded': this.opened ? 'true' : 'false',
1102
+ 'aria-haspopup': 'listbox',
1103
+ 'aria-autocomplete': 'list',
1104
+ 'aria-owns': 'internal-list',
1105
+ 'aria-activedescendant': this.highlightedItemValue
1106
+ };
1107
+ }
1108
+ /**
1109
+ * Returns a template for input field
1110
+ * @returns Input template
1111
+ */
1112
+ get inputTemplate() {
1113
+ return html `<div part="input-wrapper">
1114
+ ${this.renderInput()}
1115
+ ${this.selectionBadgeTemplate}
1116
+ ${this.clearButtonTemplate}
1117
+ <div id="toggle-button" part="button button-toggle">
1118
+ <ef-icon part="icon icon-toggle" icon="down"></ef-icon>
1119
+ </div>
1120
+ </div>`;
1121
+ }
1122
+ /**
1123
+ * A `TemplateResult` that will be used
1124
+ * to render the updated internal template.
1125
+ * @returns Render template
1126
+ */
1127
+ render() {
1128
+ return html `
1129
+ ${this.inputTemplate}
1130
+ ${this.popupTemplate}
1131
+ `;
1132
+ }
1133
+ };
1134
+ __decorate([
1135
+ property({ type: Function, attribute: false })
1136
+ ], ComboBox.prototype, "filter", void 0);
1137
+ __decorate([
1138
+ property({ type: Function, attribute: false })
1139
+ ], ComboBox.prototype, "renderer", void 0);
1140
+ __decorate([
1141
+ property({ type: Boolean })
1142
+ ], ComboBox.prototype, "multiple", null);
1143
+ __decorate([
1144
+ property({ type: Boolean, reflect: true })
1145
+ ], ComboBox.prototype, "opened", void 0);
1146
+ __decorate([
1147
+ property({ type: String })
1148
+ ], ComboBox.prototype, "placeholder", void 0);
1149
+ __decorate([
1150
+ property({ type: Boolean })
1151
+ ], ComboBox.prototype, "clears", void 0);
1152
+ __decorate([
1153
+ property({ type: Boolean, attribute: 'free-text' })
1154
+ ], ComboBox.prototype, "freeText", null);
1155
+ __decorate([
1156
+ property({ type: Boolean, reflect: true })
1157
+ ], ComboBox.prototype, "error", void 0);
1158
+ __decorate([
1159
+ property({ type: Boolean, reflect: true })
1160
+ ], ComboBox.prototype, "warning", void 0);
1161
+ __decorate([
1162
+ property({ type: Number, attribute: 'query-debounce-rate' })
1163
+ ], ComboBox.prototype, "queryDebounceRate", null);
1164
+ __decorate([
1165
+ property({ attribute: false })
1166
+ ], ComboBox.prototype, "data", null);
1167
+ __decorate([
1168
+ property({ type: String })
1169
+ ], ComboBox.prototype, "value", null);
1170
+ __decorate([
1171
+ property({ type: Array, attribute: false })
1172
+ ], ComboBox.prototype, "values", null);
1173
+ __decorate([
1174
+ property({ type: String, attribute: false })
1175
+ ], ComboBox.prototype, "query", null);
1176
+ __decorate([
1177
+ query('#internal-list')
1178
+ ], ComboBox.prototype, "listEl", void 0);
1179
+ __decorate([
1180
+ query('#toggle-button')
1181
+ ], ComboBox.prototype, "toggleButtonEl", void 0);
1182
+ __decorate([
1183
+ query('#clears-button')
1184
+ ], ComboBox.prototype, "clearsButtonEl", void 0);
1185
+ __decorate([
1186
+ property({ type: String, reflect: true })
1187
+ ], ComboBox.prototype, "loading", void 0);
1188
+ __decorate([
1189
+ translate({ scope: 'ef-combo-box' })
1190
+ ], ComboBox.prototype, "t", void 0);
1191
+ __decorate([
1192
+ eventOptions({ capture: true })
1193
+ ], ComboBox.prototype, "shiftFocus", null);
1194
+ ComboBox = __decorate([
1195
+ customElement('ef-combo-box', {
1196
+ alias: 'coral-combo-box'
1197
+ })
1198
+ ], ComboBox);
1199
+ export { ComboBox };