@fluentui/react-button 9.0.0-rc.1 → 9.0.0-rc.12
Sign up to get free protection for your applications and to get access to all the features.
- package/CHANGELOG.json +549 -1
- package/CHANGELOG.md +321 -172
- package/README.md +80 -18
- package/dist/{react-button.d.ts → index.d.ts} +42 -37
- package/{lib → dist}/tsdoc-metadata.json +0 -0
- package/lib/Button.js.map +1 -1
- package/lib/CompoundButton.js.map +1 -1
- package/lib/MenuButton.js.map +1 -1
- package/lib/SplitButton.js.map +1 -1
- package/lib/ToggleButton.js.map +1 -1
- package/lib/components/Button/Button.js.map +1 -1
- package/lib/components/Button/Button.types.js.map +1 -1
- package/lib/components/Button/index.js +1 -1
- package/lib/components/Button/index.js.map +1 -1
- package/lib/components/Button/renderButton.js.map +1 -1
- package/lib/components/Button/useButton.js +1 -3
- package/lib/components/Button/useButton.js.map +1 -1
- package/lib/components/Button/useButtonStyles.js +162 -115
- package/lib/components/Button/useButtonStyles.js.map +1 -1
- package/lib/components/CompoundButton/CompoundButton.js.map +1 -1
- package/lib/components/CompoundButton/CompoundButton.types.js.map +1 -1
- package/lib/components/CompoundButton/index.js +1 -1
- package/lib/components/CompoundButton/index.js.map +1 -1
- package/lib/components/CompoundButton/renderCompoundButton.js.map +1 -1
- package/lib/components/CompoundButton/useCompoundButton.js +7 -2
- package/lib/components/CompoundButton/useCompoundButton.js.map +1 -1
- package/lib/components/CompoundButton/useCompoundButtonStyles.js +72 -55
- package/lib/components/CompoundButton/useCompoundButtonStyles.js.map +1 -1
- package/lib/components/MenuButton/MenuButton.js +2 -1
- package/lib/components/MenuButton/MenuButton.js.map +1 -1
- package/lib/components/MenuButton/MenuButton.types.js.map +1 -1
- package/lib/components/MenuButton/index.js +1 -1
- package/lib/components/MenuButton/index.js.map +1 -1
- package/lib/components/MenuButton/renderMenuButton.js.map +1 -1
- package/lib/components/MenuButton/useMenuButton.js.map +1 -1
- package/lib/components/MenuButton/useMenuButtonStyles.js +34 -14
- package/lib/components/MenuButton/useMenuButtonStyles.js.map +1 -1
- package/lib/components/SplitButton/SplitButton.js +1 -1
- package/lib/components/SplitButton/SplitButton.js.map +1 -1
- package/lib/components/SplitButton/SplitButton.types.js.map +1 -1
- package/lib/components/SplitButton/index.js +1 -1
- package/lib/components/SplitButton/index.js.map +1 -1
- package/lib/components/SplitButton/renderSplitButton.js.map +1 -1
- package/lib/components/SplitButton/useSplitButton.js +17 -8
- package/lib/components/SplitButton/useSplitButton.js.map +1 -1
- package/lib/components/SplitButton/useSplitButtonStyles.js +37 -34
- package/lib/components/SplitButton/useSplitButtonStyles.js.map +1 -1
- package/lib/components/ToggleButton/ToggleButton.js.map +1 -1
- package/lib/components/ToggleButton/ToggleButton.types.js.map +1 -1
- package/lib/components/ToggleButton/index.js +1 -1
- package/lib/components/ToggleButton/index.js.map +1 -1
- package/lib/components/ToggleButton/renderToggleButton.js.map +1 -1
- package/lib/components/ToggleButton/useToggleButton.js +3 -41
- package/lib/components/ToggleButton/useToggleButton.js.map +1 -1
- package/lib/components/ToggleButton/useToggleButtonStyles.js +122 -61
- package/lib/components/ToggleButton/useToggleButtonStyles.js.map +1 -1
- package/lib/index.js +6 -5
- package/lib/index.js.map +1 -1
- package/lib/utils/index.js +2 -0
- package/lib/utils/index.js.map +1 -0
- package/lib/utils/useToggleState.js +37 -0
- package/lib/utils/useToggleState.js.map +1 -0
- package/lib-commonjs/Button.js.map +1 -1
- package/lib-commonjs/CompoundButton.js.map +1 -1
- package/lib-commonjs/MenuButton.js.map +1 -1
- package/lib-commonjs/SplitButton.js.map +1 -1
- package/lib-commonjs/ToggleButton.js.map +1 -1
- package/lib-commonjs/components/Button/Button.js.map +1 -1
- package/lib-commonjs/components/Button/Button.types.js.map +1 -1
- package/lib-commonjs/components/Button/index.js +3 -3
- package/lib-commonjs/components/Button/index.js.map +1 -1
- package/lib-commonjs/components/Button/renderButton.js.map +1 -1
- package/lib-commonjs/components/Button/useButton.js +1 -3
- package/lib-commonjs/components/Button/useButton.js.map +1 -1
- package/lib-commonjs/components/Button/useButtonStyles.js +164 -116
- package/lib-commonjs/components/Button/useButtonStyles.js.map +1 -1
- package/lib-commonjs/components/CompoundButton/CompoundButton.js.map +1 -1
- package/lib-commonjs/components/CompoundButton/CompoundButton.types.js.map +1 -1
- package/lib-commonjs/components/CompoundButton/index.js +3 -3
- package/lib-commonjs/components/CompoundButton/index.js.map +1 -1
- package/lib-commonjs/components/CompoundButton/renderCompoundButton.js.map +1 -1
- package/lib-commonjs/components/CompoundButton/useCompoundButton.js +7 -2
- package/lib-commonjs/components/CompoundButton/useCompoundButton.js.map +1 -1
- package/lib-commonjs/components/CompoundButton/useCompoundButtonStyles.js +74 -57
- package/lib-commonjs/components/CompoundButton/useCompoundButtonStyles.js.map +1 -1
- package/lib-commonjs/components/MenuButton/MenuButton.js +2 -1
- package/lib-commonjs/components/MenuButton/MenuButton.js.map +1 -1
- package/lib-commonjs/components/MenuButton/MenuButton.types.js.map +1 -1
- package/lib-commonjs/components/MenuButton/index.js +3 -3
- package/lib-commonjs/components/MenuButton/index.js.map +1 -1
- package/lib-commonjs/components/MenuButton/renderMenuButton.js.map +1 -1
- package/lib-commonjs/components/MenuButton/useMenuButton.js.map +1 -1
- package/lib-commonjs/components/MenuButton/useMenuButtonStyles.js +36 -15
- package/lib-commonjs/components/MenuButton/useMenuButtonStyles.js.map +1 -1
- package/lib-commonjs/components/SplitButton/SplitButton.js +1 -1
- package/lib-commonjs/components/SplitButton/SplitButton.js.map +1 -1
- package/lib-commonjs/components/SplitButton/SplitButton.types.js.map +1 -1
- package/lib-commonjs/components/SplitButton/index.js +3 -3
- package/lib-commonjs/components/SplitButton/index.js.map +1 -1
- package/lib-commonjs/components/SplitButton/renderSplitButton.js.map +1 -1
- package/lib-commonjs/components/SplitButton/useSplitButton.js +16 -7
- package/lib-commonjs/components/SplitButton/useSplitButton.js.map +1 -1
- package/lib-commonjs/components/SplitButton/useSplitButtonStyles.js +38 -35
- package/lib-commonjs/components/SplitButton/useSplitButtonStyles.js.map +1 -1
- package/lib-commonjs/components/ToggleButton/ToggleButton.js.map +1 -1
- package/lib-commonjs/components/ToggleButton/ToggleButton.types.js.map +1 -1
- package/lib-commonjs/components/ToggleButton/index.js +3 -3
- package/lib-commonjs/components/ToggleButton/index.js.map +1 -1
- package/lib-commonjs/components/ToggleButton/renderToggleButton.js.map +1 -1
- package/lib-commonjs/components/ToggleButton/useToggleButton.js +3 -42
- package/lib-commonjs/components/ToggleButton/useToggleButton.js.map +1 -1
- package/lib-commonjs/components/ToggleButton/useToggleButtonStyles.js +127 -63
- package/lib-commonjs/components/ToggleButton/useToggleButtonStyles.js.map +1 -1
- package/lib-commonjs/index.js +169 -6
- package/lib-commonjs/index.js.map +1 -1
- package/lib-commonjs/utils/index.js +10 -0
- package/lib-commonjs/utils/index.js.map +1 -0
- package/lib-commonjs/utils/useToggleState.js +48 -0
- package/lib-commonjs/utils/useToggleState.js.map +1 -0
- package/package.json +20 -22
- package/dist/demo/index.html +0 -71
- package/dist/demo/react-dom.development.js +0 -21413
- package/dist/demo/react.development.js +0 -3155
- package/lib/Button.d.ts +0 -1
- package/lib/CompoundButton.d.ts +0 -1
- package/lib/MenuButton.d.ts +0 -1
- package/lib/SplitButton.d.ts +0 -1
- package/lib/ToggleButton.d.ts +0 -1
- package/lib/components/Button/Button.d.ts +0 -6
- package/lib/components/Button/Button.types.d.ts +0 -62
- package/lib/components/Button/index.d.ts +0 -5
- package/lib/components/Button/renderButton.d.ts +0 -5
- package/lib/components/Button/useButton.d.ts +0 -8
- package/lib/components/Button/useButtonStyles.d.ts +0 -3
- package/lib/components/CompoundButton/CompoundButton.d.ts +0 -6
- package/lib/components/CompoundButton/CompoundButton.types.d.ts +0 -14
- package/lib/components/CompoundButton/index.d.ts +0 -5
- package/lib/components/CompoundButton/renderCompoundButton.d.ts +0 -5
- package/lib/components/CompoundButton/useCompoundButton.d.ts +0 -8
- package/lib/components/CompoundButton/useCompoundButtonStyles.d.ts +0 -3
- package/lib/components/MenuButton/MenuButton.d.ts +0 -6
- package/lib/components/MenuButton/MenuButton.types.d.ts +0 -10
- package/lib/components/MenuButton/index.d.ts +0 -5
- package/lib/components/MenuButton/renderMenuButton.d.ts +0 -5
- package/lib/components/MenuButton/useMenuButton.d.ts +0 -6
- package/lib/components/MenuButton/useMenuButtonStyles.d.ts +0 -3
- package/lib/components/SplitButton/SplitButton.d.ts +0 -7
- package/lib/components/SplitButton/SplitButton.types.d.ts +0 -21
- package/lib/components/SplitButton/index.d.ts +0 -5
- package/lib/components/SplitButton/renderSplitButton.d.ts +0 -5
- package/lib/components/SplitButton/useSplitButton.d.ts +0 -8
- package/lib/components/SplitButton/useSplitButtonStyles.d.ts +0 -3
- package/lib/components/ToggleButton/ToggleButton.d.ts +0 -6
- package/lib/components/ToggleButton/ToggleButton.types.d.ts +0 -20
- package/lib/components/ToggleButton/index.d.ts +0 -5
- package/lib/components/ToggleButton/renderToggleButton.d.ts +0 -1
- package/lib/components/ToggleButton/useToggleButton.d.ts +0 -9
- package/lib/components/ToggleButton/useToggleButtonStyles.d.ts +0 -3
- package/lib/index.d.ts +0 -5
- package/lib-commonjs/Button.d.ts +0 -1
- package/lib-commonjs/CompoundButton.d.ts +0 -1
- package/lib-commonjs/MenuButton.d.ts +0 -1
- package/lib-commonjs/SplitButton.d.ts +0 -1
- package/lib-commonjs/ToggleButton.d.ts +0 -1
- package/lib-commonjs/components/Button/Button.d.ts +0 -6
- package/lib-commonjs/components/Button/Button.types.d.ts +0 -62
- package/lib-commonjs/components/Button/index.d.ts +0 -5
- package/lib-commonjs/components/Button/renderButton.d.ts +0 -5
- package/lib-commonjs/components/Button/useButton.d.ts +0 -8
- package/lib-commonjs/components/Button/useButtonStyles.d.ts +0 -3
- package/lib-commonjs/components/CompoundButton/CompoundButton.d.ts +0 -6
- package/lib-commonjs/components/CompoundButton/CompoundButton.types.d.ts +0 -14
- package/lib-commonjs/components/CompoundButton/index.d.ts +0 -5
- package/lib-commonjs/components/CompoundButton/renderCompoundButton.d.ts +0 -5
- package/lib-commonjs/components/CompoundButton/useCompoundButton.d.ts +0 -8
- package/lib-commonjs/components/CompoundButton/useCompoundButtonStyles.d.ts +0 -3
- package/lib-commonjs/components/MenuButton/MenuButton.d.ts +0 -6
- package/lib-commonjs/components/MenuButton/MenuButton.types.d.ts +0 -10
- package/lib-commonjs/components/MenuButton/index.d.ts +0 -5
- package/lib-commonjs/components/MenuButton/renderMenuButton.d.ts +0 -5
- package/lib-commonjs/components/MenuButton/useMenuButton.d.ts +0 -6
- package/lib-commonjs/components/MenuButton/useMenuButtonStyles.d.ts +0 -3
- package/lib-commonjs/components/SplitButton/SplitButton.d.ts +0 -7
- package/lib-commonjs/components/SplitButton/SplitButton.types.d.ts +0 -21
- package/lib-commonjs/components/SplitButton/index.d.ts +0 -5
- package/lib-commonjs/components/SplitButton/renderSplitButton.d.ts +0 -5
- package/lib-commonjs/components/SplitButton/useSplitButton.d.ts +0 -8
- package/lib-commonjs/components/SplitButton/useSplitButtonStyles.d.ts +0 -3
- package/lib-commonjs/components/ToggleButton/ToggleButton.d.ts +0 -6
- package/lib-commonjs/components/ToggleButton/ToggleButton.types.d.ts +0 -20
- package/lib-commonjs/components/ToggleButton/index.d.ts +0 -5
- package/lib-commonjs/components/ToggleButton/renderToggleButton.d.ts +0 -1
- package/lib-commonjs/components/ToggleButton/useToggleButton.d.ts +0 -9
- package/lib-commonjs/components/ToggleButton/useToggleButtonStyles.d.ts +0 -3
- package/lib-commonjs/index.d.ts +0 -5
package/README.md
CHANGED
@@ -2,35 +2,97 @@
|
|
2
2
|
|
3
3
|
**Button components for [Fluent UI React](https://developer.microsoft.com/en-us/fluentui)**
|
4
4
|
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
5
|
+
- Buttons enable users to trigger an action or event, such as submitting a form, opening a dialog, canceling an action, or performing a delete operation.
|
6
|
+
- CompoundButtons are buttons that can have secondary content that adds extra information to the user.
|
7
|
+
- MenuButtons are buttons that have a chevron icon after the button contents and are usually clicked to open/close menus.
|
8
|
+
- SplitButtons are a grouping of two interactive surfaces where interacting with the first one triggers a primary action, while interacting with the second one opens a menu with secondary actions.
|
9
|
+
- ToggleButtons are buttons that toggle between two defined states when triggered.
|
10
10
|
|
11
11
|
## Usage
|
12
12
|
|
13
13
|
To import Button:
|
14
14
|
|
15
15
|
```js
|
16
|
-
import { Button } from '@fluentui/react-
|
16
|
+
import { Button, CompoundButton, MenuButton, SplitButton, ToggleButton } from '@fluentui/react-components';
|
17
17
|
```
|
18
18
|
|
19
|
-
|
19
|
+
### Examples
|
20
20
|
|
21
|
-
|
22
|
-
|
21
|
+
### Button
|
22
|
+
|
23
|
+
```jsx
|
24
|
+
<Button>Submit</Button>
|
25
|
+
<Button icon={<SVGIcon />} />
|
26
|
+
<Button icon={<SVGIcon />}>Submit</Button>
|
27
|
+
<Button icon={<SVGIcon />} iconPosition="after">Submit</Button>
|
28
|
+
<Button appearance="primary">Submit</Button>
|
29
|
+
<Button disabled>Submit</Button>
|
30
|
+
<Button size="small">Submit</Button>
|
31
|
+
<Button size="large">Submit</Button>
|
23
32
|
```
|
24
33
|
|
25
|
-
###
|
34
|
+
### CompoundButton
|
26
35
|
|
27
36
|
```jsx
|
28
|
-
<
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
37
|
+
<CompoundButton icon={<CalendarMonth />} secondaryContent="Secondary content" {...props}>
|
38
|
+
Example
|
39
|
+
</CompoundButton>
|
40
|
+
```
|
41
|
+
|
42
|
+
### MenuButton
|
43
|
+
|
44
|
+
```jsx
|
45
|
+
<Menu>
|
46
|
+
<MenuTrigger>
|
47
|
+
<MenuButton>Example</MenuButton>
|
48
|
+
</MenuTrigger>
|
49
|
+
|
50
|
+
<MenuPopover>
|
51
|
+
<MenuList>
|
52
|
+
<MenuItem>Item a</MenuItem>
|
53
|
+
<MenuItem>Item b</MenuItem>
|
54
|
+
</MenuList>
|
55
|
+
</MenuPopover>
|
56
|
+
</Menu>
|
57
|
+
```
|
58
|
+
|
59
|
+
### SplitButton
|
60
|
+
|
61
|
+
```jsx
|
62
|
+
<Menu positioning="below-end">
|
63
|
+
<MenuTrigger>
|
64
|
+
{(triggerProps: MenuButtonProps) => <SplitButton menuButton={triggerProps}>Example</SplitButton>}
|
65
|
+
</MenuTrigger>
|
66
|
+
|
67
|
+
<MenuPopover>
|
68
|
+
<MenuList>
|
69
|
+
<MenuItem>Item a</MenuItem>
|
70
|
+
<MenuItem>Item b</MenuItem>
|
71
|
+
</MenuList>
|
72
|
+
</MenuPopover>
|
73
|
+
</Menu>
|
74
|
+
```
|
75
|
+
|
76
|
+
### ToggleButton
|
77
|
+
|
78
|
+
```jsx
|
79
|
+
<ToggleButton>Toggle volume</ToggleButton>
|
80
|
+
<ToggleButton defaultChecked={true}>Toggle volume</ToggleButton>
|
81
|
+
<ToggleButton checked={true}>Toggle volume</ToggleButton>
|
82
|
+
<ToggleButton checked={false}>Toggle volume</ToggleButton>
|
36
83
|
```
|
84
|
+
|
85
|
+
See [Fluent UI Storybook](https://aka.ms/fluentui-storybook) for more detailed usage examples.
|
86
|
+
|
87
|
+
Alternatively, run Storybook locally with:
|
88
|
+
|
89
|
+
1. `yarn start`
|
90
|
+
2. Select `react-button` from the list.
|
91
|
+
|
92
|
+
### Specification
|
93
|
+
|
94
|
+
See [SPEC.md](./src/components/Button/SPEC.md).
|
95
|
+
|
96
|
+
### Migration Guide
|
97
|
+
|
98
|
+
If you're upgrading to Fluent UI v9 see [MIGRATION.md](./src/components/Button/MIGRATION.md) for guidance on updating to the latest component implementations.
|
@@ -4,73 +4,76 @@ import type { ComponentState } from '@fluentui/react-utilities';
|
|
4
4
|
import { ForwardRefComponent } from '@fluentui/react-utilities';
|
5
5
|
import * as React_2 from 'react';
|
6
6
|
import type { Slot } from '@fluentui/react-utilities';
|
7
|
+
import type { SlotClassNames } from '@fluentui/react-utilities';
|
7
8
|
|
8
9
|
/**
|
9
10
|
* Buttons give people a way to trigger an action.
|
10
11
|
*/
|
11
12
|
export declare const Button: ForwardRefComponent<ButtonProps>;
|
12
13
|
|
13
|
-
export declare const
|
14
|
+
export declare const buttonClassNames: SlotClassNames<ButtonSlots>;
|
14
15
|
|
15
|
-
declare type
|
16
|
+
export declare type ButtonProps = ComponentProps<ButtonSlots> & {
|
16
17
|
/**
|
17
18
|
* A button can have its content and borders styled for greater emphasis or to be subtle.
|
19
|
+
* - 'secondary' (default): Gives emphasis to the button in such a way that it indicates a secondary action.
|
18
20
|
* - 'primary': Emphasizes the button as a primary action.
|
19
21
|
* - 'outline': Removes background styling.
|
20
22
|
* - 'subtle': Minimizes emphasis to blend into the background until hovered or focused.
|
21
23
|
* - 'transparent': Removes background and border styling.
|
24
|
+
*
|
25
|
+
* @default 'secondary'
|
22
26
|
*/
|
23
|
-
appearance?: 'primary' | 'outline' | 'subtle' | 'transparent';
|
24
|
-
/**
|
25
|
-
* A button can fill the width of its container.
|
26
|
-
* @default false
|
27
|
-
*/
|
28
|
-
block: boolean;
|
27
|
+
appearance?: 'secondary' | 'primary' | 'outline' | 'subtle' | 'transparent';
|
29
28
|
/**
|
30
29
|
* When set, allows the button to be focusable even when it has been disabled. This is used in scenarios where it
|
31
30
|
* is important to keep a consistent tab order for screen reader and keyboard users. The primary example of this
|
32
31
|
* pattern is when the disabled button is in a menu or a commandbar and is seldom used for standalone buttons.
|
32
|
+
*
|
33
33
|
* @default false
|
34
34
|
*/
|
35
|
-
disabledFocusable
|
35
|
+
disabledFocusable?: boolean;
|
36
36
|
/**
|
37
37
|
* A button can show that it cannot be interacted with.
|
38
|
+
*
|
38
39
|
* @default false
|
39
40
|
*/
|
40
|
-
disabled
|
41
|
+
disabled?: boolean;
|
41
42
|
/**
|
42
43
|
* A button can format its icon to appear before or after its content.
|
44
|
+
*
|
43
45
|
* @default 'before'
|
44
46
|
*/
|
45
47
|
iconPosition?: 'before' | 'after';
|
46
48
|
/**
|
47
49
|
* A button can be rounded, circular, or square.
|
50
|
+
*
|
48
51
|
* @default 'rounded'
|
49
52
|
*/
|
50
|
-
shape
|
53
|
+
shape?: 'rounded' | 'circular' | 'square';
|
51
54
|
/**
|
52
55
|
* A button supports different sizes.
|
56
|
+
*
|
53
57
|
* @default 'medium'
|
54
58
|
*/
|
55
|
-
size
|
59
|
+
size?: 'small' | 'medium' | 'large';
|
56
60
|
};
|
57
61
|
|
58
|
-
export declare type ButtonProps = ComponentProps<ButtonSlots> & Partial<ButtonCommons>;
|
59
|
-
|
60
62
|
export declare type ButtonSlots = {
|
61
63
|
/**
|
62
64
|
* Root of the component that renders as either a `<button>` tag or an `<a>` tag.
|
63
65
|
*/
|
64
|
-
root: Slot<ARIAButtonSlotProps
|
66
|
+
root: NonNullable<Slot<ARIAButtonSlotProps>>;
|
65
67
|
/**
|
66
68
|
* Icon that renders either before or after the `children` as specified by the `iconPosition` prop.
|
67
69
|
*/
|
68
70
|
icon?: Slot<'span'>;
|
69
71
|
};
|
70
72
|
|
71
|
-
export declare type ButtonState = ComponentState<ButtonSlots> &
|
73
|
+
export declare type ButtonState = ComponentState<ButtonSlots> & Required<Pick<ButtonProps, 'appearance' | 'disabledFocusable' | 'disabled' | 'iconPosition' | 'shape' | 'size'>> & {
|
72
74
|
/**
|
73
75
|
* A button can contain only an icon.
|
76
|
+
*
|
74
77
|
* @default false
|
75
78
|
*/
|
76
79
|
iconOnly: boolean;
|
@@ -81,9 +84,9 @@ export declare type ButtonState = ComponentState<ButtonSlots> & ButtonCommons &
|
|
81
84
|
*/
|
82
85
|
export declare const CompoundButton: ForwardRefComponent<CompoundButtonProps>;
|
83
86
|
|
84
|
-
export declare const
|
87
|
+
export declare const compoundButtonClassNames: SlotClassNames<CompoundButtonSlots>;
|
85
88
|
|
86
|
-
export declare type CompoundButtonProps = ComponentProps<Partial<CompoundButtonSlots>> &
|
89
|
+
export declare type CompoundButtonProps = ComponentProps<Partial<CompoundButtonSlots>> & Pick<ButtonProps, 'appearance' | 'disabledFocusable' | 'disabled' | 'iconPosition' | 'shape' | 'size'>;
|
87
90
|
|
88
91
|
export declare type CompoundButtonSlots = ButtonSlots & {
|
89
92
|
/**
|
@@ -99,13 +102,14 @@ export declare type CompoundButtonSlots = ButtonSlots & {
|
|
99
102
|
export declare type CompoundButtonState = ComponentState<CompoundButtonSlots> & Omit<ButtonState, keyof ButtonSlots | 'components'>;
|
100
103
|
|
101
104
|
/**
|
102
|
-
* MenuButtons are buttons that
|
105
|
+
* MenuButtons are buttons that have a chevron icon after the button contents and are usually clicked to open/close
|
106
|
+
* menus.
|
103
107
|
*/
|
104
108
|
export declare const MenuButton: ForwardRefComponent<MenuButtonProps>;
|
105
109
|
|
106
|
-
export declare const
|
110
|
+
export declare const menuButtonClassNames: SlotClassNames<MenuButtonSlots>;
|
107
111
|
|
108
|
-
export declare type MenuButtonProps = ComponentProps<MenuButtonSlots> &
|
112
|
+
export declare type MenuButtonProps = ComponentProps<MenuButtonSlots> & Pick<ButtonProps, 'appearance' | 'disabledFocusable' | 'disabled' | 'shape' | 'size'>;
|
109
113
|
|
110
114
|
export declare type MenuButtonSlots = ButtonSlots & {
|
111
115
|
/**
|
@@ -139,12 +143,12 @@ export declare const renderMenuButton_unstable: (state: MenuButtonState) => JSX.
|
|
139
143
|
export declare const renderSplitButton_unstable: (state: SplitButtonState) => JSX.Element;
|
140
144
|
|
141
145
|
/**
|
142
|
-
* SplitButtons are a grouping of two interactive surfaces where
|
146
|
+
* SplitButtons are a grouping of two interactive surfaces where interacting with the first one triggers a primary
|
143
147
|
* action, while interacting with the second one opens a menu with secondary actions.
|
144
148
|
*/
|
145
149
|
export declare const SplitButton: ForwardRefComponent<SplitButtonProps>;
|
146
150
|
|
147
|
-
export declare const
|
151
|
+
export declare const splitButtonClassNames: SlotClassNames<SplitButtonSlots>;
|
148
152
|
|
149
153
|
export declare type SplitButtonProps = ComponentProps<SplitButtonSlots> & Omit<ButtonProps, 'root'> & Omit<MenuButtonProps, 'root'>;
|
150
154
|
|
@@ -152,7 +156,7 @@ export declare type SplitButtonSlots = {
|
|
152
156
|
/**
|
153
157
|
* Root of the component that wraps the primary action button and menu button.
|
154
158
|
*/
|
155
|
-
root: Slot<'div'
|
159
|
+
root: NonNullable<Slot<'div'>>;
|
156
160
|
/**
|
157
161
|
* Button that opens menu with secondary actions in SplitButton.
|
158
162
|
*/
|
@@ -170,28 +174,27 @@ export declare type SplitButtonState = ComponentState<SplitButtonSlots> & Omit<B
|
|
170
174
|
*/
|
171
175
|
export declare const ToggleButton: ForwardRefComponent<ToggleButtonProps>;
|
172
176
|
|
173
|
-
export declare const
|
177
|
+
export declare const toggleButtonClassNames: SlotClassNames<ButtonSlots>;
|
174
178
|
|
175
|
-
declare type
|
179
|
+
export declare type ToggleButtonProps = ButtonProps & {
|
180
|
+
/**
|
181
|
+
* Defines whether the `ToggleButton` is initially in a checked state or not when rendered.
|
182
|
+
*
|
183
|
+
* @default false
|
184
|
+
*/
|
185
|
+
defaultChecked?: boolean;
|
176
186
|
/**
|
177
187
|
* Defines the controlled checked state of the `ToggleButton`.
|
178
188
|
* If passed, `ToggleButton` ignores the `defaultChecked` property.
|
179
189
|
* 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
|
180
190
|
* correct value based on handling `onClick` events and re-rendering.
|
191
|
+
*
|
181
192
|
* @default false
|
182
193
|
*/
|
183
|
-
checked
|
194
|
+
checked?: boolean;
|
184
195
|
};
|
185
196
|
|
186
|
-
export declare type
|
187
|
-
/**
|
188
|
-
* Defines whether the `ToggleButton` is initially in a checked state or not when rendered.
|
189
|
-
* @default false
|
190
|
-
*/
|
191
|
-
defaultChecked?: boolean;
|
192
|
-
};
|
193
|
-
|
194
|
-
export declare type ToggleButtonState = ButtonState & ToggleButtonCommons;
|
197
|
+
export declare type ToggleButtonState = ButtonState & Required<Pick<ToggleButtonProps, 'checked'>>;
|
195
198
|
|
196
199
|
/**
|
197
200
|
* Given user props, defines default props for the Button, calls useButtonState, and returns processed state.
|
@@ -233,8 +236,10 @@ export declare const useSplitButtonStyles_unstable: (state: SplitButtonState) =>
|
|
233
236
|
* @param props - User provided props to the ToggleButton component.
|
234
237
|
* @param ref - User provided ref to be passed to the ToggleButton component.
|
235
238
|
*/
|
236
|
-
export declare const useToggleButton_unstable: (
|
239
|
+
export declare const useToggleButton_unstable: (props: ToggleButtonProps, ref: React_2.Ref<HTMLButtonElement | HTMLAnchorElement>) => ToggleButtonState;
|
237
240
|
|
238
241
|
export declare const useToggleButtonStyles_unstable: (state: ToggleButtonState) => ToggleButtonState;
|
239
242
|
|
243
|
+
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;
|
244
|
+
|
240
245
|
export { }
|
File without changes
|
package/lib/Button.js.map
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"Button.js","sourceRoot":"","sources":["
|
1
|
+
{"version":3,"file":"Button.js","sourceRoot":"../src/","sources":["Button.tsx"],"names":[],"mappings":"AAAA,cAAc,2BAA2B,CAAC","sourcesContent":["export * from './components/Button/index';\n"]}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"CompoundButton.js","sourceRoot":"","sources":["
|
1
|
+
{"version":3,"file":"CompoundButton.js","sourceRoot":"../src/","sources":["CompoundButton.ts"],"names":[],"mappings":"AAAA,cAAc,mCAAmC,CAAC","sourcesContent":["export * from './components/CompoundButton/index';\n"]}
|
package/lib/MenuButton.js.map
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"MenuButton.js","sourceRoot":"","sources":["
|
1
|
+
{"version":3,"file":"MenuButton.js","sourceRoot":"../src/","sources":["MenuButton.ts"],"names":[],"mappings":"AAAA,cAAc,+BAA+B,CAAC","sourcesContent":["export * from './components/MenuButton/index';\n"]}
|
package/lib/SplitButton.js.map
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"SplitButton.js","sourceRoot":"","sources":["
|
1
|
+
{"version":3,"file":"SplitButton.js","sourceRoot":"../src/","sources":["SplitButton.ts"],"names":[],"mappings":"AAAA,cAAc,gCAAgC,CAAC","sourcesContent":["export * from './components/SplitButton/index';\n"]}
|
package/lib/ToggleButton.js.map
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"ToggleButton.js","sourceRoot":"","sources":["
|
1
|
+
{"version":3,"file":"ToggleButton.js","sourceRoot":"../src/","sources":["ToggleButton.ts"],"names":[],"mappings":"AAAA,cAAc,iCAAiC,CAAC","sourcesContent":["export * from './components/ToggleButton/index';\n"]}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["
|
1
|
+
{"version":3,"sources":["components/Button/Button.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAZ,MAAuB,OAAvB;AACA,SAAS,qBAAT,QAAsC,gBAAtC;AACA,SAAS,kBAAT,QAAmC,aAAnC;AACA,SAAS,wBAAT,QAAyC,mBAAzC;AAIA;;AAEG;;AACH,OAAO,MAAM,MAAM,gBAAqC,KAAK,CAAC,UAAN,CAAiB,CAAC,KAAD,EAAQ,GAAR,KAAe;AACtF,QAAM,KAAK,GAAG,kBAAkB,CAAC,KAAD,EAAQ,GAAR,CAAhC;AAEA,EAAA,wBAAwB,CAAC,KAAD,CAAxB;AAEA,SAAO,qBAAqB,CAAC,KAAD,CAA5B,CALsF,CAMtF;AACD,CAPuD,CAAjD;AASP,MAAM,CAAC,WAAP,GAAqB,QAArB","sourcesContent":["import * as React from 'react';\nimport { renderButton_unstable } from './renderButton';\nimport { useButton_unstable } from './useButton';\nimport { useButtonStyles_unstable } from './useButtonStyles';\nimport type { ButtonProps } from './Button.types';\nimport type { ForwardRefComponent } from '@fluentui/react-utilities';\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 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"],"sourceRoot":"../src/"}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"Button.types.js","sourceRoot":"","sources":["
|
1
|
+
{"version":3,"file":"Button.types.js","sourceRoot":"../src/","sources":["components/Button/Button.types.ts"],"names":[],"mappings":"","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>>;\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\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?: 'small' | 'medium' | 'large';\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"]}
|
@@ -1,5 +1,5 @@
|
|
1
1
|
export * from './Button';
|
2
2
|
export * from './renderButton';
|
3
3
|
export * from './useButton';
|
4
|
-
export {
|
4
|
+
export { buttonClassNames, useButtonStyles_unstable } from './useButtonStyles';
|
5
5
|
//# sourceMappingURL=index.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"../src/","sources":["components/Button/index.ts"],"names":[],"mappings":"AAAA,cAAc,UAAU,CAAC;AAGzB,cAAc,gBAAgB,CAAC;AAC/B,cAAc,aAAa,CAAC;AAC5B,OAAO,EAAE,gBAAgB,EAAE,wBAAwB,EAAE,MAAM,mBAAmB,CAAC","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';\n"]}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["
|
1
|
+
{"version":3,"sources":["components/Button/renderButton.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAZ,MAAuB,OAAvB;AACA,SAAS,QAAT,QAAyB,2BAAzB;AAGA;;AAEG;;AACH,OAAO,MAAM,qBAAqB,GAAI,KAAD,IAAuB;AAC1D,QAAM;AAAE,IAAA,KAAF;AAAS,IAAA;AAAT,MAAuB,QAAQ,CAAc,KAAd,CAArC;AACA,QAAM;AAAE,IAAA,QAAF;AAAY,IAAA;AAAZ,MAA6B,KAAnC;AAEA,sBACE,KAAA,CAAA,aAAA,CAAC,KAAK,CAAC,IAAP,EAAW,EAAA,GAAK,SAAS,CAAC;AAAf,GAAX,EACG,YAAY,KAAK,OAAjB,IAA4B,KAAK,CAAC,IAAlC,iBAA0C,KAAA,CAAA,aAAA,CAAC,KAAK,CAAC,IAAP,EAAW,EAAA,GAAK,SAAS,CAAC;AAAf,GAAX,CAD7C,EAEG,CAAC,QAAD,IAAa,KAAK,CAAC,IAAN,CAAW,QAF3B,EAGG,YAAY,KAAK,OAAjB,IAA4B,KAAK,CAAC,IAAlC,iBAA0C,KAAA,CAAA,aAAA,CAAC,KAAK,CAAC,IAAP,EAAW,EAAA,GAAK,SAAS,CAAC;AAAf,GAAX,CAH7C,CADF;AAOD,CAXM","sourcesContent":["import * as React from 'react';\nimport { getSlots } 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 } = getSlots<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"],"sourceRoot":"../src/"}
|
@@ -8,9 +8,8 @@ import { getNativeElementProps, resolveShorthand } from '@fluentui/react-utiliti
|
|
8
8
|
|
9
9
|
export const useButton_unstable = (props, ref) => {
|
10
10
|
const {
|
11
|
-
appearance,
|
11
|
+
appearance = 'secondary',
|
12
12
|
as,
|
13
|
-
block = false,
|
14
13
|
disabled = false,
|
15
14
|
disabledFocusable = false,
|
16
15
|
icon,
|
@@ -22,7 +21,6 @@ export const useButton_unstable = (props, ref) => {
|
|
22
21
|
return {
|
23
22
|
// Props passed at the top-level
|
24
23
|
appearance,
|
25
|
-
block,
|
26
24
|
disabled,
|
27
25
|
disabledFocusable,
|
28
26
|
iconPosition,
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["
|
1
|
+
{"version":3,"sources":["components/Button/useButton.ts"],"names":[],"mappings":"AACA,SAAS,aAAT,QAA8B,sBAA9B;AACA,SAAS,qBAAT,EAAgC,gBAAhC,QAAwD,2BAAxD;AAIA;;;;AAIG;;AACH,OAAO,MAAM,kBAAkB,GAAG,CAChC,KADgC,EAEhC,GAFgC,KAGjB;AACf,QAAM;AACJ,IAAA,UAAU,GAAG,WADT;AAEJ,IAAA,EAFI;AAGJ,IAAA,QAAQ,GAAG,KAHP;AAIJ,IAAA,iBAAiB,GAAG,KAJhB;AAKJ,IAAA,IALI;AAMJ,IAAA,YAAY,GAAG,QANX;AAOJ,IAAA,KAAK,GAAG,SAPJ;AAQJ,IAAA,IAAI,GAAG;AARH,MASF,KATJ;AAUA,QAAM,aAAa,GAAG,gBAAgB,CAAC,IAAD,CAAtC;AAEA,SAAO;AACL;AACA,IAAA,UAFK;AAGL,IAAA,QAHK;AAIL,IAAA,iBAJK;AAKL,IAAA,YALK;AAML,IAAA,KANK;AAOL,IAAA,IAPK;AASL;AACA,IAAA,QAAQ,EAAE,OAAO,CAAC,CAAA,aAAa,KAAA,IAAb,IAAA,aAAa,KAAA,KAAA,CAAb,GAAa,KAAA,CAAb,GAAA,aAAa,CAAE,QAAf,KAA2B,CAAC,KAAK,CAAC,QAAnC,CAVZ;AAYL;AACA,IAAA,UAAU,EAAE;AACV,MAAA,IAAI,EAAE,QADI;AAEV,MAAA,IAAI,EAAE;AAFI,KAbP;AAkBL,IAAA,IAAI,EAAE,qBAAqB,CACzB,EAAE,IAAI,QADmB,EAEzB,aAAa,CAAsB,KAAtB,EAA6B;AACxC,MAAA,QAAQ,EAAE,IAD8B;AAExC,MAAA,YAAY,EAAE;AACZ;AACA,QAAA,GAAG,EAAE,GAFO;AAGZ,QAAA,IAAI,EAAE,QAHM,CAGI;;AAHJ;AAF0B,KAA7B,CAFY,CAlBtB;AA6BL,IAAA,IAAI,EAAE;AA7BD,GAAP;AA+BD,CA/CM","sourcesContent":["import * as React from 'react';\nimport { useARIAButton } from '@fluentui/react-aria';\nimport { getNativeElementProps, resolveShorthand } from '@fluentui/react-utilities';\nimport type { ARIAButtonSlotProps } from '@fluentui/react-aria';\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 {\n appearance = 'secondary',\n as,\n disabled = false,\n disabledFocusable = false,\n icon,\n iconPosition = 'before',\n shape = 'rounded',\n size = '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 || 'button',\n useARIAButton<ARIAButtonSlotProps>(props, {\n required: true,\n defaultProps: {\n // useARIAButton isn't working with React.Ref<HTMLButtonElement | HTMLAnchorElement>\n ref: ref as React.Ref<HTMLButtonElement>,\n type: 'button', // This is added because the default for type is 'submit'\n },\n }),\n ),\n icon: iconShorthand,\n };\n};\n"],"sourceRoot":"../src/"}
|