@aquera/nile-elements 0.1.24 → 0.1.25

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 (34) hide show
  1. package/README.md +4 -0
  2. package/dist/{angular-ts-a62c12b7.cjs.js → angular-ts-5f927069.cjs.js} +2 -2
  3. package/dist/{angular-ts-a62c12b7.cjs.js.map → angular-ts-5f927069.cjs.js.map} +1 -1
  4. package/dist/index.cjs.js +1 -1
  5. package/dist/index.esm.js +1 -1
  6. package/dist/nile-auto-complete/index.cjs.js +1 -1
  7. package/dist/nile-auto-complete/index.esm.js +1 -1
  8. package/dist/nile-auto-complete/nile-auto-complete.cjs.js +5 -13
  9. package/dist/nile-auto-complete/nile-auto-complete.cjs.js.map +1 -1
  10. package/dist/nile-auto-complete/nile-auto-complete.css.cjs.js +1 -1
  11. package/dist/nile-auto-complete/nile-auto-complete.css.cjs.js.map +1 -1
  12. package/dist/nile-auto-complete/nile-auto-complete.css.esm.js +6 -4
  13. package/dist/nile-auto-complete/nile-auto-complete.esm.js +9 -22
  14. package/dist/nile-auto-complete/nile-auto-complete.test.cjs.js +1 -1
  15. package/dist/nile-auto-complete/nile-auto-complete.test.cjs.js.map +1 -1
  16. package/dist/nile-auto-complete/nile-auto-complete.test.esm.js +1 -1
  17. package/dist/nile-chip/nile-chip.cjs.js.map +1 -1
  18. package/dist/nile-chip/nile-chip.test.cjs.js +1 -1
  19. package/dist/nile-chip/nile-chip.test.cjs.js.map +1 -1
  20. package/dist/nile-chip/nile-chip.test.esm.js +1 -1
  21. package/dist/nile-highlighter/nile-highlighter.cjs.js +1 -1
  22. package/dist/src/nile-auto-complete/nile-auto-complete.css.js +6 -4
  23. package/dist/src/nile-auto-complete/nile-auto-complete.css.js.map +1 -1
  24. package/dist/src/nile-auto-complete/nile-auto-complete.d.ts +4 -3
  25. package/dist/src/nile-auto-complete/nile-auto-complete.js +35 -11
  26. package/dist/src/nile-auto-complete/nile-auto-complete.js.map +1 -1
  27. package/dist/src/nile-chip/nile-chip.d.ts +2 -2
  28. package/dist/src/nile-chip/nile-chip.js.map +1 -1
  29. package/dist/tsconfig.tsbuildinfo +1 -1
  30. package/package.json +1 -1
  31. package/src/nile-auto-complete/nile-auto-complete.css.ts +6 -4
  32. package/src/nile-auto-complete/nile-auto-complete.ts +37 -13
  33. package/src/nile-chip/nile-chip.ts +2 -2
  34. package/vscode-html-custom-data.json +6 -1
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "description": "Webcomponent nile-elements following open-wc recommendations",
4
4
  "license": "MIT",
5
5
  "author": "nile-elements",
6
- "version": "0.1.24",
6
+ "version": "0.1.25",
7
7
  "main": "dist/src/index.js",
8
8
  "type": "module",
9
9
  "module": "dist/src/index.js",
@@ -12,18 +12,20 @@ import { css } from 'lit';
12
12
  */
