svelte-typeahead 4.2.2 → 4.2.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +6 -0
- package/README.md +1 -3
- package/lib/index.js +56 -32
- package/lib/index.mjs +56 -32
- package/package.json +3 -3
- package/src/Typeahead.svelte +4 -0
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.3](https://github.com/metonym/svelte-typeahead/releases/tag/v4.2.3) - 2022-07-04
|
|
9
|
+
|
|
10
|
+
**Fixes**
|
|
11
|
+
|
|
12
|
+
- update selected index when hovering over a result
|
|
13
|
+
|
|
8
14
|
## [4.2.2](https://github.com/metonym/svelte-typeahead/releases/tag/v4.2.2) - 2022-03-20
|
|
9
15
|
|
|
10
16
|
**Fixes**
|
package/README.md
CHANGED
|
@@ -185,9 +185,7 @@ Set `focusAfterSelect` to `true` to re-focus the search input after selecting a
|
|
|
185
185
|
on:clear={() => (e = [...e, { event: "clear" }])}
|
|
186
186
|
/>
|
|
187
187
|
|
|
188
|
-
<pre>
|
|
189
|
-
{JSON.stringify(e, null, 2)}
|
|
190
|
-
</pre>
|
|
188
|
+
<pre>{JSON.stringify(e, null, 2)}</pre>
|
|
191
189
|
```
|
|
192
190
|
|
|
193
191
|
### Forwarded events
|
package/lib/index.js
CHANGED
|
@@ -136,6 +136,9 @@
|
|
|
136
136
|
function element(name) {
|
|
137
137
|
return document.createElement(name);
|
|
138
138
|
}
|
|
139
|
+
function svg_element(name) {
|
|
140
|
+
return document.createElementNS('http://www.w3.org/2000/svg', name);
|
|
141
|
+
}
|
|
139
142
|
function text(data) {
|
|
140
143
|
return document.createTextNode(data);
|
|
141
144
|
}
|
|
@@ -197,13 +200,15 @@
|
|
|
197
200
|
function toggle_class(element, name, toggle) {
|
|
198
201
|
element.classList[toggle ? 'add' : 'remove'](name);
|
|
199
202
|
}
|
|
200
|
-
function custom_event(type, detail, bubbles = false) {
|
|
203
|
+
function custom_event(type, detail, { bubbles = false, cancelable = false } = {}) {
|
|
201
204
|
const e = document.createEvent('CustomEvent');
|
|
202
|
-
e.initCustomEvent(type, bubbles,
|
|
205
|
+
e.initCustomEvent(type, bubbles, cancelable, detail);
|
|
203
206
|
return e;
|
|
204
207
|
}
|
|
205
208
|
class HtmlTag {
|
|
206
|
-
constructor() {
|
|
209
|
+
constructor(is_svg = false) {
|
|
210
|
+
this.is_svg = false;
|
|
211
|
+
this.is_svg = is_svg;
|
|
207
212
|
this.e = this.n = null;
|
|
208
213
|
}
|
|
209
214
|
c(html) {
|
|
@@ -211,7 +216,10 @@
|
|
|
211
216
|
}
|
|
212
217
|
m(html, target, anchor = null) {
|
|
213
218
|
if (!this.e) {
|
|
214
|
-
|
|
219
|
+
if (this.is_svg)
|
|
220
|
+
this.e = svg_element(target.nodeName);
|
|
221
|
+
else
|
|
222
|
+
this.e = element(target.nodeName);
|
|
215
223
|
this.t = target;
|
|
216
224
|
this.c(html);
|
|
217
225
|
}
|
|
@@ -253,16 +261,18 @@
|
|
|
253
261
|
}
|
|
254
262
|
function createEventDispatcher() {
|
|
255
263
|
const component = get_current_component();
|
|
256
|
-
return (type, detail) => {
|
|
264
|
+
return (type, detail, { cancelable = false } = {}) => {
|
|
257
265
|
const callbacks = component.$$.callbacks[type];
|
|
258
266
|
if (callbacks) {
|
|
259
267
|
// TODO are there situations where events could be dispatched
|
|
260
268
|
// in a server (non-DOM) environment?
|
|
261
|
-
const event = custom_event(type, detail);
|
|
269
|
+
const event = custom_event(type, detail, { cancelable });
|
|
262
270
|
callbacks.slice().forEach(fn => {
|
|
263
271
|
fn.call(component, event);
|
|
264
272
|
});
|
|
273
|
+
return !event.defaultPrevented;
|
|
265
274
|
}
|
|
275
|
+
return true;
|
|
266
276
|
};
|
|
267
277
|
}
|
|
268
278
|
// TODO figure out if we still want to support
|
|
@@ -721,7 +731,7 @@
|
|
|
721
731
|
|
|
722
732
|
var fuzzy = fuzzy$1.exports;
|
|
723
733
|
|
|
724
|
-
/* node_modules/svelte-search/src/Search.svelte generated by Svelte v3.
|
|
734
|
+
/* node_modules/svelte-search/src/Search.svelte generated by Svelte v3.48.0 */
|
|
725
735
|
|
|
726
736
|
function add_css$1(target) {
|
|
727
737
|
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}");
|
|
@@ -1058,7 +1068,7 @@
|
|
|
1058
1068
|
|
|
1059
1069
|
var Search$1 = Search;
|
|
1060
1070
|
|
|
1061
|
-
/* src/Typeahead.svelte generated by Svelte v3.
|
|
1071
|
+
/* src/Typeahead.svelte generated by Svelte v3.48.0 */
|
|
1062
1072
|
|
|
1063
1073
|
function add_css(target) {
|
|
1064
1074
|
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}");
|
|
@@ -1071,14 +1081,14 @@
|
|
|
1071
1081
|
|
|
1072
1082
|
const get_no_results_slot_context = ctx => ({
|
|
1073
1083
|
value: /*value*/ ctx[0],
|
|
1074
|
-
result: /*result*/ ctx[
|
|
1075
|
-
index: /*i*/ ctx[
|
|
1084
|
+
result: /*result*/ ctx[41],
|
|
1085
|
+
index: /*i*/ ctx[43]
|
|
1076
1086
|
});
|
|
1077
1087
|
|
|
1078
1088
|
function get_each_context(ctx, list, i) {
|
|
1079
1089
|
const child_ctx = ctx.slice();
|
|
1080
|
-
child_ctx[
|
|
1081
|
-
child_ctx[
|
|
1090
|
+
child_ctx[41] = list[i];
|
|
1091
|
+
child_ctx[43] = i;
|
|
1082
1092
|
return child_ctx;
|
|
1083
1093
|
}
|
|
1084
1094
|
|
|
@@ -1088,8 +1098,8 @@
|
|
|
1088
1098
|
});
|
|
1089
1099
|
|
|
1090
1100
|
const get_default_slot_context = ctx => ({
|
|
1091
|
-
result: /*result*/ ctx[
|
|
1092
|
-
index: /*i*/ ctx[
|
|
1101
|
+
result: /*result*/ ctx[41],
|
|
1102
|
+
index: /*i*/ ctx[43],
|
|
1093
1103
|
value: /*value*/ ctx[0]
|
|
1094
1104
|
});
|
|
1095
1105
|
|
|
@@ -1177,15 +1187,15 @@
|
|
|
1177
1187
|
};
|
|
1178
1188
|
}
|
|
1179
1189
|
|
|
1180
|
-
// (
|
|
1190
|
+
// (217:43)
|
|
1181
1191
|
function fallback_block(ctx) {
|
|
1182
1192
|
let html_tag;
|
|
1183
|
-
let raw_value = /*result*/ ctx[
|
|
1193
|
+
let raw_value = /*result*/ ctx[41].string + "";
|
|
1184
1194
|
let html_anchor;
|
|
1185
1195
|
|
|
1186
1196
|
return {
|
|
1187
1197
|
c() {
|
|
1188
|
-
html_tag = new HtmlTag();
|
|
1198
|
+
html_tag = new HtmlTag(false);
|
|
1189
1199
|
html_anchor = empty();
|
|
1190
1200
|
html_tag.a = html_anchor;
|
|
1191
1201
|
},
|
|
@@ -1194,7 +1204,7 @@
|
|
|
1194
1204
|
insert(target, html_anchor, anchor);
|
|
1195
1205
|
},
|
|
1196
1206
|
p(ctx, dirty) {
|
|
1197
|
-
if (dirty[0] & /*results*/ 2 && raw_value !== (raw_value = /*result*/ ctx[
|
|
1207
|
+
if (dirty[0] & /*results*/ 2 && raw_value !== (raw_value = /*result*/ ctx[41].string + "")) html_tag.p(raw_value);
|
|
1198
1208
|
},
|
|
1199
1209
|
d(detaching) {
|
|
1200
1210
|
if (detaching) detach(html_anchor);
|
|
@@ -1217,7 +1227,11 @@
|
|
|
1217
1227
|
const default_slot_or_fallback = default_slot || fallback_block(ctx);
|
|
1218
1228
|
|
|
1219
1229
|
function click_handler_1() {
|
|
1220
|
-
return /*click_handler_1*/ ctx[35](/*result*/ ctx[
|
|
1230
|
+
return /*click_handler_1*/ ctx[35](/*result*/ ctx[41], /*i*/ ctx[43]);
|
|
1231
|
+
}
|
|
1232
|
+
|
|
1233
|
+
function mouseenter_handler() {
|
|
1234
|
+
return /*mouseenter_handler*/ ctx[36](/*result*/ ctx[41], /*i*/ ctx[43]);
|
|
1221
1235
|
}
|
|
1222
1236
|
|
|
1223
1237
|
return {
|
|
@@ -1226,11 +1240,11 @@
|
|
|
1226
1240
|
if (default_slot_or_fallback) default_slot_or_fallback.c();
|
|
1227
1241
|
t = space();
|
|
1228
1242
|
attr(li, "role", "option");
|
|
1229
|
-
attr(li, "id", li_id_value = "" + (/*id*/ ctx[2] + "-result-" + /*i*/ ctx[
|
|
1230
|
-
attr(li, "aria-selected", li_aria_selected_value = /*selectedIndex*/ ctx[6] === /*i*/ ctx[
|
|
1243
|
+
attr(li, "id", li_id_value = "" + (/*id*/ ctx[2] + "-result-" + /*i*/ ctx[43]));
|
|
1244
|
+
attr(li, "aria-selected", li_aria_selected_value = /*selectedIndex*/ ctx[6] === /*i*/ ctx[43]);
|
|
1231
1245
|
attr(li, "class", "svelte-j5n77y");
|
|
1232
|
-
toggle_class(li, "selected", /*selectedIndex*/ ctx[6] === /*i*/ ctx[
|
|
1233
|
-
toggle_class(li, "disabled", /*result*/ ctx[
|
|
1246
|
+
toggle_class(li, "selected", /*selectedIndex*/ ctx[6] === /*i*/ ctx[43]);
|
|
1247
|
+
toggle_class(li, "disabled", /*result*/ ctx[41].disabled);
|
|
1234
1248
|
},
|
|
1235
1249
|
m(target, anchor) {
|
|
1236
1250
|
insert(target, li, anchor);
|
|
@@ -1243,7 +1257,11 @@
|
|
|
1243
1257
|
current = true;
|
|
1244
1258
|
|
|
1245
1259
|
if (!mounted) {
|
|
1246
|
-
dispose =
|
|
1260
|
+
dispose = [
|
|
1261
|
+
listen(li, "click", click_handler_1),
|
|
1262
|
+
listen(li, "mouseenter", mouseenter_handler)
|
|
1263
|
+
];
|
|
1264
|
+
|
|
1247
1265
|
mounted = true;
|
|
1248
1266
|
}
|
|
1249
1267
|
},
|
|
@@ -1269,20 +1287,20 @@
|
|
|
1269
1287
|
}
|
|
1270
1288
|
}
|
|
1271
1289
|
|
|
1272
|
-
if (!current || dirty[0] & /*id*/ 4 && li_id_value !== (li_id_value = "" + (/*id*/ ctx[2] + "-result-" + /*i*/ ctx[
|
|
1290
|
+
if (!current || dirty[0] & /*id*/ 4 && li_id_value !== (li_id_value = "" + (/*id*/ ctx[2] + "-result-" + /*i*/ ctx[43]))) {
|
|
1273
1291
|
attr(li, "id", li_id_value);
|
|
1274
1292
|
}
|
|
1275
1293
|
|
|
1276
|
-
if (!current || dirty[0] & /*selectedIndex*/ 64 && li_aria_selected_value !== (li_aria_selected_value = /*selectedIndex*/ ctx[6] === /*i*/ ctx[
|
|
1294
|
+
if (!current || dirty[0] & /*selectedIndex*/ 64 && li_aria_selected_value !== (li_aria_selected_value = /*selectedIndex*/ ctx[6] === /*i*/ ctx[43])) {
|
|
1277
1295
|
attr(li, "aria-selected", li_aria_selected_value);
|
|
1278
1296
|
}
|
|
1279
1297
|
|
|
1280
1298
|
if (dirty[0] & /*selectedIndex*/ 64) {
|
|
1281
|
-
toggle_class(li, "selected", /*selectedIndex*/ ctx[6] === /*i*/ ctx[
|
|
1299
|
+
toggle_class(li, "selected", /*selectedIndex*/ ctx[6] === /*i*/ ctx[43]);
|
|
1282
1300
|
}
|
|
1283
1301
|
|
|
1284
1302
|
if (dirty[0] & /*results*/ 2) {
|
|
1285
|
-
toggle_class(li, "disabled", /*result*/ ctx[
|
|
1303
|
+
toggle_class(li, "disabled", /*result*/ ctx[41].disabled);
|
|
1286
1304
|
}
|
|
1287
1305
|
},
|
|
1288
1306
|
i(local) {
|
|
@@ -1298,12 +1316,12 @@
|
|
|
1298
1316
|
if (detaching) detach(li);
|
|
1299
1317
|
if (default_slot_or_fallback) default_slot_or_fallback.d(detaching);
|
|
1300
1318
|
mounted = false;
|
|
1301
|
-
dispose
|
|
1319
|
+
run_all(dispose);
|
|
1302
1320
|
}
|
|
1303
1321
|
};
|
|
1304
1322
|
}
|
|
1305
1323
|
|
|
1306
|
-
// (
|
|
1324
|
+
// (223:4) {#if $$slots["no-results"] && !hideDropdown && value.length > 0 && results.length === 0}
|
|
1307
1325
|
function create_if_block(ctx) {
|
|
1308
1326
|
let div;
|
|
1309
1327
|
let current;
|
|
@@ -1462,7 +1480,7 @@
|
|
|
1462
1480
|
if (if_block0) if_block0.m(ul, null);
|
|
1463
1481
|
append(ul, t1);
|
|
1464
1482
|
if (if_block1) if_block1.m(ul, null);
|
|
1465
|
-
/*div_binding*/ ctx[
|
|
1483
|
+
/*div_binding*/ ctx[37](div);
|
|
1466
1484
|
current = true;
|
|
1467
1485
|
|
|
1468
1486
|
if (!mounted) {
|
|
@@ -1593,7 +1611,7 @@
|
|
|
1593
1611
|
destroy_component(search);
|
|
1594
1612
|
if (if_block0) if_block0.d();
|
|
1595
1613
|
if (if_block1) if_block1.d();
|
|
1596
|
-
/*div_binding*/ ctx[
|
|
1614
|
+
/*div_binding*/ ctx[37](null);
|
|
1597
1615
|
mounted = false;
|
|
1598
1616
|
dispose();
|
|
1599
1617
|
}
|
|
@@ -1767,6 +1785,11 @@
|
|
|
1767
1785
|
}
|
|
1768
1786
|
};
|
|
1769
1787
|
|
|
1788
|
+
const mouseenter_handler = (result, i) => {
|
|
1789
|
+
if (result.disabled) return;
|
|
1790
|
+
$$invalidate(6, selectedIndex = i);
|
|
1791
|
+
};
|
|
1792
|
+
|
|
1770
1793
|
function div_binding($$value) {
|
|
1771
1794
|
binding_callbacks[$$value ? 'unshift' : 'push'](() => {
|
|
1772
1795
|
comboboxRef = $$value;
|
|
@@ -1845,6 +1868,7 @@
|
|
|
1845
1868
|
keydown_handler,
|
|
1846
1869
|
keydown_handler_1,
|
|
1847
1870
|
click_handler_1,
|
|
1871
|
+
mouseenter_handler,
|
|
1848
1872
|
div_binding
|
|
1849
1873
|
];
|
|
1850
1874
|
}
|
package/lib/index.mjs
CHANGED
|
@@ -130,6 +130,9 @@ function destroy_each(iterations, detaching) {
|
|
|
130
130
|
function element(name) {
|
|
131
131
|
return document.createElement(name);
|
|
132
132
|
}
|
|
133
|
+
function svg_element(name) {
|
|
134
|
+
return document.createElementNS('http://www.w3.org/2000/svg', name);
|
|
135
|
+
}
|
|
133
136
|
function text(data) {
|
|
134
137
|
return document.createTextNode(data);
|
|
135
138
|
}
|
|
@@ -191,13 +194,15 @@ function set_input_value(input, value) {
|
|
|
191
194
|
function toggle_class(element, name, toggle) {
|
|
192
195
|
element.classList[toggle ? 'add' : 'remove'](name);
|
|
193
196
|
}
|
|
194
|
-
function custom_event(type, detail, bubbles = false) {
|
|
197
|
+
function custom_event(type, detail, { bubbles = false, cancelable = false } = {}) {
|
|
195
198
|
const e = document.createEvent('CustomEvent');
|
|
196
|
-
e.initCustomEvent(type, bubbles,
|
|
199
|
+
e.initCustomEvent(type, bubbles, cancelable, detail);
|
|
197
200
|
return e;
|
|
198
201
|
}
|
|
199
202
|
class HtmlTag {
|
|
200
|
-
constructor() {
|
|
203
|
+
constructor(is_svg = false) {
|
|
204
|
+
this.is_svg = false;
|
|
205
|
+
this.is_svg = is_svg;
|
|
201
206
|
this.e = this.n = null;
|
|
202
207
|
}
|
|
203
208
|
c(html) {
|
|
@@ -205,7 +210,10 @@ class HtmlTag {
|
|
|
205
210
|
}
|
|
206
211
|
m(html, target, anchor = null) {
|
|
207
212
|
if (!this.e) {
|
|
208
|
-
|
|
213
|
+
if (this.is_svg)
|
|
214
|
+
this.e = svg_element(target.nodeName);
|
|
215
|
+
else
|
|
216
|
+
this.e = element(target.nodeName);
|
|
209
217
|
this.t = target;
|
|
210
218
|
this.c(html);
|
|
211
219
|
}
|
|
@@ -247,16 +255,18 @@ function afterUpdate(fn) {
|
|
|
247
255
|
}
|
|
248
256
|
function createEventDispatcher() {
|
|
249
257
|
const component = get_current_component();
|
|
250
|
-
return (type, detail) => {
|
|
258
|
+
return (type, detail, { cancelable = false } = {}) => {
|
|
251
259
|
const callbacks = component.$$.callbacks[type];
|
|
252
260
|
if (callbacks) {
|
|
253
261
|
// TODO are there situations where events could be dispatched
|
|
254
262
|
// in a server (non-DOM) environment?
|
|
255
|
-
const event = custom_event(type, detail);
|
|
263
|
+
const event = custom_event(type, detail, { cancelable });
|
|
256
264
|
callbacks.slice().forEach(fn => {
|
|
257
265
|
fn.call(component, event);
|
|
258
266
|
});
|
|
267
|
+
return !event.defaultPrevented;
|
|
259
268
|
}
|
|
269
|
+
return true;
|
|
260
270
|
};
|
|
261
271
|
}
|
|
262
272
|
// TODO figure out if we still want to support
|
|
@@ -715,7 +725,7 @@ fuzzy.filter = function(pattern, arr, opts) {
|
|
|
715
725
|
|
|
716
726
|
var fuzzy = fuzzy$1.exports;
|
|
717
727
|
|
|
718
|
-
/* node_modules/svelte-search/src/Search.svelte generated by Svelte v3.
|
|
728
|
+
/* node_modules/svelte-search/src/Search.svelte generated by Svelte v3.48.0 */
|
|
719
729
|
|
|
720
730
|
function add_css$1(target) {
|
|
721
731
|
append_styles(target, "svelte-5m0wg6", ".hide-label.svelte-5m0wg6{position:absolute;height:1px;width:1px;overflow:hidden;clip:rect(1px 1px 1px 1px);clip:rect(1px, 1px, 1px, 1px);white-space:nowrap}");
|
|
@@ -1052,7 +1062,7 @@ class Search extends SvelteComponent {
|
|
|
1052
1062
|
|
|
1053
1063
|
var Search$1 = Search;
|
|
1054
1064
|
|
|
1055
|
-
/* src/Typeahead.svelte generated by Svelte v3.
|
|
1065
|
+
/* src/Typeahead.svelte generated by Svelte v3.48.0 */
|
|
1056
1066
|
|
|
1057
1067
|
function add_css(target) {
|
|
1058
1068
|
append_styles(target, "svelte-j5n77y", "[data-svelte-typeahead].svelte-j5n77y{position:relative;background-color:#fff}ul.svelte-j5n77y{position:absolute;top:100%;left:0;width:100%;padding:0;list-style:none;background-color:inherit;box-shadow:0 4px 8px rgba(0, 0, 0, 0.1)}li.svelte-j5n77y,.no-results.svelte-j5n77y{padding:0.25rem 1rem}li.svelte-j5n77y{cursor:pointer}li.svelte-j5n77y:not(:last-of-type){border-bottom:1px solid #e0e0e0}li.svelte-j5n77y:hover{background-color:#e5e5e5}.selected.svelte-j5n77y{background-color:#e5e5e5}.selected.svelte-j5n77y:hover{background-color:#cacaca}.disabled.svelte-j5n77y{opacity:0.4;cursor:not-allowed}[data-svelte-search] label{margin-bottom:0.25rem;display:inline-flex;font-size:0.875rem}[data-svelte-search] input{width:100%;padding:0.5rem 0.75rem;background:none;font-size:1rem;border:0;border-radius:0;border:1px solid #e5e5e5}[data-svelte-search] input:focus{outline-color:#0f62fe;outline-offset:2px;outline-width:1px}");
|
|
@@ -1065,14 +1075,14 @@ const get_no_results_slot_changes = dirty => ({
|
|
|
1065
1075
|
|
|
1066
1076
|
const get_no_results_slot_context = ctx => ({
|
|
1067
1077
|
value: /*value*/ ctx[0],
|
|
1068
|
-
result: /*result*/ ctx[
|
|
1069
|
-
index: /*i*/ ctx[
|
|
1078
|
+
result: /*result*/ ctx[41],
|
|
1079
|
+
index: /*i*/ ctx[43]
|
|
1070
1080
|
});
|
|
1071
1081
|
|
|
1072
1082
|
function get_each_context(ctx, list, i) {
|
|
1073
1083
|
const child_ctx = ctx.slice();
|
|
1074
|
-
child_ctx[
|
|
1075
|
-
child_ctx[
|
|
1084
|
+
child_ctx[41] = list[i];
|
|
1085
|
+
child_ctx[43] = i;
|
|
1076
1086
|
return child_ctx;
|
|
1077
1087
|
}
|
|
1078
1088
|
|
|
@@ -1082,8 +1092,8 @@ const get_default_slot_changes = dirty => ({
|
|
|
1082
1092
|
});
|
|
1083
1093
|
|
|
1084
1094
|
const get_default_slot_context = ctx => ({
|
|
1085
|
-
result: /*result*/ ctx[
|
|
1086
|
-
index: /*i*/ ctx[
|
|
1095
|
+
result: /*result*/ ctx[41],
|
|
1096
|
+
index: /*i*/ ctx[43],
|
|
1087
1097
|
value: /*value*/ ctx[0]
|
|
1088
1098
|
});
|
|
1089
1099
|
|
|
@@ -1171,15 +1181,15 @@ function create_if_block_1(ctx) {
|
|
|
1171
1181
|
};
|
|
1172
1182
|
}
|
|
1173
1183
|
|
|
1174
|
-
// (
|
|
1184
|
+
// (217:43)
|
|
1175
1185
|
function fallback_block(ctx) {
|
|
1176
1186
|
let html_tag;
|
|
1177
|
-
let raw_value = /*result*/ ctx[
|
|
1187
|
+
let raw_value = /*result*/ ctx[41].string + "";
|
|
1178
1188
|
let html_anchor;
|
|
1179
1189
|
|
|
1180
1190
|
return {
|
|
1181
1191
|
c() {
|
|
1182
|
-
html_tag = new HtmlTag();
|
|
1192
|
+
html_tag = new HtmlTag(false);
|
|
1183
1193
|
html_anchor = empty();
|
|
1184
1194
|
html_tag.a = html_anchor;
|
|
1185
1195
|
},
|
|
@@ -1188,7 +1198,7 @@ function fallback_block(ctx) {
|
|
|
1188
1198
|
insert(target, html_anchor, anchor);
|
|
1189
1199
|
},
|
|
1190
1200
|
p(ctx, dirty) {
|
|
1191
|
-
if (dirty[0] & /*results*/ 2 && raw_value !== (raw_value = /*result*/ ctx[
|
|
1201
|
+
if (dirty[0] & /*results*/ 2 && raw_value !== (raw_value = /*result*/ ctx[41].string + "")) html_tag.p(raw_value);
|
|
1192
1202
|
},
|
|
1193
1203
|
d(detaching) {
|
|
1194
1204
|
if (detaching) detach(html_anchor);
|
|
@@ -1211,7 +1221,11 @@ function create_each_block(ctx) {
|
|
|
1211
1221
|
const default_slot_or_fallback = default_slot || fallback_block(ctx);
|
|
1212
1222
|
|
|
1213
1223
|
function click_handler_1() {
|
|
1214
|
-
return /*click_handler_1*/ ctx[35](/*result*/ ctx[
|
|
1224
|
+
return /*click_handler_1*/ ctx[35](/*result*/ ctx[41], /*i*/ ctx[43]);
|
|
1225
|
+
}
|
|
1226
|
+
|
|
1227
|
+
function mouseenter_handler() {
|
|
1228
|
+
return /*mouseenter_handler*/ ctx[36](/*result*/ ctx[41], /*i*/ ctx[43]);
|
|
1215
1229
|
}
|
|
1216
1230
|
|
|
1217
1231
|
return {
|
|
@@ -1220,11 +1234,11 @@ function create_each_block(ctx) {
|
|
|
1220
1234
|
if (default_slot_or_fallback) default_slot_or_fallback.c();
|
|
1221
1235
|
t = space();
|
|
1222
1236
|
attr(li, "role", "option");
|
|
1223
|
-
attr(li, "id", li_id_value = "" + (/*id*/ ctx[2] + "-result-" + /*i*/ ctx[
|
|
1224
|
-
attr(li, "aria-selected", li_aria_selected_value = /*selectedIndex*/ ctx[6] === /*i*/ ctx[
|
|
1237
|
+
attr(li, "id", li_id_value = "" + (/*id*/ ctx[2] + "-result-" + /*i*/ ctx[43]));
|
|
1238
|
+
attr(li, "aria-selected", li_aria_selected_value = /*selectedIndex*/ ctx[6] === /*i*/ ctx[43]);
|
|
1225
1239
|
attr(li, "class", "svelte-j5n77y");
|
|
1226
|
-
toggle_class(li, "selected", /*selectedIndex*/ ctx[6] === /*i*/ ctx[
|
|
1227
|
-
toggle_class(li, "disabled", /*result*/ ctx[
|
|
1240
|
+
toggle_class(li, "selected", /*selectedIndex*/ ctx[6] === /*i*/ ctx[43]);
|
|
1241
|
+
toggle_class(li, "disabled", /*result*/ ctx[41].disabled);
|
|
1228
1242
|
},
|
|
1229
1243
|
m(target, anchor) {
|
|
1230
1244
|
insert(target, li, anchor);
|
|
@@ -1237,7 +1251,11 @@ function create_each_block(ctx) {
|
|
|
1237
1251
|
current = true;
|
|
1238
1252
|
|
|
1239
1253
|
if (!mounted) {
|
|
1240
|
-
dispose =
|
|
1254
|
+
dispose = [
|
|
1255
|
+
listen(li, "click", click_handler_1),
|
|
1256
|
+
listen(li, "mouseenter", mouseenter_handler)
|
|
1257
|
+
];
|
|
1258
|
+
|
|
1241
1259
|
mounted = true;
|
|
1242
1260
|
}
|
|
1243
1261
|
},
|
|
@@ -1263,20 +1281,20 @@ function create_each_block(ctx) {
|
|
|
1263
1281
|
}
|
|
1264
1282
|
}
|
|
1265
1283
|
|
|
1266
|
-
if (!current || dirty[0] & /*id*/ 4 && li_id_value !== (li_id_value = "" + (/*id*/ ctx[2] + "-result-" + /*i*/ ctx[
|
|
1284
|
+
if (!current || dirty[0] & /*id*/ 4 && li_id_value !== (li_id_value = "" + (/*id*/ ctx[2] + "-result-" + /*i*/ ctx[43]))) {
|
|
1267
1285
|
attr(li, "id", li_id_value);
|
|
1268
1286
|
}
|
|
1269
1287
|
|
|
1270
|
-
if (!current || dirty[0] & /*selectedIndex*/ 64 && li_aria_selected_value !== (li_aria_selected_value = /*selectedIndex*/ ctx[6] === /*i*/ ctx[
|
|
1288
|
+
if (!current || dirty[0] & /*selectedIndex*/ 64 && li_aria_selected_value !== (li_aria_selected_value = /*selectedIndex*/ ctx[6] === /*i*/ ctx[43])) {
|
|
1271
1289
|
attr(li, "aria-selected", li_aria_selected_value);
|
|
1272
1290
|
}
|
|
1273
1291
|
|
|
1274
1292
|
if (dirty[0] & /*selectedIndex*/ 64) {
|
|
1275
|
-
toggle_class(li, "selected", /*selectedIndex*/ ctx[6] === /*i*/ ctx[
|
|
1293
|
+
toggle_class(li, "selected", /*selectedIndex*/ ctx[6] === /*i*/ ctx[43]);
|
|
1276
1294
|
}
|
|
1277
1295
|
|
|
1278
1296
|
if (dirty[0] & /*results*/ 2) {
|
|
1279
|
-
toggle_class(li, "disabled", /*result*/ ctx[
|
|
1297
|
+
toggle_class(li, "disabled", /*result*/ ctx[41].disabled);
|
|
1280
1298
|
}
|
|
1281
1299
|
},
|
|
1282
1300
|
i(local) {
|
|
@@ -1292,12 +1310,12 @@ function create_each_block(ctx) {
|
|
|
1292
1310
|
if (detaching) detach(li);
|
|
1293
1311
|
if (default_slot_or_fallback) default_slot_or_fallback.d(detaching);
|
|
1294
1312
|
mounted = false;
|
|
1295
|
-
dispose
|
|
1313
|
+
run_all(dispose);
|
|
1296
1314
|
}
|
|
1297
1315
|
};
|
|
1298
1316
|
}
|
|
1299
1317
|
|
|
1300
|
-
// (
|
|
1318
|
+
// (223:4) {#if $$slots["no-results"] && !hideDropdown && value.length > 0 && results.length === 0}
|
|
1301
1319
|
function create_if_block(ctx) {
|
|
1302
1320
|
let div;
|
|
1303
1321
|
let current;
|
|
@@ -1456,7 +1474,7 @@ function create_fragment(ctx) {
|
|
|
1456
1474
|
if (if_block0) if_block0.m(ul, null);
|
|
1457
1475
|
append(ul, t1);
|
|
1458
1476
|
if (if_block1) if_block1.m(ul, null);
|
|
1459
|
-
/*div_binding*/ ctx[
|
|
1477
|
+
/*div_binding*/ ctx[37](div);
|
|
1460
1478
|
current = true;
|
|
1461
1479
|
|
|
1462
1480
|
if (!mounted) {
|
|
@@ -1587,7 +1605,7 @@ function create_fragment(ctx) {
|
|
|
1587
1605
|
destroy_component(search);
|
|
1588
1606
|
if (if_block0) if_block0.d();
|
|
1589
1607
|
if (if_block1) if_block1.d();
|
|
1590
|
-
/*div_binding*/ ctx[
|
|
1608
|
+
/*div_binding*/ ctx[37](null);
|
|
1591
1609
|
mounted = false;
|
|
1592
1610
|
dispose();
|
|
1593
1611
|
}
|
|
@@ -1761,6 +1779,11 @@ function instance($$self, $$props, $$invalidate) {
|
|
|
1761
1779
|
}
|
|
1762
1780
|
};
|
|
1763
1781
|
|
|
1782
|
+
const mouseenter_handler = (result, i) => {
|
|
1783
|
+
if (result.disabled) return;
|
|
1784
|
+
$$invalidate(6, selectedIndex = i);
|
|
1785
|
+
};
|
|
1786
|
+
|
|
1764
1787
|
function div_binding($$value) {
|
|
1765
1788
|
binding_callbacks[$$value ? 'unshift' : 'push'](() => {
|
|
1766
1789
|
comboboxRef = $$value;
|
|
@@ -1839,6 +1862,7 @@ function instance($$self, $$props, $$invalidate) {
|
|
|
1839
1862
|
keydown_handler,
|
|
1840
1863
|
keydown_handler_1,
|
|
1841
1864
|
click_handler_1,
|
|
1865
|
+
mouseenter_handler,
|
|
1842
1866
|
div_binding
|
|
1843
1867
|
];
|
|
1844
1868
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "svelte-typeahead",
|
|
3
|
-
"version": "4.2.
|
|
3
|
+
"version": "4.2.3",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"description": "Accessible, fuzzy search typeahead component",
|
|
6
6
|
"author": "Eric Liu (https://github.com/metonym)",
|
|
@@ -22,8 +22,8 @@
|
|
|
22
22
|
},
|
|
23
23
|
"devDependencies": {
|
|
24
24
|
"@rollup/plugin-commonjs": "^21.0.2",
|
|
25
|
-
"svelte": "^3.
|
|
26
|
-
"svelte-check": "^2.
|
|
25
|
+
"svelte": "^3.48.0",
|
|
26
|
+
"svelte-check": "^2.8.0",
|
|
27
27
|
"svelte-readme": "^3.6.3"
|
|
28
28
|
},
|
|
29
29
|
"repository": {
|