@fluentui/web-components 3.0.0-beta.53 → 3.0.0-beta.55

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 (44) hide show
  1. package/CHANGELOG.md +20 -2
  2. package/dist/dts/index-rollup.d.ts +1 -0
  3. package/dist/dts/index.d.ts +2 -1
  4. package/dist/dts/rating-display/index.d.ts +1 -1
  5. package/dist/dts/rating-display/rating-display.d.ts +65 -33
  6. package/dist/dts/tablist/define.d.ts +1 -0
  7. package/dist/dts/tablist/index.d.ts +5 -0
  8. package/dist/dts/tablist/tablist.bench.d.ts +3 -0
  9. package/dist/dts/tablist/tablist.d.ts +191 -0
  10. package/dist/dts/tablist/tablist.definition.d.ts +7 -0
  11. package/dist/dts/tablist/tablist.options.d.ts +44 -0
  12. package/dist/dts/tablist/tablist.styles.d.ts +4 -0
  13. package/dist/dts/tablist/tablist.template.d.ts +5 -0
  14. package/dist/dts/utils/focusable-element.d.ts +3 -0
  15. package/dist/esm/index-rollup.js +1 -0
  16. package/dist/esm/index-rollup.js.map +1 -1
  17. package/dist/esm/index.js +2 -1
  18. package/dist/esm/index.js.map +1 -1
  19. package/dist/esm/rating-display/index.js +1 -1
  20. package/dist/esm/rating-display/index.js.map +1 -1
  21. package/dist/esm/rating-display/rating-display.js +91 -46
  22. package/dist/esm/rating-display/rating-display.js.map +1 -1
  23. package/dist/esm/tablist/define.js +4 -0
  24. package/dist/esm/tablist/define.js.map +1 -0
  25. package/dist/esm/tablist/index.js +6 -0
  26. package/dist/esm/tablist/index.js.map +1 -0
  27. package/dist/esm/tablist/tablist.bench.js +21 -0
  28. package/dist/esm/tablist/tablist.bench.js.map +1 -0
  29. package/dist/esm/tablist/tablist.definition.js +15 -0
  30. package/dist/esm/tablist/tablist.definition.js.map +1 -0
  31. package/dist/esm/tablist/tablist.js +407 -0
  32. package/dist/esm/tablist/tablist.js.map +1 -0
  33. package/dist/esm/tablist/tablist.options.js +24 -0
  34. package/dist/esm/tablist/tablist.options.js.map +1 -0
  35. package/dist/esm/tablist/tablist.styles.js +194 -0
  36. package/dist/esm/tablist/tablist.styles.js.map +1 -0
  37. package/dist/esm/tablist/tablist.template.js +10 -0
  38. package/dist/esm/tablist/tablist.template.js.map +1 -0
  39. package/dist/esm/utils/focusable-element.js +10 -0
  40. package/dist/esm/utils/focusable-element.js.map +1 -0
  41. package/dist/web-components.d.ts +335 -45
  42. package/dist/web-components.js +987 -542
  43. package/dist/web-components.min.js +290 -287
  44. package/package.json +7 -5
@@ -5,31 +5,7 @@ import { toggleState } from '../utils/element-internals.js';
5
5
  * The base class used for constructing a fluent-rating-display custom element
6
6
  * @public
7
7
  */
