@mieweb/ui 0.5.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 +114 -9
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +41 -3
- package/dist/index.d.ts +41 -3
- package/dist/index.js +112 -10
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -3869,7 +3869,7 @@ var MessageBubble = React48__namespace.forwardRef(
|
|
|
3869
3869
|
"div",
|
|
3870
3870
|
{
|
|
3871
3871
|
className: chunkOR5DRJCW_cjs.cn(
|
|
3872
|
-
"flex flex-col",
|
|
3872
|
+
"flex flex-1 flex-col min-w-0",
|
|
3873
3873
|
isOutgoing ? "items-end" : "items-start"
|
|
3874
3874
|
),
|
|
3875
3875
|
children: [
|
|
@@ -11463,32 +11463,103 @@ function getDefaultPresets(labels = {}) {
|
|
|
11463
11463
|
{ key: "last-30-days", label: last30Days }
|
|
11464
11464
|
];
|
|
11465
11465
|
}
|
|
11466
|
+
function getExtendedPresets(labels = {}) {
|
|
11467
|
+
const {
|
|
11468
|
+
today = "Today",
|
|
11469
|
+
yesterday = "Yesterday",
|
|
11470
|
+
thisWeek = "This Week",
|
|
11471
|
+
lastWeek = "Last Week",
|
|
11472
|
+
thisMonth = "This Month",
|
|
11473
|
+
lastMonth = "Last Month",
|
|
11474
|
+
thisQuarter = "This Quarter",
|
|
11475
|
+
lastQuarter = "Last Quarter",
|
|
11476
|
+
thisYear = "This Year",
|
|
11477
|
+
lastYear = "Last Year",
|
|
11478
|
+
last24Hours = "Last 24 Hours",
|
|
11479
|
+
last7Days = "Last 7 Days",
|
|
11480
|
+
last30Days = "Last 30 Days",
|
|
11481
|
+
last90Days = "Last 90 Days",
|
|
11482
|
+
last365Days = "Last 365 Days"
|
|
11483
|
+
} = labels;
|
|
11484
|
+
return [
|
|
11485
|
+
{ key: "today", label: today },
|
|
11486
|
+
{ key: "yesterday", label: yesterday },
|
|
11487
|
+
{ key: "last-24-hours", label: last24Hours },
|
|
11488
|
+
{ key: "this-week", label: thisWeek },
|
|
11489
|
+
{ key: "last-week", label: lastWeek },
|
|
11490
|
+
{ key: "last-7-days", label: last7Days },
|
|
11491
|
+
{ key: "this-month", label: thisMonth },
|
|
11492
|
+
{ key: "last-month", label: lastMonth },
|
|
11493
|
+
{ key: "last-30-days", label: last30Days },
|
|
11494
|
+
{ key: "this-quarter", label: thisQuarter },
|
|
11495
|
+
{ key: "last-quarter", label: lastQuarter },
|
|
11496
|
+
{ key: "last-90-days", label: last90Days },
|
|
11497
|
+
{ key: "this-year", label: thisYear },
|
|
11498
|
+
{ key: "last-year", label: lastYear },
|
|
11499
|
+
{ key: "last-365-days", label: last365Days }
|
|
11500
|
+
];
|
|
11501
|
+
}
|
|
11502
|
+
function endOfDay(d) {
|
|
11503
|
+
return new Date(d.getFullYear(), d.getMonth(), d.getDate(), 23, 59, 59, 999);
|
|
11504
|
+
}
|
|
11466
11505
|
function calculateDateRange(presetKey) {
|
|
11467
11506
|
const now = /* @__PURE__ */ new Date();
|
|
11468
11507
|
const today = new Date(now.getFullYear(), now.getMonth(), now.getDate());
|
|
11469
11508
|
switch (presetKey) {
|
|
11470
11509
|
case "today":
|
|
11471
|
-
return {
|
|
11472
|
-
|
|
11473
|
-
|
|
11474
|
-
|
|
11510
|
+
return { start: today, end: endOfDay(today) };
|
|
11511
|
+
case "yesterday": {
|
|
11512
|
+
const yesterday = new Date(today);
|
|
11513
|
+
yesterday.setDate(today.getDate() - 1);
|
|
11514
|
+
return { start: yesterday, end: endOfDay(yesterday) };
|
|
11515
|
+
}
|
|
11475
11516
|
case "this-week": {
|
|
11476
11517
|
const dayOfWeek = today.getDay();
|
|
11477
11518
|
const sunday = new Date(today);
|
|
11478
11519
|
sunday.setDate(today.getDate() - dayOfWeek);
|
|
11479
11520
|
const saturday = new Date(sunday);
|
|
11480
11521
|
saturday.setDate(sunday.getDate() + 6);
|
|
11481
|
-
return { start: sunday, end: saturday };
|
|
11522
|
+
return { start: sunday, end: endOfDay(saturday) };
|
|
11523
|
+
}
|
|
11524
|
+
case "last-week": {
|
|
11525
|
+
const dayOfWeek = today.getDay();
|
|
11526
|
+
const lastSunday = new Date(today);
|
|
11527
|
+
lastSunday.setDate(today.getDate() - dayOfWeek - 7);
|
|
11528
|
+
const lastSaturday = new Date(lastSunday);
|
|
11529
|
+
lastSaturday.setDate(lastSunday.getDate() + 6);
|
|
11530
|
+
return { start: lastSunday, end: endOfDay(lastSaturday) };
|
|
11482
11531
|
}
|
|
11483
11532
|
case "this-month": {
|
|
11484
11533
|
const firstDay = new Date(now.getFullYear(), now.getMonth(), 1);
|
|
11485
11534
|
const lastDay = new Date(now.getFullYear(), now.getMonth() + 1, 0);
|
|
11486
|
-
return { start: firstDay, end: lastDay };
|
|
11535
|
+
return { start: firstDay, end: endOfDay(lastDay) };
|
|
11487
11536
|
}
|
|
11488
11537
|
case "last-month": {
|
|
11489
11538
|
const firstDay = new Date(now.getFullYear(), now.getMonth() - 1, 1);
|
|
11490
11539
|
const lastDay = new Date(now.getFullYear(), now.getMonth(), 0);
|
|
11491
|
-
return { start: firstDay, end: lastDay };
|
|
11540
|
+
return { start: firstDay, end: endOfDay(lastDay) };
|
|
11541
|
+
}
|
|
11542
|
+
case "this-quarter": {
|
|
11543
|
+
const quarter = Math.floor(now.getMonth() / 3);
|
|
11544
|
+
const firstDay = new Date(now.getFullYear(), quarter * 3, 1);
|
|
11545
|
+
const lastDay = new Date(now.getFullYear(), quarter * 3 + 3, 0);
|
|
11546
|
+
return { start: firstDay, end: endOfDay(lastDay) };
|
|
11547
|
+
}
|
|
11548
|
+
case "last-quarter": {
|
|
11549
|
+
const quarter = Math.floor(now.getMonth() / 3);
|
|
11550
|
+
const firstDay = new Date(now.getFullYear(), (quarter - 1) * 3, 1);
|
|
11551
|
+
const lastDay = new Date(now.getFullYear(), quarter * 3, 0);
|
|
11552
|
+
return { start: firstDay, end: endOfDay(lastDay) };
|
|
11553
|
+
}
|
|
11554
|
+
case "this-year": {
|
|
11555
|
+
const firstDay = new Date(now.getFullYear(), 0, 1);
|
|
11556
|
+
const lastDay = new Date(now.getFullYear(), 11, 31);
|
|
11557
|
+
return { start: firstDay, end: endOfDay(lastDay) };
|
|
11558
|
+
}
|
|
11559
|
+
case "last-year": {
|
|
11560
|
+
const firstDay = new Date(now.getFullYear() - 1, 0, 1);
|
|
11561
|
+
const lastDay = new Date(now.getFullYear() - 1, 11, 31);
|
|
11562
|
+
return { start: firstDay, end: endOfDay(lastDay) };
|
|
11492
11563
|
}
|
|
11493
11564
|
case "last-24-hours":
|
|
11494
11565
|
return {
|
|
@@ -11505,6 +11576,16 @@ function calculateDateRange(presetKey) {
|
|
|
11505
11576
|
start: new Date(now.getTime() - 30 * 24 * 60 * 60 * 1e3),
|
|
11506
11577
|
end: now
|
|
11507
11578
|
};
|
|
11579
|
+
case "last-90-days":
|
|
11580
|
+
return {
|
|
11581
|
+
start: new Date(now.getTime() - 90 * 24 * 60 * 60 * 1e3),
|
|
11582
|
+
end: now
|
|
11583
|
+
};
|
|
11584
|
+
case "last-365-days":
|
|
11585
|
+
return {
|
|
11586
|
+
start: new Date(now.getTime() - 365 * 24 * 60 * 60 * 1e3),
|
|
11587
|
+
end: now
|
|
11588
|
+
};
|
|
11508
11589
|
default:
|
|
11509
11590
|
return { start: null, end: null };
|
|
11510
11591
|
}
|
|
@@ -11531,6 +11612,7 @@ function DateRangePicker({
|
|
|
11531
11612
|
activePreset,
|
|
11532
11613
|
placeholder = "Pick a date range",
|
|
11533
11614
|
className,
|
|
11615
|
+
align = "auto",
|
|
11534
11616
|
showPresets = true,
|
|
11535
11617
|
variant = "desktop",
|
|
11536
11618
|
labels = {}
|
|
@@ -11553,6 +11635,9 @@ function DateRangePicker({
|
|
|
11553
11635
|
const [hoverDate, setHoverDate] = React48__namespace.useState(null);
|
|
11554
11636
|
const calendarRef = React48__namespace.useRef(null);
|
|
11555
11637
|
const triggerRef = React48__namespace.useRef(null);
|
|
11638
|
+
const [resolvedAlign, setResolvedAlign] = React48__namespace.useState(
|
|
11639
|
+
align === "end" ? "end" : "start"
|
|
11640
|
+
);
|
|
11556
11641
|
const isMobileVariant = variant === "mobile";
|
|
11557
11642
|
const isResponsive = variant === "responsive";
|
|
11558
11643
|
const focusTrapRef = chunkNNEFAUHV_cjs.useFocusTrap(
|
|
@@ -11591,6 +11676,22 @@ function DateRangePicker({
|
|
|
11591
11676
|
};
|
|
11592
11677
|
}
|
|
11593
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]);
|
|
11594
11695
|
const handlePresetSelect = (presetKey) => {
|
|
11595
11696
|
const range = calculateDateRange(presetKey);
|
|
11596
11697
|
setRangeStart(range.start);
|
|
@@ -11930,7 +12031,8 @@ function DateRangePicker({
|
|
|
11930
12031
|
{
|
|
11931
12032
|
ref: calendarRef,
|
|
11932
12033
|
className: chunkOR5DRJCW_cjs.cn(
|
|
11933
|
-
"absolute top-full
|
|
12034
|
+
"absolute top-full z-50 mt-1",
|
|
12035
|
+
resolvedAlign === "end" ? "right-0" : "left-0",
|
|
11934
12036
|
"bg-background border-border rounded-lg border shadow-lg"
|
|
11935
12037
|
),
|
|
11936
12038
|
role: "dialog",
|
|
@@ -40238,6 +40340,7 @@ exports.WebcamModal = WebcamModal;
|
|
|
40238
40340
|
exports.WebsiteInput = WebsiteInput;
|
|
40239
40341
|
exports.WebsiteInputGroup = WebsiteInputGroup;
|
|
40240
40342
|
exports.bubbleVariants = bubbleVariants2;
|
|
40343
|
+
exports.calculateDateRange = calculateDateRange;
|
|
40241
40344
|
exports.countBadgeVariants = countBadgeVariants;
|
|
40242
40345
|
exports.countChipVariants = countChipVariants;
|
|
40243
40346
|
exports.create24HourSchedule = create24HourSchedule;
|
|
@@ -40255,6 +40358,8 @@ exports.generateAttachmentId = generateAttachmentId;
|
|
|
40255
40358
|
exports.generateId = generateId;
|
|
40256
40359
|
exports.getConversationSubtitle = getConversationSubtitle;
|
|
40257
40360
|
exports.getConversationTitle = getConversationTitle;
|
|
40361
|
+
exports.getDefaultPresets = getDefaultPresets;
|
|
40362
|
+
exports.getExtendedPresets = getExtendedPresets;
|
|
40258
40363
|
exports.getFileType = getFileType;
|
|
40259
40364
|
exports.getGoogleMapsSearchUrl = getGoogleMapsSearchUrl;
|
|
40260
40365
|
exports.getGoogleMapsUrl = getGoogleMapsUrl;
|