@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.cjs
CHANGED
|
@@ -3593,27 +3593,31 @@ function HelpTooltip({
|
|
|
3593
3593
|
className,
|
|
3594
3594
|
contentClassName,
|
|
3595
3595
|
size = 16,
|
|
3596
|
-
label = "More info"
|
|
3596
|
+
label = "More info",
|
|
3597
|
+
triggerAs = "button"
|
|
3597
3598
|
}) {
|
|
3599
|
+
const triggerClassName = cn(
|
|
3600
|
+
"relative flex shrink-0 cursor-help items-center justify-center rounded-full",
|
|
3601
|
+
"text-chekin-gray-2 outline-none transition-colors hover:text-chekin-blue",
|
|
3602
|
+
triggerAs === "button" && "focus-visible:shadow-chekin-focus",
|
|
3603
|
+
className
|
|
3604
|
+
);
|
|
3605
|
+
const triggerStyle = { width: size, height: size };
|
|
3606
|
+
const triggerContent = /* @__PURE__ */ (0, import_jsx_runtime57.jsxs)(import_jsx_runtime57.Fragment, { children: [
|
|
3607
|
+
/* @__PURE__ */ (0, import_jsx_runtime57.jsx)(import_lucide_react16.CircleQuestionMark, { "aria-hidden": "true", style: { width: size, height: size } }),
|
|
3608
|
+
/* @__PURE__ */ (0, import_jsx_runtime57.jsx)("span", { className: "absolute -left-0.5 -top-0.5 h-5 w-5" })
|
|
3609
|
+
] });
|
|
3598
3610
|
return /* @__PURE__ */ (0, import_jsx_runtime57.jsx)(TooltipProvider, { children: /* @__PURE__ */ (0, import_jsx_runtime57.jsxs)(TooltipRoot, { children: [
|
|
3599
|
-
/* @__PURE__ */ (0, import_jsx_runtime57.jsx)(TooltipTrigger, { asChild: true, onClick, children: /* @__PURE__ */ (0, import_jsx_runtime57.
|
|
3611
|
+
/* @__PURE__ */ (0, import_jsx_runtime57.jsx)(TooltipTrigger, { asChild: true, onClick, children: triggerAs === "button" ? /* @__PURE__ */ (0, import_jsx_runtime57.jsx)(
|
|
3600
3612
|
"button",
|
|
3601
3613
|
{
|
|
3602
3614
|
type: "button",
|
|
3603
3615
|
"aria-label": label,
|
|
3604
|
-
className:
|
|
3605
|
-
|
|
3606
|
-
|
|
3607
|
-
"focus-visible:shadow-chekin-focus",
|
|
3608
|
-
className
|
|
3609
|
-
),
|
|
3610
|
-
style: { width: size, height: size },
|
|
3611
|
-
children: [
|
|
3612
|
-
/* @__PURE__ */ (0, import_jsx_runtime57.jsx)(import_lucide_react16.CircleQuestionMark, { "aria-hidden": "true", style: { width: size, height: size } }),
|
|
3613
|
-
/* @__PURE__ */ (0, import_jsx_runtime57.jsx)("span", { className: "absolute -left-0.5 -top-0.5 h-5 w-5" })
|
|
3614
|
-
]
|
|
3616
|
+
className: triggerClassName,
|
|
3617
|
+
style: triggerStyle,
|
|
3618
|
+
children: triggerContent
|
|
3615
3619
|
}
|
|
3616
|
-
) }),
|
|
3620
|
+
) : /* @__PURE__ */ (0, import_jsx_runtime57.jsx)("span", { "aria-label": label, className: triggerClassName, style: triggerStyle, children: triggerContent }) }),
|
|
3617
3621
|
/* @__PURE__ */ (0, import_jsx_runtime57.jsx)(
|
|
3618
3622
|
TooltipContent,
|
|
3619
3623
|
{
|
|
@@ -5303,37 +5307,42 @@ var SelectLabel = React19.forwardRef(({ className, ...props }, ref) => /* @__PUR
|
|
|
5303
5307
|
}
|
|
5304
5308
|
));
|
|
5305
5309
|
SelectLabel.displayName = "SelectLabel";
|
|
5306
|
-
var Select = (
|
|
5307
|
-
|
|
5308
|
-
|
|
5309
|
-
|
|
5310
|
-
|
|
5311
|
-
|
|
5312
|
-
|
|
5313
|
-
|
|
5314
|
-
|
|
5315
|
-
|
|
5316
|
-
|
|
5317
|
-
|
|
5318
|
-
|
|
5319
|
-
|
|
5320
|
-
|
|
5321
|
-
|
|
5322
|
-
|
|
5323
|
-
|
|
5324
|
-
|
|
5325
|
-
|
|
5326
|
-
|
|
5327
|
-
|
|
5328
|
-
|
|
5329
|
-
|
|
5330
|
-
|
|
5331
|
-
|
|
5332
|
-
|
|
5333
|
-
|
|
5334
|
-
|
|
5335
|
-
|
|
5336
|
-
}
|
|
5310
|
+
var Select = React19.forwardRef(
|
|
5311
|
+
({
|
|
5312
|
+
placeholder,
|
|
5313
|
+
label,
|
|
5314
|
+
supportingText,
|
|
5315
|
+
errorText,
|
|
5316
|
+
containerClassName,
|
|
5317
|
+
triggerClassName,
|
|
5318
|
+
children,
|
|
5319
|
+
...props
|
|
5320
|
+
}, ref) => {
|
|
5321
|
+
const reactId = React19.useId();
|
|
5322
|
+
const triggerId = props.name ?? reactId;
|
|
5323
|
+
const internalRef = React19.useRef(null);
|
|
5324
|
+
const combinedRef = useCombinedRef(ref, internalRef);
|
|
5325
|
+
return /* @__PURE__ */ (0, import_jsx_runtime76.jsxs)("div", { className: cn("flex flex-col gap-chekin-1 w-[300px]", containerClassName), children: [
|
|
5326
|
+
label && /* @__PURE__ */ (0, import_jsx_runtime76.jsx)(
|
|
5327
|
+
"label",
|
|
5328
|
+
{
|
|
5329
|
+
htmlFor: triggerId,
|
|
5330
|
+
className: "text-chekin-navy font-sans font-medium text-[14px] leading-5",
|
|
5331
|
+
children: label
|
|
5332
|
+
}
|
|
5333
|
+
),
|
|
5334
|
+
/* @__PURE__ */ (0, import_jsx_runtime76.jsxs)(SelectRoot, { ...props, children: [
|
|
5335
|
+
/* @__PURE__ */ (0, import_jsx_runtime76.jsx)(SelectTrigger, { ref: combinedRef, id: triggerId, className: triggerClassName, children: /* @__PURE__ */ (0, import_jsx_runtime76.jsx)(RadixSelect.Value, { placeholder }) }),
|
|
5336
|
+
/* @__PURE__ */ (0, import_jsx_runtime76.jsx)(SelectContent, { children })
|
|
5337
|
+
] }),
|
|
5338
|
+
/* @__PURE__ */ (0, import_jsx_runtime76.jsxs)("div", { className: "flex justify-between min-h-[15px]", children: [
|
|
5339
|
+
supportingText && !errorText && /* @__PURE__ */ (0, import_jsx_runtime76.jsx)("span", { className: "text-chekin-gray-2 font-sans italic text-[12px] leading-[15px]", children: supportingText }),
|
|
5340
|
+
errorText && /* @__PURE__ */ (0, import_jsx_runtime76.jsx)("span", { className: "ml-auto text-chekin-red font-sans font-medium text-[12px] leading-4 text-right", children: errorText })
|
|
5341
|
+
] })
|
|
5342
|
+
] });
|
|
5343
|
+
}
|
|
5344
|
+
);
|
|
5345
|
+
Select.displayName = "Select";
|
|
5337
5346
|
|
|
5338
5347
|
// src/pagination/Pagination.tsx
|
|
5339
5348
|
var import_jsx_runtime77 = require("react/jsx-runtime");
|
|
@@ -5843,38 +5852,70 @@ var import_lucide_react30 = require("lucide-react");
|
|
|
5843
5852
|
var import_react_i18next18 = require("react-i18next");
|
|
5844
5853
|
var import_jsx_runtime87 = require("react/jsx-runtime");
|
|
5845
5854
|
function SearchInput({
|
|
5855
|
+
disabled,
|
|
5856
|
+
invalid,
|
|
5857
|
+
label,
|
|
5858
|
+
loading,
|
|
5846
5859
|
onReset,
|
|
5860
|
+
optional,
|
|
5847
5861
|
placeholder,
|
|
5862
|
+
tooltip,
|
|
5848
5863
|
wrapperClassName,
|
|
5849
5864
|
className,
|
|
5850
5865
|
...props
|
|
5851
5866
|
}) {
|
|
5852
5867
|
const { t } = (0, import_react_i18next18.useTranslation)();
|
|
5853
5868
|
const placeholderText = placeholder || `${t("search_property")}...`;
|
|
5854
|
-
|
|
5855
|
-
|
|
5856
|
-
|
|
5857
|
-
|
|
5858
|
-
|
|
5859
|
-
|
|
5860
|
-
|
|
5861
|
-
|
|
5862
|
-
|
|
5863
|
-
|
|
5864
|
-
|
|
5869
|
+
const isBlocked = Boolean(disabled) || Boolean(loading);
|
|
5870
|
+
const optionalLabel = optional ? typeof optional === "string" ? optional : t("optional") : void 0;
|
|
5871
|
+
const hasLabelMeta = Boolean(optionalLabel) || Boolean(tooltip);
|
|
5872
|
+
return /* @__PURE__ */ (0, import_jsx_runtime87.jsxs)("div", { className: cn("input-wrapper", wrapperClassName), children: [
|
|
5873
|
+
(label || hasLabelMeta) && /* @__PURE__ */ (0, import_jsx_runtime87.jsxs)("div", { className: "mb-2 inline-flex max-w-full items-center gap-1.5 text-sm font-medium text-chekin-navy", children: [
|
|
5874
|
+
label && /* @__PURE__ */ (0, import_jsx_runtime87.jsx)("span", { className: "min-w-0 truncate", children: label }),
|
|
5875
|
+
optionalLabel && /* @__PURE__ */ (0, import_jsx_runtime87.jsx)("span", { className: "shrink-0 text-xs font-normal text-chekin-gray-2", children: optionalLabel }),
|
|
5876
|
+
tooltip && /* @__PURE__ */ (0, import_jsx_runtime87.jsx)(HelpTooltip, { content: tooltip, side: "top", size: 16 })
|
|
5877
|
+
] }),
|
|
5878
|
+
/* @__PURE__ */ (0, import_jsx_runtime87.jsxs)("div", { className: "relative", children: [
|
|
5879
|
+
/* @__PURE__ */ (0, import_jsx_runtime87.jsx)(import_lucide_react30.Search, { className: "absolute left-4 top-1/2 h-5 w-5 -translate-y-1/2 text-chekin-gray-2" }),
|
|
5880
|
+
/* @__PURE__ */ (0, import_jsx_runtime87.jsx)(
|
|
5881
|
+
Input,
|
|
5882
|
+
{
|
|
5883
|
+
...props,
|
|
5884
|
+
type: "text",
|
|
5885
|
+
disabled: isBlocked,
|
|
5886
|
+
placeholder: placeholderText,
|
|
5887
|
+
"aria-busy": loading,
|
|
5888
|
+
"aria-invalid": invalid,
|
|
5889
|
+
className: cn(
|
|
5890
|
+
"w-full py-3 pl-12 pr-10 text-base text-chekin-navy focus:border-chekin-gray-3",
|
|
5891
|
+
(loading || onReset) && "pr-20",
|
|
5892
|
+
invalid && "border-[var(--status-danger)] text-[var(--status-danger)] placeholder:text-[var(--status-danger)]",
|
|
5893
|
+
loading && "cursor-progress",
|
|
5894
|
+
className
|
|
5895
|
+
)
|
|
5896
|
+
}
|
|
5897
|
+
),
|
|
5898
|
+
(loading || onReset) && /* @__PURE__ */ (0, import_jsx_runtime87.jsxs)("div", { className: "absolute right-2 top-1/2 flex -translate-y-1/2 items-center gap-1", children: [
|
|
5899
|
+
loading && /* @__PURE__ */ (0, import_jsx_runtime87.jsx)(
|
|
5900
|
+
import_lucide_react30.Loader2,
|
|
5901
|
+
{
|
|
5902
|
+
"aria-hidden": "true",
|
|
5903
|
+
className: "h-5 w-5 animate-spin text-chekin-gray-2"
|
|
5904
|
+
}
|
|
5905
|
+
),
|
|
5906
|
+
onReset && /* @__PURE__ */ (0, import_jsx_runtime87.jsx)(
|
|
5907
|
+
Button,
|
|
5908
|
+
{
|
|
5909
|
+
variant: "ghost",
|
|
5910
|
+
onClick: onReset,
|
|
5911
|
+
disabled: isBlocked,
|
|
5912
|
+
className: "h-7 w-7 p-0 text-chekin-gray-2",
|
|
5913
|
+
"aria-label": t("reset_search"),
|
|
5914
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime87.jsx)(import_lucide_react30.X, { className: "h-5 w-5" })
|
|
5915
|
+
}
|
|
5865
5916
|
)
|
|
5866
|
-
}
|
|
5867
|
-
)
|
|
5868
|
-
onReset && /* @__PURE__ */ (0, import_jsx_runtime87.jsx)(
|
|
5869
|
-
Button,
|
|
5870
|
-
{
|
|
5871
|
-
variant: "ghost",
|
|
5872
|
-
onClick: onReset,
|
|
5873
|
-
className: "absolute right-2 top-1/2 h-7 w-7 -translate-y-1/2 p-0 text-chekin-gray-2",
|
|
5874
|
-
"aria-label": t("reset_search"),
|
|
5875
|
-
children: /* @__PURE__ */ (0, import_jsx_runtime87.jsx)(import_lucide_react30.X, { className: "h-5 w-5" })
|
|
5876
|
-
}
|
|
5877
|
-
)
|
|
5917
|
+
] })
|
|
5918
|
+
] })
|
|
5878
5919
|
] });
|
|
5879
5920
|
}
|
|
5880
5921
|
|
|
@@ -8089,7 +8130,7 @@ function WideButton({ className, disabled, ...props }) {
|
|
|
8089
8130
|
|
|
8090
8131
|
// src/datepicker/DatePicker.tsx
|
|
8091
8132
|
var React30 = __toESM(require("react"), 1);
|
|
8092
|
-
var
|
|
8133
|
+
var import_lucide_react42 = require("lucide-react");
|
|
8093
8134
|
|
|
8094
8135
|
// src/drawer/Drawer.tsx
|
|
8095
8136
|
var React27 = __toESM(require("react"), 1);
|
|
@@ -8272,6 +8313,13 @@ function stripTime(date) {
|
|
|
8272
8313
|
function isValidDate(value) {
|
|
8273
8314
|
return value instanceof Date && !Number.isNaN(value.getTime());
|
|
8274
8315
|
}
|
|
8316
|
+
function normalizeDateValue(value) {
|
|
8317
|
+
if (value === "" || value === null || value === void 0) {
|
|
8318
|
+
return null;
|
|
8319
|
+
}
|
|
8320
|
+
const date = value instanceof Date ? value : new Date(value);
|
|
8321
|
+
return isValidDate(date) ? date : null;
|
|
8322
|
+
}
|
|
8275
8323
|
function clampDate(date, minDate, maxDate) {
|
|
8276
8324
|
const normalizedDate = stripTime(date);
|
|
8277
8325
|
const normalizedMinDate = isValidDate(minDate) ? stripTime(minDate) : null;
|
|
@@ -8936,6 +8984,8 @@ var DEVICE = {
|
|
|
8936
8984
|
|
|
8937
8985
|
// src/field-trigger/FieldTrigger.tsx
|
|
8938
8986
|
var React29 = __toESM(require("react"), 1);
|
|
8987
|
+
var import_lucide_react41 = require("lucide-react");
|
|
8988
|
+
var import_react_i18next22 = require("react-i18next");
|
|
8939
8989
|
|
|
8940
8990
|
// src/field-error-message/FieldErrorMessage.tsx
|
|
8941
8991
|
var import_lucide_react40 = require("lucide-react");
|
|
@@ -8993,27 +9043,60 @@ var FieldTrigger = React29.forwardRef(
|
|
|
8993
9043
|
placeholder,
|
|
8994
9044
|
disabled,
|
|
8995
9045
|
error,
|
|
9046
|
+
loading,
|
|
9047
|
+
optional,
|
|
9048
|
+
tooltip,
|
|
8996
9049
|
describedBy,
|
|
8997
9050
|
className,
|
|
8998
9051
|
contentClassName,
|
|
8999
9052
|
trailingAdornment,
|
|
9000
9053
|
forceFloatingLabel = false,
|
|
9054
|
+
forceLabelText = false,
|
|
9001
9055
|
hideErrorMessage = false,
|
|
9002
9056
|
children,
|
|
9003
9057
|
onClick,
|
|
9004
9058
|
onKeyDown,
|
|
9005
9059
|
...props
|
|
9006
9060
|
}, ref) => {
|
|
9061
|
+
const { t } = (0, import_react_i18next22.useTranslation)();
|
|
9007
9062
|
const hasValue = Boolean(valueText);
|
|
9008
9063
|
const isRaised = hasValue || forceFloatingLabel;
|
|
9009
|
-
const
|
|
9064
|
+
const optionalLabel = optional ? typeof optional === "string" ? optional : t("optional") : void 0;
|
|
9065
|
+
const visibleLabelText = labelText ?? label;
|
|
9066
|
+
const hasLabelMeta = Boolean(optionalLabel) || Boolean(tooltip);
|
|
9067
|
+
const resolvedLabelText = visibleLabelText && hasLabelMeta ? /* @__PURE__ */ (0, import_jsx_runtime122.jsxs)("span", { className: "inline-flex max-w-full items-center gap-1.5 align-middle", children: [
|
|
9068
|
+
/* @__PURE__ */ (0, import_jsx_runtime122.jsx)("span", { className: "min-w-0 truncate", children: visibleLabelText }),
|
|
9069
|
+
optionalLabel && /* @__PURE__ */ (0, import_jsx_runtime122.jsxs)("span", { className: "shrink-0 text-[12px] relative top-[1px] font-normal leading-4 text-current opacity-70", children: [
|
|
9070
|
+
"(",
|
|
9071
|
+
optionalLabel,
|
|
9072
|
+
")"
|
|
9073
|
+
] }),
|
|
9074
|
+
tooltip && /* @__PURE__ */ (0, import_jsx_runtime122.jsx)(
|
|
9075
|
+
HelpTooltip,
|
|
9076
|
+
{
|
|
9077
|
+
content: tooltip,
|
|
9078
|
+
side: "top",
|
|
9079
|
+
size: 16,
|
|
9080
|
+
triggerAs: as === "button" ? "span" : "button",
|
|
9081
|
+
className: "pointer-events-auto text-current opacity-70 hover:text-current hover:opacity-100"
|
|
9082
|
+
}
|
|
9083
|
+
)
|
|
9084
|
+
] }) : visibleLabelText;
|
|
9085
|
+
const animatedLabel = forceLabelText ? resolvedLabelText ?? placeholder : isRaised ? resolvedLabelText : label ?? placeholder;
|
|
9010
9086
|
const isAirbnbVariant = variant === "airbnb";
|
|
9087
|
+
const hasInvalidState = Boolean(error);
|
|
9088
|
+
const errorMessage = typeof error === "string" ? error : void 0;
|
|
9089
|
+
const isBlocked = Boolean(disabled) || Boolean(loading);
|
|
9090
|
+
const resolvedTrailingAdornment = loading || trailingAdornment ? /* @__PURE__ */ (0, import_jsx_runtime122.jsxs)("span", { className: "flex items-center gap-2", children: [
|
|
9091
|
+
trailingAdornment,
|
|
9092
|
+
loading && /* @__PURE__ */ (0, import_jsx_runtime122.jsx)(import_lucide_react41.Loader2, { "aria-hidden": "true", className: "h-5 w-5 animate-spin text-[#7A8399]" })
|
|
9093
|
+
] }) : void 0;
|
|
9011
9094
|
const sharedClasses = cn(
|
|
9012
9095
|
"relative flex border w-full items-center bg-[var(--form-background-color,#fff)] text-left transition-colors focus-visible:outline-none",
|
|
9013
9096
|
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]",
|
|
9014
9097
|
isAirbnbVariant ? isRaised ? "min-h-[60px]" : "h-[60px]" : "min-h-[48px]",
|
|
9015
|
-
|
|
9016
|
-
disabled ? "cursor-not-allowed opacity-50" : isAirbnbVariant ? "cursor-pointer" : "cursor-text",
|
|
9098
|
+
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",
|
|
9099
|
+
disabled ? "cursor-not-allowed opacity-50" : loading ? "cursor-progress" : isAirbnbVariant ? "cursor-pointer" : "cursor-text",
|
|
9017
9100
|
className
|
|
9018
9101
|
);
|
|
9019
9102
|
const sharedContent = /* @__PURE__ */ (0, import_jsx_runtime122.jsxs)(import_jsx_runtime122.Fragment, { children: [
|
|
@@ -9031,9 +9114,10 @@ var FieldTrigger = React29.forwardRef(
|
|
|
9031
9114
|
{
|
|
9032
9115
|
id: labelId,
|
|
9033
9116
|
className: cn(
|
|
9034
|
-
"
|
|
9117
|
+
"absolute left-0 origin-left truncate transition-all duration-200 ease-out",
|
|
9118
|
+
hasLabelMeta ? "" : "pointer-events-none",
|
|
9035
9119
|
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",
|
|
9036
|
-
|
|
9120
|
+
hasInvalidState ? "text-[var(--status-danger)]" : isAirbnbVariant ? "text-[var(--form-placeholder-color,#6c6c6c)]" : "text-[#7A8399]"
|
|
9037
9121
|
),
|
|
9038
9122
|
children: animatedLabel
|
|
9039
9123
|
}
|
|
@@ -9045,7 +9129,7 @@ var FieldTrigger = React29.forwardRef(
|
|
|
9045
9129
|
className: cn(
|
|
9046
9130
|
"absolute left-0 block truncate transition-all duration-200 ease-out",
|
|
9047
9131
|
isAirbnbVariant ? "bottom-0 translate-y-0 text-[16px] leading-6 opacity-100" : "bottom-[11px] text-[16px] leading-6",
|
|
9048
|
-
|
|
9132
|
+
hasInvalidState ? "text-[var(--status-danger)]" : "text-[var(--form-field-text-color,#222222)]"
|
|
9049
9133
|
),
|
|
9050
9134
|
children: valueText
|
|
9051
9135
|
}
|
|
@@ -9053,7 +9137,7 @@ var FieldTrigger = React29.forwardRef(
|
|
|
9053
9137
|
]
|
|
9054
9138
|
}
|
|
9055
9139
|
),
|
|
9056
|
-
|
|
9140
|
+
resolvedTrailingAdornment && /* @__PURE__ */ (0, import_jsx_runtime122.jsx)(
|
|
9057
9141
|
"span",
|
|
9058
9142
|
{
|
|
9059
9143
|
"aria-hidden": "true",
|
|
@@ -9061,7 +9145,7 @@ var FieldTrigger = React29.forwardRef(
|
|
|
9061
9145
|
"pointer-events-none absolute top-1/2 -translate-y-1/2",
|
|
9062
9146
|
isAirbnbVariant ? "right-5" : "right-4"
|
|
9063
9147
|
),
|
|
9064
|
-
children:
|
|
9148
|
+
children: resolvedTrailingAdornment
|
|
9065
9149
|
}
|
|
9066
9150
|
)
|
|
9067
9151
|
] });
|
|
@@ -9075,10 +9159,11 @@ var FieldTrigger = React29.forwardRef(
|
|
|
9075
9159
|
type: "button",
|
|
9076
9160
|
"aria-labelledby": hasValue && valueId ? `${labelId} ${valueId}` : labelId,
|
|
9077
9161
|
"aria-describedby": describedBy,
|
|
9078
|
-
"aria-invalid":
|
|
9079
|
-
|
|
9080
|
-
|
|
9081
|
-
|
|
9162
|
+
"aria-invalid": hasInvalidState,
|
|
9163
|
+
"aria-busy": loading,
|
|
9164
|
+
disabled: isBlocked,
|
|
9165
|
+
onClick: isBlocked ? void 0 : onClick,
|
|
9166
|
+
onKeyDown: isBlocked ? void 0 : onKeyDown,
|
|
9082
9167
|
className: sharedClasses,
|
|
9083
9168
|
...props,
|
|
9084
9169
|
children: sharedContent
|
|
@@ -9090,16 +9175,17 @@ var FieldTrigger = React29.forwardRef(
|
|
|
9090
9175
|
ref,
|
|
9091
9176
|
"aria-labelledby": hasValue && valueId ? `${labelId} ${valueId}` : labelId,
|
|
9092
9177
|
"aria-describedby": describedBy,
|
|
9093
|
-
"aria-invalid":
|
|
9094
|
-
"aria-
|
|
9095
|
-
|
|
9096
|
-
|
|
9178
|
+
"aria-invalid": hasInvalidState,
|
|
9179
|
+
"aria-busy": loading,
|
|
9180
|
+
"aria-disabled": isBlocked,
|
|
9181
|
+
onClick: isBlocked ? void 0 : onClick,
|
|
9182
|
+
onKeyDown: isBlocked ? void 0 : onKeyDown,
|
|
9097
9183
|
className: sharedClasses,
|
|
9098
9184
|
...props,
|
|
9099
9185
|
children: sharedContent
|
|
9100
9186
|
}
|
|
9101
9187
|
),
|
|
9102
|
-
|
|
9188
|
+
errorMessage && !hideErrorMessage && /* @__PURE__ */ (0, import_jsx_runtime122.jsx)(FieldErrorMessage, { id: errorId, message: errorMessage })
|
|
9103
9189
|
] });
|
|
9104
9190
|
}
|
|
9105
9191
|
);
|
|
@@ -9108,154 +9194,190 @@ FieldTrigger.displayName = "FieldTrigger";
|
|
|
9108
9194
|
// src/datepicker/DatePicker.tsx
|
|
9109
9195
|
var import_jsx_runtime123 = require("react/jsx-runtime");
|
|
9110
9196
|
var DEFAULT_MIN_DATE = new Date(1920, 0, 1);
|
|
9111
|
-
|
|
9112
|
-
|
|
9113
|
-
|
|
9114
|
-
|
|
9115
|
-
|
|
9116
|
-
|
|
9117
|
-
onChange,
|
|
9118
|
-
placeholder = "Select a date",
|
|
9119
|
-
disabled,
|
|
9120
|
-
error,
|
|
9121
|
-
className,
|
|
9122
|
-
name,
|
|
9123
|
-
minDate,
|
|
9124
|
-
maxDate,
|
|
9125
|
-
locale = "en-US",
|
|
9126
|
-
mobileTitle,
|
|
9127
|
-
doneLabel = "Done",
|
|
9128
|
-
formatValue = formatDateValue
|
|
9129
|
-
}) {
|
|
9130
|
-
const { isMatch: isMobile } = useScreenResize(DEVICE.mobileXL);
|
|
9131
|
-
const [isOpen, setIsOpen] = React30.useState(false);
|
|
9132
|
-
const triggerId = React30.useId();
|
|
9133
|
-
const pickerId = React30.useId();
|
|
9134
|
-
const labelId = React30.useId();
|
|
9135
|
-
const valueId = React30.useId();
|
|
9136
|
-
const helperTextId = React30.useId();
|
|
9137
|
-
const errorId = React30.useId();
|
|
9138
|
-
const triggerRef = React30.useRef(null);
|
|
9139
|
-
const monthLabels = React30.useMemo(() => getMonthLabels(locale), [locale]);
|
|
9140
|
-
const resolvedMinDate = React30.useMemo(() => minDate ?? DEFAULT_MIN_DATE, [minDate]);
|
|
9141
|
-
const resolvedMaxDate = React30.useMemo(() => maxDate ?? /* @__PURE__ */ new Date(), [maxDate]);
|
|
9142
|
-
const resolvedValue = React30.useMemo(
|
|
9143
|
-
() => value ? clampDate(value, resolvedMinDate, resolvedMaxDate) : null,
|
|
9144
|
-
[resolvedMaxDate, resolvedMinDate, value]
|
|
9145
|
-
);
|
|
9146
|
-
const hasValue = Boolean(resolvedValue);
|
|
9147
|
-
const {
|
|
9148
|
-
dayIndex,
|
|
9149
|
-
dayListRef,
|
|
9150
|
-
dayScrollTop,
|
|
9151
|
-
days,
|
|
9152
|
-
draftDate,
|
|
9153
|
-
handleColumnKeyDown,
|
|
9154
|
-
handleColumnScroll,
|
|
9155
|
-
handleOptionSelect,
|
|
9156
|
-
monthIndex,
|
|
9157
|
-
monthListRef,
|
|
9158
|
-
months,
|
|
9159
|
-
monthScrollTop,
|
|
9160
|
-
yearIndex,
|
|
9161
|
-
yearListRef,
|
|
9162
|
-
yearScrollTop,
|
|
9163
|
-
years
|
|
9164
|
-
} = useDatePickerWheel({
|
|
9165
|
-
isOpen,
|
|
9166
|
-
value: resolvedValue,
|
|
9197
|
+
var DatePicker = React30.forwardRef(
|
|
9198
|
+
({
|
|
9199
|
+
variant = "default",
|
|
9200
|
+
label,
|
|
9201
|
+
topLabel,
|
|
9202
|
+
value,
|
|
9167
9203
|
defaultValue,
|
|
9168
|
-
|
|
9169
|
-
|
|
9170
|
-
|
|
9171
|
-
|
|
9172
|
-
|
|
9173
|
-
|
|
9174
|
-
|
|
9175
|
-
|
|
9176
|
-
|
|
9177
|
-
|
|
9178
|
-
|
|
9179
|
-
|
|
9180
|
-
|
|
9181
|
-
|
|
9182
|
-
|
|
9183
|
-
|
|
9184
|
-
},
|
|
9185
|
-
|
|
9186
|
-
(
|
|
9187
|
-
|
|
9188
|
-
|
|
9189
|
-
|
|
9190
|
-
|
|
9191
|
-
|
|
9192
|
-
|
|
9193
|
-
|
|
9194
|
-
|
|
9195
|
-
|
|
9196
|
-
|
|
9197
|
-
|
|
9198
|
-
|
|
9199
|
-
|
|
9200
|
-
|
|
9201
|
-
|
|
9202
|
-
|
|
9203
|
-
|
|
9204
|
-
|
|
9205
|
-
|
|
9206
|
-
|
|
9207
|
-
|
|
9208
|
-
|
|
9209
|
-
|
|
9210
|
-
|
|
9211
|
-
|
|
9212
|
-
|
|
9213
|
-
|
|
9214
|
-
|
|
9215
|
-
|
|
9216
|
-
|
|
9217
|
-
|
|
9218
|
-
|
|
9219
|
-
|
|
9220
|
-
|
|
9221
|
-
|
|
9222
|
-
|
|
9223
|
-
|
|
9224
|
-
|
|
9225
|
-
|
|
9226
|
-
|
|
9227
|
-
|
|
9228
|
-
|
|
9229
|
-
|
|
9230
|
-
|
|
9231
|
-
|
|
9232
|
-
|
|
9233
|
-
|
|
9234
|
-
|
|
9235
|
-
|
|
9236
|
-
|
|
9237
|
-
|
|
9238
|
-
|
|
9239
|
-
|
|
9240
|
-
|
|
9241
|
-
|
|
9242
|
-
|
|
9243
|
-
|
|
9244
|
-
|
|
9245
|
-
|
|
9246
|
-
|
|
9247
|
-
|
|
9248
|
-
|
|
9249
|
-
|
|
9250
|
-
|
|
9251
|
-
|
|
9252
|
-
|
|
9253
|
-
|
|
9254
|
-
|
|
9204
|
+
onChange,
|
|
9205
|
+
placeholder = "Select a date",
|
|
9206
|
+
disabled,
|
|
9207
|
+
error,
|
|
9208
|
+
invalid,
|
|
9209
|
+
loading,
|
|
9210
|
+
optional,
|
|
9211
|
+
tooltip,
|
|
9212
|
+
className,
|
|
9213
|
+
name,
|
|
9214
|
+
minDate,
|
|
9215
|
+
maxDate,
|
|
9216
|
+
locale = "en-US",
|
|
9217
|
+
mobileTitle,
|
|
9218
|
+
doneLabel = "Done",
|
|
9219
|
+
formatValue = formatDateValue
|
|
9220
|
+
}, ref) => {
|
|
9221
|
+
const { isMatch: isMobile } = useScreenResize(DEVICE.mobileXL);
|
|
9222
|
+
const [isOpen, setIsOpen] = React30.useState(false);
|
|
9223
|
+
const triggerId = React30.useId();
|
|
9224
|
+
const pickerId = React30.useId();
|
|
9225
|
+
const labelId = React30.useId();
|
|
9226
|
+
const valueId = React30.useId();
|
|
9227
|
+
const helperTextId = React30.useId();
|
|
9228
|
+
const errorId = React30.useId();
|
|
9229
|
+
const internalRef = React30.useRef(null);
|
|
9230
|
+
const combinedRef = useCombinedRef(ref, internalRef);
|
|
9231
|
+
const monthLabels = React30.useMemo(() => getMonthLabels(locale), [locale]);
|
|
9232
|
+
const resolvedMinDate = React30.useMemo(() => minDate ?? DEFAULT_MIN_DATE, [minDate]);
|
|
9233
|
+
const resolvedMaxDate = React30.useMemo(() => maxDate ?? /* @__PURE__ */ new Date(), [maxDate]);
|
|
9234
|
+
const normalizedValue = React30.useMemo(() => normalizeDateValue(value), [value]);
|
|
9235
|
+
const normalizedDefaultValue = React30.useMemo(
|
|
9236
|
+
() => normalizeDateValue(defaultValue),
|
|
9237
|
+
[defaultValue]
|
|
9238
|
+
);
|
|
9239
|
+
const resolvedValue = React30.useMemo(
|
|
9240
|
+
() => normalizedValue ? clampDate(normalizedValue, resolvedMinDate, resolvedMaxDate) : null,
|
|
9241
|
+
[normalizedValue, resolvedMaxDate, resolvedMinDate]
|
|
9242
|
+
);
|
|
9243
|
+
const hasValue = Boolean(resolvedValue);
|
|
9244
|
+
const isBlocked = Boolean(disabled) || Boolean(loading);
|
|
9245
|
+
const triggerError = error ?? invalid;
|
|
9246
|
+
const {
|
|
9247
|
+
dayIndex,
|
|
9248
|
+
dayListRef,
|
|
9249
|
+
dayScrollTop,
|
|
9250
|
+
days,
|
|
9251
|
+
draftDate,
|
|
9252
|
+
handleColumnKeyDown,
|
|
9253
|
+
handleColumnScroll,
|
|
9254
|
+
handleOptionSelect,
|
|
9255
|
+
monthIndex,
|
|
9256
|
+
monthListRef,
|
|
9257
|
+
months,
|
|
9258
|
+
monthScrollTop,
|
|
9259
|
+
yearIndex,
|
|
9260
|
+
yearListRef,
|
|
9261
|
+
yearScrollTop,
|
|
9262
|
+
years
|
|
9263
|
+
} = useDatePickerWheel({
|
|
9264
|
+
isOpen,
|
|
9265
|
+
value: resolvedValue,
|
|
9266
|
+
defaultValue: normalizedDefaultValue,
|
|
9267
|
+
minDate: resolvedMinDate,
|
|
9268
|
+
maxDate: resolvedMaxDate
|
|
9269
|
+
});
|
|
9270
|
+
const handleOpenChange = React30.useCallback(
|
|
9271
|
+
(nextOpen) => {
|
|
9272
|
+
if (isBlocked && nextOpen) return;
|
|
9273
|
+
setIsOpen(nextOpen);
|
|
9274
|
+
if (!nextOpen) {
|
|
9275
|
+
internalRef.current?.focus();
|
|
9276
|
+
}
|
|
9277
|
+
},
|
|
9278
|
+
[isBlocked]
|
|
9279
|
+
);
|
|
9280
|
+
const handleDone = React30.useCallback(() => {
|
|
9281
|
+
if (isBlocked) return;
|
|
9282
|
+
onChange(clampDate(draftDate, resolvedMinDate, resolvedMaxDate));
|
|
9283
|
+
handleOpenChange(false);
|
|
9284
|
+
}, [
|
|
9285
|
+
draftDate,
|
|
9286
|
+
handleOpenChange,
|
|
9287
|
+
isBlocked,
|
|
9288
|
+
onChange,
|
|
9289
|
+
resolvedMaxDate,
|
|
9290
|
+
resolvedMinDate
|
|
9291
|
+
]);
|
|
9292
|
+
const handleTriggerClick = React30.useCallback(() => {
|
|
9293
|
+
if (isBlocked) return;
|
|
9294
|
+
setIsOpen(true);
|
|
9295
|
+
}, [isBlocked]);
|
|
9296
|
+
const handleTriggerKeyDown = React30.useCallback(
|
|
9297
|
+
(event) => {
|
|
9298
|
+
if (isBlocked) return;
|
|
9299
|
+
if (event.key === "ArrowDown" || event.key === "ArrowUp" || event.key === "Enter" || event.key === " ") {
|
|
9300
|
+
event.preventDefault();
|
|
9301
|
+
setIsOpen(true);
|
|
9302
|
+
}
|
|
9303
|
+
},
|
|
9304
|
+
[isBlocked]
|
|
9305
|
+
);
|
|
9306
|
+
React30.useEffect(() => {
|
|
9307
|
+
if (isBlocked) {
|
|
9308
|
+
setIsOpen(false);
|
|
9255
9309
|
}
|
|
9256
|
-
)
|
|
9257
|
-
|
|
9258
|
-
|
|
9310
|
+
}, [isBlocked]);
|
|
9311
|
+
return /* @__PURE__ */ (0, import_jsx_runtime123.jsxs)("div", { className: cn("relative w-full max-w-[425px]", className), children: [
|
|
9312
|
+
name && /* @__PURE__ */ (0, import_jsx_runtime123.jsx)(
|
|
9313
|
+
"input",
|
|
9314
|
+
{
|
|
9315
|
+
type: "hidden",
|
|
9316
|
+
name,
|
|
9317
|
+
value: resolvedValue ? formatDateInputValue(resolvedValue) : ""
|
|
9318
|
+
}
|
|
9319
|
+
),
|
|
9320
|
+
/* @__PURE__ */ (0, import_jsx_runtime123.jsx)(
|
|
9321
|
+
FieldTrigger,
|
|
9322
|
+
{
|
|
9323
|
+
id: triggerId,
|
|
9324
|
+
ref: combinedRef,
|
|
9325
|
+
variant,
|
|
9326
|
+
label,
|
|
9327
|
+
topLabel,
|
|
9328
|
+
labelId,
|
|
9329
|
+
valueId: hasValue ? valueId : void 0,
|
|
9330
|
+
helperTextId: !hasValue ? helperTextId : void 0,
|
|
9331
|
+
errorId: error ? errorId : void 0,
|
|
9332
|
+
describedBy: error ? errorId : void 0,
|
|
9333
|
+
labelText: topLabel ? placeholder : void 0,
|
|
9334
|
+
valueText: resolvedValue ? formatValue(resolvedValue) : void 0,
|
|
9335
|
+
placeholder,
|
|
9336
|
+
disabled,
|
|
9337
|
+
error: triggerError,
|
|
9338
|
+
loading,
|
|
9339
|
+
optional,
|
|
9340
|
+
tooltip,
|
|
9341
|
+
forceLabelText: Boolean(optional) || Boolean(tooltip),
|
|
9342
|
+
"aria-haspopup": "dialog",
|
|
9343
|
+
"aria-expanded": isOpen,
|
|
9344
|
+
onClick: handleTriggerClick,
|
|
9345
|
+
onKeyDown: handleTriggerKeyDown,
|
|
9346
|
+
trailingAdornment: /* @__PURE__ */ (0, import_jsx_runtime123.jsx)(import_lucide_react42.Calendar, { className: "h-5 w-5 text-[#1F1F1B]", strokeWidth: 2 })
|
|
9347
|
+
}
|
|
9348
|
+
),
|
|
9349
|
+
/* @__PURE__ */ (0, import_jsx_runtime123.jsx)(
|
|
9350
|
+
DatePickerContent,
|
|
9351
|
+
{
|
|
9352
|
+
baseId: pickerId,
|
|
9353
|
+
open: isOpen,
|
|
9354
|
+
isMobile,
|
|
9355
|
+
label,
|
|
9356
|
+
title: mobileTitle ?? label,
|
|
9357
|
+
doneLabel,
|
|
9358
|
+
monthLabels: months.map((month) => monthLabels[month] ?? ""),
|
|
9359
|
+
days,
|
|
9360
|
+
years,
|
|
9361
|
+
monthIndex,
|
|
9362
|
+
dayIndex,
|
|
9363
|
+
yearIndex,
|
|
9364
|
+
monthScrollTop,
|
|
9365
|
+
dayScrollTop,
|
|
9366
|
+
yearScrollTop,
|
|
9367
|
+
monthListRef,
|
|
9368
|
+
dayListRef,
|
|
9369
|
+
yearListRef,
|
|
9370
|
+
onOpenChange: handleOpenChange,
|
|
9371
|
+
onDone: handleDone,
|
|
9372
|
+
onColumnScroll: handleColumnScroll,
|
|
9373
|
+
onColumnKeyDown: handleColumnKeyDown,
|
|
9374
|
+
onOptionSelect: handleOptionSelect
|
|
9375
|
+
}
|
|
9376
|
+
)
|
|
9377
|
+
] });
|
|
9378
|
+
}
|
|
9379
|
+
);
|
|
9380
|
+
DatePicker.displayName = "DatePicker";
|
|
9259
9381
|
|
|
9260
9382
|
// src/responsive-sheet/ResponsiveSheet.tsx
|
|
9261
9383
|
var import_jsx_runtime124 = require("react/jsx-runtime");
|
|
@@ -9376,6 +9498,10 @@ var AirbnbInput = React31.forwardRef(
|
|
|
9376
9498
|
topLabel,
|
|
9377
9499
|
helperText,
|
|
9378
9500
|
error,
|
|
9501
|
+
invalid,
|
|
9502
|
+
loading,
|
|
9503
|
+
optional,
|
|
9504
|
+
tooltip,
|
|
9379
9505
|
wrapperClassName,
|
|
9380
9506
|
fieldClassName,
|
|
9381
9507
|
contentClassName,
|
|
@@ -9400,7 +9526,7 @@ var AirbnbInput = React31.forwardRef(
|
|
|
9400
9526
|
const fieldId = `${inputId}-field`;
|
|
9401
9527
|
const labelId = `${inputId}-label`;
|
|
9402
9528
|
const errorId = `${inputId}-error`;
|
|
9403
|
-
const accessibleLabel =
|
|
9529
|
+
const accessibleLabel = placeholder ?? label;
|
|
9404
9530
|
const [isFocused, setIsFocused] = React31.useState(false);
|
|
9405
9531
|
const [currentValue, setCurrentValue] = React31.useState(
|
|
9406
9532
|
() => value != null ? getInputValue(value) : getInputValue(defaultValue)
|
|
@@ -9408,6 +9534,10 @@ var AirbnbInput = React31.forwardRef(
|
|
|
9408
9534
|
const resolvedValue = value != null ? getInputValue(value) : currentValue;
|
|
9409
9535
|
const hasValue = resolvedValue.length > 0;
|
|
9410
9536
|
const shouldShowLabel = hasValue || isFocused;
|
|
9537
|
+
const hasInvalidState = Boolean(error) || Boolean(invalid);
|
|
9538
|
+
const triggerError = error ?? invalid;
|
|
9539
|
+
const hasLabelMeta = Boolean(optional) || Boolean(tooltip);
|
|
9540
|
+
const isBlocked = Boolean(disabled) || Boolean(loading);
|
|
9411
9541
|
React31.useLayoutEffect(() => {
|
|
9412
9542
|
const nextValue = value != null ? getInputValue(value) : getInputValue(inputRef.current?.value);
|
|
9413
9543
|
setCurrentValue((prevValue) => prevValue === nextValue ? prevValue : nextValue);
|
|
@@ -9456,7 +9586,10 @@ var AirbnbInput = React31.forwardRef(
|
|
|
9456
9586
|
labelText: helperText ?? label,
|
|
9457
9587
|
placeholder: placeholder ?? label,
|
|
9458
9588
|
disabled,
|
|
9459
|
-
error,
|
|
9589
|
+
error: triggerError,
|
|
9590
|
+
loading,
|
|
9591
|
+
optional,
|
|
9592
|
+
tooltip,
|
|
9460
9593
|
describedBy: error && renderErrorMessage ? errorId : void 0,
|
|
9461
9594
|
className: cn(
|
|
9462
9595
|
variant === "airbnb" ? "px-4 focus-within:ring-2 focus-within:ring-[#1F1F1B] focus-within:ring-offset-2" : "px-3.5 focus-within:border-[#315EFB]",
|
|
@@ -9469,6 +9602,7 @@ var AirbnbInput = React31.forwardRef(
|
|
|
9469
9602
|
),
|
|
9470
9603
|
trailingAdornment,
|
|
9471
9604
|
forceFloatingLabel: shouldShowLabel,
|
|
9605
|
+
forceLabelText: hasLabelMeta,
|
|
9472
9606
|
hideErrorMessage: !renderErrorMessage,
|
|
9473
9607
|
children: /* @__PURE__ */ (0, import_jsx_runtime125.jsx)(
|
|
9474
9608
|
"input",
|
|
@@ -9477,21 +9611,23 @@ var AirbnbInput = React31.forwardRef(
|
|
|
9477
9611
|
id: inputId,
|
|
9478
9612
|
ref: setRefs,
|
|
9479
9613
|
type,
|
|
9480
|
-
disabled,
|
|
9614
|
+
disabled: isBlocked,
|
|
9481
9615
|
value,
|
|
9482
9616
|
defaultValue,
|
|
9483
9617
|
onChange: handleChange,
|
|
9484
9618
|
onFocus: handleFocus,
|
|
9485
9619
|
onBlur: handleBlur,
|
|
9486
9620
|
placeholder: "",
|
|
9487
|
-
"aria-invalid":
|
|
9621
|
+
"aria-invalid": hasInvalidState,
|
|
9622
|
+
"aria-busy": loading,
|
|
9488
9623
|
"aria-describedby": error && renderErrorMessage ? errorId : void 0,
|
|
9489
|
-
"aria-
|
|
9624
|
+
"aria-label": accessibleLabel && hasLabelMeta ? accessibleLabel : void 0,
|
|
9625
|
+
"aria-labelledby": accessibleLabel && !hasLabelMeta ? labelId : void 0,
|
|
9490
9626
|
className: cn(
|
|
9491
9627
|
"absolute left-0 h-6 w-full border-0 bg-transparent p-0 text-[16px] leading-6 text-[#1F1F1B] outline-none placeholder:text-[#7A8399]",
|
|
9492
9628
|
variant === "airbnb" ? "bottom-0" : "bottom-[12px]",
|
|
9493
|
-
|
|
9494
|
-
disabled ? "cursor-not-allowed" : "",
|
|
9629
|
+
hasInvalidState ? "text-[var(--status-danger)] placeholder:text-[var(--status-danger)]" : "",
|
|
9630
|
+
disabled ? "cursor-not-allowed" : loading ? "cursor-progress" : "",
|
|
9495
9631
|
inputClassName,
|
|
9496
9632
|
className
|
|
9497
9633
|
)
|
|
@@ -9505,7 +9641,7 @@ AirbnbInput.displayName = "Input";
|
|
|
9505
9641
|
|
|
9506
9642
|
// src/airbnb/phone-field/PhoneField.tsx
|
|
9507
9643
|
var React37 = __toESM(require("react"), 1);
|
|
9508
|
-
var
|
|
9644
|
+
var import_lucide_react44 = require("lucide-react");
|
|
9509
9645
|
|
|
9510
9646
|
// src/airbnb/select/Select.tsx
|
|
9511
9647
|
var React36 = __toESM(require("react"), 1);
|
|
@@ -9854,7 +9990,7 @@ function SelectMobileContent({
|
|
|
9854
9990
|
|
|
9855
9991
|
// src/airbnb/select/SelectTrigger.tsx
|
|
9856
9992
|
var React32 = __toESM(require("react"), 1);
|
|
9857
|
-
var
|
|
9993
|
+
var import_lucide_react43 = require("lucide-react");
|
|
9858
9994
|
var import_jsx_runtime130 = require("react/jsx-runtime");
|
|
9859
9995
|
var SelectTrigger2 = React32.forwardRef(
|
|
9860
9996
|
({
|
|
@@ -9866,6 +10002,9 @@ var SelectTrigger2 = React32.forwardRef(
|
|
|
9866
10002
|
helperText,
|
|
9867
10003
|
valueLabel,
|
|
9868
10004
|
disabled,
|
|
10005
|
+
loading,
|
|
10006
|
+
optional,
|
|
10007
|
+
tooltip,
|
|
9869
10008
|
error,
|
|
9870
10009
|
hideErrorMessage,
|
|
9871
10010
|
labelId,
|
|
@@ -9897,12 +10036,16 @@ var SelectTrigger2 = React32.forwardRef(
|
|
|
9897
10036
|
placeholder: helperText,
|
|
9898
10037
|
describedBy,
|
|
9899
10038
|
error,
|
|
10039
|
+
loading,
|
|
10040
|
+
optional,
|
|
10041
|
+
tooltip,
|
|
10042
|
+
forceLabelText: Boolean(optional) || Boolean(tooltip),
|
|
9900
10043
|
hideErrorMessage,
|
|
9901
10044
|
disabled,
|
|
9902
10045
|
onClick,
|
|
9903
10046
|
onKeyDown,
|
|
9904
10047
|
trailingAdornment: /* @__PURE__ */ (0, import_jsx_runtime130.jsx)(
|
|
9905
|
-
|
|
10048
|
+
import_lucide_react43.ChevronDown,
|
|
9906
10049
|
{
|
|
9907
10050
|
className: open ? "h-6 w-6 rotate-180 text-[#1F1F1B] transition-transform" : "h-6 w-6 text-[#1F1F1B] transition-transform"
|
|
9908
10051
|
}
|
|
@@ -10316,7 +10459,7 @@ function useOutsideClick(elementRef, onOutsideClick, nested) {
|
|
|
10316
10459
|
|
|
10317
10460
|
// src/airbnb/select/Select.tsx
|
|
10318
10461
|
var import_jsx_runtime131 = require("react/jsx-runtime");
|
|
10319
|
-
|
|
10462
|
+
var AirbnbSelect = React36.forwardRef(function AirbnbSelect2({
|
|
10320
10463
|
options,
|
|
10321
10464
|
value,
|
|
10322
10465
|
onChange,
|
|
@@ -10327,7 +10470,11 @@ function AirbnbSelect({
|
|
|
10327
10470
|
getValueLabel,
|
|
10328
10471
|
renderTrigger,
|
|
10329
10472
|
disabled,
|
|
10473
|
+
loading,
|
|
10474
|
+
optional,
|
|
10475
|
+
tooltip,
|
|
10330
10476
|
error,
|
|
10477
|
+
invalid,
|
|
10331
10478
|
hideErrorMessage,
|
|
10332
10479
|
className,
|
|
10333
10480
|
menuClassName,
|
|
@@ -10336,12 +10483,14 @@ function AirbnbSelect({
|
|
|
10336
10483
|
mobileTitle,
|
|
10337
10484
|
name,
|
|
10338
10485
|
noOptionsMessage
|
|
10339
|
-
}) {
|
|
10486
|
+
}, ref) {
|
|
10340
10487
|
const { isMatch: isMobile } = useScreenResize(DEVICE.mobileXL);
|
|
10341
10488
|
const [isOpen, setIsOpen] = React36.useState(false);
|
|
10342
10489
|
const containerRef = React36.useRef(null);
|
|
10343
10490
|
const hasValue = Boolean(value);
|
|
10344
10491
|
const helperText = placeholder ?? label;
|
|
10492
|
+
const isBlocked = Boolean(disabled) || Boolean(loading);
|
|
10493
|
+
const triggerError = error ?? invalid;
|
|
10345
10494
|
const {
|
|
10346
10495
|
triggerId,
|
|
10347
10496
|
labelId,
|
|
@@ -10367,14 +10516,14 @@ function AirbnbSelect({
|
|
|
10367
10516
|
isOpen,
|
|
10368
10517
|
options,
|
|
10369
10518
|
value,
|
|
10370
|
-
disabled
|
|
10519
|
+
disabled: isBlocked
|
|
10371
10520
|
});
|
|
10372
10521
|
const {
|
|
10373
10522
|
highlightedIndex,
|
|
10374
10523
|
listRef: desktopListRef,
|
|
10375
10524
|
setHighlightedIndex,
|
|
10376
10525
|
setOptionRef,
|
|
10377
|
-
triggerRef,
|
|
10526
|
+
triggerRef: desktopTriggerRef,
|
|
10378
10527
|
focusTrigger,
|
|
10379
10528
|
handleSelect: handleDesktopSelect,
|
|
10380
10529
|
handleMenuKeyDown,
|
|
@@ -10384,12 +10533,18 @@ function AirbnbSelect({
|
|
|
10384
10533
|
isOpen,
|
|
10385
10534
|
options,
|
|
10386
10535
|
value,
|
|
10387
|
-
disabled,
|
|
10536
|
+
disabled: isBlocked,
|
|
10388
10537
|
onChange
|
|
10389
10538
|
});
|
|
10539
|
+
const combinedRef = useCombinedRef(ref, desktopTriggerRef);
|
|
10390
10540
|
const activeMobileIndex = getOptionIndex(options, pendingValue);
|
|
10391
10541
|
const valueLabel = value ? getValueLabel?.(value) ?? String(value.label) : void 0;
|
|
10392
10542
|
useOutsideClick(containerRef, isOpen && !isMobile ? () => setIsOpen(false) : null);
|
|
10543
|
+
React36.useEffect(() => {
|
|
10544
|
+
if (isBlocked) {
|
|
10545
|
+
setIsOpen(false);
|
|
10546
|
+
}
|
|
10547
|
+
}, [isBlocked]);
|
|
10393
10548
|
React36.useEffect(
|
|
10394
10549
|
function setCorrectOptionIfThereIsOnlyValue() {
|
|
10395
10550
|
if (value?.value === void 0 || value.value === null || value.label !== "") {
|
|
@@ -10404,24 +10559,26 @@ function AirbnbSelect({
|
|
|
10404
10559
|
);
|
|
10405
10560
|
const handleMobileOpenChange = React36.useCallback(
|
|
10406
10561
|
(nextOpen) => {
|
|
10562
|
+
if (isBlocked && nextOpen) return;
|
|
10407
10563
|
setIsOpen(nextOpen);
|
|
10408
10564
|
syncPendingValue(value ?? null);
|
|
10409
10565
|
if (!nextOpen) {
|
|
10410
10566
|
focusTrigger();
|
|
10411
10567
|
}
|
|
10412
10568
|
},
|
|
10413
|
-
[focusTrigger, syncPendingValue, value]
|
|
10569
|
+
[focusTrigger, isBlocked, syncPendingValue, value]
|
|
10414
10570
|
);
|
|
10415
10571
|
const handleMobileDone = React36.useCallback(() => {
|
|
10572
|
+
if (isBlocked) return;
|
|
10416
10573
|
const finalOption = pendingValue;
|
|
10417
10574
|
if (finalOption && finalOption.value !== value?.value) {
|
|
10418
10575
|
onChange(finalOption);
|
|
10419
10576
|
}
|
|
10420
10577
|
setIsOpen(false);
|
|
10421
10578
|
focusTrigger();
|
|
10422
|
-
}, [focusTrigger, onChange, pendingValue, value]);
|
|
10579
|
+
}, [focusTrigger, isBlocked, onChange, pendingValue, value]);
|
|
10423
10580
|
const handleTriggerClick = React36.useCallback(() => {
|
|
10424
|
-
if (
|
|
10581
|
+
if (isBlocked) return;
|
|
10425
10582
|
setIsOpen((prev) => {
|
|
10426
10583
|
const nextOpen = !prev;
|
|
10427
10584
|
if (isMobile) {
|
|
@@ -10429,10 +10586,10 @@ function AirbnbSelect({
|
|
|
10429
10586
|
}
|
|
10430
10587
|
return nextOpen;
|
|
10431
10588
|
});
|
|
10432
|
-
}, [
|
|
10589
|
+
}, [isBlocked, isMobile, syncPendingValue, value]);
|
|
10433
10590
|
const handleRootTriggerKeyDown = (event) => {
|
|
10434
10591
|
if (isMobile) {
|
|
10435
|
-
if (
|
|
10592
|
+
if (isBlocked) return;
|
|
10436
10593
|
if (event.key === "ArrowDown" || event.key === "ArrowUp" || event.key === "Enter" || event.key === " ") {
|
|
10437
10594
|
event.preventDefault();
|
|
10438
10595
|
syncPendingValue(value ?? null);
|
|
@@ -10473,7 +10630,7 @@ function AirbnbSelect({
|
|
|
10473
10630
|
handleMobileOpenChange(false);
|
|
10474
10631
|
}
|
|
10475
10632
|
};
|
|
10476
|
-
return /* @__PURE__ */ (0, import_jsx_runtime131.jsxs)("div", { ref: containerRef, className: cn("relative w-full max-w-[
|
|
10633
|
+
return /* @__PURE__ */ (0, import_jsx_runtime131.jsxs)("div", { ref: containerRef, className: cn("relative w-full max-w-[425px]", className), children: [
|
|
10477
10634
|
name && /* @__PURE__ */ (0, import_jsx_runtime131.jsx)("input", { type: "hidden", name, value: value ? String(value.value) : "" }),
|
|
10478
10635
|
renderTrigger ? renderTrigger({
|
|
10479
10636
|
id: triggerId,
|
|
@@ -10484,18 +10641,22 @@ function AirbnbSelect({
|
|
|
10484
10641
|
helperText,
|
|
10485
10642
|
value,
|
|
10486
10643
|
valueLabel,
|
|
10487
|
-
disabled,
|
|
10644
|
+
disabled: isBlocked,
|
|
10645
|
+
loading,
|
|
10646
|
+
optional,
|
|
10647
|
+
tooltip,
|
|
10488
10648
|
error,
|
|
10649
|
+
invalid,
|
|
10489
10650
|
listboxId,
|
|
10490
10651
|
describedBy,
|
|
10491
|
-
triggerRef,
|
|
10652
|
+
triggerRef: combinedRef,
|
|
10492
10653
|
onClick: handleTriggerClick,
|
|
10493
10654
|
onKeyDown: handleRootTriggerKeyDown
|
|
10494
10655
|
}) : /* @__PURE__ */ (0, import_jsx_runtime131.jsx)(
|
|
10495
10656
|
SelectTrigger2,
|
|
10496
10657
|
{
|
|
10497
10658
|
id: triggerId,
|
|
10498
|
-
ref:
|
|
10659
|
+
ref: combinedRef,
|
|
10499
10660
|
open: isOpen,
|
|
10500
10661
|
variant,
|
|
10501
10662
|
label,
|
|
@@ -10503,7 +10664,10 @@ function AirbnbSelect({
|
|
|
10503
10664
|
helperText,
|
|
10504
10665
|
valueLabel,
|
|
10505
10666
|
disabled,
|
|
10506
|
-
|
|
10667
|
+
loading,
|
|
10668
|
+
optional,
|
|
10669
|
+
tooltip,
|
|
10670
|
+
error: triggerError,
|
|
10507
10671
|
hideErrorMessage,
|
|
10508
10672
|
labelId,
|
|
10509
10673
|
valueId,
|
|
@@ -10528,7 +10692,7 @@ function AirbnbSelect({
|
|
|
10528
10692
|
doneLabel,
|
|
10529
10693
|
errorId: describedErrorId,
|
|
10530
10694
|
options,
|
|
10531
|
-
disabled,
|
|
10695
|
+
disabled: isBlocked,
|
|
10532
10696
|
menuClassName,
|
|
10533
10697
|
scrollTop: mobileScrollTop,
|
|
10534
10698
|
activeIndex: activeMobileIndex,
|
|
@@ -10559,7 +10723,7 @@ function AirbnbSelect({
|
|
|
10559
10723
|
onKeyDown: (event) => {
|
|
10560
10724
|
handleMenuKeyDown(event, () => setIsOpen(false));
|
|
10561
10725
|
},
|
|
10562
|
-
disabled,
|
|
10726
|
+
disabled: isBlocked,
|
|
10563
10727
|
menuClassName,
|
|
10564
10728
|
dropdownClassName,
|
|
10565
10729
|
listRef: desktopListRef,
|
|
@@ -10569,171 +10733,192 @@ function AirbnbSelect({
|
|
|
10569
10733
|
}
|
|
10570
10734
|
)
|
|
10571
10735
|
] });
|
|
10572
|
-
}
|
|
10736
|
+
});
|
|
10573
10737
|
|
|
10574
10738
|
// src/airbnb/phone-field/PhoneField.tsx
|
|
10575
10739
|
var import_jsx_runtime132 = require("react/jsx-runtime");
|
|
10576
|
-
|
|
10577
|
-
|
|
10578
|
-
|
|
10579
|
-
|
|
10580
|
-
|
|
10581
|
-
|
|
10582
|
-
|
|
10583
|
-
|
|
10584
|
-
|
|
10585
|
-
|
|
10586
|
-
|
|
10587
|
-
|
|
10588
|
-
|
|
10589
|
-
|
|
10590
|
-
|
|
10591
|
-
|
|
10592
|
-
|
|
10593
|
-
|
|
10594
|
-
|
|
10595
|
-
|
|
10596
|
-
|
|
10597
|
-
|
|
10598
|
-
|
|
10599
|
-
|
|
10600
|
-
|
|
10601
|
-
|
|
10602
|
-
|
|
10603
|
-
|
|
10604
|
-
|
|
10605
|
-
|
|
10606
|
-
|
|
10607
|
-
|
|
10608
|
-
|
|
10609
|
-
|
|
10610
|
-
|
|
10611
|
-
|
|
10612
|
-
|
|
10613
|
-
|
|
10614
|
-
|
|
10615
|
-
|
|
10616
|
-
|
|
10617
|
-
|
|
10618
|
-
|
|
10619
|
-
|
|
10620
|
-
{
|
|
10621
|
-
type: "hidden",
|
|
10622
|
-
name: numberName,
|
|
10623
|
-
value: value?.number ?? "",
|
|
10624
|
-
disabled
|
|
10625
|
-
}
|
|
10626
|
-
),
|
|
10627
|
-
topLabel && /* @__PURE__ */ (0, import_jsx_runtime132.jsx)(
|
|
10628
|
-
"label",
|
|
10629
|
-
{
|
|
10630
|
-
htmlFor: inputId,
|
|
10631
|
-
className: "mb-3 block text-[16px] font-medium leading-5 text-[#1F1F1B]",
|
|
10632
|
-
children: topLabel
|
|
10633
|
-
}
|
|
10634
|
-
),
|
|
10635
|
-
/* @__PURE__ */ (0, import_jsx_runtime132.jsxs)("div", { className: "flex items-stretch", children: [
|
|
10636
|
-
/* @__PURE__ */ (0, import_jsx_runtime132.jsx)(
|
|
10637
|
-
AirbnbSelect,
|
|
10740
|
+
var PhoneField = React37.forwardRef(
|
|
10741
|
+
({
|
|
10742
|
+
variant = "default",
|
|
10743
|
+
label,
|
|
10744
|
+
topLabel,
|
|
10745
|
+
value,
|
|
10746
|
+
onChange,
|
|
10747
|
+
options,
|
|
10748
|
+
placeholder = "Phone number",
|
|
10749
|
+
disabled,
|
|
10750
|
+
codeReadOnly,
|
|
10751
|
+
error,
|
|
10752
|
+
invalid,
|
|
10753
|
+
loading,
|
|
10754
|
+
optional,
|
|
10755
|
+
tooltip,
|
|
10756
|
+
className,
|
|
10757
|
+
name,
|
|
10758
|
+
codeName,
|
|
10759
|
+
numberName,
|
|
10760
|
+
mobileTitle,
|
|
10761
|
+
codePlaceholder = "+00"
|
|
10762
|
+
}, ref) => {
|
|
10763
|
+
const inputId = React37.useId();
|
|
10764
|
+
const codeOptions = React37.useMemo(
|
|
10765
|
+
() => options.map((option) => ({
|
|
10766
|
+
value: option.value,
|
|
10767
|
+
label: option.label,
|
|
10768
|
+
disabled: option.disabled
|
|
10769
|
+
})),
|
|
10770
|
+
[options]
|
|
10771
|
+
);
|
|
10772
|
+
const selectedCodeOption = React37.useMemo(
|
|
10773
|
+
() => codeOptions.find((option) => option.value === value?.code) ?? null,
|
|
10774
|
+
[codeOptions, value?.code]
|
|
10775
|
+
);
|
|
10776
|
+
const combinedValue = value?.code || value?.number ? `${value?.code ?? ""}${value?.number ?? ""}` : "";
|
|
10777
|
+
const hasInvalidState = Boolean(error) || Boolean(invalid);
|
|
10778
|
+
const isBlocked = Boolean(disabled) || Boolean(loading);
|
|
10779
|
+
const isCodeBlocked = isBlocked || Boolean(codeReadOnly);
|
|
10780
|
+
return /* @__PURE__ */ (0, import_jsx_runtime132.jsxs)("div", { className: cn("w-full max-w-[425px]", className), children: [
|
|
10781
|
+
name && /* @__PURE__ */ (0, import_jsx_runtime132.jsx)("input", { type: "hidden", name, value: combinedValue, disabled }),
|
|
10782
|
+
codeName && /* @__PURE__ */ (0, import_jsx_runtime132.jsx)(
|
|
10783
|
+
"input",
|
|
10638
10784
|
{
|
|
10639
|
-
|
|
10640
|
-
|
|
10641
|
-
value:
|
|
10642
|
-
|
|
10643
|
-
code: String(option.value),
|
|
10644
|
-
number: value?.number ?? ""
|
|
10645
|
-
}),
|
|
10646
|
-
label: `${label} country code`,
|
|
10647
|
-
placeholder: codePlaceholder,
|
|
10648
|
-
disabled,
|
|
10649
|
-
className: "max-w-none shrink-0 basis-[96px]",
|
|
10650
|
-
mobileTitle: mobileTitle ?? "Select country code",
|
|
10651
|
-
dropdownClassName: "right-auto w-[280px]",
|
|
10652
|
-
getValueLabel: (option) => String(option.value),
|
|
10653
|
-
renderTrigger: ({
|
|
10654
|
-
id,
|
|
10655
|
-
open,
|
|
10656
|
-
variant: selectVariant,
|
|
10657
|
-
disabled: triggerDisabled,
|
|
10658
|
-
listboxId,
|
|
10659
|
-
triggerRef,
|
|
10660
|
-
onClick,
|
|
10661
|
-
onKeyDown,
|
|
10662
|
-
valueLabel
|
|
10663
|
-
}) => /* @__PURE__ */ (0, import_jsx_runtime132.jsxs)(
|
|
10664
|
-
"button",
|
|
10665
|
-
{
|
|
10666
|
-
id,
|
|
10667
|
-
ref: triggerRef,
|
|
10668
|
-
type: "button",
|
|
10669
|
-
"aria-label": `${label} country code`,
|
|
10670
|
-
"aria-haspopup": "listbox",
|
|
10671
|
-
"aria-expanded": open,
|
|
10672
|
-
"aria-controls": listboxId,
|
|
10673
|
-
disabled: triggerDisabled,
|
|
10674
|
-
onClick,
|
|
10675
|
-
onKeyDown,
|
|
10676
|
-
className: cn(
|
|
10677
|
-
"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",
|
|
10678
|
-
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]",
|
|
10679
|
-
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]",
|
|
10680
|
-
triggerDisabled ? "cursor-not-allowed opacity-50" : "cursor-pointer"
|
|
10681
|
-
),
|
|
10682
|
-
children: [
|
|
10683
|
-
/* @__PURE__ */ (0, import_jsx_runtime132.jsx)("span", { children: valueLabel ?? codePlaceholder }),
|
|
10684
|
-
/* @__PURE__ */ (0, import_jsx_runtime132.jsx)(
|
|
10685
|
-
import_lucide_react43.ChevronDown,
|
|
10686
|
-
{
|
|
10687
|
-
className: cn("h-5 w-5 transition-transform", open ? "rotate-180" : ""),
|
|
10688
|
-
strokeWidth: 2
|
|
10689
|
-
}
|
|
10690
|
-
)
|
|
10691
|
-
]
|
|
10692
|
-
}
|
|
10693
|
-
)
|
|
10785
|
+
type: "hidden",
|
|
10786
|
+
name: codeName,
|
|
10787
|
+
value: value?.code ?? "",
|
|
10788
|
+
disabled
|
|
10694
10789
|
}
|
|
10695
10790
|
),
|
|
10696
|
-
/* @__PURE__ */ (0, import_jsx_runtime132.jsx)(
|
|
10697
|
-
|
|
10791
|
+
numberName && /* @__PURE__ */ (0, import_jsx_runtime132.jsx)(
|
|
10792
|
+
"input",
|
|
10698
10793
|
{
|
|
10699
|
-
|
|
10700
|
-
|
|
10701
|
-
type: "tel",
|
|
10702
|
-
inputMode: "tel",
|
|
10703
|
-
label,
|
|
10704
|
-
helperText: placeholder,
|
|
10794
|
+
type: "hidden",
|
|
10795
|
+
name: numberName,
|
|
10705
10796
|
value: value?.number ?? "",
|
|
10706
|
-
|
|
10707
|
-
disabled,
|
|
10708
|
-
error,
|
|
10709
|
-
renderErrorMessage: false,
|
|
10710
|
-
wrapperClassName: "min-w-0 flex-1",
|
|
10711
|
-
fieldClassName: cn(
|
|
10712
|
-
variant === "airbnb" ? "min-h-[60px] rounded-l-none rounded-r-[16px] border-l-0" : "rounded-l-none rounded-r-[10px] border-l-0"
|
|
10713
|
-
),
|
|
10714
|
-
contentClassName: cn(variant === "airbnb" ? "h-[40px] py-2" : "h-[48px]"),
|
|
10715
|
-
inputClassName: "text-[16px] leading-7",
|
|
10716
|
-
onChange: (event) => onChange({
|
|
10717
|
-
code: value?.code ?? "",
|
|
10718
|
-
number: event.target.value
|
|
10719
|
-
})
|
|
10797
|
+
disabled
|
|
10720
10798
|
}
|
|
10721
|
-
)
|
|
10722
|
-
|
|
10723
|
-
|
|
10724
|
-
|
|
10725
|
-
|
|
10799
|
+
),
|
|
10800
|
+
topLabel && /* @__PURE__ */ (0, import_jsx_runtime132.jsx)(
|
|
10801
|
+
"label",
|
|
10802
|
+
{
|
|
10803
|
+
htmlFor: inputId,
|
|
10804
|
+
className: "mb-3 block text-[16px] font-medium leading-5 text-[#1F1F1B]",
|
|
10805
|
+
children: topLabel
|
|
10806
|
+
}
|
|
10807
|
+
),
|
|
10808
|
+
/* @__PURE__ */ (0, import_jsx_runtime132.jsxs)("div", { className: "flex items-stretch", children: [
|
|
10809
|
+
/* @__PURE__ */ (0, import_jsx_runtime132.jsx)(
|
|
10810
|
+
AirbnbSelect,
|
|
10811
|
+
{
|
|
10812
|
+
ref,
|
|
10813
|
+
variant,
|
|
10814
|
+
options: codeOptions,
|
|
10815
|
+
value: selectedCodeOption,
|
|
10816
|
+
onChange: (option) => onChange({
|
|
10817
|
+
code: String(option.value),
|
|
10818
|
+
number: value?.number ?? ""
|
|
10819
|
+
}),
|
|
10820
|
+
label: `${label} country code`,
|
|
10821
|
+
placeholder: codePlaceholder,
|
|
10822
|
+
disabled: isCodeBlocked,
|
|
10823
|
+
loading,
|
|
10824
|
+
invalid,
|
|
10825
|
+
className: "max-w-none shrink-0 basis-[96px]",
|
|
10826
|
+
mobileTitle: mobileTitle ?? "Select country code",
|
|
10827
|
+
dropdownClassName: "right-auto w-[280px]",
|
|
10828
|
+
getValueLabel: (option) => String(option.value),
|
|
10829
|
+
renderTrigger: ({
|
|
10830
|
+
id,
|
|
10831
|
+
open,
|
|
10832
|
+
variant: selectVariant,
|
|
10833
|
+
disabled: triggerDisabled,
|
|
10834
|
+
loading: triggerLoading,
|
|
10835
|
+
listboxId,
|
|
10836
|
+
triggerRef,
|
|
10837
|
+
onClick,
|
|
10838
|
+
onKeyDown,
|
|
10839
|
+
valueLabel
|
|
10840
|
+
}) => /* @__PURE__ */ (0, import_jsx_runtime132.jsxs)(
|
|
10841
|
+
"button",
|
|
10842
|
+
{
|
|
10843
|
+
id,
|
|
10844
|
+
ref: triggerRef,
|
|
10845
|
+
type: "button",
|
|
10846
|
+
"aria-label": `${label} country code`,
|
|
10847
|
+
"aria-haspopup": "listbox",
|
|
10848
|
+
"aria-expanded": open,
|
|
10849
|
+
"aria-controls": listboxId,
|
|
10850
|
+
"aria-busy": triggerLoading,
|
|
10851
|
+
"aria-invalid": hasInvalidState,
|
|
10852
|
+
disabled: triggerDisabled,
|
|
10853
|
+
onClick,
|
|
10854
|
+
onKeyDown,
|
|
10855
|
+
className: cn(
|
|
10856
|
+
"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",
|
|
10857
|
+
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]",
|
|
10858
|
+
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]",
|
|
10859
|
+
triggerDisabled ? "cursor-not-allowed opacity-50" : triggerLoading ? "cursor-progress" : "cursor-pointer"
|
|
10860
|
+
),
|
|
10861
|
+
children: [
|
|
10862
|
+
/* @__PURE__ */ (0, import_jsx_runtime132.jsx)("span", { children: valueLabel ?? codePlaceholder }),
|
|
10863
|
+
/* @__PURE__ */ (0, import_jsx_runtime132.jsx)(
|
|
10864
|
+
import_lucide_react44.ChevronDown,
|
|
10865
|
+
{
|
|
10866
|
+
className: cn("h-5 w-5 transition-transform", open ? "rotate-180" : ""),
|
|
10867
|
+
strokeWidth: 2
|
|
10868
|
+
}
|
|
10869
|
+
)
|
|
10870
|
+
]
|
|
10871
|
+
}
|
|
10872
|
+
)
|
|
10873
|
+
}
|
|
10874
|
+
),
|
|
10875
|
+
/* @__PURE__ */ (0, import_jsx_runtime132.jsx)(
|
|
10876
|
+
AirbnbInput,
|
|
10877
|
+
{
|
|
10878
|
+
id: inputId,
|
|
10879
|
+
variant,
|
|
10880
|
+
type: "tel",
|
|
10881
|
+
inputMode: "tel",
|
|
10882
|
+
label,
|
|
10883
|
+
helperText: placeholder,
|
|
10884
|
+
value: value?.number ?? "",
|
|
10885
|
+
placeholder,
|
|
10886
|
+
disabled,
|
|
10887
|
+
error,
|
|
10888
|
+
invalid,
|
|
10889
|
+
loading,
|
|
10890
|
+
optional,
|
|
10891
|
+
tooltip,
|
|
10892
|
+
renderErrorMessage: false,
|
|
10893
|
+
wrapperClassName: "min-w-0 flex-1",
|
|
10894
|
+
fieldClassName: cn(
|
|
10895
|
+
variant === "airbnb" ? "min-h-[60px] rounded-l-none rounded-r-[16px] border-l-0" : "rounded-l-none rounded-r-[10px] border-l-0"
|
|
10896
|
+
),
|
|
10897
|
+
contentClassName: cn(variant === "airbnb" ? "h-[40px] py-2" : "h-[48px]"),
|
|
10898
|
+
inputClassName: "text-[16px] leading-7",
|
|
10899
|
+
onChange: (event) => onChange({
|
|
10900
|
+
code: value?.code ?? "",
|
|
10901
|
+
number: event.target.value
|
|
10902
|
+
})
|
|
10903
|
+
}
|
|
10904
|
+
)
|
|
10905
|
+
] }),
|
|
10906
|
+
error && /* @__PURE__ */ (0, import_jsx_runtime132.jsx)(FieldErrorMessage, { message: error })
|
|
10907
|
+
] });
|
|
10908
|
+
}
|
|
10909
|
+
);
|
|
10910
|
+
PhoneField.displayName = "PhoneField";
|
|
10726
10911
|
|
|
10727
10912
|
// src/airbnb/search-input/SearchInput.tsx
|
|
10728
10913
|
var React38 = __toESM(require("react"), 1);
|
|
10729
|
-
var
|
|
10730
|
-
var
|
|
10914
|
+
var import_react_i18next23 = require("react-i18next");
|
|
10915
|
+
var import_lucide_react45 = require("lucide-react");
|
|
10731
10916
|
var import_jsx_runtime133 = require("react/jsx-runtime");
|
|
10732
10917
|
var AirbnbSearchInput = React38.forwardRef(({ onReset, placeholder, wrapperClassName, ...props }, ref) => {
|
|
10733
|
-
const { t } = (0,
|
|
10918
|
+
const { t } = (0, import_react_i18next23.useTranslation)();
|
|
10734
10919
|
const placeholderText = placeholder || t("search_property") + "...";
|
|
10735
10920
|
return /* @__PURE__ */ (0, import_jsx_runtime133.jsxs)("div", { className: cn("input-wrapper relative", wrapperClassName), children: [
|
|
10736
|
-
/* @__PURE__ */ (0, import_jsx_runtime133.jsx)(
|
|
10921
|
+
/* @__PURE__ */ (0, import_jsx_runtime133.jsx)(import_lucide_react45.Search, { className: "absolute left-4 top-1/2 h-5 w-5 -translate-y-1/2 transform text-[#9696B9]" }),
|
|
10737
10922
|
/* @__PURE__ */ (0, import_jsx_runtime133.jsx)(
|
|
10738
10923
|
"input",
|
|
10739
10924
|
{
|
|
@@ -10759,7 +10944,7 @@ var AirbnbSearchInput = React38.forwardRef(({ onReset, placeholder, wrapperClass
|
|
|
10759
10944
|
variant: "ghost",
|
|
10760
10945
|
onClick: onReset,
|
|
10761
10946
|
className: "absolute right-0 top-1/2 h-5 w-5 -translate-y-1/2 transform text-[#9696B9]",
|
|
10762
|
-
children: /* @__PURE__ */ (0, import_jsx_runtime133.jsx)(
|
|
10947
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime133.jsx)(import_lucide_react45.X, { className: "h-5 w-5" })
|
|
10763
10948
|
}
|
|
10764
10949
|
)
|
|
10765
10950
|
] });
|
|
@@ -10768,7 +10953,7 @@ AirbnbSearchInput.displayName = "SearchInput";
|
|
|
10768
10953
|
|
|
10769
10954
|
// src/searchable-select/SearchableSelect.tsx
|
|
10770
10955
|
var React39 = __toESM(require("react"), 1);
|
|
10771
|
-
var
|
|
10956
|
+
var import_lucide_react46 = require("lucide-react");
|
|
10772
10957
|
var import_react_virtual = require("@tanstack/react-virtual");
|
|
10773
10958
|
var import_jsx_runtime134 = require("react/jsx-runtime");
|
|
10774
10959
|
var ROW_HEIGHT = 48;
|
|
@@ -10798,6 +10983,9 @@ var SearchableSelectInternal = ({
|
|
|
10798
10983
|
getValueLabel,
|
|
10799
10984
|
disabled,
|
|
10800
10985
|
error,
|
|
10986
|
+
invalid,
|
|
10987
|
+
optional,
|
|
10988
|
+
tooltip,
|
|
10801
10989
|
hideErrorMessage,
|
|
10802
10990
|
name,
|
|
10803
10991
|
className,
|
|
@@ -10834,10 +11022,16 @@ var SearchableSelectInternal = ({
|
|
|
10834
11022
|
);
|
|
10835
11023
|
const helperText = placeholder ?? label;
|
|
10836
11024
|
const valueLabel = value ? getValueLabel?.(value) ?? String(value.label) : void 0;
|
|
11025
|
+
const isBlocked = Boolean(disabled) || Boolean(loading);
|
|
11026
|
+
const triggerError = error ?? invalid;
|
|
10837
11027
|
const describedBy = error && !hideErrorMessage ? errorId : void 0;
|
|
10838
11028
|
const activeOptionId = highlightedIndex >= 0 ? getOptionId(reactId, highlightedIndex) : void 0;
|
|
10839
11029
|
useOutsideClick(containerRef, open && !isMobile ? () => closeSelect() : null);
|
|
10840
11030
|
React39.useEffect(() => {
|
|
11031
|
+
if (isBlocked) {
|
|
11032
|
+
setSelectOpen(false);
|
|
11033
|
+
return;
|
|
11034
|
+
}
|
|
10841
11035
|
if (!open) return;
|
|
10842
11036
|
const frameId = window.requestAnimationFrame(() => {
|
|
10843
11037
|
inputRef.current?.focus();
|
|
@@ -10845,7 +11039,7 @@ var SearchableSelectInternal = ({
|
|
|
10845
11039
|
return () => {
|
|
10846
11040
|
window.cancelAnimationFrame(frameId);
|
|
10847
11041
|
};
|
|
10848
|
-
}, [open]);
|
|
11042
|
+
}, [isBlocked, open]);
|
|
10849
11043
|
React39.useEffect(() => {
|
|
10850
11044
|
if (!open) {
|
|
10851
11045
|
setHighlightedIndex(-1);
|
|
@@ -10866,7 +11060,7 @@ var SearchableSelectInternal = ({
|
|
|
10866
11060
|
}
|
|
10867
11061
|
}
|
|
10868
11062
|
function openSelect() {
|
|
10869
|
-
if (
|
|
11063
|
+
if (isBlocked) return;
|
|
10870
11064
|
setSelectOpen(true);
|
|
10871
11065
|
}
|
|
10872
11066
|
function closeSelect() {
|
|
@@ -10879,7 +11073,7 @@ var SearchableSelectInternal = ({
|
|
|
10879
11073
|
onSearchChange?.(nextValue);
|
|
10880
11074
|
}
|
|
10881
11075
|
function handleSelect(option) {
|
|
10882
|
-
if (
|
|
11076
|
+
if (isBlocked || option.isDisabled) return;
|
|
10883
11077
|
onChange(option);
|
|
10884
11078
|
setSelectOpen(false, { restoreFocus: true });
|
|
10885
11079
|
}
|
|
@@ -10891,7 +11085,7 @@ var SearchableSelectInternal = ({
|
|
|
10891
11085
|
}
|
|
10892
11086
|
}
|
|
10893
11087
|
function handleTriggerKeyDown(event) {
|
|
10894
|
-
if (
|
|
11088
|
+
if (isBlocked) return;
|
|
10895
11089
|
if (event.key === "Enter" || event.key === " " || event.key === "ArrowDown" || event.key === "ArrowUp") {
|
|
10896
11090
|
event.preventDefault();
|
|
10897
11091
|
openSelect();
|
|
@@ -10949,7 +11143,7 @@ var SearchableSelectInternal = ({
|
|
|
10949
11143
|
}
|
|
10950
11144
|
);
|
|
10951
11145
|
React39.useImperativeHandle(ref, () => triggerRef.current, []);
|
|
10952
|
-
return /* @__PURE__ */ (0, import_jsx_runtime134.jsxs)("div", { ref: containerRef, className: cn("relative w-full max-w-[
|
|
11146
|
+
return /* @__PURE__ */ (0, import_jsx_runtime134.jsxs)("div", { ref: containerRef, className: cn("relative w-full max-w-[425px]", className), children: [
|
|
10953
11147
|
name && /* @__PURE__ */ (0, import_jsx_runtime134.jsx)("input", { type: "hidden", name, value: value ? String(value.value) : "" }),
|
|
10954
11148
|
/* @__PURE__ */ (0, import_jsx_runtime134.jsx)(
|
|
10955
11149
|
FieldTrigger,
|
|
@@ -10970,7 +11164,11 @@ var SearchableSelectInternal = ({
|
|
|
10970
11164
|
valueText: valueLabel,
|
|
10971
11165
|
placeholder: helperText,
|
|
10972
11166
|
describedBy,
|
|
10973
|
-
error,
|
|
11167
|
+
error: triggerError,
|
|
11168
|
+
loading,
|
|
11169
|
+
optional,
|
|
11170
|
+
tooltip,
|
|
11171
|
+
forceLabelText: Boolean(optional) || Boolean(tooltip),
|
|
10974
11172
|
hideErrorMessage,
|
|
10975
11173
|
disabled,
|
|
10976
11174
|
onClick: () => {
|
|
@@ -10982,7 +11180,7 @@ var SearchableSelectInternal = ({
|
|
|
10982
11180
|
},
|
|
10983
11181
|
onKeyDown: handleTriggerKeyDown,
|
|
10984
11182
|
trailingAdornment: /* @__PURE__ */ (0, import_jsx_runtime134.jsx)(
|
|
10985
|
-
|
|
11183
|
+
import_lucide_react46.ChevronDown,
|
|
10986
11184
|
{
|
|
10987
11185
|
className: cn(
|
|
10988
11186
|
"h-6 w-6 text-[#1F1F1B] transition-transform",
|
|
@@ -10997,6 +11195,7 @@ var SearchableSelectInternal = ({
|
|
|
10997
11195
|
{
|
|
10998
11196
|
open,
|
|
10999
11197
|
onOpenChange: (nextOpen) => {
|
|
11198
|
+
if (isBlocked && nextOpen) return;
|
|
11000
11199
|
if (nextOpen) {
|
|
11001
11200
|
setSelectOpen(true);
|
|
11002
11201
|
return;
|
|
@@ -11079,7 +11278,7 @@ function SearchableSelectContent({
|
|
|
11079
11278
|
return /* @__PURE__ */ (0, import_jsx_runtime134.jsxs)("div", { className: "p-2", children: [
|
|
11080
11279
|
/* @__PURE__ */ (0, import_jsx_runtime134.jsxs)("div", { className: "relative mb-2", children: [
|
|
11081
11280
|
/* @__PURE__ */ (0, import_jsx_runtime134.jsx)(
|
|
11082
|
-
|
|
11281
|
+
import_lucide_react46.Search,
|
|
11083
11282
|
{
|
|
11084
11283
|
"aria-hidden": "true",
|
|
11085
11284
|
className: "absolute left-4 top-1/2 h-5 w-5 -translate-y-1/2 text-[#9696B9]"
|