@chekinapp/ui 0.0.3 → 0.0.5
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 +617 -418
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +59 -14
- package/dist/index.d.ts +59 -14
- package/dist/index.js +628 -429
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -3312,7 +3312,7 @@ GridItems.displayName = "GridItems";
|
|
|
3312
3312
|
|
|
3313
3313
|
// src/help-tooltip/HelpTooltip.tsx
|
|
3314
3314
|
import { CircleQuestionMark } from "lucide-react";
|
|
3315
|
-
import { jsx as jsx55, jsxs as jsxs34 } from "react/jsx-runtime";
|
|
3315
|
+
import { Fragment as Fragment5, jsx as jsx55, jsxs as jsxs34 } from "react/jsx-runtime";
|
|
3316
3316
|
function HelpTooltip({
|
|
3317
3317
|
content,
|
|
3318
3318
|
side,
|
|
@@ -3321,27 +3321,31 @@ function HelpTooltip({
|
|
|
3321
3321
|
className,
|
|
3322
3322
|
contentClassName,
|
|
3323
3323
|
size = 16,
|
|
3324
|
-
label = "More info"
|
|
3324
|
+
label = "More info",
|
|
3325
|
+
triggerAs = "button"
|
|
3325
3326
|
}) {
|
|
3327
|
+
const triggerClassName = cn(
|
|
3328
|
+
"relative flex shrink-0 cursor-help items-center justify-center rounded-full",
|
|
3329
|
+
"text-chekin-gray-2 outline-none transition-colors hover:text-chekin-blue",
|
|
3330
|
+
triggerAs === "button" && "focus-visible:shadow-chekin-focus",
|
|
3331
|
+
className
|
|
3332
|
+
);
|
|
3333
|
+
const triggerStyle = { width: size, height: size };
|
|
3334
|
+
const triggerContent = /* @__PURE__ */ jsxs34(Fragment5, { children: [
|
|
3335
|
+
/* @__PURE__ */ jsx55(CircleQuestionMark, { "aria-hidden": "true", style: { width: size, height: size } }),
|
|
3336
|
+
/* @__PURE__ */ jsx55("span", { className: "absolute -left-0.5 -top-0.5 h-5 w-5" })
|
|
3337
|
+
] });
|
|
3326
3338
|
return /* @__PURE__ */ jsx55(TooltipProvider, { children: /* @__PURE__ */ jsxs34(TooltipRoot, { children: [
|
|
3327
|
-
/* @__PURE__ */ jsx55(TooltipTrigger, { asChild: true, onClick, children: /* @__PURE__ */
|
|
3339
|
+
/* @__PURE__ */ jsx55(TooltipTrigger, { asChild: true, onClick, children: triggerAs === "button" ? /* @__PURE__ */ jsx55(
|
|
3328
3340
|
"button",
|
|
3329
3341
|
{
|
|
3330
3342
|
type: "button",
|
|
3331
3343
|
"aria-label": label,
|
|
3332
|
-
className:
|
|
3333
|
-
|
|
3334
|
-
|
|
3335
|
-
"focus-visible:shadow-chekin-focus",
|
|
3336
|
-
className
|
|
3337
|
-
),
|
|
3338
|
-
style: { width: size, height: size },
|
|
3339
|
-
children: [
|
|
3340
|
-
/* @__PURE__ */ jsx55(CircleQuestionMark, { "aria-hidden": "true", style: { width: size, height: size } }),
|
|
3341
|
-
/* @__PURE__ */ jsx55("span", { className: "absolute -left-0.5 -top-0.5 h-5 w-5" })
|
|
3342
|
-
]
|
|
3344
|
+
className: triggerClassName,
|
|
3345
|
+
style: triggerStyle,
|
|
3346
|
+
children: triggerContent
|
|
3343
3347
|
}
|
|
3344
|
-
) }),
|
|
3348
|
+
) : /* @__PURE__ */ jsx55("span", { "aria-label": label, className: triggerClassName, style: triggerStyle, children: triggerContent }) }),
|
|
3345
3349
|
/* @__PURE__ */ jsx55(
|
|
3346
3350
|
TooltipContent,
|
|
3347
3351
|
{
|
|
@@ -3356,11 +3360,11 @@ function HelpTooltip({
|
|
|
3356
3360
|
|
|
3357
3361
|
// src/icon/Icon.tsx
|
|
3358
3362
|
import { forwardRef as forwardRef23, memo as memo2 } from "react";
|
|
3359
|
-
import { Fragment as
|
|
3363
|
+
import { Fragment as Fragment6, jsx as jsx56, jsxs as jsxs35 } from "react/jsx-runtime";
|
|
3360
3364
|
var MissingIcon = forwardRef23(
|
|
3361
3365
|
({ size = 24, className = "", fallback = null, color, ...props }, ref) => {
|
|
3362
3366
|
if (fallback) {
|
|
3363
|
-
return /* @__PURE__ */ jsx56(
|
|
3367
|
+
return /* @__PURE__ */ jsx56(Fragment6, { children: fallback });
|
|
3364
3368
|
}
|
|
3365
3369
|
return /* @__PURE__ */ jsxs35(
|
|
3366
3370
|
"svg",
|
|
@@ -5033,37 +5037,42 @@ var SelectLabel = React19.forwardRef(({ className, ...props }, ref) => /* @__PUR
|
|
|
5033
5037
|
}
|
|
5034
5038
|
));
|
|
5035
5039
|
SelectLabel.displayName = "SelectLabel";
|
|
5036
|
-
var Select = (
|
|
5037
|
-
|
|
5038
|
-
|
|
5039
|
-
|
|
5040
|
-
|
|
5041
|
-
|
|
5042
|
-
|
|
5043
|
-
|
|
5044
|
-
|
|
5045
|
-
|
|
5046
|
-
|
|
5047
|
-
|
|
5048
|
-
|
|
5049
|
-
|
|
5050
|
-
|
|
5051
|
-
|
|
5052
|
-
|
|
5053
|
-
|
|
5054
|
-
|
|
5055
|
-
|
|
5056
|
-
|
|
5057
|
-
|
|
5058
|
-
|
|
5059
|
-
|
|
5060
|
-
|
|
5061
|
-
|
|
5062
|
-
|
|
5063
|
-
|
|
5064
|
-
|
|
5065
|
-
|
|
5066
|
-
}
|
|
5040
|
+
var Select = React19.forwardRef(
|
|
5041
|
+
({
|
|
5042
|
+
placeholder,
|
|
5043
|
+
label,
|
|
5044
|
+
supportingText,
|
|
5045
|
+
errorText,
|
|
5046
|
+
containerClassName,
|
|
5047
|
+
triggerClassName,
|
|
5048
|
+
children,
|
|
5049
|
+
...props
|
|
5050
|
+
}, ref) => {
|
|
5051
|
+
const reactId = React19.useId();
|
|
5052
|
+
const triggerId = props.name ?? reactId;
|
|
5053
|
+
const internalRef = React19.useRef(null);
|
|
5054
|
+
const combinedRef = useCombinedRef(ref, internalRef);
|
|
5055
|
+
return /* @__PURE__ */ jsxs46("div", { className: cn("flex flex-col gap-chekin-1 w-[300px]", containerClassName), children: [
|
|
5056
|
+
label && /* @__PURE__ */ jsx74(
|
|
5057
|
+
"label",
|
|
5058
|
+
{
|
|
5059
|
+
htmlFor: triggerId,
|
|
5060
|
+
className: "text-chekin-navy font-sans font-medium text-[14px] leading-5",
|
|
5061
|
+
children: label
|
|
5062
|
+
}
|
|
5063
|
+
),
|
|
5064
|
+
/* @__PURE__ */ jsxs46(SelectRoot, { ...props, children: [
|
|
5065
|
+
/* @__PURE__ */ jsx74(SelectTrigger, { ref: combinedRef, id: triggerId, className: triggerClassName, children: /* @__PURE__ */ jsx74(RadixSelect.Value, { placeholder }) }),
|
|
5066
|
+
/* @__PURE__ */ jsx74(SelectContent, { children })
|
|
5067
|
+
] }),
|
|
5068
|
+
/* @__PURE__ */ jsxs46("div", { className: "flex justify-between min-h-[15px]", children: [
|
|
5069
|
+
supportingText && !errorText && /* @__PURE__ */ jsx74("span", { className: "text-chekin-gray-2 font-sans italic text-[12px] leading-[15px]", children: supportingText }),
|
|
5070
|
+
errorText && /* @__PURE__ */ jsx74("span", { className: "ml-auto text-chekin-red font-sans font-medium text-[12px] leading-4 text-right", children: errorText })
|
|
5071
|
+
] })
|
|
5072
|
+
] });
|
|
5073
|
+
}
|
|
5074
|
+
);
|
|
5075
|
+
Select.displayName = "Select";
|
|
5067
5076
|
|
|
5068
5077
|
// src/pagination/Pagination.tsx
|
|
5069
5078
|
import { jsx as jsx75, jsxs as jsxs47 } from "react/jsx-runtime";
|
|
@@ -5280,7 +5289,7 @@ function useRadioOptions({ options, defaultValue, onChange }) {
|
|
|
5280
5289
|
var styles_default5 = {};
|
|
5281
5290
|
|
|
5282
5291
|
// src/radio/Radio.tsx
|
|
5283
|
-
import { Fragment as
|
|
5292
|
+
import { Fragment as Fragment7, jsx as jsx78, jsxs as jsxs48 } from "react/jsx-runtime";
|
|
5284
5293
|
var Radio = forwardRef32(
|
|
5285
5294
|
({ options, value, onChange, error, className = "", disabled = false, renderOption }, ref) => {
|
|
5286
5295
|
const { selectedValue, handleValueChange } = useRadioOptions({
|
|
@@ -5294,7 +5303,7 @@ var Radio = forwardRef32(
|
|
|
5294
5303
|
}
|
|
5295
5304
|
return option.value === selectedValue;
|
|
5296
5305
|
};
|
|
5297
|
-
return /* @__PURE__ */ jsxs48(
|
|
5306
|
+
return /* @__PURE__ */ jsxs48(Fragment7, { children: [
|
|
5298
5307
|
/* @__PURE__ */ jsx78(
|
|
5299
5308
|
RadioGroup,
|
|
5300
5309
|
{
|
|
@@ -5311,7 +5320,7 @@ var Radio = forwardRef32(
|
|
|
5311
5320
|
styles_default5.radio__wrapper,
|
|
5312
5321
|
(disabled || option.disabled) && styles_default5.radio__wrapper_disabled
|
|
5313
5322
|
),
|
|
5314
|
-
children: renderOption ? renderOption({ option, isSelected: getIsSelected(option) }) : /* @__PURE__ */ jsxs48(
|
|
5323
|
+
children: renderOption ? renderOption({ option, isSelected: getIsSelected(option) }) : /* @__PURE__ */ jsxs48(Fragment7, { children: [
|
|
5315
5324
|
/* @__PURE__ */ jsx78(
|
|
5316
5325
|
RadioGroupItem,
|
|
5317
5326
|
{
|
|
@@ -5569,42 +5578,74 @@ function SearchButton({ onClick, className, icon, ariaLabel }) {
|
|
|
5569
5578
|
}
|
|
5570
5579
|
|
|
5571
5580
|
// src/search-input/SearchInput.tsx
|
|
5572
|
-
import { Search as Search2, X as X6 } from "lucide-react";
|
|
5581
|
+
import { Loader2 as Loader23, Search as Search2, X as X6 } from "lucide-react";
|
|
5573
5582
|
import { useTranslation as useTranslation18 } from "react-i18next";
|
|
5574
5583
|
import { jsx as jsx85, jsxs as jsxs53 } from "react/jsx-runtime";
|
|
5575
5584
|
function SearchInput({
|
|
5585
|
+
disabled,
|
|
5586
|
+
invalid,
|
|
5587
|
+
label,
|
|
5588
|
+
loading,
|
|
5576
5589
|
onReset,
|
|
5590
|
+
optional,
|
|
5577
5591
|
placeholder,
|
|
5592
|
+
tooltip,
|
|
5578
5593
|
wrapperClassName,
|
|
5579
5594
|
className,
|
|
5580
5595
|
...props
|
|
5581
5596
|
}) {
|
|
5582
5597
|
const { t } = useTranslation18();
|
|
5583
5598
|
const placeholderText = placeholder || `${t("search_property")}...`;
|
|
5584
|
-
|
|
5585
|
-
|
|
5586
|
-
|
|
5587
|
-
|
|
5588
|
-
|
|
5589
|
-
|
|
5590
|
-
|
|
5591
|
-
|
|
5592
|
-
|
|
5593
|
-
|
|
5594
|
-
|
|
5599
|
+
const isBlocked = Boolean(disabled) || Boolean(loading);
|
|
5600
|
+
const optionalLabel = optional ? typeof optional === "string" ? optional : t("optional") : void 0;
|
|
5601
|
+
const hasLabelMeta = Boolean(optionalLabel) || Boolean(tooltip);
|
|
5602
|
+
return /* @__PURE__ */ jsxs53("div", { className: cn("input-wrapper", wrapperClassName), children: [
|
|
5603
|
+
(label || hasLabelMeta) && /* @__PURE__ */ jsxs53("div", { className: "mb-2 inline-flex max-w-full items-center gap-1.5 text-sm font-medium text-chekin-navy", children: [
|
|
5604
|
+
label && /* @__PURE__ */ jsx85("span", { className: "min-w-0 truncate", children: label }),
|
|
5605
|
+
optionalLabel && /* @__PURE__ */ jsx85("span", { className: "shrink-0 text-xs font-normal text-chekin-gray-2", children: optionalLabel }),
|
|
5606
|
+
tooltip && /* @__PURE__ */ jsx85(HelpTooltip, { content: tooltip, side: "top", size: 16 })
|
|
5607
|
+
] }),
|
|
5608
|
+
/* @__PURE__ */ jsxs53("div", { className: "relative", children: [
|
|
5609
|
+
/* @__PURE__ */ jsx85(Search2, { className: "absolute left-4 top-1/2 h-5 w-5 -translate-y-1/2 text-chekin-gray-2" }),
|
|
5610
|
+
/* @__PURE__ */ jsx85(
|
|
5611
|
+
Input,
|
|
5612
|
+
{
|
|
5613
|
+
...props,
|
|
5614
|
+
type: "text",
|
|
5615
|
+
disabled: isBlocked,
|
|
5616
|
+
placeholder: placeholderText,
|
|
5617
|
+
"aria-busy": loading,
|
|
5618
|
+
"aria-invalid": invalid,
|
|
5619
|
+
className: cn(
|
|
5620
|
+
"w-full py-3 pl-12 pr-10 text-base text-chekin-navy focus:border-chekin-gray-3",
|
|
5621
|
+
(loading || onReset) && "pr-20",
|
|
5622
|
+
invalid && "border-[var(--status-danger)] text-[var(--status-danger)] placeholder:text-[var(--status-danger)]",
|
|
5623
|
+
loading && "cursor-progress",
|
|
5624
|
+
className
|
|
5625
|
+
)
|
|
5626
|
+
}
|
|
5627
|
+
),
|
|
5628
|
+
(loading || onReset) && /* @__PURE__ */ jsxs53("div", { className: "absolute right-2 top-1/2 flex -translate-y-1/2 items-center gap-1", children: [
|
|
5629
|
+
loading && /* @__PURE__ */ jsx85(
|
|
5630
|
+
Loader23,
|
|
5631
|
+
{
|
|
5632
|
+
"aria-hidden": "true",
|
|
5633
|
+
className: "h-5 w-5 animate-spin text-chekin-gray-2"
|
|
5634
|
+
}
|
|
5635
|
+
),
|
|
5636
|
+
onReset && /* @__PURE__ */ jsx85(
|
|
5637
|
+
Button,
|
|
5638
|
+
{
|
|
5639
|
+
variant: "ghost",
|
|
5640
|
+
onClick: onReset,
|
|
5641
|
+
disabled: isBlocked,
|
|
5642
|
+
className: "h-7 w-7 p-0 text-chekin-gray-2",
|
|
5643
|
+
"aria-label": t("reset_search"),
|
|
5644
|
+
children: /* @__PURE__ */ jsx85(X6, { className: "h-5 w-5" })
|
|
5645
|
+
}
|
|
5595
5646
|
)
|
|
5596
|
-
}
|
|
5597
|
-
)
|
|
5598
|
-
onReset && /* @__PURE__ */ jsx85(
|
|
5599
|
-
Button,
|
|
5600
|
-
{
|
|
5601
|
-
variant: "ghost",
|
|
5602
|
-
onClick: onReset,
|
|
5603
|
-
className: "absolute right-2 top-1/2 h-7 w-7 -translate-y-1/2 p-0 text-chekin-gray-2",
|
|
5604
|
-
"aria-label": t("reset_search"),
|
|
5605
|
-
children: /* @__PURE__ */ jsx85(X6, { className: "h-5 w-5" })
|
|
5606
|
-
}
|
|
5607
|
-
)
|
|
5647
|
+
] })
|
|
5648
|
+
] })
|
|
5608
5649
|
] });
|
|
5609
5650
|
}
|
|
5610
5651
|
|
|
@@ -5797,7 +5838,7 @@ SelectorButton.displayName = "SelectorButton";
|
|
|
5797
5838
|
var styles_default8 = {};
|
|
5798
5839
|
|
|
5799
5840
|
// src/selectors/Selectors.tsx
|
|
5800
|
-
import { Fragment as
|
|
5841
|
+
import { Fragment as Fragment8, jsx as jsx89, jsxs as jsxs56 } from "react/jsx-runtime";
|
|
5801
5842
|
var getValueArray = (value) => {
|
|
5802
5843
|
if (value) {
|
|
5803
5844
|
return Array.isArray(value) ? value : [value];
|
|
@@ -5854,7 +5895,7 @@ function SelectorsInternal({
|
|
|
5854
5895
|
useEffect9(() => {
|
|
5855
5896
|
onAnySelectorActive?.(isAnyActive);
|
|
5856
5897
|
}, [isAnyActive, onAnySelectorActive]);
|
|
5857
|
-
return /* @__PURE__ */ jsxs56(
|
|
5898
|
+
return /* @__PURE__ */ jsxs56(Fragment8, { children: [
|
|
5858
5899
|
label && /* @__PURE__ */ jsx89("div", { className: styles_default8.labelWrapper, children: /* @__PURE__ */ jsx89("div", { className: cn(styles_default8.name, "label"), children: label }) }),
|
|
5859
5900
|
/* @__PURE__ */ jsx89(
|
|
5860
5901
|
"div",
|
|
@@ -6831,7 +6872,7 @@ function SortingAction({
|
|
|
6831
6872
|
// src/status-button/StatusButton.tsx
|
|
6832
6873
|
import { useMemo as useMemo3 } from "react";
|
|
6833
6874
|
import { useTranslation as useTranslation20 } from "react-i18next";
|
|
6834
|
-
import { AlertCircle as AlertCircle2, CheckCircle, Loader2 as
|
|
6875
|
+
import { AlertCircle as AlertCircle2, CheckCircle, Loader2 as Loader24 } from "lucide-react";
|
|
6835
6876
|
import { jsx as jsx97, jsxs as jsxs61 } from "react/jsx-runtime";
|
|
6836
6877
|
function StatusButton({
|
|
6837
6878
|
hidden,
|
|
@@ -6850,7 +6891,7 @@ function StatusButton({
|
|
|
6850
6891
|
const configMap = useMemo3(() => {
|
|
6851
6892
|
const defaultLoadingConfig = {
|
|
6852
6893
|
text: loadingText ?? `${t("saving")}...`,
|
|
6853
|
-
icon: /* @__PURE__ */ jsx97(
|
|
6894
|
+
icon: /* @__PURE__ */ jsx97(Loader24, { className: "h-4 w-4 animate-spin" }),
|
|
6854
6895
|
variant,
|
|
6855
6896
|
isLoading: true
|
|
6856
6897
|
};
|
|
@@ -7249,10 +7290,10 @@ var TASK_VARIANTS = {
|
|
|
7249
7290
|
import { Toaster, toast as toast2 } from "sonner";
|
|
7250
7291
|
|
|
7251
7292
|
// src/toaster/useUpdateToast.ts
|
|
7252
|
-
import { useCallback as useCallback9, useRef as
|
|
7293
|
+
import { useCallback as useCallback9, useRef as useRef9 } from "react";
|
|
7253
7294
|
import { toast } from "sonner";
|
|
7254
7295
|
function useUpdateToast({ id }) {
|
|
7255
|
-
const toastIdRef =
|
|
7296
|
+
const toastIdRef = useRef9("");
|
|
7256
7297
|
const getToastOptions = useCallback9(
|
|
7257
7298
|
(options) => ({
|
|
7258
7299
|
id: toastIdRef.current,
|
|
@@ -7737,7 +7778,7 @@ var LABEL_PLACEMENT = /* @__PURE__ */ ((LABEL_PLACEMENT2) => {
|
|
|
7737
7778
|
var styles_default10 = {};
|
|
7738
7779
|
|
|
7739
7780
|
// src/three-dots-loader/ThreeDotsLoader.tsx
|
|
7740
|
-
import { Fragment as
|
|
7781
|
+
import { Fragment as Fragment9, jsx as jsx113, jsxs as jsxs71 } from "react/jsx-runtime";
|
|
7741
7782
|
function Dots({
|
|
7742
7783
|
height,
|
|
7743
7784
|
width,
|
|
@@ -7759,10 +7800,10 @@ function ThreeDotsLoader({
|
|
|
7759
7800
|
}) {
|
|
7760
7801
|
const dots = /* @__PURE__ */ jsx113(Dots, { color, height, width });
|
|
7761
7802
|
if (label) {
|
|
7762
|
-
return /* @__PURE__ */ jsx113("div", { className: cn(styles_default10.Loader, className), children: labelPlacement === 0 /* right */ ? /* @__PURE__ */ jsxs71(
|
|
7803
|
+
return /* @__PURE__ */ jsx113("div", { className: cn(styles_default10.Loader, className), children: labelPlacement === 0 /* right */ ? /* @__PURE__ */ jsxs71(Fragment9, { children: [
|
|
7763
7804
|
dots,
|
|
7764
7805
|
/* @__PURE__ */ jsx113("div", { children: label })
|
|
7765
|
-
] }) : /* @__PURE__ */ jsxs71(
|
|
7806
|
+
] }) : /* @__PURE__ */ jsxs71(Fragment9, { children: [
|
|
7766
7807
|
/* @__PURE__ */ jsx113("div", { children: label }),
|
|
7767
7808
|
dots
|
|
7768
7809
|
] }) });
|
|
@@ -8007,6 +8048,13 @@ function stripTime(date) {
|
|
|
8007
8048
|
function isValidDate(value) {
|
|
8008
8049
|
return value instanceof Date && !Number.isNaN(value.getTime());
|
|
8009
8050
|
}
|
|
8051
|
+
function normalizeDateValue(value) {
|
|
8052
|
+
if (value === "" || value === null || value === void 0) {
|
|
8053
|
+
return null;
|
|
8054
|
+
}
|
|
8055
|
+
const date = value instanceof Date ? value : new Date(value);
|
|
8056
|
+
return isValidDate(date) ? date : null;
|
|
8057
|
+
}
|
|
8010
8058
|
function clampDate(date, minDate, maxDate) {
|
|
8011
8059
|
const normalizedDate = stripTime(date);
|
|
8012
8060
|
const normalizedMinDate = isValidDate(minDate) ? stripTime(minDate) : null;
|
|
@@ -8671,6 +8719,8 @@ var DEVICE = {
|
|
|
8671
8719
|
|
|
8672
8720
|
// src/field-trigger/FieldTrigger.tsx
|
|
8673
8721
|
import * as React29 from "react";
|
|
8722
|
+
import { Loader2 as Loader25 } from "lucide-react";
|
|
8723
|
+
import { useTranslation as useTranslation22 } from "react-i18next";
|
|
8674
8724
|
|
|
8675
8725
|
// src/field-error-message/FieldErrorMessage.tsx
|
|
8676
8726
|
import { AlertCircle as AlertCircle3 } from "lucide-react";
|
|
@@ -8711,7 +8761,7 @@ function FieldErrorMessage({
|
|
|
8711
8761
|
}
|
|
8712
8762
|
|
|
8713
8763
|
// src/field-trigger/FieldTrigger.tsx
|
|
8714
|
-
import { Fragment as
|
|
8764
|
+
import { Fragment as Fragment10, jsx as jsx120, jsxs as jsxs77 } from "react/jsx-runtime";
|
|
8715
8765
|
var FieldTrigger = React29.forwardRef(
|
|
8716
8766
|
({
|
|
8717
8767
|
as = "button",
|
|
@@ -8728,30 +8778,63 @@ var FieldTrigger = React29.forwardRef(
|
|
|
8728
8778
|
placeholder,
|
|
8729
8779
|
disabled,
|
|
8730
8780
|
error,
|
|
8781
|
+
loading,
|
|
8782
|
+
optional,
|
|
8783
|
+
tooltip,
|
|
8731
8784
|
describedBy,
|
|
8732
8785
|
className,
|
|
8733
8786
|
contentClassName,
|
|
8734
8787
|
trailingAdornment,
|
|
8735
8788
|
forceFloatingLabel = false,
|
|
8789
|
+
forceLabelText = false,
|
|
8736
8790
|
hideErrorMessage = false,
|
|
8737
8791
|
children,
|
|
8738
8792
|
onClick,
|
|
8739
8793
|
onKeyDown,
|
|
8740
8794
|
...props
|
|
8741
8795
|
}, ref) => {
|
|
8796
|
+
const { t } = useTranslation22();
|
|
8742
8797
|
const hasValue = Boolean(valueText);
|
|
8743
8798
|
const isRaised = hasValue || forceFloatingLabel;
|
|
8744
|
-
const
|
|
8799
|
+
const optionalLabel = optional ? typeof optional === "string" ? optional : t("optional") : void 0;
|
|
8800
|
+
const visibleLabelText = labelText ?? label;
|
|
8801
|
+
const hasLabelMeta = Boolean(optionalLabel) || Boolean(tooltip);
|
|
8802
|
+
const resolvedLabelText = visibleLabelText && hasLabelMeta ? /* @__PURE__ */ jsxs77("span", { className: "inline-flex max-w-full items-center gap-1.5 align-middle", children: [
|
|
8803
|
+
/* @__PURE__ */ jsx120("span", { className: "min-w-0 truncate", children: visibleLabelText }),
|
|
8804
|
+
optionalLabel && /* @__PURE__ */ jsxs77("span", { className: "shrink-0 text-[12px] relative top-[1px] font-normal leading-4 text-current opacity-70", children: [
|
|
8805
|
+
"(",
|
|
8806
|
+
optionalLabel,
|
|
8807
|
+
")"
|
|
8808
|
+
] }),
|
|
8809
|
+
tooltip && /* @__PURE__ */ jsx120(
|
|
8810
|
+
HelpTooltip,
|
|
8811
|
+
{
|
|
8812
|
+
content: tooltip,
|
|
8813
|
+
side: "top",
|
|
8814
|
+
size: 16,
|
|
8815
|
+
triggerAs: as === "button" ? "span" : "button",
|
|
8816
|
+
className: "pointer-events-auto text-current opacity-70 hover:text-current hover:opacity-100"
|
|
8817
|
+
}
|
|
8818
|
+
)
|
|
8819
|
+
] }) : visibleLabelText;
|
|
8820
|
+
const animatedLabel = forceLabelText ? resolvedLabelText ?? placeholder : isRaised ? resolvedLabelText : label ?? placeholder;
|
|
8745
8821
|
const isAirbnbVariant = variant === "airbnb";
|
|
8822
|
+
const hasInvalidState = Boolean(error);
|
|
8823
|
+
const errorMessage = typeof error === "string" ? error : void 0;
|
|
8824
|
+
const isBlocked = Boolean(disabled) || Boolean(loading);
|
|
8825
|
+
const resolvedTrailingAdornment = loading || trailingAdornment ? /* @__PURE__ */ jsxs77("span", { className: "flex items-center gap-2", children: [
|
|
8826
|
+
trailingAdornment,
|
|
8827
|
+
loading && /* @__PURE__ */ jsx120(Loader25, { "aria-hidden": "true", className: "h-5 w-5 animate-spin text-[#7A8399]" })
|
|
8828
|
+
] }) : void 0;
|
|
8746
8829
|
const sharedClasses = cn(
|
|
8747
8830
|
"relative flex border w-full items-center bg-[var(--form-background-color,#fff)] text-left transition-colors focus-visible:outline-none",
|
|
8748
8831
|
isAirbnbVariant ? "rounded-[var(--form-input-border-radius,12px)] border-[var(--form-border-color,#8c8c8c)] pl-4 pr-4 focus-visible:ring-2 focus-visible:ring-[var(--form-title-color,#222222)] focus-visible:ring-offset-2" : "rounded-[10px] px-3.5 focus-visible:border-[#315EFB]",
|
|
8749
8832
|
isAirbnbVariant ? isRaised ? "min-h-[60px]" : "h-[60px]" : "min-h-[48px]",
|
|
8750
|
-
|
|
8751
|
-
disabled ? "cursor-not-allowed opacity-50" : isAirbnbVariant ? "cursor-pointer" : "cursor-text",
|
|
8833
|
+
hasInvalidState ? isAirbnbVariant ? "border-[var(--status-danger)] bg-[var(--form-error-background,#FFF5F3)]" : "border-[var(--status-danger)] bg-white" : isAirbnbVariant ? "border-[var(--form-border-color,#8c8c8c)]" : "border-[#A8A8A4] bg-white",
|
|
8834
|
+
disabled ? "cursor-not-allowed opacity-50" : loading ? "cursor-progress" : isAirbnbVariant ? "cursor-pointer" : "cursor-text",
|
|
8752
8835
|
className
|
|
8753
8836
|
);
|
|
8754
|
-
const sharedContent = /* @__PURE__ */ jsxs77(
|
|
8837
|
+
const sharedContent = /* @__PURE__ */ jsxs77(Fragment10, { children: [
|
|
8755
8838
|
/* @__PURE__ */ jsxs77(
|
|
8756
8839
|
"span",
|
|
8757
8840
|
{
|
|
@@ -8766,9 +8849,10 @@ var FieldTrigger = React29.forwardRef(
|
|
|
8766
8849
|
{
|
|
8767
8850
|
id: labelId,
|
|
8768
8851
|
className: cn(
|
|
8769
|
-
"
|
|
8852
|
+
"absolute left-0 origin-left truncate transition-all duration-200 ease-out",
|
|
8853
|
+
hasLabelMeta ? "" : "pointer-events-none",
|
|
8770
8854
|
isAirbnbVariant ? isRaised ? "top-0 translate-y-0 text-xs leading-5" : "top-1/2 -translate-y-1/2 text-[16px] leading-7" : isRaised ? "-top-2 translate-y-0 bg-[var(--form-background-color,#fff)] px-1 text-[12px] font-medium leading-4" : "top-1/2 -translate-y-1/2 text-[16px] leading-6",
|
|
8771
|
-
|
|
8855
|
+
hasInvalidState ? "text-[var(--status-danger)]" : isAirbnbVariant ? "text-[var(--form-placeholder-color,#6c6c6c)]" : "text-[#7A8399]"
|
|
8772
8856
|
),
|
|
8773
8857
|
children: animatedLabel
|
|
8774
8858
|
}
|
|
@@ -8780,7 +8864,7 @@ var FieldTrigger = React29.forwardRef(
|
|
|
8780
8864
|
className: cn(
|
|
8781
8865
|
"absolute left-0 block truncate transition-all duration-200 ease-out",
|
|
8782
8866
|
isAirbnbVariant ? "bottom-0 translate-y-0 text-[16px] leading-6 opacity-100" : "bottom-[11px] text-[16px] leading-6",
|
|
8783
|
-
|
|
8867
|
+
hasInvalidState ? "text-[var(--status-danger)]" : "text-[var(--form-field-text-color,#222222)]"
|
|
8784
8868
|
),
|
|
8785
8869
|
children: valueText
|
|
8786
8870
|
}
|
|
@@ -8788,7 +8872,7 @@ var FieldTrigger = React29.forwardRef(
|
|
|
8788
8872
|
]
|
|
8789
8873
|
}
|
|
8790
8874
|
),
|
|
8791
|
-
|
|
8875
|
+
resolvedTrailingAdornment && /* @__PURE__ */ jsx120(
|
|
8792
8876
|
"span",
|
|
8793
8877
|
{
|
|
8794
8878
|
"aria-hidden": "true",
|
|
@@ -8796,7 +8880,7 @@ var FieldTrigger = React29.forwardRef(
|
|
|
8796
8880
|
"pointer-events-none absolute top-1/2 -translate-y-1/2",
|
|
8797
8881
|
isAirbnbVariant ? "right-5" : "right-4"
|
|
8798
8882
|
),
|
|
8799
|
-
children:
|
|
8883
|
+
children: resolvedTrailingAdornment
|
|
8800
8884
|
}
|
|
8801
8885
|
)
|
|
8802
8886
|
] });
|
|
@@ -8810,10 +8894,11 @@ var FieldTrigger = React29.forwardRef(
|
|
|
8810
8894
|
type: "button",
|
|
8811
8895
|
"aria-labelledby": hasValue && valueId ? `${labelId} ${valueId}` : labelId,
|
|
8812
8896
|
"aria-describedby": describedBy,
|
|
8813
|
-
"aria-invalid":
|
|
8814
|
-
|
|
8815
|
-
|
|
8816
|
-
|
|
8897
|
+
"aria-invalid": hasInvalidState,
|
|
8898
|
+
"aria-busy": loading,
|
|
8899
|
+
disabled: isBlocked,
|
|
8900
|
+
onClick: isBlocked ? void 0 : onClick,
|
|
8901
|
+
onKeyDown: isBlocked ? void 0 : onKeyDown,
|
|
8817
8902
|
className: sharedClasses,
|
|
8818
8903
|
...props,
|
|
8819
8904
|
children: sharedContent
|
|
@@ -8825,16 +8910,17 @@ var FieldTrigger = React29.forwardRef(
|
|
|
8825
8910
|
ref,
|
|
8826
8911
|
"aria-labelledby": hasValue && valueId ? `${labelId} ${valueId}` : labelId,
|
|
8827
8912
|
"aria-describedby": describedBy,
|
|
8828
|
-
"aria-invalid":
|
|
8829
|
-
"aria-
|
|
8830
|
-
|
|
8831
|
-
|
|
8913
|
+
"aria-invalid": hasInvalidState,
|
|
8914
|
+
"aria-busy": loading,
|
|
8915
|
+
"aria-disabled": isBlocked,
|
|
8916
|
+
onClick: isBlocked ? void 0 : onClick,
|
|
8917
|
+
onKeyDown: isBlocked ? void 0 : onKeyDown,
|
|
8832
8918
|
className: sharedClasses,
|
|
8833
8919
|
...props,
|
|
8834
8920
|
children: sharedContent
|
|
8835
8921
|
}
|
|
8836
8922
|
),
|
|
8837
|
-
|
|
8923
|
+
errorMessage && !hideErrorMessage && /* @__PURE__ */ jsx120(FieldErrorMessage, { id: errorId, message: errorMessage })
|
|
8838
8924
|
] });
|
|
8839
8925
|
}
|
|
8840
8926
|
);
|
|
@@ -8843,154 +8929,190 @@ FieldTrigger.displayName = "FieldTrigger";
|
|
|
8843
8929
|
// src/datepicker/DatePicker.tsx
|
|
8844
8930
|
import { jsx as jsx121, jsxs as jsxs78 } from "react/jsx-runtime";
|
|
8845
8931
|
var DEFAULT_MIN_DATE = new Date(1920, 0, 1);
|
|
8846
|
-
|
|
8847
|
-
|
|
8848
|
-
|
|
8849
|
-
|
|
8850
|
-
|
|
8851
|
-
|
|
8852
|
-
onChange,
|
|
8853
|
-
placeholder = "Select a date",
|
|
8854
|
-
disabled,
|
|
8855
|
-
error,
|
|
8856
|
-
className,
|
|
8857
|
-
name,
|
|
8858
|
-
minDate,
|
|
8859
|
-
maxDate,
|
|
8860
|
-
locale = "en-US",
|
|
8861
|
-
mobileTitle,
|
|
8862
|
-
doneLabel = "Done",
|
|
8863
|
-
formatValue = formatDateValue
|
|
8864
|
-
}) {
|
|
8865
|
-
const { isMatch: isMobile } = useScreenResize(DEVICE.mobileXL);
|
|
8866
|
-
const [isOpen, setIsOpen] = React30.useState(false);
|
|
8867
|
-
const triggerId = React30.useId();
|
|
8868
|
-
const pickerId = React30.useId();
|
|
8869
|
-
const labelId = React30.useId();
|
|
8870
|
-
const valueId = React30.useId();
|
|
8871
|
-
const helperTextId = React30.useId();
|
|
8872
|
-
const errorId = React30.useId();
|
|
8873
|
-
const triggerRef = React30.useRef(null);
|
|
8874
|
-
const monthLabels = React30.useMemo(() => getMonthLabels(locale), [locale]);
|
|
8875
|
-
const resolvedMinDate = React30.useMemo(() => minDate ?? DEFAULT_MIN_DATE, [minDate]);
|
|
8876
|
-
const resolvedMaxDate = React30.useMemo(() => maxDate ?? /* @__PURE__ */ new Date(), [maxDate]);
|
|
8877
|
-
const resolvedValue = React30.useMemo(
|
|
8878
|
-
() => value ? clampDate(value, resolvedMinDate, resolvedMaxDate) : null,
|
|
8879
|
-
[resolvedMaxDate, resolvedMinDate, value]
|
|
8880
|
-
);
|
|
8881
|
-
const hasValue = Boolean(resolvedValue);
|
|
8882
|
-
const {
|
|
8883
|
-
dayIndex,
|
|
8884
|
-
dayListRef,
|
|
8885
|
-
dayScrollTop,
|
|
8886
|
-
days,
|
|
8887
|
-
draftDate,
|
|
8888
|
-
handleColumnKeyDown,
|
|
8889
|
-
handleColumnScroll,
|
|
8890
|
-
handleOptionSelect,
|
|
8891
|
-
monthIndex,
|
|
8892
|
-
monthListRef,
|
|
8893
|
-
months,
|
|
8894
|
-
monthScrollTop,
|
|
8895
|
-
yearIndex,
|
|
8896
|
-
yearListRef,
|
|
8897
|
-
yearScrollTop,
|
|
8898
|
-
years
|
|
8899
|
-
} = useDatePickerWheel({
|
|
8900
|
-
isOpen,
|
|
8901
|
-
value: resolvedValue,
|
|
8932
|
+
var DatePicker = React30.forwardRef(
|
|
8933
|
+
({
|
|
8934
|
+
variant = "default",
|
|
8935
|
+
label,
|
|
8936
|
+
topLabel,
|
|
8937
|
+
value,
|
|
8902
8938
|
defaultValue,
|
|
8903
|
-
|
|
8904
|
-
|
|
8905
|
-
|
|
8906
|
-
|
|
8907
|
-
|
|
8908
|
-
|
|
8909
|
-
|
|
8910
|
-
|
|
8911
|
-
|
|
8912
|
-
|
|
8913
|
-
|
|
8914
|
-
|
|
8915
|
-
|
|
8916
|
-
|
|
8917
|
-
|
|
8918
|
-
|
|
8919
|
-
},
|
|
8920
|
-
|
|
8921
|
-
(
|
|
8922
|
-
|
|
8923
|
-
|
|
8924
|
-
|
|
8925
|
-
|
|
8926
|
-
|
|
8927
|
-
|
|
8928
|
-
|
|
8929
|
-
|
|
8930
|
-
|
|
8931
|
-
|
|
8932
|
-
|
|
8933
|
-
|
|
8934
|
-
|
|
8935
|
-
|
|
8936
|
-
|
|
8937
|
-
|
|
8938
|
-
|
|
8939
|
-
|
|
8940
|
-
|
|
8941
|
-
|
|
8942
|
-
|
|
8943
|
-
|
|
8944
|
-
|
|
8945
|
-
|
|
8946
|
-
|
|
8947
|
-
|
|
8948
|
-
|
|
8949
|
-
|
|
8950
|
-
|
|
8951
|
-
|
|
8952
|
-
|
|
8953
|
-
|
|
8954
|
-
|
|
8955
|
-
|
|
8956
|
-
|
|
8957
|
-
|
|
8958
|
-
|
|
8959
|
-
|
|
8960
|
-
|
|
8961
|
-
|
|
8962
|
-
|
|
8963
|
-
|
|
8964
|
-
|
|
8965
|
-
|
|
8966
|
-
|
|
8967
|
-
|
|
8968
|
-
|
|
8969
|
-
|
|
8970
|
-
|
|
8971
|
-
|
|
8972
|
-
|
|
8973
|
-
|
|
8974
|
-
|
|
8975
|
-
|
|
8976
|
-
|
|
8977
|
-
|
|
8978
|
-
|
|
8979
|
-
|
|
8980
|
-
|
|
8981
|
-
|
|
8982
|
-
|
|
8983
|
-
|
|
8984
|
-
|
|
8985
|
-
|
|
8986
|
-
|
|
8987
|
-
|
|
8988
|
-
|
|
8989
|
-
|
|
8939
|
+
onChange,
|
|
8940
|
+
placeholder = "Select a date",
|
|
8941
|
+
disabled,
|
|
8942
|
+
error,
|
|
8943
|
+
invalid,
|
|
8944
|
+
loading,
|
|
8945
|
+
optional,
|
|
8946
|
+
tooltip,
|
|
8947
|
+
className,
|
|
8948
|
+
name,
|
|
8949
|
+
minDate,
|
|
8950
|
+
maxDate,
|
|
8951
|
+
locale = "en-US",
|
|
8952
|
+
mobileTitle,
|
|
8953
|
+
doneLabel = "Done",
|
|
8954
|
+
formatValue = formatDateValue
|
|
8955
|
+
}, ref) => {
|
|
8956
|
+
const { isMatch: isMobile } = useScreenResize(DEVICE.mobileXL);
|
|
8957
|
+
const [isOpen, setIsOpen] = React30.useState(false);
|
|
8958
|
+
const triggerId = React30.useId();
|
|
8959
|
+
const pickerId = React30.useId();
|
|
8960
|
+
const labelId = React30.useId();
|
|
8961
|
+
const valueId = React30.useId();
|
|
8962
|
+
const helperTextId = React30.useId();
|
|
8963
|
+
const errorId = React30.useId();
|
|
8964
|
+
const internalRef = React30.useRef(null);
|
|
8965
|
+
const combinedRef = useCombinedRef(ref, internalRef);
|
|
8966
|
+
const monthLabels = React30.useMemo(() => getMonthLabels(locale), [locale]);
|
|
8967
|
+
const resolvedMinDate = React30.useMemo(() => minDate ?? DEFAULT_MIN_DATE, [minDate]);
|
|
8968
|
+
const resolvedMaxDate = React30.useMemo(() => maxDate ?? /* @__PURE__ */ new Date(), [maxDate]);
|
|
8969
|
+
const normalizedValue = React30.useMemo(() => normalizeDateValue(value), [value]);
|
|
8970
|
+
const normalizedDefaultValue = React30.useMemo(
|
|
8971
|
+
() => normalizeDateValue(defaultValue),
|
|
8972
|
+
[defaultValue]
|
|
8973
|
+
);
|
|
8974
|
+
const resolvedValue = React30.useMemo(
|
|
8975
|
+
() => normalizedValue ? clampDate(normalizedValue, resolvedMinDate, resolvedMaxDate) : null,
|
|
8976
|
+
[normalizedValue, resolvedMaxDate, resolvedMinDate]
|
|
8977
|
+
);
|
|
8978
|
+
const hasValue = Boolean(resolvedValue);
|
|
8979
|
+
const isBlocked = Boolean(disabled) || Boolean(loading);
|
|
8980
|
+
const triggerError = error ?? invalid;
|
|
8981
|
+
const {
|
|
8982
|
+
dayIndex,
|
|
8983
|
+
dayListRef,
|
|
8984
|
+
dayScrollTop,
|
|
8985
|
+
days,
|
|
8986
|
+
draftDate,
|
|
8987
|
+
handleColumnKeyDown,
|
|
8988
|
+
handleColumnScroll,
|
|
8989
|
+
handleOptionSelect,
|
|
8990
|
+
monthIndex,
|
|
8991
|
+
monthListRef,
|
|
8992
|
+
months,
|
|
8993
|
+
monthScrollTop,
|
|
8994
|
+
yearIndex,
|
|
8995
|
+
yearListRef,
|
|
8996
|
+
yearScrollTop,
|
|
8997
|
+
years
|
|
8998
|
+
} = useDatePickerWheel({
|
|
8999
|
+
isOpen,
|
|
9000
|
+
value: resolvedValue,
|
|
9001
|
+
defaultValue: normalizedDefaultValue,
|
|
9002
|
+
minDate: resolvedMinDate,
|
|
9003
|
+
maxDate: resolvedMaxDate
|
|
9004
|
+
});
|
|
9005
|
+
const handleOpenChange = React30.useCallback(
|
|
9006
|
+
(nextOpen) => {
|
|
9007
|
+
if (isBlocked && nextOpen) return;
|
|
9008
|
+
setIsOpen(nextOpen);
|
|
9009
|
+
if (!nextOpen) {
|
|
9010
|
+
internalRef.current?.focus();
|
|
9011
|
+
}
|
|
9012
|
+
},
|
|
9013
|
+
[isBlocked]
|
|
9014
|
+
);
|
|
9015
|
+
const handleDone = React30.useCallback(() => {
|
|
9016
|
+
if (isBlocked) return;
|
|
9017
|
+
onChange(clampDate(draftDate, resolvedMinDate, resolvedMaxDate));
|
|
9018
|
+
handleOpenChange(false);
|
|
9019
|
+
}, [
|
|
9020
|
+
draftDate,
|
|
9021
|
+
handleOpenChange,
|
|
9022
|
+
isBlocked,
|
|
9023
|
+
onChange,
|
|
9024
|
+
resolvedMaxDate,
|
|
9025
|
+
resolvedMinDate
|
|
9026
|
+
]);
|
|
9027
|
+
const handleTriggerClick = React30.useCallback(() => {
|
|
9028
|
+
if (isBlocked) return;
|
|
9029
|
+
setIsOpen(true);
|
|
9030
|
+
}, [isBlocked]);
|
|
9031
|
+
const handleTriggerKeyDown = React30.useCallback(
|
|
9032
|
+
(event) => {
|
|
9033
|
+
if (isBlocked) return;
|
|
9034
|
+
if (event.key === "ArrowDown" || event.key === "ArrowUp" || event.key === "Enter" || event.key === " ") {
|
|
9035
|
+
event.preventDefault();
|
|
9036
|
+
setIsOpen(true);
|
|
9037
|
+
}
|
|
9038
|
+
},
|
|
9039
|
+
[isBlocked]
|
|
9040
|
+
);
|
|
9041
|
+
React30.useEffect(() => {
|
|
9042
|
+
if (isBlocked) {
|
|
9043
|
+
setIsOpen(false);
|
|
8990
9044
|
}
|
|
8991
|
-
)
|
|
8992
|
-
|
|
8993
|
-
|
|
9045
|
+
}, [isBlocked]);
|
|
9046
|
+
return /* @__PURE__ */ jsxs78("div", { className: cn("relative w-full max-w-[425px]", className), children: [
|
|
9047
|
+
name && /* @__PURE__ */ jsx121(
|
|
9048
|
+
"input",
|
|
9049
|
+
{
|
|
9050
|
+
type: "hidden",
|
|
9051
|
+
name,
|
|
9052
|
+
value: resolvedValue ? formatDateInputValue(resolvedValue) : ""
|
|
9053
|
+
}
|
|
9054
|
+
),
|
|
9055
|
+
/* @__PURE__ */ jsx121(
|
|
9056
|
+
FieldTrigger,
|
|
9057
|
+
{
|
|
9058
|
+
id: triggerId,
|
|
9059
|
+
ref: combinedRef,
|
|
9060
|
+
variant,
|
|
9061
|
+
label,
|
|
9062
|
+
topLabel,
|
|
9063
|
+
labelId,
|
|
9064
|
+
valueId: hasValue ? valueId : void 0,
|
|
9065
|
+
helperTextId: !hasValue ? helperTextId : void 0,
|
|
9066
|
+
errorId: error ? errorId : void 0,
|
|
9067
|
+
describedBy: error ? errorId : void 0,
|
|
9068
|
+
labelText: topLabel ? placeholder : void 0,
|
|
9069
|
+
valueText: resolvedValue ? formatValue(resolvedValue) : void 0,
|
|
9070
|
+
placeholder,
|
|
9071
|
+
disabled,
|
|
9072
|
+
error: triggerError,
|
|
9073
|
+
loading,
|
|
9074
|
+
optional,
|
|
9075
|
+
tooltip,
|
|
9076
|
+
forceLabelText: Boolean(optional) || Boolean(tooltip),
|
|
9077
|
+
"aria-haspopup": "dialog",
|
|
9078
|
+
"aria-expanded": isOpen,
|
|
9079
|
+
onClick: handleTriggerClick,
|
|
9080
|
+
onKeyDown: handleTriggerKeyDown,
|
|
9081
|
+
trailingAdornment: /* @__PURE__ */ jsx121(Calendar2, { className: "h-5 w-5 text-[#1F1F1B]", strokeWidth: 2 })
|
|
9082
|
+
}
|
|
9083
|
+
),
|
|
9084
|
+
/* @__PURE__ */ jsx121(
|
|
9085
|
+
DatePickerContent,
|
|
9086
|
+
{
|
|
9087
|
+
baseId: pickerId,
|
|
9088
|
+
open: isOpen,
|
|
9089
|
+
isMobile,
|
|
9090
|
+
label,
|
|
9091
|
+
title: mobileTitle ?? label,
|
|
9092
|
+
doneLabel,
|
|
9093
|
+
monthLabels: months.map((month) => monthLabels[month] ?? ""),
|
|
9094
|
+
days,
|
|
9095
|
+
years,
|
|
9096
|
+
monthIndex,
|
|
9097
|
+
dayIndex,
|
|
9098
|
+
yearIndex,
|
|
9099
|
+
monthScrollTop,
|
|
9100
|
+
dayScrollTop,
|
|
9101
|
+
yearScrollTop,
|
|
9102
|
+
monthListRef,
|
|
9103
|
+
dayListRef,
|
|
9104
|
+
yearListRef,
|
|
9105
|
+
onOpenChange: handleOpenChange,
|
|
9106
|
+
onDone: handleDone,
|
|
9107
|
+
onColumnScroll: handleColumnScroll,
|
|
9108
|
+
onColumnKeyDown: handleColumnKeyDown,
|
|
9109
|
+
onOptionSelect: handleOptionSelect
|
|
9110
|
+
}
|
|
9111
|
+
)
|
|
9112
|
+
] });
|
|
9113
|
+
}
|
|
9114
|
+
);
|
|
9115
|
+
DatePicker.displayName = "DatePicker";
|
|
8994
9116
|
|
|
8995
9117
|
// src/responsive-sheet/ResponsiveSheet.tsx
|
|
8996
9118
|
import { jsx as jsx122, jsxs as jsxs79 } from "react/jsx-runtime";
|
|
@@ -9111,6 +9233,10 @@ var AirbnbInput = React31.forwardRef(
|
|
|
9111
9233
|
topLabel,
|
|
9112
9234
|
helperText,
|
|
9113
9235
|
error,
|
|
9236
|
+
invalid,
|
|
9237
|
+
loading,
|
|
9238
|
+
optional,
|
|
9239
|
+
tooltip,
|
|
9114
9240
|
wrapperClassName,
|
|
9115
9241
|
fieldClassName,
|
|
9116
9242
|
contentClassName,
|
|
@@ -9135,7 +9261,7 @@ var AirbnbInput = React31.forwardRef(
|
|
|
9135
9261
|
const fieldId = `${inputId}-field`;
|
|
9136
9262
|
const labelId = `${inputId}-label`;
|
|
9137
9263
|
const errorId = `${inputId}-error`;
|
|
9138
|
-
const accessibleLabel =
|
|
9264
|
+
const accessibleLabel = placeholder ?? label;
|
|
9139
9265
|
const [isFocused, setIsFocused] = React31.useState(false);
|
|
9140
9266
|
const [currentValue, setCurrentValue] = React31.useState(
|
|
9141
9267
|
() => value != null ? getInputValue(value) : getInputValue(defaultValue)
|
|
@@ -9143,6 +9269,10 @@ var AirbnbInput = React31.forwardRef(
|
|
|
9143
9269
|
const resolvedValue = value != null ? getInputValue(value) : currentValue;
|
|
9144
9270
|
const hasValue = resolvedValue.length > 0;
|
|
9145
9271
|
const shouldShowLabel = hasValue || isFocused;
|
|
9272
|
+
const hasInvalidState = Boolean(error) || Boolean(invalid);
|
|
9273
|
+
const triggerError = error ?? invalid;
|
|
9274
|
+
const hasLabelMeta = Boolean(optional) || Boolean(tooltip);
|
|
9275
|
+
const isBlocked = Boolean(disabled) || Boolean(loading);
|
|
9146
9276
|
React31.useLayoutEffect(() => {
|
|
9147
9277
|
const nextValue = value != null ? getInputValue(value) : getInputValue(inputRef.current?.value);
|
|
9148
9278
|
setCurrentValue((prevValue) => prevValue === nextValue ? prevValue : nextValue);
|
|
@@ -9191,7 +9321,10 @@ var AirbnbInput = React31.forwardRef(
|
|
|
9191
9321
|
labelText: helperText ?? label,
|
|
9192
9322
|
placeholder: placeholder ?? label,
|
|
9193
9323
|
disabled,
|
|
9194
|
-
error,
|
|
9324
|
+
error: triggerError,
|
|
9325
|
+
loading,
|
|
9326
|
+
optional,
|
|
9327
|
+
tooltip,
|
|
9195
9328
|
describedBy: error && renderErrorMessage ? errorId : void 0,
|
|
9196
9329
|
className: cn(
|
|
9197
9330
|
variant === "airbnb" ? "px-4 focus-within:ring-2 focus-within:ring-[#1F1F1B] focus-within:ring-offset-2" : "px-3.5 focus-within:border-[#315EFB]",
|
|
@@ -9204,6 +9337,7 @@ var AirbnbInput = React31.forwardRef(
|
|
|
9204
9337
|
),
|
|
9205
9338
|
trailingAdornment,
|
|
9206
9339
|
forceFloatingLabel: shouldShowLabel,
|
|
9340
|
+
forceLabelText: hasLabelMeta,
|
|
9207
9341
|
hideErrorMessage: !renderErrorMessage,
|
|
9208
9342
|
children: /* @__PURE__ */ jsx123(
|
|
9209
9343
|
"input",
|
|
@@ -9212,21 +9346,23 @@ var AirbnbInput = React31.forwardRef(
|
|
|
9212
9346
|
id: inputId,
|
|
9213
9347
|
ref: setRefs,
|
|
9214
9348
|
type,
|
|
9215
|
-
disabled,
|
|
9349
|
+
disabled: isBlocked,
|
|
9216
9350
|
value,
|
|
9217
9351
|
defaultValue,
|
|
9218
9352
|
onChange: handleChange,
|
|
9219
9353
|
onFocus: handleFocus,
|
|
9220
9354
|
onBlur: handleBlur,
|
|
9221
9355
|
placeholder: "",
|
|
9222
|
-
"aria-invalid":
|
|
9356
|
+
"aria-invalid": hasInvalidState,
|
|
9357
|
+
"aria-busy": loading,
|
|
9223
9358
|
"aria-describedby": error && renderErrorMessage ? errorId : void 0,
|
|
9224
|
-
"aria-
|
|
9359
|
+
"aria-label": accessibleLabel && hasLabelMeta ? accessibleLabel : void 0,
|
|
9360
|
+
"aria-labelledby": accessibleLabel && !hasLabelMeta ? labelId : void 0,
|
|
9225
9361
|
className: cn(
|
|
9226
9362
|
"absolute left-0 h-6 w-full border-0 bg-transparent p-0 text-[16px] leading-6 text-[#1F1F1B] outline-none placeholder:text-[#7A8399]",
|
|
9227
9363
|
variant === "airbnb" ? "bottom-0" : "bottom-[12px]",
|
|
9228
|
-
|
|
9229
|
-
disabled ? "cursor-not-allowed" : "",
|
|
9364
|
+
hasInvalidState ? "text-[var(--status-danger)] placeholder:text-[var(--status-danger)]" : "",
|
|
9365
|
+
disabled ? "cursor-not-allowed" : loading ? "cursor-progress" : "",
|
|
9230
9366
|
inputClassName,
|
|
9231
9367
|
className
|
|
9232
9368
|
)
|
|
@@ -9601,6 +9737,9 @@ var SelectTrigger2 = React32.forwardRef(
|
|
|
9601
9737
|
helperText,
|
|
9602
9738
|
valueLabel,
|
|
9603
9739
|
disabled,
|
|
9740
|
+
loading,
|
|
9741
|
+
optional,
|
|
9742
|
+
tooltip,
|
|
9604
9743
|
error,
|
|
9605
9744
|
hideErrorMessage,
|
|
9606
9745
|
labelId,
|
|
@@ -9632,6 +9771,10 @@ var SelectTrigger2 = React32.forwardRef(
|
|
|
9632
9771
|
placeholder: helperText,
|
|
9633
9772
|
describedBy,
|
|
9634
9773
|
error,
|
|
9774
|
+
loading,
|
|
9775
|
+
optional,
|
|
9776
|
+
tooltip,
|
|
9777
|
+
forceLabelText: Boolean(optional) || Boolean(tooltip),
|
|
9635
9778
|
hideErrorMessage,
|
|
9636
9779
|
disabled,
|
|
9637
9780
|
onClick,
|
|
@@ -9998,9 +10141,9 @@ function useSelectIds({ name, hasValue, error, hideErrorMessage }) {
|
|
|
9998
10141
|
}
|
|
9999
10142
|
|
|
10000
10143
|
// src/lib/use-outside-click.ts
|
|
10001
|
-
import { useCallback as useCallback18, useEffect as
|
|
10144
|
+
import { useCallback as useCallback18, useEffect as useEffect17, useRef as useRef16 } from "react";
|
|
10002
10145
|
function useOutsideClick(elementRef, onOutsideClick, nested) {
|
|
10003
|
-
const handleOutsideClick =
|
|
10146
|
+
const handleOutsideClick = useRef16(onOutsideClick);
|
|
10004
10147
|
handleOutsideClick.current = onOutsideClick;
|
|
10005
10148
|
const checkNestedElements = useCallback18(
|
|
10006
10149
|
(event) => {
|
|
@@ -10033,7 +10176,7 @@ function useOutsideClick(elementRef, onOutsideClick, nested) {
|
|
|
10033
10176
|
},
|
|
10034
10177
|
[nested]
|
|
10035
10178
|
);
|
|
10036
|
-
|
|
10179
|
+
useEffect17(() => {
|
|
10037
10180
|
function handleClickOutside(event) {
|
|
10038
10181
|
const isNestedElement = checkNestedElements(event);
|
|
10039
10182
|
if (elementRef?.current && !elementRef.current.contains(event.target) && !isNestedElement) {
|
|
@@ -10051,7 +10194,7 @@ function useOutsideClick(elementRef, onOutsideClick, nested) {
|
|
|
10051
10194
|
|
|
10052
10195
|
// src/airbnb/select/Select.tsx
|
|
10053
10196
|
import { jsx as jsx129, jsxs as jsxs83 } from "react/jsx-runtime";
|
|
10054
|
-
|
|
10197
|
+
var AirbnbSelect = React36.forwardRef(function AirbnbSelect2({
|
|
10055
10198
|
options,
|
|
10056
10199
|
value,
|
|
10057
10200
|
onChange,
|
|
@@ -10062,7 +10205,11 @@ function AirbnbSelect({
|
|
|
10062
10205
|
getValueLabel,
|
|
10063
10206
|
renderTrigger,
|
|
10064
10207
|
disabled,
|
|
10208
|
+
loading,
|
|
10209
|
+
optional,
|
|
10210
|
+
tooltip,
|
|
10065
10211
|
error,
|
|
10212
|
+
invalid,
|
|
10066
10213
|
hideErrorMessage,
|
|
10067
10214
|
className,
|
|
10068
10215
|
menuClassName,
|
|
@@ -10071,12 +10218,14 @@ function AirbnbSelect({
|
|
|
10071
10218
|
mobileTitle,
|
|
10072
10219
|
name,
|
|
10073
10220
|
noOptionsMessage
|
|
10074
|
-
}) {
|
|
10221
|
+
}, ref) {
|
|
10075
10222
|
const { isMatch: isMobile } = useScreenResize(DEVICE.mobileXL);
|
|
10076
10223
|
const [isOpen, setIsOpen] = React36.useState(false);
|
|
10077
10224
|
const containerRef = React36.useRef(null);
|
|
10078
10225
|
const hasValue = Boolean(value);
|
|
10079
10226
|
const helperText = placeholder ?? label;
|
|
10227
|
+
const isBlocked = Boolean(disabled) || Boolean(loading);
|
|
10228
|
+
const triggerError = error ?? invalid;
|
|
10080
10229
|
const {
|
|
10081
10230
|
triggerId,
|
|
10082
10231
|
labelId,
|
|
@@ -10102,14 +10251,14 @@ function AirbnbSelect({
|
|
|
10102
10251
|
isOpen,
|
|
10103
10252
|
options,
|
|
10104
10253
|
value,
|
|
10105
|
-
disabled
|
|
10254
|
+
disabled: isBlocked
|
|
10106
10255
|
});
|
|
10107
10256
|
const {
|
|
10108
10257
|
highlightedIndex,
|
|
10109
10258
|
listRef: desktopListRef,
|
|
10110
10259
|
setHighlightedIndex,
|
|
10111
10260
|
setOptionRef,
|
|
10112
|
-
triggerRef,
|
|
10261
|
+
triggerRef: desktopTriggerRef,
|
|
10113
10262
|
focusTrigger,
|
|
10114
10263
|
handleSelect: handleDesktopSelect,
|
|
10115
10264
|
handleMenuKeyDown,
|
|
@@ -10119,12 +10268,18 @@ function AirbnbSelect({
|
|
|
10119
10268
|
isOpen,
|
|
10120
10269
|
options,
|
|
10121
10270
|
value,
|
|
10122
|
-
disabled,
|
|
10271
|
+
disabled: isBlocked,
|
|
10123
10272
|
onChange
|
|
10124
10273
|
});
|
|
10274
|
+
const combinedRef = useCombinedRef(ref, desktopTriggerRef);
|
|
10125
10275
|
const activeMobileIndex = getOptionIndex(options, pendingValue);
|
|
10126
10276
|
const valueLabel = value ? getValueLabel?.(value) ?? String(value.label) : void 0;
|
|
10127
10277
|
useOutsideClick(containerRef, isOpen && !isMobile ? () => setIsOpen(false) : null);
|
|
10278
|
+
React36.useEffect(() => {
|
|
10279
|
+
if (isBlocked) {
|
|
10280
|
+
setIsOpen(false);
|
|
10281
|
+
}
|
|
10282
|
+
}, [isBlocked]);
|
|
10128
10283
|
React36.useEffect(
|
|
10129
10284
|
function setCorrectOptionIfThereIsOnlyValue() {
|
|
10130
10285
|
if (value?.value === void 0 || value.value === null || value.label !== "") {
|
|
@@ -10139,24 +10294,26 @@ function AirbnbSelect({
|
|
|
10139
10294
|
);
|
|
10140
10295
|
const handleMobileOpenChange = React36.useCallback(
|
|
10141
10296
|
(nextOpen) => {
|
|
10297
|
+
if (isBlocked && nextOpen) return;
|
|
10142
10298
|
setIsOpen(nextOpen);
|
|
10143
10299
|
syncPendingValue(value ?? null);
|
|
10144
10300
|
if (!nextOpen) {
|
|
10145
10301
|
focusTrigger();
|
|
10146
10302
|
}
|
|
10147
10303
|
},
|
|
10148
|
-
[focusTrigger, syncPendingValue, value]
|
|
10304
|
+
[focusTrigger, isBlocked, syncPendingValue, value]
|
|
10149
10305
|
);
|
|
10150
10306
|
const handleMobileDone = React36.useCallback(() => {
|
|
10307
|
+
if (isBlocked) return;
|
|
10151
10308
|
const finalOption = pendingValue;
|
|
10152
10309
|
if (finalOption && finalOption.value !== value?.value) {
|
|
10153
10310
|
onChange(finalOption);
|
|
10154
10311
|
}
|
|
10155
10312
|
setIsOpen(false);
|
|
10156
10313
|
focusTrigger();
|
|
10157
|
-
}, [focusTrigger, onChange, pendingValue, value]);
|
|
10314
|
+
}, [focusTrigger, isBlocked, onChange, pendingValue, value]);
|
|
10158
10315
|
const handleTriggerClick = React36.useCallback(() => {
|
|
10159
|
-
if (
|
|
10316
|
+
if (isBlocked) return;
|
|
10160
10317
|
setIsOpen((prev) => {
|
|
10161
10318
|
const nextOpen = !prev;
|
|
10162
10319
|
if (isMobile) {
|
|
@@ -10164,10 +10321,10 @@ function AirbnbSelect({
|
|
|
10164
10321
|
}
|
|
10165
10322
|
return nextOpen;
|
|
10166
10323
|
});
|
|
10167
|
-
}, [
|
|
10324
|
+
}, [isBlocked, isMobile, syncPendingValue, value]);
|
|
10168
10325
|
const handleRootTriggerKeyDown = (event) => {
|
|
10169
10326
|
if (isMobile) {
|
|
10170
|
-
if (
|
|
10327
|
+
if (isBlocked) return;
|
|
10171
10328
|
if (event.key === "ArrowDown" || event.key === "ArrowUp" || event.key === "Enter" || event.key === " ") {
|
|
10172
10329
|
event.preventDefault();
|
|
10173
10330
|
syncPendingValue(value ?? null);
|
|
@@ -10208,7 +10365,7 @@ function AirbnbSelect({
|
|
|
10208
10365
|
handleMobileOpenChange(false);
|
|
10209
10366
|
}
|
|
10210
10367
|
};
|
|
10211
|
-
return /* @__PURE__ */ jsxs83("div", { ref: containerRef, className: cn("relative w-full max-w-[
|
|
10368
|
+
return /* @__PURE__ */ jsxs83("div", { ref: containerRef, className: cn("relative w-full max-w-[425px]", className), children: [
|
|
10212
10369
|
name && /* @__PURE__ */ jsx129("input", { type: "hidden", name, value: value ? String(value.value) : "" }),
|
|
10213
10370
|
renderTrigger ? renderTrigger({
|
|
10214
10371
|
id: triggerId,
|
|
@@ -10219,18 +10376,22 @@ function AirbnbSelect({
|
|
|
10219
10376
|
helperText,
|
|
10220
10377
|
value,
|
|
10221
10378
|
valueLabel,
|
|
10222
|
-
disabled,
|
|
10379
|
+
disabled: isBlocked,
|
|
10380
|
+
loading,
|
|
10381
|
+
optional,
|
|
10382
|
+
tooltip,
|
|
10223
10383
|
error,
|
|
10384
|
+
invalid,
|
|
10224
10385
|
listboxId,
|
|
10225
10386
|
describedBy,
|
|
10226
|
-
triggerRef,
|
|
10387
|
+
triggerRef: combinedRef,
|
|
10227
10388
|
onClick: handleTriggerClick,
|
|
10228
10389
|
onKeyDown: handleRootTriggerKeyDown
|
|
10229
10390
|
}) : /* @__PURE__ */ jsx129(
|
|
10230
10391
|
SelectTrigger2,
|
|
10231
10392
|
{
|
|
10232
10393
|
id: triggerId,
|
|
10233
|
-
ref:
|
|
10394
|
+
ref: combinedRef,
|
|
10234
10395
|
open: isOpen,
|
|
10235
10396
|
variant,
|
|
10236
10397
|
label,
|
|
@@ -10238,7 +10399,10 @@ function AirbnbSelect({
|
|
|
10238
10399
|
helperText,
|
|
10239
10400
|
valueLabel,
|
|
10240
10401
|
disabled,
|
|
10241
|
-
|
|
10402
|
+
loading,
|
|
10403
|
+
optional,
|
|
10404
|
+
tooltip,
|
|
10405
|
+
error: triggerError,
|
|
10242
10406
|
hideErrorMessage,
|
|
10243
10407
|
labelId,
|
|
10244
10408
|
valueId,
|
|
@@ -10263,7 +10427,7 @@ function AirbnbSelect({
|
|
|
10263
10427
|
doneLabel,
|
|
10264
10428
|
errorId: describedErrorId,
|
|
10265
10429
|
options,
|
|
10266
|
-
disabled,
|
|
10430
|
+
disabled: isBlocked,
|
|
10267
10431
|
menuClassName,
|
|
10268
10432
|
scrollTop: mobileScrollTop,
|
|
10269
10433
|
activeIndex: activeMobileIndex,
|
|
@@ -10294,7 +10458,7 @@ function AirbnbSelect({
|
|
|
10294
10458
|
onKeyDown: (event) => {
|
|
10295
10459
|
handleMenuKeyDown(event, () => setIsOpen(false));
|
|
10296
10460
|
},
|
|
10297
|
-
disabled,
|
|
10461
|
+
disabled: isBlocked,
|
|
10298
10462
|
menuClassName,
|
|
10299
10463
|
dropdownClassName,
|
|
10300
10464
|
listRef: desktopListRef,
|
|
@@ -10304,168 +10468,189 @@ function AirbnbSelect({
|
|
|
10304
10468
|
}
|
|
10305
10469
|
)
|
|
10306
10470
|
] });
|
|
10307
|
-
}
|
|
10471
|
+
});
|
|
10308
10472
|
|
|
10309
10473
|
// src/airbnb/phone-field/PhoneField.tsx
|
|
10310
10474
|
import { jsx as jsx130, jsxs as jsxs84 } from "react/jsx-runtime";
|
|
10311
|
-
|
|
10312
|
-
|
|
10313
|
-
|
|
10314
|
-
|
|
10315
|
-
|
|
10316
|
-
|
|
10317
|
-
|
|
10318
|
-
|
|
10319
|
-
|
|
10320
|
-
|
|
10321
|
-
|
|
10322
|
-
|
|
10323
|
-
|
|
10324
|
-
|
|
10325
|
-
|
|
10326
|
-
|
|
10327
|
-
|
|
10328
|
-
|
|
10329
|
-
|
|
10330
|
-
|
|
10331
|
-
|
|
10332
|
-
|
|
10333
|
-
|
|
10334
|
-
|
|
10335
|
-
|
|
10336
|
-
|
|
10337
|
-
|
|
10338
|
-
|
|
10339
|
-
|
|
10340
|
-
|
|
10341
|
-
|
|
10342
|
-
|
|
10343
|
-
|
|
10344
|
-
|
|
10345
|
-
|
|
10346
|
-
|
|
10347
|
-
|
|
10348
|
-
|
|
10349
|
-
|
|
10350
|
-
|
|
10351
|
-
|
|
10352
|
-
|
|
10353
|
-
|
|
10354
|
-
|
|
10355
|
-
{
|
|
10356
|
-
type: "hidden",
|
|
10357
|
-
name: numberName,
|
|
10358
|
-
value: value?.number ?? "",
|
|
10359
|
-
disabled
|
|
10360
|
-
}
|
|
10361
|
-
),
|
|
10362
|
-
topLabel && /* @__PURE__ */ jsx130(
|
|
10363
|
-
"label",
|
|
10364
|
-
{
|
|
10365
|
-
htmlFor: inputId,
|
|
10366
|
-
className: "mb-3 block text-[16px] font-medium leading-5 text-[#1F1F1B]",
|
|
10367
|
-
children: topLabel
|
|
10368
|
-
}
|
|
10369
|
-
),
|
|
10370
|
-
/* @__PURE__ */ jsxs84("div", { className: "flex items-stretch", children: [
|
|
10371
|
-
/* @__PURE__ */ jsx130(
|
|
10372
|
-
AirbnbSelect,
|
|
10475
|
+
var PhoneField = React37.forwardRef(
|
|
10476
|
+
({
|
|
10477
|
+
variant = "default",
|
|
10478
|
+
label,
|
|
10479
|
+
topLabel,
|
|
10480
|
+
value,
|
|
10481
|
+
onChange,
|
|
10482
|
+
options,
|
|
10483
|
+
placeholder = "Phone number",
|
|
10484
|
+
disabled,
|
|
10485
|
+
codeReadOnly,
|
|
10486
|
+
error,
|
|
10487
|
+
invalid,
|
|
10488
|
+
loading,
|
|
10489
|
+
optional,
|
|
10490
|
+
tooltip,
|
|
10491
|
+
className,
|
|
10492
|
+
name,
|
|
10493
|
+
codeName,
|
|
10494
|
+
numberName,
|
|
10495
|
+
mobileTitle,
|
|
10496
|
+
codePlaceholder = "+00"
|
|
10497
|
+
}, ref) => {
|
|
10498
|
+
const inputId = React37.useId();
|
|
10499
|
+
const codeOptions = React37.useMemo(
|
|
10500
|
+
() => options.map((option) => ({
|
|
10501
|
+
value: option.value,
|
|
10502
|
+
label: option.label,
|
|
10503
|
+
disabled: option.disabled
|
|
10504
|
+
})),
|
|
10505
|
+
[options]
|
|
10506
|
+
);
|
|
10507
|
+
const selectedCodeOption = React37.useMemo(
|
|
10508
|
+
() => codeOptions.find((option) => option.value === value?.code) ?? null,
|
|
10509
|
+
[codeOptions, value?.code]
|
|
10510
|
+
);
|
|
10511
|
+
const combinedValue = value?.code || value?.number ? `${value?.code ?? ""}${value?.number ?? ""}` : "";
|
|
10512
|
+
const hasInvalidState = Boolean(error) || Boolean(invalid);
|
|
10513
|
+
const isBlocked = Boolean(disabled) || Boolean(loading);
|
|
10514
|
+
const isCodeBlocked = isBlocked || Boolean(codeReadOnly);
|
|
10515
|
+
return /* @__PURE__ */ jsxs84("div", { className: cn("w-full max-w-[425px]", className), children: [
|
|
10516
|
+
name && /* @__PURE__ */ jsx130("input", { type: "hidden", name, value: combinedValue, disabled }),
|
|
10517
|
+
codeName && /* @__PURE__ */ jsx130(
|
|
10518
|
+
"input",
|
|
10373
10519
|
{
|
|
10374
|
-
|
|
10375
|
-
|
|
10376
|
-
value:
|
|
10377
|
-
|
|
10378
|
-
code: String(option.value),
|
|
10379
|
-
number: value?.number ?? ""
|
|
10380
|
-
}),
|
|
10381
|
-
label: `${label} country code`,
|
|
10382
|
-
placeholder: codePlaceholder,
|
|
10383
|
-
disabled,
|
|
10384
|
-
className: "max-w-none shrink-0 basis-[96px]",
|
|
10385
|
-
mobileTitle: mobileTitle ?? "Select country code",
|
|
10386
|
-
dropdownClassName: "right-auto w-[280px]",
|
|
10387
|
-
getValueLabel: (option) => String(option.value),
|
|
10388
|
-
renderTrigger: ({
|
|
10389
|
-
id,
|
|
10390
|
-
open,
|
|
10391
|
-
variant: selectVariant,
|
|
10392
|
-
disabled: triggerDisabled,
|
|
10393
|
-
listboxId,
|
|
10394
|
-
triggerRef,
|
|
10395
|
-
onClick,
|
|
10396
|
-
onKeyDown,
|
|
10397
|
-
valueLabel
|
|
10398
|
-
}) => /* @__PURE__ */ jsxs84(
|
|
10399
|
-
"button",
|
|
10400
|
-
{
|
|
10401
|
-
id,
|
|
10402
|
-
ref: triggerRef,
|
|
10403
|
-
type: "button",
|
|
10404
|
-
"aria-label": `${label} country code`,
|
|
10405
|
-
"aria-haspopup": "listbox",
|
|
10406
|
-
"aria-expanded": open,
|
|
10407
|
-
"aria-controls": listboxId,
|
|
10408
|
-
disabled: triggerDisabled,
|
|
10409
|
-
onClick,
|
|
10410
|
-
onKeyDown,
|
|
10411
|
-
className: cn(
|
|
10412
|
-
"flex w-full items-center justify-center gap-2 border border-r-0 text-[16px] font-medium leading-6 transition-colors focus-visible:outline-none",
|
|
10413
|
-
selectVariant === "airbnb" ? "h-full min-h-[60px] rounded-l-[16px] rounded-r-none px-4 focus-visible:ring-2 focus-visible:ring-[#1F1F1B] focus-visible:ring-offset-2" : "min-h-[48px] rounded-l-[10px] rounded-r-none px-3.5 focus-visible:border-[#315EFB]",
|
|
10414
|
-
error ? "border-[var(--status-danger)] bg-[#F2F2F2] text-[var(--status-danger)]" : selectVariant === "airbnb" ? "border-[#8C8C8C] bg-[#F4F4F2] text-[#1F1F1B]" : "border-[#A8A8A4] bg-white text-[#1F1F1B]",
|
|
10415
|
-
triggerDisabled ? "cursor-not-allowed opacity-50" : "cursor-pointer"
|
|
10416
|
-
),
|
|
10417
|
-
children: [
|
|
10418
|
-
/* @__PURE__ */ jsx130("span", { children: valueLabel ?? codePlaceholder }),
|
|
10419
|
-
/* @__PURE__ */ jsx130(
|
|
10420
|
-
ChevronDown2,
|
|
10421
|
-
{
|
|
10422
|
-
className: cn("h-5 w-5 transition-transform", open ? "rotate-180" : ""),
|
|
10423
|
-
strokeWidth: 2
|
|
10424
|
-
}
|
|
10425
|
-
)
|
|
10426
|
-
]
|
|
10427
|
-
}
|
|
10428
|
-
)
|
|
10520
|
+
type: "hidden",
|
|
10521
|
+
name: codeName,
|
|
10522
|
+
value: value?.code ?? "",
|
|
10523
|
+
disabled
|
|
10429
10524
|
}
|
|
10430
10525
|
),
|
|
10431
|
-
/* @__PURE__ */ jsx130(
|
|
10432
|
-
|
|
10526
|
+
numberName && /* @__PURE__ */ jsx130(
|
|
10527
|
+
"input",
|
|
10433
10528
|
{
|
|
10434
|
-
|
|
10435
|
-
|
|
10436
|
-
type: "tel",
|
|
10437
|
-
inputMode: "tel",
|
|
10438
|
-
label,
|
|
10439
|
-
helperText: placeholder,
|
|
10529
|
+
type: "hidden",
|
|
10530
|
+
name: numberName,
|
|
10440
10531
|
value: value?.number ?? "",
|
|
10441
|
-
|
|
10442
|
-
disabled,
|
|
10443
|
-
error,
|
|
10444
|
-
renderErrorMessage: false,
|
|
10445
|
-
wrapperClassName: "min-w-0 flex-1",
|
|
10446
|
-
fieldClassName: cn(
|
|
10447
|
-
variant === "airbnb" ? "min-h-[60px] rounded-l-none rounded-r-[16px] border-l-0" : "rounded-l-none rounded-r-[10px] border-l-0"
|
|
10448
|
-
),
|
|
10449
|
-
contentClassName: cn(variant === "airbnb" ? "h-[40px] py-2" : "h-[48px]"),
|
|
10450
|
-
inputClassName: "text-[16px] leading-7",
|
|
10451
|
-
onChange: (event) => onChange({
|
|
10452
|
-
code: value?.code ?? "",
|
|
10453
|
-
number: event.target.value
|
|
10454
|
-
})
|
|
10532
|
+
disabled
|
|
10455
10533
|
}
|
|
10456
|
-
)
|
|
10457
|
-
|
|
10458
|
-
|
|
10459
|
-
|
|
10460
|
-
|
|
10534
|
+
),
|
|
10535
|
+
topLabel && /* @__PURE__ */ jsx130(
|
|
10536
|
+
"label",
|
|
10537
|
+
{
|
|
10538
|
+
htmlFor: inputId,
|
|
10539
|
+
className: "mb-3 block text-[16px] font-medium leading-5 text-[#1F1F1B]",
|
|
10540
|
+
children: topLabel
|
|
10541
|
+
}
|
|
10542
|
+
),
|
|
10543
|
+
/* @__PURE__ */ jsxs84("div", { className: "flex items-stretch", children: [
|
|
10544
|
+
/* @__PURE__ */ jsx130(
|
|
10545
|
+
AirbnbSelect,
|
|
10546
|
+
{
|
|
10547
|
+
ref,
|
|
10548
|
+
variant,
|
|
10549
|
+
options: codeOptions,
|
|
10550
|
+
value: selectedCodeOption,
|
|
10551
|
+
onChange: (option) => onChange({
|
|
10552
|
+
code: String(option.value),
|
|
10553
|
+
number: value?.number ?? ""
|
|
10554
|
+
}),
|
|
10555
|
+
label: `${label} country code`,
|
|
10556
|
+
placeholder: codePlaceholder,
|
|
10557
|
+
disabled: isCodeBlocked,
|
|
10558
|
+
loading,
|
|
10559
|
+
invalid,
|
|
10560
|
+
className: "max-w-none shrink-0 basis-[96px]",
|
|
10561
|
+
mobileTitle: mobileTitle ?? "Select country code",
|
|
10562
|
+
dropdownClassName: "right-auto w-[280px]",
|
|
10563
|
+
getValueLabel: (option) => String(option.value),
|
|
10564
|
+
renderTrigger: ({
|
|
10565
|
+
id,
|
|
10566
|
+
open,
|
|
10567
|
+
variant: selectVariant,
|
|
10568
|
+
disabled: triggerDisabled,
|
|
10569
|
+
loading: triggerLoading,
|
|
10570
|
+
listboxId,
|
|
10571
|
+
triggerRef,
|
|
10572
|
+
onClick,
|
|
10573
|
+
onKeyDown,
|
|
10574
|
+
valueLabel
|
|
10575
|
+
}) => /* @__PURE__ */ jsxs84(
|
|
10576
|
+
"button",
|
|
10577
|
+
{
|
|
10578
|
+
id,
|
|
10579
|
+
ref: triggerRef,
|
|
10580
|
+
type: "button",
|
|
10581
|
+
"aria-label": `${label} country code`,
|
|
10582
|
+
"aria-haspopup": "listbox",
|
|
10583
|
+
"aria-expanded": open,
|
|
10584
|
+
"aria-controls": listboxId,
|
|
10585
|
+
"aria-busy": triggerLoading,
|
|
10586
|
+
"aria-invalid": hasInvalidState,
|
|
10587
|
+
disabled: triggerDisabled,
|
|
10588
|
+
onClick,
|
|
10589
|
+
onKeyDown,
|
|
10590
|
+
className: cn(
|
|
10591
|
+
"flex w-full items-center justify-center gap-2 border border-r-0 text-[16px] font-medium leading-6 transition-colors focus-visible:outline-none",
|
|
10592
|
+
selectVariant === "airbnb" ? "h-full min-h-[60px] rounded-l-[16px] rounded-r-none px-4 focus-visible:ring-2 focus-visible:ring-[#1F1F1B] focus-visible:ring-offset-2" : "min-h-[48px] rounded-l-[10px] rounded-r-none px-3.5 focus-visible:border-[#315EFB]",
|
|
10593
|
+
hasInvalidState ? "border-[var(--status-danger)] bg-[#F2F2F2] text-[var(--status-danger)]" : selectVariant === "airbnb" ? "border-[#8C8C8C] bg-[#F4F4F2] text-[#1F1F1B]" : "border-[#A8A8A4] bg-white text-[#1F1F1B]",
|
|
10594
|
+
triggerDisabled ? "cursor-not-allowed opacity-50" : triggerLoading ? "cursor-progress" : "cursor-pointer"
|
|
10595
|
+
),
|
|
10596
|
+
children: [
|
|
10597
|
+
/* @__PURE__ */ jsx130("span", { children: valueLabel ?? codePlaceholder }),
|
|
10598
|
+
/* @__PURE__ */ jsx130(
|
|
10599
|
+
ChevronDown2,
|
|
10600
|
+
{
|
|
10601
|
+
className: cn("h-5 w-5 transition-transform", open ? "rotate-180" : ""),
|
|
10602
|
+
strokeWidth: 2
|
|
10603
|
+
}
|
|
10604
|
+
)
|
|
10605
|
+
]
|
|
10606
|
+
}
|
|
10607
|
+
)
|
|
10608
|
+
}
|
|
10609
|
+
),
|
|
10610
|
+
/* @__PURE__ */ jsx130(
|
|
10611
|
+
AirbnbInput,
|
|
10612
|
+
{
|
|
10613
|
+
id: inputId,
|
|
10614
|
+
variant,
|
|
10615
|
+
type: "tel",
|
|
10616
|
+
inputMode: "tel",
|
|
10617
|
+
label,
|
|
10618
|
+
helperText: placeholder,
|
|
10619
|
+
value: value?.number ?? "",
|
|
10620
|
+
placeholder,
|
|
10621
|
+
disabled,
|
|
10622
|
+
error,
|
|
10623
|
+
invalid,
|
|
10624
|
+
loading,
|
|
10625
|
+
optional,
|
|
10626
|
+
tooltip,
|
|
10627
|
+
renderErrorMessage: false,
|
|
10628
|
+
wrapperClassName: "min-w-0 flex-1",
|
|
10629
|
+
fieldClassName: cn(
|
|
10630
|
+
variant === "airbnb" ? "min-h-[60px] rounded-l-none rounded-r-[16px] border-l-0" : "rounded-l-none rounded-r-[10px] border-l-0"
|
|
10631
|
+
),
|
|
10632
|
+
contentClassName: cn(variant === "airbnb" ? "h-[40px] py-2" : "h-[48px]"),
|
|
10633
|
+
inputClassName: "text-[16px] leading-7",
|
|
10634
|
+
onChange: (event) => onChange({
|
|
10635
|
+
code: value?.code ?? "",
|
|
10636
|
+
number: event.target.value
|
|
10637
|
+
})
|
|
10638
|
+
}
|
|
10639
|
+
)
|
|
10640
|
+
] }),
|
|
10641
|
+
error && /* @__PURE__ */ jsx130(FieldErrorMessage, { message: error })
|
|
10642
|
+
] });
|
|
10643
|
+
}
|
|
10644
|
+
);
|
|
10645
|
+
PhoneField.displayName = "PhoneField";
|
|
10461
10646
|
|
|
10462
10647
|
// src/airbnb/search-input/SearchInput.tsx
|
|
10463
10648
|
import * as React38 from "react";
|
|
10464
|
-
import { useTranslation as
|
|
10649
|
+
import { useTranslation as useTranslation23 } from "react-i18next";
|
|
10465
10650
|
import { Search as Search3, X as X8 } from "lucide-react";
|
|
10466
10651
|
import { jsx as jsx131, jsxs as jsxs85 } from "react/jsx-runtime";
|
|
10467
10652
|
var AirbnbSearchInput = React38.forwardRef(({ onReset, placeholder, wrapperClassName, ...props }, ref) => {
|
|
10468
|
-
const { t } =
|
|
10653
|
+
const { t } = useTranslation23();
|
|
10469
10654
|
const placeholderText = placeholder || t("search_property") + "...";
|
|
10470
10655
|
return /* @__PURE__ */ jsxs85("div", { className: cn("input-wrapper relative", wrapperClassName), children: [
|
|
10471
10656
|
/* @__PURE__ */ jsx131(Search3, { className: "absolute left-4 top-1/2 h-5 w-5 -translate-y-1/2 transform text-[#9696B9]" }),
|
|
@@ -10533,6 +10718,9 @@ var SearchableSelectInternal = ({
|
|
|
10533
10718
|
getValueLabel,
|
|
10534
10719
|
disabled,
|
|
10535
10720
|
error,
|
|
10721
|
+
invalid,
|
|
10722
|
+
optional,
|
|
10723
|
+
tooltip,
|
|
10536
10724
|
hideErrorMessage,
|
|
10537
10725
|
name,
|
|
10538
10726
|
className,
|
|
@@ -10569,10 +10757,16 @@ var SearchableSelectInternal = ({
|
|
|
10569
10757
|
);
|
|
10570
10758
|
const helperText = placeholder ?? label;
|
|
10571
10759
|
const valueLabel = value ? getValueLabel?.(value) ?? String(value.label) : void 0;
|
|
10760
|
+
const isBlocked = Boolean(disabled) || Boolean(loading);
|
|
10761
|
+
const triggerError = error ?? invalid;
|
|
10572
10762
|
const describedBy = error && !hideErrorMessage ? errorId : void 0;
|
|
10573
10763
|
const activeOptionId = highlightedIndex >= 0 ? getOptionId(reactId, highlightedIndex) : void 0;
|
|
10574
10764
|
useOutsideClick(containerRef, open && !isMobile ? () => closeSelect() : null);
|
|
10575
10765
|
React39.useEffect(() => {
|
|
10766
|
+
if (isBlocked) {
|
|
10767
|
+
setSelectOpen(false);
|
|
10768
|
+
return;
|
|
10769
|
+
}
|
|
10576
10770
|
if (!open) return;
|
|
10577
10771
|
const frameId = window.requestAnimationFrame(() => {
|
|
10578
10772
|
inputRef.current?.focus();
|
|
@@ -10580,7 +10774,7 @@ var SearchableSelectInternal = ({
|
|
|
10580
10774
|
return () => {
|
|
10581
10775
|
window.cancelAnimationFrame(frameId);
|
|
10582
10776
|
};
|
|
10583
|
-
}, [open]);
|
|
10777
|
+
}, [isBlocked, open]);
|
|
10584
10778
|
React39.useEffect(() => {
|
|
10585
10779
|
if (!open) {
|
|
10586
10780
|
setHighlightedIndex(-1);
|
|
@@ -10601,7 +10795,7 @@ var SearchableSelectInternal = ({
|
|
|
10601
10795
|
}
|
|
10602
10796
|
}
|
|
10603
10797
|
function openSelect() {
|
|
10604
|
-
if (
|
|
10798
|
+
if (isBlocked) return;
|
|
10605
10799
|
setSelectOpen(true);
|
|
10606
10800
|
}
|
|
10607
10801
|
function closeSelect() {
|
|
@@ -10614,7 +10808,7 @@ var SearchableSelectInternal = ({
|
|
|
10614
10808
|
onSearchChange?.(nextValue);
|
|
10615
10809
|
}
|
|
10616
10810
|
function handleSelect(option) {
|
|
10617
|
-
if (
|
|
10811
|
+
if (isBlocked || option.isDisabled) return;
|
|
10618
10812
|
onChange(option);
|
|
10619
10813
|
setSelectOpen(false, { restoreFocus: true });
|
|
10620
10814
|
}
|
|
@@ -10626,7 +10820,7 @@ var SearchableSelectInternal = ({
|
|
|
10626
10820
|
}
|
|
10627
10821
|
}
|
|
10628
10822
|
function handleTriggerKeyDown(event) {
|
|
10629
|
-
if (
|
|
10823
|
+
if (isBlocked) return;
|
|
10630
10824
|
if (event.key === "Enter" || event.key === " " || event.key === "ArrowDown" || event.key === "ArrowUp") {
|
|
10631
10825
|
event.preventDefault();
|
|
10632
10826
|
openSelect();
|
|
@@ -10684,7 +10878,7 @@ var SearchableSelectInternal = ({
|
|
|
10684
10878
|
}
|
|
10685
10879
|
);
|
|
10686
10880
|
React39.useImperativeHandle(ref, () => triggerRef.current, []);
|
|
10687
|
-
return /* @__PURE__ */ jsxs86("div", { ref: containerRef, className: cn("relative w-full max-w-[
|
|
10881
|
+
return /* @__PURE__ */ jsxs86("div", { ref: containerRef, className: cn("relative w-full max-w-[425px]", className), children: [
|
|
10688
10882
|
name && /* @__PURE__ */ jsx132("input", { type: "hidden", name, value: value ? String(value.value) : "" }),
|
|
10689
10883
|
/* @__PURE__ */ jsx132(
|
|
10690
10884
|
FieldTrigger,
|
|
@@ -10705,7 +10899,11 @@ var SearchableSelectInternal = ({
|
|
|
10705
10899
|
valueText: valueLabel,
|
|
10706
10900
|
placeholder: helperText,
|
|
10707
10901
|
describedBy,
|
|
10708
|
-
error,
|
|
10902
|
+
error: triggerError,
|
|
10903
|
+
loading,
|
|
10904
|
+
optional,
|
|
10905
|
+
tooltip,
|
|
10906
|
+
forceLabelText: Boolean(optional) || Boolean(tooltip),
|
|
10709
10907
|
hideErrorMessage,
|
|
10710
10908
|
disabled,
|
|
10711
10909
|
onClick: () => {
|
|
@@ -10732,6 +10930,7 @@ var SearchableSelectInternal = ({
|
|
|
10732
10930
|
{
|
|
10733
10931
|
open,
|
|
10734
10932
|
onOpenChange: (nextOpen) => {
|
|
10933
|
+
if (isBlocked && nextOpen) return;
|
|
10735
10934
|
if (nextOpen) {
|
|
10736
10935
|
setSelectOpen(true);
|
|
10737
10936
|
return;
|