@synerise/ds-search-bar 0.3.47 → 0.4.0

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.
package/CHANGELOG.md CHANGED
@@ -3,6 +3,17 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
5
 
6
+ # [0.4.0](https://github.com/Synerise/synerise-design/compare/@synerise/ds-search-bar@0.3.47...@synerise/ds-search-bar@0.4.0) (2021-10-19)
7
+
8
+
9
+ ### Features
10
+
11
+ * **search-bar:** performance improvements ([d8a543e](https://github.com/Synerise/synerise-design/commit/d8a543e1f0532202fc6ad3f3016ffc28a4fe5ddb))
12
+
13
+
14
+
15
+
16
+
6
17
  ## [0.3.47](https://github.com/Synerise/synerise-design/compare/@synerise/ds-search-bar@0.3.46...@synerise/ds-search-bar@0.3.47) (2021-09-21)
7
18
 
8
19
  **Note:** Version bump only for package @synerise/ds-search-bar
package/README.md CHANGED
@@ -39,3 +39,4 @@ import SearchBar from '@synerise/ds-search-bar'
39
39
  | onClearInput | Callback when user press clear button | () => void | - |
40
40
  | placeholder | Placeholder | string / React.ReactNode | - |
41
41
  | value | The input content value | string | - |
42
+ | autofocusDelay | Delay (ms) of the focus on search input | number | 0 |
package/dist/SearchBar.js CHANGED
@@ -14,7 +14,6 @@ import * as React from 'react';
14
14
  import Icon from '@synerise/ds-icon';
15
15
  import Close3M from '@synerise/ds-icon/dist/icons/Close3M';
16
16
  import theme from '@synerise/ds-core/dist/js/DSProvider/ThemeProvider/theme';
17
- import { useState } from 'react';
18
17
  import Tooltip from '@synerise/ds-tooltip';
19
18
  import { FormattedMessage } from 'react-intl';
20
19
  import * as S from './SearchBar.styles';
@@ -33,26 +32,38 @@ var SearchBar = function SearchBar(_ref) {
33
32
  }) : _ref$clearTooltip,
34
33
  disabled = _ref.disabled,
35
34
  borderRadius = _ref.borderRadius,
36
- handleInputRef = _ref.handleInputRef;
35
+ handleInputRef = _ref.handleInputRef,
36
+ autofocusDelay = _ref.autofocusDelay;
37
37
 
38
- var _useState = useState(false),
39
- _useState2 = _slicedToArray(_useState, 2),
40
- isFocused = _useState2[0],
41
- setFocus = _useState2[1];
38
+ var _React$useState = React.useState(false),
39
+ _React$useState2 = _slicedToArray(_React$useState, 2),
40
+ isFocused = _React$useState2[0],
41
+ setFocus = _React$useState2[1];
42
42
 
43
- var _useState3 = useState(),
44
- _useState4 = _slicedToArray(_useState3, 2),
45
- inputRef = _useState4[0],
46
- setInputRef = _useState4[1];
43
+ var _React$useState3 = React.useState(),
44
+ _React$useState4 = _slicedToArray(_React$useState3, 2),
45
+ inputRef = _React$useState4[0],
46
+ setInputRef = _React$useState4[1];
47
47
 
48
48
  React.useEffect(function () {
49
49
  if (inputRef) {
50
50
  handleInputRef && handleInputRef(inputRef);
51
- autofocus && inputRef.current && inputRef.current.focus({
52
- preventScroll: true
53
- });
51
+
52
+ if (autofocus) {
53
+ if (autofocusDelay) {
54
+ setTimeout(function () {
55
+ inputRef.current && inputRef.current.focus({
56
+ preventScroll: true
57
+ });
58
+ }, 50);
59
+ } else {
60
+ inputRef.current && inputRef.current.focus({
61
+ preventScroll: true
62
+ });
63
+ }
64
+ }
54
65
  }
55
- }, [autofocus, handleInputRef, inputRef]);
66
+ }, [autofocus, autofocusDelay, handleInputRef, inputRef]);
56
67
  return React.createElement(S.SearchBarWrapper, {
57
68
  iconLeft: iconLeft,
58
69
  isEmpty: !value,
@@ -8,6 +8,7 @@ export interface SearchBarProps {
8
8
  value: string;
9
9
  iconLeft?: React.ReactNode;
10
10
  autofocus?: boolean;
11
+ autofocusDelay?: number;
11
12
  disabled?: boolean;
12
13
  borderRadius?: boolean | undefined;
13
14
  handleInputRef?: (inputRef: React.MutableRefObject<HTMLInputElement | HTMLTextAreaElement | undefined>) => void;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@synerise/ds-search-bar",
3
- "version": "0.3.47",
3
+ "version": "0.4.0",
4
4
  "description": "SearchBar UI Component for the Synerise Design System",
5
5
  "license": "ISC",
6
6
  "repository": "Synerise/synerise-design",
@@ -32,13 +32,13 @@
32
32
  ],
33
33
  "types": "dist/index.d.ts",
34
34
  "dependencies": {
35
- "@synerise/ds-button": "^0.13.66",
36
- "@synerise/ds-input": "^0.17.42",
35
+ "@synerise/ds-button": "^0.13.67",
36
+ "@synerise/ds-input": "^0.17.43",
37
37
  "@synerise/ds-typography": "^0.11.9"
38
38
  },
39
39
  "peerDependencies": {
40
40
  "@synerise/ds-core": "*",
41
41
  "react": ">=16.9.0 < 17.0.0"
42
42
  },
43
- "gitHead": "a9b2577e3c7e6b51625ab3ecca84600819ad0eeb"
43
+ "gitHead": "1fdb5eb22cd9c4d5f786d33d75531c31eba7ece3"
44
44
  }