react-better-html 1.1.82 → 1.1.84

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
@@ -638,10 +638,15 @@ type TabsProps = {
638
638
  name?: string;
639
639
  accentColor?: Color;
640
640
  style?: "default" | "borderRadiusTop" | "box";
641
+ onChange?: (tab: string) => void;
641
642
  children?: React.ReactNode;
642
643
  } & ComponentMarginProps;
644
+ type TabsRef = {
645
+ selectedTab: string;
646
+ selectTab: (tab: string) => void;
647
+ };
643
648
  type TabsComponent = {
644
- (props: TabsProps): React.ReactElement;
649
+ (props: ComponentPropWithRef<TabsRef, TabsProps>): React.ReactElement;
645
650
  content: (props: TabsContentProps) => React.ReactElement;
646
651
  };
647
652
  declare const TabsComponent: TabsComponent;
@@ -746,4 +751,4 @@ declare const isMobileDevice: boolean;
746
751
 
747
752
  declare const reactRouterDomPlugin: BetterHtmlPlugin;
748
753
 
749
- export { type AppConfig, type AssetName, type AssetsConfig, type BetterHtmlConfig, type BetterHtmlPlugin, _default as BetterHtmlProvider, type BetterHtmlProviderValue, type BrowserName, Button, type ButtonProps, Chip, type ChipProps, type Color, type ColorName, type ColorTheme, ColorThemeSwitch, type ColorThemeSwitchProps, type Colors, type DeepPartialRecord, Div, type DivProps, _default$6 as Divider, Dropdown, type DropdownOption, type DropdownProps, type ExcludeOptions, Foldable, type FoldableProps, type FoldableRef, _default$2 as Form, type FormProps, FormRow, type FormRowProps, type HorizontalDividerProps, _default$8 as Icon, type IconName, type IconProps, type IconsConfig, _default$7 as Image, type ImageProps, InputField, type InputFieldProps, _default$1 as Label, type LabelProps, Loader, type LoaderConfig, type LoaderName, type LoaderProps, Modal, type ModalProps, type ModalRef, type OmitProps, _default$4 as PageHeader, type PageHeaderProps, _default$5 as PageHolder, type PageHolderProps, type PartialRecord, type PickAllRequired, type PickValue, type PluginName, type Styles, type TabGroup, Table, type TableColumn, type TableProps, Tabs, type TabsProps, Text, type TextAs, type TextProps, type TextareaFieldProps, type Theme, type ThemeConfig, _default$3 as ToggleInput, type ToggleInputProps, type ToggleInputRef, type VerticalDividerProps, formatPhoneNumber, generateRandomString, getBrowser, getFormErrorObject, isMobileDevice, loaderControls, reactRouterDomPlugin, useBetterHtmlContext, useBooleanState, useDebounceState, useForm, useLoader, useLoaderControls, useMediaQuery, usePageResize, usePageScroll, useTheme, useUrlQuery };
754
+ export { type AppConfig, type AssetName, type AssetsConfig, type BetterHtmlConfig, type BetterHtmlPlugin, _default as BetterHtmlProvider, type BetterHtmlProviderValue, type BrowserName, Button, type ButtonProps, Chip, type ChipProps, type Color, type ColorName, type ColorTheme, ColorThemeSwitch, type ColorThemeSwitchProps, type Colors, type DeepPartialRecord, Div, type DivProps, _default$6 as Divider, Dropdown, type DropdownOption, type DropdownProps, type ExcludeOptions, Foldable, type FoldableProps, type FoldableRef, _default$2 as Form, type FormProps, FormRow, type FormRowProps, type HorizontalDividerProps, _default$8 as Icon, type IconName, type IconProps, type IconsConfig, _default$7 as Image, type ImageProps, InputField, type InputFieldProps, _default$1 as Label, type LabelProps, Loader, type LoaderConfig, type LoaderName, type LoaderProps, Modal, type ModalProps, type ModalRef, type OmitProps, _default$4 as PageHeader, type PageHeaderProps, _default$5 as PageHolder, type PageHolderProps, type PartialRecord, type PickAllRequired, type PickValue, type PluginName, type Styles, type TabGroup, Table, type TableColumn, type TableProps, Tabs, type TabsProps, type TabsRef, Text, type TextAs, type TextProps, type TextareaFieldProps, type Theme, type ThemeConfig, _default$3 as ToggleInput, type ToggleInputProps, type ToggleInputRef, type VerticalDividerProps, formatPhoneNumber, generateRandomString, getBrowser, getFormErrorObject, isMobileDevice, loaderControls, reactRouterDomPlugin, useBetterHtmlContext, useBooleanState, useDebounceState, useForm, useLoader, useLoaderControls, useMediaQuery, usePageResize, usePageScroll, useTheme, useUrlQuery };
package/dist/index.d.ts CHANGED
@@ -638,10 +638,15 @@ type TabsProps = {
638
638
  name?: string;
639
639
  accentColor?: Color;
640
640
  style?: "default" | "borderRadiusTop" | "box";
641
+ onChange?: (tab: string) => void;
641
642
  children?: React.ReactNode;
642
643
  } & ComponentMarginProps;
