@telia-ace/knowledge-widget-components-search 1.0.14 → 1.0.17
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/index.js +140 -221
- package/dist/index.js.map +1 -1
- package/dist/search.ffb2e6c2.js +779 -0
- package/dist/search.ffb2e6c2.js.map +1 -0
- package/package.json +11 -7
- package/dist/search.js +0 -1063
- package/dist/search.js.map +0 -1
|
@@ -0,0 +1,779 @@
|
|
|
1
|
+
var Ae = Object.defineProperty, Ie = Object.defineProperties;
|
|
2
|
+
var qe = Object.getOwnPropertyDescriptors;
|
|
3
|
+
var Q = Object.getOwnPropertySymbols;
|
|
4
|
+
var re = Object.prototype.hasOwnProperty, se = Object.prototype.propertyIsEnumerable;
|
|
5
|
+
var ne = (e, t, o) => t in e ? Ae(e, t, { enumerable: !0, configurable: !0, writable: !0, value: o }) : e[t] = o, B = (e, t) => {
|
|
6
|
+
for (var o in t || (t = {}))
|
|
7
|
+
re.call(t, o) && ne(e, o, t[o]);
|
|
8
|
+
if (Q)
|
|
9
|
+
for (var o of Q(t))
|
|
10
|
+
se.call(t, o) && ne(e, o, t[o]);
|
|
11
|
+
return e;
|
|
12
|
+
}, D = (e, t) => Ie(e, qe(t));
|
|
13
|
+
var U = (e, t) => {
|
|
14
|
+
var o = {};
|
|
15
|
+
for (var r in e)
|
|
16
|
+
re.call(e, r) && t.indexOf(r) < 0 && (o[r] = e[r]);
|
|
17
|
+
if (e != null && Q)
|
|
18
|
+
for (var r of Q(e))
|
|
19
|
+
t.indexOf(r) < 0 && se.call(e, r) && (o[r] = e[r]);
|
|
20
|
+
return o;
|
|
21
|
+
};
|
|
22
|
+
import { Component as ze } from "@telia-ace/knowledge-widget-types-grid";
|
|
23
|
+
import { borderTabStyle as _, Text as de, Link as fe, SymbolBadge as H, useProperties as P, useDispatch as M, useRouteData as ge, useEventListener as J, useKeyPress as G, Tooltip as Fe, ItemTree as Be, contentBox as me, useScroll as Le, useContainer as he, Loader as De, useDebounce as Te, usePrevious as ae, useChildren as Ne, useWidgetEvent as Oe, useTransitionEnd as Ke, convertToStringAttributes as Pe, Input as We, Button as pe } from "@telia-ace/knowledge-widget-ui";
|
|
24
|
+
import { appendClassNames as R, deepClone as je, categoryTrail as Qe } from "@telia-ace/widget-utilities";
|
|
25
|
+
import f, { useRef as V, useState as N, useCallback as I, useEffect as O } from "react";
|
|
26
|
+
import z, { css as K } from "styled-components";
|
|
27
|
+
const Xe = (v) => {
|
|
28
|
+
var b = v, {
|
|
29
|
+
text: e,
|
|
30
|
+
className: t,
|
|
31
|
+
forceFocusStyle: o,
|
|
32
|
+
filterType: r,
|
|
33
|
+
handleClick: l,
|
|
34
|
+
deleteAriaLabel: c = ""
|
|
35
|
+
} = b, s = U(b, [
|
|
36
|
+
"text",
|
|
37
|
+
"className",
|
|
38
|
+
"forceFocusStyle",
|
|
39
|
+
"filterType",
|
|
40
|
+
"handleClick",
|
|
41
|
+
"deleteAriaLabel"
|
|
42
|
+
]);
|
|
43
|
+
const k = V();
|
|
44
|
+
return /* @__PURE__ */ f.createElement(de, {
|
|
45
|
+
className: R(t, "humany-filter-badge"),
|
|
46
|
+
onKeyDown: (y) => {
|
|
47
|
+
y.key === "Enter" && l(y, r);
|
|
48
|
+
}
|
|
49
|
+
}, e, /* @__PURE__ */ f.createElement(fe, D(B({}, s), {
|
|
50
|
+
ref: k,
|
|
51
|
+
tabIndex: 0,
|
|
52
|
+
role: "button",
|
|
53
|
+
"aria-label": c.replace("{{item}}", e),
|
|
54
|
+
onClick: (y) => l(y, r)
|
|
55
|
+
}), /* @__PURE__ */ f.createElement(H, {
|
|
56
|
+
size: 13,
|
|
57
|
+
symbol: { type: "Svg", content: "close" }
|
|
58
|
+
})));
|
|
59
|
+
}, Me = ({
|
|
60
|
+
inputHasFocus: e,
|
|
61
|
+
searchContainerRef: t,
|
|
62
|
+
showTag: o,
|
|
63
|
+
showGuideCategory: r,
|
|
64
|
+
position: l
|
|
65
|
+
}) => {
|
|
66
|
+
const { activeFilterBadges: c = {}, deleteFilterBadgeAriaLabel: s = "" } = P(), v = M(), { name: b, params: k } = ge(), [y, u] = N(!1), $ = I((m) => {
|
|
67
|
+
const { key: a } = m;
|
|
68
|
+
["ArrowLeft", "ArrowRight"].indexOf(a) === -1 && u(!1);
|
|
69
|
+
}, []);
|
|
70
|
+
J("keydown", $, window), J("click", $, window);
|
|
71
|
+
const { guideCategory: S, tag: x, tooltip: A } = c, d = (m) => {
|
|
72
|
+
const a = m.querySelectorAll(".humany-filter-badge");
|
|
73
|
+
return {
|
|
74
|
+
badges: a,
|
|
75
|
+
index: Array.from(a).findIndex((h) => document.activeElement === h)
|
|
76
|
+
};
|
|
77
|
+
}, n = (m, a) => {
|
|
78
|
+
m.preventDefault(), v("quick-filter:remove", { types: [a] });
|
|
79
|
+
}, i = (m, a) => {
|
|
80
|
+
if (!t)
|
|
81
|
+
return;
|
|
82
|
+
const { badges: h, index: p } = d(t);
|
|
83
|
+
if (h.length) {
|
|
84
|
+
let q = null;
|
|
85
|
+
m === "left" ? p === -1 ? q = h.item(h.length - 1) : p > 0 && (q = h.item(p - 1)) : m === "right" && (p === h.length - 1 ? a && a.focus() : h.item(p + 1) && (q = h.item(p + 1))), q && (q.focus(), u(!0));
|
|
86
|
+
}
|
|
87
|
+
};
|
|
88
|
+
G("ArrowLeft", I(() => {
|
|
89
|
+
if (!t)
|
|
90
|
+
return;
|
|
91
|
+
const { index: m } = d(t);
|
|
92
|
+
if (e || m > -1) {
|
|
93
|
+
const a = t.querySelector('[data-type="search"]'), h = a && a.selectionStart !== null && a.selectionStart <= 0, p = m > -1;
|
|
94
|
+
(h || p) && i("left", a);
|
|
95
|
+
}
|
|
96
|
+
}, [e, t])), G("ArrowRight", I(() => {
|
|
97
|
+
if (!t)
|
|
98
|
+
return;
|
|
99
|
+
const { index: m } = d(t);
|
|
100
|
+
if (m > -1) {
|
|
101
|
+
const a = t.querySelector('[data-type="search"]');
|
|
102
|
+
m > -1 && i("right", a);
|
|
103
|
+
}
|
|
104
|
+
}, [t])), G("Backspace", I((m) => {
|
|
105
|
+
if (!t)
|
|
106
|
+
return;
|
|
107
|
+
let a = [];
|
|
108
|
+
const { index: h } = d(t), p = t.querySelector('[data-type="search"]');
|
|
109
|
+
h > -1 ? h === 0 ? r ? a = ["guideCategory"] : o && (a = ["tag"]) : h === 1 && (a = ["tag"]) : p && p.selectionStart !== null && p.selectionStart <= 0 && (c != null && c.tag ? a = ["tag"] : c != null && c.guideCategory && (a = ["guideCategory"])), a.length > 0 && (m.preventDefault(), v("quick-filter:remove", { types: a }));
|
|
110
|
+
}, [t, c, o, r]));
|
|
111
|
+
const g = I((m) => m === "guideCategory" && S && r ? /* @__PURE__ */ f.createElement(ie, {
|
|
112
|
+
text: `@${S.title}`,
|
|
113
|
+
routeName: b,
|
|
114
|
+
filterType: "guideCategory",
|
|
115
|
+
handleClick: n,
|
|
116
|
+
forceFocusStyle: y,
|
|
117
|
+
deleteAriaLabel: s,
|
|
118
|
+
params: D(B({}, k), {
|
|
119
|
+
guideCategory: void 0
|
|
120
|
+
})
|
|
121
|
+
}) : m === "tag" && x && o ? /* @__PURE__ */ f.createElement(ie, {
|
|
122
|
+
className: "humany-filter-badge",
|
|
123
|
+
text: `#${x.title}`,
|
|
124
|
+
routeName: b,
|
|
125
|
+
filterType: "tag",
|
|
126
|
+
handleClick: n,
|
|
127
|
+
forceFocusStyle: y,
|
|
128
|
+
deleteAriaLabel: s,
|
|
129
|
+
params: D(B({}, k), {
|
|
130
|
+
tag: void 0
|
|
131
|
+
})
|
|
132
|
+
}) : null, [S, x, b, k, r, o, y]);
|
|
133
|
+
return !S && !x ? null : /* @__PURE__ */ f.createElement(Ue, {
|
|
134
|
+
className: "humany-filter-badges",
|
|
135
|
+
position: l
|
|
136
|
+
}, S && A ? /* @__PURE__ */ f.createElement(Fe, {
|
|
137
|
+
content: /* @__PURE__ */ f.createElement(f.Fragment, null, A),
|
|
138
|
+
sticky: !1
|
|
139
|
+
}, g("guideCategory")) : g("guideCategory"), x && g("tag"));
|
|
140
|
+
}, Ue = z.div`
|
|
141
|
+
display: flex;
|
|
142
|
+
align-items: center;
|
|
143
|
+
flex-wrap: wrap;
|
|
144
|
+
|
|
145
|
+
${(e) => e.position === "inside" ? K`
|
|
146
|
+
&:not(:first-child) {
|
|
147
|
+
margin: 0 0 0 ${(t) => {
|
|
148
|
+
var o;
|
|
149
|
+
return (o = t.theme.sizes) == null ? void 0 : o.normal;
|
|
150
|
+
}};
|
|
151
|
+
}
|
|
152
|
+
` : K`
|
|
153
|
+
margin: ${(t) => {
|
|
154
|
+
var o;
|
|
155
|
+
return (o = t.theme.sizes) == null ? void 0 : o.small;
|
|
156
|
+
}} 0 0 0;
|
|
157
|
+
span:first-child {
|
|
158
|
+
margin-left: 0;
|
|
159
|
+
}
|
|
160
|
+
`}
|
|
161
|
+
`, ie = z(Xe)`
|
|
162
|
+
display: flex;
|
|
163
|
+
align-items: center;
|
|
164
|
+
padding: ${(e) => {
|
|
165
|
+
var t, o;
|
|
166
|
+
return `${(t = e.theme.sizes) == null ? void 0 : t.small} calc(${(o = e.theme.sizes) == null ? void 0 : o.normal}/2) `;
|
|
167
|
+
}};
|
|
168
|
+
background-color: ${(e) => {
|
|
169
|
+
var t;
|
|
170
|
+
return (t = e.theme.colors) == null ? void 0 : t.primary;
|
|
171
|
+
}};
|
|
172
|
+
border-radius: ${(e) => e.theme.borderRadius};
|
|
173
|
+
font-weight: 300;
|
|
174
|
+
font-size: ${(e) => {
|
|
175
|
+
var t;
|
|
176
|
+
return (t = e.theme.fonts) == null ? void 0 : t.normal;
|
|
177
|
+
}};
|
|
178
|
+
font-style: italic;
|
|
179
|
+
color: #ffffff;
|
|
180
|
+
text-decoration: none;
|
|
181
|
+
white-space: nowrap;
|
|
182
|
+
|
|
183
|
+
margin: calc(${(e) => {
|
|
184
|
+
var t;
|
|
185
|
+
return (t = e.theme.sizes) == null ? void 0 : t.small;
|
|
186
|
+
}} / 2);
|
|
187
|
+
|
|
188
|
+
&:focus-within {
|
|
189
|
+
${(e) => {
|
|
190
|
+
var t;
|
|
191
|
+
return (((t = e.theme.accessibility) == null ? void 0 : t.isTabbing) || e.forceFocusStyle) && K`
|
|
192
|
+
${_}
|
|
193
|
+
background-color: transparent;
|
|
194
|
+
|
|
195
|
+
svg {
|
|
196
|
+
path {
|
|
197
|
+
stroke: ${(o) => {
|
|
198
|
+
var r;
|
|
199
|
+
return (r = o.theme.colors) == null ? void 0 : r.primary;
|
|
200
|
+
}};
|
|
201
|
+
}
|
|
202
|
+
}
|
|
203
|
+
`;
|
|
204
|
+
}};
|
|
205
|
+
a {
|
|
206
|
+
outline: none;
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
svg {
|
|
211
|
+
width: 17px;
|
|
212
|
+
height: 11px;
|
|
213
|
+
margin: 1px 0 0 ${(e) => {
|
|
214
|
+
var t;
|
|
215
|
+
return (t = e.theme.sizes) == null ? void 0 : t.small;
|
|
216
|
+
}};
|
|
217
|
+
path {
|
|
218
|
+
stroke: #ffffff;
|
|
219
|
+
stroke-width: 2px;
|
|
220
|
+
}
|
|
221
|
+
order: 1;
|
|
222
|
+
}
|
|
223
|
+
`, T = (e, t) => !t || !e ? !0 : e.toLowerCase().indexOf(t.toLowerCase()) > -1, Ge = (e = [], t, o) => {
|
|
224
|
+
if (!o)
|
|
225
|
+
return e;
|
|
226
|
+
const r = je(e);
|
|
227
|
+
if (t === "tag")
|
|
228
|
+
return r.filter((s) => T(s.title, o));
|
|
229
|
+
const l = He(r, o);
|
|
230
|
+
return ye(r, (s) => l.indexOf(s.id) > -1);
|
|
231
|
+
}, ye = (e, t) => e.filter((o) => (o.items && o.items.length && (o.items = ye(o.items, t)), t(o))), He = (e, t) => {
|
|
232
|
+
const r = be(e).filter((c) => T(c.title, t)).map((c) => c.id);
|
|
233
|
+
let l = [];
|
|
234
|
+
return r.forEach((c) => {
|
|
235
|
+
const s = Qe(c, e);
|
|
236
|
+
l = l.concat(s);
|
|
237
|
+
}), l;
|
|
238
|
+
}, be = (e) => {
|
|
239
|
+
let t = [];
|
|
240
|
+
return e.forEach((o) => {
|
|
241
|
+
t.push(o), Array.isArray(o.items) && (t = t.concat(be(o.items)));
|
|
242
|
+
}), t;
|
|
243
|
+
}, Y = (e) => {
|
|
244
|
+
const t = Array.from((e == null ? void 0 : e.getElementsByTagName("A")) || []).filter((o) => o.getAttribute("disabled") === null);
|
|
245
|
+
return {
|
|
246
|
+
anchors: t,
|
|
247
|
+
focusedIndex: t.findIndex((o) => document.activeElement === o)
|
|
248
|
+
};
|
|
249
|
+
}, Je = (e) => e ? e.querySelector('[data-type="search"], input[type="search"]') : null, Z = (e) => {
|
|
250
|
+
if (!e)
|
|
251
|
+
return;
|
|
252
|
+
const t = Je(e);
|
|
253
|
+
t && t.focus();
|
|
254
|
+
}, Ye = ({
|
|
255
|
+
filterPhrase: e,
|
|
256
|
+
items: t,
|
|
257
|
+
filterType: o,
|
|
258
|
+
filterContainer: r,
|
|
259
|
+
searchContainer: l,
|
|
260
|
+
inputHasFocus: c
|
|
261
|
+
}) => {
|
|
262
|
+
const [s, v] = N(t || []), [b, k] = N(null), y = M(), { activeFilterBadges: u, quickFilters: $ } = P(), S = typeof $ == "object" && !!$.autoSelect || typeof $ == "boolean" && !!$;
|
|
263
|
+
O(() => {
|
|
264
|
+
v(Ge(t, o, e));
|
|
265
|
+
}, [e, o, t]), O(() => {
|
|
266
|
+
var d;
|
|
267
|
+
if (r) {
|
|
268
|
+
const { anchors: n } = Y(r), i = (d = n[0]) == null ? void 0 : d.getAttribute("data-id");
|
|
269
|
+
i && k(i);
|
|
270
|
+
}
|
|
271
|
+
}, [s, r]);
|
|
272
|
+
const x = I((d, n) => {
|
|
273
|
+
const i = {
|
|
274
|
+
category: u != null && u.guideCategory ? u.guideCategory.id : void 0,
|
|
275
|
+
tag: u != null && u.tag ? u.tag.id : void 0
|
|
276
|
+
};
|
|
277
|
+
n === "guideCategory" ? i.category = d.id : n === "tag" && (i.tag = d.id), y("quick-filter:add", i);
|
|
278
|
+
}, [u, y]), A = (d) => d === "guideCategory" ? {
|
|
279
|
+
renderItem: (n, i) => /* @__PURE__ */ f.createElement(ue, {
|
|
280
|
+
autoSelect: S && c && n.id === b,
|
|
281
|
+
disabled: !T(n.title, e),
|
|
282
|
+
tabIndex: T(n.title, e) ? 0 : -1,
|
|
283
|
+
onKeyDown: (g) => {
|
|
284
|
+
g.key === "Enter" && x(n, d);
|
|
285
|
+
},
|
|
286
|
+
"data-level": i,
|
|
287
|
+
onClick: () => {
|
|
288
|
+
x(n, d);
|
|
289
|
+
},
|
|
290
|
+
"data-id": n.id
|
|
291
|
+
}, /* @__PURE__ */ f.createElement(ce, {
|
|
292
|
+
title: n.title,
|
|
293
|
+
phrase: e,
|
|
294
|
+
matches: T(n.title, e)
|
|
295
|
+
}))
|
|
296
|
+
} : {
|
|
297
|
+
renderLi: !0,
|
|
298
|
+
renderItem: (n) => /* @__PURE__ */ f.createElement(ue, {
|
|
299
|
+
autoSelect: S && c && n.id === b,
|
|
300
|
+
onKeyDown: (i) => {
|
|
301
|
+
i.key === "Enter" && x(n, d);
|
|
302
|
+
},
|
|
303
|
+
onClick: () => {
|
|
304
|
+
x(n, d);
|
|
305
|
+
},
|
|
306
|
+
"data-id": n.id
|
|
307
|
+
}, /* @__PURE__ */ f.createElement(ce, {
|
|
308
|
+
symbol: "#",
|
|
309
|
+
title: n.title,
|
|
310
|
+
phrase: e,
|
|
311
|
+
matches: T(n.title, e)
|
|
312
|
+
}))
|
|
313
|
+
};
|
|
314
|
+
return J("keydown", (d) => {
|
|
315
|
+
var q;
|
|
316
|
+
const { key: n } = d;
|
|
317
|
+
if (!r || !(n === "ArrowDown" || n === "ArrowUp" || n === "Enter"))
|
|
318
|
+
return;
|
|
319
|
+
const { anchors: i, focusedIndex: g } = Y(r);
|
|
320
|
+
if (n === "Enter") {
|
|
321
|
+
if (c && S) {
|
|
322
|
+
const w = (q = i[0]) == null ? void 0 : q.getAttribute("data-id");
|
|
323
|
+
w && x({ id: w }, o);
|
|
324
|
+
}
|
|
325
|
+
return;
|
|
326
|
+
}
|
|
327
|
+
const m = () => {
|
|
328
|
+
var w;
|
|
329
|
+
return (w = i[0]) == null ? void 0 : w.focus();
|
|
330
|
+
}, a = () => {
|
|
331
|
+
var w;
|
|
332
|
+
return (w = i[i.length - 1]) == null ? void 0 : w.focus();
|
|
333
|
+
}, h = () => {
|
|
334
|
+
var w;
|
|
335
|
+
return (w = i[g + 1]) == null ? void 0 : w.focus();
|
|
336
|
+
}, p = () => {
|
|
337
|
+
var w;
|
|
338
|
+
return (w = i[g - 1]) == null ? void 0 : w.focus();
|
|
339
|
+
};
|
|
340
|
+
c ? (d.preventDefault(), n === "ArrowDown" ? m() : a()) : g > -1 && (d.preventDefault(), n === "ArrowDown" ? i.length > g + 1 ? h() : Z(l) : g - 1 < 0 ? Z(l) : p());
|
|
341
|
+
}, window), /* @__PURE__ */ f.createElement(Be, B({
|
|
342
|
+
tree: s,
|
|
343
|
+
renderEmpty: !1,
|
|
344
|
+
ulProps: { role: "listbox" },
|
|
345
|
+
liProps: { role: "option" }
|
|
346
|
+
}, A(o)));
|
|
347
|
+
}, ce = ({ title: e, phrase: t, matches: o, symbol: r = "" }) => {
|
|
348
|
+
const l = () => {
|
|
349
|
+
if (!o || !t)
|
|
350
|
+
return [e];
|
|
351
|
+
const b = e.toLowerCase().indexOf(t.toLowerCase()), k = e.substr(0, b), y = e.slice(b, b + t.length), u = e.substr(b + t.length);
|
|
352
|
+
return [k, y, u];
|
|
353
|
+
}, [c, s, v] = l();
|
|
354
|
+
return /* @__PURE__ */ f.createElement(de, null, r, c, s ? /* @__PURE__ */ f.createElement("strong", null, s) : null, v || null);
|
|
355
|
+
}, Ze = K`
|
|
356
|
+
opacity: 0.5;
|
|
357
|
+
pointer-events: none;
|
|
358
|
+
`, le = K`
|
|
359
|
+
background-color: ${(e) => {
|
|
360
|
+
var t;
|
|
361
|
+
return (t = e.theme.colors) == null ? void 0 : t.text;
|
|
362
|
+
}};
|
|
363
|
+
color: #ffffff;
|
|
364
|
+
outline: none;
|
|
365
|
+
|
|
366
|
+
span:first-child {
|
|
367
|
+
border-color: ${(e) => {
|
|
368
|
+
var t;
|
|
369
|
+
return (t = e.theme.colors) == null ? void 0 : t.text;
|
|
370
|
+
}};
|
|
371
|
+
}
|
|
372
|
+
`, ue = z(fe)`
|
|
373
|
+
display: block;
|
|
374
|
+
text-decoration: none;
|
|
375
|
+
font-size: ${(e) => {
|
|
376
|
+
var t;
|
|
377
|
+
return (t = e.theme.fonts) == null ? void 0 : t.normal;
|
|
378
|
+
}};
|
|
379
|
+
|
|
380
|
+
${(e) => e.disabled && Ze}
|
|
381
|
+
color: ${(e) => {
|
|
382
|
+
var t;
|
|
383
|
+
return (t = e.theme.colors) == null ? void 0 : t.text;
|
|
384
|
+
}};
|
|
385
|
+
background-color: transparent;
|
|
386
|
+
|
|
387
|
+
span {
|
|
388
|
+
display: block;
|
|
389
|
+
${(e) => {
|
|
390
|
+
var t, o, r, l;
|
|
391
|
+
return e["data-level"] ? `padding: calc(${(t = e.theme.sizes) == null ? void 0 : t.normal} / 2) ${(o = e.theme.sizes) == null ? void 0 : o.normal};` : `padding: calc(${(r = e.theme.sizes) == null ? void 0 : r.normal} / 2) ${(l = e.theme.sizes) == null ? void 0 : l.medium}; `;
|
|
392
|
+
}}
|
|
393
|
+
${(e) => e["data-level"] && "border-left: 2px solid"}
|
|
394
|
+
}
|
|
395
|
+
|
|
396
|
+
span:first-child {
|
|
397
|
+
border-color: #e7e7e7;
|
|
398
|
+
}
|
|
399
|
+
|
|
400
|
+
${(e) => {
|
|
401
|
+
var t;
|
|
402
|
+
return e["data-level"] && `padding: 0 calc(${(t = e.theme.sizes) == null ? void 0 : t.medium} * ${e["data-level"]});`;
|
|
403
|
+
}}
|
|
404
|
+
|
|
405
|
+
${(e) => e.autoSelect && le}
|
|
406
|
+
|
|
407
|
+
&:hover,
|
|
408
|
+
&:focus {
|
|
409
|
+
${le}
|
|
410
|
+
}
|
|
411
|
+
`, _e = ({ phrase: e = "", inputHasFocus: t, searchContainerRef: o }) => {
|
|
412
|
+
const {
|
|
413
|
+
quickFilter: r = {
|
|
414
|
+
open: !1,
|
|
415
|
+
loading: !1,
|
|
416
|
+
symbol: "",
|
|
417
|
+
type: "",
|
|
418
|
+
items: []
|
|
419
|
+
}
|
|
420
|
+
} = P(), [l, c] = Le(!0), s = he(), { events: v } = s.get("$widget"), b = V(), k = I((d) => (d && d.addEventListener("keydown", () => {
|
|
421
|
+
Y(d).focusedIndex > -1 && v.subscribeOnce("router:changed", () => {
|
|
422
|
+
Z(o);
|
|
423
|
+
});
|
|
424
|
+
}, !0), b.current = d, d), [o]), { items: y = [], symbol: u, type: $, open: S, loading: x } = r;
|
|
425
|
+
if (!S || !u)
|
|
426
|
+
return null;
|
|
427
|
+
const A = e.slice(e.indexOf(u) + 1);
|
|
428
|
+
return /* @__PURE__ */ f.createElement(Re, {
|
|
429
|
+
ref: k,
|
|
430
|
+
"data-loading": x,
|
|
431
|
+
className: R("humany-quick-filter-dropdown", [$ === "guideCategory", "humany-quick-filter-guide-categories"], [$ === "tag", "humany-quick-filter-tags"])
|
|
432
|
+
}, /* @__PURE__ */ f.createElement(Ve, {
|
|
433
|
+
className: "humany-quick-filter-dropdown-inner",
|
|
434
|
+
css: l,
|
|
435
|
+
ref: c
|
|
436
|
+
}, /* @__PURE__ */ f.createElement(Ye, {
|
|
437
|
+
filterType: $,
|
|
438
|
+
items: y,
|
|
439
|
+
filterPhrase: A,
|
|
440
|
+
filterContainer: c.current,
|
|
441
|
+
searchContainer: o,
|
|
442
|
+
inputHasFocus: t
|
|
443
|
+
})), /* @__PURE__ */ f.createElement(De, {
|
|
444
|
+
loading: x
|
|
445
|
+
}));
|
|
446
|
+
}, Re = z.div`
|
|
447
|
+
${me};
|
|
448
|
+
position: absolute;
|
|
449
|
+
top: calc(100% + ${(e) => {
|
|
450
|
+
var t;
|
|
451
|
+
return (t = e.theme.sizes) == null ? void 0 : t.normal;
|
|
452
|
+
}});
|
|
453
|
+
left: 0;
|
|
454
|
+
right: 0;
|
|
455
|
+
z-index: 1;
|
|
456
|
+
overflow: hidden;
|
|
457
|
+
`, Ve = z.div`
|
|
458
|
+
max-height: 300px;
|
|
459
|
+
overflow: auto;
|
|
460
|
+
padding: ${(e) => {
|
|
461
|
+
var t;
|
|
462
|
+
return (t = e.theme.sizes) == null ? void 0 : t.medium;
|
|
463
|
+
}} 0;
|
|
464
|
+
${(e) => e.css}
|
|
465
|
+
ul {
|
|
466
|
+
list-style: none;
|
|
467
|
+
padding: 0;
|
|
468
|
+
margin: 0;
|
|
469
|
+
}
|
|
470
|
+
li div {
|
|
471
|
+
${(e) => {
|
|
472
|
+
var t;
|
|
473
|
+
return `margin: ${(t = e.theme.sizes) == null ? void 0 : t.normal} 0;`;
|
|
474
|
+
}}
|
|
475
|
+
}
|
|
476
|
+
`, X = (e, t) => !!(e && !t || !e && t || e && t && e.id !== t.id), et = (e, t = {}, o = !0) => {
|
|
477
|
+
const r = M(), {
|
|
478
|
+
quickFilters: l = !1,
|
|
479
|
+
quickFilter: c = { open: !1 },
|
|
480
|
+
activeFilterBadges: s,
|
|
481
|
+
filterBadges: v = !1,
|
|
482
|
+
incremental: b = 600
|
|
483
|
+
} = P(), k = Te(e, typeof b == "boolean" ? 600 : b), y = ae(k), u = ae(s), $ = V(null), S = I((n = "") => {
|
|
484
|
+
if (v) {
|
|
485
|
+
const i = X(s == null ? void 0 : s.guideCategory, u == null ? void 0 : u.guideCategory) || X(s == null ? void 0 : s.tag, u == null ? void 0 : u.tag);
|
|
486
|
+
return r("search", { value: n, filtersChanged: i, filters: s });
|
|
487
|
+
}
|
|
488
|
+
return r("search", { value: n });
|
|
489
|
+
}, [r, s]), x = I((n) => {
|
|
490
|
+
r("clear", { navigateToHome: n });
|
|
491
|
+
}, [r]), A = (n) => l ? n.replace(/([@#].*)/g, "") : n, d = I((n) => {
|
|
492
|
+
if (c.open && n.preventDefault) {
|
|
493
|
+
n.preventDefault();
|
|
494
|
+
return;
|
|
495
|
+
}
|
|
496
|
+
const i = document.activeElement, g = $.current && typeof $.current.contains == "function" ? $.current.contains(i) : !1, m = A(e);
|
|
497
|
+
typeof n == "boolean" && n || m.length && g || (s == null ? void 0 : s.guideCategory) || (s == null ? void 0 : s.tag) && g ? S(m) : x(g);
|
|
498
|
+
}, [$, e, c, x, s, S]);
|
|
499
|
+
return O(() => {
|
|
500
|
+
const n = X(s == null ? void 0 : s.guideCategory, u == null ? void 0 : u.guideCategory) || X(s == null ? void 0 : s.tag, u == null ? void 0 : u.tag), i = k && A(k), g = y && A(y);
|
|
501
|
+
(typeof g != "undefined" && g !== i && i !== t.phrase && o && !c.open || n && !(s != null && s.initial)) && d(n);
|
|
502
|
+
}, [k, c.open, s, d]), O(() => {
|
|
503
|
+
if (e && l) {
|
|
504
|
+
const n = typeof l == "boolean" && !!l || typeof l == "object" && !!l.guideCategory, i = typeof l == "boolean" && !!l || typeof l == "object" && !!l.tag;
|
|
505
|
+
n && e.indexOf("@") === e.length - 1 && r("quick-filter:open", { type: "guideCategory", symbol: "@" }), i && e.indexOf("#") === e.length - 1 && r("quick-filter:open", { type: "tag", symbol: "#" });
|
|
506
|
+
}
|
|
507
|
+
c.open && e.indexOf("@") === -1 && e.indexOf("#") === -1 && r("quick-filter:close");
|
|
508
|
+
}, [e]), [d, x, $];
|
|
509
|
+
}, dt = (o) => {
|
|
510
|
+
var r = o, { className: e } = r, t = U(r, ["className"]);
|
|
511
|
+
const {
|
|
512
|
+
showSearchButton: l,
|
|
513
|
+
showClearButton: c,
|
|
514
|
+
role: s = "search",
|
|
515
|
+
autoFocus: v,
|
|
516
|
+
placeholder: b,
|
|
517
|
+
searchButtonLabel: k,
|
|
518
|
+
clearButtonLabel: y,
|
|
519
|
+
ariaLabel: u,
|
|
520
|
+
route: $ = "search",
|
|
521
|
+
incremental: S = !0,
|
|
522
|
+
showChildren: x = !1,
|
|
523
|
+
quickFilter: A,
|
|
524
|
+
quickFilters: d,
|
|
525
|
+
filterBadges: n
|
|
526
|
+
} = P(), { params: i } = ge(), [g, m] = N(!1), [a, h] = N(i.phrase || ""), [p, q] = N({
|
|
527
|
+
guideCategory: !1,
|
|
528
|
+
tag: !1
|
|
529
|
+
}), w = he(), ke = Ne(), W = M(), { position: xe = "inside" } = typeof n == "object" ? n : {};
|
|
530
|
+
O(() => {
|
|
531
|
+
const { guideCategory: E, tag: C } = i, F = typeof n == "object" ? !!n.guideCategory : !!n, ve = typeof n == "object" ? !!n.tag : !!n;
|
|
532
|
+
q({
|
|
533
|
+
guideCategory: F && !!E,
|
|
534
|
+
tag: ve && !!C
|
|
535
|
+
});
|
|
536
|
+
}, [n, i]), Oe("router:changed", () => {
|
|
537
|
+
if (A) {
|
|
538
|
+
const { open: E, symbol: C } = A;
|
|
539
|
+
if (E) {
|
|
540
|
+
if (C) {
|
|
541
|
+
const F = a.replace(a.slice(a.indexOf(C)), "");
|
|
542
|
+
h(F);
|
|
543
|
+
}
|
|
544
|
+
W("quick-filter:close");
|
|
545
|
+
}
|
|
546
|
+
}
|
|
547
|
+
}, [A, a, h, W]);
|
|
548
|
+
const [ee, j, L] = et(a, i, !!S);
|
|
549
|
+
O(() => {
|
|
550
|
+
h(i.phrase || "");
|
|
551
|
+
}, [i.phrase]);
|
|
552
|
+
const $e = I((E) => {
|
|
553
|
+
h(E);
|
|
554
|
+
}, [h]), Ee = I(() => {
|
|
555
|
+
W("quick-filter:close").then(() => j(!0));
|
|
556
|
+
}, [W, j]), we = I(() => {
|
|
557
|
+
var E, C;
|
|
558
|
+
v && !g && ((C = (E = L.current) == null ? void 0 : E.getElementsByTagName("input")[0]) == null || C.focus());
|
|
559
|
+
}, [v, g, L]), Ce = I(() => {
|
|
560
|
+
w.getAsync("router").then((E) => {
|
|
561
|
+
const C = E.getInitialRoute(), F = E.getRouteData();
|
|
562
|
+
(C == null ? void 0 : C.name) === F.name && (C == null ? void 0 : C.name) !== $ ? h("") : j(!0);
|
|
563
|
+
});
|
|
564
|
+
}, [w, h, j]), te = (E) => {
|
|
565
|
+
if (E !== xe)
|
|
566
|
+
return null;
|
|
567
|
+
if (!!p.guideCategory || !!p.tag)
|
|
568
|
+
return /* @__PURE__ */ f.createElement(Me, {
|
|
569
|
+
position: E,
|
|
570
|
+
inputHasFocus: g,
|
|
571
|
+
showGuideCategory: p.guideCategory,
|
|
572
|
+
showTag: p.tag,
|
|
573
|
+
searchContainerRef: L.current
|
|
574
|
+
});
|
|
575
|
+
};
|
|
576
|
+
Ke(we);
|
|
577
|
+
const oe = c && (p.guideCategory || p.tag || a), Se = d ? Pe({
|
|
578
|
+
role: "combobox",
|
|
579
|
+
"aria-autocomplete": "list",
|
|
580
|
+
autoComplete: "off",
|
|
581
|
+
"aria-haspopup": "listbox"
|
|
582
|
+
}) : {};
|
|
583
|
+
return /* @__PURE__ */ f.createElement(tt, D(B({}, t), {
|
|
584
|
+
ref: L,
|
|
585
|
+
role: s,
|
|
586
|
+
className: R(e, "humany-search"),
|
|
587
|
+
"data-has-phrase": !!a,
|
|
588
|
+
"data-has-focus": g,
|
|
589
|
+
"data-has-search-symbol": l ? "true" : "false"
|
|
590
|
+
}), /* @__PURE__ */ f.createElement(ot, {
|
|
591
|
+
action: ".",
|
|
592
|
+
onSubmit: (E) => {
|
|
593
|
+
var C, F;
|
|
594
|
+
E.preventDefault(), (F = (C = L.current) == null ? void 0 : C.getElementsByTagName("input")[0]) == null || F.blur();
|
|
595
|
+
},
|
|
596
|
+
"data-has-focus": g
|
|
597
|
+
}, l && /* @__PURE__ */ f.createElement(nt, {
|
|
598
|
+
"aria-label": k,
|
|
599
|
+
type: "submit",
|
|
600
|
+
title: k,
|
|
601
|
+
disabled: !a,
|
|
602
|
+
onClick: ee,
|
|
603
|
+
"data-has-phrase": !!a,
|
|
604
|
+
"data-has-focus": g
|
|
605
|
+
}, /* @__PURE__ */ f.createElement(H, {
|
|
606
|
+
size: 32,
|
|
607
|
+
symbol: { type: "Svg", content: "search" }
|
|
608
|
+
})), te("inside"), /* @__PURE__ */ f.createElement(We, D(B({
|
|
609
|
+
type: "search",
|
|
610
|
+
"aria-label": u
|
|
611
|
+
}, Se), {
|
|
612
|
+
placeholder: p.guideCategory || p.tag ? "" : b,
|
|
613
|
+
onFocusChange: m,
|
|
614
|
+
onEscape: Ee,
|
|
615
|
+
onEnter: ee,
|
|
616
|
+
onChange: $e,
|
|
617
|
+
value: a
|
|
618
|
+
})), oe && /* @__PURE__ */ f.createElement(rt, {
|
|
619
|
+
"aria-label": y,
|
|
620
|
+
type: "reset",
|
|
621
|
+
hasFocus: g,
|
|
622
|
+
title: y,
|
|
623
|
+
onClick: Ce
|
|
624
|
+
}, /* @__PURE__ */ f.createElement(H, {
|
|
625
|
+
size: 27,
|
|
626
|
+
symbol: { type: "Svg", content: "clear" }
|
|
627
|
+
})), x && !oe && ke.map((E) => /* @__PURE__ */ f.createElement(ze, {
|
|
628
|
+
key: E.id,
|
|
629
|
+
id: E.id,
|
|
630
|
+
branch: "default"
|
|
631
|
+
})), /* @__PURE__ */ f.createElement(_e, {
|
|
632
|
+
inputHasFocus: g,
|
|
633
|
+
phrase: a,
|
|
634
|
+
searchContainerRef: L.current
|
|
635
|
+
})), te("below"));
|
|
636
|
+
}, tt = z.div`
|
|
637
|
+
${me};
|
|
638
|
+
width: 100%;
|
|
639
|
+
padding: ${(e) => {
|
|
640
|
+
var t;
|
|
641
|
+
return (t = e.theme.sizes) == null ? void 0 : t.large;
|
|
642
|
+
}};
|
|
643
|
+
|
|
644
|
+
input {
|
|
645
|
+
background-color: transparent;
|
|
646
|
+
border: none;
|
|
647
|
+
outline: none;
|
|
648
|
+
min-width: 25%;
|
|
649
|
+
flex: 1;
|
|
650
|
+
font-size: ${(e) => {
|
|
651
|
+
var t;
|
|
652
|
+
return (t = e.theme.fonts) == null ? void 0 : t.normal;
|
|
653
|
+
}};
|
|
654
|
+
font-weight: 300;
|
|
655
|
+
font-style: italic;
|
|
656
|
+
padding: 1em 0;
|
|
657
|
+
color: ${(e) => {
|
|
658
|
+
var t;
|
|
659
|
+
return (t = e.theme.colors) == null ? void 0 : t.text;
|
|
660
|
+
}};
|
|
661
|
+
-webkit-appearance: none;
|
|
662
|
+
|
|
663
|
+
${(e) => {
|
|
664
|
+
var t;
|
|
665
|
+
return e["data-has-search-symbol"] === "true" && `text-indent: ${(t = e.theme.sizes) == null ? void 0 : t.normal};`;
|
|
666
|
+
}}
|
|
667
|
+
|
|
668
|
+
::placeholder {
|
|
669
|
+
color: ${(e) => {
|
|
670
|
+
var t;
|
|
671
|
+
return (t = e.theme.colors) == null ? void 0 : t.text;
|
|
672
|
+
}};
|
|
673
|
+
}
|
|
674
|
+
/* removes the 'X' from IE */
|
|
675
|
+
&[type='search']::-ms-clear {
|
|
676
|
+
display: none;
|
|
677
|
+
width: 0;
|
|
678
|
+
height: 0;
|
|
679
|
+
}
|
|
680
|
+
&[type='search']::-ms-reveal {
|
|
681
|
+
display: none;
|
|
682
|
+
width: 0;
|
|
683
|
+
height: 0;
|
|
684
|
+
}
|
|
685
|
+
|
|
686
|
+
/* removes the 'X' from Chrome */
|
|
687
|
+
&[type='search']::-webkit-search-decoration,
|
|
688
|
+
&[type='search']::-webkit-search-cancel-button,
|
|
689
|
+
&[type='search']::-webkit-search-results-button,
|
|
690
|
+
&[type='search']::-webkit-search-results-decoration {
|
|
691
|
+
display: none;
|
|
692
|
+
}
|
|
693
|
+
|
|
694
|
+
&:focus {
|
|
695
|
+
outline: none;
|
|
696
|
+
}
|
|
697
|
+
}
|
|
698
|
+
|
|
699
|
+
button {
|
|
700
|
+
background: transparent;
|
|
701
|
+
border: none;
|
|
702
|
+
padding: 0;
|
|
703
|
+
font-size: ${(e) => {
|
|
704
|
+
var t;
|
|
705
|
+
return (t = e.theme.fonts) == null ? void 0 : t.large;
|
|
706
|
+
}};
|
|
707
|
+
transition: color 200ms ease-out;
|
|
708
|
+
color: ${(e) => {
|
|
709
|
+
var t;
|
|
710
|
+
return e["data-has-focus"] || e["data-has-phrase"] ? (t = e.theme.colors) == null ? void 0 : t.primary : "#000000";
|
|
711
|
+
}};
|
|
712
|
+
cursor: pointer;
|
|
713
|
+
> svg {
|
|
714
|
+
height: 100%;
|
|
715
|
+
}
|
|
716
|
+
}
|
|
717
|
+
`, ot = z.form`
|
|
718
|
+
display: flex;
|
|
719
|
+
flex-wrap: nowrap;
|
|
720
|
+
align-items: center;
|
|
721
|
+
border: ${(e) => e.theme.inputBorder};
|
|
722
|
+
border-radius: ${(e) => e.theme.borderRadius};
|
|
723
|
+
background-color: #ffffff;
|
|
724
|
+
position: relative;
|
|
725
|
+
padding: 0 ${(e) => {
|
|
726
|
+
var t;
|
|
727
|
+
return (t = e.theme.sizes) == null ? void 0 : t.normal;
|
|
728
|
+
}};
|
|
729
|
+
|
|
730
|
+
${(e) => e["data-has-focus"] && K`
|
|
731
|
+
${(t) => {
|
|
732
|
+
var o, r;
|
|
733
|
+
return (o = t.theme.accessibility) != null && o.isTabbing ? _ : `
|
|
734
|
+
border-color: ${(r = t.theme.colors) == null ? void 0 : r.primary};
|
|
735
|
+
outline: none;
|
|
736
|
+
input {
|
|
737
|
+
outline: none;
|
|
738
|
+
}
|
|
739
|
+
`;
|
|
740
|
+
}}
|
|
741
|
+
`};
|
|
742
|
+
`, nt = z(pe)`
|
|
743
|
+
padding: 0;
|
|
744
|
+
height: 2em;
|
|
745
|
+
|
|
746
|
+
svg {
|
|
747
|
+
circle,
|
|
748
|
+
line {
|
|
749
|
+
stroke: ${(e) => {
|
|
750
|
+
var t;
|
|
751
|
+
return e["data-has-focus"] ? (t = e.theme.colors) == null ? void 0 : t.primary : "#000000";
|
|
752
|
+
}};
|
|
753
|
+
}
|
|
754
|
+
}
|
|
755
|
+
`, rt = z(pe)`
|
|
756
|
+
&:focus svg {
|
|
757
|
+
${(e) => {
|
|
758
|
+
var t;
|
|
759
|
+
return ((t = e.theme.accessibility) == null ? void 0 : t.isTabbing) && _;
|
|
760
|
+
}}
|
|
761
|
+
}
|
|
762
|
+
|
|
763
|
+
svg {
|
|
764
|
+
vertical-align: top;
|
|
765
|
+
|
|
766
|
+
circle,
|
|
767
|
+
line,
|
|
768
|
+
path {
|
|
769
|
+
stroke: ${(e) => {
|
|
770
|
+
var t, o;
|
|
771
|
+
return e.hasFocus ? (t = e.theme.colors) == null ? void 0 : t.primary : (o = e.theme.colors) == null ? void 0 : o.text;
|
|
772
|
+
}};
|
|
773
|
+
}
|
|
774
|
+
}
|
|
775
|
+
`;
|
|
776
|
+
export {
|
|
777
|
+
dt as default
|
|
778
|
+
};
|
|
779
|
+
//# sourceMappingURL=search.ffb2e6c2.js.map
|