@mhmo91/schmancy 0.4.48 → 0.4.52
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/ai/dialog.md +6 -3
- package/dist/ai/dialog.md +6 -3
- package/dist/autocomplete-CkycjWy4.js +267 -0
- package/dist/autocomplete-CkycjWy4.js.map +1 -0
- package/dist/autocomplete-CrhgxhFI.cjs +73 -0
- package/dist/autocomplete-CrhgxhFI.cjs.map +1 -0
- package/dist/autocomplete.cjs +1 -1
- package/dist/autocomplete.js +1 -1
- package/dist/{avatar-DBcrNPzz.js → avatar-2RMudsVg.js} +7 -7
- package/dist/{avatar-DBcrNPzz.js.map → avatar-2RMudsVg.js.map} +1 -1
- package/dist/{avatar-CagKP9HD.cjs → avatar-nwqyt3uc.cjs} +2 -2
- package/dist/{avatar-CagKP9HD.cjs.map → avatar-nwqyt3uc.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/{date-range-DPZXGoEA.js → date-range-8o_f5N7V.js} +2 -2
- package/dist/{date-range-DPZXGoEA.js.map → date-range-8o_f5N7V.js.map} +1 -1
- package/dist/{date-range-Cf9ldt-N.cjs → date-range-9NUFmKqd.cjs} +2 -2
- package/dist/{date-range-Cf9ldt-N.cjs.map → date-range-9NUFmKqd.cjs.map} +1 -1
- package/dist/date-range.cjs +1 -1
- package/dist/date-range.js +1 -1
- package/dist/{dialog-content-CT6Y3ZLb.js → dialog-content-C_paCOeM.js} +2 -2
- package/dist/{dialog-content-CT6Y3ZLb.js.map → dialog-content-C_paCOeM.js.map} +1 -1
- package/dist/{dialog-content-tiwbeegi.cjs → dialog-content-tGl9B67L.cjs} +2 -2
- package/dist/{dialog-content-tiwbeegi.cjs.map → dialog-content-tGl9B67L.cjs.map} +1 -1
- package/dist/{dialog-service-Dm7HJGjx.js → dialog-service-DZv4KB89.js} +5 -2
- package/dist/{dialog-service-Dm7HJGjx.js.map → dialog-service-DZv4KB89.js.map} +1 -1
- package/dist/{dialog-service-DUDhcx9X.cjs → dialog-service-JNWTLfAy.cjs} +2 -2
- package/dist/{dialog-service-DUDhcx9X.cjs.map → dialog-service-JNWTLfAy.cjs.map} +1 -1
- package/dist/dialog.cjs +1 -1
- package/dist/dialog.js +2 -2
- package/dist/index.cjs +1 -1
- package/dist/index.js +16 -14
- package/dist/index.js.map +1 -1
- package/dist/nav-drawer.cjs +1 -1
- package/dist/nav-drawer.js +1 -1
- package/dist/search-6Hr7K1gh.js +53 -0
- package/dist/search-6Hr7K1gh.js.map +1 -0
- package/dist/search-DWW8IoOp.cjs +2 -0
- package/dist/search-DWW8IoOp.cjs.map +1 -0
- package/dist/{tabs-compatibility-DsOH4PSw.js → tabs-compatibility-BEXurIiZ.js} +6 -6
- package/dist/{tabs-compatibility-DsOH4PSw.js.map → tabs-compatibility-BEXurIiZ.js.map} +1 -1
- package/dist/tabs.js +1 -1
- package/dist/teleport.cjs +1 -1
- package/dist/teleport.js +1 -1
- package/dist/{typewriter-CnloNIdN.js → typewriter-DMKxup-I.js} +6 -6
- package/dist/{typewriter-CnloNIdN.js.map → typewriter-DMKxup-I.js.map} +1 -1
- package/dist/{typewriter-DwLZUKKQ.cjs → typewriter-Fq4uV6Gm.cjs} +2 -2
- package/dist/{typewriter-DwLZUKKQ.cjs.map → typewriter-Fq4uV6Gm.cjs.map} +1 -1
- package/dist/typewriter.cjs +1 -1
- package/dist/typewriter.js +1 -1
- package/dist/utils.cjs +1 -1
- package/dist/utils.js +3 -1
- package/dist/utils.js.map +1 -1
- package/package.json +1 -1
- package/types/src/dialog/dialog-service.d.ts +10 -0
- package/types/src/index.d.ts +0 -1
- package/types/src/utils/index.d.ts +1 -0
- package/dist/autocomplete-CHObbMzK.js +0 -315
- package/dist/autocomplete-CHObbMzK.js.map +0 -1
- package/dist/autocomplete-PHnzqAII.cjs +0 -73
- package/dist/autocomplete-PHnzqAII.cjs.map +0 -1
|
@@ -1,315 +0,0 @@
|
|
|
1
|
-
import { BehaviorSubject as S, Subject as O, fromEvent as E, combineLatest as L, timer as y, of as j, 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 f, state as R, 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 $, distinctUntilChanged as q, debounceTime as Y, withLatestFrom as C, take as w, filter as x, switchMap as A, startWith as G, map as T } from "rxjs/operators";
|
|
10
|
-
function D(e, t) {
|
|
11
|
-
if (!e || !t) return 0;
|
|
12
|
-
if (e === t) return 1;
|
|
13
|
-
const i = e.toLowerCase().trim(), n = t.toLowerCase().trim();
|
|
14
|
-
if (i === n) return 1;
|
|
15
|
-
if (n.startsWith(i))
|
|
16
|
-
return 0.95 + 0.05 * (i.length / n.length);
|
|
17
|
-
const s = n.split(/[\s\-_]+/);
|
|
18
|
-
for (const h of s) if (h.startsWith(i))
|
|
19
|
-
return 0.85 * (1 - s.indexOf(h) / s.length * 0.1);
|
|
20
|
-
if (n.includes(i))
|
|
21
|
-
return 0.7 * (1 - n.indexOf(i) / n.length * 0.2);
|
|
22
|
-
if (function(h, m) {
|
|
23
|
-
let d = 0, o = 0;
|
|
24
|
-
for (; d < h.length && o < m.length; ) h[d] === m[o] && d++, o++;
|
|
25
|
-
return d === h.length;
|
|
26
|
-
}(i, n)) return 0.5;
|
|
27
|
-
const l = function(h, m) {
|
|
28
|
-
if (h.length < 2 || m.length < 2) return 0;
|
|
29
|
-
const d = P(h), o = P(m);
|
|
30
|
-
let b = 0;
|
|
31
|
-
const g = new Array(o.length).fill(!1);
|
|
32
|
-
for (const k of d) for (let V = 0; V < o.length; V++) if (!g[V] && o[V] === k) {
|
|
33
|
-
b++, g[V] = !0;
|
|
34
|
-
break;
|
|
35
|
-
}
|
|
36
|
-
return 2 * b / (d.length + o.length);
|
|
37
|
-
}(i, n), a = Math.max(i.length, n.length), c = function(h, m) {
|
|
38
|
-
if (h.length === 0) return m.length;
|
|
39
|
-
if (m.length === 0) return h.length;
|
|
40
|
-
const d = [];
|
|
41
|
-
for (let o = 0; o <= m.length; o++) d[o] = [o];
|
|
42
|
-
for (let o = 0; o <= h.length; o++) d[0][o] = o;
|
|
43
|
-
for (let o = 1; o <= m.length; o++) for (let b = 1; b <= h.length; b++) {
|
|
44
|
-
const g = h[b - 1] === m[o - 1] ? 0 : 1;
|
|
45
|
-
d[o][b] = Math.min(d[o - 1][b] + 1, d[o][b - 1] + 1, d[o - 1][b - 1] + g);
|
|
46
|
-
}
|
|
47
|
-
return d[m.length][h.length];
|
|
48
|
-
}(i, n), _ = a ? 1 - c / a : 0, v = function(h, m) {
|
|
49
|
-
const d = (g) => g.split("").reduce((k, V) => (k[V] = (k[V] || 0) + 1, k), {}), o = d(h), b = d(m);
|
|
50
|
-
return Object.keys(o).every((g) => (b[g] || 0) >= o[g]);
|
|
51
|
-
}(i, n) ? 0.3 : 0;
|
|
52
|
-
return Math.max(0.4 * l, 0.4 * _, v);
|
|
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, n) => {
|
|
60
|
-
for (var s, l = n > 1 ? void 0 : n ? Q(t, i) : t, a = e.length - 1; a >= 0; a--) (s = e[a]) && (l = (n ? s(t, i, l) : s(l)) || l);
|
|
61
|
-
return n && l && J(t, i, l), l;
|
|
62
|
-
};
|
|
63
|
-
let u = 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 S(""), this._selectedValues$ = new S([]), this._inputValue$ = new S(""), this._open$ = new S(!1), this._options$ = new S([]), this._optionSelect$ = new O(), this._documentClick$ = new O(), this._checkAutofill$ = new O();
|
|
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") || (E(t, "click").pipe(r((n) => n.stopPropagation()), $(this.disconnecting)).subscribe(() => this._optionSelect$.next(t)), t.setAttribute("data-event-bound", "true"));
|
|
86
|
-
});
|
|
87
|
-
}), $(this.disconnecting)).subscribe(), L([this._selectedValue$, this._selectedValues$, this._options$]).pipe(r(([e, t, i]) => {
|
|
88
|
-
i.forEach((n) => {
|
|
89
|
-
n.selected = this.multi ? t.includes(n.value) : n.value === e, n.setAttribute("aria-selected", String(n.selected));
|
|
90
|
-
});
|
|
91
|
-
}), $(this.disconnecting)).subscribe(), this._inputValue$.pipe(q(), Y(this.debounceMs), C(this._options$, this._open$), r(([e, t, i]) => {
|
|
92
|
-
if (!i) return;
|
|
93
|
-
const n = e.trim();
|
|
94
|
-
if (n) {
|
|
95
|
-
const s = t.map((a) => {
|
|
96
|
-
const c = a.label || a.textContent || "", _ = a.value, v = D(n, c), h = D(n, _);
|
|
97
|
-
return { option: a, score: Math.max(1.1 * v, h) };
|
|
98
|
-
});
|
|
99
|
-
s.sort((a, c) => c.score - a.score);
|
|
100
|
-
let l = 0;
|
|
101
|
-
s.forEach((a, c) => {
|
|
102
|
-
const { option: _, score: v } = a;
|
|
103
|
-
v < this.similarityThreshold ? _.hidden = !0 : (_.hidden = !1, l++, _.style.order = String(c));
|
|
104
|
-
}), this._visibleOptionsCount = l, this._hasResults = l > 0;
|
|
105
|
-
} else t.forEach((s) => {
|
|
106
|
-
s.hidden = !1, s.style.order = "0";
|
|
107
|
-
}), this._visibleOptionsCount = t.length, this._hasResults = !0;
|
|
108
|
-
this._announceToScreenReader(this._visibleOptionsCount > 0 ? `${this._visibleOptionsCount} option${this._visibleOptionsCount === 1 ? "" : "s"} available.` : "No results found.");
|
|
109
|
-
}), $(this.disconnecting)).subscribe(), this._optionSelect$.pipe(C(this._selectedValue$, this._selectedValues$), r(([e, t, i]) => {
|
|
110
|
-
if (this.multi) {
|
|
111
|
-
const n = i.indexOf(e.value), s = n > -1 ? [...i.slice(0, n), ...i.slice(n + 1)] : [...i, e.value];
|
|
112
|
-
this._selectedValues$.next(s), this._inputValue$.next(""), this._inputValue = "";
|
|
113
|
-
const l = this._getSelectedLabels();
|
|
114
|
-
this._announceToScreenReader(l.length > 0 ? `Selected: ${l.join(", ")}` : "No options selected");
|
|
115
|
-
} else this._selectedValue$.next(e.value), this._open$.next(!1), this._open = !1, this._inputValue = e.label || e.textContent || "", this._inputValue$.next(this._inputValue), y(100).pipe(r(() => this._inputElementRef.value?.blur()), w(1)).subscribe(), this._announceToScreenReader(`Selected: ${e.label || e.textContent}`);
|
|
116
|
-
}), r(() => this._fireChangeEvent()), $(this.disconnecting)).subscribe(), L([this._open$, this._selectedValue$, this._selectedValues$, this._options$]).pipe(x(() => !this._open$.value), r(([, e, t, i]) => {
|
|
117
|
-
if (this.multi) {
|
|
118
|
-
const n = i.filter((s) => t.includes(s.value)).map((s) => s.label || s.textContent || "");
|
|
119
|
-
this._inputValue = n.join(", ");
|
|
120
|
-
} else {
|
|
121
|
-
const n = i.find((s) => s.value === e);
|
|
122
|
-
this._inputValue = n && (n.label || n.textContent) || "";
|
|
123
|
-
}
|
|
124
|
-
this._inputValue$.next(this._inputValue);
|
|
125
|
-
}), $(this.disconnecting)).subscribe(), this._open$.pipe(r((e) => this._open = e), $(this.disconnecting)).subscribe();
|
|
126
|
-
}
|
|
127
|
-
_setupDocumentClickHandler() {
|
|
128
|
-
this._documentClick$.pipe(x((e) => !e.composedPath().includes(this)), x((e) => !this._options.some((t) => e.composedPath().includes(t))), x(() => this._open), r(() => {
|
|
129
|
-
this._open$.next(!1), this._updateInputDisplay();
|
|
130
|
-
}), $(this.disconnecting)).subscribe(), this._open$.pipe(q(), A((e) => e ? y(10).pipe(r(() => document.addEventListener("click", (t) => this._documentClick$.next(t))), A(() => N)) : j(null).pipe(r(() => document.removeEventListener("click", (t) => this._documentClick$.next(t))))), $(this.disconnecting)).subscribe();
|
|
131
|
-
}
|
|
132
|
-
_setupAutofillDetection() {
|
|
133
|
-
z(y(100, 500).pipe(w(10)), this._checkAutofill$, y(100).pipe(A(() => E(window, "load").pipe(G(null))))).pipe(T(() => {
|
|
134
|
-
const e = this._inputElementRef.value;
|
|
135
|
-
return e ? e.shadowRoot?.querySelector("input") || e.querySelector("input") || e._inputRef?.value : null;
|
|
136
|
-
}), x((e) => !!e), T((e) => e.value), x((e) => !!e && e.trim().length > 0), q(), C(this._options$), r(([e, t]) => {
|
|
137
|
-
let i = null, n = 0;
|
|
138
|
-
if (t.forEach((s) => {
|
|
139
|
-
const l = s.label || s.textContent || "", a = s.value, c = D(e, l), _ = D(e, a), v = Math.max(c, _);
|
|
140
|
-
v > n && v >= this.similarityThreshold && (n = v, i = s);
|
|
141
|
-
}), i) {
|
|
142
|
-
this.multi ? this._selectedValues$.next([i.value]) : this._selectedValue$.next(i.value);
|
|
143
|
-
const s = i.label || i.textContent || "";
|
|
144
|
-
this._inputValue = s, this._inputValue$.next(s);
|
|
145
|
-
const l = this._inputElementRef.value;
|
|
146
|
-
l && (l.value = s), this._open$.next(!1), this._fireChangeEvent(), this._announceToScreenReader(`Autofilled: ${s}`);
|
|
147
|
-
}
|
|
148
|
-
}), $(this.disconnecting)).subscribe(), y(100).pipe(T(() => {
|
|
149
|
-
const e = this._inputElementRef.value;
|
|
150
|
-
return e ? e.shadowRoot?.querySelector("input") || e.querySelector("input") || e._inputRef?.value : null;
|
|
151
|
-
}), x((e) => !!e), A((e) => E(e, "animationstart").pipe(x((t) => t.animationName === "onAutoFillStart"), r(() => {
|
|
152
|
-
y(100).pipe(r(() => this._checkAutofill$.next()), w(1)).subscribe();
|
|
153
|
-
}))), $(this.disconnecting)).subscribe();
|
|
154
|
-
}
|
|
155
|
-
_updateInputDisplay() {
|
|
156
|
-
j(null).pipe(C(this._selectedValue$, this._selectedValues$, this._options$, this._open$), r(([, e, t, i, n]) => {
|
|
157
|
-
if (this._inputElementRef.value && (!n || !this.multi)) {
|
|
158
|
-
if (this.multi) {
|
|
159
|
-
const s = i.filter((l) => t.includes(l.value)).map((l) => l.label || l.textContent || "");
|
|
160
|
-
this._inputValue = s.join(", ");
|
|
161
|
-
} else {
|
|
162
|
-
const s = i.find((l) => l.value === e);
|
|
163
|
-
this._inputValue = s && (s.label || s.textContent) || "";
|
|
164
|
-
}
|
|
165
|
-
this._inputValue$.next(this._inputValue), this._inputElementRef.value.value = this._inputValue;
|
|
166
|
-
}
|
|
167
|
-
}), w(1)).subscribe();
|
|
168
|
-
}
|
|
169
|
-
_getSelectedLabels() {
|
|
170
|
-
return this._options.filter((e) => this.multi ? this._selectedValues$.value.includes(e.value) : e.value === this._selectedValue$.value).map((e) => e.label || e.textContent || "");
|
|
171
|
-
}
|
|
172
|
-
_announceToScreenReader(e) {
|
|
173
|
-
const t = this.shadowRoot?.querySelector("#live-status");
|
|
174
|
-
t && (t.textContent = e);
|
|
175
|
-
}
|
|
176
|
-
_fireChangeEvent() {
|
|
177
|
-
const e = { value: this.value };
|
|
178
|
-
this.multi && (e.values = [...this._selectedValues$.value]), this.dispatchEvent(new CustomEvent("change", { detail: e, bubbles: !0, composed: !0 }));
|
|
179
|
-
}
|
|
180
|
-
checkValidity() {
|
|
181
|
-
return !this.required || (this.multi ? this._selectedValues$.value.length > 0 : !!this._selectedValue$.value);
|
|
182
|
-
}
|
|
183
|
-
reportValidity() {
|
|
184
|
-
return this._inputElementRef.value ? this._inputElementRef.value.reportValidity() : this.checkValidity();
|
|
185
|
-
}
|
|
186
|
-
firstUpdated() {
|
|
187
|
-
y(200).pipe(r(() => this._checkAutofill$.next()), w(1)).subscribe(), this._options$.pipe(x((e) => e.length > 0), r(() => this._checkAutofill$.next()), $(this.disconnecting)).subscribe();
|
|
188
|
-
}
|
|
189
|
-
render() {
|
|
190
|
-
const e = `${this.id}-desc`;
|
|
191
|
-
return M`
|
|
192
|
-
<div class="relative">
|
|
193
|
-
<!-- Screen reader live region -->
|
|
194
|
-
<div id="live-status" role="status" aria-live="polite" class="sr-only"></div>
|
|
195
|
-
|
|
196
|
-
<!-- Description -->
|
|
197
|
-
${this.description ? M`<div id="${e}" class="sr-only">${this.description}</div>` : ""}
|
|
198
|
-
|
|
199
|
-
<!-- Input -->
|
|
200
|
-
<slot name="trigger">
|
|
201
|
-
<schmancy-input
|
|
202
|
-
.size=${this.size}
|
|
203
|
-
${K(this._inputElementRef)}
|
|
204
|
-
id="autocomplete-input"
|
|
205
|
-
class="w-full"
|
|
206
|
-
.name=${this.name || this.label?.toLowerCase().replace(/\s+/g, "-")}
|
|
207
|
-
.label=${this.label}
|
|
208
|
-
.placeholder=${this.placeholder}
|
|
209
|
-
.required=${this.required}
|
|
210
|
-
.value=${this._inputValue}
|
|
211
|
-
type="text"
|
|
212
|
-
autocomplete=${this.autocomplete}
|
|
213
|
-
clickable
|
|
214
|
-
role="combobox"
|
|
215
|
-
aria-autocomplete="list"
|
|
216
|
-
aria-haspopup="listbox"
|
|
217
|
-
aria-controls="options"
|
|
218
|
-
aria-expanded=${this._open}
|
|
219
|
-
aria-describedby=${this.description ? e : void 0}
|
|
220
|
-
@input=${(t) => {
|
|
221
|
-
const i = t.target.value;
|
|
222
|
-
this._inputValue = i, this._inputValue$.next(i);
|
|
223
|
-
}}
|
|
224
|
-
@focus=${(t) => {
|
|
225
|
-
t.stopPropagation();
|
|
226
|
-
const i = this.multi ? this._selectedValues$.value.length > 0 : !!this._selectedValue$.value;
|
|
227
|
-
this.multi && !i && (this._inputValue = "", this._inputValue$.next(""), this._inputElementRef.value && (this._inputElementRef.value.value = "")), this._open$.next(!0);
|
|
228
|
-
}}
|
|
229
|
-
@click=${(t) => {
|
|
230
|
-
t.stopPropagation(), this._open$.next(!0);
|
|
231
|
-
}}
|
|
232
|
-
@keydown=${(t) => {
|
|
233
|
-
this._handleKeyDown(t);
|
|
234
|
-
}}
|
|
235
|
-
>
|
|
236
|
-
</schmancy-input>
|
|
237
|
-
</slot>
|
|
238
|
-
|
|
239
|
-
<!-- Options dropdown -->
|
|
240
|
-
<ul
|
|
241
|
-
id="options"
|
|
242
|
-
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 })}
|
|
243
|
-
role="listbox"
|
|
244
|
-
aria-multiselectable=${this.multi ? "true" : "false"}
|
|
245
|
-
aria-label=${`${this.label || "Options"} dropdown`}
|
|
246
|
-
?hidden=${!this._open}
|
|
247
|
-
style="max-height: ${this.maxHeight}; display: ${this._open ? "flex" : "none"};"
|
|
248
|
-
@slotchange=${() => {
|
|
249
|
-
this._options$.next(this._options), y(100).pipe(r(() => this._checkAutofill$.next()), w(1)).subscribe();
|
|
250
|
-
}}
|
|
251
|
-
>
|
|
252
|
-
<slot></slot>
|
|
253
|
-
${this._hasResults ? "" : M`
|
|
254
|
-
<li class="px-3 py-2 text-sm text-muted">No results found</li>
|
|
255
|
-
`}
|
|
256
|
-
</ul>
|
|
257
|
-
</div>
|
|
258
|
-
|
|
259
|
-
<style>
|
|
260
|
-
:host {
|
|
261
|
-
display: block;
|
|
262
|
-
}
|
|
263
|
-
|
|
264
|
-
@keyframes onAutoFillStart {
|
|
265
|
-
from {/**/}
|
|
266
|
-
to {/**/}
|
|
267
|
-
}
|
|
268
|
-
|
|
269
|
-
sch-input::part(input):-webkit-autofill,
|
|
270
|
-
sch-input input:-webkit-autofill {
|
|
271
|
-
animation-name: onAutoFillStart;
|
|
272
|
-
animation-duration: 1ms;
|
|
273
|
-
}
|
|
274
|
-
</style>
|
|
275
|
-
`;
|
|
276
|
-
}
|
|
277
|
-
_handleKeyDown(e) {
|
|
278
|
-
E(document, "keydown").pipe(w(1), C(this._open$, this._options$), r(([t, i, n]) => {
|
|
279
|
-
if (!i && (t.key === "ArrowDown" || t.key === "Enter")) return t.preventDefault(), this._open$.next(!0), void y(10).pipe(r(() => {
|
|
280
|
-
n.find((_) => !_.hidden)?.focus();
|
|
281
|
-
}), w(1)).subscribe();
|
|
282
|
-
if (!i) return;
|
|
283
|
-
const s = n.filter((c) => !c.hidden).sort((c, _) => parseInt(c.style.order || "0") - parseInt(_.style.order || "0")), l = s.find((c) => c === document.activeElement), a = l ? s.indexOf(l) : -1;
|
|
284
|
-
switch (t.key) {
|
|
285
|
-
case "Escape":
|
|
286
|
-
t.preventDefault(), this._open$.next(!1), this._updateInputDisplay(), this._inputElementRef.value?.focus();
|
|
287
|
-
break;
|
|
288
|
-
case "Tab":
|
|
289
|
-
this._open$.next(!1), this._updateInputDisplay();
|
|
290
|
-
break;
|
|
291
|
-
case "ArrowDown":
|
|
292
|
-
t.preventDefault();
|
|
293
|
-
const c = a < s.length - 1 ? a + 1 : 0;
|
|
294
|
-
s[c]?.focus();
|
|
295
|
-
break;
|
|
296
|
-
case "ArrowUp":
|
|
297
|
-
t.preventDefault();
|
|
298
|
-
const _ = a > 0 ? a - 1 : s.length - 1;
|
|
299
|
-
s[_]?.focus();
|
|
300
|
-
break;
|
|
301
|
-
case "Home":
|
|
302
|
-
t.preventDefault(), s[0]?.focus();
|
|
303
|
-
break;
|
|
304
|
-
case "End":
|
|
305
|
-
t.preventDefault(), s[s.length - 1]?.focus();
|
|
306
|
-
break;
|
|
307
|
-
case "Enter":
|
|
308
|
-
case " ":
|
|
309
|
-
l && (t.preventDefault(), this._optionSelect$.next(l));
|
|
310
|
-
}
|
|
311
|
-
})).subscribe();
|
|
312
|
-
}
|
|
313
|
-
};
|
|
314
|
-
p([f({ type: Boolean })], u.prototype, "required", 2), p([f({ type: String })], u.prototype, "placeholder", 2), p([f({ type: String, reflect: !0 })], u.prototype, "label", 2), p([f({ type: String })], u.prototype, "name", 2), p([f({ type: String })], u.prototype, "maxHeight", 2), p([f({ type: Boolean })], u.prototype, "multi", 2), p([f({ type: String })], u.prototype, "description", 2), p([f({ type: String, reflect: !0 })], u.prototype, "size", 2), p([f({ type: String })], u.prototype, "autocomplete", 2), p([f({ type: Number })], u.prototype, "debounceMs", 2), p([f({ type: Number })], u.prototype, "similarityThreshold", 2), p([f({ type: Array })], u.prototype, "values", 1), p([f({ type: String, reflect: !0 })], u.prototype, "value", 1), p([R()], u.prototype, "_open", 2), p([R()], u.prototype, "_inputValue", 2), p([R()], u.prototype, "_visibleOptionsCount", 2), p([R()], u.prototype, "_hasResults", 2), p([I("#options")], u.prototype, "_listbox", 2), p([I("sch-input")], u.prototype, "_input", 2), p([F({ flatten: !0 })], u.prototype, "_options", 2), u = p([U("schmancy-autocomplete")], u);
|
|
315
|
-
//# sourceMappingURL=autocomplete-CHObbMzK.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"autocomplete-CHObbMzK.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, SchmancyInput } from '@schmancy/input'\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 (or include it inline)\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!: SchmancyInput\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 // 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 if (bestMatch) {\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 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 <schmancy-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 @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 @click=${(e: MouseEvent) => {\n e.stopPropagation()\n this._open$.next(true)\n }}\n @keydown=${(e: KeyboardEvent) => {\n this._handleKeyDown(e)\n }}\n >\n </schmancy-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","constructor","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","visibleCount","item","hidden","style","order","_announceToScreenReader","_","currentValues","newValues","labels","_getSelectedLabels","timer","blur","take","_fireChangeEvent","opt","find","open","composedPath","_options","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","reportValidity","checkValidity","firstUpdated","render","descriptionId","html","ref","replace","hasSelection","_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,MAAA,CAAKD,MAAUC,EAAQ,QAAO;AAC9B,MAAID,MAAUC,EAAQ,QAAO;AAG7B,QAAMC,IAAkBF,EAAMG,YAAAA,EAAcC,QACtCC,IAAmBJ,EAAOE,cAAcC,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,CAAAA;AAInB,WAAO,QADmB,IADRM,EAAMG,QAAQD,CAAAA,IACWF,EAAMD,SAAU;AAM7D,MAAIF,EAAiBO,SAASV;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,EAA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map.js");const C=require("./litElement.mixin-B01R2oT7.cjs");require("./tailwind.mixin-DVKI3qb9.cjs");const h=require("lit/decorators.js"),V=require("lit"),w=require("lit/directives/ref.js"),e=require("rxjs/operators");function k(t,i){if(!t||!i)return 0;if(t===i)return 1;const s=t.toLowerCase().trim(),l=i.toLowerCase().trim();if(s===l)return 1;if(l.startsWith(s))return .95+.05*(s.length/l.length);const n=l.split(/[\s\-_]+/);for(const d of n)if(d.startsWith(s))return .85*(1-n.indexOf(d)/n.length*.1);if(l.includes(s))return .7*(1-l.indexOf(s)/l.length*.2);if(function(d,b){let m=0,a=0;for(;m<d.length&&a<b.length;)d[m]===b[a]&&m++,a++;return m===d.length}(s,l))return .5;const o=function(d,b){if(d.length<2||b.length<2)return 0;const m=S(d),a=S(b);let $=0;const y=new Array(a.length).fill(!1);for(const x of m)for(let g=0;g<a.length;g++)if(!y[g]&&a[g]===x){$++,y[g]=!0;break}return 2*$/(m.length+a.length)}(s,l),u=Math.max(s.length,l.length),_=function(d,b){if(d.length===0)return b.length;if(b.length===0)return d.length;const m=[];for(let a=0;a<=b.length;a++)m[a]=[a];for(let a=0;a<=d.length;a++)m[0][a]=a;for(let a=1;a<=b.length;a++)for(let $=1;$<=d.length;$++){const y=d[$-1]===b[a-1]?0:1;m[a][$]=Math.min(m[a-1][$]+1,m[a][$-1]+1,m[a-1][$-1]+y)}return m[b.length][d.length]}(s,l),f=u?1-_/u:0,v=function(d,b){const m=y=>y.split("").reduce((x,g)=>(x[g]=(x[g]||0)+1,x),{}),a=m(d),$=m(b);return Object.keys(a).every(y=>($[y]||0)>=a[y])}(s,l)?.3:0;return Math.max(.4*o,.4*f,v)}function S(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,c=(t,i,s,l)=>{for(var n,o=l>1?void 0:l?A(i,s):i,u=t.length-1;u>=0;u--)(n=t[u])&&(o=(l?n(i,s,o):n(o))||o);return l&&o&&R(i,s,o),o};let p=class extends C.$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 r.BehaviorSubject(""),this._selectedValues$=new r.BehaviorSubject([]),this._inputValue$=new r.BehaviorSubject(""),this._open$=new r.BehaviorSubject(!1),this._options$=new r.BehaviorSubject([]),this._optionSelect$=new r.Subject,this._documentClick$=new r.Subject,this._checkAutofill$=new r.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")||(r.fromEvent(i,"click").pipe(e.tap(l=>l.stopPropagation()),e.takeUntil(this.disconnecting)).subscribe(()=>this._optionSelect$.next(i)),i.setAttribute("data-event-bound","true"))})}),e.takeUntil(this.disconnecting)).subscribe(),r.combineLatest([this._selectedValue$,this._selectedValues$,this._options$]).pipe(e.tap(([t,i,s])=>{s.forEach(l=>{l.selected=this.multi?i.includes(l.value):l.value===t,l.setAttribute("aria-selected",String(l.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 l=t.trim();if(l){const n=i.map(u=>{const _=u.label||u.textContent||"",f=u.value,v=k(l,_),d=k(l,f);return{option:u,score:Math.max(1.1*v,d)}});n.sort((u,_)=>_.score-u.score);let o=0;n.forEach((u,_)=>{const{option:f,score:v}=u;v<this.similarityThreshold?f.hidden=!0:(f.hidden=!1,o++,f.style.order=String(_))}),this._visibleOptionsCount=o,this._hasResults=o>0}else i.forEach(n=>{n.hidden=!1,n.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 l=s.indexOf(t.value),n=l>-1?[...s.slice(0,l),...s.slice(l+1)]:[...s,t.value];this._selectedValues$.next(n),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),r.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(),r.combineLatest([this._open$,this._selectedValue$,this._selectedValues$,this._options$]).pipe(e.filter(()=>!this._open$.value),e.tap(([,t,i,s])=>{if(this.multi){const l=s.filter(n=>i.includes(n.value)).map(n=>n.label||n.textContent||"");this._inputValue=l.join(", ")}else{const l=s.find(n=>n.value===t);this._inputValue=l&&(l.label||l.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?r.timer(10).pipe(e.tap(()=>document.addEventListener("click",i=>this._documentClick$.next(i))),e.switchMap(()=>r.EMPTY)):r.of(null).pipe(e.tap(()=>document.removeEventListener("click",i=>this._documentClick$.next(i))))),e.takeUntil(this.disconnecting)).subscribe()}_setupAutofillDetection(){r.merge(r.timer(100,500).pipe(e.take(10)),this._checkAutofill$,r.timer(100).pipe(e.switchMap(()=>r.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,l=0;if(i.forEach(n=>{const o=n.label||n.textContent||"",u=n.value,_=k(t,o),f=k(t,u),v=Math.max(_,f);v>l&&v>=this.similarityThreshold&&(l=v,s=n)}),s){this.multi?this._selectedValues$.next([s.value]):this._selectedValue$.next(s.value);const n=s.label||s.textContent||"";this._inputValue=n,this._inputValue$.next(n);const o=this._inputElementRef.value;o&&(o.value=n),this._open$.next(!1),this._fireChangeEvent(),this._announceToScreenReader(`Autofilled: ${n}`)}}),e.takeUntil(this.disconnecting)).subscribe(),r.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=>r.fromEvent(t,"animationstart").pipe(e.filter(i=>i.animationName==="onAutoFillStart"),e.tap(()=>{r.timer(100).pipe(e.tap(()=>this._checkAutofill$.next()),e.take(1)).subscribe()}))),e.takeUntil(this.disconnecting)).subscribe()}_updateInputDisplay(){r.of(null).pipe(e.withLatestFrom(this._selectedValue$,this._selectedValues$,this._options$,this._open$),e.tap(([,t,i,s,l])=>{if(this._inputElementRef.value&&(!l||!this.multi)){if(this.multi){const n=s.filter(o=>i.includes(o.value)).map(o=>o.label||o.textContent||"");this._inputValue=n.join(", ")}else{const n=s.find(o=>o.value===t);this._inputValue=n&&(n.label||n.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(){r.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 V.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?V.html`<div id="${t}" class="sr-only">${this.description}</div>`:""}
|
|
8
|
-
|
|
9
|
-
<!-- Input -->
|
|
10
|
-
<slot name="trigger">
|
|
11
|
-
<schmancy-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)}}
|
|
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
|
-
@click=${i=>{i.stopPropagation(),this._open$.next(!0)}}
|
|
33
|
-
@keydown=${i=>{this._handleKeyDown(i)}}
|
|
34
|
-
>
|
|
35
|
-
</schmancy-input>
|
|
36
|
-
</slot>
|
|
37
|
-
|
|
38
|
-
<!-- Options dropdown -->
|
|
39
|
-
<ul
|
|
40
|
-
id="options"
|
|
41
|
-
class=${E.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})}
|
|
42
|
-
role="listbox"
|
|
43
|
-
aria-multiselectable=${this.multi?"true":"false"}
|
|
44
|
-
aria-label=${`${this.label||"Options"} dropdown`}
|
|
45
|
-
?hidden=${!this._open}
|
|
46
|
-
style="max-height: ${this.maxHeight}; display: ${this._open?"flex":"none"};"
|
|
47
|
-
@slotchange=${()=>{this._options$.next(this._options),r.timer(100).pipe(e.tap(()=>this._checkAutofill$.next()),e.take(1)).subscribe()}}
|
|
48
|
-
>
|
|
49
|
-
<slot></slot>
|
|
50
|
-
${this._hasResults?"":V.html`
|
|
51
|
-
<li class="px-3 py-2 text-sm text-muted">No results found</li>
|
|
52
|
-
`}
|
|
53
|
-
</ul>
|
|
54
|
-
</div>
|
|
55
|
-
|
|
56
|
-
<style>
|
|
57
|
-
:host {
|
|
58
|
-
display: block;
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
@keyframes onAutoFillStart {
|
|
62
|
-
from {/**/}
|
|
63
|
-
to {/**/}
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
sch-input::part(input):-webkit-autofill,
|
|
67
|
-
sch-input input:-webkit-autofill {
|
|
68
|
-
animation-name: onAutoFillStart;
|
|
69
|
-
animation-duration: 1ms;
|
|
70
|
-
}
|
|
71
|
-
</style>
|
|
72
|
-
`}_handleKeyDown(t){r.fromEvent(document,"keydown").pipe(e.take(1),e.withLatestFrom(this._open$,this._options$),e.tap(([i,s,l])=>{if(!s&&(i.key==="ArrowDown"||i.key==="Enter"))return i.preventDefault(),this._open$.next(!0),void r.timer(10).pipe(e.tap(()=>{l.find(f=>!f.hidden)?.focus()}),e.take(1)).subscribe();if(!s)return;const n=l.filter(_=>!_.hidden).sort((_,f)=>parseInt(_.style.order||"0")-parseInt(f.style.order||"0")),o=n.find(_=>_===document.activeElement),u=o?n.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 _=u<n.length-1?u+1:0;n[_]?.focus();break;case"ArrowUp":i.preventDefault();const f=u>0?u-1:n.length-1;n[f]?.focus();break;case"Home":i.preventDefault(),n[0]?.focus();break;case"End":i.preventDefault(),n[n.length-1]?.focus();break;case"Enter":case" ":o&&(i.preventDefault(),this._optionSelect$.next(o))}})).subscribe()}};c([h.property({type:Boolean})],p.prototype,"required",2),c([h.property({type:String})],p.prototype,"placeholder",2),c([h.property({type:String,reflect:!0})],p.prototype,"label",2),c([h.property({type:String})],p.prototype,"name",2),c([h.property({type:String})],p.prototype,"maxHeight",2),c([h.property({type:Boolean})],p.prototype,"multi",2),c([h.property({type:String})],p.prototype,"description",2),c([h.property({type:String,reflect:!0})],p.prototype,"size",2),c([h.property({type:String})],p.prototype,"autocomplete",2),c([h.property({type:Number})],p.prototype,"debounceMs",2),c([h.property({type:Number})],p.prototype,"similarityThreshold",2),c([h.property({type:Array})],p.prototype,"values",1),c([h.property({type:String,reflect:!0})],p.prototype,"value",1),c([h.state()],p.prototype,"_open",2),c([h.state()],p.prototype,"_inputValue",2),c([h.state()],p.prototype,"_visibleOptionsCount",2),c([h.state()],p.prototype,"_hasResults",2),c([h.query("#options")],p.prototype,"_listbox",2),c([h.query("sch-input")],p.prototype,"_input",2),c([h.queryAssignedElements({flatten:!0})],p.prototype,"_options",2),p=c([h.customElement("schmancy-autocomplete")],p);
|
|
73
|
-
//# sourceMappingURL=autocomplete-PHnzqAII.cjs.map
|