@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 u } from "react/jsx-runtime";
2
- import c, { useEffect as V } from "react";
3
- import { getCommonProps as j, px as D, encodeURLSearchParams as N } from "../../utils/index.js";
4
- import f from "../../node_modules/classnames/index.js";
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: i,
17
- searchResults: E = [],
18
- state: l = "idle",
19
- defaultValue: R = "",
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: d = "Search",
22
+ searchButtonText: l = "Search",
23
23
  loadingText: C = "Search In Progress...",
24
- invalidText: k = "Invalid search",
25
- getAllResultsText: L = (r) => `View all results for ${r}`,
26
- getAllResultsLink: S = (r) => `/Search?Search=${r}`,
27
- ...v
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 I;
30
- const { className: r, "data-testid": m, ...P } = j(v, "Search"), o = c.useContext(U), h = c.useRef(null), p = c.useRef(null), x = c.useRef(null), t = o.isSearchExpanded, s = (I = h.current) == null ? void 0 : I.value, T = _ ? (e) => {
31
- _(e.target.value);
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(x, (e) => {
34
- i == null || i(), g(!1), e.stopPropagation();
33
+ M($, (e) => {
34
+ o == null || o(), u(!1), e.stopPropagation();
35
35
  });
36
- const $ = (e) => {
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 = N(S(s));
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(), o.setIsSearchExpanded(!1));
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 g = (e) => {
54
+ const u = (e) => {
55
55
  var n;
56
- (n = p.current) == null || n.reset(), o.setIsSearchExpanded(e);
56
+ (n = p.current) == null || n.reset(), m.setIsSearchExpanded(e);
57
57
  };
58
- return /* @__PURE__ */ a("div", { className: `${r}__container`, children: /* @__PURE__ */ u(
59
- "div",
60
- {
61
- onClick: () => o.setIsSearchExpanded(!0),
62
- className: `${r}__container__inner`,
63
- ref: x,
64
- children: [
65
- /* @__PURE__ */ a(K, { variant: F.heading4, className: `${r}__container__inner__label`, children: d }),
66
- /* @__PURE__ */ a(
67
- "div",
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
- ...P,
70
- className: f(r, b, { [`${r}--active`]: t }),
71
- "data-testid": m,
72
- role: "search",
73
- ...v,
74
- children: /* @__PURE__ */ u(
75
- "form",
76
- {
77
- "data-testid": `${m}-form`,
78
- className: f(`${r}__form`, {
79
- [`${r}__form--active`]: t
80
- }),
81
- ref: p,
82
- children: [
83
- /* @__PURE__ */ u(
84
- "div",
85
- {
86
- className: f(`${r}__content-wrapper`, {
87
- [`${r}__content-wrapper--active`]: t
88
- }),
89
- role: "combobox",
90
- "aria-haspopup": "listbox",
91
- children: [
92
- /* @__PURE__ */ a(
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
- className: r,
123
- searchButtonText: d,
124
- state: l,
125
- testId: m,
126
- isSearchExpanded: t,
127
- setIsSearchExpanded: g,
128
- onCancel: i
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
- s && s.length > 2 ? /* @__PURE__ */ a(
135
- A,
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
- autoCompleteResults: E,
138
- isLoading: l === "loading",
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
- ) : null
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 a } from "../../../utils/index.js";
3
- import u from "../../Link/Link.js";
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: e = [],
7
- isLoading: i,
8
- children: c,
9
- loadingText: t = "Loading...",
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(e) && e.length > 0;
14
- function d(s, n) {
15
- return s.split(new RegExp(`(${n})`, "gi")).map(
16
- (l, _) => l.toLocaleLowerCase() === n.toLocaleLowerCase() ? /* @__PURE__ */ r("strong", { children: l }, _) : l
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: `${a}-search__results`, children: /* @__PURE__ */ p("ul", { "data-testid": "search-results", className: `${a}-search__results-container`, children: [
20
- i ? /* @__PURE__ */ r("li", { className: `${a}-search__result`, children: t }) : null,
21
- m && e.map((s) => /* @__PURE__ */ r("li", { className: `${a}-search__result`, children: /* @__PURE__ */ r(u, { href: s.url, onKeyDown: o, variant: L.snwFlyoutLink, children: /* @__PURE__ */ r("span", { className: "${px}-search__result__label", children: d(s.label, h) }) }) }, s.id)),
22
- c
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 {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@phillips/seldon",
3
- "version": "1.79.0",
3
+ "version": "1.79.1",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "https://github.com/PhillipsAuctionHouse/seldon"