svelte-typeahead 4.2.0 → 4.2.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +26 -0
- package/README.md +43 -59
- package/lib/index.js +167 -107
- package/lib/index.mjs +163 -103
- package/package.json +5 -5
- package/src/Typeahead.svelte +31 -9
- package/types/Typeahead.svelte.d.ts +1 -0
package/lib/index.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
(function (global, factory) {
|
|
2
2
|
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) :
|
|
3
3
|
typeof define === 'function' && define.amd ? define(['exports'], factory) :
|
|
4
|
-
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global[
|
|
5
|
-
}(this, (function (exports) { 'use strict';
|
|
4
|
+
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global["svelte-typeahead"] = {}));
|
|
5
|
+
})(this, (function (exports) { 'use strict';
|
|
6
6
|
|
|
7
7
|
function noop() { }
|
|
8
8
|
function assign(tar, src) {
|
|
@@ -136,6 +136,9 @@
|
|
|
136
136
|
function element(name) {
|
|
137
137
|
return document.createElement(name);
|
|
138
138
|
}
|
|
139
|
+
function svg_element(name) {
|
|
140
|
+
return document.createElementNS('http://www.w3.org/2000/svg', name);
|
|
141
|
+
}
|
|
139
142
|
function text(data) {
|
|
140
143
|
return document.createTextNode(data);
|
|
141
144
|
}
|
|
@@ -197,13 +200,15 @@
|
|
|
197
200
|
function toggle_class(element, name, toggle) {
|
|
198
201
|
element.classList[toggle ? 'add' : 'remove'](name);
|
|
199
202
|
}
|
|
200
|
-
function custom_event(type, detail, bubbles = false) {
|
|
203
|
+
function custom_event(type, detail, { bubbles = false, cancelable = false } = {}) {
|
|
201
204
|
const e = document.createEvent('CustomEvent');
|
|
202
|
-
e.initCustomEvent(type, bubbles,
|
|
205
|
+
e.initCustomEvent(type, bubbles, cancelable, detail);
|
|
203
206
|
return e;
|
|
204
207
|
}
|
|
205
208
|
class HtmlTag {
|
|
206
|
-
constructor() {
|
|
209
|
+
constructor(is_svg = false) {
|
|
210
|
+
this.is_svg = false;
|
|
211
|
+
this.is_svg = is_svg;
|
|
207
212
|
this.e = this.n = null;
|
|
208
213
|
}
|
|
209
214
|
c(html) {
|
|
@@ -211,7 +216,10 @@
|
|
|
211
216
|
}
|
|
212
217
|
m(html, target, anchor = null) {
|
|
213
218
|
if (!this.e) {
|
|
214
|
-
|
|
219
|
+
if (this.is_svg)
|
|
220
|
+
this.e = svg_element(target.nodeName);
|
|
221
|
+
else
|
|
222
|
+
this.e = element(target.nodeName);
|
|
215
223
|
this.t = target;
|
|
216
224
|
this.c(html);
|
|
217
225
|
}
|
|
@@ -253,16 +261,18 @@
|
|
|
253
261
|
}
|
|
254
262
|
function createEventDispatcher() {
|
|
255
263
|
const component = get_current_component();
|
|
256
|
-
return (type, detail) => {
|
|
264
|
+
return (type, detail, { cancelable = false } = {}) => {
|
|
257
265
|
const callbacks = component.$$.callbacks[type];
|
|
258
266
|
if (callbacks) {
|
|
259
267
|
// TODO are there situations where events could be dispatched
|
|
260
268
|
// in a server (non-DOM) environment?
|
|
261
|
-
const event = custom_event(type, detail);
|
|
269
|
+
const event = custom_event(type, detail, { cancelable });
|
|
262
270
|
callbacks.slice().forEach(fn => {
|
|
263
271
|
fn.call(component, event);
|
|
264
272
|
});
|
|
273
|
+
return !event.defaultPrevented;
|
|
265
274
|
}
|
|
275
|
+
return true;
|
|
266
276
|
};
|
|
267
277
|
}
|
|
268
278
|
// TODO figure out if we still want to support
|
|
@@ -298,22 +308,40 @@
|
|
|
298
308
|
function add_flush_callback(fn) {
|
|
299
309
|
flush_callbacks.push(fn);
|
|
300
310
|
}
|
|
301
|
-
|
|
311
|
+
// flush() calls callbacks in this order:
|
|
312
|
+
// 1. All beforeUpdate callbacks, in order: parents before children
|
|
313
|
+
// 2. All bind:this callbacks, in reverse order: children before parents.
|
|
314
|
+
// 3. All afterUpdate callbacks, in order: parents before children. EXCEPT
|
|
315
|
+
// for afterUpdates called during the initial onMount, which are called in
|
|
316
|
+
// reverse order: children before parents.
|
|
317
|
+
// Since callbacks might update component values, which could trigger another
|
|
318
|
+
// call to flush(), the following steps guard against this:
|
|
319
|
+
// 1. During beforeUpdate, any updated components will be added to the
|
|
320
|
+
// dirty_components array and will cause a reentrant call to flush(). Because
|
|
321
|
+
// the flush index is kept outside the function, the reentrant call will pick
|
|
322
|
+
// up where the earlier call left off and go through all dirty components. The
|
|
323
|
+
// current_component value is saved and restored so that the reentrant call will
|
|
324
|
+
// not interfere with the "parent" flush() call.
|
|
325
|
+
// 2. bind:this callbacks cannot trigger new flush() calls.
|
|
326
|
+
// 3. During afterUpdate, any updated components will NOT have their afterUpdate
|
|
327
|
+
// callback called a second time; the seen_callbacks set, outside the flush()
|
|
328
|
+
// function, guarantees this behavior.
|
|
302
329
|
const seen_callbacks = new Set();
|
|
330
|
+
let flushidx = 0; // Do *not* move this inside the flush() function
|
|
303
331
|
function flush() {
|
|
304
|
-
|
|
305
|
-
return;
|
|
306
|
-
flushing = true;
|
|
332
|
+
const saved_component = current_component;
|
|
307
333
|
do {
|
|
308
334
|
// first, call beforeUpdate functions
|
|
309
335
|
// and update components
|
|
310
|
-
|
|
311
|
-
const component = dirty_components[
|
|
336
|
+
while (flushidx < dirty_components.length) {
|
|
337
|
+
const component = dirty_components[flushidx];
|
|
338
|
+
flushidx++;
|
|
312
339
|
set_current_component(component);
|
|
313
340
|
update(component.$$);
|
|
314
341
|
}
|
|
315
342
|
set_current_component(null);
|
|
316
343
|
dirty_components.length = 0;
|
|
344
|
+
flushidx = 0;
|
|
317
345
|
while (binding_callbacks.length)
|
|
318
346
|
binding_callbacks.pop()();
|
|
319
347
|
// then, once components are updated, call
|
|
@@ -333,8 +361,8 @@
|
|
|
333
361
|
flush_callbacks.pop()();
|
|
334
362
|
}
|
|
335
363
|
update_scheduled = false;
|
|
336
|
-
flushing = false;
|
|
337
364
|
seen_callbacks.clear();
|
|
365
|
+
set_current_component(saved_component);
|
|
338
366
|
}
|
|
339
367
|
function update($$) {
|
|
340
368
|
if ($$.fragment !== null) {
|
|
@@ -703,7 +731,7 @@
|
|
|
703
731
|
|
|
704
732
|
var fuzzy = fuzzy$1.exports;
|
|
705
733
|
|
|
706
|
-
/* node_modules/svelte-search/src/Search.svelte generated by Svelte v3.
|
|
734
|
+
/* node_modules/svelte-search/src/Search.svelte generated by Svelte v3.48.0 */
|
|
707
735
|
|
|
708
736
|
function add_css$1(target) {
|
|
709
737
|
append_styles(target, "svelte-5m0wg6", ".hide-label.svelte-5m0wg6{position:absolute;height:1px;width:1px;overflow:hidden;clip:rect(1px 1px 1px 1px);clip:rect(1px, 1px, 1px, 1px);white-space:nowrap}");
|
|
@@ -1040,7 +1068,7 @@
|
|
|
1040
1068
|
|
|
1041
1069
|
var Search$1 = Search;
|
|
1042
1070
|
|
|
1043
|
-
/* src/Typeahead.svelte generated by Svelte v3.
|
|
1071
|
+
/* src/Typeahead.svelte generated by Svelte v3.48.0 */
|
|
1044
1072
|
|
|
1045
1073
|
function add_css(target) {
|
|
1046
1074
|
append_styles(target, "svelte-j5n77y", "[data-svelte-typeahead].svelte-j5n77y{position:relative;background-color:#fff}ul.svelte-j5n77y{position:absolute;top:100%;left:0;width:100%;padding:0;list-style:none;background-color:inherit;box-shadow:0 4px 8px rgba(0, 0, 0, 0.1)}li.svelte-j5n77y,.no-results.svelte-j5n77y{padding:0.25rem 1rem}li.svelte-j5n77y{cursor:pointer}li.svelte-j5n77y:not(:last-of-type){border-bottom:1px solid #e0e0e0}li.svelte-j5n77y:hover{background-color:#e5e5e5}.selected.svelte-j5n77y{background-color:#e5e5e5}.selected.svelte-j5n77y:hover{background-color:#cacaca}.disabled.svelte-j5n77y{opacity:0.4;cursor:not-allowed}[data-svelte-search] label{margin-bottom:0.25rem;display:inline-flex;font-size:0.875rem}[data-svelte-search] input{width:100%;padding:0.5rem 0.75rem;background:none;font-size:1rem;border:0;border-radius:0;border:1px solid #e5e5e5}[data-svelte-search] input:focus{outline-color:#0f62fe;outline-offset:2px;outline-width:1px}");
|
|
@@ -1053,14 +1081,14 @@
|
|
|
1053
1081
|
|
|
1054
1082
|
const get_no_results_slot_context = ctx => ({
|
|
1055
1083
|
value: /*value*/ ctx[0],
|
|
1056
|
-
result: /*result*/ ctx[
|
|
1057
|
-
index: /*i*/ ctx[
|
|
1084
|
+
result: /*result*/ ctx[41],
|
|
1085
|
+
index: /*i*/ ctx[43]
|
|
1058
1086
|
});
|
|
1059
1087
|
|
|
1060
1088
|
function get_each_context(ctx, list, i) {
|
|
1061
1089
|
const child_ctx = ctx.slice();
|
|
1062
|
-
child_ctx[
|
|
1063
|
-
child_ctx[
|
|
1090
|
+
child_ctx[41] = list[i];
|
|
1091
|
+
child_ctx[43] = i;
|
|
1064
1092
|
return child_ctx;
|
|
1065
1093
|
}
|
|
1066
1094
|
|
|
@@ -1070,12 +1098,12 @@
|
|
|
1070
1098
|
});
|
|
1071
1099
|
|
|
1072
1100
|
const get_default_slot_context = ctx => ({
|
|
1073
|
-
result: /*result*/ ctx[
|
|
1074
|
-
index: /*i*/ ctx[
|
|
1101
|
+
result: /*result*/ ctx[41],
|
|
1102
|
+
index: /*i*/ ctx[43],
|
|
1075
1103
|
value: /*value*/ ctx[0]
|
|
1076
1104
|
});
|
|
1077
1105
|
|
|
1078
|
-
// (
|
|
1106
|
+
// (198:4) {#if !hideDropdown && results.length > 0}
|
|
1079
1107
|
function create_if_block_1(ctx) {
|
|
1080
1108
|
let each_1_anchor;
|
|
1081
1109
|
let current;
|
|
@@ -1107,7 +1135,7 @@
|
|
|
1107
1135
|
current = true;
|
|
1108
1136
|
},
|
|
1109
1137
|
p(ctx, dirty) {
|
|
1110
|
-
if (dirty[0] & /*id, selectedIndex, results, select, $$scope, value*/
|
|
1138
|
+
if (dirty[0] & /*id, selectedIndex, results, select, $$scope, value*/ 1048775) {
|
|
1111
1139
|
each_value = /*results*/ ctx[1];
|
|
1112
1140
|
let i;
|
|
1113
1141
|
|
|
@@ -1159,15 +1187,15 @@
|
|
|
1159
1187
|
};
|
|
1160
1188
|
}
|
|
1161
1189
|
|
|
1162
|
-
// (
|
|
1190
|
+
// (217:43)
|
|
1163
1191
|
function fallback_block(ctx) {
|
|
1164
1192
|
let html_tag;
|
|
1165
|
-
let raw_value = /*result*/ ctx[
|
|
1193
|
+
let raw_value = /*result*/ ctx[41].string + "";
|
|
1166
1194
|
let html_anchor;
|
|
1167
1195
|
|
|
1168
1196
|
return {
|
|
1169
1197
|
c() {
|
|
1170
|
-
html_tag = new HtmlTag();
|
|
1198
|
+
html_tag = new HtmlTag(false);
|
|
1171
1199
|
html_anchor = empty();
|
|
1172
1200
|
html_tag.a = html_anchor;
|
|
1173
1201
|
},
|
|
@@ -1176,7 +1204,7 @@
|
|
|
1176
1204
|
insert(target, html_anchor, anchor);
|
|
1177
1205
|
},
|
|
1178
1206
|
p(ctx, dirty) {
|
|
1179
|
-
if (dirty[0] & /*results*/ 2 && raw_value !== (raw_value = /*result*/ ctx[
|
|
1207
|
+
if (dirty[0] & /*results*/ 2 && raw_value !== (raw_value = /*result*/ ctx[41].string + "")) html_tag.p(raw_value);
|
|
1180
1208
|
},
|
|
1181
1209
|
d(detaching) {
|
|
1182
1210
|
if (detaching) detach(html_anchor);
|
|
@@ -1185,7 +1213,7 @@
|
|
|
1185
1213
|
};
|
|
1186
1214
|
}
|
|
1187
1215
|
|
|
1188
|
-
// (
|
|
1216
|
+
// (199:6) {#each results as result, i}
|
|
1189
1217
|
function create_each_block(ctx) {
|
|
1190
1218
|
let li;
|
|
1191
1219
|
let t;
|
|
@@ -1194,12 +1222,16 @@
|
|
|
1194
1222
|
let current;
|
|
1195
1223
|
let mounted;
|
|
1196
1224
|
let dispose;
|
|
1197
|
-
const default_slot_template = /*#slots*/ ctx[
|
|
1198
|
-
const default_slot = create_slot(default_slot_template, ctx, /*$$scope*/ ctx[
|
|
1225
|
+
const default_slot_template = /*#slots*/ ctx[21].default;
|
|
1226
|
+
const default_slot = create_slot(default_slot_template, ctx, /*$$scope*/ ctx[20], get_default_slot_context);
|
|
1199
1227
|
const default_slot_or_fallback = default_slot || fallback_block(ctx);
|
|
1200
1228
|
|
|
1201
1229
|
function click_handler_1() {
|
|
1202
|
-
return /*click_handler_1*/ ctx[
|
|
1230
|
+
return /*click_handler_1*/ ctx[35](/*result*/ ctx[41], /*i*/ ctx[43]);
|
|
1231
|
+
}
|
|
1232
|
+
|
|
1233
|
+
function mouseenter_handler() {
|
|
1234
|
+
return /*mouseenter_handler*/ ctx[36](/*result*/ ctx[41], /*i*/ ctx[43]);
|
|
1203
1235
|
}
|
|
1204
1236
|
|
|
1205
1237
|
return {
|
|
@@ -1208,11 +1240,11 @@
|
|
|
1208
1240
|
if (default_slot_or_fallback) default_slot_or_fallback.c();
|
|
1209
1241
|
t = space();
|
|
1210
1242
|
attr(li, "role", "option");
|
|
1211
|
-
attr(li, "id", li_id_value = "" + (/*id*/ ctx[2] + "-result-" + /*i*/ ctx[
|
|
1212
|
-
attr(li, "aria-selected", li_aria_selected_value = /*selectedIndex*/ ctx[6] === /*i*/ ctx[
|
|
1243
|
+
attr(li, "id", li_id_value = "" + (/*id*/ ctx[2] + "-result-" + /*i*/ ctx[43]));
|
|
1244
|
+
attr(li, "aria-selected", li_aria_selected_value = /*selectedIndex*/ ctx[6] === /*i*/ ctx[43]);
|
|
1213
1245
|
attr(li, "class", "svelte-j5n77y");
|
|
1214
|
-
toggle_class(li, "selected", /*selectedIndex*/ ctx[6] === /*i*/ ctx[
|
|
1215
|
-
toggle_class(li, "disabled", /*result*/ ctx[
|
|
1246
|
+
toggle_class(li, "selected", /*selectedIndex*/ ctx[6] === /*i*/ ctx[43]);
|
|
1247
|
+
toggle_class(li, "disabled", /*result*/ ctx[41].disabled);
|
|
1216
1248
|
},
|
|
1217
1249
|
m(target, anchor) {
|
|
1218
1250
|
insert(target, li, anchor);
|
|
@@ -1225,7 +1257,11 @@
|
|
|
1225
1257
|
current = true;
|
|
1226
1258
|
|
|
1227
1259
|
if (!mounted) {
|
|
1228
|
-
dispose =
|
|
1260
|
+
dispose = [
|
|
1261
|
+
listen(li, "click", click_handler_1),
|
|
1262
|
+
listen(li, "mouseenter", mouseenter_handler)
|
|
1263
|
+
];
|
|
1264
|
+
|
|
1229
1265
|
mounted = true;
|
|
1230
1266
|
}
|
|
1231
1267
|
},
|
|
@@ -1233,15 +1269,15 @@
|
|
|
1233
1269
|
ctx = new_ctx;
|
|
1234
1270
|
|
|
1235
1271
|
if (default_slot) {
|
|
1236
|
-
if (default_slot.p && (!current || dirty[0] & /*$$scope, results, value*/
|
|
1272
|
+
if (default_slot.p && (!current || dirty[0] & /*$$scope, results, value*/ 1048579)) {
|
|
1237
1273
|
update_slot_base(
|
|
1238
1274
|
default_slot,
|
|
1239
1275
|
default_slot_template,
|
|
1240
1276
|
ctx,
|
|
1241
|
-
/*$$scope*/ ctx[
|
|
1277
|
+
/*$$scope*/ ctx[20],
|
|
1242
1278
|
!current
|
|
1243
|
-
? get_all_dirty_from_scope(/*$$scope*/ ctx[
|
|
1244
|
-
: get_slot_changes(default_slot_template, /*$$scope*/ ctx[
|
|
1279
|
+
? get_all_dirty_from_scope(/*$$scope*/ ctx[20])
|
|
1280
|
+
: get_slot_changes(default_slot_template, /*$$scope*/ ctx[20], dirty, get_default_slot_changes),
|
|
1245
1281
|
get_default_slot_context
|
|
1246
1282
|
);
|
|
1247
1283
|
}
|
|
@@ -1251,20 +1287,20 @@
|
|
|
1251
1287
|
}
|
|
1252
1288
|
}
|
|
1253
1289
|
|
|
1254
|
-
if (!current || dirty[0] & /*id*/ 4 && li_id_value !== (li_id_value = "" + (/*id*/ ctx[2] + "-result-" + /*i*/ ctx[
|
|
1290
|
+
if (!current || dirty[0] & /*id*/ 4 && li_id_value !== (li_id_value = "" + (/*id*/ ctx[2] + "-result-" + /*i*/ ctx[43]))) {
|
|
1255
1291
|
attr(li, "id", li_id_value);
|
|
1256
1292
|
}
|
|
1257
1293
|
|
|
1258
|
-
if (!current || dirty[0] & /*selectedIndex*/ 64 && li_aria_selected_value !== (li_aria_selected_value = /*selectedIndex*/ ctx[6] === /*i*/ ctx[
|
|
1294
|
+
if (!current || dirty[0] & /*selectedIndex*/ 64 && li_aria_selected_value !== (li_aria_selected_value = /*selectedIndex*/ ctx[6] === /*i*/ ctx[43])) {
|
|
1259
1295
|
attr(li, "aria-selected", li_aria_selected_value);
|
|
1260
1296
|
}
|
|
1261
1297
|
|
|
1262
1298
|
if (dirty[0] & /*selectedIndex*/ 64) {
|
|
1263
|
-
toggle_class(li, "selected", /*selectedIndex*/ ctx[6] === /*i*/ ctx[
|
|
1299
|
+
toggle_class(li, "selected", /*selectedIndex*/ ctx[6] === /*i*/ ctx[43]);
|
|
1264
1300
|
}
|
|
1265
1301
|
|
|
1266
1302
|
if (dirty[0] & /*results*/ 2) {
|
|
1267
|
-
toggle_class(li, "disabled", /*result*/ ctx[
|
|
1303
|
+
toggle_class(li, "disabled", /*result*/ ctx[41].disabled);
|
|
1268
1304
|
}
|
|
1269
1305
|
},
|
|
1270
1306
|
i(local) {
|
|
@@ -1280,17 +1316,17 @@
|
|
|
1280
1316
|
if (detaching) detach(li);
|
|
1281
1317
|
if (default_slot_or_fallback) default_slot_or_fallback.d(detaching);
|
|
1282
1318
|
mounted = false;
|
|
1283
|
-
dispose
|
|
1319
|
+
run_all(dispose);
|
|
1284
1320
|
}
|
|
1285
1321
|
};
|
|
1286
1322
|
}
|
|
1287
1323
|
|
|
1288
|
-
// (
|
|
1324
|
+
// (223:4) {#if $$slots["no-results"] && !hideDropdown && value.length > 0 && results.length === 0}
|
|
1289
1325
|
function create_if_block(ctx) {
|
|
1290
1326
|
let div;
|
|
1291
1327
|
let current;
|
|
1292
|
-
const no_results_slot_template = /*#slots*/ ctx[
|
|
1293
|
-
const no_results_slot = create_slot(no_results_slot_template, ctx, /*$$scope*/ ctx[
|
|
1328
|
+
const no_results_slot_template = /*#slots*/ ctx[21]["no-results"];
|
|
1329
|
+
const no_results_slot = create_slot(no_results_slot_template, ctx, /*$$scope*/ ctx[20], get_no_results_slot_context);
|
|
1294
1330
|
|
|
1295
1331
|
return {
|
|
1296
1332
|
c() {
|
|
@@ -1310,15 +1346,15 @@
|
|
|
1310
1346
|
},
|
|
1311
1347
|
p(ctx, dirty) {
|
|
1312
1348
|
if (no_results_slot) {
|
|
1313
|
-
if (no_results_slot.p && (!current || dirty[0] & /*$$scope, value, results*/
|
|
1349
|
+
if (no_results_slot.p && (!current || dirty[0] & /*$$scope, value, results*/ 1048579)) {
|
|
1314
1350
|
update_slot_base(
|
|
1315
1351
|
no_results_slot,
|
|
1316
1352
|
no_results_slot_template,
|
|
1317
1353
|
ctx,
|
|
1318
|
-
/*$$scope*/ ctx[
|
|
1354
|
+
/*$$scope*/ ctx[20],
|
|
1319
1355
|
!current
|
|
1320
|
-
? get_all_dirty_from_scope(/*$$scope*/ ctx[
|
|
1321
|
-
: get_slot_changes(no_results_slot_template, /*$$scope*/ ctx[
|
|
1356
|
+
? get_all_dirty_from_scope(/*$$scope*/ ctx[20])
|
|
1357
|
+
: get_slot_changes(no_results_slot_template, /*$$scope*/ ctx[20], dirty, get_no_results_slot_changes),
|
|
1322
1358
|
get_no_results_slot_context
|
|
1323
1359
|
);
|
|
1324
1360
|
}
|
|
@@ -1360,7 +1396,7 @@
|
|
|
1360
1396
|
const search_spread_levels = [
|
|
1361
1397
|
{ id: /*id*/ ctx[2] },
|
|
1362
1398
|
{ removeFormAriaAttributes: true },
|
|
1363
|
-
/*$$restProps*/ ctx[
|
|
1399
|
+
/*$$restProps*/ ctx[10],
|
|
1364
1400
|
{ "aria-autocomplete": "list" },
|
|
1365
1401
|
{
|
|
1366
1402
|
"aria-controls": "" + (/*id*/ ctx[2] + "-listbox")
|
|
@@ -1376,11 +1412,11 @@
|
|
|
1376
1412
|
];
|
|
1377
1413
|
|
|
1378
1414
|
function search_ref_binding(value) {
|
|
1379
|
-
/*search_ref_binding*/ ctx[
|
|
1415
|
+
/*search_ref_binding*/ ctx[23](value);
|
|
1380
1416
|
}
|
|
1381
1417
|
|
|
1382
1418
|
function search_value_binding(value) {
|
|
1383
|
-
/*search_value_binding*/ ctx[
|
|
1419
|
+
/*search_value_binding*/ ctx[24](value);
|
|
1384
1420
|
}
|
|
1385
1421
|
|
|
1386
1422
|
let search_props = {};
|
|
@@ -1400,18 +1436,18 @@
|
|
|
1400
1436
|
search = new Search$1({ props: search_props });
|
|
1401
1437
|
binding_callbacks.push(() => bind(search, 'ref', search_ref_binding));
|
|
1402
1438
|
binding_callbacks.push(() => bind(search, 'value', search_value_binding));
|
|
1403
|
-
search.$on("type", /*type_handler*/ ctx[
|
|
1404
|
-
search.$on("input", /*input_handler*/ ctx[
|
|
1405
|
-
search.$on("change", /*change_handler*/ ctx[
|
|
1406
|
-
search.$on("focus", /*focus_handler*/ ctx[
|
|
1407
|
-
search.$on("focus", /*focus_handler_1*/ ctx[
|
|
1408
|
-
search.$on("clear", /*clear_handler*/ ctx[
|
|
1409
|
-
search.$on("clear", /*clear_handler_1*/ ctx[
|
|
1410
|
-
search.$on("blur", /*blur_handler*/ ctx[
|
|
1411
|
-
search.$on("keydown", /*keydown_handler*/ ctx[
|
|
1412
|
-
search.$on("keydown", /*keydown_handler_1*/ ctx[
|
|
1439
|
+
search.$on("type", /*type_handler*/ ctx[25]);
|
|
1440
|
+
search.$on("input", /*input_handler*/ ctx[26]);
|
|
1441
|
+
search.$on("change", /*change_handler*/ ctx[27]);
|
|
1442
|
+
search.$on("focus", /*focus_handler*/ ctx[28]);
|
|
1443
|
+
search.$on("focus", /*focus_handler_1*/ ctx[29]);
|
|
1444
|
+
search.$on("clear", /*clear_handler*/ ctx[30]);
|
|
1445
|
+
search.$on("clear", /*clear_handler_1*/ ctx[31]);
|
|
1446
|
+
search.$on("blur", /*blur_handler*/ ctx[32]);
|
|
1447
|
+
search.$on("keydown", /*keydown_handler*/ ctx[33]);
|
|
1448
|
+
search.$on("keydown", /*keydown_handler_1*/ ctx[34]);
|
|
1413
1449
|
let if_block0 = !/*hideDropdown*/ ctx[5] && /*results*/ ctx[1].length > 0 && create_if_block_1(ctx);
|
|
1414
|
-
let if_block1 = /*$$slots*/ ctx[
|
|
1450
|
+
let if_block1 = /*$$slots*/ ctx[9]["no-results"] && !/*hideDropdown*/ ctx[5] && /*value*/ ctx[0].length > 0 && /*results*/ ctx[1].length === 0 && create_if_block(ctx);
|
|
1415
1451
|
|
|
1416
1452
|
return {
|
|
1417
1453
|
c() {
|
|
@@ -1444,20 +1480,20 @@
|
|
|
1444
1480
|
if (if_block0) if_block0.m(ul, null);
|
|
1445
1481
|
append(ul, t1);
|
|
1446
1482
|
if (if_block1) if_block1.m(ul, null);
|
|
1447
|
-
/*div_binding*/ ctx[
|
|
1483
|
+
/*div_binding*/ ctx[37](div);
|
|
1448
1484
|
current = true;
|
|
1449
1485
|
|
|
1450
1486
|
if (!mounted) {
|
|
1451
|
-
dispose = listen(window, "click", /*click_handler*/ ctx[
|
|
1487
|
+
dispose = listen(window, "click", /*click_handler*/ ctx[22]);
|
|
1452
1488
|
mounted = true;
|
|
1453
1489
|
}
|
|
1454
1490
|
},
|
|
1455
1491
|
p(ctx, dirty) {
|
|
1456
|
-
const search_changes = (dirty[0] & /*id, $$restProps, selectedIndex, hideDropdown, results*/
|
|
1492
|
+
const search_changes = (dirty[0] & /*id, $$restProps, selectedIndex, hideDropdown, results*/ 1126)
|
|
1457
1493
|
? get_spread_update(search_spread_levels, [
|
|
1458
1494
|
dirty[0] & /*id*/ 4 && { id: /*id*/ ctx[2] },
|
|
1459
1495
|
search_spread_levels[1],
|
|
1460
|
-
dirty[0] & /*$$restProps*/
|
|
1496
|
+
dirty[0] & /*$$restProps*/ 1024 && get_spread_object(/*$$restProps*/ ctx[10]),
|
|
1461
1497
|
search_spread_levels[3],
|
|
1462
1498
|
dirty[0] & /*id*/ 4 && {
|
|
1463
1499
|
"aria-controls": "" + (/*id*/ ctx[2] + "-listbox")
|
|
@@ -1510,11 +1546,11 @@
|
|
|
1510
1546
|
check_outros();
|
|
1511
1547
|
}
|
|
1512
1548
|
|
|
1513
|
-
if (/*$$slots*/ ctx[
|
|
1549
|
+
if (/*$$slots*/ ctx[9]["no-results"] && !/*hideDropdown*/ ctx[5] && /*value*/ ctx[0].length > 0 && /*results*/ ctx[1].length === 0) {
|
|
1514
1550
|
if (if_block1) {
|
|
1515
1551
|
if_block1.p(ctx, dirty);
|
|
1516
1552
|
|
|
1517
|
-
if (dirty[0] & /*$$slots, hideDropdown, value, results*/
|
|
1553
|
+
if (dirty[0] & /*$$slots, hideDropdown, value, results*/ 547) {
|
|
1518
1554
|
transition_in(if_block1, 1);
|
|
1519
1555
|
}
|
|
1520
1556
|
} else {
|
|
@@ -1575,7 +1611,7 @@
|
|
|
1575
1611
|
destroy_component(search);
|
|
1576
1612
|
if (if_block0) if_block0.d();
|
|
1577
1613
|
if (if_block1) if_block1.d();
|
|
1578
|
-
/*div_binding*/ ctx[
|
|
1614
|
+
/*div_binding*/ ctx[37](null);
|
|
1579
1615
|
mounted = false;
|
|
1580
1616
|
dispose();
|
|
1581
1617
|
}
|
|
@@ -1625,6 +1661,7 @@
|
|
|
1625
1661
|
|
|
1626
1662
|
async function select() {
|
|
1627
1663
|
const result = results[selectedIndex];
|
|
1664
|
+
if (result.disabled) return;
|
|
1628
1665
|
const selectedValue = extract(result.original);
|
|
1629
1666
|
const searchedValue = value;
|
|
1630
1667
|
if (inputAfterSelect == "clear") $$invalidate(0, value = "");
|
|
@@ -1643,6 +1680,28 @@
|
|
|
1643
1680
|
$$invalidate(5, hideDropdown = true);
|
|
1644
1681
|
}
|
|
1645
1682
|
|
|
1683
|
+
/** @type {(direction: -1 | 1) => void} */
|
|
1684
|
+
function change(direction) {
|
|
1685
|
+
let index = direction === 1 && selectedIndex === results.length - 1
|
|
1686
|
+
? 0
|
|
1687
|
+
: selectedIndex + direction;
|
|
1688
|
+
|
|
1689
|
+
if (index < 0) index = results.length - 1;
|
|
1690
|
+
let disabled = results[index].disabled;
|
|
1691
|
+
|
|
1692
|
+
while (disabled) {
|
|
1693
|
+
if (index === results.length) {
|
|
1694
|
+
index = 0;
|
|
1695
|
+
} else {
|
|
1696
|
+
index += direction;
|
|
1697
|
+
}
|
|
1698
|
+
|
|
1699
|
+
disabled = results[index].disabled;
|
|
1700
|
+
}
|
|
1701
|
+
|
|
1702
|
+
$$invalidate(6, selectedIndex = index);
|
|
1703
|
+
}
|
|
1704
|
+
|
|
1646
1705
|
const click_handler = ({ target }) => {
|
|
1647
1706
|
if (!hideDropdown && comboboxRef && !comboboxRef.contains(target)) {
|
|
1648
1707
|
$$invalidate(5, hideDropdown = true);
|
|
@@ -1704,17 +1763,11 @@
|
|
|
1704
1763
|
break;
|
|
1705
1764
|
case "ArrowDown":
|
|
1706
1765
|
e.preventDefault();
|
|
1707
|
-
|
|
1708
|
-
if (selectedIndex === results.length) {
|
|
1709
|
-
$$invalidate(6, selectedIndex = 0);
|
|
1710
|
-
}
|
|
1766
|
+
change(1);
|
|
1711
1767
|
break;
|
|
1712
1768
|
case "ArrowUp":
|
|
1713
1769
|
e.preventDefault();
|
|
1714
|
-
|
|
1715
|
-
if (selectedIndex < 0) {
|
|
1716
|
-
$$invalidate(6, selectedIndex = results.length - 1);
|
|
1717
|
-
}
|
|
1770
|
+
change(-1);
|
|
1718
1771
|
break;
|
|
1719
1772
|
case "Escape":
|
|
1720
1773
|
e.preventDefault();
|
|
@@ -1732,6 +1785,11 @@
|
|
|
1732
1785
|
}
|
|
1733
1786
|
};
|
|
1734
1787
|
|
|
1788
|
+
const mouseenter_handler = (result, i) => {
|
|
1789
|
+
if (result.disabled) return;
|
|
1790
|
+
$$invalidate(6, selectedIndex = i);
|
|
1791
|
+
};
|
|
1792
|
+
|
|
1735
1793
|
function div_binding($$value) {
|
|
1736
1794
|
binding_callbacks[$$value ? 'unshift' : 'push'](() => {
|
|
1737
1795
|
comboboxRef = $$value;
|
|
@@ -1741,34 +1799,34 @@
|
|
|
1741
1799
|
|
|
1742
1800
|
$$self.$$set = $$new_props => {
|
|
1743
1801
|
$$props = assign(assign({}, $$props), exclude_internal_props($$new_props));
|
|
1744
|
-
$$invalidate(
|
|
1802
|
+
$$invalidate(10, $$restProps = compute_rest_props($$props, omit_props_names));
|
|
1745
1803
|
if ('id' in $$new_props) $$invalidate(2, id = $$new_props.id);
|
|
1746
1804
|
if ('value' in $$new_props) $$invalidate(0, value = $$new_props.value);
|
|
1747
|
-
if ('data' in $$new_props) $$invalidate(
|
|
1748
|
-
if ('extract' in $$new_props) $$invalidate(
|
|
1749
|
-
if ('disable' in $$new_props) $$invalidate(
|
|
1750
|
-
if ('filter' in $$new_props) $$invalidate(
|
|
1751
|
-
if ('autoselect' in $$new_props) $$invalidate(
|
|
1752
|
-
if ('inputAfterSelect' in $$new_props) $$invalidate(
|
|
1805
|
+
if ('data' in $$new_props) $$invalidate(11, data = $$new_props.data);
|
|
1806
|
+
if ('extract' in $$new_props) $$invalidate(12, extract = $$new_props.extract);
|
|
1807
|
+
if ('disable' in $$new_props) $$invalidate(13, disable = $$new_props.disable);
|
|
1808
|
+
if ('filter' in $$new_props) $$invalidate(14, filter = $$new_props.filter);
|
|
1809
|
+
if ('autoselect' in $$new_props) $$invalidate(15, autoselect = $$new_props.autoselect);
|
|
1810
|
+
if ('inputAfterSelect' in $$new_props) $$invalidate(16, inputAfterSelect = $$new_props.inputAfterSelect);
|
|
1753
1811
|
if ('results' in $$new_props) $$invalidate(1, results = $$new_props.results);
|
|
1754
|
-
if ('focusAfterSelect' in $$new_props) $$invalidate(
|
|
1755
|
-
if ('limit' in $$new_props) $$invalidate(
|
|
1756
|
-
if ('$$scope' in $$new_props) $$invalidate(
|
|
1812
|
+
if ('focusAfterSelect' in $$new_props) $$invalidate(17, focusAfterSelect = $$new_props.focusAfterSelect);
|
|
1813
|
+
if ('limit' in $$new_props) $$invalidate(18, limit = $$new_props.limit);
|
|
1814
|
+
if ('$$scope' in $$new_props) $$invalidate(20, $$scope = $$new_props.$$scope);
|
|
1757
1815
|
};
|
|
1758
1816
|
|
|
1759
1817
|
$$self.$$.update = () => {
|
|
1760
|
-
if ($$self.$$.dirty[0] & /*extract*/
|
|
1761
|
-
$$invalidate(
|
|
1818
|
+
if ($$self.$$.dirty[0] & /*extract*/ 4096) {
|
|
1819
|
+
$$invalidate(19, options = { pre: "<mark>", post: "</mark>", extract });
|
|
1762
1820
|
}
|
|
1763
1821
|
|
|
1764
|
-
if ($$self.$$.dirty[0] & /*value, data, options, limit, filter, disable*/
|
|
1822
|
+
if ($$self.$$.dirty[0] & /*value, data, options, limit, filter, disable*/ 813057) {
|
|
1765
1823
|
$$invalidate(1, results = fuzzy.filter(value, data, options).filter(({ score }) => score > 0).slice(0, limit).filter(result => !filter(result.original)).map(result => ({
|
|
1766
1824
|
...result,
|
|
1767
1825
|
disabled: disable(result.original)
|
|
1768
1826
|
})));
|
|
1769
1827
|
}
|
|
1770
1828
|
|
|
1771
|
-
if ($$self.$$.dirty[0] & /*results, extract*/
|
|
1829
|
+
if ($$self.$$.dirty[0] & /*results, extract*/ 4098) {
|
|
1772
1830
|
resultsId = results.map(result => extract(result.original)).join("");
|
|
1773
1831
|
}
|
|
1774
1832
|
};
|
|
@@ -1782,6 +1840,7 @@
|
|
|
1782
1840
|
hideDropdown,
|
|
1783
1841
|
selectedIndex,
|
|
1784
1842
|
select,
|
|
1843
|
+
change,
|
|
1785
1844
|
$$slots,
|
|
1786
1845
|
$$restProps,
|
|
1787
1846
|
data,
|
|
@@ -1809,6 +1868,7 @@
|
|
|
1809
1868
|
keydown_handler,
|
|
1810
1869
|
keydown_handler_1,
|
|
1811
1870
|
click_handler_1,
|
|
1871
|
+
mouseenter_handler,
|
|
1812
1872
|
div_binding
|
|
1813
1873
|
];
|
|
1814
1874
|
}
|
|
@@ -1826,15 +1886,15 @@
|
|
|
1826
1886
|
{
|
|
1827
1887
|
id: 2,
|
|
1828
1888
|
value: 0,
|
|
1829
|
-
data:
|
|
1830
|
-
extract:
|
|
1831
|
-
disable:
|
|
1832
|
-
filter:
|
|
1833
|
-
autoselect:
|
|
1834
|
-
inputAfterSelect:
|
|
1889
|
+
data: 11,
|
|
1890
|
+
extract: 12,
|
|
1891
|
+
disable: 13,
|
|
1892
|
+
filter: 14,
|
|
1893
|
+
autoselect: 15,
|
|
1894
|
+
inputAfterSelect: 16,
|
|
1835
1895
|
results: 1,
|
|
1836
|
-
focusAfterSelect:
|
|
1837
|
-
limit:
|
|
1896
|
+
focusAfterSelect: 17,
|
|
1897
|
+
limit: 18
|
|
1838
1898
|
},
|
|
1839
1899
|
add_css,
|
|
1840
1900
|
[-1, -1]
|
|
@@ -1844,8 +1904,8 @@
|
|
|
1844
1904
|
|
|
1845
1905
|
var Typeahead$1 = Typeahead;
|
|
1846
1906
|
|
|
1847
|
-
exports[
|
|
1907
|
+
exports["default"] = Typeahead$1;
|
|
1848
1908
|
|
|
1849
1909
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
1850
1910
|
|
|
1851
|
-
}))
|
|
1911
|
+
}));
|