@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
@@ -1,5 +1,17 @@
1
1
  # @hashrytech/quick-components-kit
2
2
 
3
+ ## 0.20.6
4
+
5
+ ### Patch Changes
6
+
7
+ - patch: adding css loading icons
8
+
9
+ ## 0.20.5
10
+
11
+ ### Patch Changes
12
+
13
+ - add: Adding max decimal places property
14
+
3
15
  ## 0.20.4
4
16
 
5
17
  ### Patch Changes
@@ -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}
@@ -5,6 +5,7 @@ export type ButtonProps = {
5
5
  children?: Snippet;
6
6
  cssIcon?: string;
7
7
  cssIconClass?: ClassNameValue;
8
+ cssLoadingIcon?: string;
8
9
  icon?: Snippet;
9
10
  loadingIcon?: Snippet;
10
11
  loading?: boolean;
@@ -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);
@@ -52,6 +52,7 @@ export type TextInputProps = {
52
52
  step?: number;
53
53
  debounceDelay?: number;
54
54
  forcePositiveNumber?: boolean;
55
+ maxDecimalPlaces?: number;
55
56
  onInput?: (value: string | number | null) => void;
56
57
  onchange?: (event: Event) => void;
57
58
  onmouseup?: () => void;
package/package.json CHANGED
@@ -5,7 +5,7 @@
5
5
  "type": "git",
6
6
  "url": "git+https://github.com/hashrytech/quick-components-kit.git"
7
7
  },
8
- "version": "0.20.4",
8
+ "version": "0.20.6",
9
9
  "license": "MIT",
10
10
  "author": "Hashry Tech",
11
11
  "files": [