@fluentui/web-components 3.0.0-beta.30 → 3.0.0-beta.31

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 (49) hide show
  1. package/CHANGELOG.md +12 -2
  2. package/dist/dts/anchor-button/anchor-button.d.ts +38 -3
  3. package/dist/dts/anchor-button/anchor-button.options.d.ts +0 -1
  4. package/dist/dts/badge/badge.d.ts +30 -0
  5. package/dist/dts/button/button.d.ts +25 -1
  6. package/dist/dts/button/button.options.d.ts +0 -1
  7. package/dist/dts/compound-button/compound-button.options.d.ts +0 -5
  8. package/dist/dts/counter-badge/counter-badge.d.ts +36 -0
  9. package/dist/dts/menu-button/menu-button.options.d.ts +0 -1
  10. package/dist/dts/styles/states/index.d.ts +110 -0
  11. package/dist/dts/toggle-button/toggle-button.options.d.ts +0 -1
  12. package/dist/esm/anchor-button/anchor-button.js +76 -8
  13. package/dist/esm/anchor-button/anchor-button.js.map +1 -1
  14. package/dist/esm/anchor-button/anchor-button.styles.js +8 -1
  15. package/dist/esm/anchor-button/anchor-button.styles.js.map +1 -1
  16. package/dist/esm/anchor-button/anchor-button.template.js +2 -2
  17. package/dist/esm/anchor-button/anchor-button.template.js.map +1 -1
  18. package/dist/esm/badge/badge.js +59 -0
  19. package/dist/esm/badge/badge.js.map +1 -1
  20. package/dist/esm/badge/badge.styles.js +6 -5
  21. package/dist/esm/badge/badge.styles.js.map +1 -1
  22. package/dist/esm/button/button.js +48 -0
  23. package/dist/esm/button/button.js.map +1 -1
  24. package/dist/esm/button/button.options.js +0 -1
  25. package/dist/esm/button/button.options.js.map +1 -1
  26. package/dist/esm/button/button.styles.js +40 -49
  27. package/dist/esm/button/button.styles.js.map +1 -1
  28. package/dist/esm/compound-button/compound-button.styles.js +14 -15
  29. package/dist/esm/compound-button/compound-button.styles.js.map +1 -1
  30. package/dist/esm/counter-badge/counter-badge.js +67 -0
  31. package/dist/esm/counter-badge/counter-badge.js.map +1 -1
  32. package/dist/esm/counter-badge/counter-badge.styles.js +12 -6
  33. package/dist/esm/counter-badge/counter-badge.styles.js.map +1 -1
  34. package/dist/esm/link/link.styles.js +6 -0
  35. package/dist/esm/link/link.styles.js.map +1 -1
  36. package/dist/esm/link/link.template.js +2 -2
  37. package/dist/esm/link/link.template.js.map +1 -1
  38. package/dist/esm/styles/partials/badge.partials.js +43 -42
  39. package/dist/esm/styles/partials/badge.partials.js.map +1 -1
  40. package/dist/esm/styles/states/index.js +112 -0
  41. package/dist/esm/styles/states/index.js.map +1 -0
  42. package/dist/esm/toggle-button/toggle-button.js +2 -1
  43. package/dist/esm/toggle-button/toggle-button.js.map +1 -1
  44. package/dist/esm/toggle-button/toggle-button.styles.js +24 -23
  45. package/dist/esm/toggle-button/toggle-button.styles.js.map +1 -1
  46. package/dist/web-components.d.ts +129 -13
  47. package/dist/web-components.js +343 -80
  48. package/dist/web-components.min.js +305 -304
  49. package/package.json +3 -2
package/CHANGELOG.md CHANGED
@@ -1,12 +1,22 @@
1
1
  # Change Log - @fluentui/web-components
2
2
 
3
- This log was last generated on Fri, 14 Jun 2024 04:06:00 GMT and should not be manually modified.
3
+ This log was last generated on Tue, 18 Jun 2024 04:05:24 GMT and should not be manually modified.
4
4
 
5
5
  <!-- Start content -->
6
6
 
