@chekinapp/ui 0.0.138 → 0.0.140
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 +237 -187
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +10 -2
- package/dist/index.d.ts +10 -2
- package/dist/index.js +237 -187
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -13338,8 +13338,8 @@ function ComboboxTrigger({
|
|
|
13338
13338
|
"span",
|
|
13339
13339
|
{
|
|
13340
13340
|
className: cn(
|
|
13341
|
-
"grid min-w-0 max-w-full
|
|
13342
|
-
isMulti
|
|
13341
|
+
"grid min-w-0 max-w-full",
|
|
13342
|
+
isMulti ? "w-min flex-none min-w-[40px]" : "w-full overflow-hidden",
|
|
13343
13343
|
!searchable && "sr-only"
|
|
13344
13344
|
),
|
|
13345
13345
|
children: [
|
|
@@ -13371,7 +13371,7 @@ function ComboboxTrigger({
|
|
|
13371
13371
|
"aria-activedescendant": activeOptionId,
|
|
13372
13372
|
className: cn(
|
|
13373
13373
|
"col-start-1 row-start-1 m-0 box-border w-full min-w-0 border-0 bg-transparent p-0 text-[16px] font-medium leading-5 text-[var(--chekin-color-brand-navy)] outline-none placeholder:text-[var(--chekin-color-gray-1)]",
|
|
13374
|
-
isMulti
|
|
13374
|
+
isMulti ? "min-w-[40px]" : "text-ellipsis",
|
|
13375
13375
|
readOnly && !disabled && !loading && "cursor-default",
|
|
13376
13376
|
disabled && !loading && "cursor-not-allowed",
|
|
13377
13377
|
loading && "!cursor-progress",
|
|
@@ -13527,6 +13527,7 @@ function useSelectState(params) {
|
|
|
13527
13527
|
onKeyDown,
|
|
13528
13528
|
onFocus,
|
|
13529
13529
|
onBlur,
|
|
13530
|
+
inputValue: controlledInputValue,
|
|
13530
13531
|
onInputChange,
|
|
13531
13532
|
isSearchInDropdown,
|
|
13532
13533
|
searchable = true
|
|
@@ -13544,9 +13545,17 @@ function useSelectState(params) {
|
|
|
13544
13545
|
[singleSelected, getValueLabel]
|
|
13545
13546
|
);
|
|
13546
13547
|
const isSearchOnlyInput = searchable && (isMulti || Boolean(isSearchInDropdown));
|
|
13547
|
-
const
|
|
13548
|
+
const isInputControlled = controlledInputValue !== void 0;
|
|
13549
|
+
const [internalInputValue, setInternalInputValue] = React48.useState(
|
|
13548
13550
|
searchable && !isSearchOnlyInput ? valueLabel : ""
|
|
13549
13551
|
);
|
|
13552
|
+
const inputValue = isInputControlled ? controlledInputValue : internalInputValue;
|
|
13553
|
+
const setInputValue = React48.useCallback(
|
|
13554
|
+
(next) => {
|
|
13555
|
+
if (!isInputControlled) setInternalInputValue(next);
|
|
13556
|
+
},
|
|
13557
|
+
[isInputControlled]
|
|
13558
|
+
);
|
|
13550
13559
|
const hasValue = selectedOptions.length > 0;
|
|
13551
13560
|
const isBlocked = Boolean(disabled) || Boolean(loading) || Boolean(readOnly);
|
|
13552
13561
|
const hasInvalidState = Boolean(error);
|
|
@@ -13713,7 +13722,7 @@ function useSelectState(params) {
|
|
|
13713
13722
|
onInputChange?.(nextValue);
|
|
13714
13723
|
if (!isOpen) setIsOpen(true);
|
|
13715
13724
|
},
|
|
13716
|
-
[isOpen, onInputChange, searchable, setIsOpen]
|
|
13725
|
+
[isOpen, onInputChange, searchable, setIsOpen, setInputValue]
|
|
13717
13726
|
);
|
|
13718
13727
|
const handleInputFocus = React48.useCallback(
|
|
13719
13728
|
(event) => {
|
|
@@ -14241,6 +14250,7 @@ function SelectInternal(props, ref) {
|
|
|
14241
14250
|
hideIndicator,
|
|
14242
14251
|
openMenuOnFocus,
|
|
14243
14252
|
components: userComponents,
|
|
14253
|
+
inputValue,
|
|
14244
14254
|
onInputChange,
|
|
14245
14255
|
searchable = true,
|
|
14246
14256
|
searchPosition = "trigger",
|
|
@@ -14310,6 +14320,7 @@ function SelectInternal(props, ref) {
|
|
|
14310
14320
|
onKeyDown,
|
|
14311
14321
|
onFocus,
|
|
14312
14322
|
onBlur,
|
|
14323
|
+
inputValue,
|
|
14313
14324
|
onInputChange,
|
|
14314
14325
|
isSearchInDropdown,
|
|
14315
14326
|
searchable
|
|
@@ -14534,189 +14545,228 @@ function formatPhoneCodeOptionLabel(option) {
|
|
|
14534
14545
|
// src/dashboard/phone-input/PhoneInput.tsx
|
|
14535
14546
|
var import_jsx_runtime158 = require("react/jsx-runtime");
|
|
14536
14547
|
var EMPTY_VALUE = { code: "", number: "" };
|
|
14537
|
-
var PhoneInput = React50.forwardRef(
|
|
14538
|
-
|
|
14539
|
-
|
|
14540
|
-
|
|
14541
|
-
|
|
14542
|
-
|
|
14543
|
-
|
|
14544
|
-
|
|
14545
|
-
|
|
14546
|
-
|
|
14547
|
-
|
|
14548
|
-
|
|
14549
|
-
|
|
14550
|
-
|
|
14551
|
-
|
|
14552
|
-
|
|
14553
|
-
|
|
14554
|
-
|
|
14555
|
-
|
|
14556
|
-
|
|
14557
|
-
|
|
14558
|
-
|
|
14559
|
-
|
|
14560
|
-
|
|
14561
|
-
|
|
14562
|
-
|
|
14563
|
-
|
|
14564
|
-
|
|
14565
|
-
|
|
14566
|
-
|
|
14567
|
-
|
|
14568
|
-
|
|
14569
|
-
|
|
14570
|
-
|
|
14571
|
-
|
|
14572
|
-
|
|
14573
|
-
|
|
14574
|
-
|
|
14575
|
-
|
|
14576
|
-
|
|
14577
|
-
|
|
14578
|
-
|
|
14579
|
-
|
|
14580
|
-
|
|
14581
|
-
|
|
14582
|
-
|
|
14583
|
-
|
|
14584
|
-
|
|
14585
|
-
|
|
14586
|
-
|
|
14587
|
-
|
|
14588
|
-
|
|
14589
|
-
|
|
14590
|
-
|
|
14591
|
-
|
|
14592
|
-
|
|
14593
|
-
|
|
14594
|
-
|
|
14595
|
-
|
|
14596
|
-
|
|
14597
|
-
|
|
14598
|
-
|
|
14599
|
-
|
|
14600
|
-
|
|
14601
|
-
|
|
14602
|
-
|
|
14603
|
-
|
|
14604
|
-
|
|
14605
|
-
const
|
|
14606
|
-
|
|
14607
|
-
|
|
14608
|
-
|
|
14609
|
-
|
|
14610
|
-
|
|
14611
|
-
|
|
14612
|
-
|
|
14613
|
-
|
|
14614
|
-
|
|
14615
|
-
|
|
14616
|
-
|
|
14617
|
-
|
|
14618
|
-
|
|
14619
|
-
|
|
14620
|
-
|
|
14621
|
-
|
|
14622
|
-
|
|
14623
|
-
|
|
14624
|
-
|
|
14625
|
-
|
|
14626
|
-
|
|
14627
|
-
|
|
14628
|
-
|
|
14629
|
-
|
|
14630
|
-
|
|
14631
|
-
|
|
14632
|
-
|
|
14633
|
-
|
|
14634
|
-
|
|
14635
|
-
|
|
14636
|
-
|
|
14637
|
-
|
|
14638
|
-
|
|
14639
|
-
|
|
14640
|
-
|
|
14641
|
-
|
|
14642
|
-
|
|
14643
|
-
|
|
14644
|
-
|
|
14645
|
-
|
|
14646
|
-
|
|
14647
|
-
|
|
14648
|
-
|
|
14649
|
-
|
|
14650
|
-
|
|
14651
|
-
|
|
14652
|
-
|
|
14653
|
-
|
|
14654
|
-
|
|
14655
|
-
Select,
|
|
14656
|
-
{
|
|
14657
|
-
ref,
|
|
14658
|
-
options: codeOptions,
|
|
14659
|
-
value: selectedCodeOption,
|
|
14660
|
-
onChange: handleCodeChange,
|
|
14661
|
-
label: prefixLabel,
|
|
14662
|
-
placeholder: codePlaceholder,
|
|
14663
|
-
disabled,
|
|
14664
|
-
readOnly: Boolean(readOnly) || Boolean(codeReadOnly),
|
|
14665
|
-
loading,
|
|
14666
|
-
invalid: hasInvalidState,
|
|
14667
|
-
hideErrorMessage: true,
|
|
14668
|
-
searchPosition: searchable ? "dropdown" : "trigger",
|
|
14669
|
-
searchable,
|
|
14670
|
-
filterOption: countriesFilter,
|
|
14671
|
-
clearable: false,
|
|
14672
|
-
getValueLabel: (option) => option.value,
|
|
14673
|
-
className: "max-w-none w-auto",
|
|
14674
|
-
dropdownClassName: "right-auto w-[280px]"
|
|
14675
|
-
}
|
|
14676
|
-
),
|
|
14677
|
-
/* @__PURE__ */ (0, import_jsx_runtime158.jsx)(
|
|
14678
|
-
Input,
|
|
14679
|
-
{
|
|
14680
|
-
ref: numberInputRef,
|
|
14681
|
-
type: "tel",
|
|
14682
|
-
inputMode: "tel",
|
|
14683
|
-
autoComplete: "tel-national",
|
|
14684
|
-
label: resolvedLabel,
|
|
14685
|
-
value: safeValue.number,
|
|
14686
|
-
placeholder,
|
|
14687
|
-
disabled,
|
|
14688
|
-
readOnly,
|
|
14689
|
-
loading,
|
|
14690
|
-
invalid: hasInvalidState,
|
|
14691
|
-
tooltip,
|
|
14692
|
-
"aria-label": resolvedLabel || name,
|
|
14693
|
-
"aria-describedby": errorMessage ? errorMsgId : void 0,
|
|
14694
|
-
onChange: handleNumberChange,
|
|
14695
|
-
onFocus,
|
|
14696
|
-
onBlur,
|
|
14697
|
-
renderErrorMessage: false,
|
|
14698
|
-
wrapperClassName: "max-w-none w-auto",
|
|
14699
|
-
contentClassName: readOnly ? "!cursor-default" : void 0,
|
|
14700
|
-
inputClassName: readOnly ? "!cursor-default" : void 0
|
|
14701
|
-
}
|
|
14702
|
-
)
|
|
14703
|
-
]
|
|
14704
|
-
}
|
|
14548
|
+
var PhoneInput = React50.forwardRef(
|
|
14549
|
+
function PhoneInput2({
|
|
14550
|
+
options,
|
|
14551
|
+
value,
|
|
14552
|
+
onChange,
|
|
14553
|
+
onFocus,
|
|
14554
|
+
onBlur,
|
|
14555
|
+
name,
|
|
14556
|
+
codeName,
|
|
14557
|
+
numberName,
|
|
14558
|
+
label,
|
|
14559
|
+
topLabel,
|
|
14560
|
+
prefixLabel,
|
|
14561
|
+
placeholder,
|
|
14562
|
+
codePlaceholder = "+00",
|
|
14563
|
+
disabled,
|
|
14564
|
+
loading,
|
|
14565
|
+
readOnly,
|
|
14566
|
+
codeReadOnly,
|
|
14567
|
+
optional,
|
|
14568
|
+
tooltip,
|
|
14569
|
+
error,
|
|
14570
|
+
invalid,
|
|
14571
|
+
className,
|
|
14572
|
+
autoDetectCode = true,
|
|
14573
|
+
searchable = true,
|
|
14574
|
+
defaultCode
|
|
14575
|
+
}, ref) {
|
|
14576
|
+
const { t } = (0, import_react_i18next33.useTranslation)();
|
|
14577
|
+
const groupLabelId = React50.useId();
|
|
14578
|
+
const errorMsgId = React50.useId();
|
|
14579
|
+
const numberInputRef = React50.useRef(null);
|
|
14580
|
+
const [codeSearchValue, setCodeSearchValue] = React50.useState("");
|
|
14581
|
+
const safeValue = value ?? EMPTY_VALUE;
|
|
14582
|
+
const effectiveCode = safeValue.code || defaultCode || "";
|
|
14583
|
+
const resolvedLabel = label ?? "";
|
|
14584
|
+
const hasExternalError = Boolean(error);
|
|
14585
|
+
const isPrefixRequired = autoDetectCode && Boolean(safeValue.number) && !effectiveCode;
|
|
14586
|
+
const hasInvalidState = hasExternalError || Boolean(invalid) || isPrefixRequired;
|
|
14587
|
+
const errorMessage = error ?? (isPrefixRequired ? t("prefix_required") : void 0);
|
|
14588
|
+
const combinedValue = effectiveCode || safeValue.number ? `${effectiveCode}${safeValue.number}` : "";
|
|
14589
|
+
const codeOptions = React50.useMemo(
|
|
14590
|
+
() => options.map((option) => ({
|
|
14591
|
+
value: option.value,
|
|
14592
|
+
label: formatPhoneCodeOptionLabel(option),
|
|
14593
|
+
data: option.data,
|
|
14594
|
+
isDisabled: option.disabled
|
|
14595
|
+
})),
|
|
14596
|
+
[options]
|
|
14597
|
+
);
|
|
14598
|
+
const selectedCodeOption = React50.useMemo(
|
|
14599
|
+
() => codeOptions.find((option) => option.value === effectiveCode) ?? null,
|
|
14600
|
+
[codeOptions, effectiveCode]
|
|
14601
|
+
);
|
|
14602
|
+
const parsePhoneValue = React50.useMemo(
|
|
14603
|
+
() => parsePhoneValueWithOptions(options),
|
|
14604
|
+
[options]
|
|
14605
|
+
);
|
|
14606
|
+
const emitChange = (next) => {
|
|
14607
|
+
onChange?.(next, name);
|
|
14608
|
+
};
|
|
14609
|
+
const handleCodeChange = (option) => {
|
|
14610
|
+
if (!option) return;
|
|
14611
|
+
emitChange({ code: option.value, number: safeValue.number });
|
|
14612
|
+
if (!disabled && !readOnly) {
|
|
14613
|
+
setTimeout(() => numberInputRef.current?.focus(), 0);
|
|
14614
|
+
}
|
|
14615
|
+
};
|
|
14616
|
+
const handleNumberChange = (event) => {
|
|
14617
|
+
if (readOnly || disabled) return;
|
|
14618
|
+
const rawValue = event.target.value;
|
|
14619
|
+
if (!autoDetectCode) {
|
|
14620
|
+
emitChange({ code: effectiveCode, number: clearPhoneNumber(rawValue) });
|
|
14621
|
+
return;
|
|
14622
|
+
}
|
|
14623
|
+
const parsed = parsePhoneValue(rawValue);
|
|
14624
|
+
const cleanedNumber = clearPhoneNumber(parsed.number);
|
|
14625
|
+
if (parsed.code) {
|
|
14626
|
+
emitChange({ code: parsed.code, number: cleanedNumber });
|
|
14627
|
+
return;
|
|
14628
|
+
}
|
|
14629
|
+
emitChange({ code: effectiveCode, number: cleanedNumber });
|
|
14630
|
+
};
|
|
14631
|
+
const effectiveCodeRef = React50.useRef(effectiveCode);
|
|
14632
|
+
const numberValueRef = React50.useRef(safeValue.number);
|
|
14633
|
+
const codeSearchValueRef = React50.useRef(codeSearchValue);
|
|
14634
|
+
const onChangeRef = React50.useRef(onChange);
|
|
14635
|
+
const nameRef = React50.useRef(name);
|
|
14636
|
+
effectiveCodeRef.current = effectiveCode;
|
|
14637
|
+
numberValueRef.current = safeValue.number;
|
|
14638
|
+
codeSearchValueRef.current = codeSearchValue;
|
|
14639
|
+
onChangeRef.current = onChange;
|
|
14640
|
+
nameRef.current = name;
|
|
14641
|
+
React50.useImperativeHandle(
|
|
14642
|
+
ref,
|
|
14643
|
+
() => ({
|
|
14644
|
+
getCodeSearchValue: () => codeSearchValueRef.current,
|
|
14645
|
+
setCodeSearchValue: (next) => setCodeSearchValue(next),
|
|
14646
|
+
getNumberValue: () => numberValueRef.current,
|
|
14647
|
+
setNumberValue: (next) => {
|
|
14648
|
+
const cleanedNumber = clearPhoneNumber(next);
|
|
14649
|
+
onChangeRef.current?.(
|
|
14650
|
+
{ code: effectiveCodeRef.current, number: cleanedNumber },
|
|
14651
|
+
nameRef.current
|
|
14652
|
+
);
|
|
14653
|
+
},
|
|
14654
|
+
focus: () => numberInputRef.current?.focus()
|
|
14655
|
+
}),
|
|
14656
|
+
[]
|
|
14657
|
+
);
|
|
14658
|
+
return /* @__PURE__ */ (0, import_jsx_runtime158.jsxs)(
|
|
14659
|
+
"div",
|
|
14660
|
+
{
|
|
14661
|
+
className: cn(
|
|
14662
|
+
"relative w-[var(--field-width,100%)] max-w-[var(--field-max-width,296px)]",
|
|
14663
|
+
disabled && "cursor-not-allowed opacity-50",
|
|
14664
|
+
loading && "cursor-progress",
|
|
14665
|
+
className
|
|
14705
14666
|
),
|
|
14706
|
-
|
|
14707
|
-
|
|
14708
|
-
|
|
14709
|
-
|
|
14710
|
-
|
|
14711
|
-
|
|
14712
|
-
|
|
14713
|
-
|
|
14714
|
-
|
|
14715
|
-
|
|
14716
|
-
|
|
14717
|
-
|
|
14718
|
-
|
|
14719
|
-
|
|
14667
|
+
children: [
|
|
14668
|
+
name && /* @__PURE__ */ (0, import_jsx_runtime158.jsx)("input", { type: "hidden", name, value: combinedValue, disabled }),
|
|
14669
|
+
codeName && /* @__PURE__ */ (0, import_jsx_runtime158.jsx)(
|
|
14670
|
+
"input",
|
|
14671
|
+
{
|
|
14672
|
+
type: "hidden",
|
|
14673
|
+
name: codeName,
|
|
14674
|
+
value: effectiveCode,
|
|
14675
|
+
disabled
|
|
14676
|
+
}
|
|
14677
|
+
),
|
|
14678
|
+
numberName && /* @__PURE__ */ (0, import_jsx_runtime158.jsx)(
|
|
14679
|
+
"input",
|
|
14680
|
+
{
|
|
14681
|
+
type: "hidden",
|
|
14682
|
+
name: numberName,
|
|
14683
|
+
value: safeValue.number,
|
|
14684
|
+
disabled
|
|
14685
|
+
}
|
|
14686
|
+
),
|
|
14687
|
+
topLabel && /* @__PURE__ */ (0, import_jsx_runtime158.jsx)(
|
|
14688
|
+
"span",
|
|
14689
|
+
{
|
|
14690
|
+
id: groupLabelId,
|
|
14691
|
+
className: "mb-2 block text-[14px] font-medium text-[var(--chekin-color-brand-navy)]",
|
|
14692
|
+
children: topLabel
|
|
14693
|
+
}
|
|
14694
|
+
),
|
|
14695
|
+
/* @__PURE__ */ (0, import_jsx_runtime158.jsxs)(
|
|
14696
|
+
"div",
|
|
14697
|
+
{
|
|
14698
|
+
role: "group",
|
|
14699
|
+
"aria-labelledby": topLabel ? groupLabelId : void 0,
|
|
14700
|
+
className: "grid grid-cols-[96px_minmax(0,1fr)] gap-2",
|
|
14701
|
+
children: [
|
|
14702
|
+
/* @__PURE__ */ (0, import_jsx_runtime158.jsx)(
|
|
14703
|
+
Select,
|
|
14704
|
+
{
|
|
14705
|
+
options: codeOptions,
|
|
14706
|
+
value: selectedCodeOption,
|
|
14707
|
+
onChange: handleCodeChange,
|
|
14708
|
+
label: prefixLabel,
|
|
14709
|
+
placeholder: codePlaceholder,
|
|
14710
|
+
disabled,
|
|
14711
|
+
readOnly: Boolean(readOnly) || Boolean(codeReadOnly),
|
|
14712
|
+
loading,
|
|
14713
|
+
invalid: hasInvalidState,
|
|
14714
|
+
hideErrorMessage: true,
|
|
14715
|
+
searchPosition: searchable ? "dropdown" : "trigger",
|
|
14716
|
+
searchable,
|
|
14717
|
+
filterOption: countriesFilter,
|
|
14718
|
+
clearable: false,
|
|
14719
|
+
getValueLabel: (option) => option.value,
|
|
14720
|
+
className: "max-w-none w-auto",
|
|
14721
|
+
dropdownClassName: "right-auto w-[280px]",
|
|
14722
|
+
inputValue: searchable ? codeSearchValue : void 0,
|
|
14723
|
+
onInputChange: setCodeSearchValue
|
|
14724
|
+
}
|
|
14725
|
+
),
|
|
14726
|
+
/* @__PURE__ */ (0, import_jsx_runtime158.jsx)(
|
|
14727
|
+
Input,
|
|
14728
|
+
{
|
|
14729
|
+
ref: numberInputRef,
|
|
14730
|
+
type: "tel",
|
|
14731
|
+
inputMode: "tel",
|
|
14732
|
+
autoComplete: "tel-national",
|
|
14733
|
+
label: resolvedLabel,
|
|
14734
|
+
value: safeValue.number,
|
|
14735
|
+
placeholder,
|
|
14736
|
+
disabled,
|
|
14737
|
+
readOnly,
|
|
14738
|
+
loading,
|
|
14739
|
+
invalid: hasInvalidState,
|
|
14740
|
+
tooltip,
|
|
14741
|
+
"aria-label": resolvedLabel || name,
|
|
14742
|
+
"aria-describedby": errorMessage ? errorMsgId : void 0,
|
|
14743
|
+
onChange: handleNumberChange,
|
|
14744
|
+
onFocus,
|
|
14745
|
+
onBlur,
|
|
14746
|
+
renderErrorMessage: false,
|
|
14747
|
+
wrapperClassName: "max-w-none w-auto",
|
|
14748
|
+
contentClassName: readOnly ? "!cursor-default" : void 0,
|
|
14749
|
+
inputClassName: readOnly ? "!cursor-default" : void 0
|
|
14750
|
+
}
|
|
14751
|
+
)
|
|
14752
|
+
]
|
|
14753
|
+
}
|
|
14754
|
+
),
|
|
14755
|
+
!errorMessage && optional && /* @__PURE__ */ (0, import_jsx_runtime158.jsx)("span", { className: "mt-[1px] block text-left text-[14px] font-medium text-[var(--chekin-color-gray-1)]", children: typeof optional === "string" ? optional : t("optional") }),
|
|
14756
|
+
errorMessage && /* @__PURE__ */ (0, import_jsx_runtime158.jsx)(
|
|
14757
|
+
FieldErrorMessage,
|
|
14758
|
+
{
|
|
14759
|
+
id: errorMsgId,
|
|
14760
|
+
message: errorMessage,
|
|
14761
|
+
"data-testid": name ? `${name}-error` : void 0,
|
|
14762
|
+
className: "mt-[1px] text-[14px]"
|
|
14763
|
+
}
|
|
14764
|
+
)
|
|
14765
|
+
]
|
|
14766
|
+
}
|
|
14767
|
+
);
|
|
14768
|
+
}
|
|
14769
|
+
);
|
|
14720
14770
|
PhoneInput.displayName = "PhoneInput";
|
|
14721
14771
|
|
|
14722
14772
|
// src/dashboard/creatable-select/CreatableSelect.tsx
|