react-better-html 1.1.81 → 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.mjs CHANGED
@@ -6520,19 +6520,12 @@ var Table2 = memo20(TableComponent);
6520
6520
  var Table_default = Table2;
6521
6521
 
6522
6522
  // src/components/Tabs.tsx
6523
- import { memo as memo21, useCallback as useCallback11, useEffect as useEffect9, useMemo as useMemo8, useRef as useRef5, useState as useState9 } from "react";
6523
+ import { forwardRef as forwardRef12, memo as memo21, useCallback as useCallback11, useEffect as useEffect9, useImperativeHandle as useImperativeHandle2, useMemo as useMemo8, useRef as useRef5, useState as useState9 } from "react";
6524
6524
  import { jsx as jsx21, jsxs as jsxs16 } from "react/jsx-runtime";
6525
6525
  var tabBottomLineWidth = 2;
6526
6526
  var tabDotSize = 6;
6527
6527
  var defaultTabName = "tab";
6528
- var TabsComponent = function Tabs({
6529
- tabs,
6530
- name,
6531
- accentColor,
6532
- style = "default",
6533
- children,
6534
- ...props
6535
- }) {
6528
+ var TabsComponent = forwardRef12(function Tabs({ tabs, name, accentColor, style = "default", onChange, children, ...props }, ref) {
6536
6529
  const reactRouterDomPlugin2 = usePlugin("react-router-dom");
6537
6530
  const theme2 = useTheme();
6538
6531
  const urlQuery = reactRouterDomPlugin2 ? useUrlQuery() : void 0;
@@ -6553,13 +6546,14 @@ var TabsComponent = function Tabs({
6553
6546
  const onClickTab = useCallback11(
6554
6547
  (tab) => {
6555
6548
  setSelectedTab(tab);
6549
+ onChange?.(tab);
6556
6550
  if (urlQuery) {
6557
6551
  urlQuery.setQuery({
6558
6552
  [name ?? defaultTabName]: tab
6559
6553
  });
6560
6554
  }
6561
6555
  },
6562
- [name, urlQuery]
6556
+ [onChange, name, urlQuery]
6563
6557
  );
6564
6558
  const width = useMemo8(
6565
6559
  () => tabsRef.current[selectedTab]?.getBoundingClientRect().width ?? 0,
@@ -6609,6 +6603,16 @@ var TabsComponent = function Tabs({
6609
6603
  block: "nearest"
6610
6604
  });
6611
6605
  }, [selectedTab]);
6606
+ useImperativeHandle2(
6607
+ ref,
6608
+ () => {
6609
+ return {
6610
+ selectedTab,
6611
+ setSelectedTab: onClickTab
6612
+ };
6613
+ },
6614
+ [selectedTab, onClickTab]
6615
+ );
6612
6616
  return /* @__PURE__ */ jsxs16(Div_default.column, { width: "100%", gap: theme2.styles.space, ...props, children: [
6613
6617
  /* @__PURE__ */ jsxs16(Div_default, { position: "relative", className: "react-better-html-no-scrollbar", overflowY: "auto", children: [
6614
6618
  /* @__PURE__ */ jsx21(Div_default.row, { position: "relative", width: "fit-content", gap: tabsGap, userSelect: "none", children: tabs.map((tab) => {
@@ -6630,8 +6634,8 @@ var TabsComponent = function Tabs({
6630
6634
  cursor: "pointer",
6631
6635
  isTabAccessed: true,
6632
6636
  onClickWithValue: onClickTab,
6633
- ref: (ref) => {
6634
- tabsRef.current[tab] = ref;
6637
+ ref: (ref2) => {
6638
+ tabsRef.current[tab] = ref2;
6635
6639
  },
6636
6640
  children: [
6637
6641
  componentsState.tabs.tabsWithDots.includes(tab) && /* @__PURE__ */ jsx21(
@@ -6677,8 +6681,8 @@ var TabsComponent = function Tabs({
6677
6681
  ] }),
6678
6682
  /* @__PURE__ */ jsx21(Div_default, { width: "100%", children })
6679
6683
  ] });
6680
- };
6681
- TabsComponent.content = function Content({ tab, tabWithDot, tabsGroupName, children }) {
6684
+ });
6685
+ TabsComponent.content = function Content({ tab, tabWithDot, tabsGroupName, isInitialTab, children }) {
6682
6686
  const { componentsState } = useBetterHtmlContextInternal();
6683
6687
  const thisTabGroupData = useMemo8(
6684
6688
  () => componentsState.tabs.tabGroups.find((item) => item.name === (tabsGroupName ?? defaultTabName)),
@@ -6693,24 +6697,25 @@ TabsComponent.content = function Content({ tab, tabWithDot, tabsGroupName, child
6693
6697
  );
6694
6698
  }
6695
6699
  }, [tabWithDot]);
6696
- return thisTabGroupData?.selectedTab === tab ? /* @__PURE__ */ jsx21(Div_default, { width: "100%", children }) : void 0;
6700
+ return (thisTabGroupData ? thisTabGroupData.selectedTab === tab : isInitialTab) ? /* @__PURE__ */ jsx21(Div_default, { width: "100%", children }) : void 0;
6697
6701
  };
6698
6702
  var Tabs2 = memo21(TabsComponent);
6699
6703
  Tabs2.content = TabsComponent.content;
6700
6704
  var Tabs_default = Tabs2;
6701
6705
 
6702
6706
  // src/components/Foldable.tsx
6703
- import { forwardRef as forwardRef12, memo as memo22, useCallback as useCallback12, useEffect as useEffect10, useImperativeHandle as useImperativeHandle2, useRef as useRef6, useState as useState10 } from "react";
6707
+ import { forwardRef as forwardRef13, memo as memo22, useCallback as useCallback12, useEffect as useEffect10, useImperativeHandle as useImperativeHandle3, useRef as useRef6, useState as useState10 } from "react";
6704
6708
  import { jsx as jsx22, jsxs as jsxs17 } from "react/jsx-runtime";
6705
6709
  var animationDurationClose = 0.15;
6706
6710
  var animationDurationOpen = animationDurationClose * 2;
6707
- var FoldableComponent = forwardRef12(function Foldable({
6711
+ var FoldableComponent = forwardRef13(function Foldable({
6708
6712
  isOpen: controlledIsOpen,
6709
6713
  defaultOpen = false,
6710
6714
  title,
6711
6715
  description,
6712
6716
  icon,
6713
6717
  image,
6718
+ headerPaddingBlock,
6714
6719
  headerPaddingInline,
6715
6720
  renderHeader,
6716
6721
  onOpenChange,
@@ -6738,7 +6743,7 @@ var FoldableComponent = forwardRef12(function Foldable({
6738
6743
  if (!bodyRef.current) return;
6739
6744
  setBodyVirtualHeight(Math.min(500, bodyRef.current.scrollHeight * 2));
6740
6745
  }, [isOpen]);
6741
- useImperativeHandle2(
6746
+ useImperativeHandle3(
6742
6747
  ref,
6743
6748
  () => {
6744
6749
  return {
@@ -6757,7 +6762,7 @@ var FoldableComponent = forwardRef12(function Foldable({
6757
6762
  width: "100%",
6758
6763
  alignItems: "center",
6759
6764
  gap: theme2.styles.gap,
6760
- paddingBlock: theme2.styles.gap,
6765
+ paddingBlock: headerPaddingBlock ?? theme2.styles.gap,
6761
6766
  paddingInline: headerPaddingInline,
6762
6767
  cursor: "pointer",
6763
6768
  onClick: toggleOpen,
@@ -6767,7 +6772,7 @@ var FoldableComponent = forwardRef12(function Foldable({
6767
6772
  icon && /* @__PURE__ */ jsx22(Icon_default, { name: icon, size: 20, flexShrink: 0 }),
6768
6773
  image && /* @__PURE__ */ jsx22(Image_default.profileImage, { name: image, size: 24, flexShrink: 0 }),
6769
6774
  /* @__PURE__ */ jsxs17(Div_default.column, { gap: theme2.styles.gap / 2, children: [
6770
- title && /* @__PURE__ */ jsx22(Text_default, { as: "h3", fontWeight: 700, children: title }),
6775
+ title && /* @__PURE__ */ jsx22(Text_default, { as: "h3", fontWeight: 700, lineHeight: "20px", children: title }),
6771
6776
  description && /* @__PURE__ */ jsx22(Text_default, { color: theme2.colors.textSecondary, children: description })
6772
6777
  ] })
6773
6778
  ] }),
@@ -6797,7 +6802,7 @@ var FoldableComponent = forwardRef12(function Foldable({
6797
6802
  )
6798
6803
  ] });
6799
6804
  });
6800
- FoldableComponent.box = forwardRef12(function Box3({ ...props }, ref) {
6805
+ FoldableComponent.box = forwardRef13(function Box3({ ...props }, ref) {
6801
6806
  const theme2 = useTheme();
6802
6807
  return /* @__PURE__ */ jsx22(
6803
6808
  FoldableComponent,
@@ -6805,6 +6810,7 @@ FoldableComponent.box = forwardRef12(function Box3({ ...props }, ref) {
6805
6810
  backgroundColor: theme2.colors.backgroundContent,
6806
6811
  border: `1px solid ${theme2.colors.border}`,
6807
6812
  borderRadius: theme2.styles.borderRadius,
6813
+ headerPaddingBlock: (theme2.styles.gap + theme2.styles.space) / 2,
6808
6814
  headerPaddingInline: theme2.styles.space,
6809
6815
  ...props,
6810
6816
  ref