@arkyn/components 1.4.18 → 1.4.20

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":"index.d.ts","sourceRoot":"","sources":["../../../src/components/Select/index.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAUhD,OAAO,cAAc,CAAC;AAEtB,iBAAS,MAAM,CAAC,KAAK,EAAE,WAAW,2CAgKjC;AAED,OAAO,EAAE,MAAM,EAAE,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/Select/index.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAUhD,OAAO,cAAc,CAAC;AAEtB,iBAAS,MAAM,CAAC,KAAK,EAAE,WAAW,2CAyKjC;AAED,OAAO,EAAE,MAAM,EAAE,CAAC"}
@@ -20,6 +20,14 @@ function Select(props) {
20
20
  setIsFocused(true);
21
21
  ref.current.focus();
22
22
  }
23
+ function handleSearch(e) {
24
+ if (onSearch) {
25
+ setSearch("");
26
+ onSearch(e.target.value);
27
+ }
28
+ if (!onSearch)
29
+ setSearch(e.target.value);
30
+ }
23
31
  function handleFocus(e) {
24
32
  if (isFocused)
25
33
  return;
@@ -55,7 +63,7 @@ function Select(props) {
55
63
  if (isFocused && !currentLabel)
56
64
  return false;
57
65
  };
58
- return (_jsxs(_Fragment, { children: [_jsxs("section", { title: title, style: style, onClick: handleSectionClick, className: `${className} placeholder_dark_${placeholderDark()}`, children: [prefix, LeftIcon && _jsx(LeftIcon, { size: iconSize, strokeWidth: 2.5 }), _jsx("input", { disabled: disabled, readOnly: true, placeholder: currentLabel || placeholder, onFocus: handleFocus, ...rest }), _jsx("input", { type: "hidden", ref: ref, name: name, value: currentValue || "", readOnly: true }), isFocused && (_jsxs("div", { className: "arkyn_select_content", style: { overflow: "auto", maxHeight: optionMaxHeight }, children: [isSearchable && (_jsx(Input, { type: "search", name: "search-select", variant: "underline", leftIcon: Search, onChange: (e) => setSearch(e.target.value) })), options
66
+ return (_jsxs(_Fragment, { children: [_jsxs("section", { title: title, style: style, onClick: handleSectionClick, className: `${className} placeholder_dark_${placeholderDark()}`, children: [prefix, LeftIcon && _jsx(LeftIcon, { size: iconSize, strokeWidth: 2.5 }), _jsx("input", { disabled: disabled, readOnly: true, placeholder: currentLabel || placeholder, onFocus: handleFocus, ...rest }), _jsx("input", { type: "hidden", ref: ref, name: name, value: currentValue || "", readOnly: true }), isFocused && (_jsxs("div", { className: "arkyn_select_content", style: { overflow: "auto", maxHeight: optionMaxHeight }, children: [isSearchable && (_jsx(Input, { type: "search", name: "search-select", variant: "underline", leftIcon: Search, onChange: handleSearch })), options
59
67
  .filter((option) => {
60
68
  if (props.onSearch)
61
69
  return true;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@arkyn/components",
3
- "version": "1.4.18",
3
+ "version": "1.4.20",
4
4
  "main": "./dist/bundle.js",
5
5
  "types": "./dist/index.d.ts",
6
6
  "author": "Lucas Gonçalves",
@@ -53,6 +53,15 @@ function Select(props: SelectProps) {
53
53
  ref.current.focus();
54
54
  }
55
55
 
56
+ function handleSearch(e: React.ChangeEvent<HTMLInputElement>) {
57
+ if (onSearch) {
58
+ setSearch("");
59
+ onSearch(e.target.value);
60
+ }
61
+
62
+ if (!onSearch) setSearch(e.target.value);
63
+ }
64
+
56
65
  function handleFocus(e: FocusEvent<HTMLInputElement>) {
57
66
  if (isFocused) return;
58
67
  setIsFocused(true);
@@ -125,7 +134,7 @@ function Select(props: SelectProps) {
125
134
  name="search-select"
126
135
  variant="underline"
127
136
  leftIcon={Search}
128
- onChange={(e) => setSearch(e.target.value)}
137
+ onChange={handleSearch}
129
138
  />
130
139
  )}
131
140