svelte-typeahead 4.2.2 → 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
@@ -130,6 +130,9 @@ function destroy_each(iterations, detaching) {
130
130
  function element(name) {
131
131
  return document.createElement(name);
132
132
  }
133
+ function svg_element(name) {
134
+ return document.createElementNS('http://www.w3.org/2000/svg', name);
135
+ }
133
136
  function text(data) {
134
137
  return document.createTextNode(data);
135
138
  }
@@ -191,13 +194,15 @@ function set_input_value(input, value) {
191
194
  function toggle_class(element, name, toggle) {
192
195
  element.classList[toggle ? 'add' : 'remove'](name);
193
196
  }
194
- function custom_event(type, detail, bubbles = false) {
197
+ function custom_event(type, detail, { bubbles = false, cancelable = false } = {}) {
195
198
  const e = document.createEvent('CustomEvent');
196
- e.initCustomEvent(type, bubbles, false, detail);
199
+ e.initCustomEvent(type, bubbles, cancelable, detail);
197
200
  return e;
198
201
  }
199
202
  class HtmlTag {
200
- constructor() {
203
+ constructor(is_svg = false) {
204
+ this.is_svg = false;
205
+ this.is_svg = is_svg;
201
206
  this.e = this.n = null;
202
207
  }
203
208
  c(html) {
@@ -205,7 +210,10 @@ class HtmlTag {
205
210
  }
206
211
  m(html, target, anchor = null) {
207
212
  if (!this.e) {
208
- this.e = element(target.nodeName);
213
+ if (this.is_svg)
214
+ this.e = svg_element(target.nodeName);
215
+ else
216
+ this.e = element(target.nodeName);
209
217
  this.t = target;
210
218
  this.c(html);
211
219
  }
@@ -247,16 +255,18 @@ function afterUpdate(fn) {
247
255
  }
248
256
  function createEventDispatcher() {
249
257
  const component = get_current_component();
250
- return (type, detail) => {
258
+ return (type, detail, { cancelable = false } = {}) => {
251
259
  const callbacks = component.$$.callbacks[type];
252
260
  if (callbacks) {
253
261
  // TODO are there situations where events could be dispatched
254
262
  // in a server (non-DOM) environment?
255
- const event = custom_event(type, detail);
263
+ const event = custom_event(type, detail, { cancelable });
256
264
  callbacks.slice().forEach(fn => {
257
265
  fn.call(component, event);
258
266
  });
267
+ return !event.defaultPrevented;
259
268
  }
269
+ return true;
260
270
  };
261
271
  }
262
272
  // TODO figure out if we still want to support
@@ -394,6 +404,9 @@ function transition_out(block, local, detach, callback) {
394
404
  });
395
405
  block.o(local);
396
406
  }
407
+ else if (callback) {
408
+ callback();
409
+ }
397
410
  }
398
411
 
399
412
  function get_spread_update(levels, updates) {
@@ -715,7 +728,7 @@ fuzzy.filter = function(pattern, arr, opts) {
715
728
 
716
729
  var fuzzy = fuzzy$1.exports;
717
730
 
718
- /* node_modules/svelte-search/src/Search.svelte generated by Svelte v3.46.4 */
731
+ /* node_modules/svelte-search/src/Search.svelte generated by Svelte v3.49.0 */
719
732
 
720
733
  function add_css$1(target) {
721
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}");
@@ -1052,10 +1065,10 @@ class Search extends SvelteComponent {
1052
1065
 
1053
1066
  var Search$1 = Search;
1054
1067
 
1055
- /* src/Typeahead.svelte generated by Svelte v3.46.4 */
1068
+ /* src/Typeahead.svelte generated by Svelte v3.49.0 */
1056
1069
 
1057
1070
  function add_css(target) {
1058
- 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}");
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}");
1059
1072
  }
1060
1073
 
1061
1074
  const get_no_results_slot_changes = dirty => ({
@@ -1065,14 +1078,14 @@ const get_no_results_slot_changes = dirty => ({
1065
1078
 
1066
1079
  const get_no_results_slot_context = ctx => ({
1067
1080
  value: /*value*/ ctx[0],
1068
- result: /*result*/ ctx[40],
1069
- index: /*i*/ ctx[42]
1081
+ result: /*result*/ ctx[46],
1082
+ index: /*index*/ ctx[48]
1070
1083
  });
1071
1084
 
1072
1085
  function get_each_context(ctx, list, i) {
1073
1086
  const child_ctx = ctx.slice();
1074
- child_ctx[40] = list[i];
1075
- child_ctx[42] = i;
1087
+ child_ctx[46] = list[i];
1088
+ child_ctx[48] = i;
1076
1089
  return child_ctx;
1077
1090
  }
1078
1091
 
@@ -1082,12 +1095,12 @@ const get_default_slot_changes = dirty => ({
1082
1095
  });
1083
1096
 
1084
1097
  const get_default_slot_context = ctx => ({
1085
- result: /*result*/ ctx[40],
1086
- index: /*i*/ ctx[42],
1098
+ result: /*result*/ ctx[46],
1099
+ index: /*index*/ ctx[48],
1087
1100
  value: /*value*/ ctx[0]
1088
1101
  });
1089
1102
 
1090
- // (198:4) {#if !hideDropdown && results.length > 0}
1103
+ // (212:4) {#if showResults}
1091
1104
  function create_if_block_1(ctx) {
1092
1105
  let each_1_anchor;
1093
1106
  let current;
@@ -1119,7 +1132,7 @@ function create_if_block_1(ctx) {
1119
1132
  current = true;
1120
1133
  },
1121
1134
  p(ctx, dirty) {
1122
- if (dirty[0] & /*id, selectedIndex, results, select, $$scope, value*/ 1048775) {
1135
+ if (dirty[0] & /*id, selectedIndex, results, select, $$scope, value*/ 33555207) {
1123
1136
  each_value = /*results*/ ctx[1];
1124
1137
  let i;
1125
1138
 
@@ -1171,15 +1184,15 @@ function create_if_block_1(ctx) {
1171
1184
  };
1172
1185
  }
1173
1186
 
1174
- // (213:43)
1187
+ // (230:41)
1175
1188
  function fallback_block(ctx) {
1176
1189
  let html_tag;
1177
- let raw_value = /*result*/ ctx[40].string + "";
1190
+ let raw_value = /*result*/ ctx[46].string + "";
1178
1191
  let html_anchor;
1179
1192
 
1180
1193
  return {
1181
1194
  c() {
1182
- html_tag = new HtmlTag();
1195
+ html_tag = new HtmlTag(false);
1183
1196
  html_anchor = empty();
1184
1197
  html_tag.a = html_anchor;
1185
1198
  },
@@ -1188,7 +1201,7 @@ function fallback_block(ctx) {
1188
1201
  insert(target, html_anchor, anchor);
1189
1202
  },
1190
1203
  p(ctx, dirty) {
1191
- if (dirty[0] & /*results*/ 2 && raw_value !== (raw_value = /*result*/ ctx[40].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);
1192
1205
  },
1193
1206
  d(detaching) {
1194
1207
  if (detaching) detach(html_anchor);
@@ -1197,7 +1210,7 @@ function fallback_block(ctx) {
1197
1210
  };
1198
1211
  }
1199
1212
 
1200
- // (199:6) {#each results as result, i}
1213
+ // (213:6) {#each results as result, index}
1201
1214
  function create_each_block(ctx) {
1202
1215
  let li;
1203
1216
  let t;
@@ -1206,12 +1219,16 @@ function create_each_block(ctx) {
1206
1219
  let current;
1207
1220
  let mounted;
1208
1221
  let dispose;
1209
- const default_slot_template = /*#slots*/ ctx[21].default;
1210
- const default_slot = create_slot(default_slot_template, ctx, /*$$scope*/ ctx[20], 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);
1211
1224
  const default_slot_or_fallback = default_slot || fallback_block(ctx);
1212
1225
 
1213
1226
  function click_handler_1() {
1214
- return /*click_handler_1*/ ctx[35](/*result*/ ctx[40], /*i*/ ctx[42]);
1227
+ return /*click_handler_1*/ ctx[40](/*result*/ ctx[46], /*index*/ ctx[48]);
1228
+ }
1229
+
1230
+ function mouseenter_handler() {
1231
+ return /*mouseenter_handler*/ ctx[41](/*result*/ ctx[46], /*index*/ ctx[48]);
1215
1232
  }
1216
1233
 
1217
1234
  return {
@@ -1220,11 +1237,11 @@ function create_each_block(ctx) {
1220
1237
  if (default_slot_or_fallback) default_slot_or_fallback.c();
1221
1238
  t = space();
1222
1239
  attr(li, "role", "option");
1223
- attr(li, "id", li_id_value = "" + (/*id*/ ctx[2] + "-result-" + /*i*/ ctx[42]));
1224
- attr(li, "aria-selected", li_aria_selected_value = /*selectedIndex*/ ctx[6] === /*i*/ ctx[42]);
1225
- attr(li, "class", "svelte-j5n77y");
1226
- toggle_class(li, "selected", /*selectedIndex*/ ctx[6] === /*i*/ ctx[42]);
1227
- toggle_class(li, "disabled", /*result*/ ctx[40].disabled);
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]);
1242
+ attr(li, "class", "svelte-9wywte");
1243
+ toggle_class(li, "selected", /*selectedIndex*/ ctx[8] === /*index*/ ctx[48]);
1244
+ toggle_class(li, "disabled", /*result*/ ctx[46].disabled);
1228
1245
  },
1229
1246
  m(target, anchor) {
1230
1247
  insert(target, li, anchor);
@@ -1237,7 +1254,11 @@ function create_each_block(ctx) {
1237
1254
  current = true;
1238
1255
 
1239
1256
  if (!mounted) {
1240
- dispose = listen(li, "click", click_handler_1);
1257
+ dispose = [
1258
+ listen(li, "click", click_handler_1),
1259
+ listen(li, "mouseenter", mouseenter_handler)
1260
+ ];
1261
+
1241
1262
  mounted = true;
1242
1263
  }
1243
1264
  },
@@ -1245,15 +1266,15 @@ function create_each_block(ctx) {
1245
1266
  ctx = new_ctx;
1246
1267
 
1247
1268
  if (default_slot) {
1248
- if (default_slot.p && (!current || dirty[0] & /*$$scope, results, value*/ 1048579)) {
1269
+ if (default_slot.p && (!current || dirty[0] & /*$$scope, results, value*/ 33554435)) {
1249
1270
  update_slot_base(
1250
1271
  default_slot,
1251
1272
  default_slot_template,
1252
1273
  ctx,
1253
- /*$$scope*/ ctx[20],
1274
+ /*$$scope*/ ctx[25],
1254
1275
  !current
1255
- ? get_all_dirty_from_scope(/*$$scope*/ ctx[20])
1256
- : get_slot_changes(default_slot_template, /*$$scope*/ ctx[20], 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),
1257
1278
  get_default_slot_context
1258
1279
  );
1259
1280
  }
@@ -1263,20 +1284,20 @@ function create_each_block(ctx) {
1263
1284
  }
1264
1285
  }
1265
1286
 
1266
- if (!current || dirty[0] & /*id*/ 4 && li_id_value !== (li_id_value = "" + (/*id*/ ctx[2] + "-result-" + /*i*/ ctx[42]))) {
1287
+ if (!current || dirty[0] & /*id*/ 4 && li_id_value !== (li_id_value = "" + (/*id*/ ctx[2] + "-result-" + /*index*/ ctx[48]))) {
1267
1288
  attr(li, "id", li_id_value);
1268
1289
  }
1269
1290
 
1270
- if (!current || dirty[0] & /*selectedIndex*/ 64 && li_aria_selected_value !== (li_aria_selected_value = /*selectedIndex*/ ctx[6] === /*i*/ ctx[42])) {
1291
+ if (!current || dirty[0] & /*selectedIndex*/ 256 && li_aria_selected_value !== (li_aria_selected_value = /*selectedIndex*/ ctx[8] === /*index*/ ctx[48])) {
1271
1292
  attr(li, "aria-selected", li_aria_selected_value);
1272
1293
  }
1273
1294
 
1274
- if (dirty[0] & /*selectedIndex*/ 64) {
1275
- toggle_class(li, "selected", /*selectedIndex*/ ctx[6] === /*i*/ ctx[42]);
1295
+ if (dirty[0] & /*selectedIndex*/ 256) {
1296
+ toggle_class(li, "selected", /*selectedIndex*/ ctx[8] === /*index*/ ctx[48]);
1276
1297
  }
1277
1298
 
1278
1299
  if (dirty[0] & /*results*/ 2) {
1279
- toggle_class(li, "disabled", /*result*/ ctx[40].disabled);
1300
+ toggle_class(li, "disabled", /*result*/ ctx[46].disabled);
1280
1301
  }
1281
1302
  },
1282
1303
  i(local) {
@@ -1292,23 +1313,23 @@ function create_each_block(ctx) {
1292
1313
  if (detaching) detach(li);
1293
1314
  if (default_slot_or_fallback) default_slot_or_fallback.d(detaching);
1294
1315
  mounted = false;
1295
- dispose();
1316
+ run_all(dispose);
1296
1317
  }
1297
1318
  };
1298
1319
  }
1299
1320
 
1300
- // (219: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}
1301
1322
  function create_if_block(ctx) {
1302
1323
  let div;
1303
1324
  let current;
1304
- const no_results_slot_template = /*#slots*/ ctx[21]["no-results"];
1305
- const no_results_slot = create_slot(no_results_slot_template, ctx, /*$$scope*/ ctx[20], 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);
1306
1327
 
1307
1328
  return {
1308
1329
  c() {
1309
1330
  div = element("div");
1310
1331
  if (no_results_slot) no_results_slot.c();
1311
- attr(div, "class", "svelte-j5n77y");
1332
+ attr(div, "class", "svelte-9wywte");
1312
1333
  toggle_class(div, "no-results", true);
1313
1334
  },
1314
1335
  m(target, anchor) {
@@ -1322,15 +1343,15 @@ function create_if_block(ctx) {
1322
1343
  },
1323
1344
  p(ctx, dirty) {
1324
1345
  if (no_results_slot) {
1325
- if (no_results_slot.p && (!current || dirty[0] & /*$$scope, value, results*/ 1048579)) {
1346
+ if (no_results_slot.p && (!current || dirty[0] & /*$$scope, value, results*/ 33554435)) {
1326
1347
  update_slot_base(
1327
1348
  no_results_slot,
1328
1349
  no_results_slot_template,
1329
1350
  ctx,
1330
- /*$$scope*/ ctx[20],
1351
+ /*$$scope*/ ctx[25],
1331
1352
  !current
1332
- ? get_all_dirty_from_scope(/*$$scope*/ ctx[20])
1333
- : get_slot_changes(no_results_slot_template, /*$$scope*/ ctx[20], 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),
1334
1355
  get_no_results_slot_context
1335
1356
  );
1336
1357
  }
@@ -1363,7 +1384,6 @@ function create_fragment(ctx) {
1363
1384
  let ul_aria_labelledby_value;
1364
1385
  let ul_id_value;
1365
1386
  let div_aria_owns_value;
1366
- let div_aria_expanded_value;
1367
1387
  let div_id_value;
1368
1388
  let current;
1369
1389
  let mounted;
@@ -1372,7 +1392,7 @@ function create_fragment(ctx) {
1372
1392
  const search_spread_levels = [
1373
1393
  { id: /*id*/ ctx[2] },
1374
1394
  { removeFormAriaAttributes: true },
1375
- /*$$restProps*/ ctx[10],
1395
+ /*$$restProps*/ ctx[14],
1376
1396
  { "aria-autocomplete": "list" },
1377
1397
  {
1378
1398
  "aria-controls": "" + (/*id*/ ctx[2] + "-listbox")
@@ -1381,18 +1401,18 @@ function create_fragment(ctx) {
1381
1401
  "aria-labelledby": "" + (/*id*/ ctx[2] + "-label")
1382
1402
  },
1383
1403
  {
1384
- "aria-activedescendant": /*selectedIndex*/ ctx[6] >= 0 && !/*hideDropdown*/ ctx[5] && /*results*/ ctx[1].length > 0
1385
- ? `${/*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]}`
1386
1406
  : null
1387
1407
  }
1388
1408
  ];
1389
1409
 
1390
1410
  function search_ref_binding(value) {
1391
- /*search_ref_binding*/ ctx[23](value);
1411
+ /*search_ref_binding*/ ctx[28](value);
1392
1412
  }
1393
1413
 
1394
1414
  function search_value_binding(value) {
1395
- /*search_value_binding*/ ctx[24](value);
1415
+ /*search_value_binding*/ ctx[29](value);
1396
1416
  }
1397
1417
 
1398
1418
  let search_props = {};
@@ -1401,8 +1421,8 @@ function create_fragment(ctx) {
1401
1421
  search_props = assign(search_props, search_spread_levels[i]);
1402
1422
  }
1403
1423
 
1404
- if (/*searchRef*/ ctx[4] !== void 0) {
1405
- search_props.ref = /*searchRef*/ ctx[4];
1424
+ if (/*searchRef*/ ctx[7] !== void 0) {
1425
+ search_props.ref = /*searchRef*/ ctx[7];
1406
1426
  }
1407
1427
 
1408
1428
  if (/*value*/ ctx[0] !== void 0) {
@@ -1412,18 +1432,19 @@ function create_fragment(ctx) {
1412
1432
  search = new Search$1({ props: search_props });
1413
1433
  binding_callbacks.push(() => bind(search, 'ref', search_ref_binding));
1414
1434
  binding_callbacks.push(() => bind(search, 'value', search_value_binding));
1415
- search.$on("type", /*type_handler*/ ctx[25]);
1416
- search.$on("input", /*input_handler*/ ctx[26]);
1417
- search.$on("change", /*change_handler*/ ctx[27]);
1418
- search.$on("focus", /*focus_handler*/ ctx[28]);
1419
- search.$on("focus", /*focus_handler_1*/ ctx[29]);
1420
- search.$on("clear", /*clear_handler*/ ctx[30]);
1421
- search.$on("clear", /*clear_handler_1*/ ctx[31]);
1422
- search.$on("blur", /*blur_handler*/ ctx[32]);
1423
- search.$on("keydown", /*keydown_handler*/ ctx[33]);
1424
- search.$on("keydown", /*keydown_handler_1*/ ctx[34]);
1425
- let if_block0 = !/*hideDropdown*/ ctx[5] && /*results*/ ctx[1].length > 0 && create_if_block_1(ctx);
1426
- 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);
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);
1427
1448
 
1428
1449
  return {
1429
1450
  c() {
@@ -1437,15 +1458,15 @@ function create_fragment(ctx) {
1437
1458
  attr(ul, "role", "listbox");
1438
1459
  attr(ul, "aria-labelledby", ul_aria_labelledby_value = "" + (/*id*/ ctx[2] + "-label"));
1439
1460
  attr(ul, "id", ul_id_value = "" + (/*id*/ ctx[2] + "-listbox"));
1440
- attr(ul, "class", "svelte-j5n77y");
1461
+ attr(ul, "class", "svelte-9wywte");
1441
1462
  toggle_class(ul, "svelte-typeahead-list", true);
1442
1463
  attr(div, "data-svelte-typeahead", "");
1443
1464
  attr(div, "role", "combobox");
1444
1465
  attr(div, "aria-haspopup", "listbox");
1445
1466
  attr(div, "aria-owns", div_aria_owns_value = "" + (/*id*/ ctx[2] + "-listbox"));
1446
- attr(div, "aria-expanded", div_aria_expanded_value = !/*hideDropdown*/ ctx[5] && /*results*/ ctx[1].length > 0);
1467
+ attr(div, "aria-expanded", /*showResults*/ ctx[5]);
1447
1468
  attr(div, "id", div_id_value = "" + (/*id*/ ctx[2] + "-typeahead"));
1448
- attr(div, "class", "svelte-j5n77y");
1469
+ attr(div, "class", "svelte-9wywte");
1449
1470
  toggle_class(div, "dropdown", /*results*/ ctx[1].length > 0);
1450
1471
  },
1451
1472
  m(target, anchor) {
@@ -1456,20 +1477,20 @@ function create_fragment(ctx) {
1456
1477
  if (if_block0) if_block0.m(ul, null);
1457
1478
  append(ul, t1);
1458
1479
  if (if_block1) if_block1.m(ul, null);
1459
- /*div_binding*/ ctx[36](div);
1480
+ /*div_binding*/ ctx[42](div);
1460
1481
  current = true;
1461
1482
 
1462
1483
  if (!mounted) {
1463
- dispose = listen(window, "click", /*click_handler*/ ctx[22]);
1484
+ dispose = listen(window, "click", /*click_handler*/ ctx[27]);
1464
1485
  mounted = true;
1465
1486
  }
1466
1487
  },
1467
1488
  p(ctx, dirty) {
1468
- const search_changes = (dirty[0] & /*id, $$restProps, selectedIndex, hideDropdown, results*/ 1126)
1489
+ const search_changes = (dirty[0] & /*id, $$restProps, selectedIndex, hideDropdown, results*/ 16654)
1469
1490
  ? get_spread_update(search_spread_levels, [
1470
1491
  dirty[0] & /*id*/ 4 && { id: /*id*/ ctx[2] },
1471
1492
  search_spread_levels[1],
1472
- dirty[0] & /*$$restProps*/ 1024 && get_spread_object(/*$$restProps*/ ctx[10]),
1493
+ dirty[0] & /*$$restProps*/ 16384 && get_spread_object(/*$$restProps*/ ctx[14]),
1473
1494
  search_spread_levels[3],
1474
1495
  dirty[0] & /*id*/ 4 && {
1475
1496
  "aria-controls": "" + (/*id*/ ctx[2] + "-listbox")
@@ -1477,17 +1498,17 @@ function create_fragment(ctx) {
1477
1498
  dirty[0] & /*id*/ 4 && {
1478
1499
  "aria-labelledby": "" + (/*id*/ ctx[2] + "-label")
1479
1500
  },
1480
- dirty[0] & /*selectedIndex, hideDropdown, results, id*/ 102 && {
1481
- "aria-activedescendant": /*selectedIndex*/ ctx[6] >= 0 && !/*hideDropdown*/ ctx[5] && /*results*/ ctx[1].length > 0
1482
- ? `${/*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]}`
1483
1504
  : null
1484
1505
  }
1485
1506
  ])
1486
1507
  : {};
1487
1508
 
1488
- if (!updating_ref && dirty[0] & /*searchRef*/ 16) {
1509
+ if (!updating_ref && dirty[0] & /*searchRef*/ 128) {
1489
1510
  updating_ref = true;
1490
- search_changes.ref = /*searchRef*/ ctx[4];
1511
+ search_changes.ref = /*searchRef*/ ctx[7];
1491
1512
  add_flush_callback(() => updating_ref = false);
1492
1513
  }
1493
1514
 
@@ -1499,11 +1520,11 @@ function create_fragment(ctx) {
1499
1520
 
1500
1521
  search.$set(search_changes);
1501
1522
 
1502
- if (!/*hideDropdown*/ ctx[5] && /*results*/ ctx[1].length > 0) {
1523
+ if (/*showResults*/ ctx[5]) {
1503
1524
  if (if_block0) {
1504
1525
  if_block0.p(ctx, dirty);
1505
1526
 
1506
- if (dirty[0] & /*hideDropdown, results*/ 34) {
1527
+ if (dirty[0] & /*showResults*/ 32) {
1507
1528
  transition_in(if_block0, 1);
1508
1529
  }
1509
1530
  } else {
@@ -1522,11 +1543,11 @@ function create_fragment(ctx) {
1522
1543
  check_outros();
1523
1544
  }
1524
1545
 
1525
- if (/*$$slots*/ ctx[9]["no-results"] && !/*hideDropdown*/ ctx[5] && /*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) {
1526
1547
  if (if_block1) {
1527
1548
  if_block1.p(ctx, dirty);
1528
1549
 
1529
- if (dirty[0] & /*$$slots, hideDropdown, value, results*/ 547) {
1550
+ if (dirty[0] & /*$$slots, hideDropdown, value, results*/ 8203) {
1530
1551
  transition_in(if_block1, 1);
1531
1552
  }
1532
1553
  } else {
@@ -1557,8 +1578,8 @@ function create_fragment(ctx) {
1557
1578
  attr(div, "aria-owns", div_aria_owns_value);
1558
1579
  }
1559
1580
 
1560
- if (!current || dirty[0] & /*hideDropdown, results*/ 34 && div_aria_expanded_value !== (div_aria_expanded_value = !/*hideDropdown*/ ctx[5] && /*results*/ ctx[1].length > 0)) {
1561
- attr(div, "aria-expanded", div_aria_expanded_value);
1581
+ if (!current || dirty[0] & /*showResults*/ 32) {
1582
+ attr(div, "aria-expanded", /*showResults*/ ctx[5]);
1562
1583
  }
1563
1584
 
1564
1585
  if (!current || dirty[0] & /*id*/ 4 && div_id_value !== (div_id_value = "" + (/*id*/ ctx[2] + "-typeahead"))) {
@@ -1587,7 +1608,7 @@ function create_fragment(ctx) {
1587
1608
  destroy_component(search);
1588
1609
  if (if_block0) if_block0.d();
1589
1610
  if (if_block1) if_block1.d();
1590
- /*div_binding*/ ctx[36](null);
1611
+ /*div_binding*/ ctx[42](null);
1591
1612
  mounted = false;
1592
1613
  dispose();
1593
1614
  }
@@ -1597,9 +1618,10 @@ function create_fragment(ctx) {
1597
1618
  function instance($$self, $$props, $$invalidate) {
1598
1619
  let options;
1599
1620
  let resultsId;
1621
+ let showResults;
1600
1622
 
1601
1623
  const omit_props_names = [
1602
- "id","value","data","extract","disable","filter","autoselect","inputAfterSelect","results","focusAfterSelect","limit"
1624
+ "id","value","data","extract","disable","filter","autoselect","inputAfterSelect","results","focusAfterSelect","showDropdownOnFocus","limit"
1603
1625
  ];
1604
1626
 
1605
1627
  let $$restProps = compute_rest_props($$props, omit_props_names);
@@ -1615,6 +1637,7 @@ function instance($$self, $$props, $$invalidate) {
1615
1637
  let { inputAfterSelect = "update" } = $$props;
1616
1638
  let { results = [] } = $$props;
1617
1639
  let { focusAfterSelect = false } = $$props;
1640
+ let { showDropdownOnFocus = false } = $$props;
1618
1641
  let { limit = Infinity } = $$props;
1619
1642
  const dispatch = createEventDispatcher();
1620
1643
  let comboboxRef = null;
@@ -1622,14 +1645,15 @@ function instance($$self, $$props, $$invalidate) {
1622
1645
  let hideDropdown = false;
1623
1646
  let selectedIndex = -1;
1624
1647
  let prevResults = "";
1648
+ let isFocused = false;
1625
1649
 
1626
1650
  afterUpdate(() => {
1627
1651
  if (prevResults !== resultsId && autoselect) {
1628
- $$invalidate(6, selectedIndex = 0);
1652
+ $$invalidate(8, selectedIndex = 0);
1629
1653
  }
1630
1654
 
1631
1655
  if (prevResults !== resultsId && !$$slots["no-results"]) {
1632
- $$invalidate(5, hideDropdown = results.length === 0);
1656
+ $$invalidate(3, hideDropdown = results.length === 0);
1633
1657
  }
1634
1658
 
1635
1659
  prevResults = resultsId;
@@ -1653,7 +1677,7 @@ function instance($$self, $$props, $$invalidate) {
1653
1677
 
1654
1678
  await tick();
1655
1679
  if (focusAfterSelect) searchRef.focus();
1656
- $$invalidate(5, hideDropdown = true);
1680
+ close();
1657
1681
  }
1658
1682
 
1659
1683
  /** @type {(direction: -1 | 1) => void} */
@@ -1675,18 +1699,21 @@ function instance($$self, $$props, $$invalidate) {
1675
1699
  disabled = results[index].disabled;
1676
1700
  }
1677
1701
 
1678
- $$invalidate(6, selectedIndex = index);
1702
+ $$invalidate(8, selectedIndex = index);
1679
1703
  }
1680
1704
 
1705
+ const open = () => $$invalidate(3, hideDropdown = false);
1706
+ const close = () => $$invalidate(3, hideDropdown = true);
1707
+
1681
1708
  const click_handler = ({ target }) => {
1682
- if (!hideDropdown && comboboxRef && !comboboxRef.contains(target)) {
1683
- $$invalidate(5, hideDropdown = true);
1709
+ if (!hideDropdown && !comboboxRef?.contains(target)) {
1710
+ close();
1684
1711
  }
1685
1712
  };
1686
1713
 
1687
1714
  function search_ref_binding(value) {
1688
1715
  searchRef = value;
1689
- $$invalidate(4, searchRef);
1716
+ $$invalidate(7, searchRef);
1690
1717
  }
1691
1718
 
1692
1719
  function search_value_binding(value$1) {
@@ -1711,21 +1738,22 @@ function instance($$self, $$props, $$invalidate) {
1711
1738
  }
1712
1739
 
1713
1740
  const focus_handler_1 = () => {
1714
- $$invalidate(5, hideDropdown = false);
1741
+ open();
1742
+ $$invalidate(4, isFocused = true);
1715
1743
  };
1716
1744
 
1717
1745
  function clear_handler(event) {
1718
1746
  bubble.call(this, $$self, event);
1719
1747
  }
1720
1748
 
1721
- const clear_handler_1 = () => {
1722
- $$invalidate(5, hideDropdown = false);
1723
- };
1724
-
1725
1749
  function blur_handler(event) {
1726
1750
  bubble.call(this, $$self, event);
1727
1751
  }
1728
1752
 
1753
+ const blur_handler_1 = () => {
1754
+ $$invalidate(4, isFocused = false);
1755
+ };
1756
+
1729
1757
  function keydown_handler(event) {
1730
1758
  bubble.call(this, $$self, event);
1731
1759
  }
@@ -1748,70 +1776,89 @@ function instance($$self, $$props, $$invalidate) {
1748
1776
  case "Escape":
1749
1777
  e.preventDefault();
1750
1778
  $$invalidate(0, value = "");
1751
- searchRef.focus();
1752
- $$invalidate(5, hideDropdown = true);
1779
+ searchRef?.focus();
1780
+ close();
1753
1781
  break;
1754
1782
  }
1755
1783
  };
1756
1784
 
1757
- const click_handler_1 = (result, i) => {
1758
- if (!result.disabled) {
1759
- $$invalidate(6, selectedIndex = i);
1760
- select();
1761
- }
1785
+ const click_handler_1 = (result, index) => {
1786
+ if (result.disabled) return;
1787
+ $$invalidate(8, selectedIndex = index);
1788
+ select();
1789
+ };
1790
+
1791
+ const mouseenter_handler = (result, index) => {
1792
+ if (result.disabled) return;
1793
+ $$invalidate(8, selectedIndex = index);
1762
1794
  };
1763
1795
 
1764
1796
  function div_binding($$value) {
1765
1797
  binding_callbacks[$$value ? 'unshift' : 'push'](() => {
1766
1798
  comboboxRef = $$value;
1767
- $$invalidate(3, comboboxRef);
1799
+ $$invalidate(6, comboboxRef);
1768
1800
  });
1769
1801
  }
1770
1802
 
1771
1803
  $$self.$$set = $$new_props => {
1772
1804
  $$props = assign(assign({}, $$props), exclude_internal_props($$new_props));
1773
- $$invalidate(10, $$restProps = compute_rest_props($$props, omit_props_names));
1805
+ $$invalidate(14, $$restProps = compute_rest_props($$props, omit_props_names));
1774
1806
  if ('id' in $$new_props) $$invalidate(2, id = $$new_props.id);
1775
1807
  if ('value' in $$new_props) $$invalidate(0, value = $$new_props.value);
1776
- if ('data' in $$new_props) $$invalidate(11, data = $$new_props.data);
1777
- if ('extract' in $$new_props) $$invalidate(12, extract = $$new_props.extract);
1778
- if ('disable' in $$new_props) $$invalidate(13, disable = $$new_props.disable);
1779
- if ('filter' in $$new_props) $$invalidate(14, filter = $$new_props.filter);
1780
- if ('autoselect' in $$new_props) $$invalidate(15, autoselect = $$new_props.autoselect);
1781
- if ('inputAfterSelect' in $$new_props) $$invalidate(16, 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);
1782
1814
  if ('results' in $$new_props) $$invalidate(1, results = $$new_props.results);
1783
- if ('focusAfterSelect' in $$new_props) $$invalidate(17, focusAfterSelect = $$new_props.focusAfterSelect);
1784
- if ('limit' in $$new_props) $$invalidate(18, limit = $$new_props.limit);
1785
- if ('$$scope' in $$new_props) $$invalidate(20, $$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);
1786
1819
  };
1787
1820
 
1788
1821
  $$self.$$.update = () => {
1789
- if ($$self.$$.dirty[0] & /*extract*/ 4096) {
1790
- $$invalidate(19, options = { pre: "<mark>", post: "</mark>", extract });
1822
+ if ($$self.$$.dirty[0] & /*extract*/ 65536) {
1823
+ $$invalidate(24, options = { pre: "<mark>", post: "</mark>", extract });
1791
1824
  }
1792
1825
 
1793
- if ($$self.$$.dirty[0] & /*value, data, options, limit, filter, disable*/ 813057) {
1826
+ if ($$self.$$.dirty[0] & /*value, data, options, limit, filter, disable*/ 25591809) {
1794
1827
  $$invalidate(1, results = fuzzy.filter(value, data, options).filter(({ score }) => score > 0).slice(0, limit).filter(result => !filter(result.original)).map(result => ({
1795
1828
  ...result,
1796
1829
  disabled: disable(result.original)
1797
1830
  })));
1798
1831
  }
1799
1832
 
1800
- if ($$self.$$.dirty[0] & /*results, extract*/ 4098) {
1833
+ if ($$self.$$.dirty[0] & /*results, extract*/ 65538) {
1801
1834
  resultsId = results.map(result => extract(result.original)).join("");
1802
1835
  }
1836
+
1837
+ if ($$self.$$.dirty[0] & /*hideDropdown, results*/ 10) {
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
+ }
1845
+ }
1803
1846
  };
1804
1847
 
1805
1848
  return [
1806
1849
  value,
1807
1850
  results,
1808
1851
  id,
1852
+ hideDropdown,
1853
+ isFocused,
1854
+ showResults,
1809
1855
  comboboxRef,
1810
1856
  searchRef,
1811
- hideDropdown,
1812
1857
  selectedIndex,
1813
1858
  select,
1814
1859
  change,
1860
+ open,
1861
+ close,
1815
1862
  $$slots,
1816
1863
  $$restProps,
1817
1864
  data,
@@ -1821,6 +1868,7 @@ function instance($$self, $$props, $$invalidate) {
1821
1868
  autoselect,
1822
1869
  inputAfterSelect,
1823
1870
  focusAfterSelect,
1871
+ showDropdownOnFocus,
1824
1872
  limit,
1825
1873
  options,
1826
1874
  $$scope,
@@ -1834,11 +1882,12 @@ function instance($$self, $$props, $$invalidate) {
1834
1882
  focus_handler,
1835
1883
  focus_handler_1,
1836
1884
  clear_handler,
1837
- clear_handler_1,
1838
1885
  blur_handler,
1886
+ blur_handler_1,
1839
1887
  keydown_handler,
1840
1888
  keydown_handler_1,
1841
1889
  click_handler_1,
1890
+ mouseenter_handler,
1842
1891
  div_binding
1843
1892
  ];
1844
1893
  }
@@ -1856,15 +1905,16 @@ class Typeahead extends SvelteComponent {
1856
1905
  {
1857
1906
  id: 2,
1858
1907
  value: 0,
1859
- data: 11,
1860
- extract: 12,
1861
- disable: 13,
1862
- filter: 14,
1863
- autoselect: 15,
1864
- inputAfterSelect: 16,
1908
+ data: 15,
1909
+ extract: 16,
1910
+ disable: 17,
1911
+ filter: 18,
1912
+ autoselect: 19,
1913
+ inputAfterSelect: 20,
1865
1914
  results: 1,
1866
- focusAfterSelect: 17,
1867
- limit: 18
1915
+ focusAfterSelect: 21,
1916
+ showDropdownOnFocus: 22,
1917
+ limit: 23
1868
1918
  },
1869
1919
  add_css,
1870
1920
  [-1, -1]