644
+ type TabsRef = {
645
+ selectedTab: string;
646
+ selectTab: (tab: string) => void;
647
+ };
643
648
  type TabsComponent = {
644
- (props: TabsProps): React.ReactElement;
649
+ (props: ComponentPropWithRef<TabsRef, TabsProps>): React.ReactElement;
645
650
  content: (props: TabsContentProps) => React.ReactElement;
646
651
  };
647
652
  declare const TabsComponent: TabsComponent;
@@ -746,4 +751,4 @@ declare const isMobileDevice: boolean;
746
751
 
747
752
  declare const reactRouterDomPlugin: BetterHtmlPlugin;
748
753
 
749
- export { type AppConfig, type AssetName, type AssetsConfig, type BetterHtmlConfig, type BetterHtmlPlugin, _default as BetterHtmlProvider, type BetterHtmlProviderValue, type BrowserName, Button, type ButtonProps, Chip, type ChipProps, type Color, type ColorName, type ColorTheme, ColorThemeSwitch, type ColorThemeSwitchProps, type Colors, type DeepPartialRecord, Div, type DivProps, _default$6 as Divider, Dropdown, type DropdownOption, type DropdownProps, type ExcludeOptions, Foldable, type FoldableProps, type FoldableRef, _default$2 as Form, type FormProps, FormRow, type FormRowProps, type HorizontalDividerProps, _default$8 as Icon, type IconName, type IconProps, type IconsConfig, _default$7 as Image, type ImageProps, InputField, type InputFieldProps, _default$1 as Label, type LabelProps, Loader, type LoaderConfig, type LoaderName, type LoaderProps, Modal, type ModalProps, type ModalRef, type OmitProps, _default$4 as PageHeader, type PageHeaderProps, _default$5 as PageHolder, type PageHolderProps, type PartialRecord, type PickAllRequired, type PickValue, type PluginName, type Styles, type TabGroup, Table, type TableColumn, type TableProps, Tabs, type TabsProps, Text, type TextAs, type TextProps, type TextareaFieldProps, type Theme, type ThemeConfig, _default$3 as ToggleInput, type ToggleInputProps, type ToggleInputRef, type VerticalDividerProps, formatPhoneNumber, generateRandomString, getBrowser, getFormErrorObject, isMobileDevice, loaderControls, reactRouterDomPlugin, useBetterHtmlContext, useBooleanState, useDebounceState, useForm, useLoader, useLoaderControls, useMediaQuery, usePageResize, usePageScroll, useTheme, useUrlQuery };
754
+ export { type AppConfig, type AssetName, type AssetsConfig, type BetterHtmlConfig, type BetterHtmlPlugin, _default as BetterHtmlProvider, type BetterHtmlProviderValue, type BrowserName, Button, type ButtonProps, Chip, type ChipProps, type Color, type ColorName, type ColorTheme, ColorThemeSwitch, type ColorThemeSwitchProps, type Colors, type DeepPartialRecord, Div, type DivProps, _default$6 as Divider, Dropdown, type DropdownOption, type DropdownProps, type ExcludeOptions, Foldable, type FoldableProps, type FoldableRef, _default$2 as Form, type FormProps, FormRow, type FormRowProps, type HorizontalDividerProps, _default$8 as Icon, type IconName, type IconProps, type IconsConfig, _default$7 as Image, type ImageProps, InputField, type InputFieldProps, _default$1 as Label, type LabelProps, Loader, type LoaderConfig, type LoaderName, type LoaderProps, Modal, type ModalProps, type ModalRef, type OmitProps, _default$4 as PageHeader, type PageHeaderProps, _default$5 as PageHolder, type PageHolderProps, type PartialRecord, type PickAllRequired, type PickValue, type PluginName, type Styles, type TabGroup, Table, type TableColumn, type TableProps, Tabs, type TabsProps, type TabsRef, Text, type TextAs, type TextProps, type TextareaFieldProps, type Theme, type ThemeConfig, _default$3 as ToggleInput, type ToggleInputProps, type ToggleInputRef, type VerticalDividerProps, formatPhoneNumber, generateRandomString, getBrowser, getFormErrorObject, isMobileDevice, loaderControls, reactRouterDomPlugin, useBetterHtmlContext, useBooleanState, useDebounceState, useForm, useLoader, useLoaderControls, useMediaQuery, usePageResize, usePageScroll, useTheme, useUrlQuery };
package/dist/index.js CHANGED
@@ -6600,14 +6600,7 @@ var import_jsx_runtime22 = require("react/jsx-runtime");
6600
6600
  var tabBottomLineWidth = 2;
