@vunset/vue 1.0.0-rc.2 → 1.0.0-rc.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.
@@ -20,12 +20,19 @@ function useInput(options = {}) {
20
20
  });
21
21
  const invalid = () => (toValue(options.invalid) ?? false) || (field?.state.value.invalid ?? false) || outsideLimits();
22
22
  const normalize = (raw) => raw == null ? void 0 : String(raw);
23
+ const typed = ref();
23
24
  const value = useControlled({
24
- value: () => normalize(toValue(options.value)),
25
+ value: () => {
26
+ const raw = toValue(options.value);
27
+ return typeof raw === "number" && typed.value !== void 0 && parseFloat(typed.value) === raw ? typed.value : normalize(raw);
28
+ },
25
29
  defaultValue: () => normalize(toValue(options.defaultValue)) ?? "",
26
30
  prop: "modelValue",
27
31
  empty: "",
28
- onChange: options.onChange,
32
+ onChange: (next) => {
33
+ typed.value = next;
34
+ options.onChange?.(next);
35
+ },
29
36
  name: "useInput",
30
37
  label: "value"
31
38
  });
@@ -108,7 +115,15 @@ function useInput(options = {}) {
108
115
  const element = event.target;
109
116
  const inserted = insertedText(event);
110
117
  if (inserted === null) return;
111
- if (!accepts(prospectiveValue(element, inserted) ?? element.value + inserted)) event.preventDefault();
118
+ if (accepts(prospectiveValue(element, inserted) ?? element.value + inserted)) return;
119
+ event.preventDefault();
120
+ if (!numeric() || !/^insertFrom(Paste|Drop)/.test(event.inputType)) return;
121
+ const cleaned = inserted.replace(/[,\s]/g, "");
122
+ const start = element.selectionStart ?? element.value.length;
123
+ const end = element.selectionEnd ?? element.value.length;
124
+ if (!accepts(element.value.slice(0, start) + cleaned + element.value.slice(end))) return;
125
+ element.setRangeText(cleaned, start, end, "end");
126
+ handleInput({ target: element });
112
127
  },
113
128
  onInput(event) {
114
129
  if (composing) return;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vunset/vue",
3
- "version": "1.0.0-rc.2",
3
+ "version": "1.0.0-rc.3",
4
4
  "description": "Headless, unstyled Vue 3 components: keyboard, focus and ARIA handled, the look left to you.",
5
5
  "keywords": [
6
6
  "vue",
@@ -47,7 +47,7 @@
47
47
  },
48
48
  "dependencies": {
49
49
  "@floating-ui/vue": "^2.0.1",
50
- "@vunset/utils": "1.0.0-rc.2"
50
+ "@vunset/utils": "1.0.0-rc.3"
51
51
  },
52
52
  "peerDependencies": {
53
53
  "@tanstack/charts": "^1.1.0",