svelte-typeahead 4.4.1 → 4.4.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/lib/index.js CHANGED
@@ -126,7 +126,9 @@
126
126
  target.insertBefore(node, anchor || null);
127
127
  }
128
128
  function detach(node) {
129
- node.parentNode.removeChild(node);
129
+ if (node.parentNode) {
130
+ node.parentNode.removeChild(node);
131
+ }
130
132
  }
131
133
  function destroy_each(iterations, detaching) {
132
134
  for (let i = 0; i < iterations.length; i += 1) {
@@ -166,6 +168,14 @@
166
168
  else if (node.getAttribute(attribute) !== value)
167
169
  node.setAttribute(attribute, value);
168
170
  }
171
+ /**
172
+ * List of attributes that should always be set through the attr method,
173
+ * because updating them through the property setter doesn't work reliably.
174
+ * In the example of `width`/`height`, the problem is that the setter only
175
+ * accepts numeric values, but the attribute can also be set to a string like `50%`.
176
+ * If this list becomes too big, rethink this approach.
177
+ */
178
+ const always_set_through_set_attribute = ['width', 'height'];
169
179
  function set_attributes(node, attributes) {
170
180
  // @ts-ignore
171
181
  const descriptors = Object.getOwnPropertyDescriptors(node.__proto__);
@@ -179,7 +189,7 @@
179
189
  else if (key === '__value') {
180
190
  node.value = node[key] = attributes[key];
181
191
  }
182
- else if (descriptors[key] && descriptors[key].set) {
192
+ else if (descriptors[key] && descriptors[key].set && always_set_through_set_attribute.indexOf(key) === -1) {
183
193
  node[key] = attributes[key];
184
194
  }
185
195
  else {
@@ -192,8 +202,9 @@
192
202
  }
193
203
  function set_data(text, data) {
194
204
  data = '' + data;
195
- if (text.wholeText !== data)
196
- text.data = data;
205
+ if (text.data === data)
206
+ return;
207
+ text.data = data;
197
208
  }
198
209
  function set_input_value(input, value) {
199
210
  input.value = value == null ? '' : value;
@@ -219,16 +230,17 @@
219
230
  if (!this.e) {
220
231
  if (this.is_svg)
221
232
  this.e = svg_element(target.nodeName);
233
+ /** #7364 target for <template> may be provided as #document-fragment(11) */
222
234
  else
223
- this.e = element(target.nodeName);
224
- this.t = target;
235
+ this.e = element((target.nodeType === 11 ? 'TEMPLATE' : target.nodeName));
236
+ this.t = target.tagName !== 'TEMPLATE' ? target : target.content;
225
237
  this.c(html);
226
238
  }
227
239
  this.i(anchor);
228
240
  }
229
241
  h(html) {
230
242
  this.e.innerHTML = html;
231
- this.n = Array.from(this.e.childNodes);
243
+ this.n = Array.from(this.e.nodeName === 'TEMPLATE' ? this.e.content.childNodes : this.e.childNodes);
232
244
  }
233
245
  i(anchor) {
234
246
  for (let i = 0; i < this.n.length; i += 1) {
@@ -315,9 +327,9 @@
315
327
 
316
328
  const dirty_components = [];
317
329
  const binding_callbacks = [];
318
- const render_callbacks = [];
330
+ let render_callbacks = [];
319
331
  const flush_callbacks = [];
320
- const resolved_promise = Promise.resolve();
332
+ const resolved_promise = /* @__PURE__ */ Promise.resolve();
321
333
  let update_scheduled = false;
322
334
  function schedule_update() {
323
335
  if (!update_scheduled) {
@@ -356,15 +368,29 @@
356
368
  const seen_callbacks = new Set();
357
369
  let flushidx = 0; // Do *not* move this inside the flush() function
358
370
  function flush() {
371
+ // Do not reenter flush while dirty components are updated, as this can
372
+ // result in an infinite loop. Instead, let the inner flush handle it.
373
+ // Reentrancy is ok afterwards for bindings etc.
374
+ if (flushidx !== 0) {
375
+ return;
376
+ }
359
377
  const saved_component = current_component;
360
378
  do {
361
379
  // first, call beforeUpdate functions
362
380
  // and update components
363
- while (flushidx < dirty_components.length) {
364
- const component = dirty_components[flushidx];
365
- flushidx++;
366
- set_current_component(component);
367
- update(component.$$);
381
+ try {
382
+ while (flushidx < dirty_components.length) {
383
+ const component = dirty_components[flushidx];
384
+ flushidx++;
385
+ set_current_component(component);
386
+ update(component.$$);
387
+ }
388
+ }
389
+ catch (e) {
390
+ // reset dirty state to not end up in a deadlocked state and then rethrow
391
+ dirty_components.length = 0;
392
+ flushidx = 0;
393
+ throw e;
368
394
  }
369
395
  set_current_component(null);
370
396
  dirty_components.length = 0;
@@ -401,6 +427,16 @@
401
427
  $$.after_update.forEach(add_render_callback);
402
428
  }
403
429
  }
430
+ /**
431
+ * Useful for example to execute remaining `afterUpdate` callbacks before executing `destroy`.
432
+ */
433
+ function flush_render_callbacks(fns) {
434
+ const filtered = [];
435
+ const targets = [];
436
+ render_callbacks.forEach((c) => fns.indexOf(c) === -1 ? filtered.push(c) : targets.push(c));
437
+ targets.forEach((c) => c());
438
+ render_callbacks = filtered;
439
+ }
404
440
  const outroing = new Set();
405
441
  let outros;
406
442
  function group_outros() {
@@ -515,6 +551,7 @@
515
551
  function destroy_component(component, detaching) {
516
552
  const $$ = component.$$;
517
553
  if ($$.fragment !== null) {
554
+ flush_render_callbacks($$.after_update);
518
555
  run_all($$.on_destroy);
519
556
  $$.fragment && $$.fragment.d(detaching);
520
557
  // TODO null out other refs, including component.$$ (but need to
@@ -767,16 +804,11 @@
767
804
 
768
805
  var fuzzy = fuzzy$1.exports;
769
806
 
770
- /* node_modules/svelte-search/src/Search.svelte generated by Svelte v3.52.0 */
771
-
772
- function add_css$1(target) {
773
- 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}");
774
- }
775
-
807
+ /* node_modules/svelte-search/src/Search.svelte generated by Svelte v3.59.2 */
776
808
  const get_label_slot_changes = dirty => ({});
777
809
  const get_label_slot_context = ctx => ({});
778
810
 
779
- // (60:23) {label}
811
+ // (94:23) {label}
780
812
  function fallback_block$1(ctx) {
781
813
  let t;
782
814
 
@@ -800,6 +832,7 @@
800
832
  let form;
801
833
  let label_1;
802
834
  let label_1_id_value;
835
+ let label_1_style_value;
803
836
  let t;
804
837
  let input;
805
838
  let form_role_value;
@@ -836,16 +869,16 @@
836
869
  input = element("input");
837
870
  attr(label_1, "id", label_1_id_value = "" + (/*id*/ ctx[4] + "-label"));
838
871
  attr(label_1, "for", /*id*/ ctx[4]);
839
- attr(label_1, "class", "svelte-5m0wg6");
840
- toggle_class(label_1, "hide-label", /*hideLabel*/ ctx[3]);
872
+ attr(label_1, "style", label_1_style_value = /*hideLabel*/ ctx[3] && "position: absolute;height: 1px;width: 1px;overflow: hidden;clip: rect(1px 1px 1px 1px);clip: rect(1px, 1px, 1px, 1px);white-space: nowrap;");
841
873
  set_attributes(input, input_data);
842
- toggle_class(input, "svelte-5m0wg6", true);
843
874
  attr(form, "data-svelte-search", "");
844
875
  attr(form, "role", form_role_value = /*removeFormAriaAttributes*/ ctx[5] ? null : "search");
845
876
 
846
877
  attr(form, "aria-labelledby", form_aria_labelledby_value = /*removeFormAriaAttributes*/ ctx[5]
847
878
  ? null
848
879
  : /*id*/ ctx[4]);
880
+
881
+ attr(form, "action", "");
849
882
  },
850
883
  m(target, anchor) {
851
884
  insert(target, form, anchor);
@@ -904,8 +937,8 @@
904
937
  attr(label_1, "for", /*id*/ ctx[4]);
905
938
  }
906
939
 
907
- if (!current || dirty & /*hideLabel*/ 8) {
908
- toggle_class(label_1, "hide-label", /*hideLabel*/ ctx[3]);
940
+ if (!current || dirty & /*hideLabel*/ 8 && label_1_style_value !== (label_1_style_value = /*hideLabel*/ ctx[3] && "position: absolute;height: 1px;width: 1px;overflow: hidden;clip: rect(1px 1px 1px 1px);clip: rect(1px, 1px, 1px, 1px);white-space: nowrap;")) {
941
+ attr(label_1, "style", label_1_style_value);
909
942
  }
910
943
 
911
944
  set_attributes(input, input_data = get_spread_update(input_levels, [
@@ -918,12 +951,10 @@
918
951
  (!current || dirty & /*id*/ 16) && { id: /*id*/ ctx[4] }
919
952
  ]));
920
953
 
921
- if (dirty & /*value*/ 1) {
954
+ if (dirty & /*value*/ 1 && input.value !== /*value*/ ctx[0]) {
922
955
  set_input_value(input, /*value*/ ctx[0]);
923
956
  }
924
957
 
925
- toggle_class(input, "svelte-5m0wg6", true);
926
-
927
958
  if (!current || dirty & /*removeFormAriaAttributes*/ 32 && form_role_value !== (form_role_value = /*removeFormAriaAttributes*/ ctx[5] ? null : "search")) {
928
959
  attr(form, "role", form_role_value);
929
960
  }
@@ -973,13 +1004,14 @@
973
1004
  let timeout = undefined;
974
1005
  let calling = false;
975
1006
 
976
- function debounced(cb) {
1007
+ /** @type {() => any;} */
1008
+ function debounceFn(fn) {
977
1009
  if (calling) return;
978
1010
  calling = true;
979
1011
 
980
1012
  timeout = setTimeout(
981
1013
  () => {
982
- cb();
1014
+ fn();
983
1015
  calling = false;
984
1016
  },
985
1017
  debounce
@@ -994,7 +1026,7 @@
994
1026
  afterUpdate(() => {
995
1027
  if (value.length > 0 && value !== prevValue) {
996
1028
  if (debounce > 0) {
997
- debounced(() => dispatch("type", value));
1029
+ debounceFn(() => dispatch("type", value));
998
1030
  } else {
999
1031
  dispatch("type", value);
1000
1032
  }
@@ -1081,30 +1113,20 @@
1081
1113
  constructor(options) {
1082
1114
  super();
1083
1115
 
1084
- init(
1085
- this,
1086
- options,
1087
- instance$1,
1088
- create_fragment$1,
1089
- safe_not_equal,
1090
- {
1091
- value: 0,
1092
- autofocus: 7,
1093
- debounce: 8,
1094
- label: 2,
1095
- hideLabel: 3,
1096
- id: 4,
1097
- ref: 1,
1098
- removeFormAriaAttributes: 5
1099
- },
1100
- add_css$1
1101
- );
1116
+ init(this, options, instance$1, create_fragment$1, safe_not_equal, {
1117
+ value: 0,
1118
+ autofocus: 7,
1119
+ debounce: 8,
1120
+ label: 2,
1121
+ hideLabel: 3,
1122
+ id: 4,
1123
+ ref: 1,
1124
+ removeFormAriaAttributes: 5
1125
+ });
1102
1126
  }
1103
1127
  }
1104
1128
 
1105
- var Search$1 = Search;
1106
-
1107
- /* src/Typeahead.svelte generated by Svelte v3.52.0 */
1129
+ /* src/Typeahead.svelte generated by Svelte v3.59.2 */
1108
1130
 
1109
1131
  function add_css(target) {
1110
1132
  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}");
@@ -1164,7 +1186,9 @@
1164
1186
  },
1165
1187
  m(target, anchor) {
1166
1188
  for (let i = 0; i < each_blocks.length; i += 1) {
1167
- each_blocks[i].m(target, anchor);
1189
+ if (each_blocks[i]) {
1190
+ each_blocks[i].m(target, anchor);
1191
+ }
1168
1192
  }
1169
1193
 
1170
1194
  insert(target, each_1_anchor, anchor);
@@ -1468,7 +1492,7 @@
1468
1492
  search_props.value = /*value*/ ctx[0];
1469
1493
  }
1470
1494
 
1471
- search = new Search$1({ props: search_props });
1495
+ search = new Search({ props: search_props });
1472
1496
  binding_callbacks.push(() => bind(search, 'ref', search_ref_binding));
1473
1497
  binding_callbacks.push(() => bind(search, 'value', search_value_binding));
1474
1498
  search.$on("type", /*type_handler*/ ctx[31]);
package/lib/index.mjs CHANGED
@@ -120,7 +120,9 @@ function insert(target, node, anchor) {
120
120
  target.insertBefore(node, anchor || null);
121
121
  }
122
122
  function detach(node) {
123
- node.parentNode.removeChild(node);
123
+ if (node.parentNode) {
124
+ node.parentNode.removeChild(node);
125
+ }
124
126
  }
125
127
  function destroy_each(iterations, detaching) {
126
128
  for (let i = 0; i < iterations.length; i += 1) {
@@ -160,6 +162,14 @@ function attr(node, attribute, value) {
160
162
  else if (node.getAttribute(attribute) !== value)
161
163
  node.setAttribute(attribute, value);
162
164
  }
165
+ /**
166
+ * List of attributes that should always be set through the attr method,
167
+ * because updating them through the property setter doesn't work reliably.
168
+ * In the example of `width`/`height`, the problem is that the setter only
169
+ * accepts numeric values, but the attribute can also be set to a string like `50%`.
170
+ * If this list becomes too big, rethink this approach.
171
+ */
172
+ const always_set_through_set_attribute = ['width', 'height'];
163
173
  function set_attributes(node, attributes) {
164
174
  // @ts-ignore
165
175
  const descriptors = Object.getOwnPropertyDescriptors(node.__proto__);
@@ -173,7 +183,7 @@ function set_attributes(node, attributes) {
173
183
  else if (key === '__value') {
174
184
  node.value = node[key] = attributes[key];
175
185
  }
176
- else if (descriptors[key] && descriptors[key].set) {
186
+ else if (descriptors[key] && descriptors[key].set && always_set_through_set_attribute.indexOf(key) === -1) {
177
187
  node[key] = attributes[key];
178
188
  }
179
189
  else {
@@ -186,8 +196,9 @@ function children(element) {
186
196
  }
187
197
  function set_data(text, data) {
188
198
  data = '' + data;
189
- if (text.wholeText !== data)
190
- text.data = data;
199
+ if (text.data === data)
200
+ return;
201
+ text.data = data;
191
202
  }
192
203
  function set_input_value(input, value) {
193
204
  input.value = value == null ? '' : value;
@@ -213,16 +224,17 @@ class HtmlTag {
213
224
  if (!this.e) {
214
225
  if (this.is_svg)
215
226
  this.e = svg_element(target.nodeName);
227
+ /** #7364 target for <template> may be provided as #document-fragment(11) */
216
228
  else
217
- this.e = element(target.nodeName);
218
- this.t = target;
229
+ this.e = element((target.nodeType === 11 ? 'TEMPLATE' : target.nodeName));
230
+ this.t = target.tagName !== 'TEMPLATE' ? target : target.content;
219
231
  this.c(html);
220
232
  }
221
233
  this.i(anchor);
222
234
  }
223
235
  h(html) {
224
236
  this.e.innerHTML = html;
225
- this.n = Array.from(this.e.childNodes);
237
+ this.n = Array.from(this.e.nodeName === 'TEMPLATE' ? this.e.content.childNodes : this.e.childNodes);
226
238
  }
227
239
  i(anchor) {
228
240
  for (let i = 0; i < this.n.length; i += 1) {
@@ -309,9 +321,9 @@ function bubble(component, event) {
309
321
 
310
322
  const dirty_components = [];
311
323
  const binding_callbacks = [];
312
- const render_callbacks = [];
324
+ let render_callbacks = [];
313
325
  const flush_callbacks = [];
314
- const resolved_promise = Promise.resolve();
326
+ const resolved_promise = /* @__PURE__ */ Promise.resolve();
315
327
  let update_scheduled = false;
316
328
  function schedule_update() {
317
329
  if (!update_scheduled) {
@@ -350,15 +362,29 @@ function add_flush_callback(fn) {
350
362
  const seen_callbacks = new Set();
351
363
  let flushidx = 0; // Do *not* move this inside the flush() function
352
364
  function flush() {
365
+ // Do not reenter flush while dirty components are updated, as this can
366
+ // result in an infinite loop. Instead, let the inner flush handle it.
367
+ // Reentrancy is ok afterwards for bindings etc.
368
+ if (flushidx !== 0) {
369
+ return;
370
+ }
353
371
  const saved_component = current_component;
354
372
  do {
355
373
  // first, call beforeUpdate functions
356
374
  // and update components
357
- while (flushidx < dirty_components.length) {
358
- const component = dirty_components[flushidx];
359
- flushidx++;
360
- set_current_component(component);
361
- update(component.$$);
375
+ try {
376
+ while (flushidx < dirty_components.length) {
377
+ const component = dirty_components[flushidx];
378
+ flushidx++;
379
+ set_current_component(component);
380
+ update(component.$$);
381
+ }
382
+ }
383
+ catch (e) {
384
+ // reset dirty state to not end up in a deadlocked state and then rethrow
385
+ dirty_components.length = 0;
386
+ flushidx = 0;
387
+ throw e;
362
388
  }
363
389
  set_current_component(null);
364
390
  dirty_components.length = 0;
@@ -395,6 +421,16 @@ function update($$) {
395
421
  $$.after_update.forEach(add_render_callback);
396
422
  }
397
423
  }
424
+ /**
425
+ * Useful for example to execute remaining `afterUpdate` callbacks before executing `destroy`.
426
+ */
427
+ function flush_render_callbacks(fns) {
428
+ const filtered = [];
429
+ const targets = [];
430
+ render_callbacks.forEach((c) => fns.indexOf(c) === -1 ? filtered.push(c) : targets.push(c));
431
+ targets.forEach((c) => c());
432
+ render_callbacks = filtered;
433
+ }
398
434
  const outroing = new Set();
399
435
  let outros;
400
436
  function group_outros() {
@@ -509,6 +545,7 @@ function mount_component(component, target, anchor, customElement) {
509
545
  function destroy_component(component, detaching) {
510
546
  const $$ = component.$$;
511
547
  if ($$.fragment !== null) {
548
+ flush_render_callbacks($$.after_update);
512
549
  run_all($$.on_destroy);
513
550
  $$.fragment && $$.fragment.d(detaching);
514
551
  // TODO null out other refs, including component.$$ (but need to
@@ -761,16 +798,11 @@ fuzzy.filter = function(pattern, arr, opts) {
761
798
 
762
799
  var fuzzy = fuzzy$1.exports;
763
800
 
764
- /* node_modules/svelte-search/src/Search.svelte generated by Svelte v3.52.0 */
765
-
766
- function add_css$1(target) {
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}");
768
- }
769
-
801
+ /* node_modules/svelte-search/src/Search.svelte generated by Svelte v3.59.2 */
770
802
  const get_label_slot_changes = dirty => ({});
771
803
  const get_label_slot_context = ctx => ({});
772
804
 
773
- // (60:23) {label}
805
+ // (94:23) {label}
774
806
  function fallback_block$1(ctx) {
775
807
  let t;
776
808
 
@@ -794,6 +826,7 @@ function create_fragment$1(ctx) {
794
826
  let form;
795
827
  let label_1;
796
828
  let label_1_id_value;
829
+ let label_1_style_value;
797
830
  let t;
798
831
  let input;
799
832
  let form_role_value;
@@ -830,16 +863,16 @@ function create_fragment$1(ctx) {
830
863
  input = element("input");
831
864
  attr(label_1, "id", label_1_id_value = "" + (/*id*/ ctx[4] + "-label"));
832
865
  attr(label_1, "for", /*id*/ ctx[4]);
833
- attr(label_1, "class", "svelte-5m0wg6");
834
- toggle_class(label_1, "hide-label", /*hideLabel*/ ctx[3]);
866
+ attr(label_1, "style", label_1_style_value = /*hideLabel*/ ctx[3] && "position: absolute;height: 1px;width: 1px;overflow: hidden;clip: rect(1px 1px 1px 1px);clip: rect(1px, 1px, 1px, 1px);white-space: nowrap;");
835
867
  set_attributes(input, input_data);
836
- toggle_class(input, "svelte-5m0wg6", true);
837
868
  attr(form, "data-svelte-search", "");
838
869
  attr(form, "role", form_role_value = /*removeFormAriaAttributes*/ ctx[5] ? null : "search");
839
870
 
840
871
  attr(form, "aria-labelledby", form_aria_labelledby_value = /*removeFormAriaAttributes*/ ctx[5]
841
872
  ? null
842
873
  : /*id*/ ctx[4]);
874
+
875
+ attr(form, "action", "");
843
876
  },
844
877
  m(target, anchor) {
845
878
  insert(target, form, anchor);
@@ -898,8 +931,8 @@ function create_fragment$1(ctx) {
898
931
  attr(label_1, "for", /*id*/ ctx[4]);
899
932
  }
900
933
 
901
- if (!current || dirty & /*hideLabel*/ 8) {
902
- toggle_class(label_1, "hide-label", /*hideLabel*/ ctx[3]);
934
+ if (!current || dirty & /*hideLabel*/ 8 && label_1_style_value !== (label_1_style_value = /*hideLabel*/ ctx[3] && "position: absolute;height: 1px;width: 1px;overflow: hidden;clip: rect(1px 1px 1px 1px);clip: rect(1px, 1px, 1px, 1px);white-space: nowrap;")) {
935
+ attr(label_1, "style", label_1_style_value);
903
936
  }
904
937
 
905
938
  set_attributes(input, input_data = get_spread_update(input_levels, [
@@ -912,12 +945,10 @@ function create_fragment$1(ctx) {
912
945
  (!current || dirty & /*id*/ 16) && { id: /*id*/ ctx[4] }
913
946
  ]));
914
947
 
915
- if (dirty & /*value*/ 1) {
948
+ if (dirty & /*value*/ 1 && input.value !== /*value*/ ctx[0]) {
916
949
  set_input_value(input, /*value*/ ctx[0]);
917
950
  }
918
951
 
919
- toggle_class(input, "svelte-5m0wg6", true);
920
-
921
952
  if (!current || dirty & /*removeFormAriaAttributes*/ 32 && form_role_value !== (form_role_value = /*removeFormAriaAttributes*/ ctx[5] ? null : "search")) {
922
953
  attr(form, "role", form_role_value);
923
954
  }
@@ -967,13 +998,14 @@ function instance$1($$self, $$props, $$invalidate) {
967
998
  let timeout = undefined;
968
999
  let calling = false;
969
1000
 
970
- function debounced(cb) {
1001
+ /** @type {() => any;} */
1002
+ function debounceFn(fn) {
971
1003
  if (calling) return;
972
1004
  calling = true;
973
1005
 
974
1006
  timeout = setTimeout(
975
1007
  () => {
976
- cb();
1008
+ fn();
977
1009
  calling = false;
978
1010
  },
979
1011
  debounce
@@ -988,7 +1020,7 @@ function instance$1($$self, $$props, $$invalidate) {
988
1020
  afterUpdate(() => {
989
1021
  if (value.length > 0 && value !== prevValue) {
990
1022
  if (debounce > 0) {
991
- debounced(() => dispatch("type", value));
1023
+ debounceFn(() => dispatch("type", value));
992
1024
  } else {
993
1025
  dispatch("type", value);
994
1026
  }
@@ -1075,30 +1107,20 @@ class Search extends SvelteComponent {
1075
1107
  constructor(options) {
1076
1108
  super();
1077
1109
 
1078
- init(
1079
- this,
1080
- options,
1081
- instance$1,
1082
- create_fragment$1,
1083
- safe_not_equal,
1084
- {
1085
- value: 0,
1086
- autofocus: 7,
1087
- debounce: 8,
1088
- label: 2,
1089
- hideLabel: 3,
1090
- id: 4,
1091
- ref: 1,
1092
- removeFormAriaAttributes: 5
1093
- },
1094
- add_css$1
1095
- );
1110
+ init(this, options, instance$1, create_fragment$1, safe_not_equal, {
1111
+ value: 0,
1112
+ autofocus: 7,
1113
+ debounce: 8,
1114
+ label: 2,
1115
+ hideLabel: 3,
1116
+ id: 4,
1117
+ ref: 1,
1118
+ removeFormAriaAttributes: 5
1119
+ });
1096
1120
  }
1097
1121
  }
1098
1122
 
1099
- var Search$1 = Search;
1100
-
1101
- /* src/Typeahead.svelte generated by Svelte v3.52.0 */
1123
+ /* src/Typeahead.svelte generated by Svelte v3.59.2 */
1102
1124
 
1103
1125
  function add_css(target) {
1104
1126
  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}");
@@ -1158,7 +1180,9 @@ function create_if_block_1(ctx) {
1158
1180
  },
1159
1181
  m(target, anchor) {
1160
1182
  for (let i = 0; i < each_blocks.length; i += 1) {
1161
- each_blocks[i].m(target, anchor);
1183
+ if (each_blocks[i]) {
1184
+ each_blocks[i].m(target, anchor);
1185
+ }
1162
1186
  }
1163
1187
 
1164
1188
  insert(target, each_1_anchor, anchor);
@@ -1462,7 +1486,7 @@ function create_fragment(ctx) {
1462
1486
  search_props.value = /*value*/ ctx[0];
1463
1487
  }
1464
1488
 
1465
- search = new Search$1({ props: search_props });
1489
+ search = new Search({ props: search_props });
1466
1490
  binding_callbacks.push(() => bind(search, 'ref', search_ref_binding));
1467
1491
  binding_callbacks.push(() => bind(search, 'value', search_value_binding));
1468
1492
  search.$on("type", /*type_handler*/ ctx[31]);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "svelte-typeahead",
3
- "version": "4.4.1",
3
+ "version": "4.4.2",
4
4
  "license": "MIT",
5
5
  "description": "Accessible, fuzzy search typeahead component",
6
6
  "author": "Eric Liu (https://github.com/metonym)",
@@ -15,12 +15,12 @@
15
15
  },
16
16
  "dependencies": {
17
17
  "fuzzy": "0.1.3",
18
- "svelte-search": "^1.1.0"
18
+ "svelte-search": "^2.1.0"
19
19
  },
20
20
  "devDependencies": {
21
21
  "@rollup/plugin-commonjs": "^21.0.2",
22
- "svelte": "^3.52.0",
23
- "svelte-check": "^2.9.0",
22
+ "svelte": "^3.59.1",
23
+ "svelte-check": "^3.6.2",
24
24
  "svelte-readme": "^3.6.3"
25
25
  },
26
26
  "repository": {
@@ -1,8 +1,8 @@
1
1
  /// <reference types="svelte" />
2
2
  import { SvelteComponentTyped } from "svelte";
3
- import { SearchProps } from "svelte-search/types/Search";
3
+ import { SearchProps } from "svelte-search/src/Search.svelte";
4
4
 
5
- export interface TypeaheadProps<TItem> extends SearchProps {
5
+ export interface TypeaheadProps<TItem> extends Omit<SearchProps, "results"> {
6
6
  /**
7
7
  * @default "typeahead-" + Math.random().toString(36)
8
8
  */
package/CHANGELOG.md DELETED
@@ -1,172 +0,0 @@
1
- # Changelog
2
-
3
- All notable changes to this project will be documented in this file.
4
-
5
- The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
6
- and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
-
8
- ## [4.4.1](https://github.com/metonym/svelte-typeahead/releases/tag/v4.4.1) - 2022-11-12
9
-
10
- - replace `aria-owns` with `aria-controls` to resolve `a11y-role-has-required-aria-props` warning
11
-
12
- ## [4.4.0](https://github.com/metonym/svelte-typeahead/releases/tag/v4.4.0) - 2022-11-08
13
-
14
- **Features**
15
-
16
- - add `showAllResultsOnFocus` prop to display all results when focusing an empty input
17
-
18
- **Fixes**
19
-
20
- - silence a11y warnings emitted by Svelte@3.52
21
- - event type for dispatched `clear` event should be `null`
22
- - unset `ul` margin
23
-
24
- ## [4.3.2](https://github.com/metonym/svelte-typeahead/releases/tag/v4.3.2) - 2022-09-01
25
-
26
- **Fixes**
27
-
28
- - allow results to be selected if using `showDropdownOnFocus`
29
-
30
- ## [4.3.1](https://github.com/metonym/svelte-typeahead/releases/tag/v4.3.1) - 2022-08-29
31
-
32
- **Fixes**
33
-
34
- - skip disabled results when auto-selecting a result
35
-
36
- ## [4.3.0](https://github.com/metonym/svelte-typeahead/releases/tag/v4.3.0) - 2022-08-29
37
-
38
- **Features**
39
-
40
- - add `showDropdownOnFocus` prop to only show dropdown if the search input is focused
41
-
42
- ## [4.2.4](https://github.com/metonym/svelte-typeahead/releases/tag/v4.2.4) - 2022-07-05
43
-
44
- **Fixes**
45
-
46
- - set dropdown menu `z-index: 1` when expanded
47
-
48
- ## [4.2.3](https://github.com/metonym/svelte-typeahead/releases/tag/v4.2.3) - 2022-07-04
49
-
50
- **Fixes**
51
-
52
- - update selected index when hovering over a result
53
-
54
- ## [4.2.2](https://github.com/metonym/svelte-typeahead/releases/tag/v4.2.2) - 2022-03-20
55
-
56
- **Fixes**
57
-
58
- - pressing "ArrowUp" on last item should not reset highlighted index
59
-
60
- ## [4.2.1](https://github.com/metonym/svelte-typeahead/releases/tag/v4.2.1) - 2021-10-30
61
-
62
- **Fixes**
63
-
64
- - prevent keyboard selection and navigation of disabled results
65
- - add missing annotation for `TItem.disabled` to `results` prop
66
-
67
- **Documentation**
68
-
69
- - add `pnpm` installation command
70
- - remove "disabling items after selection" example
71
- - remove `id` fields from `data` array
72
- - simplify dispatched events example
73
-
74
- ## [4.2.0](https://github.com/metonym/svelte-typeahead/releases/tag/v4.2.0) - 2021-10-26
75
-
76
- **Features**
77
-
78
- - use TypeScript generics so that the item type can be inferred from `data` value
79
-
80
- ## [4.1.0](https://github.com/metonym/svelte-typeahead/releases/tag/v4.1.0) - 2021-10-03
81
-
82
- **Features**
83
-
84
- - render a "no-results" slot when the search value does not yield results
85
- - add `value` to the default slot props
86
-
87
- ## [4.0.0](https://github.com/metonym/svelte-typeahead/releases/tag/v4.0.0) - 2021-09-05
88
-
89
- **Breaking Changes**
90
-
91
- - use `.svelte.d.ts` extension for component TypeScript definition
92
-
93
- ## [3.0.0](https://github.com/metonym/svelte-typeahead/releases/tag/v3.0.0) - 2021-03-16
94
-
95
- **Breaking Changes**
96
-
97
- - the `ul` element is rendered even without results to preserve the accessibility label
98
-
99
- **Fixes**
100
-
101
- - disable form ARIA attributes in `svelte-search`
102
- - pass the correct `aria-activedescendant` item to `svelte-search`
103
-
104
- ## [2.4.1](https://github.com/metonym/svelte-typeahead/releases/tag/v2.4.1) - 2021-03-14
105
-
106
- **Fixes**
107
-
108
- - pass `id` to `Search` to fix `aria-labelledby` references
109
-
110
- ## [2.4.0](https://github.com/metonym/svelte-typeahead/releases/tag/v2.4.0) - 2021-03-04
111
-
112
- **Features**
113
-
114
- - add `limit` prop to limit number of results; default value is `Infinity`
115
-
116
- ## [2.3.0](https://github.com/metonym/svelte-typeahead/releases/tag/v2.3.0) - 2021-02-21
117
-
118
- **Features**
119
-
120
- - add `disable`, `filter` props to disable and filter items from the result set
121
-
122
- **Fixes**
123
-
124
- - bind the input element reference correctly to fix focusing behavior
125
- - don't pass the Typeahead id to Search
126
-
127
- ## [2.2.0](https://github.com/metonym/svelte-typeahead/releases/tag/v2.2.0) - 2021-02-20
128
-
129
- **Features**
130
-
131
- - add `inputAfterSelect` prop to allow user to preserve or clear the input field after selecting a result; possible values are `"update" | "clear" | "keep"` (default is `"update"`)
132
- - add searched value to dispatched "select" event detail (`e.detail.searched`)
133
-
134
- ## [2.1.0](https://github.com/metonym/svelte-typeahead/releases/tag/v2.1.0) - 2021-02-20
135
-
136
- **Features**
137
-
138
- - include `original` item and `originalIndex` in dispatched "select" event
139
-
140
- ## [2.0.0](https://github.com/metonym/svelte-typeahead/releases/tag/v2.0.0) - 2020-12-31
141
-
142
- **Breaking Changes**
143
-
144
- - upgrade `svelte-search` to version 1.0.0
145
- - defer to default `label`, `placeholder` props from `search-svelte`
146
- - use `SvelteComponentTyped` interface in TypeScript definitions
147
-
148
- ## [1.0.0](https://github.com/metonym/svelte-typeahead/releases/tag/v1.0.0) - 2020-11-28
149
-
150
- **Features**
151
-
152
- - export reactive `results` array containing fuzzy results
153
- - add `focusAfterSelect` to opt in to focusing input after selecting a result
154
- - keydown default behavior is preventing if pressing "ArrowUp", "ArrowDown", or "Escape"
155
-
156
- **Breaking changes**
157
-
158
- - `focusAfterSelect` is `false` by default
159
- - redesigned default styles
160
- - if using TS, Svelte version >=3.30 is required
161
-
162
- ## [0.2.0](https://github.com/metonym/svelte-typeahead/releases/tag/v0.2.0) - 2020-11-17
163
-
164
- - Add TypeScript definitions
165
-
166
- ## [0.1.1](https://github.com/metonym/svelte-typeahead/releases/tag/v0.1.1) - 2020-08-06
167
-
168
- - Remove `filter` named export
169
-
170
- ## [0.1.0](https://github.com/metonym/svelte-typeahead/releases/tag/v0.1.0) - 2020-04-15
171
-
172
- - Initial release