6601
6601
  var tabDotSize = 6;
6602
6602
  var defaultTabName = "tab";
6603
- var TabsComponent = function Tabs({
6604
- tabs,
6605
- name,
6606
- accentColor,
6607
- style = "default",
6608
- children,
6609
- ...props
6610
- }) {
6603
+ var TabsComponent = (0, import_react24.forwardRef)(function Tabs({ tabs, name, accentColor, style = "default", onChange, children, ...props }, ref) {
6611
6604
  const reactRouterDomPlugin2 = usePlugin("react-router-dom");
6612
6605
  const theme2 = useTheme();
6613
6606
  const urlQuery = reactRouterDomPlugin2 ? useUrlQuery() : void 0;
@@ -6628,13 +6621,14 @@ var TabsComponent = function Tabs({
6628
6621
  const onClickTab = (0, import_react24.useCallback)(
6629
6622
  (tab) => {
6630
6623
  setSelectedTab(tab);
6624
+ onChange?.(tab);
6631
6625
  if (urlQuery) {
6632
6626
  urlQuery.setQuery({
6633
6627
  [name ?? defaultTabName]: tab
6634
6628
  });
6635
6629
  }
6636
6630
  },
6637
- [name, urlQuery]
6631
+ [onChange, name, urlQuery]
6638
6632
  );
6639
6633
  const width = (0, import_react24.useMemo)(
6640
6634
  () => tabsRef.current[selectedTab]?.getBoundingClientRect().width ?? 0,
@@ -6684,6 +6678,23 @@ var TabsComponent = function Tabs({
6684
6678
  block: "nearest"
6685
6679
  });
6686
6680
  }, [selectedTab]);
6681
+ (0, import_react24.useEffect)(() => {
6682
+ return () => {
6683
+ componentsState.tabs.setTabGroups(
6684
+ (oldValue) => oldValue.filter((item) => item.name !== (name ?? defaultTabName))
6685
+ );
6686
+ };
6687
+ }, []);
6688
+ (0, import_react24.useImperativeHandle)(
6689
+ ref,
6690
+ () => {
6691
+ return {
6692
+ selectedTab,
6693
+ selectTab: onClickTab
6694
+ };
6695
+ },
6696
+ [selectedTab, onClickTab]
6697
+ );
6687
6698
  return /* @__PURE__ */ (0, import_jsx_runtime22.jsxs)(Div_default.column, { width: "100%", gap: theme2.styles.space, ...props, children: [
6688
6699
  /* @__PURE__ */ (0, import_jsx_runtime22.jsxs)(Div_default, { position: "relative", className: "react-better-html-no-scrollbar", overflowY: "auto", children: [
6689
6700
  /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(Div_default.row, { position: "relative", width: "fit-content", gap: tabsGap, userSelect: "none", children: tabs.map((tab) => {
@@ -6705,8 +6716,8 @@ var TabsComponent = function Tabs({
6705
6716
  cursor: "pointer",
6706
6717
  isTabAccessed: true,
6707
6718
  onClickWithValue: onClickTab,
6708
- ref: (ref) => {
6709
- tabsRef.current[tab] = ref;
6719
+ ref: (ref2) => {
6720
+ tabsRef.current[tab] = ref2;
6710
6721
  },
6711
6722
  children: [
6712
6723
  componentsState.tabs.tabsWithDots.includes(tab) && /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(
@@ -6750,9 +6761,9 @@ var TabsComponent = function Tabs({
6750
6761
  }
6751
6762
  )
6752
6763
  ] }),
6753
- /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(Div_default, { width: "100%", children })
6764
+ children && /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(Div_default, { width: "100%", children })
6754
6765
  ] });
6755
- };
6766
+ });
6756
6767
  TabsComponent.content = function Content({ tab, tabWithDot, tabsGroupName, isInitialTab, children }) {
6757
6768
  const { componentsState } = useBetterHtmlContextInternal();
6758
6769
  const thisTabGroupData = (0, import_react24.useMemo)(