@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.cjs
CHANGED
|
@@ -5046,6 +5046,7 @@ var OTPCodeInput = ({
|
|
|
5046
5046
|
const updateValue = (newDigits) => {
|
|
5047
5047
|
onChange(newDigits.join(""));
|
|
5048
5048
|
};
|
|
5049
|
+
const focusedIndexRef = React22__namespace.useRef(0);
|
|
5049
5050
|
const focusSlot = (index) => {
|
|
5050
5051
|
var _a;
|
|
5051
5052
|
if (index >= 0 && index < length) {
|
|
@@ -5084,24 +5085,25 @@ var OTPCodeInput = ({
|
|
|
5084
5085
|
e.preventDefault();
|
|
5085
5086
|
}
|
|
5086
5087
|
};
|
|
5087
|
-
const handlePaste = (e) => {
|
|
5088
|
+
const handlePaste = (e, startIndex) => {
|
|
5088
5089
|
e.preventDefault();
|
|
5089
5090
|
const pasted = e.clipboardData.getData("text").replace(/\D/g, "").slice(0, length);
|
|
5090
5091
|
if (!pasted) return;
|
|
5091
5092
|
const newDigits = [...digits];
|
|
5092
|
-
for (let i = 0; i < pasted.length; i++) {
|
|
5093
|
-
newDigits[i] = pasted[i];
|
|
5093
|
+
for (let i = 0; i < pasted.length && startIndex + i < length; i++) {
|
|
5094
|
+
newDigits[startIndex + i] = pasted[i];
|
|
5094
5095
|
}
|
|
5095
5096
|
updateValue(newDigits);
|
|
5096
|
-
const
|
|
5097
|
-
focusSlot(
|
|
5097
|
+
const lastFilled = Math.min(startIndex + pasted.length, length) - 1;
|
|
5098
|
+
focusSlot(lastFilled < length - 1 ? lastFilled + 1 : lastFilled);
|
|
5098
5099
|
};
|
|
5099
|
-
return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: cn("flex flex-col", className), children: [
|
|
5100
|
+
return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: cn("flex flex-col items-center", className), children: [
|
|
5100
5101
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
5101
5102
|
"label",
|
|
5102
5103
|
{
|
|
5104
|
+
htmlFor: baseId,
|
|
5103
5105
|
className: cn(
|
|
5104
|
-
"text-sm text-muted-foreground mb-2",
|
|
5106
|
+
"self-start text-sm text-muted-foreground font-ui mb-2",
|
|
5105
5107
|
required && "after:content-['*'] after:text-primary after:ml-0.5"
|
|
5106
5108
|
),
|
|
5107
5109
|
children: label
|
|
@@ -5111,7 +5113,7 @@ var OTPCodeInput = ({
|
|
|
5111
5113
|
"div",
|
|
5112
5114
|
{
|
|
5113
5115
|
className: cn(
|
|
5114
|
-
"flex gap-2",
|
|
5116
|
+
"flex justify-center gap-2",
|
|
5115
5117
|
disabled && "opacity-50 pointer-events-none"
|
|
5116
5118
|
),
|
|
5117
5119
|
role: "group",
|
|
@@ -5133,10 +5135,13 @@ var OTPCodeInput = ({
|
|
|
5133
5135
|
disabled,
|
|
5134
5136
|
onChange: (e) => handleChange(index, e.target.value),
|
|
5135
5137
|
onKeyDown: (e) => handleKeyDown(index, e),
|
|
5136
|
-
onPaste: handlePaste,
|
|
5137
|
-
onFocus: (e) =>
|
|
5138
|
+
onPaste: (e) => handlePaste(e, index),
|
|
5139
|
+
onFocus: (e) => {
|
|
5140
|
+
focusedIndexRef.current = index;
|
|
5141
|
+
e.target.select();
|
|
5142
|
+
},
|
|
5138
5143
|
className: cn(
|
|
5139
|
-
"w-
|
|
5144
|
+
"w-11 h-14 text-center text-lg rounded-lg border font-ui",
|
|
5140
5145
|
"bg-background text-foreground border-border",
|
|
5141
5146
|
"transition-colors",
|
|
5142
5147
|
"focus:outline-none focus:border-primary focus:ring-1 focus:ring-primary",
|
|
@@ -5147,7 +5152,7 @@ var OTPCodeInput = ({
|
|
|
5147
5152
|
))
|
|
5148
5153
|
}
|
|
5149
5154
|
),
|
|
5150
|
-
error && /* @__PURE__ */ jsxRuntime.jsx("p", { className: "mt-1 text-xs text-destructive", children: error })
|
|
5155
|
+
error && /* @__PURE__ */ jsxRuntime.jsx("p", { className: "mt-1 text-xs text-destructive font-ui self-start", children: error })
|
|
5151
5156
|
] });
|
|
5152
5157
|
};
|
|
5153
5158
|
OTPCodeInput.displayName = "OTPCodeInput";
|