@refinitiv-ui/elements 5.3.3 → 5.3.4

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 (558) hide show
  1. package/lib/accordion/custom-elements.json +49 -0
  2. package/lib/accordion/index.d.ts +76 -0
  3. package/lib/accordion/index.js +139 -0
  4. package/lib/accordion/themes/halo/dark/index.js +3 -0
  5. package/lib/accordion/themes/halo/light/index.js +3 -0
  6. package/lib/accordion/themes/solar/charcoal/index.js +3 -0
  7. package/lib/accordion/themes/solar/pearl/index.js +3 -0
  8. package/lib/appstate-bar/custom-elements.json +49 -0
  9. package/lib/appstate-bar/index.d.ts +65 -0
  10. package/lib/appstate-bar/index.js +103 -0
  11. package/lib/appstate-bar/themes/halo/dark/index.js +3 -0
  12. package/lib/appstate-bar/themes/halo/light/index.js +3 -0
  13. package/lib/appstate-bar/themes/solar/charcoal/index.js +3 -0
  14. package/lib/appstate-bar/themes/solar/pearl/index.js +3 -0
  15. package/lib/autosuggest/custom-elements.json +223 -0
  16. package/lib/autosuggest/helpers/const.d.ts +2 -0
  17. package/lib/autosuggest/helpers/const.js +3 -0
  18. package/lib/autosuggest/helpers/types.d.ts +54 -0
  19. package/lib/autosuggest/helpers/types.js +1 -0
  20. package/lib/autosuggest/helpers/utils.d.ts +39 -0
  21. package/lib/autosuggest/helpers/utils.js +76 -0
  22. package/lib/autosuggest/index.d.ts +533 -0
  23. package/lib/autosuggest/index.js +1248 -0
  24. package/lib/autosuggest/themes/halo/dark/index.js +5 -0
  25. package/lib/autosuggest/themes/halo/light/index.js +5 -0
  26. package/lib/autosuggest/themes/solar/charcoal/index.js +5 -0
  27. package/lib/autosuggest/themes/solar/pearl/index.js +5 -0
  28. package/lib/button/custom-elements.json +119 -0
  29. package/lib/button/index.d.ts +132 -0
  30. package/lib/button/index.js +213 -0
  31. package/lib/button/themes/halo/dark/index.js +3 -0
  32. package/lib/button/themes/halo/light/index.js +3 -0
  33. package/lib/button/themes/solar/charcoal/index.js +3 -0
  34. package/lib/button/themes/solar/pearl/index.js +3 -0
  35. package/lib/button-bar/custom-elements.json +26 -0
  36. package/lib/button-bar/index.d.ts +76 -0
  37. package/lib/button-bar/index.js +157 -0
  38. package/lib/button-bar/themes/halo/dark/index.js +3 -0
  39. package/lib/button-bar/themes/halo/light/index.js +3 -0
  40. package/lib/button-bar/themes/solar/charcoal/index.js +3 -0
  41. package/lib/button-bar/themes/solar/pearl/index.js +3 -0
  42. package/lib/calendar/custom-elements.json +199 -0
  43. package/lib/calendar/index.d.ts +321 -0
  44. package/lib/calendar/index.js +926 -0
  45. package/lib/calendar/locales.d.ts +31 -0
  46. package/lib/calendar/locales.js +144 -0
  47. package/lib/calendar/themes/halo/dark/index.js +3 -0
  48. package/lib/calendar/themes/halo/light/index.js +3 -0
  49. package/lib/calendar/themes/solar/charcoal/index.js +3 -0
  50. package/lib/calendar/themes/solar/pearl/index.js +3 -0
  51. package/lib/calendar/types.d.ts +33 -0
  52. package/lib/calendar/types.js +6 -0
  53. package/lib/calendar/utils.d.ts +12 -0
  54. package/lib/calendar/utils.js +17 -0
  55. package/lib/canvas/custom-elements.json +69 -0
  56. package/lib/canvas/index.d.ts +100 -0
  57. package/lib/canvas/index.js +175 -0
  58. package/lib/canvas/themes/halo/dark/index.js +2 -0
  59. package/lib/canvas/themes/halo/light/index.js +2 -0
  60. package/lib/canvas/themes/solar/charcoal/index.js +2 -0
  61. package/lib/canvas/themes/solar/pearl/index.js +2 -0
  62. package/lib/card/custom-elements.json +59 -0
  63. package/lib/card/helpers/types.d.ts +12 -0
  64. package/lib/card/helpers/types.js +1 -0
  65. package/lib/card/index.d.ts +140 -0
  66. package/lib/card/index.js +247 -0
  67. package/lib/card/themes/halo/dark/index.js +5 -0
  68. package/lib/card/themes/halo/light/index.js +5 -0
  69. package/lib/card/themes/solar/charcoal/index.js +5 -0
  70. package/lib/card/themes/solar/pearl/index.js +5 -0
  71. package/lib/chart/custom-elements.json +42 -0
  72. package/lib/chart/helpers/index.d.ts +2 -0
  73. package/lib/chart/helpers/index.js +2 -0
  74. package/lib/chart/helpers/legend.d.ts +5 -0
  75. package/lib/chart/helpers/legend.js +78 -0
  76. package/lib/chart/helpers/merge.d.ts +15 -0
  77. package/lib/chart/helpers/merge.js +28 -0
  78. package/lib/chart/helpers/types.d.ts +69 -0
  79. package/lib/chart/helpers/types.js +1 -0
  80. package/lib/chart/index.d.ts +187 -0
  81. package/lib/chart/index.js +493 -0
  82. package/lib/chart/plugins/doughnut-center-label.d.ts +3 -0
  83. package/lib/chart/plugins/doughnut-center-label.js +196 -0
  84. package/lib/chart/themes/halo/dark/index.js +4 -0
  85. package/lib/chart/themes/halo/light/index.js +4 -0
  86. package/lib/chart/themes/solar/charcoal/index.js +4 -0
  87. package/lib/chart/themes/solar/pearl/index.js +4 -0
  88. package/lib/checkbox/custom-elements.json +71 -0
  89. package/lib/checkbox/index.d.ts +89 -0
  90. package/lib/checkbox/index.js +170 -0
  91. package/lib/checkbox/themes/halo/dark/index.js +4 -0
  92. package/lib/checkbox/themes/halo/light/index.js +4 -0
  93. package/lib/checkbox/themes/solar/charcoal/index.js +4 -0
  94. package/lib/checkbox/themes/solar/pearl/index.js +4 -0
  95. package/lib/clock/custom-elements.json +108 -0
  96. package/lib/clock/index.d.ts +309 -0
  97. package/lib/clock/index.js +564 -0
  98. package/lib/clock/themes/halo/dark/index.js +2 -0
  99. package/lib/clock/themes/halo/light/index.js +2 -0
  100. package/lib/clock/themes/solar/charcoal/index.js +2 -0
  101. package/lib/clock/themes/solar/pearl/index.js +2 -0
  102. package/lib/clock/utils/TickManager.d.ts +14 -0
  103. package/lib/clock/utils/TickManager.js +66 -0
  104. package/lib/clock/utils/timestamps.d.ts +6 -0
  105. package/lib/clock/utils/timestamps.js +6 -0
  106. package/lib/collapse/custom-elements.json +79 -0
  107. package/lib/collapse/index.d.ts +119 -0
  108. package/lib/collapse/index.js +199 -0
  109. package/lib/collapse/themes/halo/dark/index.js +5 -0
  110. package/lib/collapse/themes/halo/light/index.js +5 -0
  111. package/lib/collapse/themes/solar/charcoal/index.js +5 -0
  112. package/lib/collapse/themes/solar/pearl/index.js +5 -0
  113. package/lib/color-dialog/custom-elements.json +193 -0
  114. package/lib/color-dialog/elements/color-palettes.d.ts +52 -0
  115. package/lib/color-dialog/elements/color-palettes.js +105 -0
  116. package/lib/color-dialog/elements/grayscale-palettes.d.ts +67 -0
  117. package/lib/color-dialog/elements/grayscale-palettes.js +164 -0
  118. package/lib/color-dialog/elements/palettes.d.ts +58 -0
  119. package/lib/color-dialog/elements/palettes.js +119 -0
  120. package/lib/color-dialog/helpers/color-helpers.d.ts +62 -0
  121. package/lib/color-dialog/helpers/color-helpers.js +258 -0
  122. package/lib/color-dialog/helpers/value-model.d.ts +75 -0
  123. package/lib/color-dialog/helpers/value-model.js +139 -0
  124. package/lib/color-dialog/index.d.ts +232 -0
  125. package/lib/color-dialog/index.js +457 -0
  126. package/lib/color-dialog/themes/halo/dark/index.js +7 -0
  127. package/lib/color-dialog/themes/halo/light/index.js +7 -0
  128. package/lib/color-dialog/themes/solar/charcoal/index.js +7 -0
  129. package/lib/color-dialog/themes/solar/pearl/index.js +7 -0
  130. package/lib/combo-box/custom-elements.json +207 -0
  131. package/lib/combo-box/helpers/filter.d.ts +10 -0
  132. package/lib/combo-box/helpers/filter.js +29 -0
  133. package/lib/combo-box/helpers/keyboard-event.d.ts +17 -0
  134. package/lib/combo-box/helpers/keyboard-event.js +19 -0
  135. package/lib/combo-box/helpers/types.d.ts +11 -0
  136. package/lib/combo-box/helpers/types.js +1 -0
  137. package/lib/combo-box/index.d.ts +523 -0
  138. package/lib/combo-box/index.js +1146 -0
  139. package/lib/combo-box/themes/halo/dark/index.js +8 -0
  140. package/lib/combo-box/themes/halo/light/index.js +8 -0
  141. package/lib/combo-box/themes/solar/charcoal/index.js +8 -0
  142. package/lib/combo-box/themes/solar/pearl/index.js +8 -0
  143. package/lib/counter/custom-elements.json +35 -0
  144. package/lib/counter/index.d.ts +89 -0
  145. package/lib/counter/index.js +155 -0
  146. package/lib/counter/themes/halo/dark/index.js +3 -0
  147. package/lib/counter/themes/halo/light/index.js +3 -0
  148. package/lib/counter/themes/solar/charcoal/index.js +3 -0
  149. package/lib/counter/themes/solar/pearl/index.js +3 -0
  150. package/lib/counter/utils.d.ts +13 -0
  151. package/lib/counter/utils.js +52 -0
  152. package/lib/datetime-picker/custom-elements.json +333 -0
  153. package/lib/datetime-picker/index.d.ts +498 -0
  154. package/lib/datetime-picker/index.js +1164 -0
  155. package/lib/datetime-picker/locales.d.ts +8 -0
  156. package/lib/datetime-picker/locales.js +46 -0
  157. package/lib/datetime-picker/themes/halo/dark/index.js +7 -0
  158. package/lib/datetime-picker/themes/halo/light/index.js +7 -0
  159. package/lib/datetime-picker/themes/solar/charcoal/index.js +7 -0
  160. package/lib/datetime-picker/themes/solar/pearl/index.js +7 -0
  161. package/lib/datetime-picker/types.d.ts +3 -0
  162. package/lib/datetime-picker/types.js +1 -0
  163. package/lib/datetime-picker/utils.d.ts +55 -0
  164. package/lib/datetime-picker/utils.js +92 -0
  165. package/lib/dialog/custom-elements.json +136 -0
  166. package/lib/dialog/draggable-element.d.ts +14 -0
  167. package/lib/dialog/draggable-element.js +221 -0
  168. package/lib/dialog/index.d.ts +199 -0
  169. package/lib/dialog/index.js +331 -0
  170. package/lib/dialog/themes/halo/dark/index.js +7 -0
  171. package/lib/dialog/themes/halo/light/index.js +7 -0
  172. package/lib/dialog/themes/solar/charcoal/index.js +7 -0
  173. package/lib/dialog/themes/solar/pearl/index.js +7 -0
  174. package/lib/email-field/custom-elements.json +199 -0
  175. package/lib/email-field/index.d.ts +152 -0
  176. package/lib/email-field/index.js +287 -0
  177. package/lib/email-field/themes/halo/dark/index.js +3 -0
  178. package/lib/email-field/themes/halo/light/index.js +3 -0
  179. package/lib/email-field/themes/solar/charcoal/index.js +3 -0
  180. package/lib/email-field/themes/solar/pearl/index.js +3 -0
  181. package/lib/events.d.ts +121 -0
  182. package/lib/events.js +2 -0
  183. package/lib/flag/custom-elements.json +35 -0
  184. package/lib/flag/index.d.ts +94 -0
  185. package/lib/flag/index.js +168 -0
  186. package/lib/flag/themes/halo/dark/index.js +2 -0
  187. package/lib/flag/themes/halo/light/index.js +2 -0
  188. package/lib/flag/themes/solar/charcoal/index.js +2 -0
  189. package/lib/flag/themes/solar/pearl/index.js +2 -0
  190. package/lib/flag/utils/FlagLoader.d.ts +47 -0
  191. package/lib/flag/utils/FlagLoader.js +86 -0
  192. package/lib/header/custom-elements.json +36 -0
  193. package/lib/header/index.d.ts +46 -0
  194. package/lib/header/index.js +76 -0
  195. package/lib/header/themes/halo/dark/index.js +2 -0
  196. package/lib/header/themes/halo/light/index.js +2 -0
  197. package/lib/header/themes/solar/charcoal/index.js +2 -0
  198. package/lib/header/themes/solar/pearl/index.js +2 -0
  199. package/lib/heatmap/custom-elements.json +151 -0
  200. package/lib/heatmap/helpers/color.d.ts +30 -0
  201. package/lib/heatmap/helpers/color.js +68 -0
  202. package/lib/heatmap/helpers/text.d.ts +26 -0
  203. package/lib/heatmap/helpers/text.js +91 -0
  204. package/lib/heatmap/helpers/track.d.ts +102 -0
  205. package/lib/heatmap/helpers/track.js +160 -0
  206. package/lib/heatmap/helpers/types.d.ts +40 -0
  207. package/lib/heatmap/helpers/types.js +1 -0
  208. package/lib/heatmap/index.d.ts +453 -0
  209. package/lib/heatmap/index.js +1104 -0
  210. package/lib/heatmap/themes/halo/dark/index.js +4 -0
  211. package/lib/heatmap/themes/halo/light/index.js +4 -0
  212. package/lib/heatmap/themes/solar/charcoal/index.js +4 -0
  213. package/lib/heatmap/themes/solar/pearl/index.js +4 -0
  214. package/lib/icon/custom-elements.json +34 -0
  215. package/lib/icon/index.d.ts +87 -0
  216. package/lib/icon/index.js +161 -0
  217. package/lib/icon/themes/halo/dark/index.js +2 -0
  218. package/lib/icon/themes/halo/light/index.js +2 -0
  219. package/lib/icon/themes/solar/charcoal/index.js +2 -0
  220. package/lib/icon/themes/solar/pearl/index.js +2 -0
  221. package/lib/icon/utils/IconLoader.d.ts +47 -0
  222. package/lib/icon/utils/IconLoader.js +86 -0
  223. package/lib/index.d.ts +2 -0
  224. package/lib/index.js +2 -0
  225. package/lib/interactive-chart/custom-elements.json +86 -0
  226. package/lib/interactive-chart/helpers/merge.d.ts +15 -0
  227. package/lib/interactive-chart/helpers/merge.js +28 -0
  228. package/lib/interactive-chart/helpers/types.d.ts +45 -0
  229. package/lib/interactive-chart/helpers/types.js +6 -0
  230. package/lib/interactive-chart/index.d.ts +380 -0
  231. package/lib/interactive-chart/index.js +1093 -0
  232. package/lib/interactive-chart/themes/halo/dark/index.js +3 -0
  233. package/lib/interactive-chart/themes/halo/light/index.js +3 -0
  234. package/lib/interactive-chart/themes/solar/charcoal/index.js +3 -0
  235. package/lib/interactive-chart/themes/solar/pearl/index.js +3 -0
  236. package/lib/item/custom-elements.json +153 -0
  237. package/lib/item/helpers/types.d.ts +57 -0
  238. package/lib/item/helpers/types.js +1 -0
  239. package/lib/item/index.d.ts +149 -0
  240. package/lib/item/index.js +252 -0
  241. package/lib/item/themes/halo/dark/index.js +4 -0
  242. package/lib/item/themes/halo/light/index.js +4 -0
  243. package/lib/item/themes/solar/charcoal/index.js +4 -0
  244. package/lib/item/themes/solar/pearl/index.js +4 -0
  245. package/lib/jsx.d.ts +223 -0
  246. package/lib/label/custom-elements.json +52 -0
  247. package/lib/label/index.d.ts +102 -0
  248. package/lib/label/index.js +252 -0
  249. package/lib/label/themes/halo/dark/index.js +3 -0
  250. package/lib/label/themes/halo/light/index.js +3 -0
  251. package/lib/label/themes/solar/charcoal/index.js +3 -0
  252. package/lib/label/themes/solar/pearl/index.js +3 -0
  253. package/lib/layout/custom-elements.json +163 -0
  254. package/lib/layout/index.d.ts +107 -0
  255. package/lib/layout/index.js +215 -0
  256. package/lib/layout/themes/halo/dark/index.js +2 -0
  257. package/lib/layout/themes/halo/light/index.js +2 -0
  258. package/lib/layout/themes/solar/charcoal/index.js +2 -0
  259. package/lib/layout/themes/solar/pearl/index.js +2 -0
  260. package/lib/led-gauge/custom-elements.json +113 -0
  261. package/lib/led-gauge/index.d.ts +143 -0
  262. package/lib/led-gauge/index.js +440 -0
  263. package/lib/led-gauge/themes/halo/dark/index.js +3 -0
  264. package/lib/led-gauge/themes/halo/light/index.js +3 -0
  265. package/lib/led-gauge/themes/solar/charcoal/index.js +3 -0
  266. package/lib/led-gauge/themes/solar/pearl/index.js +3 -0
  267. package/lib/list/custom-elements.json +111 -0
  268. package/lib/list/extensible-function.d.ts +8 -0
  269. package/lib/list/extensible-function.js +13 -0
  270. package/lib/list/helpers/list-renderer.d.ts +9 -0
  271. package/lib/list/helpers/list-renderer.js +35 -0
  272. package/lib/list/helpers/types.d.ts +3 -0
  273. package/lib/list/helpers/types.js +1 -0
  274. package/lib/list/index.d.ts +292 -0
  275. package/lib/list/index.js +604 -0
  276. package/lib/list/renderer.d.ts +36 -0
  277. package/lib/list/renderer.js +9 -0
  278. package/lib/list/themes/halo/dark/index.js +3 -0
  279. package/lib/list/themes/halo/light/index.js +3 -0
  280. package/lib/list/themes/solar/charcoal/index.js +3 -0
  281. package/lib/list/themes/solar/pearl/index.js +3 -0
  282. package/lib/loader/custom-elements.json +9 -0
  283. package/lib/loader/index.d.ts +41 -0
  284. package/lib/loader/index.js +65 -0
  285. package/lib/loader/themes/halo/dark/index.js +2 -0
  286. package/lib/loader/themes/halo/light/index.js +2 -0
  287. package/lib/loader/themes/solar/charcoal/index.js +2 -0
  288. package/lib/loader/themes/solar/pearl/index.js +2 -0
  289. package/lib/multi-input/custom-elements.json +238 -0
  290. package/lib/multi-input/helpers/types.d.ts +11 -0
  291. package/lib/multi-input/helpers/types.js +1 -0
  292. package/lib/multi-input/index.d.ts +297 -0
  293. package/lib/multi-input/index.js +591 -0
  294. package/lib/multi-input/themes/halo/dark/index.js +4 -0
  295. package/lib/multi-input/themes/halo/light/index.js +4 -0
  296. package/lib/multi-input/themes/solar/charcoal/index.js +4 -0
  297. package/lib/multi-input/themes/solar/pearl/index.js +4 -0
  298. package/lib/notification/custom-elements.json +95 -0
  299. package/lib/notification/elements/notification-tray.d.ts +97 -0
  300. package/lib/notification/elements/notification-tray.js +170 -0
  301. package/lib/notification/elements/notification.d.ts +90 -0
  302. package/lib/notification/elements/notification.js +157 -0
  303. package/lib/notification/helpers/status.d.ts +30 -0
  304. package/lib/notification/helpers/status.js +130 -0
  305. package/lib/notification/helpers/types.d.ts +10 -0
  306. package/lib/notification/helpers/types.js +1 -0
  307. package/lib/notification/index.d.ts +2 -0
  308. package/lib/notification/index.js +2 -0
  309. package/lib/notification/themes/halo/dark/index.js +5 -0
  310. package/lib/notification/themes/halo/light/index.js +5 -0
  311. package/lib/notification/themes/solar/charcoal/index.js +5 -0
  312. package/lib/notification/themes/solar/pearl/index.js +5 -0
  313. package/lib/number-field/custom-elements.json +200 -0
  314. package/lib/number-field/index.d.ts +294 -0
  315. package/lib/number-field/index.js +708 -0
  316. package/lib/number-field/themes/halo/dark/index.js +3 -0
  317. package/lib/number-field/themes/halo/light/index.js +3 -0
  318. package/lib/number-field/themes/solar/charcoal/index.js +3 -0
  319. package/lib/number-field/themes/solar/pearl/index.js +3 -0
  320. package/lib/overlay/custom-elements.json +342 -0
  321. package/lib/overlay/elements/overlay-backdrop.d.ts +46 -0
  322. package/lib/overlay/elements/overlay-backdrop.js +67 -0
  323. package/lib/overlay/elements/overlay-viewport.d.ts +40 -0
  324. package/lib/overlay/elements/overlay-viewport.js +56 -0
  325. package/lib/overlay/elements/overlay.d.ts +403 -0
  326. package/lib/overlay/elements/overlay.js +1427 -0
  327. package/lib/overlay/helpers/functions.d.ts +13 -0
  328. package/lib/overlay/helpers/functions.js +16 -0
  329. package/lib/overlay/helpers/types.d.ts +97 -0
  330. package/lib/overlay/helpers/types.js +16 -0
  331. package/lib/overlay/index.d.ts +2 -0
  332. package/lib/overlay/index.js +1 -0
  333. package/lib/overlay/managers/backdrop-manager.d.ts +45 -0
  334. package/lib/overlay/managers/backdrop-manager.js +96 -0
  335. package/lib/overlay/managers/close-manager.d.ts +54 -0
  336. package/lib/overlay/managers/close-manager.js +138 -0
  337. package/lib/overlay/managers/focus-manager.d.ts +71 -0
  338. package/lib/overlay/managers/focus-manager.js +228 -0
  339. package/lib/overlay/managers/interaction-lock-manager.d.ts +138 -0
  340. package/lib/overlay/managers/interaction-lock-manager.js +375 -0
  341. package/lib/overlay/managers/viewport-manager.d.ts +93 -0
  342. package/lib/overlay/managers/viewport-manager.js +207 -0
  343. package/lib/overlay/managers/zindex-manager.d.ts +80 -0
  344. package/lib/overlay/managers/zindex-manager.js +195 -0
  345. package/lib/overlay/themes/halo/dark/index.js +4 -0
  346. package/lib/overlay/themes/halo/light/index.js +4 -0
  347. package/lib/overlay/themes/solar/charcoal/index.js +4 -0
  348. package/lib/overlay/themes/solar/pearl/index.js +4 -0
  349. package/lib/overlay-menu/custom-elements.json +196 -0
  350. package/lib/overlay-menu/helpers/types.d.ts +8 -0
  351. package/lib/overlay-menu/helpers/types.js +1 -0
  352. package/lib/overlay-menu/helpers/uuid.d.ts +7 -0
  353. package/lib/overlay-menu/helpers/uuid.js +13 -0
  354. package/lib/overlay-menu/index.d.ts +380 -0
  355. package/lib/overlay-menu/index.js +921 -0
  356. package/lib/overlay-menu/managers/menu-manager.d.ts +98 -0
  357. package/lib/overlay-menu/managers/menu-manager.js +240 -0
  358. package/lib/overlay-menu/themes/halo/dark/index.js +5 -0
  359. package/lib/overlay-menu/themes/halo/light/index.js +5 -0
  360. package/lib/overlay-menu/themes/solar/charcoal/index.js +5 -0
  361. package/lib/overlay-menu/themes/solar/pearl/index.js +5 -0
  362. package/lib/pagination/custom-elements.json +93 -0
  363. package/lib/pagination/helpers/types.d.ts +9 -0
  364. package/lib/pagination/helpers/types.js +1 -0
  365. package/lib/pagination/index.d.ts +207 -0
  366. package/lib/pagination/index.js +400 -0
  367. package/lib/pagination/themes/halo/dark/index.js +6 -0
  368. package/lib/pagination/themes/halo/light/index.js +6 -0
  369. package/lib/pagination/themes/solar/charcoal/index.js +6 -0
  370. package/lib/pagination/themes/solar/pearl/index.js +6 -0
  371. package/lib/panel/custom-elements.json +39 -0
  372. package/lib/panel/index.d.ts +48 -0
  373. package/lib/panel/index.js +77 -0
  374. package/lib/panel/themes/halo/dark/index.js +2 -0
  375. package/lib/panel/themes/halo/light/index.js +2 -0
  376. package/lib/panel/themes/solar/charcoal/index.js +2 -0
  377. package/lib/panel/themes/solar/pearl/index.js +2 -0
  378. package/lib/password-field/custom-elements.json +156 -0
  379. package/lib/password-field/index.d.ts +140 -0
  380. package/lib/password-field/index.js +258 -0
  381. package/lib/password-field/themes/halo/dark/index.js +3 -0
  382. package/lib/password-field/themes/halo/light/index.js +3 -0
  383. package/lib/password-field/themes/solar/charcoal/index.js +3 -0
  384. package/lib/password-field/themes/solar/pearl/index.js +3 -0
  385. package/lib/pill/custom-elements.json +95 -0
  386. package/lib/pill/index.d.ts +97 -0
  387. package/lib/pill/index.js +162 -0
  388. package/lib/pill/themes/halo/dark/index.js +3 -0
  389. package/lib/pill/themes/halo/light/index.js +3 -0
  390. package/lib/pill/themes/solar/charcoal/index.js +3 -0
  391. package/lib/pill/themes/solar/pearl/index.js +3 -0
  392. package/lib/progress-bar/custom-elements.json +58 -0
  393. package/lib/progress-bar/index.d.ts +82 -0
  394. package/lib/progress-bar/index.js +159 -0
  395. package/lib/progress-bar/themes/halo/dark/index.js +2 -0
  396. package/lib/progress-bar/themes/halo/light/index.js +2 -0
  397. package/lib/progress-bar/themes/solar/charcoal/index.js +2 -0
  398. package/lib/progress-bar/themes/solar/pearl/index.js +2 -0
  399. package/lib/radio-button/custom-elements.json +84 -0
  400. package/lib/radio-button/index.d.ts +106 -0
  401. package/lib/radio-button/index.js +195 -0
  402. package/lib/radio-button/radio-button-registry.d.ts +21 -0
  403. package/lib/radio-button/radio-button-registry.js +40 -0
  404. package/lib/radio-button/themes/halo/dark/index.js +3 -0
  405. package/lib/radio-button/themes/halo/light/index.js +3 -0
  406. package/lib/radio-button/themes/solar/charcoal/index.js +3 -0
  407. package/lib/radio-button/themes/solar/pearl/index.js +3 -0
  408. package/lib/rating/custom-elements.json +58 -0
  409. package/lib/rating/index.d.ts +91 -0
  410. package/lib/rating/index.js +158 -0
  411. package/lib/rating/themes/halo/dark/index.js +2 -0
  412. package/lib/rating/themes/halo/light/index.js +2 -0
  413. package/lib/rating/themes/solar/charcoal/index.js +2 -0
  414. package/lib/rating/themes/solar/pearl/index.js +2 -0
  415. package/lib/search-field/custom-elements.json +173 -0
  416. package/lib/search-field/index.d.ts +134 -0
  417. package/lib/search-field/index.js +254 -0
  418. package/lib/search-field/themes/halo/dark/index.js +3 -0
  419. package/lib/search-field/themes/halo/light/index.js +3 -0
  420. package/lib/search-field/themes/solar/charcoal/index.js +3 -0
  421. package/lib/search-field/themes/solar/pearl/index.js +3 -0
  422. package/lib/select/custom-elements.json +103 -0
  423. package/lib/select/helpers/types.d.ts +3 -0
  424. package/lib/select/helpers/types.js +1 -0
  425. package/lib/select/index.d.ts +388 -0
  426. package/lib/select/index.js +942 -0
  427. package/lib/select/themes/halo/dark/index.js +5 -0
  428. package/lib/select/themes/halo/light/index.js +5 -0
  429. package/lib/select/themes/solar/charcoal/index.js +5 -0
  430. package/lib/select/themes/solar/pearl/index.js +5 -0
  431. package/lib/sidebar-layout/custom-elements.json +72 -0
  432. package/lib/sidebar-layout/index.d.ts +69 -0
  433. package/lib/sidebar-layout/index.js +135 -0
  434. package/lib/sidebar-layout/themes/halo/dark/index.js +3 -0
  435. package/lib/sidebar-layout/themes/halo/light/index.js +3 -0
  436. package/lib/sidebar-layout/themes/solar/charcoal/index.js +3 -0
  437. package/lib/sidebar-layout/themes/solar/pearl/index.js +3 -0
  438. package/lib/slider/custom-elements.json +181 -0
  439. package/lib/slider/index.d.ts +409 -0
  440. package/lib/slider/index.js +1188 -0
  441. package/lib/slider/themes/halo/dark/index.js +3 -0
  442. package/lib/slider/themes/halo/light/index.js +3 -0
  443. package/lib/slider/themes/solar/charcoal/index.js +3 -0
  444. package/lib/slider/themes/solar/pearl/index.js +3 -0
  445. package/lib/sparkline/custom-elements.json +59 -0
  446. package/lib/sparkline/index.d.ts +107 -0
  447. package/lib/sparkline/index.js +188 -0
  448. package/lib/sparkline/themes/halo/dark/index.js +2 -0
  449. package/lib/sparkline/themes/halo/light/index.js +2 -0
  450. package/lib/sparkline/themes/solar/charcoal/index.js +2 -0
  451. package/lib/sparkline/themes/solar/pearl/index.js +2 -0
  452. package/lib/swing-gauge/const.d.ts +22 -0
  453. package/lib/swing-gauge/const.js +26 -0
  454. package/lib/swing-gauge/custom-elements.json +109 -0
  455. package/lib/swing-gauge/helpers.d.ts +8 -0
  456. package/lib/swing-gauge/helpers.js +105 -0
  457. package/lib/swing-gauge/index.d.ts +294 -0
  458. package/lib/swing-gauge/index.js +762 -0
  459. package/lib/swing-gauge/themes/halo/dark/index.js +3 -0
  460. package/lib/swing-gauge/themes/halo/light/index.js +3 -0
  461. package/lib/swing-gauge/themes/solar/charcoal/index.js +3 -0
  462. package/lib/swing-gauge/themes/solar/pearl/index.js +3 -0
  463. package/lib/swing-gauge/types.d.ts +34 -0
  464. package/lib/swing-gauge/types.js +1 -0
  465. package/lib/tab/custom-elements.json +123 -0
  466. package/lib/tab/index.d.ts +118 -0
  467. package/lib/tab/index.js +211 -0
  468. package/lib/tab/themes/halo/dark/index.js +4 -0
  469. package/lib/tab/themes/halo/light/index.js +4 -0
  470. package/lib/tab/themes/solar/charcoal/index.js +4 -0
  471. package/lib/tab/themes/solar/pearl/index.js +4 -0
  472. package/lib/tab-bar/custom-elements.json +52 -0
  473. package/lib/tab-bar/helpers/animate.d.ts +16 -0
  474. package/lib/tab-bar/helpers/animate.js +53 -0
  475. package/lib/tab-bar/index.d.ts +108 -0
  476. package/lib/tab-bar/index.js +220 -0
  477. package/lib/tab-bar/themes/halo/dark/index.js +4 -0
  478. package/lib/tab-bar/themes/halo/light/index.js +4 -0
  479. package/lib/tab-bar/themes/solar/charcoal/index.js +4 -0
  480. package/lib/tab-bar/themes/solar/pearl/index.js +4 -0
  481. package/lib/text-field/custom-elements.json +210 -0
  482. package/lib/text-field/index.d.ts +171 -0
  483. package/lib/text-field/index.js +319 -0
  484. package/lib/text-field/themes/halo/dark/index.js +3 -0
  485. package/lib/text-field/themes/halo/light/index.js +3 -0
  486. package/lib/text-field/themes/solar/charcoal/index.js +3 -0
  487. package/lib/text-field/themes/solar/pearl/index.js +3 -0
  488. package/lib/time-picker/custom-elements.json +124 -0
  489. package/lib/time-picker/index.d.ts +379 -0
  490. package/lib/time-picker/index.js +777 -0
  491. package/lib/time-picker/themes/halo/dark/index.js +4 -0
  492. package/lib/time-picker/themes/halo/light/index.js +4 -0
  493. package/lib/time-picker/themes/solar/charcoal/index.js +4 -0
  494. package/lib/time-picker/themes/solar/pearl/index.js +4 -0
  495. package/lib/toggle/custom-elements.json +84 -0
  496. package/lib/toggle/index.d.ts +77 -0
  497. package/lib/toggle/index.js +134 -0
  498. package/lib/toggle/themes/halo/dark/index.js +2 -0
  499. package/lib/toggle/themes/halo/light/index.js +2 -0
  500. package/lib/toggle/themes/solar/charcoal/index.js +2 -0
  501. package/lib/toggle/themes/solar/pearl/index.js +2 -0
  502. package/lib/tooltip/custom-elements.json +62 -0
  503. package/lib/tooltip/elements/title-tooltip.d.ts +1 -0
  504. package/lib/tooltip/elements/title-tooltip.js +18 -0
  505. package/lib/tooltip/elements/tooltip-element.d.ts +21 -0
  506. package/lib/tooltip/elements/tooltip-element.js +54 -0
  507. package/lib/tooltip/helpers/overflow-tooltip.d.ts +9 -0
  508. package/lib/tooltip/helpers/overflow-tooltip.js +19 -0
  509. package/lib/tooltip/helpers/renderer.d.ts +8 -0
  510. package/lib/tooltip/helpers/renderer.js +11 -0
  511. package/lib/tooltip/helpers/types.d.ts +23 -0
  512. package/lib/tooltip/helpers/types.js +1 -0
  513. package/lib/tooltip/index.d.ts +232 -0
  514. package/lib/tooltip/index.js +479 -0
  515. package/lib/tooltip/managers/tooltip-manager.d.ts +15 -0
  516. package/lib/tooltip/managers/tooltip-manager.js +144 -0
  517. package/lib/tooltip/themes/halo/dark/index.js +3 -0
  518. package/lib/tooltip/themes/halo/light/index.js +3 -0
  519. package/lib/tooltip/themes/solar/charcoal/index.js +3 -0
  520. package/lib/tooltip/themes/solar/pearl/index.js +3 -0
  521. package/lib/tornado-chart/custom-elements.json +45 -0
  522. package/lib/tornado-chart/elements/tornado-chart.d.ts +78 -0
  523. package/lib/tornado-chart/elements/tornado-chart.js +125 -0
  524. package/lib/tornado-chart/elements/tornado-item.d.ts +110 -0
  525. package/lib/tornado-chart/elements/tornado-item.js +209 -0
  526. package/lib/tornado-chart/index.d.ts +2 -0
  527. package/lib/tornado-chart/index.js +2 -0
  528. package/lib/tornado-chart/themes/halo/dark/index.js +6 -0
  529. package/lib/tornado-chart/themes/halo/light/index.js +6 -0
  530. package/lib/tornado-chart/themes/solar/charcoal/index.js +6 -0
  531. package/lib/tornado-chart/themes/solar/pearl/index.js +6 -0
  532. package/lib/tree/custom-elements.json +100 -0
  533. package/lib/tree/elements/tree-item.d.ts +96 -0
  534. package/lib/tree/elements/tree-item.js +182 -0
  535. package/lib/tree/elements/tree.d.ts +156 -0
  536. package/lib/tree/elements/tree.js +286 -0
  537. package/lib/tree/helpers/renderer.d.ts +5 -0
  538. package/lib/tree/helpers/renderer.js +33 -0
  539. package/lib/tree/helpers/types.d.ts +17 -0
  540. package/lib/tree/helpers/types.js +1 -0
  541. package/lib/tree/index.d.ts +4 -0
  542. package/lib/tree/index.js +3 -0
  543. package/lib/tree/managers/tree-manager.d.ts +236 -0
  544. package/lib/tree/managers/tree-manager.js +379 -0
  545. package/lib/tree/themes/halo/dark/index.js +7 -0
  546. package/lib/tree/themes/halo/light/index.js +7 -0
  547. package/lib/tree/themes/solar/charcoal/index.js +7 -0
  548. package/lib/tree/themes/solar/pearl/index.js +7 -0
  549. package/lib/tree-select/custom-elements.json +107 -0
  550. package/lib/tree-select/helpers/types.d.ts +4 -0
  551. package/lib/tree-select/helpers/types.js +1 -0
  552. package/lib/tree-select/index.d.ts +400 -0
  553. package/lib/tree-select/index.js +881 -0
  554. package/lib/tree-select/themes/halo/dark/index.js +12 -0
  555. package/lib/tree-select/themes/halo/light/index.js +12 -0
  556. package/lib/tree-select/themes/solar/charcoal/index.js +12 -0
  557. package/lib/tree-select/themes/solar/pearl/index.js +12 -0
  558. package/package.json +9 -9
