ublo-lib 1.11.3 → 1.11.4

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,5 +1,5 @@
1
1
  import * as React from "react";
2
- const useConstant = fn => {
2
+ export default function useConstant(fn) {
3
3
  const ref = React.useRef();
4
4
  if (!ref.current) {
5
5
  ref.current = {
@@ -7,5 +7,4 @@ const useConstant = fn => {
7
7
  };
8
8
  }
9
9
  return ref.current.v;
10
- };
11
- export default useConstant;
10
+ }
@@ -1,10 +1,11 @@
1
- import { useState } from "react";
1
+ import * as React from "react";
2
2
  import debouncePromise from "awesome-debounce-promise";
3
- import useConstant from "./use-constant";
4
3
  import { useAsync } from "react-async-hook";
5
- export const useDebouncedSearch = searchFunction => {
6
- const [text, setText] = useState("");
7
- const debouncedSearchFunction = useConstant(() => debouncePromise(searchFunction, 200));
4
+ import useConstant from "./use-constant";
5
+ const DEBOUNCE_AMOUNT = 600;
6
+ export default function useDebouncedSearch(searchFunction) {
7
+ const [text, setText] = React.useState("");
8
+ const debouncedSearchFunction = useConstant(() => debouncePromise(searchFunction, DEBOUNCE_AMOUNT));
8
9
  const search = useAsync(async () => text.length === 0 ? undefined : debouncedSearchFunction(text), [debouncedSearchFunction, text], {
9
10
  setLoading: state => ({
10
11
  ...state,
@@ -16,4 +17,4 @@ export const useDebouncedSearch = searchFunction => {
16
17
  setText,
17
18
  search
18
19
  };
19
- };
20
+ }
@@ -1,3 +1,13 @@
1
- import { useDebouncedSearch } from "./use-debounced-search";
1
+ import useDebouncedSearch from "./use-debounced-search";
2
2
  import { fetchResults } from "../utils/fetcher";
3
- export const useSearch = (ubloApi, site, lang, seo, exclude) => useDebouncedSearch(query => fetchResults(ubloApi, site, lang, query, seo, exclude));
3
+ export default function useSearch({
4
+ ubloApi,
5
+ site,
6
+ lang,
7
+ seo,
8
+ exclude
9
+ }) {
10
+ return useDebouncedSearch(async query => {
11
+ return fetchResults(ubloApi, site, lang, query, seo, exclude);
12
+ });
13
+ }
@@ -4,9 +4,9 @@ import Router from "next/router";
4
4
  import getConfig from "next/config";
5
5
  import Link from "ublo/link";
6
6
  import { useUbloContext } from "ublo/with-ublo";
7
- import { SearchIcon, LoadIcon } from "./icons";
7
+ import * as DSIcons from "dt-design-system/es/icons";
8
8
  import * as Plausible from "../plausible";
9
- import { useSearch } from "./hooks/use-search";
9
+ import useSearch from "./hooks/use-search";
10
10
  import * as KeyboardKeys from "./utils/keyboard-keys";
11
11
  import { message } from "./messages";
12
12
  import { jsx as _jsx } from "react/jsx-runtime";
@@ -14,6 +14,10 @@ import { jsxs as _jsxs } from "react/jsx-runtime";
14
14
  const {
15
15
  publicRuntimeConfig
16
16
  } = getConfig();
17
+ const {
18
+ ubloApi,
19
+ site
20
+ } = publicRuntimeConfig;
17
21
  const SearchBar = ({
18
22
  lang,
19
23
  resultFormatter,
@@ -33,21 +37,25 @@ const SearchBar = ({
33
37
  const {
34
38
  lang: ubloLang = lang
35
39
  } = useUbloContext();
36
- const {
37
- ubloApi,
38
- site
39
- } = publicRuntimeConfig;
40
40
  const {
41
41
  text,
42
42
  setText,
43
43
  search
44
- } = useSearch(ubloApi, site, ubloLang, seo, exclude);
44
+ } = useSearch({
45
+ ubloApi,
46
+ site,
47
+ lang: ubloLang,
48
+ seo,
49
+ exclude
50
+ });
45
51
  const DefaultIcons = {
46
- SearchIcon,
47
- LoadIcon
52
+ SearchIcon: DSIcons.Search,
53
+ LoadIcon: DSIcons.Loader2
54
+ };
55
+ const Icons = Object.assign({}, DefaultIcons, OverrideIcons);
56
+ const close = () => {
57
+ setText("");
48
58
  };
49
- const Icons = Object.assign(DefaultIcons, OverrideIcons);
50
- const close = () => setText("");
51
59
  const onChange = e => {
52
60
  const userInput = e.currentTarget.value;
53
61
  setText(userInput);
@@ -89,8 +97,12 @@ const SearchBar = ({
89
97
  newSelected = up ? selectedResult.previousElementSibling || lastResult : selectedResult.nextElementSibling || firstResult;
90
98
  }
91
99
  allResults.forEach(result => result.classList.remove("search-bar__result--selected"));
92
- newSelected && newSelected.classList.add("search-bar__result--selected");
93
- container && newSelected && (container.scrollTop = newSelected.offsetTop - newSelected.clientHeight);
100
+ if (newSelected) {
101
+ newSelected.classList.add("search-bar__result--selected");
102
+ }
103
+ if (container && newSelected) {
104
+ container.scrollTop = newSelected.offsetTop - newSelected.clientHeight;
105
+ }
94
106
  };
95
107
  const focusInput = () => {
96
108
  input.current.focus();
@@ -98,6 +98,7 @@ export default function Instructor({
98
98
  isOpened: popupOpened,
99
99
  close: closePopup,
100
100
  onClose: closePopup,
101
+ showAsModal: false,
101
102
  children: _jsx("div", {
102
103
  className: css.dialogContent,
103
104
  children: _jsx(Sheet, {
@@ -24,9 +24,6 @@
24
24
  gap: 26px;
25
25
  }
26
26
 
27
- .link {
28
- }
29
-
30
27
  .header {
31
28
  display: flex;
32
29
  align-items: center;
@@ -40,7 +37,6 @@
40
37
  display: flex;
41
38
  align-items: center;
42
39
  justify-content: center;
43
- border-bottom: 1px solid var(--ds-grey-100, #f5f5f5);
44
40
  border-radius: var(--ds-radius-200, 10px);
45
41
  }
46
42
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ublo-lib",
3
- "version": "1.11.3",
3
+ "version": "1.11.4",
4
4
  "peerDependencies": {
5
5
  "dt-design-system": "^2.1.0",
6
6
  "leaflet": "^1.9.1",
@@ -1,25 +0,0 @@
1
- import * as React from "react";
2
- import { jsx as _jsx } from "react/jsx-runtime";
3
- const Icon = ({
4
- width = 24,
5
- height = 24,
6
- ...props
7
- }) => _jsx("svg", {
8
- viewBox: `0 0 ${width} ${height}`,
9
- width: width,
10
- height: height,
11
- ...props,
12
- children: props.children
13
- });
14
- export const SearchIcon = props => _jsx(Icon, {
15
- ...props,
16
- children: _jsx("path", {
17
- d: "M15.5 14h-.79l-.28-.27C15.41 12.59 16 11.11 16 9.5 16 5.91 13.09 3 9.5 3S3 5.91 3 9.5 5.91 16 9.5 16c1.61 0 3.09-.59 4.23-1.57l.27.28v.79l5 4.99L20.49 19l-4.99-5zm-6 0C7.01 14 5 11.99 5 9.5S7.01 5 9.5 5 14 7.01 14 9.5 11.99 14 9.5 14z"
18
- })
19
- });
20
- export const LoadIcon = props => _jsx(Icon, {
21
- ...props,
22
- children: _jsx("path", {
23
- d: "M19 8l-4 4h3c0 3.31-2.69 6-6 6-1.01 0-1.97-.25-2.8-.7l-1.46 1.46C8.97 19.54 10.43 20 12 20c4.42 0 8-3.58 8-8h3l-4-4zM6 12c0-3.31 2.69-6 6-6 1.01 0 1.97.25 2.8.7l1.46-1.46C15.03 4.46 13.57 4 12 4c-4.42 0-8 3.58-8 8H1l4 4 4-4H6z"
24
- })
25
- });