plasma-svelte 0.0.1
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 +65 -0
- package/dist/accordion/Accordion.svelte +28 -0
- package/dist/accordion/Accordion.svelte.d.ts +8 -0
- package/dist/accordion/AccordionItem.svelte +193 -0
- package/dist/accordion/AccordionItem.svelte.d.ts +14 -0
- package/dist/avatar/Avatar.svelte +178 -0
- package/dist/avatar/Avatar.svelte.d.ts +16 -0
- package/dist/badge/Badge.svelte +162 -0
- package/dist/badge/Badge.svelte.d.ts +16 -0
- package/dist/breadcrumb/Breadcrumb.svelte +59 -0
- package/dist/breadcrumb/Breadcrumb.svelte.d.ts +9 -0
- package/dist/breadcrumb/BreadcrumbItem.svelte +151 -0
- package/dist/breadcrumb/BreadcrumbItem.svelte.d.ts +14 -0
- package/dist/button/Button.svelte +274 -0
- package/dist/button/Button.svelte.d.ts +22 -0
- package/dist/button/ButtonGroup.svelte +98 -0
- package/dist/button/ButtonGroup.svelte.d.ts +12 -0
- package/dist/card/Card.svelte +191 -0
- package/dist/card/Card.svelte.d.ts +18 -0
- package/dist/checkbox/Checkbox.svelte +199 -0
- package/dist/checkbox/Checkbox.svelte.d.ts +12 -0
- package/dist/datepicker/DatePicker.svelte +509 -0
- package/dist/datepicker/DatePicker.svelte.d.ts +14 -0
- package/dist/divider/Divider.svelte +112 -0
- package/dist/divider/Divider.svelte.d.ts +13 -0
- package/dist/drawer/Drawer.svelte +330 -0
- package/dist/drawer/Drawer.svelte.d.ts +21 -0
- package/dist/dropzone/DropZone.svelte +282 -0
- package/dist/dropzone/DropZone.svelte.d.ts +17 -0
- package/dist/emptystate/EmptyState.svelte +169 -0
- package/dist/emptystate/EmptyState.svelte.d.ts +15 -0
- package/dist/headerbar/HeaderBar.svelte +210 -0
- package/dist/headerbar/HeaderBar.svelte.d.ts +17 -0
- package/dist/index.d.ts +44 -0
- package/dist/index.js +44 -0
- package/dist/input/Input.svelte +227 -0
- package/dist/input/Input.svelte.d.ts +14 -0
- package/dist/layout/Flex.svelte +110 -0
- package/dist/layout/Flex.svelte.d.ts +20 -0
- package/dist/layout/Grid.svelte +78 -0
- package/dist/layout/Grid.svelte.d.ts +19 -0
- package/dist/layout/Space.svelte +64 -0
- package/dist/layout/Space.svelte.d.ts +16 -0
- package/dist/layout/utils.d.ts +2 -0
- package/dist/layout/utils.js +19 -0
- package/dist/menu/Menu.svelte +156 -0
- package/dist/menu/Menu.svelte.d.ts +14 -0
- package/dist/menu/MenuDivider.svelte +19 -0
- package/dist/menu/MenuDivider.svelte.d.ts +6 -0
- package/dist/menu/MenuItem.svelte +126 -0
- package/dist/menu/MenuItem.svelte.d.ts +13 -0
- package/dist/message/InlineMessage.svelte +226 -0
- package/dist/message/InlineMessage.svelte.d.ts +15 -0
- package/dist/modal/ConfirmDialog.svelte +151 -0
- package/dist/modal/ConfirmDialog.svelte.d.ts +19 -0
- package/dist/modal/Modal.svelte +279 -0
- package/dist/modal/Modal.svelte.d.ts +18 -0
- package/dist/pagination/Pagination.svelte +258 -0
- package/dist/pagination/Pagination.svelte.d.ts +16 -0
- package/dist/progress/ProgressBar.svelte +179 -0
- package/dist/progress/ProgressBar.svelte.d.ts +15 -0
- package/dist/radio/Radio.svelte +161 -0
- package/dist/radio/Radio.svelte.d.ts +13 -0
- package/dist/searchfield/SearchField.svelte +246 -0
- package/dist/searchfield/SearchField.svelte.d.ts +15 -0
- package/dist/select/Select.svelte +392 -0
- package/dist/select/Select.svelte.d.ts +20 -0
- package/dist/sidebar/Sidebar.svelte +78 -0
- package/dist/sidebar/Sidebar.svelte.d.ts +11 -0
- package/dist/sidebar/SidebarGroup.svelte +51 -0
- package/dist/sidebar/SidebarGroup.svelte.d.ts +9 -0
- package/dist/sidebar/SidebarItem.svelte +185 -0
- package/dist/sidebar/SidebarItem.svelte.d.ts +16 -0
- package/dist/slider/Slider.svelte +204 -0
- package/dist/slider/Slider.svelte.d.ts +16 -0
- package/dist/spinbox/SpinBox.svelte +299 -0
- package/dist/spinbox/SpinBox.svelte.d.ts +20 -0
- package/dist/spinner/Spinner.svelte +130 -0
- package/dist/spinner/Spinner.svelte.d.ts +11 -0
- package/dist/style/base.css +178 -0
- package/dist/style/index.css +2 -0
- package/dist/style/token.css +230 -0
- package/dist/switch/Switch.svelte +199 -0
- package/dist/switch/Switch.svelte.d.ts +13 -0
- package/dist/table/Table.svelte +305 -0
- package/dist/table/Table.svelte.d.ts +32 -0
- package/dist/tabs/Tabs.svelte +216 -0
- package/dist/tabs/Tabs.svelte.d.ts +21 -0
- package/dist/textarea/TextArea.svelte +114 -0
- package/dist/textarea/TextArea.svelte.d.ts +14 -0
- package/dist/timepicker/TimePicker.svelte +452 -0
- package/dist/timepicker/TimePicker.svelte.d.ts +16 -0
- package/dist/tooltip/Tooltip.svelte +122 -0
- package/dist/tooltip/Tooltip.svelte.d.ts +12 -0
- package/package.json +66 -0
|
@@ -0,0 +1,156 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import type { Snippet } from "svelte";
|
|
3
|
+
import type { HTMLAttributes } from "svelte/elements";
|
|
4
|
+
|
|
5
|
+
type MenuPlacement = "bottom-start" | "bottom-end" | "top-start" | "top-end";
|
|
6
|
+
|
|
7
|
+
interface Props extends HTMLAttributes<HTMLDivElement> {
|
|
8
|
+
open?: boolean;
|
|
9
|
+
inline?: boolean;
|
|
10
|
+
placement?: MenuPlacement;
|
|
11
|
+
trigger?: Snippet;
|
|
12
|
+
children?: Snippet;
|
|
13
|
+
onclose?: () => void;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
let {
|
|
17
|
+
open = $bindable(false),
|
|
18
|
+
inline = false,
|
|
19
|
+
placement = "bottom-start",
|
|
20
|
+
trigger,
|
|
21
|
+
children,
|
|
22
|
+
onclose,
|
|
23
|
+
class: customClass = "",
|
|
24
|
+
...restProps
|
|
25
|
+
}: Props = $props();
|
|
26
|
+
|
|
27
|
+
let containerEl = $state<HTMLDivElement | null>(null);
|
|
28
|
+
|
|
29
|
+
function toggle() {
|
|
30
|
+
open = !open;
|
|
31
|
+
if (!open) onclose?.();
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
function handleWindowClick(e: MouseEvent) {
|
|
35
|
+
if (
|
|
36
|
+
!inline &&
|
|
37
|
+
open &&
|
|
38
|
+
containerEl &&
|
|
39
|
+
!containerEl.contains(e.target as Node)
|
|
40
|
+
) {
|
|
41
|
+
open = false;
|
|
42
|
+
onclose?.();
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
function handleKeydown(e: KeyboardEvent) {
|
|
47
|
+
if (!inline && open && e.key === "Escape") {
|
|
48
|
+
e.stopPropagation();
|
|
49
|
+
open = false;
|
|
50
|
+
onclose?.();
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
</script>
|
|
54
|
+
|
|
55
|
+
<svelte:window onclick={handleWindowClick} onkeydown={handleKeydown} />
|
|
56
|
+
|
|
57
|
+
<div
|
|
58
|
+
bind:this={containerEl}
|
|
59
|
+
class="plasma-menu-wrapper {customClass}"
|
|
60
|
+
class:plasma-menu-wrapper--inline={inline}
|
|
61
|
+
{...restProps}
|
|
62
|
+
>
|
|
63
|
+
{#if trigger}
|
|
64
|
+
<!-- svelte-ignore a11y_click_events_have_key_events -->
|
|
65
|
+
<!-- svelte-ignore a11y_no_static_element_interactions -->
|
|
66
|
+
<!-- biome-ignore lint/a11y/noStaticElementInteractions: trigger slot wrapper -->
|
|
67
|
+
<div class="plasma-menu-trigger" onclick={toggle} onkeydown={() => {}}>
|
|
68
|
+
{@render trigger()}
|
|
69
|
+
</div>
|
|
70
|
+
{/if}
|
|
71
|
+
|
|
72
|
+
{#if open || inline}
|
|
73
|
+
<ul
|
|
74
|
+
role="menu"
|
|
75
|
+
class="plasma-menu plasma-menu--{placement}"
|
|
76
|
+
class:plasma-menu--static={inline}
|
|
77
|
+
>
|
|
78
|
+
{@render children?.()}
|
|
79
|
+
</ul>
|
|
80
|
+
{/if}
|
|
81
|
+
</div>
|
|
82
|
+
|
|
83
|
+
<style>
|
|
84
|
+
.plasma-menu-wrapper {
|
|
85
|
+
position: relative;
|
|
86
|
+
display: inline-flex;
|
|
87
|
+
box-sizing: border-box;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
.plasma-menu-wrapper--inline {
|
|
91
|
+
width: auto;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
.plasma-menu-trigger {
|
|
95
|
+
display: inline-flex;
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
/* --------------------------------------------------------------------------
|
|
99
|
+
Floating Menu Panel (KDE Breeze QMenu)
|
|
100
|
+
-------------------------------------------------------------------------- */
|
|
101
|
+
.plasma-menu {
|
|
102
|
+
position: absolute;
|
|
103
|
+
z-index: 1000;
|
|
104
|
+
min-width: 180px;
|
|
105
|
+
max-width: 320px;
|
|
106
|
+
margin: 0;
|
|
107
|
+
padding: 4px;
|
|
108
|
+
list-style: none;
|
|
109
|
+
background-color: var(--plasma-color-surface);
|
|
110
|
+
border: 1px solid var(--plasma-color-border);
|
|
111
|
+
border-radius: var(--plasma-radius-md);
|
|
112
|
+
box-shadow: var(--plasma-shadow-md);
|
|
113
|
+
animation: plasma-menu-pop var(--plasma-duration-fast)
|
|
114
|
+
var(--plasma-ease-default);
|
|
115
|
+
box-sizing: border-box;
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
.plasma-menu--static {
|
|
119
|
+
position: relative;
|
|
120
|
+
top: auto;
|
|
121
|
+
left: auto;
|
|
122
|
+
right: auto;
|
|
123
|
+
bottom: auto;
|
|
124
|
+
z-index: auto;
|
|
125
|
+
animation: none;
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
/* Placements */
|
|
129
|
+
.plasma-menu--bottom-start {
|
|
130
|
+
top: calc(100% + 4px);
|
|
131
|
+
left: 0;
|
|
132
|
+
}
|
|
133
|
+
.plasma-menu--bottom-end {
|
|
134
|
+
top: calc(100% + 4px);
|
|
135
|
+
right: 0;
|
|
136
|
+
}
|
|
137
|
+
.plasma-menu--top-start {
|
|
138
|
+
bottom: calc(100% + 4px);
|
|
139
|
+
left: 0;
|
|
140
|
+
}
|
|
141
|
+
.plasma-menu--top-end {
|
|
142
|
+
bottom: calc(100% + 4px);
|
|
143
|
+
right: 0;
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
@keyframes plasma-menu-pop {
|
|
147
|
+
from {
|
|
148
|
+
opacity: 0;
|
|
149
|
+
transform: scale(0.95) translateY(-4px);
|
|
150
|
+
}
|
|
151
|
+
to {
|
|
152
|
+
opacity: 1;
|
|
153
|
+
transform: scale(1) translateY(0);
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
</style>
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { Snippet } from "svelte";
|
|
2
|
+
import type { HTMLAttributes } from "svelte/elements";
|
|
3
|
+
type MenuPlacement = "bottom-start" | "bottom-end" | "top-start" | "top-end";
|
|
4
|
+
interface Props extends HTMLAttributes<HTMLDivElement> {
|
|
5
|
+
open?: boolean;
|
|
6
|
+
inline?: boolean;
|
|
7
|
+
placement?: MenuPlacement;
|
|
8
|
+
trigger?: Snippet;
|
|
9
|
+
children?: Snippet;
|
|
10
|
+
onclose?: () => void;
|
|
11
|
+
}
|
|
12
|
+
declare const Menu: import("svelte").Component<Props, {}, "open">;
|
|
13
|
+
type Menu = ReturnType<typeof Menu>;
|
|
14
|
+
export default Menu;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import type { HTMLAttributes } from "svelte/elements";
|
|
3
|
+
|
|
4
|
+
interface Props extends HTMLAttributes<HTMLHRElement> {}
|
|
5
|
+
|
|
6
|
+
let { class: customClass = "", ...restProps }: Props = $props();
|
|
7
|
+
</script>
|
|
8
|
+
|
|
9
|
+
<hr class="plasma-menu-divider {customClass}" {...restProps} />
|
|
10
|
+
|
|
11
|
+
<style>
|
|
12
|
+
.plasma-menu-divider {
|
|
13
|
+
height: 1px;
|
|
14
|
+
margin: 4px 0;
|
|
15
|
+
padding: 0;
|
|
16
|
+
border: none;
|
|
17
|
+
background-color: var(--plasma-color-border-subtle);
|
|
18
|
+
}
|
|
19
|
+
</style>
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { HTMLAttributes } from "svelte/elements";
|
|
2
|
+
interface Props extends HTMLAttributes<HTMLHRElement> {
|
|
3
|
+
}
|
|
4
|
+
declare const MenuDivider: import("svelte").Component<Props, {}, "">;
|
|
5
|
+
type MenuDivider = ReturnType<typeof MenuDivider>;
|
|
6
|
+
export default MenuDivider;
|
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
<!-- biome-ignore-all lint/a11y/useFocusableInteractive: handled by menu -->
|
|
2
|
+
<!-- biome-ignore-all lint/a11y/useKeyWithClickEvents: handled by menu container -->
|
|
3
|
+
<script lang="ts">
|
|
4
|
+
import type { Snippet } from "svelte";
|
|
5
|
+
import type { HTMLAttributes } from "svelte/elements";
|
|
6
|
+
|
|
7
|
+
interface Props extends HTMLAttributes<HTMLLIElement> {
|
|
8
|
+
label?: string;
|
|
9
|
+
shortcut?: string;
|
|
10
|
+
icon?: Snippet;
|
|
11
|
+
disabled?: boolean;
|
|
12
|
+
danger?: boolean;
|
|
13
|
+
children?: Snippet;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
let {
|
|
17
|
+
label = "",
|
|
18
|
+
shortcut = "",
|
|
19
|
+
icon,
|
|
20
|
+
disabled = false,
|
|
21
|
+
danger = false,
|
|
22
|
+
children,
|
|
23
|
+
class: customClass = "",
|
|
24
|
+
onclick,
|
|
25
|
+
...restProps
|
|
26
|
+
}: Props = $props();
|
|
27
|
+
|
|
28
|
+
function handleClick(e: MouseEvent) {
|
|
29
|
+
if (disabled) {
|
|
30
|
+
e.stopPropagation();
|
|
31
|
+
return;
|
|
32
|
+
}
|
|
33
|
+
onclick?.(e as any);
|
|
34
|
+
}
|
|
35
|
+
</script>
|
|
36
|
+
|
|
37
|
+
<li
|
|
38
|
+
role="menuitem"
|
|
39
|
+
aria-disabled={disabled}
|
|
40
|
+
class="plasma-menu-item {customClass}"
|
|
41
|
+
class:plasma-menu-item--disabled={disabled}
|
|
42
|
+
class:plasma-menu-item--danger={danger}
|
|
43
|
+
onclick={handleClick}
|
|
44
|
+
{...restProps}
|
|
45
|
+
>
|
|
46
|
+
{#if icon}
|
|
47
|
+
<span class="plasma-menu-item-icon">
|
|
48
|
+
{@render icon()}
|
|
49
|
+
</span>
|
|
50
|
+
{/if}
|
|
51
|
+
|
|
52
|
+
<span class="plasma-menu-item-label">
|
|
53
|
+
{#if children}
|
|
54
|
+
{@render children()}
|
|
55
|
+
{:else}
|
|
56
|
+
{label}
|
|
57
|
+
{/if}
|
|
58
|
+
</span>
|
|
59
|
+
|
|
60
|
+
{#if shortcut}
|
|
61
|
+
<span class="plasma-menu-item-shortcut">{shortcut}</span>
|
|
62
|
+
{/if}
|
|
63
|
+
</li>
|
|
64
|
+
|
|
65
|
+
<style>
|
|
66
|
+
.plasma-menu-item {
|
|
67
|
+
display: flex;
|
|
68
|
+
align-items: center;
|
|
69
|
+
gap: var(--plasma-space-sm);
|
|
70
|
+
padding: 6px var(--plasma-space-sm);
|
|
71
|
+
border-radius: var(--plasma-radius-sm);
|
|
72
|
+
font-family: var(--plasma-font-sans);
|
|
73
|
+
font-size: var(--plasma-font-size-base);
|
|
74
|
+
color: var(--plasma-color-text);
|
|
75
|
+
cursor: pointer;
|
|
76
|
+
user-select: none;
|
|
77
|
+
transition: var(--plasma-transition-fast);
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
.plasma-menu-item-icon {
|
|
81
|
+
display: inline-flex;
|
|
82
|
+
align-items: center;
|
|
83
|
+
justify-content: center;
|
|
84
|
+
width: 16px;
|
|
85
|
+
height: 16px;
|
|
86
|
+
color: var(--plasma-color-text-muted);
|
|
87
|
+
flex-shrink: 0;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
.plasma-menu-item-label {
|
|
91
|
+
flex: 1;
|
|
92
|
+
overflow: hidden;
|
|
93
|
+
text-overflow: ellipsis;
|
|
94
|
+
white-space: nowrap;
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
.plasma-menu-item-shortcut {
|
|
98
|
+
font-family: var(--plasma-font-mono);
|
|
99
|
+
font-size: var(--plasma-font-size-xs);
|
|
100
|
+
color: var(--plasma-color-text-muted);
|
|
101
|
+
padding-left: var(--plasma-space-md);
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
/* Hover & Active States */
|
|
105
|
+
.plasma-menu-item:hover:not(.plasma-menu-item--disabled) {
|
|
106
|
+
background-color: var(--plasma-color-highlight);
|
|
107
|
+
color: #ffffff;
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
.plasma-menu-item:hover:not(.plasma-menu-item--disabled) .plasma-menu-item-icon,
|
|
111
|
+
.plasma-menu-item:hover:not(.plasma-menu-item--disabled) .plasma-menu-item-shortcut {
|
|
112
|
+
color: rgba(255, 255, 255, 0.9);
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
/* Danger / Destructive Variant */
|
|
116
|
+
.plasma-menu-item--danger:hover:not(.plasma-menu-item--disabled) {
|
|
117
|
+
background-color: var(--plasma-color-negative);
|
|
118
|
+
color: #ffffff;
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
/* Disabled */
|
|
122
|
+
.plasma-menu-item--disabled {
|
|
123
|
+
opacity: 0.4;
|
|
124
|
+
cursor: not-allowed;
|
|
125
|
+
}
|
|
126
|
+
</style>
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { Snippet } from "svelte";
|
|
2
|
+
import type { HTMLAttributes } from "svelte/elements";
|
|
3
|
+
interface Props extends HTMLAttributes<HTMLLIElement> {
|
|
4
|
+
label?: string;
|
|
5
|
+
shortcut?: string;
|
|
6
|
+
icon?: Snippet;
|
|
7
|
+
disabled?: boolean;
|
|
8
|
+
danger?: boolean;
|
|
9
|
+
children?: Snippet;
|
|
10
|
+
}
|
|
11
|
+
declare const MenuItem: import("svelte").Component<Props, {}, "">;
|
|
12
|
+
type MenuItem = ReturnType<typeof MenuItem>;
|
|
13
|
+
export default MenuItem;
|
|
@@ -0,0 +1,226 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import type { Snippet } from "svelte";
|
|
3
|
+
import type { HTMLAttributes } from "svelte/elements";
|
|
4
|
+
|
|
5
|
+
type MessageType =
|
|
6
|
+
| "information"
|
|
7
|
+
| "info"
|
|
8
|
+
| "positive"
|
|
9
|
+
| "success"
|
|
10
|
+
| "warning"
|
|
11
|
+
| "neutral"
|
|
12
|
+
| "negative"
|
|
13
|
+
| "error";
|
|
14
|
+
|
|
15
|
+
interface Props extends HTMLAttributes<HTMLDivElement> {
|
|
16
|
+
type?: MessageType;
|
|
17
|
+
title?: string;
|
|
18
|
+
text?: string;
|
|
19
|
+
closable?: boolean;
|
|
20
|
+
actions?: Snippet;
|
|
21
|
+
children?: Snippet;
|
|
22
|
+
onclose?: () => void;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
let {
|
|
26
|
+
type = "information",
|
|
27
|
+
title = "",
|
|
28
|
+
text = "",
|
|
29
|
+
closable = false,
|
|
30
|
+
actions,
|
|
31
|
+
children,
|
|
32
|
+
onclose,
|
|
33
|
+
class: customClass = "",
|
|
34
|
+
...restProps
|
|
35
|
+
}: Props = $props();
|
|
36
|
+
|
|
37
|
+
let isVisible = $state(true);
|
|
38
|
+
|
|
39
|
+
const resolvedType = $derived(
|
|
40
|
+
type === "info"
|
|
41
|
+
? "information"
|
|
42
|
+
: type === "success"
|
|
43
|
+
? "positive"
|
|
44
|
+
: type === "warning"
|
|
45
|
+
? "neutral"
|
|
46
|
+
: type === "error"
|
|
47
|
+
? "negative"
|
|
48
|
+
: type
|
|
49
|
+
);
|
|
50
|
+
|
|
51
|
+
function handleClose() {
|
|
52
|
+
isVisible = false;
|
|
53
|
+
onclose?.();
|
|
54
|
+
}
|
|
55
|
+
</script>
|
|
56
|
+
|
|
57
|
+
{#if isVisible}
|
|
58
|
+
<div
|
|
59
|
+
role="status"
|
|
60
|
+
class="plasma-message plasma-message--{resolvedType} {customClass}"
|
|
61
|
+
{...restProps}
|
|
62
|
+
>
|
|
63
|
+
<div class="plasma-message-icon">
|
|
64
|
+
{#if resolvedType === "positive"}
|
|
65
|
+
<svg aria-hidden="true" viewBox="0 0 16 16" width="16" height="16" fill="currentColor">
|
|
66
|
+
<path d="M16 8A8 8 0 1 1 0 8a8 8 0 0 1 16 0zm-3.97-3.03a.75.75 0 0 0-1.08.022L7.477 9.417 5.384 7.323a.75.75 0 0 0-1.06 1.06L6.97 11.03a.75.75 0 0 0 1.079-.02l3.992-4.99a.75.75 0 0 0-.01-1.05z" />
|
|
67
|
+
</svg>
|
|
68
|
+
{:else if resolvedType === "neutral"}
|
|
69
|
+
<svg aria-hidden="true" viewBox="0 0 16 16" width="16" height="16" fill="currentColor">
|
|
70
|
+
<path d="M8.982 1.566a1.13 1.13 0 0 0-1.96 0L.165 13.233c-.457.778.091 1.767.98 1.767h13.713c.889 0 1.438-.99.98-1.767L8.982 1.566zM8 5c.535 0 .954.462.9.995l-.35 3.507a.552.552 0 0 1-1.1 0L7.1 5.995A.905.905 0 0 1 8 5zm.002 6a1 1 0 1 1 0 2 1 1 0 0 1 0-2z" />
|
|
71
|
+
</svg>
|
|
72
|
+
{:else if resolvedType === "negative"}
|
|
73
|
+
<svg aria-hidden="true" viewBox="0 0 16 16" width="16" height="16" fill="currentColor">
|
|
74
|
+
<path d="M16 8A8 8 0 1 1 0 8a8 8 0 0 1 16 0zM5.354 4.646a.5.5 0 1 0-.708.708L7.293 8l-2.647 2.646a.5.5 0 0 0 .708.708L8 8.707l2.646 2.647a.5.5 0 0 0 .708-.708L8.707 8l2.647-2.646a.5.5 0 0 0-.708-.708L8 7.293 5.354 4.646z" />
|
|
75
|
+
</svg>
|
|
76
|
+
{:else}
|
|
77
|
+
<svg aria-hidden="true" viewBox="0 0 16 16" width="16" height="16" fill="currentColor">
|
|
78
|
+
<path d="M8 16A8 8 0 1 0 8 0a8 8 0 0 0 0 16zm.93-9.412-1 4.705c-.07.34.029.533.304.533.194 0 .487-.07.686-.246l-.088.416c-.287.346-.92.598-1.465.598-.703 0-1.002-.422-.808-1.319l.738-3.468c.064-.293.006-.399-.287-.47l-.451-.081.082-.381 2.29-.287zM8 5.5a1 1 0 1 1 0-2 1 1 0 0 1 0 2z" />
|
|
79
|
+
</svg>
|
|
80
|
+
{/if}
|
|
81
|
+
</div>
|
|
82
|
+
|
|
83
|
+
<div class="plasma-message-content">
|
|
84
|
+
{#if title}
|
|
85
|
+
<span class="plasma-message-title">{title}</span>
|
|
86
|
+
{/if}
|
|
87
|
+
|
|
88
|
+
{#if children}
|
|
89
|
+
<div class="plasma-message-body">
|
|
90
|
+
{@render children()}
|
|
91
|
+
</div>
|
|
92
|
+
{:else if text}
|
|
93
|
+
<div class="plasma-message-body">
|
|
94
|
+
{text}
|
|
95
|
+
</div>
|
|
96
|
+
{/if}
|
|
97
|
+
</div>
|
|
98
|
+
|
|
99
|
+
{#if actions}
|
|
100
|
+
<div class="plasma-message-actions">
|
|
101
|
+
{@render actions()}
|
|
102
|
+
</div>
|
|
103
|
+
{/if}
|
|
104
|
+
|
|
105
|
+
{#if closable}
|
|
106
|
+
<button
|
|
107
|
+
type="button"
|
|
108
|
+
class="plasma-message-close"
|
|
109
|
+
onclick={handleClose}
|
|
110
|
+
aria-label="Dismiss message"
|
|
111
|
+
>
|
|
112
|
+
<svg aria-hidden="true" viewBox="0 0 16 16" width="12" height="12" fill="currentColor">
|
|
113
|
+
<path d="M4.646 4.646a.5.5 0 0 1 .708 0L8 7.293l2.646-2.647a.5.5 0 0 1 .708.708L8.707 8l2.647 2.646a.5.5 0 0 1-.708.708L8 8.707l-2.646 2.647a.5.5 0 0 1-.708-.708L7.293 8 4.646 5.354a.5.5 0 0 1 0-.708z" />
|
|
114
|
+
</svg>
|
|
115
|
+
</button>
|
|
116
|
+
{/if}
|
|
117
|
+
</div>
|
|
118
|
+
{/if}
|
|
119
|
+
|
|
120
|
+
<style>
|
|
121
|
+
.plasma-message {
|
|
122
|
+
display: flex;
|
|
123
|
+
align-items: flex-start;
|
|
124
|
+
gap: var(--plasma-space-md);
|
|
125
|
+
padding: var(--plasma-space-md);
|
|
126
|
+
border-radius: var(--plasma-radius-md);
|
|
127
|
+
font-family: var(--plasma-font-sans);
|
|
128
|
+
font-size: var(--plasma-font-size-base);
|
|
129
|
+
box-sizing: border-box;
|
|
130
|
+
width: 100%;
|
|
131
|
+
border: 1px solid transparent;
|
|
132
|
+
transition: var(--plasma-transition-fast);
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
.plasma-message-icon {
|
|
136
|
+
display: inline-flex;
|
|
137
|
+
align-items: center;
|
|
138
|
+
justify-content: center;
|
|
139
|
+
flex-shrink: 0;
|
|
140
|
+
margin-top: 2px;
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
.plasma-message-content {
|
|
144
|
+
flex: 1;
|
|
145
|
+
display: flex;
|
|
146
|
+
flex-direction: column;
|
|
147
|
+
gap: 2px;
|
|
148
|
+
line-height: 1.4;
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
.plasma-message-title {
|
|
152
|
+
font-weight: var(--plasma-font-weight-bold);
|
|
153
|
+
font-size: var(--plasma-font-size-base);
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
.plasma-message-body {
|
|
157
|
+
font-size: var(--plasma-font-size-sm);
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
.plasma-message-actions {
|
|
161
|
+
display: flex;
|
|
162
|
+
align-items: center;
|
|
163
|
+
gap: var(--plasma-space-xs);
|
|
164
|
+
flex-shrink: 0;
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
.plasma-message-close {
|
|
168
|
+
display: inline-flex;
|
|
169
|
+
align-items: center;
|
|
170
|
+
justify-content: center;
|
|
171
|
+
width: 20px;
|
|
172
|
+
height: 20px;
|
|
173
|
+
border-radius: var(--plasma-radius-full);
|
|
174
|
+
border: none;
|
|
175
|
+
background: transparent;
|
|
176
|
+
color: inherit;
|
|
177
|
+
opacity: 0.7;
|
|
178
|
+
cursor: pointer;
|
|
179
|
+
transition: var(--plasma-transition-fast);
|
|
180
|
+
flex-shrink: 0;
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
.plasma-message-close:hover {
|
|
184
|
+
opacity: 1;
|
|
185
|
+
background-color: rgba(0, 0, 0, 0.15);
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
/* --------------------------------------------------------------------------
|
|
189
|
+
Theme & Role Variants
|
|
190
|
+
-------------------------------------------------------------------------- */
|
|
191
|
+
.plasma-message--information {
|
|
192
|
+
background-color: var(--plasma-color-highlight-soft);
|
|
193
|
+
border-color: rgba(61, 174, 233, 0.4);
|
|
194
|
+
color: var(--plasma-color-text);
|
|
195
|
+
}
|
|
196
|
+
.plasma-message--information .plasma-message-icon {
|
|
197
|
+
color: var(--plasma-color-highlight);
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
.plasma-message--positive {
|
|
201
|
+
background-color: var(--plasma-color-positive-soft);
|
|
202
|
+
border-color: rgba(39, 174, 96, 0.4);
|
|
203
|
+
color: var(--plasma-color-text);
|
|
204
|
+
}
|
|
205
|
+
.plasma-message--positive .plasma-message-icon {
|
|
206
|
+
color: var(--plasma-color-positive);
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
.plasma-message--neutral {
|
|
210
|
+
background-color: var(--plasma-color-neutral-soft);
|
|
211
|
+
border-color: rgba(246, 116, 0, 0.4);
|
|
212
|
+
color: var(--plasma-color-text);
|
|
213
|
+
}
|
|
214
|
+
.plasma-message--neutral .plasma-message-icon {
|
|
215
|
+
color: var(--plasma-color-neutral);
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
.plasma-message--negative {
|
|
219
|
+
background-color: var(--plasma-color-negative-soft);
|
|
220
|
+
border-color: rgba(218, 68, 83, 0.4);
|
|
221
|
+
color: var(--plasma-color-text);
|
|
222
|
+
}
|
|
223
|
+
.plasma-message--negative .plasma-message-icon {
|
|
224
|
+
color: var(--plasma-color-negative);
|
|
225
|
+
}
|
|
226
|
+
</style>
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { Snippet } from "svelte";
|
|
2
|
+
import type { HTMLAttributes } from "svelte/elements";
|
|
3
|
+
type MessageType = "information" | "info" | "positive" | "success" | "warning" | "neutral" | "negative" | "error";
|
|
4
|
+
interface Props extends HTMLAttributes<HTMLDivElement> {
|
|
5
|
+
type?: MessageType;
|
|
6
|
+
title?: string;
|
|
7
|
+
text?: string;
|
|
8
|
+
closable?: boolean;
|
|
9
|
+
actions?: Snippet;
|
|
10
|
+
children?: Snippet;
|
|
11
|
+
onclose?: () => void;
|
|
12
|
+
}
|
|
13
|
+
declare const InlineMessage: import("svelte").Component<Props, {}, "">;
|
|
14
|
+
type InlineMessage = ReturnType<typeof InlineMessage>;
|
|
15
|
+
export default InlineMessage;
|