@functionalcms/svelte-components 4.0.0-pre-2.4 → 4.0.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/dist/components/blog/blog.d.ts +20 -0
- package/dist/components/blog/blog.js +29 -0
- package/dist/components/form/Button.svelte +113 -108
- package/dist/components/form/Button.svelte.d.ts +2 -0
- package/dist/components/form/Input.d.ts +2 -21
- package/dist/components/form/Input.js +1 -23
- package/dist/components/form/Input.svelte +99 -74
- package/dist/components/form/Input.svelte.d.ts +25 -23
- package/dist/components/form/Switch.svelte +290 -0
- package/dist/components/form/Switch.svelte.d.ts +13 -0
- package/dist/components/layouts/Meta.svelte +1 -1
- package/dist/components/layouts/Meta.svelte.d.ts +2 -3
- package/dist/components/presentation/Carousel.svelte +2 -2
- package/dist/components/presentation/Gallery.svelte +2 -2
- package/dist/components/presentation/Gallery.svelte.d.ts +2 -3
- package/dist/components/presentation/ImageCompare.svelte +1 -0
- package/dist/components/presentation/ShowItem.d.ts +0 -5
- package/dist/index.d.ts +2 -1
- package/dist/index.js +5 -1
- package/package.json +1 -1
- package/css/functional.css +0 -1
- package/css/functional.css.map +0 -1
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
export interface BlogPost {
|
|
2
|
+
slug: string;
|
|
3
|
+
title: string;
|
|
4
|
+
author: string;
|
|
5
|
+
description: string;
|
|
6
|
+
date: string;
|
|
7
|
+
published: boolean;
|
|
8
|
+
}
|
|
9
|
+
export interface MdsvexFile {
|
|
10
|
+
default: any;
|
|
11
|
+
metadata: Record<string, string>;
|
|
12
|
+
}
|
|
13
|
+
export type MdsvexResolver = () => Promise<MdsvexFile>;
|
|
14
|
+
export declare function listAllPosts(page?: number, postCount?: number): Promise<{
|
|
15
|
+
posts: BlogPost[];
|
|
16
|
+
}>;
|
|
17
|
+
export declare function importPost(loadEvent: any): Promise<{
|
|
18
|
+
component: any;
|
|
19
|
+
frontmatter: Record<string, string> | undefined;
|
|
20
|
+
}>;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
const MAX_POSTS = 25;
|
|
2
|
+
const slugFromPath = (path) => path.match(/([\w-]+)\.(svelte\.md|md|svx)/i)?.[1] ?? null;
|
|
3
|
+
export async function listAllPosts(page = 0, postCount = MAX_POSTS) {
|
|
4
|
+
const modules = import.meta.glob(`/src/posts/*.{md,svx,svelte.md}`);
|
|
5
|
+
const postPromises = Object.entries(modules).map(([path, resolver]) => resolver().then((post) => ({
|
|
6
|
+
slug: slugFromPath(path),
|
|
7
|
+
...post.metadata
|
|
8
|
+
})));
|
|
9
|
+
const posts = await Promise.all(postPromises);
|
|
10
|
+
const publishedPosts = posts.filter((post) => post.published).slice(page, postCount);
|
|
11
|
+
publishedPosts.sort((a, b) => (new Date(a.date) > new Date(b.date) ? -1 : 1));
|
|
12
|
+
return { posts: publishedPosts };
|
|
13
|
+
}
|
|
14
|
+
export async function importPost(loadEvent) {
|
|
15
|
+
const modules = import.meta.glob(`/src/posts/*.{md,svx,svelte.md}`);
|
|
16
|
+
let match = {};
|
|
17
|
+
for (const [path, resolver] of Object.entries(modules)) {
|
|
18
|
+
if (slugFromPath(path) === loadEvent.params.slug) {
|
|
19
|
+
match = { path, resolver: resolver };
|
|
20
|
+
break;
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
const post = await match?.resolver?.();
|
|
24
|
+
return {
|
|
25
|
+
component: post?.default,
|
|
26
|
+
frontmatter: post?.metadata
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
;
|
|
@@ -1,110 +1,115 @@
|
|
|
1
|
-
<script lang="ts">
|
|
2
|
-
import { cn } from '../../utils.js';
|
|
3
|
-
import type { Snippet } from 'svelte';
|
|
4
|
-
|
|
5
|
-
interface Props {
|
|
6
|
-
children: Snippet;
|
|
7
|
-
css: string;
|
|
8
|
-
style: string;
|
|
9
|
-
type?: 'submit' | 'reset' | 'button' | 'link';
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
{
|
|
85
|
-
{
|
|
86
|
-
{
|
|
87
|
-
|
|
88
|
-
{
|
|
89
|
-
|
|
90
|
-
{
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
{
|
|
101
|
-
{
|
|
102
|
-
{
|
|
103
|
-
|
|
104
|
-
{
|
|
105
|
-
|
|
106
|
-
{
|
|
107
|
-
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import { cn } from '../../utils.js';
|
|
3
|
+
import type { Snippet } from 'svelte';
|
|
4
|
+
|
|
5
|
+
interface Props {
|
|
6
|
+
children: Snippet;
|
|
7
|
+
css: string;
|
|
8
|
+
style: string;
|
|
9
|
+
type?: 'submit' | 'reset' | 'button' | 'link';
|
|
10
|
+
href: string;
|
|
11
|
+
mode?: string;
|
|
12
|
+
size?: string;
|
|
13
|
+
isPrimary: boolean;
|
|
14
|
+
isBordered?: boolean;
|
|
15
|
+
isCapsule?: boolean;
|
|
16
|
+
isGrouped?: boolean;
|
|
17
|
+
isBlock?: boolean;
|
|
18
|
+
isLink?: boolean;
|
|
19
|
+
isBlank?: boolean;
|
|
20
|
+
isDisabled?: boolean;
|
|
21
|
+
role?: string;
|
|
22
|
+
isCircle?: boolean;
|
|
23
|
+
isRounded?: boolean;
|
|
24
|
+
isSkinned?: boolean;
|
|
25
|
+
ariaSelected?: boolean;
|
|
26
|
+
ariaControls?: string;
|
|
27
|
+
tabIndex?: number;
|
|
28
|
+
onclick?: () => void;
|
|
29
|
+
onkeydown?: (e: KeyboardEvent) => void;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
let {
|
|
33
|
+
children,
|
|
34
|
+
css = '',
|
|
35
|
+
style = '',
|
|
36
|
+
href = '',
|
|
37
|
+
mode = undefined,
|
|
38
|
+
size = undefined,
|
|
39
|
+
type = 'button',
|
|
40
|
+
isPrimary = false,
|
|
41
|
+
isBordered = false,
|
|
42
|
+
isCapsule = false,
|
|
43
|
+
isGrouped = false,
|
|
44
|
+
isBlock = false,
|
|
45
|
+
isLink = false,
|
|
46
|
+
isBlank = false,
|
|
47
|
+
isDisabled = false,
|
|
48
|
+
role = undefined,
|
|
49
|
+
isCircle = false,
|
|
50
|
+
isRounded = false,
|
|
51
|
+
isSkinned = true,
|
|
52
|
+
ariaSelected = undefined,
|
|
53
|
+
ariaControls = undefined,
|
|
54
|
+
tabIndex = 0,
|
|
55
|
+
onclick = undefined,
|
|
56
|
+
onkeydown = undefined,
|
|
57
|
+
...restProps
|
|
58
|
+
}: Partial<Props> = $props();
|
|
59
|
+
|
|
60
|
+
let klasses = $derived(
|
|
61
|
+
cn(
|
|
62
|
+
isSkinned ? 'btn' : 'btn-base',
|
|
63
|
+
mode ? `btn-${mode}` : '',
|
|
64
|
+
size ? `btn-${size}` : '',
|
|
65
|
+
isBordered ? 'btn-bordered' : '',
|
|
66
|
+
isCapsule ? 'btn-capsule ' : '',
|
|
67
|
+
isGrouped ? 'btn-grouped' : '',
|
|
68
|
+
isBlock ? 'btn-block' : '',
|
|
69
|
+
isCircle ? 'btn-circle' : '',
|
|
70
|
+
isRounded ? 'btn-rounded' : '',
|
|
71
|
+
isDisabled ? 'disabled' : '',
|
|
72
|
+
isBlank ? 'btn-blank' : '',
|
|
73
|
+
isLink ? 'btn-link' : '',
|
|
74
|
+
css ? `${css}` : ''
|
|
75
|
+
)
|
|
76
|
+
);
|
|
77
|
+
</script>
|
|
78
|
+
|
|
79
|
+
{#if type == 'link'}
|
|
80
|
+
<!-- svelte-ignore a11y_no_noninteractive_tabindex -->
|
|
81
|
+
<a
|
|
82
|
+
class={klasses}
|
|
83
|
+
{href}
|
|
84
|
+
{style}
|
|
85
|
+
{role}
|
|
86
|
+
aria-selected={ariaSelected}
|
|
87
|
+
aria-controls={ariaControls}
|
|
88
|
+
tabindex={tabIndex}
|
|
89
|
+
{onclick}
|
|
90
|
+
{onkeydown}
|
|
91
|
+
{...restProps}
|
|
92
|
+
>
|
|
93
|
+
{@render children?.()}
|
|
94
|
+
</a>
|
|
95
|
+
{:else}
|
|
96
|
+
<button
|
|
97
|
+
{type}
|
|
98
|
+
class={klasses}
|
|
99
|
+
{style}
|
|
100
|
+
{role}
|
|
101
|
+
aria-selected={ariaSelected}
|
|
102
|
+
aria-controls={ariaControls}
|
|
103
|
+
tabindex={tabIndex}
|
|
104
|
+
disabled={isDisabled}
|
|
105
|
+
{onclick}
|
|
106
|
+
{onkeydown}
|
|
107
|
+
{...restProps}
|
|
108
|
+
>
|
|
109
|
+
{@render children?.()}
|
|
110
|
+
</button>
|
|
111
|
+
{/if}
|
|
112
|
+
|
|
108
113
|
<style>.btn-base {
|
|
109
114
|
display: inline-flex;
|
|
110
115
|
align-items: center;
|
|
@@ -376,4 +381,4 @@ on the side padding. As such, these have a good bit less then regular buttons. *
|
|
|
376
381
|
|
|
377
382
|
.btn-link:hover {
|
|
378
383
|
cursor: pointer;
|
|
379
|
-
}</style>
|
|
384
|
+
}</style>
|
|
@@ -4,8 +4,10 @@ declare const Button: import("svelte").Component<Partial<{
|
|
|
4
4
|
css: string;
|
|
5
5
|
style: string;
|
|
6
6
|
type?: "submit" | "reset" | "button" | "link";
|
|
7
|
+
href: string;
|
|
7
8
|
mode?: string;
|
|
8
9
|
size?: string;
|
|
10
|
+
isPrimary: boolean;
|
|
9
11
|
isBordered?: boolean;
|
|
10
12
|
isCapsule?: boolean;
|
|
11
13
|
isGrouped?: boolean;
|
|
@@ -1,21 +1,2 @@
|
|
|
1
|
-
export
|
|
2
|
-
|
|
3
|
-
Textarea = "textarea",
|
|
4
|
-
Email = "email",
|
|
5
|
-
Search = "search",
|
|
6
|
-
Password = "password",
|
|
7
|
-
Tel = "tel",
|
|
8
|
-
Number = "number",
|
|
9
|
-
Url = "url",
|
|
10
|
-
Month = "month",
|
|
11
|
-
Time = "time",
|
|
12
|
-
Week = "week",
|
|
13
|
-
Date = "date",
|
|
14
|
-
DatetimeLocal = "datetime-local",
|
|
15
|
-
Color = "color"
|
|
16
|
-
}
|
|
17
|
-
export declare enum Size {
|
|
18
|
-
Small = "small",
|
|
19
|
-
Large = "large",
|
|
20
|
-
Normal = ""
|
|
21
|
-
}
|
|
1
|
+
export type Type = 'text' | 'textarea' | 'email' | 'search' | 'password' | 'tel' | 'number' | 'url' | 'month' | 'time' | 'week' | 'date' | 'datetime-local' | 'color';
|
|
2
|
+
export type LabelSize = 'small' | 'large' | '';
|
|
@@ -1,23 +1 @@
|
|
|
1
|
-
export
|
|
2
|
-
(function (Type) {
|
|
3
|
-
Type["Text"] = "text";
|
|
4
|
-
Type["Textarea"] = "textarea";
|
|
5
|
-
Type["Email"] = "email";
|
|
6
|
-
Type["Search"] = "search";
|
|
7
|
-
Type["Password"] = "password";
|
|
8
|
-
Type["Tel"] = "tel";
|
|
9
|
-
Type["Number"] = "number";
|
|
10
|
-
Type["Url"] = "url";
|
|
11
|
-
Type["Month"] = "month";
|
|
12
|
-
Type["Time"] = "time";
|
|
13
|
-
Type["Week"] = "week";
|
|
14
|
-
Type["Date"] = "date";
|
|
15
|
-
Type["DatetimeLocal"] = "datetime-local";
|
|
16
|
-
Type["Color"] = "color";
|
|
17
|
-
})(Type || (Type = {}));
|
|
18
|
-
export var Size;
|
|
19
|
-
(function (Size) {
|
|
20
|
-
Size["Small"] = "small";
|
|
21
|
-
Size["Large"] = "large";
|
|
22
|
-
Size["Normal"] = "";
|
|
23
|
-
})(Size || (Size = {}));
|
|
1
|
+
export {};
|