react-restyle-components 0.1.29 → 0.1.32

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.
Files changed (78) hide show
  1. package/README.md +6 -1
  2. package/lib/cjs/App.js +36 -12
  3. package/lib/cjs/App.test.js +10 -8
  4. package/lib/cjs/core-components/atoms/buttons/button.stories.js +20 -8
  5. package/lib/cjs/core-components/atoms/buttons/buttons.component.js +17 -6
  6. package/lib/cjs/core-components/atoms/buttons/buttons.component.test.js +15 -7
  7. package/lib/cjs/core-components/atoms/check-box/checkBox.component.js +25 -9
  8. package/lib/cjs/core-components/atoms/check-box/checkBox.component.test.js +14 -7
  9. package/lib/cjs/core-components/atoms/check-box/checkBox.stories.js +22 -9
  10. package/lib/cjs/core-components/atoms/date-picker/date-picker.component.js +97 -37
  11. package/lib/cjs/core-components/atoms/date-picker/date-picker.component.test.js +15 -7
  12. package/lib/cjs/core-components/atoms/date-picker/date-picker.stories.js +18 -8
  13. package/lib/cjs/core-components/atoms/input/input-otp.component.js +118 -76
  14. package/lib/cjs/core-components/atoms/input/input-pin.component.js +174 -94
  15. package/lib/cjs/core-components/atoms/input/input-pin.component.test.js +28 -10
  16. package/lib/cjs/core-components/atoms/input/input-pin.stories.js +17 -9
  17. package/lib/cjs/core-components/atoms/input/input.component.js +65 -13
  18. package/lib/cjs/core-components/atoms/input/input.component.test.js +30 -10
  19. package/lib/cjs/core-components/atoms/input/input.stories.js +16 -7
  20. package/lib/cjs/core-components/atoms/input-dropdown/input-dropdown.component.js +132 -56
  21. package/lib/cjs/core-components/atoms/input-dropdown/input-dropdown.component.test.js +16 -7
  22. package/lib/cjs/core-components/atoms/input-dropdown/input-dropdown.stories.js +14 -7
  23. package/lib/cjs/core-components/atoms/loader/loader.component.js +83 -21
  24. package/lib/cjs/core-components/atoms/loader/loader.component.test.js +11 -7
  25. package/lib/cjs/core-components/atoms/loader/loader.stories.js +14 -8
  26. package/lib/cjs/core-components/atoms/radio/radio.component.js +20 -6
  27. package/lib/cjs/core-components/atoms/radio/radio.component.test.js +14 -7
  28. package/lib/cjs/core-components/atoms/radio/radio.stories.js +22 -10
  29. package/lib/cjs/core-components/atoms/stepper/stepper.component.js +77 -34
  30. package/lib/cjs/core-components/atoms/stepper/stepper.component.test.js +16 -7
  31. package/lib/cjs/core-components/atoms/stepper/stepper.stories.js +15 -7
  32. package/lib/cjs/core-components/atoms/timer/timer.component.js +119 -92
  33. package/lib/cjs/core-components/atoms/timer/timer.component.test.js +20 -10
  34. package/lib/cjs/core-components/index.js +35 -16
  35. package/lib/cjs/core-utils/index.js +31 -15
  36. package/lib/cjs/core-utils/unit-test.utils.js +8 -6
  37. package/lib/cjs/index.js +31 -15
  38. package/lib/cjs/reportWebVitals.js +52 -29
  39. package/lib/cjs/setupTests.js +1 -1
  40. package/lib/esm/App.js +34 -12
  41. package/lib/esm/App.test.js +8 -8
  42. package/lib/esm/core-components/atoms/buttons/button.stories.js +17 -7
  43. package/lib/esm/core-components/atoms/buttons/buttons.component.js +13 -4
  44. package/lib/esm/core-components/atoms/buttons/buttons.component.test.js +13 -7
  45. package/lib/esm/core-components/atoms/check-box/checkBox.component.js +20 -9
  46. package/lib/esm/core-components/atoms/check-box/checkBox.component.test.js +9 -7
  47. package/lib/esm/core-components/atoms/check-box/checkBox.stories.js +16 -8
  48. package/lib/esm/core-components/atoms/date-picker/date-picker.component.js +52 -20
  49. package/lib/esm/core-components/atoms/date-picker/date-picker.component.test.js +14 -8
  50. package/lib/esm/core-components/atoms/date-picker/date-picker.stories.js +16 -8
  51. package/lib/esm/core-components/atoms/input/input-otp.component.js +80 -59
  52. package/lib/esm/core-components/atoms/input/input-pin.component.js +136 -77
  53. package/lib/esm/core-components/atoms/input/input-pin.component.test.js +26 -10
  54. package/lib/esm/core-components/atoms/input/input-pin.stories.js +14 -8
  55. package/lib/esm/core-components/atoms/input/input.component.js +62 -12
  56. package/lib/esm/core-components/atoms/input/input.component.test.js +28 -10
  57. package/lib/esm/core-components/atoms/input/input.stories.js +13 -6
  58. package/lib/esm/core-components/atoms/input-dropdown/input-dropdown.component.js +96 -37
  59. package/lib/esm/core-components/atoms/input-dropdown/input-dropdown.component.test.js +14 -7
  60. package/lib/esm/core-components/atoms/input-dropdown/input-dropdown.stories.js +11 -6
  61. package/lib/esm/core-components/atoms/loader/loader.component.js +80 -20
  62. package/lib/esm/core-components/atoms/loader/loader.component.test.js +7 -7
  63. package/lib/esm/core-components/atoms/loader/loader.stories.js +11 -7
  64. package/lib/esm/core-components/atoms/radio/radio.component.js +12 -6
  65. package/lib/esm/core-components/atoms/radio/radio.component.test.js +9 -7
  66. package/lib/esm/core-components/atoms/radio/radio.stories.js +16 -9
  67. package/lib/esm/core-components/atoms/stepper/stepper.component.js +74 -32
  68. package/lib/esm/core-components/atoms/stepper/stepper.component.test.js +14 -7
  69. package/lib/esm/core-components/atoms/stepper/stepper.stories.js +12 -6
  70. package/lib/esm/core-components/atoms/timer/timer.component.js +81 -75
  71. package/lib/esm/core-components/atoms/timer/timer.component.test.js +10 -10
  72. package/lib/esm/core-components/index.js +12 -12
  73. package/lib/esm/core-utils/index.js +2 -2
  74. package/lib/esm/core-utils/unit-test.utils.js +5 -5
  75. package/lib/esm/index.js +2 -2
  76. package/lib/esm/reportWebVitals.js +10 -10
  77. package/lib/esm/setupTests.js +2 -2
  78. package/package.json +20 -4