8
- export class RatingDisplay extends FASTElement {
9
- /**
10
- * Handles changes to the color attribute.
11
- *
12
- * @param prev - The previous state
13
- * @param next - The next state
14
- */
15
- colorChanged(prev, next) {
16
- if (prev)
17
- toggleState(this.elementInternals, prev, false);
18
- if (next)
19
- toggleState(this.elementInternals, next, true);
20
- }
21
- /**
22
- * Handles changes to the size attribute.
23
- *
24
- * @param prev - The previous state
25
- * @param next - The next state
26
- */
27
- sizeChanged(prev, next) {
28
- if (prev)
29
- toggleState(this.elementInternals, prev, false);
30
- if (next)
31
- toggleState(this.elementInternals, next, true);
32
- }
8
+ export class BaseRatingDisplay extends FASTElement {
33
9
  constructor() {
34
10
  super();
35
11
  /**
@@ -38,14 +14,6 @@ export class RatingDisplay extends FASTElement {
38
14
  * @internal
39
15
  */
40
16
  this.elementInternals = this.attachInternals();
41
- /**
42
- * Renders a single filled icon with a label next to it.
43
- *
44
- * @public
45
- * @remarks
46
- * HTML Attribute: `compact`
47
- */
48
- this.compact = false;
49
17
  this.intlNumberFormatter = new Intl.NumberFormat();
50
18
  this.elementInternals.role = 'img';
51
19
  }
@@ -57,19 +25,35 @@ export class RatingDisplay extends FASTElement {
57
25
  get formattedCount() {
58
26
  return this.count ? this.intlNumberFormatter.format(this.count) : '';
59
27
  }
28
+ /**
29
+ * Gets the selected value
30
+ *
31
+ * @protected
32
+ */
33
+ getSelectedValue() {
34
+ var _a;
35
+ return Math.round(((_a = this.value) !== null && _a !== void 0 ? _a : 0) * 2) / 2;
36
+ }
37
+ /**
38
+ * Gets the maximum icons to render
39
+ *
40
+ * @protected
41
+ */
42
+ getMaxIcons() {
43
+ var _a;
44
+ return ((_a = this.max) !== null && _a !== void 0 ? _a : 5) * 2;
45
+ }
60
46
  /**
61
47
  * Generates the icon SVG elements based on the "max" attribute.
62
48
  *
63
49
  * @internal
64
50
  */
65
51
  generateIcons() {
66
- var _a, _b;
67
52
  let htmlString = '';
68
53
  // The value of the selected icon. Based on the "value" attribute, rounded to the nearest half.
69
- const selectedValue = Math.round((this.compact ? 1 : (_a = this.value) !== null && _a !== void 0 ? _a : 0) * 2) / 2;
54
+ const selectedValue = this.getSelectedValue();
70
55
  // Render the icons based on the "max" attribute. If "max" is not set, render 5 icons.
71
- // If "compact" is true, only render one filled icon.
72
- for (let i = 0; i < (this.compact ? 1 : (_b = this.max) !== null && _b !== void 0 ? _b : 5) * 2; i++) {
56
+ for (let i = 0; i < this.getMaxIcons(); i++) {
73
57
  const iconValue = (i + 1) / 2;
74
58
  htmlString += `<svg aria-hidden="true" ${iconValue === selectedValue ? 'selected' : ''}><use href="#star"></use></svg>`;
75
59
  }
@@ -77,21 +61,82 @@ export class RatingDisplay extends FASTElement {
77
61
  }
78
62
  }
79
63
  __decorate([
80
- attr
81
- ], RatingDisplay.prototype, "color", void 0);
82
- __decorate([
83
- attr({ mode: 'boolean' })
84
- ], RatingDisplay.prototype, "compact", void 0);
64
+ attr({ converter: nullableNumberConverter })
65
+ ], BaseRatingDisplay.prototype, "count", void 0);
85
66
  __decorate([
86
67
  attr({ converter: nullableNumberConverter })
87
- ], RatingDisplay.prototype, "count", void 0);
68
+ ], BaseRatingDisplay.prototype, "max", void 0);
88
69
  __decorate([
89
70
  attr({ converter: nullableNumberConverter })
90
- ], RatingDisplay.prototype, "max", void 0);
71
+ ], BaseRatingDisplay.prototype, "value", void 0);
72
+ /**
73
+ * A Rating Dislpay Custom HTML Element.
74
+ * Based on BaseRatingDisplay and includes style and layout specific attributes
75
+ *
76
+ * @public
77
+ */
78
+ export class RatingDisplay extends BaseRatingDisplay {
79
+ constructor() {
80
+ super(...arguments);
81
+ /**
82
+ * Renders a single filled icon with a label next to it.
83
+ *
84
+ * @public
85
+ * @remarks
86
+ * HTML Attribute: `compact`
87
+ */
88
+ this.compact = false;
89
+ }
90
+ /**
91
+ * Handles changes to the color attribute.
92
+ *
93
+ * @param prev - The previous state
94
+ * @param next - The next state
95
+ */
96
+ colorChanged(prev, next) {
97
+ if (prev)
98
+ toggleState(this.elementInternals, prev, false);
99
+ if (next)
100
+ toggleState(this.elementInternals, next, true);
101
+ }
102
+ /**
103
+ * Handles changes to the size attribute.
104
+ *
105
+ * @param prev - The previous state
106
+ * @param next - The next state
107
+ */
108
+ sizeChanged(prev, next) {
109
+ if (prev)
110
+ toggleState(this.elementInternals, prev, false);
111
+ if (next)
112
+ toggleState(this.elementInternals, next, true);
113
+ }
114
+ /**
115
+ * Overrides the selected value and returns 1 if compact is true.
116
+ *
117
+ * @override
118
+ */
119
+ getSelectedValue() {
120
+ var _a;
121
+ return Math.round((this.compact ? 1 : (_a = this.value) !== null && _a !== void 0 ? _a : 0) * 2) / 2;
122
+ }
123
+ /**
124
+ * Overrides the maximum icons and returns a max of 1 if compact is true.
125
+ *
126
+ * @override
127
+ */
128
+ getMaxIcons() {
129
+ var _a;
130
+ return (this.compact ? 1 : (_a = this.max) !== null && _a !== void 0 ? _a : 5) * 2;
131
+ }
132
+ }
133
+ __decorate([
134
+ attr
135
+ ], RatingDisplay.prototype, "color", void 0);
91
136
  __decorate([
92
137
  attr
93
138
  ], RatingDisplay.prototype, "size", void 0);
