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.js CHANGED
@@ -1,8 +1,8 @@
1
1
  (function (global, factory) {
2
2
  typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) :
3
3
  typeof define === 'function' && define.amd ? define(['exports'], factory) :
4
- (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global['svelte-typeahead'] = {}));
5
- }(this, (function (exports) { 'use strict';
4
+ (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global["svelte-typeahead"] = {}));
5
+ })(this, (function (exports) { 'use strict';
6
6
 
7
7
  function noop() { }
8
8
  function assign(tar, src) {
@@ -136,6 +136,9 @@
136
136
  function element(name) {
137
137
  return document.createElement(name);
138
138
  }
139
+ function svg_element(name) {
140
+ return document.createElementNS('http://www.w3.org/2000/svg', name);
141
+ }
139
142
  function text(data) {
140
143
  return document.createTextNode(data);
141
144
  }
@@ -197,13 +200,15 @@
197
200
  function toggle_class(element, name, toggle) {
198
201
  element.classList[toggle ? 'add' : 'remove'](name);
199
202
  }
200
- function custom_event(type, detail, bubbles = false) {
203
+ function custom_event(type, detail, { bubbles = false, cancelable = false } = {}) {
201
204
  const e = document.createEvent('CustomEvent');
202
- e.initCustomEvent(type, bubbles, false, detail);
205
+ e.initCustomEvent(type, bubbles, cancelable, detail);
203
206
  return e;
204
207
  }
205
208
  class HtmlTag {
206
- constructor() {
209
+ constructor(is_svg = false) {
210
+ this.is_svg = false;
211
+ this.is_svg = is_svg;
207
212
  this.e = this.n = null;
208
213
  }
209
214
  c(html) {
@@ -211,7 +216,10 @@
211
216
  }
212
217
  m(html, target, anchor = null) {
213
218
  if (!this.e) {
214
- this.e = element(target.nodeName);
219
+ if (this.is_svg)
220
+ this.e = svg_element(target.nodeName);
221
+ else
222
+ this.e = element(target.nodeName);
215
223
  this.t = target;
216
224
  this.c(html);
217
225
  }
@@ -253,16 +261,18 @@
253
261
  }
254
262
  function createEventDispatcher() {
255
263
  const component = get_current_component();
256
- return (type, detail) => {
264
+ return (type, detail, { cancelable = false } = {}) => {
257
265
  const callbacks = component.$$.callbacks[type];
258
266
  if (callbacks) {
259
267
  // TODO are there situations where events could be dispatched
260
268
  // in a server (non-DOM) environment?
261
- const event = custom_event(type, detail);
269
+ const event = custom_event(type, detail, { cancelable });
262
270
  callbacks.slice().forEach(fn => {
263
271
  fn.call(component, event);
264
272
  });
273
+ return !event.defaultPrevented;
265
274
  }
275
+ return true;
266
276
  };
267
277
  }
268
278
  // TODO figure out if we still want to support
@@ -298,22 +308,40 @@
298
308
  function add_flush_callback(fn) {
299
309
  flush_callbacks.push(fn);
300
310
  }
301
- let flushing = false;
311
+ // flush() calls callbacks in this order:
312
+ // 1. All beforeUpdate callbacks, in order: parents before children
313
+ // 2. All bind:this callbacks, in reverse order: children before parents.
314
+ // 3. All afterUpdate callbacks, in order: parents before children. EXCEPT
315
+ // for afterUpdates called during the initial onMount, which are called in
316
+ // reverse order: children before parents.
317
+ // Since callbacks might update component values, which could trigger another
318
+ // call to flush(), the following steps guard against this:
319
+ // 1. During beforeUpdate, any updated components will be added to the
320
+ // dirty_components array and will cause a reentrant call to flush(). Because
321
+ // the flush index is kept outside the function, the reentrant call will pick
322
+ // up where the earlier call left off and go through all dirty components. The
323
+ // current_component value is saved and restored so that the reentrant call will
324
+ // not interfere with the "parent" flush() call.
325
+ // 2. bind:this callbacks cannot trigger new flush() calls.
326
+ // 3. During afterUpdate, any updated components will NOT have their afterUpdate
327
+ // callback called a second time; the seen_callbacks set, outside the flush()
328
+ // function, guarantees this behavior.
302
329
  const seen_callbacks = new Set();
330
+ let flushidx = 0; // Do *not* move this inside the flush() function
303
331
  function flush() {
304
- if (flushing)
305
- return;
306
- flushing = true;
332
+ const saved_component = current_component;
307
333
  do {
308
334
  // first, call beforeUpdate functions
309
335
  // and update components
310
- for (let i = 0; i < dirty_components.length; i += 1) {
311
- const component = dirty_components[i];
336
+ while (flushidx < dirty_components.length) {
337
+ const component = dirty_components[flushidx];
338
+ flushidx++;
312
339
  set_current_component(component);
313
340
  update(component.$$);
314
341
  }
315
342
  set_current_component(null);
316
343
  dirty_components.length = 0;
344
+ flushidx = 0;
317
345
  while (binding_callbacks.length)
318
346
  binding_callbacks.pop()();
319
347
  // then, once components are updated, call
@@ -333,8 +361,8 @@
333
361
  flush_callbacks.pop()();
334
362
  }
335
363
  update_scheduled = false;
336
- flushing = false;
337
364
  seen_callbacks.clear();
365
+ set_current_component(saved_component);
338
366
  }
339
367
  function update($$) {
340
368
  if ($$.fragment !== null) {
@@ -703,7 +731,7 @@
703
731
 
704
732
  var fuzzy = fuzzy$1.exports;
705
733
 
706
- /* node_modules/svelte-search/src/Search.svelte generated by Svelte v3.44.0 */
734
+ /* node_modules/svelte-search/src/Search.svelte generated by Svelte v3.48.0 */
707
735
 
708
736
  function add_css$1(target) {
709
737
  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}");
@@ -1040,10 +1068,10 @@
1040
1068
 
1041
1069
  var Search$1 = Search;
1042
1070
 
1043
- /* src/Typeahead.svelte generated by Svelte v3.44.0 */
1071
+ /* src/Typeahead.svelte generated by Svelte v3.48.0 */
1044
1072
 
1045
1073
  function add_css(target) {
1046
- 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}");
1074
+ 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}");
1047
1075
  }
1048
1076
 
1049
1077
  const get_no_results_slot_changes = dirty => ({
@@ -1053,14 +1081,14 @@
1053
1081
 
1054
1082
  const get_no_results_slot_context = ctx => ({
1055
1083
  value: /*value*/ ctx[0],
1056
- result: /*result*/ ctx[40],
1057
- index: /*i*/ ctx[42]
1084
+ result: /*result*/ ctx[42],
1085
+ index: /*index*/ ctx[44]
1058
1086
  });
1059
1087
 
1060
1088
  function get_each_context(ctx, list, i) {
1061
1089
  const child_ctx = ctx.slice();
1062
- child_ctx[40] = list[i];
1063
- child_ctx[42] = i;
1090
+ child_ctx[42] = list[i];
1091
+ child_ctx[44] = i;
1064
1092
  return child_ctx;
1065
1093
  }
1066
1094
 
@@ -1070,12 +1098,12 @@
1070
1098
  });
1071
1099
 
1072
1100
  const get_default_slot_context = ctx => ({
1073
- result: /*result*/ ctx[40],
1074
- index: /*i*/ ctx[42],
1101
+ result: /*result*/ ctx[42],
1102
+ index: /*index*/ ctx[44],
1075
1103
  value: /*value*/ ctx[0]
1076
1104
  });
1077
1105
 
1078
- // (198:4) {#if !hideDropdown && results.length > 0}
1106
+ // (201:4) {#if showResults}
1079
1107
  function create_if_block_1(ctx) {
1080
1108
  let each_1_anchor;
1081
1109
  let current;
@@ -1107,7 +1135,7 @@
1107
1135
  current = true;
1108
1136
  },
1109
1137
  p(ctx, dirty) {
1110
- if (dirty[0] & /*id, selectedIndex, results, select, $$scope, value*/ 1048775) {
1138
+ if (dirty[0] & /*id, selectedIndex, results, select, $$scope, value*/ 2097479) {
1111
1139
  each_value = /*results*/ ctx[1];
1112
1140
  let i;
1113
1141
 
@@ -1159,15 +1187,15 @@
1159
1187
  };
1160
1188
  }
1161
1189
 
1162
- // (213:43)
1190
+ // (219:41)
1163
1191
  function fallback_block(ctx) {
1164
1192
  let html_tag;
1165
- let raw_value = /*result*/ ctx[40].string + "";
1193
+ let raw_value = /*result*/ ctx[42].string + "";
1166
1194
  let html_anchor;
1167
1195
 
1168
1196
  return {
1169
1197
  c() {
1170
- html_tag = new HtmlTag();
1198
+ html_tag = new HtmlTag(false);
1171
1199
  html_anchor = empty();
1172
1200
  html_tag.a = html_anchor;
1173
1201
  },
@@ -1176,7 +1204,7 @@
1176
1204
  insert(target, html_anchor, anchor);
1177
1205
  },
1178
1206
  p(ctx, dirty) {
1179
- if (dirty[0] & /*results*/ 2 && raw_value !== (raw_value = /*result*/ ctx[40].string + "")) html_tag.p(raw_value);
1207
+ if (dirty[0] & /*results*/ 2 && raw_value !== (raw_value = /*result*/ ctx[42].string + "")) html_tag.p(raw_value);
1180
1208
  },
1181
1209
  d(detaching) {
1182
1210
  if (detaching) detach(html_anchor);
@@ -1185,7 +1213,7 @@
1185
1213
  };
1186
1214
  }
1187
1215
 
1188
- // (199:6) {#each results as result, i}
1216
+ // (202:6) {#each results as result, index}
1189
1217
  function create_each_block(ctx) {
1190
1218
  let li;
1191
1219
  let t;
@@ -1194,12 +1222,16 @@
1194
1222
  let current;
1195
1223
  let mounted;
1196
1224
  let dispose;
1197
- const default_slot_template = /*#slots*/ ctx[21].default;
1198
- const default_slot = create_slot(default_slot_template, ctx, /*$$scope*/ ctx[20], get_default_slot_context);
1225
+ const default_slot_template = /*#slots*/ ctx[22].default;
1226
+ const default_slot = create_slot(default_slot_template, ctx, /*$$scope*/ ctx[21], get_default_slot_context);
1199
1227
  const default_slot_or_fallback = default_slot || fallback_block(ctx);
1200
1228
 
1201
1229
  function click_handler_1() {
1202
- return /*click_handler_1*/ ctx[35](/*result*/ ctx[40], /*i*/ ctx[42]);
1230
+ return /*click_handler_1*/ ctx[36](/*result*/ ctx[42], /*index*/ ctx[44]);
1231
+ }
1232
+
1233
+ function mouseenter_handler() {
1234
+ return /*mouseenter_handler*/ ctx[37](/*result*/ ctx[42], /*index*/ ctx[44]);
1203
1235
  }
1204
1236
 
1205
1237
  return {
@@ -1208,11 +1240,11 @@
1208
1240
  if (default_slot_or_fallback) default_slot_or_fallback.c();
1209
1241
  t = space();
1210
1242
  attr(li, "role", "option");
1211
- attr(li, "id", li_id_value = "" + (/*id*/ ctx[2] + "-result-" + /*i*/ ctx[42]));
1212
- attr(li, "aria-selected", li_aria_selected_value = /*selectedIndex*/ ctx[6] === /*i*/ ctx[42]);
1213
- attr(li, "class", "svelte-j5n77y");
1214
- toggle_class(li, "selected", /*selectedIndex*/ ctx[6] === /*i*/ ctx[42]);
1215
- toggle_class(li, "disabled", /*result*/ ctx[40].disabled);
1243
+ attr(li, "id", li_id_value = "" + (/*id*/ ctx[2] + "-result-" + /*index*/ ctx[44]));
1244
+ attr(li, "aria-selected", li_aria_selected_value = /*selectedIndex*/ ctx[6] === /*index*/ ctx[44]);
1245
+ attr(li, "class", "svelte-9wywte");
1246
+ toggle_class(li, "selected", /*selectedIndex*/ ctx[6] === /*index*/ ctx[44]);
1247
+ toggle_class(li, "disabled", /*result*/ ctx[42].disabled);
1216
1248
  },
1217
1249
  m(target, anchor) {
1218
1250
  insert(target, li, anchor);
@@ -1225,7 +1257,11 @@
1225
1257
  current = true;
1226
1258
 
1227
1259
  if (!mounted) {
1228
- dispose = listen(li, "click", click_handler_1);
1260
+ dispose = [
1261
+ listen(li, "click", click_handler_1),
1262
+ listen(li, "mouseenter", mouseenter_handler)
1263
+ ];
1264
+
1229
1265
  mounted = true;
1230
1266
  }
1231
1267
  },
@@ -1233,15 +1269,15 @@
1233
1269
  ctx = new_ctx;
1234
1270
 
1235
1271
  if (default_slot) {
1236
- if (default_slot.p && (!current || dirty[0] & /*$$scope, results, value*/ 1048579)) {
1272
+ if (default_slot.p && (!current || dirty[0] & /*$$scope, results, value*/ 2097155)) {
1237
1273
  update_slot_base(
1238
1274
  default_slot,
1239
1275
  default_slot_template,
1240
1276
  ctx,
1241
- /*$$scope*/ ctx[20],
1277
+ /*$$scope*/ ctx[21],
1242
1278
  !current
1243
- ? get_all_dirty_from_scope(/*$$scope*/ ctx[20])
1244
- : get_slot_changes(default_slot_template, /*$$scope*/ ctx[20], dirty, get_default_slot_changes),
1279
+ ? get_all_dirty_from_scope(/*$$scope*/ ctx[21])
1280
+ : get_slot_changes(default_slot_template, /*$$scope*/ ctx[21], dirty, get_default_slot_changes),
1245
1281
  get_default_slot_context
1246
1282
  );
1247
1283
  }
@@ -1251,20 +1287,20 @@
1251
1287
  }
1252
1288
  }
1253
1289
 
1254
- if (!current || dirty[0] & /*id*/ 4 && li_id_value !== (li_id_value = "" + (/*id*/ ctx[2] + "-result-" + /*i*/ ctx[42]))) {
1290
+ if (!current || dirty[0] & /*id*/ 4 && li_id_value !== (li_id_value = "" + (/*id*/ ctx[2] + "-result-" + /*index*/ ctx[44]))) {
1255
1291
  attr(li, "id", li_id_value);
1256
1292
  }
1257
1293
 
1258
- if (!current || dirty[0] & /*selectedIndex*/ 64 && li_aria_selected_value !== (li_aria_selected_value = /*selectedIndex*/ ctx[6] === /*i*/ ctx[42])) {
1294
+ if (!current || dirty[0] & /*selectedIndex*/ 64 && li_aria_selected_value !== (li_aria_selected_value = /*selectedIndex*/ ctx[6] === /*index*/ ctx[44])) {
1259
1295
  attr(li, "aria-selected", li_aria_selected_value);
1260
1296
  }
1261
1297
 
1262
1298
  if (dirty[0] & /*selectedIndex*/ 64) {
1263
- toggle_class(li, "selected", /*selectedIndex*/ ctx[6] === /*i*/ ctx[42]);
1299
+ toggle_class(li, "selected", /*selectedIndex*/ ctx[6] === /*index*/ ctx[44]);
1264
1300
  }
1265
1301
 
1266
1302
  if (dirty[0] & /*results*/ 2) {
1267
- toggle_class(li, "disabled", /*result*/ ctx[40].disabled);
1303
+ toggle_class(li, "disabled", /*result*/ ctx[42].disabled);
1268
1304
  }
1269
1305
  },
1270
1306
  i(local) {
@@ -1280,23 +1316,23 @@
1280
1316
  if (detaching) detach(li);
1281
1317
  if (default_slot_or_fallback) default_slot_or_fallback.d(detaching);
1282
1318
  mounted = false;
1283
- dispose();
1319
+ run_all(dispose);
1284
1320
  }
1285
1321
  };
1286
1322
  }
1287
1323
 
1288
- // (219:4) {#if $$slots["no-results"] && !hideDropdown && value.length > 0 && results.length === 0}
1324
+ // (225:4) {#if $$slots["no-results"] && !hideDropdown && value.length > 0 && results.length === 0}
1289
1325
  function create_if_block(ctx) {
1290
1326
  let div;
1291
1327
  let current;
1292
- const no_results_slot_template = /*#slots*/ ctx[21]["no-results"];
1293
- const no_results_slot = create_slot(no_results_slot_template, ctx, /*$$scope*/ ctx[20], get_no_results_slot_context);
1328
+ const no_results_slot_template = /*#slots*/ ctx[22]["no-results"];
1329
+ const no_results_slot = create_slot(no_results_slot_template, ctx, /*$$scope*/ ctx[21], get_no_results_slot_context);
1294
1330
 
1295
1331
  return {
1296
1332
  c() {
1297
1333
  div = element("div");
1298
1334
  if (no_results_slot) no_results_slot.c();
1299
- attr(div, "class", "svelte-j5n77y");
1335
+ attr(div, "class", "svelte-9wywte");
1300
1336
  toggle_class(div, "no-results", true);
1301
1337
  },
1302
1338
  m(target, anchor) {
@@ -1310,15 +1346,15 @@
1310
1346
  },
1311
1347
  p(ctx, dirty) {
1312
1348
  if (no_results_slot) {
1313
- if (no_results_slot.p && (!current || dirty[0] & /*$$scope, value, results*/ 1048579)) {
1349
+ if (no_results_slot.p && (!current || dirty[0] & /*$$scope, value, results*/ 2097155)) {
1314
1350
  update_slot_base(
1315
1351
  no_results_slot,
1316
1352
  no_results_slot_template,
1317
1353
  ctx,
1318
- /*$$scope*/ ctx[20],
1354
+ /*$$scope*/ ctx[21],
1319
1355
  !current
1320
- ? get_all_dirty_from_scope(/*$$scope*/ ctx[20])
1321
- : get_slot_changes(no_results_slot_template, /*$$scope*/ ctx[20], dirty, get_no_results_slot_changes),
1356
+ ? get_all_dirty_from_scope(/*$$scope*/ ctx[21])
1357
+ : get_slot_changes(no_results_slot_template, /*$$scope*/ ctx[21], dirty, get_no_results_slot_changes),
1322
1358
  get_no_results_slot_context
1323
1359
  );
1324
1360
  }
@@ -1351,7 +1387,6 @@
1351
1387
  let ul_aria_labelledby_value;
1352
1388
  let ul_id_value;
1353
1389
  let div_aria_owns_value;
1354
- let div_aria_expanded_value;
1355
1390
  let div_id_value;
1356
1391
  let current;
1357
1392
  let mounted;
@@ -1360,7 +1395,7 @@
1360
1395
  const search_spread_levels = [
1361
1396
  { id: /*id*/ ctx[2] },
1362
1397
  { removeFormAriaAttributes: true },
1363
- /*$$restProps*/ ctx[10],
1398
+ /*$$restProps*/ ctx[11],
1364
1399
  { "aria-autocomplete": "list" },
1365
1400
  {
1366
1401
  "aria-controls": "" + (/*id*/ ctx[2] + "-listbox")
@@ -1369,18 +1404,18 @@
1369
1404
  "aria-labelledby": "" + (/*id*/ ctx[2] + "-label")
1370
1405
  },
1371
1406
  {
1372
- "aria-activedescendant": /*selectedIndex*/ ctx[6] >= 0 && !/*hideDropdown*/ ctx[5] && /*results*/ ctx[1].length > 0
1407
+ "aria-activedescendant": /*selectedIndex*/ ctx[6] >= 0 && !/*hideDropdown*/ ctx[3] && /*results*/ ctx[1].length > 0
1373
1408
  ? `${/*id*/ ctx[2]}-result-${/*selectedIndex*/ ctx[6]}`
1374
1409
  : null
1375
1410
  }
1376
1411
  ];
1377
1412
 
1378
1413
  function search_ref_binding(value) {
1379
- /*search_ref_binding*/ ctx[23](value);
1414
+ /*search_ref_binding*/ ctx[24](value);
1380
1415
  }
1381
1416
 
1382
1417
  function search_value_binding(value) {
1383
- /*search_value_binding*/ ctx[24](value);
1418
+ /*search_value_binding*/ ctx[25](value);
1384
1419
  }
1385
1420
 
1386
1421
  let search_props = {};
@@ -1389,8 +1424,8 @@
1389
1424
  search_props = assign(search_props, search_spread_levels[i]);
1390
1425
  }
1391
1426
 
1392
- if (/*searchRef*/ ctx[4] !== void 0) {
1393
- search_props.ref = /*searchRef*/ ctx[4];
1427
+ if (/*searchRef*/ ctx[5] !== void 0) {
1428
+ search_props.ref = /*searchRef*/ ctx[5];
1394
1429
  }
1395
1430
 
1396
1431
  if (/*value*/ ctx[0] !== void 0) {
@@ -1400,18 +1435,18 @@
1400
1435
  search = new Search$1({ props: search_props });
1401
1436
  binding_callbacks.push(() => bind(search, 'ref', search_ref_binding));
1402
1437
  binding_callbacks.push(() => bind(search, 'value', search_value_binding));
1403
- search.$on("type", /*type_handler*/ ctx[25]);
1404
- search.$on("input", /*input_handler*/ ctx[26]);
1405
- search.$on("change", /*change_handler*/ ctx[27]);
1406
- search.$on("focus", /*focus_handler*/ ctx[28]);
1407
- search.$on("focus", /*focus_handler_1*/ ctx[29]);
1408
- search.$on("clear", /*clear_handler*/ ctx[30]);
1409
- search.$on("clear", /*clear_handler_1*/ ctx[31]);
1410
- search.$on("blur", /*blur_handler*/ ctx[32]);
1411
- search.$on("keydown", /*keydown_handler*/ ctx[33]);
1412
- search.$on("keydown", /*keydown_handler_1*/ ctx[34]);
1413
- let if_block0 = !/*hideDropdown*/ ctx[5] && /*results*/ ctx[1].length > 0 && create_if_block_1(ctx);
1414
- 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);
1438
+ search.$on("type", /*type_handler*/ ctx[26]);
1439
+ search.$on("input", /*input_handler*/ ctx[27]);
1440
+ search.$on("change", /*change_handler*/ ctx[28]);
1441
+ search.$on("focus", /*focus_handler*/ ctx[29]);
1442
+ search.$on("focus", /*focus_handler_1*/ ctx[30]);
1443
+ search.$on("clear", /*clear_handler*/ ctx[31]);
1444
+ search.$on("clear", /*clear_handler_1*/ ctx[32]);
1445
+ search.$on("blur", /*blur_handler*/ ctx[33]);
1446
+ search.$on("keydown", /*keydown_handler*/ ctx[34]);
1447
+ search.$on("keydown", /*keydown_handler_1*/ ctx[35]);
1448
+ let if_block0 = /*showResults*/ ctx[7] && create_if_block_1(ctx);
1449
+ 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);
1415
1450
 
1416
1451
  return {
1417
1452
  c() {
@@ -1425,15 +1460,15 @@
1425
1460
  attr(ul, "role", "listbox");
1426
1461
  attr(ul, "aria-labelledby", ul_aria_labelledby_value = "" + (/*id*/ ctx[2] + "-label"));
1427
1462
  attr(ul, "id", ul_id_value = "" + (/*id*/ ctx[2] + "-listbox"));
1428
- attr(ul, "class", "svelte-j5n77y");
1463
+ attr(ul, "class", "svelte-9wywte");
1429
1464
  toggle_class(ul, "svelte-typeahead-list", true);
1430
1465
  attr(div, "data-svelte-typeahead", "");
1431
1466
  attr(div, "role", "combobox");
1432
1467
  attr(div, "aria-haspopup", "listbox");
1433
1468
  attr(div, "aria-owns", div_aria_owns_value = "" + (/*id*/ ctx[2] + "-listbox"));
1434
- attr(div, "aria-expanded", div_aria_expanded_value = !/*hideDropdown*/ ctx[5] && /*results*/ ctx[1].length > 0);
1469
+ attr(div, "aria-expanded", /*showResults*/ ctx[7]);
1435
1470
  attr(div, "id", div_id_value = "" + (/*id*/ ctx[2] + "-typeahead"));
1436
- attr(div, "class", "svelte-j5n77y");
1471
+ attr(div, "class", "svelte-9wywte");
1437
1472
  toggle_class(div, "dropdown", /*results*/ ctx[1].length > 0);
1438
1473
  },
1439
1474
  m(target, anchor) {
@@ -1444,20 +1479,20 @@
1444
1479
  if (if_block0) if_block0.m(ul, null);
1445
1480
  append(ul, t1);
1446
1481
  if (if_block1) if_block1.m(ul, null);
1447
- /*div_binding*/ ctx[36](div);
1482
+ /*div_binding*/ ctx[38](div);
1448
1483
  current = true;
1449
1484
 
1450
1485
  if (!mounted) {
1451
- dispose = listen(window, "click", /*click_handler*/ ctx[22]);
1486
+ dispose = listen(window, "click", /*click_handler*/ ctx[23]);
1452
1487
  mounted = true;
1453
1488
  }
1454
1489
  },
1455
1490
  p(ctx, dirty) {
1456
- const search_changes = (dirty[0] & /*id, $$restProps, selectedIndex, hideDropdown, results*/ 1126)
1491
+ const search_changes = (dirty[0] & /*id, $$restProps, selectedIndex, hideDropdown, results*/ 2126)
1457
1492
  ? get_spread_update(search_spread_levels, [
1458
1493
  dirty[0] & /*id*/ 4 && { id: /*id*/ ctx[2] },
1459
1494
  search_spread_levels[1],
1460
- dirty[0] & /*$$restProps*/ 1024 && get_spread_object(/*$$restProps*/ ctx[10]),
1495
+ dirty[0] & /*$$restProps*/ 2048 && get_spread_object(/*$$restProps*/ ctx[11]),
1461
1496
  search_spread_levels[3],
1462
1497
  dirty[0] & /*id*/ 4 && {
1463
1498
  "aria-controls": "" + (/*id*/ ctx[2] + "-listbox")
@@ -1465,17 +1500,17 @@
1465
1500
  dirty[0] & /*id*/ 4 && {
1466
1501
  "aria-labelledby": "" + (/*id*/ ctx[2] + "-label")
1467
1502
  },
1468
- dirty[0] & /*selectedIndex, hideDropdown, results, id*/ 102 && {
1469
- "aria-activedescendant": /*selectedIndex*/ ctx[6] >= 0 && !/*hideDropdown*/ ctx[5] && /*results*/ ctx[1].length > 0
1503
+ dirty[0] & /*selectedIndex, hideDropdown, results, id*/ 78 && {
1504
+ "aria-activedescendant": /*selectedIndex*/ ctx[6] >= 0 && !/*hideDropdown*/ ctx[3] && /*results*/ ctx[1].length > 0
1470
1505
  ? `${/*id*/ ctx[2]}-result-${/*selectedIndex*/ ctx[6]}`
1471
1506
  : null
1472
1507
  }
1473
1508
  ])
1474
1509
  : {};
1475
1510
 
1476
- if (!updating_ref && dirty[0] & /*searchRef*/ 16) {
1511
+ if (!updating_ref && dirty[0] & /*searchRef*/ 32) {
1477
1512
  updating_ref = true;
1478
- search_changes.ref = /*searchRef*/ ctx[4];
1513
+ search_changes.ref = /*searchRef*/ ctx[5];
1479
1514
  add_flush_callback(() => updating_ref = false);
1480
1515
  }
1481
1516
 
@@ -1487,11 +1522,11 @@
1487
1522
 
1488
1523
  search.$set(search_changes);
1489
1524
 
1490
- if (!/*hideDropdown*/ ctx[5] && /*results*/ ctx[1].length > 0) {
1525
+ if (/*showResults*/ ctx[7]) {
1491
1526
  if (if_block0) {
1492
1527
  if_block0.p(ctx, dirty);
1493
1528
 
1494
- if (dirty[0] & /*hideDropdown, results*/ 34) {
1529
+ if (dirty[0] & /*showResults*/ 128) {
1495
1530
  transition_in(if_block0, 1);
1496
1531
  }
1497
1532
  } else {
@@ -1510,11 +1545,11 @@
1510
1545
  check_outros();
1511
1546
  }
1512
1547
 
1513
- if (/*$$slots*/ ctx[9]["no-results"] && !/*hideDropdown*/ ctx[5] && /*value*/ ctx[0].length > 0 && /*results*/ ctx[1].length === 0) {
1548
+ if (/*$$slots*/ ctx[10]["no-results"] && !/*hideDropdown*/ ctx[3] && /*value*/ ctx[0].length > 0 && /*results*/ ctx[1].length === 0) {
1514
1549
  if (if_block1) {
1515
1550
  if_block1.p(ctx, dirty);
1516
1551
 
1517
- if (dirty[0] & /*$$slots, hideDropdown, value, results*/ 547) {
1552
+ if (dirty[0] & /*$$slots, hideDropdown, value, results*/ 1035) {
1518
1553
  transition_in(if_block1, 1);
1519
1554
  }
1520
1555
  } else {
@@ -1545,8 +1580,8 @@
1545
1580
  attr(div, "aria-owns", div_aria_owns_value);
1546
1581
  }
1547
1582
 
1548
- if (!current || dirty[0] & /*hideDropdown, results*/ 34 && div_aria_expanded_value !== (div_aria_expanded_value = !/*hideDropdown*/ ctx[5] && /*results*/ ctx[1].length > 0)) {
1549
- attr(div, "aria-expanded", div_aria_expanded_value);
1583
+ if (!current || dirty[0] & /*showResults*/ 128) {
1584
+ attr(div, "aria-expanded", /*showResults*/ ctx[7]);
1550
1585
  }
1551
1586
 
1552
1587
  if (!current || dirty[0] & /*id*/ 4 && div_id_value !== (div_id_value = "" + (/*id*/ ctx[2] + "-typeahead"))) {
@@ -1575,7 +1610,7 @@
1575
1610
  destroy_component(search);
1576
1611
  if (if_block0) if_block0.d();
1577
1612
  if (if_block1) if_block1.d();
1578
- /*div_binding*/ ctx[36](null);
1613
+ /*div_binding*/ ctx[38](null);
1579
1614
  mounted = false;
1580
1615
  dispose();
1581
1616
  }
@@ -1585,6 +1620,7 @@
1585
1620
  function instance($$self, $$props, $$invalidate) {
1586
1621
  let options;
1587
1622
  let resultsId;
1623
+ let showResults;
1588
1624
 
1589
1625
  const omit_props_names = [
1590
1626
  "id","value","data","extract","disable","filter","autoselect","inputAfterSelect","results","focusAfterSelect","limit"
@@ -1617,7 +1653,7 @@
1617
1653
  }
1618
1654
 
1619
1655
  if (prevResults !== resultsId && !$$slots["no-results"]) {
1620
- $$invalidate(5, hideDropdown = results.length === 0);
1656
+ $$invalidate(3, hideDropdown = results.length === 0);
1621
1657
  }
1622
1658
 
1623
1659
  prevResults = resultsId;
@@ -1641,12 +1677,12 @@
1641
1677
 
1642
1678
  await tick();
1643
1679
  if (focusAfterSelect) searchRef.focus();
1644
- $$invalidate(5, hideDropdown = true);
1680
+ $$invalidate(3, hideDropdown = true);
1645
1681
  }
1646
1682
 
1647
1683
  /** @type {(direction: -1 | 1) => void} */
1648
1684
  function change(direction) {
1649
- let index = selectedIndex === results.length - 1
1685
+ let index = direction === 1 && selectedIndex === results.length - 1
1650
1686
  ? 0
1651
1687
  : selectedIndex + direction;
1652
1688
 
@@ -1668,13 +1704,13 @@
1668
1704
 
1669
1705
  const click_handler = ({ target }) => {
1670
1706
  if (!hideDropdown && comboboxRef && !comboboxRef.contains(target)) {
1671
- $$invalidate(5, hideDropdown = true);
1707
+ $$invalidate(3, hideDropdown = true);
1672
1708
  }
1673
1709
  };
1674
1710
 
1675
1711
  function search_ref_binding(value) {
1676
1712
  searchRef = value;
1677
- $$invalidate(4, searchRef);
1713
+ $$invalidate(5, searchRef);
1678
1714
  }
1679
1715
 
1680
1716
  function search_value_binding(value$1) {
@@ -1699,7 +1735,7 @@
1699
1735
  }
1700
1736
 
1701
1737
  const focus_handler_1 = () => {
1702
- $$invalidate(5, hideDropdown = false);
1738
+ $$invalidate(3, hideDropdown = false);
1703
1739
  };
1704
1740
 
1705
1741
  function clear_handler(event) {
@@ -1707,7 +1743,7 @@
1707
1743
  }
1708
1744
 
1709
1745
  const clear_handler_1 = () => {
1710
- $$invalidate(5, hideDropdown = false);
1746
+ $$invalidate(3, hideDropdown = false);
1711
1747
  };
1712
1748
 
1713
1749
  function blur_handler(event) {
@@ -1737,67 +1773,76 @@
1737
1773
  e.preventDefault();
1738
1774
  $$invalidate(0, value = "");
1739
1775
  searchRef.focus();
1740
- $$invalidate(5, hideDropdown = true);
1776
+ $$invalidate(3, hideDropdown = true);
1741
1777
  break;
1742
1778
  }
1743
1779
  };
1744
1780
 
1745
- const click_handler_1 = (result, i) => {
1746
- if (!result.disabled) {
1747
- $$invalidate(6, selectedIndex = i);
1748
- select();
1749
- }
1781
+ const click_handler_1 = (result, index) => {
1782
+ if (result.disabled) return;
1783
+ $$invalidate(6, selectedIndex = index);
1784
+ select();
1785
+ };
1786
+
1787
+ const mouseenter_handler = (result, index) => {
1788
+ if (result.disabled) return;
1789
+ $$invalidate(6, selectedIndex = index);
1750
1790
  };
1751
1791
 
1752
1792
  function div_binding($$value) {
1753
1793
  binding_callbacks[$$value ? 'unshift' : 'push'](() => {
1754
1794
  comboboxRef = $$value;
1755
- $$invalidate(3, comboboxRef);
1795
+ $$invalidate(4, comboboxRef);
1756
1796
  });
1757
1797
  }
1758
1798
 
1759
1799
  $$self.$$set = $$new_props => {
1760
1800
  $$props = assign(assign({}, $$props), exclude_internal_props($$new_props));
1761
- $$invalidate(10, $$restProps = compute_rest_props($$props, omit_props_names));
1801
+ $$invalidate(11, $$restProps = compute_rest_props($$props, omit_props_names));
1762
1802
  if ('id' in $$new_props) $$invalidate(2, id = $$new_props.id);
1763
1803
  if ('value' in $$new_props) $$invalidate(0, value = $$new_props.value);
1764
- if ('data' in $$new_props) $$invalidate(11, data = $$new_props.data);
1765
- if ('extract' in $$new_props) $$invalidate(12, extract = $$new_props.extract);
1766
- if ('disable' in $$new_props) $$invalidate(13, disable = $$new_props.disable);
1767
- if ('filter' in $$new_props) $$invalidate(14, filter = $$new_props.filter);
1768
- if ('autoselect' in $$new_props) $$invalidate(15, autoselect = $$new_props.autoselect);
1769
- if ('inputAfterSelect' in $$new_props) $$invalidate(16, inputAfterSelect = $$new_props.inputAfterSelect);
1804
+ if ('data' in $$new_props) $$invalidate(12, data = $$new_props.data);
1805
+ if ('extract' in $$new_props) $$invalidate(13, extract = $$new_props.extract);
1806
+ if ('disable' in $$new_props) $$invalidate(14, disable = $$new_props.disable);
1807
+ if ('filter' in $$new_props) $$invalidate(15, filter = $$new_props.filter);
1808
+ if ('autoselect' in $$new_props) $$invalidate(16, autoselect = $$new_props.autoselect);
1809
+ if ('inputAfterSelect' in $$new_props) $$invalidate(17, inputAfterSelect = $$new_props.inputAfterSelect);
1770
1810
  if ('results' in $$new_props) $$invalidate(1, results = $$new_props.results);
1771
- if ('focusAfterSelect' in $$new_props) $$invalidate(17, focusAfterSelect = $$new_props.focusAfterSelect);
1772
- if ('limit' in $$new_props) $$invalidate(18, limit = $$new_props.limit);
1773
- if ('$$scope' in $$new_props) $$invalidate(20, $$scope = $$new_props.$$scope);
1811
+ if ('focusAfterSelect' in $$new_props) $$invalidate(18, focusAfterSelect = $$new_props.focusAfterSelect);
1812
+ if ('limit' in $$new_props) $$invalidate(19, limit = $$new_props.limit);
1813
+ if ('$$scope' in $$new_props) $$invalidate(21, $$scope = $$new_props.$$scope);
1774
1814
  };
1775
1815
 
1776
1816
  $$self.$$.update = () => {
1777
- if ($$self.$$.dirty[0] & /*extract*/ 4096) {
1778
- $$invalidate(19, options = { pre: "<mark>", post: "</mark>", extract });
1817
+ if ($$self.$$.dirty[0] & /*extract*/ 8192) {
1818
+ $$invalidate(20, options = { pre: "<mark>", post: "</mark>", extract });
1779
1819
  }
1780
1820
 
1781
- if ($$self.$$.dirty[0] & /*value, data, options, limit, filter, disable*/ 813057) {
1821
+ if ($$self.$$.dirty[0] & /*value, data, options, limit, filter, disable*/ 1626113) {
1782
1822
  $$invalidate(1, results = fuzzy.filter(value, data, options).filter(({ score }) => score > 0).slice(0, limit).filter(result => !filter(result.original)).map(result => ({
1783
1823
  ...result,
1784
1824
  disabled: disable(result.original)
1785
1825
  })));
1786
1826
  }
1787
1827
 
1788
- if ($$self.$$.dirty[0] & /*results, extract*/ 4098) {
1828
+ if ($$self.$$.dirty[0] & /*results, extract*/ 8194) {
1789
1829
  resultsId = results.map(result => extract(result.original)).join("");
1790
1830
  }
1831
+
1832
+ if ($$self.$$.dirty[0] & /*hideDropdown, results*/ 10) {
1833
+ $$invalidate(7, showResults = !hideDropdown && results.length > 0);
1834
+ }
1791
1835
  };
1792
1836
 
1793
1837
  return [
1794
1838
  value,
1795
1839
  results,
1796
1840
  id,
1841
+ hideDropdown,
1797
1842
  comboboxRef,
1798
1843
  searchRef,
1799
- hideDropdown,
1800
1844
  selectedIndex,
1845
+ showResults,
1801
1846
  select,
1802
1847
  change,
1803
1848
  $$slots,
@@ -1827,6 +1872,7 @@
1827
1872
  keydown_handler,
1828
1873
  keydown_handler_1,
1829
1874
  click_handler_1,
1875
+ mouseenter_handler,
1830
1876
  div_binding
1831
1877
  ];
1832
1878
  }
@@ -1844,15 +1890,15 @@
1844
1890
  {
1845
1891
  id: 2,
1846
1892
  value: 0,
1847
- data: 11,
1848
- extract: 12,
1849
- disable: 13,
1850
- filter: 14,
1851
- autoselect: 15,
1852
- inputAfterSelect: 16,
1893
+ data: 12,
1894
+ extract: 13,
1895
+ disable: 14,
1896
+ filter: 15,
1897
+ autoselect: 16,
1898
+ inputAfterSelect: 17,
1853
1899
  results: 1,
1854
- focusAfterSelect: 17,
1855
- limit: 18
1900
+ focusAfterSelect: 18,
1901
+ limit: 19
1856
1902
  },
1857
1903
  add_css,
1858
1904
  [-1, -1]
@@ -1862,8 +1908,8 @@
1862
1908
 
1863
1909
  var Typeahead$1 = Typeahead;
1864
1910
 
1865
- exports['default'] = Typeahead$1;
1911
+ exports["default"] = Typeahead$1;
1866
1912
 
1867
1913
  Object.defineProperty(exports, '__esModule', { value: true });
1868
1914
 
1869
- })));
1915
+ }));