@react-types/shared 3.34.0 → 3.35.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 +9 -6
- package/src/collections.d.ts +85 -75
- package/src/dna.d.ts +9 -40
- package/src/dnd.d.ts +105 -84
- package/src/dom.d.ts +240 -188
- package/src/events.d.ts +54 -58
- package/src/inputs.d.ts +32 -27
- package/src/labelable.d.ts +9 -6
- package/src/refs.d.ts +10 -5
- package/src/removable.d.ts +2 -2
- package/src/selection.d.ts +11 -11
- package/src/style.d.ts +504 -180
package/package.json
CHANGED
|
@@ -1,18 +1,21 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@react-types/shared",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.35.0",
|
|
4
4
|
"description": "Spectrum UI components in React",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
|
-
"types": "src/index.d.ts",
|
|
7
6
|
"repository": {
|
|
8
7
|
"type": "git",
|
|
9
8
|
"url": "https://github.com/adobe/react-spectrum"
|
|
10
9
|
},
|
|
11
|
-
"
|
|
12
|
-
"react": "^16.8.0 || ^17.0.0-rc.1 || ^18.0.0 || ^19.0.0-rc.1"
|
|
13
|
-
},
|
|
10
|
+
"types": "src/index.d.ts",
|
|
14
11
|
"publishConfig": {
|
|
15
12
|
"access": "public"
|
|
16
13
|
},
|
|
17
|
-
"
|
|
14
|
+
"devDependencies": {
|
|
15
|
+
"react": "^16.8.0 || ^17.0.0-rc.1 || ^18.0.0 || ^19.0.0-rc.1"
|
|
16
|
+
},
|
|
17
|
+
"peerDependencies": {
|
|
18
|
+
"react": "^16.8.0 || ^17.0.0-rc.1 || ^18.0.0 || ^19.0.0-rc.1"
|
|
19
|
+
},
|
|
20
|
+
"gitHead": "3577a20859b9585a000010c720f6ee39c1c588cc"
|
|
18
21
|
}
|
package/src/collections.d.ts
CHANGED
|
@@ -16,17 +16,17 @@ import {ReactElement, ReactNode} from 'react';
|
|
|
16
16
|
|
|
17
17
|
export interface ItemProps<T> extends LinkDOMProps {
|
|
18
18
|
/** Rendered contents of the item or child items. */
|
|
19
|
-
children: ReactNode
|
|
19
|
+
children: ReactNode;
|
|
20
20
|
/** Rendered contents of the item if `children` contains child items. */
|
|
21
|
-
title?: ReactNode
|
|
21
|
+
title?: ReactNode; // label?? contents?
|
|
22
22
|
/** A string representation of the item's contents, used for features like typeahead. */
|
|
23
|
-
textValue?: string
|
|
23
|
+
textValue?: string;
|
|
24
24
|
/** An accessibility label for this item. */
|
|
25
|
-
'aria-label'?: string
|
|
25
|
+
'aria-label'?: string;
|
|
26
26
|
/** A list of child item objects. Used for dynamic collections. */
|
|
27
|
-
childItems?: Iterable<T
|
|
27
|
+
childItems?: Iterable<T>;
|
|
28
28
|
/** Whether this item has children, even if not loaded yet. */
|
|
29
|
-
hasChildItems?: boolean
|
|
29
|
+
hasChildItems?: boolean;
|
|
30
30
|
}
|
|
31
31
|
|
|
32
32
|
export type ItemElement<T> = ReactElement<ItemProps<T>> | null;
|
|
@@ -35,116 +35,125 @@ export type LoadingState = 'loading' | 'sorting' | 'loadingMore' | 'error' | 'id
|
|
|
35
35
|
|
|
36
36
|
export interface AsyncLoadable {
|
|
37
37
|
/** Whether the items are currently loading. */
|
|
38
|
-
isLoading?: boolean
|
|
38
|
+
isLoading?: boolean; // possibly isLoadingMore
|
|
39
39
|
/** Handler that is called when more items should be loaded, e.g. while scrolling near the bottom. */
|
|
40
|
-
onLoadMore?: () => any
|
|
40
|
+
onLoadMore?: () => any;
|
|
41
41
|
}
|
|
42
42
|
|
|
43
43
|
export interface SectionProps<T> {
|
|
44
44
|
/** Rendered contents of the section, e.g. a header. */
|
|
45
|
-
title?: ReactNode
|
|
45
|
+
title?: ReactNode;
|
|
46
46
|
/** An accessibility label for the section. */
|
|
47
|
-
'aria-label'?: string
|
|
47
|
+
'aria-label'?: string;
|
|
48
48
|
/** Static child items or a function to render children. */
|
|
49
|
-
children: ItemElement<T> | ItemElement<T>[] | ItemRenderer<T
|
|
49
|
+
children: ItemElement<T> | ItemElement<T>[] | ItemRenderer<T>;
|
|
50
50
|
/** Item objects in the section. */
|
|
51
|
-
items?: Iterable<T
|
|
51
|
+
items?: Iterable<T>;
|
|
52
52
|
}
|
|
53
53
|
|
|
54
54
|
export type SectionElement<T> = ReactElement<SectionProps<T>> | null;
|
|
55
55
|
|
|
56
56
|
export type CollectionElement<T> = SectionElement<T> | ItemElement<T>;
|
|
57
|
-
export type CollectionChildren<T> =
|
|
57
|
+
export type CollectionChildren<T> =
|
|
58
|
+
| CollectionElement<T>
|
|
59
|
+
| CollectionElement<T>[]
|
|
60
|
+
| ((item: T) => CollectionElement<T>);
|
|
58
61
|
export interface CollectionBase<T> {
|
|
59
62
|
/** The contents of the collection. */
|
|
60
|
-
children: CollectionChildren<T
|
|
63
|
+
children: CollectionChildren<T>;
|
|
61
64
|
/** Item objects in the collection. */
|
|
62
|
-
items?: Iterable<T
|
|
63
|
-
/**
|
|
64
|
-
|
|
65
|
+
items?: Iterable<T>;
|
|
66
|
+
/**
|
|
67
|
+
* The item keys that are disabled. These items cannot be selected, focused, or otherwise
|
|
68
|
+
* interacted with.
|
|
69
|
+
*/
|
|
70
|
+
disabledKeys?: Iterable<Key>;
|
|
65
71
|
}
|
|
66
72
|
|
|
67
|
-
export interface CollectionStateBase<
|
|
73
|
+
export interface CollectionStateBase<
|
|
74
|
+
T,
|
|
75
|
+
C extends Collection<Node<T>> = Collection<Node<T>>
|
|
76
|
+
> extends Partial<CollectionBase<T>> {
|
|
68
77
|
/** A pre-constructed collection to use instead of building one from items and children. */
|
|
69
|
-
collection?: C
|
|
78
|
+
collection?: C;
|
|
70
79
|
}
|
|
71
80
|
|
|
72
81
|
export interface Expandable {
|
|
73
82
|
/** The currently expanded keys in the collection (controlled). */
|
|
74
|
-
expandedKeys?: Iterable<Key
|
|
83
|
+
expandedKeys?: Iterable<Key>;
|
|
75
84
|
/** The initial expanded keys in the collection (uncontrolled). */
|
|
76
|
-
defaultExpandedKeys?: Iterable<Key
|
|
85
|
+
defaultExpandedKeys?: Iterable<Key>;
|
|
77
86
|
/** Handler that is called when items are expanded or collapsed. */
|
|
78
|
-
onExpandedChange?: (keys: Set<Key>) => any
|
|
87
|
+
onExpandedChange?: (keys: Set<Key>) => any;
|
|
79
88
|
}
|
|
80
89
|
|
|
81
90
|
export interface Sortable {
|
|
82
91
|
/** The current sorted column and direction. */
|
|
83
|
-
sortDescriptor?: SortDescriptor
|
|
92
|
+
sortDescriptor?: SortDescriptor;
|
|
84
93
|
/** Handler that is called when the sorted column or direction changes. */
|
|
85
|
-
onSortChange?: (descriptor: SortDescriptor) => any
|
|
94
|
+
onSortChange?: (descriptor: SortDescriptor) => any;
|
|
86
95
|
}
|
|
87
96
|
|
|
88
97
|
export interface SortDescriptor {
|
|
89
98
|
/** The key of the column to sort by. */
|
|
90
|
-
column: Key
|
|
99
|
+
column: Key;
|
|
91
100
|
/** The direction to sort by. */
|
|
92
|
-
direction: SortDirection
|
|
101
|
+
direction: SortDirection;
|
|
93
102
|
}
|
|
94
103
|
|
|
95
104
|
export type SortDirection = 'ascending' | 'descending';
|
|
96
105
|
|
|
97
106
|
export interface KeyboardDelegate {
|
|
98
107
|
/** Returns the key visually below the given one, or `null` for none. */
|
|
99
|
-
getKeyBelow?(key: Key): Key | null
|
|
108
|
+
getKeyBelow?(key: Key, options?: {includeDisabled?: boolean}): Key | null;
|
|
100
109
|
|
|
101
110
|
/** Returns the key visually above the given one, or `null` for none. */
|
|
102
|
-
getKeyAbove?(key: Key): Key | null
|
|
111
|
+
getKeyAbove?(key: Key, options?: {includeDisabled?: boolean}): Key | null;
|
|
103
112
|
|
|
104
113
|
/** Returns the key visually to the left of the given one, or `null` for none. */
|
|
105
|
-
getKeyLeftOf?(key: Key): Key | null
|
|
114
|
+
getKeyLeftOf?(key: Key, options?: {includeDisabled?: boolean}): Key | null;
|
|
106
115
|
|
|
107
116
|
/** Returns the key visually to the right of the given one, or `null` for none. */
|
|
108
|
-
getKeyRightOf?(key: Key): Key | null
|
|
117
|
+
getKeyRightOf?(key: Key, options?: {includeDisabled?: boolean}): Key | null;
|
|
109
118
|
|
|
110
119
|
/** Returns the key visually one page below the given one, or `null` for none. */
|
|
111
|
-
getKeyPageBelow?(key: Key): Key | null
|
|
120
|
+
getKeyPageBelow?(key: Key): Key | null;
|
|
112
121
|
|
|
113
122
|
/** Returns the key visually one page above the given one, or `null` for none. */
|
|
114
|
-
getKeyPageAbove?(key: Key): Key | null
|
|
123
|
+
getKeyPageAbove?(key: Key): Key | null;
|
|
115
124
|
|
|
116
125
|
/** Returns the first key, or `null` for none. */
|
|
117
|
-
getFirstKey?(key?: Key | null, global?: boolean): Key | null
|
|
126
|
+
getFirstKey?(key?: Key | null, global?: boolean): Key | null;
|
|
118
127
|
|
|
119
128
|
/** Returns the last key, or `null` for none. */
|
|
120
|
-
getLastKey?(key?: Key | null, global?: boolean): Key | null
|
|
129
|
+
getLastKey?(key?: Key | null, global?: boolean): Key | null;
|
|
121
130
|
|
|
122
131
|
/** Returns the next key after `fromKey` that matches the given search string, or `null` for none. */
|
|
123
|
-
getKeyForSearch?(search: string, fromKey?: Key | null): Key | null
|
|
132
|
+
getKeyForSearch?(search: string, fromKey?: Key | null): Key | null;
|
|
124
133
|
}
|
|
125
134
|
|
|
126
135
|
export interface Rect {
|
|
127
|
-
x: number
|
|
128
|
-
y: number
|
|
129
|
-
width: number
|
|
130
|
-
height: number
|
|
136
|
+
x: number;
|
|
137
|
+
y: number;
|
|
138
|
+
width: number;
|
|
139
|
+
height: number;
|
|
131
140
|
}
|
|
132
141
|
|
|
133
142
|
export interface Size {
|
|
134
|
-
width: number
|
|
135
|
-
height: number
|
|
143
|
+
width: number;
|
|
144
|
+
height: number;
|
|
136
145
|
}
|
|
137
146
|
|
|
138
147
|
/** A LayoutDelegate provides layout information for collection items. */
|
|
139
148
|
export interface LayoutDelegate {
|
|
140
149
|
/** Returns a rectangle for the item with the given key. */
|
|
141
|
-
getItemRect(key: Key): Rect | null
|
|
150
|
+
getItemRect(key: Key): Rect | null;
|
|
142
151
|
/** Returns the visible rectangle of the collection. */
|
|
143
|
-
getVisibleRect(): Rect
|
|
152
|
+
getVisibleRect(): Rect;
|
|
144
153
|
/** Returns the size of the scrollable content in the collection. */
|
|
145
|
-
getContentSize(): Size
|
|
154
|
+
getContentSize(): Size;
|
|
146
155
|
/** Returns a list of keys between `from` and `to`. */
|
|
147
|
-
getKeyRange?(from: Key, to: Key): Key[]
|
|
156
|
+
getKeyRange?(from: Key, to: Key): Key[];
|
|
148
157
|
}
|
|
149
158
|
|
|
150
159
|
/**
|
|
@@ -153,79 +162,80 @@ export interface LayoutDelegate {
|
|
|
153
162
|
*/
|
|
154
163
|
export interface Collection<T> extends Iterable<T> {
|
|
155
164
|
/** The number of items in the collection. */
|
|
156
|
-
readonly size: number
|
|
165
|
+
readonly size: number;
|
|
157
166
|
|
|
158
167
|
/** Iterate over all keys in the collection. */
|
|
159
|
-
getKeys(): Iterable<Key
|
|
168
|
+
getKeys(): Iterable<Key>;
|
|
160
169
|
|
|
161
170
|
/** Get an item by its key. */
|
|
162
|
-
getItem(key: Key): T | null
|
|
171
|
+
getItem(key: Key): T | null;
|
|
163
172
|
|
|
164
173
|
/** Get an item by the index of its key. */
|
|
165
|
-
at(idx: number): T | null
|
|
174
|
+
at(idx: number): T | null;
|
|
166
175
|
|
|
167
176
|
/** Get the key that comes before the given key in the collection. */
|
|
168
|
-
getKeyBefore(key: Key): Key | null
|
|
177
|
+
getKeyBefore(key: Key): Key | null;
|
|
169
178
|
|
|
170
179
|
/** Get the key that comes after the given key in the collection. */
|
|
171
|
-
getKeyAfter(key: Key): Key | null
|
|
180
|
+
getKeyAfter(key: Key): Key | null;
|
|
172
181
|
|
|
173
182
|
/** Get the first key in the collection. */
|
|
174
|
-
getFirstKey(): Key | null
|
|
183
|
+
getFirstKey(): Key | null;
|
|
175
184
|
|
|
176
185
|
/** Get the last key in the collection. */
|
|
177
|
-
getLastKey(): Key | null
|
|
186
|
+
getLastKey(): Key | null;
|
|
178
187
|
|
|
179
188
|
/** Iterate over the child items of the given key. */
|
|
180
|
-
getChildren?(key: Key): Iterable<T
|
|
189
|
+
getChildren?(key: Key): Iterable<T>;
|
|
181
190
|
|
|
182
191
|
/** Returns a string representation of the item's contents. */
|
|
183
|
-
getTextValue?(key: Key): string
|
|
192
|
+
getTextValue?(key: Key): string;
|
|
184
193
|
|
|
185
194
|
/** Filters the collection using the given function. */
|
|
186
|
-
filter?(filterFn: (nodeValue: string, node: T) => boolean): Collection<T
|
|
195
|
+
filter?(filterFn: (nodeValue: string, node: T) => boolean): Collection<T>;
|
|
187
196
|
}
|
|
188
197
|
|
|
189
198
|
export interface Node<T> {
|
|
190
199
|
/** The type of item this node represents. */
|
|
191
|
-
type: string
|
|
200
|
+
type: string;
|
|
192
201
|
/** A unique key for the node. */
|
|
193
|
-
key: Key
|
|
202
|
+
key: Key;
|
|
194
203
|
/** The object value the node was created from. */
|
|
195
|
-
value: T | null
|
|
204
|
+
value: T | null;
|
|
196
205
|
/** The level of depth this node is at in the hierarchy. */
|
|
197
|
-
level: number
|
|
206
|
+
level: number;
|
|
198
207
|
/** Whether this item has children, even if not loaded yet. */
|
|
199
|
-
hasChildNodes: boolean
|
|
208
|
+
hasChildNodes: boolean;
|
|
200
209
|
/**
|
|
201
210
|
* The loaded children of this node.
|
|
211
|
+
*
|
|
202
212
|
* @deprecated Use `collection.getChildren(node.key)` instead.
|
|
203
213
|
*/
|
|
204
|
-
childNodes: Iterable<Node<T
|
|
214
|
+
childNodes: Iterable<Node<T>>;
|
|
205
215
|
/** The rendered contents of this node (e.g. JSX). */
|
|
206
|
-
rendered: ReactNode
|
|
216
|
+
rendered: ReactNode;
|
|
207
217
|
/** A string value for this node, used for features like typeahead. */
|
|
208
|
-
textValue: string
|
|
218
|
+
textValue: string;
|
|
209
219
|
/** An accessibility label for this node. */
|
|
210
|
-
'aria-label'?: string
|
|
220
|
+
'aria-label'?: string;
|
|
211
221
|
/** The index of this node within its parent. */
|
|
212
|
-
index: number
|
|
222
|
+
index: number;
|
|
213
223
|
/** A function that should be called to wrap the rendered node. */
|
|
214
|
-
wrapper?: (element: ReactElement) => ReactElement
|
|
224
|
+
wrapper?: (element: ReactElement) => ReactElement;
|
|
215
225
|
/** The key of the parent node. */
|
|
216
|
-
parentKey?: Key | null
|
|
226
|
+
parentKey?: Key | null;
|
|
217
227
|
/** The key of the node before this node. */
|
|
218
|
-
prevKey?: Key | null
|
|
228
|
+
prevKey?: Key | null;
|
|
219
229
|
/** The key of the node after this node. */
|
|
220
|
-
nextKey?: Key | null
|
|
230
|
+
nextKey?: Key | null;
|
|
221
231
|
/** The first child key of this node. */
|
|
222
|
-
firstChildKey?: Key | null
|
|
232
|
+
firstChildKey?: Key | null;
|
|
223
233
|
/** The last child key of this node. */
|
|
224
|
-
lastChildKey?: Key | null
|
|
234
|
+
lastChildKey?: Key | null;
|
|
225
235
|
/** Additional properties specific to a particular node type. */
|
|
226
|
-
props?: any
|
|
236
|
+
props?: any;
|
|
227
237
|
/** @private */
|
|
228
|
-
shouldInvalidate?: (context: any) => boolean
|
|
238
|
+
shouldInvalidate?: (context: any) => boolean;
|
|
229
239
|
/** A function that renders this node to a React Element in the DOM. */
|
|
230
|
-
render?: (node: Node<any>) => ReactElement
|
|
240
|
+
render?: (node: Node<any>) => ReactElement;
|
|
231
241
|
}
|
package/src/dna.d.ts
CHANGED
|
@@ -435,11 +435,7 @@ export type ColorValueV6 =
|
|
|
435
435
|
| 'magenta-1400'
|
|
436
436
|
| SemanticColorValue;
|
|
437
437
|
|
|
438
|
-
type SemanticColorValue =
|
|
439
|
-
| 'negative'
|
|
440
|
-
| 'notice'
|
|
441
|
-
| 'positive'
|
|
442
|
-
| 'informative';
|
|
438
|
+
type SemanticColorValue = 'negative' | 'notice' | 'positive' | 'informative';
|
|
443
439
|
|
|
444
440
|
type BorderColorAlias =
|
|
445
441
|
| 'negative'
|
|
@@ -459,45 +455,18 @@ type BorderColorAlias =
|
|
|
459
455
|
| 'translucent-dark'
|
|
460
456
|
| 'translucent-darker';
|
|
461
457
|
|
|
462
|
-
type BackgroundColorAlias =
|
|
463
|
-
| 'default'
|
|
464
|
-
| 'disabled'
|
|
465
|
-
| 'transparent'
|
|
466
|
-
| 'label-gray';
|
|
458
|
+
type BackgroundColorAlias = 'default' | 'disabled' | 'transparent' | 'label-gray';
|
|
467
459
|
|
|
468
|
-
export type IconColorValue =
|
|
469
|
-
| 'negative'
|
|
470
|
-
| 'notice'
|
|
471
|
-
| 'positive'
|
|
472
|
-
| 'informative';
|
|
460
|
+
export type IconColorValue = 'negative' | 'notice' | 'positive' | 'informative';
|
|
473
461
|
|
|
474
|
-
export type BorderSizeValue =
|
|
475
|
-
| 'thin'
|
|
476
|
-
| 'thick'
|
|
477
|
-
| 'thicker'
|
|
478
|
-
| 'thickest'
|
|
479
|
-
| 'none';
|
|
462
|
+
export type BorderSizeValue = 'thin' | 'thick' | 'thicker' | 'thickest' | 'none';
|
|
480
463
|
|
|
481
|
-
export type BorderRadiusValue =
|
|
482
|
-
| 'xsmall'
|
|
483
|
-
| 'small'
|
|
484
|
-
| 'regular'
|
|
485
|
-
| 'medium'
|
|
486
|
-
| 'large';
|
|
464
|
+
export type BorderRadiusValue = 'xsmall' | 'small' | 'regular' | 'medium' | 'large';
|
|
487
465
|
|
|
488
|
-
export type BorderColorValue =
|
|
489
|
-
| 'default'
|
|
490
|
-
| BorderColorAlias
|
|
491
|
-
| ColorValue;
|
|
466
|
+
export type BorderColorValue = 'default' | BorderColorAlias | ColorValue;
|
|
492
467
|
|
|
493
|
-
export type BorderColorValueV6 =
|
|
494
|
-
| BorderColorAlias
|
|
495
|
-
| ColorValueV6;
|
|
468
|
+
export type BorderColorValueV6 = BorderColorAlias | ColorValueV6;
|
|
496
469
|
|
|
497
|
-
export type BackgroundColorValue =
|
|
498
|
-
| BackgroundColorAlias
|
|
499
|
-
| ColorValue;
|
|
470
|
+
export type BackgroundColorValue = BackgroundColorAlias | ColorValue;
|
|
500
471
|
|
|
501
|
-
export type BackgroundColorValueV6 =
|
|
502
|
-
| BackgroundColorAlias
|
|
503
|
-
| ColorValueV6;
|
|
472
|
+
export type BackgroundColorValueV6 = BackgroundColorAlias | ColorValueV6;
|