@veritree/ui 0.83.1 → 0.84.0

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@veritree/ui",
3
- "version": "0.83.1",
3
+ "version": "0.84.0",
4
4
  "description": "veritree ui library",
5
5
  "type": "module",
6
6
  "main": "index.js",
@@ -22,36 +22,10 @@ export default {
22
22
  },
23
23
  },
24
24
 
25
- // data() {
26
- // return {
27
- // expanded: false,
28
- // };
29
- // },
30
-
31
25
  computed: {
32
- // id() {
33
- // return this.apiDetails().idIcon;
34
- // },
35
-
36
- // idGroup() {
37
- // return this.apiDetails().idGroup;
38
- // },
39
-
40
26
  expanded() {
41
27
  return this.apiDetails().visible;
42
28
  },
43
29
  },
44
-
45
- mounted() {
46
- // const icon = {
47
- // id: this.id,
48
- // idGroup: this.idGroup,
49
- // };
50
- // this.apiDisclosure().register('icons', icon);
51
- },
52
-
53
- beforeDestroy() {
54
- // this.apiDisclosure().unregister('icons', this.id);
55
- },
56
30
  };
57
31
  </script>
@@ -66,6 +66,10 @@ export default {
66
66
  return {
67
67
  event: null,
68
68
  key: null,
69
+ /**
70
+ * @property {boolean} isDirty - Indicates whether the input field has been modified by the user.
71
+ */
72
+ isDirty: false,
69
73
  };
70
74
  },
71
75
 
@@ -91,15 +95,21 @@ export default {
91
95
  if (this.format === 'currency' && this.event !== 'input') {
92
96
  options = {
93
97
  minimumFractionDigits: 2,
94
- maximumFractionDigits: 2,
98
+ maximumFractionDigits: 3,
95
99
  };
96
100
  } else {
97
101
  options = {};
98
102
  }
99
103
 
100
- const number = Number(this.value).toLocaleString(this.locale, options);
104
+ if (this.value === null || this.value === undefined) {
105
+ return null;
106
+ }
107
+
108
+ if (this.value === 0 && !this.isDirty) {
109
+ return null;
110
+ }
101
111
 
102
- return number === '0' ? null : number;
112
+ return Number(this.value).toLocaleString(this.locale, options);
103
113
  },
104
114
  set(value) {
105
115
  // value without formatting that will be
@@ -123,6 +133,10 @@ export default {
123
133
  },
124
134
  },
125
135
 
136
+ beforeDestroy() {
137
+ this.isDirty = false;
138
+ },
139
+
126
140
  methods: {
127
141
  /**
128
142
  * Unformats a formatted number string by removing commas and converting it to an integer.
@@ -164,6 +178,7 @@ export default {
164
178
  onInput(e) {
165
179
  this.event = 'input';
166
180
  this.valueComputed = e.target.value;
181
+ this.isDirty = true;
167
182
  },
168
183
 
169
184
  onBlur(e) {
@@ -187,6 +202,11 @@ export default {
187
202
  * @param {Event} e - The keydown event object.
188
203
  */
189
204
  onKeyDown(e) {
205
+ // if select all (Ctrl + A) is pressed, don't prevent default
206
+ if (e.key === 'a' && (e.ctrlKey || e.metaKey)) {
207
+ return;
208
+ }
209
+
190
210
  if (
191
211
  !/^[0-9.,]$/.test(e.key) &&
192
212
  !['Backspace', 'Delete', 'ArrowLeft', 'ArrowRight', 'Tab'].includes(