@rkosafo/cai.components 0.0.3 → 0.0.6

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.
Files changed (61) hide show
  1. package/README.md +8 -8
  2. package/dist/baseEditor/index.svelte +32 -32
  3. package/dist/builders/filters/FilterBuilder.svelte +638 -638
  4. package/dist/forms/FormCheckbox/FormCheckbox.svelte +53 -53
  5. package/dist/forms/FormDatepicker/FormDatepicker.svelte +159 -159
  6. package/dist/forms/FormInput/FormInput.svelte +87 -87
  7. package/dist/forms/FormRadio/FormRadio.svelte +53 -53
  8. package/dist/forms/FormSelect/FormSelect.svelte +86 -86
  9. package/dist/forms/FormTextarea/FormTextarea.svelte +77 -77
  10. package/dist/forms/checkbox/Checkbox.svelte +82 -82
  11. package/dist/forms/checkbox/CheckboxButton.svelte +92 -92
  12. package/dist/forms/datepicker/Datepicker.svelte +706 -706
  13. package/dist/forms/form/Form.svelte +69 -69
  14. package/dist/forms/input/Input.svelte +363 -363
  15. package/dist/forms/label/Label.svelte +38 -38
  16. package/dist/forms/radio/Radio.svelte +48 -48
  17. package/dist/forms/radio/RadioButton.svelte +22 -22
  18. package/dist/forms/select/Select.svelte +50 -50
  19. package/dist/forms/textarea/Textarea.svelte +165 -165
  20. package/dist/layout/TF/Content/Content.svelte +28 -28
  21. package/dist/layout/TF/Header/Header.svelte +159 -159
  22. package/dist/layout/TF/Sidebar/Sidebar.svelte +74 -74
  23. package/dist/layout/TF/Wrapper/Wrapper.svelte +17 -17
  24. package/dist/themes/ThemeProvider.svelte +20 -20
  25. package/dist/typography/heading/Heading.svelte +35 -35
  26. package/dist/ui/accordion/Accordion.svelte +49 -49
  27. package/dist/ui/accordion/AccordionItem.svelte +173 -173
  28. package/dist/ui/alert/Alert.svelte +83 -83
  29. package/dist/ui/alertDialog/AlertDialog.svelte +40 -40
  30. package/dist/ui/avatar/Avatar.svelte +77 -77
  31. package/dist/ui/buttons/Button.svelte +102 -102
  32. package/dist/ui/buttons/GradientButton.svelte +59 -59
  33. package/dist/ui/datatable/Datatable.svelte +516 -516
  34. package/dist/ui/drawer/Drawer.svelte +280 -280
  35. package/dist/ui/dropdown/Dropdown.svelte +36 -36
  36. package/dist/ui/dropdown/DropdownDivider.svelte +11 -11
  37. package/dist/ui/dropdown/DropdownGroup.svelte +14 -14
  38. package/dist/ui/dropdown/DropdownHeader.svelte +14 -14
  39. package/dist/ui/dropdown/DropdownItem.svelte +52 -52
  40. package/dist/ui/footer/Footer.svelte +15 -15
  41. package/dist/ui/footer/FooterBrand.svelte +37 -37
  42. package/dist/ui/footer/FooterCopyright.svelte +45 -45
  43. package/dist/ui/footer/FooterIcon.svelte +22 -22
  44. package/dist/ui/footer/FooterLink.svelte +33 -33
  45. package/dist/ui/footer/FooterLinkGroup.svelte +13 -13
  46. package/dist/ui/indicator/Indicator.svelte +42 -42
  47. package/dist/ui/modal/Modal.svelte +265 -265
  48. package/dist/ui/notificationList/NotificationList.svelte +123 -123
  49. package/dist/ui/pageLoader/PageLoader.svelte +10 -10
  50. package/dist/ui/paginate/Paginate.svelte +96 -96
  51. package/dist/ui/tab/Tab.svelte +65 -65
  52. package/dist/ui/table/Table.svelte +385 -385
  53. package/dist/ui/tableLoader/TableLoader.svelte +24 -24
  54. package/dist/ui/toolbar/Toolbar.svelte +59 -59
  55. package/dist/ui/toolbar/ToolbarButton.svelte +56 -56
  56. package/dist/ui/toolbar/ToolbarGroup.svelte +43 -43
  57. package/dist/utils/Popper.svelte +257 -257
  58. package/dist/utils/closeButton/CloseButton.svelte +88 -88
  59. package/dist/utils/singleSelection.svelte.js +48 -48
  60. package/dist/youtube/index.svelte +12 -12
  61. package/package.json +7 -3
