@apexcura/ui-components 0.0.14-Beta56 → 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 +4 -1
- package/dist/index.d.ts +4 -1
- package/dist/index.js +64 -3
- package/dist/index.mjs +63 -3
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -62,6 +62,7 @@ type ElementType = {
|
|
|
62
62
|
selectAfter?: any[];
|
|
63
63
|
isSVGStylesOverride?: boolean;
|
|
64
64
|
rowSelection?: string;
|
|
65
|
+
length?: number;
|
|
65
66
|
};
|
|
66
67
|
|
|
67
68
|
declare const TextElement: (props: ElementType) => React$1.JSX.Element;
|
|
@@ -115,4 +116,6 @@ declare const SwitchElement: () => React$1.JSX.Element;
|
|
|
115
116
|
|
|
116
117
|
declare const Upload: (props: ElementType) => React$1.JSX.Element;
|
|
117
118
|
|
|
118
|
-
|
|
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
|
@@ -62,6 +62,7 @@ type ElementType = {
|
|
|
62
62
|
selectAfter?: any[];
|
|
63
63
|
isSVGStylesOverride?: boolean;
|
|
64
64
|
rowSelection?: string;
|
|
65
|
+
length?: number;
|
|
65
66
|
};
|
|
66
67
|
|
|
67
68
|
declare const TextElement: (props: ElementType) => React$1.JSX.Element;
|
|
@@ -115,4 +116,6 @@ declare const SwitchElement: () => React$1.JSX.Element;
|
|
|
115
116
|
|
|
116
117
|
declare const Upload: (props: ElementType) => React$1.JSX.Element;
|
|
117
118
|
|
|
118
|
-
|
|
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,
|
|
@@ -775,9 +776,13 @@ var TableElement = (props) => {
|
|
|
775
776
|
}
|
|
776
777
|
};
|
|
777
778
|
const rowSelectionConfig = props.rowSelection ? {
|
|
778
|
-
onChange: (selectedRowKeys, selectedRows) => {
|
|
779
|
-
|
|
780
|
-
|
|
779
|
+
// onChange: (selectedRowKeys: React.Key[], selectedRows: any) => {
|
|
780
|
+
// console.log(`selectedRowKeys: ${selectedRowKeys}`, "selectedRows: ", selectedRows);
|
|
781
|
+
// // Set the selected rows as the selected record
|
|
782
|
+
// if (onChange) {
|
|
783
|
+
// onChange(selectedRows); // Trigger the onChange callback with selected rows
|
|
784
|
+
// }
|
|
785
|
+
// },
|
|
781
786
|
} : void 0;
|
|
782
787
|
return /* @__PURE__ */ import_react20.default.createElement(import_react20.default.Fragment, null, /* @__PURE__ */ import_react20.default.createElement(
|
|
783
788
|
import_antd14.Table,
|
|
@@ -1010,6 +1015,61 @@ var Upload2 = (props) => {
|
|
|
1010
1015
|
"Upload"
|
|
1011
1016
|
));
|
|
1012
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
|
+
};
|
|
1013
1073
|
// Annotate the CommonJS export names for ESM import in node:
|
|
1014
1074
|
0 && (module.exports = {
|
|
1015
1075
|
AddMoreTable,
|
|
@@ -1024,6 +1084,7 @@ var Upload2 = (props) => {
|
|
|
1024
1084
|
MultipleSelectElement,
|
|
1025
1085
|
Navbar,
|
|
1026
1086
|
NumberElement,
|
|
1087
|
+
OtpElement,
|
|
1027
1088
|
PasswordElement,
|
|
1028
1089
|
RadioElement,
|
|
1029
1090
|
SelectElement,
|
package/dist/index.mjs
CHANGED
|
@@ -716,9 +716,13 @@ var TableElement = (props) => {
|
|
|
716
716
|
}
|
|
717
717
|
};
|
|
718
718
|
const rowSelectionConfig = props.rowSelection ? {
|
|
719
|
-
onChange: (selectedRowKeys, selectedRows) => {
|
|
720
|
-
|
|
721
|
-
|
|
719
|
+
// onChange: (selectedRowKeys: React.Key[], selectedRows: any) => {
|
|
720
|
+
// console.log(`selectedRowKeys: ${selectedRowKeys}`, "selectedRows: ", selectedRows);
|
|
721
|
+
// // Set the selected rows as the selected record
|
|
722
|
+
// if (onChange) {
|
|
723
|
+
// onChange(selectedRows); // Trigger the onChange callback with selected rows
|
|
724
|
+
// }
|
|
725
|
+
// },
|
|
722
726
|
} : void 0;
|
|
723
727
|
return /* @__PURE__ */ React20.createElement(React20.Fragment, null, /* @__PURE__ */ React20.createElement(
|
|
724
728
|
Table2,
|
|
@@ -951,6 +955,61 @@ var Upload2 = (props) => {
|
|
|
951
955
|
"Upload"
|
|
952
956
|
));
|
|
953
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
|
+
};
|
|
954
1013
|
export {
|
|
955
1014
|
AddMoreTable,
|
|
956
1015
|
ButtonElement,
|
|
@@ -964,6 +1023,7 @@ export {
|
|
|
964
1023
|
MultipleSelectElement,
|
|
965
1024
|
Navbar,
|
|
966
1025
|
NumberElement,
|
|
1026
|
+
OtpElement,
|
|
967
1027
|
PasswordElement,
|
|
968
1028
|
RadioElement,
|
|
969
1029
|
SelectElement,
|