@aquera/nile-elements 0.1.21 → 0.1.23

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 (54) hide show
  1. package/README.md +9 -0
  2. package/dist/flow-8340c041.esm.js +16 -0
  3. package/dist/flow-d0fa8803.cjs.js +14 -0
  4. package/dist/flow-d0fa8803.cjs.js.map +1 -0
  5. package/dist/index.cjs.js +1 -1
  6. package/dist/index.esm.js +1 -1
  7. package/dist/nile-auto-complete/index.cjs.js +1 -1
  8. package/dist/nile-auto-complete/index.esm.js +1 -1
  9. package/dist/nile-auto-complete/nile-auto-complete.cjs.js +25 -1
  10. package/dist/nile-auto-complete/nile-auto-complete.cjs.js.map +1 -1
  11. package/dist/nile-auto-complete/nile-auto-complete.css.cjs.js +1 -1
  12. package/dist/nile-auto-complete/nile-auto-complete.css.cjs.js.map +1 -1
  13. package/dist/nile-auto-complete/nile-auto-complete.css.esm.js +11 -2
  14. package/dist/nile-auto-complete/nile-auto-complete.esm.js +50 -10
  15. package/dist/nile-auto-complete/nile-auto-complete.test.cjs.js +1 -1
  16. package/dist/nile-auto-complete/nile-auto-complete.test.cjs.js.map +1 -1
  17. package/dist/nile-auto-complete/nile-auto-complete.test.esm.js +5 -5
  18. package/dist/nile-chip/index.cjs.js +1 -1
  19. package/dist/nile-chip/index.esm.js +1 -1
  20. package/dist/nile-chip/nile-chip.cjs.js +1 -1
  21. package/dist/nile-chip/nile-chip.cjs.js.map +1 -1
  22. package/dist/nile-chip/nile-chip.esm.js +7 -5
  23. package/dist/nile-chip/nile-chip.test.cjs.js +1 -1
  24. package/dist/nile-chip/nile-chip.test.cjs.js.map +1 -1
  25. package/dist/nile-chip/nile-chip.test.esm.js +1 -1
  26. package/dist/nile-radio-group/nile-radio-group.css.cjs.js +1 -1
  27. package/dist/nile-radio-group/nile-radio-group.css.cjs.js.map +1 -1
  28. package/dist/nile-radio-group/nile-radio-group.css.esm.js +1 -1
  29. package/dist/nile-slide-toggle/nile-slide-toggle.css.cjs.js +1 -1
  30. package/dist/nile-slide-toggle/nile-slide-toggle.css.cjs.js.map +1 -1
  31. package/dist/nile-slide-toggle/nile-slide-toggle.css.esm.js +7 -2
  32. package/dist/src/nile-auto-complete/nile-auto-complete.css.js +9 -0
  33. package/dist/src/nile-auto-complete/nile-auto-complete.css.js.map +1 -1
  34. package/dist/src/nile-auto-complete/nile-auto-complete.d.ts +10 -5
  35. package/dist/src/nile-auto-complete/nile-auto-complete.js +63 -44
  36. package/dist/src/nile-auto-complete/nile-auto-complete.js.map +1 -1
  37. package/dist/src/nile-chip/nile-chip.d.ts +7 -5
  38. package/dist/src/nile-chip/nile-chip.js +83 -78
  39. package/dist/src/nile-chip/nile-chip.js.map +1 -1
  40. package/dist/src/nile-radio-group/nile-radio-group.css.js +1 -1
  41. package/dist/src/nile-radio-group/nile-radio-group.css.js.map +1 -1
  42. package/dist/src/nile-slide-toggle/nile-slide-toggle.css.js +5 -0
  43. package/dist/src/nile-slide-toggle/nile-slide-toggle.css.js.map +1 -1
  44. package/dist/tsconfig.tsbuildinfo +1 -1
  45. package/dist/watch.cjs.js +1 -1
  46. package/dist/watch.cjs.js.map +1 -1
  47. package/dist/watch.esm.js +1 -1
  48. package/package.json +3 -2
  49. package/src/nile-auto-complete/nile-auto-complete.css.ts +9 -0
  50. package/src/nile-auto-complete/nile-auto-complete.ts +61 -44
  51. package/src/nile-chip/nile-chip.ts +100 -95
  52. package/src/nile-radio-group/nile-radio-group.css.ts +1 -1
  53. package/src/nile-slide-toggle/nile-slide-toggle.css.ts +5 -0
  54. package/vscode-html-custom-data.json +12 -2
