@arkyn/components 1.3.8 → 1.3.10

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.
@@ -10,7 +10,7 @@ function Select(props) {
10
10
  const baseRef = useRef(null);
11
11
  const ref = inputRef || baseRef;
12
12
  const isError = props.isError || !!error;
13
- const { disabled, title, style, className, prefix, iconSize, isLoading, LeftIcon, value: baseValue = null, defaultValue = "", readOnly, onFocus, onBlur, Spinner, name, isSearchable, placeholder, onSelect, options, optionMaxHeight, ...rest } = getConfig({ ...props, id, isError }, isFocused);
13
+ const { disabled, title, style, className, prefix, iconSize, isLoading, LeftIcon, value: baseValue = null, defaultValue = "", readOnly, onFocus, onBlur, Spinner, name, isSearchable, placeholder, onSelect, options, optionMaxHeight, closeOnSelect, ...rest } = getConfig({ ...props, id, isError }, isFocused);
14
14
  const [selectedValue, setSelectedValue] = useState(defaultValue);
15
15
  const [searchValue, setSearchValue] = useState("");
16
16
  function handleSectionClick() {
@@ -60,12 +60,13 @@ function Select(props) {
60
60
  return true;
61
61
  }
62
62
  });
63
- 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 || isLoading, readOnly: !isSearchable, value: searchValue || "", placeholder: currentLabel || placeholder, ref: ref, onFocus: handleFocus, onBlur: () => setSearchValue(""), ...rest, onChange: (e) => setSearchValue(e.target.value) }), _jsx("input", { type: "hidden", name: name, value: currentValue || "", readOnly: true }), isFocused && (_jsxs("ul", { className: "arkyn_select_content", style: { overflow: "auto", maxHeight: optionMaxHeight }, children: [filteredOptions.map(({ label, value }) => (_jsxs("li", { className: currentValue === value ? "active" : "", onClick: () => {
63
+ 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 || isLoading, readOnly: !isSearchable, value: searchValue || "", placeholder: currentLabel || placeholder, onFocus: handleFocus, onBlur: () => setSearchValue(""), ...rest, onChange: (e) => setSearchValue(e.target.value) }), _jsx("input", { type: "hidden", ref: ref, name: name, value: currentValue || "", readOnly: true }), isFocused && (_jsxs("ul", { className: "arkyn_select_content", style: { overflow: "auto", maxHeight: optionMaxHeight }, children: [filteredOptions.map(({ label, value }) => (_jsxs("li", { className: currentValue === value ? "active" : "", onClick: () => {
64
64
  if (selectedValue !== value)
65
65
  setSelectedValue(value);
66
66
  else
67
67
  setSelectedValue("");
68
68
  onSelect && onSelect({ label, value });
69
+ closeOnSelect && setTimeout(() => handleBlur(), 100);
69
70
  }, children: [label, " ", _jsx(Check, {})] }, value))), filteredOptions.length <= 0 && _jsx("p", { children: "Sem op\u00E7\u00F5es dispon\u00EDveis" })] })), !isLoading && (_jsx(ChevronDown, { className: "arkyn_select_arrow", size: iconSize, strokeWidth: 2.5 })), isLoading && Spinner] }), isFocused && (_jsx("aside", { className: "arkyn_select_overlay", onClick: handleBlur }))] }));
70
71
  }
71
72
  export { Select };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@arkyn/components",
3
- "version": "1.3.8",
3
+ "version": "1.3.10",
4
4
  "main": "./dist/bundle.js",
5
5
  "types": "./dist/index.d.ts",
6
6
  "author": "Lucas Gonçalves",
@@ -9,9 +9,6 @@ import { currencyInputKeyDown, valueDisplay } from "./utils";
9
9
 
10
10
  function CurrencyInput(props: CurrencyInputProps) {
11
11
  const [isFocused, setIsFocused] = useState(false);
12
- const [currencyValue, setCurrencyValue] = useState(
13
- props.defaultValue * 100 || 0
14
- );
15
12
 
16
13
  const baseRef = useRef<HTMLInputElement>(null);
17
14
 
@@ -41,9 +38,12 @@ function CurrencyInput(props: CurrencyInputProps) {
41
38
  onKeyDown,
42
39
  onChange,
43
40
  showCents,
41
+ defaultValue,
44
42
  ...rest
45
43
  } = getConfig({ ...props, id, isError }, isFocused);
46
44
 
45
+ const [currencyValue, setCurrencyValue] = useState(defaultValue * 100 || 0);
46
+
47
47
  const showLeftIcon = LeftIcon && !isLoading;
48
48
  const showRightIcon = RightIcon && !isLoading;
49
49
 
@@ -58,8 +58,8 @@ function SimpleInput(props: SimpleInputProps) {
58
58
  if (onBlur) onBlur(e);
59
59
  }
60
60
 
61
- if(type === "hidden") {
62
- return <input type="hidden" {...rest} />
61
+ if (type === "hidden") {
62
+ return <input type="hidden" ref={ref} {...rest} />;
63
63
  }
64
64
 
65
65
  return (
@@ -19,6 +19,7 @@ function getConfig(props: SelectProps, isFocused: boolean) {
19
19
  title,
20
20
  style,
21
21
  isSearchable = false,
22
+ closeOnSelect = true,
22
23
  ...rest
23
24
  } = props;
24
25
 
@@ -41,6 +42,7 @@ function getConfig(props: SelectProps, isFocused: boolean) {
41
42
  onFocus,
42
43
  onBlur,
43
44
  title,
45
+ closeOnSelect,
44
46
  style,
45
47
  isSearchable,
46
48
  iconSize: iconSize,
@@ -39,6 +39,7 @@ function Select(props: SelectProps) {
39
39
  onSelect,
40
40
  options,
41
41
  optionMaxHeight,
42
+ closeOnSelect,
42
43
  ...rest
43
44
  } = getConfig({ ...props, id, isError }, isFocused);
44
45
 
@@ -109,14 +110,19 @@ function Select(props: SelectProps) {
109
110
  readOnly={!isSearchable}
110
111
  value={searchValue || ""}
111
112
  placeholder={currentLabel || placeholder}
112
- ref={ref}
113
113
  onFocus={handleFocus}
114
114
  onBlur={() => setSearchValue("")}
115
115
  {...rest}
116
116
  onChange={(e) => setSearchValue(e.target.value)}
117
117
  />
118
118
 
119
- <input type="hidden" name={name} value={currentValue || ""} readOnly />
119
+ <input
120
+ type="hidden"
121
+ ref={ref}
122
+ name={name}
123
+ value={currentValue || ""}
124
+ readOnly
125
+ />
120
126
 
121
127
  {isFocused && (
122
128
  <ul
@@ -131,6 +137,7 @@ function Select(props: SelectProps) {
131
137
  if (selectedValue !== value) setSelectedValue(value);
132
138
  else setSelectedValue("");
133
139
  onSelect && onSelect({ label, value });
140
+ closeOnSelect && setTimeout(() => handleBlur(), 100);
134
141
  }}
135
142
  >
136
143
  {label} <Check />