@react-spectrum/autocomplete 3.0.0-alpha.11 → 3.0.0-alpha.12
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/main.css +1 -1
- package/dist/main.js +40 -60
- package/dist/main.js.map +1 -1
- package/dist/module.js +40 -60
- package/dist/module.js.map +1 -1
- package/dist/types.d.ts.map +1 -1
- package/package.json +27 -27
- package/src/MobileSearchAutocomplete.tsx +12 -14
- package/src/SearchAutocomplete.tsx +19 -33
- package/src/searchautocomplete.css +6 -0
|
@@ -12,7 +12,6 @@
|
|
|
12
12
|
import {AriaButtonProps} from '@react-types/button';
|
|
13
13
|
import {classNames, useFocusableRef, useIsMobileDevice, useResizeObserver, useUnwrapDOMRef} from '@react-spectrum/utils';
|
|
14
14
|
import {ClearButton} from '@react-spectrum/button';
|
|
15
|
-
import {DismissButton, useOverlayPosition} from '@react-aria/overlays';
|
|
16
15
|
import {DOMRefValue, FocusableRef} from '@react-types/shared';
|
|
17
16
|
import {Field} from '@react-spectrum/label';
|
|
18
17
|
import {FocusRing} from '@react-aria/focus';
|
|
@@ -21,10 +20,10 @@ import intlMessages from '../intl/*.json';
|
|
|
21
20
|
import {ListBoxBase, useListBoxLayout} from '@react-spectrum/listbox';
|
|
22
21
|
import Magnifier from '@spectrum-icons/ui/Magnifier';
|
|
23
22
|
import {MobileSearchAutocomplete} from './MobileSearchAutocomplete';
|
|
24
|
-
import {Placement} from '@react-types/overlays';
|
|
25
23
|
import {Popover} from '@react-spectrum/overlays';
|
|
26
24
|
import {ProgressCircle} from '@react-spectrum/progress';
|
|
27
25
|
import React, {forwardRef, InputHTMLAttributes, RefObject, useCallback, useEffect, useRef, useState} from 'react';
|
|
26
|
+
import searchAutocompleteStyles from './searchautocomplete.css';
|
|
28
27
|
import searchStyles from '@adobe/spectrum-css-temp/components/search/vars.css';
|
|
29
28
|
import {SpectrumSearchAutocompleteProps} from '@react-types/autocomplete';
|
|
30
29
|
import styles from '@adobe/spectrum-css-temp/components/inputgroup/vars.css';
|
|
@@ -100,16 +99,6 @@ const SearchAutocompleteBase = React.forwardRef(function SearchAutocompleteBase<
|
|
|
100
99
|
state
|
|
101
100
|
);
|
|
102
101
|
|
|
103
|
-
let {overlayProps, placement, updatePosition} = useOverlayPosition({
|
|
104
|
-
targetRef: inputRef,
|
|
105
|
-
overlayRef: unwrappedPopoverRef,
|
|
106
|
-
scrollRef: listBoxRef,
|
|
107
|
-
placement: `${direction} end` as Placement,
|
|
108
|
-
shouldFlip: shouldFlip,
|
|
109
|
-
isOpen: state.isOpen,
|
|
110
|
-
onClose: state.close
|
|
111
|
-
});
|
|
112
|
-
|
|
113
102
|
// Measure the width of the inputfield to inform the width of the menu (below).
|
|
114
103
|
let [menuWidth, setMenuWidth] = useState(null);
|
|
115
104
|
let {scale} = useProvider();
|
|
@@ -128,19 +117,7 @@ const SearchAutocompleteBase = React.forwardRef(function SearchAutocompleteBase<
|
|
|
128
117
|
|
|
129
118
|
useLayoutEffect(onResize, [scale, onResize]);
|
|
130
119
|
|
|
131
|
-
// Update position once the ListBox has rendered. This ensures that
|
|
132
|
-
// it flips properly when it doesn't fit in the available space.
|
|
133
|
-
// TODO: add ResizeObserver to useOverlayPosition so we don't need this.
|
|
134
|
-
useLayoutEffect(() => {
|
|
135
|
-
if (state.isOpen) {
|
|
136
|
-
requestAnimationFrame(() => {
|
|
137
|
-
updatePosition();
|
|
138
|
-
});
|
|
139
|
-
}
|
|
140
|
-
}, [state.isOpen, updatePosition]);
|
|
141
|
-
|
|
142
120
|
let style = {
|
|
143
|
-
...overlayProps.style,
|
|
144
121
|
width: isQuiet ? null : menuWidth,
|
|
145
122
|
minWidth: isQuiet ? `calc(${menuWidth}px + calc(2 * var(--spectrum-dropdown-quiet-offset)))` : menuWidth
|
|
146
123
|
};
|
|
@@ -157,14 +134,15 @@ const SearchAutocompleteBase = React.forwardRef(function SearchAutocompleteBase<
|
|
|
157
134
|
clearButtonProps={clearButtonProps} />
|
|
158
135
|
</Field>
|
|
159
136
|
<Popover
|
|
160
|
-
|
|
137
|
+
state={state}
|
|
161
138
|
UNSAFE_style={style}
|
|
162
139
|
UNSAFE_className={classNames(styles, 'spectrum-InputGroup-popover', {'spectrum-InputGroup-popover--quiet': isQuiet})}
|
|
163
140
|
ref={popoverRef}
|
|
164
|
-
|
|
141
|
+
triggerRef={inputRef}
|
|
142
|
+
placement={`${direction} end`}
|
|
165
143
|
hideArrow
|
|
166
144
|
isNonModal
|
|
167
|
-
|
|
145
|
+
shouldFlip={shouldFlip}>
|
|
168
146
|
<ListBoxBase
|
|
169
147
|
{...listBoxProps}
|
|
170
148
|
ref={listBoxRef}
|
|
@@ -182,7 +160,6 @@ const SearchAutocompleteBase = React.forwardRef(function SearchAutocompleteBase<
|
|
|
182
160
|
{stringFormatter.format('noResults')}
|
|
183
161
|
</span>
|
|
184
162
|
)} />
|
|
185
|
-
<DismissButton onDismiss={() => state.close()} />
|
|
186
163
|
</Popover>
|
|
187
164
|
</>
|
|
188
165
|
);
|
|
@@ -297,9 +274,13 @@ const SearchAutocompleteInput = React.forwardRef(function SearchAutocompleteInpu
|
|
|
297
274
|
{
|
|
298
275
|
'spectrum-InputGroup--quiet': isQuiet,
|
|
299
276
|
'is-disabled': isDisabled,
|
|
300
|
-
'spectrum-InputGroup--invalid': validationState === 'invalid',
|
|
277
|
+
'spectrum-InputGroup--invalid': validationState === 'invalid' && !isDisabled,
|
|
301
278
|
'is-hovered': isHovered
|
|
302
279
|
},
|
|
280
|
+
classNames(
|
|
281
|
+
searchAutocompleteStyles,
|
|
282
|
+
'searchautocomplete'
|
|
283
|
+
),
|
|
303
284
|
className
|
|
304
285
|
)
|
|
305
286
|
}>
|
|
@@ -314,9 +295,13 @@ const SearchAutocompleteInput = React.forwardRef(function SearchAutocompleteInpu
|
|
|
314
295
|
{
|
|
315
296
|
'is-disabled': isDisabled,
|
|
316
297
|
'is-quiet': isQuiet,
|
|
317
|
-
'spectrum-Search--invalid': validationState === 'invalid',
|
|
318
|
-
'spectrum-Search--valid': validationState === 'valid'
|
|
319
|
-
}
|
|
298
|
+
'spectrum-Search--invalid': validationState === 'invalid' && !isDisabled,
|
|
299
|
+
'spectrum-Search--valid': validationState === 'valid' && !isDisabled
|
|
300
|
+
},
|
|
301
|
+
classNames(
|
|
302
|
+
styles,
|
|
303
|
+
'spectrum-InputGroup-field'
|
|
304
|
+
)
|
|
320
305
|
)
|
|
321
306
|
}
|
|
322
307
|
inputClassName={classNames(searchStyles, 'spectrum-Search-input')}
|
|
@@ -326,7 +311,8 @@ const SearchAutocompleteInput = React.forwardRef(function SearchAutocompleteInpu
|
|
|
326
311
|
isLoading={showLoading && (isOpen || menuTrigger === 'manual' || loadingState === 'loading')}
|
|
327
312
|
loadingIndicator={loadingState != null && loadingCircle}
|
|
328
313
|
icon={icon}
|
|
329
|
-
wrapperChildren={(inputValue !== '' && !isReadOnly) && clearButton}
|
|
314
|
+
wrapperChildren={(inputValue !== '' && !isReadOnly) && clearButton}
|
|
315
|
+
disableFocusRing />
|
|
330
316
|
</div>
|
|
331
317
|
</FocusRing>
|
|
332
318
|
);
|
|
@@ -23,6 +23,12 @@
|
|
|
23
23
|
font-style: italic;
|
|
24
24
|
}
|
|
25
25
|
|
|
26
|
+
/* override .spectrum-InputGroup */
|
|
27
|
+
.searchautocomplete.searchautocomplete {
|
|
28
|
+
border-radius: var(--spectrum-search-border-radius);
|
|
29
|
+
--spectrum-focus-ring-border-radius: var(--spectrum-search-border-radius);
|
|
30
|
+
}
|
|
31
|
+
|
|
26
32
|
.mobile-searchautocomplete {
|
|
27
33
|
outline: none;
|
|
28
34
|
}
|