svelte-typeahead 4.2.4 → 4.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/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
+ // (212: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*/ 33555207) {
1133
1136
  each_value = /*results*/ ctx[1];
1134
1137
  let i;
1135
1138
 
@@ -1181,10 +1184,10 @@ function create_if_block_1(ctx) {
1181
1184
  };
1182
1185
  }
1183
1186
 
1184
- // (219:41)
1187
+ // (230: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
+ // (213: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[40](/*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[41](/*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[8] === /*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[8] === /*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*/ 256 && li_aria_selected_value !== (li_aria_selected_value = /*selectedIndex*/ ctx[8] === /*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*/ 256) {
1296
+ toggle_class(li, "selected", /*selectedIndex*/ ctx[8] === /*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
+ // (236: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[14],
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[8] >= 0 && !/*hideDropdown*/ ctx[3] && /*results*/ ctx[1].length > 0
1405
+ ? `${/*id*/ ctx[2]}-result-${/*selectedIndex*/ ctx[8]}`
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[7] !== void 0) {
1425
+ search_props.ref = /*searchRef*/ ctx[7];
1423
1426
  }
1424
1427
 
1425
1428
  if (/*value*/ ctx[0] !== void 0) {
@@ -1429,18 +1432,19 @@ 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[11]);
1442
+ search.$on("blur", /*blur_handler*/ ctx[36]);
1443
+ search.$on("blur", /*blur_handler_1*/ ctx[37]);
1444
+ search.$on("keydown", /*keydown_handler*/ ctx[38]);
1445
+ search.$on("keydown", /*keydown_handler_1*/ ctx[39]);
1446
+ let if_block0 = /*showResults*/ ctx[5] && create_if_block_1(ctx);
1447
+ let if_block1 = /*$$slots*/ ctx[13]["no-results"] && !/*hideDropdown*/ ctx[3] && /*value*/ ctx[0].length > 0 && /*results*/ ctx[1].length === 0 && create_if_block(ctx);
1444
1448
 
