@memberjunction/ng-tabstrip 1.4.0 → 1.4.1
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.
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ChangeDetectorRef } from '@angular/core';
|
|
1
|
+
import { ChangeDetectorRef, ElementRef } from '@angular/core';
|
|
2
2
|
import { MJTabBase } from '../tab.base';
|
|
3
3
|
import { MJTabStripComponent } from '../tab-strip/tab-strip.component';
|
|
4
4
|
import * as i0 from "@angular/core";
|
|
@@ -8,12 +8,28 @@ import * as i0 from "@angular/core";
|
|
|
8
8
|
export declare class MJTabComponent extends MJTabBase {
|
|
9
9
|
private tabstrip;
|
|
10
10
|
private cdr;
|
|
11
|
+
elementRef: ElementRef;
|
|
11
12
|
private _tabSelected;
|
|
12
13
|
/**
|
|
13
14
|
* Determines if the tab is currently selected or not. This is set by the TabStrip component automatically when the SelectedTabIndex is set, do not set this directly.
|
|
14
15
|
*/
|
|
15
16
|
get TabSelected(): boolean;
|
|
16
17
|
set TabSelected(value: boolean);
|
|
18
|
+
private _visible;
|
|
19
|
+
get Visible(): boolean;
|
|
20
|
+
set Visible(value: boolean);
|
|
21
|
+
private _name;
|
|
22
|
+
get Name(): string;
|
|
23
|
+
set Name(value: string);
|
|
24
|
+
private _id;
|
|
25
|
+
get ID(): any;
|
|
26
|
+
set ID(value: any);
|
|
27
|
+
private _props;
|
|
28
|
+
/**
|
|
29
|
+
* A property bag that can be used to store any additional properties that you want to associate with this tab.
|
|
30
|
+
*/
|
|
31
|
+
get Props(): any;
|
|
32
|
+
set Props(value: any);
|
|
17
33
|
/**
|
|
18
34
|
* Determines if the tab can be closed by a user, or not. Defaults to false.
|
|
19
35
|
*/
|
|
@@ -22,7 +38,7 @@ export declare class MJTabComponent extends MJTabBase {
|
|
|
22
38
|
* Returns a reference to the tab strip that this tab belongs to.
|
|
23
39
|
*/
|
|
24
40
|
get TabStrip(): MJTabStripComponent;
|
|
25
|
-
constructor(tabstrip: MJTabStripComponent, cdr: ChangeDetectorRef);
|
|
41
|
+
constructor(tabstrip: MJTabStripComponent, cdr: ChangeDetectorRef, elementRef: ElementRef);
|
|
26
42
|
/**
|
|
27
43
|
* Event handler for when this tab is clicked to select it, generally not a great idea to call this directly, but it is possible to call directly to simulate a click.
|
|
28
44
|
* The preferred approach is to set the SelectedTabIndex property on the TabStrip component directly.
|
|
@@ -33,6 +49,6 @@ export declare class MJTabComponent extends MJTabBase {
|
|
|
33
49
|
*/
|
|
34
50
|
closeTab($event: MouseEvent): void;
|
|
35
51
|
handleContextMenu($event: MouseEvent): void;
|
|
36
|
-
static ɵfac: i0.ɵɵFactoryDeclaration<MJTabComponent, [{ host: true; }, null]>;
|
|
37
|
-
static ɵcmp: i0.ɵɵComponentDeclaration<MJTabComponent, "mj-tab", never, { "TabSelected": { "alias": "TabSelected"; "required": false; }; "TabCloseable": { "alias": "TabCloseable"; "required": false; }; }, {}, never, ["*"], false, never>;
|
|
52
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<MJTabComponent, [{ host: true; }, null, null]>;
|
|
53
|
+
static ɵcmp: i0.ɵɵComponentDeclaration<MJTabComponent, "mj-tab", never, { "TabSelected": { "alias": "TabSelected"; "required": false; }; "Visible": { "alias": "Visible"; "required": false; }; "Name": { "alias": "Name"; "required": false; }; "ID": { "alias": "ID"; "required": false; }; "Props": { "alias": "Props"; "required": false; }; "TabCloseable": { "alias": "TabCloseable"; "required": false; }; }, {}, never, ["*"], false, never>;
|
|
38
54
|
}
|
|
@@ -26,17 +26,59 @@ export class MJTabComponent extends MJTabBase {
|
|
|
26
26
|
this._tabSelected = value;
|
|
27
27
|
this.cdr.detectChanges(); // Manually trigger change detection to update the view
|
|
28
28
|
}
|
|
29
|
+
get Visible() {
|
|
30
|
+
return this._visible;
|
|
31
|
+
}
|
|
32
|
+
set Visible(value) {
|
|
33
|
+
this._visible = value;
|
|
34
|
+
// whenever the visible property changes we need to set the display style to none if it is not visible and make sure
|
|
35
|
+
// we're not selected and set to tab index of 0 if we're selected
|
|
36
|
+
// Step 1 - get the elementRef and set our display to none
|
|
37
|
+
if (!this._visible)
|
|
38
|
+
this.elementRef.nativeElement.style.display = value ? "" : "none";
|
|
39
|
+
else
|
|
40
|
+
this.elementRef.nativeElement.style.display = "";
|
|
41
|
+
// Step 2 - if we're not visible, make sure we're not selected
|
|
42
|
+
if (!this._visible)
|
|
43
|
+
this.tabstrip.SelectedTabIndex = 0;
|
|
44
|
+
}
|
|
45
|
+
get Name() {
|
|
46
|
+
return this._name;
|
|
47
|
+
}
|
|
48
|
+
set Name(value) {
|
|
49
|
+
this._name = value;
|
|
50
|
+
}
|
|
51
|
+
get ID() {
|
|
52
|
+
return this._id;
|
|
53
|
+
}
|
|
54
|
+
set ID(value) {
|
|
55
|
+
this._id = value;
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* A property bag that can be used to store any additional properties that you want to associate with this tab.
|
|
59
|
+
*/
|
|
60
|
+
get Props() {
|
|
61
|
+
return this._props;
|
|
62
|
+
}
|
|
63
|
+
set Props(value) {
|
|
64
|
+
this._props = value;
|
|
65
|
+
}
|
|
29
66
|
/**
|
|
30
67
|
* Returns a reference to the tab strip that this tab belongs to.
|
|
31
68
|
*/
|
|
32
69
|
get TabStrip() {
|
|
33
70
|
return this.tabstrip;
|
|
34
71
|
}
|
|
35
|
-
constructor(tabstrip, cdr) {
|
|
72
|
+
constructor(tabstrip, cdr, elementRef) {
|
|
36
73
|
super();
|
|
37
74
|
this.tabstrip = tabstrip;
|
|
38
75
|
this.cdr = cdr;
|
|
76
|
+
this.elementRef = elementRef;
|
|
39
77
|
this._tabSelected = false;
|
|
78
|
+
this._visible = true;
|
|
79
|
+
this._name = "";
|
|
80
|
+
this._id = null;
|
|
81
|
+
this._props = null;
|
|
40
82
|
/**
|
|
41
83
|
* Determines if the tab can be closed by a user, or not. Defaults to false.
|
|
42
84
|
*/
|
|
@@ -61,8 +103,8 @@ export class MJTabComponent extends MJTabBase {
|
|
|
61
103
|
this.tabstrip.handleTabContextMenu($event, this);
|
|
62
104
|
}
|
|
63
105
|
}
|
|
64
|
-
MJTabComponent.ɵfac = function MJTabComponent_Factory(t) { return new (t || MJTabComponent)(i0.ɵɵdirectiveInject(i1.MJTabStripComponent, 1), i0.ɵɵdirectiveInject(i0.ChangeDetectorRef)); };
|
|
65
|
-
MJTabComponent.ɵcmp = /*@__PURE__*/ i0.ɵɵdefineComponent({ type: MJTabComponent, selectors: [["mj-tab"]], inputs: { TabSelected: "TabSelected", TabCloseable: "TabCloseable" }, features: [i0.ɵɵInheritDefinitionFeature], ngContentSelectors: _c1, decls: 3, vars: 4, consts: [[1, "single-tab", 3, "ngClass", "click", "contextmenu"], ["class", "tab-close-button", 3, "click", 4, "ngIf"], [1, "tab-close-button", 3, "click"]], template: function MJTabComponent_Template(rf, ctx) { if (rf & 1) {
|
|
106
|
+
MJTabComponent.ɵfac = function MJTabComponent_Factory(t) { return new (t || MJTabComponent)(i0.ɵɵdirectiveInject(i1.MJTabStripComponent, 1), i0.ɵɵdirectiveInject(i0.ChangeDetectorRef), i0.ɵɵdirectiveInject(i0.ElementRef)); };
|
|
107
|
+
MJTabComponent.ɵcmp = /*@__PURE__*/ i0.ɵɵdefineComponent({ type: MJTabComponent, selectors: [["mj-tab"]], inputs: { TabSelected: "TabSelected", Visible: "Visible", Name: "Name", ID: "ID", Props: "Props", TabCloseable: "TabCloseable" }, features: [i0.ɵɵInheritDefinitionFeature], ngContentSelectors: _c1, decls: 3, vars: 4, consts: [[1, "single-tab", 3, "ngClass", "click", "contextmenu"], ["class", "tab-close-button", 3, "click", 4, "ngIf"], [1, "tab-close-button", 3, "click"]], template: function MJTabComponent_Template(rf, ctx) { if (rf & 1) {
|
|
66
108
|
i0.ɵɵprojectionDef();
|
|
67
109
|
i0.ɵɵelementStart(0, "div", 0);
|
|
68
110
|
i0.ɵɵlistener("click", function MJTabComponent_Template_div_click_0_listener() { return ctx.selectTab(); })("contextmenu", function MJTabComponent_Template_div_contextmenu_0_listener($event) { return ctx.handleContextMenu($event); });
|
|
@@ -79,7 +121,15 @@ MJTabComponent.ɵcmp = /*@__PURE__*/ i0.ɵɵdefineComponent({ type: MJTabCompone
|
|
|
79
121
|
args: [{ selector: 'mj-tab', template: "<div class=\"single-tab\" [ngClass]=\"{'single-tab-selected': TabSelected}\" (click)=\"selectTab()\" (contextmenu)=\"handleContextMenu($event)\">\n <ng-content><!--CONTENT PROJECTION GOES HERE--></ng-content>\n <span *ngIf=\"TabCloseable\" class=\"tab-close-button\" (click)=\"closeTab($event)\" >\u2716</span>\n</div>", styles: ["\n .single-tab {\n flex: 0 0 auto; /* Prevent tabs from shrinking */\n cursor: pointer;\n height: 26px;\n margin-right: 1px;\n padding-left: 10px;\n padding-right: 10px;\n padding-top: 5px;\n border-radius: 8px 8px 0 0;\n border-top: solid 1px #D5D8E5;;\n border-left: solid 1px #D5D8E5;;\n border-right: solid 1px #D5D8E5;;\n border-bottom: 0;\n background-color: #D5D8E5;\n font-size: 14px;\n }\n .single-tab:hover {\n color: #bb443c;\n }\n .single-tab-selected {\n background-color: #F5F6FA;\n font-weight: bold;\n }\n \n .tab-close-button {\n cursor: pointer;\n margin-left: 10px;\n padding: 2px;\n font-size: 12px;\n border-radius: 10px;\n color: black;\n }\n .tab-close-button:hover {\n background-color: lightgray;\n }\n "] }]
|
|
80
122
|
}], () => [{ type: i1.MJTabStripComponent, decorators: [{
|
|
81
123
|
type: Host
|
|
82
|
-
}] }, { type: i0.ChangeDetectorRef }], { TabSelected: [{
|
|
124
|
+
}] }, { type: i0.ChangeDetectorRef }, { type: i0.ElementRef }], { TabSelected: [{
|
|
125
|
+
type: Input
|
|
126
|
+
}], Visible: [{
|
|
127
|
+
type: Input
|
|
128
|
+
}], Name: [{
|
|
129
|
+
type: Input
|
|
130
|
+
}], ID: [{
|
|
131
|
+
type: Input
|
|
132
|
+
}], Props: [{
|
|
83
133
|
type: Input
|
|
84
134
|
}], TabCloseable: [{
|
|
85
135
|
type: Input
|
|
@@ -36,6 +36,13 @@ export declare class MJTabStripComponent implements AfterContentInit, AfterConte
|
|
|
36
36
|
*/
|
|
37
37
|
get SelectedTabIndex(): number;
|
|
38
38
|
set SelectedTabIndex(index: number);
|
|
39
|
+
/**
|
|
40
|
+
* This method will attempt to set the current tab by name. If the tab is found, it will be selected and the method will return the tab object. If the tab is not found, the method will return undefined.
|
|
41
|
+
* @param tabName
|
|
42
|
+
* @returns
|
|
43
|
+
*/
|
|
44
|
+
SelectTabByName(tabName: string): MJTabComponent | undefined;
|
|
45
|
+
GetTabByName(tabName: string): MJTabComponent | undefined;
|
|
39
46
|
protected innerRefreshTabVisibility(index: number): void;
|
|
40
47
|
/**
|
|
41
48
|
* This event is fired before a tab is selected. If you set cancel to true, the tab will not be selected.
|
|
@@ -57,12 +64,22 @@ export declare class MJTabStripComponent implements AfterContentInit, AfterConte
|
|
|
57
64
|
* This event is fired when a tab is right-clicked and the context menu event from the tab header fires.
|
|
58
65
|
*/
|
|
59
66
|
TabContextMenu: EventEmitter<TabContextMenuEvent>;
|
|
67
|
+
/**
|
|
68
|
+
* This event is fired whenever the tab control is scrolled left or right. This event can be invoked either due to a user clicking on the left/right buttons or by calling the scrollLeft/scrollRight methods, or by
|
|
69
|
+
* the ScrollIntoView method being called.
|
|
70
|
+
*/
|
|
71
|
+
TabScrolled: EventEmitter<any>;
|
|
60
72
|
tabs: QueryList<MJTabComponent>;
|
|
61
73
|
tabBodies: QueryList<MJTabBodyComponent>;
|
|
62
74
|
private _viewInitialized;
|
|
63
75
|
ngAfterViewInit(): void;
|
|
64
76
|
ngAfterContentInit(): void;
|
|
65
77
|
ngAfterContentChecked(): void;
|
|
78
|
+
/**
|
|
79
|
+
* Call this method if you are ever dynamically adding or removing tabs from the component over time using @if or *ngIf or other similar methods. This will force the tab strip to
|
|
80
|
+
* re-evaluate the tabs and tab bodies and update the display accordingly.
|
|
81
|
+
*/
|
|
82
|
+
RefreshTabs(): void;
|
|
66
83
|
protected syncTabIndexes(): void;
|
|
67
84
|
/**
|
|
68
85
|
* Returns a read-only (copy) of the tabs in this tab strip.
|
|
@@ -81,10 +98,19 @@ export declare class MJTabStripComponent implements AfterContentInit, AfterConte
|
|
|
81
98
|
showLeftButton: boolean;
|
|
82
99
|
showRightButton: boolean;
|
|
83
100
|
onResize(event: any): void;
|
|
84
|
-
checkTabScrollButtons(): void;
|
|
85
|
-
scrollTabHeader(scrollAmount: number): void;
|
|
101
|
+
protected checkTabScrollButtons(): void;
|
|
102
|
+
protected scrollTabHeader(scrollAmount: number): void;
|
|
103
|
+
/**
|
|
104
|
+
* This property determines how many pixels to scroll when the scrollLeft or scrollRight methods are called.
|
|
105
|
+
*/
|
|
106
|
+
ScrollAmount: number;
|
|
86
107
|
scrollLeft(): void;
|
|
87
108
|
scrollRight(): void;
|
|
109
|
+
/**
|
|
110
|
+
* This method will scroll the specified tab index into view if it is not currently visible in the tab strip.
|
|
111
|
+
* @param tabIndex
|
|
112
|
+
*/
|
|
113
|
+
scrollIntoView(tabIndex: number): void;
|
|
88
114
|
static ɵfac: i0.ɵɵFactoryDeclaration<MJTabStripComponent, never>;
|
|
89
|
-
static ɵcmp: i0.ɵɵComponentDeclaration<MJTabStripComponent, "mj-tabstrip", never, { "FillWidth": { "alias": "FillWidth"; "required": false; }; "FillHeight": { "alias": "FillHeight"; "required": false; }; "SelectedTabIndex": { "alias": "SelectedTabIndex"; "required": false; }; }, { "BeforeTabSelected": "BeforeTabSelected"; "TabSelected": "TabSelected"; "BeforeTabClosed": "BeforeTabClosed"; "TabClosed": "TabClosed"; "TabContextMenu": "TabContextMenu"; }, ["tabs", "tabBodies"], ["mj-tab", "mj-tab-body"], false, never>;
|
|
115
|
+
static ɵcmp: i0.ɵɵComponentDeclaration<MJTabStripComponent, "mj-tabstrip", never, { "FillWidth": { "alias": "FillWidth"; "required": false; }; "FillHeight": { "alias": "FillHeight"; "required": false; }; "SelectedTabIndex": { "alias": "SelectedTabIndex"; "required": false; }; "ScrollAmount": { "alias": "ScrollAmount"; "required": false; }; }, { "BeforeTabSelected": "BeforeTabSelected"; "TabSelected": "TabSelected"; "BeforeTabClosed": "BeforeTabClosed"; "TabClosed": "TabClosed"; "TabContextMenu": "TabContextMenu"; "TabScrolled": "TabScrolled"; }, ["tabs", "tabBodies"], ["mj-tab", "mj-tab-body"], false, never>;
|
|
90
116
|
}
|
|
@@ -78,9 +78,18 @@ export class MJTabStripComponent {
|
|
|
78
78
|
* This event is fired when a tab is right-clicked and the context menu event from the tab header fires.
|
|
79
79
|
*/
|
|
80
80
|
this.TabContextMenu = new EventEmitter();
|
|
81
|
+
/**
|
|
82
|
+
* This event is fired whenever the tab control is scrolled left or right. This event can be invoked either due to a user clicking on the left/right buttons or by calling the scrollLeft/scrollRight methods, or by
|
|
83
|
+
* the ScrollIntoView method being called.
|
|
84
|
+
*/
|
|
85
|
+
this.TabScrolled = new EventEmitter();
|
|
81
86
|
this._viewInitialized = false;
|
|
82
87
|
this.showLeftButton = false;
|
|
83
88
|
this.showRightButton = false;
|
|
89
|
+
/**
|
|
90
|
+
* This property determines how many pixels to scroll when the scrollLeft or scrollRight methods are called.
|
|
91
|
+
*/
|
|
92
|
+
this.ScrollAmount = 150;
|
|
84
93
|
}
|
|
85
94
|
/**
|
|
86
95
|
* The index of the selected tab. You can get/set this value and it will change the displayed tab.
|
|
@@ -89,6 +98,7 @@ export class MJTabStripComponent {
|
|
|
89
98
|
return this._selectedTabIndex;
|
|
90
99
|
}
|
|
91
100
|
set SelectedTabIndex(index) {
|
|
101
|
+
var _a;
|
|
92
102
|
// check to make sure that the new index is different from the current index and only do the work here if it is different
|
|
93
103
|
MJTabStripComponent.OutputDebugMessage(`MJTabStripComponent.SelectedTabIndex(${index})`);
|
|
94
104
|
if (index !== this._selectedTabIndex) {
|
|
@@ -98,23 +108,45 @@ export class MJTabStripComponent {
|
|
|
98
108
|
body: index !== null && this.tabBodies ? this.tabBodies.toArray()[index] : null,
|
|
99
109
|
cancel: false
|
|
100
110
|
};
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
+
if ((_a = props.tab) === null || _a === void 0 ? void 0 : _a.Visible) {
|
|
112
|
+
this.BeforeTabSelected.emit(props);
|
|
113
|
+
if (!props.cancel) {
|
|
114
|
+
this._selectedTabIndex = index;
|
|
115
|
+
this.innerRefreshTabVisibility(index);
|
|
116
|
+
const afterProps = {
|
|
117
|
+
index: index,
|
|
118
|
+
tab: props.tab,
|
|
119
|
+
body: props.body
|
|
120
|
+
};
|
|
121
|
+
this.TabSelected.emit(afterProps);
|
|
122
|
+
}
|
|
111
123
|
}
|
|
124
|
+
else
|
|
125
|
+
throw new Error(`Tab index ${index} is not visible and cannot be selected.`);
|
|
112
126
|
}
|
|
113
127
|
else {
|
|
114
128
|
// always do this even if we're not firing event since we're already on the right tab
|
|
115
129
|
this.innerRefreshTabVisibility(index);
|
|
116
130
|
}
|
|
117
131
|
}
|
|
132
|
+
/**
|
|
133
|
+
* This method will attempt to set the current tab by name. If the tab is found, it will be selected and the method will return the tab object. If the tab is not found, the method will return undefined.
|
|
134
|
+
* @param tabName
|
|
135
|
+
* @returns
|
|
136
|
+
*/
|
|
137
|
+
SelectTabByName(tabName) {
|
|
138
|
+
const tab = this.GetTabByName(tabName);
|
|
139
|
+
if (tab) {
|
|
140
|
+
if (tab.Visible)
|
|
141
|
+
this.SelectedTabIndex = tab.index;
|
|
142
|
+
else
|
|
143
|
+
throw new Error(`Tab ${tabName} is not visible and cannot be selected.`);
|
|
144
|
+
}
|
|
145
|
+
return tab;
|
|
146
|
+
}
|
|
147
|
+
GetTabByName(tabName) {
|
|
148
|
+
return this.tabs.find(t => { var _a; return ((_a = t.Name) === null || _a === void 0 ? void 0 : _a.trim().toLowerCase()) === tabName.trim().toLowerCase(); });
|
|
149
|
+
}
|
|
118
150
|
innerRefreshTabVisibility(index) {
|
|
119
151
|
Promise.resolve().then(() => {
|
|
120
152
|
var _a, _b;
|
|
@@ -142,6 +174,15 @@ export class MJTabStripComponent {
|
|
|
142
174
|
this.syncTabIndexes();
|
|
143
175
|
this.checkTabScrollButtons();
|
|
144
176
|
}
|
|
177
|
+
/**
|
|
178
|
+
* Call this method if you are ever dynamically adding or removing tabs from the component over time using @if or *ngIf or other similar methods. This will force the tab strip to
|
|
179
|
+
* re-evaluate the tabs and tab bodies and update the display accordingly.
|
|
180
|
+
*/
|
|
181
|
+
RefreshTabs() {
|
|
182
|
+
this.cdr.detectChanges();
|
|
183
|
+
this.syncTabIndexes();
|
|
184
|
+
this.innerRefreshTabVisibility(this.SelectedTabIndex);
|
|
185
|
+
}
|
|
145
186
|
syncTabIndexes() {
|
|
146
187
|
if (!this._viewInitialized)
|
|
147
188
|
return; // don't do anything until the view is initialized
|
|
@@ -243,6 +284,7 @@ export class MJTabStripComponent {
|
|
|
243
284
|
const curLeft = style.left ? parseInt(style.left) : 0;
|
|
244
285
|
style.left = (curLeft + scrollAmount) + 'px';
|
|
245
286
|
this.checkTabScrollButtons(); // can do immediately because the above is direct DOM manipulation so the effect is immediate
|
|
287
|
+
this.TabScrolled.emit();
|
|
246
288
|
}
|
|
247
289
|
}
|
|
248
290
|
scrollLeft() {
|
|
@@ -251,6 +293,39 @@ export class MJTabStripComponent {
|
|
|
251
293
|
scrollRight() {
|
|
252
294
|
this.scrollTabHeader(-150);
|
|
253
295
|
}
|
|
296
|
+
/**
|
|
297
|
+
* This method will scroll the specified tab index into view if it is not currently visible in the tab strip.
|
|
298
|
+
* @param tabIndex
|
|
299
|
+
*/
|
|
300
|
+
scrollIntoView(tabIndex) {
|
|
301
|
+
// In this method, we need to calculate the current left position of the specified tab,
|
|
302
|
+
// if it is not visible we need to scroll left or scroll right sufficiently in order to ensure that the tab specified is visible
|
|
303
|
+
// we do NOT change tab selection, the caller can do that separately if they want to
|
|
304
|
+
if (tabIndex >= 0 && tabIndex < this.tabs.length) {
|
|
305
|
+
const tab = this.tabs.toArray()[tabIndex];
|
|
306
|
+
if (tab) {
|
|
307
|
+
const tabElement = tab.elementRef.nativeElement;
|
|
308
|
+
if (tabElement) {
|
|
309
|
+
const tabLeft = tabElement.offsetLeft;
|
|
310
|
+
const tabRight = tabLeft + tabElement.offsetWidth;
|
|
311
|
+
const container = this.tabInnerContainer.nativeElement;
|
|
312
|
+
const containerLeft = container.offsetLeft;
|
|
313
|
+
const containerRight = containerLeft + container.offsetWidth;
|
|
314
|
+
if (tabLeft < containerLeft) {
|
|
315
|
+
// tab is off to the left, scroll left
|
|
316
|
+
this.scrollTabHeader(tabLeft - containerLeft);
|
|
317
|
+
}
|
|
318
|
+
else if (tabRight > containerRight) {
|
|
319
|
+
// tab is off to the right, scroll right
|
|
320
|
+
this.scrollTabHeader(tabRight - containerRight);
|
|
321
|
+
}
|
|
322
|
+
else {
|
|
323
|
+
// tab is already visible, do nothing
|
|
324
|
+
}
|
|
325
|
+
}
|
|
326
|
+
}
|
|
327
|
+
}
|
|
328
|
+
}
|
|
254
329
|
}
|
|
255
330
|
MJTabStripComponent.OutputDebugInfo = false;
|
|
256
331
|
MJTabStripComponent.ɵfac = function MJTabStripComponent_Factory(t) { return new (t || MJTabStripComponent)(i0.ɵɵdirectiveInject(i0.ChangeDetectorRef)); };
|
|
@@ -268,7 +343,7 @@ MJTabStripComponent.ɵcmp = /*@__PURE__*/ i0.ɵɵdefineComponent({ type: MJTabSt
|
|
|
268
343
|
i0.ɵɵqueryRefresh(_t = i0.ɵɵloadQuery()) && (ctx.tabInnerContainer = _t.first);
|
|
269
344
|
} }, hostBindings: function MJTabStripComponent_HostBindings(rf, ctx) { if (rf & 1) {
|
|
270
345
|
i0.ɵɵlistener("resize", function MJTabStripComponent_resize_HostBindingHandler($event) { return ctx.onResize($event); }, false, i0.ɵɵresolveWindow);
|
|
271
|
-
} }, inputs: { FillWidth: "FillWidth", FillHeight: "FillHeight", SelectedTabIndex: "SelectedTabIndex" }, outputs: { BeforeTabSelected: "BeforeTabSelected", TabSelected: "TabSelected", BeforeTabClosed: "BeforeTabClosed", TabClosed: "TabClosed", TabContextMenu: "TabContextMenu" }, ngContentSelectors: _c2, decls: 9, vars: 6, consts: [["mjFillContainer", "", 1, "tabstrip-container", 3, "fillWidth", "fillHeight"], [1, "tab-header-outer"], ["class", "tab-scroll-button tab-scroll-button-left", 3, "click", 4, "ngIf"], [1, "tab-header-inner"], ["tabInnerContainer", ""], ["class", "tab-scroll-button tab-scroll-button-right", 3, "click", 4, "ngIf"], ["mjFillContainer", "", 1, "tab-bodies", 3, "fillWidth", "fillHeight"], [1, "tab-scroll-button", "tab-scroll-button-left", 3, "click"], [1, "fa-solid", "fa-caret-left"], [1, "tab-scroll-button", "tab-scroll-button-right", 3, "click"], [1, "fa-solid", "fa-caret-right"]], template: function MJTabStripComponent_Template(rf, ctx) { if (rf & 1) {
|
|
346
|
+
} }, inputs: { FillWidth: "FillWidth", FillHeight: "FillHeight", SelectedTabIndex: "SelectedTabIndex", ScrollAmount: "ScrollAmount" }, outputs: { BeforeTabSelected: "BeforeTabSelected", TabSelected: "TabSelected", BeforeTabClosed: "BeforeTabClosed", TabClosed: "TabClosed", TabContextMenu: "TabContextMenu", TabScrolled: "TabScrolled" }, ngContentSelectors: _c2, decls: 9, vars: 6, consts: [["mjFillContainer", "", 1, "tabstrip-container", 3, "fillWidth", "fillHeight"], [1, "tab-header-outer"], ["class", "tab-scroll-button tab-scroll-button-left", 3, "click", 4, "ngIf"], [1, "tab-header-inner"], ["tabInnerContainer", ""], ["class", "tab-scroll-button tab-scroll-button-right", 3, "click", 4, "ngIf"], ["mjFillContainer", "", 1, "tab-bodies", 3, "fillWidth", "fillHeight"], [1, "tab-scroll-button", "tab-scroll-button-left", 3, "click"], [1, "fa-solid", "fa-caret-left"], [1, "tab-scroll-button", "tab-scroll-button-right", 3, "click"], [1, "fa-solid", "fa-caret-right"]], template: function MJTabStripComponent_Template(rf, ctx) { if (rf & 1) {
|
|
272
347
|
i0.ɵɵprojectionDef(_c1);
|
|
273
348
|
i0.ɵɵelementStart(0, "div", 0)(1, "div", 1);
|
|
274
349
|
i0.ɵɵtemplate(2, MJTabStripComponent_div_2_Template, 2, 0, "div", 2);
|
|
@@ -308,6 +383,8 @@ MJTabStripComponent.ɵcmp = /*@__PURE__*/ i0.ɵɵdefineComponent({ type: MJTabSt
|
|
|
308
383
|
type: Output
|
|
309
384
|
}], TabContextMenu: [{
|
|
310
385
|
type: Output
|
|
386
|
+
}], TabScrolled: [{
|
|
387
|
+
type: Output
|
|
311
388
|
}], tabs: [{
|
|
312
389
|
type: ContentChildren,
|
|
313
390
|
args: [MJTabComponent]
|
|
@@ -320,5 +397,7 @@ MJTabStripComponent.ɵcmp = /*@__PURE__*/ i0.ɵɵdefineComponent({ type: MJTabSt
|
|
|
320
397
|
}], onResize: [{
|
|
321
398
|
type: HostListener,
|
|
322
399
|
args: ['window:resize', ['$event']]
|
|
400
|
+
}], ScrollAmount: [{
|
|
401
|
+
type: Input
|
|
323
402
|
}] }); })();
|
|
324
403
|
(() => { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassDebugInfo(MJTabStripComponent, { className: "MJTabStripComponent", filePath: "src/lib/tab-strip/tab-strip.component.ts", lineNumber: 34 }); })();
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@memberjunction/ng-tabstrip",
|
|
3
|
-
"version": "1.4.
|
|
3
|
+
"version": "1.4.1",
|
|
4
4
|
"description": "MemberJunction: Very simple tab strip component used in the MJ Explorer app and reusable anywhere else in an Angular project.",
|
|
5
5
|
"main": "./dist/public-api.js",
|
|
6
6
|
"typings": "./dist/public-api.d.ts",
|
|
@@ -23,8 +23,8 @@
|
|
|
23
23
|
"@angular/core": "~17.2.2"
|
|
24
24
|
},
|
|
25
25
|
"dependencies": {
|
|
26
|
-
"@memberjunction/ng-container-directives": "~1.4.
|
|
27
|
-
"@memberjunction/ng-shared": "~1.4.
|
|
26
|
+
"@memberjunction/ng-container-directives": "~1.4.1",
|
|
27
|
+
"@memberjunction/ng-shared": "~1.4.1",
|
|
28
28
|
"tslib": "^2.3.0"
|
|
29
29
|
},
|
|
30
30
|
"sideEffects": false
|