svelora 3.0.0 → 3.0.2
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/Accordion/Accordion.svelte +66 -97
- package/dist/Alert/Alert.svelte +39 -64
- package/dist/Alert/Alert.svelte.d.ts +1 -1
- package/dist/Avatar/Avatar.svelte +35 -75
- package/dist/AvatarGroup/AvatarGroup.svelte +38 -55
- package/dist/Badge/Badge.svelte +28 -50
- package/dist/Banner/Banner.svelte +46 -41
- package/dist/Banner/Banner.svelte.d.ts +1 -1
- package/dist/Breadcrumb/Breadcrumb.svelte +32 -26
- package/dist/Button/Button.svelte +70 -138
- package/dist/Calendar/Calendar.svelte +94 -157
- package/dist/Calendar/Calendar.svelte.d.ts +1 -1
- package/dist/Card/Card.svelte +18 -31
- package/dist/Carousel/Carousel.svelte +118 -173
- package/dist/Checkbox/Checkbox.svelte +52 -97
- package/dist/CheckboxGroup/CheckboxGroup.svelte +62 -107
- package/dist/CheckboxGroup/CheckboxGroup.svelte.d.ts +1 -1
- package/dist/Chip/Chip.svelte +22 -34
- package/dist/CodeBlock/CodeBlock.svelte +42 -59
- package/dist/Collapsible/Collapsible.svelte +22 -38
- package/dist/Collapsible/Collapsible.svelte.d.ts +1 -1
- package/dist/Collapsible/CollapsibleTestWrapper.svelte +2 -5
- package/dist/Collapsible/CollapsibleTestWrapper.svelte.d.ts +1 -1
- package/dist/Command/Command.svelte +40 -77
- package/dist/Command/Command.svelte.d.ts +1 -1
- package/dist/Command/CommandTestWrapper.svelte +2 -10
- package/dist/Command/CommandTestWrapper.svelte.d.ts +1 -1
- package/dist/Container/Container.svelte +11 -14
- package/dist/ContextMenu/ContextMenu.svelte +51 -114
- package/dist/ContextMenu/ContextMenu.svelte.d.ts +1 -1
- package/dist/Drawer/Drawer.svelte +72 -110
- package/dist/Drawer/DrawerTriggerTestWrapper.svelte +1 -2
- package/dist/DropdownMenu/DropdownMenu.svelte +63 -124
- package/dist/DropdownMenu/DropdownMenu.svelte.d.ts +1 -1
- package/dist/DropdownMenu/DropdownMenuTriggerTestWrapper.svelte +2 -5
- package/dist/Editor/Editor.svelte +441 -576
- package/dist/Editor/Editor.svelte.d.ts +1 -1
- package/dist/Editor/EditorUrlPrompt.svelte +40 -53
- package/dist/Editor/SlashPopup.svelte +12 -24
- package/dist/Empty/Empty.svelte +32 -63
- package/dist/FieldGroup/FieldGroup.svelte +23 -38
- package/dist/FileUpload/FileUpload.svelte +242 -320
- package/dist/FileUpload/FileUpload.svelte.d.ts +1 -1
- package/dist/Fonts/Fonts.svelte +15 -37
- package/dist/Form/Form.svelte +112 -170
- package/dist/FormField/FormField.svelte +102 -135
- package/dist/Icon/Icon.svelte +7 -32
- package/dist/Input/Input.svelte +71 -141
- package/dist/Input/Input.svelte.d.ts +2 -2
- package/dist/Kbd/Kbd.svelte +18 -34
- package/dist/Link/Link.svelte +129 -196
- package/dist/LocaleButton/LocaleButton.svelte +165 -0
- package/dist/LocaleButton/LocaleButton.svelte.d.ts +5 -0
- package/dist/LocaleButton/index.d.ts +2 -0
- package/dist/LocaleButton/index.js +1 -0
- package/dist/LocaleButton/locale-button.types.d.ts +182 -0
- package/dist/LocaleButton/locale-button.types.js +1 -0
- package/dist/LocaleButton/locale-button.variants.d.ts +61 -0
- package/dist/LocaleButton/locale-button.variants.js +34 -0
- package/dist/Modal/Modal.svelte +52 -106
- package/dist/Modal/ModalTriggerTestWrapper.svelte +1 -2
- package/dist/Pagination/Pagination.svelte +48 -92
- package/dist/Pagination/pagination.variants.d.ts +1 -1
- package/dist/PinInput/PinInput.svelte +57 -111
- package/dist/PinInput/PinInput.svelte.d.ts +1 -1
- package/dist/Popover/Popover.svelte +28 -61
- package/dist/Popover/Popover.svelte.d.ts +1 -1
- package/dist/Progress/Progress.svelte +75 -94
- package/dist/RadioGroup/RadioGroup.svelte +54 -99
- package/dist/RadioGroup/RadioGroup.svelte.d.ts +1 -1
- package/dist/Select/Select.svelte +112 -269
- package/dist/Select/Select.svelte.d.ts +1 -1
- package/dist/SelectMenu/SelectMenu.svelte +211 -409
- package/dist/SelectMenu/SelectMenu.svelte.d.ts +1 -1
- package/dist/SelectMenu/SelectMenuFormFieldTestWrapper.svelte +3 -6
- package/dist/Separator/Separator.svelte +29 -44
- package/dist/Skeleton/Skeleton.svelte +11 -23
- package/dist/Slideover/Slideover.svelte +52 -106
- package/dist/Slideover/SlideoverTriggerTestWrapper.svelte +1 -2
- package/dist/Slider/Slider.svelte +48 -84
- package/dist/Slider/Slider.svelte.d.ts +1 -1
- package/dist/Stepper/Stepper.svelte +139 -132
- package/dist/Stepper/Stepper.svelte.d.ts +1 -1
- package/dist/Switch/Switch.svelte +62 -98
- package/dist/Table/Table.svelte +232 -283
- package/dist/Table/table.variants.d.ts +1 -1
- package/dist/Tabs/Tabs.svelte +96 -129
- package/dist/Tabs/Tabs.svelte.d.ts +1 -1
- package/dist/Textarea/Textarea.svelte +90 -173
- package/dist/Textarea/Textarea.svelte.d.ts +1 -1
- package/dist/ThemeModeButton/ThemeModeButton.svelte +16 -38
- package/dist/Timeline/Timeline.svelte +75 -54
- package/dist/Toast/Toaster.svelte +8 -25
- package/dist/Tooltip/Tooltip.svelte +34 -66
- package/dist/Tooltip/Tooltip.svelte.d.ts +1 -1
- package/dist/Tooltip/TooltipTestWrapper.svelte +2 -5
- package/dist/User/User.svelte +33 -49
- package/dist/docs/navigation.d.ts +1 -1
- package/dist/docs/navigation.js +8 -1
- package/dist/hooks/HookContextProbe.svelte +2 -4
- package/dist/hooks/HookContextProvider.svelte +8 -6
- package/dist/hooks/HookEmitProbe.svelte +8 -11
- package/dist/i18n.d.ts +2 -0
- package/dist/i18n.js +19 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/dist/mcp/svelora-docs.data.json +4 -2
- package/dist/theme.css +1 -1
- package/package.json +16 -8
|
@@ -1,57 +1,62 @@
|
|
|
1
|
-
<script lang="ts" module>
|
|
2
|
-
export type Props = BannerProps;
|
|
1
|
+
<script lang="ts" module>export {};
|
|
3
2
|
</script>
|
|
4
3
|
|
|
5
|
-
<script lang="ts">import { useId } from
|
|
6
|
-
import Button from
|
|
7
|
-
import { getComponentConfig, iconsDefaults } from
|
|
8
|
-
import Icon from
|
|
9
|
-
import { bannerDefaults, bannerVariants } from
|
|
10
|
-
|
|
11
|
-
const
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
const fallbackId = useId('banner-');
|
|
4
|
+
<script lang="ts">import { useId } from "bits-ui";
|
|
5
|
+
import Button from "../Button/Button.svelte";
|
|
6
|
+
import { getComponentConfig, iconsDefaults } from "../config.js";
|
|
7
|
+
import Icon from "../Icon/Icon.svelte";
|
|
8
|
+
import { bannerDefaults, bannerVariants } from "./banner.variants.js";
|
|
9
|
+
const config = getComponentConfig("banner", bannerDefaults);
|
|
10
|
+
const icons = getComponentConfig("icons", iconsDefaults);
|
|
11
|
+
let { ref = $bindable(null), as = "div", id, title, icon, color = config.defaultVariants.color, to, target, close = false, closeIcon, actions, open = $bindable(true), onClose, class: className, ui, leading, titleSlot, actionsSlot, closeSlot, ...restProps } = $props();
|
|
12
|
+
const fallbackId = useId("banner-");
|
|
15
13
|
const effectiveId = $derived(id ?? fallbackId);
|
|
16
14
|
let dismissed = $state(false);
|
|
17
|
-
function storageKey(rawId
|
|
18
|
-
|
|
15
|
+
function storageKey(rawId) {
|
|
16
|
+
return `ps-banner-${rawId.replace(/[^\w-]/g, "-")}`;
|
|
19
17
|
}
|
|
20
18
|
$effect(() => {
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
19
|
+
void open;
|
|
20
|
+
if (!id || typeof window === "undefined") {
|
|
21
|
+
dismissed = false;
|
|
22
|
+
return;
|
|
23
|
+
}
|
|
24
|
+
dismissed = localStorage.getItem(storageKey(id)) === "1";
|
|
27
25
|
});
|
|
28
26
|
const visible = $derived(open && !dismissed);
|
|
29
27
|
const isClickable = $derived(!!to);
|
|
30
28
|
const resolvedCloseIcon = $derived(closeIcon ?? icons.close);
|
|
31
29
|
const closeButtonProps = $derived(!close ? null : close === true ? {} : close);
|
|
32
30
|
const classes = $derived.by(() => {
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
31
|
+
const slots = bannerVariants({
|
|
32
|
+
color,
|
|
33
|
+
to: isClickable
|
|
34
|
+
});
|
|
35
|
+
const c = config.slots;
|
|
36
|
+
const u = ui ?? {};
|
|
37
|
+
return {
|
|
38
|
+
root: slots.root({ class: [
|
|
39
|
+
c.root,
|
|
40
|
+
className,
|
|
41
|
+
u.root
|
|
42
|
+
] }),
|
|
43
|
+
container: slots.container({ class: [c.container, u.container] }),
|
|
44
|
+
left: slots.left({ class: [c.left, u.left] }),
|
|
45
|
+
center: slots.center({ class: [c.center, u.center] }),
|
|
46
|
+
right: slots.right({ class: [c.right, u.right] }),
|
|
47
|
+
icon: slots.icon({ class: [c.icon, u.icon] }),
|
|
48
|
+
title: slots.title({ class: [c.title, u.title] }),
|
|
49
|
+
actions: slots.actions({ class: [c.actions, u.actions] }),
|
|
50
|
+
close: slots.close({ class: [c.close, u.close] })
|
|
51
|
+
};
|
|
47
52
|
});
|
|
48
|
-
function handleClose(event
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
53
|
+
function handleClose(event) {
|
|
54
|
+
event?.stopPropagation();
|
|
55
|
+
if (id && typeof window !== "undefined") {
|
|
56
|
+
localStorage.setItem(storageKey(id), "1");
|
|
57
|
+
}
|
|
58
|
+
open = false;
|
|
59
|
+
onClose?.();
|
|
55
60
|
}
|
|
56
61
|
</script>
|
|
57
62
|
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { BannerProps } from './banner.types.js';
|
|
2
2
|
export type Props = BannerProps;
|
|
3
|
-
declare const Banner: import("svelte").Component<BannerProps, {}, "
|
|
3
|
+
declare const Banner: import("svelte").Component<BannerProps, {}, "open" | "ref">;
|
|
4
4
|
type Banner = ReturnType<typeof Banner>;
|
|
5
5
|
export default Banner;
|
|
@@ -1,34 +1,40 @@
|
|
|
1
|
-
<script lang="ts" module>
|
|
2
|
-
export type Props = BreadcrumbProps;
|
|
1
|
+
<script lang="ts" module>export {};
|
|
3
2
|
</script>
|
|
4
3
|
|
|
5
|
-
<script lang="ts">import
|
|
6
|
-
import
|
|
7
|
-
import
|
|
8
|
-
import
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
const config = getComponentConfig('breadcrumb', breadcrumbDefaults);
|
|
12
|
-
let { ref = $bindable(null), as = 'nav', items, separatorIcon = 'lucide:chevron-right', class: className, ui, item: itemSnippet, separator: separatorSnippet, ...restProps }: Props = $props();
|
|
4
|
+
<script lang="ts">import { getComponentConfig } from "../config.js";
|
|
5
|
+
import Icon from "../Icon/Icon.svelte";
|
|
6
|
+
import Link from "../Link/Link.svelte";
|
|
7
|
+
import { breadcrumbDefaults, breadcrumbVariants } from "./breadcrumb.variants.js";
|
|
8
|
+
const config = getComponentConfig("breadcrumb", breadcrumbDefaults);
|
|
9
|
+
let { ref = $bindable(null), as = "nav", items, separatorIcon = "lucide:chevron-right", class: className, ui, item: itemSnippet, separator: separatorSnippet, ...restProps } = $props();
|
|
13
10
|
const variantSlots = $derived(breadcrumbVariants(config.defaultVariants));
|
|
14
11
|
const classes = $derived({
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
12
|
+
root: variantSlots.root({ class: [
|
|
13
|
+
config.slots.root,
|
|
14
|
+
className,
|
|
15
|
+
ui?.root
|
|
16
|
+
] }),
|
|
17
|
+
list: variantSlots.list({ class: [config.slots.list, ui?.list] }),
|
|
18
|
+
separator: variantSlots.separator({ class: [config.slots.separator, ui?.separator] }),
|
|
19
|
+
separatorIcon: variantSlots.separatorIcon({ class: [config.slots.separatorIcon, ui?.separatorIcon] })
|
|
21
20
|
});
|
|
22
|
-
function getLinkClasses(active
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
21
|
+
function getLinkClasses(active, disabled, to, itemClass) {
|
|
22
|
+
const slots = breadcrumbVariants({
|
|
23
|
+
...config.defaultVariants,
|
|
24
|
+
active,
|
|
25
|
+
disabled,
|
|
26
|
+
to
|
|
27
|
+
});
|
|
28
|
+
return {
|
|
29
|
+
item: slots.item({ class: [config.slots.item, ui?.item] }),
|
|
30
|
+
link: slots.link({ class: [
|
|
31
|
+
config.slots.link,
|
|
32
|
+
itemClass,
|
|
33
|
+
ui?.link
|
|
34
|
+
] }),
|
|
35
|
+
linkLeadingIcon: slots.linkLeadingIcon({ class: [config.slots.linkLeadingIcon, ui?.linkLeadingIcon] }),
|
|
36
|
+
linkLabel: slots.linkLabel({ class: [config.slots.linkLabel, ui?.linkLabel] })
|
|
37
|
+
};
|
|
32
38
|
}
|
|
33
39
|
</script>
|
|
34
40
|
|
|
@@ -1,143 +1,75 @@
|
|
|
1
|
-
<script lang="ts" module>
|
|
2
|
-
import type { ButtonProps } from './button.types.js'
|
|
3
|
-
|
|
4
|
-
export type Props = ButtonProps
|
|
1
|
+
<script lang="ts" module>export {};
|
|
5
2
|
</script>
|
|
6
3
|
|
|
7
|
-
<script lang="ts">
|
|
8
|
-
|
|
9
|
-
|
|
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
|
-
const isLeading = $derived((!!icon && !trailing) || (isLoading && !trailing) || !!leadingIcon)
|
|
77
|
-
const isTrailing = $derived((!!icon && trailing) || (isLoading && trailing) || !!trailingIcon)
|
|
78
|
-
|
|
79
|
-
const spinLeading = $derived(isLoading && !trailing)
|
|
80
|
-
const spinTrailing = $derived(isLoading && trailing)
|
|
81
|
-
|
|
82
|
-
const leadingIconName = $derived(
|
|
83
|
-
spinLeading ? loadingIcon : leadingIcon || (!trailing ? icon : undefined)
|
|
84
|
-
)
|
|
85
|
-
const trailingIconName = $derived(
|
|
86
|
-
spinTrailing ? loadingIcon : trailingIcon || (trailing ? icon : undefined)
|
|
87
|
-
)
|
|
88
|
-
|
|
89
|
-
const resolvedColor = $derived(active && activeColor ? activeColor : color)
|
|
90
|
-
const resolvedVariant = $derived(active && activeVariant ? activeVariant : variant)
|
|
91
|
-
|
|
92
|
-
const classes = $derived.by(() => {
|
|
93
|
-
const slots = buttonVariants({
|
|
94
|
-
variant: resolvedVariant,
|
|
95
|
-
color: resolvedColor,
|
|
96
|
-
size: resolvedSize,
|
|
97
|
-
block,
|
|
98
|
-
square: isIconOnly,
|
|
99
|
-
loading: isLoading,
|
|
100
|
-
leading: spinLeading,
|
|
101
|
-
trailing: spinTrailing
|
|
102
|
-
})
|
|
103
|
-
return {
|
|
104
|
-
base: slots.base({ class: [config.slots.base, fieldGroupClass, className, ui?.base] }),
|
|
105
|
-
label: slots.label({ class: [config.slots.label, ui?.label] }),
|
|
106
|
-
leadingIcon: slots.leadingIcon({ class: [config.slots.leadingIcon, ui?.leadingIcon] }),
|
|
107
|
-
trailingIcon: slots.trailingIcon({
|
|
108
|
-
class: [config.slots.trailingIcon, ui?.trailingIcon]
|
|
109
|
-
}),
|
|
110
|
-
leadingAvatar: slots.leadingAvatar({
|
|
111
|
-
class: [config.slots.leadingAvatar, ui?.leadingAvatar]
|
|
112
|
-
}),
|
|
113
|
-
leadingAvatarSize: slots.leadingAvatarSize() as AvatarSize
|
|
114
|
-
}
|
|
115
|
-
})
|
|
116
|
-
|
|
117
|
-
function handleClick(e: MouseEvent) {
|
|
118
|
-
if (disabled || isLoading) {
|
|
119
|
-
e.preventDefault()
|
|
120
|
-
e.stopPropagation()
|
|
121
|
-
return
|
|
122
|
-
}
|
|
123
|
-
|
|
124
|
-
if (typeof onclick === 'function') {
|
|
125
|
-
const result = (onclick as (e: MouseEvent) => unknown)(e)
|
|
126
|
-
|
|
127
|
-
if (loadingAuto && result instanceof Promise) {
|
|
128
|
-
autoLoading = true
|
|
129
|
-
pendingPromise = result
|
|
130
|
-
result.then(
|
|
131
|
-
() => {
|
|
132
|
-
if (pendingPromise === result) autoLoading = false
|
|
133
|
-
},
|
|
134
|
-
() => {
|
|
135
|
-
if (pendingPromise === result) autoLoading = false
|
|
136
|
-
}
|
|
137
|
-
)
|
|
138
|
-
}
|
|
139
|
-
}
|
|
140
|
-
}
|
|
4
|
+
<script lang="ts">import { getContext } from "svelte";
|
|
5
|
+
import Avatar from "../Avatar/Avatar.svelte";
|
|
6
|
+
import { getComponentConfig, iconsDefaults } from "../config.js";
|
|
7
|
+
import { fieldGroupVariant } from "../FieldGroup/field-group.variants.js";
|
|
8
|
+
import Icon from "../Icon/Icon.svelte";
|
|
9
|
+
import Link from "../Link/Link.svelte";
|
|
10
|
+
import { buttonDefaults, buttonVariants } from "./button.variants.js";
|
|
11
|
+
const config = getComponentConfig("button", buttonDefaults);
|
|
12
|
+
const icons = getComponentConfig("icons", iconsDefaults);
|
|
13
|
+
let { ref = $bindable(null), ui, color = config.defaultVariants.color, variant = config.defaultVariants.variant, size, label, loading = false, loadingAuto = false, loadingIcon = icons.loading, disabled = false, block = false, square = false, icon, leadingIcon, trailingIcon, trailing = false, avatar, href, type, external, active, exact = false, activeColor, activeVariant, activeClass, inactiveClass, leadingSlot, trailingSlot, children, class: className, onclick, ...restProps } = $props();
|
|
14
|
+
const fieldGroupContext = getContext("fieldGroup");
|
|
15
|
+
const resolvedSize = $derived(size ?? fieldGroupContext?.size ?? config.defaultVariants.size);
|
|
16
|
+
const fieldGroupClass = $derived(fieldGroupContext ? fieldGroupVariant.fieldGroup[fieldGroupContext.orientation ?? "horizontal"] : undefined);
|
|
17
|
+
let autoLoading = $state(false);
|
|
18
|
+
let pendingPromise = null;
|
|
19
|
+
const isLoading = $derived(loading || autoLoading);
|
|
20
|
+
const isIconOnly = $derived(square || !label && !children);
|
|
21
|
+
const isLeading = $derived(!!icon && !trailing || isLoading && !trailing || !!leadingIcon);
|
|
22
|
+
const isTrailing = $derived(!!icon && trailing || isLoading && trailing || !!trailingIcon);
|
|
23
|
+
const spinLeading = $derived(isLoading && !trailing);
|
|
24
|
+
const spinTrailing = $derived(isLoading && trailing);
|
|
25
|
+
const leadingIconName = $derived(spinLeading ? loadingIcon : leadingIcon || (!trailing ? icon : undefined));
|
|
26
|
+
const trailingIconName = $derived(spinTrailing ? loadingIcon : trailingIcon || (trailing ? icon : undefined));
|
|
27
|
+
const resolvedColor = $derived(active && activeColor ? activeColor : color);
|
|
28
|
+
const resolvedVariant = $derived(active && activeVariant ? activeVariant : variant);
|
|
29
|
+
const classes = $derived.by(() => {
|
|
30
|
+
const slots = buttonVariants({
|
|
31
|
+
variant: resolvedVariant,
|
|
32
|
+
color: resolvedColor,
|
|
33
|
+
size: resolvedSize,
|
|
34
|
+
block,
|
|
35
|
+
square: isIconOnly,
|
|
36
|
+
loading: isLoading,
|
|
37
|
+
leading: spinLeading,
|
|
38
|
+
trailing: spinTrailing
|
|
39
|
+
});
|
|
40
|
+
return {
|
|
41
|
+
base: slots.base({ class: [
|
|
42
|
+
config.slots.base,
|
|
43
|
+
fieldGroupClass,
|
|
44
|
+
className,
|
|
45
|
+
ui?.base
|
|
46
|
+
] }),
|
|
47
|
+
label: slots.label({ class: [config.slots.label, ui?.label] }),
|
|
48
|
+
leadingIcon: slots.leadingIcon({ class: [config.slots.leadingIcon, ui?.leadingIcon] }),
|
|
49
|
+
trailingIcon: slots.trailingIcon({ class: [config.slots.trailingIcon, ui?.trailingIcon] }),
|
|
50
|
+
leadingAvatar: slots.leadingAvatar({ class: [config.slots.leadingAvatar, ui?.leadingAvatar] }),
|
|
51
|
+
leadingAvatarSize: slots.leadingAvatarSize()
|
|
52
|
+
};
|
|
53
|
+
});
|
|
54
|
+
function handleClick(e) {
|
|
55
|
+
if (disabled || isLoading) {
|
|
56
|
+
e.preventDefault();
|
|
57
|
+
e.stopPropagation();
|
|
58
|
+
return;
|
|
59
|
+
}
|
|
60
|
+
if (typeof onclick === "function") {
|
|
61
|
+
const result = onclick(e);
|
|
62
|
+
if (loadingAuto && result instanceof Promise) {
|
|
63
|
+
autoLoading = true;
|
|
64
|
+
pendingPromise = result;
|
|
65
|
+
result.then(() => {
|
|
66
|
+
if (pendingPromise === result) autoLoading = false;
|
|
67
|
+
}, () => {
|
|
68
|
+
if (pendingPromise === result) autoLoading = false;
|
|
69
|
+
});
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
}
|
|
141
73
|
</script>
|
|
142
74
|
|
|
143
75
|
<Link
|