react-restyle-components 0.1.27 → 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.
Files changed (93) hide show
  1. package/lib/cjs/App.js +36 -12
  2. package/lib/cjs/App.test.js +10 -8
  3. package/lib/cjs/core-components/atoms/buttons/button.stories.js +20 -8
  4. package/lib/cjs/core-components/atoms/buttons/buttons.component.js +17 -6
  5. package/lib/cjs/core-components/atoms/buttons/buttons.component.test.js +15 -7
  6. package/lib/cjs/core-components/atoms/check-box/checkBox.component.js +27 -11
  7. package/lib/cjs/core-components/atoms/check-box/checkBox.component.js.map +1 -1
  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 +98 -38
  11. package/lib/cjs/core-components/atoms/date-picker/date-picker.component.js.map +1 -1
  12. package/lib/cjs/core-components/atoms/date-picker/date-picker.component.test.js +15 -7
  13. package/lib/cjs/core-components/atoms/date-picker/date-picker.stories.js +18 -8
  14. package/lib/cjs/core-components/atoms/input/input-otp.component.js +119 -77
  15. package/lib/cjs/core-components/atoms/input/input-otp.component.js.map +1 -1
  16. package/lib/cjs/core-components/atoms/input/input-otp.styles.css +35 -0
  17. package/lib/cjs/core-components/atoms/input/input-pin.component.js +174 -94
  18. package/lib/cjs/core-components/atoms/input/input-pin.component.test.js +28 -10
  19. package/lib/cjs/core-components/atoms/input/input-pin.stories.js +17 -9
  20. package/lib/cjs/core-components/atoms/input/input.component.js +65 -13
  21. package/lib/cjs/core-components/atoms/input/input.component.test.js +30 -10
  22. package/lib/cjs/core-components/atoms/input/input.stories.js +16 -7
  23. package/lib/cjs/core-components/atoms/input/input.styles.css +35 -0
  24. package/lib/cjs/core-components/atoms/input-dropdown/input-dropdown.component.js +134 -58
  25. package/lib/cjs/core-components/atoms/input-dropdown/input-dropdown.component.js.map +1 -1
  26. package/lib/cjs/core-components/atoms/input-dropdown/input-dropdown.component.test.js +16 -7
  27. package/lib/cjs/core-components/atoms/input-dropdown/input-dropdown.stories.js +14 -7
  28. package/lib/cjs/core-components/atoms/loader/loader.component.js +83 -21
  29. package/lib/cjs/core-components/atoms/loader/loader.component.test.js +11 -7
  30. package/lib/cjs/core-components/atoms/loader/loader.stories.js +14 -8
  31. package/lib/cjs/core-components/atoms/radio/radio.component.js +22 -8
  32. package/lib/cjs/core-components/atoms/radio/radio.component.js.map +1 -1
  33. package/lib/cjs/core-components/atoms/radio/radio.component.test.js +14 -7
  34. package/lib/cjs/core-components/atoms/radio/radio.stories.js +22 -10
  35. package/lib/cjs/core-components/atoms/stepper/stepper.component.js +77 -34
  36. package/lib/cjs/core-components/atoms/stepper/stepper.component.test.js +16 -7
  37. package/lib/cjs/core-components/atoms/stepper/stepper.stories.js +15 -7
  38. package/lib/cjs/core-components/atoms/timer/timer.component.js +120 -93
  39. package/lib/cjs/core-components/atoms/timer/timer.component.js.map +1 -1
  40. package/lib/cjs/core-components/atoms/timer/timer.component.test.js +20 -10
  41. package/lib/cjs/core-components/index.js +44 -15
  42. package/lib/cjs/core-components/index.js.map +1 -1
  43. package/lib/cjs/core-utils/index.js +31 -15
  44. package/lib/cjs/core-utils/unit-test.utils.js +8 -6
  45. package/lib/cjs/index.js +31 -15
  46. package/lib/cjs/reportWebVitals.js +52 -29
  47. package/lib/cjs/setupTests.js +1 -1
  48. package/lib/esm/App.js +34 -12
  49. package/lib/esm/App.test.js +8 -8
  50. package/lib/esm/core-components/atoms/buttons/button.stories.js +17 -7
  51. package/lib/esm/core-components/atoms/buttons/buttons.component.js +13 -4
  52. package/lib/esm/core-components/atoms/buttons/buttons.component.test.js +13 -7
  53. package/lib/esm/core-components/atoms/check-box/checkBox.component.js +20 -9
  54. package/lib/esm/core-components/atoms/check-box/checkBox.component.js.map +1 -1
  55. package/lib/esm/core-components/atoms/check-box/checkBox.component.test.js +9 -7
  56. package/lib/esm/core-components/atoms/check-box/checkBox.stories.js +16 -8
  57. package/lib/esm/core-components/atoms/date-picker/date-picker.component.js +52 -20
  58. package/lib/esm/core-components/atoms/date-picker/date-picker.component.js.map +1 -1
  59. package/lib/esm/core-components/atoms/date-picker/date-picker.component.test.js +14 -8
  60. package/lib/esm/core-components/atoms/date-picker/date-picker.stories.js +16 -8
  61. package/lib/esm/core-components/atoms/input/input-otp.component.js +80 -59
  62. package/lib/esm/core-components/atoms/input/input-otp.component.js.map +1 -1
  63. package/lib/esm/core-components/atoms/input/input-pin.component.js +136 -77
  64. package/lib/esm/core-components/atoms/input/input-pin.component.test.js +26 -10
  65. package/lib/esm/core-components/atoms/input/input-pin.stories.js +14 -8
  66. package/lib/esm/core-components/atoms/input/input.component.js +62 -12
  67. package/lib/esm/core-components/atoms/input/input.component.test.js +28 -10
  68. package/lib/esm/core-components/atoms/input/input.stories.js +13 -6
  69. package/lib/esm/core-components/atoms/input-dropdown/input-dropdown.component.js +96 -37
  70. package/lib/esm/core-components/atoms/input-dropdown/input-dropdown.component.js.map +1 -1
  71. package/lib/esm/core-components/atoms/input-dropdown/input-dropdown.component.test.js +14 -7
  72. package/lib/esm/core-components/atoms/input-dropdown/input-dropdown.stories.js +11 -6
  73. package/lib/esm/core-components/atoms/loader/loader.component.js +80 -20
  74. package/lib/esm/core-components/atoms/loader/loader.component.test.js +7 -7
  75. package/lib/esm/core-components/atoms/loader/loader.stories.js +11 -7
  76. package/lib/esm/core-components/atoms/radio/radio.component.js +12 -6
  77. package/lib/esm/core-components/atoms/radio/radio.component.js.map +1 -1
  78. package/lib/esm/core-components/atoms/radio/radio.component.test.js +9 -7
  79. package/lib/esm/core-components/atoms/radio/radio.stories.js +16 -9
  80. package/lib/esm/core-components/atoms/stepper/stepper.component.js +74 -32
  81. package/lib/esm/core-components/atoms/stepper/stepper.component.test.js +14 -7
  82. package/lib/esm/core-components/atoms/stepper/stepper.stories.js +12 -6
  83. package/lib/esm/core-components/atoms/timer/timer.component.js +81 -75
  84. package/lib/esm/core-components/atoms/timer/timer.component.js.map +1 -1
  85. package/lib/esm/core-components/atoms/timer/timer.component.test.js +10 -10
  86. package/lib/esm/core-components/index.js +12 -2
  87. package/lib/esm/core-components/index.js.map +1 -1
  88. package/lib/esm/core-utils/index.js +2 -2
  89. package/lib/esm/core-utils/unit-test.utils.js +5 -5
  90. package/lib/esm/index.js +2 -2
  91. package/lib/esm/reportWebVitals.js +10 -10
  92. package/lib/esm/setupTests.js +2 -2
  93. package/package.json +20 -4
