@underverse-ui/underverse 1.0.130 → 1.0.131
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/api-reference.json +1 -1
- package/dist/index.cjs +353 -39
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +7 -1
- package/dist/index.d.ts +7 -1
- package/dist/index.js +353 -39
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/api-reference.json
CHANGED
package/dist/index.cjs
CHANGED
|
@@ -8517,7 +8517,8 @@ __export(date_exports, {
|
|
|
8517
8517
|
formatTimeAgo: () => formatTimeAgo,
|
|
8518
8518
|
getDayOfWeek: () => getDayOfWeek,
|
|
8519
8519
|
isToday: () => isToday,
|
|
8520
|
-
isYesterday: () => isYesterday
|
|
8520
|
+
isYesterday: () => isYesterday,
|
|
8521
|
+
parseDateString: () => parseDateString
|
|
8521
8522
|
});
|
|
8522
8523
|
var localeMap = {
|
|
8523
8524
|
en: "en-US",
|
|
@@ -8716,6 +8717,44 @@ function formatDateSmart(date, locale = "en") {
|
|
|
8716
8717
|
}
|
|
8717
8718
|
return formatDateTime(date, locale);
|
|
8718
8719
|
}
|
|
8720
|
+
function parseDateString(str, locale = "en") {
|
|
8721
|
+
if (!str) return null;
|
|
8722
|
+
const cleaned = str.trim();
|
|
8723
|
+
if (!cleaned) return null;
|
|
8724
|
+
const parts = cleaned.split(/[\/\-\.\s]+/).filter(Boolean);
|
|
8725
|
+
if (parts.length !== 3) return null;
|
|
8726
|
+
let day = 0;
|
|
8727
|
+
let month = 0;
|
|
8728
|
+
let year = 0;
|
|
8729
|
+
if (locale === "vi") {
|
|
8730
|
+
day = parseInt(parts[0], 10);
|
|
8731
|
+
month = parseInt(parts[1], 10);
|
|
8732
|
+
year = parseInt(parts[2], 10);
|
|
8733
|
+
} else if (locale === "ja" || locale === "ko") {
|
|
8734
|
+
year = parseInt(parts[0], 10);
|
|
8735
|
+
month = parseInt(parts[1], 10);
|
|
8736
|
+
day = parseInt(parts[2], 10);
|
|
8737
|
+
} else {
|
|
8738
|
+
if (parts[0].length === 4) {
|
|
8739
|
+
year = parseInt(parts[0], 10);
|
|
8740
|
+
month = parseInt(parts[1], 10);
|
|
8741
|
+
day = parseInt(parts[2], 10);
|
|
8742
|
+
} else {
|
|
8743
|
+
month = parseInt(parts[0], 10);
|
|
8744
|
+
day = parseInt(parts[1], 10);
|
|
8745
|
+
year = parseInt(parts[2], 10);
|
|
8746
|
+
}
|
|
8747
|
+
}
|
|
8748
|
+
if (isNaN(day) || isNaN(month) || isNaN(year)) return null;
|
|
8749
|
+
if (year < 100) {
|
|
8750
|
+
year += year >= 50 ? 1900 : 2e3;
|
|
8751
|
+
}
|
|
8752
|
+
const parsedDate = new Date(year, month - 1, day);
|
|
8753
|
+
if (parsedDate.getFullYear() === year && parsedDate.getMonth() === month - 1 && parsedDate.getDate() === day) {
|
|
8754
|
+
return parsedDate;
|
|
8755
|
+
}
|
|
8756
|
+
return null;
|
|
8757
|
+
}
|
|
8719
8758
|
|
|
8720
8759
|
// src/components/DatePicker.tsx
|
|
8721
8760
|
var import_lucide_react15 = require("lucide-react");
|
|
@@ -8748,8 +8787,83 @@ var DatePicker = ({
|
|
|
8748
8787
|
const [viewMode, setViewMode] = React30.useState("calendar");
|
|
8749
8788
|
const [localRequiredError, setLocalRequiredError] = React30.useState();
|
|
8750
8789
|
const triggerRef = React30.useRef(null);
|
|
8790
|
+
const inputRef = React30.useRef(null);
|
|
8751
8791
|
const wheelContainerRef = React30.useRef(null);
|
|
8752
8792
|
const wheelDeltaRef = React30.useRef(0);
|
|
8793
|
+
const [isFocused, setIsFocused] = React30.useState(false);
|
|
8794
|
+
const [inputValue, setInputValue] = React30.useState("");
|
|
8795
|
+
React30.useEffect(() => {
|
|
8796
|
+
if (value) {
|
|
8797
|
+
const parsed = parseDateString(inputValue, locale);
|
|
8798
|
+
const isSame = parsed && parsed.getTime() === value.getTime();
|
|
8799
|
+
if (!isSame) {
|
|
8800
|
+
setInputValue(formatDateShort(value, locale));
|
|
8801
|
+
}
|
|
8802
|
+
} else if (!isFocused) {
|
|
8803
|
+
setInputValue("");
|
|
8804
|
+
}
|
|
8805
|
+
}, [value, locale, isFocused]);
|
|
8806
|
+
const handleInputChange = (e) => {
|
|
8807
|
+
const text = e.target.value;
|
|
8808
|
+
setInputValue(text);
|
|
8809
|
+
const parsedDate = parseDateString(text, locale);
|
|
8810
|
+
if (parsedDate) {
|
|
8811
|
+
if (!isDateDisabled(parsedDate)) {
|
|
8812
|
+
onChange(parsedDate);
|
|
8813
|
+
setViewDate(parsedDate);
|
|
8814
|
+
setLocalRequiredError(void 0);
|
|
8815
|
+
}
|
|
8816
|
+
}
|
|
8817
|
+
};
|
|
8818
|
+
const handleInputBlur = () => {
|
|
8819
|
+
setIsFocused(false);
|
|
8820
|
+
if (!inputValue.trim()) {
|
|
8821
|
+
if (required) {
|
|
8822
|
+
setLocalRequiredError(tv("required"));
|
|
8823
|
+
} else {
|
|
8824
|
+
onChange(void 0);
|
|
8825
|
+
setLocalRequiredError(void 0);
|
|
8826
|
+
}
|
|
8827
|
+
} else {
|
|
8828
|
+
const parsedDate = parseDateString(inputValue, locale);
|
|
8829
|
+
if (parsedDate && !isDateDisabled(parsedDate)) {
|
|
8830
|
+
onChange(parsedDate);
|
|
8831
|
+
setInputValue(formatDateShort(parsedDate, locale));
|
|
8832
|
+
setLocalRequiredError(void 0);
|
|
8833
|
+
} else {
|
|
8834
|
+
if (value) {
|
|
8835
|
+
setInputValue(formatDateShort(value, locale));
|
|
8836
|
+
setLocalRequiredError(void 0);
|
|
8837
|
+
} else {
|
|
8838
|
+
setInputValue("");
|
|
8839
|
+
if (required) {
|
|
8840
|
+
setLocalRequiredError(tv("required"));
|
|
8841
|
+
}
|
|
8842
|
+
}
|
|
8843
|
+
}
|
|
8844
|
+
}
|
|
8845
|
+
};
|
|
8846
|
+
const handleInputKeyDown = (e) => {
|
|
8847
|
+
if (e.key === "Enter") {
|
|
8848
|
+
e.preventDefault();
|
|
8849
|
+
const parsedDate = parseDateString(inputValue, locale);
|
|
8850
|
+
if (parsedDate && !isDateDisabled(parsedDate)) {
|
|
8851
|
+
onChange(parsedDate);
|
|
8852
|
+
setInputValue(formatDateShort(parsedDate, locale));
|
|
8853
|
+
setViewDate(parsedDate);
|
|
8854
|
+
setIsOpen(false);
|
|
8855
|
+
setLocalRequiredError(void 0);
|
|
8856
|
+
} else if (!inputValue.trim() && !required) {
|
|
8857
|
+
onChange(void 0);
|
|
8858
|
+
setIsOpen(false);
|
|
8859
|
+
setLocalRequiredError(void 0);
|
|
8860
|
+
} else {
|
|
8861
|
+
setIsOpen(false);
|
|
8862
|
+
}
|
|
8863
|
+
} else if (e.key === "Escape") {
|
|
8864
|
+
setIsOpen(false);
|
|
8865
|
+
}
|
|
8866
|
+
};
|
|
8753
8867
|
const normalizeToLocalDay = React30.useCallback((date) => {
|
|
8754
8868
|
if (!date) return null;
|
|
8755
8869
|
return new Date(date.getFullYear(), date.getMonth(), date.getDate());
|
|
@@ -9140,7 +9254,7 @@ var DatePicker = ({
|
|
|
9140
9254
|
{
|
|
9141
9255
|
id: labelId,
|
|
9142
9256
|
htmlFor: resolvedId,
|
|
9143
|
-
onClick: () =>
|
|
9257
|
+
onClick: () => inputRef.current?.focus(),
|
|
9144
9258
|
className: cn(
|
|
9145
9259
|
labelSize,
|
|
9146
9260
|
"font-semibold transition-colors duration-300 cursor-pointer",
|
|
@@ -9189,12 +9303,12 @@ var DatePicker = ({
|
|
|
9189
9303
|
"animate-in fade-in-0 zoom-in-95 slide-in-from-top-2 duration-300"
|
|
9190
9304
|
),
|
|
9191
9305
|
trigger: /* @__PURE__ */ (0, import_jsx_runtime35.jsxs)(
|
|
9192
|
-
"
|
|
9306
|
+
"div",
|
|
9193
9307
|
{
|
|
9194
9308
|
ref: triggerRef,
|
|
9195
|
-
type: "button",
|
|
9196
|
-
disabled,
|
|
9197
9309
|
id: resolvedId,
|
|
9310
|
+
role: "button",
|
|
9311
|
+
"aria-label": value ? formatDateDisplay(value) : placeholder || t("placeholder"),
|
|
9198
9312
|
"aria-labelledby": labelId,
|
|
9199
9313
|
"aria-required": required,
|
|
9200
9314
|
"aria-invalid": !!effectiveError,
|
|
@@ -9202,17 +9316,18 @@ var DatePicker = ({
|
|
|
9202
9316
|
"group flex w-full items-center justify-between border bg-background/80 backdrop-blur-sm",
|
|
9203
9317
|
"rounded-full",
|
|
9204
9318
|
sizeStyles8[size].trigger,
|
|
9205
|
-
"border-border/
|
|
9206
|
-
|
|
9207
|
-
|
|
9208
|
-
|
|
9319
|
+
disabled ? "border-border/40 opacity-50 cursor-not-allowed" : [
|
|
9320
|
+
"border-border/60 hover:border-primary/40",
|
|
9321
|
+
"focus-within:ring-2 focus-within:ring-primary/50 focus-within:ring-offset-2 focus-within:ring-offset-background focus-within:border-transparent focus-within:hover:border-transparent",
|
|
9322
|
+
"hover:bg-accent/10 hover:shadow-lg hover:shadow-primary/5 hover:-translate-y-0.5"
|
|
9323
|
+
],
|
|
9209
9324
|
"transition-all duration-300 ease-out",
|
|
9210
|
-
isOpen && "ring-2 ring-primary/30 border-primary/50 shadow-lg shadow-primary/10",
|
|
9211
|
-
effectiveError && "border-destructive/60 focus-
|
|
9325
|
+
isOpen && !isFocused && "ring-2 ring-primary/30 border-primary/50 shadow-lg shadow-primary/10",
|
|
9326
|
+
effectiveError && "border-destructive/60 focus-within:ring-destructive/50 bg-destructive/5",
|
|
9212
9327
|
className
|
|
9213
9328
|
),
|
|
9214
9329
|
children: [
|
|
9215
|
-
/* @__PURE__ */ (0, import_jsx_runtime35.jsxs)("div", { className: "flex items-center gap-2.5", children: [
|
|
9330
|
+
/* @__PURE__ */ (0, import_jsx_runtime35.jsxs)("div", { className: "flex items-center gap-2.5 flex-1 min-w-0", children: [
|
|
9216
9331
|
/* @__PURE__ */ (0, import_jsx_runtime35.jsx)(
|
|
9217
9332
|
"div",
|
|
9218
9333
|
{
|
|
@@ -9224,14 +9339,31 @@ var DatePicker = ({
|
|
|
9224
9339
|
}
|
|
9225
9340
|
),
|
|
9226
9341
|
/* @__PURE__ */ (0, import_jsx_runtime35.jsx)(
|
|
9227
|
-
"
|
|
9342
|
+
"input",
|
|
9228
9343
|
{
|
|
9229
|
-
|
|
9230
|
-
|
|
9344
|
+
ref: inputRef,
|
|
9345
|
+
type: "text",
|
|
9346
|
+
disabled,
|
|
9347
|
+
placeholder: placeholder || t("placeholder"),
|
|
9348
|
+
value: isFocused ? inputValue : value ? formatDateDisplay(value) : "",
|
|
9349
|
+
onChange: handleInputChange,
|
|
9350
|
+
onFocus: () => {
|
|
9351
|
+
setIsFocused(true);
|
|
9352
|
+
if (!disabled) setIsOpen(true);
|
|
9353
|
+
},
|
|
9354
|
+
onBlur: handleInputBlur,
|
|
9355
|
+
onKeyDown: handleInputKeyDown,
|
|
9356
|
+
onClick: (e) => {
|
|
9357
|
+
if (isOpen) {
|
|
9358
|
+
e.stopPropagation();
|
|
9359
|
+
}
|
|
9360
|
+
},
|
|
9361
|
+
className: "w-full bg-transparent border-none outline-none focus:outline-none p-0 text-foreground font-medium placeholder-muted-foreground/60 min-w-0"
|
|
9231
9362
|
}
|
|
9232
|
-
)
|
|
9363
|
+
),
|
|
9364
|
+
/* @__PURE__ */ (0, import_jsx_runtime35.jsx)("span", { className: "sr-only", children: value ? formatDateDisplay(value) : placeholder || t("placeholder") })
|
|
9233
9365
|
] }),
|
|
9234
|
-
/* @__PURE__ */ (0, import_jsx_runtime35.jsxs)("div", { className: "flex items-center gap-1", children: [
|
|
9366
|
+
/* @__PURE__ */ (0, import_jsx_runtime35.jsxs)("div", { className: "flex items-center gap-1 shrink-0", children: [
|
|
9235
9367
|
value && /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(
|
|
9236
9368
|
"span",
|
|
9237
9369
|
{
|
|
@@ -9291,7 +9423,8 @@ var DateRangePicker = ({
|
|
|
9291
9423
|
disablePastDates = false,
|
|
9292
9424
|
minDate,
|
|
9293
9425
|
maxDate,
|
|
9294
|
-
size = "md"
|
|
9426
|
+
size = "md",
|
|
9427
|
+
disabled = false
|
|
9295
9428
|
}) => {
|
|
9296
9429
|
const locale = useSmartLocale();
|
|
9297
9430
|
const t = useSmartTranslations("DatePicker");
|
|
@@ -9301,6 +9434,165 @@ var DateRangePicker = ({
|
|
|
9301
9434
|
const [localRequiredError, setLocalRequiredError] = React30.useState();
|
|
9302
9435
|
const wheelContainerRef = React30.useRef(null);
|
|
9303
9436
|
const wheelDeltaRef = React30.useRef(0);
|
|
9437
|
+
const triggerRef = React30.useRef(null);
|
|
9438
|
+
const inputRef = React30.useRef(null);
|
|
9439
|
+
const [isFocused, setIsFocused] = React30.useState(false);
|
|
9440
|
+
const [inputValue, setInputValue] = React30.useState("");
|
|
9441
|
+
const todayDate = React30.useMemo(() => {
|
|
9442
|
+
const today = /* @__PURE__ */ new Date();
|
|
9443
|
+
return new Date(today.getFullYear(), today.getMonth(), today.getDate());
|
|
9444
|
+
}, []);
|
|
9445
|
+
const getRangeString = React30.useCallback((s, e) => {
|
|
9446
|
+
if (!s) return "";
|
|
9447
|
+
const startStr = formatDateShort(s, locale);
|
|
9448
|
+
if (!e) return `${startStr} - `;
|
|
9449
|
+
return `${startStr} - ${formatDateShort(e, locale)}`;
|
|
9450
|
+
}, [locale]);
|
|
9451
|
+
React30.useEffect(() => {
|
|
9452
|
+
if (startDate) {
|
|
9453
|
+
const parts = inputValue.split(/\s*-\s*/);
|
|
9454
|
+
const inputStart = parts[0] ? parseDateString(parts[0], locale) : null;
|
|
9455
|
+
const inputEnd = parts[1] ? parseDateString(parts[1], locale) : null;
|
|
9456
|
+
const startSame = inputStart && startDate && inputStart.getTime() === startDate.getTime();
|
|
9457
|
+
const endSame = !endDate && !inputEnd || endDate && inputEnd && endDate.getTime() === inputEnd.getTime();
|
|
9458
|
+
if (!(startSame && endSame)) {
|
|
9459
|
+
setInputValue(getRangeString(startDate, endDate));
|
|
9460
|
+
}
|
|
9461
|
+
} else if (!isFocused) {
|
|
9462
|
+
setInputValue("");
|
|
9463
|
+
}
|
|
9464
|
+
}, [startDate, endDate, locale, isFocused, getRangeString]);
|
|
9465
|
+
const handleInputChange = (e) => {
|
|
9466
|
+
const text = e.target.value;
|
|
9467
|
+
setInputValue(text);
|
|
9468
|
+
const parts = text.split(/\s*-\s*/);
|
|
9469
|
+
if (parts.length === 2) {
|
|
9470
|
+
const s = parseDateString(parts[0], locale);
|
|
9471
|
+
const eVal = parseDateString(parts[1], locale);
|
|
9472
|
+
if (s) {
|
|
9473
|
+
const isStartDisabled = disablePastDates && s < todayDate || !!minDay && s < minDay || !!maxDay && s > maxDay;
|
|
9474
|
+
if (!isStartDisabled) {
|
|
9475
|
+
setTempStart(s);
|
|
9476
|
+
if (eVal) {
|
|
9477
|
+
const isEndDisabled = disablePastDates && eVal < todayDate || !!minDay && eVal < minDay || !!maxDay && eVal > maxDay;
|
|
9478
|
+
if (!isEndDisabled && s <= eVal) {
|
|
9479
|
+
setTempEnd(eVal);
|
|
9480
|
+
onChange(s, eVal);
|
|
9481
|
+
setViewDate(s);
|
|
9482
|
+
setLocalRequiredError(void 0);
|
|
9483
|
+
} else {
|
|
9484
|
+
setTempEnd(null);
|
|
9485
|
+
onChange(s, null);
|
|
9486
|
+
}
|
|
9487
|
+
} else {
|
|
9488
|
+
setTempEnd(null);
|
|
9489
|
+
onChange(s, null);
|
|
9490
|
+
}
|
|
9491
|
+
}
|
|
9492
|
+
}
|
|
9493
|
+
} else if (parts.length === 1 && parts[0].trim()) {
|
|
9494
|
+
const s = parseDateString(parts[0], locale);
|
|
9495
|
+
if (s) {
|
|
9496
|
+
const isStartDisabled = disablePastDates && s < todayDate || !!minDay && s < minDay || !!maxDay && s > maxDay;
|
|
9497
|
+
if (!isStartDisabled) {
|
|
9498
|
+
setTempStart(s);
|
|
9499
|
+
setTempEnd(null);
|
|
9500
|
+
onChange(s, null);
|
|
9501
|
+
}
|
|
9502
|
+
}
|
|
9503
|
+
}
|
|
9504
|
+
};
|
|
9505
|
+
const handleInputBlur = () => {
|
|
9506
|
+
setIsFocused(false);
|
|
9507
|
+
if (!inputValue.trim()) {
|
|
9508
|
+
if (required) {
|
|
9509
|
+
setLocalRequiredError(tv("required"));
|
|
9510
|
+
} else {
|
|
9511
|
+
setTempStart(null);
|
|
9512
|
+
setTempEnd(null);
|
|
9513
|
+
onChange(void 0, void 0);
|
|
9514
|
+
setLocalRequiredError(void 0);
|
|
9515
|
+
}
|
|
9516
|
+
} else {
|
|
9517
|
+
const parts = inputValue.split(/\s*-\s*/);
|
|
9518
|
+
const s = parts[0] ? parseDateString(parts[0], locale) : null;
|
|
9519
|
+
const eVal = parts[1] ? parseDateString(parts[1], locale) : null;
|
|
9520
|
+
if (s) {
|
|
9521
|
+
const isStartDisabled = disablePastDates && s < todayDate || !!minDay && s < minDay || !!maxDay && s > maxDay;
|
|
9522
|
+
if (!isStartDisabled) {
|
|
9523
|
+
if (eVal) {
|
|
9524
|
+
const isEndDisabled = disablePastDates && eVal < todayDate || !!minDay && eVal < minDay || !!maxDay && eVal > maxDay;
|
|
9525
|
+
if (!isEndDisabled && s <= eVal) {
|
|
9526
|
+
setTempStart(s);
|
|
9527
|
+
setTempEnd(eVal);
|
|
9528
|
+
onChange(s, eVal);
|
|
9529
|
+
setInputValue(getRangeString(s, eVal));
|
|
9530
|
+
setLocalRequiredError(void 0);
|
|
9531
|
+
return;
|
|
9532
|
+
}
|
|
9533
|
+
} else {
|
|
9534
|
+
setTempStart(s);
|
|
9535
|
+
setTempEnd(null);
|
|
9536
|
+
onChange(s, null);
|
|
9537
|
+
setInputValue(getRangeString(s, null));
|
|
9538
|
+
setLocalRequiredError(void 0);
|
|
9539
|
+
return;
|
|
9540
|
+
}
|
|
9541
|
+
}
|
|
9542
|
+
}
|
|
9543
|
+
if (startDate) {
|
|
9544
|
+
setTempStart(normalizeToLocal(startDate));
|
|
9545
|
+
setTempEnd(normalizeToLocal(endDate));
|
|
9546
|
+
setInputValue(getRangeString(startDate, endDate));
|
|
9547
|
+
setLocalRequiredError(void 0);
|
|
9548
|
+
} else {
|
|
9549
|
+
setTempStart(null);
|
|
9550
|
+
setTempEnd(null);
|
|
9551
|
+
setInputValue("");
|
|
9552
|
+
if (required) {
|
|
9553
|
+
setLocalRequiredError(tv("required"));
|
|
9554
|
+
}
|
|
9555
|
+
}
|
|
9556
|
+
}
|
|
9557
|
+
};
|
|
9558
|
+
const handleInputKeyDown = (e) => {
|
|
9559
|
+
if (e.key === "Enter") {
|
|
9560
|
+
e.preventDefault();
|
|
9561
|
+
const parts = inputValue.split(/\s*-\s*/);
|
|
9562
|
+
const s = parts[0] ? parseDateString(parts[0], locale) : null;
|
|
9563
|
+
const eVal = parts[1] ? parseDateString(parts[1], locale) : null;
|
|
9564
|
+
if (s) {
|
|
9565
|
+
const isStartDisabled = disablePastDates && s < todayDate || !!minDay && s < minDay || !!maxDay && s > maxDay;
|
|
9566
|
+
if (!isStartDisabled) {
|
|
9567
|
+
if (eVal) {
|
|
9568
|
+
const isEndDisabled = disablePastDates && eVal < todayDate || !!minDay && eVal < minDay || !!maxDay && eVal > maxDay;
|
|
9569
|
+
if (!isEndDisabled && s <= eVal) {
|
|
9570
|
+
setTempStart(s);
|
|
9571
|
+
setTempEnd(eVal);
|
|
9572
|
+
onChange(s, eVal);
|
|
9573
|
+
setInputValue(getRangeString(s, eVal));
|
|
9574
|
+
setViewDate(s);
|
|
9575
|
+
setIsOpen(false);
|
|
9576
|
+
setLocalRequiredError(void 0);
|
|
9577
|
+
return;
|
|
9578
|
+
}
|
|
9579
|
+
} else {
|
|
9580
|
+
setTempStart(s);
|
|
9581
|
+
setTempEnd(null);
|
|
9582
|
+
onChange(s, null);
|
|
9583
|
+
setInputValue(getRangeString(s, null));
|
|
9584
|
+
setViewDate(s);
|
|
9585
|
+
setIsOpen(false);
|
|
9586
|
+
setLocalRequiredError(void 0);
|
|
9587
|
+
return;
|
|
9588
|
+
}
|
|
9589
|
+
}
|
|
9590
|
+
}
|
|
9591
|
+
setIsOpen(false);
|
|
9592
|
+
} else if (e.key === "Escape") {
|
|
9593
|
+
setIsOpen(false);
|
|
9594
|
+
}
|
|
9595
|
+
};
|
|
9304
9596
|
const sizeStyles8 = {
|
|
9305
9597
|
sm: {
|
|
9306
9598
|
trigger: "px-2.5 py-1.5 text-sm h-8 md:h-7 md:text-xs md:py-1",
|
|
@@ -9579,10 +9871,6 @@ var DateRangePicker = ({
|
|
|
9579
9871
|
);
|
|
9580
9872
|
}) });
|
|
9581
9873
|
};
|
|
9582
|
-
const todayDate = React30.useMemo(() => {
|
|
9583
|
-
const today = /* @__PURE__ */ new Date();
|
|
9584
|
-
return new Date(today.getFullYear(), today.getMonth(), today.getDate());
|
|
9585
|
-
}, []);
|
|
9586
9874
|
const isTodayUnavailable = !!minDay && todayDate < minDay || !!maxDay && todayDate > maxDay;
|
|
9587
9875
|
const panel = /* @__PURE__ */ (0, import_jsx_runtime35.jsxs)("div", { ref: wheelContainerRef, className: "w-full", children: [
|
|
9588
9876
|
/* @__PURE__ */ (0, import_jsx_runtime35.jsxs)("div", { className: cn("flex items-center justify-between px-1", sizeStyles8[size].headerMargin), children: [
|
|
@@ -9717,7 +10005,14 @@ var DateRangePicker = ({
|
|
|
9717
10005
|
{
|
|
9718
10006
|
id: labelId,
|
|
9719
10007
|
htmlFor: resolvedId,
|
|
9720
|
-
|
|
10008
|
+
onClick: () => inputRef.current?.focus(),
|
|
10009
|
+
className: cn(
|
|
10010
|
+
size === "sm" ? "text-xs" : size === "lg" ? "text-base" : "text-sm",
|
|
10011
|
+
"font-medium transition-colors duration-300",
|
|
10012
|
+
disabled ? "text-muted-foreground cursor-not-allowed" : "text-foreground group-focus-within:text-primary hover:text-primary cursor-pointer",
|
|
10013
|
+
effectiveError && "text-destructive",
|
|
10014
|
+
labelClassName
|
|
10015
|
+
),
|
|
9721
10016
|
children: [
|
|
9722
10017
|
label,
|
|
9723
10018
|
required && /* @__PURE__ */ (0, import_jsx_runtime35.jsx)("span", { className: "text-destructive ml-1", children: "*" })
|
|
@@ -9733,6 +10028,7 @@ var DateRangePicker = ({
|
|
|
9733
10028
|
onChange: () => {
|
|
9734
10029
|
},
|
|
9735
10030
|
required,
|
|
10031
|
+
disabled,
|
|
9736
10032
|
onInvalid: (e) => {
|
|
9737
10033
|
e.preventDefault();
|
|
9738
10034
|
setLocalRequiredError(tv("required"));
|
|
@@ -9746,6 +10042,7 @@ var DateRangePicker = ({
|
|
|
9746
10042
|
open: isOpen,
|
|
9747
10043
|
onOpenChange: setIsOpen,
|
|
9748
10044
|
placement: "bottom-start",
|
|
10045
|
+
disabled,
|
|
9749
10046
|
contentWidth: sizeStyles8[size].contentWidth,
|
|
9750
10047
|
contentClassName: cn(
|
|
9751
10048
|
"p-0",
|
|
@@ -9756,25 +10053,29 @@ var DateRangePicker = ({
|
|
|
9756
10053
|
"animate-in fade-in-0 zoom-in-95 slide-in-from-top-2 duration-300"
|
|
9757
10054
|
),
|
|
9758
10055
|
trigger: /* @__PURE__ */ (0, import_jsx_runtime35.jsxs)(
|
|
9759
|
-
"
|
|
10056
|
+
"div",
|
|
9760
10057
|
{
|
|
10058
|
+
ref: triggerRef,
|
|
9761
10059
|
id: resolvedId,
|
|
9762
|
-
|
|
10060
|
+
role: "button",
|
|
10061
|
+
"aria-label": tempStart ? displayLabel : placeholder,
|
|
9763
10062
|
"aria-labelledby": labelId,
|
|
9764
10063
|
"aria-required": required,
|
|
9765
10064
|
"aria-invalid": !!effectiveError,
|
|
9766
10065
|
className: cn(
|
|
9767
10066
|
"group flex w-full items-center justify-between rounded-full border bg-background/80 backdrop-blur-sm",
|
|
9768
10067
|
sizeStyles8[size].trigger,
|
|
9769
|
-
"border-border/
|
|
9770
|
-
|
|
9771
|
-
|
|
10068
|
+
disabled ? "border-border/40 opacity-50 cursor-not-allowed" : [
|
|
10069
|
+
"border-border/60 hover:border-primary/40",
|
|
10070
|
+
"focus-within:ring-2 focus-within:ring-primary/50 focus-within:ring-offset-2 focus-within:ring-offset-background focus-within:border-transparent focus-within:hover:border-transparent",
|
|
10071
|
+
"hover:bg-accent/10 hover:shadow-lg hover:shadow-primary/5 hover:-translate-y-0.5"
|
|
10072
|
+
],
|
|
9772
10073
|
"transition-all duration-300 ease-out",
|
|
9773
|
-
isOpen && "ring-2 ring-primary/30 border-primary/50 shadow-lg shadow-primary/10",
|
|
9774
|
-
effectiveError && "border-destructive/60 focus-
|
|
10074
|
+
isOpen && !isFocused && "ring-2 ring-primary/30 border-primary/50 shadow-lg shadow-primary/10",
|
|
10075
|
+
effectiveError && "border-destructive/60 focus-within:ring-destructive/50 bg-destructive/5"
|
|
9775
10076
|
),
|
|
9776
10077
|
children: [
|
|
9777
|
-
/* @__PURE__ */ (0, import_jsx_runtime35.jsxs)("div", { className: cn("flex items-center", size === "sm" ? "gap-1.5" : "gap-2.5"), children: [
|
|
10078
|
+
/* @__PURE__ */ (0, import_jsx_runtime35.jsxs)("div", { className: cn("flex items-center flex-1 min-w-0", size === "sm" ? "gap-1.5" : "gap-2.5"), children: [
|
|
9778
10079
|
/* @__PURE__ */ (0, import_jsx_runtime35.jsx)(
|
|
9779
10080
|
"div",
|
|
9780
10081
|
{
|
|
@@ -9786,16 +10087,29 @@ var DateRangePicker = ({
|
|
|
9786
10087
|
}
|
|
9787
10088
|
),
|
|
9788
10089
|
/* @__PURE__ */ (0, import_jsx_runtime35.jsx)(
|
|
9789
|
-
"
|
|
10090
|
+
"input",
|
|
9790
10091
|
{
|
|
9791
|
-
|
|
9792
|
-
|
|
9793
|
-
|
|
9794
|
-
|
|
9795
|
-
|
|
9796
|
-
|
|
10092
|
+
ref: inputRef,
|
|
10093
|
+
type: "text",
|
|
10094
|
+
disabled,
|
|
10095
|
+
placeholder,
|
|
10096
|
+
value: isFocused ? inputValue : tempStart ? displayLabel : "",
|
|
10097
|
+
onChange: handleInputChange,
|
|
10098
|
+
onFocus: () => {
|
|
10099
|
+
setIsFocused(true);
|
|
10100
|
+
if (!disabled) setIsOpen(true);
|
|
10101
|
+
},
|
|
10102
|
+
onBlur: handleInputBlur,
|
|
10103
|
+
onKeyDown: handleInputKeyDown,
|
|
10104
|
+
onClick: (e) => {
|
|
10105
|
+
if (isOpen) {
|
|
10106
|
+
e.stopPropagation();
|
|
10107
|
+
}
|
|
10108
|
+
},
|
|
10109
|
+
className: "w-full bg-transparent border-none outline-none focus:outline-none p-0 text-foreground font-medium placeholder-muted-foreground/60 min-w-0"
|
|
9797
10110
|
}
|
|
9798
|
-
)
|
|
10111
|
+
),
|
|
10112
|
+
/* @__PURE__ */ (0, import_jsx_runtime35.jsx)("span", { className: "sr-only", children: tempStart ? displayLabel : placeholder })
|
|
9799
10113
|
] }),
|
|
9800
10114
|
/* @__PURE__ */ (0, import_jsx_runtime35.jsx)("span", { className: cn("transition-all duration-300 text-muted-foreground group-hover:text-foreground", isOpen && "rotate-180 text-primary"), children: /* @__PURE__ */ (0, import_jsx_runtime35.jsx)("svg", { className: cn(sizeStyles8[size].navIcon), fill: "none", viewBox: "0 0 24 24", stroke: "currentColor", strokeWidth: 2.5, children: /* @__PURE__ */ (0, import_jsx_runtime35.jsx)("path", { strokeLinecap: "round", strokeLinejoin: "round", d: "M19 9l-7 7-7-7" }) }) })
|
|
9801
10115
|
]
|