@@ -0,0 +1,1248 @@
1
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
2
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
3
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
4
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
5
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
6
+ };
7
+ var Autosuggest_1;
8
+ import { css, customElement, html, property, query, unsafeHTML } from '@refinitiv-ui/core';
9
+ import { AnimationTaskRunner, TimeoutTaskRunner } from '@refinitiv-ui/utils';
10
+ import { Overlay } from '../overlay';
11
+ import '../loader';
12
+ import { escapeRegExp, itemHighlightable, itemRenderer, queryWordSelect } from './helpers/utils';
13
+ import { isIE, isMobile } from './helpers/const';
14
+ import { VERSION } from '../';
15
+ export { queryWordSelect, itemRenderer, escapeRegExp, itemHighlightable, updateElementContent } from './helpers/utils';
16
+ /**
17
+ * Shows suggestions based on users' query.
18
+ * It can be used by attaching to text form control
19
+ * such as TextField, Multi Input, etc.
20
+ * Autosuggest supports various use cases such as
21
+ * custom rendering, pagination, asynchronous data request, etc.
22
+ *
23
+ * @fires item-highlight Fired when an item gets highlighted or highlight is removed
24
+ * @fires add-attach-target-events Fired when attach has been set
25
+ * @fires remove-attach-target-events Fired when attach has been removed
26
+ * @fires item-select Fired when an item gets selected
27
+ * @fires suggestions-fetch-requested Fired when auto suggest requests the data
28
+ * @fires suggestions-clear-requested Fired when auto suggest requests to clear the data. If used in reactive application, prevent default and set suggestions to []
29
+ * @fires suggestions-query Fired when input value has changed and the query must be set
30
+ * @fires suggestions-changed Fired when suggestions changed
31
+ *
32
+ * @attr {boolean} opened - Set to open auto suggest popup
33
+ * @prop {boolean} [opened=false] - Auto suggest popup's open state
34
+ */
35
+ let Autosuggest = Autosuggest_1 = class Autosuggest extends Overlay {
36
+ /**
37
+ * creates auto-suggest
38
+ */
39
+ constructor() {
40
+ super();
41
+ /**
42
+ * An HTML Element or CSS selector
43
+ * @type {AutosuggestTargetElement | string | null}
44
+ */
45
+ this.attach = null;
46
+ /**
47
+ * Request suggestions when attach target is focused
48
+ */
49
+ this.requestOnFocus = false;
50
+ /**
51
+ * If set to true display 'Has more results' item
52
+ */
53
+ this.moreResults = false;
54
+ /**
55
+ * Custom text for More Search
56
+ */
57
+ this.moreSearchText = Autosuggest_1.defaultMoreSearchText;
58
+ /**
59
+ * If set to true show loading mask
60
+ */
61
+ this.loading = false;
62
+ /**
63
+ * An object that represents a query from attach target
64
+ * @type {AutosuggestQuery | null}
65
+ */
66
+ this.query = null;
67
+ /**
68
+ * Debounce rate in ms of the filter as a number.
69
+ * Used to throttle the filter rate so as not to trigger unneeded filtering
70
+ * @default 100
71
+ */
72
+ this.debounceRate = Autosuggest_1.defaultDebounceRate;
73
+ /**
74
+ * A renderer applied to suggestion.
75
+ * By default a render maps data to item attributes
76
+ * @type {AutosuggestRenderer}
77
+ */
78
+ this.renderer = itemRenderer;
79
+ /**
80
+ * A function that is applied to every suggestion during the render process
81
+ * to say whether the item can be highlighted and selected. Only items that return true are considered.
82
+ * By default the function checks for `item` `highlightable` property.
83
+ * @type {AutosuggestHighlightable}
84
+ */
85
+ this.highlightable = itemHighlightable;
86
+ /**
87
+ * A list of suggestion items
88
+ * @type {AutosuggestItem[]}
89
+ */
90
+ this.suggestions = [];
91
+ /**
92
+ * If set to true, the render function is not called. Instead the wrapper element
93
+ * should populate and destroy suggestion elements. Rendering items manually
94
+ * may have performance benefits in frameworks that use virtual DOM (such as `Vue`, `React`, `hyperHTML` and others)
95
+ */
96
+ this.htmlRenderer = false;
97
+ // used to map render elements with data
98
+ this.suggestionMap = new Map();
99
+ this.highlightedItem = null;
100
+ this.attachTarget = null;
101
+ this.lastActiveElement = null;
102
+ this.suspendedKey = false;
103
+ this.preservedQueryValue = null;
104
+ this.focusSuspended = false;
105
+ this.jobRunner = new TimeoutTaskRunner(this.debounceRate);
106
+ this.attachChangeRunner = new AnimationTaskRunner();
107
+ this.moreResultsRunner = new AnimationTaskRunner();
108
+ this.loadingRunner = new AnimationTaskRunner();
109
+ /**
110
+ * Run when document click event happens.
111
+ * @param event object
112
+ * @returns {void}
113
+ */
114
+ this.onOutsideClick = (event) => {
115
+ const path = event.composedPath();
116
+ // outside click
117
+ if (!path.includes(this) && this.attachTarget && !path.includes(this.attachTarget)) {
118
+ this.setOpened(false);
119
+ }
120
+ };
121
+ /**
122
+ * fire event and reinit listeners if attach was changed
123
+ * @returns {void}
124
+ */
125
+ this.attachChangeFrameCallback = () => {
126
+ this.dispatchAttachEventsRemoveAction();
127
+ const attachTarget = (typeof this.attach === 'string' ? document.querySelector(this.attach) : this.attach);
128
+ if (attachTarget && attachTarget.nodeType === document.ELEMENT_NODE) {
129
+ this.attachTarget = attachTarget;
130
+ if (!this.positionTarget) {
131
+ this.positionTarget = attachTarget; // in most cases attachTarget and positionTarget must be the same
132
+ }
133
+ /**
134
+ * @event add-attach-target-events
135
+ * Fired when attach has been set.
136
+ * Add attach target listeners.
137
+ */
138
+ this.dispatchEventDefault(new CustomEvent('add-attach-target-events', {
139
+ cancelable: true
140
+ }), this.attachEventsAddAction);
141
+ }
142
+ };
143
+ /**
144
+ * set opened state due to status of focus and content
145
+ * @returns {void}
146
+ */
147
+ this.moreResultsFrameCallback = () => {
148
+ this.setOpened(this.attachTargetFocused && this.hasContent);
149
+ };
150
+ /**
151
+ * initialize opened state depends on focus and content
152
+ * @returns {void}
153
+ */
154
+ this.loadingFrameCallback = () => {
155
+ if (this.loading && !this.opened && this.attachTargetFocused) {
156
+ this.setOpened(true);
157
+ }
158
+ else if (!this.loading && this.opened && !this.hasContent) {
159
+ this.setOpened(false);
160
+ }
161
+ };
162
+ this.removeChildNode = (el) => {
163
+ el.parentNode && el.parentNode.removeChild(el);
164
+ };
165
+ this.generateSuggestionsFragment = (fragment, suggestion) => {
166
+ const el = this.renderer(suggestion, this.preservedQueryValue);
167
+ fragment.appendChild(el);
168
+ return fragment;
169
+ };
170
+ /**
171
+ * Fired when mouse down event happens. Select the item
172
+ * @param event Mouse down event
173
+ * @returns {void}
174
+ */
175
+ this.onItemMousedown = (event) => {
176
+ // do not loose focus from input when click happens on the popup
177
+ // note, in IE when scrolling the focus is lost regardless, so
178
+ // do hacking here and with on blur
179
+ /* istanbul ignore next */
180
+ requestAnimationFrame(() => {
181
+ // Ignore any focus query events!
182
+ this.focusSuspended = true;
183
+ this.attachTarget && this.attachTarget.focus();
184
+ this.focusSuspended = false;
185
+ });
186
+ event.stopPropagation();
187
+ event.preventDefault();
188
+ };
189
+ /**
190
+ * @ignore
191
+ */
192
+ this.position = ['bottom-start', 'top-start', 'right-middle'];
193
+ /**
194
+ * @ignore
195
+ */
196
+ this.noCancelOnEscKey = true;
197
+ /**
198
+ * @ignore
199
+ */
200
+ this.noCancelOnOutsideClick = true;
201
+ /**
202
+ * @ignore
203
+ */
204
+ this.noAutofocus = true;
205
+ /**
206
+ * @ignore
207
+ */
208
+ this.noOverlap = true;
209
+ /**
210
+ * @ignore
211
+ */
212
+ this.withShadow = false;
213
+ /**
214
+ * @ignore
215
+ */
216
+ this.onInputValueChange = this.onInputValueChange.bind(this);
217
+ /**
218
+ * @ignore
219
+ */
220
+ this.onInputKeyDown = this.onInputKeyDown.bind(this);
221
+ /**
222
+ * @ignore
223
+ */
224
+ this.onInputBlur = this.onInputBlur.bind(this);
225
+ /**
226
+ * @ignore
227
+ */
228
+ this.onInputFocus = this.onInputFocus.bind(this);
229
+ /**
230
+ * @ignore
231
+ */
232
+ this.suggestionsQueryAction = this.suggestionsQueryAction.bind(this);
233
+ /**
234
+ * @ignore
235
+ */
236
+ this.itemSelectAction = this.itemSelectAction.bind(this);
237
+ /**
238
+ * @ignore
239
+ */
240
+ this.itemHighlightAction = this.itemHighlightAction.bind(this);
241
+ /**
242
+ * @ignore
243
+ */
244
+ this.highlightText = this.highlightText.bind(this);
245
+ /**
246
+ * @ignore
247
+ */
248
+ this.suggestionsFetchRequestedAction = this.suggestionsFetchRequestedAction.bind(this);
249
+ /**
250
+ * @ignore
251
+ */
252
+ this.suggestionsClearRequestedAction = this.suggestionsClearRequestedAction.bind(this);
253
+ /**
254
+ * @ignore
255
+ */
256
+ this.attachEventsAddAction = this.attachEventsAddAction.bind(this);
257
+ /**
258
+ * @ignore
259
+ */
260
+ this.attachEventsRemoveAction = this.attachEventsRemoveAction.bind(this);
261
+ }
262
+ /**
263
+ * Element version number
264
+ * @returns version number
265
+ */
266
+ static get version() {
267
+ return VERSION;
268
+ }
269
+ /**
270
+ * A `CSSResult` that will be used
271
+ * to style the host, slotted children
272
+ * and the internal template of the element.
273
+ * @return CSS template
274
+ */
275
+ static get styles() {
276
+ return [Overlay.styles, css `
277
+ :host {
278
+ overflow: hidden;
279
+ display: flex;
280
+ flex-direction: column;
281
+ }
282
+ [part=content] {
283
+ flex: 1 1 auto;
284
+ overflow-x: hidden;
285
+ overflow-y: auto;
286
+ -webkit-overflow-scrolling: touch;
287
+ }
288
+ [part=header], [part=footer] {
289
+ flex: none;
290
+ }
291
+ `];
292
+ }
293
+ /**
294
+ * A basic regexp matching pattern to replace text based on string input.
295
+ * @param text Value to test against
296
+ * @param query The query
297
+ * @param [pattern=<mark>$1</mark>] Provide a pattern to replace string
298
+ * @returns innerHTML The text that can be used as innerHTML
299
+ */
300
+ static QueryWordSelect(text, query = '', pattern = '<mark>$1</mark>') {
301
+ return queryWordSelect(text, query, pattern);
302
+ }
303
+ /**
304
+ * Build item element from data object
305
+ * @param suggestion Suggestion data
306
+ * @param query A query data (usually string, but could be any entity )
307
+ * @returns item
308
+ */
309
+ static ItemRenderer(suggestion, query) {
310
+ return itemRenderer(suggestion, query);
311
+ }
312
+ /**
313
+ * Replace forbidden characters in regular expressions
314
+ * @param string A string to process
315
+ * @returns clean string
316
+ */
317
+ static EscapeRegExp(string = '') {
318
+ return escapeRegExp(string);
319
+ }
320
+ /**
321
+ * Check whether item can be highlighted
322
+ * @param suggestion Suggestion object
323
+ * @param target item element
324
+ * @returns highlightable
325
+ */
326
+ static ItemHighlightable(suggestion, target) {
327
+ return itemHighlightable(suggestion, target);
328
+ }
329
+ disconnectedCallback() {
330
+ this.dispatchAttachEventsRemoveAction();
331
+ super.disconnectedCallback();
332
+ }
333
+ /**
334
+ * Run when attach target value changes.
335
+ * @param event by default `value-changed` event is listened
336
+ * @returns {void}
337
+ */
338
+ onInputValueChange(event) {
339
+ if (!this.suspended) { // avoid circular
340
+ /* istanbul ignore next */
341
+ if (isMobile) {
342
+ this.lastActiveElement = event.target;
343
+ }
344
+ this.requestSuggestions('value-changed', true);
345
+ }
346
+ }
347
+ /**
348
+ * Run when input has lost focus
349
+ * @param event by default `blur` event is listened
350
+ * @returns {void}
351
+ */
352
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
353
+ onInputBlur(event) {
354
+ requestAnimationFrame(() => {
355
+ if (!this.attachTargetFocused) {
356
+ this.setOpened(false);
357
+ }
358
+ });
359
+ }
360
+ /**
361
+ * Run when input received focus
362
+ * @param event by default `focus` event is listened
363
+ * @returns {void}
364
+ */
365
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
366
+ onInputFocus(event) {
367
+ /* istanbul ignore next */
368
+ if (this.focusSuspended) {
369
+ // see _onItemMousedown, it is an IE fix for scrollbar
370
+ return;
371
+ }
372
+ this.requestOnFocus && this.requestSuggestions('input-focus');
373
+ }
374
+ /**
375
+ * Run when input key down event has happened
376
+ * @param event by default `keydown` event is listened
377
+ * @returns {void}
378
+ */
379
+ onInputKeyDown(event) {
380
+ if (event.key === 'Up' || event.key === 'ArrowUp') {
381
+ this.onUpKey();
382
+ }
383
+ else if (event.key === 'Down' || event.key === 'ArrowDown') {
384
+ this.onDownKey();
385
+ }
386
+ else if (event.key === 'Esc' || event.key === 'Escape') {
387
+ this.onEscKey();
388
+ }
389
+ else if (event.key === 'Enter' || event.key === 'Return') {
390
+ this.onEnterKey(event);
391
+ }
392
+ else {
393
+ return;
394
+ }
395
+ event.preventDefault();
396
+ }
397
+ /**
398
+ * @ignore
399
+ * Called when the element's dimensions have changed
400
+ * @param size dimension details
401
+ * @returns {void}
402
+ */
403
+ resizedCallback(size) {
404
+ super.resizedCallback(size);
405
+ this.calculateContentMaxHeight(size);
406
+ }
407
+ /**
408
+ * @returns template of loader if currently query loading
409
+ */
410
+ get loaderTemplate() {
411
+ if (!this.loading) {
412
+ return null;
413
+ }
414
+ return html `
415
+ <div part="loader">
416
+ <div part="backdrop"></div>
417
+ <ef-loader size="medium"></ef-loader>
418
+ </div>
419
+ `;
420
+ }
421
+ /**
422
+ * @returns template of moreResults
423
+ */
424
+ get moreResultsTemplate() {
425
+ if (!this.moreResults) {
426
+ return null;
427
+ }
428
+ return html `
429
+ <ef-item id="moreResults" part="more-results">${this.highlightText(this.moreResults, this.moreSearchText, this.query)}</ef-item>
430
+ `;
431
+ }
432
+ /**
433
+ * A `TemplateResult` that will be used
434
+ * to render the updated internal template.
435
+ * @return Render template
436
+ */
437
+ render() {
438
+ return html `
439
+ <div part="header">
440
+ <slot id="headerSlot" name="header"></slot>
441
+ </div>
442
+ <div id="content" part="content" @mousemove="${this.onItemMouseMove}" @mouseleave="${this.onItemMouseLeave}" @tap="${this.onItemMouseClick}">
443
+ <slot id="contentSlot" @slotchange="${this.onSlotChange}"></slot>
444
+ ${this.moreResultsTemplate}
445
+ </div>
446
+ <div part="footer">
447
+ <slot id="footerSlot" name="footer"></slot>
448
+ </div>
449
+ ${this.loaderTemplate}
450
+ `;
451
+ }
452
+ /**
453
+ * Called once after the component is first rendered
454
+ * @param changedProperties map of changed properties with old values
455
+ * @returns {void}
456
+ */
457
+ firstUpdated(changedProperties) {
458
+ super.firstUpdated(changedProperties);
459
+ this.addEventListener('tapstart', this.onItemMousedown);
460
+ }
461
+ /**
462
+ * Called when the element’s DOM has been updated and rendered
463
+ * @param changedProperties Properties that has changed
464
+ * @returns shouldUpdate
465
+ */
466
+ shouldUpdate(changedProperties) {
467
+ let result = super.shouldUpdate(changedProperties);
468
+ result = result || this.shouldAutosuggestUpdate(changedProperties);
469
+ return result;
470
+ }
471
+ /**
472
+ * Called after the element’s DOM has been updated
473
+ * @param changedProperties Properties that has changed
474
+ * @returns {void}
475
+ */
476
+ updated(changedProperties) {
477
+ super.updated(changedProperties);
478
+ if (changedProperties.has('suggestions')) {
479
+ this.notifySuggestions();
480
+ }
481
+ this.changedCallbacks(changedProperties);
482
+ }
483
+ /**
484
+ * inheritance callbacks
485
+ */
486
+ /**
487
+ * Run when the slot has changed.
488
+ * @param event Slot change query
489
+ * @returns {void}
490
+ */
491
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
492
+ onSlotChange(event) {
493
+ const nodes = (this.contentSlot && this.contentSlot.assignedNodes()) || [];
494
+ this.setOpened(this.attachTargetFocused && this.hasContent);
495
+ // make a brave assumption that suggestions are populated as well
496
+ const suggestions = this.suggestions;
497
+ this.highlightItem(); // hide highlight
498
+ this.suggestionMap.clear();
499
+ nodes.forEach((node, idx) => {
500
+ /* istanbul ignore next */
501
+ if (node.nodeType !== Node.ELEMENT_NODE) {
502
+ return;
503
+ }
504
+ const suggestion = suggestions[idx];
505
+ if (this.highlightable(suggestion, node)) {
506
+ this.suggestionMap.set(node, suggestion);
507
+ }
508
+ });
509
+ }
510
+ /**
511
+ * 'suggestions-query' default action
512
+ * @param event Suggestion query
513
+ * @returns {void}
514
+ */
515
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
516
+ suggestionsQueryAction(event) {
517
+ this.query = this.attachTarget && this.attachTarget.value;
518
+ }
519
+ /**
520
+ * 'item-select' default action
521
+ * @param event Select action
522
+ * @returns {void}
523
+ */
524
+ itemSelectAction(event) {
525
+ const { detail: { query, suggestion } } = event;
526
+ /* istanbul ignore next */
527
+ if (this.attachTarget) {
528
+ this.attachTarget.value = suggestion && (suggestion === null || suggestion === void 0 ? void 0 : suggestion.label) || query;
529
+ }
530
+ }
531
+ /**
532
+ * 'item-highlight' default action
533
+ * @param event Highlight action
534
+ * @returns {void}
535
+ */
536
+ itemHighlightAction(event) {
537
+ const target = event.detail.target;
538
+ const oldTarget = event.detail.oldTarget;
539
+ if (target) {
540
+ target.highlighted = true;
541
+ }
542
+ if (oldTarget) {
543
+ oldTarget.highlighted = false;
544
+ }
545
+ }
546
+ /**
547
+ * 'suggestions-fetch-requested' default action
548
+ * @param event Fetch request
549
+ * @returns {void}
550
+ */
551
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
552
+ suggestionsFetchRequestedAction(event) {
553
+ // do nothing
554
+ }
555
+ /**
556
+ * 'suggestions-clear-requested' default action
557
+ * @param event Clear request
558
+ * @returns {void}
559
+ */
560
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
561
+ suggestionsClearRequestedAction(event) {
562
+ this.suggestions = [];
563
+ }
564
+ /**
565
+ * Add listeners to the attached target
566
+ * By default `input`, 'keydown', 'focus' and 'blur' events are listened
567
+ * @param event Attach add action
568
+ * @returns {void}
569
+ */
570
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
571
+ attachEventsAddAction(event) {
572
+ const attachTarget = this.attachTarget;
573
+ /* istanbul ignore next */
574
+ if (!attachTarget) {
575
+ return;
576
+ }
577
+ attachTarget.addEventListener('input', this.onInputValueChange);
578
+ attachTarget.addEventListener('keydown', this.onInputKeyDown);
579
+ attachTarget.addEventListener('blur', this.onInputBlur);
580
+ attachTarget.addEventListener('focus', this.onInputFocus);
581
+ }
582
+ /**
583
+ * Remove event listeners from the attached target
584
+ * By default `input`, 'keydown', 'focus' and 'blur' events are listened
585
+ * @param event Attach remove action
586
+ * @returns {void}
587
+ */
588
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
589
+ attachEventsRemoveAction(event) {
590
+ const attachTarget = this.attachTarget;
591
+ if (!attachTarget) {
592
+ return;
593
+ }
594
+ attachTarget.removeEventListener('input', this.onInputValueChange);
595
+ attachTarget.removeEventListener('keydown', this.onInputKeyDown);
596
+ attachTarget.removeEventListener('blur', this.onInputBlur);
597
+ attachTarget.removeEventListener('focus', this.onInputFocus);
598
+ }
599
+ /**
600
+ * Call this method to fetch more results
601
+ * @returns {void}
602
+ */
603
+ fetchMoreSuggestions() {
604
+ this.dispatchSuggestionsFetchRequested('more-results');
605
+ }
606
+ /**
607
+ * Highlight the item and remove old highlighted item
608
+ * @param target Element to highlight. Pass null to just remove previous highlight
609
+ * @param silent Do not fire a select event on highlight. Select should be fired on keyboard navigation
610
+ * @returns {void}
611
+ */
612
+ highlightItem(target = null, silent = true) {
613
+ if (this.highlightedItem !== target) {
614
+ const oldTarget = this.highlightedItem;
615
+ this.highlightedItem = target && this.canSelect(target) ? target : null;
616
+ /**
617
+ * @event item-highlight
618
+ * Fired when an item gets highlighted or highlight is removed
619
+ * @param {HTMLElement} [target] New highlight target or null
620
+ * @param {*} [suggestion] New suggestion or null
621
+ * @param {HTMLElement} [oldTarget] Old highlight target or null
622
+ * @param {*} [oldSuggestion] Old suggestion or null
623
+ */
624
+ this.dispatchEventDefault(new CustomEvent('item-highlight', {
625
+ cancelable: true,
626
+ detail: {
627
+ target: this.highlightedItem,
628
+ suggestion: this.getSuggestionFor(this.highlightedItem),
629
+ oldTarget,
630
+ oldSuggestion: this.getSuggestionFor(oldTarget)
631
+ }
632
+ }), this.itemHighlightAction);
633
+ if (!silent && target) {
634
+ this.selectItem(target, 'navigation');
635
+ }
636
+ }
637
+ }
638
+ /**
639
+ * Calculate more search text inner html
640
+ * @param moreResults True if has more results
641
+ * @param moreSearchText More search text template
642
+ * @param query A query
643
+ * @returns innerHTML
644
+ */
645
+ highlightText(moreResults, moreSearchText, query) {
646
+ if (!moreResults) {
647
+ return null;
648
+ }
649
+ return html `
650
+ <span part="more-results-text">
651
+ ${unsafeHTML(moreSearchText.replace(/{0\}/g, `<mark>${query ? query.toString() : ''}</mark>`))}
652
+ </span>
653
+ <span part="more-results-keys" slot="right"><kbd>SHIFT</kbd> + <kbd>ENTER</kbd></span>
654
+ `;
655
+ }
656
+ /**
657
+ * Call this method to request suggestions
658
+ * @private
659
+ * @param reason The reason to request query
660
+ * @param debounce True to debounce
661
+ * @returns {void}
662
+ */
663
+ requestSuggestions(reason, debounce = false) {
664
+ this.dispatchSuggestionsQuery(reason);
665
+ if (this.preservedQueryValue === this.query) { // if the query is the same do not re-issue the request, instead try to open auto suggest
666
+ if (!this.opened && ((this.suggestions && this.suggestions.length) || this.moreResults)) {
667
+ this.setOpened(true);
668
+ }
669
+ return;
670
+ }
671
+ this.preservedQueryValue = this.query;
672
+ const dispatch = () => {
673
+ if (this.attachTargetFocused) {
674
+ this.dispatchSuggestionsFetchRequested(reason);
675
+ }
676
+ };
677
+ if (debounce) {
678
+ // debounce
679
+ this.jobRunner.schedule(dispatch);
680
+ return;
681
+ }
682
+ this.jobRunner.cancel();
683
+ dispatch();
684
+ }
685
+ /**
686
+ * All internal opened set events can be stoppable externally
687
+ * Use this instead of setting opened directly
688
+ * Protected method that can be used by managers or subclasses
689
+ * @returns {void}
690
+ */
691
+ onOpened() {
692
+ super.onOpened();
693
+ document.addEventListener('tapstart', this.onOutsideClick);
694
+ }
695
+ /**
696
+ * Run when the popup has closed, managers are de-registered
697
+ * and closing transition has finished
698
+ * @returns {void}
699
+ */
700
+ onClosed() {
701
+ super.onClosed();
702
+ this.restrictContentMaxHeight();
703
+ document.removeEventListener('tapstart', this.onOutsideClick);
704
+ }
705
+ /**
706
+ * enter key processing
707
+ * @param event Enter
708
+ * @returns {void}
709
+ */
710
+ onEnterKey(event) {
711
+ if (!this.opened) {
712
+ this.requestSuggestions('enter-pressed');
713
+ return;
714
+ }
715
+ /* istanbul ignore next */
716
+ if (this.loading) {
717
+ return;
718
+ }
719
+ // more results
720
+ if (this.moreResults && event.shiftKey) {
721
+ this.fetchMoreSuggestions();
722
+ return;
723
+ }
724
+ if (!this.highlightedItem) {
725
+ this.setOpened(false);
726
+ return;
727
+ }
728
+ this.highlightedItem && this.selectItem(this.highlightedItem, 'enter');
729
+ }
730
+ /**
731
+ * Up key processing
732
+ * @returns {void}
733
+ */
734
+ onUpKey() {
735
+ if (!this.opened) {
736
+ this.requestSuggestions('suggestions-revealed');
737
+ return;
738
+ }
739
+ /* istanbul ignore next */
740
+ if (this.loading) {
741
+ return;
742
+ }
743
+ this.focusElement(-1);
744
+ }
745
+ /**
746
+ * Down key processing
747
+ * @returns {void}
748
+ */
749
+ onDownKey() {
750
+ if (!this.opened) {
751
+ this.requestSuggestions('suggestions-revealed');
752
+ return;
753
+ }
754
+ /* istanbul ignore next */
755
+ if (this.loading) {
756
+ return;
757
+ }
758
+ this.focusElement(1);
759
+ }
760
+ /**
761
+ * Esc key processing
762
+ * @returns {void}
763
+ */
764
+ onEscKey() {
765
+ if (this.opened) {
766
+ // if preserved value exists, set it back
767
+ this.dispatchItemSelect('reset');
768
+ this.setOpened(false);
769
+ return;
770
+ }
771
+ if (this.query) {
772
+ this.suspend();
773
+ this.dispatchItemSelect('clear');
774
+ this.resume();
775
+ this.requestSuggestions('escape-pressed');
776
+ }
777
+ }
778
+ /**
779
+ * Highlight it on mouse move
780
+ * @param event for item
781
+ * @returns {void}
782
+ */
783
+ onItemMouseMove(event) {
784
+ this.highlightItem(this.getTarget(event));
785
+ }
786
+ /**
787
+ * @param target Item to check
788
+ * @returns true if an item can be highlighted and selectable
789
+ */
790
+ canSelect(target) {
791
+ return this.suggestionMap.has(target) || (this.moreResults && target === this.moreResultsItem);
792
+ }
793
+ /**
794
+ * Get suggestion for target
795
+ * @param target Target to check
796
+ * @returns suggestion
797
+ */
798
+ getSuggestionFor(target) {
799
+ return target && this.suggestionMap.get(target);
800
+ }
801
+ /**
802
+ * Select the item from the list
803
+ * @param target Element to select
804
+ * @param method 'click', 'enter' or 'navigation'
805
+ * @returns {void}
806
+ */
807
+ selectItem(target, method) {
808
+ if (this.canSelect(target)) {
809
+ // more results
810
+ if (target === this.moreResultsItem) {
811
+ this.dispatchItemSelect('reset');
812
+ switch (method) {
813
+ case 'click':
814
+ case 'enter':
815
+ this.fetchMoreSuggestions();
816
+ break;
817
+ default:
818
+ // node default
819
+ }
820
+ return;
821
+ }
822
+ this.dispatchItemSelect(method, target);
823
+ switch (method) {
824
+ case 'click':
825
+ case 'enter':
826
+ this.dispatchSuggestionsClearRequested();
827
+ break;
828
+ default:
829
+ // node default
830
+ }
831
+ }
832
+ }
833
+ /**
834
+ * Get the list of rendered suggestions
835
+ * @returns renderedSuggestions
836
+ */
837
+ get renderedSuggestions() {
838
+ const keys = [];
839
+ this.suggestionMap.forEach((value, key) => {
840
+ keys.push(key);
841
+ });
842
+ if (this.moreResults && this.moreResultsItem) {
843
+ keys.push(this.moreResultsItem);
844
+ }
845
+ return keys;
846
+ }
847
+ /**
848
+ * Fired when mouse leave event happens. Remove highlight from the item
849
+ * @returns {void}
850
+ */
851
+ /* istanbul ignore next */
852
+ onItemMouseLeave() {
853
+ this.highlightItem(); // remove highlight
854
+ }
855
+ /**
856
+ * Fired when mouse click event happens. Select an item
857
+ * @param event Mouse click event
858
+ * @returns {void}
859
+ */
860
+ onItemMouseClick(event) {
861
+ this.selectItem(this.getTarget(event), 'click');
862
+ }
863
+ /**
864
+ * check some of native properties was modified
865
+ * @param changedProperties properties that was changed
866
+ * @returns true if some of changedProperties modified
867
+ */
868
+ shouldAutosuggestUpdate(changedProperties) {
869
+ return changedProperties.has('attach') || changedProperties.has('suggestions') || changedProperties.has('moreResults') || changedProperties.has('loading') || changedProperties.has('debounceRate');
870
+ }
871
+ changedCallbacks(changedProperties) {
872
+ if (changedProperties.has('attach')) {
873
+ this.attachChangeRunner.schedule(this.attachChangeFrameCallback);
874
+ }
875
+ if (changedProperties.has('moreResults')) {
876
+ this.moreResultsRunner.schedule(this.moreResultsFrameCallback);
877
+ }
878
+ if (changedProperties.has('loading')) {
879
+ this.loadingRunner.schedule(this.loadingFrameCallback);
880
+ }
881
+ if (changedProperties.has('opened')) {
882
+ this.handleAfterOpened();
883
+ }
884
+ if (changedProperties.has('debounceRate')) {
885
+ this.debounceRateChange();
886
+ }
887
+ }
888
+ /**
889
+ * handle highlight after open
890
+ * @returns {void}
891
+ */
892
+ handleAfterOpened() {
893
+ this.highlightItem(); // hide highlight for case more-result
894
+ }
895
+ /**
896
+ * recreate debouncer if dobounceRate was changed
897
+ * @returns {void}
898
+ */
899
+ debounceRateChange() {
900
+ this.jobRunner.fulfil();
901
+ this.jobRunner = new TimeoutTaskRunner(this.debounceRate);
902
+ }
903
+ /**
904
+ * Dispatch attach events remove action event
905
+ * @returns {void}
906
+ */
907
+ dispatchAttachEventsRemoveAction() {
908
+ if (this.attachTarget) {
909
+ /**
910
+ * @event remove-attach-target-events
911
+ * Fired when attach has been removed.
912
+ * Remove attach target listeners.
913
+ */
914
+ this.dispatchEventDefault(new CustomEvent('remove-attach-target-events', {
915
+ cancelable: true
916
+ }), this.attachEventsRemoveAction);
917
+ this.attachTarget = null;
918
+ }
919
+ }
920
+ /**
921
+ * Run when suggestions get changed
922
+ * NB: this function is only run when htmlRenderer is set to false
923
+ * @returns {void}
924
+ */
925
+ suggestionsChange() {
926
+ this.contentSlot && this.contentSlot.assignedNodes().forEach(this.removeChildNode);
927
+ this.appendChild(this.suggestions.reduce(this.generateSuggestionsFragment, document.createDocumentFragment()));
928
+ }
929
+ /**
930
+ * Dispatch item select event
931
+ * The event may change input, therefore suspend listening
932
+ * @param method Select method
933
+ * @param target Target for suggestion
934
+ * @returns {void}
935
+ */
936
+ dispatchItemSelect(method, target = null) {
937
+ this.suspend();
938
+ /**
939
+ * @event item-select
940
+ * Fired when an item gets selected
941
+ * @param {AutosuggestMethodType} method Select method
942
+ * @param {HTMLElement} target Selection target
943
+ * @param {*} [suggestion] Selected suggestion or null
944
+ * @param {*} [query] Saved query object or null
945
+ */
946
+ this.dispatchEventDefault(new CustomEvent('item-select', {
947
+ cancelable: true,
948
+ detail: {
949
+ method,
950
+ target,
951
+ suggestion: this.getSuggestionFor(target),
952
+ query: method === 'clear' ? null : this.preservedQueryValue
953
+ }
954
+ }), this.itemSelectAction);
955
+ this.resume();
956
+ }
957
+ /**
958
+ * fire 'suggestions-fetch-requested' event
959
+ * @param reason Dispatch reason
960
+ * @returns {void}
961
+ */
962
+ dispatchSuggestionsFetchRequested(reason) {
963
+ /**
964
+ * @event suggestions-fetch-requested
965
+ * Fired when auto suggest requests the data.
966
+ * @param {String} query Input query
967
+ * @param {} reason The reason to fetch data
968
+ */
969
+ this.dispatchEventDefault(new CustomEvent('suggestions-fetch-requested', {
970
+ cancelable: true,
971
+ detail: {
972
+ query: this.query,
973
+ reason
974
+ }
975
+ }), this.suggestionsFetchRequestedAction);
976
+ }
977
+ /**
978
+ * fire 'suggestions-clear-requested' event
979
+ * @returns {void}
980
+ */
981
+ dispatchSuggestionsClearRequested() {
982
+ this.preservedQueryValue = null;
983
+ /**
984
+ * @event suggestions-clear-requested
985
+ * Fired when auto suggest requests to clear the data.
986
+ * If used in reactive application, prevent default and set suggestions to []
987
+ */
988
+ this.dispatchEventDefault(new CustomEvent('suggestions-clear-requested', {
989
+ cancelable: true
990
+ }), this.suggestionsClearRequestedAction);
991
+ }
992
+ /**
993
+ * fire 'suggestions-query' event
994
+ * @param reason Dispatch reason
995
+ * @returns {void}
996
+ */
997
+ dispatchSuggestionsQuery(reason) {
998
+ /**
999
+ * @event suggestions-query
1000
+ * Fired when input value has changed and the query must be set.
1001
+ * @param reason The reason to request query
1002
+ */
1003
+ this.dispatchEventDefault(new CustomEvent('suggestions-query', {
1004
+ cancelable: true,
1005
+ detail: {
1006
+ reason
1007
+ }
1008
+ }), this.suggestionsQueryAction);
1009
+ }
1010
+ /**
1011
+ * Dispatch event and run default action if preventDefault is not run
1012
+ * @param event Custom event to dispatch
1013
+ * @param defaultAction Default action to run
1014
+ * @returns {void}
1015
+ */
1016
+ dispatchEventDefault(event, defaultAction) {
1017
+ this.dispatchEvent(event);
1018
+ if (!event.defaultPrevented) {
1019
+ defaultAction.call(this, event);
1020
+ }
1021
+ }
1022
+ /**
1023
+ * Check if the attach target is in focus
1024
+ * @returns focused true if attach target is focused
1025
+ */
1026
+ get attachTargetFocused() {
1027
+ return this.isFocused(document.activeElement) || this.attachTarget === this.lastActiveElement;
1028
+ }
1029
+ /**
1030
+ * Walk through shadowDOM to find activeElement
1031
+ * @param activeElement currently active document element
1032
+ * @returns true if activeElement is attached target
1033
+ */
1034
+ isFocused(activeElement) {
1035
+ if (this.attachTarget === activeElement) {
1036
+ return true;
1037
+ }
1038
+ if (activeElement && activeElement.shadowRoot) {
1039
+ return this.isFocused(activeElement.shadowRoot.activeElement);
1040
+ }
1041
+ return false;
1042
+ }
1043
+ /**
1044
+ * Check if the autosuggest has content
1045
+ * @returns content exists
1046
+ */
1047
+ get hasContent() {
1048
+ if (this.moreResults) {
1049
+ return true;
1050
+ }
1051
+ // Space characters (e.g. space, tab, EOL) don't count as having content
1052
+ const nodes = this.contentSlot && this.contentSlot.assignedNodes() || [];
1053
+ return nodes.some(({ nodeType, textContent }) => nodeType === Node.ELEMENT_NODE || (textContent && textContent.search(/\S/) >= 0)); // If node is element always return true
1054
+ }
1055
+ /**
1056
+ * Suspend updating suggestions on value-changed
1057
+ * Autosuggest is suspended on select
1058
+ * @returns {void}
1059
+ */
1060
+ suspend() {
1061
+ this.suspendedKey = true;
1062
+ }
1063
+ /**
1064
+ * Resume suspended autosuggest
1065
+ * @returns {void}
1066
+ */
1067
+ resume() {
1068
+ this.suspendedKey = false;
1069
+ }
1070
+ /**
1071
+ * Check if the autosuggest is suspended
1072
+ * @returns {Boolean} suspended
1073
+ */
1074
+ get suspended() {
1075
+ return this.suspendedKey;
1076
+ }
1077
+ /**
1078
+ * Event target is not always what we want. Try to find the best target to process further
1079
+ * @param event Mouse click hover event
1080
+ * @returns target
1081
+ */
1082
+ getTarget(event) {
1083
+ const path = event.composedPath();
1084
+ for (let i = 0; i <= path.length; i += 1) {
1085
+ const node = path[i];
1086
+ /* istanbul ignore next */
1087
+ if (node.nodeType !== Node.ELEMENT_NODE) {
1088
+ continue;
1089
+ }
1090
+ if (this.canSelect(node)) {
1091
+ return node;
1092
+ }
1093
+ /* istanbul ignore next */
1094
+ if (node === this) {
1095
+ return event.target;
1096
+ }
1097
+ }
1098
+ return event.target;
1099
+ }
1100
+ /**
1101
+ * Highlight next or previous highlightable element if present
1102
+ * @param {Number} direction -1 - up/next; 1 - down/previous
1103
+ * @returns {void}
1104
+ */
1105
+ focusElement(direction) {
1106
+ // focus is spread across
1107
+ const highlightedItem = this.highlightedItem;
1108
+ const children = this.renderedSuggestions;
1109
+ const idx = highlightedItem ? children.indexOf(highlightedItem) : -1;
1110
+ let focusElement;
1111
+ if (direction === 1) {
1112
+ focusElement = idx === -1 ? children[0] : children[idx + 1];
1113
+ }
1114
+ else {
1115
+ focusElement = idx === -1 ? children[children.length - 1] : children[idx - 1];
1116
+ }
1117
+ if (!focusElement) {
1118
+ focusElement = direction === 1 ? children[0] : children[children.length - 1];
1119
+ }
1120
+ if (focusElement) {
1121
+ this.highlightItem(focusElement, false);
1122
+ focusElement.scrollIntoView({
1123
+ behavior: 'auto',
1124
+ block: 'nearest'
1125
+ });
1126
+ }
1127
+ }
1128
+ /**
1129
+ * @returns {void}
1130
+ */
1131
+ notifySuggestions() {
1132
+ this.dispatchEvent(new CustomEvent('suggestions-changed', {
1133
+ detail: {
1134
+ value: this.suggestions
1135
+ }
1136
+ }));
1137
+ if (!this.htmlRenderer) {
1138
+ this.suggestionsChange();
1139
+ }
1140
+ }
1141
+ /**
1142
+ * Set the width
1143
+ * @returns {void}
1144
+ */
1145
+ refit() {
1146
+ super.refit();
1147
+ if (this.positionTarget && this.positionTarget instanceof HTMLElement) {
1148
+ const rect = this.positionTarget.getBoundingClientRect();
1149
+ this.style.minWidth = `${rect.width}px`;
1150
+ }
1151
+ this.restrictContentMaxHeight();
1152
+ }
1153
+ /**
1154
+ * IE11 only: Restrict maximum height of content element
1155
+ * @param [maxHeight] Maximum height of content element
1156
+ * @returns {void}
1157
+ */
1158
+ /* istanbul ignore next */
1159
+ restrictContentMaxHeight(maxHeight) {
1160
+ if (!isIE) {
1161
+ return;
1162
+ }
1163
+ if (maxHeight) {
1164
+ this.contentElement && this.contentElement.style.setProperty('max-height', `${maxHeight}px`);
1165
+ }
1166
+ else {
1167
+ this.contentElement && this.contentElement.style.removeProperty('max-height');
1168
+ }
1169
+ }
1170
+ /**
1171
+ * IE11 only: Calculate the maxHeight of content element
1172
+ * @param size Size of the dialog
1173
+ * @returns {void}
1174
+ */
1175
+ /* istanbul ignore next */
1176
+ calculateContentMaxHeight(size) {
1177
+ var _a, _b, _c;
1178
+ if (!isIE) {
1179
+ return;
1180
+ }
1181
+ const headerRect = (_a = this.headerElement) === null || _a === void 0 ? void 0 : _a.getBoundingClientRect();
1182
+ const footerRect = (_b = this.footerElement) === null || _b === void 0 ? void 0 : _b.getBoundingClientRect();
1183
+ const contentRect = (_c = this.contentElement) === null || _c === void 0 ? void 0 : _c.getBoundingClientRect();
1184
+ const dialogHeight = size.height;
1185
+ const headerHeight = headerRect ? headerRect.height : 0;
1186
+ const footerHeight = footerRect ? footerRect.height : 0;
1187
+ const contentHeight = contentRect ? contentRect.height : 0;
1188
+ if (headerHeight + footerHeight + contentHeight > dialogHeight) {
1189
+ this.restrictContentMaxHeight(dialogHeight - footerHeight - headerHeight);
1190
+ }
1191
+ }
1192
+ };
1193
+ Autosuggest.defaultDebounceRate = 100;
1194
+ Autosuggest.defaultMoreSearchText = 'More results for {0}';
1195
+ __decorate([
1196
+ property({ type: String })
1197
+ ], Autosuggest.prototype, "attach", void 0);
1198
+ __decorate([
1199
+ property({ type: Boolean, attribute: 'request-on-focus' })
1200
+ ], Autosuggest.prototype, "requestOnFocus", void 0);
1201
+ __decorate([
1202
+ property({ type: Boolean, reflect: true, attribute: 'more-results' })
1203
+ ], Autosuggest.prototype, "moreResults", void 0);
1204
+ __decorate([
1205
+ property({ type: String, attribute: 'more-search-text' })
1206
+ ], Autosuggest.prototype, "moreSearchText", void 0);
1207
+ __decorate([
1208
+ property({ type: Boolean, reflect: true })
1209
+ ], Autosuggest.prototype, "loading", void 0);
1210
+ __decorate([
1211
+ property({ type: Object, attribute: false })
1212
+ ], Autosuggest.prototype, "query", void 0);
1213
+ __decorate([
1214
+ property({ type: Number, attribute: 'debounce-rate' })
1215
+ ], Autosuggest.prototype, "debounceRate", void 0);
1216
+ __decorate([
1217
+ property({ type: Function, attribute: false })
1218
+ ], Autosuggest.prototype, "renderer", void 0);
1219
+ __decorate([
1220
+ property({ type: Function, attribute: false })
1221
+ ], Autosuggest.prototype, "highlightable", void 0);
1222
+ __decorate([
1223
+ property({ type: Array, attribute: false })
1224
+ ], Autosuggest.prototype, "suggestions", void 0);
1225
+ __decorate([
1226
+ property({ type: Boolean, attribute: 'html-renderer' })
1227
+ ], Autosuggest.prototype, "htmlRenderer", void 0);
1228
+ __decorate([
1229
+ query('#moreResults')
1230
+ ], Autosuggest.prototype, "moreResultsItem", void 0);
1231
+ __decorate([
1232
+ query('#contentSlot')
1233
+ ], Autosuggest.prototype, "contentSlot", void 0);
1234
+ __decorate([
1235
+ query('[part="content"]')
1236
+ ], Autosuggest.prototype, "contentElement", void 0);
1237
+ __decorate([
1238
+ query('[part="header"]')
1239
+ ], Autosuggest.prototype, "headerElement", void 0);
1240
+ __decorate([
1241
+ query('[part="footer"]')
1242
+ ], Autosuggest.prototype, "footerElement", void 0);
1243
+ Autosuggest = Autosuggest_1 = __decorate([
1244
+ customElement('ef-autosuggest', {
1245
+ alias: 'emerald-autosuggest'
1246
+ })
1247
+ ], Autosuggest);
1248
+ export { Autosuggest };