@chekinapp/ui 0.0.115 → 0.0.116
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 +274 -80
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +27 -5
- package/dist/index.d.ts +27 -5
- package/dist/index.js +285 -92
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -42,6 +42,7 @@ __export(index_exports, {
|
|
|
42
42
|
AirbnbSearchInput: () => AirbnbSearchInput,
|
|
43
43
|
AirbnbSearchableSelect: () => AirbnbSearchableSelect,
|
|
44
44
|
AirbnbSelect: () => AirbnbSelect,
|
|
45
|
+
AirbnbSwitch: () => AirbnbSwitch,
|
|
45
46
|
Alert: () => Alert,
|
|
46
47
|
AlertBox: () => AlertBox,
|
|
47
48
|
AlertDescription: () => AlertDescription,
|
|
@@ -5147,7 +5148,7 @@ function Header2({ children, className, ...props }) {
|
|
|
5147
5148
|
"h2",
|
|
5148
5149
|
{
|
|
5149
5150
|
className: cn(
|
|
5150
|
-
"m-0 flex items-center gap-2 self-stretch p-0 text-2xl font-semibold leading-normal text-[var(--
|
|
5151
|
+
"m-0 flex items-center gap-2 self-stretch p-0 text-2xl font-semibold leading-normal text-[var(--form-box-title-color)]",
|
|
5151
5152
|
className
|
|
5152
5153
|
),
|
|
5153
5154
|
...props,
|
|
@@ -5163,7 +5164,7 @@ function Root11({ children, nested, className, ...props }) {
|
|
|
5163
5164
|
"div",
|
|
5164
5165
|
{
|
|
5165
5166
|
className: cn(
|
|
5166
|
-
"flex max-w-[1400px] flex-col items-start gap-6 self-stretch rounded-[
|
|
5167
|
+
"flex max-w-[1400px] flex-col items-start gap-6 self-stretch rounded-[var(--form-box-radius)] border border-[var(--form-box-border)] p-6 [container-type:inline-size]",
|
|
5167
5168
|
nested && "border-0 p-0",
|
|
5168
5169
|
className
|
|
5169
5170
|
),
|
|
@@ -5180,7 +5181,7 @@ function SubHeader({ children, className, ...props }) {
|
|
|
5180
5181
|
"h4",
|
|
5181
5182
|
{
|
|
5182
5183
|
className: cn(
|
|
5183
|
-
"m-0 flex items-center gap-2 self-stretch border-b border-[var(--
|
|
5184
|
+
"m-0 flex items-center gap-2 self-stretch border-b border-[var(--form-box-subtitle-border)] px-0 py-2 text-base font-semibold leading-normal text-[var(--form-box-subtitle-color)]",
|
|
5184
5185
|
className
|
|
5185
5186
|
),
|
|
5186
5187
|
...props,
|
|
@@ -12871,6 +12872,23 @@ var React45 = __toESM(require("react"), 1);
|
|
|
12871
12872
|
var import_react_i18next28 = require("react-i18next");
|
|
12872
12873
|
|
|
12873
12874
|
// src/dashboard/_select-internals/utils.ts
|
|
12875
|
+
function isOptionGroup(item) {
|
|
12876
|
+
return Boolean(
|
|
12877
|
+
item && Array.isArray(item.options)
|
|
12878
|
+
);
|
|
12879
|
+
}
|
|
12880
|
+
function flattenGroupedOptions(items) {
|
|
12881
|
+
if (!items) return [];
|
|
12882
|
+
const result = [];
|
|
12883
|
+
for (const item of items) {
|
|
12884
|
+
if (isOptionGroup(item)) {
|
|
12885
|
+
for (const option of item.options) result.push(option);
|
|
12886
|
+
} else {
|
|
12887
|
+
result.push(item);
|
|
12888
|
+
}
|
|
12889
|
+
}
|
|
12890
|
+
return result;
|
|
12891
|
+
}
|
|
12874
12892
|
function isOptionEnabled(option, isOptionDisabled) {
|
|
12875
12893
|
if (!option) return false;
|
|
12876
12894
|
if (option.isDisabled) return false;
|
|
@@ -12968,6 +12986,51 @@ function DefaultOption(props) {
|
|
|
12968
12986
|
|
|
12969
12987
|
// src/dashboard/_select-internals/SelectMenu.tsx
|
|
12970
12988
|
var import_jsx_runtime148 = require("react/jsx-runtime");
|
|
12989
|
+
function buildMenuEntries(groupedOptions, options, formatGroupLabel) {
|
|
12990
|
+
if (!groupedOptions || !groupedOptions.some((item) => isOptionGroup(item))) {
|
|
12991
|
+
return options.map((option, index) => ({
|
|
12992
|
+
kind: "option",
|
|
12993
|
+
key: `${String(option.value)}-${index}`,
|
|
12994
|
+
option,
|
|
12995
|
+
flatIndex: index
|
|
12996
|
+
}));
|
|
12997
|
+
}
|
|
12998
|
+
const indexByOption = /* @__PURE__ */ new Map();
|
|
12999
|
+
options.forEach((option, index) => indexByOption.set(option, index));
|
|
13000
|
+
const entries = [];
|
|
13001
|
+
let groupCount = 0;
|
|
13002
|
+
for (const item of groupedOptions) {
|
|
13003
|
+
if (isOptionGroup(item)) {
|
|
13004
|
+
const visible = item.options.filter((option) => indexByOption.has(option));
|
|
13005
|
+
if (visible.length === 0) continue;
|
|
13006
|
+
const label = formatGroupLabel ? formatGroupLabel(item) : item.label;
|
|
13007
|
+
entries.push({
|
|
13008
|
+
kind: "group-label",
|
|
13009
|
+
key: `__group-${groupCount}`,
|
|
13010
|
+
label
|
|
13011
|
+
});
|
|
13012
|
+
groupCount += 1;
|
|
13013
|
+
for (const option of visible) {
|
|
13014
|
+
const flatIndex = indexByOption.get(option);
|
|
13015
|
+
entries.push({
|
|
13016
|
+
kind: "option",
|
|
13017
|
+
key: `${String(option.value)}-${flatIndex}`,
|
|
13018
|
+
option,
|
|
13019
|
+
flatIndex
|
|
13020
|
+
});
|
|
13021
|
+
}
|
|
13022
|
+
} else if (indexByOption.has(item)) {
|
|
13023
|
+
const flatIndex = indexByOption.get(item);
|
|
13024
|
+
entries.push({
|
|
13025
|
+
kind: "option",
|
|
13026
|
+
key: `${String(item.value)}-${flatIndex}`,
|
|
13027
|
+
option: item,
|
|
13028
|
+
flatIndex
|
|
13029
|
+
});
|
|
13030
|
+
}
|
|
13031
|
+
}
|
|
13032
|
+
return entries;
|
|
13033
|
+
}
|
|
12971
13034
|
function SelectMenu({
|
|
12972
13035
|
id,
|
|
12973
13036
|
options,
|
|
@@ -12993,7 +13056,9 @@ function SelectMenu({
|
|
|
12993
13056
|
inputValue = "",
|
|
12994
13057
|
formatOptionLabel,
|
|
12995
13058
|
isOptionSelected: isOptionSelected2,
|
|
12996
|
-
onMenuScrollToBottom
|
|
13059
|
+
onMenuScrollToBottom,
|
|
13060
|
+
groupedOptions,
|
|
13061
|
+
formatGroupLabel
|
|
12997
13062
|
}) {
|
|
12998
13063
|
const { t } = (0, import_react_i18next28.useTranslation)();
|
|
12999
13064
|
const emptyMessage = noOptionsMessage?.() ?? t("no_options");
|
|
@@ -13004,6 +13069,10 @@ function SelectMenu({
|
|
|
13004
13069
|
() => selectedValues ?? (selectedValue ? [selectedValue] : []),
|
|
13005
13070
|
[selectedValues, selectedValue]
|
|
13006
13071
|
);
|
|
13072
|
+
const entries = React45.useMemo(
|
|
13073
|
+
() => buildMenuEntries(groupedOptions, options, formatGroupLabel),
|
|
13074
|
+
[groupedOptions, options, formatGroupLabel]
|
|
13075
|
+
);
|
|
13007
13076
|
const wasAtBottomRef = React45.useRef(false);
|
|
13008
13077
|
const handleScroll = React45.useCallback(
|
|
13009
13078
|
(event) => {
|
|
@@ -13037,31 +13106,43 @@ function SelectMenu({
|
|
|
13037
13106
|
),
|
|
13038
13107
|
children: [
|
|
13039
13108
|
!hasOptions && (emptyContent ?? /* @__PURE__ */ (0, import_jsx_runtime148.jsx)("div", { className: "px-3 py-3 text-left text-[14px] font-medium text-[var(--chekin-color-gray-1)]", children: emptyMessage })),
|
|
13040
|
-
|
|
13109
|
+
entries.map((entry) => {
|
|
13110
|
+
if (entry.kind === "group-label") {
|
|
13111
|
+
return /* @__PURE__ */ (0, import_jsx_runtime148.jsx)(
|
|
13112
|
+
"div",
|
|
13113
|
+
{
|
|
13114
|
+
role: "presentation",
|
|
13115
|
+
className: "px-3 pb-1 pt-2 text-[11px] font-semibold uppercase tracking-wide text-[var(--chekin-color-gray-1)]",
|
|
13116
|
+
children: entry.label
|
|
13117
|
+
},
|
|
13118
|
+
entry.key
|
|
13119
|
+
);
|
|
13120
|
+
}
|
|
13121
|
+
const { option, flatIndex } = entry;
|
|
13041
13122
|
const isSelected = isOptionSelected2 ? isOptionSelected2(option, selectedList) : isOptionSelected(option, selectedValue, selectedValues);
|
|
13042
|
-
const isHighlighted =
|
|
13123
|
+
const isHighlighted = flatIndex === highlightedIndex;
|
|
13043
13124
|
const optionDisabled = Boolean(
|
|
13044
13125
|
disabled || option.isDisabled || isOptionDisabled?.(option)
|
|
13045
13126
|
);
|
|
13046
13127
|
return /* @__PURE__ */ (0, import_jsx_runtime148.jsx)(
|
|
13047
13128
|
Option,
|
|
13048
13129
|
{
|
|
13049
|
-
id: getOptionId2(
|
|
13130
|
+
id: getOptionId2(flatIndex),
|
|
13050
13131
|
option,
|
|
13051
|
-
index,
|
|
13132
|
+
index: flatIndex,
|
|
13052
13133
|
isSelected,
|
|
13053
13134
|
isHighlighted,
|
|
13054
13135
|
isDisabled: optionDisabled,
|
|
13055
|
-
isLast:
|
|
13136
|
+
isLast: flatIndex === lastIndex,
|
|
13056
13137
|
isMulti: Boolean(isMulti),
|
|
13057
13138
|
onClick: onOptionClick,
|
|
13058
13139
|
onHover: onOptionHover ?? (() => void 0),
|
|
13059
|
-
innerRef: (node) => selectedOptionRef?.(
|
|
13140
|
+
innerRef: (node) => selectedOptionRef?.(flatIndex, node),
|
|
13060
13141
|
inputValue,
|
|
13061
13142
|
selectedOptions: selectedList,
|
|
13062
13143
|
formatOptionLabel
|
|
13063
13144
|
},
|
|
13064
|
-
|
|
13145
|
+
entry.key
|
|
13065
13146
|
);
|
|
13066
13147
|
}),
|
|
13067
13148
|
footer
|
|
@@ -13991,7 +14072,9 @@ function DefaultMenuList(props) {
|
|
|
13991
14072
|
inputValue,
|
|
13992
14073
|
formatOptionLabel,
|
|
13993
14074
|
isOptionSelected: isOptionSelected2,
|
|
13994
|
-
onMenuScrollToBottom
|
|
14075
|
+
onMenuScrollToBottom,
|
|
14076
|
+
groupedOptions,
|
|
14077
|
+
formatGroupLabel
|
|
13995
14078
|
} = props;
|
|
13996
14079
|
return /* @__PURE__ */ (0, import_jsx_runtime156.jsx)(
|
|
13997
14080
|
SelectMenu,
|
|
@@ -14019,7 +14102,9 @@ function DefaultMenuList(props) {
|
|
|
14019
14102
|
inputValue,
|
|
14020
14103
|
formatOptionLabel,
|
|
14021
14104
|
isOptionSelected: isOptionSelected2,
|
|
14022
|
-
onMenuScrollToBottom
|
|
14105
|
+
onMenuScrollToBottom,
|
|
14106
|
+
groupedOptions,
|
|
14107
|
+
formatGroupLabel
|
|
14023
14108
|
}
|
|
14024
14109
|
);
|
|
14025
14110
|
}
|
|
@@ -14111,7 +14196,8 @@ function SelectInternal(props, ref) {
|
|
|
14111
14196
|
searchPosition = "trigger",
|
|
14112
14197
|
menuHeader,
|
|
14113
14198
|
onMenuScrollToBottom,
|
|
14114
|
-
leftIcon
|
|
14199
|
+
leftIcon,
|
|
14200
|
+
formatGroupLabel
|
|
14115
14201
|
} = props;
|
|
14116
14202
|
const isSearchInDropdown = searchPosition === "dropdown";
|
|
14117
14203
|
const isMulti = props.isMulti === true;
|
|
@@ -14132,9 +14218,10 @@ function SelectInternal(props, ref) {
|
|
|
14132
14218
|
},
|
|
14133
14219
|
[isMulti, props.onChange]
|
|
14134
14220
|
);
|
|
14221
|
+
const flatOptions = React49.useMemo(() => flattenGroupedOptions(options), [options]);
|
|
14135
14222
|
const state = useSelectState({
|
|
14136
14223
|
isMulti,
|
|
14137
|
-
options,
|
|
14224
|
+
options: flatOptions,
|
|
14138
14225
|
selectedOptions,
|
|
14139
14226
|
onSelectionChange,
|
|
14140
14227
|
filterOption,
|
|
@@ -14305,7 +14392,9 @@ function SelectInternal(props, ref) {
|
|
|
14305
14392
|
inputValue: state.inputValue,
|
|
14306
14393
|
formatOptionLabel,
|
|
14307
14394
|
isOptionSelected: isOptionSelected2,
|
|
14308
|
-
onMenuScrollToBottom
|
|
14395
|
+
onMenuScrollToBottom,
|
|
14396
|
+
groupedOptions: options,
|
|
14397
|
+
formatGroupLabel
|
|
14309
14398
|
}
|
|
14310
14399
|
),
|
|
14311
14400
|
state.canCreateNewOption && /* @__PURE__ */ (0, import_jsx_runtime158.jsx)(
|
|
@@ -15128,19 +15217,33 @@ function SelectCheckboxesInternal(props, ref) {
|
|
|
15128
15217
|
);
|
|
15129
15218
|
const [inputValue, setInputValue] = React59.useState("");
|
|
15130
15219
|
const selected = value ?? [];
|
|
15131
|
-
const
|
|
15220
|
+
const flatRawOptions = React59.useMemo(
|
|
15221
|
+
() => flattenGroupedOptions(rawOptions),
|
|
15222
|
+
[rawOptions]
|
|
15223
|
+
);
|
|
15224
|
+
const filteredGrouped = React59.useMemo(() => {
|
|
15132
15225
|
const trimmed = inputValue.trim();
|
|
15133
15226
|
if (!trimmed) return rawOptions;
|
|
15134
|
-
return rawOptions.
|
|
15227
|
+
return rawOptions.map((item) => {
|
|
15228
|
+
if (isOptionGroup(item)) {
|
|
15229
|
+
const opts = item.options.filter((o) => filterOption(o, trimmed));
|
|
15230
|
+
return opts.length > 0 ? { ...item, options: opts } : null;
|
|
15231
|
+
}
|
|
15232
|
+
return filterOption(item, trimmed) ? item : null;
|
|
15233
|
+
}).filter((item) => item !== null);
|
|
15135
15234
|
}, [rawOptions, inputValue, filterOption]);
|
|
15136
|
-
const
|
|
15235
|
+
const filteredFlat = React59.useMemo(
|
|
15236
|
+
() => flattenGroupedOptions(filteredGrouped),
|
|
15237
|
+
[filteredGrouped]
|
|
15238
|
+
);
|
|
15239
|
+
const visibleSelectedCount = filteredFlat.reduce((acc, option) => {
|
|
15137
15240
|
return acc + (selected.some((s) => s.value === option.value) ? 1 : 0);
|
|
15138
15241
|
}, 0);
|
|
15139
|
-
const allVisibleSelected =
|
|
15140
|
-
const someVisibleSelected = visibleSelectedCount > 0 && visibleSelectedCount <
|
|
15242
|
+
const allVisibleSelected = filteredFlat.length > 0 && visibleSelectedCount === filteredFlat.length;
|
|
15243
|
+
const someVisibleSelected = visibleSelectedCount > 0 && visibleSelectedCount < filteredFlat.length;
|
|
15141
15244
|
const handleToggleAll = React59.useCallback(() => {
|
|
15142
15245
|
if (allVisibleSelected) {
|
|
15143
|
-
const visibleValues = new Set(
|
|
15246
|
+
const visibleValues = new Set(filteredFlat.map((option) => option.value));
|
|
15144
15247
|
onChange(
|
|
15145
15248
|
selected.filter((s) => !visibleValues.has(s.value)),
|
|
15146
15249
|
{ action: "deselect" }
|
|
@@ -15148,18 +15251,18 @@ function SelectCheckboxesInternal(props, ref) {
|
|
|
15148
15251
|
return;
|
|
15149
15252
|
}
|
|
15150
15253
|
const merged = [...selected];
|
|
15151
|
-
for (const option of
|
|
15254
|
+
for (const option of filteredFlat) {
|
|
15152
15255
|
if (!merged.some((s) => s.value === option.value)) merged.push(option);
|
|
15153
15256
|
}
|
|
15154
15257
|
onChange(merged, { action: "select" });
|
|
15155
|
-
}, [allVisibleSelected,
|
|
15258
|
+
}, [allVisibleSelected, filteredFlat, onChange, selected]);
|
|
15156
15259
|
const Control = React59.useMemo(() => {
|
|
15157
15260
|
if (trigger) return makeTriggerSlot2(trigger);
|
|
15158
15261
|
return createCountTrigger({
|
|
15159
15262
|
valueText,
|
|
15160
|
-
totalCount:
|
|
15263
|
+
totalCount: flatRawOptions.length
|
|
15161
15264
|
});
|
|
15162
|
-
}, [trigger, valueText,
|
|
15265
|
+
}, [trigger, valueText, flatRawOptions.length]);
|
|
15163
15266
|
const components = React59.useMemo(
|
|
15164
15267
|
() => ({
|
|
15165
15268
|
...userComponents,
|
|
@@ -15184,11 +15287,10 @@ function SelectCheckboxesInternal(props, ref) {
|
|
|
15184
15287
|
},
|
|
15185
15288
|
[onSearchChange]
|
|
15186
15289
|
);
|
|
15187
|
-
const
|
|
15290
|
+
const baseSharedProps = {
|
|
15188
15291
|
...paginationAndRest,
|
|
15189
15292
|
value,
|
|
15190
15293
|
onChange,
|
|
15191
|
-
options: filteredOptions,
|
|
15192
15294
|
filterOption: passthroughFilter2,
|
|
15193
15295
|
components,
|
|
15194
15296
|
closeMenuOnSelect,
|
|
@@ -15202,7 +15304,10 @@ function SelectCheckboxesInternal(props, ref) {
|
|
|
15202
15304
|
InfiniteScrollSelect,
|
|
15203
15305
|
{
|
|
15204
15306
|
ref,
|
|
15205
|
-
...
|
|
15307
|
+
...{
|
|
15308
|
+
...baseSharedProps,
|
|
15309
|
+
options: filteredFlat
|
|
15310
|
+
}
|
|
15206
15311
|
}
|
|
15207
15312
|
);
|
|
15208
15313
|
}
|
|
@@ -15210,7 +15315,10 @@ function SelectCheckboxesInternal(props, ref) {
|
|
|
15210
15315
|
Select,
|
|
15211
15316
|
{
|
|
15212
15317
|
ref,
|
|
15213
|
-
...
|
|
15318
|
+
...{
|
|
15319
|
+
...baseSharedProps,
|
|
15320
|
+
options: filteredGrouped
|
|
15321
|
+
}
|
|
15214
15322
|
}
|
|
15215
15323
|
);
|
|
15216
15324
|
}
|
|
@@ -16133,7 +16241,7 @@ var Datepicker = React63.forwardRef(
|
|
|
16133
16241
|
hideErrorMessage,
|
|
16134
16242
|
helperText,
|
|
16135
16243
|
width,
|
|
16136
|
-
locale
|
|
16244
|
+
locale,
|
|
16137
16245
|
minDate,
|
|
16138
16246
|
maxDate,
|
|
16139
16247
|
formatValue
|
|
@@ -16152,10 +16260,11 @@ var Datepicker = React63.forwardRef(
|
|
|
16152
16260
|
const yearId = `${baseId}-year`;
|
|
16153
16261
|
const labelId = `${baseId}-label`;
|
|
16154
16262
|
const errorId = `${baseId}-error`;
|
|
16155
|
-
const { t } = (0, import_react_i18next39.useTranslation)();
|
|
16263
|
+
const { t, i18n } = (0, import_react_i18next39.useTranslation)();
|
|
16264
|
+
const resolvedLocale = locale ?? i18n.resolvedLanguage ?? i18n.language ?? "en-US";
|
|
16156
16265
|
const resolvedMonthLabels = React63.useMemo(
|
|
16157
|
-
() => monthLabels ?? getMonthLabels2(
|
|
16158
|
-
[
|
|
16266
|
+
() => monthLabels ?? getMonthLabels2(resolvedLocale),
|
|
16267
|
+
[resolvedLocale, monthLabels]
|
|
16159
16268
|
);
|
|
16160
16269
|
const resolvedMonthPlaceholder = monthPlaceholder ?? t("month");
|
|
16161
16270
|
const resolvedDoneLabel = doneLabel ?? t("done");
|
|
@@ -17954,7 +18063,7 @@ var AirbnbFieldTrigger = React72.forwardRef(
|
|
|
17954
18063
|
const hasLabelMeta = Boolean(optionalLabel) || Boolean(tooltip);
|
|
17955
18064
|
const resolvedLabelText = visibleLabelText && hasLabelMeta ? /* @__PURE__ */ (0, import_jsx_runtime184.jsxs)("span", { className: "inline-flex max-w-full items-center gap-1.5 align-middle", children: [
|
|
17956
18065
|
/* @__PURE__ */ (0, import_jsx_runtime184.jsx)("span", { className: "min-w-0 truncate", children: visibleLabelText }),
|
|
17957
|
-
optionalLabel && /* @__PURE__ */ (0, import_jsx_runtime184.jsxs)("span", { className: "
|
|
18066
|
+
optionalLabel && /* @__PURE__ */ (0, import_jsx_runtime184.jsxs)("span", { className: "text-current opacity-70 lowercase", children: [
|
|
17958
18067
|
"(",
|
|
17959
18068
|
optionalLabel,
|
|
17960
18069
|
")"
|
|
@@ -18008,8 +18117,8 @@ var AirbnbFieldTrigger = React72.forwardRef(
|
|
|
18008
18117
|
{
|
|
18009
18118
|
id: labelId,
|
|
18010
18119
|
className: cn(
|
|
18011
|
-
"absolute left-0 origin-left
|
|
18012
|
-
hasLabelMeta ? "" : "pointer-events-none",
|
|
18120
|
+
"absolute left-0 origin-left transition-all duration-200 ease-out",
|
|
18121
|
+
hasLabelMeta ? "max-w-full" : "pointer-events-none truncate",
|
|
18013
18122
|
isAirbnbVariant ? isRaised ? "top-[-1px] 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-white px-1 text-[12px] font-medium leading-4" : "top-1/2 -translate-y-1/2 text-[16px] leading-6",
|
|
18014
18123
|
hasInvalidState ? "text-[var(--error-message-color)]" : isAirbnbVariant ? "text-[#6c6c6c]" : "text-[#7A8399]"
|
|
18015
18124
|
),
|
|
@@ -18277,6 +18386,8 @@ AirbnbDatePicker.displayName = "AirbnbDatePicker";
|
|
|
18277
18386
|
|
|
18278
18387
|
// src/airbnb-fields/input/Input.tsx
|
|
18279
18388
|
var React74 = __toESM(require("react"), 1);
|
|
18389
|
+
var import_lucide_react54 = require("lucide-react");
|
|
18390
|
+
var import_react_i18next44 = require("react-i18next");
|
|
18280
18391
|
var import_jsx_runtime186 = require("react/jsx-runtime");
|
|
18281
18392
|
var getInputValue = (value) => value != null ? String(value) : "";
|
|
18282
18393
|
var AirbnbInput = React74.forwardRef(
|
|
@@ -18308,6 +18419,7 @@ var AirbnbInput = React74.forwardRef(
|
|
|
18308
18419
|
placeholder,
|
|
18309
18420
|
...props
|
|
18310
18421
|
}, ref) => {
|
|
18422
|
+
const { t } = (0, import_react_i18next44.useTranslation)();
|
|
18311
18423
|
const generatedId = React74.useId();
|
|
18312
18424
|
const inputRef = React74.useRef(null);
|
|
18313
18425
|
const inputId = id ?? generatedId;
|
|
@@ -18316,11 +18428,15 @@ var AirbnbInput = React74.forwardRef(
|
|
|
18316
18428
|
const errorId = `${inputId}-error`;
|
|
18317
18429
|
const accessibleLabel = placeholder ?? label;
|
|
18318
18430
|
const [isFocused, setIsFocused] = React74.useState(false);
|
|
18431
|
+
const [isPasswordRevealed, setIsPasswordRevealed] = React74.useState(false);
|
|
18319
18432
|
const [currentValue, setCurrentValue] = React74.useState(
|
|
18320
18433
|
() => value != null ? getInputValue(value) : getInputValue(defaultValue)
|
|
18321
18434
|
);
|
|
18322
18435
|
const resolvedValue = value != null ? getInputValue(value) : currentValue;
|
|
18323
18436
|
const hasValue = resolvedValue.length > 0;
|
|
18437
|
+
const isPasswordInput = type === "password";
|
|
18438
|
+
const inputType = isPasswordInput && isPasswordRevealed ? "text" : type;
|
|
18439
|
+
const shouldShowPasswordReveal = isPasswordInput && hasValue && !loading;
|
|
18324
18440
|
const shouldShowLabel = hasValue || isFocused;
|
|
18325
18441
|
const hasInvalidState = Boolean(error) || Boolean(invalid);
|
|
18326
18442
|
const triggerError = error ?? invalid;
|
|
@@ -18330,6 +18446,11 @@ var AirbnbInput = React74.forwardRef(
|
|
|
18330
18446
|
const nextValue = value != null ? getInputValue(value) : getInputValue(inputRef.current?.value);
|
|
18331
18447
|
setCurrentValue((prevValue) => prevValue === nextValue ? prevValue : nextValue);
|
|
18332
18448
|
}, [value]);
|
|
18449
|
+
React74.useEffect(() => {
|
|
18450
|
+
if (!isPasswordInput) {
|
|
18451
|
+
setIsPasswordRevealed(false);
|
|
18452
|
+
}
|
|
18453
|
+
}, [isPasswordInput]);
|
|
18333
18454
|
const setRefs = React74.useCallback(
|
|
18334
18455
|
(node) => {
|
|
18335
18456
|
inputRef.current = node;
|
|
@@ -18360,7 +18481,10 @@ var AirbnbInput = React74.forwardRef(
|
|
|
18360
18481
|
setIsFocused(false);
|
|
18361
18482
|
onBlur?.(event);
|
|
18362
18483
|
};
|
|
18363
|
-
|
|
18484
|
+
const togglePasswordReveal = () => {
|
|
18485
|
+
setIsPasswordRevealed((isRevealed) => !isRevealed);
|
|
18486
|
+
};
|
|
18487
|
+
return /* @__PURE__ */ (0, import_jsx_runtime186.jsx)("div", { className: cn("w-full max-w-[var(--max-field-width)]", wrapperClassName), children: /* @__PURE__ */ (0, import_jsx_runtime186.jsxs)(
|
|
18364
18488
|
AirbnbFieldTrigger,
|
|
18365
18489
|
{
|
|
18366
18490
|
as: "div",
|
|
@@ -18388,39 +18512,63 @@ var AirbnbInput = React74.forwardRef(
|
|
|
18388
18512
|
variant === "airbnb" ? "h-[42px]" : "h-[48px]",
|
|
18389
18513
|
contentClassName
|
|
18390
18514
|
),
|
|
18391
|
-
trailingAdornment,
|
|
18515
|
+
trailingAdornment: shouldShowPasswordReveal ? void 0 : trailingAdornment,
|
|
18392
18516
|
forceFloatingLabel: shouldShowLabel,
|
|
18393
18517
|
forceLabelText: hasLabelMeta,
|
|
18394
18518
|
hideErrorMessage: !renderErrorMessage,
|
|
18395
|
-
children:
|
|
18396
|
-
|
|
18397
|
-
|
|
18398
|
-
|
|
18399
|
-
|
|
18400
|
-
|
|
18401
|
-
|
|
18402
|
-
|
|
18403
|
-
|
|
18404
|
-
|
|
18405
|
-
|
|
18406
|
-
|
|
18407
|
-
|
|
18408
|
-
|
|
18409
|
-
|
|
18410
|
-
|
|
18411
|
-
|
|
18412
|
-
|
|
18413
|
-
|
|
18414
|
-
|
|
18415
|
-
|
|
18416
|
-
|
|
18417
|
-
|
|
18418
|
-
|
|
18419
|
-
|
|
18420
|
-
|
|
18421
|
-
|
|
18422
|
-
|
|
18423
|
-
|
|
18519
|
+
children: [
|
|
18520
|
+
/* @__PURE__ */ (0, import_jsx_runtime186.jsx)(
|
|
18521
|
+
"input",
|
|
18522
|
+
{
|
|
18523
|
+
...props,
|
|
18524
|
+
id: inputId,
|
|
18525
|
+
ref: setRefs,
|
|
18526
|
+
type: inputType,
|
|
18527
|
+
disabled: isBlocked,
|
|
18528
|
+
value,
|
|
18529
|
+
defaultValue,
|
|
18530
|
+
onChange: handleChange,
|
|
18531
|
+
onFocus: handleFocus,
|
|
18532
|
+
onBlur: handleBlur,
|
|
18533
|
+
placeholder: "",
|
|
18534
|
+
"aria-invalid": hasInvalidState,
|
|
18535
|
+
"aria-busy": loading,
|
|
18536
|
+
"aria-describedby": error && renderErrorMessage ? errorId : void 0,
|
|
18537
|
+
"aria-label": accessibleLabel && hasLabelMeta ? accessibleLabel : void 0,
|
|
18538
|
+
"aria-labelledby": accessibleLabel && !hasLabelMeta ? labelId : void 0,
|
|
18539
|
+
className: cn(
|
|
18540
|
+
"absolute left-0 h-6 w-full border-0 bg-transparent p-0 text-[16px] leading-6 text-[#1F1F1B] outline-none placeholder:text-[#7A8399]",
|
|
18541
|
+
variant === "airbnb" ? "bottom-0" : "bottom-[12px]",
|
|
18542
|
+
hasInvalidState ? "text-[var(--status-danger)] placeholder:text-[var(--status-danger)]" : "",
|
|
18543
|
+
disabled ? "cursor-not-allowed" : loading ? "cursor-progress" : "",
|
|
18544
|
+
shouldShowPasswordReveal ? "pr-8" : "",
|
|
18545
|
+
inputClassName,
|
|
18546
|
+
className
|
|
18547
|
+
)
|
|
18548
|
+
}
|
|
18549
|
+
),
|
|
18550
|
+
shouldShowPasswordReveal && /* @__PURE__ */ (0, import_jsx_runtime186.jsx)(
|
|
18551
|
+
"button",
|
|
18552
|
+
{
|
|
18553
|
+
type: "button",
|
|
18554
|
+
onClick: togglePasswordReveal,
|
|
18555
|
+
disabled: isBlocked,
|
|
18556
|
+
className: cn(
|
|
18557
|
+
"absolute right-0 flex h-6 w-6 items-center justify-center border-0 bg-transparent p-0 text-[#7A8399] hover:text-[#1F1F1B] hover:opacity-85 disabled:cursor-not-allowed disabled:opacity-50",
|
|
18558
|
+
variant === "airbnb" ? "bottom-0" : "bottom-[12px]"
|
|
18559
|
+
),
|
|
18560
|
+
"aria-label": isPasswordRevealed ? t("hide_password") : t("show_password"),
|
|
18561
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime186.jsx)(
|
|
18562
|
+
import_lucide_react54.Eye,
|
|
18563
|
+
{
|
|
18564
|
+
size: 18,
|
|
18565
|
+
"aria-hidden": "true",
|
|
18566
|
+
className: cn(isPasswordRevealed ? "text-[#fc98dd]" : "")
|
|
18567
|
+
}
|
|
18568
|
+
)
|
|
18569
|
+
}
|
|
18570
|
+
)
|
|
18571
|
+
]
|
|
18424
18572
|
}
|
|
18425
18573
|
) });
|
|
18426
18574
|
}
|
|
@@ -18429,7 +18577,7 @@ AirbnbInput.displayName = "AirbnbInput";
|
|
|
18429
18577
|
|
|
18430
18578
|
// src/airbnb-fields/phone-field/PhoneField.tsx
|
|
18431
18579
|
var React80 = __toESM(require("react"), 1);
|
|
18432
|
-
var
|
|
18580
|
+
var import_lucide_react56 = require("lucide-react");
|
|
18433
18581
|
|
|
18434
18582
|
// src/airbnb-fields/select/Select.tsx
|
|
18435
18583
|
var React79 = __toESM(require("react"), 1);
|
|
@@ -18778,7 +18926,7 @@ function AirbnbSelectMobileContent({
|
|
|
18778
18926
|
|
|
18779
18927
|
// src/airbnb-fields/select/SelectTrigger.tsx
|
|
18780
18928
|
var React75 = __toESM(require("react"), 1);
|
|
18781
|
-
var
|
|
18929
|
+
var import_lucide_react55 = require("lucide-react");
|
|
18782
18930
|
var import_jsx_runtime191 = require("react/jsx-runtime");
|
|
18783
18931
|
var AirbnbSelectTrigger = React75.forwardRef(
|
|
18784
18932
|
({
|
|
@@ -18835,7 +18983,7 @@ var AirbnbSelectTrigger = React75.forwardRef(
|
|
|
18835
18983
|
onKeyDown,
|
|
18836
18984
|
onBlur,
|
|
18837
18985
|
trailingAdornment: /* @__PURE__ */ (0, import_jsx_runtime191.jsx)(
|
|
18838
|
-
|
|
18986
|
+
import_lucide_react55.ChevronDown,
|
|
18839
18987
|
{
|
|
18840
18988
|
className: open ? "h-6 w-6 rotate-180 text-[#1F1F1B] transition-transform" : "h-6 w-6 text-[#1F1F1B] transition-transform"
|
|
18841
18989
|
}
|
|
@@ -19622,7 +19770,7 @@ var AirbnbPhoneField = React80.forwardRef(
|
|
|
19622
19770
|
children: [
|
|
19623
19771
|
/* @__PURE__ */ (0, import_jsx_runtime193.jsx)("span", { children: valueLabel ?? codePlaceholder }),
|
|
19624
19772
|
/* @__PURE__ */ (0, import_jsx_runtime193.jsx)(
|
|
19625
|
-
|
|
19773
|
+
import_lucide_react56.ChevronDown,
|
|
19626
19774
|
{
|
|
19627
19775
|
className: cn("h-5 w-5 transition-transform", open ? "rotate-180" : ""),
|
|
19628
19776
|
strokeWidth: 2
|
|
@@ -19673,7 +19821,7 @@ AirbnbPhoneField.displayName = "AirbnbPhoneField";
|
|
|
19673
19821
|
|
|
19674
19822
|
// src/airbnb-fields/searchable-select/SearchableSelect.tsx
|
|
19675
19823
|
var React81 = __toESM(require("react"), 1);
|
|
19676
|
-
var
|
|
19824
|
+
var import_lucide_react57 = require("lucide-react");
|
|
19677
19825
|
var import_react_virtual3 = require("@tanstack/react-virtual");
|
|
19678
19826
|
var import_react90 = require("react");
|
|
19679
19827
|
var import_jsx_runtime194 = require("react/jsx-runtime");
|
|
@@ -19911,7 +20059,7 @@ var AirbnbSearchableSelectInternal = ({
|
|
|
19911
20059
|
onKeyDown: handleTriggerKeyDown,
|
|
19912
20060
|
onBlur,
|
|
19913
20061
|
trailingAdornment: /* @__PURE__ */ (0, import_jsx_runtime194.jsx)(
|
|
19914
|
-
|
|
20062
|
+
import_lucide_react57.ChevronDown,
|
|
19915
20063
|
{
|
|
19916
20064
|
className: cn(
|
|
19917
20065
|
"h-6 w-6 text-[#1F1F1B] transition-transform",
|
|
@@ -20009,7 +20157,7 @@ function AirbnbSearchableSelectContent({
|
|
|
20009
20157
|
return /* @__PURE__ */ (0, import_jsx_runtime194.jsxs)("div", { className: "p-2", children: [
|
|
20010
20158
|
/* @__PURE__ */ (0, import_jsx_runtime194.jsxs)("div", { className: "relative mb-2", children: [
|
|
20011
20159
|
/* @__PURE__ */ (0, import_jsx_runtime194.jsx)(
|
|
20012
|
-
|
|
20160
|
+
import_lucide_react57.Search,
|
|
20013
20161
|
{
|
|
20014
20162
|
"aria-hidden": "true",
|
|
20015
20163
|
className: "absolute left-4 top-1/2 h-5 w-5 -translate-y-1/2 text-[#9696B9]"
|
|
@@ -20118,14 +20266,14 @@ function getNextEnabledIndex(options, startIndex, step) {
|
|
|
20118
20266
|
|
|
20119
20267
|
// src/airbnb-fields/search-input/SearchInput.tsx
|
|
20120
20268
|
var React82 = __toESM(require("react"), 1);
|
|
20121
|
-
var
|
|
20122
|
-
var
|
|
20269
|
+
var import_react_i18next45 = require("react-i18next");
|
|
20270
|
+
var import_lucide_react58 = require("lucide-react");
|
|
20123
20271
|
var import_jsx_runtime195 = require("react/jsx-runtime");
|
|
20124
20272
|
var AirbnbSearchInput = React82.forwardRef(({ onReset, placeholder, wrapperClassName, ...props }, ref) => {
|
|
20125
|
-
const { t } = (0,
|
|
20273
|
+
const { t } = (0, import_react_i18next45.useTranslation)();
|
|
20126
20274
|
const placeholderText = placeholder || t("search_property") + "...";
|
|
20127
20275
|
return /* @__PURE__ */ (0, import_jsx_runtime195.jsxs)("div", { className: cn("input-wrapper relative", wrapperClassName), children: [
|
|
20128
|
-
/* @__PURE__ */ (0, import_jsx_runtime195.jsx)(
|
|
20276
|
+
/* @__PURE__ */ (0, import_jsx_runtime195.jsx)(import_lucide_react58.Search, { className: "absolute left-4 top-1/2 h-5 w-5 -translate-y-1/2 transform text-[#9696B9]" }),
|
|
20129
20277
|
/* @__PURE__ */ (0, import_jsx_runtime195.jsx)(
|
|
20130
20278
|
"input",
|
|
20131
20279
|
{
|
|
@@ -20151,12 +20299,57 @@ var AirbnbSearchInput = React82.forwardRef(({ onReset, placeholder, wrapperClass
|
|
|
20151
20299
|
variant: "ghost",
|
|
20152
20300
|
onClick: onReset,
|
|
20153
20301
|
className: "absolute right-0 top-1/2 h-5 w-5 -translate-y-1/2 transform text-[#9696B9]",
|
|
20154
|
-
children: /* @__PURE__ */ (0, import_jsx_runtime195.jsx)(
|
|
20302
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime195.jsx)(import_lucide_react58.X, { className: "h-5 w-5" })
|
|
20155
20303
|
}
|
|
20156
20304
|
)
|
|
20157
20305
|
] });
|
|
20158
20306
|
});
|
|
20159
20307
|
AirbnbSearchInput.displayName = "AirbnbSearchInput";
|
|
20308
|
+
|
|
20309
|
+
// src/airbnb-fields/switch/Switch.tsx
|
|
20310
|
+
var React83 = __toESM(require("react"), 1);
|
|
20311
|
+
var SwitchPrimitives2 = __toESM(require("@radix-ui/react-switch"), 1);
|
|
20312
|
+
var import_lucide_react59 = require("lucide-react");
|
|
20313
|
+
var import_jsx_runtime196 = require("react/jsx-runtime");
|
|
20314
|
+
var AirbnbSwitch = React83.forwardRef(({ className, value, onChange, disabled, loading, readOnly, ...props }, ref) => /* @__PURE__ */ (0, import_jsx_runtime196.jsx)(
|
|
20315
|
+
SwitchPrimitives2.Root,
|
|
20316
|
+
{
|
|
20317
|
+
ref,
|
|
20318
|
+
className: cn(
|
|
20319
|
+
"group inline-flex h-[24px] w-[36px] shrink-0 cursor-pointer items-center rounded-full border border-solid border-transparent p-[2px] transition-colors duration-200",
|
|
20320
|
+
"focus-visible:outline-none focus-visible:shadow-[var(--chekin-shadow-focus)]",
|
|
20321
|
+
"disabled:cursor-not-allowed disabled:opacity-50 aria-busy:cursor-wait aria-busy:opacity-50",
|
|
20322
|
+
"aria-readonly:cursor-default aria-readonly:opacity-100",
|
|
20323
|
+
"data-[state=checked]:bg-[#222222] data-[state=unchecked]:bg-[#E7E7E4]",
|
|
20324
|
+
className
|
|
20325
|
+
),
|
|
20326
|
+
disabled,
|
|
20327
|
+
checked: value,
|
|
20328
|
+
value: String(value),
|
|
20329
|
+
onCheckedChange: !disabled && !readOnly ? onChange : void 0,
|
|
20330
|
+
"aria-busy": loading,
|
|
20331
|
+
"aria-readonly": readOnly,
|
|
20332
|
+
...props,
|
|
20333
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime196.jsx)(
|
|
20334
|
+
SwitchPrimitives2.Thumb,
|
|
20335
|
+
{
|
|
20336
|
+
className: cn(
|
|
20337
|
+
"flex h-[20px] w-[20px] items-center justify-center rounded-full bg-white shadow-[0_1px_3px_rgba(0,0,0,0.22)] transition-transform duration-200",
|
|
20338
|
+
"data-[state=checked]:translate-x-[12px] data-[state=unchecked]:translate-x-0"
|
|
20339
|
+
),
|
|
20340
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime196.jsx)(
|
|
20341
|
+
import_lucide_react59.Check,
|
|
20342
|
+
{
|
|
20343
|
+
"aria-hidden": "true",
|
|
20344
|
+
className: "h-3 w-3 text-[#222222] opacity-0 transition-opacity duration-150 group-data-[state=checked]:opacity-100",
|
|
20345
|
+
strokeWidth: 3
|
|
20346
|
+
}
|
|
20347
|
+
)
|
|
20348
|
+
}
|
|
20349
|
+
)
|
|
20350
|
+
}
|
|
20351
|
+
));
|
|
20352
|
+
AirbnbSwitch.displayName = "AirbnbSwitch";
|
|
20160
20353
|
// Annotate the CommonJS export names for ESM import in node:
|
|
20161
20354
|
0 && (module.exports = {
|
|
20162
20355
|
ALERT_BOX_VARIANTS,
|
|
@@ -20171,6 +20364,7 @@ AirbnbSearchInput.displayName = "AirbnbSearchInput";
|
|
|
20171
20364
|
AirbnbSearchInput,
|
|
20172
20365
|
AirbnbSearchableSelect,
|
|
20173
20366
|
AirbnbSelect,
|
|
20367
|
+
AirbnbSwitch,
|
|
20174
20368
|
Alert,
|
|
20175
20369
|
AlertBox,
|
|
20176
20370
|
AlertDescription,
|