@react-types/shared 3.11.1 → 3.13.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.11.1",
3
+ "version": "3.13.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"
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": "404d41859b7d6f56201d7fc01bd9f22ae3512937"
17
+ "gitHead": "8f921ec5094e7c2b3c301bcb6133372e35a2052b"
18
18
  }
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,11 +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,
149
+ preview?: RefObject<DragPreviewRenderer>,
148
150
  getAllowedDropOperations?: () => DropOperation[]
149
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/events.d.ts CHANGED
@@ -133,6 +133,7 @@ export interface MoveMoveEvent extends BaseMoveEvent {
133
133
  deltaX: number,
134
134
  /** The amount moved in the Y direction since the last event. */
135
135
  deltaY: number
136
+
136
137
  }
137
138
 
138
139
  export interface MoveEndEvent extends BaseMoveEvent {
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';