@@ -1,10 +1,16 @@
1
1
  /* eslint-disable testing-library/render-result-naming-convention */
2
- import React from 'react';
3
- import { render } from '@core-utils';
4
- import { DatePickerComp } from './date-picker.component';
5
- import dayjs from 'dayjs';
6
- it('render XB_DatePicker correctly', () => {
7
- const datepicker = render(React.createElement(DatePickerComp, { className: "mt-6", value: dayjs().format('YYYY-MM-DD'), showFormat: 'dd-MM-yyyy' }));
8
- expect(datepicker).toMatchSnapshot();
2
+ import React from "react";
3
+ import { render } from "@core-utils";
4
+ import { DatePickerComp } from "./date-picker.component";
5
+ import dayjs from "dayjs";
6
+ it("render XB_DatePicker correctly", () => {
7
+ const datepicker = render(
8
+ React.createElement(DatePickerComp, {
9
+ className: "mt-6",
10
+ value: dayjs().format("YYYY-MM-DD"),
11
+ showFormat: "dd-MM-yyyy",
12
+ })
13
+ );
14
+ expect(datepicker).toMatchSnapshot();
9
15
  });
10
- //# sourceMappingURL=date-picker.component.test.js.map
16
+ //# sourceMappingURL=date-picker.component.test.js.map
@@ -1,12 +1,20 @@
1
- import React from 'react';
2
- import { DatePickerComp } from './date-picker.component';
3
- import dayjs from 'dayjs';
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
- title: 'Atoms/DatePickerComp',
7
- component: DatePickerComp,
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 = () => (React.createElement("div", { className: "flex flex-row" },
11
- React.createElement(DatePickerComp, { className: "mt-6", value: dayjs().format('YYYY-MM-DD'), showFormat: 'dd-MM-yyyy' })));
12
- //# sourceMappingURL=date-picker.stories.js.map
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 'react';
3
- import './inputOtp.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);
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
- const onKeyDown = (event, index) => {
36
- console.log({ event, index });
37
- const keyboardKeyCode = event.nativeEvent.code;
38
- if (keyboardKeyCode != BACKSPACE_Key)
39
- return;
40
- if (pin[index] === undefined) {
41
- changePinFocus(index - 1);
42
- }
43
- else {
44
- onPinChanged(undefined, index);
45
- }
46
- };
47
- return (React.createElement("div", { className: `${className} relative` },
48
- React.createElement("div", { className: "flex space-x-1 bg-background-secondary rounded-lg outline-offset-8" }, Array.from({ length: pinLength }, (_, index) => (React.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: () => {
49
- if (pin.join('').length <= 0) {
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 +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,OAAO,KAAK,EAAE,EAAC,SAAS,EAAE,MAAM,EAAC,MAAM,OAAO,CAAC;AAC/C,OAAO,uBAAuB,CAAC;AAa/B,MAAM,CAAC,MAAM,QAAQ,GAAgC,CAAC,EACpD,SAAS,EACT,GAAG,EACH,YAAY,GACb,EAAE,EAAE;IACH,MAAM,SAAS,GAAG,CAAC,CAAC;IACpB,MAAM,aAAa,GAAG,CAAC,CAAC;IACxB,MAAM,aAAa,GAAG,CAAC,CAAC;IACxB,MAAM,aAAa,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3,"file":"input-otp.component.js","sourceRoot":"","sources":["../../../../../src/core-components/atoms/input/input-otp.component.tsx"],"names":[],"mappings":"AAAA,+BAA+B;AAC/B,OAAO,KAAK,EAAE,EAAC,SAAS,EAAE,MAAM,EAAC,MAAM,OAAO,CAAC;AAC/C,OAAO,wBAAwB,CAAC;AAahC,MAAM,CAAC,MAAM,QAAQ,GAAgC,CAAC,EACpD,SAAS,EACT,GAAG,EACH,YAAY,GACb,EAAE,EAAE;IACH,MAAM,SAAS,GAAG,CAAC,CAAC;IACpB,MAAM,aAAa,GAAG,CAAC,CAAC;IACxB,MAAM,aAAa,GAAG,CAAC,CAAC;IACxB,MAAM,aAAa,GAAG,WAAW,CAAC;IAClC,MAAM,SAAS,GAAG,MAAM,CAAqB,EAAE,CAAC,CAAC;IAEjD,SAAS,CAAC,GAAG,EAAE;QACb,MAAM,GAAG,GAAG,SAAS,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC;QACjC,IAAI,GAAG,EAAE;YACP,GAAG,CAAC,KAAK,EAAE,CAAC;SACb;IACH,CAAC,EAAE,EAAE,CAAC,CAAC;IAEP,MAAM,cAAc,GAAG,CAAC,QAAgB,EAAE,EAAE;QAC1C,MAAM,GAAG,GAAG,SAAS,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC;QACxC,IAAI,GAAG,EAAE;YACP,GAAG,CAAC,KAAK,EAAE,CAAC;SACb;IACH,CAAC,CAAC;IAEF,MAAM,QAAQ,GAAG,CACf,KAA0C,EAC1C,KAAa,EACb,EAAE;QACF,MAAM,KAAK,GAAG,KAAK,CAAC,MAAM,CAAC,KAAK,CAAC;QACjC,MAAM,SAAS,GAAG,MAAM,CAAC,KAAK,CAAC,IAAI,EAAE,CAAC,CAAC;QAEvC,IAAI,KAAK,CAAC,SAAS,CAAC,IAAI,KAAK,CAAC,MAAM,KAAK,CAAC,EAAE;YAC1C,OAAO;SACR;QAED,IAAI,SAAS,IAAI,aAAa,IAAI,SAAS,IAAI,aAAa,EAAE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5B,YAAY,CAAC,SAAS,EAAE,CAAC,CAAC,CAAC;iBAC5B;YACH,CAAC,EACD,GAAG,EAAE,CAAC,EAAE,EAAE,EAAE;gBACV,IAAI,EAAE,EAAE;oBACN,SAAS,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"}
@@ -1,79 +1,138 @@
1
1
  /* eslint-disable */
2
- import React, { useRef } from 'react';
3
- import './input.styles.css';
4
- export const InputPin = ({ title, className, pin, errorMsg, defaultMsg, hasError, onPinChanged, }) => {
5
- const pinLength = 12;
6
- const Pin_Min_Value = 0;
7
- const Pin_Max_Value = 9;
8
- const BACKSPACE_Key = 'Backspace';
9
- const inputRefs = useRef([]);
10
- const removeValuesFromArray = (valuesArray, value) => {
11
- const valueIndex = valuesArray.findIndex((entry) => entry === value);
12
- if (valueIndex === -1) {
13
- return;
14
- }
15
- valuesArray.splice(valueIndex, 1);
16
- };
17
- const changePinFocus = (pinIndex) => {
18
- const ref = inputRefs.current[pinIndex];
19
- if (ref) {
20
- ref.focus();
21
- }
22
- };
23
- const onChange = (event, index) => {
24
- const previousValue = event.target.defaultValue;
25
- const valueArray = event.target.value.split('');
26
- removeValuesFromArray(valueArray, previousValue);
27
- const value = valueArray.pop();
28
- if (!value) {
29
- return;
30
- }
31
- const pinNumber = Number(value);
32
- if (isNaN(pinNumber) || value.length === 0) {
33
- return;
34
- }
35
- if (pinNumber >= Pin_Min_Value && pinNumber <= Pin_Max_Value) {
36
- onPinChanged(pinNumber, index);
37
- if (index < pinLength - 1) {
38
- changePinFocus(index + 1);
39
- }
40
- }
41
- };
42
- const onKeyDown = (event, index) => {
43
- const keyboardKeyCode = event.nativeEvent.code;
44
- if (keyboardKeyCode != BACKSPACE_Key)
45
- return;
46
- if (pin[index] !== undefined && keyboardKeyCode === BACKSPACE_Key) {
47
- changePinFocus(index - 1);
48
- }
49
- if (pin[index] === undefined) {
50
- changePinFocus(index - 1);
51
- }
52
- else {
53
- onPinChanged(undefined, index);
54
- }
55
- };
56
- return (React.createElement("div", { className: `${className} relative` },
57
- React.createElement("label", { className: "duration-300 -z-1 origin-0 text-gray-dark-secondary font-nunitoSansRegular text-md" }, title),
58
- React.createElement("div", { className: "flex space-x-1" }, Array.from({ length: pinLength }, (_, index) => {
59
- var _a;
60
- return (React.createElement("div", { className: "flex space-x-1 max-w-full items-stretch", key: index },
61
- React.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: () => {
62
- if (pin.join('').length <= 0) {
63
- changePinFocus(0);
64
- }
65
- }, onClick: () => {
66
- if (pin.join('').length <= 0) {
67
- onPinChanged(undefined, 0);
68
- }
69
- }, ref: (el) => {
70
- if (el) {
71
- inputRefs.current[index] = el;
72
- }
73
- }, onChange: (event) => onChange(event, index), value: ((_a = pin[index]) === null || _a === void 0 ? void 0 : _a.toString()) || '' }),
74
- React.createElement("div", { className: "invisible" }, (index + 1) % 4 === 0 ? 'ss' : null)));
75
- })),
76
- hasError && (hasError === null || hasError === void 0 ? void 0 : hasError.type) !== 'required' && (React.createElement("span", { className: "text-sm text-red text-4xs font-nunitoSansRegular", id: "error" }, `${errorMsg || ''}`)),
77
- (!hasError || (hasError === null || hasError === void 0 ? void 0 : hasError.type) === 'required') && (React.createElement("span", { className: "text-sm text-4xs font-nunitoSansRegular", id: "error" }, `${defaultMsg || ''}`))));
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 '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(React.createElement(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) }));
7
- expect(pinInput).toMatchSnapshot();
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('render InputOtp correctly with error', () => {
10
- const pinInput = render(React.createElement(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) }));
11
- expect(pinInput).toMatchSnapshot();
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 'react';
2
- import { InputPin } from './input-pin.component';
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
- title: 'Atoms/InputPin',
6
- component: InputPin,
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 = () => (React.createElement(InputPin, { title: "Enter your Aadhaar Number", hasError: true, onPinChanged: (value) => {
11
- console.log({ value });
12
- }, pin: pin }));
13
- //# sourceMappingURL=input-pin.stories.js.map
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 'react';
3
- import './input.styles.css';
4
- export const Input = ({ title, value, className, disable, hasError, errorMsg, defaultMsg, inputStyle, autoComplete, maxlength = 40, onChange, onBlur, }) => {
5
- const onKeyUpValue = (event) => {
6
- onChange(event.target.value);
7
- };
8
- return (React.createElement("div", { className: `${className} relative` },
9
- React.createElement("input", { "data-testid": "inputElement", type: "text", name: "name", value: value, placeholder: " ", disabled: disable, 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}`, onChange: (e) => onChange && onChange(e.target.value), onKeyUp: onKeyUpValue, onBlur: (e) => onBlur && onBlur(e.target.value), autoComplete: autoComplete, maxLength: maxlength }),
10
- React.createElement("label", { className: "absolute duration-300 top-3 -z-1 origin-0 text-gray-dark-secondary font-nunitoSansRegular text-md" }, title),
11
- hasError && (hasError === null || hasError === void 0 ? void 0 : hasError.type) !== 'required' && (React.createElement("span", { className: "text-sm text-red text-4xs", id: "error" }, `${errorMsg || ''}`)),
12
- (!hasError || (hasError === null || hasError === void 0 ? void 0 : hasError.type) === 'required') && (React.createElement("span", { className: "text-sm text-4xs", id: "error" }, `${defaultMsg || ''}`))));
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 'react';
3
- import { render } from '@core-utils';
4
- import { Input } from './input.component';
5
- it('render Input correctly without error', () => {
6
- const input = render(React.createElement(Input, { className: "h-1 relative top-1 border-red-600 border-b-0 dummy", title: 'input', hasError: false, value: '', inputStyle: " border-b-0 invisible ", onChange: () => jest.fn() }));
7
- expect(input).toMatchSnapshot();
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('render Input correctly with error', () => {
10
- const input = render(React.createElement(Input, { className: "h-1 relative top-1 border-red-600 border-b-0 dummy", title: 'input', hasError: true, value: '', inputStyle: " border-b-0 invisible ", onChange: () => jest.fn() }));
11
- expect(input).toMatchSnapshot();
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 'react';
2
- import { Input } from './input.component';
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
- title: 'Atoms/Input',
6
- component: Input,
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 = () => (React.createElement(Input, { className: "mt-4", title: "Enter your Pan Number", hasError: true, value: "", onChange: (panNumber) => console.log({ panNumber }) }));
10
- //# sourceMappingURL=input.stories.js.map
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