@onsvisual/svelte-components 1.0.60 → 1.0.61
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.
|
@@ -90,7 +90,7 @@
|
|
|
90
90
|
*/
|
|
91
91
|
export let loadOptions = (query, populateResults) => {
|
|
92
92
|
const filteredResults =
|
|
93
|
-
mode !== "search" && options.map((opt) => opt[labelKey]).includes(query)
|
|
93
|
+
mode !== "search" && (!query || options.map((opt) => opt[labelKey]).includes(query))
|
|
94
94
|
? options
|
|
95
95
|
: options.filter((opt) =>
|
|
96
96
|
opt[labelKey].match(new RegExp(`\\b${query.replace(/[^\w\s]/gi, "")}`, "i"))
|
|
@@ -135,14 +135,11 @@
|
|
|
135
135
|
|
|
136
136
|
function suggestionTemplate(result) {
|
|
137
137
|
const query = inputElement?.value || "";
|
|
138
|
-
return
|
|
139
|
-
result
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
}</span>`
|
|
144
|
-
: highlight(result?.[labelKey] || "", query))
|
|
145
|
-
);
|
|
138
|
+
return groupKey && result[groupKey]
|
|
139
|
+
? `${highlight(result?.[labelKey] || "", query)} <span class="muted-text">${
|
|
140
|
+
result[groupKey]
|
|
141
|
+
}</span>`
|
|
142
|
+
: highlight(result?.[labelKey] || "", query);
|
|
146
143
|
}
|
|
147
144
|
|
|
148
145
|
async function select(option) {
|
|
@@ -161,7 +158,8 @@
|
|
|
161
158
|
}
|
|
162
159
|
|
|
163
160
|
async function initAutocomplete(element) {
|
|
164
|
-
if (!accessibleAutocomplete)
|
|
161
|
+
if (!accessibleAutocomplete)
|
|
162
|
+
accessibleAutocomplete = (await import("accessible-autocomplete")).default;
|
|
165
163
|
|
|
166
164
|
accessibleAutocomplete({
|
|
167
165
|
element,
|
|
@@ -204,7 +202,7 @@
|
|
|
204
202
|
|
|
205
203
|
{#if renderFallback && !mounted}
|
|
206
204
|
{#if mode === "search"}
|
|
207
|
-
<Input {id} {name} {label} {hideLabel} value={value?.[labelKey]} width={null}/>
|
|
205
|
+
<Input {id} {name} {label} {hideLabel} value={value?.[labelKey]} width={null} />
|
|
208
206
|
{:else}
|
|
209
207
|
<Dropdown {id} {name} {options} {label} {hideLabel} {placeholder} {value} width={null} />
|
|
210
208
|
{/if}
|