@react-spectrum/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.
- package/README.md +3 -0
- package/dist/ActionButton.main.js +97 -0
- package/dist/ActionButton.main.js.map +1 -0
- package/dist/ActionButton.mjs +92 -0
- package/dist/ActionButton.module.js +92 -0
- package/dist/ActionButton.module.js.map +1 -0
- package/dist/Button.main.js +186 -0
- package/dist/Button.main.js.map +1 -0
- package/dist/Button.mjs +181 -0
- package/dist/Button.module.js +181 -0
- package/dist/Button.module.js.map +1 -0
- package/dist/ClearButton.main.js +75 -0
- package/dist/ClearButton.main.js.map +1 -0
- package/dist/ClearButton.mjs +70 -0
- package/dist/ClearButton.module.js +70 -0
- package/dist/ClearButton.module.js.map +1 -0
- package/dist/FieldButton.main.js +72 -0
- package/dist/FieldButton.main.js.map +1 -0
- package/dist/FieldButton.mjs +67 -0
- package/dist/FieldButton.module.js +67 -0
- package/dist/FieldButton.module.js.map +1 -0
- package/dist/LogicButton.main.js +70 -0
- package/dist/LogicButton.main.js.map +1 -0
- package/dist/LogicButton.mjs +65 -0
- package/dist/LogicButton.module.js +65 -0
- package/dist/LogicButton.module.js.map +1 -0
- package/dist/ToggleButton.main.js +90 -0
- package/dist/ToggleButton.main.js.map +1 -0
- package/dist/ToggleButton.mjs +85 -0
- package/dist/ToggleButton.module.js +85 -0
- package/dist/ToggleButton.module.js.map +1 -0
- package/dist/ar-AE.main.js +6 -0
- package/dist/ar-AE.main.js.map +1 -0
- package/dist/ar-AE.mjs +8 -0
- package/dist/ar-AE.module.js +8 -0
- package/dist/ar-AE.module.js.map +1 -0
- package/dist/bg-BG.main.js +6 -0
- package/dist/bg-BG.main.js.map +1 -0
- package/dist/bg-BG.mjs +8 -0
- package/dist/bg-BG.module.js +8 -0
- package/dist/bg-BG.module.js.map +1 -0
- package/dist/button_vars_css.main.js +122 -0
- package/dist/button_vars_css.main.js.map +1 -0
- package/dist/button_vars_css.mjs +124 -0
- package/dist/button_vars_css.module.js +124 -0
- package/dist/button_vars_css.module.js.map +1 -0
- package/dist/cs-CZ.main.js +6 -0
- package/dist/cs-CZ.main.js.map +1 -0
- package/dist/cs-CZ.mjs +8 -0
- package/dist/cs-CZ.module.js +8 -0
- package/dist/cs-CZ.module.js.map +1 -0
- package/dist/da-DK.main.js +6 -0
- package/dist/da-DK.main.js.map +1 -0
- package/dist/da-DK.mjs +8 -0
- package/dist/da-DK.module.js +8 -0
- package/dist/da-DK.module.js.map +1 -0
- package/dist/de-DE.main.js +6 -0
- package/dist/de-DE.main.js.map +1 -0
- package/dist/de-DE.mjs +8 -0
- package/dist/de-DE.module.js +8 -0
- package/dist/de-DE.module.js.map +1 -0
- package/dist/el-GR.main.js +6 -0
- package/dist/el-GR.main.js.map +1 -0
- package/dist/el-GR.mjs +8 -0
- package/dist/el-GR.module.js +8 -0
- package/dist/el-GR.module.js.map +1 -0
- package/dist/en-US.main.js +6 -0
- package/dist/en-US.main.js.map +1 -0
- package/dist/en-US.mjs +8 -0
- package/dist/en-US.module.js +8 -0
- package/dist/en-US.module.js.map +1 -0
- package/dist/es-ES.main.js +6 -0
- package/dist/es-ES.main.js.map +1 -0
- package/dist/es-ES.mjs +8 -0
- package/dist/es-ES.module.js +8 -0
- package/dist/es-ES.module.js.map +1 -0
- package/dist/et-EE.main.js +6 -0
- package/dist/et-EE.main.js.map +1 -0
- package/dist/et-EE.mjs +8 -0
- package/dist/et-EE.module.js +8 -0
- package/dist/et-EE.module.js.map +1 -0
- package/dist/fi-FI.main.js +6 -0
- package/dist/fi-FI.main.js.map +1 -0
- package/dist/fi-FI.mjs +8 -0
- package/dist/fi-FI.module.js +8 -0
- package/dist/fi-FI.module.js.map +1 -0
- package/dist/fr-FR.main.js +6 -0
- package/dist/fr-FR.main.js.map +1 -0
- package/dist/fr-FR.mjs +8 -0
- package/dist/fr-FR.module.js +8 -0
- package/dist/fr-FR.module.js.map +1 -0
- package/dist/he-IL.main.js +6 -0
- package/dist/he-IL.main.js.map +1 -0
- package/dist/he-IL.mjs +8 -0
- package/dist/he-IL.module.js +8 -0
- package/dist/he-IL.module.js.map +1 -0
- package/dist/hr-HR.main.js +6 -0
- package/dist/hr-HR.main.js.map +1 -0
- package/dist/hr-HR.mjs +8 -0
- package/dist/hr-HR.module.js +8 -0
- package/dist/hr-HR.module.js.map +1 -0
- package/dist/hu-HU.main.js +6 -0
- package/dist/hu-HU.main.js.map +1 -0
- package/dist/hu-HU.mjs +8 -0
- package/dist/hu-HU.module.js +8 -0
- package/dist/hu-HU.module.js.map +1 -0
- package/dist/import.mjs +28 -0
- package/dist/intlStrings.main.js +108 -0
- package/dist/intlStrings.main.js.map +1 -0
- package/dist/intlStrings.mjs +110 -0
- package/dist/intlStrings.module.js +110 -0
- package/dist/intlStrings.module.js.map +1 -0
- package/dist/it-IT.main.js +6 -0
- package/dist/it-IT.main.js.map +1 -0
- package/dist/it-IT.mjs +8 -0
- package/dist/it-IT.module.js +8 -0
- package/dist/it-IT.module.js.map +1 -0
- package/dist/ja-JP.main.js +6 -0
- package/dist/ja-JP.main.js.map +1 -0
- package/dist/ja-JP.mjs +8 -0
- package/dist/ja-JP.module.js +8 -0
- package/dist/ja-JP.module.js.map +1 -0
- package/dist/ko-KR.main.js +6 -0
- package/dist/ko-KR.main.js.map +1 -0
- package/dist/ko-KR.mjs +8 -0
- package/dist/ko-KR.module.js +8 -0
- package/dist/ko-KR.module.js.map +1 -0
- package/dist/lt-LT.main.js +6 -0
- package/dist/lt-LT.main.js.map +1 -0
- package/dist/lt-LT.mjs +8 -0
- package/dist/lt-LT.module.js +8 -0
- package/dist/lt-LT.module.js.map +1 -0
- package/dist/lv-LV.main.js +6 -0
- package/dist/lv-LV.main.js.map +1 -0
- package/dist/lv-LV.mjs +8 -0
- package/dist/lv-LV.module.js +8 -0
- package/dist/lv-LV.module.js.map +1 -0
- package/dist/main.js +38 -0
- package/dist/main.js.map +1 -0
- package/dist/module.js +28 -0
- package/dist/module.js.map +1 -0
- package/dist/nb-NO.main.js +6 -0
- package/dist/nb-NO.main.js.map +1 -0
- package/dist/nb-NO.mjs +8 -0
- package/dist/nb-NO.module.js +8 -0
- package/dist/nb-NO.module.js.map +1 -0
- package/dist/nl-NL.main.js +6 -0
- package/dist/nl-NL.main.js.map +1 -0
- package/dist/nl-NL.mjs +8 -0
- package/dist/nl-NL.module.js +8 -0
- package/dist/nl-NL.module.js.map +1 -0
- package/dist/pl-PL.main.js +6 -0
- package/dist/pl-PL.main.js.map +1 -0
- package/dist/pl-PL.mjs +8 -0
- package/dist/pl-PL.module.js +8 -0
- package/dist/pl-PL.module.js.map +1 -0
- package/dist/pt-BR.main.js +6 -0
- package/dist/pt-BR.main.js.map +1 -0
- package/dist/pt-BR.mjs +8 -0
- package/dist/pt-BR.module.js +8 -0
- package/dist/pt-BR.module.js.map +1 -0
- package/dist/pt-PT.main.js +6 -0
- package/dist/pt-PT.main.js.map +1 -0
- package/dist/pt-PT.mjs +8 -0
- package/dist/pt-PT.module.js +8 -0
- package/dist/pt-PT.module.js.map +1 -0
- package/dist/ro-RO.main.js +6 -0
- package/dist/ro-RO.main.js.map +1 -0
- package/dist/ro-RO.mjs +8 -0
- package/dist/ro-RO.module.js +8 -0
- package/dist/ro-RO.module.js.map +1 -0
- package/dist/ru-RU.main.js +6 -0
- package/dist/ru-RU.main.js.map +1 -0
- package/dist/ru-RU.mjs +8 -0
- package/dist/ru-RU.module.js +8 -0
- package/dist/ru-RU.module.js.map +1 -0
- package/dist/sk-SK.main.js +6 -0
- package/dist/sk-SK.main.js.map +1 -0
- package/dist/sk-SK.mjs +8 -0
- package/dist/sk-SK.module.js +8 -0
- package/dist/sk-SK.module.js.map +1 -0
- package/dist/sl-SI.main.js +6 -0
- package/dist/sl-SI.main.js.map +1 -0
- package/dist/sl-SI.mjs +8 -0
- package/dist/sl-SI.module.js +8 -0
- package/dist/sl-SI.module.js.map +1 -0
- package/dist/sr-SP.main.js +6 -0
- package/dist/sr-SP.main.js.map +1 -0
- package/dist/sr-SP.mjs +8 -0
- package/dist/sr-SP.module.js +8 -0
- package/dist/sr-SP.module.js.map +1 -0
- package/dist/sv-SE.main.js +6 -0
- package/dist/sv-SE.main.js.map +1 -0
- package/dist/sv-SE.mjs +8 -0
- package/dist/sv-SE.module.js +8 -0
- package/dist/sv-SE.module.js.map +1 -0
- package/dist/tr-TR.main.js +6 -0
- package/dist/tr-TR.main.js.map +1 -0
- package/dist/tr-TR.mjs +8 -0
- package/dist/tr-TR.module.js +8 -0
- package/dist/tr-TR.module.js.map +1 -0
- package/dist/types.d.ts +43 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/uk-UA.main.js +6 -0
- package/dist/uk-UA.main.js.map +1 -0
- package/dist/uk-UA.mjs +8 -0
- package/dist/uk-UA.module.js +8 -0
- package/dist/uk-UA.module.js.map +1 -0
- package/dist/vars.4fe44343.css +1645 -0
- package/dist/vars.4fe44343.css.map +1 -0
- package/dist/zh-CN.main.js +6 -0
- package/dist/zh-CN.main.js.map +1 -0
- package/dist/zh-CN.mjs +8 -0
- package/dist/zh-CN.module.js +8 -0
- package/dist/zh-CN.module.js.map +1 -0
- package/dist/zh-TW.main.js +6 -0
- package/dist/zh-TW.main.js.map +1 -0
- package/dist/zh-TW.mjs +8 -0
- package/dist/zh-TW.module.js +8 -0
- package/dist/zh-TW.module.js.map +1 -0
- package/package.json +66 -0
- package/src/ActionButton.tsx +107 -0
- package/src/Button.tsx +210 -0
- package/src/ClearButton.tsx +81 -0
- package/src/FieldButton.tsx +84 -0
- package/src/LogicButton.tsx +67 -0
- package/src/ToggleButton.tsx +93 -0
- package/src/index.ts +19 -0
|
@@ -0,0 +1,67 @@
|
|
|
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 {classNames, useFocusableRef, useStyleProps} from '@react-spectrum/utils';
|
|
14
|
+
import {FocusableRef} from '@react-types/shared';
|
|
15
|
+
import {FocusRing} from '@react-aria/focus';
|
|
16
|
+
import {mergeProps} from '@react-aria/utils';
|
|
17
|
+
import React from 'react';
|
|
18
|
+
import {SpectrumLogicButtonProps} from '@react-types/button';
|
|
19
|
+
import styles from '@adobe/spectrum-css-temp/components/button/vars.css';
|
|
20
|
+
import {useButton} from '@react-aria/button';
|
|
21
|
+
import {useHover} from '@react-aria/interactions';
|
|
22
|
+
import {useProviderProps} from '@react-spectrum/provider';
|
|
23
|
+
|
|
24
|
+
function LogicButton(props: SpectrumLogicButtonProps, ref: FocusableRef<HTMLButtonElement>) {
|
|
25
|
+
props = useProviderProps(props);
|
|
26
|
+
let {
|
|
27
|
+
variant,
|
|
28
|
+
children,
|
|
29
|
+
isDisabled,
|
|
30
|
+
autoFocus,
|
|
31
|
+
...otherProps
|
|
32
|
+
} = props;
|
|
33
|
+
let domRef = useFocusableRef(ref);
|
|
34
|
+
let {buttonProps, isPressed} = useButton(props, domRef);
|
|
35
|
+
let {hoverProps, isHovered} = useHover({isDisabled});
|
|
36
|
+
let {styleProps} = useStyleProps(otherProps);
|
|
37
|
+
|
|
38
|
+
return (
|
|
39
|
+
<FocusRing focusRingClass={classNames(styles, 'focus-ring')} autoFocus={autoFocus}>
|
|
40
|
+
<button
|
|
41
|
+
{...styleProps}
|
|
42
|
+
{...mergeProps(buttonProps, hoverProps)}
|
|
43
|
+
ref={domRef}
|
|
44
|
+
className={
|
|
45
|
+
classNames(
|
|
46
|
+
styles,
|
|
47
|
+
'spectrum-LogicButton',
|
|
48
|
+
{
|
|
49
|
+
[`spectrum-LogicButton--${variant}`]: variant,
|
|
50
|
+
'is-disabled': isDisabled,
|
|
51
|
+
'is-active': isPressed,
|
|
52
|
+
'is-hovered': isHovered
|
|
53
|
+
},
|
|
54
|
+
styleProps.className
|
|
55
|
+
)
|
|
56
|
+
}>
|
|
57
|
+
<span className={classNames(styles, 'spectrum-Button-label')}>{children}</span>
|
|
58
|
+
</button>
|
|
59
|
+
</FocusRing>
|
|
60
|
+
);
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
/**
|
|
64
|
+
* A LogicButton displays an operator within a boolean logic sequence.
|
|
65
|
+
*/
|
|
66
|
+
let _LogicButton = React.forwardRef(LogicButton);
|
|
67
|
+
export {_LogicButton as LogicButton};
|
|
@@ -0,0 +1,93 @@
|
|
|
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 {classNames, SlotProvider, useFocusableRef, useStyleProps} from '@react-spectrum/utils';
|
|
14
|
+
import {FocusableRef} from '@react-types/shared';
|
|
15
|
+
import {FocusRing} from '@react-aria/focus';
|
|
16
|
+
import {mergeProps} from '@react-aria/utils';
|
|
17
|
+
import React from 'react';
|
|
18
|
+
import {SpectrumToggleButtonProps} from '@react-types/button';
|
|
19
|
+
import styles from '@adobe/spectrum-css-temp/components/button/vars.css';
|
|
20
|
+
import {Text} from '@react-spectrum/text';
|
|
21
|
+
import {useHover} from '@react-aria/interactions';
|
|
22
|
+
import {useProviderProps} from '@react-spectrum/provider';
|
|
23
|
+
import {useToggleButton} from '@react-aria/button';
|
|
24
|
+
import {useToggleState} from '@react-stately/toggle';
|
|
25
|
+
|
|
26
|
+
function ToggleButton(props: SpectrumToggleButtonProps, ref: FocusableRef<HTMLButtonElement>) {
|
|
27
|
+
props = useProviderProps(props);
|
|
28
|
+
let {
|
|
29
|
+
isQuiet,
|
|
30
|
+
isDisabled,
|
|
31
|
+
isEmphasized,
|
|
32
|
+
staticColor,
|
|
33
|
+
children,
|
|
34
|
+
autoFocus,
|
|
35
|
+
...otherProps
|
|
36
|
+
} = props;
|
|
37
|
+
|
|
38
|
+
let domRef = useFocusableRef(ref);
|
|
39
|
+
let state = useToggleState(props);
|
|
40
|
+
let {buttonProps, isPressed} = useToggleButton(props, state, domRef);
|
|
41
|
+
let {hoverProps, isHovered} = useHover({isDisabled});
|
|
42
|
+
let {styleProps} = useStyleProps(otherProps);
|
|
43
|
+
let isTextOnly = React.Children.toArray(props.children).every(c => !React.isValidElement(c));
|
|
44
|
+
|
|
45
|
+
return (
|
|
46
|
+
<FocusRing focusRingClass={classNames(styles, 'focus-ring')} autoFocus={autoFocus}>
|
|
47
|
+
<button
|
|
48
|
+
{...styleProps}
|
|
49
|
+
{...mergeProps(buttonProps, hoverProps)}
|
|
50
|
+
ref={domRef}
|
|
51
|
+
className={
|
|
52
|
+
classNames(
|
|
53
|
+
styles,
|
|
54
|
+
'spectrum-ActionButton',
|
|
55
|
+
{
|
|
56
|
+
'spectrum-ActionButton--quiet': isQuiet,
|
|
57
|
+
'spectrum-ActionButton--emphasized': isEmphasized,
|
|
58
|
+
'spectrum-ActionButton--staticColor': !!staticColor,
|
|
59
|
+
'spectrum-ActionButton--staticWhite': staticColor === 'white',
|
|
60
|
+
'spectrum-ActionButton--staticBlack': staticColor === 'black',
|
|
61
|
+
'is-active': isPressed,
|
|
62
|
+
'is-disabled': isDisabled,
|
|
63
|
+
'is-hovered': isHovered,
|
|
64
|
+
'is-selected': state.isSelected
|
|
65
|
+
},
|
|
66
|
+
styleProps.className
|
|
67
|
+
)
|
|
68
|
+
}>
|
|
69
|
+
<SlotProvider
|
|
70
|
+
slots={{
|
|
71
|
+
icon: {
|
|
72
|
+
size: 'S',
|
|
73
|
+
UNSAFE_className: classNames(styles, 'spectrum-Icon')
|
|
74
|
+
},
|
|
75
|
+
text: {
|
|
76
|
+
UNSAFE_className: classNames(styles, 'spectrum-ActionButton-label')
|
|
77
|
+
}
|
|
78
|
+
}}>
|
|
79
|
+
{typeof children === 'string' || isTextOnly
|
|
80
|
+
? <Text>{children}</Text>
|
|
81
|
+
: children}
|
|
82
|
+
</SlotProvider>
|
|
83
|
+
</button>
|
|
84
|
+
</FocusRing>
|
|
85
|
+
);
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
/**
|
|
89
|
+
* ToggleButtons allow users to toggle a selection on or off, for example
|
|
90
|
+
* switching between two states or modes.
|
|
91
|
+
*/
|
|
92
|
+
let _ToggleButton = React.forwardRef(ToggleButton);
|
|
93
|
+
export {_ToggleButton as ToggleButton};
|
package/src/index.ts
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
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
|
+
/// <reference types="css-module-types" />
|
|
13
|
+
export {Button} from './Button';
|
|
14
|
+
export {ActionButton} from './ActionButton';
|
|
15
|
+
export {FieldButton} from './FieldButton';
|
|
16
|
+
export {LogicButton} from './LogicButton';
|
|
17
|
+
export {ClearButton} from './ClearButton';
|
|
18
|
+
export {ToggleButton} from './ToggleButton';
|
|
19
|
+
export type {SpectrumActionButtonProps, SpectrumButtonProps, SpectrumLogicButtonProps, SpectrumToggleButtonProps} from '@react-types/button';
|