@vaadin-component-factory/vcf-autocomplete 24.1.4 → 24.1.6

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.
@@ -46,56 +46,58 @@ import './vcf-autocomplete-overlay';
46
46
  registerStyles(
47
47
  'vaadin-item',
48
48
  css`
49
- :host(.vcf-autocomplete-no-checkmark) [part="checkmark"] {
50
- visibility: hidden;
51
- }
52
- `
49
+ :host(.vcf-autocomplete-no-checkmark) [part="checkmark"] {
50
+ visibility: hidden;
51
+ }
52
+ `
53
53
  );
54
54
  class VcfAutocomplete extends ElementMixin(ThemableMixin(PolylitMixin(LitElement))) {
55
- render() {
56
- return html`
57
- <style>
55
+ static get styles() {
56
+ return css`
58
57
  :host {
59
58
  display: inline-block;
60
59
  }
61
-
60
+
62
61
  :host([opened]) {
63
62
  pointer-events: auto;
64
63
  }
65
- </style>
66
-
67
- <vaadin-text-field id="textField" @focus="${this._textFieldFocused}" .label="${this.label}" .placeholder="${this.placeholder}" theme="${this._theme}" value="${this.value}" ?readonly="${this.readonly}">
68
- ${this._hasValue(this.value) ? html`
69
- <vaadin-button part="clear" theme="icon tertiary small" aria-label="Add new item" slot="suffix" @click="${this.clear}">
70
- <vaadin-icon icon="lumo:cross"> </vaadin-icon>
71
- </vaadin-button>
72
- ` : ''}
73
- </vaadin-text-field>
74
-
75
- <vcf-autocomplete-overlay .opened="${this.opened}" theme="${this._theme}">
76
- <vaadin-list-box part="options-container" theme="${this._theme}">
77
- ${!this.loading ? html`
78
- ${map(this._limitedOptions, (option) => html`
79
- <vaadin-item @click="${this._optionClicked}" part="option" theme="${this._theme}" class="vcf-autocomplete-no-checkmark">
80
- ${this._getSuggestedStart(this.value, option)} <span part="bold" style="font-weight: 600;">${this._getInputtedPart(this.value, option)}</span>${this._getSuggestedEnd(this.value, option)}
81
- </vaadin-item>
82
- `)}
83
- ` : ''}
84
-
85
- ${this._noResultsShown(this.options, this.loading) ? html`
86
- <vaadin-item disabled part="option">
87
- <div part="no-results">No results</div>
88
- </vaadin-item>
89
- ` : ''}
90
-
91
- ${this.loading ? html`
92
- <vaadin-item disabled part="option">
93
- <div part="loading-indicator">Loading...</div>
94
- </vaadin-item>
95
- ` : ''}
96
- </vaadin-list-box>
97
- </vcf-autocomplete-overlay>
98
- `;
64
+ `
65
+ }
66
+
67
+ render() {
68
+ return html`
69
+ <vaadin-text-field part="textfield" id="textField" @focus="${this._textFieldFocused}" .label="${this.label}" .placeholder="${this.placeholder}" theme="${this._theme}" value="${this.value}" ?readonly="${this.readonly}" ?disabled="${!this.enabled}">
70
+ ${this._hasValue(this.value) && !this.readonly && this.enabled ? html`
71
+ <vaadin-button part="clear" theme="icon tertiary small" aria-label="Add new item" slot="suffix" @click="${this.clear}">
72
+ <vaadin-icon icon="lumo:cross"> </vaadin-icon>
73
+ </vaadin-button>
74
+ ` : ''}
75
+ </vaadin-text-field>
76
+
77
+ <vcf-autocomplete-overlay .opened="${this.opened}" theme="${this._theme}">
78
+ <vaadin-list-box part="options-container" theme="${this._theme}">
79
+ ${!this.loading ? html`
80
+ ${map(this._limitedOptions, (option) => html`
81
+ <vaadin-item @click="${this._optionClicked}" part="option" theme="${this._theme}" class="vcf-autocomplete-no-checkmark">
82
+ ${this._getSuggestedStart(this.value, option)} <span part="bold" style="font-weight: 600;">${this._getInputtedPart(this.value, option)}</span>${this._getSuggestedEnd(this.value, option)}
83
+ </vaadin-item>
84
+ `)}
85
+ ` : ''}
86
+
87
+ ${this._noResultsShown(this.options, this.loading) ? html`
88
+ <vaadin-item disabled part="option">
89
+ <div part="no-results">No results</div>
90
+ </vaadin-item>
91
+ ` : ''}
92
+
93
+ ${this.loading ? html`
94
+ <vaadin-item part="loading" disabled part="option">
95
+ <div part="loading-indicator">Loading...</div>
96
+ </vaadin-item>
97
+ ` : ''}
98
+ </vaadin-list-box>
99
+ </vcf-autocomplete-overlay>
100
+ `;
99
101
  }
100
102
 
101
103
  static get is() {
@@ -170,6 +172,12 @@ class VcfAutocomplete extends ElementMixin(ThemableMixin(PolylitMixin(LitElement
170
172
  reflectToAttribute: true
171
173
  },
172
174
 
175
+ enabled: {
176
+ type: Boolean,
177
+ value: true,
178
+ reflectToAttribute: true
179
+ },
180
+
173
181
  _overlayElement: Object,
174
182
  _optionsContainer: Object,
175
183
  _selectedOption: {