@react-types/shared 3.23.0 → 3.24.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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@react-types/shared",
3
- "version": "3.23.0",
3
+ "version": "3.24.0",
4
4
  "description": "Spectrum UI components in React",
5
5
  "license": "Apache-2.0",
6
6
  "types": "src/index.d.ts",
@@ -9,10 +9,10 @@
9
9
  "url": "https://github.com/adobe/react-spectrum"
10
10
  },
11
11
  "peerDependencies": {
12
- "react": "^16.8.0 || ^17.0.0-rc.1 || ^18.0.0"
12
+ "react": "^16.8.0 || ^17.0.0-rc.1 || ^18.0.0 || ^19.0.0"
13
13
  },
14
14
  "publishConfig": {
15
15
  "access": "public"
16
16
  },
17
- "gitHead": "f645f29edc1322153fd60af4640cbcab1d992dbd"
17
+ "gitHead": "86d80e3216bc32e75108831cf3a5a720bc849206"
18
18
  }
@@ -123,6 +123,28 @@ export interface KeyboardDelegate {
123
123
  getKeyForSearch?(search: string, fromKey?: Key): Key | null
124
124
  }
125
125
 
126
+ export interface Rect {
127
+ x: number,
128
+ y: number,
129
+ width: number,
130
+ height: number
131
+ }
132
+
133
+ export interface Size {
134
+ width: number,
135
+ height: number
136
+ }
137
+
138
+ /** A LayoutDelegate provides layout information for collection items. */
139
+ export interface LayoutDelegate {
140
+ /** Returns a rectangle for the item with the given key. */
141
+ getItemRect(key: Key): Rect | null,
142
+ /** Returns the visible rectangle of the collection. */
143
+ getVisibleRect(): Rect,
144
+ /** Returns the size of the scrollable content in the collection. */
145
+ getContentSize(): Size
146
+ }
147
+
126
148
  /**
127
149
  * A generic interface to access a readonly sequential
128
150
  * collection of unique keyed items.
@@ -194,5 +216,7 @@ export interface Node<T> {
194
216
  /** Additional properties specific to a particular node type. */
195
217
  props?: any,
196
218
  /** @private */
197
- shouldInvalidate?: (context: unknown) => boolean
219
+ shouldInvalidate?: (context: unknown) => boolean,
220
+ /** A function that renders this node to a React Element in the DOM. */
221
+ render?: (node: Node<any>) => ReactElement
198
222
  }
package/src/dnd.d.ts CHANGED
@@ -10,8 +10,7 @@
10
10
  * governing permissions and limitations under the License.
11
11
  */
12
12
 
13
- import {Key} from '@react-types/shared';
14
- import {RefObject} from 'react';
13
+ import {Key, RefObject} from '@react-types/shared';
15
14
 
16
15
  export interface DragDropEvent {
17
16
  /** The x coordinate of the event, relative to the target element. */
@@ -281,7 +280,7 @@ export interface DraggableCollectionProps {
281
280
  /** A function that returns the items being dragged. */
282
281
  getItems: (keys: Set<Key>) => DragItem[],
283
282
  /** The ref of the element that will be rendered as the drag preview while dragging. */
284
- preview?: RefObject<DragPreviewRenderer>,
283
+ preview?: RefObject<DragPreviewRenderer | null>,
285
284
  /** Function that returns the drop operations that are allowed for the dragged items. If not provided, all drop operations are allowed. */
286
285
  getAllowedDropOperations?: () => DropOperation[]
287
286
  }
package/src/events.d.ts CHANGED
@@ -45,6 +45,10 @@ export interface PressEvent {
45
45
  metaKey: boolean,
46
46
  /** Whether the alt keyboard modifier was held during the press event. */
47
47
  altKey: boolean,
48
+ /** X position relative to the target. */
49
+ x: number,
50
+ /** Y position relative to the target. */
51
+ y: number,
48
52
  /**
49
53
  * By default, press events stop propagation to parent elements.
50
54
  * In cases where a handler decides not to handle a specific event,
package/src/refs.d.ts CHANGED
@@ -10,7 +10,7 @@
10
10
  * governing permissions and limitations under the License.
11
11
  */
12
12
 
13
- import {Ref} from 'react';
13
+ import {ReactNode, Ref, RefAttributes} from 'react';
14
14
 
15
15
  export interface DOMRefValue<T extends HTMLElement = HTMLElement> {
16
16
  UNSAFE_getDOMNode(): T
@@ -22,3 +22,14 @@ export interface FocusableRefValue<T extends HTMLElement = HTMLElement, D extend
22
22
 
23
23
  export type DOMRef<T extends HTMLElement = HTMLElement> = Ref<DOMRefValue<T>>;
24
24
  export type FocusableRef<T extends HTMLElement = HTMLElement> = Ref<FocusableRefValue<T>>;
25
+
26
+ export interface RefObject<T> {
27
+ current: T
28
+ }
29
+
30
+ // Override forwardRef types so generics work.
31
+ declare function forwardRef<T, P = {}>(
32
+ render: (props: P, ref: Ref<T>) => ReactNode | null
33
+ ): (props: P & RefAttributes<T>) => ReactNode | null;
34
+
35
+ export type forwardRefType = typeof forwardRef;