@cashub/ui 0.43.6 → 0.43.7

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.
@@ -13,7 +13,7 @@ var _inputPlaceholder = _interopRequireDefault(require("../styles/mixin/inputPla
13
13
  var _scrollbar = _interopRequireDefault(require("../styles/mixin/scrollbar"));
14
14
  var _jsxRuntime = require("react/jsx-runtime");
15
15
  var _templateObject, _templateObject2, _templateObject3, _templateObject4, _templateObject5, _templateObject6, _templateObject7, _templateObject8, _templateObject9;
16
- const _excluded = ["options", "status", "placeholder", "onInnerSearch", "onOuterSearch", "onOuterReset", "onToggleOptions"];
16
+ const _excluded = ["options", "outerStatus", "placeholder", "onInnerSearch", "onOuterSearch", "onOuterReset", "onToggleOptions"];
17
17
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
18
18
  function _taggedTemplateLiteral(e, t) { return t || (t = e.slice(0)), Object.freeze(Object.defineProperties(e, { raw: { value: Object.freeze(t) } })); }
19
19
  function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
@@ -26,7 +26,7 @@ function _objectWithoutPropertiesLoose(r, e) { if (null == r) return {}; var t =
26
26
  const SearchSelect = _ref => {
27
27
  let {
28
28
  options,
29
- status = 'idle',
29
+ outerStatus = 'idle',
30
30
  placeholder = 'Search',
31
31
  onInnerSearch,
32
32
  onOuterSearch,
@@ -39,11 +39,15 @@ const SearchSelect = _ref => {
39
39
  const [innerKeyword, setInnerKeyword] = (0, _react.useState)('');
40
40
  const [showDropdown, setShowDropdown] = (0, _react.useState)(false);
41
41
  const [dropdownWidth, setDropdownWidth] = (0, _react.useState)(0);
42
- const handleSearch = (keyword, target) => {
43
- if (onOuterSearch && target === 'outer') {
44
- onOuterSearch(keyword);
45
- } else if (onInnerSearch && target === 'inner') {
46
- onInnerSearch(keyword);
42
+ const handleSearch = async (keyword, target) => {
43
+ const hasResult = target === 'outer' ? await onOuterSearch(keyword) : await onInnerSearch(keyword);
44
+ if (hasResult) {
45
+ if (target === 'outer') {
46
+ setOuterKeyword('');
47
+ }
48
+ if (target === 'inner') {
49
+ setInnerKeyword('');
50
+ }
47
51
  }
48
52
  };
49
53
  const handleKeyUp = (event, target) => {
@@ -51,6 +55,10 @@ const SearchSelect = _ref => {
51
55
  const keyword = target === 'outer' ? outerKeyword : innerKeyword;
52
56
  handleSearch(keyword, target);
53
57
  };
58
+ const handleOuterReset = () => {
59
+ setOuterKeyword('');
60
+ onOuterReset();
61
+ };
54
62
 
55
63
  // close dropdown when click outside of the component
56
64
  (0, _react.useEffect)(() => {
@@ -91,20 +99,20 @@ const SearchSelect = _ref => {
91
99
  onFocus: () => setShowDropdown(true),
92
100
  value: outerKeyword
93
101
  }), onOuterReset && /*#__PURE__*/(0, _jsxRuntime.jsx)(_md.MdClose, {
94
- onClick: onOuterReset,
102
+ onClick: handleOuterReset,
95
103
  style: {
96
- visibility: status === 'empty' ? 'visible' : 'hidden'
104
+ visibility: outerStatus === 'empty' ? 'visible' : 'hidden'
97
105
  }
98
106
  })]
99
107
  })), showDropdown && /*#__PURE__*/(0, _jsxRuntime.jsxs)(Dropdown, {
100
108
  style: {
101
109
  width: dropdownWidth
102
110
  },
103
- children: [onOuterReset && status === 'empty' && /*#__PURE__*/(0, _jsxRuntime.jsx)(MessageWrapper, {
111
+ children: [onOuterReset && outerStatus === 'empty' && /*#__PURE__*/(0, _jsxRuntime.jsx)(MessageWrapper, {
104
112
  children: /*#__PURE__*/(0, _jsxRuntime.jsx)(Message, {
105
113
  children: "Data Not Found"
106
114
  })
107
- }), status !== 'empty' && /*#__PURE__*/(0, _jsxRuntime.jsxs)(_jsxRuntime.Fragment, {
115
+ }), outerStatus !== 'empty' && /*#__PURE__*/(0, _jsxRuntime.jsxs)(_jsxRuntime.Fragment, {
108
116
  children: [/*#__PURE__*/(0, _jsxRuntime.jsxs)(InputWrapper, {
109
117
  border: true,
110
118
  children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_fa.FaSearch, {}), /*#__PURE__*/(0, _jsxRuntime.jsx)(Input, {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cashub/ui",
3
- "version": "0.43.6",
3
+ "version": "0.43.7",
4
4
  "private": false,
5
5
  "author": "CasHUB Team",
6
6
  "description": "CasHUB UI components library",