sveltacular 0.0.19 → 0.0.21
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/forms/list-box/list-box.svelte +16 -1
- package/dist/forms/list-box/list-box.svelte.d.ts +1 -0
- package/dist/helpers/random.d.ts +24 -0
- package/dist/helpers/random.js +108 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +3 -0
- package/dist/placeholders/loading.svelte +56 -0
- package/dist/placeholders/loading.svelte.d.ts +18 -0
- package/dist/placeholders/skeleton-text.svelte +18 -0
- package/dist/placeholders/skeleton-text.svelte.d.ts +17 -0
- package/package.json +1 -1
|
@@ -11,6 +11,7 @@ export let size = "full";
|
|
|
11
11
|
export let disabled = false;
|
|
12
12
|
export let required = false;
|
|
13
13
|
export let searchable = false;
|
|
14
|
+
export let search = void 0;
|
|
14
15
|
const getText = () => items.find((item) => item.value == value)?.name || "";
|
|
15
16
|
const onSelect = (e) => {
|
|
16
17
|
value = e.detail.value;
|
|
@@ -52,10 +53,19 @@ const onInputKeyPress = (e) => {
|
|
|
52
53
|
triggerSearch();
|
|
53
54
|
}
|
|
54
55
|
};
|
|
55
|
-
const triggerSearch = debounce(() => {
|
|
56
|
+
const triggerSearch = debounce(async () => {
|
|
56
57
|
dispatch("search", searchText);
|
|
58
|
+
if (search) {
|
|
59
|
+
items = await search(searchText);
|
|
60
|
+
text = getText();
|
|
61
|
+
}
|
|
57
62
|
}, 300);
|
|
58
63
|
const dispatch = createEventDispatcher();
|
|
64
|
+
const updateText = async () => {
|
|
65
|
+
const textBox = document.getElementById(id);
|
|
66
|
+
if (document.activeElement != textBox)
|
|
67
|
+
text = getText();
|
|
68
|
+
};
|
|
59
69
|
const id = uniqueId();
|
|
60
70
|
let text = getText();
|
|
61
71
|
let open = false;
|
|
@@ -64,6 +74,9 @@ $:
|
|
|
64
74
|
searchText = searchable ? text : "";
|
|
65
75
|
$:
|
|
66
76
|
filteredItems = searchText ? items.map((item, index) => ({ ...item, index })).filter((item) => item.name.toLowerCase().includes(searchText.toLowerCase())) : items.map((item, index) => ({ ...item, index }));
|
|
77
|
+
$:
|
|
78
|
+
items && updateText();
|
|
79
|
+
triggerSearch();
|
|
67
80
|
</script>
|
|
68
81
|
|
|
69
82
|
<FormField {size}>
|
|
@@ -80,6 +93,8 @@ $:
|
|
|
80
93
|
readonly={!searchable}
|
|
81
94
|
on:focus={() => (open = true)}
|
|
82
95
|
on:keyup={onInputKeyPress}
|
|
96
|
+
data-value={value}
|
|
97
|
+
data-text={text}
|
|
83
98
|
/>
|
|
84
99
|
<button type="button" class="icon" on:click={toggle} on:keydown={toggle}>
|
|
85
100
|
<AngleUpIcon />
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
export declare const randomInt: (min: number, max: number) => number;
|
|
2
|
+
export declare const randomFloat: (min: number, max: number) => number;
|
|
3
|
+
export declare const randomBool: () => boolean;
|
|
4
|
+
export declare const randomString: (length: number) => string;
|
|
5
|
+
export declare const randomDate: (start: Date, end: Date) => Date;
|
|
6
|
+
export declare const randomColor: () => string;
|
|
7
|
+
export declare const randomHex: (length: number) => string;
|
|
8
|
+
export declare const randomRGB: () => string;
|
|
9
|
+
export declare const randomRGBA: () => string;
|
|
10
|
+
export declare const randomHSL: () => string;
|
|
11
|
+
export declare const randomHSLA: () => string;
|
|
12
|
+
export declare const randomEmail: () => string;
|
|
13
|
+
export declare const randomPhone: () => string;
|
|
14
|
+
export declare const randomAddress: () => string;
|
|
15
|
+
export declare const randomCity: () => string;
|
|
16
|
+
export declare const randomState: () => string;
|
|
17
|
+
export declare const randomZip: () => string;
|
|
18
|
+
export declare const randomCountry: () => string;
|
|
19
|
+
export declare const randomName: () => string;
|
|
20
|
+
export declare const randomFirstName: () => string;
|
|
21
|
+
export declare const randomLastName: () => string;
|
|
22
|
+
export declare const randomUsername: () => string;
|
|
23
|
+
export declare const randomPassword: () => string;
|
|
24
|
+
export declare const randomAvatar: () => string;
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
// Generate random integer between min and max
|
|
2
|
+
export const randomInt = (min, max) => {
|
|
3
|
+
return Math.floor(Math.random() * (max - min + 1)) + min;
|
|
4
|
+
};
|
|
5
|
+
// Generate random float between min and max
|
|
6
|
+
export const randomFloat = (min, max) => {
|
|
7
|
+
return Math.random() * (max - min) + min;
|
|
8
|
+
};
|
|
9
|
+
// Generate random boolean
|
|
10
|
+
export const randomBool = () => {
|
|
11
|
+
return Math.random() >= 0.5;
|
|
12
|
+
};
|
|
13
|
+
// Generate random string
|
|
14
|
+
export const randomString = (length) => {
|
|
15
|
+
let result = '';
|
|
16
|
+
const characters = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';
|
|
17
|
+
const charactersLength = characters.length;
|
|
18
|
+
for (let i = 0; i < length; i++) {
|
|
19
|
+
result += characters.charAt(Math.floor(Math.random() * charactersLength));
|
|
20
|
+
}
|
|
21
|
+
return result;
|
|
22
|
+
};
|
|
23
|
+
// Generate random date
|
|
24
|
+
export const randomDate = (start, end) => {
|
|
25
|
+
return new Date(start.getTime() + Math.random() * (end.getTime() - start.getTime()));
|
|
26
|
+
};
|
|
27
|
+
// Generate random color
|
|
28
|
+
export const randomColor = () => {
|
|
29
|
+
return '#' + Math.floor(Math.random() * 16777215).toString(16);
|
|
30
|
+
};
|
|
31
|
+
// Generate random hex
|
|
32
|
+
export const randomHex = (length) => {
|
|
33
|
+
let result = '';
|
|
34
|
+
const characters = 'abcdef0123456789';
|
|
35
|
+
const charactersLength = characters.length;
|
|
36
|
+
for (let i = 0; i < length; i++) {
|
|
37
|
+
result += characters.charAt(Math.floor(Math.random() * charactersLength));
|
|
38
|
+
}
|
|
39
|
+
return result;
|
|
40
|
+
};
|
|
41
|
+
// Generate random rgb
|
|
42
|
+
export const randomRGB = () => {
|
|
43
|
+
return `rgb(${randomInt(0, 255)}, ${randomInt(0, 255)}, ${randomInt(0, 255)})`;
|
|
44
|
+
};
|
|
45
|
+
// Generate random rgba
|
|
46
|
+
export const randomRGBA = () => {
|
|
47
|
+
return `rgba(${randomInt(0, 255)}, ${randomInt(0, 255)}, ${randomInt(0, 255)}, ${randomFloat(0, 1)})`;
|
|
48
|
+
};
|
|
49
|
+
// Generate random hsl
|
|
50
|
+
export const randomHSL = () => {
|
|
51
|
+
return `hsl(${randomInt(0, 360)}, ${randomInt(0, 100)}%, ${randomInt(0, 100)}%)`;
|
|
52
|
+
};
|
|
53
|
+
// Generate random hsla
|
|
54
|
+
export const randomHSLA = () => {
|
|
55
|
+
return `hsla(${randomInt(0, 360)}, ${randomInt(0, 100)}%, ${randomInt(0, 100)}%, ${randomFloat(0, 1)})`;
|
|
56
|
+
};
|
|
57
|
+
// Generate random email
|
|
58
|
+
export const randomEmail = () => {
|
|
59
|
+
return `${randomString(10)}@${randomString(5)}.com`;
|
|
60
|
+
};
|
|
61
|
+
// Generate random phone number
|
|
62
|
+
export const randomPhone = () => {
|
|
63
|
+
return `${randomInt(100, 999)}-${randomInt(100, 999)}-${randomInt(1000, 9999)}`;
|
|
64
|
+
};
|
|
65
|
+
// Generate random address
|
|
66
|
+
export const randomAddress = () => {
|
|
67
|
+
return `${randomInt(100, 999)} ${randomString(10)} ${randomString(5)}`;
|
|
68
|
+
};
|
|
69
|
+
// Generate random city
|
|
70
|
+
export const randomCity = () => {
|
|
71
|
+
return `${randomString(10)}`;
|
|
72
|
+
};
|
|
73
|
+
// Generate random state
|
|
74
|
+
export const randomState = () => {
|
|
75
|
+
return `${randomString(2)}`;
|
|
76
|
+
};
|
|
77
|
+
// Generate random zip
|
|
78
|
+
export const randomZip = () => {
|
|
79
|
+
return `${randomInt(10000, 99999)}`;
|
|
80
|
+
};
|
|
81
|
+
// Generate random country
|
|
82
|
+
export const randomCountry = () => {
|
|
83
|
+
return `${randomString(10)}`;
|
|
84
|
+
};
|
|
85
|
+
// Generate random name
|
|
86
|
+
export const randomName = () => {
|
|
87
|
+
return `${randomString(10)} ${randomString(10)}`;
|
|
88
|
+
};
|
|
89
|
+
// Generate random first name
|
|
90
|
+
export const randomFirstName = () => {
|
|
91
|
+
return `${randomString(10)}`;
|
|
92
|
+
};
|
|
93
|
+
// Generate random last name
|
|
94
|
+
export const randomLastName = () => {
|
|
95
|
+
return `${randomString(10)}`;
|
|
96
|
+
};
|
|
97
|
+
// Generate random username
|
|
98
|
+
export const randomUsername = () => {
|
|
99
|
+
return `${randomString(10)}`;
|
|
100
|
+
};
|
|
101
|
+
// Generate random password
|
|
102
|
+
export const randomPassword = () => {
|
|
103
|
+
return `${randomString(10)}`;
|
|
104
|
+
};
|
|
105
|
+
// Generate random avatar
|
|
106
|
+
export const randomAvatar = () => {
|
|
107
|
+
return `https://avatars.dicebear.com/api/avataaars/${randomString(10)}.svg`;
|
|
108
|
+
};
|
package/dist/index.d.ts
CHANGED
|
@@ -69,6 +69,8 @@ export { default as CodeBlock } from './typography/code-block.svelte';
|
|
|
69
69
|
export { default as Paragraph } from './typography/paragraph.svelte';
|
|
70
70
|
export { default as Timeline } from './timeline/timeline.svelte';
|
|
71
71
|
export { default as TimelineItem } from './timeline/timeline-item.svelte';
|
|
72
|
+
export { default as Loading } from './placeholders/loading.svelte';
|
|
73
|
+
export { default as SkeletonText } from './placeholders/skeleton-text.svelte';
|
|
72
74
|
export * from './types/data.js';
|
|
73
75
|
export * from './types/date.js';
|
|
74
76
|
export * from './types/form.js';
|
package/dist/index.js
CHANGED
|
@@ -77,6 +77,9 @@ export { default as Paragraph } from './typography/paragraph.svelte';
|
|
|
77
77
|
// Timeline
|
|
78
78
|
export { default as Timeline } from './timeline/timeline.svelte';
|
|
79
79
|
export { default as TimelineItem } from './timeline/timeline-item.svelte';
|
|
80
|
+
// Placeholders
|
|
81
|
+
export { default as Loading } from './placeholders/loading.svelte';
|
|
82
|
+
export { default as SkeletonText } from './placeholders/skeleton-text.svelte';
|
|
80
83
|
// Types
|
|
81
84
|
export * from './types/data.js';
|
|
82
85
|
export * from './types/date.js';
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
<script>export let type = "spinner";
|
|
2
|
+
</script>
|
|
3
|
+
|
|
4
|
+
<div class={type}>
|
|
5
|
+
<span>
|
|
6
|
+
<slot />
|
|
7
|
+
</span>
|
|
8
|
+
</div>
|
|
9
|
+
|
|
10
|
+
<style>div {
|
|
11
|
+
text-align: center;
|
|
12
|
+
}
|
|
13
|
+
div span {
|
|
14
|
+
display: block;
|
|
15
|
+
width: 100%;
|
|
16
|
+
padding: 1rem;
|
|
17
|
+
}
|
|
18
|
+
div.spinner {
|
|
19
|
+
border: 4px solid rgba(0, 0, 0, 0.1);
|
|
20
|
+
border-top: 4px solid #3498db;
|
|
21
|
+
border-radius: 50%;
|
|
22
|
+
width: 40px;
|
|
23
|
+
height: 40px;
|
|
24
|
+
animation: spin 1s linear infinite;
|
|
25
|
+
}
|
|
26
|
+
div.block {
|
|
27
|
+
width: 100%;
|
|
28
|
+
height: 100%;
|
|
29
|
+
background-color: #ccc;
|
|
30
|
+
color: #888;
|
|
31
|
+
font-size: 1.5rem;
|
|
32
|
+
font-family: var(--base-font-family, sans-serif);
|
|
33
|
+
animation: pulse 2s infinite;
|
|
34
|
+
display: flex;
|
|
35
|
+
align-items: center;
|
|
36
|
+
justify-content: center;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
@keyframes spin {
|
|
40
|
+
0% {
|
|
41
|
+
transform: rotate(0deg);
|
|
42
|
+
}
|
|
43
|
+
100% {
|
|
44
|
+
transform: rotate(360deg);
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
@keyframes pulse {
|
|
48
|
+
0%, 100% {
|
|
49
|
+
opacity: 0.5;
|
|
50
|
+
transform: scale(0.95);
|
|
51
|
+
}
|
|
52
|
+
50% {
|
|
53
|
+
opacity: 1;
|
|
54
|
+
transform: scale(1);
|
|
55
|
+
}
|
|
56
|
+
}</style>
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { SvelteComponent } from "svelte";
|
|
2
|
+
declare const __propDef: {
|
|
3
|
+
props: {
|
|
4
|
+
type?: "block" | "spinner" | undefined;
|
|
5
|
+
};
|
|
6
|
+
events: {
|
|
7
|
+
[evt: string]: CustomEvent<any>;
|
|
8
|
+
};
|
|
9
|
+
slots: {
|
|
10
|
+
default: {};
|
|
11
|
+
};
|
|
12
|
+
};
|
|
13
|
+
export type LoadingProps = typeof __propDef.props;
|
|
14
|
+
export type LoadingEvents = typeof __propDef.events;
|
|
15
|
+
export type LoadingSlots = typeof __propDef.slots;
|
|
16
|
+
export default class Loading extends SvelteComponent<LoadingProps, LoadingEvents, LoadingSlots> {
|
|
17
|
+
}
|
|
18
|
+
export {};
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
<script>import { randomInt } from "../helpers/random.js";
|
|
2
|
+
export let min = 50;
|
|
3
|
+
export let max = 100;
|
|
4
|
+
$:
|
|
5
|
+
width = randomInt(min, max);
|
|
6
|
+
</script>
|
|
7
|
+
|
|
8
|
+
<div style="width: {width}%" />
|
|
9
|
+
|
|
10
|
+
<style>
|
|
11
|
+
div {
|
|
12
|
+
height: 1rem;
|
|
13
|
+
background-color: var(--base-color-fg, #ccc);
|
|
14
|
+
opacity: 0.5;
|
|
15
|
+
border-radius: 1rem;
|
|
16
|
+
margin-bottom: 1rem;
|
|
17
|
+
}
|
|
18
|
+
</style>
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { SvelteComponent } from "svelte";
|
|
2
|
+
declare const __propDef: {
|
|
3
|
+
props: {
|
|
4
|
+
min?: number | undefined;
|
|
5
|
+
max?: number | undefined;
|
|
6
|
+
};
|
|
7
|
+
events: {
|
|
8
|
+
[evt: string]: CustomEvent<any>;
|
|
9
|
+
};
|
|
10
|
+
slots: {};
|
|
11
|
+
};
|
|
12
|
+
export type SkeletonTextProps = typeof __propDef.props;
|
|
13
|
+
export type SkeletonTextEvents = typeof __propDef.events;
|
|
14
|
+
export type SkeletonTextSlots = typeof __propDef.slots;
|
|
15
|
+
export default class SkeletonText extends SvelteComponent<SkeletonTextProps, SkeletonTextEvents, SkeletonTextSlots> {
|
|
16
|
+
}
|
|
17
|
+
export {};
|