1445
1449
  return {
1446
1450
  c() {
@@ -1460,7 +1464,7 @@ function create_fragment(ctx) {
1460
1464
  attr(div, "role", "combobox");
1461
1465
  attr(div, "aria-haspopup", "listbox");
1462
1466
  attr(div, "aria-owns", div_aria_owns_value = "" + (/*id*/ ctx[2] + "-listbox"));
1463
- attr(div, "aria-expanded", /*showResults*/ ctx[7]);
1467
+ attr(div, "aria-expanded", /*showResults*/ ctx[5]);
1464
1468
  attr(div, "id", div_id_value = "" + (/*id*/ ctx[2] + "-typeahead"));
1465
1469
  attr(div, "class", "svelte-9wywte");
1466
1470
  toggle_class(div, "dropdown", /*results*/ ctx[1].length > 0);
@@ -1473,20 +1477,20 @@ function create_fragment(ctx) {
1473
1477
  if (if_block0) if_block0.m(ul, null);
1474
1478
  append(ul, t1);
1475
1479
  if (if_block1) if_block1.m(ul, null);
1476
- /*div_binding*/ ctx[38](div);
1480
+ /*div_binding*/ ctx[42](div);
1477
1481
  current = true;
1478
1482
 
1479
1483
  if (!mounted) {
1480
- dispose = listen(window, "click", /*click_handler*/ ctx[23]);
1484
+ dispose = listen(window, "click", /*click_handler*/ ctx[27]);
1481
1485
  mounted = true;
1482
1486
  }
1483
1487
  },
1484
1488
  p(ctx, dirty) {
1485
- const search_changes = (dirty[0] & /*id, $$restProps, selectedIndex, hideDropdown, results*/ 2126)
1489
+ const search_changes = (dirty[0] & /*id, $$restProps, selectedIndex, hideDropdown, results*/ 16654)
1486
1490
  ? get_spread_update(search_spread_levels, [
1487
1491
  dirty[0] & /*id*/ 4 && { id: /*id*/ ctx[2] },
1488
1492
  search_spread_levels[1],
1489
- dirty[0] & /*$$restProps*/ 2048 && get_spread_object(/*$$restProps*/ ctx[11]),
1493
+ dirty[0] & /*$$restProps*/ 16384 && get_spread_object(/*$$restProps*/ ctx[14]),
1490
1494
  search_spread_levels[3],
1491
1495
  dirty[0] & /*id*/ 4 && {
1492
1496
  "aria-controls": "" + (/*id*/ ctx[2] + "-listbox")
@@ -1494,17 +1498,17 @@ function create_fragment(ctx) {
1494
1498
  dirty[0] & /*id*/ 4 && {
1495
1499
  "aria-labelledby": "" + (/*id*/ ctx[2] + "-label")
1496
1500
  },
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]}`
1501
+ dirty[0] & /*selectedIndex, hideDropdown, results, id*/ 270 && {
1502
+ "aria-activedescendant": /*selectedIndex*/ ctx[8] >= 0 && !/*hideDropdown*/ ctx[3] && /*results*/ ctx[1].length > 0
1503
+ ? `${/*id*/ ctx[2]}-result-${/*selectedIndex*/ ctx[8]}`
1500
1504
  : null
1501
1505
  }
1502
1506
  ])
1503
1507
  : {};
1504
1508
 
1505
- if (!updating_ref && dirty[0] & /*searchRef*/ 32) {
1509
+ if (!updating_ref && dirty[0] & /*searchRef*/ 128) {
1506
1510
  updating_ref = true;
1507
- search_changes.ref = /*searchRef*/ ctx[5];
1511
+ search_changes.ref = /*searchRef*/ ctx[7];
1508
1512
  add_flush_callback(() => updating_ref = false);
1509
1513
  }
1510
1514
 
@@ -1516,11 +1520,11 @@ function create_fragment(ctx) {
1516
1520
 
1517
1521
  search.$set(search_changes);
1518
1522
 
1519
- if (/*showResults*/ ctx[7]) {
1523
+ if (/*showResults*/ ctx[5]) {
1520
1524
  if (if_block0) {
1521
1525
  if_block0.p(ctx, dirty);
1522
1526
 
1523
- if (dirty[0] & /*showResults*/ 128) {
1527
+ if (dirty[0] & /*showResults*/ 32) {
1524
1528
  transition_in(if_block0, 1);
1525
1529
  }
1526
1530
  } else {
@@ -1539,11 +1543,11 @@ function create_fragment(ctx) {
1539
1543
  check_outros();
1540
1544
  }
1541
1545
 
1542
- if (/*$$slots*/ ctx[10]["no-results"] && !/*hideDropdown*/ ctx[3] && /*value*/ ctx[0].length > 0 && /*results*/ ctx[1].length === 0) {
1546
+ if (/*$$slots*/ ctx[13]["no-results"] && !/*hideDropdown*/ ctx[3] && /*value*/ ctx[0].length > 0 && /*results*/ ctx[1].length === 0) {
1543
1547
  if (if_block1) {
1544
1548
  if_block1.p(ctx, dirty);
1545
1549
 
1546
- if (dirty[0] & /*$$slots, hideDropdown, value, results*/ 1035) {
1550
+ if (dirty[0] & /*$$slots, hideDropdown, value, results*/ 8203) {
1547
1551
  transition_in(if_block1, 1);
1548
1552
  }
1549
1553
  } else {
@@ -1574,8 +1578,8 @@ function create_fragment(ctx) {
1574
1578
  attr(div, "aria-owns", div_aria_owns_value);
1575
1579
  }
1576
1580
 
1577
- if (!current || dirty[0] & /*showResults*/ 128) {
1578
- attr(div, "aria-expanded", /*showResults*/ ctx[7]);
1581
+ if (!current || dirty[0] & /*showResults*/ 32) {
1582
+ attr(div, "aria-expanded", /*showResults*/ ctx[5]);
1579
1583
  }
1580
1584
 
1581
1585
  if (!current || dirty[0] & /*id*/ 4 && div_id_value !== (div_id_value = "" + (/*id*/ ctx[2] + "-typeahead"))) {
@@ -1604,7 +1608,7 @@ function create_fragment(ctx) {
1604
1608
  destroy_component(search);
1605
1609
  if (if_block0) if_block0.d();
1606
1610
  if (if_block1) if_block1.d();
1607
- /*div_binding*/ ctx[38](null);
1611
+ /*div_binding*/ ctx[42](null);
1608
1612
  mounted = false;
1609
1613
  dispose();
1610
1614
  }
@@ -1617,7 +1621,7 @@ function instance($$self, $$props, $$invalidate) {
1617
1621
  let showResults;
1618
1622
 
1619
1623
  const omit_props_names = [
1620
- "id","value","data","extract","disable","filter","autoselect","inputAfterSelect","results","focusAfterSelect","limit"
1624
+ "id","value","data","extract","disable","filter","autoselect","inputAfterSelect","results","focusAfterSelect","showDropdownOnFocus","limit"
1621
1625
  ];
1622
1626
 
1623
1627
  let $$restProps = compute_rest_props($$props, omit_props_names);
@@ -1633,6 +1637,7 @@ function instance($$self, $$props, $$invalidate) {
1633
1637
  let { inputAfterSelect = "update" } = $$props;
1634
1638
  let { results = [] } = $$props;
1635
1639
  let { focusAfterSelect = false } = $$props;
1640
+ let { showDropdownOnFocus = false } = $$props;
1636
1641
  let { limit = Infinity } = $$props;
1637
1642
  const dispatch = createEventDispatcher();
1638
1643
  let comboboxRef = null;
@@ -1640,10 +1645,11 @@ function instance($$self, $$props, $$invalidate) {
1640
1645
  let hideDropdown = false;
1641
1646
  let selectedIndex = -1;
1642
1647
  let prevResults = "";
1648
+ let isFocused = false;
1643
1649
 
1644
1650
  afterUpdate(() => {
1645
1651
  if (prevResults !== resultsId && autoselect) {
1646
- $$invalidate(6, selectedIndex = 0);
1652
+ $$invalidate(8, selectedIndex = 0);
1647
1653
  }
1648
1654
 
1649
1655
  if (prevResults !== resultsId && !$$slots["no-results"]) {
@@ -1671,7 +1677,7 @@ function instance($$self, $$props, $$invalidate) {
1671
1677
 
1672
1678
  await tick();
1673
1679
  if (focusAfterSelect) searchRef.focus();
1674
- $$invalidate(3, hideDropdown = true);
1680
+ close();
1675
1681
  }
1676
1682
 
1677
1683
  /** @type {(direction: -1 | 1) => void} */
@@ -1693,18 +1699,21 @@ function instance($$self, $$props, $$invalidate) {
1693
1699
  disabled = results[index].disabled;
1694
1700
  }
1695
1701
 
1696
- $$invalidate(6, selectedIndex = index);
1702
+ $$invalidate(8, selectedIndex = index);
1697
1703
  }
1698
1704
 
1705
+ const open = () => $$invalidate(3, hideDropdown = false);
1706
+ const close = () => $$invalidate(3, hideDropdown = true);
1707
+
1699
1708
  const click_handler = ({ target }) => {
1700
- if (!hideDropdown && comboboxRef && !comboboxRef.contains(target)) {
1701
- $$invalidate(3, hideDropdown = true);
1709
+ if (!hideDropdown && !comboboxRef?.contains(target)) {
1710
+ close();
1702
1711
  }
1703
1712
  };
1704
1713
 
1705
1714
  function search_ref_binding(value) {
1706
1715
  searchRef = value;
1707
- $$invalidate(5, searchRef);
1716
+ $$invalidate(7, searchRef);
1708
1717
  }
1709
1718
 
1710
1719
  function search_value_binding(value$1) {
@@ -1729,21 +1738,22 @@ function instance($$self, $$props, $$invalidate) {
1729
1738
  }
1730
1739
 
1731
1740
  const focus_handler_1 = () => {
1732
- $$invalidate(3, hideDropdown = false);
1741
+ open();
1742
+ $$invalidate(4, isFocused = true);
1733
1743
  };
1734
1744
 
1735
1745
  function clear_handler(event) {
1736
1746
  bubble.call(this, $$self, event);
1737
1747
  }
1738
1748
 
1739
- const clear_handler_1 = () => {
1740
- $$invalidate(3, hideDropdown = false);
1741
- };
1742
-
1743
1749
  function blur_handler(event) {
1744
1750
  bubble.call(this, $$self, event);
1745
1751
  }
1746
1752
 
1753
+ const blur_handler_1 = () => {
1754
+ $$invalidate(4, isFocused = false);
1755
+ };
1756
+
1747
1757
  function keydown_handler(event) {
1748
1758
  bubble.call(this, $$self, event);
1749
1759
  }
@@ -1766,65 +1776,72 @@ function instance($$self, $$props, $$invalidate) {
1766
1776
  case "Escape":
1767
1777
  e.preventDefault();
1768
1778
  $$invalidate(0, value = "");
1769
- searchRef.focus();
1770
- $$invalidate(3, hideDropdown = true);
1779
+ searchRef?.focus();
1780
+ close();
1771
1781
  break;
1772
1782
  }
1773
1783
  };
1774
1784
 
1775
1785
  const click_handler_1 = (result, index) => {
1776
1786
  if (result.disabled) return;
1777
- $$invalidate(6, selectedIndex = index);
1787
+ $$invalidate(8, selectedIndex = index);
1778
1788
  select();
1779
1789
  };
1780
1790
 
1781
1791
  const mouseenter_handler = (result, index) => {
1782
1792
  if (result.disabled) return;
1783
- $$invalidate(6, selectedIndex = index);
1793
+ $$invalidate(8, selectedIndex = index);
1784
1794
  };
1785
1795
 
1786
1796
  function div_binding($$value) {
1787
1797
  binding_callbacks[$$value ? 'unshift' : 'push'](() => {
1788
1798
  comboboxRef = $$value;
1789
- $$invalidate(4, comboboxRef);
1799
+ $$invalidate(6, comboboxRef);
1790
1800
  });
1791
1801
  }
1792
1802
 
1793
1803
  $$self.$$set = $$new_props => {
1794
1804
  $$props = assign(assign({}, $$props), exclude_internal_props($$new_props));
1795
- $$invalidate(11, $$restProps = compute_rest_props($$props, omit_props_names));
1805
+ $$invalidate(14, $$restProps = compute_rest_props($$props, omit_props_names));
1796
1806
  if ('id' in $$new_props) $$invalidate(2, id = $$new_props.id);
1797
1807
  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);
1808
+ if ('data' in $$new_props) $$invalidate(15, data = $$new_props.data);
1809
+ if ('extract' in $$new_props) $$invalidate(16, extract = $$new_props.extract);
1810
+ if ('disable' in $$new_props) $$invalidate(17, disable = $$new_props.disable);
1811
+ if ('filter' in $$new_props) $$invalidate(18, filter = $$new_props.filter);
1812
+ if ('autoselect' in $$new_props) $$invalidate(19, autoselect = $$new_props.autoselect);
1813
+ if ('inputAfterSelect' in $$new_props) $$invalidate(20, inputAfterSelect = $$new_props.inputAfterSelect);
1804
1814
  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);
1815
+ if ('focusAfterSelect' in $$new_props) $$invalidate(21, focusAfterSelect = $$new_props.focusAfterSelect);
1816
+ if ('showDropdownOnFocus' in $$new_props) $$invalidate(22, showDropdownOnFocus = $$new_props.showDropdownOnFocus);
1817
+ if ('limit' in $$new_props) $$invalidate(23, limit = $$new_props.limit);
1818
+ if ('$$scope' in $$new_props) $$invalidate(25, $$scope = $$new_props.$$scope);
1808
1819
  };
1809
1820
 
1810
1821
  $$self.$$.update = () => {
1811
- if ($$self.$$.dirty[0] & /*extract*/ 8192) {
1812
- $$invalidate(20, options = { pre: "<mark>", post: "</mark>", extract });
1822
+ if ($$self.$$.dirty[0] & /*extract*/ 65536) {
1823
+ $$invalidate(24, options = { pre: "<mark>", post: "</mark>", extract });
1813
1824
  }
1814
1825
 
1815
- if ($$self.$$.dirty[0] & /*value, data, options, limit, filter, disable*/ 1626113) {
1826
+ if ($$self.$$.dirty[0] & /*value, data, options, limit, filter, disable*/ 25591809) {
1816
1827
  $$invalidate(1, results = fuzzy.filter(value, data, options).filter(({ score }) => score > 0).slice(0, limit).filter(result => !filter(result.original)).map(result => ({
1817
1828
  ...result,
1818
1829
  disabled: disable(result.original)
1819
1830
  })));
1820
1831
  }
1821
1832
 
1822
- if ($$self.$$.dirty[0] & /*results, extract*/ 8194) {
1833
+ if ($$self.$$.dirty[0] & /*results, extract*/ 65538) {
1823
1834
  resultsId = results.map(result => extract(result.original)).join("");
1824
1835
  }
1825
1836
 
1826
1837
  if ($$self.$$.dirty[0] & /*hideDropdown, results*/ 10) {
1827
- $$invalidate(7, showResults = !hideDropdown && results.length > 0);
1838
+ $$invalidate(5, showResults = !hideDropdown && results.length > 0);
1839
+ }
1840
+
1841
+ if ($$self.$$.dirty[0] & /*showDropdownOnFocus, showResults, isFocused*/ 4194352) {
1842
+ if (showDropdownOnFocus) {
1843
+ $$invalidate(5, showResults = showResults && isFocused);
1844
+ }
1828
1845
  }
1829
1846
  };
1830
1847
 
@@ -1833,12 +1850,15 @@ function instance($$self, $$props, $$invalidate) {
1833
1850
  results,
1834
1851
  id,
1835
1852
  hideDropdown,
1853
+ isFocused,
1854
+ showResults,
1836
1855
  comboboxRef,
1837
1856
  searchRef,
1838
1857
  selectedIndex,
1839
- showResults,
1840
1858
  select,
1841
1859
  change,
1860
+ open,
1861
+ close,
1842
1862
  $$slots,
1843
1863
  $$restProps,
1844
1864
  data,
@@ -1848,6 +1868,7 @@ function instance($$self, $$props, $$invalidate) {
1848
1868
  autoselect,
1849
1869
  inputAfterSelect,
1850
1870
  focusAfterSelect,
1871
+ showDropdownOnFocus,
1851
1872
  limit,
1852
1873
  options,
1853
1874
  $$scope,
@@ -1861,8 +1882,8 @@ function instance($$self, $$props, $$invalidate) {
1861
1882
  focus_handler,
1862
1883
  focus_handler_1,
1863
1884
  clear_handler,
1864
- clear_handler_1,
1865
1885
  blur_handler,
1886
+ blur_handler_1,
1866
1887
  keydown_handler,
1867
1888
  keydown_handler_1,
1868
1889
  click_handler_1,
@@ -1884,15 +1905,16 @@ class Typeahead extends SvelteComponent {
1884
1905
  {
1885
1906
  id: 2,
1886
1907
  value: 0,
1887
- data: 12,
1888
- extract: 13,
1889
- disable: 14,
1890
- filter: 15,
1891
- autoselect: 16,
1892
- inputAfterSelect: 17,
1908
+ data: 15,
1909
+ extract: 16,
1910
+ disable: 17,
1911
+ filter: 18,
1912
+ autoselect: 19,
1913
+ inputAfterSelect: 20,
1893
1914
  results: 1,
1894
- focusAfterSelect: 18,
1895
- limit: 19
1915
+ focusAfterSelect: 21,
1916
+ showDropdownOnFocus: 22,
1917
+ limit: 23
1896
1918
  },
1897
1919
  add_css,
1898
1920
  [-1, -1]
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "svelte-typeahead",
3
- "version": "4.2.4",
3
+ "version": "4.3.0",
4
4
  "license": "MIT",
5
5
  "description": "Accessible, fuzzy search typeahead component",
6
6
  "author": "Eric Liu (https://github.com/metonym)",
@@ -22,7 +22,7 @@
22
22
  },
23
23
  "devDependencies": {
24
24
  "@rollup/plugin-commonjs": "^21.0.2",
25
- "svelte": "^3.48.0",
25
+ "svelte": "^3.49.0",
26
26
  "svelte-check": "^2.8.0",
27
27
  "svelte-readme": "^3.6.3"
28
28
  },