@bbl-digital/snorre 3.0.7 → 3.0.10
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/bundle.js +23 -35
- package/esm/core/Autocomplete/hooks/useAutocomplete.js +2 -13
- package/esm/core/Autocomplete/index.js +3 -4
- package/esm/core/Autocomplete/styles.js +18 -18
- package/lib/core/Autocomplete/hooks/useAutocomplete.d.ts +0 -1
- package/lib/core/Autocomplete/hooks/useAutocomplete.d.ts.map +1 -1
- package/lib/core/Autocomplete/hooks/useAutocomplete.js +2 -13
- package/lib/core/Autocomplete/index.d.ts.map +1 -1
- package/lib/core/Autocomplete/index.interfaces.d.ts +4 -3
- package/lib/core/Autocomplete/index.interfaces.d.ts.map +1 -1
- package/lib/core/Autocomplete/index.js +3 -4
- package/lib/core/Autocomplete/styles.d.ts.map +1 -1
- package/lib/core/Autocomplete/styles.js +18 -18
- package/package.json +1 -1
@@ -12,8 +12,8 @@ const useAutocomplete = props => {
|
|
12
12
|
const [inputValues, setInputValues] = useState(props.values);
|
13
13
|
|
14
14
|
const handleValueClick = value => {
|
15
|
-
props.onSelectItem?.(value);
|
16
15
|
setShowValues(false);
|
16
|
+
props.onSelectItem?.(value);
|
17
17
|
};
|
18
18
|
|
19
19
|
const clearSelectedItem = () => handleValueClick({
|
@@ -38,8 +38,6 @@ const useAutocomplete = props => {
|
|
38
38
|
const onFuzzyBlur = e => {
|
39
39
|
// If the value of the input is changed, and does not match the value of the values array,
|
40
40
|
// we should revert back the input value to the original value
|
41
|
-
//What
|
42
|
-
// if (!e.target.value.length) clearSelectedItem()
|
43
41
|
if (e.target.value === props.value) return; // If target value is the same as a value from the values array, we should set the value for the user
|
44
42
|
|
45
43
|
if (inputValues?.length) {
|
@@ -50,18 +48,10 @@ const useAutocomplete = props => {
|
|
50
48
|
setValueChanged(val);
|
51
49
|
handleValueClick(valueInInputValues);
|
52
50
|
return;
|
53
|
-
}
|
54
|
-
|
55
|
-
|
56
|
-
setValueChanged(props.value ?? '');
|
51
|
+
}
|
57
52
|
}
|
58
53
|
};
|
59
54
|
|
60
|
-
const onFuzzyFocus = () => {
|
61
|
-
setValueChanged('');
|
62
|
-
if (props.values?.length) setShowValues(true);
|
63
|
-
};
|
64
|
-
|
65
55
|
const renderedValues = useMemo(() => {
|
66
56
|
if (!props.values?.length) return [];
|
67
57
|
|
@@ -231,7 +221,6 @@ const useAutocomplete = props => {
|
|
231
221
|
handleCustomOnKeyDown,
|
232
222
|
handleOnInputClick,
|
233
223
|
onFuzzyBlur,
|
234
|
-
onFuzzyFocus,
|
235
224
|
value,
|
236
225
|
highlightedIndex,
|
237
226
|
showValues,
|
@@ -37,8 +37,7 @@ const Autocomplete = /*#__PURE__*/React.forwardRef(({
|
|
37
37
|
handleOnKeyDown,
|
38
38
|
handleValueClick,
|
39
39
|
onInputChange,
|
40
|
-
onFuzzyBlur
|
41
|
-
onFuzzyFocus
|
40
|
+
onFuzzyBlur
|
42
41
|
} = useAutocomplete(props);
|
43
42
|
useEffect(() => {
|
44
43
|
const handleClickOutside = e => {
|
@@ -60,8 +59,8 @@ const Autocomplete = /*#__PURE__*/React.forwardRef(({
|
|
60
59
|
return _jsxs(_Fragment, {
|
61
60
|
children: [_jsxs("label", {
|
62
61
|
ref: inputWrapperRef,
|
63
|
-
css: theme => [styles.default(theme), (props.invalid || props.invalidMessage) && styles.invalid(theme), props.validation && styles.validation, props.onLabelClick && styles.clickableLabel, height && styles.height(height), css && css],
|
64
62
|
onClick: props.onLabelClick ? e => e.preventDefault() : undefined,
|
63
|
+
css: theme => [styles.default(theme), (props.invalid || props.invalidMessage) && styles.invalid(theme), props.validation && styles.validation, props.onLabelClick && styles.clickableLabel, height && styles.height(height), css && css],
|
65
64
|
children: [_jsxs("span", {
|
66
65
|
css: styles.label,
|
67
66
|
children: [props.label && (props.onLabelClick ? _jsx(Link, {
|
@@ -83,7 +82,7 @@ const Autocomplete = /*#__PURE__*/React.forwardRef(({
|
|
83
82
|
disabled: props.disabled,
|
84
83
|
autoFocus: props.focus,
|
85
84
|
onBlur: props.fuzzy ? onFuzzyBlur : props.onBlur,
|
86
|
-
onFocus: props.
|
85
|
+
onFocus: props.onFocus,
|
87
86
|
onChange: onInputChange,
|
88
87
|
onKeyDown: props.onKeyDown ? handleCustomOnKeyDown : handleOnKeyDown,
|
89
88
|
onClick: handleOnInputClick,
|