react-better-html 1.1.261 → 1.1.262
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 +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +23 -23
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +23 -23
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -7464,41 +7464,41 @@ var TabsComponent = forwardRef17(function Tabs({ tabs, name, accentColor, style
|
|
|
7464
7464
|
const firstRenderPassedRef = useRef8(false);
|
|
7465
7465
|
const tabsRef = useRef8({});
|
|
7466
7466
|
const tabsGap = gap ?? (style === "box" ? theme2.styles.gap / 2 : 0);
|
|
7467
|
-
const [
|
|
7468
|
-
const
|
|
7467
|
+
const [selectedTabId, setSelectedTabId] = useState13(() => {
|
|
7468
|
+
const selectedTabId2 = tabs[0];
|
|
7469
7469
|
if (urlQuery) {
|
|
7470
7470
|
const tabQueryValue = urlQuery.getQuery(name ?? defaultTabName);
|
|
7471
|
-
if (!tabQueryValue) return
|
|
7471
|
+
if (!tabQueryValue) return selectedTabId2.id;
|
|
7472
7472
|
const queryTab = tabs.find((tab) => tab.id === tabQueryValue);
|
|
7473
|
-
if (queryTab) return queryTab;
|
|
7473
|
+
if (queryTab) return queryTab.id;
|
|
7474
7474
|
}
|
|
7475
|
-
return
|
|
7475
|
+
return selectedTabId2.id;
|
|
7476
7476
|
});
|
|
7477
7477
|
const [rerenderState, setRerenderState] = useState13(0);
|
|
7478
7478
|
const onClickTab = useCallback16(
|
|
7479
|
-
(
|
|
7480
|
-
|
|
7481
|
-
onChange?.(
|
|
7479
|
+
(tabId) => {
|
|
7480
|
+
setSelectedTabId(tabId);
|
|
7481
|
+
onChange?.(tabId);
|
|
7482
7482
|
if (urlQuery) {
|
|
7483
7483
|
urlQuery.setQuery({
|
|
7484
|
-
[name ?? defaultTabName]:
|
|
7484
|
+
[name ?? defaultTabName]: tabId
|
|
7485
7485
|
});
|
|
7486
7486
|
}
|
|
7487
7487
|
},
|
|
7488
7488
|
[onChange, name, urlQuery]
|
|
7489
7489
|
);
|
|
7490
7490
|
const width = useMemo11(
|
|
7491
|
-
() => tabsRef.current[
|
|
7492
|
-
[rerenderState,
|
|
7491
|
+
() => tabsRef.current[selectedTabId]?.getBoundingClientRect().width ?? 0,
|
|
7492
|
+
[rerenderState, selectedTabId]
|
|
7493
7493
|
);
|
|
7494
7494
|
const leftSpacing = useMemo11(() => {
|
|
7495
|
-
const selectedTabIndex = tabs.findIndex((tab) => tab.id ===
|
|
7495
|
+
const selectedTabIndex = tabs.findIndex((tab) => tab.id === selectedTabId);
|
|
7496
7496
|
let spacing = 0;
|
|
7497
7497
|
Object.values(tabsRef.current).forEach((tab, index) => {
|
|
7498
7498
|
if (index < selectedTabIndex) spacing += (tab?.getBoundingClientRect().width ?? 0) + tabsGap;
|
|
7499
7499
|
});
|
|
7500
7500
|
return spacing;
|
|
7501
|
-
}, [
|
|
7501
|
+
}, [selectedTabId, tabs, tabsGap]);
|
|
7502
7502
|
useEffect14(() => {
|
|
7503
7503
|
const timeout = setTimeout(() => {
|
|
7504
7504
|
setRerenderState(Math.random());
|
|
@@ -7515,7 +7515,7 @@ var TabsComponent = forwardRef17(function Tabs({ tabs, name, accentColor, style
|
|
|
7515
7515
|
return oldValue.map(
|
|
7516
7516
|
(item) => item.name === (name ?? defaultTabName) ? {
|
|
7517
7517
|
...item,
|
|
7518
|
-
selectedTab:
|
|
7518
|
+
selectedTab: selectedTabId
|
|
7519
7519
|
} : item
|
|
7520
7520
|
);
|
|
7521
7521
|
} else {
|
|
@@ -7523,18 +7523,18 @@ var TabsComponent = forwardRef17(function Tabs({ tabs, name, accentColor, style
|
|
|
7523
7523
|
...oldValue,
|
|
7524
7524
|
{
|
|
7525
7525
|
name: name ?? defaultTabName,
|
|
7526
|
-
selectedTab:
|
|
7526
|
+
selectedTab: selectedTabId
|
|
7527
7527
|
}
|
|
7528
7528
|
];
|
|
7529
7529
|
}
|
|
7530
7530
|
});
|
|
7531
|
-
}, [
|
|
7531
|
+
}, [selectedTabId, name]);
|
|
7532
7532
|
useEffect14(() => {
|
|
7533
|
-
tabsRef.current[
|
|
7533
|
+
tabsRef.current[selectedTabId]?.scrollIntoView({
|
|
7534
7534
|
behavior: firstRenderPassedRef.current ? "smooth" : void 0,
|
|
7535
7535
|
block: "nearest"
|
|
7536
7536
|
});
|
|
7537
|
-
}, [
|
|
7537
|
+
}, [selectedTabId]);
|
|
7538
7538
|
useEffect14(() => {
|
|
7539
7539
|
return () => {
|
|
7540
7540
|
componentsState.tabs.setTabGroups(
|
|
@@ -7543,18 +7543,18 @@ var TabsComponent = forwardRef17(function Tabs({ tabs, name, accentColor, style
|
|
|
7543
7543
|
};
|
|
7544
7544
|
}, []);
|
|
7545
7545
|
useEffect14(() => {
|
|
7546
|
-
onChange?.(
|
|
7546
|
+
onChange?.(selectedTabId);
|
|
7547
7547
|
}, []);
|
|
7548
7548
|
useImperativeHandle4(ref, () => {
|
|
7549
7549
|
return {
|
|
7550
|
-
selectedTab:
|
|
7550
|
+
selectedTab: selectedTabId,
|
|
7551
7551
|
selectTab: onClickTab
|
|
7552
7552
|
};
|
|
7553
|
-
}, [
|
|
7553
|
+
}, [selectedTabId, onClickTab]);
|
|
7554
7554
|
return /* @__PURE__ */ jsxs22(Div_default.column, { width: "100%", gap: theme2.styles.space, ...props, children: [
|
|
7555
7555
|
/* @__PURE__ */ jsxs22(Div_default, { position: "relative", className: "react-better-html-no-scrollbar", overflowY: "auto", children: [
|
|
7556
7556
|
/* @__PURE__ */ jsx25(Div_default.row, { position: "relative", width: "fit-content", gap: tabsGap, userSelect: "none", children: tabs.map((tab) => {
|
|
7557
|
-
const selected = tab.id ===
|
|
7557
|
+
const selected = tab.id === selectedTabId;
|
|
7558
7558
|
return /* @__PURE__ */ jsxs22(
|
|
7559
7559
|
Div_default,
|
|
7560
7560
|
{
|
|
@@ -7569,7 +7569,7 @@ var TabsComponent = forwardRef17(function Tabs({ tabs, name, accentColor, style
|
|
|
7569
7569
|
filterHover: colorTheme === "dark" ? style === "box" ? "brightness(1.2)" : "brightness(2)" : "brightness(0.9)",
|
|
7570
7570
|
paddingInline: theme2.styles.space,
|
|
7571
7571
|
paddingBlock: theme2.styles.gap,
|
|
7572
|
-
value: tab,
|
|
7572
|
+
value: tab.id,
|
|
7573
7573
|
cursor: "pointer",
|
|
7574
7574
|
isTabAccessed: true,
|
|
7575
7575
|
onClickWithValue: onClickTab,
|