@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.
- package/README.md +8 -8
- package/dist/baseEditor/index.svelte +32 -32
- package/dist/builders/filters/FilterBuilder.svelte +638 -638
- package/dist/forms/FormCheckbox/FormCheckbox.svelte +53 -53
- package/dist/forms/FormDatepicker/FormDatepicker.svelte +159 -159
- package/dist/forms/FormInput/FormInput.svelte +87 -87
- package/dist/forms/FormRadio/FormRadio.svelte +53 -53
- package/dist/forms/FormSelect/FormSelect.svelte +86 -86
- package/dist/forms/FormTextarea/FormTextarea.svelte +77 -77
- package/dist/forms/checkbox/Checkbox.svelte +82 -82
- package/dist/forms/checkbox/CheckboxButton.svelte +92 -92
- package/dist/forms/datepicker/Datepicker.svelte +706 -706
- package/dist/forms/form/Form.svelte +69 -69
- package/dist/forms/input/Input.svelte +363 -363
- package/dist/forms/label/Label.svelte +38 -38
- package/dist/forms/radio/Radio.svelte +48 -48
- package/dist/forms/radio/RadioButton.svelte +22 -22
- package/dist/forms/select/Select.svelte +50 -50
- package/dist/forms/textarea/Textarea.svelte +165 -165
- package/dist/layout/TF/Content/Content.svelte +28 -28
- package/dist/layout/TF/Header/Header.svelte +159 -159
- package/dist/layout/TF/Sidebar/Sidebar.svelte +74 -74
- package/dist/layout/TF/Wrapper/Wrapper.svelte +17 -17
- package/dist/themes/ThemeProvider.svelte +20 -20
- package/dist/typography/heading/Heading.svelte +35 -35
- package/dist/ui/accordion/Accordion.svelte +49 -49
- package/dist/ui/accordion/AccordionItem.svelte +173 -173
- package/dist/ui/alert/Alert.svelte +83 -83
- package/dist/ui/alertDialog/AlertDialog.svelte +40 -40
- package/dist/ui/avatar/Avatar.svelte +77 -77
- package/dist/ui/buttons/Button.svelte +102 -102
- package/dist/ui/buttons/GradientButton.svelte +59 -59
- package/dist/ui/datatable/Datatable.svelte +516 -516
- package/dist/ui/drawer/Drawer.svelte +280 -280
- package/dist/ui/dropdown/Dropdown.svelte +36 -36
- package/dist/ui/dropdown/DropdownDivider.svelte +11 -11
- package/dist/ui/dropdown/DropdownGroup.svelte +14 -14
- package/dist/ui/dropdown/DropdownHeader.svelte +14 -14
- package/dist/ui/dropdown/DropdownItem.svelte +52 -52
- package/dist/ui/footer/Footer.svelte +15 -15
- package/dist/ui/footer/FooterBrand.svelte +37 -37
- package/dist/ui/footer/FooterCopyright.svelte +45 -45
- package/dist/ui/footer/FooterIcon.svelte +22 -22
- package/dist/ui/footer/FooterLink.svelte +33 -33
- package/dist/ui/footer/FooterLinkGroup.svelte +13 -13
- package/dist/ui/indicator/Indicator.svelte +42 -42
- package/dist/ui/modal/Modal.svelte +265 -265
- package/dist/ui/notificationList/NotificationList.svelte +123 -123
- package/dist/ui/pageLoader/PageLoader.svelte +10 -10
- package/dist/ui/paginate/Paginate.svelte +96 -96
- package/dist/ui/tab/Tab.svelte +65 -65
- package/dist/ui/table/Table.svelte +385 -385
- package/dist/ui/tableLoader/TableLoader.svelte +24 -24
- package/dist/ui/toolbar/Toolbar.svelte +59 -59
- package/dist/ui/toolbar/ToolbarButton.svelte +56 -56
- package/dist/ui/toolbar/ToolbarGroup.svelte +43 -43
- package/dist/utils/Popper.svelte +257 -257
- package/dist/utils/closeButton/CloseButton.svelte +88 -88
- package/dist/utils/singleSelection.svelte.js +48 -48
- package/dist/youtube/index.svelte +12 -12
- package/package.json +7 -3
|
@@ -1,40 +1,40 @@
|
|
|
1
|
-
<script lang="ts">
|
|
2
|
-
import { Modal, Button, type AlertDialogProps } from '../../index.js';
|
|
3
|
-
|
|
4
|
-
let {
|
|
5
|
-
open = $bindable(false),
|
|
6
|
-
message = '',
|
|
7
|
-
icon = 'line-md:alert-circle',
|
|
8
|
-
disableYes = false,
|
|
9
|
-
busy = false,
|
|
10
|
-
iconColor = '',
|
|
11
|
-
confirmText = "Yes, I'm sure",
|
|
12
|
-
buttonType = 'button',
|
|
13
|
-
dismissable = true,
|
|
14
|
-
onCancel,
|
|
15
|
-
onYes
|
|
16
|
-
}: AlertDialogProps = $props();
|
|
17
|
-
</script>
|
|
18
|
-
|
|
19
|
-
<div class="fixed z-[2000]">
|
|
20
|
-
<Modal bind:open size="xs" {dismissable}>
|
|
21
|
-
<div class="text-center">
|
|
22
|
-
<iconify-icon {icon} style="font-size: 100px;" class={iconColor}></iconify-icon>
|
|
23
|
-
<h3 class="mb-5 text-lg font-normal text-gray-500 dark:text-gray-400">{message}</h3>
|
|
24
|
-
<Button
|
|
25
|
-
type={buttonType}
|
|
26
|
-
disabled={disableYes || busy}
|
|
27
|
-
color="red"
|
|
28
|
-
class="mr-2"
|
|
29
|
-
onclick={onYes}
|
|
30
|
-
><div class="flex items-center gap-1">
|
|
31
|
-
{confirmText}
|
|
32
|
-
{#if busy}
|
|
33
|
-
<iconify-icon icon="svg-spinners:180-ring-with-bg" class="text-pink-600"></iconify-icon>
|
|
34
|
-
{/if}
|
|
35
|
-
</div></Button
|
|
36
|
-
>
|
|
37
|
-
<Button color="alternative" onclick={onCancel} disabled={busy}>No, cancel</Button>
|
|
38
|
-
</div>
|
|
39
|
-
</Modal>
|
|
40
|
-
</div>
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import { Modal, Button, type AlertDialogProps } from '../../index.js';
|
|
3
|
+
|
|
4
|
+
let {
|
|
5
|
+
open = $bindable(false),
|
|
6
|
+
message = '',
|
|
7
|
+
icon = 'line-md:alert-circle',
|
|
8
|
+
disableYes = false,
|
|
9
|
+
busy = false,
|
|
10
|
+
iconColor = '',
|
|
11
|
+
confirmText = "Yes, I'm sure",
|
|
12
|
+
buttonType = 'button',
|
|
13
|
+
dismissable = true,
|
|
14
|
+
onCancel,
|
|
15
|
+
onYes
|
|
16
|
+
}: AlertDialogProps = $props();
|
|
17
|
+
</script>
|
|
18
|
+
|
|
19
|
+
<div class="fixed z-[2000]">
|
|
20
|
+
<Modal bind:open size="xs" {dismissable}>
|
|
21
|
+
<div class="text-center">
|
|
22
|
+
<iconify-icon {icon} style="font-size: 100px;" class={iconColor}></iconify-icon>
|
|
23
|
+
<h3 class="mb-5 text-lg font-normal text-gray-500 dark:text-gray-400">{message}</h3>
|
|
24
|
+
<Button
|
|
25
|
+
type={buttonType}
|
|
26
|
+
disabled={disableYes || busy}
|
|
27
|
+
color="red"
|
|
28
|
+
class="mr-2"
|
|
29
|
+
onclick={onYes}
|
|
30
|
+
><div class="flex items-center gap-1">
|
|
31
|
+
{confirmText}
|
|
32
|
+
{#if busy}
|
|
33
|
+
<iconify-icon icon="svg-spinners:180-ring-with-bg" class="text-pink-600"></iconify-icon>
|
|
34
|
+
{/if}
|
|
35
|
+
</div></Button
|
|
36
|
+
>
|
|
37
|
+
<Button color="alternative" onclick={onCancel} disabled={busy}>No, cancel</Button>
|
|
38
|
+
</div>
|
|
39
|
+
</Modal>
|
|
40
|
+
</div>
|
|
@@ -1,77 +1,77 @@
|
|
|
1
|
-
<script lang="ts">
|
|
2
|
-
import clsx from 'clsx';
|
|
3
|
-
import { avatar } from './theme.js';
|
|
4
|
-
import { Indicator } from '../indicator/index.js';
|
|
5
|
-
import { getTheme } from '../../themes/themeUtils.js';
|
|
6
|
-
import type { AvatarProps } from '../../index.js';
|
|
7
|
-
|
|
8
|
-
let {
|
|
9
|
-
children,
|
|
10
|
-
indicator,
|
|
11
|
-
src,
|
|
12
|
-
href,
|
|
13
|
-
target,
|
|
14
|
-
cornerStyle = 'circular',
|
|
15
|
-
border = false,
|
|
16
|
-
stacked = false,
|
|
17
|
-
dot,
|
|
18
|
-
class: className,
|
|
19
|
-
alt,
|
|
20
|
-
size = 'md',
|
|
21
|
-
onclick,
|
|
22
|
-
...restProps
|
|
23
|
-
}: AvatarProps = $props();
|
|
24
|
-
|
|
25
|
-
dot = dot && { placement: 'top-right', color: 'gray', size: 'lg', ...dot };
|
|
26
|
-
|
|
27
|
-
const theme = getTheme('avatar');
|
|
28
|
-
|
|
29
|
-
let avatarClass = $derived(
|
|
30
|
-
avatar({
|
|
31
|
-
cornerStyle,
|
|
32
|
-
border,
|
|
33
|
-
stacked,
|
|
34
|
-
size,
|
|
35
|
-
class: clsx(theme, className)
|
|
36
|
-
})
|
|
37
|
-
);
|
|
38
|
-
</script>
|
|
39
|
-
|
|
40
|
-
{#if !src || !!href || children || dot || indicator}
|
|
41
|
-
<svelte:element
|
|
42
|
-
this={href ? 'a' : 'div'}
|
|
43
|
-
role={href ? undefined : 'button'}
|
|
44
|
-
{onclick}
|
|
45
|
-
{href}
|
|
46
|
-
{target}
|
|
47
|
-
{...restProps}
|
|
48
|
-
class={avatarClass}
|
|
49
|
-
>
|
|
50
|
-
{#if src}
|
|
51
|
-
<img {alt} {src} class={cornerStyle === 'circular' ? 'rounded-full' : 'rounded-sm'} />
|
|
52
|
-
{:else if children}
|
|
53
|
-
{@render children()}
|
|
54
|
-
{:else}
|
|
55
|
-
<svg
|
|
56
|
-
class="h-full w-full {cornerStyle === 'circular' ? 'rounded-full' : 'rounded-sm'}"
|
|
57
|
-
fill="currentColor"
|
|
58
|
-
viewBox="0 0 16 16"
|
|
59
|
-
xmlns="http://www.w3.org/2000/svg"
|
|
60
|
-
>
|
|
61
|
-
<path
|
|
62
|
-
fill-rule="evenodd"
|
|
63
|
-
d="M8 9a3 3 0 100-6 3 3 0 000 6zm-7 9a7 7 0 1114 0H3z"
|
|
64
|
-
clip-rule="evenodd"
|
|
65
|
-
></path>
|
|
66
|
-
</svg>
|
|
67
|
-
{/if}
|
|
68
|
-
{#if dot}
|
|
69
|
-
<Indicator border offset={cornerStyle === 'circular' ? true : false} {...dot} />
|
|
70
|
-
{/if}
|
|
71
|
-
{#if indicator}
|
|
72
|
-
{@render indicator()}
|
|
73
|
-
{/if}
|
|
74
|
-
</svelte:element>
|
|
75
|
-
{:else}
|
|
76
|
-
<img {alt} {src} {...restProps} {onclick} class={avatarClass} />
|
|
77
|
-
{/if}
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import clsx from 'clsx';
|
|
3
|
+
import { avatar } from './theme.js';
|
|
4
|
+
import { Indicator } from '../indicator/index.js';
|
|
5
|
+
import { getTheme } from '../../themes/themeUtils.js';
|
|
6
|
+
import type { AvatarProps } from '../../index.js';
|
|
7
|
+
|
|
8
|
+
let {
|
|
9
|
+
children,
|
|
10
|
+
indicator,
|
|
11
|
+
src,
|
|
12
|
+
href,
|
|
13
|
+
target,
|
|
14
|
+
cornerStyle = 'circular',
|
|
15
|
+
border = false,
|
|
16
|
+
stacked = false,
|
|
17
|
+
dot,
|
|
18
|
+
class: className,
|
|
19
|
+
alt,
|
|
20
|
+
size = 'md',
|
|
21
|
+
onclick,
|
|
22
|
+
...restProps
|
|
23
|
+
}: AvatarProps = $props();
|
|
24
|
+
|
|
25
|
+
dot = dot && { placement: 'top-right', color: 'gray', size: 'lg', ...dot };
|
|
26
|
+
|
|
27
|
+
const theme = getTheme('avatar');
|
|
28
|
+
|
|
29
|
+
let avatarClass = $derived(
|
|
30
|
+
avatar({
|
|
31
|
+
cornerStyle,
|
|
32
|
+
border,
|
|
33
|
+
stacked,
|
|
34
|
+
size,
|
|
35
|
+
class: clsx(theme, className)
|
|
36
|
+
})
|
|
37
|
+
);
|
|
38
|
+
</script>
|
|
39
|
+
|
|
40
|
+
{#if !src || !!href || children || dot || indicator}
|
|
41
|
+
<svelte:element
|
|
42
|
+
this={href ? 'a' : 'div'}
|
|
43
|
+
role={href ? undefined : 'button'}
|
|
44
|
+
{onclick}
|
|
45
|
+
{href}
|
|
46
|
+
{target}
|
|
47
|
+
{...restProps}
|
|
48
|
+
class={avatarClass}
|
|
49
|
+
>
|
|
50
|
+
{#if src}
|
|
51
|
+
<img {alt} {src} class={cornerStyle === 'circular' ? 'rounded-full' : 'rounded-sm'} />
|
|
52
|
+
{:else if children}
|
|
53
|
+
{@render children()}
|
|
54
|
+
{:else}
|
|
55
|
+
<svg
|
|
56
|
+
class="h-full w-full {cornerStyle === 'circular' ? 'rounded-full' : 'rounded-sm'}"
|
|
57
|
+
fill="currentColor"
|
|
58
|
+
viewBox="0 0 16 16"
|
|
59
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
60
|
+
>
|
|
61
|
+
<path
|
|
62
|
+
fill-rule="evenodd"
|
|
63
|
+
d="M8 9a3 3 0 100-6 3 3 0 000 6zm-7 9a7 7 0 1114 0H3z"
|
|
64
|
+
clip-rule="evenodd"
|
|
65
|
+
></path>
|
|
66
|
+
</svg>
|
|
67
|
+
{/if}
|
|
68
|
+
{#if dot}
|
|
69
|
+
<Indicator border offset={cornerStyle === 'circular' ? true : false} {...dot} />
|
|
70
|
+
{/if}
|
|
71
|
+
{#if indicator}
|
|
72
|
+
{@render indicator()}
|
|
73
|
+
{/if}
|
|
74
|
+
</svelte:element>
|
|
75
|
+
{:else}
|
|
76
|
+
<img {alt} {src} {...restProps} {onclick} class={avatarClass} />
|
|
77
|
+
{/if}
|
|
@@ -1,102 +1,102 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
<script lang="ts">
|
|
4
|
-
import { getContext, type Snippet } from 'svelte';
|
|
5
|
-
import clsx from 'clsx';
|
|
6
|
-
import { button, getTheme, type ButtonProps, type SizeType } from '../../index.js';
|
|
7
|
-
|
|
8
|
-
const group: SizeType = getContext('group');
|
|
9
|
-
const ctxDisabled: boolean | undefined = getContext('disabled');
|
|
10
|
-
|
|
11
|
-
let {
|
|
12
|
-
children,
|
|
13
|
-
pill,
|
|
14
|
-
outline = false,
|
|
15
|
-
size = 'md',
|
|
16
|
-
color,
|
|
17
|
-
shadow = false,
|
|
18
|
-
tag = 'button',
|
|
19
|
-
disabled,
|
|
20
|
-
loading = false,
|
|
21
|
-
class: className,
|
|
22
|
-
leadingIcon,
|
|
23
|
-
trailingIcon,
|
|
24
|
-
ripple = true,
|
|
25
|
-
...restProps
|
|
26
|
-
}: ButtonProps = $props();
|
|
27
|
-
|
|
28
|
-
const theme = getTheme('button');
|
|
29
|
-
|
|
30
|
-
let actualSize = $derived(group ? 'sm' : size);
|
|
31
|
-
let actualColor = $derived(color ?? (group ? (outline ? 'dark' : 'alternative') : 'primary'));
|
|
32
|
-
let isDisabled = $derived(Boolean(ctxDisabled) || Boolean(disabled) || loading);
|
|
33
|
-
|
|
34
|
-
const {
|
|
35
|
-
base,
|
|
36
|
-
outline: outline_,
|
|
37
|
-
shadow: shadow_
|
|
38
|
-
} = $derived(
|
|
39
|
-
button({ color: actualColor, size: actualSize, disabled: isDisabled, pill, group: !!group })
|
|
40
|
-
);
|
|
41
|
-
let btnCls = $derived(
|
|
42
|
-
base({ class: clsx(outline && outline_(), shadow && shadow_(), theme?.base, className) })
|
|
43
|
-
);
|
|
44
|
-
|
|
45
|
-
function createRipple(event: MouseEvent) {
|
|
46
|
-
if (!ripple || isDisabled) {
|
|
47
|
-
// onclick?.(event as any);
|
|
48
|
-
return;
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
const button = event.currentTarget as HTMLElement;
|
|
52
|
-
const diameter = Math.max(button.clientWidth, button.clientHeight);
|
|
53
|
-
const radius = diameter / 2;
|
|
54
|
-
|
|
55
|
-
const rippleSpan = document.createElement('span');
|
|
56
|
-
rippleSpan.style.width = rippleSpan.style.height = `${diameter}px`;
|
|
57
|
-
rippleSpan.style.left = `${event.clientX - button.getBoundingClientRect().left - radius}px`;
|
|
58
|
-
rippleSpan.style.top = `${event.clientY - button.getBoundingClientRect().top - radius}px`;
|
|
59
|
-
rippleSpan.classList.add('ripple', 'opacity-70');
|
|
60
|
-
|
|
61
|
-
rippleSpan.addEventListener('animationend', () => {
|
|
62
|
-
{
|
|
63
|
-
// onclick?.(event as any);
|
|
64
|
-
rippleSpan.remove();
|
|
65
|
-
}
|
|
66
|
-
});
|
|
67
|
-
button.appendChild(rippleSpan);
|
|
68
|
-
}
|
|
69
|
-
</script>
|
|
70
|
-
|
|
71
|
-
{#if restProps.href === undefined}
|
|
72
|
-
<button type="button" {...restProps} class={btnCls} disabled={isDisabled}>
|
|
73
|
-
{@render leadingIcon?.()}
|
|
74
|
-
{@render children?.()}
|
|
75
|
-
{@render trailingIcon?.()}
|
|
76
|
-
|
|
77
|
-
{#if loading}
|
|
78
|
-
<svg
|
|
79
|
-
class="ml-2 h-4 w-4 animate-spin text-white"
|
|
80
|
-
fill="none"
|
|
81
|
-
viewBox="0 0 24 24"
|
|
82
|
-
xmlns="http://www.w3.org/2000/svg"
|
|
83
|
-
aria-hidden="true"
|
|
84
|
-
>
|
|
85
|
-
<circle class="opacity-25" cx="12" cy="12" r="10" stroke="currentColor" stroke-width="4" />
|
|
86
|
-
<path class="opacity-75" fill="currentColor" d="M4 12a8 8 0 018-8v4a4 4 0 00-4 4H4z" />
|
|
87
|
-
</svg>
|
|
88
|
-
{/if}
|
|
89
|
-
</button>
|
|
90
|
-
{:else if restProps.href}
|
|
91
|
-
<a {...restProps} class={btnCls} role="button">
|
|
92
|
-
{@render leadingIcon?.()}
|
|
93
|
-
{@render children?.()}
|
|
94
|
-
{@render trailingIcon?.()}
|
|
95
|
-
</a>
|
|
96
|
-
{:else}
|
|
97
|
-
<svelte:element this={tag} {...restProps} class={btnCls}>
|
|
98
|
-
{@render leadingIcon?.()}
|
|
99
|
-
{@render children?.()}
|
|
100
|
-
{@render trailingIcon?.()}
|
|
101
|
-
</svelte:element>
|
|
102
|
-
{/if}
|
|
1
|
+
|
|
2
|
+
|
|
3
|
+
<script lang="ts">
|
|
4
|
+
import { getContext, type Snippet } from 'svelte';
|
|
5
|
+
import clsx from 'clsx';
|
|
6
|
+
import { button, getTheme, type ButtonProps, type SizeType } from '../../index.js';
|
|
7
|
+
|
|
8
|
+
const group: SizeType = getContext('group');
|
|
9
|
+
const ctxDisabled: boolean | undefined = getContext('disabled');
|
|
10
|
+
|
|
11
|
+
let {
|
|
12
|
+
children,
|
|
13
|
+
pill,
|
|
14
|
+
outline = false,
|
|
15
|
+
size = 'md',
|
|
16
|
+
color,
|
|
17
|
+
shadow = false,
|
|
18
|
+
tag = 'button',
|
|
19
|
+
disabled,
|
|
20
|
+
loading = false,
|
|
21
|
+
class: className,
|
|
22
|
+
leadingIcon,
|
|
23
|
+
trailingIcon,
|
|
24
|
+
ripple = true,
|
|
25
|
+
...restProps
|
|
26
|
+
}: ButtonProps = $props();
|
|
27
|
+
|
|
28
|
+
const theme = getTheme('button');
|
|
29
|
+
|
|
30
|
+
let actualSize = $derived(group ? 'sm' : size);
|
|
31
|
+
let actualColor = $derived(color ?? (group ? (outline ? 'dark' : 'alternative') : 'primary'));
|
|
32
|
+
let isDisabled = $derived(Boolean(ctxDisabled) || Boolean(disabled) || loading);
|
|
33
|
+
|
|
34
|
+
const {
|
|
35
|
+
base,
|
|
36
|
+
outline: outline_,
|
|
37
|
+
shadow: shadow_
|
|
38
|
+
} = $derived(
|
|
39
|
+
button({ color: actualColor, size: actualSize, disabled: isDisabled, pill, group: !!group })
|
|
40
|
+
);
|
|
41
|
+
let btnCls = $derived(
|
|
42
|
+
base({ class: clsx(outline && outline_(), shadow && shadow_(), theme?.base, className) })
|
|
43
|
+
);
|
|
44
|
+
|
|
45
|
+
function createRipple(event: MouseEvent) {
|
|
46
|
+
if (!ripple || isDisabled) {
|
|
47
|
+
// onclick?.(event as any);
|
|
48
|
+
return;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
const button = event.currentTarget as HTMLElement;
|
|
52
|
+
const diameter = Math.max(button.clientWidth, button.clientHeight);
|
|
53
|
+
const radius = diameter / 2;
|
|
54
|
+
|
|
55
|
+
const rippleSpan = document.createElement('span');
|
|
56
|
+
rippleSpan.style.width = rippleSpan.style.height = `${diameter}px`;
|
|
57
|
+
rippleSpan.style.left = `${event.clientX - button.getBoundingClientRect().left - radius}px`;
|
|
58
|
+
rippleSpan.style.top = `${event.clientY - button.getBoundingClientRect().top - radius}px`;
|
|
59
|
+
rippleSpan.classList.add('ripple', 'opacity-70');
|
|
60
|
+
|
|
61
|
+
rippleSpan.addEventListener('animationend', () => {
|
|
62
|
+
{
|
|
63
|
+
// onclick?.(event as any);
|
|
64
|
+
rippleSpan.remove();
|
|
65
|
+
}
|
|
66
|
+
});
|
|
67
|
+
button.appendChild(rippleSpan);
|
|
68
|
+
}
|
|
69
|
+
</script>
|
|
70
|
+
|
|
71
|
+
{#if restProps.href === undefined}
|
|
72
|
+
<button type="button" {...restProps} class={btnCls} disabled={isDisabled}>
|
|
73
|
+
{@render leadingIcon?.()}
|
|
74
|
+
{@render children?.()}
|
|
75
|
+
{@render trailingIcon?.()}
|
|
76
|
+
|
|
77
|
+
{#if loading}
|
|
78
|
+
<svg
|
|
79
|
+
class="ml-2 h-4 w-4 animate-spin text-white"
|
|
80
|
+
fill="none"
|
|
81
|
+
viewBox="0 0 24 24"
|
|
82
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
83
|
+
aria-hidden="true"
|
|
84
|
+
>
|
|
85
|
+
<circle class="opacity-25" cx="12" cy="12" r="10" stroke="currentColor" stroke-width="4" />
|
|
86
|
+
<path class="opacity-75" fill="currentColor" d="M4 12a8 8 0 018-8v4a4 4 0 00-4 4H4z" />
|
|
87
|
+
</svg>
|
|
88
|
+
{/if}
|
|
89
|
+
</button>
|
|
90
|
+
{:else if restProps.href}
|
|
91
|
+
<a {...restProps} class={btnCls} role="button">
|
|
92
|
+
{@render leadingIcon?.()}
|
|
93
|
+
{@render children?.()}
|
|
94
|
+
{@render trailingIcon?.()}
|
|
95
|
+
</a>
|
|
96
|
+
{:else}
|
|
97
|
+
<svelte:element this={tag} {...restProps} class={btnCls}>
|
|
98
|
+
{@render leadingIcon?.()}
|
|
99
|
+
{@render children?.()}
|
|
100
|
+
{@render trailingIcon?.()}
|
|
101
|
+
</svelte:element>
|
|
102
|
+
{/if}
|
|
@@ -1,59 +1,59 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
<script lang="ts">
|
|
4
|
-
import { getContext, type Snippet } from 'svelte';
|
|
5
|
-
import clsx from 'clsx';
|
|
6
|
-
import {
|
|
7
|
-
Button,
|
|
8
|
-
getTheme,
|
|
9
|
-
gradientButton,
|
|
10
|
-
type GradientButtonProps,
|
|
11
|
-
type SizeType
|
|
12
|
-
} from '../../index.js';
|
|
13
|
-
|
|
14
|
-
const group: SizeType = getContext('group');
|
|
15
|
-
|
|
16
|
-
let {
|
|
17
|
-
children,
|
|
18
|
-
outline,
|
|
19
|
-
pill,
|
|
20
|
-
color = 'blue',
|
|
21
|
-
shadow,
|
|
22
|
-
class: className,
|
|
23
|
-
href,
|
|
24
|
-
disabled,
|
|
25
|
-
size,
|
|
26
|
-
btnClass,
|
|
27
|
-
...restProps
|
|
28
|
-
}: GradientButtonProps = $props();
|
|
29
|
-
|
|
30
|
-
const theme = getTheme('gradientButton');
|
|
31
|
-
|
|
32
|
-
const { base, outlineWrapper } = $derived(
|
|
33
|
-
gradientButton({ color, outline, pill, shadow, disabled, size, group: !!group })
|
|
34
|
-
);
|
|
35
|
-
</script>
|
|
36
|
-
|
|
37
|
-
{#if outline}
|
|
38
|
-
<div class={base({ class: clsx(theme?.base, className) })}>
|
|
39
|
-
<Button
|
|
40
|
-
{...restProps}
|
|
41
|
-
class={outlineWrapper({ class: clsx(theme?.outlineWrapper, btnClass) })}
|
|
42
|
-
{disabled}
|
|
43
|
-
{href}
|
|
44
|
-
{size}
|
|
45
|
-
>
|
|
46
|
-
{@render children?.()}
|
|
47
|
-
</Button>
|
|
48
|
-
</div>
|
|
49
|
-
{:else}
|
|
50
|
-
<Button
|
|
51
|
-
{...restProps}
|
|
52
|
-
class={base({ class: clsx(theme?.base, className) })}
|
|
53
|
-
{disabled}
|
|
54
|
-
{href}
|
|
55
|
-
{size}
|
|
56
|
-
>
|
|
57
|
-
{@render children?.()}
|
|
58
|
-
</Button>
|
|
59
|
-
{/if}
|
|
1
|
+
|
|
2
|
+
|
|
3
|
+
<script lang="ts">
|
|
4
|
+
import { getContext, type Snippet } from 'svelte';
|
|
5
|
+
import clsx from 'clsx';
|
|
6
|
+
import {
|
|
7
|
+
Button,
|
|
8
|
+
getTheme,
|
|
9
|
+
gradientButton,
|
|
10
|
+
type GradientButtonProps,
|
|
11
|
+
type SizeType
|
|
12
|
+
} from '../../index.js';
|
|
13
|
+
|
|
14
|
+
const group: SizeType = getContext('group');
|
|
15
|
+
|
|
16
|
+
let {
|
|
17
|
+
children,
|
|
18
|
+
outline,
|
|
19
|
+
pill,
|
|
20
|
+
color = 'blue',
|
|
21
|
+
shadow,
|
|
22
|
+
class: className,
|
|
23
|
+
href,
|
|
24
|
+
disabled,
|
|
25
|
+
size,
|
|
26
|
+
btnClass,
|
|
27
|
+
...restProps
|
|
28
|
+
}: GradientButtonProps = $props();
|
|
29
|
+
|
|
30
|
+
const theme = getTheme('gradientButton');
|
|
31
|
+
|
|
32
|
+
const { base, outlineWrapper } = $derived(
|
|
33
|
+
gradientButton({ color, outline, pill, shadow, disabled, size, group: !!group })
|
|
34
|
+
);
|
|
35
|
+
</script>
|
|
36
|
+
|
|
37
|
+
{#if outline}
|
|
38
|
+
<div class={base({ class: clsx(theme?.base, className) })}>
|
|
39
|
+
<Button
|
|
40
|
+
{...restProps}
|
|
41
|
+
class={outlineWrapper({ class: clsx(theme?.outlineWrapper, btnClass) })}
|
|
42
|
+
{disabled}
|
|
43
|
+
{href}
|
|
44
|
+
{size}
|
|
45
|
+
>
|
|
46
|
+
{@render children?.()}
|
|
47
|
+
</Button>
|
|
48
|
+
</div>
|
|
49
|
+
{:else}
|
|
50
|
+
<Button
|
|
51
|
+
{...restProps}
|
|
52
|
+
class={base({ class: clsx(theme?.base, className) })}
|
|
53
|
+
{disabled}
|
|
54
|
+
{href}
|
|
55
|
+
{size}
|
|
56
|
+
>
|
|
57
|
+
{@render children?.()}
|
|
58
|
+
</Button>
|
|
59
|
+
{/if}
|