intelliwaketssveltekitv25 0.1.163 → 0.1.164
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/dist/InputNumber.svelte +11 -9
- package/dist/NumberFormat.svelte +9 -2
- package/package.json +1 -1
package/dist/InputNumber.svelte
CHANGED
|
@@ -40,11 +40,11 @@
|
|
|
40
40
|
let displayMultiplier = $derived(shiftDigits === 0 ? 1 : shiftDigits > 0 ? CleanNumber(`1${'0'.repeat(shiftDigits)}`) : CleanNumber(`.${'0'.repeat(Math.abs(shiftDigits) + 1)}1`))
|
|
41
41
|
let constrainDecimals = $derived(fixedDecimals ?? maxDecimals ?? minDecimals ?? (currency ? 2 : 0))
|
|
42
42
|
let useDecimals = $derived(!shiftDigits ? constrainDecimals : CleanNumbers(0, constrainDecimals, shiftDigits))
|
|
43
|
-
let
|
|
43
|
+
let readonly = $derived(!!otherProps.readonly || !!otherProps.disabled)
|
|
44
44
|
let usePrefix = $derived(prefix ?? (currency ? '$' : ''))
|
|
45
45
|
let useSuffix = $derived(suffix ?? (percent ? '%' : ''))
|
|
46
46
|
|
|
47
|
-
function refreshDisplayValue(useValue: number | null) {
|
|
47
|
+
function refreshDisplayValue(useValue: number | null, ro: boolean) {
|
|
48
48
|
if (!isFocused) {
|
|
49
49
|
tick()
|
|
50
50
|
.then(() => {
|
|
@@ -52,17 +52,19 @@
|
|
|
52
52
|
if (useValue === null) {
|
|
53
53
|
newDisplayValue = !!otherProps.required ? '0' : ''
|
|
54
54
|
} else {
|
|
55
|
-
const workingValue = useValue * displayMultiplier
|
|
55
|
+
const workingValue = useValue * (ro ? 1 : displayMultiplier)
|
|
56
56
|
newDisplayValue = ToNumberString(workingValue, {
|
|
57
|
-
currency: !!
|
|
58
|
-
percent: !!
|
|
57
|
+
currency: !!ro && !!currency,
|
|
58
|
+
percent: !!ro && !!percent,
|
|
59
59
|
fixedDecimals,
|
|
60
60
|
minDecimals,
|
|
61
61
|
maxDecimals,
|
|
62
62
|
zeroBlank,
|
|
63
63
|
zeroDash,
|
|
64
64
|
nullBlank,
|
|
65
|
-
nullDash
|
|
65
|
+
nullDash,
|
|
66
|
+
prefix: ro ? prefix : undefined,
|
|
67
|
+
suffix: ro ? suffix : undefined
|
|
66
68
|
})
|
|
67
69
|
}
|
|
68
70
|
|
|
@@ -73,7 +75,7 @@
|
|
|
73
75
|
}
|
|
74
76
|
}
|
|
75
77
|
|
|
76
|
-
$effect(() => refreshDisplayValue(value))
|
|
78
|
+
$effect(() => refreshDisplayValue(value, readonly))
|
|
77
79
|
|
|
78
80
|
function handleInput(event: Event) {
|
|
79
81
|
const input = event.target as HTMLInputElement
|
|
@@ -135,7 +137,7 @@
|
|
|
135
137
|
use:useActions={use}
|
|
136
138
|
bind:this={thisRef}
|
|
137
139
|
/>
|
|
138
|
-
{#if !
|
|
140
|
+
{#if !readonly}
|
|
139
141
|
{#if usePrefix}
|
|
140
142
|
<div class="absolute pointer-events-none left-1 top-1/2 -translate-y-1/2">{usePrefix}</div>
|
|
141
143
|
{/if}
|
|
@@ -143,4 +145,4 @@
|
|
|
143
145
|
<div class="absolute pointer-events-none right-1 top-1/2 -translate-y-1/2">{useSuffix}</div>
|
|
144
146
|
{/if}
|
|
145
147
|
{/if}
|
|
146
|
-
</div>
|
|
148
|
+
</div>
|
package/dist/NumberFormat.svelte
CHANGED
|
@@ -13,7 +13,9 @@
|
|
|
13
13
|
nullBlank,
|
|
14
14
|
nullDash,
|
|
15
15
|
className,
|
|
16
|
-
classNameAddOnNegative
|
|
16
|
+
classNameAddOnNegative,
|
|
17
|
+
prefix,
|
|
18
|
+
suffix
|
|
17
19
|
}: ({
|
|
18
20
|
value?: number | null
|
|
19
21
|
className?: string
|
|
@@ -22,6 +24,9 @@
|
|
|
22
24
|
|
|
23
25
|
let isNegative = $derived(CleanNumber(value) < 0)
|
|
24
26
|
|
|
27
|
+
let usePrefix = $derived(prefix ? `${prefix} ` : undefined)
|
|
28
|
+
let useSuffix = $derived(suffix ? ` ${suffix}` : undefined)
|
|
29
|
+
|
|
25
30
|
</script>
|
|
26
31
|
|
|
27
32
|
<span
|
|
@@ -38,6 +43,8 @@
|
|
|
38
43
|
zeroBlank,
|
|
39
44
|
zeroDash,
|
|
40
45
|
nullBlank,
|
|
41
|
-
nullDash
|
|
46
|
+
nullDash,
|
|
47
|
+
prefix: usePrefix,
|
|
48
|
+
suffix: useSuffix
|
|
42
49
|
})}
|
|
43
50
|
</span>
|