@tuspe/components 1.9.8 → 1.9.10
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/Breadcrumbs.svelte +4 -12
- package/dist/Button.svelte +6 -95
- package/dist/Checkbox.svelte +6 -20
- package/dist/Image.svelte +5 -46
- package/dist/Input.svelte +16 -91
- package/dist/Modal.svelte +4 -14
- package/dist/Select.svelte +16 -30
- package/dist/index.d.ts +8 -0
- package/dist/index.js +12 -4
- package/dist/types.d.ts +3 -5
- package/package.json +18 -18
package/dist/Breadcrumbs.svelte
CHANGED
|
@@ -1,16 +1,14 @@
|
|
|
1
1
|
<script lang="ts">
|
|
2
2
|
import {page} from '$app/state'
|
|
3
|
-
import {
|
|
4
|
-
import {validateArray} from './'
|
|
3
|
+
import {cx, validateArray} from './'
|
|
5
4
|
import type {Breadcrumb} from './'
|
|
6
5
|
import type {BreadcrumbView} from './types'
|
|
7
6
|
|
|
8
7
|
let {homeName = 'Etusivu', homeSlug = '', onlyMeta = false, outerClass, values}: BreadcrumbView = $props()
|
|
9
|
-
let classes = $
|
|
8
|
+
let classes = $derived(cx('truncate', outerClass))
|
|
10
9
|
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
let originWithSlug = $state(origin + homeSlug),
|
|
10
|
+
let origin = $derived(page.url.origin + '/'),
|
|
11
|
+
originWithSlug = $derived(origin + homeSlug),
|
|
14
12
|
listItems = $derived<Breadcrumb[]>(
|
|
15
13
|
validateArray(values)
|
|
16
14
|
? [
|
|
@@ -34,12 +32,6 @@
|
|
|
34
32
|
? `<script type="application/ld+json">{"@context":"https://schema.org","@type":"BreadcrumbList","itemListElement":${JSON.stringify(listItems)}}${'<'}/script>`
|
|
35
33
|
: ''
|
|
36
34
|
)
|
|
37
|
-
|
|
38
|
-
onMount(() => {
|
|
39
|
-
if (outerClass) {
|
|
40
|
-
classes += ` ${outerClass}`
|
|
41
|
-
}
|
|
42
|
-
})
|
|
43
35
|
</script>
|
|
44
36
|
|
|
45
37
|
<svelte:head>
|
package/dist/Button.svelte
CHANGED
|
@@ -1,87 +1,10 @@
|
|
|
1
1
|
<script lang="ts">
|
|
2
|
-
import {loading} from './'
|
|
2
|
+
import {cx, loading} from './'
|
|
3
3
|
import type {ButtonView} from './types'
|
|
4
4
|
|
|
5
|
-
let {
|
|
6
|
-
ariaControls,
|
|
7
|
-
ariaExpanded,
|
|
8
|
-
ariaLabel,
|
|
9
|
-
ariaPopup,
|
|
10
|
-
borderColor = 'content',
|
|
11
|
-
borderSize = 0,
|
|
12
|
-
children,
|
|
13
|
-
color = 'white',
|
|
14
|
-
colorBg = 'primary',
|
|
15
|
-
control,
|
|
16
|
-
disabled = $bindable(),
|
|
17
|
-
extraClass,
|
|
18
|
-
fill,
|
|
19
|
-
fontWeight = 'bold',
|
|
20
|
-
fullWidth,
|
|
21
|
-
hover = 'secondary',
|
|
22
|
-
hoverText = 'white',
|
|
23
|
-
href,
|
|
24
|
-
id,
|
|
25
|
-
noCenter = false,
|
|
26
|
-
noHeight,
|
|
27
|
-
noPadding,
|
|
28
|
-
noSpinner,
|
|
29
|
-
onclick = undefined,
|
|
30
|
-
preload,
|
|
31
|
-
rel = 'noopener noreferrer',
|
|
32
|
-
role,
|
|
33
|
-
rounded = 'sm',
|
|
34
|
-
spinnerColor = 'white',
|
|
35
|
-
target,
|
|
36
|
-
title,
|
|
37
|
-
type,
|
|
38
|
-
uppercase = true,
|
|
39
|
-
value
|
|
40
|
-
}: ButtonView = $props()
|
|
5
|
+
let {ariaControls, ariaExpanded, ariaLabel, ariaPopup, borderColor = 'content', borderSize = 0, children, color = 'white', colorBg = 'primary', control, disabled = $bindable(), extraClass, fill, fontWeight = 'bold', fullWidth, hover = 'secondary', hoverText = 'white', href, id, noCenter = false, noHeight, noPadding, noSpinner, onclick = undefined, preload, rel = 'noopener noreferrer', role, rounded = 'sm', spinnerColor = 'white', target, title, type, uppercase = true, value}: ButtonView = $props()
|
|
41
6
|
|
|
42
|
-
let classes = $
|
|
43
|
-
|
|
44
|
-
if (control) {
|
|
45
|
-
classes += ' control'
|
|
46
|
-
} else {
|
|
47
|
-
classes += ' bg-' + colorBg
|
|
48
|
-
}
|
|
49
|
-
if (borderSize) {
|
|
50
|
-
classes += ' border-solid border-' + borderSize + ' border-' + borderColor
|
|
51
|
-
}
|
|
52
|
-
if (extraClass) {
|
|
53
|
-
classes += ' ' + extraClass
|
|
54
|
-
}
|
|
55
|
-
if (fill) {
|
|
56
|
-
classes += ' fill'
|
|
57
|
-
}
|
|
58
|
-
if (fontWeight) {
|
|
59
|
-
classes += ' font-' + fontWeight
|
|
60
|
-
}
|
|
61
|
-
if (fullWidth) {
|
|
62
|
-
classes += ' w-full'
|
|
63
|
-
}
|
|
64
|
-
if (hover) {
|
|
65
|
-
classes += ' hover-' + hover
|
|
66
|
-
}
|
|
67
|
-
if (hoverText) {
|
|
68
|
-
classes += ' hover-text-' + hoverText
|
|
69
|
-
}
|
|
70
|
-
if (!noCenter) {
|
|
71
|
-
classes += ' center'
|
|
72
|
-
}
|
|
73
|
-
if (noHeight) {
|
|
74
|
-
classes += ' no-height'
|
|
75
|
-
}
|
|
76
|
-
if (noPadding) {
|
|
77
|
-
classes += ' no-padding'
|
|
78
|
-
}
|
|
79
|
-
if (rounded) {
|
|
80
|
-
classes += ' radius-' + rounded
|
|
81
|
-
}
|
|
82
|
-
if (uppercase) {
|
|
83
|
-
classes += ' uppercase'
|
|
84
|
-
}
|
|
7
|
+
let classes = $derived(cx('btn', `text-${color}`, control ? 'control' : `bg-${colorBg}`, borderSize ? `border-solid border-${borderSize} border-${borderColor}` : false, extraClass, fill && 'fill', fontWeight && `font-${fontWeight}`, fullWidth && 'w-full', hover && `hover-${hover}`, hoverText && `hover-text-${hoverText}`, !noCenter && 'center', noHeight && 'no-height', noPadding && 'no-padding', rounded && `radius-${rounded}`, uppercase && 'uppercase'))
|
|
85
8
|
</script>
|
|
86
9
|
|
|
87
10
|
{#if href}
|
|
@@ -89,19 +12,7 @@
|
|
|
89
12
|
{@render children?.()}
|
|
90
13
|
</a>
|
|
91
14
|
{:else if control}
|
|
92
|
-
<button
|
|
93
|
-
{id}
|
|
94
|
-
{onclick}
|
|
95
|
-
{role}
|
|
96
|
-
{title}
|
|
97
|
-
{value}
|
|
98
|
-
aria-controls={ariaControls}
|
|
99
|
-
aria-expanded={ariaExpanded}
|
|
100
|
-
aria-haspopup={ariaPopup}
|
|
101
|
-
aria-label={ariaLabel}
|
|
102
|
-
class={classes}
|
|
103
|
-
{disabled}
|
|
104
|
-
>
|
|
15
|
+
<button {id} {onclick} {role} {title} {value} aria-controls={ariaControls} aria-expanded={ariaExpanded} aria-haspopup={ariaPopup} aria-label={ariaLabel} class={classes} {disabled}>
|
|
105
16
|
{@render children?.()}
|
|
106
17
|
</button>
|
|
107
18
|
{:else}
|
|
@@ -153,11 +64,11 @@
|
|
|
153
64
|
}
|
|
154
65
|
.bg-success:not(:hover),
|
|
155
66
|
.hover-success:hover {
|
|
156
|
-
background-color: green;
|
|
67
|
+
background-color: var(--color-success, green);
|
|
157
68
|
}
|
|
158
69
|
.bg-danger:not(:hover),
|
|
159
70
|
.hover-danger:hover {
|
|
160
|
-
background-color: darkred;
|
|
71
|
+
background-color: var(--color-danger, darkred);
|
|
161
72
|
}
|
|
162
73
|
.bg-black:not(:hover),
|
|
163
74
|
.hover-black:hover {
|
package/dist/Checkbox.svelte
CHANGED
|
@@ -1,26 +1,12 @@
|
|
|
1
1
|
<script lang="ts">
|
|
2
|
-
import {loading} from './'
|
|
2
|
+
import {cx, isDisabled, loading} from './'
|
|
3
3
|
import type {CheckboxView} from './types'
|
|
4
|
-
let {
|
|
5
|
-
|
|
6
|
-
onchange,
|
|
7
|
-
checked = $bindable(false),
|
|
8
|
-
disabled = $bindable(false),
|
|
9
|
-
group = $bindable(),
|
|
10
|
-
id,
|
|
11
|
-
outerClass,
|
|
12
|
-
required,
|
|
13
|
-
value,
|
|
14
|
-
...props
|
|
15
|
-
}: CheckboxView = $props()
|
|
16
|
-
let classes = $state('input-checkbox')
|
|
17
|
-
if (outerClass) {
|
|
18
|
-
classes += ` ${outerClass}`
|
|
19
|
-
}
|
|
4
|
+
let {children, onchange, checked = $bindable(false), disabled = $bindable(false), group = $bindable(), id, outerClass, required, value, ...props}: CheckboxView = $props()
|
|
5
|
+
let classes = $derived(cx('input-checkbox', outerClass))
|
|
20
6
|
</script>
|
|
21
7
|
|
|
22
8
|
<label class={classes}>
|
|
23
|
-
<input bind:checked disabled={disabled
|
|
9
|
+
<input bind:checked disabled={isDisabled(disabled, $loading)} {id} {onchange} {required} type="checkbox" {value} {...props} />
|
|
24
10
|
<span>
|
|
25
11
|
{@render children?.()}
|
|
26
12
|
{#if required}<sup>*</sup>{/if}
|
|
@@ -30,7 +16,7 @@
|
|
|
30
16
|
<style scoped>
|
|
31
17
|
input {
|
|
32
18
|
accent-color: var(--color-primary);
|
|
33
|
-
border: 1px solid var(--color-border);
|
|
19
|
+
border: 1px solid var(--color-border, #999);
|
|
34
20
|
height: 20px;
|
|
35
21
|
margin-top: 3px;
|
|
36
22
|
outline: none;
|
|
@@ -56,6 +42,6 @@
|
|
|
56
42
|
}
|
|
57
43
|
|
|
58
44
|
sup {
|
|
59
|
-
color: darkred;
|
|
45
|
+
color: var(--color-danger, darkred);
|
|
60
46
|
}
|
|
61
47
|
</style>
|
package/dist/Image.svelte
CHANGED
|
@@ -1,54 +1,13 @@
|
|
|
1
1
|
<script lang="ts">
|
|
2
|
+
import {cx} from './'
|
|
2
3
|
import type {ImageView} from './types'
|
|
3
|
-
let {
|
|
4
|
-
ariaHidden,
|
|
5
|
-
aspect,
|
|
6
|
-
ball = false,
|
|
7
|
-
border,
|
|
8
|
-
center = false,
|
|
9
|
-
display = 'inline-block',
|
|
10
|
-
extraClasses,
|
|
11
|
-
fullWidth,
|
|
12
|
-
image,
|
|
13
|
-
loading = 'lazy',
|
|
14
|
-
objectFit
|
|
15
|
-
}: ImageView = $props()
|
|
4
|
+
let {ariaHidden, aspect, ball = false, border, center = false, display = 'inline-block', extraClasses, fullWidth, image, loading = 'lazy', objectFit}: ImageView = $props()
|
|
16
5
|
|
|
17
|
-
let classes = $
|
|
18
|
-
if (aspect) {
|
|
19
|
-
classes += ` aspect-${aspect}`
|
|
20
|
-
}
|
|
21
|
-
if (objectFit) {
|
|
22
|
-
classes += ' ' + objectFit
|
|
23
|
-
}
|
|
24
|
-
if (ball) {
|
|
25
|
-
classes += ' radius-full'
|
|
26
|
-
}
|
|
27
|
-
if (border) {
|
|
28
|
-
classes += ' border-full'
|
|
29
|
-
}
|
|
30
|
-
if (center) {
|
|
31
|
-
classes += ' mx-auto'
|
|
32
|
-
}
|
|
33
|
-
if (fullWidth) {
|
|
34
|
-
classes += ' full'
|
|
35
|
-
}
|
|
36
|
-
if (extraClasses) {
|
|
37
|
-
classes += ' ' + extraClasses
|
|
38
|
-
}
|
|
6
|
+
let classes = $derived(cx(display, aspect && `aspect-${aspect}`, objectFit, ball && 'radius-full', border && 'border-full', center && 'mx-auto', fullWidth && 'full', extraClasses))
|
|
39
7
|
</script>
|
|
40
8
|
|
|
41
9
|
{#if image?.src}
|
|
42
|
-
<img
|
|
43
|
-
{loading}
|
|
44
|
-
alt={image.alt}
|
|
45
|
-
aria-hidden={ariaHidden}
|
|
46
|
-
class={classes}
|
|
47
|
-
decoding="async"
|
|
48
|
-
height={image.height}
|
|
49
|
-
src={image.src}
|
|
50
|
-
width={image.width}
|
|
51
|
-
/>
|
|
10
|
+
<img {loading} alt={image.alt} aria-hidden={ariaHidden} class={classes} decoding="async" height={image.height} src={image.src} width={image.width} />
|
|
52
11
|
{/if}
|
|
53
12
|
|
|
54
13
|
<style scoped>
|
|
@@ -72,7 +31,7 @@
|
|
|
72
31
|
display: block;
|
|
73
32
|
}
|
|
74
33
|
.border-full {
|
|
75
|
-
border: 1px solid var(--color-content);
|
|
34
|
+
border: 1px solid var(--color-content, #222);
|
|
76
35
|
}
|
|
77
36
|
.contain {
|
|
78
37
|
object-fit: contain;
|
package/dist/Input.svelte
CHANGED
|
@@ -1,101 +1,26 @@
|
|
|
1
1
|
<script lang="ts">
|
|
2
|
-
import {loading} from './'
|
|
2
|
+
import {cx, isDisabled, loading} from './'
|
|
3
3
|
import type {InputView} from './types'
|
|
4
4
|
|
|
5
|
-
let {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
inputClass,
|
|
11
|
-
label,
|
|
12
|
-
max,
|
|
13
|
-
min,
|
|
14
|
-
onchange,
|
|
15
|
-
outerClass,
|
|
16
|
-
placeholder,
|
|
17
|
-
required = false,
|
|
18
|
-
step,
|
|
19
|
-
type = 'text',
|
|
20
|
-
value = $bindable(),
|
|
21
|
-
...props
|
|
22
|
-
}: InputView = $props()
|
|
23
|
-
|
|
24
|
-
let classesIn = $state(''),
|
|
25
|
-
classesOut = $state(`input-${type}`)
|
|
26
|
-
if (inputClass) {
|
|
27
|
-
classesIn = inputClass
|
|
28
|
-
}
|
|
29
|
-
if (bgColor && bgColor !== 'none') {
|
|
30
|
-
classesIn += ` bg-${bgColor}`
|
|
31
|
-
}
|
|
32
|
-
if (borderColor && borderColor !== 'none') {
|
|
33
|
-
classesIn += ` border-color-${borderColor}`
|
|
34
|
-
}
|
|
35
|
-
if (outerClass) {
|
|
36
|
-
classesOut += ` ${outerClass}`
|
|
37
|
-
}
|
|
5
|
+
let {bgColor = 'transparent', borderColor = 'default', disabled, id, inputClass, label, max, min, onchange, outerClass, placeholder, required = false, step, type = 'text', value = $bindable(), ...props}: InputView = $props()
|
|
6
|
+
|
|
7
|
+
let classesIn = $derived(cx(inputClass, bgColor !== 'none' && `bg-${bgColor}`, borderColor !== 'none' && `border-color-${borderColor}`)),
|
|
8
|
+
classesOut = $derived(cx(`input-${type}`, outerClass)),
|
|
9
|
+
inputDisabled = $derived(isDisabled(disabled, $loading))
|
|
38
10
|
</script>
|
|
39
11
|
|
|
40
12
|
<label class={classesOut}>
|
|
41
13
|
{label}{#if required}<sup>*</sup>{/if}
|
|
42
14
|
|
|
43
15
|
{#if type === 'textarea'}
|
|
44
|
-
<textarea
|
|
45
|
-
bind:value
|
|
46
|
-
class={classesIn}
|
|
47
|
-
disabled={disabled || $loading ? true : false}
|
|
48
|
-
{id}
|
|
49
|
-
maxlength={max ? Number(max) : undefined}
|
|
50
|
-
{required}
|
|
51
|
-
{placeholder}
|
|
52
|
-
rows={4}
|
|
53
|
-
{...props}
|
|
54
|
-
></textarea>
|
|
16
|
+
<textarea bind:value class={classesIn} disabled={inputDisabled} {id} maxlength={max ? Number(max) : undefined} {required} {placeholder} rows={4} {...props}></textarea>
|
|
55
17
|
{:else if ['date', 'number'].includes(type)}
|
|
56
|
-
<input
|
|
57
|
-
bind:value
|
|
58
|
-
class={classesIn}
|
|
59
|
-
disabled={disabled || $loading ? true : false}
|
|
60
|
-
lang="fi-FI"
|
|
61
|
-
{max}
|
|
62
|
-
{min}
|
|
63
|
-
{onchange}
|
|
64
|
-
{required}
|
|
65
|
-
{step}
|
|
66
|
-
{type}
|
|
67
|
-
{placeholder}
|
|
68
|
-
{...props}
|
|
69
|
-
/>
|
|
18
|
+
<input bind:value class={classesIn} disabled={inputDisabled} lang="fi-FI" {max} {min} {onchange} {required} {step} {type} {placeholder} {...props} />
|
|
70
19
|
{:else}
|
|
71
|
-
<input
|
|
72
|
-
bind:value
|
|
73
|
-
{id}
|
|
74
|
-
{placeholder}
|
|
75
|
-
{required}
|
|
76
|
-
{type}
|
|
77
|
-
class={classesIn}
|
|
78
|
-
disabled={disabled || $loading ? true : false}
|
|
79
|
-
maxlength={max ? Number(max) : undefined}
|
|
80
|
-
minlength={min ? Number(min) : undefined}
|
|
81
|
-
onkeyup={onchange}
|
|
82
|
-
{...props}
|
|
83
|
-
/>
|
|
20
|
+
<input bind:value {id} {placeholder} {required} {type} class={classesIn} disabled={inputDisabled} maxlength={max ? Number(max) : undefined} minlength={min ? Number(min) : undefined} onkeyup={onchange} {...props} />
|
|
84
21
|
{#if type === 'search'}
|
|
85
|
-
<svg
|
|
86
|
-
|
|
87
|
-
fill-rule="evenodd"
|
|
88
|
-
stroke-linejoin="round"
|
|
89
|
-
stroke-miterlimit="2"
|
|
90
|
-
viewBox="0 0 24 24"
|
|
91
|
-
xmlns="http://www.w3.org/2000/svg"
|
|
92
|
-
height="20"
|
|
93
|
-
width="20"
|
|
94
|
-
>
|
|
95
|
-
<path
|
|
96
|
-
d="m15.97 17.031c-1.479 1.238-3.384 1.985-5.461 1.985-4.697 0-8.509-3.812-8.509-8.508s3.812-8.508 8.509-8.508c4.695 0 8.508 3.812 8.508 8.508 0 2.078-.747 3.984-1.985 5.461l4.749 4.75c.146.146.219.338.219.531 0 .587-.537.75-.75.75-.192 0-.384-.073-.531-.22zm-5.461-13.53c-3.868 0-7.007 3.14-7.007 7.007s3.139 7.007 7.007 7.007c3.866 0 7.007-3.14 7.007-7.007s-3.141-7.007-7.007-7.007z"
|
|
97
|
-
fill-rule="nonzero"
|
|
98
|
-
/>
|
|
22
|
+
<svg clip-rule="evenodd" fill-rule="evenodd" stroke-linejoin="round" stroke-miterlimit="2" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg" height="20" width="20">
|
|
23
|
+
<path d="m15.97 17.031c-1.479 1.238-3.384 1.985-5.461 1.985-4.697 0-8.509-3.812-8.509-8.508s3.812-8.508 8.509-8.508c4.695 0 8.508 3.812 8.508 8.508 0 2.078-.747 3.984-1.985 5.461l4.749 4.75c.146.146.219.338.219.531 0 .587-.537.75-.75.75-.192 0-.384-.073-.531-.22zm-5.461-13.53c-3.868 0-7.007 3.14-7.007 7.007s3.139 7.007 7.007 7.007c3.866 0 7.007-3.14 7.007-7.007s-3.141-7.007-7.007-7.007z" fill-rule="nonzero" />
|
|
99
24
|
</svg>
|
|
100
25
|
{/if}
|
|
101
26
|
{/if}
|
|
@@ -111,7 +36,7 @@
|
|
|
111
36
|
border-radius: 0.375rem;
|
|
112
37
|
border-style: solid;
|
|
113
38
|
border-width: 1px;
|
|
114
|
-
color: var(--color-content);
|
|
39
|
+
color: var(--color-content, #222);
|
|
115
40
|
display: block;
|
|
116
41
|
font-size: 1rem;
|
|
117
42
|
margin-top: 0.25rem;
|
|
@@ -138,7 +63,7 @@
|
|
|
138
63
|
}
|
|
139
64
|
|
|
140
65
|
label.filter {
|
|
141
|
-
font-size: var(--text-sm);
|
|
66
|
+
font-size: var(--text-sm, 0.95rem);
|
|
142
67
|
}
|
|
143
68
|
|
|
144
69
|
label svg {
|
|
@@ -148,7 +73,7 @@
|
|
|
148
73
|
}
|
|
149
74
|
|
|
150
75
|
sup {
|
|
151
|
-
color: darkred;
|
|
76
|
+
color: var(--color-danger, darkred);
|
|
152
77
|
}
|
|
153
78
|
|
|
154
79
|
textarea {
|
|
@@ -166,7 +91,7 @@
|
|
|
166
91
|
}
|
|
167
92
|
|
|
168
93
|
.border-color-default {
|
|
169
|
-
border-color: var(--color-border);
|
|
94
|
+
border-color: var(--color-border, #999);
|
|
170
95
|
}
|
|
171
96
|
|
|
172
97
|
.border-color-primary {
|
|
@@ -174,6 +99,6 @@
|
|
|
174
99
|
}
|
|
175
100
|
|
|
176
101
|
.border-color-content {
|
|
177
|
-
border-color: var(--color-content);
|
|
102
|
+
border-color: var(--color-content, #222);
|
|
178
103
|
}
|
|
179
104
|
</style>
|
package/dist/Modal.svelte
CHANGED
|
@@ -1,17 +1,7 @@
|
|
|
1
1
|
<script lang="ts">
|
|
2
2
|
import ButtonClose from './ButtonClose.svelte'
|
|
3
3
|
import type {ModalView} from './types'
|
|
4
|
-
let {
|
|
5
|
-
children,
|
|
6
|
-
buttonAriaLabel,
|
|
7
|
-
colorButton = 'white',
|
|
8
|
-
headerClass = 'bg-primary text-white',
|
|
9
|
-
innerClass,
|
|
10
|
-
open = $bindable(),
|
|
11
|
-
outerClass = 'bg-white text-content',
|
|
12
|
-
title,
|
|
13
|
-
titleClass = 'text-white'
|
|
14
|
-
}: ModalView = $props()
|
|
4
|
+
let {children, buttonAriaLabel, colorButton = 'white', headerClass = 'bg-primary text-white', innerClass, open = $bindable(), outerClass = 'bg-white text-content', title, titleClass = 'text-white'}: ModalView = $props()
|
|
15
5
|
const handleClose = () => {
|
|
16
6
|
open = false
|
|
17
7
|
}
|
|
@@ -53,7 +43,7 @@
|
|
|
53
43
|
#modal-content {
|
|
54
44
|
border-radius: 1rem;
|
|
55
45
|
border: 2px solid var(--color-primary);
|
|
56
|
-
color: var(--color-content);
|
|
46
|
+
color: var(--color-content, #222);
|
|
57
47
|
margin-left: auto;
|
|
58
48
|
margin-right: auto;
|
|
59
49
|
max-width: 95vw;
|
|
@@ -69,7 +59,7 @@
|
|
|
69
59
|
padding: 1rem;
|
|
70
60
|
}
|
|
71
61
|
header {
|
|
72
|
-
border-bottom: 1px solid var(--color-border);
|
|
62
|
+
border-bottom: 1px solid var(--color-border, #999);
|
|
73
63
|
padding: 1rem;
|
|
74
64
|
}
|
|
75
65
|
h2 {
|
|
@@ -85,7 +75,7 @@
|
|
|
85
75
|
background-color: #fff;
|
|
86
76
|
}
|
|
87
77
|
.text-content {
|
|
88
|
-
color: var(--color-content);
|
|
78
|
+
color: var(--color-content, #222);
|
|
89
79
|
}
|
|
90
80
|
.text-white {
|
|
91
81
|
color: #fff;
|
package/dist/Select.svelte
CHANGED
|
@@ -1,29 +1,14 @@
|
|
|
1
1
|
<script lang="ts">
|
|
2
|
-
import {loading} from './'
|
|
2
|
+
import {cx, isDisabled, loading} from './'
|
|
3
3
|
import type {SelectView} from './types'
|
|
4
|
-
let {
|
|
5
|
-
|
|
6
|
-
disabled,
|
|
7
|
-
id,
|
|
8
|
-
innerClass,
|
|
9
|
-
label,
|
|
10
|
-
onchange,
|
|
11
|
-
outerClass,
|
|
12
|
-
placeholder,
|
|
13
|
-
required = false,
|
|
14
|
-
value = $bindable(),
|
|
15
|
-
values
|
|
16
|
-
}: SelectView = $props()
|
|
17
|
-
let classes = $state(colorBg)
|
|
18
|
-
if (innerClass) {
|
|
19
|
-
classes += ' ' + innerClass
|
|
20
|
-
}
|
|
4
|
+
let {disabled, id, innerClass, label, onchange, outerClass, placeholder, required = false, value = $bindable(), values}: SelectView = $props()
|
|
5
|
+
let classes = $derived(cx(innerClass))
|
|
21
6
|
</script>
|
|
22
7
|
|
|
23
8
|
<label class={outerClass}>
|
|
24
9
|
{label}
|
|
25
10
|
{#if required}<sup>*</sup>{/if}
|
|
26
|
-
<select bind:value {onchange} class={classes} disabled={disabled
|
|
11
|
+
<select bind:value {onchange} class={classes} disabled={isDisabled(disabled, $loading)} {id} {placeholder} {required}>
|
|
27
12
|
{#each values as item}
|
|
28
13
|
<option value={item.value}>{item.name}</option>
|
|
29
14
|
{/each}
|
|
@@ -32,11 +17,17 @@
|
|
|
32
17
|
|
|
33
18
|
<style scoped>
|
|
34
19
|
select {
|
|
35
|
-
|
|
36
|
-
|
|
20
|
+
appearance: none;
|
|
21
|
+
background-attachment: scroll;
|
|
22
|
+
background-color: var(--color-input-bg, #fff);
|
|
23
|
+
background-image: url('data:image/svg+xml;base64,PHN2ZyBpZD0iTGF5ZXJfMSIgZGF0YS1uYW1lPSJMYXllciAxIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZpZXdCb3g9IjAgMCA0Ljk1IDEwIj48ZGVmcz48c3R5bGU+LmNscy0xe2ZpbGw6I2ZmZjt9LmNscy0ye2ZpbGw6IzQ0NDt9PC9zdHlsZT48L2RlZnM+PHRpdGxlPmFycm93czwvdGl0bGU+PHJlY3QgY2xhc3M9ImNscy0xIiB3aWR0aD0iNC45NSIgaGVpZ2h0PSIxMCIvPjxwb2x5Z29uIGNsYXNzPSJjbHMtMiIgcG9pbnRzPSIxLjQxIDQuNjcgMi40OCAzLjE4IDMuNTQgNC42NyAxLjQxIDQuNjciLz48cG9seWdvbiBjbGFzcz0iY2xzLTIiIHBvaW50cz0iMy41NCA1LjMzIDIuNDggNi44MiAxLjQxIDUuMzMgMy41NCA1LjMzIi8+PC9zdmc+');
|
|
24
|
+
background-position-x: 98%;
|
|
25
|
+
background-position-y: 50%;
|
|
26
|
+
background-repeat: no-repeat;
|
|
27
|
+
background-size: auto;
|
|
37
28
|
border-radius: 0.375rem;
|
|
38
|
-
border: 1px solid var(--color-border);
|
|
39
|
-
color: var(--color-content);
|
|
29
|
+
border: 1px solid var(--color-border, #999);
|
|
30
|
+
color: var(--color-content, #222);
|
|
40
31
|
font-size: 1rem;
|
|
41
32
|
height: 48px;
|
|
42
33
|
margin-top: 0.25rem;
|
|
@@ -44,11 +35,6 @@
|
|
|
44
35
|
width: 100%;
|
|
45
36
|
-moz-appearance: none;
|
|
46
37
|
-webkit-appearance: none;
|
|
47
|
-
appearance: none;
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
select.bg-transparent {
|
|
51
|
-
background-color: transparent;
|
|
52
38
|
}
|
|
53
39
|
|
|
54
40
|
select:disabled {
|
|
@@ -63,10 +49,10 @@
|
|
|
63
49
|
|
|
64
50
|
label.filter {
|
|
65
51
|
position: relative;
|
|
66
|
-
font-size: var(--text-sm);
|
|
52
|
+
font-size: var(--text-sm, 0.95rem);
|
|
67
53
|
}
|
|
68
54
|
|
|
69
55
|
sup {
|
|
70
|
-
color: darkred;
|
|
56
|
+
color: var(--color-danger, darkred);
|
|
71
57
|
}
|
|
72
58
|
</style>
|
package/dist/index.d.ts
CHANGED
|
@@ -26,6 +26,14 @@ export interface SelectItem {
|
|
|
26
26
|
value: number | string;
|
|
27
27
|
}
|
|
28
28
|
export declare const loading: import("svelte/store").Writable<number>;
|
|
29
|
+
/**
|
|
30
|
+
* CLASS NAMES
|
|
31
|
+
*/
|
|
32
|
+
export declare const cx: (...classes: (string | false | null | undefined)[]) => string;
|
|
33
|
+
/**
|
|
34
|
+
* DISABLED STATE
|
|
35
|
+
*/
|
|
36
|
+
export declare const isDisabled: (disabled: boolean | undefined, loadingCount: number) => boolean;
|
|
29
37
|
/**
|
|
30
38
|
* PRICES AND NUMBERS
|
|
31
39
|
*/
|
package/dist/index.js
CHANGED
|
@@ -11,6 +11,14 @@ import Modal from './Modal.svelte';
|
|
|
11
11
|
import Select from './Select.svelte';
|
|
12
12
|
export { Breadcrumbs, Button, ButtonArrow, ButtonClose, ButtonMenu, Checkbox, Image, Input, Modal, Select };
|
|
13
13
|
export const loading = writable(0);
|
|
14
|
+
/**
|
|
15
|
+
* CLASS NAMES
|
|
16
|
+
*/
|
|
17
|
+
export const cx = (...classes) => classes.filter(Boolean).join(' ');
|
|
18
|
+
/**
|
|
19
|
+
* DISABLED STATE
|
|
20
|
+
*/
|
|
21
|
+
export const isDisabled = (disabled, loadingCount) => disabled === true || loadingCount > 0;
|
|
14
22
|
/**
|
|
15
23
|
* PRICES AND NUMBERS
|
|
16
24
|
*/
|
|
@@ -61,20 +69,20 @@ export const slugify = (value) => {
|
|
|
61
69
|
.replace(/^-+|-+$/g, ''); // Trim leading and trailing hyphens
|
|
62
70
|
};
|
|
63
71
|
export const validateSlug = (value) => {
|
|
64
|
-
return value && slugify(value) === value
|
|
72
|
+
return !!value && slugify(value) === value;
|
|
65
73
|
};
|
|
66
74
|
export const validateEmail = (email) => {
|
|
67
|
-
|
|
75
|
+
const re = /\S+@\S+\.\S+/;
|
|
68
76
|
return re.test(email);
|
|
69
77
|
};
|
|
70
78
|
export const validateString = (value) => {
|
|
71
|
-
return value && value.replace(/[^\w\s@!.:;,?+äÄöÖåÅ/%&()|-]/gi, '') === value
|
|
79
|
+
return !!value && value.replace(/[^\w\s@!.:;,?+äÄöÖåÅ/%&()|-]/gi, '') === value;
|
|
72
80
|
};
|
|
73
81
|
/**
|
|
74
82
|
* ARRAY VALIDATIONS
|
|
75
83
|
*/
|
|
76
84
|
export const validateArray = (value, items = 0) => {
|
|
77
|
-
return
|
|
85
|
+
return Array.isArray(value) && value.length > items;
|
|
78
86
|
};
|
|
79
87
|
export const cacheValues = writable({});
|
|
80
88
|
export const handleCache = (key, value = undefined, ttl = 60) => {
|
package/dist/types.d.ts
CHANGED
|
@@ -16,10 +16,9 @@ export interface ButtonArrowView {
|
|
|
16
16
|
}
|
|
17
17
|
export interface ButtonCloseView {
|
|
18
18
|
onclick?: any;
|
|
19
|
-
ariaLabel?: string;
|
|
19
|
+
ariaLabel?: string | undefined;
|
|
20
20
|
color?: string;
|
|
21
|
-
hover?: 'black' | 'primary' | 'secondary' | 'success' | 'transparent';
|
|
22
|
-
hoverText?: 'black' | 'primary' | 'secondary' | 'white';
|
|
21
|
+
hover?: 'black' | 'primary' | 'secondary' | 'success' | 'transparent' | undefined;
|
|
23
22
|
id?: string;
|
|
24
23
|
}
|
|
25
24
|
export interface ButtonMenuView {
|
|
@@ -51,7 +50,7 @@ export interface ButtonView {
|
|
|
51
50
|
hover?: 'black' | 'primary' | 'secondary' | 'success' | 'transparent';
|
|
52
51
|
hoverText?: 'black' | 'primary' | 'secondary' | 'white';
|
|
53
52
|
href?: string | undefined;
|
|
54
|
-
id?: string;
|
|
53
|
+
id?: string | undefined;
|
|
55
54
|
noCenter?: boolean;
|
|
56
55
|
noHeight?: boolean;
|
|
57
56
|
noPadding?: boolean;
|
|
@@ -114,7 +113,6 @@ export interface ModalView {
|
|
|
114
113
|
children: Snippet;
|
|
115
114
|
buttonAriaLabel?: string;
|
|
116
115
|
colorButton?: string;
|
|
117
|
-
colorBg?: string;
|
|
118
116
|
headerClass?: string;
|
|
119
117
|
innerClass?: string;
|
|
120
118
|
open?: boolean;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tuspe/components",
|
|
3
|
-
"version": "1.9.
|
|
3
|
+
"version": "1.9.10",
|
|
4
4
|
"description": "A reusable SvelteKit component library for form elements, breadcrumbs, prices and images.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"svelteKit",
|
|
@@ -60,24 +60,24 @@
|
|
|
60
60
|
"svelte": "^5.20.2"
|
|
61
61
|
},
|
|
62
62
|
"devDependencies": {
|
|
63
|
-
"@eslint/compat": "^2.0
|
|
64
|
-
"@eslint/js": "^
|
|
63
|
+
"@eslint/compat": "^2.1.0",
|
|
64
|
+
"@eslint/js": "^10.0.1",
|
|
65
65
|
"@sveltejs/adapter-static": "^3.0.10",
|
|
66
|
-
"@sveltejs/enhanced-img": "^0.10.
|
|
67
|
-
"@sveltejs/kit": "^2.
|
|
68
|
-
"@sveltejs/package": "^2.5.
|
|
69
|
-
"@sveltejs/vite-plugin-svelte": "^
|
|
70
|
-
"eslint": "^
|
|
66
|
+
"@sveltejs/enhanced-img": "^0.10.4",
|
|
67
|
+
"@sveltejs/kit": "^2.65.0",
|
|
68
|
+
"@sveltejs/package": "^2.5.8",
|
|
69
|
+
"@sveltejs/vite-plugin-svelte": "^7.1.2",
|
|
70
|
+
"eslint": "^10.4.1",
|
|
71
71
|
"eslint-config-prettier": "^10.1.8",
|
|
72
|
-
"eslint-plugin-svelte": "^3.
|
|
73
|
-
"globals": "^17.
|
|
74
|
-
"prettier": "^3.8.
|
|
75
|
-
"prettier-plugin-svelte": "^
|
|
76
|
-
"publint": "^0.3.
|
|
77
|
-
"svelte": "^5.
|
|
78
|
-
"svelte-check": "^4.
|
|
79
|
-
"typescript": "^
|
|
80
|
-
"typescript-eslint": "^8.
|
|
81
|
-
"vite": "^
|
|
72
|
+
"eslint-plugin-svelte": "^3.19.0",
|
|
73
|
+
"globals": "^17.6.0",
|
|
74
|
+
"prettier": "^3.8.4",
|
|
75
|
+
"prettier-plugin-svelte": "^4.1.0",
|
|
76
|
+
"publint": "^0.3.21",
|
|
77
|
+
"svelte": "^5.56.3",
|
|
78
|
+
"svelte-check": "^4.6.0",
|
|
79
|
+
"typescript": "^6.0.3",
|
|
80
|
+
"typescript-eslint": "^8.61.0",
|
|
81
|
+
"vite": "^8.0.16"
|
|
82
82
|
}
|
|
83
83
|
}
|