@infineon/infineon-design-system-stencil 38.0.0--canary.1954.89974e8652917b13e12f27392809a5638fe1be81.0 → 38.0.0--canary.1954.fdfbd944c08cecdcc9824a417e1f25c770138dcf.0
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/dist/cjs/ifx-search-field.cjs.entry.js +230 -2
- package/dist/cjs/ifx-search-field.cjs.entry.js.map +1 -1
- package/dist/collection/components/search-field/search-field.js +230 -2
- package/dist/collection/components/search-field/search-field.js.map +1 -1
- package/dist/components/ifx-filter-search.js +1 -1
- package/dist/components/ifx-icons-preview.js +1 -1
- package/dist/components/ifx-multiselect.js +1 -1
- package/dist/components/ifx-search-bar.js +1 -1
- package/dist/components/ifx-search-field.js +1 -1
- package/dist/components/ifx-set-filter.js +2 -2
- package/dist/components/{p-b8f1ae15.js → p-c28c8d28.js} +2 -2
- package/dist/components/{p-b8f1ae15.js.map → p-c28c8d28.js.map} +1 -1
- package/dist/components/{p-78e57415.js → p-e0560473.js} +231 -3
- package/dist/components/p-e0560473.js.map +1 -0
- package/dist/esm/ifx-search-field.entry.js +230 -2
- package/dist/esm/ifx-search-field.entry.js.map +1 -1
- package/dist/infineon-design-system-stencil/infineon-design-system-stencil.esm.js +1 -1
- package/dist/infineon-design-system-stencil/p-12840ca6.entry.js +2 -0
- package/dist/infineon-design-system-stencil/p-12840ca6.entry.js.map +1 -0
- package/dist/types/components/search-field/search-field.d.ts +14 -0
- package/package.json +1 -1
- package/dist/components/p-78e57415.js.map +0 -1
- package/dist/infineon-design-system-stencil/p-e45947e8.entry.js +0 -2
- package/dist/infineon-design-system-stencil/p-e45947e8.entry.js.map +0 -1
@@ -71,6 +71,11 @@ const SearchField = class {
|
|
71
71
|
}
|
72
72
|
this.hideDropdown();
|
73
73
|
};
|
74
|
+
// Handle click on history delete button
|
75
|
+
this.handleHistoryDelete = (event, term) => {
|
76
|
+
event.stopPropagation(); // Prevent selection of the entry
|
77
|
+
this.removeFromHistory(term);
|
78
|
+
};
|
74
79
|
}
|
75
80
|
componentDidLoad() {
|
76
81
|
this.loadSearchHistory();
|
@@ -141,6 +146,229 @@ const SearchField = class {
|
|
141
146
|
}
|
142
147
|
}
|
143
148
|
}
|
149
|
+
blurInput() {
|
150
|
+
setTimeout(() => {
|
151
|
+
this.isFocused = false;
|
152
|
+
this.focusEmitted = false; // Reset focus flag when blur occurs
|
153
|
+
this.ifxBlur.emit();
|
154
|
+
}, 150);
|
155
|
+
}
|
156
|
+
// Public method to update history from external sources
|
157
|
+
loadSearchHistory() {
|
158
|
+
if (this.enableHistory && typeof localStorage !== 'undefined') {
|
159
|
+
const stored = localStorage.getItem(this.historyKey);
|
160
|
+
this.searchHistory = stored ? JSON.parse(stored) : [];
|
161
|
+
// Update suggestions when history is loaded
|
162
|
+
this.updateSuggestions();
|
163
|
+
// If no input and no history left, close dropdown
|
164
|
+
if (this.value.length === 0 && this.searchHistory.length === 0) {
|
165
|
+
this.showDropdown = false;
|
166
|
+
}
|
167
|
+
}
|
168
|
+
}
|
169
|
+
// Public method to completely clear history
|
170
|
+
clearSearchHistory() {
|
171
|
+
if (this.enableHistory && typeof localStorage !== 'undefined') {
|
172
|
+
// Clear from localStorage
|
173
|
+
localStorage.removeItem(this.historyKey);
|
174
|
+
// Clear internal history
|
175
|
+
this.searchHistory = [];
|
176
|
+
// Reset all dropdown-relevant states
|
177
|
+
this.filteredSuggestions = [];
|
178
|
+
this.selectedSuggestionIndex = -1;
|
179
|
+
this.showDropdown = false;
|
180
|
+
// Update suggestions after reset
|
181
|
+
this.updateSuggestions();
|
182
|
+
}
|
183
|
+
}
|
184
|
+
// Suggestion Management Methods
|
185
|
+
addToHistory(term) {
|
186
|
+
if (!this.enableHistory || !term.trim())
|
187
|
+
return;
|
188
|
+
const history = [...this.searchHistory];
|
189
|
+
const existingIndex = history.indexOf(term);
|
190
|
+
if (existingIndex > -1) {
|
191
|
+
history.splice(existingIndex, 1);
|
192
|
+
}
|
193
|
+
history.unshift(term);
|
194
|
+
// Limit history to maxHistoryItems (default 5)
|
195
|
+
this.searchHistory = history.slice(0, this.maxHistoryItems);
|
196
|
+
if (typeof localStorage !== 'undefined') {
|
197
|
+
localStorage.setItem(this.historyKey, JSON.stringify(this.searchHistory));
|
198
|
+
}
|
199
|
+
}
|
200
|
+
// Remove individual history entry
|
201
|
+
removeFromHistory(term) {
|
202
|
+
if (!this.enableHistory)
|
203
|
+
return;
|
204
|
+
const history = [...this.searchHistory];
|
205
|
+
const index = history.indexOf(term);
|
206
|
+
if (index > -1) {
|
207
|
+
history.splice(index, 1);
|
208
|
+
this.searchHistory = history;
|
209
|
+
// Update localStorage
|
210
|
+
if (typeof localStorage !== 'undefined') {
|
211
|
+
localStorage.setItem(this.historyKey, JSON.stringify(this.searchHistory));
|
212
|
+
}
|
213
|
+
// Update suggestions after removal
|
214
|
+
this.updateSuggestions();
|
215
|
+
// Close dropdown if no history remains
|
216
|
+
if (this.searchHistory.length === 0 && this.value.length === 0) {
|
217
|
+
this.showDropdown = false;
|
218
|
+
}
|
219
|
+
}
|
220
|
+
}
|
221
|
+
requestSuggestions(query) {
|
222
|
+
this.ifxSuggestionRequested.emit(query);
|
223
|
+
this.updateSuggestions();
|
224
|
+
}
|
225
|
+
updateSuggestions() {
|
226
|
+
const query = this.value.toLowerCase();
|
227
|
+
let suggestions = [];
|
228
|
+
if (query.length > 0) {
|
229
|
+
// For text input: Mix external suggestions and relevant history
|
230
|
+
// 1. Filter external suggestions
|
231
|
+
if (this.suggestions && this.suggestions.length > 0) {
|
232
|
+
const filteredExternal = this.suggestions.filter(s => s.text.toLowerCase().includes(query));
|
233
|
+
suggestions = [...suggestions, ...filteredExternal];
|
234
|
+
}
|
235
|
+
// 2. Filter relevant history entries
|
236
|
+
if (this.enableHistory && this.searchHistory.length > 0) {
|
237
|
+
const filteredHistory = this.searchHistory
|
238
|
+
.filter(term => term.toLowerCase().includes(query))
|
239
|
+
.map((term, index) => ({
|
240
|
+
id: `history-${index}`,
|
241
|
+
text: term,
|
242
|
+
type: 'history'
|
243
|
+
}));
|
244
|
+
suggestions = [...suggestions, ...filteredHistory];
|
245
|
+
}
|
246
|
+
// 3. Sort by relevance (exact matches first, then prefix matches)
|
247
|
+
suggestions.sort((a, b) => {
|
248
|
+
const aText = a.text.toLowerCase();
|
249
|
+
const bText = b.text.toLowerCase();
|
250
|
+
// Exact match has highest priority
|
251
|
+
if (aText === query && bText !== query)
|
252
|
+
return -1;
|
253
|
+
if (bText === query && aText !== query)
|
254
|
+
return 1;
|
255
|
+
// Prefix match has second highest priority
|
256
|
+
const aStartsWith = aText.startsWith(query);
|
257
|
+
const bStartsWith = bText.startsWith(query);
|
258
|
+
if (aStartsWith && !bStartsWith)
|
259
|
+
return -1;
|
260
|
+
if (bStartsWith && !aStartsWith)
|
261
|
+
return 1;
|
262
|
+
// With equal relevance: external suggestions before history
|
263
|
+
if (a.type === 'suggestion' && b.type === 'history')
|
264
|
+
return -1;
|
265
|
+
if (a.type === 'history' && b.type === 'suggestion')
|
266
|
+
return 1;
|
267
|
+
// Alphabetical sorting as last criterion
|
268
|
+
return aText.localeCompare(bText);
|
269
|
+
});
|
270
|
+
}
|
271
|
+
else {
|
272
|
+
// For empty query: Show only history (no external suggestions)
|
273
|
+
if (this.enableHistory && this.searchHistory.length > 0) {
|
274
|
+
const historySuggestions = this.searchHistory.map((term, index) => ({
|
275
|
+
id: `history-${index}`,
|
276
|
+
text: term,
|
277
|
+
type: 'history'
|
278
|
+
}));
|
279
|
+
suggestions = historySuggestions;
|
280
|
+
}
|
281
|
+
// For empty query DO NOT show external suggestions
|
282
|
+
}
|
283
|
+
// Remove duplicates based on text and scope combination (history takes precedence over external)
|
284
|
+
const uniqueSuggestions = suggestions.reduce((unique, current) => {
|
285
|
+
const existingIndex = unique.findIndex(item => item.text.toLowerCase() === current.text.toLowerCase() &&
|
286
|
+
item.scope === current.scope);
|
287
|
+
if (existingIndex === -1) {
|
288
|
+
unique.push(current);
|
289
|
+
}
|
290
|
+
else {
|
291
|
+
// If already exists, prefer history over external suggestions
|
292
|
+
if (current.type === 'history' && unique[existingIndex].type !== 'history') {
|
293
|
+
unique[existingIndex] = current;
|
294
|
+
}
|
295
|
+
}
|
296
|
+
return unique;
|
297
|
+
}, []);
|
298
|
+
this.filteredSuggestions = uniqueSuggestions.slice(0, this.maxSuggestions);
|
299
|
+
this.selectedSuggestionIndex = -1;
|
300
|
+
}
|
301
|
+
navigateSuggestions(direction) {
|
302
|
+
const maxIndex = this.filteredSuggestions.length - 1;
|
303
|
+
if (direction > 0) {
|
304
|
+
this.selectedSuggestionIndex = this.selectedSuggestionIndex < maxIndex
|
305
|
+
? this.selectedSuggestionIndex + 1
|
306
|
+
: 0;
|
307
|
+
}
|
308
|
+
else {
|
309
|
+
this.selectedSuggestionIndex = this.selectedSuggestionIndex > 0
|
310
|
+
? this.selectedSuggestionIndex - 1
|
311
|
+
: maxIndex;
|
312
|
+
}
|
313
|
+
}
|
314
|
+
selectSuggestion(suggestion) {
|
315
|
+
this.value = suggestion.text;
|
316
|
+
this.inputElement.value = suggestion.text;
|
317
|
+
this.ifxSuggestionSelected.emit(suggestion);
|
318
|
+
this.ifxInput.emit(this.value);
|
319
|
+
if (this.enableHistory) {
|
320
|
+
// Always add selected suggestions to history since they are valid results
|
321
|
+
this.addToHistory(suggestion.text);
|
322
|
+
}
|
323
|
+
this.hideDropdown();
|
324
|
+
}
|
325
|
+
hideDropdown() {
|
326
|
+
this.showDropdown = false;
|
327
|
+
this.selectedSuggestionIndex = -1;
|
328
|
+
this.isFocused = false;
|
329
|
+
}
|
330
|
+
// Show only history in dropdown (e.g. on focus without input)
|
331
|
+
showHistoryDropdown() {
|
332
|
+
if (this.enableHistory && this.searchHistory.length > 0) {
|
333
|
+
// Show only history entries
|
334
|
+
const historySuggestions = this.searchHistory.map((term, index) => ({
|
335
|
+
id: `history-${index}`,
|
336
|
+
text: term,
|
337
|
+
type: 'history'
|
338
|
+
}));
|
339
|
+
this.filteredSuggestions = historySuggestions.slice(0, this.maxSuggestions);
|
340
|
+
this.selectedSuggestionIndex = -1;
|
341
|
+
}
|
342
|
+
else {
|
343
|
+
this.filteredSuggestions = [];
|
344
|
+
}
|
345
|
+
}
|
346
|
+
// Check if only history entries are displayed (without text input)
|
347
|
+
isShowingOnlyHistory() {
|
348
|
+
return this.value.length === 0 &&
|
349
|
+
this.filteredSuggestions.length > 0 &&
|
350
|
+
this.filteredSuggestions.every(s => s.type === 'history');
|
351
|
+
}
|
352
|
+
// Render text with highlighted matches
|
353
|
+
renderHighlightedText(text, query) {
|
354
|
+
if (!query || query.length === 0) {
|
355
|
+
return text;
|
356
|
+
}
|
357
|
+
const lowerText = text.toLowerCase();
|
358
|
+
const lowerQuery = query.toLowerCase();
|
359
|
+
const index$1 = lowerText.indexOf(lowerQuery);
|
360
|
+
if (index$1 === -1) {
|
361
|
+
return text;
|
362
|
+
}
|
363
|
+
const before = text.substring(0, index$1);
|
364
|
+
const match = text.substring(index$1, index$1 + query.length);
|
365
|
+
const after = text.substring(index$1 + query.length);
|
366
|
+
return [
|
367
|
+
before,
|
368
|
+
index.h("strong", null, match),
|
369
|
+
after
|
370
|
+
];
|
371
|
+
}
|
144
372
|
componentWillLoad() {
|
145
373
|
if (!domUtils.isNestedInIfxComponent(this.el)) {
|
146
374
|
const framework = frameworkDetection.detectFramework();
|
@@ -155,12 +383,12 @@ const SearchField = class {
|
|
155
383
|
this.showDeleteIconInternalState = false;
|
156
384
|
}
|
157
385
|
render() {
|
158
|
-
return (index.h("div", { key: '
|
386
|
+
return (index.h("div", { key: '95b3f6773ae9b4dcf3e031d5a95aa048ecc0d26a', "aria-label": this.ariaLabel, "aria-labelledby": this.ariaLabelledBy, "aria-describedby": this.ariaDescribedBy, "aria-disabled": this.disabled, "aria-value": this.value, class: 'search-field' }, index.h("div", { key: '7b2715a0e0baee0bacb3b46b8a36e97186c0e3f0', class: this.getWrapperClassNames(), tabindex: 1, onClick: () => this.focusInput() }, index.h("ifx-icon", { key: 'c993a124ac5335fed1daedb9d420a0598b59fd74', icon: "search-16", class: "search-icon" }), index.h("input", { key: '39767e82f49ab4158618a946e3a3d1bc53a8c905', ref: (el) => (this.inputElement = el), type: "text", autocomplete: this.autocomplete, onInput: () => this.handleInput(), onFocus: () => this.focusInput(), onBlur: () => this.blurInput(), placeholder: this.placeholder, disabled: this.disabled, maxlength: this.maxlength, value: this.value, role: "combobox", "aria-expanded": this.showDropdown, "aria-autocomplete": "list", "aria-haspopup": "listbox", "aria-label": this.ariaLabel, "aria-labelledby": this.ariaLabelledBy, "aria-describedby": this.ariaDescribedBy, "aria-owns": this.showDropdown ? 'suggestions-dropdown' : undefined, "aria-activedescendant": this.selectedSuggestionIndex >= 0 ? `suggestion-${this.selectedSuggestionIndex}` : undefined }), this.showDeleteIcon && this.showDeleteIconInternalState ? (index.h("ifx-icon", { icon: "cRemove16", class: "delete-icon", onClick: this.handleDelete, role: "button", tabindex: "0", "aria-label": this.deleteIconAriaLabel, onKeyDown: (event) => {
|
159
387
|
if (event.key === 'Enter' || event.key === ' ') {
|
160
388
|
event.preventDefault();
|
161
389
|
this.handleDelete();
|
162
390
|
}
|
163
|
-
} })) : null), this.showDropdown && this.filteredSuggestions.length > 0 && (index.h("div", { key: '
|
391
|
+
} })) : null), this.showDropdown && this.filteredSuggestions.length > 0 && (index.h("div", { key: 'fd86b42d9454757e94cdcd06d4ce57c046c368f8', ref: (el) => (this.dropdownElement = el), id: "suggestions-dropdown", class: "suggestions-dropdown", role: "listbox", "aria-label": this.dropdownAriaLabel }, this.isShowingOnlyHistory() && (index.h("div", { key: 'ae176504ab9d8efe736efb8833e6c07639f216d0', class: "suggestions-header" }, this.historyHeaderText)), this.filteredSuggestions.map((suggestion, index$1) => (index.h("div", { key: suggestion.id, id: `suggestion-${index$1}`, class: this.getSuggestionClassNames(index$1), role: "option", "aria-selected": index$1 === this.selectedSuggestionIndex, "aria-label": `${suggestion.type === 'history' ? this.historyItemAriaLabel : this.suggestionAriaLabel}: ${suggestion.text}${suggestion.scope ? `, ${suggestion.scope}` : ''}${suggestion.resultCount ? `, ${suggestion.resultCount} results` : ''}`, onClick: () => this.selectSuggestion(suggestion), onMouseEnter: () => this.selectedSuggestionIndex = index$1 }, index.h("div", { class: "suggestion-content" }, suggestion.type === 'history' && (index.h("ifx-icon", { icon: "history-16", class: "suggestion-icon suggestion-icon--history" })), suggestion.type === 'suggestion' && (index.h("ifx-icon", { icon: "search-16", class: "suggestion-icon suggestion-icon--suggestion" })), index.h("span", { class: "suggestion-text" }, index.h("span", { class: "suggestion-main-text" }, this.renderHighlightedText(suggestion.text, this.value)), suggestion.scope && (index.h("span", { class: "suggestion-scope" }, "\u2013 ", suggestion.scope))), suggestion.resultCount !== undefined && suggestion.scope && (index.h("span", { class: "suggestion-count" }, suggestion.resultCount)), suggestion.type === 'history' && (index.h("ifx-icon", { icon: "cross16", class: "suggestion-delete-icon", role: "button", tabindex: "0", "aria-label": `${this.historyDeleteAriaLabel}: ${suggestion.text}`, onClick: (event) => this.handleHistoryDelete(event, suggestion.text), onKeyDown: (event) => {
|
164
392
|
if (event.key === 'Enter' || event.key === ' ') {
|
165
393
|
event.preventDefault();
|
166
394
|
this.handleHistoryDelete(event, suggestion.text);
|
@@ -1 +1 @@
|
|
1
|
-
{"file":"ifx-search-field.entry.cjs.js","mappings":";;;;;;;;;AAAA,MAAM,cAAc,GAAG,miKAAmiK,CAAC;AAC3jK,6BAAe,cAAc;;MCoBhB,WAAW;IANxB;;;;;;;QAW2B,UAAK,GAAW,EAAE,CAAC;QACpC,gBAAW,GAAqB,EAAE,CAAC;QACnC,oBAAe,GAAY,KAAK,CAAC;QACjC,mBAAc,GAAW,EAAE,CAAC;QAC5B,oBAAe,GAAW,CAAC,CAAC;QAC5B,kBAAa,GAAY,IAAI,CAAC;QAC9B,eAAU,GAAW,oBAAoB,CAAC;QAC1C,sBAAiB,GAAW,iBAAiB,CAAC;;QAG9C,cAAS,GAAkB,cAAc,CAAA;Q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AAI,CAAC,EACpE,SAAS,EAAE,CAAC,KAAK;gBACf,IAAI,KAAK,CAAC,GAAG,KAAK,OAAO,IAAI,KAAK,CAAC,GAAG,KAAK,GAAG,EAAE;oBAC9C,KAAK,CAAC,cAAc,EAAE,CAAC;oBACvB,IAAI,CAAC,mBAAmB,CAAC,KAAK,EAAE,UAAU,CAAC,IAAI,CAAC,CAAC;iBAClD;aACF,GACS,CACb,CACG,CACF,CACP,CAAC,CACE,CACP,CACG,EACN;KACH;IAED,YAAY;QACV,OAAO,GAAG,IAAI,CAAC,IAAI,EAAE,KAAK,GAAG;cACzB,yBAAyB;cACzB,EAAE,CAAC;KACR;IAED,oBAAoB;QAClB,OAAOE,kBAAU,CACf,uBAAuB,EACvB,yBAAyB,IAAI,CAAC,YAAY,EAAE,EAAE,EAC9C,GAAG,IAAI,CAAC,SAAS,GAAG,SAAS,GAAG,EAAE,EAAE,EACpC,GAAG,IAAI,CAAC,YAAY,GAAG,eAAe,GAAG,EAAE,EAAE,CAC9C,CAAC;KACH;IAED,uBAAuB,CAAC,KAAa;;QACnC,OAAOA,kBAAU,CACf,iBAAiB,EACjB;YACE,2BAA2B,EAAE,KAAK,KAAK,IAAI,CAAC,uBAAuB;YACnE,0BAA0B,EAAE,CAAA,MAAA,IAAI,CAAC,mBAAmB,CAAC,KAAK,CAAC,0CAAE,IAAI,MAAK,SAAS;SAChF,CACF,CAAC;KACH;;;;;;;;;;;","names":["isNestedInIfxComponent","detectFramework","trackComponent","h","index","classNames"],"sources":["src/components/search-field/search-field.scss?tag=ifx-search-field&encapsulation=shadow","src/components/search-field/search-field.tsx"],"sourcesContent":["@use \"~@infineon/design-system-tokens/dist/tokens\";\n@use \"../../global/font.scss\";\n\n:host {\n display: flex;\n}\n\n.search-field {\n box-sizing: border-box;\n background-color: tokens.$ifxColorBaseWhite;\n width: 100%;\n font-family: var(--ifx-font-family);\n position: relative; // Wichtig für absolute positioning des Dropdowns\n\n .search-field__wrapper {\n box-sizing: border-box;\n height: tokens.$ifxSize500;\n display: flex;\n align-items: center;\n border: 1px solid #8D8786;\n border-radius: tokens.$ifxBorderRadius12;\n padding: tokens.$ifxSpace100 tokens.$ifxSpace200;\n gap: tokens.$ifxSpace150;\n flex: none;\n order: 0;\n align-self: stretch;\n flex-grow: 0;\n position: relative;\n width: 100%;\n outline: none;\n color: tokens.$ifxColorEngineering400;\n\n &.focused {\n border: 1px solid tokens.$ifxColorOcean500;\n\n & ifx-icon {\n color: tokens.$ifxColorEngineering500;\n }\n }\n\n &.search-field__wrapper-s {\n height: 36px;\n }\n\n\n &:hover:not(.focused, :focus) {\n border: 1px solid #3C3A39;\n }\n\n &:focus {\n outline: none;\n border: 1px solid #0A8276;\n }\n\n\n .delete-icon {\n right: 12px;\n cursor: pointer;\n }\n\n input[type='text'] {\n font-style: normal;\n font-weight: 400;\n font-size: 16px;\n //line-height: 24px;\n color: #8D8786;\n border: none;\n width: 100%;\n outline: none;\n //height: 100%;\n height: 16px;\n\n &:focus {\n outline: none;\n color: #1d1d1d;\n }\n\n &:disabled {\n background-color: #EEEDED;\n }\n }\n\n &:has(input[disabled]) {\n background-color: #EEEDED;\n }\n }\n\n // Suggestions Dropdown Styles\n .suggestions-dropdown {\n position: absolute;\n top: 100%;\n left: 0;\n right: 0;\n background: tokens.$ifxColorBaseWhite;\n margin-top: tokens.$ifxSpace50;\n border: 1px solid tokens.$ifxColorEngineering200;\n box-shadow: 0px 6px 9px 0px rgba(29, 29, 29, 0.10);\n z-index: 1000;\n max-height: 300px;\n overflow-y: auto;\n container-type: inline-size; // Enable container queries\n\n .suggestions-header {\n // font: tokens.$ifxEyebrowEyebrow02; TODO\n font-family: Source Sans 3;\n font-size: 0.8125rem;\n font-weight: 600;\n line-height: 1.25rem;\n\n letter-spacing: 0.25em;\n text-transform: uppercase;\n color: tokens.$ifxColorEngineering500;\n border-bottom: 1px solid tokens.$ifxColorEngineering200;\n padding: tokens.$ifxSpace150 tokens.$ifxSpace200;\n }\n\n .suggestion-item {\n padding: tokens.$ifxSpace150 tokens.$ifxSpace200;\n cursor: pointer;\n transition: background-color 0.2s ease;\n\n &:last-child {\n border-bottom: none;\n }\n\n &:hover,\n &--selected {\n background-color: tokens.$ifxColorEngineering200;\n }\n\n .suggestion-content {\n display: flex;\n align-items: center;\n gap: tokens.$ifxSpace150;\n\n .suggestion-icon {\n color: tokens.$ifxColorEngineering500;\n flex-shrink: 0;\n\n &--history {\n color: tokens.$ifxColorEngineering500;\n }\n }\n\n .suggestion-text {\n flex: 1;\n display: flex;\n align-items: center;\n min-width: 0; // Important for flexbox truncation\n\n .suggestion-main-text {\n overflow: hidden;\n text-overflow: ellipsis;\n white-space: nowrap;\n flex-shrink: 1;\n min-width: 0;\n }\n\n .suggestion-scope {\n color: tokens.$ifxColorEngineering400;\n flex-shrink: 0; // Never truncate the scope\n white-space: nowrap;\n margin-left: tokens.$ifxSpace25; // Add space before the scope\n font-weight: tokens.$ifxFontWeightSemibold;\n font-size: tokens.$ifxFontSizeXs;\n }\n\n // When container is narrow, stack scope below main text\n @container (max-width: 320px) {\n flex-direction: column;\n align-items: flex-start;\n\n .suggestion-main-text {\n width: 100%;\n max-width: 100%;\n }\n\n .suggestion-scope {\n margin-left: 0;\n margin-top: 0;\n width: 100%;\n max-width: 100%;\n overflow: hidden;\n text-overflow: ellipsis;\n flex-shrink: 1; // Allow truncation when narrow\n }\n }\n }\n\n .suggestion-count {\n color: tokens.$ifxColorEngineering400;\n margin-left: auto;\n flex-shrink: 0;\n }\n\n .suggestion-delete-icon {\n opacity: 0;\n visibility: hidden;\n transition: opacity 0.2s ease, visibility 0.2s ease;\n cursor: pointer;\n margin-left: auto;\n flex-shrink: 0;\n color: tokens.$ifxColorEngineering500;\n\n &:hover {\n color: tokens.$ifxColorEngineering600;\n }\n }\n }\n\n &:hover {\n .suggestion-delete-icon {\n opacity: 1;\n visibility: visible;\n }\n }\n }\n }\n\n // Wrapper modifications when dropdown is open\n .search-field__wrapper.dropdown-open {\n border-radius: tokens.$ifxBorderRadius12 tokens.$ifxBorderRadius12 0 0;\n border-color: tokens.$ifxColorOcean500;\n }\n}\n","import { Component, EventEmitter, h, Event, Prop, Watch, State, Listen, Element } from '@stencil/core';\nimport { trackComponent } from '../../global/utils/tracking';\nimport { isNestedInIfxComponent } from '../../global/utils/dom-utils';\nimport { detectFramework } from '../../global/utils/framework-detection';\nimport classNames from 'classnames';\n\nexport interface SuggestionItem {\n id: string;\n text: string;\n type?: 'suggestion' | 'history';\n scope?: string;\n resultCount?: number;\n metadata?: any;\n}\n\n@Component({\n tag: 'ifx-search-field',\n styleUrl: 'search-field.scss',\n shadow: true\n})\n\nexport class SearchField {\n @Element() el;\n private inputElement: HTMLInputElement;\n private dropdownElement: HTMLDivElement;\n\n @Prop({ mutable: true }) value: string = '';\n @Prop() suggestions: SuggestionItem[] = [];\n @Prop() showSuggestions: boolean = false;\n @Prop() maxSuggestions: number = 10;\n @Prop() maxHistoryItems: number = 5;\n @Prop() enableHistory: boolean = true;\n @Prop() historyKey: string = 'ifx-search-history';\n @Prop() historyHeaderText: string = 'Recent Searches';\n\n // ARIA Labels and Accessibility Props\n @Prop() ariaLabel: string | null = \"Search Field\"\n @Prop() ariaLabelledBy?: string | null;\n @Prop() ariaDescribedBy?: string | null;\n @Prop() deleteIconAriaLabel: string = 'Clear search';\n @Prop() historyDeleteAriaLabel: string = 'Remove from history';\n @Prop() dropdownAriaLabel: string = 'Search suggestions and history';\n @Prop() suggestionAriaLabel: string = 'Search suggestion';\n @Prop() historyItemAriaLabel: string = 'Search history item';\n\n @Event() ifxInput: EventEmitter<string>;\n @Event() ifxSuggestionRequested: EventEmitter<string>;\n @Event() ifxSuggestionSelected: EventEmitter<SuggestionItem>;\n @Event() ifxFocus: EventEmitter<void>;\n @Event() ifxBlur: EventEmitter<void>;\n\n @State() showDropdown: boolean = false;\n @State() filteredSuggestions: SuggestionItem[] = [];\n @State() selectedSuggestionIndex: number = -1;\n @State() searchHistory: string[] = [];\n\n @Prop() showDeleteIcon: boolean = false;\n @State() showDeleteIconInternalState: boolean = false;\n @Prop() disabled: boolean = false;\n @Prop() size: string = 'l';\n @State() isFocused: boolean = false;\n @Prop() placeholder: string = \"Search...\";\n @Prop() autocomplete: string = \"off\";\n @Prop() maxlength?: number = null;\n\n private focusEmitted: boolean = false;\n\n componentDidLoad() {\n this.loadSearchHistory();\n }\n\n @Listen('mousedown', { target: 'document' })\n handleOutsideClick(event: MouseEvent) {\n const path = event.composedPath();\n if (!path.includes(this.inputElement) && !path.includes(this.dropdownElement)) {\n this.hideDropdown();\n }\n }\n\n @Listen('keydown')\n handleKeyDown(event: KeyboardEvent) {\n if (!this.showDropdown) return;\n\n switch (event.key) {\n case 'ArrowDown':\n event.preventDefault();\n this.navigateSuggestions(1);\n break;\n case 'ArrowUp':\n event.preventDefault();\n this.navigateSuggestions(-1);\n break;\n case 'Enter':\n event.preventDefault();\n if (this.selectedSuggestionIndex >= 0) {\n this.selectSuggestion(this.filteredSuggestions[this.selectedSuggestionIndex]);\n } else {\n this.handleSearch();\n }\n break;\n case 'Escape':\n this.hideDropdown();\n break;\n }\n }\n\n @Watch('value')\n valueWatcher(newValue: string) {\n if (this.inputElement && newValue !== this.inputElement.value) {\n this.inputElement.value = newValue;\n }\n this.updateSuggestions();\n }\n\n @Watch('suggestions')\n suggestionsWatcher() {\n this.updateSuggestions();\n }\n\n\n handleInput = () => {\n const query = this.inputElement.value;\n this.value = query;\n this.ifxInput.emit(this.value);\n\n if (this.showSuggestions) {\n this.showDropdown = true;\n this.selectedSuggestionIndex = -1;\n this.requestSuggestions(query);\n }\n };\n\n handleDelete = () => {\n this.inputElement.value = '';\n this.value = \"\";\n this.ifxInput.emit(this.value);\n this.hideDropdown();\n }\n\n handleSearch = () => {\n if (this.value.trim() && this.enableHistory) {\n // Only add to history if there are actual results\n if (this.filteredSuggestions.length > 0) {\n this.addToHistory(this.value);\n }\n }\n this.hideDropdown();\n }\n\n focusInput() {\n // Don't call focus() if the input is already focused to prevent unnecessary operations\n if (document.activeElement !== this.inputElement) {\n this.inputElement.focus();\n }\n\n // Only emit focus event if it hasn't been emitted already\n if (!this.focusEmitted) {\n this.focusEmitted = true;\n this.isFocused = true;\n this.ifxFocus.emit();\n }\n\n if (this.showSuggestions) {\n // On focus without input: Show only history\n if (this.value.length === 0) {\n this.showHistoryDropdown();\n // Only show dropdown if history is actually present\n this.showDropdown = this.enableHistory && this.searchHistory.length > 0;\n } else {\n // With existing input: Normal suggestion logic\n this.updateSuggestions();\n this.showDropdown = this.filteredSuggestions.length > 0;\n }\n }\n }\n\n componentWillLoad() { \n if(!isNestedInIfxComponent(this.el)) { \n const framework = detectFramework();\n trackComponent('ifx-search-field', framework)\n }\n }\n\n componentWillUpdate() {\n if (this.value !== \"\") {\n this.showDeleteIconInternalState = true;\n } else this.showDeleteIconInternalState = false;\n }\n\n render() {\n return (\n <div\n aria-label={this.ariaLabel}\n aria-labelledby={this.ariaLabelledBy}\n aria-describedby={this.ariaDescribedBy}\n aria-disabled={this.disabled}\n aria-value={this.value}\n class='search-field'\n >\n <div\n class={this.getWrapperClassNames()}\n tabindex={1}\n onClick={() => this.focusInput()}\n >\n <ifx-icon icon=\"search-16\" class=\"search-icon\"></ifx-icon>\n <input\n ref={(el) => (this.inputElement = el)}\n type=\"text\"\n autocomplete={this.autocomplete}\n onInput={() => this.handleInput()}\n onFocus={() => this.focusInput()}\n onBlur={() => this.blurInput()}\n placeholder={this.placeholder}\n disabled={this.disabled}\n maxlength={this.maxlength}\n value={this.value}\n role=\"combobox\"\n aria-expanded={this.showDropdown}\n aria-autocomplete=\"list\"\n aria-haspopup=\"listbox\"\n aria-label={this.ariaLabel}\n aria-labelledby={this.ariaLabelledBy}\n aria-describedby={this.ariaDescribedBy}\n aria-owns={this.showDropdown ? 'suggestions-dropdown' : undefined}\n aria-activedescendant={this.selectedSuggestionIndex >= 0 ? `suggestion-${this.selectedSuggestionIndex}` : undefined}\n />\n {this.showDeleteIcon && this.showDeleteIconInternalState ? (\n <ifx-icon\n icon=\"cRemove16\"\n class=\"delete-icon\"\n onClick={this.handleDelete}\n role=\"button\"\n tabindex=\"0\"\n aria-label={this.deleteIconAriaLabel}\n onKeyDown={(event) => {\n if (event.key === 'Enter' || event.key === ' ') {\n event.preventDefault();\n this.handleDelete();\n }\n }}>\n </ifx-icon>\n ) : null}\n </div>\n\n {/* Suggestions Dropdown */}\n {this.showDropdown && this.filteredSuggestions.length > 0 && (\n <div\n ref={(el) => (this.dropdownElement = el)}\n id=\"suggestions-dropdown\"\n class=\"suggestions-dropdown\"\n role=\"listbox\"\n aria-label={this.dropdownAriaLabel}\n >\n {/* History Header - only show when exclusively showing history entries */}\n {this.isShowingOnlyHistory() && (\n <div class=\"suggestions-header\">\n {this.historyHeaderText}\n </div>\n )}\n\n {this.filteredSuggestions.map((suggestion, index) => (\n <div\n key={suggestion.id}\n id={`suggestion-${index}`}\n class={this.getSuggestionClassNames(index)}\n role=\"option\"\n aria-selected={index === this.selectedSuggestionIndex}\n aria-label={`${suggestion.type === 'history' ? this.historyItemAriaLabel : this.suggestionAriaLabel}: ${suggestion.text}${suggestion.scope ? `, ${suggestion.scope}` : ''}${suggestion.resultCount ? `, ${suggestion.resultCount} results` : ''}`}\n onClick={() => this.selectSuggestion(suggestion)}\n onMouseEnter={() => this.selectedSuggestionIndex = index}\n >\n <div class=\"suggestion-content\">\n {suggestion.type === 'history' && (\n <ifx-icon icon=\"history-16\" class=\"suggestion-icon suggestion-icon--history\"></ifx-icon>\n )}\n {suggestion.type === 'suggestion' && (\n <ifx-icon icon=\"search-16\" class=\"suggestion-icon suggestion-icon--suggestion\"></ifx-icon>\n )}\n <span class=\"suggestion-text\">\n <span class=\"suggestion-main-text\">\n {this.renderHighlightedText(suggestion.text, this.value)}\n </span>\n {suggestion.scope && (\n <span class=\"suggestion-scope\">– {suggestion.scope}</span>\n )}\n </span>\n\n {suggestion.resultCount !== undefined && suggestion.scope && (\n <span class=\"suggestion-count\">{suggestion.resultCount}</span>\n )}\n\n {/* Delete Button only for history entries */}\n {suggestion.type === 'history' && (\n <ifx-icon\n icon=\"cross16\"\n class=\"suggestion-delete-icon\"\n role=\"button\"\n tabindex=\"0\"\n aria-label={`${this.historyDeleteAriaLabel}: ${suggestion.text}`}\n onClick={(event) => this.handleHistoryDelete(event, suggestion.text)}\n onKeyDown={(event) => {\n if (event.key === 'Enter' || event.key === ' ') {\n event.preventDefault();\n this.handleHistoryDelete(event, suggestion.text);\n }\n }}\n ></ifx-icon>\n )}\n </div>\n </div>\n ))}\n </div>\n )}\n </div>\n );\n }\n\n getSizeClass() {\n return `${this.size}` === \"s\"\n ? \"search-field__wrapper-s\"\n : \"\";\n }\n\n getWrapperClassNames() {\n return classNames(\n `search-field__wrapper`,\n `search-field__wrapper ${this.getSizeClass()}`,\n `${this.isFocused ? 'focused' : \"\"}`,\n `${this.showDropdown ? 'dropdown-open' : \"\"}`\n );\n }\n\n getSuggestionClassNames(index: number) {\n return classNames(\n 'suggestion-item',\n {\n 'suggestion-item--selected': index === this.selectedSuggestionIndex,\n 'suggestion-item--history': this.filteredSuggestions[index]?.type === 'history'\n }\n );\n }\n}\n"],"version":3}
|
1
|
+
{"file":"ifx-search-field.entry.cjs.js","mappings":";;;;;;;;;AAAA,MAAM,cAAc,GAAG,miKAAmiK,CAAC;AAC3jK,6BAAe,cAAc;;MCoBhB,WAAW;IANxB;;;;;;;QAW2B,UAAK,GAAW,EAAE,CAAC;QACpC,gBAAW,GAAqB,EAAE,CAAC;QACnC,oBAAe,GAAY,KAAK,CAAC;QACjC,mBAAc,GAAW,EAAE,CAAC;QAC5B,oBAAe,GAAW,CAAC,CAAC;QAC5B,kBAAa,GAAY,IAAI,CAAC;QAC9B,eAAU,GAAW,oBAAoB,CAAC;QAC1C,sBAAiB,GAAW,iBAAiB,CAAC;;QAG9C,cAAS,GAAkB,cAAc,CAAA;QAGzC,wBAAmB,GAAW,cAAc,CAAC;QAC7C,2BAAsB,GAAW,qBAAqB,CAAC;QACvD,sBAAiB,G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G,IAAI,CAAC,SAAS,GAAG,SAAS,GAAG,EAAE,EAAE,EACpC,GAAG,IAAI,CAAC,YAAY,GAAG,eAAe,GAAG,EAAE,EAAE,CAC9C,CAAC;KACH;IAED,uBAAuB,CAAC,KAAa;;QACnC,OAAOA,kBAAU,CACf,iBAAiB,EACjB;YACE,2BAA2B,EAAE,KAAK,KAAK,IAAI,CAAC,uBAAuB;YACnE,0BAA0B,EAAE,CAAA,MAAA,IAAI,CAAC,mBAAmB,CAAC,KAAK,CAAC,0CAAE,IAAI,MAAK,SAAS;SAChF,CACF,CAAC;KACH;;;;;;;;;;;","names":["index","h","isNestedInIfxComponent","detectFramework","trackComponent","classNames"],"sources":["src/components/search-field/search-field.scss?tag=ifx-search-field&encapsulation=shadow","src/components/search-field/search-field.tsx"],"sourcesContent":["@use \"~@infineon/design-system-tokens/dist/tokens\";\n@use \"../../global/font.scss\";\n\n:host {\n display: flex;\n}\n\n.search-field {\n box-sizing: border-box;\n background-color: tokens.$ifxColorBaseWhite;\n width: 100%;\n font-family: var(--ifx-font-family);\n position: relative; // Wichtig für absolute positioning des Dropdowns\n\n .search-field__wrapper {\n box-sizing: border-box;\n height: tokens.$ifxSize500;\n display: flex;\n align-items: center;\n border: 1px solid #8D8786;\n border-radius: tokens.$ifxBorderRadius12;\n padding: tokens.$ifxSpace100 tokens.$ifxSpace200;\n gap: tokens.$ifxSpace150;\n flex: none;\n order: 0;\n align-self: stretch;\n flex-grow: 0;\n position: relative;\n width: 100%;\n outline: none;\n color: tokens.$ifxColorEngineering400;\n\n &.focused {\n border: 1px solid tokens.$ifxColorOcean500;\n\n & ifx-icon {\n color: tokens.$ifxColorEngineering500;\n }\n }\n\n &.search-field__wrapper-s {\n height: 36px;\n }\n\n\n &:hover:not(.focused, :focus) {\n border: 1px solid #3C3A39;\n }\n\n &:focus {\n outline: none;\n border: 1px solid #0A8276;\n }\n\n\n .delete-icon {\n right: 12px;\n cursor: pointer;\n }\n\n input[type='text'] {\n font-style: normal;\n font-weight: 400;\n font-size: 16px;\n //line-height: 24px;\n color: #8D8786;\n border: none;\n width: 100%;\n outline: none;\n //height: 100%;\n height: 16px;\n\n &:focus {\n outline: none;\n color: #1d1d1d;\n }\n\n &:disabled {\n background-color: #EEEDED;\n }\n }\n\n &:has(input[disabled]) {\n background-color: #EEEDED;\n }\n }\n\n // Suggestions Dropdown Styles\n .suggestions-dropdown {\n position: absolute;\n top: 100%;\n left: 0;\n right: 0;\n background: tokens.$ifxColorBaseWhite;\n margin-top: tokens.$ifxSpace50;\n border: 1px solid tokens.$ifxColorEngineering200;\n box-shadow: 0px 6px 9px 0px rgba(29, 29, 29, 0.10);\n z-index: 1000;\n max-height: 300px;\n overflow-y: auto;\n container-type: inline-size; // Enable container queries\n\n .suggestions-header {\n // font: tokens.$ifxEyebrowEyebrow02; TODO\n font-family: Source Sans 3;\n font-size: 0.8125rem;\n font-weight: 600;\n line-height: 1.25rem;\n\n letter-spacing: 0.25em;\n text-transform: uppercase;\n color: tokens.$ifxColorEngineering500;\n border-bottom: 1px solid tokens.$ifxColorEngineering200;\n padding: tokens.$ifxSpace150 tokens.$ifxSpace200;\n }\n\n .suggestion-item {\n padding: tokens.$ifxSpace150 tokens.$ifxSpace200;\n cursor: pointer;\n transition: background-color 0.2s ease;\n\n &:last-child {\n border-bottom: none;\n }\n\n &:hover,\n &--selected {\n background-color: tokens.$ifxColorEngineering200;\n }\n\n .suggestion-content {\n display: flex;\n align-items: center;\n gap: tokens.$ifxSpace150;\n\n .suggestion-icon {\n color: tokens.$ifxColorEngineering500;\n flex-shrink: 0;\n\n &--history {\n color: tokens.$ifxColorEngineering500;\n }\n }\n\n .suggestion-text {\n flex: 1;\n display: flex;\n align-items: center;\n min-width: 0; // Important for flexbox truncation\n\n .suggestion-main-text {\n overflow: hidden;\n text-overflow: ellipsis;\n white-space: nowrap;\n flex-shrink: 1;\n min-width: 0;\n }\n\n .suggestion-scope {\n color: tokens.$ifxColorEngineering400;\n flex-shrink: 0; // Never truncate the scope\n white-space: nowrap;\n margin-left: tokens.$ifxSpace25; // Add space before the scope\n font-weight: tokens.$ifxFontWeightSemibold;\n font-size: tokens.$ifxFontSizeXs;\n }\n\n // When container is narrow, stack scope below main text\n @container (max-width: 320px) {\n flex-direction: column;\n align-items: flex-start;\n\n .suggestion-main-text {\n width: 100%;\n max-width: 100%;\n }\n\n .suggestion-scope {\n margin-left: 0;\n margin-top: 0;\n width: 100%;\n max-width: 100%;\n overflow: hidden;\n text-overflow: ellipsis;\n flex-shrink: 1; // Allow truncation when narrow\n }\n }\n }\n\n .suggestion-count {\n color: tokens.$ifxColorEngineering400;\n margin-left: auto;\n flex-shrink: 0;\n }\n\n .suggestion-delete-icon {\n opacity: 0;\n visibility: hidden;\n transition: opacity 0.2s ease, visibility 0.2s ease;\n cursor: pointer;\n margin-left: auto;\n flex-shrink: 0;\n color: tokens.$ifxColorEngineering500;\n\n &:hover {\n color: tokens.$ifxColorEngineering600;\n }\n }\n }\n\n &:hover {\n .suggestion-delete-icon {\n opacity: 1;\n visibility: visible;\n }\n }\n }\n }\n\n // Wrapper modifications when dropdown is open\n .search-field__wrapper.dropdown-open {\n border-radius: tokens.$ifxBorderRadius12 tokens.$ifxBorderRadius12 0 0;\n border-color: tokens.$ifxColorOcean500;\n }\n}\n","import { Component, EventEmitter, h, Event, Prop, Watch, State, Listen, Element } from '@stencil/core';\nimport { trackComponent } from '../../global/utils/tracking';\nimport { isNestedInIfxComponent } from '../../global/utils/dom-utils';\nimport { detectFramework } from '../../global/utils/framework-detection';\nimport classNames from 'classnames';\n\nexport interface SuggestionItem {\n id: string;\n text: string;\n type?: 'suggestion' | 'history';\n scope?: string;\n resultCount?: number;\n metadata?: any;\n}\n\n@Component({\n tag: 'ifx-search-field',\n styleUrl: 'search-field.scss',\n shadow: true\n})\n\nexport class SearchField {\n @Element() el;\n private inputElement: HTMLInputElement;\n private dropdownElement: HTMLDivElement;\n\n @Prop({ mutable: true }) value: string = '';\n @Prop() suggestions: SuggestionItem[] = [];\n @Prop() showSuggestions: boolean = false;\n @Prop() maxSuggestions: number = 10;\n @Prop() maxHistoryItems: number = 5;\n @Prop() enableHistory: boolean = true;\n @Prop() historyKey: string = 'ifx-search-history';\n @Prop() historyHeaderText: string = 'Recent Searches';\n\n // ARIA Labels and Accessibility Props\n @Prop() ariaLabel: string | null = \"Search Field\"\n @Prop() ariaLabelledBy?: string | null;\n @Prop() ariaDescribedBy?: string | null;\n @Prop() deleteIconAriaLabel: string = 'Clear search';\n @Prop() historyDeleteAriaLabel: string = 'Remove from history';\n @Prop() dropdownAriaLabel: string = 'Search suggestions and history';\n @Prop() suggestionAriaLabel: string = 'Search suggestion';\n @Prop() historyItemAriaLabel: string = 'Search history item';\n\n @Event() ifxInput: EventEmitter<string>;\n @Event() ifxSuggestionRequested: EventEmitter<string>;\n @Event() ifxSuggestionSelected: EventEmitter<SuggestionItem>;\n @Event() ifxFocus: EventEmitter<void>;\n @Event() ifxBlur: EventEmitter<void>;\n\n @State() showDropdown: boolean = false;\n @State() filteredSuggestions: SuggestionItem[] = [];\n @State() selectedSuggestionIndex: number = -1;\n @State() searchHistory: string[] = [];\n\n @Prop() showDeleteIcon: boolean = false;\n @State() showDeleteIconInternalState: boolean = false;\n @Prop() disabled: boolean = false;\n @Prop() size: string = 'l';\n @State() isFocused: boolean = false;\n @Prop() placeholder: string = \"Search...\";\n @Prop() autocomplete: string = \"off\";\n @Prop() maxlength?: number = null;\n\n private focusEmitted: boolean = false;\n\n componentDidLoad() {\n this.loadSearchHistory();\n }\n\n @Listen('mousedown', { target: 'document' })\n handleOutsideClick(event: MouseEvent) {\n const path = event.composedPath();\n if (!path.includes(this.inputElement) && !path.includes(this.dropdownElement)) {\n this.hideDropdown();\n }\n }\n\n @Listen('keydown')\n handleKeyDown(event: KeyboardEvent) {\n if (!this.showDropdown) return;\n\n switch (event.key) {\n case 'ArrowDown':\n event.preventDefault();\n this.navigateSuggestions(1);\n break;\n case 'ArrowUp':\n event.preventDefault();\n this.navigateSuggestions(-1);\n break;\n case 'Enter':\n event.preventDefault();\n if (this.selectedSuggestionIndex >= 0) {\n this.selectSuggestion(this.filteredSuggestions[this.selectedSuggestionIndex]);\n } else {\n this.handleSearch();\n }\n break;\n case 'Escape':\n this.hideDropdown();\n break;\n }\n }\n\n @Watch('value')\n valueWatcher(newValue: string) {\n if (this.inputElement && newValue !== this.inputElement.value) {\n this.inputElement.value = newValue;\n }\n this.updateSuggestions();\n }\n\n @Watch('suggestions')\n suggestionsWatcher() {\n this.updateSuggestions();\n }\n\n\n handleInput = () => {\n const query = this.inputElement.value;\n this.value = query;\n this.ifxInput.emit(this.value);\n\n if (this.showSuggestions) {\n this.showDropdown = true;\n this.selectedSuggestionIndex = -1;\n this.requestSuggestions(query);\n }\n };\n\n handleDelete = () => {\n this.inputElement.value = '';\n this.value = \"\";\n this.ifxInput.emit(this.value);\n this.hideDropdown();\n }\n\n handleSearch = () => {\n if (this.value.trim() && this.enableHistory) {\n // Only add to history if there are actual results\n if (this.filteredSuggestions.length > 0) {\n this.addToHistory(this.value);\n }\n }\n this.hideDropdown();\n }\n\n focusInput() {\n // Don't call focus() if the input is already focused to prevent unnecessary operations\n if (document.activeElement !== this.inputElement) {\n this.inputElement.focus();\n }\n\n // Only emit focus event if it hasn't been emitted already\n if (!this.focusEmitted) {\n this.focusEmitted = true;\n this.isFocused = true;\n this.ifxFocus.emit();\n }\n\n if (this.showSuggestions) {\n // On focus without input: Show only history\n if (this.value.length === 0) {\n this.showHistoryDropdown();\n // Only show dropdown if history is actually present\n this.showDropdown = this.enableHistory && this.searchHistory.length > 0;\n } else {\n // With existing input: Normal suggestion logic\n this.updateSuggestions();\n this.showDropdown = this.filteredSuggestions.length > 0;\n }\n }\n }\n\n blurInput() {\n setTimeout(() => {\n this.isFocused = false;\n this.focusEmitted = false; // Reset focus flag when blur occurs\n this.ifxBlur.emit();\n }, 150);\n }\n\n // Public method to update history from external sources\n public loadSearchHistory() {\n if (this.enableHistory && typeof localStorage !== 'undefined') {\n const stored = localStorage.getItem(this.historyKey);\n this.searchHistory = stored ? JSON.parse(stored) : [];\n\n // Update suggestions when history is loaded\n this.updateSuggestions();\n\n // If no input and no history left, close dropdown\n if (this.value.length === 0 && this.searchHistory.length === 0) {\n this.showDropdown = false;\n }\n }\n }\n\n // Public method to completely clear history\n public clearSearchHistory() {\n if (this.enableHistory && typeof localStorage !== 'undefined') {\n // Clear from localStorage\n localStorage.removeItem(this.historyKey);\n\n // Clear internal history\n this.searchHistory = [];\n\n // Reset all dropdown-relevant states\n this.filteredSuggestions = [];\n this.selectedSuggestionIndex = -1;\n this.showDropdown = false;\n\n // Update suggestions after reset\n this.updateSuggestions();\n }\n }\n\n // Suggestion Management Methods\n private addToHistory(term: string) {\n if (!this.enableHistory || !term.trim()) return;\n\n const history = [...this.searchHistory];\n const existingIndex = history.indexOf(term);\n\n if (existingIndex > -1) {\n history.splice(existingIndex, 1);\n }\n\n history.unshift(term);\n // Limit history to maxHistoryItems (default 5)\n this.searchHistory = history.slice(0, this.maxHistoryItems);\n\n if (typeof localStorage !== 'undefined') {\n localStorage.setItem(this.historyKey, JSON.stringify(this.searchHistory));\n }\n }\n\n // Remove individual history entry\n private removeFromHistory(term: string) {\n if (!this.enableHistory) return;\n\n const history = [...this.searchHistory];\n const index = history.indexOf(term);\n\n if (index > -1) {\n history.splice(index, 1);\n this.searchHistory = history;\n\n // Update localStorage\n if (typeof localStorage !== 'undefined') {\n localStorage.setItem(this.historyKey, JSON.stringify(this.searchHistory));\n }\n\n // Update suggestions after removal\n this.updateSuggestions();\n\n // Close dropdown if no history remains\n if (this.searchHistory.length === 0 && this.value.length === 0) {\n this.showDropdown = false;\n }\n }\n }\n\n // Handle click on history delete button\n private handleHistoryDelete = (event: Event, term: string) => {\n event.stopPropagation(); // Prevent selection of the entry\n this.removeFromHistory(term);\n }\n\n private requestSuggestions(query: string) {\n this.ifxSuggestionRequested.emit(query);\n this.updateSuggestions();\n }\n\n private updateSuggestions() {\n const query = this.value.toLowerCase();\n let suggestions: SuggestionItem[] = [];\n\n if (query.length > 0) {\n // For text input: Mix external suggestions and relevant history\n\n // 1. Filter external suggestions\n if (this.suggestions && this.suggestions.length > 0) {\n const filteredExternal = this.suggestions.filter(s =>\n s.text.toLowerCase().includes(query)\n );\n suggestions = [...suggestions, ...filteredExternal];\n }\n\n // 2. Filter relevant history entries\n if (this.enableHistory && this.searchHistory.length > 0) {\n const filteredHistory = this.searchHistory\n .filter(term => term.toLowerCase().includes(query))\n .map((term, index) => ({\n id: `history-${index}`,\n text: term,\n type: 'history' as const\n }));\n suggestions = [...suggestions, ...filteredHistory];\n }\n\n // 3. Sort by relevance (exact matches first, then prefix matches)\n suggestions.sort((a, b) => {\n const aText = a.text.toLowerCase();\n const bText = b.text.toLowerCase();\n\n // Exact match has highest priority\n if (aText === query && bText !== query) return -1;\n if (bText === query && aText !== query) return 1;\n\n // Prefix match has second highest priority\n const aStartsWith = aText.startsWith(query);\n const bStartsWith = bText.startsWith(query);\n\n if (aStartsWith && !bStartsWith) return -1;\n if (bStartsWith && !aStartsWith) return 1;\n\n // With equal relevance: external suggestions before history\n if (a.type === 'suggestion' && b.type === 'history') return -1;\n if (a.type === 'history' && b.type === 'suggestion') return 1;\n\n // Alphabetical sorting as last criterion\n return aText.localeCompare(bText);\n });\n\n } else {\n // For empty query: Show only history (no external suggestions)\n if (this.enableHistory && this.searchHistory.length > 0) {\n const historySuggestions = this.searchHistory.map((term, index) => ({\n id: `history-${index}`,\n text: term,\n type: 'history' as const\n }));\n\n suggestions = historySuggestions;\n }\n // For empty query DO NOT show external suggestions\n }\n\n // Remove duplicates based on text and scope combination (history takes precedence over external)\n const uniqueSuggestions = suggestions.reduce((unique: SuggestionItem[], current) => {\n const existingIndex = unique.findIndex(item =>\n item.text.toLowerCase() === current.text.toLowerCase() &&\n item.scope === current.scope\n );\n if (existingIndex === -1) {\n unique.push(current);\n } else {\n // If already exists, prefer history over external suggestions\n if (current.type === 'history' && unique[existingIndex].type !== 'history') {\n unique[existingIndex] = current;\n }\n }\n return unique;\n }, []);\n\n this.filteredSuggestions = uniqueSuggestions.slice(0, this.maxSuggestions);\n this.selectedSuggestionIndex = -1;\n }\n\n private navigateSuggestions(direction: number) {\n const maxIndex = this.filteredSuggestions.length - 1;\n\n if (direction > 0) {\n this.selectedSuggestionIndex = this.selectedSuggestionIndex < maxIndex\n ? this.selectedSuggestionIndex + 1\n : 0;\n } else {\n this.selectedSuggestionIndex = this.selectedSuggestionIndex > 0\n ? this.selectedSuggestionIndex - 1\n : maxIndex;\n }\n }\n\n private selectSuggestion(suggestion: SuggestionItem) {\n this.value = suggestion.text;\n this.inputElement.value = suggestion.text;\n this.ifxSuggestionSelected.emit(suggestion);\n this.ifxInput.emit(this.value);\n\n if (this.enableHistory) {\n // Always add selected suggestions to history since they are valid results\n this.addToHistory(suggestion.text);\n }\n\n this.hideDropdown();\n }\n\n private hideDropdown() {\n this.showDropdown = false;\n this.selectedSuggestionIndex = -1;\n this.isFocused = false;\n }\n\n // Show only history in dropdown (e.g. on focus without input)\n private showHistoryDropdown() {\n if (this.enableHistory && this.searchHistory.length > 0) {\n // Show only history entries\n const historySuggestions = this.searchHistory.map((term, index) => ({\n id: `history-${index}`,\n text: term,\n type: 'history' as const\n }));\n\n this.filteredSuggestions = historySuggestions.slice(0, this.maxSuggestions);\n this.selectedSuggestionIndex = -1;\n } else {\n this.filteredSuggestions = [];\n }\n }\n\n // Check if only history entries are displayed (without text input)\n private isShowingOnlyHistory(): boolean {\n return this.value.length === 0 &&\n this.filteredSuggestions.length > 0 &&\n this.filteredSuggestions.every(s => s.type === 'history');\n }\n\n // Render text with highlighted matches\n private renderHighlightedText(text: string, query: string) {\n if (!query || query.length === 0) {\n return text;\n }\n\n const lowerText = text.toLowerCase();\n const lowerQuery = query.toLowerCase();\n const index = lowerText.indexOf(lowerQuery);\n\n if (index === -1) {\n return text;\n }\n\n const before = text.substring(0, index);\n const match = text.substring(index, index + query.length);\n const after = text.substring(index + query.length);\n\n return [\n before,\n <strong>{match}</strong>,\n after\n ];\n }\n\n componentWillLoad() {\n if(!isNestedInIfxComponent(this.el)) {\n const framework = detectFramework()\n trackComponent('ifx-search-field', framework)\n }\n }\n\n componentWillUpdate() {\n if (this.value !== \"\") {\n this.showDeleteIconInternalState = true;\n } else this.showDeleteIconInternalState = false;\n }\n\n render() {\n return (\n <div\n aria-label={this.ariaLabel}\n aria-labelledby={this.ariaLabelledBy}\n aria-describedby={this.ariaDescribedBy}\n aria-disabled={this.disabled}\n aria-value={this.value}\n class='search-field'\n >\n <div\n class={this.getWrapperClassNames()}\n tabindex={1}\n onClick={() => this.focusInput()}\n >\n <ifx-icon icon=\"search-16\" class=\"search-icon\"></ifx-icon>\n <input\n ref={(el) => (this.inputElement = el)}\n type=\"text\"\n autocomplete={this.autocomplete}\n onInput={() => this.handleInput()}\n onFocus={() => this.focusInput()}\n onBlur={() => this.blurInput()}\n placeholder={this.placeholder}\n disabled={this.disabled}\n maxlength={this.maxlength}\n value={this.value}\n role=\"combobox\"\n aria-expanded={this.showDropdown}\n aria-autocomplete=\"list\"\n aria-haspopup=\"listbox\"\n aria-label={this.ariaLabel}\n aria-labelledby={this.ariaLabelledBy}\n aria-describedby={this.ariaDescribedBy}\n aria-owns={this.showDropdown ? 'suggestions-dropdown' : undefined}\n aria-activedescendant={this.selectedSuggestionIndex >= 0 ? `suggestion-${this.selectedSuggestionIndex}` : undefined}\n />\n {this.showDeleteIcon && this.showDeleteIconInternalState ? (\n <ifx-icon\n icon=\"cRemove16\"\n class=\"delete-icon\"\n onClick={this.handleDelete}\n role=\"button\"\n tabindex=\"0\"\n aria-label={this.deleteIconAriaLabel}\n onKeyDown={(event) => {\n if (event.key === 'Enter' || event.key === ' ') {\n event.preventDefault();\n this.handleDelete();\n }\n }}>\n </ifx-icon>\n ) : null}\n </div>\n\n {/* Suggestions Dropdown */}\n {this.showDropdown && this.filteredSuggestions.length > 0 && (\n <div\n ref={(el) => (this.dropdownElement = el)}\n id=\"suggestions-dropdown\"\n class=\"suggestions-dropdown\"\n role=\"listbox\"\n aria-label={this.dropdownAriaLabel}\n >\n {/* History Header - only show when exclusively showing history entries */}\n {this.isShowingOnlyHistory() && (\n <div class=\"suggestions-header\">\n {this.historyHeaderText}\n </div>\n )}\n\n {this.filteredSuggestions.map((suggestion, index) => (\n <div\n key={suggestion.id}\n id={`suggestion-${index}`}\n class={this.getSuggestionClassNames(index)}\n role=\"option\"\n aria-selected={index === this.selectedSuggestionIndex}\n aria-label={`${suggestion.type === 'history' ? this.historyItemAriaLabel : this.suggestionAriaLabel}: ${suggestion.text}${suggestion.scope ? `, ${suggestion.scope}` : ''}${suggestion.resultCount ? `, ${suggestion.resultCount} results` : ''}`}\n onClick={() => this.selectSuggestion(suggestion)}\n onMouseEnter={() => this.selectedSuggestionIndex = index}\n >\n <div class=\"suggestion-content\">\n {suggestion.type === 'history' && (\n <ifx-icon icon=\"history-16\" class=\"suggestion-icon suggestion-icon--history\"></ifx-icon>\n )}\n {suggestion.type === 'suggestion' && (\n <ifx-icon icon=\"search-16\" class=\"suggestion-icon suggestion-icon--suggestion\"></ifx-icon>\n )}\n <span class=\"suggestion-text\">\n <span class=\"suggestion-main-text\">\n {this.renderHighlightedText(suggestion.text, this.value)}\n </span>\n {suggestion.scope && (\n <span class=\"suggestion-scope\">– {suggestion.scope}</span>\n )}\n </span>\n\n {suggestion.resultCount !== undefined && suggestion.scope && (\n <span class=\"suggestion-count\">{suggestion.resultCount}</span>\n )}\n\n {/* Delete Button only for history entries */}\n {suggestion.type === 'history' && (\n <ifx-icon\n icon=\"cross16\"\n class=\"suggestion-delete-icon\"\n role=\"button\"\n tabindex=\"0\"\n aria-label={`${this.historyDeleteAriaLabel}: ${suggestion.text}`}\n onClick={(event) => this.handleHistoryDelete(event, suggestion.text)}\n onKeyDown={(event) => {\n if (event.key === 'Enter' || event.key === ' ') {\n event.preventDefault();\n this.handleHistoryDelete(event, suggestion.text);\n }\n }}\n ></ifx-icon>\n )}\n </div>\n </div>\n ))}\n </div>\n )}\n </div>\n );\n }\n\n getSizeClass() {\n return `${this.size}` === \"s\"\n ? \"search-field__wrapper-s\"\n : \"\";\n }\n\n getWrapperClassNames() {\n return classNames(\n `search-field__wrapper`,\n `search-field__wrapper ${this.getSizeClass()}`,\n `${this.isFocused ? 'focused' : \"\"}`,\n `${this.showDropdown ? 'dropdown-open' : \"\"}`\n );\n }\n\n getSuggestionClassNames(index: number) {\n return classNames(\n 'suggestion-item',\n {\n 'suggestion-item--selected': index === this.selectedSuggestionIndex,\n 'suggestion-item--history': this.filteredSuggestions[index]?.type === 'history'\n }\n );\n }\n}\n"],"version":3}
|