@aquera/nile-elements 0.1.73-beta-1.4 → 0.1.73-beta-1.5

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.
package/demo/index.html CHANGED
@@ -1,62 +1,54 @@
1
1
  <!DOCTYPE html>
2
2
  <html lang="en-GB">
3
- <head>
4
- <meta charset="utf-8" />
5
- <link rel="stylesheet" href="variables_v2.css" id="stylesheet" />
6
- <link rel="stylesheet" href="index.css" />
7
- <script type="module" src="index.js"></script>
8
- </head>
9
- <style>
10
- .flex-container {
11
- display: flex;
12
- flex-wrap: wrap;
13
- gap: 30px;
14
- padding: 0;
15
- margin: 0;
16
- border: 1px solid silver;
17
- height: 900px;
18
- }
19
3
 
20
- nile-button {
21
- flex: 0 0 auto;
22
- height: 38px;
23
- }
24
- </style>
4
+ <head>
5
+ <meta charset="utf-8" />
6
+ <link rel="stylesheet" href="variables_v2.css" id="stylesheet" />
7
+ <link rel="stylesheet" href="index.css" />
8
+ <script type="module" src="index.js"></script>
9
+ </head>
10
+ <style>
11
+ .flex-container {
12
+ display: flex;
13
+ flex-wrap: wrap;
14
+ gap: 30px;
15
+ padding: 0;
16
+ margin: 0;
17
+ border: 1px solid silver;
18
+ height: 900px;
19
+ }
25
20
 
26
- <body>
27
- <div style="padding: 30px">
28
- <nile-select placeholder="Please Select" searchEnabled enableVirtualScroll disableLocalSearch >
29
- </nile-select>
21
+ nile-button {
22
+ flex: 0 0 auto;
23
+ height: 38px;
24
+ }
25
+ </style>
30
26
 
31
-
27
+ <body>
28
+ <div>
29
+ <nile-virtual-select id="vselect" [data]="arrOptions" placeholder="Please Select" multiple="true">
30
+ </nile-virtual-select>
32
31
  </div>
33
32
 
34
33
  <script>