13
13
  export const styles = css`
14
14
  :host {
15
- --virtual-scroll-container-width:100px;
15
+ --virtual-scroll-container-width:110px;
16
+ --virtual-scroll-container-height:200px;
16
17
  }
17
18
 
18
19
  .nile-dropdown--input {
19
20
  width: 100%;
20
21
  }
21
22
 
22
- .nile-dropdown--input lit-virtualizer{
23
- min-width: var(--virtual-scroll-container-width)!important;
23
+ .virtualized__menu{
24
+ min-width: var(--virtual-scroll-container-width);
25
+ min-height: var(--virtual-scroll-container-height) !important;
24
26
  }
25
27
 
26
- .nile-dropdown--input nile-menu-item{
28
+ .virtualized__menu nile-menu-item{
27
29
  width:100%;
28
30
  }
29
31
 
@@ -10,7 +10,8 @@ import { styles } from './nile-auto-complete.css';
10
10
  import NileElement from '../internal/nile-element';
11
11
  import type { CSSResultGroup, PropertyValues } from 'lit';
12
12
  import { NileDropdown } from '../nile-dropdown';
13
- import '@lit-labs/virtualizer';
13
+
14
+ import { virtualize } from '@lit-labs/virtualizer/virtualize.js';
14
15
 
15
16
  // Define the custom element 'nile-auto-complete'
16
17
  @customElement('nile-auto-complete')
@@ -22,6 +23,8 @@ export class NileAutoComplete extends NileElement {
22
23
 
23
24
  // Define component properties
24
25
 
26
+ @property({ type: Boolean }) disabled: boolean = false;
27
+
25
28
  @property({ type: Boolean }) isDropdownOpen: boolean = false;
26
29
 
27
30
  @property({ type: Boolean }) enableVirtualScroll: boolean = false;
@@ -36,9 +39,9 @@ export class NileAutoComplete extends NileElement {
36
39
 
37
40
  @property({ type: Boolean }) loading: boolean = false;
38
41
 
39
- @property({ attribute:false}) filterFunction: any = (item:string,searchedValue:string)=>item.toLowerCase().includes(searchedValue.toLowerCase());
42
+ @property({ attribute:false}) filterFunction: (item:string,searchedValue:string)=>boolean=(item:string,searchedValue:string)=>item.toLowerCase().includes(searchedValue.toLowerCase());
40
43
 
41
- @property({ attribute:false}) renderItemFunction: any = (item:any)=>item;
44
+ @property({ attribute:false}) renderItemFunction: (item:any)=>string = (item:any)=>item;
42
45
 
43
46
  @property({ type: Array }) allMenuItems: any = [];
44
47
 
@@ -46,13 +49,19 @@ export class NileAutoComplete extends NileElement {
46
49
 
47
50
  connectedCallback() {
48
51
  super.connectedCallback();
49
- this.menuItems = [...this.allMenuItems];
52
+ this.renderItemFunction=(item:any)=>item;
50
53
  }
51
54
 
52
55
  protected updated(changedProperties: PropertyValues): void {
53
56
  super.updated(changedProperties);
54
- if (changedProperties.has('allMenuItems')) this.menuItems = [...this.allMenuItems];
57
+ if (changedProperties.has('allMenuItems')){
58
+ this.menuItems = this.applyFilter(this.allMenuItems,this.filterFunction);
59
+ this.setVirtualMenuWidth();
60
+ }
55
61
  if (changedProperties.has('isDropdownOpen')) this.menuItems = this.applyFilter(this.allMenuItems,this.filterFunction);
62
+ if (changedProperties.has('value')){
63
+ this.menuItems = this.applyFilter(this.allMenuItems,this.filterFunction);
64
+ }
56
65
  }
57
66
 
58
67
  public render(): TemplateResult {
@@ -61,6 +70,7 @@ export class NileAutoComplete extends NileElement {
61
70
  <nile-dropdown class="nile-dropdown--input" ?open=${this.isDropdownOpen} noOpenOnCLick>
62
71
  <nile-input class="nile-auto-complete--input"
63
72
  ?no-border=${this.noBorder}
73
+ .disabled=${this.disabled}
64
74
  .value=${this.value}
65
75
  @nile-input=${this.handleSearch}
66
76
  @focus=${this.handleFocus}
@@ -79,11 +89,12 @@ export class NileAutoComplete extends NileElement {
79
89
 
80
90
  getVirtualizedContent():TemplateResult{
81
91
  return html`
82
- <nile-menu @nile-select=${this.handleSelect} id="content-menu" exportparts="menu__items-wrapper:options__wrapper">
83
- <lit-virtualizer
84
- .items=${this.menuItems}
85
- .renderItem=${(item:any):TemplateResult=>this.getItemRenderFunction(item)}
86
- ></lit-virtualizer>
92
+ <nile-menu class="virtualized__menu" @nile-select=${this.handleSelect} id="content-menu" exportparts="menu__items-wrapper:options__wrapper">
93
+ ${virtualize({
94
+ items: this.menuItems,
95
+ renderItem: (item:any):TemplateResult=>this.getItemRenderFunction(item),
96
+ scroller:true
97
+ })}
87
98
  </nile-menu>
