@autoguru/overdrive 4.1.2 → 4.1.6

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/CHANGELOG.md CHANGED
@@ -1,5 +1,29 @@
1
1
  # @autoguru/overdrive
2
2
 
3
+ ## 4.1.6
4
+
5
+ ### Patch Changes
6
+
7
+ - 13acf79: AutoSuggest: Calls onEnter with current value
8
+
9
+ ## 4.1.5
10
+
11
+ ### Patch Changes
12
+
13
+ - 6ae288e: AutoSuggest: Type fixes
14
+
15
+ ## 4.1.4
16
+
17
+ ### Patch Changes
18
+
19
+ - Overdrive: Fixed input ref type
20
+
21
+ ## 4.1.3
22
+
23
+ ### Patch Changes
24
+
25
+ - 9884f4c: Autosuggest: Closes results when enter key is pressed
26
+
3
27
  ## 4.1.2
4
28
 
5
29
  ### Patch Changes
@@ -1 +1 @@
1
- {"version":3,"file":"AutoSuggest.d.ts","sourceRoot":"","sources":["../../../lib/components/AutoSuggest/AutoSuggest.tsx"],"names":[],"mappings":"AAAA,OAAO,EAA8B,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAIvE,OAAO,EACN,wBAAwB,EAIxB,YAAY,EAEZ,GAAG,EAOH,MAAM,OAAO,CAAC;AAWf,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAMzC,MAAM,WAAW,gBAAgB,CAAC,WAAW;IAC5C,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,WAAW,GAAG,IAAI,GAAG,SAAS,CAAC;IACxC,IAAI,CAAC,EAAE,OAAO,CAAC;CACf;AAED,oBAAY,uBAAuB,CAAC,WAAW,IAAI,CAAC,KAAK,EAAE;IAC1D,KAAK,EAAE,gBAAgB,CAAC,WAAW,CAAC,CAAC;IACrC,SAAS,EAAE,OAAO,CAAC;IACnB,WAAW,EAAE,KAAK,CAAC,gBAAgB,CAAC,WAAW,CAAC,CAAC,CAAC;CAClD,KAAK,YAAY,CAAC;AAiCnB,aAAK,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uBAAuB,CAAC,WAAW,IAAI,CAAC,KAAK,EAAE;IAC1D,KAAK,EAAE,gBAAgB,CAAC,WAAW,CAAC,CAAC;IACrC,SAAS,EAAE,OAAO,CAAC;IACnB,WAAW,EAAE,KAAK,CAAC,gBAAgB,CAAC,WAAW,CAAC,CAAC,CAAC;CAClD,KAAK,YAAY,CAAC;AAiCnB,aAAK,WAAW,CAAC,WAAW,IAAI,KAAK,CAAC,gBAAgB,CAAC,WAAW,CAAC,CAAC,CAAC;AAErE,MAAM,WAAW,KAAK,CAAC,WAAW,CACjC,SAAQ,IAAI,CACX,wBAAwB,CAAC,OAAO,SAAS,CAAC,EAC1C,UAAU,GAAG,OAAO,GAAG,MAAM,GAAG,YAAY,CAC5C;IACD,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB,SAAS,CAAC,EAAE,QAAQ,CAAC;IACrB,KAAK,EAAE,gBAAgB,CAAC,WAAW,CAAC,GAAG,IAAI,CAAC;IAC5C,WAAW,EAAE,WAAW,CAAC,WAAW,CAAC,CAAC;IAEtC,YAAY,CAAC,EAAE,uBAAuB,CAAC,WAAW,CAAC,CAAC;IAEpD,QAAQ,CAAC,CAAC,KAAK,EAAE,gBAAgB,CAAC,WAAW,CAAC,GAAG,IAAI,CAAC;IACtD,OAAO,CAAC,CAAC,KAAK,EAAE,gBAAgB,CAAC,WAAW,CAAC,GAAG,IAAI,CAAC;CACrD;AAwGD,eAAO,MAAM,WAAW;UAqFS,IAAI,gBAAgB,CAAC;MACjD,YAAY,CAAC"}
@@ -2,7 +2,7 @@ import { ChevronDownIcon, CloseIcon } from '@autoguru/icons';
2
2
  import { wrapEvent } from '@autoguru/utilities';
