react-table-edit 0.1.2 → 0.1.3
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 +14 -6
- package/dist/index.mjs +14 -6
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -290,23 +290,26 @@ var generateUUID = () => {
|
|
|
290
290
|
});
|
|
291
291
|
};
|
|
292
292
|
var formartNumberic = (str, decimalSeparator, thousandSeparator, fraction = 10, isDone) => {
|
|
293
|
+
if (isDone) {
|
|
294
|
+
str = roundNumber(Number(str), fraction);
|
|
295
|
+
}
|
|
293
296
|
if (str || str == "0") {
|
|
294
297
|
str = str.toString();
|
|
295
298
|
const value = decimalSeparator !== "." ? str.toString().replaceAll(".", decimalSeparator ?? "") : str;
|
|
296
299
|
const arr = value.toString().split(decimalSeparator ?? "", 2);
|
|
297
300
|
let flag = value.toString().includes(decimalSeparator ?? "");
|
|
298
|
-
if (
|
|
301
|
+
if (arr[0].length < 3) {
|
|
299
302
|
return flag ? `${arr[0]}${decimalSeparator}${arr[1]?.substring(0, fraction) ?? ""}` : arr[0];
|
|
300
303
|
} else {
|
|
301
304
|
let count = 0;
|
|
302
|
-
for (let i =
|
|
303
|
-
if ((
|
|
304
|
-
arr[0] = `${arr[0]
|
|
305
|
+
for (let i = arr[0].length - 2; i >= 0; i--) {
|
|
306
|
+
if ((arr[0].length - i - count) % 3 === 0 && i > 0) {
|
|
307
|
+
arr[0] = `${arr[0].substring(0, i)}${thousandSeparator}${arr[0].substring(i, arr[0].length)}`;
|
|
305
308
|
count++;
|
|
306
309
|
}
|
|
307
310
|
}
|
|
308
|
-
if (arr[0]
|
|
309
|
-
arr[0] = arr[0]
|
|
311
|
+
if (arr[0].lastIndexOf(thousandSeparator ?? "") === arr[0].length - 1) {
|
|
312
|
+
arr[0] = arr[0].slice(0, arr[0].length - 1);
|
|
310
313
|
}
|
|
311
314
|
if (isDone) {
|
|
312
315
|
flag = (arr[1]?.substring(0, fraction) ?? "") !== "";
|
|
@@ -317,6 +320,11 @@ var formartNumberic = (str, decimalSeparator, thousandSeparator, fraction = 10,
|
|
|
317
320
|
return "";
|
|
318
321
|
}
|
|
319
322
|
};
|
|
323
|
+
var roundNumber = (num, fraction) => {
|
|
324
|
+
const base = 10 ** fraction;
|
|
325
|
+
const result = Math.round(num * base) / base;
|
|
326
|
+
return result;
|
|
327
|
+
};
|
|
320
328
|
|
|
321
329
|
// test-app/src/component/icon/index.tsx
|
|
322
330
|
var Icon = __toESM(require("becoxy-icons"));
|
package/dist/index.mjs
CHANGED
|
@@ -245,23 +245,26 @@ var generateUUID = () => {
|
|
|
245
245
|
});
|
|
246
246
|
};
|
|
247
247
|
var formartNumberic = (str, decimalSeparator, thousandSeparator, fraction = 10, isDone) => {
|
|
248
|
+
if (isDone) {
|
|
249
|
+
str = roundNumber(Number(str), fraction);
|
|
250
|
+
}
|
|
248
251
|
if (str || str == "0") {
|
|
249
252
|
str = str.toString();
|
|
250
253
|
const value = decimalSeparator !== "." ? str.toString().replaceAll(".", decimalSeparator ?? "") : str;
|
|
251
254
|
const arr = value.toString().split(decimalSeparator ?? "", 2);
|
|
252
255
|
let flag = value.toString().includes(decimalSeparator ?? "");
|
|
253
|
-
if (
|
|
256
|
+
if (arr[0].length < 3) {
|
|
254
257
|
return flag ? `${arr[0]}${decimalSeparator}${arr[1]?.substring(0, fraction) ?? ""}` : arr[0];
|
|
255
258
|
} else {
|
|
256
259
|
let count = 0;
|
|
257
|
-
for (let i =
|
|
258
|
-
if ((
|
|
259
|
-
arr[0] = `${arr[0]
|
|
260
|
+
for (let i = arr[0].length - 2; i >= 0; i--) {
|
|
261
|
+
if ((arr[0].length - i - count) % 3 === 0 && i > 0) {
|
|
262
|
+
arr[0] = `${arr[0].substring(0, i)}${thousandSeparator}${arr[0].substring(i, arr[0].length)}`;
|
|
260
263
|
count++;
|
|
261
264
|
}
|
|
262
265
|
}
|
|
263
|
-
if (arr[0]
|
|
264
|
-
arr[0] = arr[0]
|
|
266
|
+
if (arr[0].lastIndexOf(thousandSeparator ?? "") === arr[0].length - 1) {
|
|
267
|
+
arr[0] = arr[0].slice(0, arr[0].length - 1);
|
|
265
268
|
}
|
|
266
269
|
if (isDone) {
|
|
267
270
|
flag = (arr[1]?.substring(0, fraction) ?? "") !== "";
|
|
@@ -272,6 +275,11 @@ var formartNumberic = (str, decimalSeparator, thousandSeparator, fraction = 10,
|
|
|
272
275
|
return "";
|
|
273
276
|
}
|
|
274
277
|
};
|
|
278
|
+
var roundNumber = (num, fraction) => {
|
|
279
|
+
const base = 10 ** fraction;
|
|
280
|
+
const result = Math.round(num * base) / base;
|
|
281
|
+
return result;
|
|
282
|
+
};
|
|
275
283
|
|
|
276
284
|
// test-app/src/component/icon/index.tsx
|
|
277
285
|
import * as Icon from "becoxy-icons";
|