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.
Files changed (166) hide show
  1. package/docs/AutoSuggestComponent.md +17 -0
  2. package/docs/ButtonComponent.md +14 -0
  3. package/docs/CheckBoxComponent.md +12 -0
  4. package/docs/DateComponent.md +12 -0
  5. package/docs/DateRangeComponent.md +13 -0
  6. package/docs/DateTimeComponent.md +13 -0
  7. package/docs/DialogComponent.md +15 -0
  8. package/docs/ExpanderComponent.md +13 -0
  9. package/docs/FormComponent.md +15 -0
  10. package/docs/FormFieldComponent.md +15 -0
  11. package/docs/GridComponent.md +19 -0
  12. package/docs/InputComponent.md +15 -0
  13. package/docs/IntervalComponent.md +13 -0
  14. package/docs/LoadingComponent.md +12 -0
  15. package/docs/NavigationComponent.md +17 -0
  16. package/docs/Notification.md +14 -0
  17. package/docs/NotificationComponent.md +13 -0
  18. package/docs/NumberComponent.md +12 -0
  19. package/docs/OverlayComponent.md +12 -0
  20. package/docs/ProgressComponent.md +12 -0
  21. package/docs/README.md +24 -0
  22. package/docs/RibbonMenuComponent.md +14 -0
  23. package/docs/SelectComponent.md +15 -0
  24. package/docs/SplitterComponent.md +14 -0
  25. package/docs/StackPanelComponent.md +13 -0
  26. package/docs/TabsComponent.md +16 -0
  27. package/docs/TimeComponent.md +13 -0
  28. package/docs/TreeViewComponent.md +16 -0
  29. package/examples/showcase/checks-and-expanders.ts +163 -0
  30. package/examples/showcase/cultures.ts +39 -0
  31. package/examples/showcase/dates.ts +182 -0
  32. package/examples/showcase/dialogs.ts +184 -0
  33. package/examples/showcase/feedback-and-navigation.ts +174 -0
  34. package/examples/showcase/fields.ts +178 -0
  35. package/examples/showcase/fonts/Jost-Variable.ttf +0 -0
  36. package/examples/showcase/fonts/OFL-Jost.txt +93 -0
  37. package/examples/showcase/grids.ts +150 -0
  38. package/examples/showcase/index.html +60 -0
  39. package/examples/showcase/layout-and-navigation.ts +47 -0
  40. package/examples/showcase/nivona.css +98 -0
  41. package/examples/showcase/selects.ts +158 -0
  42. package/examples/showcase/showcase.css +231 -0
  43. package/examples/showcase/showcase.ts +214 -0
  44. package/examples/showcase/tabs.ts +161 -0
  45. package/examples/showcase/themes.css +83 -0
  46. package/examples/showcase/themes.ts +54 -0
  47. package/lib/components/IntervalComponent.d.ts +5 -0
  48. package/lib/components/IntervalComponent.js +29 -13
  49. package/lib/components/auto-suggest/AutoSuggestComponent.d.ts +11 -9
  50. package/lib/components/auto-suggest/AutoSuggestComponent.js +25 -38
  51. package/lib/components/button/ButtonComponent.d.ts +30 -1
  52. package/lib/components/button/ButtonComponent.js +85 -4
  53. package/lib/components/checkbox/CheckBoxComponent.d.ts +11 -1
  54. package/lib/components/checkbox/CheckBoxComponent.js +66 -56
  55. package/lib/components/checkbox/CheckBoxStyle.scss +72 -85
  56. package/lib/components/date/DateComponent.d.ts +10 -0
  57. package/lib/components/date/DateComponent.js +92 -44
  58. package/lib/components/date-range/DateRangeComponent.d.ts +14 -3
  59. package/lib/components/date-range/DateRangeComponent.js +96 -86
  60. package/lib/components/date-range/DateRangeStyle.scss +35 -11
  61. package/lib/components/date-time/DateTimeComponent.d.ts +8 -0
  62. package/lib/components/date-time/DateTimeComponent.js +64 -23
  63. package/lib/components/date-time/DateTimeStyle.scss +10 -7
  64. package/lib/components/dialog/DialogComponent.d.ts +21 -7
  65. package/lib/components/dialog/DialogComponent.js +179 -122
  66. package/lib/components/expander/ExpanderComponent.d.ts +15 -1
  67. package/lib/components/expander/ExpanderComponent.js +85 -64
  68. package/lib/components/expander/ExpanderStyle.scss +61 -47
  69. package/lib/components/form-field/FormFieldComponent.d.ts +45 -15
  70. package/lib/components/form-field/FormFieldComponent.js +249 -96
  71. package/lib/components/form-field/FormFieldStyle.scss +36 -87
  72. package/lib/components/form-field/create-control.d.ts +7 -0
  73. package/lib/components/form-field/create-control.js +48 -0
  74. package/lib/components/input/InputComponent.d.ts +18 -1
  75. package/lib/components/input/InputComponent.js +68 -93
  76. package/lib/components/loading/LoadingComponent.d.ts +9 -2
  77. package/lib/components/loading/LoadingComponent.js +13 -12
  78. package/lib/components/loading/LoadingStyle.css +19 -29
  79. package/lib/components/navigation/NavigationComponent.d.ts +34 -10
  80. package/lib/components/navigation/NavigationComponent.js +261 -33
  81. package/lib/components/navigation/NavigationStyle.scss +62 -226
  82. package/lib/components/notification/Notification.d.ts +37 -4
  83. package/lib/components/notification/Notification.js +160 -41
  84. package/lib/components/notification/Notification.scss +103 -19
  85. package/lib/components/number/NumberComponent.d.ts +16 -2
  86. package/lib/components/number/NumberComponent.js +54 -53
  87. package/lib/components/overlay/OverlayComponent.d.ts +13 -7
  88. package/lib/components/overlay/OverlayComponent.js +46 -114
  89. package/lib/components/overlay/overlay.css +18 -57
  90. package/lib/components/progress/ProgressComponent.d.ts +1 -0
  91. package/lib/components/progress/ProgressComponent.js +6 -6
  92. package/lib/components/progress/ProgressStyle.scss +5 -15
  93. package/lib/components/ribbon-menu/RibbonMenuComponent.js +2 -2
  94. package/lib/components/ribbon-menu/RibbonMenuStyle.scss +6 -76
  95. package/lib/components/select/SelectComponent.d.ts +33 -3
  96. package/lib/components/select/SelectComponent.js +312 -278
  97. package/lib/components/select/SelectDDAreaComponent.d.ts +13 -7
  98. package/lib/components/select/SelectDDAreaComponent.js +215 -256
  99. package/lib/components/select/SelectStyle.scss +204 -186
  100. package/lib/components/slider/nouislider.css +40 -54
  101. package/lib/components/stack-panel/SplitterComponent.d.ts +19 -3
  102. package/lib/components/stack-panel/SplitterComponent.js +94 -111
  103. package/lib/components/stack-panel/SplitterStyle.scss +9 -45
  104. package/lib/components/stack-panel/StackPanelComponent.js +3 -3
  105. package/lib/components/stack-panel/StackPanelStyle.scss +10 -52
  106. package/lib/components/tabs/TabsComponent.d.ts +17 -1
  107. package/lib/components/tabs/TabsComponent.js +247 -123
  108. package/lib/components/tabs/TabsStyle.scss +138 -75
  109. package/lib/components/time/TimeComponent.d.ts +5 -0
  110. package/lib/components/time/TimeComponent.js +61 -69
  111. package/lib/components/time/TimeComponent.scss +4 -4
  112. package/lib/components/tree-view/TreeViewComponent.d.ts +10 -4
  113. package/lib/components/tree-view/TreeViewComponent.js +65 -32
  114. package/lib/components/tree-view/TreeViewStyle.scss +12 -96
  115. package/lib/core/date.d.ts +2 -0
  116. package/lib/core/date.js +6 -0
  117. package/lib/core/jq.js +11 -8
  118. package/lib/grid/slick-default-theme.css +107 -31
  119. package/lib/grid/slick.creator.js +23 -5
  120. package/lib/grid/slick.formatters.js +4 -3
  121. package/lib/grid/slick.grid.css +38 -26
  122. package/lib/grid/slick.grid.d.ts +1 -0
  123. package/lib/grid/slick.grid.js +2 -3
  124. package/lib/grid.css +3413 -454
  125. package/lib/index.css +2500 -1031
  126. package/lib/index.css.map +1 -1
  127. package/lib/index.d.ts +1 -0
  128. package/lib/index.js +1 -1
  129. package/lib/index.js.map +1 -1
  130. package/lib/interaction/moveable.d.ts +1 -0
  131. package/lib/interaction/moveable.js +8 -0
  132. package/lib/interaction/resizable.d.ts +1 -0
  133. package/lib/interaction/resizable.js +9 -0
  134. package/lib/ui/auto.suggest.css +31 -14
  135. package/lib/ui/auto.suggest.d.ts +1 -0
  136. package/lib/ui/auto.suggest.js +88 -18
  137. package/lib/ui/base.css +2 -48
  138. package/lib/ui/button.css +134 -0
  139. package/lib/ui/date-input.css +11 -0
  140. package/lib/ui/date.picker/css/tiny-date-picker.css +124 -325
  141. package/lib/ui/date.picker/date-picker-options.js +4 -3
  142. package/lib/ui/date.picker/lib/date-manip.js +9 -0
  143. package/lib/ui/date.picker/mode/base-mode.d.ts +2 -1
  144. package/lib/ui/date.picker/mode/base-mode.js +112 -22
  145. package/lib/ui/date.picker/mode/dropdown-mode.d.ts +2 -4
  146. package/lib/ui/date.picker/mode/dropdown-mode.js +29 -42
  147. package/lib/ui/date.picker/mode/index.d.ts +2 -1
  148. package/lib/ui/date.picker/mode/modal-mode.d.ts +2 -1
  149. package/lib/ui/date.picker/mode/modal-mode.js +4 -2
  150. package/lib/ui/date.picker/mode/permanent-mode.d.ts +2 -1
  151. package/lib/ui/date.picker/views/day-picker.js +24 -15
  152. package/lib/ui/date.picker/views/month-picker.js +1 -1
  153. package/lib/ui/date.picker/views/year-picker.js +3 -2
  154. package/lib/ui/date.picker.d.ts +2 -1
  155. package/lib/ui/dialog.css +144 -108
  156. package/lib/ui/dialog.d.ts +19 -1
  157. package/lib/ui/dialog.js +178 -60
  158. package/lib/ui/input.css +35 -0
  159. package/lib/ui/number.input.js +50 -37
  160. package/lib/ui/theme.css +28 -0
  161. package/package.json +12 -8
  162. package/lib/components/drop-down/DropDownComponent.d.ts +0 -27
  163. package/lib/components/drop-down/DropDownComponent.js +0 -60
  164. package/lib/components/expander/OldExpanderStyle.scss +0 -37
  165. package/lib/ui/drop.down.d.ts +0 -52
  166. 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 : 0;
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
- return (_a = this.State.selectedIndex) !== null && _a !== void 0 ? _a : this.options.selectedIndex;
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, _b, _c, _d, _e;
22
+ var _a;
19
23
  this.checkForDuplicateIds();