35
- let arrOptions = Array.from({ length: 1000 }, (_, i) => ({
34
+ const arrOptions = Array.from({ length: 1000 }, (_, i) => ({
36
35
  value: `option-${i + 1}`,
37
36
  label: `Option ${i + 1}`,
38
37
  }));
39
38
  document.addEventListener("DOMContentLoaded", ()=> {
40
- const nileSelect = document.querySelector('nile-select');
39
+ let nileVirtualSelect = document.querySelector('#vselect');
41
40
 
42
- nileSelect.data = arrOptions;
43
-
44
-
45
- // nileSelect.addEventListener('nile-scroll', (event)=> {
46
- // console.log("nile-select scroll event:", event.detail);
47
- // });
48
-
49
- nileSelect.addEventListener('nile-scroll-start', (event)=> {
50
- console.log("nile-select scroll START:", event.detail.scrollTop);
51
- });
52
-
53
- nileSelect.addEventListener('nile-scroll-end', (event)=> {
54
- console.log("nile-select scroll END (reached bottom):", event.detail.scrollTop);
55
- });
56
- });
41
+ // setTimeout(()=> {
42
+ // nileVirtualSelect = document.querySelector('#vselect');
43
+ nileVirtualSelect.value = ['option-3','option-5'];
44
+ // nileVirtualSelect.values = ['option-3','option-4'];
57
45
 
58
-
46
+ // }, 2000)
47
+
48
+ nileVirtualSelect.data = arrOptions;
49
+ });
59
50
  </script>
51
+ </body>
60
52
 
61
- </body>
62
53
  </html>
54
+
package/dist/index.js CHANGED
@@ -4350,7 +4350,7 @@ class Hi{constructor(e){this._element=null;const t=e??window;this._node=t,e&&(th
4350
4350
  >
4351
4351
  ${pe(a)}
4352
4352
  </nile-option>
4353
- `}static shouldUseVirtualizer(e){return e.length>=50}}let rN=class extends Pe{constructor(){super(...arguments),this.formControlController=new be(this,{assumeInteractionOn:["nile-blur","nile-input"]}),this.hasSlotController=new ve(this,"help-text","label"),this.hasFocus=!1,this.displayLabel="",this.selectedOptions=[],this.oldValue="",this.scrolling=!1,this.name="",this.data=[],this.originalOptionItems=[],this.value="",this.defaultValue="",this.size="medium",this.placeholder="Select...",this.searchValue="",this.searchEnabled=!1,this.internalSearchPlaceHolder="Search...",this.disableLocalSearch=!1,this.optionsLoading=!1,this.multiple=!1,this.helpText="",this.errorMessage="",this.warning=!1,this.error=!1,this.success=!1,this.disabled=!1,this.clearable=!1,this.open=!1,this.hoist=!1,this.filled=!1,this.pill=!1,this.label="",this.placement="bottom",this.form="",this.required=!1,this.showNoResults=!1,this.noResultsMessage="No results found",this.showSelected=!1,this.blockValueChange=!1,this.noWidthSync=!1,this.maxOptionsVisible=3,this.oldMaxOptionsVisible=1,this.handleDocumentMouseDown=e=>{if(!this.open)return;const t=e.composedPath(),M=t.includes(this),i=this.popup&&t.includes(this.popup);M||i||this.hide()}}get validity(){return this.valueInput?.validity}get validationMessage(){return this.valueInput?.validationMessage??""}connectedCallback(){super.connectedCallback(),this.initializeComponent(),this.setupEventListeners(),this.updateComplete.then((()=>{this.value&&this.data.length>0&&this.selectionChanged()}))}disconnectedCallback(){this.removeOpenListeners(),this.scrollTimeout&&(clearTimeout(this.scrollTimeout),this.scrollTimeout=void 0)}initializeComponent(){this.open=!1,this.emit("nile-init")}getDisplayText(e){return this.renderItemConfig?.getDisplayText?this.renderItemConfig.getDisplayText(e):e?.label||e?.name||e?.toString()||""}getItemValue(e){return this.renderItemConfig?.getValue?this.renderItemConfig.getValue(e):e?.value||e}getSearchText(e){return this.renderItemConfig?.getSearchText?this.renderItemConfig.getSearchText(e):this.getDisplayText(e)}setupEventListeners(){this.handleDocumentFocusIn=this.handleDocumentFocusIn.bind(this),this.handleDocumentKeyDown=this.handleDocumentKeyDown.bind(this),this.handleDocumentMouseDown=this.handleDocumentMouseDown.bind(this)}addOpenListeners(){document.addEventListener("focusin",this.handleDocumentFocusIn),document.addEventListener("keydown",this.handleDocumentKeyDown),document.addEventListener("mousedown",this.handleDocumentMouseDown)}removeOpenListeners(){document.removeEventListener("focusin",this.handleDocumentFocusIn),document.removeEventListener("keydown",this.handleDocumentKeyDown),document.removeEventListener("mousedown",this.handleDocumentMouseDown)}handleFocus(){this.hasFocus=!0,this.emit("nile-focus")}handleBlur(){this.hasFocus=!1,this.emit("nile-blur")}handleDocumentFocusIn(e){if(!this.open)return;const t=e.composedPath(),M=t.includes(this),i=this.popup&&t.includes(this.popup);M||i||this.hide()}handleDocumentKeyDown(e){this.shouldIgnoreKeyPress(e)||(this.isEscapeKey(e)&&this.handleEscapeKey(e),this.isEnterOrSpaceKey(e)&&this.handleEnterOrSpaceKey(e))}shouldIgnoreKeyPress(e){const t=e.target,M=null!==t.closest(".select__clear"),i=null!==t.closest("nile-icon-button");return M||i}isEscapeKey(e){return"Escape"===e.key&&this.open}handleEscapeKey(e){e.preventDefault(),e.stopPropagation(),this.hide(),this.displayInput.focus({preventScroll:!0})}isEnterOrSpaceKey(e){return"Enter"===e.key||" "===e.key}handleEnterOrSpaceKey(e){e.preventDefault(),e.stopImmediatePropagation(),this.open?this.multiple||(this.hide(),this.displayInput.focus({preventScroll:!0})):this.show()}handleFooterClick(e){e.stopPropagation(),e.preventDefault()}toggleShowSelected(e){if(e.stopPropagation(),e.preventDefault(),0!==this.selectedOptions?.length){if(this.showSelected=!this.showSelected,this.showSelected){const e=Array.isArray(this.value)?this.value:[this.value];this.data=this.originalOptionItems.filter((t=>e.includes(t.value)))}else this.data=[...this.originalOptionItems];this.requestUpdate(),this.resetScrollPosition()}}unSelectAll(){this.showSelected=!1,this.value=this.multiple?[]:"",this.data=[...this.originalOptionItems],this.selectionChanged(),this.emit("nile-change",{value:this.value,name:this.name}),this.emit("nile-clear",{value:this.multiple?this.value:"",name:this.name}),this.resetScrollPosition()}handleLabelClick(){this.displayInput.focus(),this.hide()}handleComboboxMouseDown(e){this.shouldIgnoreComboboxClick(e)||(e.preventDefault(),this.displayInput.focus({preventScroll:!0}),this.open=!this.open)}shouldIgnoreComboboxClick(e){const t=e.composedPath().some((e=>e instanceof Element&&"nile-icon-button"===e.tagName.toLowerCase()));return this.disabled||t}handleComboboxKeyDown(e){this.isEnterOrSpaceKey(e)&&(e.preventDefault(),this.open=!this.open)}handleClearClick(e){e.stopPropagation(),this.clearSelection()}clearSelection(){this.value,this.value=this.multiple?[]:"",this.selectionChanged(),this.updateComplete.then((()=>{this.nileInput({value:this.value,name:this.name}),this.nileChange({value:this.value,name:this.name}),this.emit("nile-clear")}))}handleClearMouseDown(e){e.stopPropagation()}handleOptionClick(e){const t=e.target.closest("nile-option");if(this.shouldBlockValueChange(t))return;const M=this.value;this.oldValue=M,t&&!t.disabled&&this.handleOptionSelection(t)}shouldBlockValueChange(e){return!(!this.blockValueChange||!e)&&(this.emit("nile-block-change",{value:e?.value,name:this.name}),this.hide(),!0)}handleOptionSelection(e){const t=e.value;this.multiple?this.toggleOptionSelection(t):this.setSelectedOptions(t),this.updateComplete.then((()=>this.displayInput.focus({preventScroll:!0}))),this.value!==this.oldValue&&this.updateComplete.then((()=>{this.nileInput({value:this.value,name:this.name}),this.nileChange({value:this.value,name:this.name})})),this.multiple||(this.hide(),this.displayInput.focus({preventScroll:!0}))}setSelectedOptions(e){this.value=e,this.selectionChanged()}toggleOptionSelection(e){const t=Array.isArray(this.value)?this.value:[];t.includes(e)?this.value=t.filter((t=>t!==e)):this.value=[...t,e],this.selectionChanged()}handleTagRemove(e,t){e.stopPropagation(),this.disabled||(this.removeTagFromSelection(t),this.emitTagRemovalEvent(t))}removeTagFromSelection(e){let t=this.value;Array.isArray(t)||(t=t?[t]:[]);const M=t.filter((t=>t!==e.value));this.value=M,this.selectionChanged()}emitTagRemovalEvent(e){this.updateComplete.then((()=>{this.nileInput({value:this.value,name:this.name}),this.nileChange({value:this.value,name:this.name}),this.emit("nile-tag-remove",{value:this.value,name:this.name,removedtagvalue:e.value})}))}selectionChanged(){const e=this.originalOptionItems.length>0?this.originalOptionItems:this.data;if(this.selectedOptions=ji.createVirtualOptionsFromValues(this.value,e,this.getDisplayText.bind(this),this.renderItemConfig?.getValue),this.multiple)this.placeholder&&0===this.value.length?this.displayLabel="":this.displayLabel=this.selectedOptions.length+" selected";else{const e=Array.isArray(this.value)?this.value[0]:this.value,t=this.selectedOptions[0]?.getTextLabel();this.displayLabel=t||(e??"")}this.updateValidity(),0===this.selectedOptions.length&&(this.showSelected=!1),this.calculateTotalWidthOfTags()}handleSearchFocus(){document.removeEventListener("keydown",this.handleDocumentKeyDown)}handleSearchBlur(){document.addEventListener("keydown",this.handleDocumentKeyDown)}handleSearchChange(e){this.searchValue=e.detail.value,this.emit("nile-search",{query:this.searchValue,name:this.name}),this.disableLocalSearch||(this.filterVirtualOptions(this.searchValue),this.resetScrollPosition())}handleScroll(e){const t=e.target;this.emit("nile-scroll",{scrollTop:t.scrollTop,scrollLeft:t.scrollLeft,name:this.name}),this.scrolling||(this.scrolling=!0,this.emit("nile-scroll-start",{scrollTop:t.scrollTop,scrollLeft:t.scrollLeft,name:this.name})),clearTimeout(this.scrollTimeout),this.scrollTimeout=window.setTimeout((()=>{this.scrolling&&(this.scrolling=!1)}),300);Math.ceil(t.scrollTop)>=Math.floor(t.scrollHeight-t.offsetHeight)&&this.emit("nile-scroll-end",{scrollTop:t.scrollTop,scrollLeft:t.scrollLeft,name:this.name,isAtBottom:!0})}filterVirtualOptions(e){const t=ci.filterVirtualOptions(e,this.originalOptionItems,this.data,this.getDisplayText.bind(this),this.renderItemConfig?.getSearchText);this.data=t.filteredItems,this.showNoResults=t.showNoResults,this.showSelected=!1,this.requestUpdate()}handleInvalid(e){this.formControlController.setValidity(!1),this.formControlController.emitInvalidEvent(e)}handleDisabledChange(){this.disabled&&(this.open=!1,this.handleOpenChange())}handleValueChange(){this.selectionChanged(),this.requestUpdate()}handleDataChange(){this.selectionChanged(),this.optionsLoading||0!==this.data.length?this.data.length>0&&(this.showNoResults=!1):this.showNoResults=!0,this.requestUpdate(),this.open&&this.resetScrollPosition()}handleRenderItemConfigChange(){this.value&&this.data.length>0&&(this.selectionChanged(),this.requestUpdate())}handleOptionsLoadingChange(){this.optionsLoading||0!==this.data.length||(this.showNoResults=!0),this.requestUpdate()}async handleOpenChange(){this.open&&!this.disabled?await this.handleOpen():await this.handleClose()}async handleOpen(){this.emit("nile-show",{value:this.value,name:this.name}),this.addOpenListeners(),this.showNoResults=!this.data?.length,await ct(this),this.popup.active=!0;const{keyframes:e,options:t}=yt(this,"select.show",{dir:"ltr"});await ut(this.popup.popup,e,t),this.initializeOriginalItems(),this.filterVirtualOptions(this.searchValue),this.resetScrollPosition(),this.emit("nile-after-show",{value:this.value,name:this.name})}async handleClose(){this.emit("nile-hide",{value:this.value,name:this.name}),this.removeOpenListeners(),await ct(this);const{keyframes:e,options:t}=yt(this,"select.hide",{dir:"ltr"});await ut(this.popup.popup,e,t),this.popup.active=!1,this.searchValue="",this.emit("nile-after-hide",{value:this.value,name:this.name})}initializeOriginalItems(){0===this.originalOptionItems.length&&this.data.length>0&&(this.originalOptionItems=[...this.data])}async show(){if(!this.open&&!this.disabled)return this.open=!0,St(this,"nile-after-show");this.open=!1}async hide(){if(this.open&&!this.disabled)return this.open=!1,St(this,"nile-after-hide");this.open=!1}checkValidity(){return this.valueInput.checkValidity()}getForm(){return this.formControlController.getForm()}reportValidity(){return this.valueInput.reportValidity()}setCustomValidity(e){this.valueInput.setCustomValidity(e),this.formControlController.updateValidity()}focus(e){this.displayInput.focus(e)}blur(){this.displayInput.blur()}onInputChange(e){e.stopPropagation()}render(){const e=this.hasSlotController.test("label");this.hasSlotController.test("help-text");const t=this.hasSlotController.test("label-suffix"),M=this.hasSlotController.test("custom-select"),i=!!this.label||!!e,N=this.clearable&&!this.disabled&&this.value.length>0,o=!!this.placeholder&&0===this.value.length,s=!!this.helpText,n=!!this.errorMessage;return R`
4353
+ `}static shouldUseVirtualizer(e){return e.length>=50}}let rN=class extends Pe{constructor(){super(...arguments),this.formControlController=new be(this,{assumeInteractionOn:["nile-blur","nile-input"]}),this.hasSlotController=new ve(this,"help-text","label"),this.hasFocus=!1,this.displayLabel="",this.selectedOptions=[],this.oldValue="",this.scrolling=!1,this.name="",this.data=[],this.originalOptionItems=[],this.value="",this.defaultValue="",this.size="medium",this.placeholder="Select...",this.searchValue="",this.searchEnabled=!1,this.internalSearchPlaceHolder="Search...",this.disableLocalSearch=!1,this.optionsLoading=!1,this.multiple=!1,this.helpText="",this.errorMessage="",this.warning=!1,this.error=!1,this.success=!1,this.disabled=!1,this.clearable=!1,this.open=!1,this.hoist=!1,this.filled=!1,this.pill=!1,this.label="",this.placement="bottom",this.form="",this.required=!1,this.showNoResults=!1,this.noResultsMessage="No results found",this.showSelected=!1,this.blockValueChange=!1,this.noWidthSync=!1,this.maxOptionsVisible=3,this.oldMaxOptionsVisible=1,this.handleDocumentMouseDown=e=>{if(!this.open)return;const t=e.composedPath(),M=t.includes(this),i=this.popup&&t.includes(this.popup);M||i||this.hide()}}get validity(){return this.valueInput?.validity}get validationMessage(){return this.valueInput?.validationMessage??""}connectedCallback(){super.connectedCallback(),this.initializeComponent(),this.setupEventListeners(),this.updateComplete.then((()=>{this.value&&this.data.length>0&&this.selectionChanged()}))}disconnectedCallback(){this.removeOpenListeners(),this.scrollTimeout&&(clearTimeout(this.scrollTimeout),this.scrollTimeout=void 0)}updated(e){e.has("value")&&this.selectionChanged()}initializeComponent(){this.open=!1,this.emit("nile-init")}getDisplayText(e){return this.renderItemConfig?.getDisplayText?this.renderItemConfig.getDisplayText(e):e?.label||e?.name||e?.toString()||""}getItemValue(e){return this.renderItemConfig?.getValue?this.renderItemConfig.getValue(e):e?.value||e}getSearchText(e){return this.renderItemConfig?.getSearchText?this.renderItemConfig.getSearchText(e):this.getDisplayText(e)}setupEventListeners(){this.handleDocumentFocusIn=this.handleDocumentFocusIn.bind(this),this.handleDocumentKeyDown=this.handleDocumentKeyDown.bind(this),this.handleDocumentMouseDown=this.handleDocumentMouseDown.bind(this)}addOpenListeners(){document.addEventListener("focusin",this.handleDocumentFocusIn),document.addEventListener("keydown",this.handleDocumentKeyDown),document.addEventListener("mousedown",this.handleDocumentMouseDown)}removeOpenListeners(){document.removeEventListener("focusin",this.handleDocumentFocusIn),document.removeEventListener("keydown",this.handleDocumentKeyDown),document.removeEventListener("mousedown",this.handleDocumentMouseDown)}handleFocus(){this.hasFocus=!0,this.emit("nile-focus")}handleBlur(){this.hasFocus=!1,this.emit("nile-blur")}handleDocumentFocusIn(e){if(!this.open)return;const t=e.composedPath(),M=t.includes(this),i=this.popup&&t.includes(this.popup);M||i||this.hide()}handleDocumentKeyDown(e){this.shouldIgnoreKeyPress(e)||(this.isEscapeKey(e)&&this.handleEscapeKey(e),this.isEnterOrSpaceKey(e)&&this.handleEnterOrSpaceKey(e))}shouldIgnoreKeyPress(e){const t=e.target,M=null!==t.closest(".select__clear"),i=null!==t.closest("nile-icon-button");return M||i}isEscapeKey(e){return"Escape"===e.key&&this.open}handleEscapeKey(e){e.preventDefault(),e.stopPropagation(),this.hide(),this.displayInput.focus({preventScroll:!0})}isEnterOrSpaceKey(e){return"Enter"===e.key||" "===e.key}handleEnterOrSpaceKey(e){e.preventDefault(),e.stopImmediatePropagation(),this.open?this.multiple||(this.hide(),this.displayInput.focus({preventScroll:!0})):this.show()}handleFooterClick(e){e.stopPropagation(),e.preventDefault()}toggleShowSelected(e){if(e.stopPropagation(),e.preventDefault(),0!==this.selectedOptions?.length){if(this.showSelected=!this.showSelected,this.showSelected){const e=Array.isArray(this.value)?this.value:[this.value];this.data=this.originalOptionItems.filter((t=>e.includes(t.value)))}else this.data=[...this.originalOptionItems];this.requestUpdate(),this.resetScrollPosition()}}unSelectAll(){this.showSelected=!1,this.value=this.multiple?[]:"",this.data=[...this.originalOptionItems],this.selectionChanged(),this.emit("nile-change",{value:this.value,name:this.name}),this.emit("nile-clear",{value:this.multiple?this.value:"",name:this.name}),this.resetScrollPosition()}handleLabelClick(){this.displayInput.focus(),this.hide()}handleComboboxMouseDown(e){this.shouldIgnoreComboboxClick(e)||(e.preventDefault(),this.displayInput.focus({preventScroll:!0}),this.open=!this.open)}shouldIgnoreComboboxClick(e){const t=e.composedPath().some((e=>e instanceof Element&&"nile-icon-button"===e.tagName.toLowerCase()));return this.disabled||t}handleComboboxKeyDown(e){this.isEnterOrSpaceKey(e)&&(e.preventDefault(),this.open=!this.open)}handleClearClick(e){e.stopPropagation(),this.clearSelection()}clearSelection(){this.value,this.value=this.multiple?[]:"",this.selectionChanged(),this.updateComplete.then((()=>{this.nileInput({value:this.value,name:this.name}),this.nileChange({value:this.value,name:this.name}),this.emit("nile-clear")}))}handleClearMouseDown(e){e.stopPropagation()}handleOptionClick(e){const t=e.target.closest("nile-option");if(this.shouldBlockValueChange(t))return;const M=this.value;this.oldValue=M,t&&!t.disabled&&this.handleOptionSelection(t)}shouldBlockValueChange(e){return!(!this.blockValueChange||!e)&&(this.emit("nile-block-change",{value:e?.value,name:this.name}),this.hide(),!0)}handleOptionSelection(e){const t=e.value;this.multiple?this.toggleOptionSelection(t):this.setSelectedOptions(t),this.updateComplete.then((()=>this.displayInput.focus({preventScroll:!0}))),this.value!==this.oldValue&&this.updateComplete.then((()=>{this.nileInput({value:this.value,name:this.name}),this.nileChange({value:this.value,name:this.name})})),this.multiple||(this.hide(),this.displayInput.focus({preventScroll:!0}))}setSelectedOptions(e){this.value=e,this.selectionChanged()}toggleOptionSelection(e){const t=Array.isArray(this.value)?this.value:[];t.includes(e)?this.value=t.filter((t=>t!==e)):this.value=[...t,e],this.selectionChanged()}handleTagRemove(e,t){e.stopPropagation(),this.disabled||(this.removeTagFromSelection(t),this.emitTagRemovalEvent(t))}removeTagFromSelection(e){let t=this.value;Array.isArray(t)||(t=t?[t]:[]);const M=t.filter((t=>t!==e.value));this.value=M,this.selectionChanged()}emitTagRemovalEvent(e){this.updateComplete.then((()=>{this.nileInput({value:this.value,name:this.name}),this.nileChange({value:this.value,name:this.name}),this.emit("nile-tag-remove",{value:this.value,name:this.name,removedtagvalue:e.value})}))}selectionChanged(){const e=this.originalOptionItems.length>0?this.originalOptionItems:this.data;if(this.selectedOptions=ji.createVirtualOptionsFromValues(this.value,e,this.getDisplayText.bind(this),this.renderItemConfig?.getValue),this.multiple)this.placeholder&&0===this.value.length?this.displayLabel="":this.displayLabel=this.selectedOptions.length+" selected";else{const e=Array.isArray(this.value)?this.value[0]:this.value,t=this.selectedOptions[0]?.getTextLabel();this.displayLabel=t||(e??"")}this.updateValidity(),0===this.selectedOptions.length&&(this.showSelected=!1),this.calculateTotalWidthOfTags()}handleSearchFocus(){document.removeEventListener("keydown",this.handleDocumentKeyDown)}handleSearchBlur(){document.addEventListener("keydown",this.handleDocumentKeyDown)}handleSearchChange(e){this.searchValue=e.detail.value,this.emit("nile-search",{query:this.searchValue,name:this.name}),this.disableLocalSearch||(this.filterVirtualOptions(this.searchValue),this.resetScrollPosition())}handleScroll(e){const t=e.target;this.emit("nile-scroll",{scrollTop:t.scrollTop,scrollLeft:t.scrollLeft,name:this.name}),this.scrolling||(this.scrolling=!0,this.emit("nile-scroll-start",{scrollTop:t.scrollTop,scrollLeft:t.scrollLeft,name:this.name})),clearTimeout(this.scrollTimeout),this.scrollTimeout=window.setTimeout((()=>{this.scrolling&&(this.scrolling=!1)}),300);Math.ceil(t.scrollTop)>=Math.floor(t.scrollHeight-t.offsetHeight)&&this.emit("nile-scroll-end",{scrollTop:t.scrollTop,scrollLeft:t.scrollLeft,name:this.name,isAtBottom:!0})}filterVirtualOptions(e){const t=ci.filterVirtualOptions(e,this.originalOptionItems,this.data,this.getDisplayText.bind(this),this.renderItemConfig?.getSearchText);this.data=t.filteredItems,this.showNoResults=t.showNoResults,this.showSelected=!1,this.requestUpdate()}handleInvalid(e){this.formControlController.setValidity(!1),this.formControlController.emitInvalidEvent(e)}handleDisabledChange(){this.disabled&&(this.open=!1,this.handleOpenChange())}handleValueChange(){this.selectionChanged(),this.requestUpdate()}handleDataChange(){this.selectionChanged(),this.optionsLoading||0!==this.data.length?this.data.length>0&&(this.showNoResults=!1):this.showNoResults=!0,this.requestUpdate(),this.open&&this.resetScrollPosition()}handleRenderItemConfigChange(){this.value&&this.data.length>0&&(this.selectionChanged(),this.requestUpdate())}handleOptionsLoadingChange(){this.optionsLoading||0!==this.data.length||(this.showNoResults=!0),this.requestUpdate()}async handleOpenChange(){this.open&&!this.disabled?await this.handleOpen():await this.handleClose()}async handleOpen(){this.emit("nile-show",{value:this.value,name:this.name}),this.addOpenListeners(),this.showNoResults=!this.data?.length,await ct(this),this.popup.active=!0;const{keyframes:e,options:t}=yt(this,"select.show",{dir:"ltr"});await ut(this.popup.popup,e,t),this.initializeOriginalItems(),this.filterVirtualOptions(this.searchValue),this.resetScrollPosition(),this.emit("nile-after-show",{value:this.value,name:this.name})}async handleClose(){this.emit("nile-hide",{value:this.value,name:this.name}),this.removeOpenListeners(),await ct(this);const{keyframes:e,options:t}=yt(this,"select.hide",{dir:"ltr"});await ut(this.popup.popup,e,t),this.popup.active=!1,this.searchValue="",this.emit("nile-after-hide",{value:this.value,name:this.name})}initializeOriginalItems(){0===this.originalOptionItems.length&&this.data.length>0&&(this.originalOptionItems=[...this.data])}async show(){if(!this.open&&!this.disabled)return this.open=!0,St(this,"nile-after-show");this.open=!1}async hide(){if(this.open&&!this.disabled)return this.open=!1,St(this,"nile-after-hide");this.open=!1}checkValidity(){return this.valueInput.checkValidity()}getForm(){return this.formControlController.getForm()}reportValidity(){return this.valueInput.reportValidity()}setCustomValidity(e){this.valueInput.setCustomValidity(e),this.formControlController.updateValidity()}focus(e){this.displayInput.focus(e)}blur(){this.displayInput.blur()}onInputChange(e){e.stopPropagation()}render(){const e=this.hasSlotController.test("label");this.hasSlotController.test("help-text");const t=this.hasSlotController.test("label-suffix"),M=this.hasSlotController.test("custom-select"),i=!!this.label||!!e,N=this.clearable&&!this.disabled&&this.value.length>0,o=!!this.placeholder&&0===this.value.length,s=!!this.helpText,n=!!this.errorMessage;return R`
4354
4354
  <div
4355
4355
  part="form-control"
4356
4356
  class=${Le({"form-control":!0,"form-control--small":"small"===this.size,"form-control--medium":"medium"===this.size,"form-control--large":"large"===this.size,"form-control--has-label":i,"form-control--has-help-text":s})}