@react-types/select 3.10.1 → 3.12.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 +32 -5
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@react-types/select",
3
- "version": "3.10.1",
3
+ "version": "3.12.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.32.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": "2c58ed3ddd9be9100af9b1d0cfd137fcdc95ba2d"
20
+ "gitHead": "4d838da5bfe36abb35aed166995a9ef63825370f"
21
21
  }
package/src/index.d.ts CHANGED
@@ -27,19 +27,46 @@ 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. */
37
62
  defaultOpen?: boolean,
38
63
  /** Method that is called when the open state of the menu changes. */
39
- onOpenChange?: (isOpen: boolean) => void
64
+ onOpenChange?: (isOpen: boolean) => void,
65
+ /** Whether the select should be allowed to be open when the collection is empty. */
66
+ allowsEmptyCollection?: boolean
40
67
  }
41
68
 
42
- export interface AriaSelectProps<T> extends SelectProps<T>, DOMProps, AriaLabelingProps, FocusableDOMProps {
69
+ export interface AriaSelectProps<T, M extends SelectionMode = 'single'> extends SelectProps<T, M>, DOMProps, AriaLabelingProps, FocusableDOMProps {
43
70
  /**
44
71
  * 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
72
  */
@@ -56,7 +83,7 @@ export interface AriaSelectProps<T> extends SelectProps<T>, DOMProps, AriaLabeli
56
83
  form?: string
57
84
  }
58
85
 
59
- export interface SpectrumPickerProps<T> extends AriaSelectProps<T>, AsyncLoadable, SpectrumLabelableProps, StyleProps {
86
+ export interface SpectrumPickerProps<T> extends Omit<AriaSelectProps<T>, 'selectionMode' | 'selectedKey' | 'defaultSelectedKey' | 'onSelectionChange' | 'value' | 'defaultValue' | 'onChange' | 'allowsEmptyCollection'>, Omit<SingleSelection, 'disallowEmptySelection'>, AsyncLoadable, SpectrumLabelableProps, StyleProps {
60
87
  /** Whether the textfield should be displayed with a quiet style. */
61
88
  isQuiet?: boolean,
62
89
  /** Alignment of the menu relative to the input target.