@hashrytech/quick-components-kit 0.20.4 → 0.20.6
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/CHANGELOG.md
CHANGED
|
@@ -7,6 +7,7 @@
|
|
|
7
7
|
children?: Snippet;
|
|
8
8
|
cssIcon?: string;
|
|
9
9
|
cssIconClass?: ClassNameValue;
|
|
10
|
+
cssLoadingIcon?: string;
|
|
10
11
|
icon?: Snippet;
|
|
11
12
|
loadingIcon?: Snippet;
|
|
12
13
|
loading?: boolean;
|
|
@@ -20,14 +21,14 @@
|
|
|
20
21
|
import {twMerge} from 'tailwind-merge';
|
|
21
22
|
import { Icon } from '../icon/index.js';
|
|
22
23
|
|
|
23
|
-
let { disabled=$bindable(), loading=$bindable(false), children, cssIcon, cssIconClass, icon, loadingIcon, onclick, ...props }: ButtonProps = $props();
|
|
24
|
+
let { disabled=$bindable(), loading=$bindable(false), children, cssIcon, cssIconClass, cssLoadingIcon, icon, loadingIcon, onclick, ...props }: ButtonProps = $props();
|
|
24
25
|
|
|
25
26
|
</script>
|
|
26
27
|
|
|
27
28
|
<button {disabled} class={twMerge("flex flex-row items-center gap-2 px-4 py-2 focus:outline-primary-focus bg-primary-button hover:bg-primary-button-hover rounded-primary cursor-pointer focus:ring-primary-focus focus:ring",
|
|
28
29
|
"disabled:bg-primary-button/60 disabled:cursor-default", props.class)}
|
|
29
30
|
{onclick}>
|
|
30
|
-
{#if cssIcon}<Icon icon={cssIcon} class={twMerge(loading ? "animate-spin" : "", cssIconClass)} />
|
|
31
|
+
{#if cssIcon}<Icon icon={loading ? cssLoadingIcon ? cssLoadingIcon : "" : cssIcon} class={twMerge(loading ? "animate-spin" : "", cssIconClass)} />
|
|
31
32
|
{:else if loadingIcon && loading}
|
|
32
33
|
<span class="shrink-0 animate-spin font-semibold">{@render loadingIcon()}</span>
|
|
33
34
|
{:else if icon}
|
|
@@ -55,6 +55,7 @@
|
|
|
55
55
|
step?: number;
|
|
56
56
|
debounceDelay?: number;
|
|
57
57
|
forcePositiveNumber?: boolean;
|
|
58
|
+
maxDecimalPlaces?: number;
|
|
58
59
|
onInput?: (value: string|number|null) => void;
|
|
59
60
|
onchange?: (event: Event) => void;
|
|
60
61
|
onmouseup?: () => void;
|
|
@@ -95,6 +96,7 @@
|
|
|
95
96
|
step,
|
|
96
97
|
debounceDelay=300, //ms
|
|
97
98
|
forcePositiveNumber=false,
|
|
99
|
+
maxDecimalPlaces=-1,
|
|
98
100
|
onchange,
|
|
99
101
|
onInput,
|
|
100
102
|
onmouseup,
|
|
@@ -139,6 +141,15 @@
|
|
|
139
141
|
(e.target as HTMLInputElement).value = localValue; // reflect sanitized value in the UI
|
|
140
142
|
}
|
|
141
143
|
|
|
144
|
+
if(maxDecimalPlaces > -1){
|
|
145
|
+
const parts = localValue.split(".");
|
|
146
|
+
if(parts.length > 1){
|
|
147
|
+
parts[1] = parts[1].slice(0, maxDecimalPlaces); // limit to maxDecimalPlaces decimal places
|
|
148
|
+
localValue = parts.join(".");
|
|
149
|
+
(e.target as HTMLInputElement).value = localValue; // reflect limited decimal places in the UI
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
|
|
142
153
|
if(max && max > 0){
|
|
143
154
|
if(Number(value) > max){
|
|
144
155
|
localValue = String(max);
|