@luscii-healthtech/web-ui 0.9.2 → 0.9.3
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/dist/components/Tabbar/Tabbar.d.ts +1 -1
- package/dist/components/Tabbar/TabbarItem.d.ts +2 -1
- package/dist/web-ui.cjs.development.js +24 -3
- package/dist/web-ui.cjs.development.js.map +1 -1
- package/dist/web-ui.cjs.production.min.js +1 -1
- package/dist/web-ui.cjs.production.min.js.map +1 -1
- package/dist/web-ui.esm.js +24 -3
- package/dist/web-ui.esm.js.map +1 -1
- package/package.json +1 -1
- package/src/components/Tabbar/Tabbar.tsx +29 -6
- package/src/components/Tabbar/TabbarItem.tsx +17 -4
|
@@ -6,5 +6,5 @@ interface TabbarProps {
|
|
|
6
6
|
onSelect?: (index: number) => void;
|
|
7
7
|
className?: string;
|
|
8
8
|
}
|
|
9
|
-
export declare const Tabbar: ({ tabs, selectedIndex, onSelect, className }: TabbarProps) => JSX.Element;
|
|
9
|
+
export declare const Tabbar: ({ tabs, selectedIndex, onSelect, className, }: TabbarProps) => JSX.Element;
|
|
10
10
|
export default Tabbar;
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
|
-
export interface TabItemDetails {
|
|
2
|
+
export interface TabItemDetails<T extends object = Record<string, unknown>> {
|
|
3
3
|
title: string | JSX.Element;
|
|
4
4
|
badgeCount?: number;
|
|
5
5
|
isLoading?: boolean;
|
|
6
6
|
dataTestId?: string;
|
|
7
|
+
extra?: T;
|
|
7
8
|
}
|
|
8
9
|
interface TabbarItemProps extends TabItemDetails {
|
|
9
10
|
index: number;
|
|
@@ -3949,15 +3949,36 @@ var Tabbar = function Tabbar(_ref) {
|
|
|
3949
3949
|
onSelect = _ref.onSelect,
|
|
3950
3950
|
_ref$className = _ref.className,
|
|
3951
3951
|
className = _ref$className === void 0 ? "" : _ref$className;
|
|
3952
|
+
|
|
3953
|
+
var _useState = React.useState(tabs),
|
|
3954
|
+
innerTabs = _useState[0],
|
|
3955
|
+
setInnerTabs = _useState[1];
|
|
3956
|
+
|
|
3957
|
+
var _useState2 = React.useState(selectedIndex),
|
|
3958
|
+
innerSelectedIndex = _useState2[0],
|
|
3959
|
+
setInnerSelectedIndex = _useState2[1];
|
|
3960
|
+
|
|
3961
|
+
React.useEffect(function () {
|
|
3962
|
+
setInnerTabs(tabs);
|
|
3963
|
+
}, [tabs]);
|
|
3964
|
+
React.useEffect(function () {
|
|
3965
|
+
setInnerSelectedIndex(innerSelectedIndex);
|
|
3966
|
+
}, [innerSelectedIndex]);
|
|
3967
|
+
|
|
3968
|
+
function handleOnTabSelect(index) {
|
|
3969
|
+
setInnerSelectedIndex(index);
|
|
3970
|
+
onSelect == null ? void 0 : onSelect(index);
|
|
3971
|
+
}
|
|
3972
|
+
|
|
3952
3973
|
return /*#__PURE__*/React__default.createElement("div", {
|
|
3953
3974
|
className: "flex flex-row w-full bg-white rounded-xl " + className
|
|
3954
|
-
},
|
|
3975
|
+
}, innerTabs == null ? void 0 : innerTabs.map(function (tabItemProps, index) {
|
|
3955
3976
|
var _tabItemProps$dataTes;
|
|
3956
3977
|
|
|
3957
3978
|
var itemProps = _extends({
|
|
3958
3979
|
index: index,
|
|
3959
|
-
onSelect:
|
|
3960
|
-
isSelected:
|
|
3980
|
+
onSelect: handleOnTabSelect,
|
|
3981
|
+
isSelected: innerSelectedIndex === index
|
|
3961
3982
|
}, tabItemProps);
|
|
3962
3983
|
|
|
3963
3984
|
return /*#__PURE__*/React__default.createElement(TabbarItem, Object.assign({
|