svelte-typeahead 4.3.1 → 4.3.2
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/CHANGELOG.md +6 -0
- package/README.md +20 -0
- package/lib/index.js +85 -87
- package/lib/index.mjs +85 -87
- package/package.json +1 -1
- package/src/Typeahead.svelte +4 -4
package/CHANGELOG.md
CHANGED
|
@@ -5,6 +5,12 @@ All notable changes to this project will be documented in this file.
|
|
|
5
5
|
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
|
6
6
|
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
7
7
|
|
|
8
|
+
## [4.3.2](https://github.com/metonym/svelte-typeahead/releases/tag/v4.3.2) - 2022-09-01
|
|
9
|
+
|
|
10
|
+
**Fixes**
|
|
11
|
+
|
|
12
|
+
- allow results to be selected if using `showDropdownOnFocus`
|
|
13
|
+
|
|
8
14
|
## [4.3.1](https://github.com/metonym/svelte-typeahead/releases/tag/v4.3.1) - 2022-08-29
|
|
9
15
|
|
|
10
16
|
**Fixes**
|
package/README.md
CHANGED
|
@@ -83,6 +83,26 @@ Pass an array of objects to the `data` prop. Use the `extractor` prop to specify
|
|
|
83
83
|
<Typeahead {data} {extract} />
|
|
84
84
|
```
|
|
85
85
|
|
|
86
|
+
### Custom label
|
|
87
|
+
|
|
88
|
+
`$$restProps` are forwarded to [svelte-search](https://github.com/metonym/svelte-search).
|
|
89
|
+
|
|
90
|
+
Use the `label` prop to specify a custom label.
|
|
91
|
+
|
|
92
|
+
```svelte
|
|
93
|
+
<Typeahead label="U.S. States" {data} {extract} />
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
### Hidden label
|
|
97
|
+
|
|
98
|
+
Set `hideLabel` to `true` to visually hide the label.
|
|
99
|
+
|
|
100
|
+
It's recommended that you set the `label` – even if hidden – for accessibility.
|
|
101
|
+
|
|
102
|
+
```svelte
|
|
103
|
+
<Typeahead label="U.S. States" hideLabel {data} {extract} />
|
|
104
|
+
```
|
|
105
|
+
|
|
86
106
|
### Custom-styled results
|
|
87
107
|
|
|
88
108
|
This component uses the [fuzzy](https://github.com/mattyork/fuzzy) library to highlight matching characters with the [mark](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/mark) element.
|
package/lib/index.js
CHANGED
|
@@ -1084,14 +1084,14 @@
|
|
|
1084
1084
|
|
|
1085
1085
|
const get_no_results_slot_context = ctx => ({
|
|
1086
1086
|
value: /*value*/ ctx[0],
|
|
1087
|
-
result: /*result*/ ctx[
|
|
1088
|
-
index: /*index*/ ctx[
|
|
1087
|
+
result: /*result*/ ctx[46],
|
|
1088
|
+
index: /*index*/ ctx[48]
|
|
1089
1089
|
});
|
|
1090
1090
|
|
|
1091
1091
|
function get_each_context(ctx, list, i) {
|
|
1092
1092
|
const child_ctx = ctx.slice();
|
|
1093
|
-
child_ctx[
|
|
1094
|
-
child_ctx[
|
|
1093
|
+
child_ctx[46] = list[i];
|
|
1094
|
+
child_ctx[48] = i;
|
|
1095
1095
|
return child_ctx;
|
|
1096
1096
|
}
|
|
1097
1097
|
|
|
@@ -1101,8 +1101,8 @@
|
|
|
1101
1101
|
});
|
|
1102
1102
|
|
|
1103
1103
|
const get_default_slot_context = ctx => ({
|
|
1104
|
-
result: /*result*/ ctx[
|
|
1105
|
-
index: /*index*/ ctx[
|
|
1104
|
+
result: /*result*/ ctx[46],
|
|
1105
|
+
index: /*index*/ ctx[48],
|
|
1106
1106
|
value: /*value*/ ctx[0]
|
|
1107
1107
|
});
|
|
1108
1108
|
|
|
@@ -1138,7 +1138,7 @@
|
|
|
1138
1138
|
current = true;
|
|
1139
1139
|
},
|
|
1140
1140
|
p(ctx, dirty) {
|
|
1141
|
-
if (dirty[0] & /*id, selectedIndex, results, select, $$scope, value*/
|
|
1141
|
+
if (dirty[0] & /*id, selectedIndex, results, select, $$scope, value*/ 33555975) {
|
|
1142
1142
|
each_value = /*results*/ ctx[1];
|
|
1143
1143
|
let i;
|
|
1144
1144
|
|
|
@@ -1193,7 +1193,7 @@
|
|
|
1193
1193
|
// (248:41)
|
|
1194
1194
|
function fallback_block(ctx) {
|
|
1195
1195
|
let html_tag;
|
|
1196
|
-
let raw_value = /*result*/ ctx[
|
|
1196
|
+
let raw_value = /*result*/ ctx[46].string + "";
|
|
1197
1197
|
let html_anchor;
|
|
1198
1198
|
|
|
1199
1199
|
return {
|
|
@@ -1207,7 +1207,7 @@
|
|
|
1207
1207
|
insert(target, html_anchor, anchor);
|
|
1208
1208
|
},
|
|
1209
1209
|
p(ctx, dirty) {
|
|
1210
|
-
if (dirty[0] & /*results*/ 2 && raw_value !== (raw_value = /*result*/ ctx[
|
|
1210
|
+
if (dirty[0] & /*results*/ 2 && raw_value !== (raw_value = /*result*/ ctx[46].string + "")) html_tag.p(raw_value);
|
|
1211
1211
|
},
|
|
1212
1212
|
d(detaching) {
|
|
1213
1213
|
if (detaching) detach(html_anchor);
|
|
@@ -1230,11 +1230,11 @@
|
|
|
1230
1230
|
const default_slot_or_fallback = default_slot || fallback_block(ctx);
|
|
1231
1231
|
|
|
1232
1232
|
function click_handler_1() {
|
|
1233
|
-
return /*click_handler_1*/ ctx[
|
|
1233
|
+
return /*click_handler_1*/ ctx[39](/*result*/ ctx[46], /*index*/ ctx[48]);
|
|
1234
1234
|
}
|
|
1235
1235
|
|
|
1236
1236
|
function mouseenter_handler() {
|
|
1237
|
-
return /*mouseenter_handler*/ ctx[
|
|
1237
|
+
return /*mouseenter_handler*/ ctx[40](/*result*/ ctx[46], /*index*/ ctx[48]);
|
|
1238
1238
|
}
|
|
1239
1239
|
|
|
1240
1240
|
return {
|
|
@@ -1243,11 +1243,11 @@
|
|
|
1243
1243
|
if (default_slot_or_fallback) default_slot_or_fallback.c();
|
|
1244
1244
|
t = space();
|
|
1245
1245
|
attr(li, "role", "option");
|
|
1246
|
-
attr(li, "id", li_id_value = "" + (/*id*/ ctx[2] + "-result-" + /*index*/ ctx[
|
|
1247
|
-
attr(li, "aria-selected", li_aria_selected_value = /*selectedIndex*/ ctx[
|
|
1246
|
+
attr(li, "id", li_id_value = "" + (/*id*/ ctx[2] + "-result-" + /*index*/ ctx[48]));
|
|
1247
|
+
attr(li, "aria-selected", li_aria_selected_value = /*selectedIndex*/ ctx[9] === /*index*/ ctx[48]);
|
|
1248
1248
|
attr(li, "class", "svelte-9wywte");
|
|
1249
|
-
toggle_class(li, "selected", /*selectedIndex*/ ctx[
|
|
1250
|
-
toggle_class(li, "disabled", /*result*/ ctx[
|
|
1249
|
+
toggle_class(li, "selected", /*selectedIndex*/ ctx[9] === /*index*/ ctx[48]);
|
|
1250
|
+
toggle_class(li, "disabled", /*result*/ ctx[46].disabled);
|
|
1251
1251
|
},
|
|
1252
1252
|
m(target, anchor) {
|
|
1253
1253
|
insert(target, li, anchor);
|
|
@@ -1290,20 +1290,20 @@
|
|
|
1290
1290
|
}
|
|
1291
1291
|
}
|
|
1292
1292
|
|
|
1293
|
-
if (!current || dirty[0] & /*id*/ 4 && li_id_value !== (li_id_value = "" + (/*id*/ ctx[2] + "-result-" + /*index*/ ctx[
|
|
1293
|
+
if (!current || dirty[0] & /*id*/ 4 && li_id_value !== (li_id_value = "" + (/*id*/ ctx[2] + "-result-" + /*index*/ ctx[48]))) {
|
|
1294
1294
|
attr(li, "id", li_id_value);
|
|
1295
1295
|
}
|
|
1296
1296
|
|
|
1297
|
-
if (!current || dirty[0] & /*selectedIndex*/
|
|
1297
|
+
if (!current || dirty[0] & /*selectedIndex*/ 512 && li_aria_selected_value !== (li_aria_selected_value = /*selectedIndex*/ ctx[9] === /*index*/ ctx[48])) {
|
|
1298
1298
|
attr(li, "aria-selected", li_aria_selected_value);
|
|
1299
1299
|
}
|
|
1300
1300
|
|
|
1301
|
-
if (dirty[0] & /*selectedIndex*/
|
|
1302
|
-
toggle_class(li, "selected", /*selectedIndex*/ ctx[
|
|
1301
|
+
if (dirty[0] & /*selectedIndex*/ 512) {
|
|
1302
|
+
toggle_class(li, "selected", /*selectedIndex*/ ctx[9] === /*index*/ ctx[48]);
|
|
1303
1303
|
}
|
|
1304
1304
|
|
|
1305
1305
|
if (dirty[0] & /*results*/ 2) {
|
|
1306
|
-
toggle_class(li, "disabled", /*result*/ ctx[
|
|
1306
|
+
toggle_class(li, "disabled", /*result*/ ctx[46].disabled);
|
|
1307
1307
|
}
|
|
1308
1308
|
},
|
|
1309
1309
|
i(local) {
|
|
@@ -1398,7 +1398,7 @@
|
|
|
1398
1398
|
const search_spread_levels = [
|
|
1399
1399
|
{ id: /*id*/ ctx[2] },
|
|
1400
1400
|
{ removeFormAriaAttributes: true },
|
|
1401
|
-
/*$$restProps*/ ctx[
|
|
1401
|
+
/*$$restProps*/ ctx[15],
|
|
1402
1402
|
{ "aria-autocomplete": "list" },
|
|
1403
1403
|
{
|
|
1404
1404
|
"aria-controls": "" + (/*id*/ ctx[2] + "-listbox")
|
|
@@ -1407,8 +1407,8 @@
|
|
|
1407
1407
|
"aria-labelledby": "" + (/*id*/ ctx[2] + "-label")
|
|
1408
1408
|
},
|
|
1409
1409
|
{
|
|
1410
|
-
"aria-activedescendant": /*selectedIndex*/ ctx[
|
|
1411
|
-
? `${/*id*/ ctx[2]}-result-${/*selectedIndex*/ ctx[
|
|
1410
|
+
"aria-activedescendant": /*selectedIndex*/ ctx[9] >= 0 && !/*hideDropdown*/ ctx[4] && /*results*/ ctx[1].length > 0
|
|
1411
|
+
? `${/*id*/ ctx[2]}-result-${/*selectedIndex*/ ctx[9]}`
|
|
1412
1412
|
: null
|
|
1413
1413
|
}
|
|
1414
1414
|
];
|
|
@@ -1427,8 +1427,8 @@
|
|
|
1427
1427
|
search_props = assign(search_props, search_spread_levels[i]);
|
|
1428
1428
|
}
|
|
1429
1429
|
|
|
1430
|
-
if (/*searchRef*/ ctx[
|
|
1431
|
-
search_props.ref = /*searchRef*/ ctx[
|
|
1430
|
+
if (/*searchRef*/ ctx[8] !== void 0) {
|
|
1431
|
+
search_props.ref = /*searchRef*/ ctx[8];
|
|
1432
1432
|
}
|
|
1433
1433
|
|
|
1434
1434
|
if (/*value*/ ctx[0] !== void 0) {
|
|
@@ -1444,13 +1444,12 @@
|
|
|
1444
1444
|
search.$on("focus", /*focus_handler*/ ctx[33]);
|
|
1445
1445
|
search.$on("focus", /*focus_handler_1*/ ctx[34]);
|
|
1446
1446
|
search.$on("clear", /*clear_handler*/ ctx[35]);
|
|
1447
|
-
search.$on("clear", /*open*/ ctx[
|
|
1447
|
+
search.$on("clear", /*open*/ ctx[12]);
|
|
1448
1448
|
search.$on("blur", /*blur_handler*/ ctx[36]);
|
|
1449
|
-
search.$on("
|
|
1450
|
-
search.$on("keydown", /*
|
|
1451
|
-
|
|
1452
|
-
let
|
|
1453
|
-
let if_block1 = /*$$slots*/ ctx[13]["no-results"] && !/*hideDropdown*/ ctx[3] && /*value*/ ctx[0].length > 0 && /*results*/ ctx[1].length === 0 && create_if_block(ctx);
|
|
1449
|
+
search.$on("keydown", /*keydown_handler*/ ctx[37]);
|
|
1450
|
+
search.$on("keydown", /*keydown_handler_1*/ ctx[38]);
|
|
1451
|
+
let if_block0 = /*showResults*/ ctx[6] && create_if_block_1(ctx);
|
|
1452
|
+
let if_block1 = /*$$slots*/ ctx[14]["no-results"] && !/*hideDropdown*/ ctx[4] && /*value*/ ctx[0].length > 0 && /*results*/ ctx[1].length === 0 && create_if_block(ctx);
|
|
1454
1453
|
|
|
1455
1454
|
return {
|
|
1456
1455
|
c() {
|
|
@@ -1470,7 +1469,7 @@
|
|
|
1470
1469
|
attr(div, "role", "combobox");
|
|
1471
1470
|
attr(div, "aria-haspopup", "listbox");
|
|
1472
1471
|
attr(div, "aria-owns", div_aria_owns_value = "" + (/*id*/ ctx[2] + "-listbox"));
|
|
1473
|
-
attr(div, "aria-expanded", /*showResults*/ ctx[
|
|
1472
|
+
attr(div, "aria-expanded", /*showResults*/ ctx[6]);
|
|
1474
1473
|
attr(div, "id", div_id_value = "" + (/*id*/ ctx[2] + "-typeahead"));
|
|
1475
1474
|
attr(div, "class", "svelte-9wywte");
|
|
1476
1475
|
toggle_class(div, "dropdown", /*results*/ ctx[1].length > 0);
|
|
@@ -1483,7 +1482,7 @@
|
|
|
1483
1482
|
if (if_block0) if_block0.m(ul, null);
|
|
1484
1483
|
append(ul, t1);
|
|
1485
1484
|
if (if_block1) if_block1.m(ul, null);
|
|
1486
|
-
/*div_binding*/ ctx[
|
|
1485
|
+
/*div_binding*/ ctx[41](div);
|
|
1487
1486
|
current = true;
|
|
1488
1487
|
|
|
1489
1488
|
if (!mounted) {
|
|
@@ -1492,11 +1491,11 @@
|
|
|
1492
1491
|
}
|
|
1493
1492
|
},
|
|
1494
1493
|
p(ctx, dirty) {
|
|
1495
|
-
const search_changes = (dirty[0] & /*id, $$restProps, selectedIndex, hideDropdown, results*/
|
|
1494
|
+
const search_changes = (dirty[0] & /*id, $$restProps, selectedIndex, hideDropdown, results*/ 33302)
|
|
1496
1495
|
? get_spread_update(search_spread_levels, [
|
|
1497
1496
|
dirty[0] & /*id*/ 4 && { id: /*id*/ ctx[2] },
|
|
1498
1497
|
search_spread_levels[1],
|
|
1499
|
-
dirty[0] & /*$$restProps*/
|
|
1498
|
+
dirty[0] & /*$$restProps*/ 32768 && get_spread_object(/*$$restProps*/ ctx[15]),
|
|
1500
1499
|
search_spread_levels[3],
|
|
1501
1500
|
dirty[0] & /*id*/ 4 && {
|
|
1502
1501
|
"aria-controls": "" + (/*id*/ ctx[2] + "-listbox")
|
|
@@ -1504,17 +1503,17 @@
|
|
|
1504
1503
|
dirty[0] & /*id*/ 4 && {
|
|
1505
1504
|
"aria-labelledby": "" + (/*id*/ ctx[2] + "-label")
|
|
1506
1505
|
},
|
|
1507
|
-
dirty[0] & /*selectedIndex, hideDropdown, results, id*/
|
|
1508
|
-
"aria-activedescendant": /*selectedIndex*/ ctx[
|
|
1509
|
-
? `${/*id*/ ctx[2]}-result-${/*selectedIndex*/ ctx[
|
|
1506
|
+
dirty[0] & /*selectedIndex, hideDropdown, results, id*/ 534 && {
|
|
1507
|
+
"aria-activedescendant": /*selectedIndex*/ ctx[9] >= 0 && !/*hideDropdown*/ ctx[4] && /*results*/ ctx[1].length > 0
|
|
1508
|
+
? `${/*id*/ ctx[2]}-result-${/*selectedIndex*/ ctx[9]}`
|
|
1510
1509
|
: null
|
|
1511
1510
|
}
|
|
1512
1511
|
])
|
|
1513
1512
|
: {};
|
|
1514
1513
|
|
|
1515
|
-
if (!updating_ref && dirty[0] & /*searchRef*/
|
|
1514
|
+
if (!updating_ref && dirty[0] & /*searchRef*/ 256) {
|
|
1516
1515
|
updating_ref = true;
|
|
1517
|
-
search_changes.ref = /*searchRef*/ ctx[
|
|
1516
|
+
search_changes.ref = /*searchRef*/ ctx[8];
|
|
1518
1517
|
add_flush_callback(() => updating_ref = false);
|
|
1519
1518
|
}
|
|
1520
1519
|
|
|
@@ -1526,11 +1525,11 @@
|
|
|
1526
1525
|
|
|
1527
1526
|
search.$set(search_changes);
|
|
1528
1527
|
|
|
1529
|
-
if (/*showResults*/ ctx[
|
|
1528
|
+
if (/*showResults*/ ctx[6]) {
|
|
1530
1529
|
if (if_block0) {
|
|
1531
1530
|
if_block0.p(ctx, dirty);
|
|
1532
1531
|
|
|
1533
|
-
if (dirty[0] & /*showResults*/
|
|
1532
|
+
if (dirty[0] & /*showResults*/ 64) {
|
|
1534
1533
|
transition_in(if_block0, 1);
|
|
1535
1534
|
}
|
|
1536
1535
|
} else {
|
|
@@ -1549,11 +1548,11 @@
|
|
|
1549
1548
|
check_outros();
|
|
1550
1549
|
}
|
|
1551
1550
|
|
|
1552
|
-
if (/*$$slots*/ ctx[
|
|
1551
|
+
if (/*$$slots*/ ctx[14]["no-results"] && !/*hideDropdown*/ ctx[4] && /*value*/ ctx[0].length > 0 && /*results*/ ctx[1].length === 0) {
|
|
1553
1552
|
if (if_block1) {
|
|
1554
1553
|
if_block1.p(ctx, dirty);
|
|
1555
1554
|
|
|
1556
|
-
if (dirty[0] & /*$$slots, hideDropdown, value, results*/
|
|
1555
|
+
if (dirty[0] & /*$$slots, hideDropdown, value, results*/ 16403) {
|
|
1557
1556
|
transition_in(if_block1, 1);
|
|
1558
1557
|
}
|
|
1559
1558
|
} else {
|
|
@@ -1584,8 +1583,8 @@
|
|
|
1584
1583
|
attr(div, "aria-owns", div_aria_owns_value);
|
|
1585
1584
|
}
|
|
1586
1585
|
|
|
1587
|
-
if (!current || dirty[0] & /*showResults*/
|
|
1588
|
-
attr(div, "aria-expanded", /*showResults*/ ctx[
|
|
1586
|
+
if (!current || dirty[0] & /*showResults*/ 64) {
|
|
1587
|
+
attr(div, "aria-expanded", /*showResults*/ ctx[6]);
|
|
1589
1588
|
}
|
|
1590
1589
|
|
|
1591
1590
|
if (!current || dirty[0] & /*id*/ 4 && div_id_value !== (div_id_value = "" + (/*id*/ ctx[2] + "-typeahead"))) {
|
|
@@ -1614,7 +1613,7 @@
|
|
|
1614
1613
|
destroy_component(search);
|
|
1615
1614
|
if (if_block0) if_block0.d();
|
|
1616
1615
|
if (if_block1) if_block1.d();
|
|
1617
|
-
/*div_binding*/ ctx[
|
|
1616
|
+
/*div_binding*/ ctx[41](null);
|
|
1618
1617
|
mounted = false;
|
|
1619
1618
|
dispose();
|
|
1620
1619
|
}
|
|
@@ -1655,11 +1654,11 @@
|
|
|
1655
1654
|
|
|
1656
1655
|
afterUpdate(() => {
|
|
1657
1656
|
if (prevResults !== resultsId && autoselect) {
|
|
1658
|
-
$$invalidate(
|
|
1657
|
+
$$invalidate(9, selectedIndex = getNextNonDisabledIndex());
|
|
1659
1658
|
}
|
|
1660
1659
|
|
|
1661
1660
|
if (prevResults !== resultsId && !$$slots["no-results"]) {
|
|
1662
|
-
$$invalidate(
|
|
1661
|
+
$$invalidate(4, hideDropdown = results.length === 0);
|
|
1663
1662
|
}
|
|
1664
1663
|
|
|
1665
1664
|
prevResults = resultsId;
|
|
@@ -1723,11 +1722,11 @@
|
|
|
1723
1722
|
disabled = results[index].disabled;
|
|
1724
1723
|
}
|
|
1725
1724
|
|
|
1726
|
-
$$invalidate(
|
|
1725
|
+
$$invalidate(9, selectedIndex = index);
|
|
1727
1726
|
}
|
|
1728
1727
|
|
|
1729
|
-
const open = () => $$invalidate(
|
|
1730
|
-
const close = () => $$invalidate(
|
|
1728
|
+
const open = () => $$invalidate(4, hideDropdown = false);
|
|
1729
|
+
const close = () => $$invalidate(4, hideDropdown = true);
|
|
1731
1730
|
|
|
1732
1731
|
const click_handler = ({ target }) => {
|
|
1733
1732
|
if (!hideDropdown && !comboboxRef?.contains(target)) {
|
|
@@ -1737,7 +1736,7 @@
|
|
|
1737
1736
|
|
|
1738
1737
|
function search_ref_binding(value) {
|
|
1739
1738
|
searchRef = value;
|
|
1740
|
-
$$invalidate(
|
|
1739
|
+
$$invalidate(8, searchRef);
|
|
1741
1740
|
}
|
|
1742
1741
|
|
|
1743
1742
|
function search_value_binding(value$1) {
|
|
@@ -1763,7 +1762,11 @@
|
|
|
1763
1762
|
|
|
1764
1763
|
const focus_handler_1 = () => {
|
|
1765
1764
|
open();
|
|
1766
|
-
|
|
1765
|
+
|
|
1766
|
+
if (showDropdownOnFocus) {
|
|
1767
|
+
$$invalidate(6, showResults = true);
|
|
1768
|
+
$$invalidate(5, isFocused = true);
|
|
1769
|
+
}
|
|
1767
1770
|
};
|
|
1768
1771
|
|
|
1769
1772
|
function clear_handler(event) {
|
|
@@ -1774,10 +1777,6 @@
|
|
|
1774
1777
|
bubble.call(this, $$self, event);
|
|
1775
1778
|
}
|
|
1776
1779
|
|
|
1777
|
-
const blur_handler_1 = () => {
|
|
1778
|
-
$$invalidate(4, isFocused = false);
|
|
1779
|
-
};
|
|
1780
|
-
|
|
1781
1780
|
function keydown_handler(event) {
|
|
1782
1781
|
bubble.call(this, $$self, event);
|
|
1783
1782
|
}
|
|
@@ -1808,63 +1807,63 @@
|
|
|
1808
1807
|
|
|
1809
1808
|
const click_handler_1 = (result, index) => {
|
|
1810
1809
|
if (result.disabled) return;
|
|
1811
|
-
$$invalidate(
|
|
1810
|
+
$$invalidate(9, selectedIndex = index);
|
|
1812
1811
|
select();
|
|
1813
1812
|
};
|
|
1814
1813
|
|
|
1815
1814
|
const mouseenter_handler = (result, index) => {
|
|
1816
1815
|
if (result.disabled) return;
|
|
1817
|
-
$$invalidate(
|
|
1816
|
+
$$invalidate(9, selectedIndex = index);
|
|
1818
1817
|
};
|
|
1819
1818
|
|
|
1820
1819
|
function div_binding($$value) {
|
|
1821
1820
|
binding_callbacks[$$value ? 'unshift' : 'push'](() => {
|
|
1822
1821
|
comboboxRef = $$value;
|
|
1823
|
-
$$invalidate(
|
|
1822
|
+
$$invalidate(7, comboboxRef);
|
|
1824
1823
|
});
|
|
1825
1824
|
}
|
|
1826
1825
|
|
|
1827
1826
|
$$self.$$set = $$new_props => {
|
|
1828
1827
|
$$props = assign(assign({}, $$props), exclude_internal_props($$new_props));
|
|
1829
|
-
$$invalidate(
|
|
1828
|
+
$$invalidate(15, $$restProps = compute_rest_props($$props, omit_props_names));
|
|
1830
1829
|
if ('id' in $$new_props) $$invalidate(2, id = $$new_props.id);
|
|
1831
1830
|
if ('value' in $$new_props) $$invalidate(0, value = $$new_props.value);
|
|
1832
|
-
if ('data' in $$new_props) $$invalidate(
|
|
1833
|
-
if ('extract' in $$new_props) $$invalidate(
|
|
1834
|
-
if ('disable' in $$new_props) $$invalidate(
|
|
1835
|
-
if ('filter' in $$new_props) $$invalidate(
|
|
1836
|
-
if ('autoselect' in $$new_props) $$invalidate(
|
|
1837
|
-
if ('inputAfterSelect' in $$new_props) $$invalidate(
|
|
1831
|
+
if ('data' in $$new_props) $$invalidate(16, data = $$new_props.data);
|
|
1832
|
+
if ('extract' in $$new_props) $$invalidate(17, extract = $$new_props.extract);
|
|
1833
|
+
if ('disable' in $$new_props) $$invalidate(18, disable = $$new_props.disable);
|
|
1834
|
+
if ('filter' in $$new_props) $$invalidate(19, filter = $$new_props.filter);
|
|
1835
|
+
if ('autoselect' in $$new_props) $$invalidate(20, autoselect = $$new_props.autoselect);
|
|
1836
|
+
if ('inputAfterSelect' in $$new_props) $$invalidate(21, inputAfterSelect = $$new_props.inputAfterSelect);
|
|
1838
1837
|
if ('results' in $$new_props) $$invalidate(1, results = $$new_props.results);
|
|
1839
|
-
if ('focusAfterSelect' in $$new_props) $$invalidate(
|
|
1840
|
-
if ('showDropdownOnFocus' in $$new_props) $$invalidate(
|
|
1838
|
+
if ('focusAfterSelect' in $$new_props) $$invalidate(22, focusAfterSelect = $$new_props.focusAfterSelect);
|
|
1839
|
+
if ('showDropdownOnFocus' in $$new_props) $$invalidate(3, showDropdownOnFocus = $$new_props.showDropdownOnFocus);
|
|
1841
1840
|
if ('limit' in $$new_props) $$invalidate(23, limit = $$new_props.limit);
|
|
1842
1841
|
if ('$$scope' in $$new_props) $$invalidate(25, $$scope = $$new_props.$$scope);
|
|
1843
1842
|
};
|
|
1844
1843
|
|
|
1845
1844
|
$$self.$$.update = () => {
|
|
1846
|
-
if ($$self.$$.dirty[0] & /*extract*/
|
|
1845
|
+
if ($$self.$$.dirty[0] & /*extract*/ 131072) {
|
|
1847
1846
|
$$invalidate(24, options = { pre: "<mark>", post: "</mark>", extract });
|
|
1848
1847
|
}
|
|
1849
1848
|
|
|
1850
|
-
if ($$self.$$.dirty[0] & /*value, data, options, limit, filter, disable*/
|
|
1849
|
+
if ($$self.$$.dirty[0] & /*value, data, options, limit, filter, disable*/ 26017793) {
|
|
1851
1850
|
$$invalidate(1, results = fuzzy.filter(value, data, options).filter(({ score }) => score > 0).slice(0, limit).filter(result => !filter(result.original)).map(result => ({
|
|
1852
1851
|
...result,
|
|
1853
1852
|
disabled: disable(result.original)
|
|
1854
1853
|
})));
|
|
1855
1854
|
}
|
|
1856
1855
|
|
|
1857
|
-
if ($$self.$$.dirty[0] & /*results, extract*/
|
|
1856
|
+
if ($$self.$$.dirty[0] & /*results, extract*/ 131074) {
|
|
1858
1857
|
resultsId = results.map(result => extract(result.original)).join("");
|
|
1859
1858
|
}
|
|
1860
1859
|
|
|
1861
|
-
if ($$self.$$.dirty[0] & /*hideDropdown, results*/
|
|
1862
|
-
$$invalidate(
|
|
1860
|
+
if ($$self.$$.dirty[0] & /*hideDropdown, results*/ 18) {
|
|
1861
|
+
$$invalidate(6, showResults = !hideDropdown && results.length > 0);
|
|
1863
1862
|
}
|
|
1864
1863
|
|
|
1865
|
-
if ($$self.$$.dirty[0] & /*showDropdownOnFocus, showResults, isFocused*/
|
|
1864
|
+
if ($$self.$$.dirty[0] & /*showDropdownOnFocus, showResults, isFocused*/ 104) {
|
|
1866
1865
|
if (showDropdownOnFocus) {
|
|
1867
|
-
$$invalidate(
|
|
1866
|
+
$$invalidate(6, showResults = showResults && isFocused);
|
|
1868
1867
|
}
|
|
1869
1868
|
}
|
|
1870
1869
|
};
|
|
@@ -1873,6 +1872,7 @@
|
|
|
1873
1872
|
value,
|
|
1874
1873
|
results,
|
|
1875
1874
|
id,
|
|
1875
|
+
showDropdownOnFocus,
|
|
1876
1876
|
hideDropdown,
|
|
1877
1877
|
isFocused,
|
|
1878
1878
|
showResults,
|
|
@@ -1892,7 +1892,6 @@
|
|
|
1892
1892
|
autoselect,
|
|
1893
1893
|
inputAfterSelect,
|
|
1894
1894
|
focusAfterSelect,
|
|
1895
|
-
showDropdownOnFocus,
|
|
1896
1895
|
limit,
|
|
1897
1896
|
options,
|
|
1898
1897
|
$$scope,
|
|
@@ -1907,7 +1906,6 @@
|
|
|
1907
1906
|
focus_handler_1,
|
|
1908
1907
|
clear_handler,
|
|
1909
1908
|
blur_handler,
|
|
1910
|
-
blur_handler_1,
|
|
1911
1909
|
keydown_handler,
|
|
1912
1910
|
keydown_handler_1,
|
|
1913
1911
|
click_handler_1,
|
|
@@ -1929,15 +1927,15 @@
|
|
|
1929
1927
|
{
|
|
1930
1928
|
id: 2,
|
|
1931
1929
|
value: 0,
|
|
1932
|
-
data:
|
|
1933
|
-
extract:
|
|
1934
|
-
disable:
|
|
1935
|
-
filter:
|
|
1936
|
-
autoselect:
|
|
1937
|
-
inputAfterSelect:
|
|
1930
|
+
data: 16,
|
|
1931
|
+
extract: 17,
|
|
1932
|
+
disable: 18,
|
|
1933
|
+
filter: 19,
|
|
1934
|
+
autoselect: 20,
|
|
1935
|
+
inputAfterSelect: 21,
|
|
1938
1936
|
results: 1,
|
|
1939
|
-
focusAfterSelect:
|
|
1940
|
-
showDropdownOnFocus:
|
|
1937
|
+
focusAfterSelect: 22,
|
|
1938
|
+
showDropdownOnFocus: 3,
|
|
1941
1939
|
limit: 23
|
|
1942
1940
|
},
|
|
1943
1941
|
add_css,
|
package/lib/index.mjs
CHANGED
|
@@ -1078,14 +1078,14 @@ const get_no_results_slot_changes = dirty => ({
|
|
|
1078
1078
|
|
|
1079
1079
|
const get_no_results_slot_context = ctx => ({
|
|
1080
1080
|
value: /*value*/ ctx[0],
|
|
1081
|
-
result: /*result*/ ctx[
|
|
1082
|
-
index: /*index*/ ctx[
|
|
1081
|
+
result: /*result*/ ctx[46],
|
|
1082
|
+
index: /*index*/ ctx[48]
|
|
1083
1083
|
});
|
|
1084
1084
|
|
|
1085
1085
|
function get_each_context(ctx, list, i) {
|
|
1086
1086
|
const child_ctx = ctx.slice();
|
|
1087
|
-
child_ctx[
|
|
1088
|
-
child_ctx[
|
|
1087
|
+
child_ctx[46] = list[i];
|
|
1088
|
+
child_ctx[48] = i;
|
|
1089
1089
|
return child_ctx;
|
|
1090
1090
|
}
|
|
1091
1091
|
|
|
@@ -1095,8 +1095,8 @@ const get_default_slot_changes = dirty => ({
|
|
|
1095
1095
|
});
|
|
1096
1096
|
|
|
1097
1097
|
const get_default_slot_context = ctx => ({
|
|
1098
|
-
result: /*result*/ ctx[
|
|
1099
|
-
index: /*index*/ ctx[
|
|
1098
|
+
result: /*result*/ ctx[46],
|
|
1099
|
+
index: /*index*/ ctx[48],
|
|
1100
1100
|
value: /*value*/ ctx[0]
|
|
1101
1101
|
});
|
|
1102
1102
|
|
|
@@ -1132,7 +1132,7 @@ function create_if_block_1(ctx) {
|
|
|
1132
1132
|
current = true;
|
|
1133
1133
|
},
|
|
1134
1134
|
p(ctx, dirty) {
|
|
1135
|
-
if (dirty[0] & /*id, selectedIndex, results, select, $$scope, value*/
|
|
1135
|
+
if (dirty[0] & /*id, selectedIndex, results, select, $$scope, value*/ 33555975) {
|
|
1136
1136
|
each_value = /*results*/ ctx[1];
|
|
1137
1137
|
let i;
|
|
1138
1138
|
|
|
@@ -1187,7 +1187,7 @@ function create_if_block_1(ctx) {
|
|
|
1187
1187
|
// (248:41)
|
|
1188
1188
|
function fallback_block(ctx) {
|
|
1189
1189
|
let html_tag;
|
|
1190
|
-
let raw_value = /*result*/ ctx[
|
|
1190
|
+
let raw_value = /*result*/ ctx[46].string + "";
|
|
1191
1191
|
let html_anchor;
|
|
1192
1192
|
|
|
1193
1193
|
return {
|
|
@@ -1201,7 +1201,7 @@ function fallback_block(ctx) {
|
|
|
1201
1201
|
insert(target, html_anchor, anchor);
|
|
1202
1202
|
},
|
|
1203
1203
|
p(ctx, dirty) {
|
|
1204
|
-
if (dirty[0] & /*results*/ 2 && raw_value !== (raw_value = /*result*/ ctx[
|
|
1204
|
+
if (dirty[0] & /*results*/ 2 && raw_value !== (raw_value = /*result*/ ctx[46].string + "")) html_tag.p(raw_value);
|
|
1205
1205
|
},
|
|
1206
1206
|
d(detaching) {
|
|
1207
1207
|
if (detaching) detach(html_anchor);
|
|
@@ -1224,11 +1224,11 @@ function create_each_block(ctx) {
|
|
|
1224
1224
|
const default_slot_or_fallback = default_slot || fallback_block(ctx);
|
|
1225
1225
|
|
|
1226
1226
|
function click_handler_1() {
|
|
1227
|
-
return /*click_handler_1*/ ctx[
|
|
1227
|
+
return /*click_handler_1*/ ctx[39](/*result*/ ctx[46], /*index*/ ctx[48]);
|
|
1228
1228
|
}
|
|
1229
1229
|
|
|
1230
1230
|
function mouseenter_handler() {
|
|
1231
|
-
return /*mouseenter_handler*/ ctx[
|
|
1231
|
+
return /*mouseenter_handler*/ ctx[40](/*result*/ ctx[46], /*index*/ ctx[48]);
|
|
1232
1232
|
}
|
|
1233
1233
|
|
|
1234
1234
|
return {
|
|
@@ -1237,11 +1237,11 @@ function create_each_block(ctx) {
|
|
|
1237
1237
|
if (default_slot_or_fallback) default_slot_or_fallback.c();
|
|
1238
1238
|
t = space();
|
|
1239
1239
|
attr(li, "role", "option");
|
|
1240
|
-
attr(li, "id", li_id_value = "" + (/*id*/ ctx[2] + "-result-" + /*index*/ ctx[
|
|
1241
|
-
attr(li, "aria-selected", li_aria_selected_value = /*selectedIndex*/ ctx[
|
|
1240
|
+
attr(li, "id", li_id_value = "" + (/*id*/ ctx[2] + "-result-" + /*index*/ ctx[48]));
|
|
1241
|
+
attr(li, "aria-selected", li_aria_selected_value = /*selectedIndex*/ ctx[9] === /*index*/ ctx[48]);
|
|
1242
1242
|
attr(li, "class", "svelte-9wywte");
|
|
1243
|
-
toggle_class(li, "selected", /*selectedIndex*/ ctx[
|
|
1244
|
-
toggle_class(li, "disabled", /*result*/ ctx[
|
|
1243
|
+
toggle_class(li, "selected", /*selectedIndex*/ ctx[9] === /*index*/ ctx[48]);
|
|
1244
|
+
toggle_class(li, "disabled", /*result*/ ctx[46].disabled);
|
|
1245
1245
|
},
|
|
1246
1246
|
m(target, anchor) {
|
|
1247
1247
|
insert(target, li, anchor);
|
|
@@ -1284,20 +1284,20 @@ function create_each_block(ctx) {
|
|
|
1284
1284
|
}
|
|
1285
1285
|
}
|
|
1286
1286
|
|
|
1287
|
-
if (!current || dirty[0] & /*id*/ 4 && li_id_value !== (li_id_value = "" + (/*id*/ ctx[2] + "-result-" + /*index*/ ctx[
|
|
1287
|
+
if (!current || dirty[0] & /*id*/ 4 && li_id_value !== (li_id_value = "" + (/*id*/ ctx[2] + "-result-" + /*index*/ ctx[48]))) {
|
|
1288
1288
|
attr(li, "id", li_id_value);
|
|
1289
1289
|
}
|
|
1290
1290
|
|
|
1291
|
-
if (!current || dirty[0] & /*selectedIndex*/
|
|
1291
|
+
if (!current || dirty[0] & /*selectedIndex*/ 512 && li_aria_selected_value !== (li_aria_selected_value = /*selectedIndex*/ ctx[9] === /*index*/ ctx[48])) {
|
|
1292
1292
|
attr(li, "aria-selected", li_aria_selected_value);
|
|
1293
1293
|
}
|
|
1294
1294
|
|
|
1295
|
-
if (dirty[0] & /*selectedIndex*/
|
|
1296
|
-
toggle_class(li, "selected", /*selectedIndex*/ ctx[
|
|
1295
|
+
if (dirty[0] & /*selectedIndex*/ 512) {
|
|
1296
|
+
toggle_class(li, "selected", /*selectedIndex*/ ctx[9] === /*index*/ ctx[48]);
|
|
1297
1297
|
}
|
|
1298
1298
|
|
|
1299
1299
|
if (dirty[0] & /*results*/ 2) {
|
|
1300
|
-
toggle_class(li, "disabled", /*result*/ ctx[
|
|
1300
|
+
toggle_class(li, "disabled", /*result*/ ctx[46].disabled);
|
|
1301
1301
|
}
|
|
1302
1302
|
},
|
|
1303
1303
|
i(local) {
|
|
@@ -1392,7 +1392,7 @@ function create_fragment(ctx) {
|
|
|
1392
1392
|
const search_spread_levels = [
|
|
1393
1393
|
{ id: /*id*/ ctx[2] },
|
|
1394
1394
|
{ removeFormAriaAttributes: true },
|
|
1395
|
-
/*$$restProps*/ ctx[
|
|
1395
|
+
/*$$restProps*/ ctx[15],
|
|
1396
1396
|
{ "aria-autocomplete": "list" },
|
|
1397
1397
|
{
|
|
1398
1398
|
"aria-controls": "" + (/*id*/ ctx[2] + "-listbox")
|
|
@@ -1401,8 +1401,8 @@ function create_fragment(ctx) {
|
|
|
1401
1401
|
"aria-labelledby": "" + (/*id*/ ctx[2] + "-label")
|
|
1402
1402
|
},
|
|
1403
1403
|
{
|
|
1404
|
-
"aria-activedescendant": /*selectedIndex*/ ctx[
|
|
1405
|
-
? `${/*id*/ ctx[2]}-result-${/*selectedIndex*/ ctx[
|
|
1404
|
+
"aria-activedescendant": /*selectedIndex*/ ctx[9] >= 0 && !/*hideDropdown*/ ctx[4] && /*results*/ ctx[1].length > 0
|
|
1405
|
+
? `${/*id*/ ctx[2]}-result-${/*selectedIndex*/ ctx[9]}`
|
|
1406
1406
|
: null
|
|
1407
1407
|
}
|
|
1408
1408
|
];
|
|
@@ -1421,8 +1421,8 @@ function create_fragment(ctx) {
|
|
|
1421
1421
|
search_props = assign(search_props, search_spread_levels[i]);
|
|
1422
1422
|
}
|
|
1423
1423
|
|
|
1424
|
-
if (/*searchRef*/ ctx[
|
|
1425
|
-
search_props.ref = /*searchRef*/ ctx[
|
|
1424
|
+
if (/*searchRef*/ ctx[8] !== void 0) {
|
|
1425
|
+
search_props.ref = /*searchRef*/ ctx[8];
|
|
1426
1426
|
}
|
|
1427
1427
|
|
|
1428
1428
|
if (/*value*/ ctx[0] !== void 0) {
|
|
@@ -1438,13 +1438,12 @@ function create_fragment(ctx) {
|
|
|
1438
1438
|
search.$on("focus", /*focus_handler*/ ctx[33]);
|
|
1439
1439
|
search.$on("focus", /*focus_handler_1*/ ctx[34]);
|
|
1440
1440
|
search.$on("clear", /*clear_handler*/ ctx[35]);
|
|
1441
|
-
search.$on("clear", /*open*/ ctx[
|
|
1441
|
+
search.$on("clear", /*open*/ ctx[12]);
|
|
1442
1442
|
search.$on("blur", /*blur_handler*/ ctx[36]);
|
|
1443
|
-
search.$on("
|
|
1444
|
-
search.$on("keydown", /*
|
|
1445
|
-
|
|
1446
|
-
let
|
|
1447
|
-
let if_block1 = /*$$slots*/ ctx[13]["no-results"] && !/*hideDropdown*/ ctx[3] && /*value*/ ctx[0].length > 0 && /*results*/ ctx[1].length === 0 && create_if_block(ctx);
|
|
1443
|
+
search.$on("keydown", /*keydown_handler*/ ctx[37]);
|
|
1444
|
+
search.$on("keydown", /*keydown_handler_1*/ ctx[38]);
|
|
1445
|
+
let if_block0 = /*showResults*/ ctx[6] && create_if_block_1(ctx);
|
|
1446
|
+
let if_block1 = /*$$slots*/ ctx[14]["no-results"] && !/*hideDropdown*/ ctx[4] && /*value*/ ctx[0].length > 0 && /*results*/ ctx[1].length === 0 && create_if_block(ctx);
|
|
1448
1447
|
|
|
1449
1448
|
return {
|
|
1450
1449
|
c() {
|
|
@@ -1464,7 +1463,7 @@ function create_fragment(ctx) {
|
|
|
1464
1463
|
attr(div, "role", "combobox");
|
|
1465
1464
|
attr(div, "aria-haspopup", "listbox");
|
|
1466
1465
|
attr(div, "aria-owns", div_aria_owns_value = "" + (/*id*/ ctx[2] + "-listbox"));
|
|
1467
|
-
attr(div, "aria-expanded", /*showResults*/ ctx[
|
|
1466
|
+
attr(div, "aria-expanded", /*showResults*/ ctx[6]);
|
|
1468
1467
|
attr(div, "id", div_id_value = "" + (/*id*/ ctx[2] + "-typeahead"));
|
|
1469
1468
|
attr(div, "class", "svelte-9wywte");
|
|
1470
1469
|
toggle_class(div, "dropdown", /*results*/ ctx[1].length > 0);
|
|
@@ -1477,7 +1476,7 @@ function create_fragment(ctx) {
|
|
|
1477
1476
|
if (if_block0) if_block0.m(ul, null);
|
|
1478
1477
|
append(ul, t1);
|
|
1479
1478
|
if (if_block1) if_block1.m(ul, null);
|
|
1480
|
-
/*div_binding*/ ctx[
|
|
1479
|
+
/*div_binding*/ ctx[41](div);
|
|
1481
1480
|
current = true;
|
|
1482
1481
|
|
|
1483
1482
|
if (!mounted) {
|
|
@@ -1486,11 +1485,11 @@ function create_fragment(ctx) {
|
|
|
1486
1485
|
}
|
|
1487
1486
|
},
|
|
1488
1487
|
p(ctx, dirty) {
|
|
1489
|
-
const search_changes = (dirty[0] & /*id, $$restProps, selectedIndex, hideDropdown, results*/
|
|
1488
|
+
const search_changes = (dirty[0] & /*id, $$restProps, selectedIndex, hideDropdown, results*/ 33302)
|
|
1490
1489
|
? get_spread_update(search_spread_levels, [
|
|
1491
1490
|
dirty[0] & /*id*/ 4 && { id: /*id*/ ctx[2] },
|
|
1492
1491
|
search_spread_levels[1],
|
|
1493
|
-
dirty[0] & /*$$restProps*/
|
|
1492
|
+
dirty[0] & /*$$restProps*/ 32768 && get_spread_object(/*$$restProps*/ ctx[15]),
|
|
1494
1493
|
search_spread_levels[3],
|
|
1495
1494
|
dirty[0] & /*id*/ 4 && {
|
|
1496
1495
|
"aria-controls": "" + (/*id*/ ctx[2] + "-listbox")
|
|
@@ -1498,17 +1497,17 @@ function create_fragment(ctx) {
|
|
|
1498
1497
|
dirty[0] & /*id*/ 4 && {
|
|
1499
1498
|
"aria-labelledby": "" + (/*id*/ ctx[2] + "-label")
|
|
1500
1499
|
},
|
|
1501
|
-
dirty[0] & /*selectedIndex, hideDropdown, results, id*/
|
|
1502
|
-
"aria-activedescendant": /*selectedIndex*/ ctx[
|
|
1503
|
-
? `${/*id*/ ctx[2]}-result-${/*selectedIndex*/ ctx[
|
|
1500
|
+
dirty[0] & /*selectedIndex, hideDropdown, results, id*/ 534 && {
|
|
1501
|
+
"aria-activedescendant": /*selectedIndex*/ ctx[9] >= 0 && !/*hideDropdown*/ ctx[4] && /*results*/ ctx[1].length > 0
|
|
1502
|
+
? `${/*id*/ ctx[2]}-result-${/*selectedIndex*/ ctx[9]}`
|
|
1504
1503
|
: null
|
|
1505
1504
|
}
|
|
1506
1505
|
])
|
|
1507
1506
|
: {};
|
|
1508
1507
|
|
|
1509
|
-
if (!updating_ref && dirty[0] & /*searchRef*/
|
|
1508
|
+
if (!updating_ref && dirty[0] & /*searchRef*/ 256) {
|
|
1510
1509
|
updating_ref = true;
|
|
1511
|
-
search_changes.ref = /*searchRef*/ ctx[
|
|
1510
|
+
search_changes.ref = /*searchRef*/ ctx[8];
|
|
1512
1511
|
add_flush_callback(() => updating_ref = false);
|
|
1513
1512
|
}
|
|
1514
1513
|
|
|
@@ -1520,11 +1519,11 @@ function create_fragment(ctx) {
|
|
|
1520
1519
|
|
|
1521
1520
|
search.$set(search_changes);
|
|
1522
1521
|
|
|
1523
|
-
if (/*showResults*/ ctx[
|
|
1522
|
+
if (/*showResults*/ ctx[6]) {
|
|
1524
1523
|
if (if_block0) {
|
|
1525
1524
|
if_block0.p(ctx, dirty);
|
|
1526
1525
|
|
|
1527
|
-
if (dirty[0] & /*showResults*/
|
|
1526
|
+
if (dirty[0] & /*showResults*/ 64) {
|
|
1528
1527
|
transition_in(if_block0, 1);
|
|
1529
1528
|
}
|
|
1530
1529
|
} else {
|
|
@@ -1543,11 +1542,11 @@ function create_fragment(ctx) {
|
|
|
1543
1542
|
check_outros();
|
|
1544
1543
|
}
|
|
1545
1544
|
|
|
1546
|
-
if (/*$$slots*/ ctx[
|
|
1545
|
+
if (/*$$slots*/ ctx[14]["no-results"] && !/*hideDropdown*/ ctx[4] && /*value*/ ctx[0].length > 0 && /*results*/ ctx[1].length === 0) {
|
|
1547
1546
|
if (if_block1) {
|
|
1548
1547
|
if_block1.p(ctx, dirty);
|
|
1549
1548
|
|
|
1550
|
-
if (dirty[0] & /*$$slots, hideDropdown, value, results*/
|
|
1549
|
+
if (dirty[0] & /*$$slots, hideDropdown, value, results*/ 16403) {
|
|
1551
1550
|
transition_in(if_block1, 1);
|
|
1552
1551
|
}
|
|
1553
1552
|
} else {
|
|
@@ -1578,8 +1577,8 @@ function create_fragment(ctx) {
|
|
|
1578
1577
|
attr(div, "aria-owns", div_aria_owns_value);
|
|
1579
1578
|
}
|
|
1580
1579
|
|
|
1581
|
-
if (!current || dirty[0] & /*showResults*/
|
|
1582
|
-
attr(div, "aria-expanded", /*showResults*/ ctx[
|
|
1580
|
+
if (!current || dirty[0] & /*showResults*/ 64) {
|
|
1581
|
+
attr(div, "aria-expanded", /*showResults*/ ctx[6]);
|
|
1583
1582
|
}
|
|
1584
1583
|
|
|
1585
1584
|
if (!current || dirty[0] & /*id*/ 4 && div_id_value !== (div_id_value = "" + (/*id*/ ctx[2] + "-typeahead"))) {
|
|
@@ -1608,7 +1607,7 @@ function create_fragment(ctx) {
|
|
|
1608
1607
|
destroy_component(search);
|
|
1609
1608
|
if (if_block0) if_block0.d();
|
|
1610
1609
|
if (if_block1) if_block1.d();
|
|
1611
|
-
/*div_binding*/ ctx[
|
|
1610
|
+
/*div_binding*/ ctx[41](null);
|
|
1612
1611
|
mounted = false;
|
|
1613
1612
|
dispose();
|
|
1614
1613
|
}
|
|
@@ -1649,11 +1648,11 @@ function instance($$self, $$props, $$invalidate) {
|
|
|
1649
1648
|
|
|
1650
1649
|
afterUpdate(() => {
|
|
1651
1650
|
if (prevResults !== resultsId && autoselect) {
|
|
1652
|
-
$$invalidate(
|
|
1651
|
+
$$invalidate(9, selectedIndex = getNextNonDisabledIndex());
|
|
1653
1652
|
}
|
|
1654
1653
|
|
|
1655
1654
|
if (prevResults !== resultsId && !$$slots["no-results"]) {
|
|
1656
|
-
$$invalidate(
|
|
1655
|
+
$$invalidate(4, hideDropdown = results.length === 0);
|
|
1657
1656
|
}
|
|
1658
1657
|
|
|
1659
1658
|
prevResults = resultsId;
|
|
@@ -1717,11 +1716,11 @@ function instance($$self, $$props, $$invalidate) {
|
|
|
1717
1716
|
disabled = results[index].disabled;
|
|
1718
1717
|
}
|
|
1719
1718
|
|
|
1720
|
-
$$invalidate(
|
|
1719
|
+
$$invalidate(9, selectedIndex = index);
|
|
1721
1720
|
}
|
|
1722
1721
|
|
|
1723
|
-
const open = () => $$invalidate(
|
|
1724
|
-
const close = () => $$invalidate(
|
|
1722
|
+
const open = () => $$invalidate(4, hideDropdown = false);
|
|
1723
|
+
const close = () => $$invalidate(4, hideDropdown = true);
|
|
1725
1724
|
|
|
1726
1725
|
const click_handler = ({ target }) => {
|
|
1727
1726
|
if (!hideDropdown && !comboboxRef?.contains(target)) {
|
|
@@ -1731,7 +1730,7 @@ function instance($$self, $$props, $$invalidate) {
|
|
|
1731
1730
|
|
|
1732
1731
|
function search_ref_binding(value) {
|
|
1733
1732
|
searchRef = value;
|
|
1734
|
-
$$invalidate(
|
|
1733
|
+
$$invalidate(8, searchRef);
|
|
1735
1734
|
}
|
|
1736
1735
|
|
|
1737
1736
|
function search_value_binding(value$1) {
|
|
@@ -1757,7 +1756,11 @@ function instance($$self, $$props, $$invalidate) {
|
|
|
1757
1756
|
|
|
1758
1757
|
const focus_handler_1 = () => {
|
|
1759
1758
|
open();
|
|
1760
|
-
|
|
1759
|
+
|
|
1760
|
+
if (showDropdownOnFocus) {
|
|
1761
|
+
$$invalidate(6, showResults = true);
|
|
1762
|
+
$$invalidate(5, isFocused = true);
|
|
1763
|
+
}
|
|
1761
1764
|
};
|
|
1762
1765
|
|
|
1763
1766
|
function clear_handler(event) {
|
|
@@ -1768,10 +1771,6 @@ function instance($$self, $$props, $$invalidate) {
|
|
|
1768
1771
|
bubble.call(this, $$self, event);
|
|
1769
1772
|
}
|
|
1770
1773
|
|
|
1771
|
-
const blur_handler_1 = () => {
|
|
1772
|
-
$$invalidate(4, isFocused = false);
|
|
1773
|
-
};
|
|
1774
|
-
|
|
1775
1774
|
function keydown_handler(event) {
|
|
1776
1775
|
bubble.call(this, $$self, event);
|
|
1777
1776
|
}
|
|
@@ -1802,63 +1801,63 @@ function instance($$self, $$props, $$invalidate) {
|
|
|
1802
1801
|
|
|
1803
1802
|
const click_handler_1 = (result, index) => {
|
|
1804
1803
|
if (result.disabled) return;
|
|
1805
|
-
$$invalidate(
|
|
1804
|
+
$$invalidate(9, selectedIndex = index);
|
|
1806
1805
|
select();
|
|
1807
1806
|
};
|
|
1808
1807
|
|
|
1809
1808
|
const mouseenter_handler = (result, index) => {
|
|
1810
1809
|
if (result.disabled) return;
|
|
1811
|
-
$$invalidate(
|
|
1810
|
+
$$invalidate(9, selectedIndex = index);
|
|
1812
1811
|
};
|
|
1813
1812
|
|
|
1814
1813
|
function div_binding($$value) {
|
|
1815
1814
|
binding_callbacks[$$value ? 'unshift' : 'push'](() => {
|
|
1816
1815
|
comboboxRef = $$value;
|
|
1817
|
-
$$invalidate(
|
|
1816
|
+
$$invalidate(7, comboboxRef);
|
|
1818
1817
|
});
|
|
1819
1818
|
}
|
|
1820
1819
|
|
|
1821
1820
|
$$self.$$set = $$new_props => {
|
|
1822
1821
|
$$props = assign(assign({}, $$props), exclude_internal_props($$new_props));
|
|
1823
|
-
$$invalidate(
|
|
1822
|
+
$$invalidate(15, $$restProps = compute_rest_props($$props, omit_props_names));
|
|
1824
1823
|
if ('id' in $$new_props) $$invalidate(2, id = $$new_props.id);
|
|
1825
1824
|
if ('value' in $$new_props) $$invalidate(0, value = $$new_props.value);
|
|
1826
|
-
if ('data' in $$new_props) $$invalidate(
|
|
1827
|
-
if ('extract' in $$new_props) $$invalidate(
|
|
1828
|
-
if ('disable' in $$new_props) $$invalidate(
|
|
1829
|
-
if ('filter' in $$new_props) $$invalidate(
|
|
1830
|
-
if ('autoselect' in $$new_props) $$invalidate(
|
|
1831
|
-
if ('inputAfterSelect' in $$new_props) $$invalidate(
|
|
1825
|
+
if ('data' in $$new_props) $$invalidate(16, data = $$new_props.data);
|
|
1826
|
+
if ('extract' in $$new_props) $$invalidate(17, extract = $$new_props.extract);
|
|
1827
|
+
if ('disable' in $$new_props) $$invalidate(18, disable = $$new_props.disable);
|
|
1828
|
+
if ('filter' in $$new_props) $$invalidate(19, filter = $$new_props.filter);
|
|
1829
|
+
if ('autoselect' in $$new_props) $$invalidate(20, autoselect = $$new_props.autoselect);
|
|
1830
|
+
if ('inputAfterSelect' in $$new_props) $$invalidate(21, inputAfterSelect = $$new_props.inputAfterSelect);
|
|
1832
1831
|
if ('results' in $$new_props) $$invalidate(1, results = $$new_props.results);
|
|
1833
|
-
if ('focusAfterSelect' in $$new_props) $$invalidate(
|
|
1834
|
-
if ('showDropdownOnFocus' in $$new_props) $$invalidate(
|
|
1832
|
+
if ('focusAfterSelect' in $$new_props) $$invalidate(22, focusAfterSelect = $$new_props.focusAfterSelect);
|
|
1833
|
+
if ('showDropdownOnFocus' in $$new_props) $$invalidate(3, showDropdownOnFocus = $$new_props.showDropdownOnFocus);
|
|
1835
1834
|
if ('limit' in $$new_props) $$invalidate(23, limit = $$new_props.limit);
|
|
1836
1835
|
if ('$$scope' in $$new_props) $$invalidate(25, $$scope = $$new_props.$$scope);
|
|
1837
1836
|
};
|
|
1838
1837
|
|
|
1839
1838
|
$$self.$$.update = () => {
|
|
1840
|
-
if ($$self.$$.dirty[0] & /*extract*/
|
|
1839
|
+
if ($$self.$$.dirty[0] & /*extract*/ 131072) {
|
|
1841
1840
|
$$invalidate(24, options = { pre: "<mark>", post: "</mark>", extract });
|
|
1842
1841
|
}
|
|
1843
1842
|
|
|
1844
|
-
if ($$self.$$.dirty[0] & /*value, data, options, limit, filter, disable*/
|
|
1843
|
+
if ($$self.$$.dirty[0] & /*value, data, options, limit, filter, disable*/ 26017793) {
|
|
1845
1844
|
$$invalidate(1, results = fuzzy.filter(value, data, options).filter(({ score }) => score > 0).slice(0, limit).filter(result => !filter(result.original)).map(result => ({
|
|
1846
1845
|
...result,
|
|
1847
1846
|
disabled: disable(result.original)
|
|
1848
1847
|
})));
|
|
1849
1848
|
}
|
|
1850
1849
|
|
|
1851
|
-
if ($$self.$$.dirty[0] & /*results, extract*/
|
|
1850
|
+
if ($$self.$$.dirty[0] & /*results, extract*/ 131074) {
|
|
1852
1851
|
resultsId = results.map(result => extract(result.original)).join("");
|
|
1853
1852
|
}
|
|
1854
1853
|
|
|
1855
|
-
if ($$self.$$.dirty[0] & /*hideDropdown, results*/
|
|
1856
|
-
$$invalidate(
|
|
1854
|
+
if ($$self.$$.dirty[0] & /*hideDropdown, results*/ 18) {
|
|
1855
|
+
$$invalidate(6, showResults = !hideDropdown && results.length > 0);
|
|
1857
1856
|
}
|
|
1858
1857
|
|
|
1859
|
-
if ($$self.$$.dirty[0] & /*showDropdownOnFocus, showResults, isFocused*/
|
|
1858
|
+
if ($$self.$$.dirty[0] & /*showDropdownOnFocus, showResults, isFocused*/ 104) {
|
|
1860
1859
|
if (showDropdownOnFocus) {
|
|
1861
|
-
$$invalidate(
|
|
1860
|
+
$$invalidate(6, showResults = showResults && isFocused);
|
|
1862
1861
|
}
|
|
1863
1862
|
}
|
|
1864
1863
|
};
|
|
@@ -1867,6 +1866,7 @@ function instance($$self, $$props, $$invalidate) {
|
|
|
1867
1866
|
value,
|
|
1868
1867
|
results,
|
|
1869
1868
|
id,
|
|
1869
|
+
showDropdownOnFocus,
|
|
1870
1870
|
hideDropdown,
|
|
1871
1871
|
isFocused,
|
|
1872
1872
|
showResults,
|
|
@@ -1886,7 +1886,6 @@ function instance($$self, $$props, $$invalidate) {
|
|
|
1886
1886
|
autoselect,
|
|
1887
1887
|
inputAfterSelect,
|
|
1888
1888
|
focusAfterSelect,
|
|
1889
|
-
showDropdownOnFocus,
|
|
1890
1889
|
limit,
|
|
1891
1890
|
options,
|
|
1892
1891
|
$$scope,
|
|
@@ -1901,7 +1900,6 @@ function instance($$self, $$props, $$invalidate) {
|
|
|
1901
1900
|
focus_handler_1,
|
|
1902
1901
|
clear_handler,
|
|
1903
1902
|
blur_handler,
|
|
1904
|
-
blur_handler_1,
|
|
1905
1903
|
keydown_handler,
|
|
1906
1904
|
keydown_handler_1,
|
|
1907
1905
|
click_handler_1,
|
|
@@ -1923,15 +1921,15 @@ class Typeahead extends SvelteComponent {
|
|
|
1923
1921
|
{
|
|
1924
1922
|
id: 2,
|
|
1925
1923
|
value: 0,
|
|
1926
|
-
data:
|
|
1927
|
-
extract:
|
|
1928
|
-
disable:
|
|
1929
|
-
filter:
|
|
1930
|
-
autoselect:
|
|
1931
|
-
inputAfterSelect:
|
|
1924
|
+
data: 16,
|
|
1925
|
+
extract: 17,
|
|
1926
|
+
disable: 18,
|
|
1927
|
+
filter: 19,
|
|
1928
|
+
autoselect: 20,
|
|
1929
|
+
inputAfterSelect: 21,
|
|
1932
1930
|
results: 1,
|
|
1933
|
-
focusAfterSelect:
|
|
1934
|
-
showDropdownOnFocus:
|
|
1931
|
+
focusAfterSelect: 22,
|
|
1932
|
+
showDropdownOnFocus: 3,
|
|
1935
1933
|
limit: 23
|
|
1936
1934
|
},
|
|
1937
1935
|
add_css,
|
package/package.json
CHANGED
package/src/Typeahead.svelte
CHANGED
|
@@ -188,14 +188,14 @@
|
|
|
188
188
|
on:focus
|
|
189
189
|
on:focus={() => {
|
|
190
190
|
open();
|
|
191
|
-
|
|
191
|
+
if (showDropdownOnFocus) {
|
|
192
|
+
showResults = true;
|
|
193
|
+
isFocused = true;
|
|
194
|
+
}
|
|
192
195
|
}}
|
|
193
196
|
on:clear
|
|
194
197
|
on:clear={open}
|
|
195
198
|
on:blur
|
|
196
|
-
on:blur={() => {
|
|
197
|
-
isFocused = false;
|
|
198
|
-
}}
|
|
199
199
|
on:keydown
|
|
200
200
|
on:keydown={(e) => {
|
|
201
201
|
if (results.length === 0) return;
|