@alfalab/core-components-tab-bar 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/Component.d.ts +7 -0
- package/Component.js +39 -0
- package/components/tab/Component.d.ts +5 -0
- package/components/tab/Component.js +39 -0
- package/components/tab/index.css +71 -0
- package/components/tab/index.d.ts +1 -0
- package/components/tab/index.js +14 -0
- package/cssm/Component.d.ts +7 -0
- package/cssm/Component.js +39 -0
- package/cssm/components/tab/Component.d.ts +5 -0
- package/cssm/components/tab/Component.js +38 -0
- package/cssm/components/tab/index.d.ts +1 -0
- package/cssm/components/tab/index.js +15 -0
- package/cssm/components/tab/index.module.css +70 -0
- package/cssm/index.d.ts +2 -0
- package/cssm/index.js +18 -0
- package/cssm/index.module.css +29 -0
- package/cssm/types.d.ts +99 -0
- package/cssm/types.js +2 -0
- package/esm/Component.d.ts +7 -0
- package/esm/Component.js +30 -0
- package/esm/components/tab/Component.d.ts +5 -0
- package/esm/components/tab/Component.js +30 -0
- package/esm/components/tab/index.css +71 -0
- package/esm/components/tab/index.d.ts +1 -0
- package/esm/components/tab/index.js +6 -0
- package/esm/index.css +30 -0
- package/esm/index.d.ts +2 -0
- package/esm/index.js +8 -0
- package/esm/types.d.ts +99 -0
- package/esm/types.js +1 -0
- package/index.css +30 -0
- package/index.d.ts +2 -0
- package/index.js +16 -0
- package/modern/Component.d.ts +7 -0
- package/modern/Component.js +25 -0
- package/modern/components/tab/Component.d.ts +5 -0
- package/modern/components/tab/Component.js +27 -0
- package/modern/components/tab/index.css +71 -0
- package/modern/components/tab/index.d.ts +1 -0
- package/modern/components/tab/index.js +5 -0
- package/modern/index.css +30 -0
- package/modern/index.d.ts +2 -0
- package/modern/index.js +7 -0
- package/modern/types.d.ts +99 -0
- package/modern/types.js +1 -0
- package/package.json +24 -0
- package/src/Component.tsx +50 -0
- package/src/components/tab/Component.tsx +93 -0
- package/src/components/tab/index.module.css +45 -0
- package/src/components/tab/index.ts +1 -0
- package/src/index.module.css +16 -0
- package/src/index.ts +2 -0
- package/src/types.ts +139 -0
- package/types.d.ts +99 -0
- package/types.js +2 -0
package/Component.d.ts
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import React from 'react';
|
|
3
|
+
import { TabBarProps } from "./types";
|
|
4
|
+
declare const TabBar: React.ForwardRefExoticComponent<TabBarProps & React.RefAttributes<HTMLDivElement>> & {
|
|
5
|
+
Tab: React.ForwardRefExoticComponent<import("./types").TabProps & React.RefAttributes<HTMLElement>>;
|
|
6
|
+
};
|
|
7
|
+
export { TabBar };
|
package/Component.js
ADDED
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
var tslib = require('tslib');
|
|
6
|
+
var React = require('react');
|
|
7
|
+
var cn = require('classnames');
|
|
8
|
+
var coreComponentsShared = require('@alfalab/core-components-shared');
|
|
9
|
+
var components_tab_Component = require('./components/tab/Component.js');
|
|
10
|
+
require('@alfalab/core-components-badge');
|
|
11
|
+
require('@alfalab/core-components-typography');
|
|
12
|
+
|
|
13
|
+
function _interopDefaultCompat (e) { return e && typeof e === 'object' && 'default' in e ? e : { default: e }; }
|
|
14
|
+
|
|
15
|
+
var React__default = /*#__PURE__*/_interopDefaultCompat(React);
|
|
16
|
+
var cn__default = /*#__PURE__*/_interopDefaultCompat(cn);
|
|
17
|
+
|
|
18
|
+
var styles = {"component":"tab-bar__component_1tqhl","border":"tab-bar__border_1tqhl"};
|
|
19
|
+
require('./index.css')
|
|
20
|
+
|
|
21
|
+
var TabBarComponent = React.forwardRef(function (_a, ref) {
|
|
22
|
+
var _b;
|
|
23
|
+
var children = _a.children, className = _a.className, selectedId = _a.selectedId, border = _a.border, dataTestId = _a.dataTestId, tabClassNames = _a.tabClassNames, onChange = _a.onChange, restProps = tslib.__rest(_a, ["children", "className", "selectedId", "border", "dataTestId", "tabClassNames", "onChange"]);
|
|
24
|
+
if (React.Children.count(children) > 5) {
|
|
25
|
+
// eslint-disable-next-line no-console
|
|
26
|
+
console.error('Компонент TabBar не может содержать больше 5 табов');
|
|
27
|
+
}
|
|
28
|
+
return (React__default.default.createElement("nav", tslib.__assign({ "data-test-id": dataTestId }, restProps, { ref: ref, className: cn__default.default(styles.component, className, (_b = {}, _b[styles.border] = border, _b)) }), React.Children.map(children, function (tab) {
|
|
29
|
+
return React.cloneElement(tab, {
|
|
30
|
+
selected: tab.props.id === selectedId,
|
|
31
|
+
onChange: onChange,
|
|
32
|
+
tabClassNames: tabClassNames,
|
|
33
|
+
dataTestId: coreComponentsShared.getDataTestId(dataTestId, 'tab'),
|
|
34
|
+
});
|
|
35
|
+
})));
|
|
36
|
+
});
|
|
37
|
+
var TabBar = Object.assign(TabBarComponent, { Tab: components_tab_Component.Tab });
|
|
38
|
+
|
|
39
|
+
exports.TabBar = TabBar;
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
var tslib = require('tslib');
|
|
6
|
+
var React = require('react');
|
|
7
|
+
var cn = require('classnames');
|
|
8
|
+
var coreComponentsBadge = require('@alfalab/core-components-badge');
|
|
9
|
+
var coreComponentsTypography = require('@alfalab/core-components-typography');
|
|
10
|
+
|
|
11
|
+
function _interopDefaultCompat (e) { return e && typeof e === 'object' && 'default' in e ? e : { default: e }; }
|
|
12
|
+
|
|
13
|
+
var React__default = /*#__PURE__*/_interopDefaultCompat(React);
|
|
14
|
+
var cn__default = /*#__PURE__*/_interopDefaultCompat(cn);
|
|
15
|
+
|
|
16
|
+
var styles = {"component":"tab-bar__component_1cyxn","selected":"tab-bar__selected_1cyxn","icon":"tab-bar__icon_1cyxn","label":"tab-bar__label_1cyxn","labelSelected":"tab-bar__labelSelected_1cyxn","indicator":"tab-bar__indicator_1cyxn"};
|
|
17
|
+
require('./index.css')
|
|
18
|
+
|
|
19
|
+
var TabComponent = React.forwardRef(function (_a, ref) {
|
|
20
|
+
var _b, _c;
|
|
21
|
+
var showIndicator = _a.showIndicator, indicatorProps = _a.indicatorProps, label = _a.label, icon = _a.icon, id = _a.id, selected = _a.selected, onChange = _a.onChange, onClick = _a.onClick, _d = _a.tabClassNames, tabClassNames = _d === void 0 ? {} : _d, dataTestId = _a.dataTestId, className = _a.className, labelClassName = _a.labelClassName, selectedClassName = _a.selectedClassName, iconClassName = _a.iconClassName, href = _a.href, _e = _a.Component, Component = _e === void 0 ? href ? 'a' : 'button' : _e, restProps = tslib.__rest(_a, ["showIndicator", "indicatorProps", "label", "icon", "id", "selected", "onChange", "onClick", "tabClassNames", "dataTestId", "className", "labelClassName", "selectedClassName", "iconClassName", "href", "Component"]);
|
|
22
|
+
var handleClick = function (event) {
|
|
23
|
+
onChange === null || onChange === void 0 ? void 0 : onChange(id);
|
|
24
|
+
onClick === null || onClick === void 0 ? void 0 : onClick(event);
|
|
25
|
+
};
|
|
26
|
+
var commonClassName = tabClassNames.className, commonLabelClassName = tabClassNames.labelClassName, commonSelectedClassName = tabClassNames.selectedClassName, commonIconClassName = tabClassNames.iconClassName;
|
|
27
|
+
return (React__default.default.createElement(Component, tslib.__assign({ "data-test-id": dataTestId, tabIndex: 0 }, (Component === 'button' ? { type: 'button' } : null), restProps, { href: href, id: id, ref: ref, className: cn__default.default(styles.component, commonClassName, className, selected && commonSelectedClassName, selected && selectedClassName, (_b = {},
|
|
28
|
+
_b[styles.selected] = selected,
|
|
29
|
+
_b)), onClick: handleClick }),
|
|
30
|
+
React__default.default.createElement("div", { className: cn__default.default(styles.icon, commonIconClassName, iconClassName) }, React.isValidElement(icon) ? React.cloneElement(icon, { selected: selected }) : icon),
|
|
31
|
+
React__default.default.createElement(coreComponentsTypography.Typography.Text, { weight: 'medium', view: 'secondary-small', className: cn__default.default(styles.label, commonLabelClassName, labelClassName, (_c = {},
|
|
32
|
+
_c[styles.labelSelected] = selected,
|
|
33
|
+
_c)) }, React.isValidElement(label) ? React.cloneElement(label, { selected: selected }) : label),
|
|
34
|
+
showIndicator && (React__default.default.createElement("div", { className: styles.indicator },
|
|
35
|
+
React__default.default.createElement(coreComponentsBadge.Badge, tslib.__assign({ visibleIconOutline: true }, indicatorProps, { view: 'count' }))))));
|
|
36
|
+
});
|
|
37
|
+
var Tab = TabComponent;
|
|
38
|
+
|
|
39
|
+
exports.Tab = Tab;
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
/* hash: 8qv7e */
|
|
2
|
+
:root {
|
|
3
|
+
} /* deprecated */ :root {
|
|
4
|
+
--color-light-accent-primary: #ef3124;
|
|
5
|
+
--color-light-neutral-translucent-700: rgba(4, 4, 21, 0.47);
|
|
6
|
+
--color-light-text-secondary: rgba(4, 4, 19, 0.55); /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */
|
|
7
|
+
} :root { /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */
|
|
8
|
+
} :root {
|
|
9
|
+
} :root {
|
|
10
|
+
|
|
11
|
+
/* Hard */
|
|
12
|
+
|
|
13
|
+
/* Up */
|
|
14
|
+
|
|
15
|
+
/* Hard up */
|
|
16
|
+
} :root {
|
|
17
|
+
} :root {
|
|
18
|
+
--gap-2xs: 4px;
|
|
19
|
+
--gap-xs: 8px;
|
|
20
|
+
} :root {
|
|
21
|
+
} :root {
|
|
22
|
+
} .tab-bar__component_1cyxn {
|
|
23
|
+
box-sizing: border-box;
|
|
24
|
+
background-color: transparent;
|
|
25
|
+
-webkit-tap-highlight-color: transparent;
|
|
26
|
+
outline: none;
|
|
27
|
+
border: 0;
|
|
28
|
+
margin: 0;
|
|
29
|
+
box-shadow: none;
|
|
30
|
+
border-radius: 0;
|
|
31
|
+
-webkit-user-select: none;
|
|
32
|
+
user-select: none;
|
|
33
|
+
vertical-align: middle;
|
|
34
|
+
appearance: none;
|
|
35
|
+
text-decoration: none;
|
|
36
|
+
min-width: 0;
|
|
37
|
+
cursor: pointer;
|
|
38
|
+
|
|
39
|
+
position: relative;
|
|
40
|
+
display: inline-flex;
|
|
41
|
+
flex-direction: column;
|
|
42
|
+
flex: 1 0 0;
|
|
43
|
+
align-items: center;
|
|
44
|
+
padding: var(--gap-xs) 0;
|
|
45
|
+
color: var(--color-light-neutral-translucent-700);
|
|
46
|
+
} .tab-bar__selected_1cyxn {
|
|
47
|
+
color: var(--color-light-accent-primary);
|
|
48
|
+
} .tab-bar__icon_1cyxn {
|
|
49
|
+
display: flex;
|
|
50
|
+
align-items: center;
|
|
51
|
+
justify-content: center;
|
|
52
|
+
flex-grow: 1;
|
|
53
|
+
width: 100%;
|
|
54
|
+
} .tab-bar__label_1cyxn {
|
|
55
|
+
-webkit-line-clamp: 1;
|
|
56
|
+
display: -webkit-box;
|
|
57
|
+
-webkit-box-orient: vertical;
|
|
58
|
+
overflow: hidden;
|
|
59
|
+
word-break: break-all;
|
|
60
|
+
flex-shrink: 0;
|
|
61
|
+
|
|
62
|
+
color: var(--color-light-text-secondary);
|
|
63
|
+
} .tab-bar__labelSelected_1cyxn {
|
|
64
|
+
color: inherit;
|
|
65
|
+
} .tab-bar__indicator_1cyxn {
|
|
66
|
+
position: absolute;
|
|
67
|
+
top: var(--gap-2xs);
|
|
68
|
+
left: calc(50% + var(--gap-2xs));
|
|
69
|
+
height: 16px;
|
|
70
|
+
min-width: 16px;
|
|
71
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./Component";
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
var components_tab_Component = require('./Component.js');
|
|
6
|
+
require('tslib');
|
|
7
|
+
require('react');
|
|
8
|
+
require('classnames');
|
|
9
|
+
require('@alfalab/core-components-badge');
|
|
10
|
+
require('@alfalab/core-components-typography');
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
exports.Tab = components_tab_Component.Tab;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import React from 'react';
|
|
3
|
+
import { TabBarProps } from "./types";
|
|
4
|
+
declare const TabBar: React.ForwardRefExoticComponent<TabBarProps & React.RefAttributes<HTMLDivElement>> & {
|
|
5
|
+
Tab: React.ForwardRefExoticComponent<import("./types").TabProps & React.RefAttributes<HTMLElement>>;
|
|
6
|
+
};
|
|
7
|
+
export { TabBar };
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
var tslib = require('tslib');
|
|
6
|
+
var React = require('react');
|
|
7
|
+
var cn = require('classnames');
|
|
8
|
+
var coreComponentsShared = require('@alfalab/core-components-shared/cssm');
|
|
9
|
+
var components_tab_Component = require('./components/tab/Component.js');
|
|
10
|
+
var styles = require('./index.module.css');
|
|
11
|
+
require('@alfalab/core-components-badge/cssm');
|
|
12
|
+
require('@alfalab/core-components-typography/cssm');
|
|
13
|
+
require('./components/tab/index.module.css');
|
|
14
|
+
|
|
15
|
+
function _interopDefaultCompat (e) { return e && typeof e === 'object' && 'default' in e ? e : { default: e }; }
|
|
16
|
+
|
|
17
|
+
var React__default = /*#__PURE__*/_interopDefaultCompat(React);
|
|
18
|
+
var cn__default = /*#__PURE__*/_interopDefaultCompat(cn);
|
|
19
|
+
var styles__default = /*#__PURE__*/_interopDefaultCompat(styles);
|
|
20
|
+
|
|
21
|
+
var TabBarComponent = React.forwardRef(function (_a, ref) {
|
|
22
|
+
var _b;
|
|
23
|
+
var children = _a.children, className = _a.className, selectedId = _a.selectedId, border = _a.border, dataTestId = _a.dataTestId, tabClassNames = _a.tabClassNames, onChange = _a.onChange, restProps = tslib.__rest(_a, ["children", "className", "selectedId", "border", "dataTestId", "tabClassNames", "onChange"]);
|
|
24
|
+
if (React.Children.count(children) > 5) {
|
|
25
|
+
// eslint-disable-next-line no-console
|
|
26
|
+
console.error('Компонент TabBar не может содержать больше 5 табов');
|
|
27
|
+
}
|
|
28
|
+
return (React__default.default.createElement("nav", tslib.__assign({ "data-test-id": dataTestId }, restProps, { ref: ref, className: cn__default.default(styles__default.default.component, className, (_b = {}, _b[styles__default.default.border] = border, _b)) }), React.Children.map(children, function (tab) {
|
|
29
|
+
return React.cloneElement(tab, {
|
|
30
|
+
selected: tab.props.id === selectedId,
|
|
31
|
+
onChange: onChange,
|
|
32
|
+
tabClassNames: tabClassNames,
|
|
33
|
+
dataTestId: coreComponentsShared.getDataTestId(dataTestId, 'tab'),
|
|
34
|
+
});
|
|
35
|
+
})));
|
|
36
|
+
});
|
|
37
|
+
var TabBar = Object.assign(TabBarComponent, { Tab: components_tab_Component.Tab });
|
|
38
|
+
|
|
39
|
+
exports.TabBar = TabBar;
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
var tslib = require('tslib');
|
|
6
|
+
var React = require('react');
|
|
7
|
+
var cn = require('classnames');
|
|
8
|
+
var coreComponentsBadge = require('@alfalab/core-components-badge/cssm');
|
|
9
|
+
var coreComponentsTypography = require('@alfalab/core-components-typography/cssm');
|
|
10
|
+
var styles = require('./index.module.css');
|
|
11
|
+
|
|
12
|
+
function _interopDefaultCompat (e) { return e && typeof e === 'object' && 'default' in e ? e : { default: e }; }
|
|
13
|
+
|
|
14
|
+
var React__default = /*#__PURE__*/_interopDefaultCompat(React);
|
|
15
|
+
var cn__default = /*#__PURE__*/_interopDefaultCompat(cn);
|
|
16
|
+
var styles__default = /*#__PURE__*/_interopDefaultCompat(styles);
|
|
17
|
+
|
|
18
|
+
var TabComponent = React.forwardRef(function (_a, ref) {
|
|
19
|
+
var _b, _c;
|
|
20
|
+
var showIndicator = _a.showIndicator, indicatorProps = _a.indicatorProps, label = _a.label, icon = _a.icon, id = _a.id, selected = _a.selected, onChange = _a.onChange, onClick = _a.onClick, _d = _a.tabClassNames, tabClassNames = _d === void 0 ? {} : _d, dataTestId = _a.dataTestId, className = _a.className, labelClassName = _a.labelClassName, selectedClassName = _a.selectedClassName, iconClassName = _a.iconClassName, href = _a.href, _e = _a.Component, Component = _e === void 0 ? href ? 'a' : 'button' : _e, restProps = tslib.__rest(_a, ["showIndicator", "indicatorProps", "label", "icon", "id", "selected", "onChange", "onClick", "tabClassNames", "dataTestId", "className", "labelClassName", "selectedClassName", "iconClassName", "href", "Component"]);
|
|
21
|
+
var handleClick = function (event) {
|
|
22
|
+
onChange === null || onChange === void 0 ? void 0 : onChange(id);
|
|
23
|
+
onClick === null || onClick === void 0 ? void 0 : onClick(event);
|
|
24
|
+
};
|
|
25
|
+
var commonClassName = tabClassNames.className, commonLabelClassName = tabClassNames.labelClassName, commonSelectedClassName = tabClassNames.selectedClassName, commonIconClassName = tabClassNames.iconClassName;
|
|
26
|
+
return (React__default.default.createElement(Component, tslib.__assign({ "data-test-id": dataTestId, tabIndex: 0 }, (Component === 'button' ? { type: 'button' } : null), restProps, { href: href, id: id, ref: ref, className: cn__default.default(styles__default.default.component, commonClassName, className, selected && commonSelectedClassName, selected && selectedClassName, (_b = {},
|
|
27
|
+
_b[styles__default.default.selected] = selected,
|
|
28
|
+
_b)), onClick: handleClick }),
|
|
29
|
+
React__default.default.createElement("div", { className: cn__default.default(styles__default.default.icon, commonIconClassName, iconClassName) }, React.isValidElement(icon) ? React.cloneElement(icon, { selected: selected }) : icon),
|
|
30
|
+
React__default.default.createElement(coreComponentsTypography.Typography.Text, { weight: 'medium', view: 'secondary-small', className: cn__default.default(styles__default.default.label, commonLabelClassName, labelClassName, (_c = {},
|
|
31
|
+
_c[styles__default.default.labelSelected] = selected,
|
|
32
|
+
_c)) }, React.isValidElement(label) ? React.cloneElement(label, { selected: selected }) : label),
|
|
33
|
+
showIndicator && (React__default.default.createElement("div", { className: styles__default.default.indicator },
|
|
34
|
+
React__default.default.createElement(coreComponentsBadge.Badge, tslib.__assign({ visibleIconOutline: true }, indicatorProps, { view: 'count' }))))));
|
|
35
|
+
});
|
|
36
|
+
var Tab = TabComponent;
|
|
37
|
+
|
|
38
|
+
exports.Tab = Tab;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./Component";
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
var components_tab_Component = require('./Component.js');
|
|
6
|
+
require('tslib');
|
|
7
|
+
require('react');
|
|
8
|
+
require('classnames');
|
|
9
|
+
require('@alfalab/core-components-badge/cssm');
|
|
10
|
+
require('@alfalab/core-components-typography/cssm');
|
|
11
|
+
require('./index.module.css');
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
exports.Tab = components_tab_Component.Tab;
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
:root {
|
|
2
|
+
} /* deprecated */ :root {
|
|
3
|
+
--color-light-accent-primary: #ef3124;
|
|
4
|
+
--color-light-neutral-translucent-700: rgba(4, 4, 21, 0.47);
|
|
5
|
+
--color-light-text-secondary: rgba(4, 4, 19, 0.55); /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */
|
|
6
|
+
} :root { /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */
|
|
7
|
+
} :root {
|
|
8
|
+
} :root {
|
|
9
|
+
|
|
10
|
+
/* Hard */
|
|
11
|
+
|
|
12
|
+
/* Up */
|
|
13
|
+
|
|
14
|
+
/* Hard up */
|
|
15
|
+
} :root {
|
|
16
|
+
} :root {
|
|
17
|
+
--gap-2xs: 4px;
|
|
18
|
+
--gap-xs: 8px;
|
|
19
|
+
} :root {
|
|
20
|
+
} :root {
|
|
21
|
+
} .component {
|
|
22
|
+
box-sizing: border-box;
|
|
23
|
+
background-color: transparent;
|
|
24
|
+
-webkit-tap-highlight-color: transparent;
|
|
25
|
+
outline: none;
|
|
26
|
+
border: 0;
|
|
27
|
+
margin: 0;
|
|
28
|
+
box-shadow: none;
|
|
29
|
+
border-radius: 0;
|
|
30
|
+
-webkit-user-select: none;
|
|
31
|
+
user-select: none;
|
|
32
|
+
vertical-align: middle;
|
|
33
|
+
appearance: none;
|
|
34
|
+
text-decoration: none;
|
|
35
|
+
min-width: 0;
|
|
36
|
+
cursor: pointer;
|
|
37
|
+
|
|
38
|
+
position: relative;
|
|
39
|
+
display: inline-flex;
|
|
40
|
+
flex-direction: column;
|
|
41
|
+
flex: 1 0 0;
|
|
42
|
+
align-items: center;
|
|
43
|
+
padding: var(--gap-xs) 0;
|
|
44
|
+
color: var(--color-light-neutral-translucent-700);
|
|
45
|
+
} .selected {
|
|
46
|
+
color: var(--color-light-accent-primary);
|
|
47
|
+
} .icon {
|
|
48
|
+
display: flex;
|
|
49
|
+
align-items: center;
|
|
50
|
+
justify-content: center;
|
|
51
|
+
flex-grow: 1;
|
|
52
|
+
width: 100%;
|
|
53
|
+
} .label {
|
|
54
|
+
-webkit-line-clamp: 1;
|
|
55
|
+
display: -webkit-box;
|
|
56
|
+
-webkit-box-orient: vertical;
|
|
57
|
+
overflow: hidden;
|
|
58
|
+
word-break: break-all;
|
|
59
|
+
flex-shrink: 0;
|
|
60
|
+
|
|
61
|
+
color: var(--color-light-text-secondary);
|
|
62
|
+
} .labelSelected {
|
|
63
|
+
color: inherit;
|
|
64
|
+
} .indicator {
|
|
65
|
+
position: absolute;
|
|
66
|
+
top: var(--gap-2xs);
|
|
67
|
+
left: calc(50% + var(--gap-2xs));
|
|
68
|
+
height: 16px;
|
|
69
|
+
min-width: 16px;
|
|
70
|
+
}
|
package/cssm/index.d.ts
ADDED
package/cssm/index.js
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
var Component = require('./Component.js');
|
|
6
|
+
require('tslib');
|
|
7
|
+
require('react');
|
|
8
|
+
require('classnames');
|
|
9
|
+
require('@alfalab/core-components-shared/cssm');
|
|
10
|
+
require('./components/tab/Component.js');
|
|
11
|
+
require('@alfalab/core-components-badge/cssm');
|
|
12
|
+
require('@alfalab/core-components-typography/cssm');
|
|
13
|
+
require('./components/tab/index.module.css');
|
|
14
|
+
require('./index.module.css');
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
exports.TabBar = Component.TabBar;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
:root {
|
|
2
|
+
} /* deprecated */ :root {
|
|
3
|
+
--color-light-base-bg-primary: #fff;
|
|
4
|
+
--color-light-neutral-300: #e7e8eb; /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */
|
|
5
|
+
} :root { /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */
|
|
6
|
+
} :root {
|
|
7
|
+
} :root {
|
|
8
|
+
|
|
9
|
+
/* Hard */
|
|
10
|
+
|
|
11
|
+
/* Up */
|
|
12
|
+
|
|
13
|
+
/* Hard up */
|
|
14
|
+
} :root {
|
|
15
|
+
} :root {
|
|
16
|
+
} :root {
|
|
17
|
+
} :root {
|
|
18
|
+
} .component {
|
|
19
|
+
display: flex;
|
|
20
|
+
justify-content: center;
|
|
21
|
+
height: 64px;
|
|
22
|
+
max-height: 64px;
|
|
23
|
+
background-color: var(--color-light-base-bg-primary);
|
|
24
|
+
box-sizing: border-box;
|
|
25
|
+
overflow: hidden;
|
|
26
|
+
transition: box-shadow 0.2s ease;
|
|
27
|
+
} .border {
|
|
28
|
+
box-shadow: 0 -1px 0 0 var(--color-light-neutral-300);
|
|
29
|
+
}
|
package/cssm/types.d.ts
ADDED
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
import { AllHTMLAttributes, ElementType, ForwardRefExoticComponent, HTMLAttributes, ReactElement, ReactNode, RefAttributes } from 'react';
|
|
2
|
+
import { BadgeProps } from "@alfalab/core-components-badge";
|
|
3
|
+
type TabElementType = ReactElement<TabProps, ForwardRefExoticComponent<TabProps & RefAttributes<HTMLElement>>>;
|
|
4
|
+
interface TabBarProps extends Omit<HTMLAttributes<HTMLDivElement>, 'onChange'> {
|
|
5
|
+
/**
|
|
6
|
+
* Дополнительный класс
|
|
7
|
+
*/
|
|
8
|
+
className?: string;
|
|
9
|
+
/**
|
|
10
|
+
* Идентификатор для систем автоматизированного тестирования.
|
|
11
|
+
* Для таба используется модификатор -tab
|
|
12
|
+
*/
|
|
13
|
+
dataTestId?: string;
|
|
14
|
+
/**
|
|
15
|
+
* Дополнительные классы для таба.
|
|
16
|
+
*/
|
|
17
|
+
tabClassNames?: {
|
|
18
|
+
/**
|
|
19
|
+
* Дополнительный класс таба
|
|
20
|
+
*/
|
|
21
|
+
className?: string;
|
|
22
|
+
/**
|
|
23
|
+
* Дополнительный класс таба в выбранном состоянии
|
|
24
|
+
*/
|
|
25
|
+
selectedClassName?: string;
|
|
26
|
+
/**
|
|
27
|
+
* Дополнительный класс подписи
|
|
28
|
+
*/
|
|
29
|
+
labelClassName?: string;
|
|
30
|
+
/**
|
|
31
|
+
* Дополнительный класс враппера иконки
|
|
32
|
+
*/
|
|
33
|
+
iconClassName?: string;
|
|
34
|
+
};
|
|
35
|
+
/**
|
|
36
|
+
* Список табов
|
|
37
|
+
*/
|
|
38
|
+
children: TabElementType[];
|
|
39
|
+
/**
|
|
40
|
+
* Идентификатор выбранного таба
|
|
41
|
+
*/
|
|
42
|
+
selectedId?: string;
|
|
43
|
+
/**
|
|
44
|
+
* Включает верхний бордер
|
|
45
|
+
*/
|
|
46
|
+
border?: boolean;
|
|
47
|
+
/**
|
|
48
|
+
* Обработчик изменения выбранного таба
|
|
49
|
+
*/
|
|
50
|
+
onChange?: (id: string) => void;
|
|
51
|
+
}
|
|
52
|
+
type AdditionalTabProps = Record<string, unknown>;
|
|
53
|
+
interface TabProps extends Omit<AllHTMLAttributes<unknown>, 'onChange' | 'label'>, AdditionalTabProps {
|
|
54
|
+
/**
|
|
55
|
+
* Кастомный компонент таба.
|
|
56
|
+
* @default button
|
|
57
|
+
*/
|
|
58
|
+
Component?: ElementType;
|
|
59
|
+
/**
|
|
60
|
+
* Идентификатор таба
|
|
61
|
+
*/
|
|
62
|
+
id: string;
|
|
63
|
+
/**
|
|
64
|
+
* Лейбл
|
|
65
|
+
*/
|
|
66
|
+
label: ReactNode;
|
|
67
|
+
/**
|
|
68
|
+
* Иконка
|
|
69
|
+
*/
|
|
70
|
+
icon: ReactNode;
|
|
71
|
+
/**
|
|
72
|
+
* Показать индикатор
|
|
73
|
+
*/
|
|
74
|
+
showIndicator?: boolean;
|
|
75
|
+
/**
|
|
76
|
+
* Свойства индикатора
|
|
77
|
+
*/
|
|
78
|
+
indicatorProps?: Omit<BadgeProps, 'view' | 'visibleColorOutline' | 'size' | 'iconColor' | 'iconUnderlayColor'>;
|
|
79
|
+
/**
|
|
80
|
+
* Дополнительный класс таба
|
|
81
|
+
*/
|
|
82
|
+
className?: string;
|
|
83
|
+
/**
|
|
84
|
+
* Дополнительный класс таба в выбранном состоянии
|
|
85
|
+
*/
|
|
86
|
+
selectedClassName?: string;
|
|
87
|
+
/**
|
|
88
|
+
* Дополнительный класс подписи
|
|
89
|
+
*/
|
|
90
|
+
labelClassName?: string;
|
|
91
|
+
/**
|
|
92
|
+
* Дополнительный класс враппера иконки
|
|
93
|
+
*/
|
|
94
|
+
iconClassName?: string;
|
|
95
|
+
}
|
|
96
|
+
interface PrivateTabProps extends Pick<TabBarProps, 'tabClassNames' | 'onChange' | 'dataTestId'> {
|
|
97
|
+
selected: boolean;
|
|
98
|
+
}
|
|
99
|
+
export { TabBarProps, TabProps, PrivateTabProps };
|
package/cssm/types.js
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import React from 'react';
|
|
3
|
+
import { TabBarProps } from "./types";
|
|
4
|
+
declare const TabBar: React.ForwardRefExoticComponent<TabBarProps & React.RefAttributes<HTMLDivElement>> & {
|
|
5
|
+
Tab: React.ForwardRefExoticComponent<import("./types").TabProps & React.RefAttributes<HTMLElement>>;
|
|
6
|
+
};
|
|
7
|
+
export { TabBar };
|
package/esm/Component.js
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { __rest, __assign } from 'tslib';
|
|
2
|
+
import React, { forwardRef, Children, cloneElement } from 'react';
|
|
3
|
+
import cn from 'classnames';
|
|
4
|
+
import { getDataTestId } from '@alfalab/core-components-shared/esm';
|
|
5
|
+
import { Tab } from './components/tab/Component.js';
|
|
6
|
+
import '@alfalab/core-components-badge/esm';
|
|
7
|
+
import '@alfalab/core-components-typography/esm';
|
|
8
|
+
|
|
9
|
+
var styles = {"component":"tab-bar__component_1tqhl","border":"tab-bar__border_1tqhl"};
|
|
10
|
+
require('./index.css')
|
|
11
|
+
|
|
12
|
+
var TabBarComponent = forwardRef(function (_a, ref) {
|
|
13
|
+
var _b;
|
|
14
|
+
var children = _a.children, className = _a.className, selectedId = _a.selectedId, border = _a.border, dataTestId = _a.dataTestId, tabClassNames = _a.tabClassNames, onChange = _a.onChange, restProps = __rest(_a, ["children", "className", "selectedId", "border", "dataTestId", "tabClassNames", "onChange"]);
|
|
15
|
+
if (Children.count(children) > 5) {
|
|
16
|
+
// eslint-disable-next-line no-console
|
|
17
|
+
console.error('Компонент TabBar не может содержать больше 5 табов');
|
|
18
|
+
}
|
|
19
|
+
return (React.createElement("nav", __assign({ "data-test-id": dataTestId }, restProps, { ref: ref, className: cn(styles.component, className, (_b = {}, _b[styles.border] = border, _b)) }), Children.map(children, function (tab) {
|
|
20
|
+
return cloneElement(tab, {
|
|
21
|
+
selected: tab.props.id === selectedId,
|
|
22
|
+
onChange: onChange,
|
|
23
|
+
tabClassNames: tabClassNames,
|
|
24
|
+
dataTestId: getDataTestId(dataTestId, 'tab'),
|
|
25
|
+
});
|
|
26
|
+
})));
|
|
27
|
+
});
|
|
28
|
+
var TabBar = Object.assign(TabBarComponent, { Tab: Tab });
|
|
29
|
+
|
|
30
|
+
export { TabBar };
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { __rest, __assign } from 'tslib';
|
|
2
|
+
import React, { forwardRef, isValidElement, cloneElement } from 'react';
|
|
3
|
+
import cn from 'classnames';
|
|
4
|
+
import { Badge } from '@alfalab/core-components-badge/esm';
|
|
5
|
+
import { Typography } from '@alfalab/core-components-typography/esm';
|
|
6
|
+
|
|
7
|
+
var styles = {"component":"tab-bar__component_1cyxn","selected":"tab-bar__selected_1cyxn","icon":"tab-bar__icon_1cyxn","label":"tab-bar__label_1cyxn","labelSelected":"tab-bar__labelSelected_1cyxn","indicator":"tab-bar__indicator_1cyxn"};
|
|
8
|
+
require('./index.css')
|
|
9
|
+
|
|
10
|
+
var TabComponent = forwardRef(function (_a, ref) {
|
|
11
|
+
var _b, _c;
|
|
12
|
+
var showIndicator = _a.showIndicator, indicatorProps = _a.indicatorProps, label = _a.label, icon = _a.icon, id = _a.id, selected = _a.selected, onChange = _a.onChange, onClick = _a.onClick, _d = _a.tabClassNames, tabClassNames = _d === void 0 ? {} : _d, dataTestId = _a.dataTestId, className = _a.className, labelClassName = _a.labelClassName, selectedClassName = _a.selectedClassName, iconClassName = _a.iconClassName, href = _a.href, _e = _a.Component, Component = _e === void 0 ? href ? 'a' : 'button' : _e, restProps = __rest(_a, ["showIndicator", "indicatorProps", "label", "icon", "id", "selected", "onChange", "onClick", "tabClassNames", "dataTestId", "className", "labelClassName", "selectedClassName", "iconClassName", "href", "Component"]);
|
|
13
|
+
var handleClick = function (event) {
|
|
14
|
+
onChange === null || onChange === void 0 ? void 0 : onChange(id);
|
|
15
|
+
onClick === null || onClick === void 0 ? void 0 : onClick(event);
|
|
16
|
+
};
|
|
17
|
+
var commonClassName = tabClassNames.className, commonLabelClassName = tabClassNames.labelClassName, commonSelectedClassName = tabClassNames.selectedClassName, commonIconClassName = tabClassNames.iconClassName;
|
|
18
|
+
return (React.createElement(Component, __assign({ "data-test-id": dataTestId, tabIndex: 0 }, (Component === 'button' ? { type: 'button' } : null), restProps, { href: href, id: id, ref: ref, className: cn(styles.component, commonClassName, className, selected && commonSelectedClassName, selected && selectedClassName, (_b = {},
|
|
19
|
+
_b[styles.selected] = selected,
|
|
20
|
+
_b)), onClick: handleClick }),
|
|
21
|
+
React.createElement("div", { className: cn(styles.icon, commonIconClassName, iconClassName) }, isValidElement(icon) ? cloneElement(icon, { selected: selected }) : icon),
|
|
22
|
+
React.createElement(Typography.Text, { weight: 'medium', view: 'secondary-small', className: cn(styles.label, commonLabelClassName, labelClassName, (_c = {},
|
|
23
|
+
_c[styles.labelSelected] = selected,
|
|
24
|
+
_c)) }, isValidElement(label) ? cloneElement(label, { selected: selected }) : label),
|
|
25
|
+
showIndicator && (React.createElement("div", { className: styles.indicator },
|
|
26
|
+
React.createElement(Badge, __assign({ visibleIconOutline: true }, indicatorProps, { view: 'count' }))))));
|
|
27
|
+
});
|
|
28
|
+
var Tab = TabComponent;
|
|
29
|
+
|
|
30
|
+
export { Tab };
|