@grandbazar/ui-baza 1.2.9 → 1.2.11

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
@@ -1321,6 +1321,19 @@ function getCalendarGrid(month, year, firstDayOfWeek) {
1321
1321
  );
1322
1322
  }
1323
1323
 
1324
+ function normalizeDateRange(firstDate, secondDate) {
1325
+ if (!firstDate || !secondDate) {
1326
+ return { firstDate, secondDate };
1327
+ }
1328
+ if (firstDate.getTime() <= secondDate.getTime()) {
1329
+ return { firstDate, secondDate };
1330
+ }
1331
+ return {
1332
+ firstDate: secondDate,
1333
+ secondDate: firstDate
1334
+ };
1335
+ }
1336
+
1324
1337
  const datePickerField = "_datePickerField_1qk8s_2";
1325
1338
  const datePickerFieldCalendar = "_datePickerFieldCalendar_1qk8s_8";
1326
1339
  const datePickerFieldWeek = "_datePickerFieldWeek_1qk8s_14";
@@ -1426,9 +1439,14 @@ function useDatePickerControls(initialDate = /* @__PURE__ */ new Date()) {
1426
1439
  };
1427
1440
  }
1428
1441
 
1429
- function useDatePickerMultiSelect(firstDayOfWeek = LOCALE_FIRST_DAY_OF_WEEK.ru) {
1430
- const [firstSelectedDate, setFirstSelectedDate] = React.useState(null);
1431
- const [secondSelectedDate, setSecondSelectedDate] = React.useState(null);
1442
+ function useDatePickerMultiSelect({
1443
+ firstDayOfWeek = LOCALE_FIRST_DAY_OF_WEEK.ru,
1444
+ initialFirstSelectedDate = null,
1445
+ initialSecondSelectedDate = null
1446
+ } = {}) {
1447
+ const normalizedRange = normalizeDateRange(initialFirstSelectedDate, initialSecondSelectedDate);
1448
+ const [firstSelectedDate, setFirstSelectedDate] = React.useState(normalizedRange.firstDate);
1449
+ const [secondSelectedDate, setSecondSelectedDate] = React.useState(normalizedRange.secondDate);
1432
1450
  const lastDayOfWeek = (firstDayOfWeek + 6) % 7;
1433
1451
  const dayInfoCache = React.useMemo(() => /* @__PURE__ */ new Map(), []);
1434
1452
  const getDayInfo = React.useCallback(
@@ -1544,8 +1562,8 @@ function useDatePickerMultiSelect(firstDayOfWeek = LOCALE_FIRST_DAY_OF_WEEK.ru)
1544
1562
  return { firstSelectedDate, secondSelectedDate, setFirstSelectedDate, setSecondSelectedDate, getCellProps };
1545
1563
  }
1546
1564
 
1547
- function useDatePickerSelect() {
1548
- const [selectedDate, setSelectedDate] = React.useState(null);
1565
+ function useDatePickerSelect({ initialSelectedDate = null } = {}) {
1566
+ const [selectedDate, setSelectedDate] = React.useState(initialSelectedDate);
1549
1567
  const getCellProps = React.useCallback(
1550
1568
  (day) => {
1551
1569
  return {
@@ -1684,7 +1702,7 @@ function DropdownMenuProvider({ children }) {
1684
1702
  portalPlacement,
1685
1703
  setPortalPlacement
1686
1704
  },
1687
- children: typeof children === "function" ? children({ isOpen, setIsOpen, portalPlacement }) : children
1705
+ children: typeof children === "function" ? children({ isOpen, setIsOpen, portalPlacement, triggerRef }) : children
1688
1706
  }
1689
1707
  );
1690
1708
  }
@@ -2068,6 +2086,7 @@ const styles$g = {
2068
2086
  function DropdownPortal({
2069
2087
  children,
2070
2088
  className,
2089
+ style,
2071
2090
  align = "start",
2072
2091
  position = "bottom",
2073
2092
  isNested,
@@ -2096,7 +2115,8 @@ function DropdownPortal({
2096
2115
  style: {
2097
2116
  ...portalPosition,
2098
2117
  ...maxWidth && { "--dropdown-portal-max-width": `${maxWidth + offset}px` },
2099
- ...maxHeight && { "--dropdown-portal-max-height": `${maxHeight + offset}px` }
2118
+ ...maxHeight && { "--dropdown-portal-max-height": `${maxHeight + offset}px` },
2119
+ ...style
2100
2120
  },
2101
2121
  ref: portalRef,
2102
2122
  className: classNames(styles$g.dropdownPortal, className),
@@ -2784,8 +2804,15 @@ function Tag({ children, className, size = "md", mode = "primary", disabled, ...
2784
2804
  );
2785
2805
  }
2786
2806
 
2787
- const tooltipContent = "_tooltipContent_1267q_2";
2788
- const tooltipTitle = "_tooltipTitle_1267q_96";
2807
+ const TOOLTIP_CONTENT_ARROW = {
2808
+ width: 16,
2809
+ height: 8,
2810
+ offsetInline: 12,
2811
+ offsetBlock: 10
2812
+ };
2813
+
2814
+ const tooltipContent = "_tooltipContent_ww0bo_2";
2815
+ const tooltipTitle = "_tooltipTitle_ww0bo_92";
2789
2816
  const styles = {
2790
2817
  tooltipContent: tooltipContent,
2791
2818
  tooltipTitle: tooltipTitle
@@ -2798,7 +2825,6 @@ function TooltipContent({
2798
2825
  description,
2799
2826
  arrowAlign,
2800
2827
  arrowPosition,
2801
- arrowOffset,
2802
2828
  ...props
2803
2829
  }) {
2804
2830
  return /* @__PURE__ */ jsxRuntime.jsxs(
@@ -2808,11 +2834,11 @@ function TooltipContent({
2808
2834
  role: role ?? "tooltip",
2809
2835
  "data-align": arrowAlign,
2810
2836
  "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
- }
2837
+ style: {
2838
+ "--tooltip-content-arrow-width": `${TOOLTIP_CONTENT_ARROW.width}px`,
2839
+ "--tooltip-content-arrow-height": `${TOOLTIP_CONTENT_ARROW.height}px`,
2840
+ "--tooltip-content-arrow-offset-inline": `${TOOLTIP_CONTENT_ARROW.offsetInline}px`,
2841
+ "--tooltip-content-arrow-offset-block": `${TOOLTIP_CONTENT_ARROW.offsetBlock}px`
2816
2842
  },
2817
2843
  ...props,
2818
2844
  children: [
@@ -2823,7 +2849,24 @@ function TooltipContent({
2823
2849
  );
2824
2850
  }
2825
2851
 
2826
- const TOOLTIP_OFFSET = 8;
2852
+ function getCenteredPortalShiftStyle({
2853
+ portalPlacement,
2854
+ triggerRef
2855
+ }) {
2856
+ const triggerRect = triggerRef.current?.getBoundingClientRect();
2857
+ if (!triggerRect || !portalPlacement || portalPlacement.align === "center") {
2858
+ return {};
2859
+ }
2860
+ const isHorizontal = portalPlacement.position === "top" || portalPlacement.position === "bottom";
2861
+ const triggerHalfSize = isHorizontal ? triggerRect.width / 2 : triggerRect.height / 2;
2862
+ const arrowOffset = (isHorizontal ? TOOLTIP_CONTENT_ARROW.offsetInline : TOOLTIP_CONTENT_ARROW.offsetBlock) + TOOLTIP_CONTENT_ARROW.height * Math.SQRT2 / 2;
2863
+ const shift = portalPlacement.align === "start" ? triggerHalfSize - arrowOffset : arrowOffset - triggerHalfSize;
2864
+ const shiftPx = `${Number(shift.toFixed(3))}px`;
2865
+ if (isHorizontal) {
2866
+ return { marginLeft: shiftPx };
2867
+ }
2868
+ return { marginTop: shiftPx };
2869
+ }
2827
2870
 
2828
2871
  function TooltipRoot({
2829
2872
  children,
@@ -2834,19 +2877,23 @@ function TooltipRoot({
2834
2877
  maxHeight,
2835
2878
  withoutArrow = false,
2836
2879
  scrollContainerRef,
2880
+ centerArrowToTrigger = true,
2837
2881
  ...tooltipContentProps
2838
2882
  }) {
2839
- return /* @__PURE__ */ jsxRuntime.jsx(DropdownMenu.Root, { children: ({ portalPlacement }) => /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
2883
+ return /* @__PURE__ */ jsxRuntime.jsx(DropdownMenu.Root, { children: ({ portalPlacement, triggerRef }) => /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
2840
2884
  /* @__PURE__ */ jsxRuntime.jsx(DropdownMenu.Trigger, { asChild: true, triggerEvent, children }),
2841
2885
  /* @__PURE__ */ jsxRuntime.jsx(
2842
2886
  DropdownMenu.Portal,
2843
2887
  {
2844
2888
  align,
2845
2889
  position,
2846
- offset: TOOLTIP_OFFSET,
2890
+ offset: TOOLTIP_CONTENT_ARROW.height,
2847
2891
  maxWidth,
2848
2892
  maxHeight,
2849
2893
  scrollContainerRef,
2894
+ style: {
2895
+ ...!withoutArrow && centerArrowToTrigger && getCenteredPortalShiftStyle({ portalPlacement, triggerRef })
2896
+ },
2850
2897
  children: /* @__PURE__ */ jsxRuntime.jsx(
2851
2898
  TooltipContent,
2852
2899
  {
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,22 @@ 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;
881
+ };
882
+
883
+ declare type TUseDatePickerMultiSelectOptions = {
884
+ firstDayOfWeek?: number;
885
+ initialFirstSelectedDate?: Date | null;
886
+ initialSecondSelectedDate?: Date | null;
887
+ };
888
+
889
+ declare type TUseDatePickerSelectOptions = {
890
+ initialSelectedDate?: Date | null;
887
891
  };
888
892
 
889
893
  declare type TWithRef<TProps, TElement = HTMLElement> = TProps & {
@@ -910,10 +914,13 @@ export declare function useDatePickerControls(initialDate?: Date): {
910
914
  * Manages date range selection state for DatePicker.
911
915
  * Handles two-date selection with automatic ordering and visual range styling.
912
916
  *
913
- * @param firstDayOfWeek - First day of the week (0 = Sunday, 1 = Monday, etc.)
917
+ * @param options - Hook options for range selection
918
+ * @param options.firstDayOfWeek - First day of the week (0 = Sunday, 1 = Monday, etc.)
919
+ * @param options.initialFirstSelectedDate - Initial start date for range selection
920
+ * @param options.initialSecondSelectedDate - Initial end date for range selection
914
921
  * @returns Object containing selected dates, setters, and cell props generator with range styling
915
922
  */
916
- export declare function useDatePickerMultiSelect(firstDayOfWeek?: number): {
923
+ export declare function useDatePickerMultiSelect({ firstDayOfWeek, initialFirstSelectedDate, initialSecondSelectedDate, }?: TUseDatePickerMultiSelectOptions): {
917
924
  firstSelectedDate: Date | null;
918
925
  secondSelectedDate: Date | null;
919
926
  setFirstSelectedDate: Dispatch<SetStateAction<Date | null>>;
@@ -925,9 +932,11 @@ export declare function useDatePickerMultiSelect(firstDayOfWeek?: number): {
925
932
  * Manages single date selection state for DatePicker.
926
933
  * Provides cell props with selection logic and state management.
927
934
  *
935
+ * @param options - Hook options for initial selection state
936
+ * @param options.initialSelectedDate - Initial selected date
928
937
  * @returns Object containing selected date, setter, and cell props generator
929
938
  */
930
- export declare function useDatePickerSelect(): {
939
+ export declare function useDatePickerSelect({ initialSelectedDate }?: TUseDatePickerSelectOptions): {
931
940
  selectedDate: Date | null;
932
941
  setSelectedDate: Dispatch<SetStateAction<Date | null>>;
933
942
  getCellProps: (day: TCalendarDay) => Pick<ComponentProps<typeof DatePickerCell>, "onClick" | "disabled" | "isCurrent" | "state">;
package/dist/index.js CHANGED
@@ -1317,6 +1317,19 @@ function getCalendarGrid(month, year, firstDayOfWeek) {
1317
1317
  );
1318
1318
  }
1319
1319
 
1320
+ function normalizeDateRange(firstDate, secondDate) {
1321
+ if (!firstDate || !secondDate) {
1322
+ return { firstDate, secondDate };
1323
+ }
1324
+ if (firstDate.getTime() <= secondDate.getTime()) {
1325
+ return { firstDate, secondDate };
1326
+ }
1327
+ return {
1328
+ firstDate: secondDate,
1329
+ secondDate: firstDate
1330
+ };
1331
+ }
1332
+
1320
1333
  const datePickerField = "_datePickerField_1qk8s_2";
1321
1334
  const datePickerFieldCalendar = "_datePickerFieldCalendar_1qk8s_8";
1322
1335
  const datePickerFieldWeek = "_datePickerFieldWeek_1qk8s_14";
@@ -1422,9 +1435,14 @@ function useDatePickerControls(initialDate = /* @__PURE__ */ new Date()) {
1422
1435
  };
1423
1436
  }
1424
1437
 
1425
- function useDatePickerMultiSelect(firstDayOfWeek = LOCALE_FIRST_DAY_OF_WEEK.ru) {
1426
- const [firstSelectedDate, setFirstSelectedDate] = useState(null);
1427
- const [secondSelectedDate, setSecondSelectedDate] = useState(null);
1438
+ function useDatePickerMultiSelect({
1439
+ firstDayOfWeek = LOCALE_FIRST_DAY_OF_WEEK.ru,
1440
+ initialFirstSelectedDate = null,
1441
+ initialSecondSelectedDate = null
1442
+ } = {}) {
1443
+ const normalizedRange = normalizeDateRange(initialFirstSelectedDate, initialSecondSelectedDate);
1444
+ const [firstSelectedDate, setFirstSelectedDate] = useState(normalizedRange.firstDate);
1445
+ const [secondSelectedDate, setSecondSelectedDate] = useState(normalizedRange.secondDate);
1428
1446
  const lastDayOfWeek = (firstDayOfWeek + 6) % 7;
1429
1447
  const dayInfoCache = useMemo(() => /* @__PURE__ */ new Map(), []);
1430
1448
  const getDayInfo = useCallback(
@@ -1540,8 +1558,8 @@ function useDatePickerMultiSelect(firstDayOfWeek = LOCALE_FIRST_DAY_OF_WEEK.ru)
1540
1558
  return { firstSelectedDate, secondSelectedDate, setFirstSelectedDate, setSecondSelectedDate, getCellProps };
1541
1559
  }
1542
1560
 
1543
- function useDatePickerSelect() {
1544
- const [selectedDate, setSelectedDate] = useState(null);
1561
+ function useDatePickerSelect({ initialSelectedDate = null } = {}) {
1562
+ const [selectedDate, setSelectedDate] = useState(initialSelectedDate);
1545
1563
  const getCellProps = useCallback(
1546
1564
  (day) => {
1547
1565
  return {
@@ -1680,7 +1698,7 @@ function DropdownMenuProvider({ children }) {
1680
1698
  portalPlacement,
1681
1699
  setPortalPlacement
1682
1700
  },
1683
- children: typeof children === "function" ? children({ isOpen, setIsOpen, portalPlacement }) : children
1701
+ children: typeof children === "function" ? children({ isOpen, setIsOpen, portalPlacement, triggerRef }) : children
1684
1702
  }
1685
1703
  );
1686
1704
  }
@@ -2064,6 +2082,7 @@ const styles$g = {
2064
2082
  function DropdownPortal({
2065
2083
  children,
2066
2084
  className,
2085
+ style,
2067
2086
  align = "start",
2068
2087
  position = "bottom",
2069
2088
  isNested,
@@ -2092,7 +2111,8 @@ function DropdownPortal({
2092
2111
  style: {
2093
2112
  ...portalPosition,
2094
2113
  ...maxWidth && { "--dropdown-portal-max-width": `${maxWidth + offset}px` },
2095
- ...maxHeight && { "--dropdown-portal-max-height": `${maxHeight + offset}px` }
2114
+ ...maxHeight && { "--dropdown-portal-max-height": `${maxHeight + offset}px` },
2115
+ ...style
2096
2116
  },
2097
2117
  ref: portalRef,
2098
2118
  className: classNames(styles$g.dropdownPortal, className),
@@ -2780,8 +2800,15 @@ function Tag({ children, className, size = "md", mode = "primary", disabled, ...
2780
2800
  );
2781
2801
  }
2782
2802
 
2783
- const tooltipContent = "_tooltipContent_1267q_2";
2784
- const tooltipTitle = "_tooltipTitle_1267q_96";
2803
+ const TOOLTIP_CONTENT_ARROW = {
2804
+ width: 16,
2805
+ height: 8,
2806
+ offsetInline: 12,
2807
+ offsetBlock: 10
2808
+ };
2809
+
2810
+ const tooltipContent = "_tooltipContent_ww0bo_2";
2811
+ const tooltipTitle = "_tooltipTitle_ww0bo_92";
2785
2812
  const styles = {
2786
2813
  tooltipContent: tooltipContent,
2787
2814
  tooltipTitle: tooltipTitle
@@ -2794,7 +2821,6 @@ function TooltipContent({
2794
2821
  description,
2795
2822
  arrowAlign,
2796
2823
  arrowPosition,
2797
- arrowOffset,
2798
2824
  ...props
2799
2825
  }) {
2800
2826
  return /* @__PURE__ */ jsxs(
@@ -2804,11 +2830,11 @@ function TooltipContent({
2804
2830
  role: role ?? "tooltip",
2805
2831
  "data-align": arrowAlign,
2806
2832
  "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
- }
2833
+ style: {
2834
+ "--tooltip-content-arrow-width": `${TOOLTIP_CONTENT_ARROW.width}px`,
2835
+ "--tooltip-content-arrow-height": `${TOOLTIP_CONTENT_ARROW.height}px`,
2836
+ "--tooltip-content-arrow-offset-inline": `${TOOLTIP_CONTENT_ARROW.offsetInline}px`,
2837
+ "--tooltip-content-arrow-offset-block": `${TOOLTIP_CONTENT_ARROW.offsetBlock}px`
2812
2838
  },
2813
2839
  ...props,
2814
2840
  children: [
@@ -2819,7 +2845,24 @@ function TooltipContent({
2819
2845
  );
2820
2846
  }
2821
2847
 
2822
- const TOOLTIP_OFFSET = 8;
2848
+ function getCenteredPortalShiftStyle({
2849
+ portalPlacement,
2850
+ triggerRef
2851
+ }) {
2852
+ const triggerRect = triggerRef.current?.getBoundingClientRect();
2853
+ if (!triggerRect || !portalPlacement || portalPlacement.align === "center") {
2854
+ return {};
2855
+ }
2856
+ const isHorizontal = portalPlacement.position === "top" || portalPlacement.position === "bottom";
2857
+ const triggerHalfSize = isHorizontal ? triggerRect.width / 2 : triggerRect.height / 2;
2858
+ const arrowOffset = (isHorizontal ? TOOLTIP_CONTENT_ARROW.offsetInline : TOOLTIP_CONTENT_ARROW.offsetBlock) + TOOLTIP_CONTENT_ARROW.height * Math.SQRT2 / 2;
2859
+ const shift = portalPlacement.align === "start" ? triggerHalfSize - arrowOffset : arrowOffset - triggerHalfSize;
2860
+ const shiftPx = `${Number(shift.toFixed(3))}px`;
2861
+ if (isHorizontal) {
2862
+ return { marginLeft: shiftPx };
2863
+ }
2864
+ return { marginTop: shiftPx };
2865
+ }
2823
2866
 
2824
2867
  function TooltipRoot({
2825
2868
  children,
@@ -2830,19 +2873,23 @@ function TooltipRoot({
2830
2873
  maxHeight,
2831
2874
  withoutArrow = false,
2832
2875
  scrollContainerRef,
2876
+ centerArrowToTrigger = true,
2833
2877
  ...tooltipContentProps
2834
2878
  }) {
2835
- return /* @__PURE__ */ jsx(DropdownMenu.Root, { children: ({ portalPlacement }) => /* @__PURE__ */ jsxs(Fragment$1, { children: [
2879
+ return /* @__PURE__ */ jsx(DropdownMenu.Root, { children: ({ portalPlacement, triggerRef }) => /* @__PURE__ */ jsxs(Fragment$1, { children: [
2836
2880
  /* @__PURE__ */ jsx(DropdownMenu.Trigger, { asChild: true, triggerEvent, children }),
2837
2881
  /* @__PURE__ */ jsx(
2838
2882
  DropdownMenu.Portal,
2839
2883
  {
2840
2884
  align,
2841
2885
  position,
2842
- offset: TOOLTIP_OFFSET,
2886
+ offset: TOOLTIP_CONTENT_ARROW.height,
2843
2887
  maxWidth,
2844
2888
  maxHeight,
2845
2889
  scrollContainerRef,
2890
+ style: {
2891
+ ...!withoutArrow && centerArrowToTrigger && getCenteredPortalShiftStyle({ portalPlacement, triggerRef })
2892
+ },
2846
2893
  children: /* @__PURE__ */ jsx(
2847
2894
  TooltipContent,
2848
2895
  {
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.11",
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",