7
+ ## [3.0.0-beta.31](https://github.com/microsoft/fluentui/tree/@fluentui/web-components_v3.0.0-beta.31)
8
+
9
+ Tue, 18 Jun 2024 04:05:24 GMT
10
+ [Compare changes](https://github.com/microsoft/fluentui/compare/@fluentui/web-components_v3.0.0-beta.30..@fluentui/web-components_v3.0.0-beta.31)
11
+
12
+ ### Changes
13
+
14
+ - feat: update button and anchor button to leverage custom states for variants ([PR #31718](https://github.com/microsoft/fluentui/pull/31718) by 13071055+chrisdholt@users.noreply.github.com)
15
+ - update badge to use element internals custom states ([PR #31733](https://github.com/microsoft/fluentui/pull/31733) by 13071055+chrisdholt@users.noreply.github.com)
16
+
7
17
  ## [3.0.0-beta.30](https://github.com/microsoft/fluentui/tree/@fluentui/web-components_v3.0.0-beta.30)
8
18
 
9
- Fri, 14 Jun 2024 04:06:00 GMT
19
+ Fri, 14 Jun 2024 04:06:06 GMT
10
20
  [Compare changes](https://github.com/microsoft/fluentui/compare/@fluentui/web-components_v3.0.0-beta.29..@fluentui/web-components_v3.0.0-beta.30)
11
21
 
12
22
  ### Changes
@@ -20,6 +20,11 @@ export type AnchorOptions = StartEndOptions<AnchorButton>;
20
20
  * @public
21
21
  */
22
22
  export declare class BaseAnchor extends FASTElement {
23
+ /**
24
+ * Holds a reference to the platform to manage ctrl+click on Windows and cmd+click on Mac
25
+ * @internal
26
+ */
27
+ private readonly isMac;
23
28
  /**
24
29
  * The internal {@link https://developer.mozilla.org/docs/Web/API/ElementInternals | `ElementInternals`} instance for the component.
25
30
  *
@@ -120,15 +125,21 @@ export declare class BaseAnchor extends FASTElement {
120
125
  * @param e - The event object
121
126
  * @internal
122
127
  */
123
- clickHandler(): boolean;
128
+ clickHandler(e: PointerEvent): boolean;
124
129
  /**
125
- * Handles keypress events for the anchor.
130
+ * Handles keydown events for the anchor.
126
131
  *
127
132
  * @param e - the keyboard event
128
133
  * @returns - the return value of the click handler
129
134
  * @public
130
135
  */
131
- keypressHandler(e: KeyboardEvent): boolean | void;
136
+ keydownHandler(e: KeyboardEvent): boolean | void;
137
+ /**
138
+ * Handles navigation based on input
139
+ * If the metaKey is pressed, opens the href in a new window, if false, uses the click on the proxy
140
+ * @internal
141
+ */
142
+ private handleNavigation;
132
143
  /**
133
144
  * A method for updating proxy attributes when attributes have changed
134
145
  * @internal
@@ -147,6 +158,12 @@ export declare class AnchorButton extends BaseAnchor {
147
158
  * HTML Attribute: `appearance`
148
159
  */
149
160
  appearance?: AnchorButtonAppearance | undefined;
161
+ /**
162
+ * Handles changes to appearance attribute custom states
163
+ * @param prev - the previous state
164
+ * @param next - the next state
165
+ */
166
+ appearanceChanged(prev: AnchorButtonAppearance | undefined, next: AnchorButtonAppearance | undefined): void;
150
167
  /**
151
168
  * The shape the anchor button should have.
152
169
  *
@@ -155,6 +172,12 @@ export declare class AnchorButton extends BaseAnchor {
155
172
  * HTML Attribute: `shape`
156
173
  */
157
174
  shape?: AnchorButtonShape | undefined;
175
+ /**
176
+ * Handles changes to shape attribute custom states
177
+ * @param prev - the previous state
178
+ * @param next - the next state
179
+ */
180
+ shapeChanged(prev: AnchorButtonShape | undefined, next: AnchorButtonShape | undefined): void;
158
181
  /**
159
182
  * The size the anchor button should have.
160
183
  *
@@ -163,6 +186,12 @@ export declare class AnchorButton extends BaseAnchor {
163
186
  * HTML Attribute: `size`
164
187
  */
165
188
  size?: AnchorButtonSize;
189
+ /**
190
+ * Handles changes to size attribute custom states
191
+ * @param prev - the previous state
192
+ * @param next - the next state
193
+ */
194
+ sizeChanged(prev: AnchorButtonSize | undefined, next: AnchorButtonSize | undefined): void;
166
195
  /**
167
196
  * The anchor button has an icon only, no text content
168
197
  *
@@ -171,6 +200,12 @@ export declare class AnchorButton extends BaseAnchor {
171
200
  * HTML Attribute: `icon-only`
172
201
  */
173
202
  iconOnly: boolean;
203
+ /**
204
+ * Handles changes to icon only custom states
205
+ * @param prev - the previous state
206
+ * @param next - the next state
207
+ */
208
+ iconOnlyChanged(prev: boolean, next: boolean): void;
174
209
  }
175
210
  /**
176
211
  * Mark internal because exporting class and interface of the same name
@@ -8,7 +8,6 @@ export declare const AnchorButtonAppearance: {
8
8
  readonly primary: "primary";
9
9
  readonly outline: "outline";
10
10
  readonly subtle: "subtle";
11
- readonly secondary: "secondary";
12
11
  readonly transparent: "transparent";
13
12
  };
14
13
  /**
@@ -6,6 +6,12 @@ import { BadgeAppearance, BadgeColor, BadgeShape, BadgeSize } from './badge.opti
6
6
  * @public
7
7
  */
8
8
  export declare class Badge extends FASTElement {
9
+ /**
10
+ * The internal {@link https://developer.mozilla.org/docs/Web/API/ElementInternals | `ElementInternals`} instance for the component.
11
+ *
12
+ * @internal
13
+ */
14
+ elementInternals: ElementInternals;
9
15
  /**
10
16
  * The appearance the badge should have.
11
17
  *
@@ -14,6 +20,12 @@ export declare class Badge extends FASTElement {
14
20
  * HTML Attribute: appearance
15
21
  */
16
22
  appearance: BadgeAppearance;
23
+ /**
24
+ * Handles changes to appearance attribute custom states
25
+ * @param prev - the previous state
26
+ * @param next - the next state
27
+ */
28
+ appearanceChanged(prev: BadgeAppearance | undefined, next: BadgeAppearance | undefined): void;
17
29
  /**
18
30
  * The color the badge should have.
19
31
  *
@@ -22,6 +34,12 @@ export declare class Badge extends FASTElement {
22
34
  * HTML Attribute: color
23
35
  */
24
36
  color: BadgeColor;
37
+ /**
38
+ * Handles changes to color attribute custom states
39
+ * @param prev - the previous state
40
+ * @param next - the next state
41
+ */
42
+ colorChanged(prev: BadgeColor | undefined, next: BadgeColor | undefined): void;
25
43
  /**
26
44
  * The shape the badge should have.
27
45
  *
@@ -30,6 +48,12 @@ export declare class Badge extends FASTElement {
30
48
  * HTML Attribute: shape
31
49
  */
32
50
  shape?: BadgeShape;
51
+ /**
52
+ * Handles changes to shape attribute custom states
53
+ * @param prev - the previous state
54
+ * @param next - the next state
55
+ */
56
+ shapeChanged(prev: BadgeShape | undefined, next: BadgeShape | undefined): void;
33
57
  /**
34
58
  * The size the badge should have.
35
59
  *
@@ -38,6 +62,12 @@ export declare class Badge extends FASTElement {
38
62
  * HTML Attribute: size
39
63
  */
40
64
  size?: BadgeSize;
65
+ /**
66
+ * Handles changes to size attribute custom states
67
+ * @param prev - the previous state
68
+ * @param next - the next state
69
+ */
70
+ sizeChanged(prev: BadgeSize | undefined, next: BadgeSize | undefined): void;
41
71
  }
42
72
  /**
43
73
  * Mark internal because exporting class and interface of the same name
@@ -22,6 +22,12 @@ export declare class Button extends FASTElement {
22
22
  * HTML Attribute: `appearance`
23
23
  */
24
24
  appearance?: ButtonAppearance;
25
+ /**
26
+ * Handles changes to appearance attribute custom states
27
+ * @param prev - the previous state
28
+ * @param next - the next state
29
+ */
30
+ appearanceChanged(prev: ButtonAppearance | undefined, next: ButtonAppearance | undefined): void;
25
31
  /**
26
32
  * Indicates the button should be focused when the page is loaded.
27
33
  * @see The {@link https://developer.mozilla.org/en-US/docs/Web/HTML/Element/button#autofocus | `autofocus`} attribute
@@ -67,7 +73,7 @@ export declare class Button extends FASTElement {
67
73
  *
68
74
  * @internal
69
75
  */
70
- protected elementInternals: ElementInternals;
76
+ elementInternals: ElementInternals;
71
77
  /**
72
78
  * The associated form element.
73
79
  *
@@ -155,6 +161,12 @@ export declare class Button extends FASTElement {
155
161
  * HTML Attribute: `icon-only`
156
162
  */
157
163
  iconOnly: boolean;
164
+ /**
165
+ * Handles changes to icon only custom states
166
+ * @param prev - the previous state
167
+ * @param next - the next state
168
+ */
169
+ iconOnlyChanged(prev: boolean, next: boolean): void;
158
170
  /**
159
171
  * A reference to all associated label elements.
160
172
  *
@@ -178,6 +190,12 @@ export declare class Button extends FASTElement {
178
190
  * HTML Attribute: `shape`
179
191
  */
180
192
  shape?: ButtonShape;
193
+ /**
194
+ * Handles changes to shape attribute custom states
195
+ * @param prev - the previous state
196
+ * @param next - the next state
197
+ */
198
+ shapeChanged(prev: ButtonShape | undefined, next: ButtonShape | undefined): void;
181
199
  /**
182
200
  * The size of the button.
183
201
  *
@@ -186,6 +204,12 @@ export declare class Button extends FASTElement {
186
204
  * HTML Attribute: `size`
187
205
  */
188
206
  size?: ButtonSize;
207
+ /**
208
+ * Handles changes to size attribute custom states
209
+ * @param prev - the previous state
210
+ * @param next - the next state
211
+ */
212
+ sizeChanged(prev: ButtonSize | undefined, next: ButtonSize | undefined): void;
189
213
  /**
190
214
  * The button type.
191
215
  * @see The {@link https://developer.mozilla.org/en-US/docs/Web/HTML/Element/button#type | `type`} attribute
@@ -9,7 +9,6 @@ export declare const ButtonAppearance: {
9
9
  readonly primary: "primary";
10
10
  readonly outline: "outline";
11
11
  readonly subtle: "subtle";
12
- readonly secondary: "secondary";
13
12
  readonly transparent: "transparent";
14
13
  };
15
14
  /**
@@ -8,11 +8,6 @@ export declare const CompoundButtonAppearance: {
8
8
  readonly primary: "primary";
9
9
  readonly outline: "outline";
10
10
  readonly subtle: "subtle";
11
- readonly secondary: "secondary";
12
- /**
13
- * A Compound Button can be secondary, primary, outline, subtle, transparent
14
- * @public
15
- */
16
11
  readonly transparent: "transparent";
17
12
  };
18
13
  /**
@@ -6,6 +6,12 @@ import { CounterBadgeAppearance, CounterBadgeColor, CounterBadgeShape, CounterBa
6
6
  * @public
7
7
  */
8
8
  export declare class CounterBadge extends FASTElement {
9
+ /**
10
+ * The internal {@link https://developer.mozilla.org/docs/Web/API/ElementInternals | `ElementInternals`} instance for the component.
11
+ *
12
+ * @internal
13
+ */
14
+ elementInternals: ElementInternals;
9
15
  /**
10
16
  * The appearance the badge should have.
11
17
  *
@@ -14,6 +20,12 @@ export declare class CounterBadge extends FASTElement {
14
20
  * HTML Attribute: appearance
15
21
  */
16
22
  appearance?: CounterBadgeAppearance;
23
+ /**
24
+ * Handles changes to appearance attribute custom states
25
+ * @param prev - the previous state
26
+ * @param next - the next state
27
+ */
28
+ appearanceChanged(prev: CounterBadgeAppearance | undefined, next: CounterBadgeAppearance | undefined): void;
17
29
  /**
18
30
  * The color the badge should have.
19
31
  *
@@ -22,6 +34,12 @@ export declare class CounterBadge extends FASTElement {
22
34
  * HTML Attribute: color
23
35
  */
24
36
  color?: CounterBadgeColor;
37
+ /**
38
+ * Handles changes to color attribute custom states
39
+ * @param prev - the previous state
40
+ * @param next - the next state
41
+ */
42
+ colorChanged(prev: CounterBadgeColor | undefined, next: CounterBadgeColor | undefined): void;
25
43
  /**
26
44
  * The shape the badge should have.
27
45
  *
@@ -30,6 +48,12 @@ export declare class CounterBadge extends FASTElement {
30
48
  * HTML Attribute: shape
31
49
  */
32
50
  shape?: CounterBadgeShape;
51
+ /**
52
+ * Handles changes to shape attribute custom states
53
+ * @param prev - the previous state
54
+ * @param next - the next state
55
+ */
56
+ shapeChanged(prev: CounterBadgeShape | undefined, next: CounterBadgeShape | undefined): void;
33
57
  /**
34
58
  * The size the badge should have.
35
59
  *
@@ -38,6 +62,12 @@ export declare class CounterBadge extends FASTElement {
38
62
  * HTML Attribute: size
39
63
  */
40
64
  size?: CounterBadgeSize;
65
+ /**
66
+ * Handles changes to size attribute custom states
67
+ * @param prev - the previous state
68
+ * @param next - the next state
69
+ */
70
+ sizeChanged(prev: CounterBadgeSize | undefined, next: CounterBadgeSize | undefined): void;
41
71
  /**
42
72
  * The count the badge should have.
43
73
  *
@@ -72,6 +102,12 @@ export declare class CounterBadge extends FASTElement {
72
102
  * HTML Attribute: dot
73
103
  */
74
104
  dot: boolean;
105
+ /**
106
+ * Handles changes to dot attribute custom states
107
+ * @param prev - the previous state
108
+ * @param next - the next state
109
+ */
110
+ dotChanged(prev: boolean | undefined, next: boolean | undefined): void;
75
111
  /**
76
112
  * @internal
77
113
  * Function to set the count
@@ -8,7 +8,6 @@ export declare const MenuButtonAppearance: {
8
8
  readonly primary: "primary";
9
9
  readonly outline: "outline";
10
10
  readonly subtle: "subtle";
11
- readonly secondary: "secondary";
12
11
  readonly transparent: "transparent";
13
12
  };
14
13
  /**
@@ -0,0 +1,110 @@
1
+ /**
2
+ * Selector for the `ghost` state.
3
+ * @public
4
+ */
5
+ export declare const ghostState: import("@microsoft/fast-element").CSSDirective;
6
+ /**
7
+ * Selector for the `primary` state.
8
+ * @public
9
+ */
10
+ export declare const primaryState: import("@microsoft/fast-element").CSSDirective;
11
+ /**
12
+ * Selector for the `outline` state.
13
+ * @public
14
+ */
15
+ export declare const outlineState: import("@microsoft/fast-element").CSSDirective;
16
+ /**
17
+ * Selector for the `subtle` state.
18
+ * @public
19
+ */
20
+ export declare const subtleState: import("@microsoft/fast-element").CSSDirective;
21
+ /**
22
+ * Selector for the `tint` state.
23
+ * @public
24
+ */
25
+ export declare const tintState: import("@microsoft/fast-element").CSSDirective;
26
+ /**
27
+ * Selector for the `transparent` state.
28
+ * @public
29
+ */
30
+ export declare const transparentState: import("@microsoft/fast-element").CSSDirective;
31
+ /**
32
+ * Selector for the `circular` state.
33
+ * @public
34
+ */
35
+ export declare const circularState: import("@microsoft/fast-element").CSSDirective;
36
+ /**
37
+ * Selector for the `rounded` state.
38
+ * @public
39
+ */
40
+ export declare const roundedState: import("@microsoft/fast-element").CSSDirective;
41
+ /**
42
+ * Selector for the `square` state.
43
+ * @public
44
+ */
45
+ export declare const squareState: import("@microsoft/fast-element").CSSDirective;
46
+ /**
47
+ * Selector for the `tiny` state.
48
+ * @public
49
+ */
50
+ export declare const tinyState: import("@microsoft/fast-element").CSSDirective;
51
+ /**
52
+ * Selector for the `extra-small` state.
53
+ * @public
54
+ */
55
+ export declare const extraSmallState: import("@microsoft/fast-element").CSSDirective;
56
+ /**
57
+ * Selector for the `small` state.
58
+ * @public
59
+ */
60
+ export declare const smallState: import("@microsoft/fast-element").CSSDirective;
61
+ /**
62
+ * Selector for the `large` state.
63
+ * @public
64
+ */
65
+ export declare const largeState: import("@microsoft/fast-element").CSSDirective;
66
+ /**
67
+ * Selector for the `extra-large` state.
68
+ * @public
69
+ */
70
+ export declare const extraLargeState: import("@microsoft/fast-element").CSSDirective;
71
+ /**
72
+ * Selector for the `iconOnly` state.
73
+ * @public
74
+ */
75
+ export declare const iconOnlyState: import("@microsoft/fast-element").CSSDirective;
76
+ /**
77
+ * Selector for the `pressed` state.
78
+ * @public
79
+ */
80
+ export declare const pressedState: import("@microsoft/fast-element").CSSDirective;
81
+ /**
82
+ * Selector for the `danger` state.
83
+ * @public
84
+ */
85
+ export declare const dangerState: import("@microsoft/fast-element").CSSDirective;
86
+ /**
87
+ * Selector for the `important` state.
88
+ * @public
89
+ */
90
+ export declare const importantState: import("@microsoft/fast-element").CSSDirective;
91
+ /**
92
+ * Selector for the `informative` state.
93
+ * @public
94
+ */
95
+ export declare const informativeState: import("@microsoft/fast-element").CSSDirective;
96
+ /**
97
+ * Selector for the `severe` state.
98
+ * @public
99
+ */
100
+ export declare const severeState: import("@microsoft/fast-element").CSSDirective;
101
+ /**
102
+ * Selector for the `success` state.
103
+ * @public
104
+ */
105
+ export declare const successState: import("@microsoft/fast-element").CSSDirective;
106
+ /**
107
+ * Selector for the `warning` state.
108
+ * @public
109
+ */
110
+ export declare const warningState: import("@microsoft/fast-element").CSSDirective;
@@ -8,7 +8,6 @@ export declare const ToggleButtonAppearance: {
8
8
  readonly primary: "primary";
9
9
  readonly outline: "outline";
10
10
  readonly subtle: "subtle";
11
- readonly secondary: "secondary";
12
11
  readonly transparent: "transparent";
13
12
  };
14
13
  /**
@@ -3,6 +3,7 @@ import { attr, FASTElement, Observable } from '@microsoft/fast-element';
3
3
  import { keyEnter } from '@microsoft/fast-web-utilities';
4
4
  import { StartEnd } from '../patterns/index.js';
5
5
  import { applyMixins } from '../utils/apply-mixins.js';
6
+ import { toggleState } from '../utils/element-internals.js';
6
7
  import { AnchorAttributes, } from './anchor-button.options.js';
7
8
  /**
8
9
  * An Anchor Custom HTML Element.
@@ -19,6 +20,11 @@ import { AnchorAttributes, } from './anchor-button.options.js';
19
20
  export class BaseAnchor extends FASTElement {
20
21
  constructor() {
21
22
  super();
23
+ /**
24
+ * Holds a reference to the platform to manage ctrl+click on Windows and cmd+click on Mac
25
+ * @internal
26
+ */
27
+ this.isMac = navigator.userAgent.includes('Mac');
22
28
  /**
23
29
  * The internal {@link https://developer.mozilla.org/docs/Web/API/ElementInternals | `ElementInternals`} instance for the component.
24
30
  *
@@ -65,24 +71,38 @@ export class BaseAnchor extends FASTElement {
65
71
  * @param e - The event object
66
72
  * @internal
67
73
  */
68
- clickHandler() {
69
- this.internalProxyAnchor.click();
74
+ clickHandler(e) {
75
+ if (this.href) {
76
+ const newTab = !this.isMac ? e.ctrlKey : e.metaKey;
77
+ this.handleNavigation(newTab);
78
+ }
70
79
  return true;
71
80
  }
72
81
  /**
73
- * Handles keypress events for the anchor.
82
+ * Handles keydown events for the anchor.
74
83
  *
75
84
  * @param e - the keyboard event
76
85
  * @returns - the return value of the click handler
77
86
  * @public
78
87
  */
79
- keypressHandler(e) {
80
- if (e.key === keyEnter) {
81
- this.internalProxyAnchor.click();
82
- return;
88
+ keydownHandler(e) {
89
+ if (this.href) {
90
+ if (e.key === keyEnter) {
91
+ const newTab = !this.isMac ? e.ctrlKey : e.metaKey || e.ctrlKey;
92
+ this.handleNavigation(newTab);
93
+ return;
94
+ }
83
95
  }
84
96
  return true;
85
97
  }
98
+ /**
99
+ * Handles navigation based on input
100
+ * If the metaKey is pressed, opens the href in a new window, if false, uses the click on the proxy
101
+ * @internal
102
+ */
103
+ handleNavigation(newTab) {
104
+ newTab ? window.open(this.href, '_blank') : this.internalProxyAnchor.click();
105
+ }
86
106
  /**
87
107
  * A method for updating proxy attributes when attributes have changed
88
108
  * @internal
@@ -100,7 +120,8 @@ export class BaseAnchor extends FASTElement {
100
120
  createProxyElement() {
101
121
  var _a;
102
122
  const proxy = (_a = this.internalProxyAnchor) !== null && _a !== void 0 ? _a : document.createElement('a');
103
- proxy.hidden = true;
123
+ proxy.ariaHidden = 'true';
124
+ proxy.tabIndex = -1;
104
125
  return proxy;
105
126
  }
106
127
  }
@@ -140,6 +161,53 @@ export class AnchorButton extends BaseAnchor {
140
161
  */
141
162
  this.iconOnly = false;
142
163
  }
164
+ /**
165
+ * Handles changes to appearance attribute custom states
166
+ * @param prev - the previous state
167
+ * @param next - the next state
168
+ */
169
+ appearanceChanged(prev, next) {
170
+ if (prev) {
171
+ toggleState(this.elementInternals, `${prev}`, false);
172
+ }
173
+ if (next) {
174
+ toggleState(this.elementInternals, `${next}`, true);
175
+ }
176
+ }
177
+ /**
178
+ * Handles changes to shape attribute custom states
179
+ * @param prev - the previous state
180
+ * @param next - the next state
181
+ */
182
+ shapeChanged(prev, next) {
183
+ if (prev) {
184
+ toggleState(this.elementInternals, `${prev}`, false);
185
+ }
186
+ if (next) {
187
+ toggleState(this.elementInternals, `${next}`, true);
188
+ }
189
+ }
190
+ /**
191
+ * Handles changes to size attribute custom states
192
+ * @param prev - the previous state
193
+ * @param next - the next state
194
+ */
195
+ sizeChanged(prev, next) {
196
+ if (prev) {
197
+ toggleState(this.elementInternals, `${prev}`, false);
198
+ }
199
+ if (next) {
200
+ toggleState(this.elementInternals, `${next}`, true);
201
+ }
202
+ }
203
+ /**
204
+ * Handles changes to icon only custom states
205
+ * @param prev - the previous state
206
+ * @param next - the next state
207
+ */
208
+ iconOnlyChanged(prev, next) {
209
+ toggleState(this.elementInternals, 'icon', !!next);
210
+ }
143
211
  }
144
212
  __decorate([
145
213
  attr
@@ -1 +1 @@
1
- {"version":3,"file":"anchor-button.js","sourceRoot":"","sources":["../../../src/anchor-button/anchor-button.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,IAAI,EAAE,WAAW,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;AACxE,OAAO,EAAE,QAAQ,EAAE,MAAM,+BAA+B,CAAC;AACzD,OAAO,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AAEhD,OAAO,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAC;AACvD,OAAO,EACL,gBAAgB,GAKjB,MAAM,4BAA4B,CAAC;AAQpC;;;;;;;;;;;GAWG;AACH,MAAM,OAAO,UAAW,SAAQ,WAAW;IAuGzC;QACE,KAAK,EAAE,CAAC;QAvGV;;;;WAIG;QACO,qBAAgB,GAAqB,IAAI,CAAC,eAAe,EAAE,CAAC;QAEtE;;;WAGG;QACK,wBAAmB,GAAsB,IAAI,CAAC,kBAAkB,EAAE,CAAC;QA8FzE,IAAI,CAAC,gBAAgB,CAAC,IAAI,GAAG,MAAM,CAAC;IACtC,CAAC;IAEM,iBAAiB;QACtB,KAAK,CAAC,iBAAiB,EAAE,CAAC;QAC1B,UAAU,CAAC,WAAW,CAAC,IAAI,CAAC,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC;QAE7C,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,eAAe,CAAC,UAAU,CAAC,eAAe,CAAC,CAAC,OAAO,CAAC,GAAG,CAAC,EAAE;YACzE,IAAI,CAAC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AC;IAYD;;;;OAIG;IACI,eAAe,CAAC,IAAa,EAAE,IAAa;QACjD,WAAW,CAAC,IAAI,CAAC,gBAAgB,EAAE,MAAM,EAAE,CAAC,CAAC,IAAI,CAAC,CAAC;IACrD,CAAC;CACF;AAlFC;IADC,IAAI;gDACkD;AAwBvD;IADC,IAAI;2CACwC;AAwB7C;IADC,IAAI;0CAC0B;AAwB/B;IADC,IAAI,CAAC,EAAE,SAAS,EAAE,WAAW,EAAE,IAAI,EAAE,SAAS,EAAE,CAAC;8CACjB;AAoBnC,WAAW,CAAC,YAAY,EAAE,QAAQ,CAAC,CAAC"}
@@ -2,7 +2,14 @@ import { css } from '@microsoft/fast-element';
2
2
  import { baseButtonStyles } from '../button/button.styles.js';
3
3
  import { forcedColorsStylesheetBehavior } from '../utils/index.js';
4
4
  // Need to support icon hover styles
5
- export const styles = baseButtonStyles.withBehaviors(forcedColorsStylesheetBehavior(css `
5
+ export const styles = css `
6
+ ${baseButtonStyles}
7
+
8
+ ::slotted(a) {
9
+ position: absolute;
10
+ inset: 0;
11
+ }
12
+ `.withBehaviors(forcedColorsStylesheetBehavior(css `
6
13
  :host {
7
14
  border-color: LinkText;
8
15
  color: LinkText;
@@ -1 +1 @@
1
- {"version":3,"file":"anchor-button.styles.js","sourceRoot":"","sources":["../../../src/anchor-button/anchor-button.styles.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,yBAAyB,CAAC;AAC9C,OAAO,EAAE,gBAAgB,EAAE,MAAM,4BAA4B,CAAC;AAC9D,OAAO,EAAE,8BAA8B,EAAE,MAAM,mBAAmB,CAAC;AAEnE,oCAAoC;AACpC,MAAM,CAAC,MAAM,MAAM,GAAG,gBAAgB,CAAC,aAAa,CAClD,8BAA8B,CAAC,GAAG,CAAA;;;;;GAKjC,CAAC,CACH,CAAC"}
1
+ {"version":3,"file":"anchor-button.styles.js","sourceRoot":"","sources":["../../../src/anchor-button/anchor-button.styles.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,yBAAyB,CAAC;AAC9C,OAAO,EAAE,gBAAgB,EAAE,MAAM,4BAA4B,CAAC;AAC9D,OAAO,EAAE,8BAA8B,EAAE,MAAM,mBAAmB,CAAC;AAEnE,oCAAoC;AACpC,MAAM,CAAC,MAAM,MAAM,GAAG,GAAG,CAAA;IACrB,gBAAgB;;;;;;CAMnB,CAAC,aAAa,CACb,8BAA8B,CAAC,GAAG,CAAA;;;;;GAKjC,CAAC,CACH,CAAC"}
@@ -8,8 +8,8 @@ export function anchorTemplate(options = {}) {
8
8
  return html `
9
9
  <template
10
10
  tabindex="0"
11
- @click="${x => x.clickHandler()}"
12
- @keypress="${(x, c) => x.keypressHandler(c.event)}"
11
+ @click="${(x, c) => x.clickHandler(c.event)}"
12
+ @keydown="${(x, c) => x.keydownHandler(c.event)}"
13
13
  >
14
14
  ${startSlotTemplate(options)}
15
15
  <span class="content" part="content">
@@ -1 +1 @@
1
- {"version":3,"file":"anchor-button.template.js","sourceRoot":"","sources":["../../../src/anchor-button/anchor-button.template.ts"],"names":[],"mappings":"AAAA,OAAO,EAAuB,IAAI,EAAgB,MAAM,yBAAyB,CAAC;AAClF,OAAO,EAAE,eAAe,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AAG1E;;;GAGG;AACH,MAAM,UAAU,cAAc,CAAyB,UAAyB,EAAE;IAChF,OAAO,IAAI,CAAG;;;gBAGA,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,YAAY,EAAE;mBAClB,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,eAAe,CAAC,CAAC,CAAC,KAAsB,CAAC;;QAEhE,iBAAiB,CAAC,OAAO,CAAC;;;;QAI1B,eAAe,CAAC,OAAO,CAAC;;GAE7B,CAAC;AACJ,CAAC;AAED;;;GAGG;AACH,MAAM,CAAC,MAAM,QAAQ,GAAsC,cAAc,EAAE,CAAC"}
1
+ {"version":3,"file":"anchor-button.template.js","sourceRoot":"","sources":["../../../src/anchor-button/anchor-button.template.ts"],"names":[],"mappings":"AAAA,OAAO,EAAuB,IAAI,EAAgB,MAAM,yBAAyB,CAAC;AAClF,OAAO,EAAE,eAAe,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AAG1E;;;GAGG;AACH,MAAM,UAAU,cAAc,CAAyB,UAAyB,EAAE;IAChF,OAAO,IAAI,CAAG;;;gBAGA,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,YAAY,CAAC,CAAC,CAAC,KAAqB,CAAC;kBAC/C,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,cAAc,CAAC,CAAC,CAAC,KAAsB,CAAC;;QAE9D,iBAAiB,CAAC,OAAO,CAAC;;;;QAI1B,eAAe,CAAC,OAAO,CAAC;;GAE7B,CAAC;AACJ,CAAC;AAED;;;GAGG;AACH,MAAM,CAAC,MAAM,QAAQ,GAAsC,cAAc,EAAE,CAAC"}