ublo-lib 1.47.98 → 1.47.100

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 +1 @@
1
- {"version":3,"file":"use-debounced-search.d.ts","sourceRoot":"","sources":["../../../../../src/common/components/search-bar/hooks/use-debounced-search.js"],"names":[],"mappings":"AAOA;;;;EAWC;uBAlBsB,OAAO"}
1
+ {"version":3,"file":"use-debounced-search.d.ts","sourceRoot":"","sources":["../../../../../src/common/components/search-bar/hooks/use-debounced-search.js"],"names":[],"mappings":"AAOA;;;;EAaC;uBApBsB,OAAO"}
@@ -6,6 +6,8 @@ const DEBOUNCE_AMOUNT = 600;
6
6
  export default function useDebouncedSearch(searchFunction) {
7
7
  const [text, setText] = React.useState("");
8
8
  const debouncedSearchFunction = useConstant(() => debouncePromise(searchFunction, DEBOUNCE_AMOUNT));
9
- const search = useAsync(async () => (text.length === 0 ? undefined : debouncedSearchFunction(text)), [debouncedSearchFunction, text], { setLoading: (state) => ({ ...state, loading: true }) });
9
+ const search = useAsync(async () => {
10
+ return text.length === 0 ? undefined : debouncedSearchFunction(text);
11
+ }, [debouncedSearchFunction, text], { setLoading: (state) => ({ ...state, loading: true }) });
10
12
  return { text, setText, search };
11
13
  }
@@ -1 +1 @@
1
- {"version":3,"file":"use-search.d.ts","sourceRoot":"","sources":["../../../../../src/common/components/search-bar/hooks/use-search.js"],"names":[],"mappings":"AAGA;;;;;;;;;;EAYC"}
1
+ {"version":3,"file":"use-search.d.ts","sourceRoot":"","sources":["../../../../../src/common/components/search-bar/hooks/use-search.js"],"names":[],"mappings":"AAIA;;;;;;;;;;EAYC"}
@@ -1,11 +1,12 @@
1
1
  import useDebouncedSearch from "./use-debounced-search";
2
2
  import { fetchResults } from "../utils/fetcher";
3
+ import { sendEvent } from "../../../../future/components/event-analytics/instant-search";
3
4
  export default function useSearch({ ubloApi, site, lang, seo, exclude }) {
4
5
  return useDebouncedSearch(async (query) => {
5
6
  return fetchResults(ubloApi, site, lang, query, seo, exclude).then((res) => {
6
7
  sendEvent("basic", "search", {
7
8
  query: query,
8
- match_count: res?.result?.length,
9
+ match_count: res?.length,
9
10
  });
10
11
  return res;
11
12
  });
@@ -49,6 +49,9 @@ const SearchBar = ({ lang, resultFormatter, backdrop, OverrideIcons = {}, messag
49
49
  }
50
50
  };
51
51
  const updateSearch = (e) => {
52
+ if (text?.length === 0 && e.currentTarget.value.length === 1) {
53
+ sendEvent("basic", "load");
54
+ }
52
55
  const userInput = e.currentTarget.value;
53
56
  setText(userInput);
54
57
  setState({ active: 0 });
@@ -140,7 +143,7 @@ const SearchBar = ({ lang, resultFormatter, backdrop, OverrideIcons = {}, messag
140
143
  "search-bar--opened": results.length > 0,
141
144
  "search-bar--loading": search?.loading,
142
145
  });
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) => {
146
+ 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, 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) => {
144
147
  const { name, title, page, path } = result;
145
148
  const externalLink = page === undefined;
146
149
  const Tag = externalLink ? "a" : Link;
@@ -9,7 +9,7 @@ export default function useSearch(lang, options = {}) {
9
9
  return API.fetchResults(site, lang, query, options.queryBy, options.queryByWeights).then((res) => {
10
10
  sendEvent("esf", "search", {
11
11
  query: query,
12
- match_count: res?.result?.hits?.length,
12
+ match_count: res?.hits?.length,
13
13
  });
14
14
  return res;
15
15
  });
@@ -9,7 +9,7 @@ export default function useSearch(lang, options = {}) {
9
9
  return API.fetchResults(site, lang, query, facet, options.queryBy, options.queryByWeights).then((res) => {
10
10
  sendEvent("lbm", "search", {
11
11
  query: query,
12
- match_count: res?.result?.hits?.length,
12
+ match_count: res?.hits?.length,
13
13
  });
14
14
  return res;
15
15
  });
@@ -9,7 +9,7 @@ export default function useSearch(lang, options = {}) {
9
9
  return API.fetchResults(site, lang, query, options.queryBy, options.queryByWeights).then((res) => {
10
10
  sendEvent("market-place", "search", {
11
11
  query: query,
12
- match_count: res?.result?.hits?.length,
12
+ match_count: res?.hits?.length,
13
13
  });
14
14
  return res;
15
15
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ublo-lib",
3
- "version": "1.47.98",
3
+ "version": "1.47.100",
4
4
  "peerDependencies": {
5
5
  "classnames": "^2.5.1",
6
6
  "dt-design-system": "^3.12.0",