hamzus-ui 0.0.63 → 0.0.64

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": "hamzus-ui",
3
- "version": "0.0.63",
3
+ "version": "0.0.64",
4
4
  "type": "module",
5
5
  "main": "index.js",
6
6
  "svelte": "index.js",
@@ -35,8 +35,15 @@
35
35
  // local var
36
36
 
37
37
  $: {
38
- value = formatInput(value)
39
- };
38
+ let newValue = formatInput(value);
39
+
40
+ if (newValue !== value) {
41
+ value = newValue;
42
+ hasChanged = value != initialValue;
43
+ } else if (onChange) {
44
+ onChange(value);
45
+ }
46
+ }
40
47
 
41
48
  // fnctions
42
49
  function formatInput(inputValue) {
@@ -47,7 +54,6 @@
47
54
 
48
55
  // Supprime tout sauf chiffres et un seul point
49
56
  inputValue = inputValue.replace(/[^0-9.]/g, '');
50
-
51
57
  }
52
58
 
53
59
  if (formatPattern.length == 0) {
@@ -81,7 +87,12 @@
81
87
  }
82
88
 
83
89
  onMount(() => {
84
- value = formatInput(value);
90
+ let newValue = formatInput(value);
91
+
92
+ if (newValue !== value) {
93
+ value = newValue;
94
+ }
95
+
85
96
  if (formatPattern.length !== 0) {
86
97
  initialValue = value;
87
98
  }
@@ -90,15 +101,6 @@
90
101
  function handleDisplay() {
91
102
  isVisible = !isVisible;
92
103
  }
93
-
94
- function handleChange(event) {
95
- value = formatInput(event.target.value);
96
- hasChanged = value != initialValue;
97
-
98
- if (onChange) {
99
- onChange(value);
100
- }
101
- }
102
104
  </script>
103
105
 
104
106
  <div
@@ -133,10 +135,9 @@
133
135
  <input
134
136
  on:focus={onFocus}
135
137
  on:blur={onBlur}
136
- on:input={handleChange}
137
138
  class="h4"
138
139
  {placeholder}
139
- type={(isVisible && type == 'password') || type === "number" ? 'text' : type}
140
+ type={(isVisible && type == 'password') || type === 'number' ? 'text' : type}
140
141
  {name}
141
142
  bind:value
142
143
  {required}