@react-types/button 3.15.1 → 3.16.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 +7 -4
  2. package/src/index.d.ts +6 -127
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@react-types/button",
3
- "version": "3.15.1",
3
+ "version": "3.16.0",
4
4
  "description": "Spectrum UI components in React",
5
5
  "license": "Apache-2.0",
6
6
  "types": "src/index.d.ts",
@@ -9,13 +9,16 @@
9
9
  "url": "https://github.com/adobe/react-spectrum"
10
10
  },
11
11
  "dependencies": {
12
- "@react-types/shared": "^3.33.1"
12
+ "@react-aria/button": "^3.15.0",
13
+ "@react-spectrum/button": "^3.18.0"
13
14
  },
14
15
  "peerDependencies": {
15
- "react": "^16.8.0 || ^17.0.0-rc.1 || ^18.0.0 || ^19.0.0-rc.1"
16
+ "@react-spectrum/provider": "^3.0.0",
17
+ "react": "^16.8.0 || ^17.0.0-rc.1 || ^18.0.0 || ^19.0.0-rc.1",
18
+ "react-dom": "^16.8.0 || ^17.0.0-rc.1 || ^18.0.0 || ^19.0.0-rc.1"
16
19
  },
17
20
  "publishConfig": {
18
21
  "access": "public"
19
22
  },
20
- "gitHead": "8df187370053aa35f553cb388ad670f65e1ab371"
23
+ "gitHead": "a6999bdf494a2e9c0381a5881908328bdd22ddae"
21
24
  }
package/src/index.d.ts CHANGED
@@ -10,132 +10,11 @@
10
10
  * governing permissions and limitations under the License.
11
11
  */
12
12
 
13
- import {AriaLabelingProps, FocusableDOMProps, FocusableProps, Key, PressEvents, StyleProps} from '@react-types/shared';
14
- import {ButtonHTMLAttributes, ElementType, JSXElementConstructor, ReactNode} from 'react';
13
+ import {AriaButtonProps} from '@react-aria/button';
14
+ import {ElementType} from 'react';
15
15
 
16
- interface ButtonProps extends PressEvents, FocusableProps {
17
- /** Whether the button is disabled. */
18
- isDisabled?: boolean,
19
- /** The content to display in the button. */
20
- children?: ReactNode
21
- }
16
+ export {LinkButtonProps, AriaButtonProps, AriaToggleButtonProps, AriaToggleButtonGroupItemProps} from '@react-aria/button';
17
+ export {SpectrumButtonProps, SpectrumActionButtonProps, SpectrumLogicButtonProps, SpectrumToggleButtonProps} from '@react-spectrum/button';
22
18
 
