@aquera/nile-elements 0.1.47-beta-2.1 → 0.1.48

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 (304) hide show
  1. package/README.md +9 -7
  2. package/demo/index.html +32 -72
  3. package/dist/index.cjs.js +1 -1
  4. package/dist/index.esm.js +1 -1
  5. package/dist/internal/form.cjs.js +1 -1
  6. package/dist/internal/form.cjs.js.map +1 -1
  7. package/dist/internal/form.esm.js +1 -1
  8. package/dist/nile-accordion/nile-accordian.test.cjs.js +1 -1
  9. package/dist/nile-auto-complete/index.cjs.js +1 -1
  10. package/dist/nile-auto-complete/index.esm.js +1 -1
  11. package/dist/nile-auto-complete/nile-auto-complete.cjs.js +17 -1
  12. package/dist/nile-auto-complete/nile-auto-complete.cjs.js.map +1 -1
  13. package/dist/nile-auto-complete/nile-auto-complete.esm.js +29 -8
  14. package/dist/nile-auto-complete/nile-auto-complete.test.cjs.js +1 -1
  15. package/dist/nile-auto-complete/nile-auto-complete.test.cjs.js.map +1 -1
  16. package/dist/nile-auto-complete/nile-auto-complete.test.esm.js +1 -1
  17. package/dist/nile-avatar/nile-avatar.test.cjs.js +1 -1
  18. package/dist/nile-badge/nile-badge.test.cjs.js +1 -1
  19. package/dist/nile-button/nile-button.test.cjs.js +1 -1
  20. package/dist/nile-button-toggle-group/nile-button-toggle-group.test.cjs.js +1 -1
  21. package/dist/nile-calendar/nile-calendar.test.cjs.js +1 -1
  22. package/dist/nile-calendar/nile-calendar.test.cjs.js.map +1 -1
  23. package/dist/nile-calendar/nile-calendar.test.esm.js +1 -1
  24. package/dist/nile-card/nile-card.test.cjs.js +1 -1
  25. package/dist/nile-checkbox/nile-checkbox.test.cjs.js +1 -1
  26. package/dist/nile-chip/nile-chip.test.cjs.js +1 -1
  27. package/dist/nile-chip/nile-chip.test.cjs.js.map +1 -1
  28. package/dist/nile-chip/nile-chip.test.esm.js +1 -1
  29. package/dist/nile-dialog/nile-dialog.test.cjs.js +1 -1
  30. package/dist/nile-drawer/nile-drawer.test.cjs.js +1 -1
  31. package/dist/nile-dropdown/nile-dropdown.test.cjs.js +1 -1
  32. package/dist/nile-empty-state/nile-empty-state.test.cjs.js +1 -1
  33. package/dist/nile-error-message/nile-error-message.test.cjs.js +1 -1
  34. package/dist/nile-filter-chip/nile-filter-chip.test.cjs.js +1 -1
  35. package/dist/nile-form-group/nile-form-group.test.cjs.js +1 -1
  36. package/dist/nile-form-help-text/nile-form-help-text.test.cjs.js +1 -1
  37. package/dist/nile-hero/nile-hero.test.cjs.js +1 -1
  38. package/dist/nile-icon/icons/svg/agent.cjs.js +1 -1
  39. package/dist/nile-icon/icons/svg/agent.cjs.js.map +1 -1
  40. package/dist/nile-icon/icons/svg/agent.esm.js +1 -1
  41. package/dist/nile-icon/icons/svg/api.cjs.js +1 -1
  42. package/dist/nile-icon/icons/svg/api.cjs.js.map +1 -1
  43. package/dist/nile-icon/icons/svg/api.esm.js +1 -1
  44. package/dist/nile-icon/icons/svg/apply-filter.cjs.js +1 -1
  45. package/dist/nile-icon/icons/svg/apply-filter.cjs.js.map +1 -1
  46. package/dist/nile-icon/icons/svg/apply-filter.esm.js +1 -1
  47. package/dist/nile-icon/icons/svg/arrowdropdown.cjs.js +1 -1
  48. package/dist/nile-icon/icons/svg/arrowdropdown.cjs.js.map +1 -1
  49. package/dist/nile-icon/icons/svg/arrowdropdown.esm.js +1 -1
  50. package/dist/nile-icon/icons/svg/arrowdropup.cjs.js +1 -1
  51. package/dist/nile-icon/icons/svg/arrowdropup.cjs.js.map +1 -1
  52. package/dist/nile-icon/icons/svg/arrowdropup.esm.js +1 -1
  53. package/dist/nile-icon/icons/svg/database.cjs.js +1 -1
  54. package/dist/nile-icon/icons/svg/database.cjs.js.map +1 -1
  55. package/dist/nile-icon/icons/svg/database.esm.js +1 -1
  56. package/dist/nile-icon/icons/svg/done.cjs.js +1 -1
  57. package/dist/nile-icon/icons/svg/done.cjs.js.map +1 -1
  58. package/dist/nile-icon/icons/svg/done.esm.js +1 -1
  59. package/dist/nile-icon/icons/svg/dontmap.cjs.js +1 -1
  60. package/dist/nile-icon/icons/svg/dontmap.cjs.js.map +1 -1
  61. package/dist/nile-icon/icons/svg/dontmap.esm.js +1 -1
  62. package/dist/nile-icon/icons/svg/doublearrowleft.cjs.js +1 -1
  63. package/dist/nile-icon/icons/svg/doublearrowleft.cjs.js.map +1 -1
  64. package/dist/nile-icon/icons/svg/doublearrowleft.esm.js +1 -1
  65. package/dist/nile-icon/icons/svg/doublearrowright.cjs.js +1 -1
  66. package/dist/nile-icon/icons/svg/doublearrowright.cjs.js.map +1 -1
  67. package/dist/nile-icon/icons/svg/doublearrowright.esm.js +1 -1
  68. package/dist/nile-icon/icons/svg/drag.cjs.js +1 -1
  69. package/dist/nile-icon/icons/svg/drag.cjs.js.map +1 -1
  70. package/dist/nile-icon/icons/svg/drag.esm.js +1 -1
  71. package/dist/nile-icon/icons/svg/expand-06.cjs.js +1 -1
  72. package/dist/nile-icon/icons/svg/expand-06.cjs.js.map +1 -1
  73. package/dist/nile-icon/icons/svg/expand-06.esm.js +1 -1
  74. package/dist/nile-icon/icons/svg/expand.cjs.js +1 -1
  75. package/dist/nile-icon/icons/svg/expand.cjs.js.map +1 -1
  76. package/dist/nile-icon/icons/svg/expand.esm.js +1 -1
  77. package/dist/nile-icon/icons/svg/integer.cjs.js +1 -1
  78. package/dist/nile-icon/icons/svg/integer.cjs.js.map +1 -1
  79. package/dist/nile-icon/icons/svg/integer.esm.js +1 -1
  80. package/dist/nile-icon/icons/svg/pluscircle.cjs.js +1 -1
  81. package/dist/nile-icon/icons/svg/pluscircle.cjs.js.map +1 -1
  82. package/dist/nile-icon/icons/svg/pluscircle.esm.js +1 -1
  83. package/dist/nile-icon/icons/svg/question.cjs.js +1 -1
  84. package/dist/nile-icon/icons/svg/question.cjs.js.map +1 -1
  85. package/dist/nile-icon/icons/svg/question.esm.js +1 -1
  86. package/dist/nile-icon/icons/svg/resource.cjs.js +1 -1
  87. package/dist/nile-icon/icons/svg/resource.cjs.js.map +1 -1
  88. package/dist/nile-icon/icons/svg/resource.esm.js +1 -1
  89. package/dist/nile-icon/icons/svg/sendescalation.cjs.js +1 -1
  90. package/dist/nile-icon/icons/svg/sendescalation.cjs.js.map +1 -1
  91. package/dist/nile-icon/icons/svg/sendescalation.esm.js +1 -1
  92. package/dist/nile-icon/icons/svg/sendreminder.cjs.js +1 -1
  93. package/dist/nile-icon/icons/svg/sendreminder.cjs.js.map +1 -1
  94. package/dist/nile-icon/icons/svg/sendreminder.esm.js +1 -1
  95. package/dist/nile-icon/icons/svg/timezone.cjs.js +1 -1
  96. package/dist/nile-icon/icons/svg/timezone.cjs.js.map +1 -1
  97. package/dist/nile-icon/icons/svg/timezone.esm.js +1 -1
  98. package/dist/nile-icon/icons/svg/unmute.cjs.js +1 -1
  99. package/dist/nile-icon/icons/svg/unmute.cjs.js.map +1 -1
  100. package/dist/nile-icon/icons/svg/unmute.esm.js +1 -1
  101. package/dist/nile-icon/icons/svg/upgrade.cjs.js +1 -1
  102. package/dist/nile-icon/icons/svg/upgrade.cjs.js.map +1 -1
  103. package/dist/nile-icon/icons/svg/upgrade.esm.js +1 -1
  104. package/dist/nile-icon/nile-icon.test.cjs.js +1 -1
  105. package/dist/nile-input/nile-input.test.cjs.js +1 -1
  106. package/dist/nile-link/nile-link.test.cjs.js +1 -1
  107. package/dist/nile-loader/nile-loader.test.cjs.js +1 -1
  108. package/dist/nile-option/nile-option.cjs.js +1 -1
  109. package/dist/nile-option/nile-option.cjs.js.map +1 -1
  110. package/dist/nile-option/nile-option.css.cjs.js +1 -1
  111. package/dist/nile-option/nile-option.css.cjs.js.map +1 -1
  112. package/dist/nile-option/nile-option.css.esm.js +1 -1
  113. package/dist/nile-option/nile-option.esm.js +2 -2
  114. package/dist/nile-popover/nile-popover.test.cjs.js +1 -1
  115. package/dist/nile-popup/nile-popup.test.cjs.js +1 -1
  116. package/dist/nile-progress-bar/nile-progress-bar.test.cjs.js +1 -1
  117. package/dist/nile-radio/nile-radio.test.cjs.js +1 -1
  118. package/dist/nile-radio-group/nile-radio-group.test.cjs.js +1 -1
  119. package/dist/nile-select/index.cjs.js +1 -1
  120. package/dist/nile-select/index.esm.js +1 -1
  121. package/dist/nile-select/nile-select.cjs.js +1 -1
  122. package/dist/nile-select/nile-select.cjs.js.map +1 -1
  123. package/dist/nile-select/nile-select.esm.js +2 -2
  124. package/dist/nile-select/nile-select.test.cjs.js +1 -1
  125. package/dist/nile-select/nile-select.test.cjs.js.map +1 -1
  126. package/dist/nile-select/nile-select.test.esm.js +2 -2
  127. package/dist/nile-slide-toggle/nile-slide-toggle.test.cjs.js +1 -1
  128. package/dist/nile-tab-group/nile-tab-group.test.cjs.js +1 -1
  129. package/dist/nile-textarea/nile-textarea.test.cjs.js +1 -1
  130. package/dist/src/index.d.ts +0 -1
  131. package/dist/src/index.js +0 -1
  132. package/dist/src/index.js.map +1 -1
  133. package/dist/src/internal/form.js +2 -2
  134. package/dist/src/internal/form.js.map +1 -1
  135. package/dist/src/nile-icon/icons/svg/agent.d.ts +1 -1
  136. package/dist/src/nile-icon/icons/svg/agent.js +1 -1
  137. package/dist/src/nile-icon/icons/svg/agent.js.map +1 -1
  138. package/dist/src/nile-icon/icons/svg/api.d.ts +1 -1
  139. package/dist/src/nile-icon/icons/svg/api.js +1 -1
  140. package/dist/src/nile-icon/icons/svg/api.js.map +1 -1
  141. package/dist/src/nile-icon/icons/svg/apply-filter.d.ts +1 -1
  142. package/dist/src/nile-icon/icons/svg/apply-filter.js +1 -1
  143. package/dist/src/nile-icon/icons/svg/apply-filter.js.map +1 -1
  144. package/dist/src/nile-icon/icons/svg/arrowdropdown.d.ts +1 -1
  145. package/dist/src/nile-icon/icons/svg/arrowdropdown.js +1 -1
  146. package/dist/src/nile-icon/icons/svg/arrowdropdown.js.map +1 -1
  147. package/dist/src/nile-icon/icons/svg/arrowdropup.d.ts +1 -1
  148. package/dist/src/nile-icon/icons/svg/arrowdropup.js +1 -1
  149. package/dist/src/nile-icon/icons/svg/arrowdropup.js.map +1 -1
  150. package/dist/src/nile-icon/icons/svg/database.d.ts +1 -1
  151. package/dist/src/nile-icon/icons/svg/database.js +1 -1
  152. package/dist/src/nile-icon/icons/svg/database.js.map +1 -1
  153. package/dist/src/nile-icon/icons/svg/done.d.ts +1 -1
  154. package/dist/src/nile-icon/icons/svg/done.js +1 -1
  155. package/dist/src/nile-icon/icons/svg/done.js.map +1 -1
  156. package/dist/src/nile-icon/icons/svg/dontmap.d.ts +1 -1
  157. package/dist/src/nile-icon/icons/svg/dontmap.js +1 -1
  158. package/dist/src/nile-icon/icons/svg/dontmap.js.map +1 -1
  159. package/dist/src/nile-icon/icons/svg/doublearrowleft.d.ts +1 -1
  160. package/dist/src/nile-icon/icons/svg/doublearrowleft.js +1 -1
  161. package/dist/src/nile-icon/icons/svg/doublearrowleft.js.map +1 -1
  162. package/dist/src/nile-icon/icons/svg/doublearrowright.d.ts +1 -1
  163. package/dist/src/nile-icon/icons/svg/doublearrowright.js +1 -1
  164. package/dist/src/nile-icon/icons/svg/doublearrowright.js.map +1 -1
  165. package/dist/src/nile-icon/icons/svg/drag.d.ts +1 -1
  166. package/dist/src/nile-icon/icons/svg/drag.js +1 -1
  167. package/dist/src/nile-icon/icons/svg/drag.js.map +1 -1
  168. package/dist/src/nile-icon/icons/svg/expand-06.d.ts +1 -1
  169. package/dist/src/nile-icon/icons/svg/expand-06.js +1 -1
  170. package/dist/src/nile-icon/icons/svg/expand-06.js.map +1 -1
  171. package/dist/src/nile-icon/icons/svg/expand.d.ts +1 -1
  172. package/dist/src/nile-icon/icons/svg/expand.js +1 -1
  173. package/dist/src/nile-icon/icons/svg/expand.js.map +1 -1
  174. package/dist/src/nile-icon/icons/svg/integer.d.ts +1 -1
  175. package/dist/src/nile-icon/icons/svg/integer.js +1 -1
  176. package/dist/src/nile-icon/icons/svg/integer.js.map +1 -1
  177. package/dist/src/nile-icon/icons/svg/pluscircle.d.ts +1 -1
  178. package/dist/src/nile-icon/icons/svg/pluscircle.js +1 -1
  179. package/dist/src/nile-icon/icons/svg/pluscircle.js.map +1 -1
  180. package/dist/src/nile-icon/icons/svg/question.d.ts +1 -1
  181. package/dist/src/nile-icon/icons/svg/question.js +1 -1
  182. package/dist/src/nile-icon/icons/svg/question.js.map +1 -1
  183. package/dist/src/nile-icon/icons/svg/resource.d.ts +1 -1
  184. package/dist/src/nile-icon/icons/svg/resource.js +1 -1
  185. package/dist/src/nile-icon/icons/svg/resource.js.map +1 -1
  186. package/dist/src/nile-icon/icons/svg/sendescalation.d.ts +1 -1
  187. package/dist/src/nile-icon/icons/svg/sendescalation.js +1 -1
  188. package/dist/src/nile-icon/icons/svg/sendescalation.js.map +1 -1
  189. package/dist/src/nile-icon/icons/svg/sendreminder.d.ts +1 -1
  190. package/dist/src/nile-icon/icons/svg/sendreminder.js +1 -1
  191. package/dist/src/nile-icon/icons/svg/sendreminder.js.map +1 -1
  192. package/dist/src/nile-icon/icons/svg/timezone.d.ts +1 -1
  193. package/dist/src/nile-icon/icons/svg/timezone.js +1 -1
  194. package/dist/src/nile-icon/icons/svg/timezone.js.map +1 -1
  195. package/dist/src/nile-icon/icons/svg/unmute.d.ts +1 -1
  196. package/dist/src/nile-icon/icons/svg/unmute.js +1 -1
  197. package/dist/src/nile-icon/icons/svg/unmute.js.map +1 -1
  198. package/dist/src/nile-icon/icons/svg/upgrade.d.ts +1 -1
  199. package/dist/src/nile-icon/icons/svg/upgrade.js +1 -1
  200. package/dist/src/nile-icon/icons/svg/upgrade.js.map +1 -1
  201. package/dist/src/nile-option/nile-option.css.js +1 -1
  202. package/dist/src/nile-option/nile-option.css.js.map +1 -1
  203. package/dist/src/nile-option/nile-option.d.ts +4 -6
  204. package/dist/src/nile-option/nile-option.js +14 -20
  205. package/dist/src/nile-option/nile-option.js.map +1 -1
  206. package/dist/src/nile-select/nile-select.d.ts +5 -10
  207. package/dist/src/nile-select/nile-select.js +29 -38
  208. package/dist/src/nile-select/nile-select.js.map +1 -1
  209. package/dist/tsconfig.tsbuildinfo +1 -1
  210. package/package.json +2 -1
  211. package/src/index.ts +1 -3
  212. package/src/internal/form.ts +2 -2
  213. package/src/nile-icon/icons/svg/agent.ts +1 -1
  214. package/src/nile-icon/icons/svg/api.ts +1 -1
  215. package/src/nile-icon/icons/svg/apply-filter.ts +1 -1
  216. package/src/nile-icon/icons/svg/arrowdropdown.ts +1 -1
  217. package/src/nile-icon/icons/svg/arrowdropup.ts +1 -1
  218. package/src/nile-icon/icons/svg/database.ts +1 -1
  219. package/src/nile-icon/icons/svg/done.ts +1 -1
  220. package/src/nile-icon/icons/svg/dontmap.ts +1 -1
  221. package/src/nile-icon/icons/svg/doublearrowleft.ts +1 -1
  222. package/src/nile-icon/icons/svg/doublearrowright.ts +1 -1
  223. package/src/nile-icon/icons/svg/drag.ts +1 -1
  224. package/src/nile-icon/icons/svg/expand-06.ts +1 -1
  225. package/src/nile-icon/icons/svg/expand.ts +1 -1
  226. package/src/nile-icon/icons/svg/integer.ts +1 -1
  227. package/src/nile-icon/icons/svg/pluscircle.ts +1 -1
  228. package/src/nile-icon/icons/svg/question.ts +1 -1
  229. package/src/nile-icon/icons/svg/resource.ts +1 -1
  230. package/src/nile-icon/icons/svg/sendescalation.ts +1 -1
  231. package/src/nile-icon/icons/svg/sendreminder.ts +1 -1
  232. package/src/nile-icon/icons/svg/timezone.ts +1 -1
  233. package/src/nile-icon/icons/svg/unmute.ts +1 -1
  234. package/src/nile-icon/icons/svg/upgrade.ts +1 -1
  235. package/src/nile-option/nile-option.css.ts +1 -1
  236. package/src/nile-option/nile-option.ts +10 -16
  237. package/src/nile-select/nile-select.ts +23 -34
  238. package/vscode-html-custom-data.json +6 -228
  239. package/dist/nile-select/virtual-scroll-helper.cjs.js +0 -2
  240. package/dist/nile-select/virtual-scroll-helper.cjs.js.map +0 -1
  241. package/dist/nile-select/virtual-scroll-helper.esm.js +0 -38
  242. package/dist/nile-virtual-select/index.cjs.js +0 -2
  243. package/dist/nile-virtual-select/index.cjs.js.map +0 -1
  244. package/dist/nile-virtual-select/index.esm.js +0 -1
  245. package/dist/nile-virtual-select/nile-virtual-select.cjs.js +0 -2
  246. package/dist/nile-virtual-select/nile-virtual-select.cjs.js.map +0 -1
  247. package/dist/nile-virtual-select/nile-virtual-select.css.cjs.js +0 -2
  248. package/dist/nile-virtual-select/nile-virtual-select.css.cjs.js.map +0 -1
  249. package/dist/nile-virtual-select/nile-virtual-select.css.esm.js +0 -468
  250. package/dist/nile-virtual-select/nile-virtual-select.esm.js +0 -227
  251. package/dist/nile-virtual-select/nile-virtual-select.test.cjs.js +0 -2
  252. package/dist/nile-virtual-select/nile-virtual-select.test.cjs.js.map +0 -1
  253. package/dist/nile-virtual-select/nile-virtual-select.test.esm.js +0 -49
  254. package/dist/nile-virtual-select/renderer.cjs.js +0 -2
  255. package/dist/nile-virtual-select/renderer.cjs.js.map +0 -1
  256. package/dist/nile-virtual-select/renderer.esm.js +0 -17
  257. package/dist/nile-virtual-select/search-manager.cjs.js +0 -2
  258. package/dist/nile-virtual-select/search-manager.cjs.js.map +0 -1
  259. package/dist/nile-virtual-select/search-manager.esm.js +0 -1
  260. package/dist/nile-virtual-select/selection-manager.cjs.js +0 -2
  261. package/dist/nile-virtual-select/selection-manager.cjs.js.map +0 -1
  262. package/dist/nile-virtual-select/selection-manager.esm.js +0 -1
  263. package/dist/nile-virtual-select/types.cjs.js +0 -2
  264. package/dist/nile-virtual-select/types.cjs.js.map +0 -1
  265. package/dist/nile-virtual-select/types.esm.js +0 -1
  266. package/dist/src/nile-select/virtual-scroll-helper.d.ts +0 -9
  267. package/dist/src/nile-select/virtual-scroll-helper.js +0 -51
  268. package/dist/src/nile-select/virtual-scroll-helper.js.map +0 -1
  269. package/dist/src/nile-virtual-select/index.d.ts +0 -1
  270. package/dist/src/nile-virtual-select/index.js +0 -2
  271. package/dist/src/nile-virtual-select/index.js.map +0 -1
  272. package/dist/src/nile-virtual-select/nile-virtual-select.css.d.ts +0 -12
  273. package/dist/src/nile-virtual-select/nile-virtual-select.css.js +0 -480
  274. package/dist/src/nile-virtual-select/nile-virtual-select.css.js.map +0 -1
  275. package/dist/src/nile-virtual-select/nile-virtual-select.d.ts +0 -251
  276. package/dist/src/nile-virtual-select/nile-virtual-select.js +0 -1158
  277. package/dist/src/nile-virtual-select/nile-virtual-select.js.map +0 -1
  278. package/dist/src/nile-virtual-select/nile-virtual-select.test.d.ts +0 -7
  279. package/dist/src/nile-virtual-select/nile-virtual-select.test.js +0 -317
  280. package/dist/src/nile-virtual-select/nile-virtual-select.test.js.map +0 -1
  281. package/dist/src/nile-virtual-select/renderer.d.ts +0 -11
  282. package/dist/src/nile-virtual-select/renderer.js +0 -48
  283. package/dist/src/nile-virtual-select/renderer.js.map +0 -1
  284. package/dist/src/nile-virtual-select/search-manager.d.ts +0 -12
  285. package/dist/src/nile-virtual-select/search-manager.js +0 -39
  286. package/dist/src/nile-virtual-select/search-manager.js.map +0 -1
  287. package/dist/src/nile-virtual-select/selection-manager.d.ts +0 -12
  288. package/dist/src/nile-virtual-select/selection-manager.js +0 -57
  289. package/dist/src/nile-virtual-select/selection-manager.js.map +0 -1
  290. package/dist/src/nile-virtual-select/types.d.ts +0 -45
  291. package/dist/src/nile-virtual-select/types.js +0 -8
  292. package/dist/src/nile-virtual-select/types.js.map +0 -1
  293. package/dist/virtualize-a4a40d96.esm.js +0 -22
  294. package/dist/virtualize-b6a2fbe0.cjs.js +0 -18
  295. package/dist/virtualize-b6a2fbe0.cjs.js.map +0 -1
  296. package/src/nile-select/virtual-scroll-helper.ts +0 -56
  297. package/src/nile-virtual-select/index.ts +0 -1
  298. package/src/nile-virtual-select/nile-virtual-select.css.ts +0 -482
  299. package/src/nile-virtual-select/nile-virtual-select.test.ts +0 -390
  300. package/src/nile-virtual-select/nile-virtual-select.ts +0 -1234
  301. package/src/nile-virtual-select/renderer.ts +0 -65
  302. package/src/nile-virtual-select/search-manager.ts +0 -48
  303. package/src/nile-virtual-select/selection-manager.ts +0 -64
  304. package/src/nile-virtual-select/types.ts +0 -48
