@react-types/shared 3.7.1 → 3.10.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.7.1",
3
+ "version": "3.10.1",
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": "7a22a08c534513db71c2b31d9c45b64b2742a53e"
17
+ "gitHead": "45e63a00c00486cf57b457371da6f8749cd9bca4"
18
18
  }
@@ -130,6 +130,9 @@ export interface Collection<T> extends Iterable<T> {
130
130
  /** Get an item by its key. */
131
131
  getItem(key: Key): T,
132
132
 
133
+ /** Get an item by the index of its key. */
134
+ at(idx: number): T,
135
+
133
136
  /** Get the key that comes before the given key in the collection. */
134
137
  getKeyBefore(key: Key): Key | null,
135
138
 
package/src/dom.d.ts CHANGED
@@ -10,7 +10,12 @@
10
10
  * governing permissions and limitations under the License.
11
11
  */
12
12
 
13
- import {ClipboardEventHandler, CompositionEventHandler, FormEventHandler, ReactEventHandler} from 'react';
13
+ import {
14
+ ClipboardEventHandler,
15
+ CompositionEventHandler,
16
+ FormEventHandler,
17
+ ReactEventHandler
18
+ } from 'react';
14
19
 
15
20
  export interface AriaLabelingProps {
16
21
  /**
@@ -125,7 +130,7 @@ export interface TextInputDOMProps extends DOMProps {
125
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).
126
131
  */
127
132
  onCompositionStart?: CompositionEventHandler<HTMLInputElement>,
128
-
133
+
129
134
  /**
130
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).
131
136
  */
package/src/events.d.ts CHANGED
@@ -40,7 +40,14 @@ export interface PressEvent {
40
40
  /** Whether the ctrl keyboard modifier was held during the press event. */
41
41
  ctrlKey: boolean,
42
42
  /** Whether the meta keyboard modifier was held during the press event. */
43
- metaKey: boolean
43
+ metaKey: boolean,
44
+ /** Whether the alt keyboard modifier was held during the press event. */
45
+ altKey: boolean
46
+ }
47
+
48
+ export interface LongPressEvent extends Omit<PressEvent, 'type'> {
49
+ /** The type of long press event being fired. */
50
+ type: 'longpressstart' | 'longpressend' | 'longpress'
44
51
  }
45
52
 
46
53
  export interface HoverEvent {
package/src/index.d.ts CHANGED
@@ -13,7 +13,6 @@
13
13
  export * from './dom';
14
14
  export * from './inputs';
15
15
  export * from './selection';
16
- export * from './splitview';
17
16
  export * from './dnd';
18
17
  export * from './collections';
19
18
  export * from './removable';
package/src/inputs.d.ts CHANGED
@@ -10,6 +10,8 @@
10
10
  * governing permissions and limitations under the License.
11
11
  */
12
12
 
13
+ import {ReactNode} from 'react';
14
+
13
15
  export type ValidationState = 'valid' | 'invalid';
14
16
 
15
17
  export interface Validation {
@@ -29,13 +31,13 @@ export interface InputBase {
29
31
  isReadOnly?: boolean
30
32
  }
31
33
 
32
- export interface ValueBase<T> {
34
+ export interface ValueBase<T, C = T> {
33
35
  /** The current value (controlled). */
34
36
  value?: T,
35
37
  /** The default value (uncontrolled). */
36
38
  defaultValue?: T,
37
39
  /** Handler that is called when the value changes. */
38
- onChange?: (value: T) => void
40
+ onChange?: (value: C) => void
39
41
  }
40
42
 
41
43
  export interface TextInputBase {
@@ -58,3 +60,18 @@ export interface RangeInputBase<T> {
58
60
  /** The amount that the input value changes with each increment or decrement "tick". */
59
61
  step?: T // ??
60
62
  }
63
+
64
+ export interface HelpTextProps {
65
+ /** A description for the field. Provides a hint such as specific requirements for what to choose. */
66
+ description?: ReactNode,
67
+ /** An error message for the field. */
68
+ errorMessage?: ReactNode
69
+ }
70
+
71
+ // Spectrum specific types. Extends `Validation` so that the `validationState` prop is available.
72
+ export interface SpectrumHelpTextProps extends HelpTextProps, Validation {
73
+ /** Whether the description is displayed with lighter text. */
74
+ isDisabled?: boolean,
75
+ /** Whether an error icon is rendered. */
76
+ showErrorIcon?: boolean
77
+ }
@@ -24,6 +24,7 @@ export interface SingleSelection {
24
24
  }
25
25
 
26
26
  export type SelectionMode = 'none' | 'single' | 'multiple';
27
+ export type SelectionBehavior = 'toggle' | 'replace';
27
28
  export type Selection = 'all' | Set<Key>;
28
29
  export interface MultipleSelection {
29
30
  /** The type of selection that is allowed in the collection. */
@@ -40,4 +41,9 @@ export interface MultipleSelection {
40
41
  disabledKeys?: Iterable<Key>
41
42
  }
42
43
 
44
+ export interface SpectrumSelectionProps {
45
+ /** How selection should be displayed. */
46
+ selectionStyle?: 'checkbox' | 'highlight'
47
+ }
48
+
43
49
  export type FocusStrategy = 'first' | 'last';
@@ -1,83 +0,0 @@
1
- /*
2
- * Copyright 2020 Adobe. All rights reserved.
3
- * This file is licensed to you under the Apache License, Version 2.0 (the "License");
4
- * you may not use this file except in compliance with the License. You may obtain a copy
5
- * of the License at http://www.apache.org/licenses/LICENSE-2.0
6
- *
7
- * Unless required by applicable law or agreed to in writing, software distributed under
8
- * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
9
- * OF ANY KIND, either express or implied. See the License for the specific language
10
- * governing permissions and limitations under the License.
11
- */
12
-
13
- import {
14
- Dispatch,
15
- MutableRefObject,
16
- ReactElement,
17
- SetStateAction
18
- } from 'react';
19
- import {Orientation} from './orientation';
20
-
21
- export interface SplitViewStatelyProps {
22
- allowsCollapsing?: boolean,
23
- onResize?: (primarySize: number) => void,
24
- onResizeEnd?: (primarySize: number) => void,
25
- primarySize?: number,
26
- defaultPrimarySize?: number
27
- }
28
-
29
- export interface SplitViewHandleState {
30
- offset: number,
31
- dragging: boolean,
32
- hovered: boolean,
33
- setOffset: (value: number) => void,
34
- setDragging: (value: boolean) => void,
35
- setHover: (value: boolean) => void,
36
- increment: () => void,
37
- decrement: () => void,
38
- incrementToMax: () => void,
39
- decrementToMin: () => void,
40
- collapseToggle: () => void
41
- }
42
-
43
- export interface SplitViewContainerState {
44
- minPos: number,
45
- maxPos: number,
46
- setMinPos: Dispatch<SetStateAction<number>>,
47
- setMaxPos: Dispatch<SetStateAction<number>>
48
- }
49
-
50
- export interface SplitViewState {
51
- handleState: SplitViewHandleState,
52
- containerState: SplitViewContainerState
53
- }
54
-
55
- export interface SplitViewAriaProps {
56
- id?: string,
57
- allowsResizing?: boolean,
58
- orientation?: Orientation,
59
- primaryPane?: 0 | 1,
60
- primaryMinSize?: number,
61
- primaryMaxSize?: number,
62
- secondaryMinSize?: number,
63
- secondaryMaxSize?: number,
64
- 'aria-label'?: string,
65
- 'aria-labelledby'?: string,
66
- containerRef?: MutableRefObject<HTMLDivElement>
67
- }
68
-
69
- export interface SplitViewProps {
70
- children: [ReactElement, ReactElement],
71
- orientation?: Orientation,
72
- allowsResizing?: boolean,
73
- allowsCollapsing?: boolean,
74
- onResize?: (primarySize: number) => void,
75
- onResizeEnd?: (primarySize: number) => void,
76
- primaryPane?: 0 | 1,
77
- primarySize?: number,
78
- defaultPrimarySize?: number,
79
- primaryMinSize?: number,
80
- primaryMaxSize?: number,
81
- secondaryMinSize?: number,
82
- secondaryMaxSize?: number
83
- }