@ni/nimble-components 8.3.0 → 8.6.0

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 (46) hide show
  1. package/dist/all-components-bundle.js +102 -48
  2. package/dist/all-components-bundle.js.map +1 -1
  3. package/dist/all-components-bundle.min.js +835 -796
  4. package/dist/all-components-bundle.min.js.map +1 -1
  5. package/dist/esm/all-components.d.ts +1 -0
  6. package/dist/esm/all-components.js +1 -0
  7. package/dist/esm/all-components.js.map +1 -1
  8. package/dist/esm/anchored-region/index.d.ts +11 -0
  9. package/dist/esm/anchored-region/index.js +24 -0
  10. package/dist/esm/anchored-region/index.js.map +1 -0
  11. package/dist/esm/anchored-region/styles.d.ts +1 -0
  12. package/dist/esm/anchored-region/styles.js +9 -0
  13. package/dist/esm/anchored-region/styles.js.map +1 -0
  14. package/dist/esm/button/index.d.ts +2 -7
  15. package/dist/esm/button/index.js +0 -6
  16. package/dist/esm/button/index.js.map +1 -1
  17. package/dist/esm/menu-button/index.d.ts +50 -0
  18. package/dist/esm/menu-button/index.js +154 -0
  19. package/dist/esm/menu-button/index.js.map +1 -0
  20. package/dist/esm/menu-button/styles.d.ts +1 -0
  21. package/dist/esm/menu-button/styles.js +29 -0
  22. package/dist/esm/menu-button/styles.js.map +1 -0
  23. package/dist/esm/menu-button/template.d.ts +2 -0
  24. package/dist/esm/menu-button/template.js +48 -0
  25. package/dist/esm/menu-button/template.js.map +1 -0
  26. package/dist/esm/menu-button/types.d.ts +15 -0
  27. package/dist/esm/menu-button/types.js +11 -0
  28. package/dist/esm/menu-button/types.js.map +1 -0
  29. package/dist/esm/nimble-components/src/all-components.d.ts +1 -0
  30. package/dist/esm/nimble-components/src/anchored-region/index.d.ts +11 -0
  31. package/dist/esm/nimble-components/src/anchored-region/styles.d.ts +1 -0
  32. package/dist/esm/nimble-components/src/button/index.d.ts +2 -7
  33. package/dist/esm/nimble-components/src/menu-button/index.d.ts +50 -0
  34. package/dist/esm/nimble-components/src/menu-button/styles.d.ts +1 -0
  35. package/dist/esm/nimble-components/src/menu-button/template.d.ts +2 -0
  36. package/dist/esm/nimble-components/src/menu-button/types.d.ts +15 -0
  37. package/dist/esm/nimble-components/src/patterns/button/types.d.ts +20 -0
  38. package/dist/esm/nimble-components/src/toggle-button/index.d.ts +3 -8
  39. package/dist/esm/patterns/button/types.d.ts +20 -0
  40. package/dist/esm/patterns/button/types.js.map +1 -1
  41. package/dist/esm/text-field/styles.js +31 -7
  42. package/dist/esm/text-field/styles.js.map +1 -1
  43. package/dist/esm/toggle-button/index.d.ts +3 -8
  44. package/dist/esm/toggle-button/index.js +1 -7
  45. package/dist/esm/toggle-button/index.js.map +1 -1
  46. package/package.json +1 -1
@@ -3,6 +3,7 @@
3
3
  * Production applications are encouraged to import only components
4
4
  * that are required instead of leveraging this file.
5
5
  */
6
+ import './anchored-region';
6
7
  import './breadcrumb';
7
8
  import './breadcrumb-item';
8
9
  import './button';
@@ -3,6 +3,7 @@
3
3
  * Production applications are encouraged to import only components
4
4
  * that are required instead of leveraging this file.
5
5
  */
6
+ import './anchored-region';
6
7
  import './breadcrumb';
7
8
  import './breadcrumb-item';
8
9
  import './button';
