@plesk/ui-library 3.42.0 → 3.43.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/cjs/components/CodeEditor/CodeEditor.js +1 -2
- package/cjs/components/Icon/constants.js +0 -1
- package/cjs/components/List/List.js +6 -3
- package/cjs/components/Tabs/FakeTabs.js +58 -0
- package/cjs/components/Tabs/Tab.js +0 -1
- package/cjs/components/Tabs/TabClose.js +35 -0
- package/cjs/components/Tabs/TabIcon.js +22 -0
- package/cjs/components/Tabs/TabLabel.js +34 -0
- package/cjs/components/Tabs/TabList.js +120 -0
- package/cjs/components/Tabs/TabListItem.js +75 -0
- package/cjs/components/Tabs/Tabs.js +98 -537
- package/cjs/components/Tabs/useActive.js +19 -0
- package/cjs/components/Tabs/useWidths.js +102 -0
- package/cjs/components/Toaster/PanelView.js +15 -13
- package/cjs/components/Toolbar/ToolbarMenu.js +0 -1
- package/cjs/components/Toolbar/index.js +1 -8
- package/cjs/components/index.js +0 -7
- package/cjs/index.js +1 -1
- package/dist/plesk-ui-library-rtl.css +1 -1
- package/dist/plesk-ui-library-rtl.css.map +1 -1
- package/dist/plesk-ui-library.css +1 -1
- package/dist/plesk-ui-library.css.map +1 -1
- package/dist/plesk-ui-library.js +668 -608
- package/dist/plesk-ui-library.js.map +1 -1
- package/dist/plesk-ui-library.min.js +5 -5
- package/dist/plesk-ui-library.min.js.map +1 -1
- package/esm/components/CodeEditor/CodeEditor.js +1 -2
- package/esm/components/Icon/constants.js +0 -1
- package/esm/components/List/List.js +6 -3
- package/esm/components/Tabs/FakeTabs.js +51 -0
- package/esm/components/Tabs/Tab.js +0 -1
- package/esm/components/Tabs/TabClose.js +28 -0
- package/esm/components/Tabs/TabIcon.js +14 -0
- package/esm/components/Tabs/TabLabel.js +27 -0
- package/esm/components/Tabs/TabList.js +111 -0
- package/esm/components/Tabs/TabListItem.js +68 -0
- package/esm/components/Tabs/Tabs.js +100 -537
- package/esm/components/Tabs/useActive.js +12 -0
- package/esm/components/Tabs/useWidths.js +95 -0
- package/esm/components/Toaster/PanelView.js +15 -13
- package/esm/components/Toolbar/ToolbarMenu.js +0 -1
- package/esm/components/Toolbar/index.js +1 -2
- package/esm/components/index.js +1 -1
- package/esm/index.js +1 -1
- package/package.json +9 -10
- package/styleguide/build/bundle.ef040f7a.js +2 -0
- package/styleguide/index.html +2 -2
- package/types/components/Carousel/Carousel.d.ts +1 -1
- package/types/components/Label/Label.d.ts +1 -1
- package/types/components/List/List.d.ts +8 -2
- package/types/components/Tabs/FakeTabs.d.ts +9 -0
- package/types/components/Tabs/SearchBar.d.ts +3 -3
- package/types/components/Tabs/TabClose.d.ts +9 -0
- package/types/components/Tabs/TabIcon.d.ts +7 -0
- package/types/components/Tabs/TabLabel.d.ts +9 -0
- package/types/components/Tabs/TabList.d.ts +14 -0
- package/types/components/Tabs/TabListItem.d.ts +12 -0
- package/types/components/Tabs/Tabs.d.ts +2 -52
- package/types/components/Tabs/useActive.d.ts +1 -0
- package/types/components/Tabs/useWidths.d.ts +16 -0
- package/types/components/Toolbar/index.d.ts +0 -1
- package/types/components/index.d.ts +1 -1
- package/types/utils/types/ComponentProps.d.ts +1 -1
- package/types/utils/types/PolymorphicComponent.d.ts +2 -2
- package/cjs/components/Toolbar/ToolbarBetaProvider.js +0 -23
- package/esm/components/Toolbar/ToolbarBetaProvider.js +0 -16
- package/styleguide/build/bundle.7ac8a2af.js +0 -2
- package/types/components/Toolbar/ToolbarBetaProvider.d.ts +0 -5
- /package/styleguide/build/{bundle.7ac8a2af.js.LICENSE.txt → bundle.ef040f7a.js.LICENSE.txt} +0 -0
|
@@ -5,26 +5,17 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
value: true
|
|
6
6
|
});
|
|
7
7
|
exports.default = void 0;
|
|
8
|
-
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
9
8
|
var _classnames = _interopRequireDefault(require("classnames"));
|
|
10
9
|
var _react = require("react");
|
|
11
|
-
var _reactMeasure = _interopRequireDefault(require("react-measure"));
|
|
12
10
|
var _constants = require("../../constants");
|
|
13
|
-
var _Dropdown = _interopRequireDefault(require("../Dropdown"));
|
|
14
|
-
var _Icon = _interopRequireWildcard(require("../Icon"));
|
|
15
|
-
var _Label = _interopRequireDefault(require("../Label"));
|
|
16
|
-
var _Menu = _interopRequireWildcard(require("../Menu"));
|
|
17
11
|
var _ResponsiveContext = _interopRequireDefault(require("../ResponsiveContext"));
|
|
18
|
-
var
|
|
19
|
-
var
|
|
12
|
+
var _FakeTabs = _interopRequireDefault(require("./FakeTabs"));
|
|
13
|
+
var _TabList = _interopRequireDefault(require("./TabList"));
|
|
14
|
+
var _useActive = require("./useActive");
|
|
15
|
+
var _useWidths = require("./useWidths");
|
|
20
16
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
21
|
-
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
|
|
22
|
-
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
|
23
17
|
// Copyright 1999-2025. WebPros International GmbH. All rights reserved.
|
|
24
18
|
|
|
25
|
-
const ADDON_LEFT_PADDING = 5;
|
|
26
|
-
const MIN_ADDON_WIDTH_DEFAULT = 150;
|
|
27
|
-
const COLLAPSED_SEARCH_WIDTH = 60;
|
|
28
19
|
/**
|
|
29
20
|
* `Tabs` component is a content area with a group of individual [Tab](#!/Tab) elements, each displaying different content
|
|
30
21
|
* in the same screen area. `Tabs` are used when you have too much content to display in one place at the same time, so
|
|
@@ -32,430 +23,65 @@ const COLLAPSED_SEARCH_WIDTH = 60;
|
|
|
32
23
|
* group name and a navigation button.
|
|
33
24
|
* @since 0.0.35
|
|
34
25
|
*/
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
const searchWidth = compact && search ? COLLAPSED_SEARCH_WIDTH + ADDON_LEFT_PADDING : 0;
|
|
71
|
-
const {
|
|
72
|
-
more,
|
|
73
|
-
container,
|
|
74
|
-
margin
|
|
75
|
-
} = widths;
|
|
76
|
-
let tabs = widths.tabs.slice();
|
|
77
|
-
const tabsNumber = tabs.length;
|
|
78
|
-
let lastTabIndex = tabsNumber - 1 - collapsedLength;
|
|
79
|
-
if (monospaced) {
|
|
80
|
-
monospacedWidth = Math.max(...tabs.slice(0, lastTabIndex + 1));
|
|
81
|
-
tabs = tabs.map(getMonospacedWidth);
|
|
82
|
-
}
|
|
83
|
-
const getListWidth = () => {
|
|
84
|
-
let listWidth = monospaced ? margin * Math.max(0, tabsNumber - 1 - Math.max(0, collapsedLength - 1)) : 0;
|
|
85
|
-
for (let i = 0; i <= lastTabIndex; ++i) {
|
|
86
|
-
listWidth += tabs[i];
|
|
87
|
-
}
|
|
88
|
-
if (collapsedLength) {
|
|
89
|
-
listWidth += more;
|
|
90
|
-
}
|
|
91
|
-
return listWidth;
|
|
92
|
-
};
|
|
93
|
-
let spaceForAddon = container - getListWidth();
|
|
94
|
-
if (addon && !collapsedLength && !compact && spaceForAddon <= addonMinWidth) {
|
|
95
|
-
compact = true;
|
|
96
|
-
}
|
|
97
|
-
let freeSpace = spaceForAddon - searchWidth;
|
|
98
|
-
if (freeSpace <= 0) {
|
|
99
|
-
// collapse
|
|
100
|
-
for (let i = lastTabIndex; i >= 0; --i) {
|
|
101
|
-
let width = tabs[i];
|
|
102
|
-
if (monospaced && widths.tabs[i] === monospacedWidth) {
|
|
103
|
-
monospacedWidth = widths.tabs.slice(0, lastTabIndex).reduce((max, tab) => tab > max ? tab : max, 0);
|
|
104
|
-
tabs = tabs.map(getMonospacedWidth);
|
|
105
|
-
width += (widths.tabs[i] - monospacedWidth) * lastTabIndex;
|
|
106
|
-
}
|
|
107
|
-
if (collapsedLength === 0) {
|
|
108
|
-
width -= more;
|
|
109
|
-
}
|
|
110
|
-
freeSpace += width;
|
|
111
|
-
++collapsedLength;
|
|
112
|
-
--lastTabIndex;
|
|
113
|
-
if (freeSpace > 0) {
|
|
114
|
-
break;
|
|
115
|
-
}
|
|
116
|
-
}
|
|
117
|
-
} else {
|
|
118
|
-
// expand
|
|
119
|
-
for (let i = lastTabIndex + 1; i < tabsNumber; ++i) {
|
|
120
|
-
let width = tabs[i];
|
|
121
|
-
if (monospaced && widths.tabs[i] > monospacedWidth) {
|
|
122
|
-
monospacedWidth = widths.tabs[i];
|
|
123
|
-
tabs = tabs.map(getMonospacedWidth);
|
|
124
|
-
width = monospacedWidth + (monospacedWidth - width) * (lastTabIndex + 1);
|
|
125
|
-
}
|
|
126
|
-
if (collapsedLength === 1) {
|
|
127
|
-
width -= more;
|
|
128
|
-
}
|
|
129
|
-
if (freeSpace <= width) {
|
|
130
|
-
break;
|
|
131
|
-
}
|
|
132
|
-
freeSpace -= width;
|
|
133
|
-
--collapsedLength;
|
|
134
|
-
++lastTabIndex;
|
|
135
|
-
}
|
|
136
|
-
}
|
|
137
|
-
if (collapsedLength || compact) {
|
|
138
|
-
spaceForAddon = container - getListWidth();
|
|
139
|
-
if (collapsedLength) {
|
|
140
|
-
compact = true;
|
|
141
|
-
} else if (spaceForAddon >= addonMinWidth) {
|
|
142
|
-
compact = false;
|
|
143
|
-
searching = false;
|
|
144
|
-
}
|
|
145
|
-
}
|
|
146
|
-
const newState = {
|
|
147
|
-
compact,
|
|
148
|
-
searching,
|
|
149
|
-
collapsedLength,
|
|
150
|
-
monospacedWidth
|
|
151
|
-
};
|
|
152
|
-
for (const key of Object.keys(newState)) {
|
|
153
|
-
if (JSON.stringify(newState[key]) === JSON.stringify(this.state[key])) {
|
|
154
|
-
delete newState[key];
|
|
155
|
-
}
|
|
156
|
-
}
|
|
157
|
-
if (Object.keys(newState).length) {
|
|
158
|
-
this.setState(newState, () => {
|
|
159
|
-
if (typeof newState.collapsedLength !== 'undefined' && this.state.collapsedLength !== newState.collapsedLength) {
|
|
160
|
-
this.checkAdaptive();
|
|
161
|
-
}
|
|
162
|
-
});
|
|
163
|
-
}
|
|
164
|
-
});
|
|
165
|
-
(0, _defineProperty2.default)(this, "handleStartSearching", () => {
|
|
166
|
-
this.setState({
|
|
167
|
-
searching: true
|
|
168
|
-
});
|
|
169
|
-
});
|
|
170
|
-
(0, _defineProperty2.default)(this, "handleCancelSearching", () => {
|
|
171
|
-
this.setState({
|
|
172
|
-
searching: false
|
|
173
|
-
}, this.checkAdaptive);
|
|
174
|
-
});
|
|
175
|
-
(0, _defineProperty2.default)(this, "handleResize", () => {
|
|
176
|
-
const {
|
|
177
|
-
baseClassName
|
|
178
|
-
} = this.props;
|
|
179
|
-
if (this.tabsnavRef) {
|
|
180
|
-
const tabElements = this.tabsnavRef.querySelectorAll(`.${baseClassName}__tab-list--fake .${baseClassName}__tab`);
|
|
181
|
-
const more = tabElements[tabElements.length - 1];
|
|
182
|
-
const tabs = Array.prototype.slice.call(tabElements, 0, -1).map(el => el.offsetWidth);
|
|
183
|
-
this.widths = {
|
|
184
|
-
tabs,
|
|
185
|
-
more: more.offsetWidth,
|
|
186
|
-
container: this.tabsnavRef.offsetWidth,
|
|
187
|
-
margin: more.offsetWidth - (more.querySelector(`.${baseClassName}__link`)?.offsetWidth ?? 0)
|
|
188
|
-
};
|
|
189
|
-
}
|
|
190
|
-
this.checkAdaptive();
|
|
191
|
-
});
|
|
192
|
-
(0, _defineProperty2.default)(this, "handleAddonResize", contentRect => {
|
|
193
|
-
this.addon = contentRect.bounds;
|
|
194
|
-
this.checkAdaptive();
|
|
195
|
-
});
|
|
196
|
-
(0, _defineProperty2.default)(this, "renderTabItem", (tab, index, tabMode) => {
|
|
197
|
-
const {
|
|
198
|
-
baseClassName
|
|
199
|
-
} = this.props;
|
|
200
|
-
const {
|
|
201
|
-
monospacedWidth,
|
|
202
|
-
active
|
|
203
|
-
} = this.state;
|
|
204
|
-
if (!tab || tab.type !== _Tab.default) {
|
|
205
|
-
return null;
|
|
206
|
-
}
|
|
207
|
-
const {
|
|
208
|
-
title,
|
|
209
|
-
label,
|
|
210
|
-
icon,
|
|
211
|
-
onActivate,
|
|
212
|
-
onClose,
|
|
213
|
-
component: Tag = 'a',
|
|
214
|
-
...tabProps
|
|
215
|
-
} = tab.props;
|
|
216
|
-
const selected = index + 1 === active;
|
|
217
|
-
const key = index.toString();
|
|
218
|
-
const tabIcon = _Icon.default.create(icon, {
|
|
219
|
-
size: _Icon.ICON_SIZE_16,
|
|
220
|
-
className: `${baseClassName}__tab-icon`
|
|
221
|
-
});
|
|
222
|
-
const tabLabel = this.renderTabLabel(tabMode, label);
|
|
223
|
-
const tabClose = this.renderTabClose(tabMode, onClose);
|
|
224
|
-
const handleClick = () => this.onClick(index + 1);
|
|
225
|
-
tabProps.tabIndex = tabProps.tabIndex || 0;
|
|
226
|
-
tabProps.onKeyDown = (0, _utils.wrapFunction)(tabProps.onKeyDown, e => {
|
|
227
|
-
if (e.key === 'Enter') {
|
|
228
|
-
e.currentTarget.click();
|
|
229
|
-
}
|
|
230
|
-
});
|
|
231
|
-
if (tabMode === 'menu-item') {
|
|
232
|
-
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_Menu.MenuItem, {
|
|
233
|
-
icon: tabIcon,
|
|
234
|
-
label: /*#__PURE__*/(0, _jsxRuntime.jsxs)(_react.Fragment, {
|
|
235
|
-
children: [tabLabel, tabClose]
|
|
236
|
-
}),
|
|
237
|
-
active: selected,
|
|
238
|
-
onClick: handleClick,
|
|
239
|
-
className: `${baseClassName}__menu-item`,
|
|
240
|
-
component: Tag,
|
|
241
|
-
...tabProps,
|
|
242
|
-
children: title
|
|
243
|
-
}, key);
|
|
244
|
-
}
|
|
245
|
-
return /*#__PURE__*/(0, _jsxRuntime.jsx)("li", {
|
|
246
|
-
className: (0, _classnames.default)(`${baseClassName}__tab`, selected && `${baseClassName}__tab--selected`, tabClose && `${baseClassName}__tab--closable`),
|
|
247
|
-
role: "presentation",
|
|
248
|
-
children: /*#__PURE__*/(0, _jsxRuntime.jsxs)(Tag, {
|
|
249
|
-
className: `${baseClassName}__link`,
|
|
250
|
-
role: "tab",
|
|
251
|
-
"aria-selected": selected || undefined,
|
|
252
|
-
style: {
|
|
253
|
-
width: monospacedWidth || undefined
|
|
254
|
-
},
|
|
255
|
-
onClick: handleClick,
|
|
256
|
-
...tabProps,
|
|
257
|
-
children: [tabIcon, /*#__PURE__*/(0, _jsxRuntime.jsx)("span", {
|
|
258
|
-
className: `${baseClassName}__tab-title`,
|
|
259
|
-
children: title
|
|
260
|
-
}), tabLabel, tabClose]
|
|
261
|
-
})
|
|
262
|
-
}, key);
|
|
263
|
-
});
|
|
264
|
-
}
|
|
265
|
-
static getDerivedStateFromProps(props, state) {
|
|
266
|
-
const {
|
|
267
|
-
active
|
|
268
|
-
} = props;
|
|
269
|
-
const {
|
|
270
|
-
prevActive
|
|
271
|
-
} = state;
|
|
272
|
-
const nextState = {};
|
|
273
|
-
if (active && active !== prevActive) {
|
|
274
|
-
nextState.active = active;
|
|
275
|
-
}
|
|
276
|
-
nextState.prevActive = active;
|
|
277
|
-
return nextState;
|
|
278
|
-
}
|
|
279
|
-
componentDidUpdate() {
|
|
280
|
-
if (!this.widths || _react.Children.count(this.props.children) !== this.widths.tabs.length) {
|
|
281
|
-
setTimeout(() => this.handleResize());
|
|
282
|
-
}
|
|
283
|
-
}
|
|
284
|
-
onClick(active) {
|
|
285
|
-
this.setState({
|
|
286
|
-
active
|
|
287
|
-
});
|
|
288
|
-
const tab = Array.isArray(this.props.children) ? this.props.children[active - 1] : this.props.children;
|
|
26
|
+
const Tabs = _ref => {
|
|
27
|
+
let {
|
|
28
|
+
baseClassName = `${_constants.CLS_PREFIX}tabs`,
|
|
29
|
+
className,
|
|
30
|
+
addon,
|
|
31
|
+
placeholder,
|
|
32
|
+
children,
|
|
33
|
+
active: externalActive,
|
|
34
|
+
addonMinWidth,
|
|
35
|
+
monospaced,
|
|
36
|
+
search,
|
|
37
|
+
...props
|
|
38
|
+
} = _ref;
|
|
39
|
+
const addonElement = addon || placeholder;
|
|
40
|
+
const tabNavRef = (0, _react.useRef)(null);
|
|
41
|
+
const tabListRef = (0, _react.useRef)(null);
|
|
42
|
+
const fakeAddonRef = (0, _react.useRef)(null);
|
|
43
|
+
const childrenCount = _react.Children.count(children);
|
|
44
|
+
const [active, setActive] = (0, _useActive.useActive)(externalActive);
|
|
45
|
+
const {
|
|
46
|
+
monospacedWidth,
|
|
47
|
+
recalculateWidths,
|
|
48
|
+
compact,
|
|
49
|
+
visibleLength
|
|
50
|
+
} = (0, _useWidths.useWidths)({
|
|
51
|
+
monospaced,
|
|
52
|
+
tabNavRef,
|
|
53
|
+
tabListRef,
|
|
54
|
+
fakeAddonRef,
|
|
55
|
+
baseClassName,
|
|
56
|
+
childrenCount
|
|
57
|
+
});
|
|
58
|
+
const handleTabClick = active => {
|
|
59
|
+
setActive(active);
|
|
60
|
+
const tab = Array.isArray(children) ? children[active - 1] : children;
|
|
289
61
|
tab?.props?.onActivate?.();
|
|
290
|
-
}
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
baseClassName
|
|
294
|
-
} = this.props;
|
|
295
|
-
if (typeof label === 'string') {
|
|
296
|
-
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_Label.default, {
|
|
297
|
-
className: `${baseClassName}__${tabMode}-label`,
|
|
298
|
-
intent: "danger",
|
|
299
|
-
children: label
|
|
300
|
-
});
|
|
301
|
-
}
|
|
302
|
-
if (/*#__PURE__*/(0, _react.isValidElement)(label)) {
|
|
303
|
-
return /*#__PURE__*/(0, _react.cloneElement)(label, {
|
|
304
|
-
className: (0, _classnames.default)(`${baseClassName}__${tabMode}-label`, label.props.className)
|
|
305
|
-
});
|
|
306
|
-
}
|
|
307
|
-
return null;
|
|
308
|
-
}
|
|
309
|
-
renderTabClose(tabMode, onClose) {
|
|
310
|
-
const {
|
|
311
|
-
baseClassName
|
|
312
|
-
} = this.props;
|
|
313
|
-
if (typeof onClose === 'function') {
|
|
314
|
-
return /*#__PURE__*/(0, _jsxRuntime.jsx)("button", {
|
|
315
|
-
className: `${baseClassName}__${tabMode}-close`,
|
|
316
|
-
type: "button",
|
|
317
|
-
onClick: e => {
|
|
318
|
-
e.preventDefault();
|
|
319
|
-
e.stopPropagation();
|
|
320
|
-
onClose(e);
|
|
321
|
-
},
|
|
322
|
-
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_Icon.default, {
|
|
323
|
-
className: `${baseClassName}__${tabMode}-close-icon`,
|
|
324
|
-
name: "cross-mark"
|
|
325
|
-
})
|
|
326
|
-
});
|
|
327
|
-
}
|
|
62
|
+
};
|
|
63
|
+
const [searching, setSearching] = (0, _react.useState)(false);
|
|
64
|
+
if (!childrenCount) {
|
|
328
65
|
return null;
|
|
329
66
|
}
|
|
330
|
-
|
|
331
|
-
const {
|
|
332
|
-
baseClassName,
|
|
333
|
-
children
|
|
334
|
-
} = this.props;
|
|
335
|
-
const childrenCount = _react.Children.count(children);
|
|
336
|
-
if (!childrenCount || !children) {
|
|
337
|
-
return null;
|
|
338
|
-
}
|
|
339
|
-
return /*#__PURE__*/(0, _jsxRuntime.jsxs)("ul", {
|
|
340
|
-
className: (0, _classnames.default)(`${baseClassName}__tab-list`, `${baseClassName}__tab-list--fake`),
|
|
341
|
-
children: [_react.Children.map(children, tab => {
|
|
342
|
-
if (!tab || tab.type !== _Tab.default) {
|
|
343
|
-
return null;
|
|
344
|
-
}
|
|
345
|
-
const {
|
|
346
|
-
title,
|
|
347
|
-
label,
|
|
348
|
-
icon,
|
|
349
|
-
onActivate,
|
|
350
|
-
onClose,
|
|
351
|
-
...tabProps
|
|
352
|
-
} = tab.props;
|
|
353
|
-
const iconBlock = _Icon.default.create(icon, {
|
|
354
|
-
size: _Icon.ICON_SIZE_16,
|
|
355
|
-
className: `${baseClassName}__tab-icon`
|
|
356
|
-
});
|
|
357
|
-
const closeBlock = this.renderTabClose('tab', onClose);
|
|
358
|
-
return /*#__PURE__*/(0, _jsxRuntime.jsxs)("li", {
|
|
359
|
-
className: (0, _classnames.default)(`${baseClassName}__tab`, closeBlock && `${baseClassName}__tab--closable`),
|
|
360
|
-
children: [/*#__PURE__*/(0, _jsxRuntime.jsxs)("a", {
|
|
361
|
-
className: `${baseClassName}__link`,
|
|
362
|
-
tabIndex: -1,
|
|
363
|
-
style: tabProps.style,
|
|
364
|
-
children: [iconBlock, /*#__PURE__*/(0, _jsxRuntime.jsx)("span", {
|
|
365
|
-
className: `${baseClassName}__tab-title`,
|
|
366
|
-
children: title
|
|
367
|
-
}), this.renderTabLabel('tab', label)]
|
|
368
|
-
}), closeBlock]
|
|
369
|
-
}, `${title}`);
|
|
370
|
-
}), /*#__PURE__*/(0, _jsxRuntime.jsx)("li", {
|
|
371
|
-
className: (0, _classnames.default)(`${baseClassName}__tab`, `${baseClassName}__tab--more`),
|
|
372
|
-
children: /*#__PURE__*/(0, _jsxRuntime.jsx)("a", {
|
|
373
|
-
className: `${baseClassName}__link`,
|
|
374
|
-
tabIndex: -1,
|
|
375
|
-
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_Icon.default, {
|
|
376
|
-
name: "three-dots-horizontal"
|
|
377
|
-
})
|
|
378
|
-
})
|
|
379
|
-
})]
|
|
380
|
-
});
|
|
381
|
-
}
|
|
382
|
-
createTabItems() {
|
|
383
|
-
const {
|
|
384
|
-
children
|
|
385
|
-
} = this.props;
|
|
386
|
-
const {
|
|
387
|
-
collapsedLength
|
|
388
|
-
} = this.state;
|
|
389
|
-
const visibleItems = [];
|
|
390
|
-
const hiddenItems = [];
|
|
391
|
-
const lastTabIndex = _react.Children.count(children) - 1 - collapsedLength;
|
|
392
|
-
_react.Children.forEach(children, (child, index) => {
|
|
393
|
-
const hidden = index > lastTabIndex;
|
|
394
|
-
const tabMode = hidden ? 'menu-item' : 'tab';
|
|
395
|
-
const renderedTab = this.renderTabItem(child, index, tabMode);
|
|
396
|
-
if (renderedTab) {
|
|
397
|
-
(hidden ? hiddenItems : visibleItems).push(renderedTab);
|
|
398
|
-
}
|
|
399
|
-
});
|
|
400
|
-
return {
|
|
401
|
-
visibleItems,
|
|
402
|
-
hiddenItems
|
|
403
|
-
};
|
|
404
|
-
}
|
|
405
|
-
renderTabList() {
|
|
406
|
-
const {
|
|
407
|
-
baseClassName,
|
|
408
|
-
children
|
|
409
|
-
} = this.props;
|
|
410
|
-
const {
|
|
411
|
-
active
|
|
412
|
-
} = this.state;
|
|
413
|
-
if (!_react.Children.toArray(children).length) {
|
|
414
|
-
return null;
|
|
415
|
-
}
|
|
416
|
-
const {
|
|
417
|
-
visibleItems,
|
|
418
|
-
hiddenItems
|
|
419
|
-
} = this.createTabItems();
|
|
420
|
-
const moreSelected = active > visibleItems.length;
|
|
421
|
-
return /*#__PURE__*/(0, _jsxRuntime.jsxs)("ul", {
|
|
422
|
-
className: `${baseClassName}__tab-list`,
|
|
423
|
-
role: "tablist",
|
|
424
|
-
children: [visibleItems, hiddenItems.length > 0 && /*#__PURE__*/(0, _jsxRuntime.jsx)("li", {
|
|
425
|
-
ref: ref => this.moreTabsRef = ref,
|
|
426
|
-
className: (0, _classnames.default)(`${baseClassName}__tab`, moreSelected && `${baseClassName}__tab--selected`, `${baseClassName}__tab--more`),
|
|
427
|
-
role: "presentation",
|
|
428
|
-
"aria-selected": moreSelected || undefined,
|
|
429
|
-
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_Dropdown.default, {
|
|
430
|
-
className: `${baseClassName}__dropdown`,
|
|
431
|
-
menu: /*#__PURE__*/(0, _jsxRuntime.jsx)(_Menu.default, {
|
|
432
|
-
children: hiddenItems
|
|
433
|
-
}),
|
|
434
|
-
menuPlacement: "bottom-end",
|
|
435
|
-
children: /*#__PURE__*/(0, _jsxRuntime.jsx)("a", {
|
|
436
|
-
className: `${baseClassName}__link`,
|
|
437
|
-
role: "tab",
|
|
438
|
-
tabIndex: 0,
|
|
439
|
-
"aria-selected": moreSelected || undefined,
|
|
440
|
-
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_Icon.default, {
|
|
441
|
-
name: "three-dots-horizontal"
|
|
442
|
-
})
|
|
443
|
-
})
|
|
444
|
-
})
|
|
445
|
-
})]
|
|
446
|
-
});
|
|
447
|
-
}
|
|
448
|
-
renderSearchBar(searchProps) {
|
|
449
|
-
const {
|
|
450
|
-
baseClassName,
|
|
451
|
-
search
|
|
452
|
-
} = this.props;
|
|
67
|
+
const renderSearchBar = () => {
|
|
453
68
|
if (!search) {
|
|
454
69
|
return null;
|
|
455
70
|
}
|
|
456
|
-
const
|
|
457
|
-
|
|
458
|
-
|
|
71
|
+
const handleStartSearching = () => setSearching(true);
|
|
72
|
+
const handleCancelSearching = () => setSearching(false);
|
|
73
|
+
const searchProps = {
|
|
74
|
+
className: `${baseClassName}__search-bar`,
|
|
75
|
+
collapsable: compact,
|
|
76
|
+
onExpand: handleStartSearching,
|
|
77
|
+
onCollapse: handleCancelSearching,
|
|
78
|
+
...(searching ? {
|
|
79
|
+
autoFocus: true,
|
|
80
|
+
responsive: false,
|
|
81
|
+
maxWidth: 'none',
|
|
82
|
+
minWidth: 'unset'
|
|
83
|
+
} : {})
|
|
84
|
+
};
|
|
459
85
|
const clone = /*#__PURE__*/(0, _react.cloneElement)(search, searchProps);
|
|
460
86
|
if (compact) {
|
|
461
87
|
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_ResponsiveContext.default.Provider, {
|
|
@@ -467,112 +93,47 @@ class Tabs extends _react.Component {
|
|
|
467
93
|
});
|
|
468
94
|
}
|
|
469
95
|
return clone;
|
|
96
|
+
};
|
|
97
|
+
const addonStyle = {};
|
|
98
|
+
if (search && !compact) {
|
|
99
|
+
addonStyle.maxWidth = search.props.maxWidth;
|
|
470
100
|
}
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
};
|
|
502
|
-
if (compact) {
|
|
503
|
-
if (searching) {
|
|
504
|
-
searchProps.maxWidth = undefined;
|
|
505
|
-
searchProps.minWidth = undefined;
|
|
506
|
-
searchProps.autoFocus = true;
|
|
507
|
-
searchProps.responsive = false;
|
|
508
|
-
} else {
|
|
509
|
-
searchProps.onSearch = this.handleStartSearching;
|
|
510
|
-
}
|
|
511
|
-
searchBlock = this.renderSearchBar(searchProps);
|
|
512
|
-
} else if (addonElement) {
|
|
513
|
-
searchProps.key = 1;
|
|
514
|
-
addonBlock = /*#__PURE__*/(0, _jsxRuntime.jsxs)(_jsxRuntime.Fragment, {
|
|
515
|
-
children: [this.renderSearchBar(searchProps), /*#__PURE__*/(0, _react.cloneElement)(addonElement, {
|
|
516
|
-
key: 2
|
|
517
|
-
})]
|
|
518
|
-
});
|
|
519
|
-
} else {
|
|
520
|
-
addonProps.style = {
|
|
521
|
-
maxWidth: search.props.maxWidth
|
|
522
|
-
};
|
|
523
|
-
addonBlock = this.renderSearchBar(searchProps);
|
|
524
|
-
}
|
|
525
|
-
}
|
|
526
|
-
return /*#__PURE__*/(0, _jsxRuntime.jsxs)("div", {
|
|
527
|
-
className: (0, _classnames.default)(baseClassName, className),
|
|
528
|
-
...props,
|
|
529
|
-
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_reactMeasure.default, {
|
|
530
|
-
onResize: this.handleResize,
|
|
531
|
-
innerRef: ref => this.tabsnavRef = ref,
|
|
532
|
-
children: _ref => {
|
|
533
|
-
let {
|
|
534
|
-
measureRef
|
|
535
|
-
} = _ref;
|
|
536
|
-
return /*#__PURE__*/(0, _jsxRuntime.jsxs)("div", {
|
|
537
|
-
className: (0, _classnames.default)(`${baseClassName}__nav`, compact && `${baseClassName}__nav--compact`, searching && `${baseClassName}__nav--searching`, search && `${baseClassName}__nav--search`),
|
|
538
|
-
ref: measureRef,
|
|
539
|
-
children: [this.renderTabList(), /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactMeasure.default, {
|
|
540
|
-
onResize: this.handleResize,
|
|
541
|
-
children: _ref2 => {
|
|
542
|
-
let {
|
|
543
|
-
measureRef: ref
|
|
544
|
-
} = _ref2;
|
|
545
|
-
const fakeTabs = this.renderFakeTabs();
|
|
546
|
-
return fakeTabs ? /*#__PURE__*/(0, _react.cloneElement)(fakeTabs, {
|
|
547
|
-
ref
|
|
548
|
-
}) : null;
|
|
549
|
-
}
|
|
550
|
-
}), searchBlock, addonBlock && /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactMeasure.default, {
|
|
551
|
-
onResize: this.handleAddonResize,
|
|
552
|
-
bounds: true,
|
|
553
|
-
children: _ref3 => {
|
|
554
|
-
let {
|
|
555
|
-
measureRef: ref
|
|
556
|
-
} = _ref3;
|
|
557
|
-
return /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
|
|
558
|
-
className: `${baseClassName}__addon`,
|
|
559
|
-
ref: ref,
|
|
560
|
-
...addonProps,
|
|
561
|
-
children: addonBlock
|
|
562
|
-
});
|
|
563
|
-
}
|
|
564
|
-
})]
|
|
565
|
-
});
|
|
566
|
-
}
|
|
567
|
-
}), /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
|
|
568
|
-
className: `${baseClassName}__tab-panel`,
|
|
569
|
-
role: "tabpanel",
|
|
570
|
-
children: _react.Children.map(children, (tab, index) => index + 1 === this.state.active ? tab : null)
|
|
101
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsxs)("div", {
|
|
102
|
+
className: (0, _classnames.default)(baseClassName, className),
|
|
103
|
+
...props,
|
|
104
|
+
children: [compact && addonElement && /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
|
|
105
|
+
className: `${baseClassName}__addon ${baseClassName}__addon--compact`,
|
|
106
|
+
children: addonElement
|
|
107
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsxs)("div", {
|
|
108
|
+
className: (0, _classnames.default)(`${baseClassName}__nav`, compact && `${baseClassName}__nav--compact`, searching && `${baseClassName}__nav--searching`, search && `${baseClassName}__nav--search`),
|
|
109
|
+
ref: tabNavRef,
|
|
110
|
+
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_TabList.default, {
|
|
111
|
+
tabListRef: tabListRef,
|
|
112
|
+
active: active,
|
|
113
|
+
onTabClick: handleTabClick,
|
|
114
|
+
visibleLength: visibleLength,
|
|
115
|
+
monospacedWidth: monospacedWidth,
|
|
116
|
+
baseClassName: baseClassName,
|
|
117
|
+
children: children
|
|
118
|
+
}), compact && renderSearchBar(), !compact && (addonElement || search) && /*#__PURE__*/(0, _jsxRuntime.jsxs)("div", {
|
|
119
|
+
className: `${baseClassName}__addon`,
|
|
120
|
+
style: addonStyle,
|
|
121
|
+
children: [renderSearchBar(), addonElement]
|
|
122
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_FakeTabs.default, {
|
|
123
|
+
onResize: recalculateWidths,
|
|
124
|
+
baseClassName: baseClassName,
|
|
125
|
+
children: children
|
|
126
|
+
}), addonElement && /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
|
|
127
|
+
ref: fakeAddonRef,
|
|
128
|
+
className: `${baseClassName}__addon-fake-wrapper`,
|
|
129
|
+
"aria-hidden": true,
|
|
130
|
+
children: addonElement
|
|
571
131
|
})]
|
|
572
|
-
})
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
});
|
|
132
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
|
|
133
|
+
className: `${baseClassName}__tab-panel`,
|
|
134
|
+
role: "tabpanel",
|
|
135
|
+
children: _react.Children.map(children, (tab, index) => index + 1 === active ? tab : null)
|
|
136
|
+
})]
|
|
137
|
+
});
|
|
138
|
+
};
|
|
578
139
|
var _default = exports.default = Tabs;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.useActive = void 0;
|
|
7
|
+
var _react = require("react");
|
|
8
|
+
// Copyright 1999-2025. WebPros International GmbH. All rights reserved.
|
|
9
|
+
|
|
10
|
+
const useActive = externalActive => {
|
|
11
|
+
const [active, setActive] = (0, _react.useState)(externalActive || 1);
|
|
12
|
+
const [prevExternalActive, setPrevExternalActive] = (0, _react.useState)(externalActive);
|
|
13
|
+
if (externalActive && externalActive !== prevExternalActive) {
|
|
14
|
+
setPrevExternalActive(externalActive);
|
|
15
|
+
setActive(externalActive);
|
|
16
|
+
}
|
|
17
|
+
return [active, setActive];
|
|
18
|
+
};
|
|
19
|
+
exports.useActive = useActive;
|