@threadlabs/looma 0.14.7 → 0.14.8
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/components/ui-combobox/ui-combobox.html +4 -0
- package/components/ui-combobox/ui-combobox.js +6 -3
- package/dist/index.js +1 -1
- package/package.json +1 -1
- package/vanilla/UiCombobox.d.ts +1 -0
- package/vanilla/UiCombobox.js +1 -1
- package/vue/UiCombobox.d.ts +2 -0
- package/vue/UiCombobox.vue +2 -0
- package/vue/chunks/UiCombobox.js +2 -1
- package/vue/components.css +53 -53
|
@@ -33,6 +33,10 @@
|
|
|
33
33
|
<prop name="query" type="string"
|
|
34
34
|
>The input's text, when the consumer controls it. Once set, the consumer owns the text: typing reports query-change, and the input returns to query unless
|
|
35
35
|
query is updated to match. Leave it unset to let the combobox manage its own text, showing the chosen option's label.</prop>
|
|
36
|
+
<prop name="filter" type="label | none" default="label"
|
|
37
|
+
>How the list narrows as the user types. label lists the options whose label contains the typed text, ignoring case. none lists every authored option, for
|
|
38
|
+
options already narrowed elsewhere, such as a server search, so a result that matched on data other than its label still shows. Leaving the field still
|
|
39
|
+
commits an option whose label matches the text, or the only one listed.</prop>
|
|
36
40
|
<prop name="allowFreeText" type="boolean" default="false">Allows values that do not match an authored option.</prop>
|
|
37
41
|
<prop name="allowCreate" type="boolean" default="false"
|
|
38
42
|
>Offers the current query as a new option, reported as create-item. When nothing else matches, the offer is highlighted, so Enter creates it; with nothing
|
|
@@ -55,6 +55,8 @@ export default function controller(host) {
|
|
|
55
55
|
options: authoredOptions(authored),
|
|
56
56
|
allowFreeText: Boolean(host.state.allowFreeText),
|
|
57
57
|
allowCreate: Boolean(host.state.allowCreate),
|
|
58
|
+
// "none": the consumer already narrowed the options (a server search), so every one is listed.
|
|
59
|
+
filterByLabel: host.state.filter !== "none",
|
|
58
60
|
});
|
|
59
61
|
// Selected items work uncontrolled: the component keeps them and reports every change. A consumer
|
|
60
62
|
// that owns `items` stays in charge, because the prop resyncs whatever it sets. A consumer that sets
|
|
@@ -149,7 +151,7 @@ export default function controller(host) {
|
|
|
149
151
|
const filtered = options.filter((option) => {
|
|
150
152
|
if (ids.has(option.id)) return false;
|
|
151
153
|
ids.add(option.id);
|
|
152
|
-
if (fullSet) return true;
|
|
154
|
+
if (fullSet || !current.filterByLabel) return true;
|
|
153
155
|
return option.label.toLocaleLowerCase().includes(query.toLocaleLowerCase());
|
|
154
156
|
}).map((option) => ({
|
|
155
157
|
...option,
|
|
@@ -267,7 +269,8 @@ export default function controller(host) {
|
|
|
267
269
|
};
|
|
268
270
|
// A strict combobox (single, no free text, no create) behaves like a select: leaving it resolves the
|
|
269
271
|
// typed text to a valid option (the highlighted one, an exact label, the first label it begins, or the
|
|
270
|
-
// only remaining option); with no match it reverts to the previous selection, or clears.
|
|
272
|
+
// only remaining option); with no match it reverts to the previous selection, or clears. With filter
|
|
273
|
+
// "none" the remaining options are all of them, whatever their labels, so the only one listed counts.
|
|
271
274
|
const resolveTyped = (trigger) => {
|
|
272
275
|
const current = config();
|
|
273
276
|
if (host.state.multiple || current.allowFreeText || current.allowCreate) return;
|
|
@@ -285,7 +288,7 @@ export default function controller(host) {
|
|
|
285
288
|
?? enabled.find((row) => row.label.toLocaleLowerCase() === query)
|
|
286
289
|
?? enabled.find((row) => row.label.toLocaleLowerCase().startsWith(query))
|
|
287
290
|
?? (() => {
|
|
288
|
-
const containing = enabled.filter((option) => option.label.toLocaleLowerCase().includes(query));
|
|
291
|
+
const containing = current.filterByLabel ? enabled.filter((option) => option.label.toLocaleLowerCase().includes(query)) : enabled;
|
|
289
292
|
return containing.length === 1 ? containing[0] : undefined;
|
|
290
293
|
})();
|
|
291
294
|
if (match) commit(match.value, match.label, match, "selection", trigger);
|