nntc-ui 0.0.24 → 0.0.26
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/index.d.ts +2 -0
- package/index.js +60 -47
- package/package.json +1 -1
package/index.d.ts
CHANGED
|
@@ -210,6 +210,7 @@ interface Item$1<T> {
|
|
|
210
210
|
name?: string;
|
|
211
211
|
value: T;
|
|
212
212
|
icon?: ReactNode | string;
|
|
213
|
+
onClick?: () => void;
|
|
213
214
|
}
|
|
214
215
|
|
|
215
216
|
type Size$1 = 'medium' | 'small';
|
|
@@ -221,6 +222,7 @@ interface Props$8<T> {
|
|
|
221
222
|
filled?: boolean;
|
|
222
223
|
isVertical?: boolean;
|
|
223
224
|
disableBorder?: boolean;
|
|
225
|
+
allowDeselect?: boolean;
|
|
224
226
|
}
|
|
225
227
|
declare function Tabs<T>(props: UiProps<Props$8<T>>): react_jsx_runtime.JSX.Element;
|
|
226
228
|
|
package/index.js
CHANGED
|
@@ -2020,15 +2020,24 @@ function Tabs(props) {
|
|
|
2020
2020
|
filled: filled7 = false,
|
|
2021
2021
|
isVertical = false,
|
|
2022
2022
|
disableBorder: disableBorder2 = false,
|
|
2023
|
+
allowDeselect = false,
|
|
2023
2024
|
classes
|
|
2024
2025
|
} = props;
|
|
2025
2026
|
const [isMounted, setIsMounted] = useState8(false);
|
|
2026
2027
|
const [selectedTab, setSelectedTab] = useState8(defaultSelected);
|
|
2027
|
-
const handleClick = (
|
|
2028
|
-
|
|
2028
|
+
const handleClick = (item3) => () => {
|
|
2029
|
+
if (item3.onClick) {
|
|
2030
|
+
item3.onClick();
|
|
2031
|
+
return;
|
|
2032
|
+
}
|
|
2033
|
+
if (allowDeselect && selectedTab === item3.value) {
|
|
2034
|
+
setSelectedTab(void 0);
|
|
2035
|
+
} else {
|
|
2036
|
+
setSelectedTab(item3.value);
|
|
2037
|
+
}
|
|
2029
2038
|
};
|
|
2030
2039
|
useEffect5(() => {
|
|
2031
|
-
if (isMounted
|
|
2040
|
+
if (isMounted) {
|
|
2032
2041
|
onChange?.(selectedTab);
|
|
2033
2042
|
}
|
|
2034
2043
|
if (!isMounted) {
|
|
@@ -2046,51 +2055,55 @@ function Tabs(props) {
|
|
|
2046
2055
|
tabs_exports[size],
|
|
2047
2056
|
classes?.root
|
|
2048
2057
|
),
|
|
2049
|
-
children: items2.map((item3) =>
|
|
2050
|
-
|
|
2051
|
-
|
|
2052
|
-
|
|
2053
|
-
|
|
2054
|
-
|
|
2055
|
-
|
|
2056
|
-
|
|
2057
|
-
|
|
2058
|
-
|
|
2059
|
-
|
|
2060
|
-
|
|
2061
|
-
|
|
2062
|
-
|
|
2063
|
-
|
|
2064
|
-
/* @__PURE__ */ jsxs13(
|
|
2065
|
-
"div",
|
|
2066
|
-
{
|
|
2067
|
-
className: classnames15(
|
|
2068
|
-
tabTitle,
|
|
2069
|
-
classes?.tabTitle,
|
|
2070
|
-
selectedTab === item3.value ? classes?.tabSelectedTitle : void 0
|
|
2071
|
-
),
|
|
2072
|
-
children: [
|
|
2073
|
-
item3.icon && /* @__PURE__ */ jsx24("span", { className: tabIcon, children: typeof item3.icon === "string" ? /* @__PURE__ */ jsx24("span", { className: tabIcon, dangerouslySetInnerHTML: { __html: item3.icon } }) : item3.icon }),
|
|
2074
|
-
item3.name && /* @__PURE__ */ jsx24("span", { title: item3.name, children: item3.name })
|
|
2075
|
-
]
|
|
2076
|
-
}
|
|
2058
|
+
children: items2.map((item3) => {
|
|
2059
|
+
const isButton = !!item3.onClick;
|
|
2060
|
+
const isSelected = !isButton && selectedTab === item3.value;
|
|
2061
|
+
return /* @__PURE__ */ jsxs13(
|
|
2062
|
+
"div",
|
|
2063
|
+
{
|
|
2064
|
+
className: classnames15(
|
|
2065
|
+
tab,
|
|
2066
|
+
filled7 && tabFilled,
|
|
2067
|
+
isVertical && tabVertical,
|
|
2068
|
+
disableBorder2 && disableBorder,
|
|
2069
|
+
isSelected ? selected2 : void 0,
|
|
2070
|
+
isSelected && filled7 ? selectedFilled : void 0,
|
|
2071
|
+
classes?.tab,
|
|
2072
|
+
isSelected ? classes?.tabSelected : void 0
|
|
2077
2073
|
),
|
|
2078
|
-
|
|
2079
|
-
|
|
2080
|
-
|
|
2081
|
-
|
|
2082
|
-
|
|
2083
|
-
|
|
2084
|
-
|
|
2085
|
-
|
|
2086
|
-
|
|
2087
|
-
|
|
2088
|
-
|
|
2089
|
-
|
|
2090
|
-
|
|
2091
|
-
|
|
2092
|
-
|
|
2093
|
-
|
|
2074
|
+
onClick: handleClick(item3),
|
|
2075
|
+
children: [
|
|
2076
|
+
/* @__PURE__ */ jsxs13(
|
|
2077
|
+
"div",
|
|
2078
|
+
{
|
|
2079
|
+
className: classnames15(
|
|
2080
|
+
tabTitle,
|
|
2081
|
+
classes?.tabTitle,
|
|
2082
|
+
isSelected ? classes?.tabSelectedTitle : void 0
|
|
2083
|
+
),
|
|
2084
|
+
children: [
|
|
2085
|
+
item3.icon && /* @__PURE__ */ jsx24("span", { className: tabIcon, children: typeof item3.icon === "string" ? /* @__PURE__ */ jsx24("span", { className: tabIcon, dangerouslySetInnerHTML: { __html: item3.icon } }) : item3.icon }),
|
|
2086
|
+
item3.name && /* @__PURE__ */ jsx24("span", { title: item3.name, children: item3.name })
|
|
2087
|
+
]
|
|
2088
|
+
}
|
|
2089
|
+
),
|
|
2090
|
+
/* @__PURE__ */ jsx24(
|
|
2091
|
+
"div",
|
|
2092
|
+
{
|
|
2093
|
+
className: classnames15(
|
|
2094
|
+
tabBorder,
|
|
2095
|
+
isVertical && tabBorderVertical,
|
|
2096
|
+
disableBorder2 && disableBorder,
|
|
2097
|
+
classes?.tabBorder,
|
|
2098
|
+
isSelected ? classes?.tabSelectedBorder : void 0
|
|
2099
|
+
)
|
|
2100
|
+
}
|
|
2101
|
+
)
|
|
2102
|
+
]
|
|
2103
|
+
},
|
|
2104
|
+
`tab-${item3.value}`
|
|
2105
|
+
);
|
|
2106
|
+
})
|
|
2094
2107
|
}
|
|
2095
2108
|
);
|
|
2096
2109
|
}
|