@react-types/shared 3.11.2 → 3.13.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.11.2",
3
+ "version": "3.13.1",
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"
12
+ "react": "^16.8.0 || ^17.0.0-rc.1 || ^18.0.0"
13
13
  },
14
14
  "publishConfig": {
15
15
  "access": "public"
16
16
  },
17
- "gitHead": "ed8d8d984c2f7f2c31e8b18795b97858a95e4729"
17
+ "gitHead": "715c3f563ccf8c2e0102d3e18403d9db21a05a71"
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
@@ -10,7 +10,7 @@
10
10
  * governing permissions and limitations under the License.
11
11
  */
12
12
 
13
- import {Key} from 'react';
13
+ import {Key, RefObject} from 'react';
14
14
 
15
15
  export interface DragDropEvent {
16
16
  // Relative to the target element's position
@@ -139,12 +139,13 @@ interface DraggableCollectionEndEvent extends DragEndEvent {
139
139
  keys: Set<Key>
140
140
  }
141
141
 
142
+ export type DragPreviewRenderer = (items: DragItem[], callback: (node: HTMLElement) => void) => void;
143
+
142
144
  export interface DraggableCollectionProps {
143
145
  onDragStart?: (e: DraggableCollectionStartEvent) => void,
144
146
  onDragMove?: (e: DraggableCollectionMoveEvent) => void,
145
147
  onDragEnd?: (e: DraggableCollectionEndEvent) => void,
146
148
  getItems: (keys: Set<Key>) => DragItem[],
147
- renderPreview?: (selectedKeys: Set<Key>, draggedKey: Key) => JSX.Element,
148
- getAllowedDropOperations?: () => DropOperation[],
149
- allowsDraggingItem?: (key: Key) => boolean
149
+ preview?: RefObject<DragPreviewRenderer>,
150
+ getAllowedDropOperations?: () => DropOperation[]
150
151
  }
package/src/dom.d.ts CHANGED
@@ -66,9 +66,60 @@ export interface FocusableDOMProps extends DOMProps {
66
66
  excludeFromTabOrder?: boolean
67
67
  }
68
68
 
69
+
70
+ export interface TextInputDOMEvents {
71
+ // Clipboard events
72
+ /**
73
+ * Handler that is called when the user copies text. See [MDN](https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/oncopy).
74
+ */
75
+ onCopy?: ClipboardEventHandler<HTMLInputElement>,
76
+
77
+ /**
78
+ * Handler that is called when the user cuts text. See [MDN](https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/oncut).
79
+ */
80
+ onCut?: ClipboardEventHandler<HTMLInputElement>,
81
+
82
+ /**
83
+ * Handler that is called when the user pastes text. See [MDN](https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/onpaste).
84
+ */
85
+ onPaste?: ClipboardEventHandler<HTMLInputElement>,
86
+
87
+ // Composition events
88
+ /**
89
+ * Handler that is called when a text composition system starts a new text composition session. See [MDN](https://developer.mozilla.org/en-US/docs/Web/API/Element/compositionstart_event).
90
+ */
91
+ onCompositionStart?: CompositionEventHandler<HTMLInputElement>,
92
+
93
+ /**
94
+ * Handler that is called when a text composition system completes or cancels the current text composition session. See [MDN](https://developer.mozilla.org/en-US/docs/Web/API/Element/compositionend_event).
95
+ */
96
+ onCompositionEnd?: CompositionEventHandler<HTMLInputElement>,
97
+
98
+ /**
99
+ * Handler that is called when a new character is received in the current text composition session. See [MDN](https://developer.mozilla.org/en-US/docs/Web/API/Element/compositionupdate_event).
100
+ */
101
+ onCompositionUpdate?: CompositionEventHandler<HTMLInputElement>,
102
+
103
+ // Selection events
104
+ /**
105
+ * Handler that is called when text in the input is selected. See [MDN](https://developer.mozilla.org/en-US/docs/Web/API/Element/select_event).
106
+ */
107
+ onSelect?: ReactEventHandler<HTMLInputElement>,
108
+
109
+ // Input events
110
+ /**
111
+ * Handler that is called when the input value is about to be modified. See [MDN](https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/beforeinput_event).
112
+ */
113
+ onBeforeInput?: FormEventHandler<HTMLInputElement>,
114
+ /**
115
+ * Handler that is called when the input value is modified. See [MDN](https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/input_event).
116
+ */
117
+ onInput?: FormEventHandler<HTMLInputElement>
118
+ }
119
+
69
120
  // DOM props that apply to all text inputs
70
121
  // Ensure this is synced with useTextField
71
- export interface TextInputDOMProps extends DOMProps {
122
+ export interface TextInputDOMProps extends DOMProps, TextInputDOMEvents {
72
123
  /**
73
124
  * Describes the type of autocomplete functionality the input should provide if any. See [MDN](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input#htmlattrdefautocomplete).
74
125
  */
@@ -107,53 +158,5 @@ export interface TextInputDOMProps extends DOMProps {
107
158
  /**
108
159
  * Hints at the type of data that might be entered by the user while editing the element or its contents. See [MDN](https://html.spec.whatwg.org/multipage/interaction.html#input-modalities:-the-inputmode-attribute).
109
160
  */
110
- inputMode?: 'none' | 'text' | 'tel' | 'url' | 'email' | 'numeric' | 'decimal' | 'search',
111
-
112
- // Clipboard events
113
- /**
114
- * Handler that is called when the user copies text. See [MDN](https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/oncopy).
115
- */
116
- onCopy?: ClipboardEventHandler<HTMLInputElement>,
117
-
118
- /**
119
- * Handler that is called when the user cuts text. See [MDN](https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/oncut).
120
- */
121
- onCut?: ClipboardEventHandler<HTMLInputElement>,
122
-
123
- /**
124
- * Handler that is called when the user pastes text. See [MDN](https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/onpaste).
125
- */
126
- onPaste?: ClipboardEventHandler<HTMLInputElement>,
127
-
128
- // Composition events
129
- /**
130
- * Handler that is called when a text composition system starts a new text composition session. See [MDN](https://developer.mozilla.org/en-US/docs/Web/API/Element/compositionstart_event).
131
- */
132
- onCompositionStart?: CompositionEventHandler<HTMLInputElement>,
133
-
134
- /**
135
- * Handler that is called when a text composition system completes or cancels the current text composition session. See [MDN](https://developer.mozilla.org/en-US/docs/Web/API/Element/compositionend_event).
136
- */
137
- onCompositionEnd?: CompositionEventHandler<HTMLInputElement>,
138
-
139
- /**
140
- * Handler that is called when a new character is received in the current text composition session. See [MDN](https://developer.mozilla.org/en-US/docs/Web/API/Element/compositionupdate_event).
141
- */
142
- onCompositionUpdate?: CompositionEventHandler<HTMLInputElement>,
143
-
144
- // Selection events
145
- /**
146
- * Handler that is called when text in the input is selected. See [MDN](https://developer.mozilla.org/en-US/docs/Web/API/Element/select_event).
147
- */
148
- onSelect?: ReactEventHandler<HTMLInputElement>,
149
-
150
- // Input events
151
- /**
152
- * Handler that is called when the input value is about to be modified. See [MDN](https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/beforeinput_event).
153
- */
154
- onBeforeInput?: FormEventHandler<HTMLInputElement>,
155
- /**
156
- * Handler that is called when the input value is modified. See [MDN](https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/input_event).
157
- */
158
- onInput?: FormEventHandler<HTMLInputElement>
161
+ inputMode?: 'none' | 'text' | 'tel' | 'url' | 'email' | 'numeric' | 'decimal' | 'search'
159
162
  }
package/src/inputs.d.ts CHANGED
@@ -45,6 +45,15 @@ export interface TextInputBase {
45
45
  placeholder?: string
46
46
  }
47
47
 
48
+ export interface SpectrumTextInputBase {
49
+ /**
50
+ * Temporary text that occupies the text input when it is empty.
51
+ * Please use help text instead.
52
+ * @deprecated
53
+ **/
54
+ placeholder?: string
55
+ }
56
+
48
57
  export interface RangeValue<T> {
49
58
  /** The start value of the range. */
50
59
  start: T,
@@ -47,3 +47,4 @@ export interface SpectrumSelectionProps {
47
47
  }
48
48
 
49
49
  export type FocusStrategy = 'first' | 'last';
50
+ export type DisabledBehavior = 'selection' | 'all';