@longline/aqua-ui 1.0.253 → 1.0.255
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/controls/TabBar/Tab.d.ts +4 -0
- package/controls/TabBar/Tab.js +12 -4
- package/package.json +1 -1
package/controls/TabBar/Tab.d.ts
CHANGED
|
@@ -26,6 +26,10 @@ interface ITabProps {
|
|
|
26
26
|
* @default false
|
|
27
27
|
*/
|
|
28
28
|
disabled?: boolean;
|
|
29
|
+
/**
|
|
30
|
+
* Optional badge to show by label.
|
|
31
|
+
*/
|
|
32
|
+
badge?: React.ReactNode;
|
|
29
33
|
}
|
|
30
34
|
declare const Tab: React.ForwardRefExoticComponent<ITabProps & React.RefAttributes<HTMLDivElement>>;
|
|
31
35
|
export { Tab, ITabProps };
|
package/controls/TabBar/Tab.js
CHANGED
|
@@ -28,15 +28,23 @@ import * as React from 'react';
|
|
|
28
28
|
import styled, { css } from 'styled-components';
|
|
29
29
|
import { Ghost } from '../Ghost';
|
|
30
30
|
var TabBase = React.forwardRef(function (props, ref) {
|
|
31
|
-
|
|
31
|
+
var handleClick = function () {
|
|
32
|
+
if (props.onClick)
|
|
33
|
+
props.onClick();
|
|
34
|
+
};
|
|
35
|
+
return (React.createElement("div", { className: props.className, role: "tab", "aria-selected": props.active, ref: ref, onClick: handleClick },
|
|
32
36
|
props.ghost && React.createElement(Ghost, { style: { position: 'absolute', left: '5px', top: '6px', right: '5px', bottom: '6px', zIndex: 100 } }),
|
|
33
|
-
React.createElement(
|
|
37
|
+
React.createElement(Content, null,
|
|
38
|
+
props.children,
|
|
39
|
+
props.badge !== undefined && React.createElement(Badge, null, props.badge))));
|
|
34
40
|
});
|
|
35
|
-
var TabStyled = styled(TabBase)(templateObject_6 || (templateObject_6 = __makeTemplateObject(["\n position: relative;\n display: table-cell;\n vertical-align: middle;\n
|
|
41
|
+
var TabStyled = styled(TabBase)(templateObject_6 || (templateObject_6 = __makeTemplateObject(["\n position: relative;\n display: table-cell;\n vertical-align: middle;\n padding: 0 20px;\n\n font: ", ";\n box-sizing: border-box;\n ", "\n height: 40px;\n z-index: 1;\n cursor: pointer;\n color: ", ";\n transition: color ", "ms ease-in-out;\n\n /* User cannot select header text.\n * This prevents accidental selection when clicking the tab.\n */\n user-select: none; \n\n ", " \n &:hover {\n color: ", ";\n }\n\n // Ghost and disabled cannot be clicked:\n ", "\n\n // Disabled:\n ", "\n\n // Ghost state:\n ", " \n"], ["\n position: relative;\n display: table-cell;\n vertical-align: middle;\n padding: 0 20px;\n\n font: ", ";\n box-sizing: border-box;\n ", "\n height: 40px;\n z-index: 1;\n cursor: pointer;\n color: ", ";\n transition: color ", "ms ease-in-out;\n\n /* User cannot select header text.\n * This prevents accidental selection when clicking the tab.\n */\n user-select: none; \n\n ", " \n &:hover {\n color: ", ";\n }\n\n // Ghost and disabled cannot be clicked:\n ", "\n\n // Disabled:\n ", "\n\n // Ghost state:\n ", " \n"])), function (p) { return p.theme.font.labelLarge; }, function (p) { return p.tabWidth && css(templateObject_1 || (templateObject_1 = __makeTemplateObject(["min-width: ", "px;"], ["min-width: ", "px;"])), p.tabWidth); }, function (p) { return p.theme.colors.neutral[80]; }, function (p) { return p.theme.animation.duration; }, function (p) { return p.active && css(templateObject_2 || (templateObject_2 = __makeTemplateObject(["\n color: ", ";\n "], ["\n color: ", ";\n "])), function (p) { return p.theme.colors.neutral[100]; }); }, function (p) { return p.theme.colors.neutral[100]; }, function (p) { return (p.ghost || p.disabled) && css(templateObject_3 || (templateObject_3 = __makeTemplateObject(["\n pointer-events: none;\n "], ["\n pointer-events: none;\n "]))); }, function (p) { return p.disabled && css(templateObject_4 || (templateObject_4 = __makeTemplateObject(["\n color: ", ";\n &:hover {\n color: ", ";\n }\n "], ["\n color: ", ";\n &:hover {\n color: ", ";\n }\n "])), function (p) { return p.theme.colors.neutral[50]; }, function (p) { return p.theme.colors.neutral[50]; }); }, function (p) { return p.ghost && css(templateObject_5 || (templateObject_5 = __makeTemplateObject(["\n & > *:not(:first-child) {\n visibility: hidden;\n } \n "], ["\n & > *:not(:first-child) {\n visibility: hidden;\n } \n "]))); });
|
|
42
|
+
var Content = styled.div(templateObject_7 || (templateObject_7 = __makeTemplateObject(["\n display: flex;\n justify-content: center;\n align-items: center;\n gap: 4px;\n white-space: nowrap;\n"], ["\n display: flex;\n justify-content: center;\n align-items: center;\n gap: 4px;\n white-space: nowrap;\n"])));
|
|
43
|
+
var Badge = styled.div(templateObject_8 || (templateObject_8 = __makeTemplateObject(["\n background: ", ";\n border-radius: ", "px;\n padding: 0 6px;\n font: ", ";\n"], ["\n background: ", ";\n border-radius: ", "px;\n padding: 0 6px;\n font: ", ";\n"])), function (p) { return p.theme.colors.primary[5]; }, function (p) { return p.theme.radius.normal; }, function (p) { return p.theme.font.labelSmall; });
|
|
36
44
|
var Tab = React.forwardRef(function (_a, ref) {
|
|
37
45
|
var _b = _a.ghost, ghost = _b === void 0 ? false : _b, _c = _a.disabled, disabled = _c === void 0 ? false : _c, props = __rest(_a, ["ghost", "disabled"]);
|
|
38
46
|
return React.createElement(TabStyled, __assign({ ref: ref, ghost: ghost, disabled: disabled }, props));
|
|
39
47
|
});
|
|
40
48
|
Tab.displayName = "TabBar.Tab";
|
|
41
49
|
export { Tab };
|
|
42
|
-
var templateObject_1, templateObject_2, templateObject_3, templateObject_4, templateObject_5, templateObject_6;
|
|
50
|
+
var templateObject_1, templateObject_2, templateObject_3, templateObject_4, templateObject_5, templateObject_6, templateObject_7, templateObject_8;
|