@@ -1 +1 @@
1
- {"version":3,"file":"all-components.js","sourceRoot":"","sources":["../../src/all-components.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,cAAc,CAAC;AACtB,OAAO,mBAAmB,CAAC;AAC3B,OAAO,UAAU,CAAC;AAClB,OAAO,YAAY,CAAC;AACpB,OAAO,UAAU,CAAC;AAClB,OAAO,mBAAmB,CAAC;AAC3B,OAAO,eAAe,CAAC;AACvB,OAAO,QAAQ,CAAC;AAChB,OAAO,aAAa,CAAC;AACrB,OAAO,gBAAgB,CAAC;AACxB,OAAO,UAAU,CAAC;AAClB,OAAO,UAAU,CAAC;AAClB,OAAO,OAAO,CAAC;AACf,OAAO,aAAa,CAAC;AACrB,OAAO,QAAQ,CAAC;AAChB,OAAO,gBAAgB,CAAC;AACxB,OAAO,aAAa,CAAC;AACrB,OAAO,cAAc,CAAC;AACtB,OAAO,kBAAkB,CAAC;AAC1B,OAAO,iBAAiB,CAAC;AACzB,OAAO,WAAW,CAAC;AACnB,OAAO,aAAa,CAAC;AACrB,OAAO,aAAa,CAAC"}
1
+ {"version":3,"file":"all-components.js","sourceRoot":"","sources":["../../src/all-components.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,mBAAmB,CAAC;AAC3B,OAAO,cAAc,CAAC;AACtB,OAAO,mBAAmB,CAAC;AAC3B,OAAO,UAAU,CAAC;AAClB,OAAO,YAAY,CAAC;AACpB,OAAO,UAAU,CAAC;AAClB,OAAO,mBAAmB,CAAC;AAC3B,OAAO,eAAe,CAAC;AACvB,OAAO,QAAQ,CAAC;AAChB,OAAO,aAAa,CAAC;AACrB,OAAO,gBAAgB,CAAC;AACxB,OAAO,UAAU,CAAC;AAClB,OAAO,UAAU,CAAC;AAClB,OAAO,OAAO,CAAC;AACf,OAAO,aAAa,CAAC;AACrB,OAAO,QAAQ,CAAC;AAChB,OAAO,gBAAgB,CAAC;AACxB,OAAO,aAAa,CAAC;AACrB,OAAO,cAAc,CAAC;AACtB,OAAO,kBAAkB,CAAC;AAC1B,OAAO,iBAAiB,CAAC;AACzB,OAAO,WAAW,CAAC;AACnB,OAAO,aAAa,CAAC;AACrB,OAAO,aAAa,CAAC"}
@@ -0,0 +1,11 @@
1
+ import { AnchoredRegion as FoundationAnchoredRegion } from '@microsoft/fast-foundation';
2
+ declare global {
3
+ interface HTMLElementTagNameMap {
4
+ 'nimble-anchored-region': AnchoredRegion;
5
+ }
6
+ }
7
+ /**
8
+ * A nimble-styled anchored region control.
9
+ */
10
+ export declare class AnchoredRegion extends FoundationAnchoredRegion {
11
+ }
@@ -0,0 +1,24 @@
1
+ import { DesignSystem, AnchoredRegion as FoundationAnchoredRegion, anchoredRegionTemplate as template } from '@microsoft/fast-foundation';
2
+ import { styles } from './styles';
3
+ // When the anchor element changes position on the page, it is the client's responsibility to update the position
4
+ // of the anchored region by calling update() on the anchored region.
5
+ //
6
+ // When the anchor element is recreated on the page, it is the client's responsibility to reset the reference the
7
+ // anchored region has to the anchor element. This can be done by either recreating the anchor element with a new
8
+ // ID that is also set as the \`anchor\` attribute on the anchored region or by explicitly setting the value of
9
+ // anchorElement on the anchored region to the new anchor element.
10
+ /**
11
+ * A nimble-styled anchored region control.
12
+ */
13
+ export class AnchoredRegion extends FoundationAnchoredRegion {
14
+ }
15
+ const nimbleAnchoredRegion = AnchoredRegion.compose({
16
+ baseName: 'anchored-region',
17
+ baseClass: FoundationAnchoredRegion,
18
+ template,
19
+ styles
20
+ });
21
+ DesignSystem.getOrCreate()
22
+ .withPrefix('nimble')
23
+ .register(nimbleAnchoredRegion());
24
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/anchored-region/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACH,YAAY,EACZ,cAAc,IAAI,wBAAwB,EAC1C,sBAAsB,IAAI,QAAQ,EACrC,MAAM,4BAA4B,CAAC;AACpC,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAQlC,iHAAiH;AACjH,qEAAqE;AACrE,EAAE;AACF,iHAAiH;AACjH,iHAAiH;AACjH,+GAA+G;AAC/G,kEAAkE;AAElE;;GAEG;AACH,MAAM,OAAO,cAAe,SAAQ,wBAAwB;CAAG;AAE/D,MAAM,oBAAoB,GAAG,cAAc,CAAC,OAAO,CAAC;IAChD,QAAQ,EAAE,iBAAiB;IAC3B,SAAS,EAAE,wBAAwB;IACnC,QAAQ;IACR,MAAM;CACT,CAAC,CAAC;AAEH,YAAY,CAAC,WAAW,EAAE;KACrB,UAAU,CAAC,QAAQ,CAAC;KACpB,QAAQ,CAAC,oBAAoB,EAAE,CAAC,CAAC"}
@@ -0,0 +1 @@
1
+ export declare const styles: import("@microsoft/fast-element").ElementStyles;
@@ -0,0 +1,9 @@
1
+ import { css } from '@microsoft/fast-element';
2
+ export const styles = css `
3
+ :host {
4
+ contain: layout;
5
+ display: block;
6
+ z-index: 1000;
7
+ }
8
+ `;
9
+ //# sourceMappingURL=styles.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"styles.js","sourceRoot":"","sources":["../../../src/anchored-region/styles.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,yBAAyB,CAAC;AAE9C,MAAM,CAAC,MAAM,MAAM,GAAG,GAAG,CAAA;;;;;;CAMxB,CAAC"}
@@ -1,4 +1,5 @@
1
1
  import { Button as FoundationButton } from '@microsoft/fast-foundation';
2
+ import type { IButton } from '../patterns/button/types';
2
3
  import { ButtonAppearance } from './types';
3
4
  declare global {
4
5
  interface HTMLElementTagNameMap {
@@ -8,20 +9,14 @@ declare global {
8
9
  /**
9
10
  * A nimble-styled HTML button
10
11
  */
11
- export declare class Button extends FoundationButton {
12
+ export declare class Button extends FoundationButton implements IButton {
12
13
  /**
13
- * The appearance the button should have.
14
- *
15
14
  * @public
16
15
  * @remarks
17
16
  * HTML Attribute: appearance
18
17
  */
19
18
  appearance: ButtonAppearance;
20
19
  /**
21
- * Specify as 'true' to hide the text content of the button. The button will
22
- * become square, and the text content will be used as the label of the button
23
- * for accessibility purposes.
24
- *
25
20
  * @public
26
21
  * @remarks
27
22
  * HTML Attribute: content-hidden
@@ -10,18 +10,12 @@ export class Button extends FoundationButton {
10
10
  constructor() {
11
11
  super(...arguments);
12
12
  /**
13
- * The appearance the button should have.
14
- *
15
13
  * @public
16
14
  * @remarks
17
15
  * HTML Attribute: appearance
18
16
  */
19
17
  this.appearance = ButtonAppearance.Outline;
20
18
  /**
21
- * Specify as 'true' to hide the text content of the button. The button will
22
- * become square, and the text content will be used as the label of the button
23
- * for accessibility purposes.
24
- *
25
19
  * @public
26
20
  * @remarks
27
21
  * HTML Attribute: content-hidden
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/button/index.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,yBAAyB,CAAC;AAC/C,OAAO,EACH,MAAM,IAAI,gBAAgB,EAE1B,cAAc,IAAI,QAAQ,EAC1B,YAAY,EACf,MAAM,4BAA4B,CAAC;AACpC,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAClC,OAAO,EAAE,gBAAgB,EAAE,MAAM,SAAS,CAAC;AAQ3C;;GAEG;AACH,MAAM,OAAO,MAAO,SAAQ,gBAAgB;IAA5C;;QACI;;;;;;WAMG;QAEI,eAAU,GAAqB,gBAAgB,CAAC,OAAO,CAAC;QAE/D;;;;;;;;WAQG;QAEI,kBAAa,GAAG,KAAK,CAAC;IACjC,CAAC;CAAA;AAbG;IADC,IAAI;0CAC0D;AAY/D;IADC,IAAI,CAAC,EAAE,SAAS,EAAE,gBAAgB,EAAE,IAAI,EAAE,SAAS,EAAE,CAAC;6CAC1B;AAGjC;;;;;;;;GAQG;AACH,MAAM,YAAY,GAAG,MAAM,CAAC,OAAO,CAAgB;IAC/C,QAAQ,EAAE,QAAQ;IAClB,SAAS,EAAE,gBAAgB;IAC3B,QAAQ;IACR,MAAM;IACN,aAAa,EAAE;QACX,cAAc,EAAE,IAAI;KACvB;CACJ,CAAC,CAAC;AAEH,YAAY,CAAC,WAAW,EAAE,CAAC,UAAU,CAAC,QAAQ,CAAC,CAAC,QAAQ,CAAC,YAAY,EAAE,CAAC,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/button/index.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,yBAAyB,CAAC;AAC/C,OAAO,EACH,MAAM,IAAI,gBAAgB,EAE1B,cAAc,IAAI,QAAQ,EAC1B,YAAY,EACf,MAAM,4BAA4B,CAAC;AAEpC,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAClC,OAAO,EAAE,gBAAgB,EAAE,MAAM,SAAS,CAAC;AAQ3C;;GAEG;AACH,MAAM,OAAO,MAAO,SAAQ,gBAAgB;IAA5C;;QACI;;;;WAIG;QAEI,eAAU,GAAqB,gBAAgB,CAAC,OAAO,CAAC;QAE/D;;;;WAIG;QAEI,kBAAa,GAAG,KAAK,CAAC;IACjC,CAAC;CAAA;AATG;IADC,IAAI;0CAC0D;AAQ/D;IADC,IAAI,CAAC,EAAE,SAAS,EAAE,gBAAgB,EAAE,IAAI,EAAE,SAAS,EAAE,CAAC;6CAC1B;AAGjC;;;;;;;;GAQG;AACH,MAAM,YAAY,GAAG,MAAM,CAAC,OAAO,CAAgB;IAC/C,QAAQ,EAAE,QAAQ;IAClB,SAAS,EAAE,gBAAgB;IAC3B,QAAQ;IACR,MAAM;IACN,aAAa,EAAE;QACX,cAAc,EAAE,IAAI;KACvB;CACJ,CAAC,CAAC;AAEH,YAAY,CAAC,WAAW,EAAE,CAAC,UAAU,CAAC,QAAQ,CAAC,CAAC,QAAQ,CAAC,YAAY,EAAE,CAAC,CAAC"}
@@ -0,0 +1,50 @@
1
+ import { FoundationElement } from '@microsoft/fast-foundation';
2
+ import { ButtonAppearance } from '../button/types';
3
+ import type { ToggleButton } from '../toggle-button';
4
+ import { MenuButtonPosition } from './types';
5
+ import type { IButton } from '../patterns/button/types';
6
+ import type { AnchoredRegion } from '../anchored-region';
7
+ declare global {
8
+ interface HTMLElementTagNameMap {
9
+ 'nimble-menu-button': MenuButton;
10
+ }
11
+ }
12
+ /**
13
+ * A nimble-styled menu button control.
14
+ */
15
+ export declare class MenuButton extends FoundationElement implements IButton {
16
+ appearance: ButtonAppearance;
17
+ disabled: boolean;
18
+ contentHidden: boolean;
19
+ /**
20
+ * Specifies whether or not the menu is open.
21
+ */
22
+ open: boolean;
23
+ /**
24
+ * Configures where the menu should be placed relative to the button that opens the menu.
25
+ */
26
+ position: MenuButtonPosition;
27
+ /** @internal */
28
+ readonly toggleButton: ToggleButton | undefined;
29
+ /** @internal */
30
+ readonly region: AnchoredRegion | undefined;
31
+ /** @internal */
32
+ readonly slottedMenus: HTMLElement[] | undefined;
33
+ /**
34
+ * Used to maintain the internal state of whether the last menu item should be focused instead
35
+ * of the first menu item the next time the menu is opened.
36
+ */
37
+ private focusLastItemWhenOpened;
38
+ toggleButtonChanged(_prev: ToggleButton | undefined, _next: ToggleButton | undefined): void;
39
+ regionChanged(_prev: AnchoredRegion | undefined, _next: AnchoredRegion | undefined): void;
40
+ openChanged(_prev: boolean | undefined, _next: boolean): void;
41
+ regionLoadedHandler(): void;
42
+ focusoutHandler(e: FocusEvent): boolean;
43
+ toggleButtonCheckedChangeHandler(e: Event): boolean;
44
+ toggleButtonKeyDownHandler(e: KeyboardEvent): boolean;
45
+ menuChangeHandler(): void;
46
+ menuKeyDownHandler(e: KeyboardEvent): boolean;
47
+ private get menu();
48
+ private focusMenu;
49
+ private focusLastMenuItem;
50
+ }
@@ -0,0 +1,154 @@
1
+ import { __decorate } from "tslib";
2
+ import { attr, observable } from '@microsoft/fast-element';
3
+ import { DesignSystem, FoundationElement } from '@microsoft/fast-foundation';
4
+ import { keyArrowDown, keyArrowUp, keyEscape } from '@microsoft/fast-web-utilities';
5
+ import { ButtonAppearance } from '../button/types';
6
+ import { styles } from './styles';
7
+ import { template } from './template';
8
+ import { MenuButtonPosition } from './types';
9
+ /**
10
+ * A nimble-styled menu button control.
11
+ */
12
+ export class MenuButton extends FoundationElement {
13
+ constructor() {
14
+ super(...arguments);
15
+ this.appearance = ButtonAppearance.Outline;
16
+ this.disabled = false;
17
+ this.contentHidden = false;
18
+ /**
19
+ * Specifies whether or not the menu is open.
20
+ */
21
+ this.open = false;
22
+ /**
23
+ * Configures where the menu should be placed relative to the button that opens the menu.
24
+ */
25
+ this.position = MenuButtonPosition.auto;
26
+ /**
27
+ * Used to maintain the internal state of whether the last menu item should be focused instead
28
+ * of the first menu item the next time the menu is opened.
29
+ */
30
+ this.focusLastItemWhenOpened = false;
31
+ }
32
+ toggleButtonChanged(_prev, _next) {
33
+ if (this.region && this.toggleButton) {
34
+ this.region.anchorElement = this.toggleButton;
35
+ }
36
+ }
37
+ regionChanged(_prev, _next) {
38
+ if (this.region && this.toggleButton) {
39
+ this.region.anchorElement = this.toggleButton;
40
+ }
41
+ }
42
+ openChanged(_prev, _next) {
43
+ if (this.toggleButton) {
44
+ this.toggleButton.checked = this.open;
45
+ }
46
+ if (!this.open) {
47
+ // Only fire an event here if the menu is changing to being closed. Otherwise,
48
+ // wait until the menu is actually opened before firing the event.
49
+ this.$emit('open-change');
50
+ }
51
+ }
52
+ regionLoadedHandler() {
53
+ if (this.focusLastItemWhenOpened) {
54
+ this.focusLastMenuItem();
55
+ this.focusLastItemWhenOpened = false;
56
+ }
57
+ else {
58
+ this.focusMenu();
59
+ }
60
+ this.$emit('open-change');
61
+ }
62
+ focusoutHandler(e) {
63
+ if (!this.open) {
64
+ return true;
65
+ }
66
+ const focusTarget = e.relatedTarget;
67
+ if (!this.contains(focusTarget)) {
68
+ this.open = false;
69
+ return false;
70
+ }
71
+ return true;
72
+ }
73
+ toggleButtonCheckedChangeHandler(e) {
74
+ this.open = this.toggleButton.checked;
75
+ // Don't bubble the 'change' event from the toggle button because
76
+ // the menu button has its own 'open-change' event.
77
+ e.stopPropagation();
78
+ return false;
79
+ }
80
+ toggleButtonKeyDownHandler(e) {
81
+ switch (e.key) {
82
+ case keyArrowUp:
83
+ this.focusLastItemWhenOpened = true;
84
+ this.open = true;
85
+ return false;
86
+ case keyArrowDown:
87
+ this.open = true;
88
+ return false;
89
+ default:
90
+ return true;
91
+ }
92
+ }
93
+ menuChangeHandler() {
94
+ this.open = false;
95
+ this.toggleButton.focus();
96
+ }
97
+ menuKeyDownHandler(e) {
98
+ switch (e.key) {
99
+ case keyEscape:
100
+ this.open = false;
101
+ this.toggleButton.focus();
102
+ return false;
103
+ default:
104
+ return true;
105
+ }
106
+ }
107
+ get menu() {
108
+ return this.slottedMenus?.length ? this.slottedMenus[0] : undefined;
109
+ }
110
+ focusMenu() {
111
+ this.menu?.focus();
112
+ }
113
+ focusLastMenuItem() {
114
+ const menuItems = this.menu?.querySelectorAll('[role=menuitem]');
115
+ if (menuItems?.length) {
116
+ const lastMenuItem = menuItems[menuItems.length - 1];
117
+ lastMenuItem.focus();
118
+ }
119
+ }
120
+ }
121
+ __decorate([
122
+ attr
123
+ ], MenuButton.prototype, "appearance", void 0);
124
+ __decorate([
125
+ attr({ mode: 'boolean' })
126
+ ], MenuButton.prototype, "disabled", void 0);
127
+ __decorate([
128
+ attr({ attribute: 'content-hidden', mode: 'boolean' })
129
+ ], MenuButton.prototype, "contentHidden", void 0);
130
+ __decorate([
131
+ attr({ mode: 'boolean' })
132
+ ], MenuButton.prototype, "open", void 0);
133
+ __decorate([
134
+ attr({ attribute: 'position' })
135
+ ], MenuButton.prototype, "position", void 0);
136
+ __decorate([
137
+ observable
138
+ ], MenuButton.prototype, "toggleButton", void 0);
139
+ __decorate([
140
+ observable
141
+ ], MenuButton.prototype, "region", void 0);
142
+ __decorate([
143
+ observable
144
+ ], MenuButton.prototype, "slottedMenus", void 0);
145
+ const nimbleMenuButton = MenuButton.compose({
146
+ baseName: 'menu-button',
147
+ template,
148
+ styles,
149
+ shadowOptions: {
150
+ delegatesFocus: true
151
+ }
152
+ });
153
+ DesignSystem.getOrCreate().withPrefix('nimble').register(nimbleMenuButton());
154
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/menu-button/index.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,IAAI,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;AAC3D,OAAO,EAAE,YAAY,EAAE,iBAAiB,EAAE,MAAM,4BAA4B,CAAC;AAC7E,OAAO,EACH,YAAY,EACZ,UAAU,EACV,SAAS,EACZ,MAAM,+BAA+B,CAAC;AACvC,OAAO,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAC;AAEnD,OAAO,EAAE,MAAM,EAAE,MAAM,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AAC,gBAAgB,EAAE,CAAC,CAAC"}
@@ -0,0 +1 @@
1
+ export declare const styles: import("@microsoft/fast-element").ElementStyles;
@@ -0,0 +1,29 @@
1
+ import { css } from '@microsoft/fast-element';
2
+ import { display } from '@microsoft/fast-foundation';
3
+ import { controlHeight, smallPadding } from '../theme-provider/design-tokens';
4
+ export const styles = css `
5
+ ${display('inline-block')}
6
+
7
+ :host {
8
+ height: ${controlHeight};
9
+ }
10
+
11
+ [part='button'] {
12
+ width: 100%;
13
+ height: 100%;
14
+ }
15
+
16
+ [part='start'] {
17
+ display: contents;
18
+ }
19
+
20
+ [part='end'] {
21
+ display: contents;
22
+ }
23
+
24
+ slot[name='menu']::slotted(*) {
25
+ margin-top: ${smallPadding};
26
+ margin-bottom: ${smallPadding};
27
+ }
28
+ `;
29
+ //# sourceMappingURL=styles.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"styles.js","sourceRoot":"","sources":["../../../src/menu-button/styles.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,yBAAyB,CAAC;AAC9C,OAAO,EAAE,OAAO,EAAE,MAAM,4BAA4B,CAAC;AACrD,OAAO,EAAE,aAAa,EAAE,YAAY,EAAE,MAAM,iCAAiC,CAAC;AAE9E,MAAM,CAAC,MAAM,MAAM,GAAG,GAAG,CAAA;MACnB,OAAO,CAAC,cAAc,CAAC;;;kBAGX,aAAa;;;;;;;;;;;;;;;;;sBAiBT,YAAY;yBACT,YAAY;;CAEpC,CAAC"}
@@ -0,0 +1,2 @@
1
+ import type { MenuButton } from '.';
2
+ export declare const template: import("@microsoft/fast-element").ViewTemplate<MenuButton, any>;
@@ -0,0 +1,48 @@
1
+ import { elements, html, ref, slotted, when } from '@microsoft/fast-element';
2
+ // prettier-ignore
3
+ export const template = html `
4
+ <template
5
+ ?open="${x => x.open}"
6
+ @focusout="${(x, c) => x.focusoutHandler(c.event)}"
7
+ >
8
+ <nimble-toggle-button
9
+ part="button"
10
+ appearance="${x => x.appearance}"
11
+ content-hidden="${x => x.contentHidden}"
12
+ ?checked="${x => x.open}"
13
+ ?disabled="${x => x.disabled}"
14
+ aria-haspopup="true"
15
+ aria-expanded="${x => x.open}"
16
+ @change="${(x, c) => x.toggleButtonCheckedChangeHandler(c.event)}"
17
+ @keydown="${(x, c) => x.toggleButtonKeyDownHandler(c.event)}"
18
+ ${ref('toggleButton')}
19
+ >
20
+ <span slot="start" part="start">
21
+ <slot name="start"></slot>
22
+ </span>
23
+ <slot></slot>
24
+ <span slot="end" part="end">
25
+ <slot name="end"></slot>
26
+ </span>
27
+ </nimble-toggle-button>
28
+ ${when(x => x.open, html `
29
+ <nimble-anchored-region
30
+ fixed-placement="true"
31
+ auto-update-mode="auto"
32
+ horizontal-inset="true"
33
+ horizontal-positioning-mode="dynamic"
34
+ vertical-positioning-mode="${x => (x.position === 'auto' ? 'dynamic' : 'locktodefault')}"
35
+ vertical-default-position="${x => (x.position === 'above' ? 'top' : 'bottom')}"
36
+ @loaded="${x => x.regionLoadedHandler()}"
37
+ @change="${x => x.menuChangeHandler()}"
38
+ @keydown="${(x, c) => x.menuKeyDownHandler(c.event)}"
39
+ ${ref('region')}
40
+ >
41
+ <span part="menu">
42
+ <slot name="menu" ${slotted({ property: 'slottedMenus', filter: elements('[role=menu]') })}></slot>
43
+ </span>
44
+ </nimble-anchored-region>
45
+ `)}
46
+ </template>
47
+ `;
48
+ //# sourceMappingURL=template.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"template.js","sourceRoot":"","sources":["../../../src/menu-button/template.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,IAAI,EAAE,GAAG,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,yBAAyB,CAAC;AAG7E,kBAAkB;AAClB,MAAM,CAAC,MAAM,QAAQ,GAAG,IAAI,CAAY;;iBAEvB,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI;qBACP,CAAC,CAAC,EAAE,CAAC,EAAE,E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E,CAAC;;;SAGrG,CACJ;;CAEJ,CAAC"}
@@ -0,0 +1,15 @@
1
+ /**
2
+ * Types of menu button appearance.
3
+ * @public
4
+ */
5
+ export type { ButtonAppearanceAttribute } from '../patterns/button/types';
6
+ export { ButtonAppearance } from '../patterns/button/types';
7
+ /**
8
+ * The options of where to position the menu relative to the menu button.
9
+ */
10
+ export declare const MenuButtonPosition: {
11
+ readonly above: "above";
12
+ readonly below: "below";
13
+ readonly auto: "auto";
14
+ };
15
+ export declare type MenuButtonPosition = typeof MenuButtonPosition[keyof typeof MenuButtonPosition];
@@ -0,0 +1,11 @@
1
+ export { ButtonAppearance } from '../patterns/button/types';
2
+ /**
3
+ * The options of where to position the menu relative to the menu button.
4
+ */
5
+ // eslint-disable-next-line @typescript-eslint/naming-convention
6
+ export const MenuButtonPosition = {
7
+ above: 'above',
8
+ below: 'below',
9
+ auto: 'auto'
10
+ };
11
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/menu-button/types.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,gBAAgB,EAAE,MAAM,0BAA0B,CAAC;AAE5D;;GAEG;AACH,gEAAgE;AAChE,MAAM,CAAC,MAAM,kBAAkB,GAAG;IAC9B,KAAK,EAAE,OAAO;IACd,KAAK,EAAE,OAAO;IACd,IAAI,EAAE,MAAM;CACN,CAAC"}
@@ -3,6 +3,7 @@
3
3
  * Production applications are encouraged to import only components
4
4
  * that are required instead of leveraging this file.
5
5
  */
6
+ import './anchored-region';
6
7
  import './breadcrumb';
7
8
  import './breadcrumb-item';
8
9
  import './button';
@@ -0,0 +1,11 @@
1
+ import { AnchoredRegion as FoundationAnchoredRegion } from '@microsoft/fast-foundation';
2
+ declare global {
3
+ interface HTMLElementTagNameMap {
4
+ 'nimble-anchored-region': AnchoredRegion;
5
+ }
6
+ }
7
+ /**
8
+ * A nimble-styled anchored region control.
9
+ */
10
+ export declare class AnchoredRegion extends FoundationAnchoredRegion {
11
+ }
@@ -0,0 +1 @@
1
+ export declare const styles: import("@microsoft/fast-element").ElementStyles;
@@ -1,4 +1,5 @@
1
1
  import { Button as FoundationButton } from '@microsoft/fast-foundation';
2
+ import type { IButton } from '../patterns/button/types';
2
3
  import { ButtonAppearance } from './types';
3
4
  declare global {
4
5
  interface HTMLElementTagNameMap {
@@ -8,20 +9,14 @@ declare global {
8
9
  /**
9
10
  * A nimble-styled HTML button
10
11
  */
11
- export declare class Button extends FoundationButton {
12
+ export declare class Button extends FoundationButton implements IButton {
12
13
  /**
13
- * The appearance the button should have.
14
- *
15
14
  * @public
16
15
  * @remarks
17
16
  * HTML Attribute: appearance
18
17
  */
19
18
  appearance: ButtonAppearance;
20
19
  /**
21
- * Specify as 'true' to hide the text content of the button. The button will
22
- * become square, and the text content will be used as the label of the button
23
- * for accessibility purposes.
24
- *
25
20
  * @public
26
21
  * @remarks
27
22
  * HTML Attribute: content-hidden
@@ -0,0 +1,50 @@
1
+ import { FoundationElement } from '@microsoft/fast-foundation';
2
+ import { ButtonAppearance } from '../button/types';
3
+ import type { ToggleButton } from '../toggle-button';
4
+ import { MenuButtonPosition } from './types';
5
+ import type { IButton } from '../patterns/button/types';
6
+ import type { AnchoredRegion } from '../anchored-region';
7
+ declare global {
8
+ interface HTMLElementTagNameMap {
9
+ 'nimble-menu-button': MenuButton;
10
+ }
11
+ }
12
+ /**
13
+ * A nimble-styled menu button control.
14
+ */
15
+ export declare class MenuButton extends FoundationElement implements IButton {
16
+ appearance: ButtonAppearance;
17
+ disabled: boolean;
18
+ contentHidden: boolean;
19
+ /**
20
+ * Specifies whether or not the menu is open.
21
+ */
22
+ open: boolean;
23
+ /**
24
+ * Configures where the menu should be placed relative to the button that opens the menu.
25
+ */
26
+ position: MenuButtonPosition;
27
+ /** @internal */
28
+ readonly toggleButton: ToggleButton | undefined;
29
+ /** @internal */
30
+ readonly region: AnchoredRegion | undefined;
31
+ /** @internal */
32
+ readonly slottedMenus: HTMLElement[] | undefined;
33
+ /**
34
+ * Used to maintain the internal state of whether the last menu item should be focused instead
35
+ * of the first menu item the next time the menu is opened.
36
+ */
37
+ private focusLastItemWhenOpened;
38
+ toggleButtonChanged(_prev: ToggleButton | undefined, _next: ToggleButton | undefined): void;
39
+ regionChanged(_prev: AnchoredRegion | undefined, _next: AnchoredRegion | undefined): void;
40
+ openChanged(_prev: boolean | undefined, _next: boolean): void;
41
+ regionLoadedHandler(): void;
42
+ focusoutHandler(e: FocusEvent): boolean;
43
+ toggleButtonCheckedChangeHandler(e: Event): boolean;
44
+ toggleButtonKeyDownHandler(e: KeyboardEvent): boolean;
45
+ menuChangeHandler(): void;
46
+ menuKeyDownHandler(e: KeyboardEvent): boolean;
47
+ private get menu();
48
+ private focusMenu;
49
+ private focusLastMenuItem;
50
+ }
@@ -0,0 +1 @@
1
+ export declare const styles: import("@microsoft/fast-element").ElementStyles;
@@ -0,0 +1,2 @@
1
+ import type { MenuButton } from '.';
2
+ export declare const template: import("@microsoft/fast-element").ViewTemplate<MenuButton, any>;
@@ -0,0 +1,15 @@
1
+ /**
2
+ * Types of menu button appearance.
3
+ * @public
4
+ */
5
+ export type { ButtonAppearanceAttribute } from '../patterns/button/types';
6
+ export { ButtonAppearance } from '../patterns/button/types';
7
+ /**
8
+ * The options of where to position the menu relative to the menu button.
9
+ */
10
+ export declare const MenuButtonPosition: {
11
+ readonly above: "above";
12
+ readonly below: "below";
13
+ readonly auto: "auto";
14
+ };
15
+ export declare type MenuButtonPosition = typeof MenuButtonPosition[keyof typeof MenuButtonPosition];
@@ -1,3 +1,23 @@
1
+ /**
2
+ * The interface that buttons of various types implement. The properties in this interface
3
+ * are leveraged by the shared button pattern css.
4
+ */
5
+ export interface IButton {
6
+ /**
7
+ * The appearance the button should have.
8
+ */
9
+ appearance: ButtonAppearance;
10
+ /**
11
+ * Specify as 'true' to hide the text content of the button. The button will
12
+ * become square, and the text content will be used as the label of the button
13
+ * for accessibility purposes.
14
+ */
15
+ contentHidden: boolean;
16
+ /**
17
+ * Whether or not the button is disabled.
18
+ */
19
+ disabled: boolean;
20
+ }
1
21
  /**
2
22
  * Types of button appearance.
3
23
  * @public