svelte-typeahead 4.2.2 → 4.3.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/CHANGELOG.md +18 -0
- package/README.md +35 -35
- package/lib/index.js +183 -133
- package/lib/index.mjs +183 -133
- package/package.json +3 -3
- package/src/Typeahead.svelte +43 -22
- package/types/Typeahead.svelte.d.ts +6 -0
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
|
|
@@ -400,6 +410,9 @@
|
|
|
400
410
|
});
|
|
401
411
|
block.o(local);
|
|
402
412
|
}
|
|
413
|
+
else if (callback) {
|
|
414
|
+
callback();
|
|
415
|
+
}
|
|
403
416
|
}
|
|
404
417
|
|
|
405
418
|
function get_spread_update(levels, updates) {
|
|
@@ -721,7 +734,7 @@
|
|
|
721
734
|
|
|
722
735
|
var fuzzy = fuzzy$1.exports;
|
|
723
736
|
|
|
724
|
-
/* node_modules/svelte-search/src/Search.svelte generated by Svelte v3.
|
|
737
|
+
/* node_modules/svelte-search/src/Search.svelte generated by Svelte v3.49.0 */
|
|
725
738
|
|
|
726
739
|
function add_css$1(target) {
|
|
727
740
|
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,10 +1071,10 @@
|
|
|
1058
1071
|
|
|
1059
1072
|
var Search$1 = Search;
|
|
1060
1073
|
|
|
1061
|
-
/* src/Typeahead.svelte generated by Svelte v3.
|
|
1074
|
+
/* src/Typeahead.svelte generated by Svelte v3.49.0 */
|
|
1062
1075
|
|
|
1063
1076
|
function add_css(target) {
|
|
1064
|
-
append_styles(target, "svelte-
|
|
1077
|
+
append_styles(target, "svelte-9wywte", "[data-svelte-typeahead].svelte-9wywte.svelte-9wywte{position:relative;background-color:#fff}ul.svelte-9wywte.svelte-9wywte{position:absolute;top:100%;left:0;width:100%;padding:0;list-style:none;background-color:inherit;box-shadow:0 4px 8px rgba(0, 0, 0, 0.1)}[aria-expanded=\"true\"].svelte-9wywte ul.svelte-9wywte{z-index:1}li.svelte-9wywte.svelte-9wywte,.no-results.svelte-9wywte.svelte-9wywte{padding:0.25rem 1rem}li.svelte-9wywte.svelte-9wywte{cursor:pointer}li.svelte-9wywte.svelte-9wywte:not(:last-of-type){border-bottom:1px solid #e0e0e0}li.svelte-9wywte.svelte-9wywte:hover{background-color:#e5e5e5}.selected.svelte-9wywte.svelte-9wywte{background-color:#e5e5e5}.selected.svelte-9wywte.svelte-9wywte:hover{background-color:#cacaca}.disabled.svelte-9wywte.svelte-9wywte{opacity:0.4;cursor:not-allowed}[data-svelte-search] label{margin-bottom:0.25rem;display:inline-flex;font-size:0.875rem}[data-svelte-search] input{width:100%;padding:0.5rem 0.75rem;background:none;font-size:1rem;border:0;border-radius:0;border:1px solid #e5e5e5}[data-svelte-search] input:focus{outline-color:#0f62fe;outline-offset:2px;outline-width:1px}");
|
|
1065
1078
|
}
|
|
1066
1079
|
|
|
1067
1080
|
const get_no_results_slot_changes = dirty => ({
|
|
@@ -1071,14 +1084,14 @@
|
|
|
1071
1084
|
|
|
1072
1085
|
const get_no_results_slot_context = ctx => ({
|
|
1073
1086
|
value: /*value*/ ctx[0],
|
|
1074
|
-
result: /*result*/ ctx[
|
|
1075
|
-
index: /*
|
|
1087
|
+
result: /*result*/ ctx[46],
|
|
1088
|
+
index: /*index*/ ctx[48]
|
|
1076
1089
|
});
|
|
1077
1090
|
|
|
1078
1091
|
function get_each_context(ctx, list, i) {
|
|
1079
1092
|
const child_ctx = ctx.slice();
|
|
1080
|
-
child_ctx[
|
|
1081
|
-
child_ctx[
|
|
1093
|
+
child_ctx[46] = list[i];
|
|
1094
|
+
child_ctx[48] = i;
|
|
1082
1095
|
return child_ctx;
|
|
1083
1096
|
}
|
|
1084
1097
|
|
|
@@ -1088,12 +1101,12 @@
|
|
|
1088
1101
|
});
|
|
1089
1102
|
|
|
1090
1103
|
const get_default_slot_context = ctx => ({
|
|
1091
|
-
result: /*result*/ ctx[
|
|
1092
|
-
index: /*
|
|
1104
|
+
result: /*result*/ ctx[46],
|
|
1105
|
+
index: /*index*/ ctx[48],
|
|
1093
1106
|
value: /*value*/ ctx[0]
|
|
1094
1107
|
});
|
|
1095
1108
|
|
|
1096
|
-
// (
|
|
1109
|
+
// (212:4) {#if showResults}
|
|
1097
1110
|
function create_if_block_1(ctx) {
|
|
1098
1111
|
let each_1_anchor;
|
|
1099
1112
|
let current;
|
|
@@ -1125,7 +1138,7 @@
|
|
|
1125
1138
|
current = true;
|
|
1126
1139
|
},
|
|
1127
1140
|
p(ctx, dirty) {
|
|
1128
|
-
if (dirty[0] & /*id, selectedIndex, results, select, $$scope, value*/
|
|
1141
|
+
if (dirty[0] & /*id, selectedIndex, results, select, $$scope, value*/ 33555207) {
|
|
1129
1142
|
each_value = /*results*/ ctx[1];
|
|
1130
1143
|
let i;
|
|
1131
1144
|
|
|
@@ -1177,15 +1190,15 @@
|
|
|
1177
1190
|
};
|
|
1178
1191
|
}
|
|
1179
1192
|
|
|
1180
|
-
// (
|
|
1193
|
+
// (230:41)
|
|
1181
1194
|
function fallback_block(ctx) {
|
|
1182
1195
|
let html_tag;
|
|
1183
|
-
let raw_value = /*result*/ ctx[
|
|
1196
|
+
let raw_value = /*result*/ ctx[46].string + "";
|
|
1184
1197
|
let html_anchor;
|
|
1185
1198
|
|
|
1186
1199
|
return {
|
|
1187
1200
|
c() {
|
|
1188
|
-
html_tag = new HtmlTag();
|
|
1201
|
+
html_tag = new HtmlTag(false);
|
|
1189
1202
|
html_anchor = empty();
|
|
1190
1203
|
html_tag.a = html_anchor;
|
|
1191
1204
|
},
|
|
@@ -1194,7 +1207,7 @@
|
|
|
1194
1207
|
insert(target, html_anchor, anchor);
|
|
1195
1208
|
},
|
|
1196
1209
|
p(ctx, dirty) {
|
|
1197
|
-
if (dirty[0] & /*results*/ 2 && raw_value !== (raw_value = /*result*/ ctx[
|
|
1210
|
+
if (dirty[0] & /*results*/ 2 && raw_value !== (raw_value = /*result*/ ctx[46].string + "")) html_tag.p(raw_value);
|
|
1198
1211
|
},
|
|
1199
1212
|
d(detaching) {
|
|
1200
1213
|
if (detaching) detach(html_anchor);
|
|
@@ -1203,7 +1216,7 @@
|
|
|
1203
1216
|
};
|
|
1204
1217
|
}
|
|
1205
1218
|
|
|
1206
|
-
// (
|
|
1219
|
+
// (213:6) {#each results as result, index}
|
|
1207
1220
|
function create_each_block(ctx) {
|
|
1208
1221
|
let li;
|
|
1209
1222
|
let t;
|
|
@@ -1212,12 +1225,16 @@
|
|
|
1212
1225
|
let current;
|
|
1213
1226
|
let mounted;
|
|
1214
1227
|
let dispose;
|
|
1215
|
-
const default_slot_template = /*#slots*/ ctx[
|
|
1216
|
-
const default_slot = create_slot(default_slot_template, ctx, /*$$scope*/ ctx[
|
|
1228
|
+
const default_slot_template = /*#slots*/ ctx[26].default;
|
|
1229
|
+
const default_slot = create_slot(default_slot_template, ctx, /*$$scope*/ ctx[25], get_default_slot_context);
|
|
1217
1230
|
const default_slot_or_fallback = default_slot || fallback_block(ctx);
|
|
1218
1231
|
|
|
1219
1232
|
function click_handler_1() {
|
|
1220
|
-
return /*click_handler_1*/ ctx[
|
|
1233
|
+
return /*click_handler_1*/ ctx[40](/*result*/ ctx[46], /*index*/ ctx[48]);
|
|
1234
|
+
}
|
|
1235
|
+
|
|
1236
|
+
function mouseenter_handler() {
|
|
1237
|
+
return /*mouseenter_handler*/ ctx[41](/*result*/ ctx[46], /*index*/ ctx[48]);
|
|
1221
1238
|
}
|
|
1222
1239
|
|
|
1223
1240
|
return {
|
|
@@ -1226,11 +1243,11 @@
|
|
|
1226
1243
|
if (default_slot_or_fallback) default_slot_or_fallback.c();
|
|
1227
1244
|
t = space();
|
|
1228
1245
|
attr(li, "role", "option");
|
|
1229
|
-
attr(li, "id", li_id_value = "" + (/*id*/ ctx[2] + "-result-" + /*
|
|
1230
|
-
attr(li, "aria-selected", li_aria_selected_value = /*selectedIndex*/ ctx[
|
|
1231
|
-
attr(li, "class", "svelte-
|
|
1232
|
-
toggle_class(li, "selected", /*selectedIndex*/ ctx[
|
|
1233
|
-
toggle_class(li, "disabled", /*result*/ ctx[
|
|
1246
|
+
attr(li, "id", li_id_value = "" + (/*id*/ ctx[2] + "-result-" + /*index*/ ctx[48]));
|
|
1247
|
+
attr(li, "aria-selected", li_aria_selected_value = /*selectedIndex*/ ctx[8] === /*index*/ ctx[48]);
|
|
1248
|
+
attr(li, "class", "svelte-9wywte");
|
|
1249
|
+
toggle_class(li, "selected", /*selectedIndex*/ ctx[8] === /*index*/ ctx[48]);
|
|
1250
|
+
toggle_class(li, "disabled", /*result*/ ctx[46].disabled);
|
|
1234
1251
|
},
|
|
1235
1252
|
m(target, anchor) {
|
|
1236
1253
|
insert(target, li, anchor);
|
|
@@ -1243,7 +1260,11 @@
|
|
|
1243
1260
|
current = true;
|
|
1244
1261
|
|
|
1245
1262
|
if (!mounted) {
|
|
1246
|
-
dispose =
|
|
1263
|
+
dispose = [
|
|
1264
|
+
listen(li, "click", click_handler_1),
|
|
1265
|
+
listen(li, "mouseenter", mouseenter_handler)
|
|
1266
|
+
];
|
|
1267
|
+
|
|
1247
1268
|
mounted = true;
|
|
1248
1269
|
}
|
|
1249
1270
|
},
|
|
@@ -1251,15 +1272,15 @@
|
|
|
1251
1272
|
ctx = new_ctx;
|
|
1252
1273
|
|
|
1253
1274
|
if (default_slot) {
|
|
1254
|
-
if (default_slot.p && (!current || dirty[0] & /*$$scope, results, value*/
|
|
1275
|
+
if (default_slot.p && (!current || dirty[0] & /*$$scope, results, value*/ 33554435)) {
|
|
1255
1276
|
update_slot_base(
|
|
1256
1277
|
default_slot,
|
|
1257
1278
|
default_slot_template,
|
|
1258
1279
|
ctx,
|
|
1259
|
-
/*$$scope*/ ctx[
|
|
1280
|
+
/*$$scope*/ ctx[25],
|
|
1260
1281
|
!current
|
|
1261
|
-
? get_all_dirty_from_scope(/*$$scope*/ ctx[
|
|
1262
|
-
: get_slot_changes(default_slot_template, /*$$scope*/ ctx[
|
|
1282
|
+
? get_all_dirty_from_scope(/*$$scope*/ ctx[25])
|
|
1283
|
+
: get_slot_changes(default_slot_template, /*$$scope*/ ctx[25], dirty, get_default_slot_changes),
|
|
1263
1284
|
get_default_slot_context
|
|
1264
1285
|
);
|
|
1265
1286
|
}
|
|
@@ -1269,20 +1290,20 @@
|
|
|
1269
1290
|
}
|
|
1270
1291
|
}
|
|
1271
1292
|
|
|
1272
|
-
if (!current || dirty[0] & /*id*/ 4 && li_id_value !== (li_id_value = "" + (/*id*/ ctx[2] + "-result-" + /*
|
|
1293
|
+
if (!current || dirty[0] & /*id*/ 4 && li_id_value !== (li_id_value = "" + (/*id*/ ctx[2] + "-result-" + /*index*/ ctx[48]))) {
|
|
1273
1294
|
attr(li, "id", li_id_value);
|
|
1274
1295
|
}
|
|
1275
1296
|
|
|
1276
|
-
if (!current || dirty[0] & /*selectedIndex*/
|
|
1297
|
+
if (!current || dirty[0] & /*selectedIndex*/ 256 && li_aria_selected_value !== (li_aria_selected_value = /*selectedIndex*/ ctx[8] === /*index*/ ctx[48])) {
|
|
1277
1298
|
attr(li, "aria-selected", li_aria_selected_value);
|
|
1278
1299
|
}
|
|
1279
1300
|
|
|
1280
|
-
if (dirty[0] & /*selectedIndex*/
|
|
1281
|
-
toggle_class(li, "selected", /*selectedIndex*/ ctx[
|
|
1301
|
+
if (dirty[0] & /*selectedIndex*/ 256) {
|
|
1302
|
+
toggle_class(li, "selected", /*selectedIndex*/ ctx[8] === /*index*/ ctx[48]);
|
|
1282
1303
|
}
|
|
1283
1304
|
|
|
1284
1305
|
if (dirty[0] & /*results*/ 2) {
|
|
1285
|
-
toggle_class(li, "disabled", /*result*/ ctx[
|
|
1306
|
+
toggle_class(li, "disabled", /*result*/ ctx[46].disabled);
|
|
1286
1307
|
}
|
|
1287
1308
|
},
|
|
1288
1309
|
i(local) {
|
|
@@ -1298,23 +1319,23 @@
|
|
|
1298
1319
|
if (detaching) detach(li);
|
|
1299
1320
|
if (default_slot_or_fallback) default_slot_or_fallback.d(detaching);
|
|
1300
1321
|
mounted = false;
|
|
1301
|
-
dispose
|
|
1322
|
+
run_all(dispose);
|
|
1302
1323
|
}
|
|
1303
1324
|
};
|
|
1304
1325
|
}
|
|
1305
1326
|
|
|
1306
|
-
// (
|
|
1327
|
+
// (236:4) {#if $$slots["no-results"] && !hideDropdown && value.length > 0 && results.length === 0}
|
|
1307
1328
|
function create_if_block(ctx) {
|
|
1308
1329
|
let div;
|
|
1309
1330
|
let current;
|
|
1310
|
-
const no_results_slot_template = /*#slots*/ ctx[
|
|
1311
|
-
const no_results_slot = create_slot(no_results_slot_template, ctx, /*$$scope*/ ctx[
|
|
1331
|
+
const no_results_slot_template = /*#slots*/ ctx[26]["no-results"];
|
|
1332
|
+
const no_results_slot = create_slot(no_results_slot_template, ctx, /*$$scope*/ ctx[25], get_no_results_slot_context);
|
|
1312
1333
|
|
|
1313
1334
|
return {
|
|
1314
1335
|
c() {
|
|
1315
1336
|
div = element("div");
|
|
1316
1337
|
if (no_results_slot) no_results_slot.c();
|
|
1317
|
-
attr(div, "class", "svelte-
|
|
1338
|
+
attr(div, "class", "svelte-9wywte");
|
|
1318
1339
|
toggle_class(div, "no-results", true);
|
|
1319
1340
|
},
|
|
1320
1341
|
m(target, anchor) {
|
|
@@ -1328,15 +1349,15 @@
|
|
|
1328
1349
|
},
|
|
1329
1350
|
p(ctx, dirty) {
|
|
1330
1351
|
if (no_results_slot) {
|
|
1331
|
-
if (no_results_slot.p && (!current || dirty[0] & /*$$scope, value, results*/
|
|
1352
|
+
if (no_results_slot.p && (!current || dirty[0] & /*$$scope, value, results*/ 33554435)) {
|
|
1332
1353
|
update_slot_base(
|
|
1333
1354
|
no_results_slot,
|
|
1334
1355
|
no_results_slot_template,
|
|
1335
1356
|
ctx,
|
|
1336
|
-
/*$$scope*/ ctx[
|
|
1357
|
+
/*$$scope*/ ctx[25],
|
|
1337
1358
|
!current
|
|
1338
|
-
? get_all_dirty_from_scope(/*$$scope*/ ctx[
|
|
1339
|
-
: get_slot_changes(no_results_slot_template, /*$$scope*/ ctx[
|
|
1359
|
+
? get_all_dirty_from_scope(/*$$scope*/ ctx[25])
|
|
1360
|
+
: get_slot_changes(no_results_slot_template, /*$$scope*/ ctx[25], dirty, get_no_results_slot_changes),
|
|
1340
1361
|
get_no_results_slot_context
|
|
1341
1362
|
);
|
|
1342
1363
|
}
|
|
@@ -1369,7 +1390,6 @@
|
|
|
1369
1390
|
let ul_aria_labelledby_value;
|
|
1370
1391
|
let ul_id_value;
|
|
1371
1392
|
let div_aria_owns_value;
|
|
1372
|
-
let div_aria_expanded_value;
|
|
1373
1393
|
let div_id_value;
|
|
1374
1394
|
let current;
|
|
1375
1395
|
let mounted;
|
|
@@ -1378,7 +1398,7 @@
|
|
|
1378
1398
|
const search_spread_levels = [
|
|
1379
1399
|
{ id: /*id*/ ctx[2] },
|
|
1380
1400
|
{ removeFormAriaAttributes: true },
|
|
1381
|
-
/*$$restProps*/ ctx[
|
|
1401
|
+
/*$$restProps*/ ctx[14],
|
|
1382
1402
|
{ "aria-autocomplete": "list" },
|
|
1383
1403
|
{
|
|
1384
1404
|
"aria-controls": "" + (/*id*/ ctx[2] + "-listbox")
|
|
@@ -1387,18 +1407,18 @@
|
|
|
1387
1407
|
"aria-labelledby": "" + (/*id*/ ctx[2] + "-label")
|
|
1388
1408
|
},
|
|
1389
1409
|
{
|
|
1390
|
-
"aria-activedescendant": /*selectedIndex*/ ctx[
|
|
1391
|
-
? `${/*id*/ ctx[2]}-result-${/*selectedIndex*/ ctx[
|
|
1410
|
+
"aria-activedescendant": /*selectedIndex*/ ctx[8] >= 0 && !/*hideDropdown*/ ctx[3] && /*results*/ ctx[1].length > 0
|
|
1411
|
+
? `${/*id*/ ctx[2]}-result-${/*selectedIndex*/ ctx[8]}`
|
|
1392
1412
|
: null
|
|
1393
1413
|
}
|
|
1394
1414
|
];
|
|
1395
1415
|
|
|
1396
1416
|
function search_ref_binding(value) {
|
|
1397
|
-
/*search_ref_binding*/ ctx[
|
|
1417
|
+
/*search_ref_binding*/ ctx[28](value);
|
|
1398
1418
|
}
|
|
1399
1419
|
|
|
1400
1420
|
function search_value_binding(value) {
|
|
1401
|
-
/*search_value_binding*/ ctx[
|
|
1421
|
+
/*search_value_binding*/ ctx[29](value);
|
|
1402
1422
|
}
|
|
1403
1423
|
|
|
1404
1424
|
let search_props = {};
|
|
@@ -1407,8 +1427,8 @@
|
|
|
1407
1427
|
search_props = assign(search_props, search_spread_levels[i]);
|
|
1408
1428
|
}
|
|
1409
1429
|
|
|
1410
|
-
if (/*searchRef*/ ctx[
|
|
1411
|
-
search_props.ref = /*searchRef*/ ctx[
|
|
1430
|
+
if (/*searchRef*/ ctx[7] !== void 0) {
|
|
1431
|
+
search_props.ref = /*searchRef*/ ctx[7];
|
|
1412
1432
|
}
|
|
1413
1433
|
|
|
1414
1434
|
if (/*value*/ ctx[0] !== void 0) {
|
|
@@ -1418,18 +1438,19 @@
|
|
|
1418
1438
|
search = new Search$1({ props: search_props });
|
|
1419
1439
|
binding_callbacks.push(() => bind(search, 'ref', search_ref_binding));
|
|
1420
1440
|
binding_callbacks.push(() => bind(search, 'value', search_value_binding));
|
|
1421
|
-
search.$on("type", /*type_handler*/ ctx[
|
|
1422
|
-
search.$on("input", /*input_handler*/ ctx[
|
|
1423
|
-
search.$on("change", /*change_handler*/ ctx[
|
|
1424
|
-
search.$on("focus", /*focus_handler*/ ctx[
|
|
1425
|
-
search.$on("focus", /*focus_handler_1*/ ctx[
|
|
1426
|
-
search.$on("clear", /*clear_handler*/ ctx[
|
|
1427
|
-
search.$on("clear", /*
|
|
1428
|
-
search.$on("blur", /*blur_handler*/ ctx[
|
|
1429
|
-
search.$on("
|
|
1430
|
-
search.$on("keydown", /*
|
|
1431
|
-
|
|
1432
|
-
let
|
|
1441
|
+
search.$on("type", /*type_handler*/ ctx[30]);
|
|
1442
|
+
search.$on("input", /*input_handler*/ ctx[31]);
|
|
1443
|
+
search.$on("change", /*change_handler*/ ctx[32]);
|
|
1444
|
+
search.$on("focus", /*focus_handler*/ ctx[33]);
|
|
1445
|
+
search.$on("focus", /*focus_handler_1*/ ctx[34]);
|
|
1446
|
+
search.$on("clear", /*clear_handler*/ ctx[35]);
|
|
1447
|
+
search.$on("clear", /*open*/ ctx[11]);
|
|
1448
|
+
search.$on("blur", /*blur_handler*/ ctx[36]);
|
|
1449
|
+
search.$on("blur", /*blur_handler_1*/ ctx[37]);
|
|
1450
|
+
search.$on("keydown", /*keydown_handler*/ ctx[38]);
|
|
1451
|
+
search.$on("keydown", /*keydown_handler_1*/ ctx[39]);
|
|
1452
|
+
let if_block0 = /*showResults*/ ctx[5] && create_if_block_1(ctx);
|
|
1453
|
+
let if_block1 = /*$$slots*/ ctx[13]["no-results"] && !/*hideDropdown*/ ctx[3] && /*value*/ ctx[0].length > 0 && /*results*/ ctx[1].length === 0 && create_if_block(ctx);
|
|
1433
1454
|
|
|
1434
1455
|
return {
|
|
1435
1456
|
c() {
|
|
@@ -1443,15 +1464,15 @@
|
|
|
1443
1464
|
attr(ul, "role", "listbox");
|
|
1444
1465
|
attr(ul, "aria-labelledby", ul_aria_labelledby_value = "" + (/*id*/ ctx[2] + "-label"));
|
|
1445
1466
|
attr(ul, "id", ul_id_value = "" + (/*id*/ ctx[2] + "-listbox"));
|
|
1446
|
-
attr(ul, "class", "svelte-
|
|
1467
|
+
attr(ul, "class", "svelte-9wywte");
|
|
1447
1468
|
toggle_class(ul, "svelte-typeahead-list", true);
|
|
1448
1469
|
attr(div, "data-svelte-typeahead", "");
|
|
1449
1470
|
attr(div, "role", "combobox");
|
|
1450
1471
|
attr(div, "aria-haspopup", "listbox");
|
|
1451
1472
|
attr(div, "aria-owns", div_aria_owns_value = "" + (/*id*/ ctx[2] + "-listbox"));
|
|
1452
|
-
attr(div, "aria-expanded",
|
|
1473
|
+
attr(div, "aria-expanded", /*showResults*/ ctx[5]);
|
|
1453
1474
|
attr(div, "id", div_id_value = "" + (/*id*/ ctx[2] + "-typeahead"));
|
|
1454
|
-
attr(div, "class", "svelte-
|
|
1475
|
+
attr(div, "class", "svelte-9wywte");
|
|
1455
1476
|
toggle_class(div, "dropdown", /*results*/ ctx[1].length > 0);
|
|
1456
1477
|
},
|
|
1457
1478
|
m(target, anchor) {
|
|
@@ -1462,20 +1483,20 @@
|
|
|
1462
1483
|
if (if_block0) if_block0.m(ul, null);
|
|
1463
1484
|
append(ul, t1);
|
|
1464
1485
|
if (if_block1) if_block1.m(ul, null);
|
|
1465
|
-
/*div_binding*/ ctx[
|
|
1486
|
+
/*div_binding*/ ctx[42](div);
|
|
1466
1487
|
current = true;
|
|
1467
1488
|
|
|
1468
1489
|
if (!mounted) {
|
|
1469
|
-
dispose = listen(window, "click", /*click_handler*/ ctx[
|
|
1490
|
+
dispose = listen(window, "click", /*click_handler*/ ctx[27]);
|
|
1470
1491
|
mounted = true;
|
|
1471
1492
|
}
|
|
1472
1493
|
},
|
|
1473
1494
|
p(ctx, dirty) {
|
|
1474
|
-
const search_changes = (dirty[0] & /*id, $$restProps, selectedIndex, hideDropdown, results*/
|
|
1495
|
+
const search_changes = (dirty[0] & /*id, $$restProps, selectedIndex, hideDropdown, results*/ 16654)
|
|
1475
1496
|
? get_spread_update(search_spread_levels, [
|
|
1476
1497
|
dirty[0] & /*id*/ 4 && { id: /*id*/ ctx[2] },
|
|
1477
1498
|
search_spread_levels[1],
|
|
1478
|
-
dirty[0] & /*$$restProps*/
|
|
1499
|
+
dirty[0] & /*$$restProps*/ 16384 && get_spread_object(/*$$restProps*/ ctx[14]),
|
|
1479
1500
|
search_spread_levels[3],
|
|
1480
1501
|
dirty[0] & /*id*/ 4 && {
|
|
1481
1502
|
"aria-controls": "" + (/*id*/ ctx[2] + "-listbox")
|
|
@@ -1483,17 +1504,17 @@
|
|
|
1483
1504
|
dirty[0] & /*id*/ 4 && {
|
|
1484
1505
|
"aria-labelledby": "" + (/*id*/ ctx[2] + "-label")
|
|
1485
1506
|
},
|
|
1486
|
-
dirty[0] & /*selectedIndex, hideDropdown, results, id*/
|
|
1487
|
-
"aria-activedescendant": /*selectedIndex*/ ctx[
|
|
1488
|
-
? `${/*id*/ ctx[2]}-result-${/*selectedIndex*/ ctx[
|
|
1507
|
+
dirty[0] & /*selectedIndex, hideDropdown, results, id*/ 270 && {
|
|
1508
|
+
"aria-activedescendant": /*selectedIndex*/ ctx[8] >= 0 && !/*hideDropdown*/ ctx[3] && /*results*/ ctx[1].length > 0
|
|
1509
|
+
? `${/*id*/ ctx[2]}-result-${/*selectedIndex*/ ctx[8]}`
|
|
1489
1510
|
: null
|
|
1490
1511
|
}
|
|
1491
1512
|
])
|
|
1492
1513
|
: {};
|
|
1493
1514
|
|
|
1494
|
-
if (!updating_ref && dirty[0] & /*searchRef*/
|
|
1515
|
+
if (!updating_ref && dirty[0] & /*searchRef*/ 128) {
|
|
1495
1516
|
updating_ref = true;
|
|
1496
|
-
search_changes.ref = /*searchRef*/ ctx[
|
|
1517
|
+
search_changes.ref = /*searchRef*/ ctx[7];
|
|
1497
1518
|
add_flush_callback(() => updating_ref = false);
|
|
1498
1519
|
}
|
|
1499
1520
|
|
|
@@ -1505,11 +1526,11 @@
|
|
|
1505
1526
|
|
|
1506
1527
|
search.$set(search_changes);
|
|
1507
1528
|
|
|
1508
|
-
if (
|
|
1529
|
+
if (/*showResults*/ ctx[5]) {
|
|
1509
1530
|
if (if_block0) {
|
|
1510
1531
|
if_block0.p(ctx, dirty);
|
|
1511
1532
|
|
|
1512
|
-
if (dirty[0] & /*
|
|
1533
|
+
if (dirty[0] & /*showResults*/ 32) {
|
|
1513
1534
|
transition_in(if_block0, 1);
|
|
1514
1535
|
}
|
|
1515
1536
|
} else {
|
|
@@ -1528,11 +1549,11 @@
|
|
|
1528
1549
|
check_outros();
|
|
1529
1550
|
}
|
|
1530
1551
|
|
|
1531
|
-
if (/*$$slots*/ ctx[
|
|
1552
|
+
if (/*$$slots*/ ctx[13]["no-results"] && !/*hideDropdown*/ ctx[3] && /*value*/ ctx[0].length > 0 && /*results*/ ctx[1].length === 0) {
|
|
1532
1553
|
if (if_block1) {
|
|
1533
1554
|
if_block1.p(ctx, dirty);
|
|
1534
1555
|
|
|
1535
|
-
if (dirty[0] & /*$$slots, hideDropdown, value, results*/
|
|
1556
|
+
if (dirty[0] & /*$$slots, hideDropdown, value, results*/ 8203) {
|
|
1536
1557
|
transition_in(if_block1, 1);
|
|
1537
1558
|
}
|
|
1538
1559
|
} else {
|
|
@@ -1563,8 +1584,8 @@
|
|
|
1563
1584
|
attr(div, "aria-owns", div_aria_owns_value);
|
|
1564
1585
|
}
|
|
1565
1586
|
|
|
1566
|
-
if (!current || dirty[0] & /*
|
|
1567
|
-
attr(div, "aria-expanded",
|
|
1587
|
+
if (!current || dirty[0] & /*showResults*/ 32) {
|
|
1588
|
+
attr(div, "aria-expanded", /*showResults*/ ctx[5]);
|
|
1568
1589
|
}
|
|
1569
1590
|
|
|
1570
1591
|
if (!current || dirty[0] & /*id*/ 4 && div_id_value !== (div_id_value = "" + (/*id*/ ctx[2] + "-typeahead"))) {
|
|
@@ -1593,7 +1614,7 @@
|
|
|
1593
1614
|
destroy_component(search);
|
|
1594
1615
|
if (if_block0) if_block0.d();
|
|
1595
1616
|
if (if_block1) if_block1.d();
|
|
1596
|
-
/*div_binding*/ ctx[
|
|
1617
|
+
/*div_binding*/ ctx[42](null);
|
|
1597
1618
|
mounted = false;
|
|
1598
1619
|
dispose();
|
|
1599
1620
|
}
|
|
@@ -1603,9 +1624,10 @@
|
|
|
1603
1624
|
function instance($$self, $$props, $$invalidate) {
|
|
1604
1625
|
let options;
|
|
1605
1626
|
let resultsId;
|
|
1627
|
+
let showResults;
|
|
1606
1628
|
|
|
1607
1629
|
const omit_props_names = [
|
|
1608
|
-
"id","value","data","extract","disable","filter","autoselect","inputAfterSelect","results","focusAfterSelect","limit"
|
|
1630
|
+
"id","value","data","extract","disable","filter","autoselect","inputAfterSelect","results","focusAfterSelect","showDropdownOnFocus","limit"
|
|
1609
1631
|
];
|
|
1610
1632
|
|
|
1611
1633
|
let $$restProps = compute_rest_props($$props, omit_props_names);
|
|
@@ -1621,6 +1643,7 @@
|
|
|
1621
1643
|
let { inputAfterSelect = "update" } = $$props;
|
|
1622
1644
|
let { results = [] } = $$props;
|
|
1623
1645
|
let { focusAfterSelect = false } = $$props;
|
|
1646
|
+
let { showDropdownOnFocus = false } = $$props;
|
|
1624
1647
|
let { limit = Infinity } = $$props;
|
|
1625
1648
|
const dispatch = createEventDispatcher();
|
|
1626
1649
|
let comboboxRef = null;
|
|
@@ -1628,14 +1651,15 @@
|
|
|
1628
1651
|
let hideDropdown = false;
|
|
1629
1652
|
let selectedIndex = -1;
|
|
1630
1653
|
let prevResults = "";
|
|
1654
|
+
let isFocused = false;
|
|
1631
1655
|
|
|
1632
1656
|
afterUpdate(() => {
|
|
1633
1657
|
if (prevResults !== resultsId && autoselect) {
|
|
1634
|
-
$$invalidate(
|
|
1658
|
+
$$invalidate(8, selectedIndex = 0);
|
|
1635
1659
|
}
|
|
1636
1660
|
|
|
1637
1661
|
if (prevResults !== resultsId && !$$slots["no-results"]) {
|
|
1638
|
-
$$invalidate(
|
|
1662
|
+
$$invalidate(3, hideDropdown = results.length === 0);
|
|
1639
1663
|
}
|
|
1640
1664
|
|
|
1641
1665
|
prevResults = resultsId;
|
|
@@ -1659,7 +1683,7 @@
|
|
|
1659
1683
|
|
|
1660
1684
|
await tick();
|
|
1661
1685
|
if (focusAfterSelect) searchRef.focus();
|
|
1662
|
-
|
|
1686
|
+
close();
|
|
1663
1687
|
}
|
|
1664
1688
|
|
|
1665
1689
|
/** @type {(direction: -1 | 1) => void} */
|
|
@@ -1681,18 +1705,21 @@
|
|
|
1681
1705
|
disabled = results[index].disabled;
|
|
1682
1706
|
}
|
|
1683
1707
|
|
|
1684
|
-
$$invalidate(
|
|
1708
|
+
$$invalidate(8, selectedIndex = index);
|
|
1685
1709
|
}
|
|
1686
1710
|
|
|
1711
|
+
const open = () => $$invalidate(3, hideDropdown = false);
|
|
1712
|
+
const close = () => $$invalidate(3, hideDropdown = true);
|
|
1713
|
+
|
|
1687
1714
|
const click_handler = ({ target }) => {
|
|
1688
|
-
if (!hideDropdown &&
|
|
1689
|
-
|
|
1715
|
+
if (!hideDropdown && !comboboxRef?.contains(target)) {
|
|
1716
|
+
close();
|
|
1690
1717
|
}
|
|
1691
1718
|
};
|
|
1692
1719
|
|
|
1693
1720
|
function search_ref_binding(value) {
|
|
1694
1721
|
searchRef = value;
|
|
1695
|
-
$$invalidate(
|
|
1722
|
+
$$invalidate(7, searchRef);
|
|
1696
1723
|
}
|
|
1697
1724
|
|
|
1698
1725
|
function search_value_binding(value$1) {
|
|
@@ -1717,21 +1744,22 @@
|
|
|
1717
1744
|
}
|
|
1718
1745
|
|
|
1719
1746
|
const focus_handler_1 = () => {
|
|
1720
|
-
|
|
1747
|
+
open();
|
|
1748
|
+
$$invalidate(4, isFocused = true);
|
|
1721
1749
|
};
|
|
1722
1750
|
|
|
1723
1751
|
function clear_handler(event) {
|
|
1724
1752
|
bubble.call(this, $$self, event);
|
|
1725
1753
|
}
|
|
1726
1754
|
|
|
1727
|
-
const clear_handler_1 = () => {
|
|
1728
|
-
$$invalidate(5, hideDropdown = false);
|
|
1729
|
-
};
|
|
1730
|
-
|
|
1731
1755
|
function blur_handler(event) {
|
|
1732
1756
|
bubble.call(this, $$self, event);
|
|
1733
1757
|
}
|
|
1734
1758
|
|
|
1759
|
+
const blur_handler_1 = () => {
|
|
1760
|
+
$$invalidate(4, isFocused = false);
|
|
1761
|
+
};
|
|
1762
|
+
|
|
1735
1763
|
function keydown_handler(event) {
|
|
1736
1764
|
bubble.call(this, $$self, event);
|
|
1737
1765
|
}
|
|
@@ -1754,70 +1782,89 @@
|
|
|
1754
1782
|
case "Escape":
|
|
1755
1783
|
e.preventDefault();
|
|
1756
1784
|
$$invalidate(0, value = "");
|
|
1757
|
-
searchRef
|
|
1758
|
-
|
|
1785
|
+
searchRef?.focus();
|
|
1786
|
+
close();
|
|
1759
1787
|
break;
|
|
1760
1788
|
}
|
|
1761
1789
|
};
|
|
1762
1790
|
|
|
1763
|
-
const click_handler_1 = (result,
|
|
1764
|
-
if (
|
|
1765
|
-
|
|
1766
|
-
|
|
1767
|
-
|
|
1791
|
+
const click_handler_1 = (result, index) => {
|
|
1792
|
+
if (result.disabled) return;
|
|
1793
|
+
$$invalidate(8, selectedIndex = index);
|
|
1794
|
+
select();
|
|
1795
|
+
};
|
|
1796
|
+
|
|
1797
|
+
const mouseenter_handler = (result, index) => {
|
|
1798
|
+
if (result.disabled) return;
|
|
1799
|
+
$$invalidate(8, selectedIndex = index);
|
|
1768
1800
|
};
|
|
1769
1801
|
|
|
1770
1802
|
function div_binding($$value) {
|
|
1771
1803
|
binding_callbacks[$$value ? 'unshift' : 'push'](() => {
|
|
1772
1804
|
comboboxRef = $$value;
|
|
1773
|
-
$$invalidate(
|
|
1805
|
+
$$invalidate(6, comboboxRef);
|
|
1774
1806
|
});
|
|
1775
1807
|
}
|
|
1776
1808
|
|
|
1777
1809
|
$$self.$$set = $$new_props => {
|
|
1778
1810
|
$$props = assign(assign({}, $$props), exclude_internal_props($$new_props));
|
|
1779
|
-
$$invalidate(
|
|
1811
|
+
$$invalidate(14, $$restProps = compute_rest_props($$props, omit_props_names));
|
|
1780
1812
|
if ('id' in $$new_props) $$invalidate(2, id = $$new_props.id);
|
|
1781
1813
|
if ('value' in $$new_props) $$invalidate(0, value = $$new_props.value);
|
|
1782
|
-
if ('data' in $$new_props) $$invalidate(
|
|
1783
|
-
if ('extract' in $$new_props) $$invalidate(
|
|
1784
|
-
if ('disable' in $$new_props) $$invalidate(
|
|
1785
|
-
if ('filter' in $$new_props) $$invalidate(
|
|
1786
|
-
if ('autoselect' in $$new_props) $$invalidate(
|
|
1787
|
-
if ('inputAfterSelect' in $$new_props) $$invalidate(
|
|
1814
|
+
if ('data' in $$new_props) $$invalidate(15, data = $$new_props.data);
|
|
1815
|
+
if ('extract' in $$new_props) $$invalidate(16, extract = $$new_props.extract);
|
|
1816
|
+
if ('disable' in $$new_props) $$invalidate(17, disable = $$new_props.disable);
|
|
1817
|
+
if ('filter' in $$new_props) $$invalidate(18, filter = $$new_props.filter);
|
|
1818
|
+
if ('autoselect' in $$new_props) $$invalidate(19, autoselect = $$new_props.autoselect);
|
|
1819
|
+
if ('inputAfterSelect' in $$new_props) $$invalidate(20, inputAfterSelect = $$new_props.inputAfterSelect);
|
|
1788
1820
|
if ('results' in $$new_props) $$invalidate(1, results = $$new_props.results);
|
|
1789
|
-
if ('focusAfterSelect' in $$new_props) $$invalidate(
|
|
1790
|
-
if ('
|
|
1791
|
-
if ('
|
|
1821
|
+
if ('focusAfterSelect' in $$new_props) $$invalidate(21, focusAfterSelect = $$new_props.focusAfterSelect);
|
|
1822
|
+
if ('showDropdownOnFocus' in $$new_props) $$invalidate(22, showDropdownOnFocus = $$new_props.showDropdownOnFocus);
|
|
1823
|
+
if ('limit' in $$new_props) $$invalidate(23, limit = $$new_props.limit);
|
|
1824
|
+
if ('$$scope' in $$new_props) $$invalidate(25, $$scope = $$new_props.$$scope);
|
|
1792
1825
|
};
|
|
1793
1826
|
|
|
1794
1827
|
$$self.$$.update = () => {
|
|
1795
|
-
if ($$self.$$.dirty[0] & /*extract*/
|
|
1796
|
-
$$invalidate(
|
|
1828
|
+
if ($$self.$$.dirty[0] & /*extract*/ 65536) {
|
|
1829
|
+
$$invalidate(24, options = { pre: "<mark>", post: "</mark>", extract });
|
|
1797
1830
|
}
|
|
1798
1831
|
|
|
1799
|
-
if ($$self.$$.dirty[0] & /*value, data, options, limit, filter, disable*/
|
|
1832
|
+
if ($$self.$$.dirty[0] & /*value, data, options, limit, filter, disable*/ 25591809) {
|
|
1800
1833
|
$$invalidate(1, results = fuzzy.filter(value, data, options).filter(({ score }) => score > 0).slice(0, limit).filter(result => !filter(result.original)).map(result => ({
|
|
1801
1834
|
...result,
|
|
1802
1835
|
disabled: disable(result.original)
|
|
1803
1836
|
})));
|
|
1804
1837
|
}
|
|
1805
1838
|
|
|
1806
|
-
if ($$self.$$.dirty[0] & /*results, extract*/
|
|
1839
|
+
if ($$self.$$.dirty[0] & /*results, extract*/ 65538) {
|
|
1807
1840
|
resultsId = results.map(result => extract(result.original)).join("");
|
|
1808
1841
|
}
|
|
1842
|
+
|
|
1843
|
+
if ($$self.$$.dirty[0] & /*hideDropdown, results*/ 10) {
|
|
1844
|
+
$$invalidate(5, showResults = !hideDropdown && results.length > 0);
|
|
1845
|
+
}
|
|
1846
|
+
|
|
1847
|
+
if ($$self.$$.dirty[0] & /*showDropdownOnFocus, showResults, isFocused*/ 4194352) {
|
|
1848
|
+
if (showDropdownOnFocus) {
|
|
1849
|
+
$$invalidate(5, showResults = showResults && isFocused);
|
|
1850
|
+
}
|
|
1851
|
+
}
|
|
1809
1852
|
};
|
|
1810
1853
|
|
|
1811
1854
|
return [
|
|
1812
1855
|
value,
|
|
1813
1856
|
results,
|
|
1814
1857
|
id,
|
|
1858
|
+
hideDropdown,
|
|
1859
|
+
isFocused,
|
|
1860
|
+
showResults,
|
|
1815
1861
|
comboboxRef,
|
|
1816
1862
|
searchRef,
|
|
1817
|
-
hideDropdown,
|
|
1818
1863
|
selectedIndex,
|
|
1819
1864
|
select,
|
|
1820
1865
|
change,
|
|
1866
|
+
open,
|
|
1867
|
+
close,
|
|
1821
1868
|
$$slots,
|
|
1822
1869
|
$$restProps,
|
|
1823
1870
|
data,
|
|
@@ -1827,6 +1874,7 @@
|
|
|
1827
1874
|
autoselect,
|
|
1828
1875
|
inputAfterSelect,
|
|
1829
1876
|
focusAfterSelect,
|
|
1877
|
+
showDropdownOnFocus,
|
|
1830
1878
|
limit,
|
|
1831
1879
|
options,
|
|
1832
1880
|
$$scope,
|
|
@@ -1840,11 +1888,12 @@
|
|
|
1840
1888
|
focus_handler,
|
|
1841
1889
|
focus_handler_1,
|
|
1842
1890
|
clear_handler,
|
|
1843
|
-
clear_handler_1,
|
|
1844
1891
|
blur_handler,
|
|
1892
|
+
blur_handler_1,
|
|
1845
1893
|
keydown_handler,
|
|
1846
1894
|
keydown_handler_1,
|
|
1847
1895
|
click_handler_1,
|
|
1896
|
+
mouseenter_handler,
|
|
1848
1897
|
div_binding
|
|
1849
1898
|
];
|
|
1850
1899
|
}
|
|
@@ -1862,15 +1911,16 @@
|
|
|
1862
1911
|
{
|
|
1863
1912
|
id: 2,
|
|
1864
1913
|
value: 0,
|
|
1865
|
-
data:
|
|
1866
|
-
extract:
|
|
1867
|
-
disable:
|
|
1868
|
-
filter:
|
|
1869
|
-
autoselect:
|
|
1870
|
-
inputAfterSelect:
|
|
1914
|
+
data: 15,
|
|
1915
|
+
extract: 16,
|
|
1916
|
+
disable: 17,
|
|
1917
|
+
filter: 18,
|
|
1918
|
+
autoselect: 19,
|
|
1919
|
+
inputAfterSelect: 20,
|
|
1871
1920
|
results: 1,
|
|
1872
|
-
focusAfterSelect:
|
|
1873
|
-
|
|
1921
|
+
focusAfterSelect: 21,
|
|
1922
|
+
showDropdownOnFocus: 22,
|
|
1923
|
+
limit: 23
|
|
1874
1924
|
},
|
|
1875
1925
|
add_css,
|
|
1876
1926
|
[-1, -1]
|