sprint-asia-custom-component 0.1.166 → 0.1.168

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
@@ -26028,7 +26028,7 @@
26028
26028
  if (file.errors[0]?.code === "file-too-large") {
26029
26029
  setErrorMessage("Your file is too large. Max file size is 5 MB");
26030
26030
  } else if (file.errors[0]?.code === "file-invalid-type") {
26031
- setErrorMessage(excelAcceptedFiles ? "File format not supported. Please try again with XLSX, XLS, CSV, or TSV file within 5 MB" : "File format not supported. Please try again with PNG, JPEG, JPG, or PDF file within 5 MB");
26031
+ setErrorMessage(excelAcceptedFiles ? "File format not supported. Please try again with XLSX, CSV, or TXT file" : "File format not supported. Please try again with PNG, JPEG, JPG, or PDF file");
26032
26032
  }
26033
26033
  };
26034
26034
 
@@ -26039,12 +26039,12 @@
26039
26039
  "application/pdf": [".pdf"]
26040
26040
  };
26041
26041
 
26042
- // Additional file types
26042
+ // Additional file types (updated: remove .tsv, add .txt)
26043
26043
  const excelAcceptedFiles = {
26044
26044
  "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet": [".xlsx"],
26045
26045
  "application/vnd.ms-excel": [".xls"],
26046
26046
  "text/csv": [".csv"],
26047
- "text/tab-separated-values": [".tsv"]
26047
+ "text/plain": [".txt"] // ✅ ganti dari .tsv ke .txt
26048
26048
  };
26049
26049
  const {
26050
26050
  getRootProps,
@@ -29145,6 +29145,14 @@
29145
29145
  }, props.subtitle))))))));
29146
29146
  };
29147
29147
 