94
139
  __decorate([
95
- attr({ converter: nullableNumberConverter })
96
- ], RatingDisplay.prototype, "value", void 0);
140
+ attr({ mode: 'boolean' })
141
+ ], RatingDisplay.prototype, "compact", void 0);
97
142
  //# sourceMappingURL=rating-display.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"rating-display.js","sourceRoot":"","sources":["../../../src/rating-display/rating-display.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,IAAI,EAAE,WAAW,EAAE,uBAAuB,EAAE,MAAM,yBAAyB,CAAC;AACrF,OAAO,EAAE,WAAW,EAAE,MAAM,+BAA+B,CAAC;AAG5D;;;GAGG;AACH,MAAM,OAAO,aAAc,SAAQ,WAAW;IAmB5C;;;;;OAKG;IACI,YAAY,CAAC,IAAoC,EAAE,IAAoC;QAC5F,IAAI,IAAI;YAAE,WAAW,CAAC,IAAI,CAAC,gBAAgB,EAAE,IAAI,EAAE,KAAK,CAAC,CAAC;QAC1D,IAAI,IAAI;YAAE,WAAW,CAAC,IAAI,CAAC,gBAAgB,EAAE,IAAI,EAAE,IAAI,CAAC,CAAC;IAC3D,CAAC;IA6CD;;;;;OAKG;IACI,WAAW,CAAC,IAAmC,EAAE,IAAmC;QACzF,IAAI,IAAI;YAAE,WAAW,CAAC,IAAI,CAAC,gBAAgB,EAAE,IAAI,EAAE,KAAK,CAAC,CAAC;QAC1D,IAAI,IAAI;YAAE,WAAW,CAAC,IAAI,CAAC,gBAAgB,EAAE,IAAI,EAAE,IAAI,CAAC,CAAC;IAC3D,CAAC;IAcD;QACE,KAAK,EAAE,CAAC;QAhGV;;;;WAIG;QACI,qBAAgB,GAAqB,IAAI,CAAC,eAAe,EAAE,CAAC;QAwBnE;;;;;;WAMG;QAEI,YAAO,GAAY,KAAK,CAAC;QAwDxB,wBAAmB,GAAG,IAAI,IAAI,CAAC,YAAY,EAAE,CAAC;QAKpD,IAAI,CAAC,gBAAgB,CAAC,IAAI,GAAG,KAAK,CAAC;IACrC,CAAC;IAED;;;;OAIG;IACH,IAAW,cAAc;QACvB,OAAO,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,CAAC,mBAAmB,CAAC,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC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CAAC,CAAC,MAAA,IAAI,CAAC,GAAG,mCAAI,CAAC,CAAC,GAAG,CAAC,CAAC;IAChD,CAAC;CACF;AA9DQ;IADN,IAAI;4CAC6B;AAsB3B;IADN,IAAI;2CAC2B;AAqBzB;IADN,IAAI,CAAC,EAAE,IAAI,EAAE,SAAS,EAAE,CAAC;8CACM"}