3
3
  import clsx from 'clsx';
4
4
  import * as React from 'react';
5
- import { forwardRef, useCallback, useEffect, useMemo, useReducer, useRef, useState, } from 'react';
5
+ import { forwardRef, useCallback, useEffect, useImperativeHandle, useMemo, useReducer, useRef, useState, } from 'react';
6
6
  import { useMedia } from '../../hooks/useMedia';
7
7
  import { setRef, useId } from '../../utils';
8
8
  import { Box } from '../Box';
@@ -97,6 +97,8 @@ const inputReducerFactory = (suggestions) => (prevState, action) => {
97
97
  }
98
98
  };
99
99
  export const AutoSuggest = forwardRef(function AutoSuggest({ autoFocus = false, autoWidth = false, inlineOptions = false, fieldIcon, suggestions, value, onChange: incomingOnChange, onEnter, itemRenderer = defaultItemRenderer, onBlur: incomingOnBlur, onFocus: incomingOnFocus, onKeyDown, onClick, ...textInputProps }, ref) {
100
+ const inputRef = useRef();
101
+ useImperativeHandle(ref, () => inputRef.current);
100
102
  const [isDesktop] = useMedia(['desktop'], false);
101
103
  const [isFocused, setIsFocused] = useState(false);
102
104
  const [showModal, setShowModal] = useState(false);
@@ -115,6 +117,9 @@ export const AutoSuggest = forwardRef(function AutoSuggest({ autoFocus = false,
115
117
  },
116
118
  onKeyUp: (event) => {
117
119
  if (event.key === 'Enter' && typeof onEnter === 'function') {
120
+ setShowModal(false);
121
+ setIsFocused(false);
122
+ inputRef.current?.blur();
118
123
  onEnter(value);
119
124
  }
120
125
  },
@@ -132,7 +137,7 @@ export const AutoSuggest = forwardRef(function AutoSuggest({ autoFocus = false,
132
137
  setShowModal(false);
133
138
  setIsFocused(false);
134
139
  }, [setShowModal]);
135
- return !inlineOptions && !isDesktop && showModal ? (React.createElement(AutoSuggestFullscreenInput, { ...props, isFocused: isFocused, inlineOptions: true, fieldIcon: fieldIcon, autoFocus: autoFocus, closeModal: closeModal })) : (React.createElement(AutoSuggestInput, { ref: ref, ...props, isFocused: isFocused, inlineOptions: inlineOptions, fieldIcon: fieldIcon, autoFocus: autoFocus, autoWidth: autoWidth }));
140
+ return !inlineOptions && !isDesktop && showModal ? (React.createElement(AutoSuggestFullscreenInput, { ...props, isFocused: isFocused, inlineOptions: true, fieldIcon: fieldIcon, autoFocus: autoFocus, closeModal: closeModal })) : (React.createElement(AutoSuggestInput, { ref: inputRef, ...props, isFocused: isFocused, inlineOptions: inlineOptions, fieldIcon: fieldIcon, autoFocus: autoFocus, autoWidth: autoWidth }));
136
141
  });
137
142
  const AutoSuggestFullscreenInput = forwardRef(function AutoSuggestFullscreenInput({ closeModal, ...props }, ref) {
138
143
  const [showPortal, setShowPortal] = useState(false);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@autoguru/overdrive",
3
- "version": "4.1.2",
3
+ "version": "4.1.6",
4
4
  "description": "Overdrive is a product component library, and design system for AutoGuru.",
5
5
  "types": "dist/index.d.ts",
6
6
  "main": "dist/index.js",