svelte-typeahead 4.2.4 → 4.3.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/CHANGELOG.md +6 -0
- package/README.md +34 -32
- package/lib/index.js +138 -116
- package/lib/index.mjs +138 -116
- package/package.json +2 -2
- package/src/Typeahead.svelte +21 -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
|
+
// (212: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*/ 33555207) {
|
|
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
|
+
// (230: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
|
+
// (213: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[40](/*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[41](/*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[8] === /*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[8] === /*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*/ 256 && li_aria_selected_value !== (li_aria_selected_value = /*selectedIndex*/ ctx[8] === /*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*/ 256) {
|
|
1302
|
+
toggle_class(li, "selected", /*selectedIndex*/ ctx[8] === /*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
|
+
// (236: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[14],
|
|
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[8] >= 0 && !/*hideDropdown*/ ctx[3] && /*results*/ ctx[1].length > 0
|
|
1411
|
+
? `${/*id*/ ctx[2]}-result-${/*selectedIndex*/ ctx[8]}`
|
|
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[7] !== void 0) {
|
|
1431
|
+
search_props.ref = /*searchRef*/ ctx[7];
|
|
1429
1432
|
}
|
|
1430
1433
|
|
|
1431
1434
|
if (/*value*/ ctx[0] !== void 0) {
|
|
@@ -1435,18 +1438,19 @@
|
|
|
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("
|
|
1447
|
-
search.$on("keydown", /*
|
|
1448
|
-
|
|
1449
|
-
let
|
|
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[11]);
|
|
1448
|
+
search.$on("blur", /*blur_handler*/ ctx[36]);
|
|
1449
|
+
search.$on("blur", /*blur_handler_1*/ ctx[37]);
|
|
1450
|
+
search.$on("keydown", /*keydown_handler*/ ctx[38]);
|
|
1451
|
+
search.$on("keydown", /*keydown_handler_1*/ ctx[39]);
|
|
1452
|
+
let if_block0 = /*showResults*/ ctx[5] && create_if_block_1(ctx);
|
|
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);
|
|
1450
1454
|
|
|
1451
1455
|
return {
|
|
1452
1456
|
c() {
|
|
@@ -1466,7 +1470,7 @@
|
|
|
1466
1470
|
attr(div, "role", "combobox");
|
|
1467
1471
|
attr(div, "aria-haspopup", "listbox");
|
|
1468
1472
|
attr(div, "aria-owns", div_aria_owns_value = "" + (/*id*/ ctx[2] + "-listbox"));
|
|
1469
|
-
attr(div, "aria-expanded", /*showResults*/ ctx[
|
|
1473
|
+
attr(div, "aria-expanded", /*showResults*/ ctx[5]);
|
|
1470
1474
|
attr(div, "id", div_id_value = "" + (/*id*/ ctx[2] + "-typeahead"));
|
|
1471
1475
|
attr(div, "class", "svelte-9wywte");
|
|
1472
1476
|
toggle_class(div, "dropdown", /*results*/ ctx[1].length > 0);
|
|
@@ -1479,20 +1483,20 @@
|
|
|
1479
1483
|
if (if_block0) if_block0.m(ul, null);
|
|
1480
1484
|
append(ul, t1);
|
|
1481
1485
|
if (if_block1) if_block1.m(ul, null);
|
|
1482
|
-
/*div_binding*/ ctx[
|
|
1486
|
+
/*div_binding*/ ctx[42](div);
|
|
1483
1487
|
current = true;
|
|
1484
1488
|
|
|
1485
1489
|
if (!mounted) {
|
|
1486
|
-
dispose = listen(window, "click", /*click_handler*/ ctx[
|
|
1490
|
+
dispose = listen(window, "click", /*click_handler*/ ctx[27]);
|
|
1487
1491
|
mounted = true;
|
|
1488
1492
|
}
|
|
1489
1493
|
},
|
|
1490
1494
|
p(ctx, dirty) {
|
|
1491
|
-
const search_changes = (dirty[0] & /*id, $$restProps, selectedIndex, hideDropdown, results*/
|
|
1495
|
+
const search_changes = (dirty[0] & /*id, $$restProps, selectedIndex, hideDropdown, results*/ 16654)
|
|
1492
1496
|
? get_spread_update(search_spread_levels, [
|
|
1493
1497
|
dirty[0] & /*id*/ 4 && { id: /*id*/ ctx[2] },
|
|
1494
1498
|
search_spread_levels[1],
|
|
1495
|
-
dirty[0] & /*$$restProps*/
|
|
1499
|
+
dirty[0] & /*$$restProps*/ 16384 && get_spread_object(/*$$restProps*/ ctx[14]),
|
|
1496
1500
|
search_spread_levels[3],
|
|
1497
1501
|
dirty[0] & /*id*/ 4 && {
|
|
1498
1502
|
"aria-controls": "" + (/*id*/ ctx[2] + "-listbox")
|
|
@@ -1500,17 +1504,17 @@
|
|
|
1500
1504
|
dirty[0] & /*id*/ 4 && {
|
|
1501
1505
|
"aria-labelledby": "" + (/*id*/ ctx[2] + "-label")
|
|
1502
1506
|
},
|
|
1503
|
-
dirty[0] & /*selectedIndex, hideDropdown, results, id*/
|
|
1504
|
-
"aria-activedescendant": /*selectedIndex*/ ctx[
|
|
1505
|
-
? `${/*id*/ ctx[2]}-result-${/*selectedIndex*/ ctx[
|
|
1507
|
+
dirty[0] & /*selectedIndex, hideDropdown, results, id*/ 270 && {
|
|
1508
|
+
"aria-activedescendant": /*selectedIndex*/ ctx[8] >= 0 && !/*hideDropdown*/ ctx[3] && /*results*/ ctx[1].length > 0
|
|
1509
|
+
? `${/*id*/ ctx[2]}-result-${/*selectedIndex*/ ctx[8]}`
|
|
1506
1510
|
: null
|
|
1507
1511
|
}
|
|
1508
1512
|
])
|
|
1509
1513
|
: {};
|
|
1510
1514
|
|
|
1511
|
-
if (!updating_ref && dirty[0] & /*searchRef*/
|
|
1515
|
+
if (!updating_ref && dirty[0] & /*searchRef*/ 128) {
|
|
1512
1516
|
updating_ref = true;
|
|
1513
|
-
search_changes.ref = /*searchRef*/ ctx[
|
|
1517
|
+
search_changes.ref = /*searchRef*/ ctx[7];
|
|
1514
1518
|
add_flush_callback(() => updating_ref = false);
|
|
1515
1519
|
}
|
|
1516
1520
|
|
|
@@ -1522,11 +1526,11 @@
|
|
|
1522
1526
|
|
|
1523
1527
|
search.$set(search_changes);
|
|
1524
1528
|
|
|
1525
|
-
if (/*showResults*/ ctx[
|
|
1529
|
+
if (/*showResults*/ ctx[5]) {
|
|
1526
1530
|
if (if_block0) {
|
|
1527
1531
|
if_block0.p(ctx, dirty);
|
|
1528
1532
|
|
|
1529
|
-
if (dirty[0] & /*showResults*/
|
|
1533
|
+
if (dirty[0] & /*showResults*/ 32) {
|
|
1530
1534
|
transition_in(if_block0, 1);
|
|
1531
1535
|
}
|
|
1532
1536
|
} else {
|
|
@@ -1545,11 +1549,11 @@
|
|
|
1545
1549
|
check_outros();
|
|
1546
1550
|
}
|
|
1547
1551
|
|
|
1548
|
-
if (/*$$slots*/ ctx[
|
|
1552
|
+
if (/*$$slots*/ ctx[13]["no-results"] && !/*hideDropdown*/ ctx[3] && /*value*/ ctx[0].length > 0 && /*results*/ ctx[1].length === 0) {
|
|
1549
1553
|
if (if_block1) {
|
|
1550
1554
|
if_block1.p(ctx, dirty);
|
|
1551
1555
|
|
|
1552
|
-
if (dirty[0] & /*$$slots, hideDropdown, value, results*/
|
|
1556
|
+
if (dirty[0] & /*$$slots, hideDropdown, value, results*/ 8203) {
|
|
1553
1557
|
transition_in(if_block1, 1);
|
|
1554
1558
|
}
|
|
1555
1559
|
} else {
|
|
@@ -1580,8 +1584,8 @@
|
|
|
1580
1584
|
attr(div, "aria-owns", div_aria_owns_value);
|
|
1581
1585
|
}
|
|
1582
1586
|
|
|
1583
|
-
if (!current || dirty[0] & /*showResults*/
|
|
1584
|
-
attr(div, "aria-expanded", /*showResults*/ ctx[
|
|
1587
|
+
if (!current || dirty[0] & /*showResults*/ 32) {
|
|
1588
|
+
attr(div, "aria-expanded", /*showResults*/ ctx[5]);
|
|
1585
1589
|
}
|
|
1586
1590
|
|
|
1587
1591
|
if (!current || dirty[0] & /*id*/ 4 && div_id_value !== (div_id_value = "" + (/*id*/ ctx[2] + "-typeahead"))) {
|
|
@@ -1610,7 +1614,7 @@
|
|
|
1610
1614
|
destroy_component(search);
|
|
1611
1615
|
if (if_block0) if_block0.d();
|
|
1612
1616
|
if (if_block1) if_block1.d();
|
|
1613
|
-
/*div_binding*/ ctx[
|
|
1617
|
+
/*div_binding*/ ctx[42](null);
|
|
1614
1618
|
mounted = false;
|
|
1615
1619
|
dispose();
|
|
1616
1620
|
}
|
|
@@ -1623,7 +1627,7 @@
|
|
|
1623
1627
|
let showResults;
|
|
1624
1628
|
|
|
1625
1629
|
const omit_props_names = [
|
|
1626
|
-
"id","value","data","extract","disable","filter","autoselect","inputAfterSelect","results","focusAfterSelect","limit"
|
|
1630
|
+
"id","value","data","extract","disable","filter","autoselect","inputAfterSelect","results","focusAfterSelect","showDropdownOnFocus","limit"
|
|
1627
1631
|
];
|
|
1628
1632
|
|
|
1629
1633
|
let $$restProps = compute_rest_props($$props, omit_props_names);
|
|
@@ -1639,6 +1643,7 @@
|
|
|
1639
1643
|
let { inputAfterSelect = "update" } = $$props;
|
|
1640
1644
|
let { results = [] } = $$props;
|
|
1641
1645
|
let { focusAfterSelect = false } = $$props;
|
|
1646
|
+
let { showDropdownOnFocus = false } = $$props;
|
|
1642
1647
|
let { limit = Infinity } = $$props;
|
|
1643
1648
|
const dispatch = createEventDispatcher();
|
|
1644
1649
|
let comboboxRef = null;
|
|
@@ -1646,10 +1651,11 @@
|
|
|
1646
1651
|
let hideDropdown = false;
|
|
1647
1652
|
let selectedIndex = -1;
|
|
1648
1653
|
let prevResults = "";
|
|
1654
|
+
let isFocused = false;
|
|
1649
1655
|
|
|
1650
1656
|
afterUpdate(() => {
|
|
1651
1657
|
if (prevResults !== resultsId && autoselect) {
|
|
1652
|
-
$$invalidate(
|
|
1658
|
+
$$invalidate(8, selectedIndex = 0);
|
|
1653
1659
|
}
|
|
1654
1660
|
|
|
1655
1661
|
if (prevResults !== resultsId && !$$slots["no-results"]) {
|
|
@@ -1677,7 +1683,7 @@
|
|
|
1677
1683
|
|
|
1678
1684
|
await tick();
|
|
1679
1685
|
if (focusAfterSelect) searchRef.focus();
|
|
1680
|
-
|
|
1686
|
+
close();
|
|
1681
1687
|
}
|
|
1682
1688
|
|
|
1683
1689
|
/** @type {(direction: -1 | 1) => void} */
|
|
@@ -1699,18 +1705,21 @@
|
|
|
1699
1705
|
disabled = results[index].disabled;
|
|
1700
1706
|
}
|
|
1701
1707
|
|
|
1702
|
-
$$invalidate(
|
|
1708
|
+
$$invalidate(8, selectedIndex = index);
|
|
1703
1709
|
}
|
|
1704
1710
|
|
|
1711
|
+
const open = () => $$invalidate(3, hideDropdown = false);
|
|
1712
|
+
const close = () => $$invalidate(3, hideDropdown = true);
|
|
1713
|
+
|
|
1705
1714
|
const click_handler = ({ target }) => {
|
|
1706
|
-
if (!hideDropdown &&
|
|
1707
|
-
|
|
1715
|
+
if (!hideDropdown && !comboboxRef?.contains(target)) {
|
|
1716
|
+
close();
|
|
1708
1717
|
}
|
|
1709
1718
|
};
|
|
1710
1719
|
|
|
1711
1720
|
function search_ref_binding(value) {
|
|
1712
1721
|
searchRef = value;
|
|
1713
|
-
$$invalidate(
|
|
1722
|
+
$$invalidate(7, searchRef);
|
|
1714
1723
|
}
|
|
1715
1724
|
|
|
1716
1725
|
function search_value_binding(value$1) {
|
|
@@ -1735,21 +1744,22 @@
|
|
|
1735
1744
|
}
|
|
1736
1745
|
|
|
1737
1746
|
const focus_handler_1 = () => {
|
|
1738
|
-
|
|
1747
|
+
open();
|
|
1748
|
+
$$invalidate(4, isFocused = true);
|
|
1739
1749
|
};
|
|
1740
1750
|
|
|
1741
1751
|
function clear_handler(event) {
|
|
1742
1752
|
bubble.call(this, $$self, event);
|
|
1743
1753
|
}
|
|
1744
1754
|
|
|
1745
|
-
const clear_handler_1 = () => {
|
|
1746
|
-
$$invalidate(3, hideDropdown = false);
|
|
1747
|
-
};
|
|
1748
|
-
|
|
1749
1755
|
function blur_handler(event) {
|
|
1750
1756
|
bubble.call(this, $$self, event);
|
|
1751
1757
|
}
|
|
1752
1758
|
|
|
1759
|
+
const blur_handler_1 = () => {
|
|
1760
|
+
$$invalidate(4, isFocused = false);
|
|
1761
|
+
};
|
|
1762
|
+
|
|
1753
1763
|
function keydown_handler(event) {
|
|
1754
1764
|
bubble.call(this, $$self, event);
|
|
1755
1765
|
}
|
|
@@ -1772,65 +1782,72 @@
|
|
|
1772
1782
|
case "Escape":
|
|
1773
1783
|
e.preventDefault();
|
|
1774
1784
|
$$invalidate(0, value = "");
|
|
1775
|
-
searchRef
|
|
1776
|
-
|
|
1785
|
+
searchRef?.focus();
|
|
1786
|
+
close();
|
|
1777
1787
|
break;
|
|
1778
1788
|
}
|
|
1779
1789
|
};
|
|
1780
1790
|
|
|
1781
1791
|
const click_handler_1 = (result, index) => {
|
|
1782
1792
|
if (result.disabled) return;
|
|
1783
|
-
$$invalidate(
|
|
1793
|
+
$$invalidate(8, selectedIndex = index);
|
|
1784
1794
|
select();
|
|
1785
1795
|
};
|
|
1786
1796
|
|
|
1787
1797
|
const mouseenter_handler = (result, index) => {
|
|
1788
1798
|
if (result.disabled) return;
|
|
1789
|
-
$$invalidate(
|
|
1799
|
+
$$invalidate(8, selectedIndex = index);
|
|
1790
1800
|
};
|
|
1791
1801
|
|
|
1792
1802
|
function div_binding($$value) {
|
|
1793
1803
|
binding_callbacks[$$value ? 'unshift' : 'push'](() => {
|
|
1794
1804
|
comboboxRef = $$value;
|
|
1795
|
-
$$invalidate(
|
|
1805
|
+
$$invalidate(6, comboboxRef);
|
|
1796
1806
|
});
|
|
1797
1807
|
}
|
|
1798
1808
|
|
|
1799
1809
|
$$self.$$set = $$new_props => {
|
|
1800
1810
|
$$props = assign(assign({}, $$props), exclude_internal_props($$new_props));
|
|
1801
|
-
$$invalidate(
|
|
1811
|
+
$$invalidate(14, $$restProps = compute_rest_props($$props, omit_props_names));
|
|
1802
1812
|
if ('id' in $$new_props) $$invalidate(2, id = $$new_props.id);
|
|
1803
1813
|
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(
|
|
1814
|
+
if ('data' in $$new_props) $$invalidate(15, data = $$new_props.data);
|
|
1815
|
+
if ('extract' in $$new_props) $$invalidate(16, extract = $$new_props.extract);
|
|
1816
|
+
if ('disable' in $$new_props) $$invalidate(17, disable = $$new_props.disable);
|
|
1817
|
+
if ('filter' in $$new_props) $$invalidate(18, filter = $$new_props.filter);
|
|
1818
|
+
if ('autoselect' in $$new_props) $$invalidate(19, autoselect = $$new_props.autoselect);
|
|
1819
|
+
if ('inputAfterSelect' in $$new_props) $$invalidate(20, inputAfterSelect = $$new_props.inputAfterSelect);
|
|
1810
1820
|
if ('results' in $$new_props) $$invalidate(1, results = $$new_props.results);
|
|
1811
|
-
if ('focusAfterSelect' in $$new_props) $$invalidate(
|
|
1812
|
-
if ('
|
|
1813
|
-
if ('
|
|
1821
|
+
if ('focusAfterSelect' in $$new_props) $$invalidate(21, focusAfterSelect = $$new_props.focusAfterSelect);
|
|
1822
|
+
if ('showDropdownOnFocus' in $$new_props) $$invalidate(22, showDropdownOnFocus = $$new_props.showDropdownOnFocus);
|
|
1823
|
+
if ('limit' in $$new_props) $$invalidate(23, limit = $$new_props.limit);
|
|
1824
|
+
if ('$$scope' in $$new_props) $$invalidate(25, $$scope = $$new_props.$$scope);
|
|
1814
1825
|
};
|
|
1815
1826
|
|
|
1816
1827
|
$$self.$$.update = () => {
|
|
1817
|
-
if ($$self.$$.dirty[0] & /*extract*/
|
|
1818
|
-
$$invalidate(
|
|
1828
|
+
if ($$self.$$.dirty[0] & /*extract*/ 65536) {
|
|
1829
|
+
$$invalidate(24, options = { pre: "<mark>", post: "</mark>", extract });
|
|
1819
1830
|
}
|
|
1820
1831
|
|
|
1821
|
-
if ($$self.$$.dirty[0] & /*value, data, options, limit, filter, disable*/
|
|
1832
|
+
if ($$self.$$.dirty[0] & /*value, data, options, limit, filter, disable*/ 25591809) {
|
|
1822
1833
|
$$invalidate(1, results = fuzzy.filter(value, data, options).filter(({ score }) => score > 0).slice(0, limit).filter(result => !filter(result.original)).map(result => ({
|
|
1823
1834
|
...result,
|
|
1824
1835
|
disabled: disable(result.original)
|
|
1825
1836
|
})));
|
|
1826
1837
|
}
|
|
1827
1838
|
|
|
1828
|
-
if ($$self.$$.dirty[0] & /*results, extract*/
|
|
1839
|
+
if ($$self.$$.dirty[0] & /*results, extract*/ 65538) {
|
|
1829
1840
|
resultsId = results.map(result => extract(result.original)).join("");
|
|
1830
1841
|
}
|
|
1831
1842
|
|
|
1832
1843
|
if ($$self.$$.dirty[0] & /*hideDropdown, results*/ 10) {
|
|
1833
|
-
$$invalidate(
|
|
1844
|
+
$$invalidate(5, showResults = !hideDropdown && results.length > 0);
|
|
1845
|
+
}
|
|
1846
|
+
|
|
1847
|
+
if ($$self.$$.dirty[0] & /*showDropdownOnFocus, showResults, isFocused*/ 4194352) {
|
|
1848
|
+
if (showDropdownOnFocus) {
|
|
1849
|
+
$$invalidate(5, showResults = showResults && isFocused);
|
|
1850
|
+
}
|
|
1834
1851
|
}
|
|
1835
1852
|
};
|
|
1836
1853
|
|
|
@@ -1839,12 +1856,15 @@
|
|
|
1839
1856
|
results,
|
|
1840
1857
|
id,
|
|
1841
1858
|
hideDropdown,
|
|
1859
|
+
isFocused,
|
|
1860
|
+
showResults,
|
|
1842
1861
|
comboboxRef,
|
|
1843
1862
|
searchRef,
|
|
1844
1863
|
selectedIndex,
|
|
1845
|
-
showResults,
|
|
1846
1864
|
select,
|
|
1847
1865
|
change,
|
|
1866
|
+
open,
|
|
1867
|
+
close,
|
|
1848
1868
|
$$slots,
|
|
1849
1869
|
$$restProps,
|
|
1850
1870
|
data,
|
|
@@ -1854,6 +1874,7 @@
|
|
|
1854
1874
|
autoselect,
|
|
1855
1875
|
inputAfterSelect,
|
|
1856
1876
|
focusAfterSelect,
|
|
1877
|
+
showDropdownOnFocus,
|
|
1857
1878
|
limit,
|
|
1858
1879
|
options,
|
|
1859
1880
|
$$scope,
|
|
@@ -1867,8 +1888,8 @@
|
|
|
1867
1888
|
focus_handler,
|
|
1868
1889
|
focus_handler_1,
|
|
1869
1890
|
clear_handler,
|
|
1870
|
-
clear_handler_1,
|
|
1871
1891
|
blur_handler,
|
|
1892
|
+
blur_handler_1,
|
|
1872
1893
|
keydown_handler,
|
|
1873
1894
|
keydown_handler_1,
|
|
1874
1895
|
click_handler_1,
|
|
@@ -1890,15 +1911,16 @@
|
|
|
1890
1911
|
{
|
|
1891
1912
|
id: 2,
|
|
1892
1913
|
value: 0,
|
|
1893
|
-
data:
|
|
1894
|
-
extract:
|
|
1895
|
-
disable:
|
|
1896
|
-
filter:
|
|
1897
|
-
autoselect:
|
|
1898
|
-
inputAfterSelect:
|
|
1914
|
+
data: 15,
|
|
1915
|
+
extract: 16,
|
|
1916
|
+
disable: 17,
|
|
1917
|
+
filter: 18,
|
|
1918
|
+
autoselect: 19,
|
|
1919
|
+
inputAfterSelect: 20,
|
|
1899
1920
|
results: 1,
|
|
1900
|
-
focusAfterSelect:
|
|
1901
|
-
|
|
1921
|
+
focusAfterSelect: 21,
|
|
1922
|
+
showDropdownOnFocus: 22,
|
|
1923
|
+
limit: 23
|
|
1902
1924
|
},
|
|
1903
1925
|
add_css,
|
|
1904
1926
|
[-1, -1]
|