sprint-asia-custom-component 0.1.181 → 0.1.183

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/dist/index.js CHANGED
@@ -29092,50 +29092,60 @@
29092
29092
 
29093
29093
  var img$7 = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADYAAAA2CAYAAACMRWrdAAAACXBIWXMAAAsTAAALEwEAmpwYAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAARGSURBVHgB1ZpRbttGEIb/ofRgoyniG5S5gdwoQJWgKJULJD1B5RPEN7B1A/cEVU5Q9wIWjSBWASe1blD2BHWAIMmDxMnM0rQpiqQocRmL34vEpZbe37M7uzNDQg1ceZ29z2h5Idh1QC7BeZi8zwg/yL2A4UwfYDbd96fXsAzBEm+8rtcCvyTCC3msi7XgQNT6M9Drn/13PixQSZha5gvar5j4kEB7sEIkEpgPe/40wIZsJKweQRkwjzYVuLawC697COKjWgUtwEHIPHzm/zNap1dpYTdW+lN6eLgP1rReKWETr+OCWuP1nYJtdP3N+2XErRT21ut0SER9u6lXDAPXzNR/5l9Oi35XKGzbRMWUEZcrTKcfU+tq20TFqDji2X7etHSyGuM1ta2iFLHIno5RnVrW/UxhjNbx/TuKMpBrPHUGS8Leej8OiOg3NAXZfszeutScYHvc+nroetvl2aPkYdpZ/EFTpuAiut4+oX2YaouIrNX+Fw0lbTXn7oZaq7mkrXYrTOKoX9BwRMOr+LsRNpEg0craIgxDDg+YcFq2i0yhc9NHgkxURK32xmgB2tHDeUBVg2miUe/s8vjmanTRfzySZxZuG/J3Xz8dvx/EfSbPuxpkHqECGsXLh+9EY6o+DcNwfp681gHrwPN+nxJ184wwQEWi1IRMReMNQS4q4sBZsk6euCxRZlAOvUBlyNVjllis7cIGcgKYPH/8R7o5LS5PlPYlppewgGbIHFm8HdiCaVAkrkiU9oU1yBXnwa7FLFwsDr2z9wfJ5ixBin1RZhCSz4RjPzTJsVyaekSpmZyHDupihbi6RMXUJwyaWMqf40X3bFCbsDxHEbNqn6uKCAutFwRWiYqpS5wWPUQYBbBIkUsvs8/ZgQLHJCEtsXKfWrHPwRJzYOrsYu7DAnqiL7X5FoiTDx8W0JqboxGn/Lf+Q0U4DP9Kt+W69BxxEr5YsBoFqinyilw+fsrHcZNXK/epDHES5nioCkVWN3uJCTQJY1RFKiJSgj03J/2SVRmdwmpt6fOD9DlGRWaMvlZFbzfJi373f5NdbTQU9MaXj/RbMufxO5oO3TmfW2E74exEU1hoMmFrGH+9FaaepNFW05yL/3cQXy6cFZtrNTk9JaylLAgz/p8xRNOQMSetpWSGDpN+V12/hyYQpf0O0s2ZYcsOz361fTiuh+UpGJMpzCT2udXf5vVmxiZjTE/BmNxAUztoAXsbxcXF9TxRSonXIZ50iHi8LacSK69DxEy8n6R2Nh9Hqbr7RNZUwfRLUirnYR5k1lz1isimaFVmh7/bLyNKWTtTNPGeDKTX0beynlnjUp56evbuZJ1+G6XAdGoyzY8JXNvbBeYFFTni7YQPTvZ9f20HVim3dydQy1B2LFhVUIy1pKUGq0w02ESkSU2wcyoz4LS3Da/O5nHleXtf8LETVXLIxfJWcR1lxzjYxfd+Fcvk8RW++zEUFiaVEwAAAABJRU5ErkJggg==";
29094
29094
 
