svelte-typeahead 4.2.1 → 4.2.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/CHANGELOG.md +6 -0
- package/README.md +0 -1
- package/lib/index.js +32 -14
- package/lib/index.mjs +28 -10
- package/package.json +5 -5
- package/src/Typeahead.svelte +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -5,6 +5,12 @@ All notable changes to this project will be documented in this file.
|
|
|
5
5
|
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
|
6
6
|
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
7
7
|
|
|
8
|
+
## [4.2.2](https://github.com/metonym/svelte-typeahead/releases/tag/v4.2.2) - 2022-03-20
|
|
9
|
+
|
|
10
|
+
**Fixes**
|
|
11
|
+
|
|
12
|
+
- pressing "ArrowUp" on last item should not reset highlighted index
|
|
13
|
+
|
|
8
14
|
## [4.2.1](https://github.com/metonym/svelte-typeahead/releases/tag/v4.2.1) - 2021-10-30
|
|
9
15
|
|
|
10
16
|
**Fixes**
|
package/README.md
CHANGED
package/lib/index.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
(function (global, factory) {
|
|
2
2
|
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) :
|
|
3
3
|
typeof define === 'function' && define.amd ? define(['exports'], factory) :
|
|
4
|
-
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global[
|
|
5
|
-
}(this, (function (exports) { 'use strict';
|
|
4
|
+
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global["svelte-typeahead"] = {}));
|
|
5
|
+
})(this, (function (exports) { 'use strict';
|
|
6
6
|
|
|
7
7
|
function noop() { }
|
|
8
8
|
function assign(tar, src) {
|
|
@@ -298,22 +298,40 @@
|
|
|
298
298
|
function add_flush_callback(fn) {
|
|
299
299
|
flush_callbacks.push(fn);
|
|
300
300
|
}
|
|
301
|
-
|
|
301
|
+
// flush() calls callbacks in this order:
|
|
302
|
+
// 1. All beforeUpdate callbacks, in order: parents before children
|
|
303
|
+
// 2. All bind:this callbacks, in reverse order: children before parents.
|
|
304
|
+
// 3. All afterUpdate callbacks, in order: parents before children. EXCEPT
|
|
305
|
+
// for afterUpdates called during the initial onMount, which are called in
|
|
306
|
+
// reverse order: children before parents.
|
|
307
|
+
// Since callbacks might update component values, which could trigger another
|
|
308
|
+
// call to flush(), the following steps guard against this:
|
|
309
|
+
// 1. During beforeUpdate, any updated components will be added to the
|
|
310
|
+
// dirty_components array and will cause a reentrant call to flush(). Because
|
|
311
|
+
// the flush index is kept outside the function, the reentrant call will pick
|
|
312
|
+
// up where the earlier call left off and go through all dirty components. The
|
|
313
|
+
// current_component value is saved and restored so that the reentrant call will
|
|
314
|
+
// not interfere with the "parent" flush() call.
|
|
315
|
+
// 2. bind:this callbacks cannot trigger new flush() calls.
|
|
316
|
+
// 3. During afterUpdate, any updated components will NOT have their afterUpdate
|
|
317
|
+
// callback called a second time; the seen_callbacks set, outside the flush()
|
|
318
|
+
// function, guarantees this behavior.
|
|
302
319
|
const seen_callbacks = new Set();
|
|
320
|
+
let flushidx = 0; // Do *not* move this inside the flush() function
|
|
303
321
|
function flush() {
|
|
304
|
-
|
|
305
|
-
return;
|
|
306
|
-
flushing = true;
|
|
322
|
+
const saved_component = current_component;
|
|
307
323
|
do {
|
|
308
324
|
// first, call beforeUpdate functions
|
|
309
325
|
// and update components
|
|
310
|
-
|
|
311
|
-
const component = dirty_components[
|
|
326
|
+
while (flushidx < dirty_components.length) {
|
|
327
|
+
const component = dirty_components[flushidx];
|
|
328
|
+
flushidx++;
|
|
312
329
|
set_current_component(component);
|
|
313
330
|
update(component.$$);
|
|
314
331
|
}
|
|
315
332
|
set_current_component(null);
|
|
316
333
|
dirty_components.length = 0;
|
|
334
|
+
flushidx = 0;
|
|
317
335
|
while (binding_callbacks.length)
|
|
318
336
|
binding_callbacks.pop()();
|
|
319
337
|
// then, once components are updated, call
|
|
@@ -333,8 +351,8 @@
|
|
|
333
351
|
flush_callbacks.pop()();
|
|
334
352
|
}
|
|
335
353
|
update_scheduled = false;
|
|
336
|
-
flushing = false;
|
|
337
354
|
seen_callbacks.clear();
|
|
355
|
+
set_current_component(saved_component);
|
|
338
356
|
}
|
|
339
357
|
function update($$) {
|
|
340
358
|
if ($$.fragment !== null) {
|
|
@@ -703,7 +721,7 @@
|
|
|
703
721
|
|
|
704
722
|
var fuzzy = fuzzy$1.exports;
|
|
705
723
|
|
|
706
|
-
/* node_modules/svelte-search/src/Search.svelte generated by Svelte v3.
|
|
724
|
+
/* node_modules/svelte-search/src/Search.svelte generated by Svelte v3.46.4 */
|
|
707
725
|
|
|
708
726
|
function add_css$1(target) {
|
|
709
727
|
append_styles(target, "svelte-5m0wg6", ".hide-label.svelte-5m0wg6{position:absolute;height:1px;width:1px;overflow:hidden;clip:rect(1px 1px 1px 1px);clip:rect(1px, 1px, 1px, 1px);white-space:nowrap}");
|
|
@@ -1040,7 +1058,7 @@
|
|
|
1040
1058
|
|
|
1041
1059
|
var Search$1 = Search;
|
|
1042
1060
|
|
|
1043
|
-
/* src/Typeahead.svelte generated by Svelte v3.
|
|
1061
|
+
/* src/Typeahead.svelte generated by Svelte v3.46.4 */
|
|
1044
1062
|
|
|
1045
1063
|
function add_css(target) {
|
|
1046
1064
|
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}");
|
|
@@ -1646,7 +1664,7 @@
|
|
|
1646
1664
|
|
|
1647
1665
|
/** @type {(direction: -1 | 1) => void} */
|
|
1648
1666
|
function change(direction) {
|
|
1649
|
-
let index = selectedIndex === results.length - 1
|
|
1667
|
+
let index = direction === 1 && selectedIndex === results.length - 1
|
|
1650
1668
|
? 0
|
|
1651
1669
|
: selectedIndex + direction;
|
|
1652
1670
|
|
|
@@ -1862,8 +1880,8 @@
|
|
|
1862
1880
|
|
|
1863
1881
|
var Typeahead$1 = Typeahead;
|
|
1864
1882
|
|
|
1865
|
-
exports[
|
|
1883
|
+
exports["default"] = Typeahead$1;
|
|
1866
1884
|
|
|
1867
1885
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
1868
1886
|
|
|
1869
|
-
}))
|
|
1887
|
+
}));
|
package/lib/index.mjs
CHANGED
|
@@ -292,22 +292,40 @@ function add_render_callback(fn) {
|
|
|
292
292
|
function add_flush_callback(fn) {
|
|
293
293
|
flush_callbacks.push(fn);
|
|
294
294
|
}
|
|
295
|
-
|
|
295
|
+
// flush() calls callbacks in this order:
|
|
296
|
+
// 1. All beforeUpdate callbacks, in order: parents before children
|
|
297
|
+
// 2. All bind:this callbacks, in reverse order: children before parents.
|
|
298
|
+
// 3. All afterUpdate callbacks, in order: parents before children. EXCEPT
|
|
299
|
+
// for afterUpdates called during the initial onMount, which are called in
|
|
300
|
+
// reverse order: children before parents.
|
|
301
|
+
// Since callbacks might update component values, which could trigger another
|
|
302
|
+
// call to flush(), the following steps guard against this:
|
|
303
|
+
// 1. During beforeUpdate, any updated components will be added to the
|
|
304
|
+
// dirty_components array and will cause a reentrant call to flush(). Because
|
|
305
|
+
// the flush index is kept outside the function, the reentrant call will pick
|
|
306
|
+
// up where the earlier call left off and go through all dirty components. The
|
|
307
|
+
// current_component value is saved and restored so that the reentrant call will
|
|
308
|
+
// not interfere with the "parent" flush() call.
|
|
309
|
+
// 2. bind:this callbacks cannot trigger new flush() calls.
|
|
310
|
+
// 3. During afterUpdate, any updated components will NOT have their afterUpdate
|
|
311
|
+
// callback called a second time; the seen_callbacks set, outside the flush()
|
|
312
|
+
// function, guarantees this behavior.
|
|
296
313
|
const seen_callbacks = new Set();
|
|
314
|
+
let flushidx = 0; // Do *not* move this inside the flush() function
|
|
297
315
|
function flush() {
|
|
298
|
-
|
|
299
|
-
return;
|
|
300
|
-
flushing = true;
|
|
316
|
+
const saved_component = current_component;
|
|
301
317
|
do {
|
|
302
318
|
// first, call beforeUpdate functions
|
|
303
319
|
// and update components
|
|
304
|
-
|
|
305
|
-
const component = dirty_components[
|
|
320
|
+
while (flushidx < dirty_components.length) {
|
|
321
|
+
const component = dirty_components[flushidx];
|
|
322
|
+
flushidx++;
|
|
306
323
|
set_current_component(component);
|
|
307
324
|
update(component.$$);
|
|
308
325
|
}
|
|
309
326
|
set_current_component(null);
|
|
310
327
|
dirty_components.length = 0;
|
|
328
|
+
flushidx = 0;
|
|
311
329
|
while (binding_callbacks.length)
|
|
312
330
|
binding_callbacks.pop()();
|
|
313
331
|
// then, once components are updated, call
|
|
@@ -327,8 +345,8 @@ function flush() {
|
|
|
327
345
|
flush_callbacks.pop()();
|
|
328
346
|
}
|
|
329
347
|
update_scheduled = false;
|
|
330
|
-
flushing = false;
|
|
331
348
|
seen_callbacks.clear();
|
|
349
|
+
set_current_component(saved_component);
|
|
332
350
|
}
|
|
333
351
|
function update($$) {
|
|
334
352
|
if ($$.fragment !== null) {
|
|
@@ -697,7 +715,7 @@ fuzzy.filter = function(pattern, arr, opts) {
|
|
|
697
715
|
|
|
698
716
|
var fuzzy = fuzzy$1.exports;
|
|
699
717
|
|
|
700
|
-
/* node_modules/svelte-search/src/Search.svelte generated by Svelte v3.
|
|
718
|
+
/* node_modules/svelte-search/src/Search.svelte generated by Svelte v3.46.4 */
|
|
701
719
|
|
|
702
720
|
function add_css$1(target) {
|
|
703
721
|
append_styles(target, "svelte-5m0wg6", ".hide-label.svelte-5m0wg6{position:absolute;height:1px;width:1px;overflow:hidden;clip:rect(1px 1px 1px 1px);clip:rect(1px, 1px, 1px, 1px);white-space:nowrap}");
|
|
@@ -1034,7 +1052,7 @@ class Search extends SvelteComponent {
|
|
|
1034
1052
|
|
|
1035
1053
|
var Search$1 = Search;
|
|
1036
1054
|
|
|
1037
|
-
/* src/Typeahead.svelte generated by Svelte v3.
|
|
1055
|
+
/* src/Typeahead.svelte generated by Svelte v3.46.4 */
|
|
1038
1056
|
|
|
1039
1057
|
function add_css(target) {
|
|
1040
1058
|
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}");
|
|
@@ -1640,7 +1658,7 @@ function instance($$self, $$props, $$invalidate) {
|
|
|
1640
1658
|
|
|
1641
1659
|
/** @type {(direction: -1 | 1) => void} */
|
|
1642
1660
|
function change(direction) {
|
|
1643
|
-
let index = selectedIndex === results.length - 1
|
|
1661
|
+
let index = direction === 1 && selectedIndex === results.length - 1
|
|
1644
1662
|
? 0
|
|
1645
1663
|
: selectedIndex + direction;
|
|
1646
1664
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "svelte-typeahead",
|
|
3
|
-
"version": "4.2.
|
|
3
|
+
"version": "4.2.2",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"description": "Accessible, fuzzy search typeahead component",
|
|
6
6
|
"author": "Eric Liu (https://github.com/metonym)",
|
|
@@ -21,10 +21,10 @@
|
|
|
21
21
|
"svelte-search": "^1.1.0"
|
|
22
22
|
},
|
|
23
23
|
"devDependencies": {
|
|
24
|
-
"@rollup/plugin-commonjs": "^21.0.
|
|
25
|
-
"svelte": "^3.
|
|
26
|
-
"svelte-check": "^2.
|
|
27
|
-
"svelte-readme": "^3.
|
|
24
|
+
"@rollup/plugin-commonjs": "^21.0.2",
|
|
25
|
+
"svelte": "^3.46.4",
|
|
26
|
+
"svelte-check": "^2.4.6",
|
|
27
|
+
"svelte-readme": "^3.6.3"
|
|
28
28
|
},
|
|
29
29
|
"repository": {
|
|
30
30
|
"type": "git",
|
package/src/Typeahead.svelte
CHANGED
|
@@ -92,7 +92,7 @@
|
|
|
92
92
|
/** @type {(direction: -1 | 1) => void} */
|
|
93
93
|
function change(direction) {
|
|
94
94
|
let index =
|
|
95
|
-
selectedIndex === results.length - 1 ? 0 : selectedIndex + direction;
|
|
95
|
+
direction === 1 && selectedIndex === results.length - 1 ? 0 : selectedIndex + direction;
|
|
96
96
|
if (index < 0) index = results.length - 1;
|
|
97
97
|
|
|
98
98
|
let disabled = results[index].disabled;
|