@react-types/select 3.10.0 → 3.11.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.
Files changed (2) hide show
  1. package/package.json +3 -3
  2. package/src/index.d.ts +29 -4
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@react-types/select",
3
- "version": "3.10.0",
3
+ "version": "3.11.0",
4
4
  "description": "Spectrum UI components in React",
5
5
  "license": "Apache-2.0",
6
6
  "types": "src/index.d.ts",
@@ -9,7 +9,7 @@
9
9
  "url": "https://github.com/adobe/react-spectrum"
10
10
  },
11
11
  "dependencies": {
12
- "@react-types/shared": "^3.31.0"
12
+ "@react-types/shared": "^3.32.1"
13
13
  },
14
14
  "peerDependencies": {
15
15
  "react": "^16.8.0 || ^17.0.0-rc.1 || ^18.0.0 || ^19.0.0-rc.1"
@@ -17,5 +17,5 @@
17
17
  "publishConfig": {
18
18
  "access": "public"
19
19
  },
20
- "gitHead": "8b9348ff255e018b2dd9b27e2a45507cadfa1d35"
20
+ "gitHead": "0bda51183baa23306342af32a82012ea0fe0f2dc"
21
21
  }
package/src/index.d.ts CHANGED
@@ -27,10 +27,35 @@ import {
27
27
  SpectrumLabelableProps,
28
28
  StyleProps,
29
29
  TextInputBase,
30
- Validation
30
+ Validation,
31
+ ValueBase
31
32
  } from '@react-types/shared';
32
33
 
33
- export interface SelectProps<T> extends CollectionBase<T>, Omit<InputBase, 'isReadOnly'>, Validation<Key>, HelpTextProps, LabelableProps, TextInputBase, Omit<SingleSelection, 'disallowEmptySelection'>, FocusableProps {
34
+ export type SelectionMode = 'single' | 'multiple';
35
+ export type ValueType<M extends SelectionMode> = M extends 'single' ? Key | null : Key[];
36
+ type ValidationType<M extends SelectionMode> = M extends 'single' ? Key : Key[];
37
+
38
+ export interface SelectProps<T, M extends SelectionMode = 'single'> extends CollectionBase<T>, Omit<InputBase, 'isReadOnly'>, ValueBase<ValueType<M>>, Validation<ValidationType<M>>, HelpTextProps, LabelableProps, TextInputBase, FocusableProps {
39
+ /**
40
+ * Whether single or multiple selection is enabled.
41
+ * @default 'single'
42
+ */
43
+ selectionMode?: M,
44
+ /**
45
+ * The currently selected key in the collection (controlled).
46
+ * @deprecated
47
+ */
48
+ selectedKey?: Key | null,
49
+ /**
50
+ * The initial selected key in the collection (uncontrolled).
51
+ * @deprecated
52
+ */
53
+ defaultSelectedKey?: Key,
54
+ /**
55
+ * Handler that is called when the selection changes.
56
+ * @deprecated
57
+ */
58
+ onSelectionChange?: (key: Key | null) => void,
34
59
  /** Sets the open state of the menu. */
35
60
  isOpen?: boolean,
36
61
  /** Sets the default open state of the menu. */
@@ -39,7 +64,7 @@ export interface SelectProps<T> extends CollectionBase<T>, Omit<InputBase, 'isRe
39
64
  onOpenChange?: (isOpen: boolean) => void
40
65
  }
41
66
 
42
- export interface AriaSelectProps<T> extends SelectProps<T>, DOMProps, AriaLabelingProps, FocusableDOMProps {
67
+ export interface AriaSelectProps<T, M extends SelectionMode = 'single'> extends SelectProps<T, M>, DOMProps, AriaLabelingProps, FocusableDOMProps {
43
68
  /**
44
69
  * 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).
45
70
  */
@@ -56,7 +81,7 @@ export interface AriaSelectProps<T> extends SelectProps<T>, DOMProps, AriaLabeli
56
81
  form?: string
57
82
  }
58
83
 
59
- export interface SpectrumPickerProps<T> extends AriaSelectProps<T>, AsyncLoadable, SpectrumLabelableProps, StyleProps {
84
+ export interface SpectrumPickerProps<T> extends Omit<AriaSelectProps<T>, 'selectionMode' | 'selectedKey' | 'defaultSelectedKey' | 'onSelectionChange' | 'value' | 'defaultValue' | 'onChange'>, Omit<SingleSelection, 'disallowEmptySelection'>, AsyncLoadable, SpectrumLabelableProps, StyleProps {
60
85
  /** Whether the textfield should be displayed with a quiet style. */
61
86
  isQuiet?: boolean,
62
87
  /** Alignment of the menu relative to the input target.