@mieweb/ui 0.6.0 → 0.6.1

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
@@ -11612,6 +11612,7 @@ function DateRangePicker({
11612
11612
  activePreset,
11613
11613
  placeholder = "Pick a date range",
11614
11614
  className,
11615
+ align = "auto",
11615
11616
  showPresets = true,
11616
11617
  variant = "desktop",
11617
11618
  labels = {}
@@ -11634,6 +11635,9 @@ function DateRangePicker({
11634
11635
  const [hoverDate, setHoverDate] = React48__namespace.useState(null);
11635
11636
  const calendarRef = React48__namespace.useRef(null);
11636
11637
  const triggerRef = React48__namespace.useRef(null);
11638
+ const [resolvedAlign, setResolvedAlign] = React48__namespace.useState(
11639
+ align === "end" ? "end" : "start"
11640
+ );
11637
11641
  const isMobileVariant = variant === "mobile";
11638
11642
  const isResponsive = variant === "responsive";
11639
11643
  const focusTrapRef = chunkNNEFAUHV_cjs.useFocusTrap(
@@ -11672,6 +11676,22 @@ function DateRangePicker({
11672
11676
  };
11673
11677
  }
11674
11678
  }, [isMobileVariant, isCalendarOpen]);
11679
+ React48__namespace.useLayoutEffect(() => {
11680
+ if (isMobileVariant || !isCalendarOpen) return;
11681
+ if (align === "start" || align === "end") {
11682
+ setResolvedAlign(align);
11683
+ return;
11684
+ }
11685
+ if (typeof window === "undefined") return;
11686
+ const trigger = triggerRef.current;
11687
+ if (!trigger) return;
11688
+ const rect = trigger.getBoundingClientRect();
11689
+ const estimatedPopupWidth = showPresets ? 840 : 640;
11690
+ const margin = 8;
11691
+ const overflowsRight = rect.left + estimatedPopupWidth > window.innerWidth - margin;
11692
+ const fitsLeftAligned = rect.right - estimatedPopupWidth >= margin;
11693
+ setResolvedAlign(overflowsRight && fitsLeftAligned ? "end" : "start");
11694
+ }, [align, isCalendarOpen, isMobileVariant, showPresets]);
11675
11695
  const handlePresetSelect = (presetKey) => {
11676
11696
  const range = calculateDateRange(presetKey);
11677
11697
  setRangeStart(range.start);
@@ -12011,7 +12031,8 @@ function DateRangePicker({
12011
12031
  {
12012
12032
  ref: calendarRef,
12013
12033
  className: chunkOR5DRJCW_cjs.cn(
12014
- "absolute top-full left-0 z-50 mt-1",
12034
+ "absolute top-full z-50 mt-1",
12035
+ resolvedAlign === "end" ? "right-0" : "left-0",
12015
12036
  "bg-background border-border rounded-lg border shadow-lg"
12016
12037
  ),
12017
12038
  role: "dialog",