20
- let index = -1;
21
- const activeIndex = (_a = this.State.selectedIndex) !== null && _a !== void 0 ? _a : this.options.selectedIndex;
22
- if (activeIndex > -1 &&
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", attr: { class: "stabcomponent " + (this.options.class || ""), style: this.options.style }, children: [
33
+ tag: "div",
34
+ attr: { class: "stabcomponent " + (this.options.class || ""), style: this.options.style },
35
+ children: [
55
36
  {
56
- tag: "div", attr: { class: "tab-header-row" }, children: this.options.tabs.map((x) => {
57
- index++;
58
- const currIndex = index;
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
- class: "tab-item " + (index === activeIndex ? "active " : "") + (this.options.tabs[currIndex].enabled === false ? "disabled " : ""),
62
- click: (evt) => {
63
- var _a;
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
- { tag: "span", attr: { style: "vertical-align: middle; vertical-align: -webkit-baseline-middle; vertical-align: -moz-middle-with-baseline;" }, children: [this.toNode(x.header, "span")] },
73
- this.options.tabs[index].canClose
74
- ?
75
- {
76
- tag: "div", attr: {
77
- class: "close-button", click: (evt) => {
78
- var _a;
79
- if ((_a = this.options.tabs[currIndex].enabled) !== null && _a !== void 0 ? _a : true) {
80
- evt.stopPropagation();
81
- this.closeTabIndex(currIndex, true);
82
- }
83
- }
84
- }, content: "X"
85
- }
86
- :
87
- undefined
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
- }, ...tabs
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.checkForDuplicateIds();
100
- return this.options.tabs.length - 1;
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
- refresh();
122
+ this.requestRefresh();
111
123
  }
124
+ return index;
112
125
  }
113
- DisableAll() {
114
- for (let i = 0; i < this.options.tabs.length; i++) {
115
- this.options.tabs[i].enabled = false;
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
- else {
121
- refresh();
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.filter((f) => f.id === id)[0];
139
+ return this.options.tabs.find(tab => tab.id === id);
126
140
  }
127
141
  closeTabIndex(index, raiseSelectEvent) {
128
- var _a, _b;
129
- // console.log("closing tab index " + index);
130
- if (this.options.tabs[index].onClosing) {
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
- this.options.tabs = this.options.tabs.filter((_, currIdx) => currIdx !== index);
136
- let newSelectedIndex = (_b = (_a = this.State.selectedIndex) !== null && _a !== void 0 ? _a : this.options.selectedIndex) !== null && _b !== void 0 ? _b : 0;
137
- if (this.options.tabs.length <= newSelectedIndex) {
138
- newSelectedIndex--;
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
- if (raiseSelectEvent) {
142
- if (this.options.onSelect) {
143
- this.options.onSelect(newSelectedIndex);
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
- var _a;
159
- if (((_a = this.options.tabs[index]) === null || _a === void 0 ? void 0 : _a.onCreate) != null && this.options.tabs[index].content == null) {
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
- if (this.renderer != null) {
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
- toNode(content, tag) {
172
- if (content == null) {
173
- return undefined;
174
- }
175
- if (typeof content === "string") {
176
- return { tag: tag !== null && tag !== void 0 ? tag : "div", content };
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
- return content;
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
- checkForDuplicateIds() {
181
- if (this.options.tabs == null || this.options.tabs.length === 0) {
280
+ createContent(index) {
281
+ const tab = this.options.tabs[index];
282
+ if (!tab || tab.content != null || !tab.onCreate) {
182
283
  return;
183
284
  }
184
- const ids = {};
185
- for (const tab of this.options.tabs) {
186
- if (tab.id && ids[tab.id] !== undefined) {
187
- throw new Error("Tab Control has duplicate id " + tab.id);
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
- .stabcomponent {
3
- .tab-header-row {
4
- display: flex;
5
- .tab-item {
6
- display: inline-block;
7
- margin-right: 0.1rem;
8
- padding: 0.5rem 0.5rem 0.5rem 0.5rem;
9
- box-sizing: border-box;
10
- border: 1px solid transparent;
11
- border-radius: 4px 4px 0 0;
12
- text-decoration: none;
13
- border-color: #C0C0C0;
14
- border-bottom: 1px solid #ddd;
15
- vertical-align: middle;
16
- vertical-align: -webkit-baseline-middle;
17
- vertical-align: -moz-middle-with-baseline;
18
- cursor: pointer;
19
-
20
- &:hover {
21
- background:#c9e2f9;
22
- color: black;
23
- }
24
-
25
- .close-button {
26
- background: linear-gradient(#d9d8d6, #d9d8d6);
27
- border: 1px solid #88898d;
28
- border-radius: 0.2rem;
29
- color: #000;
30
- cursor: pointer;
31
- float: right;
32
- padding: 0.3rem;
33
- min-width: 1rem;
34
- text-align: center;
35
- margin-left: 0.5rem;
36
- margin-right: -0.5rem;
37
-
38
- &:hover {
39
- color: #000;
40
- border-color: #000;
41
- background: linear-gradient(#ff634b, #ff3313);
42
- }
43
- }
44
- }
45
-
46
- .active {
47
- cursor: default;
48
- background: #3B99FF;
49
- color: white;
50
- font-weight: bold;
51
- border: 1px solid rgb(116, 116, 116);
52
- border-bottom-color: transparent;
53
- }
54
-
55
- .disabled {
56
- cursor: default;
57
- color: #88898d;
58
- background: #d9d8d6;
59
-
60
- &:hover {
61
- color: #88898d;
62
- background: #d9d8d6;
63
- }
64
- }
65
- }
66
-
67
- .tab-content {
68
- max-height: calc(100vh - 9.6rem);
69
- overflow:auto;
70
- border:1px solid #C0C0C0;
71
- }
72
-
73
- .tab-hidden {
74
- display: none;
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
  }