29148
+ const formatNumber = val => {
29149
+ if (!val) return "";
29150
+ return val.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ".");
29151
+ };
29152
+ const parseNumber = val => {
29153
+ if (!val) return "";
29154
+ return val.replace(/\./g, ""); // hapus titik biar jadi angka murni
29155
+ };
29148
29156
  const TextInput = ({
29149
29157
  title = "",
29150
29158
  rightComponent = null,
@@ -29165,15 +29173,27 @@
29165
29173
  }) => {
29166
29174
  const [isFocused, setIsFocused] = React.useState(false);
29167
29175
  const [showPassword, setShowPassword] = React.useState(false);
29168
- const handleFocus = () => {
29169
- setIsFocused(true);
29170
- };
29171
- const handleBlur = () => {
29172
- setIsFocused(false);
29173
- };
29174
- const handleTogglePasswordVisibility = () => {
29175
- setShowPassword(!showPassword);
29176
+ const handleFocus = () => setIsFocused(true);
29177
+ const handleBlur = () => setIsFocused(false);
29178
+ const handleTogglePasswordVisibility = () => setShowPassword(!showPassword);
29179
+ const handleChange = e => {
29180
+ let val = e.target.value;
29181
+ if (type === "number") {
29182
+ // hapus semua karakter non digit
29183
+ const raw = parseNumber(val.replace(/\D/g, ""));
29184
+ // kirim angka murni ke parent
29185
+ onChangeInput({
29186
+ ...e,
29187
+ target: {
29188
+ ...e.target,
29189
+ value: raw
29190
+ }
29191
+ });
29192
+ return;
29193
+ }
29194
+ onChangeInput(e);
29176
29195
  };
29196
+ const displayValue = type === "number" ? value ? formatNumber(value) : "" : value;
29177
29197
  return /*#__PURE__*/React__default["default"].createElement("div", {
29178
29198
  className: `w-full ${className}`
29179
29199
  }, /*#__PURE__*/React__default["default"].createElement("div", {
@@ -29194,27 +29214,27 @@
29194
29214
  ${mode === "primary" && "text-black"}
29195
29215
  ${mode === "disable" && "text-neutral50"}
29196
29216
  ${mode === "danger" && "text-danger500"}
29197
- `
29217
+ `
29198
29218
  })), /*#__PURE__*/React__default["default"].createElement("input", {
29199
29219
  min: minimum !== null && minimum !== undefined && type === "number" ? minimum : undefined,
29200
29220
  max: maximum !== null && maximum !== undefined && type === "number" ? maximum : undefined,
29201
- type: type === "password" ? showPassword ? "text" : "password" : type,
29221
+ type: type === "password" ? showPassword ? "text" : "password" : "text" // number tetap text
29222
+ ,
29202
29223
  className: `py-2.5 px-4 w-full font-normal text-sm text-black rounded-md border
29203
- ${!value && mode === "default" && "bg-neutral20 border-neutral50 focus:outline-2 outline-primary500"}
29204
- ${value && mode === "default" && "bg-neutral20 border-black focus:outline-2 outline-primary500"}
29205
- ${isFocused && mode === "default" && "bg-neutral20 border-primary500"}
29206
- ${mode === "disable" && "bg-neutral30 border-neutral50"}
29207
- ${mode === "white" && "bg-white border-neutral50"}
29208
- ${mode === "danger" && "bg-danger50 border-danger500 focus:outline-2 outline-danger500"}
29209
- ${leftIcon || leftAdornment ? "pl-8" : "pl-3"}
29210
- ${leftIcon && leftAdornment ? "pl-16" : "pl-3"}
29211
- ${rightIcon || rightAdornment ? "pr-8" : "pr-3"}
29212
- ${rightIcon && rightAdornment ? "pr-16" : "pr-3"}`,
29224
+ ${!value && mode === "default" && "bg-neutral20 border-neutral50 focus:outline-2 outline-primary500"}
29225
+ ${value && mode === "default" && "bg-neutral20 border-black focus:outline-2 outline-primary500"}
29226
+ ${isFocused && mode === "default" && "bg-neutral20 border-primary500"}
29227
+ ${mode === "disable" && "bg-neutral30 border-neutral50"}
29228
+ ${mode === "white" && "bg-white border-neutral50"}
29229
+ ${mode === "danger" && "bg-danger50 border-danger500 focus:outline-2 outline-danger500"}
29230
+ ${leftIcon || leftAdornment ? "pl-8" : "pl-3"}
29231
+ ${leftIcon && leftAdornment ? "pl-16" : "pl-3"}
29232
+ ${rightIcon || rightAdornment ? "pr-8" : "pr-3"}
29233
+ ${rightIcon && rightAdornment ? "pr-16" : "pr-3"}`,
29213
29234
  placeholder: placeholder,
29214
- "data-mask": "000.000.000-00",
29215
29235
  disabled: mode === "disable",
29216
- value: value,
29217
- onChange: onChangeInput,
29236
+ value: displayValue,
29237
+ onChange: handleChange,
29218
29238
  onFocus: handleFocus,
29219
29239
  onBlur: handleBlur
29220
29240
  }), type === "password" && /*#__PURE__*/React__default["default"].createElement("span", {
@@ -29234,7 +29254,7 @@
29234
29254
  ${mode === "primary" && "text-neutral50"}
29235
29255
  ${mode === "disable" && "text-neutral50"}
29236
29256
  ${mode === "danger" && "text-danger500"}
29237
- `
29257
+ `
29238
29258
  }))), footer && /*#__PURE__*/React__default["default"].createElement("div", {
29239
29259
  className: "mt-1"
29240
29260
  }, mode === "danger" ? /*#__PURE__*/React__default["default"].createElement("div", {
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.166",
4
+ "version": "0.1.168",
5
5
  "private": false,
6
6
  "dependencies": {
7
7
  "@headlessui/react": "^1.7.18",
@@ -23,8 +23,8 @@ const DropzoneUploadFile = ({
23
23
  } else if (file.errors[0]?.code === "file-invalid-type") {
24
24
  setErrorMessage(
25
25
  excelAcceptedFiles
26
- ? "File format not supported. Please try again with XLSX, XLS, CSV, or TSV file within 5 MB"
27
- : "File format not supported. Please try again with PNG, JPEG, JPG, or PDF file within 5 MB"
26
+ ? "File format not supported. Please try again with XLSX, CSV, or TXT file"
27
+ : "File format not supported. Please try again with PNG, JPEG, JPG, or PDF file"
28
28
  );
29
29
  }
30
30
  };
@@ -36,12 +36,12 @@ const DropzoneUploadFile = ({
36
36
  "application/pdf": [".pdf"],
37
37
  };
38
38
 
39
- // Additional file types
39
+ // Additional file types (updated: remove .tsv, add .txt)
40
40
  const excelAcceptedFiles = {
41
41
  "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet": [".xlsx"],
42
42
  "application/vnd.ms-excel": [".xls"],
43
43
  "text/csv": [".csv"],
44
- "text/tab-separated-values": [".tsv"],
44
+ "text/plain": [".txt"], // ✅ ganti dari .tsv ke .txt
45
45
  };
46
46
 
47
47
  const { getRootProps, getInputProps } = useDropzone({
@@ -75,7 +75,9 @@ const DropzoneUploadFile = ({
75
75
  <div className="flex justify-center">
76
76
  <PiFileArrowUpDuotone size={16} className="text-neutral300" />
77
77
  </div>
78
- <p className="text-sm text-neutral300 mt-2">Drag & Drop File Here or Chose File</p>
78
+ <p className="text-sm text-neutral300 mt-2">
79
+ Drag & Drop File Here or Chose File
80
+ </p>
79
81
  {errorMessage && <p className="text-xs text-danger500">{errorMessage}</p>}
80
82
  </>
81
83
  ) : (
@@ -96,4 +98,4 @@ const DropzoneUploadFile = ({
96
98
  );
97
99
  };
98
100
 
99
- export default DropzoneUploadFile;
101
+ export default DropzoneUploadFile;
@@ -1,6 +1,16 @@
1
1
  import React, { useState } from "react";
2
2
  import { PiEyeClosedLight, PiEye, PiInfo } from "react-icons/pi";
3
3
 
4
+ const formatNumber = (val) => {
5
+ if (!val) return "";
6
+ return val.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ".");
7
+ };
8
+
9
+ const parseNumber = (val) => {
10
+ if (!val) return "";
11
+ return val.replace(/\./g, ""); // hapus titik biar jadi angka murni
12
+ };
13
+
4
14
  const TextInput = ({
5
15
  title = "",
6
16
  rightComponent = null,
@@ -22,25 +32,39 @@ const TextInput = ({
22
32
  const [isFocused, setIsFocused] = useState(false);
23
33
  const [showPassword, setShowPassword] = useState(false);
24
34
 
25
- const handleFocus = () => {
26
- setIsFocused(true);
27
- };
35
+ const handleFocus = () => setIsFocused(true);
36
+ const handleBlur = () => setIsFocused(false);
37
+ const handleTogglePasswordVisibility = () => setShowPassword(!showPassword);
28
38
 
29
- const handleBlur = () => {
30
- setIsFocused(false);
31
- };
39
+ const handleChange = (e) => {
40
+ let val = e.target.value;
32
41
 
33
- const handleTogglePasswordVisibility = () => {
34
- setShowPassword(!showPassword);
42
+ if (type === "number") {
43
+ // hapus semua karakter non digit
44
+ const raw = parseNumber(val.replace(/\D/g, ""));
45
+ // kirim angka murni ke parent
46
+ onChangeInput({
47
+ ...e,
48
+ target: { ...e.target, value: raw },
49
+ });
50
+ return;
51
+ }
52
+
53
+ onChangeInput(e);
35
54
  };
36
55
 
56
+ const displayValue =
57
+ type === "number" ? (value ? formatNumber(value) : "") : value;
58
+
37
59
  return (
38
60
  <div className={`w-full ${className}`}>
39
61
  <div className="flex w-full items-center">
40
62
  {title && (
41
63
  <div className="flex">
42
64
  <p className="text-sm font-normal text-black mb-1">{title}</p>
43
- {isRequired && <p className="text-sm font-normal text-danger500 ml-1">*</p>}
65
+ {isRequired && (
66
+ <p className="text-sm font-normal text-danger500 ml-1">*</p>
67
+ )}
44
68
  </div>
45
69
  )}
46
70
  {rightComponent}
@@ -56,34 +80,51 @@ const TextInput = ({
56
80
  ${mode === "primary" && "text-black"}
57
81
  ${mode === "disable" && "text-neutral50"}
58
82
  ${mode === "danger" && "text-danger500"}
59
- `}
83
+ `}
60
84
  />
61
85
  )}
62
86
  </section>
63
87
 
64
88
  <input
65
- min={minimum !== null && minimum !== undefined && type === "number" ? minimum : undefined}
66
- max={maximum !== null && maximum !== undefined && type === "number" ? maximum : undefined}
67
- type={type === "password" ? (showPassword ? "text" : "password") : type}
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
68
102
  className={`py-2.5 px-4 w-full font-normal text-sm text-black rounded-md border
69
- ${!value &&
70
- mode === "default" &&
71
- "bg-neutral20 border-neutral50 focus:outline-2 outline-primary500"
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
+ }
113
+ ${isFocused && mode === "default" && "bg-neutral20 border-primary500"}
114
+ ${mode === "disable" && "bg-neutral30 border-neutral50"}
115
+ ${mode === "white" && "bg-white border-neutral50"}
116
+ ${
117
+ mode === "danger" &&
118
+ "bg-danger50 border-danger500 focus:outline-2 outline-danger500"
72
119
  }
73
- ${value && mode === "default" && "bg-neutral20 border-black focus:outline-2 outline-primary500"}
74
- ${isFocused && mode === "default" && "bg-neutral20 border-primary500"}
75
- ${mode === "disable" && "bg-neutral30 border-neutral50"}
76
- ${mode === "white" && "bg-white border-neutral50"}
77
- ${mode === "danger" && "bg-danger50 border-danger500 focus:outline-2 outline-danger500"}
78
- ${leftIcon || leftAdornment ? "pl-8" : "pl-3"}
79
- ${leftIcon && leftAdornment ? "pl-16" : "pl-3"}
80
- ${rightIcon || rightAdornment ? "pr-8" : "pr-3"}
81
- ${rightIcon && rightAdornment ? "pr-16" : "pr-3"}`}
120
+ ${leftIcon || leftAdornment ? "pl-8" : "pl-3"}
121
+ ${leftIcon && leftAdornment ? "pl-16" : "pl-3"}
122
+ ${rightIcon || rightAdornment ? "pr-8" : "pr-3"}
123
+ ${rightIcon && rightAdornment ? "pr-16" : "pr-3"}`}
82
124
  placeholder={placeholder}
83
- data-mask="000.000.000-00"
84
125
  disabled={mode === "disable"}
85
- value={value}
86
- onChange={onChangeInput}
126
+ value={displayValue}
127
+ onChange={handleChange}
87
128
  onFocus={handleFocus}
88
129
  onBlur={handleBlur}
89
130
  />
@@ -94,9 +135,19 @@ const TextInput = ({
94
135
  onClick={handleTogglePasswordVisibility}
95
136
  >
96
137
  {showPassword ? (
97
- <PiEye size={16} className={`text-black ${mode === "danger" && "text-danger500"}`} />
138
+ <PiEye
139
+ size={16}
140
+ className={`text-black ${
141
+ mode === "danger" && "text-danger500"
142
+ }`}
143
+ />
98
144
  ) : (
99
- <PiEyeClosedLight size={16} className={`text-black ${mode === "danger" && "text-danger500"}`} />
145
+ <PiEyeClosedLight
146
+ size={16}
147
+ className={`text-black ${
148
+ mode === "danger" && "text-danger500"
149
+ }`}
150
+ />
100
151
  )}
101
152
  </span>
102
153
  )}
@@ -110,7 +161,7 @@ const TextInput = ({
110
161
  ${mode === "primary" && "text-neutral50"}
111
162
  ${mode === "disable" && "text-neutral50"}
112
163
  ${mode === "danger" && "text-danger500"}
113
- `}
164
+ `}
114
165
  />
115
166
  )}
116
167
  </section>
@@ -134,4 +185,4 @@ const TextInput = ({
134
185
  );
135
186
  };
136
187
 
137
- export default TextInput;
188
+ export default TextInput;