@@ -0,0 +1,4 @@
1
+ import { FluentDesignSystem } from '../fluent-design-system.js';
2
+ import { definition } from './tablist.definition.js';
3
+ definition.define(FluentDesignSystem.registry);
4
+ //# sourceMappingURL=define.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"define.js","sourceRoot":"","sources":["../../../src/tablist/define.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,4BAA4B,CAAC;AAChE,OAAO,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;AAErD,UAAU,CAAC,MAAM,CAAC,kBAAkB,CAAC,QAAQ,CAAC,CAAC"}
@@ -0,0 +1,6 @@
1
+ export { definition as TablistDefinition } from './tablist.definition.js';
2
+ export { BaseTablist, Tablist } from './tablist.js';
3
+ export { TablistAppearance, TablistOrientation, TablistSize } from './tablist.options.js';
4
+ export { styles as TablistStyles } from './tablist.styles.js';
5
+ export { template as TablistTemplate } from './tablist.template.js';
6
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/tablist/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,IAAI,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;AAC1E,OAAO,EAAE,WAAW,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AACpD,OAAO,EAAE,iBAAiB,EAAE,kBAAkB,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AAC1F,OAAO,EAAE,MAAM,IAAI,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAC9D,OAAO,EAAE,QAAQ,IAAI,eAAe,EAAE,MAAM,uBAAuB,CAAC"}
@@ -0,0 +1,21 @@
1
+ import { FluentDesignSystem } from '../fluent-design-system.js';
2
+ import { definition as tabDefinition } from '../tab/tab.definition.js';
3
+ import { definition as tablistDefinition } from './tablist.definition.js';
4
+ tabDefinition.define(FluentDesignSystem.registry);
5
+ tablistDefinition.define(FluentDesignSystem.registry);
6
+ const itemRenderer = () => {
7
+ const tablist = document.createElement('fluent-tablist');
8
+ const tab = document.createElement('fluent-tab');
9
+ const tab2 = document.createElement('fluent-tab');
10
+ const tab3 = document.createElement('fluent-tab');
11
+ tab.appendChild(document.createTextNode('Tab 1'));
12
+ tab2.appendChild(document.createTextNode('Tab 2'));
13
+ tab3.appendChild(document.createTextNode('Tab 3'));
14
+ tablist.appendChild(tab);
15
+ tablist.appendChild(tab2);
16
+ tablist.appendChild(tab3);
17
+ return tablist;
18
+ };
19
+ export default itemRenderer;
20
+ export { tests } from '../utils/benchmark-wrapper.js';
21
+ //# sourceMappingURL=tablist.bench.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tablist.bench.js","sourceRoot":"","sources":["../../../src/tablist/tablist.bench.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,4BAA4B,CAAC;AAChE,OAAO,EAAE,UAAU,IAAI,aAAa,EAAE,MAAM,0BAA0B,CAAC;AACvE,OAAO,EAAE,UAAU,IAAI,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;AAE1E,aAAa,CAAC,MAAM,CAAC,kBAAkB,CAAC,QAAQ,CAAC,CAAC;AAClD,iBAAiB,CAAC,MAAM,CAAC,kBAAkB,CAAC,QAAQ,CAAC,CAAC;AAEtD,MAAM,YAAY,GAAG,GAAG,EAAE;IACxB,MAAM,OAAO,GAAG,QAAQ,CAAC,aAAa,CAAC,gBAAgB,CAAC,CAAC;IACzD,MAAM,GAAG,GAAG,QAAQ,CAAC,aAAa,CAAC,YAAY,CAAC,CAAC;IACjD,MAAM,IAAI,GAAG,QAAQ,CAAC,aAAa,CAAC,YAAY,CAAC,CAAC;IAClD,MAAM,IAAI,GAAG,QAAQ,CAAC,aAAa,CAAC,YAAY,CAAC,CAAC;IAElD,GAAG,CAAC,WAAW,CAAC,QAAQ,CAAC,cAAc,CAAC,OAAO,CAAC,CAAC,CAAC;IAClD,IAAI,CAAC,WAAW,CAAC,QAAQ,CAAC,cAAc,CAAC,OAAO,CAAC,CAAC,CAAC;IACnD,IAAI,CAAC,WAAW,CAAC,QAAQ,CAAC,cAAc,CAAC,OAAO,CAAC,CAAC,CAAC;IAEnD,OAAO,CAAC,WAAW,CAAC,GAAG,CAAC,CAAC;IACzB,OAAO,CAAC,WAAW,CAAC,IAAI,CAAC,CAAC;IAC1B,OAAO,CAAC,WAAW,CAAC,IAAI,CAAC,CAAC;IAE1B,OAAO,OAAO,CAAC;AACjB,CAAC,CAAC;AAEF,eAAe,YAAY,CAAC;AAC5B,OAAO,EAAE,KAAK,EAAE,MAAM,+BAA+B,CAAC"}
@@ -0,0 +1,15 @@
1
+ import { FluentDesignSystem } from '../fluent-design-system.js';
2
+ import { Tablist } from './tablist.js';
3
+ import { template } from './tablist.template.js';
4
+ import { styles } from './tablist.styles.js';
5
+ /**
6
+ * @public
7
+ * @remarks
8
+ * HTML Element: \<fluent-tablist\>
9
+ */
10
+ export const definition = Tablist.compose({
11
+ name: `${FluentDesignSystem.prefix}-tablist`,
12
+ template,
13
+ styles,
14
+ });
15
+ //# sourceMappingURL=tablist.definition.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tablist.definition.js","sourceRoot":"","sources":["../../../src/tablist/tablist.definition.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,4BAA4B,CAAC;AAChE,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AACvC,OAAO,EAAE,QAAQ,EAAE,MAAM,uBAAuB,CAAC;AACjD,OAAO,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAE7C;;;;GAIG;AACH,MAAM,CAAC,MAAM,UAAU,GAAG,OAAO,CAAC,OAAO,CAAC;IACxC,IAAI,EAAE,GAAG,kBAAkB,CAAC,MAAM,UAAU;IAC5C,QAAQ;IACR,MAAM;CACP,CAAC,CAAC"}
@@ -0,0 +1,407 @@
1
+ import { __decorate } from "tslib";
2
+ import { attr, FASTElement, observable } from '@microsoft/fast-element';
3
+ import { wrapInBounds } from '@microsoft/fast-web-utilities';
4
+ import { keyArrowDown, keyArrowLeft, keyArrowRight, keyArrowUp, keyEnd, keyHome, uniqueId, } from '@microsoft/fast-web-utilities';
5
+ import { getDirection } from '../utils/index.js';
6
+ import { toggleState } from '../utils/element-internals.js';
7
+ import { isFocusableElement } from '../utils/focusable-element.js';
8
+ import { TablistAppearance, TablistOrientation } from './tablist.options.js';
9
+ /**
10
+ * A Tablist element that wraps a collection of tab elements
11
+ * @public
12
+ */
13
+ export class BaseTablist extends FASTElement {
14
+ constructor() {
15
+ super(...arguments);
16
+ /**
17
+ * The internal {@link https://developer.mozilla.org/docs/Web/API/ElementInternals | `ElementInternals`} instance for the component.
18
+ *
19
+ * @internal
20
+ */
21
+ this.elementInternals = this.attachInternals();
22
+ /**
23
+ * Used for disabling all click and keyboard events for the tabs, child tab elements.
24
+ * @public
25
+ * @remarks
26
+ * HTML Attribute: disabled.
27
+ */
28
+ this.disabled = false;
29
+ /**
30
+ * The orientation
31
+ * @public
32
+ * @remarks
33
+ * HTML Attribute: orientation
34
+ */
35
+ this.orientation = TablistOrientation.horizontal;
36
+ this.prevActiveTabIndex = 0;
37
+ this.activeTabIndex = 0;
38
+ this.change = () => {
39
+ this.$emit('change', this.activetab);
40
+ };
41
+ this.handleTabClick = (event) => {
42
+ const selectedTab = event.currentTarget;
43
+ if (selectedTab.nodeType === Node.ELEMENT_NODE && isFocusableElement(selectedTab)) {
44
+ this.prevActiveTabIndex = this.activeTabIndex;
45
+ this.activeTabIndex = this.tabs.indexOf(selectedTab);
46
+ this.setComponent();
47
+ }
48
+ };
49
+ this.handleTabKeyDown = (event) => {
50
+ const dir = getDirection(this);
51
+ switch (event.key) {
52
+ case keyArrowLeft:
53
+ if (!this.isHorizontal()) {
54
+ return;
55
+ }
56
+ event.preventDefault();
57
+ this.adjust(dir === 'ltr' ? -1 : 1);
58
+ break;
59
+ case keyArrowRight:
60
+ if (!this.isHorizontal()) {
61
+ return;
62
+ }
63
+ event.preventDefault();
64
+ this.adjust(dir === 'ltr' ? 1 : -1);
65
+ break;
66
+ case keyArrowUp:
67
+ if (this.isHorizontal()) {
68
+ return;
69
+ }
70
+ event.preventDefault();
71
+ this.adjust(-1);
72
+ break;
73
+ case keyArrowDown:
74
+ if (this.isHorizontal()) {
75
+ return;
76
+ }
77
+ event.preventDefault();
78
+ this.adjust(1);
79
+ break;
80
+ case keyHome:
81
+ event.preventDefault();
82
+ this.adjust(-this.activeTabIndex);
83
+ break;
84
+ case keyEnd:
85
+ event.preventDefault();
86
+ this.adjust(this.tabs.filter(t => isFocusableElement(t)).length - this.activeTabIndex - 1);
87
+ break;
88
+ }
89
+ };
90
+ }
91
+ /**
92
+ * Handles disabled changes
93
+ * @param prev - previous value
94
+ * @param next - next value
95
+ *
96
+ * @internal
97
+ */
98
+ disabledChanged(prev, next) {
99
+ toggleState(this.elementInternals, 'disabled', next);
100
+ }
101
+ /**
102
+ * @internal
103
+ */
104
+ orientationChanged(prev, next) {
105
+ this.elementInternals.ariaOrientation = next !== null && next !== void 0 ? next : TablistOrientation.horizontal;
106
+ if (prev) {
107
+ toggleState(this.elementInternals, `${prev}`, false);
108
+ }
109
+ if (next) {
110
+ toggleState(this.elementInternals, `${next}`, true);
111
+ }
112
+ if (this.$fastController.isConnected) {
113
+ this.setTabs();
114
+ }
115
+ }
116
+ /**
117
+ * @internal
118
+ */
119
+ activeidChanged(oldValue, newValue) {
120
+ if (this.$fastController.isConnected && this.tabs.length > 0) {
121
+ this.prevActiveTabIndex = this.tabs.findIndex((item) => item.id === oldValue);
122
+ this.setTabs();
123
+ }
124
+ }
125
+ /**
126
+ * @internal
127
+ */
128
+ tabsChanged() {
129
+ if (this.$fastController.isConnected && this.tabs.length > 0) {
130
+ this.tabIds = this.getTabIds();
131
+ this.setTabs();
132
+ }
133
+ }
134
+ getActiveIndex() {
135
+ const id = this.activeid;
136
+ if (id !== undefined) {
137
+ return this.tabIds.indexOf(this.activeid) === -1 ? 0 : this.tabIds.indexOf(this.activeid);
138
+ }
139
+ else {
140
+ return 0;
141
+ }
142
+ }
143
+ /**
144
+ * Function that is invoked whenever the selected tab or the tab collection changes.
145
+ *
146
+ * @public
147
+ */
148
+ setTabs() {
149
+ this.activeTabIndex = this.getActiveIndex();
150
+ this.tabs.forEach((tab, index) => {
151
+ if (tab.slot === 'tab') {
152
+ const isActiveTab = this.activeTabIndex === index && isFocusableElement(tab);
153
+ const tabId = this.tabIds[index];
154
+ tab.setAttribute('id', tabId);
155
+ tab.setAttribute('aria-selected', isActiveTab ? 'true' : 'false');
156
+ tab.addEventListener('click', this.handleTabClick);
157
+ tab.addEventListener('keydown', this.handleTabKeyDown);
158
+ tab.setAttribute('tabindex', isActiveTab && !this.disabled ? '0' : '-1');
159
+ if (isActiveTab) {
160
+ this.activetab = tab;
161
+ this.activeid = tabId;
162
+ }
163
+ this.change();
164
+ }
165
+ });
166
+ }
167
+ getTabIds() {
168
+ return this.tabs.map((tab) => {
169
+ var _a;
170
+ return (_a = tab.getAttribute('id')) !== null && _a !== void 0 ? _a : `tab-${uniqueId()}`;
171
+ });
172
+ }
173
+ setComponent() {
174
+ if (this.activeTabIndex !== this.prevActiveTabIndex) {
175
+ this.activeid = this.tabIds[this.activeTabIndex];
176
+ this.focusTab();
177
+ this.change();
178
+ }
179
+ }
180
+ isHorizontal() {
181
+ return this.orientation === TablistOrientation.horizontal;
182
+ }
183
+ /**
184
+ * The adjust method for FASTTabs
185
+ * @public
186
+ * @remarks
187
+ * This method allows the active index to be adjusted by numerical increments
188
+ */
189
+ adjust(adjustment) {
190
+ const focusableTabs = this.tabs.filter(t => isFocusableElement(t));
191
+ const currentActiveTabIndex = focusableTabs.indexOf(this.activetab);
192
+ const nextTabIndex = wrapInBounds(0, focusableTabs.length - 1, currentActiveTabIndex + adjustment);
193
+ // the index of the next focusable tab within the context of all available tabs
194
+ const nextIndex = this.tabs.indexOf(focusableTabs[nextTabIndex]);
195
+ if (nextIndex > -1) {
196
+ this.activateTabByIndex(this.tabs, nextIndex);
197
+ }
198
+ }
199
+ activateTabByIndex(group, index) {
200
+ const tab = group[index];
201
+ this.activetab = tab;
202
+ this.prevActiveTabIndex = this.activeTabIndex;
203
+ this.activeTabIndex = index;
204
+ tab.focus();
205
+ this.setComponent();
206
+ }
207
+ focusTab() {
208
+ this.tabs[this.activeTabIndex].focus();
209
+ }
210
+ /**
211
+ * @internal
212
+ */
213
+ connectedCallback() {
214
+ super.connectedCallback();
215
+ this.tabIds = this.getTabIds();
216
+ this.activeTabIndex = this.getActiveIndex();
217
+ }
218
+ }
219
+ __decorate([
220
+ attr({ mode: 'boolean' })
221
+ ], BaseTablist.prototype, "disabled", void 0);
222
+ __decorate([
223
+ attr
224
+ ], BaseTablist.prototype, "orientation", void 0);
225
+ __decorate([
226
+ attr
227
+ ], BaseTablist.prototype, "activeid", void 0);
228
+ __decorate([
229
+ observable
230
+ ], BaseTablist.prototype, "tabs", void 0);
231
+ /**
232
+ * A BaseTablist component with extra logic for handling the styled active tab indicator.
233
+ * @public
234
+ */
235
+ export class Tablist extends BaseTablist {
236
+ constructor() {
237
+ super(...arguments);
238
+ /**
239
+ * activeTabData
240
+ * The positional coordinates and size dimensions of the active tab. Used for calculating the offset and scale of the tab active indicator.
241
+ */
242
+ this.activeTabData = { x: 0, y: 0, height: 0, width: 0 };
243
+ /**
244
+ * previousActiveTabData
245
+ * The positional coordinates and size dimensions of the active tab. Used for calculating the offset and scale of the tab active indicator.
246
+ */
247
+ this.previousActiveTabData = { x: 0, y: 0, height: 0, width: 0 };
248
+ /**
249
+ * activeTabOffset
250
+ * Used to position the active indicator for animations of the active indicator on active tab changes.
251
+ */
252
+ this.activeTabOffset = 0;
253
+ /**
254
+ * activeTabScale
255
+ * Used to scale the tab active indicator up or down as animations of the active indicator occur.
256
+ */
257
+ this.activeTabScale = 1;
258
+ /**
259
+ * appearance
260
+ * There are two modes of appearance: transparent and subtle.
261
+ */
262
+ this.appearance = TablistAppearance.transparent;
263
+ }
264
+ /**
265
+ * @internal
266
+ */
267
+ appearanceChanged(prev, next) {
268
+ if (prev) {
269
+ toggleState(this.elementInternals, `${prev}`, false);
270
+ }
271
+ if (next) {
272
+ toggleState(this.elementInternals, `${next}`, true);
273
+ }
274
+ }
275
+ /**
276
+ * @internal
277
+ */
278
+ sizeChanged(prev, next) {
279
+ if (prev) {
280
+ toggleState(this.elementInternals, `${prev}`, false);
281
+ }
282
+ if (next) {
283
+ toggleState(this.elementInternals, `${next}`, true);
284
+ }
285
+ }
286
+ /**
287
+ * calculateAnimationProperties
288
+ *
289
+ * Recalculates the active tab offset and scale.
290
+ * These values will be applied to css variables that control the tab active indicator position animations
291
+ */
292
+ calculateAnimationProperties(tab) {
293
+ this.activeTabOffset = this.getTabPosition(tab);
294
+ this.activeTabScale = this.getTabScale(tab);
295
+ }
296
+ /**
297
+ * getSelectedTabPosition - gets the x or y coordinates of the tab
298
+ */
299
+ getTabPosition(tab) {
300
+ if (this.orientation === TablistOrientation.horizontal) {
301
+ return this.previousActiveTabData.x - (tab.getBoundingClientRect().x - this.getBoundingClientRect().x);
302
+ }
303
+ else
304
+ return this.previousActiveTabData.y - (tab.getBoundingClientRect().y - this.getBoundingClientRect().y);
305
+ }
306
+ /**
307
+ * getSelectedTabScale - gets the scale of the tab
308
+ */
309
+ getTabScale(tab) {
310
+ if (this.orientation === TablistOrientation.horizontal) {
311
+ return this.previousActiveTabData.width / tab.getBoundingClientRect().width;
312
+ }
313
+ else
314
+ return this.previousActiveTabData.height / tab.getBoundingClientRect().height;
315
+ }
316
+ /**
317
+ * Calculates and applies updated values to CSS variables.
318
+ *
319
+ * @param tab - the tab element to apply the updated values to
320
+ * @internal
321
+ */
322
+ applyUpdatedCSSValues(tab) {
323
+ this.calculateAnimationProperties(tab);
324
+ this.setAnimationVars();
325
+ }
326
+ /**
327
+ * Runs through all the operations required for setting the tab active indicator to its starting location, ending
328
+ * location, and applying the animated css class to the tab.
329
+ *
330
+ * @param tab - the tab element to apply the updated values to
331
+ * @internal
332
+ */
333
+ animationLoop(tab) {
334
+ // remove the animated class so nothing animates yet
335
+ tab.setAttribute('data-animate', 'false');
336
+ // animation start - this applyUpdatedCSSValues sets the active indicator to the location of the previously selected tab
337
+ this.applyUpdatedCSSValues(tab);
338
+ // changing the previously active tab allows the applyUpdatedCSSValues method to calculate the correct end to the animation.
339
+ this.previousActiveTabData = this.activeTabData;
340
+ // calculate and apply updated css values for animation.
341
+ this.applyUpdatedCSSValues(tab);
342
+ // add the css class and active indicator will animate from the previous tab location to its tab location
343
+ tab.setAttribute('data-animate', 'true');
344
+ }
345
+ /**
346
+ * Sets the data from the active tab onto the class. used for making all the animation calculations for the active
347
+ * tab indicator.
348
+ *
349
+ * @internal
350
+ */
351
+ setTabData() {
352
+ var _a, _b, _c, _d;
353
+ if (this.tabs && this.tabs.length > 0) {
354
+ const tabs = this.tabs;
355
+ const activeTab = this.activetab || tabs[0];
356
+ const activeRect = activeTab === null || activeTab === void 0 ? void 0 : activeTab.getBoundingClientRect();
357
+ const parentRect = this.getBoundingClientRect();
358
+ this.activeTabData = {
359
+ x: activeRect.x - parentRect.x,
360
+ y: activeRect.y - parentRect.y,
361
+ height: activeRect.height,
362
+ width: activeRect.width,
363
+ };
364
+ if (((_a = this.previousActiveTabData) === null || _a === void 0 ? void 0 : _a.x) !== ((_b = this.activeTabData) === null || _b === void 0 ? void 0 : _b.x) &&
365
+ ((_c = this.previousActiveTabData) === null || _c === void 0 ? void 0 : _c.y) !== ((_d = this.activeTabData) === null || _d === void 0 ? void 0 : _d.y)) {
366
+ this.previousActiveTabData = this.activeTabData;
367
+ }
368
+ }
369
+ }
370
+ /**
371
+ * Sets the css variables for the active tab indicator.
372
+ * @internal
373
+ */
374
+ setAnimationVars() {
375
+ this.style.setProperty('--tabIndicatorOffset', `${this.activeTabOffset}px`);
376
+ this.style.setProperty('--tabIndicatorScale', `${this.activeTabScale}`);
377
+ }
378
+ /**
379
+ * Initiates the active tab indicator animation loop when activeid changes.
380
+ * @param oldValue - the previous tabId
381
+ * @param newValue - the new tabId
382
+ */
383
+ activeidChanged(oldValue, newValue) {
384
+ super.activeidChanged(oldValue, newValue);
385
+ this.setTabData();
386
+ if (this.activetab) {
387
+ this.animationLoop(this.activetab);
388
+ }
389
+ }
390
+ /**
391
+ * Initiates the active tab indicator animation loop when tabs change.
392
+ */
393
+ tabsChanged() {
394
+ super.tabsChanged();
395
+ this.setTabData();
396
+ if (this.activetab) {
397
+ this.animationLoop(this.activetab);
398
+ }
399
+ }
400
+ }
401
+ __decorate([
402
+ attr
403
+ ], Tablist.prototype, "appearance", void 0);
404
+ __decorate([
405
+ attr
406
+ ], Tablist.prototype, "size", void 0);
407
+ //# sourceMappingURL=tablist.js.map