@kiva/kv-components 6.46.0 → 6.47.1

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.
@@ -1,112 +0,0 @@
1
- import { ref as s, computed as f, watch as b } from "vue";
2
- import { gql as q } from "@apollo/client/core";
3
- import { useEventListener as g } from "./event.js";
4
- import x from "./markMatches.js";
5
- import { hasExcludedQueryParams as I } from "./loanSearch/queryParamUtils.js";
6
- import G from "./searchEngine.js";
7
- import { groupBy as U } from "./arrayUtils.js";
8
- const d = {}, S = [
9
- "Gender",
10
- "Regions",
11
- "Countries and Territories",
12
- "United States",
13
- "U.S. cities",
14
- "Sectors",
15
- "Group or Individual",
16
- "Attributes",
17
- "User tags",
18
- "Partners",
19
- "Gifts"
20
- ];
21
- function O() {
22
- const i = s(null), o = s(""), v = s(""), t = s(-1), c = s([]), m = new G(), l = f(() => {
23
- const e = U(c.value, "group");
24
- return Object.keys(e).map((r) => {
25
- const a = e[r].slice(0, 5).map((n) => ({
26
- ...n,
27
- html: x(n.label, n.matches)
28
- }));
29
- return { name: r, suggestions: a };
30
- }).sort((r, a) => {
31
- const n = S.indexOf(r.name), u = S.indexOf(a.name);
32
- return n === -1 && u === -1 ? r.name.localeCompare(a.name) : n === -1 ? 1 : u === -1 ? -1 : n - u;
33
- });
34
- }), p = f(() => l.value.reduce((e, r) => e + r.suggestions.length, 0)), w = (e) => {
35
- e.query({
36
- query: q`
37
- query LoanSearchSuggestions {
38
- lend {
39
- loanSearchSuggestions {
40
- group
41
- label
42
- query
43
- }
44
- }
45
- }
46
- `
47
- }).then(({ data: r }) => {
48
- r && r.lend && m.reset([
49
- ...r.lend.loanSearchSuggestions,
50
- {
51
- group: "Gifts",
52
- label: "Kiva Cards",
53
- keywords: ["gift card", "kiva card", "gift", "gift certificate"],
54
- url: "https://www.kiva.org/gifts/kiva-cards"
55
- },
56
- {
57
- group: "Gifts",
58
- label: "Kiva Store",
59
- keywords: ["gift card", "kiva card", "gift", "gift certificate"],
60
- url: "https://store.kiva.org"
61
- }
62
- ]);
63
- });
64
- }, h = f(() => {
65
- if (t.value === -1)
66
- return {};
67
- let e = t.value, r = 0;
68
- for (; e >= l.value[r].suggestions.length; )
69
- e -= l.value[r].suggestions.length, r += 1;
70
- return l.value[r].suggestions[e];
71
- });
72
- return b(h, (e) => {
73
- v.value = (e == null ? void 0 : e.label) ?? o.value;
74
- }), g(i, "input", (e) => {
75
- e.target.value !== o.value && (o.value = e.target.value, t.value = -1, o.value.length > 0 ? m.search(o.value).then((r) => {
76
- c.value = r;
77
- }) : c.value = []);
78
- }), g(i, "keydown", (e) => {
79
- e.key === "ArrowUp" ? (e.preventDefault(), t.value === -1 && (t.value = p.value), t.value -= 1) : e.key === "ArrowDown" && (e.preventDefault(), t.value += 1, t.value === p.value && (t.value = -1));
80
- }), g(i, "blur", () => {
81
- t.value = -1;
82
- }), {
83
- searchInput: i,
84
- displayTerm: v,
85
- suggestionSections: l,
86
- highlightedSuggestion: h,
87
- getSuggestions: w,
88
- runSearch: (e) => {
89
- const r = typeof e == "object";
90
- if (r && e.url)
91
- window.location.href = e.url;
92
- else {
93
- let a;
94
- if (r && e.query) {
95
- const [y, k] = e.query.split("=");
96
- a = { [y]: k };
97
- } else
98
- a = { queryString: e };
99
- let n = "/lend/filter";
100
- I(a) && (n = "/lend");
101
- const u = new URLSearchParams(a).toString();
102
- window.location.href = `${window.location.origin}${n}?${u}`;
103
- }
104
- }
105
- };
106
- }
107
- function K(i = "default") {
108
- return d[i] || (d[i] = O()), d[i];
109
- }
110
- export {
111
- K as useSiteSearch
112
- };
@@ -1,72 +0,0 @@
1
- import { ref as f, resolveComponent as u, resolveDirective as h, openBlock as c, createElementBlock as w, withDirectives as d, createElementVNode as p, withKeys as v, vModelText as y, createVNode as x, normalizeClass as _, createTextVNode as S } from "vue";
2
- import { useSiteSearch as g } from "../../utils/siteSearch.js";
3
- import { mdiMagnify as k } from "@mdi/js";
4
- import b from "../KvMaterialIcon.js";
5
- import T from "../../_virtual/_plugin-vue_export-helper.js";
6
- const V = {
7
- components: {
8
- KvMaterialIcon: b
9
- },
10
- emits: [
11
- "close-search"
12
- ],
13
- setup(m, { emit: t }) {
14
- const {
15
- searchInput: n,
16
- displayTerm: e,
17
- runSearch: i,
18
- getSuggestions: a
19
- } = g(), o = f(!1);
20
- return {
21
- mdiMagnify: k,
22
- closeSearch: () => {
23
- o.value = !1, t("close-search");
24
- },
25
- displayTerm: e,
26
- onOpen: () => {
27
- var s;
28
- o.value = !0, (s = n.value) == null || s.focus();
29
- },
30
- searchInput: n,
31
- searchExitVisible: o,
32
- runSearch: i,
33
- getSuggestions: a
34
- };
35
- }
36
- }, E = { class: "tw-inline-flex tw-pl-1.5 md:tw-pl-0 tw-w-full" }, C = { class: "tw-flex-none tw-order-first tw-inline-flex tw-items-center tw-my-1.5 tw-p-0.5 tw-rounded-l tw-bg-tertiary peer-placeholder-shown:tw-bg-secondary tw-transition-colors tw-duration-100" };
37
- function K(m, t, n, e, i, a) {
38
- const o = u("kv-material-icon"), l = h("kv-track-event");
39
- return c(), w("div", E, [
40
- d(p("input", {
41
- ref: "searchInput",
42
- "onUpdate:modelValue": t[0] || (t[0] = (r) => e.displayTerm = r),
43
- type: "text",
44
- placeholder: "Search",
45
- class: "tw-peer tw-flex-1 tw-min-w-0 tw-my-1.5 tw-px-1 tw-rounded-r tw-bg-tertiary placeholder-shown:tw-bg-secondary focus:tw-outline-none placeholder:tw-text-gray-300 placeholder:tw-font-medium tw-transition-colors tw-duration-100",
46
- onKeydown: t[1] || (t[1] = v((r) => e.runSearch(e.displayTerm), ["enter"]))
47
- }, null, 544), [
48
- [y, e.displayTerm]
49
- ]),
50
- p("div", C, [
51
- x(o, {
52
- class: "tw-w-3 tw-h-3",
53
- icon: e.mdiMagnify
54
- }, null, 8, ["icon"])
55
- ]),
56
- d((c(), w("button", {
57
- class: _(["tw-px-2.5 tw-transition-opacity", {
58
- "tw-opacity-full tw-duration-300": e.searchExitVisible,
59
- "tw-opacity-0 tw-duration-100": !e.searchExitVisible
60
- }]),
61
- onClick: t[2] || (t[2] = (...r) => e.closeSearch && e.closeSearch(...r))
62
- }, t[3] || (t[3] = [
63
- S(" Cancel ")
64
- ]), 2)), [
65
- [l, ["TopNav", "click-cancel-search"]]
66
- ])
67
- ]);
68
- }
69
- const O = /* @__PURE__ */ T(V, [["render", K]]);
70
- export {
71
- O as default
72
- };
@@ -1 +0,0 @@
1
- .search-results[data-v-f3f87a06]{top:3.75rem}
@@ -1,57 +0,0 @@
1
- import { useSiteSearch as h } from "../../utils/siteSearch.js";
2
- import { withDirectives as u, openBlock as t, createElementBlock as e, createElementVNode as i, Fragment as d, renderList as c, toDisplayString as w, normalizeClass as m, withModifiers as p, vShow as _ } from "vue";
3
- import "./KvHeaderSearchSuggestions.css";
4
- import g from "../../_virtual/_plugin-vue_export-helper.js";
5
- const f = {
6
- setup() {
7
- const {
8
- suggestionSections: a,
9
- highlightedSuggestion: r,
10
- runSearch: l
11
- } = h();
12
- return {
13
- suggestionSections: a,
14
- highlightedSuggestion: r,
15
- runSearch: l
16
- };
17
- }
18
- }, S = { class: "search-results tw-absolute tw-bg-primary tw-border tw-border-tertiary tw-p-2.5 tw-w-full tw-z-popover" }, v = {
19
- style: {
20
- "max-width": "600px"
21
- },
22
- class: "tw-mx-auto"
23
- }, y = ["data-testid"], b = { class: "tw-text-base tw-py-0.5" }, x = ["onClick"], k = ["innerHTML"];
24
- function M(a, r, l, o, C, H) {
25
- return u((t(), e("div", S, [
26
- i("ol", v, [
27
- (t(!0), e(d, null, c(o.suggestionSections, (s) => (t(), e("li", {
28
- key: s.name,
29
- "data-testid": `header-search-results-${s.name}`
30
- }, [
31
- i("h2", b, w(s.name), 1),
32
- i("ol", null, [
33
- (t(!0), e(d, null, c(s.suggestions, (n) => (t(), e("li", {
34
- key: n.label,
35
- "data-testid": "header-search-result-item",
36
- class: m(["tw-pl-1.5 tw-py-0.5 tw-rounded-sm tw-font-medium tw-cursor-pointer hover:tw-bg-tertiary hover:tw-underline", {
37
- "tw-bg-tertiary tw-underline": o.highlightedSuggestion === n
38
- }]),
39
- onMousedown: r[0] || (r[0] = p(() => {
40
- }, ["prevent"])),
41
- onClick: (L) => o.runSearch(n)
42
- }, [
43
- i("span", {
44
- innerHTML: n.html
45
- }, null, 8, k)
46
- ], 42, x))), 128))
47
- ])
48
- ], 8, y))), 128))
49
- ])
50
- ], 512)), [
51
- [_, o.suggestionSections.length]
52
- ]);
53
- }
54
- const T = /* @__PURE__ */ g(f, [["render", M], ["__scopeId", "data-v-f3f87a06"]]);
55
- export {
56
- T as default
57
- };