@@ -1,89 +1,131 @@
1
1
  "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
- Object.defineProperty(o, "default", { enumerable: true, value: v });
15
- }) : function(o, v) {
16
- o["default"] = v;
17
- });
18
- var __importStar = (this && this.__importStar) || function (mod) {
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) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
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
50
  require("./input-otp.styles.css");
30
- const InputOtp = ({ className, pin, onPinChanged, }) => {
31
- const pinLength = 6;
32
- const Pin_Min_Value = 0;
33
- const Pin_Max_Value = 9;
34
- const BACKSPACE_Key = 'Backspace';
35
- const inputRefs = (0, react_1.useRef)([]);
36
- (0, react_1.useEffect)(() => {
37
- const ref = inputRefs.current[0];
38
- if (ref) {
39
- ref.focus();
40
- }
41
- }, []);
42
- const changePinFocus = (pinIndex) => {
43
- const ref = inputRefs.current[pinIndex];
44
- if (ref) {
45
- ref.focus();
46
- }
47
- };
48
- const onChange = (event, index) => {
49
- const value = event.target.value;
50
- const pinNumber = Number(value.trim());
51
- if (isNaN(pinNumber) || value.length === 0) {
52
- return;
53
- }
54
- if (pinNumber >= Pin_Min_Value && pinNumber <= Pin_Max_Value) {
55
- onPinChanged(pinNumber, index);
56
- if (index < pinLength - 1) {
57
- changePinFocus(index + 1);
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
- const onKeyDown = (event, index) => {
62
- console.log({ event, index });
63
- const keyboardKeyCode = event.nativeEvent.code;
64
- if (keyboardKeyCode != BACKSPACE_Key)
65
- return;
66
- if (pin[index] === undefined) {
67
- changePinFocus(index - 1);
68
- }
69
- else {
70
- onPinChanged(undefined, index);
71
- }
72
- };
73
- return (react_1.default.createElement("div", { className: `${className} relative` },
74
- react_1.default.createElement("div", { className: "flex space-x-1 bg-background-secondary rounded-lg outline-offset-8" }, Array.from({ length: pinLength }, (_, index) => (react_1.default.createElement("input", { "data-testid": "onPinChanged", className: "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", onKeyDown: (event) => onKeyDown(event, index), key: index, onMouseUp: () => {
75
- if (pin.join('').length <= 0) {
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,106 +1,186 @@
1
1
  "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
- Object.defineProperty(o, "default", { enumerable: true, value: v });
15
- }) : function(o, v) {
16
- o["default"] = v;
17
- });
18
- var __importStar = (this && this.__importStar) || function (mod) {
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) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
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 = ({ title, className, pin, errorMsg, defaultMsg, hasError, onPinChanged, }) => {
31
- const pinLength = 12;
32
- const Pin_Min_Value = 0;
33
- const Pin_Max_Value = 9;
34
- const BACKSPACE_Key = 'Backspace';
35
- const inputRefs = (0, react_1.useRef)([]);
36
- const removeValuesFromArray = (valuesArray, value) => {
37
- const valueIndex = valuesArray.findIndex((entry) => entry === value);
38
- if (valueIndex === -1) {
39
- return;
40
- }
41
- valuesArray.splice(valueIndex, 1);
42
- };
43
- const changePinFocus = (pinIndex) => {
44
- const ref = inputRefs.current[pinIndex];
45
- if (ref) {
46
- ref.focus();
47
- }
48
- };
49
- const onChange = (event, index) => {
50
- const previousValue = event.target.defaultValue;
51
- const valueArray = event.target.value.split('');
52
- removeValuesFromArray(valueArray, previousValue);
53
- const value = valueArray.pop();
54
- if (!value) {
55
- return;
56
- }
57
- const pinNumber = Number(value);
58
- if (isNaN(pinNumber) || value.length === 0) {
59
- return;
60
- }
61
- if (pinNumber >= Pin_Min_Value && pinNumber <= Pin_Max_Value) {
62
- onPinChanged(pinNumber, index);
63
- if (index < pinLength - 1) {
64
- changePinFocus(index + 1);
65
- }
66
- }
67
- };
68
- const onKeyDown = (event, index) => {
69
- const keyboardKeyCode = event.nativeEvent.code;
70
- if (keyboardKeyCode != BACKSPACE_Key)
71
- return;
72
- if (pin[index] !== undefined && keyboardKeyCode === BACKSPACE_Key) {
73
- changePinFocus(index - 1);
74
- }
75
- if (pin[index] === undefined) {
76
- changePinFocus(index - 1);
77
- }
78
- else {
79
- onPinChanged(undefined, index);
80
- }
81
- };
82
- return (react_1.default.createElement("div", { className: `${className} relative` },
83
- react_1.default.createElement("label", { className: "duration-300 -z-1 origin-0 text-gray-dark-secondary font-nunitoSansRegular text-md" }, title),
84
- react_1.default.createElement("div", { className: "flex space-x-1" }, Array.from({ length: pinLength }, (_, index) => {
85
- var _a;
86
- return (react_1.default.createElement("div", { className: "flex space-x-1 max-w-full items-stretch", key: index },
87
- react_1.default.createElement("input", { "data-testid": "inputElementPin", type: "tel", className: "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 ", onKeyUp: (event) => onKeyDown(event, index), key: index, onMouseUp: () => {
88
- if (pin.join('').length <= 0) {
89
- changePinFocus(0);
90
- }
91
- }, onClick: () => {
92
- if (pin.join('').length <= 0) {
93
- onPinChanged(undefined, 0);
94
- }
95
- }, ref: (el) => {
96
- if (el) {
97
- inputRefs.current[index] = el;
98
- }
99
- }, onChange: (event) => onChange(event, index), value: ((_a = pin[index]) === null || _a === void 0 ? void 0 : _a.toString()) || '' }),
100
- react_1.default.createElement("div", { className: "invisible" }, (index + 1) % 4 === 0 ? 'ss' : null)));
101
- })),
102
- hasError && (hasError === null || hasError === void 0 ? void 0 : hasError.type) !== 'required' && (react_1.default.createElement("span", { className: "text-sm text-red text-4xs font-nunitoSansRegular", id: "error" }, `${errorMsg || ''}`)),
103
- (!hasError || (hasError === null || hasError === void 0 ? void 0 : hasError.type) === 'required') && (react_1.default.createElement("span", { className: "text-sm text-4xs font-nunitoSansRegular", id: "error" }, `${defaultMsg || ''}`))));
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 = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
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('render InputOtp correctly without error', () => {
11
- const pinInput = (0, _core_utils_1.render)(react_1.default.createElement(input_pin_component_1.InputPin, { title: "Enter your Aadhaar Number", hasError: false, errorMsg: "Uh oh! You\u2019ve entered an invalid aadhaar number", onPinChanged: () => jest.fn(), pin: new Array(12) }));
12
- expect(pinInput).toMatchSnapshot();
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('render InputOtp correctly with error', () => {
15
- const pinInput = (0, _core_utils_1.render)(react_1.default.createElement(input_pin_component_1.InputPin, { title: "Enter your Aadhaar Number", hasError: true, errorMsg: "Uh oh! You\u2019ve entered an invalid aadhaar number", onPinChanged: () => jest.fn(), pin: new Array(12) }));
16
- expect(pinInput).toMatchSnapshot();
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 = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
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
- title: 'Atoms/InputPin',
12
- component: input_pin_component_1.InputPin,
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 = () => (react_1.default.createElement(input_pin_component_1.InputPin, { title: "Enter your Aadhaar Number", hasError: true, onPinChanged: (value) => {
17
- console.log({ value });
18
- }, pin: pin }));
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