88
99
  `
89
100
  }
@@ -107,13 +118,25 @@ export class NileAutoComplete extends NileElement {
107
118
  private handleSelect(event: CustomEvent) {
108
119
  this.value = event.detail.value;
109
120
  this.emit('nile-complete', { value: event.detail.value });
121
+ this.emit('nile-input', { value: event.detail.value });
110
122
  this.isDropdownOpen = false;
111
123
  this.dropdownElement?.hide();
112
124
  }
113
125
 
126
+ private setVirtualMenuWidth() {
127
+ const maxLengthOption = this.menuItems
128
+ .reduce((acc: number, curr: any) => {
129
+ const currLength = this.renderItemFunction(curr).length
130
+ return acc > currLength ? acc : currLength
131
+ }, 0)
132
+ const defaultWith = 110;
133
+ const pixelMultiplier = 9.5;
134
+ const menuWidth = maxLengthOption * pixelMultiplier < defaultWith ? defaultWith : maxLengthOption * pixelMultiplier;
135
+ this.style.setProperty("--virtual-scroll-container-width", menuWidth + "px");
136
+ }
137
+
114
138
  private handleSearch(event: CustomEvent) {
115
- const searchValue = event.detail.value.toLowerCase();
116
- this.value = searchValue;
139
+ this.value = event.detail.value.toLowerCase();
117
140
 
118
141
  // Filter menu items based on the search value
119
142
  this.menuItems = this.applyFilter(this.allMenuItems,this.filterFunction);
@@ -140,6 +163,7 @@ export class NileAutoComplete extends NileElement {
140
163
  }
141
164
 
142
165
  applyFilter<T>(list: T[], filterFn: (item: T,searchValue?:string) => boolean): T[] {
166
+ if(typeof(list)!=='object') return []
143
167
  const res:T[]=[]
144
168
  list.forEach( el=> filterFn(el,this.value) && res.push(el) )
145
169
  return res
@@ -153,4 +177,4 @@ declare global {
153
177
  interface HTMLElementTagNameMap {
154
178
  'nile-auto-complete': NileAutoComplete;
155
179
  }
156
- }
180
+ }
@@ -93,9 +93,9 @@ export class NileChip extends NileElement {
93
93
 
94
94
  @property({ attribute: 'error-message', reflect: true }) errorMessage = '';
95
95
 
96
- @property({ attribute:false}) filterFunction: any = (item:string,searchedValue:string)=>item.toLowerCase().includes(searchedValue.toLowerCase());
96
+ @property({ attribute:false}) filterFunction: (item:string,searchedValue:string)=>boolean = (item:string,searchedValue:string)=>item.toLowerCase().includes(searchedValue.toLowerCase());
97
97
 
98
- @property({ attribute:false}) renderItemFunction: any = (item:any)=>item;
98
+ @property({ attribute:false}) renderItemFunction: (item:any)=>string = (item:any)=>item;
99
99
 
100
100
  protected updated(changedProperties: PropertyValues): void {
101
101
  super.updated(changedProperties);
@@ -62,8 +62,13 @@
62
62
  },
63
63
  {
64
64
  "name": "nile-auto-complete",
65
- "description": "Attributes:\n\n * `isDropdownOpen` {`boolean`} - \n\n * `enableVirtualScroll` {`boolean`} - \n\n * `openOnFocus` {`boolean`} - \n\n * `value` {`string`} - \n\n * `placeholder` {`string`} - \n\n * `noBorder` {`boolean`} - \n\n * `loading` {`boolean`} - \n\n * `allMenuItems` - \n\nProperties:\n\n * `styles` - \n\n * `dropdownElement` - \n\n * `isDropdownOpen` {`boolean`} - \n\n * `enableVirtualScroll` {`boolean`} - \n\n * `openOnFocus` {`boolean`} - \n\n * `value` {`string`} - \n\n * `placeholder` {`string`} - \n\n * `noBorder` {`boolean`} - \n\n * `loading` {`boolean`} - \n\n * `filterFunction` - \n\n * `renderItemFunction` - \n\n * `allMenuItems` - \n\n * `menuItems` - \n\n * `BUBBLES` {`boolean`} - \n\n * `COMPOSED` {`boolean`} - \n\n * `CANCELABLE` {`boolean`} - ",
65
+ "description": "Attributes:\n\n * `disabled` {`boolean`} - \n\n * `isDropdownOpen` {`boolean`} - \n\n * `enableVirtualScroll` {`boolean`} - \n\n * `openOnFocus` {`boolean`} - \n\n * `value` {`string`} - \n\n * `placeholder` {`string`} - \n\n * `noBorder` {`boolean`} - \n\n * `loading` {`boolean`} - \n\n * `allMenuItems` - \n\nProperties:\n\n * `styles` - \n\n * `dropdownElement` - \n\n * `disabled` {`boolean`} - \n\n * `isDropdownOpen` {`boolean`} - \n\n * `enableVirtualScroll` {`boolean`} - \n\n * `openOnFocus` {`boolean`} - \n\n * `value` {`string`} - \n\n * `placeholder` {`string`} - \n\n * `noBorder` {`boolean`} - \n\n * `loading` {`boolean`} - \n\n * `filterFunction` - \n\n * `renderItemFunction` - \n\n * `allMenuItems` - \n\n * `menuItems` - \n\n * `BUBBLES` {`boolean`} - \n\n * `COMPOSED` {`boolean`} - \n\n * `CANCELABLE` {`boolean`} - ",
66
66
  "attributes": [
67
+ {
68
+ "name": "disabled",
69
+ "description": "`disabled` {`boolean`} - \n\nProperty: disabled\n\nDefault: false",
70
+ "valueSet": "v"
71
+ },
67
72
  {
68
73
  "name": "isDropdownOpen",
69
74
  "description": "`isDropdownOpen` {`boolean`} - \n\nProperty: isDropdownOpen\n\nDefault: false",