@react-types/button 3.0.0-nightly-641446f65-240905

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 (3) hide show
  1. package/README.md +3 -0
  2. package/package.json +21 -0
  3. package/src/index.d.ts +110 -0
package/README.md ADDED
@@ -0,0 +1,3 @@
1
+ # @react-types/button
2
+
3
+ This package is part of [react-spectrum](https://github.com/adobe/react-spectrum). See the repo for more details.
package/package.json ADDED
@@ -0,0 +1,21 @@
1
+ {
2
+ "name": "@react-types/button",
3
+ "version": "3.0.0-nightly-641446f65-240905",
4
+ "description": "Spectrum UI components in React",
5
+ "license": "Apache-2.0",
6
+ "types": "src/index.d.ts",
7
+ "repository": {
8
+ "type": "git",
9
+ "url": "https://github.com/adobe/react-spectrum"
10
+ },
11
+ "dependencies": {
12
+ "@react-types/shared": "^3.0.0-nightly-641446f65-240905"
13
+ },
14
+ "peerDependencies": {
15
+ "react": "^16.8.0 || ^17.0.0-rc.1 || ^18.0.0 || ^19.0.0"
16
+ },
17
+ "publishConfig": {
18
+ "access": "public"
19
+ },
20
+ "stableVersion": "3.9.6"
21
+ }
package/src/index.d.ts ADDED
@@ -0,0 +1,110 @@
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 {AriaLabelingProps, FocusableDOMProps, FocusableProps, PressEvents, StyleProps} from '@react-types/shared';
14
+ import {ElementType, JSXElementConstructor, ReactNode} from 'react';
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
+ }
22
+
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, or another grouping element it controls, is currently expanded or collapsed. */
51
+ 'aria-expanded'?: boolean | 'true' | 'false',
52
+ /** Indicates the availability and type of interactive popup element, such as menu or dialog, that can be triggered by an element. */
53
+ 'aria-haspopup'?: boolean | 'menu' | 'listbox' | 'tree' | 'grid' | 'dialog' | 'true' | 'false',
54
+ /** Identifies the element (or elements) whose contents or presence are controlled by the current element. */
55
+ 'aria-controls'?: string,
56
+ /** Indicates the current "pressed" state of toggle buttons. */
57
+ 'aria-pressed'?: boolean | 'true' | 'false' | 'mixed',
58
+ /**
59
+ * The behavior of the button when used in an HTML form.
60
+ * @default 'button'
61
+ */
62
+ type?: 'button' | 'submit' | 'reset',
63
+ /**
64
+ * Whether to prevent focus from moving to the button when pressing it.
65
+ *
66
+ * Caution, this can make the button inaccessible and should only be used when alternative keyboard interaction is provided,
67
+ * such as ComboBox's MenuTrigger or a NumberField's increment/decrement control.
68
+ */
69
+ preventFocusOnPress?: boolean
70
+ }
71
+
72
+ export interface AriaButtonProps<T extends ElementType = 'button'> extends ButtonProps, LinkButtonProps<T>, AriaBaseButtonProps {}
73
+ export interface AriaToggleButtonProps<T extends ElementType = 'button'> extends ToggleButtonProps, AriaBaseButtonProps, AriaButtonElementTypeProps<T> {}
74
+
75
+ /** @deprecated */
76
+ type LegacyButtonVariant = 'cta' | 'overBackground';
77
+ export interface SpectrumButtonProps<T extends ElementType = 'button'> extends AriaBaseButtonProps, ButtonProps, LinkButtonProps<T>, StyleProps {
78
+ /** The [visual style](https://spectrum.adobe.com/page/button/#Options) of the button. */
79
+ variant: 'accent' | 'primary' | 'secondary' | 'negative' | LegacyButtonVariant,
80
+ /** The background style of the button. */
81
+ style?: 'fill' | 'outline',
82
+ /** The static color style to apply. Useful when the button appears over a color background. */
83
+ staticColor?: 'white' | 'black',
84
+ /**
85
+ * Whether to disable events immediately and display a loading spinner after a 1 second delay.
86
+ */
87
+ isPending?: boolean,
88
+ /**
89
+ * Whether the button should be displayed with a quiet style.
90
+ * @deprecated
91
+ */
92
+ isQuiet?: boolean
93
+ }
94
+
95
+ export interface SpectrumActionButtonProps extends AriaBaseButtonProps, ButtonProps, StyleProps {
96
+ /** Whether the button should be displayed with a [quiet style](https://spectrum.adobe.com/page/action-button/#Quiet). */
97
+ isQuiet?: boolean,
98
+ /** The static color style to apply. Useful when the button appears over a color background. */
99
+ staticColor?: 'white' | 'black'
100
+ }
101
+
102
+ export interface SpectrumLogicButtonProps extends AriaBaseButtonProps, ButtonProps, StyleProps {
103
+ /** The type of boolean sequence to be represented by the LogicButton. */
104
+ variant: 'and' | 'or'
105
+ }
106
+
107
+ export interface SpectrumToggleButtonProps extends ToggleButtonProps, SpectrumActionButtonProps {
108
+ /** Whether the button should be displayed with an [emphasized style](https://spectrum.adobe.com/page/action-button/#Emphasis). */
109
+ isEmphasized?: boolean
110
+ }