react-better-html 1.1.260 → 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 CHANGED
@@ -519,12 +519,12 @@ type TabsProps = {
519
519
  style?: "default" | "borderRadiusTop" | "box";
520
520
  gap?: number;
521
521
  noBottomLine?: boolean;
522
- onChange?: (tab: Tab) => void;
522
+ onChange?: (tab: Tab["id"]) => void;
523
523
  children?: React.ReactNode;
524
524
  } & ComponentMarginProps;
525
525
  type TabsRef = {
526
526
  selectedTab: Tab["id"];
527
- selectTab: (tab: Tab) => void;
527
+ selectTab: (tabId: Tab["id"]) => void;
528
528
  };
529
529
  type TabsComponent = {
530
530
  (props: ComponentPropWithRef<TabsRef, TabsProps>): React.ReactElement;
@@ -802,6 +802,7 @@ type FormProps = {
802
802
  renderActionButtons?: React.ReactNode;
803
803
  onClickCancel?: () => void;
804
804
  onSubmit?: (event: React.FormEvent<HTMLFormElement>) => void;
805
+ id?: React.ComponentProps<"form">["id"];
805
806
  children?: React.ReactNode;
806
807
  } & ComponentMarginProps;
807
808
  type FormComponentType = {
package/dist/index.d.ts CHANGED
@@ -519,12 +519,12 @@ type TabsProps = {
519
519
  style?: "default" | "borderRadiusTop" | "box";
520
520
  gap?: number;
521
521
  noBottomLine?: boolean;
522
- onChange?: (tab: Tab) => void;
522
+ onChange?: (tab: Tab["id"]) => void;
523
523
  children?: React.ReactNode;
524
524
  } & ComponentMarginProps;
525
525
  type TabsRef = {
526
526
  selectedTab: Tab["id"];
527
- selectTab: (tab: Tab) => void;
527
+ selectTab: (tabId: Tab["id"]) => void;
528
528
  };
529
529
  type TabsComponent = {
530
530
  (props: ComponentPropWithRef<TabsRef, TabsProps>): React.ReactElement;
@@ -802,6 +802,7 @@ type FormProps = {
802
802
  renderActionButtons?: React.ReactNode;
803
803
  onClickCancel?: () => void;
804
804
  onSubmit?: (event: React.FormEvent<HTMLFormElement>) => void;
805
+ id?: React.ComponentProps<"form">["id"];
805
806
  children?: React.ReactNode;
806
807
  } & ComponentMarginProps;
807
808
  type FormComponentType = {
package/dist/index.js CHANGED
@@ -5989,6 +5989,7 @@ var FormComponent = (0, import_react23.forwardRef)(function Form({
5989
5989
  renderActionButtons,
5990
5990
  onClickCancel,
5991
5991
  onSubmit,
5992
+ id,
5992
5993
  children,
5993
5994
  ...props
5994
5995
  }, ref) {
@@ -6001,7 +6002,7 @@ var FormComponent = (0, import_react23.forwardRef)(function Form({
6001
6002
  }, [form]);
6002
6003
  const SubmitButtonTag = isDestructive ? Button_default.destructive : Button_default;
6003
6004
  const submitButtonIsDisabledFinal = submitButtonIsDisabled || submitButtonIsDisabledInternal;
6004
- return /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(Div_default, { width: "100%", ...props, children: /* @__PURE__ */ (0, import_jsx_runtime20.jsxs)("form", { name, onSubmit: onSubmit ?? form?.onSubmit, ref, children: [
6005
+ return /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(Div_default, { width: "100%", ...props, children: /* @__PURE__ */ (0, import_jsx_runtime20.jsxs)("form", { name, onSubmit: onSubmit ?? form?.onSubmit, id, ref, children: [
6005
6006
  gap !== void 0 || withDividers ? /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(Div_default.column, { gap: gap ?? (withDividers ? theme2.styles.space : theme2.styles.gap), children: withDividers ? import_react23.Children.toArray(children).map((child, index) => /* @__PURE__ */ (0, import_jsx_runtime20.jsxs)(import_react23.Fragment, { children: [
6006
6007
  child,
6007
6008
  index < import_react23.Children.toArray(children).length - 1 && /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(
@@ -7502,41 +7503,41 @@ var TabsComponent = (0, import_react29.forwardRef)(function Tabs({ tabs, name, a
7502
7503
  const firstRenderPassedRef = (0, import_react29.useRef)(false);
7503
7504
  const tabsRef = (0, import_react29.useRef)({});
7504
7505
  const tabsGap = gap ?? (style === "box" ? theme2.styles.gap / 2 : 0);
7505
- const [selectedTab, setSelectedTab] = (0, import_react29.useState)(() => {
7506
- const selectedTabId = tabs[0];
7506
+ const [selectedTabId, setSelectedTabId] = (0, import_react29.useState)(() => {
7507
+ const selectedTabId2 = tabs[0];
7507
7508
  if (urlQuery) {
7508
7509
  const tabQueryValue = urlQuery.getQuery(name ?? defaultTabName);
7509
- if (!tabQueryValue) return selectedTabId;
7510
+ if (!tabQueryValue) return selectedTabId2.id;
7510
7511
  const queryTab = tabs.find((tab) => tab.id === tabQueryValue);
7511
- if (queryTab) return queryTab;
7512
+ if (queryTab) return queryTab.id;
7512
7513
  }
7513
- return selectedTabId;
7514
+ return selectedTabId2.id;
7514
7515
  });
7515
7516
  const [rerenderState, setRerenderState] = (0, import_react29.useState)(0);
7516
7517
  const onClickTab = (0, import_react29.useCallback)(
7517
- (tab) => {
7518
- setSelectedTab(tab);
7519
- onChange?.(tab);
7518
+ (tabId) => {
7519
+ setSelectedTabId(tabId);
7520
+ onChange?.(tabId);
7520
7521
  if (urlQuery) {
7521
7522
  urlQuery.setQuery({
7522
- [name ?? defaultTabName]: tab.id
7523
+ [name ?? defaultTabName]: tabId
7523
7524
  });
7524
7525
  }
7525
7526
  },
7526
7527
  [onChange, name, urlQuery]
7527
7528
  );
7528
7529
  const width = (0, import_react29.useMemo)(
7529
- () => tabsRef.current[selectedTab.id]?.getBoundingClientRect().width ?? 0,
7530
- [rerenderState, selectedTab]
7530
+ () => tabsRef.current[selectedTabId]?.getBoundingClientRect().width ?? 0,
7531
+ [rerenderState, selectedTabId]
7531
7532
  );
7532
7533
  const leftSpacing = (0, import_react29.useMemo)(() => {
7533
- const selectedTabIndex = tabs.findIndex((tab) => tab.id === selectedTab.id);
7534
+ const selectedTabIndex = tabs.findIndex((tab) => tab.id === selectedTabId);
7534
7535
  let spacing = 0;
7535
7536
  Object.values(tabsRef.current).forEach((tab, index) => {
7536
7537
  if (index < selectedTabIndex) spacing += (tab?.getBoundingClientRect().width ?? 0) + tabsGap;
7537
7538
  });
7538
7539
  return spacing;
7539
- }, [selectedTab, tabs, tabsGap]);
7540
+ }, [selectedTabId, tabs, tabsGap]);
7540
7541
  (0, import_react29.useEffect)(() => {
7541
7542
  const timeout = setTimeout(() => {
7542
7543
  setRerenderState(Math.random());
@@ -7553,7 +7554,7 @@ var TabsComponent = (0, import_react29.forwardRef)(function Tabs({ tabs, name, a
7553
7554
  return oldValue.map(
7554
7555
  (item) => item.name === (name ?? defaultTabName) ? {
7555
7556
  ...item,
7556
- selectedTab: selectedTab.id
7557
+ selectedTab: selectedTabId
7557
7558
  } : item
7558
7559
  );
7559
7560
  } else {
@@ -7561,18 +7562,18 @@ var TabsComponent = (0, import_react29.forwardRef)(function Tabs({ tabs, name, a
7561
7562
  ...oldValue,
7562
7563
  {
7563
7564
  name: name ?? defaultTabName,
7564
- selectedTab: selectedTab.id
7565
+ selectedTab: selectedTabId
7565
7566
  }
7566
7567
  ];
7567
7568
  }
7568
7569
  });
7569
- }, [selectedTab, name]);
7570
+ }, [selectedTabId, name]);
7570
7571
  (0, import_react29.useEffect)(() => {
7571
- tabsRef.current[selectedTab.id]?.scrollIntoView({
7572
+ tabsRef.current[selectedTabId]?.scrollIntoView({
7572
7573
  behavior: firstRenderPassedRef.current ? "smooth" : void 0,
7573
7574
  block: "nearest"
7574
7575
  });
7575
- }, [selectedTab]);
7576
+ }, [selectedTabId]);
7576
7577
  (0, import_react29.useEffect)(() => {
7577
7578
  return () => {
7578
7579
  componentsState.tabs.setTabGroups(
@@ -7581,18 +7582,18 @@ var TabsComponent = (0, import_react29.forwardRef)(function Tabs({ tabs, name, a
7581
7582
  };
7582
7583
  }, []);
7583
7584
  (0, import_react29.useEffect)(() => {
7584
- onChange?.(selectedTab);
7585
+ onChange?.(selectedTabId);
7585
7586
  }, []);
7586
7587
  (0, import_react29.useImperativeHandle)(ref, () => {
7587
7588
  return {
7588
- selectedTab: selectedTab.id,
7589
+ selectedTab: selectedTabId,
7589
7590
  selectTab: onClickTab
7590
7591
  };
7591
- }, [selectedTab, onClickTab]);
7592
+ }, [selectedTabId, onClickTab]);
7592
7593
  return /* @__PURE__ */ (0, import_jsx_runtime26.jsxs)(Div_default.column, { width: "100%", gap: theme2.styles.space, ...props, children: [
7593
7594
  /* @__PURE__ */ (0, import_jsx_runtime26.jsxs)(Div_default, { position: "relative", className: "react-better-html-no-scrollbar", overflowY: "auto", children: [
7594
7595
  /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(Div_default.row, { position: "relative", width: "fit-content", gap: tabsGap, userSelect: "none", children: tabs.map((tab) => {
7595
- const selected = tab.id === selectedTab.id;
7596
+ const selected = tab.id === selectedTabId;
7596
7597
  return /* @__PURE__ */ (0, import_jsx_runtime26.jsxs)(
7597
7598
  Div_default,
7598
7599
  {
@@ -7607,7 +7608,7 @@ var TabsComponent = (0, import_react29.forwardRef)(function Tabs({ tabs, name, a
7607
7608
  filterHover: colorTheme === "dark" ? style === "box" ? "brightness(1.2)" : "brightness(2)" : "brightness(0.9)",
7608
7609
  paddingInline: theme2.styles.space,
7609
7610
  paddingBlock: theme2.styles.gap,
7610
- value: tab,
7611
+ value: tab.id,
7611
7612
  cursor: "pointer",
7612
7613
  isTabAccessed: true,
7613
7614
  onClickWithValue: onClickTab,