@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.js
CHANGED
|
@@ -12973,8 +12973,8 @@ function ComboboxTrigger({
|
|
|
12973
12973
|
"span",
|
|
12974
12974
|
{
|
|
12975
12975
|
className: cn(
|
|
12976
|
-
"grid min-w-0 max-w-full
|
|
12977
|
-
isMulti
|
|
12976
|
+
"grid min-w-0 max-w-full",
|
|
12977
|
+
isMulti ? "w-min flex-none min-w-[40px]" : "w-full overflow-hidden",
|
|
12978
12978
|
!searchable && "sr-only"
|
|
12979
12979
|
),
|
|
12980
12980
|
children: [
|
|
@@ -13006,7 +13006,7 @@ function ComboboxTrigger({
|
|
|
13006
13006
|
"aria-activedescendant": activeOptionId,
|
|
13007
13007
|
className: cn(
|
|
13008
13008
|
"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)]",
|
|
13009
|
-
isMulti
|
|
13009
|
+
isMulti ? "min-w-[40px]" : "text-ellipsis",
|
|
13010
13010
|
readOnly && !disabled && !loading && "cursor-default",
|
|
13011
13011
|
disabled && !loading && "cursor-not-allowed",
|
|
13012
13012
|
loading && "!cursor-progress",
|
|
@@ -13162,6 +13162,7 @@ function useSelectState(params) {
|
|
|
13162
13162
|
onKeyDown,
|
|
13163
13163
|
onFocus,
|
|
13164
13164
|
onBlur,
|
|
13165
|
+
inputValue: controlledInputValue,
|
|
13165
13166
|
onInputChange,
|
|
13166
13167
|
isSearchInDropdown,
|
|
13167
13168
|
searchable = true
|
|
@@ -13179,9 +13180,17 @@ function useSelectState(params) {
|
|
|
13179
13180
|
[singleSelected, getValueLabel]
|
|
13180
13181
|
);
|
|
13181
13182
|
const isSearchOnlyInput = searchable && (isMulti || Boolean(isSearchInDropdown));
|
|
13182
|
-
const
|
|
13183
|
+
const isInputControlled = controlledInputValue !== void 0;
|
|
13184
|
+
const [internalInputValue, setInternalInputValue] = React48.useState(
|
|
13183
13185
|
searchable && !isSearchOnlyInput ? valueLabel : ""
|
|
13184
13186
|
);
|
|
13187
|
+
const inputValue = isInputControlled ? controlledInputValue : internalInputValue;
|
|
13188
|
+
const setInputValue = React48.useCallback(
|
|
13189
|
+
(next) => {
|
|
13190
|
+
if (!isInputControlled) setInternalInputValue(next);
|
|
13191
|
+
},
|
|
13192
|
+
[isInputControlled]
|
|
13193
|
+
);
|
|
13185
13194
|
const hasValue = selectedOptions.length > 0;
|
|
13186
13195
|
const isBlocked = Boolean(disabled) || Boolean(loading) || Boolean(readOnly);
|
|
13187
13196
|
const hasInvalidState = Boolean(error);
|
|
@@ -13348,7 +13357,7 @@ function useSelectState(params) {
|
|
|
13348
13357
|
onInputChange?.(nextValue);
|
|
13349
13358
|
if (!isOpen) setIsOpen(true);
|
|
13350
13359
|
},
|
|
13351
|
-
[isOpen, onInputChange, searchable, setIsOpen]
|
|
13360
|
+
[isOpen, onInputChange, searchable, setIsOpen, setInputValue]
|
|
13352
13361
|
);
|
|
13353
13362
|
const handleInputFocus = React48.useCallback(
|
|
13354
13363
|
(event) => {
|
|
@@ -13876,6 +13885,7 @@ function SelectInternal(props, ref) {
|
|
|
13876
13885
|
hideIndicator,
|
|
13877
13886
|
openMenuOnFocus,
|
|
13878
13887
|
components: userComponents,
|
|
13888
|
+
inputValue,
|
|
13879
13889
|
onInputChange,
|
|
13880
13890
|
searchable = true,
|
|
13881
13891
|
searchPosition = "trigger",
|
|
@@ -13945,6 +13955,7 @@ function SelectInternal(props, ref) {
|
|
|
13945
13955
|
onKeyDown,
|
|
13946
13956
|
onFocus,
|
|
13947
13957
|
onBlur,
|
|
13958
|
+
inputValue,
|
|
13948
13959
|
onInputChange,
|
|
13949
13960
|
isSearchInDropdown,
|
|
13950
13961
|
searchable
|
|
@@ -14169,189 +14180,228 @@ function formatPhoneCodeOptionLabel(option) {
|
|
|
14169
14180
|
// src/dashboard/phone-input/PhoneInput.tsx
|
|
14170
14181
|
import { jsx as jsx156, jsxs as jsxs100 } from "react/jsx-runtime";
|
|
14171
14182
|
var EMPTY_VALUE = { code: "", number: "" };
|
|
14172
|
-
var PhoneInput = React50.forwardRef(
|
|
14173
|
-
|
|
14174
|
-
|
|
14175
|
-
|
|
14176
|
-
|
|
14177
|
-
|
|
14178
|
-
|
|
14179
|
-
|
|
14180
|
-
|
|
14181
|
-
|
|
14182
|
-
|
|
14183
|
-
|
|
14184
|
-
|
|
14185
|
-
|
|
14186
|
-
|
|
14187
|
-
|
|
14188
|
-
|
|
14189
|
-
|
|
14190
|
-
|
|
14191
|
-
|
|
14192
|
-
|
|
14193
|
-
|
|
14194
|
-
|
|
14195
|
-
|
|
14196
|
-
|
|
14197
|
-
|
|
14198
|
-
|
|
14199
|
-
|
|
14200
|
-
|
|
14201
|
-
|
|
14202
|
-
|
|
14203
|
-
|
|
14204
|
-
|
|
14205
|
-
|
|
14206
|
-
|
|
14207
|
-
|
|
14208
|
-
|
|
14209
|
-
|
|
14210
|
-
|
|
14211
|
-
|
|
14212
|
-
|
|
14213
|
-
|
|
14214
|
-
|
|
14215
|
-
|
|
14216
|
-
|
|
14217
|
-
|
|
14218
|
-
|
|
14219
|
-
|
|
14220
|
-
|
|
14221
|
-
|
|
14222
|
-
|
|
14223
|
-
|
|
14224
|
-
|
|
14225
|
-
|
|
14226
|
-
|
|
14227
|
-
|
|
14228
|
-
|
|
14229
|
-
|
|
14230
|
-
|
|
14231
|
-
|
|
14232
|
-
|
|
14233
|
-
|
|
14234
|
-
|
|
14235
|
-
|
|
14236
|
-
|
|
14237
|
-
|
|
14238
|
-
|
|
14239
|
-
|
|
14240
|
-
const
|
|
14241
|
-
|
|
14242
|
-
|
|
14243
|
-
|
|
14244
|
-
|
|
14245
|
-
|
|
14246
|
-
|
|
14247
|
-
|
|
14248
|
-
|
|
14249
|
-
|
|
14250
|
-
|
|
14251
|
-
|
|
14252
|
-
|
|
14253
|
-
|
|
14254
|
-
|
|
14255
|
-
|
|
14256
|
-
|
|
14257
|
-
|
|
14258
|
-
|
|
14259
|
-
|
|
14260
|
-
|
|
14261
|
-
|
|
14262
|
-
|
|
14263
|
-
|
|
14264
|
-
|
|
14265
|
-
|
|
14266
|
-
|
|
14267
|
-
|
|
14268
|
-
|
|
14269
|
-
|
|
14270
|
-
|
|
14271
|
-
|
|
14272
|
-
|
|
14273
|
-
|
|
14274
|
-
|
|
14275
|
-
|
|
14276
|
-
|
|
14277
|
-
|
|
14278
|
-
|
|
14279
|
-
|
|
14280
|
-
|
|
14281
|
-
|
|
14282
|
-
|
|
14283
|
-
|
|
14284
|
-
|
|
14285
|
-
|
|
14286
|
-
|
|
14287
|
-
|
|
14288
|
-
|
|
14289
|
-
|
|
14290
|
-
Select,
|
|
14291
|
-
{
|
|
14292
|
-
ref,
|
|
14293
|
-
options: codeOptions,
|
|
14294
|
-
value: selectedCodeOption,
|
|
14295
|
-
onChange: handleCodeChange,
|
|
14296
|
-
label: prefixLabel,
|
|
14297
|
-
placeholder: codePlaceholder,
|
|
14298
|
-
disabled,
|
|
14299
|
-
readOnly: Boolean(readOnly) || Boolean(codeReadOnly),
|
|
14300
|
-
loading,
|
|
14301
|
-
invalid: hasInvalidState,
|
|
14302
|
-
hideErrorMessage: true,
|
|
14303
|
-
searchPosition: searchable ? "dropdown" : "trigger",
|
|
14304
|
-
searchable,
|
|
14305
|
-
filterOption: countriesFilter,
|
|
14306
|
-
clearable: false,
|
|
14307
|
-
getValueLabel: (option) => option.value,
|
|
14308
|
-
className: "max-w-none w-auto",
|
|
14309
|
-
dropdownClassName: "right-auto w-[280px]"
|
|
14310
|
-
}
|
|
14311
|
-
),
|
|
14312
|
-
/* @__PURE__ */ jsx156(
|
|
14313
|
-
Input,
|
|
14314
|
-
{
|
|
14315
|
-
ref: numberInputRef,
|
|
14316
|
-
type: "tel",
|
|
14317
|
-
inputMode: "tel",
|
|
14318
|
-
autoComplete: "tel-national",
|
|
14319
|
-
label: resolvedLabel,
|
|
14320
|
-
value: safeValue.number,
|
|
14321
|
-
placeholder,
|
|
14322
|
-
disabled,
|
|
14323
|
-
readOnly,
|
|
14324
|
-
loading,
|
|
14325
|
-
invalid: hasInvalidState,
|
|
14326
|
-
tooltip,
|
|
14327
|
-
"aria-label": resolvedLabel || name,
|
|
14328
|
-
"aria-describedby": errorMessage ? errorMsgId : void 0,
|
|
14329
|
-
onChange: handleNumberChange,
|
|
14330
|
-
onFocus,
|
|
14331
|
-
onBlur,
|
|
14332
|
-
renderErrorMessage: false,
|
|
14333
|
-
wrapperClassName: "max-w-none w-auto",
|
|
14334
|
-
contentClassName: readOnly ? "!cursor-default" : void 0,
|
|
14335
|
-
inputClassName: readOnly ? "!cursor-default" : void 0
|
|
14336
|
-
}
|
|
14337
|
-
)
|
|
14338
|
-
]
|
|
14339
|
-
}
|
|
14183
|
+
var PhoneInput = React50.forwardRef(
|
|
14184
|
+
function PhoneInput2({
|
|
14185
|
+
options,
|
|
14186
|
+
value,
|
|
14187
|
+
onChange,
|
|
14188
|
+
onFocus,
|
|
14189
|
+
onBlur,
|
|
14190
|
+
name,
|
|
14191
|
+
codeName,
|
|
14192
|
+
numberName,
|
|
14193
|
+
label,
|
|
14194
|
+
topLabel,
|
|
14195
|
+
prefixLabel,
|
|
14196
|
+
placeholder,
|
|
14197
|
+
codePlaceholder = "+00",
|
|
14198
|
+
disabled,
|
|
14199
|
+
loading,
|
|
14200
|
+
readOnly,
|
|
14201
|
+
codeReadOnly,
|
|
14202
|
+
optional,
|
|
14203
|
+
tooltip,
|
|
14204
|
+
error,
|
|
14205
|
+
invalid,
|
|
14206
|
+
className,
|
|
14207
|
+
autoDetectCode = true,
|
|
14208
|
+
searchable = true,
|
|
14209
|
+
defaultCode
|
|
14210
|
+
}, ref) {
|
|
14211
|
+
const { t } = useTranslation33();
|
|
14212
|
+
const groupLabelId = React50.useId();
|
|
14213
|
+
const errorMsgId = React50.useId();
|
|
14214
|
+
const numberInputRef = React50.useRef(null);
|
|
14215
|
+
const [codeSearchValue, setCodeSearchValue] = React50.useState("");
|
|
14216
|
+
const safeValue = value ?? EMPTY_VALUE;
|
|
14217
|
+
const effectiveCode = safeValue.code || defaultCode || "";
|
|
14218
|
+
const resolvedLabel = label ?? "";
|
|
14219
|
+
const hasExternalError = Boolean(error);
|
|
14220
|
+
const isPrefixRequired = autoDetectCode && Boolean(safeValue.number) && !effectiveCode;
|
|
14221
|
+
const hasInvalidState = hasExternalError || Boolean(invalid) || isPrefixRequired;
|
|
14222
|
+
const errorMessage = error ?? (isPrefixRequired ? t("prefix_required") : void 0);
|
|
14223
|
+
const combinedValue = effectiveCode || safeValue.number ? `${effectiveCode}${safeValue.number}` : "";
|
|
14224
|
+
const codeOptions = React50.useMemo(
|
|
14225
|
+
() => options.map((option) => ({
|
|
14226
|
+
value: option.value,
|
|
14227
|
+
label: formatPhoneCodeOptionLabel(option),
|
|
14228
|
+
data: option.data,
|
|
14229
|
+
isDisabled: option.disabled
|
|
14230
|
+
})),
|
|
14231
|
+
[options]
|
|
14232
|
+
);
|
|
14233
|
+
const selectedCodeOption = React50.useMemo(
|
|
14234
|
+
() => codeOptions.find((option) => option.value === effectiveCode) ?? null,
|
|
14235
|
+
[codeOptions, effectiveCode]
|
|
14236
|
+
);
|
|
14237
|
+
const parsePhoneValue = React50.useMemo(
|
|
14238
|
+
() => parsePhoneValueWithOptions(options),
|
|
14239
|
+
[options]
|
|
14240
|
+
);
|
|
14241
|
+
const emitChange = (next) => {
|
|
14242
|
+
onChange?.(next, name);
|
|
14243
|
+
};
|
|
14244
|
+
const handleCodeChange = (option) => {
|
|
14245
|
+
if (!option) return;
|
|
14246
|
+
emitChange({ code: option.value, number: safeValue.number });
|
|
14247
|
+
if (!disabled && !readOnly) {
|
|
14248
|
+
setTimeout(() => numberInputRef.current?.focus(), 0);
|
|
14249
|
+
}
|
|
14250
|
+
};
|
|
14251
|
+
const handleNumberChange = (event) => {
|
|
14252
|
+
if (readOnly || disabled) return;
|
|
14253
|
+
const rawValue = event.target.value;
|
|
14254
|
+
if (!autoDetectCode) {
|
|
14255
|
+
emitChange({ code: effectiveCode, number: clearPhoneNumber(rawValue) });
|
|
14256
|
+
return;
|
|
14257
|
+
}
|
|
14258
|
+
const parsed = parsePhoneValue(rawValue);
|
|
14259
|
+
const cleanedNumber = clearPhoneNumber(parsed.number);
|
|
14260
|
+
if (parsed.code) {
|
|
14261
|
+
emitChange({ code: parsed.code, number: cleanedNumber });
|
|
14262
|
+
return;
|
|
14263
|
+
}
|
|
14264
|
+
emitChange({ code: effectiveCode, number: cleanedNumber });
|
|
14265
|
+
};
|
|
14266
|
+
const effectiveCodeRef = React50.useRef(effectiveCode);
|
|
14267
|
+
const numberValueRef = React50.useRef(safeValue.number);
|
|
14268
|
+
const codeSearchValueRef = React50.useRef(codeSearchValue);
|
|
14269
|
+
const onChangeRef = React50.useRef(onChange);
|
|
14270
|
+
const nameRef = React50.useRef(name);
|
|
14271
|
+
effectiveCodeRef.current = effectiveCode;
|
|
14272
|
+
numberValueRef.current = safeValue.number;
|
|
14273
|
+
codeSearchValueRef.current = codeSearchValue;
|
|
14274
|
+
onChangeRef.current = onChange;
|
|
14275
|
+
nameRef.current = name;
|
|
14276
|
+
React50.useImperativeHandle(
|
|
14277
|
+
ref,
|
|
14278
|
+
() => ({
|
|
14279
|
+
getCodeSearchValue: () => codeSearchValueRef.current,
|
|
14280
|
+
setCodeSearchValue: (next) => setCodeSearchValue(next),
|
|
14281
|
+
getNumberValue: () => numberValueRef.current,
|
|
14282
|
+
setNumberValue: (next) => {
|
|
14283
|
+
const cleanedNumber = clearPhoneNumber(next);
|
|
14284
|
+
onChangeRef.current?.(
|
|
14285
|
+
{ code: effectiveCodeRef.current, number: cleanedNumber },
|
|
14286
|
+
nameRef.current
|
|
14287
|
+
);
|
|
14288
|
+
},
|
|
14289
|
+
focus: () => numberInputRef.current?.focus()
|
|
14290
|
+
}),
|
|
14291
|
+
[]
|
|
14292
|
+
);
|
|
14293
|
+
return /* @__PURE__ */ jsxs100(
|
|
14294
|
+
"div",
|
|
14295
|
+
{
|
|
14296
|
+
className: cn(
|
|
14297
|
+
"relative w-[var(--field-width,100%)] max-w-[var(--field-max-width,296px)]",
|
|
14298
|
+
disabled && "cursor-not-allowed opacity-50",
|
|
14299
|
+
loading && "cursor-progress",
|
|
14300
|
+
className
|
|
14340
14301
|
),
|
|
14341
|
-
|
|
14342
|
-
|
|
14343
|
-
|
|
14344
|
-
|
|
14345
|
-
|
|
14346
|
-
|
|
14347
|
-
|
|
14348
|
-
|
|
14349
|
-
|
|
14350
|
-
|
|
14351
|
-
|
|
14352
|
-
|
|
14353
|
-
|
|
14354
|
-
|
|
14302
|
+
children: [
|
|
14303
|
+
name && /* @__PURE__ */ jsx156("input", { type: "hidden", name, value: combinedValue, disabled }),
|
|
14304
|
+
codeName && /* @__PURE__ */ jsx156(
|
|
14305
|
+
"input",
|
|
14306
|
+
{
|
|
14307
|
+
type: "hidden",
|
|
14308
|
+
name: codeName,
|
|
14309
|
+
value: effectiveCode,
|
|
14310
|
+
disabled
|
|
14311
|
+
}
|
|
14312
|
+
),
|
|
14313
|
+
numberName && /* @__PURE__ */ jsx156(
|
|
14314
|
+
"input",
|
|
14315
|
+
{
|
|
14316
|
+
type: "hidden",
|
|
14317
|
+
name: numberName,
|
|
14318
|
+
value: safeValue.number,
|
|
14319
|
+
disabled
|
|
14320
|
+
}
|
|
14321
|
+
),
|
|
14322
|
+
topLabel && /* @__PURE__ */ jsx156(
|
|
14323
|
+
"span",
|
|
14324
|
+
{
|
|
14325
|
+
id: groupLabelId,
|
|
14326
|
+
className: "mb-2 block text-[14px] font-medium text-[var(--chekin-color-brand-navy)]",
|
|
14327
|
+
children: topLabel
|
|
14328
|
+
}
|
|
14329
|
+
),
|
|
14330
|
+
/* @__PURE__ */ jsxs100(
|
|
14331
|
+
"div",
|
|
14332
|
+
{
|
|
14333
|
+
role: "group",
|
|
14334
|
+
"aria-labelledby": topLabel ? groupLabelId : void 0,
|
|
14335
|
+
className: "grid grid-cols-[96px_minmax(0,1fr)] gap-2",
|
|
14336
|
+
children: [
|
|
14337
|
+
/* @__PURE__ */ jsx156(
|
|
14338
|
+
Select,
|
|
14339
|
+
{
|
|
14340
|
+
options: codeOptions,
|
|
14341
|
+
value: selectedCodeOption,
|
|
14342
|
+
onChange: handleCodeChange,
|
|
14343
|
+
label: prefixLabel,
|
|
14344
|
+
placeholder: codePlaceholder,
|
|
14345
|
+
disabled,
|
|
14346
|
+
readOnly: Boolean(readOnly) || Boolean(codeReadOnly),
|
|
14347
|
+
loading,
|
|
14348
|
+
invalid: hasInvalidState,
|
|
14349
|
+
hideErrorMessage: true,
|
|
14350
|
+
searchPosition: searchable ? "dropdown" : "trigger",
|
|
14351
|
+
searchable,
|
|
14352
|
+
filterOption: countriesFilter,
|
|
14353
|
+
clearable: false,
|
|
14354
|
+
getValueLabel: (option) => option.value,
|
|
14355
|
+
className: "max-w-none w-auto",
|
|
14356
|
+
dropdownClassName: "right-auto w-[280px]",
|
|
14357
|
+
inputValue: searchable ? codeSearchValue : void 0,
|
|
14358
|
+
onInputChange: setCodeSearchValue
|
|
14359
|
+
}
|
|
14360
|
+
),
|
|
14361
|
+
/* @__PURE__ */ jsx156(
|
|
14362
|
+
Input,
|
|
14363
|
+
{
|
|
14364
|
+
ref: numberInputRef,
|
|
14365
|
+
type: "tel",
|
|
14366
|
+
inputMode: "tel",
|
|
14367
|
+
autoComplete: "tel-national",
|
|
14368
|
+
label: resolvedLabel,
|
|
14369
|
+
value: safeValue.number,
|
|
14370
|
+
placeholder,
|
|
14371
|
+
disabled,
|
|
14372
|
+
readOnly,
|
|
14373
|
+
loading,
|
|
14374
|
+
invalid: hasInvalidState,
|
|
14375
|
+
tooltip,
|
|
14376
|
+
"aria-label": resolvedLabel || name,
|
|
14377
|
+
"aria-describedby": errorMessage ? errorMsgId : void 0,
|
|
14378
|
+
onChange: handleNumberChange,
|
|
14379
|
+
onFocus,
|
|
14380
|
+
onBlur,
|
|
14381
|
+
renderErrorMessage: false,
|
|
14382
|
+
wrapperClassName: "max-w-none w-auto",
|
|
14383
|
+
contentClassName: readOnly ? "!cursor-default" : void 0,
|
|
14384
|
+
inputClassName: readOnly ? "!cursor-default" : void 0
|
|
14385
|
+
}
|
|
14386
|
+
)
|
|
14387
|
+
]
|
|
14388
|
+
}
|
|
14389
|
+
),
|
|
14390
|
+
!errorMessage && optional && /* @__PURE__ */ jsx156("span", { className: "mt-[1px] block text-left text-[14px] font-medium text-[var(--chekin-color-gray-1)]", children: typeof optional === "string" ? optional : t("optional") }),
|
|
14391
|
+
errorMessage && /* @__PURE__ */ jsx156(
|
|
14392
|
+
FieldErrorMessage,
|
|
14393
|
+
{
|
|
14394
|
+
id: errorMsgId,
|
|
14395
|
+
message: errorMessage,
|
|
14396
|
+
"data-testid": name ? `${name}-error` : void 0,
|
|
14397
|
+
className: "mt-[1px] text-[14px]"
|
|
14398
|
+
}
|
|
14399
|
+
)
|
|
14400
|
+
]
|
|
14401
|
+
}
|
|
14402
|
+
);
|
|
14403
|
+
}
|
|
14404
|
+
);
|
|
14355
14405
|
PhoneInput.displayName = "PhoneInput";
|
|
14356
14406
|
|
|
14357
14407
|
// src/dashboard/creatable-select/CreatableSelect.tsx
|