@react-types/shared 3.24.1 → 3.26.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.24.1",
3
+ "version": "3.26.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 || ^19.0.0"
12
+ "react": "^16.8.0 || ^17.0.0-rc.1 || ^18.0.0 || ^19.0.0-rc.1"
13
13
  },
14
14
  "publishConfig": {
15
15
  "access": "public"
16
16
  },
17
- "gitHead": "f0aa6aacee60af265dc8994b9274ccf072a850aa"
17
+ "gitHead": "71f0ef23053f9e03ee7e97df736e8b083e006849"
18
18
  }
@@ -29,7 +29,7 @@ export interface ItemProps<T> extends LinkDOMProps {
29
29
  hasChildItems?: boolean
30
30
  }
31
31
 
32
- export type ItemElement<T> = ReactElement<ItemProps<T>>;
32
+ export type ItemElement<T> = ReactElement<ItemProps<T>> | null;
33
33
  export type ItemRenderer<T> = (item: T) => ItemElement<T>;
34
34
  export type LoadingState = 'loading' | 'sorting' | 'loadingMore' | 'error' | 'idle' | 'filtering';
35
35
 
@@ -51,7 +51,7 @@ export interface SectionProps<T> {
51
51
  items?: Iterable<T>
52
52
  }
53
53
 
54
- export type SectionElement<T> = ReactElement<SectionProps<T>>;
54
+ export type SectionElement<T> = ReactElement<SectionProps<T>> | null;
55
55
 
56
56
  export type CollectionElement<T> = SectionElement<T> | ItemElement<T>;
57
57
  export type CollectionChildren<T> = CollectionElement<T> | CollectionElement<T>[] | ((item: T) => CollectionElement<T>);
@@ -87,9 +87,9 @@ export interface Sortable {
87
87
 
88
88
  export interface SortDescriptor {
89
89
  /** The key of the column to sort by. */
90
- column?: Key,
90
+ column: Key,
91
91
  /** The direction to sort by. */
92
- direction?: SortDirection
92
+ direction: SortDirection
93
93
  }
94
94
 
95
95
  export type SortDirection = 'ascending' | 'descending';
@@ -114,13 +114,13 @@ export interface KeyboardDelegate {
114
114
  getKeyPageAbove?(key: Key): Key | null,
115
115
 
116
116
  /** Returns the first key, or `null` for none. */
117
- getFirstKey?(key?: Key, global?: boolean): Key | null,
117
+ getFirstKey?(key?: Key | null, global?: boolean): Key | null,
118
118
 
119
119
  /** Returns the last key, or `null` for none. */
120
- getLastKey?(key?: Key, global?: boolean): Key | null,
120
+ getLastKey?(key?: Key | null, global?: boolean): Key | null,
121
121
 
122
122
  /** Returns the next key after `fromKey` that matches the given search string, or `null` for none. */
123
- getKeyForSearch?(search: string, fromKey?: Key): Key | null
123
+ getKeyForSearch?(search: string, fromKey?: Key | null): Key | null
124
124
  }
125
125
 
126
126
  export interface Rect {
@@ -142,7 +142,9 @@ export interface LayoutDelegate {
142
142
  /** Returns the visible rectangle of the collection. */
143
143
  getVisibleRect(): Rect,
144
144
  /** Returns the size of the scrollable content in the collection. */
145
- getContentSize(): Size
145
+ getContentSize(): Size,
146
+ /** Returns a list of keys between `from` and `to`. */
147
+ getKeyRange?(from: Key, to: Key): Key[]
146
148
  }
147
149
 
148
150
  /**
@@ -204,7 +206,7 @@ export interface Node<T> {
204
206
  /** An accessibility label for this node. */
205
207
  'aria-label'?: string,
206
208
  /** The index of this node within its parent. */
207
- index?: number,
209
+ index: number,
208
210
  /** A function that should be called to wrap the rendered node. */
209
211
  wrapper?: (element: ReactElement) => ReactElement,
210
212
  /** The key of the parent node. */
@@ -216,7 +218,7 @@ export interface Node<T> {
216
218
  /** Additional properties specific to a particular node type. */
217
219
  props?: any,
218
220
  /** @private */
219
- shouldInvalidate?: (context: unknown) => boolean,
221
+ shouldInvalidate?: (context: any) => boolean,
220
222
  /** A function that renders this node to a React Element in the DOM. */
221
223
  render?: (node: Node<any>) => ReactElement
222
224
  }
package/src/dnd.d.ts CHANGED
@@ -268,7 +268,7 @@ export interface DraggableCollectionEndEvent extends DragEndEvent {
268
268
  isInternal: boolean
269
269
  }
270
270
 
271
- export type DragPreviewRenderer = (items: DragItem[], callback: (node: HTMLElement) => void) => void;
271
+ export type DragPreviewRenderer = (items: DragItem[], callback: (node: HTMLElement | null) => void) => void;
272
272
 
273
273
  export interface DraggableCollectionProps {
274
274
  /** Handler that is called when a drag operation is started. */
package/src/refs.d.ts CHANGED
@@ -13,7 +13,7 @@
13
13
  import {ReactElement, Ref, RefAttributes} from 'react';
14
14
 
15
15
  export interface DOMRefValue<T extends HTMLElement = HTMLElement> {
16
- UNSAFE_getDOMNode(): T
16
+ UNSAFE_getDOMNode(): T | null
17
17
  }
18
18
 
19
19
  export interface FocusableRefValue<T extends HTMLElement = HTMLElement, D extends HTMLElement = T> extends DOMRefValue<D> {