svelte-typeahead 4.3.2 → 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 +12 -0
- package/README.md +36 -42
- package/lib/index.js +179 -126
- package/lib/index.mjs +179 -126
- package/package.json +3 -5
- package/src/Typeahead.svelte +22 -2
- 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 => ({
|
|
@@ -1084,14 +1117,14 @@
|
|
|
1084
1117
|
|
|
1085
1118
|
const get_no_results_slot_context = ctx => ({
|
|
1086
1119
|
value: /*value*/ ctx[0],
|
|
1087
|
-
result: /*result*/ ctx[
|
|
1088
|
-
index: /*index*/ ctx[
|
|
1120
|
+
result: /*result*/ ctx[47],
|
|
1121
|
+
index: /*index*/ ctx[49]
|
|
1089
1122
|
});
|
|
1090
1123
|
|
|
1091
1124
|
function get_each_context(ctx, list, i) {
|
|
1092
1125
|
const child_ctx = ctx.slice();
|
|
1093
|
-
child_ctx[
|
|
1094
|
-
child_ctx[
|
|
1126
|
+
child_ctx[47] = list[i];
|
|
1127
|
+
child_ctx[49] = i;
|
|
1095
1128
|
return child_ctx;
|
|
1096
1129
|
}
|
|
1097
1130
|
|
|
@@ -1101,12 +1134,12 @@
|
|
|
1101
1134
|
});
|
|
1102
1135
|
|
|
1103
1136
|
const get_default_slot_context = ctx => ({
|
|
1104
|
-
result: /*result*/ ctx[
|
|
1105
|
-
index: /*index*/ ctx[
|
|
1137
|
+
result: /*result*/ ctx[47],
|
|
1138
|
+
index: /*index*/ ctx[49],
|
|
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,10 +1223,10 @@
|
|
|
1190
1223
|
};
|
|
1191
1224
|
}
|
|
1192
1225
|
|
|
1193
|
-
// (
|
|
1226
|
+
// (267:41)
|
|
1194
1227
|
function fallback_block(ctx) {
|
|
1195
1228
|
let html_tag;
|
|
1196
|
-
let raw_value = /*result*/ ctx[
|
|
1229
|
+
let raw_value = /*result*/ ctx[47].string + "";
|
|
1197
1230
|
let html_anchor;
|
|
1198
1231
|
|
|
1199
1232
|
return {
|
|
@@ -1207,7 +1240,7 @@
|
|
|
1207
1240
|
insert(target, html_anchor, anchor);
|
|
1208
1241
|
},
|
|
1209
1242
|
p(ctx, dirty) {
|
|
1210
|
-
if (dirty[0] & /*results*/ 2 && raw_value !== (raw_value = /*result*/ ctx[
|
|
1243
|
+
if (dirty[0] & /*results*/ 2 && raw_value !== (raw_value = /*result*/ ctx[47].string + "")) html_tag.p(raw_value);
|
|
1211
1244
|
},
|
|
1212
1245
|
d(detaching) {
|
|
1213
1246
|
if (detaching) detach(html_anchor);
|
|
@@ -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,16 +1258,16 @@
|
|
|
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() {
|
|
1233
|
-
return /*click_handler_1*/ ctx[
|
|
1266
|
+
return /*click_handler_1*/ ctx[40](/*result*/ ctx[47], /*index*/ ctx[49]);
|
|
1234
1267
|
}
|
|
1235
1268
|
|
|
1236
1269
|
function mouseenter_handler() {
|
|
1237
|
-
return /*mouseenter_handler*/ ctx[
|
|
1270
|
+
return /*mouseenter_handler*/ ctx[41](/*result*/ ctx[47], /*index*/ ctx[49]);
|
|
1238
1271
|
}
|
|
1239
1272
|
|
|
1240
1273
|
return {
|
|
@@ -1243,11 +1276,11 @@
|
|
|
1243
1276
|
if (default_slot_or_fallback) default_slot_or_fallback.c();
|
|
1244
1277
|
t = space();
|
|
1245
1278
|
attr(li, "role", "option");
|
|
1246
|
-
attr(li, "id", li_id_value = "" + (/*id*/ ctx[2] + "-result-" + /*index*/ ctx[
|
|
1247
|
-
attr(li, "aria-selected", li_aria_selected_value = /*selectedIndex*/ ctx[
|
|
1248
|
-
attr(li, "class", "svelte-
|
|
1249
|
-
toggle_class(li, "selected", /*selectedIndex*/ ctx[
|
|
1250
|
-
toggle_class(li, "disabled", /*result*/ ctx[
|
|
1279
|
+
attr(li, "id", li_id_value = "" + (/*id*/ ctx[2] + "-result-" + /*index*/ ctx[49]));
|
|
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]);
|
|
1283
|
+
toggle_class(li, "disabled", /*result*/ ctx[47].disabled);
|
|
1251
1284
|
},
|
|
1252
1285
|
m(target, anchor) {
|
|
1253
1286
|
insert(target, li, 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
|
}
|
|
@@ -1290,20 +1323,20 @@
|
|
|
1290
1323
|
}
|
|
1291
1324
|
}
|
|
1292
1325
|
|
|
1293
|
-
if (!current || dirty[0] & /*id*/ 4 && li_id_value !== (li_id_value = "" + (/*id*/ ctx[2] + "-result-" + /*index*/ ctx[
|
|
1326
|
+
if (!current || dirty[0] & /*id*/ 4 && li_id_value !== (li_id_value = "" + (/*id*/ ctx[2] + "-result-" + /*index*/ ctx[49]))) {
|
|
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) {
|
|
1306
|
-
toggle_class(li, "disabled", /*result*/ ctx[
|
|
1338
|
+
if (!current || dirty[0] & /*results*/ 2) {
|
|
1339
|
+
toggle_class(li, "disabled", /*result*/ ctx[47].disabled);
|
|
1307
1340
|
}
|
|
1308
1341
|
},
|
|
1309
1342
|
i(local) {
|
|
@@ -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,18 +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("keydown", /*keydown_handler*/ ctx[
|
|
1450
|
-
search.$on("keydown", /*keydown_handler_1*/ ctx[
|
|
1451
|
-
let if_block0 = /*showResults*/ ctx[
|
|
1452
|
-
let if_block1 = /*$$slots*/ ctx[
|
|
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]);
|
|
1482
|
+
search.$on("keydown", /*keydown_handler*/ ctx[38]);
|
|
1483
|
+
search.$on("keydown", /*keydown_handler_1*/ ctx[39]);
|
|
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);
|
|
1453
1486
|
|
|
1454
1487
|
return {
|
|
1455
1488
|
c() {
|
|
@@ -1463,15 +1496,15 @@
|
|
|
1463
1496
|
attr(ul, "role", "listbox");
|
|
1464
1497
|
attr(ul, "aria-labelledby", ul_aria_labelledby_value = "" + (/*id*/ ctx[2] + "-label"));
|
|
1465
1498
|
attr(ul, "id", ul_id_value = "" + (/*id*/ ctx[2] + "-listbox"));
|
|
1466
|
-
attr(ul, "class", "svelte-
|
|
1499
|
+
attr(ul, "class", "svelte-1t4elht");
|
|
1467
1500
|
toggle_class(ul, "svelte-typeahead-list", true);
|
|
1468
1501
|
attr(div, "data-svelte-typeahead", "");
|
|
1469
1502
|
attr(div, "role", "combobox");
|
|
1470
1503
|
attr(div, "aria-haspopup", "listbox");
|
|
1471
1504
|
attr(div, "aria-owns", div_aria_owns_value = "" + (/*id*/ ctx[2] + "-listbox"));
|
|
1472
|
-
attr(div, "aria-expanded", /*showResults*/ ctx[
|
|
1505
|
+
attr(div, "aria-expanded", /*showResults*/ ctx[7]);
|
|
1473
1506
|
attr(div, "id", div_id_value = "" + (/*id*/ ctx[2] + "-typeahead"));
|
|
1474
|
-
attr(div, "class", "svelte-
|
|
1507
|
+
attr(div, "class", "svelte-1t4elht");
|
|
1475
1508
|
toggle_class(div, "dropdown", /*results*/ ctx[1].length > 0);
|
|
1476
1509
|
},
|
|
1477
1510
|
m(target, anchor) {
|
|
@@ -1482,20 +1515,20 @@
|
|
|
1482
1515
|
if (if_block0) if_block0.m(ul, null);
|
|
1483
1516
|
append(ul, t1);
|
|
1484
1517
|
if (if_block1) if_block1.m(ul, null);
|
|
1485
|
-
/*div_binding*/ ctx[
|
|
1518
|
+
/*div_binding*/ ctx[42](div);
|
|
1486
1519
|
current = true;
|
|
1487
1520
|
|
|
1488
1521
|
if (!mounted) {
|
|
1489
|
-
dispose = listen(window, "click", /*click_handler*/ ctx[
|
|
1522
|
+
dispose = listen(window, "click", /*click_handler*/ ctx[28]);
|
|
1490
1523
|
mounted = true;
|
|
1491
1524
|
}
|
|
1492
1525
|
},
|
|
1493
1526
|
p(ctx, dirty) {
|
|
1494
|
-
const search_changes = (dirty[0] & /*id, $$restProps, selectedIndex, hideDropdown, results*/
|
|
1527
|
+
const search_changes = (dirty[0] & /*id, $$restProps, selectedIndex, hideDropdown, results*/ 66598)
|
|
1495
1528
|
? get_spread_update(search_spread_levels, [
|
|
1496
1529
|
dirty[0] & /*id*/ 4 && { id: /*id*/ ctx[2] },
|
|
1497
1530
|
search_spread_levels[1],
|
|
1498
|
-
dirty[0] & /*$$restProps*/
|
|
1531
|
+
dirty[0] & /*$$restProps*/ 65536 && get_spread_object(/*$$restProps*/ ctx[16]),
|
|
1499
1532
|
search_spread_levels[3],
|
|
1500
1533
|
dirty[0] & /*id*/ 4 && {
|
|
1501
1534
|
"aria-controls": "" + (/*id*/ ctx[2] + "-listbox")
|
|
@@ -1503,17 +1536,17 @@
|
|
|
1503
1536
|
dirty[0] & /*id*/ 4 && {
|
|
1504
1537
|
"aria-labelledby": "" + (/*id*/ ctx[2] + "-label")
|
|
1505
1538
|
},
|
|
1506
|
-
dirty[0] & /*selectedIndex, hideDropdown, results, id*/
|
|
1507
|
-
"aria-activedescendant": /*selectedIndex*/ ctx[
|
|
1508
|
-
? `${/*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]}`
|
|
1509
1542
|
: null
|
|
1510
1543
|
}
|
|
1511
1544
|
])
|
|
1512
1545
|
: {};
|
|
1513
1546
|
|
|
1514
|
-
if (!updating_ref && dirty[0] & /*searchRef*/
|
|
1547
|
+
if (!updating_ref && dirty[0] & /*searchRef*/ 512) {
|
|
1515
1548
|
updating_ref = true;
|
|
1516
|
-
search_changes.ref = /*searchRef*/ ctx[
|
|
1549
|
+
search_changes.ref = /*searchRef*/ ctx[9];
|
|
1517
1550
|
add_flush_callback(() => updating_ref = false);
|
|
1518
1551
|
}
|
|
1519
1552
|
|
|
@@ -1525,11 +1558,11 @@
|
|
|
1525
1558
|
|
|
1526
1559
|
search.$set(search_changes);
|
|
1527
1560
|
|
|
1528
|
-
if (/*showResults*/ ctx[
|
|
1561
|
+
if (/*showResults*/ ctx[7]) {
|
|
1529
1562
|
if (if_block0) {
|
|
1530
1563
|
if_block0.p(ctx, dirty);
|
|
1531
1564
|
|
|
1532
|
-
if (dirty[0] & /*showResults*/
|
|
1565
|
+
if (dirty[0] & /*showResults*/ 128) {
|
|
1533
1566
|
transition_in(if_block0, 1);
|
|
1534
1567
|
}
|
|
1535
1568
|
} else {
|
|
@@ -1548,11 +1581,11 @@
|
|
|
1548
1581
|
check_outros();
|
|
1549
1582
|
}
|
|
1550
1583
|
|
|
1551
|
-
if (/*$$slots*/ ctx[
|
|
1584
|
+
if (/*$$slots*/ ctx[15]["no-results"] && !/*hideDropdown*/ ctx[5] && /*value*/ ctx[0].length > 0 && /*results*/ ctx[1].length === 0) {
|
|
1552
1585
|
if (if_block1) {
|
|
1553
1586
|
if_block1.p(ctx, dirty);
|
|
1554
1587
|
|
|
1555
|
-
if (dirty[0] & /*$$slots, hideDropdown, value, results*/
|
|
1588
|
+
if (dirty[0] & /*$$slots, hideDropdown, value, results*/ 32803) {
|
|
1556
1589
|
transition_in(if_block1, 1);
|
|
1557
1590
|
}
|
|
1558
1591
|
} else {
|
|
@@ -1583,15 +1616,15 @@
|
|
|
1583
1616
|
attr(div, "aria-owns", div_aria_owns_value);
|
|
1584
1617
|
}
|
|
1585
1618
|
|
|
1586
|
-
if (!current || dirty[0] & /*showResults*/
|
|
1587
|
-
attr(div, "aria-expanded", /*showResults*/ ctx[
|
|
1619
|
+
if (!current || dirty[0] & /*showResults*/ 128) {
|
|
1620
|
+
attr(div, "aria-expanded", /*showResults*/ ctx[7]);
|
|
1588
1621
|
}
|
|
1589
1622
|
|
|
1590
1623
|
if (!current || dirty[0] & /*id*/ 4 && div_id_value !== (div_id_value = "" + (/*id*/ ctx[2] + "-typeahead"))) {
|
|
1591
1624
|
attr(div, "id", div_id_value);
|
|
1592
1625
|
}
|
|
1593
1626
|
|
|
1594
|
-
if (dirty[0] & /*results*/ 2) {
|
|
1627
|
+
if (!current || dirty[0] & /*results*/ 2) {
|
|
1595
1628
|
toggle_class(div, "dropdown", /*results*/ ctx[1].length > 0);
|
|
1596
1629
|
}
|
|
1597
1630
|
},
|
|
@@ -1613,7 +1646,7 @@
|
|
|
1613
1646
|
destroy_component(search);
|
|
1614
1647
|
if (if_block0) if_block0.d();
|
|
1615
1648
|
if (if_block1) if_block1.d();
|
|
1616
|
-
/*div_binding*/ ctx[
|
|
1649
|
+
/*div_binding*/ ctx[42](null);
|
|
1617
1650
|
mounted = false;
|
|
1618
1651
|
dispose();
|
|
1619
1652
|
}
|
|
@@ -1626,7 +1659,7 @@
|
|
|
1626
1659
|
let showResults;
|
|
1627
1660
|
|
|
1628
1661
|
const omit_props_names = [
|
|
1629
|
-
"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"
|
|
1630
1663
|
];
|
|
1631
1664
|
|
|
1632
1665
|
let $$restProps = compute_rest_props($$props, omit_props_names);
|
|
@@ -1643,6 +1676,7 @@
|
|
|
1643
1676
|
let { results = [] } = $$props;
|
|
1644
1677
|
let { focusAfterSelect = false } = $$props;
|
|
1645
1678
|
let { showDropdownOnFocus = false } = $$props;
|
|
1679
|
+
let { showAllResultsOnFocus = false } = $$props;
|
|
1646
1680
|
let { limit = Infinity } = $$props;
|
|
1647
1681
|
const dispatch = createEventDispatcher();
|
|
1648
1682
|
let comboboxRef = null;
|
|
@@ -1654,11 +1688,11 @@
|
|
|
1654
1688
|
|
|
1655
1689
|
afterUpdate(() => {
|
|
1656
1690
|
if (prevResults !== resultsId && autoselect) {
|
|
1657
|
-
$$invalidate(
|
|
1691
|
+
$$invalidate(10, selectedIndex = getNextNonDisabledIndex());
|
|
1658
1692
|
}
|
|
1659
1693
|
|
|
1660
1694
|
if (prevResults !== resultsId && !$$slots["no-results"]) {
|
|
1661
|
-
$$invalidate(
|
|
1695
|
+
$$invalidate(5, hideDropdown = results.length === 0);
|
|
1662
1696
|
}
|
|
1663
1697
|
|
|
1664
1698
|
prevResults = resultsId;
|
|
@@ -1722,11 +1756,15 @@
|
|
|
1722
1756
|
disabled = results[index].disabled;
|
|
1723
1757
|
}
|
|
1724
1758
|
|
|
1725
|
-
$$invalidate(
|
|
1759
|
+
$$invalidate(10, selectedIndex = index);
|
|
1726
1760
|
}
|
|
1727
1761
|
|
|
1728
|
-
const open = () => $$invalidate(
|
|
1729
|
-
|
|
1762
|
+
const open = () => $$invalidate(5, hideDropdown = false);
|
|
1763
|
+
|
|
1764
|
+
const close = () => {
|
|
1765
|
+
$$invalidate(5, hideDropdown = true);
|
|
1766
|
+
$$invalidate(6, isFocused = false);
|
|
1767
|
+
};
|
|
1730
1768
|
|
|
1731
1769
|
const click_handler = ({ target }) => {
|
|
1732
1770
|
if (!hideDropdown && !comboboxRef?.contains(target)) {
|
|
@@ -1736,7 +1774,7 @@
|
|
|
1736
1774
|
|
|
1737
1775
|
function search_ref_binding(value) {
|
|
1738
1776
|
searchRef = value;
|
|
1739
|
-
$$invalidate(
|
|
1777
|
+
$$invalidate(9, searchRef);
|
|
1740
1778
|
}
|
|
1741
1779
|
|
|
1742
1780
|
function search_value_binding(value$1) {
|
|
@@ -1763,9 +1801,9 @@
|
|
|
1763
1801
|
const focus_handler_1 = () => {
|
|
1764
1802
|
open();
|
|
1765
1803
|
|
|
1766
|
-
if (showDropdownOnFocus) {
|
|
1767
|
-
$$invalidate(
|
|
1768
|
-
$$invalidate(
|
|
1804
|
+
if (showDropdownOnFocus || showAllResultsOnFocus) {
|
|
1805
|
+
$$invalidate(7, showResults = true);
|
|
1806
|
+
$$invalidate(6, isFocused = true);
|
|
1769
1807
|
}
|
|
1770
1808
|
};
|
|
1771
1809
|
|
|
@@ -1807,63 +1845,76 @@
|
|
|
1807
1845
|
|
|
1808
1846
|
const click_handler_1 = (result, index) => {
|
|
1809
1847
|
if (result.disabled) return;
|
|
1810
|
-
$$invalidate(
|
|
1848
|
+
$$invalidate(10, selectedIndex = index);
|
|
1811
1849
|
select();
|
|
1812
1850
|
};
|
|
1813
1851
|
|
|
1814
1852
|
const mouseenter_handler = (result, index) => {
|
|
1815
1853
|
if (result.disabled) return;
|
|
1816
|
-
$$invalidate(
|
|
1854
|
+
$$invalidate(10, selectedIndex = index);
|
|
1817
1855
|
};
|
|
1818
1856
|
|
|
1819
1857
|
function div_binding($$value) {
|
|
1820
1858
|
binding_callbacks[$$value ? 'unshift' : 'push'](() => {
|
|
1821
1859
|
comboboxRef = $$value;
|
|
1822
|
-
$$invalidate(
|
|
1860
|
+
$$invalidate(8, comboboxRef);
|
|
1823
1861
|
});
|
|
1824
1862
|
}
|
|
1825
1863
|
|
|
1826
1864
|
$$self.$$set = $$new_props => {
|
|
1827
1865
|
$$props = assign(assign({}, $$props), exclude_internal_props($$new_props));
|
|
1828
|
-
$$invalidate(
|
|
1866
|
+
$$invalidate(16, $$restProps = compute_rest_props($$props, omit_props_names));
|
|
1829
1867
|
if ('id' in $$new_props) $$invalidate(2, id = $$new_props.id);
|
|
1830
1868
|
if ('value' in $$new_props) $$invalidate(0, value = $$new_props.value);
|
|
1831
|
-
if ('data' in $$new_props) $$invalidate(
|
|
1832
|
-
if ('extract' in $$new_props) $$invalidate(
|
|
1833
|
-
if ('disable' in $$new_props) $$invalidate(
|
|
1834
|
-
if ('filter' in $$new_props) $$invalidate(
|
|
1835
|
-
if ('autoselect' in $$new_props) $$invalidate(
|
|
1836
|
-
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);
|
|
1837
1875
|
if ('results' in $$new_props) $$invalidate(1, results = $$new_props.results);
|
|
1838
|
-
if ('focusAfterSelect' in $$new_props) $$invalidate(
|
|
1876
|
+
if ('focusAfterSelect' in $$new_props) $$invalidate(23, focusAfterSelect = $$new_props.focusAfterSelect);
|
|
1839
1877
|
if ('showDropdownOnFocus' in $$new_props) $$invalidate(3, showDropdownOnFocus = $$new_props.showDropdownOnFocus);
|
|
1840
|
-
if ('
|
|
1841
|
-
if ('
|
|
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);
|
|
1842
1881
|
};
|
|
1843
1882
|
|
|
1844
1883
|
$$self.$$.update = () => {
|
|
1845
|
-
if ($$self.$$.dirty[0] & /*extract*/
|
|
1846
|
-
$$invalidate(
|
|
1884
|
+
if ($$self.$$.dirty[0] & /*extract*/ 262144) {
|
|
1885
|
+
$$invalidate(25, options = { pre: "<mark>", post: "</mark>", extract });
|
|
1847
1886
|
}
|
|
1848
1887
|
|
|
1849
|
-
if ($$self.$$.dirty[0] & /*value, data, options, limit, filter, disable*/
|
|
1888
|
+
if ($$self.$$.dirty[0] & /*value, data, options, limit, filter, disable*/ 52035585) {
|
|
1850
1889
|
$$invalidate(1, results = fuzzy.filter(value, data, options).filter(({ score }) => score > 0).slice(0, limit).filter(result => !filter(result.original)).map(result => ({
|
|
1851
1890
|
...result,
|
|
1852
1891
|
disabled: disable(result.original)
|
|
1853
1892
|
})));
|
|
1854
1893
|
}
|
|
1855
1894
|
|
|
1856
|
-
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) {
|
|
1857
1908
|
resultsId = results.map(result => extract(result.original)).join("");
|
|
1858
1909
|
}
|
|
1859
1910
|
|
|
1860
|
-
if ($$self.$$.dirty[0] & /*hideDropdown, results*/
|
|
1861
|
-
$$invalidate(
|
|
1911
|
+
if ($$self.$$.dirty[0] & /*hideDropdown, results*/ 34) {
|
|
1912
|
+
$$invalidate(7, showResults = !hideDropdown && results.length > 0);
|
|
1862
1913
|
}
|
|
1863
1914
|
|
|
1864
|
-
if ($$self.$$.dirty[0] & /*showDropdownOnFocus, showResults, isFocused*/
|
|
1915
|
+
if ($$self.$$.dirty[0] & /*showDropdownOnFocus, showResults, isFocused*/ 200) {
|
|
1865
1916
|
if (showDropdownOnFocus) {
|
|
1866
|
-
$$invalidate(
|
|
1917
|
+
$$invalidate(7, showResults = showResults && isFocused);
|
|
1867
1918
|
}
|
|
1868
1919
|
}
|
|
1869
1920
|
};
|
|
@@ -1873,6 +1924,7 @@
|
|
|
1873
1924
|
results,
|
|
1874
1925
|
id,
|
|
1875
1926
|
showDropdownOnFocus,
|
|
1927
|
+
showAllResultsOnFocus,
|
|
1876
1928
|
hideDropdown,
|
|
1877
1929
|
isFocused,
|
|
1878
1930
|
showResults,
|
|
@@ -1927,16 +1979,17 @@
|
|
|
1927
1979
|
{
|
|
1928
1980
|
id: 2,
|
|
1929
1981
|
value: 0,
|
|
1930
|
-
data:
|
|
1931
|
-
extract:
|
|
1932
|
-
disable:
|
|
1933
|
-
filter:
|
|
1934
|
-
autoselect:
|
|
1935
|
-
inputAfterSelect:
|
|
1982
|
+
data: 17,
|
|
1983
|
+
extract: 18,
|
|
1984
|
+
disable: 19,
|
|
1985
|
+
filter: 20,
|
|
1986
|
+
autoselect: 21,
|
|
1987
|
+
inputAfterSelect: 22,
|
|
1936
1988
|
results: 1,
|
|
1937
|
-
focusAfterSelect:
|
|
1989
|
+
focusAfterSelect: 23,
|
|
1938
1990
|
showDropdownOnFocus: 3,
|
|
1939
|
-
|
|
1991
|
+
showAllResultsOnFocus: 4,
|
|
1992
|
+
limit: 24
|
|
1940
1993
|
},
|
|
1941
1994
|
add_css,
|
|
1942
1995
|
[-1, -1]
|