package/dist/watch.cjs.js CHANGED
@@ -1,2 +1,2 @@
1
- System.register([],function(_export,_context){"use strict";function _typeof(o){"@babel/helpers - typeof";return _typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(o){return typeof o;}:function(o){return o&&"function"==typeof Symbol&&o.constructor===Symbol&&o!==Symbol.prototype?"symbol":typeof o;},_typeof(o);}function ownKeys(e,r){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);r&&(o=o.filter(function(r){return Object.getOwnPropertyDescriptor(e,r).enumerable;})),t.push.apply(t,o);}return t;}function _objectSpread(e){for(var r=1;r<arguments.length;r++){var t=null!=arguments[r]?arguments[r]:{};r%2?ownKeys(Object(t),!0).forEach(function(r){_defineProperty(e,r,t[r]);}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):ownKeys(Object(t)).forEach(function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(t,r));});}return e;}function _defineProperty(e,r,t){return(r=_toPropertyKey(r))in e?Object.defineProperty(e,r,{value:t,enumerable:!0,configurable:!0,writable:!0}):e[r]=t,e;}function _toPropertyKey(t){var i=_toPrimitive(t,"string");return"symbol"==_typeof(i)?i:i+"";}function _toPrimitive(t,r){if("object"!=_typeof(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var i=e.call(t,r||"default");if("object"!=_typeof(i))return i;throw new TypeError("@@toPrimitive must return a primitive value.");}return("string"===r?String:Number)(t);}function t(t,i){var n=_objectSpread({waitUntilFirstUpdate:!1},i);return function(i,s){var o=i.update,c=Array.isArray(t)?t:[t];i.update=function(t){var _this=this;c.forEach(function(i){var o=i;if(t.has(o)){var _i=t.get(o),_c=_this[o];_i!==_c&&(n.waitUntilFirstUpdate&&!_this.hasUpdated||_this[s](_i,_c));}}),o.call(this,t);};};}_export("w",t);return{setters:[],execute:function execute(){}};});
1
+ System.register([],function(_export,_context){"use strict";return{setters:[],execute:function execute(){}};});
2
2
  //# sourceMappingURL=watch.cjs.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"watch.cjs.js","sources":["../../src/watch.ts"],"sourcesContent":["import type { LitElement } from 'lit';\n\ntype UpdateHandler = (prev?: unknown, next?: unknown) => void;\n\ntype NonUndefined<A> = A extends undefined ? never : A;\n\ntype UpdateHandlerFunctionKeys<T extends object> = {\n [K in keyof T]-?: NonUndefined<T[K]> extends UpdateHandler ? K : never;\n}[keyof T];\n\ninterface WatchOptions {\n /**\n * If true, will only start watching after the initial update/render\n */\n waitUntilFirstUpdate?: boolean;\n}\n\n/**\n * Runs when observed properties change, e.g. @property or @state, but before the component updates. To wait for an\n * update to complete after a change occurs, use `await this.updateComplete` in the handler. To start watching after the\n * initial update/render, use `{ waitUntilFirstUpdate: true }` or `this.hasUpdated` in the handler.\n *\n * Usage:\n *\n * @watch('propName')\n * handlePropChange(oldValue, newValue) {\n * ...\n * }\n */\nexport function watch(propertyName: string | string[], options?: WatchOptions) {\n const resolvedOptions: Required<WatchOptions> = {\n waitUntilFirstUpdate: false,\n ...options\n };\n return <ElemClass extends LitElement>(proto: ElemClass, decoratedFnName: UpdateHandlerFunctionKeys<ElemClass>) => {\n // @ts-expect-error - update is a protected property\n const { update } = proto;\n const watchedProperties = Array.isArray(propertyName) ? propertyName : [propertyName];\n\n // @ts-expect-error - update is a protected property\n proto.update = function (this: ElemClass, changedProps: Map<keyof ElemClass, ElemClass[keyof ElemClass]>) {\n watchedProperties.forEach(property => {\n const key = property as keyof ElemClass;\n if (changedProps.has(key)) {\n const oldValue = changedProps.get(key);\n const newValue = this[key];\n\n if (oldValue !== newValue) {\n if (!resolvedOptions.waitUntilFirstUpdate || this.hasUpdated) {\n (this[decoratedFnName] as unknown as UpdateHandler)(oldValue, newValue);\n }\n }\n }\n });\n\n update.call(this, changedProps);\n };\n };\n}\n"],"names":["watch","propertyName","options","resolvedOptions","_objectSpread","waitUntilFirstUpdate","proto","decoratedFnName","update","watchedProperties","Array","isArray","changedProps","forEach","property","key","has","oldValue","get","newValue","this","hasUpdated","call"],"mappings":"u8CA6BgB,QAAAA,CAAAA,CAAMC,CAAAA,CAAAA,CAAiCC,CACrD,CAAA,CAAA,GAAMC,CAAAA,CAA0C,CAAAC,aAAA,EAC9CC,oBAAsB,CAAA,CAAA,CAAA,EACnBH,CAEL,CAAA,CAAA,MAAO,UAA+BI,CAAAA,CAAkBC,GAEhDC,GAAEA,CAAAA,CAAWF,CAAAA,CAAAA,CAAbE,MAAAA,CACAC,CAAoBC,CAAAA,KAAAA,CAAMC,OAAQV,CAAAA,CAAAA,CAAAA,CAAgBA,CAAe,CAAA,CAACA,CAGxEK,CAAAA,CAAAA,CAAAA,CAAME,MAAS,CAAA,SAA2BI,CACxCH,CAAAA,KAAAA,KAAAA,MAAAA,CAAAA,CAAkBI,QAAQC,SAAAA,CACxB,CAAA,CAAA,GAAMC,CAAAA,CAAMD,CAAAA,CAAAA,CACZ,GAAIF,CAAAA,CAAaI,GAAID,CAAAA,CAAAA,CAAAA,CAAM,CACzB,GAAME,CAAAA,EAAWL,CAAAA,CAAAA,CAAaM,GAAIH,CAAAA,CAAAA,CAAAA,CAC5BI,EAAWC,CAAAA,KAAAA,CAAKL,GAElBE,EAAaE,GAAAA,EAAAA,GACVhB,CAAgBE,CAAAA,oBAAAA,EAAAA,CAAwBe,KAAKC,CAAAA,UAAAA,EAC/CD,KAAKb,CAAAA,CAAAA,CAAAA,CAA8CU,EAAUE,CAAAA,EAAAA,CAAAA,CAGnE,EAGHX,CAAAA,CAAAA,CAAAA,CAAAA,CAAOc,IAAKF,CAAAA,IAAAA,CAAMR,CACpB,CAAA,EAAC,EAEL"}
