@react-types/shared 3.20.0 → 3.22.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/package.json +2 -2
- package/src/collections.d.ts +4 -2
- package/src/dna.d.ts +2 -1
- package/src/dnd.d.ts +2 -1
- package/src/dom.d.ts +22 -0
- package/src/index.d.ts +1 -0
- package/src/inputs.d.ts +31 -4
- package/src/key.d.ts +13 -0
- package/src/selection.d.ts +1 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@react-types/shared",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.22.0",
|
|
4
4
|
"description": "Spectrum UI components in React",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"types": "src/index.d.ts",
|
|
@@ -14,5 +14,5 @@
|
|
|
14
14
|
"publishConfig": {
|
|
15
15
|
"access": "public"
|
|
16
16
|
},
|
|
17
|
-
"gitHead": "
|
|
17
|
+
"gitHead": "9ce2f674eab2cc8912800d3162dcf00a1ce94274"
|
|
18
18
|
}
|
package/src/collections.d.ts
CHANGED
|
@@ -10,9 +10,11 @@
|
|
|
10
10
|
* governing permissions and limitations under the License.
|
|
11
11
|
*/
|
|
12
12
|
|
|
13
|
-
import {Key
|
|
13
|
+
import {Key} from '@react-types/shared';
|
|
14
|
+
import {LinkDOMProps} from './dom';
|
|
15
|
+
import {ReactElement, ReactNode} from 'react';
|
|
14
16
|
|
|
15
|
-
export interface ItemProps<T> {
|
|
17
|
+
export interface ItemProps<T> extends LinkDOMProps {
|
|
16
18
|
/** Rendered contents of the item or child items. */
|
|
17
19
|
children: ReactNode,
|
|
18
20
|
/** Rendered contents of the item if `children` contains child items. */
|
package/src/dna.d.ts
CHANGED
package/src/dnd.d.ts
CHANGED
|
@@ -10,7 +10,8 @@
|
|
|
10
10
|
* governing permissions and limitations under the License.
|
|
11
11
|
*/
|
|
12
12
|
|
|
13
|
-
import {Key
|
|
13
|
+
import {Key} from '@react-types/shared';
|
|
14
|
+
import {RefObject} from 'react';
|
|
14
15
|
|
|
15
16
|
export interface DragDropEvent {
|
|
16
17
|
/** The x coordinate of the event, relative to the target element. */
|
package/src/dom.d.ts
CHANGED
|
@@ -17,6 +17,8 @@ import {
|
|
|
17
17
|
CompositionEventHandler,
|
|
18
18
|
CSSProperties,
|
|
19
19
|
FormEventHandler,
|
|
20
|
+
HTMLAttributeAnchorTarget,
|
|
21
|
+
HTMLAttributeReferrerPolicy,
|
|
20
22
|
DOMAttributes as ReactDOMAttributes,
|
|
21
23
|
ReactEventHandler
|
|
22
24
|
} from 'react';
|
|
@@ -167,6 +169,22 @@ export interface TextInputDOMProps extends DOMProps, InputDOMProps, TextInputDOM
|
|
|
167
169
|
inputMode?: 'none' | 'text' | 'tel' | 'url' | 'email' | 'numeric' | 'decimal' | 'search'
|
|
168
170
|
}
|
|
169
171
|
|
|
172
|
+
// Make sure to update filterDOMProps.ts when updating this.
|
|
173
|
+
export interface LinkDOMProps {
|
|
174
|
+
/** A URL to link to. See [MDN](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/a#href). */
|
|
175
|
+
href?: string,
|
|
176
|
+
/** The target window for the link. See [MDN](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/a#target). */
|
|
177
|
+
target?: HTMLAttributeAnchorTarget,
|
|
178
|
+
/** The relationship between the linked resource and the current page. See [MDN](https://developer.mozilla.org/en-US/docs/Web/HTML/Attributes/rel). */
|
|
179
|
+
rel?: string,
|
|
180
|
+
/** Causes the browser to download the linked URL. A string may be provided to suggest a file name. See [MDN](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/a#download). */
|
|
181
|
+
download?: boolean | string,
|
|
182
|
+
/** A space-separated list of URLs to ping when the link is followed. See [MDN](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/a#ping). */
|
|
183
|
+
ping?: string,
|
|
184
|
+
/** How much of the referrer to send when following the link. See [MDN](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/a#referrerpolicy). */
|
|
185
|
+
referrerPolicy?: HTMLAttributeReferrerPolicy
|
|
186
|
+
}
|
|
187
|
+
|
|
170
188
|
/** Any focusable element, including both HTML and SVG elements. */
|
|
171
189
|
export interface FocusableElement extends Element, HTMLOrSVGElement {}
|
|
172
190
|
|
|
@@ -178,3 +196,7 @@ export interface DOMAttributes<T = FocusableElement> extends AriaAttributes, Rea
|
|
|
178
196
|
style?: CSSProperties | undefined,
|
|
179
197
|
className?: string | undefined
|
|
180
198
|
}
|
|
199
|
+
|
|
200
|
+
export interface GroupDOMAttributes extends Omit<DOMAttributes<HTMLElement>, 'role'> {
|
|
201
|
+
role?: 'group' | 'region' | 'presentation'
|
|
202
|
+
}
|
package/src/index.d.ts
CHANGED
package/src/inputs.d.ts
CHANGED
|
@@ -14,16 +14,43 @@ import {ReactNode} from 'react';
|
|
|
14
14
|
|
|
15
15
|
export type ValidationState = 'valid' | 'invalid';
|
|
16
16
|
|
|
17
|
-
export
|
|
17
|
+
export type ValidationError = string | string[];
|
|
18
|
+
export type ValidationErrors = Record<string, ValidationError>;
|
|
19
|
+
export type ValidationFunction<T> = (value: T) => ValidationError | true | null | undefined;
|
|
20
|
+
|
|
21
|
+
export interface Validation<T> {
|
|
18
22
|
/** Whether user input is required on the input before form submission. */
|
|
19
23
|
isRequired?: boolean,
|
|
20
24
|
/** Whether the input value is invalid. */
|
|
21
25
|
isInvalid?: boolean,
|
|
22
26
|
/** @deprecated Use `isInvalid` instead. */
|
|
23
|
-
validationState?: ValidationState
|
|
27
|
+
validationState?: ValidationState,
|
|
28
|
+
/**
|
|
29
|
+
* Whether to use native HTML form validation to prevent form submission
|
|
30
|
+
* when the value is missing or invalid, or mark the field as required
|
|
31
|
+
* or invalid via ARIA.
|
|
32
|
+
* @default 'aria'
|
|
33
|
+
*/
|
|
34
|
+
validationBehavior?: 'aria' | 'native',
|
|
35
|
+
/**
|
|
36
|
+
* A function that returns an error message if a given value is invalid.
|
|
37
|
+
* Validation errors are displayed to the user when the form is submitted
|
|
38
|
+
* if `validationBehavior="native"`. For realtime validation, use the `isInvalid`
|
|
39
|
+
* prop instead.
|
|
40
|
+
*/
|
|
41
|
+
validate?: (value: T) => ValidationError | true | null | undefined
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
export interface ValidationResult {
|
|
45
|
+
/** Whether the input value is invalid. */
|
|
46
|
+
isInvalid: boolean,
|
|
47
|
+
/** The current error messages for the input if it is invalid, otherwise an empty array. */
|
|
48
|
+
validationErrors: string[],
|
|
49
|
+
/** The native validation details for the input. */
|
|
50
|
+
validationDetails: ValidityState
|
|
24
51
|
}
|
|
25
52
|
|
|
26
|
-
export interface SpectrumFieldValidation extends Omit<Validation
|
|
53
|
+
export interface SpectrumFieldValidation<T> extends Omit<Validation<T>, 'isInvalid' | 'validationState'> {
|
|
27
54
|
/** Whether the input should display its "valid" or "invalid" visual styling. */
|
|
28
55
|
validationState?: ValidationState
|
|
29
56
|
}
|
|
@@ -78,7 +105,7 @@ export interface HelpTextProps {
|
|
|
78
105
|
/** A description for the field. Provides a hint such as specific requirements for what to choose. */
|
|
79
106
|
description?: ReactNode,
|
|
80
107
|
/** An error message for the field. */
|
|
81
|
-
errorMessage?: ReactNode
|
|
108
|
+
errorMessage?: ReactNode | ((v: ValidationResult) => ReactNode)
|
|
82
109
|
}
|
|
83
110
|
|
|
84
111
|
// Spectrum specific types. Extends `Validation` so that the `validationState` prop is available.
|
package/src/key.d.ts
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright 2023 Adobe. All rights reserved.
|
|
3
|
+
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
4
|
+
* you may not use this file except in compliance with the License. You may obtain a copy
|
|
5
|
+
* of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
6
|
+
*
|
|
7
|
+
* Unless required by applicable law or agreed to in writing, software distributed under
|
|
8
|
+
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
9
|
+
* OF ANY KIND, either express or implied. See the License for the specific language
|
|
10
|
+
* governing permissions and limitations under the License.
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
export type Key = string | number;
|
package/src/selection.d.ts
CHANGED