@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 +22 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +10 -1
- package/dist/index.d.ts +10 -1
- package/dist/index.js +22 -1
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.cts
CHANGED
|
@@ -2410,6 +2410,15 @@ interface DateRangePickerProps {
|
|
|
2410
2410
|
placeholder?: string;
|
|
2411
2411
|
/** Custom className */
|
|
2412
2412
|
className?: string;
|
|
2413
|
+
/**
|
|
2414
|
+
* Horizontal alignment of the desktop popup relative to the trigger.
|
|
2415
|
+
* - `'start'` (default historical behavior): popup left edge aligns with trigger left edge.
|
|
2416
|
+
* - `'end'`: popup right edge aligns with trigger right edge.
|
|
2417
|
+
* - `'auto'`: starts as `'start'`, then automatically flips to `'end'` if the popup
|
|
2418
|
+
* would overflow the right edge of the viewport. Recommended for triggers placed
|
|
2419
|
+
* in the right side of a layout (e.g. page header action slots).
|
|
2420
|
+
*/
|
|
2421
|
+
align?: 'start' | 'end' | 'auto';
|
|
2413
2422
|
/** Whether to show the preset sidebar in the calendar popup (default: true) */
|
|
2414
2423
|
showPresets?: boolean;
|
|
2415
2424
|
/** Display variant: desktop (default), mobile (bottom sheet), or responsive (auto-adapts at md breakpoint) */
|
|
@@ -2471,7 +2480,7 @@ declare function calculateDateRange(presetKey: string): DateRange$1;
|
|
|
2471
2480
|
* />
|
|
2472
2481
|
* ```
|
|
2473
2482
|
*/
|
|
2474
|
-
declare function DateRangePicker({ value, onChange, presets, activePreset, placeholder, className, showPresets, variant, labels, }: DateRangePickerProps): react_jsx_runtime.JSX.Element;
|
|
2483
|
+
declare function DateRangePicker({ value, onChange, presets, activePreset, placeholder, className, align, showPresets, variant, labels, }: DateRangePickerProps): react_jsx_runtime.JSX.Element;
|
|
2475
2484
|
interface DateRangeFilterProps {
|
|
2476
2485
|
/** Current date range value */
|
|
2477
2486
|
value?: DateRange$1;
|
package/dist/index.d.ts
CHANGED
|
@@ -2410,6 +2410,15 @@ interface DateRangePickerProps {
|
|
|
2410
2410
|
placeholder?: string;
|
|
2411
2411
|
/** Custom className */
|
|
2412
2412
|
className?: string;
|
|
2413
|
+
/**
|
|
2414
|
+
* Horizontal alignment of the desktop popup relative to the trigger.
|
|
2415
|
+
* - `'start'` (default historical behavior): popup left edge aligns with trigger left edge.
|
|
2416
|
+
* - `'end'`: popup right edge aligns with trigger right edge.
|
|
2417
|
+
* - `'auto'`: starts as `'start'`, then automatically flips to `'end'` if the popup
|
|
2418
|
+
* would overflow the right edge of the viewport. Recommended for triggers placed
|
|
2419
|
+
* in the right side of a layout (e.g. page header action slots).
|
|
2420
|
+
*/
|
|
2421
|
+
align?: 'start' | 'end' | 'auto';
|
|
2413
2422
|
/** Whether to show the preset sidebar in the calendar popup (default: true) */
|
|
2414
2423
|
showPresets?: boolean;
|
|
2415
2424
|
/** Display variant: desktop (default), mobile (bottom sheet), or responsive (auto-adapts at md breakpoint) */
|
|
@@ -2471,7 +2480,7 @@ declare function calculateDateRange(presetKey: string): DateRange$1;
|
|
|
2471
2480
|
* />
|
|
2472
2481
|
* ```
|
|
2473
2482
|
*/
|
|
2474
|
-
declare function DateRangePicker({ value, onChange, presets, activePreset, placeholder, className, showPresets, variant, labels, }: DateRangePickerProps): react_jsx_runtime.JSX.Element;
|
|
2483
|
+
declare function DateRangePicker({ value, onChange, presets, activePreset, placeholder, className, align, showPresets, variant, labels, }: DateRangePickerProps): react_jsx_runtime.JSX.Element;
|
|
2475
2484
|
interface DateRangeFilterProps {
|
|
2476
2485
|
/** Current date range value */
|
|
2477
2486
|
value?: DateRange$1;
|
package/dist/index.js
CHANGED
|
@@ -11619,6 +11619,7 @@ function DateRangePicker({
|
|
|
11619
11619
|
activePreset,
|
|
11620
11620
|
placeholder = "Pick a date range",
|
|
11621
11621
|
className,
|
|
11622
|
+
align = "auto",
|
|
11622
11623
|
showPresets = true,
|
|
11623
11624
|
variant = "desktop",
|
|
11624
11625
|
labels = {}
|
|
@@ -11641,6 +11642,9 @@ function DateRangePicker({
|
|
|
11641
11642
|
const [hoverDate, setHoverDate] = React48.useState(null);
|
|
11642
11643
|
const calendarRef = React48.useRef(null);
|
|
11643
11644
|
const triggerRef = React48.useRef(null);
|
|
11645
|
+
const [resolvedAlign, setResolvedAlign] = React48.useState(
|
|
11646
|
+
align === "end" ? "end" : "start"
|
|
11647
|
+
);
|
|
11644
11648
|
const isMobileVariant = variant === "mobile";
|
|
11645
11649
|
const isResponsive = variant === "responsive";
|
|
11646
11650
|
const focusTrapRef = useFocusTrap(
|
|
@@ -11679,6 +11683,22 @@ function DateRangePicker({
|
|
|
11679
11683
|
};
|
|
11680
11684
|
}
|
|
11681
11685
|
}, [isMobileVariant, isCalendarOpen]);
|
|
11686
|
+
React48.useLayoutEffect(() => {
|
|
11687
|
+
if (isMobileVariant || !isCalendarOpen) return;
|
|
11688
|
+
if (align === "start" || align === "end") {
|
|
11689
|
+
setResolvedAlign(align);
|
|
11690
|
+
return;
|
|
11691
|
+
}
|
|
11692
|
+
if (typeof window === "undefined") return;
|
|
11693
|
+
const trigger = triggerRef.current;
|
|
11694
|
+
if (!trigger) return;
|
|
11695
|
+
const rect = trigger.getBoundingClientRect();
|
|
11696
|
+
const estimatedPopupWidth = showPresets ? 840 : 640;
|
|
11697
|
+
const margin = 8;
|
|
11698
|
+
const overflowsRight = rect.left + estimatedPopupWidth > window.innerWidth - margin;
|
|
11699
|
+
const fitsLeftAligned = rect.right - estimatedPopupWidth >= margin;
|
|
11700
|
+
setResolvedAlign(overflowsRight && fitsLeftAligned ? "end" : "start");
|
|
11701
|
+
}, [align, isCalendarOpen, isMobileVariant, showPresets]);
|
|
11682
11702
|
const handlePresetSelect = (presetKey) => {
|
|
11683
11703
|
const range = calculateDateRange(presetKey);
|
|
11684
11704
|
setRangeStart(range.start);
|
|
@@ -12018,7 +12038,8 @@ function DateRangePicker({
|
|
|
12018
12038
|
{
|
|
12019
12039
|
ref: calendarRef,
|
|
12020
12040
|
className: cn(
|
|
12021
|
-
"absolute top-full
|
|
12041
|
+
"absolute top-full z-50 mt-1",
|
|
12042
|
+
resolvedAlign === "end" ? "right-0" : "left-0",
|
|
12022
12043
|
"bg-background border-border rounded-lg border shadow-lg"
|
|
12023
12044
|
),
|
|
12024
12045
|
role: "dialog",
|