@apexcura/ui-components 0.0.14-Beta58 → 0.0.14-Beta59
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.d.mts +3 -1
- package/dist/index.d.ts +3 -1
- package/dist/index.js +57 -0
- package/dist/index.mjs +56 -0
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -116,4 +116,6 @@ declare const SwitchElement: () => React$1.JSX.Element;
|
|
|
116
116
|
|
|
117
117
|
declare const Upload: (props: ElementType) => React$1.JSX.Element;
|
|
118
118
|
|
|
119
|
-
|
|
119
|
+
declare const OtpElement: (props: ElementType) => React$1.JSX.Element;
|
|
120
|
+
|
|
121
|
+
export { AddMoreTable, ButtonElement, CheckboxElement, CkEditor, DatePickerElement, DateRangePickerElement, DropDownGroup, FileUpload, Image, MultipleSelectElement, Navbar, NumberElement, OtpElement, PasswordElement, RadioElement, SelectElement, Sidebar, SingleCheckbox, SingleSelectElement, SwitchElement, TableElement, TabsElement, TextElement, TextareaElement, Upload };
|
package/dist/index.d.ts
CHANGED
|
@@ -116,4 +116,6 @@ declare const SwitchElement: () => React$1.JSX.Element;
|
|
|
116
116
|
|
|
117
117
|
declare const Upload: (props: ElementType) => React$1.JSX.Element;
|
|
118
118
|
|
|
119
|
-
|
|
119
|
+
declare const OtpElement: (props: ElementType) => React$1.JSX.Element;
|
|
120
|
+
|
|
121
|
+
export { AddMoreTable, ButtonElement, CheckboxElement, CkEditor, DatePickerElement, DateRangePickerElement, DropDownGroup, FileUpload, Image, MultipleSelectElement, Navbar, NumberElement, OtpElement, PasswordElement, RadioElement, SelectElement, Sidebar, SingleCheckbox, SingleSelectElement, SwitchElement, TableElement, TabsElement, TextElement, TextareaElement, Upload };
|
package/dist/index.js
CHANGED
|
@@ -42,6 +42,7 @@ __export(src_exports, {
|
|
|
42
42
|
MultipleSelectElement: () => MultipleSelectElement,
|
|
43
43
|
Navbar: () => Navbar,
|
|
44
44
|
NumberElement: () => NumberElement,
|
|
45
|
+
OtpElement: () => OtpElement,
|
|
45
46
|
PasswordElement: () => PasswordElement,
|
|
46
47
|
RadioElement: () => RadioElement,
|
|
47
48
|
SelectElement: () => SelectElement,
|
|
@@ -1014,6 +1015,61 @@ var Upload2 = (props) => {
|
|
|
1014
1015
|
"Upload"
|
|
1015
1016
|
));
|
|
1016
1017
|
};
|
|
1018
|
+
|
|
1019
|
+
// src/Components/OtpElement.tsx
|
|
1020
|
+
var import_react30 = __toESM(require("react"));
|
|
1021
|
+
var import_antd22 = require("antd");
|
|
1022
|
+
var OtpElement = (props) => {
|
|
1023
|
+
const [otp, setOtp] = (0, import_react30.useState)(Array(length).fill(""));
|
|
1024
|
+
const inputRefs = (0, import_react30.useRef)([]);
|
|
1025
|
+
const handleChange = (e, index) => {
|
|
1026
|
+
const value = e.target.value;
|
|
1027
|
+
if (/^[0-9]$/.test(value) || value === "") {
|
|
1028
|
+
const newOtp = [...otp];
|
|
1029
|
+
newOtp[index] = value;
|
|
1030
|
+
setOtp(newOtp);
|
|
1031
|
+
props.onChange && props.onChange(newOtp.join(""));
|
|
1032
|
+
if (value && index < length - 1) {
|
|
1033
|
+
inputRefs.current[index + 1]?.focus();
|
|
1034
|
+
}
|
|
1035
|
+
}
|
|
1036
|
+
};
|
|
1037
|
+
const handleKeyDown = (e, index) => {
|
|
1038
|
+
if (e.key === "Backspace" && !otp[index] && index > 0) {
|
|
1039
|
+
inputRefs.current[index - 1]?.focus();
|
|
1040
|
+
}
|
|
1041
|
+
};
|
|
1042
|
+
const handlePaste = (e) => {
|
|
1043
|
+
e.preventDefault();
|
|
1044
|
+
const pasteData = e.clipboardData.getData("text");
|
|
1045
|
+
if (/^\d+$/.test(pasteData)) {
|
|
1046
|
+
const newOtp = pasteData.split("").slice(0, length);
|
|
1047
|
+
setOtp(newOtp.concat(Array(length - newOtp.length).fill("")));
|
|
1048
|
+
props.onChange && props.onChange(newOtp.join(""));
|
|
1049
|
+
newOtp.forEach((_, idx) => {
|
|
1050
|
+
if (inputRefs.current[idx]) {
|
|
1051
|
+
inputRefs.current[idx]?.focus();
|
|
1052
|
+
}
|
|
1053
|
+
});
|
|
1054
|
+
}
|
|
1055
|
+
};
|
|
1056
|
+
(0, import_react30.useEffect)(() => {
|
|
1057
|
+
inputRefs.current[0]?.focus();
|
|
1058
|
+
}, []);
|
|
1059
|
+
return /* @__PURE__ */ import_react30.default.createElement("div", { className: props.containerClassName }, Array.from({ length }).map((_, index) => /* @__PURE__ */ import_react30.default.createElement(
|
|
1060
|
+
import_antd22.Input,
|
|
1061
|
+
{
|
|
1062
|
+
key: index,
|
|
1063
|
+
className: props.className,
|
|
1064
|
+
maxLength: 1,
|
|
1065
|
+
value: otp[index],
|
|
1066
|
+
onChange: (e) => handleChange(e, index),
|
|
1067
|
+
onKeyDown: (e) => handleKeyDown(e, index),
|
|
1068
|
+
onPaste: handlePaste,
|
|
1069
|
+
ref: (el) => inputRefs.current[index] = el
|
|
1070
|
+
}
|
|
1071
|
+
)));
|
|
1072
|
+
};
|
|
1017
1073
|
// Annotate the CommonJS export names for ESM import in node:
|
|
1018
1074
|
0 && (module.exports = {
|
|
1019
1075
|
AddMoreTable,
|
|
@@ -1028,6 +1084,7 @@ var Upload2 = (props) => {
|
|
|
1028
1084
|
MultipleSelectElement,
|
|
1029
1085
|
Navbar,
|
|
1030
1086
|
NumberElement,
|
|
1087
|
+
OtpElement,
|
|
1031
1088
|
PasswordElement,
|
|
1032
1089
|
RadioElement,
|
|
1033
1090
|
SelectElement,
|
package/dist/index.mjs
CHANGED
|
@@ -955,6 +955,61 @@ var Upload2 = (props) => {
|
|
|
955
955
|
"Upload"
|
|
956
956
|
));
|
|
957
957
|
};
|
|
958
|
+
|
|
959
|
+
// src/Components/OtpElement.tsx
|
|
960
|
+
import React30, { useState as useState11, useRef, useEffect as useEffect3 } from "react";
|
|
961
|
+
import { Input as Input3 } from "antd";
|
|
962
|
+
var OtpElement = (props) => {
|
|
963
|
+
const [otp, setOtp] = useState11(Array(length).fill(""));
|
|
964
|
+
const inputRefs = useRef([]);
|
|
965
|
+
const handleChange = (e, index) => {
|
|
966
|
+
const value = e.target.value;
|
|
967
|
+
if (/^[0-9]$/.test(value) || value === "") {
|
|
968
|
+
const newOtp = [...otp];
|
|
969
|
+
newOtp[index] = value;
|
|
970
|
+
setOtp(newOtp);
|
|
971
|
+
props.onChange && props.onChange(newOtp.join(""));
|
|
972
|
+
if (value && index < length - 1) {
|
|
973
|
+
inputRefs.current[index + 1]?.focus();
|
|
974
|
+
}
|
|
975
|
+
}
|
|
976
|
+
};
|
|
977
|
+
const handleKeyDown = (e, index) => {
|
|
978
|
+
if (e.key === "Backspace" && !otp[index] && index > 0) {
|
|
979
|
+
inputRefs.current[index - 1]?.focus();
|
|
980
|
+
}
|
|
981
|
+
};
|
|
982
|
+
const handlePaste = (e) => {
|
|
983
|
+
e.preventDefault();
|
|
984
|
+
const pasteData = e.clipboardData.getData("text");
|
|
985
|
+
if (/^\d+$/.test(pasteData)) {
|
|
986
|
+
const newOtp = pasteData.split("").slice(0, length);
|
|
987
|
+
setOtp(newOtp.concat(Array(length - newOtp.length).fill("")));
|
|
988
|
+
props.onChange && props.onChange(newOtp.join(""));
|
|
989
|
+
newOtp.forEach((_, idx) => {
|
|
990
|
+
if (inputRefs.current[idx]) {
|
|
991
|
+
inputRefs.current[idx]?.focus();
|
|
992
|
+
}
|
|
993
|
+
});
|
|
994
|
+
}
|
|
995
|
+
};
|
|
996
|
+
useEffect3(() => {
|
|
997
|
+
inputRefs.current[0]?.focus();
|
|
998
|
+
}, []);
|
|
999
|
+
return /* @__PURE__ */ React30.createElement("div", { className: props.containerClassName }, Array.from({ length }).map((_, index) => /* @__PURE__ */ React30.createElement(
|
|
1000
|
+
Input3,
|
|
1001
|
+
{
|
|
1002
|
+
key: index,
|
|
1003
|
+
className: props.className,
|
|
1004
|
+
maxLength: 1,
|
|
1005
|
+
value: otp[index],
|
|
1006
|
+
onChange: (e) => handleChange(e, index),
|
|
1007
|
+
onKeyDown: (e) => handleKeyDown(e, index),
|
|
1008
|
+
onPaste: handlePaste,
|
|
1009
|
+
ref: (el) => inputRefs.current[index] = el
|
|
1010
|
+
}
|
|
1011
|
+
)));
|
|
1012
|
+
};
|
|
958
1013
|
export {
|
|
959
1014
|
AddMoreTable,
|
|
960
1015
|
ButtonElement,
|
|
@@ -968,6 +1023,7 @@ export {
|
|
|
968
1023
|
MultipleSelectElement,
|
|
969
1024
|
Navbar,
|
|
970
1025
|
NumberElement,
|
|
1026
|
+
OtpElement,
|
|
971
1027
|
PasswordElement,
|
|
972
1028
|
RadioElement,
|
|
973
1029
|
SelectElement,
|