@mhmo91/schmancy 0.4.37 → 0.4.39
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/dist/autocomplete-CHObbMzK.js +315 -0
- package/dist/autocomplete-CHObbMzK.js.map +1 -0
- package/dist/autocomplete-PHnzqAII.cjs +73 -0
- package/dist/autocomplete-PHnzqAII.cjs.map +1 -0
- package/dist/autocomplete.cjs +1 -1
- package/dist/autocomplete.js +1 -1
- package/dist/{avatar-nkJ8dWjK.js → avatar-CnJrdjfS.js} +2 -2
- package/dist/{avatar-nkJ8dWjK.js.map → avatar-CnJrdjfS.js.map} +1 -1
- package/dist/{avatar-DkxeVuSe.cjs → avatar-sXepW60q.cjs} +2 -2
- package/dist/{avatar-DkxeVuSe.cjs.map → avatar-sXepW60q.cjs.map} +1 -1
- package/dist/badge.cjs +1 -1
- package/dist/badge.js +1 -1
- package/dist/content-drawer.cjs +1 -1
- package/dist/content-drawer.js +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.js +2 -2
- package/dist/input-Cpo-ws8k.js.map +1 -1
- package/dist/input-DzNoI9qU.cjs.map +1 -1
- package/dist/nav-drawer.cjs +1 -1
- package/dist/nav-drawer.js +1 -1
- package/dist/teleport.cjs +1 -1
- package/dist/teleport.js +1 -1
- package/package.json +1 -1
- package/dist/autocomplete-C58ehz-F.js +0 -332
- package/dist/autocomplete-C58ehz-F.js.map +0 -1
- package/dist/autocomplete-cWc3oqB5.cjs +0 -74
- package/dist/autocomplete-cWc3oqB5.cjs.map +0 -1
|
@@ -1,332 +0,0 @@
|
|
|
1
|
-
import { BehaviorSubject as E, Subject as L, fromEvent as R, combineLatest as j, timer as x, of as O, EMPTY as N, merge as z } from "rxjs";
|
|
2
|
-
import { classMap as H } from "lit/directives/class-map.js";
|
|
3
|
-
import "lit/directives/style-map.js";
|
|
4
|
-
import { $ as B } from "./litElement.mixin-BH9PTyUD.js";
|
|
5
|
-
import "./tailwind.mixin-CaIkmP6j.js";
|
|
6
|
-
import { property as b, state as A, query as I, queryAssignedElements as F, customElement as U } from "lit/decorators.js";
|
|
7
|
-
import { html as M } from "lit";
|
|
8
|
-
import { createRef as W, ref as K } from "lit/directives/ref.js";
|
|
9
|
-
import { tap as r, takeUntil as v, distinctUntilChanged as T, debounceTime as Y, withLatestFrom as C, take as V, filter as g, switchMap as D, startWith as G, map as q } from "rxjs/operators";
|
|
10
|
-
function k(e, t) {
|
|
11
|
-
if (!e || !t) return 0;
|
|
12
|
-
if (e === t) return 1;
|
|
13
|
-
const i = e.toLowerCase().trim(), s = t.toLowerCase().trim();
|
|
14
|
-
if (i === s) return 1;
|
|
15
|
-
if (s.startsWith(i))
|
|
16
|
-
return 0.95 + 0.05 * (i.length / s.length);
|
|
17
|
-
const n = s.split(/[\s\-_]+/);
|
|
18
|
-
for (const u of n) if (u.startsWith(i))
|
|
19
|
-
return 0.85 * (1 - n.indexOf(u) / n.length * 0.1);
|
|
20
|
-
if (s.includes(i))
|
|
21
|
-
return 0.7 * (1 - s.indexOf(i) / s.length * 0.2);
|
|
22
|
-
if (function(u, m) {
|
|
23
|
-
let _ = 0, a = 0;
|
|
24
|
-
for (; _ < u.length && a < m.length; ) u[_] === m[a] && _++, a++;
|
|
25
|
-
return _ === u.length;
|
|
26
|
-
}(i, s)) return 0.5;
|
|
27
|
-
const l = function(u, m) {
|
|
28
|
-
if (u.length < 2 || m.length < 2) return 0;
|
|
29
|
-
const _ = P(u), a = P(m);
|
|
30
|
-
let $ = 0;
|
|
31
|
-
const y = new Array(a.length).fill(!1);
|
|
32
|
-
for (const S of _) for (let w = 0; w < a.length; w++) if (!y[w] && a[w] === S) {
|
|
33
|
-
$++, y[w] = !0;
|
|
34
|
-
break;
|
|
35
|
-
}
|
|
36
|
-
return 2 * $ / (_.length + a.length);
|
|
37
|
-
}(i, s), c = Math.max(i.length, s.length), o = function(u, m) {
|
|
38
|
-
if (u.length === 0) return m.length;
|
|
39
|
-
if (m.length === 0) return u.length;
|
|
40
|
-
const _ = [];
|
|
41
|
-
for (let a = 0; a <= m.length; a++) _[a] = [a];
|
|
42
|
-
for (let a = 0; a <= u.length; a++) _[0][a] = a;
|
|
43
|
-
for (let a = 1; a <= m.length; a++) for (let $ = 1; $ <= u.length; $++) {
|
|
44
|
-
const y = u[$ - 1] === m[a - 1] ? 0 : 1;
|
|
45
|
-
_[a][$] = Math.min(_[a - 1][$] + 1, _[a][$ - 1] + 1, _[a - 1][$ - 1] + y);
|
|
46
|
-
}
|
|
47
|
-
return _[m.length][u.length];
|
|
48
|
-
}(i, s), d = c ? 1 - o / c : 0, f = function(u, m) {
|
|
49
|
-
const _ = (y) => y.split("").reduce((S, w) => (S[w] = (S[w] || 0) + 1, S), {}), a = _(u), $ = _(m);
|
|
50
|
-
return Object.keys(a).every((y) => ($[y] || 0) >= a[y]);
|
|
51
|
-
}(i, s) ? 0.3 : 0;
|
|
52
|
-
return Math.max(0.4 * l, 0.4 * d, f);
|
|
53
|
-
}
|
|
54
|
-
function P(e) {
|
|
55
|
-
const t = [];
|
|
56
|
-
for (let i = 0; i < e.length - 1; i++) t.push(e.substring(i, i + 2));
|
|
57
|
-
return t;
|
|
58
|
-
}
|
|
59
|
-
var J = Object.defineProperty, Q = Object.getOwnPropertyDescriptor, p = (e, t, i, s) => {
|
|
60
|
-
for (var n, l = s > 1 ? void 0 : s ? Q(t, i) : t, c = e.length - 1; c >= 0; c--) (n = e[c]) && (l = (s ? n(t, i, l) : n(l)) || l);
|
|
61
|
-
return s && l && J(t, i, l), l;
|
|
62
|
-
};
|
|
63
|
-
let h = class extends B(":host{display:block;border:unset!important;line-height:unset!important;background:unset!important;padding:unset!important;font-size:unset!important;box-shadow:unset!important}:host:focus{box-shadow:unset!important}") {
|
|
64
|
-
constructor() {
|
|
65
|
-
super(...arguments), this.required = !1, this.placeholder = "", this.label = "", this.name = "", this.maxHeight = "300px", this.multi = !1, this.description = "", this.size = "md", this.autocomplete = "on", this.debounceMs = 200, this.similarityThreshold = 0.3, this._open = !1, this._inputValue = "", this._visibleOptionsCount = 0, this._hasResults = !0, this._inputElementRef = W(), this._selectedValue$ = new E(""), this._selectedValues$ = new E([]), this._inputValue$ = new E(""), this._open$ = new E(!1), this._options$ = new E([]), this._optionSelect$ = new L(), this._documentClick$ = new L(), this._checkAutofill$ = new L();
|
|
66
|
-
}
|
|
67
|
-
get values() {
|
|
68
|
-
return [...this._selectedValues$.value];
|
|
69
|
-
}
|
|
70
|
-
set values(e) {
|
|
71
|
-
this._selectedValues$.next(Array.isArray(e) ? [...e] : []);
|
|
72
|
-
}
|
|
73
|
-
get value() {
|
|
74
|
-
return this.multi ? this._selectedValues$.value.join(",") : this._selectedValue$.value;
|
|
75
|
-
}
|
|
76
|
-
set value(e) {
|
|
77
|
-
this.multi ? this._selectedValues$.next(e ? e.split(",").map((t) => t.trim()).filter(Boolean) : []) : this._selectedValue$.next(e);
|
|
78
|
-
}
|
|
79
|
-
connectedCallback() {
|
|
80
|
-
super.connectedCallback(), this.id || (this.id = `sch-autocomplete-${Math.random().toString(36).slice(2, 9)}`), this._setupAutocompleteLogic(), this._setupDocumentClickHandler(), this._setupAutofillDetection();
|
|
81
|
-
}
|
|
82
|
-
_setupAutocompleteLogic() {
|
|
83
|
-
this._options$.pipe(r((e) => {
|
|
84
|
-
e.forEach((t, i) => {
|
|
85
|
-
t.setAttribute("role", "option"), t.tabIndex = -1, t.id || (t.id = `${this.id}-option-${i}`), t.hasAttribute("data-event-bound") || (R(t, "click").pipe(r((s) => s.stopPropagation()), v(this.disconnecting)).subscribe(() => this._optionSelect$.next(t)), t.setAttribute("data-event-bound", "true"));
|
|
86
|
-
});
|
|
87
|
-
}), v(this.disconnecting)).subscribe(), j([this._selectedValue$, this._selectedValues$, this._options$]).pipe(r(([e, t, i]) => {
|
|
88
|
-
i.forEach((s) => {
|
|
89
|
-
s.selected = this.multi ? t.includes(s.value) : s.value === e, s.setAttribute("aria-selected", String(s.selected));
|
|
90
|
-
});
|
|
91
|
-
}), v(this.disconnecting)).subscribe(), this._inputValue$.pipe(T(), Y(this.debounceMs), C(this._options$, this._open$), r(([e, t, i]) => {
|
|
92
|
-
if (!i) return;
|
|
93
|
-
const s = e.trim();
|
|
94
|
-
if (s) {
|
|
95
|
-
const n = t.map((o) => {
|
|
96
|
-
const d = o.label || o.textContent || "", f = o.value, u = k(s, d), m = k(s, f);
|
|
97
|
-
return { option: o, score: Math.max(1.1 * u, m) };
|
|
98
|
-
});
|
|
99
|
-
n.sort((o, d) => d.score - o.score);
|
|
100
|
-
const l = n.find((o) => (o.option.label || o.option.textContent || "").toLowerCase().trim() === s.toLowerCase());
|
|
101
|
-
if (l && !this.multi) {
|
|
102
|
-
const o = this._options.find((f) => f.value === this._selectedValue$.value), d = (o?.label || o?.textContent || "").toLowerCase().trim();
|
|
103
|
-
if (s.toLowerCase() !== d) return void this._optionSelect$.next(l.option);
|
|
104
|
-
}
|
|
105
|
-
let c = 0;
|
|
106
|
-
n.forEach((o, d) => {
|
|
107
|
-
const { option: f, score: u } = o;
|
|
108
|
-
u < this.similarityThreshold ? f.hidden = !0 : (f.hidden = !1, c++, f.style.order = String(d));
|
|
109
|
-
}), this._visibleOptionsCount = c, this._hasResults = c > 0;
|
|
110
|
-
} else t.forEach((n) => {
|
|
111
|
-
n.hidden = !1, n.style.order = "0";
|
|
112
|
-
}), this._visibleOptionsCount = t.length, this._hasResults = !0;
|
|
113
|
-
this._announceToScreenReader(this._visibleOptionsCount > 0 ? `${this._visibleOptionsCount} option${this._visibleOptionsCount === 1 ? "" : "s"} available.` : "No results found.");
|
|
114
|
-
}), v(this.disconnecting)).subscribe(), this._optionSelect$.pipe(C(this._selectedValue$, this._selectedValues$), r(([e, t, i]) => {
|
|
115
|
-
if (this.multi) {
|
|
116
|
-
const s = i.indexOf(e.value), n = s > -1 ? [...i.slice(0, s), ...i.slice(s + 1)] : [...i, e.value];
|
|
117
|
-
this._selectedValues$.next(n), this._inputValue$.next(""), this._inputValue = "";
|
|
118
|
-
const l = this._getSelectedLabels();
|
|
119
|
-
this._announceToScreenReader(l.length > 0 ? `Selected: ${l.join(", ")}` : "No options selected");
|
|
120
|
-
} else this._selectedValue$.next(e.value), this._open$.next(!1), this._open = !1, this._inputValue = e.label || e.textContent || "", this._inputValue$.next(this._inputValue), x(100).pipe(r(() => this._inputElementRef.value?.blur()), V(1)).subscribe(), this._announceToScreenReader(`Selected: ${e.label || e.textContent}`);
|
|
121
|
-
}), r(() => this._fireChangeEvent()), v(this.disconnecting)).subscribe(), j([this._open$, this._selectedValue$, this._selectedValues$, this._options$]).pipe(g(() => !this._open$.value), r(([, e, t, i]) => {
|
|
122
|
-
if (this.multi) {
|
|
123
|
-
const s = i.filter((n) => t.includes(n.value)).map((n) => n.label || n.textContent || "");
|
|
124
|
-
this._inputValue = s.join(", ");
|
|
125
|
-
} else {
|
|
126
|
-
const s = i.find((n) => n.value === e);
|
|
127
|
-
this._inputValue = s && (s.label || s.textContent) || "";
|
|
128
|
-
}
|
|
129
|
-
this._inputValue$.next(this._inputValue);
|
|
130
|
-
}), v(this.disconnecting)).subscribe(), this._open$.pipe(r((e) => this._open = e), v(this.disconnecting)).subscribe();
|
|
131
|
-
}
|
|
132
|
-
_setupDocumentClickHandler() {
|
|
133
|
-
this._documentClick$.pipe(g((e) => !e.composedPath().includes(this)), g((e) => !this._options.some((t) => e.composedPath().includes(t))), g(() => this._open), r(() => {
|
|
134
|
-
this._open$.next(!1), this._updateInputDisplay();
|
|
135
|
-
}), v(this.disconnecting)).subscribe(), this._open$.pipe(T(), D((e) => e ? x(10).pipe(r(() => document.addEventListener("click", (t) => this._documentClick$.next(t))), D(() => N)) : O(null).pipe(r(() => document.removeEventListener("click", (t) => this._documentClick$.next(t))))), v(this.disconnecting)).subscribe();
|
|
136
|
-
}
|
|
137
|
-
_setupAutofillDetection() {
|
|
138
|
-
z(x(100, 500).pipe(V(10)), this._checkAutofill$, x(100).pipe(D(() => R(window, "load").pipe(G(null))))).pipe(q(() => {
|
|
139
|
-
const e = this._inputElementRef.value;
|
|
140
|
-
return e ? e.shadowRoot?.querySelector("input") || e.querySelector("input") || e._inputRef?.value : null;
|
|
141
|
-
}), g((e) => !!e), q((e) => e.value), g((e) => !!e && e.trim().length > 0), T(), C(this._options$), r(([e, t]) => {
|
|
142
|
-
let i = null, s = 0;
|
|
143
|
-
if (t.forEach((n) => {
|
|
144
|
-
const l = n.label || n.textContent || "", c = n.value, o = k(e, l), d = k(e, c), f = Math.max(o, d);
|
|
145
|
-
f > s && f >= this.similarityThreshold && (s = f, i = n);
|
|
146
|
-
}), i && s >= 0.95 && e.length >= 3 && ((i.label || i.textContent || "").toLowerCase() === e.toLowerCase() || i.value.toLowerCase() === e.toLowerCase())) {
|
|
147
|
-
this.multi ? this._selectedValues$.next([i.value]) : this._selectedValue$.next(i.value);
|
|
148
|
-
const n = i.label || i.textContent || "";
|
|
149
|
-
this._inputValue = n, this._inputValue$.next(n);
|
|
150
|
-
const l = this._inputElementRef.value;
|
|
151
|
-
l && (l.value = n), this._open$.next(!1), this._fireChangeEvent(), this._announceToScreenReader(`Autofilled: ${n}`);
|
|
152
|
-
}
|
|
153
|
-
}), v(this.disconnecting)).subscribe(), x(100).pipe(q(() => {
|
|
154
|
-
const e = this._inputElementRef.value;
|
|
155
|
-
return e ? e.shadowRoot?.querySelector("input") || e.querySelector("input") || e._inputRef?.value : null;
|
|
156
|
-
}), g((e) => !!e), D((e) => R(e, "animationstart").pipe(g((t) => t.animationName === "onAutoFillStart"), r(() => {
|
|
157
|
-
x(100).pipe(r(() => this._checkAutofill$.next()), V(1)).subscribe();
|
|
158
|
-
}))), v(this.disconnecting)).subscribe();
|
|
159
|
-
}
|
|
160
|
-
_updateInputDisplay() {
|
|
161
|
-
O(null).pipe(C(this._selectedValue$, this._selectedValues$, this._options$, this._open$), r(([, e, t, i, s]) => {
|
|
162
|
-
if (this._inputElementRef.value && (!s || !this.multi)) {
|
|
163
|
-
if (this.multi) {
|
|
164
|
-
const n = i.filter((l) => t.includes(l.value)).map((l) => l.label || l.textContent || "");
|
|
165
|
-
this._inputValue = n.join(", ");
|
|
166
|
-
} else {
|
|
167
|
-
const n = i.find((l) => l.value === e);
|
|
168
|
-
this._inputValue = n && (n.label || n.textContent) || "";
|
|
169
|
-
}
|
|
170
|
-
this._inputValue$.next(this._inputValue), this._inputElementRef.value.value = this._inputValue;
|
|
171
|
-
}
|
|
172
|
-
}), V(1)).subscribe();
|
|
173
|
-
}
|
|
174
|
-
_getSelectedLabels() {
|
|
175
|
-
return this._options.filter((e) => this.multi ? this._selectedValues$.value.includes(e.value) : e.value === this._selectedValue$.value).map((e) => e.label || e.textContent || "");
|
|
176
|
-
}
|
|
177
|
-
_announceToScreenReader(e) {
|
|
178
|
-
const t = this.shadowRoot?.querySelector("#live-status");
|
|
179
|
-
t && (t.textContent = e);
|
|
180
|
-
}
|
|
181
|
-
_fireChangeEvent() {
|
|
182
|
-
const e = { value: this.value };
|
|
183
|
-
this.multi && (e.values = [...this._selectedValues$.value]), this.dispatchEvent(new CustomEvent("change", { detail: e, bubbles: !0, composed: !0 }));
|
|
184
|
-
}
|
|
185
|
-
checkValidity() {
|
|
186
|
-
return !this.required || (this.multi ? this._selectedValues$.value.length > 0 : !!this._selectedValue$.value);
|
|
187
|
-
}
|
|
188
|
-
reportValidity() {
|
|
189
|
-
return this._inputElementRef.value ? this._inputElementRef.value.reportValidity() : this.checkValidity();
|
|
190
|
-
}
|
|
191
|
-
firstUpdated() {
|
|
192
|
-
x(200).pipe(r(() => this._checkAutofill$.next()), V(1)).subscribe(), this._options$.pipe(g((e) => e.length > 0), r(() => this._checkAutofill$.next()), v(this.disconnecting)).subscribe();
|
|
193
|
-
}
|
|
194
|
-
render() {
|
|
195
|
-
const e = `${this.id}-desc`;
|
|
196
|
-
return M`
|
|
197
|
-
<div class="relative">
|
|
198
|
-
<!-- Screen reader live region -->
|
|
199
|
-
<div id="live-status" role="status" aria-live="polite" class="sr-only"></div>
|
|
200
|
-
|
|
201
|
-
<!-- Description -->
|
|
202
|
-
${this.description ? M`<div id="${e}" class="sr-only">${this.description}</div>` : ""}
|
|
203
|
-
|
|
204
|
-
<!-- Input -->
|
|
205
|
-
<slot name="trigger">
|
|
206
|
-
<sch-input
|
|
207
|
-
.size=${this.size}
|
|
208
|
-
${K(this._inputElementRef)}
|
|
209
|
-
id="autocomplete-input"
|
|
210
|
-
class="w-full"
|
|
211
|
-
.name=${this.name || this.label?.toLowerCase().replace(/\s+/g, "-")}
|
|
212
|
-
.label=${this.label}
|
|
213
|
-
.placeholder=${this.placeholder}
|
|
214
|
-
.required=${this.required}
|
|
215
|
-
.value=${this._inputValue}
|
|
216
|
-
type="text"
|
|
217
|
-
autocomplete=${this.autocomplete}
|
|
218
|
-
clickable
|
|
219
|
-
role="combobox"
|
|
220
|
-
aria-autocomplete="list"
|
|
221
|
-
aria-haspopup="listbox"
|
|
222
|
-
aria-controls="options"
|
|
223
|
-
aria-expanded=${this._open}
|
|
224
|
-
aria-describedby=${this.description ? e : void 0}
|
|
225
|
-
@input=${(t) => {
|
|
226
|
-
const i = t.target.value;
|
|
227
|
-
this._inputValue = i, this._inputValue$.next(i), i.trim() || this.multi || !this._selectedValue$.value || (this._selectedValue$.next(""), this._fireChangeEvent());
|
|
228
|
-
}}
|
|
229
|
-
@focus=${(t) => {
|
|
230
|
-
t.stopPropagation();
|
|
231
|
-
const i = this.multi ? this._selectedValues$.value.length > 0 : !!this._selectedValue$.value;
|
|
232
|
-
this.multi && !i && (this._inputValue = "", this._inputValue$.next(""), this._inputElementRef.value && (this._inputElementRef.value.value = "")), this._open$.next(!0);
|
|
233
|
-
}}
|
|
234
|
-
@blur=${(t) => {
|
|
235
|
-
t.stopPropagation(), O(this._inputValue.trim()).pipe(C(this._open$), g(([, i]) => i), r(([i]) => {
|
|
236
|
-
if (i && (this.multi || !this._selectedValue$.value)) {
|
|
237
|
-
let s = null, n = 0;
|
|
238
|
-
this._options.forEach((l) => {
|
|
239
|
-
if (this.multi && this._selectedValues$.value.includes(l.value)) return;
|
|
240
|
-
const c = l.label || l.textContent || "", o = l.value, d = k(i, c), f = k(i, o), u = Math.max(1.1 * d, f);
|
|
241
|
-
u > n && u >= this.similarityThreshold && (n = u, s = l);
|
|
242
|
-
}), s ? this._optionSelect$.next(s) : (this._open$.next(!1), this._updateInputDisplay());
|
|
243
|
-
} else this._open$.next(!1), this._updateInputDisplay();
|
|
244
|
-
}), V(1)).subscribe();
|
|
245
|
-
}}
|
|
246
|
-
@click=${(t) => {
|
|
247
|
-
t.stopPropagation(), this._open$.next(!0);
|
|
248
|
-
}}
|
|
249
|
-
@keydown=${(t) => {
|
|
250
|
-
this._handleKeyDown(t);
|
|
251
|
-
}}
|
|
252
|
-
>
|
|
253
|
-
</sch-input>
|
|
254
|
-
</slot>
|
|
255
|
-
|
|
256
|
-
<!-- Options dropdown -->
|
|
257
|
-
<ul
|
|
258
|
-
id="options"
|
|
259
|
-
class=${H({ absolute: !0, "z-[1000]": !0, "mt-1": !0, "w-full": !0, "rounded-md": !0, "shadow-md": !0, "overflow-auto": !0, "min-w-full": !0, "bg-surface-low": !0, flex: !0, "flex-col": !0 })}
|
|
260
|
-
role="listbox"
|
|
261
|
-
aria-multiselectable=${this.multi ? "true" : "false"}
|
|
262
|
-
aria-label=${`${this.label || "Options"} dropdown`}
|
|
263
|
-
?hidden=${!this._open}
|
|
264
|
-
style="max-height: ${this.maxHeight}; display: ${this._open ? "flex" : "none"};"
|
|
265
|
-
@slotchange=${() => {
|
|
266
|
-
this._options$.next(this._options), x(100).pipe(r(() => this._checkAutofill$.next()), V(1)).subscribe();
|
|
267
|
-
}}
|
|
268
|
-
>
|
|
269
|
-
<slot></slot>
|
|
270
|
-
${this._hasResults ? "" : M`
|
|
271
|
-
<li class="px-3 py-2 text-sm text-muted">No results found</li>
|
|
272
|
-
`}
|
|
273
|
-
</ul>
|
|
274
|
-
</div>
|
|
275
|
-
|
|
276
|
-
<style>
|
|
277
|
-
:host {
|
|
278
|
-
display: block;
|
|
279
|
-
}
|
|
280
|
-
|
|
281
|
-
@keyframes onAutoFillStart {
|
|
282
|
-
from {/**/}
|
|
283
|
-
to {/**/}
|
|
284
|
-
}
|
|
285
|
-
|
|
286
|
-
sch-input::part(input):-webkit-autofill,
|
|
287
|
-
sch-input input:-webkit-autofill {
|
|
288
|
-
animation-name: onAutoFillStart;
|
|
289
|
-
animation-duration: 1ms;
|
|
290
|
-
}
|
|
291
|
-
</style>
|
|
292
|
-
`;
|
|
293
|
-
}
|
|
294
|
-
_handleKeyDown(e) {
|
|
295
|
-
R(document, "keydown").pipe(V(1), C(this._open$, this._options$), r(([t, i, s]) => {
|
|
296
|
-
if (!i && (t.key === "ArrowDown" || t.key === "Enter")) return t.preventDefault(), this._open$.next(!0), void x(10).pipe(r(() => {
|
|
297
|
-
s.find((d) => !d.hidden)?.focus();
|
|
298
|
-
}), V(1)).subscribe();
|
|
299
|
-
if (!i) return;
|
|
300
|
-
const n = s.filter((o) => !o.hidden).sort((o, d) => parseInt(o.style.order || "0") - parseInt(d.style.order || "0")), l = n.find((o) => o === document.activeElement), c = l ? n.indexOf(l) : -1;
|
|
301
|
-
switch (t.key) {
|
|
302
|
-
case "Escape":
|
|
303
|
-
t.preventDefault(), this._open$.next(!1), this._updateInputDisplay(), this._inputElementRef.value?.focus();
|
|
304
|
-
break;
|
|
305
|
-
case "Tab":
|
|
306
|
-
this._open$.next(!1), this._updateInputDisplay();
|
|
307
|
-
break;
|
|
308
|
-
case "ArrowDown":
|
|
309
|
-
t.preventDefault();
|
|
310
|
-
const o = c < n.length - 1 ? c + 1 : 0;
|
|
311
|
-
n[o]?.focus();
|
|
312
|
-
break;
|
|
313
|
-
case "ArrowUp":
|
|
314
|
-
t.preventDefault();
|
|
315
|
-
const d = c > 0 ? c - 1 : n.length - 1;
|
|
316
|
-
n[d]?.focus();
|
|
317
|
-
break;
|
|
318
|
-
case "Home":
|
|
319
|
-
t.preventDefault(), n[0]?.focus();
|
|
320
|
-
break;
|
|
321
|
-
case "End":
|
|
322
|
-
t.preventDefault(), n[n.length - 1]?.focus();
|
|
323
|
-
break;
|
|
324
|
-
case "Enter":
|
|
325
|
-
case " ":
|
|
326
|
-
l && (t.preventDefault(), this._optionSelect$.next(l));
|
|
327
|
-
}
|
|
328
|
-
})).subscribe();
|
|
329
|
-
}
|
|
330
|
-
};
|
|
331
|
-
p([b({ type: Boolean })], h.prototype, "required", 2), p([b({ type: String })], h.prototype, "placeholder", 2), p([b({ type: String, reflect: !0 })], h.prototype, "label", 2), p([b({ type: String })], h.prototype, "name", 2), p([b({ type: String })], h.prototype, "maxHeight", 2), p([b({ type: Boolean })], h.prototype, "multi", 2), p([b({ type: String })], h.prototype, "description", 2), p([b({ type: String, reflect: !0 })], h.prototype, "size", 2), p([b({ type: String })], h.prototype, "autocomplete", 2), p([b({ type: Number })], h.prototype, "debounceMs", 2), p([b({ type: Number })], h.prototype, "similarityThreshold", 2), p([b({ type: Array })], h.prototype, "values", 1), p([b({ type: String, reflect: !0 })], h.prototype, "value", 1), p([A()], h.prototype, "_open", 2), p([A()], h.prototype, "_inputValue", 2), p([A()], h.prototype, "_visibleOptionsCount", 2), p([A()], h.prototype, "_hasResults", 2), p([I("#options")], h.prototype, "_listbox", 2), p([I("sch-input")], h.prototype, "_input", 2), p([F({ flatten: !0 })], h.prototype, "_options", 2), h = p([U("schmancy-autocomplete")], h);
|
|
332
|
-
//# sourceMappingURL=autocomplete-C58ehz-F.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"autocomplete-C58ehz-F.js","sources":["../src/utils/search.ts","../src/autocomplete/autocomplete.ts"],"sourcesContent":["/**\n * Calculate similarity score between two strings.\n * Returns a value between 0 (no match) and 1 (exact match).\n * Optimized for autocomplete with prioritization of start matches and whole words.\n *\n * @param query The search query string\n * @param target The target string to compare against\n * @returns A similarity score from 0 to 1\n */\nexport function similarity(query: string, target: string): number {\n\t// Handle edge cases\n\tif (!query || !target) return 0\n\tif (query === target) return 1\n\n\t// Normalize strings for comparison\n\tconst normalizedQuery = query.toLowerCase().trim()\n\tconst normalizedTarget = target.toLowerCase().trim()\n\n\t// 1. Exact match (case-insensitive)\n\tif (normalizedQuery === normalizedTarget) return 1\n\n\t// 2. Target starts with query (highest priority for autocomplete)\n\tif (normalizedTarget.startsWith(normalizedQuery)) {\n\t\t// Give higher score to shorter targets (more precise matches)\n\t\tconst lengthRatio = normalizedQuery.length / normalizedTarget.length\n\t\treturn 0.95 + (lengthRatio * 0.05) // Score between 0.95 and 1.0\n\t}\n\n\t// 3. Word boundary match (query matches start of any word in target)\n\tconst words = normalizedTarget.split(/[\\s\\-_]+/)\n\tfor (const word of words) {\n\t\tif (word.startsWith(normalizedQuery)) {\n\t\t\t// Score based on which word matched (earlier words score higher)\n\t\t\tconst wordIndex = words.indexOf(word)\n\t\t\tconst wordPositionScore = 1 - (wordIndex / words.length) * 0.1\n\t\t\treturn 0.85 * wordPositionScore // Score between 0.765 and 0.85\n\t\t}\n\t}\n\n\t// 4. Direct substring match (query appears anywhere in target)\n\tif (normalizedTarget.includes(normalizedQuery)) {\n\t\t// Score based on position (earlier position scores higher)\n\t\tconst position = normalizedTarget.indexOf(normalizedQuery)\n\t\tconst positionScore = 1 - (position / normalizedTarget.length) * 0.2\n\t\treturn 0.7 * positionScore // Score between 0.56 and 0.7\n\t}\n\n\t// 5. Subsequence check (all query chars appear in order)\n\tif (isSubsequence(normalizedQuery, normalizedTarget)) {\n\t\treturn 0.5\n\t}\n\n\t// 6. Fuzzy matching for typos\n\t// 6a. Dice coefficient (good for similar words)\n\tconst diceScore = diceCoefficient(normalizedQuery, normalizedTarget)\n\t\n\t// 6b. Levenshtein distance (good for typos)\n\tconst maxLength = Math.max(normalizedQuery.length, normalizedTarget.length)\n\tconst levenshteinDistance = calculateLevenshtein(normalizedQuery, normalizedTarget)\n\tconst levenshteinScore = maxLength ? 1 - levenshteinDistance / maxLength : 0\n\n\t// 6c. Character frequency match (anagram-like)\n\tconst anagramScore = hasAllCharacters(normalizedQuery, normalizedTarget) ? 0.3 : 0\n\n\t// Combine fuzzy scores with weights\n\tconst fuzzyScore = Math.max(\n\t\tdiceScore * 0.4,\n\t\tlevenshteinScore * 0.4,\n\t\tanagramScore\n\t)\n\n\treturn fuzzyScore\n}\n\n// Keep the rest of the helper functions as they are...\n/**\n * Check if string 'sub' is a subsequence of string 'str'.\n * All characters in 'sub' must appear in order in 'str'.\n */\nfunction isSubsequence(sub: string, str: string): boolean {\n\tlet i = 0,\n\t\tj = 0\n\twhile (i < sub.length && j < str.length) {\n\t\tif (sub[i] === str[j]) i++\n\t\tj++\n\t}\n\treturn i === sub.length\n}\n\n/**\n * Check if all characters in 'query' are present in 'target'.\n * For example, \"aovc\" matches \"avocados\" (anagram subset matching).\n */\nfunction hasAllCharacters(query: string, target: string): boolean {\n\tconst countChars = (s: string): Record<string, number> => {\n\t\treturn s.split('').reduce(\n\t\t\t(acc, char) => {\n\t\t\t\tacc[char] = (acc[char] || 0) + 1\n\t\t\t\treturn acc\n\t\t\t},\n\t\t\t{} as Record<string, number>,\n\t\t)\n\t}\n\n\tconst queryCount = countChars(query)\n\tconst targetCount = countChars(target)\n\n\treturn Object.keys(queryCount).every(char => (targetCount[char] || 0) >= queryCount[char])\n}\n\n/**\n * Generate bigrams for a string.\n * A bigram is a sequence of two adjacent characters.\n */\nfunction getBigrams(s: string): string[] {\n\tconst bigrams = []\n\tfor (let i = 0; i < s.length - 1; i++) {\n\t\tbigrams.push(s.substring(i, i + 2))\n\t}\n\treturn bigrams\n}\n\n/**\n * Compute Dice's coefficient for two strings based on bigrams.\n * Returns a value between 0 (no similarity) and 1 (perfect match).\n */\nfunction diceCoefficient(s1: string, s2: string): number {\n\tif (s1.length < 2 || s2.length < 2) return 0\n\n\tconst bigrams1 = getBigrams(s1)\n\tconst bigrams2 = getBigrams(s2)\n\n\tlet intersection = 0\n\tconst used = new Array(bigrams2.length).fill(false)\n\n\tfor (const bigram of bigrams1) {\n\t\tfor (let i = 0; i < bigrams2.length; i++) {\n\t\t\tif (!used[i] && bigrams2[i] === bigram) {\n\t\t\t\tintersection++\n\t\t\t\tused[i] = true\n\t\t\t\tbreak\n\t\t\t}\n\t\t}\n\t}\n\n\treturn (2 * intersection) / (bigrams1.length + bigrams2.length)\n}\n\n/**\n * Calculate Levenshtein distance between two strings.\n */\nfunction calculateLevenshtein(a: string, b: string): number {\n\tif (a.length === 0) return b.length\n\tif (b.length === 0) return a.length\n\n\tconst matrix: number[][] = []\n\n\t// Initialize the matrix\n\tfor (let i = 0; i <= b.length; i++) {\n\t\tmatrix[i] = [i]\n\t}\n\tfor (let j = 0; j <= a.length; j++) {\n\t\tmatrix[0][j] = j\n\t}\n\n\t// Calculate distances\n\tfor (let i = 1; i <= b.length; i++) {\n\t\tfor (let j = 1; j <= a.length; j++) {\n\t\t\tconst cost = a[j - 1] === b[i - 1] ? 0 : 1\n\t\t\tmatrix[i][j] = Math.min(\n\t\t\t\tmatrix[i - 1][j] + 1, // deletion\n\t\t\t\tmatrix[i][j - 1] + 1, // insertion\n\t\t\t\tmatrix[i - 1][j - 1] + cost, // substitution\n\t\t\t)\n\t\t}\n\t}\n\n\treturn matrix[b.length][a.length]\n}\n","import { $LitElement } from '@mixins/index'\nimport { InputSize } from '@schmancy/input'\nimport SchmancyInputV2 from '@schmancy/input/input-v2'\nimport SchmancyOption from '@schmancy/option/option'\nimport { html } from 'lit'\nimport { customElement, property, query, queryAssignedElements, state } from 'lit/decorators.js'\nimport { classMap } from 'lit/directives/class-map.js'\nimport { createRef, ref } from 'lit/directives/ref.js'\nimport {\n BehaviorSubject,\n combineLatest,\n EMPTY,\n fromEvent,\n merge,\n of,\n Subject,\n timer\n} from 'rxjs'\nimport {\n debounceTime,\n distinctUntilChanged,\n filter,\n map,\n startWith,\n switchMap,\n take,\n takeUntil,\n tap,\n withLatestFrom\n} from 'rxjs/operators'\nimport style from './autocomplete.scss?inline'\n\n// Import the similarity function\nimport { similarity } from '../utils/search'\n\nexport type SchmancyAutocompleteChangeEvent = CustomEvent<{\n value: string | string[]\n values?: string[]\n}>\n\ninterface FilteredOption {\n option: SchmancyOption\n score: number\n}\n\n@customElement('schmancy-autocomplete')\nexport default class SchmancyAutocomplete extends $LitElement(style) {\n // Public API properties\n @property({ type: Boolean }) required = false\n @property({ type: String }) placeholder = ''\n @property({ type: String, reflect: true }) label = ''\n @property({ type: String }) name = ''\n @property({ type: String }) maxHeight = '300px'\n @property({ type: Boolean }) multi = false\n @property({ type: String }) description = ''\n @property({ type: String, reflect: true }) size: InputSize = 'md'\n @property({ type: String }) autocomplete = 'on'\n @property({ type: Number }) debounceMs = 200\n @property({ type: Number }) similarityThreshold = 0.3 // Minimum similarity score to show option\n\n // Values property for multi-select mode\n @property({ type: Array })\n get values() {\n return [...this._selectedValues$.value]\n }\n set values(vals: string[]) {\n this._selectedValues$.next(Array.isArray(vals) ? [...vals] : [])\n }\n\n // Value property\n @property({ type: String, reflect: true })\n get value() {\n return this.multi \n ? this._selectedValues$.value.join(',')\n : this._selectedValue$.value\n }\n set value(val: string) {\n if (this.multi) {\n this._selectedValues$.next(\n val ? val.split(',').map(v => v.trim()).filter(Boolean) : []\n )\n } else {\n this._selectedValue$.next(val)\n }\n }\n\n // State\n @state() private _open = false\n @state() private _inputValue = ''\n @state() private _visibleOptionsCount = 0\n @state() private _hasResults = true\n\n // DOM references\n @query('#options') _listbox!: HTMLUListElement\n @query('sch-input') _input!: SchmancyInputV2\n @queryAssignedElements({ flatten: true }) private _options!: SchmancyOption[]\n private _inputElementRef = createRef<HTMLInputElement>()\n\n // RxJS Subjects\n private _selectedValue$ = new BehaviorSubject<string>('')\n private _selectedValues$ = new BehaviorSubject<string[]>([])\n private _inputValue$ = new BehaviorSubject<string>('')\n private _open$ = new BehaviorSubject<boolean>(false)\n private _options$ = new BehaviorSubject<SchmancyOption[]>([])\n private _optionSelect$ = new Subject<SchmancyOption>()\n private _documentClick$ = new Subject<MouseEvent>()\n private _checkAutofill$ = new Subject<void>()\n\n connectedCallback() {\n super.connectedCallback()\n \n if (!this.id) {\n this.id = `sch-autocomplete-${Math.random().toString(36).slice(2, 9)}`\n }\n\n this._setupAutocompleteLogic()\n this._setupDocumentClickHandler()\n this._setupAutofillDetection()\n }\n\n private _setupAutocompleteLogic() {\n // Options management pipeline\n this._options$.pipe(\n tap(options => {\n options.forEach((option, index) => {\n option.setAttribute('role', 'option')\n option.tabIndex = -1\n if (!option.id) {\n option.id = `${this.id}-option-${index}`\n }\n if (!option.hasAttribute('data-event-bound')) {\n fromEvent(option, 'click').pipe(\n tap(e => e.stopPropagation()),\n takeUntil(this.disconnecting)\n ).subscribe(() => this._optionSelect$.next(option))\n option.setAttribute('data-event-bound', 'true')\n }\n })\n }),\n takeUntil(this.disconnecting)\n ).subscribe()\n\n // Selection sync pipeline\n combineLatest([\n this._selectedValue$,\n this._selectedValues$,\n this._options$\n ]).pipe(\n tap(([selectedValue, selectedValues, options]) => {\n options.forEach(option => {\n option.selected = this.multi \n ? selectedValues.includes(option.value)\n : option.value === selectedValue\n option.setAttribute('aria-selected', String(option.selected))\n })\n }),\n takeUntil(this.disconnecting)\n ).subscribe()\n\n // Enhanced fuzzy filtering pipeline\n this._inputValue$.pipe(\n distinctUntilChanged(),\n debounceTime(this.debounceMs),\n withLatestFrom(this._options$, this._open$),\n tap(([searchTerm, options, isOpen]) => {\n if (!isOpen) return\n\n const term = searchTerm.trim()\n \n if (!term) {\n // Show all options if no search term\n options.forEach(option => {\n option.hidden = false\n option.style.order = '0' // Reset order\n })\n this._visibleOptionsCount = options.length\n this._hasResults = true\n } else {\n // Calculate similarity scores for all options\n const scoredOptions: FilteredOption[] = options.map(option => {\n // Get text to search in (prioritize label, then textContent, then value)\n const optionLabel = option.label || option.textContent || ''\n const optionValue = option.value\n \n // Calculate similarity scores for both label and value\n const labelScore = similarity(term, optionLabel)\n const valueScore = similarity(term, optionValue)\n \n // Use the higher score (prioritizing label matches)\n const score = Math.max(labelScore * 1.1, valueScore) // Slight boost for label matches\n \n return { option, score }\n })\n \n // Sort by score (highest first)\n scoredOptions.sort((a, b) => b.score - a.score)\n \n // Check for exact match with the input\n const exactMatch = scoredOptions.find(item => {\n const optionLabel = (item.option.label || item.option.textContent || '').toLowerCase().trim()\n return optionLabel === term.toLowerCase()\n })\n \n // Auto-select exact match for single select mode when:\n // 1. The input exactly matches an option's label\n // 2. Not in multi-select mode\n // 3. Either no value is selected OR the current selection doesn't match the input\n if (exactMatch && !this.multi) {\n const currentSelectedOption = this._options.find(opt => opt.value === this._selectedValue$.value)\n const currentSelectedLabel = (currentSelectedOption?.label || currentSelectedOption?.textContent || '').toLowerCase().trim()\n \n // Only auto-select if the input doesn't match the current selection\n if (term.toLowerCase() !== currentSelectedLabel) {\n // Auto-select the exact match\n this._optionSelect$.next(exactMatch.option)\n return // Exit early since we've made a selection\n }\n }\n \n // Apply visibility and ordering\n let visibleCount = 0\n scoredOptions.forEach((item, index) => {\n const { option, score } = item\n \n // Hide options below threshold\n if (score < this.similarityThreshold) {\n option.hidden = true\n } else {\n option.hidden = false\n visibleCount++\n // Use CSS order to sort visible options by relevance\n option.style.order = String(index)\n }\n })\n \n this._visibleOptionsCount = visibleCount\n this._hasResults = visibleCount > 0\n }\n \n this._announceToScreenReader(\n this._visibleOptionsCount > 0 \n ? `${this._visibleOptionsCount} option${this._visibleOptionsCount === 1 ? '' : 's'} available.`\n : 'No results found.'\n )\n }),\n takeUntil(this.disconnecting)\n ).subscribe()\n\n // Option selection pipeline\n this._optionSelect$.pipe(\n withLatestFrom(this._selectedValue$, this._selectedValues$),\n tap(([option, _, currentValues]) => {\n if (this.multi) {\n const index = currentValues.indexOf(option.value)\n const newValues = index > -1\n ? [...currentValues.slice(0, index), ...currentValues.slice(index + 1)]\n : [...currentValues, option.value]\n this._selectedValues$.next(newValues)\n \n this._inputValue$.next('')\n this._inputValue = ''\n \n const labels = this._getSelectedLabels()\n this._announceToScreenReader(\n labels.length > 0 \n ? `Selected: ${labels.join(', ')}`\n : 'No options selected'\n )\n } else {\n this._selectedValue$.next(option.value)\n this._open$.next(false)\n this._open = false\n \n this._inputValue = option.label || option.textContent || ''\n this._inputValue$.next(this._inputValue)\n \n timer(100).pipe(\n tap(() => this._inputElementRef.value?.blur()),\n take(1)\n ).subscribe()\n \n this._announceToScreenReader(`Selected: ${option.label || option.textContent}`)\n }\n }),\n tap(() => this._fireChangeEvent()),\n takeUntil(this.disconnecting)\n ).subscribe()\n\n // Display update pipeline\n combineLatest([\n this._open$,\n this._selectedValue$,\n this._selectedValues$,\n this._options$\n ]).pipe(\n filter(() => !this._open$.value),\n tap(([, selectedValue, selectedValues, options]) => {\n if (this.multi) {\n const labels = options\n .filter(opt => selectedValues.includes(opt.value))\n .map(opt => opt.label || opt.textContent || '')\n this._inputValue = labels.join(', ')\n } else {\n const option = options.find(opt => opt.value === selectedValue)\n this._inputValue = option ? option.label || option.textContent || '' : ''\n }\n this._inputValue$.next(this._inputValue)\n }),\n takeUntil(this.disconnecting)\n ).subscribe()\n\n // Open state sync\n this._open$.pipe(\n tap(open => this._open = open),\n takeUntil(this.disconnecting)\n ).subscribe()\n }\n\n private _setupDocumentClickHandler() {\n this._documentClick$.pipe(\n filter(e => !e.composedPath().includes(this)),\n filter(e => !this._options.some(opt => e.composedPath().includes(opt))),\n filter(() => this._open),\n tap(() => {\n this._open$.next(false)\n this._updateInputDisplay()\n }),\n takeUntil(this.disconnecting)\n ).subscribe()\n\n this._open$.pipe(\n distinctUntilChanged(),\n switchMap(open => \n open \n ? timer(10).pipe(\n tap(() => document.addEventListener('click', e => this._documentClick$.next(e))),\n switchMap(() => EMPTY)\n )\n : of(null).pipe(\n tap(() => document.removeEventListener('click', e => this._documentClick$.next(e)))\n )\n ),\n takeUntil(this.disconnecting)\n ).subscribe()\n }\n\n private _setupAutofillDetection() {\n // Enhanced autofill detection with fuzzy matching\n merge(\n timer(100, 500).pipe(take(10)),\n this._checkAutofill$,\n timer(100).pipe(\n switchMap(() => \n fromEvent(window, 'load').pipe(startWith(null))\n )\n )\n ).pipe(\n map(() => {\n const schInput = this._inputElementRef.value\n if (!schInput) return null\n return schInput.shadowRoot?.querySelector('input') || \n schInput.querySelector('input') ||\n (schInput as any)._inputRef?.value\n }),\n filter(input => !!input),\n map(input => (input as HTMLInputElement).value),\n filter(value => !!value && value.trim().length > 0),\n distinctUntilChanged(),\n withLatestFrom(this._options$),\n tap(([autofilledValue, options]) => {\n console.log('Autofill detected:', autofilledValue)\n \n // Use fuzzy matching to find best matching option\n let bestMatch: SchmancyOption | null = null\n let bestScore = 0\n \n options.forEach(option => {\n const optionLabel = option.label || option.textContent || ''\n const optionValue = option.value\n \n // Calculate similarity scores\n const labelScore = similarity(autofilledValue, optionLabel)\n const valueScore = similarity(autofilledValue, optionValue)\n \n // Use the higher score\n const score = Math.max(labelScore, valueScore)\n \n // Keep track of best match\n if (score > bestScore && score >= this.similarityThreshold) {\n bestScore = score\n bestMatch = option\n }\n })\n\n // Only accept autofill if:\n // 1. The score is very high (>= 0.95)\n // 2. The autofilled value is at least 3 characters (to avoid single character matches)\n // 3. It's an exact match (case-insensitive)\n if (bestMatch && bestScore >= 0.95 && autofilledValue.length >= 3) {\n // Additional check for exact match\n const optionLabel = bestMatch.label || bestMatch.textContent || ''\n const isExactMatch = optionLabel.toLowerCase() === autofilledValue.toLowerCase() ||\n bestMatch.value.toLowerCase() === autofilledValue.toLowerCase()\n \n if (isExactMatch) {\n console.log('Found matching option:', bestMatch.value, 'with score:', bestScore)\n \n // Select the option\n if (this.multi) {\n this._selectedValues$.next([bestMatch.value])\n } else {\n this._selectedValue$.next(bestMatch.value)\n }\n \n // Update input to show the label\n const displayValue = bestMatch.label || bestMatch.textContent || ''\n this._inputValue = displayValue\n this._inputValue$.next(displayValue)\n \n // Update the actual input element\n const input = this._inputElementRef.value\n if (input) {\n input.value = displayValue\n }\n \n // Close dropdown if open\n this._open$.next(false)\n \n // Fire change event\n this._fireChangeEvent()\n \n // Announce to screen reader\n this._announceToScreenReader(`Autofilled: ${displayValue}`)\n }\n }\n }),\n takeUntil(this.disconnecting)\n ).subscribe()\n\n // Chrome autofill animation detection\n timer(100).pipe(\n map(() => {\n const schInput = this._inputElementRef.value\n if (!schInput) return null\n return schInput.shadowRoot?.querySelector('input') || \n schInput.querySelector('input') ||\n (schInput as any)._inputRef?.value\n }),\n filter(input => !!input),\n switchMap(input => {\n return fromEvent<AnimationEvent>(input!, 'animationstart').pipe(\n filter(e => e.animationName === 'onAutoFillStart'),\n tap(() => {\n console.log('Chrome autofill animation detected')\n timer(100).pipe(\n tap(() => this._checkAutofill$.next()),\n take(1)\n ).subscribe()\n })\n )\n }),\n takeUntil(this.disconnecting)\n ).subscribe()\n }\n\n private _updateInputDisplay() {\n of(null).pipe(\n withLatestFrom(\n this._selectedValue$,\n this._selectedValues$,\n this._options$,\n this._open$\n ),\n tap(([, selectedValue, selectedValues, options, isOpen]) => {\n if (!this._inputElementRef.value) return\n\n if (!isOpen || !this.multi) {\n if (this.multi) {\n const labels = options\n .filter(opt => selectedValues.includes(opt.value))\n .map(opt => opt.label || opt.textContent || '')\n this._inputValue = labels.join(', ')\n } else {\n const option = options.find(opt => opt.value === selectedValue)\n this._inputValue = option ? option.label || option.textContent || '' : ''\n }\n this._inputValue$.next(this._inputValue)\n this._inputElementRef.value.value = this._inputValue\n }\n }),\n take(1)\n ).subscribe()\n }\n\n private _getSelectedLabels(): string[] {\n return this._options\n .filter(option => \n this.multi \n ? this._selectedValues$.value.includes(option.value)\n : option.value === this._selectedValue$.value\n )\n .map(option => option.label || option.textContent || '')\n }\n\n private _announceToScreenReader(message: string) {\n const liveRegion = this.shadowRoot?.querySelector('#live-status')\n if (liveRegion) {\n liveRegion.textContent = message\n }\n }\n\n private _fireChangeEvent() {\n const detail: SchmancyAutocompleteChangeEvent['detail'] = {\n value: this.value,\n }\n\n if (this.multi) {\n detail.values = [...this._selectedValues$.value]\n }\n\n this.dispatchEvent(\n new CustomEvent<SchmancyAutocompleteChangeEvent['detail']>('change', {\n detail,\n bubbles: true,\n composed: true,\n })\n )\n }\n\n public checkValidity(): boolean {\n if (!this.required) return true\n return this.multi \n ? this._selectedValues$.value.length > 0 \n : Boolean(this._selectedValue$.value)\n }\n\n public reportValidity(): boolean {\n if (this._inputElementRef.value) {\n return this._inputElementRef.value.reportValidity()\n }\n return this.checkValidity()\n }\n\n firstUpdated() {\n timer(200).pipe(\n tap(() => this._checkAutofill$.next()),\n take(1)\n ).subscribe()\n \n this._options$.pipe(\n filter(options => options.length > 0),\n tap(() => this._checkAutofill$.next()),\n takeUntil(this.disconnecting)\n ).subscribe()\n }\n\n render() {\n const descriptionId = `${this.id}-desc`\n\n return html`\n <div class=\"relative\">\n <!-- Screen reader live region -->\n <div id=\"live-status\" role=\"status\" aria-live=\"polite\" class=\"sr-only\"></div>\n\n <!-- Description -->\n ${this.description ? html`<div id=\"${descriptionId}\" class=\"sr-only\">${this.description}</div>` : ''}\n\n <!-- Input -->\n <slot name=\"trigger\">\n <sch-input\n .size=${this.size}\n ${ref(this._inputElementRef)}\n id=\"autocomplete-input\"\n class=\"w-full\"\n .name=${this.name || this.label?.toLowerCase().replace(/\\s+/g, '-')}\n .label=${this.label}\n .placeholder=${this.placeholder}\n .required=${this.required}\n .value=${this._inputValue}\n type=\"text\"\n autocomplete=${this.autocomplete}\n clickable\n role=\"combobox\"\n aria-autocomplete=\"list\"\n aria-haspopup=\"listbox\"\n aria-controls=\"options\"\n aria-expanded=${this._open}\n aria-describedby=${this.description ? descriptionId : undefined}\n @input=${(e: Event) => {\n const value = (e.target as HTMLInputElement).value\n this._inputValue = value\n this._inputValue$.next(value)\n \n // If the input is cleared, also clear the selected value\n if (!value.trim() && !this.multi && this._selectedValue$.value) {\n this._selectedValue$.next('')\n this._fireChangeEvent()\n }\n }}\n @focus=${(e: FocusEvent) => {\n e.stopPropagation()\n \n const hasSelection = this.multi \n ? this._selectedValues$.value.length > 0\n : !!this._selectedValue$.value\n \n if (this.multi && !hasSelection) {\n this._inputValue = ''\n this._inputValue$.next('')\n if (this._inputElementRef.value) {\n this._inputElementRef.value.value = ''\n }\n }\n \n this._open$.next(true)\n }}\n @blur=${(e: FocusEvent) => {\n e.stopPropagation()\n // Delay to allow click events on options to fire first\n of(this._inputValue.trim()).pipe(\n withLatestFrom(this._open$),\n filter(([, isOpen]) => isOpen),\n tap(([inputValue]) => {\n // Only auto-select if there's input and no current selection (for single select)\n const shouldAutoSelect = inputValue && (\n this.multi \n ? true // Always try to match for multi-select\n : !this._selectedValue$.value // Only if no value for single select\n )\n \n if (shouldAutoSelect) {\n // Find best matching option\n let bestMatch: SchmancyOption | null = null\n let bestScore = 0\n \n this._options.forEach(option => {\n // Skip already selected options in multi mode\n if (this.multi && this._selectedValues$.value.includes(option.value)) {\n return\n }\n \n const optionLabel = option.label || option.textContent || ''\n const optionValue = option.value\n \n // Calculate similarity scores\n const labelScore = similarity(inputValue, optionLabel)\n const valueScore = similarity(inputValue, optionValue)\n \n // Use the higher score (prioritizing label matches)\n const score = Math.max(labelScore * 1.1, valueScore)\n \n // Keep track of best match\n if (score > bestScore && score >= this.similarityThreshold) {\n bestScore = score\n bestMatch = option\n }\n })\n \n // If we found a good match, select it\n if (bestMatch) {\n this._optionSelect$.next(bestMatch)\n } else {\n // Close dropdown without selection\n this._open$.next(false)\n this._updateInputDisplay()\n }\n } else {\n // Close dropdown\n this._open$.next(false)\n this._updateInputDisplay()\n }\n }),\n take(1)\n ).subscribe()\n }}\n @click=${(e: MouseEvent) => {\n e.stopPropagation()\n this._open$.next(true)\n }}\n @keydown=${(e: KeyboardEvent) => {\n this._handleKeyDown(e)\n }}\n >\n </sch-input>\n </slot>\n\n <!-- Options dropdown -->\n <ul\n id=\"options\"\n class=${classMap({\n 'absolute': true,\n 'z-[1000]': true,\n 'mt-1': true,\n 'w-full': true,\n 'rounded-md': true,\n 'shadow-md': true,\n 'overflow-auto': true,\n 'min-w-full': true,\n 'bg-surface-low': true,\n 'flex': true,\n 'flex-col': true, // Enable flexbox for ordering\n })}\n role=\"listbox\"\n aria-multiselectable=${this.multi ? 'true' : 'false'}\n aria-label=${`${this.label || 'Options'} dropdown`}\n ?hidden=${!this._open}\n style=\"max-height: ${this.maxHeight}; display: ${this._open ? 'flex' : 'none'};\"\n @slotchange=${() => {\n this._options$.next(this._options)\n timer(100).pipe(\n tap(() => this._checkAutofill$.next()),\n take(1)\n ).subscribe()\n }}\n >\n <slot></slot>\n ${!this._hasResults ? html`\n <li class=\"px-3 py-2 text-sm text-muted\">No results found</li>\n ` : ''}\n </ul>\n </div>\n\n <style>\n :host {\n display: block;\n }\n\n @keyframes onAutoFillStart {\n from {/**/}\n to {/**/}\n }\n\n sch-input::part(input):-webkit-autofill,\n sch-input input:-webkit-autofill {\n animation-name: onAutoFillStart;\n animation-duration: 1ms;\n }\n </style>\n `\n }\n\n private _handleKeyDown(_e: KeyboardEvent) {\n fromEvent<KeyboardEvent>(document, 'keydown').pipe(\n take(1),\n withLatestFrom(this._open$, this._options$),\n tap(([event, isOpen, options]) => {\n if (!isOpen && (event.key === 'ArrowDown' || event.key === 'Enter')) {\n event.preventDefault()\n this._open$.next(true)\n \n timer(10).pipe(\n tap(() => {\n const firstVisible = options.find(opt => !opt.hidden)\n firstVisible?.focus()\n }),\n take(1)\n ).subscribe()\n return\n }\n\n if (!isOpen) return\n\n const visibleOptions = options.filter(opt => !opt.hidden)\n .sort((a, b) => parseInt(a.style.order || '0') - parseInt(b.style.order || '0'))\n \n const focusedOption = visibleOptions.find(opt => opt === document.activeElement)\n const currentIndex = focusedOption ? visibleOptions.indexOf(focusedOption) : -1\n\n switch (event.key) {\n case 'Escape':\n event.preventDefault()\n this._open$.next(false)\n this._updateInputDisplay()\n this._inputElementRef.value?.focus()\n break\n\n case 'Tab':\n this._open$.next(false)\n this._updateInputDisplay()\n break\n\n case 'ArrowDown':\n event.preventDefault()\n const nextIndex = currentIndex < visibleOptions.length - 1 ? currentIndex + 1 : 0\n visibleOptions[nextIndex]?.focus()\n break\n\n case 'ArrowUp':\n event.preventDefault()\n const prevIndex = currentIndex > 0 ? currentIndex - 1 : visibleOptions.length - 1\n visibleOptions[prevIndex]?.focus()\n break\n\n case 'Home':\n event.preventDefault()\n visibleOptions[0]?.focus()\n break\n\n case 'End':\n event.preventDefault()\n visibleOptions[visibleOptions.length - 1]?.focus()\n break\n\n case 'Enter':\n case ' ':\n if (focusedOption) {\n event.preventDefault()\n this._optionSelect$.next(focusedOption)\n }\n break\n }\n })\n ).subscribe()\n }\n}\n\n\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'schmancy-autocomplete': SchmancyAutocomplete\n }\n}"],"names":["similarity","query","target","normalizedQuery","toLowerCase","trim","normalizedTarget","startsWith","length","words","split","word","indexOf","includes","sub","str","i","j","diceScore","s1","s2","bigrams1","getBigrams","bigrams2","intersection","used","Array","fill","bigram","maxLength","Math","max","levenshteinDistance","a","b","matrix","cost","min","levenshteinScore","anagramScore","countChars","s","reduce","acc","char","queryCount","targetCount","Object","keys","every","bigrams","push","substring","SchmancyAutocomplete","$LitElement","super","arguments","this","required","placeholder","label","name","maxHeight","multi","description","size","autocomplete","debounceMs","similarityThreshold","_open","_inputValue","_visibleOptionsCount","_hasResults","_inputElementRef","createRef","_selectedValue$","BehaviorSubject","_selectedValues$","_inputValue$","_open$","_options$","_optionSelect$","Subject","_documentClick$","_checkAutofill$","values","value","vals","next","isArray","join","val","map","v","filter","Boolean","connectedCallback","id","random","toString","slice","_setupAutocompleteLogic","_setupDocumentClickHandler","_setupAutofillDetection","pipe","tap","options","forEach","option","index","setAttribute","tabIndex","hasAttribute","fromEvent","e","stopPropagation","takeUntil","disconnecting","subscribe","combineLatest","selectedValue","selectedValues","selected","String","distinctUntilChanged","debounceTime","withLatestFrom","searchTerm","isOpen","term","scoredOptions","optionLabel","textContent","optionValue","labelScore","valueScore","score","sort","exactMatch","find","item","currentSelectedOption","_options","opt","currentSelectedLabel","visibleCount","hidden","style","order","_announceToScreenReader","_","currentValues","newValues","labels","_getSelectedLabels","timer","blur","take","_fireChangeEvent","open","composedPath","some","_updateInputDisplay","switchMap","document","addEventListener","EMPTY","of","removeEventListener","merge","window","startWith","schInput","shadowRoot","querySelector","_inputRef","input","autofilledValue","bestMatch","bestScore","displayValue","animationName","message","liveRegion","detail","dispatchEvent","CustomEvent","bubbles","composed","checkValidity","reportValidity","render","descriptionId","html","ref","replace","hasSelection","inputValue","_handleKeyDown","classMap","absolute","flex","_e","event","key","preventDefault","firstVisible","focus","visibleOptions","parseInt","focusedOption","activeElement","currentIndex","nextIndex","prevIndex","__decorateClass","property","type","prototype","reflect","Number","state","queryAssignedElements","flatten","customElement"],"mappings":";;;;;;;;;AASO,SAASA,EAAWC,GAAeC,GAAAA;AAEzC,OAAKD,KAAAA,CAAUC,EAAQ,QAAO;AAC9B,MAAID,MAAUC,EAAQ,QAAO;AAG7B,QAAMC,IAAkBF,EAAMG,cAAcC,KAAAA,GACtCC,IAAmBJ,EAAOE,YAAAA,EAAcC,KAAAA;AAG9C,MAAIF,MAAoBG,EAAkB,QAAO;AAGjD,MAAIA,EAAiBC,WAAWJ,CAAAA;AAG/B,WAAO,OAAsB,QADTA,EAAgBK,SAASF,EAAiBE;AAK/D,QAAMC,IAAQH,EAAiBI,MAAM,UAAA;AACrC,aAAWC,KAAQF,EAClB,KAAIE,EAAKJ,WAAWJ;AAInB,WAAO,QADmB,IADRM,EAAMG,QAAQD,CAAAA,IACWF,EAAMD,SAAU;AAM7D,MAAIF,EAAiBO,SAASV,CAAAA;AAI7B,WAAO,OADe,IADLG,EAAiBM,QAAQT,CAAAA,IACJG,EAAiBE,SAAU;AAKlE,MA+BD,SAAuBM,GAAaC,GAAAA;AACnC,QAAIC,IAAI,GACPC,IAAI;AACL,WAAOD,IAAIF,EAAIN,UAAUS,IAAIF,EAAIP,SAC5BM,CAAAA,EAAIE,CAAAA,MAAOD,EAAIE,CAAAA,KAAID,KACvBC;AAED,WAAOD,MAAMF,EAAIN;AAAAA,EAClB,EAvCmBL,GAAiBG,CAAAA,EAClC,QAAO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EAyBbqK,WAAA,SAAA,CAAA,GAgBaH,EAAA,CAAhBM,EAAAA,CAAAA,GAzCgBxK,EAyCAqK,WAAA,SAAA,IACAH,EAAA,CAAhBM,MA1CgBxK,EA0CAqK,WAAA,eAAA,CAAA,GACAH,EAAA,CAAhBM,EAAAA,CAAAA,GA3CgBxK,EA2CAqK,WAAA,wBAAA,CAAA,GACAH,EAAA,CAAhBM,EAAAA,CAAAA,GA5CgBxK,EA4CAqK,WAAA,eAAA,IAGEH,EAAA,CAAlBtN,EAAM,UAAA,CAAA,GA/CUoD,EA+CEqK,WAAA,YAAA,CAAA,GACCH,EAAA,CAAnBtN,EAAM,eAhDUoD,EAgDGqK,WAAA,UAAA,CAAA,GAC8BH,EAAA,CAAjDO,EAAsB,EAAEC,YAAS,CAAA,CAAA,GAjDjB1K,EAiDiCqK,WAAA,YAAA,CAAA,GAjDjCrK,IAArBkK,EAAA,CADCS,EAAc,uBAAA,CAAA,GACM3K,CAAAA;"}
|
|
@@ -1,74 +0,0 @@
|
|
|
1
|
-
"use strict";const u=require("rxjs"),S=require("lit/directives/class-map.js");require("lit/directives/style-map.js");const E=require("./litElement.mixin-B01R2oT7.cjs");require("./tailwind.mixin-DVKI3qb9.cjs");const c=require("lit/decorators.js"),k=require("lit"),w=require("lit/directives/ref.js"),e=require("rxjs/operators");function x(t,i){if(!t||!i)return 0;if(t===i)return 1;const s=t.toLowerCase().trim(),n=i.toLowerCase().trim();if(s===n)return 1;if(n.startsWith(s))return .95+.05*(s.length/n.length);const l=n.split(/[\s\-_]+/);for(const p of l)if(p.startsWith(s))return .85*(1-l.indexOf(p)/l.length*.1);if(n.includes(s))return .7*(1-n.indexOf(s)/n.length*.2);if(function(p,b){let f=0,r=0;for(;f<p.length&&r<b.length;)p[f]===b[r]&&f++,r++;return f===p.length}(s,n))return .5;const o=function(p,b){if(p.length<2||b.length<2)return 0;const f=C(p),r=C(b);let v=0;const y=new Array(r.length).fill(!1);for(const V of f)for(let g=0;g<r.length;g++)if(!y[g]&&r[g]===V){v++,y[g]=!0;break}return 2*v/(f.length+r.length)}(s,n),_=Math.max(s.length,n.length),a=function(p,b){if(p.length===0)return b.length;if(b.length===0)return p.length;const f=[];for(let r=0;r<=b.length;r++)f[r]=[r];for(let r=0;r<=p.length;r++)f[0][r]=r;for(let r=1;r<=b.length;r++)for(let v=1;v<=p.length;v++){const y=p[v-1]===b[r-1]?0:1;f[r][v]=Math.min(f[r-1][v]+1,f[r][v-1]+1,f[r-1][v-1]+y)}return f[b.length][p.length]}(s,n),m=_?1-a/_:0,$=function(p,b){const f=y=>y.split("").reduce((V,g)=>(V[g]=(V[g]||0)+1,V),{}),r=f(p),v=f(b);return Object.keys(r).every(y=>(v[y]||0)>=r[y])}(s,n)?.3:0;return Math.max(.4*o,.4*m,$)}function C(t){const i=[];for(let s=0;s<t.length-1;s++)i.push(t.substring(s,s+2));return i}var R=Object.defineProperty,A=Object.getOwnPropertyDescriptor,d=(t,i,s,n)=>{for(var l,o=n>1?void 0:n?A(i,s):i,_=t.length-1;_>=0;_--)(l=t[_])&&(o=(n?l(i,s,o):l(o))||o);return n&&o&&R(i,s,o),o};let h=class extends E.$LitElement(":host{display:block;border:unset!important;line-height:unset!important;background:unset!important;padding:unset!important;font-size:unset!important;box-shadow:unset!important}:host:focus{box-shadow:unset!important}"){constructor(){super(...arguments),this.required=!1,this.placeholder="",this.label="",this.name="",this.maxHeight="300px",this.multi=!1,this.description="",this.size="md",this.autocomplete="on",this.debounceMs=200,this.similarityThreshold=.3,this._open=!1,this._inputValue="",this._visibleOptionsCount=0,this._hasResults=!0,this._inputElementRef=w.createRef(),this._selectedValue$=new u.BehaviorSubject(""),this._selectedValues$=new u.BehaviorSubject([]),this._inputValue$=new u.BehaviorSubject(""),this._open$=new u.BehaviorSubject(!1),this._options$=new u.BehaviorSubject([]),this._optionSelect$=new u.Subject,this._documentClick$=new u.Subject,this._checkAutofill$=new u.Subject}get values(){return[...this._selectedValues$.value]}set values(t){this._selectedValues$.next(Array.isArray(t)?[...t]:[])}get value(){return this.multi?this._selectedValues$.value.join(","):this._selectedValue$.value}set value(t){this.multi?this._selectedValues$.next(t?t.split(",").map(i=>i.trim()).filter(Boolean):[]):this._selectedValue$.next(t)}connectedCallback(){super.connectedCallback(),this.id||(this.id=`sch-autocomplete-${Math.random().toString(36).slice(2,9)}`),this._setupAutocompleteLogic(),this._setupDocumentClickHandler(),this._setupAutofillDetection()}_setupAutocompleteLogic(){this._options$.pipe(e.tap(t=>{t.forEach((i,s)=>{i.setAttribute("role","option"),i.tabIndex=-1,i.id||(i.id=`${this.id}-option-${s}`),i.hasAttribute("data-event-bound")||(u.fromEvent(i,"click").pipe(e.tap(n=>n.stopPropagation()),e.takeUntil(this.disconnecting)).subscribe(()=>this._optionSelect$.next(i)),i.setAttribute("data-event-bound","true"))})}),e.takeUntil(this.disconnecting)).subscribe(),u.combineLatest([this._selectedValue$,this._selectedValues$,this._options$]).pipe(e.tap(([t,i,s])=>{s.forEach(n=>{n.selected=this.multi?i.includes(n.value):n.value===t,n.setAttribute("aria-selected",String(n.selected))})}),e.takeUntil(this.disconnecting)).subscribe(),this._inputValue$.pipe(e.distinctUntilChanged(),e.debounceTime(this.debounceMs),e.withLatestFrom(this._options$,this._open$),e.tap(([t,i,s])=>{if(!s)return;const n=t.trim();if(n){const l=i.map(a=>{const m=a.label||a.textContent||"",$=a.value,p=x(n,m),b=x(n,$);return{option:a,score:Math.max(1.1*p,b)}});l.sort((a,m)=>m.score-a.score);const o=l.find(a=>(a.option.label||a.option.textContent||"").toLowerCase().trim()===n.toLowerCase());if(o&&!this.multi){const a=this._options.find($=>$.value===this._selectedValue$.value),m=(a?.label||a?.textContent||"").toLowerCase().trim();if(n.toLowerCase()!==m)return void this._optionSelect$.next(o.option)}let _=0;l.forEach((a,m)=>{const{option:$,score:p}=a;p<this.similarityThreshold?$.hidden=!0:($.hidden=!1,_++,$.style.order=String(m))}),this._visibleOptionsCount=_,this._hasResults=_>0}else i.forEach(l=>{l.hidden=!1,l.style.order="0"}),this._visibleOptionsCount=i.length,this._hasResults=!0;this._announceToScreenReader(this._visibleOptionsCount>0?`${this._visibleOptionsCount} option${this._visibleOptionsCount===1?"":"s"} available.`:"No results found.")}),e.takeUntil(this.disconnecting)).subscribe(),this._optionSelect$.pipe(e.withLatestFrom(this._selectedValue$,this._selectedValues$),e.tap(([t,i,s])=>{if(this.multi){const n=s.indexOf(t.value),l=n>-1?[...s.slice(0,n),...s.slice(n+1)]:[...s,t.value];this._selectedValues$.next(l),this._inputValue$.next(""),this._inputValue="";const o=this._getSelectedLabels();this._announceToScreenReader(o.length>0?`Selected: ${o.join(", ")}`:"No options selected")}else this._selectedValue$.next(t.value),this._open$.next(!1),this._open=!1,this._inputValue=t.label||t.textContent||"",this._inputValue$.next(this._inputValue),u.timer(100).pipe(e.tap(()=>this._inputElementRef.value?.blur()),e.take(1)).subscribe(),this._announceToScreenReader(`Selected: ${t.label||t.textContent}`)}),e.tap(()=>this._fireChangeEvent()),e.takeUntil(this.disconnecting)).subscribe(),u.combineLatest([this._open$,this._selectedValue$,this._selectedValues$,this._options$]).pipe(e.filter(()=>!this._open$.value),e.tap(([,t,i,s])=>{if(this.multi){const n=s.filter(l=>i.includes(l.value)).map(l=>l.label||l.textContent||"");this._inputValue=n.join(", ")}else{const n=s.find(l=>l.value===t);this._inputValue=n&&(n.label||n.textContent)||""}this._inputValue$.next(this._inputValue)}),e.takeUntil(this.disconnecting)).subscribe(),this._open$.pipe(e.tap(t=>this._open=t),e.takeUntil(this.disconnecting)).subscribe()}_setupDocumentClickHandler(){this._documentClick$.pipe(e.filter(t=>!t.composedPath().includes(this)),e.filter(t=>!this._options.some(i=>t.composedPath().includes(i))),e.filter(()=>this._open),e.tap(()=>{this._open$.next(!1),this._updateInputDisplay()}),e.takeUntil(this.disconnecting)).subscribe(),this._open$.pipe(e.distinctUntilChanged(),e.switchMap(t=>t?u.timer(10).pipe(e.tap(()=>document.addEventListener("click",i=>this._documentClick$.next(i))),e.switchMap(()=>u.EMPTY)):u.of(null).pipe(e.tap(()=>document.removeEventListener("click",i=>this._documentClick$.next(i))))),e.takeUntil(this.disconnecting)).subscribe()}_setupAutofillDetection(){u.merge(u.timer(100,500).pipe(e.take(10)),this._checkAutofill$,u.timer(100).pipe(e.switchMap(()=>u.fromEvent(window,"load").pipe(e.startWith(null))))).pipe(e.map(()=>{const t=this._inputElementRef.value;return t?t.shadowRoot?.querySelector("input")||t.querySelector("input")||t._inputRef?.value:null}),e.filter(t=>!!t),e.map(t=>t.value),e.filter(t=>!!t&&t.trim().length>0),e.distinctUntilChanged(),e.withLatestFrom(this._options$),e.tap(([t,i])=>{let s=null,n=0;if(i.forEach(l=>{const o=l.label||l.textContent||"",_=l.value,a=x(t,o),m=x(t,_),$=Math.max(a,m);$>n&&$>=this.similarityThreshold&&(n=$,s=l)}),s&&n>=.95&&t.length>=3&&((s.label||s.textContent||"").toLowerCase()===t.toLowerCase()||s.value.toLowerCase()===t.toLowerCase())){this.multi?this._selectedValues$.next([s.value]):this._selectedValue$.next(s.value);const l=s.label||s.textContent||"";this._inputValue=l,this._inputValue$.next(l);const o=this._inputElementRef.value;o&&(o.value=l),this._open$.next(!1),this._fireChangeEvent(),this._announceToScreenReader(`Autofilled: ${l}`)}}),e.takeUntil(this.disconnecting)).subscribe(),u.timer(100).pipe(e.map(()=>{const t=this._inputElementRef.value;return t?t.shadowRoot?.querySelector("input")||t.querySelector("input")||t._inputRef?.value:null}),e.filter(t=>!!t),e.switchMap(t=>u.fromEvent(t,"animationstart").pipe(e.filter(i=>i.animationName==="onAutoFillStart"),e.tap(()=>{u.timer(100).pipe(e.tap(()=>this._checkAutofill$.next()),e.take(1)).subscribe()}))),e.takeUntil(this.disconnecting)).subscribe()}_updateInputDisplay(){u.of(null).pipe(e.withLatestFrom(this._selectedValue$,this._selectedValues$,this._options$,this._open$),e.tap(([,t,i,s,n])=>{if(this._inputElementRef.value&&(!n||!this.multi)){if(this.multi){const l=s.filter(o=>i.includes(o.value)).map(o=>o.label||o.textContent||"");this._inputValue=l.join(", ")}else{const l=s.find(o=>o.value===t);this._inputValue=l&&(l.label||l.textContent)||""}this._inputValue$.next(this._inputValue),this._inputElementRef.value.value=this._inputValue}}),e.take(1)).subscribe()}_getSelectedLabels(){return this._options.filter(t=>this.multi?this._selectedValues$.value.includes(t.value):t.value===this._selectedValue$.value).map(t=>t.label||t.textContent||"")}_announceToScreenReader(t){const i=this.shadowRoot?.querySelector("#live-status");i&&(i.textContent=t)}_fireChangeEvent(){const t={value:this.value};this.multi&&(t.values=[...this._selectedValues$.value]),this.dispatchEvent(new CustomEvent("change",{detail:t,bubbles:!0,composed:!0}))}checkValidity(){return!this.required||(this.multi?this._selectedValues$.value.length>0:!!this._selectedValue$.value)}reportValidity(){return this._inputElementRef.value?this._inputElementRef.value.reportValidity():this.checkValidity()}firstUpdated(){u.timer(200).pipe(e.tap(()=>this._checkAutofill$.next()),e.take(1)).subscribe(),this._options$.pipe(e.filter(t=>t.length>0),e.tap(()=>this._checkAutofill$.next()),e.takeUntil(this.disconnecting)).subscribe()}render(){const t=`${this.id}-desc`;return k.html`
|
|
2
|
-
<div class="relative">
|
|
3
|
-
<!-- Screen reader live region -->
|
|
4
|
-
<div id="live-status" role="status" aria-live="polite" class="sr-only"></div>
|
|
5
|
-
|
|
6
|
-
<!-- Description -->
|
|
7
|
-
${this.description?k.html`<div id="${t}" class="sr-only">${this.description}</div>`:""}
|
|
8
|
-
|
|
9
|
-
<!-- Input -->
|
|
10
|
-
<slot name="trigger">
|
|
11
|
-
<sch-input
|
|
12
|
-
.size=${this.size}
|
|
13
|
-
${w.ref(this._inputElementRef)}
|
|
14
|
-
id="autocomplete-input"
|
|
15
|
-
class="w-full"
|
|
16
|
-
.name=${this.name||this.label?.toLowerCase().replace(/\s+/g,"-")}
|
|
17
|
-
.label=${this.label}
|
|
18
|
-
.placeholder=${this.placeholder}
|
|
19
|
-
.required=${this.required}
|
|
20
|
-
.value=${this._inputValue}
|
|
21
|
-
type="text"
|
|
22
|
-
autocomplete=${this.autocomplete}
|
|
23
|
-
clickable
|
|
24
|
-
role="combobox"
|
|
25
|
-
aria-autocomplete="list"
|
|
26
|
-
aria-haspopup="listbox"
|
|
27
|
-
aria-controls="options"
|
|
28
|
-
aria-expanded=${this._open}
|
|
29
|
-
aria-describedby=${this.description?t:void 0}
|
|
30
|
-
@input=${i=>{const s=i.target.value;this._inputValue=s,this._inputValue$.next(s),s.trim()||this.multi||!this._selectedValue$.value||(this._selectedValue$.next(""),this._fireChangeEvent())}}
|
|
31
|
-
@focus=${i=>{i.stopPropagation();const s=this.multi?this._selectedValues$.value.length>0:!!this._selectedValue$.value;this.multi&&!s&&(this._inputValue="",this._inputValue$.next(""),this._inputElementRef.value&&(this._inputElementRef.value.value="")),this._open$.next(!0)}}
|
|
32
|
-
@blur=${i=>{i.stopPropagation(),u.of(this._inputValue.trim()).pipe(e.withLatestFrom(this._open$),e.filter(([,s])=>s),e.tap(([s])=>{if(s&&(this.multi||!this._selectedValue$.value)){let n=null,l=0;this._options.forEach(o=>{if(this.multi&&this._selectedValues$.value.includes(o.value))return;const _=o.label||o.textContent||"",a=o.value,m=x(s,_),$=x(s,a),p=Math.max(1.1*m,$);p>l&&p>=this.similarityThreshold&&(l=p,n=o)}),n?this._optionSelect$.next(n):(this._open$.next(!1),this._updateInputDisplay())}else this._open$.next(!1),this._updateInputDisplay()}),e.take(1)).subscribe()}}
|
|
33
|
-
@click=${i=>{i.stopPropagation(),this._open$.next(!0)}}
|
|
34
|
-
@keydown=${i=>{this._handleKeyDown(i)}}
|
|
35
|
-
>
|
|
36
|
-
</sch-input>
|
|
37
|
-
</slot>
|
|
38
|
-
|
|
39
|
-
<!-- Options dropdown -->
|
|
40
|
-
<ul
|
|
41
|
-
id="options"
|
|
42
|
-
class=${S.classMap({absolute:!0,"z-[1000]":!0,"mt-1":!0,"w-full":!0,"rounded-md":!0,"shadow-md":!0,"overflow-auto":!0,"min-w-full":!0,"bg-surface-low":!0,flex:!0,"flex-col":!0})}
|
|
43
|
-
role="listbox"
|
|
44
|
-
aria-multiselectable=${this.multi?"true":"false"}
|
|
45
|
-
aria-label=${`${this.label||"Options"} dropdown`}
|
|
46
|
-
?hidden=${!this._open}
|
|
47
|
-
style="max-height: ${this.maxHeight}; display: ${this._open?"flex":"none"};"
|
|
48
|
-
@slotchange=${()=>{this._options$.next(this._options),u.timer(100).pipe(e.tap(()=>this._checkAutofill$.next()),e.take(1)).subscribe()}}
|
|
49
|
-
>
|
|
50
|
-
<slot></slot>
|
|
51
|
-
${this._hasResults?"":k.html`
|
|
52
|
-
<li class="px-3 py-2 text-sm text-muted">No results found</li>
|
|
53
|
-
`}
|
|
54
|
-
</ul>
|
|
55
|
-
</div>
|
|
56
|
-
|
|
57
|
-
<style>
|
|
58
|
-
:host {
|
|
59
|
-
display: block;
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
@keyframes onAutoFillStart {
|
|
63
|
-
from {/**/}
|
|
64
|
-
to {/**/}
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
sch-input::part(input):-webkit-autofill,
|
|
68
|
-
sch-input input:-webkit-autofill {
|
|
69
|
-
animation-name: onAutoFillStart;
|
|
70
|
-
animation-duration: 1ms;
|
|
71
|
-
}
|
|
72
|
-
</style>
|
|
73
|
-
`}_handleKeyDown(t){u.fromEvent(document,"keydown").pipe(e.take(1),e.withLatestFrom(this._open$,this._options$),e.tap(([i,s,n])=>{if(!s&&(i.key==="ArrowDown"||i.key==="Enter"))return i.preventDefault(),this._open$.next(!0),void u.timer(10).pipe(e.tap(()=>{n.find(m=>!m.hidden)?.focus()}),e.take(1)).subscribe();if(!s)return;const l=n.filter(a=>!a.hidden).sort((a,m)=>parseInt(a.style.order||"0")-parseInt(m.style.order||"0")),o=l.find(a=>a===document.activeElement),_=o?l.indexOf(o):-1;switch(i.key){case"Escape":i.preventDefault(),this._open$.next(!1),this._updateInputDisplay(),this._inputElementRef.value?.focus();break;case"Tab":this._open$.next(!1),this._updateInputDisplay();break;case"ArrowDown":i.preventDefault();const a=_<l.length-1?_+1:0;l[a]?.focus();break;case"ArrowUp":i.preventDefault();const m=_>0?_-1:l.length-1;l[m]?.focus();break;case"Home":i.preventDefault(),l[0]?.focus();break;case"End":i.preventDefault(),l[l.length-1]?.focus();break;case"Enter":case" ":o&&(i.preventDefault(),this._optionSelect$.next(o))}})).subscribe()}};d([c.property({type:Boolean})],h.prototype,"required",2),d([c.property({type:String})],h.prototype,"placeholder",2),d([c.property({type:String,reflect:!0})],h.prototype,"label",2),d([c.property({type:String})],h.prototype,"name",2),d([c.property({type:String})],h.prototype,"maxHeight",2),d([c.property({type:Boolean})],h.prototype,"multi",2),d([c.property({type:String})],h.prototype,"description",2),d([c.property({type:String,reflect:!0})],h.prototype,"size",2),d([c.property({type:String})],h.prototype,"autocomplete",2),d([c.property({type:Number})],h.prototype,"debounceMs",2),d([c.property({type:Number})],h.prototype,"similarityThreshold",2),d([c.property({type:Array})],h.prototype,"values",1),d([c.property({type:String,reflect:!0})],h.prototype,"value",1),d([c.state()],h.prototype,"_open",2),d([c.state()],h.prototype,"_inputValue",2),d([c.state()],h.prototype,"_visibleOptionsCount",2),d([c.state()],h.prototype,"_hasResults",2),d([c.query("#options")],h.prototype,"_listbox",2),d([c.query("sch-input")],h.prototype,"_input",2),d([c.queryAssignedElements({flatten:!0})],h.prototype,"_options",2),h=d([c.customElement("schmancy-autocomplete")],h);
|
|
74
|
-
//# sourceMappingURL=autocomplete-cWc3oqB5.cjs.map
|