@tuspe/components 1.7.21 → 1.8.1
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/README.md +8 -2
- package/dist/Button.svelte +8 -3
- package/dist/Button.svelte.d.ts +3 -1
- package/dist/ButtonMenu.svelte +3 -3
- package/dist/ButtonMenu.svelte.d.ts +1 -1
- package/dist/Input.svelte +11 -5
- package/dist/index.d.ts +3 -2
- package/dist/index.js +3 -2
- package/package.json +7 -7
package/README.md
CHANGED
|
@@ -43,7 +43,7 @@ Easily replace most buttons in your project with this versatile button component
|
|
|
43
43
|
ariaControls?: string | undefined
|
|
44
44
|
ariaExpanded?: boolean | undefined
|
|
45
45
|
ariaLabel?: string
|
|
46
|
-
ariaPopup?: 'dialog' | '
|
|
46
|
+
ariaPopup?: 'dialog' | 'listbox' | 'menu' | undefined
|
|
47
47
|
borderColor?: 'content' | 'default' | 'primary'
|
|
48
48
|
borderSize?: 0 | 1 | 2
|
|
49
49
|
children: Snippet
|
|
@@ -64,9 +64,11 @@ Easily replace most buttons in your project with this versatile button component
|
|
|
64
64
|
noPadding?: boolean
|
|
65
65
|
onclick?: any
|
|
66
66
|
preload?: 'hover' | 'tap'
|
|
67
|
+
rel?: string
|
|
67
68
|
role?: string
|
|
68
69
|
rounded?: 'full' | 'lg' | 'none' | 'sm'
|
|
69
70
|
target?: '_blank' | '_top' | undefined
|
|
71
|
+
title?: string
|
|
70
72
|
type?: 'submit'
|
|
71
73
|
uppercase?: boolean
|
|
72
74
|
value?: string | number
|
|
@@ -109,13 +111,13 @@ A button for toggling the mobile menu, dynamically changing its icon based on th
|
|
|
109
111
|
```TypeScript
|
|
110
112
|
interface Props {
|
|
111
113
|
ariaControls: string
|
|
112
|
-
ariaLabel: string
|
|
113
114
|
color?: 'black' | 'white'
|
|
114
115
|
extraClass?: string
|
|
115
116
|
hidden?: boolean
|
|
116
117
|
id?: string
|
|
117
118
|
onclick?: () => any
|
|
118
119
|
open: boolean
|
|
120
|
+
title: string
|
|
119
121
|
}
|
|
120
122
|
```
|
|
121
123
|
|
|
@@ -239,6 +241,10 @@ Computes the pre-tax amount by subtracting the tax from the total, using the spe
|
|
|
239
241
|
|
|
240
242
|
Calculates the tax portion of a total amount based on a given VAT percentage (default: 25.5%), ensuring precision.
|
|
241
243
|
|
|
244
|
+
### calculateWithTax
|
|
245
|
+
|
|
246
|
+
Calculates the total price by adding VAT to a pre-tax amount, using the specified VAT percentage (default: 25.5%).
|
|
247
|
+
|
|
242
248
|
### fixNumber
|
|
243
249
|
|
|
244
250
|
Converts a number or string to a rounded number with two decimal places, ensuring precision.
|
package/dist/Button.svelte
CHANGED
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
ariaControls?: string | undefined
|
|
7
7
|
ariaExpanded?: boolean | undefined
|
|
8
8
|
ariaLabel?: string
|
|
9
|
-
ariaPopup?: 'dialog' | '
|
|
9
|
+
ariaPopup?: 'dialog' | 'listbox' | 'menu' | undefined
|
|
10
10
|
borderColor?: 'content' | 'default' | 'primary'
|
|
11
11
|
borderSize?: 0 | 1 | 2
|
|
12
12
|
children: Snippet
|
|
@@ -27,9 +27,11 @@
|
|
|
27
27
|
noPadding?: boolean
|
|
28
28
|
onclick?: any
|
|
29
29
|
preload?: 'hover' | 'tap'
|
|
30
|
+
rel?: string
|
|
30
31
|
role?: string
|
|
31
32
|
rounded?: 'full' | 'lg' | 'none' | 'sm'
|
|
32
33
|
target?: '_blank' | '_top' | undefined
|
|
34
|
+
title?: string
|
|
33
35
|
type?: 'submit'
|
|
34
36
|
uppercase?: boolean
|
|
35
37
|
value?: string | number
|
|
@@ -60,9 +62,11 @@
|
|
|
60
62
|
noPadding,
|
|
61
63
|
onclick = undefined,
|
|
62
64
|
preload,
|
|
65
|
+
rel = 'noopener noreferrer',
|
|
63
66
|
role,
|
|
64
67
|
rounded = 'sm',
|
|
65
68
|
target,
|
|
69
|
+
title,
|
|
66
70
|
type,
|
|
67
71
|
uppercase = true,
|
|
68
72
|
value
|
|
@@ -114,7 +118,7 @@
|
|
|
114
118
|
</script>
|
|
115
119
|
|
|
116
120
|
{#if href}
|
|
117
|
-
<a class={classes} {href} {id} {target} data-sveltekit-preload-data={preload} rel
|
|
121
|
+
<a class={classes} {href} {id} {target} data-sveltekit-preload-data={preload} {rel} {title}>
|
|
118
122
|
{@render children?.()}
|
|
119
123
|
</a>
|
|
120
124
|
{:else if control}
|
|
@@ -122,6 +126,7 @@
|
|
|
122
126
|
{id}
|
|
123
127
|
{onclick}
|
|
124
128
|
{role}
|
|
129
|
+
{title}
|
|
125
130
|
{value}
|
|
126
131
|
aria-controls={ariaControls}
|
|
127
132
|
aria-expanded={ariaExpanded}
|
|
@@ -133,7 +138,7 @@
|
|
|
133
138
|
{@render children?.()}
|
|
134
139
|
</button>
|
|
135
140
|
{:else}
|
|
136
|
-
<button {onclick} class={classes} {disabled} {type}>
|
|
141
|
+
<button {onclick} class={classes} {disabled} {title} {type}>
|
|
137
142
|
{@render children?.()}
|
|
138
143
|
</button>
|
|
139
144
|
{/if}
|
package/dist/Button.svelte.d.ts
CHANGED
|
@@ -3,7 +3,7 @@ interface Props {
|
|
|
3
3
|
ariaControls?: string | undefined;
|
|
4
4
|
ariaExpanded?: boolean | undefined;
|
|
5
5
|
ariaLabel?: string;
|
|
6
|
-
ariaPopup?: 'dialog' | '
|
|
6
|
+
ariaPopup?: 'dialog' | 'listbox' | 'menu' | undefined;
|
|
7
7
|
borderColor?: 'content' | 'default' | 'primary';
|
|
8
8
|
borderSize?: 0 | 1 | 2;
|
|
9
9
|
children: Snippet;
|
|
@@ -24,9 +24,11 @@ interface Props {
|
|
|
24
24
|
noPadding?: boolean;
|
|
25
25
|
onclick?: any;
|
|
26
26
|
preload?: 'hover' | 'tap';
|
|
27
|
+
rel?: string;
|
|
27
28
|
role?: string;
|
|
28
29
|
rounded?: 'full' | 'lg' | 'none' | 'sm';
|
|
29
30
|
target?: '_blank' | '_top' | undefined;
|
|
31
|
+
title?: string;
|
|
30
32
|
type?: 'submit';
|
|
31
33
|
uppercase?: boolean;
|
|
32
34
|
value?: string | number;
|
package/dist/ButtonMenu.svelte
CHANGED
|
@@ -2,22 +2,22 @@
|
|
|
2
2
|
import Button from './Button.svelte'
|
|
3
3
|
interface Props {
|
|
4
4
|
ariaControls: string
|
|
5
|
-
ariaLabel: string
|
|
6
5
|
color?: 'black' | 'white'
|
|
7
6
|
extraClass?: string
|
|
8
7
|
hidden?: boolean
|
|
9
8
|
id?: string
|
|
10
9
|
onclick?: () => any
|
|
11
10
|
open: boolean
|
|
11
|
+
title: string
|
|
12
12
|
}
|
|
13
|
-
let {ariaControls,
|
|
13
|
+
let {ariaControls, title, color = 'white', extraClass, hidden = false, id, open = $bindable()}: Props = $props()
|
|
14
14
|
const handleOpen = () => {
|
|
15
15
|
open = !open
|
|
16
16
|
}
|
|
17
17
|
</script>
|
|
18
18
|
|
|
19
19
|
<div id="menu-button" class={extraClass} class:hidden>
|
|
20
|
-
<Button onclick={handleOpen} {ariaControls} ariaPopup="menu" ariaExpanded={open} {
|
|
20
|
+
<Button onclick={handleOpen} {ariaControls} ariaPopup="menu" ariaExpanded={open} {title} {color} control fill {id}>
|
|
21
21
|
<svg
|
|
22
22
|
fill={color}
|
|
23
23
|
clip-rule="evenodd"
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
interface Props {
|
|
2
2
|
ariaControls: string;
|
|
3
|
-
ariaLabel: string;
|
|
4
3
|
color?: 'black' | 'white';
|
|
5
4
|
extraClass?: string;
|
|
6
5
|
hidden?: boolean;
|
|
7
6
|
id?: string;
|
|
8
7
|
onclick?: () => any;
|
|
9
8
|
open: boolean;
|
|
9
|
+
title: string;
|
|
10
10
|
}
|
|
11
11
|
declare const ButtonMenu: import("svelte").Component<Props, {}, "open">;
|
|
12
12
|
type ButtonMenu = ReturnType<typeof ButtonMenu>;
|
package/dist/Input.svelte
CHANGED
|
@@ -38,8 +38,6 @@
|
|
|
38
38
|
value = $bindable()
|
|
39
39
|
}: Props = $props()
|
|
40
40
|
|
|
41
|
-
let isDisabled = $state(disabled || $loading)
|
|
42
|
-
|
|
43
41
|
let classes = $state('')
|
|
44
42
|
if (inputClass) {
|
|
45
43
|
classes = inputClass
|
|
@@ -56,10 +54,18 @@
|
|
|
56
54
|
{label}{#if required}<sup>*</sup>{/if}
|
|
57
55
|
|
|
58
56
|
{#if type === 'textarea'}
|
|
59
|
-
<textarea
|
|
57
|
+
<textarea
|
|
58
|
+
bind:value
|
|
59
|
+
class={classes}
|
|
60
|
+
disabled={disabled || $loading}
|
|
61
|
+
{id}
|
|
62
|
+
maxlength={max ? Number(max) : undefined}
|
|
63
|
+
{required}
|
|
64
|
+
{placeholder}
|
|
65
|
+
rows={4}
|
|
60
66
|
></textarea>
|
|
61
67
|
{:else if ['date', 'number'].includes(type)}
|
|
62
|
-
<input bind:value class={classes} disabled={
|
|
68
|
+
<input bind:value class={classes} disabled={disabled || $loading} lang="fi-FI" {max} {min} {onchange} {required} {step} {type} {placeholder} />
|
|
63
69
|
{:else}
|
|
64
70
|
<input
|
|
65
71
|
bind:value
|
|
@@ -68,7 +74,7 @@
|
|
|
68
74
|
{required}
|
|
69
75
|
{type}
|
|
70
76
|
class={classes}
|
|
71
|
-
disabled={
|
|
77
|
+
disabled={disabled || $loading}
|
|
72
78
|
maxlength={max ? Number(max) : undefined}
|
|
73
79
|
minlength={min ? Number(min) : undefined}
|
|
74
80
|
onkeyup={onchange}
|
package/dist/index.d.ts
CHANGED
|
@@ -31,8 +31,9 @@ export declare const loading: import("svelte/store").Writable<number>;
|
|
|
31
31
|
*/
|
|
32
32
|
export declare const formatPrice: (value: number | string, comma?: boolean, currency?: string) => string;
|
|
33
33
|
export declare const fixNumber: (value: number | string) => number;
|
|
34
|
-
export declare const calculateTax: (
|
|
35
|
-
export declare const calculatePreTax: (
|
|
34
|
+
export declare const calculateTax: (value: number, vatPercentage?: number) => number;
|
|
35
|
+
export declare const calculatePreTax: (value: number, vatPercentage?: number) => number;
|
|
36
|
+
export declare const calculateWithTax: (value: number, vatPercentage?: number) => number;
|
|
36
37
|
/**
|
|
37
38
|
* STRING VALIDATIONS
|
|
38
39
|
*/
|
package/dist/index.js
CHANGED
|
@@ -42,8 +42,9 @@ export const fixNumber = (value) => {
|
|
|
42
42
|
* VAT CALCULATION
|
|
43
43
|
*/
|
|
44
44
|
const defaultVatPercentage = 25.5;
|
|
45
|
-
export const calculateTax = (
|
|
46
|
-
export const calculatePreTax = (
|
|
45
|
+
export const calculateTax = (value, vatPercentage = defaultVatPercentage) => fixNumber((vatPercentage * value) / (100 + vatPercentage));
|
|
46
|
+
export const calculatePreTax = (value, vatPercentage = defaultVatPercentage) => fixNumber(value - calculateTax(value, vatPercentage));
|
|
47
|
+
export const calculateWithTax = (value, vatPercentage = defaultVatPercentage) => fixNumber(value * (1 + vatPercentage / 100));
|
|
47
48
|
/**
|
|
48
49
|
* STRING VALIDATIONS
|
|
49
50
|
*/
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tuspe/components",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.8.1",
|
|
4
4
|
"description": "A reusable SvelteKit component library for form elements, breadcrumbs, prices and images.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"svelteKit",
|
|
@@ -61,21 +61,21 @@
|
|
|
61
61
|
},
|
|
62
62
|
"devDependencies": {
|
|
63
63
|
"@eslint/compat": "^1.2.7",
|
|
64
|
-
"@eslint/js": "^9.
|
|
64
|
+
"@eslint/js": "^9.23.0",
|
|
65
65
|
"@sveltejs/adapter-static": "^3.0.8",
|
|
66
|
-
"@sveltejs/kit": "^2.
|
|
66
|
+
"@sveltejs/kit": "^2.20.2",
|
|
67
67
|
"@sveltejs/package": "^2.3.10",
|
|
68
68
|
"@sveltejs/vite-plugin-svelte": "^5.0.3",
|
|
69
69
|
"eslint-config-prettier": "^10.1.1",
|
|
70
|
-
"eslint-plugin-svelte": "^3.
|
|
71
|
-
"eslint": "^9.
|
|
70
|
+
"eslint-plugin-svelte": "^3.3.3",
|
|
71
|
+
"eslint": "^9.23.0",
|
|
72
72
|
"globals": "^16.0.0",
|
|
73
73
|
"prettier-plugin-svelte": "^3.3.3",
|
|
74
74
|
"prettier": "^3.5.3",
|
|
75
75
|
"publint": "^0.3.9",
|
|
76
76
|
"svelte-check": "^4.1.5",
|
|
77
|
-
"svelte": "^5.
|
|
78
|
-
"typescript-eslint": "^8.
|
|
77
|
+
"svelte": "^5.25.2",
|
|
78
|
+
"typescript-eslint": "^8.27.0",
|
|
79
79
|
"typescript": "^5.8.2",
|
|
80
80
|
"vite": "^6.2.2"
|
|
81
81
|
}
|