react-restyle-components 0.1.29 → 0.1.30
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/lib/cjs/App.js +36 -12
- package/lib/cjs/App.test.js +10 -8
- package/lib/cjs/core-components/atoms/buttons/button.stories.js +20 -8
- package/lib/cjs/core-components/atoms/buttons/buttons.component.js +17 -6
- package/lib/cjs/core-components/atoms/buttons/buttons.component.test.js +15 -7
- package/lib/cjs/core-components/atoms/check-box/checkBox.component.js +25 -9
- package/lib/cjs/core-components/atoms/check-box/checkBox.component.test.js +14 -7
- package/lib/cjs/core-components/atoms/check-box/checkBox.stories.js +22 -9
- package/lib/cjs/core-components/atoms/date-picker/date-picker.component.js +97 -37
- package/lib/cjs/core-components/atoms/date-picker/date-picker.component.test.js +15 -7
- package/lib/cjs/core-components/atoms/date-picker/date-picker.stories.js +18 -8
- package/lib/cjs/core-components/atoms/input/input-otp.component.js +118 -76
- package/lib/cjs/core-components/atoms/input/input-otp.styles.css +35 -0
- package/lib/cjs/core-components/atoms/input/input-pin.component.js +174 -94
- package/lib/cjs/core-components/atoms/input/input-pin.component.test.js +28 -10
- package/lib/cjs/core-components/atoms/input/input-pin.stories.js +17 -9
- package/lib/cjs/core-components/atoms/input/input.component.js +65 -13
- package/lib/cjs/core-components/atoms/input/input.component.test.js +30 -10
- package/lib/cjs/core-components/atoms/input/input.stories.js +16 -7
- package/lib/cjs/core-components/atoms/input/input.styles.css +35 -0
- package/lib/cjs/core-components/atoms/input-dropdown/input-dropdown.component.js +132 -56
- package/lib/cjs/core-components/atoms/input-dropdown/input-dropdown.component.test.js +16 -7
- package/lib/cjs/core-components/atoms/input-dropdown/input-dropdown.stories.js +14 -7
- package/lib/cjs/core-components/atoms/loader/loader.component.js +83 -21
- package/lib/cjs/core-components/atoms/loader/loader.component.test.js +11 -7
- package/lib/cjs/core-components/atoms/loader/loader.stories.js +14 -8
- package/lib/cjs/core-components/atoms/radio/radio.component.js +20 -6
- package/lib/cjs/core-components/atoms/radio/radio.component.test.js +14 -7
- package/lib/cjs/core-components/atoms/radio/radio.stories.js +22 -10
- package/lib/cjs/core-components/atoms/stepper/stepper.component.js +77 -34
- package/lib/cjs/core-components/atoms/stepper/stepper.component.test.js +16 -7
- package/lib/cjs/core-components/atoms/stepper/stepper.stories.js +15 -7
- package/lib/cjs/core-components/atoms/timer/timer.component.js +119 -92
- package/lib/cjs/core-components/atoms/timer/timer.component.test.js +20 -10
- package/lib/cjs/core-components/index.js +35 -16
- package/lib/cjs/core-utils/index.js +31 -15
- package/lib/cjs/core-utils/unit-test.utils.js +8 -6
- package/lib/cjs/index.js +31 -15
- package/lib/cjs/reportWebVitals.js +52 -29
- package/lib/cjs/setupTests.js +1 -1
- package/lib/esm/App.js +34 -12
- package/lib/esm/App.test.js +8 -8
- package/lib/esm/core-components/atoms/buttons/button.stories.js +17 -7
- package/lib/esm/core-components/atoms/buttons/buttons.component.js +13 -4
- package/lib/esm/core-components/atoms/buttons/buttons.component.test.js +13 -7
- package/lib/esm/core-components/atoms/check-box/checkBox.component.js +20 -9
- package/lib/esm/core-components/atoms/check-box/checkBox.component.test.js +9 -7
- package/lib/esm/core-components/atoms/check-box/checkBox.stories.js +16 -8
- package/lib/esm/core-components/atoms/date-picker/date-picker.component.js +52 -20
- package/lib/esm/core-components/atoms/date-picker/date-picker.component.test.js +14 -8
- package/lib/esm/core-components/atoms/date-picker/date-picker.stories.js +16 -8
- package/lib/esm/core-components/atoms/input/input-otp.component.js +80 -59
- package/lib/esm/core-components/atoms/input/input-pin.component.js +136 -77
- package/lib/esm/core-components/atoms/input/input-pin.component.test.js +26 -10
- package/lib/esm/core-components/atoms/input/input-pin.stories.js +14 -8
- package/lib/esm/core-components/atoms/input/input.component.js +62 -12
- package/lib/esm/core-components/atoms/input/input.component.test.js +28 -10
- package/lib/esm/core-components/atoms/input/input.stories.js +13 -6
- package/lib/esm/core-components/atoms/input-dropdown/input-dropdown.component.js +96 -37
- package/lib/esm/core-components/atoms/input-dropdown/input-dropdown.component.test.js +14 -7
- package/lib/esm/core-components/atoms/input-dropdown/input-dropdown.stories.js +11 -6
- package/lib/esm/core-components/atoms/loader/loader.component.js +80 -20
- package/lib/esm/core-components/atoms/loader/loader.component.test.js +7 -7
- package/lib/esm/core-components/atoms/loader/loader.stories.js +11 -7
- package/lib/esm/core-components/atoms/radio/radio.component.js +12 -6
- package/lib/esm/core-components/atoms/radio/radio.component.test.js +9 -7
- package/lib/esm/core-components/atoms/radio/radio.stories.js +16 -9
- package/lib/esm/core-components/atoms/stepper/stepper.component.js +74 -32
- package/lib/esm/core-components/atoms/stepper/stepper.component.test.js +14 -7
- package/lib/esm/core-components/atoms/stepper/stepper.stories.js +12 -6
- package/lib/esm/core-components/atoms/timer/timer.component.js +81 -75
- package/lib/esm/core-components/atoms/timer/timer.component.test.js +10 -10
- package/lib/esm/core-components/index.js +12 -12
- package/lib/esm/core-utils/index.js +2 -2
- package/lib/esm/core-utils/unit-test.utils.js +5 -5
- package/lib/esm/index.js +2 -2
- package/lib/esm/reportWebVitals.js +10 -10
- package/lib/esm/setupTests.js +2 -2
- package/package.json +20 -4
|
@@ -1,12 +1,20 @@
|
|
|
1
|
-
import React from
|
|
2
|
-
import { DatePickerComp } from
|
|
3
|
-
import dayjs from
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { DatePickerComp } from "./date-picker.component";
|
|
3
|
+
import dayjs from "dayjs";
|
|
4
4
|
// More on default export: https://storybook.js.org/docs/react/writing-stories/introduction#default-export
|
|
5
5
|
export default {
|
|
6
|
-
|
|
7
|
-
|
|
6
|
+
title: "Atoms/DatePickerComp",
|
|
7
|
+
component: DatePickerComp,
|
|
8
8
|
};
|
|
9
9
|
// More on component templates: https://storybook.js.org/docs/react/writing-stories/introduction#using-args
|
|
10
|
-
export const Primary = () =>
|
|
11
|
-
|
|
12
|
-
|
|
10
|
+
export const Primary = () =>
|
|
11
|
+
React.createElement(
|
|
12
|
+
"div",
|
|
13
|
+
{ className: "flex flex-row" },
|
|
14
|
+
React.createElement(DatePickerComp, {
|
|
15
|
+
className: "mt-6",
|
|
16
|
+
value: dayjs().format("YYYY-MM-DD"),
|
|
17
|
+
showFormat: "dd-MM-yyyy",
|
|
18
|
+
})
|
|
19
|
+
);
|
|
20
|
+
//# sourceMappingURL=date-picker.stories.js.map
|
|
@@ -1,62 +1,83 @@
|
|
|
1
1
|
/* eslint-disable no-console */
|
|
2
|
-
import React, { useEffect, useRef } from
|
|
3
|
-
import
|
|
4
|
-
export const InputOtp = ({ className, pin, onPinChanged
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
2
|
+
import React, { useEffect, useRef } from "react";
|
|
3
|
+
import "./input-otp.styles.css";
|
|
4
|
+
export const InputOtp = ({ className, pin, onPinChanged }) => {
|
|
5
|
+
const pinLength = 6;
|
|
6
|
+
const Pin_Min_Value = 0;
|
|
7
|
+
const Pin_Max_Value = 9;
|
|
8
|
+
const BACKSPACE_Key = "Backspace";
|
|
9
|
+
const inputRefs = useRef([]);
|
|
10
|
+
useEffect(() => {
|
|
11
|
+
const ref = inputRefs.current[0];
|
|
12
|
+
if (ref) {
|
|
13
|
+
ref.focus();
|
|
14
|
+
}
|
|
15
|
+
}, []);
|
|
16
|
+
const changePinFocus = (pinIndex) => {
|
|
17
|
+
const ref = inputRefs.current[pinIndex];
|
|
18
|
+
if (ref) {
|
|
19
|
+
ref.focus();
|
|
20
|
+
}
|
|
21
|
+
};
|
|
22
|
+
const onChange = (event, index) => {
|
|
23
|
+
const value = event.target.value;
|
|
24
|
+
const pinNumber = Number(value.trim());
|
|
25
|
+
if (isNaN(pinNumber) || value.length === 0) {
|
|
26
|
+
return;
|
|
27
|
+
}
|
|
28
|
+
if (pinNumber >= Pin_Min_Value && pinNumber <= Pin_Max_Value) {
|
|
29
|
+
onPinChanged(pinNumber, index);
|
|
30
|
+
if (index < pinLength - 1) {
|
|
31
|
+
changePinFocus(index + 1);
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
};
|
|
35
|
+
const onKeyDown = (event, index) => {
|
|
36
|
+
console.log({ event, index });
|
|
37
|
+
const keyboardKeyCode = event.nativeEvent.code;
|
|
38
|
+
if (keyboardKeyCode != BACKSPACE_Key) return;
|
|
39
|
+
if (pin[index] === undefined) {
|
|
40
|
+
changePinFocus(index - 1);
|
|
41
|
+
} else {
|
|
42
|
+
onPinChanged(undefined, index);
|
|
43
|
+
}
|
|
44
|
+
};
|
|
45
|
+
return React.createElement(
|
|
46
|
+
"div",
|
|
47
|
+
{ className: `${className} relative` },
|
|
48
|
+
React.createElement(
|
|
49
|
+
"div",
|
|
50
|
+
{
|
|
51
|
+
className:
|
|
52
|
+
"flex space-x-1 bg-background-secondary rounded-lg outline-offset-8",
|
|
53
|
+
},
|
|
54
|
+
Array.from({ length: pinLength }, (_, index) =>
|
|
55
|
+
React.createElement("input", {
|
|
56
|
+
"data-testid": "onPinChanged",
|
|
57
|
+
className:
|
|
58
|
+
"pt-3 pb-2 block w-full px-0 text-5xl font-extrabold border-b-0 text-orange mt-0 bg-transparent text-center z-20 appearance-none focus:outline-none font-nunitoSansRegular",
|
|
59
|
+
onKeyDown: (event) => onKeyDown(event, index),
|
|
60
|
+
key: index,
|
|
61
|
+
onMouseUp: () => {
|
|
62
|
+
if (pin.join("").length <= 0) {
|
|
63
|
+
changePinFocus(0);
|
|
32
64
|
}
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
changePinFocus(0);
|
|
51
|
-
}
|
|
52
|
-
}, onClick: () => {
|
|
53
|
-
if (pin.join('').length <= 0) {
|
|
54
|
-
onPinChanged(undefined, 0);
|
|
55
|
-
}
|
|
56
|
-
}, ref: (el) => {
|
|
57
|
-
if (el) {
|
|
58
|
-
inputRefs.current[index] = el;
|
|
59
|
-
}
|
|
60
|
-
}, onChange: (event) => onChange(event, index), value: pin[index] || '' }))))));
|
|
65
|
+
},
|
|
66
|
+
onClick: () => {
|
|
67
|
+
if (pin.join("").length <= 0) {
|
|
68
|
+
onPinChanged(undefined, 0);
|
|
69
|
+
}
|
|
70
|
+
},
|
|
71
|
+
ref: (el) => {
|
|
72
|
+
if (el) {
|
|
73
|
+
inputRefs.current[index] = el;
|
|
74
|
+
}
|
|
75
|
+
},
|
|
76
|
+
onChange: (event) => onChange(event, index),
|
|
77
|
+
value: pin[index] || "",
|
|
78
|
+
})
|
|
79
|
+
)
|
|
80
|
+
)
|
|
81
|
+
);
|
|
61
82
|
};
|
|
62
|
-
//# sourceMappingURL=input-otp.component.js.map
|
|
83
|
+
//# sourceMappingURL=input-otp.component.js.map
|
|
@@ -1,79 +1,138 @@
|
|
|
1
1
|
/* eslint-disable */
|
|
2
|
-
import React, { useRef } from
|
|
3
|
-
import
|
|
4
|
-
export const InputPin = ({
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
2
|
+
import React, { useRef } from "react";
|
|
3
|
+
import "./input.styles.css";
|
|
4
|
+
export const InputPin = ({
|
|
5
|
+
title,
|
|
6
|
+
className,
|
|
7
|
+
pin,
|
|
8
|
+
errorMsg,
|
|
9
|
+
defaultMsg,
|
|
10
|
+
hasError,
|
|
11
|
+
onPinChanged,
|
|
12
|
+
}) => {
|
|
13
|
+
const pinLength = 12;
|
|
14
|
+
const Pin_Min_Value = 0;
|
|
15
|
+
const Pin_Max_Value = 9;
|
|
16
|
+
const BACKSPACE_Key = "Backspace";
|
|
17
|
+
const inputRefs = useRef([]);
|
|
18
|
+
const removeValuesFromArray = (valuesArray, value) => {
|
|
19
|
+
const valueIndex = valuesArray.findIndex((entry) => entry === value);
|
|
20
|
+
if (valueIndex === -1) {
|
|
21
|
+
return;
|
|
22
|
+
}
|
|
23
|
+
valuesArray.splice(valueIndex, 1);
|
|
24
|
+
};
|
|
25
|
+
const changePinFocus = (pinIndex) => {
|
|
26
|
+
const ref = inputRefs.current[pinIndex];
|
|
27
|
+
if (ref) {
|
|
28
|
+
ref.focus();
|
|
29
|
+
}
|
|
30
|
+
};
|
|
31
|
+
const onChange = (event, index) => {
|
|
32
|
+
const previousValue = event.target.defaultValue;
|
|
33
|
+
const valueArray = event.target.value.split("");
|
|
34
|
+
removeValuesFromArray(valueArray, previousValue);
|
|
35
|
+
const value = valueArray.pop();
|
|
36
|
+
if (!value) {
|
|
37
|
+
return;
|
|
38
|
+
}
|
|
39
|
+
const pinNumber = Number(value);
|
|
40
|
+
if (isNaN(pinNumber) || value.length === 0) {
|
|
41
|
+
return;
|
|
42
|
+
}
|
|
43
|
+
if (pinNumber >= Pin_Min_Value && pinNumber <= Pin_Max_Value) {
|
|
44
|
+
onPinChanged(pinNumber, index);
|
|
45
|
+
if (index < pinLength - 1) {
|
|
46
|
+
changePinFocus(index + 1);
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
};
|
|
50
|
+
const onKeyDown = (event, index) => {
|
|
51
|
+
const keyboardKeyCode = event.nativeEvent.code;
|
|
52
|
+
if (keyboardKeyCode != BACKSPACE_Key) return;
|
|
53
|
+
if (pin[index] !== undefined && keyboardKeyCode === BACKSPACE_Key) {
|
|
54
|
+
changePinFocus(index - 1);
|
|
55
|
+
}
|
|
56
|
+
if (pin[index] === undefined) {
|
|
57
|
+
changePinFocus(index - 1);
|
|
58
|
+
} else {
|
|
59
|
+
onPinChanged(undefined, index);
|
|
60
|
+
}
|
|
61
|
+
};
|
|
62
|
+
return React.createElement(
|
|
63
|
+
"div",
|
|
64
|
+
{ className: `${className} relative` },
|
|
65
|
+
React.createElement(
|
|
66
|
+
"label",
|
|
67
|
+
{
|
|
68
|
+
className:
|
|
69
|
+
"duration-300 -z-1 origin-0 text-gray-dark-secondary font-nunitoSansRegular text-md",
|
|
70
|
+
},
|
|
71
|
+
title
|
|
72
|
+
),
|
|
73
|
+
React.createElement(
|
|
74
|
+
"div",
|
|
75
|
+
{ className: "flex space-x-1" },
|
|
76
|
+
Array.from({ length: pinLength }, (_, index) => {
|
|
77
|
+
var _a;
|
|
78
|
+
return React.createElement(
|
|
79
|
+
"div",
|
|
80
|
+
{ className: "flex space-x-1 max-w-full items-stretch", key: index },
|
|
81
|
+
React.createElement("input", {
|
|
82
|
+
"data-testid": "inputElementPin",
|
|
83
|
+
type: "tel",
|
|
84
|
+
className:
|
|
85
|
+
"pb-2 block w-4 px-0 mt-0 bg-transparent text-center border-0 border-b z-20 appearance-none rounded-none focus:outline-none focus:ring-0 focus:border-gray-secondary border-gray-secondary font-nunitoSansRegular ",
|
|
86
|
+
onKeyUp: (event) => onKeyDown(event, index),
|
|
87
|
+
key: index,
|
|
88
|
+
onMouseUp: () => {
|
|
89
|
+
if (pin.join("").length <= 0) {
|
|
90
|
+
changePinFocus(0);
|
|
91
|
+
}
|
|
92
|
+
},
|
|
93
|
+
onClick: () => {
|
|
94
|
+
if (pin.join("").length <= 0) {
|
|
95
|
+
onPinChanged(undefined, 0);
|
|
96
|
+
}
|
|
97
|
+
},
|
|
98
|
+
ref: (el) => {
|
|
99
|
+
if (el) {
|
|
100
|
+
inputRefs.current[index] = el;
|
|
101
|
+
}
|
|
102
|
+
},
|
|
103
|
+
onChange: (event) => onChange(event, index),
|
|
104
|
+
value:
|
|
105
|
+
((_a = pin[index]) === null || _a === void 0
|
|
106
|
+
? void 0
|
|
107
|
+
: _a.toString()) || "",
|
|
108
|
+
}),
|
|
109
|
+
React.createElement(
|
|
110
|
+
"div",
|
|
111
|
+
{ className: "invisible" },
|
|
112
|
+
(index + 1) % 4 === 0 ? "ss" : null
|
|
113
|
+
)
|
|
114
|
+
);
|
|
115
|
+
})
|
|
116
|
+
),
|
|
117
|
+
hasError &&
|
|
118
|
+
(hasError === null || hasError === void 0 ? void 0 : hasError.type) !==
|
|
119
|
+
"required" &&
|
|
120
|
+
React.createElement(
|
|
121
|
+
"span",
|
|
122
|
+
{
|
|
123
|
+
className: "text-sm text-red text-4xs font-nunitoSansRegular",
|
|
124
|
+
id: "error",
|
|
125
|
+
},
|
|
126
|
+
`${errorMsg || ""}`
|
|
127
|
+
),
|
|
128
|
+
(!hasError ||
|
|
129
|
+
(hasError === null || hasError === void 0 ? void 0 : hasError.type) ===
|
|
130
|
+
"required") &&
|
|
131
|
+
React.createElement(
|
|
132
|
+
"span",
|
|
133
|
+
{ className: "text-sm text-4xs font-nunitoSansRegular", id: "error" },
|
|
134
|
+
`${defaultMsg || ""}`
|
|
135
|
+
)
|
|
136
|
+
);
|
|
78
137
|
};
|
|
79
|
-
//# sourceMappingURL=input-pin.component.js.map
|
|
138
|
+
//# sourceMappingURL=input-pin.component.js.map
|
|
@@ -1,13 +1,29 @@
|
|
|
1
1
|
/* eslint-disable testing-library/render-result-naming-convention */
|
|
2
|
-
import React from
|
|
3
|
-
import { render } from
|
|
4
|
-
import { InputPin } from
|
|
5
|
-
it(
|
|
6
|
-
|
|
7
|
-
|
|
2
|
+
import React from "react";
|
|
3
|
+
import { render } from "@core-utils";
|
|
4
|
+
import { InputPin } from "./input-pin.component";
|
|
5
|
+
it("render InputOtp correctly without error", () => {
|
|
6
|
+
const pinInput = render(
|
|
7
|
+
React.createElement(InputPin, {
|
|
8
|
+
title: "Enter your Aadhaar Number",
|
|
9
|
+
hasError: false,
|
|
10
|
+
errorMsg: "Uh oh! You\u2019ve entered an invalid aadhaar number",
|
|
11
|
+
onPinChanged: () => jest.fn(),
|
|
12
|
+
pin: new Array(12),
|
|
13
|
+
})
|
|
14
|
+
);
|
|
15
|
+
expect(pinInput).toMatchSnapshot();
|
|
8
16
|
});
|
|
9
|
-
it(
|
|
10
|
-
|
|
11
|
-
|
|
17
|
+
it("render InputOtp correctly with error", () => {
|
|
18
|
+
const pinInput = render(
|
|
19
|
+
React.createElement(InputPin, {
|
|
20
|
+
title: "Enter your Aadhaar Number",
|
|
21
|
+
hasError: true,
|
|
22
|
+
errorMsg: "Uh oh! You\u2019ve entered an invalid aadhaar number",
|
|
23
|
+
onPinChanged: () => jest.fn(),
|
|
24
|
+
pin: new Array(12),
|
|
25
|
+
})
|
|
26
|
+
);
|
|
27
|
+
expect(pinInput).toMatchSnapshot();
|
|
12
28
|
});
|
|
13
|
-
//# sourceMappingURL=input-pin.component.test.js.map
|
|
29
|
+
//# sourceMappingURL=input-pin.component.test.js.map
|
|
@@ -1,13 +1,19 @@
|
|
|
1
|
-
import React from
|
|
2
|
-
import { InputPin } from
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { InputPin } from "./input-pin.component";
|
|
3
3
|
// More on default export: https://storybook.js.org/docs/react/writing-stories/introduction#default-export
|
|
4
4
|
export default {
|
|
5
|
-
|
|
6
|
-
|
|
5
|
+
title: "Atoms/InputPin",
|
|
6
|
+
component: InputPin,
|
|
7
7
|
};
|
|
8
8
|
const pin = new Array(12);
|
|
9
9
|
// More on component templates: https://storybook.js.org/docs/react/writing-stories/introduction#using-args
|
|
10
|
-
export const Primary = () =>
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
10
|
+
export const Primary = () =>
|
|
11
|
+
React.createElement(InputPin, {
|
|
12
|
+
title: "Enter your Aadhaar Number",
|
|
13
|
+
hasError: true,
|
|
14
|
+
onPinChanged: (value) => {
|
|
15
|
+
console.log({ value });
|
|
16
|
+
},
|
|
17
|
+
pin: pin,
|
|
18
|
+
});
|
|
19
|
+
//# sourceMappingURL=input-pin.stories.js.map
|
|
@@ -1,14 +1,64 @@
|
|
|
1
1
|
/* eslint-disable no-console */
|
|
2
|
-
import React from
|
|
3
|
-
import
|
|
4
|
-
export const Input = ({
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
2
|
+
import React from "react";
|
|
3
|
+
import "./input.styles.css";
|
|
4
|
+
export const Input = ({
|
|
5
|
+
title,
|
|
6
|
+
value,
|
|
7
|
+
className,
|
|
8
|
+
disable,
|
|
9
|
+
hasError,
|
|
10
|
+
errorMsg,
|
|
11
|
+
defaultMsg,
|
|
12
|
+
inputStyle,
|
|
13
|
+
autoComplete,
|
|
14
|
+
maxlength = 40,
|
|
15
|
+
onChange,
|
|
16
|
+
onBlur,
|
|
17
|
+
}) => {
|
|
18
|
+
const onKeyUpValue = (event) => {
|
|
19
|
+
onChange(event.target.value);
|
|
20
|
+
};
|
|
21
|
+
return React.createElement(
|
|
22
|
+
"div",
|
|
23
|
+
{ className: `${className} relative` },
|
|
24
|
+
React.createElement("input", {
|
|
25
|
+
"data-testid": "inputElement",
|
|
26
|
+
type: "text",
|
|
27
|
+
name: "name",
|
|
28
|
+
value: value,
|
|
29
|
+
placeholder: " ",
|
|
30
|
+
disabled: disable,
|
|
31
|
+
className: `pt-3 pb-2 bg-transparent block w-full px-0 mt-0 rounded-none border-0 border-b appearance-none focus:outline-none focus:ring-0 focus:border-gray-secondary border-gray-secondary font-nunitoSansRegular ${inputStyle}`,
|
|
32
|
+
onChange: (e) => onChange && onChange(e.target.value),
|
|
33
|
+
onKeyUp: onKeyUpValue,
|
|
34
|
+
onBlur: (e) => onBlur && onBlur(e.target.value),
|
|
35
|
+
autoComplete: autoComplete,
|
|
36
|
+
maxLength: maxlength,
|
|
37
|
+
}),
|
|
38
|
+
React.createElement(
|
|
39
|
+
"label",
|
|
40
|
+
{
|
|
41
|
+
className:
|
|
42
|
+
"absolute duration-300 top-3 -z-1 origin-0 text-gray-dark-secondary font-nunitoSansRegular text-md",
|
|
43
|
+
},
|
|
44
|
+
title
|
|
45
|
+
),
|
|
46
|
+
hasError &&
|
|
47
|
+
(hasError === null || hasError === void 0 ? void 0 : hasError.type) !==
|
|
48
|
+
"required" &&
|
|
49
|
+
React.createElement(
|
|
50
|
+
"span",
|
|
51
|
+
{ className: "text-sm text-red text-4xs", id: "error" },
|
|
52
|
+
`${errorMsg || ""}`
|
|
53
|
+
),
|
|
54
|
+
(!hasError ||
|
|
55
|
+
(hasError === null || hasError === void 0 ? void 0 : hasError.type) ===
|
|
56
|
+
"required") &&
|
|
57
|
+
React.createElement(
|
|
58
|
+
"span",
|
|
59
|
+
{ className: "text-sm text-4xs", id: "error" },
|
|
60
|
+
`${defaultMsg || ""}`
|
|
61
|
+
)
|
|
62
|
+
);
|
|
13
63
|
};
|
|
14
|
-
//# sourceMappingURL=input.component.js.map
|
|
64
|
+
//# sourceMappingURL=input.component.js.map
|
|
@@ -1,13 +1,31 @@
|
|
|
1
1
|
/* eslint-disable testing-library/render-result-naming-convention */
|
|
2
|
-
import React from
|
|
3
|
-
import { render } from
|
|
4
|
-
import { Input } from
|
|
5
|
-
it(
|
|
6
|
-
|
|
7
|
-
|
|
2
|
+
import React from "react";
|
|
3
|
+
import { render } from "@core-utils";
|
|
4
|
+
import { Input } from "./input.component";
|
|
5
|
+
it("render Input correctly without error", () => {
|
|
6
|
+
const input = render(
|
|
7
|
+
React.createElement(Input, {
|
|
8
|
+
className: "h-1 relative top-1 border-red-600 border-b-0 dummy",
|
|
9
|
+
title: "input",
|
|
10
|
+
hasError: false,
|
|
11
|
+
value: "",
|
|
12
|
+
inputStyle: " border-b-0 invisible ",
|
|
13
|
+
onChange: () => jest.fn(),
|
|
14
|
+
})
|
|
15
|
+
);
|
|
16
|
+
expect(input).toMatchSnapshot();
|
|
8
17
|
});
|
|
9
|
-
it(
|
|
10
|
-
|
|
11
|
-
|
|
18
|
+
it("render Input correctly with error", () => {
|
|
19
|
+
const input = render(
|
|
20
|
+
React.createElement(Input, {
|
|
21
|
+
className: "h-1 relative top-1 border-red-600 border-b-0 dummy",
|
|
22
|
+
title: "input",
|
|
23
|
+
hasError: true,
|
|
24
|
+
value: "",
|
|
25
|
+
inputStyle: " border-b-0 invisible ",
|
|
26
|
+
onChange: () => jest.fn(),
|
|
27
|
+
})
|
|
28
|
+
);
|
|
29
|
+
expect(input).toMatchSnapshot();
|
|
12
30
|
});
|
|
13
|
-
//# sourceMappingURL=input.component.test.js.map
|
|
31
|
+
//# sourceMappingURL=input.component.test.js.map
|
|
@@ -1,10 +1,17 @@
|
|
|
1
|
-
import React from
|
|
2
|
-
import { Input } from
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { Input } from "./input.component";
|
|
3
3
|
// More on default export: https://storybook.js.org/docs/react/writing-stories/introduction#default-export
|
|
4
4
|
export default {
|
|
5
|
-
|
|
6
|
-
|
|
5
|
+
title: "Atoms/Input",
|
|
6
|
+
component: Input,
|
|
7
7
|
};
|
|
8
8
|
// More on component templates: https://storybook.js.org/docs/react/writing-stories/introduction#using-args
|
|
9
|
-
export const Primary = () =>
|
|
10
|
-
|
|
9
|
+
export const Primary = () =>
|
|
10
|
+
React.createElement(Input, {
|
|
11
|
+
className: "mt-4",
|
|
12
|
+
title: "Enter your Pan Number",
|
|
13
|
+
hasError: true,
|
|
14
|
+
value: "",
|
|
15
|
+
onChange: (panNumber) => console.log({ panNumber }),
|
|
16
|
+
});
|
|
17
|
+
//# sourceMappingURL=input.stories.js.map
|