23
- interface ToggleButtonProps extends ButtonProps {
24
- /** Whether the element should be selected (controlled). */
25
- isSelected?: boolean,
26
- /** Whether the element should be selected (uncontrolled). */
27
- defaultSelected?: boolean,
28
- /** Handler that is called when the element's selection state changes. */
29
- onChange?: (isSelected: boolean) => void
30
- }
31
-
32
- export interface AriaButtonElementTypeProps<T extends ElementType = 'button'> {
33
- /**
34
- * The HTML element or React element used to render the button, e.g. 'div', 'a', or `RouterLink`.
35
- * @default 'button'
36
- */
37
- elementType?: T | JSXElementConstructor<any>
38
- }
39
-
40
- export interface LinkButtonProps<T extends ElementType = 'button'> extends AriaButtonElementTypeProps<T> {
41
- /** A URL to link to if elementType="a". */
42
- href?: string,
43
- /** The target window for the link. */
44
- target?: string,
45
- /** The relationship between the linked resource and the current page. See [MDN](https://developer.mozilla.org/en-US/docs/Web/HTML/Attributes/rel). */
46
- rel?: string
47
- }
48
-
49
- interface AriaBaseButtonProps extends FocusableDOMProps, AriaLabelingProps {
50
- /** Indicates whether the element is disabled to users of assistive technology. */
51
- 'aria-disabled'?: boolean | 'true' | 'false',
52
- /** Indicates whether the element, or another grouping element it controls, is currently expanded or collapsed. */
53
- 'aria-expanded'?: boolean | 'true' | 'false',
54
- /** Indicates the availability and type of interactive popup element, such as menu or dialog, that can be triggered by an element. */
55
- 'aria-haspopup'?: boolean | 'menu' | 'listbox' | 'tree' | 'grid' | 'dialog' | 'true' | 'false',
56
- /** Identifies the element (or elements) whose contents or presence are controlled by the current element. */
57
- 'aria-controls'?: string,
58
- /** Indicates the current "pressed" state of toggle buttons. */
59
- 'aria-pressed'?: boolean | 'true' | 'false' | 'mixed',
60
- /** Indicates whether this element represents the current item within a container or set of related elements. */
61
- 'aria-current'?: boolean | 'true' | 'false' | 'page' | 'step' | 'location' | 'date' | 'time',
62
- /**
63
- * The behavior of the button when used in an HTML form.
64
- * @default 'button'
65
- */
66
- type?: 'button' | 'submit' | 'reset',
67
- /**
68
- * Whether to prevent focus from moving to the button when pressing it.
69
- *
70
- * Caution, this can make the button inaccessible and should only be used when alternative keyboard interaction is provided,
71
- * such as ComboBox's MenuTrigger or a NumberField's increment/decrement control.
72
- */
73
- preventFocusOnPress?: boolean,
74
- /**
75
- * The `<form>` element to associate the button with.
76
- * The value of this attribute must be the id of a `<form>` in the same document.
77
- * See [MDN](https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Elements/button#form).
78
- */
79
- form?: string,
80
- /**
81
- * The URL that processes the information submitted by the button.
82
- * Overrides the action attribute of the button's form owner.
83
- */
84
- formAction?: ButtonHTMLAttributes<HTMLButtonElement>['formAction'],
85
- /** Indicates how to encode the form data that is submitted. */
86
- formEncType?: string,
87
- /** Indicates the HTTP method used to submit the form. */
88
- formMethod?: string,
89
- /** Indicates that the form is not to be validated when it is submitted. */
90
- formNoValidate?: boolean,
91
- /** Overrides the target attribute of the button's form owner. */
92
- formTarget?: string,
93
- /** Submitted as a pair with the button's value as part of the form data. */
94
- name?: string,
95
- /** The value associated with the button's name when it's submitted with the form data. */
96
- value?: string
97
- }
98
-
99
- export interface AriaButtonProps<T extends ElementType = 'button'> extends ButtonProps, LinkButtonProps<T>, AriaBaseButtonProps {}
100
- export interface AriaToggleButtonProps<T extends ElementType = 'button'> extends ToggleButtonProps, Omit<AriaBaseButtonProps, 'aria-current' | 'form' | 'formAction' | 'formEncType' | 'formMethod' | 'formNoValidate' | 'formTarget' | 'name' | 'value' | 'type'>, AriaButtonElementTypeProps<T> {}
101
- export interface AriaToggleButtonGroupItemProps<E extends ElementType = 'button'> extends Omit<AriaToggleButtonProps<E>, 'id' | 'isSelected' | 'defaultSelected' | 'onChange'> {
102
- /** An identifier for the item in the `selectedKeys` of a ToggleButtonGroup. */
103
- id: Key
104
- }
105
-
106
- /** @deprecated */
107
- type LegacyButtonVariant = 'cta' | 'overBackground';
108
- export interface SpectrumButtonProps<T extends ElementType = 'button'> extends AriaBaseButtonProps, Omit<ButtonProps, 'onClick'>, LinkButtonProps<T>, StyleProps {
109
- /** The [visual style](https://spectrum.adobe.com/page/button/#Options) of the button. */
110
- variant: 'accent' | 'primary' | 'secondary' | 'negative' | LegacyButtonVariant,
111
- /** The background style of the button. */
112
- style?: 'fill' | 'outline',
113
- /** The static color style to apply. Useful when the button appears over a color background. */
114
- staticColor?: 'white' | 'black',
115
- /**
116
- * Whether to disable events immediately and display a loading spinner after a 1 second delay.
117
- */
118
- isPending?: boolean,
119
- /**
120
- * Whether the button should be displayed with a quiet style.
121
- * @deprecated
122
- */
123
- isQuiet?: boolean
124
- }
125
-
126
- export interface SpectrumActionButtonProps extends AriaBaseButtonProps, Omit<ButtonProps, 'onClick'>, StyleProps {
127
- /** Whether the button should be displayed with a [quiet style](https://spectrum.adobe.com/page/action-button/#Quiet). */
128
- isQuiet?: boolean,
129
- /** The static color style to apply. Useful when the button appears over a color background. */
130
- staticColor?: 'white' | 'black'
131
- }
132
-
133
- export interface SpectrumLogicButtonProps extends AriaBaseButtonProps, Omit<ButtonProps, 'onClick'>, StyleProps {
134
- /** The type of boolean sequence to be represented by the LogicButton. */
135
- variant: 'and' | 'or'
136
- }
137
-
138
- export interface SpectrumToggleButtonProps extends Omit<ToggleButtonProps, 'onClick'>, Omit<SpectrumActionButtonProps, 'aria-current' | 'type' | 'form' | 'formAction' | 'formEncType' | 'formMethod' | 'formNoValidate' | 'formTarget' | 'name' | 'value'> {
139
- /** Whether the button should be displayed with an [emphasized style](https://spectrum.adobe.com/page/action-button/#Emphasis). */
140
- isEmphasized?: boolean
141
- }
19
+ // Backward compatibility.
20
+ export type AriaButtonElementTypeProps<T extends ElementType = 'button'> = Pick<AriaButtonProps<T>, 'elementType'>;