react-better-html 1.1.82 → 1.1.83
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/index.d.mts +6 -1
- package/dist/index.d.ts +6 -1
- package/dist/index.js +16 -12
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +21 -17
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -638,10 +638,15 @@ type TabsProps = {
|
|
|
638
638
|
name?: string;
|
|
639
639
|
accentColor?: Color;
|
|
640
640
|
style?: "default" | "borderRadiusTop" | "box";
|
|
641
|
+
onChange?: (tab: string) => void;
|
|
641
642
|
children?: React.ReactNode;
|
|
642
643
|
} & ComponentMarginProps;
|
|
644
|
+
type TabsRef = {
|
|
645
|
+
selectedTab: string;
|
|
646
|
+
setSelectedTab: (tab: string) => void;
|
|
647
|
+
};
|
|
643
648
|
type TabsComponent = {
|
|
644
|
-
(props: TabsProps): React.ReactElement;
|
|
649
|
+
(props: ComponentPropWithRef<TabsRef, TabsProps>): React.ReactElement;
|
|
645
650
|
content: (props: TabsContentProps) => React.ReactElement;
|
|
646
651
|
};
|
|
647
652
|
declare const TabsComponent: TabsComponent;
|
package/dist/index.d.ts
CHANGED
|
@@ -638,10 +638,15 @@ type TabsProps = {
|
|
|
638
638
|
name?: string;
|
|
639
639
|
accentColor?: Color;
|
|
640
640
|
style?: "default" | "borderRadiusTop" | "box";
|
|
641
|
+
onChange?: (tab: string) => void;
|
|
641
642
|
children?: React.ReactNode;
|
|
642
643
|
} & ComponentMarginProps;
|
|
644
|
+
type TabsRef = {
|
|
645
|
+
selectedTab: string;
|
|
646
|
+
setSelectedTab: (tab: string) => void;
|
|
647
|
+
};
|
|
643
648
|
type TabsComponent = {
|
|
644
|
-
(props: TabsProps): React.ReactElement;
|
|
649
|
+
(props: ComponentPropWithRef<TabsRef, TabsProps>): React.ReactElement;
|
|
645
650
|
content: (props: TabsContentProps) => React.ReactElement;
|
|
646
651
|
};
|
|
647
652
|
declare const TabsComponent: TabsComponent;
|
package/dist/index.js
CHANGED
|
@@ -6600,14 +6600,7 @@ var import_jsx_runtime22 = require("react/jsx-runtime");
|
|
|
6600
6600
|
var tabBottomLineWidth = 2;
|
|
6601
6601
|
var tabDotSize = 6;
|
|
6602
6602
|
var defaultTabName = "tab";
|
|
6603
|
-
var TabsComponent = function Tabs({
|
|
6604
|
-
tabs,
|
|
6605
|
-
name,
|
|
6606
|
-
accentColor,
|
|
6607
|
-
style = "default",
|
|
6608
|
-
children,
|
|
6609
|
-
...props
|
|
6610
|
-
}) {
|
|
6603
|
+
var TabsComponent = (0, import_react24.forwardRef)(function Tabs({ tabs, name, accentColor, style = "default", onChange, children, ...props }, ref) {
|
|
6611
6604
|
const reactRouterDomPlugin2 = usePlugin("react-router-dom");
|
|
6612
6605
|
const theme2 = useTheme();
|
|
6613
6606
|
const urlQuery = reactRouterDomPlugin2 ? useUrlQuery() : void 0;
|
|
@@ -6628,13 +6621,14 @@ var TabsComponent = function Tabs({
|
|
|
6628
6621
|
const onClickTab = (0, import_react24.useCallback)(
|
|
6629
6622
|
(tab) => {
|
|
6630
6623
|
setSelectedTab(tab);
|
|
6624
|
+
onChange?.(tab);
|
|
6631
6625
|
if (urlQuery) {
|
|
6632
6626
|
urlQuery.setQuery({
|
|
6633
6627
|
[name ?? defaultTabName]: tab
|
|
6634
6628
|
});
|
|
6635
6629
|
}
|
|
6636
6630
|
},
|
|
6637
|
-
[name, urlQuery]
|
|
6631
|
+
[onChange, name, urlQuery]
|
|
6638
6632
|
);
|
|
6639
6633
|
const width = (0, import_react24.useMemo)(
|
|
6640
6634
|
() => tabsRef.current[selectedTab]?.getBoundingClientRect().width ?? 0,
|
|
@@ -6684,6 +6678,16 @@ var TabsComponent = function Tabs({
|
|
|
6684
6678
|
block: "nearest"
|
|
6685
6679
|
});
|
|
6686
6680
|
}, [selectedTab]);
|
|
6681
|
+
(0, import_react24.useImperativeHandle)(
|
|
6682
|
+
ref,
|
|
6683
|
+
() => {
|
|
6684
|
+
return {
|
|
6685
|
+
selectedTab,
|
|
6686
|
+
setSelectedTab: onClickTab
|
|
6687
|
+
};
|
|
6688
|
+
},
|
|
6689
|
+
[selectedTab, onClickTab]
|
|
6690
|
+
);
|
|
6687
6691
|
return /* @__PURE__ */ (0, import_jsx_runtime22.jsxs)(Div_default.column, { width: "100%", gap: theme2.styles.space, ...props, children: [
|
|
6688
6692
|
/* @__PURE__ */ (0, import_jsx_runtime22.jsxs)(Div_default, { position: "relative", className: "react-better-html-no-scrollbar", overflowY: "auto", children: [
|
|
6689
6693
|
/* @__PURE__ */ (0, import_jsx_runtime22.jsx)(Div_default.row, { position: "relative", width: "fit-content", gap: tabsGap, userSelect: "none", children: tabs.map((tab) => {
|
|
@@ -6705,8 +6709,8 @@ var TabsComponent = function Tabs({
|
|
|
6705
6709
|
cursor: "pointer",
|
|
6706
6710
|
isTabAccessed: true,
|
|
6707
6711
|
onClickWithValue: onClickTab,
|
|
6708
|
-
ref: (
|
|
6709
|
-
tabsRef.current[tab] =
|
|
6712
|
+
ref: (ref2) => {
|
|
6713
|
+
tabsRef.current[tab] = ref2;
|
|
6710
6714
|
},
|
|
6711
6715
|
children: [
|
|
6712
6716
|
componentsState.tabs.tabsWithDots.includes(tab) && /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(
|
|
@@ -6752,7 +6756,7 @@ var TabsComponent = function Tabs({
|
|
|
6752
6756
|
] }),
|
|
6753
6757
|
/* @__PURE__ */ (0, import_jsx_runtime22.jsx)(Div_default, { width: "100%", children })
|
|
6754
6758
|
] });
|
|
6755
|
-
};
|
|
6759
|
+
});
|
|
6756
6760
|
TabsComponent.content = function Content({ tab, tabWithDot, tabsGroupName, isInitialTab, children }) {
|
|
6757
6761
|
const { componentsState } = useBetterHtmlContextInternal();
|
|
6758
6762
|
const thisTabGroupData = (0, import_react24.useMemo)(
|