@fluentui/react-button 0.0.0-nightly-20230502-0418.1 → 0.0.0-nightly-20230504-0417.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/CHANGELOG.json +19 -19
- package/CHANGELOG.md +12 -12
- package/dist/index.d.ts +272 -0
- package/lib/Button.js +2 -0
- package/lib/Button.js.map +1 -0
- package/lib/CompoundButton.js +2 -0
- package/lib/CompoundButton.js.map +1 -0
- package/lib/MenuButton.js +2 -0
- package/lib/MenuButton.js.map +1 -0
- package/lib/SplitButton.js +2 -0
- package/lib/SplitButton.js.map +1 -0
- package/lib/ToggleButton.js +2 -0
- package/lib/ToggleButton.js.map +1 -0
- package/lib/components/Button/Button.js +18 -0
- package/lib/components/Button/Button.js.map +1 -0
- package/lib/components/Button/Button.types.js +2 -0
- package/lib/components/Button/Button.types.js.map +1 -0
- package/lib/components/Button/index.js +5 -0
- package/lib/components/Button/index.js.map +1 -0
- package/lib/components/Button/renderButton.js +17 -0
- package/lib/components/Button/renderButton.js.map +1 -0
- package/lib/components/Button/useButton.js +50 -0
- package/lib/components/Button/useButton.js.map +1 -0
- package/lib/components/Button/useButtonStyles.styles.js +485 -0
- package/lib/components/Button/useButtonStyles.styles.js.map +1 -0
- package/lib/components/CompoundButton/CompoundButton.js +18 -0
- package/lib/components/CompoundButton/CompoundButton.js.map +1 -0
- package/lib/components/CompoundButton/CompoundButton.types.js +2 -0
- package/lib/components/CompoundButton/CompoundButton.types.js.map +1 -0
- package/lib/components/CompoundButton/index.js +6 -0
- package/lib/components/CompoundButton/index.js.map +1 -0
- package/lib/components/CompoundButton/renderCompoundButton.js +17 -0
- package/lib/components/CompoundButton/renderCompoundButton.js.map +1 -0
- package/lib/components/CompoundButton/useCompoundButton.js +34 -0
- package/lib/components/CompoundButton/useCompoundButton.js.map +1 -0
- package/lib/components/CompoundButton/useCompoundButtonStyles.styles.js +192 -0
- package/lib/components/CompoundButton/useCompoundButtonStyles.styles.js.map +1 -0
- package/lib/components/MenuButton/MenuButton.js +19 -0
- package/lib/components/MenuButton/MenuButton.js.map +1 -0
- package/lib/components/MenuButton/MenuButton.types.js +2 -0
- package/lib/components/MenuButton/MenuButton.types.js.map +1 -0
- package/lib/components/MenuButton/index.js +6 -0
- package/lib/components/MenuButton/index.js.map +1 -0
- package/lib/components/MenuButton/renderMenuButton.js +17 -0
- package/lib/components/MenuButton/renderMenuButton.js.map +1 -0
- package/lib/components/MenuButton/useMenuButton.js +34 -0
- package/lib/components/MenuButton/useMenuButton.js.map +1 -0
- package/lib/components/MenuButton/useMenuButtonStyles.styles.js +110 -0
- package/lib/components/MenuButton/useMenuButtonStyles.styles.js.map +1 -0
- package/lib/components/SplitButton/SplitButton.js +19 -0
- package/lib/components/SplitButton/SplitButton.js.map +1 -0
- package/lib/components/SplitButton/SplitButton.types.js +2 -0
- package/lib/components/SplitButton/SplitButton.types.js.map +1 -0
- package/lib/components/SplitButton/index.js +6 -0
- package/lib/components/SplitButton/index.js.map +1 -0
- package/lib/components/SplitButton/renderSplitButton.js +13 -0
- package/lib/components/SplitButton/renderSplitButton.js.map +1 -0
- package/lib/components/SplitButton/useSplitButton.js +77 -0
- package/lib/components/SplitButton/useSplitButton.js.map +1 -0
- package/lib/components/SplitButton/useSplitButtonStyles.styles.js +108 -0
- package/lib/components/SplitButton/useSplitButtonStyles.styles.js.map +1 -0
- package/lib/components/ToggleButton/ToggleButton.js +18 -0
- package/lib/components/ToggleButton/ToggleButton.js.map +1 -0
- package/lib/components/ToggleButton/ToggleButton.types.js +2 -0
- package/lib/components/ToggleButton/ToggleButton.types.js.map +1 -0
- package/lib/components/ToggleButton/index.js +6 -0
- package/lib/components/ToggleButton/index.js.map +1 -0
- package/lib/components/ToggleButton/renderToggleButton.js +2 -0
- package/lib/components/ToggleButton/renderToggleButton.js.map +1 -0
- package/lib/components/ToggleButton/useToggleButton.js +14 -0
- package/lib/components/ToggleButton/useToggleButton.js.map +1 -0
- package/lib/components/ToggleButton/useToggleButtonStyles.styles.js +386 -0
- package/lib/components/ToggleButton/useToggleButtonStyles.styles.js.map +1 -0
- package/lib/contexts/ButtonContext.js +15 -0
- package/lib/contexts/ButtonContext.js.map +1 -0
- package/lib/contexts/index.js +2 -0
- package/lib/contexts/index.js.map +1 -0
- package/lib/index.js +8 -0
- package/lib/index.js.map +1 -0
- package/lib/utils/index.js +2 -0
- package/lib/utils/index.js.map +1 -0
- package/lib/utils/useToggleState.js +38 -0
- package/lib/utils/useToggleState.js.map +1 -0
- package/package.json +9 -9
- package/.swcrc +0 -30
package/CHANGELOG.json
CHANGED
@@ -2,9 +2,9 @@
|
|
2
2
|
"name": "@fluentui/react-button",
|
3
3
|
"entries": [
|
4
4
|
{
|
5
|
-
"date": "
|
6
|
-
"tag": "@fluentui/react-button_v0.0.0-nightly-
|
7
|
-
"version": "0.0.0-nightly-
|
5
|
+
"date": "Thu, 04 May 2023 04:24:59 GMT",
|
6
|
+
"tag": "@fluentui/react-button_v0.0.0-nightly-20230504-0417.1",
|
7
|
+
"version": "0.0.0-nightly-20230504-0417.1",
|
8
8
|
"comments": {
|
9
9
|
"prerelease": [
|
10
10
|
{
|
@@ -16,50 +16,50 @@
|
|
16
16
|
{
|
17
17
|
"author": "beachball",
|
18
18
|
"package": "@fluentui/react-button",
|
19
|
-
"comment": "Bump @fluentui/keyboard-keys to v0.0.0-nightly-
|
20
|
-
"commit": "
|
19
|
+
"comment": "Bump @fluentui/keyboard-keys to v0.0.0-nightly-20230504-0417.1",
|
20
|
+
"commit": "433bf105e0be3c4383e246e823c6c1a56a6aea0f"
|
21
21
|
},
|
22
22
|
{
|
23
23
|
"author": "beachball",
|
24
24
|
"package": "@fluentui/react-button",
|
25
|
-
"comment": "Bump @fluentui/react-aria to v0.0.0-nightly-
|
26
|
-
"commit": "
|
25
|
+
"comment": "Bump @fluentui/react-aria to v0.0.0-nightly-20230504-0417.1",
|
26
|
+
"commit": "433bf105e0be3c4383e246e823c6c1a56a6aea0f"
|
27
27
|
},
|
28
28
|
{
|
29
29
|
"author": "beachball",
|
30
30
|
"package": "@fluentui/react-button",
|
31
|
-
"comment": "Bump @fluentui/react-jsx-runtime to v0.0.0-nightly-
|
32
|
-
"commit": "
|
31
|
+
"comment": "Bump @fluentui/react-jsx-runtime to v0.0.0-nightly-20230504-0417.1",
|
32
|
+
"commit": "433bf105e0be3c4383e246e823c6c1a56a6aea0f"
|
33
33
|
},
|
34
34
|
{
|
35
35
|
"author": "beachball",
|
36
36
|
"package": "@fluentui/react-button",
|
37
|
-
"comment": "Bump @fluentui/react-shared-contexts to v0.0.0-nightly-
|
38
|
-
"commit": "
|
37
|
+
"comment": "Bump @fluentui/react-shared-contexts to v0.0.0-nightly-20230504-0417.1",
|
38
|
+
"commit": "433bf105e0be3c4383e246e823c6c1a56a6aea0f"
|
39
39
|
},
|
40
40
|
{
|
41
41
|
"author": "beachball",
|
42
42
|
"package": "@fluentui/react-button",
|
43
|
-
"comment": "Bump @fluentui/react-tabster to v0.0.0-nightly-
|
44
|
-
"commit": "
|
43
|
+
"comment": "Bump @fluentui/react-tabster to v0.0.0-nightly-20230504-0417.1",
|
44
|
+
"commit": "433bf105e0be3c4383e246e823c6c1a56a6aea0f"
|
45
45
|
},
|
46
46
|
{
|
47
47
|
"author": "beachball",
|
48
48
|
"package": "@fluentui/react-button",
|
49
|
-
"comment": "Bump @fluentui/react-theme to v0.0.0-nightly-
|
50
|
-
"commit": "
|
49
|
+
"comment": "Bump @fluentui/react-theme to v0.0.0-nightly-20230504-0417.1",
|
50
|
+
"commit": "433bf105e0be3c4383e246e823c6c1a56a6aea0f"
|
51
51
|
},
|
52
52
|
{
|
53
53
|
"author": "beachball",
|
54
54
|
"package": "@fluentui/react-button",
|
55
|
-
"comment": "Bump @fluentui/react-utilities to v0.0.0-nightly-
|
56
|
-
"commit": "
|
55
|
+
"comment": "Bump @fluentui/react-utilities to v0.0.0-nightly-20230504-0417.1",
|
56
|
+
"commit": "433bf105e0be3c4383e246e823c6c1a56a6aea0f"
|
57
57
|
},
|
58
58
|
{
|
59
59
|
"author": "beachball",
|
60
60
|
"package": "@fluentui/react-button",
|
61
|
-
"comment": "Bump @fluentui/react-conformance-griffel to v0.0.0-nightly-
|
62
|
-
"commit": "
|
61
|
+
"comment": "Bump @fluentui/react-conformance-griffel to v0.0.0-nightly-20230504-0417.1",
|
62
|
+
"commit": "433bf105e0be3c4383e246e823c6c1a56a6aea0f"
|
63
63
|
}
|
64
64
|
]
|
65
65
|
}
|
package/CHANGELOG.md
CHANGED
@@ -1,25 +1,25 @@
|
|
1
1
|
# Change Log - @fluentui/react-button
|
2
2
|
|
3
|
-
This log was last generated on
|
3
|
+
This log was last generated on Thu, 04 May 2023 04:24:59 GMT and should not be manually modified.
|
4
4
|
|
5
5
|
<!-- Start content -->
|
6
6
|
|
7
|
-
## [0.0.0-nightly-
|
7
|
+
## [0.0.0-nightly-20230504-0417.1](https://github.com/microsoft/fluentui/tree/@fluentui/react-button_v0.0.0-nightly-20230504-0417.1)
|
8
8
|
|
9
|
-
|
10
|
-
[Compare changes](https://github.com/microsoft/fluentui/compare/@fluentui/react-button_v9.3.10..@fluentui/react-button_v0.0.0-nightly-
|
9
|
+
Thu, 04 May 2023 04:24:59 GMT
|
10
|
+
[Compare changes](https://github.com/microsoft/fluentui/compare/@fluentui/react-button_v9.3.10..@fluentui/react-button_v0.0.0-nightly-20230504-0417.1)
|
11
11
|
|
12
12
|
### Changes
|
13
13
|
|
14
14
|
- Release nightly v9 ([commit](https://github.com/microsoft/fluentui/commit/not available) by fluentui-internal@service.microsoft.com)
|
15
|
-
- Bump @fluentui/keyboard-keys to v0.0.0-nightly-
|
16
|
-
- Bump @fluentui/react-aria to v0.0.0-nightly-
|
17
|
-
- Bump @fluentui/react-jsx-runtime to v0.0.0-nightly-
|
18
|
-
- Bump @fluentui/react-shared-contexts to v0.0.0-nightly-
|
19
|
-
- Bump @fluentui/react-tabster to v0.0.0-nightly-
|
20
|
-
- Bump @fluentui/react-theme to v0.0.0-nightly-
|
21
|
-
- Bump @fluentui/react-utilities to v0.0.0-nightly-
|
22
|
-
- Bump @fluentui/react-conformance-griffel to v0.0.0-nightly-
|
15
|
+
- Bump @fluentui/keyboard-keys to v0.0.0-nightly-20230504-0417.1 ([commit](https://github.com/microsoft/fluentui/commit/433bf105e0be3c4383e246e823c6c1a56a6aea0f) by beachball)
|
16
|
+
- Bump @fluentui/react-aria to v0.0.0-nightly-20230504-0417.1 ([commit](https://github.com/microsoft/fluentui/commit/433bf105e0be3c4383e246e823c6c1a56a6aea0f) by beachball)
|
17
|
+
- Bump @fluentui/react-jsx-runtime to v0.0.0-nightly-20230504-0417.1 ([commit](https://github.com/microsoft/fluentui/commit/433bf105e0be3c4383e246e823c6c1a56a6aea0f) by beachball)
|
18
|
+
- Bump @fluentui/react-shared-contexts to v0.0.0-nightly-20230504-0417.1 ([commit](https://github.com/microsoft/fluentui/commit/433bf105e0be3c4383e246e823c6c1a56a6aea0f) by beachball)
|
19
|
+
- Bump @fluentui/react-tabster to v0.0.0-nightly-20230504-0417.1 ([commit](https://github.com/microsoft/fluentui/commit/433bf105e0be3c4383e246e823c6c1a56a6aea0f) by beachball)
|
20
|
+
- Bump @fluentui/react-theme to v0.0.0-nightly-20230504-0417.1 ([commit](https://github.com/microsoft/fluentui/commit/433bf105e0be3c4383e246e823c6c1a56a6aea0f) by beachball)
|
21
|
+
- Bump @fluentui/react-utilities to v0.0.0-nightly-20230504-0417.1 ([commit](https://github.com/microsoft/fluentui/commit/433bf105e0be3c4383e246e823c6c1a56a6aea0f) by beachball)
|
22
|
+
- Bump @fluentui/react-conformance-griffel to v0.0.0-nightly-20230504-0417.1 ([commit](https://github.com/microsoft/fluentui/commit/433bf105e0be3c4383e246e823c6c1a56a6aea0f) by beachball)
|
23
23
|
|
24
24
|
## [9.3.10](https://github.com/microsoft/fluentui/tree/@fluentui/react-button_v9.3.10)
|
25
25
|
|
package/dist/index.d.ts
ADDED
@@ -0,0 +1,272 @@
|
|
1
|
+
/// <reference types="react" />
|
2
|
+
|
3
|
+
import type { ARIAButtonSlotProps } from '@fluentui/react-aria';
|
4
|
+
import type { ComponentProps } from '@fluentui/react-utilities';
|
5
|
+
import type { ComponentState } from '@fluentui/react-utilities';
|
6
|
+
import { ForwardRefComponent } from '@fluentui/react-utilities';
|
7
|
+
import * as React_2 from 'react';
|
8
|
+
import type { Slot } from '@fluentui/react-utilities';
|
9
|
+
import type { SlotClassNames } from '@fluentui/react-utilities';
|
10
|
+
|
11
|
+
/**
|
12
|
+
* Buttons give people a way to trigger an action.
|
13
|
+
*/
|
14
|
+
export declare const Button: ForwardRefComponent<ButtonProps>;
|
15
|
+
|
16
|
+
export declare const buttonClassNames: SlotClassNames<ButtonSlots>;
|
17
|
+
|
18
|
+
/**
|
19
|
+
* @internal
|
20
|
+
* Internal context provider used to update default values between internal components
|
21
|
+
*/
|
22
|
+
export declare const ButtonContextProvider: React_2.Provider<ButtonContextValue | undefined>;
|
23
|
+
|
24
|
+
/**
|
25
|
+
* @internal
|
26
|
+
* Internal context value used to update default values between internal components
|
27
|
+
*/
|
28
|
+
export declare interface ButtonContextValue {
|
29
|
+
size?: ButtonSize;
|
30
|
+
}
|
31
|
+
|
32
|
+
export declare type ButtonProps = ComponentProps<ButtonSlots> & {
|
33
|
+
/**
|
34
|
+
* A button can have its content and borders styled for greater emphasis or to be subtle.
|
35
|
+
* - 'secondary' (default): Gives emphasis to the button in such a way that it indicates a secondary action.
|
36
|
+
* - 'primary': Emphasizes the button as a primary action.
|
37
|
+
* - 'outline': Removes background styling.
|
38
|
+
* - 'subtle': Minimizes emphasis to blend into the background until hovered or focused.
|
39
|
+
* - 'transparent': Removes background and border styling.
|
40
|
+
*
|
41
|
+
* @default 'secondary'
|
42
|
+
*/
|
43
|
+
appearance?: 'secondary' | 'primary' | 'outline' | 'subtle' | 'transparent';
|
44
|
+
/**
|
45
|
+
* When set, allows the button to be focusable even when it has been disabled. This is used in scenarios where it
|
46
|
+
* is important to keep a consistent tab order for screen reader and keyboard users. The primary example of this
|
47
|
+
* pattern is when the disabled button is in a menu or a commandbar and is seldom used for standalone buttons.
|
48
|
+
*
|
49
|
+
* @default false
|
50
|
+
*/
|
51
|
+
disabledFocusable?: boolean;
|
52
|
+
/**
|
53
|
+
* A button can show that it cannot be interacted with.
|
54
|
+
*
|
55
|
+
* @default false
|
56
|
+
*/
|
57
|
+
disabled?: boolean;
|
58
|
+
/**
|
59
|
+
* A button can format its icon to appear before or after its content.
|
60
|
+
*
|
61
|
+
* @default 'before'
|
62
|
+
*/
|
63
|
+
iconPosition?: 'before' | 'after';
|
64
|
+
/**
|
65
|
+
* A button can be rounded, circular, or square.
|
66
|
+
*
|
67
|
+
* @default 'rounded'
|
68
|
+
*/
|
69
|
+
shape?: 'rounded' | 'circular' | 'square';
|
70
|
+
/**
|
71
|
+
* A button supports different sizes.
|
72
|
+
*
|
73
|
+
* @default 'medium'
|
74
|
+
*/
|
75
|
+
size?: ButtonSize;
|
76
|
+
};
|
77
|
+
|
78
|
+
/**
|
79
|
+
* A button supports different sizes.
|
80
|
+
*/
|
81
|
+
declare type ButtonSize = 'small' | 'medium' | 'large';
|
82
|
+
|
83
|
+
export declare type ButtonSlots = {
|
84
|
+
/**
|
85
|
+
* Root of the component that renders as either a `<button>` tag or an `<a>` tag.
|
86
|
+
*/
|
87
|
+
root: NonNullable<Slot<ARIAButtonSlotProps<'a'>>>;
|
88
|
+
/**
|
89
|
+
* Icon that renders either before or after the `children` as specified by the `iconPosition` prop.
|
90
|
+
*/
|
91
|
+
icon?: Slot<'span'>;
|
92
|
+
};
|
93
|
+
|
94
|
+
export declare type ButtonState = ComponentState<ButtonSlots> & Required<Pick<ButtonProps, 'appearance' | 'disabledFocusable' | 'disabled' | 'iconPosition' | 'shape' | 'size'>> & {
|
95
|
+
/**
|
96
|
+
* A button can contain only an icon.
|
97
|
+
*
|
98
|
+
* @default false
|
99
|
+
*/
|
100
|
+
iconOnly: boolean;
|
101
|
+
};
|
102
|
+
|
103
|
+
/**
|
104
|
+
* CompoundButtons are buttons that can have secondary content that adds extra information to the user.
|
105
|
+
*/
|
106
|
+
export declare const CompoundButton: ForwardRefComponent<CompoundButtonProps>;
|
107
|
+
|
108
|
+
export declare const compoundButtonClassNames: SlotClassNames<CompoundButtonSlots>;
|
109
|
+
|
110
|
+
export declare type CompoundButtonProps = ComponentProps<Partial<CompoundButtonSlots>> & Pick<ButtonProps, 'appearance' | 'disabledFocusable' | 'disabled' | 'iconPosition' | 'shape' | 'size'>;
|
111
|
+
|
112
|
+
export declare type CompoundButtonSlots = ButtonSlots & {
|
113
|
+
/**
|
114
|
+
* Second line of text that describes the action this button takes.
|
115
|
+
*/
|
116
|
+
secondaryContent?: Slot<'span'>;
|
117
|
+
/**
|
118
|
+
* Container that wraps the children and the secondaryContent slot.
|
119
|
+
*/
|
120
|
+
contentContainer: NonNullable<Slot<'span'>>;
|
121
|
+
};
|
122
|
+
|
123
|
+
export declare type CompoundButtonState = ComponentState<CompoundButtonSlots> & Omit<ButtonState, keyof ButtonSlots | 'components'>;
|
124
|
+
|
125
|
+
/**
|
126
|
+
* MenuButtons are buttons that have a chevron icon after the button contents and are usually clicked to open/close
|
127
|
+
* menus.
|
128
|
+
*/
|
129
|
+
export declare const MenuButton: ForwardRefComponent<MenuButtonProps>;
|
130
|
+
|
131
|
+
export declare const menuButtonClassNames: SlotClassNames<MenuButtonSlots>;
|
132
|
+
|
133
|
+
export declare type MenuButtonProps = ComponentProps<MenuButtonSlots> & Pick<ButtonProps, 'appearance' | 'disabledFocusable' | 'disabled' | 'shape' | 'size'>;
|
134
|
+
|
135
|
+
export declare type MenuButtonSlots = ButtonSlots & {
|
136
|
+
/**
|
137
|
+
* Menu icon that indicates that this button has a menu that can be expanded.
|
138
|
+
*/
|
139
|
+
menuIcon?: Slot<'span'>;
|
140
|
+
};
|
141
|
+
|
142
|
+
export declare type MenuButtonState = ComponentState<MenuButtonSlots> & Omit<ButtonState, keyof ButtonSlots | 'components' | 'iconPosition'>;
|
143
|
+
|
144
|
+
/**
|
145
|
+
* Renders a Button component by passing the state defined props to the appropriate slots.
|
146
|
+
*/
|
147
|
+
declare const renderButton_unstable: (state: ButtonState) => JSX.Element;
|
148
|
+
export { renderButton_unstable }
|
149
|
+
export { renderButton_unstable as renderToggleButton_unstable }
|
150
|
+
|
151
|
+
/**
|
152
|
+
* Renders a CompoundButton component by passing the state defined props to the appropriate slots.
|
153
|
+
*/
|
154
|
+
export declare const renderCompoundButton_unstable: (state: CompoundButtonState) => JSX.Element;
|
155
|
+
|
156
|
+
/**
|
157
|
+
* Renders a MenuButton component by passing the state defined props to the appropriate slots.
|
158
|
+
*/
|
159
|
+
export declare const renderMenuButton_unstable: (state: MenuButtonState) => JSX.Element;
|
160
|
+
|
161
|
+
/**
|
162
|
+
* Renders a SplitButton component by passing the state defined props to the appropriate slots.
|
163
|
+
*/
|
164
|
+
export declare const renderSplitButton_unstable: (state: SplitButtonState) => JSX.Element;
|
165
|
+
|
166
|
+
/**
|
167
|
+
* SplitButtons are a grouping of two interactive surfaces where interacting with the first one triggers a primary
|
168
|
+
* action, while interacting with the second one opens a menu with secondary actions.
|
169
|
+
*/
|
170
|
+
export declare const SplitButton: ForwardRefComponent<SplitButtonProps>;
|
171
|
+
|
172
|
+
export declare const splitButtonClassNames: SlotClassNames<SplitButtonSlots>;
|
173
|
+
|
174
|
+
export declare type SplitButtonProps = ComponentProps<SplitButtonSlots> & Omit<ButtonProps, 'root'> & Omit<MenuButtonProps, 'root'>;
|
175
|
+
|
176
|
+
export declare type SplitButtonSlots = {
|
177
|
+
/**
|
178
|
+
* Root of the component that wraps the primary action button and menu button.
|
179
|
+
*/
|
180
|
+
root: NonNullable<Slot<'div'>>;
|
181
|
+
/**
|
182
|
+
* Button that opens menu with secondary actions in SplitButton.
|
183
|
+
*/
|
184
|
+
menuButton?: Slot<typeof MenuButton>;
|
185
|
+
/**
|
186
|
+
* Button to perform primary action in SplitButton.
|
187
|
+
*/
|
188
|
+
primaryActionButton?: Slot<typeof Button>;
|
189
|
+
};
|
190
|
+
|
191
|
+
export declare type SplitButtonState = ComponentState<SplitButtonSlots> & Omit<ButtonState, 'components' | 'iconOnly' | 'root'> & Omit<MenuButtonState, 'components' | 'iconOnly' | 'root'>;
|
192
|
+
|
193
|
+
/**
|
194
|
+
* ToggleButtons are buttons that toggle between two defined states when triggered.
|
195
|
+
*/
|
196
|
+
export declare const ToggleButton: ForwardRefComponent<ToggleButtonProps>;
|
197
|
+
|
198
|
+
export declare const toggleButtonClassNames: SlotClassNames<ButtonSlots>;
|
199
|
+
|
200
|
+
export declare type ToggleButtonProps = ButtonProps & {
|
201
|
+
/**
|
202
|
+
* Defines whether the `ToggleButton` is initially in a checked state or not when rendered.
|
203
|
+
*
|
204
|
+
* @default false
|
205
|
+
*/
|
206
|
+
defaultChecked?: boolean;
|
207
|
+
/**
|
208
|
+
* Defines the controlled checked state of the `ToggleButton`.
|
209
|
+
* If passed, `ToggleButton` ignores the `defaultChecked` property.
|
210
|
+
* This should only be used if the checked state is to be controlled at a higher level and there is a plan to pass the
|
211
|
+
* correct value based on handling `onClick` events and re-rendering.
|
212
|
+
*
|
213
|
+
* @default false
|
214
|
+
*/
|
215
|
+
checked?: boolean;
|
216
|
+
};
|
217
|
+
|
218
|
+
export declare type ToggleButtonState = ButtonState & Required<Pick<ToggleButtonProps, 'checked'>>;
|
219
|
+
|
220
|
+
/**
|
221
|
+
* Given user props, defines default props for the Button, calls useButtonState, and returns processed state.
|
222
|
+
* @param props - User provided props to the Button component.
|
223
|
+
* @param ref - User provided ref to be passed to the Button component.
|
224
|
+
*/
|
225
|
+
export declare const useButton_unstable: (props: ButtonProps, ref: React_2.Ref<HTMLButtonElement | HTMLAnchorElement>) => ButtonState;
|
226
|
+
|
227
|
+
/**
|
228
|
+
* @internal
|
229
|
+
* Internal context hook used to update default values between internal components
|
230
|
+
*/
|
231
|
+
export declare const useButtonContext: () => ButtonContextValue;
|
232
|
+
|
233
|
+
export declare const useButtonStyles_unstable: (state: ButtonState) => ButtonState;
|
234
|
+
|
235
|
+
/**
|
236
|
+
* Given user props, defines default props for the CompoundButton, calls useButtonState, and returns processed state.
|
237
|
+
* @param props - User provided props to the CompoundButton component.
|
238
|
+
* @param ref - User provided ref to be passed to the CompoundButton component.
|
239
|
+
*/
|
240
|
+
export declare const useCompoundButton_unstable: ({ contentContainer, secondaryContent, ...props }: CompoundButtonProps, ref: React_2.Ref<HTMLButtonElement | HTMLAnchorElement>) => CompoundButtonState;
|
241
|
+
|
242
|
+
export declare const useCompoundButtonStyles_unstable: (state: CompoundButtonState) => CompoundButtonState;
|
243
|
+
|
244
|
+
/**
|
245
|
+
* Given user props, returns the final state for a MenuButton.
|
246
|
+
*/
|
247
|
+
export declare const useMenuButton_unstable: ({ menuIcon, ...props }: MenuButtonProps, ref: React_2.Ref<HTMLButtonElement | HTMLAnchorElement>) => MenuButtonState;
|
248
|
+
|
249
|
+
export declare const useMenuButtonStyles_unstable: (state: MenuButtonState) => MenuButtonState;
|
250
|
+
|
251
|
+
/**
|
252
|
+
* Given user props, defines default props for the SplitButton and returns processed state.
|
253
|
+
* @param props - User provided props to the SplitButton component.
|
254
|
+
* @param ref - User provided ref to be passed to the SplitButton component.
|
255
|
+
*/
|
256
|
+
export declare const useSplitButton_unstable: (props: SplitButtonProps, ref: React_2.Ref<HTMLButtonElement | HTMLAnchorElement>) => SplitButtonState;
|
257
|
+
|
258
|
+
export declare const useSplitButtonStyles_unstable: (state: SplitButtonState) => SplitButtonState;
|
259
|
+
|
260
|
+
/**
|
261
|
+
* Given user props, defines default props for the ToggleButton, calls useButtonState and useChecked, and returns
|
262
|
+
* processed state.
|
263
|
+
* @param props - User provided props to the ToggleButton component.
|
264
|
+
* @param ref - User provided ref to be passed to the ToggleButton component.
|
265
|
+
*/
|
266
|
+
export declare const useToggleButton_unstable: (props: ToggleButtonProps, ref: React_2.Ref<HTMLButtonElement | HTMLAnchorElement>) => ToggleButtonState;
|
267
|
+
|
268
|
+
export declare const useToggleButtonStyles_unstable: (state: ToggleButtonState) => ToggleButtonState;
|
269
|
+
|
270
|
+
export declare function useToggleState<TToggleButtonProps extends Pick<ToggleButtonProps, 'checked' | 'defaultChecked' | 'disabled' | 'disabledFocusable'>, TButtonState extends Pick<ButtonState, 'root'>, TToggleButtonState extends Pick<ToggleButtonState, 'checked' | 'root'>>(props: TToggleButtonProps, state: TButtonState): TToggleButtonState;
|
271
|
+
|
272
|
+
export { }
|
package/lib/Button.js
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"names":[],"sources":["../src/Button.tsx"],"sourcesContent":["export * from './components/Button/index';\n"],"mappings":"AAAA,cAAc"}
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"names":[],"sources":["../src/CompoundButton.ts"],"sourcesContent":["export * from './components/CompoundButton/index';\n"],"mappings":"AAAA,cAAc"}
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"names":[],"sources":["../src/MenuButton.ts"],"sourcesContent":["export * from './components/MenuButton/index';\n"],"mappings":"AAAA,cAAc"}
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"names":[],"sources":["../src/SplitButton.ts"],"sourcesContent":["export * from './components/SplitButton/index';\n"],"mappings":"AAAA,cAAc"}
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"names":[],"sources":["../src/ToggleButton.ts"],"sourcesContent":["export * from './components/ToggleButton/index';\n"],"mappings":"AAAA,cAAc"}
|
@@ -0,0 +1,18 @@
|
|
1
|
+
import * as React from 'react';
|
2
|
+
import { renderButton_unstable } from './renderButton';
|
3
|
+
import { useButton_unstable } from './useButton';
|
4
|
+
import { useButtonStyles_unstable } from './useButtonStyles.styles';
|
5
|
+
import { useCustomStyleHook_unstable } from '@fluentui/react-shared-contexts';
|
6
|
+
/**
|
7
|
+
* Buttons give people a way to trigger an action.
|
8
|
+
*/
|
9
|
+
export const Button = /*#__PURE__*/React.forwardRef((props, ref) => {
|
10
|
+
const state = useButton_unstable(props, ref);
|
11
|
+
useButtonStyles_unstable(state);
|
12
|
+
useCustomStyleHook_unstable('useButtonStyles_unstable')(state);
|
13
|
+
return renderButton_unstable(state);
|
14
|
+
// Casting is required due to lack of distributive union to support unions on @types/react
|
15
|
+
});
|
16
|
+
|
17
|
+
Button.displayName = 'Button';
|
18
|
+
//# sourceMappingURL=Button.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"names":["React","renderButton_unstable","useButton_unstable","useButtonStyles_unstable","useCustomStyleHook_unstable","Button","forwardRef","props","ref","state","displayName"],"sources":["../../../src/components/Button/Button.tsx"],"sourcesContent":["import * as React from 'react';\nimport { renderButton_unstable } from './renderButton';\nimport { useButton_unstable } from './useButton';\nimport { useButtonStyles_unstable } from './useButtonStyles.styles';\nimport type { ButtonProps } from './Button.types';\nimport type { ForwardRefComponent } from '@fluentui/react-utilities';\nimport { useCustomStyleHook_unstable } from '@fluentui/react-shared-contexts';\n\n/**\n * Buttons give people a way to trigger an action.\n */\nexport const Button: ForwardRefComponent<ButtonProps> = React.forwardRef((props, ref) => {\n const state = useButton_unstable(props, ref);\n\n useButtonStyles_unstable(state);\n\n useCustomStyleHook_unstable('useButtonStyles_unstable')(state);\n\n return renderButton_unstable(state);\n // Casting is required due to lack of distributive union to support unions on @types/react\n}) as ForwardRefComponent<ButtonProps>;\n\nButton.displayName = 'Button';\n"],"mappings":"AAAA,YAAYA,KAAA,MAAW;AACvB,SAASC,qBAAqB,QAAQ;AACtC,SAASC,kBAAkB,QAAQ;AACnC,SAASC,wBAAwB,QAAQ;AAGzC,SAASC,2BAA2B,QAAQ;AAE5C;;;AAGA,OAAO,MAAMC,MAAA,gBAA2CL,KAAA,CAAMM,UAAU,CAAC,CAACC,KAAA,EAAOC,GAAA,KAAQ;EACvF,MAAMC,KAAA,GAAQP,kBAAA,CAAmBK,KAAA,EAAOC,GAAA;EAExCL,wBAAA,CAAyBM,KAAA;EAEzBL,2BAAA,CAA4B,4BAA4BK,KAAA;EAExD,OAAOR,qBAAA,CAAsBQ,KAAA;EAC7B;AACF;;AAEAJ,MAAA,CAAOK,WAAW,GAAG"}
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"names":[],"sources":["../../../src/components/Button/Button.types.ts"],"sourcesContent":["import type { ARIAButtonSlotProps } from '@fluentui/react-aria';\nimport type { ComponentProps, ComponentState, Slot } from '@fluentui/react-utilities';\n\nexport type ButtonSlots = {\n /**\n * Root of the component that renders as either a `<button>` tag or an `<a>` tag.\n */\n root: NonNullable<Slot<ARIAButtonSlotProps<'a'>>>;\n\n /**\n * Icon that renders either before or after the `children` as specified by the `iconPosition` prop.\n */\n icon?: Slot<'span'>;\n};\n\n/**\n * A button supports different sizes.\n */\nexport type ButtonSize = 'small' | 'medium' | 'large';\n\nexport type ButtonProps = ComponentProps<ButtonSlots> & {\n /**\n * A button can have its content and borders styled for greater emphasis or to be subtle.\n * - 'secondary' (default): Gives emphasis to the button in such a way that it indicates a secondary action.\n * - 'primary': Emphasizes the button as a primary action.\n * - 'outline': Removes background styling.\n * - 'subtle': Minimizes emphasis to blend into the background until hovered or focused.\n * - 'transparent': Removes background and border styling.\n *\n * @default 'secondary'\n */\n appearance?: 'secondary' | 'primary' | 'outline' | 'subtle' | 'transparent';\n\n /**\n * When set, allows the button to be focusable even when it has been disabled. This is used in scenarios where it\n * is important to keep a consistent tab order for screen reader and keyboard users. The primary example of this\n * pattern is when the disabled button is in a menu or a commandbar and is seldom used for standalone buttons.\n *\n * @default false\n */\n disabledFocusable?: boolean;\n\n /**\n * A button can show that it cannot be interacted with.\n *\n * @default false\n */\n disabled?: boolean;\n\n /**\n * A button can format its icon to appear before or after its content.\n *\n * @default 'before'\n */\n iconPosition?: 'before' | 'after';\n\n /**\n * A button can be rounded, circular, or square.\n *\n * @default 'rounded'\n */\n shape?: 'rounded' | 'circular' | 'square';\n\n /**\n * A button supports different sizes.\n *\n * @default 'medium'\n */\n size?: ButtonSize;\n};\n\nexport type ButtonState = ComponentState<ButtonSlots> &\n Required<Pick<ButtonProps, 'appearance' | 'disabledFocusable' | 'disabled' | 'iconPosition' | 'shape' | 'size'>> & {\n /**\n * A button can contain only an icon.\n *\n * @default false\n */\n iconOnly: boolean;\n };\n"],"mappings":"AAAA"}
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"names":["buttonClassNames","useButtonStyles_unstable"],"sources":["../../../src/components/Button/index.ts"],"sourcesContent":["export * from './Button';\n// Explicit exports to omit ButtonCommons\nexport type { ButtonProps, ButtonSlots, ButtonState } from './Button.types';\nexport * from './renderButton';\nexport * from './useButton';\nexport { buttonClassNames, useButtonStyles_unstable } from './useButtonStyles.styles';\n"],"mappings":"AAAA,cAAc;AAGd,cAAc;AACd,cAAc;AACd,SAASA,gBAAgB,EAAEC,wBAAwB,QAAQ"}
|
@@ -0,0 +1,17 @@
|
|
1
|
+
/** @jsxRuntime classic */ /** @jsx createElement */import { createElement } from '@fluentui/react-jsx-runtime';
|
2
|
+
import { getSlotsNext } from '@fluentui/react-utilities';
|
3
|
+
/**
|
4
|
+
* Renders a Button component by passing the state defined props to the appropriate slots.
|
5
|
+
*/
|
6
|
+
export const renderButton_unstable = state => {
|
7
|
+
const {
|
8
|
+
slots,
|
9
|
+
slotProps
|
10
|
+
} = getSlotsNext(state);
|
11
|
+
const {
|
12
|
+
iconOnly,
|
13
|
+
iconPosition
|
14
|
+
} = state;
|
15
|
+
return /*#__PURE__*/createElement(slots.root, slotProps.root, iconPosition !== 'after' && slots.icon && /*#__PURE__*/createElement(slots.icon, slotProps.icon), !iconOnly && state.root.children, iconPosition === 'after' && slots.icon && /*#__PURE__*/createElement(slots.icon, slotProps.icon));
|
16
|
+
};
|
17
|
+
//# sourceMappingURL=renderButton.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"names":["createElement","getSlotsNext","renderButton_unstable","state","slots","slotProps","iconOnly","iconPosition","root","icon","children"],"sources":["../../../src/components/Button/renderButton.tsx"],"sourcesContent":["/** @jsxRuntime classic */\n/** @jsx createElement */\n\nimport { createElement } from '@fluentui/react-jsx-runtime';\n\nimport { getSlotsNext } from '@fluentui/react-utilities';\nimport type { ButtonSlots, ButtonState } from './Button.types';\n\n/**\n * Renders a Button component by passing the state defined props to the appropriate slots.\n */\nexport const renderButton_unstable = (state: ButtonState) => {\n const { slots, slotProps } = getSlotsNext<ButtonSlots>(state);\n const { iconOnly, iconPosition } = state;\n\n return (\n <slots.root {...slotProps.root}>\n {iconPosition !== 'after' && slots.icon && <slots.icon {...slotProps.icon} />}\n {!iconOnly && state.root.children}\n {iconPosition === 'after' && slots.icon && <slots.icon {...slotProps.icon} />}\n </slots.root>\n );\n};\n"],"mappings":"AAAA,2BACA,yBAEA,SAASA,aAAa,QAAQ;AAE9B,SAASC,YAAY,QAAQ;AAG7B;;;AAGA,OAAO,MAAMC,qBAAA,GAAyBC,KAAA,IAAuB;EAC3D,MAAM;IAAEC,KAAA;IAAOC;EAAS,CAAE,GAAGJ,YAAA,CAA0BE,KAAA;EACvD,MAAM;IAAEG,QAAA;IAAUC;EAAY,CAAE,GAAGJ,KAAA;EAEnC,oBACEH,aAfJ,CAeKI,KAAA,CAAMI,IAAI,EAAKH,SAAA,CAAUG,IAAI,EAC3BD,YAAA,KAAiB,WAAWH,KAAA,CAAMK,IAAI,iBAAIT,aAhBjD,CAgBkDI,KAAA,CAAMK,IAAI,EAAKJ,SAAA,CAAUI,IAAI,GACxE,CAACH,QAAA,IAAYH,KAAA,CAAMK,IAAI,CAACE,QAAQ,EAChCH,YAAA,KAAiB,WAAWH,KAAA,CAAMK,IAAI,iBAAIT,aAlBjD,CAkBkDI,KAAA,CAAMK,IAAI,EAAKJ,SAAA,CAAUI,IAAI;AAG/E"}
|
@@ -0,0 +1,50 @@
|
|
1
|
+
import * as React from 'react';
|
2
|
+
import { useARIAButtonShorthand } from '@fluentui/react-aria';
|
3
|
+
import { getNativeElementProps, resolveShorthand } from '@fluentui/react-utilities';
|
4
|
+
import { useButtonContext } from '../../contexts/ButtonContext';
|
5
|
+
/**
|
6
|
+
* Given user props, defines default props for the Button, calls useButtonState, and returns processed state.
|
7
|
+
* @param props - User provided props to the Button component.
|
8
|
+
* @param ref - User provided ref to be passed to the Button component.
|
9
|
+
*/
|
10
|
+
export const useButton_unstable = (props, ref) => {
|
11
|
+
const {
|
12
|
+
size: contextSize
|
13
|
+
} = useButtonContext();
|
14
|
+
const {
|
15
|
+
appearance = 'secondary',
|
16
|
+
as = 'button',
|
17
|
+
disabled = false,
|
18
|
+
disabledFocusable = false,
|
19
|
+
icon,
|
20
|
+
iconPosition = 'before',
|
21
|
+
shape = 'rounded',
|
22
|
+
size = contextSize !== null && contextSize !== void 0 ? contextSize : 'medium'
|
23
|
+
} = props;
|
24
|
+
const iconShorthand = resolveShorthand(icon);
|
25
|
+
return {
|
26
|
+
// Props passed at the top-level
|
27
|
+
appearance,
|
28
|
+
disabled,
|
29
|
+
disabledFocusable,
|
30
|
+
iconPosition,
|
31
|
+
shape,
|
32
|
+
size,
|
33
|
+
// State calculated from a set of props
|
34
|
+
iconOnly: Boolean((iconShorthand === null || iconShorthand === void 0 ? void 0 : iconShorthand.children) && !props.children),
|
35
|
+
// Slots definition
|
36
|
+
components: {
|
37
|
+
root: 'button',
|
38
|
+
icon: 'span'
|
39
|
+
},
|
40
|
+
root: getNativeElementProps(as, useARIAButtonShorthand(props, {
|
41
|
+
required: true,
|
42
|
+
defaultProps: {
|
43
|
+
ref: ref,
|
44
|
+
type: 'button'
|
45
|
+
}
|
46
|
+
})),
|
47
|
+
icon: iconShorthand
|
48
|
+
};
|
49
|
+
};
|
50
|
+
//# sourceMappingURL=useButton.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"names":["React","useARIAButtonShorthand","getNativeElementProps","resolveShorthand","useButtonContext","useButton_unstable","props","ref","size","contextSize","appearance","as","disabled","disabledFocusable","icon","iconPosition","shape","iconShorthand","iconOnly","Boolean","children","components","root","required","defaultProps","type"],"sources":["../../../src/components/Button/useButton.ts"],"sourcesContent":["import * as React from 'react';\nimport { ARIAButtonSlotProps, useARIAButtonShorthand } from '@fluentui/react-aria';\nimport { getNativeElementProps, resolveShorthand } from '@fluentui/react-utilities';\nimport { useButtonContext } from '../../contexts/ButtonContext';\nimport type { ButtonProps, ButtonState } from './Button.types';\n\n/**\n * Given user props, defines default props for the Button, calls useButtonState, and returns processed state.\n * @param props - User provided props to the Button component.\n * @param ref - User provided ref to be passed to the Button component.\n */\nexport const useButton_unstable = (\n props: ButtonProps,\n ref: React.Ref<HTMLButtonElement | HTMLAnchorElement>,\n): ButtonState => {\n const { size: contextSize } = useButtonContext();\n const {\n appearance = 'secondary',\n as = 'button',\n disabled = false,\n disabledFocusable = false,\n icon,\n iconPosition = 'before',\n shape = 'rounded',\n size = contextSize ?? 'medium',\n } = props;\n const iconShorthand = resolveShorthand(icon);\n\n return {\n // Props passed at the top-level\n appearance,\n disabled,\n disabledFocusable,\n iconPosition,\n shape,\n size,\n\n // State calculated from a set of props\n iconOnly: Boolean(iconShorthand?.children && !props.children),\n\n // Slots definition\n components: {\n root: 'button',\n icon: 'span',\n },\n\n root: getNativeElementProps(\n as,\n useARIAButtonShorthand<ARIAButtonSlotProps<'a'>>(props, {\n required: true,\n defaultProps: {\n ref: ref as React.Ref<HTMLButtonElement & HTMLAnchorElement>,\n type: 'button',\n },\n }),\n ),\n icon: iconShorthand,\n };\n};\n"],"mappings":"AAAA,YAAYA,KAAA,MAAW;AACvB,SAA8BC,sBAAsB,QAAQ;AAC5D,SAASC,qBAAqB,EAAEC,gBAAgB,QAAQ;AACxD,SAASC,gBAAgB,QAAQ;AAGjC;;;;;AAKA,OAAO,MAAMC,kBAAA,GAAqBA,CAChCC,KAAA,EACAC,GAAA,KACgB;EAChB,MAAM;IAAEC,IAAA,EAAMC;EAAW,CAAE,GAAGL,gBAAA;EAC9B,MAAM;IACJM,UAAA,GAAa;IACbC,EAAA,GAAK;IACLC,QAAA,GAAW,KAAK;IAChBC,iBAAA,GAAoB,KAAK;IACzBC,IAAA;IACAC,YAAA,GAAe;IACfC,KAAA,GAAQ;IACRR,IAAA,GAAOC,WAAA,aAAAA,WAAA,cAAAA,WAAA,GAAe;EAAQ,CAC/B,GAAGH,KAAA;EACJ,MAAMW,aAAA,GAAgBd,gBAAA,CAAiBW,IAAA;EAEvC,OAAO;IACL;IACAJ,UAAA;IACAE,QAAA;IACAC,iBAAA;IACAE,YAAA;IACAC,KAAA;IACAR,IAAA;IAEA;IACAU,QAAA,EAAUC,OAAA,CAAQ,CAAAF,aAAA,aAAAA,aAAA,uBAAAA,aAAA,CAAeG,QAAQ,KAAI,CAACd,KAAA,CAAMc,QAAQ;IAE5D;IACAC,UAAA,EAAY;MACVC,IAAA,EAAM;MACNR,IAAA,EAAM;IACR;IAEAQ,IAAA,EAAMpB,qBAAA,CACJS,EAAA,EACAV,sBAAA,CAAiDK,KAAA,EAAO;MACtDiB,QAAA,EAAU,IAAI;MACdC,YAAA,EAAc;QACZjB,GAAA,EAAKA,GAAA;QACLkB,IAAA,EAAM;MACR;IACF;IAEFX,IAAA,EAAMG;EACR;AACF"}
|