svelte-typeahead 4.3.2 → 4.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/lib/index.mjs CHANGED
@@ -114,6 +114,7 @@ function get_root_for_style(node) {
114
114
  }
115
115
  function append_stylesheet(node, style) {
116
116
  append(node.head || node, style);
117
+ return style.sheet;
117
118
  }
118
119
  function insert(target, node, anchor) {
119
120
  target.insertBefore(node, anchor || null);
@@ -247,12 +248,38 @@ function get_current_component() {
247
248
  throw new Error('Function called outside component initialization');
248
249
  return current_component;
249
250
  }
251
+ /**
252
+ * The `onMount` function schedules a callback to run as soon as the component has been mounted to the DOM.
253
+ * It must be called during the component's initialisation (but doesn't need to live *inside* the component;
254
+ * it can be called from an external module).
255
+ *
256
+ * `onMount` does not run inside a [server-side component](/docs#run-time-server-side-component-api).
257
+ *
258
+ * https://svelte.dev/docs#run-time-svelte-onmount
259
+ */
250
260
  function onMount(fn) {
251
261
  get_current_component().$$.on_mount.push(fn);
252
262
  }
263
+ /**
264
+ * Schedules a callback to run immediately after the component has been updated.
265
+ *
266
+ * The first time the callback runs will be after the initial `onMount`
267
+ */
253
268
  function afterUpdate(fn) {
254
269
  get_current_component().$$.after_update.push(fn);
255
270
  }
271
+ /**
272
+ * Creates an event dispatcher that can be used to dispatch [component events](/docs#template-syntax-component-directives-on-eventname).
273
+ * Event dispatchers are functions that can take two arguments: `name` and `detail`.
274
+ *
275
+ * Component events created with `createEventDispatcher` create a
276
+ * [CustomEvent](https://developer.mozilla.org/en-US/docs/Web/API/CustomEvent).
277
+ * These events do not [bubble](https://developer.mozilla.org/en-US/docs/Learn/JavaScript/Building_blocks/Events#Event_bubbling_and_capture).
278
+ * The `detail` argument corresponds to the [CustomEvent.detail](https://developer.mozilla.org/en-US/docs/Web/API/CustomEvent/detail)
279
+ * property and can contain any type of data.
280
+ *
281
+ * https://svelte.dev/docs#run-time-svelte-createeventdispatcher
282
+ */
256
283
  function createEventDispatcher() {
257
284
  const component = get_current_component();
258
285
  return (type, detail, { cancelable = false } = {}) => {
@@ -457,14 +484,17 @@ function create_component(block) {
457
484
  block && block.c();
458
485
  }
459
486
  function mount_component(component, target, anchor, customElement) {
460
- const { fragment, on_mount, on_destroy, after_update } = component.$$;
487
+ const { fragment, after_update } = component.$$;
461
488
  fragment && fragment.m(target, anchor);
462
489
  if (!customElement) {
463
490
  // onMount happens before the initial afterUpdate
464
491
  add_render_callback(() => {
465
- const new_on_destroy = on_mount.map(run).filter(is_function);
466
- if (on_destroy) {
467
- on_destroy.push(...new_on_destroy);
492
+ const new_on_destroy = component.$$.on_mount.map(run).filter(is_function);
493
+ // if the component was destroyed immediately
494
+ // it will update the `$$.on_destroy` reference to `null`.
495
+ // the destructured on_destroy may still reference to the old array
496
+ if (component.$$.on_destroy) {
497
+ component.$$.on_destroy.push(...new_on_destroy);
468
498
  }
469
499
  else {
470
500
  // Edge case - component was destroyed immediately,
@@ -500,7 +530,7 @@ function init(component, options, instance, create_fragment, not_equal, props, a
500
530
  set_current_component(component);
501
531
  const $$ = component.$$ = {
502
532
  fragment: null,
503
- ctx: null,
533
+ ctx: [],
504
534
  // state
505
535
  props,
506
536
  update: noop,
@@ -565,6 +595,9 @@ class SvelteComponent {
565
595
  this.$destroy = noop;
566
596
  }
567
597
  $on(type, callback) {
598
+ if (!is_function(callback)) {
599
+ return noop;
600
+ }
568
601
  const callbacks = (this.$$.callbacks[type] || (this.$$.callbacks[type] = []));
569
602
  callbacks.push(callback);
570
603
  return () => {
@@ -728,7 +761,7 @@ fuzzy.filter = function(pattern, arr, opts) {
728
761
 
729
762
  var fuzzy = fuzzy$1.exports;
730
763
 
731
- /* node_modules/svelte-search/src/Search.svelte generated by Svelte v3.49.0 */
764
+ /* node_modules/svelte-search/src/Search.svelte generated by Svelte v3.52.0 */
732
765
 
733
766
  function add_css$1(target) {
734
767
  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}");
@@ -865,7 +898,7 @@ function create_fragment$1(ctx) {
865
898
  attr(label_1, "for", /*id*/ ctx[4]);
866
899
  }
867
900
 
868
- if (dirty & /*hideLabel*/ 8) {
901
+ if (!current || dirty & /*hideLabel*/ 8) {
869
902
  toggle_class(label_1, "hide-label", /*hideLabel*/ ctx[3]);
870
903
  }
871
904
 
@@ -1065,10 +1098,10 @@ class Search extends SvelteComponent {
1065
1098
 
1066
1099
  var Search$1 = Search;
1067
1100
 
1068
- /* src/Typeahead.svelte generated by Svelte v3.49.0 */
1101
+ /* src/Typeahead.svelte generated by Svelte v3.52.0 */
1069
1102
 
1070
1103
  function add_css(target) {
1071
- append_styles(target, "svelte-9wywte", "[data-svelte-typeahead].svelte-9wywte.svelte-9wywte{position:relative;background-color:#fff}ul.svelte-9wywte.svelte-9wywte{position:absolute;top:100%;left:0;width:100%;padding:0;list-style:none;background-color:inherit;box-shadow:0 4px 8px rgba(0, 0, 0, 0.1)}[aria-expanded=\"true\"].svelte-9wywte ul.svelte-9wywte{z-index:1}li.svelte-9wywte.svelte-9wywte,.no-results.svelte-9wywte.svelte-9wywte{padding:0.25rem 1rem}li.svelte-9wywte.svelte-9wywte{cursor:pointer}li.svelte-9wywte.svelte-9wywte:not(:last-of-type){border-bottom:1px solid #e0e0e0}li.svelte-9wywte.svelte-9wywte:hover{background-color:#e5e5e5}.selected.svelte-9wywte.svelte-9wywte{background-color:#e5e5e5}.selected.svelte-9wywte.svelte-9wywte:hover{background-color:#cacaca}.disabled.svelte-9wywte.svelte-9wywte{opacity:0.4;cursor:not-allowed}[data-svelte-search] label{margin-bottom:0.25rem;display:inline-flex;font-size:0.875rem}[data-svelte-search] input{width:100%;padding:0.5rem 0.75rem;background:none;font-size:1rem;border:0;border-radius:0;border:1px solid #e5e5e5}[data-svelte-search] input:focus{outline-color:#0f62fe;outline-offset:2px;outline-width:1px}");
1104
+ append_styles(target, "svelte-1t4elht", "[data-svelte-typeahead].svelte-1t4elht.svelte-1t4elht{position:relative;background-color:#fff}ul.svelte-1t4elht.svelte-1t4elht{position:absolute;top:100%;left:0;width:100%;margin:0;padding:0;list-style:none;background-color:inherit;box-shadow:0 4px 8px rgba(0, 0, 0, 0.1)}[aria-expanded=\"true\"].svelte-1t4elht ul.svelte-1t4elht{z-index:1}li.svelte-1t4elht.svelte-1t4elht,.no-results.svelte-1t4elht.svelte-1t4elht{padding:0.25rem 1rem}li.svelte-1t4elht.svelte-1t4elht{cursor:pointer}li.svelte-1t4elht.svelte-1t4elht:not(:last-of-type){border-bottom:1px solid #e0e0e0}li.svelte-1t4elht.svelte-1t4elht:hover{background-color:#e5e5e5}.selected.svelte-1t4elht.svelte-1t4elht{background-color:#e5e5e5}.selected.svelte-1t4elht.svelte-1t4elht:hover{background-color:#cacaca}.disabled.svelte-1t4elht.svelte-1t4elht{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}");
1072
1105
  }
1073
1106
 
1074
1107
  const get_no_results_slot_changes = dirty => ({
@@ -1078,14 +1111,14 @@ const get_no_results_slot_changes = dirty => ({
1078
1111
 
1079
1112
  const get_no_results_slot_context = ctx => ({
1080
1113
  value: /*value*/ ctx[0],
1081
- result: /*result*/ ctx[46],
1082
- index: /*index*/ ctx[48]
1114
+ result: /*result*/ ctx[47],
1115
+ index: /*index*/ ctx[49]
1083
1116
  });
1084
1117
 
1085
1118
  function get_each_context(ctx, list, i) {
1086
1119
  const child_ctx = ctx.slice();
1087
- child_ctx[46] = list[i];
1088
- child_ctx[48] = i;
1120
+ child_ctx[47] = list[i];
1121
+ child_ctx[49] = i;
1089
1122
  return child_ctx;
1090
1123
  }
1091
1124
 
@@ -1095,12 +1128,12 @@ const get_default_slot_changes = dirty => ({
1095
1128
  });
1096
1129
 
1097
1130
  const get_default_slot_context = ctx => ({
1098
- result: /*result*/ ctx[46],
1099
- index: /*index*/ ctx[48],
1131
+ result: /*result*/ ctx[47],
1132
+ index: /*index*/ ctx[49],
1100
1133
  value: /*value*/ ctx[0]
1101
1134
  });
1102
1135
 
1103
- // (230:4) {#if showResults}
1136
+ // (248:4) {#if showResults}
1104
1137
  function create_if_block_1(ctx) {
1105
1138
  let each_1_anchor;
1106
1139
  let current;
@@ -1132,7 +1165,7 @@ function create_if_block_1(ctx) {
1132
1165
  current = true;
1133
1166
  },
1134
1167
  p(ctx, dirty) {
1135
- if (dirty[0] & /*id, selectedIndex, results, select, $$scope, value*/ 33555975) {
1168
+ if (dirty[0] & /*id, selectedIndex, results, select, $$scope, value*/ 67111943) {
1136
1169
  each_value = /*results*/ ctx[1];
1137
1170
  let i;
1138
1171
 
@@ -1184,10 +1217,10 @@ function create_if_block_1(ctx) {
1184
1217
  };
1185
1218
  }
1186
1219
 
1187
- // (248:41)
1220
+ // (267:41)
1188
1221
  function fallback_block(ctx) {
1189
1222
  let html_tag;
1190
- let raw_value = /*result*/ ctx[46].string + "";
1223
+ let raw_value = /*result*/ ctx[47].string + "";
1191
1224
  let html_anchor;
1192
1225
 
1193
1226
  return {
@@ -1201,7 +1234,7 @@ function fallback_block(ctx) {
1201
1234
  insert(target, html_anchor, anchor);
1202
1235
  },
1203
1236
  p(ctx, dirty) {
1204
- if (dirty[0] & /*results*/ 2 && raw_value !== (raw_value = /*result*/ ctx[46].string + "")) html_tag.p(raw_value);
1237
+ if (dirty[0] & /*results*/ 2 && raw_value !== (raw_value = /*result*/ ctx[47].string + "")) html_tag.p(raw_value);
1205
1238
  },
1206
1239
  d(detaching) {
1207
1240
  if (detaching) detach(html_anchor);
@@ -1210,7 +1243,7 @@ function fallback_block(ctx) {
1210
1243
  };
1211
1244
  }
1212
1245
 
1213
- // (231:6) {#each results as result, index}
1246
+ // (249:6) {#each results as result, index}
1214
1247
  function create_each_block(ctx) {
1215
1248
  let li;
1216
1249
  let t;
@@ -1219,16 +1252,16 @@ function create_each_block(ctx) {
1219
1252
  let current;
1220
1253
  let mounted;
1221
1254
  let dispose;
1222
- const default_slot_template = /*#slots*/ ctx[26].default;
1223
- const default_slot = create_slot(default_slot_template, ctx, /*$$scope*/ ctx[25], get_default_slot_context);
1255
+ const default_slot_template = /*#slots*/ ctx[27].default;
1256
+ const default_slot = create_slot(default_slot_template, ctx, /*$$scope*/ ctx[26], get_default_slot_context);
1224
1257
  const default_slot_or_fallback = default_slot || fallback_block(ctx);
1225
1258
 
1226
1259
  function click_handler_1() {
1227
- return /*click_handler_1*/ ctx[39](/*result*/ ctx[46], /*index*/ ctx[48]);
1260
+ return /*click_handler_1*/ ctx[40](/*result*/ ctx[47], /*index*/ ctx[49]);
1228
1261
  }
1229
1262
 
1230
1263
  function mouseenter_handler() {
1231
- return /*mouseenter_handler*/ ctx[40](/*result*/ ctx[46], /*index*/ ctx[48]);
1264
+ return /*mouseenter_handler*/ ctx[41](/*result*/ ctx[47], /*index*/ ctx[49]);
1232
1265
  }
1233
1266
 
1234
1267
  return {
@@ -1237,11 +1270,11 @@ function create_each_block(ctx) {
1237
1270
  if (default_slot_or_fallback) default_slot_or_fallback.c();
1238
1271
  t = space();
1239
1272
  attr(li, "role", "option");
1240
- attr(li, "id", li_id_value = "" + (/*id*/ ctx[2] + "-result-" + /*index*/ ctx[48]));
1241
- attr(li, "aria-selected", li_aria_selected_value = /*selectedIndex*/ ctx[9] === /*index*/ ctx[48]);
1242
- attr(li, "class", "svelte-9wywte");
1243
- toggle_class(li, "selected", /*selectedIndex*/ ctx[9] === /*index*/ ctx[48]);
1244
- toggle_class(li, "disabled", /*result*/ ctx[46].disabled);
1273
+ attr(li, "id", li_id_value = "" + (/*id*/ ctx[2] + "-result-" + /*index*/ ctx[49]));
1274
+ attr(li, "aria-selected", li_aria_selected_value = /*selectedIndex*/ ctx[10] === /*index*/ ctx[49]);
1275
+ attr(li, "class", "svelte-1t4elht");
1276
+ toggle_class(li, "selected", /*selectedIndex*/ ctx[10] === /*index*/ ctx[49]);
1277
+ toggle_class(li, "disabled", /*result*/ ctx[47].disabled);
1245
1278
  },
1246
1279
  m(target, anchor) {
1247
1280
  insert(target, li, anchor);
@@ -1266,15 +1299,15 @@ function create_each_block(ctx) {
1266
1299
  ctx = new_ctx;
1267
1300
 
1268
1301
  if (default_slot) {
1269
- if (default_slot.p && (!current || dirty[0] & /*$$scope, results, value*/ 33554435)) {
1302
+ if (default_slot.p && (!current || dirty[0] & /*$$scope, results, value*/ 67108867)) {
1270
1303
  update_slot_base(
1271
1304
  default_slot,
1272
1305
  default_slot_template,
1273
1306
  ctx,
1274
- /*$$scope*/ ctx[25],
1307
+ /*$$scope*/ ctx[26],
1275
1308
  !current
1276
- ? get_all_dirty_from_scope(/*$$scope*/ ctx[25])
1277
- : get_slot_changes(default_slot_template, /*$$scope*/ ctx[25], dirty, get_default_slot_changes),
1309
+ ? get_all_dirty_from_scope(/*$$scope*/ ctx[26])
1310
+ : get_slot_changes(default_slot_template, /*$$scope*/ ctx[26], dirty, get_default_slot_changes),
1278
1311
  get_default_slot_context
1279
1312
  );
1280
1313
  }
@@ -1284,20 +1317,20 @@ function create_each_block(ctx) {
1284
1317
  }
1285
1318
  }
1286
1319
 
1287
- if (!current || dirty[0] & /*id*/ 4 && li_id_value !== (li_id_value = "" + (/*id*/ ctx[2] + "-result-" + /*index*/ ctx[48]))) {
1320
+ if (!current || dirty[0] & /*id*/ 4 && li_id_value !== (li_id_value = "" + (/*id*/ ctx[2] + "-result-" + /*index*/ ctx[49]))) {
1288
1321
  attr(li, "id", li_id_value);
1289
1322
  }
1290
1323
 
1291
- if (!current || dirty[0] & /*selectedIndex*/ 512 && li_aria_selected_value !== (li_aria_selected_value = /*selectedIndex*/ ctx[9] === /*index*/ ctx[48])) {
1324
+ if (!current || dirty[0] & /*selectedIndex*/ 1024 && li_aria_selected_value !== (li_aria_selected_value = /*selectedIndex*/ ctx[10] === /*index*/ ctx[49])) {
1292
1325
  attr(li, "aria-selected", li_aria_selected_value);
1293
1326
  }
1294
1327
 
1295
- if (dirty[0] & /*selectedIndex*/ 512) {
1296
- toggle_class(li, "selected", /*selectedIndex*/ ctx[9] === /*index*/ ctx[48]);
1328
+ if (!current || dirty[0] & /*selectedIndex*/ 1024) {
1329
+ toggle_class(li, "selected", /*selectedIndex*/ ctx[10] === /*index*/ ctx[49]);
1297
1330
  }
1298
1331
 
1299
- if (dirty[0] & /*results*/ 2) {
1300
- toggle_class(li, "disabled", /*result*/ ctx[46].disabled);
1332
+ if (!current || dirty[0] & /*results*/ 2) {
1333
+ toggle_class(li, "disabled", /*result*/ ctx[47].disabled);
1301
1334
  }
1302
1335
  },
1303
1336
  i(local) {
@@ -1318,18 +1351,18 @@ function create_each_block(ctx) {
1318
1351
  };
1319
1352
  }
1320
1353
 
1321
- // (254:4) {#if $$slots["no-results"] && !hideDropdown && value.length > 0 && results.length === 0}
1354
+ // (273:4) {#if $$slots["no-results"] && !hideDropdown && value.length > 0 && results.length === 0}
1322
1355
  function create_if_block(ctx) {
1323
1356
  let div;
1324
1357
  let current;
1325
- const no_results_slot_template = /*#slots*/ ctx[26]["no-results"];
1326
- const no_results_slot = create_slot(no_results_slot_template, ctx, /*$$scope*/ ctx[25], get_no_results_slot_context);
1358
+ const no_results_slot_template = /*#slots*/ ctx[27]["no-results"];
1359
+ const no_results_slot = create_slot(no_results_slot_template, ctx, /*$$scope*/ ctx[26], get_no_results_slot_context);
1327
1360
 
1328
1361
  return {
1329
1362
  c() {
1330
1363
  div = element("div");
1331
1364
  if (no_results_slot) no_results_slot.c();
1332
- attr(div, "class", "svelte-9wywte");
1365
+ attr(div, "class", "svelte-1t4elht");
1333
1366
  toggle_class(div, "no-results", true);
1334
1367
  },
1335
1368
  m(target, anchor) {
@@ -1343,15 +1376,15 @@ function create_if_block(ctx) {
1343
1376
  },
1344
1377
  p(ctx, dirty) {
1345
1378
  if (no_results_slot) {
1346
- if (no_results_slot.p && (!current || dirty[0] & /*$$scope, value, results*/ 33554435)) {
1379
+ if (no_results_slot.p && (!current || dirty[0] & /*$$scope, value, results*/ 67108867)) {
1347
1380
  update_slot_base(
1348
1381
  no_results_slot,
1349
1382
  no_results_slot_template,
1350
1383
  ctx,
1351
- /*$$scope*/ ctx[25],
1384
+ /*$$scope*/ ctx[26],
1352
1385
  !current
1353
- ? get_all_dirty_from_scope(/*$$scope*/ ctx[25])
1354
- : get_slot_changes(no_results_slot_template, /*$$scope*/ ctx[25], dirty, get_no_results_slot_changes),
1386
+ ? get_all_dirty_from_scope(/*$$scope*/ ctx[26])
1387
+ : get_slot_changes(no_results_slot_template, /*$$scope*/ ctx[26], dirty, get_no_results_slot_changes),
1355
1388
  get_no_results_slot_context
1356
1389
  );
1357
1390
  }
@@ -1392,7 +1425,7 @@ function create_fragment(ctx) {
1392
1425
  const search_spread_levels = [
1393
1426
  { id: /*id*/ ctx[2] },
1394
1427
  { removeFormAriaAttributes: true },
1395
- /*$$restProps*/ ctx[15],
1428
+ /*$$restProps*/ ctx[16],
1396
1429
  { "aria-autocomplete": "list" },
1397
1430
  {
1398
1431
  "aria-controls": "" + (/*id*/ ctx[2] + "-listbox")
@@ -1401,18 +1434,18 @@ function create_fragment(ctx) {
1401
1434
  "aria-labelledby": "" + (/*id*/ ctx[2] + "-label")
1402
1435
  },
1403
1436
  {
1404
- "aria-activedescendant": /*selectedIndex*/ ctx[9] >= 0 && !/*hideDropdown*/ ctx[4] && /*results*/ ctx[1].length > 0
1405
- ? `${/*id*/ ctx[2]}-result-${/*selectedIndex*/ ctx[9]}`
1437
+ "aria-activedescendant": /*selectedIndex*/ ctx[10] >= 0 && !/*hideDropdown*/ ctx[5] && /*results*/ ctx[1].length > 0
1438
+ ? `${/*id*/ ctx[2]}-result-${/*selectedIndex*/ ctx[10]}`
1406
1439
  : null
1407
1440
  }
1408
1441
  ];
1409
1442
 
1410
1443
  function search_ref_binding(value) {
1411
- /*search_ref_binding*/ ctx[28](value);
1444
+ /*search_ref_binding*/ ctx[29](value);
1412
1445
  }
1413
1446
 
1414
1447
  function search_value_binding(value) {
1415
- /*search_value_binding*/ ctx[29](value);
1448
+ /*search_value_binding*/ ctx[30](value);
1416
1449
  }
1417
1450
 
1418
1451
  let search_props = {};
@@ -1421,8 +1454,8 @@ function create_fragment(ctx) {
1421
1454
  search_props = assign(search_props, search_spread_levels[i]);
1422
1455
  }
1423
1456
 
1424
- if (/*searchRef*/ ctx[8] !== void 0) {
1425
- search_props.ref = /*searchRef*/ ctx[8];
1457
+ if (/*searchRef*/ ctx[9] !== void 0) {
1458
+ search_props.ref = /*searchRef*/ ctx[9];
1426
1459
  }
1427
1460
 
1428
1461
  if (/*value*/ ctx[0] !== void 0) {
@@ -1432,18 +1465,18 @@ function create_fragment(ctx) {
1432
1465
  search = new Search$1({ props: search_props });
1433
1466
  binding_callbacks.push(() => bind(search, 'ref', search_ref_binding));
1434
1467
  binding_callbacks.push(() => bind(search, 'value', search_value_binding));
1435
- search.$on("type", /*type_handler*/ ctx[30]);
1436
- search.$on("input", /*input_handler*/ ctx[31]);
1437
- search.$on("change", /*change_handler*/ ctx[32]);
1438
- search.$on("focus", /*focus_handler*/ ctx[33]);
1439
- search.$on("focus", /*focus_handler_1*/ ctx[34]);
1440
- search.$on("clear", /*clear_handler*/ ctx[35]);
1441
- search.$on("clear", /*open*/ ctx[12]);
1442
- search.$on("blur", /*blur_handler*/ ctx[36]);
1443
- search.$on("keydown", /*keydown_handler*/ ctx[37]);
1444
- search.$on("keydown", /*keydown_handler_1*/ ctx[38]);
1445
- let if_block0 = /*showResults*/ ctx[6] && create_if_block_1(ctx);
1446
- let if_block1 = /*$$slots*/ ctx[14]["no-results"] && !/*hideDropdown*/ ctx[4] && /*value*/ ctx[0].length > 0 && /*results*/ ctx[1].length === 0 && create_if_block(ctx);
1468
+ search.$on("type", /*type_handler*/ ctx[31]);
1469
+ search.$on("input", /*input_handler*/ ctx[32]);
1470
+ search.$on("change", /*change_handler*/ ctx[33]);
1471
+ search.$on("focus", /*focus_handler*/ ctx[34]);
1472
+ search.$on("focus", /*focus_handler_1*/ ctx[35]);
1473
+ search.$on("clear", /*clear_handler*/ ctx[36]);
1474
+ search.$on("clear", /*open*/ ctx[13]);
1475
+ search.$on("blur", /*blur_handler*/ ctx[37]);
1476
+ search.$on("keydown", /*keydown_handler*/ ctx[38]);
1477
+ search.$on("keydown", /*keydown_handler_1*/ ctx[39]);
1478
+ let if_block0 = /*showResults*/ ctx[7] && create_if_block_1(ctx);
1479
+ let if_block1 = /*$$slots*/ ctx[15]["no-results"] && !/*hideDropdown*/ ctx[5] && /*value*/ ctx[0].length > 0 && /*results*/ ctx[1].length === 0 && create_if_block(ctx);
1447
1480
 
1448
1481
  return {
1449
1482
  c() {
@@ -1457,15 +1490,15 @@ function create_fragment(ctx) {
1457
1490
  attr(ul, "role", "listbox");
1458
1491
  attr(ul, "aria-labelledby", ul_aria_labelledby_value = "" + (/*id*/ ctx[2] + "-label"));
1459
1492
  attr(ul, "id", ul_id_value = "" + (/*id*/ ctx[2] + "-listbox"));
1460
- attr(ul, "class", "svelte-9wywte");
1493
+ attr(ul, "class", "svelte-1t4elht");
1461
1494
  toggle_class(ul, "svelte-typeahead-list", true);
1462
1495
  attr(div, "data-svelte-typeahead", "");
1463
1496
  attr(div, "role", "combobox");
1464
1497
  attr(div, "aria-haspopup", "listbox");
1465
1498
  attr(div, "aria-owns", div_aria_owns_value = "" + (/*id*/ ctx[2] + "-listbox"));
1466
- attr(div, "aria-expanded", /*showResults*/ ctx[6]);
1499
+ attr(div, "aria-expanded", /*showResults*/ ctx[7]);
1467
1500
  attr(div, "id", div_id_value = "" + (/*id*/ ctx[2] + "-typeahead"));
1468
- attr(div, "class", "svelte-9wywte");
1501
+ attr(div, "class", "svelte-1t4elht");
1469
1502
  toggle_class(div, "dropdown", /*results*/ ctx[1].length > 0);
1470
1503
  },
1471
1504
  m(target, anchor) {
@@ -1476,20 +1509,20 @@ function create_fragment(ctx) {
1476
1509
  if (if_block0) if_block0.m(ul, null);
1477
1510
  append(ul, t1);
1478
1511
  if (if_block1) if_block1.m(ul, null);
1479
- /*div_binding*/ ctx[41](div);
1512
+ /*div_binding*/ ctx[42](div);
1480
1513
  current = true;
1481
1514
 
1482
1515
  if (!mounted) {
1483
- dispose = listen(window, "click", /*click_handler*/ ctx[27]);
1516
+ dispose = listen(window, "click", /*click_handler*/ ctx[28]);
1484
1517
  mounted = true;
1485
1518
  }
1486
1519
  },
1487
1520
  p(ctx, dirty) {
1488
- const search_changes = (dirty[0] & /*id, $$restProps, selectedIndex, hideDropdown, results*/ 33302)
1521
+ const search_changes = (dirty[0] & /*id, $$restProps, selectedIndex, hideDropdown, results*/ 66598)
1489
1522
  ? get_spread_update(search_spread_levels, [
1490
1523
  dirty[0] & /*id*/ 4 && { id: /*id*/ ctx[2] },
1491
1524
  search_spread_levels[1],
1492
- dirty[0] & /*$$restProps*/ 32768 && get_spread_object(/*$$restProps*/ ctx[15]),
1525
+ dirty[0] & /*$$restProps*/ 65536 && get_spread_object(/*$$restProps*/ ctx[16]),
1493
1526
  search_spread_levels[3],
1494
1527
  dirty[0] & /*id*/ 4 && {
1495
1528
  "aria-controls": "" + (/*id*/ ctx[2] + "-listbox")
@@ -1497,17 +1530,17 @@ function create_fragment(ctx) {
1497
1530
  dirty[0] & /*id*/ 4 && {
1498
1531
  "aria-labelledby": "" + (/*id*/ ctx[2] + "-label")
1499
1532
  },
1500
- dirty[0] & /*selectedIndex, hideDropdown, results, id*/ 534 && {
1501
- "aria-activedescendant": /*selectedIndex*/ ctx[9] >= 0 && !/*hideDropdown*/ ctx[4] && /*results*/ ctx[1].length > 0
1502
- ? `${/*id*/ ctx[2]}-result-${/*selectedIndex*/ ctx[9]}`
1533
+ dirty[0] & /*selectedIndex, hideDropdown, results, id*/ 1062 && {
1534
+ "aria-activedescendant": /*selectedIndex*/ ctx[10] >= 0 && !/*hideDropdown*/ ctx[5] && /*results*/ ctx[1].length > 0
1535
+ ? `${/*id*/ ctx[2]}-result-${/*selectedIndex*/ ctx[10]}`
1503
1536
  : null
1504
1537
  }
1505
1538
  ])
1506
1539
  : {};
1507
1540
 
1508
- if (!updating_ref && dirty[0] & /*searchRef*/ 256) {
1541
+ if (!updating_ref && dirty[0] & /*searchRef*/ 512) {
1509
1542
  updating_ref = true;
1510
- search_changes.ref = /*searchRef*/ ctx[8];
1543
+ search_changes.ref = /*searchRef*/ ctx[9];
1511
1544
  add_flush_callback(() => updating_ref = false);
1512
1545
  }
1513
1546
 
@@ -1519,11 +1552,11 @@ function create_fragment(ctx) {
1519
1552
 
1520
1553
  search.$set(search_changes);
1521
1554
 
1522
- if (/*showResults*/ ctx[6]) {
1555
+ if (/*showResults*/ ctx[7]) {
1523
1556
  if (if_block0) {
1524
1557
  if_block0.p(ctx, dirty);
1525
1558
 
1526
- if (dirty[0] & /*showResults*/ 64) {
1559
+ if (dirty[0] & /*showResults*/ 128) {
1527
1560
  transition_in(if_block0, 1);
1528
1561
  }
1529
1562
  } else {
@@ -1542,11 +1575,11 @@ function create_fragment(ctx) {
1542
1575
  check_outros();
1543
1576
  }
1544
1577
 
1545
- if (/*$$slots*/ ctx[14]["no-results"] && !/*hideDropdown*/ ctx[4] && /*value*/ ctx[0].length > 0 && /*results*/ ctx[1].length === 0) {
1578
+ if (/*$$slots*/ ctx[15]["no-results"] && !/*hideDropdown*/ ctx[5] && /*value*/ ctx[0].length > 0 && /*results*/ ctx[1].length === 0) {
1546
1579
  if (if_block1) {
1547
1580
  if_block1.p(ctx, dirty);
1548
1581
 
1549
- if (dirty[0] & /*$$slots, hideDropdown, value, results*/ 16403) {
1582
+ if (dirty[0] & /*$$slots, hideDropdown, value, results*/ 32803) {
1550
1583
  transition_in(if_block1, 1);
1551
1584
  }
1552
1585
  } else {
@@ -1577,15 +1610,15 @@ function create_fragment(ctx) {
1577
1610
  attr(div, "aria-owns", div_aria_owns_value);
1578
1611
  }
1579
1612
 
1580
- if (!current || dirty[0] & /*showResults*/ 64) {
1581
- attr(div, "aria-expanded", /*showResults*/ ctx[6]);
1613
+ if (!current || dirty[0] & /*showResults*/ 128) {
1614
+ attr(div, "aria-expanded", /*showResults*/ ctx[7]);
1582
1615
  }
1583
1616
 
1584
1617
  if (!current || dirty[0] & /*id*/ 4 && div_id_value !== (div_id_value = "" + (/*id*/ ctx[2] + "-typeahead"))) {
1585
1618
  attr(div, "id", div_id_value);
1586
1619
  }
1587
1620
 
1588
- if (dirty[0] & /*results*/ 2) {
1621
+ if (!current || dirty[0] & /*results*/ 2) {
1589
1622
  toggle_class(div, "dropdown", /*results*/ ctx[1].length > 0);
1590
1623
  }
1591
1624
  },
@@ -1607,7 +1640,7 @@ function create_fragment(ctx) {
1607
1640
  destroy_component(search);
1608
1641
  if (if_block0) if_block0.d();
1609
1642
  if (if_block1) if_block1.d();
1610
- /*div_binding*/ ctx[41](null);
1643
+ /*div_binding*/ ctx[42](null);
1611
1644
  mounted = false;
1612
1645
  dispose();
1613
1646
  }
@@ -1620,7 +1653,7 @@ function instance($$self, $$props, $$invalidate) {
1620
1653
  let showResults;
1621
1654
 
1622
1655
  const omit_props_names = [
1623
- "id","value","data","extract","disable","filter","autoselect","inputAfterSelect","results","focusAfterSelect","showDropdownOnFocus","limit"
1656
+ "id","value","data","extract","disable","filter","autoselect","inputAfterSelect","results","focusAfterSelect","showDropdownOnFocus","showAllResultsOnFocus","limit"
1624
1657
  ];
1625
1658
 
1626
1659
  let $$restProps = compute_rest_props($$props, omit_props_names);
@@ -1637,6 +1670,7 @@ function instance($$self, $$props, $$invalidate) {
1637
1670
  let { results = [] } = $$props;
1638
1671
  let { focusAfterSelect = false } = $$props;
1639
1672
  let { showDropdownOnFocus = false } = $$props;
1673
+ let { showAllResultsOnFocus = false } = $$props;
1640
1674
  let { limit = Infinity } = $$props;
1641
1675
  const dispatch = createEventDispatcher();
1642
1676
  let comboboxRef = null;
@@ -1648,11 +1682,11 @@ function instance($$self, $$props, $$invalidate) {
1648
1682
 
1649
1683
  afterUpdate(() => {
1650
1684
  if (prevResults !== resultsId && autoselect) {
1651
- $$invalidate(9, selectedIndex = getNextNonDisabledIndex());
1685
+ $$invalidate(10, selectedIndex = getNextNonDisabledIndex());
1652
1686
  }
1653
1687
 
1654
1688
  if (prevResults !== resultsId && !$$slots["no-results"]) {
1655
- $$invalidate(4, hideDropdown = results.length === 0);
1689
+ $$invalidate(5, hideDropdown = results.length === 0);
1656
1690
  }
1657
1691
 
1658
1692
  prevResults = resultsId;
@@ -1716,11 +1750,15 @@ function instance($$self, $$props, $$invalidate) {
1716
1750
  disabled = results[index].disabled;
1717
1751
  }
1718
1752
 
1719
- $$invalidate(9, selectedIndex = index);
1753
+ $$invalidate(10, selectedIndex = index);
1720
1754
  }
1721
1755
 
1722
- const open = () => $$invalidate(4, hideDropdown = false);
1723
- const close = () => $$invalidate(4, hideDropdown = true);
1756
+ const open = () => $$invalidate(5, hideDropdown = false);
1757
+
1758
+ const close = () => {
1759
+ $$invalidate(5, hideDropdown = true);
1760
+ $$invalidate(6, isFocused = false);
1761
+ };
1724
1762
 
1725
1763
  const click_handler = ({ target }) => {
1726
1764
  if (!hideDropdown && !comboboxRef?.contains(target)) {
@@ -1730,7 +1768,7 @@ function instance($$self, $$props, $$invalidate) {
1730
1768
 
1731
1769
  function search_ref_binding(value) {
1732
1770
  searchRef = value;
1733
- $$invalidate(8, searchRef);
1771
+ $$invalidate(9, searchRef);
1734
1772
  }
1735
1773
 
1736
1774
  function search_value_binding(value$1) {
@@ -1757,9 +1795,9 @@ function instance($$self, $$props, $$invalidate) {
1757
1795
  const focus_handler_1 = () => {
1758
1796
  open();
1759
1797
 
1760
- if (showDropdownOnFocus) {
1761
- $$invalidate(6, showResults = true);
1762
- $$invalidate(5, isFocused = true);
1798
+ if (showDropdownOnFocus || showAllResultsOnFocus) {
1799
+ $$invalidate(7, showResults = true);
1800
+ $$invalidate(6, isFocused = true);
1763
1801
  }
1764
1802
  };
1765
1803
 
@@ -1801,63 +1839,76 @@ function instance($$self, $$props, $$invalidate) {
1801
1839
 
1802
1840
  const click_handler_1 = (result, index) => {
1803
1841
  if (result.disabled) return;
1804
- $$invalidate(9, selectedIndex = index);
1842
+ $$invalidate(10, selectedIndex = index);
1805
1843
  select();
1806
1844
  };
1807
1845
 
1808
1846
  const mouseenter_handler = (result, index) => {
1809
1847
  if (result.disabled) return;
1810
- $$invalidate(9, selectedIndex = index);
1848
+ $$invalidate(10, selectedIndex = index);
1811
1849
  };
1812
1850
 
1813
1851
  function div_binding($$value) {
1814
1852
  binding_callbacks[$$value ? 'unshift' : 'push'](() => {
1815
1853
  comboboxRef = $$value;
1816
- $$invalidate(7, comboboxRef);
1854
+ $$invalidate(8, comboboxRef);
1817
1855
  });
1818
1856
  }
1819
1857
 
1820
1858
  $$self.$$set = $$new_props => {
1821
1859
  $$props = assign(assign({}, $$props), exclude_internal_props($$new_props));
1822
- $$invalidate(15, $$restProps = compute_rest_props($$props, omit_props_names));
1860
+ $$invalidate(16, $$restProps = compute_rest_props($$props, omit_props_names));
1823
1861
  if ('id' in $$new_props) $$invalidate(2, id = $$new_props.id);
1824
1862
  if ('value' in $$new_props) $$invalidate(0, value = $$new_props.value);
1825
- if ('data' in $$new_props) $$invalidate(16, data = $$new_props.data);
1826
- if ('extract' in $$new_props) $$invalidate(17, extract = $$new_props.extract);
1827
- if ('disable' in $$new_props) $$invalidate(18, disable = $$new_props.disable);
1828
- if ('filter' in $$new_props) $$invalidate(19, filter = $$new_props.filter);
1829
- if ('autoselect' in $$new_props) $$invalidate(20, autoselect = $$new_props.autoselect);
1830
- if ('inputAfterSelect' in $$new_props) $$invalidate(21, inputAfterSelect = $$new_props.inputAfterSelect);
1863
+ if ('data' in $$new_props) $$invalidate(17, data = $$new_props.data);
1864
+ if ('extract' in $$new_props) $$invalidate(18, extract = $$new_props.extract);
1865
+ if ('disable' in $$new_props) $$invalidate(19, disable = $$new_props.disable);
1866
+ if ('filter' in $$new_props) $$invalidate(20, filter = $$new_props.filter);
1867
+ if ('autoselect' in $$new_props) $$invalidate(21, autoselect = $$new_props.autoselect);
1868
+ if ('inputAfterSelect' in $$new_props) $$invalidate(22, inputAfterSelect = $$new_props.inputAfterSelect);
1831
1869
  if ('results' in $$new_props) $$invalidate(1, results = $$new_props.results);
1832
- if ('focusAfterSelect' in $$new_props) $$invalidate(22, focusAfterSelect = $$new_props.focusAfterSelect);
1870
+ if ('focusAfterSelect' in $$new_props) $$invalidate(23, focusAfterSelect = $$new_props.focusAfterSelect);
1833
1871
  if ('showDropdownOnFocus' in $$new_props) $$invalidate(3, showDropdownOnFocus = $$new_props.showDropdownOnFocus);
1834
- if ('limit' in $$new_props) $$invalidate(23, limit = $$new_props.limit);
1835
- if ('$$scope' in $$new_props) $$invalidate(25, $$scope = $$new_props.$$scope);
1872
+ if ('showAllResultsOnFocus' in $$new_props) $$invalidate(4, showAllResultsOnFocus = $$new_props.showAllResultsOnFocus);
1873
+ if ('limit' in $$new_props) $$invalidate(24, limit = $$new_props.limit);
1874
+ if ('$$scope' in $$new_props) $$invalidate(26, $$scope = $$new_props.$$scope);
1836
1875
  };
1837
1876
 
1838
1877
  $$self.$$.update = () => {
1839
- if ($$self.$$.dirty[0] & /*extract*/ 131072) {
1840
- $$invalidate(24, options = { pre: "<mark>", post: "</mark>", extract });
1878
+ if ($$self.$$.dirty[0] & /*extract*/ 262144) {
1879
+ $$invalidate(25, options = { pre: "<mark>", post: "</mark>", extract });
1841
1880
  }
1842
1881
 
1843
- if ($$self.$$.dirty[0] & /*value, data, options, limit, filter, disable*/ 26017793) {
1882
+ if ($$self.$$.dirty[0] & /*value, data, options, limit, filter, disable*/ 52035585) {
1844
1883
  $$invalidate(1, results = fuzzy.filter(value, data, options).filter(({ score }) => score > 0).slice(0, limit).filter(result => !filter(result.original)).map(result => ({
1845
1884
  ...result,
1846
1885
  disabled: disable(result.original)
1847
1886
  })));
1848
1887
  }
1849
1888
 
1850
- if ($$self.$$.dirty[0] & /*results, extract*/ 131074) {
1889
+ if ($$self.$$.dirty[0] & /*isFocused, showAllResultsOnFocus, value, data, filter, disable, extract*/ 1966161) {
1890
+ if (isFocused && showAllResultsOnFocus && value.length === 0) {
1891
+ $$invalidate(1, results = data.filter(datum => !filter(datum)).map((original, index) => ({
1892
+ disabled: disable(original),
1893
+ index,
1894
+ original,
1895
+ score: 0,
1896
+ string: extract(original)
1897
+ })));
1898
+ }
1899
+ }
1900
+
1901
+ if ($$self.$$.dirty[0] & /*results, extract*/ 262146) {
1851
1902
  resultsId = results.map(result => extract(result.original)).join("");
1852
1903
  }
1853
1904
 
1854
- if ($$self.$$.dirty[0] & /*hideDropdown, results*/ 18) {
1855
- $$invalidate(6, showResults = !hideDropdown && results.length > 0);
1905
+ if ($$self.$$.dirty[0] & /*hideDropdown, results*/ 34) {
1906
+ $$invalidate(7, showResults = !hideDropdown && results.length > 0);
1856
1907
  }
1857
1908
 
1858
- if ($$self.$$.dirty[0] & /*showDropdownOnFocus, showResults, isFocused*/ 104) {
1909
+ if ($$self.$$.dirty[0] & /*showDropdownOnFocus, showResults, isFocused*/ 200) {
1859
1910
  if (showDropdownOnFocus) {
1860
- $$invalidate(6, showResults = showResults && isFocused);
1911
+ $$invalidate(7, showResults = showResults && isFocused);
1861
1912
  }
1862
1913
  }
1863
1914
  };
@@ -1867,6 +1918,7 @@ function instance($$self, $$props, $$invalidate) {
1867
1918
  results,
1868
1919
  id,
1869
1920
  showDropdownOnFocus,
1921
+ showAllResultsOnFocus,
1870
1922
  hideDropdown,
1871
1923
  isFocused,
1872
1924
  showResults,
@@ -1921,16 +1973,17 @@ class Typeahead extends SvelteComponent {
1921
1973
  {
1922
1974
  id: 2,
1923
1975
  value: 0,
1924
- data: 16,
1925
- extract: 17,
1926
- disable: 18,
1927
- filter: 19,
1928
- autoselect: 20,
1929
- inputAfterSelect: 21,
1976
+ data: 17,
1977
+ extract: 18,
1978
+ disable: 19,
1979
+ filter: 20,
1980
+ autoselect: 21,
1981
+ inputAfterSelect: 22,
1930
1982
  results: 1,
1931
- focusAfterSelect: 22,
1983
+ focusAfterSelect: 23,
1932
1984
  showDropdownOnFocus: 3,
1933
- limit: 23
1985
+ showAllResultsOnFocus: 4,
1986
+ limit: 24
1934
1987
  },
1935
1988
  add_css,
1936
1989
  [-1, -1]