@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.cjs
CHANGED
|
@@ -12488,7 +12488,14 @@ var Input = React44.forwardRef(
|
|
|
12488
12488
|
"div",
|
|
12489
12489
|
{
|
|
12490
12490
|
className: cn(
|
|
12491
|
-
"
|
|
12491
|
+
"input",
|
|
12492
|
+
disabled && "input--disabled",
|
|
12493
|
+
loading && "input--loading",
|
|
12494
|
+
readOnly && "input--readonly",
|
|
12495
|
+
isFocused && "input--focused",
|
|
12496
|
+
isEmpty && "input--empty",
|
|
12497
|
+
hasInvalidState && "input--invalid",
|
|
12498
|
+
"relative block w-[var(--field-width,100%)] max-w-[var(--field-max-width,296px)] min-h-[var(--field-min-height,48px)]",
|
|
12492
12499
|
disabled && "cursor-not-allowed opacity-50",
|
|
12493
12500
|
loading && "cursor-progress opacity-50",
|
|
12494
12501
|
wrapperClassName,
|
|
@@ -12499,7 +12506,7 @@ var Input = React44.forwardRef(
|
|
|
12499
12506
|
"label",
|
|
12500
12507
|
{
|
|
12501
12508
|
htmlFor: inputId,
|
|
12502
|
-
className: "mb-2 block text-[14px] font-medium text-[var(--chekin-color-brand-navy)]",
|
|
12509
|
+
className: "input__top-label mb-2 block text-[14px] font-medium text-[var(--chekin-color-brand-navy)]",
|
|
12503
12510
|
children: topLabel
|
|
12504
12511
|
}
|
|
12505
12512
|
),
|
|
@@ -12507,110 +12514,121 @@ var Input = React44.forwardRef(
|
|
|
12507
12514
|
"div",
|
|
12508
12515
|
{
|
|
12509
12516
|
className: cn(
|
|
12517
|
+
"input__field",
|
|
12510
12518
|
"relative block w-full",
|
|
12511
12519
|
readOnly && "bg-[var(--empty-field-background)]",
|
|
12512
12520
|
fieldClassName
|
|
12513
12521
|
),
|
|
12514
12522
|
children: [
|
|
12515
|
-
/* @__PURE__ */ (0, import_jsx_runtime144.jsxs)(
|
|
12516
|
-
|
|
12517
|
-
|
|
12518
|
-
|
|
12519
|
-
|
|
12520
|
-
|
|
12521
|
-
|
|
12522
|
-
onClick: handleLabelClick,
|
|
12523
|
-
isActivated: !isEmpty || isFocused,
|
|
12524
|
-
readOnly,
|
|
12525
|
-
loading,
|
|
12526
|
-
disabled,
|
|
12527
|
-
htmlFor: inputId,
|
|
12528
|
-
labelId: `${inputId}-label`,
|
|
12529
|
-
legend: typeof label === "string" ? label : void 0,
|
|
12530
|
-
label,
|
|
12531
|
-
tooltip,
|
|
12532
|
-
labelClassName: cn({
|
|
12533
|
-
"pl-[28px]": !!leftIcon
|
|
12534
|
-
})
|
|
12535
|
-
}
|
|
12536
|
-
),
|
|
12537
|
-
leftIcon && /* @__PURE__ */ (0, import_jsx_runtime144.jsx)("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__ */ (0, import_jsx_runtime144.jsx)("span", { className: "flex h-full w-10 items-center justify-center", children: leftIcon }) }),
|
|
12538
|
-
/* @__PURE__ */ (0, import_jsx_runtime144.jsx)(
|
|
12539
|
-
"input",
|
|
12540
|
-
{
|
|
12541
|
-
...props,
|
|
12542
|
-
ref: combinedInputRef,
|
|
12543
|
-
id: inputId,
|
|
12544
|
-
name,
|
|
12545
|
-
type: inputType,
|
|
12546
|
-
"data-testid": "input",
|
|
12547
|
-
value,
|
|
12548
|
-
defaultValue,
|
|
12549
|
-
disabled: disabled || loading,
|
|
12550
|
-
readOnly,
|
|
12551
|
-
required: !optional,
|
|
12552
|
-
"aria-label": typeof label === "string" ? label : void 0,
|
|
12553
|
-
"aria-invalid": hasInvalidState,
|
|
12554
|
-
"aria-busy": loading,
|
|
12555
|
-
"aria-describedby": errorMessage && renderErrorMessage ? errorId : void 0,
|
|
12556
|
-
placeholder: isFocused || !label ? placeholder : void 0,
|
|
12557
|
-
onChange: handleChange,
|
|
12558
|
-
onFocus: handleFocus,
|
|
12559
|
-
onBlur: handleBlur,
|
|
12560
|
-
className: cn(
|
|
12561
|
-
"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",
|
|
12562
|
-
"placeholder:font-medium placeholder:text-[var(--chekin-color-gray-1)] placeholder:opacity-100",
|
|
12563
|
-
isEmpty && !isFocused ? "bg-[var(--empty-field-background)]" : "bg-transparent",
|
|
12564
|
-
isEmpty && "text-[var(--chekin-color-gray-1)]",
|
|
12565
|
-
inputType === "password" && "[&:not(:placeholder-shown)]:font-bold [&:not(:placeholder-shown)]:tracking-[2px]",
|
|
12566
|
-
(disabled || readOnly) && "cursor-not-allowed",
|
|
12567
|
-
loading && "cursor-progress",
|
|
12568
|
-
leftIcon && "pl-10",
|
|
12569
|
-
(showRightPaddingForReset || showRightPaddingForReveal) && "pr-10",
|
|
12570
|
-
sign && "pr-10",
|
|
12571
|
-
inputClassName
|
|
12572
|
-
)
|
|
12573
|
-
}
|
|
12574
|
-
),
|
|
12575
|
-
sign && /* @__PURE__ */ (0, import_jsx_runtime144.jsx)("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 }),
|
|
12576
|
-
trailingAdornment && /* @__PURE__ */ (0, import_jsx_runtime144.jsx)("span", { className: "pointer-events-none absolute right-[14px] top-0 flex h-full items-center", children: trailingAdornment }),
|
|
12577
|
-
onReset && !isEmpty && /* @__PURE__ */ (0, import_jsx_runtime144.jsx)(
|
|
12578
|
-
"button",
|
|
12579
|
-
{
|
|
12580
|
-
type: "button",
|
|
12581
|
-
onClick: onReset,
|
|
12582
|
-
disabled,
|
|
12583
|
-
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",
|
|
12584
|
-
"aria-label": t("reset"),
|
|
12585
|
-
children: /* @__PURE__ */ (0, import_jsx_runtime144.jsx)(import_lucide_react42.X, { size: 14 })
|
|
12586
|
-
}
|
|
12587
|
-
),
|
|
12588
|
-
isPasswordReveal && /* @__PURE__ */ (0, import_jsx_runtime144.jsx)(
|
|
12589
|
-
"button",
|
|
12590
|
-
{
|
|
12591
|
-
type: "button",
|
|
12592
|
-
onClick: togglePasswordReveal,
|
|
12593
|
-
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",
|
|
12594
|
-
"aria-label": isPasswordRevealed ? t("hide_password") : t("show_password"),
|
|
12595
|
-
children: /* @__PURE__ */ (0, import_jsx_runtime144.jsx)(
|
|
12596
|
-
import_lucide_react42.Eye,
|
|
12523
|
+
/* @__PURE__ */ (0, import_jsx_runtime144.jsxs)(
|
|
12524
|
+
"div",
|
|
12525
|
+
{
|
|
12526
|
+
className: cn("input__content relative w-full cursor-text", contentClassName),
|
|
12527
|
+
children: [
|
|
12528
|
+
/* @__PURE__ */ (0, import_jsx_runtime144.jsx)(
|
|
12529
|
+
Fieldset,
|
|
12597
12530
|
{
|
|
12598
|
-
|
|
12531
|
+
isFocused: isFocused && !readOnly,
|
|
12532
|
+
invalid: hasInvalidState,
|
|
12533
|
+
isEmpty,
|
|
12534
|
+
onClick: handleLabelClick,
|
|
12535
|
+
isActivated: !isEmpty || isFocused,
|
|
12536
|
+
readOnly,
|
|
12537
|
+
loading,
|
|
12538
|
+
disabled,
|
|
12539
|
+
htmlFor: inputId,
|
|
12540
|
+
labelId: `${inputId}-label`,
|
|
12541
|
+
legend: typeof label === "string" ? label : void 0,
|
|
12542
|
+
label,
|
|
12543
|
+
tooltip,
|
|
12544
|
+
className: "input__fieldset",
|
|
12545
|
+
labelClassName: cn({
|
|
12546
|
+
input__label: true,
|
|
12547
|
+
"pl-[28px]": !!leftIcon
|
|
12548
|
+
})
|
|
12549
|
+
}
|
|
12550
|
+
),
|
|
12551
|
+
leftIcon && /* @__PURE__ */ (0, import_jsx_runtime144.jsx)("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__ */ (0, import_jsx_runtime144.jsx)("span", { className: "input__left-icon-inner flex h-full w-10 items-center justify-center", children: leftIcon }) }),
|
|
12552
|
+
/* @__PURE__ */ (0, import_jsx_runtime144.jsx)(
|
|
12553
|
+
"input",
|
|
12554
|
+
{
|
|
12555
|
+
...props,
|
|
12556
|
+
ref: combinedInputRef,
|
|
12557
|
+
id: inputId,
|
|
12558
|
+
name,
|
|
12559
|
+
type: inputType,
|
|
12560
|
+
"data-testid": "input",
|
|
12561
|
+
value,
|
|
12562
|
+
defaultValue,
|
|
12563
|
+
disabled: disabled || loading,
|
|
12564
|
+
readOnly,
|
|
12565
|
+
required: !optional,
|
|
12566
|
+
"aria-label": typeof label === "string" ? label : void 0,
|
|
12567
|
+
"aria-invalid": hasInvalidState,
|
|
12568
|
+
"aria-busy": loading,
|
|
12569
|
+
"aria-describedby": errorMessage && renderErrorMessage ? errorId : void 0,
|
|
12570
|
+
placeholder: isFocused || !label ? placeholder : void 0,
|
|
12571
|
+
onChange: handleChange,
|
|
12572
|
+
onFocus: handleFocus,
|
|
12573
|
+
onBlur: handleBlur,
|
|
12599
12574
|
className: cn(
|
|
12600
|
-
|
|
12575
|
+
"input__control",
|
|
12576
|
+
"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",
|
|
12577
|
+
"placeholder:font-medium placeholder:text-[var(--chekin-color-gray-1)] placeholder:opacity-100",
|
|
12578
|
+
isEmpty && !isFocused ? "bg-[var(--empty-field-background)]" : "bg-transparent",
|
|
12579
|
+
isEmpty && "text-[var(--chekin-color-gray-1)]",
|
|
12580
|
+
inputType === "password" && "[&:not(:placeholder-shown)]:font-bold [&:not(:placeholder-shown)]:tracking-[2px]",
|
|
12581
|
+
(disabled || readOnly) && "cursor-not-allowed",
|
|
12582
|
+
loading && "cursor-progress",
|
|
12583
|
+
leftIcon && "pl-10",
|
|
12584
|
+
(showRightPaddingForReset || showRightPaddingForReveal) && "pr-10",
|
|
12585
|
+
sign && "pr-10",
|
|
12586
|
+
inputClassName
|
|
12587
|
+
)
|
|
12588
|
+
}
|
|
12589
|
+
),
|
|
12590
|
+
sign && /* @__PURE__ */ (0, import_jsx_runtime144.jsx)("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 }),
|
|
12591
|
+
trailingAdornment && /* @__PURE__ */ (0, import_jsx_runtime144.jsx)("span", { className: "input__trailing-adornment pointer-events-none absolute right-[14px] top-0 flex h-full items-center", children: trailingAdornment }),
|
|
12592
|
+
onReset && !isEmpty && /* @__PURE__ */ (0, import_jsx_runtime144.jsx)(
|
|
12593
|
+
"button",
|
|
12594
|
+
{
|
|
12595
|
+
type: "button",
|
|
12596
|
+
onClick: onReset,
|
|
12597
|
+
disabled,
|
|
12598
|
+
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",
|
|
12599
|
+
"aria-label": t("reset"),
|
|
12600
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime144.jsx)(import_lucide_react42.X, { size: 14 })
|
|
12601
|
+
}
|
|
12602
|
+
),
|
|
12603
|
+
isPasswordReveal && /* @__PURE__ */ (0, import_jsx_runtime144.jsx)(
|
|
12604
|
+
"button",
|
|
12605
|
+
{
|
|
12606
|
+
type: "button",
|
|
12607
|
+
onClick: togglePasswordReveal,
|
|
12608
|
+
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",
|
|
12609
|
+
"aria-label": isPasswordRevealed ? t("hide_password") : t("show_password"),
|
|
12610
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime144.jsx)(
|
|
12611
|
+
import_lucide_react42.Eye,
|
|
12612
|
+
{
|
|
12613
|
+
size: 20,
|
|
12614
|
+
className: cn(
|
|
12615
|
+
"input__password-icon",
|
|
12616
|
+
isPasswordRevealed ? "text-[#fc98dd]" : "text-[var(--chekin-color-gray-2)]"
|
|
12617
|
+
)
|
|
12618
|
+
}
|
|
12601
12619
|
)
|
|
12602
12620
|
}
|
|
12603
12621
|
)
|
|
12604
|
-
|
|
12605
|
-
|
|
12606
|
-
|
|
12607
|
-
type === "number" && showNumberButtons && /* @__PURE__ */ (0, import_jsx_runtime144.jsxs)("div", { className: "absolute right-[18px] top-[13px] inline-flex items-center text-right", children: [
|
|
12622
|
+
]
|
|
12623
|
+
}
|
|
12624
|
+
),
|
|
12625
|
+
type === "number" && showNumberButtons && /* @__PURE__ */ (0, import_jsx_runtime144.jsxs)("div", { className: "input__number-controls absolute right-[18px] top-[13px] inline-flex items-center text-right", children: [
|
|
12608
12626
|
/* @__PURE__ */ (0, import_jsx_runtime144.jsx)(
|
|
12609
12627
|
"button",
|
|
12610
12628
|
{
|
|
12611
12629
|
type: "button",
|
|
12612
12630
|
onClick: onDecrement,
|
|
12613
|
-
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",
|
|
12631
|
+
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",
|
|
12614
12632
|
"aria-label": t("decrement"),
|
|
12615
12633
|
children: /* @__PURE__ */ (0, import_jsx_runtime144.jsx)(import_lucide_react42.Minus, { size: 16, strokeWidth: 3, "aria-hidden": true })
|
|
12616
12634
|
}
|
|
@@ -12620,7 +12638,7 @@ var Input = React44.forwardRef(
|
|
|
12620
12638
|
{
|
|
12621
12639
|
type: "button",
|
|
12622
12640
|
onClick: onIncrement,
|
|
12623
|
-
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",
|
|
12641
|
+
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",
|
|
12624
12642
|
"aria-label": t("increment"),
|
|
12625
12643
|
children: /* @__PURE__ */ (0, import_jsx_runtime144.jsx)(import_lucide_react42.Plus, { size: 16, strokeWidth: 3, "aria-hidden": true })
|
|
12626
12644
|
}
|
|
@@ -12633,18 +12651,18 @@ var Input = React44.forwardRef(
|
|
|
12633
12651
|
"span",
|
|
12634
12652
|
{
|
|
12635
12653
|
"data-testid": `${name}-optional`,
|
|
12636
|
-
className: "mt-[1px] block text-left text-[14px] font-medium text-[var(--chekin-color-gray-1)]",
|
|
12654
|
+
className: "input__optional mt-[1px] block text-left text-[14px] font-medium text-[var(--chekin-color-gray-1)]",
|
|
12637
12655
|
children: typeof optional === "string" ? optional : t("optional")
|
|
12638
12656
|
}
|
|
12639
12657
|
),
|
|
12640
|
-
!errorMessage && helperText && /* @__PURE__ */ (0, import_jsx_runtime144.jsx)("span", { className: "mt-[1px] block text-[12px] font-normal text-[var(--chekin-color-gray-1)]", children: helperText }),
|
|
12658
|
+
!errorMessage && helperText && /* @__PURE__ */ (0, import_jsx_runtime144.jsx)("span", { className: "input__helper-text mt-[1px] block text-[12px] font-normal text-[var(--chekin-color-gray-1)]", children: helperText }),
|
|
12641
12659
|
errorMessage && renderErrorMessage && /* @__PURE__ */ (0, import_jsx_runtime144.jsx)(
|
|
12642
12660
|
FieldErrorMessage,
|
|
12643
12661
|
{
|
|
12644
12662
|
id: errorId,
|
|
12645
12663
|
message: errorMessage,
|
|
12646
12664
|
"data-testid": name ? `${name}-error` : void 0,
|
|
12647
|
-
className: "mt-[1px] text-[14px]"
|
|
12665
|
+
className: "input__error mt-[1px] text-[14px]"
|
|
12648
12666
|
}
|
|
12649
12667
|
),
|
|
12650
12668
|
footer
|
|
@@ -12698,7 +12716,7 @@ function SelectFieldShell({
|
|
|
12698
12716
|
onBlur,
|
|
12699
12717
|
onFocus: handleContainerFocus,
|
|
12700
12718
|
className: cn(
|
|
12701
|
-
"relative w-
|
|
12719
|
+
"relative w-[var(--field-width,100%)] max-w-[var(--field-max-width,296px)] outline-none",
|
|
12702
12720
|
disabled && !loading && "cursor-not-allowed opacity-50",
|
|
12703
12721
|
loading && "cursor-progress opacity-50",
|
|
12704
12722
|
className
|
|
@@ -13444,15 +13462,15 @@ function useSelectMenuState({
|
|
|
13444
13462
|
}) {
|
|
13445
13463
|
const containerRef = React47.useRef(null);
|
|
13446
13464
|
const [internalIsOpen, setInternalIsOpen] = React47.useState(false);
|
|
13447
|
-
const
|
|
13448
|
-
const isOpen =
|
|
13465
|
+
const isControlledOpen = controlledIsOpen === true;
|
|
13466
|
+
const isOpen = isControlledOpen || internalIsOpen;
|
|
13449
13467
|
const setIsOpen = React47.useCallback(
|
|
13450
13468
|
(next) => {
|
|
13451
13469
|
const value = typeof next === "function" ? next(isOpen) : next;
|
|
13452
|
-
|
|
13470
|
+
setInternalIsOpen(value);
|
|
13453
13471
|
onMenuOpenChange?.(value);
|
|
13454
13472
|
},
|
|
13455
|
-
[isOpen,
|
|
13473
|
+
[isOpen, onMenuOpenChange]
|
|
13456
13474
|
);
|
|
13457
13475
|
const openMenu = React47.useCallback(() => {
|
|
13458
13476
|
setIsOpen(true);
|
|
@@ -14602,7 +14620,7 @@ var PhoneInput = React50.forwardRef(function PhoneInput2({
|
|
|
14602
14620
|
"div",
|
|
14603
14621
|
{
|
|
14604
14622
|
className: cn(
|
|
14605
|
-
"relative w-
|
|
14623
|
+
"relative w-[var(--field-width,100%)] max-w-[var(--field-max-width,296px)]",
|
|
14606
14624
|
disabled && "cursor-not-allowed opacity-50",
|
|
14607
14625
|
loading && "cursor-progress",
|
|
14608
14626
|
className
|
|
@@ -15520,7 +15538,7 @@ var Textarea = React60.forwardRef(function Textarea2({
|
|
|
15520
15538
|
"div",
|
|
15521
15539
|
{
|
|
15522
15540
|
className: cn(
|
|
15523
|
-
"relative block min-h-[88px] w-
|
|
15541
|
+
"relative block min-h-[88px] w-[var(--field-width,100%)] max-w-[var(--field-max-width,296px)]",
|
|
15524
15542
|
isBlocked && "cursor-not-allowed opacity-50",
|
|
15525
15543
|
loading && "cursor-progress opacity-50",
|
|
15526
15544
|
className
|
|
@@ -16590,7 +16608,7 @@ var Datepicker = React62.forwardRef(
|
|
|
16590
16608
|
{
|
|
16591
16609
|
ref: containerRef,
|
|
16592
16610
|
className: cn(
|
|
16593
|
-
"relative w-
|
|
16611
|
+
"relative w-[var(--field-width,100%)] max-w-[var(--field-max-width,296px)]",
|
|
16594
16612
|
disabled && "cursor-not-allowed opacity-50",
|
|
16595
16613
|
loading && "cursor-progress opacity-50",
|
|
16596
16614
|
className
|
|
@@ -16951,19 +16969,130 @@ function useRangeValue({
|
|
|
16951
16969
|
|
|
16952
16970
|
// src/dashboard/date-range-picker/hooks/useRangeTextInputs.ts
|
|
16953
16971
|
var React64 = __toESM(require("react"), 1);
|
|
16972
|
+
|
|
16973
|
+
// src/dashboard/date-range-picker/utils/inputFormat.ts
|
|
16974
|
+
function parseDateInputFormat(format2) {
|
|
16975
|
+
const tokens = [];
|
|
16976
|
+
let i = 0;
|
|
16977
|
+
while (i < format2.length) {
|
|
16978
|
+
const ch = format2[i];
|
|
16979
|
+
if (/[a-zA-Z]/.test(ch)) {
|
|
16980
|
+
let len = 1;
|
|
16981
|
+
while (i + len < format2.length && format2[i + len] === ch) len++;
|
|
16982
|
+
tokens.push({ type: "digits", length: len });
|
|
16983
|
+
i += len;
|
|
16984
|
+
} else {
|
|
16985
|
+
tokens.push({ type: "separator", char: ch });
|
|
16986
|
+
i += 1;
|
|
16987
|
+
}
|
|
16988
|
+
}
|
|
16989
|
+
return tokens;
|
|
16990
|
+
}
|
|
16991
|
+
function getMaxDigits(tokens) {
|
|
16992
|
+
return tokens.reduce(
|
|
16993
|
+
(sum, token) => token.type === "digits" ? sum + token.length : sum,
|
|
16994
|
+
0
|
|
16995
|
+
);
|
|
16996
|
+
}
|
|
16997
|
+
function autoFormatDateInput(raw, tokens) {
|
|
16998
|
+
const digitTokens = tokens.filter(
|
|
16999
|
+
(token) => token.type === "digits"
|
|
17000
|
+
);
|
|
17001
|
+
const sepToken = tokens.find(
|
|
17002
|
+
(token) => token.type === "separator"
|
|
17003
|
+
);
|
|
17004
|
+
const sepChar = sepToken?.char ?? "-";
|
|
17005
|
+
const segments = [];
|
|
17006
|
+
let segIdx = 0;
|
|
17007
|
+
let current = "";
|
|
17008
|
+
let endedWithSeparator = false;
|
|
17009
|
+
for (let i = 0; i < raw.length; i++) {
|
|
17010
|
+
if (segIdx >= digitTokens.length) break;
|
|
17011
|
+
const ch = raw[i];
|
|
17012
|
+
const segLen = digitTokens[segIdx].length;
|
|
17013
|
+
if (/\d/.test(ch)) {
|
|
17014
|
+
if (current.length >= segLen) {
|
|
17015
|
+
segments.push(current);
|
|
17016
|
+
segIdx++;
|
|
17017
|
+
if (segIdx >= digitTokens.length) {
|
|
17018
|
+
current = "";
|
|
17019
|
+
endedWithSeparator = false;
|
|
17020
|
+
break;
|
|
17021
|
+
}
|
|
17022
|
+
current = ch;
|
|
17023
|
+
} else {
|
|
17024
|
+
current += ch;
|
|
17025
|
+
}
|
|
17026
|
+
endedWithSeparator = false;
|
|
17027
|
+
} else if (current.length > 0) {
|
|
17028
|
+
if (current.length < segLen) {
|
|
17029
|
+
if (segLen > 2) continue;
|
|
17030
|
+
current = current.padStart(segLen, "0");
|
|
17031
|
+
}
|
|
17032
|
+
segments.push(current);
|
|
17033
|
+
current = "";
|
|
17034
|
+
segIdx++;
|
|
17035
|
+
endedWithSeparator = true;
|
|
17036
|
+
}
|
|
17037
|
+
}
|
|
17038
|
+
if (current.length > 0) {
|
|
17039
|
+
segments.push(current);
|
|
17040
|
+
endedWithSeparator = false;
|
|
17041
|
+
}
|
|
17042
|
+
let result = segments.join(sepChar);
|
|
17043
|
+
if (endedWithSeparator && segments.length < digitTokens.length) {
|
|
17044
|
+
result += sepChar;
|
|
17045
|
+
}
|
|
17046
|
+
return result;
|
|
17047
|
+
}
|
|
17048
|
+
|
|
17049
|
+
// src/dashboard/date-range-picker/hooks/useRangeTextInputs.ts
|
|
17050
|
+
var countDigits = (text) => text.replace(/\D/g, "").length;
|
|
16954
17051
|
function useRangeTextInputs({
|
|
16955
17052
|
value,
|
|
16956
17053
|
format: format2,
|
|
16957
17054
|
parse: parse3,
|
|
17055
|
+
displayFormat,
|
|
16958
17056
|
onCommit,
|
|
16959
|
-
onBlur
|
|
17057
|
+
onBlur,
|
|
17058
|
+
onFromComplete,
|
|
17059
|
+
onToComplete
|
|
16960
17060
|
}) {
|
|
17061
|
+
const tokens = React64.useMemo(
|
|
17062
|
+
() => parseDateInputFormat(displayFormat),
|
|
17063
|
+
[displayFormat]
|
|
17064
|
+
);
|
|
17065
|
+
const maxDigits = React64.useMemo(() => getMaxDigits(tokens), [tokens]);
|
|
16961
17066
|
const [fromText, setFromText] = React64.useState(value?.from ? format2(value.from) : "");
|
|
16962
17067
|
const [toText, setToText] = React64.useState(value?.to ? format2(value.to) : "");
|
|
16963
17068
|
React64.useEffect(() => {
|
|
16964
17069
|
setFromText(value?.from ? format2(value.from) : "");
|
|
16965
17070
|
setToText(value?.to ? format2(value.to) : "");
|
|
16966
17071
|
}, [format2, value?.from, value?.to]);
|
|
17072
|
+
const handleFromChange = React64.useCallback(
|
|
17073
|
+
(raw) => {
|
|
17074
|
+
const formatted = autoFormatDateInput(raw, tokens);
|
|
17075
|
+
const wasComplete = countDigits(fromText) === maxDigits;
|
|
17076
|
+
const isComplete = countDigits(formatted) === maxDigits;
|
|
17077
|
+
setFromText(formatted);
|
|
17078
|
+
if (!wasComplete && isComplete && parse3(formatted)) {
|
|
17079
|
+
setTimeout(() => onFromComplete?.(), 0);
|
|
17080
|
+
}
|
|
17081
|
+
},
|
|
17082
|
+
[fromText, maxDigits, onFromComplete, parse3, tokens]
|
|
17083
|
+
);
|
|
17084
|
+
const handleToChange = React64.useCallback(
|
|
17085
|
+
(raw) => {
|
|
17086
|
+
const formatted = autoFormatDateInput(raw, tokens);
|
|
17087
|
+
const wasComplete = countDigits(toText) === maxDigits;
|
|
17088
|
+
const isComplete = countDigits(formatted) === maxDigits;
|
|
17089
|
+
setToText(formatted);
|
|
17090
|
+
if (!wasComplete && isComplete && parse3(formatted)) {
|
|
17091
|
+
setTimeout(() => onToComplete?.(), 0);
|
|
17092
|
+
}
|
|
17093
|
+
},
|
|
17094
|
+
[maxDigits, onToComplete, parse3, toText, tokens]
|
|
17095
|
+
);
|
|
16967
17096
|
const handleFromBlur = React64.useCallback(() => {
|
|
16968
17097
|
if (!fromText) {
|
|
16969
17098
|
const next = { from: void 0, to: value?.to };
|
|
@@ -17002,6 +17131,8 @@ function useRangeTextInputs({
|
|
|
17002
17131
|
toText,
|
|
17003
17132
|
setFromText,
|
|
17004
17133
|
setToText,
|
|
17134
|
+
handleFromChange,
|
|
17135
|
+
handleToChange,
|
|
17005
17136
|
handleFromBlur,
|
|
17006
17137
|
handleToBlur
|
|
17007
17138
|
};
|
|
@@ -17106,6 +17237,7 @@ function DateRangeInputs({
|
|
|
17106
17237
|
id: fromId,
|
|
17107
17238
|
name: name ? `${name}-from` : void 0,
|
|
17108
17239
|
type: "text",
|
|
17240
|
+
inputMode: "numeric",
|
|
17109
17241
|
autoComplete: "off",
|
|
17110
17242
|
placeholder: fromPlaceholder,
|
|
17111
17243
|
value: fromText,
|
|
@@ -17141,6 +17273,7 @@ function DateRangeInputs({
|
|
|
17141
17273
|
id: toId,
|
|
17142
17274
|
name: name ? `${name}-to` : void 0,
|
|
17143
17275
|
type: "text",
|
|
17276
|
+
inputMode: "numeric",
|
|
17144
17277
|
autoComplete: "off",
|
|
17145
17278
|
placeholder: toPlaceholder,
|
|
17146
17279
|
value: toText,
|
|
@@ -17342,12 +17475,33 @@ var DateRangePicker = React66.forwardRef(function DateRangePicker2({
|
|
|
17342
17475
|
const normalizedMaxDate = React66.useMemo(() => toDate(maxDate), [maxDate]);
|
|
17343
17476
|
const formatter = React66.useMemo(() => formatDate(displayFormat), [displayFormat]);
|
|
17344
17477
|
const parser = React66.useMemo(() => parseDate(displayFormat), [displayFormat]);
|
|
17345
|
-
const
|
|
17478
|
+
const closeCalendarRef = React66.useRef(() => {
|
|
17479
|
+
});
|
|
17480
|
+
const handleFromComplete = React66.useCallback(() => {
|
|
17481
|
+
toInputRef.current?.focus();
|
|
17482
|
+
}, []);
|
|
17483
|
+
const handleToComplete = React66.useCallback(() => {
|
|
17484
|
+
toInputRef.current?.blur();
|
|
17485
|
+
closeCalendarRef.current();
|
|
17486
|
+
}, []);
|
|
17487
|
+
const {
|
|
17488
|
+
fromText,
|
|
17489
|
+
toText,
|
|
17490
|
+
setFromText,
|
|
17491
|
+
setToText,
|
|
17492
|
+
handleFromChange,
|
|
17493
|
+
handleToChange,
|
|
17494
|
+
handleFromBlur,
|
|
17495
|
+
handleToBlur
|
|
17496
|
+
} = useRangeTextInputs({
|
|
17346
17497
|
value,
|
|
17347
17498
|
format: formatter,
|
|
17348
17499
|
parse: parser,
|
|
17500
|
+
displayFormat,
|
|
17349
17501
|
onCommit: commit,
|
|
17350
|
-
onBlur
|
|
17502
|
+
onBlur,
|
|
17503
|
+
onFromComplete: handleFromComplete,
|
|
17504
|
+
onToComplete: handleToComplete
|
|
17351
17505
|
});
|
|
17352
17506
|
const { month, setMonth, syncMonthToValue } = useRangeMonthSync(value);
|
|
17353
17507
|
const [isOpen, setIsOpen] = React66.useState(false);
|
|
@@ -17369,6 +17523,7 @@ var DateRangePicker = React66.forwardRef(function DateRangePicker2({
|
|
|
17369
17523
|
setAutoFocus(false);
|
|
17370
17524
|
if (value?.from) setMonth(value.from);
|
|
17371
17525
|
}, [setMonth, value?.from]);
|
|
17526
|
+
closeCalendarRef.current = closeCalendar;
|
|
17372
17527
|
const openCalendar = React66.useCallback(() => {
|
|
17373
17528
|
if (isBlocked || readOnly) return;
|
|
17374
17529
|
setIsOpen(true);
|
|
@@ -17446,7 +17601,7 @@ var DateRangePicker = React66.forwardRef(function DateRangePicker2({
|
|
|
17446
17601
|
{
|
|
17447
17602
|
ref: containerRef,
|
|
17448
17603
|
className: cn(
|
|
17449
|
-
"relative w-
|
|
17604
|
+
"relative w-[var(--field-width,100%)] max-w-[var(--field-max-width,296px)]",
|
|
17450
17605
|
disabled && "cursor-not-allowed opacity-50",
|
|
17451
17606
|
loading && "cursor-progress opacity-50",
|
|
17452
17607
|
className
|
|
@@ -17479,8 +17634,8 @@ var DateRangePicker = React66.forwardRef(function DateRangePicker2({
|
|
|
17479
17634
|
focusedInput,
|
|
17480
17635
|
clearLabel: t("clear_dates"),
|
|
17481
17636
|
openCalendarLabel: t("open_calendar"),
|
|
17482
|
-
onFromTextChange:
|
|
17483
|
-
onToTextChange:
|
|
17637
|
+
onFromTextChange: handleFromChange,
|
|
17638
|
+
onToTextChange: handleToChange,
|
|
17484
17639
|
onFromFocus: (event) => {
|
|
17485
17640
|
onFocus?.(event);
|
|
17486
17641
|
setFocusedInput("from");
|
|
@@ -17796,7 +17951,7 @@ var FileInput = React69.forwardRef(function FileInput2({
|
|
|
17796
17951
|
{
|
|
17797
17952
|
htmlFor: inputId,
|
|
17798
17953
|
className: cn(
|
|
17799
|
-
"relative block w-
|
|
17954
|
+
"relative block w-[var(--field-width,100%)] max-w-[var(--field-max-width,296px)] cursor-pointer text-left",
|
|
17800
17955
|
(disabled || readOnly) && "cursor-not-allowed",
|
|
17801
17956
|
loading && "cursor-progress opacity-50",
|
|
17802
17957
|
disabled && "opacity-50",
|