svelte-typeahead 4.2.4 → 4.3.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/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.48.0 */
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,7 +1065,7 @@ class Search extends SvelteComponent {
1062
1065
 
1063
1066
  var Search$1 = Search;
1064
1067
 
1065
- /* src/Typeahead.svelte generated by Svelte v3.48.0 */
1068
+ /* src/Typeahead.svelte generated by Svelte v3.49.0 */
1066
1069
 
1067
1070
  function add_css(target) {
1068
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}");
@@ -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[42],
1079
- index: /*index*/ ctx[44]
1081
+ result: /*result*/ ctx[46],
1082
+ index: /*index*/ ctx[48]
1080
1083
  });
1081
1084
 
1082
1085
  function get_each_context(ctx, list, i) {
1083
1086
  const child_ctx = ctx.slice();
1084
- child_ctx[42] = list[i];
1085
- child_ctx[44] = i;
1087
+ child_ctx[46] = list[i];
1088
+ child_ctx[48] = 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[42],
1096
- index: /*index*/ ctx[44],
1098
+ result: /*result*/ ctx[46],
1099
+ index: /*index*/ ctx[48],
1097
1100
  value: /*value*/ ctx[0]
1098
1101
  });
1099
1102
 
1100
- // (201:4) {#if showResults}
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*/ 2097479) {
1135
+ if (dirty[0] & /*id, selectedIndex, results, select, $$scope, value*/ 33555975) {
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
- // (219:41)
1187
+ // (248:41)
1185
1188
  function fallback_block(ctx) {
1186
1189
  let html_tag;
1187
- let raw_value = /*result*/ ctx[42].string + "";
1190
+ let raw_value = /*result*/ ctx[46].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[42].string + "")) html_tag.p(raw_value);
1204
+ if (dirty[0] & /*results*/ 2 && raw_value !== (raw_value = /*result*/ ctx[46].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
- // (202:6) {#each results as result, index}
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[22].default;
1220
- const default_slot = create_slot(default_slot_template, ctx, /*$$scope*/ ctx[21], get_default_slot_context);
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[36](/*result*/ ctx[42], /*index*/ ctx[44]);
1227
+ return /*click_handler_1*/ ctx[39](/*result*/ ctx[46], /*index*/ ctx[48]);
1225
1228
  }
1226
1229
 
1227
1230
  function mouseenter_handler() {
1228
- return /*mouseenter_handler*/ ctx[37](/*result*/ ctx[42], /*index*/ ctx[44]);
1231
+ return /*mouseenter_handler*/ ctx[40](/*result*/ ctx[46], /*index*/ ctx[48]);
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-" + /*index*/ ctx[44]));
1238
- attr(li, "aria-selected", li_aria_selected_value = /*selectedIndex*/ ctx[6] === /*index*/ ctx[44]);
1240
+ attr(li, "id", li_id_value = "" + (/*id*/ ctx[2] + "-result-" + /*index*/ ctx[48]));
1241
+ attr(li, "aria-selected", li_aria_selected_value = /*selectedIndex*/ ctx[9] === /*index*/ ctx[48]);
1239
1242
  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);
1243
+ toggle_class(li, "selected", /*selectedIndex*/ ctx[9] === /*index*/ ctx[48]);
1244
+ toggle_class(li, "disabled", /*result*/ ctx[46].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*/ 2097155)) {
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[21],
1274
+ /*$$scope*/ ctx[25],
1272
1275
  !current
1273
- ? get_all_dirty_from_scope(/*$$scope*/ ctx[21])
1274
- : get_slot_changes(default_slot_template, /*$$scope*/ ctx[21], dirty, get_default_slot_changes),
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-" + /*index*/ ctx[44]))) {
1287
+ if (!current || dirty[0] & /*id*/ 4 && li_id_value !== (li_id_value = "" + (/*id*/ ctx[2] + "-result-" + /*index*/ ctx[48]))) {
1285
1288
  attr(li, "id", li_id_value);
1286
1289
  }
1287
1290
 
1288
- if (!current || dirty[0] & /*selectedIndex*/ 64 && li_aria_selected_value !== (li_aria_selected_value = /*selectedIndex*/ ctx[6] === /*index*/ ctx[44])) {
1291
+ if (!current || dirty[0] & /*selectedIndex*/ 512 && li_aria_selected_value !== (li_aria_selected_value = /*selectedIndex*/ ctx[9] === /*index*/ ctx[48])) {
1289
1292
  attr(li, "aria-selected", li_aria_selected_value);
1290
1293
  }
1291
1294
 
1292
- if (dirty[0] & /*selectedIndex*/ 64) {
1293
- toggle_class(li, "selected", /*selectedIndex*/ ctx[6] === /*index*/ ctx[44]);
1295
+ if (dirty[0] & /*selectedIndex*/ 512) {
1296
+ toggle_class(li, "selected", /*selectedIndex*/ ctx[9] === /*index*/ ctx[48]);
1294
1297
  }
1295
1298
 
1296
1299
  if (dirty[0] & /*results*/ 2) {
1297
- toggle_class(li, "disabled", /*result*/ ctx[42].disabled);
1300
+ toggle_class(li, "disabled", /*result*/ ctx[46].disabled);
1298
1301
  }
1299
1302
  },
1300
1303
  i(local) {
@@ -1315,12 +1318,12 @@ function create_each_block(ctx) {
1315
1318
  };
1316
1319
  }
1317
1320
 
1318
- // (225:4) {#if $$slots["no-results"] && !hideDropdown && value.length > 0 && results.length === 0}
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[22]["no-results"];
1323
- const no_results_slot = create_slot(no_results_slot_template, ctx, /*$$scope*/ ctx[21], get_no_results_slot_context);
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() {
@@ -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*/ 2097155)) {
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[21],
1351
+ /*$$scope*/ ctx[25],
1349
1352
  !current
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),
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
  }
@@ -1389,7 +1392,7 @@ function create_fragment(ctx) {
1389
1392
  const search_spread_levels = [
1390
1393
  { id: /*id*/ ctx[2] },
1391
1394
  { removeFormAriaAttributes: true },
1392
- /*$$restProps*/ ctx[11],
1395
+ /*$$restProps*/ ctx[15],
1393
1396
  { "aria-autocomplete": "list" },
1394
1397
  {
1395
1398
  "aria-controls": "" + (/*id*/ ctx[2] + "-listbox")
@@ -1398,18 +1401,18 @@ function create_fragment(ctx) {
1398
1401
  "aria-labelledby": "" + (/*id*/ ctx[2] + "-label")
1399
1402
  },
1400
1403
  {
1401
- "aria-activedescendant": /*selectedIndex*/ ctx[6] >= 0 && !/*hideDropdown*/ ctx[3] && /*results*/ ctx[1].length > 0
1402
- ? `${/*id*/ ctx[2]}-result-${/*selectedIndex*/ ctx[6]}`
1404
+ "aria-activedescendant": /*selectedIndex*/ ctx[9] >= 0 && !/*hideDropdown*/ ctx[4] && /*results*/ ctx[1].length > 0
1405
+ ? `${/*id*/ ctx[2]}-result-${/*selectedIndex*/ ctx[9]}`
1403
1406
  : null
1404
1407
  }
1405
1408
  ];
1406
1409
 
1407
1410
  function search_ref_binding(value) {
1408
- /*search_ref_binding*/ ctx[24](value);
1411
+ /*search_ref_binding*/ ctx[28](value);
1409
1412
  }
1410
1413
 
1411
1414
  function search_value_binding(value) {
1412
- /*search_value_binding*/ ctx[25](value);
1415
+ /*search_value_binding*/ ctx[29](value);
1413
1416
  }
1414
1417
 
1415
1418
  let search_props = {};
@@ -1418,8 +1421,8 @@ function create_fragment(ctx) {
1418
1421
  search_props = assign(search_props, search_spread_levels[i]);
1419
1422
  }
1420
1423
 
1421
- if (/*searchRef*/ ctx[5] !== void 0) {
1422
- search_props.ref = /*searchRef*/ ctx[5];
1424
+ if (/*searchRef*/ ctx[8] !== void 0) {
1425
+ search_props.ref = /*searchRef*/ ctx[8];
1423
1426
  }
1424
1427
 
1425
1428
  if (/*value*/ ctx[0] !== void 0) {
@@ -1429,18 +1432,18 @@ function create_fragment(ctx) {
1429
1432
  search = new Search$1({ props: search_props });
1430
1433
  binding_callbacks.push(() => bind(search, 'ref', search_ref_binding));
1431
1434
  binding_callbacks.push(() => bind(search, 'value', search_value_binding));
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);
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[12]);
1442
+ search.$on("blur", /*blur_handler*/ ctx[36]);
1443
+ search.$on("keydown", /*keydown_handler*/ ctx[37]);
1444
+ search.$on("keydown", /*keydown_handler_1*/ ctx[38]);
1445
+ let if_block0 = /*showResults*/ ctx[6] && create_if_block_1(ctx);
1446
+ let if_block1 = /*$$slots*/ ctx[14]["no-results"] && !/*hideDropdown*/ ctx[4] && /*value*/ ctx[0].length > 0 && /*results*/ ctx[1].length === 0 && create_if_block(ctx);
1444
1447
 
1445
1448
  return {
1446
1449
  c() {
@@ -1460,7 +1463,7 @@ function create_fragment(ctx) {
1460
1463
  attr(div, "role", "combobox");
1461
1464
  attr(div, "aria-haspopup", "listbox");
1462
1465
  attr(div, "aria-owns", div_aria_owns_value = "" + (/*id*/ ctx[2] + "-listbox"));
1463
- attr(div, "aria-expanded", /*showResults*/ ctx[7]);
1466
+ attr(div, "aria-expanded", /*showResults*/ ctx[6]);
1464
1467
  attr(div, "id", div_id_value = "" + (/*id*/ ctx[2] + "-typeahead"));
1465
1468
  attr(div, "class", "svelte-9wywte");
1466
1469
  toggle_class(div, "dropdown", /*results*/ ctx[1].length > 0);
@@ -1473,20 +1476,20 @@ function create_fragment(ctx) {
1473
1476
  if (if_block0) if_block0.m(ul, null);
1474
1477
  append(ul, t1);
1475
1478
  if (if_block1) if_block1.m(ul, null);
1476
- /*div_binding*/ ctx[38](div);
1479
+ /*div_binding*/ ctx[41](div);
1477
1480
  current = true;
1478
1481
 
1479
1482
  if (!mounted) {
1480
- dispose = listen(window, "click", /*click_handler*/ ctx[23]);
1483
+ dispose = listen(window, "click", /*click_handler*/ ctx[27]);
1481
1484
  mounted = true;
1482
1485
  }
1483
1486
  },
1484
1487
  p(ctx, dirty) {
1485
- const search_changes = (dirty[0] & /*id, $$restProps, selectedIndex, hideDropdown, results*/ 2126)
1488
+ const search_changes = (dirty[0] & /*id, $$restProps, selectedIndex, hideDropdown, results*/ 33302)
1486
1489
  ? get_spread_update(search_spread_levels, [
1487
1490
  dirty[0] & /*id*/ 4 && { id: /*id*/ ctx[2] },
1488
1491
  search_spread_levels[1],
1489
- dirty[0] & /*$$restProps*/ 2048 && get_spread_object(/*$$restProps*/ ctx[11]),
1492
+ dirty[0] & /*$$restProps*/ 32768 && get_spread_object(/*$$restProps*/ ctx[15]),
1490
1493
  search_spread_levels[3],
1491
1494
  dirty[0] & /*id*/ 4 && {
1492
1495
  "aria-controls": "" + (/*id*/ ctx[2] + "-listbox")
@@ -1494,17 +1497,17 @@ function create_fragment(ctx) {
1494
1497
  dirty[0] & /*id*/ 4 && {
1495
1498
  "aria-labelledby": "" + (/*id*/ ctx[2] + "-label")
1496
1499
  },
1497
- dirty[0] & /*selectedIndex, hideDropdown, results, id*/ 78 && {
1498
- "aria-activedescendant": /*selectedIndex*/ ctx[6] >= 0 && !/*hideDropdown*/ ctx[3] && /*results*/ ctx[1].length > 0
1499
- ? `${/*id*/ ctx[2]}-result-${/*selectedIndex*/ ctx[6]}`
1500
+ dirty[0] & /*selectedIndex, hideDropdown, results, id*/ 534 && {
1501
+ "aria-activedescendant": /*selectedIndex*/ ctx[9] >= 0 && !/*hideDropdown*/ ctx[4] && /*results*/ ctx[1].length > 0
1502
+ ? `${/*id*/ ctx[2]}-result-${/*selectedIndex*/ ctx[9]}`
1500
1503
  : null
1501
1504
  }
1502
1505
  ])
1503
1506
  : {};
1504
1507
 
1505
- if (!updating_ref && dirty[0] & /*searchRef*/ 32) {
1508
+ if (!updating_ref && dirty[0] & /*searchRef*/ 256) {
1506
1509
  updating_ref = true;
1507
- search_changes.ref = /*searchRef*/ ctx[5];
1510
+ search_changes.ref = /*searchRef*/ ctx[8];
1508
1511
  add_flush_callback(() => updating_ref = false);
1509
1512
  }
1510
1513
 
@@ -1516,11 +1519,11 @@ function create_fragment(ctx) {
1516
1519
 
1517
1520
  search.$set(search_changes);
1518
1521
 
1519
- if (/*showResults*/ ctx[7]) {
1522
+ if (/*showResults*/ ctx[6]) {
1520
1523
  if (if_block0) {
1521
1524
  if_block0.p(ctx, dirty);
1522
1525
 
1523
- if (dirty[0] & /*showResults*/ 128) {
1526
+ if (dirty[0] & /*showResults*/ 64) {
1524
1527
  transition_in(if_block0, 1);
1525
1528
  }
1526
1529
  } else {
@@ -1539,11 +1542,11 @@ function create_fragment(ctx) {
1539
1542
  check_outros();
1540
1543
  }
1541
1544
 
1542
- if (/*$$slots*/ ctx[10]["no-results"] && !/*hideDropdown*/ ctx[3] && /*value*/ ctx[0].length > 0 && /*results*/ ctx[1].length === 0) {
1545
+ if (/*$$slots*/ ctx[14]["no-results"] && !/*hideDropdown*/ ctx[4] && /*value*/ ctx[0].length > 0 && /*results*/ ctx[1].length === 0) {
1543
1546
  if (if_block1) {
1544
1547
  if_block1.p(ctx, dirty);
1545
1548
 
1546
- if (dirty[0] & /*$$slots, hideDropdown, value, results*/ 1035) {
1549
+ if (dirty[0] & /*$$slots, hideDropdown, value, results*/ 16403) {
1547
1550
  transition_in(if_block1, 1);
1548
1551
  }
1549
1552
  } else {
@@ -1574,8 +1577,8 @@ function create_fragment(ctx) {
1574
1577
  attr(div, "aria-owns", div_aria_owns_value);
1575
1578
  }
1576
1579
 
1577
- if (!current || dirty[0] & /*showResults*/ 128) {
1578
- attr(div, "aria-expanded", /*showResults*/ ctx[7]);
1580
+ if (!current || dirty[0] & /*showResults*/ 64) {
1581
+ attr(div, "aria-expanded", /*showResults*/ ctx[6]);
1579
1582
  }
1580
1583
 
1581
1584
  if (!current || dirty[0] & /*id*/ 4 && div_id_value !== (div_id_value = "" + (/*id*/ ctx[2] + "-typeahead"))) {
@@ -1604,7 +1607,7 @@ function create_fragment(ctx) {
1604
1607
  destroy_component(search);
1605
1608
  if (if_block0) if_block0.d();
1606
1609
  if (if_block1) if_block1.d();
1607
- /*div_binding*/ ctx[38](null);
1610
+ /*div_binding*/ ctx[41](null);
1608
1611
  mounted = false;
1609
1612
  dispose();
1610
1613
  }
@@ -1617,7 +1620,7 @@ function instance($$self, $$props, $$invalidate) {
1617
1620
  let showResults;
1618
1621
 
1619
1622
  const omit_props_names = [
1620
- "id","value","data","extract","disable","filter","autoselect","inputAfterSelect","results","focusAfterSelect","limit"
1623
+ "id","value","data","extract","disable","filter","autoselect","inputAfterSelect","results","focusAfterSelect","showDropdownOnFocus","limit"
1621
1624
  ];
1622
1625
 
1623
1626
  let $$restProps = compute_rest_props($$props, omit_props_names);
@@ -1633,6 +1636,7 @@ function instance($$self, $$props, $$invalidate) {
1633
1636
  let { inputAfterSelect = "update" } = $$props;
1634
1637
  let { results = [] } = $$props;
1635
1638
  let { focusAfterSelect = false } = $$props;
1639
+ let { showDropdownOnFocus = false } = $$props;
1636
1640
  let { limit = Infinity } = $$props;
1637
1641
  const dispatch = createEventDispatcher();
1638
1642
  let comboboxRef = null;
@@ -1640,14 +1644,15 @@ function instance($$self, $$props, $$invalidate) {
1640
1644
  let hideDropdown = false;
1641
1645
  let selectedIndex = -1;
1642
1646
  let prevResults = "";
1647
+ let isFocused = false;
1643
1648
 
1644
1649
  afterUpdate(() => {
1645
1650
  if (prevResults !== resultsId && autoselect) {
1646
- $$invalidate(6, selectedIndex = 0);
1651
+ $$invalidate(9, selectedIndex = getNextNonDisabledIndex());
1647
1652
  }
1648
1653
 
1649
1654
  if (prevResults !== resultsId && !$$slots["no-results"]) {
1650
- $$invalidate(3, hideDropdown = results.length === 0);
1655
+ $$invalidate(4, hideDropdown = results.length === 0);
1651
1656
  }
1652
1657
 
1653
1658
  prevResults = resultsId;
@@ -1671,7 +1676,25 @@ function instance($$self, $$props, $$invalidate) {
1671
1676
 
1672
1677
  await tick();
1673
1678
  if (focusAfterSelect) searchRef.focus();
1674
- $$invalidate(3, hideDropdown = true);
1679
+ close();
1680
+ }
1681
+
1682
+ /** @type {() => number} */
1683
+ function getNextNonDisabledIndex() {
1684
+ let index = 0;
1685
+ let disabled = results[index]?.disabled ?? false;
1686
+
1687
+ while (disabled) {
1688
+ if (index === results.length) {
1689
+ index = 0;
1690
+ } else {
1691
+ index += 1;
1692
+ }
1693
+
1694
+ disabled = results[index]?.disabled ?? false;
1695
+ }
1696
+
1697
+ return index;
1675
1698
  }
1676
1699
 
1677
1700
  /** @type {(direction: -1 | 1) => void} */
@@ -1693,18 +1716,21 @@ function instance($$self, $$props, $$invalidate) {
1693
1716
  disabled = results[index].disabled;
1694
1717
  }
1695
1718
 
1696
- $$invalidate(6, selectedIndex = index);
1719
+ $$invalidate(9, selectedIndex = index);
1697
1720
  }
1698
1721
 
1722
+ const open = () => $$invalidate(4, hideDropdown = false);
1723
+ const close = () => $$invalidate(4, hideDropdown = true);
1724
+
1699
1725
  const click_handler = ({ target }) => {
1700
- if (!hideDropdown && comboboxRef && !comboboxRef.contains(target)) {
1701
- $$invalidate(3, hideDropdown = true);
1726
+ if (!hideDropdown && !comboboxRef?.contains(target)) {
1727
+ close();
1702
1728
  }
1703
1729
  };
1704
1730
 
1705
1731
  function search_ref_binding(value) {
1706
1732
  searchRef = value;
1707
- $$invalidate(5, searchRef);
1733
+ $$invalidate(8, searchRef);
1708
1734
  }
1709
1735
 
1710
1736
  function search_value_binding(value$1) {
@@ -1729,17 +1755,18 @@ function instance($$self, $$props, $$invalidate) {
1729
1755
  }
1730
1756
 
1731
1757
  const focus_handler_1 = () => {
1732
- $$invalidate(3, hideDropdown = false);
1758
+ open();
1759
+
1760
+ if (showDropdownOnFocus) {
1761
+ $$invalidate(6, showResults = true);
1762
+ $$invalidate(5, isFocused = true);
1763
+ }
1733
1764
  };
1734
1765
 
1735
1766
  function clear_handler(event) {
1736
1767
  bubble.call(this, $$self, event);
1737
1768
  }
1738
1769
 
1739
- const clear_handler_1 = () => {
1740
- $$invalidate(3, hideDropdown = false);
1741
- };
1742
-
1743
1770
  function blur_handler(event) {
1744
1771
  bubble.call(this, $$self, event);
1745
1772
  }
@@ -1766,65 +1793,72 @@ function instance($$self, $$props, $$invalidate) {
1766
1793
  case "Escape":
1767
1794
  e.preventDefault();
1768
1795
  $$invalidate(0, value = "");
1769
- searchRef.focus();
1770
- $$invalidate(3, hideDropdown = true);
1796
+ searchRef?.focus();
1797
+ close();
1771
1798
  break;
1772
1799
  }
1773
1800
  };
1774
1801
 
1775
1802
  const click_handler_1 = (result, index) => {
1776
1803
  if (result.disabled) return;
1777
- $$invalidate(6, selectedIndex = index);
1804
+ $$invalidate(9, selectedIndex = index);
1778
1805
  select();
1779
1806
  };
1780
1807
 
1781
1808
  const mouseenter_handler = (result, index) => {
1782
1809
  if (result.disabled) return;
1783
- $$invalidate(6, selectedIndex = index);
1810
+ $$invalidate(9, selectedIndex = index);
1784
1811
  };
1785
1812
 
1786
1813
  function div_binding($$value) {
1787
1814
  binding_callbacks[$$value ? 'unshift' : 'push'](() => {
1788
1815
  comboboxRef = $$value;
1789
- $$invalidate(4, comboboxRef);
1816
+ $$invalidate(7, comboboxRef);
1790
1817
  });
1791
1818
  }
1792
1819
 
1793
1820
  $$self.$$set = $$new_props => {
1794
1821
  $$props = assign(assign({}, $$props), exclude_internal_props($$new_props));
1795
- $$invalidate(11, $$restProps = compute_rest_props($$props, omit_props_names));
1822
+ $$invalidate(15, $$restProps = compute_rest_props($$props, omit_props_names));
1796
1823
  if ('id' in $$new_props) $$invalidate(2, id = $$new_props.id);
1797
1824
  if ('value' in $$new_props) $$invalidate(0, value = $$new_props.value);
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);
1825
+ if ('data' in $$new_props) $$invalidate(16, data = $$new_props.data);
1826
+ if ('extract' in $$new_props) $$invalidate(17, extract = $$new_props.extract);
1827
+ if ('disable' in $$new_props) $$invalidate(18, disable = $$new_props.disable);
1828
+ if ('filter' in $$new_props) $$invalidate(19, filter = $$new_props.filter);
1829
+ if ('autoselect' in $$new_props) $$invalidate(20, autoselect = $$new_props.autoselect);
1830
+ if ('inputAfterSelect' in $$new_props) $$invalidate(21, inputAfterSelect = $$new_props.inputAfterSelect);
1804
1831
  if ('results' in $$new_props) $$invalidate(1, results = $$new_props.results);
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);
1832
+ if ('focusAfterSelect' in $$new_props) $$invalidate(22, focusAfterSelect = $$new_props.focusAfterSelect);
1833
+ if ('showDropdownOnFocus' in $$new_props) $$invalidate(3, showDropdownOnFocus = $$new_props.showDropdownOnFocus);
1834
+ if ('limit' in $$new_props) $$invalidate(23, limit = $$new_props.limit);
1835
+ if ('$$scope' in $$new_props) $$invalidate(25, $$scope = $$new_props.$$scope);
1808
1836
  };
1809
1837
 
1810
1838
  $$self.$$.update = () => {
1811
- if ($$self.$$.dirty[0] & /*extract*/ 8192) {
1812
- $$invalidate(20, options = { pre: "<mark>", post: "</mark>", extract });
1839
+ if ($$self.$$.dirty[0] & /*extract*/ 131072) {
1840
+ $$invalidate(24, options = { pre: "<mark>", post: "</mark>", extract });
1813
1841
  }
1814
1842
 
1815
- if ($$self.$$.dirty[0] & /*value, data, options, limit, filter, disable*/ 1626113) {
1843
+ if ($$self.$$.dirty[0] & /*value, data, options, limit, filter, disable*/ 26017793) {
1816
1844
  $$invalidate(1, results = fuzzy.filter(value, data, options).filter(({ score }) => score > 0).slice(0, limit).filter(result => !filter(result.original)).map(result => ({
1817
1845
  ...result,
1818
1846
  disabled: disable(result.original)
1819
1847
  })));
1820
1848
  }
1821
1849
 
1822
- if ($$self.$$.dirty[0] & /*results, extract*/ 8194) {
1850
+ if ($$self.$$.dirty[0] & /*results, extract*/ 131074) {
1823
1851
  resultsId = results.map(result => extract(result.original)).join("");
1824
1852
  }
1825
1853
 
1826
- if ($$self.$$.dirty[0] & /*hideDropdown, results*/ 10) {
1827
- $$invalidate(7, showResults = !hideDropdown && results.length > 0);
1854
+ if ($$self.$$.dirty[0] & /*hideDropdown, results*/ 18) {
1855
+ $$invalidate(6, showResults = !hideDropdown && results.length > 0);
1856
+ }
1857
+
1858
+ if ($$self.$$.dirty[0] & /*showDropdownOnFocus, showResults, isFocused*/ 104) {
1859
+ if (showDropdownOnFocus) {
1860
+ $$invalidate(6, showResults = showResults && isFocused);
1861
+ }
1828
1862
  }
1829
1863
  };
1830
1864
 
@@ -1832,13 +1866,17 @@ function instance($$self, $$props, $$invalidate) {
1832
1866
  value,
1833
1867
  results,
1834
1868
  id,
1869
+ showDropdownOnFocus,
1835
1870
  hideDropdown,
1871
+ isFocused,
1872
+ showResults,
1836
1873
  comboboxRef,
1837
1874
  searchRef,
1838
1875
  selectedIndex,
1839
- showResults,
1840
1876
  select,
1841
1877
  change,
1878
+ open,
1879
+ close,
1842
1880
  $$slots,
1843
1881
  $$restProps,
1844
1882
  data,
@@ -1861,7 +1899,6 @@ function instance($$self, $$props, $$invalidate) {
1861
1899
  focus_handler,
1862
1900
  focus_handler_1,
1863
1901
  clear_handler,
1864
- clear_handler_1,
1865
1902
  blur_handler,
1866
1903
  keydown_handler,
1867
1904
  keydown_handler_1,
@@ -1884,15 +1921,16 @@ class Typeahead extends SvelteComponent {
1884
1921
  {
1885
1922
  id: 2,
1886
1923
  value: 0,
1887
- data: 12,
1888
- extract: 13,
1889
- disable: 14,
1890
- filter: 15,
1891
- autoselect: 16,
1892
- inputAfterSelect: 17,
1924
+ data: 16,
1925
+ extract: 17,
1926
+ disable: 18,
1927
+ filter: 19,
1928
+ autoselect: 20,
1929
+ inputAfterSelect: 21,
1893
1930
  results: 1,
1894
- focusAfterSelect: 18,
1895
- limit: 19
1931
+ focusAfterSelect: 22,
1932
+ showDropdownOnFocus: 3,
1933
+ limit: 23
1896
1934
  },
1897
1935
  add_css,
1898
1936
  [-1, -1]
@@ -1900,6 +1938,4 @@ class Typeahead extends SvelteComponent {
1900
1938
  }
1901
1939
  }
1902
1940
 
1903
- var Typeahead$1 = Typeahead;
1904
-
1905
- export { Typeahead$1 as default };
1941
+ export { Typeahead as default };