29095
- const ModalResult = props => {
29096
- const cancelButtonRef = React.useRef(null);
29097
- function handleBackgroundClick(e) {
29098
- e.stopPropagation();
29099
- }
29100
- return /*#__PURE__*/React__default["default"].createElement(qe.Root, {
29101
- show: props.isOpen,
29102
- as: React.Fragment
29103
- }, /*#__PURE__*/React__default["default"].createElement(_t, {
29104
- as: "div",
29105
- className: "relative",
29106
- initialFocus: cancelButtonRef,
29107
- onClose: () => props.onClose(),
29108
- static: true,
29095
+ const Modal = ({
29096
+ open,
29097
+ onClose = () => {},
29098
+ children
29099
+ }) => {
29100
+ const [visible, setVisible] = React.useState(open);
29101
+ const [animate, setAnimate] = React.useState(false);
29102
+ React.useEffect(() => {
29103
+ if (open) {
29104
+ setVisible(true);
29105
+ requestAnimationFrame(() => setAnimate(true));
29106
+ document.body.style.overflow = "hidden";
29107
+ } else {
29108
+ setAnimate(false);
29109
+ const t = setTimeout(() => setVisible(false), 200);
29110
+ document.body.style.overflow = "";
29111
+ return () => clearTimeout(t);
29112
+ }
29113
+ }, [open]);
29114
+ if (!visible) return null;
29115
+ const modalRoot = document.getElementById("modal-root");
29116
+ if (!modalRoot) return null;
29117
+ return /*#__PURE__*/reactDomExports.createPortal( /*#__PURE__*/React__default["default"].createElement("div", {
29118
+ className: "fixed inset-0",
29109
29119
  style: {
29110
29120
  zIndex: 1001
29111
- }
29112
- }, /*#__PURE__*/React__default["default"].createElement(qe.Child, {
29113
- as: React.Fragment,
29114
- enter: "ease-out duration-300",
29115
- enterFrom: "opacity-0",
29116
- enterTo: "opacity-100",
29117
- leave: "ease-in duration-200",
29118
- leaveFrom: "opacity-100",
29119
- leaveTo: "opacity-0"
29121
+ },
29122
+ onClick: onClose
29120
29123
  }, /*#__PURE__*/React__default["default"].createElement("div", {
29121
- className: "fixed inset-0 bg-black bg-opacity-25 transition-opacity",
29122
- onClick: handleBackgroundClick
29123
- })), /*#__PURE__*/React__default["default"].createElement("div", {
29124
- className: "fixed inset-0 z-10 w-screen overflow-y-auto"
29124
+ className: `absolute inset-0 bg-black transition-opacity duration-200 ${animate ? "opacity-40" : "opacity-0"}`,
29125
+ onClick: onClose
29126
+ }), /*#__PURE__*/React__default["default"].createElement("div", {
29127
+ className: "relative z-10 h-full overflow-y-auto"
29128
+ }, /*#__PURE__*/React__default["default"].createElement("div", {
29129
+ className: "min-h-full flex items-center justify-center p-4 sm:p-8"
29130
+ }, /*#__PURE__*/React__default["default"].createElement("div", {
29131
+ className: `
29132
+ inline-block
29133
+ bg-white rounded-lg shadow-xl
29134
+ transform transition-all duration-200
29135
+ ${animate ? "opacity-100 scale-100" : "opacity-0 scale-95"}
29136
+ `,
29137
+ onClick: e => e.stopPropagation()
29138
+ }, children)))), modalRoot);
29139
+ };
29140
+
29141
+ const ModalResult = props => {
29142
+ return /*#__PURE__*/React__default["default"].createElement(Modal, {
29143
+ open: props.isOpen,
29144
+ onClose: props.onClose
29125
29145
  }, /*#__PURE__*/React__default["default"].createElement("div", {
29126
- className: "flex min-h-full items-center justify-center p-4 text-center sm:items-center sm:p-0"
29127
- }, /*#__PURE__*/React__default["default"].createElement(qe.Child, {
29128
- as: React.Fragment,
29129
- enter: "ease-out duration-300",
29130
- enterFrom: "opacity-0 translate-y-4 sm:translate-y-0 sm:scale-95",
29131
- enterTo: "opacity-100 translate-y-0 sm:scale-100",
29132
- leave: "ease-in duration-200",
29133
- leaveFrom: "opacity-100 translate-y-0 sm:scale-100",
29134
- leaveTo: "opacity-0 translate-y-4 sm:translate-y-0 sm:scale-95"
29135
- }, /*#__PURE__*/React__default["default"].createElement(_t.Panel, {
29136
29146
  className: "relative transform overflow-hidden rounded-lg bg-white text-left shadow-xl transition-all w-80"
29137
29147
  }, /*#__PURE__*/React__default["default"].createElement("div", {
29138
- className: "bg-white px-4 pb-4 pt-5 sm:p-4 text-center"
29148
+ className: "bg-white px-4 pb-4 pt-4 sm:p-4 text-center"
29139
29149
  }, /*#__PURE__*/React__default["default"].createElement("div", {
29140
29150
  className: "flex justify-center items-center my-3"
29141
29151
  }, props.type == "success" ? /*#__PURE__*/React__default["default"].createElement("img", {
@@ -29148,7 +29158,7 @@
29148
29158
  className: "text-xl text-black font-semibold mt-2"
29149
29159
  }, props.type == "success" ? "Success" : "Failed"), /*#__PURE__*/React__default["default"].createElement("p", {
29150
29160
  className: "text-sm text-black mb-2"
29151
- }, props.subtitle))))))));
29161
+ }, props.subtitle))));
29152
29162
  };
