react-restyle-components 0.1.28 → 0.1.31
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 +27 -11
- package/lib/cjs/core-components/atoms/check-box/checkBox.component.js.map +1 -1
- 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 +98 -38
- package/lib/cjs/core-components/atoms/date-picker/date-picker.component.js.map +1 -1
- 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 +119 -77
- package/lib/cjs/core-components/atoms/input/input-otp.component.js.map +1 -1
- 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 +134 -58
- package/lib/cjs/core-components/atoms/input-dropdown/input-dropdown.component.js.map +1 -1
- 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 +22 -8
- package/lib/cjs/core-components/atoms/radio/radio.component.js.map +1 -1
- 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 +120 -93
- package/lib/cjs/core-components/atoms/timer/timer.component.js.map +1 -1
- 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.js.map +1 -1
- 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.js.map +1 -1
- 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-otp.component.js.map +1 -1
- package/lib/esm/core-components/atoms/input/input-otp.styles.css +35 -0
- 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/input.styles.css +35 -0
- 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.js.map +1 -1
- 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.js.map +1 -1
- 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.js.map +1 -1
- 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,89 +1,131 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __createBinding =
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
}
|
|
18
|
-
|
|
2
|
+
var __createBinding =
|
|
3
|
+
(this && this.__createBinding) ||
|
|
4
|
+
(Object.create
|
|
5
|
+
? function (o, m, k, k2) {
|
|
6
|
+
if (k2 === undefined) k2 = k;
|
|
7
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
8
|
+
if (
|
|
9
|
+
!desc ||
|
|
10
|
+
("get" in desc ? !m.__esModule : desc.writable || desc.configurable)
|
|
11
|
+
) {
|
|
12
|
+
desc = {
|
|
13
|
+
enumerable: true,
|
|
14
|
+
get: function () {
|
|
15
|
+
return m[k];
|
|
16
|
+
},
|
|
17
|
+
};
|
|
18
|
+
}
|
|
19
|
+
Object.defineProperty(o, k2, desc);
|
|
20
|
+
}
|
|
21
|
+
: function (o, m, k, k2) {
|
|
22
|
+
if (k2 === undefined) k2 = k;
|
|
23
|
+
o[k2] = m[k];
|
|
24
|
+
});
|
|
25
|
+
var __setModuleDefault =
|
|
26
|
+
(this && this.__setModuleDefault) ||
|
|
27
|
+
(Object.create
|
|
28
|
+
? function (o, v) {
|
|
29
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
30
|
+
}
|
|
31
|
+
: function (o, v) {
|
|
32
|
+
o["default"] = v;
|
|
33
|
+
});
|
|
34
|
+
var __importStar =
|
|
35
|
+
(this && this.__importStar) ||
|
|
36
|
+
function (mod) {
|
|
19
37
|
if (mod && mod.__esModule) return mod;
|
|
20
38
|
var result = {};
|
|
21
|
-
if (mod != null)
|
|
39
|
+
if (mod != null)
|
|
40
|
+
for (var k in mod)
|
|
41
|
+
if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k))
|
|
42
|
+
__createBinding(result, mod, k);
|
|
22
43
|
__setModuleDefault(result, mod);
|
|
23
44
|
return result;
|
|
24
|
-
};
|
|
45
|
+
};
|
|
25
46
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
47
|
exports.InputOtp = void 0;
|
|
27
48
|
/* eslint-disable no-console */
|
|
28
49
|
const react_1 = __importStar(require("react"));
|
|
29
|
-
require("./
|
|
30
|
-
const InputOtp = ({ className, pin, onPinChanged
|
|
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
|
-
|
|
50
|
+
require("./input-otp.styles.css");
|
|
51
|
+
const InputOtp = ({ className, pin, onPinChanged }) => {
|
|
52
|
+
const pinLength = 6;
|
|
53
|
+
const Pin_Min_Value = 0;
|
|
54
|
+
const Pin_Max_Value = 9;
|
|
55
|
+
const BACKSPACE_Key = "Backspace";
|
|
56
|
+
const inputRefs = (0, react_1.useRef)([]);
|
|
57
|
+
(0, react_1.useEffect)(() => {
|
|
58
|
+
const ref = inputRefs.current[0];
|
|
59
|
+
if (ref) {
|
|
60
|
+
ref.focus();
|
|
61
|
+
}
|
|
62
|
+
}, []);
|
|
63
|
+
const changePinFocus = (pinIndex) => {
|
|
64
|
+
const ref = inputRefs.current[pinIndex];
|
|
65
|
+
if (ref) {
|
|
66
|
+
ref.focus();
|
|
67
|
+
}
|
|
68
|
+
};
|
|
69
|
+
const onChange = (event, index) => {
|
|
70
|
+
const value = event.target.value;
|
|
71
|
+
const pinNumber = Number(value.trim());
|
|
72
|
+
if (isNaN(pinNumber) || value.length === 0) {
|
|
73
|
+
return;
|
|
74
|
+
}
|
|
75
|
+
if (pinNumber >= Pin_Min_Value && pinNumber <= Pin_Max_Value) {
|
|
76
|
+
onPinChanged(pinNumber, index);
|
|
77
|
+
if (index < pinLength - 1) {
|
|
78
|
+
changePinFocus(index + 1);
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
};
|
|
82
|
+
const onKeyDown = (event, index) => {
|
|
83
|
+
console.log({ event, index });
|
|
84
|
+
const keyboardKeyCode = event.nativeEvent.code;
|
|
85
|
+
if (keyboardKeyCode != BACKSPACE_Key) return;
|
|
86
|
+
if (pin[index] === undefined) {
|
|
87
|
+
changePinFocus(index - 1);
|
|
88
|
+
} else {
|
|
89
|
+
onPinChanged(undefined, index);
|
|
90
|
+
}
|
|
91
|
+
};
|
|
92
|
+
return react_1.default.createElement(
|
|
93
|
+
"div",
|
|
94
|
+
{ className: `${className} relative` },
|
|
95
|
+
react_1.default.createElement(
|
|
96
|
+
"div",
|
|
97
|
+
{
|
|
98
|
+
className:
|
|
99
|
+
"flex space-x-1 bg-background-secondary rounded-lg outline-offset-8",
|
|
100
|
+
},
|
|
101
|
+
Array.from({ length: pinLength }, (_, index) =>
|
|
102
|
+
react_1.default.createElement("input", {
|
|
103
|
+
"data-testid": "onPinChanged",
|
|
104
|
+
className:
|
|
105
|
+
"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",
|
|
106
|
+
onKeyDown: (event) => onKeyDown(event, index),
|
|
107
|
+
key: index,
|
|
108
|
+
onMouseUp: () => {
|
|
109
|
+
if (pin.join("").length <= 0) {
|
|
110
|
+
changePinFocus(0);
|
|
58
111
|
}
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
changePinFocus(0);
|
|
77
|
-
}
|
|
78
|
-
}, onClick: () => {
|
|
79
|
-
if (pin.join('').length <= 0) {
|
|
80
|
-
onPinChanged(undefined, 0);
|
|
81
|
-
}
|
|
82
|
-
}, ref: (el) => {
|
|
83
|
-
if (el) {
|
|
84
|
-
inputRefs.current[index] = el;
|
|
85
|
-
}
|
|
86
|
-
}, onChange: (event) => onChange(event, index), value: pin[index] || '' }))))));
|
|
112
|
+
},
|
|
113
|
+
onClick: () => {
|
|
114
|
+
if (pin.join("").length <= 0) {
|
|
115
|
+
onPinChanged(undefined, 0);
|
|
116
|
+
}
|
|
117
|
+
},
|
|
118
|
+
ref: (el) => {
|
|
119
|
+
if (el) {
|
|
120
|
+
inputRefs.current[index] = el;
|
|
121
|
+
}
|
|
122
|
+
},
|
|
123
|
+
onChange: (event) => onChange(event, index),
|
|
124
|
+
value: pin[index] || "",
|
|
125
|
+
})
|
|
126
|
+
)
|
|
127
|
+
)
|
|
128
|
+
);
|
|
87
129
|
};
|
|
88
130
|
exports.InputOtp = InputOtp;
|
|
89
|
-
//# sourceMappingURL=input-otp.component.js.map
|
|
131
|
+
//# sourceMappingURL=input-otp.component.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"input-otp.component.js","sourceRoot":"","sources":["../../../../../src/core-components/atoms/input/input-otp.component.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,+BAA+B;AAC/B,+CAA+C;AAC/C,
|
|
1
|
+
{"version":3,"file":"input-otp.component.js","sourceRoot":"","sources":["../../../../../src/core-components/atoms/input/input-otp.component.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;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AS,CAAC,OAAO,CAAC,KAAK,CAAC,GAAG,EAAE,CAAC;iBAC/B;YACH,CAAC,EACD,QAAQ,EAAE,CAAC,KAAK,EAAE,EAAE,CAAC,QAAQ,CAAC,KAAK,EAAE,KAAK,CAAC,EAC3C,KAAK,EAAE,GAAG,CAAC,KAAK,CAAC,IAAI,EAAE,GACvB,CACH,CAAC,CACE,CACF,CACP,CAAC;AACJ,CAAC,CAAC;AA3FW,QAAA,QAAQ,YA2FnB"}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
.-z-1 {
|
|
2
|
+
z-index: -1;
|
|
3
|
+
}
|
|
4
|
+
|
|
5
|
+
.origin-0 {
|
|
6
|
+
transform-origin: 0%;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
input:focus ~ label,
|
|
10
|
+
input:not(:placeholder-shown) ~ label,
|
|
11
|
+
textarea:focus ~ label,
|
|
12
|
+
textarea:not(:placeholder-shown) ~ label,
|
|
13
|
+
select:focus ~ label,
|
|
14
|
+
select:not([value=""]):valid ~ label {
|
|
15
|
+
/* @apply transform; scale-75; -translate-y-6; */
|
|
16
|
+
--tw-translate-x: 0;
|
|
17
|
+
--tw-translate-y: 0;
|
|
18
|
+
--tw-rotate: 0;
|
|
19
|
+
--tw-skew-x: 0;
|
|
20
|
+
--tw-skew-y: 0;
|
|
21
|
+
transform: translateX(var(--tw-translate-x)) translateY(var(--tw-translate-y))
|
|
22
|
+
rotate(var(--tw-rotate)) skewX(var(--tw-skew-x)) skewY(var(--tw-skew-y))
|
|
23
|
+
scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y));
|
|
24
|
+
--tw-scale-x: 0.75;
|
|
25
|
+
--tw-scale-y: 0.75;
|
|
26
|
+
--tw-translate-y: -1.5rem;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
input:focus ~ label,
|
|
30
|
+
select:focus ~ label {
|
|
31
|
+
/* @apply text-black; left-0; */
|
|
32
|
+
--tw-text-opacity: 1;
|
|
33
|
+
color: "#696969";
|
|
34
|
+
left: 0px;
|
|
35
|
+
}
|
|
@@ -1,106 +1,186 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __createBinding =
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
}
|
|
18
|
-
|
|
2
|
+
var __createBinding =
|
|
3
|
+
(this && this.__createBinding) ||
|
|
4
|
+
(Object.create
|
|
5
|
+
? function (o, m, k, k2) {
|
|
6
|
+
if (k2 === undefined) k2 = k;
|
|
7
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
8
|
+
if (
|
|
9
|
+
!desc ||
|
|
10
|
+
("get" in desc ? !m.__esModule : desc.writable || desc.configurable)
|
|
11
|
+
) {
|
|
12
|
+
desc = {
|
|
13
|
+
enumerable: true,
|
|
14
|
+
get: function () {
|
|
15
|
+
return m[k];
|
|
16
|
+
},
|
|
17
|
+
};
|
|
18
|
+
}
|
|
19
|
+
Object.defineProperty(o, k2, desc);
|
|
20
|
+
}
|
|
21
|
+
: function (o, m, k, k2) {
|
|
22
|
+
if (k2 === undefined) k2 = k;
|
|
23
|
+
o[k2] = m[k];
|
|
24
|
+
});
|
|
25
|
+
var __setModuleDefault =
|
|
26
|
+
(this && this.__setModuleDefault) ||
|
|
27
|
+
(Object.create
|
|
28
|
+
? function (o, v) {
|
|
29
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
30
|
+
}
|
|
31
|
+
: function (o, v) {
|
|
32
|
+
o["default"] = v;
|
|
33
|
+
});
|
|
34
|
+
var __importStar =
|
|
35
|
+
(this && this.__importStar) ||
|
|
36
|
+
function (mod) {
|
|
19
37
|
if (mod && mod.__esModule) return mod;
|
|
20
38
|
var result = {};
|
|
21
|
-
if (mod != null)
|
|
39
|
+
if (mod != null)
|
|
40
|
+
for (var k in mod)
|
|
41
|
+
if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k))
|
|
42
|
+
__createBinding(result, mod, k);
|
|
22
43
|
__setModuleDefault(result, mod);
|
|
23
44
|
return result;
|
|
24
|
-
};
|
|
45
|
+
};
|
|
25
46
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
47
|
exports.InputPin = void 0;
|
|
27
48
|
/* eslint-disable */
|
|
28
49
|
const react_1 = __importStar(require("react"));
|
|
29
50
|
require("./input.styles.css");
|
|
30
|
-
const InputPin = ({
|
|
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
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
51
|
+
const InputPin = ({
|
|
52
|
+
title,
|
|
53
|
+
className,
|
|
54
|
+
pin,
|
|
55
|
+
errorMsg,
|
|
56
|
+
defaultMsg,
|
|
57
|
+
hasError,
|
|
58
|
+
onPinChanged,
|
|
59
|
+
}) => {
|
|
60
|
+
const pinLength = 12;
|
|
61
|
+
const Pin_Min_Value = 0;
|
|
62
|
+
const Pin_Max_Value = 9;
|
|
63
|
+
const BACKSPACE_Key = "Backspace";
|
|
64
|
+
const inputRefs = (0, react_1.useRef)([]);
|
|
65
|
+
const removeValuesFromArray = (valuesArray, value) => {
|
|
66
|
+
const valueIndex = valuesArray.findIndex((entry) => entry === value);
|
|
67
|
+
if (valueIndex === -1) {
|
|
68
|
+
return;
|
|
69
|
+
}
|
|
70
|
+
valuesArray.splice(valueIndex, 1);
|
|
71
|
+
};
|
|
72
|
+
const changePinFocus = (pinIndex) => {
|
|
73
|
+
const ref = inputRefs.current[pinIndex];
|
|
74
|
+
if (ref) {
|
|
75
|
+
ref.focus();
|
|
76
|
+
}
|
|
77
|
+
};
|
|
78
|
+
const onChange = (event, index) => {
|
|
79
|
+
const previousValue = event.target.defaultValue;
|
|
80
|
+
const valueArray = event.target.value.split("");
|
|
81
|
+
removeValuesFromArray(valueArray, previousValue);
|
|
82
|
+
const value = valueArray.pop();
|
|
83
|
+
if (!value) {
|
|
84
|
+
return;
|
|
85
|
+
}
|
|
86
|
+
const pinNumber = Number(value);
|
|
87
|
+
if (isNaN(pinNumber) || value.length === 0) {
|
|
88
|
+
return;
|
|
89
|
+
}
|
|
90
|
+
if (pinNumber >= Pin_Min_Value && pinNumber <= Pin_Max_Value) {
|
|
91
|
+
onPinChanged(pinNumber, index);
|
|
92
|
+
if (index < pinLength - 1) {
|
|
93
|
+
changePinFocus(index + 1);
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
};
|
|
97
|
+
const onKeyDown = (event, index) => {
|
|
98
|
+
const keyboardKeyCode = event.nativeEvent.code;
|
|
99
|
+
if (keyboardKeyCode != BACKSPACE_Key) return;
|
|
100
|
+
if (pin[index] !== undefined && keyboardKeyCode === BACKSPACE_Key) {
|
|
101
|
+
changePinFocus(index - 1);
|
|
102
|
+
}
|
|
103
|
+
if (pin[index] === undefined) {
|
|
104
|
+
changePinFocus(index - 1);
|
|
105
|
+
} else {
|
|
106
|
+
onPinChanged(undefined, index);
|
|
107
|
+
}
|
|
108
|
+
};
|
|
109
|
+
return react_1.default.createElement(
|
|
110
|
+
"div",
|
|
111
|
+
{ className: `${className} relative` },
|
|
112
|
+
react_1.default.createElement(
|
|
113
|
+
"label",
|
|
114
|
+
{
|
|
115
|
+
className:
|
|
116
|
+
"duration-300 -z-1 origin-0 text-gray-dark-secondary font-nunitoSansRegular text-md",
|
|
117
|
+
},
|
|
118
|
+
title
|
|
119
|
+
),
|
|
120
|
+
react_1.default.createElement(
|
|
121
|
+
"div",
|
|
122
|
+
{ className: "flex space-x-1" },
|
|
123
|
+
Array.from({ length: pinLength }, (_, index) => {
|
|
124
|
+
var _a;
|
|
125
|
+
return react_1.default.createElement(
|
|
126
|
+
"div",
|
|
127
|
+
{ className: "flex space-x-1 max-w-full items-stretch", key: index },
|
|
128
|
+
react_1.default.createElement("input", {
|
|
129
|
+
"data-testid": "inputElementPin",
|
|
130
|
+
type: "tel",
|
|
131
|
+
className:
|
|
132
|
+
"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 ",
|
|
133
|
+
onKeyUp: (event) => onKeyDown(event, index),
|
|
134
|
+
key: index,
|
|
135
|
+
onMouseUp: () => {
|
|
136
|
+
if (pin.join("").length <= 0) {
|
|
137
|
+
changePinFocus(0);
|
|
138
|
+
}
|
|
139
|
+
},
|
|
140
|
+
onClick: () => {
|
|
141
|
+
if (pin.join("").length <= 0) {
|
|
142
|
+
onPinChanged(undefined, 0);
|
|
143
|
+
}
|
|
144
|
+
},
|
|
145
|
+
ref: (el) => {
|
|
146
|
+
if (el) {
|
|
147
|
+
inputRefs.current[index] = el;
|
|
148
|
+
}
|
|
149
|
+
},
|
|
150
|
+
onChange: (event) => onChange(event, index),
|
|
151
|
+
value:
|
|
152
|
+
((_a = pin[index]) === null || _a === void 0
|
|
153
|
+
? void 0
|
|
154
|
+
: _a.toString()) || "",
|
|
155
|
+
}),
|
|
156
|
+
react_1.default.createElement(
|
|
157
|
+
"div",
|
|
158
|
+
{ className: "invisible" },
|
|
159
|
+
(index + 1) % 4 === 0 ? "ss" : null
|
|
160
|
+
)
|
|
161
|
+
);
|
|
162
|
+
})
|
|
163
|
+
),
|
|
164
|
+
hasError &&
|
|
165
|
+
(hasError === null || hasError === void 0 ? void 0 : hasError.type) !==
|
|
166
|
+
"required" &&
|
|
167
|
+
react_1.default.createElement(
|
|
168
|
+
"span",
|
|
169
|
+
{
|
|
170
|
+
className: "text-sm text-red text-4xs font-nunitoSansRegular",
|
|
171
|
+
id: "error",
|
|
172
|
+
},
|
|
173
|
+
`${errorMsg || ""}`
|
|
174
|
+
),
|
|
175
|
+
(!hasError ||
|
|
176
|
+
(hasError === null || hasError === void 0 ? void 0 : hasError.type) ===
|
|
177
|
+
"required") &&
|
|
178
|
+
react_1.default.createElement(
|
|
179
|
+
"span",
|
|
180
|
+
{ className: "text-sm text-4xs font-nunitoSansRegular", id: "error" },
|
|
181
|
+
`${defaultMsg || ""}`
|
|
182
|
+
)
|
|
183
|
+
);
|
|
104
184
|
};
|
|
105
185
|
exports.InputPin = InputPin;
|
|
106
|
-
//# sourceMappingURL=input-pin.component.js.map
|
|
186
|
+
//# sourceMappingURL=input-pin.component.js.map
|
|
@@ -1,18 +1,36 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __importDefault =
|
|
3
|
-
|
|
4
|
-
|
|
2
|
+
var __importDefault =
|
|
3
|
+
(this && this.__importDefault) ||
|
|
4
|
+
function (mod) {
|
|
5
|
+
return mod && mod.__esModule ? mod : { default: mod };
|
|
6
|
+
};
|
|
5
7
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
8
|
/* eslint-disable testing-library/render-result-naming-convention */
|
|
7
9
|
const react_1 = __importDefault(require("react"));
|
|
8
10
|
const _core_utils_1 = require("@core-utils");
|
|
9
11
|
const input_pin_component_1 = require("./input-pin.component");
|
|
10
|
-
it(
|
|
11
|
-
|
|
12
|
-
|
|
12
|
+
it("render InputOtp correctly without error", () => {
|
|
13
|
+
const pinInput = (0, _core_utils_1.render)(
|
|
14
|
+
react_1.default.createElement(input_pin_component_1.InputPin, {
|
|
15
|
+
title: "Enter your Aadhaar Number",
|
|
16
|
+
hasError: false,
|
|
17
|
+
errorMsg: "Uh oh! You\u2019ve entered an invalid aadhaar number",
|
|
18
|
+
onPinChanged: () => jest.fn(),
|
|
19
|
+
pin: new Array(12),
|
|
20
|
+
})
|
|
21
|
+
);
|
|
22
|
+
expect(pinInput).toMatchSnapshot();
|
|
13
23
|
});
|
|
14
|
-
it(
|
|
15
|
-
|
|
16
|
-
|
|
24
|
+
it("render InputOtp correctly with error", () => {
|
|
25
|
+
const pinInput = (0, _core_utils_1.render)(
|
|
26
|
+
react_1.default.createElement(input_pin_component_1.InputPin, {
|
|
27
|
+
title: "Enter your Aadhaar Number",
|
|
28
|
+
hasError: true,
|
|
29
|
+
errorMsg: "Uh oh! You\u2019ve entered an invalid aadhaar number",
|
|
30
|
+
onPinChanged: () => jest.fn(),
|
|
31
|
+
pin: new Array(12),
|
|
32
|
+
})
|
|
33
|
+
);
|
|
34
|
+
expect(pinInput).toMatchSnapshot();
|
|
17
35
|
});
|
|
18
|
-
//# sourceMappingURL=input-pin.component.test.js.map
|
|
36
|
+
//# sourceMappingURL=input-pin.component.test.js.map
|
|
@@ -1,20 +1,28 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __importDefault =
|
|
3
|
-
|
|
4
|
-
|
|
2
|
+
var __importDefault =
|
|
3
|
+
(this && this.__importDefault) ||
|
|
4
|
+
function (mod) {
|
|
5
|
+
return mod && mod.__esModule ? mod : { default: mod };
|
|
6
|
+
};
|
|
5
7
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
8
|
exports.Primary = void 0;
|
|
7
9
|
const react_1 = __importDefault(require("react"));
|
|
8
10
|
const input_pin_component_1 = require("./input-pin.component");
|
|
9
11
|
// More on default export: https://storybook.js.org/docs/react/writing-stories/introduction#default-export
|
|
10
12
|
exports.default = {
|
|
11
|
-
|
|
12
|
-
|
|
13
|
+
title: "Atoms/InputPin",
|
|
14
|
+
component: input_pin_component_1.InputPin,
|
|
13
15
|
};
|
|
14
16
|
const pin = new Array(12);
|
|
15
17
|
// More on component templates: https://storybook.js.org/docs/react/writing-stories/introduction#using-args
|
|
16
|
-
const Primary = () =>
|
|
17
|
-
|
|
18
|
-
|
|
18
|
+
const Primary = () =>
|
|
19
|
+
react_1.default.createElement(input_pin_component_1.InputPin, {
|
|
20
|
+
title: "Enter your Aadhaar Number",
|
|
21
|
+
hasError: true,
|
|
22
|
+
onPinChanged: (value) => {
|
|
23
|
+
console.log({ value });
|
|
24
|
+
},
|
|
25
|
+
pin: pin,
|
|
26
|
+
});
|
|
19
27
|
exports.Primary = Primary;
|
|
20
|
-
//# sourceMappingURL=input-pin.stories.js.map
|
|
28
|
+
//# sourceMappingURL=input-pin.stories.js.map
|