svelte-typeahead 4.2.3 → 4.3.1
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 +34 -32
- package/lib/index.js +172 -130
- package/lib/index.mjs +172 -130
- package/package.json +2 -3
- package/src/Typeahead.svelte +58 -23
- package/types/Typeahead.svelte.d.ts +6 -0
package/lib/index.mjs
CHANGED
|
@@ -404,6 +404,9 @@ function transition_out(block, local, detach, callback) {
|
|
|
404
404
|
});
|
|
405
405
|
block.o(local);
|
|
406
406
|
}
|
|
407
|
+
else if (callback) {
|
|
408
|
+
callback();
|
|
409
|
+
}
|
|
407
410
|
}
|
|
408
411
|
|
|
409
412
|
function get_spread_update(levels, updates) {
|
|
@@ -725,7 +728,7 @@ fuzzy.filter = function(pattern, arr, opts) {
|
|
|
725
728
|
|
|
726
729
|
var fuzzy = fuzzy$1.exports;
|
|
727
730
|
|
|
728
|
-
/* node_modules/svelte-search/src/Search.svelte generated by Svelte v3.
|
|
731
|
+
/* node_modules/svelte-search/src/Search.svelte generated by Svelte v3.49.0 */
|
|
729
732
|
|
|
730
733
|
function add_css$1(target) {
|
|
731
734
|
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}");
|
|
@@ -1062,10 +1065,10 @@ class Search extends SvelteComponent {
|
|
|
1062
1065
|
|
|
1063
1066
|
var Search$1 = Search;
|
|
1064
1067
|
|
|
1065
|
-
/* src/Typeahead.svelte generated by Svelte v3.
|
|
1068
|
+
/* src/Typeahead.svelte generated by Svelte v3.49.0 */
|
|
1066
1069
|
|
|
1067
1070
|
function add_css(target) {
|
|
1068
|
-
append_styles(target, "svelte-
|
|
1071
|
+
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}");
|
|
1069
1072
|
}
|
|
1070
1073
|
|
|
1071
1074
|
const get_no_results_slot_changes = dirty => ({
|
|
@@ -1075,14 +1078,14 @@ const get_no_results_slot_changes = dirty => ({
|
|
|
1075
1078
|
|
|
1076
1079
|
const get_no_results_slot_context = ctx => ({
|
|
1077
1080
|
value: /*value*/ ctx[0],
|
|
1078
|
-
result: /*result*/ ctx[
|
|
1079
|
-
index: /*
|
|
1081
|
+
result: /*result*/ ctx[47],
|
|
1082
|
+
index: /*index*/ ctx[49]
|
|
1080
1083
|
});
|
|
1081
1084
|
|
|
1082
1085
|
function get_each_context(ctx, list, i) {
|
|
1083
1086
|
const child_ctx = ctx.slice();
|
|
1084
|
-
child_ctx[
|
|
1085
|
-
child_ctx[
|
|
1087
|
+
child_ctx[47] = list[i];
|
|
1088
|
+
child_ctx[49] = i;
|
|
1086
1089
|
return child_ctx;
|
|
1087
1090
|
}
|
|
1088
1091
|
|
|
@@ -1092,12 +1095,12 @@ const get_default_slot_changes = dirty => ({
|
|
|
1092
1095
|
});
|
|
1093
1096
|
|
|
1094
1097
|
const get_default_slot_context = ctx => ({
|
|
1095
|
-
result: /*result*/ ctx[
|
|
1096
|
-
index: /*
|
|
1098
|
+
result: /*result*/ ctx[47],
|
|
1099
|
+
index: /*index*/ ctx[49],
|
|
1097
1100
|
value: /*value*/ ctx[0]
|
|
1098
1101
|
});
|
|
1099
1102
|
|
|
1100
|
-
// (
|
|
1103
|
+
// (230:4) {#if showResults}
|
|
1101
1104
|
function create_if_block_1(ctx) {
|
|
1102
1105
|
let each_1_anchor;
|
|
1103
1106
|
let current;
|
|
@@ -1129,7 +1132,7 @@ function create_if_block_1(ctx) {
|
|
|
1129
1132
|
current = true;
|
|
1130
1133
|
},
|
|
1131
1134
|
p(ctx, dirty) {
|
|
1132
|
-
if (dirty[0] & /*id, selectedIndex, results, select, $$scope, value*/
|
|
1135
|
+
if (dirty[0] & /*id, selectedIndex, results, select, $$scope, value*/ 33555207) {
|
|
1133
1136
|
each_value = /*results*/ ctx[1];
|
|
1134
1137
|
let i;
|
|
1135
1138
|
|
|
@@ -1181,10 +1184,10 @@ function create_if_block_1(ctx) {
|
|
|
1181
1184
|
};
|
|
1182
1185
|
}
|
|
1183
1186
|
|
|
1184
|
-
// (
|
|
1187
|
+
// (248:41)
|
|
1185
1188
|
function fallback_block(ctx) {
|
|
1186
1189
|
let html_tag;
|
|
1187
|
-
let raw_value = /*result*/ ctx[
|
|
1190
|
+
let raw_value = /*result*/ ctx[47].string + "";
|
|
1188
1191
|
let html_anchor;
|
|
1189
1192
|
|
|
1190
1193
|
return {
|
|
@@ -1198,7 +1201,7 @@ function fallback_block(ctx) {
|
|
|
1198
1201
|
insert(target, html_anchor, anchor);
|
|
1199
1202
|
},
|
|
1200
1203
|
p(ctx, dirty) {
|
|
1201
|
-
if (dirty[0] & /*results*/ 2 && raw_value !== (raw_value = /*result*/ ctx[
|
|
1204
|
+
if (dirty[0] & /*results*/ 2 && raw_value !== (raw_value = /*result*/ ctx[47].string + "")) html_tag.p(raw_value);
|
|
1202
1205
|
},
|
|
1203
1206
|
d(detaching) {
|
|
1204
1207
|
if (detaching) detach(html_anchor);
|
|
@@ -1207,7 +1210,7 @@ function fallback_block(ctx) {
|
|
|
1207
1210
|
};
|
|
1208
1211
|
}
|
|
1209
1212
|
|
|
1210
|
-
// (
|
|
1213
|
+
// (231:6) {#each results as result, index}
|
|
1211
1214
|
function create_each_block(ctx) {
|
|
1212
1215
|
let li;
|
|
1213
1216
|
let t;
|
|
@@ -1216,16 +1219,16 @@ function create_each_block(ctx) {
|
|
|
1216
1219
|
let current;
|
|
1217
1220
|
let mounted;
|
|
1218
1221
|
let dispose;
|
|
1219
|
-
const default_slot_template = /*#slots*/ ctx[
|
|
1220
|
-
const default_slot = create_slot(default_slot_template, ctx, /*$$scope*/ ctx[
|
|
1222
|
+
const default_slot_template = /*#slots*/ ctx[26].default;
|
|
1223
|
+
const default_slot = create_slot(default_slot_template, ctx, /*$$scope*/ ctx[25], get_default_slot_context);
|
|
1221
1224
|
const default_slot_or_fallback = default_slot || fallback_block(ctx);
|
|
1222
1225
|
|
|
1223
1226
|
function click_handler_1() {
|
|
1224
|
-
return /*click_handler_1*/ ctx[
|
|
1227
|
+
return /*click_handler_1*/ ctx[40](/*result*/ ctx[47], /*index*/ ctx[49]);
|
|
1225
1228
|
}
|
|
1226
1229
|
|
|
1227
1230
|
function mouseenter_handler() {
|
|
1228
|
-
return /*mouseenter_handler*/ ctx[
|
|
1231
|
+
return /*mouseenter_handler*/ ctx[41](/*result*/ ctx[47], /*index*/ ctx[49]);
|
|
1229
1232
|
}
|
|
1230
1233
|
|
|
1231
1234
|
return {
|
|
@@ -1234,11 +1237,11 @@ function create_each_block(ctx) {
|
|
|
1234
1237
|
if (default_slot_or_fallback) default_slot_or_fallback.c();
|
|
1235
1238
|
t = space();
|
|
1236
1239
|
attr(li, "role", "option");
|
|
1237
|
-
attr(li, "id", li_id_value = "" + (/*id*/ ctx[2] + "-result-" + /*
|
|
1238
|
-
attr(li, "aria-selected", li_aria_selected_value = /*selectedIndex*/ ctx[
|
|
1239
|
-
attr(li, "class", "svelte-
|
|
1240
|
-
toggle_class(li, "selected", /*selectedIndex*/ ctx[
|
|
1241
|
-
toggle_class(li, "disabled", /*result*/ ctx[
|
|
1240
|
+
attr(li, "id", li_id_value = "" + (/*id*/ ctx[2] + "-result-" + /*index*/ ctx[49]));
|
|
1241
|
+
attr(li, "aria-selected", li_aria_selected_value = /*selectedIndex*/ ctx[8] === /*index*/ ctx[49]);
|
|
1242
|
+
attr(li, "class", "svelte-9wywte");
|
|
1243
|
+
toggle_class(li, "selected", /*selectedIndex*/ ctx[8] === /*index*/ ctx[49]);
|
|
1244
|
+
toggle_class(li, "disabled", /*result*/ ctx[47].disabled);
|
|
1242
1245
|
},
|
|
1243
1246
|
m(target, anchor) {
|
|
1244
1247
|
insert(target, li, anchor);
|
|
@@ -1263,15 +1266,15 @@ function create_each_block(ctx) {
|
|
|
1263
1266
|
ctx = new_ctx;
|
|
1264
1267
|
|
|
1265
1268
|
if (default_slot) {
|
|
1266
|
-
if (default_slot.p && (!current || dirty[0] & /*$$scope, results, value*/
|
|
1269
|
+
if (default_slot.p && (!current || dirty[0] & /*$$scope, results, value*/ 33554435)) {
|
|
1267
1270
|
update_slot_base(
|
|
1268
1271
|
default_slot,
|
|
1269
1272
|
default_slot_template,
|
|
1270
1273
|
ctx,
|
|
1271
|
-
/*$$scope*/ ctx[
|
|
1274
|
+
/*$$scope*/ ctx[25],
|
|
1272
1275
|
!current
|
|
1273
|
-
? get_all_dirty_from_scope(/*$$scope*/ ctx[
|
|
1274
|
-
: get_slot_changes(default_slot_template, /*$$scope*/ ctx[
|
|
1276
|
+
? get_all_dirty_from_scope(/*$$scope*/ ctx[25])
|
|
1277
|
+
: get_slot_changes(default_slot_template, /*$$scope*/ ctx[25], dirty, get_default_slot_changes),
|
|
1275
1278
|
get_default_slot_context
|
|
1276
1279
|
);
|
|
1277
1280
|
}
|
|
@@ -1281,20 +1284,20 @@ function create_each_block(ctx) {
|
|
|
1281
1284
|
}
|
|
1282
1285
|
}
|
|
1283
1286
|
|
|
1284
|
-
if (!current || dirty[0] & /*id*/ 4 && li_id_value !== (li_id_value = "" + (/*id*/ ctx[2] + "-result-" + /*
|
|
1287
|
+
if (!current || dirty[0] & /*id*/ 4 && li_id_value !== (li_id_value = "" + (/*id*/ ctx[2] + "-result-" + /*index*/ ctx[49]))) {
|
|
1285
1288
|
attr(li, "id", li_id_value);
|
|
1286
1289
|
}
|
|
1287
1290
|
|
|
1288
|
-
if (!current || dirty[0] & /*selectedIndex*/
|
|
1291
|
+
if (!current || dirty[0] & /*selectedIndex*/ 256 && li_aria_selected_value !== (li_aria_selected_value = /*selectedIndex*/ ctx[8] === /*index*/ ctx[49])) {
|
|
1289
1292
|
attr(li, "aria-selected", li_aria_selected_value);
|
|
1290
1293
|
}
|
|
1291
1294
|
|
|
1292
|
-
if (dirty[0] & /*selectedIndex*/
|
|
1293
|
-
toggle_class(li, "selected", /*selectedIndex*/ ctx[
|
|
1295
|
+
if (dirty[0] & /*selectedIndex*/ 256) {
|
|
1296
|
+
toggle_class(li, "selected", /*selectedIndex*/ ctx[8] === /*index*/ ctx[49]);
|
|
1294
1297
|
}
|
|
1295
1298
|
|
|
1296
1299
|
if (dirty[0] & /*results*/ 2) {
|
|
1297
|
-
toggle_class(li, "disabled", /*result*/ ctx[
|
|
1300
|
+
toggle_class(li, "disabled", /*result*/ ctx[47].disabled);
|
|
1298
1301
|
}
|
|
1299
1302
|
},
|
|
1300
1303
|
i(local) {
|
|
@@ -1315,18 +1318,18 @@ function create_each_block(ctx) {
|
|
|
1315
1318
|
};
|
|
1316
1319
|
}
|
|
1317
1320
|
|
|
1318
|
-
// (
|
|
1321
|
+
// (254:4) {#if $$slots["no-results"] && !hideDropdown && value.length > 0 && results.length === 0}
|
|
1319
1322
|
function create_if_block(ctx) {
|
|
1320
1323
|
let div;
|
|
1321
1324
|
let current;
|
|
1322
|
-
const no_results_slot_template = /*#slots*/ ctx[
|
|
1323
|
-
const no_results_slot = create_slot(no_results_slot_template, ctx, /*$$scope*/ ctx[
|
|
1325
|
+
const no_results_slot_template = /*#slots*/ ctx[26]["no-results"];
|
|
1326
|
+
const no_results_slot = create_slot(no_results_slot_template, ctx, /*$$scope*/ ctx[25], get_no_results_slot_context);
|
|
1324
1327
|
|
|
1325
1328
|
return {
|
|
1326
1329
|
c() {
|
|
1327
1330
|
div = element("div");
|
|
1328
1331
|
if (no_results_slot) no_results_slot.c();
|
|
1329
|
-
attr(div, "class", "svelte-
|
|
1332
|
+
attr(div, "class", "svelte-9wywte");
|
|
1330
1333
|
toggle_class(div, "no-results", true);
|
|
1331
1334
|
},
|
|
1332
1335
|
m(target, anchor) {
|
|
@@ -1340,15 +1343,15 @@ function create_if_block(ctx) {
|
|
|
1340
1343
|
},
|
|
1341
1344
|
p(ctx, dirty) {
|
|
1342
1345
|
if (no_results_slot) {
|
|
1343
|
-
if (no_results_slot.p && (!current || dirty[0] & /*$$scope, value, results*/
|
|
1346
|
+
if (no_results_slot.p && (!current || dirty[0] & /*$$scope, value, results*/ 33554435)) {
|
|
1344
1347
|
update_slot_base(
|
|
1345
1348
|
no_results_slot,
|
|
1346
1349
|
no_results_slot_template,
|
|
1347
1350
|
ctx,
|
|
1348
|
-
/*$$scope*/ ctx[
|
|
1351
|
+
/*$$scope*/ ctx[25],
|
|
1349
1352
|
!current
|
|
1350
|
-
? get_all_dirty_from_scope(/*$$scope*/ ctx[
|
|
1351
|
-
: get_slot_changes(no_results_slot_template, /*$$scope*/ ctx[
|
|
1353
|
+
? get_all_dirty_from_scope(/*$$scope*/ ctx[25])
|
|
1354
|
+
: get_slot_changes(no_results_slot_template, /*$$scope*/ ctx[25], dirty, get_no_results_slot_changes),
|
|
1352
1355
|
get_no_results_slot_context
|
|
1353
1356
|
);
|
|
1354
1357
|
}
|
|
@@ -1381,7 +1384,6 @@ function create_fragment(ctx) {
|
|
|
1381
1384
|
let ul_aria_labelledby_value;
|
|
1382
1385
|
let ul_id_value;
|
|
1383
1386
|
let div_aria_owns_value;
|
|
1384
|
-
let div_aria_expanded_value;
|
|
1385
1387
|
let div_id_value;
|
|
1386
1388
|
let current;
|
|
1387
1389
|
let mounted;
|
|
@@ -1390,7 +1392,7 @@ function create_fragment(ctx) {
|
|
|
1390
1392
|
const search_spread_levels = [
|
|
1391
1393
|
{ id: /*id*/ ctx[2] },
|
|
1392
1394
|
{ removeFormAriaAttributes: true },
|
|
1393
|
-
/*$$restProps*/ ctx[
|
|
1395
|
+
/*$$restProps*/ ctx[14],
|
|
1394
1396
|
{ "aria-autocomplete": "list" },
|
|
1395
1397
|
{
|
|
1396
1398
|
"aria-controls": "" + (/*id*/ ctx[2] + "-listbox")
|
|
@@ -1399,18 +1401,18 @@ function create_fragment(ctx) {
|
|
|
1399
1401
|
"aria-labelledby": "" + (/*id*/ ctx[2] + "-label")
|
|
1400
1402
|
},
|
|
1401
1403
|
{
|
|
1402
|
-
"aria-activedescendant": /*selectedIndex*/ ctx[
|
|
1403
|
-
? `${/*id*/ ctx[2]}-result-${/*selectedIndex*/ ctx[
|
|
1404
|
+
"aria-activedescendant": /*selectedIndex*/ ctx[8] >= 0 && !/*hideDropdown*/ ctx[3] && /*results*/ ctx[1].length > 0
|
|
1405
|
+
? `${/*id*/ ctx[2]}-result-${/*selectedIndex*/ ctx[8]}`
|
|
1404
1406
|
: null
|
|
1405
1407
|
}
|
|
1406
1408
|
];
|
|
1407
1409
|
|
|
1408
1410
|
function search_ref_binding(value) {
|
|
1409
|
-
/*search_ref_binding*/ ctx[
|
|
1411
|
+
/*search_ref_binding*/ ctx[28](value);
|
|
1410
1412
|
}
|
|
1411
1413
|
|
|
1412
1414
|
function search_value_binding(value) {
|
|
1413
|
-
/*search_value_binding*/ ctx[
|
|
1415
|
+
/*search_value_binding*/ ctx[29](value);
|
|
1414
1416
|
}
|
|
1415
1417
|
|
|
1416
1418
|
let search_props = {};
|
|
@@ -1419,8 +1421,8 @@ function create_fragment(ctx) {
|
|
|
1419
1421
|
search_props = assign(search_props, search_spread_levels[i]);
|
|
1420
1422
|
}
|
|
1421
1423
|
|
|
1422
|
-
if (/*searchRef*/ ctx[
|
|
1423
|
-
search_props.ref = /*searchRef*/ ctx[
|
|
1424
|
+
if (/*searchRef*/ ctx[7] !== void 0) {
|
|
1425
|
+
search_props.ref = /*searchRef*/ ctx[7];
|
|
1424
1426
|
}
|
|
1425
1427
|
|
|
1426
1428
|
if (/*value*/ ctx[0] !== void 0) {
|
|
@@ -1430,18 +1432,19 @@ function create_fragment(ctx) {
|
|
|
1430
1432
|
search = new Search$1({ props: search_props });
|
|
1431
1433
|
binding_callbacks.push(() => bind(search, 'ref', search_ref_binding));
|
|
1432
1434
|
binding_callbacks.push(() => bind(search, 'value', search_value_binding));
|
|
1433
|
-
search.$on("type", /*type_handler*/ ctx[
|
|
1434
|
-
search.$on("input", /*input_handler*/ ctx[
|
|
1435
|
-
search.$on("change", /*change_handler*/ ctx[
|
|
1436
|
-
search.$on("focus", /*focus_handler*/ ctx[
|
|
1437
|
-
search.$on("focus", /*focus_handler_1*/ ctx[
|
|
1438
|
-
search.$on("clear", /*clear_handler*/ ctx[
|
|
1439
|
-
search.$on("clear", /*
|
|
1440
|
-
search.$on("blur", /*blur_handler*/ ctx[
|
|
1441
|
-
search.$on("
|
|
1442
|
-
search.$on("keydown", /*
|
|
1443
|
-
|
|
1444
|
-
let
|
|
1435
|
+
search.$on("type", /*type_handler*/ ctx[30]);
|
|
1436
|
+
search.$on("input", /*input_handler*/ ctx[31]);
|
|
1437
|
+
search.$on("change", /*change_handler*/ ctx[32]);
|
|
1438
|
+
search.$on("focus", /*focus_handler*/ ctx[33]);
|
|
1439
|
+
search.$on("focus", /*focus_handler_1*/ ctx[34]);
|
|
1440
|
+
search.$on("clear", /*clear_handler*/ ctx[35]);
|
|
1441
|
+
search.$on("clear", /*open*/ ctx[11]);
|
|
1442
|
+
search.$on("blur", /*blur_handler*/ ctx[36]);
|
|
1443
|
+
search.$on("blur", /*blur_handler_1*/ ctx[37]);
|
|
1444
|
+
search.$on("keydown", /*keydown_handler*/ ctx[38]);
|
|
1445
|
+
search.$on("keydown", /*keydown_handler_1*/ ctx[39]);
|
|
1446
|
+
let if_block0 = /*showResults*/ ctx[5] && create_if_block_1(ctx);
|
|
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);
|
|
1445
1448
|
|
|
1446
1449
|
return {
|
|
1447
1450
|
c() {
|
|
@@ -1455,15 +1458,15 @@ function create_fragment(ctx) {
|
|
|
1455
1458
|
attr(ul, "role", "listbox");
|
|
1456
1459
|
attr(ul, "aria-labelledby", ul_aria_labelledby_value = "" + (/*id*/ ctx[2] + "-label"));
|
|
1457
1460
|
attr(ul, "id", ul_id_value = "" + (/*id*/ ctx[2] + "-listbox"));
|
|
1458
|
-
attr(ul, "class", "svelte-
|
|
1461
|
+
attr(ul, "class", "svelte-9wywte");
|
|
1459
1462
|
toggle_class(ul, "svelte-typeahead-list", true);
|
|
1460
1463
|
attr(div, "data-svelte-typeahead", "");
|
|
1461
1464
|
attr(div, "role", "combobox");
|
|
1462
1465
|
attr(div, "aria-haspopup", "listbox");
|
|
1463
1466
|
attr(div, "aria-owns", div_aria_owns_value = "" + (/*id*/ ctx[2] + "-listbox"));
|
|
1464
|
-
attr(div, "aria-expanded",
|
|
1467
|
+
attr(div, "aria-expanded", /*showResults*/ ctx[5]);
|
|
1465
1468
|
attr(div, "id", div_id_value = "" + (/*id*/ ctx[2] + "-typeahead"));
|
|
1466
|
-
attr(div, "class", "svelte-
|
|
1469
|
+
attr(div, "class", "svelte-9wywte");
|
|
1467
1470
|
toggle_class(div, "dropdown", /*results*/ ctx[1].length > 0);
|
|
1468
1471
|
},
|
|
1469
1472
|
m(target, anchor) {
|
|
@@ -1474,20 +1477,20 @@ function create_fragment(ctx) {
|
|
|
1474
1477
|
if (if_block0) if_block0.m(ul, null);
|
|
1475
1478
|
append(ul, t1);
|
|
1476
1479
|
if (if_block1) if_block1.m(ul, null);
|
|
1477
|
-
/*div_binding*/ ctx[
|
|
1480
|
+
/*div_binding*/ ctx[42](div);
|
|
1478
1481
|
current = true;
|
|
1479
1482
|
|
|
1480
1483
|
if (!mounted) {
|
|
1481
|
-
dispose = listen(window, "click", /*click_handler*/ ctx[
|
|
1484
|
+
dispose = listen(window, "click", /*click_handler*/ ctx[27]);
|
|
1482
1485
|
mounted = true;
|
|
1483
1486
|
}
|
|
1484
1487
|
},
|
|
1485
1488
|
p(ctx, dirty) {
|
|
1486
|
-
const search_changes = (dirty[0] & /*id, $$restProps, selectedIndex, hideDropdown, results*/
|
|
1489
|
+
const search_changes = (dirty[0] & /*id, $$restProps, selectedIndex, hideDropdown, results*/ 16654)
|
|
1487
1490
|
? get_spread_update(search_spread_levels, [
|
|
1488
1491
|
dirty[0] & /*id*/ 4 && { id: /*id*/ ctx[2] },
|
|
1489
1492
|
search_spread_levels[1],
|
|
1490
|
-
dirty[0] & /*$$restProps*/
|
|
1493
|
+
dirty[0] & /*$$restProps*/ 16384 && get_spread_object(/*$$restProps*/ ctx[14]),
|
|
1491
1494
|
search_spread_levels[3],
|
|
1492
1495
|
dirty[0] & /*id*/ 4 && {
|
|
1493
1496
|
"aria-controls": "" + (/*id*/ ctx[2] + "-listbox")
|
|
@@ -1495,17 +1498,17 @@ function create_fragment(ctx) {
|
|
|
1495
1498
|
dirty[0] & /*id*/ 4 && {
|
|
1496
1499
|
"aria-labelledby": "" + (/*id*/ ctx[2] + "-label")
|
|
1497
1500
|
},
|
|
1498
|
-
dirty[0] & /*selectedIndex, hideDropdown, results, id*/
|
|
1499
|
-
"aria-activedescendant": /*selectedIndex*/ ctx[
|
|
1500
|
-
? `${/*id*/ ctx[2]}-result-${/*selectedIndex*/ ctx[
|
|
1501
|
+
dirty[0] & /*selectedIndex, hideDropdown, results, id*/ 270 && {
|
|
1502
|
+
"aria-activedescendant": /*selectedIndex*/ ctx[8] >= 0 && !/*hideDropdown*/ ctx[3] && /*results*/ ctx[1].length > 0
|
|
1503
|
+
? `${/*id*/ ctx[2]}-result-${/*selectedIndex*/ ctx[8]}`
|
|
1501
1504
|
: null
|
|
1502
1505
|
}
|
|
1503
1506
|
])
|
|
1504
1507
|
: {};
|
|
1505
1508
|
|
|
1506
|
-
if (!updating_ref && dirty[0] & /*searchRef*/
|
|
1509
|
+
if (!updating_ref && dirty[0] & /*searchRef*/ 128) {
|
|
1507
1510
|
updating_ref = true;
|
|
1508
|
-
search_changes.ref = /*searchRef*/ ctx[
|
|
1511
|
+
search_changes.ref = /*searchRef*/ ctx[7];
|
|
1509
1512
|
add_flush_callback(() => updating_ref = false);
|
|
1510
1513
|
}
|
|
1511
1514
|
|
|
@@ -1517,11 +1520,11 @@ function create_fragment(ctx) {
|
|
|
1517
1520
|
|
|
1518
1521
|
search.$set(search_changes);
|
|
1519
1522
|
|
|
1520
|
-
if (
|
|
1523
|
+
if (/*showResults*/ ctx[5]) {
|
|
1521
1524
|
if (if_block0) {
|
|
1522
1525
|
if_block0.p(ctx, dirty);
|
|
1523
1526
|
|
|
1524
|
-
if (dirty[0] & /*
|
|
1527
|
+
if (dirty[0] & /*showResults*/ 32) {
|
|
1525
1528
|
transition_in(if_block0, 1);
|
|
1526
1529
|
}
|
|
1527
1530
|
} else {
|
|
@@ -1540,11 +1543,11 @@ function create_fragment(ctx) {
|
|
|
1540
1543
|
check_outros();
|
|
1541
1544
|
}
|
|
1542
1545
|
|
|
1543
|
-
if (/*$$slots*/ ctx[
|
|
1546
|
+
if (/*$$slots*/ ctx[13]["no-results"] && !/*hideDropdown*/ ctx[3] && /*value*/ ctx[0].length > 0 && /*results*/ ctx[1].length === 0) {
|
|
1544
1547
|
if (if_block1) {
|
|
1545
1548
|
if_block1.p(ctx, dirty);
|
|
1546
1549
|
|
|
1547
|
-
if (dirty[0] & /*$$slots, hideDropdown, value, results*/
|
|
1550
|
+
if (dirty[0] & /*$$slots, hideDropdown, value, results*/ 8203) {
|
|
1548
1551
|
transition_in(if_block1, 1);
|
|
1549
1552
|
}
|
|
1550
1553
|
} else {
|
|
@@ -1575,8 +1578,8 @@ function create_fragment(ctx) {
|
|
|
1575
1578
|
attr(div, "aria-owns", div_aria_owns_value);
|
|
1576
1579
|
}
|
|
1577
1580
|
|
|
1578
|
-
if (!current || dirty[0] & /*
|
|
1579
|
-
attr(div, "aria-expanded",
|
|
1581
|
+
if (!current || dirty[0] & /*showResults*/ 32) {
|
|
1582
|
+
attr(div, "aria-expanded", /*showResults*/ ctx[5]);
|
|
1580
1583
|
}
|
|
1581
1584
|
|
|
1582
1585
|
if (!current || dirty[0] & /*id*/ 4 && div_id_value !== (div_id_value = "" + (/*id*/ ctx[2] + "-typeahead"))) {
|
|
@@ -1605,7 +1608,7 @@ function create_fragment(ctx) {
|
|
|
1605
1608
|
destroy_component(search);
|
|
1606
1609
|
if (if_block0) if_block0.d();
|
|
1607
1610
|
if (if_block1) if_block1.d();
|
|
1608
|
-
/*div_binding*/ ctx[
|
|
1611
|
+
/*div_binding*/ ctx[42](null);
|
|
1609
1612
|
mounted = false;
|
|
1610
1613
|
dispose();
|
|
1611
1614
|
}
|
|
@@ -1615,9 +1618,10 @@ function create_fragment(ctx) {
|
|
|
1615
1618
|
function instance($$self, $$props, $$invalidate) {
|
|
1616
1619
|
let options;
|
|
1617
1620
|
let resultsId;
|
|
1621
|
+
let showResults;
|
|
1618
1622
|
|
|
1619
1623
|
const omit_props_names = [
|
|
1620
|
-
"id","value","data","extract","disable","filter","autoselect","inputAfterSelect","results","focusAfterSelect","limit"
|
|
1624
|
+
"id","value","data","extract","disable","filter","autoselect","inputAfterSelect","results","focusAfterSelect","showDropdownOnFocus","limit"
|
|
1621
1625
|
];
|
|
1622
1626
|
|
|
1623
1627
|
let $$restProps = compute_rest_props($$props, omit_props_names);
|
|
@@ -1633,6 +1637,7 @@ function instance($$self, $$props, $$invalidate) {
|
|
|
1633
1637
|
let { inputAfterSelect = "update" } = $$props;
|
|
1634
1638
|
let { results = [] } = $$props;
|
|
1635
1639
|
let { focusAfterSelect = false } = $$props;
|
|
1640
|
+
let { showDropdownOnFocus = false } = $$props;
|
|
1636
1641
|
let { limit = Infinity } = $$props;
|
|
1637
1642
|
const dispatch = createEventDispatcher();
|
|
1638
1643
|
let comboboxRef = null;
|
|
@@ -1640,14 +1645,15 @@ function instance($$self, $$props, $$invalidate) {
|
|
|
1640
1645
|
let hideDropdown = false;
|
|
1641
1646
|
let selectedIndex = -1;
|
|
1642
1647
|
let prevResults = "";
|
|
1648
|
+
let isFocused = false;
|
|
1643
1649
|
|
|
1644
1650
|
afterUpdate(() => {
|
|
1645
1651
|
if (prevResults !== resultsId && autoselect) {
|
|
1646
|
-
$$invalidate(
|
|
1652
|
+
$$invalidate(8, selectedIndex = getNextNonDisabledIndex());
|
|
1647
1653
|
}
|
|
1648
1654
|
|
|
1649
1655
|
if (prevResults !== resultsId && !$$slots["no-results"]) {
|
|
1650
|
-
$$invalidate(
|
|
1656
|
+
$$invalidate(3, hideDropdown = results.length === 0);
|
|
1651
1657
|
}
|
|
1652
1658
|
|
|
1653
1659
|
prevResults = resultsId;
|
|
@@ -1671,7 +1677,25 @@ function instance($$self, $$props, $$invalidate) {
|
|
|
1671
1677
|
|
|
1672
1678
|
await tick();
|
|
1673
1679
|
if (focusAfterSelect) searchRef.focus();
|
|
1674
|
-
|
|
1680
|
+
close();
|
|
1681
|
+
}
|
|
1682
|
+
|
|
1683
|
+
/** @type {() => number} */
|
|
1684
|
+
function getNextNonDisabledIndex() {
|
|
1685
|
+
let index = 0;
|
|
1686
|
+
let disabled = results[index]?.disabled ?? false;
|
|
1687
|
+
|
|
1688
|
+
while (disabled) {
|
|
1689
|
+
if (index === results.length) {
|
|
1690
|
+
index = 0;
|
|
1691
|
+
} else {
|
|
1692
|
+
index += 1;
|
|
1693
|
+
}
|
|
1694
|
+
|
|
1695
|
+
disabled = results[index]?.disabled ?? false;
|
|
1696
|
+
}
|
|
1697
|
+
|
|
1698
|
+
return index;
|
|
1675
1699
|
}
|
|
1676
1700
|
|
|
1677
1701
|
/** @type {(direction: -1 | 1) => void} */
|
|
@@ -1693,18 +1717,21 @@ function instance($$self, $$props, $$invalidate) {
|
|
|
1693
1717
|
disabled = results[index].disabled;
|
|
1694
1718
|
}
|
|
1695
1719
|
|
|
1696
|
-
$$invalidate(
|
|
1720
|
+
$$invalidate(8, selectedIndex = index);
|
|
1697
1721
|
}
|
|
1698
1722
|
|
|
1723
|
+
const open = () => $$invalidate(3, hideDropdown = false);
|
|
1724
|
+
const close = () => $$invalidate(3, hideDropdown = true);
|
|
1725
|
+
|
|
1699
1726
|
const click_handler = ({ target }) => {
|
|
1700
|
-
if (!hideDropdown &&
|
|
1701
|
-
|
|
1727
|
+
if (!hideDropdown && !comboboxRef?.contains(target)) {
|
|
1728
|
+
close();
|
|
1702
1729
|
}
|
|
1703
1730
|
};
|
|
1704
1731
|
|
|
1705
1732
|
function search_ref_binding(value) {
|
|
1706
1733
|
searchRef = value;
|
|
1707
|
-
$$invalidate(
|
|
1734
|
+
$$invalidate(7, searchRef);
|
|
1708
1735
|
}
|
|
1709
1736
|
|
|
1710
1737
|
function search_value_binding(value$1) {
|
|
@@ -1729,21 +1756,22 @@ function instance($$self, $$props, $$invalidate) {
|
|
|
1729
1756
|
}
|
|
1730
1757
|
|
|
1731
1758
|
const focus_handler_1 = () => {
|
|
1732
|
-
|
|
1759
|
+
open();
|
|
1760
|
+
$$invalidate(4, isFocused = true);
|
|
1733
1761
|
};
|
|
1734
1762
|
|
|
1735
1763
|
function clear_handler(event) {
|
|
1736
1764
|
bubble.call(this, $$self, event);
|
|
1737
1765
|
}
|
|
1738
1766
|
|
|
1739
|
-
const clear_handler_1 = () => {
|
|
1740
|
-
$$invalidate(5, hideDropdown = false);
|
|
1741
|
-
};
|
|
1742
|
-
|
|
1743
1767
|
function blur_handler(event) {
|
|
1744
1768
|
bubble.call(this, $$self, event);
|
|
1745
1769
|
}
|
|
1746
1770
|
|
|
1771
|
+
const blur_handler_1 = () => {
|
|
1772
|
+
$$invalidate(4, isFocused = false);
|
|
1773
|
+
};
|
|
1774
|
+
|
|
1747
1775
|
function keydown_handler(event) {
|
|
1748
1776
|
bubble.call(this, $$self, event);
|
|
1749
1777
|
}
|
|
@@ -1766,75 +1794,89 @@ function instance($$self, $$props, $$invalidate) {
|
|
|
1766
1794
|
case "Escape":
|
|
1767
1795
|
e.preventDefault();
|
|
1768
1796
|
$$invalidate(0, value = "");
|
|
1769
|
-
searchRef
|
|
1770
|
-
|
|
1797
|
+
searchRef?.focus();
|
|
1798
|
+
close();
|
|
1771
1799
|
break;
|
|
1772
1800
|
}
|
|
1773
1801
|
};
|
|
1774
1802
|
|
|
1775
|
-
const click_handler_1 = (result,
|
|
1776
|
-
if (
|
|
1777
|
-
|
|
1778
|
-
|
|
1779
|
-
}
|
|
1803
|
+
const click_handler_1 = (result, index) => {
|
|
1804
|
+
if (result.disabled) return;
|
|
1805
|
+
$$invalidate(8, selectedIndex = index);
|
|
1806
|
+
select();
|
|
1780
1807
|
};
|
|
1781
1808
|
|
|
1782
|
-
const mouseenter_handler = (result,
|
|
1809
|
+
const mouseenter_handler = (result, index) => {
|
|
1783
1810
|
if (result.disabled) return;
|
|
1784
|
-
$$invalidate(
|
|
1811
|
+
$$invalidate(8, selectedIndex = index);
|
|
1785
1812
|
};
|
|
1786
1813
|
|
|
1787
1814
|
function div_binding($$value) {
|
|
1788
1815
|
binding_callbacks[$$value ? 'unshift' : 'push'](() => {
|
|
1789
1816
|
comboboxRef = $$value;
|
|
1790
|
-
$$invalidate(
|
|
1817
|
+
$$invalidate(6, comboboxRef);
|
|
1791
1818
|
});
|
|
1792
1819
|
}
|
|
1793
1820
|
|
|
1794
1821
|
$$self.$$set = $$new_props => {
|
|
1795
1822
|
$$props = assign(assign({}, $$props), exclude_internal_props($$new_props));
|
|
1796
|
-
$$invalidate(
|
|
1823
|
+
$$invalidate(14, $$restProps = compute_rest_props($$props, omit_props_names));
|
|
1797
1824
|
if ('id' in $$new_props) $$invalidate(2, id = $$new_props.id);
|
|
1798
1825
|
if ('value' in $$new_props) $$invalidate(0, value = $$new_props.value);
|
|
1799
|
-
if ('data' in $$new_props) $$invalidate(
|
|
1800
|
-
if ('extract' in $$new_props) $$invalidate(
|
|
1801
|
-
if ('disable' in $$new_props) $$invalidate(
|
|
1802
|
-
if ('filter' in $$new_props) $$invalidate(
|
|
1803
|
-
if ('autoselect' in $$new_props) $$invalidate(
|
|
1804
|
-
if ('inputAfterSelect' in $$new_props) $$invalidate(
|
|
1826
|
+
if ('data' in $$new_props) $$invalidate(15, data = $$new_props.data);
|
|
1827
|
+
if ('extract' in $$new_props) $$invalidate(16, extract = $$new_props.extract);
|
|
1828
|
+
if ('disable' in $$new_props) $$invalidate(17, disable = $$new_props.disable);
|
|
1829
|
+
if ('filter' in $$new_props) $$invalidate(18, filter = $$new_props.filter);
|
|
1830
|
+
if ('autoselect' in $$new_props) $$invalidate(19, autoselect = $$new_props.autoselect);
|
|
1831
|
+
if ('inputAfterSelect' in $$new_props) $$invalidate(20, inputAfterSelect = $$new_props.inputAfterSelect);
|
|
1805
1832
|
if ('results' in $$new_props) $$invalidate(1, results = $$new_props.results);
|
|
1806
|
-
if ('focusAfterSelect' in $$new_props) $$invalidate(
|
|
1807
|
-
if ('
|
|
1808
|
-
if ('
|
|
1833
|
+
if ('focusAfterSelect' in $$new_props) $$invalidate(21, focusAfterSelect = $$new_props.focusAfterSelect);
|
|
1834
|
+
if ('showDropdownOnFocus' in $$new_props) $$invalidate(22, showDropdownOnFocus = $$new_props.showDropdownOnFocus);
|
|
1835
|
+
if ('limit' in $$new_props) $$invalidate(23, limit = $$new_props.limit);
|
|
1836
|
+
if ('$$scope' in $$new_props) $$invalidate(25, $$scope = $$new_props.$$scope);
|
|
1809
1837
|
};
|
|
1810
1838
|
|
|
1811
1839
|
$$self.$$.update = () => {
|
|
1812
|
-
if ($$self.$$.dirty[0] & /*extract*/
|
|
1813
|
-
$$invalidate(
|
|
1840
|
+
if ($$self.$$.dirty[0] & /*extract*/ 65536) {
|
|
1841
|
+
$$invalidate(24, options = { pre: "<mark>", post: "</mark>", extract });
|
|
1814
1842
|
}
|
|
1815
1843
|
|
|
1816
|
-
if ($$self.$$.dirty[0] & /*value, data, options, limit, filter, disable*/
|
|
1844
|
+
if ($$self.$$.dirty[0] & /*value, data, options, limit, filter, disable*/ 25591809) {
|
|
1817
1845
|
$$invalidate(1, results = fuzzy.filter(value, data, options).filter(({ score }) => score > 0).slice(0, limit).filter(result => !filter(result.original)).map(result => ({
|
|
1818
1846
|
...result,
|
|
1819
1847
|
disabled: disable(result.original)
|
|
1820
1848
|
})));
|
|
1821
1849
|
}
|
|
1822
1850
|
|
|
1823
|
-
if ($$self.$$.dirty[0] & /*results, extract*/
|
|
1851
|
+
if ($$self.$$.dirty[0] & /*results, extract*/ 65538) {
|
|
1824
1852
|
resultsId = results.map(result => extract(result.original)).join("");
|
|
1825
1853
|
}
|
|
1854
|
+
|
|
1855
|
+
if ($$self.$$.dirty[0] & /*hideDropdown, results*/ 10) {
|
|
1856
|
+
$$invalidate(5, showResults = !hideDropdown && results.length > 0);
|
|
1857
|
+
}
|
|
1858
|
+
|
|
1859
|
+
if ($$self.$$.dirty[0] & /*showDropdownOnFocus, showResults, isFocused*/ 4194352) {
|
|
1860
|
+
if (showDropdownOnFocus) {
|
|
1861
|
+
$$invalidate(5, showResults = showResults && isFocused);
|
|
1862
|
+
}
|
|
1863
|
+
}
|
|
1826
1864
|
};
|
|
1827
1865
|
|
|
1828
1866
|
return [
|
|
1829
1867
|
value,
|
|
1830
1868
|
results,
|
|
1831
1869
|
id,
|
|
1870
|
+
hideDropdown,
|
|
1871
|
+
isFocused,
|
|
1872
|
+
showResults,
|
|
1832
1873
|
comboboxRef,
|
|
1833
1874
|
searchRef,
|
|
1834
|
-
hideDropdown,
|
|
1835
1875
|
selectedIndex,
|
|
1836
1876
|
select,
|
|
1837
1877
|
change,
|
|
1878
|
+
open,
|
|
1879
|
+
close,
|
|
1838
1880
|
$$slots,
|
|
1839
1881
|
$$restProps,
|
|
1840
1882
|
data,
|
|
@@ -1844,6 +1886,7 @@ function instance($$self, $$props, $$invalidate) {
|
|
|
1844
1886
|
autoselect,
|
|
1845
1887
|
inputAfterSelect,
|
|
1846
1888
|
focusAfterSelect,
|
|
1889
|
+
showDropdownOnFocus,
|
|
1847
1890
|
limit,
|
|
1848
1891
|
options,
|
|
1849
1892
|
$$scope,
|
|
@@ -1857,8 +1900,8 @@ function instance($$self, $$props, $$invalidate) {
|
|
|
1857
1900
|
focus_handler,
|
|
1858
1901
|
focus_handler_1,
|
|
1859
1902
|
clear_handler,
|
|
1860
|
-
clear_handler_1,
|
|
1861
1903
|
blur_handler,
|
|
1904
|
+
blur_handler_1,
|
|
1862
1905
|
keydown_handler,
|
|
1863
1906
|
keydown_handler_1,
|
|
1864
1907
|
click_handler_1,
|
|
@@ -1880,15 +1923,16 @@ class Typeahead extends SvelteComponent {
|
|
|
1880
1923
|
{
|
|
1881
1924
|
id: 2,
|
|
1882
1925
|
value: 0,
|
|
1883
|
-
data:
|
|
1884
|
-
extract:
|
|
1885
|
-
disable:
|
|
1886
|
-
filter:
|
|
1887
|
-
autoselect:
|
|
1888
|
-
inputAfterSelect:
|
|
1926
|
+
data: 15,
|
|
1927
|
+
extract: 16,
|
|
1928
|
+
disable: 17,
|
|
1929
|
+
filter: 18,
|
|
1930
|
+
autoselect: 19,
|
|
1931
|
+
inputAfterSelect: 20,
|
|
1889
1932
|
results: 1,
|
|
1890
|
-
focusAfterSelect:
|
|
1891
|
-
|
|
1933
|
+
focusAfterSelect: 21,
|
|
1934
|
+
showDropdownOnFocus: 22,
|
|
1935
|
+
limit: 23
|
|
1892
1936
|
},
|
|
1893
1937
|
add_css,
|
|
1894
1938
|
[-1, -1]
|
|
@@ -1896,6 +1940,4 @@ class Typeahead extends SvelteComponent {
|
|
|
1896
1940
|
}
|
|
1897
1941
|
}
|
|
1898
1942
|
|
|
1899
|
-
|
|
1900
|
-
|
|
1901
|
-
export { Typeahead$1 as default };
|
|
1943
|
+
export { Typeahead as default };
|