@cloud-ru/ds-tabs 1.0.14 → 1.0.15-preview-2e0a6d5c.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/README.md +31 -27
- package/dist/cjs/components/ScrollButton/ScrollButton.d.ts +3 -3
- package/dist/cjs/components/ScrollButton/ScrollButton.js +2 -2
- package/dist/cjs/components/ScrollButton/styles.module.css +16 -16
- package/dist/cjs/components/Tab/Tab.d.ts +1 -1
- package/dist/cjs/components/Tab/Tab.js +8 -7
- package/dist/cjs/components/Tab/styles.module.css +77 -58
- package/dist/cjs/components/TabBar/TabBar.d.ts +8 -10
- package/dist/cjs/components/TabBar/TabBar.js +16 -11
- package/dist/cjs/components/TabBar/hooks.d.ts +5 -1
- package/dist/cjs/components/TabBar/hooks.js +5 -2
- package/dist/cjs/components/TabBar/styles.module.css +43 -29
- package/dist/cjs/components/Tabs/Tabs.d.ts +4 -1
- package/dist/cjs/components/Tabs/Tabs.js +3 -9
- package/dist/cjs/constants.d.ts +3 -3
- package/dist/cjs/constants.js +4 -4
- package/dist/cjs/context.d.ts +4 -2
- package/dist/cjs/context.js +2 -0
- package/dist/cjs/style.css +136 -103
- package/dist/cjs/types.d.ts +5 -3
- package/dist/esm/components/ScrollButton/ScrollButton.d.ts +3 -3
- package/dist/esm/components/ScrollButton/ScrollButton.js +2 -2
- package/dist/esm/components/ScrollButton/styles.module.css +16 -16
- package/dist/esm/components/Tab/Tab.d.ts +1 -1
- package/dist/esm/components/Tab/Tab.js +9 -8
- package/dist/esm/components/Tab/styles.module.css +77 -58
- package/dist/esm/components/TabBar/TabBar.d.ts +8 -10
- package/dist/esm/components/TabBar/TabBar.js +17 -12
- package/dist/esm/components/TabBar/hooks.d.ts +5 -1
- package/dist/esm/components/TabBar/hooks.js +5 -2
- package/dist/esm/components/TabBar/styles.module.css +43 -29
- package/dist/esm/components/Tabs/Tabs.d.ts +4 -1
- package/dist/esm/components/Tabs/Tabs.js +3 -9
- package/dist/esm/constants.d.ts +3 -3
- package/dist/esm/constants.js +3 -3
- package/dist/esm/context.d.ts +4 -2
- package/dist/esm/context.js +2 -0
- package/dist/esm/style.css +136 -103
- package/dist/esm/types.d.ts +5 -3
- package/dist/tsconfig.cjs.tsbuildinfo +1 -1
- package/dist/tsconfig.esm.tsbuildinfo +1 -1
- package/package.json +8 -7
- package/src/components/ScrollButton/ScrollButton.tsx +4 -4
- package/src/components/ScrollButton/styles.module.scss +4 -6
- package/src/components/Tab/Tab.tsx +15 -13
- package/src/components/Tab/styles.module.scss +41 -45
- package/src/components/TabBar/TabBar.tsx +36 -35
- package/src/components/TabBar/hooks.ts +9 -2
- package/src/components/TabBar/styles.module.scss +68 -29
- package/src/components/Tabs/Tabs.tsx +13 -14
- package/src/constants.ts +3 -3
- package/src/context.tsx +2 -0
- package/src/types.ts +5 -3
package/README.md
CHANGED
|
@@ -43,10 +43,10 @@ import { Tabs } from '@cloud-ru/ds-tabs'
|
|
|
43
43
|
### Анатомия
|
|
44
44
|
|
|
45
45
|
#### Orientation
|
|
46
|
-
`horizontal` — табы в строку (дефолт), `vertical` — колонкой (для боковых навигаций).
|
|
46
|
+
Проп `orientation` компонента `Tabs` задаёт ориентацию: `horizontal` — табы в строку (дефолт), `vertical` — колонкой (для боковых навигаций).
|
|
47
47
|
|
|
48
|
-
####
|
|
49
|
-
`
|
|
48
|
+
#### Variant
|
|
49
|
+
`primary` — по умолчанию, `secondary` — для навигации внутри контента.
|
|
50
50
|
|
|
51
51
|
### Примеры использования
|
|
52
52
|
|
|
@@ -79,8 +79,13 @@ export function Uncontrolled() {
|
|
|
79
79
|
| `className` | `string` | — | Дополнительный класс на корневой контейнер |
|
|
80
80
|
| `defaultValue` | `string` | — | Выбранная вкладка по умолчанию |
|
|
81
81
|
| `onChange` | `((id: T) => void)` | — | Колбек выбора вкладки |
|
|
82
|
+
| `orientation` | `"horizontal"` \| `"vertical"` | `horizontal` | Ориентация вкладок |
|
|
82
83
|
| `value` | `string` | — | Текущая вкладка |
|
|
83
84
|
|
|
85
|
+
##### Related types
|
|
86
|
+
|
|
87
|
+
- `Orientation` = `"horizontal"` \| `"vertical"`
|
|
88
|
+
|
|
84
89
|
## Tab
|
|
85
90
|
|
|
86
91
|
Отдельная вкладка в TabBar — поддерживает label, counter и disabled.
|
|
@@ -94,8 +99,8 @@ export function Uncontrolled() {
|
|
|
94
99
|
|
|
95
100
|
### Анатомия
|
|
96
101
|
|
|
97
|
-
####
|
|
98
|
-
|
|
102
|
+
#### Variant
|
|
103
|
+
Вариант таба: `primary` — по умолчанию, `secondary` — для навигации внутри контента. Наследуется от `TabBar`.
|
|
99
104
|
|
|
100
105
|
#### Marker position
|
|
101
106
|
Положение активного маркера: `before` — перед содержимым, `after` — после. Наследуется от `TabBar`.
|
|
@@ -111,7 +116,7 @@ export function WithCounter() {
|
|
|
111
116
|
return (
|
|
112
117
|
<Tabs defaultValue='inbox'>
|
|
113
118
|
<Tabs.TabBar>
|
|
114
|
-
<Tabs.Tab value='inbox' label='Входящие' counter={{
|
|
119
|
+
<Tabs.Tab value='inbox' label='Входящие' counter={{ value: 12 }} />
|
|
115
120
|
<Tabs.Tab value='archive' label='Архив' />
|
|
116
121
|
</Tabs.TabBar>
|
|
117
122
|
</Tabs>
|
|
@@ -152,42 +157,44 @@ export function Disabled() {
|
|
|
152
157
|
|
|
153
158
|
## TabBar
|
|
154
159
|
|
|
155
|
-
Панель табов — задаёт
|
|
160
|
+
Панель табов — задаёт вариант, ориентацию, позицию маркера и слот справа (afterContent) для дополнительных действий.
|
|
156
161
|
|
|
157
162
|
Панель переключателей табов. Задаёт:
|
|
158
163
|
|
|
159
|
-
- `
|
|
160
|
-
- `orientation
|
|
164
|
+
- `variant` — `primary` (по умолчанию, верхнеуровневый) или `secondary` (внутри контента).
|
|
165
|
+
- Ориентация задаётся через `Tabs.orientation`: `horizontal` (по умолчанию) или `vertical`.
|
|
161
166
|
- `markerPosition` — позиция активного маркера (`before` / `after`).
|
|
162
|
-
- `
|
|
167
|
+
- `afterContent` — действие справа от горизонтального списка или снизу от вертикального. При отсутствии содержимого вся обёртка скрыта; разделитель проходит вдоль всей панели.
|
|
168
|
+
|
|
169
|
+
При переполнении появляются кнопки прокрутки: слева/справа для горизонтальной панели и сверху/снизу для вертикальной. У достигнутого края кнопка скрывается. Для вертикальной прокрутки контейнеру `Tabs` нужна ограниченная высота, например родитель с `height: 240px`.
|
|
163
170
|
|
|
164
171
|
### Когда использовать
|
|
165
172
|
|
|
166
173
|
- Внутри `Tabs` как единственный контейнер списка кнопок-табов.
|
|
167
|
-
- Если нужно разместить дополнительные действия справа от табов (через слот `
|
|
174
|
+
- Если нужно разместить дополнительные действия справа от табов (через слот `afterContent`).
|
|
168
175
|
|
|
169
176
|
### Анатомия
|
|
170
177
|
|
|
171
178
|
#### Orientation
|
|
172
179
|
`horizontal` — бар в строку, `vertical` — колонкой.
|
|
173
180
|
|
|
174
|
-
####
|
|
175
|
-
`
|
|
181
|
+
#### Variant
|
|
182
|
+
`primary` — по умолчанию, `secondary` — для навигации внутри контента.
|
|
176
183
|
|
|
177
184
|
#### Marker position
|
|
178
185
|
Положение активного маркера относительно содержимого таба: `before` — перед, `after` — после.
|
|
179
186
|
|
|
180
187
|
### Примеры использования
|
|
181
188
|
|
|
182
|
-
####
|
|
189
|
+
#### Primary — верхнеуровневый
|
|
183
190
|
|
|
184
191
|
```tsx
|
|
185
|
-
import {
|
|
192
|
+
import { Tabs, VARIANT } from '@cloud-ru/ds-tabs';
|
|
186
193
|
|
|
187
|
-
export function
|
|
194
|
+
export function Primary() {
|
|
188
195
|
return (
|
|
189
196
|
<Tabs defaultValue='a'>
|
|
190
|
-
<Tabs.TabBar
|
|
197
|
+
<Tabs.TabBar variant={VARIANT.Primary}>
|
|
191
198
|
<Tabs.Tab value='a' label='Первая' />
|
|
192
199
|
<Tabs.Tab value='b' label='Вторая' />
|
|
193
200
|
</Tabs.TabBar>
|
|
@@ -203,8 +210,8 @@ import { ORIENTATION, Tabs } from '@cloud-ru/ds-tabs';
|
|
|
203
210
|
|
|
204
211
|
export function Vertical() {
|
|
205
212
|
return (
|
|
206
|
-
<Tabs defaultValue='a'>
|
|
207
|
-
<Tabs.TabBar
|
|
213
|
+
<Tabs defaultValue='a' orientation={ORIENTATION.Vertical}>
|
|
214
|
+
<Tabs.TabBar>
|
|
208
215
|
<Tabs.Tab value='a' label='Профиль' />
|
|
209
216
|
<Tabs.Tab value='b' label='Безопасность' />
|
|
210
217
|
</Tabs.TabBar>
|
|
@@ -219,23 +226,18 @@ export function Vertical() {
|
|
|
219
226
|
|
|
220
227
|
| Prop | Type | Default | Description |
|
|
221
228
|
|------|------|---------|-------------|
|
|
229
|
+
| `afterContent` | `ReactNode` | — | Слот действия: контент после списка табов — справа при горизонтальной <br/> ориентации, снизу при вертикальной. Разделитель проходит вдоль всей панели. |
|
|
222
230
|
| `children` | `TabProps` | — | Контент (элементы Tabs.Tab) |
|
|
223
231
|
| `className` | `string` | — | CSS-класс |
|
|
224
232
|
| `data-test-id` | `string` | — | |
|
|
225
|
-
| `
|
|
233
|
+
| `divider` | `boolean` | `true` | Показывать разделитель под/рядом с панелью табов |
|
|
226
234
|
| `markerPosition` | `"after"` \| `"before"` | `after` | Позиция маркера относительно таб-бара. <br/> Значения ориентационно-нейтральны, в Figma та же ось названа сторонами: <br/> `before` = Figma `top` (horizontal) / `left` (vertical), <br/> `after` = Figma `bottom` (horizontal) / `right` (vertical). |
|
|
227
|
-
| `
|
|
228
|
-
| `size` | `"l"` \| `"m"` | `l` | Размер панели табов: L — верхнеуровневый, M — на уровне контента |
|
|
229
|
-
| `slotActionButton` | `ReactNode` | — | Слот действия: контент после списка табов — справа при горизонтальной <br/> ориентации, снизу при вертикальной. Разделитель под ним не продолжается. |
|
|
235
|
+
| `variant` | `"primary"` \| `"secondary"` | `primary` | Вариант панели: primary — верхнеуровневый, secondary — на уровне контента |
|
|
230
236
|
|
|
231
237
|
##### Related types
|
|
232
238
|
|
|
233
239
|
- `MarkerPosition` = `"after"` \| `"before"`
|
|
234
240
|
|
|
235
|
-
- `Orientation` = `"horizontal"` \| `"vertical"`
|
|
236
|
-
|
|
237
|
-
- `Size` = `"l"` \| `"m"`
|
|
238
|
-
|
|
239
241
|
**TabProps**
|
|
240
242
|
|
|
241
243
|
| Prop | Type | Default | Description |
|
|
@@ -248,6 +250,8 @@ export function Vertical() {
|
|
|
248
250
|
| `onClick` | `((event: MouseEvent<HTMLButtonElement>) => void) \| undefined` | — | Колбек клика по кнопке переключения |
|
|
249
251
|
| `value` | `string` | — | Value вкладки |
|
|
250
252
|
|
|
253
|
+
- `Variant` = `"primary"` \| `"secondary"`
|
|
254
|
+
|
|
251
255
|
## TabContent
|
|
252
256
|
|
|
253
257
|
Контейнер контента таба — рендерится только когда его value совпадает с активным табом.
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { Direction, Orientation,
|
|
1
|
+
import { Direction, Orientation, Variant } from '../../types';
|
|
2
2
|
export type ScrollButtonProps = {
|
|
3
|
-
|
|
3
|
+
variant: Variant;
|
|
4
4
|
direction: Direction;
|
|
5
5
|
orientation: Orientation;
|
|
6
6
|
onClick(): void;
|
|
7
7
|
};
|
|
8
|
-
export declare function ScrollButton({
|
|
8
|
+
export declare function ScrollButton({ variant, onClick, direction, orientation }: ScrollButtonProps): import("react/jsx-runtime").JSX.Element;
|
|
@@ -14,6 +14,6 @@ const MAP_DIRECTION_TO_ICON = {
|
|
|
14
14
|
top: (0, jsx_runtime_1.jsx)(system_1.ChevronUpSVG, {}),
|
|
15
15
|
bottom: (0, jsx_runtime_1.jsx)(system_1.ChevronDownSVG, {}),
|
|
16
16
|
};
|
|
17
|
-
function ScrollButton({
|
|
18
|
-
return ((0, jsx_runtime_1.jsx)("div", { className: styles_module_scss_1.default.scrollButton, "data-direction": direction, "data-
|
|
17
|
+
function ScrollButton({ variant, onClick, direction, orientation }) {
|
|
18
|
+
return ((0, jsx_runtime_1.jsx)("div", { className: styles_module_scss_1.default.scrollButton, "data-direction": direction, "data-variant": variant, "data-orientation": orientation, "data-test-id": `tabs__scroll-button-${direction}`, children: (0, jsx_runtime_1.jsx)(button_1.Button, { tabIndex: -1, icon: MAP_DIRECTION_TO_ICON[direction], size: 's', view: 'elevated', appearance: 'neutral', onClick: onClick, "aria-label": `Scroll ${direction}` }) }));
|
|
19
19
|
}
|
|
@@ -4,29 +4,29 @@
|
|
|
4
4
|
align-items:center;
|
|
5
5
|
justify-content:center;
|
|
6
6
|
}
|
|
7
|
-
.scrollButton[data-
|
|
8
|
-
padding-left:var(--sn-tabs-anatomy-
|
|
7
|
+
.scrollButton[data-variant=secondary][data-direction=left]{
|
|
8
|
+
padding-left:var(--sn-tabs-anatomy-secondary-control-back-padding, var(--sn-primitive-dimension-2, 2px));
|
|
9
9
|
}
|
|
10
|
-
.scrollButton[data-
|
|
11
|
-
padding-right:var(--sn-tabs-anatomy-
|
|
10
|
+
.scrollButton[data-variant=secondary][data-direction=right]{
|
|
11
|
+
padding-right:var(--sn-tabs-anatomy-secondary-control-forward-padding, var(--sn-primitive-dimension-2, 2px));
|
|
12
12
|
}
|
|
13
|
-
.scrollButton[data-
|
|
14
|
-
padding-top:var(--sn-tabs-anatomy-
|
|
13
|
+
.scrollButton[data-variant=secondary][data-direction=top]{
|
|
14
|
+
padding-top:var(--sn-tabs-anatomy-secondary-control-back-padding, var(--sn-primitive-dimension-2, 2px));
|
|
15
15
|
}
|
|
16
|
-
.scrollButton[data-
|
|
17
|
-
padding-bottom:var(--sn-tabs-anatomy-
|
|
16
|
+
.scrollButton[data-variant=secondary][data-direction=bottom]{
|
|
17
|
+
padding-bottom:var(--sn-tabs-anatomy-secondary-control-forward-padding, var(--sn-primitive-dimension-2, 2px));
|
|
18
18
|
}
|
|
19
|
-
.scrollButton[data-
|
|
20
|
-
padding-left:var(--sn-tabs-anatomy-
|
|
19
|
+
.scrollButton[data-variant=primary][data-direction=left]{
|
|
20
|
+
padding-left:var(--sn-tabs-anatomy-primary-control-back-padding, var(--sn-primitive-dimension-4, 4px));
|
|
21
21
|
}
|
|
22
|
-
.scrollButton[data-
|
|
23
|
-
padding-right:var(--sn-tabs-anatomy-
|
|
22
|
+
.scrollButton[data-variant=primary][data-direction=right]{
|
|
23
|
+
padding-right:var(--sn-tabs-anatomy-primary-control-forward-padding, var(--sn-primitive-dimension-4, 4px));
|
|
24
24
|
}
|
|
25
|
-
.scrollButton[data-
|
|
26
|
-
padding-top:var(--sn-tabs-anatomy-
|
|
25
|
+
.scrollButton[data-variant=primary][data-direction=top]{
|
|
26
|
+
padding-top:var(--sn-tabs-anatomy-primary-control-back-padding, var(--sn-primitive-dimension-4, 4px));
|
|
27
27
|
}
|
|
28
|
-
.scrollButton[data-
|
|
29
|
-
padding-bottom:var(--sn-tabs-anatomy-
|
|
28
|
+
.scrollButton[data-variant=primary][data-direction=bottom]{
|
|
29
|
+
padding-bottom:var(--sn-tabs-anatomy-primary-control-forward-padding, var(--sn-primitive-dimension-4, 4px));
|
|
30
30
|
}
|
|
31
31
|
.scrollButton[data-direction=left]{
|
|
32
32
|
top:0;
|
|
@@ -13,7 +13,7 @@ export type TabProps = WithSupportProps<{
|
|
|
13
13
|
/** Счетчик, отображающийся внутри кнопки переключения */
|
|
14
14
|
counter?: {
|
|
15
15
|
/** Значение счетчика */
|
|
16
|
-
|
|
16
|
+
value: number;
|
|
17
17
|
/** Внешний вид */
|
|
18
18
|
appearance?: CounterProps['appearance'];
|
|
19
19
|
/** Роль, в которой применяется `appearance` счётчика */
|
|
@@ -6,6 +6,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
6
6
|
exports.Tab = Tab;
|
|
7
7
|
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
8
8
|
const counter_1 = require("@cloud-ru/ds-counter");
|
|
9
|
+
const truncate_string_1 = require("@cloud-ru/ds-truncate-string");
|
|
9
10
|
const typography_1 = require("@cloud-ru/ds-typography");
|
|
10
11
|
const utils_1 = require("@cloud-ru/ds-utils");
|
|
11
12
|
const classnames_1 = __importDefault(require("classnames"));
|
|
@@ -14,8 +15,8 @@ const constants_1 = require("../../constants");
|
|
|
14
15
|
const context_1 = require("../../context");
|
|
15
16
|
const utils_2 = require("../../utils");
|
|
16
17
|
const styles_module_scss_1 = __importDefault(require('./styles.module.css'));
|
|
17
|
-
const
|
|
18
|
-
[constants_1.
|
|
18
|
+
const MAP_VARIANT_TO_PROPS = {
|
|
19
|
+
[constants_1.VARIANT.Primary]: {
|
|
19
20
|
typographyProps: {
|
|
20
21
|
variant: 'title',
|
|
21
22
|
size: 'm',
|
|
@@ -24,7 +25,7 @@ const MAP_SIZE_TO_PROPS = {
|
|
|
24
25
|
size: 's',
|
|
25
26
|
},
|
|
26
27
|
},
|
|
27
|
-
[constants_1.
|
|
28
|
+
[constants_1.VARIANT.Secondary]: {
|
|
28
29
|
typographyProps: {
|
|
29
30
|
variant: 'title',
|
|
30
31
|
size: 's',
|
|
@@ -36,7 +37,7 @@ const MAP_SIZE_TO_PROPS = {
|
|
|
36
37
|
};
|
|
37
38
|
function Tab({ label, value, disabled = false, className, onClick, counter, ...otherProps }) {
|
|
38
39
|
const ref = (0, react_1.useRef)(null);
|
|
39
|
-
const { onSelect,
|
|
40
|
+
const { onSelect, variant, orientation, focusedTab, onFocus } = (0, context_1.useTabBarContext)();
|
|
40
41
|
const { selectedTab, setSelectedTab } = (0, context_1.useTabsContext)();
|
|
41
42
|
const selected = value === selectedTab;
|
|
42
43
|
(0, react_1.useEffect)(() => {
|
|
@@ -70,9 +71,9 @@ function Tab({ label, value, disabled = false, className, onClick, counter, ...o
|
|
|
70
71
|
const onFocusHandler = (0, react_1.useCallback)((e) => {
|
|
71
72
|
onFocus?.(e.target, value);
|
|
72
73
|
}, [onFocus, value]);
|
|
73
|
-
if (!
|
|
74
|
+
if (!variant) {
|
|
74
75
|
return null;
|
|
75
76
|
}
|
|
76
|
-
const { typographyProps, counterProps } =
|
|
77
|
-
return ((0, jsx_runtime_1.jsx)("button", { type: 'button', role: 'tab', "data-test-id": `tabs__tab-${value}`, ...(0, utils_1.extractSupportProps)(otherProps), id: value, ref: ref, "aria-disabled": disabled, "data-disabled": disabled || undefined, className: (0, classnames_1.default)(styles_module_scss_1.default.tab, className), "aria-controls": (0, utils_2.getTabContentId)(value), "aria-selected": selected, "data-selected": selected || undefined, "data-
|
|
77
|
+
const { typographyProps, counterProps } = MAP_VARIANT_TO_PROPS[variant];
|
|
78
|
+
return ((0, jsx_runtime_1.jsx)("button", { type: 'button', role: 'tab', "data-test-id": `tabs__tab-${value}`, ...(0, utils_1.extractSupportProps)(otherProps), id: value, ref: ref, "aria-disabled": disabled, "data-disabled": disabled || undefined, className: (0, classnames_1.default)(styles_module_scss_1.default.tab, className), "aria-controls": (0, utils_2.getTabContentId)(value), "aria-selected": selected, "data-selected": selected || undefined, "data-variant": variant, "data-orientation": orientation, onClick: handleClick, onFocus: onFocusHandler, onKeyDown: clickByEnterOrSpaceKey, children: (0, jsx_runtime_1.jsxs)(typography_1.Typography, { className: styles_module_scss_1.default.container, as: 'div', ...typographyProps, children: [orientation === constants_1.ORIENTATION.Vertical ? (0, jsx_runtime_1.jsx)(truncate_string_1.TruncateString, { text: label, className: styles_module_scss_1.default.label }) : label, counter && ((0, jsx_runtime_1.jsx)(counter_1.Counter, { className: styles_module_scss_1.default.counter, appearance: counter.appearance, roleAppearance: counter.roleAppearance, value: counter.value, "data-test-id": `tabs__tab-counter-${value}`, ...counterProps })), (0, jsx_runtime_1.jsx)("span", { "data-state-layer": true, "aria-hidden": true, "data-state": 'emptyNeutralOnBackground' })] }) }));
|
|
78
79
|
}
|
|
@@ -3,71 +3,69 @@
|
|
|
3
3
|
position:relative;
|
|
4
4
|
display:inline-flex;
|
|
5
5
|
flex-direction:row;
|
|
6
|
+
flex-shrink:0;
|
|
6
7
|
align-items:center;
|
|
7
8
|
box-sizing:border-box;
|
|
8
9
|
padding:0;
|
|
9
10
|
border-width:0;
|
|
10
11
|
color:var(--sn-theme-color-available-version-textSecondary, var(--sn-brand-color-text-version-secondary, rgba(0, 0, 0, 0.7803921569)));
|
|
12
|
+
white-space:nowrap;
|
|
11
13
|
background-color:transparent;
|
|
12
14
|
outline:none;
|
|
13
15
|
}
|
|
14
|
-
.tab[data-orientation=horizontal][data-
|
|
15
|
-
min-height:var(--sn-tabs-anatomy-
|
|
16
|
-
padding-left:var(--sn-tabs-anatomy-
|
|
17
|
-
padding-right:var(--sn-tabs-anatomy-
|
|
18
|
-
}
|
|
19
|
-
.tab[data-orientation=horizontal][data-
|
|
20
|
-
padding-left:var(--sn-tabs-anatomy-
|
|
21
|
-
padding-right:var(--sn-tabs-anatomy-
|
|
22
|
-
border-radius:var(--sn-tabs-anatomy-
|
|
23
|
-
min-width:var(--sn-tabs-anatomy-
|
|
24
|
-
gap:var(--sn-tabs-anatomy-
|
|
25
|
-
min-height:var(--sn-tabs-anatomy-
|
|
26
|
-
}
|
|
27
|
-
.tab[data-orientation=vertical][data-
|
|
28
|
-
padding-left:var(--sn-tabs-anatomy-
|
|
29
|
-
padding-right:var(--sn-tabs-anatomy-
|
|
30
|
-
min-height:var(--sn-tabs-anatomy-
|
|
31
|
-
}
|
|
32
|
-
.tab[data-orientation=vertical][data-
|
|
33
|
-
min-width:var(--sn-tabs-anatomy-
|
|
34
|
-
gap:var(--sn-tabs-anatomy-
|
|
35
|
-
min-height:var(--sn-tabs-anatomy-
|
|
36
|
-
border-radius:var(--sn-tabs-anatomy-
|
|
37
|
-
padding-left:var(--sn-tabs-anatomy-
|
|
38
|
-
padding-right:var(--sn-tabs-anatomy-
|
|
39
|
-
}
|
|
40
|
-
.tab[data-orientation=horizontal][data-
|
|
41
|
-
min-height:var(--sn-tabs-anatomy-
|
|
42
|
-
padding-left:var(--sn-tabs-anatomy-
|
|
43
|
-
padding-right:var(--sn-tabs-anatomy-
|
|
44
|
-
}
|
|
45
|
-
.tab[data-orientation=horizontal][data-
|
|
46
|
-
min-width:var(--sn-tabs-anatomy-
|
|
47
|
-
min-height:var(--sn-tabs-anatomy-
|
|
48
|
-
gap:var(--sn-tabs-anatomy-
|
|
49
|
-
border-radius:var(--sn-tabs-anatomy-
|
|
50
|
-
padding-left:var(--sn-tabs-anatomy-
|
|
51
|
-
padding-right:var(--sn-tabs-anatomy-
|
|
52
|
-
}
|
|
53
|
-
.tab[data-orientation=vertical][data-
|
|
54
|
-
padding-left:var(--sn-tabs-anatomy-
|
|
55
|
-
padding-right:var(--sn-tabs-anatomy-
|
|
56
|
-
min-height:var(--sn-tabs-anatomy-
|
|
57
|
-
}
|
|
58
|
-
.tab[data-orientation=vertical][data-
|
|
59
|
-
min-width:var(--sn-tabs-anatomy-
|
|
60
|
-
padding-left:var(--sn-tabs-anatomy-
|
|
61
|
-
padding-right:var(--sn-tabs-anatomy-
|
|
62
|
-
border-radius:var(--sn-tabs-anatomy-
|
|
63
|
-
gap:var(--sn-tabs-anatomy-
|
|
64
|
-
min-height:var(--sn-tabs-anatomy-
|
|
65
|
-
}
|
|
66
|
-
.tab[data-
|
|
67
|
-
padding-right:var(--sn-tabs-anatomy-size-m-tabsVertical-tabContainer-horizontalPadding, var(--sn-density-spacing-interval-m, var(--sn-platform-comfort-spacing-interval-m, var(--sn-primitive-dimension-24, 24px))));
|
|
68
|
-
padding-left:var(--sn-tabs-anatomy-size-m-tabsVertical-tabContainer-horizontalPadding, var(--sn-density-spacing-interval-m, var(--sn-platform-comfort-spacing-interval-m, var(--sn-primitive-dimension-24, 24px))));
|
|
69
|
-
}
|
|
70
|
-
.tab[data-selected=true], .tab:focus-visible, .tab:hover{
|
|
16
|
+
.tab[data-orientation=horizontal][data-variant=secondary]{
|
|
17
|
+
min-height:var(--sn-tabs-anatomy-secondary-tabsHorizontal-tabContainer-minHeight, var(--sn-density-size-l, var(--sn-density-scale-100-l, var(--sn-platform-comfort-scale-100-l, var(--sn-primitive-dimension-48, 48px)))));
|
|
18
|
+
padding-left:var(--sn-tabs-anatomy-secondary-tabsHorizontal-tabContainer-paddingHorizontal, var(--sn-primitive-dimension-0, 0px));
|
|
19
|
+
padding-right:var(--sn-tabs-anatomy-secondary-tabsHorizontal-tabContainer-paddingHorizontal, var(--sn-primitive-dimension-0, 0px));
|
|
20
|
+
}
|
|
21
|
+
.tab[data-orientation=horizontal][data-variant=secondary] .container{
|
|
22
|
+
padding-left:var(--sn-tabs-anatomy-secondary-tabsHorizontal-tabContainer-textWrapper-paddingHorizontal, var(--sn-density-spacing-control-wrapper-horizontal-m, var(--sn-platform-comfort-spacing-control-wrapper-horizontal-m, var(--sn-platform-comfort-spacing-control-wrapper-vertical-m, var(--sn-platform-comfort-scale-025-xs, var(--sn-primitive-dimension-4, 4px))))));
|
|
23
|
+
padding-right:var(--sn-tabs-anatomy-secondary-tabsHorizontal-tabContainer-textWrapper-paddingHorizontal, var(--sn-density-spacing-control-wrapper-horizontal-m, var(--sn-platform-comfort-spacing-control-wrapper-horizontal-m, var(--sn-platform-comfort-spacing-control-wrapper-vertical-m, var(--sn-platform-comfort-scale-025-xs, var(--sn-primitive-dimension-4, 4px))))));
|
|
24
|
+
border-radius:var(--sn-tabs-anatomy-secondary-tabsHorizontal-tabContainer-textWrapper-borderRadius, var(--sn-brand-anatomy-radius-button-m, var(--sn-primitive-dimension-2, 2px)));
|
|
25
|
+
min-width:var(--sn-tabs-anatomy-secondary-tabsHorizontal-tabContainer-textWrapper-minWidth, var(--sn-density-size-m, var(--sn-density-scale-100-m, var(--sn-platform-comfort-scale-100-m, var(--sn-primitive-dimension-40, 40px)))));
|
|
26
|
+
gap:var(--sn-tabs-anatomy-secondary-tabsHorizontal-tabContainer-textWrapper-gap, var(--sn-density-spacing-control-wrapper-horizontal-m, var(--sn-platform-comfort-spacing-control-wrapper-horizontal-m, var(--sn-platform-comfort-spacing-control-wrapper-vertical-m, var(--sn-platform-comfort-scale-025-xs, var(--sn-primitive-dimension-4, 4px))))));
|
|
27
|
+
min-height:var(--sn-tabs-anatomy-secondary-tabsHorizontal-tabContainer-textWrapper-minHeight, var(--sn-density-size-s, var(--sn-density-scale-100-s, var(--sn-platform-comfort-scale-100-s, var(--sn-primitive-dimension-32, 32px)))));
|
|
28
|
+
}
|
|
29
|
+
.tab[data-orientation=vertical][data-variant=secondary]{
|
|
30
|
+
padding-left:var(--sn-tabs-anatomy-secondary-tabsVertical-tabContainer-paddingHorizontal, var(--sn-density-spacing-control-container-horizontal-m, var(--sn-platform-comfort-spacing-control-container-horizontal-m, var(--sn-platform-comfort-scale-050-xs, var(--sn-primitive-dimension-8, 8px)))));
|
|
31
|
+
padding-right:var(--sn-tabs-anatomy-secondary-tabsVertical-tabContainer-paddingHorizontal, var(--sn-density-spacing-control-container-horizontal-m, var(--sn-platform-comfort-spacing-control-container-horizontal-m, var(--sn-platform-comfort-scale-050-xs, var(--sn-primitive-dimension-8, 8px)))));
|
|
32
|
+
min-height:var(--sn-tabs-anatomy-secondary-tabsVertical-tabContainer-minHeight, var(--sn-density-size-l, var(--sn-density-scale-100-l, var(--sn-platform-comfort-scale-100-l, var(--sn-primitive-dimension-48, 48px)))));
|
|
33
|
+
}
|
|
34
|
+
.tab[data-orientation=vertical][data-variant=secondary] .container{
|
|
35
|
+
min-width:var(--sn-tabs-anatomy-secondary-tabsVertical-tabContainer-textWrapper-minWidth, var(--sn-primitive-dimension-0, 0px));
|
|
36
|
+
gap:var(--sn-tabs-anatomy-secondary-tabsVertical-tabContainer-textWrapper-gap, var(--sn-density-spacing-control-wrapper-horizontal-m, var(--sn-platform-comfort-spacing-control-wrapper-horizontal-m, var(--sn-platform-comfort-spacing-control-wrapper-vertical-m, var(--sn-platform-comfort-scale-025-xs, var(--sn-primitive-dimension-4, 4px))))));
|
|
37
|
+
min-height:var(--sn-tabs-anatomy-secondary-tabsVertical-tabContainer-textWrapper-minHeight, var(--sn-density-size-s, var(--sn-density-scale-100-s, var(--sn-platform-comfort-scale-100-s, var(--sn-primitive-dimension-32, 32px)))));
|
|
38
|
+
border-radius:var(--sn-tabs-anatomy-secondary-tabsVertical-tabContainer-textWrapper-borderRadius, var(--sn-brand-anatomy-radius-button-m, var(--sn-primitive-dimension-2, 2px)));
|
|
39
|
+
padding-left:var(--sn-tabs-anatomy-secondary-tabsVertical-tabContainer-textWrapper-paddingHorizontal, var(--sn-density-spacing-control-wrapper-horizontal-m, var(--sn-platform-comfort-spacing-control-wrapper-horizontal-m, var(--sn-platform-comfort-spacing-control-wrapper-vertical-m, var(--sn-platform-comfort-scale-025-xs, var(--sn-primitive-dimension-4, 4px))))));
|
|
40
|
+
padding-right:var(--sn-tabs-anatomy-secondary-tabsVertical-tabContainer-textWrapper-paddingHorizontal, var(--sn-density-spacing-control-wrapper-horizontal-m, var(--sn-platform-comfort-spacing-control-wrapper-horizontal-m, var(--sn-platform-comfort-spacing-control-wrapper-vertical-m, var(--sn-platform-comfort-scale-025-xs, var(--sn-primitive-dimension-4, 4px))))));
|
|
41
|
+
}
|
|
42
|
+
.tab[data-orientation=horizontal][data-variant=primary]{
|
|
43
|
+
min-height:var(--sn-tabs-anatomy-primary-tabsHorizontal-tabContainer-minHeight, var(--sn-density-size-xl, var(--sn-density-scale-100-xl, var(--sn-platform-comfort-scale-100-xl, var(--sn-primitive-dimension-56, 56px)))));
|
|
44
|
+
padding-left:var(--sn-tabs-anatomy-primary-tabsHorizontal-tabContainer-paddingHorizontal, var(--sn-density-spacing-control-container-horizontal-l, var(--sn-platform-comfort-spacing-control-container-horizontal-l, var(--sn-platform-comfort-scale-050-s, var(--sn-primitive-dimension-12, 12px)))));
|
|
45
|
+
padding-right:var(--sn-tabs-anatomy-primary-tabsHorizontal-tabContainer-paddingHorizontal, var(--sn-density-spacing-control-container-horizontal-l, var(--sn-platform-comfort-spacing-control-container-horizontal-l, var(--sn-platform-comfort-scale-050-s, var(--sn-primitive-dimension-12, 12px)))));
|
|
46
|
+
}
|
|
47
|
+
.tab[data-orientation=horizontal][data-variant=primary] .container{
|
|
48
|
+
min-width:var(--sn-tabs-anatomy-primary-tabsHorizontal-tabContainer-textWrapper-minWidth, var(--sn-density-size-l, var(--sn-density-scale-100-l, var(--sn-platform-comfort-scale-100-l, var(--sn-primitive-dimension-48, 48px)))));
|
|
49
|
+
min-height:var(--sn-tabs-anatomy-primary-tabsHorizontal-tabContainer-textWrapper-minHeight, var(--sn-density-size-m, var(--sn-density-scale-100-m, var(--sn-platform-comfort-scale-100-m, var(--sn-primitive-dimension-40, 40px)))));
|
|
50
|
+
gap:var(--sn-tabs-anatomy-primary-tabsHorizontal-tabContainer-textWrapper-gap, var(--sn-density-spacing-control-wrapper-horizontal-l, var(--sn-platform-comfort-spacing-control-wrapper-horizontal-l, var(--sn-platform-comfort-spacing-control-wrapper-vertical-l, var(--sn-platform-comfort-scale-025-xs, var(--sn-primitive-dimension-4, 4px))))));
|
|
51
|
+
border-radius:var(--sn-tabs-anatomy-primary-tabsHorizontal-tabContainer-textWrapper-borderRadius, var(--sn-brand-anatomy-radius-button-l, var(--sn-primitive-dimension-2, 2px)));
|
|
52
|
+
padding-left:var(--sn-tabs-anatomy-primary-tabsHorizontal-tabContainer-textWrapper-paddingHorizontal, var(--sn-density-spacing-control-wrapper-horizontal-l, var(--sn-platform-comfort-spacing-control-wrapper-horizontal-l, var(--sn-platform-comfort-spacing-control-wrapper-vertical-l, var(--sn-platform-comfort-scale-025-xs, var(--sn-primitive-dimension-4, 4px))))));
|
|
53
|
+
padding-right:var(--sn-tabs-anatomy-primary-tabsHorizontal-tabContainer-textWrapper-paddingHorizontal, var(--sn-density-spacing-control-wrapper-horizontal-l, var(--sn-platform-comfort-spacing-control-wrapper-horizontal-l, var(--sn-platform-comfort-spacing-control-wrapper-vertical-l, var(--sn-platform-comfort-scale-025-xs, var(--sn-primitive-dimension-4, 4px))))));
|
|
54
|
+
}
|
|
55
|
+
.tab[data-orientation=vertical][data-variant=primary]{
|
|
56
|
+
padding-left:var(--sn-tabs-anatomy-primary-tabsVertical-tabContainer-paddingHorizontal, var(--sn-density-spacing-control-container-horizontal-l, var(--sn-platform-comfort-spacing-control-container-horizontal-l, var(--sn-platform-comfort-scale-050-s, var(--sn-primitive-dimension-12, 12px)))));
|
|
57
|
+
padding-right:var(--sn-tabs-anatomy-primary-tabsVertical-tabContainer-paddingHorizontal, var(--sn-density-spacing-control-container-horizontal-l, var(--sn-platform-comfort-spacing-control-container-horizontal-l, var(--sn-platform-comfort-scale-050-s, var(--sn-primitive-dimension-12, 12px)))));
|
|
58
|
+
min-height:var(--sn-tabs-anatomy-primary-tabsVertical-tabContainer-minHeight, var(--sn-density-size-xl, var(--sn-density-scale-100-xl, var(--sn-platform-comfort-scale-100-xl, var(--sn-primitive-dimension-56, 56px)))));
|
|
59
|
+
}
|
|
60
|
+
.tab[data-orientation=vertical][data-variant=primary] .container{
|
|
61
|
+
min-width:var(--sn-tabs-anatomy-primary-tabsVertical-tabContainer-textWrapper-minWidth, var(--sn-density-size-l, var(--sn-density-scale-100-l, var(--sn-platform-comfort-scale-100-l, var(--sn-primitive-dimension-48, 48px)))));
|
|
62
|
+
padding-left:var(--sn-tabs-anatomy-primary-tabsVertical-tabContainer-textWrapper-paddingHorizontal, var(--sn-density-spacing-control-wrapper-horizontal-l, var(--sn-platform-comfort-spacing-control-wrapper-horizontal-l, var(--sn-platform-comfort-spacing-control-wrapper-vertical-l, var(--sn-platform-comfort-scale-025-xs, var(--sn-primitive-dimension-4, 4px))))));
|
|
63
|
+
padding-right:var(--sn-tabs-anatomy-primary-tabsVertical-tabContainer-textWrapper-paddingHorizontal, var(--sn-density-spacing-control-wrapper-horizontal-l, var(--sn-platform-comfort-spacing-control-wrapper-horizontal-l, var(--sn-platform-comfort-spacing-control-wrapper-vertical-l, var(--sn-platform-comfort-scale-025-xs, var(--sn-primitive-dimension-4, 4px))))));
|
|
64
|
+
border-radius:var(--sn-tabs-anatomy-primary-tabsVertical-tabContainer-textWrapper-borderRadius, var(--sn-brand-anatomy-radius-button-l, var(--sn-primitive-dimension-2, 2px)));
|
|
65
|
+
gap:var(--sn-tabs-anatomy-primary-tabsVertical-tabContainer-textWrapper-gap, var(--sn-density-spacing-control-wrapper-horizontal-l, var(--sn-platform-comfort-spacing-control-wrapper-horizontal-l, var(--sn-platform-comfort-spacing-control-wrapper-vertical-l, var(--sn-platform-comfort-scale-025-xs, var(--sn-primitive-dimension-4, 4px))))));
|
|
66
|
+
min-height:var(--sn-tabs-anatomy-primary-tabsVertical-tabContainer-textWrapper-minHeight, var(--sn-density-size-m, var(--sn-density-scale-100-m, var(--sn-platform-comfort-scale-100-m, var(--sn-primitive-dimension-40, 40px)))));
|
|
67
|
+
}
|
|
68
|
+
.tab:not([data-disabled])[data-selected=true], .tab:not([data-disabled]):focus-visible, .tab:not([data-disabled]):hover{
|
|
71
69
|
color:var(--sn-theme-color-available-version-textMain, var(--sn-brand-color-text-version-main, #000000));
|
|
72
70
|
}
|
|
73
71
|
.tab[data-disabled]{
|
|
@@ -83,7 +81,7 @@
|
|
|
83
81
|
background:var(--sn-theme-color-material-stateLayer-neutral-onBackground-defaultEmpty-filled, var(--sn-brand-color-state-neutral-forLightMode-default-background, rgba(0, 0, 0, 0)));
|
|
84
82
|
}
|
|
85
83
|
@media (hover: hover){
|
|
86
|
-
.tab:hover:not([data-disabled], [data-loading]) .container > [data-state-layer][data-state=emptyNeutralOnBackground]{
|
|
84
|
+
.tab:hover:not([data-disabled], [data-loading], [data-selected]) .container > [data-state-layer][data-state=emptyNeutralOnBackground]{
|
|
87
85
|
background:var(--sn-theme-color-material-stateLayer-neutral-onBackground-hovered-filled, var(--sn-brand-color-state-neutral-forLightMode-hovered-background, rgba(0, 0, 0, 0.0784313725)));
|
|
88
86
|
}
|
|
89
87
|
}
|
|
@@ -95,9 +93,30 @@
|
|
|
95
93
|
.tab .container{
|
|
96
94
|
position:relative;
|
|
97
95
|
display:flex;
|
|
96
|
+
flex-shrink:0;
|
|
98
97
|
align-items:center;
|
|
99
98
|
justify-content:center;
|
|
100
99
|
box-sizing:border-box;
|
|
100
|
+
width:-moz-max-content;
|
|
101
|
+
width:max-content;
|
|
102
|
+
}
|
|
103
|
+
.tab[data-orientation=vertical]{
|
|
104
|
+
min-width:0;
|
|
105
|
+
}
|
|
106
|
+
.tab[data-orientation=vertical] .container{
|
|
107
|
+
flex-wrap:1;
|
|
108
|
+
justify-content:flex-start;
|
|
109
|
+
width:100%;
|
|
110
|
+
min-width:0;
|
|
111
|
+
}
|
|
112
|
+
.tab[data-orientation=vertical] .label{
|
|
113
|
+
flex-grow:0;
|
|
114
|
+
flex-shrink:1;
|
|
115
|
+
min-width:0;
|
|
116
|
+
text-align:left;
|
|
117
|
+
}
|
|
118
|
+
.tab[data-orientation=vertical] .counter{
|
|
119
|
+
flex-shrink:0;
|
|
101
120
|
}
|
|
102
121
|
.tab:focus-visible .container{
|
|
103
122
|
outline:var(--sn-primitive-strokeWeight-strokeSemiBold, 2px) solid var(--sn-theme-color-available-complementary, #000000);
|
|
@@ -1,17 +1,15 @@
|
|
|
1
1
|
import { WithSupportProps } from '@cloud-ru/ds-utils';
|
|
2
2
|
import { ReactElement, ReactNode } from 'react';
|
|
3
|
-
import { MarkerPosition,
|
|
3
|
+
import { MarkerPosition, Variant } from '../../types';
|
|
4
4
|
import { TabProps } from '../Tab';
|
|
5
5
|
export type TabBarProps = WithSupportProps<{
|
|
6
6
|
/** Контент (элементы Tabs.Tab) */
|
|
7
7
|
children: ReactElement<TabProps>[];
|
|
8
8
|
/**
|
|
9
9
|
* Слот действия: контент после списка табов — справа при горизонтальной
|
|
10
|
-
* ориентации, снизу при вертикальной. Разделитель
|
|
10
|
+
* ориентации, снизу при вертикальной. Разделитель проходит вдоль всей панели.
|
|
11
11
|
*/
|
|
12
|
-
|
|
13
|
-
/** Ориентация */
|
|
14
|
-
orientation?: Orientation;
|
|
12
|
+
afterContent?: ReactNode;
|
|
15
13
|
/**
|
|
16
14
|
* Позиция маркера относительно таб-бара.
|
|
17
15
|
*
|
|
@@ -20,11 +18,11 @@ export type TabBarProps = WithSupportProps<{
|
|
|
20
18
|
* `after` = Figma `bottom` (horizontal) / `right` (vertical).
|
|
21
19
|
*/
|
|
22
20
|
markerPosition?: MarkerPosition;
|
|
23
|
-
/**
|
|
24
|
-
|
|
25
|
-
/**
|
|
26
|
-
|
|
21
|
+
/** Вариант панели: primary — верхнеуровневый, secondary — на уровне контента */
|
|
22
|
+
variant?: Variant;
|
|
23
|
+
/** Показывать разделитель под/рядом с панелью табов */
|
|
24
|
+
divider?: boolean;
|
|
27
25
|
/** CSS-класс */
|
|
28
26
|
className?: string;
|
|
29
27
|
}>;
|
|
30
|
-
export declare function TabBar({ children, className,
|
|
28
|
+
export declare function TabBar({ children, className, variant, markerPosition, afterContent, divider, ...otherProps }: TabBarProps): import("react/jsx-runtime").JSX.Element;
|
|
@@ -19,10 +19,14 @@ const SCROLL_CONTAINER_ORIENTATION_MAP = {
|
|
|
19
19
|
[constants_1.ORIENTATION.Horizontal]: styles_module_scss_1.default.horizontalScrollContainer,
|
|
20
20
|
[constants_1.ORIENTATION.Vertical]: styles_module_scss_1.default.verticalScrollContainer,
|
|
21
21
|
};
|
|
22
|
-
function TabBar({ children, className,
|
|
22
|
+
function TabBar({ children, className, variant = constants_1.VARIANT.Primary, markerPosition = constants_1.MARKER_POSITION.After, afterContent, divider = true, ...otherProps }) {
|
|
23
23
|
const scrollContainerRef = (0, react_1.useRef)(null);
|
|
24
|
-
const
|
|
25
|
-
const {
|
|
24
|
+
const tabsRowRef = (0, react_1.useRef)(null);
|
|
25
|
+
const { selectedTab, setSelectedTab, orientation } = (0, context_1.useTabsContext)();
|
|
26
|
+
const { hasOverflow, scrollLeft, scrollRight, scrollTop, scrollBottom } = (0, hooks_1.useScrollContainer)({
|
|
27
|
+
container: scrollContainerRef,
|
|
28
|
+
tabsRow: tabsRowRef,
|
|
29
|
+
});
|
|
26
30
|
const selectedRef = (0, react_1.useRef)(null);
|
|
27
31
|
const [markerScrollPosition, setMarkerScrollPosition] = (0, react_1.useState)({});
|
|
28
32
|
const [focusedTab, setFocusedTab] = (0, react_1.useState)();
|
|
@@ -64,7 +68,7 @@ function TabBar({ children, className, size = constants_1.SIZE.L, orientation =
|
|
|
64
68
|
return () => {
|
|
65
69
|
resizeObserver.disconnect();
|
|
66
70
|
};
|
|
67
|
-
}, [children,
|
|
71
|
+
}, [children, variant, updateMarkPosition]);
|
|
68
72
|
const scrollContainerToElement = (0, react_1.useCallback)((element) => {
|
|
69
73
|
const container = scrollContainerRef.current;
|
|
70
74
|
if (element && container) {
|
|
@@ -109,11 +113,12 @@ function TabBar({ children, className, size = constants_1.SIZE.L, orientation =
|
|
|
109
113
|
setFocusedTab(newFocusTab);
|
|
110
114
|
}
|
|
111
115
|
}, [getPrev, getNext, focusedTab, selectedTab]);
|
|
112
|
-
return ((0, jsx_runtime_1.jsxs)("div", { className: (0, classnames_1.default)(styles_module_scss_1.default.tabBar, className), role: 'tablist', "data-orientation": orientation, "data-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
116
|
+
return ((0, jsx_runtime_1.jsxs)("div", { className: (0, classnames_1.default)(styles_module_scss_1.default.tabBar, className), role: 'tablist', "data-orientation": orientation, "data-variant": variant, ...(0, utils_1.extractSupportProps)(otherProps), children: [divider && ((0, jsx_runtime_1.jsx)("div", { className: styles_module_scss_1.default.divider, "data-position": markerPosition, children: (0, jsx_runtime_1.jsx)(divider_1.Divider, { variant: 'regular', orientation: orientation }) })), (0, jsx_runtime_1.jsx)("div", { className: styles_module_scss_1.default.tabListWrapper, "data-orientation": orientation, children: (0, jsx_runtime_1.jsxs)("div", { className: styles_module_scss_1.default.tabBarScrollZone, "data-orientation": orientation, children: [(0, jsx_runtime_1.jsx)("div", { className: styles_module_scss_1.default.tabBarMain, "data-testid": 'tabs__bar-wrap', "data-orientation": orientation, children: (0, jsx_runtime_1.jsx)(react_indiana_drag_scroll_1.default, { className: (0, classnames_1.default)(SCROLL_CONTAINER_ORIENTATION_MAP[orientation], styles_module_scss_1.default.scrollArea), innerRef: scrollContainerRef, children: (0, jsx_runtime_1.jsxs)("div", { className: styles_module_scss_1.default.tabsRow, "data-variant": variant, "data-orientation": orientation, onKeyDown: handleKeyDown, role: 'presentation', ref: tabsRowRef, children: [(0, jsx_runtime_1.jsx)(context_1.TabBarContext.Provider, { value: {
|
|
117
|
+
onSelect: onSelectHandler,
|
|
118
|
+
variant,
|
|
119
|
+
orientation,
|
|
120
|
+
focusedTab,
|
|
121
|
+
onFocus: onFocusHandler,
|
|
122
|
+
markerPosition,
|
|
123
|
+
}, children: children }), (0, jsx_runtime_1.jsx)("div", { className: styles_module_scss_1.default.marker, style: markerScrollPosition, "data-position": markerPosition, "data-orientation": orientation })] }) }) }), orientation === constants_1.ORIENTATION.Horizontal && hasOverflow.left && ((0, jsx_runtime_1.jsx)(ScrollButton_1.ScrollButton, { direction: 'left', onClick: scrollLeft, orientation: orientation, variant: variant })), orientation === constants_1.ORIENTATION.Horizontal && hasOverflow.right && ((0, jsx_runtime_1.jsx)(ScrollButton_1.ScrollButton, { direction: 'right', onClick: scrollRight, orientation: orientation, variant: variant })), orientation === constants_1.ORIENTATION.Vertical && hasOverflow.top && ((0, jsx_runtime_1.jsx)(ScrollButton_1.ScrollButton, { direction: 'top', onClick: scrollTop, orientation: orientation, variant: variant })), orientation === constants_1.ORIENTATION.Vertical && hasOverflow.bottom && ((0, jsx_runtime_1.jsx)(ScrollButton_1.ScrollButton, { direction: 'bottom', onClick: scrollBottom, orientation: orientation, variant: variant }))] }) }), afterContent && ((0, jsx_runtime_1.jsx)("div", { "data-test-id": 'tabs__bar__after', "data-orientation": orientation, "data-variant": variant, className: styles_module_scss_1.default.actionWrapper, children: afterContent }))] }));
|
|
119
124
|
}
|
|
@@ -10,7 +10,11 @@ type ScrollContainerControl = {
|
|
|
10
10
|
scrollTop: () => void;
|
|
11
11
|
scrollBottom: () => void;
|
|
12
12
|
};
|
|
13
|
-
|
|
13
|
+
type UseScrollContainerProps = {
|
|
14
|
+
container: RefObject<HTMLElement | null>;
|
|
15
|
+
tabsRow: RefObject<HTMLElement | null>;
|
|
16
|
+
};
|
|
17
|
+
export declare function useScrollContainer({ container, tabsRow }: UseScrollContainerProps): ScrollContainerControl;
|
|
14
18
|
export declare function useFocusControl(children: ReactElement<{
|
|
15
19
|
value: string;
|
|
16
20
|
disabled?: boolean;
|