@redis-ui/components 50.0.0 → 50.0.1

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.
@@ -44,6 +44,10 @@ var AutoCompleteSelect = react.default.forwardRef(({ placeholder = "Select", val
44
44
  error,
45
45
  disabled,
46
46
  ...restProps,
47
+ onPointerDown: (e) => {
48
+ e.stopPropagation();
49
+ restProps.onPointerDown?.(e);
50
+ },
47
51
  onBlur: (e) => {
48
52
  if (open) return;
49
53
  restProps.onBlur?.(e);
@@ -42,6 +42,10 @@ var AutoCompleteSelect = React.forwardRef(({ placeholder = "Select", value, opti
42
42
  error,
43
43
  disabled,
44
44
  ...restProps,
45
+ onPointerDown: (e) => {
46
+ e.stopPropagation();
47
+ restProps.onPointerDown?.(e);
48
+ },
45
49
  onBlur: (e) => {
46
50
  if (open) return;
47
51
  restProps.onBlur?.(e);
@@ -7,10 +7,12 @@ var useAutoCompleteSelect = ({ options, open, value, setOpen, onChange }) => {
7
7
  return options.filter((item) => item.value.toLowerCase().includes(value.toLowerCase()));
8
8
  }, [options, value]);
9
9
  const isSuggestedOptionsEmpty = suggestedOptions.length === 0;
10
- const onInputFocus = () => {
10
+ const onInputFocus = (moveCaretToEnd = false) => {
11
11
  setTimeout(() => {
12
- inputElRef.current?.focus();
13
- if (inputElRef.current?.value) inputElRef.current?.setSelectionRange(inputElRef.current?.value.length, inputElRef.current?.value.length);
12
+ const input = inputElRef.current;
13
+ if (!input) return;
14
+ input.focus();
15
+ if (moveCaretToEnd && input.value) input.setSelectionRange(input.value.length, input.value.length);
14
16
  });
15
17
  };
16
18
  (0, react.useEffect)(() => {
@@ -18,7 +20,7 @@ var useAutoCompleteSelect = ({ options, open, value, setOpen, onChange }) => {
18
20
  setHighlightedIndex(-1);
19
21
  }, [open, options]);
20
22
  const onItemClick = (val) => {
21
- onInputFocus();
23
+ onInputFocus(true);
22
24
  setHighlightedIndex(-1);
23
25
  setOpen(false);
24
26
  onChange(val, !isSuggestedOptionsEmpty);
@@ -16,6 +16,6 @@ declare const useAutoCompleteSelect: ({ options, open, value, setOpen, onChange
16
16
  isSuggestedOptionsEmpty: boolean;
17
17
  highlightedIndex: number;
18
18
  onClickOutside: (e: Event) => void;
19
- onInputFocus: () => void;
19
+ onInputFocus: (moveCaretToEnd?: boolean) => void;
20
20
  };
21
21
  export default useAutoCompleteSelect;
@@ -7,10 +7,12 @@ var useAutoCompleteSelect = ({ options, open, value, setOpen, onChange }) => {
7
7
  return options.filter((item) => item.value.toLowerCase().includes(value.toLowerCase()));
8
8
  }, [options, value]);
9
9
  const isSuggestedOptionsEmpty = suggestedOptions.length === 0;
10
- const onInputFocus = () => {
10
+ const onInputFocus = (moveCaretToEnd = false) => {
11
11
  setTimeout(() => {
12
- inputElRef.current?.focus();
13
- if (inputElRef.current?.value) inputElRef.current?.setSelectionRange(inputElRef.current?.value.length, inputElRef.current?.value.length);
12
+ const input = inputElRef.current;
13
+ if (!input) return;
14
+ input.focus();
15
+ if (moveCaretToEnd && input.value) input.setSelectionRange(input.value.length, input.value.length);
14
16
  });
15
17
  };
16
18
  useEffect(() => {
@@ -18,7 +20,7 @@ var useAutoCompleteSelect = ({ options, open, value, setOpen, onChange }) => {
18
20
  setHighlightedIndex(-1);
19
21
  }, [open, options]);
20
22
  const onItemClick = (val) => {
21
- onInputFocus();
23
+ onInputFocus(true);
22
24
  setHighlightedIndex(-1);
23
25
  setOpen(false);
24
26
  onChange(val, !isSuggestedOptionsEmpty);
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@redis-ui/components",
3
3
  "license": "UNLICENSED",
4
- "version": "50.0.0",
4
+ "version": "50.0.1",
5
5
  "type": "module",
6
6
  "sideEffects": [
7
7
  "./dist/index.js",