@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.
- package/dist/bundle.js +814 -804
- package/dist/bundle.umd.cjs +12 -12
- package/dist/components/Input/CurrencyInput/index.js +2 -2
- package/dist/components/Input/SimpleInput/index.js +1 -1
- package/dist/components/Select/getConfig.d.ts +1 -0
- package/dist/components/Select/getConfig.d.ts.map +1 -1
- package/dist/components/Select/getConfig.js +2 -1
- package/dist/components/Select/index.d.ts.map +1 -1
- package/dist/components/Select/index.js +3 -2
- package/package.json +1 -1
- package/src/components/Input/CurrencyInput/index.tsx +3 -3
- package/src/components/Input/SimpleInput/index.tsx +2 -2
- package/src/components/Select/getConfig.tsx +2 -0
- package/src/components/Select/index.tsx +9 -2
@@ -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,
|
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
@@ -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
|
|
@@ -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
|
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 />
|