@planetaexo/design-system 0.4.16 → 0.4.18
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 +17 -12
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +17 -12
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -5025,6 +5025,7 @@ var OTPCodeInput = ({
|
|
|
5025
5025
|
const updateValue = (newDigits) => {
|
|
5026
5026
|
onChange(newDigits.join(""));
|
|
5027
5027
|
};
|
|
5028
|
+
const focusedIndexRef = React22.useRef(0);
|
|
5028
5029
|
const focusSlot = (index) => {
|
|
5029
5030
|
var _a;
|
|
5030
5031
|
if (index >= 0 && index < length) {
|
|
@@ -5063,24 +5064,25 @@ var OTPCodeInput = ({
|
|
|
5063
5064
|
e.preventDefault();
|
|
5064
5065
|
}
|
|
5065
5066
|
};
|
|
5066
|
-
const handlePaste = (e) => {
|
|
5067
|
+
const handlePaste = (e, startIndex) => {
|
|
5067
5068
|
e.preventDefault();
|
|
5068
5069
|
const pasted = e.clipboardData.getData("text").replace(/\D/g, "").slice(0, length);
|
|
5069
5070
|
if (!pasted) return;
|
|
5070
5071
|
const newDigits = [...digits];
|
|
5071
|
-
for (let i = 0; i < pasted.length; i++) {
|
|
5072
|
-
newDigits[i] = pasted[i];
|
|
5072
|
+
for (let i = 0; i < pasted.length && startIndex + i < length; i++) {
|
|
5073
|
+
newDigits[startIndex + i] = pasted[i];
|
|
5073
5074
|
}
|
|
5074
5075
|
updateValue(newDigits);
|
|
5075
|
-
const
|
|
5076
|
-
focusSlot(
|
|
5076
|
+
const lastFilled = Math.min(startIndex + pasted.length, length) - 1;
|
|
5077
|
+
focusSlot(lastFilled < length - 1 ? lastFilled + 1 : lastFilled);
|
|
5077
5078
|
};
|
|
5078
|
-
return /* @__PURE__ */ jsxs("div", { className: cn("flex flex-col", className), children: [
|
|
5079
|
+
return /* @__PURE__ */ jsxs("div", { className: cn("flex flex-col items-center", className), children: [
|
|
5079
5080
|
/* @__PURE__ */ jsx(
|
|
5080
5081
|
"label",
|
|
5081
5082
|
{
|
|
5083
|
+
htmlFor: baseId,
|
|
5082
5084
|
className: cn(
|
|
5083
|
-
"text-sm text-muted-foreground mb-2",
|
|
5085
|
+
"self-start text-sm text-muted-foreground font-ui mb-2",
|
|
5084
5086
|
required && "after:content-['*'] after:text-primary after:ml-0.5"
|
|
5085
5087
|
),
|
|
5086
5088
|
children: label
|
|
@@ -5090,7 +5092,7 @@ var OTPCodeInput = ({
|
|
|
5090
5092
|
"div",
|
|
5091
5093
|
{
|
|
5092
5094
|
className: cn(
|
|
5093
|
-
"flex gap-2",
|
|
5095
|
+
"flex justify-center gap-2",
|
|
5094
5096
|
disabled && "opacity-50 pointer-events-none"
|
|
5095
5097
|
),
|
|
5096
5098
|
role: "group",
|
|
@@ -5112,10 +5114,13 @@ var OTPCodeInput = ({
|
|
|
5112
5114
|
disabled,
|
|
5113
5115
|
onChange: (e) => handleChange(index, e.target.value),
|
|
5114
5116
|
onKeyDown: (e) => handleKeyDown(index, e),
|
|
5115
|
-
onPaste: handlePaste,
|
|
5116
|
-
onFocus: (e) =>
|
|
5117
|
+
onPaste: (e) => handlePaste(e, index),
|
|
5118
|
+
onFocus: (e) => {
|
|
5119
|
+
focusedIndexRef.current = index;
|
|
5120
|
+
e.target.select();
|
|
5121
|
+
},
|
|
5117
5122
|
className: cn(
|
|
5118
|
-
"w-
|
|
5123
|
+
"w-11 h-14 text-center text-lg rounded-lg border font-ui",
|
|
5119
5124
|
"bg-background text-foreground border-border",
|
|
5120
5125
|
"transition-colors",
|
|
5121
5126
|
"focus:outline-none focus:border-primary focus:ring-1 focus:ring-primary",
|
|
@@ -5126,7 +5131,7 @@ var OTPCodeInput = ({
|
|
|
5126
5131
|
))
|
|
5127
5132
|
}
|
|
5128
5133
|
),
|
|
5129
|
-
error && /* @__PURE__ */ jsx("p", { className: "mt-1 text-xs text-destructive", children: error })
|
|
5134
|
+
error && /* @__PURE__ */ jsx("p", { className: "mt-1 text-xs text-destructive font-ui self-start", children: error })
|
|
5130
5135
|
] });
|
|
5131
5136
|
};
|
|
5132
5137
|
OTPCodeInput.displayName = "OTPCodeInput";
|