29153
29163
 
29154
29164
  const formatNumber = val => {
@@ -45176,10 +45186,10 @@
45176
45186
  }
45177
45187
  };
45178
45188
  return /*#__PURE__*/React__default["default"].createElement("div", {
45179
- className: `relative inline-block ${checked ? 'bg-primary500' : 'bg-neutral40'} rounded-full w-12 h-6 transition-all duration-300 ${isEdit ? "cursor-pointer" : "cursor-default"}`,
45189
+ className: `relative inline-block ${checked ? "bg-primary500" : "bg-neutral40"} rounded-full w-12 h-6 transition-all duration-300 ${isEdit ? "cursor-pointer opacity-100" : "cursor-not-allowed opacity-50"}`,
45180
45190
  onClick: handleClick
45181
45191
  }, /*#__PURE__*/React__default["default"].createElement("div", {
45182
- className: `absolute flex items-center justify-center w-6 h-6 transition-all duration-300 ${checked ? 'right-0' : 'left-0'}`
45192
+ className: `absolute flex items-center justify-center w-6 h-6 transition-all duration-300 ${checked ? "right-0" : "left-0"}`
45183
45193
  }, /*#__PURE__*/React__default["default"].createElement("div", {
45184
45194
  className: `w-4 h-4 bg-white rounded-full shadow-md transition-all`
45185
45195
  })));
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "sprint-asia-custom-component",
3
3
  "main": "dist/index.js",
4
- "version": "0.1.181",
4
+ "version": "0.1.183",
5
5
  "private": false,
