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