react-better-html 1.1.252 → 1.1.254
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.js +14 -10
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +14 -10
- package/dist/index.mjs.map +1 -1
- package/package.json +2 -2
package/dist/index.mjs
CHANGED
|
@@ -7405,11 +7405,12 @@ var TabsComponent = forwardRef17(function Tabs({ tabs, name, accentColor, style
|
|
|
7405
7405
|
const firstRenderPassedRef = useRef8(false);
|
|
7406
7406
|
const tabsRef = useRef8({});
|
|
7407
7407
|
const [selectedTab, setSelectedTab] = useState13(() => {
|
|
7408
|
-
const selectedTabId = tabs[0]
|
|
7408
|
+
const selectedTabId = tabs[0];
|
|
7409
7409
|
if (urlQuery) {
|
|
7410
7410
|
const tabQueryValue = urlQuery.getQuery(name ?? defaultTabName);
|
|
7411
7411
|
if (!tabQueryValue) return selectedTabId;
|
|
7412
|
-
|
|
7412
|
+
const queryTab = tabs.find((tab) => tab.id === tabQueryValue);
|
|
7413
|
+
if (queryTab) return queryTab;
|
|
7413
7414
|
}
|
|
7414
7415
|
return selectedTabId;
|
|
7415
7416
|
});
|
|
@@ -7417,7 +7418,7 @@ var TabsComponent = forwardRef17(function Tabs({ tabs, name, accentColor, style
|
|
|
7417
7418
|
const tabsGap = style === "box" ? theme2.styles.gap / 2 : 0;
|
|
7418
7419
|
const onClickTab = useCallback16(
|
|
7419
7420
|
(tab) => {
|
|
7420
|
-
setSelectedTab(tab
|
|
7421
|
+
setSelectedTab(tab);
|
|
7421
7422
|
onChange?.(tab);
|
|
7422
7423
|
if (urlQuery) {
|
|
7423
7424
|
urlQuery.setQuery({
|
|
@@ -7428,11 +7429,11 @@ var TabsComponent = forwardRef17(function Tabs({ tabs, name, accentColor, style
|
|
|
7428
7429
|
[onChange, name, urlQuery]
|
|
7429
7430
|
);
|
|
7430
7431
|
const width = useMemo11(
|
|
7431
|
-
() => tabsRef.current[selectedTab]?.getBoundingClientRect().width ?? 0,
|
|
7432
|
+
() => tabsRef.current[selectedTab.id]?.getBoundingClientRect().width ?? 0,
|
|
7432
7433
|
[rerenderState, selectedTab]
|
|
7433
7434
|
);
|
|
7434
7435
|
const leftSpacing = useMemo11(() => {
|
|
7435
|
-
const selectedTabIndex = tabs.findIndex((tab) => tab.id === selectedTab);
|
|
7436
|
+
const selectedTabIndex = tabs.findIndex((tab) => tab.id === selectedTab.id);
|
|
7436
7437
|
let spacing = 0;
|
|
7437
7438
|
Object.values(tabsRef.current).forEach((tab, index) => {
|
|
7438
7439
|
if (index < selectedTabIndex) spacing += (tab?.getBoundingClientRect().width ?? 0) + tabsGap;
|
|
@@ -7455,7 +7456,7 @@ var TabsComponent = forwardRef17(function Tabs({ tabs, name, accentColor, style
|
|
|
7455
7456
|
return oldValue.map(
|
|
7456
7457
|
(item) => item.name === (name ?? defaultTabName) ? {
|
|
7457
7458
|
...item,
|
|
7458
|
-
selectedTab
|
|
7459
|
+
selectedTab: selectedTab.id
|
|
7459
7460
|
} : item
|
|
7460
7461
|
);
|
|
7461
7462
|
} else {
|
|
@@ -7463,14 +7464,14 @@ var TabsComponent = forwardRef17(function Tabs({ tabs, name, accentColor, style
|
|
|
7463
7464
|
...oldValue,
|
|
7464
7465
|
{
|
|
7465
7466
|
name: name ?? defaultTabName,
|
|
7466
|
-
selectedTab
|
|
7467
|
+
selectedTab: selectedTab.id
|
|
7467
7468
|
}
|
|
7468
7469
|
];
|
|
7469
7470
|
}
|
|
7470
7471
|
});
|
|
7471
7472
|
}, [selectedTab, name]);
|
|
7472
7473
|
useEffect14(() => {
|
|
7473
|
-
tabsRef.current[selectedTab]?.scrollIntoView({
|
|
7474
|
+
tabsRef.current[selectedTab.id]?.scrollIntoView({
|
|
7474
7475
|
behavior: firstRenderPassedRef.current ? "smooth" : void 0,
|
|
7475
7476
|
block: "nearest"
|
|
7476
7477
|
});
|
|
@@ -7482,16 +7483,19 @@ var TabsComponent = forwardRef17(function Tabs({ tabs, name, accentColor, style
|
|
|
7482
7483
|
);
|
|
7483
7484
|
};
|
|
7484
7485
|
}, []);
|
|
7486
|
+
useEffect14(() => {
|
|
7487
|
+
onChange?.(selectedTab);
|
|
7488
|
+
}, []);
|
|
7485
7489
|
useImperativeHandle4(ref, () => {
|
|
7486
7490
|
return {
|
|
7487
|
-
selectedTab,
|
|
7491
|
+
selectedTab: selectedTab.id,
|
|
7488
7492
|
selectTab: onClickTab
|
|
7489
7493
|
};
|
|
7490
7494
|
}, [selectedTab, onClickTab]);
|
|
7491
7495
|
return /* @__PURE__ */ jsxs22(Div_default.column, { width: "100%", gap: theme2.styles.space, ...props, children: [
|
|
7492
7496
|
/* @__PURE__ */ jsxs22(Div_default, { position: "relative", className: "react-better-html-no-scrollbar", overflowY: "auto", children: [
|
|
7493
7497
|
/* @__PURE__ */ jsx25(Div_default.row, { position: "relative", width: "fit-content", gap: tabsGap, userSelect: "none", children: tabs.map((tab) => {
|
|
7494
|
-
const selected = tab.id === selectedTab;
|
|
7498
|
+
const selected = tab.id === selectedTab.id;
|
|
7495
7499
|
return /* @__PURE__ */ jsxs22(
|
|
7496
7500
|
Div_default,
|
|
7497
7501
|
{
|