@aquera/nile-elements 0.1.50-beta-1.0 → 0.1.50

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