@fluentui/react-badge 0.0.0-nightly-20220302-0405.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 +2968 -0
- package/CHANGELOG.md +1083 -0
- package/LICENSE +15 -0
- package/README.md +5 -0
- package/Spec.md +157 -0
- package/dist/react-badge.d.ts +159 -0
- package/lib/Badge.d.ts +1 -0
- package/lib/Badge.js +2 -0
- package/lib/Badge.js.map +1 -0
- package/lib/CounterBadge.d.ts +1 -0
- package/lib/CounterBadge.js +2 -0
- package/lib/CounterBadge.js.map +1 -0
- package/lib/PresenceBadge.d.ts +1 -0
- package/lib/PresenceBadge.js +2 -0
- package/lib/PresenceBadge.js.map +1 -0
- package/lib/components/Badge/Badge.d.ts +6 -0
- package/lib/components/Badge/Badge.js +15 -0
- package/lib/components/Badge/Badge.js.map +1 -0
- package/lib/components/Badge/Badge.types.d.ts +34 -0
- package/lib/components/Badge/Badge.types.js +2 -0
- package/lib/components/Badge/Badge.types.js.map +1 -0
- package/lib/components/Badge/index.d.ts +5 -0
- package/lib/components/Badge/index.js +5 -0
- package/lib/components/Badge/index.js.map +1 -0
- package/lib/components/Badge/renderBadge.d.ts +2 -0
- package/lib/components/Badge/renderBadge.js +13 -0
- package/lib/components/Badge/renderBadge.js.map +1 -0
- package/lib/components/Badge/useBadge.d.ts +6 -0
- package/lib/components/Badge/useBadge.js +33 -0
- package/lib/components/Badge/useBadge.js.map +1 -0
- package/lib/components/Badge/useBadgeStyles.d.ts +6 -0
- package/lib/components/Badge/useBadgeStyles.js +331 -0
- package/lib/components/Badge/useBadgeStyles.js.map +1 -0
- package/lib/components/CounterBadge/CounterBadge.d.ts +6 -0
- package/lib/components/CounterBadge/CounterBadge.js +15 -0
- package/lib/components/CounterBadge/CounterBadge.js.map +1 -0
- package/lib/components/CounterBadge/CounterBadge.types.d.ts +41 -0
- package/lib/components/CounterBadge/CounterBadge.types.js +2 -0
- package/lib/components/CounterBadge/CounterBadge.types.js.map +1 -0
- package/lib/components/CounterBadge/index.d.ts +4 -0
- package/lib/components/CounterBadge/index.js +5 -0
- package/lib/components/CounterBadge/index.js.map +1 -0
- package/lib/components/CounterBadge/useCounterBadge.d.ts +6 -0
- package/lib/components/CounterBadge/useCounterBadge.js +30 -0
- package/lib/components/CounterBadge/useCounterBadge.js.map +1 -0
- package/lib/components/CounterBadge/useCounterBadgeStyles.d.ts +6 -0
- package/lib/components/CounterBadge/useCounterBadgeStyles.js +31 -0
- package/lib/components/CounterBadge/useCounterBadgeStyles.js.map +1 -0
- package/lib/components/PresenceBadge/PresenceBadge.d.ts +6 -0
- package/lib/components/PresenceBadge/PresenceBadge.js +15 -0
- package/lib/components/PresenceBadge/PresenceBadge.js.map +1 -0
- package/lib/components/PresenceBadge/PresenceBadge.types.d.ts +19 -0
- package/lib/components/PresenceBadge/PresenceBadge.types.js +2 -0
- package/lib/components/PresenceBadge/PresenceBadge.types.js.map +1 -0
- package/lib/components/PresenceBadge/index.d.ts +4 -0
- package/lib/components/PresenceBadge/index.js +5 -0
- package/lib/components/PresenceBadge/index.js.map +1 -0
- package/lib/components/PresenceBadge/presenceIcons.d.ts +11 -0
- package/lib/components/PresenceBadge/presenceIcons.js +128 -0
- package/lib/components/PresenceBadge/presenceIcons.js.map +1 -0
- package/lib/components/PresenceBadge/usePresenceBadge.d.ts +6 -0
- package/lib/components/PresenceBadge/usePresenceBadge.js +53 -0
- package/lib/components/PresenceBadge/usePresenceBadge.js.map +1 -0
- package/lib/components/PresenceBadge/usePresenceBadgeStyles.d.ts +6 -0
- package/lib/components/PresenceBadge/usePresenceBadgeStyles.js +80 -0
- package/lib/components/PresenceBadge/usePresenceBadgeStyles.js.map +1 -0
- package/lib/index.d.ts +5 -0
- package/lib/index.js +6 -0
- package/lib/index.js.map +1 -0
- package/lib/tsdoc-metadata.json +11 -0
- package/lib-commonjs/Badge.d.ts +1 -0
- package/lib-commonjs/Badge.js +10 -0
- package/lib-commonjs/Badge.js.map +1 -0
- package/lib-commonjs/CounterBadge.d.ts +1 -0
- package/lib-commonjs/CounterBadge.js +10 -0
- package/lib-commonjs/CounterBadge.js.map +1 -0
- package/lib-commonjs/PresenceBadge.d.ts +1 -0
- package/lib-commonjs/PresenceBadge.js +10 -0
- package/lib-commonjs/PresenceBadge.js.map +1 -0
- package/lib-commonjs/components/Badge/Badge.d.ts +6 -0
- package/lib-commonjs/components/Badge/Badge.js +26 -0
- package/lib-commonjs/components/Badge/Badge.js.map +1 -0
- package/lib-commonjs/components/Badge/Badge.types.d.ts +34 -0
- package/lib-commonjs/components/Badge/Badge.types.js +6 -0
- package/lib-commonjs/components/Badge/Badge.types.js.map +1 -0
- package/lib-commonjs/components/Badge/index.d.ts +5 -0
- package/lib-commonjs/components/Badge/index.js +16 -0
- package/lib-commonjs/components/Badge/index.js.map +1 -0
- package/lib-commonjs/components/Badge/renderBadge.d.ts +2 -0
- package/lib-commonjs/components/Badge/renderBadge.js +24 -0
- package/lib-commonjs/components/Badge/renderBadge.js.map +1 -0
- package/lib-commonjs/components/Badge/useBadge.d.ts +6 -0
- package/lib-commonjs/components/Badge/useBadge.js +43 -0
- package/lib-commonjs/components/Badge/useBadge.js.map +1 -0
- package/lib-commonjs/components/Badge/useBadgeStyles.d.ts +6 -0
- package/lib-commonjs/components/Badge/useBadgeStyles.js +342 -0
- package/lib-commonjs/components/Badge/useBadgeStyles.js.map +1 -0
- package/lib-commonjs/components/CounterBadge/CounterBadge.d.ts +6 -0
- package/lib-commonjs/components/CounterBadge/CounterBadge.js +26 -0
- package/lib-commonjs/components/CounterBadge/CounterBadge.js.map +1 -0
- package/lib-commonjs/components/CounterBadge/CounterBadge.types.d.ts +41 -0
- package/lib-commonjs/components/CounterBadge/CounterBadge.types.js +6 -0
- package/lib-commonjs/components/CounterBadge/CounterBadge.types.js.map +1 -0
- package/lib-commonjs/components/CounterBadge/index.d.ts +4 -0
- package/lib-commonjs/components/CounterBadge/index.js +16 -0
- package/lib-commonjs/components/CounterBadge/index.js.map +1 -0
- package/lib-commonjs/components/CounterBadge/useCounterBadge.d.ts +6 -0
- package/lib-commonjs/components/CounterBadge/useCounterBadge.js +40 -0
- package/lib-commonjs/components/CounterBadge/useCounterBadge.js.map +1 -0
- package/lib-commonjs/components/CounterBadge/useCounterBadgeStyles.d.ts +6 -0
- package/lib-commonjs/components/CounterBadge/useCounterBadgeStyles.js +42 -0
- package/lib-commonjs/components/CounterBadge/useCounterBadgeStyles.js.map +1 -0
- package/lib-commonjs/components/PresenceBadge/PresenceBadge.d.ts +6 -0
- package/lib-commonjs/components/PresenceBadge/PresenceBadge.js +26 -0
- package/lib-commonjs/components/PresenceBadge/PresenceBadge.js.map +1 -0
- package/lib-commonjs/components/PresenceBadge/PresenceBadge.types.d.ts +19 -0
- package/lib-commonjs/components/PresenceBadge/PresenceBadge.types.js +6 -0
- package/lib-commonjs/components/PresenceBadge/PresenceBadge.types.js.map +1 -0
- package/lib-commonjs/components/PresenceBadge/index.d.ts +4 -0
- package/lib-commonjs/components/PresenceBadge/index.js +16 -0
- package/lib-commonjs/components/PresenceBadge/index.js.map +1 -0
- package/lib-commonjs/components/PresenceBadge/presenceIcons.d.ts +11 -0
- package/lib-commonjs/components/PresenceBadge/presenceIcons.js +136 -0
- package/lib-commonjs/components/PresenceBadge/presenceIcons.js.map +1 -0
- package/lib-commonjs/components/PresenceBadge/usePresenceBadge.d.ts +6 -0
- package/lib-commonjs/components/PresenceBadge/usePresenceBadge.js +65 -0
- package/lib-commonjs/components/PresenceBadge/usePresenceBadge.js.map +1 -0
- package/lib-commonjs/components/PresenceBadge/usePresenceBadgeStyles.d.ts +6 -0
- package/lib-commonjs/components/PresenceBadge/usePresenceBadgeStyles.js +91 -0
- package/lib-commonjs/components/PresenceBadge/usePresenceBadgeStyles.js.map +1 -0
- package/lib-commonjs/index.d.ts +5 -0
- package/lib-commonjs/index.js +18 -0
- package/lib-commonjs/index.js.map +1 -0
- package/package.json +64 -0
package/LICENSE
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
@fluentui/react-badge
|
2
|
+
|
3
|
+
Copyright (c) Microsoft Corporation
|
4
|
+
|
5
|
+
All rights reserved.
|
6
|
+
|
7
|
+
MIT License
|
8
|
+
|
9
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the ""Software""), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
12
|
+
|
13
|
+
THE SOFTWARE IS PROVIDED *AS IS*, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
14
|
+
|
15
|
+
Note: Usage of the fonts and icons referenced in Fluent UI React is subject to the terms listed at https://aka.ms/fluentui-assets-license
|
package/README.md
ADDED
@@ -0,0 +1,5 @@
|
|
1
|
+
# @fluentui/react-badge
|
2
|
+
|
3
|
+
**React Badge components for [Fluent UI React](https://developer.microsoft.com/en-us/fluentui)**
|
4
|
+
|
5
|
+
These are not production-ready components and **should never be used in product**. This space is useful for testing new components whose APIs might change before final release.
|
package/Spec.md
ADDED
@@ -0,0 +1,157 @@
|
|
1
|
+
# [Badge](https://github.com/microsoft/fluentui/issues/16925)
|
2
|
+
|
3
|
+
## Background
|
4
|
+
|
5
|
+
A badge is an additional visual descriptor for UI elements. It can be used to denote numerical value, status or general information.
|
6
|
+
|
7
|
+
## Prior Art
|
8
|
+
|
9
|
+
- [OpenUI Research](https://open-ui.org/components/badge.research)
|
10
|
+
|
11
|
+
## Sample Code
|
12
|
+
|
13
|
+
```jsx
|
14
|
+
<Badge>
|
15
|
+
My Custom Badge
|
16
|
+
</Badge>
|
17
|
+
<Badge
|
18
|
+
style={{ position: 'absolute', top: -4, right: -4 }}
|
19
|
+
/>
|
20
|
+
```
|
21
|
+
|
22
|
+
## Variants
|
23
|
+
|
24
|
+
`Badge` can have several variations.
|
25
|
+
|
26
|
+
- Appearance: `default`, `rounded` and `circular`
|
27
|
+
- Size: `tiny`, `extra-small`, `small`, `medium`, `large`, `extra-large`.
|
28
|
+
- Styles: `filled`, `outline`, `ghost`, `tint`, `inverted filled`
|
29
|
+
|
30
|
+
## PROPS
|
31
|
+
|
32
|
+
```typescript
|
33
|
+
type BadgeAppearance = 'filled' | 'outline' | 'ghost' | 'tint';
|
34
|
+
|
35
|
+
type BadgeShape = 'rounded' | 'square' | 'circular';
|
36
|
+
|
37
|
+
type BadgeSize = 'tiny' | 'extra-small' | 'small' | 'medium' | 'large' | 'extra-large';
|
38
|
+
|
39
|
+
type BadgeProps extends ComponentProps, React.HTMLAttributes<HTMLElement> {
|
40
|
+
/**
|
41
|
+
* A Badge can be sized.
|
42
|
+
*/
|
43
|
+
size?: BadgeSize;
|
44
|
+
|
45
|
+
/**
|
46
|
+
* A Badge can be square, circular or rounded
|
47
|
+
*/
|
48
|
+
shape?: BadgeShape;
|
49
|
+
|
50
|
+
/**
|
51
|
+
* A Badge can be filled, outline, ghost, inverted
|
52
|
+
*/
|
53
|
+
appearance?: BadgeAppearance;
|
54
|
+
|
55
|
+
/**
|
56
|
+
* Icon slot
|
57
|
+
*/
|
58
|
+
icon?: ShorthandProps<HTMLElement>;
|
59
|
+
|
60
|
+
/**
|
61
|
+
* Position for Icon to be rendered
|
62
|
+
*/
|
63
|
+
iconPosition?: 'before' | 'after';
|
64
|
+
}
|
65
|
+
```
|
66
|
+
|
67
|
+
## Structure
|
68
|
+
|
69
|
+
- _**Public**_
|
70
|
+
|
71
|
+
```jsx
|
72
|
+
<Badge />
|
73
|
+
```
|
74
|
+
|
75
|
+
- _**Internal**_
|
76
|
+
|
77
|
+
```jsx
|
78
|
+
<ElementType>{children}</ElementType>
|
79
|
+
```
|
80
|
+
|
81
|
+
- _**DOM**_
|
82
|
+
|
83
|
+
```html
|
84
|
+
<span class="ui-badge"> ... </span>
|
85
|
+
```
|
86
|
+
|
87
|
+
## Migration
|
88
|
+
|
89
|
+
- _Migration from v8_
|
90
|
+
|
91
|
+
`Badge` can be passed to `Avatar`'s `badge` slot. The `PresenceBadge` will be the best replacement for `Persona` presence mapping status, icon and colors.
|
92
|
+
|
93
|
+
- _Migration from v0_
|
94
|
+
|
95
|
+
`Badge` can be passed to `Avatar`'s `badge` slot.
|
96
|
+
|
97
|
+
## Behaviors
|
98
|
+
|
99
|
+
- Badges don't receive focus
|
100
|
+
|
101
|
+
- Badge information would be surfaced as part of the control that it is associated with, badges themselves do not receive focus meaning they are not directly accessible by screenreaders.
|
102
|
+
If the combination of icon and badge communicates some meaningful information, that information should be surfaced in another way through screenreader or tooltip on the component the badge is associated with.
|
103
|
+
|
104
|
+
- Screen Readers
|
105
|
+
|
106
|
+
- Badges should be given a meaningful description. This description will be applied, via “aria-describedby” to the element decorated by the Badge. For example, "Chat, 6 unread" or similar.
|
107
|
+
General guidance is that the badge icon is marked as “aria-hidden” by default.
|
108
|
+
|
109
|
+
- Badge shouldn't rely only on color information
|
110
|
+
|
111
|
+
- Include meaningful descriptions when using color to represent meaning in a badge. If relying on color only [unread dot] ensure that non-visual information is included using aria-describedby
|
112
|
+
|
113
|
+
## Variants
|
114
|
+
|
115
|
+
`Badge` is base component that can be used to create custom `Badge` such as `PresenceBadge` or `CounterBadge` with specific behaviors.
|
116
|
+
|
117
|
+
### Presence Badge
|
118
|
+
|
119
|
+
A Presence Badge represents someone's availbility or status
|
120
|
+
|
121
|
+
```typescript
|
122
|
+
export type PresenceBadgeStatus = 'busy' | 'oof' | 'away' | 'available' | 'offline';
|
123
|
+
|
124
|
+
export type PresenceBadgeProps = Omit<BadgeProps, 'shape' | 'appearance'> & {
|
125
|
+
/**
|
126
|
+
* A PresenceBadge can represent several status
|
127
|
+
* @defaultvalue available
|
128
|
+
*/
|
129
|
+
status?: PresenceBadgeStatus;
|
130
|
+
/**
|
131
|
+
* A PresenceBadge can represent status of someone out of the office
|
132
|
+
* @defaultvalue true
|
133
|
+
*/
|
134
|
+
inOffice?: boolean;
|
135
|
+
};
|
136
|
+
|
137
|
+
export type PresenceBadgeState = BadgeState & {
|
138
|
+
/**
|
139
|
+
* A PresenceBadge can represent several status
|
140
|
+
* @defaultvalue available
|
141
|
+
*/
|
142
|
+
status: PresenceBadgeStatus;
|
143
|
+
/**
|
144
|
+
* A PresenceBadge can represent status of someone out of the office
|
145
|
+
* @defaultvalue true
|
146
|
+
*/
|
147
|
+
inOffice: boolean;
|
148
|
+
};
|
149
|
+
```
|
150
|
+
|
151
|
+
### Counter Badge
|
152
|
+
|
153
|
+
A Counter Badge is a visual indicator for numeric values such as tallies and scores.
|
154
|
+
|
155
|
+
```typescript
|
156
|
+
export type CounterBadgeProps = Omit<BadgeProps, 'appearance' | 'shape'> & Partial<CounterBadgeCommons>;
|
157
|
+
```
|
@@ -0,0 +1,159 @@
|
|
1
|
+
import type { ComponentProps } from '@fluentui/react-utilities';
|
2
|
+
import type { ComponentState } from '@fluentui/react-utilities';
|
3
|
+
import type { ForwardRefComponent } from '@fluentui/react-utilities';
|
4
|
+
import * as React_2 from 'react';
|
5
|
+
import type { Slot } from '@fluentui/react-utilities';
|
6
|
+
|
7
|
+
/**
|
8
|
+
* Define a styled Badge, using the `useBadge_unstable` hook.
|
9
|
+
*/
|
10
|
+
export declare const Badge: ForwardRefComponent<BadgeProps>;
|
11
|
+
|
12
|
+
export declare const badgeClassName = "fui-Badge";
|
13
|
+
|
14
|
+
declare type BadgeCommons = {
|
15
|
+
/**
|
16
|
+
* A Badge can be filled, outline, ghost, inverted
|
17
|
+
* @defaultvalue filled
|
18
|
+
*/
|
19
|
+
appearance: 'filled' | 'ghost' | 'outline' | 'tint';
|
20
|
+
/**
|
21
|
+
* A Badge can be one of preset colors
|
22
|
+
* @defaultvalue brand
|
23
|
+
*/
|
24
|
+
color: 'brand' | 'danger' | 'important' | 'informative' | 'severe' | 'subtle' | 'success' | 'warning';
|
25
|
+
/**
|
26
|
+
* A Badge can position the icon before or after the content.
|
27
|
+
* @defaultvalue before
|
28
|
+
*/
|
29
|
+
iconPosition: 'before' | 'after';
|
30
|
+
/**
|
31
|
+
* A Badge can be square, circular or rounded.
|
32
|
+
* @defaultvalue circular
|
33
|
+
*/
|
34
|
+
shape: 'circular' | 'rounded' | 'square';
|
35
|
+
/**
|
36
|
+
* A Badge can be on of several preset sizes.
|
37
|
+
* @defaultvalue medium
|
38
|
+
*/
|
39
|
+
size: 'tiny' | 'extra-small' | 'small' | 'medium' | 'large' | 'extra-large';
|
40
|
+
};
|
41
|
+
|
42
|
+
export declare type BadgeProps = Omit<ComponentProps<BadgeSlots>, 'color'> & Partial<BadgeCommons>;
|
43
|
+
|
44
|
+
export declare type BadgeSlots = {
|
45
|
+
root: Slot<'div'>;
|
46
|
+
icon?: Slot<'span'>;
|
47
|
+
};
|
48
|
+
|
49
|
+
export declare type BadgeState = ComponentState<BadgeSlots> & BadgeCommons;
|
50
|
+
|
51
|
+
/**
|
52
|
+
* Define a styled CounterBadge, using the `useCounterBadge_unstable` hook.
|
53
|
+
*/
|
54
|
+
export declare const CounterBadge: ForwardRefComponent<CounterBadgeProps>;
|
55
|
+
|
56
|
+
export declare const counterBadgeClassName = "fui-CounterBadge";
|
57
|
+
|
58
|
+
declare type CounterBadgeCommons = {
|
59
|
+
/**
|
60
|
+
* Max number to be displayed
|
61
|
+
* @default 99
|
62
|
+
*/
|
63
|
+
overflowCount: number;
|
64
|
+
/**
|
65
|
+
* Value displayed by the Badge
|
66
|
+
* @default 0
|
67
|
+
*/
|
68
|
+
count: number;
|
69
|
+
/**
|
70
|
+
* If the badge should be shown when count is 0
|
71
|
+
* @default false
|
72
|
+
*/
|
73
|
+
showZero: boolean;
|
74
|
+
/**
|
75
|
+
* If a dot should be displayed without the count
|
76
|
+
* @default false
|
77
|
+
*/
|
78
|
+
dot: boolean;
|
79
|
+
/**
|
80
|
+
* A Badge can be circular or rounded
|
81
|
+
* @default circular
|
82
|
+
*/
|
83
|
+
shape: 'circular' | 'rounded';
|
84
|
+
/**
|
85
|
+
* A Badge can be filled, ghost
|
86
|
+
* @default filled
|
87
|
+
*/
|
88
|
+
appearance: 'filled' | 'ghost';
|
89
|
+
/**
|
90
|
+
* Semantic colors for a counter badge
|
91
|
+
* @default brand
|
92
|
+
*/
|
93
|
+
color: Extract<BadgeProps['color'], 'brand' | 'danger' | 'important' | 'informative'>;
|
94
|
+
};
|
95
|
+
|
96
|
+
export declare type CounterBadgeProps = Omit<BadgeProps, 'appearance' | 'shape' | 'color'> & Partial<CounterBadgeCommons>;
|
97
|
+
|
98
|
+
export declare type CounterBadgeState = Omit<BadgeState, 'appearance' | 'shape' | 'color'> & CounterBadgeCommons;
|
99
|
+
|
100
|
+
/**
|
101
|
+
* Define a styled Badge, using the `useBadge_unstable` hook.
|
102
|
+
*/
|
103
|
+
export declare const PresenceBadge: ForwardRefComponent<PresenceBadgeProps>;
|
104
|
+
|
105
|
+
export declare const presenceBadgeClassName = "fui-PresenceBadge";
|
106
|
+
|
107
|
+
declare type PresenceBadgeCommons = {
|
108
|
+
/**
|
109
|
+
* Represents several status
|
110
|
+
* @default available
|
111
|
+
*/
|
112
|
+
status: PresenceBadgeStatus;
|
113
|
+
/**
|
114
|
+
* Modifies the display to indicate that the user is out of office.
|
115
|
+
* This can be combined with any status to display an out-of-office version of that status
|
116
|
+
* @default false
|
117
|
+
*/
|
118
|
+
outOfOffice: boolean;
|
119
|
+
} & BadgeCommons;
|
120
|
+
|
121
|
+
export declare type PresenceBadgeProps = Omit<ComponentProps<Pick<BadgeSlots, 'root'>>, 'color'> & Partial<Pick<PresenceBadgeCommons, 'status' | 'outOfOffice' | 'size'>>;
|
122
|
+
|
123
|
+
export declare type PresenceBadgeState = PresenceBadgeCommons & ComponentState<BadgeSlots>;
|
124
|
+
|
125
|
+
export declare type PresenceBadgeStatus = 'busy' | 'outOfOffice' | 'away' | 'available' | 'offline' | 'doNotDisturb';
|
126
|
+
|
127
|
+
export declare const renderBadge_unstable: (state: BadgeState) => JSX.Element;
|
128
|
+
|
129
|
+
/**
|
130
|
+
* Returns the props and state required to render the component
|
131
|
+
*/
|
132
|
+
export declare const useBadge_unstable: (props: BadgeProps, ref: React_2.Ref<HTMLElement>) => BadgeState;
|
133
|
+
|
134
|
+
/**
|
135
|
+
* Applies style classnames to slots
|
136
|
+
*/
|
137
|
+
export declare const useBadgeStyles_unstable: (state: BadgeState) => BadgeState;
|
138
|
+
|
139
|
+
/**
|
140
|
+
* Returns the props and state required to render the component
|
141
|
+
*/
|
142
|
+
export declare const useCounterBadge_unstable: (props: CounterBadgeProps, ref: React_2.Ref<HTMLElement>) => CounterBadgeState;
|
143
|
+
|
144
|
+
/**
|
145
|
+
* Applies style classnames to slots
|
146
|
+
*/
|
147
|
+
export declare const useCounterBadgeStyles_unstable: (state: CounterBadgeState) => CounterBadgeState;
|
148
|
+
|
149
|
+
/**
|
150
|
+
* Returns the props and state required to render the component
|
151
|
+
*/
|
152
|
+
export declare const usePresenceBadge_unstable: (props: PresenceBadgeProps, ref: React_2.Ref<HTMLElement>) => PresenceBadgeState;
|
153
|
+
|
154
|
+
/**
|
155
|
+
* Applies style classnames to slots
|
156
|
+
*/
|
157
|
+
export declare const usePresenceBadgeStyles_unstable: (state: PresenceBadgeState) => PresenceBadgeState;
|
158
|
+
|
159
|
+
export { }
|
package/lib/Badge.d.ts
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
export * from './components/Badge/index';
|
package/lib/Badge.js
ADDED
package/lib/Badge.js.map
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"Badge.js","sourceRoot":"../src/","sources":["Badge.ts"],"names":[],"mappings":"AAAA,cAAc,0BAA0B,CAAC","sourcesContent":["export * from './components/Badge/index';\n"]}
|
@@ -0,0 +1 @@
|
|
1
|
+
export * from './components/CounterBadge/index';
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"CounterBadge.js","sourceRoot":"../src/","sources":["CounterBadge.ts"],"names":[],"mappings":"AAAA,cAAc,iCAAiC,CAAC","sourcesContent":["export * from './components/CounterBadge/index';\n"]}
|
@@ -0,0 +1 @@
|
|
1
|
+
export * from './components/PresenceBadge/index';
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"PresenceBadge.js","sourceRoot":"../src/","sources":["PresenceBadge.ts"],"names":[],"mappings":"AAAA,cAAc,kCAAkC,CAAC","sourcesContent":["export * from './components/PresenceBadge/index';\n"]}
|
@@ -0,0 +1,15 @@
|
|
1
|
+
import * as React from 'react';
|
2
|
+
import { useBadge_unstable } from './useBadge';
|
3
|
+
import { useBadgeStyles_unstable } from './useBadgeStyles';
|
4
|
+
import { renderBadge_unstable } from './renderBadge';
|
5
|
+
/**
|
6
|
+
* Define a styled Badge, using the `useBadge_unstable` hook.
|
7
|
+
*/
|
8
|
+
|
9
|
+
export const Badge = /*#__PURE__*/React.forwardRef((props, ref) => {
|
10
|
+
const state = useBadge_unstable(props, ref);
|
11
|
+
useBadgeStyles_unstable(state);
|
12
|
+
return renderBadge_unstable(state);
|
13
|
+
});
|
14
|
+
Badge.displayName = 'Badge';
|
15
|
+
//# sourceMappingURL=Badge.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"sources":["components/Badge/Badge.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAZ,MAAuB,OAAvB;AACA,SAAS,iBAAT,QAAkC,YAAlC;AACA,SAAS,uBAAT,QAAwC,kBAAxC;AACA,SAAS,oBAAT,QAAqC,eAArC;AAIA;;AAEG;;AACH,OAAO,MAAM,KAAK,gBAAoC,KAAK,CAAC,UAAN,CAAiB,CAAC,KAAD,EAAQ,GAAR,KAAe;AACpF,QAAM,KAAK,GAAG,iBAAiB,CAAC,KAAD,EAAQ,GAAR,CAA/B;AACA,EAAA,uBAAuB,CAAC,KAAD,CAAvB;AAEA,SAAO,oBAAoB,CAAC,KAAD,CAA3B;AACD,CALqD,CAA/C;AAOP,KAAK,CAAC,WAAN,GAAoB,OAApB","sourcesContent":["import * as React from 'react';\nimport { useBadge_unstable } from './useBadge';\nimport { useBadgeStyles_unstable } from './useBadgeStyles';\nimport { renderBadge_unstable } from './renderBadge';\nimport type { BadgeProps } from './Badge.types';\nimport type { ForwardRefComponent } from '@fluentui/react-utilities';\n\n/**\n * Define a styled Badge, using the `useBadge_unstable` hook.\n */\nexport const Badge: ForwardRefComponent<BadgeProps> = React.forwardRef((props, ref) => {\n const state = useBadge_unstable(props, ref);\n useBadgeStyles_unstable(state);\n\n return renderBadge_unstable(state);\n});\n\nBadge.displayName = 'Badge';\n"],"sourceRoot":"../src/"}
|
@@ -0,0 +1,34 @@
|
|
1
|
+
import type { ComponentProps, ComponentState, Slot } from '@fluentui/react-utilities';
|
2
|
+
export declare type BadgeSlots = {
|
3
|
+
root: Slot<'div'>;
|
4
|
+
icon?: Slot<'span'>;
|
5
|
+
};
|
6
|
+
export declare type BadgeCommons = {
|
7
|
+
/**
|
8
|
+
* A Badge can be filled, outline, ghost, inverted
|
9
|
+
* @defaultvalue filled
|
10
|
+
*/
|
11
|
+
appearance: 'filled' | 'ghost' | 'outline' | 'tint';
|
12
|
+
/**
|
13
|
+
* A Badge can be one of preset colors
|
14
|
+
* @defaultvalue brand
|
15
|
+
*/
|
16
|
+
color: 'brand' | 'danger' | 'important' | 'informative' | 'severe' | 'subtle' | 'success' | 'warning';
|
17
|
+
/**
|
18
|
+
* A Badge can position the icon before or after the content.
|
19
|
+
* @defaultvalue before
|
20
|
+
*/
|
21
|
+
iconPosition: 'before' | 'after';
|
22
|
+
/**
|
23
|
+
* A Badge can be square, circular or rounded.
|
24
|
+
* @defaultvalue circular
|
25
|
+
*/
|
26
|
+
shape: 'circular' | 'rounded' | 'square';
|
27
|
+
/**
|
28
|
+
* A Badge can be on of several preset sizes.
|
29
|
+
* @defaultvalue medium
|
30
|
+
*/
|
31
|
+
size: 'tiny' | 'extra-small' | 'small' | 'medium' | 'large' | 'extra-large';
|
32
|
+
};
|
33
|
+
export declare type BadgeProps = Omit<ComponentProps<BadgeSlots>, 'color'> & Partial<BadgeCommons>;
|
34
|
+
export declare type BadgeState = ComponentState<BadgeSlots> & BadgeCommons;
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"Badge.types.js","sourceRoot":"../src/","sources":["components/Badge/Badge.types.ts"],"names":[],"mappings":"","sourcesContent":["import type { ComponentProps, ComponentState, Slot } from '@fluentui/react-utilities';\n\nexport type BadgeSlots = {\n root: Slot<'div'>;\n icon?: Slot<'span'>;\n};\n\nexport type BadgeCommons = {\n /**\n * A Badge can be filled, outline, ghost, inverted\n * @defaultvalue filled\n */\n appearance: 'filled' | 'ghost' | 'outline' | 'tint';\n\n /**\n * A Badge can be one of preset colors\n * @defaultvalue brand\n */\n color: 'brand' | 'danger' | 'important' | 'informative' | 'severe' | 'subtle' | 'success' | 'warning';\n\n /**\n * A Badge can position the icon before or after the content.\n * @defaultvalue before\n */\n iconPosition: 'before' | 'after';\n\n /**\n * A Badge can be square, circular or rounded.\n * @defaultvalue circular\n */\n shape: 'circular' | 'rounded' | 'square';\n\n /**\n * A Badge can be on of several preset sizes.\n * @defaultvalue medium\n */\n size: 'tiny' | 'extra-small' | 'small' | 'medium' | 'large' | 'extra-large';\n};\n\n// react has a non-standard `color` attribute in its types\n// https://github.com/DefinitelyTyped/DefinitelyTyped/blob/a4ab0fa432320e70da9e51c8ae2e47377f65804b/types/react/index.d.ts#L1868\nexport type BadgeProps = Omit<ComponentProps<BadgeSlots>, 'color'> & Partial<BadgeCommons>;\nexport type BadgeState = ComponentState<BadgeSlots> & BadgeCommons;\n"]}
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"../src/","sources":["components/Badge/index.ts"],"names":[],"mappings":"AAAA,cAAc,SAAS,CAAC;AAGxB,cAAc,eAAe,CAAC;AAC9B,cAAc,YAAY,CAAC;AAC3B,cAAc,kBAAkB,CAAC","sourcesContent":["export * from './Badge';\n// Explicit exports to omit BadgeCommons\nexport type { BadgeProps, BadgeSlots, BadgeState } from './Badge.types';\nexport * from './renderBadge';\nexport * from './useBadge';\nexport * from './useBadgeStyles';\n"]}
|
@@ -0,0 +1,13 @@
|
|
1
|
+
import * as React from 'react';
|
2
|
+
import { getSlots } from '@fluentui/react-utilities';
|
3
|
+
export const renderBadge_unstable = state => {
|
4
|
+
const {
|
5
|
+
slots,
|
6
|
+
slotProps
|
7
|
+
} = getSlots(state);
|
8
|
+
return /*#__PURE__*/React.createElement(slots.root, { ...slotProps.root
|
9
|
+
}, state.iconPosition === 'before' && slots.icon && /*#__PURE__*/React.createElement(slots.icon, { ...slotProps.icon
|
10
|
+
}), state.root.children, state.iconPosition === 'after' && slots.icon && /*#__PURE__*/React.createElement(slots.icon, { ...slotProps.icon
|
11
|
+
}));
|
12
|
+
};
|
13
|
+
//# sourceMappingURL=renderBadge.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"sources":["components/Badge/renderBadge.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAZ,MAAuB,OAAvB;AACA,SAAS,QAAT,QAAyB,2BAAzB;AAGA,OAAO,MAAM,oBAAoB,GAAI,KAAD,IAAsB;AACxD,QAAM;AAAE,IAAA,KAAF;AAAS,IAAA;AAAT,MAAuB,QAAQ,CAAa,KAAb,CAArC;AAEA,sBACE,KAAA,CAAA,aAAA,CAAC,KAAK,CAAC,IAAP,EAAW,EAAA,GAAK,SAAS,CAAC;AAAf,GAAX,EACG,KAAK,CAAC,YAAN,KAAuB,QAAvB,IAAmC,KAAK,CAAC,IAAzC,iBAAiD,KAAA,CAAA,aAAA,CAAC,KAAK,CAAC,IAAP,EAAW,EAAA,GAAK,SAAS,CAAC;AAAf,GAAX,CADpD,EAEG,KAAK,CAAC,IAAN,CAAW,QAFd,EAGG,KAAK,CAAC,YAAN,KAAuB,OAAvB,IAAkC,KAAK,CAAC,IAAxC,iBAAgD,KAAA,CAAA,aAAA,CAAC,KAAK,CAAC,IAAP,EAAW,EAAA,GAAK,SAAS,CAAC;AAAf,GAAX,CAHnD,CADF;AAOD,CAVM","sourcesContent":["import * as React from 'react';\nimport { getSlots } from '@fluentui/react-utilities';\nimport type { BadgeState, BadgeSlots } from './Badge.types';\n\nexport const renderBadge_unstable = (state: BadgeState) => {\n const { slots, slotProps } = getSlots<BadgeSlots>(state);\n\n return (\n <slots.root {...slotProps.root}>\n {state.iconPosition === 'before' && slots.icon && <slots.icon {...slotProps.icon} />}\n {state.root.children}\n {state.iconPosition === 'after' && slots.icon && <slots.icon {...slotProps.icon} />}\n </slots.root>\n );\n};\n"],"sourceRoot":"../src/"}
|
@@ -0,0 +1,6 @@
|
|
1
|
+
import * as React from 'react';
|
2
|
+
import type { BadgeProps, BadgeState } from './Badge.types';
|
3
|
+
/**
|
4
|
+
* Returns the props and state required to render the component
|
5
|
+
*/
|
6
|
+
export declare const useBadge_unstable: (props: BadgeProps, ref: React.Ref<HTMLElement>) => BadgeState;
|
@@ -0,0 +1,33 @@
|
|
1
|
+
import { getNativeElementProps, resolveShorthand } from '@fluentui/react-utilities';
|
2
|
+
/**
|
3
|
+
* Returns the props and state required to render the component
|
4
|
+
*/
|
5
|
+
|
6
|
+
export const useBadge_unstable = (props, ref) => {
|
7
|
+
const {
|
8
|
+
shape = 'circular',
|
9
|
+
size = 'medium',
|
10
|
+
iconPosition = 'before',
|
11
|
+
appearance = 'filled',
|
12
|
+
color = 'brand'
|
13
|
+
} = props;
|
14
|
+
const state = {
|
15
|
+
shape,
|
16
|
+
size,
|
17
|
+
iconPosition,
|
18
|
+
appearance,
|
19
|
+
color,
|
20
|
+
components: {
|
21
|
+
root: 'div',
|
22
|
+
icon: 'span'
|
23
|
+
},
|
24
|
+
root: getNativeElementProps('div', {
|
25
|
+
ref,
|
26
|
+
'aria-hidden': true,
|
27
|
+
...props
|
28
|
+
}),
|
29
|
+
icon: resolveShorthand(props.icon)
|
30
|
+
};
|
31
|
+
return state;
|
32
|
+
};
|
33
|
+
//# sourceMappingURL=useBadge.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"sources":["components/Badge/useBadge.ts"],"names":[],"mappings":"AACA,SAAS,qBAAT,EAAgC,gBAAhC,QAAwD,2BAAxD;AAGA;;AAEG;;AACH,OAAO,MAAM,iBAAiB,GAAG,CAAC,KAAD,EAAoB,GAApB,KAA+D;AAC9F,QAAM;AACJ,IAAA,KAAK,GAAG,UADJ;AAEJ,IAAA,IAAI,GAAG,QAFH;AAGJ,IAAA,YAAY,GAAG,QAHX;AAIJ,IAAA,UAAU,GAAG,QAJT;AAKJ,IAAA,KAAK,GAAG;AALJ,MAMF,KANJ;AAQA,QAAM,KAAK,GAAe;AACxB,IAAA,KADwB;AAExB,IAAA,IAFwB;AAGxB,IAAA,YAHwB;AAIxB,IAAA,UAJwB;AAKxB,IAAA,KALwB;AAMxB,IAAA,UAAU,EAAE;AACV,MAAA,IAAI,EAAE,KADI;AAEV,MAAA,IAAI,EAAE;AAFI,KANY;AAUxB,IAAA,IAAI,EAAE,qBAAqB,CAAC,KAAD,EAAQ;AACjC,MAAA,GADiC;AAEjC,qBAAe,IAFkB;AAGjC,SAAG;AAH8B,KAAR,CAVH;AAexB,IAAA,IAAI,EAAE,gBAAgB,CAAC,KAAK,CAAC,IAAP;AAfE,GAA1B;AAkBA,SAAO,KAAP;AACD,CA5BM","sourcesContent":["import * as React from 'react';\nimport { getNativeElementProps, resolveShorthand } from '@fluentui/react-utilities';\nimport type { BadgeProps, BadgeState } from './Badge.types';\n\n/**\n * Returns the props and state required to render the component\n */\nexport const useBadge_unstable = (props: BadgeProps, ref: React.Ref<HTMLElement>): BadgeState => {\n const {\n shape = 'circular',\n size = 'medium',\n iconPosition = 'before',\n appearance = 'filled',\n color = 'brand',\n } = props;\n\n const state: BadgeState = {\n shape,\n size,\n iconPosition,\n appearance,\n color,\n components: {\n root: 'div',\n icon: 'span',\n },\n root: getNativeElementProps('div', {\n ref,\n 'aria-hidden': true,\n ...props,\n }),\n icon: resolveShorthand(props.icon),\n };\n\n return state;\n};\n"],"sourceRoot":"../src/"}
|