svelte-typeahead 4.2.4 → 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 +18 -0
- package/README.md +54 -32
- package/lib/index.js +157 -121
- package/lib/index.mjs +157 -121
- package/package.json +2 -3
- package/src/Typeahead.svelte +39 -10
- package/types/Typeahead.svelte.d.ts +6 -0
package/lib/index.js
CHANGED
|
@@ -410,6 +410,9 @@
|
|
|
410
410
|
});
|
|
411
411
|
block.o(local);
|
|
412
412
|
}
|
|
413
|
+
else if (callback) {
|
|
414
|
+
callback();
|
|
415
|
+
}
|
|
413
416
|
}
|
|
414
417
|
|
|
415
418
|
function get_spread_update(levels, updates) {
|
|
@@ -731,7 +734,7 @@
|
|
|
731
734
|
|
|
732
735
|
var fuzzy = fuzzy$1.exports;
|
|
733
736
|
|
|
734
|
-
/* node_modules/svelte-search/src/Search.svelte generated by Svelte v3.
|
|
737
|
+
/* node_modules/svelte-search/src/Search.svelte generated by Svelte v3.49.0 */
|
|
735
738
|
|
|
736
739
|
function add_css$1(target) {
|
|
737
740
|
append_styles(target, "svelte-5m0wg6", ".hide-label.svelte-5m0wg6{position:absolute;height:1px;width:1px;overflow:hidden;clip:rect(1px 1px 1px 1px);clip:rect(1px, 1px, 1px, 1px);white-space:nowrap}");
|
|
@@ -1068,7 +1071,7 @@
|
|
|
1068
1071
|
|
|
1069
1072
|
var Search$1 = Search;
|
|
1070
1073
|
|
|
1071
|
-
/* src/Typeahead.svelte generated by Svelte v3.
|
|
1074
|
+
/* src/Typeahead.svelte generated by Svelte v3.49.0 */
|
|
1072
1075
|
|
|
1073
1076
|
function add_css(target) {
|
|
1074
1077
|
append_styles(target, "svelte-9wywte", "[data-svelte-typeahead].svelte-9wywte.svelte-9wywte{position:relative;background-color:#fff}ul.svelte-9wywte.svelte-9wywte{position:absolute;top:100%;left:0;width:100%;padding:0;list-style:none;background-color:inherit;box-shadow:0 4px 8px rgba(0, 0, 0, 0.1)}[aria-expanded=\"true\"].svelte-9wywte ul.svelte-9wywte{z-index:1}li.svelte-9wywte.svelte-9wywte,.no-results.svelte-9wywte.svelte-9wywte{padding:0.25rem 1rem}li.svelte-9wywte.svelte-9wywte{cursor:pointer}li.svelte-9wywte.svelte-9wywte:not(:last-of-type){border-bottom:1px solid #e0e0e0}li.svelte-9wywte.svelte-9wywte:hover{background-color:#e5e5e5}.selected.svelte-9wywte.svelte-9wywte{background-color:#e5e5e5}.selected.svelte-9wywte.svelte-9wywte:hover{background-color:#cacaca}.disabled.svelte-9wywte.svelte-9wywte{opacity:0.4;cursor:not-allowed}[data-svelte-search] label{margin-bottom:0.25rem;display:inline-flex;font-size:0.875rem}[data-svelte-search] input{width:100%;padding:0.5rem 0.75rem;background:none;font-size:1rem;border:0;border-radius:0;border:1px solid #e5e5e5}[data-svelte-search] input:focus{outline-color:#0f62fe;outline-offset:2px;outline-width:1px}");
|
|
@@ -1081,14 +1084,14 @@
|
|
|
1081
1084
|
|
|
1082
1085
|
const get_no_results_slot_context = ctx => ({
|
|
1083
1086
|
value: /*value*/ ctx[0],
|
|
1084
|
-
result: /*result*/ ctx[
|
|
1085
|
-
index: /*index*/ ctx[
|
|
1087
|
+
result: /*result*/ ctx[46],
|
|
1088
|
+
index: /*index*/ ctx[48]
|
|
1086
1089
|
});
|
|
1087
1090
|
|
|
1088
1091
|
function get_each_context(ctx, list, i) {
|
|
1089
1092
|
const child_ctx = ctx.slice();
|
|
1090
|
-
child_ctx[
|
|
1091
|
-
child_ctx[
|
|
1093
|
+
child_ctx[46] = list[i];
|
|
1094
|
+
child_ctx[48] = i;
|
|
1092
1095
|
return child_ctx;
|
|
1093
1096
|
}
|
|
1094
1097
|
|
|
@@ -1098,12 +1101,12 @@
|
|
|
1098
1101
|
});
|
|
1099
1102
|
|
|
1100
1103
|
const get_default_slot_context = ctx => ({
|
|
1101
|
-
result: /*result*/ ctx[
|
|
1102
|
-
index: /*index*/ ctx[
|
|
1104
|
+
result: /*result*/ ctx[46],
|
|
1105
|
+
index: /*index*/ ctx[48],
|
|
1103
1106
|
value: /*value*/ ctx[0]
|
|
1104
1107
|
});
|
|
1105
1108
|
|
|
1106
|
-
// (
|
|
1109
|
+
// (230:4) {#if showResults}
|
|
1107
1110
|
function create_if_block_1(ctx) {
|
|
1108
1111
|
let each_1_anchor;
|
|
1109
1112
|
let current;
|
|
@@ -1135,7 +1138,7 @@
|
|
|
1135
1138
|
current = true;
|
|
1136
1139
|
},
|
|
1137
1140
|
p(ctx, dirty) {
|
|
1138
|
-
if (dirty[0] & /*id, selectedIndex, results, select, $$scope, value*/
|
|
1141
|
+
if (dirty[0] & /*id, selectedIndex, results, select, $$scope, value*/ 33555975) {
|
|
1139
1142
|
each_value = /*results*/ ctx[1];
|
|
1140
1143
|
let i;
|
|
1141
1144
|
|
|
@@ -1187,10 +1190,10 @@
|
|
|
1187
1190
|
};
|
|
1188
1191
|
}
|
|
1189
1192
|
|
|
1190
|
-
// (
|
|
1193
|
+
// (248:41)
|
|
1191
1194
|
function fallback_block(ctx) {
|
|
1192
1195
|
let html_tag;
|
|
1193
|
-
let raw_value = /*result*/ ctx[
|
|
1196
|
+
let raw_value = /*result*/ ctx[46].string + "";
|
|
1194
1197
|
let html_anchor;
|
|
1195
1198
|
|
|
1196
1199
|
return {
|
|
@@ -1204,7 +1207,7 @@
|
|
|
1204
1207
|
insert(target, html_anchor, anchor);
|
|
1205
1208
|
},
|
|
1206
1209
|
p(ctx, dirty) {
|
|
1207
|
-
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);
|
|
1208
1211
|
},
|
|
1209
1212
|
d(detaching) {
|
|
1210
1213
|
if (detaching) detach(html_anchor);
|
|
@@ -1213,7 +1216,7 @@
|
|
|
1213
1216
|
};
|
|
1214
1217
|
}
|
|
1215
1218
|
|
|
1216
|
-
// (
|
|
1219
|
+
// (231:6) {#each results as result, index}
|
|
1217
1220
|
function create_each_block(ctx) {
|
|
1218
1221
|
let li;
|
|
1219
1222
|
let t;
|
|
@@ -1222,16 +1225,16 @@
|
|
|
1222
1225
|
let current;
|
|
1223
1226
|
let mounted;
|
|
1224
1227
|
let dispose;
|
|
1225
|
-
const default_slot_template = /*#slots*/ ctx[
|
|
1226
|
-
const default_slot = create_slot(default_slot_template, ctx, /*$$scope*/ ctx[
|
|
1228
|
+
const default_slot_template = /*#slots*/ ctx[26].default;
|
|
1229
|
+
const default_slot = create_slot(default_slot_template, ctx, /*$$scope*/ ctx[25], get_default_slot_context);
|
|
1227
1230
|
const default_slot_or_fallback = default_slot || fallback_block(ctx);
|
|
1228
1231
|
|
|
1229
1232
|
function click_handler_1() {
|
|
1230
|
-
return /*click_handler_1*/ ctx[
|
|
1233
|
+
return /*click_handler_1*/ ctx[39](/*result*/ ctx[46], /*index*/ ctx[48]);
|
|
1231
1234
|
}
|
|
1232
1235
|
|
|
1233
1236
|
function mouseenter_handler() {
|
|
1234
|
-
return /*mouseenter_handler*/ ctx[
|
|
1237
|
+
return /*mouseenter_handler*/ ctx[40](/*result*/ ctx[46], /*index*/ ctx[48]);
|
|
1235
1238
|
}
|
|
1236
1239
|
|
|
1237
1240
|
return {
|
|
@@ -1240,11 +1243,11 @@
|
|
|
1240
1243
|
if (default_slot_or_fallback) default_slot_or_fallback.c();
|
|
1241
1244
|
t = space();
|
|
1242
1245
|
attr(li, "role", "option");
|
|
1243
|
-
attr(li, "id", li_id_value = "" + (/*id*/ ctx[2] + "-result-" + /*index*/ ctx[
|
|
1244
|
-
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]);
|
|
1245
1248
|
attr(li, "class", "svelte-9wywte");
|
|
1246
|
-
toggle_class(li, "selected", /*selectedIndex*/ ctx[
|
|
1247
|
-
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);
|
|
1248
1251
|
},
|
|
1249
1252
|
m(target, anchor) {
|
|
1250
1253
|
insert(target, li, anchor);
|
|
@@ -1269,15 +1272,15 @@
|
|
|
1269
1272
|
ctx = new_ctx;
|
|
1270
1273
|
|
|
1271
1274
|
if (default_slot) {
|
|
1272
|
-
if (default_slot.p && (!current || dirty[0] & /*$$scope, results, value*/
|
|
1275
|
+
if (default_slot.p && (!current || dirty[0] & /*$$scope, results, value*/ 33554435)) {
|
|
1273
1276
|
update_slot_base(
|
|
1274
1277
|
default_slot,
|
|
1275
1278
|
default_slot_template,
|
|
1276
1279
|
ctx,
|
|
1277
|
-
/*$$scope*/ ctx[
|
|
1280
|
+
/*$$scope*/ ctx[25],
|
|
1278
1281
|
!current
|
|
1279
|
-
? get_all_dirty_from_scope(/*$$scope*/ ctx[
|
|
1280
|
-
: get_slot_changes(default_slot_template, /*$$scope*/ ctx[
|
|
1282
|
+
? get_all_dirty_from_scope(/*$$scope*/ ctx[25])
|
|
1283
|
+
: get_slot_changes(default_slot_template, /*$$scope*/ ctx[25], dirty, get_default_slot_changes),
|
|
1281
1284
|
get_default_slot_context
|
|
1282
1285
|
);
|
|
1283
1286
|
}
|
|
@@ -1287,20 +1290,20 @@
|
|
|
1287
1290
|
}
|
|
1288
1291
|
}
|
|
1289
1292
|
|
|
1290
|
-
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]))) {
|
|
1291
1294
|
attr(li, "id", li_id_value);
|
|
1292
1295
|
}
|
|
1293
1296
|
|
|
1294
|
-
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])) {
|
|
1295
1298
|
attr(li, "aria-selected", li_aria_selected_value);
|
|
1296
1299
|
}
|
|
1297
1300
|
|
|
1298
|
-
if (dirty[0] & /*selectedIndex*/
|
|
1299
|
-
toggle_class(li, "selected", /*selectedIndex*/ ctx[
|
|
1301
|
+
if (dirty[0] & /*selectedIndex*/ 512) {
|
|
1302
|
+
toggle_class(li, "selected", /*selectedIndex*/ ctx[9] === /*index*/ ctx[48]);
|
|
1300
1303
|
}
|
|
1301
1304
|
|
|
1302
1305
|
if (dirty[0] & /*results*/ 2) {
|
|
1303
|
-
toggle_class(li, "disabled", /*result*/ ctx[
|
|
1306
|
+
toggle_class(li, "disabled", /*result*/ ctx[46].disabled);
|
|
1304
1307
|
}
|
|
1305
1308
|
},
|
|
1306
1309
|
i(local) {
|
|
@@ -1321,12 +1324,12 @@
|
|
|
1321
1324
|
};
|
|
1322
1325
|
}
|
|
1323
1326
|
|
|
1324
|
-
// (
|
|
1327
|
+
// (254:4) {#if $$slots["no-results"] && !hideDropdown && value.length > 0 && results.length === 0}
|
|
1325
1328
|
function create_if_block(ctx) {
|
|
1326
1329
|
let div;
|
|
1327
1330
|
let current;
|
|
1328
|
-
const no_results_slot_template = /*#slots*/ ctx[
|
|
1329
|
-
const no_results_slot = create_slot(no_results_slot_template, ctx, /*$$scope*/ ctx[
|
|
1331
|
+
const no_results_slot_template = /*#slots*/ ctx[26]["no-results"];
|
|
1332
|
+
const no_results_slot = create_slot(no_results_slot_template, ctx, /*$$scope*/ ctx[25], get_no_results_slot_context);
|
|
1330
1333
|
|
|
1331
1334
|
return {
|
|
1332
1335
|
c() {
|
|
@@ -1346,15 +1349,15 @@
|
|
|
1346
1349
|
},
|
|
1347
1350
|
p(ctx, dirty) {
|
|
1348
1351
|
if (no_results_slot) {
|
|
1349
|
-
if (no_results_slot.p && (!current || dirty[0] & /*$$scope, value, results*/
|
|
1352
|
+
if (no_results_slot.p && (!current || dirty[0] & /*$$scope, value, results*/ 33554435)) {
|
|
1350
1353
|
update_slot_base(
|
|
1351
1354
|
no_results_slot,
|
|
1352
1355
|
no_results_slot_template,
|
|
1353
1356
|
ctx,
|
|
1354
|
-
/*$$scope*/ ctx[
|
|
1357
|
+
/*$$scope*/ ctx[25],
|
|
1355
1358
|
!current
|
|
1356
|
-
? get_all_dirty_from_scope(/*$$scope*/ ctx[
|
|
1357
|
-
: get_slot_changes(no_results_slot_template, /*$$scope*/ ctx[
|
|
1359
|
+
? get_all_dirty_from_scope(/*$$scope*/ ctx[25])
|
|
1360
|
+
: get_slot_changes(no_results_slot_template, /*$$scope*/ ctx[25], dirty, get_no_results_slot_changes),
|
|
1358
1361
|
get_no_results_slot_context
|
|
1359
1362
|
);
|
|
1360
1363
|
}
|
|
@@ -1395,7 +1398,7 @@
|
|
|
1395
1398
|
const search_spread_levels = [
|
|
1396
1399
|
{ id: /*id*/ ctx[2] },
|
|
1397
1400
|
{ removeFormAriaAttributes: true },
|
|
1398
|
-
/*$$restProps*/ ctx[
|
|
1401
|
+
/*$$restProps*/ ctx[15],
|
|
1399
1402
|
{ "aria-autocomplete": "list" },
|
|
1400
1403
|
{
|
|
1401
1404
|
"aria-controls": "" + (/*id*/ ctx[2] + "-listbox")
|
|
@@ -1404,18 +1407,18 @@
|
|
|
1404
1407
|
"aria-labelledby": "" + (/*id*/ ctx[2] + "-label")
|
|
1405
1408
|
},
|
|
1406
1409
|
{
|
|
1407
|
-
"aria-activedescendant": /*selectedIndex*/ ctx[
|
|
1408
|
-
? `${/*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]}`
|
|
1409
1412
|
: null
|
|
1410
1413
|
}
|
|
1411
1414
|
];
|
|
1412
1415
|
|
|
1413
1416
|
function search_ref_binding(value) {
|
|
1414
|
-
/*search_ref_binding*/ ctx[
|
|
1417
|
+
/*search_ref_binding*/ ctx[28](value);
|
|
1415
1418
|
}
|
|
1416
1419
|
|
|
1417
1420
|
function search_value_binding(value) {
|
|
1418
|
-
/*search_value_binding*/ ctx[
|
|
1421
|
+
/*search_value_binding*/ ctx[29](value);
|
|
1419
1422
|
}
|
|
1420
1423
|
|
|
1421
1424
|
let search_props = {};
|
|
@@ -1424,8 +1427,8 @@
|
|
|
1424
1427
|
search_props = assign(search_props, search_spread_levels[i]);
|
|
1425
1428
|
}
|
|
1426
1429
|
|
|
1427
|
-
if (/*searchRef*/ ctx[
|
|
1428
|
-
search_props.ref = /*searchRef*/ ctx[
|
|
1430
|
+
if (/*searchRef*/ ctx[8] !== void 0) {
|
|
1431
|
+
search_props.ref = /*searchRef*/ ctx[8];
|
|
1429
1432
|
}
|
|
1430
1433
|
|
|
1431
1434
|
if (/*value*/ ctx[0] !== void 0) {
|
|
@@ -1435,18 +1438,18 @@
|
|
|
1435
1438
|
search = new Search$1({ props: search_props });
|
|
1436
1439
|
binding_callbacks.push(() => bind(search, 'ref', search_ref_binding));
|
|
1437
1440
|
binding_callbacks.push(() => bind(search, 'value', search_value_binding));
|
|
1438
|
-
search.$on("type", /*type_handler*/ ctx[
|
|
1439
|
-
search.$on("input", /*input_handler*/ ctx[
|
|
1440
|
-
search.$on("change", /*change_handler*/ ctx[
|
|
1441
|
-
search.$on("focus", /*focus_handler*/ ctx[
|
|
1442
|
-
search.$on("focus", /*focus_handler_1*/ ctx[
|
|
1443
|
-
search.$on("clear", /*clear_handler*/ ctx[
|
|
1444
|
-
search.$on("clear", /*
|
|
1445
|
-
search.$on("blur", /*blur_handler*/ ctx[
|
|
1446
|
-
search.$on("keydown", /*keydown_handler*/ ctx[
|
|
1447
|
-
search.$on("keydown", /*keydown_handler_1*/ ctx[
|
|
1448
|
-
let if_block0 = /*showResults*/ ctx[
|
|
1449
|
-
let if_block1 = /*$$slots*/ ctx[
|
|
1441
|
+
search.$on("type", /*type_handler*/ ctx[30]);
|
|
1442
|
+
search.$on("input", /*input_handler*/ ctx[31]);
|
|
1443
|
+
search.$on("change", /*change_handler*/ ctx[32]);
|
|
1444
|
+
search.$on("focus", /*focus_handler*/ ctx[33]);
|
|
1445
|
+
search.$on("focus", /*focus_handler_1*/ ctx[34]);
|
|
1446
|
+
search.$on("clear", /*clear_handler*/ ctx[35]);
|
|
1447
|
+
search.$on("clear", /*open*/ ctx[12]);
|
|
1448
|
+
search.$on("blur", /*blur_handler*/ ctx[36]);
|
|
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);
|
|
1450
1453
|
|
|
1451
1454
|
return {
|
|
1452
1455
|
c() {
|
|
@@ -1466,7 +1469,7 @@
|
|
|
1466
1469
|
attr(div, "role", "combobox");
|
|
1467
1470
|
attr(div, "aria-haspopup", "listbox");
|
|
1468
1471
|
attr(div, "aria-owns", div_aria_owns_value = "" + (/*id*/ ctx[2] + "-listbox"));
|
|
1469
|
-
attr(div, "aria-expanded", /*showResults*/ ctx[
|
|
1472
|
+
attr(div, "aria-expanded", /*showResults*/ ctx[6]);
|
|
1470
1473
|
attr(div, "id", div_id_value = "" + (/*id*/ ctx[2] + "-typeahead"));
|
|
1471
1474
|
attr(div, "class", "svelte-9wywte");
|
|
1472
1475
|
toggle_class(div, "dropdown", /*results*/ ctx[1].length > 0);
|
|
@@ -1479,20 +1482,20 @@
|
|
|
1479
1482
|
if (if_block0) if_block0.m(ul, null);
|
|
1480
1483
|
append(ul, t1);
|
|
1481
1484
|
if (if_block1) if_block1.m(ul, null);
|
|
1482
|
-
/*div_binding*/ ctx[
|
|
1485
|
+
/*div_binding*/ ctx[41](div);
|
|
1483
1486
|
current = true;
|
|
1484
1487
|
|
|
1485
1488
|
if (!mounted) {
|
|
1486
|
-
dispose = listen(window, "click", /*click_handler*/ ctx[
|
|
1489
|
+
dispose = listen(window, "click", /*click_handler*/ ctx[27]);
|
|
1487
1490
|
mounted = true;
|
|
1488
1491
|
}
|
|
1489
1492
|
},
|
|
1490
1493
|
p(ctx, dirty) {
|
|
1491
|
-
const search_changes = (dirty[0] & /*id, $$restProps, selectedIndex, hideDropdown, results*/
|
|
1494
|
+
const search_changes = (dirty[0] & /*id, $$restProps, selectedIndex, hideDropdown, results*/ 33302)
|
|
1492
1495
|
? get_spread_update(search_spread_levels, [
|
|
1493
1496
|
dirty[0] & /*id*/ 4 && { id: /*id*/ ctx[2] },
|
|
1494
1497
|
search_spread_levels[1],
|
|
1495
|
-
dirty[0] & /*$$restProps*/
|
|
1498
|
+
dirty[0] & /*$$restProps*/ 32768 && get_spread_object(/*$$restProps*/ ctx[15]),
|
|
1496
1499
|
search_spread_levels[3],
|
|
1497
1500
|
dirty[0] & /*id*/ 4 && {
|
|
1498
1501
|
"aria-controls": "" + (/*id*/ ctx[2] + "-listbox")
|
|
@@ -1500,17 +1503,17 @@
|
|
|
1500
1503
|
dirty[0] & /*id*/ 4 && {
|
|
1501
1504
|
"aria-labelledby": "" + (/*id*/ ctx[2] + "-label")
|
|
1502
1505
|
},
|
|
1503
|
-
dirty[0] & /*selectedIndex, hideDropdown, results, id*/
|
|
1504
|
-
"aria-activedescendant": /*selectedIndex*/ ctx[
|
|
1505
|
-
? `${/*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]}`
|
|
1506
1509
|
: null
|
|
1507
1510
|
}
|
|
1508
1511
|
])
|
|
1509
1512
|
: {};
|
|
1510
1513
|
|
|
1511
|
-
if (!updating_ref && dirty[0] & /*searchRef*/
|
|
1514
|
+
if (!updating_ref && dirty[0] & /*searchRef*/ 256) {
|
|
1512
1515
|
updating_ref = true;
|
|
1513
|
-
search_changes.ref = /*searchRef*/ ctx[
|
|
1516
|
+
search_changes.ref = /*searchRef*/ ctx[8];
|
|
1514
1517
|
add_flush_callback(() => updating_ref = false);
|
|
1515
1518
|
}
|
|
1516
1519
|
|
|
@@ -1522,11 +1525,11 @@
|
|
|
1522
1525
|
|
|
1523
1526
|
search.$set(search_changes);
|
|
1524
1527
|
|
|
1525
|
-
if (/*showResults*/ ctx[
|
|
1528
|
+
if (/*showResults*/ ctx[6]) {
|
|
1526
1529
|
if (if_block0) {
|
|
1527
1530
|
if_block0.p(ctx, dirty);
|
|
1528
1531
|
|
|
1529
|
-
if (dirty[0] & /*showResults*/
|
|
1532
|
+
if (dirty[0] & /*showResults*/ 64) {
|
|
1530
1533
|
transition_in(if_block0, 1);
|
|
1531
1534
|
}
|
|
1532
1535
|
} else {
|
|
@@ -1545,11 +1548,11 @@
|
|
|
1545
1548
|
check_outros();
|
|
1546
1549
|
}
|
|
1547
1550
|
|
|
1548
|
-
if (/*$$slots*/ ctx[
|
|
1551
|
+
if (/*$$slots*/ ctx[14]["no-results"] && !/*hideDropdown*/ ctx[4] && /*value*/ ctx[0].length > 0 && /*results*/ ctx[1].length === 0) {
|
|
1549
1552
|
if (if_block1) {
|
|
1550
1553
|
if_block1.p(ctx, dirty);
|
|
1551
1554
|
|
|
1552
|
-
if (dirty[0] & /*$$slots, hideDropdown, value, results*/
|
|
1555
|
+
if (dirty[0] & /*$$slots, hideDropdown, value, results*/ 16403) {
|
|
1553
1556
|
transition_in(if_block1, 1);
|
|
1554
1557
|
}
|
|
1555
1558
|
} else {
|
|
@@ -1580,8 +1583,8 @@
|
|
|
1580
1583
|
attr(div, "aria-owns", div_aria_owns_value);
|
|
1581
1584
|
}
|
|
1582
1585
|
|
|
1583
|
-
if (!current || dirty[0] & /*showResults*/
|
|
1584
|
-
attr(div, "aria-expanded", /*showResults*/ ctx[
|
|
1586
|
+
if (!current || dirty[0] & /*showResults*/ 64) {
|
|
1587
|
+
attr(div, "aria-expanded", /*showResults*/ ctx[6]);
|
|
1585
1588
|
}
|
|
1586
1589
|
|
|
1587
1590
|
if (!current || dirty[0] & /*id*/ 4 && div_id_value !== (div_id_value = "" + (/*id*/ ctx[2] + "-typeahead"))) {
|
|
@@ -1610,7 +1613,7 @@
|
|
|
1610
1613
|
destroy_component(search);
|
|
1611
1614
|
if (if_block0) if_block0.d();
|
|
1612
1615
|
if (if_block1) if_block1.d();
|
|
1613
|
-
/*div_binding*/ ctx[
|
|
1616
|
+
/*div_binding*/ ctx[41](null);
|
|
1614
1617
|
mounted = false;
|
|
1615
1618
|
dispose();
|
|
1616
1619
|
}
|
|
@@ -1623,7 +1626,7 @@
|
|
|
1623
1626
|
let showResults;
|
|
1624
1627
|
|
|
1625
1628
|
const omit_props_names = [
|
|
1626
|
-
"id","value","data","extract","disable","filter","autoselect","inputAfterSelect","results","focusAfterSelect","limit"
|
|
1629
|
+
"id","value","data","extract","disable","filter","autoselect","inputAfterSelect","results","focusAfterSelect","showDropdownOnFocus","limit"
|
|
1627
1630
|
];
|
|
1628
1631
|
|
|
1629
1632
|
let $$restProps = compute_rest_props($$props, omit_props_names);
|
|
@@ -1639,6 +1642,7 @@
|
|
|
1639
1642
|
let { inputAfterSelect = "update" } = $$props;
|
|
1640
1643
|
let { results = [] } = $$props;
|
|
1641
1644
|
let { focusAfterSelect = false } = $$props;
|
|
1645
|
+
let { showDropdownOnFocus = false } = $$props;
|
|
1642
1646
|
let { limit = Infinity } = $$props;
|
|
1643
1647
|
const dispatch = createEventDispatcher();
|
|
1644
1648
|
let comboboxRef = null;
|
|
@@ -1646,14 +1650,15 @@
|
|
|
1646
1650
|
let hideDropdown = false;
|
|
1647
1651
|
let selectedIndex = -1;
|
|
1648
1652
|
let prevResults = "";
|
|
1653
|
+
let isFocused = false;
|
|
1649
1654
|
|
|
1650
1655
|
afterUpdate(() => {
|
|
1651
1656
|
if (prevResults !== resultsId && autoselect) {
|
|
1652
|
-
$$invalidate(
|
|
1657
|
+
$$invalidate(9, selectedIndex = getNextNonDisabledIndex());
|
|
1653
1658
|
}
|
|
1654
1659
|
|
|
1655
1660
|
if (prevResults !== resultsId && !$$slots["no-results"]) {
|
|
1656
|
-
$$invalidate(
|
|
1661
|
+
$$invalidate(4, hideDropdown = results.length === 0);
|
|
1657
1662
|
}
|
|
1658
1663
|
|
|
1659
1664
|
prevResults = resultsId;
|
|
@@ -1677,7 +1682,25 @@
|
|
|
1677
1682
|
|
|
1678
1683
|
await tick();
|
|
1679
1684
|
if (focusAfterSelect) searchRef.focus();
|
|
1680
|
-
|
|
1685
|
+
close();
|
|
1686
|
+
}
|
|
1687
|
+
|
|
1688
|
+
/** @type {() => number} */
|
|
1689
|
+
function getNextNonDisabledIndex() {
|
|
1690
|
+
let index = 0;
|
|
1691
|
+
let disabled = results[index]?.disabled ?? false;
|
|
1692
|
+
|
|
1693
|
+
while (disabled) {
|
|
1694
|
+
if (index === results.length) {
|
|
1695
|
+
index = 0;
|
|
1696
|
+
} else {
|
|
1697
|
+
index += 1;
|
|
1698
|
+
}
|
|
1699
|
+
|
|
1700
|
+
disabled = results[index]?.disabled ?? false;
|
|
1701
|
+
}
|
|
1702
|
+
|
|
1703
|
+
return index;
|
|
1681
1704
|
}
|
|
1682
1705
|
|
|
1683
1706
|
/** @type {(direction: -1 | 1) => void} */
|
|
@@ -1699,18 +1722,21 @@
|
|
|
1699
1722
|
disabled = results[index].disabled;
|
|
1700
1723
|
}
|
|
1701
1724
|
|
|
1702
|
-
$$invalidate(
|
|
1725
|
+
$$invalidate(9, selectedIndex = index);
|
|
1703
1726
|
}
|
|
1704
1727
|
|
|
1728
|
+
const open = () => $$invalidate(4, hideDropdown = false);
|
|
1729
|
+
const close = () => $$invalidate(4, hideDropdown = true);
|
|
1730
|
+
|
|
1705
1731
|
const click_handler = ({ target }) => {
|
|
1706
|
-
if (!hideDropdown &&
|
|
1707
|
-
|
|
1732
|
+
if (!hideDropdown && !comboboxRef?.contains(target)) {
|
|
1733
|
+
close();
|
|
1708
1734
|
}
|
|
1709
1735
|
};
|
|
1710
1736
|
|
|
1711
1737
|
function search_ref_binding(value) {
|
|
1712
1738
|
searchRef = value;
|
|
1713
|
-
$$invalidate(
|
|
1739
|
+
$$invalidate(8, searchRef);
|
|
1714
1740
|
}
|
|
1715
1741
|
|
|
1716
1742
|
function search_value_binding(value$1) {
|
|
@@ -1735,17 +1761,18 @@
|
|
|
1735
1761
|
}
|
|
1736
1762
|
|
|
1737
1763
|
const focus_handler_1 = () => {
|
|
1738
|
-
|
|
1764
|
+
open();
|
|
1765
|
+
|
|
1766
|
+
if (showDropdownOnFocus) {
|
|
1767
|
+
$$invalidate(6, showResults = true);
|
|
1768
|
+
$$invalidate(5, isFocused = true);
|
|
1769
|
+
}
|
|
1739
1770
|
};
|
|
1740
1771
|
|
|
1741
1772
|
function clear_handler(event) {
|
|
1742
1773
|
bubble.call(this, $$self, event);
|
|
1743
1774
|
}
|
|
1744
1775
|
|
|
1745
|
-
const clear_handler_1 = () => {
|
|
1746
|
-
$$invalidate(3, hideDropdown = false);
|
|
1747
|
-
};
|
|
1748
|
-
|
|
1749
1776
|
function blur_handler(event) {
|
|
1750
1777
|
bubble.call(this, $$self, event);
|
|
1751
1778
|
}
|
|
@@ -1772,65 +1799,72 @@
|
|
|
1772
1799
|
case "Escape":
|
|
1773
1800
|
e.preventDefault();
|
|
1774
1801
|
$$invalidate(0, value = "");
|
|
1775
|
-
searchRef
|
|
1776
|
-
|
|
1802
|
+
searchRef?.focus();
|
|
1803
|
+
close();
|
|
1777
1804
|
break;
|
|
1778
1805
|
}
|
|
1779
1806
|
};
|
|
1780
1807
|
|
|
1781
1808
|
const click_handler_1 = (result, index) => {
|
|
1782
1809
|
if (result.disabled) return;
|
|
1783
|
-
$$invalidate(
|
|
1810
|
+
$$invalidate(9, selectedIndex = index);
|
|
1784
1811
|
select();
|
|
1785
1812
|
};
|
|
1786
1813
|
|
|
1787
1814
|
const mouseenter_handler = (result, index) => {
|
|
1788
1815
|
if (result.disabled) return;
|
|
1789
|
-
$$invalidate(
|
|
1816
|
+
$$invalidate(9, selectedIndex = index);
|
|
1790
1817
|
};
|
|
1791
1818
|
|
|
1792
1819
|
function div_binding($$value) {
|
|
1793
1820
|
binding_callbacks[$$value ? 'unshift' : 'push'](() => {
|
|
1794
1821
|
comboboxRef = $$value;
|
|
1795
|
-
$$invalidate(
|
|
1822
|
+
$$invalidate(7, comboboxRef);
|
|
1796
1823
|
});
|
|
1797
1824
|
}
|
|
1798
1825
|
|
|
1799
1826
|
$$self.$$set = $$new_props => {
|
|
1800
1827
|
$$props = assign(assign({}, $$props), exclude_internal_props($$new_props));
|
|
1801
|
-
$$invalidate(
|
|
1828
|
+
$$invalidate(15, $$restProps = compute_rest_props($$props, omit_props_names));
|
|
1802
1829
|
if ('id' in $$new_props) $$invalidate(2, id = $$new_props.id);
|
|
1803
1830
|
if ('value' in $$new_props) $$invalidate(0, value = $$new_props.value);
|
|
1804
|
-
if ('data' in $$new_props) $$invalidate(
|
|
1805
|
-
if ('extract' in $$new_props) $$invalidate(
|
|
1806
|
-
if ('disable' in $$new_props) $$invalidate(
|
|
1807
|
-
if ('filter' in $$new_props) $$invalidate(
|
|
1808
|
-
if ('autoselect' in $$new_props) $$invalidate(
|
|
1809
|
-
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);
|
|
1810
1837
|
if ('results' in $$new_props) $$invalidate(1, results = $$new_props.results);
|
|
1811
|
-
if ('focusAfterSelect' in $$new_props) $$invalidate(
|
|
1812
|
-
if ('
|
|
1813
|
-
if ('
|
|
1838
|
+
if ('focusAfterSelect' in $$new_props) $$invalidate(22, focusAfterSelect = $$new_props.focusAfterSelect);
|
|
1839
|
+
if ('showDropdownOnFocus' in $$new_props) $$invalidate(3, showDropdownOnFocus = $$new_props.showDropdownOnFocus);
|
|
1840
|
+
if ('limit' in $$new_props) $$invalidate(23, limit = $$new_props.limit);
|
|
1841
|
+
if ('$$scope' in $$new_props) $$invalidate(25, $$scope = $$new_props.$$scope);
|
|
1814
1842
|
};
|
|
1815
1843
|
|
|
1816
1844
|
$$self.$$.update = () => {
|
|
1817
|
-
if ($$self.$$.dirty[0] & /*extract*/
|
|
1818
|
-
$$invalidate(
|
|
1845
|
+
if ($$self.$$.dirty[0] & /*extract*/ 131072) {
|
|
1846
|
+
$$invalidate(24, options = { pre: "<mark>", post: "</mark>", extract });
|
|
1819
1847
|
}
|
|
1820
1848
|
|
|
1821
|
-
if ($$self.$$.dirty[0] & /*value, data, options, limit, filter, disable*/
|
|
1849
|
+
if ($$self.$$.dirty[0] & /*value, data, options, limit, filter, disable*/ 26017793) {
|
|
1822
1850
|
$$invalidate(1, results = fuzzy.filter(value, data, options).filter(({ score }) => score > 0).slice(0, limit).filter(result => !filter(result.original)).map(result => ({
|
|
1823
1851
|
...result,
|
|
1824
1852
|
disabled: disable(result.original)
|
|
1825
1853
|
})));
|
|
1826
1854
|
}
|
|
1827
1855
|
|
|
1828
|
-
if ($$self.$$.dirty[0] & /*results, extract*/
|
|
1856
|
+
if ($$self.$$.dirty[0] & /*results, extract*/ 131074) {
|
|
1829
1857
|
resultsId = results.map(result => extract(result.original)).join("");
|
|
1830
1858
|
}
|
|
1831
1859
|
|
|
1832
|
-
if ($$self.$$.dirty[0] & /*hideDropdown, results*/
|
|
1833
|
-
$$invalidate(
|
|
1860
|
+
if ($$self.$$.dirty[0] & /*hideDropdown, results*/ 18) {
|
|
1861
|
+
$$invalidate(6, showResults = !hideDropdown && results.length > 0);
|
|
1862
|
+
}
|
|
1863
|
+
|
|
1864
|
+
if ($$self.$$.dirty[0] & /*showDropdownOnFocus, showResults, isFocused*/ 104) {
|
|
1865
|
+
if (showDropdownOnFocus) {
|
|
1866
|
+
$$invalidate(6, showResults = showResults && isFocused);
|
|
1867
|
+
}
|
|
1834
1868
|
}
|
|
1835
1869
|
};
|
|
1836
1870
|
|
|
@@ -1838,13 +1872,17 @@
|
|
|
1838
1872
|
value,
|
|
1839
1873
|
results,
|
|
1840
1874
|
id,
|
|
1875
|
+
showDropdownOnFocus,
|
|
1841
1876
|
hideDropdown,
|
|
1877
|
+
isFocused,
|
|
1878
|
+
showResults,
|
|
1842
1879
|
comboboxRef,
|
|
1843
1880
|
searchRef,
|
|
1844
1881
|
selectedIndex,
|
|
1845
|
-
showResults,
|
|
1846
1882
|
select,
|
|
1847
1883
|
change,
|
|
1884
|
+
open,
|
|
1885
|
+
close,
|
|
1848
1886
|
$$slots,
|
|
1849
1887
|
$$restProps,
|
|
1850
1888
|
data,
|
|
@@ -1867,7 +1905,6 @@
|
|
|
1867
1905
|
focus_handler,
|
|
1868
1906
|
focus_handler_1,
|
|
1869
1907
|
clear_handler,
|
|
1870
|
-
clear_handler_1,
|
|
1871
1908
|
blur_handler,
|
|
1872
1909
|
keydown_handler,
|
|
1873
1910
|
keydown_handler_1,
|
|
@@ -1890,15 +1927,16 @@
|
|
|
1890
1927
|
{
|
|
1891
1928
|
id: 2,
|
|
1892
1929
|
value: 0,
|
|
1893
|
-
data:
|
|
1894
|
-
extract:
|
|
1895
|
-
disable:
|
|
1896
|
-
filter:
|
|
1897
|
-
autoselect:
|
|
1898
|
-
inputAfterSelect:
|
|
1930
|
+
data: 16,
|
|
1931
|
+
extract: 17,
|
|
1932
|
+
disable: 18,
|
|
1933
|
+
filter: 19,
|
|
1934
|
+
autoselect: 20,
|
|
1935
|
+
inputAfterSelect: 21,
|
|
1899
1936
|
results: 1,
|
|
1900
|
-
focusAfterSelect:
|
|
1901
|
-
|
|
1937
|
+
focusAfterSelect: 22,
|
|
1938
|
+
showDropdownOnFocus: 3,
|
|
1939
|
+
limit: 23
|
|
1902
1940
|
},
|
|
1903
1941
|
add_css,
|
|
1904
1942
|
[-1, -1]
|
|
@@ -1906,9 +1944,7 @@
|
|
|
1906
1944
|
}
|
|
1907
1945
|
}
|
|
1908
1946
|
|
|
1909
|
-
|
|
1910
|
-
|
|
1911
|
-
exports["default"] = Typeahead$1;
|
|
1947
|
+
exports["default"] = Typeahead;
|
|
1912
1948
|
|
|
1913
1949
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
1914
1950
|
|