@tuspe/components 1.7.3 → 1.7.5
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 +11 -2
- package/dist/ButtonClose.svelte +13 -4
- package/dist/ButtonClose.svelte.d.ts +7 -3
- package/dist/Image.svelte +12 -2
- package/dist/Image.svelte.d.ts +1 -0
- package/dist/Modal.svelte +31 -9
- package/dist/Modal.svelte.d.ts +5 -0
- package/package.json +3 -2
package/README.md
CHANGED
|
@@ -79,8 +79,11 @@ Close button for modals and other dismissible elements.
|
|
|
79
79
|
|
|
80
80
|
```TypeScript
|
|
81
81
|
interface Props {
|
|
82
|
-
|
|
82
|
+
ariaLabel?: string
|
|
83
83
|
color?: string
|
|
84
|
+
hover?: 'black' | 'primary' | 'secondary' | 'success' | 'transparent'
|
|
85
|
+
hoverText?: 'black' | 'primary' | 'secondary' | 'white'
|
|
86
|
+
onclick: () => any
|
|
84
87
|
}
|
|
85
88
|
```
|
|
86
89
|
|
|
@@ -113,6 +116,7 @@ A versatile image component supporting various aspect ratios and object fit opti
|
|
|
113
116
|
}
|
|
114
117
|
|
|
115
118
|
interface Props {
|
|
119
|
+
ariaHidden?: boolean
|
|
116
120
|
aspect?: '3:4' | '4:3' | 'square' | 'video'
|
|
117
121
|
ball?: boolean
|
|
118
122
|
border?: boolean
|
|
@@ -195,10 +199,15 @@ A simple `Modal` component that displays a popup with customizable content.
|
|
|
195
199
|
```TypeScript
|
|
196
200
|
interface Props {
|
|
197
201
|
children: Snippet
|
|
202
|
+
buttonAriaLabel?: string
|
|
203
|
+
colorButton?: string
|
|
204
|
+
colorBg?: string
|
|
205
|
+
headerClass?: string
|
|
198
206
|
innerClass?: string
|
|
199
207
|
open?: boolean
|
|
200
208
|
outerClass?: string
|
|
201
209
|
title?: string
|
|
210
|
+
titleClass?: string
|
|
202
211
|
}
|
|
203
212
|
```
|
|
204
213
|
|
|
@@ -224,7 +233,7 @@ Formats a number or string as a price with two decimal places, spaces as thousan
|
|
|
224
233
|
|
|
225
234
|
Retrieves or stores values in the cache; keys are slugified, and values are updated or returned if they exist. This ensures that `+page.ts` and other pages only retrieve data from the backend once and that the WordPress frontend uses the product list data on the product page without retrieving the same page again.
|
|
226
235
|
|
|
227
|
-
|
|
236
|
+
### preventDefault
|
|
228
237
|
|
|
229
238
|
Previously, Svelte handled form submission without reloading the page. However, the `preventDefault` function is no longer supported by Svelte v5, so this function handles form submission without loading the page.
|
|
230
239
|
|
package/dist/ButtonClose.svelte
CHANGED
|
@@ -1,12 +1,21 @@
|
|
|
1
1
|
<script lang="ts">
|
|
2
2
|
import Button from './Button.svelte'
|
|
3
|
-
|
|
3
|
+
|
|
4
|
+
interface Props {
|
|
5
|
+
ariaLabel?: string
|
|
6
|
+
color?: string
|
|
7
|
+
hover?: 'black' | 'primary' | 'secondary' | 'success' | 'transparent'
|
|
8
|
+
hoverText?: 'black' | 'primary' | 'secondary' | 'white'
|
|
9
|
+
onclick?: any
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
let {ariaLabel, color = 'white', hover = 'transparent', onclick}: Props = $props()
|
|
4
13
|
</script>
|
|
5
14
|
|
|
6
15
|
<div class="close-button">
|
|
7
|
-
<Button {color} {onclick} control fill>
|
|
8
|
-
<svg xmlns="http://www.w3.org/2000/svg" width="32" height="32" viewBox="0 0 24 24">
|
|
9
|
-
<title>
|
|
16
|
+
<Button {ariaLabel} {color} {onclick} control fill {hover}>
|
|
17
|
+
<svg xmlns="http://www.w3.org/2000/svg" width="32" height="32" viewBox="0 0 24 24" aria-hidden="true">
|
|
18
|
+
<title>Close</title>
|
|
10
19
|
<path
|
|
11
20
|
d="M12 2c5.514 0 10 4.486 10 10s-4.486 10-10 10-10-4.486-10-10 4.486-10 10-10zm0-2c-6.627 0-12 5.373-12 12s5.373 12 12 12 12-5.373 12-12-5.373-12-12-12zm5 15.538l-3.592-3.548 3.546-3.587-1.416-1.403-3.545 3.589-3.588-3.543-1.405 1.405 3.593 3.552-3.547 3.592 1.405 1.405 3.555-3.596 3.591 3.55 1.403-1.416z"
|
|
12
21
|
/>
|
|
@@ -1,6 +1,10 @@
|
|
|
1
|
-
|
|
1
|
+
interface Props {
|
|
2
|
+
ariaLabel?: string;
|
|
2
3
|
color?: string;
|
|
3
|
-
|
|
4
|
-
|
|
4
|
+
hover?: 'black' | 'primary' | 'secondary' | 'success' | 'transparent';
|
|
5
|
+
hoverText?: 'black' | 'primary' | 'secondary' | 'white';
|
|
6
|
+
onclick?: any;
|
|
7
|
+
}
|
|
8
|
+
declare const ButtonClose: import("svelte").Component<Props, {}, "">;
|
|
5
9
|
type ButtonClose = ReturnType<typeof ButtonClose>;
|
|
6
10
|
export default ButtonClose;
|
package/dist/Image.svelte
CHANGED
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
import type {ImageData} from './'
|
|
3
3
|
|
|
4
4
|
interface Props {
|
|
5
|
+
ariaHidden?: boolean
|
|
5
6
|
aspect?: '3:4' | '4:3' | 'square' | 'video'
|
|
6
7
|
ball?: boolean
|
|
7
8
|
border?: boolean
|
|
@@ -13,7 +14,7 @@
|
|
|
13
14
|
objectFit?: 'contain' | 'cover'
|
|
14
15
|
}
|
|
15
16
|
|
|
16
|
-
let {aspect, ball = false, border, center = false, extraClasses, fullWidth, image, loading = 'lazy', objectFit}: Props = $props()
|
|
17
|
+
let {ariaHidden, aspect, ball = false, border, center = false, extraClasses, fullWidth, image, loading = 'lazy', objectFit}: Props = $props()
|
|
17
18
|
|
|
18
19
|
let classes = $state('')
|
|
19
20
|
if (aspect) {
|
|
@@ -40,7 +41,16 @@
|
|
|
40
41
|
</script>
|
|
41
42
|
|
|
42
43
|
{#if image?.src}
|
|
43
|
-
<img
|
|
44
|
+
<img
|
|
45
|
+
{loading}
|
|
46
|
+
alt={image.alt}
|
|
47
|
+
aria-hidden={ariaHidden}
|
|
48
|
+
class={classes}
|
|
49
|
+
decoding="async"
|
|
50
|
+
height={image.height}
|
|
51
|
+
src={image.src}
|
|
52
|
+
width={image.width}
|
|
53
|
+
/>
|
|
44
54
|
{/if}
|
|
45
55
|
|
|
46
56
|
<style scoped>
|
package/dist/Image.svelte.d.ts
CHANGED
package/dist/Modal.svelte
CHANGED
|
@@ -3,24 +3,45 @@
|
|
|
3
3
|
import ButtonClose from './ButtonClose.svelte'
|
|
4
4
|
interface Props {
|
|
5
5
|
children: Snippet
|
|
6
|
+
buttonAriaLabel?: string
|
|
7
|
+
colorButton?: string
|
|
8
|
+
colorBg?: string
|
|
9
|
+
headerClass?: string
|
|
6
10
|
innerClass?: string
|
|
7
11
|
open?: boolean
|
|
8
12
|
outerClass?: string
|
|
9
13
|
title?: string
|
|
14
|
+
titleClass?: string
|
|
10
15
|
}
|
|
11
|
-
let {
|
|
16
|
+
let {
|
|
17
|
+
children,
|
|
18
|
+
buttonAriaLabel,
|
|
19
|
+
colorButton = 'white',
|
|
20
|
+
colorBg = 'white',
|
|
21
|
+
headerClass = 'bg-primary',
|
|
22
|
+
innerClass,
|
|
23
|
+
open = $bindable(),
|
|
24
|
+
outerClass,
|
|
25
|
+
title,
|
|
26
|
+
titleClass
|
|
27
|
+
}: Props = $props()
|
|
12
28
|
const handleClose = () => {
|
|
13
29
|
open = false
|
|
14
30
|
}
|
|
31
|
+
|
|
32
|
+
let contentClass = $state('bg-' + colorBg)
|
|
33
|
+
if (outerClass) {
|
|
34
|
+
contentClass += ' ' + outerClass
|
|
35
|
+
}
|
|
15
36
|
</script>
|
|
16
37
|
|
|
17
38
|
<div id="modal" class:hidden={!open}>
|
|
18
|
-
<div id="modal-content" class={
|
|
19
|
-
<header>
|
|
39
|
+
<div id="modal-content" class={contentClass} aria-live="polite">
|
|
40
|
+
<header class={headerClass}>
|
|
20
41
|
{#if title}
|
|
21
|
-
<h2>{title}</h2>
|
|
42
|
+
<h2 class={titleClass}>{title}</h2>
|
|
22
43
|
{/if}
|
|
23
|
-
<ButtonClose
|
|
44
|
+
<ButtonClose ariaLabel={buttonAriaLabel} onclick={handleClose} color={colorButton} hover="transparent" />
|
|
24
45
|
</header>
|
|
25
46
|
<div id="modal-body" class={innerClass}>
|
|
26
47
|
{@render children?.()}
|
|
@@ -47,21 +68,22 @@
|
|
|
47
68
|
display: none;
|
|
48
69
|
visibility: hidden;
|
|
49
70
|
}
|
|
71
|
+
#modal header.bg-primary {
|
|
72
|
+
background-color: var(--color-primary);
|
|
73
|
+
}
|
|
50
74
|
#modal-content {
|
|
51
|
-
background-color: #fff;
|
|
52
75
|
border-radius: 1rem;
|
|
53
76
|
border: 2px solid var(--color-primary);
|
|
54
|
-
|
|
77
|
+
color: var(--color-content);
|
|
55
78
|
margin-left: auto;
|
|
56
79
|
margin-right: auto;
|
|
57
|
-
max-height: 85vh;
|
|
58
80
|
max-width: 95vw;
|
|
59
81
|
overflow: hidden;
|
|
60
82
|
overscroll-behavior: contain;
|
|
61
83
|
position: relative;
|
|
62
84
|
}
|
|
63
85
|
#modal-body {
|
|
64
|
-
max-height:
|
|
86
|
+
max-height: 70vh;
|
|
65
87
|
overflow-x: hidden;
|
|
66
88
|
overflow-y: auto;
|
|
67
89
|
padding: 1rem;
|
package/dist/Modal.svelte.d.ts
CHANGED
|
@@ -1,10 +1,15 @@
|
|
|
1
1
|
import type { Snippet } from 'svelte';
|
|
2
2
|
interface Props {
|
|
3
3
|
children: Snippet;
|
|
4
|
+
buttonAriaLabel?: string;
|
|
5
|
+
colorButton?: string;
|
|
6
|
+
colorBg?: string;
|
|
7
|
+
headerClass?: string;
|
|
4
8
|
innerClass?: string;
|
|
5
9
|
open?: boolean;
|
|
6
10
|
outerClass?: string;
|
|
7
11
|
title?: string;
|
|
12
|
+
titleClass?: string;
|
|
8
13
|
}
|
|
9
14
|
declare const Modal: import("svelte").Component<Props, {}, "open">;
|
|
10
15
|
type Modal = ReturnType<typeof Modal>;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tuspe/components",
|
|
3
|
-
"version": "1.7.
|
|
3
|
+
"version": "1.7.5",
|
|
4
4
|
"description": "A reusable SvelteKit component library for form elements, breadcrumbs, prices and images.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"svelteKit",
|
|
@@ -14,7 +14,8 @@
|
|
|
14
14
|
"input",
|
|
15
15
|
"checkbox",
|
|
16
16
|
"select",
|
|
17
|
-
"preventDefault"
|
|
17
|
+
"preventDefault",
|
|
18
|
+
"validation"
|
|
18
19
|
],
|
|
19
20
|
"homepage": "https://github.com/TuspeDesign/svelte-components",
|
|
20
21
|
"license": "MIT",
|