@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.
@@ -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
- mode?: string;
11
- size?: string;
12
- isBordered?: boolean;
13
- isCapsule?: boolean;
14
- isGrouped?: boolean;
15
- isBlock?: boolean;
16
- isLink?: boolean;
17
- isBlank?: boolean;
18
- isDisabled?: boolean;
19
- role?: string;
20
- isCircle?: boolean;
21
- isRounded?: boolean;
22
- isSkinned?: boolean;
23
- ariaSelected?: boolean;
24
- ariaControls?: string;
25
- tabIndex?: number;
26
- onclick?: () => void;
27
- onkeydown?: (e: KeyboardEvent) => void;
28
- }
29
-
30
- let {
31
- children,
32
- css = '',
33
- style = '',
34
- mode = undefined,
35
- size = undefined,
36
- type = 'button',
37
- isBordered = false,
38
- isCapsule = false,
39
- isGrouped = false,
40
- isBlock = false,
41
- isLink = false,
42
- isBlank = false,
43
- isDisabled = false,
44
- role = undefined,
45
- isCircle = false,
46
- isRounded = false,
47
- isSkinned = true,
48
- ariaSelected = undefined,
49
- ariaControls = undefined,
50
- tabIndex = 0,
51
- onclick = undefined,
52
- onkeydown = undefined,
53
- ...restProps
54
- }: Partial<Props> = $props();
55
-
56
- let klasses = $derived(
57
- cn(
58
- isSkinned ? 'btn' : 'btn-base',
59
- mode ? `btn-${mode}` : '',
60
- size ? `btn-${size}` : '',
61
- isBordered ? 'btn-bordered' : '',
62
- isCapsule ? 'btn-capsule ' : '',
63
- isGrouped ? 'btn-grouped' : '',
64
- isBlock ? 'btn-block' : '',
65
- isCircle ? 'btn-circle' : '',
66
- isRounded ? 'btn-rounded' : '',
67
- isDisabled ? 'disabled' : '',
68
- isBlank ? 'btn-blank' : '',
69
- isLink ? 'btn-link' : '',
70
- css ? `${css}` : ''
71
- )
72
- );
73
- </script>
74
-
75
- {#if type == 'link'}
76
- <!-- svelte-ignore a11y_no_noninteractive_tabindex -->
77
- <a
78
- class={klasses}
79
- {style}
80
- {role}
81
- aria-selected={ariaSelected}
82
- aria-controls={ariaControls}
83
- tabindex={tabIndex}
84
- {onclick}
85
- {onkeydown}
86
- {...restProps}
87
- >
88
- {@render children?.()}
89
- </a>
90
- {:else}
91
- <button
92
- {type}
93
- class={klasses}
94
- {style}
95
- {role}
96
- aria-selected={ariaSelected}
97
- aria-controls={ariaControls}
98
- tabindex={tabIndex}
99
- disabled={isDisabled}
100
- {onclick}
101
- {onkeydown}
102
- {...restProps}
103
- >
104
- {@render children?.()}
105
- </button>
106
- {/if}
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 declare enum Type {
2
- Text = "text",
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 var Type;
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 {};