svelora 3.0.1 → 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.js +6 -0
- 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/package.json +16 -8
|
@@ -1,102 +1,71 @@
|
|
|
1
|
-
<script lang="ts" module>
|
|
2
|
-
import type { AccordionItem, AccordionProps } from './accordion.types.js'
|
|
3
|
-
|
|
4
|
-
export type Props = AccordionProps
|
|
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
|
-
ui?.[slot],
|
|
73
|
-
item.ui?.[slot],
|
|
74
|
-
slot === 'item' ? item.class : undefined
|
|
75
|
-
]
|
|
76
|
-
const opts =
|
|
77
|
-
slot === 'trigger'
|
|
78
|
-
? { class: baseClass, disabled: item.disabled }
|
|
79
|
-
: { class: baseClass }
|
|
80
|
-
result[slot] = variantSlots[slot](opts)
|
|
81
|
-
}
|
|
82
|
-
return result
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
function isOpen(itemValue: string): boolean {
|
|
86
|
-
if (!value) return false
|
|
87
|
-
if (Array.isArray(value)) return value.includes(itemValue)
|
|
88
|
-
return value === itemValue
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
function handleSingleValueChange(newValue: string) {
|
|
92
|
-
value = newValue
|
|
93
|
-
onValueChange?.(newValue)
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
function handleMultipleValueChange(newValue: string[]) {
|
|
97
|
-
value = newValue
|
|
98
|
-
onValueChange?.(newValue)
|
|
99
|
-
}
|
|
4
|
+
<script lang="ts">import { Accordion } from "bits-ui";
|
|
5
|
+
import { slide } from "svelte/transition";
|
|
6
|
+
import { getComponentConfig } from "../config.js";
|
|
7
|
+
import Icon from "../Icon/Icon.svelte";
|
|
8
|
+
import { accordionDefaults, accordionVariants } from "./accordion.variants.js";
|
|
9
|
+
const config = getComponentConfig("accordion", accordionDefaults);
|
|
10
|
+
let { items = [], type = "single", value = $bindable(), onValueChange, disabled = false, loop = false, orientation = "vertical", forceMount = false, trailingIcon = "lucide:chevron-down", ui, class: className, leading, label: labelSlot, trailing, content: contentSlot, body: bodySlot } = $props();
|
|
11
|
+
const variantSlots = $derived(accordionVariants({ disabled }));
|
|
12
|
+
const rootClass = $derived(variantSlots.root({ class: [
|
|
13
|
+
config.slots.root,
|
|
14
|
+
ui?.root,
|
|
15
|
+
className
|
|
16
|
+
] }));
|
|
17
|
+
const singleValue = $derived(typeof value === "string" ? value : undefined);
|
|
18
|
+
const multipleValue = $derived(Array.isArray(value) ? value : undefined);
|
|
19
|
+
const slotNames = [
|
|
20
|
+
"item",
|
|
21
|
+
"header",
|
|
22
|
+
"trigger",
|
|
23
|
+
"content",
|
|
24
|
+
"body",
|
|
25
|
+
"leadingIcon",
|
|
26
|
+
"trailingIcon",
|
|
27
|
+
"label"
|
|
28
|
+
];
|
|
29
|
+
const itemDefaults = $derived.by(() => {
|
|
30
|
+
const result = {};
|
|
31
|
+
for (const slot of slotNames) {
|
|
32
|
+
result[slot] = variantSlots[slot]({ class: [config.slots[slot], ui?.[slot]] });
|
|
33
|
+
}
|
|
34
|
+
return result;
|
|
35
|
+
});
|
|
36
|
+
function getItemClasses(item) {
|
|
37
|
+
if (!item.ui && item.class === undefined && item.disabled === undefined) {
|
|
38
|
+
return itemDefaults;
|
|
39
|
+
}
|
|
40
|
+
const result = {};
|
|
41
|
+
for (const slot of slotNames) {
|
|
42
|
+
const baseClass = [
|
|
43
|
+
config.slots[slot],
|
|
44
|
+
ui?.[slot],
|
|
45
|
+
item.ui?.[slot],
|
|
46
|
+
slot === "item" ? item.class : undefined
|
|
47
|
+
];
|
|
48
|
+
const opts = slot === "trigger" ? {
|
|
49
|
+
class: baseClass,
|
|
50
|
+
disabled: item.disabled
|
|
51
|
+
} : { class: baseClass };
|
|
52
|
+
result[slot] = variantSlots[slot](opts);
|
|
53
|
+
}
|
|
54
|
+
return result;
|
|
55
|
+
}
|
|
56
|
+
function isOpen(itemValue) {
|
|
57
|
+
if (!value) return false;
|
|
58
|
+
if (Array.isArray(value)) return value.includes(itemValue);
|
|
59
|
+
return value === itemValue;
|
|
60
|
+
}
|
|
61
|
+
function handleSingleValueChange(newValue) {
|
|
62
|
+
value = newValue;
|
|
63
|
+
onValueChange?.(newValue);
|
|
64
|
+
}
|
|
65
|
+
function handleMultipleValueChange(newValue) {
|
|
66
|
+
value = newValue;
|
|
67
|
+
onValueChange?.(newValue);
|
|
68
|
+
}
|
|
100
69
|
</script>
|
|
101
70
|
|
|
102
71
|
{#snippet accordionItem(item: AccordionItem, index: number)}
|
package/dist/Alert/Alert.svelte
CHANGED
|
@@ -1,69 +1,44 @@
|
|
|
1
|
-
<script lang="ts" module>
|
|
2
|
-
import type { AlertProps } from './alert.types.js'
|
|
3
|
-
|
|
4
|
-
export type Props = AlertProps
|
|
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
|
-
const slots = alertVariants({ variant, color, orientation, title: !!title })
|
|
46
|
-
return {
|
|
47
|
-
root: slots.root({ class: [config.slots.root, className, ui?.root] }),
|
|
48
|
-
wrapper: slots.wrapper({ class: [config.slots.wrapper, ui?.wrapper] }),
|
|
49
|
-
title: slots.title({ class: [config.slots.title, ui?.title] }),
|
|
50
|
-
description: slots.description({ class: [config.slots.description, ui?.description] }),
|
|
51
|
-
icon: slots.icon({ class: [config.slots.icon, ui?.icon] }),
|
|
52
|
-
avatar: slots.avatar({ class: [config.slots.avatar, ui?.avatar] }),
|
|
53
|
-
actions: slots.actions({ class: [config.slots.actions, ui?.actions] }),
|
|
54
|
-
close: slots.close({ class: [config.slots.close, ui?.close] })
|
|
55
|
-
}
|
|
56
|
-
})
|
|
57
|
-
|
|
58
|
-
const closeButtonProps = $derived(!close ? null : close === true ? {} : close)
|
|
59
|
-
|
|
60
|
-
const isVertical = $derived(orientation === 'vertical')
|
|
61
|
-
const hasActions = $derived(!!actionsSlot || (actions && actions.length > 0))
|
|
62
|
-
|
|
63
|
-
function handleClose() {
|
|
64
|
-
open = false
|
|
65
|
-
onClose?.()
|
|
66
|
-
}
|
|
4
|
+
<script lang="ts">import Avatar from "../Avatar/Avatar.svelte";
|
|
5
|
+
import Button from "../Button/Button.svelte";
|
|
6
|
+
import { getComponentConfig, iconsDefaults } from "../config.js";
|
|
7
|
+
import Icon from "../Icon/Icon.svelte";
|
|
8
|
+
import { alertDefaults, alertVariants } from "./alert.variants.js";
|
|
9
|
+
const config = getComponentConfig("alert", alertDefaults);
|
|
10
|
+
const icons = getComponentConfig("icons", iconsDefaults);
|
|
11
|
+
let { ref = $bindable(null), as = "div", ui, title, description, icon, avatar, color = config.defaultVariants.color, variant = config.defaultVariants.variant, orientation = config.defaultVariants.orientation, open = $bindable(true), close = false, closeIcon, actions, class: className, leading, titleSlot, descriptionSlot, actionsSlot, closeSlot, onClose, ...restProps } = $props();
|
|
12
|
+
const resolvedCloseIcon = $derived(closeIcon ?? icons.close);
|
|
13
|
+
const classes = $derived.by(() => {
|
|
14
|
+
const slots = alertVariants({
|
|
15
|
+
variant,
|
|
16
|
+
color,
|
|
17
|
+
orientation,
|
|
18
|
+
title: !!title
|
|
19
|
+
});
|
|
20
|
+
return {
|
|
21
|
+
root: slots.root({ class: [
|
|
22
|
+
config.slots.root,
|
|
23
|
+
className,
|
|
24
|
+
ui?.root
|
|
25
|
+
] }),
|
|
26
|
+
wrapper: slots.wrapper({ class: [config.slots.wrapper, ui?.wrapper] }),
|
|
27
|
+
title: slots.title({ class: [config.slots.title, ui?.title] }),
|
|
28
|
+
description: slots.description({ class: [config.slots.description, ui?.description] }),
|
|
29
|
+
icon: slots.icon({ class: [config.slots.icon, ui?.icon] }),
|
|
30
|
+
avatar: slots.avatar({ class: [config.slots.avatar, ui?.avatar] }),
|
|
31
|
+
actions: slots.actions({ class: [config.slots.actions, ui?.actions] }),
|
|
32
|
+
close: slots.close({ class: [config.slots.close, ui?.close] })
|
|
33
|
+
};
|
|
34
|
+
});
|
|
35
|
+
const closeButtonProps = $derived(!close ? null : close === true ? {} : close);
|
|
36
|
+
const isVertical = $derived(orientation === "vertical");
|
|
37
|
+
const hasActions = $derived(!!actionsSlot || actions && actions.length > 0);
|
|
38
|
+
function handleClose() {
|
|
39
|
+
open = false;
|
|
40
|
+
onClose?.();
|
|
41
|
+
}
|
|
67
42
|
</script>
|
|
68
43
|
|
|
69
44
|
{#snippet actionsContent()}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { AlertProps } from './alert.types.js';
|
|
2
2
|
export type Props = AlertProps;
|
|
3
|
-
declare const Alert: import("svelte").Component<AlertProps, {}, "
|
|
3
|
+
declare const Alert: import("svelte").Component<AlertProps, {}, "open" | "ref">;
|
|
4
4
|
type Alert = ReturnType<typeof Alert>;
|
|
5
5
|
export default Alert;
|
|
@@ -1,80 +1,40 @@
|
|
|
1
|
-
<script lang="ts" module>
|
|
2
|
-
import type { AvatarProps, AvatarRounded, AvatarSize } from './avatar.types.js'
|
|
3
|
-
|
|
4
|
-
export type Props = AvatarProps
|
|
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
|
-
rounded ?? groupContext?.rounded ?? config.defaultVariants.rounded ?? 'full'
|
|
42
|
-
)
|
|
43
|
-
const sizePx = $derived(avatarSizePx[resolvedSize])
|
|
44
|
-
|
|
45
|
-
const initials = $derived(
|
|
46
|
-
text !== undefined
|
|
47
|
-
? text
|
|
48
|
-
: alt
|
|
49
|
-
? alt
|
|
50
|
-
.split(' ')
|
|
51
|
-
.filter(Boolean)
|
|
52
|
-
.slice(0, 2)
|
|
53
|
-
.map((w) => w[0])
|
|
54
|
-
.join('')
|
|
55
|
-
.toUpperCase()
|
|
56
|
-
: ''
|
|
57
|
-
)
|
|
58
|
-
|
|
59
|
-
const chipProps = $derived(
|
|
60
|
-
chip === true
|
|
61
|
-
? { inset: true as const }
|
|
62
|
-
: chip
|
|
63
|
-
? { inset: true as const, ...chip }
|
|
64
|
-
: undefined
|
|
65
|
-
)
|
|
66
|
-
|
|
67
|
-
const classes = $derived.by(() => {
|
|
68
|
-
const slots = avatarVariants({ size: resolvedSize, rounded: resolvedRounded })
|
|
69
|
-
return {
|
|
70
|
-
root: slots.root({
|
|
71
|
-
class: [config.slots.root, groupContext?.baseClass, className, ui?.root]
|
|
72
|
-
}),
|
|
73
|
-
image: slots.image({ class: [config.slots.image, ui?.image] }),
|
|
74
|
-
fallback: slots.fallback({ class: [config.slots.fallback, ui?.fallback] }),
|
|
75
|
-
icon: slots.icon({ class: [config.slots.icon, ui?.icon] })
|
|
76
|
-
}
|
|
77
|
-
})
|
|
4
|
+
<script lang="ts">import { Avatar } from "bits-ui";
|
|
5
|
+
import { getContext } from "svelte";
|
|
6
|
+
import Chip from "../Chip/Chip.svelte";
|
|
7
|
+
import { getComponentConfig } from "../config.js";
|
|
8
|
+
import Icon from "../Icon/Icon.svelte";
|
|
9
|
+
import { avatarDefaults, avatarSizePx, avatarVariants } from "./avatar.variants.js";
|
|
10
|
+
const config = getComponentConfig("avatar", avatarDefaults);
|
|
11
|
+
let { ref = $bindable(null), src, alt, size, rounded, text, icon, chip, loading, delayMs = 0, class: className, ui, fallback: fallbackSnippet, children, ...restProps } = $props();
|
|
12
|
+
const groupContext = getContext("avatarGroup");
|
|
13
|
+
const resolvedSize = $derived(size ?? groupContext?.size ?? config.defaultVariants.size ?? "md");
|
|
14
|
+
const resolvedRounded = $derived(rounded ?? groupContext?.rounded ?? config.defaultVariants.rounded ?? "full");
|
|
15
|
+
const sizePx = $derived(avatarSizePx[resolvedSize]);
|
|
16
|
+
const initials = $derived(text !== undefined ? text : alt ? alt.split(" ").filter(Boolean).slice(0, 2).map((w) => w[0]).join("").toUpperCase() : "");
|
|
17
|
+
const chipProps = $derived(chip === true ? { inset: true } : chip ? {
|
|
18
|
+
inset: true,
|
|
19
|
+
...chip
|
|
20
|
+
} : undefined);
|
|
21
|
+
const classes = $derived.by(() => {
|
|
22
|
+
const slots = avatarVariants({
|
|
23
|
+
size: resolvedSize,
|
|
24
|
+
rounded: resolvedRounded
|
|
25
|
+
});
|
|
26
|
+
return {
|
|
27
|
+
root: slots.root({ class: [
|
|
28
|
+
config.slots.root,
|
|
29
|
+
groupContext?.baseClass,
|
|
30
|
+
className,
|
|
31
|
+
ui?.root
|
|
32
|
+
] }),
|
|
33
|
+
image: slots.image({ class: [config.slots.image, ui?.image] }),
|
|
34
|
+
fallback: slots.fallback({ class: [config.slots.fallback, ui?.fallback] }),
|
|
35
|
+
icon: slots.icon({ class: [config.slots.icon, ui?.icon] })
|
|
36
|
+
};
|
|
37
|
+
});
|
|
78
38
|
</script>
|
|
79
39
|
|
|
80
40
|
{#snippet avatarContent()}
|
|
@@ -1,60 +1,43 @@
|
|
|
1
|
-
<script lang="ts" module>
|
|
2
|
-
import type { AvatarGroupProps } from './avatar-group.types.js'
|
|
3
|
-
|
|
4
|
-
export type Props = AvatarGroupProps
|
|
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
|
-
get baseClass() {
|
|
45
|
-
return classes.base
|
|
46
|
-
}
|
|
47
|
-
})
|
|
48
|
-
|
|
49
|
-
const visibleAvatars = $derived.by(() => {
|
|
50
|
-
if (!avatars) return []
|
|
51
|
-
const shown = max && max > 0 ? avatars.slice(0, max) : avatars
|
|
52
|
-
return [...shown].reverse()
|
|
53
|
-
})
|
|
54
|
-
|
|
55
|
-
const overflowCount = $derived(
|
|
56
|
-
avatars && max && max > 0 ? Math.max(0, avatars.length - max) : 0
|
|
57
|
-
)
|
|
4
|
+
<script lang="ts">import { setContext } from "svelte";
|
|
5
|
+
import Avatar from "../Avatar/Avatar.svelte";
|
|
6
|
+
import { getComponentConfig } from "../config.js";
|
|
7
|
+
import { avatarGroupDefaults, avatarGroupVariants } from "./avatar-group.variants.js";
|
|
8
|
+
const config = getComponentConfig("avatarGroup", avatarGroupDefaults);
|
|
9
|
+
let { ref = $bindable(null), as = "div", ui, size = config.defaultVariants.size ?? "md", rounded = config.defaultVariants.rounded ?? "full", avatars, max, class: className, children, ...restProps } = $props();
|
|
10
|
+
const classes = $derived.by(() => {
|
|
11
|
+
const slots = avatarGroupVariants({
|
|
12
|
+
size,
|
|
13
|
+
rounded
|
|
14
|
+
});
|
|
15
|
+
return {
|
|
16
|
+
root: slots.root({ class: [
|
|
17
|
+
config.slots.root,
|
|
18
|
+
className,
|
|
19
|
+
ui?.root
|
|
20
|
+
] }),
|
|
21
|
+
base: slots.base({ class: [config.slots.base, ui?.base] })
|
|
22
|
+
};
|
|
23
|
+
});
|
|
24
|
+
setContext("avatarGroup", {
|
|
25
|
+
get size() {
|
|
26
|
+
return size;
|
|
27
|
+
},
|
|
28
|
+
get rounded() {
|
|
29
|
+
return rounded;
|
|
30
|
+
},
|
|
31
|
+
get baseClass() {
|
|
32
|
+
return classes.base;
|
|
33
|
+
}
|
|
34
|
+
});
|
|
35
|
+
const visibleAvatars = $derived.by(() => {
|
|
36
|
+
if (!avatars) return [];
|
|
37
|
+
const shown = max && max > 0 ? avatars.slice(0, max) : avatars;
|
|
38
|
+
return [...shown].reverse();
|
|
39
|
+
});
|
|
40
|
+
const overflowCount = $derived(avatars && max && max > 0 ? Math.max(0, avatars.length - max) : 0);
|
|
58
41
|
</script>
|
|
59
42
|
|
|
60
43
|
<svelte:element this={as} bind:this={ref} class={classes.root} {...restProps}>
|
package/dist/Badge/Badge.svelte
CHANGED
|
@@ -1,55 +1,33 @@
|
|
|
1
|
-
<script lang="ts" module>
|
|
2
|
-
import type { BadgeProps } from './badge.types.js'
|
|
3
|
-
|
|
4
|
-
export type Props = BadgeProps
|
|
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
|
-
}: Props = $props()
|
|
35
|
-
|
|
36
|
-
const isIconOnly = $derived(!!icon || (square && label === undefined && !children))
|
|
37
|
-
|
|
38
|
-
const classes = $derived.by(() => {
|
|
39
|
-
const slots = badgeVariants({ variant, color, size, square: isIconOnly || square })
|
|
40
|
-
return {
|
|
41
|
-
base: slots.base({ class: [config.slots.base, className, ui?.base] }),
|
|
42
|
-
label: slots.label({ class: [config.slots.label, ui?.label] }),
|
|
43
|
-
leadingIcon: slots.leadingIcon({ class: [config.slots.leadingIcon, ui?.leadingIcon] }),
|
|
44
|
-
trailingIcon: slots.trailingIcon({
|
|
45
|
-
class: [config.slots.trailingIcon, ui?.trailingIcon]
|
|
46
|
-
}),
|
|
47
|
-
leadingAvatar: slots.leadingAvatar({
|
|
48
|
-
class: [config.slots.leadingAvatar, ui?.leadingAvatar]
|
|
49
|
-
}),
|
|
50
|
-
leadingAvatarSize: slots.leadingAvatarSize() as AvatarSize
|
|
51
|
-
}
|
|
52
|
-
})
|
|
4
|
+
<script lang="ts">import Avatar from "../Avatar/Avatar.svelte";
|
|
5
|
+
import { getComponentConfig } from "../config.js";
|
|
6
|
+
import Icon from "../Icon/Icon.svelte";
|
|
7
|
+
import { badgeDefaults, badgeVariants } from "./badge.variants.js";
|
|
8
|
+
const config = getComponentConfig("badge", badgeDefaults);
|
|
9
|
+
let { ref = $bindable(null), as = "span", ui, label, color = config.defaultVariants.color, variant = config.defaultVariants.variant, size = config.defaultVariants.size, square = false, icon, leadingIcon, trailingIcon, avatar, class: className, leading, children, trailing, ...restProps } = $props();
|
|
10
|
+
const isIconOnly = $derived(!!icon || square && label === undefined && !children);
|
|
11
|
+
const classes = $derived.by(() => {
|
|
12
|
+
const slots = badgeVariants({
|
|
13
|
+
variant,
|
|
14
|
+
color,
|
|
15
|
+
size,
|
|
16
|
+
square: isIconOnly || square
|
|
17
|
+
});
|
|
18
|
+
return {
|
|
19
|
+
base: slots.base({ class: [
|
|
20
|
+
config.slots.base,
|
|
21
|
+
className,
|
|
22
|
+
ui?.base
|
|
23
|
+
] }),
|
|
24
|
+
label: slots.label({ class: [config.slots.label, ui?.label] }),
|
|
25
|
+
leadingIcon: slots.leadingIcon({ class: [config.slots.leadingIcon, ui?.leadingIcon] }),
|
|
26
|
+
trailingIcon: slots.trailingIcon({ class: [config.slots.trailingIcon, ui?.trailingIcon] }),
|
|
27
|
+
leadingAvatar: slots.leadingAvatar({ class: [config.slots.leadingAvatar, ui?.leadingAvatar] }),
|
|
28
|
+
leadingAvatarSize: slots.leadingAvatarSize()
|
|
29
|
+
};
|
|
30
|
+
});
|
|
53
31
|
</script>
|
|
54
32
|
|
|
55
33
|
<svelte:element this={as} bind:this={ref} class={classes.base} {...restProps}>
|