jsl-ui 9.28.7 → 10.0.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.
- package/docs/AutoSuggestComponent.md +17 -0
- package/docs/ButtonComponent.md +14 -0
- package/docs/CheckBoxComponent.md +12 -0
- package/docs/DateComponent.md +12 -0
- package/docs/DateRangeComponent.md +13 -0
- package/docs/DateTimeComponent.md +13 -0
- package/docs/DialogComponent.md +15 -0
- package/docs/ExpanderComponent.md +13 -0
- package/docs/FormComponent.md +15 -0
- package/docs/FormFieldComponent.md +15 -0
- package/docs/GridComponent.md +19 -0
- package/docs/InputComponent.md +15 -0
- package/docs/IntervalComponent.md +13 -0
- package/docs/LoadingComponent.md +12 -0
- package/docs/NavigationComponent.md +17 -0
- package/docs/Notification.md +14 -0
- package/docs/NotificationComponent.md +13 -0
- package/docs/NumberComponent.md +12 -0
- package/docs/OverlayComponent.md +12 -0
- package/docs/ProgressComponent.md +12 -0
- package/docs/README.md +24 -0
- package/docs/RibbonMenuComponent.md +14 -0
- package/docs/SelectComponent.md +15 -0
- package/docs/SplitterComponent.md +14 -0
- package/docs/StackPanelComponent.md +13 -0
- package/docs/TabsComponent.md +16 -0
- package/docs/TimeComponent.md +13 -0
- package/docs/TreeViewComponent.md +16 -0
- package/examples/showcase/checks-and-expanders.ts +163 -0
- package/examples/showcase/cultures.ts +39 -0
- package/examples/showcase/dates.ts +182 -0
- package/examples/showcase/dialogs.ts +184 -0
- package/examples/showcase/feedback-and-navigation.ts +174 -0
- package/examples/showcase/fields.ts +178 -0
- package/examples/showcase/fonts/Jost-Variable.ttf +0 -0
- package/examples/showcase/fonts/OFL-Jost.txt +93 -0
- package/examples/showcase/grids.ts +150 -0
- package/examples/showcase/index.html +60 -0
- package/examples/showcase/layout-and-navigation.ts +47 -0
- package/examples/showcase/nivona.css +98 -0
- package/examples/showcase/selects.ts +158 -0
- package/examples/showcase/showcase.css +231 -0
- package/examples/showcase/showcase.ts +214 -0
- package/examples/showcase/tabs.ts +161 -0
- package/examples/showcase/themes.css +83 -0
- package/examples/showcase/themes.ts +54 -0
- package/lib/components/IntervalComponent.d.ts +5 -0
- package/lib/components/IntervalComponent.js +29 -13
- package/lib/components/auto-suggest/AutoSuggestComponent.d.ts +11 -9
- package/lib/components/auto-suggest/AutoSuggestComponent.js +25 -38
- package/lib/components/button/ButtonComponent.d.ts +30 -1
- package/lib/components/button/ButtonComponent.js +85 -4
- package/lib/components/checkbox/CheckBoxComponent.d.ts +11 -1
- package/lib/components/checkbox/CheckBoxComponent.js +66 -56
- package/lib/components/checkbox/CheckBoxStyle.scss +72 -85
- package/lib/components/date/DateComponent.d.ts +10 -0
- package/lib/components/date/DateComponent.js +92 -44
- package/lib/components/date-range/DateRangeComponent.d.ts +14 -3
- package/lib/components/date-range/DateRangeComponent.js +96 -86
- package/lib/components/date-range/DateRangeStyle.scss +35 -11
- package/lib/components/date-time/DateTimeComponent.d.ts +8 -0
- package/lib/components/date-time/DateTimeComponent.js +64 -23
- package/lib/components/date-time/DateTimeStyle.scss +10 -7
- package/lib/components/dialog/DialogComponent.d.ts +21 -7
- package/lib/components/dialog/DialogComponent.js +179 -122
- package/lib/components/expander/ExpanderComponent.d.ts +15 -1
- package/lib/components/expander/ExpanderComponent.js +85 -64
- package/lib/components/expander/ExpanderStyle.scss +61 -47
- package/lib/components/form-field/FormFieldComponent.d.ts +45 -15
- package/lib/components/form-field/FormFieldComponent.js +249 -96
- package/lib/components/form-field/FormFieldStyle.scss +36 -87
- package/lib/components/form-field/create-control.d.ts +7 -0
- package/lib/components/form-field/create-control.js +48 -0
- package/lib/components/input/InputComponent.d.ts +18 -1
- package/lib/components/input/InputComponent.js +68 -93
- package/lib/components/loading/LoadingComponent.d.ts +9 -2
- package/lib/components/loading/LoadingComponent.js +13 -12
- package/lib/components/loading/LoadingStyle.css +19 -29
- package/lib/components/navigation/NavigationComponent.d.ts +34 -10
- package/lib/components/navigation/NavigationComponent.js +261 -33
- package/lib/components/navigation/NavigationStyle.scss +62 -226
- package/lib/components/notification/Notification.d.ts +37 -4
- package/lib/components/notification/Notification.js +160 -41
- package/lib/components/notification/Notification.scss +103 -19
- package/lib/components/number/NumberComponent.d.ts +16 -2
- package/lib/components/number/NumberComponent.js +54 -53
- package/lib/components/overlay/OverlayComponent.d.ts +13 -7
- package/lib/components/overlay/OverlayComponent.js +46 -114
- package/lib/components/overlay/overlay.css +18 -57
- package/lib/components/progress/ProgressComponent.d.ts +1 -0
- package/lib/components/progress/ProgressComponent.js +6 -6
- package/lib/components/progress/ProgressStyle.scss +5 -15
- package/lib/components/ribbon-menu/RibbonMenuComponent.js +2 -2
- package/lib/components/ribbon-menu/RibbonMenuStyle.scss +6 -76
- package/lib/components/select/SelectComponent.d.ts +33 -3
- package/lib/components/select/SelectComponent.js +312 -278
- package/lib/components/select/SelectDDAreaComponent.d.ts +13 -7
- package/lib/components/select/SelectDDAreaComponent.js +215 -256
- package/lib/components/select/SelectStyle.scss +204 -186
- package/lib/components/slider/nouislider.css +40 -54
- package/lib/components/stack-panel/SplitterComponent.d.ts +19 -3
- package/lib/components/stack-panel/SplitterComponent.js +94 -111
- package/lib/components/stack-panel/SplitterStyle.scss +9 -45
- package/lib/components/stack-panel/StackPanelComponent.js +3 -3
- package/lib/components/stack-panel/StackPanelStyle.scss +10 -52
- package/lib/components/tabs/TabsComponent.d.ts +17 -1
- package/lib/components/tabs/TabsComponent.js +247 -123
- package/lib/components/tabs/TabsStyle.scss +138 -75
- package/lib/components/time/TimeComponent.d.ts +5 -0
- package/lib/components/time/TimeComponent.js +61 -69
- package/lib/components/time/TimeComponent.scss +4 -4
- package/lib/components/tree-view/TreeViewComponent.d.ts +10 -4
- package/lib/components/tree-view/TreeViewComponent.js +65 -32
- package/lib/components/tree-view/TreeViewStyle.scss +12 -96
- package/lib/core/date.d.ts +2 -0
- package/lib/core/date.js +6 -0
- package/lib/core/jq.js +11 -8
- package/lib/grid/slick-default-theme.css +107 -31
- package/lib/grid/slick.creator.js +23 -5
- package/lib/grid/slick.formatters.js +4 -3
- package/lib/grid/slick.grid.css +38 -26
- package/lib/grid/slick.grid.d.ts +1 -0
- package/lib/grid/slick.grid.js +2 -3
- package/lib/grid.css +3413 -454
- package/lib/index.css +2500 -1031
- package/lib/index.css.map +1 -1
- package/lib/index.d.ts +1 -0
- package/lib/index.js +1 -1
- package/lib/index.js.map +1 -1
- package/lib/interaction/moveable.d.ts +1 -0
- package/lib/interaction/moveable.js +8 -0
- package/lib/interaction/resizable.d.ts +1 -0
- package/lib/interaction/resizable.js +9 -0
- package/lib/ui/auto.suggest.css +31 -14
- package/lib/ui/auto.suggest.d.ts +1 -0
- package/lib/ui/auto.suggest.js +88 -18
- package/lib/ui/base.css +2 -48
- package/lib/ui/button.css +134 -0
- package/lib/ui/date-input.css +11 -0
- package/lib/ui/date.picker/css/tiny-date-picker.css +124 -325
- package/lib/ui/date.picker/date-picker-options.js +4 -3
- package/lib/ui/date.picker/lib/date-manip.js +9 -0
- package/lib/ui/date.picker/mode/base-mode.d.ts +2 -1
- package/lib/ui/date.picker/mode/base-mode.js +112 -22
- package/lib/ui/date.picker/mode/dropdown-mode.d.ts +2 -4
- package/lib/ui/date.picker/mode/dropdown-mode.js +29 -42
- package/lib/ui/date.picker/mode/index.d.ts +2 -1
- package/lib/ui/date.picker/mode/modal-mode.d.ts +2 -1
- package/lib/ui/date.picker/mode/modal-mode.js +4 -2
- package/lib/ui/date.picker/mode/permanent-mode.d.ts +2 -1
- package/lib/ui/date.picker/views/day-picker.js +24 -15
- package/lib/ui/date.picker/views/month-picker.js +1 -1
- package/lib/ui/date.picker/views/year-picker.js +3 -2
- package/lib/ui/date.picker.d.ts +2 -1
- package/lib/ui/dialog.css +144 -108
- package/lib/ui/dialog.d.ts +19 -1
- package/lib/ui/dialog.js +178 -60
- package/lib/ui/input.css +35 -0
- package/lib/ui/number.input.js +50 -37
- package/lib/ui/theme.css +28 -0
- package/package.json +12 -8
- package/lib/components/drop-down/DropDownComponent.d.ts +0 -27
- package/lib/components/drop-down/DropDownComponent.js +0 -60
- package/lib/components/expander/OldExpanderStyle.scss +0 -37
- package/lib/ui/drop.down.d.ts +0 -52
- package/lib/ui/drop.down.js +0 -2112
|
@@ -8,183 +8,307 @@ export class TabsComponent {
|
|
|
8
8
|
this.State = { selectedIndex: null };
|
|
9
9
|
this.options = (_a = this.options) !== null && _a !== void 0 ? _a : {};
|
|
10
10
|
this.options.tabs = (_b = this.options.tabs) !== null && _b !== void 0 ? _b : [];
|
|
11
|
-
this.options.selectedIndex = (_c = this.options.selectedIndex) !== null && _c !== void 0 ? _c :
|
|
11
|
+
this.options.selectedIndex = (_c = this.options.selectedIndex) !== null && _c !== void 0 ? _c : this.firstEnabledIndex();
|
|
12
12
|
}
|
|
13
13
|
getActiveTabIndex() {
|
|
14
14
|
var _a;
|
|
15
|
-
|
|
15
|
+
const index = (_a = this.State.selectedIndex) !== null && _a !== void 0 ? _a : this.options.selectedIndex;
|
|
16
|
+
if (index === -1) {
|
|
17
|
+
return -1;
|
|
18
|
+
}
|
|
19
|
+
return this.isValidIndex(index) ? index : this.firstEnabledIndex();
|
|
16
20
|
}
|
|
17
21
|
render() {
|
|
18
|
-
var _a
|
|
22
|
+
var _a;
|
|
19
23
|
this.checkForDuplicateIds();
|
|
20
|
-
|
|
21
|
-
const
|
|
22
|
-
|
|
23
|
-
this.options.tabs[activeIndex].content == null &&
|
|
24
|
-
this.options.tabs[activeIndex].onCreate) {
|
|
25
|
-
this.options.tabs[activeIndex].content = this.options.tabs[activeIndex].onCreate();
|
|
26
|
-
}
|
|
27
|
-
const tabs = [];
|
|
28
|
-
for (let idx = 0; idx < this.options.tabs.length; idx++) {
|
|
29
|
-
if (!this.options.tabs[idx].id) {
|
|
30
|
-
this.options.tabs[idx].id = helper.newDomGuid();
|
|
31
|
-
}
|
|
32
|
-
if (idx === activeIndex) {
|
|
33
|
-
tabs.push({
|
|
34
|
-
tag: "div", attr: {
|
|
35
|
-
class: "tab-content " + ((_b = this.options.contentClass) !== null && _b !== void 0 ? _b : ""),
|
|
36
|
-
style: { "max-height": ((_c = this.options.maxHeight) !== null && _c !== void 0 ? _c : "100%") },
|
|
37
|
-
id: this.options.tabs[idx].id
|
|
38
|
-
},
|
|
39
|
-
children: [this.toNode(this.options.tabs[idx].content)]
|
|
40
|
-
});
|
|
41
|
-
}
|
|
42
|
-
else if (this.options.preserveContent) {
|
|
43
|
-
tabs.push({
|
|
44
|
-
tag: "div", attr: {
|
|
45
|
-
class: "tab-content tab-hidden " + ((_d = this.options.contentClass) !== null && _d !== void 0 ? _d : ""),
|
|
46
|
-
style: { "max-height": ((_e = this.options.maxHeight) !== null && _e !== void 0 ? _e : "100%") },
|
|
47
|
-
id: this.options.tabs[idx].id
|
|
48
|
-
},
|
|
49
|
-
children: [this.toNode(this.options.tabs[idx].content)]
|
|
50
|
-
});
|
|
51
|
-
}
|
|
24
|
+
this.State.id = this.State.id || helper.newDomGuid();
|
|
25
|
+
for (const tab of this.options.tabs) {
|
|
26
|
+
tab.id = tab.id || helper.newDomGuid();
|
|
52
27
|
}
|
|
28
|
+
const activeIndex = this.getActiveTabIndex();
|
|
29
|
+
const focusIndex = ((_a = this.options.tabs[activeIndex]) === null || _a === void 0 ? void 0 : _a.enabled) !== false && activeIndex >= 0
|
|
30
|
+
? activeIndex : this.firstEnabledIndex();
|
|
31
|
+
this.createContent(activeIndex);
|
|
53
32
|
return {
|
|
54
|
-
tag: "div",
|
|
33
|
+
tag: "div",
|
|
34
|
+
attr: { class: "stabcomponent " + (this.options.class || ""), style: this.options.style },
|
|
35
|
+
children: [
|
|
55
36
|
{
|
|
56
|
-
tag: "div", attr: {
|
|
57
|
-
|
|
58
|
-
|
|
37
|
+
tag: "div", attr: {
|
|
38
|
+
class: "tab-header-row", role: "tablist",
|
|
39
|
+
id: this.State.id + "-tablist",
|
|
40
|
+
"aria-label": this.options.ariaLabel || "Tabs",
|
|
41
|
+
"aria-orientation": "horizontal",
|
|
42
|
+
tabindex: focusIndex === -1 ? "0" : undefined
|
|
43
|
+
}, children: this.options.tabs.map((tab, index) => {
|
|
44
|
+
const active = index === activeIndex;
|
|
45
|
+
const disabled = tab.enabled === false;
|
|
46
|
+
const label = tab.ariaLabel || (typeof tab.header === "string" ? tab.header : "Tab " + (index + 1));
|
|
59
47
|
return {
|
|
60
48
|
tag: "div", attr: {
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
if ((_a = this.options.tabs[currIndex].enabled) !== null && _a !== void 0 ? _a : true) {
|
|
65
|
-
this.SetSelectedTab(currIndex);
|
|
66
|
-
if (this.options.onSelect) {
|
|
67
|
-
this.options.onSelect(currIndex);
|
|
68
|
-
}
|
|
69
|
-
}
|
|
70
|
-
}
|
|
49
|
+
id: this.State.id + "-item-" + tab.id,
|
|
50
|
+
class: "tab-item " + (active ? "active " : "") + (disabled ? "disabled" : ""),
|
|
51
|
+
role: "presentation"
|
|
71
52
|
}, children: [
|
|
72
|
-
{
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
53
|
+
{
|
|
54
|
+
tag: "button", attr: {
|
|
55
|
+
id: this.triggerId(tab), class: "tab-trigger", type: "button",
|
|
56
|
+
role: "tab", disabled: disabled ? "disabled" : undefined,
|
|
57
|
+
tabindex: index === focusIndex ? "0" : "-1",
|
|
58
|
+
"aria-selected": String(active),
|
|
59
|
+
"aria-disabled": disabled ? "true" : undefined,
|
|
60
|
+
"aria-controls": tab.id,
|
|
61
|
+
"aria-label": tab.ariaLabel,
|
|
62
|
+
click: () => this.selectFromUser(index),
|
|
63
|
+
keydown: (event) => this.onTabKeydown(event, index)
|
|
64
|
+
}, children: [{
|
|
65
|
+
tag: "span", attr: { class: "tab-label" },
|
|
66
|
+
children: [this.toNode(tab.header, "span")]
|
|
67
|
+
}]
|
|
68
|
+
},
|
|
69
|
+
tab.canClose ? {
|
|
70
|
+
tag: "button", attr: {
|
|
71
|
+
class: "close-button", type: "button",
|
|
72
|
+
"aria-label": tab.closeButtonLabel || "Close " + label,
|
|
73
|
+
title: tab.closeButtonLabel || "Close " + label,
|
|
74
|
+
tabindex: index === focusIndex ? "0" : "-1",
|
|
75
|
+
disabled: disabled ? "disabled" : undefined,
|
|
76
|
+
click: (event) => {
|
|
77
|
+
event.stopPropagation();
|
|
78
|
+
if (!disabled) {
|
|
79
|
+
this.closeTabIndex(index, true);
|
|
80
|
+
}
|
|
81
|
+
},
|
|
82
|
+
keydown: (event) => this.onTabKeydown(event, index)
|
|
83
|
+
}
|
|
84
|
+
} : undefined
|
|
88
85
|
]
|
|
89
86
|
};
|
|
90
87
|
})
|
|
91
|
-
},
|
|
88
|
+
},
|
|
89
|
+
{
|
|
90
|
+
tag: "div", attr: { class: "tab-panels" },
|
|
91
|
+
// Stable panel shells keep ARIA links valid and preserve mounted content.
|
|
92
|
+
children: this.options.tabs.map((tab, index) => {
|
|
93
|
+
var _a, _b;
|
|
94
|
+
return ({
|
|
95
|
+
tag: "div", attr: {
|
|
96
|
+
id: tab.id,
|
|
97
|
+
class: "tab-content " + (index === activeIndex ? "" : "tab-hidden ") + ((_a = this.options.contentClass) !== null && _a !== void 0 ? _a : ""),
|
|
98
|
+
style: { "max-height": (_b = this.options.maxHeight) !== null && _b !== void 0 ? _b : "100%" },
|
|
99
|
+
role: "tabpanel", "aria-labelledby": this.triggerId(tab),
|
|
100
|
+
tabindex: "0",
|
|
101
|
+
hidden: index !== activeIndex ? "hidden" : undefined
|
|
102
|
+
}, children: index === activeIndex || this.options.preserveContent
|
|
103
|
+
? [this.toNode(tab.content)] : []
|
|
104
|
+
});
|
|
105
|
+
})
|
|
106
|
+
}
|
|
92
107
|
]
|
|
93
108
|
};
|
|
94
109
|
}
|
|
95
110
|
AddTab(tabItem) {
|
|
96
111
|
var _a;
|
|
112
|
+
this.checkForDuplicateIds([...this.options.tabs, tabItem]);
|
|
113
|
+
const wasEmpty = this.options.tabs.length === 0;
|
|
97
114
|
tabItem.enabled = (_a = tabItem.enabled) !== null && _a !== void 0 ? _a : true;
|
|
115
|
+
tabItem.id = tabItem.id || helper.newDomGuid();
|
|
98
116
|
this.options.tabs.push(tabItem);
|
|
99
|
-
this.
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
EnableAll() {
|
|
103
|
-
for (let i = 0; i < this.options.tabs.length; i++) {
|
|
104
|
-
this.options.tabs[i].enabled = true;
|
|
105
|
-
}
|
|
106
|
-
if (this.renderer != null) {
|
|
107
|
-
this.renderer.refresh();
|
|
117
|
+
const index = this.options.tabs.length - 1;
|
|
118
|
+
if (wasEmpty) {
|
|
119
|
+
this.SetSelectedTab(index);
|
|
108
120
|
}
|
|
109
121
|
else {
|
|
110
|
-
|
|
122
|
+
this.requestRefresh();
|
|
111
123
|
}
|
|
124
|
+
return index;
|
|
112
125
|
}
|
|
113
|
-
|
|
114
|
-
for (
|
|
115
|
-
|
|
116
|
-
}
|
|
117
|
-
if (this.renderer != null) {
|
|
118
|
-
this.renderer.refresh();
|
|
126
|
+
EnableAll() {
|
|
127
|
+
for (const tab of this.options.tabs) {
|
|
128
|
+
tab.enabled = true;
|
|
119
129
|
}
|
|
120
|
-
|
|
121
|
-
|
|
130
|
+
this.requestRefresh();
|
|
131
|
+
}
|
|
132
|
+
DisableAll() {
|
|
133
|
+
for (const tab of this.options.tabs) {
|
|
134
|
+
tab.enabled = false;
|
|
122
135
|
}
|
|
136
|
+
this.requestRefresh();
|
|
123
137
|
}
|
|
124
138
|
GetByID(id) {
|
|
125
|
-
return this.options.tabs.
|
|
139
|
+
return this.options.tabs.find(tab => tab.id === id);
|
|
126
140
|
}
|
|
127
141
|
closeTabIndex(index, raiseSelectEvent) {
|
|
128
|
-
var _a, _b;
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
if (this.options.tabs[index].onClosing() === false) {
|
|
132
|
-
return false;
|
|
133
|
-
}
|
|
142
|
+
var _a, _b, _c, _d, _e;
|
|
143
|
+
if (!this.isValidIndex(index)) {
|
|
144
|
+
return false;
|
|
134
145
|
}
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
this.SetSelectedTab(newSelectedIndex);
|
|
146
|
+
const closing = this.options.tabs[index];
|
|
147
|
+
if (((_a = closing.onClosing) === null || _a === void 0 ? void 0 : _a.call(closing)) === false) {
|
|
148
|
+
this.requestRefresh();
|
|
149
|
+
return false;
|
|
140
150
|
}
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
151
|
+
const activeIndex = this.getActiveTabIndex();
|
|
152
|
+
const trigger = document.getElementById(this.triggerId(closing));
|
|
153
|
+
const restoreFocus = !!((_b = trigger === null || trigger === void 0 ? void 0 : trigger.parentElement) === null || _b === void 0 ? void 0 : _b.contains(document.activeElement));
|
|
154
|
+
this.options.tabs = this.options.tabs.filter((_, tabIndex) => tabIndex !== index);
|
|
155
|
+
let next = activeIndex;
|
|
156
|
+
if (index < activeIndex) {
|
|
157
|
+
next--;
|
|
158
|
+
}
|
|
159
|
+
else if (index === activeIndex) {
|
|
160
|
+
next = this.options.tabs.findIndex((tab, tabIndex) => tabIndex >= index && tab.enabled !== false);
|
|
161
|
+
if (next === -1) {
|
|
162
|
+
for (let previous = Math.min(index - 1, this.options.tabs.length - 1); previous >= 0; previous--) {
|
|
163
|
+
if (this.options.tabs[previous].enabled !== false) {
|
|
164
|
+
next = previous;
|
|
165
|
+
break;
|
|
166
|
+
}
|
|
167
|
+
}
|
|
144
168
|
}
|
|
145
169
|
}
|
|
170
|
+
this.SetSelectedTab(next);
|
|
171
|
+
if (raiseSelectEvent) {
|
|
172
|
+
(_d = (_c = this.options).onSelect) === null || _d === void 0 ? void 0 : _d.call(_c, next);
|
|
173
|
+
}
|
|
174
|
+
if (restoreFocus) {
|
|
175
|
+
const focusIndex = next >= 0 && ((_e = this.options.tabs[next]) === null || _e === void 0 ? void 0 : _e.enabled) !== false ? next : this.firstEnabledIndex();
|
|
176
|
+
this.requestRefresh(focusIndex);
|
|
177
|
+
}
|
|
146
178
|
return true;
|
|
147
179
|
}
|
|
148
|
-
// public onCreate(node: IJSLVNode) {
|
|
149
|
-
// this.ref = node.dom as HTMLDivElement;
|
|
150
|
-
// }
|
|
151
|
-
// public onUpdate(node: IJSLVNode) {
|
|
152
|
-
// this.ref = node.dom as HTMLDivElement;
|
|
153
|
-
// }
|
|
154
180
|
onInit(renderer) {
|
|
155
181
|
this.renderer = renderer;
|
|
156
182
|
}
|
|
183
|
+
onCreate() {
|
|
184
|
+
this.revealTab();
|
|
185
|
+
}
|
|
186
|
+
/** Select programmatically without raising onSelect, including -1 for no selection. */
|
|
157
187
|
SetSelectedTab(index) {
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
this.options.tabs[index].content = this.options.tabs[index].onCreate();
|
|
188
|
+
if (index !== -1 && !this.isValidIndex(index)) {
|
|
189
|
+
return;
|
|
161
190
|
}
|
|
162
|
-
this.options.selectedIndex = index;
|
|
163
191
|
this.State.selectedIndex = index;
|
|
164
|
-
|
|
192
|
+
this.options.selectedIndex = index;
|
|
193
|
+
this.createContent(index);
|
|
194
|
+
this.requestRefresh();
|
|
195
|
+
}
|
|
196
|
+
selectFromUser(index) {
|
|
197
|
+
var _a, _b;
|
|
198
|
+
if (!this.isValidIndex(index) || this.options.tabs[index].enabled === false) {
|
|
199
|
+
return false;
|
|
200
|
+
}
|
|
201
|
+
if (((_b = (_a = this.options).onSelect) === null || _b === void 0 ? void 0 : _b.call(_a, index)) === false) {
|
|
202
|
+
this.requestRefresh(this.getActiveTabIndex());
|
|
203
|
+
return false;
|
|
204
|
+
}
|
|
205
|
+
this.SetSelectedTab(index);
|
|
206
|
+
return true;
|
|
207
|
+
}
|
|
208
|
+
onTabKeydown(event, index) {
|
|
209
|
+
var _a, _b;
|
|
210
|
+
if (event.altKey || event.ctrlKey || event.metaKey || ((_a = this.options.tabs[index]) === null || _a === void 0 ? void 0 : _a.enabled) === false) {
|
|
211
|
+
return;
|
|
212
|
+
}
|
|
213
|
+
const enabled = this.options.tabs.map((tab, tabIndex) => tab.enabled !== false ? tabIndex : -1)
|
|
214
|
+
.filter(tabIndex => tabIndex !== -1);
|
|
215
|
+
let next;
|
|
216
|
+
const position = enabled.indexOf(index);
|
|
217
|
+
const rtl = getComputedStyle(event.currentTarget).direction === "rtl";
|
|
218
|
+
if (event.key === "ArrowRight" || event.key === "ArrowLeft") {
|
|
219
|
+
const forward = (event.key === "ArrowRight") !== rtl;
|
|
220
|
+
next = enabled[(position + (forward ? 1 : -1) + enabled.length) % enabled.length];
|
|
221
|
+
}
|
|
222
|
+
else if (event.key === "Home") {
|
|
223
|
+
next = enabled[0];
|
|
224
|
+
}
|
|
225
|
+
else if (event.key === "End") {
|
|
226
|
+
next = enabled[enabled.length - 1];
|
|
227
|
+
}
|
|
228
|
+
else if (event.key === "Delete" && ((_b = this.options.tabs[index]) === null || _b === void 0 ? void 0 : _b.canClose)) {
|
|
229
|
+
event.preventDefault();
|
|
230
|
+
this.closeTabIndex(index, true);
|
|
231
|
+
return;
|
|
232
|
+
}
|
|
233
|
+
else {
|
|
234
|
+
return; // Native Enter and Space activate the tab or close button.
|
|
235
|
+
}
|
|
236
|
+
event.preventDefault();
|
|
237
|
+
if (next != null && this.selectFromUser(next)) {
|
|
238
|
+
this.requestRefresh(next);
|
|
239
|
+
}
|
|
240
|
+
}
|
|
241
|
+
requestRefresh(focusIndex) {
|
|
242
|
+
if (this.renderer) {
|
|
165
243
|
this.renderer.refresh();
|
|
166
244
|
}
|
|
167
245
|
else {
|
|
168
246
|
refresh();
|
|
169
247
|
}
|
|
248
|
+
this.revealTab(focusIndex);
|
|
170
249
|
}
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
250
|
+
revealTab(focusIndex) {
|
|
251
|
+
const tab = this.options.tabs[focusIndex !== null && focusIndex !== void 0 ? focusIndex : this.getActiveTabIndex()];
|
|
252
|
+
if (!tab) {
|
|
253
|
+
if (focusIndex != null) {
|
|
254
|
+
const listId = this.State.id + "-tablist";
|
|
255
|
+
requestAnimationFrame(() => { var _a; return (_a = document.getElementById(listId)) === null || _a === void 0 ? void 0 : _a.focus({ preventScroll: true }); });
|
|
256
|
+
}
|
|
257
|
+
return;
|
|
177
258
|
}
|
|
178
|
-
|
|
259
|
+
const id = this.triggerId(tab);
|
|
260
|
+
requestAnimationFrame(() => {
|
|
261
|
+
const trigger = document.getElementById(id);
|
|
262
|
+
const item = trigger === null || trigger === void 0 ? void 0 : trigger.parentElement;
|
|
263
|
+
const row = item === null || item === void 0 ? void 0 : item.parentElement;
|
|
264
|
+
if (!trigger || !row) {
|
|
265
|
+
return;
|
|
266
|
+
}
|
|
267
|
+
if (focusIndex != null && !trigger.disabled) {
|
|
268
|
+
trigger.focus({ preventScroll: true });
|
|
269
|
+
}
|
|
270
|
+
const itemRect = item.getBoundingClientRect();
|
|
271
|
+
const rowRect = row.getBoundingClientRect();
|
|
272
|
+
if (itemRect.left < rowRect.left) {
|
|
273
|
+
row.scrollLeft += itemRect.left - rowRect.left;
|
|
274
|
+
}
|
|
275
|
+
else if (itemRect.right > rowRect.right) {
|
|
276
|
+
row.scrollLeft += itemRect.right - rowRect.right;
|
|
277
|
+
}
|
|
278
|
+
});
|
|
179
279
|
}
|
|
180
|
-
|
|
181
|
-
|
|
280
|
+
createContent(index) {
|
|
281
|
+
const tab = this.options.tabs[index];
|
|
282
|
+
if (!tab || tab.content != null || !tab.onCreate) {
|
|
182
283
|
return;
|
|
183
284
|
}
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
285
|
+
this.State.created = this.State.created || new WeakSet();
|
|
286
|
+
if (!this.State.created.has(tab)) {
|
|
287
|
+
tab.content = tab.onCreate();
|
|
288
|
+
this.State.created.add(tab);
|
|
289
|
+
}
|
|
290
|
+
}
|
|
291
|
+
isValidIndex(index) {
|
|
292
|
+
return Number.isInteger(index) && index >= 0 && index < this.options.tabs.length;
|
|
293
|
+
}
|
|
294
|
+
firstEnabledIndex() {
|
|
295
|
+
return this.options.tabs.findIndex(tab => tab.enabled !== false);
|
|
296
|
+
}
|
|
297
|
+
triggerId(tab) {
|
|
298
|
+
this.State.id = this.State.id || helper.newDomGuid();
|
|
299
|
+
return this.State.id + "-tab-" + tab.id;
|
|
300
|
+
}
|
|
301
|
+
toNode(content, tag = "div") {
|
|
302
|
+
return typeof content === "string" ? { tag, content } : content;
|
|
303
|
+
}
|
|
304
|
+
checkForDuplicateIds(tabs = this.options.tabs) {
|
|
305
|
+
const ids = new Set();
|
|
306
|
+
for (const tab of tabs) {
|
|
307
|
+
if (tab.id) {
|
|
308
|
+
if (ids.has(tab.id)) {
|
|
309
|
+
throw new Error("Tab Control has duplicate id " + tab.id);
|
|
310
|
+
}
|
|
311
|
+
ids.add(tab.id);
|
|
188
312
|
}
|
|
189
313
|
}
|
|
190
314
|
}
|
|
@@ -1,76 +1,139 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
cursor:
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
.
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
1
|
+
@import "../../ui/theme.css";
|
|
2
|
+
|
|
3
|
+
.stabcomponent {
|
|
4
|
+
min-width: 0;
|
|
5
|
+
max-width: 100%;
|
|
6
|
+
color: var(--jsl-color-text);
|
|
7
|
+
|
|
8
|
+
> .tab-header-row {
|
|
9
|
+
display: flex;
|
|
10
|
+
align-items: stretch;
|
|
11
|
+
gap: 0.25rem;
|
|
12
|
+
min-width: 0;
|
|
13
|
+
overflow-x: auto;
|
|
14
|
+
overscroll-behavior-inline: contain;
|
|
15
|
+
scrollbar-width: thin;
|
|
16
|
+
border-bottom: 1px solid var(--jsl-tabs-border, var(--jsl-color-border-subtle));
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
> .tab-header-row > .tab-item {
|
|
20
|
+
display: flex;
|
|
21
|
+
align-items: center;
|
|
22
|
+
flex: 0 0 auto;
|
|
23
|
+
gap: 0.125rem;
|
|
24
|
+
position: relative;
|
|
25
|
+
margin: 0;
|
|
26
|
+
padding: 0;
|
|
27
|
+
border: 0;
|
|
28
|
+
border-bottom: 2px solid transparent;
|
|
29
|
+
border-radius: 0.375rem 0.375rem 0 0;
|
|
30
|
+
background: transparent;
|
|
31
|
+
color: var(--jsl-tabs-text, var(--jsl-color-text-secondary));
|
|
32
|
+
|
|
33
|
+
&:hover {
|
|
34
|
+
background: var(--jsl-tabs-hover-surface, var(--jsl-color-surface-hover));
|
|
35
|
+
color: var(--jsl-color-text);
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
&.active {
|
|
39
|
+
border-bottom-color: var(--jsl-tabs-accent, var(--jsl-color-accent));
|
|
40
|
+
color: var(--jsl-tabs-active-text, var(--jsl-color-text));
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
&.disabled {
|
|
44
|
+
border-bottom-color: transparent;
|
|
45
|
+
background: transparent;
|
|
46
|
+
color: var(--jsl-color-disabled-text);
|
|
47
|
+
cursor: not-allowed;
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
.tab-trigger {
|
|
52
|
+
display: inline-flex;
|
|
53
|
+
align-items: center;
|
|
54
|
+
justify-content: center;
|
|
55
|
+
gap: 0.5rem;
|
|
56
|
+
box-sizing: border-box;
|
|
57
|
+
min-height: 2.5rem;
|
|
58
|
+
min-width: 0;
|
|
59
|
+
padding: 0.625rem 0.875rem;
|
|
60
|
+
margin: 0;
|
|
61
|
+
border: 0;
|
|
62
|
+
border-radius: 0.375rem;
|
|
63
|
+
background: transparent;
|
|
64
|
+
color: inherit;
|
|
65
|
+
font: inherit;
|
|
66
|
+
font-size: 0.875rem;
|
|
67
|
+
font-weight: 500;
|
|
68
|
+
line-height: 1.5;
|
|
69
|
+
text-align: start;
|
|
70
|
+
text-decoration: none;
|
|
71
|
+
cursor: pointer;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
.tab-trigger:disabled { cursor: not-allowed; }
|
|
75
|
+
.tab-trigger:focus-visible,
|
|
76
|
+
> .tab-header-row > .tab-item > .close-button:focus-visible,
|
|
77
|
+
> .tab-header-row:focus-visible {
|
|
78
|
+
outline: 2px solid var(--jsl-color-focus);
|
|
79
|
+
outline-offset: -3px;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
.tab-label {
|
|
83
|
+
display: inline-flex;
|
|
84
|
+
align-items: center;
|
|
85
|
+
gap: 0.5rem;
|
|
86
|
+
white-space: nowrap;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
> .tab-header-row > .tab-item > .close-button {
|
|
90
|
+
display: inline-flex;
|
|
91
|
+
align-items: center;
|
|
92
|
+
justify-content: center;
|
|
93
|
+
position: relative;
|
|
94
|
+
flex: 0 0 auto;
|
|
95
|
+
box-sizing: border-box;
|
|
96
|
+
width: 1.5rem;
|
|
97
|
+
height: 1.5rem;
|
|
98
|
+
padding: 0;
|
|
99
|
+
margin: 0 0.5rem 0 -0.375rem;
|
|
100
|
+
border: 0;
|
|
101
|
+
border-radius: 0.25rem;
|
|
102
|
+
background: transparent;
|
|
103
|
+
color: var(--jsl-color-text-muted);
|
|
104
|
+
cursor: pointer;
|
|
105
|
+
|
|
106
|
+
&::before,
|
|
107
|
+
&::after {
|
|
108
|
+
content: "";
|
|
109
|
+
position: absolute;
|
|
110
|
+
width: 0.625rem;
|
|
111
|
+
height: 1.5px;
|
|
112
|
+
border-radius: 1px;
|
|
113
|
+
background: currentColor;
|
|
114
|
+
transform: rotate(45deg);
|
|
115
|
+
}
|
|
116
|
+
&::after { transform: rotate(-45deg); }
|
|
117
|
+
&:hover { background: var(--jsl-color-surface-selected); color: var(--jsl-color-text); }
|
|
118
|
+
&:disabled { color: var(--jsl-color-disabled-text); background: transparent; cursor: not-allowed; }
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
> .tab-panels {
|
|
122
|
+
min-width: 0;
|
|
123
|
+
background: var(--jsl-tabs-surface, var(--jsl-color-surface));
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
> .tab-panels > .tab-content {
|
|
127
|
+
box-sizing: border-box;
|
|
128
|
+
min-width: 0;
|
|
129
|
+
padding: 1rem;
|
|
130
|
+
overflow: auto;
|
|
131
|
+
overflow-wrap: anywhere;
|
|
132
|
+
overscroll-behavior: contain;
|
|
133
|
+
line-height: 1.6;
|
|
134
|
+
|
|
135
|
+
&:focus-visible { outline: 2px solid var(--jsl-color-focus); outline-offset: -2px; }
|
|
136
|
+
&.tab-hidden,
|
|
137
|
+
&[hidden] { display: none; }
|
|
138
|
+
}
|
|
76
139
|
}
|