@tagplus/components 5.3.8 → 5.3.12

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.
@@ -59,6 +59,13 @@ const _sfc_main = /* @__PURE__ */ Object.assign({
59
59
  });
60
60
  const inputNumberSize = useFormSize();
61
61
  const inputNumberDisabled = useFormDisabled();
62
+ const escapeRegExp = (value) => value.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
63
+ const toNumberValue = (value) => {
64
+ if (value === "") return null;
65
+ const normalizedValue = String(value).replace(",", ".");
66
+ const parsedValue = Number(normalizedValue);
67
+ return Number.isNaN(parsedValue) ? null : parsedValue;
68
+ };
62
69
  const displayValue = computed(() => {
63
70
  if (data.userInput !== null) {
64
71
  return data.userInput;
@@ -80,18 +87,26 @@ const _sfc_main = /* @__PURE__ */ Object.assign({
80
87
  const decimalChar = vm.$t("locale.number.decimal");
81
88
  const thousandsChar = vm.$t("locale.number.thousands");
82
89
  return (value) => {
83
- const noLetters = value.replaceAll(/[a-zA-Z]/g, "");
84
- const res = noLetters.replace(".", decimalChar).replace(/\B(?=(\d{3})+(?!\d))/g, thousandsChar);
85
- return res;
90
+ if (value === null || value === void 0) return value;
91
+ const noLetters = String(value).replaceAll(/[a-zA-Z]/g, "");
92
+ if (!props.usarVirgula) {
93
+ return noLetters;
94
+ }
95
+ return noLetters.replace(".", decimalChar).replace(/\B(?=(\d{3})+(?!\d))/g, thousandsChar);
86
96
  };
87
97
  });
88
98
  const inputParser = computed(() => {
89
99
  const decimalChar = vm.$t("locale.number.decimal");
90
100
  const thousandsChar = vm.$t("locale.number.thousands");
91
101
  return (value) => {
92
- const regexThou = `/$s?|(${thousandsChar}*)/g`;
93
- const res = value.replace(regexThou, "").replace(decimalChar, ".");
94
- return res;
102
+ if (!value) return value;
103
+ const inputValue = String(value).replaceAll(/[a-zA-Z]/g, "");
104
+ if (props.usarVirgula) {
105
+ const thousandsRegex = new RegExp(escapeRegExp(thousandsChar), "g");
106
+ const withoutThousands = inputValue.replace(thousandsRegex, "");
107
+ return withoutThousands.replace(decimalChar, ".");
108
+ }
109
+ return inputValue.replaceAll(",", "");
95
110
  };
96
111
  });
97
112
  const toPrecision = (num, pre) => {
@@ -184,8 +199,9 @@ const _sfc_main = /* @__PURE__ */ Object.assign({
184
199
  };
185
200
  const handleInput = (value) => {
186
201
  data.userInput = value;
187
- const newVal = value === "" ? null : Number(value);
202
+ const newVal = toNumberValue(value);
188
203
  emit(INPUT_EVENT, newVal);
204
+ emit(CHANGE_EVENT, newVal, data.currentValue);
189
205
  setCurrentValue(newVal, false);
190
206
  };
191
207
  const handleInputChange = (value) => {
@@ -113,10 +113,18 @@ const inputNumberProps = buildProps({
113
113
  stringDefaultsZero: {
114
114
  type: Boolean,
115
115
  default: true
116
+ },
117
+ /**
118
+ * @tagplus
119
+ * Permite usar virgula como separador decimal na digitacao
120
+ **/
121
+ usarVirgula: {
122
+ type: Boolean,
123
+ default: true
116
124
  }
117
125
  });
118
126
  const inputNumberEmits = {
119
- [CHANGE_EVENT]: (cur, prev) => prev !== cur,
127
+ [CHANGE_EVENT]: (cur, prev) => (isNumber(cur) || isNil(cur) || cur === "") && (isNumber(prev) || isNil(prev) || prev === ""),
120
128
  blur: (e) => e instanceof FocusEvent,
121
129
  focus: (e) => e instanceof FocusEvent,
122
130
  [INPUT_EVENT]: (val) => isNumber(val) || isNil(val),
@@ -61,6 +61,13 @@ const _sfc_main = /* @__PURE__ */ Object.assign({
61
61
  });
62
62
  const inputNumberSize = useFormCommonProps.useFormSize();
63
63
  const inputNumberDisabled = useFormCommonProps.useFormDisabled();
64
+ const escapeRegExp = (value) => value.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
65
+ const toNumberValue = (value) => {
66
+ if (value === "") return null;
67
+ const normalizedValue = String(value).replace(",", ".");
68
+ const parsedValue = Number(normalizedValue);
69
+ return Number.isNaN(parsedValue) ? null : parsedValue;
70
+ };
64
71
  const displayValue = vue.computed(() => {
65
72
  if (data.userInput !== null) {
66
73
  return data.userInput;
@@ -82,18 +89,26 @@ const _sfc_main = /* @__PURE__ */ Object.assign({
82
89
  const decimalChar = vm.$t("locale.number.decimal");
83
90
  const thousandsChar = vm.$t("locale.number.thousands");
84
91
  return (value) => {
85
- const noLetters = value.replaceAll(/[a-zA-Z]/g, "");
86
- const res = noLetters.replace(".", decimalChar).replace(/\B(?=(\d{3})+(?!\d))/g, thousandsChar);
87
- return res;
92
+ if (value === null || value === void 0) return value;
93
+ const noLetters = String(value).replaceAll(/[a-zA-Z]/g, "");
94
+ if (!props.usarVirgula) {
95
+ return noLetters;
96
+ }
97
+ return noLetters.replace(".", decimalChar).replace(/\B(?=(\d{3})+(?!\d))/g, thousandsChar);
88
98
  };
89
99
  });
90
100
  const inputParser = vue.computed(() => {
91
101
  const decimalChar = vm.$t("locale.number.decimal");
92
102
  const thousandsChar = vm.$t("locale.number.thousands");
93
103
  return (value) => {
94
- const regexThou = `/$s?|(${thousandsChar}*)/g`;
95
- const res = value.replace(regexThou, "").replace(decimalChar, ".");
96
- return res;
104
+ if (!value) return value;
105
+ const inputValue = String(value).replaceAll(/[a-zA-Z]/g, "");
106
+ if (props.usarVirgula) {
107
+ const thousandsRegex = new RegExp(escapeRegExp(thousandsChar), "g");
108
+ const withoutThousands = inputValue.replace(thousandsRegex, "");
109
+ return withoutThousands.replace(decimalChar, ".");
110
+ }
111
+ return inputValue.replaceAll(",", "");
97
112
  };
98
113
  });
99
114
  const toPrecision = (num, pre) => {
@@ -186,8 +201,9 @@ const _sfc_main = /* @__PURE__ */ Object.assign({
186
201
  };
187
202
  const handleInput = (value) => {
188
203
  data.userInput = value;
189
- const newVal = value === "" ? null : Number(value);
204
+ const newVal = toNumberValue(value);
190
205
  emit(INPUT_EVENT, newVal);
206
+ emit(CHANGE_EVENT, newVal, data.currentValue);
191
207
  setCurrentValue(newVal, false);
192
208
  };
193
209
  const handleInputChange = (value) => {
@@ -115,10 +115,18 @@ const inputNumberProps = runtime.buildProps({
115
115
  stringDefaultsZero: {
116
116
  type: Boolean,
117
117
  default: true
118
+ },
119
+ /**
120
+ * @tagplus
121
+ * Permite usar virgula como separador decimal na digitacao
122
+ **/
123
+ usarVirgula: {
124
+ type: Boolean,
125
+ default: true
118
126
  }
119
127
  });
120
128
  const inputNumberEmits = {
121
- [index.CHANGE_EVENT]: (cur, prev) => prev !== cur,
129
+ [index.CHANGE_EVENT]: (cur, prev) => (types.isNumber(cur) || lodashEs.isNil(cur) || cur === "") && (types.isNumber(prev) || lodashEs.isNil(prev) || prev === ""),
122
130
  blur: (e) => e instanceof FocusEvent,
123
131
  focus: (e) => e instanceof FocusEvent,
124
132
  [index.INPUT_EVENT]: (val) => types.isNumber(val) || lodashEs.isNil(val),
package/package.json CHANGED
@@ -8,7 +8,7 @@
8
8
  "email": "qualidade@tagplus.com.br"
9
9
  }
10
10
  ],
11
- "version": "5.3.8",
11
+ "version": "5.3.12",
12
12
  "type": "module",
13
13
  "main": "./dist/lib/src/main.js",
14
14
  "module": "./dist/es/src/main.mjs",
@@ -80,7 +80,6 @@
80
80
  "js-cookie": "^3.0.5",
81
81
  "lint-staged": "^15.2.2",
82
82
  "lodash-unified": "^1.0.3",
83
- "node-sass": "^9.0.0",
84
83
  "nodemon": "^3.1.10",
85
84
  "sass-embedded": "^1.89.2",
86
85
  "sass-loader": "^14.2.1",