@chekinapp/ui 0.0.129 → 0.0.130
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 +265 -110
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +265 -110
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -12124,7 +12124,14 @@ var Input = React44.forwardRef(
|
|
|
12124
12124
|
"div",
|
|
12125
12125
|
{
|
|
12126
12126
|
className: cn(
|
|
12127
|
-
"
|
|
12127
|
+
"input",
|
|
12128
|
+
disabled && "input--disabled",
|
|
12129
|
+
loading && "input--loading",
|
|
12130
|
+
readOnly && "input--readonly",
|
|
12131
|
+
isFocused && "input--focused",
|
|
12132
|
+
isEmpty && "input--empty",
|
|
12133
|
+
hasInvalidState && "input--invalid",
|
|
12134
|
+
"relative block w-[var(--field-width,100%)] max-w-[var(--field-max-width,296px)] min-h-[var(--field-min-height,48px)]",
|
|
12128
12135
|
disabled && "cursor-not-allowed opacity-50",
|
|
12129
12136
|
loading && "cursor-progress opacity-50",
|
|
12130
12137
|
wrapperClassName,
|
|
@@ -12135,7 +12142,7 @@ var Input = React44.forwardRef(
|
|
|
12135
12142
|
"label",
|
|
12136
12143
|
{
|
|
12137
12144
|
htmlFor: inputId,
|
|
12138
|
-
className: "mb-2 block text-[14px] font-medium text-[var(--chekin-color-brand-navy)]",
|
|
12145
|
+
className: "input__top-label mb-2 block text-[14px] font-medium text-[var(--chekin-color-brand-navy)]",
|
|
12139
12146
|
children: topLabel
|
|
12140
12147
|
}
|
|
12141
12148
|
),
|
|
@@ -12143,110 +12150,121 @@ var Input = React44.forwardRef(
|
|
|
12143
12150
|
"div",
|
|
12144
12151
|
{
|
|
12145
12152
|
className: cn(
|
|
12153
|
+
"input__field",
|
|
12146
12154
|
"relative block w-full",
|
|
12147
12155
|
readOnly && "bg-[var(--empty-field-background)]",
|
|
12148
12156
|
fieldClassName
|
|
12149
12157
|
),
|
|
12150
12158
|
children: [
|
|
12151
|
-
/* @__PURE__ */ jsxs89(
|
|
12152
|
-
|
|
12153
|
-
|
|
12154
|
-
|
|
12155
|
-
|
|
12156
|
-
|
|
12157
|
-
|
|
12158
|
-
onClick: handleLabelClick,
|
|
12159
|
-
isActivated: !isEmpty || isFocused,
|
|
12160
|
-
readOnly,
|
|
12161
|
-
loading,
|
|
12162
|
-
disabled,
|
|
12163
|
-
htmlFor: inputId,
|
|
12164
|
-
labelId: `${inputId}-label`,
|
|
12165
|
-
legend: typeof label === "string" ? label : void 0,
|
|
12166
|
-
label,
|
|
12167
|
-
tooltip,
|
|
12168
|
-
labelClassName: cn({
|
|
12169
|
-
"pl-[28px]": !!leftIcon
|
|
12170
|
-
})
|
|
12171
|
-
}
|
|
12172
|
-
),
|
|
12173
|
-
leftIcon && /* @__PURE__ */ jsx142("span", { className: "pointer-events-none absolute left-0 top-0 flex h-full max-w-10 items-center justify-center text-[var(--chekin-color-gray-2)]", children: /* @__PURE__ */ jsx142("span", { className: "flex h-full w-10 items-center justify-center", children: leftIcon }) }),
|
|
12174
|
-
/* @__PURE__ */ jsx142(
|
|
12175
|
-
"input",
|
|
12176
|
-
{
|
|
12177
|
-
...props,
|
|
12178
|
-
ref: combinedInputRef,
|
|
12179
|
-
id: inputId,
|
|
12180
|
-
name,
|
|
12181
|
-
type: inputType,
|
|
12182
|
-
"data-testid": "input",
|
|
12183
|
-
value,
|
|
12184
|
-
defaultValue,
|
|
12185
|
-
disabled: disabled || loading,
|
|
12186
|
-
readOnly,
|
|
12187
|
-
required: !optional,
|
|
12188
|
-
"aria-label": typeof label === "string" ? label : void 0,
|
|
12189
|
-
"aria-invalid": hasInvalidState,
|
|
12190
|
-
"aria-busy": loading,
|
|
12191
|
-
"aria-describedby": errorMessage && renderErrorMessage ? errorId : void 0,
|
|
12192
|
-
placeholder: isFocused || !label ? placeholder : void 0,
|
|
12193
|
-
onChange: handleChange,
|
|
12194
|
-
onFocus: handleFocus,
|
|
12195
|
-
onBlur: handleBlur,
|
|
12196
|
-
className: cn(
|
|
12197
|
-
"m-0 box-border h-12 w-full rounded-[6px] border-0 px-4 text-[16px] font-medium leading-5 text-[var(--chekin-color-brand-navy)] outline-none transition-colors duration-200 [text-overflow:ellipsis] [&::-webkit-inner-spin-button]:appearance-none [&::-webkit-outer-spin-button]:appearance-none",
|
|
12198
|
-
"placeholder:font-medium placeholder:text-[var(--chekin-color-gray-1)] placeholder:opacity-100",
|
|
12199
|
-
isEmpty && !isFocused ? "bg-[var(--empty-field-background)]" : "bg-transparent",
|
|
12200
|
-
isEmpty && "text-[var(--chekin-color-gray-1)]",
|
|
12201
|
-
inputType === "password" && "[&:not(:placeholder-shown)]:font-bold [&:not(:placeholder-shown)]:tracking-[2px]",
|
|
12202
|
-
(disabled || readOnly) && "cursor-not-allowed",
|
|
12203
|
-
loading && "cursor-progress",
|
|
12204
|
-
leftIcon && "pl-10",
|
|
12205
|
-
(showRightPaddingForReset || showRightPaddingForReveal) && "pr-10",
|
|
12206
|
-
sign && "pr-10",
|
|
12207
|
-
inputClassName
|
|
12208
|
-
)
|
|
12209
|
-
}
|
|
12210
|
-
),
|
|
12211
|
-
sign && /* @__PURE__ */ jsx142("span", { className: "pointer-events-none absolute right-[14px] top-0 flex h-full items-center text-[18px] font-medium leading-6 text-[var(--chekin-color-brand-navy)]", children: sign }),
|
|
12212
|
-
trailingAdornment && /* @__PURE__ */ jsx142("span", { className: "pointer-events-none absolute right-[14px] top-0 flex h-full items-center", children: trailingAdornment }),
|
|
12213
|
-
onReset && !isEmpty && /* @__PURE__ */ jsx142(
|
|
12214
|
-
"button",
|
|
12215
|
-
{
|
|
12216
|
-
type: "button",
|
|
12217
|
-
onClick: onReset,
|
|
12218
|
-
disabled,
|
|
12219
|
-
className: "absolute right-0 top-0 flex h-full w-10 items-center justify-center border-0 bg-transparent p-0 text-[#9696b9] hover:opacity-80 disabled:cursor-not-allowed disabled:opacity-50",
|
|
12220
|
-
"aria-label": t("reset"),
|
|
12221
|
-
children: /* @__PURE__ */ jsx142(X9, { size: 14 })
|
|
12222
|
-
}
|
|
12223
|
-
),
|
|
12224
|
-
isPasswordReveal && /* @__PURE__ */ jsx142(
|
|
12225
|
-
"button",
|
|
12226
|
-
{
|
|
12227
|
-
type: "button",
|
|
12228
|
-
onClick: togglePasswordReveal,
|
|
12229
|
-
className: "absolute right-[14px] top-[18px] flex h-[13px] w-[21px] cursor-pointer items-center justify-center border-0 bg-transparent p-0 hover:opacity-85",
|
|
12230
|
-
"aria-label": isPasswordRevealed ? t("hide_password") : t("show_password"),
|
|
12231
|
-
children: /* @__PURE__ */ jsx142(
|
|
12232
|
-
Eye,
|
|
12159
|
+
/* @__PURE__ */ jsxs89(
|
|
12160
|
+
"div",
|
|
12161
|
+
{
|
|
12162
|
+
className: cn("input__content relative w-full cursor-text", contentClassName),
|
|
12163
|
+
children: [
|
|
12164
|
+
/* @__PURE__ */ jsx142(
|
|
12165
|
+
Fieldset,
|
|
12233
12166
|
{
|
|
12234
|
-
|
|
12167
|
+
isFocused: isFocused && !readOnly,
|
|
12168
|
+
invalid: hasInvalidState,
|
|
12169
|
+
isEmpty,
|
|
12170
|
+
onClick: handleLabelClick,
|
|
12171
|
+
isActivated: !isEmpty || isFocused,
|
|
12172
|
+
readOnly,
|
|
12173
|
+
loading,
|
|
12174
|
+
disabled,
|
|
12175
|
+
htmlFor: inputId,
|
|
12176
|
+
labelId: `${inputId}-label`,
|
|
12177
|
+
legend: typeof label === "string" ? label : void 0,
|
|
12178
|
+
label,
|
|
12179
|
+
tooltip,
|
|
12180
|
+
className: "input__fieldset",
|
|
12181
|
+
labelClassName: cn({
|
|
12182
|
+
input__label: true,
|
|
12183
|
+
"pl-[28px]": !!leftIcon
|
|
12184
|
+
})
|
|
12185
|
+
}
|
|
12186
|
+
),
|
|
12187
|
+
leftIcon && /* @__PURE__ */ jsx142("span", { className: "input__left-icon pointer-events-none absolute left-0 top-0 flex h-full max-w-10 items-center justify-center text-[var(--chekin-color-gray-2)]", children: /* @__PURE__ */ jsx142("span", { className: "input__left-icon-inner flex h-full w-10 items-center justify-center", children: leftIcon }) }),
|
|
12188
|
+
/* @__PURE__ */ jsx142(
|
|
12189
|
+
"input",
|
|
12190
|
+
{
|
|
12191
|
+
...props,
|
|
12192
|
+
ref: combinedInputRef,
|
|
12193
|
+
id: inputId,
|
|
12194
|
+
name,
|
|
12195
|
+
type: inputType,
|
|
12196
|
+
"data-testid": "input",
|
|
12197
|
+
value,
|
|
12198
|
+
defaultValue,
|
|
12199
|
+
disabled: disabled || loading,
|
|
12200
|
+
readOnly,
|
|
12201
|
+
required: !optional,
|
|
12202
|
+
"aria-label": typeof label === "string" ? label : void 0,
|
|
12203
|
+
"aria-invalid": hasInvalidState,
|
|
12204
|
+
"aria-busy": loading,
|
|
12205
|
+
"aria-describedby": errorMessage && renderErrorMessage ? errorId : void 0,
|
|
12206
|
+
placeholder: isFocused || !label ? placeholder : void 0,
|
|
12207
|
+
onChange: handleChange,
|
|
12208
|
+
onFocus: handleFocus,
|
|
12209
|
+
onBlur: handleBlur,
|
|
12235
12210
|
className: cn(
|
|
12236
|
-
|
|
12211
|
+
"input__control",
|
|
12212
|
+
"m-0 box-border h-12 w-full rounded-[6px] border-0 px-4 text-[16px] font-medium leading-5 text-[var(--chekin-color-brand-navy)] outline-none transition-colors duration-200 [text-overflow:ellipsis] [&::-webkit-inner-spin-button]:appearance-none [&::-webkit-outer-spin-button]:appearance-none",
|
|
12213
|
+
"placeholder:font-medium placeholder:text-[var(--chekin-color-gray-1)] placeholder:opacity-100",
|
|
12214
|
+
isEmpty && !isFocused ? "bg-[var(--empty-field-background)]" : "bg-transparent",
|
|
12215
|
+
isEmpty && "text-[var(--chekin-color-gray-1)]",
|
|
12216
|
+
inputType === "password" && "[&:not(:placeholder-shown)]:font-bold [&:not(:placeholder-shown)]:tracking-[2px]",
|
|
12217
|
+
(disabled || readOnly) && "cursor-not-allowed",
|
|
12218
|
+
loading && "cursor-progress",
|
|
12219
|
+
leftIcon && "pl-10",
|
|
12220
|
+
(showRightPaddingForReset || showRightPaddingForReveal) && "pr-10",
|
|
12221
|
+
sign && "pr-10",
|
|
12222
|
+
inputClassName
|
|
12223
|
+
)
|
|
12224
|
+
}
|
|
12225
|
+
),
|
|
12226
|
+
sign && /* @__PURE__ */ jsx142("span", { className: "input__sign pointer-events-none absolute right-[14px] top-0 flex h-full items-center text-[18px] font-medium leading-6 text-[var(--chekin-color-brand-navy)]", children: sign }),
|
|
12227
|
+
trailingAdornment && /* @__PURE__ */ jsx142("span", { className: "input__trailing-adornment pointer-events-none absolute right-[14px] top-0 flex h-full items-center", children: trailingAdornment }),
|
|
12228
|
+
onReset && !isEmpty && /* @__PURE__ */ jsx142(
|
|
12229
|
+
"button",
|
|
12230
|
+
{
|
|
12231
|
+
type: "button",
|
|
12232
|
+
onClick: onReset,
|
|
12233
|
+
disabled,
|
|
12234
|
+
className: "input__reset-button absolute right-0 top-0 flex h-full w-10 items-center justify-center border-0 bg-transparent p-0 text-[#9696b9] hover:opacity-80 disabled:cursor-not-allowed disabled:opacity-50",
|
|
12235
|
+
"aria-label": t("reset"),
|
|
12236
|
+
children: /* @__PURE__ */ jsx142(X9, { size: 14 })
|
|
12237
|
+
}
|
|
12238
|
+
),
|
|
12239
|
+
isPasswordReveal && /* @__PURE__ */ jsx142(
|
|
12240
|
+
"button",
|
|
12241
|
+
{
|
|
12242
|
+
type: "button",
|
|
12243
|
+
onClick: togglePasswordReveal,
|
|
12244
|
+
className: "input__password-button absolute right-[14px] top-[18px] flex h-[13px] w-[21px] cursor-pointer items-center justify-center border-0 bg-transparent p-0 hover:opacity-85",
|
|
12245
|
+
"aria-label": isPasswordRevealed ? t("hide_password") : t("show_password"),
|
|
12246
|
+
children: /* @__PURE__ */ jsx142(
|
|
12247
|
+
Eye,
|
|
12248
|
+
{
|
|
12249
|
+
size: 20,
|
|
12250
|
+
className: cn(
|
|
12251
|
+
"input__password-icon",
|
|
12252
|
+
isPasswordRevealed ? "text-[#fc98dd]" : "text-[var(--chekin-color-gray-2)]"
|
|
12253
|
+
)
|
|
12254
|
+
}
|
|
12237
12255
|
)
|
|
12238
12256
|
}
|
|
12239
12257
|
)
|
|
12240
|
-
|
|
12241
|
-
|
|
12242
|
-
|
|
12243
|
-
type === "number" && showNumberButtons && /* @__PURE__ */ jsxs89("div", { className: "absolute right-[18px] top-[13px] inline-flex items-center text-right", children: [
|
|
12258
|
+
]
|
|
12259
|
+
}
|
|
12260
|
+
),
|
|
12261
|
+
type === "number" && showNumberButtons && /* @__PURE__ */ jsxs89("div", { className: "input__number-controls absolute right-[18px] top-[13px] inline-flex items-center text-right", children: [
|
|
12244
12262
|
/* @__PURE__ */ jsx142(
|
|
12245
12263
|
"button",
|
|
12246
12264
|
{
|
|
12247
12265
|
type: "button",
|
|
12248
12266
|
onClick: onDecrement,
|
|
12249
|
-
className: "mr-2 inline-flex h-[23px] w-8 cursor-pointer items-center justify-center rounded-[3px] border-0 bg-[var(--chekin-color-brand-blue)] p-0 text-[20px] font-bold text-white outline-none hover:opacity-90 active:opacity-100",
|
|
12267
|
+
className: "input__decrement-button mr-2 inline-flex h-[23px] w-8 cursor-pointer items-center justify-center rounded-[3px] border-0 bg-[var(--chekin-color-brand-blue)] p-0 text-[20px] font-bold text-white outline-none hover:opacity-90 active:opacity-100",
|
|
12250
12268
|
"aria-label": t("decrement"),
|
|
12251
12269
|
children: /* @__PURE__ */ jsx142(Minus4, { size: 16, strokeWidth: 3, "aria-hidden": true })
|
|
12252
12270
|
}
|
|
@@ -12256,7 +12274,7 @@ var Input = React44.forwardRef(
|
|
|
12256
12274
|
{
|
|
12257
12275
|
type: "button",
|
|
12258
12276
|
onClick: onIncrement,
|
|
12259
|
-
className: "inline-flex h-[23px] w-8 cursor-pointer items-center justify-center rounded-[3px] border-0 bg-[var(--chekin-color-brand-blue)] p-0 text-[20px] font-bold text-white outline-none hover:opacity-90 active:opacity-100",
|
|
12277
|
+
className: "input__increment-button inline-flex h-[23px] w-8 cursor-pointer items-center justify-center rounded-[3px] border-0 bg-[var(--chekin-color-brand-blue)] p-0 text-[20px] font-bold text-white outline-none hover:opacity-90 active:opacity-100",
|
|
12260
12278
|
"aria-label": t("increment"),
|
|
12261
12279
|
children: /* @__PURE__ */ jsx142(Plus3, { size: 16, strokeWidth: 3, "aria-hidden": true })
|
|
12262
12280
|
}
|
|
@@ -12269,18 +12287,18 @@ var Input = React44.forwardRef(
|
|
|
12269
12287
|
"span",
|
|
12270
12288
|
{
|
|
12271
12289
|
"data-testid": `${name}-optional`,
|
|
12272
|
-
className: "mt-[1px] block text-left text-[14px] font-medium text-[var(--chekin-color-gray-1)]",
|
|
12290
|
+
className: "input__optional mt-[1px] block text-left text-[14px] font-medium text-[var(--chekin-color-gray-1)]",
|
|
12273
12291
|
children: typeof optional === "string" ? optional : t("optional")
|
|
12274
12292
|
}
|
|
12275
12293
|
),
|
|
12276
|
-
!errorMessage && helperText && /* @__PURE__ */ jsx142("span", { className: "mt-[1px] block text-[12px] font-normal text-[var(--chekin-color-gray-1)]", children: helperText }),
|
|
12294
|
+
!errorMessage && helperText && /* @__PURE__ */ jsx142("span", { className: "input__helper-text mt-[1px] block text-[12px] font-normal text-[var(--chekin-color-gray-1)]", children: helperText }),
|
|
12277
12295
|
errorMessage && renderErrorMessage && /* @__PURE__ */ jsx142(
|
|
12278
12296
|
FieldErrorMessage,
|
|
12279
12297
|
{
|
|
12280
12298
|
id: errorId,
|
|
12281
12299
|
message: errorMessage,
|
|
12282
12300
|
"data-testid": name ? `${name}-error` : void 0,
|
|
12283
|
-
className: "mt-[1px] text-[14px]"
|
|
12301
|
+
className: "input__error mt-[1px] text-[14px]"
|
|
12284
12302
|
}
|
|
12285
12303
|
),
|
|
12286
12304
|
footer
|
|
@@ -12334,7 +12352,7 @@ function SelectFieldShell({
|
|
|
12334
12352
|
onBlur,
|
|
12335
12353
|
onFocus: handleContainerFocus,
|
|
12336
12354
|
className: cn(
|
|
12337
|
-
"relative w-
|
|
12355
|
+
"relative w-[var(--field-width,100%)] max-w-[var(--field-max-width,296px)] outline-none",
|
|
12338
12356
|
disabled && !loading && "cursor-not-allowed opacity-50",
|
|
12339
12357
|
loading && "cursor-progress opacity-50",
|
|
12340
12358
|
className
|
|
@@ -13080,15 +13098,15 @@ function useSelectMenuState({
|
|
|
13080
13098
|
}) {
|
|
13081
13099
|
const containerRef = React47.useRef(null);
|
|
13082
13100
|
const [internalIsOpen, setInternalIsOpen] = React47.useState(false);
|
|
13083
|
-
const
|
|
13084
|
-
const isOpen =
|
|
13101
|
+
const isControlledOpen = controlledIsOpen === true;
|
|
13102
|
+
const isOpen = isControlledOpen || internalIsOpen;
|
|
13085
13103
|
const setIsOpen = React47.useCallback(
|
|
13086
13104
|
(next) => {
|
|
13087
13105
|
const value = typeof next === "function" ? next(isOpen) : next;
|
|
13088
|
-
|
|
13106
|
+
setInternalIsOpen(value);
|
|
13089
13107
|
onMenuOpenChange?.(value);
|
|
13090
13108
|
},
|
|
13091
|
-
[isOpen,
|
|
13109
|
+
[isOpen, onMenuOpenChange]
|
|
13092
13110
|
);
|
|
13093
13111
|
const openMenu = React47.useCallback(() => {
|
|
13094
13112
|
setIsOpen(true);
|
|
@@ -14238,7 +14256,7 @@ var PhoneInput = React50.forwardRef(function PhoneInput2({
|
|
|
14238
14256
|
"div",
|
|
14239
14257
|
{
|
|
14240
14258
|
className: cn(
|
|
14241
|
-
"relative w-
|
|
14259
|
+
"relative w-[var(--field-width,100%)] max-w-[var(--field-max-width,296px)]",
|
|
14242
14260
|
disabled && "cursor-not-allowed opacity-50",
|
|
14243
14261
|
loading && "cursor-progress",
|
|
14244
14262
|
className
|
|
@@ -15156,7 +15174,7 @@ var Textarea = React60.forwardRef(function Textarea2({
|
|
|
15156
15174
|
"div",
|
|
15157
15175
|
{
|
|
15158
15176
|
className: cn(
|
|
15159
|
-
"relative block min-h-[88px] w-
|
|
15177
|
+
"relative block min-h-[88px] w-[var(--field-width,100%)] max-w-[var(--field-max-width,296px)]",
|
|
15160
15178
|
isBlocked && "cursor-not-allowed opacity-50",
|
|
15161
15179
|
loading && "cursor-progress opacity-50",
|
|
15162
15180
|
className
|
|
@@ -16226,7 +16244,7 @@ var Datepicker = React62.forwardRef(
|
|
|
16226
16244
|
{
|
|
16227
16245
|
ref: containerRef,
|
|
16228
16246
|
className: cn(
|
|
16229
|
-
"relative w-
|
|
16247
|
+
"relative w-[var(--field-width,100%)] max-w-[var(--field-max-width,296px)]",
|
|
16230
16248
|
disabled && "cursor-not-allowed opacity-50",
|
|
16231
16249
|
loading && "cursor-progress opacity-50",
|
|
16232
16250
|
className
|
|
@@ -16587,19 +16605,130 @@ function useRangeValue({
|
|
|
16587
16605
|
|
|
16588
16606
|
// src/dashboard/date-range-picker/hooks/useRangeTextInputs.ts
|
|
16589
16607
|
import * as React64 from "react";
|
|
16608
|
+
|
|
16609
|
+
// src/dashboard/date-range-picker/utils/inputFormat.ts
|
|
16610
|
+
function parseDateInputFormat(format2) {
|
|
16611
|
+
const tokens = [];
|
|
16612
|
+
let i = 0;
|
|
16613
|
+
while (i < format2.length) {
|
|
16614
|
+
const ch = format2[i];
|
|
16615
|
+
if (/[a-zA-Z]/.test(ch)) {
|
|
16616
|
+
let len = 1;
|
|
16617
|
+
while (i + len < format2.length && format2[i + len] === ch) len++;
|
|
16618
|
+
tokens.push({ type: "digits", length: len });
|
|
16619
|
+
i += len;
|
|
16620
|
+
} else {
|
|
16621
|
+
tokens.push({ type: "separator", char: ch });
|
|
16622
|
+
i += 1;
|
|
16623
|
+
}
|
|
16624
|
+
}
|
|
16625
|
+
return tokens;
|
|
16626
|
+
}
|
|
16627
|
+
function getMaxDigits(tokens) {
|
|
16628
|
+
return tokens.reduce(
|
|
16629
|
+
(sum, token) => token.type === "digits" ? sum + token.length : sum,
|
|
16630
|
+
0
|
|
16631
|
+
);
|
|
16632
|
+
}
|
|
16633
|
+
function autoFormatDateInput(raw, tokens) {
|
|
16634
|
+
const digitTokens = tokens.filter(
|
|
16635
|
+
(token) => token.type === "digits"
|
|
16636
|
+
);
|
|
16637
|
+
const sepToken = tokens.find(
|
|
16638
|
+
(token) => token.type === "separator"
|
|
16639
|
+
);
|
|
16640
|
+
const sepChar = sepToken?.char ?? "-";
|
|
16641
|
+
const segments = [];
|
|
16642
|
+
let segIdx = 0;
|
|
16643
|
+
let current = "";
|
|
16644
|
+
let endedWithSeparator = false;
|
|
16645
|
+
for (let i = 0; i < raw.length; i++) {
|
|
16646
|
+
if (segIdx >= digitTokens.length) break;
|
|
16647
|
+
const ch = raw[i];
|
|
16648
|
+
const segLen = digitTokens[segIdx].length;
|
|
16649
|
+
if (/\d/.test(ch)) {
|
|
16650
|
+
if (current.length >= segLen) {
|
|
16651
|
+
segments.push(current);
|
|
16652
|
+
segIdx++;
|
|
16653
|
+
if (segIdx >= digitTokens.length) {
|
|
16654
|
+
current = "";
|
|
16655
|
+
endedWithSeparator = false;
|
|
16656
|
+
break;
|
|
16657
|
+
}
|
|
16658
|
+
current = ch;
|
|
16659
|
+
} else {
|
|
16660
|
+
current += ch;
|
|
16661
|
+
}
|
|
16662
|
+
endedWithSeparator = false;
|
|
16663
|
+
} else if (current.length > 0) {
|
|
16664
|
+
if (current.length < segLen) {
|
|
16665
|
+
if (segLen > 2) continue;
|
|
16666
|
+
current = current.padStart(segLen, "0");
|
|
16667
|
+
}
|
|
16668
|
+
segments.push(current);
|
|
16669
|
+
current = "";
|
|
16670
|
+
segIdx++;
|
|
16671
|
+
endedWithSeparator = true;
|
|
16672
|
+
}
|
|
16673
|
+
}
|
|
16674
|
+
if (current.length > 0) {
|
|
16675
|
+
segments.push(current);
|
|
16676
|
+
endedWithSeparator = false;
|
|
16677
|
+
}
|
|
16678
|
+
let result = segments.join(sepChar);
|
|
16679
|
+
if (endedWithSeparator && segments.length < digitTokens.length) {
|
|
16680
|
+
result += sepChar;
|
|
16681
|
+
}
|
|
16682
|
+
return result;
|
|
16683
|
+
}
|
|
16684
|
+
|
|
16685
|
+
// src/dashboard/date-range-picker/hooks/useRangeTextInputs.ts
|
|
16686
|
+
var countDigits = (text) => text.replace(/\D/g, "").length;
|
|
16590
16687
|
function useRangeTextInputs({
|
|
16591
16688
|
value,
|
|
16592
16689
|
format: format2,
|
|
16593
16690
|
parse: parse3,
|
|
16691
|
+
displayFormat,
|
|
16594
16692
|
onCommit,
|
|
16595
|
-
onBlur
|
|
16693
|
+
onBlur,
|
|
16694
|
+
onFromComplete,
|
|
16695
|
+
onToComplete
|
|
16596
16696
|
}) {
|
|
16697
|
+
const tokens = React64.useMemo(
|
|
16698
|
+
() => parseDateInputFormat(displayFormat),
|
|
16699
|
+
[displayFormat]
|
|
16700
|
+
);
|
|
16701
|
+
const maxDigits = React64.useMemo(() => getMaxDigits(tokens), [tokens]);
|
|
16597
16702
|
const [fromText, setFromText] = React64.useState(value?.from ? format2(value.from) : "");
|
|
16598
16703
|
const [toText, setToText] = React64.useState(value?.to ? format2(value.to) : "");
|
|
16599
16704
|
React64.useEffect(() => {
|
|
16600
16705
|
setFromText(value?.from ? format2(value.from) : "");
|
|
16601
16706
|
setToText(value?.to ? format2(value.to) : "");
|
|
16602
16707
|
}, [format2, value?.from, value?.to]);
|
|
16708
|
+
const handleFromChange = React64.useCallback(
|
|
16709
|
+
(raw) => {
|
|
16710
|
+
const formatted = autoFormatDateInput(raw, tokens);
|
|
16711
|
+
const wasComplete = countDigits(fromText) === maxDigits;
|
|
16712
|
+
const isComplete = countDigits(formatted) === maxDigits;
|
|
16713
|
+
setFromText(formatted);
|
|
16714
|
+
if (!wasComplete && isComplete && parse3(formatted)) {
|
|
16715
|
+
setTimeout(() => onFromComplete?.(), 0);
|
|
16716
|
+
}
|
|
16717
|
+
},
|
|
16718
|
+
[fromText, maxDigits, onFromComplete, parse3, tokens]
|
|
16719
|
+
);
|
|
16720
|
+
const handleToChange = React64.useCallback(
|
|
16721
|
+
(raw) => {
|
|
16722
|
+
const formatted = autoFormatDateInput(raw, tokens);
|
|
16723
|
+
const wasComplete = countDigits(toText) === maxDigits;
|
|
16724
|
+
const isComplete = countDigits(formatted) === maxDigits;
|
|
16725
|
+
setToText(formatted);
|
|
16726
|
+
if (!wasComplete && isComplete && parse3(formatted)) {
|
|
16727
|
+
setTimeout(() => onToComplete?.(), 0);
|
|
16728
|
+
}
|
|
16729
|
+
},
|
|
16730
|
+
[maxDigits, onToComplete, parse3, toText, tokens]
|
|
16731
|
+
);
|
|
16603
16732
|
const handleFromBlur = React64.useCallback(() => {
|
|
16604
16733
|
if (!fromText) {
|
|
16605
16734
|
const next = { from: void 0, to: value?.to };
|
|
@@ -16638,6 +16767,8 @@ function useRangeTextInputs({
|
|
|
16638
16767
|
toText,
|
|
16639
16768
|
setFromText,
|
|
16640
16769
|
setToText,
|
|
16770
|
+
handleFromChange,
|
|
16771
|
+
handleToChange,
|
|
16641
16772
|
handleFromBlur,
|
|
16642
16773
|
handleToBlur
|
|
16643
16774
|
};
|
|
@@ -16742,6 +16873,7 @@ function DateRangeInputs({
|
|
|
16742
16873
|
id: fromId,
|
|
16743
16874
|
name: name ? `${name}-from` : void 0,
|
|
16744
16875
|
type: "text",
|
|
16876
|
+
inputMode: "numeric",
|
|
16745
16877
|
autoComplete: "off",
|
|
16746
16878
|
placeholder: fromPlaceholder,
|
|
16747
16879
|
value: fromText,
|
|
@@ -16777,6 +16909,7 @@ function DateRangeInputs({
|
|
|
16777
16909
|
id: toId,
|
|
16778
16910
|
name: name ? `${name}-to` : void 0,
|
|
16779
16911
|
type: "text",
|
|
16912
|
+
inputMode: "numeric",
|
|
16780
16913
|
autoComplete: "off",
|
|
16781
16914
|
placeholder: toPlaceholder,
|
|
16782
16915
|
value: toText,
|
|
@@ -16978,12 +17111,33 @@ var DateRangePicker = React66.forwardRef(function DateRangePicker2({
|
|
|
16978
17111
|
const normalizedMaxDate = React66.useMemo(() => toDate(maxDate), [maxDate]);
|
|
16979
17112
|
const formatter = React66.useMemo(() => formatDate(displayFormat), [displayFormat]);
|
|
16980
17113
|
const parser = React66.useMemo(() => parseDate(displayFormat), [displayFormat]);
|
|
16981
|
-
const
|
|
17114
|
+
const closeCalendarRef = React66.useRef(() => {
|
|
17115
|
+
});
|
|
17116
|
+
const handleFromComplete = React66.useCallback(() => {
|
|
17117
|
+
toInputRef.current?.focus();
|
|
17118
|
+
}, []);
|
|
17119
|
+
const handleToComplete = React66.useCallback(() => {
|
|
17120
|
+
toInputRef.current?.blur();
|
|
17121
|
+
closeCalendarRef.current();
|
|
17122
|
+
}, []);
|
|
17123
|
+
const {
|
|
17124
|
+
fromText,
|
|
17125
|
+
toText,
|
|
17126
|
+
setFromText,
|
|
17127
|
+
setToText,
|
|
17128
|
+
handleFromChange,
|
|
17129
|
+
handleToChange,
|
|
17130
|
+
handleFromBlur,
|
|
17131
|
+
handleToBlur
|
|
17132
|
+
} = useRangeTextInputs({
|
|
16982
17133
|
value,
|
|
16983
17134
|
format: formatter,
|
|
16984
17135
|
parse: parser,
|
|
17136
|
+
displayFormat,
|
|
16985
17137
|
onCommit: commit,
|
|
16986
|
-
onBlur
|
|
17138
|
+
onBlur,
|
|
17139
|
+
onFromComplete: handleFromComplete,
|
|
17140
|
+
onToComplete: handleToComplete
|
|
16987
17141
|
});
|
|
16988
17142
|
const { month, setMonth, syncMonthToValue } = useRangeMonthSync(value);
|
|
16989
17143
|
const [isOpen, setIsOpen] = React66.useState(false);
|
|
@@ -17005,6 +17159,7 @@ var DateRangePicker = React66.forwardRef(function DateRangePicker2({
|
|
|
17005
17159
|
setAutoFocus(false);
|
|
17006
17160
|
if (value?.from) setMonth(value.from);
|
|
17007
17161
|
}, [setMonth, value?.from]);
|
|
17162
|
+
closeCalendarRef.current = closeCalendar;
|
|
17008
17163
|
const openCalendar = React66.useCallback(() => {
|
|
17009
17164
|
if (isBlocked || readOnly) return;
|
|
17010
17165
|
setIsOpen(true);
|
|
@@ -17082,7 +17237,7 @@ var DateRangePicker = React66.forwardRef(function DateRangePicker2({
|
|
|
17082
17237
|
{
|
|
17083
17238
|
ref: containerRef,
|
|
17084
17239
|
className: cn(
|
|
17085
|
-
"relative w-
|
|
17240
|
+
"relative w-[var(--field-width,100%)] max-w-[var(--field-max-width,296px)]",
|
|
17086
17241
|
disabled && "cursor-not-allowed opacity-50",
|
|
17087
17242
|
loading && "cursor-progress opacity-50",
|
|
17088
17243
|
className
|
|
@@ -17115,8 +17270,8 @@ var DateRangePicker = React66.forwardRef(function DateRangePicker2({
|
|
|
17115
17270
|
focusedInput,
|
|
17116
17271
|
clearLabel: t("clear_dates"),
|
|
17117
17272
|
openCalendarLabel: t("open_calendar"),
|
|
17118
|
-
onFromTextChange:
|
|
17119
|
-
onToTextChange:
|
|
17273
|
+
onFromTextChange: handleFromChange,
|
|
17274
|
+
onToTextChange: handleToChange,
|
|
17120
17275
|
onFromFocus: (event) => {
|
|
17121
17276
|
onFocus?.(event);
|
|
17122
17277
|
setFocusedInput("from");
|
|
@@ -17435,7 +17590,7 @@ var FileInput = React69.forwardRef(function FileInput2({
|
|
|
17435
17590
|
{
|
|
17436
17591
|
htmlFor: inputId,
|
|
17437
17592
|
className: cn(
|
|
17438
|
-
"relative block w-
|
|
17593
|
+
"relative block w-[var(--field-width,100%)] max-w-[var(--field-max-width,296px)] cursor-pointer text-left",
|
|
17439
17594
|
(disabled || readOnly) && "cursor-not-allowed",
|
|
17440
17595
|
loading && "cursor-progress opacity-50",
|
|
17441
17596
|
disabled && "opacity-50",
|