ublo-lib 1.47.92 → 1.47.94

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.
@@ -31,7 +31,18 @@ const SearchBar = ({ lang, resultFormatter, backdrop, OverrideIcons = {}, messag
31
31
  LoadIcon: LoaderIcon,
32
32
  };
33
33
  const Icons = Object.assign({}, DefaultIcons, OverrideIcons);
34
- const close = () => {
34
+ const close = (skipEvent = false) => {
35
+ if (!skipEvent) {
36
+ if (text?.length > 2) {
37
+ sendEvent("basic", "fail", {
38
+ query: text,
39
+ match_count: search?.result?.length,
40
+ });
41
+ }
42
+ else {
43
+ sendEvent("basic", "cancel");
44
+ }
45
+ }
35
46
  setText("");
36
47
  if (document.activeElement) {
37
48
  document.activeElement.blur();
@@ -85,23 +96,13 @@ const SearchBar = ({ lang, resultFormatter, backdrop, OverrideIcons = {}, messag
85
96
  const handleBlur = () => {
86
97
  if (text?.length > 2) {
87
98
  const event = search?.result?.length === 0 ? "Search failed" : "Search canceled";
88
- sendEvent("basic", "fail", {
89
- query: text,
90
- match_count: search?.result?.length,
91
- });
92
99
  Plausible.sendGoal(event, {
93
100
  Terms: text,
94
101
  });
95
102
  }
96
- else {
97
- sendEvent("basic", "cancel");
98
- }
99
103
  };
100
- const focusInput = (focus = true) => {
101
- sendEvent("basic", "load");
102
- if (focus) {
103
- input.current.focus();
104
- }
104
+ const focusInput = () => {
105
+ input.current.focus();
105
106
  };
106
107
  const handleKeyPresses = React.useCallback((e) => {
107
108
  const allowedKeys = ["k"];
@@ -139,7 +140,7 @@ const SearchBar = ({ lang, resultFormatter, backdrop, OverrideIcons = {}, messag
139
140
  "search-bar--opened": results.length > 0,
140
141
  "search-bar--loading": search?.loading,
141
142
  });
142
- return (_jsxs("div", { className: classes, children: [backdrop && _jsx("div", { className: "search-bar__backdrop", onClick: close }), _jsxs("div", { className: "search-bar__input-container", children: [_jsx("input", { ref: input, type: "text", value: text, onChange: updateSearch, onFocus: focusInput, onKeyDown: handleKeyDown, className: "search-bar__input", placeholder: message(ubloLang, "what-are-you-looking-for", messages), onBlur: handleBlur }), _jsx(Icon, { className: "search-bar__icon" }), _jsxs("div", { ref: resultsContainer, className: "search-bar__results", children: [results?.map((result, i) => {
143
+ return (_jsxs("div", { className: classes, onFocus: () => sendEvent("basic", "load"), children: [backdrop && _jsx("div", { className: "search-bar__backdrop", onClick: close }), _jsxs("div", { className: "search-bar__input-container", children: [_jsx("input", { ref: input, type: "text", value: text, onChange: updateSearch, onKeyDown: handleKeyDown, className: "search-bar__input", placeholder: message(ubloLang, "what-are-you-looking-for", messages), onBlur: handleBlur }), _jsx(Icon, { className: "search-bar__icon" }), _jsxs("div", { ref: resultsContainer, className: "search-bar__results", children: [results?.map((result, i) => {
143
144
  const { name, title, page, path } = result;
144
145
  const externalLink = page === undefined;
145
146
  const Tag = externalLink ? "a" : Link;
@@ -167,7 +168,7 @@ const SearchBar = ({ lang, resultFormatter, backdrop, OverrideIcons = {}, messag
167
168
  });
168
169
  };
169
170
  const onClick = () => {
170
- close();
171
+ close(false);
171
172
  sendPlausibleGoal();
172
173
  };
173
174
  const props = externalLink ? anchorProps : linkProps;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ublo-lib",
3
- "version": "1.47.92",
3
+ "version": "1.47.94",
4
4
  "peerDependencies": {
5
5
  "classnames": "^2.5.1",
6
6
  "dt-design-system": "^3.12.0",