@react-aria/searchfield 3.1.5 → 3.2.3
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.js +245 -232
- package/dist/main.js.map +1 -1
- package/dist/module.js +242 -231
- package/dist/module.js.map +1 -1
- package/dist/types.d.ts +7 -3
- package/dist/types.d.ts.map +1 -1
- package/package.json +10 -10
- package/src/useSearchField.ts +14 -7
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@react-aria/searchfield",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.2.3",
|
|
4
4
|
"description": "Spectrum UI components in React",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"main": "dist/main.js",
|
|
@@ -18,14 +18,14 @@
|
|
|
18
18
|
},
|
|
19
19
|
"dependencies": {
|
|
20
20
|
"@babel/runtime": "^7.6.2",
|
|
21
|
-
"@react-aria/i18n": "^3.3.
|
|
22
|
-
"@react-aria/interactions": "^3.
|
|
23
|
-
"@react-aria/textfield": "^3.
|
|
24
|
-
"@react-aria/utils": "^3.
|
|
25
|
-
"@react-stately/searchfield": "^3.1.
|
|
26
|
-
"@react-types/button": "^3.4.
|
|
27
|
-
"@react-types/searchfield": "^3.1.
|
|
28
|
-
"@react-types/shared": "^3.
|
|
21
|
+
"@react-aria/i18n": "^3.3.5",
|
|
22
|
+
"@react-aria/interactions": "^3.8.0",
|
|
23
|
+
"@react-aria/textfield": "^3.5.1",
|
|
24
|
+
"@react-aria/utils": "^3.11.1",
|
|
25
|
+
"@react-stately/searchfield": "^3.1.4",
|
|
26
|
+
"@react-types/button": "^3.4.2",
|
|
27
|
+
"@react-types/searchfield": "^3.1.3",
|
|
28
|
+
"@react-types/shared": "^3.11.0"
|
|
29
29
|
},
|
|
30
30
|
"peerDependencies": {
|
|
31
31
|
"react": "^16.8.0 || ^17.0.0-rc.1"
|
|
@@ -33,5 +33,5 @@
|
|
|
33
33
|
"publishConfig": {
|
|
34
34
|
"access": "public"
|
|
35
35
|
},
|
|
36
|
-
"gitHead": "
|
|
36
|
+
"gitHead": "54c2366c4f31bd4bf619126131cd583c12972acc"
|
|
37
37
|
}
|
package/src/useSearchField.ts
CHANGED
|
@@ -12,7 +12,8 @@
|
|
|
12
12
|
|
|
13
13
|
import {AriaButtonProps} from '@react-types/button';
|
|
14
14
|
import {AriaSearchFieldProps} from '@react-types/searchfield';
|
|
15
|
-
import {
|
|
15
|
+
import {chain} from '@react-aria/utils';
|
|
16
|
+
import {HTMLAttributes, InputHTMLAttributes, LabelHTMLAttributes, RefObject} from 'react';
|
|
16
17
|
// @ts-ignore
|
|
17
18
|
import intlMessages from '../intl/*.json';
|
|
18
19
|
import {SearchFieldState} from '@react-stately/searchfield';
|
|
@@ -23,9 +24,13 @@ interface SearchFieldAria {
|
|
|
23
24
|
/** Props for the text field's visible label element (if any). */
|
|
24
25
|
labelProps: LabelHTMLAttributes<HTMLLabelElement>,
|
|
25
26
|
/** Props for the input element. */
|
|
26
|
-
inputProps: InputHTMLAttributes<HTMLInputElement
|
|
27
|
+
inputProps: InputHTMLAttributes<HTMLInputElement>,
|
|
27
28
|
/** Props for the clear button. */
|
|
28
|
-
clearButtonProps: AriaButtonProps
|
|
29
|
+
clearButtonProps: AriaButtonProps,
|
|
30
|
+
/** Props for the searchfield's description element, if any. */
|
|
31
|
+
descriptionProps: HTMLAttributes<HTMLElement>,
|
|
32
|
+
/** Props for the searchfield's error message element, if any. */
|
|
33
|
+
errorMessageProps: HTMLAttributes<HTMLElement>
|
|
29
34
|
}
|
|
30
35
|
|
|
31
36
|
/**
|
|
@@ -37,7 +42,7 @@ interface SearchFieldAria {
|
|
|
37
42
|
export function useSearchField(
|
|
38
43
|
props: AriaSearchFieldProps,
|
|
39
44
|
state: SearchFieldState,
|
|
40
|
-
inputRef: RefObject<HTMLInputElement
|
|
45
|
+
inputRef: RefObject<HTMLInputElement>
|
|
41
46
|
): SearchFieldAria {
|
|
42
47
|
let formatMessage = useMessageFormatter(intlMessages);
|
|
43
48
|
let {
|
|
@@ -84,11 +89,11 @@ export function useSearchField(
|
|
|
84
89
|
inputRef.current.focus();
|
|
85
90
|
};
|
|
86
91
|
|
|
87
|
-
let {labelProps, inputProps} = useTextField({
|
|
92
|
+
let {labelProps, inputProps, descriptionProps, errorMessageProps} = useTextField({
|
|
88
93
|
...props,
|
|
89
94
|
value: state.value,
|
|
90
95
|
onChange: state.setValue,
|
|
91
|
-
onKeyDown,
|
|
96
|
+
onKeyDown: chain(onKeyDown, props.onKeyDown),
|
|
92
97
|
type
|
|
93
98
|
}, inputRef);
|
|
94
99
|
|
|
@@ -106,6 +111,8 @@ export function useSearchField(
|
|
|
106
111
|
preventFocusOnPress: true,
|
|
107
112
|
onPress: onClearButtonClick,
|
|
108
113
|
onPressStart
|
|
109
|
-
}
|
|
114
|
+
},
|
|
115
|
+
descriptionProps,
|
|
116
|
+
errorMessageProps
|
|
110
117
|
};
|
|
111
118
|
}
|