svelte-typeahead 2.4.1 → 4.2.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
@@ -52,13 +52,23 @@ function get_slot_changes(definition, $$scope, dirty, fn) {
52
52
  }
53
53
  return $$scope.dirty;
54
54
  }
55
- function update_slot(slot, slot_definition, ctx, $$scope, dirty, get_slot_changes_fn, get_slot_context_fn) {
56
- const slot_changes = get_slot_changes(slot_definition, $$scope, dirty, get_slot_changes_fn);
55
+ function update_slot_base(slot, slot_definition, ctx, $$scope, slot_changes, get_slot_context_fn) {
57
56
  if (slot_changes) {
58
57
  const slot_context = get_slot_context(slot_definition, ctx, $$scope, get_slot_context_fn);
59
58
  slot.p(slot_context, slot_changes);
60
59
  }
61
60
  }
61
+ function get_all_dirty_from_scope($$scope) {
62
+ if ($$scope.ctx.length > 32) {
63
+ const dirty = [];
64
+ const length = $$scope.ctx.length / 32;
65
+ for (let i = 0; i < length; i++) {
66
+ dirty[i] = -1;
67
+ }
68
+ return dirty;
69
+ }
70
+ return -1;
71
+ }
62
72
  function exclude_internal_props(props) {
63
73
  const result = {};
64
74
  for (const k in props)
@@ -74,10 +84,37 @@ function compute_rest_props(props, keys) {
74
84
  rest[k] = props[k];
75
85
  return rest;
76
86
  }
77
-
87
+ function compute_slots(slots) {
88
+ const result = {};
89
+ for (const key in slots) {
90
+ result[key] = true;
91
+ }
92
+ return result;
93
+ }
78
94
  function append(target, node) {
79
95
  target.appendChild(node);
80
96
  }
97
+ function append_styles(target, style_sheet_id, styles) {
98
+ const append_styles_to = get_root_for_style(target);
99
+ if (!append_styles_to.getElementById(style_sheet_id)) {
100
+ const style = element('style');
101
+ style.id = style_sheet_id;
102
+ style.textContent = styles;
103
+ append_stylesheet(append_styles_to, style);
104
+ }
105
+ }
106
+ function get_root_for_style(node) {
107
+ if (!node)
108
+ return document;
109
+ const root = node.getRootNode ? node.getRootNode() : node.ownerDocument;
110
+ if (root && root.host) {
111
+ return root;
112
+ }
113
+ return node.ownerDocument;
114
+ }
115
+ function append_stylesheet(node, style) {
116
+ append(node.head || node, style);
117
+ }
81
118
  function insert(target, node, anchor) {
82
119
  target.insertBefore(node, anchor || null);
83
120
  }
@@ -154,21 +191,23 @@ function set_input_value(input, value) {
154
191
  function toggle_class(element, name, toggle) {
155
192
  element.classList[toggle ? 'add' : 'remove'](name);
156
193
  }
157
- function custom_event(type, detail) {
194
+ function custom_event(type, detail, bubbles = false) {
158
195
  const e = document.createEvent('CustomEvent');
159
- e.initCustomEvent(type, false, false, detail);
196
+ e.initCustomEvent(type, bubbles, false, detail);
160
197
  return e;
161
198
  }
162
199
  class HtmlTag {
163
- constructor(anchor = null) {
164
- this.a = anchor;
200
+ constructor() {
165
201
  this.e = this.n = null;
166
202
  }
203
+ c(html) {
204
+ this.h(html);
205
+ }
167
206
  m(html, target, anchor = null) {
168
207
  if (!this.e) {
169
208
  this.e = element(target.nodeName);
170
209
  this.t = target;
171
- this.h(html);
210
+ this.c(html);
172
211
  }
173
212
  this.i(anchor);
174
213
  }
@@ -226,7 +265,8 @@ function createEventDispatcher() {
226
265
  function bubble(component, event) {
227
266
  const callbacks = component.$$.callbacks[event.type];
228
267
  if (callbacks) {
229
- callbacks.slice().forEach(fn => fn(event));
268
+ // @ts-ignore
269
+ callbacks.slice().forEach(fn => fn.call(this, event));
230
270
  }
231
271
  }
232
272
 
@@ -424,7 +464,7 @@ function make_dirty(component, i) {
424
464
  }
425
465
  component.$$.dirty[(i / 31) | 0] |= (1 << (i % 31));
426
466
  }
427
- function init(component, options, instance, create_fragment, not_equal, props, dirty = [-1]) {
467
+ function init(component, options, instance, create_fragment, not_equal, props, append_styles, dirty = [-1]) {
428
468
  const parent_component = current_component;
429
469
  set_current_component(component);
430
470
  const $$ = component.$$ = {
@@ -441,12 +481,14 @@ function init(component, options, instance, create_fragment, not_equal, props, d
441
481
  on_disconnect: [],
442
482
  before_update: [],
443
483
  after_update: [],
444
- context: new Map(parent_component ? parent_component.$$.context : []),
484
+ context: new Map(options.context || (parent_component ? parent_component.$$.context : [])),
445
485
  // everything else
446
486
  callbacks: blank_object(),
447
487
  dirty,
448
- skip_bound: false
488
+ skip_bound: false,
489
+ root: options.target || parent_component.$$.root
449
490
  };
491
+ append_styles && append_styles($$.root);
450
492
  let ready = false;
451
493
  $$.ctx = instance
452
494
  ? instance(component, options.props || {}, (i, ret, ...rest) => {
@@ -509,10 +551,7 @@ class SvelteComponent {
509
551
  }
510
552
  }
511
553
 
512
- function createCommonjsModule(fn) {
513
- var module = { exports: {} };
514
- return fn(module, module.exports), module.exports;
515
- }
554
+ var fuzzy$1 = {exports: {}};
516
555
 
517
556
  /*
518
557
  * Fuzzy
@@ -522,7 +561,7 @@ function createCommonjsModule(fn) {
522
561
  * Licensed under the MIT license.
523
562
  */
524
563
 
525
- var fuzzy = createCommonjsModule(function (module, exports) {
564
+ (function (module, exports) {
526
565
  (function() {
527
566
 
528
567
  var fuzzy = {};
@@ -654,21 +693,20 @@ fuzzy.filter = function(pattern, arr, opts) {
654
693
 
655
694
 
656
695
  }());
657
- });
696
+ }(fuzzy$1));
658
697
 
659
- /* node_modules/svelte-search/src/Search.svelte generated by Svelte v3.35.0 */
698
+ var fuzzy = fuzzy$1.exports;
660
699
 
661
- function add_css$1() {
662
- var style = element("style");
663
- style.id = "svelte-5m0wg6-style";
664
- style.textContent = ".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}";
665
- append(document.head, style);
700
+ /* node_modules/svelte-search/src/Search.svelte generated by Svelte v3.44.0 */
701
+
702
+ function add_css$1(target) {
703
+ 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}");
666
704
  }
667
705
 
668
706
  const get_label_slot_changes = dirty => ({});
669
707
  const get_label_slot_context = ctx => ({});
670
708
 
671
- // (70:23) {label}
709
+ // (60:23) {label}
672
710
  function fallback_block$1(ctx) {
673
711
  let t;
674
712
 
@@ -694,11 +732,13 @@ function create_fragment$1(ctx) {
694
732
  let label_1_id_value;
695
733
  let t;
696
734
  let input;
735
+ let form_role_value;
736
+ let form_aria_labelledby_value;
697
737
  let current;
698
738
  let mounted;
699
739
  let dispose;
700
- const label_slot_template = /*#slots*/ ctx[9].label;
701
- const label_slot = create_slot(label_slot_template, ctx, /*$$scope*/ ctx[8], get_label_slot_context);
740
+ const label_slot_template = /*#slots*/ ctx[10].label;
741
+ const label_slot = create_slot(label_slot_template, ctx, /*$$scope*/ ctx[9], get_label_slot_context);
702
742
  const label_slot_or_fallback = label_slot || fallback_block$1(ctx);
703
743
 
704
744
  let input_levels = [
@@ -707,7 +747,7 @@ function create_fragment$1(ctx) {
707
747
  { placeholder: "Search..." },
708
748
  { autocomplete: "off" },
709
749
  { spellcheck: "false" },
710
- /*$$restProps*/ ctx[5],
750
+ /*$$restProps*/ ctx[6],
711
751
  { id: /*id*/ ctx[4] }
712
752
  ];
713
753
 
@@ -731,8 +771,11 @@ function create_fragment$1(ctx) {
731
771
  set_attributes(input, input_data);
732
772
  toggle_class(input, "svelte-5m0wg6", true);
733
773
  attr(form, "data-svelte-search", "");
734
- attr(form, "role", "search");
735
- attr(form, "aria-labelledby", /*id*/ ctx[4]);
774
+ attr(form, "role", form_role_value = /*removeFormAriaAttributes*/ ctx[5] ? null : "search");
775
+
776
+ attr(form, "aria-labelledby", form_aria_labelledby_value = /*removeFormAriaAttributes*/ ctx[5]
777
+ ? null
778
+ : /*id*/ ctx[4]);
736
779
  },
737
780
  m(target, anchor) {
738
781
  insert(target, form, anchor);
@@ -744,19 +787,20 @@ function create_fragment$1(ctx) {
744
787
 
745
788
  append(form, t);
746
789
  append(form, input);
747
- /*input_binding*/ ctx[16](input);
790
+ if (input.autofocus) input.focus();
791
+ /*input_binding*/ ctx[17](input);
748
792
  set_input_value(input, /*value*/ ctx[0]);
749
793
  current = true;
750
794
 
751
795
  if (!mounted) {
752
796
  dispose = [
753
- listen(input, "input", /*input_input_handler*/ ctx[17]),
754
- listen(input, "input", /*input_handler*/ ctx[11]),
755
- listen(input, "change", /*change_handler*/ ctx[12]),
756
- listen(input, "focus", /*focus_handler*/ ctx[13]),
757
- listen(input, "blur", /*blur_handler*/ ctx[14]),
758
- listen(input, "keydown", /*keydown_handler*/ ctx[15]),
759
- listen(form, "submit", prevent_default(/*submit_handler*/ ctx[10]))
797
+ listen(input, "input", /*input_input_handler*/ ctx[18]),
798
+ listen(input, "input", /*input_handler*/ ctx[12]),
799
+ listen(input, "change", /*change_handler*/ ctx[13]),
800
+ listen(input, "focus", /*focus_handler*/ ctx[14]),
801
+ listen(input, "blur", /*blur_handler*/ ctx[15]),
802
+ listen(input, "keydown", /*keydown_handler*/ ctx[16]),
803
+ listen(form, "submit", prevent_default(/*submit_handler*/ ctx[11]))
760
804
  ];
761
805
 
762
806
  mounted = true;
@@ -764,12 +808,21 @@ function create_fragment$1(ctx) {
764
808
  },
765
809
  p(ctx, [dirty]) {
766
810
  if (label_slot) {
767
- if (label_slot.p && dirty & /*$$scope*/ 256) {
768
- update_slot(label_slot, label_slot_template, ctx, /*$$scope*/ ctx[8], dirty, get_label_slot_changes, get_label_slot_context);
811
+ if (label_slot.p && (!current || dirty & /*$$scope*/ 512)) {
812
+ update_slot_base(
813
+ label_slot,
814
+ label_slot_template,
815
+ ctx,
816
+ /*$$scope*/ ctx[9],
817
+ !current
818
+ ? get_all_dirty_from_scope(/*$$scope*/ ctx[9])
819
+ : get_slot_changes(label_slot_template, /*$$scope*/ ctx[9], dirty, get_label_slot_changes),
820
+ get_label_slot_context
821
+ );
769
822
  }
770
823
  } else {
771
- if (label_slot_or_fallback && label_slot_or_fallback.p && dirty & /*label*/ 4) {
772
- label_slot_or_fallback.p(ctx, dirty);
824
+ if (label_slot_or_fallback && label_slot_or_fallback.p && (!current || dirty & /*label*/ 4)) {
825
+ label_slot_or_fallback.p(ctx, !current ? -1 : dirty);
773
826
  }
774
827
  }
775
828
 
@@ -791,7 +844,7 @@ function create_fragment$1(ctx) {
791
844
  { placeholder: "Search..." },
792
845
  { autocomplete: "off" },
793
846
  { spellcheck: "false" },
794
- dirty & /*$$restProps*/ 32 && /*$$restProps*/ ctx[5],
847
+ dirty & /*$$restProps*/ 64 && /*$$restProps*/ ctx[6],
795
848
  (!current || dirty & /*id*/ 16) && { id: /*id*/ ctx[4] }
796
849
  ]));
797
850
 
@@ -801,8 +854,14 @@ function create_fragment$1(ctx) {
801
854
 
802
855
  toggle_class(input, "svelte-5m0wg6", true);
803
856
 
804
- if (!current || dirty & /*id*/ 16) {
805
- attr(form, "aria-labelledby", /*id*/ ctx[4]);
857
+ if (!current || dirty & /*removeFormAriaAttributes*/ 32 && form_role_value !== (form_role_value = /*removeFormAriaAttributes*/ ctx[5] ? null : "search")) {
858
+ attr(form, "role", form_role_value);
859
+ }
860
+
861
+ if (!current || dirty & /*removeFormAriaAttributes, id*/ 48 && form_aria_labelledby_value !== (form_aria_labelledby_value = /*removeFormAriaAttributes*/ ctx[5]
862
+ ? null
863
+ : /*id*/ ctx[4])) {
864
+ attr(form, "aria-labelledby", form_aria_labelledby_value);
806
865
  }
807
866
  },
808
867
  i(local) {
@@ -817,7 +876,7 @@ function create_fragment$1(ctx) {
817
876
  d(detaching) {
818
877
  if (detaching) detach(form);
819
878
  if (label_slot_or_fallback) label_slot_or_fallback.d(detaching);
820
- /*input_binding*/ ctx[16](null);
879
+ /*input_binding*/ ctx[17](null);
821
880
  mounted = false;
822
881
  run_all(dispose);
823
882
  }
@@ -825,7 +884,10 @@ function create_fragment$1(ctx) {
825
884
  }
826
885
 
827
886
  function instance$1($$self, $$props, $$invalidate) {
828
- const omit_props_names = ["value","autofocus","debounce","label","hideLabel","id","ref"];
887
+ const omit_props_names = [
888
+ "value","autofocus","debounce","label","hideLabel","id","ref","removeFormAriaAttributes"
889
+ ];
890
+
829
891
  let $$restProps = compute_rest_props($$props, omit_props_names);
830
892
  let { $$slots: slots = {}, $$scope } = $$props;
831
893
  let { value = "" } = $$props;
@@ -835,6 +897,7 @@ function instance$1($$self, $$props, $$invalidate) {
835
897
  let { hideLabel = false } = $$props;
836
898
  let { id = "search" + Math.random().toString(36) } = $$props;
837
899
  let { ref = null } = $$props;
900
+ let { removeFormAriaAttributes = false } = $$props;
838
901
  const dispatch = createEventDispatcher();
839
902
  let prevValue = value;
840
903
  let timeout = undefined;
@@ -872,31 +935,31 @@ function instance$1($$self, $$props, $$invalidate) {
872
935
  });
873
936
 
874
937
  function submit_handler(event) {
875
- bubble($$self, event);
938
+ bubble.call(this, $$self, event);
876
939
  }
877
940
 
878
941
  function input_handler(event) {
879
- bubble($$self, event);
942
+ bubble.call(this, $$self, event);
880
943
  }
881
944
 
882
945
  function change_handler(event) {
883
- bubble($$self, event);
946
+ bubble.call(this, $$self, event);
884
947
  }
885
948
 
886
949
  function focus_handler(event) {
887
- bubble($$self, event);
950
+ bubble.call(this, $$self, event);
888
951
  }
889
952
 
890
953
  function blur_handler(event) {
891
- bubble($$self, event);
954
+ bubble.call(this, $$self, event);
892
955
  }
893
956
 
894
957
  function keydown_handler(event) {
895
- bubble($$self, event);
958
+ bubble.call(this, $$self, event);
896
959
  }
897
960
 
898
961
  function input_binding($$value) {
899
- binding_callbacks[$$value ? "unshift" : "push"](() => {
962
+ binding_callbacks[$$value ? 'unshift' : 'push'](() => {
900
963
  ref = $$value;
901
964
  $$invalidate(1, ref);
902
965
  });
@@ -909,15 +972,16 @@ function instance$1($$self, $$props, $$invalidate) {
909
972
 
910
973
  $$self.$$set = $$new_props => {
911
974
  $$props = assign(assign({}, $$props), exclude_internal_props($$new_props));
912
- $$invalidate(5, $$restProps = compute_rest_props($$props, omit_props_names));
913
- if ("value" in $$new_props) $$invalidate(0, value = $$new_props.value);
914
- if ("autofocus" in $$new_props) $$invalidate(6, autofocus = $$new_props.autofocus);
915
- if ("debounce" in $$new_props) $$invalidate(7, debounce = $$new_props.debounce);
916
- if ("label" in $$new_props) $$invalidate(2, label = $$new_props.label);
917
- if ("hideLabel" in $$new_props) $$invalidate(3, hideLabel = $$new_props.hideLabel);
918
- if ("id" in $$new_props) $$invalidate(4, id = $$new_props.id);
919
- if ("ref" in $$new_props) $$invalidate(1, ref = $$new_props.ref);
920
- if ("$$scope" in $$new_props) $$invalidate(8, $$scope = $$new_props.$$scope);
975
+ $$invalidate(6, $$restProps = compute_rest_props($$props, omit_props_names));
976
+ if ('value' in $$new_props) $$invalidate(0, value = $$new_props.value);
977
+ if ('autofocus' in $$new_props) $$invalidate(7, autofocus = $$new_props.autofocus);
978
+ if ('debounce' in $$new_props) $$invalidate(8, debounce = $$new_props.debounce);
979
+ if ('label' in $$new_props) $$invalidate(2, label = $$new_props.label);
980
+ if ('hideLabel' in $$new_props) $$invalidate(3, hideLabel = $$new_props.hideLabel);
981
+ if ('id' in $$new_props) $$invalidate(4, id = $$new_props.id);
982
+ if ('ref' in $$new_props) $$invalidate(1, ref = $$new_props.ref);
983
+ if ('removeFormAriaAttributes' in $$new_props) $$invalidate(5, removeFormAriaAttributes = $$new_props.removeFormAriaAttributes);
984
+ if ('$$scope' in $$new_props) $$invalidate(9, $$scope = $$new_props.$$scope);
921
985
  };
922
986
 
923
987
  return [
@@ -926,6 +990,7 @@ function instance$1($$self, $$props, $$invalidate) {
926
990
  label,
927
991
  hideLabel,
928
992
  id,
993
+ removeFormAriaAttributes,
929
994
  $$restProps,
930
995
  autofocus,
931
996
  debounce,
@@ -945,48 +1010,68 @@ function instance$1($$self, $$props, $$invalidate) {
945
1010
  class Search extends SvelteComponent {
946
1011
  constructor(options) {
947
1012
  super();
948
- if (!document.getElementById("svelte-5m0wg6-style")) add_css$1();
949
-
950
- init(this, options, instance$1, create_fragment$1, safe_not_equal, {
951
- value: 0,
952
- autofocus: 6,
953
- debounce: 7,
954
- label: 2,
955
- hideLabel: 3,
956
- id: 4,
957
- ref: 1
958
- });
1013
+
1014
+ init(
1015
+ this,
1016
+ options,
1017
+ instance$1,
1018
+ create_fragment$1,
1019
+ safe_not_equal,
1020
+ {
1021
+ value: 0,
1022
+ autofocus: 7,
1023
+ debounce: 8,
1024
+ label: 2,
1025
+ hideLabel: 3,
1026
+ id: 4,
1027
+ ref: 1,
1028
+ removeFormAriaAttributes: 5
1029
+ },
1030
+ add_css$1
1031
+ );
959
1032
  }
960
1033
  }
961
1034
 
962
- /* src/Typeahead.svelte generated by Svelte v3.35.0 */
1035
+ var Search$1 = Search;
963
1036
 
964
- function add_css() {
965
- var style = element("style");
966
- style.id = "svelte-t0wd5r-style";
967
- style.textContent = "[data-svelte-typeahead].svelte-t0wd5r{position:relative;background-color:#fff}ul.svelte-t0wd5r{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-t0wd5r{padding:0.25rem 1rem;cursor:pointer}li.svelte-t0wd5r:not(:last-of-type){border-bottom:1px solid #e0e0e0}li.svelte-t0wd5r:hover{background-color:#e5e5e5}.selected.svelte-t0wd5r{background-color:#e5e5e5}.selected.svelte-t0wd5r:hover{background-color:#cacaca}.disabled.svelte-t0wd5r{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}";
968
- append(document.head, style);
1037
+ /* src/Typeahead.svelte generated by Svelte v3.44.0 */
1038
+
1039
+ function add_css(target) {
1040
+ append_styles(target, "svelte-j5n77y", "[data-svelte-typeahead].svelte-j5n77y{position:relative;background-color:#fff}ul.svelte-j5n77y{position:absolute;top:100%;left:0;width:100%;padding:0;list-style:none;background-color:inherit;box-shadow:0 4px 8px rgba(0, 0, 0, 0.1)}li.svelte-j5n77y,.no-results.svelte-j5n77y{padding:0.25rem 1rem}li.svelte-j5n77y{cursor:pointer}li.svelte-j5n77y:not(:last-of-type){border-bottom:1px solid #e0e0e0}li.svelte-j5n77y:hover{background-color:#e5e5e5}.selected.svelte-j5n77y{background-color:#e5e5e5}.selected.svelte-j5n77y:hover{background-color:#cacaca}.disabled.svelte-j5n77y{opacity:0.4;cursor:not-allowed}[data-svelte-search] label{margin-bottom:0.25rem;display:inline-flex;font-size:0.875rem}[data-svelte-search] input{width:100%;padding:0.5rem 0.75rem;background:none;font-size:1rem;border:0;border-radius:0;border:1px solid #e5e5e5}[data-svelte-search] input:focus{outline-color:#0f62fe;outline-offset:2px;outline-width:1px}");
969
1041
  }
970
1042
 
1043
+ const get_no_results_slot_changes = dirty => ({
1044
+ value: dirty[0] & /*value*/ 1,
1045
+ result: dirty[0] & /*results*/ 2
1046
+ });
1047
+
1048
+ const get_no_results_slot_context = ctx => ({
1049
+ value: /*value*/ ctx[0],
1050
+ result: /*result*/ ctx[39],
1051
+ index: /*i*/ ctx[41]
1052
+ });
1053
+
971
1054
  function get_each_context(ctx, list, i) {
972
1055
  const child_ctx = ctx.slice();
973
- child_ctx[38] = list[i];
974
- child_ctx[40] = i;
1056
+ child_ctx[39] = list[i];
1057
+ child_ctx[41] = i;
975
1058
  return child_ctx;
976
1059
  }
977
1060
 
978
- const get_default_slot_changes = dirty => ({ result: dirty[0] & /*results*/ 2 });
1061
+ const get_default_slot_changes = dirty => ({
1062
+ result: dirty[0] & /*results*/ 2,
1063
+ value: dirty[0] & /*value*/ 1
1064
+ });
979
1065
 
980
1066
  const get_default_slot_context = ctx => ({
981
- result: /*result*/ ctx[38],
982
- index: /*i*/ ctx[40]
1067
+ result: /*result*/ ctx[39],
1068
+ index: /*i*/ ctx[41],
1069
+ value: /*value*/ ctx[0]
983
1070
  });
984
1071
 
985
- // (176:2) {#if !hideDropdown && results.length > 0}
986
- function create_if_block(ctx) {
987
- let ul;
988
- let ul_aria_labelledby_value;
989
- let ul_id_value;
1072
+ // (180:4) {#if !hideDropdown && results.length > 0}
1073
+ function create_if_block_1(ctx) {
1074
+ let each_1_anchor;
990
1075
  let current;
991
1076
  let each_value = /*results*/ ctx[1];
992
1077
  let each_blocks = [];
@@ -1001,29 +1086,22 @@ function create_if_block(ctx) {
1001
1086
 
1002
1087
  return {
1003
1088
  c() {
1004
- ul = element("ul");
1005
-
1006
1089
  for (let i = 0; i < each_blocks.length; i += 1) {
1007
1090
  each_blocks[i].c();
1008
1091
  }
1009
1092
 
1010
- attr(ul, "role", "listbox");
1011
- attr(ul, "aria-labelledby", ul_aria_labelledby_value = "" + (/*id*/ ctx[2] + "-label"));
1012
- attr(ul, "id", ul_id_value = "" + (/*id*/ ctx[2] + "-listbox"));
1013
- attr(ul, "class", "svelte-t0wd5r");
1014
- toggle_class(ul, "svelte-typeahead-list", true);
1093
+ each_1_anchor = empty();
1015
1094
  },
1016
1095
  m(target, anchor) {
1017
- insert(target, ul, anchor);
1018
-
1019
1096
  for (let i = 0; i < each_blocks.length; i += 1) {
1020
- each_blocks[i].m(ul, null);
1097
+ each_blocks[i].m(target, anchor);
1021
1098
  }
1022
1099
 
1100
+ insert(target, each_1_anchor, anchor);
1023
1101
  current = true;
1024
1102
  },
1025
1103
  p(ctx, dirty) {
1026
- if (dirty[0] & /*id, selectedIndex, results, select, $$scope*/ 262342) {
1104
+ if (dirty[0] & /*id, selectedIndex, results, select, $$scope, value*/ 524487) {
1027
1105
  each_value = /*results*/ ctx[1];
1028
1106
  let i;
1029
1107
 
@@ -1037,7 +1115,7 @@ function create_if_block(ctx) {
1037
1115
  each_blocks[i] = create_each_block(child_ctx);
1038
1116
  each_blocks[i].c();
1039
1117
  transition_in(each_blocks[i], 1);
1040
- each_blocks[i].m(ul, null);
1118
+ each_blocks[i].m(each_1_anchor.parentNode, each_1_anchor);
1041
1119
  }
1042
1120
  }
1043
1121
 
@@ -1049,14 +1127,6 @@ function create_if_block(ctx) {
1049
1127
 
1050
1128
  check_outros();
1051
1129
  }
1052
-
1053
- if (!current || dirty[0] & /*id*/ 4 && ul_aria_labelledby_value !== (ul_aria_labelledby_value = "" + (/*id*/ ctx[2] + "-label"))) {
1054
- attr(ul, "aria-labelledby", ul_aria_labelledby_value);
1055
- }
1056
-
1057
- if (!current || dirty[0] & /*id*/ 4 && ul_id_value !== (ul_id_value = "" + (/*id*/ ctx[2] + "-listbox"))) {
1058
- attr(ul, "id", ul_id_value);
1059
- }
1060
1130
  },
1061
1131
  i(local) {
1062
1132
  if (current) return;
@@ -1077,29 +1147,30 @@ function create_if_block(ctx) {
1077
1147
  current = false;
1078
1148
  },
1079
1149
  d(detaching) {
1080
- if (detaching) detach(ul);
1081
1150
  destroy_each(each_blocks, detaching);
1151
+ if (detaching) detach(each_1_anchor);
1082
1152
  }
1083
1153
  };
1084
1154
  }
1085
1155
 
1086
- // (197:35)
1156
+ // (195:43)
1087
1157
  function fallback_block(ctx) {
1088
1158
  let html_tag;
1089
- let raw_value = /*result*/ ctx[38].string + "";
1159
+ let raw_value = /*result*/ ctx[39].string + "";
1090
1160
  let html_anchor;
1091
1161
 
1092
1162
  return {
1093
1163
  c() {
1164
+ html_tag = new HtmlTag();
1094
1165
  html_anchor = empty();
1095
- html_tag = new HtmlTag(html_anchor);
1166
+ html_tag.a = html_anchor;
1096
1167
  },
1097
1168
  m(target, anchor) {
1098
1169
  html_tag.m(raw_value, target, anchor);
1099
1170
  insert(target, html_anchor, anchor);
1100
1171
  },
1101
1172
  p(ctx, dirty) {
1102
- if (dirty[0] & /*results*/ 2 && raw_value !== (raw_value = /*result*/ ctx[38].string + "")) html_tag.p(raw_value);
1173
+ if (dirty[0] & /*results*/ 2 && raw_value !== (raw_value = /*result*/ ctx[39].string + "")) html_tag.p(raw_value);
1103
1174
  },
1104
1175
  d(detaching) {
1105
1176
  if (detaching) detach(html_anchor);
@@ -1108,7 +1179,7 @@ function fallback_block(ctx) {
1108
1179
  };
1109
1180
  }
1110
1181
 
1111
- // (183:6) {#each results as result, i}
1182
+ // (181:6) {#each results as result, i}
1112
1183
  function create_each_block(ctx) {
1113
1184
  let li;
1114
1185
  let t;
@@ -1117,12 +1188,12 @@ function create_each_block(ctx) {
1117
1188
  let current;
1118
1189
  let mounted;
1119
1190
  let dispose;
1120
- const default_slot_template = /*#slots*/ ctx[19].default;
1121
- const default_slot = create_slot(default_slot_template, ctx, /*$$scope*/ ctx[18], get_default_slot_context);
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);
1122
1193
  const default_slot_or_fallback = default_slot || fallback_block(ctx);
1123
1194
 
1124
1195
  function click_handler_1() {
1125
- return /*click_handler_1*/ ctx[33](/*result*/ ctx[38], /*i*/ ctx[40]);
1196
+ return /*click_handler_1*/ ctx[34](/*result*/ ctx[39], /*i*/ ctx[41]);
1126
1197
  }
1127
1198
 
1128
1199
  return {
@@ -1131,11 +1202,11 @@ function create_each_block(ctx) {
1131
1202
  if (default_slot_or_fallback) default_slot_or_fallback.c();
1132
1203
  t = space();
1133
1204
  attr(li, "role", "option");
1134
- attr(li, "id", li_id_value = "" + (/*id*/ ctx[2] + "-result-" + /*i*/ ctx[40]));
1135
- attr(li, "aria-selected", li_aria_selected_value = /*selectedIndex*/ ctx[6] === /*i*/ ctx[40]);
1136
- attr(li, "class", "svelte-t0wd5r");
1137
- toggle_class(li, "selected", /*selectedIndex*/ ctx[6] === /*i*/ ctx[40]);
1138
- toggle_class(li, "disabled", /*result*/ ctx[38].disabled);
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]);
1207
+ 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);
1139
1210
  },
1140
1211
  m(target, anchor) {
1141
1212
  insert(target, li, anchor);
@@ -1156,29 +1227,38 @@ function create_each_block(ctx) {
1156
1227
  ctx = new_ctx;
1157
1228
 
1158
1229
  if (default_slot) {
1159
- if (default_slot.p && dirty[0] & /*$$scope, results*/ 262146) {
1160
- update_slot(default_slot, default_slot_template, ctx, /*$$scope*/ ctx[18], dirty, get_default_slot_changes, get_default_slot_context);
1230
+ if (default_slot.p && (!current || dirty[0] & /*$$scope, results, value*/ 524291)) {
1231
+ update_slot_base(
1232
+ default_slot,
1233
+ default_slot_template,
1234
+ ctx,
1235
+ /*$$scope*/ ctx[19],
1236
+ !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),
1239
+ get_default_slot_context
1240
+ );
1161
1241
  }
1162
1242
  } else {
1163
- if (default_slot_or_fallback && default_slot_or_fallback.p && dirty[0] & /*results*/ 2) {
1164
- default_slot_or_fallback.p(ctx, dirty);
1243
+ if (default_slot_or_fallback && default_slot_or_fallback.p && (!current || dirty[0] & /*results*/ 2)) {
1244
+ default_slot_or_fallback.p(ctx, !current ? [-1, -1] : dirty);
1165
1245
  }
1166
1246
  }
1167
1247
 
1168
- if (!current || dirty[0] & /*id*/ 4 && li_id_value !== (li_id_value = "" + (/*id*/ ctx[2] + "-result-" + /*i*/ ctx[40]))) {
1248
+ if (!current || dirty[0] & /*id*/ 4 && li_id_value !== (li_id_value = "" + (/*id*/ ctx[2] + "-result-" + /*i*/ ctx[41]))) {
1169
1249
  attr(li, "id", li_id_value);
1170
1250
  }
1171
1251
 
1172
- if (!current || dirty[0] & /*selectedIndex*/ 64 && li_aria_selected_value !== (li_aria_selected_value = /*selectedIndex*/ ctx[6] === /*i*/ ctx[40])) {
1252
+ if (!current || dirty[0] & /*selectedIndex*/ 64 && li_aria_selected_value !== (li_aria_selected_value = /*selectedIndex*/ ctx[6] === /*i*/ ctx[41])) {
1173
1253
  attr(li, "aria-selected", li_aria_selected_value);
1174
1254
  }
1175
1255
 
1176
1256
  if (dirty[0] & /*selectedIndex*/ 64) {
1177
- toggle_class(li, "selected", /*selectedIndex*/ ctx[6] === /*i*/ ctx[40]);
1257
+ toggle_class(li, "selected", /*selectedIndex*/ ctx[6] === /*i*/ ctx[41]);
1178
1258
  }
1179
1259
 
1180
1260
  if (dirty[0] & /*results*/ 2) {
1181
- toggle_class(li, "disabled", /*result*/ ctx[38].disabled);
1261
+ toggle_class(li, "disabled", /*result*/ ctx[39].disabled);
1182
1262
  }
1183
1263
  },
1184
1264
  i(local) {
@@ -1199,12 +1279,71 @@ function create_each_block(ctx) {
1199
1279
  };
1200
1280
  }
1201
1281
 
1282
+ // (201:4) {#if $$slots["no-results"] && !hideDropdown && value.length > 0 && results.length === 0}
1283
+ function create_if_block(ctx) {
1284
+ let div;
1285
+ 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);
1288
+
1289
+ return {
1290
+ c() {
1291
+ div = element("div");
1292
+ if (no_results_slot) no_results_slot.c();
1293
+ attr(div, "class", "svelte-j5n77y");
1294
+ toggle_class(div, "no-results", true);
1295
+ },
1296
+ m(target, anchor) {
1297
+ insert(target, div, anchor);
1298
+
1299
+ if (no_results_slot) {
1300
+ no_results_slot.m(div, null);
1301
+ }
1302
+
1303
+ current = true;
1304
+ },
1305
+ p(ctx, dirty) {
1306
+ if (no_results_slot) {
1307
+ if (no_results_slot.p && (!current || dirty[0] & /*$$scope, value, results*/ 524291)) {
1308
+ update_slot_base(
1309
+ no_results_slot,
1310
+ no_results_slot_template,
1311
+ ctx,
1312
+ /*$$scope*/ ctx[19],
1313
+ !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),
1316
+ get_no_results_slot_context
1317
+ );
1318
+ }
1319
+ }
1320
+ },
1321
+ i(local) {
1322
+ if (current) return;
1323
+ transition_in(no_results_slot, local);
1324
+ current = true;
1325
+ },
1326
+ o(local) {
1327
+ transition_out(no_results_slot, local);
1328
+ current = false;
1329
+ },
1330
+ d(detaching) {
1331
+ if (detaching) detach(div);
1332
+ if (no_results_slot) no_results_slot.d(detaching);
1333
+ }
1334
+ };
1335
+ }
1336
+
1202
1337
  function create_fragment(ctx) {
1203
1338
  let div;
1204
1339
  let search;
1205
1340
  let updating_ref;
1206
1341
  let updating_value;
1207
- let t;
1342
+ let t0;
1343
+ let ul;
1344
+ let t1;
1345
+ let ul_aria_labelledby_value;
1346
+ let ul_id_value;
1208
1347
  let div_aria_owns_value;
1209
1348
  let div_aria_expanded_value;
1210
1349
  let div_id_value;
@@ -1214,7 +1353,8 @@ function create_fragment(ctx) {
1214
1353
 
1215
1354
  const search_spread_levels = [
1216
1355
  { id: /*id*/ ctx[2] },
1217
- /*$$restProps*/ ctx[8],
1356
+ { removeFormAriaAttributes: true },
1357
+ /*$$restProps*/ ctx[9],
1218
1358
  { "aria-autocomplete": "list" },
1219
1359
  {
1220
1360
  "aria-controls": "" + (/*id*/ ctx[2] + "-listbox")
@@ -1222,15 +1362,19 @@ function create_fragment(ctx) {
1222
1362
  {
1223
1363
  "aria-labelledby": "" + (/*id*/ ctx[2] + "-label")
1224
1364
  },
1225
- { "aria-activedescendant": "" }
1365
+ {
1366
+ "aria-activedescendant": /*selectedIndex*/ ctx[6] >= 0 && !/*hideDropdown*/ ctx[5] && /*results*/ ctx[1].length > 0
1367
+ ? `${/*id*/ ctx[2]}-result-${/*selectedIndex*/ ctx[6]}`
1368
+ : null
1369
+ }
1226
1370
  ];
1227
1371
 
1228
1372
  function search_ref_binding(value) {
1229
- /*search_ref_binding*/ ctx[21](value);
1373
+ /*search_ref_binding*/ ctx[22](value);
1230
1374
  }
1231
1375
 
1232
1376
  function search_value_binding(value) {
1233
- /*search_value_binding*/ ctx[22](value);
1377
+ /*search_value_binding*/ ctx[23](value);
1234
1378
  }
1235
1379
 
1236
1380
  let search_props = {};
@@ -1247,62 +1391,79 @@ function create_fragment(ctx) {
1247
1391
  search_props.value = /*value*/ ctx[0];
1248
1392
  }
1249
1393
 
1250
- search = new Search({ props: search_props });
1251
- binding_callbacks.push(() => bind(search, "ref", search_ref_binding));
1252
- binding_callbacks.push(() => bind(search, "value", search_value_binding));
1253
- search.$on("type", /*type_handler*/ ctx[23]);
1254
- search.$on("input", /*input_handler*/ ctx[24]);
1255
- search.$on("change", /*change_handler*/ ctx[25]);
1256
- search.$on("focus", /*focus_handler*/ ctx[26]);
1257
- search.$on("focus", /*focus_handler_1*/ ctx[27]);
1258
- search.$on("clear", /*clear_handler*/ ctx[28]);
1259
- search.$on("clear", /*clear_handler_1*/ ctx[29]);
1260
- search.$on("blur", /*blur_handler*/ ctx[30]);
1261
- search.$on("keydown", /*keydown_handler*/ ctx[31]);
1262
- search.$on("keydown", /*keydown_handler_1*/ ctx[32]);
1263
- let if_block = !/*hideDropdown*/ ctx[5] && /*results*/ ctx[1].length > 0 && create_if_block(ctx);
1394
+ search = new Search$1({ props: search_props });
1395
+ binding_callbacks.push(() => bind(search, 'ref', search_ref_binding));
1396
+ 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]);
1407
+ 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);
1264
1409
 
1265
1410
  return {
1266
1411
  c() {
1267
1412
  div = element("div");
1268
1413
  create_component(search.$$.fragment);
1269
- t = space();
1270
- if (if_block) if_block.c();
1414
+ t0 = space();
1415
+ ul = element("ul");
1416
+ if (if_block0) if_block0.c();
1417
+ t1 = space();
1418
+ if (if_block1) if_block1.c();
1419
+ attr(ul, "role", "listbox");
1420
+ attr(ul, "aria-labelledby", ul_aria_labelledby_value = "" + (/*id*/ ctx[2] + "-label"));
1421
+ attr(ul, "id", ul_id_value = "" + (/*id*/ ctx[2] + "-listbox"));
1422
+ attr(ul, "class", "svelte-j5n77y");
1423
+ toggle_class(ul, "svelte-typeahead-list", true);
1271
1424
  attr(div, "data-svelte-typeahead", "");
1272
1425
  attr(div, "role", "combobox");
1273
1426
  attr(div, "aria-haspopup", "listbox");
1274
1427
  attr(div, "aria-owns", div_aria_owns_value = "" + (/*id*/ ctx[2] + "-listbox"));
1275
1428
  attr(div, "aria-expanded", div_aria_expanded_value = !/*hideDropdown*/ ctx[5] && /*results*/ ctx[1].length > 0);
1276
1429
  attr(div, "id", div_id_value = "" + (/*id*/ ctx[2] + "-typeahead"));
1277
- attr(div, "class", "svelte-t0wd5r");
1430
+ attr(div, "class", "svelte-j5n77y");
1278
1431
  toggle_class(div, "dropdown", /*results*/ ctx[1].length > 0);
1279
1432
  },
1280
1433
  m(target, anchor) {
1281
1434
  insert(target, div, anchor);
1282
1435
  mount_component(search, div, null);
1283
- append(div, t);
1284
- if (if_block) if_block.m(div, null);
1285
- /*div_binding*/ ctx[34](div);
1436
+ append(div, t0);
1437
+ append(div, ul);
1438
+ if (if_block0) if_block0.m(ul, null);
1439
+ append(ul, t1);
1440
+ if (if_block1) if_block1.m(ul, null);
1441
+ /*div_binding*/ ctx[35](div);
1286
1442
  current = true;
1287
1443
 
1288
1444
  if (!mounted) {
1289
- dispose = listen(window, "click", /*click_handler*/ ctx[20]);
1445
+ dispose = listen(window, "click", /*click_handler*/ ctx[21]);
1290
1446
  mounted = true;
1291
1447
  }
1292
1448
  },
1293
1449
  p(ctx, dirty) {
1294
- const search_changes = (dirty[0] & /*id, $$restProps*/ 260)
1450
+ const search_changes = (dirty[0] & /*id, $$restProps, selectedIndex, hideDropdown, results*/ 614)
1295
1451
  ? get_spread_update(search_spread_levels, [
1296
1452
  dirty[0] & /*id*/ 4 && { id: /*id*/ ctx[2] },
1297
- dirty[0] & /*$$restProps*/ 256 && get_spread_object(/*$$restProps*/ ctx[8]),
1298
- search_spread_levels[2],
1453
+ search_spread_levels[1],
1454
+ dirty[0] & /*$$restProps*/ 512 && get_spread_object(/*$$restProps*/ ctx[9]),
1455
+ search_spread_levels[3],
1299
1456
  dirty[0] & /*id*/ 4 && {
1300
1457
  "aria-controls": "" + (/*id*/ ctx[2] + "-listbox")
1301
1458
  },
1302
1459
  dirty[0] & /*id*/ 4 && {
1303
1460
  "aria-labelledby": "" + (/*id*/ ctx[2] + "-label")
1304
1461
  },
1305
- search_spread_levels[5]
1462
+ dirty[0] & /*selectedIndex, hideDropdown, results, id*/ 102 && {
1463
+ "aria-activedescendant": /*selectedIndex*/ ctx[6] >= 0 && !/*hideDropdown*/ ctx[5] && /*results*/ ctx[1].length > 0
1464
+ ? `${/*id*/ ctx[2]}-result-${/*selectedIndex*/ ctx[6]}`
1465
+ : null
1466
+ }
1306
1467
  ])
1307
1468
  : {};
1308
1469
 
@@ -1321,28 +1482,59 @@ function create_fragment(ctx) {
1321
1482
  search.$set(search_changes);
1322
1483
 
1323
1484
  if (!/*hideDropdown*/ ctx[5] && /*results*/ ctx[1].length > 0) {
1324
- if (if_block) {
1325
- if_block.p(ctx, dirty);
1485
+ if (if_block0) {
1486
+ if_block0.p(ctx, dirty);
1326
1487
 
1327
1488
  if (dirty[0] & /*hideDropdown, results*/ 34) {
1328
- transition_in(if_block, 1);
1489
+ transition_in(if_block0, 1);
1329
1490
  }
1330
1491
  } else {
1331
- if_block = create_if_block(ctx);
1332
- if_block.c();
1333
- transition_in(if_block, 1);
1334
- if_block.m(div, null);
1492
+ if_block0 = create_if_block_1(ctx);
1493
+ if_block0.c();
1494
+ transition_in(if_block0, 1);
1495
+ if_block0.m(ul, t1);
1335
1496
  }
1336
- } else if (if_block) {
1497
+ } else if (if_block0) {
1337
1498
  group_outros();
1338
1499
 
1339
- transition_out(if_block, 1, 1, () => {
1340
- if_block = null;
1500
+ transition_out(if_block0, 1, 1, () => {
1501
+ if_block0 = null;
1341
1502
  });
1342
1503
 
1343
1504
  check_outros();
1344
1505
  }
1345
1506
 
1507
+ if (/*$$slots*/ ctx[8]["no-results"] && !/*hideDropdown*/ ctx[5] && /*value*/ ctx[0].length > 0 && /*results*/ ctx[1].length === 0) {
1508
+ if (if_block1) {
1509
+ if_block1.p(ctx, dirty);
1510
+
1511
+ if (dirty[0] & /*$$slots, hideDropdown, value, results*/ 291) {
1512
+ transition_in(if_block1, 1);
1513
+ }
1514
+ } else {
1515
+ if_block1 = create_if_block(ctx);
1516
+ if_block1.c();
1517
+ transition_in(if_block1, 1);
1518
+ if_block1.m(ul, null);
1519
+ }
1520
+ } else if (if_block1) {
1521
+ group_outros();
1522
+
1523
+ transition_out(if_block1, 1, 1, () => {
1524
+ if_block1 = null;
1525
+ });
1526
+
1527
+ check_outros();
1528
+ }
1529
+
1530
+ if (!current || dirty[0] & /*id*/ 4 && ul_aria_labelledby_value !== (ul_aria_labelledby_value = "" + (/*id*/ ctx[2] + "-label"))) {
1531
+ attr(ul, "aria-labelledby", ul_aria_labelledby_value);
1532
+ }
1533
+
1534
+ if (!current || dirty[0] & /*id*/ 4 && ul_id_value !== (ul_id_value = "" + (/*id*/ ctx[2] + "-listbox"))) {
1535
+ attr(ul, "id", ul_id_value);
1536
+ }
1537
+
1346
1538
  if (!current || dirty[0] & /*id*/ 4 && div_aria_owns_value !== (div_aria_owns_value = "" + (/*id*/ ctx[2] + "-listbox"))) {
1347
1539
  attr(div, "aria-owns", div_aria_owns_value);
1348
1540
  }
@@ -1362,19 +1554,22 @@ function create_fragment(ctx) {
1362
1554
  i(local) {
1363
1555
  if (current) return;
1364
1556
  transition_in(search.$$.fragment, local);
1365
- transition_in(if_block);
1557
+ transition_in(if_block0);
1558
+ transition_in(if_block1);
1366
1559
  current = true;
1367
1560
  },
1368
1561
  o(local) {
1369
1562
  transition_out(search.$$.fragment, local);
1370
- transition_out(if_block);
1563
+ transition_out(if_block0);
1564
+ transition_out(if_block1);
1371
1565
  current = false;
1372
1566
  },
1373
1567
  d(detaching) {
1374
1568
  if (detaching) detach(div);
1375
1569
  destroy_component(search);
1376
- if (if_block) if_block.d();
1377
- /*div_binding*/ ctx[34](null);
1570
+ if (if_block0) if_block0.d();
1571
+ if (if_block1) if_block1.d();
1572
+ /*div_binding*/ ctx[35](null);
1378
1573
  mounted = false;
1379
1574
  dispose();
1380
1575
  }
@@ -1391,6 +1586,7 @@ function instance($$self, $$props, $$invalidate) {
1391
1586
 
1392
1587
  let $$restProps = compute_rest_props($$props, omit_props_names);
1393
1588
  let { $$slots: slots = {}, $$scope } = $$props;
1589
+ const $$slots = compute_slots(slots);
1394
1590
  let { id = "typeahead-" + Math.random().toString(36) } = $$props;
1395
1591
  let { value = "" } = $$props;
1396
1592
  let { data = [] } = $$props;
@@ -1414,7 +1610,7 @@ function instance($$self, $$props, $$invalidate) {
1414
1610
  $$invalidate(6, selectedIndex = 0);
1415
1611
  }
1416
1612
 
1417
- if (prevResults !== resultsId) {
1613
+ if (prevResults !== resultsId && !$$slots["no-results"]) {
1418
1614
  $$invalidate(5, hideDropdown = results.length === 0);
1419
1615
  }
1420
1616
 
@@ -1442,7 +1638,7 @@ function instance($$self, $$props, $$invalidate) {
1442
1638
  }
1443
1639
 
1444
1640
  const click_handler = ({ target }) => {
1445
- if (!hideDropdown && results.length > 0 && comboboxRef && !comboboxRef.contains(target)) {
1641
+ if (!hideDropdown && comboboxRef && !comboboxRef.contains(target)) {
1446
1642
  $$invalidate(5, hideDropdown = true);
1447
1643
  }
1448
1644
  };
@@ -1458,19 +1654,19 @@ function instance($$self, $$props, $$invalidate) {
1458
1654
  }
1459
1655
 
1460
1656
  function type_handler(event) {
1461
- bubble($$self, event);
1657
+ bubble.call(this, $$self, event);
1462
1658
  }
1463
1659
 
1464
1660
  function input_handler(event) {
1465
- bubble($$self, event);
1661
+ bubble.call(this, $$self, event);
1466
1662
  }
1467
1663
 
1468
1664
  function change_handler(event) {
1469
- bubble($$self, event);
1665
+ bubble.call(this, $$self, event);
1470
1666
  }
1471
1667
 
1472
1668
  function focus_handler(event) {
1473
- bubble($$self, event);
1669
+ bubble.call(this, $$self, event);
1474
1670
  }
1475
1671
 
1476
1672
  const focus_handler_1 = () => {
@@ -1478,7 +1674,7 @@ function instance($$self, $$props, $$invalidate) {
1478
1674
  };
1479
1675
 
1480
1676
  function clear_handler(event) {
1481
- bubble($$self, event);
1677
+ bubble.call(this, $$self, event);
1482
1678
  }
1483
1679
 
1484
1680
  const clear_handler_1 = () => {
@@ -1486,14 +1682,16 @@ function instance($$self, $$props, $$invalidate) {
1486
1682
  };
1487
1683
 
1488
1684
  function blur_handler(event) {
1489
- bubble($$self, event);
1685
+ bubble.call(this, $$self, event);
1490
1686
  }
1491
1687
 
1492
1688
  function keydown_handler(event) {
1493
- bubble($$self, event);
1689
+ bubble.call(this, $$self, event);
1494
1690
  }
1495
1691
 
1496
1692
  const keydown_handler_1 = e => {
1693
+ if (results.length === 0) return;
1694
+
1497
1695
  switch (e.key) {
1498
1696
  case "Enter":
1499
1697
  select();
@@ -1529,7 +1727,7 @@ function instance($$self, $$props, $$invalidate) {
1529
1727
  };
1530
1728
 
1531
1729
  function div_binding($$value) {
1532
- binding_callbacks[$$value ? "unshift" : "push"](() => {
1730
+ binding_callbacks[$$value ? 'unshift' : 'push'](() => {
1533
1731
  comboboxRef = $$value;
1534
1732
  $$invalidate(3, comboboxRef);
1535
1733
  });
@@ -1537,34 +1735,34 @@ function instance($$self, $$props, $$invalidate) {
1537
1735
 
1538
1736
  $$self.$$set = $$new_props => {
1539
1737
  $$props = assign(assign({}, $$props), exclude_internal_props($$new_props));
1540
- $$invalidate(8, $$restProps = compute_rest_props($$props, omit_props_names));
1541
- if ("id" in $$new_props) $$invalidate(2, id = $$new_props.id);
1542
- if ("value" in $$new_props) $$invalidate(0, value = $$new_props.value);
1543
- if ("data" in $$new_props) $$invalidate(9, data = $$new_props.data);
1544
- if ("extract" in $$new_props) $$invalidate(10, extract = $$new_props.extract);
1545
- if ("disable" in $$new_props) $$invalidate(11, disable = $$new_props.disable);
1546
- if ("filter" in $$new_props) $$invalidate(12, filter = $$new_props.filter);
1547
- if ("autoselect" in $$new_props) $$invalidate(13, autoselect = $$new_props.autoselect);
1548
- if ("inputAfterSelect" in $$new_props) $$invalidate(14, inputAfterSelect = $$new_props.inputAfterSelect);
1549
- if ("results" in $$new_props) $$invalidate(1, results = $$new_props.results);
1550
- if ("focusAfterSelect" in $$new_props) $$invalidate(15, focusAfterSelect = $$new_props.focusAfterSelect);
1551
- if ("limit" in $$new_props) $$invalidate(16, limit = $$new_props.limit);
1552
- if ("$$scope" in $$new_props) $$invalidate(18, $$scope = $$new_props.$$scope);
1738
+ $$invalidate(9, $$restProps = compute_rest_props($$props, omit_props_names));
1739
+ if ('id' in $$new_props) $$invalidate(2, id = $$new_props.id);
1740
+ 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);
1747
+ 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);
1553
1751
  };
1554
1752
 
1555
1753
  $$self.$$.update = () => {
1556
- if ($$self.$$.dirty[0] & /*extract*/ 1024) {
1557
- $$invalidate(17, options = { pre: "<mark>", post: "</mark>", extract });
1754
+ if ($$self.$$.dirty[0] & /*extract*/ 2048) {
1755
+ $$invalidate(18, options = { pre: "<mark>", post: "</mark>", extract });
1558
1756
  }
1559
1757
 
1560
- if ($$self.$$.dirty[0] & /*value, data, options, limit, filter, disable*/ 203265) {
1758
+ if ($$self.$$.dirty[0] & /*value, data, options, limit, filter, disable*/ 406529) {
1561
1759
  $$invalidate(1, results = fuzzy.filter(value, data, options).filter(({ score }) => score > 0).slice(0, limit).filter(result => !filter(result.original)).map(result => ({
1562
1760
  ...result,
1563
1761
  disabled: disable(result.original)
1564
1762
  })));
1565
1763
  }
1566
1764
 
1567
- if ($$self.$$.dirty[0] & /*results, extract*/ 1026) {
1765
+ if ($$self.$$.dirty[0] & /*results, extract*/ 2050) {
1568
1766
  resultsId = results.map(result => extract(result.original)).join("");
1569
1767
  }
1570
1768
  };
@@ -1578,6 +1776,7 @@ function instance($$self, $$props, $$invalidate) {
1578
1776
  hideDropdown,
1579
1777
  selectedIndex,
1580
1778
  select,
1779
+ $$slots,
1581
1780
  $$restProps,
1582
1781
  data,
1583
1782
  extract,
@@ -1611,7 +1810,6 @@ function instance($$self, $$props, $$invalidate) {
1611
1810
  class Typeahead extends SvelteComponent {
1612
1811
  constructor(options) {
1613
1812
  super();
1614
- if (!document.getElementById("svelte-t0wd5r-style")) add_css();
1615
1813
 
1616
1814
  init(
1617
1815
  this,
@@ -1622,19 +1820,22 @@ class Typeahead extends SvelteComponent {
1622
1820
  {
1623
1821
  id: 2,
1624
1822
  value: 0,
1625
- data: 9,
1626
- extract: 10,
1627
- disable: 11,
1628
- filter: 12,
1629
- autoselect: 13,
1630
- inputAfterSelect: 14,
1823
+ data: 10,
1824
+ extract: 11,
1825
+ disable: 12,
1826
+ filter: 13,
1827
+ autoselect: 14,
1828
+ inputAfterSelect: 15,
1631
1829
  results: 1,
1632
- focusAfterSelect: 15,
1633
- limit: 16
1830
+ focusAfterSelect: 16,
1831
+ limit: 17
1634
1832
  },
1833
+ add_css,
1635
1834
  [-1, -1]
1636
1835
  );
1637
1836
  }
1638
1837
  }
1639
1838
 
1640
- export default Typeahead;
1839
+ var Typeahead$1 = Typeahead;
1840
+
1841
+ export { Typeahead$1 as default };