@vonage/vivid 4.14.0 → 4.14.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/custom-elements.json +152 -197
- package/lib/divider/divider.d.ts +1 -1
- package/lib/divider/divider.template.d.ts +1 -1
- package/lib/elevation/elevation.d.ts +1 -0
- package/lib/radio/radio.form-associated.d.ts +2 -0
- package/lib/tabs/tabs.d.ts +0 -5
- package/lib/text-anchor/text-anchor.d.ts +2 -2
- package/lib/tree-item/tree-item.d.ts +2 -2
- package/lib/tree-view/tree-view.d.ts +2 -2
- package/package.json +1 -1
- package/shared/affix.cjs +8 -8
- package/shared/affix.js +2 -2
- package/shared/anchor.cjs +10 -10
- package/shared/anchor.js +1 -1
- package/shared/anchored.cjs +6 -6
- package/shared/anchored.js +1 -1
- package/shared/apply-mixins.cjs +3 -3
- package/shared/apply-mixins.js +1 -1
- package/shared/apply-mixins2.cjs +3 -3
- package/shared/apply-mixins2.js +1 -1
- package/shared/applyMixinsWithObservables.cjs +3 -3
- package/shared/applyMixinsWithObservables.js +1 -1
- package/shared/aria-global.cjs +20 -20
- package/shared/aria-global.js +1 -1
- package/shared/base-progress.cjs +7 -8
- package/shared/base-progress.js +2 -3
- package/shared/breadcrumb-item.cjs +2 -3
- package/shared/breadcrumb-item.js +1 -2
- package/shared/button.cjs +10 -11
- package/shared/button.js +1 -2
- package/shared/calendar-event.cjs +7 -8
- package/shared/calendar-event.js +1 -2
- package/shared/children.cjs +2 -2
- package/shared/children.js +1 -1
- package/shared/definition.cjs +14 -15
- package/shared/definition.js +2 -3
- package/shared/definition10.cjs +5 -6
- package/shared/definition10.js +1 -2
- package/shared/definition11.cjs +29 -29
- package/shared/definition11.js +2 -2
- package/shared/definition12.cjs +6 -6
- package/shared/definition12.js +1 -1
- package/shared/definition13.cjs +13 -14
- package/shared/definition13.js +1 -2
- package/shared/definition14.cjs +23 -24
- package/shared/definition14.js +1 -2
- package/shared/definition15.cjs +15 -16
- package/shared/definition15.js +1 -2
- package/shared/definition16.cjs +21 -21
- package/shared/definition16.js +5 -5
- package/shared/definition17.cjs +62 -61
- package/shared/definition17.js +10 -9
- package/shared/definition18.cjs +4 -4
- package/shared/definition18.js +1 -1
- package/shared/definition19.cjs +12 -12
- package/shared/definition19.js +1 -1
- package/shared/definition2.cjs +6 -7
- package/shared/definition2.js +1 -2
- package/shared/definition20.cjs +20 -21
- package/shared/definition20.js +1 -2
- package/shared/definition21.cjs +27 -28
- package/shared/definition21.js +3 -4
- package/shared/definition22.cjs +7 -7
- package/shared/definition22.js +3 -3
- package/shared/definition23.cjs +10 -11
- package/shared/definition23.js +1 -2
- package/shared/definition24.cjs +8 -8
- package/shared/definition24.js +3 -3
- package/shared/definition25.cjs +13 -14
- package/shared/definition25.js +1 -2
- package/shared/definition26.cjs +5 -6
- package/shared/definition26.js +1 -2
- package/shared/definition27.cjs +12 -13
- package/shared/definition27.js +2 -3
- package/shared/definition28.cjs +9 -10
- package/shared/definition28.js +2 -3
- package/shared/definition29.cjs +44 -45
- package/shared/definition29.js +3 -4
- package/shared/definition3.cjs +8 -9
- package/shared/definition3.js +1 -2
- package/shared/definition30.cjs +9 -10
- package/shared/definition30.js +2 -3
- package/shared/definition31.cjs +5 -5
- package/shared/definition31.js +2 -2
- package/shared/definition32.cjs +3 -4
- package/shared/definition32.js +1 -2
- package/shared/definition33.cjs +6 -7
- package/shared/definition33.js +2 -3
- package/shared/definition34.cjs +112 -45
- package/shared/definition34.js +73 -6
- package/shared/definition35.cjs +9 -209
- package/shared/definition35.js +4 -202
- package/shared/definition36.cjs +15 -16
- package/shared/definition36.js +1 -2
- package/shared/definition37.cjs +9 -9
- package/shared/definition37.js +1 -1
- package/shared/definition38.cjs +10 -10
- package/shared/definition38.js +1 -1
- package/shared/definition39.cjs +12 -13
- package/shared/definition39.js +1 -2
- package/shared/definition4.cjs +19 -20
- package/shared/definition4.js +2 -3
- package/shared/definition40.cjs +61 -13
- package/shared/definition40.js +52 -4
- package/shared/definition41.cjs +29 -30
- package/shared/definition41.js +1 -2
- package/shared/definition42.cjs +52 -53
- package/shared/definition42.js +3 -4
- package/shared/definition43.cjs +40 -40
- package/shared/definition43.js +6 -6
- package/shared/definition44.cjs +14 -15
- package/shared/definition44.js +1 -2
- package/shared/definition45.cjs +9 -10
- package/shared/definition45.js +1 -2
- package/shared/definition46.cjs +26 -27
- package/shared/definition46.js +1 -2
- package/shared/definition47.cjs +17 -18
- package/shared/definition47.js +2 -3
- package/shared/definition48.cjs +9 -10
- package/shared/definition48.js +1 -2
- package/shared/definition49.cjs +3 -4
- package/shared/definition49.js +1 -2
- package/shared/definition5.cjs +30 -31
- package/shared/definition5.js +1 -2
- package/shared/definition50.cjs +12 -13
- package/shared/definition50.js +2 -3
- package/shared/definition51.cjs +109 -72
- package/shared/definition51.js +78 -41
- package/shared/definition52.cjs +4 -5
- package/shared/definition52.js +1 -2
- package/shared/definition53.cjs +15 -16
- package/shared/definition53.js +2 -3
- package/shared/definition54.cjs +20 -21
- package/shared/definition54.js +1 -2
- package/shared/definition55.cjs +5 -5
- package/shared/definition55.js +1 -1
- package/shared/definition56.cjs +18 -19
- package/shared/definition56.js +1 -2
- package/shared/definition57.cjs +10 -11
- package/shared/definition57.js +1 -2
- package/shared/definition58.cjs +7 -8
- package/shared/definition58.js +1 -2
- package/shared/definition59.cjs +16 -17
- package/shared/definition59.js +3 -4
- package/shared/definition6.cjs +11 -12
- package/shared/definition6.js +1 -2
- package/shared/definition60.cjs +9 -10
- package/shared/definition60.js +2 -3
- package/shared/definition61.cjs +27 -30
- package/shared/definition61.js +17 -20
- package/shared/definition62.cjs +12 -9
- package/shared/definition62.js +8 -5
- package/shared/definition63.cjs +13 -14
- package/shared/definition63.js +1 -2
- package/shared/definition7.cjs +9 -10
- package/shared/definition7.js +2 -3
- package/shared/definition8.cjs +14 -15
- package/shared/definition8.js +2 -3
- package/shared/definition9.cjs +7 -7
- package/shared/definition9.js +1 -1
- package/shared/form-associated.cjs +14 -14
- package/shared/form-associated.js +1 -1
- package/shared/form-associated2.cjs +10 -10
- package/shared/form-associated2.js +1 -1
- package/shared/form-elements.cjs +13 -13
- package/shared/form-elements.js +1 -1
- package/shared/foundation/progress/base-progress.d.ts +2 -2
- package/shared/foundation-element.cjs +11 -11
- package/shared/foundation-element.js +1 -1
- package/shared/key-codes2.cjs +0 -56
- package/shared/key-codes2.js +1 -53
- package/shared/listbox.cjs +15 -16
- package/shared/listbox.js +2 -3
- package/shared/localized.cjs +2 -2
- package/shared/localized.js +1 -1
- package/shared/option.cjs +205 -0
- package/shared/option.js +202 -0
- package/shared/presentationDate.cjs +42 -43
- package/shared/presentationDate.js +1 -2
- package/shared/ref.cjs +2 -2
- package/shared/ref.js +1 -1
- package/shared/repeat.cjs +15 -15
- package/shared/repeat.js +1 -1
- package/shared/slider.template.cjs +4 -4
- package/shared/slider.template.js +1 -1
- package/shared/slotted.cjs +4 -4
- package/shared/slotted.js +1 -1
- package/shared/start-end.cjs +52 -0
- package/shared/start-end.js +50 -0
- package/shared/text-anchor.cjs +5 -6
- package/shared/text-anchor.js +3 -4
- package/shared/text-anchor.template.cjs +2 -2
- package/shared/text-anchor.template.js +1 -1
- package/shared/text-field2.cjs +23 -24
- package/shared/text-field2.js +2 -3
- package/shared/vivid-element.cjs +2610 -2
- package/shared/vivid-element.js +2591 -2
- package/styles/core/all.css +40 -1
- package/styles/core/theme.css +40 -1
- package/styles/core/typography.css +1 -1
- package/styles/tokens/theme-dark.css +25 -4
- package/styles/tokens/theme-light.css +25 -4
- package/styles/tokens/vivid-2-compat.css +1 -1
- package/text-anchor/index.cjs +3 -3
- package/text-anchor/index.js +1 -1
- package/lib/listbox/definition.d.ts +0 -2
- package/lib/listbox/listbox.d.ts +0 -14
- package/lib/listbox/listbox.template.d.ts +0 -2
- package/listbox/index.cjs +0 -54
- package/listbox/index.js +0 -52
- package/shared/aria-global2.cjs +0 -75
- package/shared/aria-global2.js +0 -73
- package/shared/defineVividComponent.cjs +0 -2612
- package/shared/defineVividComponent.js +0 -2592
- package/shared/listbox2.cjs +0 -1268
- package/shared/listbox2.js +0 -1265
- package/shared/strings2.cjs +0 -37
- package/shared/strings2.js +0 -33
package/shared/definition51.cjs
CHANGED
|
@@ -2,20 +2,40 @@
|
|
|
2
2
|
|
|
3
3
|
const definition = require('./definition50.cjs');
|
|
4
4
|
const definition$1 = require('./definition49.cjs');
|
|
5
|
-
const defineVividComponent = require('./defineVividComponent.cjs');
|
|
6
|
-
const keyCodes$1 = require('./key-codes.cjs');
|
|
7
5
|
const vividElement = require('./vivid-element.cjs');
|
|
6
|
+
const keyCodes$1 = require('./key-codes.cjs');
|
|
8
7
|
const foundationElement = require('./foundation-element.cjs');
|
|
9
|
-
const
|
|
8
|
+
const startEnd = require('./start-end.cjs');
|
|
10
9
|
const applyMixins = require('./apply-mixins2.cjs');
|
|
11
|
-
const
|
|
12
|
-
const strings
|
|
10
|
+
const keyCodes = require('./key-codes2.cjs');
|
|
11
|
+
const strings = require('./strings.cjs');
|
|
13
12
|
const numbers = require('./numbers.cjs');
|
|
14
13
|
const ref = require('./ref.cjs');
|
|
15
14
|
const slotted = require('./slotted.cjs');
|
|
16
15
|
const when = require('./when.cjs');
|
|
17
16
|
const classNames = require('./class-names.cjs');
|
|
18
17
|
|
|
18
|
+
/**
|
|
19
|
+
* This method keeps a given value within the bounds of a min and max value. If the value
|
|
20
|
+
* is larger than the max, the minimum value will be returned. If the value is smaller than the minimum,
|
|
21
|
+
* the maximum will be returned. Otherwise, the value is returned un-changed.
|
|
22
|
+
*/
|
|
23
|
+
/**
|
|
24
|
+
* Ensures that a value is between a min and max value. If value is lower than min, min will be returned.
|
|
25
|
+
* If value is greater than max, max will be returned.
|
|
26
|
+
*/
|
|
27
|
+
function limit(min, max, value) {
|
|
28
|
+
return Math.min(Math.max(value, min), max);
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
let uniqueIdCounter = 0;
|
|
32
|
+
/**
|
|
33
|
+
* Generates a unique ID based on incrementing a counter.
|
|
34
|
+
*/
|
|
35
|
+
function uniqueId(prefix = "") {
|
|
36
|
+
return `${prefix}${uniqueIdCounter++}`;
|
|
37
|
+
}
|
|
38
|
+
|
|
19
39
|
/**
|
|
20
40
|
* The orientation of the {@link @microsoft/fast-foundation#(Tabs:class)} component
|
|
21
41
|
* @public
|
|
@@ -280,13 +300,13 @@ let Tabs$1 = class Tabs extends foundationElement.FoundationElement {
|
|
|
280
300
|
getTabIds() {
|
|
281
301
|
return this.tabs.map((tab) => {
|
|
282
302
|
var _a;
|
|
283
|
-
return (_a = tab.getAttribute("id")) !== null && _a !== void 0 ? _a : `tab-${
|
|
303
|
+
return (_a = tab.getAttribute("id")) !== null && _a !== void 0 ? _a : `tab-${uniqueId()}`;
|
|
284
304
|
});
|
|
285
305
|
}
|
|
286
306
|
getTabPanelIds() {
|
|
287
307
|
return this.tabpanels.map((tabPanel) => {
|
|
288
308
|
var _a;
|
|
289
|
-
return (_a = tabPanel.getAttribute("id")) !== null && _a !== void 0 ? _a : `panel-${
|
|
309
|
+
return (_a = tabPanel.getAttribute("id")) !== null && _a !== void 0 ? _a : `panel-${uniqueId()}`;
|
|
290
310
|
});
|
|
291
311
|
}
|
|
292
312
|
setComponent() {
|
|
@@ -343,7 +363,7 @@ let Tabs$1 = class Tabs extends foundationElement.FoundationElement {
|
|
|
343
363
|
adjust(adjustment) {
|
|
344
364
|
const focusableTabs = this.tabs.filter(t => this.isFocusableElement(t));
|
|
345
365
|
const currentActiveTabIndex = focusableTabs.indexOf(this.activetab);
|
|
346
|
-
const nextTabIndex =
|
|
366
|
+
const nextTabIndex = limit(0, focusableTabs.length - 1, currentActiveTabIndex + adjustment);
|
|
347
367
|
// the index of the next focusable tab within the context of all available tabs
|
|
348
368
|
const nextIndex = this.tabs.indexOf(focusableTabs[nextTabIndex]);
|
|
349
369
|
if (nextIndex > -1) {
|
|
@@ -364,27 +384,27 @@ let Tabs$1 = class Tabs extends foundationElement.FoundationElement {
|
|
|
364
384
|
}
|
|
365
385
|
};
|
|
366
386
|
foundationElement.__decorate([
|
|
367
|
-
|
|
387
|
+
vividElement.attr
|
|
368
388
|
], Tabs$1.prototype, "orientation", void 0);
|
|
369
389
|
foundationElement.__decorate([
|
|
370
|
-
|
|
390
|
+
vividElement.attr
|
|
371
391
|
], Tabs$1.prototype, "activeid", void 0);
|
|
372
392
|
foundationElement.__decorate([
|
|
373
|
-
|
|
393
|
+
vividElement.observable
|
|
374
394
|
], Tabs$1.prototype, "tabs", void 0);
|
|
375
395
|
foundationElement.__decorate([
|
|
376
|
-
|
|
396
|
+
vividElement.observable
|
|
377
397
|
], Tabs$1.prototype, "tabpanels", void 0);
|
|
378
398
|
foundationElement.__decorate([
|
|
379
|
-
|
|
399
|
+
vividElement.attr({ mode: "boolean" })
|
|
380
400
|
], Tabs$1.prototype, "activeindicator", void 0);
|
|
381
401
|
foundationElement.__decorate([
|
|
382
|
-
|
|
402
|
+
vividElement.observable
|
|
383
403
|
], Tabs$1.prototype, "activeIndicatorRef", void 0);
|
|
384
404
|
foundationElement.__decorate([
|
|
385
|
-
|
|
405
|
+
vividElement.observable
|
|
386
406
|
], Tabs$1.prototype, "showActiveIndicator", void 0);
|
|
387
|
-
applyMixins.applyMixins(Tabs$1,
|
|
407
|
+
applyMixins.applyMixins(Tabs$1, startEnd.StartEnd);
|
|
388
408
|
|
|
389
409
|
const styles = ":host{display:block}.base{--_appearance-color-text: var(--_connotation-color-firm);--_appearance-color-fill: transparent;--_appearance-color-outline: transparent}.base.connotation-cta{--_connotation-color-firm: var(--vvd-tabs-cta-firm, var(--vvd-color-cta-600))}.base:not(.connotation-cta){--_connotation-color-firm: var(--vvd-tabs-accent-firm, var(--vvd-color-canvas-text))}.base{--_tabs-tablist-gutter: 8px;--_tabs-active-indicator-stroke-width: 2px;display:grid;box-sizing:border-box}.base.orientation-vertical{overflow:hidden;block-size:inherit;grid-template-columns:auto 1fr;grid-template-rows:1fr}.base:not(.orientation-vertical){grid-template-columns:1fr;grid-template-rows:auto 1fr;max-block-size:100%}.base.layout-stretch .scroll-shadow{flex:1}.base:not(.orientation-vertical) .scroll-shadow{position:relative;overflow:hidden;isolation:isolate}.base:not(.orientation-vertical) .scroll-shadow.start-scroll:before,.base:not(.orientation-vertical) .scroll-shadow.start-scroll:after,.base:not(.orientation-vertical) .scroll-shadow.end-scroll:before,.base:not(.orientation-vertical) .scroll-shadow.end-scroll:after{position:absolute;content:\"\";inline-size:10px;inset-block:0;opacity:0;transition:opacity .1s}.base:not(.orientation-vertical) .scroll-shadow.start-scroll:before{z-index:1;box-shadow:inset 7px 1px 5px -3px var(--vvd-color-neutral-950);inset-inline-start:0;opacity:.2}.base:not(.orientation-vertical) .scroll-shadow.end-scroll:after{box-shadow:inset -7px 1px 5px -3px var(--vvd-color-neutral-950);inset-inline-end:0;opacity:.2}.tabs{display:flex;overflow:hidden}.base.orientation-vertical .tabs{flex-direction:column;box-shadow:1px 0 0 0 var(--vvd-color-neutral-300)}.base.orientation-horizontal .tabs{flex-direction:row;border-bottom:1px solid var(--vvd-color-neutral-300)}.tablist{position:relative;display:grid;box-sizing:border-box;color:var(--_appearance-color-text)}.base.layout-stretch .tablist{--_tab-justify-content: center;--_tabs-tablist-column: 1fr}.tablist .base:not(.layout-stretch){--_tabs-tablist-column: auto}.base.orientation-vertical .tablist{padding:var(--_tabs-tablist-gutter);grid-row:1/2;grid-template-columns:auto 1fr;grid-template-rows:auto;inline-size:100%;place-self:flex-start end;row-gap:var(--_tabs-tablist-gutter)}.base:not(.orientation-vertical) .tablist{justify-content:flex-start;column-gap:var(--_tabs-tablist-gutter);grid-auto-flow:column;grid-template-rows:auto auto;inline-size:100%;padding-inline:var(--_tabs-tablist-gutter)}.base.has-action-items.orientation-vertical .tablist{padding-block-end:0}.base.has-action-items:not(.orientation-vertical) .tablist{padding-inline-end:0}.tablist-wrapper{--scrollbar-track-color: transparent;--scrollbar-thumb-color: color-mix(in srgb, var(--vvd-color-neutral-950), transparent 70%)}.tablist-wrapper{scrollbar-color:var(--scrollbar-thumb-color) var(--scrollbar-track-color);scrollbar-width:thin}.tablist-wrapper ::-webkit-scrollbar{width:4px}.tablist-wrapper ::-webkit-scrollbar-track{background:var(--scrollbar-track-color)}.tablist-wrapper ::-webkit-scrollbar-thumb{border:0;border-radius:4px;background-color:var(--scrollbar-thumb-color)}.base:not(.orientation-vertical) .tablist-wrapper{overflow:auto hidden;align-self:end;inline-size:100%}.base.orientation-vertical .tablist-wrapper{overflow:hidden auto;block-size:100%}.tablist-wrapper::-webkit-scrollbar{display:none}slot[name=action-items]{display:flex}.base.has-action-items.orientation-horizontal slot[name=action-items]{align-items:center;margin-inline:var(--_tabs-tablist-gutter)}.base.has-action-items.orientation-vertical slot[name=action-items]{margin-block:var(--_tabs-tablist-gutter)}.tabpanel{box-sizing:border-box;block-size:100%;min-block-size:0;min-inline-size:0}.base.scroll .tabpanel{overflow-y:auto;--scrollbar-track-color: transparent;--scrollbar-thumb-color: color-mix(in srgb, var(--vvd-color-neutral-950), transparent 70%)}.base.scroll .tabpanel{scrollbar-color:var(--scrollbar-thumb-color) var(--scrollbar-track-color);scrollbar-width:thin}.base.scroll .tabpanel ::-webkit-scrollbar{width:4px}.base.scroll .tabpanel ::-webkit-scrollbar-track{background:var(--scrollbar-track-color)}.base.scroll .tabpanel ::-webkit-scrollbar-thumb{border:0;border-radius:4px;background-color:var(--scrollbar-thumb-color)}.base.gutters-small .tabpanel{padding:calc(1px*(40 + 4*clamp(-1,var(--vvd-size-density, 0),2)) - (1px*(24 + 4*clamp(-1,var(--vvd-size-density, 0),2))))}.active-indicator{background:currentColor;margin-inline-start:calc(var(--_tabs-tablist-gutter) * -1)}.base.orientation-vertical .active-indicator{align-self:center;border-radius:2px;block-size:80%;grid-area:1/1/auto/auto;inline-size:var(--_tabs-active-indicator-stroke-width)}.base:not(.orientation-vertical) .active-indicator{position:absolute;z-index:1;border-radius:2px;block-size:var(--_tabs-active-indicator-stroke-width);grid-column:1/auto;inline-size:calc(var(--_tabs-active-tab-inline-size));inset-block-end:0;inset-inline-start:8px}.activeIndicatorTransition{transition:transform .2s ease-out 0s,inline-size .2s ease-out 0s}";
|
|
390
410
|
|
|
@@ -404,6 +424,11 @@ class Tabs extends vividElement.VividElement {
|
|
|
404
424
|
super(...arguments);
|
|
405
425
|
// eslint-disable-next-line @nrwl/nx/workspace/no-attribute-default-value
|
|
406
426
|
this.orientation = TabsOrientation.horizontal;
|
|
427
|
+
this.#isLastTabSelectedAfterRemove = (oldValue, newValue, isTab = true) => {
|
|
428
|
+
return oldValue.length > newValue.length && this.activetab.id === oldValue[oldValue.length - 1].getAttribute(
|
|
429
|
+
isTab ? "id" : "aria-labelledby"
|
|
430
|
+
);
|
|
431
|
+
};
|
|
407
432
|
// eslint-disable-next-line @nrwl/nx/workspace/no-attribute-default-value
|
|
408
433
|
this.activeindicator = true;
|
|
409
434
|
this.showActiveIndicator = true;
|
|
@@ -426,10 +451,10 @@ class Tabs extends vividElement.VividElement {
|
|
|
426
451
|
this.setTabs = () => {
|
|
427
452
|
const gridHorizontalProperty = "gridColumn";
|
|
428
453
|
const gridVerticalProperty = "gridRow";
|
|
429
|
-
const gridProperty = this
|
|
454
|
+
const gridProperty = this.#isHorizontal() ? gridHorizontalProperty : gridVerticalProperty;
|
|
430
455
|
this.activeTabIndex = this.getActiveIndex();
|
|
431
456
|
this.showActiveIndicator = false;
|
|
432
|
-
if (this
|
|
457
|
+
if (this.#isHorizontal()) {
|
|
433
458
|
this.tablist.style.setProperty(
|
|
434
459
|
"grid-template-columns",
|
|
435
460
|
`repeat(${this.tabs.length}, var(${TABLIST_COLUMN}))`
|
|
@@ -449,7 +474,7 @@ class Tabs extends vividElement.VividElement {
|
|
|
449
474
|
tab.setAttribute("aria-selected", isActiveTab ? "true" : "false");
|
|
450
475
|
tab.setAttribute("aria-controls", tabpanelId);
|
|
451
476
|
tab.addEventListener("click", this.handleTabClick);
|
|
452
|
-
tab.addEventListener("keydown", this
|
|
477
|
+
tab.addEventListener("keydown", this.#handleTabKeyDown);
|
|
453
478
|
tab.setAttribute("tabindex", isActiveTab ? "0" : "-1");
|
|
454
479
|
if (isActiveTab) {
|
|
455
480
|
this.activetab = tab;
|
|
@@ -459,7 +484,7 @@ class Tabs extends vividElement.VividElement {
|
|
|
459
484
|
tab.style[gridHorizontalProperty] = "";
|
|
460
485
|
tab.style[gridVerticalProperty] = "";
|
|
461
486
|
tab.style[gridProperty] = `${index + 1}`;
|
|
462
|
-
!this
|
|
487
|
+
!this.#isHorizontal() ? tab.classList.add("vertical") : tab.classList.remove("vertical");
|
|
463
488
|
});
|
|
464
489
|
};
|
|
465
490
|
this.setTabPanels = () => {
|
|
@@ -479,8 +504,11 @@ class Tabs extends vividElement.VividElement {
|
|
|
479
504
|
this.setComponent();
|
|
480
505
|
}
|
|
481
506
|
};
|
|
482
|
-
this
|
|
483
|
-
|
|
507
|
+
this.#isHorizontal = () => {
|
|
508
|
+
return this.orientation === TabsOrientation.horizontal;
|
|
509
|
+
};
|
|
510
|
+
this.#handleTabKeyDown = (event) => {
|
|
511
|
+
if (this.#isHorizontal()) {
|
|
484
512
|
switch (event.key) {
|
|
485
513
|
case keyCodes$1.keyArrowLeft:
|
|
486
514
|
event.preventDefault();
|
|
@@ -520,7 +548,7 @@ class Tabs extends vividElement.VividElement {
|
|
|
520
548
|
this.adjustBackward = (_) => {
|
|
521
549
|
this.#moveToNextTab(-1);
|
|
522
550
|
};
|
|
523
|
-
this
|
|
551
|
+
this.#moveToTabByIndex = (group, index) => {
|
|
524
552
|
const tab = group[index];
|
|
525
553
|
this.activetab = tab;
|
|
526
554
|
this.prevActiveTabIndex = this.activeTabIndex;
|
|
@@ -538,9 +566,9 @@ class Tabs extends vividElement.VividElement {
|
|
|
538
566
|
if (this.$fastController.isConnected) {
|
|
539
567
|
this.setTabs();
|
|
540
568
|
this.setTabPanels();
|
|
541
|
-
this
|
|
569
|
+
this.#handleActiveIndicatorPosition();
|
|
542
570
|
}
|
|
543
|
-
this
|
|
571
|
+
this.#patchIndicatorStyleTransition();
|
|
544
572
|
if (!this.activeIndicatorRef) return;
|
|
545
573
|
if (this.orientation === TabsOrientation.vertical) {
|
|
546
574
|
this.activeIndicatorRef.style.removeProperty(ACTIVE_TAB_WIDTH);
|
|
@@ -556,38 +584,43 @@ class Tabs extends vividElement.VividElement {
|
|
|
556
584
|
);
|
|
557
585
|
this.setTabs();
|
|
558
586
|
this.setTabPanels();
|
|
559
|
-
this
|
|
587
|
+
this.#handleActiveIndicatorPosition();
|
|
560
588
|
}
|
|
561
|
-
this
|
|
589
|
+
this.#patchIndicatorStyleTransition();
|
|
562
590
|
this.#updateTabsConnotation();
|
|
563
591
|
this.#scrollToIndex(this.activeTabIndex);
|
|
564
592
|
}
|
|
593
|
+
#isLastTabSelectedAfterRemove;
|
|
565
594
|
/**
|
|
566
595
|
* @internal
|
|
567
596
|
*/
|
|
568
|
-
tabsChanged() {
|
|
597
|
+
tabsChanged(oldValue, newValue) {
|
|
569
598
|
if (this.$fastController.isConnected && this.tabs.length <= this.tabpanels.length) {
|
|
570
599
|
this.tabIds = this.getTabIds();
|
|
571
600
|
this.tabpanelIds = this.getTabPanelIds();
|
|
572
601
|
this.setTabs();
|
|
573
602
|
this.setTabPanels();
|
|
574
|
-
this
|
|
603
|
+
this.#handleActiveIndicatorPosition(
|
|
604
|
+
!this.#isLastTabSelectedAfterRemove(oldValue, newValue)
|
|
605
|
+
);
|
|
575
606
|
}
|
|
576
|
-
this
|
|
607
|
+
this.#patchIndicatorStyleTransition();
|
|
577
608
|
this.#updateScrollStatus();
|
|
578
609
|
}
|
|
579
610
|
/**
|
|
580
611
|
* @internal
|
|
581
612
|
*/
|
|
582
|
-
tabpanelsChanged() {
|
|
613
|
+
tabpanelsChanged(oldValue, newValue) {
|
|
583
614
|
if (this.$fastController.isConnected && this.tabpanels.length <= this.tabs.length) {
|
|
584
615
|
this.tabIds = this.getTabIds();
|
|
585
616
|
this.tabpanelIds = this.getTabPanelIds();
|
|
586
617
|
this.setTabs();
|
|
587
618
|
this.setTabPanels();
|
|
588
|
-
this
|
|
619
|
+
this.#handleActiveIndicatorPosition(
|
|
620
|
+
!this.#isLastTabSelectedAfterRemove(oldValue, newValue, false)
|
|
621
|
+
);
|
|
589
622
|
}
|
|
590
|
-
this
|
|
623
|
+
this.#patchIndicatorStyleTransition();
|
|
591
624
|
}
|
|
592
625
|
getActiveIndex() {
|
|
593
626
|
const id = this.activeid;
|
|
@@ -599,12 +632,12 @@ class Tabs extends vividElement.VividElement {
|
|
|
599
632
|
}
|
|
600
633
|
getTabIds() {
|
|
601
634
|
return this.tabs.map((tab) => {
|
|
602
|
-
return tab.getAttribute("id") ?? `tab-${strings
|
|
635
|
+
return tab.getAttribute("id") ?? `tab-${strings.uniqueId()}`;
|
|
603
636
|
});
|
|
604
637
|
}
|
|
605
638
|
getTabPanelIds() {
|
|
606
639
|
return this.tabpanels.map((tabPanel) => {
|
|
607
|
-
return tabPanel.getAttribute("id") ?? `panel-${strings
|
|
640
|
+
return tabPanel.getAttribute("id") ?? `panel-${strings.uniqueId()}`;
|
|
608
641
|
});
|
|
609
642
|
}
|
|
610
643
|
setComponent() {
|
|
@@ -614,9 +647,8 @@ class Tabs extends vividElement.VividElement {
|
|
|
614
647
|
this.change();
|
|
615
648
|
}
|
|
616
649
|
}
|
|
617
|
-
isHorizontal
|
|
618
|
-
|
|
619
|
-
}
|
|
650
|
+
#isHorizontal;
|
|
651
|
+
#handleTabKeyDown;
|
|
620
652
|
/**
|
|
621
653
|
* The adjust method for FASTTabs
|
|
622
654
|
* @public
|
|
@@ -633,7 +665,7 @@ class Tabs extends vividElement.VividElement {
|
|
|
633
665
|
);
|
|
634
666
|
const nextIndex = this.tabs.indexOf(focusableTabs[nextTabIndex]);
|
|
635
667
|
if (nextIndex > -1) {
|
|
636
|
-
this
|
|
668
|
+
this.#moveToTabByIndex(this.tabs, nextIndex);
|
|
637
669
|
}
|
|
638
670
|
}
|
|
639
671
|
#moveToNextTab(direction) {
|
|
@@ -641,11 +673,12 @@ class Tabs extends vividElement.VividElement {
|
|
|
641
673
|
for (let offset = 1; offset < this.tabs.length; offset++) {
|
|
642
674
|
const index = (activeIndex + direction * offset + this.tabs.length) % this.tabs.length;
|
|
643
675
|
if (this.isFocusableElement(this.tabs[index])) {
|
|
644
|
-
this
|
|
676
|
+
this.#moveToTabByIndex(this.tabs, index);
|
|
645
677
|
break;
|
|
646
678
|
}
|
|
647
679
|
}
|
|
648
680
|
}
|
|
681
|
+
#moveToTabByIndex;
|
|
649
682
|
focusTab() {
|
|
650
683
|
this.tabs[this.activeTabIndex].focus();
|
|
651
684
|
}
|
|
@@ -658,13 +691,13 @@ class Tabs extends vividElement.VividElement {
|
|
|
658
691
|
#updateScrollStatus() {
|
|
659
692
|
this.tablist.parentElement.dispatchEvent(new Event("scroll"));
|
|
660
693
|
}
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
patchIndicatorStyleTransition() {
|
|
665
|
-
if (!this
|
|
666
|
-
if (this.orientation === TabsOrientation.vertical || !this.showActiveIndicator)
|
|
694
|
+
get #shouldMoveIndicator() {
|
|
695
|
+
return !(!this.activetab || !this.activeIndicatorRef || this.orientation === TabsOrientation.vertical || !this.showActiveIndicator);
|
|
696
|
+
}
|
|
697
|
+
#patchIndicatorStyleTransition() {
|
|
698
|
+
if (!this.#shouldMoveIndicator) {
|
|
667
699
|
return;
|
|
700
|
+
}
|
|
668
701
|
const width = this.activetab.getBoundingClientRect().width;
|
|
669
702
|
this.activeIndicatorRef.style.setProperty(ACTIVE_TAB_WIDTH, `${width}px`);
|
|
670
703
|
}
|
|
@@ -677,7 +710,7 @@ class Tabs extends vividElement.VividElement {
|
|
|
677
710
|
const scrollWrapper = this.tablist.parentElement;
|
|
678
711
|
this.#resizeObserver = new ResizeObserver(() => {
|
|
679
712
|
this.#updateScrollStatus();
|
|
680
|
-
this
|
|
713
|
+
this.#patchIndicatorStyleTransition();
|
|
681
714
|
});
|
|
682
715
|
this.#resizeObserver.observe(scrollWrapper);
|
|
683
716
|
}
|
|
@@ -723,18 +756,18 @@ class Tabs extends vividElement.VividElement {
|
|
|
723
756
|
this.#tabListWrapper.scrollTo({ top, left, behavior: "smooth" });
|
|
724
757
|
}
|
|
725
758
|
#getGridProperty() {
|
|
726
|
-
return this
|
|
759
|
+
return this.#isHorizontal() ? "gridColumn" : "gridRow";
|
|
727
760
|
}
|
|
728
761
|
#getTranslateProperty() {
|
|
729
|
-
return this
|
|
762
|
+
return this.#isHorizontal() ? "translateX" : "translateY";
|
|
730
763
|
}
|
|
731
|
-
handleActiveIndicatorPosition() {
|
|
764
|
+
#handleActiveIndicatorPosition(animate = true) {
|
|
732
765
|
if (this.showActiveIndicator && this.activeindicator) {
|
|
733
|
-
this
|
|
766
|
+
this.#animateActiveIndicator(animate);
|
|
734
767
|
}
|
|
735
768
|
}
|
|
736
|
-
animateActiveIndicator() {
|
|
737
|
-
const offsetProperty = this
|
|
769
|
+
#animateActiveIndicator(animate) {
|
|
770
|
+
const offsetProperty = this.#isHorizontal() ? "offsetLeft" : "offsetTop";
|
|
738
771
|
const currentOffset = this.activeIndicatorRef[offsetProperty];
|
|
739
772
|
const currentGridValue = this.activeIndicatorRef.style[this.#getGridProperty()];
|
|
740
773
|
this.activeIndicatorRef.style[this.#getGridProperty()] = `${this.activeTabIndex + 1}`;
|
|
@@ -742,7 +775,11 @@ class Tabs extends vividElement.VividElement {
|
|
|
742
775
|
this.activeIndicatorRef.style[this.#getGridProperty()] = currentGridValue;
|
|
743
776
|
const relativeOffset = targetOffset - currentOffset;
|
|
744
777
|
this.activeIndicatorRef.style.transform = `${this.#getTranslateProperty()}(${relativeOffset}px)`;
|
|
745
|
-
|
|
778
|
+
if (animate) {
|
|
779
|
+
this.activeIndicatorRef.classList.add("activeIndicatorTransition");
|
|
780
|
+
} else {
|
|
781
|
+
this.activeIndicatorRef.classList.remove("activeIndicatorTransition");
|
|
782
|
+
}
|
|
746
783
|
}
|
|
747
784
|
/**
|
|
748
785
|
* @internal
|
|
@@ -756,43 +793,43 @@ class Tabs extends vividElement.VividElement {
|
|
|
756
793
|
}
|
|
757
794
|
}
|
|
758
795
|
__decorateClass([
|
|
759
|
-
|
|
796
|
+
vividElement.attr
|
|
760
797
|
], Tabs.prototype, "orientation");
|
|
761
798
|
__decorateClass([
|
|
762
|
-
|
|
799
|
+
vividElement.attr
|
|
763
800
|
], Tabs.prototype, "activeid");
|
|
764
801
|
__decorateClass([
|
|
765
|
-
|
|
802
|
+
vividElement.observable
|
|
766
803
|
], Tabs.prototype, "tabs");
|
|
767
804
|
__decorateClass([
|
|
768
|
-
|
|
805
|
+
vividElement.observable
|
|
769
806
|
], Tabs.prototype, "tabpanels");
|
|
770
807
|
__decorateClass([
|
|
771
|
-
|
|
808
|
+
vividElement.attr({ mode: "boolean" })
|
|
772
809
|
], Tabs.prototype, "activeindicator");
|
|
773
810
|
__decorateClass([
|
|
774
|
-
|
|
811
|
+
vividElement.observable
|
|
775
812
|
], Tabs.prototype, "activeIndicatorRef");
|
|
776
813
|
__decorateClass([
|
|
777
|
-
|
|
814
|
+
vividElement.observable
|
|
778
815
|
], Tabs.prototype, "showActiveIndicator");
|
|
779
816
|
__decorateClass([
|
|
780
|
-
|
|
817
|
+
vividElement.observable
|
|
781
818
|
], Tabs.prototype, "tablist");
|
|
782
819
|
__decorateClass([
|
|
783
|
-
|
|
820
|
+
vividElement.attr
|
|
784
821
|
], Tabs.prototype, "connotation");
|
|
785
822
|
__decorateClass([
|
|
786
|
-
|
|
823
|
+
vividElement.attr
|
|
787
824
|
], Tabs.prototype, "gutters");
|
|
788
825
|
__decorateClass([
|
|
789
|
-
|
|
826
|
+
vividElement.attr({ mode: "boolean", attribute: "scrollable-panel" })
|
|
790
827
|
], Tabs.prototype, "scrollablePanel");
|
|
791
828
|
__decorateClass([
|
|
792
|
-
|
|
829
|
+
vividElement.attr({ attribute: "tabs-layout" })
|
|
793
830
|
], Tabs.prototype, "tabsLayout");
|
|
794
831
|
__decorateClass([
|
|
795
|
-
|
|
832
|
+
vividElement.observable
|
|
796
833
|
], Tabs.prototype, "_actionItemsSlottedContent");
|
|
797
834
|
|
|
798
835
|
const getClasses = ({
|
|
@@ -829,7 +866,7 @@ function addEndShadow(scrollShadow, scrollWrapper) {
|
|
|
829
866
|
);
|
|
830
867
|
}
|
|
831
868
|
function setShadowWhenScrollTabs(_, { event }) {
|
|
832
|
-
const scrollWrapper = event.
|
|
869
|
+
const scrollWrapper = event.currentTarget;
|
|
833
870
|
const scrollShadow = scrollWrapper.parentElement;
|
|
834
871
|
if (setNoScrollState(scrollShadow, scrollWrapper)) {
|
|
835
872
|
return;
|
|
@@ -837,7 +874,7 @@ function setShadowWhenScrollTabs(_, { event }) {
|
|
|
837
874
|
addStartShadow(scrollShadow, scrollWrapper);
|
|
838
875
|
addEndShadow(scrollShadow, scrollWrapper);
|
|
839
876
|
}
|
|
840
|
-
const TabsTemplate =
|
|
877
|
+
const TabsTemplate = vividElement.html`
|
|
841
878
|
<template>
|
|
842
879
|
<div class="${getClasses}">
|
|
843
880
|
<div class="tabs">
|
|
@@ -847,7 +884,7 @@ const TabsTemplate = defineVividComponent.html`
|
|
|
847
884
|
<slot name="tab" ${slotted.slotted("tabs")}></slot>
|
|
848
885
|
${when.when(
|
|
849
886
|
(x) => x.showActiveIndicator,
|
|
850
|
-
|
|
887
|
+
vividElement.html`
|
|
851
888
|
<div
|
|
852
889
|
${ref.ref("activeIndicatorRef")}
|
|
853
890
|
class="active-indicator"
|
|
@@ -869,7 +906,7 @@ const TabsTemplate = defineVividComponent.html`
|
|
|
869
906
|
</template>
|
|
870
907
|
`;
|
|
871
908
|
|
|
872
|
-
const tabsDefinition =
|
|
909
|
+
const tabsDefinition = vividElement.defineVividComponent(
|
|
873
910
|
"tabs",
|
|
874
911
|
Tabs,
|
|
875
912
|
TabsTemplate,
|
|
@@ -878,7 +915,7 @@ const tabsDefinition = defineVividComponent.defineVividComponent(
|
|
|
878
915
|
styles
|
|
879
916
|
}
|
|
880
917
|
);
|
|
881
|
-
const registerTabs =
|
|
918
|
+
const registerTabs = vividElement.createRegisterFunction(tabsDefinition);
|
|
882
919
|
|
|
883
920
|
exports.registerTabs = registerTabs;
|
|
884
921
|
exports.tabsDefinition = tabsDefinition;
|