@grandbazar/ui-baza 1.2.9 → 1.2.10

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.cjs CHANGED
@@ -1684,7 +1684,7 @@ function DropdownMenuProvider({ children }) {
1684
1684
  portalPlacement,
1685
1685
  setPortalPlacement
1686
1686
  },
1687
- children: typeof children === "function" ? children({ isOpen, setIsOpen, portalPlacement }) : children
1687
+ children: typeof children === "function" ? children({ isOpen, setIsOpen, portalPlacement, triggerRef }) : children
1688
1688
  }
1689
1689
  );
1690
1690
  }
@@ -2068,6 +2068,7 @@ const styles$g = {
2068
2068
  function DropdownPortal({
2069
2069
  children,
2070
2070
  className,
2071
+ style,
2071
2072
  align = "start",
2072
2073
  position = "bottom",
2073
2074
  isNested,
@@ -2096,7 +2097,8 @@ function DropdownPortal({
2096
2097
  style: {
2097
2098
  ...portalPosition,
2098
2099
  ...maxWidth && { "--dropdown-portal-max-width": `${maxWidth + offset}px` },
2099
- ...maxHeight && { "--dropdown-portal-max-height": `${maxHeight + offset}px` }
2100
+ ...maxHeight && { "--dropdown-portal-max-height": `${maxHeight + offset}px` },
2101
+ ...style
2100
2102
  },
2101
2103
  ref: portalRef,
2102
2104
  className: classNames(styles$g.dropdownPortal, className),
@@ -2784,8 +2786,15 @@ function Tag({ children, className, size = "md", mode = "primary", disabled, ...
2784
2786
  );
2785
2787
  }
2786
2788
 
2787
- const tooltipContent = "_tooltipContent_1267q_2";
2788
- const tooltipTitle = "_tooltipTitle_1267q_96";
2789
+ const TOOLTIP_CONTENT_ARROW = {
2790
+ width: 16,
2791
+ height: 8,
2792
+ offsetInline: 12,
2793
+ offsetBlock: 10
2794
+ };
2795
+
2796
+ const tooltipContent = "_tooltipContent_ww0bo_2";
2797
+ const tooltipTitle = "_tooltipTitle_ww0bo_92";
2789
2798
  const styles = {
2790
2799
  tooltipContent: tooltipContent,
2791
2800
  tooltipTitle: tooltipTitle
@@ -2798,7 +2807,6 @@ function TooltipContent({
2798
2807
  description,
2799
2808
  arrowAlign,
2800
2809
  arrowPosition,
2801
- arrowOffset,
2802
2810
  ...props
2803
2811
  }) {
2804
2812
  return /* @__PURE__ */ jsxRuntime.jsxs(
@@ -2808,11 +2816,11 @@ function TooltipContent({
2808
2816
  role: role ?? "tooltip",
2809
2817
  "data-align": arrowAlign,
2810
2818
  "data-position": arrowPosition,
2811
- ...arrowOffset && {
2812
- style: {
2813
- "--tooltip-content-arrow-offset-inline": `${arrowOffset.inline}px`,
2814
- "--tooltip-content-arrow-offset-block": `${arrowOffset.block}px`
2815
- }
2819
+ style: {
2820
+ "--tooltip-content-arrow-width": `${TOOLTIP_CONTENT_ARROW.width}px`,
2821
+ "--tooltip-content-arrow-height": `${TOOLTIP_CONTENT_ARROW.height}px`,
2822
+ "--tooltip-content-arrow-offset-inline": `${TOOLTIP_CONTENT_ARROW.offsetInline}px`,
2823
+ "--tooltip-content-arrow-offset-block": `${TOOLTIP_CONTENT_ARROW.offsetBlock}px`
2816
2824
  },
2817
2825
  ...props,
2818
2826
  children: [
@@ -2823,7 +2831,24 @@ function TooltipContent({
2823
2831
  );
2824
2832
  }
2825
2833
 
2826
- const TOOLTIP_OFFSET = 8;
2834
+ function getCenteredPortalShiftStyle({
2835
+ portalPlacement,
2836
+ triggerRef
2837
+ }) {
2838
+ const triggerRect = triggerRef.current?.getBoundingClientRect();
2839
+ if (!triggerRect || !portalPlacement || portalPlacement.align === "center") {
2840
+ return {};
2841
+ }
2842
+ const isHorizontal = portalPlacement.position === "top" || portalPlacement.position === "bottom";
2843
+ const triggerHalfSize = isHorizontal ? triggerRect.width / 2 : triggerRect.height / 2;
2844
+ const arrowOffset = (isHorizontal ? TOOLTIP_CONTENT_ARROW.offsetInline : TOOLTIP_CONTENT_ARROW.offsetBlock) + TOOLTIP_CONTENT_ARROW.height * Math.SQRT2 / 2;
2845
+ const shift = portalPlacement.align === "start" ? triggerHalfSize - arrowOffset : arrowOffset - triggerHalfSize;
2846
+ const shiftPx = `${Number(shift.toFixed(3))}px`;
2847
+ if (isHorizontal) {
2848
+ return { marginLeft: shiftPx };
2849
+ }
2850
+ return { marginTop: shiftPx };
2851
+ }
2827
2852
 
2828
2853
  function TooltipRoot({
2829
2854
  children,
@@ -2834,19 +2859,23 @@ function TooltipRoot({
2834
2859
  maxHeight,
2835
2860
  withoutArrow = false,
2836
2861
  scrollContainerRef,
2862
+ centerArrowToTrigger = true,
2837
2863
  ...tooltipContentProps
2838
2864
  }) {
2839
- return /* @__PURE__ */ jsxRuntime.jsx(DropdownMenu.Root, { children: ({ portalPlacement }) => /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
2865
+ return /* @__PURE__ */ jsxRuntime.jsx(DropdownMenu.Root, { children: ({ portalPlacement, triggerRef }) => /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
2840
2866
  /* @__PURE__ */ jsxRuntime.jsx(DropdownMenu.Trigger, { asChild: true, triggerEvent, children }),
2841
2867
  /* @__PURE__ */ jsxRuntime.jsx(
2842
2868
  DropdownMenu.Portal,
2843
2869
  {
2844
2870
  align,
2845
2871
  position,
2846
- offset: TOOLTIP_OFFSET,
2872
+ offset: TOOLTIP_CONTENT_ARROW.height,
2847
2873
  maxWidth,
2848
2874
  maxHeight,
2849
2875
  scrollContainerRef,
2876
+ style: {
2877
+ ...!withoutArrow && centerArrowToTrigger && getCenteredPortalShiftStyle({ portalPlacement, triggerRef })
2878
+ },
2850
2879
  children: /* @__PURE__ */ jsxRuntime.jsx(
2851
2880
  TooltipContent,
2852
2881
  {
package/dist/index.d.ts CHANGED
@@ -1,4 +1,5 @@
1
1
  import { ComponentProps } from 'react';
2
+ import { CSSProperties } from 'react';
2
3
  import { default as default_2 } from 'react';
3
4
  import { Dispatch } from 'react';
4
5
  import { IconGoogle } from './logos';
@@ -190,7 +191,7 @@ export declare namespace DropdownMenu {
190
191
  var Portal: typeof DropdownPortal;
191
192
  }
192
193
 
193
- declare function DropdownPortal({ children, className, align, position, isNested, offset, maxWidth, maxHeight, scrollContainerRef, }: TDropdownPortalProps): ReactPortal | null;
194
+ declare function DropdownPortal({ children, className, style, align, position, isNested, offset, maxWidth, maxHeight, scrollContainerRef, }: TDropdownPortalProps): ReactPortal | null;
194
195
 
195
196
  declare function DropdownRoot({ children }: TDropdownRootProps): JSX.Element;
196
197
 
@@ -664,6 +665,7 @@ declare type TDropdownMenuContextValue = {
664
665
  declare type TDropdownPortalProps = {
665
666
  children: React.ReactNode;
666
667
  className?: string;
668
+ style?: CSSProperties;
667
669
  align?: TArrayElement<typeof DROPDOWN_PORTAL_ALIGN_LIST>;
668
670
  position?: TArrayElement<typeof DROPDOWN_PORTAL_POSITION_LIST>;
669
671
  isNested?: boolean;
@@ -674,7 +676,7 @@ declare type TDropdownPortalProps = {
674
676
  };
675
677
 
676
678
  declare type TDropdownRootProps = {
677
- children: React.ReactNode | ((context: Pick<TDropdownMenuContextValue, 'isOpen' | 'setIsOpen' | 'portalPlacement'>) => React.ReactNode);
679
+ children: React.ReactNode | ((context: Pick<TDropdownMenuContextValue, 'isOpen' | 'setIsOpen' | 'portalPlacement' | 'triggerRef'>) => React.ReactNode);
678
680
  };
679
681
 
680
682
  declare type TDropdownTriggerProps = TAsChildProps<React.HTMLAttributes<HTMLButtonElement>> & {
@@ -727,7 +729,8 @@ declare type TLocale = TArrayElement<typeof LOCALES>;
727
729
  * @param triggerEvent - Trigger behavior (hover, click)
728
730
  * @param maxWidth - Max width of the tooltip content in pixels (required for horizontal flip)
729
731
  * @param maxHeight - Max height of the tooltip content in pixels (required for vertical flip)
730
- * @param arrowOffset - Arrow offset in pixels for inline and block axes
732
+ * @param scrollContainerRef - Optional scroll container used as portal mount node and positioning boundary
733
+ * @param centerArrowToTrigger - Automatically shifts portal to keep arrow at trigger center for start/end align
731
734
  * @param withoutArrow - Hide tooltip arrow
732
735
  *
733
736
  * @example
@@ -741,9 +744,9 @@ export declare namespace Tooltip {
741
744
  var Content: typeof TooltipContent;
742
745
  }
743
746
 
744
- declare function TooltipContent({ className, role, title, description, arrowAlign, arrowPosition, arrowOffset, ...props }: TTooltipContentProps): JSX.Element;
747
+ declare function TooltipContent({ className, role, title, description, arrowAlign, arrowPosition, ...props }: TTooltipContentProps): JSX.Element;
745
748
 
746
- declare function TooltipRoot({ children, align, position, triggerEvent, maxWidth, maxHeight, withoutArrow, scrollContainerRef, ...tooltipContentProps }: TTooltipRootProps): JSX.Element;
749
+ declare function TooltipRoot({ children, align, position, triggerEvent, maxWidth, maxHeight, withoutArrow, scrollContainerRef, centerArrowToTrigger, ...tooltipContentProps }: TTooltipRootProps): JSX.Element;
747
750
 
748
751
  declare type TPaginationItemProps = React.ButtonHTMLAttributes<HTMLButtonElement> & {
749
752
  size?: TArrayElement<typeof PAGINATION_SIZES>;
@@ -869,21 +872,12 @@ declare type TTooltipContentProps = Omit<React.HTMLAttributes<HTMLDivElement>, '
869
872
  description?: string;
870
873
  arrowAlign?: TArrayElement<typeof DROPDOWN_PORTAL_ALIGN_LIST>;
871
874
  arrowPosition?: TArrayElement<typeof DROPDOWN_PORTAL_POSITION_LIST>;
872
- arrowOffset?: {
873
- inline: number;
874
- block: number;
875
- };
876
875
  };
877
876
 
878
- declare type TTooltipRootProps = Omit<React.ComponentProps<typeof TooltipContent>, 'arrowAlign' | 'arrowPosition'> & {
879
- children: React.ReactNode;
877
+ declare type TTooltipRootProps = Omit<React.ComponentProps<typeof TooltipContent>, 'arrowAlign' | 'arrowPosition'> & Pick<React.ComponentProps<typeof DropdownMenu.Portal>, 'align' | 'position' | 'maxWidth' | 'maxHeight' | 'scrollContainerRef' | 'children'> & {
880
878
  triggerEvent?: TArrayElement<typeof DROPDOWN_TRIGGER_EVENT_LIST>;
881
- align?: TArrayElement<typeof DROPDOWN_PORTAL_ALIGN_LIST>;
882
- position?: TArrayElement<typeof DROPDOWN_PORTAL_POSITION_LIST>;
883
- maxWidth?: number;
884
- maxHeight?: number;
885
879
  withoutArrow?: boolean;
886
- scrollContainerRef?: React.RefObject<HTMLElement | null>;
880
+ centerArrowToTrigger?: boolean;
887
881
  };
888
882
 
889
883
  declare type TWithRef<TProps, TElement = HTMLElement> = TProps & {
package/dist/index.js CHANGED
@@ -1680,7 +1680,7 @@ function DropdownMenuProvider({ children }) {
1680
1680
  portalPlacement,
1681
1681
  setPortalPlacement
1682
1682
  },
1683
- children: typeof children === "function" ? children({ isOpen, setIsOpen, portalPlacement }) : children
1683
+ children: typeof children === "function" ? children({ isOpen, setIsOpen, portalPlacement, triggerRef }) : children
1684
1684
  }
1685
1685
  );
1686
1686
  }
@@ -2064,6 +2064,7 @@ const styles$g = {
2064
2064
  function DropdownPortal({
2065
2065
  children,
2066
2066
  className,
2067
+ style,
2067
2068
  align = "start",
2068
2069
  position = "bottom",
2069
2070
  isNested,
@@ -2092,7 +2093,8 @@ function DropdownPortal({
2092
2093
  style: {
2093
2094
  ...portalPosition,
2094
2095
  ...maxWidth && { "--dropdown-portal-max-width": `${maxWidth + offset}px` },
2095
- ...maxHeight && { "--dropdown-portal-max-height": `${maxHeight + offset}px` }
2096
+ ...maxHeight && { "--dropdown-portal-max-height": `${maxHeight + offset}px` },
2097
+ ...style
2096
2098
  },
2097
2099
  ref: portalRef,
2098
2100
  className: classNames(styles$g.dropdownPortal, className),
@@ -2780,8 +2782,15 @@ function Tag({ children, className, size = "md", mode = "primary", disabled, ...
2780
2782
  );
2781
2783
  }
2782
2784
 
2783
- const tooltipContent = "_tooltipContent_1267q_2";
2784
- const tooltipTitle = "_tooltipTitle_1267q_96";
2785
+ const TOOLTIP_CONTENT_ARROW = {
2786
+ width: 16,
2787
+ height: 8,
2788
+ offsetInline: 12,
2789
+ offsetBlock: 10
2790
+ };
2791
+
2792
+ const tooltipContent = "_tooltipContent_ww0bo_2";
2793
+ const tooltipTitle = "_tooltipTitle_ww0bo_92";
2785
2794
  const styles = {
2786
2795
  tooltipContent: tooltipContent,
2787
2796
  tooltipTitle: tooltipTitle
@@ -2794,7 +2803,6 @@ function TooltipContent({
2794
2803
  description,
2795
2804
  arrowAlign,
2796
2805
  arrowPosition,
2797
- arrowOffset,
2798
2806
  ...props
2799
2807
  }) {
2800
2808
  return /* @__PURE__ */ jsxs(
@@ -2804,11 +2812,11 @@ function TooltipContent({
2804
2812
  role: role ?? "tooltip",
2805
2813
  "data-align": arrowAlign,
2806
2814
  "data-position": arrowPosition,
2807
- ...arrowOffset && {
2808
- style: {
2809
- "--tooltip-content-arrow-offset-inline": `${arrowOffset.inline}px`,
2810
- "--tooltip-content-arrow-offset-block": `${arrowOffset.block}px`
2811
- }
2815
+ style: {
2816
+ "--tooltip-content-arrow-width": `${TOOLTIP_CONTENT_ARROW.width}px`,
2817
+ "--tooltip-content-arrow-height": `${TOOLTIP_CONTENT_ARROW.height}px`,
2818
+ "--tooltip-content-arrow-offset-inline": `${TOOLTIP_CONTENT_ARROW.offsetInline}px`,
2819
+ "--tooltip-content-arrow-offset-block": `${TOOLTIP_CONTENT_ARROW.offsetBlock}px`
2812
2820
  },
2813
2821
  ...props,
2814
2822
  children: [
@@ -2819,7 +2827,24 @@ function TooltipContent({
2819
2827
  );
2820
2828
  }
2821
2829
 
2822
- const TOOLTIP_OFFSET = 8;
2830
+ function getCenteredPortalShiftStyle({
2831
+ portalPlacement,
2832
+ triggerRef
2833
+ }) {
2834
+ const triggerRect = triggerRef.current?.getBoundingClientRect();
2835
+ if (!triggerRect || !portalPlacement || portalPlacement.align === "center") {
2836
+ return {};
2837
+ }
2838
+ const isHorizontal = portalPlacement.position === "top" || portalPlacement.position === "bottom";
2839
+ const triggerHalfSize = isHorizontal ? triggerRect.width / 2 : triggerRect.height / 2;
2840
+ const arrowOffset = (isHorizontal ? TOOLTIP_CONTENT_ARROW.offsetInline : TOOLTIP_CONTENT_ARROW.offsetBlock) + TOOLTIP_CONTENT_ARROW.height * Math.SQRT2 / 2;
2841
+ const shift = portalPlacement.align === "start" ? triggerHalfSize - arrowOffset : arrowOffset - triggerHalfSize;
2842
+ const shiftPx = `${Number(shift.toFixed(3))}px`;
2843
+ if (isHorizontal) {
2844
+ return { marginLeft: shiftPx };
2845
+ }
2846
+ return { marginTop: shiftPx };
2847
+ }
2823
2848
 
2824
2849
  function TooltipRoot({
2825
2850
  children,
@@ -2830,19 +2855,23 @@ function TooltipRoot({
2830
2855
  maxHeight,
2831
2856
  withoutArrow = false,
2832
2857
  scrollContainerRef,
2858
+ centerArrowToTrigger = true,
2833
2859
  ...tooltipContentProps
2834
2860
  }) {
2835
- return /* @__PURE__ */ jsx(DropdownMenu.Root, { children: ({ portalPlacement }) => /* @__PURE__ */ jsxs(Fragment$1, { children: [
2861
+ return /* @__PURE__ */ jsx(DropdownMenu.Root, { children: ({ portalPlacement, triggerRef }) => /* @__PURE__ */ jsxs(Fragment$1, { children: [
2836
2862
  /* @__PURE__ */ jsx(DropdownMenu.Trigger, { asChild: true, triggerEvent, children }),
2837
2863
  /* @__PURE__ */ jsx(
2838
2864
  DropdownMenu.Portal,
2839
2865
  {
2840
2866
  align,
2841
2867
  position,
2842
- offset: TOOLTIP_OFFSET,
2868
+ offset: TOOLTIP_CONTENT_ARROW.height,
2843
2869
  maxWidth,
2844
2870
  maxHeight,
2845
2871
  scrollContainerRef,
2872
+ style: {
2873
+ ...!withoutArrow && centerArrowToTrigger && getCenteredPortalShiftStyle({ portalPlacement, triggerRef })
2874
+ },
2846
2875
  children: /* @__PURE__ */ jsx(
2847
2876
  TooltipContent,
2848
2877
  {
package/dist/style.css CHANGED
@@ -1863,13 +1863,9 @@ textarea {
1863
1863
  }
1864
1864
  }
1865
1865
  @layer ui_baza_components {
1866
- ._tooltipContent_1267q_2 {
1867
- --tooltip-content-arrow-width: 16px;
1868
- --tooltip-content-arrow-height: 8px;
1866
+ ._tooltipContent_ww0bo_2 {
1869
1867
  --tooltip-content-arrow-square-side: calc(var(--tooltip-content-arrow-height) * sqrt(2));
1870
1868
  --tooltip-content-arrow-border-radius: 2px;
1871
- --tooltip-content-arrow-offset-inline: var(--space-xl);
1872
- --tooltip-content-arrow-offset-block: var(--space-lg);
1873
1869
 
1874
1870
  display: flex;
1875
1871
  position: relative;
@@ -1957,7 +1953,7 @@ textarea {
1957
1953
  }
1958
1954
  }
1959
1955
 
1960
- ._tooltipTitle_1267q_96 {
1956
+ ._tooltipTitle_ww0bo_92 {
1961
1957
  font-weight: var(--font-weight-medium);
1962
1958
  font-size: var(--size-md);
1963
1959
  line-height: var(--line-height-lg);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@grandbazar/ui-baza",
3
- "version": "1.2.9",
3
+ "version": "1.2.10",
4
4
  "description": "A lightweight and modular UI kit for building modern, accessible web interfaces. Designed for flexibility, scalability, and developer happiness.",
5
5
  "repository": {
6
6
  "type": "git",