1
+ {"version":3,"file":"watch.cjs.js","sources":[],"sourcesContent":[],"names":[],"mappings":""}
package/dist/watch.esm.js CHANGED
@@ -1 +1 @@
1
- function t(t,i){const n={waitUntilFirstUpdate:!1,...i};return(i,s)=>{const{update:o}=i,c=Array.isArray(t)?t:[t];i.update=function(t){c.forEach((i=>{const o=i;if(t.has(o)){const i=t.get(o),c=this[o];i!==c&&(n.waitUntilFirstUpdate&&!this.hasUpdated||this[s](i,c))}})),o.call(this,t)}}}export{t as w};
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.21",
6
+ "version": "0.1.23",
7
7
  "main": "dist/src/index.js",
8
8
  "type": "module",
9
9
  "module": "dist/src/index.js",
@@ -117,7 +117,8 @@
117
117
  "@codemirror/lang-javascript": "6.2.1",
118
118
  "@codemirror/lang-sql": "6.7.0",
119
119
  "@codemirror/lang-json": "^6.0.1",
120
- "@codemirror/lang-html":"6.4.9",
120
+ "@codemirror/lang-html": "6.4.9",
121
+ "@lit-labs/virtualizer": "^2.0.15",
121
122
  "codemirror": "6.0.1",
122
123
  "chalk": "5.3.0",
123
124
  "figlet": "1.7.0",
@@ -12,12 +12,21 @@ import { css } from 'lit';
12
12
  */
