@chekinapp/ui 0.0.110 → 0.0.111
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 +469 -363
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +14 -5
- package/dist/index.d.ts +14 -5
- package/dist/index.js +471 -365
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
- package/src/global.css +1 -1
package/dist/index.js
CHANGED
|
@@ -3417,18 +3417,15 @@ function useSwitchSectionActive(preloadedSectionActive, { canToggle, onToggle, o
|
|
|
3417
3417
|
|
|
3418
3418
|
// src/hooks/use-countdown.ts
|
|
3419
3419
|
import { useEffect as useEffect19, useState as useState15 } from "react";
|
|
3420
|
-
var useCountdown = ({
|
|
3421
|
-
|
|
3422
|
-
|
|
3423
|
-
onFinish
|
|
3424
|
-
} = {}) => {
|
|
3425
|
-
const [timeLeft, setTimeLeft] = useState15(initialTime);
|
|
3420
|
+
var useCountdown = ({ initialTime, enabled = true, onFinish } = {}) => {
|
|
3421
|
+
const duration = initialTime ?? 60;
|
|
3422
|
+
const [timeLeft, setTimeLeft] = useState15(duration);
|
|
3426
3423
|
const [isTimerRunning, setIsTimerRunning] = useState15(enabled);
|
|
3427
3424
|
const handleOnFinish = useEvent(onFinish);
|
|
3428
3425
|
useEffect19(() => {
|
|
3429
|
-
setTimeLeft(
|
|
3426
|
+
setTimeLeft(duration);
|
|
3430
3427
|
setIsTimerRunning(enabled);
|
|
3431
|
-
}, [
|
|
3428
|
+
}, [duration, enabled]);
|
|
3432
3429
|
useEffect19(() => {
|
|
3433
3430
|
if (!isTimerRunning) return;
|
|
3434
3431
|
const timer = setInterval(() => {
|
|
@@ -3447,12 +3444,13 @@ var useCountdown = ({
|
|
|
3447
3444
|
if (timeLeft <= 0) {
|
|
3448
3445
|
handleOnFinish();
|
|
3449
3446
|
}
|
|
3450
|
-
}, [timeLeft]);
|
|
3447
|
+
}, [timeLeft, handleOnFinish]);
|
|
3451
3448
|
const resetTimer = () => {
|
|
3452
|
-
setTimeLeft(
|
|
3449
|
+
setTimeLeft(duration);
|
|
3453
3450
|
setIsTimerRunning(enabled);
|
|
3454
3451
|
};
|
|
3455
3452
|
return {
|
|
3453
|
+
count: timeLeft,
|
|
3456
3454
|
timeLeft,
|
|
3457
3455
|
isTimerRunning,
|
|
3458
3456
|
resetTimer
|
|
@@ -11189,7 +11187,7 @@ function useErrorHandler({ onError }) {
|
|
|
11189
11187
|
const handleUserMediaError = useCallback28(
|
|
11190
11188
|
(error) => {
|
|
11191
11189
|
console.error(error);
|
|
11192
|
-
let errorText
|
|
11190
|
+
let errorText;
|
|
11193
11191
|
if (error?.message === GET_USER_MEDIA_ERROR) {
|
|
11194
11192
|
errorText = t("camera_errors.chekin_cant_use_your_camera");
|
|
11195
11193
|
handleError({
|
|
@@ -12087,7 +12085,7 @@ function Fieldset({
|
|
|
12087
12085
|
className: cn(
|
|
12088
12086
|
"absolute box-border inline-flex max-w-full cursor-text items-center pl-[3px] pr-5 transition-all duration-100 ease-in",
|
|
12089
12087
|
"left-[13px] text-[var(--chekin-color-gray-1)]",
|
|
12090
|
-
isEmpty && !isFocused ? "top-[12px]" : "top-[-10px] !
|
|
12088
|
+
isEmpty && !isFocused ? "top-[12px]" : "top-[-10px] !px-1",
|
|
12091
12089
|
isFocused && "text-[var(--chekin-color-brand-blue)]",
|
|
12092
12090
|
raised && invalid && "text-[var(--error-message-color)]",
|
|
12093
12091
|
readOnly && "cursor-default",
|
|
@@ -12102,8 +12100,8 @@ function Fieldset({
|
|
|
12102
12100
|
id: labelId,
|
|
12103
12101
|
htmlFor,
|
|
12104
12102
|
className: cn(
|
|
12105
|
-
"block cursor-[inherit] truncate
|
|
12106
|
-
raised ? "text-[14px]" : "text-[16px]"
|
|
12103
|
+
"block cursor-[inherit] truncate transition-all duration-100 ease-in",
|
|
12104
|
+
raised ? "text-[14px] font-semibold" : "text-[16px] font-medium"
|
|
12107
12105
|
),
|
|
12108
12106
|
children: label
|
|
12109
12107
|
}
|
|
@@ -12141,7 +12139,16 @@ function Fieldset({
|
|
|
12141
12139
|
!label && "w-0"
|
|
12142
12140
|
),
|
|
12143
12141
|
children: [
|
|
12144
|
-
showLegendText && /* @__PURE__ */ jsx142(
|
|
12142
|
+
showLegendText && /* @__PURE__ */ jsx142(
|
|
12143
|
+
"span",
|
|
12144
|
+
{
|
|
12145
|
+
className: cn(
|
|
12146
|
+
"visible inline-block px-1 text-[14px] opacity-0",
|
|
12147
|
+
raised ? "font-semibold" : "font-medium"
|
|
12148
|
+
),
|
|
12149
|
+
children: legend || label
|
|
12150
|
+
}
|
|
12151
|
+
),
|
|
12145
12152
|
tooltip && /* @__PURE__ */ jsx142("span", { className: "visible inline-block w-[20px] opacity-0", children: /* @__PURE__ */ jsx142("span", { className: "inline-block h-4 w-4" }) })
|
|
12146
12153
|
]
|
|
12147
12154
|
}
|
|
@@ -12248,7 +12255,7 @@ var Input = React44.forwardRef(
|
|
|
12248
12255
|
"div",
|
|
12249
12256
|
{
|
|
12250
12257
|
className: cn(
|
|
12251
|
-
"relative block w-full max-w-[var(--field-max-width,296px)] min-h-[
|
|
12258
|
+
"relative block w-full max-w-[var(--field-max-width,296px)] min-h-[var(--field-min-height,48px)]",
|
|
12252
12259
|
disabled && "cursor-not-allowed opacity-50",
|
|
12253
12260
|
loading && "cursor-progress opacity-50",
|
|
12254
12261
|
wrapperClassName,
|
|
@@ -12268,7 +12275,7 @@ var Input = React44.forwardRef(
|
|
|
12268
12275
|
{
|
|
12269
12276
|
className: cn(
|
|
12270
12277
|
"relative block w-full",
|
|
12271
|
-
readOnly && "bg-[var(--
|
|
12278
|
+
readOnly && "bg-[var(--empty-field-background)]",
|
|
12272
12279
|
fieldClassName
|
|
12273
12280
|
),
|
|
12274
12281
|
children: [
|
|
@@ -12320,7 +12327,7 @@ var Input = React44.forwardRef(
|
|
|
12320
12327
|
className: cn(
|
|
12321
12328
|
"m-0 box-border h-12 w-full rounded-[6px] border-0 px-4 text-[16px] font-medium leading-5 text-[var(--chekin-color-brand-navy)] outline-none transition-colors duration-200 [text-overflow:ellipsis] [&::-webkit-inner-spin-button]:appearance-none [&::-webkit-outer-spin-button]:appearance-none",
|
|
12322
12329
|
"placeholder:font-medium placeholder:text-[var(--chekin-color-gray-1)] placeholder:opacity-100",
|
|
12323
|
-
isEmpty && !isFocused ? "bg-[var(--
|
|
12330
|
+
isEmpty && !isFocused ? "bg-[var(--empty-field-background)]" : "bg-transparent",
|
|
12324
12331
|
isEmpty && "text-[var(--chekin-color-gray-1)]",
|
|
12325
12332
|
inputType === "password" && "[&:not(:placeholder-shown)]:font-bold [&:not(:placeholder-shown)]:tracking-[2px]",
|
|
12326
12333
|
(disabled || readOnly) && "cursor-not-allowed",
|
|
@@ -12453,14 +12460,14 @@ function SelectFieldShell({
|
|
|
12453
12460
|
onBlur,
|
|
12454
12461
|
className: cn(
|
|
12455
12462
|
"relative w-full max-w-[var(--field-max-width,296px)]",
|
|
12456
|
-
disabled && "cursor-not-allowed opacity-50",
|
|
12457
|
-
loading && "cursor-progress",
|
|
12463
|
+
disabled && !loading && "cursor-not-allowed opacity-50",
|
|
12464
|
+
loading && "cursor-progress opacity-50",
|
|
12458
12465
|
className
|
|
12459
12466
|
),
|
|
12460
12467
|
style: wrapperWidth ? { width: wrapperWidth } : void 0,
|
|
12461
12468
|
children: [
|
|
12462
12469
|
name && /* @__PURE__ */ jsx144("input", { type: "hidden", name, value: hiddenValue ?? "" }),
|
|
12463
|
-
/* @__PURE__ */ jsxs91("div", { className: "relative min-h-[
|
|
12470
|
+
/* @__PURE__ */ jsxs91("div", { className: "relative min-h-[var(--field-min-height,48px)] w-full", children: [
|
|
12464
12471
|
topLabel && /* @__PURE__ */ jsx144(
|
|
12465
12472
|
"label",
|
|
12466
12473
|
{
|
|
@@ -12494,13 +12501,19 @@ function getOptionIndex(options, option) {
|
|
|
12494
12501
|
if (!option) return -1;
|
|
12495
12502
|
return options.findIndex((item) => item.value === option.value);
|
|
12496
12503
|
}
|
|
12497
|
-
function
|
|
12498
|
-
|
|
12504
|
+
function isOptionEnabled(option, isOptionDisabled) {
|
|
12505
|
+
if (!option) return false;
|
|
12506
|
+
if (option.isDisabled) return false;
|
|
12507
|
+
if (isOptionDisabled?.(option)) return false;
|
|
12508
|
+
return true;
|
|
12509
|
+
}
|
|
12510
|
+
function getFirstEnabledOptionIndex(options, isOptionDisabled) {
|
|
12511
|
+
return options.findIndex((option) => isOptionEnabled(option, isOptionDisabled));
|
|
12499
12512
|
}
|
|
12500
|
-
function getNextEnabledOptionIndex(options, startIndex, step) {
|
|
12513
|
+
function getNextEnabledOptionIndex(options, startIndex, step, isOptionDisabled) {
|
|
12501
12514
|
let nextIndex = startIndex;
|
|
12502
12515
|
while (nextIndex >= 0 && nextIndex < options.length) {
|
|
12503
|
-
if (
|
|
12516
|
+
if (isOptionEnabled(options[nextIndex], isOptionDisabled)) return nextIndex;
|
|
12504
12517
|
nextIndex += step;
|
|
12505
12518
|
}
|
|
12506
12519
|
return -1;
|
|
@@ -12531,6 +12544,7 @@ function SelectMenu({
|
|
|
12531
12544
|
onOptionHover,
|
|
12532
12545
|
onKeyDown,
|
|
12533
12546
|
disabled,
|
|
12547
|
+
isOptionDisabled,
|
|
12534
12548
|
menuClassName,
|
|
12535
12549
|
listRef,
|
|
12536
12550
|
selectedOptionRef,
|
|
@@ -12565,7 +12579,9 @@ function SelectMenu({
|
|
|
12565
12579
|
const isSelected = isOptionSelected(option, selectedValue, selectedValues);
|
|
12566
12580
|
const isHighlighted = index === highlightedIndex;
|
|
12567
12581
|
const optionKey = `${String(option.value)}-${index}`;
|
|
12568
|
-
const
|
|
12582
|
+
const isOptionDisabledFlag = Boolean(
|
|
12583
|
+
disabled || option.isDisabled || isOptionDisabled?.(option)
|
|
12584
|
+
);
|
|
12569
12585
|
return /* @__PURE__ */ jsxs92(
|
|
12570
12586
|
"button",
|
|
12571
12587
|
{
|
|
@@ -12576,9 +12592,9 @@ function SelectMenu({
|
|
|
12576
12592
|
type: "button",
|
|
12577
12593
|
role: "option",
|
|
12578
12594
|
"aria-selected": isSelected,
|
|
12579
|
-
"aria-disabled":
|
|
12595
|
+
"aria-disabled": isOptionDisabledFlag,
|
|
12580
12596
|
tabIndex: -1,
|
|
12581
|
-
disabled:
|
|
12597
|
+
disabled: isOptionDisabledFlag,
|
|
12582
12598
|
onClick: () => onOptionClick(option),
|
|
12583
12599
|
onMouseMove: () => onOptionHover?.(index),
|
|
12584
12600
|
className: cn(
|
|
@@ -12586,7 +12602,7 @@ function SelectMenu({
|
|
|
12586
12602
|
"last:border-b-transparent",
|
|
12587
12603
|
isHighlighted && !isSelected && "cursor-pointer text-[var(--chekin-color-brand-blue)]",
|
|
12588
12604
|
isSelected && "cursor-default font-bold text-[var(--chekin-color-brand-navy)]",
|
|
12589
|
-
|
|
12605
|
+
isOptionDisabledFlag && "cursor-default opacity-30"
|
|
12590
12606
|
),
|
|
12591
12607
|
children: [
|
|
12592
12608
|
/* @__PURE__ */ jsx145("span", { className: "block break-words", children: option.label }),
|
|
@@ -12746,25 +12762,22 @@ function SelectTrigger({
|
|
|
12746
12762
|
onBlur,
|
|
12747
12763
|
className: cn(
|
|
12748
12764
|
"relative m-0 box-border flex h-12 w-full cursor-pointer items-center justify-between gap-2 rounded-[6px] border-0 px-4 text-left text-[16px] font-medium leading-5 outline-none transition-colors duration-200",
|
|
12749
|
-
isEmpty ? "bg-[var(--
|
|
12750
|
-
disabled && "cursor-not-allowed opacity-50",
|
|
12751
|
-
loading && "cursor-progress"
|
|
12765
|
+
isEmpty ? "bg-[var(--empty-field-background)] text-[var(--chekin-color-gray-1)]" : "bg-transparent text-[var(--chekin-color-brand-navy)]",
|
|
12766
|
+
disabled && !loading && "cursor-not-allowed opacity-50",
|
|
12767
|
+
loading && "!cursor-progress"
|
|
12752
12768
|
),
|
|
12753
12769
|
children: [
|
|
12754
12770
|
/* @__PURE__ */ jsx148("span", { id: valueId, className: "block min-w-0 flex-1 truncate text-left", children: valueLabel ?? (isOpen ? placeholder : null) }),
|
|
12755
|
-
/* @__PURE__ */
|
|
12756
|
-
|
|
12757
|
-
|
|
12758
|
-
|
|
12759
|
-
|
|
12760
|
-
|
|
12761
|
-
|
|
12762
|
-
|
|
12763
|
-
|
|
12764
|
-
|
|
12765
|
-
}
|
|
12766
|
-
)
|
|
12767
|
-
] })
|
|
12771
|
+
/* @__PURE__ */ jsx148("span", { className: "pointer-events-none flex items-center gap-2 text-[var(--chekin-color-gray-2)]", children: /* @__PURE__ */ jsx148(
|
|
12772
|
+
ChevronDown2,
|
|
12773
|
+
{
|
|
12774
|
+
size: 16,
|
|
12775
|
+
className: cn(
|
|
12776
|
+
"transition-transform duration-200",
|
|
12777
|
+
isOpen && "rotate-180 text-[var(--chekin-color-brand-blue)]"
|
|
12778
|
+
)
|
|
12779
|
+
}
|
|
12780
|
+
) })
|
|
12768
12781
|
]
|
|
12769
12782
|
}
|
|
12770
12783
|
);
|
|
@@ -12822,9 +12835,9 @@ function ComboboxTrigger({
|
|
|
12822
12835
|
className: cn(
|
|
12823
12836
|
"relative box-border flex w-full cursor-text rounded-[6px] border-0 text-left text-[16px] font-medium leading-5 outline-none transition-colors duration-200",
|
|
12824
12837
|
"min-h-12",
|
|
12825
|
-
isEmpty && !isFocused ? "bg-[var(--
|
|
12826
|
-
disabled && "cursor-not-allowed",
|
|
12827
|
-
loading && "cursor-progress",
|
|
12838
|
+
isEmpty && !isFocused ? "bg-[var(--empty-field-background)]" : "bg-transparent",
|
|
12839
|
+
disabled && !loading && "cursor-not-allowed",
|
|
12840
|
+
loading && "!cursor-progress",
|
|
12828
12841
|
containerClassName
|
|
12829
12842
|
),
|
|
12830
12843
|
children: [
|
|
@@ -12857,7 +12870,8 @@ function ComboboxTrigger({
|
|
|
12857
12870
|
className: cn(
|
|
12858
12871
|
"m-0 box-border min-w-0 flex-1 border-0 bg-transparent p-0 text-[16px] font-medium leading-5 text-[var(--chekin-color-brand-navy)] outline-none placeholder:text-[var(--chekin-color-gray-1)]",
|
|
12859
12872
|
isMulti && "min-w-[40px]",
|
|
12860
|
-
isBlocked && "cursor-not-allowed",
|
|
12873
|
+
isBlocked && !loading && "cursor-not-allowed",
|
|
12874
|
+
loading && "!cursor-progress",
|
|
12861
12875
|
inputClassName
|
|
12862
12876
|
)
|
|
12863
12877
|
}
|
|
@@ -12866,7 +12880,6 @@ function ComboboxTrigger({
|
|
|
12866
12880
|
}
|
|
12867
12881
|
),
|
|
12868
12882
|
/* @__PURE__ */ jsxs96("span", { className: "flex h-12 shrink-0 items-center gap-2 self-start pl-2 pr-4 text-[var(--chekin-color-gray-2)]", children: [
|
|
12869
|
-
loading && /* @__PURE__ */ jsx149(ThreeDotsLoader, { height: 18, width: 18 }),
|
|
12870
12883
|
showClear && /* @__PURE__ */ jsx149(
|
|
12871
12884
|
"button",
|
|
12872
12885
|
{
|
|
@@ -13155,7 +13168,7 @@ function SearchableSelectInternal({
|
|
|
13155
13168
|
legend: typeof label === "string" ? label : void 0,
|
|
13156
13169
|
label,
|
|
13157
13170
|
tooltip,
|
|
13158
|
-
labelClassName: "cursor-pointer"
|
|
13171
|
+
labelClassName: loading ? void 0 : "cursor-pointer"
|
|
13159
13172
|
}
|
|
13160
13173
|
),
|
|
13161
13174
|
/* @__PURE__ */ jsxs97(
|
|
@@ -13450,6 +13463,7 @@ function SelectInternal({
|
|
|
13450
13463
|
width,
|
|
13451
13464
|
noOptionsMessage,
|
|
13452
13465
|
filterOption = defaultFilterOption,
|
|
13466
|
+
isOptionDisabled,
|
|
13453
13467
|
helperText,
|
|
13454
13468
|
clearable = true,
|
|
13455
13469
|
isCreatable = false,
|
|
@@ -13512,9 +13526,9 @@ function SelectInternal({
|
|
|
13512
13526
|
}
|
|
13513
13527
|
setHighlightedIndex((current) => {
|
|
13514
13528
|
if (current >= 0 && current < filteredOptions.length) return current;
|
|
13515
|
-
return getFirstEnabledOptionIndex(filteredOptions);
|
|
13529
|
+
return getFirstEnabledOptionIndex(filteredOptions, isOptionDisabled);
|
|
13516
13530
|
});
|
|
13517
|
-
}, [isOpen, filteredOptions]);
|
|
13531
|
+
}, [isOpen, filteredOptions, isOptionDisabled]);
|
|
13518
13532
|
React50.useEffect(() => {
|
|
13519
13533
|
if (!isOpen) return;
|
|
13520
13534
|
if (highlightedIndex < 0) return;
|
|
@@ -13528,8 +13542,8 @@ function SelectInternal({
|
|
|
13528
13542
|
return () => window.cancelAnimationFrame(frame);
|
|
13529
13543
|
}, [isOpen, isMobile3]);
|
|
13530
13544
|
const commitSelection = (option) => {
|
|
13531
|
-
if (option
|
|
13532
|
-
onChange(option);
|
|
13545
|
+
if (!isOptionEnabled(option, isOptionDisabled)) return;
|
|
13546
|
+
onChange(option, { action: "select" });
|
|
13533
13547
|
setInputValue(resolveLabel(option));
|
|
13534
13548
|
setIsOpen(false);
|
|
13535
13549
|
setIsFocused(false);
|
|
@@ -13538,7 +13552,7 @@ function SelectInternal({
|
|
|
13538
13552
|
const commitCreate = () => {
|
|
13539
13553
|
if (!canCreateNewOption) return;
|
|
13540
13554
|
const newOption = onCreateOption?.(trimmedInput) ?? { value: trimmedInput, label: trimmedInput };
|
|
13541
|
-
onChange(newOption);
|
|
13555
|
+
onChange(newOption, { action: "create" });
|
|
13542
13556
|
setInputValue(resolveLabel(newOption));
|
|
13543
13557
|
setIsOpen(false);
|
|
13544
13558
|
setIsFocused(false);
|
|
@@ -13547,7 +13561,7 @@ function SelectInternal({
|
|
|
13547
13561
|
const clearSelection = (event) => {
|
|
13548
13562
|
event.stopPropagation();
|
|
13549
13563
|
if (isBlocked) return;
|
|
13550
|
-
onChange(null);
|
|
13564
|
+
onChange(null, { action: "clear" });
|
|
13551
13565
|
setInputValue("");
|
|
13552
13566
|
inputRef.current?.focus();
|
|
13553
13567
|
};
|
|
@@ -13570,7 +13584,12 @@ function SelectInternal({
|
|
|
13570
13584
|
setIsOpen(true);
|
|
13571
13585
|
return;
|
|
13572
13586
|
}
|
|
13573
|
-
const next = getNextEnabledOptionIndex(
|
|
13587
|
+
const next = getNextEnabledOptionIndex(
|
|
13588
|
+
filteredOptions,
|
|
13589
|
+
highlightedIndex + 1,
|
|
13590
|
+
1,
|
|
13591
|
+
isOptionDisabled
|
|
13592
|
+
);
|
|
13574
13593
|
if (next >= 0) setHighlightedIndex(next);
|
|
13575
13594
|
return;
|
|
13576
13595
|
}
|
|
@@ -13580,7 +13599,12 @@ function SelectInternal({
|
|
|
13580
13599
|
setIsOpen(true);
|
|
13581
13600
|
return;
|
|
13582
13601
|
}
|
|
13583
|
-
const next = getNextEnabledOptionIndex(
|
|
13602
|
+
const next = getNextEnabledOptionIndex(
|
|
13603
|
+
filteredOptions,
|
|
13604
|
+
highlightedIndex - 1,
|
|
13605
|
+
-1,
|
|
13606
|
+
isOptionDisabled
|
|
13607
|
+
);
|
|
13584
13608
|
if (next >= 0) setHighlightedIndex(next);
|
|
13585
13609
|
return;
|
|
13586
13610
|
}
|
|
@@ -13588,7 +13612,7 @@ function SelectInternal({
|
|
|
13588
13612
|
if (!isOpen) return;
|
|
13589
13613
|
event.preventDefault();
|
|
13590
13614
|
const option = filteredOptions[highlightedIndex];
|
|
13591
|
-
if (option &&
|
|
13615
|
+
if (option && isOptionEnabled(option, isOptionDisabled)) {
|
|
13592
13616
|
commitSelection(option);
|
|
13593
13617
|
} else if (canCreateNewOption) {
|
|
13594
13618
|
commitCreate();
|
|
@@ -13715,6 +13739,7 @@ function SelectInternal({
|
|
|
13715
13739
|
onOptionClick: commitSelection,
|
|
13716
13740
|
onOptionHover: setHighlightedIndex,
|
|
13717
13741
|
disabled: isBlocked,
|
|
13742
|
+
isOptionDisabled,
|
|
13718
13743
|
menuClassName,
|
|
13719
13744
|
listRef,
|
|
13720
13745
|
selectedOptionRef: (index, node) => {
|
|
@@ -13809,6 +13834,7 @@ function MultiSelectInternal({
|
|
|
13809
13834
|
width,
|
|
13810
13835
|
noOptionsMessage,
|
|
13811
13836
|
filterOption,
|
|
13837
|
+
isOptionDisabled,
|
|
13812
13838
|
closeMenuOnSelect = false,
|
|
13813
13839
|
renderChip,
|
|
13814
13840
|
helperText,
|
|
@@ -13872,9 +13898,9 @@ function MultiSelectInternal({
|
|
|
13872
13898
|
}
|
|
13873
13899
|
setHighlightedIndex((current) => {
|
|
13874
13900
|
if (current >= 0 && current < filteredOptions.length) return current;
|
|
13875
|
-
return getFirstEnabledOptionIndex(filteredOptions);
|
|
13901
|
+
return getFirstEnabledOptionIndex(filteredOptions, isOptionDisabled);
|
|
13876
13902
|
});
|
|
13877
|
-
}, [isOpen, filteredOptions]);
|
|
13903
|
+
}, [isOpen, filteredOptions, isOptionDisabled]);
|
|
13878
13904
|
React52.useEffect(() => {
|
|
13879
13905
|
if (!isOpen || !isMobile3) return;
|
|
13880
13906
|
const frame = window.requestAnimationFrame(
|
|
@@ -13888,10 +13914,10 @@ function MultiSelectInternal({
|
|
|
13888
13914
|
setIsFocused(true);
|
|
13889
13915
|
};
|
|
13890
13916
|
const toggleOption = (option) => {
|
|
13891
|
-
if (option
|
|
13917
|
+
if (!isOptionEnabled(option, isOptionDisabled)) return;
|
|
13892
13918
|
const exists = isValueSelected(selectedValues, option);
|
|
13893
13919
|
const next = exists ? selectedValues.filter((item) => item.value !== option.value) : [...selectedValues, option];
|
|
13894
|
-
onChange(next);
|
|
13920
|
+
onChange(next, { action: exists ? "deselect" : "select" });
|
|
13895
13921
|
clearSearch();
|
|
13896
13922
|
if (closeMenuOnSelect) {
|
|
13897
13923
|
setIsOpen(false);
|
|
@@ -13901,18 +13927,21 @@ function MultiSelectInternal({
|
|
|
13901
13927
|
};
|
|
13902
13928
|
const removeOption = (option) => {
|
|
13903
13929
|
if (isBlocked) return;
|
|
13904
|
-
onChange(
|
|
13930
|
+
onChange(
|
|
13931
|
+
selectedValues.filter((item) => item.value !== option.value),
|
|
13932
|
+
{ action: "deselect" }
|
|
13933
|
+
);
|
|
13905
13934
|
inputRef.current?.focus();
|
|
13906
13935
|
};
|
|
13907
13936
|
const clearAll = () => {
|
|
13908
13937
|
if (isBlocked) return;
|
|
13909
|
-
onChange([]);
|
|
13938
|
+
onChange([], { action: "clear" });
|
|
13910
13939
|
inputRef.current?.focus();
|
|
13911
13940
|
};
|
|
13912
13941
|
const createOption = React52.useCallback(() => {
|
|
13913
13942
|
if (!canCreateNewOption) return;
|
|
13914
13943
|
const newOption = onCreateOption?.(trimmedSearch) ?? { value: trimmedSearch, label: trimmedSearch };
|
|
13915
|
-
onChange([...selectedValues, newOption]);
|
|
13944
|
+
onChange([...selectedValues, newOption], { action: "create" });
|
|
13916
13945
|
clearSearch();
|
|
13917
13946
|
inputRef.current?.focus();
|
|
13918
13947
|
if (closeMenuOnSelect) setIsOpen(false);
|
|
@@ -13929,7 +13958,7 @@ function MultiSelectInternal({
|
|
|
13929
13958
|
const handleInputKeyDown = (event) => {
|
|
13930
13959
|
if (event.key === "Backspace" && !searchValue && selectedValues.length > 0) {
|
|
13931
13960
|
event.preventDefault();
|
|
13932
|
-
onChange(selectedValues.slice(0, -1));
|
|
13961
|
+
onChange(selectedValues.slice(0, -1), { action: "deselect" });
|
|
13933
13962
|
return;
|
|
13934
13963
|
}
|
|
13935
13964
|
if (event.key === "ArrowDown") {
|
|
@@ -13938,7 +13967,12 @@ function MultiSelectInternal({
|
|
|
13938
13967
|
openMenu();
|
|
13939
13968
|
return;
|
|
13940
13969
|
}
|
|
13941
|
-
const next = getNextEnabledOptionIndex(
|
|
13970
|
+
const next = getNextEnabledOptionIndex(
|
|
13971
|
+
filteredOptions,
|
|
13972
|
+
highlightedIndex + 1,
|
|
13973
|
+
1,
|
|
13974
|
+
isOptionDisabled
|
|
13975
|
+
);
|
|
13942
13976
|
if (next >= 0) setHighlightedIndex(next);
|
|
13943
13977
|
return;
|
|
13944
13978
|
}
|
|
@@ -13948,7 +13982,12 @@ function MultiSelectInternal({
|
|
|
13948
13982
|
openMenu();
|
|
13949
13983
|
return;
|
|
13950
13984
|
}
|
|
13951
|
-
const next = getNextEnabledOptionIndex(
|
|
13985
|
+
const next = getNextEnabledOptionIndex(
|
|
13986
|
+
filteredOptions,
|
|
13987
|
+
highlightedIndex - 1,
|
|
13988
|
+
-1,
|
|
13989
|
+
isOptionDisabled
|
|
13990
|
+
);
|
|
13952
13991
|
if (next >= 0) setHighlightedIndex(next);
|
|
13953
13992
|
return;
|
|
13954
13993
|
}
|
|
@@ -13956,7 +13995,7 @@ function MultiSelectInternal({
|
|
|
13956
13995
|
if (!isOpen) return;
|
|
13957
13996
|
event.preventDefault();
|
|
13958
13997
|
const option = filteredOptions[highlightedIndex];
|
|
13959
|
-
if (option &&
|
|
13998
|
+
if (option && isOptionEnabled(option, isOptionDisabled)) {
|
|
13960
13999
|
toggleOption(option);
|
|
13961
14000
|
} else if (canCreateNewOption) {
|
|
13962
14001
|
createOption();
|
|
@@ -14104,6 +14143,7 @@ function MultiSelectInternal({
|
|
|
14104
14143
|
onOptionClick: toggleOption,
|
|
14105
14144
|
onOptionHover: setHighlightedIndex,
|
|
14106
14145
|
disabled: isBlocked,
|
|
14146
|
+
isOptionDisabled,
|
|
14107
14147
|
menuClassName,
|
|
14108
14148
|
listRef,
|
|
14109
14149
|
selectedOptionRef: (index, node) => {
|
|
@@ -14622,17 +14662,79 @@ var InfiniteScrollSelect = React54.forwardRef(
|
|
|
14622
14662
|
);
|
|
14623
14663
|
|
|
14624
14664
|
// src/dashboard/textarea/Textarea.tsx
|
|
14625
|
-
import * as
|
|
14665
|
+
import * as React56 from "react";
|
|
14626
14666
|
import { useTranslation as useTranslation36 } from "react-i18next";
|
|
14667
|
+
|
|
14668
|
+
// src/dashboard/textarea/useTextareaValueState.ts
|
|
14669
|
+
import * as React55 from "react";
|
|
14670
|
+
var isEmptyValue2 = (value) => {
|
|
14671
|
+
if (value === void 0 || value === null) return true;
|
|
14672
|
+
return String(value).length === 0;
|
|
14673
|
+
};
|
|
14674
|
+
var getTextareaEmptyState = ({
|
|
14675
|
+
empty,
|
|
14676
|
+
defaultValue,
|
|
14677
|
+
value
|
|
14678
|
+
}) => {
|
|
14679
|
+
if (typeof empty !== "undefined") return empty;
|
|
14680
|
+
if (typeof value !== "undefined") return isEmptyValue2(value);
|
|
14681
|
+
return isEmptyValue2(defaultValue);
|
|
14682
|
+
};
|
|
14683
|
+
function useTextareaValueState({
|
|
14684
|
+
empty,
|
|
14685
|
+
value,
|
|
14686
|
+
defaultValue
|
|
14687
|
+
}) {
|
|
14688
|
+
const textareaRef = React55.useRef(null);
|
|
14689
|
+
const isControlled = typeof empty !== "undefined" || typeof value !== "undefined";
|
|
14690
|
+
const propsAreEmpty = getTextareaEmptyState({ empty, value, defaultValue });
|
|
14691
|
+
const [nativeIsEmpty, setNativeIsEmpty] = React55.useState(propsAreEmpty);
|
|
14692
|
+
const isEmpty = isControlled ? propsAreEmpty : nativeIsEmpty;
|
|
14693
|
+
const setNativeValue = React55.useCallback(
|
|
14694
|
+
(nextValue) => {
|
|
14695
|
+
if (isControlled) return;
|
|
14696
|
+
const nextIsEmpty = nextValue.length === 0;
|
|
14697
|
+
setNativeIsEmpty(
|
|
14698
|
+
(prevIsEmpty) => prevIsEmpty === nextIsEmpty ? prevIsEmpty : nextIsEmpty
|
|
14699
|
+
);
|
|
14700
|
+
},
|
|
14701
|
+
[isControlled]
|
|
14702
|
+
);
|
|
14703
|
+
const syncValueState = React55.useCallback(() => {
|
|
14704
|
+
if (!textareaRef.current) return;
|
|
14705
|
+
setNativeValue(textareaRef.current.value);
|
|
14706
|
+
}, [setNativeValue]);
|
|
14707
|
+
React55.useLayoutEffect(() => {
|
|
14708
|
+
syncValueState();
|
|
14709
|
+
});
|
|
14710
|
+
React55.useEffect(() => {
|
|
14711
|
+
const textarea = textareaRef.current;
|
|
14712
|
+
const form = textarea?.form;
|
|
14713
|
+
if (isControlled || !form) return;
|
|
14714
|
+
const handleReset = () => {
|
|
14715
|
+
if (typeof window !== "undefined" && window.requestAnimationFrame) {
|
|
14716
|
+
window.requestAnimationFrame(syncValueState);
|
|
14717
|
+
return;
|
|
14718
|
+
}
|
|
14719
|
+
globalThis.setTimeout(syncValueState, 0);
|
|
14720
|
+
};
|
|
14721
|
+
form.addEventListener("reset", handleReset);
|
|
14722
|
+
return () => form.removeEventListener("reset", handleReset);
|
|
14723
|
+
}, [isControlled, syncValueState]);
|
|
14724
|
+
return {
|
|
14725
|
+
textareaRef,
|
|
14726
|
+
isControlled,
|
|
14727
|
+
isEmpty,
|
|
14728
|
+
setNativeValue,
|
|
14729
|
+
syncValueState
|
|
14730
|
+
};
|
|
14731
|
+
}
|
|
14732
|
+
|
|
14733
|
+
// src/dashboard/textarea/Textarea.tsx
|
|
14627
14734
|
import { jsx as jsx159, jsxs as jsxs104 } from "react/jsx-runtime";
|
|
14628
14735
|
var LINE_HEIGHT = 20;
|
|
14629
14736
|
var VERTICAL_PADDING = 32;
|
|
14630
|
-
|
|
14631
|
-
if (typeof empty === "boolean") return empty;
|
|
14632
|
-
if (value !== void 0) return !String(value);
|
|
14633
|
-
return !defaultValue;
|
|
14634
|
-
}
|
|
14635
|
-
var Textarea = React55.forwardRef(function Textarea2({
|
|
14737
|
+
var Textarea = React56.forwardRef(function Textarea2({
|
|
14636
14738
|
className,
|
|
14637
14739
|
textareaClassName,
|
|
14638
14740
|
label,
|
|
@@ -14653,18 +14755,20 @@ var Textarea = React55.forwardRef(function Textarea2({
|
|
|
14653
14755
|
value,
|
|
14654
14756
|
defaultValue,
|
|
14655
14757
|
onInput,
|
|
14758
|
+
onChange,
|
|
14759
|
+
onFocus,
|
|
14760
|
+
onBlur,
|
|
14656
14761
|
...textareaProps
|
|
14657
14762
|
}, ref) {
|
|
14658
|
-
const
|
|
14659
|
-
const combinedRef = useCombinedRef(ref,
|
|
14660
|
-
const reactId =
|
|
14763
|
+
const { textareaRef, isControlled, isEmpty, setNativeValue, syncValueState } = useTextareaValueState({ empty, value, defaultValue });
|
|
14764
|
+
const combinedRef = useCombinedRef(ref, textareaRef);
|
|
14765
|
+
const reactId = React56.useId();
|
|
14661
14766
|
const textareaId = id ?? name ?? `dash-textarea-${reactId}`;
|
|
14662
14767
|
const { t } = useTranslation36();
|
|
14663
14768
|
const isInvalid = Boolean(invalid || error);
|
|
14664
|
-
const isEmpty = getEmptyState(empty, value, defaultValue);
|
|
14665
14769
|
const isBlocked = Boolean(disabled);
|
|
14666
|
-
const resize =
|
|
14667
|
-
const el =
|
|
14770
|
+
const resize = React56.useCallback(() => {
|
|
14771
|
+
const el = textareaRef.current;
|
|
14668
14772
|
if (!el || !autosize) return;
|
|
14669
14773
|
el.style.height = "auto";
|
|
14670
14774
|
const minHeight = minRows * LINE_HEIGHT + VERTICAL_PADDING;
|
|
@@ -14672,14 +14776,30 @@ var Textarea = React55.forwardRef(function Textarea2({
|
|
|
14672
14776
|
const nextHeight = Math.min(Math.max(el.scrollHeight, minHeight), maxHeight);
|
|
14673
14777
|
el.style.height = `${nextHeight}px`;
|
|
14674
14778
|
el.style.overflowY = el.scrollHeight > nextHeight ? "auto" : "hidden";
|
|
14675
|
-
}, [autosize, maxRows, minRows]);
|
|
14676
|
-
|
|
14779
|
+
}, [autosize, maxRows, minRows, textareaRef]);
|
|
14780
|
+
React56.useLayoutEffect(() => {
|
|
14677
14781
|
resize();
|
|
14678
14782
|
}, [resize, value]);
|
|
14679
14783
|
const handleInput = (event) => {
|
|
14680
14784
|
resize();
|
|
14681
14785
|
onInput?.(event);
|
|
14682
14786
|
};
|
|
14787
|
+
const handleChange = (event) => {
|
|
14788
|
+
if (readOnly || disabled) return;
|
|
14789
|
+
if (!isControlled) {
|
|
14790
|
+
setNativeValue(event.currentTarget.value);
|
|
14791
|
+
}
|
|
14792
|
+
onChange?.(event);
|
|
14793
|
+
};
|
|
14794
|
+
const handleFocus = (event) => {
|
|
14795
|
+
if (readOnly || disabled) return;
|
|
14796
|
+
onFocus?.(event);
|
|
14797
|
+
syncValueState();
|
|
14798
|
+
};
|
|
14799
|
+
const handleBlur = (event) => {
|
|
14800
|
+
onBlur?.(event);
|
|
14801
|
+
syncValueState();
|
|
14802
|
+
};
|
|
14683
14803
|
return /* @__PURE__ */ jsxs104(
|
|
14684
14804
|
"div",
|
|
14685
14805
|
{
|
|
@@ -14715,11 +14835,14 @@ var Textarea = React55.forwardRef(function Textarea2({
|
|
|
14715
14835
|
"aria-invalid": isInvalid,
|
|
14716
14836
|
"aria-busy": loading,
|
|
14717
14837
|
onInput: handleInput,
|
|
14838
|
+
onChange: handleChange,
|
|
14839
|
+
onFocus: handleFocus,
|
|
14840
|
+
onBlur: handleBlur,
|
|
14718
14841
|
className: cn(
|
|
14719
14842
|
"m-0 box-border block w-full resize-none rounded-[6px] border bg-white px-4 py-4 text-[16px] font-medium leading-5 text-[var(--chekin-color-brand-navy)] outline-none transition-colors duration-100 ease-in-out",
|
|
14720
14843
|
"border-[var(--chekin-color-gray-3)] placeholder:font-medium placeholder:text-[var(--chekin-color-gray-1)]",
|
|
14721
14844
|
!isBlocked && "focus:border-[var(--chekin-color-brand-blue)]",
|
|
14722
|
-
isEmpty && "border-[var(--chekin-color-gray-3)] bg-[var(--
|
|
14845
|
+
isEmpty && "border-[var(--chekin-color-gray-3)] bg-[var(--empty-field-background)] text-[var(--chekin-color-gray-1)]",
|
|
14723
14846
|
isInvalid && "border-[var(--error-message-color)] focus:border-[var(--error-message-color)]",
|
|
14724
14847
|
(readOnly || isBlocked) && "cursor-default",
|
|
14725
14848
|
isBlocked && "cursor-not-allowed",
|
|
@@ -14746,12 +14869,12 @@ var Textarea = React55.forwardRef(function Textarea2({
|
|
|
14746
14869
|
});
|
|
14747
14870
|
|
|
14748
14871
|
// src/dashboard/datepicker/Datepicker.tsx
|
|
14749
|
-
import * as
|
|
14872
|
+
import * as React58 from "react";
|
|
14750
14873
|
import { ChevronDown as ChevronDown3 } from "lucide-react";
|
|
14751
14874
|
import { useTranslation as useTranslation37 } from "react-i18next";
|
|
14752
14875
|
|
|
14753
14876
|
// src/airbnb-fields/datepicker/useDatePickerWheel.ts
|
|
14754
|
-
import * as
|
|
14877
|
+
import * as React57 from "react";
|
|
14755
14878
|
|
|
14756
14879
|
// src/airbnb-fields/datepicker/datePicker.utils.ts
|
|
14757
14880
|
var DISPLAY_PAD_LENGTH = 2;
|
|
@@ -14902,21 +15025,21 @@ function useDatePickerWheel({
|
|
|
14902
15025
|
minDate,
|
|
14903
15026
|
maxDate
|
|
14904
15027
|
}) {
|
|
14905
|
-
const years =
|
|
14906
|
-
const [draftDate, setDraftDate] =
|
|
15028
|
+
const years = React57.useMemo(() => getYearRange(minDate, maxDate), [maxDate, minDate]);
|
|
15029
|
+
const [draftDate, setDraftDate] = React57.useState(
|
|
14907
15030
|
() => resolveInitialDate({ value, defaultValue, minDate, maxDate })
|
|
14908
15031
|
);
|
|
14909
15032
|
const draftYear = draftDate.getFullYear();
|
|
14910
15033
|
const draftMonth = draftDate.getMonth();
|
|
14911
|
-
const [monthScrollTop, setMonthScrollTop] =
|
|
14912
|
-
const [dayScrollTop, setDayScrollTop] =
|
|
14913
|
-
const [yearScrollTop, setYearScrollTop] =
|
|
14914
|
-
const monthListRef =
|
|
14915
|
-
const dayListRef =
|
|
14916
|
-
const yearListRef =
|
|
14917
|
-
const settleTimeoutsRef =
|
|
14918
|
-
const animationFramesRef =
|
|
14919
|
-
const columnRefs =
|
|
15034
|
+
const [monthScrollTop, setMonthScrollTop] = React57.useState(0);
|
|
15035
|
+
const [dayScrollTop, setDayScrollTop] = React57.useState(0);
|
|
15036
|
+
const [yearScrollTop, setYearScrollTop] = React57.useState(0);
|
|
15037
|
+
const monthListRef = React57.useRef(null);
|
|
15038
|
+
const dayListRef = React57.useRef(null);
|
|
15039
|
+
const yearListRef = React57.useRef(null);
|
|
15040
|
+
const settleTimeoutsRef = React57.useRef({});
|
|
15041
|
+
const animationFramesRef = React57.useRef({});
|
|
15042
|
+
const columnRefs = React57.useMemo(
|
|
14920
15043
|
() => ({
|
|
14921
15044
|
month: monthListRef,
|
|
14922
15045
|
day: dayListRef,
|
|
@@ -14924,7 +15047,7 @@ function useDatePickerWheel({
|
|
|
14924
15047
|
}),
|
|
14925
15048
|
[]
|
|
14926
15049
|
);
|
|
14927
|
-
const setColumnScrollTop =
|
|
15050
|
+
const setColumnScrollTop = React57.useCallback(
|
|
14928
15051
|
(column, nextScrollTop) => {
|
|
14929
15052
|
if (column === "month") {
|
|
14930
15053
|
setMonthScrollTop(nextScrollTop);
|
|
@@ -14938,19 +15061,19 @@ function useDatePickerWheel({
|
|
|
14938
15061
|
},
|
|
14939
15062
|
[]
|
|
14940
15063
|
);
|
|
14941
|
-
const clearSettleTimeout =
|
|
15064
|
+
const clearSettleTimeout = React57.useCallback((column) => {
|
|
14942
15065
|
const timeoutId = settleTimeoutsRef.current[column];
|
|
14943
15066
|
if (timeoutId === void 0) return;
|
|
14944
15067
|
window.clearTimeout(timeoutId);
|
|
14945
15068
|
delete settleTimeoutsRef.current[column];
|
|
14946
15069
|
}, []);
|
|
14947
|
-
const clearAnimationFrame =
|
|
15070
|
+
const clearAnimationFrame = React57.useCallback((column) => {
|
|
14948
15071
|
const frameId = animationFramesRef.current[column];
|
|
14949
15072
|
if (frameId === void 0) return;
|
|
14950
15073
|
window.cancelAnimationFrame(frameId);
|
|
14951
15074
|
delete animationFramesRef.current[column];
|
|
14952
15075
|
}, []);
|
|
14953
|
-
|
|
15076
|
+
React57.useEffect(
|
|
14954
15077
|
() => () => {
|
|
14955
15078
|
["month", "day", "year"].forEach((column) => {
|
|
14956
15079
|
clearSettleTimeout(column);
|
|
@@ -14959,22 +15082,22 @@ function useDatePickerWheel({
|
|
|
14959
15082
|
},
|
|
14960
15083
|
[clearAnimationFrame, clearSettleTimeout]
|
|
14961
15084
|
);
|
|
14962
|
-
|
|
15085
|
+
React57.useEffect(() => {
|
|
14963
15086
|
if (isOpen) return;
|
|
14964
15087
|
setDraftDate(resolveInitialDate({ value, defaultValue, minDate, maxDate }));
|
|
14965
15088
|
}, [defaultValue, isOpen, maxDate, minDate, value]);
|
|
14966
|
-
const months =
|
|
15089
|
+
const months = React57.useMemo(
|
|
14967
15090
|
() => getAllowedMonths(draftYear, minDate, maxDate),
|
|
14968
15091
|
[draftYear, maxDate, minDate]
|
|
14969
15092
|
);
|
|
14970
|
-
const days =
|
|
15093
|
+
const days = React57.useMemo(
|
|
14971
15094
|
() => getAllowedDays(draftYear, draftMonth, minDate, maxDate),
|
|
14972
15095
|
[draftMonth, draftYear, maxDate, minDate]
|
|
14973
15096
|
);
|
|
14974
15097
|
const monthIndex = months.findIndex((month) => month === draftMonth);
|
|
14975
15098
|
const dayIndex = days.findIndex((day) => day === draftDate.getDate());
|
|
14976
15099
|
const yearIndex = years.findIndex((year) => year === draftYear);
|
|
14977
|
-
const syncScrollPositions =
|
|
15100
|
+
const syncScrollPositions = React57.useCallback(
|
|
14978
15101
|
(nextDate, behavior = "auto") => {
|
|
14979
15102
|
const nextMonths = getAllowedMonths(nextDate.getFullYear(), minDate, maxDate);
|
|
14980
15103
|
const nextMonthIndex = nextMonths.findIndex((month) => month === nextDate.getMonth());
|
|
@@ -14998,7 +15121,7 @@ function useDatePickerWheel({
|
|
|
14998
15121
|
},
|
|
14999
15122
|
[maxDate, minDate, years]
|
|
15000
15123
|
);
|
|
15001
|
-
|
|
15124
|
+
React57.useLayoutEffect(() => {
|
|
15002
15125
|
if (!isOpen) return;
|
|
15003
15126
|
const nextDate = resolveInitialDate({ value, defaultValue, minDate, maxDate });
|
|
15004
15127
|
setDraftDate(nextDate);
|
|
@@ -15009,7 +15132,7 @@ function useDatePickerWheel({
|
|
|
15009
15132
|
window.cancelAnimationFrame(frameId);
|
|
15010
15133
|
};
|
|
15011
15134
|
}, [defaultValue, isOpen, maxDate, minDate, syncScrollPositions, value]);
|
|
15012
|
-
const updateDraftDate =
|
|
15135
|
+
const updateDraftDate = React57.useCallback(
|
|
15013
15136
|
(column, targetIndex, behavior = "smooth") => {
|
|
15014
15137
|
const currentDate = stripTime(draftDate);
|
|
15015
15138
|
const currentYear = currentDate.getFullYear();
|
|
@@ -15054,7 +15177,7 @@ function useDatePickerWheel({
|
|
|
15054
15177
|
},
|
|
15055
15178
|
[days, draftDate, maxDate, minDate, months, syncScrollPositions, years]
|
|
15056
15179
|
);
|
|
15057
|
-
const settleColumnScroll =
|
|
15180
|
+
const settleColumnScroll = React57.useCallback(
|
|
15058
15181
|
(column) => {
|
|
15059
15182
|
const list = columnRefs[column].current;
|
|
15060
15183
|
if (!list) return;
|
|
@@ -15067,7 +15190,7 @@ function useDatePickerWheel({
|
|
|
15067
15190
|
},
|
|
15068
15191
|
[columnRefs, days.length, months.length, updateDraftDate, years.length]
|
|
15069
15192
|
);
|
|
15070
|
-
const scheduleScrollSettle =
|
|
15193
|
+
const scheduleScrollSettle = React57.useCallback(
|
|
15071
15194
|
(column) => {
|
|
15072
15195
|
clearSettleTimeout(column);
|
|
15073
15196
|
settleTimeoutsRef.current[column] = window.setTimeout(() => {
|
|
@@ -15076,7 +15199,7 @@ function useDatePickerWheel({
|
|
|
15076
15199
|
},
|
|
15077
15200
|
[clearSettleTimeout, settleColumnScroll]
|
|
15078
15201
|
);
|
|
15079
|
-
const handleColumnScroll =
|
|
15202
|
+
const handleColumnScroll = React57.useCallback(
|
|
15080
15203
|
(column) => {
|
|
15081
15204
|
const list = columnRefs[column].current;
|
|
15082
15205
|
if (!list) return;
|
|
@@ -15090,13 +15213,13 @@ function useDatePickerWheel({
|
|
|
15090
15213
|
},
|
|
15091
15214
|
[clearAnimationFrame, columnRefs, scheduleScrollSettle, setColumnScrollTop]
|
|
15092
15215
|
);
|
|
15093
|
-
const handleOptionSelect =
|
|
15216
|
+
const handleOptionSelect = React57.useCallback(
|
|
15094
15217
|
(column, targetIndex) => {
|
|
15095
15218
|
updateDraftDate(column, targetIndex, "smooth");
|
|
15096
15219
|
},
|
|
15097
15220
|
[updateDraftDate]
|
|
15098
15221
|
);
|
|
15099
|
-
const focusAdjacentColumn =
|
|
15222
|
+
const focusAdjacentColumn = React57.useCallback(
|
|
15100
15223
|
(column, direction) => {
|
|
15101
15224
|
const order = ["month", "day", "year"];
|
|
15102
15225
|
const currentIndex = order.indexOf(column);
|
|
@@ -15106,7 +15229,7 @@ function useDatePickerWheel({
|
|
|
15106
15229
|
},
|
|
15107
15230
|
[columnRefs]
|
|
15108
15231
|
);
|
|
15109
|
-
const handleColumnKeyDown =
|
|
15232
|
+
const handleColumnKeyDown = React57.useCallback(
|
|
15110
15233
|
(column, event) => {
|
|
15111
15234
|
const currentIndex = column === "month" ? monthIndex : column === "day" ? dayIndex : yearIndex;
|
|
15112
15235
|
const maxIndex = column === "month" ? months.length - 1 : column === "day" ? days.length - 1 : years.length - 1;
|
|
@@ -15428,7 +15551,7 @@ function dateFromParts(day, monthIndex, year) {
|
|
|
15428
15551
|
if (!isValidCalendarDate(yearNum, monthIndex, dayNum)) return null;
|
|
15429
15552
|
return new Date(yearNum, monthIndex, dayNum);
|
|
15430
15553
|
}
|
|
15431
|
-
var Datepicker =
|
|
15554
|
+
var Datepicker = React58.forwardRef(
|
|
15432
15555
|
function Datepicker2({
|
|
15433
15556
|
label,
|
|
15434
15557
|
value,
|
|
@@ -15458,14 +15581,14 @@ var Datepicker = React57.forwardRef(
|
|
|
15458
15581
|
maxDate,
|
|
15459
15582
|
formatValue
|
|
15460
15583
|
}, ref) {
|
|
15461
|
-
const containerRef =
|
|
15462
|
-
const dayInputRef =
|
|
15463
|
-
const monthInputRef =
|
|
15464
|
-
const monthListRef =
|
|
15465
|
-
const yearInputRef =
|
|
15466
|
-
const mobileTriggerRef =
|
|
15467
|
-
const wheelBaseId =
|
|
15468
|
-
const reactId =
|
|
15584
|
+
const containerRef = React58.useRef(null);
|
|
15585
|
+
const dayInputRef = React58.useRef(null);
|
|
15586
|
+
const monthInputRef = React58.useRef(null);
|
|
15587
|
+
const monthListRef = React58.useRef(null);
|
|
15588
|
+
const yearInputRef = React58.useRef(null);
|
|
15589
|
+
const mobileTriggerRef = React58.useRef(null);
|
|
15590
|
+
const wheelBaseId = React58.useId();
|
|
15591
|
+
const reactId = React58.useId();
|
|
15469
15592
|
const baseId = name ?? `dash-datepicker-${reactId}`;
|
|
15470
15593
|
const dayId = `${baseId}-day`;
|
|
15471
15594
|
const monthId = `${baseId}-month`;
|
|
@@ -15473,51 +15596,51 @@ var Datepicker = React57.forwardRef(
|
|
|
15473
15596
|
const labelId = `${baseId}-label`;
|
|
15474
15597
|
const errorId = `${baseId}-error`;
|
|
15475
15598
|
const { t } = useTranslation37();
|
|
15476
|
-
const resolvedMonthLabels =
|
|
15599
|
+
const resolvedMonthLabels = React58.useMemo(
|
|
15477
15600
|
() => monthLabels ?? getMonthLabels2(locale),
|
|
15478
15601
|
[locale, monthLabels]
|
|
15479
15602
|
);
|
|
15480
15603
|
const resolvedMonthPlaceholder = monthPlaceholder ?? t("month");
|
|
15481
15604
|
const resolvedDoneLabel = doneLabel ?? t("done");
|
|
15482
15605
|
const isControlled = value !== void 0;
|
|
15483
|
-
const initialParts =
|
|
15606
|
+
const initialParts = React58.useMemo(
|
|
15484
15607
|
() => partsFromDate(value ?? defaultValue ?? null),
|
|
15485
15608
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
15486
15609
|
[]
|
|
15487
15610
|
);
|
|
15488
|
-
const [day, setDay] =
|
|
15489
|
-
const [monthIndex, setMonthIndex] =
|
|
15611
|
+
const [day, setDay] = React58.useState(initialParts.day);
|
|
15612
|
+
const [monthIndex, setMonthIndex] = React58.useState(
|
|
15490
15613
|
initialParts.monthIndex
|
|
15491
15614
|
);
|
|
15492
|
-
const [year, setYear] =
|
|
15493
|
-
const [isMonthOpen, setIsMonthOpen] =
|
|
15494
|
-
const [isWheelOpen, setIsWheelOpen] =
|
|
15495
|
-
const [focusedField, setFocusedField] =
|
|
15496
|
-
const [monthInputValue, setMonthInputValue] =
|
|
15497
|
-
const [monthHighlightIndex, setMonthHighlightIndex] =
|
|
15615
|
+
const [year, setYear] = React58.useState(initialParts.year);
|
|
15616
|
+
const [isMonthOpen, setIsMonthOpen] = React58.useState(false);
|
|
15617
|
+
const [isWheelOpen, setIsWheelOpen] = React58.useState(false);
|
|
15618
|
+
const [focusedField, setFocusedField] = React58.useState(null);
|
|
15619
|
+
const [monthInputValue, setMonthInputValue] = React58.useState("");
|
|
15620
|
+
const [monthHighlightIndex, setMonthHighlightIndex] = React58.useState(-1);
|
|
15498
15621
|
const isMobile3 = useIsMobile();
|
|
15499
|
-
|
|
15500
|
-
|
|
15622
|
+
React58.useImperativeHandle(ref, () => dayInputRef.current, []);
|
|
15623
|
+
React58.useEffect(() => {
|
|
15501
15624
|
if (!isControlled) return;
|
|
15502
15625
|
const next = partsFromDate(value ?? null);
|
|
15503
15626
|
setDay(next.day);
|
|
15504
15627
|
setMonthIndex(next.monthIndex);
|
|
15505
15628
|
setYear(next.year);
|
|
15506
15629
|
}, [isControlled, value]);
|
|
15507
|
-
|
|
15630
|
+
React58.useEffect(() => {
|
|
15508
15631
|
if (focusedField === "month") return;
|
|
15509
15632
|
setMonthInputValue(
|
|
15510
15633
|
monthIndex !== null ? resolvedMonthLabels[monthIndex] ?? "" : ""
|
|
15511
15634
|
);
|
|
15512
15635
|
}, [monthIndex, resolvedMonthLabels, focusedField]);
|
|
15513
|
-
const filteredMonths =
|
|
15636
|
+
const filteredMonths = React58.useMemo(() => {
|
|
15514
15637
|
const all = resolvedMonthLabels.map((label2, index) => ({ label: label2, index }));
|
|
15515
15638
|
const query = monthInputValue.trim().toLowerCase();
|
|
15516
15639
|
const currentLabel = monthIndex !== null ? resolvedMonthLabels[monthIndex] ?? "" : "";
|
|
15517
15640
|
if (!query || monthInputValue === currentLabel) return all;
|
|
15518
15641
|
return all.filter((opt) => opt.label.toLowerCase().includes(query));
|
|
15519
15642
|
}, [monthInputValue, monthIndex, resolvedMonthLabels]);
|
|
15520
|
-
|
|
15643
|
+
React58.useEffect(() => {
|
|
15521
15644
|
if (!isMonthOpen) {
|
|
15522
15645
|
setMonthHighlightIndex(-1);
|
|
15523
15646
|
return;
|
|
@@ -15538,7 +15661,7 @@ var Datepicker = React57.forwardRef(
|
|
|
15538
15661
|
const isFocused = focusedField !== null || isMonthOpen || isWheelOpen;
|
|
15539
15662
|
const isInvalid = Boolean(invalid || error);
|
|
15540
15663
|
const wrapperWidth = toCssSize(width);
|
|
15541
|
-
const currentDate =
|
|
15664
|
+
const currentDate = React58.useMemo(
|
|
15542
15665
|
() => dateFromParts(day, monthIndex, year),
|
|
15543
15666
|
[day, monthIndex, year]
|
|
15544
15667
|
);
|
|
@@ -15547,7 +15670,7 @@ var Datepicker = React57.forwardRef(
|
|
|
15547
15670
|
onOutsideClick: () => setIsMonthOpen(false),
|
|
15548
15671
|
isDisabled: !isMonthOpen || isMobile3
|
|
15549
15672
|
});
|
|
15550
|
-
const emitChange =
|
|
15673
|
+
const emitChange = React58.useCallback(
|
|
15551
15674
|
(nextDay, nextMonth, nextYear) => {
|
|
15552
15675
|
if (!onChange) return;
|
|
15553
15676
|
const date = dateFromParts(nextDay, nextMonth, nextYear);
|
|
@@ -15582,7 +15705,7 @@ var Datepicker = React57.forwardRef(
|
|
|
15582
15705
|
setIsMonthOpen(true);
|
|
15583
15706
|
setMonthHighlightIndex(0);
|
|
15584
15707
|
};
|
|
15585
|
-
const commitMonthInput =
|
|
15708
|
+
const commitMonthInput = React58.useCallback(() => {
|
|
15586
15709
|
const query = monthInputValue.trim().toLowerCase();
|
|
15587
15710
|
if (!query) {
|
|
15588
15711
|
if (monthIndex !== null) {
|
|
@@ -15642,15 +15765,15 @@ var Datepicker = React57.forwardRef(
|
|
|
15642
15765
|
setIsMonthOpen(false);
|
|
15643
15766
|
}
|
|
15644
15767
|
};
|
|
15645
|
-
const focusDayInput =
|
|
15768
|
+
const focusDayInput = React58.useCallback(() => {
|
|
15646
15769
|
if (isBlocked || readOnly) return;
|
|
15647
15770
|
dayInputRef.current?.focus();
|
|
15648
15771
|
}, [isBlocked, readOnly]);
|
|
15649
|
-
const openWheel =
|
|
15772
|
+
const openWheel = React58.useCallback(() => {
|
|
15650
15773
|
if (isBlocked || readOnly) return;
|
|
15651
15774
|
setIsWheelOpen(true);
|
|
15652
15775
|
}, [isBlocked, readOnly]);
|
|
15653
|
-
const closeWheel =
|
|
15776
|
+
const closeWheel = React58.useCallback(() => {
|
|
15654
15777
|
setIsWheelOpen(false);
|
|
15655
15778
|
mobileTriggerRef.current?.focus();
|
|
15656
15779
|
}, []);
|
|
@@ -15662,7 +15785,7 @@ var Datepicker = React57.forwardRef(
|
|
|
15662
15785
|
minDate,
|
|
15663
15786
|
maxDate
|
|
15664
15787
|
});
|
|
15665
|
-
const handleWheelDone =
|
|
15788
|
+
const handleWheelDone = React58.useCallback(() => {
|
|
15666
15789
|
const next = wheel.draftDate;
|
|
15667
15790
|
setDay(String(next.getDate()));
|
|
15668
15791
|
setMonthIndex(next.getMonth());
|
|
@@ -15671,7 +15794,7 @@ var Datepicker = React57.forwardRef(
|
|
|
15671
15794
|
setIsWheelOpen(false);
|
|
15672
15795
|
mobileTriggerRef.current?.focus();
|
|
15673
15796
|
}, [name, onChange, wheel.draftDate]);
|
|
15674
|
-
const defaultFormatValue =
|
|
15797
|
+
const defaultFormatValue = React58.useCallback(
|
|
15675
15798
|
(date) => `${date.getDate()} ${resolvedMonthLabels[date.getMonth()]} ${date.getFullYear()}`,
|
|
15676
15799
|
[resolvedMonthLabels]
|
|
15677
15800
|
);
|
|
@@ -15723,11 +15846,11 @@ var Datepicker = React57.forwardRef(
|
|
|
15723
15846
|
className: cn(
|
|
15724
15847
|
"relative w-full max-w-[var(--field-max-width,296px)]",
|
|
15725
15848
|
disabled && "cursor-not-allowed opacity-50",
|
|
15726
|
-
loading && "cursor-progress",
|
|
15849
|
+
loading && "cursor-progress opacity-50",
|
|
15727
15850
|
className
|
|
15728
15851
|
),
|
|
15729
15852
|
style: wrapperWidth ? { width: wrapperWidth } : void 0,
|
|
15730
|
-
children: /* @__PURE__ */ jsxs107("div", { className: "relative min-h-[
|
|
15853
|
+
children: /* @__PURE__ */ jsxs107("div", { className: "relative min-h-[var(--field-min-height,48px)] w-full", children: [
|
|
15731
15854
|
/* @__PURE__ */ jsxs107("div", { className: "relative w-full", children: [
|
|
15732
15855
|
isMobile3 ? /* @__PURE__ */ jsxs107(
|
|
15733
15856
|
"button",
|
|
@@ -15744,24 +15867,21 @@ var Datepicker = React57.forwardRef(
|
|
|
15744
15867
|
onClick: openWheel,
|
|
15745
15868
|
className: cn(
|
|
15746
15869
|
"relative m-0 box-border flex h-12 w-full cursor-pointer items-center justify-between gap-2 rounded-[6px] border-0 px-4 text-left text-[16px] font-medium leading-5 outline-none transition-colors duration-200",
|
|
15747
|
-
triggerText ? "bg-transparent text-[var(--chekin-color-brand-navy)]" : "bg-[var(--
|
|
15870
|
+
triggerText ? "bg-transparent text-[var(--chekin-color-brand-navy)]" : "bg-[var(--empty-field-background)] text-[var(--chekin-color-gray-1)]",
|
|
15748
15871
|
(isBlocked || readOnly) && "cursor-not-allowed"
|
|
15749
15872
|
),
|
|
15750
15873
|
children: [
|
|
15751
15874
|
/* @__PURE__ */ jsx162("span", { className: "block min-w-0 flex-1 truncate text-left", children: triggerText ?? (isWheelOpen ? mobilePlaceholder : null) }),
|
|
15752
|
-
/* @__PURE__ */
|
|
15753
|
-
|
|
15754
|
-
|
|
15755
|
-
|
|
15756
|
-
|
|
15757
|
-
|
|
15758
|
-
|
|
15759
|
-
|
|
15760
|
-
|
|
15761
|
-
|
|
15762
|
-
}
|
|
15763
|
-
)
|
|
15764
|
-
] })
|
|
15875
|
+
/* @__PURE__ */ jsx162("span", { className: "pointer-events-none flex items-center gap-2 text-[var(--chekin-color-gray-2)]", children: /* @__PURE__ */ jsx162(
|
|
15876
|
+
ChevronDown3,
|
|
15877
|
+
{
|
|
15878
|
+
size: 16,
|
|
15879
|
+
className: cn(
|
|
15880
|
+
"transition-transform duration-200",
|
|
15881
|
+
isWheelOpen && "rotate-180 text-[var(--chekin-color-brand-blue)]"
|
|
15882
|
+
)
|
|
15883
|
+
}
|
|
15884
|
+
) })
|
|
15765
15885
|
]
|
|
15766
15886
|
}
|
|
15767
15887
|
) : /* @__PURE__ */ jsxs107(
|
|
@@ -15854,45 +15974,35 @@ var Datepicker = React57.forwardRef(
|
|
|
15854
15974
|
}
|
|
15855
15975
|
)
|
|
15856
15976
|
] }),
|
|
15857
|
-
/* @__PURE__ */
|
|
15858
|
-
|
|
15859
|
-
|
|
15860
|
-
|
|
15861
|
-
|
|
15862
|
-
|
|
15863
|
-
|
|
15864
|
-
|
|
15865
|
-
|
|
15866
|
-
|
|
15867
|
-
|
|
15868
|
-
|
|
15869
|
-
|
|
15870
|
-
|
|
15871
|
-
|
|
15872
|
-
|
|
15873
|
-
|
|
15874
|
-
|
|
15875
|
-
|
|
15876
|
-
|
|
15877
|
-
|
|
15878
|
-
|
|
15879
|
-
),
|
|
15880
|
-
loading && /* @__PURE__ */ jsx162(
|
|
15881
|
-
ThreeDotsLoader,
|
|
15882
|
-
{
|
|
15883
|
-
height: 18,
|
|
15884
|
-
width: 18,
|
|
15885
|
-
className: "ml-2 text-[var(--chekin-color-gray-2)]"
|
|
15886
|
-
}
|
|
15887
|
-
)
|
|
15888
|
-
] })
|
|
15977
|
+
/* @__PURE__ */ jsx162("div", { className: "flex h-full min-w-0 items-center px-2 sm:px-4", children: /* @__PURE__ */ jsx162(
|
|
15978
|
+
"input",
|
|
15979
|
+
{
|
|
15980
|
+
ref: yearInputRef,
|
|
15981
|
+
id: yearId,
|
|
15982
|
+
type: "text",
|
|
15983
|
+
inputMode: "numeric",
|
|
15984
|
+
autoComplete: "off",
|
|
15985
|
+
name: name ? `${name}-year` : void 0,
|
|
15986
|
+
value: year,
|
|
15987
|
+
placeholder: yearPlaceholder,
|
|
15988
|
+
disabled: isBlocked,
|
|
15989
|
+
readOnly,
|
|
15990
|
+
"aria-invalid": isInvalid,
|
|
15991
|
+
"aria-labelledby": labelId,
|
|
15992
|
+
onChange: handleYearChange,
|
|
15993
|
+
onFocus: () => setFocusedField("year"),
|
|
15994
|
+
onBlur: () => setFocusedField(null),
|
|
15995
|
+
maxLength: 4,
|
|
15996
|
+
className: subInputClass
|
|
15997
|
+
}
|
|
15998
|
+
) })
|
|
15889
15999
|
]
|
|
15890
16000
|
}
|
|
15891
16001
|
),
|
|
15892
16002
|
showCoverage && /* @__PURE__ */ jsx162(
|
|
15893
16003
|
"div",
|
|
15894
16004
|
{
|
|
15895
|
-
className: "absolute inset-0 cursor-text rounded-[6px] bg-[var(--
|
|
16005
|
+
className: "absolute inset-0 cursor-text rounded-[6px] bg-[var(--empty-field-background)]",
|
|
15896
16006
|
onClick: focusDayInput,
|
|
15897
16007
|
"aria-hidden": "true"
|
|
15898
16008
|
}
|
|
@@ -15962,7 +16072,7 @@ var Datepicker = React57.forwardRef(
|
|
|
15962
16072
|
);
|
|
15963
16073
|
|
|
15964
16074
|
// src/dashboard/date-range-picker/DateRangePicker.tsx
|
|
15965
|
-
import * as
|
|
16075
|
+
import * as React62 from "react";
|
|
15966
16076
|
import { useTranslation as useTranslation38 } from "react-i18next";
|
|
15967
16077
|
|
|
15968
16078
|
// src/dashboard/date-range-picker/isDayBlocked.ts
|
|
@@ -16041,7 +16151,7 @@ var createDisabledMatchers = ({
|
|
|
16041
16151
|
};
|
|
16042
16152
|
|
|
16043
16153
|
// src/dashboard/date-range-picker/hooks/useRangeValue.ts
|
|
16044
|
-
import * as
|
|
16154
|
+
import * as React59 from "react";
|
|
16045
16155
|
var getRangeKey = (range) => `${range?.from?.getTime() ?? ""}-${range?.to?.getTime() ?? ""}`;
|
|
16046
16156
|
function useRangeValue({
|
|
16047
16157
|
value: externalValue,
|
|
@@ -16050,10 +16160,10 @@ function useRangeValue({
|
|
|
16050
16160
|
name
|
|
16051
16161
|
}) {
|
|
16052
16162
|
const isControlled = externalValue !== void 0;
|
|
16053
|
-
const [draft, setDraft] =
|
|
16163
|
+
const [draft, setDraft] = React59.useState(
|
|
16054
16164
|
isControlled ? externalValue : defaultValue
|
|
16055
16165
|
);
|
|
16056
|
-
const lastExternalKeyRef =
|
|
16166
|
+
const lastExternalKeyRef = React59.useRef(getRangeKey(externalValue));
|
|
16057
16167
|
if (isControlled) {
|
|
16058
16168
|
const externalKey = getRangeKey(externalValue);
|
|
16059
16169
|
if (externalKey !== lastExternalKeyRef.current) {
|
|
@@ -16061,7 +16171,7 @@ function useRangeValue({
|
|
|
16061
16171
|
setDraft(externalValue);
|
|
16062
16172
|
}
|
|
16063
16173
|
}
|
|
16064
|
-
const commit =
|
|
16174
|
+
const commit = React59.useCallback(
|
|
16065
16175
|
(next) => {
|
|
16066
16176
|
setDraft(next);
|
|
16067
16177
|
if (next === void 0) {
|
|
@@ -16076,7 +16186,7 @@ function useRangeValue({
|
|
|
16076
16186
|
}
|
|
16077
16187
|
|
|
16078
16188
|
// src/dashboard/date-range-picker/hooks/useRangeTextInputs.ts
|
|
16079
|
-
import * as
|
|
16189
|
+
import * as React60 from "react";
|
|
16080
16190
|
function useRangeTextInputs({
|
|
16081
16191
|
value,
|
|
16082
16192
|
format: format2,
|
|
@@ -16084,13 +16194,13 @@ function useRangeTextInputs({
|
|
|
16084
16194
|
onCommit,
|
|
16085
16195
|
onBlur
|
|
16086
16196
|
}) {
|
|
16087
|
-
const [fromText, setFromText] =
|
|
16088
|
-
const [toText, setToText] =
|
|
16089
|
-
|
|
16197
|
+
const [fromText, setFromText] = React60.useState(value?.from ? format2(value.from) : "");
|
|
16198
|
+
const [toText, setToText] = React60.useState(value?.to ? format2(value.to) : "");
|
|
16199
|
+
React60.useEffect(() => {
|
|
16090
16200
|
setFromText(value?.from ? format2(value.from) : "");
|
|
16091
16201
|
setToText(value?.to ? format2(value.to) : "");
|
|
16092
16202
|
}, [format2, value?.from, value?.to]);
|
|
16093
|
-
const handleFromBlur =
|
|
16203
|
+
const handleFromBlur = React60.useCallback(() => {
|
|
16094
16204
|
if (!fromText) {
|
|
16095
16205
|
const next = { from: void 0, to: value?.to };
|
|
16096
16206
|
onCommit(next);
|
|
@@ -16107,7 +16217,7 @@ function useRangeTextInputs({
|
|
|
16107
16217
|
setFromText(value?.from ? format2(value.from) : "");
|
|
16108
16218
|
return void 0;
|
|
16109
16219
|
}, [format2, fromText, onBlur, onCommit, parse3, value]);
|
|
16110
|
-
const handleToBlur =
|
|
16220
|
+
const handleToBlur = React60.useCallback(() => {
|
|
16111
16221
|
if (!toText) {
|
|
16112
16222
|
const next = { from: value?.from, to: void 0 };
|
|
16113
16223
|
onCommit(next);
|
|
@@ -16134,21 +16244,21 @@ function useRangeTextInputs({
|
|
|
16134
16244
|
}
|
|
16135
16245
|
|
|
16136
16246
|
// src/dashboard/date-range-picker/hooks/useRangeMonthSync.ts
|
|
16137
|
-
import * as
|
|
16247
|
+
import * as React61 from "react";
|
|
16138
16248
|
function useRangeMonthSync(value) {
|
|
16139
|
-
const isPreloadedRef =
|
|
16140
|
-
const [month, setMonth] =
|
|
16141
|
-
|
|
16249
|
+
const isPreloadedRef = React61.useRef(false);
|
|
16250
|
+
const [month, setMonth] = React61.useState(value?.from ?? /* @__PURE__ */ new Date());
|
|
16251
|
+
React61.useEffect(() => {
|
|
16142
16252
|
if (value?.from && !isPreloadedRef.current) {
|
|
16143
16253
|
setMonth(value.from);
|
|
16144
16254
|
isPreloadedRef.current = true;
|
|
16145
16255
|
}
|
|
16146
16256
|
}, [value?.from]);
|
|
16147
|
-
const syncMonthToValue =
|
|
16257
|
+
const syncMonthToValue = React61.useCallback((next) => {
|
|
16148
16258
|
isPreloadedRef.current = true;
|
|
16149
16259
|
if (next?.from) setMonth(next.from);
|
|
16150
16260
|
}, []);
|
|
16151
|
-
const resetPreload =
|
|
16261
|
+
const resetPreload = React61.useCallback(() => {
|
|
16152
16262
|
isPreloadedRef.current = false;
|
|
16153
16263
|
}, []);
|
|
16154
16264
|
return { month, setMonth, syncMonthToValue, resetPreload };
|
|
@@ -16221,7 +16331,7 @@ function DateRangeInputs({
|
|
|
16221
16331
|
{
|
|
16222
16332
|
className: cn(
|
|
16223
16333
|
"relative box-border flex h-12 w-full items-center rounded-[6px] pr-2 text-[16px] font-medium text-[var(--chekin-color-brand-navy)] transition-colors duration-200",
|
|
16224
|
-
isEmpty && !isFocused && "bg-[var(--
|
|
16334
|
+
isEmpty && !isFocused && "bg-[var(--empty-field-background)]"
|
|
16225
16335
|
),
|
|
16226
16336
|
onClick: onRowClick,
|
|
16227
16337
|
children: [
|
|
@@ -16285,7 +16395,6 @@ function DateRangeInputs({
|
|
|
16285
16395
|
}
|
|
16286
16396
|
),
|
|
16287
16397
|
/* @__PURE__ */ jsxs108("span", { className: "ml-auto flex shrink-0 items-center gap-2 pl-2 text-[var(--chekin-color-gray-2)]", children: [
|
|
16288
|
-
loading && /* @__PURE__ */ jsx163(ThreeDotsLoader, { height: 18, width: 18 }),
|
|
16289
16398
|
!readOnly && !hideClearDates && !isEmpty && /* @__PURE__ */ jsx163(
|
|
16290
16399
|
"button",
|
|
16291
16400
|
{
|
|
@@ -16407,7 +16516,7 @@ function DateRangePopover({
|
|
|
16407
16516
|
|
|
16408
16517
|
// src/dashboard/date-range-picker/DateRangePicker.tsx
|
|
16409
16518
|
import { jsx as jsx166, jsxs as jsxs110 } from "react/jsx-runtime";
|
|
16410
|
-
var DateRangePicker =
|
|
16519
|
+
var DateRangePicker = React62.forwardRef(function DateRangePicker2({
|
|
16411
16520
|
label,
|
|
16412
16521
|
value: externalValue,
|
|
16413
16522
|
defaultValue,
|
|
@@ -16441,20 +16550,20 @@ var DateRangePicker = React61.forwardRef(function DateRangePicker2({
|
|
|
16441
16550
|
components: customComponents,
|
|
16442
16551
|
...dayPickerProps
|
|
16443
16552
|
}, ref) {
|
|
16444
|
-
const containerRef =
|
|
16445
|
-
const fromInputRef =
|
|
16446
|
-
const toInputRef =
|
|
16447
|
-
const reactId =
|
|
16553
|
+
const containerRef = React62.useRef(null);
|
|
16554
|
+
const fromInputRef = React62.useRef(null);
|
|
16555
|
+
const toInputRef = React62.useRef(null);
|
|
16556
|
+
const reactId = React62.useId();
|
|
16448
16557
|
const baseId = name ?? `dash-daterange-${reactId}`;
|
|
16449
16558
|
const fromId = `${baseId}-from`;
|
|
16450
16559
|
const toId = `${baseId}-to`;
|
|
16451
16560
|
const labelId = `${baseId}-label`;
|
|
16452
16561
|
const errorId = `${baseId}-error`;
|
|
16453
|
-
const normalizedValue =
|
|
16562
|
+
const normalizedValue = React62.useMemo(() => {
|
|
16454
16563
|
if (externalValue === void 0) return void 0;
|
|
16455
16564
|
return { from: toDate(externalValue?.from), to: toDate(externalValue?.to) };
|
|
16456
16565
|
}, [externalValue]);
|
|
16457
|
-
const normalizedDefaultValue =
|
|
16566
|
+
const normalizedDefaultValue = React62.useMemo(() => {
|
|
16458
16567
|
if (defaultValue === void 0) return void 0;
|
|
16459
16568
|
return { from: toDate(defaultValue?.from), to: toDate(defaultValue?.to) };
|
|
16460
16569
|
}, [defaultValue]);
|
|
@@ -16464,10 +16573,10 @@ var DateRangePicker = React61.forwardRef(function DateRangePicker2({
|
|
|
16464
16573
|
onChange,
|
|
16465
16574
|
name
|
|
16466
16575
|
});
|
|
16467
|
-
const normalizedMinDate =
|
|
16468
|
-
const normalizedMaxDate =
|
|
16469
|
-
const formatter =
|
|
16470
|
-
const parser =
|
|
16576
|
+
const normalizedMinDate = React62.useMemo(() => toDate(minDate), [minDate]);
|
|
16577
|
+
const normalizedMaxDate = React62.useMemo(() => toDate(maxDate), [maxDate]);
|
|
16578
|
+
const formatter = React62.useMemo(() => formatDate(displayFormat), [displayFormat]);
|
|
16579
|
+
const parser = React62.useMemo(() => parseDate(displayFormat), [displayFormat]);
|
|
16471
16580
|
const { fromText, toText, setFromText, setToText, handleFromBlur, handleToBlur } = useRangeTextInputs({
|
|
16472
16581
|
value,
|
|
16473
16582
|
format: formatter,
|
|
@@ -16476,9 +16585,9 @@ var DateRangePicker = React61.forwardRef(function DateRangePicker2({
|
|
|
16476
16585
|
onBlur
|
|
16477
16586
|
});
|
|
16478
16587
|
const { month, setMonth, syncMonthToValue } = useRangeMonthSync(value);
|
|
16479
|
-
const [isOpen, setIsOpen] =
|
|
16480
|
-
const [focusedInput, setFocusedInput] =
|
|
16481
|
-
const [autoFocus, setAutoFocus] =
|
|
16588
|
+
const [isOpen, setIsOpen] = React62.useState(false);
|
|
16589
|
+
const [focusedInput, setFocusedInput] = React62.useState(null);
|
|
16590
|
+
const [autoFocus, setAutoFocus] = React62.useState(false);
|
|
16482
16591
|
const isMobile3 = useIsMobile();
|
|
16483
16592
|
const { t } = useTranslation38();
|
|
16484
16593
|
const drawerTitle = label ?? t("select_dates");
|
|
@@ -16489,13 +16598,13 @@ var DateRangePicker = React61.forwardRef(function DateRangePicker2({
|
|
|
16489
16598
|
const isFocused = focusedInput !== null || isOpen;
|
|
16490
16599
|
const wrapperWidth = toCssSize(width);
|
|
16491
16600
|
const monthsToShow = numberOfMonths ?? (isMobile3 ? 1 : 2);
|
|
16492
|
-
const closeCalendar =
|
|
16601
|
+
const closeCalendar = React62.useCallback(() => {
|
|
16493
16602
|
setIsOpen(false);
|
|
16494
16603
|
setFocusedInput(null);
|
|
16495
16604
|
setAutoFocus(false);
|
|
16496
16605
|
if (value?.from) setMonth(value.from);
|
|
16497
16606
|
}, [setMonth, value?.from]);
|
|
16498
|
-
const openCalendar =
|
|
16607
|
+
const openCalendar = React62.useCallback(() => {
|
|
16499
16608
|
if (isBlocked || readOnly) return;
|
|
16500
16609
|
setIsOpen(true);
|
|
16501
16610
|
}, [isBlocked, readOnly]);
|
|
@@ -16504,7 +16613,7 @@ var DateRangePicker = React61.forwardRef(function DateRangePicker2({
|
|
|
16504
16613
|
onOutsideClick: closeCalendar,
|
|
16505
16614
|
isDisabled: !isOpen || isMobile3
|
|
16506
16615
|
});
|
|
16507
|
-
const handlePickerChange =
|
|
16616
|
+
const handlePickerChange = React62.useCallback(
|
|
16508
16617
|
(range, pickedDate) => {
|
|
16509
16618
|
const { next, shouldClose } = resolveRangeSelection({
|
|
16510
16619
|
previous: value,
|
|
@@ -16525,7 +16634,7 @@ var DateRangePicker = React61.forwardRef(function DateRangePicker2({
|
|
|
16525
16634
|
setToText("");
|
|
16526
16635
|
setMonth(/* @__PURE__ */ new Date());
|
|
16527
16636
|
};
|
|
16528
|
-
const disabledMatchers =
|
|
16637
|
+
const disabledMatchers = React62.useMemo(
|
|
16529
16638
|
() => createDisabledMatchers({
|
|
16530
16639
|
minDate: normalizedMinDate,
|
|
16531
16640
|
maxDate: normalizedMaxDate,
|
|
@@ -16544,7 +16653,7 @@ var DateRangePicker = React61.forwardRef(function DateRangePicker2({
|
|
|
16544
16653
|
openCalendar();
|
|
16545
16654
|
if (autoFocusOnOpen) setAutoFocus(true);
|
|
16546
16655
|
};
|
|
16547
|
-
|
|
16656
|
+
React62.useImperativeHandle(
|
|
16548
16657
|
ref,
|
|
16549
16658
|
() => ({
|
|
16550
16659
|
setDateRange: (range) => {
|
|
@@ -16574,11 +16683,11 @@ var DateRangePicker = React61.forwardRef(function DateRangePicker2({
|
|
|
16574
16683
|
className: cn(
|
|
16575
16684
|
"relative w-full max-w-[var(--field-max-width,296px)]",
|
|
16576
16685
|
disabled && "cursor-not-allowed opacity-50",
|
|
16577
|
-
loading && "cursor-progress",
|
|
16686
|
+
loading && "cursor-progress opacity-50",
|
|
16578
16687
|
className
|
|
16579
16688
|
),
|
|
16580
16689
|
style: wrapperWidth ? { width: wrapperWidth } : void 0,
|
|
16581
|
-
children: /* @__PURE__ */ jsxs110("div", { className: "relative min-h-[
|
|
16690
|
+
children: /* @__PURE__ */ jsxs110("div", { className: "relative min-h-[var(--field-min-height,48px)] w-full", children: [
|
|
16582
16691
|
/* @__PURE__ */ jsxs110("div", { className: "relative w-full", children: [
|
|
16583
16692
|
/* @__PURE__ */ jsx166(
|
|
16584
16693
|
DateRangeInputs,
|
|
@@ -16723,7 +16832,7 @@ var DateRangePicker = React61.forwardRef(function DateRangePicker2({
|
|
|
16723
16832
|
});
|
|
16724
16833
|
|
|
16725
16834
|
// src/dashboard/date-range-picker/useValidateDates.ts
|
|
16726
|
-
import * as
|
|
16835
|
+
import * as React63 from "react";
|
|
16727
16836
|
import { useTranslation as useTranslation39 } from "react-i18next";
|
|
16728
16837
|
import { differenceInDays as differenceInDays2, isAfter as isAfter2, isBefore as isBefore3 } from "date-fns";
|
|
16729
16838
|
import {
|
|
@@ -16749,11 +16858,11 @@ function useValidateDates({
|
|
|
16749
16858
|
const { t } = useTranslation39();
|
|
16750
16859
|
const handleError = useEvent(onError);
|
|
16751
16860
|
const handleSuccess = useEvent(onSuccess);
|
|
16752
|
-
const errorFormatter =
|
|
16861
|
+
const errorFormatter = React63.useMemo(
|
|
16753
16862
|
() => formatDate(displayFormat ?? DEFAULT_DISPLAY_FORMAT),
|
|
16754
16863
|
[displayFormat]
|
|
16755
16864
|
);
|
|
16756
|
-
const validateDates =
|
|
16865
|
+
const validateDates = React63.useCallback(
|
|
16757
16866
|
(dates) => {
|
|
16758
16867
|
const startDate = dates?.from;
|
|
16759
16868
|
const endDate = dates?.to;
|
|
@@ -16803,7 +16912,7 @@ function useValidateDates({
|
|
|
16803
16912
|
}
|
|
16804
16913
|
|
|
16805
16914
|
// src/dashboard/time-picker/TimePicker.tsx
|
|
16806
|
-
import * as
|
|
16915
|
+
import * as React64 from "react";
|
|
16807
16916
|
import { addDays, addHours, addMinutes, format, parse as parse2 } from "date-fns";
|
|
16808
16917
|
import { jsx as jsx167 } from "react/jsx-runtime";
|
|
16809
16918
|
var SHORT_TIME_FORMAT = "HH:mm";
|
|
@@ -16847,8 +16956,8 @@ var FORMAT_SETTINGS = {
|
|
|
16847
16956
|
},
|
|
16848
16957
|
hours: { intervalUnit: "H", interval: 1, minTime: "00:00", maxTime: "23:00" }
|
|
16849
16958
|
};
|
|
16850
|
-
var TimePicker =
|
|
16851
|
-
const resolvedOptions =
|
|
16959
|
+
var TimePicker = React64.forwardRef(function TimePicker2({ format: formatName = "time", timeSettings, options, ...selectProps }, ref) {
|
|
16960
|
+
const resolvedOptions = React64.useMemo(() => {
|
|
16852
16961
|
if (options) return options;
|
|
16853
16962
|
const settings = timeSettings ?? FORMAT_SETTINGS[formatName];
|
|
16854
16963
|
return buildOptions(settings);
|
|
@@ -16857,14 +16966,14 @@ var TimePicker = React63.forwardRef(function TimePicker2({ format: formatName =
|
|
|
16857
16966
|
});
|
|
16858
16967
|
|
|
16859
16968
|
// src/dashboard/file-input/FileInput.tsx
|
|
16860
|
-
import * as
|
|
16969
|
+
import * as React65 from "react";
|
|
16861
16970
|
import { Download, Paperclip, SquareX as SquareX5 } from "lucide-react";
|
|
16862
16971
|
import { useTranslation as useTranslation40 } from "react-i18next";
|
|
16863
16972
|
import { jsx as jsx168, jsxs as jsxs111 } from "react/jsx-runtime";
|
|
16864
16973
|
function defaultDownload(url) {
|
|
16865
16974
|
window.open(url, "_blank", "noopener,noreferrer");
|
|
16866
16975
|
}
|
|
16867
|
-
var FileInput =
|
|
16976
|
+
var FileInput = React65.forwardRef(function FileInput2({
|
|
16868
16977
|
label,
|
|
16869
16978
|
value,
|
|
16870
16979
|
onChange,
|
|
@@ -16886,12 +16995,12 @@ var FileInput = React64.forwardRef(function FileInput2({
|
|
|
16886
16995
|
width,
|
|
16887
16996
|
downloadLabel
|
|
16888
16997
|
}, ref) {
|
|
16889
|
-
const internalRef =
|
|
16998
|
+
const internalRef = React65.useRef(null);
|
|
16890
16999
|
const inputRef = useCombinedRef(ref, internalRef);
|
|
16891
17000
|
const { t } = useTranslation40();
|
|
16892
17001
|
const resolvedLabel = label ?? t("upload_file");
|
|
16893
17002
|
const resolvedDownloadLabel = downloadLabel ?? t("download_attachment");
|
|
16894
|
-
const reactId =
|
|
17003
|
+
const reactId = React65.useId();
|
|
16895
17004
|
const inputId = `${name || "dash-file"}-${reactId}`;
|
|
16896
17005
|
const labelId = `${inputId}-label`;
|
|
16897
17006
|
const errorId = `${inputId}-error`;
|
|
@@ -16924,7 +17033,7 @@ var FileInput = React64.forwardRef(function FileInput2({
|
|
|
16924
17033
|
className: cn(
|
|
16925
17034
|
"relative block w-full max-w-[var(--field-max-width,296px)] cursor-pointer text-left",
|
|
16926
17035
|
(disabled || readOnly) && "cursor-not-allowed",
|
|
16927
|
-
loading && "cursor-progress",
|
|
17036
|
+
loading && "cursor-progress opacity-50",
|
|
16928
17037
|
disabled && "opacity-50",
|
|
16929
17038
|
className
|
|
16930
17039
|
),
|
|
@@ -16946,14 +17055,14 @@ var FileInput = React64.forwardRef(function FileInput2({
|
|
|
16946
17055
|
"aria-invalid": isInvalid
|
|
16947
17056
|
}
|
|
16948
17057
|
),
|
|
16949
|
-
/* @__PURE__ */ jsxs111("div", { className: "relative
|
|
17058
|
+
/* @__PURE__ */ jsxs111("div", { className: "relative w-full", children: [
|
|
16950
17059
|
/* @__PURE__ */ jsxs111("div", { className: "relative w-full", children: [
|
|
16951
17060
|
/* @__PURE__ */ jsxs111(
|
|
16952
17061
|
"div",
|
|
16953
17062
|
{
|
|
16954
17063
|
className: cn(
|
|
16955
17064
|
"relative box-border flex h-12 w-full items-center justify-between gap-2 rounded-[6px] px-4 text-[16px] font-medium text-[var(--chekin-color-brand-navy)]",
|
|
16956
|
-
isEmpty && "bg-[var(--
|
|
17065
|
+
isEmpty && "bg-[var(--empty-field-background)]"
|
|
16957
17066
|
),
|
|
16958
17067
|
children: [
|
|
16959
17068
|
hasFileChip ? /* @__PURE__ */ jsxs111(
|
|
@@ -16988,10 +17097,7 @@ var FileInput = React64.forwardRef(function FileInput2({
|
|
|
16988
17097
|
]
|
|
16989
17098
|
}
|
|
16990
17099
|
) : /* @__PURE__ */ jsx168("span", { className: "block min-w-0 flex-1 truncate text-left text-[var(--chekin-color-gray-1)]", children: placeholder ?? "" }),
|
|
16991
|
-
/* @__PURE__ */
|
|
16992
|
-
loading && /* @__PURE__ */ jsx168(ThreeDotsLoader, { height: 18, width: 18 }),
|
|
16993
|
-
/* @__PURE__ */ jsx168(Paperclip, { size: 20 })
|
|
16994
|
-
] })
|
|
17100
|
+
/* @__PURE__ */ jsx168("span", { className: "ml-auto flex items-center gap-2 text-[var(--chekin-color-gray-2)]", children: /* @__PURE__ */ jsx168(Paperclip, { size: 20 }) })
|
|
16995
17101
|
]
|
|
16996
17102
|
}
|
|
16997
17103
|
),
|
|
@@ -17030,7 +17136,7 @@ var FileInput = React64.forwardRef(function FileInput2({
|
|
|
17030
17136
|
});
|
|
17031
17137
|
|
|
17032
17138
|
// src/dashboard/select-icons-box/SelectIconsBox.tsx
|
|
17033
|
-
import * as
|
|
17139
|
+
import * as React66 from "react";
|
|
17034
17140
|
import { jsx as jsx169, jsxs as jsxs112 } from "react/jsx-runtime";
|
|
17035
17141
|
function SelectIconsBox({
|
|
17036
17142
|
children,
|
|
@@ -17046,9 +17152,9 @@ function SelectIconsBox({
|
|
|
17046
17152
|
className,
|
|
17047
17153
|
boxClassName
|
|
17048
17154
|
}) {
|
|
17049
|
-
const containerRef =
|
|
17155
|
+
const containerRef = React66.useRef(null);
|
|
17050
17156
|
const isControlled = controlledOpen !== void 0;
|
|
17051
|
-
const [internalOpen, setInternalOpen] =
|
|
17157
|
+
const [internalOpen, setInternalOpen] = React66.useState(defaultOpen);
|
|
17052
17158
|
const isOpen = isControlled ? controlledOpen : internalOpen;
|
|
17053
17159
|
const setOpen = (next) => {
|
|
17054
17160
|
if (!isControlled) setInternalOpen(next);
|
|
@@ -17229,15 +17335,15 @@ var LegacyTextarea = forwardRef71(
|
|
|
17229
17335
|
LegacyTextarea.displayName = "LegacyTextarea";
|
|
17230
17336
|
|
|
17231
17337
|
// src/airbnb-fields/datepicker/DatePicker.tsx
|
|
17232
|
-
import * as
|
|
17338
|
+
import * as React68 from "react";
|
|
17233
17339
|
import { Calendar as Calendar2 } from "lucide-react";
|
|
17234
17340
|
|
|
17235
17341
|
// src/airbnb-fields/field-trigger/FieldTrigger.tsx
|
|
17236
|
-
import * as
|
|
17342
|
+
import * as React67 from "react";
|
|
17237
17343
|
import { Loader2 as Loader24 } from "lucide-react";
|
|
17238
17344
|
import { useTranslation as useTranslation41 } from "react-i18next";
|
|
17239
17345
|
import { Fragment as Fragment17, jsx as jsx172, jsxs as jsxs115 } from "react/jsx-runtime";
|
|
17240
|
-
var AirbnbFieldTrigger =
|
|
17346
|
+
var AirbnbFieldTrigger = React67.forwardRef(
|
|
17241
17347
|
({
|
|
17242
17348
|
as = "button",
|
|
17243
17349
|
variant = "airbnb",
|
|
@@ -17410,7 +17516,7 @@ AirbnbFieldTrigger.displayName = "AirbnbFieldTrigger";
|
|
|
17410
17516
|
// src/airbnb-fields/datepicker/DatePicker.tsx
|
|
17411
17517
|
import { jsx as jsx173, jsxs as jsxs116 } from "react/jsx-runtime";
|
|
17412
17518
|
var DEFAULT_MIN_DATE = new Date(1920, 0, 1);
|
|
17413
|
-
var AirbnbDatePicker =
|
|
17519
|
+
var AirbnbDatePicker = React68.forwardRef(
|
|
17414
17520
|
({
|
|
17415
17521
|
variant = "default",
|
|
17416
17522
|
label,
|
|
@@ -17436,24 +17542,24 @@ var AirbnbDatePicker = React67.forwardRef(
|
|
|
17436
17542
|
formatValue = formatDateValue
|
|
17437
17543
|
}, ref) => {
|
|
17438
17544
|
const { isMatch: isMobile3 } = useScreenResize(DEVICE.mobileXL);
|
|
17439
|
-
const [isOpen, setIsOpen] =
|
|
17440
|
-
const triggerId =
|
|
17441
|
-
const pickerId =
|
|
17442
|
-
const labelId =
|
|
17443
|
-
const valueId =
|
|
17444
|
-
const helperTextId =
|
|
17445
|
-
const errorId =
|
|
17446
|
-
const internalRef =
|
|
17545
|
+
const [isOpen, setIsOpen] = React68.useState(false);
|
|
17546
|
+
const triggerId = React68.useId();
|
|
17547
|
+
const pickerId = React68.useId();
|
|
17548
|
+
const labelId = React68.useId();
|
|
17549
|
+
const valueId = React68.useId();
|
|
17550
|
+
const helperTextId = React68.useId();
|
|
17551
|
+
const errorId = React68.useId();
|
|
17552
|
+
const internalRef = React68.useRef(null);
|
|
17447
17553
|
const combinedRef = useCombinedRef(ref, internalRef);
|
|
17448
|
-
const monthLabels =
|
|
17449
|
-
const resolvedMinDate =
|
|
17450
|
-
const resolvedMaxDate =
|
|
17451
|
-
const normalizedValue =
|
|
17452
|
-
const normalizedDefaultValue =
|
|
17554
|
+
const monthLabels = React68.useMemo(() => getMonthLabels(locale), [locale]);
|
|
17555
|
+
const resolvedMinDate = React68.useMemo(() => minDate ?? DEFAULT_MIN_DATE, [minDate]);
|
|
17556
|
+
const resolvedMaxDate = React68.useMemo(() => maxDate ?? /* @__PURE__ */ new Date(), [maxDate]);
|
|
17557
|
+
const normalizedValue = React68.useMemo(() => normalizeDateValue(value), [value]);
|
|
17558
|
+
const normalizedDefaultValue = React68.useMemo(
|
|
17453
17559
|
() => normalizeDateValue(defaultValue),
|
|
17454
17560
|
[defaultValue]
|
|
17455
17561
|
);
|
|
17456
|
-
const resolvedValue =
|
|
17562
|
+
const resolvedValue = React68.useMemo(
|
|
17457
17563
|
() => normalizedValue ? clampDate(normalizedValue, resolvedMinDate, resolvedMaxDate) : null,
|
|
17458
17564
|
[normalizedValue, resolvedMaxDate, resolvedMinDate]
|
|
17459
17565
|
);
|
|
@@ -17484,7 +17590,7 @@ var AirbnbDatePicker = React67.forwardRef(
|
|
|
17484
17590
|
minDate: resolvedMinDate,
|
|
17485
17591
|
maxDate: resolvedMaxDate
|
|
17486
17592
|
});
|
|
17487
|
-
const handleOpenChange =
|
|
17593
|
+
const handleOpenChange = React68.useCallback(
|
|
17488
17594
|
(nextOpen) => {
|
|
17489
17595
|
if (isBlocked && nextOpen) return;
|
|
17490
17596
|
setIsOpen(nextOpen);
|
|
@@ -17494,7 +17600,7 @@ var AirbnbDatePicker = React67.forwardRef(
|
|
|
17494
17600
|
},
|
|
17495
17601
|
[isBlocked]
|
|
17496
17602
|
);
|
|
17497
|
-
const handleDone =
|
|
17603
|
+
const handleDone = React68.useCallback(() => {
|
|
17498
17604
|
if (isBlocked) return;
|
|
17499
17605
|
onChange(clampDate(draftDate, resolvedMinDate, resolvedMaxDate));
|
|
17500
17606
|
handleOpenChange(false);
|
|
@@ -17506,11 +17612,11 @@ var AirbnbDatePicker = React67.forwardRef(
|
|
|
17506
17612
|
resolvedMaxDate,
|
|
17507
17613
|
resolvedMinDate
|
|
17508
17614
|
]);
|
|
17509
|
-
const handleTriggerClick =
|
|
17615
|
+
const handleTriggerClick = React68.useCallback(() => {
|
|
17510
17616
|
if (isBlocked) return;
|
|
17511
17617
|
setIsOpen(true);
|
|
17512
17618
|
}, [isBlocked]);
|
|
17513
|
-
const handleTriggerKeyDown =
|
|
17619
|
+
const handleTriggerKeyDown = React68.useCallback(
|
|
17514
17620
|
(event) => {
|
|
17515
17621
|
if (isBlocked) return;
|
|
17516
17622
|
if (event.key === "ArrowDown" || event.key === "ArrowUp" || event.key === "Enter" || event.key === " ") {
|
|
@@ -17520,7 +17626,7 @@ var AirbnbDatePicker = React67.forwardRef(
|
|
|
17520
17626
|
},
|
|
17521
17627
|
[isBlocked]
|
|
17522
17628
|
);
|
|
17523
|
-
|
|
17629
|
+
React68.useEffect(() => {
|
|
17524
17630
|
if (isBlocked) {
|
|
17525
17631
|
setIsOpen(false);
|
|
17526
17632
|
}
|
|
@@ -17598,10 +17704,10 @@ var AirbnbDatePicker = React67.forwardRef(
|
|
|
17598
17704
|
AirbnbDatePicker.displayName = "AirbnbDatePicker";
|
|
17599
17705
|
|
|
17600
17706
|
// src/airbnb-fields/input/Input.tsx
|
|
17601
|
-
import * as
|
|
17707
|
+
import * as React69 from "react";
|
|
17602
17708
|
import { jsx as jsx174 } from "react/jsx-runtime";
|
|
17603
17709
|
var getInputValue = (value) => value != null ? String(value) : "";
|
|
17604
|
-
var AirbnbInput =
|
|
17710
|
+
var AirbnbInput = React69.forwardRef(
|
|
17605
17711
|
({
|
|
17606
17712
|
variant = "default",
|
|
17607
17713
|
label,
|
|
@@ -17630,15 +17736,15 @@ var AirbnbInput = React68.forwardRef(
|
|
|
17630
17736
|
placeholder,
|
|
17631
17737
|
...props
|
|
17632
17738
|
}, ref) => {
|
|
17633
|
-
const generatedId =
|
|
17634
|
-
const inputRef =
|
|
17739
|
+
const generatedId = React69.useId();
|
|
17740
|
+
const inputRef = React69.useRef(null);
|
|
17635
17741
|
const inputId = id ?? generatedId;
|
|
17636
17742
|
const fieldId = `${inputId}-field`;
|
|
17637
17743
|
const labelId = `${inputId}-label`;
|
|
17638
17744
|
const errorId = `${inputId}-error`;
|
|
17639
17745
|
const accessibleLabel = placeholder ?? label;
|
|
17640
|
-
const [isFocused, setIsFocused] =
|
|
17641
|
-
const [currentValue, setCurrentValue] =
|
|
17746
|
+
const [isFocused, setIsFocused] = React69.useState(false);
|
|
17747
|
+
const [currentValue, setCurrentValue] = React69.useState(
|
|
17642
17748
|
() => value != null ? getInputValue(value) : getInputValue(defaultValue)
|
|
17643
17749
|
);
|
|
17644
17750
|
const resolvedValue = value != null ? getInputValue(value) : currentValue;
|
|
@@ -17648,11 +17754,11 @@ var AirbnbInput = React68.forwardRef(
|
|
|
17648
17754
|
const triggerError = error ?? invalid;
|
|
17649
17755
|
const hasLabelMeta = Boolean(optional) || Boolean(tooltip);
|
|
17650
17756
|
const isBlocked = Boolean(disabled) || Boolean(loading);
|
|
17651
|
-
|
|
17757
|
+
React69.useLayoutEffect(() => {
|
|
17652
17758
|
const nextValue = value != null ? getInputValue(value) : getInputValue(inputRef.current?.value);
|
|
17653
17759
|
setCurrentValue((prevValue) => prevValue === nextValue ? prevValue : nextValue);
|
|
17654
17760
|
}, [value]);
|
|
17655
|
-
const setRefs =
|
|
17761
|
+
const setRefs = React69.useCallback(
|
|
17656
17762
|
(node) => {
|
|
17657
17763
|
inputRef.current = node;
|
|
17658
17764
|
if (node && value == null) {
|
|
@@ -17750,11 +17856,11 @@ var AirbnbInput = React68.forwardRef(
|
|
|
17750
17856
|
AirbnbInput.displayName = "AirbnbInput";
|
|
17751
17857
|
|
|
17752
17858
|
// src/airbnb-fields/phone-field/PhoneField.tsx
|
|
17753
|
-
import * as
|
|
17859
|
+
import * as React75 from "react";
|
|
17754
17860
|
import { ChevronDown as ChevronDown5 } from "lucide-react";
|
|
17755
17861
|
|
|
17756
17862
|
// src/airbnb-fields/select/Select.tsx
|
|
17757
|
-
import * as
|
|
17863
|
+
import * as React74 from "react";
|
|
17758
17864
|
|
|
17759
17865
|
// src/airbnb-fields/select/SelectDesktopMenu.tsx
|
|
17760
17866
|
import { jsx as jsx175, jsxs as jsxs117 } from "react/jsx-runtime";
|
|
@@ -18099,10 +18205,10 @@ function AirbnbSelectMobileContent({
|
|
|
18099
18205
|
}
|
|
18100
18206
|
|
|
18101
18207
|
// src/airbnb-fields/select/SelectTrigger.tsx
|
|
18102
|
-
import * as
|
|
18208
|
+
import * as React70 from "react";
|
|
18103
18209
|
import { ChevronDown as ChevronDown4 } from "lucide-react";
|
|
18104
18210
|
import { jsx as jsx179 } from "react/jsx-runtime";
|
|
18105
|
-
var AirbnbSelectTrigger =
|
|
18211
|
+
var AirbnbSelectTrigger = React70.forwardRef(
|
|
18106
18212
|
({
|
|
18107
18213
|
id,
|
|
18108
18214
|
open,
|
|
@@ -18169,7 +18275,7 @@ var AirbnbSelectTrigger = React69.forwardRef(
|
|
|
18169
18275
|
AirbnbSelectTrigger.displayName = "AirbnbSelectTrigger";
|
|
18170
18276
|
|
|
18171
18277
|
// src/airbnb-fields/select/useDesktopSelect.ts
|
|
18172
|
-
import * as
|
|
18278
|
+
import * as React71 from "react";
|
|
18173
18279
|
function useDesktopSelect({
|
|
18174
18280
|
isMobile: isMobile3,
|
|
18175
18281
|
isOpen,
|
|
@@ -18178,12 +18284,12 @@ function useDesktopSelect({
|
|
|
18178
18284
|
disabled,
|
|
18179
18285
|
onChange
|
|
18180
18286
|
}) {
|
|
18181
|
-
const [highlightedIndex, setHighlightedIndex] =
|
|
18182
|
-
const triggerRef =
|
|
18183
|
-
const listRef =
|
|
18184
|
-
const optionRefs =
|
|
18287
|
+
const [highlightedIndex, setHighlightedIndex] = React71.useState(-1);
|
|
18288
|
+
const triggerRef = React71.useRef(null);
|
|
18289
|
+
const listRef = React71.useRef(null);
|
|
18290
|
+
const optionRefs = React71.useRef([]);
|
|
18185
18291
|
const selectedIndex = getOptionIndex2(options, value);
|
|
18186
|
-
|
|
18292
|
+
React71.useEffect(() => {
|
|
18187
18293
|
if (!isOpen || isMobile3) return;
|
|
18188
18294
|
setHighlightedIndex((currentIndex) => {
|
|
18189
18295
|
if (currentIndex >= 0) {
|
|
@@ -18198,34 +18304,34 @@ function useDesktopSelect({
|
|
|
18198
18304
|
window.cancelAnimationFrame(frameId);
|
|
18199
18305
|
};
|
|
18200
18306
|
}, [isMobile3, isOpen, options, selectedIndex]);
|
|
18201
|
-
|
|
18307
|
+
React71.useEffect(() => {
|
|
18202
18308
|
if (!isOpen || isMobile3 || highlightedIndex < 0) return;
|
|
18203
18309
|
optionRefs.current[highlightedIndex]?.scrollIntoView({
|
|
18204
18310
|
block: "nearest"
|
|
18205
18311
|
});
|
|
18206
18312
|
}, [highlightedIndex, isMobile3, isOpen]);
|
|
18207
|
-
|
|
18313
|
+
React71.useEffect(() => {
|
|
18208
18314
|
if (isOpen) return;
|
|
18209
18315
|
setHighlightedIndex(-1);
|
|
18210
18316
|
}, [isOpen]);
|
|
18211
|
-
const focusTrigger =
|
|
18317
|
+
const focusTrigger = React71.useCallback(() => {
|
|
18212
18318
|
triggerRef.current?.focus();
|
|
18213
18319
|
}, []);
|
|
18214
|
-
const handleSelect =
|
|
18320
|
+
const handleSelect = React71.useCallback(
|
|
18215
18321
|
(option) => {
|
|
18216
18322
|
if (option.isDisabled || disabled) return;
|
|
18217
18323
|
onChange(option);
|
|
18218
18324
|
},
|
|
18219
18325
|
[disabled, onChange]
|
|
18220
18326
|
);
|
|
18221
|
-
const openMenu =
|
|
18327
|
+
const openMenu = React71.useCallback(
|
|
18222
18328
|
(targetIndex) => {
|
|
18223
18329
|
const fallbackIndex = selectedIndex >= 0 ? selectedIndex : getFirstEnabledOptionIndex2(options);
|
|
18224
18330
|
setHighlightedIndex(targetIndex ?? fallbackIndex);
|
|
18225
18331
|
},
|
|
18226
18332
|
[options, selectedIndex]
|
|
18227
18333
|
);
|
|
18228
|
-
const handleTriggerKeyDown =
|
|
18334
|
+
const handleTriggerKeyDown = React71.useCallback(
|
|
18229
18335
|
(event, onOpen) => {
|
|
18230
18336
|
if (disabled) return;
|
|
18231
18337
|
if (event.key === "ArrowDown") {
|
|
@@ -18250,7 +18356,7 @@ function useDesktopSelect({
|
|
|
18250
18356
|
},
|
|
18251
18357
|
[disabled, openMenu, options, selectedIndex]
|
|
18252
18358
|
);
|
|
18253
|
-
const handleMenuKeyDown =
|
|
18359
|
+
const handleMenuKeyDown = React71.useCallback(
|
|
18254
18360
|
(event, onClose) => {
|
|
18255
18361
|
if (event.key === "Escape") {
|
|
18256
18362
|
event.preventDefault();
|
|
@@ -18300,7 +18406,7 @@ function useDesktopSelect({
|
|
|
18300
18406
|
},
|
|
18301
18407
|
[focusTrigger, highlightedIndex, onChange, options]
|
|
18302
18408
|
);
|
|
18303
|
-
const setOptionRef =
|
|
18409
|
+
const setOptionRef = React71.useCallback(
|
|
18304
18410
|
(index, node) => {
|
|
18305
18411
|
optionRefs.current[index] = node;
|
|
18306
18412
|
},
|
|
@@ -18320,23 +18426,23 @@ function useDesktopSelect({
|
|
|
18320
18426
|
}
|
|
18321
18427
|
|
|
18322
18428
|
// src/airbnb-fields/select/useMobileSelectWheel.ts
|
|
18323
|
-
import * as
|
|
18429
|
+
import * as React72 from "react";
|
|
18324
18430
|
function useMobileSelectWheel({ isMobile: isMobile3, isOpen, options, value, disabled }) {
|
|
18325
|
-
const [pendingValue, setPendingValue] =
|
|
18431
|
+
const [pendingValue, setPendingValue] = React72.useState(
|
|
18326
18432
|
value ?? null
|
|
18327
18433
|
);
|
|
18328
|
-
const [mobileScrollTop, setMobileScrollTop] =
|
|
18329
|
-
const mobileListRef =
|
|
18330
|
-
const scrollSettleTimeoutRef =
|
|
18331
|
-
const scrollAnimationFrameRef =
|
|
18332
|
-
const getTargetIndex =
|
|
18434
|
+
const [mobileScrollTop, setMobileScrollTop] = React72.useState(0);
|
|
18435
|
+
const mobileListRef = React72.useRef(null);
|
|
18436
|
+
const scrollSettleTimeoutRef = React72.useRef(null);
|
|
18437
|
+
const scrollAnimationFrameRef = React72.useRef(null);
|
|
18438
|
+
const getTargetIndex = React72.useCallback(
|
|
18333
18439
|
(targetValue) => {
|
|
18334
18440
|
const selectedIndex = getOptionIndex2(options, targetValue);
|
|
18335
18441
|
return selectedIndex >= 0 ? selectedIndex : getFirstEnabledOptionIndex2(options);
|
|
18336
18442
|
},
|
|
18337
18443
|
[options]
|
|
18338
18444
|
);
|
|
18339
|
-
const syncScrollPosition =
|
|
18445
|
+
const syncScrollPosition = React72.useCallback(
|
|
18340
18446
|
(targetValue, behavior = "instant") => {
|
|
18341
18447
|
const targetIndex = getTargetIndex(targetValue);
|
|
18342
18448
|
if (targetIndex < 0) return;
|
|
@@ -18355,27 +18461,27 @@ function useMobileSelectWheel({ isMobile: isMobile3, isOpen, options, value, dis
|
|
|
18355
18461
|
},
|
|
18356
18462
|
[getTargetIndex, options]
|
|
18357
18463
|
);
|
|
18358
|
-
const clearScrollSettleTimeout =
|
|
18464
|
+
const clearScrollSettleTimeout = React72.useCallback(() => {
|
|
18359
18465
|
if (scrollSettleTimeoutRef.current === null) return;
|
|
18360
18466
|
window.clearTimeout(scrollSettleTimeoutRef.current);
|
|
18361
18467
|
scrollSettleTimeoutRef.current = null;
|
|
18362
18468
|
}, []);
|
|
18363
|
-
const clearScrollAnimationFrame =
|
|
18469
|
+
const clearScrollAnimationFrame = React72.useCallback(() => {
|
|
18364
18470
|
if (scrollAnimationFrameRef.current === null) return;
|
|
18365
18471
|
window.cancelAnimationFrame(scrollAnimationFrameRef.current);
|
|
18366
18472
|
scrollAnimationFrameRef.current = null;
|
|
18367
18473
|
}, []);
|
|
18368
|
-
|
|
18474
|
+
React72.useEffect(
|
|
18369
18475
|
() => () => {
|
|
18370
18476
|
clearScrollSettleTimeout();
|
|
18371
18477
|
clearScrollAnimationFrame();
|
|
18372
18478
|
},
|
|
18373
18479
|
[clearScrollAnimationFrame, clearScrollSettleTimeout]
|
|
18374
18480
|
);
|
|
18375
|
-
|
|
18481
|
+
React72.useEffect(() => {
|
|
18376
18482
|
setPendingValue(value ?? null);
|
|
18377
18483
|
}, [value]);
|
|
18378
|
-
|
|
18484
|
+
React72.useLayoutEffect(() => {
|
|
18379
18485
|
if (!isMobile3 || !isOpen) return;
|
|
18380
18486
|
const frameId = window.requestAnimationFrame(() => {
|
|
18381
18487
|
syncScrollPosition(value ?? null, "instant");
|
|
@@ -18384,7 +18490,7 @@ function useMobileSelectWheel({ isMobile: isMobile3, isOpen, options, value, dis
|
|
|
18384
18490
|
window.cancelAnimationFrame(frameId);
|
|
18385
18491
|
};
|
|
18386
18492
|
}, [isMobile3, isOpen, syncScrollPosition, value]);
|
|
18387
|
-
const settleScroll =
|
|
18493
|
+
const settleScroll = React72.useCallback(() => {
|
|
18388
18494
|
if (!mobileListRef.current) return;
|
|
18389
18495
|
const nextIndex = Math.round(mobileListRef.current.scrollTop / MOBILE_OPTION_HEIGHT);
|
|
18390
18496
|
const nextOption = options[nextIndex];
|
|
@@ -18396,13 +18502,13 @@ function useMobileSelectWheel({ isMobile: isMobile3, isOpen, options, value, dis
|
|
|
18396
18502
|
}
|
|
18397
18503
|
setPendingValue(nextOption);
|
|
18398
18504
|
}, [options, pendingValue]);
|
|
18399
|
-
const scheduleScrollSettle =
|
|
18505
|
+
const scheduleScrollSettle = React72.useCallback(() => {
|
|
18400
18506
|
clearScrollSettleTimeout();
|
|
18401
18507
|
scrollSettleTimeoutRef.current = window.setTimeout(() => {
|
|
18402
18508
|
settleScroll();
|
|
18403
18509
|
}, MOBILE_SCROLL_SETTLE_DELAY);
|
|
18404
18510
|
}, [clearScrollSettleTimeout, settleScroll]);
|
|
18405
|
-
const handleScroll =
|
|
18511
|
+
const handleScroll = React72.useCallback(() => {
|
|
18406
18512
|
if (!mobileListRef.current) return;
|
|
18407
18513
|
const nextScrollTop = mobileListRef.current.scrollTop;
|
|
18408
18514
|
clearScrollAnimationFrame();
|
|
@@ -18412,7 +18518,7 @@ function useMobileSelectWheel({ isMobile: isMobile3, isOpen, options, value, dis
|
|
|
18412
18518
|
});
|
|
18413
18519
|
scheduleScrollSettle();
|
|
18414
18520
|
}, [clearScrollAnimationFrame, scheduleScrollSettle]);
|
|
18415
|
-
const focusOptionByIndex =
|
|
18521
|
+
const focusOptionByIndex = React72.useCallback(
|
|
18416
18522
|
(index, behavior = "instant", updatePendingImmediately = behavior === "instant") => {
|
|
18417
18523
|
if (!mobileListRef.current || index < 0 || index >= options.length) return;
|
|
18418
18524
|
const option = options[index];
|
|
@@ -18430,7 +18536,7 @@ function useMobileSelectWheel({ isMobile: isMobile3, isOpen, options, value, dis
|
|
|
18430
18536
|
},
|
|
18431
18537
|
[options, scheduleScrollSettle]
|
|
18432
18538
|
);
|
|
18433
|
-
const handleOptionClick =
|
|
18539
|
+
const handleOptionClick = React72.useCallback(
|
|
18434
18540
|
(option) => {
|
|
18435
18541
|
if (!mobileListRef.current || disabled || option.isDisabled) return;
|
|
18436
18542
|
const optionIndex = getOptionIndex2(options, option);
|
|
@@ -18439,7 +18545,7 @@ function useMobileSelectWheel({ isMobile: isMobile3, isOpen, options, value, dis
|
|
|
18439
18545
|
},
|
|
18440
18546
|
[disabled, focusOptionByIndex, options]
|
|
18441
18547
|
);
|
|
18442
|
-
const moveByStep =
|
|
18548
|
+
const moveByStep = React72.useCallback(
|
|
18443
18549
|
(step) => {
|
|
18444
18550
|
const currentIndex = getOptionIndex2(options, pendingValue);
|
|
18445
18551
|
const fallbackIndex = step === 1 ? getFirstEnabledOptionIndex2(options) : getLastEnabledOptionIndex2(options);
|
|
@@ -18451,7 +18557,7 @@ function useMobileSelectWheel({ isMobile: isMobile3, isOpen, options, value, dis
|
|
|
18451
18557
|
},
|
|
18452
18558
|
[focusOptionByIndex, options, pendingValue]
|
|
18453
18559
|
);
|
|
18454
|
-
const moveToBoundary =
|
|
18560
|
+
const moveToBoundary = React72.useCallback(
|
|
18455
18561
|
(boundary) => {
|
|
18456
18562
|
const targetIndex = boundary === "start" ? getFirstEnabledOptionIndex2(options) : getLastEnabledOptionIndex2(options);
|
|
18457
18563
|
if (targetIndex >= 0) {
|
|
@@ -18460,7 +18566,7 @@ function useMobileSelectWheel({ isMobile: isMobile3, isOpen, options, value, dis
|
|
|
18460
18566
|
},
|
|
18461
18567
|
[focusOptionByIndex, options]
|
|
18462
18568
|
);
|
|
18463
|
-
const syncPendingValue =
|
|
18569
|
+
const syncPendingValue = React72.useCallback(
|
|
18464
18570
|
(nextValue) => {
|
|
18465
18571
|
const normalizedValue = nextValue ?? null;
|
|
18466
18572
|
const matchedIndex = getOptionIndex2(options, normalizedValue);
|
|
@@ -18488,9 +18594,9 @@ function useMobileSelectWheel({ isMobile: isMobile3, isOpen, options, value, dis
|
|
|
18488
18594
|
}
|
|
18489
18595
|
|
|
18490
18596
|
// src/airbnb-fields/select/useSelectIds.ts
|
|
18491
|
-
import * as
|
|
18597
|
+
import * as React73 from "react";
|
|
18492
18598
|
function useSelectIds2({ name, hasValue, error, hideErrorMessage }) {
|
|
18493
|
-
const reactId =
|
|
18599
|
+
const reactId = React73.useId().replace(/:/g, "");
|
|
18494
18600
|
const baseId = name ? `select-${name}` : `select-${reactId}`;
|
|
18495
18601
|
const triggerId = `${baseId}-trigger`;
|
|
18496
18602
|
const labelId = `${baseId}-label`;
|
|
@@ -18500,7 +18606,7 @@ function useSelectIds2({ name, hasValue, error, hideErrorMessage }) {
|
|
|
18500
18606
|
const listboxId = `${baseId}-listbox`;
|
|
18501
18607
|
const describedErrorId = error && !hideErrorMessage ? errorId : void 0;
|
|
18502
18608
|
const describedBy = [!hasValue ? helperTextId : null, describedErrorId].filter(Boolean).join(" ") || void 0;
|
|
18503
|
-
const getOptionId2 =
|
|
18609
|
+
const getOptionId2 = React73.useCallback(
|
|
18504
18610
|
(index) => `${baseId}-option-${index}`,
|
|
18505
18611
|
[baseId]
|
|
18506
18612
|
);
|
|
@@ -18519,7 +18625,7 @@ function useSelectIds2({ name, hasValue, error, hideErrorMessage }) {
|
|
|
18519
18625
|
|
|
18520
18626
|
// src/airbnb-fields/select/Select.tsx
|
|
18521
18627
|
import { jsx as jsx180, jsxs as jsxs120 } from "react/jsx-runtime";
|
|
18522
|
-
var AirbnbSelect =
|
|
18628
|
+
var AirbnbSelect = React74.forwardRef(function AirbnbSelect2({
|
|
18523
18629
|
options = [],
|
|
18524
18630
|
value,
|
|
18525
18631
|
onChange,
|
|
@@ -18546,8 +18652,8 @@ var AirbnbSelect = React73.forwardRef(function AirbnbSelect2({
|
|
|
18546
18652
|
noOptionsMessage
|
|
18547
18653
|
}, ref) {
|
|
18548
18654
|
const { isMatch: isMobile3 } = useScreenResize(DEVICE.mobileXL);
|
|
18549
|
-
const [isOpen, setIsOpen] =
|
|
18550
|
-
const containerRef =
|
|
18655
|
+
const [isOpen, setIsOpen] = React74.useState(false);
|
|
18656
|
+
const containerRef = React74.useRef(null);
|
|
18551
18657
|
const hasValue = Boolean(value);
|
|
18552
18658
|
const helperText = placeholder ?? label;
|
|
18553
18659
|
const shouldDescribeHelperText = !hasValue && helperText !== label;
|
|
@@ -18608,12 +18714,12 @@ var AirbnbSelect = React73.forwardRef(function AirbnbSelect2({
|
|
|
18608
18714
|
onOutsideClick: () => setIsOpen(false),
|
|
18609
18715
|
isDisabled: !isOpen || isMobile3
|
|
18610
18716
|
});
|
|
18611
|
-
|
|
18717
|
+
React74.useEffect(() => {
|
|
18612
18718
|
if (isBlocked) {
|
|
18613
18719
|
setIsOpen(false);
|
|
18614
18720
|
}
|
|
18615
18721
|
}, [isBlocked]);
|
|
18616
|
-
|
|
18722
|
+
React74.useEffect(
|
|
18617
18723
|
function setCorrectOptionIfThereIsOnlyValue() {
|
|
18618
18724
|
if (value?.value === void 0 || value.value === null || value.label !== "") {
|
|
18619
18725
|
return;
|
|
@@ -18625,7 +18731,7 @@ var AirbnbSelect = React73.forwardRef(function AirbnbSelect2({
|
|
|
18625
18731
|
},
|
|
18626
18732
|
[onChange, options, value]
|
|
18627
18733
|
);
|
|
18628
|
-
const handleMobileOpenChange =
|
|
18734
|
+
const handleMobileOpenChange = React74.useCallback(
|
|
18629
18735
|
(nextOpen) => {
|
|
18630
18736
|
if (isBlocked && nextOpen) return;
|
|
18631
18737
|
setIsOpen(nextOpen);
|
|
@@ -18636,7 +18742,7 @@ var AirbnbSelect = React73.forwardRef(function AirbnbSelect2({
|
|
|
18636
18742
|
},
|
|
18637
18743
|
[focusTrigger, isBlocked, syncPendingValue, value]
|
|
18638
18744
|
);
|
|
18639
|
-
const handleMobileDone =
|
|
18745
|
+
const handleMobileDone = React74.useCallback(() => {
|
|
18640
18746
|
if (isBlocked) return;
|
|
18641
18747
|
const finalOption = pendingValue;
|
|
18642
18748
|
if (finalOption && finalOption.value !== value?.value) {
|
|
@@ -18645,7 +18751,7 @@ var AirbnbSelect = React73.forwardRef(function AirbnbSelect2({
|
|
|
18645
18751
|
setIsOpen(false);
|
|
18646
18752
|
focusTrigger();
|
|
18647
18753
|
}, [focusTrigger, isBlocked, onChange, pendingValue, value]);
|
|
18648
|
-
const handleTriggerClick =
|
|
18754
|
+
const handleTriggerClick = React74.useCallback(() => {
|
|
18649
18755
|
if (isBlocked) return;
|
|
18650
18756
|
setIsOpen((prev) => {
|
|
18651
18757
|
const nextOpen = !prev;
|
|
@@ -18819,7 +18925,7 @@ function formatPhoneCodeOptionLabel2(option) {
|
|
|
18819
18925
|
const value = String(option.value);
|
|
18820
18926
|
return label.includes(value) ? label : `${label} (${value})`;
|
|
18821
18927
|
}
|
|
18822
|
-
var AirbnbPhoneField =
|
|
18928
|
+
var AirbnbPhoneField = React75.forwardRef(
|
|
18823
18929
|
({
|
|
18824
18930
|
variant = "default",
|
|
18825
18931
|
label,
|
|
@@ -18843,8 +18949,8 @@ var AirbnbPhoneField = React74.forwardRef(
|
|
|
18843
18949
|
mobileTitle,
|
|
18844
18950
|
codePlaceholder = "+00"
|
|
18845
18951
|
}, ref) => {
|
|
18846
|
-
const inputId =
|
|
18847
|
-
const codeOptions =
|
|
18952
|
+
const inputId = React75.useId();
|
|
18953
|
+
const codeOptions = React75.useMemo(
|
|
18848
18954
|
() => options.map((option) => ({
|
|
18849
18955
|
value: option.value,
|
|
18850
18956
|
label: formatPhoneCodeOptionLabel2(option),
|
|
@@ -18852,7 +18958,7 @@ var AirbnbPhoneField = React74.forwardRef(
|
|
|
18852
18958
|
})),
|
|
18853
18959
|
[options]
|
|
18854
18960
|
);
|
|
18855
|
-
const selectedCodeOption =
|
|
18961
|
+
const selectedCodeOption = React75.useMemo(
|
|
18856
18962
|
() => codeOptions.find((option) => option.value === value?.code) ?? null,
|
|
18857
18963
|
[codeOptions, value?.code]
|
|
18858
18964
|
);
|
|
@@ -18994,10 +19100,10 @@ var AirbnbPhoneField = React74.forwardRef(
|
|
|
18994
19100
|
AirbnbPhoneField.displayName = "AirbnbPhoneField";
|
|
18995
19101
|
|
|
18996
19102
|
// src/airbnb-fields/searchable-select/SearchableSelect.tsx
|
|
18997
|
-
import * as
|
|
19103
|
+
import * as React76 from "react";
|
|
18998
19104
|
import { ChevronDown as ChevronDown6, Search as Search4 } from "lucide-react";
|
|
18999
19105
|
import { useVirtualizer as useVirtualizer3 } from "@tanstack/react-virtual";
|
|
19000
|
-
import { useCallback as
|
|
19106
|
+
import { useCallback as useCallback55 } from "react";
|
|
19001
19107
|
import { jsx as jsx182, jsxs as jsxs122 } from "react/jsx-runtime";
|
|
19002
19108
|
var ROW_HEIGHT = 48;
|
|
19003
19109
|
var DESKTOP_LIST_HEIGHT = 280;
|
|
@@ -19039,13 +19145,13 @@ var AirbnbSearchableSelectInternal = ({
|
|
|
19039
19145
|
loadingMessage
|
|
19040
19146
|
}, ref) => {
|
|
19041
19147
|
const { isMatch: isMobile3 } = useScreenResize(DEVICE.mobileXL);
|
|
19042
|
-
const reactId =
|
|
19043
|
-
const [open, setOpen] =
|
|
19044
|
-
const [internalSearchValue, setInternalSearchValue] =
|
|
19045
|
-
const [highlightedIndex, setHighlightedIndex] =
|
|
19046
|
-
const containerRef =
|
|
19047
|
-
const triggerRef =
|
|
19048
|
-
const inputRef =
|
|
19148
|
+
const reactId = React76.useId();
|
|
19149
|
+
const [open, setOpen] = React76.useState(false);
|
|
19150
|
+
const [internalSearchValue, setInternalSearchValue] = React76.useState("");
|
|
19151
|
+
const [highlightedIndex, setHighlightedIndex] = React76.useState(-1);
|
|
19152
|
+
const containerRef = React76.useRef(null);
|
|
19153
|
+
const triggerRef = React76.useRef(null);
|
|
19154
|
+
const inputRef = React76.useRef(null);
|
|
19049
19155
|
const listboxId = `${reactId}-listbox`;
|
|
19050
19156
|
const labelId = `${reactId}-label`;
|
|
19051
19157
|
const valueId = `${reactId}-value`;
|
|
@@ -19054,13 +19160,13 @@ var AirbnbSearchableSelectInternal = ({
|
|
|
19054
19160
|
const searchInputId = `${reactId}-search`;
|
|
19055
19161
|
const effectiveSearchValue = searchValue ?? internalSearchValue;
|
|
19056
19162
|
const shouldFilterLocally = !onSearchChange && filterOption !== null;
|
|
19057
|
-
const visibleOptions =
|
|
19163
|
+
const visibleOptions = React76.useMemo(() => {
|
|
19058
19164
|
if (!shouldFilterLocally || !effectiveSearchValue) {
|
|
19059
19165
|
return options;
|
|
19060
19166
|
}
|
|
19061
19167
|
return options.filter((option) => filterOption(option, effectiveSearchValue));
|
|
19062
19168
|
}, [effectiveSearchValue, filterOption, options, shouldFilterLocally]);
|
|
19063
|
-
const selectedIndex =
|
|
19169
|
+
const selectedIndex = React76.useMemo(
|
|
19064
19170
|
() => visibleOptions.findIndex((option) => option.value === value?.value),
|
|
19065
19171
|
[value?.value, visibleOptions]
|
|
19066
19172
|
);
|
|
@@ -19076,7 +19182,7 @@ var AirbnbSearchableSelectInternal = ({
|
|
|
19076
19182
|
isDisabled: !open || isMobile3
|
|
19077
19183
|
});
|
|
19078
19184
|
const handleOnOpenChange = useEvent(onOpenChange);
|
|
19079
|
-
const setSelectOpen =
|
|
19185
|
+
const setSelectOpen = useCallback55(
|
|
19080
19186
|
(nextOpen, options2) => {
|
|
19081
19187
|
setOpen(nextOpen);
|
|
19082
19188
|
handleOnOpenChange?.(nextOpen);
|
|
@@ -19086,7 +19192,7 @@ var AirbnbSearchableSelectInternal = ({
|
|
|
19086
19192
|
},
|
|
19087
19193
|
[handleOnOpenChange]
|
|
19088
19194
|
);
|
|
19089
|
-
|
|
19195
|
+
React76.useEffect(() => {
|
|
19090
19196
|
if (isBlocked) {
|
|
19091
19197
|
setSelectOpen(false);
|
|
19092
19198
|
return;
|
|
@@ -19099,7 +19205,7 @@ var AirbnbSearchableSelectInternal = ({
|
|
|
19099
19205
|
window.cancelAnimationFrame(frameId);
|
|
19100
19206
|
};
|
|
19101
19207
|
}, [isBlocked, open, setSelectOpen]);
|
|
19102
|
-
|
|
19208
|
+
React76.useEffect(() => {
|
|
19103
19209
|
if (!open) {
|
|
19104
19210
|
setHighlightedIndex(-1);
|
|
19105
19211
|
return;
|
|
@@ -19194,7 +19300,7 @@ var AirbnbSearchableSelectInternal = ({
|
|
|
19194
19300
|
onOptionHover: setHighlightedIndex
|
|
19195
19301
|
}
|
|
19196
19302
|
);
|
|
19197
|
-
|
|
19303
|
+
React76.useImperativeHandle(ref, () => triggerRef.current, []);
|
|
19198
19304
|
return /* @__PURE__ */ jsxs122("div", { ref: containerRef, className: cn("relative w-full max-w-[425px]", className), children: [
|
|
19199
19305
|
name && /* @__PURE__ */ jsx182("input", { type: "hidden", name, value: value ? String(value.value) : "" }),
|
|
19200
19306
|
/* @__PURE__ */ jsx182(
|
|
@@ -19273,7 +19379,7 @@ var AirbnbSearchableSelectInternal = ({
|
|
|
19273
19379
|
) : null
|
|
19274
19380
|
] });
|
|
19275
19381
|
};
|
|
19276
|
-
var AirbnbSearchableSelect =
|
|
19382
|
+
var AirbnbSearchableSelect = React76.forwardRef(
|
|
19277
19383
|
AirbnbSearchableSelectInternal
|
|
19278
19384
|
);
|
|
19279
19385
|
function AirbnbSearchableSelectContent({
|
|
@@ -19300,9 +19406,9 @@ function AirbnbSearchableSelectContent({
|
|
|
19300
19406
|
onOptionClick,
|
|
19301
19407
|
onOptionHover
|
|
19302
19408
|
}) {
|
|
19303
|
-
const listRef =
|
|
19304
|
-
const lastLoadMoreOptionsLengthRef =
|
|
19305
|
-
const previousHighlightedIndexRef =
|
|
19409
|
+
const listRef = React76.useRef(null);
|
|
19410
|
+
const lastLoadMoreOptionsLengthRef = React76.useRef(null);
|
|
19411
|
+
const previousHighlightedIndexRef = React76.useRef(highlightedIndex);
|
|
19306
19412
|
const rowCount = options.length + (loading && options.length > 0 ? 1 : 0);
|
|
19307
19413
|
const virtualizer = useVirtualizer3({
|
|
19308
19414
|
count: rowCount,
|
|
@@ -19313,7 +19419,7 @@ function AirbnbSearchableSelectContent({
|
|
|
19313
19419
|
const virtualItems = virtualizer.getVirtualItems();
|
|
19314
19420
|
const emptyMessage = noOptionsMessage?.() ?? "No matches found";
|
|
19315
19421
|
const loadingText = loadingMessage?.() ?? "Loading...";
|
|
19316
|
-
|
|
19422
|
+
React76.useEffect(() => {
|
|
19317
19423
|
const lastItem = virtualItems[virtualItems.length - 1];
|
|
19318
19424
|
const shouldLoadMore = !!lastItem && hasNextPage && !loading && lastItem.index >= options.length - LOAD_MORE_THRESHOLD;
|
|
19319
19425
|
if (shouldLoadMore && lastLoadMoreOptionsLengthRef.current !== options.length) {
|
|
@@ -19321,7 +19427,7 @@ function AirbnbSearchableSelectContent({
|
|
|
19321
19427
|
onLoadMore?.();
|
|
19322
19428
|
}
|
|
19323
19429
|
}, [hasNextPage, loading, onLoadMore, options.length, virtualItems]);
|
|
19324
|
-
|
|
19430
|
+
React76.useEffect(() => {
|
|
19325
19431
|
const hasHighlightedIndexChanged = previousHighlightedIndexRef.current !== highlightedIndex;
|
|
19326
19432
|
previousHighlightedIndexRef.current = highlightedIndex;
|
|
19327
19433
|
if (highlightedIndex >= 0 && hasHighlightedIndexChanged) {
|
|
@@ -19439,11 +19545,11 @@ function getNextEnabledIndex(options, startIndex, step) {
|
|
|
19439
19545
|
}
|
|
19440
19546
|
|
|
19441
19547
|
// src/airbnb-fields/search-input/SearchInput.tsx
|
|
19442
|
-
import * as
|
|
19548
|
+
import * as React77 from "react";
|
|
19443
19549
|
import { useTranslation as useTranslation42 } from "react-i18next";
|
|
19444
19550
|
import { Search as Search5, X as X10 } from "lucide-react";
|
|
19445
19551
|
import { jsx as jsx183, jsxs as jsxs123 } from "react/jsx-runtime";
|
|
19446
|
-
var AirbnbSearchInput =
|
|
19552
|
+
var AirbnbSearchInput = React77.forwardRef(({ onReset, placeholder, wrapperClassName, ...props }, ref) => {
|
|
19447
19553
|
const { t } = useTranslation42();
|
|
19448
19554
|
const placeholderText = placeholder || t("search_property") + "...";
|
|
19449
19555
|
return /* @__PURE__ */ jsxs123("div", { className: cn("input-wrapper relative", wrapperClassName), children: [
|