sprint-asia-custom-component 0.1.180 → 0.1.182

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 => {
@@ -29226,7 +29236,7 @@
29226
29236
  max: maximum !== null && maximum !== undefined && type === "number" ? maximum : undefined,
29227
29237
  type: type === "password" ? showPassword ? "text" : "password" : "text" // number tetap text
29228
29238
  ,
29229
- className: `py-2.5 px-3 w-full font-normal text-sm text-black rounded-md border
29239
+ className: `py-2.5 w-full font-normal text-sm text-black rounded-md border
29230
29240
  ${!value && mode === "default" && "bg-neutral20 border-neutral50 focus:outline-2 outline-primary500"}
29231
29241
  ${value && mode === "default" && "bg-neutral20 border-black focus:outline-2 outline-primary500"}
29232
29242
  ${isFocused && mode === "default" && "bg-neutral20 border-primary500"}
@@ -29237,6 +29247,10 @@
29237
29247
  ${leftIcon && leftAdornment ? "pl-16" : "pl-3"}
29238
29248
  ${rightIcon || rightAdornment ? "pr-8" : "pr-3"}
29239
29249
  ${rightIcon && rightAdornment ? "pr-16" : "pr-3"}`,
29250
+ style: {
29251
+ paddingLeft: leftAdornment || leftIcon ? "2rem" : "0.75rem",
29252
+ paddingRight: rightAdornment || rightIcon ? "2rem" : "0.75rem"
29253
+ },
29240
29254
  placeholder: placeholder,
29241
29255
  disabled: mode === "disable",
29242
29256
  value: displayValue,
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.180",
4
+ "version": "0.1.182",
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;
@@ -53,8 +53,7 @@ const TextInput = ({
53
53
  onChangeInput(e);
54
54
  };
55
55
 
56
- const displayValue =
57
- type === "number" ? (value ? formatNumber(value) : "") : value;
56
+ const displayValue = type === "number" ? (value ? formatNumber(value) : "") : value;
58
57
 
59
58
  return (
60
59
  <div className={`w-full ${className}`}>
@@ -62,9 +61,7 @@ const TextInput = ({
62
61
  {title && (
63
62
  <div className="flex">
64
63
  <p className="text-sm font-normal text-black mb-1">{title}</p>
65
- {isRequired && (
66
- <p className="text-sm font-normal text-danger500 ml-1">*</p>
67
- )}
64
+ {isRequired && <p className="text-sm font-normal text-danger500 ml-1">*</p>}
68
65
  </div>
69
66
  )}
70
67
  {rightComponent}
@@ -86,41 +83,24 @@ const TextInput = ({
86
83
  </section>
87
84
 
88
85
  <input
89
- min={
90
- minimum !== null && minimum !== undefined && type === "number"
91
- ? minimum
92
- : undefined
93
- }
94
- max={
95
- maximum !== null && maximum !== undefined && type === "number"
96
- ? maximum
97
- : undefined
98
- }
99
- type={
100
- type === "password" ? (showPassword ? "text" : "password") : "text"
101
- } // number tetap text
102
- className={`py-2.5 px-3 w-full font-normal text-sm text-black rounded-md border
103
- ${
104
- !value &&
105
- mode === "default" &&
106
- "bg-neutral20 border-neutral50 focus:outline-2 outline-primary500"
107
- }
108
- ${
109
- value &&
110
- mode === "default" &&
111
- "bg-neutral20 border-black focus:outline-2 outline-primary500"
112
- }
86
+ min={minimum !== null && minimum !== undefined && type === "number" ? minimum : undefined}
87
+ max={maximum !== null && maximum !== undefined && type === "number" ? maximum : undefined}
88
+ type={type === "password" ? (showPassword ? "text" : "password") : "text"} // number tetap text
89
+ className={`py-2.5 w-full font-normal text-sm text-black rounded-md border
90
+ ${!value && mode === "default" && "bg-neutral20 border-neutral50 focus:outline-2 outline-primary500"}
91
+ ${value && mode === "default" && "bg-neutral20 border-black focus:outline-2 outline-primary500"}
113
92
  ${isFocused && mode === "default" && "bg-neutral20 border-primary500"}
114
93
  ${mode === "disable" && "bg-neutral30 border-neutral50"}
115
94
  ${mode === "white" && "bg-white border-neutral50"}
116
- ${
117
- mode === "danger" &&
118
- "bg-danger50 border-danger500 focus:outline-2 outline-danger500"
119
- }
95
+ ${mode === "danger" && "bg-danger50 border-danger500 focus:outline-2 outline-danger500"}
120
96
  ${leftIcon || leftAdornment ? "pl-8" : "pl-3"}
121
97
  ${leftIcon && leftAdornment ? "pl-16" : "pl-3"}
122
98
  ${rightIcon || rightAdornment ? "pr-8" : "pr-3"}
123
99
  ${rightIcon && rightAdornment ? "pr-16" : "pr-3"}`}
100
+ style={{
101
+ paddingLeft: leftAdornment || leftIcon ? "2rem" : "0.75rem",
102
+ paddingRight: rightAdornment || rightIcon ? "2rem" : "0.75rem",
103
+ }}
124
104
  placeholder={placeholder}
125
105
  disabled={mode === "disable"}
126
106
  value={displayValue}
@@ -135,19 +115,9 @@ const TextInput = ({
135
115
  onClick={handleTogglePasswordVisibility}
136
116
  >
137
117
  {showPassword ? (
138
- <PiEye
139
- size={16}
140
- className={`text-black ${
141
- mode === "danger" && "text-danger500"
142
- }`}
143
- />
118
+ <PiEye size={16} className={`text-black ${mode === "danger" && "text-danger500"}`} />
144
119
  ) : (
145
- <PiEyeClosedLight
146
- size={16}
147
- className={`text-black ${
148
- mode === "danger" && "text-danger500"
149
- }`}
150
- />
120
+ <PiEyeClosedLight size={16} className={`text-black ${mode === "danger" && "text-danger500"}`} />
151
121
  )}
152
122
  </span>
153
123
  )}
@@ -185,4 +155,4 @@ const TextInput = ({
185
155
  );
186
156
  };
187
157
 
188
- export default TextInput;
158
+ export default TextInput;