13
13
  export const styles = css`
14
14
  :host {
15
+ --virtual-scroll-container-width:100px;
15
16
  }
16
17
 
17
18
  .nile-dropdown--input {
18
19
  width: 100%;
19
20
  }
20
21
 
22
+ .nile-dropdown--input lit-virtualizer{
23
+ min-width: var(--virtual-scroll-container-width)!important;
24
+ }
25
+
26
+ .nile-dropdown--input nile-menu-item{
27
+ width:100%;
28
+ }
29
+
21
30
  .nile-auto-complete--input {
22
31
  width: 100%;
23
32
  }
@@ -8,9 +8,9 @@ import {
8
8
  import { customElement, query, state, property } from 'lit/decorators.js';
9
9
  import { styles } from './nile-auto-complete.css';
10
10
  import NileElement from '../internal/nile-element';
11
- import { watch } from '../watch';
12
- import type { CSSResultGroup } from 'lit';
11
+ import type { CSSResultGroup, PropertyValues } from 'lit';
13
12
  import { NileDropdown } from '../nile-dropdown';
13
+ import '@lit-labs/virtualizer';
14
14
 
15
15
  // Define the custom element 'nile-auto-complete'
16
16
  @customElement('nile-auto-complete')
@@ -24,6 +24,8 @@ export class NileAutoComplete extends NileElement {
24
24
 
25
25
  @property({ type: Boolean }) isDropdownOpen: boolean = false;
26
26
 
27
+ @property({ type: Boolean }) enableVirtualScroll: boolean = false;
28
+
27
29
  @property({ type: Boolean }) openOnFocus: boolean = false;
28
30
 
29
31
  @property({ type: String }) value: string = '';
@@ -36,6 +38,8 @@ export class NileAutoComplete extends NileElement {
36
38
 
37
39
  @property({ attribute:false}) filterFunction: any = (item:string,searchedValue:string)=>item.toLowerCase().includes(searchedValue.toLowerCase());
38
40
 
41
+ @property({ attribute:false}) renderItemFunction: any = (item:any)=>item;
42
+
39
43
  @property({ type: Array }) allMenuItems: any = [];
40
44
 
41
45
  @state() menuItems: any = [];
@@ -45,18 +49,59 @@ export class NileAutoComplete extends NileElement {
45
49
  this.menuItems = [...this.allMenuItems];
46
50
  }
47
51
 
48
- // Watch for changes in 'allMenuItems' property
49
- @watch('allMenuItems')
50
- handleAllMenuItemsChange() {
51
- this.menuItems = [...this.allMenuItems];
52
+ protected updated(changedProperties: PropertyValues): void {
53
+ super.updated(changedProperties);
54
+ if (changedProperties.has('allMenuItems')) this.menuItems = [...this.allMenuItems];
55
+ if (changedProperties.has('isDropdownOpen')) this.menuItems = this.applyFilter(this.allMenuItems,this.filterFunction);
52
56
  }
53
57
 
58
+ public render(): TemplateResult {
59
+ const content=this.enableVirtualScroll?this.getVirtualizedContent():this.getContent();
60
+ return html`
61
+ <nile-dropdown class="nile-dropdown--input" ?open=${this.isDropdownOpen} noOpenOnCLick>
62
+ <nile-input class="nile-auto-complete--input"
63
+ ?no-border=${this.noBorder}
64
+ .value=${this.value}
65
+ @nile-input=${this.handleSearch}
66
+ @focus=${this.handleFocus}
67
+ @click=${this.handleClick}
68
+ slot="trigger"
69
+ placeholder=${this.placeholder}
70
+ >
71
+ ${this.loading?html`<nile-icon slot="suffix" color="var(--nile-colors-primary-600)" name="button-loading-blue-animated"></nile-icon>`:nothing}
72
+ </nile-input>
73
+ ${this.menuItems.length > 0 && !this.loading
74
+ ? content
75
+ : nothing}
76
+ </nile-dropdown>
77
+ `;
78
+ }
79
+
80
+ getVirtualizedContent():TemplateResult{
81
+ 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>
87
+ </nile-menu>
88
+ `
89
+ }
54
90
 
