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.
- package/README.md +6 -1
- 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-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-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,38 +1,97 @@
|
|
|
1
|
-
import React, { useState, useEffect, useRef } from
|
|
2
|
-
import UpArrow from
|
|
3
|
-
import DownArrow from
|
|
4
|
-
export const InputDropdown = ({
|
|
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
|
-
|
|
1
|
+
import React, { useState, useEffect, useRef } from "react";
|
|
2
|
+
import UpArrow from "@assets/svg/UpArrow.svg";
|
|
3
|
+
import DownArrow from "@assets/svg/DownArrow.svg";
|
|
4
|
+
export const InputDropdown = ({
|
|
5
|
+
items,
|
|
6
|
+
className,
|
|
7
|
+
hasError,
|
|
8
|
+
title,
|
|
9
|
+
onChange,
|
|
10
|
+
}) => {
|
|
11
|
+
const [isOpen, setIsOpen] = useState(false);
|
|
12
|
+
const [value, setValue] = useState("");
|
|
13
|
+
const useOutsideAlerter = (ref) => {
|
|
14
|
+
useEffect(() => {
|
|
15
|
+
function handleClickOutside(event) {
|
|
16
|
+
if (
|
|
17
|
+
ref.current &&
|
|
18
|
+
!ref.current.contains(event.target) &&
|
|
19
|
+
isOpen &&
|
|
20
|
+
isOpen
|
|
21
|
+
)
|
|
22
|
+
setIsOpen(!isOpen);
|
|
23
|
+
}
|
|
24
|
+
document.addEventListener("mousedown", handleClickOutside);
|
|
25
|
+
return () => {
|
|
26
|
+
document.removeEventListener("mousedown", handleClickOutside);
|
|
27
|
+
};
|
|
28
|
+
}, [ref]);
|
|
29
|
+
};
|
|
30
|
+
const wrapperRef = useRef(null);
|
|
31
|
+
useOutsideAlerter(wrapperRef);
|
|
32
|
+
return React.createElement(
|
|
33
|
+
"div",
|
|
34
|
+
{ className: `${className} relative` },
|
|
35
|
+
React.createElement(
|
|
36
|
+
"div",
|
|
37
|
+
{ className: "flex flex-row items-center " },
|
|
38
|
+
React.createElement("input", {
|
|
39
|
+
type: "text",
|
|
40
|
+
name: "name",
|
|
41
|
+
placeholder: title,
|
|
42
|
+
value: value,
|
|
43
|
+
className:
|
|
44
|
+
" text-gray-dark-secondary pt-3 pb-2 w-full px-0 mt-0 bg-transparent border-gray-secondary border-0 border-b appearance-none focus:outline-none focus:ring-0 font-nunitoSansRegular text-md",
|
|
45
|
+
onClick: () => {
|
|
46
|
+
setIsOpen(!isOpen);
|
|
47
|
+
},
|
|
48
|
+
onChange: (event) => onChange && onChange(event.target.value),
|
|
49
|
+
}),
|
|
50
|
+
!isOpen &&
|
|
51
|
+
React.createElement("img", {
|
|
52
|
+
src: UpArrow,
|
|
53
|
+
className: "absolute h-4 w-4 right-0",
|
|
54
|
+
}),
|
|
55
|
+
isOpen &&
|
|
56
|
+
React.createElement("img", {
|
|
57
|
+
src: DownArrow,
|
|
58
|
+
className: "absolute h-4 w-4 right-0",
|
|
59
|
+
})
|
|
60
|
+
),
|
|
61
|
+
isOpen &&
|
|
62
|
+
React.createElement(
|
|
63
|
+
"div",
|
|
64
|
+
{
|
|
65
|
+
className:
|
|
66
|
+
"z-10 w-full absolute text-base list-none bg-white rounded divide-y divide-gray-100 shadow dark:bg-gray-700",
|
|
67
|
+
ref: wrapperRef,
|
|
68
|
+
},
|
|
69
|
+
React.createElement(
|
|
70
|
+
"ul",
|
|
71
|
+
{ className: "py-1" },
|
|
72
|
+
items.map((item, index) =>
|
|
73
|
+
React.createElement(
|
|
74
|
+
"li",
|
|
75
|
+
{
|
|
76
|
+
key: index,
|
|
77
|
+
className:
|
|
78
|
+
"block py-2 px-4 text-md hover:bg-gray-100 dark:hover:bg-gray-600 dark:text-gray-200 font-nunitoSansRegular",
|
|
79
|
+
onClick: () => {
|
|
80
|
+
setValue(item);
|
|
81
|
+
setIsOpen(!isOpen);
|
|
82
|
+
},
|
|
83
|
+
},
|
|
84
|
+
item
|
|
85
|
+
)
|
|
86
|
+
)
|
|
87
|
+
)
|
|
88
|
+
),
|
|
89
|
+
hasError &&
|
|
90
|
+
React.createElement(
|
|
91
|
+
"span",
|
|
92
|
+
{ className: "text-primaryCharcoal text-4xs", id: "error" },
|
|
93
|
+
`${title} is required`
|
|
94
|
+
)
|
|
95
|
+
);
|
|
37
96
|
};
|
|
38
|
-
//# sourceMappingURL=input-dropdown.component.js.map
|
|
97
|
+
//# sourceMappingURL=input-dropdown.component.js.map
|
|
@@ -1,9 +1,16 @@
|
|
|
1
1
|
/* eslint-disable testing-library/render-result-naming-convention */
|
|
2
|
-
import React from
|
|
3
|
-
import { render } from
|
|
4
|
-
import { InputDropdown } from
|
|
5
|
-
it(
|
|
6
|
-
|
|
7
|
-
|
|
2
|
+
import React from "react";
|
|
3
|
+
import { render } from "@core-utils";
|
|
4
|
+
import { InputDropdown } from "./input-dropdown.component";
|
|
5
|
+
it("render InputDropdown correctly", () => {
|
|
6
|
+
const inputDropDown = render(
|
|
7
|
+
React.createElement(InputDropdown, {
|
|
8
|
+
title: "Source of funds",
|
|
9
|
+
items: ["Bank account", "UPI", "Credit Card"],
|
|
10
|
+
hasError: true,
|
|
11
|
+
onChange: () => jest.fn(),
|
|
12
|
+
})
|
|
13
|
+
);
|
|
14
|
+
expect(inputDropDown).toMatchSnapshot();
|
|
8
15
|
});
|
|
9
|
-
//# sourceMappingURL=input-dropdown.component.test.js.map
|
|
16
|
+
//# sourceMappingURL=input-dropdown.component.test.js.map
|
|
@@ -1,10 +1,15 @@
|
|
|
1
|
-
import React from
|
|
2
|
-
import { InputDropdown } from
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { InputDropdown } from "./input-dropdown.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/InputDropdown",
|
|
6
|
+
component: InputDropdown,
|
|
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(InputDropdown, {
|
|
11
|
+
title: "Source of funds",
|
|
12
|
+
items: ["Bank account", "UPI", "Credit Card"],
|
|
13
|
+
hasError: true,
|
|
14
|
+
});
|
|
15
|
+
//# sourceMappingURL=input-dropdown.stories.js.map
|
|
@@ -1,16 +1,48 @@
|
|
|
1
|
-
import React from
|
|
2
|
-
import { Container, Row, Spinner } from
|
|
3
|
-
export const Loader = () =>
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { Container, Row, Spinner } from "reactstrap";
|
|
3
|
+
export const Loader = () =>
|
|
4
|
+
React.createElement(
|
|
5
|
+
Container,
|
|
6
|
+
{ fluid: true, className: "vh-50 d-flex" },
|
|
7
|
+
React.createElement(
|
|
8
|
+
Row,
|
|
9
|
+
{
|
|
10
|
+
className: "justify-content-center align-self-center w-100 text-center",
|
|
11
|
+
},
|
|
12
|
+
React.createElement(Spinner, { color: "primary" })
|
|
13
|
+
)
|
|
14
|
+
);
|
|
6
15
|
export const ModalLoader = () => {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
16
|
+
return React.createElement(
|
|
17
|
+
React.Fragment,
|
|
18
|
+
null,
|
|
19
|
+
React.createElement(
|
|
20
|
+
React.Fragment,
|
|
21
|
+
null,
|
|
22
|
+
React.createElement(
|
|
23
|
+
"div",
|
|
24
|
+
{
|
|
25
|
+
className:
|
|
26
|
+
"justify-center items-center flex overflow-x-hidden overflow-y-auto fixed inset-0 z-50 outline-none focus:outline-none",
|
|
27
|
+
},
|
|
28
|
+
React.createElement(
|
|
29
|
+
"div",
|
|
30
|
+
{ className: "relative mx-auto " },
|
|
31
|
+
React.createElement(
|
|
32
|
+
"div",
|
|
33
|
+
{
|
|
34
|
+
className:
|
|
35
|
+
"border-0 rounded-lg shadow-lg relative flex flex-col w-full bg-white outline-none focus:outline-none",
|
|
36
|
+
},
|
|
37
|
+
React.createElement(
|
|
38
|
+
"div",
|
|
39
|
+
{
|
|
40
|
+
className: "relative p-2 flex-auto flex flex-col items-center",
|
|
41
|
+
},
|
|
42
|
+
React.createElement(
|
|
43
|
+
"style",
|
|
44
|
+
null,
|
|
45
|
+
`
|
|
14
46
|
.spinner .background {
|
|
15
47
|
fill: #555;
|
|
16
48
|
}
|
|
@@ -42,12 +74,40 @@ export const ModalLoader = () => {
|
|
|
42
74
|
transform: rotate(360deg);
|
|
43
75
|
}
|
|
44
76
|
}
|
|
45
|
-
`
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
77
|
+
`
|
|
78
|
+
),
|
|
79
|
+
React.createElement(
|
|
80
|
+
"svg",
|
|
81
|
+
{
|
|
82
|
+
className: "spinner",
|
|
83
|
+
width: "100",
|
|
84
|
+
height: "100",
|
|
85
|
+
viewBox: "0 0 100 100",
|
|
86
|
+
},
|
|
87
|
+
React.createElement("circle", {
|
|
88
|
+
className: "background",
|
|
89
|
+
cx: "0",
|
|
90
|
+
cy: "0",
|
|
91
|
+
}),
|
|
92
|
+
React.createElement("path", {
|
|
93
|
+
className: "line",
|
|
94
|
+
d: "M 37.5,50 C 37.5,43.096441 43.096441,37.5 50,37.5 C 56.903559,37.5 62.5,43.096441 62.5,50 C 62.5,56.903559 56.903559,62.5 50,62.5 C 43.096441,62.5 37.5,56.903559 37.5,50",
|
|
95
|
+
})
|
|
96
|
+
),
|
|
97
|
+
" ",
|
|
98
|
+
React.createElement(
|
|
99
|
+
"span",
|
|
100
|
+
{ style: { marginTop: -15 } },
|
|
101
|
+
"loading ..."
|
|
102
|
+
)
|
|
103
|
+
)
|
|
104
|
+
)
|
|
105
|
+
)
|
|
106
|
+
),
|
|
107
|
+
React.createElement("div", {
|
|
108
|
+
className: "opacity-25 fixed inset-0 z-40 bg-black",
|
|
109
|
+
})
|
|
110
|
+
)
|
|
111
|
+
);
|
|
52
112
|
};
|
|
53
|
-
//# sourceMappingURL=loader.component.js.map
|
|
113
|
+
//# sourceMappingURL=loader.component.js.map
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
/* eslint-disable testing-library/render-result-naming-convention */
|
|
2
|
-
import React from
|
|
3
|
-
import { render } from
|
|
4
|
-
import { Loader } from
|
|
5
|
-
it(
|
|
6
|
-
|
|
7
|
-
|
|
2
|
+
import React from "react";
|
|
3
|
+
import { render } from "@core-utils";
|
|
4
|
+
import { Loader } from "./loader.component";
|
|
5
|
+
it("render XB_Loader correctly", () => {
|
|
6
|
+
const loader = render(React.createElement(Loader, null));
|
|
7
|
+
expect(loader).toMatchSnapshot();
|
|
8
8
|
});
|
|
9
|
-
//# sourceMappingURL=loader.component.test.js.map
|
|
9
|
+
//# sourceMappingURL=loader.component.test.js.map
|
|
@@ -1,11 +1,15 @@
|
|
|
1
|
-
import React from
|
|
2
|
-
import { Loader } from
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { Loader } from "./loader.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/Loader",
|
|
6
|
+
component: Loader,
|
|
7
7
|
};
|
|
8
8
|
// More on component templates: https://storybook.js.org/docs/react/writing-stories/introduction#using-args
|
|
9
|
-
export const Primary = () =>
|
|
10
|
-
|
|
11
|
-
|
|
9
|
+
export const Primary = () =>
|
|
10
|
+
React.createElement(
|
|
11
|
+
"div",
|
|
12
|
+
{ className: "flex flex-row" },
|
|
13
|
+
React.createElement(Loader, null)
|
|
14
|
+
);
|
|
15
|
+
//# sourceMappingURL=loader.stories.js.map
|
|
@@ -1,8 +1,14 @@
|
|
|
1
|
-
import React from
|
|
2
|
-
import { ReactComponent as CheckedRadio } from
|
|
3
|
-
import { ReactComponent as UncheckRadio } from
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { ReactComponent as CheckedRadio } from "@assets/svg/checkedRadio.svg";
|
|
3
|
+
import { ReactComponent as UncheckRadio } from "@assets/svg/uncheckRadio.svg";
|
|
4
4
|
export const Radio = ({ className, checked, onChange }) => {
|
|
5
|
-
|
|
6
|
-
|
|
5
|
+
const width = 20;
|
|
6
|
+
return React.createElement(
|
|
7
|
+
"div",
|
|
8
|
+
{ className: `${className} flex flex-row mr-2`, onClick: onChange },
|
|
9
|
+
checked
|
|
10
|
+
? React.createElement(CheckedRadio, { width: width, height: width })
|
|
11
|
+
: React.createElement(UncheckRadio, { width: width, height: width })
|
|
12
|
+
);
|
|
7
13
|
};
|
|
8
|
-
//# sourceMappingURL=radio.component.js.map
|
|
14
|
+
//# sourceMappingURL=radio.component.js.map
|
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
/* eslint-disable testing-library/render-result-naming-convention */
|
|
2
|
-
import React from
|
|
3
|
-
import { render } from
|
|
4
|
-
import { Radio } from
|
|
5
|
-
it(
|
|
6
|
-
|
|
7
|
-
|
|
2
|
+
import React from "react";
|
|
3
|
+
import { render } from "@core-utils";
|
|
4
|
+
import { Radio } from "./radio.component";
|
|
5
|
+
it("render XB_Radio correctly", () => {
|
|
6
|
+
const radio = render(
|
|
7
|
+
React.createElement(Radio, { checked: true, onChange: () => jest.fn() })
|
|
8
|
+
);
|
|
9
|
+
expect(radio).toMatchSnapshot();
|
|
8
10
|
});
|
|
9
|
-
//# sourceMappingURL=radio.component.test.js.map
|
|
11
|
+
//# sourceMappingURL=radio.component.test.js.map
|
|
@@ -1,13 +1,20 @@
|
|
|
1
|
-
import React from
|
|
2
|
-
import { Radio } from
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { Radio } from "./radio.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/Radio",
|
|
6
|
+
component: Radio,
|
|
7
7
|
};
|
|
8
8
|
// More on component templates: https://storybook.js.org/docs/react/writing-stories/introduction#using-args
|
|
9
|
-
export const Primary = () =>
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
9
|
+
export const Primary = () =>
|
|
10
|
+
React.createElement(
|
|
11
|
+
React.Fragment,
|
|
12
|
+
null,
|
|
13
|
+
React.createElement(
|
|
14
|
+
"div",
|
|
15
|
+
{ className: "flex flex-row" },
|
|
16
|
+
React.createElement(Radio, { checked: true, onChange: () => {} }),
|
|
17
|
+
React.createElement("span", null, "Married")
|
|
18
|
+
)
|
|
19
|
+
);
|
|
20
|
+
//# sourceMappingURL=radio.stories.js.map
|
|
@@ -1,35 +1,77 @@
|
|
|
1
|
-
import React from
|
|
2
|
-
export const Stepper = ({
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
1
|
+
import React from "react";
|
|
2
|
+
export const Stepper = ({
|
|
3
|
+
className = "",
|
|
4
|
+
steps,
|
|
5
|
+
currentStep = 1,
|
|
6
|
+
onStepClick,
|
|
7
|
+
}) => {
|
|
8
|
+
const finalClass = `${className} w-full px-4 sm:px-8`;
|
|
9
|
+
const progressClass =
|
|
10
|
+
"absolute my-4 top-1/2 left-0 h-0.5 transform -translate-y-1/2 bg-orange transition-width ease-in-out duration-500";
|
|
11
|
+
const Steps =
|
|
12
|
+
steps === null || steps === void 0
|
|
13
|
+
? void 0
|
|
14
|
+
: steps.map((step, index) => {
|
|
15
|
+
let stepClass =
|
|
16
|
+
"inline-block transform -translate-x-1/2 pt-1 w-8 h-8 rounded-full text-center";
|
|
17
|
+
if (index < currentStep)
|
|
8
18
|
stepClass +=
|
|
9
|
-
|
|
10
|
-
|
|
19
|
+
" font-medium border border-orange bg-background-secondary text-gray";
|
|
20
|
+
else if (index > currentStep)
|
|
11
21
|
stepClass +=
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
stepClass +=
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
22
|
+
" font-medium border border-gray-dark-secondary text-gray bg-background-secondary";
|
|
23
|
+
else if (currentStep === index)
|
|
24
|
+
stepClass += " font-medium bg-orange text-white";
|
|
25
|
+
if (typeof onStepClick === "function") stepClass += " cursor-pointer";
|
|
26
|
+
return React.createElement(
|
|
27
|
+
"div",
|
|
28
|
+
{
|
|
29
|
+
key: step,
|
|
30
|
+
style: { left: `${(index / (steps.length - 1)) * 100}%` },
|
|
31
|
+
className: "absolute",
|
|
32
|
+
},
|
|
33
|
+
React.createElement(
|
|
34
|
+
"span",
|
|
35
|
+
{
|
|
36
|
+
className: `${stepClass} font-nunitoSansRegular text-4xs text-center`,
|
|
37
|
+
onClick: () => {
|
|
38
|
+
if (typeof onStepClick === "function")
|
|
39
|
+
onStepClick(index + 1, step);
|
|
40
|
+
},
|
|
41
|
+
},
|
|
42
|
+
step
|
|
43
|
+
)
|
|
44
|
+
);
|
|
45
|
+
});
|
|
46
|
+
return React.createElement(
|
|
47
|
+
"div",
|
|
48
|
+
{ className: finalClass },
|
|
49
|
+
React.createElement(
|
|
50
|
+
"div",
|
|
51
|
+
{ className: "w-full relative" },
|
|
52
|
+
React.createElement(
|
|
53
|
+
"div",
|
|
54
|
+
{
|
|
55
|
+
className: progressClass,
|
|
56
|
+
style: {
|
|
57
|
+
width: `${(currentStep / (steps.length - 1)) * 100}%`,
|
|
58
|
+
},
|
|
59
|
+
},
|
|
60
|
+
React.createElement("div", {
|
|
61
|
+
className:
|
|
62
|
+
"w-3 h-3 bg-orange rounded-full absolute right-0 top-1/2 transform translate-x-1/2 -translate-y-1/2",
|
|
63
|
+
})
|
|
64
|
+
),
|
|
65
|
+
React.createElement("div", {
|
|
66
|
+
className:
|
|
67
|
+
"absolute h-0.5 my-4 top-1/2 left-0 transform -translate-y-1/2 bg-gray-dark-secondary transition-width ease-in-out duration-500",
|
|
68
|
+
style: {
|
|
69
|
+
marginLeft: `${(currentStep / (steps.length - 1)) * 100}%`,
|
|
70
|
+
width: `${100 - (currentStep / (steps.length - 1)) * 100}%`,
|
|
71
|
+
},
|
|
72
|
+
})
|
|
73
|
+
),
|
|
74
|
+
React.createElement("div", { className: "relative sm:block" }, Steps)
|
|
75
|
+
);
|
|
34
76
|
};
|
|
35
|
-
//# sourceMappingURL=stepper.component.js.map
|
|
77
|
+
//# sourceMappingURL=stepper.component.js.map
|
|
@@ -1,8 +1,15 @@
|
|
|
1
|
-
import React from
|
|
2
|
-
import { render } from
|
|
3
|
-
import { Stepper } from
|
|
4
|
-
it(
|
|
5
|
-
|
|
6
|
-
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { render } from "@core-utils";
|
|
3
|
+
import { Stepper } from "./stepper.component";
|
|
4
|
+
it("render XB_Stepper correctly", () => {
|
|
5
|
+
const stepper = render(
|
|
6
|
+
React.createElement(Stepper, {
|
|
7
|
+
steps: ["1", "2", "3", "4"],
|
|
8
|
+
currentStep: 3,
|
|
9
|
+
onStepClick: () => jest.fn(),
|
|
10
|
+
className: "mt-4",
|
|
11
|
+
})
|
|
12
|
+
);
|
|
13
|
+
expect(stepper).toMatchSnapshot();
|
|
7
14
|
});
|
|
8
|
-
//# sourceMappingURL=stepper.component.test.js.map
|
|
15
|
+
//# sourceMappingURL=stepper.component.test.js.map
|
|
@@ -1,12 +1,18 @@
|
|
|
1
1
|
/* eslint-disable @typescript-eslint/no-unused-vars */
|
|
2
2
|
/* eslint-disable react/jsx-indent-props */
|
|
3
|
-
import React from
|
|
4
|
-
import { Stepper } from
|
|
3
|
+
import React from "react";
|
|
4
|
+
import { Stepper } from "./stepper.component";
|
|
5
5
|
// More on default export: https://storybook.js.org/docs/react/writing-stories/introduction#default-export
|
|
6
6
|
export default {
|
|
7
|
-
|
|
8
|
-
|
|
7
|
+
title: "Atoms/Stepper",
|
|
8
|
+
component: Stepper,
|
|
9
9
|
};
|
|
10
10
|
// More on component templates: https://storybook.js.org/docs/react/writing-stories/introduction#using-args
|
|
11
|
-
export const Primary = () =>
|
|
12
|
-
|
|
11
|
+
export const Primary = () =>
|
|
12
|
+
React.createElement(Stepper, {
|
|
13
|
+
steps: ["1", "2", "3", "4"],
|
|
14
|
+
currentStep: 2,
|
|
15
|
+
onStepClick: (currentStep, step) => {},
|
|
16
|
+
className: "mt-4",
|
|
17
|
+
});
|
|
18
|
+
//# sourceMappingURL=stepper.stories.js.map
|