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