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.mjs
CHANGED
|
@@ -114,6 +114,7 @@ function get_root_for_style(node) {
|
|
|
114
114
|
}
|
|
115
115
|
function append_stylesheet(node, style) {
|
|
116
116
|
append(node.head || node, style);
|
|
117
|
+
return style.sheet;
|
|
117
118
|
}
|
|
118
119
|
function insert(target, node, anchor) {
|
|
119
120
|
target.insertBefore(node, anchor || null);
|
|
@@ -247,12 +248,38 @@ function get_current_component() {
|
|
|
247
248
|
throw new Error('Function called outside component initialization');
|
|
248
249
|
return current_component;
|
|
249
250
|
}
|
|
251
|
+
/**
|
|
252
|
+
* The `onMount` function schedules a callback to run as soon as the component has been mounted to the DOM.
|
|
253
|
+
* It must be called during the component's initialisation (but doesn't need to live *inside* the component;
|
|
254
|
+
* it can be called from an external module).
|
|
255
|
+
*
|
|
256
|
+
* `onMount` does not run inside a [server-side component](/docs#run-time-server-side-component-api).
|
|
257
|
+
*
|
|
258
|
+
* https://svelte.dev/docs#run-time-svelte-onmount
|
|
259
|
+
*/
|
|
250
260
|
function onMount(fn) {
|
|
251
261
|
get_current_component().$$.on_mount.push(fn);
|
|
252
262
|
}
|
|
263
|
+
/**
|
|
264
|
+
* Schedules a callback to run immediately after the component has been updated.
|
|
265
|
+
*
|
|
266
|
+
* The first time the callback runs will be after the initial `onMount`
|
|
267
|
+
*/
|
|
253
268
|
function afterUpdate(fn) {
|
|
254
269
|
get_current_component().$$.after_update.push(fn);
|
|
255
270
|
}
|
|
271
|
+
/**
|
|
272
|
+
* Creates an event dispatcher that can be used to dispatch [component events](/docs#template-syntax-component-directives-on-eventname).
|
|
273
|
+
* Event dispatchers are functions that can take two arguments: `name` and `detail`.
|
|
274
|
+
*
|
|
275
|
+
* Component events created with `createEventDispatcher` create a
|
|
276
|
+
* [CustomEvent](https://developer.mozilla.org/en-US/docs/Web/API/CustomEvent).
|
|
277
|
+
* These events do not [bubble](https://developer.mozilla.org/en-US/docs/Learn/JavaScript/Building_blocks/Events#Event_bubbling_and_capture).
|
|
278
|
+
* The `detail` argument corresponds to the [CustomEvent.detail](https://developer.mozilla.org/en-US/docs/Web/API/CustomEvent/detail)
|
|
279
|
+
* property and can contain any type of data.
|
|
280
|
+
*
|
|
281
|
+
* https://svelte.dev/docs#run-time-svelte-createeventdispatcher
|
|
282
|
+
*/
|
|
256
283
|
function createEventDispatcher() {
|
|
257
284
|
const component = get_current_component();
|
|
258
285
|
return (type, detail, { cancelable = false } = {}) => {
|
|
@@ -457,14 +484,17 @@ function create_component(block) {
|
|
|
457
484
|
block && block.c();
|
|
458
485
|
}
|
|
459
486
|
function mount_component(component, target, anchor, customElement) {
|
|
460
|
-
const { fragment,
|
|
487
|
+
const { fragment, after_update } = component.$$;
|
|
461
488
|
fragment && fragment.m(target, anchor);
|
|
462
489
|
if (!customElement) {
|
|
463
490
|
// onMount happens before the initial afterUpdate
|
|
464
491
|
add_render_callback(() => {
|
|
465
|
-
const new_on_destroy = on_mount.map(run).filter(is_function);
|
|
466
|
-
if
|
|
467
|
-
|
|
492
|
+
const new_on_destroy = component.$$.on_mount.map(run).filter(is_function);
|
|
493
|
+
// if the component was destroyed immediately
|
|
494
|
+
// it will update the `$$.on_destroy` reference to `null`.
|
|
495
|
+
// the destructured on_destroy may still reference to the old array
|
|
496
|
+
if (component.$$.on_destroy) {
|
|
497
|
+
component.$$.on_destroy.push(...new_on_destroy);
|
|
468
498
|
}
|
|
469
499
|
else {
|
|
470
500
|
// Edge case - component was destroyed immediately,
|
|
@@ -500,7 +530,7 @@ function init(component, options, instance, create_fragment, not_equal, props, a
|
|
|
500
530
|
set_current_component(component);
|
|
501
531
|
const $$ = component.$$ = {
|
|
502
532
|
fragment: null,
|
|
503
|
-
ctx:
|
|
533
|
+
ctx: [],
|
|
504
534
|
// state
|
|
505
535
|
props,
|
|
506
536
|
update: noop,
|
|
@@ -565,6 +595,9 @@ class SvelteComponent {
|
|
|
565
595
|
this.$destroy = noop;
|
|
566
596
|
}
|
|
567
597
|
$on(type, callback) {
|
|
598
|
+
if (!is_function(callback)) {
|
|
599
|
+
return noop;
|
|
600
|
+
}
|
|
568
601
|
const callbacks = (this.$$.callbacks[type] || (this.$$.callbacks[type] = []));
|
|
569
602
|
callbacks.push(callback);
|
|
570
603
|
return () => {
|
|
@@ -728,7 +761,7 @@ fuzzy.filter = function(pattern, arr, opts) {
|
|
|
728
761
|
|
|
729
762
|
var fuzzy = fuzzy$1.exports;
|
|
730
763
|
|
|
731
|
-
/* node_modules/svelte-search/src/Search.svelte generated by Svelte v3.
|
|
764
|
+
/* node_modules/svelte-search/src/Search.svelte generated by Svelte v3.52.0 */
|
|
732
765
|
|
|
733
766
|
function add_css$1(target) {
|
|
734
767
|
append_styles(target, "svelte-5m0wg6", ".hide-label.svelte-5m0wg6{position:absolute;height:1px;width:1px;overflow:hidden;clip:rect(1px 1px 1px 1px);clip:rect(1px, 1px, 1px, 1px);white-space:nowrap}");
|
|
@@ -865,7 +898,7 @@ function create_fragment$1(ctx) {
|
|
|
865
898
|
attr(label_1, "for", /*id*/ ctx[4]);
|
|
866
899
|
}
|
|
867
900
|
|
|
868
|
-
if (dirty & /*hideLabel*/ 8) {
|
|
901
|
+
if (!current || dirty & /*hideLabel*/ 8) {
|
|
869
902
|
toggle_class(label_1, "hide-label", /*hideLabel*/ ctx[3]);
|
|
870
903
|
}
|
|
871
904
|
|
|
@@ -1065,10 +1098,10 @@ class Search extends SvelteComponent {
|
|
|
1065
1098
|
|
|
1066
1099
|
var Search$1 = Search;
|
|
1067
1100
|
|
|
1068
|
-
/* src/Typeahead.svelte generated by Svelte v3.
|
|
1101
|
+
/* src/Typeahead.svelte generated by Svelte v3.52.0 */
|
|
1069
1102
|
|
|
1070
1103
|
function add_css(target) {
|
|
1071
|
-
append_styles(target, "svelte-
|
|
1104
|
+
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}");
|
|
1072
1105
|
}
|
|
1073
1106
|
|
|
1074
1107
|
const get_no_results_slot_changes = dirty => ({
|
|
@@ -1100,7 +1133,7 @@ const get_default_slot_context = ctx => ({
|
|
|
1100
1133
|
value: /*value*/ ctx[0]
|
|
1101
1134
|
});
|
|
1102
1135
|
|
|
1103
|
-
// (
|
|
1136
|
+
// (248:4) {#if showResults}
|
|
1104
1137
|
function create_if_block_1(ctx) {
|
|
1105
1138
|
let each_1_anchor;
|
|
1106
1139
|
let current;
|
|
@@ -1132,7 +1165,7 @@ function create_if_block_1(ctx) {
|
|
|
1132
1165
|
current = true;
|
|
1133
1166
|
},
|
|
1134
1167
|
p(ctx, dirty) {
|
|
1135
|
-
if (dirty[0] & /*id, selectedIndex, results, select, $$scope, value*/
|
|
1168
|
+
if (dirty[0] & /*id, selectedIndex, results, select, $$scope, value*/ 67111943) {
|
|
1136
1169
|
each_value = /*results*/ ctx[1];
|
|
1137
1170
|
let i;
|
|
1138
1171
|
|
|
@@ -1184,7 +1217,7 @@ function create_if_block_1(ctx) {
|
|
|
1184
1217
|
};
|
|
1185
1218
|
}
|
|
1186
1219
|
|
|
1187
|
-
// (
|
|
1220
|
+
// (267:41)
|
|
1188
1221
|
function fallback_block(ctx) {
|
|
1189
1222
|
let html_tag;
|
|
1190
1223
|
let raw_value = /*result*/ ctx[47].string + "";
|
|
@@ -1210,7 +1243,7 @@ function fallback_block(ctx) {
|
|
|
1210
1243
|
};
|
|
1211
1244
|
}
|
|
1212
1245
|
|
|
1213
|
-
// (
|
|
1246
|
+
// (249:6) {#each results as result, index}
|
|
1214
1247
|
function create_each_block(ctx) {
|
|
1215
1248
|
let li;
|
|
1216
1249
|
let t;
|
|
@@ -1219,8 +1252,8 @@ function create_each_block(ctx) {
|
|
|
1219
1252
|
let current;
|
|
1220
1253
|
let mounted;
|
|
1221
1254
|
let dispose;
|
|
1222
|
-
const default_slot_template = /*#slots*/ ctx[
|
|
1223
|
-
const default_slot = create_slot(default_slot_template, ctx, /*$$scope*/ ctx[
|
|
1255
|
+
const default_slot_template = /*#slots*/ ctx[27].default;
|
|
1256
|
+
const default_slot = create_slot(default_slot_template, ctx, /*$$scope*/ ctx[26], get_default_slot_context);
|
|
1224
1257
|
const default_slot_or_fallback = default_slot || fallback_block(ctx);
|
|
1225
1258
|
|
|
1226
1259
|
function click_handler_1() {
|
|
@@ -1238,9 +1271,9 @@ function create_each_block(ctx) {
|
|
|
1238
1271
|
t = space();
|
|
1239
1272
|
attr(li, "role", "option");
|
|
1240
1273
|
attr(li, "id", li_id_value = "" + (/*id*/ ctx[2] + "-result-" + /*index*/ ctx[49]));
|
|
1241
|
-
attr(li, "aria-selected", li_aria_selected_value = /*selectedIndex*/ ctx[
|
|
1242
|
-
attr(li, "class", "svelte-
|
|
1243
|
-
toggle_class(li, "selected", /*selectedIndex*/ ctx[
|
|
1274
|
+
attr(li, "aria-selected", li_aria_selected_value = /*selectedIndex*/ ctx[10] === /*index*/ ctx[49]);
|
|
1275
|
+
attr(li, "class", "svelte-1t4elht");
|
|
1276
|
+
toggle_class(li, "selected", /*selectedIndex*/ ctx[10] === /*index*/ ctx[49]);
|
|
1244
1277
|
toggle_class(li, "disabled", /*result*/ ctx[47].disabled);
|
|
1245
1278
|
},
|
|
1246
1279
|
m(target, anchor) {
|
|
@@ -1266,15 +1299,15 @@ function create_each_block(ctx) {
|
|
|
1266
1299
|
ctx = new_ctx;
|
|
1267
1300
|
|
|
1268
1301
|
if (default_slot) {
|
|
1269
|
-
if (default_slot.p && (!current || dirty[0] & /*$$scope, results, value*/
|
|
1302
|
+
if (default_slot.p && (!current || dirty[0] & /*$$scope, results, value*/ 67108867)) {
|
|
1270
1303
|
update_slot_base(
|
|
1271
1304
|
default_slot,
|
|
1272
1305
|
default_slot_template,
|
|
1273
1306
|
ctx,
|
|
1274
|
-
/*$$scope*/ ctx[
|
|
1307
|
+
/*$$scope*/ ctx[26],
|
|
1275
1308
|
!current
|
|
1276
|
-
? get_all_dirty_from_scope(/*$$scope*/ ctx[
|
|
1277
|
-
: get_slot_changes(default_slot_template, /*$$scope*/ ctx[
|
|
1309
|
+
? get_all_dirty_from_scope(/*$$scope*/ ctx[26])
|
|
1310
|
+
: get_slot_changes(default_slot_template, /*$$scope*/ ctx[26], dirty, get_default_slot_changes),
|
|
1278
1311
|
get_default_slot_context
|
|
1279
1312
|
);
|
|
1280
1313
|
}
|
|
@@ -1288,15 +1321,15 @@ function create_each_block(ctx) {
|
|
|
1288
1321
|
attr(li, "id", li_id_value);
|
|
1289
1322
|
}
|
|
1290
1323
|
|
|
1291
|
-
if (!current || dirty[0] & /*selectedIndex*/
|
|
1324
|
+
if (!current || dirty[0] & /*selectedIndex*/ 1024 && li_aria_selected_value !== (li_aria_selected_value = /*selectedIndex*/ ctx[10] === /*index*/ ctx[49])) {
|
|
1292
1325
|
attr(li, "aria-selected", li_aria_selected_value);
|
|
1293
1326
|
}
|
|
1294
1327
|
|
|
1295
|
-
if (dirty[0] & /*selectedIndex*/
|
|
1296
|
-
toggle_class(li, "selected", /*selectedIndex*/ ctx[
|
|
1328
|
+
if (!current || dirty[0] & /*selectedIndex*/ 1024) {
|
|
1329
|
+
toggle_class(li, "selected", /*selectedIndex*/ ctx[10] === /*index*/ ctx[49]);
|
|
1297
1330
|
}
|
|
1298
1331
|
|
|
1299
|
-
if (dirty[0] & /*results*/ 2) {
|
|
1332
|
+
if (!current || dirty[0] & /*results*/ 2) {
|
|
1300
1333
|
toggle_class(li, "disabled", /*result*/ ctx[47].disabled);
|
|
1301
1334
|
}
|
|
1302
1335
|
},
|
|
@@ -1318,18 +1351,18 @@ function create_each_block(ctx) {
|
|
|
1318
1351
|
};
|
|
1319
1352
|
}
|
|
1320
1353
|
|
|
1321
|
-
// (
|
|
1354
|
+
// (273:4) {#if $$slots["no-results"] && !hideDropdown && value.length > 0 && results.length === 0}
|
|
1322
1355
|
function create_if_block(ctx) {
|
|
1323
1356
|
let div;
|
|
1324
1357
|
let current;
|
|
1325
|
-
const no_results_slot_template = /*#slots*/ ctx[
|
|
1326
|
-
const no_results_slot = create_slot(no_results_slot_template, ctx, /*$$scope*/ ctx[
|
|
1358
|
+
const no_results_slot_template = /*#slots*/ ctx[27]["no-results"];
|
|
1359
|
+
const no_results_slot = create_slot(no_results_slot_template, ctx, /*$$scope*/ ctx[26], get_no_results_slot_context);
|
|
1327
1360
|
|
|
1328
1361
|
return {
|
|
1329
1362
|
c() {
|
|
1330
1363
|
div = element("div");
|
|
1331
1364
|
if (no_results_slot) no_results_slot.c();
|
|
1332
|
-
attr(div, "class", "svelte-
|
|
1365
|
+
attr(div, "class", "svelte-1t4elht");
|
|
1333
1366
|
toggle_class(div, "no-results", true);
|
|
1334
1367
|
},
|
|
1335
1368
|
m(target, anchor) {
|
|
@@ -1343,15 +1376,15 @@ function create_if_block(ctx) {
|
|
|
1343
1376
|
},
|
|
1344
1377
|
p(ctx, dirty) {
|
|
1345
1378
|
if (no_results_slot) {
|
|
1346
|
-
if (no_results_slot.p && (!current || dirty[0] & /*$$scope, value, results*/
|
|
1379
|
+
if (no_results_slot.p && (!current || dirty[0] & /*$$scope, value, results*/ 67108867)) {
|
|
1347
1380
|
update_slot_base(
|
|
1348
1381
|
no_results_slot,
|
|
1349
1382
|
no_results_slot_template,
|
|
1350
1383
|
ctx,
|
|
1351
|
-
/*$$scope*/ ctx[
|
|
1384
|
+
/*$$scope*/ ctx[26],
|
|
1352
1385
|
!current
|
|
1353
|
-
? get_all_dirty_from_scope(/*$$scope*/ ctx[
|
|
1354
|
-
: get_slot_changes(no_results_slot_template, /*$$scope*/ ctx[
|
|
1386
|
+
? get_all_dirty_from_scope(/*$$scope*/ ctx[26])
|
|
1387
|
+
: get_slot_changes(no_results_slot_template, /*$$scope*/ ctx[26], dirty, get_no_results_slot_changes),
|
|
1355
1388
|
get_no_results_slot_context
|
|
1356
1389
|
);
|
|
1357
1390
|
}
|
|
@@ -1392,7 +1425,7 @@ function create_fragment(ctx) {
|
|
|
1392
1425
|
const search_spread_levels = [
|
|
1393
1426
|
{ id: /*id*/ ctx[2] },
|
|
1394
1427
|
{ removeFormAriaAttributes: true },
|
|
1395
|
-
/*$$restProps*/ ctx[
|
|
1428
|
+
/*$$restProps*/ ctx[16],
|
|
1396
1429
|
{ "aria-autocomplete": "list" },
|
|
1397
1430
|
{
|
|
1398
1431
|
"aria-controls": "" + (/*id*/ ctx[2] + "-listbox")
|
|
@@ -1401,18 +1434,18 @@ function create_fragment(ctx) {
|
|
|
1401
1434
|
"aria-labelledby": "" + (/*id*/ ctx[2] + "-label")
|
|
1402
1435
|
},
|
|
1403
1436
|
{
|
|
1404
|
-
"aria-activedescendant": /*selectedIndex*/ ctx[
|
|
1405
|
-
? `${/*id*/ ctx[2]}-result-${/*selectedIndex*/ ctx[
|
|
1437
|
+
"aria-activedescendant": /*selectedIndex*/ ctx[10] >= 0 && !/*hideDropdown*/ ctx[5] && /*results*/ ctx[1].length > 0
|
|
1438
|
+
? `${/*id*/ ctx[2]}-result-${/*selectedIndex*/ ctx[10]}`
|
|
1406
1439
|
: null
|
|
1407
1440
|
}
|
|
1408
1441
|
];
|
|
1409
1442
|
|
|
1410
1443
|
function search_ref_binding(value) {
|
|
1411
|
-
/*search_ref_binding*/ ctx[
|
|
1444
|
+
/*search_ref_binding*/ ctx[29](value);
|
|
1412
1445
|
}
|
|
1413
1446
|
|
|
1414
1447
|
function search_value_binding(value) {
|
|
1415
|
-
/*search_value_binding*/ ctx[
|
|
1448
|
+
/*search_value_binding*/ ctx[30](value);
|
|
1416
1449
|
}
|
|
1417
1450
|
|
|
1418
1451
|
let search_props = {};
|
|
@@ -1421,8 +1454,8 @@ function create_fragment(ctx) {
|
|
|
1421
1454
|
search_props = assign(search_props, search_spread_levels[i]);
|
|
1422
1455
|
}
|
|
1423
1456
|
|
|
1424
|
-
if (/*searchRef*/ ctx[
|
|
1425
|
-
search_props.ref = /*searchRef*/ ctx[
|
|
1457
|
+
if (/*searchRef*/ ctx[9] !== void 0) {
|
|
1458
|
+
search_props.ref = /*searchRef*/ ctx[9];
|
|
1426
1459
|
}
|
|
1427
1460
|
|
|
1428
1461
|
if (/*value*/ ctx[0] !== void 0) {
|
|
@@ -1432,19 +1465,18 @@ function create_fragment(ctx) {
|
|
|
1432
1465
|
search = new Search$1({ props: search_props });
|
|
1433
1466
|
binding_callbacks.push(() => bind(search, 'ref', search_ref_binding));
|
|
1434
1467
|
binding_callbacks.push(() => bind(search, 'value', search_value_binding));
|
|
1435
|
-
search.$on("type", /*type_handler*/ ctx[
|
|
1436
|
-
search.$on("input", /*input_handler*/ ctx[
|
|
1437
|
-
search.$on("change", /*change_handler*/ ctx[
|
|
1438
|
-
search.$on("focus", /*focus_handler*/ ctx[
|
|
1439
|
-
search.$on("focus", /*focus_handler_1*/ ctx[
|
|
1440
|
-
search.$on("clear", /*clear_handler*/ ctx[
|
|
1441
|
-
search.$on("clear", /*open*/ ctx[
|
|
1442
|
-
search.$on("blur", /*blur_handler*/ ctx[
|
|
1443
|
-
search.$on("blur", /*blur_handler_1*/ ctx[37]);
|
|
1468
|
+
search.$on("type", /*type_handler*/ ctx[31]);
|
|
1469
|
+
search.$on("input", /*input_handler*/ ctx[32]);
|
|
1470
|
+
search.$on("change", /*change_handler*/ ctx[33]);
|
|
1471
|
+
search.$on("focus", /*focus_handler*/ ctx[34]);
|
|
1472
|
+
search.$on("focus", /*focus_handler_1*/ ctx[35]);
|
|
1473
|
+
search.$on("clear", /*clear_handler*/ ctx[36]);
|
|
1474
|
+
search.$on("clear", /*open*/ ctx[13]);
|
|
1475
|
+
search.$on("blur", /*blur_handler*/ ctx[37]);
|
|
1444
1476
|
search.$on("keydown", /*keydown_handler*/ ctx[38]);
|
|
1445
1477
|
search.$on("keydown", /*keydown_handler_1*/ ctx[39]);
|
|
1446
|
-
let if_block0 = /*showResults*/ ctx[
|
|
1447
|
-
let if_block1 = /*$$slots*/ ctx[
|
|
1478
|
+
let if_block0 = /*showResults*/ ctx[7] && create_if_block_1(ctx);
|
|
1479
|
+
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);
|
|
1448
1480
|
|
|
1449
1481
|
return {
|
|
1450
1482
|
c() {
|
|
@@ -1458,15 +1490,15 @@ function create_fragment(ctx) {
|
|
|
1458
1490
|
attr(ul, "role", "listbox");
|
|
1459
1491
|
attr(ul, "aria-labelledby", ul_aria_labelledby_value = "" + (/*id*/ ctx[2] + "-label"));
|
|
1460
1492
|
attr(ul, "id", ul_id_value = "" + (/*id*/ ctx[2] + "-listbox"));
|
|
1461
|
-
attr(ul, "class", "svelte-
|
|
1493
|
+
attr(ul, "class", "svelte-1t4elht");
|
|
1462
1494
|
toggle_class(ul, "svelte-typeahead-list", true);
|
|
1463
1495
|
attr(div, "data-svelte-typeahead", "");
|
|
1464
1496
|
attr(div, "role", "combobox");
|
|
1465
1497
|
attr(div, "aria-haspopup", "listbox");
|
|
1466
1498
|
attr(div, "aria-owns", div_aria_owns_value = "" + (/*id*/ ctx[2] + "-listbox"));
|
|
1467
|
-
attr(div, "aria-expanded", /*showResults*/ ctx[
|
|
1499
|
+
attr(div, "aria-expanded", /*showResults*/ ctx[7]);
|
|
1468
1500
|
attr(div, "id", div_id_value = "" + (/*id*/ ctx[2] + "-typeahead"));
|
|
1469
|
-
attr(div, "class", "svelte-
|
|
1501
|
+
attr(div, "class", "svelte-1t4elht");
|
|
1470
1502
|
toggle_class(div, "dropdown", /*results*/ ctx[1].length > 0);
|
|
1471
1503
|
},
|
|
1472
1504
|
m(target, anchor) {
|
|
@@ -1481,16 +1513,16 @@ function create_fragment(ctx) {
|
|
|
1481
1513
|
current = true;
|
|
1482
1514
|
|
|
1483
1515
|
if (!mounted) {
|
|
1484
|
-
dispose = listen(window, "click", /*click_handler*/ ctx[
|
|
1516
|
+
dispose = listen(window, "click", /*click_handler*/ ctx[28]);
|
|
1485
1517
|
mounted = true;
|
|
1486
1518
|
}
|
|
1487
1519
|
},
|
|
1488
1520
|
p(ctx, dirty) {
|
|
1489
|
-
const search_changes = (dirty[0] & /*id, $$restProps, selectedIndex, hideDropdown, results*/
|
|
1521
|
+
const search_changes = (dirty[0] & /*id, $$restProps, selectedIndex, hideDropdown, results*/ 66598)
|
|
1490
1522
|
? get_spread_update(search_spread_levels, [
|
|
1491
1523
|
dirty[0] & /*id*/ 4 && { id: /*id*/ ctx[2] },
|
|
1492
1524
|
search_spread_levels[1],
|
|
1493
|
-
dirty[0] & /*$$restProps*/
|
|
1525
|
+
dirty[0] & /*$$restProps*/ 65536 && get_spread_object(/*$$restProps*/ ctx[16]),
|
|
1494
1526
|
search_spread_levels[3],
|
|
1495
1527
|
dirty[0] & /*id*/ 4 && {
|
|
1496
1528
|
"aria-controls": "" + (/*id*/ ctx[2] + "-listbox")
|
|
@@ -1498,17 +1530,17 @@ function create_fragment(ctx) {
|
|
|
1498
1530
|
dirty[0] & /*id*/ 4 && {
|
|
1499
1531
|
"aria-labelledby": "" + (/*id*/ ctx[2] + "-label")
|
|
1500
1532
|
},
|
|
1501
|
-
dirty[0] & /*selectedIndex, hideDropdown, results, id*/
|
|
1502
|
-
"aria-activedescendant": /*selectedIndex*/ ctx[
|
|
1503
|
-
? `${/*id*/ ctx[2]}-result-${/*selectedIndex*/ ctx[
|
|
1533
|
+
dirty[0] & /*selectedIndex, hideDropdown, results, id*/ 1062 && {
|
|
1534
|
+
"aria-activedescendant": /*selectedIndex*/ ctx[10] >= 0 && !/*hideDropdown*/ ctx[5] && /*results*/ ctx[1].length > 0
|
|
1535
|
+
? `${/*id*/ ctx[2]}-result-${/*selectedIndex*/ ctx[10]}`
|
|
1504
1536
|
: null
|
|
1505
1537
|
}
|
|
1506
1538
|
])
|
|
1507
1539
|
: {};
|
|
1508
1540
|
|
|
1509
|
-
if (!updating_ref && dirty[0] & /*searchRef*/
|
|
1541
|
+
if (!updating_ref && dirty[0] & /*searchRef*/ 512) {
|
|
1510
1542
|
updating_ref = true;
|
|
1511
|
-
search_changes.ref = /*searchRef*/ ctx[
|
|
1543
|
+
search_changes.ref = /*searchRef*/ ctx[9];
|
|
1512
1544
|
add_flush_callback(() => updating_ref = false);
|
|
1513
1545
|
}
|
|
1514
1546
|
|
|
@@ -1520,11 +1552,11 @@ function create_fragment(ctx) {
|
|
|
1520
1552
|
|
|
1521
1553
|
search.$set(search_changes);
|
|
1522
1554
|
|
|
1523
|
-
if (/*showResults*/ ctx[
|
|
1555
|
+
if (/*showResults*/ ctx[7]) {
|
|
1524
1556
|
if (if_block0) {
|
|
1525
1557
|
if_block0.p(ctx, dirty);
|
|
1526
1558
|
|
|
1527
|
-
if (dirty[0] & /*showResults*/
|
|
1559
|
+
if (dirty[0] & /*showResults*/ 128) {
|
|
1528
1560
|
transition_in(if_block0, 1);
|
|
1529
1561
|
}
|
|
1530
1562
|
} else {
|
|
@@ -1543,11 +1575,11 @@ function create_fragment(ctx) {
|
|
|
1543
1575
|
check_outros();
|
|
1544
1576
|
}
|
|
1545
1577
|
|
|
1546
|
-
if (/*$$slots*/ ctx[
|
|
1578
|
+
if (/*$$slots*/ ctx[15]["no-results"] && !/*hideDropdown*/ ctx[5] && /*value*/ ctx[0].length > 0 && /*results*/ ctx[1].length === 0) {
|
|
1547
1579
|
if (if_block1) {
|
|
1548
1580
|
if_block1.p(ctx, dirty);
|
|
1549
1581
|
|
|
1550
|
-
if (dirty[0] & /*$$slots, hideDropdown, value, results*/
|
|
1582
|
+
if (dirty[0] & /*$$slots, hideDropdown, value, results*/ 32803) {
|
|
1551
1583
|
transition_in(if_block1, 1);
|
|
1552
1584
|
}
|
|
1553
1585
|
} else {
|
|
@@ -1578,15 +1610,15 @@ function create_fragment(ctx) {
|
|
|
1578
1610
|
attr(div, "aria-owns", div_aria_owns_value);
|
|
1579
1611
|
}
|
|
1580
1612
|
|
|
1581
|
-
if (!current || dirty[0] & /*showResults*/
|
|
1582
|
-
attr(div, "aria-expanded", /*showResults*/ ctx[
|
|
1613
|
+
if (!current || dirty[0] & /*showResults*/ 128) {
|
|
1614
|
+
attr(div, "aria-expanded", /*showResults*/ ctx[7]);
|
|
1583
1615
|
}
|
|
1584
1616
|
|
|
1585
1617
|
if (!current || dirty[0] & /*id*/ 4 && div_id_value !== (div_id_value = "" + (/*id*/ ctx[2] + "-typeahead"))) {
|
|
1586
1618
|
attr(div, "id", div_id_value);
|
|
1587
1619
|
}
|
|
1588
1620
|
|
|
1589
|
-
if (dirty[0] & /*results*/ 2) {
|
|
1621
|
+
if (!current || dirty[0] & /*results*/ 2) {
|
|
1590
1622
|
toggle_class(div, "dropdown", /*results*/ ctx[1].length > 0);
|
|
1591
1623
|
}
|
|
1592
1624
|
},
|
|
@@ -1621,7 +1653,7 @@ function instance($$self, $$props, $$invalidate) {
|
|
|
1621
1653
|
let showResults;
|
|
1622
1654
|
|
|
1623
1655
|
const omit_props_names = [
|
|
1624
|
-
"id","value","data","extract","disable","filter","autoselect","inputAfterSelect","results","focusAfterSelect","showDropdownOnFocus","limit"
|
|
1656
|
+
"id","value","data","extract","disable","filter","autoselect","inputAfterSelect","results","focusAfterSelect","showDropdownOnFocus","showAllResultsOnFocus","limit"
|
|
1625
1657
|
];
|
|
1626
1658
|
|
|
1627
1659
|
let $$restProps = compute_rest_props($$props, omit_props_names);
|
|
@@ -1638,6 +1670,7 @@ function instance($$self, $$props, $$invalidate) {
|
|
|
1638
1670
|
let { results = [] } = $$props;
|
|
1639
1671
|
let { focusAfterSelect = false } = $$props;
|
|
1640
1672
|
let { showDropdownOnFocus = false } = $$props;
|
|
1673
|
+
let { showAllResultsOnFocus = false } = $$props;
|
|
1641
1674
|
let { limit = Infinity } = $$props;
|
|
1642
1675
|
const dispatch = createEventDispatcher();
|
|
1643
1676
|
let comboboxRef = null;
|
|
@@ -1649,11 +1682,11 @@ function instance($$self, $$props, $$invalidate) {
|
|
|
1649
1682
|
|
|
1650
1683
|
afterUpdate(() => {
|
|
1651
1684
|
if (prevResults !== resultsId && autoselect) {
|
|
1652
|
-
$$invalidate(
|
|
1685
|
+
$$invalidate(10, selectedIndex = getNextNonDisabledIndex());
|
|
1653
1686
|
}
|
|
1654
1687
|
|
|
1655
1688
|
if (prevResults !== resultsId && !$$slots["no-results"]) {
|
|
1656
|
-
$$invalidate(
|
|
1689
|
+
$$invalidate(5, hideDropdown = results.length === 0);
|
|
1657
1690
|
}
|
|
1658
1691
|
|
|
1659
1692
|
prevResults = resultsId;
|
|
@@ -1717,11 +1750,15 @@ function instance($$self, $$props, $$invalidate) {
|
|
|
1717
1750
|
disabled = results[index].disabled;
|
|
1718
1751
|
}
|
|
1719
1752
|
|
|
1720
|
-
$$invalidate(
|
|
1753
|
+
$$invalidate(10, selectedIndex = index);
|
|
1721
1754
|
}
|
|
1722
1755
|
|
|
1723
|
-
const open = () => $$invalidate(
|
|
1724
|
-
|
|
1756
|
+
const open = () => $$invalidate(5, hideDropdown = false);
|
|
1757
|
+
|
|
1758
|
+
const close = () => {
|
|
1759
|
+
$$invalidate(5, hideDropdown = true);
|
|
1760
|
+
$$invalidate(6, isFocused = false);
|
|
1761
|
+
};
|
|
1725
1762
|
|
|
1726
1763
|
const click_handler = ({ target }) => {
|
|
1727
1764
|
if (!hideDropdown && !comboboxRef?.contains(target)) {
|
|
@@ -1731,7 +1768,7 @@ function instance($$self, $$props, $$invalidate) {
|
|
|
1731
1768
|
|
|
1732
1769
|
function search_ref_binding(value) {
|
|
1733
1770
|
searchRef = value;
|
|
1734
|
-
$$invalidate(
|
|
1771
|
+
$$invalidate(9, searchRef);
|
|
1735
1772
|
}
|
|
1736
1773
|
|
|
1737
1774
|
function search_value_binding(value$1) {
|
|
@@ -1757,7 +1794,11 @@ function instance($$self, $$props, $$invalidate) {
|
|
|
1757
1794
|
|
|
1758
1795
|
const focus_handler_1 = () => {
|
|
1759
1796
|
open();
|
|
1760
|
-
|
|
1797
|
+
|
|
1798
|
+
if (showDropdownOnFocus || showAllResultsOnFocus) {
|
|
1799
|
+
$$invalidate(7, showResults = true);
|
|
1800
|
+
$$invalidate(6, isFocused = true);
|
|
1801
|
+
}
|
|
1761
1802
|
};
|
|
1762
1803
|
|
|
1763
1804
|
function clear_handler(event) {
|
|
@@ -1768,10 +1809,6 @@ function instance($$self, $$props, $$invalidate) {
|
|
|
1768
1809
|
bubble.call(this, $$self, event);
|
|
1769
1810
|
}
|
|
1770
1811
|
|
|
1771
|
-
const blur_handler_1 = () => {
|
|
1772
|
-
$$invalidate(4, isFocused = false);
|
|
1773
|
-
};
|
|
1774
|
-
|
|
1775
1812
|
function keydown_handler(event) {
|
|
1776
1813
|
bubble.call(this, $$self, event);
|
|
1777
1814
|
}
|
|
@@ -1802,63 +1839,76 @@ function instance($$self, $$props, $$invalidate) {
|
|
|
1802
1839
|
|
|
1803
1840
|
const click_handler_1 = (result, index) => {
|
|
1804
1841
|
if (result.disabled) return;
|
|
1805
|
-
$$invalidate(
|
|
1842
|
+
$$invalidate(10, selectedIndex = index);
|
|
1806
1843
|
select();
|
|
1807
1844
|
};
|
|
1808
1845
|
|
|
1809
1846
|
const mouseenter_handler = (result, index) => {
|
|
1810
1847
|
if (result.disabled) return;
|
|
1811
|
-
$$invalidate(
|
|
1848
|
+
$$invalidate(10, selectedIndex = index);
|
|
1812
1849
|
};
|
|
1813
1850
|
|
|
1814
1851
|
function div_binding($$value) {
|
|
1815
1852
|
binding_callbacks[$$value ? 'unshift' : 'push'](() => {
|
|
1816
1853
|
comboboxRef = $$value;
|
|
1817
|
-
$$invalidate(
|
|
1854
|
+
$$invalidate(8, comboboxRef);
|
|
1818
1855
|
});
|
|
1819
1856
|
}
|
|
1820
1857
|
|
|
1821
1858
|
$$self.$$set = $$new_props => {
|
|
1822
1859
|
$$props = assign(assign({}, $$props), exclude_internal_props($$new_props));
|
|
1823
|
-
$$invalidate(
|
|
1860
|
+
$$invalidate(16, $$restProps = compute_rest_props($$props, omit_props_names));
|
|
1824
1861
|
if ('id' in $$new_props) $$invalidate(2, id = $$new_props.id);
|
|
1825
1862
|
if ('value' in $$new_props) $$invalidate(0, value = $$new_props.value);
|
|
1826
|
-
if ('data' in $$new_props) $$invalidate(
|
|
1827
|
-
if ('extract' in $$new_props) $$invalidate(
|
|
1828
|
-
if ('disable' in $$new_props) $$invalidate(
|
|
1829
|
-
if ('filter' in $$new_props) $$invalidate(
|
|
1830
|
-
if ('autoselect' in $$new_props) $$invalidate(
|
|
1831
|
-
if ('inputAfterSelect' in $$new_props) $$invalidate(
|
|
1863
|
+
if ('data' in $$new_props) $$invalidate(17, data = $$new_props.data);
|
|
1864
|
+
if ('extract' in $$new_props) $$invalidate(18, extract = $$new_props.extract);
|
|
1865
|
+
if ('disable' in $$new_props) $$invalidate(19, disable = $$new_props.disable);
|
|
1866
|
+
if ('filter' in $$new_props) $$invalidate(20, filter = $$new_props.filter);
|
|
1867
|
+
if ('autoselect' in $$new_props) $$invalidate(21, autoselect = $$new_props.autoselect);
|
|
1868
|
+
if ('inputAfterSelect' in $$new_props) $$invalidate(22, inputAfterSelect = $$new_props.inputAfterSelect);
|
|
1832
1869
|
if ('results' in $$new_props) $$invalidate(1, results = $$new_props.results);
|
|
1833
|
-
if ('focusAfterSelect' in $$new_props) $$invalidate(
|
|
1834
|
-
if ('showDropdownOnFocus' in $$new_props) $$invalidate(
|
|
1835
|
-
if ('
|
|
1836
|
-
if ('
|
|
1870
|
+
if ('focusAfterSelect' in $$new_props) $$invalidate(23, focusAfterSelect = $$new_props.focusAfterSelect);
|
|
1871
|
+
if ('showDropdownOnFocus' in $$new_props) $$invalidate(3, showDropdownOnFocus = $$new_props.showDropdownOnFocus);
|
|
1872
|
+
if ('showAllResultsOnFocus' in $$new_props) $$invalidate(4, showAllResultsOnFocus = $$new_props.showAllResultsOnFocus);
|
|
1873
|
+
if ('limit' in $$new_props) $$invalidate(24, limit = $$new_props.limit);
|
|
1874
|
+
if ('$$scope' in $$new_props) $$invalidate(26, $$scope = $$new_props.$$scope);
|
|
1837
1875
|
};
|
|
1838
1876
|
|
|
1839
1877
|
$$self.$$.update = () => {
|
|
1840
|
-
if ($$self.$$.dirty[0] & /*extract*/
|
|
1841
|
-
$$invalidate(
|
|
1878
|
+
if ($$self.$$.dirty[0] & /*extract*/ 262144) {
|
|
1879
|
+
$$invalidate(25, options = { pre: "<mark>", post: "</mark>", extract });
|
|
1842
1880
|
}
|
|
1843
1881
|
|
|
1844
|
-
if ($$self.$$.dirty[0] & /*value, data, options, limit, filter, disable*/
|
|
1882
|
+
if ($$self.$$.dirty[0] & /*value, data, options, limit, filter, disable*/ 52035585) {
|
|
1845
1883
|
$$invalidate(1, results = fuzzy.filter(value, data, options).filter(({ score }) => score > 0).slice(0, limit).filter(result => !filter(result.original)).map(result => ({
|
|
1846
1884
|
...result,
|
|
1847
1885
|
disabled: disable(result.original)
|
|
1848
1886
|
})));
|
|
1849
1887
|
}
|
|
1850
1888
|
|
|
1851
|
-
if ($$self.$$.dirty[0] & /*
|
|
1889
|
+
if ($$self.$$.dirty[0] & /*isFocused, showAllResultsOnFocus, value, data, filter, disable, extract*/ 1966161) {
|
|
1890
|
+
if (isFocused && showAllResultsOnFocus && value.length === 0) {
|
|
1891
|
+
$$invalidate(1, results = data.filter(datum => !filter(datum)).map((original, index) => ({
|
|
1892
|
+
disabled: disable(original),
|
|
1893
|
+
index,
|
|
1894
|
+
original,
|
|
1895
|
+
score: 0,
|
|
1896
|
+
string: extract(original)
|
|
1897
|
+
})));
|
|
1898
|
+
}
|
|
1899
|
+
}
|
|
1900
|
+
|
|
1901
|
+
if ($$self.$$.dirty[0] & /*results, extract*/ 262146) {
|
|
1852
1902
|
resultsId = results.map(result => extract(result.original)).join("");
|
|
1853
1903
|
}
|
|
1854
1904
|
|
|
1855
|
-
if ($$self.$$.dirty[0] & /*hideDropdown, results*/
|
|
1856
|
-
$$invalidate(
|
|
1905
|
+
if ($$self.$$.dirty[0] & /*hideDropdown, results*/ 34) {
|
|
1906
|
+
$$invalidate(7, showResults = !hideDropdown && results.length > 0);
|
|
1857
1907
|
}
|
|
1858
1908
|
|
|
1859
|
-
if ($$self.$$.dirty[0] & /*showDropdownOnFocus, showResults, isFocused*/
|
|
1909
|
+
if ($$self.$$.dirty[0] & /*showDropdownOnFocus, showResults, isFocused*/ 200) {
|
|
1860
1910
|
if (showDropdownOnFocus) {
|
|
1861
|
-
$$invalidate(
|
|
1911
|
+
$$invalidate(7, showResults = showResults && isFocused);
|
|
1862
1912
|
}
|
|
1863
1913
|
}
|
|
1864
1914
|
};
|
|
@@ -1867,6 +1917,8 @@ function instance($$self, $$props, $$invalidate) {
|
|
|
1867
1917
|
value,
|
|
1868
1918
|
results,
|
|
1869
1919
|
id,
|
|
1920
|
+
showDropdownOnFocus,
|
|
1921
|
+
showAllResultsOnFocus,
|
|
1870
1922
|
hideDropdown,
|
|
1871
1923
|
isFocused,
|
|
1872
1924
|
showResults,
|
|
@@ -1886,7 +1938,6 @@ function instance($$self, $$props, $$invalidate) {
|
|
|
1886
1938
|
autoselect,
|
|
1887
1939
|
inputAfterSelect,
|
|
1888
1940
|
focusAfterSelect,
|
|
1889
|
-
showDropdownOnFocus,
|
|
1890
1941
|
limit,
|
|
1891
1942
|
options,
|
|
1892
1943
|
$$scope,
|
|
@@ -1901,7 +1952,6 @@ function instance($$self, $$props, $$invalidate) {
|
|
|
1901
1952
|
focus_handler_1,
|
|
1902
1953
|
clear_handler,
|
|
1903
1954
|
blur_handler,
|
|
1904
|
-
blur_handler_1,
|
|
1905
1955
|
keydown_handler,
|
|
1906
1956
|
keydown_handler_1,
|
|
1907
1957
|
click_handler_1,
|
|
@@ -1923,16 +1973,17 @@ class Typeahead extends SvelteComponent {
|
|
|
1923
1973
|
{
|
|
1924
1974
|
id: 2,
|
|
1925
1975
|
value: 0,
|
|
1926
|
-
data:
|
|
1927
|
-
extract:
|
|
1928
|
-
disable:
|
|
1929
|
-
filter:
|
|
1930
|
-
autoselect:
|
|
1931
|
-
inputAfterSelect:
|
|
1976
|
+
data: 17,
|
|
1977
|
+
extract: 18,
|
|
1978
|
+
disable: 19,
|
|
1979
|
+
filter: 20,
|
|
1980
|
+
autoselect: 21,
|
|
1981
|
+
inputAfterSelect: 22,
|
|
1932
1982
|
results: 1,
|
|
1933
|
-
focusAfterSelect:
|
|
1934
|
-
showDropdownOnFocus:
|
|
1935
|
-
|
|
1983
|
+
focusAfterSelect: 23,
|
|
1984
|
+
showDropdownOnFocus: 3,
|
|
1985
|
+
showAllResultsOnFocus: 4,
|
|
1986
|
+
limit: 24
|
|
1936
1987
|
},
|
|
1937
1988
|
add_css,
|
|
1938
1989
|
[-1, -1]
|