@phillips/seldon 1.79.0 → 1.79.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,7 +1,7 @@
|
|
|
1
|
-
import { jsx as a, jsxs as
|
|
2
|
-
import
|
|
3
|
-
import { getCommonProps as j, px as D, encodeURLSearchParams as
|
|
4
|
-
import
|
|
1
|
+
import { jsx as a, jsxs as f } from "react/jsx-runtime";
|
|
2
|
+
import i, { useEffect as V } from "react";
|
|
3
|
+
import { getCommonProps as j, px as D, encodeURLSearchParams as I } from "../../utils/index.js";
|
|
4
|
+
import _ from "../../node_modules/classnames/index.js";
|
|
5
5
|
import H from "../Input/Input.js";
|
|
6
6
|
import O from "../Link/Link.js";
|
|
7
7
|
import A from "./SearchResults/SearchResults.js";
|
|
@@ -12,37 +12,37 @@ import { HeaderContext as U } from "../../site-furniture/Header/Header.js";
|
|
|
12
12
|
import { SearchButton as q } from "./SearchButton.js";
|
|
13
13
|
import z from "../../node_modules/react-transition-group/esm/CSSTransition.js";
|
|
14
14
|
const ne = ({
|
|
15
|
-
onSearch:
|
|
16
|
-
onCancel:
|
|
17
|
-
searchResults:
|
|
18
|
-
state:
|
|
19
|
-
defaultValue:
|
|
15
|
+
onSearch: S,
|
|
16
|
+
onCancel: o,
|
|
17
|
+
searchResults: R = [],
|
|
18
|
+
state: c = "idle",
|
|
19
|
+
defaultValue: E = "",
|
|
20
20
|
className: b,
|
|
21
21
|
placeholder: w = "",
|
|
22
|
-
searchButtonText:
|
|
22
|
+
searchButtonText: l = "Search",
|
|
23
23
|
loadingText: C = "Search In Progress...",
|
|
24
|
-
invalidText:
|
|
25
|
-
getAllResultsText:
|
|
26
|
-
getAllResultsLink:
|
|
27
|
-
...
|
|
24
|
+
invalidText: L = "Invalid search",
|
|
25
|
+
getAllResultsText: P = (r) => `View all results for ${r}`,
|
|
26
|
+
getAllResultsLink: v = (r) => `/Search?Search=${r}`,
|
|
27
|
+
...x
|
|
28
28
|
}) => {
|
|
29
|
-
var
|
|
30
|
-
const { className: r, "data-testid":
|
|
31
|
-
|
|
29
|
+
var N;
|
|
30
|
+
const { className: r, "data-testid": d, ...T } = j(x, "Search"), m = i.useContext(U), h = i.useRef(null), p = i.useRef(null), $ = i.useRef(null), t = m.isSearchExpanded, s = (N = h.current) == null ? void 0 : N.value, k = S ? (e) => {
|
|
31
|
+
S(e.target.value);
|
|
32
32
|
} : void 0;
|
|
33
|
-
M(
|
|
34
|
-
|
|
33
|
+
M($, (e) => {
|
|
34
|
+
o == null || o(), u(!1), e.stopPropagation();
|
|
35
35
|
});
|
|
36
|
-
const
|
|
36
|
+
const g = (e) => {
|
|
37
37
|
var n;
|
|
38
38
|
if (e.stopPropagation(), e.key === "Enter") {
|
|
39
39
|
if (e.preventDefault(), s && s.length > 2) {
|
|
40
|
-
const y =
|
|
40
|
+
const y = I(v(s));
|
|
41
41
|
window.location.href = y;
|
|
42
42
|
}
|
|
43
43
|
e.currentTarget instanceof HTMLAnchorElement && e.currentTarget.click();
|
|
44
44
|
}
|
|
45
|
-
e.key === "Escape" && ((n = p.current) == null || n.reset(),
|
|
45
|
+
e.key === "Escape" && ((n = p.current) == null || n.reset(), m.setIsSearchExpanded(!1));
|
|
46
46
|
};
|
|
47
47
|
V(() => {
|
|
48
48
|
var e;
|
|
@@ -51,111 +51,104 @@ const ne = ({
|
|
|
51
51
|
return;
|
|
52
52
|
}
|
|
53
53
|
}, [t]);
|
|
54
|
-
const
|
|
54
|
+
const u = (e) => {
|
|
55
55
|
var n;
|
|
56
|
-
(n = p.current) == null || n.reset(),
|
|
56
|
+
(n = p.current) == null || n.reset(), m.setIsSearchExpanded(e);
|
|
57
57
|
};
|
|
58
|
-
return /* @__PURE__ */ a("div", { className: `${r}__container`, children: /* @__PURE__ */
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
58
|
+
return /* @__PURE__ */ a("div", { className: `${r}__container`, children: /* @__PURE__ */ f("div", { className: `${r}__container__inner`, ref: $, children: [
|
|
59
|
+
/* @__PURE__ */ a(K, { variant: F.heading4, className: `${r}__container__inner__label`, children: l }),
|
|
60
|
+
/* @__PURE__ */ a(
|
|
61
|
+
"div",
|
|
62
|
+
{
|
|
63
|
+
...T,
|
|
64
|
+
className: _(r, b, { [`${r}--active`]: t }),
|
|
65
|
+
"data-testid": d,
|
|
66
|
+
role: "search",
|
|
67
|
+
...x,
|
|
68
|
+
children: /* @__PURE__ */ f(
|
|
69
|
+
"form",
|
|
68
70
|
{
|
|
69
|
-
|
|
70
|
-
className:
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
children:
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
z,
|
|
94
|
-
{
|
|
95
|
-
in: t,
|
|
96
|
-
classNames: `${D}-input`,
|
|
97
|
-
addEndListener: () => {
|
|
98
|
-
},
|
|
99
|
-
children: /* @__PURE__ */ a(
|
|
100
|
-
H,
|
|
101
|
-
{
|
|
102
|
-
"aria-hidden": !t,
|
|
103
|
-
className: `${r}__input`,
|
|
104
|
-
id: "search-input",
|
|
105
|
-
hideLabel: !0,
|
|
106
|
-
labelText: d,
|
|
107
|
-
placeholder: t ? w : "",
|
|
108
|
-
type: "text",
|
|
109
|
-
defaultValue: R,
|
|
110
|
-
invalid: l === "invalid",
|
|
111
|
-
invalidText: k,
|
|
112
|
-
onKeyDown: $,
|
|
113
|
-
onChange: T,
|
|
114
|
-
ref: h
|
|
115
|
-
}
|
|
116
|
-
)
|
|
117
|
-
}
|
|
118
|
-
),
|
|
119
|
-
/* @__PURE__ */ a(
|
|
120
|
-
q,
|
|
71
|
+
"data-testid": `${d}-form`,
|
|
72
|
+
className: _(`${r}__form`, {
|
|
73
|
+
[`${r}__form--active`]: t
|
|
74
|
+
}),
|
|
75
|
+
ref: p,
|
|
76
|
+
children: [
|
|
77
|
+
/* @__PURE__ */ f(
|
|
78
|
+
"div",
|
|
79
|
+
{
|
|
80
|
+
className: _(`${r}__content-wrapper`, {
|
|
81
|
+
[`${r}__content-wrapper--active`]: t
|
|
82
|
+
}),
|
|
83
|
+
role: "combobox",
|
|
84
|
+
"aria-haspopup": "listbox",
|
|
85
|
+
children: [
|
|
86
|
+
/* @__PURE__ */ a(
|
|
87
|
+
z,
|
|
88
|
+
{
|
|
89
|
+
in: t,
|
|
90
|
+
classNames: `${D}-input`,
|
|
91
|
+
addEndListener: () => {
|
|
92
|
+
},
|
|
93
|
+
children: /* @__PURE__ */ a(
|
|
94
|
+
H,
|
|
121
95
|
{
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
96
|
+
"aria-hidden": !t,
|
|
97
|
+
className: `${r}__input`,
|
|
98
|
+
id: "search-input",
|
|
99
|
+
hideLabel: !0,
|
|
100
|
+
labelText: l,
|
|
101
|
+
placeholder: t ? w : "",
|
|
102
|
+
type: "text",
|
|
103
|
+
defaultValue: E,
|
|
104
|
+
invalid: c === "invalid",
|
|
105
|
+
invalidText: L,
|
|
106
|
+
onKeyDown: g,
|
|
107
|
+
onChange: k,
|
|
108
|
+
ref: h
|
|
129
109
|
}
|
|
130
110
|
)
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
111
|
+
}
|
|
112
|
+
),
|
|
113
|
+
/* @__PURE__ */ a(
|
|
114
|
+
q,
|
|
115
|
+
{
|
|
116
|
+
className: r,
|
|
117
|
+
searchButtonText: l,
|
|
118
|
+
state: c,
|
|
119
|
+
testId: d,
|
|
120
|
+
isSearchExpanded: t,
|
|
121
|
+
setIsSearchExpanded: u,
|
|
122
|
+
onCancel: o
|
|
123
|
+
}
|
|
124
|
+
)
|
|
125
|
+
]
|
|
126
|
+
}
|
|
127
|
+
),
|
|
128
|
+
s && s.length > 2 ? /* @__PURE__ */ a(
|
|
129
|
+
A,
|
|
130
|
+
{
|
|
131
|
+
autoCompleteResults: R,
|
|
132
|
+
isLoading: c === "loading",
|
|
133
|
+
loadingText: C,
|
|
134
|
+
onKeyDown: g,
|
|
135
|
+
userInputValue: s,
|
|
136
|
+
closeSearch: u,
|
|
137
|
+
children: /* @__PURE__ */ a("li", { className: `${r}__result`, children: /* @__PURE__ */ a(
|
|
138
|
+
O,
|
|
136
139
|
{
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
loadingText: C,
|
|
140
|
-
onKeyDown: $,
|
|
141
|
-
userInputValue: s,
|
|
142
|
-
children: /* @__PURE__ */ a("li", { className: `${r}__result`, children: /* @__PURE__ */ a(
|
|
143
|
-
O,
|
|
144
|
-
{
|
|
145
|
-
href: ((e) => N(S(e)))(s),
|
|
146
|
-
children: /* @__PURE__ */ a("p", { children: L(s) })
|
|
147
|
-
}
|
|
148
|
-
) }, "viewAllSearchResults")
|
|
140
|
+
href: ((e) => I(v(e)))(s),
|
|
141
|
+
children: /* @__PURE__ */ a("p", { children: P(s) })
|
|
149
142
|
}
|
|
150
|
-
)
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
143
|
+
) }, "viewAllSearchResults")
|
|
144
|
+
}
|
|
145
|
+
) : null
|
|
146
|
+
]
|
|
154
147
|
}
|
|
155
148
|
)
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
) });
|
|
149
|
+
}
|
|
150
|
+
)
|
|
151
|
+
] }) });
|
|
159
152
|
};
|
|
160
153
|
export {
|
|
161
154
|
ne as default
|
|
@@ -11,6 +11,7 @@ export interface SearchResultsProps extends React.HTMLAttributes<HTMLElement> {
|
|
|
11
11
|
loadingText?: string;
|
|
12
12
|
onKeyDown?: (event: React.KeyboardEvent<HTMLAnchorElement>) => void;
|
|
13
13
|
userInputValue?: string;
|
|
14
|
+
closeSearch: (value: boolean) => void;
|
|
14
15
|
}
|
|
15
|
-
declare const SearchResults: ({ autoCompleteResults, isLoading, children, loadingText, onKeyDown, userInputValue, }: React.PropsWithChildren<SearchResultsProps>) => import("react/jsx-runtime").JSX.Element;
|
|
16
|
+
declare const SearchResults: ({ autoCompleteResults, isLoading, children, loadingText, onKeyDown, userInputValue, closeSearch, }: React.PropsWithChildren<SearchResultsProps>) => import("react/jsx-runtime").JSX.Element;
|
|
16
17
|
export default SearchResults;
|
|
@@ -1,25 +1,35 @@
|
|
|
1
1
|
import { jsx as r, jsxs as p } from "react/jsx-runtime";
|
|
2
|
-
import { px as
|
|
3
|
-
import
|
|
2
|
+
import { px as e } from "../../../utils/index.js";
|
|
3
|
+
import f from "../../Link/Link.js";
|
|
4
4
|
import { LinkVariants as L } from "../../Link/types.js";
|
|
5
5
|
const w = ({
|
|
6
|
-
autoCompleteResults:
|
|
7
|
-
isLoading:
|
|
8
|
-
children:
|
|
9
|
-
loadingText:
|
|
6
|
+
autoCompleteResults: l = [],
|
|
7
|
+
isLoading: t,
|
|
8
|
+
children: i,
|
|
9
|
+
loadingText: c = "Loading...",
|
|
10
10
|
onKeyDown: o,
|
|
11
|
-
userInputValue: h = ""
|
|
11
|
+
userInputValue: h = "",
|
|
12
|
+
closeSearch: d
|
|
12
13
|
}) => {
|
|
13
|
-
const m = Array.isArray(
|
|
14
|
-
function
|
|
15
|
-
return s.split(new RegExp(`(${
|
|
16
|
-
(
|
|
14
|
+
const m = Array.isArray(l) && l.length > 0;
|
|
15
|
+
function _(s, a) {
|
|
16
|
+
return s.split(new RegExp(`(${a})`, "gi")).map(
|
|
17
|
+
(n, u) => n.toLocaleLowerCase() === a.toLocaleLowerCase() ? /* @__PURE__ */ r("strong", { children: n }, u) : n
|
|
17
18
|
);
|
|
18
19
|
}
|
|
19
|
-
return /* @__PURE__ */ r("div", { className: `${
|
|
20
|
-
|
|
21
|
-
m &&
|
|
22
|
-
|
|
20
|
+
return /* @__PURE__ */ r("div", { className: `${e}-search__results`, children: /* @__PURE__ */ p("ul", { "data-testid": "search-results", className: `${e}-search__results-container`, children: [
|
|
21
|
+
t ? /* @__PURE__ */ r("li", { className: `${e}-search__result`, children: c }) : null,
|
|
22
|
+
m && l.map((s, a) => /* @__PURE__ */ r("li", { className: `${e}-search__result`, children: /* @__PURE__ */ r(
|
|
23
|
+
f,
|
|
24
|
+
{
|
|
25
|
+
href: s.url,
|
|
26
|
+
onKeyDown: o,
|
|
27
|
+
onClick: () => d(!1),
|
|
28
|
+
variant: L.snwFlyoutLink,
|
|
29
|
+
children: /* @__PURE__ */ r("span", { "data-testid": `search-result-${a}`, className: "${px}-search__result__label", children: _(s.label, h) })
|
|
30
|
+
}
|
|
31
|
+
) }, s.id)),
|
|
32
|
+
i
|
|
23
33
|
] }) });
|
|
24
34
|
};
|
|
25
35
|
export {
|