@@ -1,28 +1,28 @@
1
- <script lang="ts" module>
2
- import type { Snippet } from 'svelte';
3
-
4
- export interface TFContentWrapperProps {
5
- topBar?: Snippet;
6
- children: any;
7
- }
8
- </script>
9
-
10
- <script lang="ts">
11
- let { topBar, children }: TFContentWrapperProps = $props();
12
- </script>
13
-
14
- <section id="tf-content" class="h-full w-full">
15
- {@render topBar?.()}
16
- <section class="flex h-full w-full flex-col rounded-tl-lg bg-[#f4f3ef]">
17
- <!-- {#if $activePage.showBreadCrumb}
18
- <div class="head-title pt-3 pl-6">
19
- <div class="left">
20
- <BreadCrumb options={$breadCrumb} {activeBreadCrumb} on:click={optionClicked} />
21
- </div>
22
- </div>
23
- {/if} -->
24
- <div class=" h-full w-full flex-grow overflow-hidden">
25
- {@render children()}
26
- </div>
27
- </section>
28
- </section>
1
+ <script lang="ts" module>
2
+ import type { Snippet } from 'svelte';
3
+
4
+ export interface TFContentWrapperProps {
5
+ topBar?: Snippet;
6
+ children: any;
7
+ }
8
+ </script>
9
+
10
+ <script lang="ts">
11
+ let { topBar, children }: TFContentWrapperProps = $props();
12
+ </script>
13
+
14
+ <section id="tf-content" class="h-full w-full">
15
+ {@render topBar?.()}
16
+ <section class="flex h-full w-full flex-col rounded-tl-lg bg-[#f4f3ef]">
17
+ <!-- {#if $activePage.showBreadCrumb}
18
+ <div class="head-title pt-3 pl-6">
19
+ <div class="left">
20
+ <BreadCrumb options={$breadCrumb} {activeBreadCrumb} on:click={optionClicked} />
21
+ </div>
22
+ </div>
23
+ {/if} -->
24
+ <div class=" h-full w-full flex-grow overflow-hidden">
25
+ {@render children()}
26
+ </div>
27
+ </section>
28
+ </section>
@@ -1,159 +1,159 @@
1
- <script lang="ts" module>
2
- interface UserData {
3
- firstName?: string;
4
- lastName?: string;
5
- fullName?: string;
6
- role?: string;
7
- username?: string;
8
- initials?: string;
9
- }
10
-
11
- export interface TFHeaderProps {
12
- user?: UserData;
13
- hideSidebar?: boolean;
14
- title?: string;
15
- onsignout?: () => void;
16
- notificationCount?: number;
17
- showNotifications?: boolean;
18
- // readNotifications?: () => Promise<any[]> | any[];
19
- notificationList?: Snippet;
20
- }
21
- </script>
22
-
23
- <script lang="ts">
24
- import { Avatar } from '../../../ui/avatar/index.js';
25
- import Button from '../../../ui/buttons/Button.svelte';
26
- import { slide } from 'svelte/transition';
27
-
28
- import { clickOutsideAction } from '../../../utils/svelte-legos.js';
29
- import { DropdownDivider } from '../../../ui/dropdown/index.js';
30
- import { Indicator } from '../../../ui/indicator/index.js';
31
- // import NotificationList from '../../../ui/notificationList/NotificationList.svelte';
32
- import type { Snippet } from 'svelte';
33
- let {
34
- user,
35
- hideSidebar = $bindable(false),
36
- title,
37
- onsignout,
38
- notificationCount = 0,
39
- showNotifications = true,
40
- notificationList
41
- }: TFHeaderProps = $props();
42
- let showUser = $state(false);
43
- let openNotification = $state(false);
44
- </script>
45
-
46
- <nav class="flex items-center">
47
- <button
48
- class="grid place-content-center rounded-full p-2 hover:bg-gray-200"
49
- onclick={() => (hideSidebar = !hideSidebar)}
50
- aria-label="toggle"
51
- >
52
- <iconify-icon
53
- icon={hideSidebar ? 'mdi:menu-close' : 'ic:round-menu-open'}
54
- style="font-size: 20px;"
55
- ></iconify-icon>
56
- </button>
57
- <div class="hidden flex-grow items-center gap-4 sm:flex">
58
- <div class="font-semibold text-teal-800">
59
- {title}
60
- </div>
61
- </div>
62
- <div class="flex flex-grow sm:hidden"></div>
63
- {#if showNotifications}
64
- <div
65
- class="flex items-center gap-4"
66
- use:clickOutsideAction
67
- onclickoutside={() => (openNotification = false)}
68
- >
69
- <button
70
- class="notifications relative grid cursor-pointer place-content-center hover:text-teal-400"
71
- use:clickOutsideAction
72
- onclick={() => (openNotification = !openNotification)}
73
- >
74
- <iconify-icon icon="charm:bell" class="blue-red-600 text-2xl"></iconify-icon>
75
- <Indicator
76
- color="red"
77
- border
78
- size="xl"
79
- placement="top-right"
80
- class="font- text-xs text-white {!notificationCount && 'hidden'}"
81
- >{notificationCount && notificationCount > 10 ? '10+' : notificationCount}</Indicator
82
- >
83
- </button>
84
-
85
- {@render notificationList?.()}
86
- </div>
87
- {/if}
88
-
89
- <div class="flex items-center gap-4">
90
- <div
91
- class="user grid place-content-center"
92
- use:clickOutsideAction
93
- onclickoutside={() => (showUser = false)}
94
- >
95
- <Button
96
- color="light"
97
- pill
98
- class="h-10 max-w-[150px] border-gray-300 !p-0 sm:!p-1"
99
- ripple={false}
100
- onclick={() => (showUser = !showUser)}
101
- >
102
- <Avatar class="h-9 w-9 bg-sky-300 text-sm sm:mr-2">
103
- {user?.initials}
104
- </Avatar>
105
- <div class="hidden text-left text-xs sm:block sm:pr-2">
106
- <div class="w-20 truncate">
107
- <span class="font-semibold text-black">{user?.firstName}</span>
108
- </div>
109
- {#if user?.role}
110
- <div class="w-20 truncate text-gray-500">
111
- <span>{user.role}</span>
112
- </div>
113
- {:else}
114
- <p class="flex w-20 truncate text-gray-500">{user?.username}</p>
115
- {/if}
116
- </div>
117
- </Button>
118
- {#if showUser}
119
- <div class="relative">
120
- <div
121
- class="absolute right-0 z-10 mt-2 rounded-md bg-white
122
- py-2 shadow-md shadow-gray-300
123
- "
124
- transition:slide
125
- use:clickOutsideAction
126
- >
127
- <div class="space-y-2 px-4 py-2">
128
- <span class="block truncate text-sm font-bold">{user?.fullName}</span>
129
- <div class="block truncate text-sm">
130
- <span class="font-light text-gray-500">Role:</span>
131
- <span class="font-bold">{user?.role}</span>
132
- </div>
133
- <div class="block truncate text-sm">
134
- <span class="font-light text-gray-500">Username:</span>
135
- <span class="font-bold">{user?.username}</span>
136
- </div>
137
- </div>
138
- <DropdownDivider />
139
- <div class="grid">
140
- <Button
141
- ripple={false}
142
- class="mx-0.5 flex gap-1 justify-start border bg-red-50 text-red-600 hover:bg-red-100"
143
- onclick={() => {
144
- showUser = false;
145
- onsignout?.();
146
- }}
147
- >
148
- {#snippet leadingIcon()}
149
- <iconify-icon icon="stash:signout" style="font-size: 20px;"></iconify-icon>
150
- {/snippet}
151
- Sign Out
152
- </Button>
153
- </div>
154
- </div>
155
- </div>
156
- {/if}
157
- </div>
158
- </div>
159
- </nav>
1
+ <script lang="ts" module>
2
+ interface UserData {
3
+ firstName?: string;
4
+ lastName?: string;
5
+ fullName?: string;
6
+ role?: string;
7
+ username?: string;
8
+ initials?: string;
9
+ }
10
+
11
+ export interface TFHeaderProps {
12
+ user?: UserData;
13
+ hideSidebar?: boolean;
14
+ title?: string;
15
+ onsignout?: () => void;
16
+ notificationCount?: number;
17
+ showNotifications?: boolean;
18
+ // readNotifications?: () => Promise<any[]> | any[];
19
+ notificationList?: Snippet;
20
+ }
21
+ </script>
22
+
23
+ <script lang="ts">
24
+ import { Avatar } from '../../../ui/avatar/index.js';
25
+ import Button from '../../../ui/buttons/Button.svelte';
26
+ import { slide } from 'svelte/transition';
27
+
28
+ import { clickOutsideAction } from '../../../utils/svelte-legos.js';
29
+ import { DropdownDivider } from '../../../ui/dropdown/index.js';
30
+ import { Indicator } from '../../../ui/indicator/index.js';
31
+ // import NotificationList from '../../../ui/notificationList/NotificationList.svelte';
32
+ import type { Snippet } from 'svelte';
33
+ let {
34
+ user,
35
+ hideSidebar = $bindable(false),
36
+ title,
37
+ onsignout,
38
+ notificationCount = 0,
39
+ showNotifications = true,
40
+ notificationList
41
+ }: TFHeaderProps = $props();
42
+ let showUser = $state(false);
43
+ let openNotification = $state(false);
44
+ </script>
45
+
46
+ <nav class="flex items-center">
47
+ <button
48
+ class="grid place-content-center rounded-full p-2 hover:bg-gray-200"
49
+ onclick={() => (hideSidebar = !hideSidebar)}
50
+ aria-label="toggle"
51
+ >
52
+ <iconify-icon
53
+ icon={hideSidebar ? 'mdi:menu-close' : 'ic:round-menu-open'}
54
+ style="font-size: 20px;"
55
+ ></iconify-icon>
56
+ </button>
57
+ <div class="hidden flex-grow items-center gap-4 sm:flex">
58
+ <div class="font-semibold text-teal-800">
59
+ {title}
60
+ </div>
61
+ </div>
62
+ <div class="flex flex-grow sm:hidden"></div>
63
+ {#if showNotifications}
64
+ <div
65
+ class="flex items-center gap-4"
66
+ use:clickOutsideAction
67
+ onclickoutside={() => (openNotification = false)}
68
+ >
69
+ <button
70
+ class="notifications relative grid cursor-pointer place-content-center hover:text-teal-400"
71
+ use:clickOutsideAction
72
+ onclick={() => (openNotification = !openNotification)}
73
+ >
74
+ <iconify-icon icon="charm:bell" class="blue-red-600 text-2xl"></iconify-icon>
75
+ <Indicator
76
+ color="red"
77
+ border
78
+ size="xl"
79
+ placement="top-right"
80
+ class="font- text-xs text-white {!notificationCount && 'hidden'}"
81
+ >{notificationCount && notificationCount > 10 ? '10+' : notificationCount}</Indicator
82
+ >
83
+ </button>
84
+
85
+ {@render notificationList?.()}
86
+ </div>
87
+ {/if}
88
+
89
+ <div class="flex items-center gap-4">
90
+ <div
91
+ class="user grid place-content-center"
92
+ use:clickOutsideAction
93
+ onclickoutside={() => (showUser = false)}
94
+ >
95
+ <Button
96
+ color="light"
97
+ pill
98
+ class="h-10 max-w-[150px] border-gray-300 !p-0 sm:!p-1"
99
+ ripple={false}
100
+ onclick={() => (showUser = !showUser)}
101
+ >
102
+ <Avatar class="h-9 w-9 bg-sky-300 text-sm sm:mr-2">
103
+ {user?.initials}
104
+ </Avatar>
105
+ <div class="hidden text-left text-xs sm:block sm:pr-2">
106
+ <div class="w-20 truncate">
107
+ <span class="font-semibold text-black">{user?.firstName}</span>
108
+ </div>
109
+ {#if user?.role}
110
+ <div class="w-20 truncate text-gray-500">
111
+ <span>{user.role}</span>
112
+ </div>
113
+ {:else}
114
+ <p class="flex w-20 truncate text-gray-500">{user?.username}</p>
115
+ {/if}
116
+ </div>
117
+ </Button>
118
+ {#if showUser}
119
+ <div class="relative">
120
+ <div
121
+ class="absolute right-0 z-10 mt-2 rounded-md bg-white
122
+ py-2 shadow-md shadow-gray-300
123
+ "
124
+ transition:slide
125
+ use:clickOutsideAction
126
+ >
127
+ <div class="space-y-2 px-4 py-2">
128
+ <span class="block truncate text-sm font-bold">{user?.fullName}</span>
129
+ <div class="block truncate text-sm">
130
+ <span class="font-light text-gray-500">Role:</span>
131
+ <span class="font-bold">{user?.role}</span>
132
+ </div>
133
+ <div class="block truncate text-sm">
134
+ <span class="font-light text-gray-500">Username:</span>
135
+ <span class="font-bold">{user?.username}</span>
136
+ </div>
137
+ </div>
138
+ <DropdownDivider />
139
+ <div class="grid">
140
+ <Button
141
+ ripple={false}
142
+ class="mx-0.5 flex gap-1 justify-start border bg-red-50 text-red-600 hover:bg-red-100"
143
+ onclick={() => {
144
+ showUser = false;
145
+ onsignout?.();
146
+ }}
147
+ >
148
+ {#snippet leadingIcon()}
149
+ <iconify-icon icon="stash:signout" style="font-size: 20px;"></iconify-icon>
150
+ {/snippet}
151
+ Sign Out
152
+ </Button>
153
+ </div>
154
+ </div>
155
+ </div>
156
+ {/if}
157
+ </div>
158
+ </div>
159
+ </nav>
@@ -1,74 +1,74 @@
1
- <script lang="ts" module>
2
- export interface TFSidebarProps {
3
- homeUrl: string;
4
- logoUrl: string;
5
- appShortName: string;
6
- appName: string;
7
- hideSidebar?: boolean;
8
- menuItems: IMenuItem[];
9
- logo?: Snippet;
10
- }
11
-
12
- export interface IMenuItem {
13
- title: string;
14
- icon?: string;
15
- path?: string;
16
- items?: IMenuItem[] | null;
17
- description?: string;
18
- iconBg?: string;
19
- iconColor?: string;
20
- iconSize?: number;
21
- }
22
- </script>
23
-
24
- <script lang="ts">
25
- import { cn } from '../../../utils/index.js';
26
- import { page } from '$app/state';
27
- import type { Snippet } from 'svelte';
28
-
29
- let {
30
- homeUrl,
31
- logoUrl,
32
- appName,
33
- appShortName,
34
- hideSidebar = false,
35
- menuItems = [],
36
- logo
37
- }: TFSidebarProps = $props();
38
-
39
- let activeUrl = $state('');
40
- $effect(() => {
41
- activeUrl = page.url.pathname;
42
- });
43
- </script>
44
-
45
- {#snippet menuItemSnippet(item: IMenuItem, active: boolean)}
46
- <li class:active class="relative">
47
- <a class="space-x-3 pl-3" href={item.path}>
48
- <iconify-icon icon={item.icon}></iconify-icon>
49
-
50
- <span class="text hidden md:block">{item.title}</span>
51
- </a>
52
- </li>
53
- {/snippet}
54
- <section id="tf-sidebar" class={cn('relative')} class:hide={hideSidebar}>
55
- <a href={homeUrl} class="brand flex flex-col pt-4">
56
- {#if logo}
57
- {@render logo()}
58
- {:else}
59
- <img src={logoUrl} alt="Logo" class={hideSidebar ? 'w-12' : 'w-12 md:w-24'} loading="lazy" />
60
- {/if}
61
- <span class="text-base font-thin {hideSidebar ? 'block' : 'md:hidden'}">{appShortName}</span>
62
- <p class="text-center text-lg font-medium {hideSidebar ? 'hidden' : 'hidden md:block'}">
63
- {appName}
64
- </p>
65
- </a>
66
- {#if menuItems.length > 0}
67
- <ul class="side-menu top relative pt-4">
68
- {#each menuItems as item}
69
- {@const active = activeUrl === item.path}
70
- {@render menuItemSnippet(item, active)}
71
- {/each}
72
- </ul>
73
- {/if}
74
- </section>
1
+ <script lang="ts" module>
2
+ export interface TFSidebarProps {
3
+ homeUrl: string;
4
+ logoUrl: string;
5
+ appShortName: string;
6
+ appName: string;
7
+ hideSidebar?: boolean;
8
+ menuItems: IMenuItem[];
9
+ logo?: Snippet;
10
+ }
11
+
12
+ export interface IMenuItem {
13
+ title: string;
14
+ icon?: string;
15
+ path?: string;
16
+ items?: IMenuItem[] | null;
17
+ description?: string;
18
+ iconBg?: string;
19
+ iconColor?: string;
20
+ iconSize?: number;
21
+ }
22
+ </script>
23
+
24
+ <script lang="ts">
25
+ import { cn } from '../../../utils/index.js';
26
+ import { page } from '$app/state';
27
+ import type { Snippet } from 'svelte';
28
+
29
+ let {
30
+ homeUrl,
31
+ logoUrl,
32
+ appName,
33
+ appShortName,
34
+ hideSidebar = false,
35
+ menuItems = [],
36
+ logo
37
+ }: TFSidebarProps = $props();
38
+
39
+ let activeUrl = $state('');
40
+ $effect(() => {
41
+ activeUrl = page.url.pathname;
42
+ });
43
+ </script>
44
+
45
+ {#snippet menuItemSnippet(item: IMenuItem, active: boolean)}
46
+ <li class:active class="relative">
47
+ <a class="space-x-3 pl-3" href={item.path}>
48
+ <iconify-icon icon={item.icon}></iconify-icon>
49
+
50
+ <span class="text hidden md:block">{item.title}</span>
51
+ </a>
52
+ </li>
53
+ {/snippet}
54
+ <section id="tf-sidebar" class={cn('relative')} class:hide={hideSidebar}>
55
+ <a href={homeUrl} class="brand flex flex-col pt-4">
56
+ {#if logo}
57
+ {@render logo()}
58
+ {:else}
59
+ <img src={logoUrl} alt="Logo" class={hideSidebar ? 'w-12' : 'w-12 md:w-24'} loading="lazy" />
60
+ {/if}
61
+ <span class="text-base font-thin {hideSidebar ? 'block' : 'md:hidden'}">{appShortName}</span>
62
+ <p class="text-center text-lg font-medium {hideSidebar ? 'hidden' : 'hidden md:block'}">
63
+ {appName}
64
+ </p>
65
+ </a>
66
+ {#if menuItems.length > 0}
67
+ <ul class="side-menu top relative pt-4">
68
+ {#each menuItems as item}
69
+ {@const active = activeUrl === item.path}
70
+ {@render menuItemSnippet(item, active)}
71
+ {/each}
72
+ </ul>
73
+ {/if}
74
+ </section>
@@ -1,17 +1,17 @@
1
- <script lang="ts" module>
2
- import type { Snippet } from 'svelte';
3
-
4
- export interface TFLayoutWrapperProps {
5
- sidebar: Snippet;
6
- content: Snippet;
7
- }
8
- </script>
9
-
10
- <script lang="ts">
11
- let { sidebar, content }: TFLayoutWrapperProps = $props();
12
- </script>
13
-
14
- <div class="h-full w-full overflow-hidden">
15
- {@render sidebar()}
16
- {@render content()}
17
- </div>
1
+ <script lang="ts" module>
2
+ import type { Snippet } from 'svelte';
3
+
4
+ export interface TFLayoutWrapperProps {
5
+ sidebar: Snippet;
6
+ content: Snippet;
7
+ }
8
+ </script>
9
+
10
+ <script lang="ts">
11
+ let { sidebar, content }: TFLayoutWrapperProps = $props();
12
+ </script>
13
+
14
+ <div class="h-full w-full overflow-hidden">
15
+ {@render sidebar()}
16
+ {@render content()}
17
+ </div>
@@ -1,20 +1,20 @@
1
- <script lang="ts">
2
- import type { Snippet } from 'svelte';
3
- import { setContext } from 'svelte';
4
- import type { ThemeConfig } from './index.js';
5
-
6
- interface ThemeProviderProps {
7
- children: Snippet;
8
- theme?: ThemeConfig;
9
- }
10
-
11
- let { children, theme }: ThemeProviderProps = $props();
12
-
13
- if (theme) {
14
- setContext('theme', theme);
15
- } else {
16
- console.log('ThemeProvider: No theme provided');
17
- }
18
- </script>
19
-
20
- {@render children()}
1
+ <script lang="ts">
2
+ import type { Snippet } from 'svelte';
3
+ import { setContext } from 'svelte';
4
+ import type { ThemeConfig } from './index.js';
5
+
6
+ interface ThemeProviderProps {
7
+ children: Snippet;
8
+ theme?: ThemeConfig;
9
+ }
10
+
11
+ let { children, theme }: ThemeProviderProps = $props();
12
+
13
+ if (theme) {
14
+ setContext('theme', theme);
15
+ } else {
16
+ console.log('ThemeProvider: No theme provided');
17
+ }
18
+ </script>
19
+
20
+ {@render children()}
@@ -1,35 +1,35 @@
1
- <script lang="ts" module>
2
- // heading
3
- export interface HeadingProps extends HTMLAttributes<HTMLElement> {
4
- children: Snippet;
5
- tag?: HeadingVariants['tag'];
6
- }
7
-
8
- // // hr
9
- // export interface HrProps extends HrVariants, HTMLAttributes<HTMLElement> {
10
- // children?: Snippet;
11
- // divClass?: string;
12
- // iconDivClass?: string;
13
- // textSpanClass?: string;
14
- // innerDivClass?: string;
15
- // }
16
- </script>
17
-
18
- <script lang="ts">
19
- import { getTheme } from '../../index.js';
20
- import clsx from 'clsx';
21
- import { heading } from './index.js';
22
- import type { HTMLAttributes } from 'svelte/elements';
23
- import type { Snippet } from 'svelte';
24
- import type { HeadingVariants } from './theme.js';
25
-
26
- let { children, tag = 'h1', class: className, ...restProps }: HeadingProps = $props();
27
-
28
- const theme = getTheme('heading');
29
-
30
- let headingCls = $derived(heading({ tag, class: clsx(theme, className) }));
31
- </script>
32
-
33
- <svelte:element this={tag} {...restProps} class={headingCls}>
34
- {@render children()}
35
- </svelte:element>
1
+ <script lang="ts" module>
2
+ // heading
3
+ export interface HeadingProps extends HTMLAttributes<HTMLElement> {
4
+ children: Snippet;
5
+ tag?: HeadingVariants['tag'];
6
+ }
7
+
8
+ // // hr
9
+ // export interface HrProps extends HrVariants, HTMLAttributes<HTMLElement> {
10
+ // children?: Snippet;
11
+ // divClass?: string;
12
+ // iconDivClass?: string;
13
+ // textSpanClass?: string;
14
+ // innerDivClass?: string;
15
+ // }
16
+ </script>
17
+
18
+ <script lang="ts">
19
+ import { getTheme } from '../../index.js';
20
+ import clsx from 'clsx';
21
+ import { heading } from './index.js';
22
+ import type { HTMLAttributes } from 'svelte/elements';
23
+ import type { Snippet } from 'svelte';
24
+ import type { HeadingVariants } from './theme.js';
25
+
26
+ let { children, tag = 'h1', class: className, ...restProps }: HeadingProps = $props();
27
+
28
+ const theme = getTheme('heading');
29
+
30
+ let headingCls = $derived(heading({ tag, class: clsx(theme, className) }));
31
+ </script>
32
+
33
+ <svelte:element this={tag} {...restProps} class={headingCls}>
34
+ {@render children()}
35
+ </svelte:element>