@tuspe/components 1.7.13 → 1.7.15
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 +3 -2
- package/dist/Breadcrumbs.svelte +11 -4
- package/dist/Breadcrumbs.svelte.d.ts +2 -1
- package/dist/Select.svelte +5 -4
- package/dist/Select.svelte.d.ts +3 -2
- package/dist/index.d.ts +6 -2
- package/dist/index.js +17 -10
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -175,11 +175,12 @@ A customizable `Select` component for choosing from a list of options. Supports
|
|
|
175
175
|
}
|
|
176
176
|
|
|
177
177
|
interface Props {
|
|
178
|
-
onchange?: () => void
|
|
179
178
|
disabled?: boolean
|
|
180
|
-
outerClass?: string
|
|
181
179
|
id?: string
|
|
180
|
+
innerClass?: string
|
|
182
181
|
label: string
|
|
182
|
+
onchange?: () => void
|
|
183
|
+
outerClass?: string
|
|
183
184
|
placeholder?: string
|
|
184
185
|
required?: boolean
|
|
185
186
|
value: string | number
|
package/dist/Breadcrumbs.svelte
CHANGED
|
@@ -1,14 +1,17 @@
|
|
|
1
1
|
<script lang="ts">
|
|
2
2
|
import {page} from '$app/state'
|
|
3
|
-
import type
|
|
3
|
+
import {validateArray, type Breadcrumb} from './'
|
|
4
4
|
|
|
5
5
|
interface Props {
|
|
6
6
|
homeName?: string
|
|
7
7
|
homeSlug?: string
|
|
8
|
+
outerClass?: string
|
|
8
9
|
values: Breadcrumb[]
|
|
9
10
|
}
|
|
10
11
|
|
|
11
|
-
let {homeName = 'Etusivu', homeSlug = '', values}: Props = $props()
|
|
12
|
+
let {homeName = 'Etusivu', homeSlug = '', outerClass, values}: Props = $props(),
|
|
13
|
+
classes = $state('truncate')
|
|
14
|
+
|
|
12
15
|
const origin = page.url.origin + '/'
|
|
13
16
|
|
|
14
17
|
let originWithSlug = $state(origin + homeSlug),
|
|
@@ -35,6 +38,10 @@
|
|
|
35
38
|
? `<script type="application/ld+json">{"@context":"https://schema.org","@type":"BreadcrumbList","itemListElement":${JSON.stringify(listItems)}}${'<'}/script>`
|
|
36
39
|
: ''
|
|
37
40
|
)
|
|
41
|
+
|
|
42
|
+
$effect(() => {
|
|
43
|
+
classes += outerClass ? ` ${outerClass}` : ' border-bottom'
|
|
44
|
+
})
|
|
38
45
|
</script>
|
|
39
46
|
|
|
40
47
|
<svelte:head>
|
|
@@ -43,8 +50,8 @@
|
|
|
43
50
|
{/if}
|
|
44
51
|
</svelte:head>
|
|
45
52
|
|
|
46
|
-
{#if
|
|
47
|
-
<div class=
|
|
53
|
+
{#if validateArray(listItems)}
|
|
54
|
+
<div class={classes}>
|
|
48
55
|
<ol id="breadcrumb" class="max-w-screen-xl mx-auto my-0 px-4 py-2" vocab="https://schema.org/" typeof="BreadcrumbList">
|
|
49
56
|
{#each listItems as page}
|
|
50
57
|
<li property="itemListElement" typeof="ListItem">
|
package/dist/Select.svelte
CHANGED
|
@@ -2,24 +2,25 @@
|
|
|
2
2
|
import {loading, type SelectItem} from './'
|
|
3
3
|
|
|
4
4
|
interface Props {
|
|
5
|
-
onchange?: () => void
|
|
6
5
|
disabled?: boolean
|
|
7
|
-
outerClass?: string
|
|
8
6
|
id?: string
|
|
7
|
+
innerClass?: string
|
|
9
8
|
label: string
|
|
9
|
+
onchange?: () => void
|
|
10
|
+
outerClass?: string
|
|
10
11
|
placeholder?: string
|
|
11
12
|
required?: boolean
|
|
12
13
|
value: string | number
|
|
13
14
|
values: SelectItem[]
|
|
14
15
|
}
|
|
15
16
|
|
|
16
|
-
let {
|
|
17
|
+
let {disabled, id, innerClass, label, onchange, outerClass, placeholder, required = false, value = $bindable(), values}: Props = $props()
|
|
17
18
|
</script>
|
|
18
19
|
|
|
19
20
|
<label class={outerClass}>
|
|
20
21
|
{label}
|
|
21
22
|
{#if required}<sup>*</sup>{/if}
|
|
22
|
-
<select bind:value {onchange} disabled={disabled || $loading} {id} {placeholder} {required}>
|
|
23
|
+
<select bind:value {onchange} class={innerClass} disabled={disabled || $loading} {id} {placeholder} {required}>
|
|
23
24
|
{#each values as item}
|
|
24
25
|
<option value={item.value}>{item.name}</option>
|
|
25
26
|
{/each}
|
package/dist/Select.svelte.d.ts
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import { type SelectItem } from './';
|
|
2
2
|
interface Props {
|
|
3
|
-
onchange?: () => void;
|
|
4
3
|
disabled?: boolean;
|
|
5
|
-
outerClass?: string;
|
|
6
4
|
id?: string;
|
|
5
|
+
innerClass?: string;
|
|
7
6
|
label: string;
|
|
7
|
+
onchange?: () => void;
|
|
8
|
+
outerClass?: string;
|
|
8
9
|
placeholder?: string;
|
|
9
10
|
required?: boolean;
|
|
10
11
|
value: string | number;
|
package/dist/index.d.ts
CHANGED
|
@@ -47,10 +47,14 @@ export declare const validateArray: (value: any, items?: number) => boolean;
|
|
|
47
47
|
/**
|
|
48
48
|
* CACHE
|
|
49
49
|
*/
|
|
50
|
+
interface Stored {
|
|
51
|
+
date: number;
|
|
52
|
+
value: any;
|
|
53
|
+
}
|
|
50
54
|
export declare const cacheValues: import("svelte/store").Writable<{
|
|
51
|
-
[key: string]:
|
|
55
|
+
[key: string]: Stored;
|
|
52
56
|
}>;
|
|
53
|
-
export declare const handleCache: (key: string, value?: any) => any;
|
|
57
|
+
export declare const handleCache: (key: string, value?: any, ttl?: number) => any;
|
|
54
58
|
/**
|
|
55
59
|
* PREVENT DEFAULT
|
|
56
60
|
*/
|
package/dist/index.js
CHANGED
|
@@ -75,22 +75,29 @@ export const validateString = (value) => {
|
|
|
75
75
|
export const validateArray = (value, items = 0) => {
|
|
76
76
|
return value && Array.isArray(value) && value.length > items ? true : false;
|
|
77
77
|
};
|
|
78
|
-
/**
|
|
79
|
-
* CACHE
|
|
80
|
-
*/
|
|
81
78
|
export const cacheValues = writable({});
|
|
82
|
-
export const handleCache = (key, value = undefined) => {
|
|
79
|
+
export const handleCache = (key, value = undefined, ttl = 60) => {
|
|
83
80
|
if (!key) {
|
|
84
81
|
return null;
|
|
85
82
|
}
|
|
86
|
-
const newKey = slugify(key);
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
83
|
+
const cache = get(cacheValues), newKey = slugify(key), now = Date.now(), ttlMs = ttl * 1000;
|
|
84
|
+
if (value !== undefined) {
|
|
85
|
+
const newValues = {
|
|
86
|
+
...cache,
|
|
87
|
+
[newKey]: { date: now, value }
|
|
88
|
+
};
|
|
89
|
+
cacheValues.set(newValues);
|
|
91
90
|
}
|
|
92
91
|
else if (cache?.[newKey]) {
|
|
93
|
-
|
|
92
|
+
const cachedItem = cache[newKey];
|
|
93
|
+
if (now - cachedItem.date < ttlMs) {
|
|
94
|
+
return cachedItem.value;
|
|
95
|
+
}
|
|
96
|
+
else {
|
|
97
|
+
// Remove expired cache entry
|
|
98
|
+
const { [newKey]: _, ...rest } = cache;
|
|
99
|
+
cacheValues.set(rest);
|
|
100
|
+
}
|
|
94
101
|
}
|
|
95
102
|
return null;
|
|
96
103
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tuspe/components",
|
|
3
|
-
"version": "1.7.
|
|
3
|
+
"version": "1.7.15",
|
|
4
4
|
"description": "A reusable SvelteKit component library for form elements, breadcrumbs, prices and images.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"svelteKit",
|
|
@@ -67,7 +67,7 @@
|
|
|
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.0
|
|
70
|
+
"eslint-plugin-svelte": "^3.1.0",
|
|
71
71
|
"eslint": "^9.22.0",
|
|
72
72
|
"globals": "^16.0.0",
|
|
73
73
|
"prettier-plugin-svelte": "^3.3.3",
|