@fmdeui/fmui 1.0.150 → 1.0.152

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.
@@ -39,15 +39,24 @@ var _sfc_main = /* @__PURE__ */ defineComponent({
39
39
  emit("handleInput", validNum);
40
40
  return;
41
41
  }
42
+ const strVal = String(val);
43
+ const isNegative = strVal.startsWith("-");
44
+ let pureVal = isNegative ? strVal.substring(1) : strVal;
42
45
  if (props.bType == "number") {
43
- let trimstr = String(val).replace(/[^\d]/g, "");
46
+ const match = pureVal.match(/^-?\d*/);
47
+ let trimstr = match ? match[0] : "";
48
+ if (trimstr === "-") {
49
+ modelValue.value = trimstr;
50
+ emit("handleInput", 0);
51
+ return;
52
+ }
44
53
  const num = parseInt(trimstr, 10);
45
54
  const validNum = Number.isNaN(num) ? props.defaultValue : num;
46
55
  modelValue.value = validNum;
47
56
  emit("handleInput", validNum);
48
57
  return;
49
58
  }
50
- let cleaned = String(val).replace(/[^\d.]/g, "");
59
+ let cleaned = pureVal.replace(/[^\d.]/g, "");
51
60
  const dotIndex = cleaned.indexOf(".");
52
61
  if (dotIndex !== -1) {
53
62
  const before = cleaned.substring(0, dotIndex + 1);
@@ -64,8 +73,21 @@ var _sfc_main = /* @__PURE__ */ defineComponent({
64
73
  const [intPart, decPart] = cleaned.split(".");
65
74
  cleaned = `${intPart}.${decPart.substring(0, props.decimalPlaces)}`;
66
75
  }
76
+ if (isNegative) {
77
+ if (cleaned === "" || cleaned === "0") {
78
+ cleaned = cleaned === "" ? "-" : pureVal === "-0" ? "-0" : "0";
79
+ if (pureVal === "-") cleaned = "-";
80
+ } else {
81
+ cleaned = "-" + cleaned;
82
+ }
83
+ }
84
+ if (cleaned === "-.") {
85
+ cleaned = "-0.";
86
+ }
67
87
  modelValue.value = cleaned;
68
- emit("handleInput", cleaned);
88
+ const numValue = Number(cleaned);
89
+ const finalNum = Number.isNaN(numValue) ? props.defaultValue !== -1 ? props.defaultValue : 0 : numValue;
90
+ emit("handleInput", finalNum);
69
91
  };
70
92
  watch(() => modelValue.value, (newvalue, oldValue) => {
71
93
  if (newvalue == "") {
package/index.js CHANGED
@@ -1,4 +1,4 @@
1
- /*! fmdeui-fmui v1.0.150 */
1
+ /*! fmdeui-fmui v1.0.152 */
2
2
  (function (global, factory) {
3
3
  typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('vxe-table'), require('@vxe-ui/plugin-render-element'), require('@vxe-ui/plugin-export-xlsx'), require('vxe-pc-ui'), require('exceljs'), require('@element-plus/icons-vue'), require('vue'), require('element-plus'), require('lodash-es'), require('js-cookie'), require('pinia'), require('vue-router'), require('@vueuse/core'), require('crypto-js'), require('xlsx-js-style'), require('vue-i18n'), require('sortablejs'), require('screenfull'), require('push.js'), require('mitt'), require('@microsoft/signalr'), require('axios')) :
4
4
  typeof define === 'function' && define.amd ? define(['exports', 'vxe-table', '@vxe-ui/plugin-render-element', '@vxe-ui/plugin-export-xlsx', 'vxe-pc-ui', 'exceljs', '@element-plus/icons-vue', 'vue', 'element-plus', 'lodash-es', 'js-cookie', 'pinia', 'vue-router', '@vueuse/core', 'crypto-js', 'xlsx-js-style', 'vue-i18n', 'sortablejs', 'screenfull', 'push.js', 'mitt', '@microsoft/signalr', 'axios'], factory) :
@@ -27436,15 +27436,24 @@
27436
27436
  emit("handleInput", validNum);
27437
27437
  return;
27438
27438
  }
27439
+ const strVal = String(val);
27440
+ const isNegative = strVal.startsWith("-");
27441
+ let pureVal = isNegative ? strVal.substring(1) : strVal;
27439
27442
  if (props.bType == "number") {
27440
- let trimstr = String(val).replace(/[^\d]/g, "");
27443
+ const match = pureVal.match(/^-?\d*/);
27444
+ let trimstr = match ? match[0] : "";
27445
+ if (trimstr === "-") {
27446
+ modelValue.value = trimstr;
27447
+ emit("handleInput", 0);
27448
+ return;
27449
+ }
27441
27450
  const num = parseInt(trimstr, 10);
27442
27451
  const validNum = Number.isNaN(num) ? props.defaultValue : num;
27443
27452
  modelValue.value = validNum;
27444
27453
  emit("handleInput", validNum);
27445
27454
  return;
27446
27455
  }
27447
- let cleaned = String(val).replace(/[^\d.]/g, "");
27456
+ let cleaned = pureVal.replace(/[^\d.]/g, "");
27448
27457
  const dotIndex = cleaned.indexOf(".");
27449
27458
  if (dotIndex !== -1) {
27450
27459
  const before = cleaned.substring(0, dotIndex + 1);
@@ -27461,8 +27470,21 @@
27461
27470
  const [intPart, decPart] = cleaned.split(".");
27462
27471
  cleaned = `${intPart}.${decPart.substring(0, props.decimalPlaces)}`;
27463
27472
  }
27473
+ if (isNegative) {
27474
+ if (cleaned === "" || cleaned === "0") {
27475
+ cleaned = cleaned === "" ? "-" : pureVal === "-0" ? "-0" : "0";
27476
+ if (pureVal === "-") cleaned = "-";
27477
+ } else {
27478
+ cleaned = "-" + cleaned;
27479
+ }
27480
+ }
27481
+ if (cleaned === "-.") {
27482
+ cleaned = "-0.";
27483
+ }
27464
27484
  modelValue.value = cleaned;
27465
- emit("handleInput", cleaned);
27485
+ const numValue = Number(cleaned);
27486
+ const finalNum = Number.isNaN(numValue) ? props.defaultValue !== -1 ? props.defaultValue : 0 : numValue;
27487
+ emit("handleInput", finalNum);
27466
27488
  };
27467
27489
  vue.watch(() => modelValue.value, (newvalue, oldValue) => {
27468
27490
  if (newvalue == "") {