react-better-html 1.1.261 → 1.1.263

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
@@ -1,8 +1,7 @@
1
- import { IconName, AnyOtherString, AssetName, LoaderName, OmitProps, Country, Color, BetterCoreProviderConfig, DeepPartialRecord, BetterCoreConfig, PartialRecord, PickValue } from 'react-better-core';
2
- export { API, APIConfigItem, APIError, APIResponse, AnyOtherString, AssetName, AssetsConfig, Color, ColorName, ColorTheme, Colors, Country, DeepPartialRecord, ExcludeOptions, HttpHeaders as HttpHeader, HttpMethod, IconName, IconsConfig, LoaderConfig, LoaderName, OmitProps, PartialRecord, PickAllRequired, PickValue, Styles, Theme, ThemeConfig, Unsubscribe, UrlQuery, calculateColorContrast, colorThemeControls, countries, darkenColor, desaturateColor, eventPreventDefault, eventPreventStop, eventStopPropagation, formatPhoneNumber, generateApi, generateEventEmitter, generateRandomString, getPluralWord, isApiError, lightenColor, loaderControls, log, saturateColor, useBooleanState, useDebounceState, useLoader, useLoaderControls, useTheme } from 'react-better-core';
1
+ import { OmitProps, IconName, AnyOtherString, AssetName, LoaderName, Country, Color, BetterCoreProviderConfig, DeepPartialRecord, BetterCoreConfig, PartialRecord, PickValue } from 'react-better-core';
2
+ export { API, APIConfigItem, APIEndpointConfig, APIError, APIResponse, AnyOtherString, AssetName, AssetsConfig, Color, ColorName, ColorTheme, Colors, Country, DeepPartialRecord, ExcludeOptions, HttpHeaders as HttpHeader, HttpMethod, IconName, IconsConfig, LoaderConfig, LoaderName, OmitProps, PartialRecord, PickAllRequired, PickValue, Styles, Theme, ThemeConfig, Unsubscribe, UrlQuery, calculateColorContrast, colorThemeControls, countries, darkenColor, desaturateColor, eventPreventDefault, eventPreventStop, eventStopPropagation, formatPhoneNumber, generateApi, generateEventEmitter, generateRandomString, getPluralWord, isApiError, lightenColor, loaderControls, log, saturateColor, useBooleanState, useDebounceState, useLoader, useLoaderControls, useTheme } from 'react-better-core';
3
3
  import * as react from 'react';
4
4
  import { ComponentProps, ReactNode } from 'react';
5
- import * as react_jsx_runtime from 'react/jsx-runtime';
6
5
  import { WebTarget } from 'styled-components';
7
6
  import { Location, useNavigate, useLocation, useInRouterContext, useSearchParams, createSearchParams } from 'react-router-dom';
8
7
 
@@ -24,7 +23,7 @@ type ComponentPropWithRef<ComponentRef, ComponentProps> = ComponentProps & {
24
23
  ref?: React.Ref<ComponentRef>;
25
24
  };
26
25
 
