@react-types/shared 3.13.0 → 3.14.1

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.13.0",
3
+ "version": "3.14.1",
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": "8f921ec5094e7c2b3c301bcb6133372e35a2052b"
17
+ "gitHead": "b03ef51e6317547dd0a840f151e59d039b1e1fd3"
18
18
  }
@@ -89,31 +89,31 @@ export type SortDirection = 'ascending' | 'descending';
89
89
 
90
90
  export interface KeyboardDelegate {
91
91
  /** Returns the key visually below the given one, or `null` for none. */
92
- getKeyBelow?(key: Key): Key,
92
+ getKeyBelow?(key: Key): Key | null,
93
93
 
94
94
  /** Returns the key visually above the given one, or `null` for none. */
95
- getKeyAbove?(key: Key): Key,
95
+ getKeyAbove?(key: Key): Key | null,
96
96
 
97
97
  /** Returns the key visually to the left of the given one, or `null` for none. */
98
- getKeyLeftOf?(key: Key): Key,
98
+ getKeyLeftOf?(key: Key): Key | null,
99
99
 
100
100
  /** Returns the key visually to the right of the given one, or `null` for none. */
101
- getKeyRightOf?(key: Key): Key,
101
+ getKeyRightOf?(key: Key): Key | null,
102
102
 
103
103
  /** Returns the key visually one page below the given one, or `null` for none. */
104
- getKeyPageBelow?(key: Key): Key,
104
+ getKeyPageBelow?(key: Key): Key | null,
105
105
 
106
106
  /** Returns the key visually one page above the given one, or `null` for none. */
107
- getKeyPageAbove?(key: Key): Key,
107
+ getKeyPageAbove?(key: Key): Key | null,
108
108
 
109
109
  /** Returns the first key, or `null` for none. */
110
- getFirstKey?(key?: Key, global?: boolean): Key,
110
+ getFirstKey?(key?: Key, global?: boolean): Key | null,
111
111
 
112
112
  /** Returns the last key, or `null` for none. */
113
- getLastKey?(key?: Key, global?: boolean): Key,
113
+ getLastKey?(key?: Key, global?: boolean): Key | null,
114
114
 
115
115
  /** Returns the next key after `fromKey` that matches the given search string, or `null` for none. */
116
- getKeyForSearch?(search: string, fromKey?: Key): Key
116
+ getKeyForSearch?(search: string, fromKey?: Key): Key | null
117
117
  }
118
118
 
119
119
  /**
package/src/dnd.d.ts CHANGED
@@ -118,12 +118,30 @@ export interface DragTypes {
118
118
  has(type: string): boolean
119
119
  }
120
120
 
121
+ export interface DropTargetDelegate {
122
+ /**
123
+ * Returns a drop target within a collection for the given x and y coordinates.
124
+ * The point is provided relative to the top left corner of the collection container.
125
+ * A drop target can be checked to see if it is valid using the provided `isValidDropTarget` function.
126
+ */
127
+ getDropTargetFromPoint(x: number, y: number, isValidDropTarget: (target: DropTarget) => boolean): DropTarget | null
128
+ }
129
+
121
130
  export interface DroppableCollectionProps {
131
+ /**
132
+ * A function returning the drop operation to be performed when items matching the given types are dropped
133
+ * on the drop target.
134
+ */
122
135
  getDropOperation?: (target: DropTarget, types: DragTypes, allowedOperations: DropOperation[]) => DropOperation,
136
+ /** Handler that is called when a valid drag enters the drop target. */
123
137
  onDropEnter?: (e: DroppableCollectionEnterEvent) => void,
138
+ /** Handler that is called when a valid drag is moved within the drop target. */
124
139
  onDropMove?: (e: DroppableCollectionMoveEvent) => void,
140
+ /** Handler that is called after a valid drag is held over the drop target for a period of time. */
125
141
  onDropActivate?: (e: DroppableCollectionActivateEvent) => void,
142
+ /** Handler that is called when a valid drag exits the drop target. */
126
143
  onDropExit?: (e: DroppableCollectionExitEvent) => void,
144
+ /** Handler that is called when a valid drag is dropped on the drop target. */
127
145
  onDrop?: (e: DroppableCollectionDropEvent) => void
128
146
  }
129
147
 
@@ -142,10 +160,16 @@ interface DraggableCollectionEndEvent extends DragEndEvent {
142
160
  export type DragPreviewRenderer = (items: DragItem[], callback: (node: HTMLElement) => void) => void;
143
161
 
144
162
  export interface DraggableCollectionProps {
163
+ /** Handler that is called when a drag operation is started. */
145
164
  onDragStart?: (e: DraggableCollectionStartEvent) => void,
165
+ /** Handler that is called when the dragged element is moved. */
146
166
  onDragMove?: (e: DraggableCollectionMoveEvent) => void,
167
+ /** Handler that is called when the drag operation is ended, either as a result of a drop or a cancellation. */
147
168
  onDragEnd?: (e: DraggableCollectionEndEvent) => void,
169
+ /** A function that returns the items being dragged. */
148
170
  getItems: (keys: Set<Key>) => DragItem[],
171
+ /** The ref of the element that will be rendered as the drag preview while dragging. */
149
172
  preview?: RefObject<DragPreviewRenderer>,
173
+ /** Function that returns the drop operations that are allowed for the dragged items. If not provided, all drop operations are allowed. */
150
174
  getAllowedDropOperations?: () => DropOperation[]
151
175
  }
package/src/dom.d.ts CHANGED
@@ -11,9 +11,13 @@
11
11
  */
12
12
 
13
13
  import {
14
+ AriaAttributes,
15
+ AriaRole,
14
16
  ClipboardEventHandler,
15
17
  CompositionEventHandler,
18
+ CSSProperties,
16
19
  FormEventHandler,
20
+ DOMAttributes as ReactDOMAttributes,
17
21
  ReactEventHandler
18
22
  } from 'react';
19
23
 
@@ -160,3 +164,15 @@ export interface TextInputDOMProps extends DOMProps, TextInputDOMEvents {
160
164
  */
161
165
  inputMode?: 'none' | 'text' | 'tel' | 'url' | 'email' | 'numeric' | 'decimal' | 'search'
162
166
  }
167
+
168
+ /** Any focusable element, including both HTML and SVG elements. */
169
+ export interface FocusableElement extends Element, HTMLOrSVGElement {}
170
+
171
+ /** All DOM attributes supported across both HTML and SVG elements. */
172
+ export interface DOMAttributes<T = FocusableElement> extends AriaAttributes, ReactDOMAttributes<T> {
173
+ id?: string | undefined,
174
+ role?: AriaRole | undefined,
175
+ tabIndex?: number | undefined,
176
+ style?: CSSProperties | undefined,
177
+ className?: string | undefined
178
+ }
package/src/events.d.ts CHANGED
@@ -34,7 +34,7 @@ export interface PressEvent {
34
34
  /** The pointer type that triggered the press event. */
35
35
  pointerType: PointerType,
36
36
  /** The target element of the press event. */
37
- target: HTMLElement,
37
+ target: Element,
38
38
  /** Whether the shift keyboard modifier was held during the press event. */
39
39
  shiftKey: boolean,
40
40
  /** Whether the ctrl keyboard modifier was held during the press event. */