svelte-typeahead 4.2.3 → 4.2.4
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/lib/index.js +117 -113
- package/lib/index.mjs +117 -113
- package/package.json +1 -1
- package/src/Typeahead.svelte +19 -13
package/CHANGELOG.md
CHANGED
|
@@ -5,6 +5,12 @@ All notable changes to this project will be documented in this file.
|
|
|
5
5
|
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
|
6
6
|
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
7
7
|
|
|
8
|
+
## [4.2.4](https://github.com/metonym/svelte-typeahead/releases/tag/v4.2.4) - 2022-07-05
|
|
9
|
+
|
|
10
|
+
**Fixes**
|
|
11
|
+
|
|
12
|
+
- set dropdown menu `z-index: 1` when expanded
|
|
13
|
+
|
|
8
14
|
## [4.2.3](https://github.com/metonym/svelte-typeahead/releases/tag/v4.2.3) - 2022-07-04
|
|
9
15
|
|
|
10
16
|
**Fixes**
|
package/lib/index.js
CHANGED
|
@@ -1071,7 +1071,7 @@
|
|
|
1071
1071
|
/* src/Typeahead.svelte generated by Svelte v3.48.0 */
|
|
1072
1072
|
|
|
1073
1073
|
function add_css(target) {
|
|
1074
|
-
append_styles(target, "svelte-
|
|
1074
|
+
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}");
|
|
1075
1075
|
}
|
|
1076
1076
|
|
|
1077
1077
|
const get_no_results_slot_changes = dirty => ({
|
|
@@ -1081,14 +1081,14 @@
|
|
|
1081
1081
|
|
|
1082
1082
|
const get_no_results_slot_context = ctx => ({
|
|
1083
1083
|
value: /*value*/ ctx[0],
|
|
1084
|
-
result: /*result*/ ctx[
|
|
1085
|
-
index: /*
|
|
1084
|
+
result: /*result*/ ctx[42],
|
|
1085
|
+
index: /*index*/ ctx[44]
|
|
1086
1086
|
});
|
|
1087
1087
|
|
|
1088
1088
|
function get_each_context(ctx, list, i) {
|
|
1089
1089
|
const child_ctx = ctx.slice();
|
|
1090
|
-
child_ctx[
|
|
1091
|
-
child_ctx[
|
|
1090
|
+
child_ctx[42] = list[i];
|
|
1091
|
+
child_ctx[44] = i;
|
|
1092
1092
|
return child_ctx;
|
|
1093
1093
|
}
|
|
1094
1094
|
|
|
@@ -1098,12 +1098,12 @@
|
|
|
1098
1098
|
});
|
|
1099
1099
|
|
|
1100
1100
|
const get_default_slot_context = ctx => ({
|
|
1101
|
-
result: /*result*/ ctx[
|
|
1102
|
-
index: /*
|
|
1101
|
+
result: /*result*/ ctx[42],
|
|
1102
|
+
index: /*index*/ ctx[44],
|
|
1103
1103
|
value: /*value*/ ctx[0]
|
|
1104
1104
|
});
|
|
1105
1105
|
|
|
1106
|
-
// (
|
|
1106
|
+
// (201:4) {#if showResults}
|
|
1107
1107
|
function create_if_block_1(ctx) {
|
|
1108
1108
|
let each_1_anchor;
|
|
1109
1109
|
let current;
|
|
@@ -1135,7 +1135,7 @@
|
|
|
1135
1135
|
current = true;
|
|
1136
1136
|
},
|
|
1137
1137
|
p(ctx, dirty) {
|
|
1138
|
-
if (dirty[0] & /*id, selectedIndex, results, select, $$scope, value*/
|
|
1138
|
+
if (dirty[0] & /*id, selectedIndex, results, select, $$scope, value*/ 2097479) {
|
|
1139
1139
|
each_value = /*results*/ ctx[1];
|
|
1140
1140
|
let i;
|
|
1141
1141
|
|
|
@@ -1187,10 +1187,10 @@
|
|
|
1187
1187
|
};
|
|
1188
1188
|
}
|
|
1189
1189
|
|
|
1190
|
-
// (
|
|
1190
|
+
// (219:41)
|
|
1191
1191
|
function fallback_block(ctx) {
|
|
1192
1192
|
let html_tag;
|
|
1193
|
-
let raw_value = /*result*/ ctx[
|
|
1193
|
+
let raw_value = /*result*/ ctx[42].string + "";
|
|
1194
1194
|
let html_anchor;
|
|
1195
1195
|
|
|
1196
1196
|
return {
|
|
@@ -1204,7 +1204,7 @@
|
|
|
1204
1204
|
insert(target, html_anchor, anchor);
|
|
1205
1205
|
},
|
|
1206
1206
|
p(ctx, dirty) {
|
|
1207
|
-
if (dirty[0] & /*results*/ 2 && raw_value !== (raw_value = /*result*/ ctx[
|
|
1207
|
+
if (dirty[0] & /*results*/ 2 && raw_value !== (raw_value = /*result*/ ctx[42].string + "")) html_tag.p(raw_value);
|
|
1208
1208
|
},
|
|
1209
1209
|
d(detaching) {
|
|
1210
1210
|
if (detaching) detach(html_anchor);
|
|
@@ -1213,7 +1213,7 @@
|
|
|
1213
1213
|
};
|
|
1214
1214
|
}
|
|
1215
1215
|
|
|
1216
|
-
// (
|
|
1216
|
+
// (202:6) {#each results as result, index}
|
|
1217
1217
|
function create_each_block(ctx) {
|
|
1218
1218
|
let li;
|
|
1219
1219
|
let t;
|
|
@@ -1222,16 +1222,16 @@
|
|
|
1222
1222
|
let current;
|
|
1223
1223
|
let mounted;
|
|
1224
1224
|
let dispose;
|
|
1225
|
-
const default_slot_template = /*#slots*/ ctx[
|
|
1226
|
-
const default_slot = create_slot(default_slot_template, ctx, /*$$scope*/ ctx[
|
|
1225
|
+
const default_slot_template = /*#slots*/ ctx[22].default;
|
|
1226
|
+
const default_slot = create_slot(default_slot_template, ctx, /*$$scope*/ ctx[21], get_default_slot_context);
|
|
1227
1227
|
const default_slot_or_fallback = default_slot || fallback_block(ctx);
|
|
1228
1228
|
|
|
1229
1229
|
function click_handler_1() {
|
|
1230
|
-
return /*click_handler_1*/ ctx[
|
|
1230
|
+
return /*click_handler_1*/ ctx[36](/*result*/ ctx[42], /*index*/ ctx[44]);
|
|
1231
1231
|
}
|
|
1232
1232
|
|
|
1233
1233
|
function mouseenter_handler() {
|
|
1234
|
-
return /*mouseenter_handler*/ ctx[
|
|
1234
|
+
return /*mouseenter_handler*/ ctx[37](/*result*/ ctx[42], /*index*/ ctx[44]);
|
|
1235
1235
|
}
|
|
1236
1236
|
|
|
1237
1237
|
return {
|
|
@@ -1240,11 +1240,11 @@
|
|
|
1240
1240
|
if (default_slot_or_fallback) default_slot_or_fallback.c();
|
|
1241
1241
|
t = space();
|
|
1242
1242
|
attr(li, "role", "option");
|
|
1243
|
-
attr(li, "id", li_id_value = "" + (/*id*/ ctx[2] + "-result-" + /*
|
|
1244
|
-
attr(li, "aria-selected", li_aria_selected_value = /*selectedIndex*/ ctx[6] === /*
|
|
1245
|
-
attr(li, "class", "svelte-
|
|
1246
|
-
toggle_class(li, "selected", /*selectedIndex*/ ctx[6] === /*
|
|
1247
|
-
toggle_class(li, "disabled", /*result*/ ctx[
|
|
1243
|
+
attr(li, "id", li_id_value = "" + (/*id*/ ctx[2] + "-result-" + /*index*/ ctx[44]));
|
|
1244
|
+
attr(li, "aria-selected", li_aria_selected_value = /*selectedIndex*/ ctx[6] === /*index*/ ctx[44]);
|
|
1245
|
+
attr(li, "class", "svelte-9wywte");
|
|
1246
|
+
toggle_class(li, "selected", /*selectedIndex*/ ctx[6] === /*index*/ ctx[44]);
|
|
1247
|
+
toggle_class(li, "disabled", /*result*/ ctx[42].disabled);
|
|
1248
1248
|
},
|
|
1249
1249
|
m(target, anchor) {
|
|
1250
1250
|
insert(target, li, anchor);
|
|
@@ -1269,15 +1269,15 @@
|
|
|
1269
1269
|
ctx = new_ctx;
|
|
1270
1270
|
|
|
1271
1271
|
if (default_slot) {
|
|
1272
|
-
if (default_slot.p && (!current || dirty[0] & /*$$scope, results, value*/
|
|
1272
|
+
if (default_slot.p && (!current || dirty[0] & /*$$scope, results, value*/ 2097155)) {
|
|
1273
1273
|
update_slot_base(
|
|
1274
1274
|
default_slot,
|
|
1275
1275
|
default_slot_template,
|
|
1276
1276
|
ctx,
|
|
1277
|
-
/*$$scope*/ ctx[
|
|
1277
|
+
/*$$scope*/ ctx[21],
|
|
1278
1278
|
!current
|
|
1279
|
-
? get_all_dirty_from_scope(/*$$scope*/ ctx[
|
|
1280
|
-
: get_slot_changes(default_slot_template, /*$$scope*/ ctx[
|
|
1279
|
+
? get_all_dirty_from_scope(/*$$scope*/ ctx[21])
|
|
1280
|
+
: get_slot_changes(default_slot_template, /*$$scope*/ ctx[21], dirty, get_default_slot_changes),
|
|
1281
1281
|
get_default_slot_context
|
|
1282
1282
|
);
|
|
1283
1283
|
}
|
|
@@ -1287,20 +1287,20 @@
|
|
|
1287
1287
|
}
|
|
1288
1288
|
}
|
|
1289
1289
|
|
|
1290
|
-
if (!current || dirty[0] & /*id*/ 4 && li_id_value !== (li_id_value = "" + (/*id*/ ctx[2] + "-result-" + /*
|
|
1290
|
+
if (!current || dirty[0] & /*id*/ 4 && li_id_value !== (li_id_value = "" + (/*id*/ ctx[2] + "-result-" + /*index*/ ctx[44]))) {
|
|
1291
1291
|
attr(li, "id", li_id_value);
|
|
1292
1292
|
}
|
|
1293
1293
|
|
|
1294
|
-
if (!current || dirty[0] & /*selectedIndex*/ 64 && li_aria_selected_value !== (li_aria_selected_value = /*selectedIndex*/ ctx[6] === /*
|
|
1294
|
+
if (!current || dirty[0] & /*selectedIndex*/ 64 && li_aria_selected_value !== (li_aria_selected_value = /*selectedIndex*/ ctx[6] === /*index*/ ctx[44])) {
|
|
1295
1295
|
attr(li, "aria-selected", li_aria_selected_value);
|
|
1296
1296
|
}
|
|
1297
1297
|
|
|
1298
1298
|
if (dirty[0] & /*selectedIndex*/ 64) {
|
|
1299
|
-
toggle_class(li, "selected", /*selectedIndex*/ ctx[6] === /*
|
|
1299
|
+
toggle_class(li, "selected", /*selectedIndex*/ ctx[6] === /*index*/ ctx[44]);
|
|
1300
1300
|
}
|
|
1301
1301
|
|
|
1302
1302
|
if (dirty[0] & /*results*/ 2) {
|
|
1303
|
-
toggle_class(li, "disabled", /*result*/ ctx[
|
|
1303
|
+
toggle_class(li, "disabled", /*result*/ ctx[42].disabled);
|
|
1304
1304
|
}
|
|
1305
1305
|
},
|
|
1306
1306
|
i(local) {
|
|
@@ -1321,18 +1321,18 @@
|
|
|
1321
1321
|
};
|
|
1322
1322
|
}
|
|
1323
1323
|
|
|
1324
|
-
// (
|
|
1324
|
+
// (225:4) {#if $$slots["no-results"] && !hideDropdown && value.length > 0 && results.length === 0}
|
|
1325
1325
|
function create_if_block(ctx) {
|
|
1326
1326
|
let div;
|
|
1327
1327
|
let current;
|
|
1328
|
-
const no_results_slot_template = /*#slots*/ ctx[
|
|
1329
|
-
const no_results_slot = create_slot(no_results_slot_template, ctx, /*$$scope*/ ctx[
|
|
1328
|
+
const no_results_slot_template = /*#slots*/ ctx[22]["no-results"];
|
|
1329
|
+
const no_results_slot = create_slot(no_results_slot_template, ctx, /*$$scope*/ ctx[21], get_no_results_slot_context);
|
|
1330
1330
|
|
|
1331
1331
|
return {
|
|
1332
1332
|
c() {
|
|
1333
1333
|
div = element("div");
|
|
1334
1334
|
if (no_results_slot) no_results_slot.c();
|
|
1335
|
-
attr(div, "class", "svelte-
|
|
1335
|
+
attr(div, "class", "svelte-9wywte");
|
|
1336
1336
|
toggle_class(div, "no-results", true);
|
|
1337
1337
|
},
|
|
1338
1338
|
m(target, anchor) {
|
|
@@ -1346,15 +1346,15 @@
|
|
|
1346
1346
|
},
|
|
1347
1347
|
p(ctx, dirty) {
|
|
1348
1348
|
if (no_results_slot) {
|
|
1349
|
-
if (no_results_slot.p && (!current || dirty[0] & /*$$scope, value, results*/
|
|
1349
|
+
if (no_results_slot.p && (!current || dirty[0] & /*$$scope, value, results*/ 2097155)) {
|
|
1350
1350
|
update_slot_base(
|
|
1351
1351
|
no_results_slot,
|
|
1352
1352
|
no_results_slot_template,
|
|
1353
1353
|
ctx,
|
|
1354
|
-
/*$$scope*/ ctx[
|
|
1354
|
+
/*$$scope*/ ctx[21],
|
|
1355
1355
|
!current
|
|
1356
|
-
? get_all_dirty_from_scope(/*$$scope*/ ctx[
|
|
1357
|
-
: get_slot_changes(no_results_slot_template, /*$$scope*/ ctx[
|
|
1356
|
+
? get_all_dirty_from_scope(/*$$scope*/ ctx[21])
|
|
1357
|
+
: get_slot_changes(no_results_slot_template, /*$$scope*/ ctx[21], dirty, get_no_results_slot_changes),
|
|
1358
1358
|
get_no_results_slot_context
|
|
1359
1359
|
);
|
|
1360
1360
|
}
|
|
@@ -1387,7 +1387,6 @@
|
|
|
1387
1387
|
let ul_aria_labelledby_value;
|
|
1388
1388
|
let ul_id_value;
|
|
1389
1389
|
let div_aria_owns_value;
|
|
1390
|
-
let div_aria_expanded_value;
|
|
1391
1390
|
let div_id_value;
|
|
1392
1391
|
let current;
|
|
1393
1392
|
let mounted;
|
|
@@ -1396,7 +1395,7 @@
|
|
|
1396
1395
|
const search_spread_levels = [
|
|
1397
1396
|
{ id: /*id*/ ctx[2] },
|
|
1398
1397
|
{ removeFormAriaAttributes: true },
|
|
1399
|
-
/*$$restProps*/ ctx[
|
|
1398
|
+
/*$$restProps*/ ctx[11],
|
|
1400
1399
|
{ "aria-autocomplete": "list" },
|
|
1401
1400
|
{
|
|
1402
1401
|
"aria-controls": "" + (/*id*/ ctx[2] + "-listbox")
|
|
@@ -1405,18 +1404,18 @@
|
|
|
1405
1404
|
"aria-labelledby": "" + (/*id*/ ctx[2] + "-label")
|
|
1406
1405
|
},
|
|
1407
1406
|
{
|
|
1408
|
-
"aria-activedescendant": /*selectedIndex*/ ctx[6] >= 0 && !/*hideDropdown*/ ctx[
|
|
1407
|
+
"aria-activedescendant": /*selectedIndex*/ ctx[6] >= 0 && !/*hideDropdown*/ ctx[3] && /*results*/ ctx[1].length > 0
|
|
1409
1408
|
? `${/*id*/ ctx[2]}-result-${/*selectedIndex*/ ctx[6]}`
|
|
1410
1409
|
: null
|
|
1411
1410
|
}
|
|
1412
1411
|
];
|
|
1413
1412
|
|
|
1414
1413
|
function search_ref_binding(value) {
|
|
1415
|
-
/*search_ref_binding*/ ctx[
|
|
1414
|
+
/*search_ref_binding*/ ctx[24](value);
|
|
1416
1415
|
}
|
|
1417
1416
|
|
|
1418
1417
|
function search_value_binding(value) {
|
|
1419
|
-
/*search_value_binding*/ ctx[
|
|
1418
|
+
/*search_value_binding*/ ctx[25](value);
|
|
1420
1419
|
}
|
|
1421
1420
|
|
|
1422
1421
|
let search_props = {};
|
|
@@ -1425,8 +1424,8 @@
|
|
|
1425
1424
|
search_props = assign(search_props, search_spread_levels[i]);
|
|
1426
1425
|
}
|
|
1427
1426
|
|
|
1428
|
-
if (/*searchRef*/ ctx[
|
|
1429
|
-
search_props.ref = /*searchRef*/ ctx[
|
|
1427
|
+
if (/*searchRef*/ ctx[5] !== void 0) {
|
|
1428
|
+
search_props.ref = /*searchRef*/ ctx[5];
|
|
1430
1429
|
}
|
|
1431
1430
|
|
|
1432
1431
|
if (/*value*/ ctx[0] !== void 0) {
|
|
@@ -1436,18 +1435,18 @@
|
|
|
1436
1435
|
search = new Search$1({ props: search_props });
|
|
1437
1436
|
binding_callbacks.push(() => bind(search, 'ref', search_ref_binding));
|
|
1438
1437
|
binding_callbacks.push(() => bind(search, 'value', search_value_binding));
|
|
1439
|
-
search.$on("type", /*type_handler*/ ctx[
|
|
1440
|
-
search.$on("input", /*input_handler*/ ctx[
|
|
1441
|
-
search.$on("change", /*change_handler*/ ctx[
|
|
1442
|
-
search.$on("focus", /*focus_handler*/ ctx[
|
|
1443
|
-
search.$on("focus", /*focus_handler_1*/ ctx[
|
|
1444
|
-
search.$on("clear", /*clear_handler*/ ctx[
|
|
1445
|
-
search.$on("clear", /*clear_handler_1*/ ctx[
|
|
1446
|
-
search.$on("blur", /*blur_handler*/ ctx[
|
|
1447
|
-
search.$on("keydown", /*keydown_handler*/ ctx[
|
|
1448
|
-
search.$on("keydown", /*keydown_handler_1*/ ctx[
|
|
1449
|
-
let if_block0 =
|
|
1450
|
-
let if_block1 = /*$$slots*/ ctx[
|
|
1438
|
+
search.$on("type", /*type_handler*/ ctx[26]);
|
|
1439
|
+
search.$on("input", /*input_handler*/ ctx[27]);
|
|
1440
|
+
search.$on("change", /*change_handler*/ ctx[28]);
|
|
1441
|
+
search.$on("focus", /*focus_handler*/ ctx[29]);
|
|
1442
|
+
search.$on("focus", /*focus_handler_1*/ ctx[30]);
|
|
1443
|
+
search.$on("clear", /*clear_handler*/ ctx[31]);
|
|
1444
|
+
search.$on("clear", /*clear_handler_1*/ ctx[32]);
|
|
1445
|
+
search.$on("blur", /*blur_handler*/ ctx[33]);
|
|
1446
|
+
search.$on("keydown", /*keydown_handler*/ ctx[34]);
|
|
1447
|
+
search.$on("keydown", /*keydown_handler_1*/ ctx[35]);
|
|
1448
|
+
let if_block0 = /*showResults*/ ctx[7] && create_if_block_1(ctx);
|
|
1449
|
+
let if_block1 = /*$$slots*/ ctx[10]["no-results"] && !/*hideDropdown*/ ctx[3] && /*value*/ ctx[0].length > 0 && /*results*/ ctx[1].length === 0 && create_if_block(ctx);
|
|
1451
1450
|
|
|
1452
1451
|
return {
|
|
1453
1452
|
c() {
|
|
@@ -1461,15 +1460,15 @@
|
|
|
1461
1460
|
attr(ul, "role", "listbox");
|
|
1462
1461
|
attr(ul, "aria-labelledby", ul_aria_labelledby_value = "" + (/*id*/ ctx[2] + "-label"));
|
|
1463
1462
|
attr(ul, "id", ul_id_value = "" + (/*id*/ ctx[2] + "-listbox"));
|
|
1464
|
-
attr(ul, "class", "svelte-
|
|
1463
|
+
attr(ul, "class", "svelte-9wywte");
|
|
1465
1464
|
toggle_class(ul, "svelte-typeahead-list", true);
|
|
1466
1465
|
attr(div, "data-svelte-typeahead", "");
|
|
1467
1466
|
attr(div, "role", "combobox");
|
|
1468
1467
|
attr(div, "aria-haspopup", "listbox");
|
|
1469
1468
|
attr(div, "aria-owns", div_aria_owns_value = "" + (/*id*/ ctx[2] + "-listbox"));
|
|
1470
|
-
attr(div, "aria-expanded",
|
|
1469
|
+
attr(div, "aria-expanded", /*showResults*/ ctx[7]);
|
|
1471
1470
|
attr(div, "id", div_id_value = "" + (/*id*/ ctx[2] + "-typeahead"));
|
|
1472
|
-
attr(div, "class", "svelte-
|
|
1471
|
+
attr(div, "class", "svelte-9wywte");
|
|
1473
1472
|
toggle_class(div, "dropdown", /*results*/ ctx[1].length > 0);
|
|
1474
1473
|
},
|
|
1475
1474
|
m(target, anchor) {
|
|
@@ -1480,20 +1479,20 @@
|
|
|
1480
1479
|
if (if_block0) if_block0.m(ul, null);
|
|
1481
1480
|
append(ul, t1);
|
|
1482
1481
|
if (if_block1) if_block1.m(ul, null);
|
|
1483
|
-
/*div_binding*/ ctx[
|
|
1482
|
+
/*div_binding*/ ctx[38](div);
|
|
1484
1483
|
current = true;
|
|
1485
1484
|
|
|
1486
1485
|
if (!mounted) {
|
|
1487
|
-
dispose = listen(window, "click", /*click_handler*/ ctx[
|
|
1486
|
+
dispose = listen(window, "click", /*click_handler*/ ctx[23]);
|
|
1488
1487
|
mounted = true;
|
|
1489
1488
|
}
|
|
1490
1489
|
},
|
|
1491
1490
|
p(ctx, dirty) {
|
|
1492
|
-
const search_changes = (dirty[0] & /*id, $$restProps, selectedIndex, hideDropdown, results*/
|
|
1491
|
+
const search_changes = (dirty[0] & /*id, $$restProps, selectedIndex, hideDropdown, results*/ 2126)
|
|
1493
1492
|
? get_spread_update(search_spread_levels, [
|
|
1494
1493
|
dirty[0] & /*id*/ 4 && { id: /*id*/ ctx[2] },
|
|
1495
1494
|
search_spread_levels[1],
|
|
1496
|
-
dirty[0] & /*$$restProps*/
|
|
1495
|
+
dirty[0] & /*$$restProps*/ 2048 && get_spread_object(/*$$restProps*/ ctx[11]),
|
|
1497
1496
|
search_spread_levels[3],
|
|
1498
1497
|
dirty[0] & /*id*/ 4 && {
|
|
1499
1498
|
"aria-controls": "" + (/*id*/ ctx[2] + "-listbox")
|
|
@@ -1501,17 +1500,17 @@
|
|
|
1501
1500
|
dirty[0] & /*id*/ 4 && {
|
|
1502
1501
|
"aria-labelledby": "" + (/*id*/ ctx[2] + "-label")
|
|
1503
1502
|
},
|
|
1504
|
-
dirty[0] & /*selectedIndex, hideDropdown, results, id*/
|
|
1505
|
-
"aria-activedescendant": /*selectedIndex*/ ctx[6] >= 0 && !/*hideDropdown*/ ctx[
|
|
1503
|
+
dirty[0] & /*selectedIndex, hideDropdown, results, id*/ 78 && {
|
|
1504
|
+
"aria-activedescendant": /*selectedIndex*/ ctx[6] >= 0 && !/*hideDropdown*/ ctx[3] && /*results*/ ctx[1].length > 0
|
|
1506
1505
|
? `${/*id*/ ctx[2]}-result-${/*selectedIndex*/ ctx[6]}`
|
|
1507
1506
|
: null
|
|
1508
1507
|
}
|
|
1509
1508
|
])
|
|
1510
1509
|
: {};
|
|
1511
1510
|
|
|
1512
|
-
if (!updating_ref && dirty[0] & /*searchRef*/
|
|
1511
|
+
if (!updating_ref && dirty[0] & /*searchRef*/ 32) {
|
|
1513
1512
|
updating_ref = true;
|
|
1514
|
-
search_changes.ref = /*searchRef*/ ctx[
|
|
1513
|
+
search_changes.ref = /*searchRef*/ ctx[5];
|
|
1515
1514
|
add_flush_callback(() => updating_ref = false);
|
|
1516
1515
|
}
|
|
1517
1516
|
|
|
@@ -1523,11 +1522,11 @@
|
|
|
1523
1522
|
|
|
1524
1523
|
search.$set(search_changes);
|
|
1525
1524
|
|
|
1526
|
-
if (
|
|
1525
|
+
if (/*showResults*/ ctx[7]) {
|
|
1527
1526
|
if (if_block0) {
|
|
1528
1527
|
if_block0.p(ctx, dirty);
|
|
1529
1528
|
|
|
1530
|
-
if (dirty[0] & /*
|
|
1529
|
+
if (dirty[0] & /*showResults*/ 128) {
|
|
1531
1530
|
transition_in(if_block0, 1);
|
|
1532
1531
|
}
|
|
1533
1532
|
} else {
|
|
@@ -1546,11 +1545,11 @@
|
|
|
1546
1545
|
check_outros();
|
|
1547
1546
|
}
|
|
1548
1547
|
|
|
1549
|
-
if (/*$$slots*/ ctx[
|
|
1548
|
+
if (/*$$slots*/ ctx[10]["no-results"] && !/*hideDropdown*/ ctx[3] && /*value*/ ctx[0].length > 0 && /*results*/ ctx[1].length === 0) {
|
|
1550
1549
|
if (if_block1) {
|
|
1551
1550
|
if_block1.p(ctx, dirty);
|
|
1552
1551
|
|
|
1553
|
-
if (dirty[0] & /*$$slots, hideDropdown, value, results*/
|
|
1552
|
+
if (dirty[0] & /*$$slots, hideDropdown, value, results*/ 1035) {
|
|
1554
1553
|
transition_in(if_block1, 1);
|
|
1555
1554
|
}
|
|
1556
1555
|
} else {
|
|
@@ -1581,8 +1580,8 @@
|
|
|
1581
1580
|
attr(div, "aria-owns", div_aria_owns_value);
|
|
1582
1581
|
}
|
|
1583
1582
|
|
|
1584
|
-
if (!current || dirty[0] & /*
|
|
1585
|
-
attr(div, "aria-expanded",
|
|
1583
|
+
if (!current || dirty[0] & /*showResults*/ 128) {
|
|
1584
|
+
attr(div, "aria-expanded", /*showResults*/ ctx[7]);
|
|
1586
1585
|
}
|
|
1587
1586
|
|
|
1588
1587
|
if (!current || dirty[0] & /*id*/ 4 && div_id_value !== (div_id_value = "" + (/*id*/ ctx[2] + "-typeahead"))) {
|
|
@@ -1611,7 +1610,7 @@
|
|
|
1611
1610
|
destroy_component(search);
|
|
1612
1611
|
if (if_block0) if_block0.d();
|
|
1613
1612
|
if (if_block1) if_block1.d();
|
|
1614
|
-
/*div_binding*/ ctx[
|
|
1613
|
+
/*div_binding*/ ctx[38](null);
|
|
1615
1614
|
mounted = false;
|
|
1616
1615
|
dispose();
|
|
1617
1616
|
}
|
|
@@ -1621,6 +1620,7 @@
|
|
|
1621
1620
|
function instance($$self, $$props, $$invalidate) {
|
|
1622
1621
|
let options;
|
|
1623
1622
|
let resultsId;
|
|
1623
|
+
let showResults;
|
|
1624
1624
|
|
|
1625
1625
|
const omit_props_names = [
|
|
1626
1626
|
"id","value","data","extract","disable","filter","autoselect","inputAfterSelect","results","focusAfterSelect","limit"
|
|
@@ -1653,7 +1653,7 @@
|
|
|
1653
1653
|
}
|
|
1654
1654
|
|
|
1655
1655
|
if (prevResults !== resultsId && !$$slots["no-results"]) {
|
|
1656
|
-
$$invalidate(
|
|
1656
|
+
$$invalidate(3, hideDropdown = results.length === 0);
|
|
1657
1657
|
}
|
|
1658
1658
|
|
|
1659
1659
|
prevResults = resultsId;
|
|
@@ -1677,7 +1677,7 @@
|
|
|
1677
1677
|
|
|
1678
1678
|
await tick();
|
|
1679
1679
|
if (focusAfterSelect) searchRef.focus();
|
|
1680
|
-
$$invalidate(
|
|
1680
|
+
$$invalidate(3, hideDropdown = true);
|
|
1681
1681
|
}
|
|
1682
1682
|
|
|
1683
1683
|
/** @type {(direction: -1 | 1) => void} */
|
|
@@ -1704,13 +1704,13 @@
|
|
|
1704
1704
|
|
|
1705
1705
|
const click_handler = ({ target }) => {
|
|
1706
1706
|
if (!hideDropdown && comboboxRef && !comboboxRef.contains(target)) {
|
|
1707
|
-
$$invalidate(
|
|
1707
|
+
$$invalidate(3, hideDropdown = true);
|
|
1708
1708
|
}
|
|
1709
1709
|
};
|
|
1710
1710
|
|
|
1711
1711
|
function search_ref_binding(value) {
|
|
1712
1712
|
searchRef = value;
|
|
1713
|
-
$$invalidate(
|
|
1713
|
+
$$invalidate(5, searchRef);
|
|
1714
1714
|
}
|
|
1715
1715
|
|
|
1716
1716
|
function search_value_binding(value$1) {
|
|
@@ -1735,7 +1735,7 @@
|
|
|
1735
1735
|
}
|
|
1736
1736
|
|
|
1737
1737
|
const focus_handler_1 = () => {
|
|
1738
|
-
$$invalidate(
|
|
1738
|
+
$$invalidate(3, hideDropdown = false);
|
|
1739
1739
|
};
|
|
1740
1740
|
|
|
1741
1741
|
function clear_handler(event) {
|
|
@@ -1743,7 +1743,7 @@
|
|
|
1743
1743
|
}
|
|
1744
1744
|
|
|
1745
1745
|
const clear_handler_1 = () => {
|
|
1746
|
-
$$invalidate(
|
|
1746
|
+
$$invalidate(3, hideDropdown = false);
|
|
1747
1747
|
};
|
|
1748
1748
|
|
|
1749
1749
|
function blur_handler(event) {
|
|
@@ -1773,72 +1773,76 @@
|
|
|
1773
1773
|
e.preventDefault();
|
|
1774
1774
|
$$invalidate(0, value = "");
|
|
1775
1775
|
searchRef.focus();
|
|
1776
|
-
$$invalidate(
|
|
1776
|
+
$$invalidate(3, hideDropdown = true);
|
|
1777
1777
|
break;
|
|
1778
1778
|
}
|
|
1779
1779
|
};
|
|
1780
1780
|
|
|
1781
|
-
const click_handler_1 = (result,
|
|
1782
|
-
if (
|
|
1783
|
-
|
|
1784
|
-
|
|
1785
|
-
}
|
|
1781
|
+
const click_handler_1 = (result, index) => {
|
|
1782
|
+
if (result.disabled) return;
|
|
1783
|
+
$$invalidate(6, selectedIndex = index);
|
|
1784
|
+
select();
|
|
1786
1785
|
};
|
|
1787
1786
|
|
|
1788
|
-
const mouseenter_handler = (result,
|
|
1787
|
+
const mouseenter_handler = (result, index) => {
|
|
1789
1788
|
if (result.disabled) return;
|
|
1790
|
-
$$invalidate(6, selectedIndex =
|
|
1789
|
+
$$invalidate(6, selectedIndex = index);
|
|
1791
1790
|
};
|
|
1792
1791
|
|
|
1793
1792
|
function div_binding($$value) {
|
|
1794
1793
|
binding_callbacks[$$value ? 'unshift' : 'push'](() => {
|
|
1795
1794
|
comboboxRef = $$value;
|
|
1796
|
-
$$invalidate(
|
|
1795
|
+
$$invalidate(4, comboboxRef);
|
|
1797
1796
|
});
|
|
1798
1797
|
}
|
|
1799
1798
|
|
|
1800
1799
|
$$self.$$set = $$new_props => {
|
|
1801
1800
|
$$props = assign(assign({}, $$props), exclude_internal_props($$new_props));
|
|
1802
|
-
$$invalidate(
|
|
1801
|
+
$$invalidate(11, $$restProps = compute_rest_props($$props, omit_props_names));
|
|
1803
1802
|
if ('id' in $$new_props) $$invalidate(2, id = $$new_props.id);
|
|
1804
1803
|
if ('value' in $$new_props) $$invalidate(0, value = $$new_props.value);
|
|
1805
|
-
if ('data' in $$new_props) $$invalidate(
|
|
1806
|
-
if ('extract' in $$new_props) $$invalidate(
|
|
1807
|
-
if ('disable' in $$new_props) $$invalidate(
|
|
1808
|
-
if ('filter' in $$new_props) $$invalidate(
|
|
1809
|
-
if ('autoselect' in $$new_props) $$invalidate(
|
|
1810
|
-
if ('inputAfterSelect' in $$new_props) $$invalidate(
|
|
1804
|
+
if ('data' in $$new_props) $$invalidate(12, data = $$new_props.data);
|
|
1805
|
+
if ('extract' in $$new_props) $$invalidate(13, extract = $$new_props.extract);
|
|
1806
|
+
if ('disable' in $$new_props) $$invalidate(14, disable = $$new_props.disable);
|
|
1807
|
+
if ('filter' in $$new_props) $$invalidate(15, filter = $$new_props.filter);
|
|
1808
|
+
if ('autoselect' in $$new_props) $$invalidate(16, autoselect = $$new_props.autoselect);
|
|
1809
|
+
if ('inputAfterSelect' in $$new_props) $$invalidate(17, inputAfterSelect = $$new_props.inputAfterSelect);
|
|
1811
1810
|
if ('results' in $$new_props) $$invalidate(1, results = $$new_props.results);
|
|
1812
|
-
if ('focusAfterSelect' in $$new_props) $$invalidate(
|
|
1813
|
-
if ('limit' in $$new_props) $$invalidate(
|
|
1814
|
-
if ('$$scope' in $$new_props) $$invalidate(
|
|
1811
|
+
if ('focusAfterSelect' in $$new_props) $$invalidate(18, focusAfterSelect = $$new_props.focusAfterSelect);
|
|
1812
|
+
if ('limit' in $$new_props) $$invalidate(19, limit = $$new_props.limit);
|
|
1813
|
+
if ('$$scope' in $$new_props) $$invalidate(21, $$scope = $$new_props.$$scope);
|
|
1815
1814
|
};
|
|
1816
1815
|
|
|
1817
1816
|
$$self.$$.update = () => {
|
|
1818
|
-
if ($$self.$$.dirty[0] & /*extract*/
|
|
1819
|
-
$$invalidate(
|
|
1817
|
+
if ($$self.$$.dirty[0] & /*extract*/ 8192) {
|
|
1818
|
+
$$invalidate(20, options = { pre: "<mark>", post: "</mark>", extract });
|
|
1820
1819
|
}
|
|
1821
1820
|
|
|
1822
|
-
if ($$self.$$.dirty[0] & /*value, data, options, limit, filter, disable*/
|
|
1821
|
+
if ($$self.$$.dirty[0] & /*value, data, options, limit, filter, disable*/ 1626113) {
|
|
1823
1822
|
$$invalidate(1, results = fuzzy.filter(value, data, options).filter(({ score }) => score > 0).slice(0, limit).filter(result => !filter(result.original)).map(result => ({
|
|
1824
1823
|
...result,
|
|
1825
1824
|
disabled: disable(result.original)
|
|
1826
1825
|
})));
|
|
1827
1826
|
}
|
|
1828
1827
|
|
|
1829
|
-
if ($$self.$$.dirty[0] & /*results, extract*/
|
|
1828
|
+
if ($$self.$$.dirty[0] & /*results, extract*/ 8194) {
|
|
1830
1829
|
resultsId = results.map(result => extract(result.original)).join("");
|
|
1831
1830
|
}
|
|
1831
|
+
|
|
1832
|
+
if ($$self.$$.dirty[0] & /*hideDropdown, results*/ 10) {
|
|
1833
|
+
$$invalidate(7, showResults = !hideDropdown && results.length > 0);
|
|
1834
|
+
}
|
|
1832
1835
|
};
|
|
1833
1836
|
|
|
1834
1837
|
return [
|
|
1835
1838
|
value,
|
|
1836
1839
|
results,
|
|
1837
1840
|
id,
|
|
1841
|
+
hideDropdown,
|
|
1838
1842
|
comboboxRef,
|
|
1839
1843
|
searchRef,
|
|
1840
|
-
hideDropdown,
|
|
1841
1844
|
selectedIndex,
|
|
1845
|
+
showResults,
|
|
1842
1846
|
select,
|
|
1843
1847
|
change,
|
|
1844
1848
|
$$slots,
|
|
@@ -1886,15 +1890,15 @@
|
|
|
1886
1890
|
{
|
|
1887
1891
|
id: 2,
|
|
1888
1892
|
value: 0,
|
|
1889
|
-
data:
|
|
1890
|
-
extract:
|
|
1891
|
-
disable:
|
|
1892
|
-
filter:
|
|
1893
|
-
autoselect:
|
|
1894
|
-
inputAfterSelect:
|
|
1893
|
+
data: 12,
|
|
1894
|
+
extract: 13,
|
|
1895
|
+
disable: 14,
|
|
1896
|
+
filter: 15,
|
|
1897
|
+
autoselect: 16,
|
|
1898
|
+
inputAfterSelect: 17,
|
|
1895
1899
|
results: 1,
|
|
1896
|
-
focusAfterSelect:
|
|
1897
|
-
limit:
|
|
1900
|
+
focusAfterSelect: 18,
|
|
1901
|
+
limit: 19
|
|
1898
1902
|
},
|
|
1899
1903
|
add_css,
|
|
1900
1904
|
[-1, -1]
|
package/lib/index.mjs
CHANGED
|
@@ -1065,7 +1065,7 @@ var Search$1 = Search;
|
|
|
1065
1065
|
/* src/Typeahead.svelte generated by Svelte v3.48.0 */
|
|
1066
1066
|
|
|
1067
1067
|
function add_css(target) {
|
|
1068
|
-
append_styles(target, "svelte-
|
|
1068
|
+
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
1069
|
}
|
|
1070
1070
|
|
|
1071
1071
|
const get_no_results_slot_changes = dirty => ({
|
|
@@ -1075,14 +1075,14 @@ const get_no_results_slot_changes = dirty => ({
|
|
|
1075
1075
|
|
|
1076
1076
|
const get_no_results_slot_context = ctx => ({
|
|
1077
1077
|
value: /*value*/ ctx[0],
|
|
1078
|
-
result: /*result*/ ctx[
|
|
1079
|
-
index: /*
|
|
1078
|
+
result: /*result*/ ctx[42],
|
|
1079
|
+
index: /*index*/ ctx[44]
|
|
1080
1080
|
});
|
|
1081
1081
|
|
|
1082
1082
|
function get_each_context(ctx, list, i) {
|
|
1083
1083
|
const child_ctx = ctx.slice();
|
|
1084
|
-
child_ctx[
|
|
1085
|
-
child_ctx[
|
|
1084
|
+
child_ctx[42] = list[i];
|
|
1085
|
+
child_ctx[44] = i;
|
|
1086
1086
|
return child_ctx;
|
|
1087
1087
|
}
|
|
1088
1088
|
|
|
@@ -1092,12 +1092,12 @@ const get_default_slot_changes = dirty => ({
|
|
|
1092
1092
|
});
|
|
1093
1093
|
|
|
1094
1094
|
const get_default_slot_context = ctx => ({
|
|
1095
|
-
result: /*result*/ ctx[
|
|
1096
|
-
index: /*
|
|
1095
|
+
result: /*result*/ ctx[42],
|
|
1096
|
+
index: /*index*/ ctx[44],
|
|
1097
1097
|
value: /*value*/ ctx[0]
|
|
1098
1098
|
});
|
|
1099
1099
|
|
|
1100
|
-
// (
|
|
1100
|
+
// (201:4) {#if showResults}
|
|
1101
1101
|
function create_if_block_1(ctx) {
|
|
1102
1102
|
let each_1_anchor;
|
|
1103
1103
|
let current;
|
|
@@ -1129,7 +1129,7 @@ function create_if_block_1(ctx) {
|
|
|
1129
1129
|
current = true;
|
|
1130
1130
|
},
|
|
1131
1131
|
p(ctx, dirty) {
|
|
1132
|
-
if (dirty[0] & /*id, selectedIndex, results, select, $$scope, value*/
|
|
1132
|
+
if (dirty[0] & /*id, selectedIndex, results, select, $$scope, value*/ 2097479) {
|
|
1133
1133
|
each_value = /*results*/ ctx[1];
|
|
1134
1134
|
let i;
|
|
1135
1135
|
|
|
@@ -1181,10 +1181,10 @@ function create_if_block_1(ctx) {
|
|
|
1181
1181
|
};
|
|
1182
1182
|
}
|
|
1183
1183
|
|
|
1184
|
-
// (
|
|
1184
|
+
// (219:41)
|
|
1185
1185
|
function fallback_block(ctx) {
|
|
1186
1186
|
let html_tag;
|
|
1187
|
-
let raw_value = /*result*/ ctx[
|
|
1187
|
+
let raw_value = /*result*/ ctx[42].string + "";
|
|
1188
1188
|
let html_anchor;
|
|
1189
1189
|
|
|
1190
1190
|
return {
|
|
@@ -1198,7 +1198,7 @@ function fallback_block(ctx) {
|
|
|
1198
1198
|
insert(target, html_anchor, anchor);
|
|
1199
1199
|
},
|
|
1200
1200
|
p(ctx, dirty) {
|
|
1201
|
-
if (dirty[0] & /*results*/ 2 && raw_value !== (raw_value = /*result*/ ctx[
|
|
1201
|
+
if (dirty[0] & /*results*/ 2 && raw_value !== (raw_value = /*result*/ ctx[42].string + "")) html_tag.p(raw_value);
|
|
1202
1202
|
},
|
|
1203
1203
|
d(detaching) {
|
|
1204
1204
|
if (detaching) detach(html_anchor);
|
|
@@ -1207,7 +1207,7 @@ function fallback_block(ctx) {
|
|
|
1207
1207
|
};
|
|
1208
1208
|
}
|
|
1209
1209
|
|
|
1210
|
-
// (
|
|
1210
|
+
// (202:6) {#each results as result, index}
|
|
1211
1211
|
function create_each_block(ctx) {
|
|
1212
1212
|
let li;
|
|
1213
1213
|
let t;
|
|
@@ -1216,16 +1216,16 @@ function create_each_block(ctx) {
|
|
|
1216
1216
|
let current;
|
|
1217
1217
|
let mounted;
|
|
1218
1218
|
let dispose;
|
|
1219
|
-
const default_slot_template = /*#slots*/ ctx[
|
|
1220
|
-
const default_slot = create_slot(default_slot_template, ctx, /*$$scope*/ ctx[
|
|
1219
|
+
const default_slot_template = /*#slots*/ ctx[22].default;
|
|
1220
|
+
const default_slot = create_slot(default_slot_template, ctx, /*$$scope*/ ctx[21], get_default_slot_context);
|
|
1221
1221
|
const default_slot_or_fallback = default_slot || fallback_block(ctx);
|
|
1222
1222
|
|
|
1223
1223
|
function click_handler_1() {
|
|
1224
|
-
return /*click_handler_1*/ ctx[
|
|
1224
|
+
return /*click_handler_1*/ ctx[36](/*result*/ ctx[42], /*index*/ ctx[44]);
|
|
1225
1225
|
}
|
|
1226
1226
|
|
|
1227
1227
|
function mouseenter_handler() {
|
|
1228
|
-
return /*mouseenter_handler*/ ctx[
|
|
1228
|
+
return /*mouseenter_handler*/ ctx[37](/*result*/ ctx[42], /*index*/ ctx[44]);
|
|
1229
1229
|
}
|
|
1230
1230
|
|
|
1231
1231
|
return {
|
|
@@ -1234,11 +1234,11 @@ function create_each_block(ctx) {
|
|
|
1234
1234
|
if (default_slot_or_fallback) default_slot_or_fallback.c();
|
|
1235
1235
|
t = space();
|
|
1236
1236
|
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[6] === /*
|
|
1239
|
-
attr(li, "class", "svelte-
|
|
1240
|
-
toggle_class(li, "selected", /*selectedIndex*/ ctx[6] === /*
|
|
1241
|
-
toggle_class(li, "disabled", /*result*/ ctx[
|
|
1237
|
+
attr(li, "id", li_id_value = "" + (/*id*/ ctx[2] + "-result-" + /*index*/ ctx[44]));
|
|
1238
|
+
attr(li, "aria-selected", li_aria_selected_value = /*selectedIndex*/ ctx[6] === /*index*/ ctx[44]);
|
|
1239
|
+
attr(li, "class", "svelte-9wywte");
|
|
1240
|
+
toggle_class(li, "selected", /*selectedIndex*/ ctx[6] === /*index*/ ctx[44]);
|
|
1241
|
+
toggle_class(li, "disabled", /*result*/ ctx[42].disabled);
|
|
1242
1242
|
},
|
|
1243
1243
|
m(target, anchor) {
|
|
1244
1244
|
insert(target, li, anchor);
|
|
@@ -1263,15 +1263,15 @@ function create_each_block(ctx) {
|
|
|
1263
1263
|
ctx = new_ctx;
|
|
1264
1264
|
|
|
1265
1265
|
if (default_slot) {
|
|
1266
|
-
if (default_slot.p && (!current || dirty[0] & /*$$scope, results, value*/
|
|
1266
|
+
if (default_slot.p && (!current || dirty[0] & /*$$scope, results, value*/ 2097155)) {
|
|
1267
1267
|
update_slot_base(
|
|
1268
1268
|
default_slot,
|
|
1269
1269
|
default_slot_template,
|
|
1270
1270
|
ctx,
|
|
1271
|
-
/*$$scope*/ ctx[
|
|
1271
|
+
/*$$scope*/ ctx[21],
|
|
1272
1272
|
!current
|
|
1273
|
-
? get_all_dirty_from_scope(/*$$scope*/ ctx[
|
|
1274
|
-
: get_slot_changes(default_slot_template, /*$$scope*/ ctx[
|
|
1273
|
+
? get_all_dirty_from_scope(/*$$scope*/ ctx[21])
|
|
1274
|
+
: get_slot_changes(default_slot_template, /*$$scope*/ ctx[21], dirty, get_default_slot_changes),
|
|
1275
1275
|
get_default_slot_context
|
|
1276
1276
|
);
|
|
1277
1277
|
}
|
|
@@ -1281,20 +1281,20 @@ function create_each_block(ctx) {
|
|
|
1281
1281
|
}
|
|
1282
1282
|
}
|
|
1283
1283
|
|
|
1284
|
-
if (!current || dirty[0] & /*id*/ 4 && li_id_value !== (li_id_value = "" + (/*id*/ ctx[2] + "-result-" + /*
|
|
1284
|
+
if (!current || dirty[0] & /*id*/ 4 && li_id_value !== (li_id_value = "" + (/*id*/ ctx[2] + "-result-" + /*index*/ ctx[44]))) {
|
|
1285
1285
|
attr(li, "id", li_id_value);
|
|
1286
1286
|
}
|
|
1287
1287
|
|
|
1288
|
-
if (!current || dirty[0] & /*selectedIndex*/ 64 && li_aria_selected_value !== (li_aria_selected_value = /*selectedIndex*/ ctx[6] === /*
|
|
1288
|
+
if (!current || dirty[0] & /*selectedIndex*/ 64 && li_aria_selected_value !== (li_aria_selected_value = /*selectedIndex*/ ctx[6] === /*index*/ ctx[44])) {
|
|
1289
1289
|
attr(li, "aria-selected", li_aria_selected_value);
|
|
1290
1290
|
}
|
|
1291
1291
|
|
|
1292
1292
|
if (dirty[0] & /*selectedIndex*/ 64) {
|
|
1293
|
-
toggle_class(li, "selected", /*selectedIndex*/ ctx[6] === /*
|
|
1293
|
+
toggle_class(li, "selected", /*selectedIndex*/ ctx[6] === /*index*/ ctx[44]);
|
|
1294
1294
|
}
|
|
1295
1295
|
|
|
1296
1296
|
if (dirty[0] & /*results*/ 2) {
|
|
1297
|
-
toggle_class(li, "disabled", /*result*/ ctx[
|
|
1297
|
+
toggle_class(li, "disabled", /*result*/ ctx[42].disabled);
|
|
1298
1298
|
}
|
|
1299
1299
|
},
|
|
1300
1300
|
i(local) {
|
|
@@ -1315,18 +1315,18 @@ function create_each_block(ctx) {
|
|
|
1315
1315
|
};
|
|
1316
1316
|
}
|
|
1317
1317
|
|
|
1318
|
-
// (
|
|
1318
|
+
// (225:4) {#if $$slots["no-results"] && !hideDropdown && value.length > 0 && results.length === 0}
|
|
1319
1319
|
function create_if_block(ctx) {
|
|
1320
1320
|
let div;
|
|
1321
1321
|
let current;
|
|
1322
|
-
const no_results_slot_template = /*#slots*/ ctx[
|
|
1323
|
-
const no_results_slot = create_slot(no_results_slot_template, ctx, /*$$scope*/ ctx[
|
|
1322
|
+
const no_results_slot_template = /*#slots*/ ctx[22]["no-results"];
|
|
1323
|
+
const no_results_slot = create_slot(no_results_slot_template, ctx, /*$$scope*/ ctx[21], get_no_results_slot_context);
|
|
1324
1324
|
|
|
1325
1325
|
return {
|
|
1326
1326
|
c() {
|
|
1327
1327
|
div = element("div");
|
|
1328
1328
|
if (no_results_slot) no_results_slot.c();
|
|
1329
|
-
attr(div, "class", "svelte-
|
|
1329
|
+
attr(div, "class", "svelte-9wywte");
|
|
1330
1330
|
toggle_class(div, "no-results", true);
|
|
1331
1331
|
},
|
|
1332
1332
|
m(target, anchor) {
|
|
@@ -1340,15 +1340,15 @@ function create_if_block(ctx) {
|
|
|
1340
1340
|
},
|
|
1341
1341
|
p(ctx, dirty) {
|
|
1342
1342
|
if (no_results_slot) {
|
|
1343
|
-
if (no_results_slot.p && (!current || dirty[0] & /*$$scope, value, results*/
|
|
1343
|
+
if (no_results_slot.p && (!current || dirty[0] & /*$$scope, value, results*/ 2097155)) {
|
|
1344
1344
|
update_slot_base(
|
|
1345
1345
|
no_results_slot,
|
|
1346
1346
|
no_results_slot_template,
|
|
1347
1347
|
ctx,
|
|
1348
|
-
/*$$scope*/ ctx[
|
|
1348
|
+
/*$$scope*/ ctx[21],
|
|
1349
1349
|
!current
|
|
1350
|
-
? get_all_dirty_from_scope(/*$$scope*/ ctx[
|
|
1351
|
-
: get_slot_changes(no_results_slot_template, /*$$scope*/ ctx[
|
|
1350
|
+
? get_all_dirty_from_scope(/*$$scope*/ ctx[21])
|
|
1351
|
+
: get_slot_changes(no_results_slot_template, /*$$scope*/ ctx[21], dirty, get_no_results_slot_changes),
|
|
1352
1352
|
get_no_results_slot_context
|
|
1353
1353
|
);
|
|
1354
1354
|
}
|
|
@@ -1381,7 +1381,6 @@ function create_fragment(ctx) {
|
|
|
1381
1381
|
let ul_aria_labelledby_value;
|
|
1382
1382
|
let ul_id_value;
|
|
1383
1383
|
let div_aria_owns_value;
|
|
1384
|
-
let div_aria_expanded_value;
|
|
1385
1384
|
let div_id_value;
|
|
1386
1385
|
let current;
|
|
1387
1386
|
let mounted;
|
|
@@ -1390,7 +1389,7 @@ function create_fragment(ctx) {
|
|
|
1390
1389
|
const search_spread_levels = [
|
|
1391
1390
|
{ id: /*id*/ ctx[2] },
|
|
1392
1391
|
{ removeFormAriaAttributes: true },
|
|
1393
|
-
/*$$restProps*/ ctx[
|
|
1392
|
+
/*$$restProps*/ ctx[11],
|
|
1394
1393
|
{ "aria-autocomplete": "list" },
|
|
1395
1394
|
{
|
|
1396
1395
|
"aria-controls": "" + (/*id*/ ctx[2] + "-listbox")
|
|
@@ -1399,18 +1398,18 @@ function create_fragment(ctx) {
|
|
|
1399
1398
|
"aria-labelledby": "" + (/*id*/ ctx[2] + "-label")
|
|
1400
1399
|
},
|
|
1401
1400
|
{
|
|
1402
|
-
"aria-activedescendant": /*selectedIndex*/ ctx[6] >= 0 && !/*hideDropdown*/ ctx[
|
|
1401
|
+
"aria-activedescendant": /*selectedIndex*/ ctx[6] >= 0 && !/*hideDropdown*/ ctx[3] && /*results*/ ctx[1].length > 0
|
|
1403
1402
|
? `${/*id*/ ctx[2]}-result-${/*selectedIndex*/ ctx[6]}`
|
|
1404
1403
|
: null
|
|
1405
1404
|
}
|
|
1406
1405
|
];
|
|
1407
1406
|
|
|
1408
1407
|
function search_ref_binding(value) {
|
|
1409
|
-
/*search_ref_binding*/ ctx[
|
|
1408
|
+
/*search_ref_binding*/ ctx[24](value);
|
|
1410
1409
|
}
|
|
1411
1410
|
|
|
1412
1411
|
function search_value_binding(value) {
|
|
1413
|
-
/*search_value_binding*/ ctx[
|
|
1412
|
+
/*search_value_binding*/ ctx[25](value);
|
|
1414
1413
|
}
|
|
1415
1414
|
|
|
1416
1415
|
let search_props = {};
|
|
@@ -1419,8 +1418,8 @@ function create_fragment(ctx) {
|
|
|
1419
1418
|
search_props = assign(search_props, search_spread_levels[i]);
|
|
1420
1419
|
}
|
|
1421
1420
|
|
|
1422
|
-
if (/*searchRef*/ ctx[
|
|
1423
|
-
search_props.ref = /*searchRef*/ ctx[
|
|
1421
|
+
if (/*searchRef*/ ctx[5] !== void 0) {
|
|
1422
|
+
search_props.ref = /*searchRef*/ ctx[5];
|
|
1424
1423
|
}
|
|
1425
1424
|
|
|
1426
1425
|
if (/*value*/ ctx[0] !== void 0) {
|
|
@@ -1430,18 +1429,18 @@ function create_fragment(ctx) {
|
|
|
1430
1429
|
search = new Search$1({ props: search_props });
|
|
1431
1430
|
binding_callbacks.push(() => bind(search, 'ref', search_ref_binding));
|
|
1432
1431
|
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", /*clear_handler_1*/ ctx[
|
|
1440
|
-
search.$on("blur", /*blur_handler*/ ctx[
|
|
1441
|
-
search.$on("keydown", /*keydown_handler*/ ctx[
|
|
1442
|
-
search.$on("keydown", /*keydown_handler_1*/ ctx[
|
|
1443
|
-
let if_block0 =
|
|
1444
|
-
let if_block1 = /*$$slots*/ ctx[
|
|
1432
|
+
search.$on("type", /*type_handler*/ ctx[26]);
|
|
1433
|
+
search.$on("input", /*input_handler*/ ctx[27]);
|
|
1434
|
+
search.$on("change", /*change_handler*/ ctx[28]);
|
|
1435
|
+
search.$on("focus", /*focus_handler*/ ctx[29]);
|
|
1436
|
+
search.$on("focus", /*focus_handler_1*/ ctx[30]);
|
|
1437
|
+
search.$on("clear", /*clear_handler*/ ctx[31]);
|
|
1438
|
+
search.$on("clear", /*clear_handler_1*/ ctx[32]);
|
|
1439
|
+
search.$on("blur", /*blur_handler*/ ctx[33]);
|
|
1440
|
+
search.$on("keydown", /*keydown_handler*/ ctx[34]);
|
|
1441
|
+
search.$on("keydown", /*keydown_handler_1*/ ctx[35]);
|
|
1442
|
+
let if_block0 = /*showResults*/ ctx[7] && create_if_block_1(ctx);
|
|
1443
|
+
let if_block1 = /*$$slots*/ ctx[10]["no-results"] && !/*hideDropdown*/ ctx[3] && /*value*/ ctx[0].length > 0 && /*results*/ ctx[1].length === 0 && create_if_block(ctx);
|
|
1445
1444
|
|
|
1446
1445
|
return {
|
|
1447
1446
|
c() {
|
|
@@ -1455,15 +1454,15 @@ function create_fragment(ctx) {
|
|
|
1455
1454
|
attr(ul, "role", "listbox");
|
|
1456
1455
|
attr(ul, "aria-labelledby", ul_aria_labelledby_value = "" + (/*id*/ ctx[2] + "-label"));
|
|
1457
1456
|
attr(ul, "id", ul_id_value = "" + (/*id*/ ctx[2] + "-listbox"));
|
|
1458
|
-
attr(ul, "class", "svelte-
|
|
1457
|
+
attr(ul, "class", "svelte-9wywte");
|
|
1459
1458
|
toggle_class(ul, "svelte-typeahead-list", true);
|
|
1460
1459
|
attr(div, "data-svelte-typeahead", "");
|
|
1461
1460
|
attr(div, "role", "combobox");
|
|
1462
1461
|
attr(div, "aria-haspopup", "listbox");
|
|
1463
1462
|
attr(div, "aria-owns", div_aria_owns_value = "" + (/*id*/ ctx[2] + "-listbox"));
|
|
1464
|
-
attr(div, "aria-expanded",
|
|
1463
|
+
attr(div, "aria-expanded", /*showResults*/ ctx[7]);
|
|
1465
1464
|
attr(div, "id", div_id_value = "" + (/*id*/ ctx[2] + "-typeahead"));
|
|
1466
|
-
attr(div, "class", "svelte-
|
|
1465
|
+
attr(div, "class", "svelte-9wywte");
|
|
1467
1466
|
toggle_class(div, "dropdown", /*results*/ ctx[1].length > 0);
|
|
1468
1467
|
},
|
|
1469
1468
|
m(target, anchor) {
|
|
@@ -1474,20 +1473,20 @@ function create_fragment(ctx) {
|
|
|
1474
1473
|
if (if_block0) if_block0.m(ul, null);
|
|
1475
1474
|
append(ul, t1);
|
|
1476
1475
|
if (if_block1) if_block1.m(ul, null);
|
|
1477
|
-
/*div_binding*/ ctx[
|
|
1476
|
+
/*div_binding*/ ctx[38](div);
|
|
1478
1477
|
current = true;
|
|
1479
1478
|
|
|
1480
1479
|
if (!mounted) {
|
|
1481
|
-
dispose = listen(window, "click", /*click_handler*/ ctx[
|
|
1480
|
+
dispose = listen(window, "click", /*click_handler*/ ctx[23]);
|
|
1482
1481
|
mounted = true;
|
|
1483
1482
|
}
|
|
1484
1483
|
},
|
|
1485
1484
|
p(ctx, dirty) {
|
|
1486
|
-
const search_changes = (dirty[0] & /*id, $$restProps, selectedIndex, hideDropdown, results*/
|
|
1485
|
+
const search_changes = (dirty[0] & /*id, $$restProps, selectedIndex, hideDropdown, results*/ 2126)
|
|
1487
1486
|
? get_spread_update(search_spread_levels, [
|
|
1488
1487
|
dirty[0] & /*id*/ 4 && { id: /*id*/ ctx[2] },
|
|
1489
1488
|
search_spread_levels[1],
|
|
1490
|
-
dirty[0] & /*$$restProps*/
|
|
1489
|
+
dirty[0] & /*$$restProps*/ 2048 && get_spread_object(/*$$restProps*/ ctx[11]),
|
|
1491
1490
|
search_spread_levels[3],
|
|
1492
1491
|
dirty[0] & /*id*/ 4 && {
|
|
1493
1492
|
"aria-controls": "" + (/*id*/ ctx[2] + "-listbox")
|
|
@@ -1495,17 +1494,17 @@ function create_fragment(ctx) {
|
|
|
1495
1494
|
dirty[0] & /*id*/ 4 && {
|
|
1496
1495
|
"aria-labelledby": "" + (/*id*/ ctx[2] + "-label")
|
|
1497
1496
|
},
|
|
1498
|
-
dirty[0] & /*selectedIndex, hideDropdown, results, id*/
|
|
1499
|
-
"aria-activedescendant": /*selectedIndex*/ ctx[6] >= 0 && !/*hideDropdown*/ ctx[
|
|
1497
|
+
dirty[0] & /*selectedIndex, hideDropdown, results, id*/ 78 && {
|
|
1498
|
+
"aria-activedescendant": /*selectedIndex*/ ctx[6] >= 0 && !/*hideDropdown*/ ctx[3] && /*results*/ ctx[1].length > 0
|
|
1500
1499
|
? `${/*id*/ ctx[2]}-result-${/*selectedIndex*/ ctx[6]}`
|
|
1501
1500
|
: null
|
|
1502
1501
|
}
|
|
1503
1502
|
])
|
|
1504
1503
|
: {};
|
|
1505
1504
|
|
|
1506
|
-
if (!updating_ref && dirty[0] & /*searchRef*/
|
|
1505
|
+
if (!updating_ref && dirty[0] & /*searchRef*/ 32) {
|
|
1507
1506
|
updating_ref = true;
|
|
1508
|
-
search_changes.ref = /*searchRef*/ ctx[
|
|
1507
|
+
search_changes.ref = /*searchRef*/ ctx[5];
|
|
1509
1508
|
add_flush_callback(() => updating_ref = false);
|
|
1510
1509
|
}
|
|
1511
1510
|
|
|
@@ -1517,11 +1516,11 @@ function create_fragment(ctx) {
|
|
|
1517
1516
|
|
|
1518
1517
|
search.$set(search_changes);
|
|
1519
1518
|
|
|
1520
|
-
if (
|
|
1519
|
+
if (/*showResults*/ ctx[7]) {
|
|
1521
1520
|
if (if_block0) {
|
|
1522
1521
|
if_block0.p(ctx, dirty);
|
|
1523
1522
|
|
|
1524
|
-
if (dirty[0] & /*
|
|
1523
|
+
if (dirty[0] & /*showResults*/ 128) {
|
|
1525
1524
|
transition_in(if_block0, 1);
|
|
1526
1525
|
}
|
|
1527
1526
|
} else {
|
|
@@ -1540,11 +1539,11 @@ function create_fragment(ctx) {
|
|
|
1540
1539
|
check_outros();
|
|
1541
1540
|
}
|
|
1542
1541
|
|
|
1543
|
-
if (/*$$slots*/ ctx[
|
|
1542
|
+
if (/*$$slots*/ ctx[10]["no-results"] && !/*hideDropdown*/ ctx[3] && /*value*/ ctx[0].length > 0 && /*results*/ ctx[1].length === 0) {
|
|
1544
1543
|
if (if_block1) {
|
|
1545
1544
|
if_block1.p(ctx, dirty);
|
|
1546
1545
|
|
|
1547
|
-
if (dirty[0] & /*$$slots, hideDropdown, value, results*/
|
|
1546
|
+
if (dirty[0] & /*$$slots, hideDropdown, value, results*/ 1035) {
|
|
1548
1547
|
transition_in(if_block1, 1);
|
|
1549
1548
|
}
|
|
1550
1549
|
} else {
|
|
@@ -1575,8 +1574,8 @@ function create_fragment(ctx) {
|
|
|
1575
1574
|
attr(div, "aria-owns", div_aria_owns_value);
|
|
1576
1575
|
}
|
|
1577
1576
|
|
|
1578
|
-
if (!current || dirty[0] & /*
|
|
1579
|
-
attr(div, "aria-expanded",
|
|
1577
|
+
if (!current || dirty[0] & /*showResults*/ 128) {
|
|
1578
|
+
attr(div, "aria-expanded", /*showResults*/ ctx[7]);
|
|
1580
1579
|
}
|
|
1581
1580
|
|
|
1582
1581
|
if (!current || dirty[0] & /*id*/ 4 && div_id_value !== (div_id_value = "" + (/*id*/ ctx[2] + "-typeahead"))) {
|
|
@@ -1605,7 +1604,7 @@ function create_fragment(ctx) {
|
|
|
1605
1604
|
destroy_component(search);
|
|
1606
1605
|
if (if_block0) if_block0.d();
|
|
1607
1606
|
if (if_block1) if_block1.d();
|
|
1608
|
-
/*div_binding*/ ctx[
|
|
1607
|
+
/*div_binding*/ ctx[38](null);
|
|
1609
1608
|
mounted = false;
|
|
1610
1609
|
dispose();
|
|
1611
1610
|
}
|
|
@@ -1615,6 +1614,7 @@ function create_fragment(ctx) {
|
|
|
1615
1614
|
function instance($$self, $$props, $$invalidate) {
|
|
1616
1615
|
let options;
|
|
1617
1616
|
let resultsId;
|
|
1617
|
+
let showResults;
|
|
1618
1618
|
|
|
1619
1619
|
const omit_props_names = [
|
|
1620
1620
|
"id","value","data","extract","disable","filter","autoselect","inputAfterSelect","results","focusAfterSelect","limit"
|
|
@@ -1647,7 +1647,7 @@ function instance($$self, $$props, $$invalidate) {
|
|
|
1647
1647
|
}
|
|
1648
1648
|
|
|
1649
1649
|
if (prevResults !== resultsId && !$$slots["no-results"]) {
|
|
1650
|
-
$$invalidate(
|
|
1650
|
+
$$invalidate(3, hideDropdown = results.length === 0);
|
|
1651
1651
|
}
|
|
1652
1652
|
|
|
1653
1653
|
prevResults = resultsId;
|
|
@@ -1671,7 +1671,7 @@ function instance($$self, $$props, $$invalidate) {
|
|
|
1671
1671
|
|
|
1672
1672
|
await tick();
|
|
1673
1673
|
if (focusAfterSelect) searchRef.focus();
|
|
1674
|
-
$$invalidate(
|
|
1674
|
+
$$invalidate(3, hideDropdown = true);
|
|
1675
1675
|
}
|
|
1676
1676
|
|
|
1677
1677
|
/** @type {(direction: -1 | 1) => void} */
|
|
@@ -1698,13 +1698,13 @@ function instance($$self, $$props, $$invalidate) {
|
|
|
1698
1698
|
|
|
1699
1699
|
const click_handler = ({ target }) => {
|
|
1700
1700
|
if (!hideDropdown && comboboxRef && !comboboxRef.contains(target)) {
|
|
1701
|
-
$$invalidate(
|
|
1701
|
+
$$invalidate(3, hideDropdown = true);
|
|
1702
1702
|
}
|
|
1703
1703
|
};
|
|
1704
1704
|
|
|
1705
1705
|
function search_ref_binding(value) {
|
|
1706
1706
|
searchRef = value;
|
|
1707
|
-
$$invalidate(
|
|
1707
|
+
$$invalidate(5, searchRef);
|
|
1708
1708
|
}
|
|
1709
1709
|
|
|
1710
1710
|
function search_value_binding(value$1) {
|
|
@@ -1729,7 +1729,7 @@ function instance($$self, $$props, $$invalidate) {
|
|
|
1729
1729
|
}
|
|
1730
1730
|
|
|
1731
1731
|
const focus_handler_1 = () => {
|
|
1732
|
-
$$invalidate(
|
|
1732
|
+
$$invalidate(3, hideDropdown = false);
|
|
1733
1733
|
};
|
|
1734
1734
|
|
|
1735
1735
|
function clear_handler(event) {
|
|
@@ -1737,7 +1737,7 @@ function instance($$self, $$props, $$invalidate) {
|
|
|
1737
1737
|
}
|
|
1738
1738
|
|
|
1739
1739
|
const clear_handler_1 = () => {
|
|
1740
|
-
$$invalidate(
|
|
1740
|
+
$$invalidate(3, hideDropdown = false);
|
|
1741
1741
|
};
|
|
1742
1742
|
|
|
1743
1743
|
function blur_handler(event) {
|
|
@@ -1767,72 +1767,76 @@ function instance($$self, $$props, $$invalidate) {
|
|
|
1767
1767
|
e.preventDefault();
|
|
1768
1768
|
$$invalidate(0, value = "");
|
|
1769
1769
|
searchRef.focus();
|
|
1770
|
-
$$invalidate(
|
|
1770
|
+
$$invalidate(3, hideDropdown = true);
|
|
1771
1771
|
break;
|
|
1772
1772
|
}
|
|
1773
1773
|
};
|
|
1774
1774
|
|
|
1775
|
-
const click_handler_1 = (result,
|
|
1776
|
-
if (
|
|
1777
|
-
|
|
1778
|
-
|
|
1779
|
-
}
|
|
1775
|
+
const click_handler_1 = (result, index) => {
|
|
1776
|
+
if (result.disabled) return;
|
|
1777
|
+
$$invalidate(6, selectedIndex = index);
|
|
1778
|
+
select();
|
|
1780
1779
|
};
|
|
1781
1780
|
|
|
1782
|
-
const mouseenter_handler = (result,
|
|
1781
|
+
const mouseenter_handler = (result, index) => {
|
|
1783
1782
|
if (result.disabled) return;
|
|
1784
|
-
$$invalidate(6, selectedIndex =
|
|
1783
|
+
$$invalidate(6, selectedIndex = index);
|
|
1785
1784
|
};
|
|
1786
1785
|
|
|
1787
1786
|
function div_binding($$value) {
|
|
1788
1787
|
binding_callbacks[$$value ? 'unshift' : 'push'](() => {
|
|
1789
1788
|
comboboxRef = $$value;
|
|
1790
|
-
$$invalidate(
|
|
1789
|
+
$$invalidate(4, comboboxRef);
|
|
1791
1790
|
});
|
|
1792
1791
|
}
|
|
1793
1792
|
|
|
1794
1793
|
$$self.$$set = $$new_props => {
|
|
1795
1794
|
$$props = assign(assign({}, $$props), exclude_internal_props($$new_props));
|
|
1796
|
-
$$invalidate(
|
|
1795
|
+
$$invalidate(11, $$restProps = compute_rest_props($$props, omit_props_names));
|
|
1797
1796
|
if ('id' in $$new_props) $$invalidate(2, id = $$new_props.id);
|
|
1798
1797
|
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(
|
|
1798
|
+
if ('data' in $$new_props) $$invalidate(12, data = $$new_props.data);
|
|
1799
|
+
if ('extract' in $$new_props) $$invalidate(13, extract = $$new_props.extract);
|
|
1800
|
+
if ('disable' in $$new_props) $$invalidate(14, disable = $$new_props.disable);
|
|
1801
|
+
if ('filter' in $$new_props) $$invalidate(15, filter = $$new_props.filter);
|
|
1802
|
+
if ('autoselect' in $$new_props) $$invalidate(16, autoselect = $$new_props.autoselect);
|
|
1803
|
+
if ('inputAfterSelect' in $$new_props) $$invalidate(17, inputAfterSelect = $$new_props.inputAfterSelect);
|
|
1805
1804
|
if ('results' in $$new_props) $$invalidate(1, results = $$new_props.results);
|
|
1806
|
-
if ('focusAfterSelect' in $$new_props) $$invalidate(
|
|
1807
|
-
if ('limit' in $$new_props) $$invalidate(
|
|
1808
|
-
if ('$$scope' in $$new_props) $$invalidate(
|
|
1805
|
+
if ('focusAfterSelect' in $$new_props) $$invalidate(18, focusAfterSelect = $$new_props.focusAfterSelect);
|
|
1806
|
+
if ('limit' in $$new_props) $$invalidate(19, limit = $$new_props.limit);
|
|
1807
|
+
if ('$$scope' in $$new_props) $$invalidate(21, $$scope = $$new_props.$$scope);
|
|
1809
1808
|
};
|
|
1810
1809
|
|
|
1811
1810
|
$$self.$$.update = () => {
|
|
1812
|
-
if ($$self.$$.dirty[0] & /*extract*/
|
|
1813
|
-
$$invalidate(
|
|
1811
|
+
if ($$self.$$.dirty[0] & /*extract*/ 8192) {
|
|
1812
|
+
$$invalidate(20, options = { pre: "<mark>", post: "</mark>", extract });
|
|
1814
1813
|
}
|
|
1815
1814
|
|
|
1816
|
-
if ($$self.$$.dirty[0] & /*value, data, options, limit, filter, disable*/
|
|
1815
|
+
if ($$self.$$.dirty[0] & /*value, data, options, limit, filter, disable*/ 1626113) {
|
|
1817
1816
|
$$invalidate(1, results = fuzzy.filter(value, data, options).filter(({ score }) => score > 0).slice(0, limit).filter(result => !filter(result.original)).map(result => ({
|
|
1818
1817
|
...result,
|
|
1819
1818
|
disabled: disable(result.original)
|
|
1820
1819
|
})));
|
|
1821
1820
|
}
|
|
1822
1821
|
|
|
1823
|
-
if ($$self.$$.dirty[0] & /*results, extract*/
|
|
1822
|
+
if ($$self.$$.dirty[0] & /*results, extract*/ 8194) {
|
|
1824
1823
|
resultsId = results.map(result => extract(result.original)).join("");
|
|
1825
1824
|
}
|
|
1825
|
+
|
|
1826
|
+
if ($$self.$$.dirty[0] & /*hideDropdown, results*/ 10) {
|
|
1827
|
+
$$invalidate(7, showResults = !hideDropdown && results.length > 0);
|
|
1828
|
+
}
|
|
1826
1829
|
};
|
|
1827
1830
|
|
|
1828
1831
|
return [
|
|
1829
1832
|
value,
|
|
1830
1833
|
results,
|
|
1831
1834
|
id,
|
|
1835
|
+
hideDropdown,
|
|
1832
1836
|
comboboxRef,
|
|
1833
1837
|
searchRef,
|
|
1834
|
-
hideDropdown,
|
|
1835
1838
|
selectedIndex,
|
|
1839
|
+
showResults,
|
|
1836
1840
|
select,
|
|
1837
1841
|
change,
|
|
1838
1842
|
$$slots,
|
|
@@ -1880,15 +1884,15 @@ class Typeahead extends SvelteComponent {
|
|
|
1880
1884
|
{
|
|
1881
1885
|
id: 2,
|
|
1882
1886
|
value: 0,
|
|
1883
|
-
data:
|
|
1884
|
-
extract:
|
|
1885
|
-
disable:
|
|
1886
|
-
filter:
|
|
1887
|
-
autoselect:
|
|
1888
|
-
inputAfterSelect:
|
|
1887
|
+
data: 12,
|
|
1888
|
+
extract: 13,
|
|
1889
|
+
disable: 14,
|
|
1890
|
+
filter: 15,
|
|
1891
|
+
autoselect: 16,
|
|
1892
|
+
inputAfterSelect: 17,
|
|
1889
1893
|
results: 1,
|
|
1890
|
-
focusAfterSelect:
|
|
1891
|
-
limit:
|
|
1894
|
+
focusAfterSelect: 18,
|
|
1895
|
+
limit: 19
|
|
1892
1896
|
},
|
|
1893
1897
|
add_css,
|
|
1894
1898
|
[-1, -1]
|
package/package.json
CHANGED
package/src/Typeahead.svelte
CHANGED
|
@@ -92,7 +92,9 @@
|
|
|
92
92
|
/** @type {(direction: -1 | 1) => void} */
|
|
93
93
|
function change(direction) {
|
|
94
94
|
let index =
|
|
95
|
-
direction === 1 && selectedIndex === results.length - 1
|
|
95
|
+
direction === 1 && selectedIndex === results.length - 1
|
|
96
|
+
? 0
|
|
97
|
+
: selectedIndex + direction;
|
|
96
98
|
if (index < 0) index = results.length - 1;
|
|
97
99
|
|
|
98
100
|
let disabled = results[index].disabled;
|
|
@@ -118,6 +120,7 @@
|
|
|
118
120
|
.filter((result) => !filter(result.original))
|
|
119
121
|
.map((result) => ({ ...result, disabled: disable(result.original) }));
|
|
120
122
|
$: resultsId = results.map((result) => extract(result.original)).join("");
|
|
123
|
+
$: showResults = !hideDropdown && results.length > 0;
|
|
121
124
|
</script>
|
|
122
125
|
|
|
123
126
|
<svelte:window
|
|
@@ -135,7 +138,7 @@
|
|
|
135
138
|
aria-haspopup="listbox"
|
|
136
139
|
aria-owns="{id}-listbox"
|
|
137
140
|
class:dropdown={results.length > 0}
|
|
138
|
-
aria-expanded={
|
|
141
|
+
aria-expanded={showResults}
|
|
139
142
|
id="{id}-typeahead"
|
|
140
143
|
>
|
|
141
144
|
<Search
|
|
@@ -195,26 +198,25 @@
|
|
|
195
198
|
aria-labelledby="{id}-label"
|
|
196
199
|
id="{id}-listbox"
|
|
197
200
|
>
|
|
198
|
-
{#if
|
|
199
|
-
{#each results as result,
|
|
201
|
+
{#if showResults}
|
|
202
|
+
{#each results as result, index}
|
|
200
203
|
<li
|
|
201
204
|
role="option"
|
|
202
|
-
id="{id}-result-{
|
|
203
|
-
class:selected={selectedIndex ===
|
|
205
|
+
id="{id}-result-{index}"
|
|
206
|
+
class:selected={selectedIndex === index}
|
|
204
207
|
class:disabled={result.disabled}
|
|
205
|
-
aria-selected={selectedIndex ===
|
|
208
|
+
aria-selected={selectedIndex === index}
|
|
206
209
|
on:click={() => {
|
|
207
|
-
if (
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
}
|
|
210
|
+
if (result.disabled) return;
|
|
211
|
+
selectedIndex = index;
|
|
212
|
+
select();
|
|
211
213
|
}}
|
|
212
214
|
on:mouseenter={() => {
|
|
213
215
|
if (result.disabled) return;
|
|
214
|
-
selectedIndex =
|
|
216
|
+
selectedIndex = index;
|
|
215
217
|
}}
|
|
216
218
|
>
|
|
217
|
-
<slot {result} index
|
|
219
|
+
<slot {result} {index} {value}>
|
|
218
220
|
{@html result.string}
|
|
219
221
|
</slot>
|
|
220
222
|
</li>
|
|
@@ -245,6 +247,10 @@
|
|
|
245
247
|
box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
|
|
246
248
|
}
|
|
247
249
|
|
|
250
|
+
[aria-expanded="true"] ul {
|
|
251
|
+
z-index: 1;
|
|
252
|
+
}
|
|
253
|
+
|
|
248
254
|
li,
|
|
249
255
|
.no-results {
|
|
250
256
|
padding: 0.25rem 1rem;
|