@react-types/shared 3.18.1 → 3.20.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.18.1",
3
+ "version": "3.20.0",
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": "5911ed21de4b76d66f6254c02302519e02d50e16"
17
+ "gitHead": "54fbaa67cc56867506811819fef765546d403253"
18
18
  }
package/src/dom.d.ts CHANGED
@@ -121,9 +121,16 @@ export interface TextInputDOMEvents {
121
121
  onInput?: FormEventHandler<HTMLInputElement>
122
122
  }
123
123
 
124
+ export interface InputDOMProps {
125
+ /**
126
+ * The name of the input element, used when submitting an HTML form. See [MDN](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input#htmlattrdefname).
127
+ */
128
+ name?: string
129
+ }
130
+
124
131
  // DOM props that apply to all text inputs
125
132
  // Ensure this is synced with useTextField
126
- export interface TextInputDOMProps extends DOMProps, TextInputDOMEvents {
133
+ export interface TextInputDOMProps extends DOMProps, InputDOMProps, TextInputDOMEvents {
127
134
  /**
128
135
  * 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).
129
136
  */
@@ -139,11 +146,6 @@ export interface TextInputDOMProps extends DOMProps, TextInputDOMEvents {
139
146
  */
140
147
  minLength?: number,
141
148
 
142
- /**
143
- * The name of the input element, used when submitting an HTML form. See [MDN](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input#htmlattrdefname).
144
- */
145
- name?: string,
146
-
147
149
  /**
148
150
  * Regex pattern that the value of the input must match to be valid. See [MDN](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input#htmlattrdefpattern).
149
151
  */
package/src/events.d.ts CHANGED
@@ -44,10 +44,16 @@ export interface PressEvent {
44
44
  /** Whether the meta keyboard modifier was held during the press event. */
45
45
  metaKey: boolean,
46
46
  /** Whether the alt keyboard modifier was held during the press event. */
47
- altKey: boolean
47
+ altKey: boolean,
48
+ /**
49
+ * By default, press events stop propagation to parent elements.
50
+ * In cases where a handler decides not to handle a specific event,
51
+ * it can call `continuePropagation()` to allow a parent to handle it.
52
+ */
53
+ continuePropagation(): void
48
54
  }
49
55
 
50
- export interface LongPressEvent extends Omit<PressEvent, 'type'> {
56
+ export interface LongPressEvent extends Omit<PressEvent, 'type' | 'continuePropagation'> {
51
57
  /** The type of long press event being fired. */
52
58
  type: 'longpressstart' | 'longpressend' | 'longpress'
53
59
  }
package/src/inputs.d.ts CHANGED
@@ -15,13 +15,17 @@ import {ReactNode} from 'react';
15
15
  export type ValidationState = 'valid' | 'invalid';
16
16
 
17
17
  export interface Validation {
18
+ /** Whether user input is required on the input before form submission. */
19
+ isRequired?: boolean,
20
+ /** Whether the input value is invalid. */
21
+ isInvalid?: boolean,
22
+ /** @deprecated Use `isInvalid` instead. */
23
+ validationState?: ValidationState
24
+ }
25
+
26
+ export interface SpectrumFieldValidation extends Omit<Validation, 'isInvalid' | 'validationState'> {
18
27
  /** Whether the input should display its "valid" or "invalid" visual styling. */
19
- validationState?: ValidationState,
20
- /**
21
- * Whether user input is required on the input before form submission.
22
- * Often paired with the `necessityIndicator` prop to add a visual indicator to the input.
23
- */
24
- isRequired?: boolean
28
+ validationState?: ValidationState
25
29
  }
26
30
 
27
31
  export interface InputBase {
@@ -78,7 +82,7 @@ export interface HelpTextProps {
78
82
  }
79
83
 
80
84
  // Spectrum specific types. Extends `Validation` so that the `validationState` prop is available.
81
- export interface SpectrumHelpTextProps extends HelpTextProps, Validation {
85
+ export interface SpectrumHelpTextProps extends HelpTextProps {
82
86
  /** Whether the description is displayed with lighter text. */
83
87
  isDisabled?: boolean,
84
88
  /** Whether an error icon is rendered. */