@fluentui/web-components 3.0.0-alpha.1 → 3.0.0-alpha.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (109) hide show
  1. package/.eslintrc.json +62 -0
  2. package/CHANGELOG.json +208 -8
  3. package/CHANGELOG.md +155 -97
  4. package/build/{clean.js → clean.cjs} +0 -0
  5. package/dist/dts/badge/badge.d.ts +49 -0
  6. package/dist/dts/badge/badge.definition.d.ts +11 -0
  7. package/dist/dts/badge/badge.options.d.ts +73 -0
  8. package/dist/dts/badge/badge.stories.d.ts +12 -0
  9. package/dist/dts/badge/badge.styles.d.ts +4 -0
  10. package/dist/dts/badge/badge.template.d.ts +9 -0
  11. package/dist/dts/badge/define.d.ts +1 -0
  12. package/dist/dts/badge/index.d.ts +5 -0
  13. package/dist/dts/counter-badge/counter-badge.d.ts +90 -0
  14. package/dist/dts/counter-badge/counter-badge.definition.d.ts +11 -0
  15. package/dist/dts/counter-badge/counter-badge.options.d.ts +69 -0
  16. package/dist/dts/counter-badge/counter-badge.stories.d.ts +14 -0
  17. package/dist/dts/counter-badge/counter-badge.styles.d.ts +4 -0
  18. package/dist/dts/counter-badge/counter-badge.template.d.ts +7 -0
  19. package/dist/dts/counter-badge/define.d.ts +1 -0
  20. package/dist/dts/counter-badge/index.d.ts +5 -0
  21. package/dist/dts/fluent-design-system.d.ts +5 -0
  22. package/dist/dts/index-rollup.d.ts +1 -1
  23. package/dist/dts/index.d.ts +6 -1
  24. package/dist/dts/progress-bar/define.d.ts +1 -0
  25. package/dist/dts/progress-bar/index.d.ts +5 -0
  26. package/dist/dts/progress-bar/progress-bar.d.ts +30 -0
  27. package/dist/dts/progress-bar/progress-bar.definition.d.ts +10 -0
  28. package/dist/dts/progress-bar/progress-bar.options.d.ts +41 -0
  29. package/dist/dts/progress-bar/progress-bar.stories.d.ts +9 -0
  30. package/dist/dts/progress-bar/progress-bar.styles.d.ts +4 -0
  31. package/dist/dts/progress-bar/progress-bar.template.d.ts +3 -0
  32. package/dist/dts/spinner/define.d.ts +1 -0
  33. package/dist/dts/spinner/index.d.ts +5 -0
  34. package/dist/dts/spinner/spinner.d.ts +25 -0
  35. package/dist/dts/spinner/spinner.definition.d.ts +11 -0
  36. package/dist/dts/spinner/spinner.options.d.ts +32 -0
  37. package/dist/dts/spinner/spinner.stories.d.ts +8 -0
  38. package/dist/dts/spinner/spinner.styles.d.ts +1 -0
  39. package/dist/dts/spinner/spinner.template.d.ts +3 -0
  40. package/dist/dts/styles/index.d.ts +1 -0
  41. package/dist/dts/styles/partials/badge.partials.d.ts +28 -0
  42. package/dist/dts/styles/partials/index.d.ts +1 -0
  43. package/dist/dts/text/define.d.ts +1 -0
  44. package/dist/dts/text/index.d.ts +5 -0
  45. package/dist/dts/text/text.d.ts +91 -0
  46. package/dist/dts/text/text.definition.d.ts +10 -0
  47. package/dist/dts/text/text.options.d.ts +67 -0
  48. package/dist/dts/text/text.stories.d.ts +8 -0
  49. package/dist/dts/text/text.styles.d.ts +4 -0
  50. package/dist/dts/text/text.template.d.ts +6 -0
  51. package/dist/dts/theme/index.d.ts +2 -2
  52. package/dist/esm/badge/badge.definition.js +18 -0
  53. package/dist/esm/badge/badge.js +42 -0
  54. package/dist/esm/badge/badge.options.js +45 -0
  55. package/dist/esm/badge/badge.stories.js +108 -0
  56. package/dist/esm/badge/badge.styles.js +29 -0
  57. package/dist/esm/badge/badge.template.js +14 -0
  58. package/dist/esm/badge/define.js +3 -0
  59. package/dist/esm/badge/index.js +5 -0
  60. package/dist/esm/counter-badge/counter-badge.definition.js +18 -0
  61. package/dist/esm/counter-badge/counter-badge.js +89 -0
  62. package/dist/esm/counter-badge/counter-badge.options.js +42 -0
  63. package/dist/esm/counter-badge/counter-badge.stories.js +102 -0
  64. package/dist/esm/counter-badge/counter-badge.styles.js +30 -0
  65. package/dist/esm/counter-badge/counter-badge.template.js +12 -0
  66. package/dist/esm/counter-badge/define.js +3 -0
  67. package/dist/esm/counter-badge/index.js +5 -0
  68. package/dist/esm/fluent-design-system.js +5 -0
  69. package/dist/esm/index-rollup.js +1 -1
  70. package/dist/esm/index.js +6 -1
  71. package/dist/esm/progress-bar/define.js +3 -0
  72. package/dist/esm/progress-bar/index.js +5 -0
  73. package/dist/esm/progress-bar/progress-bar.definition.js +17 -0
  74. package/dist/esm/progress-bar/progress-bar.js +18 -0
  75. package/dist/esm/progress-bar/progress-bar.options.js +25 -0
  76. package/dist/esm/progress-bar/progress-bar.stories.js +60 -0
  77. package/dist/esm/progress-bar/progress-bar.styles.js +155 -0
  78. package/dist/esm/progress-bar/progress-bar.template.js +5 -0
  79. package/dist/esm/spinner/define.js +3 -0
  80. package/dist/esm/spinner/index.js +5 -0
  81. package/dist/esm/spinner/spinner.definition.js +18 -0
  82. package/dist/esm/spinner/spinner.js +15 -0
  83. package/dist/esm/spinner/spinner.options.js +21 -0
  84. package/dist/esm/spinner/spinner.stories.js +45 -0
  85. package/dist/esm/spinner/spinner.styles.js +95 -0
  86. package/dist/esm/spinner/spinner.template.js +21 -0
  87. package/dist/esm/styles/index.js +1 -0
  88. package/dist/esm/styles/partials/badge.partials.js +272 -0
  89. package/dist/esm/styles/partials/index.js +1 -0
  90. package/dist/esm/text/define.js +3 -0
  91. package/dist/esm/text/index.js +5 -0
  92. package/dist/esm/text/text.definition.js +17 -0
  93. package/dist/esm/text/text.js +91 -0
  94. package/dist/esm/text/text.options.js +45 -0
  95. package/dist/esm/text/text.stories.js +111 -0
  96. package/dist/esm/text/text.styles.js +104 -0
  97. package/dist/esm/text/text.template.js +5 -0
  98. package/dist/esm/theme/index.js +2 -2
  99. package/dist/esm/theme/set-theme.js +1 -1
  100. package/dist/esm/theme/theme.stories.js +1 -1
  101. package/dist/fluent-web-components.api.json +14330 -8
  102. package/dist/tsdoc-metadata.json +1 -1
  103. package/dist/web-components.d.ts +1460 -1
  104. package/dist/web-components.js +5713 -2
  105. package/dist/web-components.min.js +273 -1
  106. package/docs/api-report.md +1471 -1
  107. package/package.json +48 -16
  108. package/rollup.config.js +5 -0
  109. package/karma.conf.js +0 -147
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,5 @@
1
+ export * from './text.js';
2
+ export * from './text.options.js';
3
+ export { template as TextTemplate } from './text.template.js';
4
+ export { styles as TextStyles } from './text.styles.js';
5
+ export { definition as TextDefinition } from './text.definition.js';
@@ -0,0 +1,91 @@
1
+ import { FASTElement } from '@microsoft/fast-element';
2
+ import type { TextAlign, TextFont, TextSize, TextWeight } from './text.options.js';
3
+ /**
4
+ * The base class used for constructing a fluent-text custom element
5
+ * @public
6
+ */
7
+ export declare class Text extends FASTElement {
8
+ /**
9
+ * The text will not wrap
10
+ * NOTE: In Fluent UI React v9 this is "wrap"
11
+ * Boolean attributes which default to true in HTML can't be switched off in the DOM
12
+ *
13
+ * @public
14
+ * @remarks
15
+ * HTML Attribute: nowrap
16
+ */
17
+ nowrap: boolean;
18
+ /**
19
+ * The text truncates
20
+ *
21
+ * @public
22
+ * @remarks
23
+ * HTML Attribute: truncate
24
+ */
25
+ truncate: boolean;
26
+ /**
27
+ * The text style is italic
28
+ *
29
+ * @public
30
+ * @remarks
31
+ * HTML Attribute: italic
32
+ */
33
+ italic: boolean;
34
+ /**
35
+ * The text style is underline
36
+ *
37
+ * @public
38
+ * @remarks
39
+ * HTML Attribute: underline
40
+ */
41
+ underline: boolean;
42
+ /**
43
+ * The text style is strikethrough
44
+ *
45
+ * @public
46
+ * @remarks
47
+ * HTML Attribute: strikethrough
48
+ */
49
+ strikethrough: boolean;
50
+ /**
51
+ * An text can take up the width of its container.
52
+ *
53
+ * @public
54
+ * @remarks
55
+ * HTML Attribute: block
56
+ */
57
+ block: boolean;
58
+ /**
59
+ * THe Text size
60
+ *
61
+ * @public
62
+ * @remarks
63
+ * HTML Attribute: size
64
+ *
65
+ */
66
+ size: TextSize;
67
+ /**
68
+ * THe Text font
69
+ *
70
+ * @public
71
+ * @remarks
72
+ * HTML Attribute: font
73
+ */
74
+ font: TextFont;
75
+ /**
76
+ * THe Text weight
77
+ *
78
+ * @public
79
+ * @remarks
80
+ * HTML Attribute: weight
81
+ */
82
+ weight: TextWeight;
83
+ /**
84
+ * THe Text align
85
+ *
86
+ * @public
87
+ * @remarks
88
+ * HTML Attribute: align
89
+ */
90
+ align: TextAlign;
91
+ }
@@ -0,0 +1,10 @@
1
+ import { Text } from './text.js';
2
+ /**
3
+ * The Fluent Text Element.
4
+ *
5
+ *
6
+ * @public
7
+ * @remarks
8
+ * HTML Element: \<fluent-text\>
9
+ */
10
+ export declare const definition: import("@microsoft/fast-element").FASTElementDefinition<typeof Text>;
@@ -0,0 +1,67 @@
1
+ import { ValuesOf } from '@microsoft/fast-foundation';
2
+ /**
3
+ * TextSize constants
4
+ * @public
5
+ */
6
+ export declare const TextSize: {
7
+ readonly _100: "100";
8
+ readonly _200: "200";
9
+ readonly _300: "300";
10
+ readonly _400: "400";
11
+ readonly _500: "500";
12
+ readonly _600: "600";
13
+ readonly _700: "700";
14
+ readonly _800: "800";
15
+ readonly _900: "900";
16
+ readonly _1000: "1000";
17
+ };
18
+ /**
19
+ * The type for TextSize
20
+ * The font size and line height based on the theme tokens
21
+ * @public
22
+ */
23
+ export declare type TextSize = ValuesOf<typeof TextSize>;
24
+ /**
25
+ * TextFont Constants
26
+ * @public
27
+ */
28
+ export declare const TextFont: {
29
+ readonly base: "base";
30
+ readonly numeric: "numeric";
31
+ readonly monospace: "monospace";
32
+ };
33
+ /**
34
+ * Applies font family to the content
35
+ * @public
36
+ */
37
+ export declare type TextFont = ValuesOf<typeof TextFont>;
38
+ /**
39
+ * TextWeight Constants
40
+ * @public
41
+ */
42
+ export declare const TextWeight: {
43
+ readonly medium: "medium";
44
+ readonly regular: "regular";
45
+ readonly semibold: "semibold";
46
+ readonly bold: "bold";
47
+ };
48
+ /**
49
+ * Applies font weight to the content
50
+ * @public
51
+ */
52
+ export declare type TextWeight = ValuesOf<typeof TextWeight>;
53
+ /**
54
+ * TextAlign Constants
55
+ * @public
56
+ */
57
+ export declare const TextAlign: {
58
+ readonly start: "start";
59
+ readonly end: "end";
60
+ readonly center: "center";
61
+ readonly justify: "justify";
62
+ };
63
+ /**
64
+ * Aligns the content
65
+ * @public
66
+ */
67
+ export declare type TextAlign = ValuesOf<typeof TextAlign>;
@@ -0,0 +1,8 @@
1
+ import type { Args, Meta } from '@storybook/html';
2
+ import type { Text as FluentText } from './text.js';
3
+ import './define.js';
4
+ declare type TextStoryArgs = Args & FluentText;
5
+ declare type TextStoryMeta = Meta<TextStoryArgs>;
6
+ declare const _default: TextStoryMeta;
7
+ export default _default;
8
+ export declare const Text: any;
@@ -0,0 +1,4 @@
1
+ /** Text styles
2
+ * @public
3
+ */
4
+ export declare const styles: import("@microsoft/fast-element").ElementStyles;
@@ -0,0 +1,6 @@
1
+ import { ElementViewTemplate } from '@microsoft/fast-element';
2
+ import type { Text } from './text.js';
3
+ /**
4
+ * @internal
5
+ */
6
+ export declare const template: ElementViewTemplate<Text>;
@@ -1,2 +1,2 @@
1
- export * from './design-tokens';
2
- export { setTheme } from './set-theme';
1
+ export * from './design-tokens.js';
2
+ export { setTheme } from './set-theme.js';
@@ -0,0 +1,18 @@
1
+ import { FluentDesignSystem } from '../fluent-design-system.js';
2
+ import { Badge } from './badge.js';
3
+ import { styles } from './badge.styles.js';
4
+ import { template } from './badge.template.js';
5
+ /**
6
+ * The Fluent Badge Element. Implements {@link @microsoft/fast-foundation#Badge },
7
+ * {@link @microsoft/fast-foundation#badgeTemplate}
8
+ *
9
+ *
10
+ * @public
11
+ * @remarks
12
+ * HTML Element: \<fluent-badge\>
13
+ */
14
+ export const definition = Badge.compose({
15
+ name: `${FluentDesignSystem.prefix}-badge`,
16
+ template,
17
+ styles,
18
+ });
@@ -0,0 +1,42 @@
1
+ import { __decorate } from "tslib";
2
+ import { attr, FASTElement } from '@microsoft/fast-element';
3
+ import { applyMixins, StartEnd } from '@microsoft/fast-foundation';
4
+ import { BadgeAppearance, BadgeColor } from './badge.options.js';
5
+ /**
6
+ * The base class used for constructing a fluent-badge custom element
7
+ * @public
8
+ */
9
+ export class Badge extends FASTElement {
10
+ constructor() {
11
+ super(...arguments);
12
+ /**
13
+ * The appearance the badge should have.
14
+ *
15
+ * @public
16
+ * @remarks
17
+ * HTML Attribute: appearance
18
+ */
19
+ this.appearance = BadgeAppearance.filled;
20
+ /**
21
+ * The color the badge should have.
22
+ *
23
+ * @public
24
+ * @remarks
25
+ * HTML Attribute: color
26
+ */
27
+ this.color = BadgeColor.brand;
28
+ }
29
+ }
30
+ __decorate([
31
+ attr
32
+ ], Badge.prototype, "appearance", void 0);
33
+ __decorate([
34
+ attr
35
+ ], Badge.prototype, "color", void 0);
36
+ __decorate([
37
+ attr
38
+ ], Badge.prototype, "shape", void 0);
39
+ __decorate([
40
+ attr
41
+ ], Badge.prototype, "size", void 0);
42
+ applyMixins(Badge, StartEnd);
@@ -0,0 +1,45 @@
1
+ /**
2
+ * BadgeAppearance constants
3
+ * @public
4
+ */
5
+ export const BadgeAppearance = {
6
+ filled: 'filled',
7
+ ghost: 'ghost',
8
+ outline: 'outline',
9
+ tint: 'tint',
10
+ };
11
+ /**
12
+ * BadgeColor constants
13
+ * @public
14
+ */
15
+ export const BadgeColor = {
16
+ brand: 'brand',
17
+ danger: 'danger',
18
+ important: 'important',
19
+ informative: 'informative',
20
+ severe: 'severe',
21
+ subtle: 'subtle',
22
+ success: 'success',
23
+ warning: 'warning',
24
+ };
25
+ /**
26
+ * A Badge can be square, circular or rounded.
27
+ * @public
28
+ */
29
+ export const BadgeShape = {
30
+ circular: 'circular',
31
+ rounded: 'rounded',
32
+ square: 'square',
33
+ };
34
+ /**
35
+ * A Badge can be square, circular or rounded.
36
+ * @public
37
+ */
38
+ export const BadgeSize = {
39
+ tiny: 'tiny',
40
+ extraSmall: 'extra-small',
41
+ small: 'small',
42
+ medium: 'medium',
43
+ large: 'large',
44
+ extraLarge: 'extra-large',
45
+ };
@@ -0,0 +1,108 @@
1
+ import { html, when } from '@microsoft/fast-element';
2
+ import { renderComponent } from '../__test__/helpers.js';
3
+ import { BadgeAppearance, BadgeColor, BadgeShape, BadgeSize } from './badge.options.js';
4
+ import './define.js';
5
+ const storyTemplate = html `
6
+ <fluent-badge appearance="${x => x.appearance}" color="${x => x.color}" shape="${x => x.shape}" size="${x => x.size}">
7
+ ${when(x => x.iconPosition === 'start', html `<svg
8
+ slot="start"
9
+ aria-hidden="true"
10
+ xmlns="http://www.w3.org/2000/svg"
11
+ width="1em"
12
+ height="1em"
13
+ preserveAspectRatio="xMidYMid meet"
14
+ viewBox="0 0 20 20"
15
+ >
16
+ <path
17
+ fill="currentColor"
18
+ d="M14.69 11.503c1 0 1.81.81 1.81 1.81v.689h-.005c-.034.78-.248 1.757-1.123 2.555C14.416 17.43 12.765 18 10 18c-2.766 0-4.416-.57-5.372-1.443c-.875-.798-1.089-1.776-1.123-2.555H3.5v-.69c0-.999.81-1.809 1.81-1.809h9.38ZM6.5 3A1.5 1.5 0 0 0 5 4.5v4A1.5 1.5 0 0 0 6.5 10h7A1.5 1.5 0 0 0 15 8.5v-4A1.5 1.5 0 0 0 13.5 3h-3v-.5A.48.48 0 0 0 10 2c-.276 0-.5.23-.5.5V3h-3ZM7 6.5a1 1 0 1 1 2 0a1 1 0 0 1-2 0Zm4 0a1 1 0 1 1 2 0a1 1 0 0 1-2 0Z"
19
+ />
20
+ </svg>`)}
21
+ ${x => x.content}
22
+ ${when(x => x.iconPosition === 'end', html `<svg
23
+ slot="start"
24
+ aria-hidden="true"
25
+ xmlns="http://www.w3.org/2000/svg"
26
+ width="1em"
27
+ height="1em"
28
+ preserveAspectRatio="xMidYMid meet"
29
+ viewBox="0 0 20 20"
30
+ >
31
+ <path
32
+ fill="currentColor"
33
+ d="M14.69 11.503c1 0 1.81.81 1.81 1.81v.689h-.005c-.034.78-.248 1.757-1.123 2.555C14.416 17.43 12.765 18 10 18c-2.766 0-4.416-.57-5.372-1.443c-.875-.798-1.089-1.776-1.123-2.555H3.5v-.69c0-.999.81-1.809 1.81-1.809h9.38ZM6.5 3A1.5 1.5 0 0 0 5 4.5v4A1.5 1.5 0 0 0 6.5 10h7A1.5 1.5 0 0 0 15 8.5v-4A1.5 1.5 0 0 0 13.5 3h-3v-.5A.48.48 0 0 0 10 2c-.276 0-.5.23-.5.5V3h-3ZM7 6.5a1 1 0 1 1 2 0a1 1 0 0 1-2 0Zm4 0a1 1 0 1 1 2 0a1 1 0 0 1-2 0Z"
34
+ />
35
+ </svg>`)}
36
+ </fluent-badge>
37
+ `;
38
+ export default {
39
+ title: 'Components/Badge/Badge',
40
+ args: {
41
+ content: null,
42
+ },
43
+ argTypes: {
44
+ appearance: {
45
+ options: Object.values(BadgeAppearance),
46
+ control: {
47
+ type: 'select',
48
+ },
49
+ },
50
+ color: {
51
+ options: Object.values(BadgeColor),
52
+ control: {
53
+ type: 'select',
54
+ },
55
+ },
56
+ shape: {
57
+ options: Object.values(BadgeShape),
58
+ control: {
59
+ type: 'select',
60
+ },
61
+ },
62
+ size: {
63
+ options: Object.values(BadgeSize),
64
+ control: {
65
+ type: 'select',
66
+ },
67
+ },
68
+ iconPosition: {
69
+ options: ['none', 'start', 'end'],
70
+ control: {
71
+ type: 'select',
72
+ },
73
+ },
74
+ content: {
75
+ control: 'text',
76
+ },
77
+ },
78
+ };
79
+ export const Badge = renderComponent(storyTemplate).bind({});
80
+ export const Appearance = renderComponent(html `
81
+ <fluent-badge appearance="filled">filled</fluent-badge>
82
+ <fluent-badge appearance="ghost">ghost</fluent-badge>
83
+ <fluent-badge appearance="outline">outline</fluent-badge>
84
+ <fluent-badge appearance="tint">tint</fluent-badge>
85
+ `);
86
+ export const Color = renderComponent(html `
87
+ <fluent-badge color="brand">brand</fluent-badge>
88
+ <fluent-badge color="danger">danger</fluent-badge>
89
+ <fluent-badge color="important">important</fluent-badge>
90
+ <fluent-badge color="informative">informative</fluent-badge>
91
+ <fluent-badge color="severe">severe</fluent-badge>
92
+ <fluent-badge color="subtle">subtle</fluent-badge>
93
+ <fluent-badge color="success">success</fluent-badge>
94
+ <fluent-badge color="warning">warning</fluent-badge>
95
+ `);
96
+ export const Shape = renderComponent(html `
97
+ <fluent-badge shape="circular"></fluent-badge>
98
+ <fluent-badge shape="rounded"></fluent-badge>
99
+ <fluent-badge shape="square"></fluent-badge>
100
+ `);
101
+ export const Size = renderComponent(html `
102
+ <fluent-badge size="tiny"></fluent-badge>
103
+ <fluent-badge size="extra-small"></fluent-badge>
104
+ <fluent-badge size="small"></fluent-badge>
105
+ <fluent-badge size="medium"></fluent-badge>
106
+ <fluent-badge size="large"></fluent-badge>
107
+ <fluent-badge size="extra-large"></fluent-badge>
108
+ `);
@@ -0,0 +1,29 @@
1
+ import { css } from '@microsoft/fast-element';
2
+ import { badgeBaseStyles, badgeFilledStyles, badgeGhostStyles, badgeOutlineStyles, badgeSizeStyles, badgeTintStyles, } from '../styles/index.js';
3
+ import { borderRadiusMedium, borderRadiusNone, borderRadiusSmall } from '../theme/design-tokens.js';
4
+ // why is the border not showing up?
5
+ /** Badge styles
6
+ * @public
7
+ */
8
+ export const styles = css `
9
+ :host([shape='square']) {
10
+ border-radius: ${borderRadiusNone};
11
+ }
12
+
13
+ :host([shape='rounded']) {
14
+ border-radius: ${borderRadiusMedium};
15
+ }
16
+
17
+ :host([shape='rounded'][size='tiny']),
18
+ :host([shape='rounded'][size='extra-small']),
19
+ :host([shape='rounded'][size='small']) {
20
+ border-radius: ${borderRadiusSmall};
21
+ }
22
+
23
+ ${badgeSizeStyles}
24
+ ${badgeFilledStyles}
25
+ ${badgeGhostStyles}
26
+ ${badgeOutlineStyles}
27
+ ${badgeTintStyles}
28
+ ${badgeBaseStyles}
29
+ `;
@@ -0,0 +1,14 @@
1
+ import { html } from '@microsoft/fast-element';
2
+ import { endSlotTemplate, startSlotTemplate, staticallyCompose } from '@microsoft/fast-foundation';
3
+ /**
4
+ * The template for the Badge component.
5
+ * @public
6
+ */
7
+ export function badgeTemplate(options = {}) {
8
+ return html `
9
+ ${startSlotTemplate(options)}
10
+ <slot>${staticallyCompose(options.defaultContent)}</slot>
11
+ ${endSlotTemplate(options)}
12
+ `;
13
+ }
14
+ export const template = badgeTemplate();
@@ -0,0 +1,3 @@
1
+ import { FluentDesignSystem } from '../fluent-design-system.js';
2
+ import { definition } from './badge.definition.js';
3
+ definition.define(FluentDesignSystem.registry);
@@ -0,0 +1,5 @@
1
+ export * from './badge.js';
2
+ export * from './badge.options.js';
3
+ export { template as BadgeTemplate } from './badge.template.js';
4
+ export { styles as BadgeStyles } from './badge.styles.js';
5
+ export { definition as BadgeDefinition } from './badge.definition.js';
@@ -0,0 +1,18 @@
1
+ import { FluentDesignSystem } from '../fluent-design-system.js';
2
+ import { CounterBadge } from './counter-badge.js';
3
+ import { styles } from './counter-badge.styles.js';
4
+ import { template } from './counter-badge.template.js';
5
+ /**
6
+ * The Fluent CounterBadge Element. Implements {@link @microsoft/fast-foundation#Badge },
7
+ * {@link @microsoft/fast-foundation#badgeTemplate}
8
+ *
9
+ *
10
+ * @public
11
+ * @remarks
12
+ * HTML Element: \<fluent-counter-badge\>
13
+ */
14
+ export const definition = CounterBadge.compose({
15
+ name: `${FluentDesignSystem.prefix}-counter-badge`,
16
+ template,
17
+ styles,
18
+ });
@@ -0,0 +1,89 @@
1
+ import { __decorate } from "tslib";
2
+ import { attr, FASTElement, nullableNumberConverter } from '@microsoft/fast-element';
3
+ import { applyMixins, StartEnd } from '@microsoft/fast-foundation';
4
+ /**
5
+ * The base class used for constructing a fluent-badge custom element
6
+ * @public
7
+ */
8
+ export class CounterBadge extends FASTElement {
9
+ constructor() {
10
+ super(...arguments);
11
+ /**
12
+ * The count the badge should have.
13
+ *
14
+ * @public
15
+ * @remarks
16
+ * HTML Attribute: count
17
+ */
18
+ this.count = 0;
19
+ /**
20
+ * Max number to be displayed
21
+ *
22
+ * @public
23
+ * @remarks
24
+ * HTML Attribute: overflow-count
25
+ */
26
+ this.overflowCount = 99;
27
+ /**
28
+ * If the badge should be shown when count is 0
29
+ *
30
+ * @public
31
+ * @remarks
32
+ * HTML Attribute: show-zero
33
+ */
34
+ this.showZero = false;
35
+ /**
36
+ * If a dot should be displayed without the count
37
+ *
38
+ * @public
39
+ * @remarks
40
+ * HTML Attribute: dot
41
+ */
42
+ this.dot = false;
43
+ }
44
+ countChanged() {
45
+ this.setCount();
46
+ }
47
+ overflowCountChanged() {
48
+ this.setCount();
49
+ }
50
+ /**
51
+ * @internal
52
+ * Function to set the count
53
+ * This is the default slotted content for the counter badge
54
+ * If children are slotted, that will override the value returned
55
+ */
56
+ setCount() {
57
+ var _a;
58
+ const count = (_a = this.count) !== null && _a !== void 0 ? _a : 0;
59
+ if ((count !== 0 || this.showZero) && !this.dot) {
60
+ return count > this.overflowCount ? `${this.overflowCount}+` : `${count}`;
61
+ }
62
+ return;
63
+ }
64
+ }
65
+ __decorate([
66
+ attr
67
+ ], CounterBadge.prototype, "appearance", void 0);
68
+ __decorate([
69
+ attr
70
+ ], CounterBadge.prototype, "color", void 0);
71
+ __decorate([
72
+ attr
73
+ ], CounterBadge.prototype, "shape", void 0);
74
+ __decorate([
75
+ attr
76
+ ], CounterBadge.prototype, "size", void 0);
77
+ __decorate([
78
+ attr({ converter: nullableNumberConverter })
79
+ ], CounterBadge.prototype, "count", void 0);
80
+ __decorate([
81
+ attr({ attribute: 'overflow-count', converter: nullableNumberConverter })
82
+ ], CounterBadge.prototype, "overflowCount", void 0);
83
+ __decorate([
84
+ attr({ attribute: 'show-zero', mode: 'boolean' })
85
+ ], CounterBadge.prototype, "showZero", void 0);
86
+ __decorate([
87
+ attr({ mode: 'boolean' })
88
+ ], CounterBadge.prototype, "dot", void 0);
89
+ applyMixins(CounterBadge, StartEnd);
@@ -0,0 +1,42 @@
1
+ /**
2
+ * CounterBadgeAppearance constants
3
+ * @public
4
+ */
5
+ export const CounterBadgeAppearance = {
6
+ filled: 'filled',
7
+ ghost: 'ghost',
8
+ };
9
+ /**
10
+ * CounterBadgeColor constants
11
+ * @public
12
+ */
13
+ export const CounterBadgeColor = {
14
+ brand: 'brand',
15
+ danger: 'danger',
16
+ important: 'important',
17
+ informative: 'informative',
18
+ severe: 'severe',
19
+ subtle: 'subtle',
20
+ success: 'success',
21
+ warning: 'warning',
22
+ };
23
+ /**
24
+ * A CounterBadge shape can be circular or rounded.
25
+ * @public
26
+ */
27
+ export const CounterBadgeShape = {
28
+ circular: 'circular',
29
+ rounded: 'rounded',
30
+ };
31
+ /**
32
+ * A CounterBadge can be square, circular or rounded.
33
+ * @public
34
+ */
35
+ export const CounterBadgeSize = {
36
+ tiny: 'tiny',
37
+ extraSmall: 'extra-small',
38
+ small: 'small',
39
+ medium: 'medium',
40
+ large: 'large',
41
+ extraLarge: 'extra-large',
42
+ };