@@ -1,1234 +0,0 @@
1
- /**
2
- * Copyright Aquera Inc 2025
3
- *
4
- * This source code is licensed under the BSD-3-Clause license found in the
5
- * LICENSE file in the root directory of this source tree.
6
- */
7
-
8
- import {
9
- LitElement,
10
- html,
11
- } from 'lit';
12
- import { customElement, property } from 'lit/decorators.js';
13
- import { styles } from './nile-virtual-select.css';
14
-
15
- import '../nile-icon';
16
- import '../nile-popup/nile-popup';
17
- import '../nile-tag/nile-tag';
18
- import '../nile-checkbox/nile-checkbox';
19
- import { animateTo, stopAnimations } from '../internal/animate';
20
- import { classMap } from 'lit/directives/class-map.js';
21
- import { query, state } from 'lit/decorators.js';
22
- import { defaultValue } from '../internal/default-value';
23
- import { FormControlController } from '../internal/form';
24
- import {
25
- getAnimation,
26
- setDefaultAnimation,
27
- } from '../utilities/animation-registry';
28
- import { HasSlotController } from '../internal/slot';
29
- import { waitForEvent } from '../internal/event';
30
- import { watch } from '../internal/watch';
31
- import NileElement from '../internal/nile-element';
32
- import type { CSSResultGroup, TemplateResult } from 'lit';
33
- import type { NileFormControl } from '../internal/nile-element';
34
- import type NileOption from '../nile-option/nile-option';
35
- import type NilePopup from '../nile-popup/nile-popup';
36
- import { ifDefined } from 'lit/directives/if-defined.js';
37
-
38
- import type { VirtualOption, NileRemoveEvent } from './types.js';
39
- import { VirtualSelectSelectionManager } from './selection-manager.js';
40
- import { VirtualSelectSearchManager } from './search-manager.js';
41
- import { VirtualSelectRenderer } from './renderer.js';
42
-
43
- /**
44
- * Nile Virtual Select component.
45
- *
46
- * @tag nile-virtual-select
47
- *
48
- */
49
-
50
- /**
51
- * @summary Virtual select component for handling large datasets with virtual scrolling.
52
- * @status stable
53
- * @since 2.0
54
- *
55
- * @dependency nile-icon
56
- * @dependency nile-popup
57
- * @dependency nile-tag
58
- * @dependency nile-checkbox
59
- *
60
- * @slot label - The input's label. Alternatively, you can use the `label` attribute.
61
- * @slot prefix - Used to prepend a presentational icon or similar element to the combobox.
62
- * @slot clear-icon - An icon to use in lieu of the default clear icon.
63
- * @slot expand-icon - The icon to show when the control is expanded and collapsed.
64
- * @slot help-text - Text that describes how to use the input. Alternatively, you can use the `help-text` attribute.
65
- *
66
- * @event nile-change - Emitted when the control's value changes.
67
- * @event nile-clear - Emitted when the control's value is cleared.
68
- * @event nile-input - Emitted when the control receives input.
69
- * @event nile-focus - Emitted when the control gains focus.
70
- * @event nile-blur - Emitted when the control loses focus.
71
- * @event nile-show - Emitted when the select's menu opens.
72
- * @event nile-after-show - Emitted after the select's menu opens and all animations are complete.
73
- * @event nile-hide - Emitted when the select's menu closes.
74
- * @event nile-after-hide - Emitted after the select's menu closes and all animations are complete.
75
- * @event nile-invalid - Emitted when the form control has been checked for validity and its constraints aren't satisfied.
76
- *
77
- * @csspart form-control - The form control that wraps the label, input, and help text.
78
- * @csspart form-control-label - The label's wrapper.
79
- * @csspart form-control-input - The select's wrapper.
80
- * @csspart form-control-help-text - The help text's wrapper.
81
- * @csspart combobox - The container the wraps the prefix, combobox, clear icon, and expand button.
82
- * @csspart prefix - The container that wraps the prefix slot.
83
- * @csspart display-input - The element that displays the selected option's label, an `<input>` element.
84
- * @csspart listbox - The listbox container where options are slotted.
85
- * @csspart tags - The container that houses option tags when `multiple` is used.
86
- * @csspart tag - The individual tags that represent each multiselect option.
87
- * @csspart clear-button - The clear button.
88
- * @csspart expand-icon - The container that wraps the expand icon.
89
- * @csspart footer - The footer container with show selected and clear all options.
90
- */
91
-
92
- @customElement('nile-virtual-select')
93
- export class NileVirtualSelect extends NileElement implements NileFormControl {
94
- static styles: CSSResultGroup = styles;
95
-
96
- private readonly formControlController = new FormControlController(this, {
97
- assumeInteractionOn: ['nile-blur', 'nile-input'],
98
- });
99
- private readonly hasSlotController = new HasSlotController(
100
- this,
101
- 'help-text',
102
- 'label'
103
- );
104
-
105
- @query('.select') popup: NilePopup;
106
- @query('.select__display-input') displayInput: HTMLInputElement;
107
- @query('.select__value-input') valueInput: HTMLInputElement;
108
-
109
- @state() private hasFocus = false;
110
- @state() displayLabel = '';
111
- @state() selectedOptions: VirtualOption[] = [];
112
- @state() oldValue: string | string[] = '';
113
-
114
- /** The name of the select, submitted as a name/value pair with form data. */
115
- @property() name = '';
116
-
117
- /** Array of all option items for virtual scrolling */
118
- @property({ type: Array }) data: any = [];
119
-
120
- /** Original unfiltered option items for search functionality */
121
- @state() private originalOptionItems: any = [];
122
-
123
- /**
124
- * The current value of the select. When `multiple` is enabled, the value will be an array of selected values.
125
- */
126
- @property({
127
- converter: {
128
- fromAttribute: (value: string) => value.split(' '),
129
- toAttribute: (value: string[]) => value.join(' '),
130
- },
131
- })
132
- value: string | string[] = '';
133
-
134
- /** The default value of the form control. Primarily used for resetting the form control. */
135
- @defaultValue() defaultValue: string | string[] = '';
136
-
137
- /** The select's size. */
138
- @property() size: 'small' | 'medium' | 'large' = 'medium';
139
-
140
- /** Placeholder text to show as a hint when the select is empty. */
141
- @property() placeholder = 'Select...';
142
-
143
- /** Current search value */
144
- @state() searchValue: string = '';
145
-
146
- /** Enable search functionality */
147
- @property({ type: Boolean, reflect: true }) searchEnabled = false;
148
-
149
- /** Search input placeholder */
150
- @property({attribute:'internal-search-placeholder'}) internalSearchPlaceHolder = 'Search...';
151
-
152
- /** Disable local search filtering */
153
- @property({ type: Boolean, reflect: true }) disableLocalSearch = false;
154
-
155
- /** Show loading state */
156
- @property({ type: Boolean, reflect: true }) optionsLoading = false;
157
-
158
- /** Allows more than one option to be selected. */
159
- @property({ type: Boolean, reflect: true }) multiple = false;
160
-
161
- /** Help text */
162
- @property({ attribute: 'help-text', reflect: true }) helpText = '';
163
-
164
- /** Error message */
165
- @property({ attribute: 'error-message', reflect: true }) errorMessage = '';
166
-
167
- /** Sets the input to a warning state */
168
- @property({ type: Boolean }) warning = false;
169
-
170
- /** Sets the input to an error state */
171
- @property({ type: Boolean }) error = false;
172
-
173
- /** Sets the input to a success state */
174
- @property({ type: Boolean }) success = false;
175
-
176
- /** Disables the select control. */
177
- @property({ type: Boolean, reflect: true }) disabled = false;
178
-
179
- /** Adds a clear button when the select is not empty. */
180
- @property({ type: Boolean, reflect: true }) clearable = false;
181
-
182
- /** The select's open state. */
183
- @property({ type: Boolean, reflect: true }) open = false;
184
-
185
- /**
186
- * Enable this option to prevent the listbox from being clipped when the component is placed inside a container with
187
- * `overflow: auto|scroll`. Hoisting uses a fixed positioning strategy that works in many, but not all, scenarios.
188
- */
189
- @property({ type: Boolean }) hoist = false;
190
-
191
- /** Draws a filled select. */
192
- @property({ type: Boolean, reflect: true }) filled = false;
193
-
194
- /** Draws a pill-style select with rounded edges. */
195
- @property({ type: Boolean, reflect: true }) pill = false;
196
-
197
- /** The select's label. If you need to display HTML, use the `label` slot instead. */
198
- @property() label = '';
199
-
200
- /**
201
- * The preferred placement of the select's menu. Note that the actual placement may vary as needed to keep the listbox
202
- * inside of the viewport.
203
- */
204
- @property({ reflect: true }) placement: 'top' | 'bottom' = 'bottom';
205
-
206
- /**
207
- * By default, form controls are associated with the nearest containing `<form>` element. This attribute allows you
208
- * to place the form control outside of a form and associate it with the form that has this `id`. The form must be in
209
- * the same document or shadow root for this to work.
210
- */
211
- @property({ reflect: true }) form = '';
212
-
213
- /** The select's required attribute. */
214
- @property({ type: Boolean, reflect: true }) required = false;
215
-
216
- /** Show no results message */
217
- @property({ type: Boolean }) showNoResults: boolean = false;
218
-
219
- /** No results message */
220
- @property({ type: String }) noResultsMessage: string = 'No results found';
221
-
222
- /** Show selected options only */
223
- @property({ type: Boolean }) showSelected = false;
224
-
225
- /** Function to render item value from data object */
226
- @property({ attribute:false}) renderItemFunction: (item:any)=>string = (item:any)=>item?.label || item?.name || item;
227
-
228
- /** Block value change events */
229
- @property({ type: Boolean, reflect: true }) blockValueChange = false;
230
-
231
- /** Disable width synchronization */
232
- @property({ type: Boolean, reflect: true }) noWidthSync = false;
233
-
234
- /**
235
- * The maximum number of selected options to show when `multiple` is true. After the maximum, "+n" will be shown to
236
- * indicate the number of additional items that are selected. Set to 0 to remove the limit.
237
- */
238
- @property({ attribute: 'max-options-visible', type: Number })
239
- maxOptionsVisible = 3;
240
-
241
- @state() oldMaxOptionsVisible: number = 1;
242
-
243
- /** Gets the validity state object */
244
- get validity() {
245
- return this.valueInput?.validity;
246
- }
247
-
248
- /** Gets the validation message */
249
- get validationMessage() {
250
- return this.valueInput?.validationMessage ?? '';
251
- }
252
-
253
- connectedCallback() {
254
- super.connectedCallback();
255
- this.initializeComponent();
256
- this.setupEventListeners();
257
-
258
- this.updateComplete.then(() => {
259
- if (this.value && this.data.length > 0) {
260
- this.selectionChanged();
261
- }
262
- });
263
- }
264
-
265
- disconnectedCallback() {
266
- this.removeOpenListeners();
267
- }
268
-
269
- private initializeComponent(): void {
270
- this.renderItemFunction = (item:any) => item?.label || item?.name || item;
271
- this.open = false;
272
- this.emit('nile-init');
273
- }
274
-
275
- private setupEventListeners(): void {
276
- this.handleDocumentFocusIn = this.handleDocumentFocusIn.bind(this);
277
- this.handleDocumentKeyDown = this.handleDocumentKeyDown.bind(this);
278
- this.handleDocumentMouseDown = this.handleDocumentMouseDown.bind(this);
279
- }
280
-
281
- private addOpenListeners(): void {
282
- document.addEventListener('focusin', this.handleDocumentFocusIn);
283
- document.addEventListener('keydown', this.handleDocumentKeyDown);
284
- document.addEventListener('mousedown', this.handleDocumentMouseDown);
285
- }
286
-
287
- private removeOpenListeners(): void {
288
- document.removeEventListener('focusin', this.handleDocumentFocusIn);
289
- document.removeEventListener('keydown', this.handleDocumentKeyDown);
290
- document.removeEventListener('mousedown', this.handleDocumentMouseDown);
291
- }
292
-
293
- private handleFocus(): void {
294
- this.hasFocus = true;
295
- this.emit('nile-focus');
296
- }
297
-
298
- private handleBlur(): void {
299
- this.hasFocus = false;
300
- this.emit('nile-blur');
301
- }
302
-
303
- private handleDocumentFocusIn(event: FocusEvent): void {
304
- if (!this.open) return;
305
- const path = event.composedPath();
306
- const hitSelf = path.includes(this);
307
- const hitPopup = this.popup && path.includes(this.popup);
308
-
309
- if (!hitSelf && !hitPopup) {
310
- this.hide();
311
- }
312
- }
313
-
314
- private handleDocumentKeyDown(event: KeyboardEvent): void {
315
- if (this.shouldIgnoreKeyPress(event)) {
316
- return;
317
- }
318
-
319
- if (this.isEscapeKey(event)) {
320
- this.handleEscapeKey(event);
321
- }
322
-
323
- if (this.isEnterOrSpaceKey(event)) {
324
- this.handleEnterOrSpaceKey(event);
325
- }
326
- }
327
-
328
- private shouldIgnoreKeyPress(event: KeyboardEvent): boolean {
329
- const target = event.target as HTMLElement;
330
- const isClearButton = target.closest('.select__clear') !== null;
331
- const isIconButton = target.closest('nile-icon-button') !== null;
332
- return isClearButton || isIconButton;
333
- }
334
-
335
- private isEscapeKey(event: KeyboardEvent): boolean {
336
- return event.key === 'Escape' && this.open;
337
- }
338
-
339
- private handleEscapeKey(event: KeyboardEvent): void {
340
- event.preventDefault();
341
- event.stopPropagation();
342
- this.hide();
343
- this.displayInput.focus({ preventScroll: true });
344
- }
345
-
346
- private isEnterOrSpaceKey(event: KeyboardEvent): boolean {
347
- return event.key === 'Enter' || event.key === ' ';
348
- }
349
-
350
- private handleEnterOrSpaceKey(event: KeyboardEvent): void {
351
- event.preventDefault();
352
- event.stopImmediatePropagation();
353
-
354
- if (!this.open) {
355
- this.show();
356
- return;
357
- }
358
-
359
- if (!this.multiple) {
360
- this.hide();
361
- this.displayInput.focus({ preventScroll: true });
362
- }
363
- }
364
-
365
- private handleDocumentMouseDown = (event: MouseEvent): void => {
366
- if (!this.open) return;
367
-
368
- const path = event.composedPath();
369
- const hitSelf = path.includes(this);
370
- const hitPopup = this.popup && path.includes(this.popup);
371
-
372
- if (!hitSelf && !hitPopup) {
373
- this.hide();
374
- }
375
- };
376
-
377
- private handleFooterClick(event: MouseEvent): void {
378
- event.stopPropagation();
379
- event.preventDefault();
380
- }
381
-
382
- private toggleShowSelected(event: Event): void {
383
- event.stopPropagation();
384
- event.preventDefault();
385
- if (this.selectedOptions?.length === 0) {
386
- return;
387
- }
388
- this.showSelected = !this.showSelected;
389
-
390
- if (this.showSelected) {
391
- const selectedValues = Array.isArray(this.value) ? this.value : [this.value];
392
- this.data = this.originalOptionItems.filter((item: any) =>
393
- selectedValues.includes(item.value)
394
- );
395
- } else {
396
- this.data = [...this.originalOptionItems];
397
- }
398
-
399
- this.requestUpdate();
400
- }
401
-
402
- private unSelectAll(): void {
403
- this.showSelected = false;
404
- this.value = this.multiple ? [] : '';
405
- this.data = [...this.originalOptionItems];
406
- this.selectionChanged();
407
- this.emit('nile-change', { value: this.value, name: this.name });
408
- this.emit('nile-clear', { value: this.multiple ? this.value : '', name: this.name });
409
- }
410
-
411
- private handleLabelClick(): void {
412
- this.displayInput.focus();
413
- this.hide();
414
- }
415
-
416
- private handleComboboxMouseDown(event: MouseEvent): void {
417
- if (this.shouldIgnoreComboboxClick(event)) {
418
- return;
419
- }
420
-
421
- event.preventDefault();
422
- this.displayInput.focus({ preventScroll: true });
423
- this.open = !this.open;
424
- }
425
-
426
- private shouldIgnoreComboboxClick(event: MouseEvent): boolean {
427
- const path = event.composedPath();
428
- const isIconButton = path.some(
429
- el =>
430
- el instanceof Element && el.tagName.toLowerCase() === 'nile-icon-button'
431
- );
432
- return this.disabled || isIconButton;
433
- }
434
-
435
- private handleComboboxKeyDown(event: KeyboardEvent): void {
436
- if (this.isEnterOrSpaceKey(event)) {
437
- event.preventDefault();
438
- this.open = !this.open;
439
- }
440
- }
441
-
442
- private handleClearClick(event: MouseEvent): void {
443
- event.stopPropagation();
444
- this.clearSelection();
445
- }
446
-
447
- private clearSelection(): void {
448
- const oldValue = this.value;
449
- this.value = this.multiple ? [] : '';
450
- this.selectionChanged();
451
-
452
- this.updateComplete.then(() => {
453
- this.nileInput({ value: this.value, name: this.name });
454
- this.nileChange({ value: this.value, name: this.name });
455
- this.emit('nile-clear');
456
- });
457
- }
458
-
459
- private handleClearMouseDown(event: MouseEvent): void {
460
- event.stopPropagation();
461
- }
462
-
463
- private handleOptionClick(event: MouseEvent): void {
464
- const target = event.target as HTMLElement;
465
- const option = target.closest('nile-option');
466
-
467
- if (this.shouldBlockValueChange(option)) {
468
- return;
469
- }
470
-
471
- const oldValue = this.value;
472
- this.oldValue = oldValue;
473
-
474
- if (option && !option.disabled) {
475
- this.handleOptionSelection(option);
476
- }
477
- }
478
-
479
- private shouldBlockValueChange(option: Element | null): boolean {
480
- if (this.blockValueChange && option) {
481
- this.emit('nile-block-change', { value: (option as any)?.value, name: this.name });
482
- this.hide();
483
- return true;
484
- }
485
- return false;
486
- }
487
-
488
- private handleOptionSelection(option: Element): void {
489
- const optionValue = (option as any).value;
490
-
491
- if (this.multiple) {
492
- this.toggleOptionSelection(optionValue);
493
- } else {
494
- this.setSelectedOptions(optionValue);
495
- }
496
-
497
- this.updateComplete.then(() =>
498
- this.displayInput.focus({ preventScroll: true })
499
- );
500
-
501
- if (this.value !== this.oldValue) {
502
- this.updateComplete.then(() => {
503
- this.nileInput({ value: this.value, name: this.name });
504
- this.nileChange({ value: this.value, name: this.name });
505
- });
506
- }
507
-
508
- if (!this.multiple) {
509
- this.hide();
510
- this.displayInput.focus({ preventScroll: true });
511
- }
512
- }
513
-
514
- private setSelectedOptions(optionValue: string): void {
515
- this.value = optionValue;
516
- this.selectionChanged();
517
- }
518
-
519
- private toggleOptionSelection(optionValue: string): void {
520
- const currentValues = Array.isArray(this.value) ? this.value : [];
521
-
522
- if (currentValues.includes(optionValue)) {
523
- this.value = currentValues.filter(v => v !== optionValue);
524
- } else {
525
- this.value = [...currentValues, optionValue];
526
- }
527
-
528
- this.selectionChanged();
529
- }
530
-
531
- private handleTagRemove(event: NileRemoveEvent, option: VirtualOption): void {
532
- event.stopPropagation();
533
-
534
- if (!this.disabled) {
535
- this.removeTagFromSelection(option);
536
- this.emitTagRemovalEvent(option);
537
- }
538
- }
539
-
540
- private removeTagFromSelection(option: VirtualOption): void {
541
- let currentValue = this.value;
542
- if (!Array.isArray(currentValue)) {
543
- currentValue = currentValue ? [currentValue] : [];
544
- }
545
- const newValue = currentValue.filter((v: string) => v !== option.value);
546
- this.value = newValue;
547
- this.selectionChanged();
548
- }
549
-
550
- private emitTagRemovalEvent(option: VirtualOption): void {
551
- this.updateComplete.then(() => {
552
- this.nileInput({ value: this.value, name: this.name });
553
- this.nileChange({ value: this.value, name: this.name });
554
- this.emit('nile-tag-remove', { value: this.value, name: this.name, removedtagvalue: option.value });
555
- });
556
- }
557
-
558
- private selectionChanged(): void {
559
- const itemsToSearch = this.originalOptionItems.length > 0 ? this.originalOptionItems : this.data;
560
- this.selectedOptions = VirtualSelectSelectionManager.createVirtualOptionsFromValues(
561
- this.value,
562
- itemsToSearch,
563
- this.renderItemFunction
564
- );
565
-
566
- if (this.multiple) {
567
- if (this.placeholder && this.value.length === 0) {
568
- this.displayLabel = '';
569
- } else {
570
- this.displayLabel = this.selectedOptions.length + ' selected';
571
- }
572
- } else {
573
- const currentValue = Array.isArray(this.value) ? this.value[0] : this.value;
574
- const label = this.selectedOptions[0]?.getTextLabel();
575
- this.displayLabel = label ? label : currentValue ?? '';
576
- }
577
-
578
- this.updateValidity();
579
-
580
- if (this.selectedOptions.length === 0) {
581
- this.showSelected = false;
582
- }
583
-
584
- this.calculateTotalWidthOfTags();
585
- }
586
-
587
- handleSearchFocus(): void {
588
- document.removeEventListener('keydown', this.handleDocumentKeyDown);
589
- }
590
-
591
- handleSearchBlur(): void {
592
- document.addEventListener('keydown', this.handleDocumentKeyDown);
593
- }
594
-
595
- handleSearchChange(e: any): void {
596
- this.searchValue = e.detail.value;
597
- if (!this.disableLocalSearch) {
598
- this.filterVirtualOptions(this.searchValue);
599
- }
600
- }
601
-
602
- filterVirtualOptions(searchValue: string): void {
603
- const result = VirtualSelectSearchManager.filterVirtualOptions(
604
- searchValue,
605
- this.originalOptionItems,
606
- this.data,
607
- this.renderItemFunction
608
- );
609
-
610
- this.data = result.filteredItems;
611
- this.showNoResults = result.showNoResults;
612
- this.requestUpdate();
613
- }
614
-
615
- private handleInvalid(event: Event): void {
616
- this.formControlController.setValidity(false);
617
- this.formControlController.emitInvalidEvent(event);
618
- }
619
-
620
- @watch('disabled', { waitUntilFirstUpdate: true })
621
- handleDisabledChange(): void {
622
- if (this.disabled) {
623
- this.open = false;
624
- this.handleOpenChange();
625
- }
626
- }
627
-
628
- @watch('value', { waitUntilFirstUpdate: true })
629
- handleValueChange(): void {
630
- this.selectionChanged();
631
- this.requestUpdate();
632
- }
633
-
634
- @watch('data', { waitUntilFirstUpdate: true })
635
- handleDataChange(): void {
636
- this.selectionChanged();
637
- this.requestUpdate();
638
- }
639
-
640
- @watch('renderItemFunction', { waitUntilFirstUpdate: true })
641
- handleRenderItemFunctionChange(): void {
642
- if (this.value && this.data.length > 0) {
643
- this.selectionChanged();
644
- this.requestUpdate();
645
- }
646
- }
647
-
648
- @watch('open', { waitUntilFirstUpdate: true })
649
- async handleOpenChange(): Promise<void> {
650
- if (this.open && !this.disabled) {
651
- await this.handleOpen();
652
- } else {
653
- await this.handleClose();
654
- }
655
- }
656
-
657
- private async handleOpen(): Promise<void> {
658
- this.emit('nile-show', { value: this.value, name: this.name });
659
- this.addOpenListeners();
660
- this.showNoResults = !this.data?.length;
661
-
662
- await stopAnimations(this);
663
- this.popup.active = true;
664
-
665
- const { keyframes, options } = getAnimation(this, 'select.show', {
666
- dir: 'ltr',
667
- });
668
- await animateTo(this.popup.popup, keyframes, options);
669
-
670
- this.initializeOriginalItems();
671
- this.filterVirtualOptions(this.searchValue);
672
- this.emit('nile-after-show', { value: this.value, name: this.name });
673
- }
674
-
675
- private async handleClose(): Promise<void> {
676
- this.emit('nile-hide', { value: this.value, name: this.name });
677
- this.removeOpenListeners();
678
-
679
- await stopAnimations(this);
680
- const { keyframes, options } = getAnimation(this, 'select.hide', {
681
- dir: 'ltr',
682
- });
683
- await animateTo(this.popup.popup, keyframes, options);
684
- this.popup.active = false;
685
-
686
- this.searchValue = '';
687
- this.emit('nile-after-hide', { value: this.value, name: this.name });
688
- }
689
-
690
- private initializeOriginalItems(): void {
691
- if (this.originalOptionItems.length === 0 && this.data.length > 0) {
692
- this.originalOptionItems = [...this.data];
693
- }
694
- }
695
-
696
- async show(): Promise<unknown> {
697
- if (this.open || this.disabled) {
698
- this.open = false;
699
- return undefined;
700
- }
701
-
702
- this.open = true;
703
- return waitForEvent(this, 'nile-after-show');
704
- }
705
-
706
- async hide(): Promise<unknown> {
707
- if (!this.open || this.disabled) {
708
- this.open = false;
709
- return undefined;
710
- }
711
-
712
- this.open = false;
713
- return waitForEvent(this, 'nile-after-hide');
714
- }
715
-
716
- checkValidity(): boolean {
717
- return this.valueInput.checkValidity();
718
- }
719
-
720
- getForm(): HTMLFormElement | null {
721
- return this.formControlController.getForm();
722
- }
723
-
724
- reportValidity(): boolean {
725
- return this.valueInput.reportValidity();
726
- }
727
-
728
- setCustomValidity(message: string): void {
729
- this.valueInput.setCustomValidity(message);
730
- this.formControlController.updateValidity();
731
- }
732
-
733
- focus(options?: FocusOptions): void {
734
- this.displayInput.focus(options);
735
- }
736
-
737
- blur(): void {
738
- this.displayInput.blur();
739
- }
740
-
741
- onInputChange(event: Event): void {
742
- event.stopPropagation();
743
- }
744
-
745
- render(): TemplateResult {
746
- const hasLabelSlot = this.hasSlotController.test('label');
747
- const hasHelpTextSlot = this.hasSlotController.test('help-text');
748
- const hasLabelSuffixSlot = this.hasSlotController.test('label-suffix');
749
- const hasCustomSelect = this.hasSlotController.test('custom-select');
750
- const hasLabel = this.label ? true : !!hasLabelSlot;
751
- const hasClearIcon =
752
- this.clearable && !this.disabled && this.value.length > 0;
753
- const isPlaceholderVisible = !!this.placeholder && this.value.length === 0;
754
- const hasHelpText = !!this.helpText;
755
- const hasErrorMessage = !!this.errorMessage;
756
-
757
- return html`
758
- <div
759
- part="form-control"
760
- class=${classMap({
761
- 'form-control': true,
762
- 'form-control--small': this.size === 'small',
763
- 'form-control--medium': this.size === 'medium',
764
- 'form-control--large': this.size === 'large',
765
- 'form-control--has-label': hasLabel,
766
- 'form-control--has-help-text': hasHelpText,
767
- })}
768
- >
769
- ${this.renderLabel(hasLabel, hasLabelSuffixSlot)}
770
- ${this.renderFormControlInput(hasCustomSelect, hasClearIcon, isPlaceholderVisible, hasHelpText, hasErrorMessage)}
771
- </div>
772
- `;
773
- }
774
-
775
- private renderLabel(hasLabel: boolean, hasLabelSuffixSlot: boolean): TemplateResult {
776
- return html`
777
- <label
778
- id="label"
779
- part="form-control-label"
780
- class="form-control__label"
781
- aria-hidden=${hasLabel ? 'false' : 'true'}
782
- @click=${this.handleLabelClick}
783
- >
784
- <slot name="label">${this.label}</slot>
785
- </label>
786
-
787
- ${hasLabelSuffixSlot ? html` <slot name="label-suffix"></slot> ` : ``}
788
- `;
789
- }
790
-
791
- private renderFormControlInput(
792
- hasCustomSelect: boolean,
793
- hasClearIcon: boolean,
794
- isPlaceholderVisible: boolean,
795
- hasHelpText: boolean,
796
- hasErrorMessage: boolean
797
- ): TemplateResult {
798
- return html`
799
- <div part="form-control-input" class="form-control-input">
800
- ${this.renderPopup(hasCustomSelect, hasClearIcon, isPlaceholderVisible)}
801
- ${this.renderHelpText(hasHelpText, hasErrorMessage)}
802
- </div>
803
- `;
804
- }
805
-
806
- private renderPopup(hasCustomSelect: boolean, hasClearIcon: boolean, isPlaceholderVisible: boolean): TemplateResult {
807
- return html`
808
- <nile-popup
809
- class=${classMap({
810
- select: true,
811
- 'select--warning': this.warning,
812
- 'select--error': this.error,
813
- 'select--success': this.success,
814
- 'select--standard': true,
815
- 'select--filled': this.filled,
816
- 'select--pill': this.pill,
817
- 'select--open': this.open,
818
- 'select--disabled': this.disabled,
819
- 'select--multiple': this.multiple,
820
- 'select--focused': this.hasFocus,
821
- 'select--placeholder-visible': isPlaceholderVisible,
822
- 'select--top': this.placement === 'top',
823
- 'select--bottom': this.placement === 'bottom',
824
- 'select--small': this.size === 'small',
825
- 'select--medium': this.size === 'medium',
826
- 'select--large': this.size === 'large',
827
- })}
828
- placement=${this.placement}
829
- strategy=${this.hoist ? 'fixed' : 'absolute'}
830
- distance="6"
831
- flip
832
- shift
833
- sync=${ifDefined(!this.noWidthSync ? 'width' : undefined)}
834
- auto-size="vertical"
835
- auto-size-padding="10"
836
- >
837
- ${this.renderCustomSelect(hasCustomSelect)}
838
- ${this.renderCombobox(hasCustomSelect, hasClearIcon)}
839
- ${this.renderListbox()}
840
- </nile-popup>
841
- `;
842
- }
843
-
844
- private renderCustomSelect(hasCustomSelect: boolean): TemplateResult {
845
- return hasCustomSelect
846
- ? html`<slot
847
- slot="anchor"
848
- name="custom-select"
849
- class="custom-select"
850
- @keydown=${this.handleComboboxKeyDown}
851
- @mousedown=${this.handleComboboxMouseDown}
852
- ></slot>`
853
- : html``;
854
- }
855
-
856
- private renderCombobox(hasCustomSelect: boolean, hasClearIcon: boolean): TemplateResult {
857
- return html`
858
- <div
859
- part="combobox"
860
- class=${classMap({
861
- select__combobox: true,
862
- 'select__hide-default': hasCustomSelect,
863
- })}
864
- slot="anchor"
865
- @keydown=${this.handleComboboxKeyDown}
866
- @mousedown=${this.handleComboboxMouseDown}
867
- >
868
- ${this.renderPrefix()}
869
- ${this.renderDisplayInput()}
870
- ${this.renderTags()}
871
- ${this.renderValueInput()}
872
- ${this.renderClearButton(hasClearIcon)}
873
- ${this.renderSuffix()}
874
- ${this.renderExpandIcon()}
875
- </div>
876
- `;
877
- }
878
-
879
- private renderPrefix(): TemplateResult {
880
- return html`
881
- <slot
882
- part="prefix"
883
- name="prefix"
884
- class=${classMap({
885
- select__prefix: true,
886
- multiple: this.multiple,
887
- })}
888
- ></slot>
889
- `;
890
- }
891
-
892
- private renderDisplayInput(): TemplateResult {
893
- return html`
894
- <input
895
- part="display-input"
896
- class="select__display-input"
897
- type="text"
898
- placeholder=${this.placeholder}
899
- .disabled=${this.disabled}
900
- .value=${this.displayLabel}
901
- autocomplete="off"
902
- spellcheck="false"
903
- autocapitalize="off"
904
- readonly
905
- aria-controls="listbox"
906
- aria-expanded=${this.open ? 'true' : 'false'}
907
- aria-haspopup="listbox"
908
- aria-labelledby="label"
909
- aria-disabled=${this.disabled ? 'true' : 'false'}
910
- aria-describedby="help-text"
911
- role="combobox"
912
- tabindex="0"
913
- />
914
- `;
915
- }
916
-
917
- private renderTags(): TemplateResult {
918
- return this.multiple
919
- ? html`
920
- <div part="tags" class="select__tags">
921
- ${this.selectedOptions.map((option, index) => {
922
- if (
923
- index < this.maxOptionsVisible ||
924
- this.maxOptionsVisible <= 0
925
- ) {
926
- const classes = {
927
- select__invisible:
928
- index + 1 > this.oldMaxOptionsVisible &&
929
- this.maxOptionsVisible === Infinity,
930
- };
931
- return html`
932
- <nile-tag
933
- class=${classMap(classes)}
934
- part="tag"
935
- exportparts="
936
- base:tag__base,
937
- content:tag__content,
938
- remove-button:tag__remove-button,
939
- remove-button__base:tag__remove-button__base
940
- "
941
- ?pill=${this.pill}
942
- size=${this.size}
943
- removable
944
- @nile-remove=${(event: NileRemoveEvent) =>
945
- this.handleTagRemove(event, option)}
946
- >
947
- ${option.getTextLabel()}
948
- </nile-tag>
949
- `;
950
- } else if (index === this.maxOptionsVisible) {
951
- return html`
952
- <span class="select__tags-count"
953
- >+${this.selectedOptions.length - index} More
954
- </span>
955
- `;
956
- } else {
957
- return null;
958
- }
959
- })}
960
- </div>
961
- `
962
- : html``;
963
- }
964
-
965
- private renderValueInput(): TemplateResult {
966
- return html`
967
- <input
968
- class="select__value-input"
969
- type="text"
970
- ?disabled=${this.disabled}
971
- ?required=${this.required}
972
- .value=${Array.isArray(this.value)
973
- ? this.value.join(', ')
974
- : this.value}
975
- tabindex="-1"
976
- aria-hidden="true"
977
- @focus=${() => this.focus()}
978
- @invalid=${this.handleInvalid}
979
- />
980
- `;
981
- }
982
-
983
- private renderClearButton(hasClearIcon: boolean): TemplateResult {
984
- return hasClearIcon
985
- ? html`
986
- <button
987
- part="clear-button"
988
- class="select__clear"
989
- type="button"
990
- aria-label="clearEntry"
991
- @mousedown=${this.handleClearMouseDown}
992
- @click=${this.handleClearClick}
993
- tabindex="-1"
994
- >
995
- <slot name="clear-icon">
996
- <nile-icon name="close" library="system"></nile-icon>
997
- </slot>
998
- </button>
999
- `
1000
- : html``;
1001
- }
1002
-
1003
- private renderSuffix(): TemplateResult {
1004
- return html`
1005
- <slot
1006
- part="suffix"
1007
- name="suffix"
1008
- class=${classMap({
1009
- select__suffix: true,
1010
- })}
1011
- ></slot>
1012
- `;
1013
- }
1014
-
1015
- private renderExpandIcon(): TemplateResult {
1016
- return html`
1017
- <slot
1018
- name="expand-icon"
1019
- part="expand-icon"
1020
- class="select__expand-icon"
1021
- >
1022
- <nile-icon library="system" name="arrowdown"></nile-icon>
1023
- </slot>
1024
- `;
1025
- }
1026
-
1027
- private renderListbox(): TemplateResult {
1028
- return html`
1029
- <div
1030
- id="listbox"
1031
- role="listbox"
1032
- aria-expanded=${this.open ? 'true' : 'false'}
1033
- aria-multiselectable=${this.multiple ? 'true' : 'false'}
1034
- aria-labelledby="label"
1035
- part="listbox"
1036
- class="select__listbox ${this.searchEnabled
1037
- ? 'select__search-enabled '
1038
- : ''}"
1039
- tabindex="-1"
1040
- @mouseup=${this.handleOptionClick}
1041
- >
1042
- ${this.renderSearch()}
1043
- ${this.renderLoader()}
1044
- ${this.getVirtualizedContent()}
1045
- ${this.renderFooter()}
1046
- </div>
1047
- `;
1048
- }
1049
-
1050
- private renderSearch(): TemplateResult {
1051
- return this.searchEnabled
1052
- ? html`
1053
- <div class="select__search">
1054
- <nile-input
1055
- size="small"
1056
- clearable
1057
- .value=${this.searchValue}
1058
- placeholder="${this.internalSearchPlaceHolder}"
1059
- @nile-input=${this.handleSearchChange}
1060
- @nile-focus=${this.handleSearchFocus}
1061
- @nile-change="${this.onInputChange}"
1062
- >
1063
- <nile-icon name="search" slot="suffix"> </nile-icon>
1064
- </nile-input>
1065
- </div>
1066
- `
1067
- : html``;
1068
- }
1069
-
1070
- private renderLoader(): TemplateResult {
1071
- return this.optionsLoading
1072
- ? html`
1073
- <span class="select__loader">
1074
- <nile-icon
1075
- class="select__loader--icon"
1076
- name="button-loading-blue"
1077
- ></nile-icon>
1078
- </span>
1079
- `
1080
- : html``;
1081
- }
1082
-
1083
- private renderFooter(): TemplateResult {
1084
- return this.multiple
1085
- ? html`
1086
- <div
1087
- part="footer"
1088
- class="select__footer"
1089
- @click="${this.handleFooterClick}"
1090
- >
1091
- <span
1092
- @click="${this.toggleShowSelected}"
1093
- style="cursor: pointer;"
1094
- >
1095
- <nile-checkbox
1096
- ?disabled="${this.selectedOptions.length === 0}"
1097
- ?checked="${this.showSelected}"
1098
- >
1099
- &nbsp; Show Selected</nile-checkbox
1100
- >
1101
- </span>
1102
- ${this.selectedOptions.length !== 0
1103
- ? html`
1104
- <span
1105
- class="select__clear"
1106
- @click="${this.unSelectAll}"
1107
- >
1108
- Clear All
1109
- </span>
1110
- `
1111
- : ``}
1112
- </div>
1113
- `
1114
- : html``;
1115
- }
1116
-
1117
- private renderHelpText(hasHelpText: boolean, hasErrorMessage: boolean): TemplateResult {
1118
- return html`
1119
- ${hasHelpText
1120
- ? html` <nile-form-help-text>${this.helpText}</nile-form-help-text> `
1121
- : ``}
1122
- ${hasErrorMessage
1123
- ? html`
1124
- <nile-form-error-message
1125
- >${this.errorMessage}</nile-form-error-message
1126
- >
1127
- `
1128
- : ``}
1129
- `;
1130
- }
1131
-
1132
- getVirtualizedContent(): TemplateResult {
1133
- return VirtualSelectRenderer.getVirtualizedContent(
1134
- this.data,
1135
- this.searchEnabled,
1136
- this.renderItemFunction,
1137
- this.value,
1138
- this.multiple
1139
- );
1140
- }
1141
-
1142
- nileInput(value: any): void {
1143
- this.emit('nile-input', value);
1144
- }
1145
-
1146
- nileChange(value: any): void {
1147
- this.emit('nile-change', value);
1148
- }
1149
-
1150
- private updateValidity(): void {
1151
- this.updateComplete.then(() => {
1152
- this.formControlController.updateValidity();
1153
- });
1154
- }
1155
-
1156
- private calculateWidthOfSelectTagsDiv(): number | null {
1157
- if (this.shadowRoot) {
1158
- const selectTagsDiv = this.shadowRoot.querySelector('.select__tags') as HTMLElement;
1159
- if (selectTagsDiv) {
1160
- const width = selectTagsDiv.offsetWidth;
1161
- return width - 70;
1162
- }
1163
- }
1164
- return null;
1165
- }
1166
-
1167
- private calculateTotalWidthOfTags(): void {
1168
- if (this.maxOptionsVisible !== Infinity) {
1169
- this.oldMaxOptionsVisible = this.maxOptionsVisible;
1170
- }
1171
-
1172
- this.maxOptionsVisible = Infinity;
1173
- setTimeout(() => {
1174
- let widths: number[] = [];
1175
- if (this.shadowRoot) {
1176
- const tags = this.shadowRoot.querySelectorAll('nile-tag');
1177
- tags.forEach(tag => {
1178
- if (tag instanceof HTMLElement) {
1179
- widths.push(tag.offsetWidth);
1180
- }
1181
- });
1182
- }
1183
- if (this.value.length !== widths.length) {
1184
- return;
1185
- }
1186
-
1187
- let sum = widths.reduce(
1188
- (accumulator, currentValue) => accumulator + currentValue,
1189
- 0
1190
- );
1191
- const widthOfSelectTagsDiv = this.calculateWidthOfSelectTagsDiv();
1192
- if (!widthOfSelectTagsDiv) {
1193
- return;
1194
- }
1195
-
1196
- let summ = 0;
1197
- let lastindex = 0;
1198
-
1199
- for (let i = 0; i < widths.length; i++) {
1200
- summ += widths[i];
1201
-
1202
- if (summ > widthOfSelectTagsDiv) {
1203
- lastindex = i;
1204
- break;
1205
- }
1206
- }
1207
- this.maxOptionsVisible = lastindex;
1208
- }, 1);
1209
- }
1210
- }
1211
-
1212
- setDefaultAnimation('select.show', {
1213
- keyframes: [
1214
- { opacity: 0, scale: 0.9 },
1215
- { opacity: 1, scale: 1 },
1216
- ],
1217
- options: { duration: 100, easing: 'ease' },
1218
- });
1219
-
1220
- setDefaultAnimation('select.hide', {
1221
- keyframes: [
1222
- { opacity: 1, scale: 1 },
1223
- { opacity: 0, scale: 0.9 },
1224
- ],
1225
- options: { duration: 100, easing: 'ease' },
1226
- });
1227
-
1228
- export default NileVirtualSelect;
1229
-
1230
- declare global {
1231
- interface HTMLElementTagNameMap {
1232
- 'nile-virtual-select': NileVirtualSelect;
1233
- }
1234
- }