svelte-typeahead 4.2.0 → 4.2.3

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,7 +1062,7 @@ 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
1068
  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}");
@@ -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[39],
1051
- index: /*i*/ ctx[41]
1078
+ result: /*result*/ ctx[41],
1079
+ index: /*i*/ ctx[43]
1052
1080
  });
1053
1081
 
1054
1082
  function get_each_context(ctx, list, i) {
1055
1083
  const child_ctx = ctx.slice();
1056
- child_ctx[39] = list[i];
1057
- child_ctx[41] = i;
1084
+ child_ctx[41] = list[i];
1085
+ child_ctx[43] = 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[39],
1068
- index: /*i*/ ctx[41],
1095
+ result: /*result*/ ctx[41],
1096
+ index: /*i*/ ctx[43],
1069
1097
  value: /*value*/ ctx[0]
1070
1098
  });
1071
1099
 
1072
- // (180:4) {#if !hideDropdown && results.length > 0}
1100
+ // (198:4) {#if !hideDropdown && results.length > 0}
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*/ 524487) {
1132
+ if (dirty[0] & /*id, selectedIndex, results, select, $$scope, value*/ 1048775) {
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
- // (195:43)
1184
+ // (217:43)
1157
1185
  function fallback_block(ctx) {
1158
1186
  let html_tag;
1159
- let raw_value = /*result*/ ctx[39].string + "";
1187
+ let raw_value = /*result*/ ctx[41].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[39].string + "")) html_tag.p(raw_value);
1201
+ if (dirty[0] & /*results*/ 2 && raw_value !== (raw_value = /*result*/ ctx[41].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
- // (181:6) {#each results as result, i}
1210
+ // (199:6) {#each results as result, i}
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[20].default;
1192
- const default_slot = create_slot(default_slot_template, ctx, /*$$scope*/ ctx[19], get_default_slot_context);
1219
+ const default_slot_template = /*#slots*/ ctx[21].default;
1220
+ const default_slot = create_slot(default_slot_template, ctx, /*$$scope*/ ctx[20], 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[34](/*result*/ ctx[39], /*i*/ ctx[41]);
1224
+ return /*click_handler_1*/ ctx[35](/*result*/ ctx[41], /*i*/ ctx[43]);
1225
+ }
1226
+
1227
+ function mouseenter_handler() {
1228
+ return /*mouseenter_handler*/ ctx[36](/*result*/ ctx[41], /*i*/ ctx[43]);
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[41]));
1206
- attr(li, "aria-selected", li_aria_selected_value = /*selectedIndex*/ ctx[6] === /*i*/ ctx[41]);
1237
+ attr(li, "id", li_id_value = "" + (/*id*/ ctx[2] + "-result-" + /*i*/ ctx[43]));
1238
+ attr(li, "aria-selected", li_aria_selected_value = /*selectedIndex*/ ctx[6] === /*i*/ ctx[43]);
1207
1239
  attr(li, "class", "svelte-j5n77y");
1208
- toggle_class(li, "selected", /*selectedIndex*/ ctx[6] === /*i*/ ctx[41]);
1209
- toggle_class(li, "disabled", /*result*/ ctx[39].disabled);
1240
+ toggle_class(li, "selected", /*selectedIndex*/ ctx[6] === /*i*/ ctx[43]);
1241
+ toggle_class(li, "disabled", /*result*/ ctx[41].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*/ 524291)) {
1266
+ if (default_slot.p && (!current || dirty[0] & /*$$scope, results, value*/ 1048579)) {
1231
1267
  update_slot_base(
1232
1268
  default_slot,
1233
1269
  default_slot_template,
1234
1270
  ctx,
1235
- /*$$scope*/ ctx[19],
1271
+ /*$$scope*/ ctx[20],
1236
1272
  !current
1237
- ? get_all_dirty_from_scope(/*$$scope*/ ctx[19])
1238
- : get_slot_changes(default_slot_template, /*$$scope*/ ctx[19], dirty, get_default_slot_changes),
1273
+ ? get_all_dirty_from_scope(/*$$scope*/ ctx[20])
1274
+ : get_slot_changes(default_slot_template, /*$$scope*/ ctx[20], 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[41]))) {
1284
+ if (!current || dirty[0] & /*id*/ 4 && li_id_value !== (li_id_value = "" + (/*id*/ ctx[2] + "-result-" + /*i*/ ctx[43]))) {
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[41])) {
1288
+ if (!current || dirty[0] & /*selectedIndex*/ 64 && li_aria_selected_value !== (li_aria_selected_value = /*selectedIndex*/ ctx[6] === /*i*/ ctx[43])) {
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[41]);
1293
+ toggle_class(li, "selected", /*selectedIndex*/ ctx[6] === /*i*/ ctx[43]);
1258
1294
  }
1259
1295
 
1260
1296
  if (dirty[0] & /*results*/ 2) {
1261
- toggle_class(li, "disabled", /*result*/ ctx[39].disabled);
1297
+ toggle_class(li, "disabled", /*result*/ ctx[41].disabled);
1262
1298
  }
1263
1299
  },
1264
1300
  i(local) {
@@ -1274,17 +1310,17 @@ 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
- // (201:4) {#if $$slots["no-results"] && !hideDropdown && value.length > 0 && results.length === 0}
1318
+ // (223: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[20]["no-results"];
1287
- const no_results_slot = create_slot(no_results_slot_template, ctx, /*$$scope*/ ctx[19], get_no_results_slot_context);
1322
+ const no_results_slot_template = /*#slots*/ ctx[21]["no-results"];
1323
+ const no_results_slot = create_slot(no_results_slot_template, ctx, /*$$scope*/ ctx[20], get_no_results_slot_context);
1288
1324
 
1289
1325
  return {
1290
1326
  c() {
@@ -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*/ 524291)) {
1343
+ if (no_results_slot.p && (!current || dirty[0] & /*$$scope, value, results*/ 1048579)) {
1308
1344
  update_slot_base(
1309
1345
  no_results_slot,
1310
1346
  no_results_slot_template,
1311
1347
  ctx,
1312
- /*$$scope*/ ctx[19],
1348
+ /*$$scope*/ ctx[20],
1313
1349
  !current
1314
- ? get_all_dirty_from_scope(/*$$scope*/ ctx[19])
1315
- : get_slot_changes(no_results_slot_template, /*$$scope*/ ctx[19], dirty, get_no_results_slot_changes),
1350
+ ? get_all_dirty_from_scope(/*$$scope*/ ctx[20])
1351
+ : get_slot_changes(no_results_slot_template, /*$$scope*/ ctx[20], dirty, get_no_results_slot_changes),
1316
1352
  get_no_results_slot_context
1317
1353
  );
1318
1354
  }
@@ -1354,7 +1390,7 @@ function create_fragment(ctx) {
1354
1390
  const search_spread_levels = [
1355
1391
  { id: /*id*/ ctx[2] },
1356
1392
  { removeFormAriaAttributes: true },
1357
- /*$$restProps*/ ctx[9],
1393
+ /*$$restProps*/ ctx[10],
1358
1394
  { "aria-autocomplete": "list" },
1359
1395
  {
1360
1396
  "aria-controls": "" + (/*id*/ ctx[2] + "-listbox")
@@ -1370,11 +1406,11 @@ function create_fragment(ctx) {
1370
1406
  ];
1371
1407
 
1372
1408
  function search_ref_binding(value) {
1373
- /*search_ref_binding*/ ctx[22](value);
1409
+ /*search_ref_binding*/ ctx[23](value);
1374
1410
  }
1375
1411
 
1376
1412
  function search_value_binding(value) {
1377
- /*search_value_binding*/ ctx[23](value);
1413
+ /*search_value_binding*/ ctx[24](value);
1378
1414
  }
1379
1415
 
1380
1416
  let search_props = {};
@@ -1394,18 +1430,18 @@ function create_fragment(ctx) {
1394
1430
  search = new Search$1({ props: search_props });
1395
1431
  binding_callbacks.push(() => bind(search, 'ref', search_ref_binding));
1396
1432
  binding_callbacks.push(() => bind(search, 'value', search_value_binding));
1397
- search.$on("type", /*type_handler*/ ctx[24]);
1398
- search.$on("input", /*input_handler*/ ctx[25]);
1399
- search.$on("change", /*change_handler*/ ctx[26]);
1400
- search.$on("focus", /*focus_handler*/ ctx[27]);
1401
- search.$on("focus", /*focus_handler_1*/ ctx[28]);
1402
- search.$on("clear", /*clear_handler*/ ctx[29]);
1403
- search.$on("clear", /*clear_handler_1*/ ctx[30]);
1404
- search.$on("blur", /*blur_handler*/ ctx[31]);
1405
- search.$on("keydown", /*keydown_handler*/ ctx[32]);
1406
- search.$on("keydown", /*keydown_handler_1*/ ctx[33]);
1433
+ search.$on("type", /*type_handler*/ ctx[25]);
1434
+ search.$on("input", /*input_handler*/ ctx[26]);
1435
+ search.$on("change", /*change_handler*/ ctx[27]);
1436
+ search.$on("focus", /*focus_handler*/ ctx[28]);
1437
+ search.$on("focus", /*focus_handler_1*/ ctx[29]);
1438
+ search.$on("clear", /*clear_handler*/ ctx[30]);
1439
+ search.$on("clear", /*clear_handler_1*/ ctx[31]);
1440
+ search.$on("blur", /*blur_handler*/ ctx[32]);
1441
+ search.$on("keydown", /*keydown_handler*/ ctx[33]);
1442
+ search.$on("keydown", /*keydown_handler_1*/ ctx[34]);
1407
1443
  let if_block0 = !/*hideDropdown*/ ctx[5] && /*results*/ ctx[1].length > 0 && create_if_block_1(ctx);
1408
- let if_block1 = /*$$slots*/ ctx[8]["no-results"] && !/*hideDropdown*/ ctx[5] && /*value*/ ctx[0].length > 0 && /*results*/ ctx[1].length === 0 && create_if_block(ctx);
1444
+ 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);
1409
1445
 
1410
1446
  return {
1411
1447
  c() {
@@ -1438,20 +1474,20 @@ function create_fragment(ctx) {
1438
1474
  if (if_block0) if_block0.m(ul, null);
1439
1475
  append(ul, t1);
1440
1476
  if (if_block1) if_block1.m(ul, null);
1441
- /*div_binding*/ ctx[35](div);
1477
+ /*div_binding*/ ctx[37](div);
1442
1478
  current = true;
1443
1479
 
1444
1480
  if (!mounted) {
1445
- dispose = listen(window, "click", /*click_handler*/ ctx[21]);
1481
+ dispose = listen(window, "click", /*click_handler*/ ctx[22]);
1446
1482
  mounted = true;
1447
1483
  }
1448
1484
  },
1449
1485
  p(ctx, dirty) {
1450
- const search_changes = (dirty[0] & /*id, $$restProps, selectedIndex, hideDropdown, results*/ 614)
1486
+ const search_changes = (dirty[0] & /*id, $$restProps, selectedIndex, hideDropdown, results*/ 1126)
1451
1487
  ? get_spread_update(search_spread_levels, [
1452
1488
  dirty[0] & /*id*/ 4 && { id: /*id*/ ctx[2] },
1453
1489
  search_spread_levels[1],
1454
- dirty[0] & /*$$restProps*/ 512 && get_spread_object(/*$$restProps*/ ctx[9]),
1490
+ dirty[0] & /*$$restProps*/ 1024 && get_spread_object(/*$$restProps*/ ctx[10]),
1455
1491
  search_spread_levels[3],
1456
1492
  dirty[0] & /*id*/ 4 && {
1457
1493
  "aria-controls": "" + (/*id*/ ctx[2] + "-listbox")
@@ -1504,11 +1540,11 @@ function create_fragment(ctx) {
1504
1540
  check_outros();
1505
1541
  }
1506
1542
 
1507
- if (/*$$slots*/ ctx[8]["no-results"] && !/*hideDropdown*/ ctx[5] && /*value*/ ctx[0].length > 0 && /*results*/ ctx[1].length === 0) {
1543
+ if (/*$$slots*/ ctx[9]["no-results"] && !/*hideDropdown*/ ctx[5] && /*value*/ ctx[0].length > 0 && /*results*/ ctx[1].length === 0) {
1508
1544
  if (if_block1) {
1509
1545
  if_block1.p(ctx, dirty);
1510
1546
 
1511
- if (dirty[0] & /*$$slots, hideDropdown, value, results*/ 291) {
1547
+ if (dirty[0] & /*$$slots, hideDropdown, value, results*/ 547) {
1512
1548
  transition_in(if_block1, 1);
1513
1549
  }
1514
1550
  } else {
@@ -1569,7 +1605,7 @@ function create_fragment(ctx) {
1569
1605
  destroy_component(search);
1570
1606
  if (if_block0) if_block0.d();
1571
1607
  if (if_block1) if_block1.d();
1572
- /*div_binding*/ ctx[35](null);
1608
+ /*div_binding*/ ctx[37](null);
1573
1609
  mounted = false;
1574
1610
  dispose();
1575
1611
  }
@@ -1619,6 +1655,7 @@ function instance($$self, $$props, $$invalidate) {
1619
1655
 
1620
1656
  async function select() {
1621
1657
  const result = results[selectedIndex];
1658
+ if (result.disabled) return;
1622
1659
  const selectedValue = extract(result.original);
1623
1660
  const searchedValue = value;
1624
1661
  if (inputAfterSelect == "clear") $$invalidate(0, value = "");
@@ -1637,6 +1674,28 @@ function instance($$self, $$props, $$invalidate) {
1637
1674
  $$invalidate(5, hideDropdown = true);
1638
1675
  }
1639
1676
 
1677
+ /** @type {(direction: -1 | 1) => void} */
1678
+ function change(direction) {
1679
+ let index = direction === 1 && selectedIndex === results.length - 1
1680
+ ? 0
1681
+ : selectedIndex + direction;
1682
+
1683
+ if (index < 0) index = results.length - 1;
1684
+ let disabled = results[index].disabled;
1685
+
1686
+ while (disabled) {
1687
+ if (index === results.length) {
1688
+ index = 0;
1689
+ } else {
1690
+ index += direction;
1691
+ }
1692
+
1693
+ disabled = results[index].disabled;
1694
+ }
1695
+
1696
+ $$invalidate(6, selectedIndex = index);
1697
+ }
1698
+
1640
1699
  const click_handler = ({ target }) => {
1641
1700
  if (!hideDropdown && comboboxRef && !comboboxRef.contains(target)) {
1642
1701
  $$invalidate(5, hideDropdown = true);
@@ -1698,17 +1757,11 @@ function instance($$self, $$props, $$invalidate) {
1698
1757
  break;
1699
1758
  case "ArrowDown":
1700
1759
  e.preventDefault();
1701
- $$invalidate(6, selectedIndex += 1);
1702
- if (selectedIndex === results.length) {
1703
- $$invalidate(6, selectedIndex = 0);
1704
- }
1760
+ change(1);
1705
1761
  break;
1706
1762
  case "ArrowUp":
1707
1763
  e.preventDefault();
1708
- $$invalidate(6, selectedIndex -= 1);
1709
- if (selectedIndex < 0) {
1710
- $$invalidate(6, selectedIndex = results.length - 1);
1711
- }
1764
+ change(-1);
1712
1765
  break;
1713
1766
  case "Escape":
1714
1767
  e.preventDefault();
@@ -1726,6 +1779,11 @@ function instance($$self, $$props, $$invalidate) {
1726
1779
  }
1727
1780
  };
1728
1781
 
1782
+ const mouseenter_handler = (result, i) => {
1783
+ if (result.disabled) return;
1784
+ $$invalidate(6, selectedIndex = i);
1785
+ };
1786
+
1729
1787
  function div_binding($$value) {
1730
1788
  binding_callbacks[$$value ? 'unshift' : 'push'](() => {
1731
1789
  comboboxRef = $$value;
@@ -1735,34 +1793,34 @@ function instance($$self, $$props, $$invalidate) {
1735
1793
 
1736
1794
  $$self.$$set = $$new_props => {
1737
1795
  $$props = assign(assign({}, $$props), exclude_internal_props($$new_props));
1738
- $$invalidate(9, $$restProps = compute_rest_props($$props, omit_props_names));
1796
+ $$invalidate(10, $$restProps = compute_rest_props($$props, omit_props_names));
1739
1797
  if ('id' in $$new_props) $$invalidate(2, id = $$new_props.id);
1740
1798
  if ('value' in $$new_props) $$invalidate(0, value = $$new_props.value);
1741
- if ('data' in $$new_props) $$invalidate(10, data = $$new_props.data);
1742
- if ('extract' in $$new_props) $$invalidate(11, extract = $$new_props.extract);
1743
- if ('disable' in $$new_props) $$invalidate(12, disable = $$new_props.disable);
1744
- if ('filter' in $$new_props) $$invalidate(13, filter = $$new_props.filter);
1745
- if ('autoselect' in $$new_props) $$invalidate(14, autoselect = $$new_props.autoselect);
1746
- if ('inputAfterSelect' in $$new_props) $$invalidate(15, inputAfterSelect = $$new_props.inputAfterSelect);
1799
+ if ('data' in $$new_props) $$invalidate(11, data = $$new_props.data);
1800
+ if ('extract' in $$new_props) $$invalidate(12, extract = $$new_props.extract);
1801
+ if ('disable' in $$new_props) $$invalidate(13, disable = $$new_props.disable);
1802
+ if ('filter' in $$new_props) $$invalidate(14, filter = $$new_props.filter);
1803
+ if ('autoselect' in $$new_props) $$invalidate(15, autoselect = $$new_props.autoselect);
1804
+ if ('inputAfterSelect' in $$new_props) $$invalidate(16, inputAfterSelect = $$new_props.inputAfterSelect);
1747
1805
  if ('results' in $$new_props) $$invalidate(1, results = $$new_props.results);
1748
- if ('focusAfterSelect' in $$new_props) $$invalidate(16, focusAfterSelect = $$new_props.focusAfterSelect);
1749
- if ('limit' in $$new_props) $$invalidate(17, limit = $$new_props.limit);
1750
- if ('$$scope' in $$new_props) $$invalidate(19, $$scope = $$new_props.$$scope);
1806
+ if ('focusAfterSelect' in $$new_props) $$invalidate(17, focusAfterSelect = $$new_props.focusAfterSelect);
1807
+ if ('limit' in $$new_props) $$invalidate(18, limit = $$new_props.limit);
1808
+ if ('$$scope' in $$new_props) $$invalidate(20, $$scope = $$new_props.$$scope);
1751
1809
  };
1752
1810
 
1753
1811
  $$self.$$.update = () => {
1754
- if ($$self.$$.dirty[0] & /*extract*/ 2048) {
1755
- $$invalidate(18, options = { pre: "<mark>", post: "</mark>", extract });
1812
+ if ($$self.$$.dirty[0] & /*extract*/ 4096) {
1813
+ $$invalidate(19, options = { pre: "<mark>", post: "</mark>", extract });
1756
1814
  }
1757
1815
 
1758
- if ($$self.$$.dirty[0] & /*value, data, options, limit, filter, disable*/ 406529) {
1816
+ if ($$self.$$.dirty[0] & /*value, data, options, limit, filter, disable*/ 813057) {
1759
1817
  $$invalidate(1, results = fuzzy.filter(value, data, options).filter(({ score }) => score > 0).slice(0, limit).filter(result => !filter(result.original)).map(result => ({
1760
1818
  ...result,
1761
1819
  disabled: disable(result.original)
1762
1820
  })));
1763
1821
  }
1764
1822
 
1765
- if ($$self.$$.dirty[0] & /*results, extract*/ 2050) {
1823
+ if ($$self.$$.dirty[0] & /*results, extract*/ 4098) {
1766
1824
  resultsId = results.map(result => extract(result.original)).join("");
1767
1825
  }
1768
1826
  };
@@ -1776,6 +1834,7 @@ function instance($$self, $$props, $$invalidate) {
1776
1834
  hideDropdown,
1777
1835
  selectedIndex,
1778
1836
  select,
1837
+ change,
1779
1838
  $$slots,
1780
1839
  $$restProps,
1781
1840
  data,
@@ -1803,6 +1862,7 @@ function instance($$self, $$props, $$invalidate) {
1803
1862
  keydown_handler,
1804
1863
  keydown_handler_1,
1805
1864
  click_handler_1,
1865
+ mouseenter_handler,
1806
1866
  div_binding
1807
1867
  ];
1808
1868
  }
@@ -1820,15 +1880,15 @@ class Typeahead extends SvelteComponent {
1820
1880
  {
1821
1881
  id: 2,
1822
1882
  value: 0,
1823
- data: 10,
1824
- extract: 11,
1825
- disable: 12,
1826
- filter: 13,
1827
- autoselect: 14,
1828
- inputAfterSelect: 15,
1883
+ data: 11,
1884
+ extract: 12,
1885
+ disable: 13,
1886
+ filter: 14,
1887
+ autoselect: 15,
1888
+ inputAfterSelect: 16,
1829
1889
  results: 1,
1830
- focusAfterSelect: 16,
1831
- limit: 17
1890
+ focusAfterSelect: 17,
1891
+ limit: 18
1832
1892
  },
1833
1893
  add_css,
1834
1894
  [-1, -1]
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "svelte-typeahead",
3
- "version": "4.2.0",
3
+ "version": "4.2.3",
4
4
  "license": "MIT",
5
5
  "description": "Accessible, fuzzy search typeahead component",
6
6
  "author": "Eric Liu (https://github.com/metonym)",
@@ -21,10 +21,10 @@
21
21
  "svelte-search": "^1.1.0"
22
22
  },
23
23
  "devDependencies": {
24
- "@rollup/plugin-commonjs": "^21.0.1",
25
- "svelte": "^3.44.0",
26
- "svelte-check": "^2.2.6",
27
- "svelte-readme": "^3.4.1"
24
+ "@rollup/plugin-commonjs": "^21.0.2",
25
+ "svelte": "^3.48.0",
26
+ "svelte-check": "^2.8.0",
27
+ "svelte-readme": "^3.6.3"
28
28
  },
29
29
  "repository": {
30
30
  "type": "git",