svelte-typeahead 4.3.1 → 4.4.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 +56 -42
- package/lib/index.js +166 -115
- package/lib/index.mjs +166 -115
- package/package.json +3 -5
- package/src/Typeahead.svelte +25 -5
- package/types/Typeahead.svelte.d.ts +7 -1
package/lib/index.js
CHANGED
|
@@ -120,6 +120,7 @@
|
|
|
120
120
|
}
|
|
121
121
|
function append_stylesheet(node, style) {
|
|
122
122
|
append(node.head || node, style);
|
|
123
|
+
return style.sheet;
|
|
123
124
|
}
|
|
124
125
|
function insert(target, node, anchor) {
|
|
125
126
|
target.insertBefore(node, anchor || null);
|
|
@@ -253,12 +254,38 @@
|
|
|
253
254
|
throw new Error('Function called outside component initialization');
|
|
254
255
|
return current_component;
|
|
255
256
|
}
|
|
257
|
+
/**
|
|
258
|
+
* The `onMount` function schedules a callback to run as soon as the component has been mounted to the DOM.
|
|
259
|
+
* It must be called during the component's initialisation (but doesn't need to live *inside* the component;
|
|
260
|
+
* it can be called from an external module).
|
|
261
|
+
*
|
|
262
|
+
* `onMount` does not run inside a [server-side component](/docs#run-time-server-side-component-api).
|
|
263
|
+
*
|
|
264
|
+
* https://svelte.dev/docs#run-time-svelte-onmount
|
|
265
|
+
*/
|
|
256
266
|
function onMount(fn) {
|
|
257
267
|
get_current_component().$$.on_mount.push(fn);
|
|
258
268
|
}
|
|
269
|
+
/**
|
|
270
|
+
* Schedules a callback to run immediately after the component has been updated.
|
|
271
|
+
*
|
|
272
|
+
* The first time the callback runs will be after the initial `onMount`
|
|
273
|
+
*/
|
|
259
274
|
function afterUpdate(fn) {
|
|
260
275
|
get_current_component().$$.after_update.push(fn);
|
|
261
276
|
}
|
|
277
|
+
/**
|
|
278
|
+
* Creates an event dispatcher that can be used to dispatch [component events](/docs#template-syntax-component-directives-on-eventname).
|
|
279
|
+
* Event dispatchers are functions that can take two arguments: `name` and `detail`.
|
|
280
|
+
*
|
|
281
|
+
* Component events created with `createEventDispatcher` create a
|
|
282
|
+
* [CustomEvent](https://developer.mozilla.org/en-US/docs/Web/API/CustomEvent).
|
|
283
|
+
* These events do not [bubble](https://developer.mozilla.org/en-US/docs/Learn/JavaScript/Building_blocks/Events#Event_bubbling_and_capture).
|
|
284
|
+
* The `detail` argument corresponds to the [CustomEvent.detail](https://developer.mozilla.org/en-US/docs/Web/API/CustomEvent/detail)
|
|
285
|
+
* property and can contain any type of data.
|
|
286
|
+
*
|
|
287
|
+
* https://svelte.dev/docs#run-time-svelte-createeventdispatcher
|
|
288
|
+
*/
|
|
262
289
|
function createEventDispatcher() {
|
|
263
290
|
const component = get_current_component();
|
|
264
291
|
return (type, detail, { cancelable = false } = {}) => {
|
|
@@ -463,14 +490,17 @@
|
|
|
463
490
|
block && block.c();
|
|
464
491
|
}
|
|
465
492
|
function mount_component(component, target, anchor, customElement) {
|
|
466
|
-
const { fragment,
|
|
493
|
+
const { fragment, after_update } = component.$$;
|
|
467
494
|
fragment && fragment.m(target, anchor);
|
|
468
495
|
if (!customElement) {
|
|
469
496
|
// onMount happens before the initial afterUpdate
|
|
470
497
|
add_render_callback(() => {
|
|
471
|
-
const new_on_destroy = on_mount.map(run).filter(is_function);
|
|
472
|
-
if
|
|
473
|
-
|
|
498
|
+
const new_on_destroy = component.$$.on_mount.map(run).filter(is_function);
|
|
499
|
+
// if the component was destroyed immediately
|
|
500
|
+
// it will update the `$$.on_destroy` reference to `null`.
|
|
501
|
+
// the destructured on_destroy may still reference to the old array
|
|
502
|
+
if (component.$$.on_destroy) {
|
|
503
|
+
component.$$.on_destroy.push(...new_on_destroy);
|
|
474
504
|
}
|
|
475
505
|
else {
|
|
476
506
|
// Edge case - component was destroyed immediately,
|
|
@@ -506,7 +536,7 @@
|
|
|
506
536
|
set_current_component(component);
|
|
507
537
|
const $$ = component.$$ = {
|
|
508
538
|
fragment: null,
|
|
509
|
-
ctx:
|
|
539
|
+
ctx: [],
|
|
510
540
|
// state
|
|
511
541
|
props,
|
|
512
542
|
update: noop,
|
|
@@ -571,6 +601,9 @@
|
|
|
571
601
|
this.$destroy = noop;
|
|
572
602
|
}
|
|
573
603
|
$on(type, callback) {
|
|
604
|
+
if (!is_function(callback)) {
|
|
605
|
+
return noop;
|
|
606
|
+
}
|
|
574
607
|
const callbacks = (this.$$.callbacks[type] || (this.$$.callbacks[type] = []));
|
|
575
608
|
callbacks.push(callback);
|
|
576
609
|
return () => {
|
|
@@ -734,7 +767,7 @@
|
|
|
734
767
|
|
|
735
768
|
var fuzzy = fuzzy$1.exports;
|
|
736
769
|
|
|
737
|
-
/* node_modules/svelte-search/src/Search.svelte generated by Svelte v3.
|
|
770
|
+
/* node_modules/svelte-search/src/Search.svelte generated by Svelte v3.52.0 */
|
|
738
771
|
|
|
739
772
|
function add_css$1(target) {
|
|
740
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}");
|
|
@@ -871,7 +904,7 @@
|
|
|
871
904
|
attr(label_1, "for", /*id*/ ctx[4]);
|
|
872
905
|
}
|
|
873
906
|
|
|
874
|
-
if (dirty & /*hideLabel*/ 8) {
|
|
907
|
+
if (!current || dirty & /*hideLabel*/ 8) {
|
|
875
908
|
toggle_class(label_1, "hide-label", /*hideLabel*/ ctx[3]);
|
|
876
909
|
}
|
|
877
910
|
|
|
@@ -1071,10 +1104,10 @@
|
|
|
1071
1104
|
|
|
1072
1105
|
var Search$1 = Search;
|
|
1073
1106
|
|
|
1074
|
-
/* src/Typeahead.svelte generated by Svelte v3.
|
|
1107
|
+
/* src/Typeahead.svelte generated by Svelte v3.52.0 */
|
|
1075
1108
|
|
|
1076
1109
|
function add_css(target) {
|
|
1077
|
-
append_styles(target, "svelte-
|
|
1110
|
+
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}");
|
|
1078
1111
|
}
|
|
1079
1112
|
|
|
1080
1113
|
const get_no_results_slot_changes = dirty => ({
|
|
@@ -1106,7 +1139,7 @@
|
|
|
1106
1139
|
value: /*value*/ ctx[0]
|
|
1107
1140
|
});
|
|
1108
1141
|
|
|
1109
|
-
// (
|
|
1142
|
+
// (248:4) {#if showResults}
|
|
1110
1143
|
function create_if_block_1(ctx) {
|
|
1111
1144
|
let each_1_anchor;
|
|
1112
1145
|
let current;
|
|
@@ -1138,7 +1171,7 @@
|
|
|
1138
1171
|
current = true;
|
|
1139
1172
|
},
|
|
1140
1173
|
p(ctx, dirty) {
|
|
1141
|
-
if (dirty[0] & /*id, selectedIndex, results, select, $$scope, value*/
|
|
1174
|
+
if (dirty[0] & /*id, selectedIndex, results, select, $$scope, value*/ 67111943) {
|
|
1142
1175
|
each_value = /*results*/ ctx[1];
|
|
1143
1176
|
let i;
|
|
1144
1177
|
|
|
@@ -1190,7 +1223,7 @@
|
|
|
1190
1223
|
};
|
|
1191
1224
|
}
|
|
1192
1225
|
|
|
1193
|
-
// (
|
|
1226
|
+
// (267:41)
|
|
1194
1227
|
function fallback_block(ctx) {
|
|
1195
1228
|
let html_tag;
|
|
1196
1229
|
let raw_value = /*result*/ ctx[47].string + "";
|
|
@@ -1216,7 +1249,7 @@
|
|
|
1216
1249
|
};
|
|
1217
1250
|
}
|
|
1218
1251
|
|
|
1219
|
-
// (
|
|
1252
|
+
// (249:6) {#each results as result, index}
|
|
1220
1253
|
function create_each_block(ctx) {
|
|
1221
1254
|
let li;
|
|
1222
1255
|
let t;
|
|
@@ -1225,8 +1258,8 @@
|
|
|
1225
1258
|
let current;
|
|
1226
1259
|
let mounted;
|
|
1227
1260
|
let dispose;
|
|
1228
|
-
const default_slot_template = /*#slots*/ ctx[
|
|
1229
|
-
const default_slot = create_slot(default_slot_template, ctx, /*$$scope*/ ctx[
|
|
1261
|
+
const default_slot_template = /*#slots*/ ctx[27].default;
|
|
1262
|
+
const default_slot = create_slot(default_slot_template, ctx, /*$$scope*/ ctx[26], get_default_slot_context);
|
|
1230
1263
|
const default_slot_or_fallback = default_slot || fallback_block(ctx);
|
|
1231
1264
|
|
|
1232
1265
|
function click_handler_1() {
|
|
@@ -1244,9 +1277,9 @@
|
|
|
1244
1277
|
t = space();
|
|
1245
1278
|
attr(li, "role", "option");
|
|
1246
1279
|
attr(li, "id", li_id_value = "" + (/*id*/ ctx[2] + "-result-" + /*index*/ ctx[49]));
|
|
1247
|
-
attr(li, "aria-selected", li_aria_selected_value = /*selectedIndex*/ ctx[
|
|
1248
|
-
attr(li, "class", "svelte-
|
|
1249
|
-
toggle_class(li, "selected", /*selectedIndex*/ ctx[
|
|
1280
|
+
attr(li, "aria-selected", li_aria_selected_value = /*selectedIndex*/ ctx[10] === /*index*/ ctx[49]);
|
|
1281
|
+
attr(li, "class", "svelte-1t4elht");
|
|
1282
|
+
toggle_class(li, "selected", /*selectedIndex*/ ctx[10] === /*index*/ ctx[49]);
|
|
1250
1283
|
toggle_class(li, "disabled", /*result*/ ctx[47].disabled);
|
|
1251
1284
|
},
|
|
1252
1285
|
m(target, anchor) {
|
|
@@ -1272,15 +1305,15 @@
|
|
|
1272
1305
|
ctx = new_ctx;
|
|
1273
1306
|
|
|
1274
1307
|
if (default_slot) {
|
|
1275
|
-
if (default_slot.p && (!current || dirty[0] & /*$$scope, results, value*/
|
|
1308
|
+
if (default_slot.p && (!current || dirty[0] & /*$$scope, results, value*/ 67108867)) {
|
|
1276
1309
|
update_slot_base(
|
|
1277
1310
|
default_slot,
|
|
1278
1311
|
default_slot_template,
|
|
1279
1312
|
ctx,
|
|
1280
|
-
/*$$scope*/ ctx[
|
|
1313
|
+
/*$$scope*/ ctx[26],
|
|
1281
1314
|
!current
|
|
1282
|
-
? get_all_dirty_from_scope(/*$$scope*/ ctx[
|
|
1283
|
-
: get_slot_changes(default_slot_template, /*$$scope*/ ctx[
|
|
1315
|
+
? get_all_dirty_from_scope(/*$$scope*/ ctx[26])
|
|
1316
|
+
: get_slot_changes(default_slot_template, /*$$scope*/ ctx[26], dirty, get_default_slot_changes),
|
|
1284
1317
|
get_default_slot_context
|
|
1285
1318
|
);
|
|
1286
1319
|
}
|
|
@@ -1294,15 +1327,15 @@
|
|
|
1294
1327
|
attr(li, "id", li_id_value);
|
|
1295
1328
|
}
|
|
1296
1329
|
|
|
1297
|
-
if (!current || dirty[0] & /*selectedIndex*/
|
|
1330
|
+
if (!current || dirty[0] & /*selectedIndex*/ 1024 && li_aria_selected_value !== (li_aria_selected_value = /*selectedIndex*/ ctx[10] === /*index*/ ctx[49])) {
|
|
1298
1331
|
attr(li, "aria-selected", li_aria_selected_value);
|
|
1299
1332
|
}
|
|
1300
1333
|
|
|
1301
|
-
if (dirty[0] & /*selectedIndex*/
|
|
1302
|
-
toggle_class(li, "selected", /*selectedIndex*/ ctx[
|
|
1334
|
+
if (!current || dirty[0] & /*selectedIndex*/ 1024) {
|
|
1335
|
+
toggle_class(li, "selected", /*selectedIndex*/ ctx[10] === /*index*/ ctx[49]);
|
|
1303
1336
|
}
|
|
1304
1337
|
|
|
1305
|
-
if (dirty[0] & /*results*/ 2) {
|
|
1338
|
+
if (!current || dirty[0] & /*results*/ 2) {
|
|
1306
1339
|
toggle_class(li, "disabled", /*result*/ ctx[47].disabled);
|
|
1307
1340
|
}
|
|
1308
1341
|
},
|
|
@@ -1324,18 +1357,18 @@
|
|
|
1324
1357
|
};
|
|
1325
1358
|
}
|
|
1326
1359
|
|
|
1327
|
-
// (
|
|
1360
|
+
// (273:4) {#if $$slots["no-results"] && !hideDropdown && value.length > 0 && results.length === 0}
|
|
1328
1361
|
function create_if_block(ctx) {
|
|
1329
1362
|
let div;
|
|
1330
1363
|
let current;
|
|
1331
|
-
const no_results_slot_template = /*#slots*/ ctx[
|
|
1332
|
-
const no_results_slot = create_slot(no_results_slot_template, ctx, /*$$scope*/ ctx[
|
|
1364
|
+
const no_results_slot_template = /*#slots*/ ctx[27]["no-results"];
|
|
1365
|
+
const no_results_slot = create_slot(no_results_slot_template, ctx, /*$$scope*/ ctx[26], get_no_results_slot_context);
|
|
1333
1366
|
|
|
1334
1367
|
return {
|
|
1335
1368
|
c() {
|
|
1336
1369
|
div = element("div");
|
|
1337
1370
|
if (no_results_slot) no_results_slot.c();
|
|
1338
|
-
attr(div, "class", "svelte-
|
|
1371
|
+
attr(div, "class", "svelte-1t4elht");
|
|
1339
1372
|
toggle_class(div, "no-results", true);
|
|
1340
1373
|
},
|
|
1341
1374
|
m(target, anchor) {
|
|
@@ -1349,15 +1382,15 @@
|
|
|
1349
1382
|
},
|
|
1350
1383
|
p(ctx, dirty) {
|
|
1351
1384
|
if (no_results_slot) {
|
|
1352
|
-
if (no_results_slot.p && (!current || dirty[0] & /*$$scope, value, results*/
|
|
1385
|
+
if (no_results_slot.p && (!current || dirty[0] & /*$$scope, value, results*/ 67108867)) {
|
|
1353
1386
|
update_slot_base(
|
|
1354
1387
|
no_results_slot,
|
|
1355
1388
|
no_results_slot_template,
|
|
1356
1389
|
ctx,
|
|
1357
|
-
/*$$scope*/ ctx[
|
|
1390
|
+
/*$$scope*/ ctx[26],
|
|
1358
1391
|
!current
|
|
1359
|
-
? get_all_dirty_from_scope(/*$$scope*/ ctx[
|
|
1360
|
-
: get_slot_changes(no_results_slot_template, /*$$scope*/ ctx[
|
|
1392
|
+
? get_all_dirty_from_scope(/*$$scope*/ ctx[26])
|
|
1393
|
+
: get_slot_changes(no_results_slot_template, /*$$scope*/ ctx[26], dirty, get_no_results_slot_changes),
|
|
1361
1394
|
get_no_results_slot_context
|
|
1362
1395
|
);
|
|
1363
1396
|
}
|
|
@@ -1398,7 +1431,7 @@
|
|
|
1398
1431
|
const search_spread_levels = [
|
|
1399
1432
|
{ id: /*id*/ ctx[2] },
|
|
1400
1433
|
{ removeFormAriaAttributes: true },
|
|
1401
|
-
/*$$restProps*/ ctx[
|
|
1434
|
+
/*$$restProps*/ ctx[16],
|
|
1402
1435
|
{ "aria-autocomplete": "list" },
|
|
1403
1436
|
{
|
|
1404
1437
|
"aria-controls": "" + (/*id*/ ctx[2] + "-listbox")
|
|
@@ -1407,18 +1440,18 @@
|
|
|
1407
1440
|
"aria-labelledby": "" + (/*id*/ ctx[2] + "-label")
|
|
1408
1441
|
},
|
|
1409
1442
|
{
|
|
1410
|
-
"aria-activedescendant": /*selectedIndex*/ ctx[
|
|
1411
|
-
? `${/*id*/ ctx[2]}-result-${/*selectedIndex*/ ctx[
|
|
1443
|
+
"aria-activedescendant": /*selectedIndex*/ ctx[10] >= 0 && !/*hideDropdown*/ ctx[5] && /*results*/ ctx[1].length > 0
|
|
1444
|
+
? `${/*id*/ ctx[2]}-result-${/*selectedIndex*/ ctx[10]}`
|
|
1412
1445
|
: null
|
|
1413
1446
|
}
|
|
1414
1447
|
];
|
|
1415
1448
|
|
|
1416
1449
|
function search_ref_binding(value) {
|
|
1417
|
-
/*search_ref_binding*/ ctx[
|
|
1450
|
+
/*search_ref_binding*/ ctx[29](value);
|
|
1418
1451
|
}
|
|
1419
1452
|
|
|
1420
1453
|
function search_value_binding(value) {
|
|
1421
|
-
/*search_value_binding*/ ctx[
|
|
1454
|
+
/*search_value_binding*/ ctx[30](value);
|
|
1422
1455
|
}
|
|
1423
1456
|
|
|
1424
1457
|
let search_props = {};
|
|
@@ -1427,8 +1460,8 @@
|
|
|
1427
1460
|
search_props = assign(search_props, search_spread_levels[i]);
|
|
1428
1461
|
}
|
|
1429
1462
|
|
|
1430
|
-
if (/*searchRef*/ ctx[
|
|
1431
|
-
search_props.ref = /*searchRef*/ ctx[
|
|
1463
|
+
if (/*searchRef*/ ctx[9] !== void 0) {
|
|
1464
|
+
search_props.ref = /*searchRef*/ ctx[9];
|
|
1432
1465
|
}
|
|
1433
1466
|
|
|
1434
1467
|
if (/*value*/ ctx[0] !== void 0) {
|
|
@@ -1438,19 +1471,18 @@
|
|
|
1438
1471
|
search = new Search$1({ props: search_props });
|
|
1439
1472
|
binding_callbacks.push(() => bind(search, 'ref', search_ref_binding));
|
|
1440
1473
|
binding_callbacks.push(() => bind(search, 'value', search_value_binding));
|
|
1441
|
-
search.$on("type", /*type_handler*/ ctx[
|
|
1442
|
-
search.$on("input", /*input_handler*/ ctx[
|
|
1443
|
-
search.$on("change", /*change_handler*/ ctx[
|
|
1444
|
-
search.$on("focus", /*focus_handler*/ ctx[
|
|
1445
|
-
search.$on("focus", /*focus_handler_1*/ ctx[
|
|
1446
|
-
search.$on("clear", /*clear_handler*/ ctx[
|
|
1447
|
-
search.$on("clear", /*open*/ ctx[
|
|
1448
|
-
search.$on("blur", /*blur_handler*/ ctx[
|
|
1449
|
-
search.$on("blur", /*blur_handler_1*/ ctx[37]);
|
|
1474
|
+
search.$on("type", /*type_handler*/ ctx[31]);
|
|
1475
|
+
search.$on("input", /*input_handler*/ ctx[32]);
|
|
1476
|
+
search.$on("change", /*change_handler*/ ctx[33]);
|
|
1477
|
+
search.$on("focus", /*focus_handler*/ ctx[34]);
|
|
1478
|
+
search.$on("focus", /*focus_handler_1*/ ctx[35]);
|
|
1479
|
+
search.$on("clear", /*clear_handler*/ ctx[36]);
|
|
1480
|
+
search.$on("clear", /*open*/ ctx[13]);
|
|
1481
|
+
search.$on("blur", /*blur_handler*/ ctx[37]);
|
|
1450
1482
|
search.$on("keydown", /*keydown_handler*/ ctx[38]);
|
|
1451
1483
|
search.$on("keydown", /*keydown_handler_1*/ ctx[39]);
|
|
1452
|
-
let if_block0 = /*showResults*/ ctx[
|
|
1453
|
-
let if_block1 = /*$$slots*/ ctx[
|
|
1484
|
+
let if_block0 = /*showResults*/ ctx[7] && create_if_block_1(ctx);
|
|
1485
|
+
let if_block1 = /*$$slots*/ ctx[15]["no-results"] && !/*hideDropdown*/ ctx[5] && /*value*/ ctx[0].length > 0 && /*results*/ ctx[1].length === 0 && create_if_block(ctx);
|
|
1454
1486
|
|
|
1455
1487
|
return {
|
|
1456
1488
|
c() {
|
|
@@ -1464,15 +1496,15 @@
|
|
|
1464
1496
|
attr(ul, "role", "listbox");
|
|
1465
1497
|
attr(ul, "aria-labelledby", ul_aria_labelledby_value = "" + (/*id*/ ctx[2] + "-label"));
|
|
1466
1498
|
attr(ul, "id", ul_id_value = "" + (/*id*/ ctx[2] + "-listbox"));
|
|
1467
|
-
attr(ul, "class", "svelte-
|
|
1499
|
+
attr(ul, "class", "svelte-1t4elht");
|
|
1468
1500
|
toggle_class(ul, "svelte-typeahead-list", true);
|
|
1469
1501
|
attr(div, "data-svelte-typeahead", "");
|
|
1470
1502
|
attr(div, "role", "combobox");
|
|
1471
1503
|
attr(div, "aria-haspopup", "listbox");
|
|
1472
1504
|
attr(div, "aria-owns", div_aria_owns_value = "" + (/*id*/ ctx[2] + "-listbox"));
|
|
1473
|
-
attr(div, "aria-expanded", /*showResults*/ ctx[
|
|
1505
|
+
attr(div, "aria-expanded", /*showResults*/ ctx[7]);
|
|
1474
1506
|
attr(div, "id", div_id_value = "" + (/*id*/ ctx[2] + "-typeahead"));
|
|
1475
|
-
attr(div, "class", "svelte-
|
|
1507
|
+
attr(div, "class", "svelte-1t4elht");
|
|
1476
1508
|
toggle_class(div, "dropdown", /*results*/ ctx[1].length > 0);
|
|
1477
1509
|
},
|
|
1478
1510
|
m(target, anchor) {
|
|
@@ -1487,16 +1519,16 @@
|
|
|
1487
1519
|
current = true;
|
|
1488
1520
|
|
|
1489
1521
|
if (!mounted) {
|
|
1490
|
-
dispose = listen(window, "click", /*click_handler*/ ctx[
|
|
1522
|
+
dispose = listen(window, "click", /*click_handler*/ ctx[28]);
|
|
1491
1523
|
mounted = true;
|
|
1492
1524
|
}
|
|
1493
1525
|
},
|
|
1494
1526
|
p(ctx, dirty) {
|
|
1495
|
-
const search_changes = (dirty[0] & /*id, $$restProps, selectedIndex, hideDropdown, results*/
|
|
1527
|
+
const search_changes = (dirty[0] & /*id, $$restProps, selectedIndex, hideDropdown, results*/ 66598)
|
|
1496
1528
|
? get_spread_update(search_spread_levels, [
|
|
1497
1529
|
dirty[0] & /*id*/ 4 && { id: /*id*/ ctx[2] },
|
|
1498
1530
|
search_spread_levels[1],
|
|
1499
|
-
dirty[0] & /*$$restProps*/
|
|
1531
|
+
dirty[0] & /*$$restProps*/ 65536 && get_spread_object(/*$$restProps*/ ctx[16]),
|
|
1500
1532
|
search_spread_levels[3],
|
|
1501
1533
|
dirty[0] & /*id*/ 4 && {
|
|
1502
1534
|
"aria-controls": "" + (/*id*/ ctx[2] + "-listbox")
|
|
@@ -1504,17 +1536,17 @@
|
|
|
1504
1536
|
dirty[0] & /*id*/ 4 && {
|
|
1505
1537
|
"aria-labelledby": "" + (/*id*/ ctx[2] + "-label")
|
|
1506
1538
|
},
|
|
1507
|
-
dirty[0] & /*selectedIndex, hideDropdown, results, id*/
|
|
1508
|
-
"aria-activedescendant": /*selectedIndex*/ ctx[
|
|
1509
|
-
? `${/*id*/ ctx[2]}-result-${/*selectedIndex*/ ctx[
|
|
1539
|
+
dirty[0] & /*selectedIndex, hideDropdown, results, id*/ 1062 && {
|
|
1540
|
+
"aria-activedescendant": /*selectedIndex*/ ctx[10] >= 0 && !/*hideDropdown*/ ctx[5] && /*results*/ ctx[1].length > 0
|
|
1541
|
+
? `${/*id*/ ctx[2]}-result-${/*selectedIndex*/ ctx[10]}`
|
|
1510
1542
|
: null
|
|
1511
1543
|
}
|
|
1512
1544
|
])
|
|
1513
1545
|
: {};
|
|
1514
1546
|
|
|
1515
|
-
if (!updating_ref && dirty[0] & /*searchRef*/
|
|
1547
|
+
if (!updating_ref && dirty[0] & /*searchRef*/ 512) {
|
|
1516
1548
|
updating_ref = true;
|
|
1517
|
-
search_changes.ref = /*searchRef*/ ctx[
|
|
1549
|
+
search_changes.ref = /*searchRef*/ ctx[9];
|
|
1518
1550
|
add_flush_callback(() => updating_ref = false);
|
|
1519
1551
|
}
|
|
1520
1552
|
|
|
@@ -1526,11 +1558,11 @@
|
|
|
1526
1558
|
|
|
1527
1559
|
search.$set(search_changes);
|
|
1528
1560
|
|
|
1529
|
-
if (/*showResults*/ ctx[
|
|
1561
|
+
if (/*showResults*/ ctx[7]) {
|
|
1530
1562
|
if (if_block0) {
|
|
1531
1563
|
if_block0.p(ctx, dirty);
|
|
1532
1564
|
|
|
1533
|
-
if (dirty[0] & /*showResults*/
|
|
1565
|
+
if (dirty[0] & /*showResults*/ 128) {
|
|
1534
1566
|
transition_in(if_block0, 1);
|
|
1535
1567
|
}
|
|
1536
1568
|
} else {
|
|
@@ -1549,11 +1581,11 @@
|
|
|
1549
1581
|
check_outros();
|
|
1550
1582
|
}
|
|
1551
1583
|
|
|
1552
|
-
if (/*$$slots*/ ctx[
|
|
1584
|
+
if (/*$$slots*/ ctx[15]["no-results"] && !/*hideDropdown*/ ctx[5] && /*value*/ ctx[0].length > 0 && /*results*/ ctx[1].length === 0) {
|
|
1553
1585
|
if (if_block1) {
|
|
1554
1586
|
if_block1.p(ctx, dirty);
|
|
1555
1587
|
|
|
1556
|
-
if (dirty[0] & /*$$slots, hideDropdown, value, results*/
|
|
1588
|
+
if (dirty[0] & /*$$slots, hideDropdown, value, results*/ 32803) {
|
|
1557
1589
|
transition_in(if_block1, 1);
|
|
1558
1590
|
}
|
|
1559
1591
|
} else {
|
|
@@ -1584,15 +1616,15 @@
|
|
|
1584
1616
|
attr(div, "aria-owns", div_aria_owns_value);
|
|
1585
1617
|
}
|
|
1586
1618
|
|
|
1587
|
-
if (!current || dirty[0] & /*showResults*/
|
|
1588
|
-
attr(div, "aria-expanded", /*showResults*/ ctx[
|
|
1619
|
+
if (!current || dirty[0] & /*showResults*/ 128) {
|
|
1620
|
+
attr(div, "aria-expanded", /*showResults*/ ctx[7]);
|
|
1589
1621
|
}
|
|
1590
1622
|
|
|
1591
1623
|
if (!current || dirty[0] & /*id*/ 4 && div_id_value !== (div_id_value = "" + (/*id*/ ctx[2] + "-typeahead"))) {
|
|
1592
1624
|
attr(div, "id", div_id_value);
|
|
1593
1625
|
}
|
|
1594
1626
|
|
|
1595
|
-
if (dirty[0] & /*results*/ 2) {
|
|
1627
|
+
if (!current || dirty[0] & /*results*/ 2) {
|
|
1596
1628
|
toggle_class(div, "dropdown", /*results*/ ctx[1].length > 0);
|
|
1597
1629
|
}
|
|
1598
1630
|
},
|
|
@@ -1627,7 +1659,7 @@
|
|
|
1627
1659
|
let showResults;
|
|
1628
1660
|
|
|
1629
1661
|
const omit_props_names = [
|
|
1630
|
-
"id","value","data","extract","disable","filter","autoselect","inputAfterSelect","results","focusAfterSelect","showDropdownOnFocus","limit"
|
|
1662
|
+
"id","value","data","extract","disable","filter","autoselect","inputAfterSelect","results","focusAfterSelect","showDropdownOnFocus","showAllResultsOnFocus","limit"
|
|
1631
1663
|
];
|
|
1632
1664
|
|
|
1633
1665
|
let $$restProps = compute_rest_props($$props, omit_props_names);
|
|
@@ -1644,6 +1676,7 @@
|
|
|
1644
1676
|
let { results = [] } = $$props;
|
|
1645
1677
|
let { focusAfterSelect = false } = $$props;
|
|
1646
1678
|
let { showDropdownOnFocus = false } = $$props;
|
|
1679
|
+
let { showAllResultsOnFocus = false } = $$props;
|
|
1647
1680
|
let { limit = Infinity } = $$props;
|
|
1648
1681
|
const dispatch = createEventDispatcher();
|
|
1649
1682
|
let comboboxRef = null;
|
|
@@ -1655,11 +1688,11 @@
|
|
|
1655
1688
|
|
|
1656
1689
|
afterUpdate(() => {
|
|
1657
1690
|
if (prevResults !== resultsId && autoselect) {
|
|
1658
|
-
$$invalidate(
|
|
1691
|
+
$$invalidate(10, selectedIndex = getNextNonDisabledIndex());
|
|
1659
1692
|
}
|
|
1660
1693
|
|
|
1661
1694
|
if (prevResults !== resultsId && !$$slots["no-results"]) {
|
|
1662
|
-
$$invalidate(
|
|
1695
|
+
$$invalidate(5, hideDropdown = results.length === 0);
|
|
1663
1696
|
}
|
|
1664
1697
|
|
|
1665
1698
|
prevResults = resultsId;
|
|
@@ -1723,11 +1756,15 @@
|
|
|
1723
1756
|
disabled = results[index].disabled;
|
|
1724
1757
|
}
|
|
1725
1758
|
|
|
1726
|
-
$$invalidate(
|
|
1759
|
+
$$invalidate(10, selectedIndex = index);
|
|
1727
1760
|
}
|
|
1728
1761
|
|
|
1729
|
-
const open = () => $$invalidate(
|
|
1730
|
-
|
|
1762
|
+
const open = () => $$invalidate(5, hideDropdown = false);
|
|
1763
|
+
|
|
1764
|
+
const close = () => {
|
|
1765
|
+
$$invalidate(5, hideDropdown = true);
|
|
1766
|
+
$$invalidate(6, isFocused = false);
|
|
1767
|
+
};
|
|
1731
1768
|
|
|
1732
1769
|
const click_handler = ({ target }) => {
|
|
1733
1770
|
if (!hideDropdown && !comboboxRef?.contains(target)) {
|
|
@@ -1737,7 +1774,7 @@
|
|
|
1737
1774
|
|
|
1738
1775
|
function search_ref_binding(value) {
|
|
1739
1776
|
searchRef = value;
|
|
1740
|
-
$$invalidate(
|
|
1777
|
+
$$invalidate(9, searchRef);
|
|
1741
1778
|
}
|
|
1742
1779
|
|
|
1743
1780
|
function search_value_binding(value$1) {
|
|
@@ -1763,7 +1800,11 @@
|
|
|
1763
1800
|
|
|
1764
1801
|
const focus_handler_1 = () => {
|
|
1765
1802
|
open();
|
|
1766
|
-
|
|
1803
|
+
|
|
1804
|
+
if (showDropdownOnFocus || showAllResultsOnFocus) {
|
|
1805
|
+
$$invalidate(7, showResults = true);
|
|
1806
|
+
$$invalidate(6, isFocused = true);
|
|
1807
|
+
}
|
|
1767
1808
|
};
|
|
1768
1809
|
|
|
1769
1810
|
function clear_handler(event) {
|
|
@@ -1774,10 +1815,6 @@
|
|
|
1774
1815
|
bubble.call(this, $$self, event);
|
|
1775
1816
|
}
|
|
1776
1817
|
|
|
1777
|
-
const blur_handler_1 = () => {
|
|
1778
|
-
$$invalidate(4, isFocused = false);
|
|
1779
|
-
};
|
|
1780
|
-
|
|
1781
1818
|
function keydown_handler(event) {
|
|
1782
1819
|
bubble.call(this, $$self, event);
|
|
1783
1820
|
}
|
|
@@ -1808,63 +1845,76 @@
|
|
|
1808
1845
|
|
|
1809
1846
|
const click_handler_1 = (result, index) => {
|
|
1810
1847
|
if (result.disabled) return;
|
|
1811
|
-
$$invalidate(
|
|
1848
|
+
$$invalidate(10, selectedIndex = index);
|
|
1812
1849
|
select();
|
|
1813
1850
|
};
|
|
1814
1851
|
|
|
1815
1852
|
const mouseenter_handler = (result, index) => {
|
|
1816
1853
|
if (result.disabled) return;
|
|
1817
|
-
$$invalidate(
|
|
1854
|
+
$$invalidate(10, selectedIndex = index);
|
|
1818
1855
|
};
|
|
1819
1856
|
|
|
1820
1857
|
function div_binding($$value) {
|
|
1821
1858
|
binding_callbacks[$$value ? 'unshift' : 'push'](() => {
|
|
1822
1859
|
comboboxRef = $$value;
|
|
1823
|
-
$$invalidate(
|
|
1860
|
+
$$invalidate(8, comboboxRef);
|
|
1824
1861
|
});
|
|
1825
1862
|
}
|
|
1826
1863
|
|
|
1827
1864
|
$$self.$$set = $$new_props => {
|
|
1828
1865
|
$$props = assign(assign({}, $$props), exclude_internal_props($$new_props));
|
|
1829
|
-
$$invalidate(
|
|
1866
|
+
$$invalidate(16, $$restProps = compute_rest_props($$props, omit_props_names));
|
|
1830
1867
|
if ('id' in $$new_props) $$invalidate(2, id = $$new_props.id);
|
|
1831
1868
|
if ('value' in $$new_props) $$invalidate(0, value = $$new_props.value);
|
|
1832
|
-
if ('data' in $$new_props) $$invalidate(
|
|
1833
|
-
if ('extract' in $$new_props) $$invalidate(
|
|
1834
|
-
if ('disable' in $$new_props) $$invalidate(
|
|
1835
|
-
if ('filter' in $$new_props) $$invalidate(
|
|
1836
|
-
if ('autoselect' in $$new_props) $$invalidate(
|
|
1837
|
-
if ('inputAfterSelect' in $$new_props) $$invalidate(
|
|
1869
|
+
if ('data' in $$new_props) $$invalidate(17, data = $$new_props.data);
|
|
1870
|
+
if ('extract' in $$new_props) $$invalidate(18, extract = $$new_props.extract);
|
|
1871
|
+
if ('disable' in $$new_props) $$invalidate(19, disable = $$new_props.disable);
|
|
1872
|
+
if ('filter' in $$new_props) $$invalidate(20, filter = $$new_props.filter);
|
|
1873
|
+
if ('autoselect' in $$new_props) $$invalidate(21, autoselect = $$new_props.autoselect);
|
|
1874
|
+
if ('inputAfterSelect' in $$new_props) $$invalidate(22, inputAfterSelect = $$new_props.inputAfterSelect);
|
|
1838
1875
|
if ('results' in $$new_props) $$invalidate(1, results = $$new_props.results);
|
|
1839
|
-
if ('focusAfterSelect' in $$new_props) $$invalidate(
|
|
1840
|
-
if ('showDropdownOnFocus' in $$new_props) $$invalidate(
|
|
1841
|
-
if ('
|
|
1842
|
-
if ('
|
|
1876
|
+
if ('focusAfterSelect' in $$new_props) $$invalidate(23, focusAfterSelect = $$new_props.focusAfterSelect);
|
|
1877
|
+
if ('showDropdownOnFocus' in $$new_props) $$invalidate(3, showDropdownOnFocus = $$new_props.showDropdownOnFocus);
|
|
1878
|
+
if ('showAllResultsOnFocus' in $$new_props) $$invalidate(4, showAllResultsOnFocus = $$new_props.showAllResultsOnFocus);
|
|
1879
|
+
if ('limit' in $$new_props) $$invalidate(24, limit = $$new_props.limit);
|
|
1880
|
+
if ('$$scope' in $$new_props) $$invalidate(26, $$scope = $$new_props.$$scope);
|
|
1843
1881
|
};
|
|
1844
1882
|
|
|
1845
1883
|
$$self.$$.update = () => {
|
|
1846
|
-
if ($$self.$$.dirty[0] & /*extract*/
|
|
1847
|
-
$$invalidate(
|
|
1884
|
+
if ($$self.$$.dirty[0] & /*extract*/ 262144) {
|
|
1885
|
+
$$invalidate(25, options = { pre: "<mark>", post: "</mark>", extract });
|
|
1848
1886
|
}
|
|
1849
1887
|
|
|
1850
|
-
if ($$self.$$.dirty[0] & /*value, data, options, limit, filter, disable*/
|
|
1888
|
+
if ($$self.$$.dirty[0] & /*value, data, options, limit, filter, disable*/ 52035585) {
|
|
1851
1889
|
$$invalidate(1, results = fuzzy.filter(value, data, options).filter(({ score }) => score > 0).slice(0, limit).filter(result => !filter(result.original)).map(result => ({
|
|
1852
1890
|
...result,
|
|
1853
1891
|
disabled: disable(result.original)
|
|
1854
1892
|
})));
|
|
1855
1893
|
}
|
|
1856
1894
|
|
|
1857
|
-
if ($$self.$$.dirty[0] & /*
|
|
1895
|
+
if ($$self.$$.dirty[0] & /*isFocused, showAllResultsOnFocus, value, data, filter, disable, extract*/ 1966161) {
|
|
1896
|
+
if (isFocused && showAllResultsOnFocus && value.length === 0) {
|
|
1897
|
+
$$invalidate(1, results = data.filter(datum => !filter(datum)).map((original, index) => ({
|
|
1898
|
+
disabled: disable(original),
|
|
1899
|
+
index,
|
|
1900
|
+
original,
|
|
1901
|
+
score: 0,
|
|
1902
|
+
string: extract(original)
|
|
1903
|
+
})));
|
|
1904
|
+
}
|
|
1905
|
+
}
|
|
1906
|
+
|
|
1907
|
+
if ($$self.$$.dirty[0] & /*results, extract*/ 262146) {
|
|
1858
1908
|
resultsId = results.map(result => extract(result.original)).join("");
|
|
1859
1909
|
}
|
|
1860
1910
|
|
|
1861
|
-
if ($$self.$$.dirty[0] & /*hideDropdown, results*/
|
|
1862
|
-
$$invalidate(
|
|
1911
|
+
if ($$self.$$.dirty[0] & /*hideDropdown, results*/ 34) {
|
|
1912
|
+
$$invalidate(7, showResults = !hideDropdown && results.length > 0);
|
|
1863
1913
|
}
|
|
1864
1914
|
|
|
1865
|
-
if ($$self.$$.dirty[0] & /*showDropdownOnFocus, showResults, isFocused*/
|
|
1915
|
+
if ($$self.$$.dirty[0] & /*showDropdownOnFocus, showResults, isFocused*/ 200) {
|
|
1866
1916
|
if (showDropdownOnFocus) {
|
|
1867
|
-
$$invalidate(
|
|
1917
|
+
$$invalidate(7, showResults = showResults && isFocused);
|
|
1868
1918
|
}
|
|
1869
1919
|
}
|
|
1870
1920
|
};
|
|
@@ -1873,6 +1923,8 @@
|
|
|
1873
1923
|
value,
|
|
1874
1924
|
results,
|
|
1875
1925
|
id,
|
|
1926
|
+
showDropdownOnFocus,
|
|
1927
|
+
showAllResultsOnFocus,
|
|
1876
1928
|
hideDropdown,
|
|
1877
1929
|
isFocused,
|
|
1878
1930
|
showResults,
|
|
@@ -1892,7 +1944,6 @@
|
|
|
1892
1944
|
autoselect,
|
|
1893
1945
|
inputAfterSelect,
|
|
1894
1946
|
focusAfterSelect,
|
|
1895
|
-
showDropdownOnFocus,
|
|
1896
1947
|
limit,
|
|
1897
1948
|
options,
|
|
1898
1949
|
$$scope,
|
|
@@ -1907,7 +1958,6 @@
|
|
|
1907
1958
|
focus_handler_1,
|
|
1908
1959
|
clear_handler,
|
|
1909
1960
|
blur_handler,
|
|
1910
|
-
blur_handler_1,
|
|
1911
1961
|
keydown_handler,
|
|
1912
1962
|
keydown_handler_1,
|
|
1913
1963
|
click_handler_1,
|
|
@@ -1929,16 +1979,17 @@
|
|
|
1929
1979
|
{
|
|
1930
1980
|
id: 2,
|
|
1931
1981
|
value: 0,
|
|
1932
|
-
data:
|
|
1933
|
-
extract:
|
|
1934
|
-
disable:
|
|
1935
|
-
filter:
|
|
1936
|
-
autoselect:
|
|
1937
|
-
inputAfterSelect:
|
|
1982
|
+
data: 17,
|
|
1983
|
+
extract: 18,
|
|
1984
|
+
disable: 19,
|
|
1985
|
+
filter: 20,
|
|
1986
|
+
autoselect: 21,
|
|
1987
|
+
inputAfterSelect: 22,
|
|
1938
1988
|
results: 1,
|
|
1939
|
-
focusAfterSelect:
|
|
1940
|
-
showDropdownOnFocus:
|
|
1941
|
-
|
|
1989
|
+
focusAfterSelect: 23,
|
|
1990
|
+
showDropdownOnFocus: 3,
|
|
1991
|
+
showAllResultsOnFocus: 4,
|
|
1992
|
+
limit: 24
|
|
1942
1993
|
},
|
|
1943
1994
|
add_css,
|
|
1944
1995
|
[-1, -1]
|