@sanity/ui 2.4.0 → 2.6.0
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/index.d.mts +6 -0
- package/dist/index.d.ts +6 -0
- package/dist/index.esm.js +13 -8
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +13 -8
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +13 -8
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
- package/src/core/components/autocomplete/autocomplete.tsx +14 -6
- package/src/core/primitives/textArea/textArea.tsx +6 -0
package/package.json
CHANGED
|
@@ -61,6 +61,8 @@ export interface AutocompleteProps<Option extends BaseAutocompleteOption = BaseA
|
|
|
61
61
|
onSelect?: (value: string) => void
|
|
62
62
|
/** @beta */
|
|
63
63
|
openButton?: boolean | AutocompleteOpenButtonProps
|
|
64
|
+
/** @beta */
|
|
65
|
+
openOnFocus?: boolean
|
|
64
66
|
/** The options to render. */
|
|
65
67
|
options?: Option[]
|
|
66
68
|
padding?: number | number[]
|
|
@@ -138,6 +140,7 @@ const InnerAutocomplete = forwardRef(function InnerAutocomplete<
|
|
|
138
140
|
onQueryChange,
|
|
139
141
|
onSelect,
|
|
140
142
|
openButton,
|
|
143
|
+
openOnFocus,
|
|
141
144
|
options: optionsProp,
|
|
142
145
|
padding: paddingProp = 3,
|
|
143
146
|
popover = EMPTY_RECORD,
|
|
@@ -354,15 +357,23 @@ const InnerAutocomplete = forwardRef(function InnerAutocomplete<
|
|
|
354
357
|
[onQueryChange],
|
|
355
358
|
)
|
|
356
359
|
|
|
360
|
+
const dispatchOpen = useCallback(() => {
|
|
361
|
+
dispatch({
|
|
362
|
+
type: 'root/open',
|
|
363
|
+
query: value ? renderValue(value, currentOption) : '',
|
|
364
|
+
})
|
|
365
|
+
}, [currentOption, renderValue, value])
|
|
366
|
+
|
|
357
367
|
const handleInputFocus = useCallback(
|
|
358
368
|
(event: FocusEvent<HTMLInputElement>) => {
|
|
359
369
|
if (!focused) {
|
|
360
370
|
dispatch({type: 'input/focus'})
|
|
361
371
|
|
|
362
372
|
if (onFocus) onFocus(event)
|
|
373
|
+
if (openOnFocus) dispatchOpen()
|
|
363
374
|
}
|
|
364
375
|
},
|
|
365
|
-
[focused, onFocus],
|
|
376
|
+
[focused, onFocus, openOnFocus, dispatchOpen],
|
|
366
377
|
)
|
|
367
378
|
|
|
368
379
|
const handlePopoverMouseEnter = useCallback(() => {
|
|
@@ -467,16 +478,13 @@ const InnerAutocomplete = forwardRef(function InnerAutocomplete<
|
|
|
467
478
|
|
|
468
479
|
const handleOpenClick = useCallback(
|
|
469
480
|
(event: MouseEvent<HTMLButtonElement>) => {
|
|
470
|
-
|
|
471
|
-
type: 'root/open',
|
|
472
|
-
query: value ? renderValue(value, currentOption) : '',
|
|
473
|
-
})
|
|
481
|
+
dispatchOpen()
|
|
474
482
|
|
|
475
483
|
if (openButtonProps.onClick) openButtonProps.onClick(event)
|
|
476
484
|
|
|
477
485
|
_raf(() => inputElementRef.current?.focus())
|
|
478
486
|
},
|
|
479
|
-
[
|
|
487
|
+
[openButtonProps, dispatchOpen],
|
|
480
488
|
)
|
|
481
489
|
|
|
482
490
|
const openButtonNode = useMemo(
|
|
@@ -21,6 +21,10 @@ import {ResponsiveRadiusProps} from '../types'
|
|
|
21
21
|
* @public
|
|
22
22
|
*/
|
|
23
23
|
export interface TextAreaProps extends ResponsiveRadiusProps {
|
|
24
|
+
/**
|
|
25
|
+
* @beta
|
|
26
|
+
*/
|
|
27
|
+
__unstable_disableFocusRing?: boolean
|
|
24
28
|
border?: boolean
|
|
25
29
|
customValidity?: string
|
|
26
30
|
fontSize?: number | number[]
|
|
@@ -66,6 +70,7 @@ export const TextArea = forwardRef(function TextArea(
|
|
|
66
70
|
padding = 3,
|
|
67
71
|
radius = 2,
|
|
68
72
|
weight,
|
|
73
|
+
__unstable_disableFocusRing,
|
|
69
74
|
...restProps
|
|
70
75
|
} = props
|
|
71
76
|
|
|
@@ -99,6 +104,7 @@ export const TextArea = forwardRef(function TextArea(
|
|
|
99
104
|
/>
|
|
100
105
|
<Presentation
|
|
101
106
|
$radius={useArrayProp(radius)}
|
|
107
|
+
$unstableDisableFocusRing={__unstable_disableFocusRing}
|
|
102
108
|
$scheme={rootTheme.scheme}
|
|
103
109
|
$tone={rootTheme.tone}
|
|
104
110
|
data-border={border ? '' : undefined}
|