svelte-typeahead 4.2.1 → 4.2.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/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
@@ -292,22 +302,40 @@ function add_render_callback(fn) {
292
302
  function add_flush_callback(fn) {
293
303
  flush_callbacks.push(fn);
294
304
  }
295
- let flushing = false;
305
+ // flush() calls callbacks in this order:
306
+ // 1. All beforeUpdate callbacks, in order: parents before children
307
+ // 2. All bind:this callbacks, in reverse order: children before parents.
308
+ // 3. All afterUpdate callbacks, in order: parents before children. EXCEPT
309
+ // for afterUpdates called during the initial onMount, which are called in
310
+ // reverse order: children before parents.
311
+ // Since callbacks might update component values, which could trigger another
312
+ // call to flush(), the following steps guard against this:
313
+ // 1. During beforeUpdate, any updated components will be added to the
314
+ // dirty_components array and will cause a reentrant call to flush(). Because
315
+ // the flush index is kept outside the function, the reentrant call will pick
316
+ // up where the earlier call left off and go through all dirty components. The
317
+ // current_component value is saved and restored so that the reentrant call will
318
+ // not interfere with the "parent" flush() call.
319
+ // 2. bind:this callbacks cannot trigger new flush() calls.
320
+ // 3. During afterUpdate, any updated components will NOT have their afterUpdate
321
+ // callback called a second time; the seen_callbacks set, outside the flush()
322
+ // function, guarantees this behavior.
296
323
  const seen_callbacks = new Set();
324
+ let flushidx = 0; // Do *not* move this inside the flush() function
297
325
  function flush() {
298
- if (flushing)
299
- return;
300
- flushing = true;
326
+ const saved_component = current_component;
301
327
  do {
302
328
  // first, call beforeUpdate functions
303
329
  // and update components
304
- for (let i = 0; i < dirty_components.length; i += 1) {
305
- const component = dirty_components[i];
330
+ while (flushidx < dirty_components.length) {
331
+ const component = dirty_components[flushidx];
332
+ flushidx++;
306
333
  set_current_component(component);
307
334
  update(component.$$);
308
335
  }
309
336
  set_current_component(null);
310
337
  dirty_components.length = 0;
338
+ flushidx = 0;
311
339
  while (binding_callbacks.length)
312
340
  binding_callbacks.pop()();
313
341
  // then, once components are updated, call
@@ -327,8 +355,8 @@ function flush() {
327
355
  flush_callbacks.pop()();
328
356
  }
329
357
  update_scheduled = false;
330
- flushing = false;
331
358
  seen_callbacks.clear();
359
+ set_current_component(saved_component);
332
360
  }
333
361
  function update($$) {
334
362
  if ($$.fragment !== null) {
@@ -697,7 +725,7 @@ fuzzy.filter = function(pattern, arr, opts) {
697
725
 
698
726
  var fuzzy = fuzzy$1.exports;
699
727
 
700
- /* node_modules/svelte-search/src/Search.svelte generated by Svelte v3.44.0 */
728
+ /* node_modules/svelte-search/src/Search.svelte generated by Svelte v3.48.0 */
701
729
 
702
730
  function add_css$1(target) {
703
731
  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}");
@@ -1034,10 +1062,10 @@ class Search extends SvelteComponent {
1034
1062
 
1035
1063
  var Search$1 = Search;
1036
1064
 
1037
- /* src/Typeahead.svelte generated by Svelte v3.44.0 */
1065
+ /* src/Typeahead.svelte generated by Svelte v3.48.0 */
1038
1066
 
1039
1067
  function add_css(target) {
1040
- 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}");
1068
+ append_styles(target, "svelte-9wywte", "[data-svelte-typeahead].svelte-9wywte.svelte-9wywte{position:relative;background-color:#fff}ul.svelte-9wywte.svelte-9wywte{position:absolute;top:100%;left:0;width:100%;padding:0;list-style:none;background-color:inherit;box-shadow:0 4px 8px rgba(0, 0, 0, 0.1)}[aria-expanded=\"true\"].svelte-9wywte ul.svelte-9wywte{z-index:1}li.svelte-9wywte.svelte-9wywte,.no-results.svelte-9wywte.svelte-9wywte{padding:0.25rem 1rem}li.svelte-9wywte.svelte-9wywte{cursor:pointer}li.svelte-9wywte.svelte-9wywte:not(:last-of-type){border-bottom:1px solid #e0e0e0}li.svelte-9wywte.svelte-9wywte:hover{background-color:#e5e5e5}.selected.svelte-9wywte.svelte-9wywte{background-color:#e5e5e5}.selected.svelte-9wywte.svelte-9wywte:hover{background-color:#cacaca}.disabled.svelte-9wywte.svelte-9wywte{opacity:0.4;cursor:not-allowed}[data-svelte-search] label{margin-bottom:0.25rem;display:inline-flex;font-size:0.875rem}[data-svelte-search] input{width:100%;padding:0.5rem 0.75rem;background:none;font-size:1rem;border:0;border-radius:0;border:1px solid #e5e5e5}[data-svelte-search] input:focus{outline-color:#0f62fe;outline-offset:2px;outline-width:1px}");
1041
1069
  }
1042
1070
 
1043
1071
  const get_no_results_slot_changes = dirty => ({
@@ -1047,14 +1075,14 @@ const get_no_results_slot_changes = dirty => ({
1047
1075
 
1048
1076
  const get_no_results_slot_context = ctx => ({
1049
1077
  value: /*value*/ ctx[0],
1050
- result: /*result*/ ctx[40],
1051
- index: /*i*/ ctx[42]
1078
+ result: /*result*/ ctx[42],
1079
+ index: /*index*/ ctx[44]
1052
1080
  });
1053
1081
 
1054
1082
  function get_each_context(ctx, list, i) {
1055
1083
  const child_ctx = ctx.slice();
1056
- child_ctx[40] = list[i];
1057
- child_ctx[42] = i;
1084
+ child_ctx[42] = list[i];
1085
+ child_ctx[44] = i;
1058
1086
  return child_ctx;
1059
1087
  }
1060
1088
 
@@ -1064,12 +1092,12 @@ const get_default_slot_changes = dirty => ({
1064
1092
  });
1065
1093
 
1066
1094
  const get_default_slot_context = ctx => ({
1067
- result: /*result*/ ctx[40],
1068
- index: /*i*/ ctx[42],
1095
+ result: /*result*/ ctx[42],
1096
+ index: /*index*/ ctx[44],
1069
1097
  value: /*value*/ ctx[0]
1070
1098
  });
1071
1099
 
1072
- // (198:4) {#if !hideDropdown && results.length > 0}
1100
+ // (201:4) {#if showResults}
1073
1101
  function create_if_block_1(ctx) {
1074
1102
  let each_1_anchor;
1075
1103
  let current;
@@ -1101,7 +1129,7 @@ function create_if_block_1(ctx) {
1101
1129
  current = true;
1102
1130
  },
1103
1131
  p(ctx, dirty) {
1104
- if (dirty[0] & /*id, selectedIndex, results, select, $$scope, value*/ 1048775) {
1132
+ if (dirty[0] & /*id, selectedIndex, results, select, $$scope, value*/ 2097479) {
1105
1133
  each_value = /*results*/ ctx[1];
1106
1134
  let i;
1107
1135
 
@@ -1153,15 +1181,15 @@ function create_if_block_1(ctx) {
1153
1181
  };
1154
1182
  }
1155
1183
 
1156
- // (213:43)
1184
+ // (219:41)
1157
1185
  function fallback_block(ctx) {
1158
1186
  let html_tag;
1159
- let raw_value = /*result*/ ctx[40].string + "";
1187
+ let raw_value = /*result*/ ctx[42].string + "";
1160
1188
  let html_anchor;
1161
1189
 
1162
1190
  return {
1163
1191
  c() {
1164
- html_tag = new HtmlTag();
1192
+ html_tag = new HtmlTag(false);
1165
1193
  html_anchor = empty();
1166
1194
  html_tag.a = html_anchor;
1167
1195
  },
@@ -1170,7 +1198,7 @@ function fallback_block(ctx) {
1170
1198
  insert(target, html_anchor, anchor);
1171
1199
  },
1172
1200
  p(ctx, dirty) {
1173
- if (dirty[0] & /*results*/ 2 && raw_value !== (raw_value = /*result*/ ctx[40].string + "")) html_tag.p(raw_value);
1201
+ if (dirty[0] & /*results*/ 2 && raw_value !== (raw_value = /*result*/ ctx[42].string + "")) html_tag.p(raw_value);
1174
1202
  },
1175
1203
  d(detaching) {
1176
1204
  if (detaching) detach(html_anchor);
@@ -1179,7 +1207,7 @@ function fallback_block(ctx) {
1179
1207
  };
1180
1208
  }
1181
1209
 
1182
- // (199:6) {#each results as result, i}
1210
+ // (202:6) {#each results as result, index}
1183
1211
  function create_each_block(ctx) {
1184
1212
  let li;
1185
1213
  let t;
@@ -1188,12 +1216,16 @@ function create_each_block(ctx) {
1188
1216
  let current;
1189
1217
  let mounted;
1190
1218
  let dispose;
1191
- const default_slot_template = /*#slots*/ ctx[21].default;
1192
- const default_slot = create_slot(default_slot_template, ctx, /*$$scope*/ ctx[20], get_default_slot_context);
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);
1193
1221
  const default_slot_or_fallback = default_slot || fallback_block(ctx);
1194
1222
 
1195
1223
  function click_handler_1() {
1196
- return /*click_handler_1*/ ctx[35](/*result*/ ctx[40], /*i*/ ctx[42]);
1224
+ return /*click_handler_1*/ ctx[36](/*result*/ ctx[42], /*index*/ ctx[44]);
1225
+ }
1226
+
1227
+ function mouseenter_handler() {
1228
+ return /*mouseenter_handler*/ ctx[37](/*result*/ ctx[42], /*index*/ ctx[44]);
1197
1229
  }
1198
1230
 
1199
1231
  return {
@@ -1202,11 +1234,11 @@ function create_each_block(ctx) {
1202
1234
  if (default_slot_or_fallback) default_slot_or_fallback.c();
1203
1235
  t = space();
1204
1236
  attr(li, "role", "option");
1205
- attr(li, "id", li_id_value = "" + (/*id*/ ctx[2] + "-result-" + /*i*/ ctx[42]));
1206
- attr(li, "aria-selected", li_aria_selected_value = /*selectedIndex*/ ctx[6] === /*i*/ ctx[42]);
1207
- attr(li, "class", "svelte-j5n77y");
1208
- toggle_class(li, "selected", /*selectedIndex*/ ctx[6] === /*i*/ ctx[42]);
1209
- toggle_class(li, "disabled", /*result*/ ctx[40].disabled);
1237
+ attr(li, "id", li_id_value = "" + (/*id*/ ctx[2] + "-result-" + /*index*/ ctx[44]));
1238
+ attr(li, "aria-selected", li_aria_selected_value = /*selectedIndex*/ ctx[6] === /*index*/ ctx[44]);
1239
+ attr(li, "class", "svelte-9wywte");
1240
+ toggle_class(li, "selected", /*selectedIndex*/ ctx[6] === /*index*/ ctx[44]);
1241
+ toggle_class(li, "disabled", /*result*/ ctx[42].disabled);
1210
1242
  },
1211
1243
  m(target, anchor) {
1212
1244
  insert(target, li, anchor);
@@ -1219,7 +1251,11 @@ function create_each_block(ctx) {
1219
1251
  current = true;
1220
1252
 
1221
1253
  if (!mounted) {
1222
- dispose = listen(li, "click", click_handler_1);
1254
+ dispose = [
1255
+ listen(li, "click", click_handler_1),
1256
+ listen(li, "mouseenter", mouseenter_handler)
1257
+ ];
1258
+
1223
1259
  mounted = true;
1224
1260
  }
1225
1261
  },
@@ -1227,15 +1263,15 @@ function create_each_block(ctx) {
1227
1263
  ctx = new_ctx;
1228
1264
 
1229
1265
  if (default_slot) {
1230
- if (default_slot.p && (!current || dirty[0] & /*$$scope, results, value*/ 1048579)) {
1266
+ if (default_slot.p && (!current || dirty[0] & /*$$scope, results, value*/ 2097155)) {
1231
1267
  update_slot_base(
1232
1268
  default_slot,
1233
1269
  default_slot_template,
1234
1270
  ctx,
1235
- /*$$scope*/ ctx[20],
1271
+ /*$$scope*/ ctx[21],
1236
1272
  !current
1237
- ? get_all_dirty_from_scope(/*$$scope*/ ctx[20])
1238
- : get_slot_changes(default_slot_template, /*$$scope*/ ctx[20], dirty, get_default_slot_changes),
1273
+ ? get_all_dirty_from_scope(/*$$scope*/ ctx[21])
1274
+ : get_slot_changes(default_slot_template, /*$$scope*/ ctx[21], dirty, get_default_slot_changes),
1239
1275
  get_default_slot_context
1240
1276
  );
1241
1277
  }
@@ -1245,20 +1281,20 @@ function create_each_block(ctx) {
1245
1281
  }
1246
1282
  }
1247
1283
 
1248
- if (!current || dirty[0] & /*id*/ 4 && li_id_value !== (li_id_value = "" + (/*id*/ ctx[2] + "-result-" + /*i*/ ctx[42]))) {
1284
+ if (!current || dirty[0] & /*id*/ 4 && li_id_value !== (li_id_value = "" + (/*id*/ ctx[2] + "-result-" + /*index*/ ctx[44]))) {
1249
1285
  attr(li, "id", li_id_value);
1250
1286
  }
1251
1287
 
1252
- if (!current || dirty[0] & /*selectedIndex*/ 64 && li_aria_selected_value !== (li_aria_selected_value = /*selectedIndex*/ ctx[6] === /*i*/ ctx[42])) {
1288
+ if (!current || dirty[0] & /*selectedIndex*/ 64 && li_aria_selected_value !== (li_aria_selected_value = /*selectedIndex*/ ctx[6] === /*index*/ ctx[44])) {
1253
1289
  attr(li, "aria-selected", li_aria_selected_value);
1254
1290
  }
1255
1291
 
1256
1292
  if (dirty[0] & /*selectedIndex*/ 64) {
1257
- toggle_class(li, "selected", /*selectedIndex*/ ctx[6] === /*i*/ ctx[42]);
1293
+ toggle_class(li, "selected", /*selectedIndex*/ ctx[6] === /*index*/ ctx[44]);
1258
1294
  }
1259
1295
 
1260
1296
  if (dirty[0] & /*results*/ 2) {
1261
- toggle_class(li, "disabled", /*result*/ ctx[40].disabled);
1297
+ toggle_class(li, "disabled", /*result*/ ctx[42].disabled);
1262
1298
  }
1263
1299
  },
1264
1300
  i(local) {
@@ -1274,23 +1310,23 @@ function create_each_block(ctx) {
1274
1310
  if (detaching) detach(li);
1275
1311
  if (default_slot_or_fallback) default_slot_or_fallback.d(detaching);
1276
1312
  mounted = false;
1277
- dispose();
1313
+ run_all(dispose);
1278
1314
  }
1279
1315
  };
1280
1316
  }
1281
1317
 
1282
- // (219:4) {#if $$slots["no-results"] && !hideDropdown && value.length > 0 && results.length === 0}
1318
+ // (225:4) {#if $$slots["no-results"] && !hideDropdown && value.length > 0 && results.length === 0}
1283
1319
  function create_if_block(ctx) {
1284
1320
  let div;
1285
1321
  let current;
1286
- const no_results_slot_template = /*#slots*/ ctx[21]["no-results"];
1287
- const no_results_slot = create_slot(no_results_slot_template, ctx, /*$$scope*/ ctx[20], get_no_results_slot_context);
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);
1288
1324
 
1289
1325
  return {
1290
1326
  c() {
1291
1327
  div = element("div");
1292
1328
  if (no_results_slot) no_results_slot.c();
1293
- attr(div, "class", "svelte-j5n77y");
1329
+ attr(div, "class", "svelte-9wywte");
1294
1330
  toggle_class(div, "no-results", true);
1295
1331
  },
1296
1332
  m(target, anchor) {
@@ -1304,15 +1340,15 @@ function create_if_block(ctx) {
1304
1340
  },
1305
1341
  p(ctx, dirty) {
1306
1342
  if (no_results_slot) {
1307
- if (no_results_slot.p && (!current || dirty[0] & /*$$scope, value, results*/ 1048579)) {
1343
+ if (no_results_slot.p && (!current || dirty[0] & /*$$scope, value, results*/ 2097155)) {
1308
1344
  update_slot_base(
1309
1345
  no_results_slot,
1310
1346
  no_results_slot_template,
1311
1347
  ctx,
1312
- /*$$scope*/ ctx[20],
1348
+ /*$$scope*/ ctx[21],
1313
1349
  !current
1314
- ? get_all_dirty_from_scope(/*$$scope*/ ctx[20])
1315
- : get_slot_changes(no_results_slot_template, /*$$scope*/ ctx[20], dirty, get_no_results_slot_changes),
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),
1316
1352
  get_no_results_slot_context
1317
1353
  );
1318
1354
  }
@@ -1345,7 +1381,6 @@ function create_fragment(ctx) {
1345
1381
  let ul_aria_labelledby_value;
1346
1382
  let ul_id_value;
1347
1383
  let div_aria_owns_value;
1348
- let div_aria_expanded_value;
1349
1384
  let div_id_value;
1350
1385
  let current;
1351
1386
  let mounted;
@@ -1354,7 +1389,7 @@ function create_fragment(ctx) {
1354
1389
  const search_spread_levels = [
1355
1390
  { id: /*id*/ ctx[2] },
1356
1391
  { removeFormAriaAttributes: true },
1357
- /*$$restProps*/ ctx[10],
1392
+ /*$$restProps*/ ctx[11],
1358
1393
  { "aria-autocomplete": "list" },
1359
1394
  {
1360
1395
  "aria-controls": "" + (/*id*/ ctx[2] + "-listbox")
@@ -1363,18 +1398,18 @@ function create_fragment(ctx) {
1363
1398
  "aria-labelledby": "" + (/*id*/ ctx[2] + "-label")
1364
1399
  },
1365
1400
  {
1366
- "aria-activedescendant": /*selectedIndex*/ ctx[6] >= 0 && !/*hideDropdown*/ ctx[5] && /*results*/ ctx[1].length > 0
1401
+ "aria-activedescendant": /*selectedIndex*/ ctx[6] >= 0 && !/*hideDropdown*/ ctx[3] && /*results*/ ctx[1].length > 0
1367
1402
  ? `${/*id*/ ctx[2]}-result-${/*selectedIndex*/ ctx[6]}`
1368
1403
  : null
1369
1404
  }
1370
1405
  ];
1371
1406
 
1372
1407
  function search_ref_binding(value) {
1373
- /*search_ref_binding*/ ctx[23](value);
1408
+ /*search_ref_binding*/ ctx[24](value);
1374
1409
  }
1375
1410
 
1376
1411
  function search_value_binding(value) {
1377
- /*search_value_binding*/ ctx[24](value);
1412
+ /*search_value_binding*/ ctx[25](value);
1378
1413
  }
1379
1414
 
1380
1415
  let search_props = {};
@@ -1383,8 +1418,8 @@ function create_fragment(ctx) {
1383
1418
  search_props = assign(search_props, search_spread_levels[i]);
1384
1419
  }
1385
1420
 
1386
- if (/*searchRef*/ ctx[4] !== void 0) {
1387
- search_props.ref = /*searchRef*/ ctx[4];
1421
+ if (/*searchRef*/ ctx[5] !== void 0) {
1422
+ search_props.ref = /*searchRef*/ ctx[5];
1388
1423
  }
1389
1424
 
1390
1425
  if (/*value*/ ctx[0] !== void 0) {
@@ -1394,18 +1429,18 @@ function create_fragment(ctx) {
1394
1429
  search = new Search$1({ props: search_props });
1395
1430
  binding_callbacks.push(() => bind(search, 'ref', search_ref_binding));
1396
1431
  binding_callbacks.push(() => bind(search, 'value', search_value_binding));
1397
- search.$on("type", /*type_handler*/ ctx[25]);
1398
- search.$on("input", /*input_handler*/ ctx[26]);
1399
- search.$on("change", /*change_handler*/ ctx[27]);
1400
- search.$on("focus", /*focus_handler*/ ctx[28]);
1401
- search.$on("focus", /*focus_handler_1*/ ctx[29]);
1402
- search.$on("clear", /*clear_handler*/ ctx[30]);
1403
- search.$on("clear", /*clear_handler_1*/ ctx[31]);
1404
- search.$on("blur", /*blur_handler*/ ctx[32]);
1405
- search.$on("keydown", /*keydown_handler*/ ctx[33]);
1406
- search.$on("keydown", /*keydown_handler_1*/ ctx[34]);
1407
- let if_block0 = !/*hideDropdown*/ ctx[5] && /*results*/ ctx[1].length > 0 && create_if_block_1(ctx);
1408
- 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);
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);
1409
1444
 
1410
1445
  return {
1411
1446
  c() {
@@ -1419,15 +1454,15 @@ function create_fragment(ctx) {
1419
1454
  attr(ul, "role", "listbox");
1420
1455
  attr(ul, "aria-labelledby", ul_aria_labelledby_value = "" + (/*id*/ ctx[2] + "-label"));
1421
1456
  attr(ul, "id", ul_id_value = "" + (/*id*/ ctx[2] + "-listbox"));
1422
- attr(ul, "class", "svelte-j5n77y");
1457
+ attr(ul, "class", "svelte-9wywte");
1423
1458
  toggle_class(ul, "svelte-typeahead-list", true);
1424
1459
  attr(div, "data-svelte-typeahead", "");
1425
1460
  attr(div, "role", "combobox");
1426
1461
  attr(div, "aria-haspopup", "listbox");
1427
1462
  attr(div, "aria-owns", div_aria_owns_value = "" + (/*id*/ ctx[2] + "-listbox"));
1428
- attr(div, "aria-expanded", div_aria_expanded_value = !/*hideDropdown*/ ctx[5] && /*results*/ ctx[1].length > 0);
1463
+ attr(div, "aria-expanded", /*showResults*/ ctx[7]);
1429
1464
  attr(div, "id", div_id_value = "" + (/*id*/ ctx[2] + "-typeahead"));
1430
- attr(div, "class", "svelte-j5n77y");
1465
+ attr(div, "class", "svelte-9wywte");
1431
1466
  toggle_class(div, "dropdown", /*results*/ ctx[1].length > 0);
1432
1467
  },
1433
1468
  m(target, anchor) {
@@ -1438,20 +1473,20 @@ function create_fragment(ctx) {
1438
1473
  if (if_block0) if_block0.m(ul, null);
1439
1474
  append(ul, t1);
1440
1475
  if (if_block1) if_block1.m(ul, null);
1441
- /*div_binding*/ ctx[36](div);
1476
+ /*div_binding*/ ctx[38](div);
1442
1477
  current = true;
1443
1478
 
1444
1479
  if (!mounted) {
1445
- dispose = listen(window, "click", /*click_handler*/ ctx[22]);
1480
+ dispose = listen(window, "click", /*click_handler*/ ctx[23]);
1446
1481
  mounted = true;
1447
1482
  }
1448
1483
  },
1449
1484
  p(ctx, dirty) {
1450
- const search_changes = (dirty[0] & /*id, $$restProps, selectedIndex, hideDropdown, results*/ 1126)
1485
+ const search_changes = (dirty[0] & /*id, $$restProps, selectedIndex, hideDropdown, results*/ 2126)
1451
1486
  ? get_spread_update(search_spread_levels, [
1452
1487
  dirty[0] & /*id*/ 4 && { id: /*id*/ ctx[2] },
1453
1488
  search_spread_levels[1],
1454
- dirty[0] & /*$$restProps*/ 1024 && get_spread_object(/*$$restProps*/ ctx[10]),
1489
+ dirty[0] & /*$$restProps*/ 2048 && get_spread_object(/*$$restProps*/ ctx[11]),
1455
1490
  search_spread_levels[3],
1456
1491
  dirty[0] & /*id*/ 4 && {
1457
1492
  "aria-controls": "" + (/*id*/ ctx[2] + "-listbox")
@@ -1459,17 +1494,17 @@ function create_fragment(ctx) {
1459
1494
  dirty[0] & /*id*/ 4 && {
1460
1495
  "aria-labelledby": "" + (/*id*/ ctx[2] + "-label")
1461
1496
  },
1462
- dirty[0] & /*selectedIndex, hideDropdown, results, id*/ 102 && {
1463
- "aria-activedescendant": /*selectedIndex*/ ctx[6] >= 0 && !/*hideDropdown*/ ctx[5] && /*results*/ ctx[1].length > 0
1497
+ dirty[0] & /*selectedIndex, hideDropdown, results, id*/ 78 && {
1498
+ "aria-activedescendant": /*selectedIndex*/ ctx[6] >= 0 && !/*hideDropdown*/ ctx[3] && /*results*/ ctx[1].length > 0
1464
1499
  ? `${/*id*/ ctx[2]}-result-${/*selectedIndex*/ ctx[6]}`
1465
1500
  : null
1466
1501
  }
1467
1502
  ])
1468
1503
  : {};
1469
1504
 
1470
- if (!updating_ref && dirty[0] & /*searchRef*/ 16) {
1505
+ if (!updating_ref && dirty[0] & /*searchRef*/ 32) {
1471
1506
  updating_ref = true;
1472
- search_changes.ref = /*searchRef*/ ctx[4];
1507
+ search_changes.ref = /*searchRef*/ ctx[5];
1473
1508
  add_flush_callback(() => updating_ref = false);
1474
1509
  }
1475
1510
 
@@ -1481,11 +1516,11 @@ function create_fragment(ctx) {
1481
1516
 
1482
1517
  search.$set(search_changes);
1483
1518
 
1484
- if (!/*hideDropdown*/ ctx[5] && /*results*/ ctx[1].length > 0) {
1519
+ if (/*showResults*/ ctx[7]) {
1485
1520
  if (if_block0) {
1486
1521
  if_block0.p(ctx, dirty);
1487
1522
 
1488
- if (dirty[0] & /*hideDropdown, results*/ 34) {
1523
+ if (dirty[0] & /*showResults*/ 128) {
1489
1524
  transition_in(if_block0, 1);
1490
1525
  }
1491
1526
  } else {
@@ -1504,11 +1539,11 @@ function create_fragment(ctx) {
1504
1539
  check_outros();
1505
1540
  }
1506
1541
 
1507
- if (/*$$slots*/ ctx[9]["no-results"] && !/*hideDropdown*/ ctx[5] && /*value*/ ctx[0].length > 0 && /*results*/ ctx[1].length === 0) {
1542
+ if (/*$$slots*/ ctx[10]["no-results"] && !/*hideDropdown*/ ctx[3] && /*value*/ ctx[0].length > 0 && /*results*/ ctx[1].length === 0) {
1508
1543
  if (if_block1) {
1509
1544
  if_block1.p(ctx, dirty);
1510
1545
 
1511
- if (dirty[0] & /*$$slots, hideDropdown, value, results*/ 547) {
1546
+ if (dirty[0] & /*$$slots, hideDropdown, value, results*/ 1035) {
1512
1547
  transition_in(if_block1, 1);
1513
1548
  }
1514
1549
  } else {
@@ -1539,8 +1574,8 @@ function create_fragment(ctx) {
1539
1574
  attr(div, "aria-owns", div_aria_owns_value);
1540
1575
  }
1541
1576
 
1542
- if (!current || dirty[0] & /*hideDropdown, results*/ 34 && div_aria_expanded_value !== (div_aria_expanded_value = !/*hideDropdown*/ ctx[5] && /*results*/ ctx[1].length > 0)) {
1543
- attr(div, "aria-expanded", div_aria_expanded_value);
1577
+ if (!current || dirty[0] & /*showResults*/ 128) {
1578
+ attr(div, "aria-expanded", /*showResults*/ ctx[7]);
1544
1579
  }
1545
1580
 
1546
1581
  if (!current || dirty[0] & /*id*/ 4 && div_id_value !== (div_id_value = "" + (/*id*/ ctx[2] + "-typeahead"))) {
@@ -1569,7 +1604,7 @@ function create_fragment(ctx) {
1569
1604
  destroy_component(search);
1570
1605
  if (if_block0) if_block0.d();
1571
1606
  if (if_block1) if_block1.d();
1572
- /*div_binding*/ ctx[36](null);
1607
+ /*div_binding*/ ctx[38](null);
1573
1608
  mounted = false;
1574
1609
  dispose();
1575
1610
  }
@@ -1579,6 +1614,7 @@ function create_fragment(ctx) {
1579
1614
  function instance($$self, $$props, $$invalidate) {
1580
1615
  let options;
1581
1616
  let resultsId;
1617
+ let showResults;
1582
1618
 
1583
1619
  const omit_props_names = [
1584
1620
  "id","value","data","extract","disable","filter","autoselect","inputAfterSelect","results","focusAfterSelect","limit"
@@ -1611,7 +1647,7 @@ function instance($$self, $$props, $$invalidate) {
1611
1647
  }
1612
1648
 
1613
1649
  if (prevResults !== resultsId && !$$slots["no-results"]) {
1614
- $$invalidate(5, hideDropdown = results.length === 0);
1650
+ $$invalidate(3, hideDropdown = results.length === 0);
1615
1651
  }
1616
1652
 
1617
1653
  prevResults = resultsId;
@@ -1635,12 +1671,12 @@ function instance($$self, $$props, $$invalidate) {
1635
1671
 
1636
1672
  await tick();
1637
1673
  if (focusAfterSelect) searchRef.focus();
1638
- $$invalidate(5, hideDropdown = true);
1674
+ $$invalidate(3, hideDropdown = true);
1639
1675
  }
1640
1676
 
1641
1677
  /** @type {(direction: -1 | 1) => void} */
1642
1678
  function change(direction) {
1643
- let index = selectedIndex === results.length - 1
1679
+ let index = direction === 1 && selectedIndex === results.length - 1
1644
1680
  ? 0
1645
1681
  : selectedIndex + direction;
1646
1682
 
@@ -1662,13 +1698,13 @@ function instance($$self, $$props, $$invalidate) {
1662
1698
 
1663
1699
  const click_handler = ({ target }) => {
1664
1700
  if (!hideDropdown && comboboxRef && !comboboxRef.contains(target)) {
1665
- $$invalidate(5, hideDropdown = true);
1701
+ $$invalidate(3, hideDropdown = true);
1666
1702
  }
1667
1703
  };
1668
1704
 
1669
1705
  function search_ref_binding(value) {
1670
1706
  searchRef = value;
1671
- $$invalidate(4, searchRef);
1707
+ $$invalidate(5, searchRef);
1672
1708
  }
1673
1709
 
1674
1710
  function search_value_binding(value$1) {
@@ -1693,7 +1729,7 @@ function instance($$self, $$props, $$invalidate) {
1693
1729
  }
1694
1730
 
1695
1731
  const focus_handler_1 = () => {
1696
- $$invalidate(5, hideDropdown = false);
1732
+ $$invalidate(3, hideDropdown = false);
1697
1733
  };
1698
1734
 
1699
1735
  function clear_handler(event) {
@@ -1701,7 +1737,7 @@ function instance($$self, $$props, $$invalidate) {
1701
1737
  }
1702
1738
 
1703
1739
  const clear_handler_1 = () => {
1704
- $$invalidate(5, hideDropdown = false);
1740
+ $$invalidate(3, hideDropdown = false);
1705
1741
  };
1706
1742
 
1707
1743
  function blur_handler(event) {
@@ -1731,67 +1767,76 @@ function instance($$self, $$props, $$invalidate) {
1731
1767
  e.preventDefault();
1732
1768
  $$invalidate(0, value = "");
1733
1769
  searchRef.focus();
1734
- $$invalidate(5, hideDropdown = true);
1770
+ $$invalidate(3, hideDropdown = true);
1735
1771
  break;
1736
1772
  }
1737
1773
  };
1738
1774
 
1739
- const click_handler_1 = (result, i) => {
1740
- if (!result.disabled) {
1741
- $$invalidate(6, selectedIndex = i);
1742
- select();
1743
- }
1775
+ const click_handler_1 = (result, index) => {
1776
+ if (result.disabled) return;
1777
+ $$invalidate(6, selectedIndex = index);
1778
+ select();
1779
+ };
1780
+
1781
+ const mouseenter_handler = (result, index) => {
1782
+ if (result.disabled) return;
1783
+ $$invalidate(6, selectedIndex = index);
1744
1784
  };
1745
1785
 
1746
1786
  function div_binding($$value) {
1747
1787
  binding_callbacks[$$value ? 'unshift' : 'push'](() => {
1748
1788
  comboboxRef = $$value;
1749
- $$invalidate(3, comboboxRef);
1789
+ $$invalidate(4, comboboxRef);
1750
1790
  });
1751
1791
  }
1752
1792
 
1753
1793
  $$self.$$set = $$new_props => {
1754
1794
  $$props = assign(assign({}, $$props), exclude_internal_props($$new_props));
1755
- $$invalidate(10, $$restProps = compute_rest_props($$props, omit_props_names));
1795
+ $$invalidate(11, $$restProps = compute_rest_props($$props, omit_props_names));
1756
1796
  if ('id' in $$new_props) $$invalidate(2, id = $$new_props.id);
1757
1797
  if ('value' in $$new_props) $$invalidate(0, value = $$new_props.value);
1758
- if ('data' in $$new_props) $$invalidate(11, data = $$new_props.data);
1759
- if ('extract' in $$new_props) $$invalidate(12, extract = $$new_props.extract);
1760
- if ('disable' in $$new_props) $$invalidate(13, disable = $$new_props.disable);
1761
- if ('filter' in $$new_props) $$invalidate(14, filter = $$new_props.filter);
1762
- if ('autoselect' in $$new_props) $$invalidate(15, autoselect = $$new_props.autoselect);
1763
- if ('inputAfterSelect' in $$new_props) $$invalidate(16, inputAfterSelect = $$new_props.inputAfterSelect);
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);
1764
1804
  if ('results' in $$new_props) $$invalidate(1, results = $$new_props.results);
1765
- if ('focusAfterSelect' in $$new_props) $$invalidate(17, focusAfterSelect = $$new_props.focusAfterSelect);
1766
- if ('limit' in $$new_props) $$invalidate(18, limit = $$new_props.limit);
1767
- if ('$$scope' in $$new_props) $$invalidate(20, $$scope = $$new_props.$$scope);
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);
1768
1808
  };
1769
1809
 
1770
1810
  $$self.$$.update = () => {
1771
- if ($$self.$$.dirty[0] & /*extract*/ 4096) {
1772
- $$invalidate(19, options = { pre: "<mark>", post: "</mark>", extract });
1811
+ if ($$self.$$.dirty[0] & /*extract*/ 8192) {
1812
+ $$invalidate(20, options = { pre: "<mark>", post: "</mark>", extract });
1773
1813
  }
1774
1814
 
1775
- if ($$self.$$.dirty[0] & /*value, data, options, limit, filter, disable*/ 813057) {
1815
+ if ($$self.$$.dirty[0] & /*value, data, options, limit, filter, disable*/ 1626113) {
1776
1816
  $$invalidate(1, results = fuzzy.filter(value, data, options).filter(({ score }) => score > 0).slice(0, limit).filter(result => !filter(result.original)).map(result => ({
1777
1817
  ...result,
1778
1818
  disabled: disable(result.original)
1779
1819
  })));
1780
1820
  }
1781
1821
 
1782
- if ($$self.$$.dirty[0] & /*results, extract*/ 4098) {
1822
+ if ($$self.$$.dirty[0] & /*results, extract*/ 8194) {
1783
1823
  resultsId = results.map(result => extract(result.original)).join("");
1784
1824
  }
1825
+
1826
+ if ($$self.$$.dirty[0] & /*hideDropdown, results*/ 10) {
1827
+ $$invalidate(7, showResults = !hideDropdown && results.length > 0);
1828
+ }
1785
1829
  };
1786
1830
 
1787
1831
  return [
1788
1832
  value,
1789
1833
  results,
1790
1834
  id,
1835
+ hideDropdown,
1791
1836
  comboboxRef,
1792
1837
  searchRef,
1793
- hideDropdown,
1794
1838
  selectedIndex,
1839
+ showResults,
1795
1840
  select,
1796
1841
  change,
1797
1842
  $$slots,
@@ -1821,6 +1866,7 @@ function instance($$self, $$props, $$invalidate) {
1821
1866
  keydown_handler,
1822
1867
  keydown_handler_1,
1823
1868
  click_handler_1,
1869
+ mouseenter_handler,
1824
1870
  div_binding
1825
1871
  ];
1826
1872
  }
@@ -1838,15 +1884,15 @@ class Typeahead extends SvelteComponent {
1838
1884
  {
1839
1885
  id: 2,
1840
1886
  value: 0,
1841
- data: 11,
1842
- extract: 12,
1843
- disable: 13,
1844
- filter: 14,
1845
- autoselect: 15,
1846
- inputAfterSelect: 16,
1887
+ data: 12,
1888
+ extract: 13,
1889
+ disable: 14,
1890
+ filter: 15,
1891
+ autoselect: 16,
1892
+ inputAfterSelect: 17,
1847
1893
  results: 1,
1848
- focusAfterSelect: 17,
1849
- limit: 18
1894
+ focusAfterSelect: 18,
1895
+ limit: 19
1850
1896
  },
1851
1897
  add_css,
1852
1898
  [-1, -1]