@websline/system-components 0.0.2 → 0.0.3
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/components/atoms/{form → actions}/button/Button.svelte +33 -11
- package/dist/components/atoms/{form → actions}/button/Button.svelte.d.ts +28 -4
- package/dist/components/atoms/actions/button/button.variants.d.ts +151 -0
- package/dist/components/atoms/actions/button/button.variants.js +143 -0
- package/dist/components/atoms/{closeButton → actions/closeButton}/CloseButton.svelte +8 -7
- package/dist/components/atoms/actions/closeButton/CloseButton.svelte.d.ts +49 -0
- package/dist/components/atoms/avatar/Avatar.svelte +4 -4
- package/dist/components/atoms/badge/Badge.svelte +44 -0
- package/dist/components/atoms/badge/Badge.svelte.d.ts +65 -0
- package/dist/components/atoms/badge/badge.variants.d.ts +85 -0
- package/dist/components/atoms/badge/badge.variants.js +59 -0
- package/dist/components/atoms/chip/Chip.svelte +52 -0
- package/dist/components/atoms/chip/Chip.svelte.d.ts +81 -0
- package/dist/components/atoms/chip/chip.variants.d.ts +61 -0
- package/dist/components/atoms/chip/chip.variants.js +118 -0
- package/dist/components/atoms/colorChip/ColorChip.svelte +33 -0
- package/dist/components/atoms/colorChip/ColorChip.svelte.d.ts +57 -0
- package/dist/components/atoms/colorChip/colorChip.variants.d.ts +40 -0
- package/dist/components/atoms/colorChip/colorChip.variants.js +27 -0
- package/dist/components/atoms/{loading → feedback}/spinner/Spinner.svelte +2 -16
- package/dist/components/atoms/feedback/spinner/spinner.variants.d.ts +19 -0
- package/dist/components/atoms/feedback/spinner/spinner.variants.js +17 -0
- package/dist/components/atoms/form/formField/FormField.svelte +2 -10
- package/dist/components/atoms/form/formField/FormField.svelte.d.ts +8 -0
- package/dist/components/atoms/form/formField/formField.variants.d.ts +13 -0
- package/dist/components/atoms/form/formField/formField.variants.js +12 -0
- package/dist/components/atoms/form/helperText/HelperText.svelte +9 -10
- package/dist/components/atoms/form/helperText/HelperText.svelte.d.ts +22 -4
- package/dist/components/atoms/form/helperText/helperText.variants.d.ts +13 -0
- package/dist/components/atoms/form/helperText/helperText.variants.js +12 -0
- package/dist/components/atoms/form/label/Label.svelte +6 -14
- package/dist/components/atoms/form/label/Label.svelte.d.ts +8 -0
- package/dist/components/atoms/form/label/label.variants.d.ts +22 -0
- package/dist/components/atoms/form/label/label.variants.js +15 -0
- package/dist/components/atoms/form/radio/Radio.svelte +58 -0
- package/dist/components/atoms/form/radio/Radio.svelte.d.ts +65 -0
- package/dist/components/atoms/form/radio/radio.variants.d.ts +22 -0
- package/dist/components/atoms/form/radio/radio.variants.js +15 -0
- package/dist/components/atoms/form/select/Select.svelte +91 -0
- package/dist/components/atoms/form/select/Select.svelte.d.ts +81 -0
- package/dist/components/atoms/form/select/select.variants.d.ts +58 -0
- package/dist/components/atoms/form/select/select.variants.js +66 -0
- package/dist/components/atoms/form/switch/Switch.svelte +57 -0
- package/dist/components/atoms/form/switch/Switch.svelte.d.ts +65 -0
- package/dist/components/atoms/form/switch/switch.variants.d.ts +22 -0
- package/dist/components/atoms/form/switch/switch.variants.js +15 -0
- package/dist/components/atoms/icon/Icon.svelte +8 -1
- package/dist/components/atoms/icon/components/Add.svelte +27 -0
- package/dist/components/atoms/icon/components/Add.svelte.d.ts +41 -0
- package/dist/components/atoms/icon/components/Check.svelte +27 -0
- package/dist/components/atoms/icon/components/Check.svelte.d.ts +41 -0
- package/dist/components/atoms/icon/components/ChevronDown.svelte +27 -0
- package/dist/components/atoms/icon/components/ChevronDown.svelte.d.ts +41 -0
- package/dist/components/atoms/icon/components/CloseSmall.svelte +27 -0
- package/dist/components/atoms/icon/components/CloseSmall.svelte.d.ts +41 -0
- package/dist/components/atoms/icon/components/Page.svelte +27 -0
- package/dist/components/atoms/icon/components/Page.svelte.d.ts +41 -0
- package/dist/components/atoms/icon/components/Redo.svelte +27 -0
- package/dist/components/atoms/icon/components/Redo.svelte.d.ts +41 -0
- package/dist/components/atoms/icon/components/Undo.svelte +27 -0
- package/dist/components/atoms/icon/components/Undo.svelte.d.ts +41 -0
- package/dist/components/atoms/icon/index.d.ts +14 -0
- package/dist/components/atoms/icon/index.js +14 -0
- package/dist/components/molecules/navigationItem/NavigationItem.svelte +80 -0
- package/dist/components/molecules/navigationItem/NavigationItem.svelte.d.ts +81 -0
- package/dist/components/molecules/navigationItem/navigationItem.variants.d.ts +61 -0
- package/dist/components/molecules/navigationItem/navigationItem.variants.js +29 -0
- package/dist/components/molecules/notification/Notification.svelte +1 -1
- package/dist/components/molecules/pickers/colorSwatch/ColorSwatch.svelte +99 -0
- package/dist/components/molecules/pickers/colorSwatch/ColorSwatch.svelte.d.ts +57 -0
- package/dist/components/molecules/pickers/colorSwatch/ColorSwatchColor.svelte +13 -0
- package/dist/components/molecules/pickers/colorSwatch/ColorSwatchColor.svelte.d.ts +11 -0
- package/dist/components/molecules/pickers/colorSwatch/colorSwatch.variants.d.ts +49 -0
- package/dist/components/molecules/pickers/colorSwatch/colorSwatch.variants.js +46 -0
- package/dist/components/molecules/pickers/colorSwatch/index.d.ts +3 -0
- package/dist/components/molecules/pickers/colorSwatch/index.js +4 -0
- package/dist/components/molecules/richTextEditor/RichTextEditor.svelte +50 -21
- package/dist/components/molecules/richTextEditor/RichTextEditor.svelte.d.ts +56 -0
- package/dist/components/molecules/richTextEditor/richTextEditor.variants.js +25 -3
- package/dist/components/molecules/richTextEditor/toolbar/RichTextEditorToolbar.svelte +49 -0
- package/dist/components/molecules/richTextEditor/{RichTextEditorToolbar.svelte.d.ts → toolbar/RichTextEditorToolbar.svelte.d.ts} +2 -0
- package/dist/components/molecules/richTextEditor/toolbar/ToolbarBold.svelte +13 -0
- package/dist/components/molecules/richTextEditor/toolbar/ToolbarBold.svelte.d.ts +11 -0
- package/dist/components/molecules/richTextEditor/toolbar/ToolbarColor.svelte +27 -0
- package/dist/components/molecules/richTextEditor/toolbar/ToolbarColor.svelte.d.ts +15 -0
- package/dist/components/molecules/richTextEditor/toolbar/ToolbarItalic.svelte +13 -0
- package/dist/components/molecules/richTextEditor/toolbar/ToolbarItalic.svelte.d.ts +11 -0
- package/dist/components/molecules/richTextEditor/toolbar/ToolbarLink.svelte +34 -0
- package/dist/components/molecules/richTextEditor/toolbar/ToolbarLink.svelte.d.ts +13 -0
- package/dist/components/molecules/richTextEditor/toolbar/ToolbarList.svelte +13 -0
- package/dist/components/molecules/richTextEditor/toolbar/ToolbarList.svelte.d.ts +11 -0
- package/dist/components/molecules/richTextEditor/toolbar/ToolbarListOrdered.svelte +13 -0
- package/dist/components/molecules/richTextEditor/toolbar/ToolbarListOrdered.svelte.d.ts +11 -0
- package/dist/components/molecules/richTextEditor/toolbar/ToolbarRedo.svelte +13 -0
- package/dist/components/molecules/richTextEditor/toolbar/ToolbarRedo.svelte.d.ts +11 -0
- package/dist/components/molecules/richTextEditor/toolbar/ToolbarUnderline.svelte +13 -0
- package/dist/components/molecules/richTextEditor/toolbar/ToolbarUnderline.svelte.d.ts +11 -0
- package/dist/components/molecules/richTextEditor/toolbar/ToolbarUndo.svelte +13 -0
- package/dist/components/molecules/richTextEditor/toolbar/ToolbarUndo.svelte.d.ts +11 -0
- package/dist/components/molecules/selectorCard/SelectorCard.svelte +78 -0
- package/dist/components/molecules/selectorCard/SelectorCard.svelte.d.ts +105 -0
- package/dist/components/molecules/selectorCard/selectorCard.variants.d.ts +61 -0
- package/dist/components/molecules/selectorCard/selectorCard.variants.js +32 -0
- package/dist/components/molecules/toggleGroup/ToggleGroup.svelte +1 -0
- package/dist/components/molecules/toggleGroup/ToggleGroup.svelte.d.ts +8 -0
- package/dist/components/molecules/toggleGroup/ToggleGroupItem.svelte +1 -0
- package/dist/components/molecules/toggleGroup/ToggleGroupItem.svelte.d.ts +8 -0
- package/dist/components/organisms/notificationGroup/NotificationGroup.svelte +1 -1
- package/dist/components/organisms/popover/Popover.svelte +15 -0
- package/dist/components/organisms/popover/Popover.svelte.d.ts +18 -0
- package/dist/components/organisms/popover/PopoverContent.svelte +84 -0
- package/dist/components/organisms/popover/PopoverContent.svelte.d.ts +89 -0
- package/dist/components/organisms/popover/PopoverTrigger.svelte +14 -0
- package/dist/components/{atoms/closeButton/CloseButton.svelte.d.ts → organisms/popover/PopoverTrigger.svelte.d.ts} +3 -11
- package/dist/components/organisms/popover/index.d.ts +4 -0
- package/dist/components/organisms/popover/index.js +5 -0
- package/dist/components/organisms/popover/popover.variants.d.ts +39 -0
- package/dist/components/organisms/popover/popover.variants.js +15 -0
- package/dist/index.d.ts +14 -4
- package/dist/index.js +14 -4
- package/dist/utils/colors.d.ts +9 -0
- package/dist/utils/colors.js +119 -0
- package/dist/utils/index.d.ts +2 -0
- package/dist/utils/index.js +2 -0
- package/dist/utils/theme.svelte.d.ts +10 -0
- package/dist/utils/theme.svelte.js +31 -0
- package/package.json +30 -31
- package/dist/components/atoms/form/button/button.variants.d.ts +0 -58
- package/dist/components/atoms/form/button/button.variants.js +0 -82
- package/dist/components/molecules/richTextEditor/RichTextEditorToolbar.svelte +0 -5
- package/dist/components/atoms/{closeButton → actions/closeButton}/closeButton.variants.d.ts +0 -0
- package/dist/components/atoms/{closeButton → actions/closeButton}/closeButton.variants.js +0 -0
- package/dist/components/atoms/{form → actions}/iconButton/IconButton.svelte +0 -0
- package/dist/components/atoms/{form → actions}/iconButton/IconButton.svelte.d.ts +0 -0
- package/dist/components/atoms/{form → actions}/iconButton/iconButton.variants.d.ts +0 -0
- package/dist/components/atoms/{form → actions}/iconButton/iconButton.variants.js +0 -0
- package/dist/components/atoms/{loading → feedback}/spinner/Spinner.svelte.d.ts +6 -6
|
@@ -1,18 +1,21 @@
|
|
|
1
1
|
<script>
|
|
2
|
-
import { Spinner } from "../../../../index.js";
|
|
2
|
+
import { Icon, Spinner } from "../../../../index.js";
|
|
3
3
|
import { buttonVariants } from "./button.variants.js";
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
6
|
* @typedef {Object} Props
|
|
7
|
+
* @property {import('svelte').Snippet} [children] Children content – can be text, HTML, or other Svelte components
|
|
7
8
|
* @property {string} [as="button"] The HTML element to use for the button
|
|
8
9
|
* @property {string} [class=""] Additional CSS classes to apply to the component
|
|
9
|
-
* @property {"primary" | "secondary" | "
|
|
10
|
+
* @property {"primary" | "secondary" | "success" | "error"} [color="primary"] Button color
|
|
10
11
|
* @property {boolean} [disabled=false] Whether the button is disabled
|
|
11
12
|
* @property {boolean} [fullWidth=false] Whether the button should take the full width of its container
|
|
13
|
+
* @property {string} [icon=""] Name of the icon to add to this button
|
|
14
|
+
* @property {"start" | "end"} [iconPosition="start"] Position for this button's icon
|
|
12
15
|
* @property {boolean} [loading=false] Whether the button is in a loading state, for example after a form submission
|
|
13
16
|
* @property {"small" | "medium" | "large"} [size="medium"] Button size
|
|
14
17
|
* @property {string} [type="button"] Button type, e.g. "button", "submit", "reset"
|
|
15
|
-
* @property {"filled" | "outlined"} [variant="filled"] Button style
|
|
18
|
+
* @property {"filled" | "outlined" | "text"} [variant="filled"] Button style
|
|
16
19
|
*/
|
|
17
20
|
|
|
18
21
|
/** @type {Props} */
|
|
@@ -23,6 +26,8 @@
|
|
|
23
26
|
color = "primary",
|
|
24
27
|
disabled = false,
|
|
25
28
|
fullWidth = false,
|
|
29
|
+
icon = "",
|
|
30
|
+
iconPosition = "start",
|
|
26
31
|
loading = false,
|
|
27
32
|
size = "medium",
|
|
28
33
|
type = "button",
|
|
@@ -44,24 +49,41 @@
|
|
|
44
49
|
"aria-disabled": disabled || loading ? "true" : undefined,
|
|
45
50
|
};
|
|
46
51
|
});
|
|
52
|
+
|
|
53
|
+
let hasIcon = $derived(icon.length > 0);
|
|
54
|
+
|
|
55
|
+
let styles = $derived(
|
|
56
|
+
buttonVariants({
|
|
57
|
+
color,
|
|
58
|
+
class: className,
|
|
59
|
+
disabled,
|
|
60
|
+
fullWidth,
|
|
61
|
+
hasIcon,
|
|
62
|
+
iconPosition,
|
|
63
|
+
loading,
|
|
64
|
+
size,
|
|
65
|
+
variant,
|
|
66
|
+
}),
|
|
67
|
+
);
|
|
47
68
|
</script>
|
|
48
69
|
|
|
49
70
|
<svelte:element
|
|
50
71
|
this={as}
|
|
51
72
|
aria-busy={loading}
|
|
52
|
-
class={
|
|
53
|
-
color,
|
|
73
|
+
class={styles.base({
|
|
54
74
|
class: className,
|
|
55
|
-
disabled,
|
|
56
|
-
fullWidth,
|
|
57
|
-
loading,
|
|
58
|
-
size,
|
|
59
|
-
variant,
|
|
60
75
|
})}
|
|
61
76
|
{...tagSpecificProps}
|
|
62
77
|
{...rest}>
|
|
63
78
|
{#if loading}
|
|
64
|
-
<
|
|
79
|
+
<div class={styles.spinner()}>
|
|
80
|
+
<Spinner size="small" />
|
|
81
|
+
</div>
|
|
82
|
+
{/if}
|
|
83
|
+
{#if hasIcon && !loading}
|
|
84
|
+
<div class={styles.icon()}>
|
|
85
|
+
<Icon name={icon} size={size === "small" ? 16 : 20} />
|
|
86
|
+
</div>
|
|
65
87
|
{/if}
|
|
66
88
|
{@render children?.()}
|
|
67
89
|
</svelte:element>
|
|
@@ -4,6 +4,10 @@ type Button = {
|
|
|
4
4
|
$set?(props: Partial<Props>): void;
|
|
5
5
|
};
|
|
6
6
|
declare const Button: import("svelte").Component<{
|
|
7
|
+
/**
|
|
8
|
+
* Children content – can be text, HTML, or other Svelte components
|
|
9
|
+
*/
|
|
10
|
+
children?: import("svelte").Snippet;
|
|
7
11
|
/**
|
|
8
12
|
* The HTML element to use for the button
|
|
9
13
|
*/
|
|
@@ -15,7 +19,7 @@ declare const Button: import("svelte").Component<{
|
|
|
15
19
|
/**
|
|
16
20
|
* Button color
|
|
17
21
|
*/
|
|
18
|
-
color?: "primary" | "secondary" | "
|
|
22
|
+
color?: "primary" | "secondary" | "success" | "error";
|
|
19
23
|
/**
|
|
20
24
|
* Whether the button is disabled
|
|
21
25
|
*/
|
|
@@ -24,6 +28,14 @@ declare const Button: import("svelte").Component<{
|
|
|
24
28
|
* Whether the button should take the full width of its container
|
|
25
29
|
*/
|
|
26
30
|
fullWidth?: boolean;
|
|
31
|
+
/**
|
|
32
|
+
* Name of the icon to add to this button
|
|
33
|
+
*/
|
|
34
|
+
icon?: string;
|
|
35
|
+
/**
|
|
36
|
+
* Position for this button's icon
|
|
37
|
+
*/
|
|
38
|
+
iconPosition?: "start" | "end";
|
|
27
39
|
/**
|
|
28
40
|
* Whether the button is in a loading state, for example after a form submission
|
|
29
41
|
*/
|
|
@@ -39,9 +51,13 @@ declare const Button: import("svelte").Component<{
|
|
|
39
51
|
/**
|
|
40
52
|
* Button style
|
|
41
53
|
*/
|
|
42
|
-
variant?: "filled" | "outlined";
|
|
54
|
+
variant?: "filled" | "outlined" | "text";
|
|
43
55
|
}, {}, "">;
|
|
44
56
|
type Props = {
|
|
57
|
+
/**
|
|
58
|
+
* Children content – can be text, HTML, or other Svelte components
|
|
59
|
+
*/
|
|
60
|
+
children?: import("svelte").Snippet;
|
|
45
61
|
/**
|
|
46
62
|
* The HTML element to use for the button
|
|
47
63
|
*/
|
|
@@ -53,7 +69,7 @@ type Props = {
|
|
|
53
69
|
/**
|
|
54
70
|
* Button color
|
|
55
71
|
*/
|
|
56
|
-
color?: "primary" | "secondary" | "
|
|
72
|
+
color?: "primary" | "secondary" | "success" | "error";
|
|
57
73
|
/**
|
|
58
74
|
* Whether the button is disabled
|
|
59
75
|
*/
|
|
@@ -62,6 +78,14 @@ type Props = {
|
|
|
62
78
|
* Whether the button should take the full width of its container
|
|
63
79
|
*/
|
|
64
80
|
fullWidth?: boolean;
|
|
81
|
+
/**
|
|
82
|
+
* Name of the icon to add to this button
|
|
83
|
+
*/
|
|
84
|
+
icon?: string;
|
|
85
|
+
/**
|
|
86
|
+
* Position for this button's icon
|
|
87
|
+
*/
|
|
88
|
+
iconPosition?: "start" | "end";
|
|
65
89
|
/**
|
|
66
90
|
* Whether the button is in a loading state, for example after a form submission
|
|
67
91
|
*/
|
|
@@ -77,5 +101,5 @@ type Props = {
|
|
|
77
101
|
/**
|
|
78
102
|
* Button style
|
|
79
103
|
*/
|
|
80
|
-
variant?: "filled" | "outlined";
|
|
104
|
+
variant?: "filled" | "outlined" | "text";
|
|
81
105
|
};
|
|
@@ -0,0 +1,151 @@
|
|
|
1
|
+
export const buttonVariants: import("tailwind-variants").TVReturnType<{
|
|
2
|
+
disabled: {
|
|
3
|
+
true: {
|
|
4
|
+
base: string;
|
|
5
|
+
};
|
|
6
|
+
};
|
|
7
|
+
fullWidth: {
|
|
8
|
+
true: {
|
|
9
|
+
base: string;
|
|
10
|
+
};
|
|
11
|
+
};
|
|
12
|
+
iconPosition: {
|
|
13
|
+
end: {
|
|
14
|
+
base: string;
|
|
15
|
+
};
|
|
16
|
+
};
|
|
17
|
+
loading: {
|
|
18
|
+
true: {
|
|
19
|
+
base: string;
|
|
20
|
+
};
|
|
21
|
+
};
|
|
22
|
+
size: {
|
|
23
|
+
small: {
|
|
24
|
+
base: string;
|
|
25
|
+
spinner: string;
|
|
26
|
+
};
|
|
27
|
+
medium: {
|
|
28
|
+
base: string;
|
|
29
|
+
spinner: string;
|
|
30
|
+
};
|
|
31
|
+
large: {
|
|
32
|
+
base: string;
|
|
33
|
+
spinner: string;
|
|
34
|
+
};
|
|
35
|
+
};
|
|
36
|
+
variant: {
|
|
37
|
+
filled: {
|
|
38
|
+
base: string;
|
|
39
|
+
};
|
|
40
|
+
outlined: {
|
|
41
|
+
base: string;
|
|
42
|
+
};
|
|
43
|
+
text: {
|
|
44
|
+
base: string;
|
|
45
|
+
};
|
|
46
|
+
};
|
|
47
|
+
}, {
|
|
48
|
+
base: string;
|
|
49
|
+
icon: string;
|
|
50
|
+
spinner: string;
|
|
51
|
+
}, undefined, {
|
|
52
|
+
disabled: {
|
|
53
|
+
true: {
|
|
54
|
+
base: string;
|
|
55
|
+
};
|
|
56
|
+
};
|
|
57
|
+
fullWidth: {
|
|
58
|
+
true: {
|
|
59
|
+
base: string;
|
|
60
|
+
};
|
|
61
|
+
};
|
|
62
|
+
iconPosition: {
|
|
63
|
+
end: {
|
|
64
|
+
base: string;
|
|
65
|
+
};
|
|
66
|
+
};
|
|
67
|
+
loading: {
|
|
68
|
+
true: {
|
|
69
|
+
base: string;
|
|
70
|
+
};
|
|
71
|
+
};
|
|
72
|
+
size: {
|
|
73
|
+
small: {
|
|
74
|
+
base: string;
|
|
75
|
+
spinner: string;
|
|
76
|
+
};
|
|
77
|
+
medium: {
|
|
78
|
+
base: string;
|
|
79
|
+
spinner: string;
|
|
80
|
+
};
|
|
81
|
+
large: {
|
|
82
|
+
base: string;
|
|
83
|
+
spinner: string;
|
|
84
|
+
};
|
|
85
|
+
};
|
|
86
|
+
variant: {
|
|
87
|
+
filled: {
|
|
88
|
+
base: string;
|
|
89
|
+
};
|
|
90
|
+
outlined: {
|
|
91
|
+
base: string;
|
|
92
|
+
};
|
|
93
|
+
text: {
|
|
94
|
+
base: string;
|
|
95
|
+
};
|
|
96
|
+
};
|
|
97
|
+
}, {
|
|
98
|
+
base: string;
|
|
99
|
+
icon: string;
|
|
100
|
+
spinner: string;
|
|
101
|
+
}, import("tailwind-variants").TVReturnType<{
|
|
102
|
+
disabled: {
|
|
103
|
+
true: {
|
|
104
|
+
base: string;
|
|
105
|
+
};
|
|
106
|
+
};
|
|
107
|
+
fullWidth: {
|
|
108
|
+
true: {
|
|
109
|
+
base: string;
|
|
110
|
+
};
|
|
111
|
+
};
|
|
112
|
+
iconPosition: {
|
|
113
|
+
end: {
|
|
114
|
+
base: string;
|
|
115
|
+
};
|
|
116
|
+
};
|
|
117
|
+
loading: {
|
|
118
|
+
true: {
|
|
119
|
+
base: string;
|
|
120
|
+
};
|
|
121
|
+
};
|
|
122
|
+
size: {
|
|
123
|
+
small: {
|
|
124
|
+
base: string;
|
|
125
|
+
spinner: string;
|
|
126
|
+
};
|
|
127
|
+
medium: {
|
|
128
|
+
base: string;
|
|
129
|
+
spinner: string;
|
|
130
|
+
};
|
|
131
|
+
large: {
|
|
132
|
+
base: string;
|
|
133
|
+
spinner: string;
|
|
134
|
+
};
|
|
135
|
+
};
|
|
136
|
+
variant: {
|
|
137
|
+
filled: {
|
|
138
|
+
base: string;
|
|
139
|
+
};
|
|
140
|
+
outlined: {
|
|
141
|
+
base: string;
|
|
142
|
+
};
|
|
143
|
+
text: {
|
|
144
|
+
base: string;
|
|
145
|
+
};
|
|
146
|
+
};
|
|
147
|
+
}, {
|
|
148
|
+
base: string;
|
|
149
|
+
icon: string;
|
|
150
|
+
spinner: string;
|
|
151
|
+
}, undefined, unknown, unknown, undefined>>;
|
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
import { tv } from "tailwind-variants";
|
|
2
|
+
|
|
3
|
+
const buttonVariants = tv({
|
|
4
|
+
slots: {
|
|
5
|
+
base: "inline-flex cursor-pointer items-center rounded align-middle transition duration-200 select-none",
|
|
6
|
+
icon: "flex h-lh items-center",
|
|
7
|
+
spinner: "flex h-lh items-center justify-center",
|
|
8
|
+
},
|
|
9
|
+
variants: {
|
|
10
|
+
disabled: {
|
|
11
|
+
true: {
|
|
12
|
+
base: "opacity-40 pointer-events-none",
|
|
13
|
+
},
|
|
14
|
+
},
|
|
15
|
+
fullWidth: {
|
|
16
|
+
true: {
|
|
17
|
+
base: "w-full justify-center",
|
|
18
|
+
},
|
|
19
|
+
},
|
|
20
|
+
iconPosition: {
|
|
21
|
+
end: {
|
|
22
|
+
base: "flex-row-reverse",
|
|
23
|
+
},
|
|
24
|
+
},
|
|
25
|
+
loading: {
|
|
26
|
+
true: {
|
|
27
|
+
base: "pointer-events-none",
|
|
28
|
+
},
|
|
29
|
+
},
|
|
30
|
+
size: {
|
|
31
|
+
small: {
|
|
32
|
+
base: "py-1.25 px-3 gap-2 button-small",
|
|
33
|
+
spinner: "w-4",
|
|
34
|
+
},
|
|
35
|
+
medium: {
|
|
36
|
+
base: "py-1.5 px-3 gap-2 button-default",
|
|
37
|
+
spinner: "w-5",
|
|
38
|
+
},
|
|
39
|
+
large: {
|
|
40
|
+
base: "py-2.5 px-3 gap-3 button-default",
|
|
41
|
+
spinner: "w-5",
|
|
42
|
+
},
|
|
43
|
+
},
|
|
44
|
+
variant: {
|
|
45
|
+
filled: {
|
|
46
|
+
base: "border-transparent border-1",
|
|
47
|
+
},
|
|
48
|
+
outlined: {
|
|
49
|
+
base: "border-1",
|
|
50
|
+
},
|
|
51
|
+
text: {
|
|
52
|
+
base: "relative !px-0 after:content-[''] after:absolute after:left-0 after:bottom-0 after:h-[1.5px] after:w-0 hover:after:w-full after:transition-all after:duration-300",
|
|
53
|
+
},
|
|
54
|
+
},
|
|
55
|
+
},
|
|
56
|
+
compoundVariants: [
|
|
57
|
+
{
|
|
58
|
+
color: "primary",
|
|
59
|
+
variant: "filled",
|
|
60
|
+
class: {
|
|
61
|
+
base: "bg-blue-500 text-white hover:bg-blue-600 dark:bg-blue-400 dark:hover:bg-blue-500",
|
|
62
|
+
},
|
|
63
|
+
},
|
|
64
|
+
{
|
|
65
|
+
color: "primary",
|
|
66
|
+
variant: "outlined",
|
|
67
|
+
class: {
|
|
68
|
+
base: "text-blue-500 border-blue-500 hover:bg-blue-600 hover:border-blue-600 hover:text-white dark:text-blue-400 dark:border-blue-400 dark:hover:bg-blue-500 dark:hover:border-blue-500",
|
|
69
|
+
},
|
|
70
|
+
},
|
|
71
|
+
{
|
|
72
|
+
color: "secondary",
|
|
73
|
+
variant: "filled",
|
|
74
|
+
class:
|
|
75
|
+
"bg-neutral-900 text-white hover:bg-neutral-700 dark:bg-neutral-200 dark:text-neutral-900 dark:hover:bg-neutral-500",
|
|
76
|
+
},
|
|
77
|
+
{
|
|
78
|
+
color: "secondary",
|
|
79
|
+
variant: "outlined",
|
|
80
|
+
class: {
|
|
81
|
+
base: "text-neutral-900 hover:bg-neutral-700 hover:text-white hover:border-neutral-700 dark:border-neutral-200 dark:text-neutral-200 dark:hover:bg-neutral-500 dark:hover:border-neutral-500 dark:hover:text-inherit",
|
|
82
|
+
},
|
|
83
|
+
},
|
|
84
|
+
{
|
|
85
|
+
color: "success",
|
|
86
|
+
variant: "filled",
|
|
87
|
+
class: {
|
|
88
|
+
base: "bg-green-500 text-white hover:bg-green-700 dark:bg-green-500 dark:hover:bg-green-700",
|
|
89
|
+
},
|
|
90
|
+
},
|
|
91
|
+
{
|
|
92
|
+
color: "success",
|
|
93
|
+
variant: "outlined",
|
|
94
|
+
class: {
|
|
95
|
+
base: "text-green-500 border-green-500 hover:bg-green-700 hover:border-green-700 hover:text-white dark:text-green-500 dark:border-green-500 dark:hover:bg-green-700 dark:hover:border-green-700",
|
|
96
|
+
},
|
|
97
|
+
},
|
|
98
|
+
{
|
|
99
|
+
color: "error",
|
|
100
|
+
variant: "filled",
|
|
101
|
+
class: {
|
|
102
|
+
base: "bg-red-500 text-white hover:bg-red-700 dark:bg-red-500 dark:hover:bg-red-700",
|
|
103
|
+
},
|
|
104
|
+
},
|
|
105
|
+
{
|
|
106
|
+
color: "error",
|
|
107
|
+
variant: "outlined",
|
|
108
|
+
class: {
|
|
109
|
+
base: "border-red-500 text-red-500 hover:border-red-700 hover:bg-red-700 hover:text-white dark:border-red-500 dark:text-red-500 dark:hover:border-red-700 dark:hover:bg-red-700",
|
|
110
|
+
},
|
|
111
|
+
},
|
|
112
|
+
{
|
|
113
|
+
color: "primary",
|
|
114
|
+
variant: "text",
|
|
115
|
+
class: {
|
|
116
|
+
base: "text-blue-500 after:bg-blue-500 dark:text-blue-400 dark:after:bg-blue-400",
|
|
117
|
+
},
|
|
118
|
+
},
|
|
119
|
+
{
|
|
120
|
+
color: "secondary",
|
|
121
|
+
variant: "text",
|
|
122
|
+
class: {
|
|
123
|
+
base: "text-neutral-900 after:bg-neutral-900 dark:text-neutral-200 dark:after:bg-neutral-200",
|
|
124
|
+
},
|
|
125
|
+
},
|
|
126
|
+
{
|
|
127
|
+
color: "success",
|
|
128
|
+
variant: "text",
|
|
129
|
+
class: {
|
|
130
|
+
base: "text-green-500 after:bg-green-500",
|
|
131
|
+
},
|
|
132
|
+
},
|
|
133
|
+
{
|
|
134
|
+
color: "error",
|
|
135
|
+
variant: "text",
|
|
136
|
+
class: {
|
|
137
|
+
base: "text-red-500 after:bg-red-500",
|
|
138
|
+
},
|
|
139
|
+
},
|
|
140
|
+
],
|
|
141
|
+
});
|
|
142
|
+
|
|
143
|
+
export { buttonVariants };
|
|
@@ -1,9 +1,12 @@
|
|
|
1
1
|
<script>
|
|
2
|
-
import { Icon } from "
|
|
2
|
+
import { Icon } from "../../../../index.js";
|
|
3
3
|
import { closeButtonVariants } from "./closeButton.variants.js";
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
6
|
* @typedef {Object} Props
|
|
7
|
+
* @property {boolean} [autoClose=false] Whether the button should automatically close after a duration
|
|
8
|
+
* @property {number} [durationInSeconds=6] Duration in seconds before auto-close triggers
|
|
9
|
+
* @property {() => void} onClose Function to call when the button is clicked or auto-closed
|
|
7
10
|
* @property {string} [class=""] Additional CSS classes to apply to the component
|
|
8
11
|
* @property {"circle" | "square"} [shape="round"] Button shape
|
|
9
12
|
*/
|
|
@@ -41,12 +44,12 @@
|
|
|
41
44
|
barEl.style.width = `${parentW}px`;
|
|
42
45
|
};
|
|
43
46
|
|
|
44
|
-
let {
|
|
47
|
+
let styles = $derived(closeButtonVariants({ animate, shape }));
|
|
45
48
|
|
|
46
49
|
let calculatedDurationInSeconds = $derived(durationInSeconds * 1000);
|
|
47
50
|
|
|
48
51
|
const handleClose = () => {
|
|
49
|
-
onClose();
|
|
52
|
+
if (onClose) onClose();
|
|
50
53
|
};
|
|
51
54
|
|
|
52
55
|
const handleAnimationComplete = () => {
|
|
@@ -55,10 +58,8 @@
|
|
|
55
58
|
</script>
|
|
56
59
|
|
|
57
60
|
<button
|
|
58
|
-
class={button({
|
|
59
|
-
animate,
|
|
61
|
+
class={styles.button({
|
|
60
62
|
class: className,
|
|
61
|
-
shape,
|
|
62
63
|
})}
|
|
63
64
|
onclick={handleClose}
|
|
64
65
|
onmouseenter={handleMouseOver}
|
|
@@ -67,7 +68,7 @@
|
|
|
67
68
|
{#if animate}
|
|
68
69
|
<span
|
|
69
70
|
bind:this={barEl}
|
|
70
|
-
class={bar()}
|
|
71
|
+
class={styles.bar()}
|
|
71
72
|
style={`animation-duration: ${calculatedDurationInSeconds}ms`}
|
|
72
73
|
onanimationend={handleAnimationComplete}>
|
|
73
74
|
</span>
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
export default CloseButton;
|
|
2
|
+
type CloseButton = {
|
|
3
|
+
$on?(type: string, callback: (e: any) => void): () => void;
|
|
4
|
+
$set?(props: Partial<Props>): void;
|
|
5
|
+
};
|
|
6
|
+
declare const CloseButton: import("svelte").Component<{
|
|
7
|
+
/**
|
|
8
|
+
* Whether the button should automatically close after a duration
|
|
9
|
+
*/
|
|
10
|
+
autoClose?: boolean;
|
|
11
|
+
/**
|
|
12
|
+
* Duration in seconds before auto-close triggers
|
|
13
|
+
*/
|
|
14
|
+
durationInSeconds?: number;
|
|
15
|
+
/**
|
|
16
|
+
* Function to call when the button is clicked or auto-closed
|
|
17
|
+
*/
|
|
18
|
+
onClose: () => void;
|
|
19
|
+
/**
|
|
20
|
+
* Additional CSS classes to apply to the component
|
|
21
|
+
*/
|
|
22
|
+
class?: string;
|
|
23
|
+
/**
|
|
24
|
+
* Button shape
|
|
25
|
+
*/
|
|
26
|
+
shape?: "circle" | "square";
|
|
27
|
+
}, {}, "">;
|
|
28
|
+
type Props = {
|
|
29
|
+
/**
|
|
30
|
+
* Whether the button should automatically close after a duration
|
|
31
|
+
*/
|
|
32
|
+
autoClose?: boolean;
|
|
33
|
+
/**
|
|
34
|
+
* Duration in seconds before auto-close triggers
|
|
35
|
+
*/
|
|
36
|
+
durationInSeconds?: number;
|
|
37
|
+
/**
|
|
38
|
+
* Function to call when the button is clicked or auto-closed
|
|
39
|
+
*/
|
|
40
|
+
onClose: () => void;
|
|
41
|
+
/**
|
|
42
|
+
* Additional CSS classes to apply to the component
|
|
43
|
+
*/
|
|
44
|
+
class?: string;
|
|
45
|
+
/**
|
|
46
|
+
* Button shape
|
|
47
|
+
*/
|
|
48
|
+
shape?: "circle" | "square";
|
|
49
|
+
};
|
|
@@ -52,14 +52,14 @@
|
|
|
52
52
|
}
|
|
53
53
|
});
|
|
54
54
|
|
|
55
|
-
let {
|
|
55
|
+
let styles = $derived(avatarVariants({ as, shape }));
|
|
56
56
|
|
|
57
57
|
let showImage = $derived(Boolean(src));
|
|
58
58
|
</script>
|
|
59
59
|
|
|
60
60
|
<svelte:element
|
|
61
61
|
this={as}
|
|
62
|
-
class={base({
|
|
62
|
+
class={styles.base({ class: className })}
|
|
63
63
|
style={`width: ${avatarSize}px; height: ${avatarSize}px;`}
|
|
64
64
|
type={as === "button" ? "button" : undefined}
|
|
65
65
|
{...src && showImage ? {} : { role: "img", "aria-label": name || "" }}
|
|
@@ -67,12 +67,12 @@
|
|
|
67
67
|
{#if src && showImage}
|
|
68
68
|
<img
|
|
69
69
|
alt={name || ""}
|
|
70
|
-
class={image()}
|
|
70
|
+
class={styles.image()}
|
|
71
71
|
decoding="async"
|
|
72
72
|
loading={lazy ? "lazy" : "eager"}
|
|
73
73
|
{src}
|
|
74
74
|
onerror={() => (showImage = false)} />
|
|
75
75
|
{:else}
|
|
76
|
-
<span class={fallback()}>{initials}</span>
|
|
76
|
+
<span class={styles.fallback()}>{initials}</span>
|
|
77
77
|
{/if}
|
|
78
78
|
</svelte:element>
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
<script>
|
|
2
|
+
import { badgeVariants } from "./badge.variants.js";
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* @typedef {Object} Props
|
|
6
|
+
* @property {"start" | "end"} [align="end"] Horizontal position of the badge
|
|
7
|
+
* @property {"top" | "center" | "bottom" | "inline"} [anchor="top"] Vertical position of the badge
|
|
8
|
+
* @property {import('svelte').Snippet} [children] Children content – can be text, HTML, or other Svelte components
|
|
9
|
+
* @property {string} [class=""] Additional CSS classes to apply to the badge
|
|
10
|
+
* @property {"primary" | "secondary" | "error"} [color="primary"] Set the color of the badge
|
|
11
|
+
* @property {number} [count=0] Set the visible number in the badge
|
|
12
|
+
* @property {string} [wrapperClass=""] Additional CSS classes to apply to the badge wrapper
|
|
13
|
+
*/
|
|
14
|
+
|
|
15
|
+
/** @type {Props} */
|
|
16
|
+
let {
|
|
17
|
+
align = "end",
|
|
18
|
+
anchor = "top",
|
|
19
|
+
children,
|
|
20
|
+
class: className = "",
|
|
21
|
+
color = "primary",
|
|
22
|
+
count = 0,
|
|
23
|
+
wrapperClass = "",
|
|
24
|
+
...rest
|
|
25
|
+
} = $props();
|
|
26
|
+
|
|
27
|
+
let styles = $derived(
|
|
28
|
+
badgeVariants({
|
|
29
|
+
align,
|
|
30
|
+
anchor,
|
|
31
|
+
color,
|
|
32
|
+
count: !!count,
|
|
33
|
+
}),
|
|
34
|
+
);
|
|
35
|
+
</script>
|
|
36
|
+
|
|
37
|
+
<div class={styles.wrapper({ class: wrapperClass })}>
|
|
38
|
+
<div class={styles.base({ class: className })} {...rest}>
|
|
39
|
+
{#if count > 0}
|
|
40
|
+
{count > 99 ? 99 + "+" : count}
|
|
41
|
+
{/if}
|
|
42
|
+
</div>
|
|
43
|
+
{@render children?.()}
|
|
44
|
+
</div>
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
export default Badge;
|
|
2
|
+
type Badge = {
|
|
3
|
+
$on?(type: string, callback: (e: any) => void): () => void;
|
|
4
|
+
$set?(props: Partial<Props>): void;
|
|
5
|
+
};
|
|
6
|
+
declare const Badge: import("svelte").Component<{
|
|
7
|
+
/**
|
|
8
|
+
* Horizontal position of the badge
|
|
9
|
+
*/
|
|
10
|
+
align?: "start" | "end";
|
|
11
|
+
/**
|
|
12
|
+
* Vertical position of the badge
|
|
13
|
+
*/
|
|
14
|
+
anchor?: "top" | "center" | "bottom" | "inline";
|
|
15
|
+
/**
|
|
16
|
+
* Children content – can be text, HTML, or other Svelte components
|
|
17
|
+
*/
|
|
18
|
+
children?: import("svelte").Snippet;
|
|
19
|
+
/**
|
|
20
|
+
* Additional CSS classes to apply to the badge
|
|
21
|
+
*/
|
|
22
|
+
class?: string;
|
|
23
|
+
/**
|
|
24
|
+
* Set the color of the badge
|
|
25
|
+
*/
|
|
26
|
+
color?: "primary" | "secondary" | "error";
|
|
27
|
+
/**
|
|
28
|
+
* Set the visible number in the badge
|
|
29
|
+
*/
|
|
30
|
+
count?: number;
|
|
31
|
+
/**
|
|
32
|
+
* Additional CSS classes to apply to the badge wrapper
|
|
33
|
+
*/
|
|
34
|
+
wrapperClass?: string;
|
|
35
|
+
}, {}, "">;
|
|
36
|
+
type Props = {
|
|
37
|
+
/**
|
|
38
|
+
* Horizontal position of the badge
|
|
39
|
+
*/
|
|
40
|
+
align?: "start" | "end";
|
|
41
|
+
/**
|
|
42
|
+
* Vertical position of the badge
|
|
43
|
+
*/
|
|
44
|
+
anchor?: "top" | "center" | "bottom" | "inline";
|
|
45
|
+
/**
|
|
46
|
+
* Children content – can be text, HTML, or other Svelte components
|
|
47
|
+
*/
|
|
48
|
+
children?: import("svelte").Snippet;
|
|
49
|
+
/**
|
|
50
|
+
* Additional CSS classes to apply to the badge
|
|
51
|
+
*/
|
|
52
|
+
class?: string;
|
|
53
|
+
/**
|
|
54
|
+
* Set the color of the badge
|
|
55
|
+
*/
|
|
56
|
+
color?: "primary" | "secondary" | "error";
|
|
57
|
+
/**
|
|
58
|
+
* Set the visible number in the badge
|
|
59
|
+
*/
|
|
60
|
+
count?: number;
|
|
61
|
+
/**
|
|
62
|
+
* Additional CSS classes to apply to the badge wrapper
|
|
63
|
+
*/
|
|
64
|
+
wrapperClass?: string;
|
|
65
|
+
};
|