@homebound/beam 2.349.1 → 2.350.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.
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { ReactNode } from "react";
|
|
2
|
-
import
|
|
2
|
+
import { IconKey } from "./";
|
|
3
3
|
import { Margin, Only, Padding, Xss } from "../Css";
|
|
4
4
|
import { AnyObject } from "../types";
|
|
5
5
|
export interface Tab<V extends string = string> {
|
|
@@ -7,7 +7,8 @@ export interface Tab<V extends string = string> {
|
|
|
7
7
|
value: V;
|
|
8
8
|
icon?: IconKey;
|
|
9
9
|
endAdornment?: ReactNode;
|
|
10
|
-
disabled
|
|
10
|
+
/** Whether the Tab is disabled. If a ReactNode, it's treated as a "disabled reason" that's shown in a tooltip. */
|
|
11
|
+
disabled?: boolean | ReactNode;
|
|
11
12
|
}
|
|
12
13
|
type TabsContentXss = Xss<Margin | Padding | "backgroundColor">;
|
|
13
14
|
export interface TabsProps<V extends string, X> {
|
package/dist/components/Tabs.js
CHANGED
|
@@ -88,7 +88,8 @@ function Tabs(props) {
|
|
|
88
88
|
exports.Tabs = Tabs;
|
|
89
89
|
function TabImpl(props) {
|
|
90
90
|
const { tab, onClick, active, onKeyUp, onBlur, focusProps, isFocusVisible = false, ...others } = props;
|
|
91
|
-
const { disabled
|
|
91
|
+
const { disabled = false, name: label, icon, endAdornment } = tab;
|
|
92
|
+
const isDisabled = !!disabled;
|
|
92
93
|
const { hoverProps, isHovered } = (0, react_aria_1.useHover)({ isDisabled });
|
|
93
94
|
const { baseStyles, activeStyles, focusRingStyles, hoverStyles, disabledStyles, activeHoverStyles } = (0, react_1.useMemo)(() => getTabStyles(), []);
|
|
94
95
|
const uniqueValue = uniqueTabValue(tab);
|
|
@@ -115,7 +116,11 @@ function TabImpl(props) {
|
|
|
115
116
|
...(isRouteTab(tab) ? {} : { onClick: () => onClick(tab.value) }),
|
|
116
117
|
});
|
|
117
118
|
const tabLabel = ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [label, (icon || endAdornment) && (0, jsx_runtime_1.jsx)("span", { css: Css_1.Css.ml1.$, children: icon ? (0, jsx_runtime_1.jsx)(Icon_1.Icon, { icon: icon }) : endAdornment })] }));
|
|
118
|
-
return isDisabled ? ((0,
|
|
119
|
+
return isDisabled ? ((0, components_1.maybeTooltip)({
|
|
120
|
+
title: (0, components_1.resolveTooltip)(disabled),
|
|
121
|
+
placement: "top",
|
|
122
|
+
children: (0, jsx_runtime_1.jsx)("div", { ...tabProps, children: tabLabel }),
|
|
123
|
+
})) : isRouteTab(tab) ? ((0, jsx_runtime_1.jsx)(react_router_dom_1.Link, { ...{ ...tabProps, ...interactiveProps }, className: "navLink", to: tab.href, children: tabLabel })) : ((0, jsx_runtime_1.jsx)("button", { ...{ ...tabProps, ...interactiveProps }, children: tabLabel }));
|
|
119
124
|
}
|
|
120
125
|
function getTabStyles() {
|
|
121
126
|
const borderBottomWidthPx = 4;
|