react-core-ts 1.1.22 → 1.1.23

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.
@@ -0,0 +1,62 @@
1
+ import React, { useRef } from "react";
2
+
3
+ import { RadioProps } from "./commontypes";
4
+
5
+ const Radio: React.FC<RadioProps> = ({
6
+ name,
7
+ id,
8
+ label,
9
+ checked,
10
+ value = undefined,
11
+ handleChange,
12
+ disabled = false,
13
+ customLabel,
14
+ }) => {
15
+ const radioRef = useRef<HTMLInputElement>(null);
16
+ const onChange = (e: any) => {
17
+ handleChange?.(e);
18
+ };
19
+ const labelClick = () => {
20
+ if (radioRef.current) {
21
+ radioRef.current.click();
22
+ }
23
+ };
24
+ return (
25
+ <div
26
+ className={`labels label-text flex items-center justify-start ${
27
+ !customLabel && "gap-0"
28
+ } ${disabled ? " opacity-70" : ""} `}
29
+ >
30
+ <div>
31
+ <label
32
+ className={`radio-button ${
33
+ disabled ? "cursor-not-allowed" : "cursor-pointer"
34
+ }`}
35
+ >
36
+ <input
37
+ type="radio"
38
+ checked={checked}
39
+ disabled={disabled}
40
+ ref={radioRef}
41
+ name={name}
42
+ data-testid="app-common-radio"
43
+ value={value}
44
+ id={id}
45
+ onChange={onChange}
46
+ />
47
+ <span className="radio"></span>
48
+ </label>{" "}
49
+ </div>
50
+ <div
51
+ className={`text-common font-normal cursor-pointer ${
52
+ checked ? "text-secondary" : ""
53
+ }`}
54
+ onClick={labelClick}
55
+ >
56
+ {label}
57
+ </div>
58
+ </div>
59
+ );
60
+ };
61
+
62
+ export default Radio;
@@ -174,3 +174,13 @@ export interface CheckboxProps {
174
174
  handleChange?: (e: any) => void;
175
175
  value?: string | number;
176
176
  }
177
+ export interface RadioProps {
178
+ id: string;
179
+ name: string;
180
+ label?: string;
181
+ value?: string | number;
182
+ checked?: boolean;
183
+ disabled?: boolean;
184
+ customLabel?: boolean;
185
+ handleChange?: (e: any) => void;
186
+ }
package/src/index.tsx CHANGED
@@ -10,6 +10,8 @@ export type { AutoSuggestionInputProps } from "./commontypes";
10
10
  export { default as ExpandableAutoComplete } from "./ExpandableAutoComplete";
11
11
  export { default as ModernAutoComplete } from "./ReactAutoComplete";
12
12
  export { default as ModernCheckBox } from "./ReactCheckbox";
13
+ export { default as ModernOtpInput } from "./ReactOTPInput";
14
+ export { default as ModernRadio } from "./ReactRadioButton";
13
15
  export { default as ModernTextArea } from "./ReactTextArea";
14
16
  export { default as ModernTextField } from "./ReactTextField";
15
17
  export { deepEqual } from "./utilities/deepEqual";