quasar-ui-danx 0.4.93 → 0.4.94
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
|
@@ -50,7 +50,37 @@ function format(number) {
|
|
|
50
50
|
return fNumber(number, options);
|
|
51
51
|
}
|
|
52
52
|
|
|
53
|
-
const onUpdateDebounced = useDebounceFn((val: number | string | undefined) =>
|
|
53
|
+
const onUpdateDebounced = useDebounceFn((val: number | string | undefined) => {
|
|
54
|
+
// Apply min/max clamping to the final value
|
|
55
|
+
let clampedVal = val;
|
|
56
|
+
if (typeof val === "number") {
|
|
57
|
+
if (props.min !== undefined) {
|
|
58
|
+
clampedVal = Math.max(val, props.min);
|
|
59
|
+
}
|
|
60
|
+
if (props.max !== undefined) {
|
|
61
|
+
clampedVal = Math.min(clampedVal as number, props.max);
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
emit("update", clampedVal);
|
|
65
|
+
}, props.delay);
|
|
66
|
+
|
|
67
|
+
const applyMinMaxClamping = useDebounceFn((value: number | undefined) => {
|
|
68
|
+
if (value === undefined) return;
|
|
69
|
+
|
|
70
|
+
let clampedValue = value;
|
|
71
|
+
if (props.min !== undefined) {
|
|
72
|
+
clampedValue = Math.max(clampedValue, props.min);
|
|
73
|
+
}
|
|
74
|
+
if (props.max !== undefined) {
|
|
75
|
+
clampedValue = Math.min(clampedValue, props.max);
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
// Only update the display if the value changed after clamping
|
|
79
|
+
if (clampedValue !== value) {
|
|
80
|
+
numberVal.value = format(clampedValue);
|
|
81
|
+
emit("update:model-value", clampedValue);
|
|
82
|
+
}
|
|
83
|
+
}, 500);
|
|
54
84
|
|
|
55
85
|
function onInput(value) {
|
|
56
86
|
let number: number | undefined = undefined;
|
|
@@ -68,19 +98,17 @@ function onInput(value) {
|
|
|
68
98
|
value = value.replace(/[^\d.]/g, "");
|
|
69
99
|
number = +value;
|
|
70
100
|
|
|
71
|
-
|
|
72
|
-
number = Math.max(number, props.min);
|
|
73
|
-
}
|
|
74
|
-
if (props.max) {
|
|
75
|
-
number = Math.min(number, props.max);
|
|
76
|
-
}
|
|
77
|
-
|
|
101
|
+
// Don't clamp immediately - let user type freely
|
|
78
102
|
numberVal.value = format(number);
|
|
79
103
|
}
|
|
80
104
|
|
|
105
|
+
// Emit the raw typed value immediately
|
|
81
106
|
emit("update:model-value", number);
|
|
82
107
|
|
|
83
108
|
// Delay the change event, so we only see the value after the user has finished
|
|
84
109
|
onUpdateDebounced(number);
|
|
110
|
+
|
|
111
|
+
// Apply min/max clamping after user stops typing
|
|
112
|
+
applyMinMaxClamping(number);
|
|
85
113
|
}
|
|
86
114
|
</script>
|
|
@@ -63,9 +63,12 @@ export function fMarkdownCode(type: string, string: string | object): string {
|
|
|
63
63
|
}
|
|
64
64
|
}
|
|
65
65
|
|
|
66
|
-
const regex = new RegExp(`\`\`\`${type}`, "g");
|
|
67
66
|
string = (string || "") as string;
|
|
68
|
-
if
|
|
67
|
+
// Check if string STARTS with the code fence (not just contains it anywhere)
|
|
68
|
+
// This fixes a bug where JSON containing embedded code fences in the data
|
|
69
|
+
// would incorrectly be detected as already wrapped
|
|
70
|
+
const startsWithCodeFence = new RegExp(`^\\s*\`\`\`${type}\\s`).test(string);
|
|
71
|
+
if (!startsWithCodeFence) {
|
|
69
72
|
string = parseMarkdownCode(string as string);
|
|
70
73
|
return `\`\`\`${type}\n${string}\n\`\`\``;
|
|
71
74
|
}
|