6
6
  "dependencies": {
7
7
  "@headlessui/react": "^1.7.18",
@@ -0,0 +1,57 @@
1
+ import React, { useEffect, useState } from "react";
2
+ import { createPortal } from "react-dom";
3
+
4
+ const Modal = ({ open, onClose = () => {}, children }) => {
5
+ const [visible, setVisible] = useState(open);
6
+ const [animate, setAnimate] = useState(false);
7
+
8
+ useEffect(() => {
9
+ if (open) {
10
+ setVisible(true);
11
+ requestAnimationFrame(() => setAnimate(true));
12
+ document.body.style.overflow = "hidden";
13
+ } else {
14
+ setAnimate(false);
15
+ const t = setTimeout(() => setVisible(false), 200);
16
+ document.body.style.overflow = "";
17
+ return () => clearTimeout(t);
18
+ }
19
+ }, [open]);
20
+
21
+ if (!visible) return null;
22
+
23
+ const modalRoot = document.getElementById("modal-root");
24
+ if (!modalRoot) return null;
25
+
26
+ return createPortal(
27
+ <div className="fixed inset-0" style={{ zIndex: 1001 }} onClick={onClose}>
28
+ {/* Backdrop */}
29
+ <div
30
+ className={`absolute inset-0 bg-black transition-opacity duration-200 ${animate ? "opacity-40" : "opacity-0"}`}
31
+ onClick={onClose}
32
+ />
33
+
34
+ {/* Scroll container (THIS scrolls) */}
35
+ <div className="relative z-10 h-full overflow-y-auto">
36
+ {/* Centering wrapper */}
37
+ <div className="min-h-full flex items-center justify-center p-4 sm:p-8">
38
+ {/* Modal panel */}
39
+ <div
40
+ className={`
41
+ inline-block
42
+ bg-white rounded-lg shadow-xl
43
+ transform transition-all duration-200
44
+ ${animate ? "opacity-100 scale-100" : "opacity-0 scale-95"}
45
+ `}
46
+ onClick={(e) => e.stopPropagation()}
47
+ >
48
+ {children}
49
+ </div>
50
+ </div>
51
+ </div>
52
+ </div>,
53
+ modalRoot
54
+ );
55
+ };
56
+
57
+ export default Modal;
@@ -1,70 +1,26 @@
1
1
  import React from "react";
2
- import { Fragment, useRef } from "react";
3
- import { Dialog, Transition } from "@headlessui/react";
4
2
  import LogoSuccess from "../../../assets/images/logo_success.png";
5
3
  import LogoFailed from "../../../assets/images/logo_failed.png";
4
+ import Modal from "../modal";
6
5
 
7
6
  const ModalResult = (props) => {
8
- const cancelButtonRef = useRef(null);
9
-
10
- function handleBackgroundClick(e) {
11
- e.stopPropagation();
12
- }
13
-
14
7
  return (
15
- <Transition.Root show={props.isOpen} as={Fragment}>
16
- <Dialog
17
- as="div"
18
- className="relative"
19
- initialFocus={cancelButtonRef}
20
- onClose={() => props.onClose()}
21
- static={true}
22
- style={{ zIndex: 1001 }}
23
- >
24
- <Transition.Child
25
- as={Fragment}
26
- enter="ease-out duration-300"
27
- enterFrom="opacity-0"
28
- enterTo="opacity-100"
29
- leave="ease-in duration-200"
30
- leaveFrom="opacity-100"
31
- leaveTo="opacity-0"
32
- >
33
- <div className="fixed inset-0 bg-black bg-opacity-25 transition-opacity" onClick={handleBackgroundClick} />
34
- </Transition.Child>
35
-
36
- <div className="fixed inset-0 z-10 w-screen overflow-y-auto">
37
- <div className="flex min-h-full items-center justify-center p-4 text-center sm:items-center sm:p-0">
38
- <Transition.Child
39
- as={Fragment}
40
- enter="ease-out duration-300"
41
- enterFrom="opacity-0 translate-y-4 sm:translate-y-0 sm:scale-95"
42
- enterTo="opacity-100 translate-y-0 sm:scale-100"
43
- leave="ease-in duration-200"
44
- leaveFrom="opacity-100 translate-y-0 sm:scale-100"
45
- leaveTo="opacity-0 translate-y-4 sm:translate-y-0 sm:scale-95"
46
- >
47
- <Dialog.Panel className="relative transform overflow-hidden rounded-lg bg-white text-left shadow-xl transition-all w-80">
48
- <div className="bg-white px-4 pb-4 pt-5 sm:p-4 text-center">
49
- <div className="flex justify-center items-center my-3">
50
- {props.type == "success" ? (
51
- <img src={LogoSuccess} className="w-14 h-14" />
52
- ) : (
53
- <img src={LogoFailed} className="w-14 h-14" />
54
- )}
55
- </div>
56
- <p className="text-xl text-black font-semibold mt-2">
57
- {props.type == "success" ? "Success" : "Failed"}
58
- </p>
59
- <p className="text-sm text-black mb-2">{props.subtitle}</p>
60
- </div>
61
- </Dialog.Panel>
62
- </Transition.Child>
8
+ <Modal open={props.isOpen} onClose={props.onClose}>
9
+ <div className="relative transform overflow-hidden rounded-lg bg-white text-left shadow-xl transition-all w-80">
10
+ <div className="bg-white px-4 pb-4 pt-4 sm:p-4 text-center">
11
+ <div className="flex justify-center items-center my-3">
12
+ {props.type == "success" ? (
13
+ <img src={LogoSuccess} className="w-14 h-14" />
14
+ ) : (
15
+ <img src={LogoFailed} className="w-14 h-14" />
16
+ )}
63
17
  </div>
18
+ <p className="text-xl text-black font-semibold mt-2">{props.type == "success" ? "Success" : "Failed"}</p>
19
+ <p className="text-sm text-black mb-2">{props.subtitle}</p>
64
20
  </div>
65
- </Dialog>
66
- </Transition.Root>
21
+ </div>
22
+ </Modal>
67
23
  );
68
24
  };
69
25
 
70
- export default ModalResult;
26
+ export default ModalResult;
@@ -1,4 +1,4 @@
1
- import React from 'react';
1
+ import React from "react";
2
2
 
3
3
  const Switch = ({ onChange, checked, isEdit }) => {
4
4
  const handleClick = () => {
@@ -9,12 +9,17 @@ const Switch = ({ onChange, checked, isEdit }) => {
9
9
 
10
10
  return (
11
11
  <div
12
- className={`relative inline-block ${checked ? 'bg-primary500' : 'bg-neutral40'} rounded-full w-12 h-6 transition-all duration-300 ${isEdit ? "cursor-pointer" : "cursor-default"}`}
12
+ className={`relative inline-block ${
13
+ checked ? "bg-primary500" : "bg-neutral40"
14
+ } rounded-full w-12 h-6 transition-all duration-300 ${
15
+ isEdit ? "cursor-pointer opacity-100" : "cursor-not-allowed opacity-50"
16
+ }`}
13
17
  onClick={handleClick}
14
18
  >
15
19
  <div
16
20
  className={`absolute flex items-center justify-center w-6 h-6 transition-all duration-300 ${
17
- checked ? 'right-0' : 'left-0'}`}
21
+ checked ? "right-0" : "left-0"
22
+ }`}
18
23
  >
19
24
  <div className={`w-4 h-4 bg-white rounded-full shadow-md transition-all`}></div>
20
25
  </div>
@@ -22,4 +27,4 @@ const Switch = ({ onChange, checked, isEdit }) => {
22
27
  );
23
28
  };
24
29
 
25
- export default Switch;
30
+ export default Switch;