55
- @watch('isDropdownOpen', { waitUntilFirstUpdate: true })
56
- async handleValueChange() {
57
- await this.updateComplete;
58
- // Filter menu items based on the search value
59
- this.menuItems = this.applyFilter(this.allMenuItems,this.filterFunction);
91
+ getContent():TemplateResult{
92
+ return html`
93
+ <nile-menu id="content-menu" @nile-select=${this.handleSelect} exportparts="menu__items-wrapper:options__wrapper">
94
+ ${this.menuItems.map((item: any) => this.getItemRenderFunction(item))}
95
+ </nile-menu>`
96
+ }
97
+
98
+ getItemRenderFunction(item:any):TemplateResult{
99
+ const value=this.renderItemFunction(item)
100
+ return html`
101
+ <nile-menu-item value=${value}>
102
+ ${value}
103
+ </nile-menu-item>
104
+ `;
60
105
  }
61
106
 
62
107
  private handleSelect(event: CustomEvent) {
@@ -77,12 +122,6 @@ export class NileAutoComplete extends NileElement {
77
122
  if (this.isDropdownOpen) this.dropdownElement?.show();
78
123
  }
79
124
 
80
- applyFilter<T>(list: T[], filterFn: (item: T,searchValue?:string) => boolean): T[] {
81
- const res:T[]=[]
82
- list.forEach( el=> filterFn(el,this.value) && res.push(el) )
83
- return res
84
- }
85
-
86
125
  public handleFocus() {
87
126
  if (!this.openOnFocus) {
88
127
  return;
@@ -100,34 +139,12 @@ export class NileAutoComplete extends NileElement {
100
139
  this.dropdownElement?.show();
101
140
  }
102
141
 
103
- public render(): TemplateResult {
104
- return html`
105
- <nile-dropdown class="nile-dropdown--input" ?open=${this.isDropdownOpen} noOpenOnCLick>
106
- <nile-input class="nile-auto-complete--input"
107
- ?no-border=${this.noBorder}
108
- .value=${this.value}
109
- @nile-input=${this.handleSearch}
110
- @focus=${this.handleFocus}
111
- @click=${this.handleClick}
112
- slot="trigger"
113
- placeholder=${this.placeholder}
114
- >
115
- ${this.loading?html`<nile-icon slot="suffix" color="var(--nile-colors-primary-600)" name="button-loading-blue-animated"></nile-icon>`:nothing}
116
- </nile-input>
117
- ${this.menuItems.length > 0 && !this.loading
118
- ? html`
119
- <nile-menu @nile-select=${this.handleSelect} exportparts="menu__items-wrapper:options__wrapper">
120
- ${this.menuItems.map(
121
- (item: any) => html`
122
- <nile-menu-item value=${item}>${item}</nile-menu-item>
123
- `
124
- )}
125
- </nile-menu>
126
- `
127
- : ''}
128
- </nile-dropdown>
129
- `;
142
+ applyFilter<T>(list: T[], filterFn: (item: T,searchValue?:string) => boolean): T[] {
143
+ const res:T[]=[]
144
+ list.forEach( el=> filterFn(el,this.value) && res.push(el) )
145
+ return res
130
146
  }
147
+
131
148
  }
132
149
 
133
150
  export default NileAutoComplete;
@@ -10,12 +10,12 @@ import {
10
10
  html,
11
11
  CSSResultArray,
12
12
  TemplateResult,
13
+ PropertyValues,
13
14
  } from 'lit';
14
15
  import { customElement, query, state, property } from 'lit/decorators.js';
15
16
  import { styles } from './nile-chip.css';
16
17
  import { classMap } from 'lit/directives/class-map.js';
17
18
  import { HasSlotController } from '../internal/slot';
18
- import { watch } from '../internal/watch';
19
19
  import NileElement, { NileFormControl } from '../internal/nile-element';
20
20
 
21
21
  interface CustomEventDetail {
@@ -72,7 +72,11 @@ export class NileChip extends NileElement {
72
72
  /** Disables the input. */
73
73
  @property({ type: Boolean, reflect: true }) disabled = false;
74
74
 
75
- // Auto-complete options
75
+ // AUTO-COMPLETE-OPTIONS
76
+
77
+ /** Virtual scroll in dropdown options. */
78
+ @property({ type: Boolean }) enableVirtualScroll = false;
79
+
76
80
  @property({ type: Array }) autoCompleteOptions: any[] = [];
77
81
 
78
82
  @property({ type: Array }) filteredAutoCompleteOptions: any[] = [];
@@ -91,37 +95,30 @@ export class NileChip extends NileElement {
91
95
 
92
96
  @property({ attribute:false}) filterFunction: any = (item:string,searchedValue:string)=>item.toLowerCase().includes(searchedValue.toLowerCase());
93
97
 
94
- @watch('autoCompleteOptions')
95
- onAutoCompleteOptionsChanged() {
96
- this.filteredAutoCompleteOptions = [...this.autoCompleteOptions];
97
-
98
- if (this.noDuplicates) {
99
- this.filteredAutoCompleteOptions =
100
- this.filteredAutoCompleteOptions.filter(
101
- option => !this.value.includes(option)
102
- );
98
+ @property({ attribute:false}) renderItemFunction: any = (item:any)=>item;
99
+
100
+ protected updated(changedProperties: PropertyValues): void {
101
+ super.updated(changedProperties);
102
+ if (changedProperties.has('autoCompleteOptions')) {
103
+ this.filteredAutoCompleteOptions = [...this.autoCompleteOptions];
104
+ if (this.noDuplicates) {
105
+ this.filteredAutoCompleteOptions =
106
+ this.filteredAutoCompleteOptions.filter(
107
+ option => !this.value.includes(option)
108
+ );
109
+ }
103
110
  }
104
- }
105
-
106
- @watch('value')
107
- onValueChanged() {
108
- this.tags = [...this.value];
109
- this.onTagsChanged();
110
- }
111
-
112
- @watch('tags')
113
- onTagsChanged() {
114
- if (this.noDuplicates) {
115
- this.filteredAutoCompleteOptions =
116
- this.filteredAutoCompleteOptions.filter(
117
- option => !this.tags.includes(option)
118
- );
111
+ if (changedProperties.has('value')){
112
+ this.tags = [...this.value];
113
+ this.onTagsChanged();
114
+ }
115
+ if (changedProperties.has('tags')){
116
+ this.onTagsChanged();
119
117
  }
120
118
  }
121
119
 
122
120
  connectedCallback() {
123
121
  super.connectedCallback();
124
-
125
122
  if (this.noDuplicates) {
126
123
  this.filteredAutoCompleteOptions =
127
124
  this.filteredAutoCompleteOptions.filter(
@@ -136,74 +133,6 @@ export class NileChip extends NileElement {
136
133
  this.emit('nile-destroy');
137
134
  }
138
135
 
139
- private handleSelect(event: CustomEvent<CustomEventDetail>) {
140
- // Add the selected value to the tags array only if it doesn't already exist
141
- if (!this.noDuplicates || !this.tags.includes(event.detail.value)) {
142
- this.tags = [...this.tags, event.detail.value];
143
- this.emit('nile-chip-change', { value: this.tags });
144
- this.resetInput();
145
- }
146
- }
147
-
148
- private handleRemove(value: string) {
149
- // Remove the tag from the tags array
150
- this.tags = this.tags.filter(tag => tag !== value);
151
-
152
- if (this.noDuplicates && this.autoCompleteOptions.includes(value)) {
153
- this.filteredAutoCompleteOptions = [
154
- ...this.filteredAutoCompleteOptions,
155
- value,
156
- ];
157
- }
158
- this.emit('nile-chip-change', { value: this.tags });
159
- }
160
-
161
- private handleInputChange(event: CustomEvent<CustomEventDetail>) {
162
- // Update the input value
163
- this.inputValue = event.detail.value;
164
- }
165
-
166
- private handleInputKeydown(event: KeyboardEvent) {
167
- if (!this.acceptUserInput) {
168
- return;
169
- }
170
-
171
- if(event.key === 'Tab'){
172
- event.preventDefault()
173
- }
174
-
175
- if (
176
- (event.key === 'Enter' || event.key === 'Tab' )
177
- && this.inputValue
178
- && (!this.noDuplicates || !this.tags.includes(this.inputValue))
179
- ) {
180
- event.preventDefault()
181
- this.tags = [...this.tags, this.inputValue];
182
- this.resetInput();
183
- this.emit('nile-chip-change', { value: this.tags });
184
- }
185
-
186
- if(
187
- (event.key === 'Enter'|| event.key === 'Tab' )
188
- && this.inputValue
189
- && (this.noDuplicates || this.tags.includes(this.inputValue))
190
- ){
191
- this.emit('nile-duplicates-blocked');
192
- }
193
- }
194
-
195
- private handleFocus() {
196
- this.isDropdownOpen = true;
197
- }
198
-
199
- private resetInput() {
200
- // Reset the input-related properties
201
- this.inputValue = '';
202
- this.isDropdownOpen = false;
203
- this.autoComplete.value = '';
204
- this.autoComplete.handleFocus();
205
- }
206
-
207
136
  render() {
208
137
  // Check if slots are present
209
138
  const hasLabelSlot = this.hasSlotController.test('label');
@@ -261,8 +190,10 @@ export class NileChip extends NileElement {
261
190
  )}
262
191
  <div class="nile-chip__auto-complete">
263
192
  <nile-auto-complete
193
+ .enableVirtualScroll=${this.enableVirtualScroll}
264
194
  .allMenuItems=${this.filteredAutoCompleteOptions}
265
195
  .filterFunction=${this.filterFunction}
196
+ .renderItemFunction=${this.renderItemFunction}
266
197
  .loading="${this.loading}"
267
198
  .value=${this.inputValue}
268
199
  ?isDropdownOpen=${this.isDropdownOpen}
@@ -306,6 +237,80 @@ export class NileChip extends NileElement {
306
237
  </div>
307
238
  `;
308
239
  }
240
+
241
+ private handleSelect(event: CustomEvent<CustomEventDetail>) {
242
+ // Add the selected value to the tags array only if it doesn't already exist
243
+ if (!this.noDuplicates || !this.tags.includes(event.detail.value)) {
244
+ this.tags = [...this.tags, event.detail.value];
245
+ this.emit('nile-chip-change', { value: this.tags });
246
+ this.resetInput();
247
+ }
248
+ }
249
+
250
+ private handleRemove(value: string) {
251
+ // Remove the tag from the tags array
252
+ this.tags = this.tags.filter(tag => tag !== value);
253
+
254
+ if (this.noDuplicates && this.autoCompleteOptions.includes(value)) {
255
+ this.filteredAutoCompleteOptions = [
256
+ ...this.filteredAutoCompleteOptions,
257
+ value,
258
+ ];
259
+ }
260
+ this.emit('nile-chip-change', { value: this.tags });
261
+ }
262
+
263
+ private handleInputChange(event: CustomEvent<CustomEventDetail>) {
264
+ // Update the input value
265
+ this.inputValue = event.detail.value;
266
+ }
267
+
268
+ private handleInputKeydown(event: KeyboardEvent) {
269
+ if (!this.acceptUserInput) {
270
+ return;
271
+ }
272
+
273
+ if(event.key === 'Tab'){
274
+ event.preventDefault()
275
+ }
276
+
277
+ if (
278
+ (event.key === 'Enter' || event.key === 'Tab' )
279
+ && this.inputValue
280
+ && (!this.noDuplicates || !this.tags.includes(this.inputValue))
281
+ ) {
282
+ event.preventDefault()
283
+ this.tags = [...this.tags, this.inputValue];
284
+ this.resetInput();
285
+ this.emit('nile-chip-change', { value: this.tags });
286
+ }
287
+
288
+ if(
289
+ (event.key === 'Enter'|| event.key === 'Tab' )
290
+ && this.inputValue
291
+ && (this.noDuplicates || this.tags.includes(this.inputValue))
292
+ ){
293
+ this.emit('nile-duplicates-blocked');
294
+ }
295
+ }
296
+
297
+ private handleFocus() {
298
+ this.isDropdownOpen = true;
299
+ }
300
+
301
+ onTagsChanged() {
302
+ if (this.noDuplicates)
303
+ this.filteredAutoCompleteOptions = this.filteredAutoCompleteOptions.filter(option => !this.tags.includes(option));
304
+ }
305
+
306
+
307
+ private resetInput() {
308
+ // Reset the input-related properties
309
+ this.inputValue = '';
310
+ this.isDropdownOpen = false;
311
+ this.autoComplete.value = '';
312
+ this.autoComplete.handleFocus();
313
+ }
309
314
  }
310
315
 
311
316
  export default NileChip;
@@ -8,7 +8,7 @@ export default css`
8
8
 
9
9
  .form-control--inline-radio ::slotted(nile-radio) {
10
10
  display: inline-block;
11
- margin-right: 24px !important;
11
+ margin-right: 24px;
12
12
  }
13
13
 
14
14
  .form-control {
@@ -58,6 +58,11 @@ export default css`
58
58
  line-height: 18px;
59
59
  }
60
60
 
61
+ .nile-slide--disabled .nile-slide-toggle__label,
62
+ .nile-slide--disabled .nile-slide-toggle__sublabel{
63
+ color: var(--nile-colors-dark-500);
64
+ }
65
+
61
66
  .nile-slide-toggle__switch input {
62
67
  opacity: 0;
63
68
  width: 0;
@@ -62,13 +62,18 @@
62
62
  },
63
63
  {
64
64
  "name": "nile-auto-complete",
65
- "description": "Attributes:\n\n * `isDropdownOpen` {`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 * `openOnFocus` {`boolean`} - \n\n * `value` {`string`} - \n\n * `placeholder` {`string`} - \n\n * `noBorder` {`boolean`} - \n\n * `loading` {`boolean`} - \n\n * `filterFunction` - \n\n * `allMenuItems` - \n\n * `menuItems` - \n\n * `BUBBLES` {`boolean`} - \n\n * `COMPOSED` {`boolean`} - \n\n * `CANCELABLE` {`boolean`} - ",
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`} - ",
66
66
  "attributes": [
67
67
  {
68
68
  "name": "isDropdownOpen",
69
69
  "description": "`isDropdownOpen` {`boolean`} - \n\nProperty: isDropdownOpen\n\nDefault: false",
70
70
  "valueSet": "v"
71
71
  },
72
+ {
73
+ "name": "enableVirtualScroll",
74
+ "description": "`enableVirtualScroll` {`boolean`} - \n\nProperty: enableVirtualScroll\n\nDefault: false",
75
+ "valueSet": "v"
76
+ },
72
77
  {
73
78
  "name": "openOnFocus",
74
79
  "description": "`openOnFocus` {`boolean`} - \n\nProperty: openOnFocus\n\nDefault: false",
@@ -696,7 +701,7 @@
696
701
  },
697
702
  {
698
703
  "name": "nile-chip",
699
- "description": "Attributes:\n\n * `warning` {`boolean`} - Sets the input to a warning state, changing its visual appearance.\n\n * `error` {`boolean`} - Sets the input to an error state, changing its visual appearance.\n\n * `success` {`boolean`} - Sets the input to a success state, changing its visual appearance.\n\n * `noDuplicates` {`boolean`} - Disables the duplicate entries.\n\n * `label` {`string`} - The input's label. If you need to display HTML, use the `label` slot instead.\n\n * `acceptUserInput` {`boolean`} - Adds a clear button when the input is not empty.\n\n * `clearable` {`boolean`} - Adds a clear button when the input is not empty.\n\n * `placeholder` {`string`} - Placeholder text to show as a hint when the input is empty.\n\n * `readonly` {`boolean`} - Makes the input readonly.\n\n * `disabled` {`boolean`} - Disables the input.\n\n * `autoCompleteOptions` {`any[]`} - \n\n * `filteredAutoCompleteOptions` {`any[]`} - \n\n * `value` {`any[]`} - \n\n * `noWrap` {`boolean`} - \n\n * `loading` {`boolean`} - \n\n * `errorIndexes` {`number[]`} - \n\n * `help-text` {`string`} - \n\n * `error-message` {`string`} - \n\nProperties:\n\n * `hasSlotController` - \n\n * `tags` {`string[]`} - \n\n * `inputValue` {`string`} - \n\n * `isDropdownOpen` {`boolean`} - \n\n * `autoComplete` - \n\n * `warning` {`boolean`} - Sets the input to a warning state, changing its visual appearance.\n\n * `error` {`boolean`} - Sets the input to an error state, changing its visual appearance.\n\n * `success` {`boolean`} - Sets the input to a success state, changing its visual appearance.\n\n * `noDuplicates` {`boolean`} - Disables the duplicate entries.\n\n * `label` {`string`} - The input's label. If you need to display HTML, use the `label` slot instead.\n\n * `acceptUserInput` {`boolean`} - Adds a clear button when the input is not empty.\n\n * `clearable` {`boolean`} - Adds a clear button when the input is not empty.\n\n * `placeholder` {`string`} - Placeholder text to show as a hint when the input is empty.\n\n * `readonly` {`boolean`} - Makes the input readonly.\n\n * `disabled` {`boolean`} - Disables the input.\n\n * `autoCompleteOptions` {`any[]`} - \n\n * `filteredAutoCompleteOptions` {`any[]`} - \n\n * `value` {`any[]`} - \n\n * `noWrap` {`boolean`} - \n\n * `loading` {`boolean`} - \n\n * `errorIndexes` {`number[]`} - \n\n * `helpText` {`string`} - \n\n * `errorMessage` {`string`} - \n\n * `filterFunction` - \n\n * `BUBBLES` {`boolean`} - \n\n * `COMPOSED` {`boolean`} - \n\n * `CANCELABLE` {`boolean`} - ",
704
+ "description": "Attributes:\n\n * `warning` {`boolean`} - Sets the input to a warning state, changing its visual appearance.\n\n * `error` {`boolean`} - Sets the input to an error state, changing its visual appearance.\n\n * `success` {`boolean`} - Sets the input to a success state, changing its visual appearance.\n\n * `noDuplicates` {`boolean`} - Disables the duplicate entries.\n\n * `label` {`string`} - The input's label. If you need to display HTML, use the `label` slot instead.\n\n * `acceptUserInput` {`boolean`} - Adds a clear button when the input is not empty.\n\n * `clearable` {`boolean`} - Adds a clear button when the input is not empty.\n\n * `placeholder` {`string`} - Placeholder text to show as a hint when the input is empty.\n\n * `readonly` {`boolean`} - Makes the input readonly.\n\n * `disabled` {`boolean`} - Disables the input.\n\n * `enableVirtualScroll` {`boolean`} - Virtual scroll in dropdown options.\n\n * `autoCompleteOptions` {`any[]`} - \n\n * `filteredAutoCompleteOptions` {`any[]`} - \n\n * `value` {`any[]`} - \n\n * `noWrap` {`boolean`} - \n\n * `loading` {`boolean`} - \n\n * `errorIndexes` {`number[]`} - \n\n * `help-text` {`string`} - \n\n * `error-message` {`string`} - \n\nProperties:\n\n * `hasSlotController` - \n\n * `tags` {`string[]`} - \n\n * `inputValue` {`string`} - \n\n * `isDropdownOpen` {`boolean`} - \n\n * `autoComplete` - \n\n * `warning` {`boolean`} - Sets the input to a warning state, changing its visual appearance.\n\n * `error` {`boolean`} - Sets the input to an error state, changing its visual appearance.\n\n * `success` {`boolean`} - Sets the input to a success state, changing its visual appearance.\n\n * `noDuplicates` {`boolean`} - Disables the duplicate entries.\n\n * `label` {`string`} - The input's label. If you need to display HTML, use the `label` slot instead.\n\n * `acceptUserInput` {`boolean`} - Adds a clear button when the input is not empty.\n\n * `clearable` {`boolean`} - Adds a clear button when the input is not empty.\n\n * `placeholder` {`string`} - Placeholder text to show as a hint when the input is empty.\n\n * `readonly` {`boolean`} - Makes the input readonly.\n\n * `disabled` {`boolean`} - Disables the input.\n\n * `enableVirtualScroll` {`boolean`} - Virtual scroll in dropdown options.\n\n * `autoCompleteOptions` {`any[]`} - \n\n * `filteredAutoCompleteOptions` {`any[]`} - \n\n * `value` {`any[]`} - \n\n * `noWrap` {`boolean`} - \n\n * `loading` {`boolean`} - \n\n * `errorIndexes` {`number[]`} - \n\n * `helpText` {`string`} - \n\n * `errorMessage` {`string`} - \n\n * `filterFunction` - \n\n * `renderItemFunction` - \n\n * `BUBBLES` {`boolean`} - \n\n * `COMPOSED` {`boolean`} - \n\n * `CANCELABLE` {`boolean`} - ",
700
705
  "attributes": [
701
706
  {
702
707
  "name": "warning",
@@ -746,6 +751,11 @@
746
751
  "description": "`disabled` {`boolean`} - Disables the input.\n\nProperty: disabled\n\nDefault: false",
747
752
  "valueSet": "v"
748
753
  },
754
+ {
755
+ "name": "enableVirtualScroll",
756
+ "description": "`enableVirtualScroll` {`boolean`} - Virtual scroll in dropdown options.\n\nProperty: enableVirtualScroll\n\nDefault: false",
757
+ "valueSet": "v"
758
+ },
749
759
  {
750
760
  "name": "autoCompleteOptions",
751
761
  "description": "`autoCompleteOptions` {`any[]`} - \n\nProperty: autoCompleteOptions\n\nDefault: "