react-better-html 1.1.270 → 1.1.272

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 CHANGED
@@ -520,6 +520,8 @@ type TabsProps = {
520
520
  style?: "default" | "borderRadiusTop" | "box";
521
521
  gap?: number;
522
522
  noBottomLine?: boolean;
523
+ /** @default true */
524
+ keepUrlHistory?: boolean;
523
525
  onChange?: (tab: Tab["id"]) => void;
524
526
  children?: React.ReactNode;
525
527
  } & ComponentMarginProps;
package/dist/index.d.ts CHANGED
@@ -520,6 +520,8 @@ type TabsProps = {
520
520
  style?: "default" | "borderRadiusTop" | "box";
521
521
  gap?: number;
522
522
  noBottomLine?: boolean;
523
+ /** @default true */
524
+ keepUrlHistory?: boolean;
523
525
  onChange?: (tab: Tab["id"]) => void;
524
526
  children?: React.ReactNode;
525
527
  } & ComponentMarginProps;
package/dist/index.js CHANGED
@@ -7514,17 +7514,28 @@ var import_jsx_runtime26 = require("react/jsx-runtime");
7514
7514
  var tabBottomLineWidth = 2;
7515
7515
  var tabDotSize = 6;
7516
7516
  var defaultTabName = "tab";
7517
- var TabsComponent = (0, import_react29.forwardRef)(function Tabs({ tabs, name, accentColor, style = "default", gap, noBottomLine, onChange, children, ...props }, ref) {
7517
+ var TabsComponent = (0, import_react29.forwardRef)(function Tabs({
7518
+ tabs,
7519
+ name,
7520
+ accentColor,
7521
+ style = "default",
7522
+ gap,
7523
+ noBottomLine,
7524
+ keepUrlHistory = true,
7525
+ onChange,
7526
+ children,
7527
+ ...props
7528
+ }, ref) {
7518
7529
  const reactRouterDomPlugin2 = usePlugin("react-router-dom");
7519
7530
  const theme2 = (0, import_react_better_core27.useTheme)();
7520
7531
  const urlQuery = reactRouterDomPlugin2 ? useUrlQuery() : void 0;
7521
7532
  const { componentsState } = useBetterHtmlContextInternal();
7522
- const { colorTheme } = (0, import_react_better_core27.useBetterCoreContext)();
7523
7533
  const firstRenderPassedRef = (0, import_react29.useRef)(false);
7524
7534
  const tabsRef = (0, import_react29.useRef)({});
7525
7535
  const tabsGap = gap ?? (style === "box" ? theme2.styles.gap / 2 : 0);
7526
7536
  const [selectedTabId, setSelectedTabId] = (0, import_react29.useState)(() => {
7527
7537
  const selectedTabId2 = tabs[0];
7538
+ if (!selectedTabId2) return "";
7528
7539
  if (urlQuery) {
7529
7540
  const tabQueryValue = urlQuery.getQuery(name ?? defaultTabName);
7530
7541
  if (!tabQueryValue) return selectedTabId2.id;
@@ -7539,12 +7550,15 @@ var TabsComponent = (0, import_react29.forwardRef)(function Tabs({ tabs, name, a
7539
7550
  setSelectedTabId(tabId);
7540
7551
  onChange?.(tabId);
7541
7552
  if (urlQuery) {
7542
- urlQuery.setQuery({
7543
- [name ?? defaultTabName]: tabId
7544
- });
7553
+ urlQuery.setQuery(
7554
+ {
7555
+ [name ?? defaultTabName]: tabId
7556
+ },
7557
+ keepUrlHistory
7558
+ );
7545
7559
  }
7546
7560
  },
7547
- [onChange, name, urlQuery]
7561
+ [onChange, name, urlQuery, keepUrlHistory]
7548
7562
  );
7549
7563
  const width = (0, import_react29.useMemo)(
7550
7564
  () => tabsRef.current[selectedTabId]?.getBoundingClientRect().width ?? 0,