@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.cjs
CHANGED
|
@@ -3821,18 +3821,15 @@ function useSwitchSectionActive(preloadedSectionActive, { canToggle, onToggle, o
|
|
|
3821
3821
|
|
|
3822
3822
|
// src/hooks/use-countdown.ts
|
|
3823
3823
|
var import_react33 = require("react");
|
|
3824
|
-
var useCountdown = ({
|
|
3825
|
-
|
|
3826
|
-
|
|
3827
|
-
onFinish
|
|
3828
|
-
} = {}) => {
|
|
3829
|
-
const [timeLeft, setTimeLeft] = (0, import_react33.useState)(initialTime);
|
|
3824
|
+
var useCountdown = ({ initialTime, enabled = true, onFinish } = {}) => {
|
|
3825
|
+
const duration = initialTime ?? 60;
|
|
3826
|
+
const [timeLeft, setTimeLeft] = (0, import_react33.useState)(duration);
|
|
3830
3827
|
const [isTimerRunning, setIsTimerRunning] = (0, import_react33.useState)(enabled);
|
|
3831
3828
|
const handleOnFinish = useEvent(onFinish);
|
|
3832
3829
|
(0, import_react33.useEffect)(() => {
|
|
3833
|
-
setTimeLeft(
|
|
3830
|
+
setTimeLeft(duration);
|
|
3834
3831
|
setIsTimerRunning(enabled);
|
|
3835
|
-
}, [
|
|
3832
|
+
}, [duration, enabled]);
|
|
3836
3833
|
(0, import_react33.useEffect)(() => {
|
|
3837
3834
|
if (!isTimerRunning) return;
|
|
3838
3835
|
const timer = setInterval(() => {
|
|
@@ -3851,12 +3848,13 @@ var useCountdown = ({
|
|
|
3851
3848
|
if (timeLeft <= 0) {
|
|
3852
3849
|
handleOnFinish();
|
|
3853
3850
|
}
|
|
3854
|
-
}, [timeLeft]);
|
|
3851
|
+
}, [timeLeft, handleOnFinish]);
|
|
3855
3852
|
const resetTimer = () => {
|
|
3856
|
-
setTimeLeft(
|
|
3853
|
+
setTimeLeft(duration);
|
|
3857
3854
|
setIsTimerRunning(enabled);
|
|
3858
3855
|
};
|
|
3859
3856
|
return {
|
|
3857
|
+
count: timeLeft,
|
|
3860
3858
|
timeLeft,
|
|
3861
3859
|
isTimerRunning,
|
|
3862
3860
|
resetTimer
|
|
@@ -11545,7 +11543,7 @@ function useErrorHandler({ onError }) {
|
|
|
11545
11543
|
const handleUserMediaError = (0, import_react84.useCallback)(
|
|
11546
11544
|
(error) => {
|
|
11547
11545
|
console.error(error);
|
|
11548
|
-
let errorText
|
|
11546
|
+
let errorText;
|
|
11549
11547
|
if (error?.message === GET_USER_MEDIA_ERROR) {
|
|
11550
11548
|
errorText = t("camera_errors.chekin_cant_use_your_camera");
|
|
11551
11549
|
handleError({
|
|
@@ -12443,7 +12441,7 @@ function Fieldset({
|
|
|
12443
12441
|
className: cn(
|
|
12444
12442
|
"absolute box-border inline-flex max-w-full cursor-text items-center pl-[3px] pr-5 transition-all duration-100 ease-in",
|
|
12445
12443
|
"left-[13px] text-[var(--chekin-color-gray-1)]",
|
|
12446
|
-
isEmpty && !isFocused ? "top-[12px]" : "top-[-10px] !
|
|
12444
|
+
isEmpty && !isFocused ? "top-[12px]" : "top-[-10px] !px-1",
|
|
12447
12445
|
isFocused && "text-[var(--chekin-color-brand-blue)]",
|
|
12448
12446
|
raised && invalid && "text-[var(--error-message-color)]",
|
|
12449
12447
|
readOnly && "cursor-default",
|
|
@@ -12458,8 +12456,8 @@ function Fieldset({
|
|
|
12458
12456
|
id: labelId,
|
|
12459
12457
|
htmlFor,
|
|
12460
12458
|
className: cn(
|
|
12461
|
-
"block cursor-[inherit] truncate
|
|
12462
|
-
raised ? "text-[14px]" : "text-[16px]"
|
|
12459
|
+
"block cursor-[inherit] truncate transition-all duration-100 ease-in",
|
|
12460
|
+
raised ? "text-[14px] font-semibold" : "text-[16px] font-medium"
|
|
12463
12461
|
),
|
|
12464
12462
|
children: label
|
|
12465
12463
|
}
|
|
@@ -12497,7 +12495,16 @@ function Fieldset({
|
|
|
12497
12495
|
!label && "w-0"
|
|
12498
12496
|
),
|
|
12499
12497
|
children: [
|
|
12500
|
-
showLegendText && /* @__PURE__ */ (0, import_jsx_runtime144.jsx)(
|
|
12498
|
+
showLegendText && /* @__PURE__ */ (0, import_jsx_runtime144.jsx)(
|
|
12499
|
+
"span",
|
|
12500
|
+
{
|
|
12501
|
+
className: cn(
|
|
12502
|
+
"visible inline-block px-1 text-[14px] opacity-0",
|
|
12503
|
+
raised ? "font-semibold" : "font-medium"
|
|
12504
|
+
),
|
|
12505
|
+
children: legend || label
|
|
12506
|
+
}
|
|
12507
|
+
),
|
|
12501
12508
|
tooltip && /* @__PURE__ */ (0, import_jsx_runtime144.jsx)("span", { className: "visible inline-block w-[20px] opacity-0", children: /* @__PURE__ */ (0, import_jsx_runtime144.jsx)("span", { className: "inline-block h-4 w-4" }) })
|
|
12502
12509
|
]
|
|
12503
12510
|
}
|
|
@@ -12604,7 +12611,7 @@ var Input = React44.forwardRef(
|
|
|
12604
12611
|
"div",
|
|
12605
12612
|
{
|
|
12606
12613
|
className: cn(
|
|
12607
|
-
"relative block w-full max-w-[var(--field-max-width,296px)] min-h-[
|
|
12614
|
+
"relative block w-full max-w-[var(--field-max-width,296px)] min-h-[var(--field-min-height,48px)]",
|
|
12608
12615
|
disabled && "cursor-not-allowed opacity-50",
|
|
12609
12616
|
loading && "cursor-progress opacity-50",
|
|
12610
12617
|
wrapperClassName,
|
|
@@ -12624,7 +12631,7 @@ var Input = React44.forwardRef(
|
|
|
12624
12631
|
{
|
|
12625
12632
|
className: cn(
|
|
12626
12633
|
"relative block w-full",
|
|
12627
|
-
readOnly && "bg-[var(--
|
|
12634
|
+
readOnly && "bg-[var(--empty-field-background)]",
|
|
12628
12635
|
fieldClassName
|
|
12629
12636
|
),
|
|
12630
12637
|
children: [
|
|
@@ -12676,7 +12683,7 @@ var Input = React44.forwardRef(
|
|
|
12676
12683
|
className: cn(
|
|
12677
12684
|
"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",
|
|
12678
12685
|
"placeholder:font-medium placeholder:text-[var(--chekin-color-gray-1)] placeholder:opacity-100",
|
|
12679
|
-
isEmpty && !isFocused ? "bg-[var(--
|
|
12686
|
+
isEmpty && !isFocused ? "bg-[var(--empty-field-background)]" : "bg-transparent",
|
|
12680
12687
|
isEmpty && "text-[var(--chekin-color-gray-1)]",
|
|
12681
12688
|
inputType === "password" && "[&:not(:placeholder-shown)]:font-bold [&:not(:placeholder-shown)]:tracking-[2px]",
|
|
12682
12689
|
(disabled || readOnly) && "cursor-not-allowed",
|
|
@@ -12809,14 +12816,14 @@ function SelectFieldShell({
|
|
|
12809
12816
|
onBlur,
|
|
12810
12817
|
className: cn(
|
|
12811
12818
|
"relative w-full max-w-[var(--field-max-width,296px)]",
|
|
12812
|
-
disabled && "cursor-not-allowed opacity-50",
|
|
12813
|
-
loading && "cursor-progress",
|
|
12819
|
+
disabled && !loading && "cursor-not-allowed opacity-50",
|
|
12820
|
+
loading && "cursor-progress opacity-50",
|
|
12814
12821
|
className
|
|
12815
12822
|
),
|
|
12816
12823
|
style: wrapperWidth ? { width: wrapperWidth } : void 0,
|
|
12817
12824
|
children: [
|
|
12818
12825
|
name && /* @__PURE__ */ (0, import_jsx_runtime146.jsx)("input", { type: "hidden", name, value: hiddenValue ?? "" }),
|
|
12819
|
-
/* @__PURE__ */ (0, import_jsx_runtime146.jsxs)("div", { className: "relative min-h-[
|
|
12826
|
+
/* @__PURE__ */ (0, import_jsx_runtime146.jsxs)("div", { className: "relative min-h-[var(--field-min-height,48px)] w-full", children: [
|
|
12820
12827
|
topLabel && /* @__PURE__ */ (0, import_jsx_runtime146.jsx)(
|
|
12821
12828
|
"label",
|
|
12822
12829
|
{
|
|
@@ -12850,13 +12857,19 @@ function getOptionIndex(options, option) {
|
|
|
12850
12857
|
if (!option) return -1;
|
|
12851
12858
|
return options.findIndex((item) => item.value === option.value);
|
|
12852
12859
|
}
|
|
12853
|
-
function
|
|
12854
|
-
|
|
12860
|
+
function isOptionEnabled(option, isOptionDisabled) {
|
|
12861
|
+
if (!option) return false;
|
|
12862
|
+
if (option.isDisabled) return false;
|
|
12863
|
+
if (isOptionDisabled?.(option)) return false;
|
|
12864
|
+
return true;
|
|
12865
|
+
}
|
|
12866
|
+
function getFirstEnabledOptionIndex(options, isOptionDisabled) {
|
|
12867
|
+
return options.findIndex((option) => isOptionEnabled(option, isOptionDisabled));
|
|
12855
12868
|
}
|
|
12856
|
-
function getNextEnabledOptionIndex(options, startIndex, step) {
|
|
12869
|
+
function getNextEnabledOptionIndex(options, startIndex, step, isOptionDisabled) {
|
|
12857
12870
|
let nextIndex = startIndex;
|
|
12858
12871
|
while (nextIndex >= 0 && nextIndex < options.length) {
|
|
12859
|
-
if (
|
|
12872
|
+
if (isOptionEnabled(options[nextIndex], isOptionDisabled)) return nextIndex;
|
|
12860
12873
|
nextIndex += step;
|
|
12861
12874
|
}
|
|
12862
12875
|
return -1;
|
|
@@ -12887,6 +12900,7 @@ function SelectMenu({
|
|
|
12887
12900
|
onOptionHover,
|
|
12888
12901
|
onKeyDown,
|
|
12889
12902
|
disabled,
|
|
12903
|
+
isOptionDisabled,
|
|
12890
12904
|
menuClassName,
|
|
12891
12905
|
listRef,
|
|
12892
12906
|
selectedOptionRef,
|
|
@@ -12921,7 +12935,9 @@ function SelectMenu({
|
|
|
12921
12935
|
const isSelected = isOptionSelected(option, selectedValue, selectedValues);
|
|
12922
12936
|
const isHighlighted = index === highlightedIndex;
|
|
12923
12937
|
const optionKey = `${String(option.value)}-${index}`;
|
|
12924
|
-
const
|
|
12938
|
+
const isOptionDisabledFlag = Boolean(
|
|
12939
|
+
disabled || option.isDisabled || isOptionDisabled?.(option)
|
|
12940
|
+
);
|
|
12925
12941
|
return /* @__PURE__ */ (0, import_jsx_runtime147.jsxs)(
|
|
12926
12942
|
"button",
|
|
12927
12943
|
{
|
|
@@ -12932,9 +12948,9 @@ function SelectMenu({
|
|
|
12932
12948
|
type: "button",
|
|
12933
12949
|
role: "option",
|
|
12934
12950
|
"aria-selected": isSelected,
|
|
12935
|
-
"aria-disabled":
|
|
12951
|
+
"aria-disabled": isOptionDisabledFlag,
|
|
12936
12952
|
tabIndex: -1,
|
|
12937
|
-
disabled:
|
|
12953
|
+
disabled: isOptionDisabledFlag,
|
|
12938
12954
|
onClick: () => onOptionClick(option),
|
|
12939
12955
|
onMouseMove: () => onOptionHover?.(index),
|
|
12940
12956
|
className: cn(
|
|
@@ -12942,7 +12958,7 @@ function SelectMenu({
|
|
|
12942
12958
|
"last:border-b-transparent",
|
|
12943
12959
|
isHighlighted && !isSelected && "cursor-pointer text-[var(--chekin-color-brand-blue)]",
|
|
12944
12960
|
isSelected && "cursor-default font-bold text-[var(--chekin-color-brand-navy)]",
|
|
12945
|
-
|
|
12961
|
+
isOptionDisabledFlag && "cursor-default opacity-30"
|
|
12946
12962
|
),
|
|
12947
12963
|
children: [
|
|
12948
12964
|
/* @__PURE__ */ (0, import_jsx_runtime147.jsx)("span", { className: "block break-words", children: option.label }),
|
|
@@ -13102,25 +13118,22 @@ function SelectTrigger({
|
|
|
13102
13118
|
onBlur,
|
|
13103
13119
|
className: cn(
|
|
13104
13120
|
"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",
|
|
13105
|
-
isEmpty ? "bg-[var(--
|
|
13106
|
-
disabled && "cursor-not-allowed opacity-50",
|
|
13107
|
-
loading && "cursor-progress"
|
|
13121
|
+
isEmpty ? "bg-[var(--empty-field-background)] text-[var(--chekin-color-gray-1)]" : "bg-transparent text-[var(--chekin-color-brand-navy)]",
|
|
13122
|
+
disabled && !loading && "cursor-not-allowed opacity-50",
|
|
13123
|
+
loading && "!cursor-progress"
|
|
13108
13124
|
),
|
|
13109
13125
|
children: [
|
|
13110
13126
|
/* @__PURE__ */ (0, import_jsx_runtime150.jsx)("span", { id: valueId, className: "block min-w-0 flex-1 truncate text-left", children: valueLabel ?? (isOpen ? placeholder : null) }),
|
|
13111
|
-
/* @__PURE__ */ (0, import_jsx_runtime150.
|
|
13112
|
-
|
|
13113
|
-
|
|
13114
|
-
|
|
13115
|
-
|
|
13116
|
-
|
|
13117
|
-
|
|
13118
|
-
|
|
13119
|
-
|
|
13120
|
-
|
|
13121
|
-
}
|
|
13122
|
-
)
|
|
13123
|
-
] })
|
|
13127
|
+
/* @__PURE__ */ (0, import_jsx_runtime150.jsx)("span", { className: "pointer-events-none flex items-center gap-2 text-[var(--chekin-color-gray-2)]", children: /* @__PURE__ */ (0, import_jsx_runtime150.jsx)(
|
|
13128
|
+
import_lucide_react44.ChevronDown,
|
|
13129
|
+
{
|
|
13130
|
+
size: 16,
|
|
13131
|
+
className: cn(
|
|
13132
|
+
"transition-transform duration-200",
|
|
13133
|
+
isOpen && "rotate-180 text-[var(--chekin-color-brand-blue)]"
|
|
13134
|
+
)
|
|
13135
|
+
}
|
|
13136
|
+
) })
|
|
13124
13137
|
]
|
|
13125
13138
|
}
|
|
13126
13139
|
);
|
|
@@ -13178,9 +13191,9 @@ function ComboboxTrigger({
|
|
|
13178
13191
|
className: cn(
|
|
13179
13192
|
"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",
|
|
13180
13193
|
"min-h-12",
|
|
13181
|
-
isEmpty && !isFocused ? "bg-[var(--
|
|
13182
|
-
disabled && "cursor-not-allowed",
|
|
13183
|
-
loading && "cursor-progress",
|
|
13194
|
+
isEmpty && !isFocused ? "bg-[var(--empty-field-background)]" : "bg-transparent",
|
|
13195
|
+
disabled && !loading && "cursor-not-allowed",
|
|
13196
|
+
loading && "!cursor-progress",
|
|
13184
13197
|
containerClassName
|
|
13185
13198
|
),
|
|
13186
13199
|
children: [
|
|
@@ -13213,7 +13226,8 @@ function ComboboxTrigger({
|
|
|
13213
13226
|
className: cn(
|
|
13214
13227
|
"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)]",
|
|
13215
13228
|
isMulti && "min-w-[40px]",
|
|
13216
|
-
isBlocked && "cursor-not-allowed",
|
|
13229
|
+
isBlocked && !loading && "cursor-not-allowed",
|
|
13230
|
+
loading && "!cursor-progress",
|
|
13217
13231
|
inputClassName
|
|
13218
13232
|
)
|
|
13219
13233
|
}
|
|
@@ -13222,7 +13236,6 @@ function ComboboxTrigger({
|
|
|
13222
13236
|
}
|
|
13223
13237
|
),
|
|
13224
13238
|
/* @__PURE__ */ (0, import_jsx_runtime151.jsxs)("span", { className: "flex h-12 shrink-0 items-center gap-2 self-start pl-2 pr-4 text-[var(--chekin-color-gray-2)]", children: [
|
|
13225
|
-
loading && /* @__PURE__ */ (0, import_jsx_runtime151.jsx)(ThreeDotsLoader, { height: 18, width: 18 }),
|
|
13226
13239
|
showClear && /* @__PURE__ */ (0, import_jsx_runtime151.jsx)(
|
|
13227
13240
|
"button",
|
|
13228
13241
|
{
|
|
@@ -13511,7 +13524,7 @@ function SearchableSelectInternal({
|
|
|
13511
13524
|
legend: typeof label === "string" ? label : void 0,
|
|
13512
13525
|
label,
|
|
13513
13526
|
tooltip,
|
|
13514
|
-
labelClassName: "cursor-pointer"
|
|
13527
|
+
labelClassName: loading ? void 0 : "cursor-pointer"
|
|
13515
13528
|
}
|
|
13516
13529
|
),
|
|
13517
13530
|
/* @__PURE__ */ (0, import_jsx_runtime152.jsxs)(
|
|
@@ -13806,6 +13819,7 @@ function SelectInternal({
|
|
|
13806
13819
|
width,
|
|
13807
13820
|
noOptionsMessage,
|
|
13808
13821
|
filterOption = defaultFilterOption,
|
|
13822
|
+
isOptionDisabled,
|
|
13809
13823
|
helperText,
|
|
13810
13824
|
clearable = true,
|
|
13811
13825
|
isCreatable = false,
|
|
@@ -13868,9 +13882,9 @@ function SelectInternal({
|
|
|
13868
13882
|
}
|
|
13869
13883
|
setHighlightedIndex((current) => {
|
|
13870
13884
|
if (current >= 0 && current < filteredOptions.length) return current;
|
|
13871
|
-
return getFirstEnabledOptionIndex(filteredOptions);
|
|
13885
|
+
return getFirstEnabledOptionIndex(filteredOptions, isOptionDisabled);
|
|
13872
13886
|
});
|
|
13873
|
-
}, [isOpen, filteredOptions]);
|
|
13887
|
+
}, [isOpen, filteredOptions, isOptionDisabled]);
|
|
13874
13888
|
React50.useEffect(() => {
|
|
13875
13889
|
if (!isOpen) return;
|
|
13876
13890
|
if (highlightedIndex < 0) return;
|
|
@@ -13884,8 +13898,8 @@ function SelectInternal({
|
|
|
13884
13898
|
return () => window.cancelAnimationFrame(frame);
|
|
13885
13899
|
}, [isOpen, isMobile3]);
|
|
13886
13900
|
const commitSelection = (option) => {
|
|
13887
|
-
if (option
|
|
13888
|
-
onChange(option);
|
|
13901
|
+
if (!isOptionEnabled(option, isOptionDisabled)) return;
|
|
13902
|
+
onChange(option, { action: "select" });
|
|
13889
13903
|
setInputValue(resolveLabel(option));
|
|
13890
13904
|
setIsOpen(false);
|
|
13891
13905
|
setIsFocused(false);
|
|
@@ -13894,7 +13908,7 @@ function SelectInternal({
|
|
|
13894
13908
|
const commitCreate = () => {
|
|
13895
13909
|
if (!canCreateNewOption) return;
|
|
13896
13910
|
const newOption = onCreateOption?.(trimmedInput) ?? { value: trimmedInput, label: trimmedInput };
|
|
13897
|
-
onChange(newOption);
|
|
13911
|
+
onChange(newOption, { action: "create" });
|
|
13898
13912
|
setInputValue(resolveLabel(newOption));
|
|
13899
13913
|
setIsOpen(false);
|
|
13900
13914
|
setIsFocused(false);
|
|
@@ -13903,7 +13917,7 @@ function SelectInternal({
|
|
|
13903
13917
|
const clearSelection = (event) => {
|
|
13904
13918
|
event.stopPropagation();
|
|
13905
13919
|
if (isBlocked) return;
|
|
13906
|
-
onChange(null);
|
|
13920
|
+
onChange(null, { action: "clear" });
|
|
13907
13921
|
setInputValue("");
|
|
13908
13922
|
inputRef.current?.focus();
|
|
13909
13923
|
};
|
|
@@ -13926,7 +13940,12 @@ function SelectInternal({
|
|
|
13926
13940
|
setIsOpen(true);
|
|
13927
13941
|
return;
|
|
13928
13942
|
}
|
|
13929
|
-
const next = getNextEnabledOptionIndex(
|
|
13943
|
+
const next = getNextEnabledOptionIndex(
|
|
13944
|
+
filteredOptions,
|
|
13945
|
+
highlightedIndex + 1,
|
|
13946
|
+
1,
|
|
13947
|
+
isOptionDisabled
|
|
13948
|
+
);
|
|
13930
13949
|
if (next >= 0) setHighlightedIndex(next);
|
|
13931
13950
|
return;
|
|
13932
13951
|
}
|
|
@@ -13936,7 +13955,12 @@ function SelectInternal({
|
|
|
13936
13955
|
setIsOpen(true);
|
|
13937
13956
|
return;
|
|
13938
13957
|
}
|
|
13939
|
-
const next = getNextEnabledOptionIndex(
|
|
13958
|
+
const next = getNextEnabledOptionIndex(
|
|
13959
|
+
filteredOptions,
|
|
13960
|
+
highlightedIndex - 1,
|
|
13961
|
+
-1,
|
|
13962
|
+
isOptionDisabled
|
|
13963
|
+
);
|
|
13940
13964
|
if (next >= 0) setHighlightedIndex(next);
|
|
13941
13965
|
return;
|
|
13942
13966
|
}
|
|
@@ -13944,7 +13968,7 @@ function SelectInternal({
|
|
|
13944
13968
|
if (!isOpen) return;
|
|
13945
13969
|
event.preventDefault();
|
|
13946
13970
|
const option = filteredOptions[highlightedIndex];
|
|
13947
|
-
if (option &&
|
|
13971
|
+
if (option && isOptionEnabled(option, isOptionDisabled)) {
|
|
13948
13972
|
commitSelection(option);
|
|
13949
13973
|
} else if (canCreateNewOption) {
|
|
13950
13974
|
commitCreate();
|
|
@@ -14071,6 +14095,7 @@ function SelectInternal({
|
|
|
14071
14095
|
onOptionClick: commitSelection,
|
|
14072
14096
|
onOptionHover: setHighlightedIndex,
|
|
14073
14097
|
disabled: isBlocked,
|
|
14098
|
+
isOptionDisabled,
|
|
14074
14099
|
menuClassName,
|
|
14075
14100
|
listRef,
|
|
14076
14101
|
selectedOptionRef: (index, node) => {
|
|
@@ -14165,6 +14190,7 @@ function MultiSelectInternal({
|
|
|
14165
14190
|
width,
|
|
14166
14191
|
noOptionsMessage,
|
|
14167
14192
|
filterOption,
|
|
14193
|
+
isOptionDisabled,
|
|
14168
14194
|
closeMenuOnSelect = false,
|
|
14169
14195
|
renderChip,
|
|
14170
14196
|
helperText,
|
|
@@ -14228,9 +14254,9 @@ function MultiSelectInternal({
|
|
|
14228
14254
|
}
|
|
14229
14255
|
setHighlightedIndex((current) => {
|
|
14230
14256
|
if (current >= 0 && current < filteredOptions.length) return current;
|
|
14231
|
-
return getFirstEnabledOptionIndex(filteredOptions);
|
|
14257
|
+
return getFirstEnabledOptionIndex(filteredOptions, isOptionDisabled);
|
|
14232
14258
|
});
|
|
14233
|
-
}, [isOpen, filteredOptions]);
|
|
14259
|
+
}, [isOpen, filteredOptions, isOptionDisabled]);
|
|
14234
14260
|
React52.useEffect(() => {
|
|
14235
14261
|
if (!isOpen || !isMobile3) return;
|
|
14236
14262
|
const frame = window.requestAnimationFrame(
|
|
@@ -14244,10 +14270,10 @@ function MultiSelectInternal({
|
|
|
14244
14270
|
setIsFocused(true);
|
|
14245
14271
|
};
|
|
14246
14272
|
const toggleOption = (option) => {
|
|
14247
|
-
if (option
|
|
14273
|
+
if (!isOptionEnabled(option, isOptionDisabled)) return;
|
|
14248
14274
|
const exists = isValueSelected(selectedValues, option);
|
|
14249
14275
|
const next = exists ? selectedValues.filter((item) => item.value !== option.value) : [...selectedValues, option];
|
|
14250
|
-
onChange(next);
|
|
14276
|
+
onChange(next, { action: exists ? "deselect" : "select" });
|
|
14251
14277
|
clearSearch();
|
|
14252
14278
|
if (closeMenuOnSelect) {
|
|
14253
14279
|
setIsOpen(false);
|
|
@@ -14257,18 +14283,21 @@ function MultiSelectInternal({
|
|
|
14257
14283
|
};
|
|
14258
14284
|
const removeOption = (option) => {
|
|
14259
14285
|
if (isBlocked) return;
|
|
14260
|
-
onChange(
|
|
14286
|
+
onChange(
|
|
14287
|
+
selectedValues.filter((item) => item.value !== option.value),
|
|
14288
|
+
{ action: "deselect" }
|
|
14289
|
+
);
|
|
14261
14290
|
inputRef.current?.focus();
|
|
14262
14291
|
};
|
|
14263
14292
|
const clearAll = () => {
|
|
14264
14293
|
if (isBlocked) return;
|
|
14265
|
-
onChange([]);
|
|
14294
|
+
onChange([], { action: "clear" });
|
|
14266
14295
|
inputRef.current?.focus();
|
|
14267
14296
|
};
|
|
14268
14297
|
const createOption = React52.useCallback(() => {
|
|
14269
14298
|
if (!canCreateNewOption) return;
|
|
14270
14299
|
const newOption = onCreateOption?.(trimmedSearch) ?? { value: trimmedSearch, label: trimmedSearch };
|
|
14271
|
-
onChange([...selectedValues, newOption]);
|
|
14300
|
+
onChange([...selectedValues, newOption], { action: "create" });
|
|
14272
14301
|
clearSearch();
|
|
14273
14302
|
inputRef.current?.focus();
|
|
14274
14303
|
if (closeMenuOnSelect) setIsOpen(false);
|
|
@@ -14285,7 +14314,7 @@ function MultiSelectInternal({
|
|
|
14285
14314
|
const handleInputKeyDown = (event) => {
|
|
14286
14315
|
if (event.key === "Backspace" && !searchValue && selectedValues.length > 0) {
|
|
14287
14316
|
event.preventDefault();
|
|
14288
|
-
onChange(selectedValues.slice(0, -1));
|
|
14317
|
+
onChange(selectedValues.slice(0, -1), { action: "deselect" });
|
|
14289
14318
|
return;
|
|
14290
14319
|
}
|
|
14291
14320
|
if (event.key === "ArrowDown") {
|
|
@@ -14294,7 +14323,12 @@ function MultiSelectInternal({
|
|
|
14294
14323
|
openMenu();
|
|
14295
14324
|
return;
|
|
14296
14325
|
}
|
|
14297
|
-
const next = getNextEnabledOptionIndex(
|
|
14326
|
+
const next = getNextEnabledOptionIndex(
|
|
14327
|
+
filteredOptions,
|
|
14328
|
+
highlightedIndex + 1,
|
|
14329
|
+
1,
|
|
14330
|
+
isOptionDisabled
|
|
14331
|
+
);
|
|
14298
14332
|
if (next >= 0) setHighlightedIndex(next);
|
|
14299
14333
|
return;
|
|
14300
14334
|
}
|
|
@@ -14304,7 +14338,12 @@ function MultiSelectInternal({
|
|
|
14304
14338
|
openMenu();
|
|
14305
14339
|
return;
|
|
14306
14340
|
}
|
|
14307
|
-
const next = getNextEnabledOptionIndex(
|
|
14341
|
+
const next = getNextEnabledOptionIndex(
|
|
14342
|
+
filteredOptions,
|
|
14343
|
+
highlightedIndex - 1,
|
|
14344
|
+
-1,
|
|
14345
|
+
isOptionDisabled
|
|
14346
|
+
);
|
|
14308
14347
|
if (next >= 0) setHighlightedIndex(next);
|
|
14309
14348
|
return;
|
|
14310
14349
|
}
|
|
@@ -14312,7 +14351,7 @@ function MultiSelectInternal({
|
|
|
14312
14351
|
if (!isOpen) return;
|
|
14313
14352
|
event.preventDefault();
|
|
14314
14353
|
const option = filteredOptions[highlightedIndex];
|
|
14315
|
-
if (option &&
|
|
14354
|
+
if (option && isOptionEnabled(option, isOptionDisabled)) {
|
|
14316
14355
|
toggleOption(option);
|
|
14317
14356
|
} else if (canCreateNewOption) {
|
|
14318
14357
|
createOption();
|
|
@@ -14460,6 +14499,7 @@ function MultiSelectInternal({
|
|
|
14460
14499
|
onOptionClick: toggleOption,
|
|
14461
14500
|
onOptionHover: setHighlightedIndex,
|
|
14462
14501
|
disabled: isBlocked,
|
|
14502
|
+
isOptionDisabled,
|
|
14463
14503
|
menuClassName,
|
|
14464
14504
|
listRef,
|
|
14465
14505
|
selectedOptionRef: (index, node) => {
|
|
@@ -14978,17 +15018,79 @@ var InfiniteScrollSelect = React54.forwardRef(
|
|
|
14978
15018
|
);
|
|
14979
15019
|
|
|
14980
15020
|
// src/dashboard/textarea/Textarea.tsx
|
|
14981
|
-
var
|
|
15021
|
+
var React56 = __toESM(require("react"), 1);
|
|
14982
15022
|
var import_react_i18next36 = require("react-i18next");
|
|
15023
|
+
|
|
15024
|
+
// src/dashboard/textarea/useTextareaValueState.ts
|
|
15025
|
+
var React55 = __toESM(require("react"), 1);
|
|
15026
|
+
var isEmptyValue2 = (value) => {
|
|
15027
|
+
if (value === void 0 || value === null) return true;
|
|
15028
|
+
return String(value).length === 0;
|
|
15029
|
+
};
|
|
15030
|
+
var getTextareaEmptyState = ({
|
|
15031
|
+
empty,
|
|
15032
|
+
defaultValue,
|
|
15033
|
+
value
|
|
15034
|
+
}) => {
|
|
15035
|
+
if (typeof empty !== "undefined") return empty;
|
|
15036
|
+
if (typeof value !== "undefined") return isEmptyValue2(value);
|
|
15037
|
+
return isEmptyValue2(defaultValue);
|
|
15038
|
+
};
|
|
15039
|
+
function useTextareaValueState({
|
|
15040
|
+
empty,
|
|
15041
|
+
value,
|
|
15042
|
+
defaultValue
|
|
15043
|
+
}) {
|
|
15044
|
+
const textareaRef = React55.useRef(null);
|
|
15045
|
+
const isControlled = typeof empty !== "undefined" || typeof value !== "undefined";
|
|
15046
|
+
const propsAreEmpty = getTextareaEmptyState({ empty, value, defaultValue });
|
|
15047
|
+
const [nativeIsEmpty, setNativeIsEmpty] = React55.useState(propsAreEmpty);
|
|
15048
|
+
const isEmpty = isControlled ? propsAreEmpty : nativeIsEmpty;
|
|
15049
|
+
const setNativeValue = React55.useCallback(
|
|
15050
|
+
(nextValue) => {
|
|
15051
|
+
if (isControlled) return;
|
|
15052
|
+
const nextIsEmpty = nextValue.length === 0;
|
|
15053
|
+
setNativeIsEmpty(
|
|
15054
|
+
(prevIsEmpty) => prevIsEmpty === nextIsEmpty ? prevIsEmpty : nextIsEmpty
|
|
15055
|
+
);
|
|
15056
|
+
},
|
|
15057
|
+
[isControlled]
|
|
15058
|
+
);
|
|
15059
|
+
const syncValueState = React55.useCallback(() => {
|
|
15060
|
+
if (!textareaRef.current) return;
|
|
15061
|
+
setNativeValue(textareaRef.current.value);
|
|
15062
|
+
}, [setNativeValue]);
|
|
15063
|
+
React55.useLayoutEffect(() => {
|
|
15064
|
+
syncValueState();
|
|
15065
|
+
});
|
|
15066
|
+
React55.useEffect(() => {
|
|
15067
|
+
const textarea = textareaRef.current;
|
|
15068
|
+
const form = textarea?.form;
|
|
15069
|
+
if (isControlled || !form) return;
|
|
15070
|
+
const handleReset = () => {
|
|
15071
|
+
if (typeof window !== "undefined" && window.requestAnimationFrame) {
|
|
15072
|
+
window.requestAnimationFrame(syncValueState);
|
|
15073
|
+
return;
|
|
15074
|
+
}
|
|
15075
|
+
globalThis.setTimeout(syncValueState, 0);
|
|
15076
|
+
};
|
|
15077
|
+
form.addEventListener("reset", handleReset);
|
|
15078
|
+
return () => form.removeEventListener("reset", handleReset);
|
|
15079
|
+
}, [isControlled, syncValueState]);
|
|
15080
|
+
return {
|
|
15081
|
+
textareaRef,
|
|
15082
|
+
isControlled,
|
|
15083
|
+
isEmpty,
|
|
15084
|
+
setNativeValue,
|
|
15085
|
+
syncValueState
|
|
15086
|
+
};
|
|
15087
|
+
}
|
|
15088
|
+
|
|
15089
|
+
// src/dashboard/textarea/Textarea.tsx
|
|
14983
15090
|
var import_jsx_runtime161 = require("react/jsx-runtime");
|
|
14984
15091
|
var LINE_HEIGHT = 20;
|
|
14985
15092
|
var VERTICAL_PADDING = 32;
|
|
14986
|
-
|
|
14987
|
-
if (typeof empty === "boolean") return empty;
|
|
14988
|
-
if (value !== void 0) return !String(value);
|
|
14989
|
-
return !defaultValue;
|
|
14990
|
-
}
|
|
14991
|
-
var Textarea = React55.forwardRef(function Textarea2({
|
|
15093
|
+
var Textarea = React56.forwardRef(function Textarea2({
|
|
14992
15094
|
className,
|
|
14993
15095
|
textareaClassName,
|
|
14994
15096
|
label,
|
|
@@ -15009,18 +15111,20 @@ var Textarea = React55.forwardRef(function Textarea2({
|
|
|
15009
15111
|
value,
|
|
15010
15112
|
defaultValue,
|
|
15011
15113
|
onInput,
|
|
15114
|
+
onChange,
|
|
15115
|
+
onFocus,
|
|
15116
|
+
onBlur,
|
|
15012
15117
|
...textareaProps
|
|
15013
15118
|
}, ref) {
|
|
15014
|
-
const
|
|
15015
|
-
const combinedRef = useCombinedRef(ref,
|
|
15016
|
-
const reactId =
|
|
15119
|
+
const { textareaRef, isControlled, isEmpty, setNativeValue, syncValueState } = useTextareaValueState({ empty, value, defaultValue });
|
|
15120
|
+
const combinedRef = useCombinedRef(ref, textareaRef);
|
|
15121
|
+
const reactId = React56.useId();
|
|
15017
15122
|
const textareaId = id ?? name ?? `dash-textarea-${reactId}`;
|
|
15018
15123
|
const { t } = (0, import_react_i18next36.useTranslation)();
|
|
15019
15124
|
const isInvalid = Boolean(invalid || error);
|
|
15020
|
-
const isEmpty = getEmptyState(empty, value, defaultValue);
|
|
15021
15125
|
const isBlocked = Boolean(disabled);
|
|
15022
|
-
const resize =
|
|
15023
|
-
const el =
|
|
15126
|
+
const resize = React56.useCallback(() => {
|
|
15127
|
+
const el = textareaRef.current;
|
|
15024
15128
|
if (!el || !autosize) return;
|
|
15025
15129
|
el.style.height = "auto";
|
|
15026
15130
|
const minHeight = minRows * LINE_HEIGHT + VERTICAL_PADDING;
|
|
@@ -15028,14 +15132,30 @@ var Textarea = React55.forwardRef(function Textarea2({
|
|
|
15028
15132
|
const nextHeight = Math.min(Math.max(el.scrollHeight, minHeight), maxHeight);
|
|
15029
15133
|
el.style.height = `${nextHeight}px`;
|
|
15030
15134
|
el.style.overflowY = el.scrollHeight > nextHeight ? "auto" : "hidden";
|
|
15031
|
-
}, [autosize, maxRows, minRows]);
|
|
15032
|
-
|
|
15135
|
+
}, [autosize, maxRows, minRows, textareaRef]);
|
|
15136
|
+
React56.useLayoutEffect(() => {
|
|
15033
15137
|
resize();
|
|
15034
15138
|
}, [resize, value]);
|
|
15035
15139
|
const handleInput = (event) => {
|
|
15036
15140
|
resize();
|
|
15037
15141
|
onInput?.(event);
|
|
15038
15142
|
};
|
|
15143
|
+
const handleChange = (event) => {
|
|
15144
|
+
if (readOnly || disabled) return;
|
|
15145
|
+
if (!isControlled) {
|
|
15146
|
+
setNativeValue(event.currentTarget.value);
|
|
15147
|
+
}
|
|
15148
|
+
onChange?.(event);
|
|
15149
|
+
};
|
|
15150
|
+
const handleFocus = (event) => {
|
|
15151
|
+
if (readOnly || disabled) return;
|
|
15152
|
+
onFocus?.(event);
|
|
15153
|
+
syncValueState();
|
|
15154
|
+
};
|
|
15155
|
+
const handleBlur = (event) => {
|
|
15156
|
+
onBlur?.(event);
|
|
15157
|
+
syncValueState();
|
|
15158
|
+
};
|
|
15039
15159
|
return /* @__PURE__ */ (0, import_jsx_runtime161.jsxs)(
|
|
15040
15160
|
"div",
|
|
15041
15161
|
{
|
|
@@ -15071,11 +15191,14 @@ var Textarea = React55.forwardRef(function Textarea2({
|
|
|
15071
15191
|
"aria-invalid": isInvalid,
|
|
15072
15192
|
"aria-busy": loading,
|
|
15073
15193
|
onInput: handleInput,
|
|
15194
|
+
onChange: handleChange,
|
|
15195
|
+
onFocus: handleFocus,
|
|
15196
|
+
onBlur: handleBlur,
|
|
15074
15197
|
className: cn(
|
|
15075
15198
|
"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",
|
|
15076
15199
|
"border-[var(--chekin-color-gray-3)] placeholder:font-medium placeholder:text-[var(--chekin-color-gray-1)]",
|
|
15077
15200
|
!isBlocked && "focus:border-[var(--chekin-color-brand-blue)]",
|
|
15078
|
-
isEmpty && "border-[var(--chekin-color-gray-3)] bg-[var(--
|
|
15201
|
+
isEmpty && "border-[var(--chekin-color-gray-3)] bg-[var(--empty-field-background)] text-[var(--chekin-color-gray-1)]",
|
|
15079
15202
|
isInvalid && "border-[var(--error-message-color)] focus:border-[var(--error-message-color)]",
|
|
15080
15203
|
(readOnly || isBlocked) && "cursor-default",
|
|
15081
15204
|
isBlocked && "cursor-not-allowed",
|
|
@@ -15102,12 +15225,12 @@ var Textarea = React55.forwardRef(function Textarea2({
|
|
|
15102
15225
|
});
|
|
15103
15226
|
|
|
15104
15227
|
// src/dashboard/datepicker/Datepicker.tsx
|
|
15105
|
-
var
|
|
15228
|
+
var React58 = __toESM(require("react"), 1);
|
|
15106
15229
|
var import_lucide_react47 = require("lucide-react");
|
|
15107
15230
|
var import_react_i18next37 = require("react-i18next");
|
|
15108
15231
|
|
|
15109
15232
|
// src/airbnb-fields/datepicker/useDatePickerWheel.ts
|
|
15110
|
-
var
|
|
15233
|
+
var React57 = __toESM(require("react"), 1);
|
|
15111
15234
|
|
|
15112
15235
|
// src/airbnb-fields/datepicker/datePicker.utils.ts
|
|
15113
15236
|
var DISPLAY_PAD_LENGTH = 2;
|
|
@@ -15258,21 +15381,21 @@ function useDatePickerWheel({
|
|
|
15258
15381
|
minDate,
|
|
15259
15382
|
maxDate
|
|
15260
15383
|
}) {
|
|
15261
|
-
const years =
|
|
15262
|
-
const [draftDate, setDraftDate] =
|
|
15384
|
+
const years = React57.useMemo(() => getYearRange(minDate, maxDate), [maxDate, minDate]);
|
|
15385
|
+
const [draftDate, setDraftDate] = React57.useState(
|
|
15263
15386
|
() => resolveInitialDate({ value, defaultValue, minDate, maxDate })
|
|
15264
15387
|
);
|
|
15265
15388
|
const draftYear = draftDate.getFullYear();
|
|
15266
15389
|
const draftMonth = draftDate.getMonth();
|
|
15267
|
-
const [monthScrollTop, setMonthScrollTop] =
|
|
15268
|
-
const [dayScrollTop, setDayScrollTop] =
|
|
15269
|
-
const [yearScrollTop, setYearScrollTop] =
|
|
15270
|
-
const monthListRef =
|
|
15271
|
-
const dayListRef =
|
|
15272
|
-
const yearListRef =
|
|
15273
|
-
const settleTimeoutsRef =
|
|
15274
|
-
const animationFramesRef =
|
|
15275
|
-
const columnRefs =
|
|
15390
|
+
const [monthScrollTop, setMonthScrollTop] = React57.useState(0);
|
|
15391
|
+
const [dayScrollTop, setDayScrollTop] = React57.useState(0);
|
|
15392
|
+
const [yearScrollTop, setYearScrollTop] = React57.useState(0);
|
|
15393
|
+
const monthListRef = React57.useRef(null);
|
|
15394
|
+
const dayListRef = React57.useRef(null);
|
|
15395
|
+
const yearListRef = React57.useRef(null);
|
|
15396
|
+
const settleTimeoutsRef = React57.useRef({});
|
|
15397
|
+
const animationFramesRef = React57.useRef({});
|
|
15398
|
+
const columnRefs = React57.useMemo(
|
|
15276
15399
|
() => ({
|
|
15277
15400
|
month: monthListRef,
|
|
15278
15401
|
day: dayListRef,
|
|
@@ -15280,7 +15403,7 @@ function useDatePickerWheel({
|
|
|
15280
15403
|
}),
|
|
15281
15404
|
[]
|
|
15282
15405
|
);
|
|
15283
|
-
const setColumnScrollTop =
|
|
15406
|
+
const setColumnScrollTop = React57.useCallback(
|
|
15284
15407
|
(column, nextScrollTop) => {
|
|
15285
15408
|
if (column === "month") {
|
|
15286
15409
|
setMonthScrollTop(nextScrollTop);
|
|
@@ -15294,19 +15417,19 @@ function useDatePickerWheel({
|
|
|
15294
15417
|
},
|
|
15295
15418
|
[]
|
|
15296
15419
|
);
|
|
15297
|
-
const clearSettleTimeout =
|
|
15420
|
+
const clearSettleTimeout = React57.useCallback((column) => {
|
|
15298
15421
|
const timeoutId = settleTimeoutsRef.current[column];
|
|
15299
15422
|
if (timeoutId === void 0) return;
|
|
15300
15423
|
window.clearTimeout(timeoutId);
|
|
15301
15424
|
delete settleTimeoutsRef.current[column];
|
|
15302
15425
|
}, []);
|
|
15303
|
-
const clearAnimationFrame =
|
|
15426
|
+
const clearAnimationFrame = React57.useCallback((column) => {
|
|
15304
15427
|
const frameId = animationFramesRef.current[column];
|
|
15305
15428
|
if (frameId === void 0) return;
|
|
15306
15429
|
window.cancelAnimationFrame(frameId);
|
|
15307
15430
|
delete animationFramesRef.current[column];
|
|
15308
15431
|
}, []);
|
|
15309
|
-
|
|
15432
|
+
React57.useEffect(
|
|
15310
15433
|
() => () => {
|
|
15311
15434
|
["month", "day", "year"].forEach((column) => {
|
|
15312
15435
|
clearSettleTimeout(column);
|
|
@@ -15315,22 +15438,22 @@ function useDatePickerWheel({
|
|
|
15315
15438
|
},
|
|
15316
15439
|
[clearAnimationFrame, clearSettleTimeout]
|
|
15317
15440
|
);
|
|
15318
|
-
|
|
15441
|
+
React57.useEffect(() => {
|
|
15319
15442
|
if (isOpen) return;
|
|
15320
15443
|
setDraftDate(resolveInitialDate({ value, defaultValue, minDate, maxDate }));
|
|
15321
15444
|
}, [defaultValue, isOpen, maxDate, minDate, value]);
|
|
15322
|
-
const months =
|
|
15445
|
+
const months = React57.useMemo(
|
|
15323
15446
|
() => getAllowedMonths(draftYear, minDate, maxDate),
|
|
15324
15447
|
[draftYear, maxDate, minDate]
|
|
15325
15448
|
);
|
|
15326
|
-
const days =
|
|
15449
|
+
const days = React57.useMemo(
|
|
15327
15450
|
() => getAllowedDays(draftYear, draftMonth, minDate, maxDate),
|
|
15328
15451
|
[draftMonth, draftYear, maxDate, minDate]
|
|
15329
15452
|
);
|
|
15330
15453
|
const monthIndex = months.findIndex((month) => month === draftMonth);
|
|
15331
15454
|
const dayIndex = days.findIndex((day) => day === draftDate.getDate());
|
|
15332
15455
|
const yearIndex = years.findIndex((year) => year === draftYear);
|
|
15333
|
-
const syncScrollPositions =
|
|
15456
|
+
const syncScrollPositions = React57.useCallback(
|
|
15334
15457
|
(nextDate, behavior = "auto") => {
|
|
15335
15458
|
const nextMonths = getAllowedMonths(nextDate.getFullYear(), minDate, maxDate);
|
|
15336
15459
|
const nextMonthIndex = nextMonths.findIndex((month) => month === nextDate.getMonth());
|
|
@@ -15354,7 +15477,7 @@ function useDatePickerWheel({
|
|
|
15354
15477
|
},
|
|
15355
15478
|
[maxDate, minDate, years]
|
|
15356
15479
|
);
|
|
15357
|
-
|
|
15480
|
+
React57.useLayoutEffect(() => {
|
|
15358
15481
|
if (!isOpen) return;
|
|
15359
15482
|
const nextDate = resolveInitialDate({ value, defaultValue, minDate, maxDate });
|
|
15360
15483
|
setDraftDate(nextDate);
|
|
@@ -15365,7 +15488,7 @@ function useDatePickerWheel({
|
|
|
15365
15488
|
window.cancelAnimationFrame(frameId);
|
|
15366
15489
|
};
|
|
15367
15490
|
}, [defaultValue, isOpen, maxDate, minDate, syncScrollPositions, value]);
|
|
15368
|
-
const updateDraftDate =
|
|
15491
|
+
const updateDraftDate = React57.useCallback(
|
|
15369
15492
|
(column, targetIndex, behavior = "smooth") => {
|
|
15370
15493
|
const currentDate = stripTime(draftDate);
|
|
15371
15494
|
const currentYear = currentDate.getFullYear();
|
|
@@ -15410,7 +15533,7 @@ function useDatePickerWheel({
|
|
|
15410
15533
|
},
|
|
15411
15534
|
[days, draftDate, maxDate, minDate, months, syncScrollPositions, years]
|
|
15412
15535
|
);
|
|
15413
|
-
const settleColumnScroll =
|
|
15536
|
+
const settleColumnScroll = React57.useCallback(
|
|
15414
15537
|
(column) => {
|
|
15415
15538
|
const list = columnRefs[column].current;
|
|
15416
15539
|
if (!list) return;
|
|
@@ -15423,7 +15546,7 @@ function useDatePickerWheel({
|
|
|
15423
15546
|
},
|
|
15424
15547
|
[columnRefs, days.length, months.length, updateDraftDate, years.length]
|
|
15425
15548
|
);
|
|
15426
|
-
const scheduleScrollSettle =
|
|
15549
|
+
const scheduleScrollSettle = React57.useCallback(
|
|
15427
15550
|
(column) => {
|
|
15428
15551
|
clearSettleTimeout(column);
|
|
15429
15552
|
settleTimeoutsRef.current[column] = window.setTimeout(() => {
|
|
@@ -15432,7 +15555,7 @@ function useDatePickerWheel({
|
|
|
15432
15555
|
},
|
|
15433
15556
|
[clearSettleTimeout, settleColumnScroll]
|
|
15434
15557
|
);
|
|
15435
|
-
const handleColumnScroll =
|
|
15558
|
+
const handleColumnScroll = React57.useCallback(
|
|
15436
15559
|
(column) => {
|
|
15437
15560
|
const list = columnRefs[column].current;
|
|
15438
15561
|
if (!list) return;
|
|
@@ -15446,13 +15569,13 @@ function useDatePickerWheel({
|
|
|
15446
15569
|
},
|
|
15447
15570
|
[clearAnimationFrame, columnRefs, scheduleScrollSettle, setColumnScrollTop]
|
|
15448
15571
|
);
|
|
15449
|
-
const handleOptionSelect =
|
|
15572
|
+
const handleOptionSelect = React57.useCallback(
|
|
15450
15573
|
(column, targetIndex) => {
|
|
15451
15574
|
updateDraftDate(column, targetIndex, "smooth");
|
|
15452
15575
|
},
|
|
15453
15576
|
[updateDraftDate]
|
|
15454
15577
|
);
|
|
15455
|
-
const focusAdjacentColumn =
|
|
15578
|
+
const focusAdjacentColumn = React57.useCallback(
|
|
15456
15579
|
(column, direction) => {
|
|
15457
15580
|
const order = ["month", "day", "year"];
|
|
15458
15581
|
const currentIndex = order.indexOf(column);
|
|
@@ -15462,7 +15585,7 @@ function useDatePickerWheel({
|
|
|
15462
15585
|
},
|
|
15463
15586
|
[columnRefs]
|
|
15464
15587
|
);
|
|
15465
|
-
const handleColumnKeyDown =
|
|
15588
|
+
const handleColumnKeyDown = React57.useCallback(
|
|
15466
15589
|
(column, event) => {
|
|
15467
15590
|
const currentIndex = column === "month" ? monthIndex : column === "day" ? dayIndex : yearIndex;
|
|
15468
15591
|
const maxIndex = column === "month" ? months.length - 1 : column === "day" ? days.length - 1 : years.length - 1;
|
|
@@ -15784,7 +15907,7 @@ function dateFromParts(day, monthIndex, year) {
|
|
|
15784
15907
|
if (!isValidCalendarDate(yearNum, monthIndex, dayNum)) return null;
|
|
15785
15908
|
return new Date(yearNum, monthIndex, dayNum);
|
|
15786
15909
|
}
|
|
15787
|
-
var Datepicker =
|
|
15910
|
+
var Datepicker = React58.forwardRef(
|
|
15788
15911
|
function Datepicker2({
|
|
15789
15912
|
label,
|
|
15790
15913
|
value,
|
|
@@ -15814,14 +15937,14 @@ var Datepicker = React57.forwardRef(
|
|
|
15814
15937
|
maxDate,
|
|
15815
15938
|
formatValue
|
|
15816
15939
|
}, ref) {
|
|
15817
|
-
const containerRef =
|
|
15818
|
-
const dayInputRef =
|
|
15819
|
-
const monthInputRef =
|
|
15820
|
-
const monthListRef =
|
|
15821
|
-
const yearInputRef =
|
|
15822
|
-
const mobileTriggerRef =
|
|
15823
|
-
const wheelBaseId =
|
|
15824
|
-
const reactId =
|
|
15940
|
+
const containerRef = React58.useRef(null);
|
|
15941
|
+
const dayInputRef = React58.useRef(null);
|
|
15942
|
+
const monthInputRef = React58.useRef(null);
|
|
15943
|
+
const monthListRef = React58.useRef(null);
|
|
15944
|
+
const yearInputRef = React58.useRef(null);
|
|
15945
|
+
const mobileTriggerRef = React58.useRef(null);
|
|
15946
|
+
const wheelBaseId = React58.useId();
|
|
15947
|
+
const reactId = React58.useId();
|
|
15825
15948
|
const baseId = name ?? `dash-datepicker-${reactId}`;
|
|
15826
15949
|
const dayId = `${baseId}-day`;
|
|
15827
15950
|
const monthId = `${baseId}-month`;
|
|
@@ -15829,51 +15952,51 @@ var Datepicker = React57.forwardRef(
|
|
|
15829
15952
|
const labelId = `${baseId}-label`;
|
|
15830
15953
|
const errorId = `${baseId}-error`;
|
|
15831
15954
|
const { t } = (0, import_react_i18next37.useTranslation)();
|
|
15832
|
-
const resolvedMonthLabels =
|
|
15955
|
+
const resolvedMonthLabels = React58.useMemo(
|
|
15833
15956
|
() => monthLabels ?? getMonthLabels2(locale),
|
|
15834
15957
|
[locale, monthLabels]
|
|
15835
15958
|
);
|
|
15836
15959
|
const resolvedMonthPlaceholder = monthPlaceholder ?? t("month");
|
|
15837
15960
|
const resolvedDoneLabel = doneLabel ?? t("done");
|
|
15838
15961
|
const isControlled = value !== void 0;
|
|
15839
|
-
const initialParts =
|
|
15962
|
+
const initialParts = React58.useMemo(
|
|
15840
15963
|
() => partsFromDate(value ?? defaultValue ?? null),
|
|
15841
15964
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
15842
15965
|
[]
|
|
15843
15966
|
);
|
|
15844
|
-
const [day, setDay] =
|
|
15845
|
-
const [monthIndex, setMonthIndex] =
|
|
15967
|
+
const [day, setDay] = React58.useState(initialParts.day);
|
|
15968
|
+
const [monthIndex, setMonthIndex] = React58.useState(
|
|
15846
15969
|
initialParts.monthIndex
|
|
15847
15970
|
);
|
|
15848
|
-
const [year, setYear] =
|
|
15849
|
-
const [isMonthOpen, setIsMonthOpen] =
|
|
15850
|
-
const [isWheelOpen, setIsWheelOpen] =
|
|
15851
|
-
const [focusedField, setFocusedField] =
|
|
15852
|
-
const [monthInputValue, setMonthInputValue] =
|
|
15853
|
-
const [monthHighlightIndex, setMonthHighlightIndex] =
|
|
15971
|
+
const [year, setYear] = React58.useState(initialParts.year);
|
|
15972
|
+
const [isMonthOpen, setIsMonthOpen] = React58.useState(false);
|
|
15973
|
+
const [isWheelOpen, setIsWheelOpen] = React58.useState(false);
|
|
15974
|
+
const [focusedField, setFocusedField] = React58.useState(null);
|
|
15975
|
+
const [monthInputValue, setMonthInputValue] = React58.useState("");
|
|
15976
|
+
const [monthHighlightIndex, setMonthHighlightIndex] = React58.useState(-1);
|
|
15854
15977
|
const isMobile3 = useIsMobile();
|
|
15855
|
-
|
|
15856
|
-
|
|
15978
|
+
React58.useImperativeHandle(ref, () => dayInputRef.current, []);
|
|
15979
|
+
React58.useEffect(() => {
|
|
15857
15980
|
if (!isControlled) return;
|
|
15858
15981
|
const next = partsFromDate(value ?? null);
|
|
15859
15982
|
setDay(next.day);
|
|
15860
15983
|
setMonthIndex(next.monthIndex);
|
|
15861
15984
|
setYear(next.year);
|
|
15862
15985
|
}, [isControlled, value]);
|
|
15863
|
-
|
|
15986
|
+
React58.useEffect(() => {
|
|
15864
15987
|
if (focusedField === "month") return;
|
|
15865
15988
|
setMonthInputValue(
|
|
15866
15989
|
monthIndex !== null ? resolvedMonthLabels[monthIndex] ?? "" : ""
|
|
15867
15990
|
);
|
|
15868
15991
|
}, [monthIndex, resolvedMonthLabels, focusedField]);
|
|
15869
|
-
const filteredMonths =
|
|
15992
|
+
const filteredMonths = React58.useMemo(() => {
|
|
15870
15993
|
const all = resolvedMonthLabels.map((label2, index) => ({ label: label2, index }));
|
|
15871
15994
|
const query = monthInputValue.trim().toLowerCase();
|
|
15872
15995
|
const currentLabel = monthIndex !== null ? resolvedMonthLabels[monthIndex] ?? "" : "";
|
|
15873
15996
|
if (!query || monthInputValue === currentLabel) return all;
|
|
15874
15997
|
return all.filter((opt) => opt.label.toLowerCase().includes(query));
|
|
15875
15998
|
}, [monthInputValue, monthIndex, resolvedMonthLabels]);
|
|
15876
|
-
|
|
15999
|
+
React58.useEffect(() => {
|
|
15877
16000
|
if (!isMonthOpen) {
|
|
15878
16001
|
setMonthHighlightIndex(-1);
|
|
15879
16002
|
return;
|
|
@@ -15894,7 +16017,7 @@ var Datepicker = React57.forwardRef(
|
|
|
15894
16017
|
const isFocused = focusedField !== null || isMonthOpen || isWheelOpen;
|
|
15895
16018
|
const isInvalid = Boolean(invalid || error);
|
|
15896
16019
|
const wrapperWidth = toCssSize(width);
|
|
15897
|
-
const currentDate =
|
|
16020
|
+
const currentDate = React58.useMemo(
|
|
15898
16021
|
() => dateFromParts(day, monthIndex, year),
|
|
15899
16022
|
[day, monthIndex, year]
|
|
15900
16023
|
);
|
|
@@ -15903,7 +16026,7 @@ var Datepicker = React57.forwardRef(
|
|
|
15903
16026
|
onOutsideClick: () => setIsMonthOpen(false),
|
|
15904
16027
|
isDisabled: !isMonthOpen || isMobile3
|
|
15905
16028
|
});
|
|
15906
|
-
const emitChange =
|
|
16029
|
+
const emitChange = React58.useCallback(
|
|
15907
16030
|
(nextDay, nextMonth, nextYear) => {
|
|
15908
16031
|
if (!onChange) return;
|
|
15909
16032
|
const date = dateFromParts(nextDay, nextMonth, nextYear);
|
|
@@ -15938,7 +16061,7 @@ var Datepicker = React57.forwardRef(
|
|
|
15938
16061
|
setIsMonthOpen(true);
|
|
15939
16062
|
setMonthHighlightIndex(0);
|
|
15940
16063
|
};
|
|
15941
|
-
const commitMonthInput =
|
|
16064
|
+
const commitMonthInput = React58.useCallback(() => {
|
|
15942
16065
|
const query = monthInputValue.trim().toLowerCase();
|
|
15943
16066
|
if (!query) {
|
|
15944
16067
|
if (monthIndex !== null) {
|
|
@@ -15998,15 +16121,15 @@ var Datepicker = React57.forwardRef(
|
|
|
15998
16121
|
setIsMonthOpen(false);
|
|
15999
16122
|
}
|
|
16000
16123
|
};
|
|
16001
|
-
const focusDayInput =
|
|
16124
|
+
const focusDayInput = React58.useCallback(() => {
|
|
16002
16125
|
if (isBlocked || readOnly) return;
|
|
16003
16126
|
dayInputRef.current?.focus();
|
|
16004
16127
|
}, [isBlocked, readOnly]);
|
|
16005
|
-
const openWheel =
|
|
16128
|
+
const openWheel = React58.useCallback(() => {
|
|
16006
16129
|
if (isBlocked || readOnly) return;
|
|
16007
16130
|
setIsWheelOpen(true);
|
|
16008
16131
|
}, [isBlocked, readOnly]);
|
|
16009
|
-
const closeWheel =
|
|
16132
|
+
const closeWheel = React58.useCallback(() => {
|
|
16010
16133
|
setIsWheelOpen(false);
|
|
16011
16134
|
mobileTriggerRef.current?.focus();
|
|
16012
16135
|
}, []);
|
|
@@ -16018,7 +16141,7 @@ var Datepicker = React57.forwardRef(
|
|
|
16018
16141
|
minDate,
|
|
16019
16142
|
maxDate
|
|
16020
16143
|
});
|
|
16021
|
-
const handleWheelDone =
|
|
16144
|
+
const handleWheelDone = React58.useCallback(() => {
|
|
16022
16145
|
const next = wheel.draftDate;
|
|
16023
16146
|
setDay(String(next.getDate()));
|
|
16024
16147
|
setMonthIndex(next.getMonth());
|
|
@@ -16027,7 +16150,7 @@ var Datepicker = React57.forwardRef(
|
|
|
16027
16150
|
setIsWheelOpen(false);
|
|
16028
16151
|
mobileTriggerRef.current?.focus();
|
|
16029
16152
|
}, [name, onChange, wheel.draftDate]);
|
|
16030
|
-
const defaultFormatValue =
|
|
16153
|
+
const defaultFormatValue = React58.useCallback(
|
|
16031
16154
|
(date) => `${date.getDate()} ${resolvedMonthLabels[date.getMonth()]} ${date.getFullYear()}`,
|
|
16032
16155
|
[resolvedMonthLabels]
|
|
16033
16156
|
);
|
|
@@ -16079,11 +16202,11 @@ var Datepicker = React57.forwardRef(
|
|
|
16079
16202
|
className: cn(
|
|
16080
16203
|
"relative w-full max-w-[var(--field-max-width,296px)]",
|
|
16081
16204
|
disabled && "cursor-not-allowed opacity-50",
|
|
16082
|
-
loading && "cursor-progress",
|
|
16205
|
+
loading && "cursor-progress opacity-50",
|
|
16083
16206
|
className
|
|
16084
16207
|
),
|
|
16085
16208
|
style: wrapperWidth ? { width: wrapperWidth } : void 0,
|
|
16086
|
-
children: /* @__PURE__ */ (0, import_jsx_runtime164.jsxs)("div", { className: "relative min-h-[
|
|
16209
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime164.jsxs)("div", { className: "relative min-h-[var(--field-min-height,48px)] w-full", children: [
|
|
16087
16210
|
/* @__PURE__ */ (0, import_jsx_runtime164.jsxs)("div", { className: "relative w-full", children: [
|
|
16088
16211
|
isMobile3 ? /* @__PURE__ */ (0, import_jsx_runtime164.jsxs)(
|
|
16089
16212
|
"button",
|
|
@@ -16100,24 +16223,21 @@ var Datepicker = React57.forwardRef(
|
|
|
16100
16223
|
onClick: openWheel,
|
|
16101
16224
|
className: cn(
|
|
16102
16225
|
"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",
|
|
16103
|
-
triggerText ? "bg-transparent text-[var(--chekin-color-brand-navy)]" : "bg-[var(--
|
|
16226
|
+
triggerText ? "bg-transparent text-[var(--chekin-color-brand-navy)]" : "bg-[var(--empty-field-background)] text-[var(--chekin-color-gray-1)]",
|
|
16104
16227
|
(isBlocked || readOnly) && "cursor-not-allowed"
|
|
16105
16228
|
),
|
|
16106
16229
|
children: [
|
|
16107
16230
|
/* @__PURE__ */ (0, import_jsx_runtime164.jsx)("span", { className: "block min-w-0 flex-1 truncate text-left", children: triggerText ?? (isWheelOpen ? mobilePlaceholder : null) }),
|
|
16108
|
-
/* @__PURE__ */ (0, import_jsx_runtime164.
|
|
16109
|
-
|
|
16110
|
-
|
|
16111
|
-
|
|
16112
|
-
|
|
16113
|
-
|
|
16114
|
-
|
|
16115
|
-
|
|
16116
|
-
|
|
16117
|
-
|
|
16118
|
-
}
|
|
16119
|
-
)
|
|
16120
|
-
] })
|
|
16231
|
+
/* @__PURE__ */ (0, import_jsx_runtime164.jsx)("span", { className: "pointer-events-none flex items-center gap-2 text-[var(--chekin-color-gray-2)]", children: /* @__PURE__ */ (0, import_jsx_runtime164.jsx)(
|
|
16232
|
+
import_lucide_react47.ChevronDown,
|
|
16233
|
+
{
|
|
16234
|
+
size: 16,
|
|
16235
|
+
className: cn(
|
|
16236
|
+
"transition-transform duration-200",
|
|
16237
|
+
isWheelOpen && "rotate-180 text-[var(--chekin-color-brand-blue)]"
|
|
16238
|
+
)
|
|
16239
|
+
}
|
|
16240
|
+
) })
|
|
16121
16241
|
]
|
|
16122
16242
|
}
|
|
16123
16243
|
) : /* @__PURE__ */ (0, import_jsx_runtime164.jsxs)(
|
|
@@ -16210,45 +16330,35 @@ var Datepicker = React57.forwardRef(
|
|
|
16210
16330
|
}
|
|
16211
16331
|
)
|
|
16212
16332
|
] }),
|
|
16213
|
-
/* @__PURE__ */ (0, import_jsx_runtime164.
|
|
16214
|
-
|
|
16215
|
-
|
|
16216
|
-
|
|
16217
|
-
|
|
16218
|
-
|
|
16219
|
-
|
|
16220
|
-
|
|
16221
|
-
|
|
16222
|
-
|
|
16223
|
-
|
|
16224
|
-
|
|
16225
|
-
|
|
16226
|
-
|
|
16227
|
-
|
|
16228
|
-
|
|
16229
|
-
|
|
16230
|
-
|
|
16231
|
-
|
|
16232
|
-
|
|
16233
|
-
|
|
16234
|
-
|
|
16235
|
-
),
|
|
16236
|
-
loading && /* @__PURE__ */ (0, import_jsx_runtime164.jsx)(
|
|
16237
|
-
ThreeDotsLoader,
|
|
16238
|
-
{
|
|
16239
|
-
height: 18,
|
|
16240
|
-
width: 18,
|
|
16241
|
-
className: "ml-2 text-[var(--chekin-color-gray-2)]"
|
|
16242
|
-
}
|
|
16243
|
-
)
|
|
16244
|
-
] })
|
|
16333
|
+
/* @__PURE__ */ (0, import_jsx_runtime164.jsx)("div", { className: "flex h-full min-w-0 items-center px-2 sm:px-4", children: /* @__PURE__ */ (0, import_jsx_runtime164.jsx)(
|
|
16334
|
+
"input",
|
|
16335
|
+
{
|
|
16336
|
+
ref: yearInputRef,
|
|
16337
|
+
id: yearId,
|
|
16338
|
+
type: "text",
|
|
16339
|
+
inputMode: "numeric",
|
|
16340
|
+
autoComplete: "off",
|
|
16341
|
+
name: name ? `${name}-year` : void 0,
|
|
16342
|
+
value: year,
|
|
16343
|
+
placeholder: yearPlaceholder,
|
|
16344
|
+
disabled: isBlocked,
|
|
16345
|
+
readOnly,
|
|
16346
|
+
"aria-invalid": isInvalid,
|
|
16347
|
+
"aria-labelledby": labelId,
|
|
16348
|
+
onChange: handleYearChange,
|
|
16349
|
+
onFocus: () => setFocusedField("year"),
|
|
16350
|
+
onBlur: () => setFocusedField(null),
|
|
16351
|
+
maxLength: 4,
|
|
16352
|
+
className: subInputClass
|
|
16353
|
+
}
|
|
16354
|
+
) })
|
|
16245
16355
|
]
|
|
16246
16356
|
}
|
|
16247
16357
|
),
|
|
16248
16358
|
showCoverage && /* @__PURE__ */ (0, import_jsx_runtime164.jsx)(
|
|
16249
16359
|
"div",
|
|
16250
16360
|
{
|
|
16251
|
-
className: "absolute inset-0 cursor-text rounded-[6px] bg-[var(--
|
|
16361
|
+
className: "absolute inset-0 cursor-text rounded-[6px] bg-[var(--empty-field-background)]",
|
|
16252
16362
|
onClick: focusDayInput,
|
|
16253
16363
|
"aria-hidden": "true"
|
|
16254
16364
|
}
|
|
@@ -16318,7 +16428,7 @@ var Datepicker = React57.forwardRef(
|
|
|
16318
16428
|
);
|
|
16319
16429
|
|
|
16320
16430
|
// src/dashboard/date-range-picker/DateRangePicker.tsx
|
|
16321
|
-
var
|
|
16431
|
+
var React62 = __toESM(require("react"), 1);
|
|
16322
16432
|
var import_react_i18next38 = require("react-i18next");
|
|
16323
16433
|
|
|
16324
16434
|
// src/dashboard/date-range-picker/isDayBlocked.ts
|
|
@@ -16397,7 +16507,7 @@ var createDisabledMatchers = ({
|
|
|
16397
16507
|
};
|
|
16398
16508
|
|
|
16399
16509
|
// src/dashboard/date-range-picker/hooks/useRangeValue.ts
|
|
16400
|
-
var
|
|
16510
|
+
var React59 = __toESM(require("react"), 1);
|
|
16401
16511
|
var getRangeKey = (range) => `${range?.from?.getTime() ?? ""}-${range?.to?.getTime() ?? ""}`;
|
|
16402
16512
|
function useRangeValue({
|
|
16403
16513
|
value: externalValue,
|
|
@@ -16406,10 +16516,10 @@ function useRangeValue({
|
|
|
16406
16516
|
name
|
|
16407
16517
|
}) {
|
|
16408
16518
|
const isControlled = externalValue !== void 0;
|
|
16409
|
-
const [draft, setDraft] =
|
|
16519
|
+
const [draft, setDraft] = React59.useState(
|
|
16410
16520
|
isControlled ? externalValue : defaultValue
|
|
16411
16521
|
);
|
|
16412
|
-
const lastExternalKeyRef =
|
|
16522
|
+
const lastExternalKeyRef = React59.useRef(getRangeKey(externalValue));
|
|
16413
16523
|
if (isControlled) {
|
|
16414
16524
|
const externalKey = getRangeKey(externalValue);
|
|
16415
16525
|
if (externalKey !== lastExternalKeyRef.current) {
|
|
@@ -16417,7 +16527,7 @@ function useRangeValue({
|
|
|
16417
16527
|
setDraft(externalValue);
|
|
16418
16528
|
}
|
|
16419
16529
|
}
|
|
16420
|
-
const commit =
|
|
16530
|
+
const commit = React59.useCallback(
|
|
16421
16531
|
(next) => {
|
|
16422
16532
|
setDraft(next);
|
|
16423
16533
|
if (next === void 0) {
|
|
@@ -16432,7 +16542,7 @@ function useRangeValue({
|
|
|
16432
16542
|
}
|
|
16433
16543
|
|
|
16434
16544
|
// src/dashboard/date-range-picker/hooks/useRangeTextInputs.ts
|
|
16435
|
-
var
|
|
16545
|
+
var React60 = __toESM(require("react"), 1);
|
|
16436
16546
|
function useRangeTextInputs({
|
|
16437
16547
|
value,
|
|
16438
16548
|
format: format2,
|
|
@@ -16440,13 +16550,13 @@ function useRangeTextInputs({
|
|
|
16440
16550
|
onCommit,
|
|
16441
16551
|
onBlur
|
|
16442
16552
|
}) {
|
|
16443
|
-
const [fromText, setFromText] =
|
|
16444
|
-
const [toText, setToText] =
|
|
16445
|
-
|
|
16553
|
+
const [fromText, setFromText] = React60.useState(value?.from ? format2(value.from) : "");
|
|
16554
|
+
const [toText, setToText] = React60.useState(value?.to ? format2(value.to) : "");
|
|
16555
|
+
React60.useEffect(() => {
|
|
16446
16556
|
setFromText(value?.from ? format2(value.from) : "");
|
|
16447
16557
|
setToText(value?.to ? format2(value.to) : "");
|
|
16448
16558
|
}, [format2, value?.from, value?.to]);
|
|
16449
|
-
const handleFromBlur =
|
|
16559
|
+
const handleFromBlur = React60.useCallback(() => {
|
|
16450
16560
|
if (!fromText) {
|
|
16451
16561
|
const next = { from: void 0, to: value?.to };
|
|
16452
16562
|
onCommit(next);
|
|
@@ -16463,7 +16573,7 @@ function useRangeTextInputs({
|
|
|
16463
16573
|
setFromText(value?.from ? format2(value.from) : "");
|
|
16464
16574
|
return void 0;
|
|
16465
16575
|
}, [format2, fromText, onBlur, onCommit, parse3, value]);
|
|
16466
|
-
const handleToBlur =
|
|
16576
|
+
const handleToBlur = React60.useCallback(() => {
|
|
16467
16577
|
if (!toText) {
|
|
16468
16578
|
const next = { from: value?.from, to: void 0 };
|
|
16469
16579
|
onCommit(next);
|
|
@@ -16490,21 +16600,21 @@ function useRangeTextInputs({
|
|
|
16490
16600
|
}
|
|
16491
16601
|
|
|
16492
16602
|
// src/dashboard/date-range-picker/hooks/useRangeMonthSync.ts
|
|
16493
|
-
var
|
|
16603
|
+
var React61 = __toESM(require("react"), 1);
|
|
16494
16604
|
function useRangeMonthSync(value) {
|
|
16495
|
-
const isPreloadedRef =
|
|
16496
|
-
const [month, setMonth] =
|
|
16497
|
-
|
|
16605
|
+
const isPreloadedRef = React61.useRef(false);
|
|
16606
|
+
const [month, setMonth] = React61.useState(value?.from ?? /* @__PURE__ */ new Date());
|
|
16607
|
+
React61.useEffect(() => {
|
|
16498
16608
|
if (value?.from && !isPreloadedRef.current) {
|
|
16499
16609
|
setMonth(value.from);
|
|
16500
16610
|
isPreloadedRef.current = true;
|
|
16501
16611
|
}
|
|
16502
16612
|
}, [value?.from]);
|
|
16503
|
-
const syncMonthToValue =
|
|
16613
|
+
const syncMonthToValue = React61.useCallback((next) => {
|
|
16504
16614
|
isPreloadedRef.current = true;
|
|
16505
16615
|
if (next?.from) setMonth(next.from);
|
|
16506
16616
|
}, []);
|
|
16507
|
-
const resetPreload =
|
|
16617
|
+
const resetPreload = React61.useCallback(() => {
|
|
16508
16618
|
isPreloadedRef.current = false;
|
|
16509
16619
|
}, []);
|
|
16510
16620
|
return { month, setMonth, syncMonthToValue, resetPreload };
|
|
@@ -16577,7 +16687,7 @@ function DateRangeInputs({
|
|
|
16577
16687
|
{
|
|
16578
16688
|
className: cn(
|
|
16579
16689
|
"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",
|
|
16580
|
-
isEmpty && !isFocused && "bg-[var(--
|
|
16690
|
+
isEmpty && !isFocused && "bg-[var(--empty-field-background)]"
|
|
16581
16691
|
),
|
|
16582
16692
|
onClick: onRowClick,
|
|
16583
16693
|
children: [
|
|
@@ -16641,7 +16751,6 @@ function DateRangeInputs({
|
|
|
16641
16751
|
}
|
|
16642
16752
|
),
|
|
16643
16753
|
/* @__PURE__ */ (0, import_jsx_runtime165.jsxs)("span", { className: "ml-auto flex shrink-0 items-center gap-2 pl-2 text-[var(--chekin-color-gray-2)]", children: [
|
|
16644
|
-
loading && /* @__PURE__ */ (0, import_jsx_runtime165.jsx)(ThreeDotsLoader, { height: 18, width: 18 }),
|
|
16645
16754
|
!readOnly && !hideClearDates && !isEmpty && /* @__PURE__ */ (0, import_jsx_runtime165.jsx)(
|
|
16646
16755
|
"button",
|
|
16647
16756
|
{
|
|
@@ -16763,7 +16872,7 @@ function DateRangePopover({
|
|
|
16763
16872
|
|
|
16764
16873
|
// src/dashboard/date-range-picker/DateRangePicker.tsx
|
|
16765
16874
|
var import_jsx_runtime168 = require("react/jsx-runtime");
|
|
16766
|
-
var DateRangePicker =
|
|
16875
|
+
var DateRangePicker = React62.forwardRef(function DateRangePicker2({
|
|
16767
16876
|
label,
|
|
16768
16877
|
value: externalValue,
|
|
16769
16878
|
defaultValue,
|
|
@@ -16797,20 +16906,20 @@ var DateRangePicker = React61.forwardRef(function DateRangePicker2({
|
|
|
16797
16906
|
components: customComponents,
|
|
16798
16907
|
...dayPickerProps
|
|
16799
16908
|
}, ref) {
|
|
16800
|
-
const containerRef =
|
|
16801
|
-
const fromInputRef =
|
|
16802
|
-
const toInputRef =
|
|
16803
|
-
const reactId =
|
|
16909
|
+
const containerRef = React62.useRef(null);
|
|
16910
|
+
const fromInputRef = React62.useRef(null);
|
|
16911
|
+
const toInputRef = React62.useRef(null);
|
|
16912
|
+
const reactId = React62.useId();
|
|
16804
16913
|
const baseId = name ?? `dash-daterange-${reactId}`;
|
|
16805
16914
|
const fromId = `${baseId}-from`;
|
|
16806
16915
|
const toId = `${baseId}-to`;
|
|
16807
16916
|
const labelId = `${baseId}-label`;
|
|
16808
16917
|
const errorId = `${baseId}-error`;
|
|
16809
|
-
const normalizedValue =
|
|
16918
|
+
const normalizedValue = React62.useMemo(() => {
|
|
16810
16919
|
if (externalValue === void 0) return void 0;
|
|
16811
16920
|
return { from: toDate(externalValue?.from), to: toDate(externalValue?.to) };
|
|
16812
16921
|
}, [externalValue]);
|
|
16813
|
-
const normalizedDefaultValue =
|
|
16922
|
+
const normalizedDefaultValue = React62.useMemo(() => {
|
|
16814
16923
|
if (defaultValue === void 0) return void 0;
|
|
16815
16924
|
return { from: toDate(defaultValue?.from), to: toDate(defaultValue?.to) };
|
|
16816
16925
|
}, [defaultValue]);
|
|
@@ -16820,10 +16929,10 @@ var DateRangePicker = React61.forwardRef(function DateRangePicker2({
|
|
|
16820
16929
|
onChange,
|
|
16821
16930
|
name
|
|
16822
16931
|
});
|
|
16823
|
-
const normalizedMinDate =
|
|
16824
|
-
const normalizedMaxDate =
|
|
16825
|
-
const formatter =
|
|
16826
|
-
const parser =
|
|
16932
|
+
const normalizedMinDate = React62.useMemo(() => toDate(minDate), [minDate]);
|
|
16933
|
+
const normalizedMaxDate = React62.useMemo(() => toDate(maxDate), [maxDate]);
|
|
16934
|
+
const formatter = React62.useMemo(() => formatDate(displayFormat), [displayFormat]);
|
|
16935
|
+
const parser = React62.useMemo(() => parseDate(displayFormat), [displayFormat]);
|
|
16827
16936
|
const { fromText, toText, setFromText, setToText, handleFromBlur, handleToBlur } = useRangeTextInputs({
|
|
16828
16937
|
value,
|
|
16829
16938
|
format: formatter,
|
|
@@ -16832,9 +16941,9 @@ var DateRangePicker = React61.forwardRef(function DateRangePicker2({
|
|
|
16832
16941
|
onBlur
|
|
16833
16942
|
});
|
|
16834
16943
|
const { month, setMonth, syncMonthToValue } = useRangeMonthSync(value);
|
|
16835
|
-
const [isOpen, setIsOpen] =
|
|
16836
|
-
const [focusedInput, setFocusedInput] =
|
|
16837
|
-
const [autoFocus, setAutoFocus] =
|
|
16944
|
+
const [isOpen, setIsOpen] = React62.useState(false);
|
|
16945
|
+
const [focusedInput, setFocusedInput] = React62.useState(null);
|
|
16946
|
+
const [autoFocus, setAutoFocus] = React62.useState(false);
|
|
16838
16947
|
const isMobile3 = useIsMobile();
|
|
16839
16948
|
const { t } = (0, import_react_i18next38.useTranslation)();
|
|
16840
16949
|
const drawerTitle = label ?? t("select_dates");
|
|
@@ -16845,13 +16954,13 @@ var DateRangePicker = React61.forwardRef(function DateRangePicker2({
|
|
|
16845
16954
|
const isFocused = focusedInput !== null || isOpen;
|
|
16846
16955
|
const wrapperWidth = toCssSize(width);
|
|
16847
16956
|
const monthsToShow = numberOfMonths ?? (isMobile3 ? 1 : 2);
|
|
16848
|
-
const closeCalendar =
|
|
16957
|
+
const closeCalendar = React62.useCallback(() => {
|
|
16849
16958
|
setIsOpen(false);
|
|
16850
16959
|
setFocusedInput(null);
|
|
16851
16960
|
setAutoFocus(false);
|
|
16852
16961
|
if (value?.from) setMonth(value.from);
|
|
16853
16962
|
}, [setMonth, value?.from]);
|
|
16854
|
-
const openCalendar =
|
|
16963
|
+
const openCalendar = React62.useCallback(() => {
|
|
16855
16964
|
if (isBlocked || readOnly) return;
|
|
16856
16965
|
setIsOpen(true);
|
|
16857
16966
|
}, [isBlocked, readOnly]);
|
|
@@ -16860,7 +16969,7 @@ var DateRangePicker = React61.forwardRef(function DateRangePicker2({
|
|
|
16860
16969
|
onOutsideClick: closeCalendar,
|
|
16861
16970
|
isDisabled: !isOpen || isMobile3
|
|
16862
16971
|
});
|
|
16863
|
-
const handlePickerChange =
|
|
16972
|
+
const handlePickerChange = React62.useCallback(
|
|
16864
16973
|
(range, pickedDate) => {
|
|
16865
16974
|
const { next, shouldClose } = resolveRangeSelection({
|
|
16866
16975
|
previous: value,
|
|
@@ -16881,7 +16990,7 @@ var DateRangePicker = React61.forwardRef(function DateRangePicker2({
|
|
|
16881
16990
|
setToText("");
|
|
16882
16991
|
setMonth(/* @__PURE__ */ new Date());
|
|
16883
16992
|
};
|
|
16884
|
-
const disabledMatchers =
|
|
16993
|
+
const disabledMatchers = React62.useMemo(
|
|
16885
16994
|
() => createDisabledMatchers({
|
|
16886
16995
|
minDate: normalizedMinDate,
|
|
16887
16996
|
maxDate: normalizedMaxDate,
|
|
@@ -16900,7 +17009,7 @@ var DateRangePicker = React61.forwardRef(function DateRangePicker2({
|
|
|
16900
17009
|
openCalendar();
|
|
16901
17010
|
if (autoFocusOnOpen) setAutoFocus(true);
|
|
16902
17011
|
};
|
|
16903
|
-
|
|
17012
|
+
React62.useImperativeHandle(
|
|
16904
17013
|
ref,
|
|
16905
17014
|
() => ({
|
|
16906
17015
|
setDateRange: (range) => {
|
|
@@ -16930,11 +17039,11 @@ var DateRangePicker = React61.forwardRef(function DateRangePicker2({
|
|
|
16930
17039
|
className: cn(
|
|
16931
17040
|
"relative w-full max-w-[var(--field-max-width,296px)]",
|
|
16932
17041
|
disabled && "cursor-not-allowed opacity-50",
|
|
16933
|
-
loading && "cursor-progress",
|
|
17042
|
+
loading && "cursor-progress opacity-50",
|
|
16934
17043
|
className
|
|
16935
17044
|
),
|
|
16936
17045
|
style: wrapperWidth ? { width: wrapperWidth } : void 0,
|
|
16937
|
-
children: /* @__PURE__ */ (0, import_jsx_runtime168.jsxs)("div", { className: "relative min-h-[
|
|
17046
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime168.jsxs)("div", { className: "relative min-h-[var(--field-min-height,48px)] w-full", children: [
|
|
16938
17047
|
/* @__PURE__ */ (0, import_jsx_runtime168.jsxs)("div", { className: "relative w-full", children: [
|
|
16939
17048
|
/* @__PURE__ */ (0, import_jsx_runtime168.jsx)(
|
|
16940
17049
|
DateRangeInputs,
|
|
@@ -17079,7 +17188,7 @@ var DateRangePicker = React61.forwardRef(function DateRangePicker2({
|
|
|
17079
17188
|
});
|
|
17080
17189
|
|
|
17081
17190
|
// src/dashboard/date-range-picker/useValidateDates.ts
|
|
17082
|
-
var
|
|
17191
|
+
var React63 = __toESM(require("react"), 1);
|
|
17083
17192
|
var import_react_i18next39 = require("react-i18next");
|
|
17084
17193
|
var import_date_fns4 = require("date-fns");
|
|
17085
17194
|
var import_react_day_picker2 = require("react-day-picker");
|
|
@@ -17102,11 +17211,11 @@ function useValidateDates({
|
|
|
17102
17211
|
const { t } = (0, import_react_i18next39.useTranslation)();
|
|
17103
17212
|
const handleError = useEvent(onError);
|
|
17104
17213
|
const handleSuccess = useEvent(onSuccess);
|
|
17105
|
-
const errorFormatter =
|
|
17214
|
+
const errorFormatter = React63.useMemo(
|
|
17106
17215
|
() => formatDate(displayFormat ?? DEFAULT_DISPLAY_FORMAT),
|
|
17107
17216
|
[displayFormat]
|
|
17108
17217
|
);
|
|
17109
|
-
const validateDates =
|
|
17218
|
+
const validateDates = React63.useCallback(
|
|
17110
17219
|
(dates) => {
|
|
17111
17220
|
const startDate = dates?.from;
|
|
17112
17221
|
const endDate = dates?.to;
|
|
@@ -17156,7 +17265,7 @@ function useValidateDates({
|
|
|
17156
17265
|
}
|
|
17157
17266
|
|
|
17158
17267
|
// src/dashboard/time-picker/TimePicker.tsx
|
|
17159
|
-
var
|
|
17268
|
+
var React64 = __toESM(require("react"), 1);
|
|
17160
17269
|
var import_date_fns5 = require("date-fns");
|
|
17161
17270
|
var import_jsx_runtime169 = require("react/jsx-runtime");
|
|
17162
17271
|
var SHORT_TIME_FORMAT = "HH:mm";
|
|
@@ -17200,8 +17309,8 @@ var FORMAT_SETTINGS = {
|
|
|
17200
17309
|
},
|
|
17201
17310
|
hours: { intervalUnit: "H", interval: 1, minTime: "00:00", maxTime: "23:00" }
|
|
17202
17311
|
};
|
|
17203
|
-
var TimePicker =
|
|
17204
|
-
const resolvedOptions =
|
|
17312
|
+
var TimePicker = React64.forwardRef(function TimePicker2({ format: formatName = "time", timeSettings, options, ...selectProps }, ref) {
|
|
17313
|
+
const resolvedOptions = React64.useMemo(() => {
|
|
17205
17314
|
if (options) return options;
|
|
17206
17315
|
const settings = timeSettings ?? FORMAT_SETTINGS[formatName];
|
|
17207
17316
|
return buildOptions(settings);
|
|
@@ -17210,14 +17319,14 @@ var TimePicker = React63.forwardRef(function TimePicker2({ format: formatName =
|
|
|
17210
17319
|
});
|
|
17211
17320
|
|
|
17212
17321
|
// src/dashboard/file-input/FileInput.tsx
|
|
17213
|
-
var
|
|
17322
|
+
var React65 = __toESM(require("react"), 1);
|
|
17214
17323
|
var import_lucide_react49 = require("lucide-react");
|
|
17215
17324
|
var import_react_i18next40 = require("react-i18next");
|
|
17216
17325
|
var import_jsx_runtime170 = require("react/jsx-runtime");
|
|
17217
17326
|
function defaultDownload(url) {
|
|
17218
17327
|
window.open(url, "_blank", "noopener,noreferrer");
|
|
17219
17328
|
}
|
|
17220
|
-
var FileInput =
|
|
17329
|
+
var FileInput = React65.forwardRef(function FileInput2({
|
|
17221
17330
|
label,
|
|
17222
17331
|
value,
|
|
17223
17332
|
onChange,
|
|
@@ -17239,12 +17348,12 @@ var FileInput = React64.forwardRef(function FileInput2({
|
|
|
17239
17348
|
width,
|
|
17240
17349
|
downloadLabel
|
|
17241
17350
|
}, ref) {
|
|
17242
|
-
const internalRef =
|
|
17351
|
+
const internalRef = React65.useRef(null);
|
|
17243
17352
|
const inputRef = useCombinedRef(ref, internalRef);
|
|
17244
17353
|
const { t } = (0, import_react_i18next40.useTranslation)();
|
|
17245
17354
|
const resolvedLabel = label ?? t("upload_file");
|
|
17246
17355
|
const resolvedDownloadLabel = downloadLabel ?? t("download_attachment");
|
|
17247
|
-
const reactId =
|
|
17356
|
+
const reactId = React65.useId();
|
|
17248
17357
|
const inputId = `${name || "dash-file"}-${reactId}`;
|
|
17249
17358
|
const labelId = `${inputId}-label`;
|
|
17250
17359
|
const errorId = `${inputId}-error`;
|
|
@@ -17277,7 +17386,7 @@ var FileInput = React64.forwardRef(function FileInput2({
|
|
|
17277
17386
|
className: cn(
|
|
17278
17387
|
"relative block w-full max-w-[var(--field-max-width,296px)] cursor-pointer text-left",
|
|
17279
17388
|
(disabled || readOnly) && "cursor-not-allowed",
|
|
17280
|
-
loading && "cursor-progress",
|
|
17389
|
+
loading && "cursor-progress opacity-50",
|
|
17281
17390
|
disabled && "opacity-50",
|
|
17282
17391
|
className
|
|
17283
17392
|
),
|
|
@@ -17299,14 +17408,14 @@ var FileInput = React64.forwardRef(function FileInput2({
|
|
|
17299
17408
|
"aria-invalid": isInvalid
|
|
17300
17409
|
}
|
|
17301
17410
|
),
|
|
17302
|
-
/* @__PURE__ */ (0, import_jsx_runtime170.jsxs)("div", { className: "relative
|
|
17411
|
+
/* @__PURE__ */ (0, import_jsx_runtime170.jsxs)("div", { className: "relative w-full", children: [
|
|
17303
17412
|
/* @__PURE__ */ (0, import_jsx_runtime170.jsxs)("div", { className: "relative w-full", children: [
|
|
17304
17413
|
/* @__PURE__ */ (0, import_jsx_runtime170.jsxs)(
|
|
17305
17414
|
"div",
|
|
17306
17415
|
{
|
|
17307
17416
|
className: cn(
|
|
17308
17417
|
"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)]",
|
|
17309
|
-
isEmpty && "bg-[var(--
|
|
17418
|
+
isEmpty && "bg-[var(--empty-field-background)]"
|
|
17310
17419
|
),
|
|
17311
17420
|
children: [
|
|
17312
17421
|
hasFileChip ? /* @__PURE__ */ (0, import_jsx_runtime170.jsxs)(
|
|
@@ -17341,10 +17450,7 @@ var FileInput = React64.forwardRef(function FileInput2({
|
|
|
17341
17450
|
]
|
|
17342
17451
|
}
|
|
17343
17452
|
) : /* @__PURE__ */ (0, import_jsx_runtime170.jsx)("span", { className: "block min-w-0 flex-1 truncate text-left text-[var(--chekin-color-gray-1)]", children: placeholder ?? "" }),
|
|
17344
|
-
/* @__PURE__ */ (0, import_jsx_runtime170.
|
|
17345
|
-
loading && /* @__PURE__ */ (0, import_jsx_runtime170.jsx)(ThreeDotsLoader, { height: 18, width: 18 }),
|
|
17346
|
-
/* @__PURE__ */ (0, import_jsx_runtime170.jsx)(import_lucide_react49.Paperclip, { size: 20 })
|
|
17347
|
-
] })
|
|
17453
|
+
/* @__PURE__ */ (0, import_jsx_runtime170.jsx)("span", { className: "ml-auto flex items-center gap-2 text-[var(--chekin-color-gray-2)]", children: /* @__PURE__ */ (0, import_jsx_runtime170.jsx)(import_lucide_react49.Paperclip, { size: 20 }) })
|
|
17348
17454
|
]
|
|
17349
17455
|
}
|
|
17350
17456
|
),
|
|
@@ -17383,7 +17489,7 @@ var FileInput = React64.forwardRef(function FileInput2({
|
|
|
17383
17489
|
});
|
|
17384
17490
|
|
|
17385
17491
|
// src/dashboard/select-icons-box/SelectIconsBox.tsx
|
|
17386
|
-
var
|
|
17492
|
+
var React66 = __toESM(require("react"), 1);
|
|
17387
17493
|
var import_jsx_runtime171 = require("react/jsx-runtime");
|
|
17388
17494
|
function SelectIconsBox({
|
|
17389
17495
|
children,
|
|
@@ -17399,9 +17505,9 @@ function SelectIconsBox({
|
|
|
17399
17505
|
className,
|
|
17400
17506
|
boxClassName
|
|
17401
17507
|
}) {
|
|
17402
|
-
const containerRef =
|
|
17508
|
+
const containerRef = React66.useRef(null);
|
|
17403
17509
|
const isControlled = controlledOpen !== void 0;
|
|
17404
|
-
const [internalOpen, setInternalOpen] =
|
|
17510
|
+
const [internalOpen, setInternalOpen] = React66.useState(defaultOpen);
|
|
17405
17511
|
const isOpen = isControlled ? controlledOpen : internalOpen;
|
|
17406
17512
|
const setOpen = (next) => {
|
|
17407
17513
|
if (!isControlled) setInternalOpen(next);
|
|
@@ -17582,15 +17688,15 @@ var LegacyTextarea = (0, import_react89.forwardRef)(
|
|
|
17582
17688
|
LegacyTextarea.displayName = "LegacyTextarea";
|
|
17583
17689
|
|
|
17584
17690
|
// src/airbnb-fields/datepicker/DatePicker.tsx
|
|
17585
|
-
var
|
|
17691
|
+
var React68 = __toESM(require("react"), 1);
|
|
17586
17692
|
var import_lucide_react51 = require("lucide-react");
|
|
17587
17693
|
|
|
17588
17694
|
// src/airbnb-fields/field-trigger/FieldTrigger.tsx
|
|
17589
|
-
var
|
|
17695
|
+
var React67 = __toESM(require("react"), 1);
|
|
17590
17696
|
var import_lucide_react50 = require("lucide-react");
|
|
17591
17697
|
var import_react_i18next41 = require("react-i18next");
|
|
17592
17698
|
var import_jsx_runtime174 = require("react/jsx-runtime");
|
|
17593
|
-
var AirbnbFieldTrigger =
|
|
17699
|
+
var AirbnbFieldTrigger = React67.forwardRef(
|
|
17594
17700
|
({
|
|
17595
17701
|
as = "button",
|
|
17596
17702
|
variant = "airbnb",
|
|
@@ -17763,7 +17869,7 @@ AirbnbFieldTrigger.displayName = "AirbnbFieldTrigger";
|
|
|
17763
17869
|
// src/airbnb-fields/datepicker/DatePicker.tsx
|
|
17764
17870
|
var import_jsx_runtime175 = require("react/jsx-runtime");
|
|
17765
17871
|
var DEFAULT_MIN_DATE = new Date(1920, 0, 1);
|
|
17766
|
-
var AirbnbDatePicker =
|
|
17872
|
+
var AirbnbDatePicker = React68.forwardRef(
|
|
17767
17873
|
({
|
|
17768
17874
|
variant = "default",
|
|
17769
17875
|
label,
|
|
@@ -17789,24 +17895,24 @@ var AirbnbDatePicker = React67.forwardRef(
|
|
|
17789
17895
|
formatValue = formatDateValue
|
|
17790
17896
|
}, ref) => {
|
|
17791
17897
|
const { isMatch: isMobile3 } = useScreenResize(DEVICE.mobileXL);
|
|
17792
|
-
const [isOpen, setIsOpen] =
|
|
17793
|
-
const triggerId =
|
|
17794
|
-
const pickerId =
|
|
17795
|
-
const labelId =
|
|
17796
|
-
const valueId =
|
|
17797
|
-
const helperTextId =
|
|
17798
|
-
const errorId =
|
|
17799
|
-
const internalRef =
|
|
17898
|
+
const [isOpen, setIsOpen] = React68.useState(false);
|
|
17899
|
+
const triggerId = React68.useId();
|
|
17900
|
+
const pickerId = React68.useId();
|
|
17901
|
+
const labelId = React68.useId();
|
|
17902
|
+
const valueId = React68.useId();
|
|
17903
|
+
const helperTextId = React68.useId();
|
|
17904
|
+
const errorId = React68.useId();
|
|
17905
|
+
const internalRef = React68.useRef(null);
|
|
17800
17906
|
const combinedRef = useCombinedRef(ref, internalRef);
|
|
17801
|
-
const monthLabels =
|
|
17802
|
-
const resolvedMinDate =
|
|
17803
|
-
const resolvedMaxDate =
|
|
17804
|
-
const normalizedValue =
|
|
17805
|
-
const normalizedDefaultValue =
|
|
17907
|
+
const monthLabels = React68.useMemo(() => getMonthLabels(locale), [locale]);
|
|
17908
|
+
const resolvedMinDate = React68.useMemo(() => minDate ?? DEFAULT_MIN_DATE, [minDate]);
|
|
17909
|
+
const resolvedMaxDate = React68.useMemo(() => maxDate ?? /* @__PURE__ */ new Date(), [maxDate]);
|
|
17910
|
+
const normalizedValue = React68.useMemo(() => normalizeDateValue(value), [value]);
|
|
17911
|
+
const normalizedDefaultValue = React68.useMemo(
|
|
17806
17912
|
() => normalizeDateValue(defaultValue),
|
|
17807
17913
|
[defaultValue]
|
|
17808
17914
|
);
|
|
17809
|
-
const resolvedValue =
|
|
17915
|
+
const resolvedValue = React68.useMemo(
|
|
17810
17916
|
() => normalizedValue ? clampDate(normalizedValue, resolvedMinDate, resolvedMaxDate) : null,
|
|
17811
17917
|
[normalizedValue, resolvedMaxDate, resolvedMinDate]
|
|
17812
17918
|
);
|
|
@@ -17837,7 +17943,7 @@ var AirbnbDatePicker = React67.forwardRef(
|
|
|
17837
17943
|
minDate: resolvedMinDate,
|
|
17838
17944
|
maxDate: resolvedMaxDate
|
|
17839
17945
|
});
|
|
17840
|
-
const handleOpenChange =
|
|
17946
|
+
const handleOpenChange = React68.useCallback(
|
|
17841
17947
|
(nextOpen) => {
|
|
17842
17948
|
if (isBlocked && nextOpen) return;
|
|
17843
17949
|
setIsOpen(nextOpen);
|
|
@@ -17847,7 +17953,7 @@ var AirbnbDatePicker = React67.forwardRef(
|
|
|
17847
17953
|
},
|
|
17848
17954
|
[isBlocked]
|
|
17849
17955
|
);
|
|
17850
|
-
const handleDone =
|
|
17956
|
+
const handleDone = React68.useCallback(() => {
|
|
17851
17957
|
if (isBlocked) return;
|
|
17852
17958
|
onChange(clampDate(draftDate, resolvedMinDate, resolvedMaxDate));
|
|
17853
17959
|
handleOpenChange(false);
|
|
@@ -17859,11 +17965,11 @@ var AirbnbDatePicker = React67.forwardRef(
|
|
|
17859
17965
|
resolvedMaxDate,
|
|
17860
17966
|
resolvedMinDate
|
|
17861
17967
|
]);
|
|
17862
|
-
const handleTriggerClick =
|
|
17968
|
+
const handleTriggerClick = React68.useCallback(() => {
|
|
17863
17969
|
if (isBlocked) return;
|
|
17864
17970
|
setIsOpen(true);
|
|
17865
17971
|
}, [isBlocked]);
|
|
17866
|
-
const handleTriggerKeyDown =
|
|
17972
|
+
const handleTriggerKeyDown = React68.useCallback(
|
|
17867
17973
|
(event) => {
|
|
17868
17974
|
if (isBlocked) return;
|
|
17869
17975
|
if (event.key === "ArrowDown" || event.key === "ArrowUp" || event.key === "Enter" || event.key === " ") {
|
|
@@ -17873,7 +17979,7 @@ var AirbnbDatePicker = React67.forwardRef(
|
|
|
17873
17979
|
},
|
|
17874
17980
|
[isBlocked]
|
|
17875
17981
|
);
|
|
17876
|
-
|
|
17982
|
+
React68.useEffect(() => {
|
|
17877
17983
|
if (isBlocked) {
|
|
17878
17984
|
setIsOpen(false);
|
|
17879
17985
|
}
|
|
@@ -17951,10 +18057,10 @@ var AirbnbDatePicker = React67.forwardRef(
|
|
|
17951
18057
|
AirbnbDatePicker.displayName = "AirbnbDatePicker";
|
|
17952
18058
|
|
|
17953
18059
|
// src/airbnb-fields/input/Input.tsx
|
|
17954
|
-
var
|
|
18060
|
+
var React69 = __toESM(require("react"), 1);
|
|
17955
18061
|
var import_jsx_runtime176 = require("react/jsx-runtime");
|
|
17956
18062
|
var getInputValue = (value) => value != null ? String(value) : "";
|
|
17957
|
-
var AirbnbInput =
|
|
18063
|
+
var AirbnbInput = React69.forwardRef(
|
|
17958
18064
|
({
|
|
17959
18065
|
variant = "default",
|
|
17960
18066
|
label,
|
|
@@ -17983,15 +18089,15 @@ var AirbnbInput = React68.forwardRef(
|
|
|
17983
18089
|
placeholder,
|
|
17984
18090
|
...props
|
|
17985
18091
|
}, ref) => {
|
|
17986
|
-
const generatedId =
|
|
17987
|
-
const inputRef =
|
|
18092
|
+
const generatedId = React69.useId();
|
|
18093
|
+
const inputRef = React69.useRef(null);
|
|
17988
18094
|
const inputId = id ?? generatedId;
|
|
17989
18095
|
const fieldId = `${inputId}-field`;
|
|
17990
18096
|
const labelId = `${inputId}-label`;
|
|
17991
18097
|
const errorId = `${inputId}-error`;
|
|
17992
18098
|
const accessibleLabel = placeholder ?? label;
|
|
17993
|
-
const [isFocused, setIsFocused] =
|
|
17994
|
-
const [currentValue, setCurrentValue] =
|
|
18099
|
+
const [isFocused, setIsFocused] = React69.useState(false);
|
|
18100
|
+
const [currentValue, setCurrentValue] = React69.useState(
|
|
17995
18101
|
() => value != null ? getInputValue(value) : getInputValue(defaultValue)
|
|
17996
18102
|
);
|
|
17997
18103
|
const resolvedValue = value != null ? getInputValue(value) : currentValue;
|
|
@@ -18001,11 +18107,11 @@ var AirbnbInput = React68.forwardRef(
|
|
|
18001
18107
|
const triggerError = error ?? invalid;
|
|
18002
18108
|
const hasLabelMeta = Boolean(optional) || Boolean(tooltip);
|
|
18003
18109
|
const isBlocked = Boolean(disabled) || Boolean(loading);
|
|
18004
|
-
|
|
18110
|
+
React69.useLayoutEffect(() => {
|
|
18005
18111
|
const nextValue = value != null ? getInputValue(value) : getInputValue(inputRef.current?.value);
|
|
18006
18112
|
setCurrentValue((prevValue) => prevValue === nextValue ? prevValue : nextValue);
|
|
18007
18113
|
}, [value]);
|
|
18008
|
-
const setRefs =
|
|
18114
|
+
const setRefs = React69.useCallback(
|
|
18009
18115
|
(node) => {
|
|
18010
18116
|
inputRef.current = node;
|
|
18011
18117
|
if (node && value == null) {
|
|
@@ -18103,11 +18209,11 @@ var AirbnbInput = React68.forwardRef(
|
|
|
18103
18209
|
AirbnbInput.displayName = "AirbnbInput";
|
|
18104
18210
|
|
|
18105
18211
|
// src/airbnb-fields/phone-field/PhoneField.tsx
|
|
18106
|
-
var
|
|
18212
|
+
var React75 = __toESM(require("react"), 1);
|
|
18107
18213
|
var import_lucide_react53 = require("lucide-react");
|
|
18108
18214
|
|
|
18109
18215
|
// src/airbnb-fields/select/Select.tsx
|
|
18110
|
-
var
|
|
18216
|
+
var React74 = __toESM(require("react"), 1);
|
|
18111
18217
|
|
|
18112
18218
|
// src/airbnb-fields/select/SelectDesktopMenu.tsx
|
|
18113
18219
|
var import_jsx_runtime177 = require("react/jsx-runtime");
|
|
@@ -18452,10 +18558,10 @@ function AirbnbSelectMobileContent({
|
|
|
18452
18558
|
}
|
|
18453
18559
|
|
|
18454
18560
|
// src/airbnb-fields/select/SelectTrigger.tsx
|
|
18455
|
-
var
|
|
18561
|
+
var React70 = __toESM(require("react"), 1);
|
|
18456
18562
|
var import_lucide_react52 = require("lucide-react");
|
|
18457
18563
|
var import_jsx_runtime181 = require("react/jsx-runtime");
|
|
18458
|
-
var AirbnbSelectTrigger =
|
|
18564
|
+
var AirbnbSelectTrigger = React70.forwardRef(
|
|
18459
18565
|
({
|
|
18460
18566
|
id,
|
|
18461
18567
|
open,
|
|
@@ -18522,7 +18628,7 @@ var AirbnbSelectTrigger = React69.forwardRef(
|
|
|
18522
18628
|
AirbnbSelectTrigger.displayName = "AirbnbSelectTrigger";
|
|
18523
18629
|
|
|
18524
18630
|
// src/airbnb-fields/select/useDesktopSelect.ts
|
|
18525
|
-
var
|
|
18631
|
+
var React71 = __toESM(require("react"), 1);
|
|
18526
18632
|
function useDesktopSelect({
|
|
18527
18633
|
isMobile: isMobile3,
|
|
18528
18634
|
isOpen,
|
|
@@ -18531,12 +18637,12 @@ function useDesktopSelect({
|
|
|
18531
18637
|
disabled,
|
|
18532
18638
|
onChange
|
|
18533
18639
|
}) {
|
|
18534
|
-
const [highlightedIndex, setHighlightedIndex] =
|
|
18535
|
-
const triggerRef =
|
|
18536
|
-
const listRef =
|
|
18537
|
-
const optionRefs =
|
|
18640
|
+
const [highlightedIndex, setHighlightedIndex] = React71.useState(-1);
|
|
18641
|
+
const triggerRef = React71.useRef(null);
|
|
18642
|
+
const listRef = React71.useRef(null);
|
|
18643
|
+
const optionRefs = React71.useRef([]);
|
|
18538
18644
|
const selectedIndex = getOptionIndex2(options, value);
|
|
18539
|
-
|
|
18645
|
+
React71.useEffect(() => {
|
|
18540
18646
|
if (!isOpen || isMobile3) return;
|
|
18541
18647
|
setHighlightedIndex((currentIndex) => {
|
|
18542
18648
|
if (currentIndex >= 0) {
|
|
@@ -18551,34 +18657,34 @@ function useDesktopSelect({
|
|
|
18551
18657
|
window.cancelAnimationFrame(frameId);
|
|
18552
18658
|
};
|
|
18553
18659
|
}, [isMobile3, isOpen, options, selectedIndex]);
|
|
18554
|
-
|
|
18660
|
+
React71.useEffect(() => {
|
|
18555
18661
|
if (!isOpen || isMobile3 || highlightedIndex < 0) return;
|
|
18556
18662
|
optionRefs.current[highlightedIndex]?.scrollIntoView({
|
|
18557
18663
|
block: "nearest"
|
|
18558
18664
|
});
|
|
18559
18665
|
}, [highlightedIndex, isMobile3, isOpen]);
|
|
18560
|
-
|
|
18666
|
+
React71.useEffect(() => {
|
|
18561
18667
|
if (isOpen) return;
|
|
18562
18668
|
setHighlightedIndex(-1);
|
|
18563
18669
|
}, [isOpen]);
|
|
18564
|
-
const focusTrigger =
|
|
18670
|
+
const focusTrigger = React71.useCallback(() => {
|
|
18565
18671
|
triggerRef.current?.focus();
|
|
18566
18672
|
}, []);
|
|
18567
|
-
const handleSelect =
|
|
18673
|
+
const handleSelect = React71.useCallback(
|
|
18568
18674
|
(option) => {
|
|
18569
18675
|
if (option.isDisabled || disabled) return;
|
|
18570
18676
|
onChange(option);
|
|
18571
18677
|
},
|
|
18572
18678
|
[disabled, onChange]
|
|
18573
18679
|
);
|
|
18574
|
-
const openMenu =
|
|
18680
|
+
const openMenu = React71.useCallback(
|
|
18575
18681
|
(targetIndex) => {
|
|
18576
18682
|
const fallbackIndex = selectedIndex >= 0 ? selectedIndex : getFirstEnabledOptionIndex2(options);
|
|
18577
18683
|
setHighlightedIndex(targetIndex ?? fallbackIndex);
|
|
18578
18684
|
},
|
|
18579
18685
|
[options, selectedIndex]
|
|
18580
18686
|
);
|
|
18581
|
-
const handleTriggerKeyDown =
|
|
18687
|
+
const handleTriggerKeyDown = React71.useCallback(
|
|
18582
18688
|
(event, onOpen) => {
|
|
18583
18689
|
if (disabled) return;
|
|
18584
18690
|
if (event.key === "ArrowDown") {
|
|
@@ -18603,7 +18709,7 @@ function useDesktopSelect({
|
|
|
18603
18709
|
},
|
|
18604
18710
|
[disabled, openMenu, options, selectedIndex]
|
|
18605
18711
|
);
|
|
18606
|
-
const handleMenuKeyDown =
|
|
18712
|
+
const handleMenuKeyDown = React71.useCallback(
|
|
18607
18713
|
(event, onClose) => {
|
|
18608
18714
|
if (event.key === "Escape") {
|
|
18609
18715
|
event.preventDefault();
|
|
@@ -18653,7 +18759,7 @@ function useDesktopSelect({
|
|
|
18653
18759
|
},
|
|
18654
18760
|
[focusTrigger, highlightedIndex, onChange, options]
|
|
18655
18761
|
);
|
|
18656
|
-
const setOptionRef =
|
|
18762
|
+
const setOptionRef = React71.useCallback(
|
|
18657
18763
|
(index, node) => {
|
|
18658
18764
|
optionRefs.current[index] = node;
|
|
18659
18765
|
},
|
|
@@ -18673,23 +18779,23 @@ function useDesktopSelect({
|
|
|
18673
18779
|
}
|
|
18674
18780
|
|
|
18675
18781
|
// src/airbnb-fields/select/useMobileSelectWheel.ts
|
|
18676
|
-
var
|
|
18782
|
+
var React72 = __toESM(require("react"), 1);
|
|
18677
18783
|
function useMobileSelectWheel({ isMobile: isMobile3, isOpen, options, value, disabled }) {
|
|
18678
|
-
const [pendingValue, setPendingValue] =
|
|
18784
|
+
const [pendingValue, setPendingValue] = React72.useState(
|
|
18679
18785
|
value ?? null
|
|
18680
18786
|
);
|
|
18681
|
-
const [mobileScrollTop, setMobileScrollTop] =
|
|
18682
|
-
const mobileListRef =
|
|
18683
|
-
const scrollSettleTimeoutRef =
|
|
18684
|
-
const scrollAnimationFrameRef =
|
|
18685
|
-
const getTargetIndex =
|
|
18787
|
+
const [mobileScrollTop, setMobileScrollTop] = React72.useState(0);
|
|
18788
|
+
const mobileListRef = React72.useRef(null);
|
|
18789
|
+
const scrollSettleTimeoutRef = React72.useRef(null);
|
|
18790
|
+
const scrollAnimationFrameRef = React72.useRef(null);
|
|
18791
|
+
const getTargetIndex = React72.useCallback(
|
|
18686
18792
|
(targetValue) => {
|
|
18687
18793
|
const selectedIndex = getOptionIndex2(options, targetValue);
|
|
18688
18794
|
return selectedIndex >= 0 ? selectedIndex : getFirstEnabledOptionIndex2(options);
|
|
18689
18795
|
},
|
|
18690
18796
|
[options]
|
|
18691
18797
|
);
|
|
18692
|
-
const syncScrollPosition =
|
|
18798
|
+
const syncScrollPosition = React72.useCallback(
|
|
18693
18799
|
(targetValue, behavior = "instant") => {
|
|
18694
18800
|
const targetIndex = getTargetIndex(targetValue);
|
|
18695
18801
|
if (targetIndex < 0) return;
|
|
@@ -18708,27 +18814,27 @@ function useMobileSelectWheel({ isMobile: isMobile3, isOpen, options, value, dis
|
|
|
18708
18814
|
},
|
|
18709
18815
|
[getTargetIndex, options]
|
|
18710
18816
|
);
|
|
18711
|
-
const clearScrollSettleTimeout =
|
|
18817
|
+
const clearScrollSettleTimeout = React72.useCallback(() => {
|
|
18712
18818
|
if (scrollSettleTimeoutRef.current === null) return;
|
|
18713
18819
|
window.clearTimeout(scrollSettleTimeoutRef.current);
|
|
18714
18820
|
scrollSettleTimeoutRef.current = null;
|
|
18715
18821
|
}, []);
|
|
18716
|
-
const clearScrollAnimationFrame =
|
|
18822
|
+
const clearScrollAnimationFrame = React72.useCallback(() => {
|
|
18717
18823
|
if (scrollAnimationFrameRef.current === null) return;
|
|
18718
18824
|
window.cancelAnimationFrame(scrollAnimationFrameRef.current);
|
|
18719
18825
|
scrollAnimationFrameRef.current = null;
|
|
18720
18826
|
}, []);
|
|
18721
|
-
|
|
18827
|
+
React72.useEffect(
|
|
18722
18828
|
() => () => {
|
|
18723
18829
|
clearScrollSettleTimeout();
|
|
18724
18830
|
clearScrollAnimationFrame();
|
|
18725
18831
|
},
|
|
18726
18832
|
[clearScrollAnimationFrame, clearScrollSettleTimeout]
|
|
18727
18833
|
);
|
|
18728
|
-
|
|
18834
|
+
React72.useEffect(() => {
|
|
18729
18835
|
setPendingValue(value ?? null);
|
|
18730
18836
|
}, [value]);
|
|
18731
|
-
|
|
18837
|
+
React72.useLayoutEffect(() => {
|
|
18732
18838
|
if (!isMobile3 || !isOpen) return;
|
|
18733
18839
|
const frameId = window.requestAnimationFrame(() => {
|
|
18734
18840
|
syncScrollPosition(value ?? null, "instant");
|
|
@@ -18737,7 +18843,7 @@ function useMobileSelectWheel({ isMobile: isMobile3, isOpen, options, value, dis
|
|
|
18737
18843
|
window.cancelAnimationFrame(frameId);
|
|
18738
18844
|
};
|
|
18739
18845
|
}, [isMobile3, isOpen, syncScrollPosition, value]);
|
|
18740
|
-
const settleScroll =
|
|
18846
|
+
const settleScroll = React72.useCallback(() => {
|
|
18741
18847
|
if (!mobileListRef.current) return;
|
|
18742
18848
|
const nextIndex = Math.round(mobileListRef.current.scrollTop / MOBILE_OPTION_HEIGHT);
|
|
18743
18849
|
const nextOption = options[nextIndex];
|
|
@@ -18749,13 +18855,13 @@ function useMobileSelectWheel({ isMobile: isMobile3, isOpen, options, value, dis
|
|
|
18749
18855
|
}
|
|
18750
18856
|
setPendingValue(nextOption);
|
|
18751
18857
|
}, [options, pendingValue]);
|
|
18752
|
-
const scheduleScrollSettle =
|
|
18858
|
+
const scheduleScrollSettle = React72.useCallback(() => {
|
|
18753
18859
|
clearScrollSettleTimeout();
|
|
18754
18860
|
scrollSettleTimeoutRef.current = window.setTimeout(() => {
|
|
18755
18861
|
settleScroll();
|
|
18756
18862
|
}, MOBILE_SCROLL_SETTLE_DELAY);
|
|
18757
18863
|
}, [clearScrollSettleTimeout, settleScroll]);
|
|
18758
|
-
const handleScroll =
|
|
18864
|
+
const handleScroll = React72.useCallback(() => {
|
|
18759
18865
|
if (!mobileListRef.current) return;
|
|
18760
18866
|
const nextScrollTop = mobileListRef.current.scrollTop;
|
|
18761
18867
|
clearScrollAnimationFrame();
|
|
@@ -18765,7 +18871,7 @@ function useMobileSelectWheel({ isMobile: isMobile3, isOpen, options, value, dis
|
|
|
18765
18871
|
});
|
|
18766
18872
|
scheduleScrollSettle();
|
|
18767
18873
|
}, [clearScrollAnimationFrame, scheduleScrollSettle]);
|
|
18768
|
-
const focusOptionByIndex =
|
|
18874
|
+
const focusOptionByIndex = React72.useCallback(
|
|
18769
18875
|
(index, behavior = "instant", updatePendingImmediately = behavior === "instant") => {
|
|
18770
18876
|
if (!mobileListRef.current || index < 0 || index >= options.length) return;
|
|
18771
18877
|
const option = options[index];
|
|
@@ -18783,7 +18889,7 @@ function useMobileSelectWheel({ isMobile: isMobile3, isOpen, options, value, dis
|
|
|
18783
18889
|
},
|
|
18784
18890
|
[options, scheduleScrollSettle]
|
|
18785
18891
|
);
|
|
18786
|
-
const handleOptionClick =
|
|
18892
|
+
const handleOptionClick = React72.useCallback(
|
|
18787
18893
|
(option) => {
|
|
18788
18894
|
if (!mobileListRef.current || disabled || option.isDisabled) return;
|
|
18789
18895
|
const optionIndex = getOptionIndex2(options, option);
|
|
@@ -18792,7 +18898,7 @@ function useMobileSelectWheel({ isMobile: isMobile3, isOpen, options, value, dis
|
|
|
18792
18898
|
},
|
|
18793
18899
|
[disabled, focusOptionByIndex, options]
|
|
18794
18900
|
);
|
|
18795
|
-
const moveByStep =
|
|
18901
|
+
const moveByStep = React72.useCallback(
|
|
18796
18902
|
(step) => {
|
|
18797
18903
|
const currentIndex = getOptionIndex2(options, pendingValue);
|
|
18798
18904
|
const fallbackIndex = step === 1 ? getFirstEnabledOptionIndex2(options) : getLastEnabledOptionIndex2(options);
|
|
@@ -18804,7 +18910,7 @@ function useMobileSelectWheel({ isMobile: isMobile3, isOpen, options, value, dis
|
|
|
18804
18910
|
},
|
|
18805
18911
|
[focusOptionByIndex, options, pendingValue]
|
|
18806
18912
|
);
|
|
18807
|
-
const moveToBoundary =
|
|
18913
|
+
const moveToBoundary = React72.useCallback(
|
|
18808
18914
|
(boundary) => {
|
|
18809
18915
|
const targetIndex = boundary === "start" ? getFirstEnabledOptionIndex2(options) : getLastEnabledOptionIndex2(options);
|
|
18810
18916
|
if (targetIndex >= 0) {
|
|
@@ -18813,7 +18919,7 @@ function useMobileSelectWheel({ isMobile: isMobile3, isOpen, options, value, dis
|
|
|
18813
18919
|
},
|
|
18814
18920
|
[focusOptionByIndex, options]
|
|
18815
18921
|
);
|
|
18816
|
-
const syncPendingValue =
|
|
18922
|
+
const syncPendingValue = React72.useCallback(
|
|
18817
18923
|
(nextValue) => {
|
|
18818
18924
|
const normalizedValue = nextValue ?? null;
|
|
18819
18925
|
const matchedIndex = getOptionIndex2(options, normalizedValue);
|
|
@@ -18841,9 +18947,9 @@ function useMobileSelectWheel({ isMobile: isMobile3, isOpen, options, value, dis
|
|
|
18841
18947
|
}
|
|
18842
18948
|
|
|
18843
18949
|
// src/airbnb-fields/select/useSelectIds.ts
|
|
18844
|
-
var
|
|
18950
|
+
var React73 = __toESM(require("react"), 1);
|
|
18845
18951
|
function useSelectIds2({ name, hasValue, error, hideErrorMessage }) {
|
|
18846
|
-
const reactId =
|
|
18952
|
+
const reactId = React73.useId().replace(/:/g, "");
|
|
18847
18953
|
const baseId = name ? `select-${name}` : `select-${reactId}`;
|
|
18848
18954
|
const triggerId = `${baseId}-trigger`;
|
|
18849
18955
|
const labelId = `${baseId}-label`;
|
|
@@ -18853,7 +18959,7 @@ function useSelectIds2({ name, hasValue, error, hideErrorMessage }) {
|
|
|
18853
18959
|
const listboxId = `${baseId}-listbox`;
|
|
18854
18960
|
const describedErrorId = error && !hideErrorMessage ? errorId : void 0;
|
|
18855
18961
|
const describedBy = [!hasValue ? helperTextId : null, describedErrorId].filter(Boolean).join(" ") || void 0;
|
|
18856
|
-
const getOptionId2 =
|
|
18962
|
+
const getOptionId2 = React73.useCallback(
|
|
18857
18963
|
(index) => `${baseId}-option-${index}`,
|
|
18858
18964
|
[baseId]
|
|
18859
18965
|
);
|
|
@@ -18872,7 +18978,7 @@ function useSelectIds2({ name, hasValue, error, hideErrorMessage }) {
|
|
|
18872
18978
|
|
|
18873
18979
|
// src/airbnb-fields/select/Select.tsx
|
|
18874
18980
|
var import_jsx_runtime182 = require("react/jsx-runtime");
|
|
18875
|
-
var AirbnbSelect =
|
|
18981
|
+
var AirbnbSelect = React74.forwardRef(function AirbnbSelect2({
|
|
18876
18982
|
options = [],
|
|
18877
18983
|
value,
|
|
18878
18984
|
onChange,
|
|
@@ -18899,8 +19005,8 @@ var AirbnbSelect = React73.forwardRef(function AirbnbSelect2({
|
|
|
18899
19005
|
noOptionsMessage
|
|
18900
19006
|
}, ref) {
|
|
18901
19007
|
const { isMatch: isMobile3 } = useScreenResize(DEVICE.mobileXL);
|
|
18902
|
-
const [isOpen, setIsOpen] =
|
|
18903
|
-
const containerRef =
|
|
19008
|
+
const [isOpen, setIsOpen] = React74.useState(false);
|
|
19009
|
+
const containerRef = React74.useRef(null);
|
|
18904
19010
|
const hasValue = Boolean(value);
|
|
18905
19011
|
const helperText = placeholder ?? label;
|
|
18906
19012
|
const shouldDescribeHelperText = !hasValue && helperText !== label;
|
|
@@ -18961,12 +19067,12 @@ var AirbnbSelect = React73.forwardRef(function AirbnbSelect2({
|
|
|
18961
19067
|
onOutsideClick: () => setIsOpen(false),
|
|
18962
19068
|
isDisabled: !isOpen || isMobile3
|
|
18963
19069
|
});
|
|
18964
|
-
|
|
19070
|
+
React74.useEffect(() => {
|
|
18965
19071
|
if (isBlocked) {
|
|
18966
19072
|
setIsOpen(false);
|
|
18967
19073
|
}
|
|
18968
19074
|
}, [isBlocked]);
|
|
18969
|
-
|
|
19075
|
+
React74.useEffect(
|
|
18970
19076
|
function setCorrectOptionIfThereIsOnlyValue() {
|
|
18971
19077
|
if (value?.value === void 0 || value.value === null || value.label !== "") {
|
|
18972
19078
|
return;
|
|
@@ -18978,7 +19084,7 @@ var AirbnbSelect = React73.forwardRef(function AirbnbSelect2({
|
|
|
18978
19084
|
},
|
|
18979
19085
|
[onChange, options, value]
|
|
18980
19086
|
);
|
|
18981
|
-
const handleMobileOpenChange =
|
|
19087
|
+
const handleMobileOpenChange = React74.useCallback(
|
|
18982
19088
|
(nextOpen) => {
|
|
18983
19089
|
if (isBlocked && nextOpen) return;
|
|
18984
19090
|
setIsOpen(nextOpen);
|
|
@@ -18989,7 +19095,7 @@ var AirbnbSelect = React73.forwardRef(function AirbnbSelect2({
|
|
|
18989
19095
|
},
|
|
18990
19096
|
[focusTrigger, isBlocked, syncPendingValue, value]
|
|
18991
19097
|
);
|
|
18992
|
-
const handleMobileDone =
|
|
19098
|
+
const handleMobileDone = React74.useCallback(() => {
|
|
18993
19099
|
if (isBlocked) return;
|
|
18994
19100
|
const finalOption = pendingValue;
|
|
18995
19101
|
if (finalOption && finalOption.value !== value?.value) {
|
|
@@ -18998,7 +19104,7 @@ var AirbnbSelect = React73.forwardRef(function AirbnbSelect2({
|
|
|
18998
19104
|
setIsOpen(false);
|
|
18999
19105
|
focusTrigger();
|
|
19000
19106
|
}, [focusTrigger, isBlocked, onChange, pendingValue, value]);
|
|
19001
|
-
const handleTriggerClick =
|
|
19107
|
+
const handleTriggerClick = React74.useCallback(() => {
|
|
19002
19108
|
if (isBlocked) return;
|
|
19003
19109
|
setIsOpen((prev) => {
|
|
19004
19110
|
const nextOpen = !prev;
|
|
@@ -19172,7 +19278,7 @@ function formatPhoneCodeOptionLabel2(option) {
|
|
|
19172
19278
|
const value = String(option.value);
|
|
19173
19279
|
return label.includes(value) ? label : `${label} (${value})`;
|
|
19174
19280
|
}
|
|
19175
|
-
var AirbnbPhoneField =
|
|
19281
|
+
var AirbnbPhoneField = React75.forwardRef(
|
|
19176
19282
|
({
|
|
19177
19283
|
variant = "default",
|
|
19178
19284
|
label,
|
|
@@ -19196,8 +19302,8 @@ var AirbnbPhoneField = React74.forwardRef(
|
|
|
19196
19302
|
mobileTitle,
|
|
19197
19303
|
codePlaceholder = "+00"
|
|
19198
19304
|
}, ref) => {
|
|
19199
|
-
const inputId =
|
|
19200
|
-
const codeOptions =
|
|
19305
|
+
const inputId = React75.useId();
|
|
19306
|
+
const codeOptions = React75.useMemo(
|
|
19201
19307
|
() => options.map((option) => ({
|
|
19202
19308
|
value: option.value,
|
|
19203
19309
|
label: formatPhoneCodeOptionLabel2(option),
|
|
@@ -19205,7 +19311,7 @@ var AirbnbPhoneField = React74.forwardRef(
|
|
|
19205
19311
|
})),
|
|
19206
19312
|
[options]
|
|
19207
19313
|
);
|
|
19208
|
-
const selectedCodeOption =
|
|
19314
|
+
const selectedCodeOption = React75.useMemo(
|
|
19209
19315
|
() => codeOptions.find((option) => option.value === value?.code) ?? null,
|
|
19210
19316
|
[codeOptions, value?.code]
|
|
19211
19317
|
);
|
|
@@ -19347,7 +19453,7 @@ var AirbnbPhoneField = React74.forwardRef(
|
|
|
19347
19453
|
AirbnbPhoneField.displayName = "AirbnbPhoneField";
|
|
19348
19454
|
|
|
19349
19455
|
// src/airbnb-fields/searchable-select/SearchableSelect.tsx
|
|
19350
|
-
var
|
|
19456
|
+
var React76 = __toESM(require("react"), 1);
|
|
19351
19457
|
var import_lucide_react54 = require("lucide-react");
|
|
19352
19458
|
var import_react_virtual3 = require("@tanstack/react-virtual");
|
|
19353
19459
|
var import_react90 = require("react");
|
|
@@ -19392,13 +19498,13 @@ var AirbnbSearchableSelectInternal = ({
|
|
|
19392
19498
|
loadingMessage
|
|
19393
19499
|
}, ref) => {
|
|
19394
19500
|
const { isMatch: isMobile3 } = useScreenResize(DEVICE.mobileXL);
|
|
19395
|
-
const reactId =
|
|
19396
|
-
const [open, setOpen] =
|
|
19397
|
-
const [internalSearchValue, setInternalSearchValue] =
|
|
19398
|
-
const [highlightedIndex, setHighlightedIndex] =
|
|
19399
|
-
const containerRef =
|
|
19400
|
-
const triggerRef =
|
|
19401
|
-
const inputRef =
|
|
19501
|
+
const reactId = React76.useId();
|
|
19502
|
+
const [open, setOpen] = React76.useState(false);
|
|
19503
|
+
const [internalSearchValue, setInternalSearchValue] = React76.useState("");
|
|
19504
|
+
const [highlightedIndex, setHighlightedIndex] = React76.useState(-1);
|
|
19505
|
+
const containerRef = React76.useRef(null);
|
|
19506
|
+
const triggerRef = React76.useRef(null);
|
|
19507
|
+
const inputRef = React76.useRef(null);
|
|
19402
19508
|
const listboxId = `${reactId}-listbox`;
|
|
19403
19509
|
const labelId = `${reactId}-label`;
|
|
19404
19510
|
const valueId = `${reactId}-value`;
|
|
@@ -19407,13 +19513,13 @@ var AirbnbSearchableSelectInternal = ({
|
|
|
19407
19513
|
const searchInputId = `${reactId}-search`;
|
|
19408
19514
|
const effectiveSearchValue = searchValue ?? internalSearchValue;
|
|
19409
19515
|
const shouldFilterLocally = !onSearchChange && filterOption !== null;
|
|
19410
|
-
const visibleOptions =
|
|
19516
|
+
const visibleOptions = React76.useMemo(() => {
|
|
19411
19517
|
if (!shouldFilterLocally || !effectiveSearchValue) {
|
|
19412
19518
|
return options;
|
|
19413
19519
|
}
|
|
19414
19520
|
return options.filter((option) => filterOption(option, effectiveSearchValue));
|
|
19415
19521
|
}, [effectiveSearchValue, filterOption, options, shouldFilterLocally]);
|
|
19416
|
-
const selectedIndex =
|
|
19522
|
+
const selectedIndex = React76.useMemo(
|
|
19417
19523
|
() => visibleOptions.findIndex((option) => option.value === value?.value),
|
|
19418
19524
|
[value?.value, visibleOptions]
|
|
19419
19525
|
);
|
|
@@ -19439,7 +19545,7 @@ var AirbnbSearchableSelectInternal = ({
|
|
|
19439
19545
|
},
|
|
19440
19546
|
[handleOnOpenChange]
|
|
19441
19547
|
);
|
|
19442
|
-
|
|
19548
|
+
React76.useEffect(() => {
|
|
19443
19549
|
if (isBlocked) {
|
|
19444
19550
|
setSelectOpen(false);
|
|
19445
19551
|
return;
|
|
@@ -19452,7 +19558,7 @@ var AirbnbSearchableSelectInternal = ({
|
|
|
19452
19558
|
window.cancelAnimationFrame(frameId);
|
|
19453
19559
|
};
|
|
19454
19560
|
}, [isBlocked, open, setSelectOpen]);
|
|
19455
|
-
|
|
19561
|
+
React76.useEffect(() => {
|
|
19456
19562
|
if (!open) {
|
|
19457
19563
|
setHighlightedIndex(-1);
|
|
19458
19564
|
return;
|
|
@@ -19547,7 +19653,7 @@ var AirbnbSearchableSelectInternal = ({
|
|
|
19547
19653
|
onOptionHover: setHighlightedIndex
|
|
19548
19654
|
}
|
|
19549
19655
|
);
|
|
19550
|
-
|
|
19656
|
+
React76.useImperativeHandle(ref, () => triggerRef.current, []);
|
|
19551
19657
|
return /* @__PURE__ */ (0, import_jsx_runtime184.jsxs)("div", { ref: containerRef, className: cn("relative w-full max-w-[425px]", className), children: [
|
|
19552
19658
|
name && /* @__PURE__ */ (0, import_jsx_runtime184.jsx)("input", { type: "hidden", name, value: value ? String(value.value) : "" }),
|
|
19553
19659
|
/* @__PURE__ */ (0, import_jsx_runtime184.jsx)(
|
|
@@ -19626,7 +19732,7 @@ var AirbnbSearchableSelectInternal = ({
|
|
|
19626
19732
|
) : null
|
|
19627
19733
|
] });
|
|
19628
19734
|
};
|
|
19629
|
-
var AirbnbSearchableSelect =
|
|
19735
|
+
var AirbnbSearchableSelect = React76.forwardRef(
|
|
19630
19736
|
AirbnbSearchableSelectInternal
|
|
19631
19737
|
);
|
|
19632
19738
|
function AirbnbSearchableSelectContent({
|
|
@@ -19653,9 +19759,9 @@ function AirbnbSearchableSelectContent({
|
|
|
19653
19759
|
onOptionClick,
|
|
19654
19760
|
onOptionHover
|
|
19655
19761
|
}) {
|
|
19656
|
-
const listRef =
|
|
19657
|
-
const lastLoadMoreOptionsLengthRef =
|
|
19658
|
-
const previousHighlightedIndexRef =
|
|
19762
|
+
const listRef = React76.useRef(null);
|
|
19763
|
+
const lastLoadMoreOptionsLengthRef = React76.useRef(null);
|
|
19764
|
+
const previousHighlightedIndexRef = React76.useRef(highlightedIndex);
|
|
19659
19765
|
const rowCount = options.length + (loading && options.length > 0 ? 1 : 0);
|
|
19660
19766
|
const virtualizer = (0, import_react_virtual3.useVirtualizer)({
|
|
19661
19767
|
count: rowCount,
|
|
@@ -19666,7 +19772,7 @@ function AirbnbSearchableSelectContent({
|
|
|
19666
19772
|
const virtualItems = virtualizer.getVirtualItems();
|
|
19667
19773
|
const emptyMessage = noOptionsMessage?.() ?? "No matches found";
|
|
19668
19774
|
const loadingText = loadingMessage?.() ?? "Loading...";
|
|
19669
|
-
|
|
19775
|
+
React76.useEffect(() => {
|
|
19670
19776
|
const lastItem = virtualItems[virtualItems.length - 1];
|
|
19671
19777
|
const shouldLoadMore = !!lastItem && hasNextPage && !loading && lastItem.index >= options.length - LOAD_MORE_THRESHOLD;
|
|
19672
19778
|
if (shouldLoadMore && lastLoadMoreOptionsLengthRef.current !== options.length) {
|
|
@@ -19674,7 +19780,7 @@ function AirbnbSearchableSelectContent({
|
|
|
19674
19780
|
onLoadMore?.();
|
|
19675
19781
|
}
|
|
19676
19782
|
}, [hasNextPage, loading, onLoadMore, options.length, virtualItems]);
|
|
19677
|
-
|
|
19783
|
+
React76.useEffect(() => {
|
|
19678
19784
|
const hasHighlightedIndexChanged = previousHighlightedIndexRef.current !== highlightedIndex;
|
|
19679
19785
|
previousHighlightedIndexRef.current = highlightedIndex;
|
|
19680
19786
|
if (highlightedIndex >= 0 && hasHighlightedIndexChanged) {
|
|
@@ -19792,11 +19898,11 @@ function getNextEnabledIndex(options, startIndex, step) {
|
|
|
19792
19898
|
}
|
|
19793
19899
|
|
|
19794
19900
|
// src/airbnb-fields/search-input/SearchInput.tsx
|
|
19795
|
-
var
|
|
19901
|
+
var React77 = __toESM(require("react"), 1);
|
|
19796
19902
|
var import_react_i18next42 = require("react-i18next");
|
|
19797
19903
|
var import_lucide_react55 = require("lucide-react");
|
|
19798
19904
|
var import_jsx_runtime185 = require("react/jsx-runtime");
|
|
19799
|
-
var AirbnbSearchInput =
|
|
19905
|
+
var AirbnbSearchInput = React77.forwardRef(({ onReset, placeholder, wrapperClassName, ...props }, ref) => {
|
|
19800
19906
|
const { t } = (0, import_react_i18next42.useTranslation)();
|
|
19801
19907
|
const placeholderText = placeholder || t("search_property") + "...";
|
|
19802
19908
|
return /* @__PURE__ */ (0, import_jsx_runtime185.jsxs)("div", { className: cn("input-wrapper relative", wrapperClassName), children: [
|