27
- type ButtonProps<Value = unknown> = {
26
+ type InternalButtonProps<Value = unknown> = {
28
27
  text?: string;
29
28
  value?: Value;
30
29
  href?: string;
@@ -55,8 +54,10 @@ type ButtonProps<Value = unknown> = {
55
54
  isSmall?: boolean;
56
55
  /** @default false */
57
56
  isSubmit?: boolean;
57
+ fromSubcomponent?: boolean;
58
58
  onClickWithValue?: (value: Value) => void;
59
59
  } & OmitProps<React.ComponentProps<"button">, "style" | "defaultValue" | "translate" | "value"> & ComponentStyle & ComponentHoverStyle;
60
+ type ButtonProps<Value = unknown> = OmitProps<InternalButtonProps<Value>, "fromSubcomponent">;
60
61
  type ButtonComponent = {
61
62
  <Value>(props: ButtonProps<Value>): React.ReactElement;
62
63
  secondary: <Value>(props: ButtonProps<Value>) => React.ReactElement;
@@ -422,7 +423,7 @@ type LabelProps = {
422
423
  color?: React.CSSProperties["color"];
423
424
  htmlFor?: string;
424
425
  };
425
- declare function Label(labelProps: LabelProps): react_jsx_runtime.JSX.Element;
426
+ declare function Label(labelProps: LabelProps): react.JSX.Element;
426
427
  declare const _default$3: react.MemoExoticComponent<typeof Label>;
427
428
 
428
429
  type ImageProps = {
@@ -519,12 +520,12 @@ type TabsProps = {
519
520
  style?: "default" | "borderRadiusTop" | "box";
520
521
  gap?: number;
521
522
  noBottomLine?: boolean;
522
- onChange?: (tab: Tab) => void;
523
+ onChange?: (tab: Tab["id"]) => void;
523
524
  children?: React.ReactNode;
524
525
  } & ComponentMarginProps;
525
526
  type TabsRef = {
526
527
  selectedTab: Tab["id"];
527
- selectTab: (tab: Tab) => void;
528
+ selectTab: (tabId: Tab["id"]) => void;
528
529
  };
529
530
  type TabsComponent = {
530
531
  (props: ComponentPropWithRef<TabsRef, TabsProps>): React.ReactElement;
@@ -556,7 +557,7 @@ type BetterHtmlProviderConfig = BetterCoreProviderConfig & BetterHtmlProviderInt
556
557
  type BetterHtmlProviderProps = BetterProviderCommonProps & {
557
558
  config?: BetterHtmlProviderConfig;
558
559
  };
559
- declare function BetterHtmlProvider({ config, ...props }: BetterHtmlProviderProps): react_jsx_runtime.JSX.Element;
560
+ declare function BetterHtmlProvider({ config, ...props }: BetterHtmlProviderProps): react.JSX.Element;
560
561
  declare const _default$1: react.MemoExoticComponent<typeof BetterHtmlProvider>;
561
562
 
562
563
  declare const isMobileDevice: boolean;
package/dist/index.d.ts CHANGED
@@ -1,8 +1,7 @@
1
- import { IconName, AnyOtherString, AssetName, LoaderName, OmitProps, Country, Color, BetterCoreProviderConfig, DeepPartialRecord, BetterCoreConfig, PartialRecord, PickValue } from 'react-better-core';
2
- export { API, APIConfigItem, APIError, APIResponse, AnyOtherString, AssetName, AssetsConfig, Color, ColorName, ColorTheme, Colors, Country, DeepPartialRecord, ExcludeOptions, HttpHeaders as HttpHeader, HttpMethod, IconName, IconsConfig, LoaderConfig, LoaderName, OmitProps, PartialRecord, PickAllRequired, PickValue, Styles, Theme, ThemeConfig, Unsubscribe, UrlQuery, calculateColorContrast, colorThemeControls, countries, darkenColor, desaturateColor, eventPreventDefault, eventPreventStop, eventStopPropagation, formatPhoneNumber, generateApi, generateEventEmitter, generateRandomString, getPluralWord, isApiError, lightenColor, loaderControls, log, saturateColor, useBooleanState, useDebounceState, useLoader, useLoaderControls, useTheme } from 'react-better-core';
1
+ import { OmitProps, IconName, AnyOtherString, AssetName, LoaderName, Country, Color, BetterCoreProviderConfig, DeepPartialRecord, BetterCoreConfig, PartialRecord, PickValue } from 'react-better-core';
2
+ export { API, APIConfigItem, APIEndpointConfig, APIError, APIResponse, AnyOtherString, AssetName, AssetsConfig, Color, ColorName, ColorTheme, Colors, Country, DeepPartialRecord, ExcludeOptions, HttpHeaders as HttpHeader, HttpMethod, IconName, IconsConfig, LoaderConfig, LoaderName, OmitProps, PartialRecord, PickAllRequired, PickValue, Styles, Theme, ThemeConfig, Unsubscribe, UrlQuery, calculateColorContrast, colorThemeControls, countries, darkenColor, desaturateColor, eventPreventDefault, eventPreventStop, eventStopPropagation, formatPhoneNumber, generateApi, generateEventEmitter, generateRandomString, getPluralWord, isApiError, lightenColor, loaderControls, log, saturateColor, useBooleanState, useDebounceState, useLoader, useLoaderControls, useTheme } from 'react-better-core';
3
3
  import * as react from 'react';
4
4
  import { ComponentProps, ReactNode } from 'react';
5
- import * as react_jsx_runtime from 'react/jsx-runtime';
6
5
  import { WebTarget } from 'styled-components';
7
6
  import { Location, useNavigate, useLocation, useInRouterContext, useSearchParams, createSearchParams } from 'react-router-dom';
8
7
 
@@ -24,7 +23,7 @@ type ComponentPropWithRef<ComponentRef, ComponentProps> = ComponentProps & {
24
23
  ref?: React.Ref<ComponentRef>;
25
24
  };
26
25
 
27
- type ButtonProps<Value = unknown> = {
26
+ type InternalButtonProps<Value = unknown> = {
28
27
  text?: string;
29
28
  value?: Value;
30
29
  href?: string;
@@ -55,8 +54,10 @@ type ButtonProps<Value = unknown> = {
55
54
  isSmall?: boolean;
56
55
  /** @default false */
57
56
  isSubmit?: boolean;
57
+ fromSubcomponent?: boolean;
58
58
  onClickWithValue?: (value: Value) => void;
59
59
  } & OmitProps<React.ComponentProps<"button">, "style" | "defaultValue" | "translate" | "value"> & ComponentStyle & ComponentHoverStyle;
60
+ type ButtonProps<Value = unknown> = OmitProps<InternalButtonProps<Value>, "fromSubcomponent">;
60
61
  type ButtonComponent = {
61
62
  <Value>(props: ButtonProps<Value>): React.ReactElement;
62
63
  secondary: <Value>(props: ButtonProps<Value>) => React.ReactElement;
@@ -422,7 +423,7 @@ type LabelProps = {
422
423
  color?: React.CSSProperties["color"];
423
424
  htmlFor?: string;
424
425
  };
425
- declare function Label(labelProps: LabelProps): react_jsx_runtime.JSX.Element;
426
+ declare function Label(labelProps: LabelProps): react.JSX.Element;
426
427
  declare const _default$3: react.MemoExoticComponent<typeof Label>;
427
428
 
428
429
  type ImageProps = {
@@ -519,12 +520,12 @@ type TabsProps = {
519
520
  style?: "default" | "borderRadiusTop" | "box";
520
521
  gap?: number;
521
522
  noBottomLine?: boolean;
522
- onChange?: (tab: Tab) => void;
523
+ onChange?: (tab: Tab["id"]) => void;
523
524
  children?: React.ReactNode;
524
525
  } & ComponentMarginProps;
525
526
  type TabsRef = {
526
527
  selectedTab: Tab["id"];
527
- selectTab: (tab: Tab) => void;
528
+ selectTab: (tabId: Tab["id"]) => void;
528
529
  };
529
530
  type TabsComponent = {
530
531
  (props: ComponentPropWithRef<TabsRef, TabsProps>): React.ReactElement;
@@ -556,7 +557,7 @@ type BetterHtmlProviderConfig = BetterCoreProviderConfig & BetterHtmlProviderInt
556
557
  type BetterHtmlProviderProps = BetterProviderCommonProps & {
557
558
  config?: BetterHtmlProviderConfig;
558
559
  };
559
- declare function BetterHtmlProvider({ config, ...props }: BetterHtmlProviderProps): react_jsx_runtime.JSX.Element;
560
+ declare function BetterHtmlProvider({ config, ...props }: BetterHtmlProviderProps): react.JSX.Element;
560
561
  declare const _default$1: react.MemoExoticComponent<typeof BetterHtmlProvider>;
561
562
 
562
563
  declare const isMobileDevice: boolean;
package/dist/index.js CHANGED
@@ -2124,6 +2124,9 @@ var Loader_default = Loader2;
2124
2124
 
2125
2125
  // src/components/Button.tsx
2126
2126
  var import_jsx_runtime8 = require("react/jsx-runtime");
2127
+ var fromSubcomponentProps = {
2128
+ fromSubcomponent: true
2129
+ };
2127
2130
  var ButtonElement = import_styled_components6.default.button.withConfig({
2128
2131
  shouldForwardProp: (prop) => !["theme", "colorTheme", "style", "hoverStyle", "isSmall", "withText", "isLoading", "withNoBorder"].includes(
2129
2132
  prop
@@ -2206,7 +2209,7 @@ var ButtonComponent = function Button(buttonProps) {
2206
2209
  onClickWithValue,
2207
2210
  ...props
2208
2211
  } = useComponentsPropsMerger(
2209
- betterHtmlContextInternal.components.button?.style?.default,
2212
+ !buttonProps.fromSubcomponent ? betterHtmlContextInternal.components.button?.style?.default : {},
2210
2213
  buttonProps
2211
2214
  );
2212
2215
  const theme2 = (0, import_react_better_core9.useTheme)();
@@ -2331,6 +2334,7 @@ ButtonComponent.secondary = function Secondary(buttonProps) {
2331
2334
  {
2332
2335
  className: `secondary${className ? ` ${className}` : ""}`,
2333
2336
  color: theme2.colors.textPrimary,
2337
+ ...fromSubcomponentProps,
2334
2338
  ...props
2335
2339
  }
2336
2340
  );
@@ -2342,7 +2346,15 @@ ButtonComponent.destructive = function Destructive(buttonProps) {
2342
2346
  buttonProps
2343
2347
  );
2344
2348
  const theme2 = (0, import_react_better_core9.useTheme)();
2345
- return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(ButtonComponent, { backgroundColor: theme2.colors.error, color: theme2.colors.base, ...props });
2349
+ return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
2350
+ ButtonComponent,
2351
+ {
2352
+ backgroundColor: theme2.colors.error,
2353
+ color: theme2.colors.base,
2354
+ ...fromSubcomponentProps,
2355
+ ...props
2356
+ }
2357
+ );
2346
2358
  };
2347
2359
  ButtonComponent.icon = function Icon3({ size = 16, buttonSize, backgroundButtonColor, ...buttonProps }) {
2348
2360
  const betterHtmlContextInternal = useBetterHtmlContextInternal();
@@ -2356,7 +2368,6 @@ ButtonComponent.icon = function Icon3({ size = 16, buttonSize, backgroundButtonC
2356
2368
  return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
2357
2369
  ButtonComponent,
2358
2370
  {
2359
- ...betterHtmlContextInternal.components.button?.style?.icon,
2360
2371
  width: readyButtonSize,
2361
2372
  height: readyButtonSize,
2362
2373
  color: theme2.colors.textPrimary,
@@ -2369,6 +2380,7 @@ ButtonComponent.icon = function Icon3({ size = 16, buttonSize, backgroundButtonC
2369
2380
  border: "none",
2370
2381
  padding: 0,
2371
2382
  filterHover: "none !important",
2383
+ ...fromSubcomponentProps,
2372
2384
  ...props
2373
2385
  }
2374
2386
  );
@@ -2392,10 +2404,10 @@ ButtonComponent.upload = function Upload({ accept, multiple, onUpload, ...button
2392
2404
  return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
2393
2405
  ButtonComponent,
2394
2406
  {
2395
- ...betterHtmlContextInternal.components.button?.style?.upload,
2396
2407
  text: "Upload",
2397
2408
  icon: "uploadCloud",
2398
2409
  onClick: onClickElement,
2410
+ ...fromSubcomponentProps,
2399
2411
  ...props
2400
2412
  }
2401
2413
  );
@@ -7503,41 +7515,41 @@ var TabsComponent = (0, import_react29.forwardRef)(function Tabs({ tabs, name, a
7503
7515
  const firstRenderPassedRef = (0, import_react29.useRef)(false);
7504
7516
  const tabsRef = (0, import_react29.useRef)({});
7505
7517
  const tabsGap = gap ?? (style === "box" ? theme2.styles.gap / 2 : 0);
7506
- const [selectedTab, setSelectedTab] = (0, import_react29.useState)(() => {
7507
- const selectedTabId = tabs[0];
7518
+ const [selectedTabId, setSelectedTabId] = (0, import_react29.useState)(() => {
7519
+ const selectedTabId2 = tabs[0];
7508
7520
  if (urlQuery) {
7509
7521
  const tabQueryValue = urlQuery.getQuery(name ?? defaultTabName);
7510
- if (!tabQueryValue) return selectedTabId;
7522
+ if (!tabQueryValue) return selectedTabId2.id;
7511
7523
  const queryTab = tabs.find((tab) => tab.id === tabQueryValue);
7512
- if (queryTab) return queryTab;
7524
+ if (queryTab) return queryTab.id;
7513
7525
  }
7514
- return selectedTabId;
7526
+ return selectedTabId2.id;
7515
7527
  });
7516
7528
  const [rerenderState, setRerenderState] = (0, import_react29.useState)(0);
7517
7529
  const onClickTab = (0, import_react29.useCallback)(
7518
- (tab) => {
7519
- setSelectedTab(tab);
7520
- onChange?.(tab);
7530
+ (tabId) => {
7531
+ setSelectedTabId(tabId);
7532
+ onChange?.(tabId);
7521
7533
  if (urlQuery) {
7522
7534
  urlQuery.setQuery({
7523
- [name ?? defaultTabName]: tab.id
7535
+ [name ?? defaultTabName]: tabId
7524
7536
  });
7525
7537
  }
7526
7538
  },
7527
7539
  [onChange, name, urlQuery]
7528
7540
  );
7529
7541
  const width = (0, import_react29.useMemo)(
7530
- () => tabsRef.current[selectedTab.id]?.getBoundingClientRect().width ?? 0,
7531
- [rerenderState, selectedTab]
7542
+ () => tabsRef.current[selectedTabId]?.getBoundingClientRect().width ?? 0,
7543
+ [rerenderState, selectedTabId]
7532
7544
  );
7533
7545
  const leftSpacing = (0, import_react29.useMemo)(() => {
7534
- const selectedTabIndex = tabs.findIndex((tab) => tab.id === selectedTab.id);
7546
+ const selectedTabIndex = tabs.findIndex((tab) => tab.id === selectedTabId);
7535
7547
  let spacing = 0;
7536
7548
  Object.values(tabsRef.current).forEach((tab, index) => {
7537
7549
  if (index < selectedTabIndex) spacing += (tab?.getBoundingClientRect().width ?? 0) + tabsGap;
7538
7550
  });
7539
7551
  return spacing;
7540
- }, [selectedTab, tabs, tabsGap]);
7552
+ }, [selectedTabId, tabs, tabsGap]);
7541
7553
  (0, import_react29.useEffect)(() => {
7542
7554
  const timeout = setTimeout(() => {
7543
7555
  setRerenderState(Math.random());
@@ -7554,7 +7566,7 @@ var TabsComponent = (0, import_react29.forwardRef)(function Tabs({ tabs, name, a
7554
7566
  return oldValue.map(
7555
7567
  (item) => item.name === (name ?? defaultTabName) ? {
7556
7568
  ...item,
7557
- selectedTab: selectedTab.id
7569
+ selectedTab: selectedTabId
7558
7570
  } : item
7559
7571
  );
7560
7572
  } else {
@@ -7562,18 +7574,18 @@ var TabsComponent = (0, import_react29.forwardRef)(function Tabs({ tabs, name, a
7562
7574
  ...oldValue,
7563
7575
  {
7564
7576
  name: name ?? defaultTabName,
7565
- selectedTab: selectedTab.id
7577
+ selectedTab: selectedTabId
7566
7578
  }
7567
7579
  ];
7568
7580
  }
7569
7581
  });
7570
- }, [selectedTab, name]);
7582
+ }, [selectedTabId, name]);
7571
7583
  (0, import_react29.useEffect)(() => {
7572
- tabsRef.current[selectedTab.id]?.scrollIntoView({
7584
+ tabsRef.current[selectedTabId]?.scrollIntoView({
7573
7585
  behavior: firstRenderPassedRef.current ? "smooth" : void 0,
7574
7586
  block: "nearest"
7575
7587
  });
7576
- }, [selectedTab]);
7588
+ }, [selectedTabId]);
7577
7589
  (0, import_react29.useEffect)(() => {
7578
7590
  return () => {
7579
7591
  componentsState.tabs.setTabGroups(
@@ -7582,18 +7594,18 @@ var TabsComponent = (0, import_react29.forwardRef)(function Tabs({ tabs, name, a
7582
7594
  };
7583
7595
  }, []);
7584
7596
  (0, import_react29.useEffect)(() => {
7585
- onChange?.(selectedTab);
7597
+ onChange?.(selectedTabId);
7586
7598
  }, []);
7587
7599
  (0, import_react29.useImperativeHandle)(ref, () => {
7588
7600
  return {
7589
- selectedTab: selectedTab.id,
7601
+ selectedTab: selectedTabId,
7590
7602
  selectTab: onClickTab
7591
7603
  };
7592
- }, [selectedTab, onClickTab]);
7604
+ }, [selectedTabId, onClickTab]);
7593
7605
  return /* @__PURE__ */ (0, import_jsx_runtime26.jsxs)(Div_default.column, { width: "100%", gap: theme2.styles.space, ...props, children: [
7594
7606
  /* @__PURE__ */ (0, import_jsx_runtime26.jsxs)(Div_default, { position: "relative", className: "react-better-html-no-scrollbar", overflowY: "auto", children: [
7595
7607
  /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(Div_default.row, { position: "relative", width: "fit-content", gap: tabsGap, userSelect: "none", children: tabs.map((tab) => {
7596
- const selected = tab.id === selectedTab.id;
7608
+ const selected = tab.id === selectedTabId;
7597
7609
  return /* @__PURE__ */ (0, import_jsx_runtime26.jsxs)(
7598
7610
  Div_default,
7599
7611
  {
@@ -7608,7 +7620,7 @@ var TabsComponent = (0, import_react29.forwardRef)(function Tabs({ tabs, name, a
7608
7620
  filterHover: colorTheme === "dark" ? style === "box" ? "brightness(1.2)" : "brightness(2)" : "brightness(0.9)",
7609
7621
  paddingInline: theme2.styles.space,
7610
7622
  paddingBlock: theme2.styles.gap,
7611
- value: tab,
7623
+ value: tab.id,
7612
7624
  cursor: "pointer",
7613
7625
  isTabAccessed: true,
7614
7626
  onClickWithValue: onClickTab,