lapikit 0.4.8 → 0.4.10
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/labs/compiler/components.js +7 -1
- package/dist/labs/components/accordion/accordion.svelte +133 -0
- package/dist/labs/components/accordion/accordion.svelte.d.ts +4 -0
- package/dist/labs/components/accordion/accordion.types.d.ts +34 -0
- package/dist/labs/components/accordion/accordion.types.js +1 -0
- package/dist/labs/components/accordion/modules/accordion-item.svelte +241 -0
- package/dist/labs/components/accordion/modules/accordion-item.svelte.d.ts +4 -0
- package/dist/labs/components/alert/alert.svelte +286 -0
- package/dist/labs/components/alert/alert.svelte.d.ts +4 -0
- package/dist/labs/components/alert/alert.types.d.ts +24 -0
- package/dist/labs/components/alert/alert.types.js +1 -0
- package/dist/labs/components/aspect-ratio/aspect-ratio.svelte +130 -0
- package/dist/labs/components/aspect-ratio/aspect-ratio.svelte.d.ts +4 -0
- package/dist/labs/components/aspect-ratio/aspect-ratio.types.d.ts +11 -0
- package/dist/labs/components/aspect-ratio/aspect-ratio.types.js +1 -0
- package/dist/labs/components/card/card.svelte +287 -0
- package/dist/labs/components/card/card.svelte.d.ts +4 -0
- package/dist/labs/components/card/card.types.d.ts +14 -0
- package/dist/labs/components/card/card.types.js +1 -0
- package/dist/labs/components/chip/chip.svelte +501 -0
- package/dist/labs/components/chip/chip.svelte.d.ts +4 -0
- package/dist/labs/components/chip/chip.types.d.ts +24 -0
- package/dist/labs/components/chip/chip.types.js +1 -0
- package/dist/labs/components/index.d.ts +6 -0
- package/dist/labs/components/index.js +6 -0
- package/package.json +1 -1
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import { useClassName, useStyles } from '../../utils/index.js';
|
|
3
|
+
import { makeComponentProps } from '../../compiler/mapped-code.js';
|
|
4
|
+
import type { AccordionProps } from './accordion.types.js';
|
|
5
|
+
|
|
6
|
+
let {
|
|
7
|
+
ref = $bindable(),
|
|
8
|
+
is = 'div',
|
|
9
|
+
children = undefined,
|
|
10
|
+
class: className = '',
|
|
11
|
+
style: styleAttr = '',
|
|
12
|
+
's-class': sClass,
|
|
13
|
+
's-style': sStyle,
|
|
14
|
+
text = undefined,
|
|
15
|
+
dark = false,
|
|
16
|
+
light = false,
|
|
17
|
+
color = undefined,
|
|
18
|
+
background = undefined,
|
|
19
|
+
rounded = undefined,
|
|
20
|
+
spacer = false,
|
|
21
|
+
hideIcon = false,
|
|
22
|
+
...rest
|
|
23
|
+
}: AccordionProps = $props();
|
|
24
|
+
|
|
25
|
+
let { classProps, styleProps, restProps } = $derived(
|
|
26
|
+
makeComponentProps(rest as Record<string, unknown>)
|
|
27
|
+
);
|
|
28
|
+
|
|
29
|
+
let componentClass = $derived(
|
|
30
|
+
useClassName({
|
|
31
|
+
baseClass: 'kit-accordion',
|
|
32
|
+
className: `${className ?? ''}`.trim(),
|
|
33
|
+
sClass,
|
|
34
|
+
classProps
|
|
35
|
+
})
|
|
36
|
+
);
|
|
37
|
+
|
|
38
|
+
let componentStyle = $derived(
|
|
39
|
+
useStyles({
|
|
40
|
+
styleAttr,
|
|
41
|
+
sStyle,
|
|
42
|
+
styleProps
|
|
43
|
+
})
|
|
44
|
+
);
|
|
45
|
+
|
|
46
|
+
let mergedStyle = $derived(
|
|
47
|
+
[
|
|
48
|
+
componentStyle,
|
|
49
|
+
color ? `--kit-accordion-color:${color}` : '',
|
|
50
|
+
background ? `--kit-accordion-background:${background}` : ''
|
|
51
|
+
]
|
|
52
|
+
.filter(Boolean)
|
|
53
|
+
.join('; ')
|
|
54
|
+
);
|
|
55
|
+
</script>
|
|
56
|
+
|
|
57
|
+
<svelte:element
|
|
58
|
+
this={is}
|
|
59
|
+
bind:this={ref}
|
|
60
|
+
class={componentClass}
|
|
61
|
+
style={mergedStyle}
|
|
62
|
+
{...restProps}
|
|
63
|
+
data-text={text ? true : undefined}
|
|
64
|
+
data-dark={dark}
|
|
65
|
+
data-light={light}
|
|
66
|
+
data-spacer={spacer}
|
|
67
|
+
data-hide-icon={hideIcon}
|
|
68
|
+
data-rounded={rounded}
|
|
69
|
+
>
|
|
70
|
+
{@render children?.()}
|
|
71
|
+
</svelte:element>
|
|
72
|
+
|
|
73
|
+
<style>
|
|
74
|
+
.kit-accordion {
|
|
75
|
+
--kit-accordion-radius: 8px;
|
|
76
|
+
--kit-accordion-gap: 0;
|
|
77
|
+
--kit-accordion-color: var(--kit-fg);
|
|
78
|
+
--kit-accordion-background: transparent;
|
|
79
|
+
|
|
80
|
+
display: flex;
|
|
81
|
+
flex-wrap: wrap;
|
|
82
|
+
justify-content: center;
|
|
83
|
+
width: 100%;
|
|
84
|
+
padding: 0;
|
|
85
|
+
list-style: none;
|
|
86
|
+
position: relative;
|
|
87
|
+
z-index: 1;
|
|
88
|
+
gap: var(--kit-accordion-gap);
|
|
89
|
+
color: var(--kit-accordion-color);
|
|
90
|
+
background: var(--kit-accordion-background);
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
.kit-accordion[data-spacer='true'] {
|
|
94
|
+
--kit-accordion-gap: 1rem;
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
.kit-accordion[data-rounded='0'] {
|
|
98
|
+
--kit-accordion-radius: 0;
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
.kit-accordion[data-rounded='xs'] {
|
|
102
|
+
--kit-accordion-radius: 2px;
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
.kit-accordion[data-rounded='sm'] {
|
|
106
|
+
--kit-accordion-radius: 4px;
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
.kit-accordion[data-rounded='md'] {
|
|
110
|
+
--kit-accordion-radius: 8px;
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
.kit-accordion[data-rounded='lg'] {
|
|
114
|
+
--kit-accordion-radius: 16px;
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
.kit-accordion[data-rounded='xl'] {
|
|
118
|
+
--kit-accordion-radius: 99999px;
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
.kit-accordion[data-dark='true'] {
|
|
122
|
+
--kit-accordion-background: var(--kit-surface-3);
|
|
123
|
+
--kit-accordion-color: var(--kit-fg);
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
.kit-accordion[data-light='true'] {
|
|
127
|
+
--kit-accordion-background: var(--kit-surface-1);
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
.kit-accordion[data-hide-icon='true'] :global(.kit-accordion-item__indicator) {
|
|
131
|
+
display: none;
|
|
132
|
+
}
|
|
133
|
+
</style>
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import type { RoundedType, Component } from '../../utils/types/index.js';
|
|
2
|
+
import type { Snippet } from 'svelte';
|
|
3
|
+
export interface AccordionProps extends Component {
|
|
4
|
+
ref?: HTMLElement | null;
|
|
5
|
+
is?: 'div';
|
|
6
|
+
text?: string;
|
|
7
|
+
dark?: boolean;
|
|
8
|
+
light?: boolean;
|
|
9
|
+
color?: string;
|
|
10
|
+
background?: string;
|
|
11
|
+
rounded?: RoundedType;
|
|
12
|
+
spacer?: boolean;
|
|
13
|
+
hideIcon?: boolean;
|
|
14
|
+
}
|
|
15
|
+
export type AccordionItemModelProps = {
|
|
16
|
+
open: boolean;
|
|
17
|
+
};
|
|
18
|
+
export interface AccordionItemProps extends Component {
|
|
19
|
+
ref?: HTMLElement | null;
|
|
20
|
+
is?: 'div';
|
|
21
|
+
index: number | string;
|
|
22
|
+
text?: string;
|
|
23
|
+
dark?: boolean;
|
|
24
|
+
light?: boolean;
|
|
25
|
+
rounded?: RoundedType;
|
|
26
|
+
color?: string;
|
|
27
|
+
background?: string;
|
|
28
|
+
readOnly?: boolean;
|
|
29
|
+
open?: boolean;
|
|
30
|
+
disabled?: boolean;
|
|
31
|
+
toggle?: (index: number | string) => void;
|
|
32
|
+
indicator?: Snippet<[AccordionItemModelProps]>;
|
|
33
|
+
activator?: Snippet;
|
|
34
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,241 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import { useClassName, useStyles } from '../../../utils/index.js';
|
|
3
|
+
import { makeComponentProps } from '../../../compiler/mapped-code.js';
|
|
4
|
+
import type { AccordionItemModelProps, AccordionItemProps } from '../accordion.types.js';
|
|
5
|
+
|
|
6
|
+
let {
|
|
7
|
+
ref = $bindable(),
|
|
8
|
+
is = 'div',
|
|
9
|
+
children = undefined,
|
|
10
|
+
class: className = '',
|
|
11
|
+
style: styleAttr = '',
|
|
12
|
+
's-class': sClass,
|
|
13
|
+
's-style': sStyle,
|
|
14
|
+
activator = undefined,
|
|
15
|
+
indicator = undefined,
|
|
16
|
+
text = undefined,
|
|
17
|
+
dark = false,
|
|
18
|
+
light = false,
|
|
19
|
+
rounded = undefined,
|
|
20
|
+
color = undefined,
|
|
21
|
+
background = undefined,
|
|
22
|
+
index,
|
|
23
|
+
open = false,
|
|
24
|
+
toggle = undefined,
|
|
25
|
+
disabled = false,
|
|
26
|
+
readOnly = false,
|
|
27
|
+
...rest
|
|
28
|
+
}: AccordionItemProps = $props();
|
|
29
|
+
|
|
30
|
+
let { classProps, styleProps, restProps } = $derived(
|
|
31
|
+
makeComponentProps(rest as Record<string, unknown>)
|
|
32
|
+
);
|
|
33
|
+
|
|
34
|
+
let componentClass = $derived(
|
|
35
|
+
useClassName({
|
|
36
|
+
baseClass: 'kit-accordion-item',
|
|
37
|
+
className: `${className ?? ''}`.trim(),
|
|
38
|
+
sClass,
|
|
39
|
+
classProps
|
|
40
|
+
})
|
|
41
|
+
);
|
|
42
|
+
|
|
43
|
+
let componentStyle = $derived(
|
|
44
|
+
useStyles({
|
|
45
|
+
styleAttr,
|
|
46
|
+
sStyle,
|
|
47
|
+
styleProps
|
|
48
|
+
})
|
|
49
|
+
);
|
|
50
|
+
|
|
51
|
+
let mergedStyle = $derived(
|
|
52
|
+
[
|
|
53
|
+
componentStyle,
|
|
54
|
+
color ? `--kit-accordion-item-color:${color}` : '',
|
|
55
|
+
background ? `--kit-accordion-item-background:${background}` : ''
|
|
56
|
+
]
|
|
57
|
+
.filter(Boolean)
|
|
58
|
+
.join('; ')
|
|
59
|
+
);
|
|
60
|
+
|
|
61
|
+
let safeOpen = $derived(!!open);
|
|
62
|
+
let model: AccordionItemModelProps = {
|
|
63
|
+
get open() {
|
|
64
|
+
return safeOpen;
|
|
65
|
+
}
|
|
66
|
+
};
|
|
67
|
+
|
|
68
|
+
function handleToggle() {
|
|
69
|
+
if (readOnly || disabled || !toggle) return;
|
|
70
|
+
toggle(index);
|
|
71
|
+
}
|
|
72
|
+
</script>
|
|
73
|
+
|
|
74
|
+
<svelte:element
|
|
75
|
+
this={is}
|
|
76
|
+
bind:this={ref}
|
|
77
|
+
class={componentClass}
|
|
78
|
+
style={mergedStyle}
|
|
79
|
+
{...restProps}
|
|
80
|
+
data-open={safeOpen}
|
|
81
|
+
data-disabled={disabled}
|
|
82
|
+
data-dark={dark}
|
|
83
|
+
data-light={light}
|
|
84
|
+
data-rounded={rounded}
|
|
85
|
+
>
|
|
86
|
+
<button
|
|
87
|
+
class="kit-accordion-item__trigger"
|
|
88
|
+
type="button"
|
|
89
|
+
onclick={handleToggle}
|
|
90
|
+
aria-expanded={safeOpen}
|
|
91
|
+
aria-disabled={disabled || readOnly || undefined}
|
|
92
|
+
{disabled}
|
|
93
|
+
>
|
|
94
|
+
<span class="kit-accordion-item__title">
|
|
95
|
+
{#if activator}
|
|
96
|
+
{@render activator?.()}
|
|
97
|
+
{:else}
|
|
98
|
+
{text}
|
|
99
|
+
{/if}
|
|
100
|
+
</span>
|
|
101
|
+
|
|
102
|
+
<span class="kit-accordion-item__indicator">
|
|
103
|
+
{#if indicator}
|
|
104
|
+
{@render indicator?.(model)}
|
|
105
|
+
{:else}
|
|
106
|
+
<svg viewBox="0 0 24 24" aria-hidden="true">
|
|
107
|
+
{#if safeOpen}
|
|
108
|
+
<path d="M7.41 14.59 12 10l4.59 4.59L18 13.17l-6-6-6 6z" fill="currentColor"></path>
|
|
109
|
+
{:else}
|
|
110
|
+
<path d="M7.41 8.59 12 13.17l4.59-4.58L18 10l-6 6-6-6z" fill="currentColor"></path>
|
|
111
|
+
{/if}
|
|
112
|
+
</svg>
|
|
113
|
+
{/if}
|
|
114
|
+
</span>
|
|
115
|
+
</button>
|
|
116
|
+
|
|
117
|
+
<div class="kit-accordion-item__content" hidden={!safeOpen}>
|
|
118
|
+
<div class="kit-accordion-item__content-inner">
|
|
119
|
+
{@render children?.()}
|
|
120
|
+
</div>
|
|
121
|
+
</div>
|
|
122
|
+
</svelte:element>
|
|
123
|
+
|
|
124
|
+
<style>
|
|
125
|
+
button {
|
|
126
|
+
appearance: none;
|
|
127
|
+
background: none;
|
|
128
|
+
border: none;
|
|
129
|
+
font: inherit;
|
|
130
|
+
color: inherit;
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
.kit-accordion-item {
|
|
134
|
+
--kit-accordion-item-radius: var(--kit-accordion-radius, 8px);
|
|
135
|
+
--kit-accordion-item-color: var(--kit-accordion-color, var(--kit-fg));
|
|
136
|
+
--kit-accordion-item-background: var(--kit-surface-2);
|
|
137
|
+
--kit-accordion-item-border: color-mix(
|
|
138
|
+
in oklab,
|
|
139
|
+
var(--kit-accordion-item-background),
|
|
140
|
+
var(--kit-fg) 12%
|
|
141
|
+
);
|
|
142
|
+
--kit-accordion-item-trigger-y: 1rem;
|
|
143
|
+
--kit-accordion-item-trigger-x: 1.25rem;
|
|
144
|
+
|
|
145
|
+
flex: 1 0 100%;
|
|
146
|
+
max-width: 100%;
|
|
147
|
+
position: relative;
|
|
148
|
+
border-radius: var(--kit-accordion-item-radius);
|
|
149
|
+
background: var(--kit-accordion-item-background);
|
|
150
|
+
color: var(--kit-accordion-item-color);
|
|
151
|
+
border: 1px solid var(--kit-accordion-item-border);
|
|
152
|
+
transition:
|
|
153
|
+
border-color 150ms ease,
|
|
154
|
+
background 150ms ease,
|
|
155
|
+
box-shadow 150ms ease;
|
|
156
|
+
overflow: clip;
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
.kit-accordion-item[data-rounded='0'] {
|
|
160
|
+
--kit-accordion-item-radius: 0;
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
.kit-accordion-item[data-rounded='xs'] {
|
|
164
|
+
--kit-accordion-item-radius: 2px;
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
.kit-accordion-item[data-rounded='sm'] {
|
|
168
|
+
--kit-accordion-item-radius: 4px;
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
.kit-accordion-item[data-rounded='md'] {
|
|
172
|
+
--kit-accordion-item-radius: 8px;
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
.kit-accordion-item[data-rounded='lg'] {
|
|
176
|
+
--kit-accordion-item-radius: 16px;
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
.kit-accordion-item[data-rounded='xl'] {
|
|
180
|
+
--kit-accordion-item-radius: 99999px;
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
.kit-accordion-item[data-open='true'] {
|
|
184
|
+
box-shadow: 0 10px 28px color-mix(in oklab, var(--kit-fg), transparent 90%);
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
.kit-accordion-item[data-dark='true'] {
|
|
188
|
+
--kit-accordion-item-background: var(--kit-surface-3);
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
.kit-accordion-item[data-light='true'] {
|
|
192
|
+
--kit-accordion-item-background: var(--kit-surface-1);
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
.kit-accordion-item__trigger {
|
|
196
|
+
width: 100%;
|
|
197
|
+
display: flex;
|
|
198
|
+
align-items: center;
|
|
199
|
+
justify-content: space-between;
|
|
200
|
+
gap: 1rem;
|
|
201
|
+
padding: var(--kit-accordion-item-trigger-y) var(--kit-accordion-item-trigger-x);
|
|
202
|
+
cursor: pointer;
|
|
203
|
+
text-align: left;
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
.kit-accordion-item__trigger:disabled,
|
|
207
|
+
.kit-accordion-item[data-disabled='true'] .kit-accordion-item__trigger {
|
|
208
|
+
cursor: not-allowed;
|
|
209
|
+
opacity: 0.6;
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
.kit-accordion-item__title {
|
|
213
|
+
flex: 1 1 auto;
|
|
214
|
+
min-width: 0;
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
.kit-accordion-item__indicator {
|
|
218
|
+
display: inline-flex;
|
|
219
|
+
align-items: center;
|
|
220
|
+
justify-content: center;
|
|
221
|
+
flex: 0 0 auto;
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
.kit-accordion-item__indicator svg {
|
|
225
|
+
width: 1.125rem;
|
|
226
|
+
height: 1.125rem;
|
|
227
|
+
display: block;
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
.kit-accordion-item__content {
|
|
231
|
+
display: block;
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
.kit-accordion-item__content[hidden] {
|
|
235
|
+
display: none;
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
.kit-accordion-item__content-inner {
|
|
239
|
+
padding: 0 1.25rem 1rem;
|
|
240
|
+
}
|
|
241
|
+
</style>
|
|
@@ -0,0 +1,286 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import { useClassName, useStyles } from '../../utils/index.js';
|
|
3
|
+
import { makeComponentProps } from '../../compiler/mapped-code.js';
|
|
4
|
+
import type { AlertDensity, AlertProps, AlertTone, AlertVariant } from './alert.types.js';
|
|
5
|
+
|
|
6
|
+
function resolveVariant(value: AlertVariant | undefined): AlertVariant {
|
|
7
|
+
return value === 'filled' || value === 'outline' || value === 'text' ? value : 'filled';
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
function resolveDensity(value: AlertDensity | undefined): AlertDensity {
|
|
11
|
+
return value === 'compact' || value === 'comfortable' || value === 'default'
|
|
12
|
+
? value
|
|
13
|
+
: 'default';
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
function resolveTone({
|
|
17
|
+
tone,
|
|
18
|
+
info,
|
|
19
|
+
success,
|
|
20
|
+
warning,
|
|
21
|
+
error
|
|
22
|
+
}: {
|
|
23
|
+
tone?: AlertTone;
|
|
24
|
+
info?: boolean;
|
|
25
|
+
success?: boolean;
|
|
26
|
+
warning?: boolean;
|
|
27
|
+
error?: boolean;
|
|
28
|
+
}): AlertTone {
|
|
29
|
+
if (tone && ['default', 'info', 'success', 'warning', 'error'].includes(tone)) return tone;
|
|
30
|
+
if (error) return 'error';
|
|
31
|
+
if (warning) return 'warning';
|
|
32
|
+
if (success) return 'success';
|
|
33
|
+
if (info) return 'info';
|
|
34
|
+
return 'default';
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
let {
|
|
38
|
+
ref = $bindable(),
|
|
39
|
+
is = 'div',
|
|
40
|
+
children = undefined,
|
|
41
|
+
class: className = '',
|
|
42
|
+
style: styleAttr = '',
|
|
43
|
+
's-class': sClass,
|
|
44
|
+
's-style': sStyle,
|
|
45
|
+
open = $bindable(true),
|
|
46
|
+
closable = false,
|
|
47
|
+
variant = 'filled',
|
|
48
|
+
density = 'default',
|
|
49
|
+
rounded = 'md',
|
|
50
|
+
tone = 'default',
|
|
51
|
+
info = false,
|
|
52
|
+
success = false,
|
|
53
|
+
warning = false,
|
|
54
|
+
error = false,
|
|
55
|
+
color = undefined,
|
|
56
|
+
background = undefined,
|
|
57
|
+
prepend = undefined,
|
|
58
|
+
append = undefined,
|
|
59
|
+
close = undefined,
|
|
60
|
+
...rest
|
|
61
|
+
}: AlertProps = $props();
|
|
62
|
+
|
|
63
|
+
let { classProps, styleProps, restProps } = $derived(
|
|
64
|
+
makeComponentProps(rest as Record<string, unknown>)
|
|
65
|
+
);
|
|
66
|
+
|
|
67
|
+
let componentClass = $derived(
|
|
68
|
+
useClassName({
|
|
69
|
+
baseClass: 'kit-alert',
|
|
70
|
+
className: `${className ?? ''}`.trim(),
|
|
71
|
+
sClass,
|
|
72
|
+
classProps
|
|
73
|
+
})
|
|
74
|
+
);
|
|
75
|
+
|
|
76
|
+
let baseStyle = $derived(
|
|
77
|
+
useStyles({
|
|
78
|
+
styleAttr,
|
|
79
|
+
sStyle,
|
|
80
|
+
styleProps
|
|
81
|
+
})
|
|
82
|
+
);
|
|
83
|
+
|
|
84
|
+
let safeVariant = $derived(resolveVariant(variant));
|
|
85
|
+
let safeDensity = $derived(resolveDensity(density));
|
|
86
|
+
let safeTone = $derived(resolveTone({ tone, info, success, warning, error }));
|
|
87
|
+
let mergedStyle = $derived(
|
|
88
|
+
[
|
|
89
|
+
baseStyle,
|
|
90
|
+
color ? `--kit-alert-fg:${color}` : '',
|
|
91
|
+
background ? `--kit-alert-bg:${background}` : ''
|
|
92
|
+
]
|
|
93
|
+
.filter(Boolean)
|
|
94
|
+
.join('; ')
|
|
95
|
+
);
|
|
96
|
+
</script>
|
|
97
|
+
|
|
98
|
+
{#if !closable || (closable && open)}
|
|
99
|
+
<svelte:element
|
|
100
|
+
this={is}
|
|
101
|
+
bind:this={ref}
|
|
102
|
+
class={componentClass}
|
|
103
|
+
style={mergedStyle}
|
|
104
|
+
role="alert"
|
|
105
|
+
data-variant={safeVariant}
|
|
106
|
+
data-density={safeDensity}
|
|
107
|
+
data-rounded={rounded}
|
|
108
|
+
data-tone={safeTone}
|
|
109
|
+
{...restProps}
|
|
110
|
+
>
|
|
111
|
+
{#if safeVariant === 'outline'}
|
|
112
|
+
<span class="outline"></span>
|
|
113
|
+
{/if}
|
|
114
|
+
|
|
115
|
+
{#if prepend}
|
|
116
|
+
<span class="kit-alert__prepend">
|
|
117
|
+
{@render prepend?.()}
|
|
118
|
+
</span>
|
|
119
|
+
{/if}
|
|
120
|
+
|
|
121
|
+
<div class="kit-alert__content">
|
|
122
|
+
{@render children?.()}
|
|
123
|
+
</div>
|
|
124
|
+
|
|
125
|
+
{#if append}
|
|
126
|
+
<span class="kit-alert__append">
|
|
127
|
+
{@render append?.()}
|
|
128
|
+
</span>
|
|
129
|
+
{/if}
|
|
130
|
+
|
|
131
|
+
{#if closable}
|
|
132
|
+
<button
|
|
133
|
+
class="kit-alert__close"
|
|
134
|
+
type="button"
|
|
135
|
+
aria-label="close"
|
|
136
|
+
onclick={() => (open = false)}
|
|
137
|
+
>
|
|
138
|
+
{#if close}
|
|
139
|
+
{@render close?.()}
|
|
140
|
+
{:else}
|
|
141
|
+
<span aria-hidden="true">×</span>
|
|
142
|
+
{/if}
|
|
143
|
+
</button>
|
|
144
|
+
{/if}
|
|
145
|
+
</svelte:element>
|
|
146
|
+
{/if}
|
|
147
|
+
|
|
148
|
+
<style>
|
|
149
|
+
.kit-alert {
|
|
150
|
+
--kit-alert-bg: hsl(220 20% 96%);
|
|
151
|
+
--kit-alert-fg: hsl(222 20% 16%);
|
|
152
|
+
--kit-alert-bd: hsl(220 16% 85%);
|
|
153
|
+
--kit-alert-radius: 8px;
|
|
154
|
+
--kit-alert-py: 0.75rem;
|
|
155
|
+
--kit-alert-px: 0.875rem;
|
|
156
|
+
--kit-alert-gap: 0.625rem;
|
|
157
|
+
--outline-color: var(--kit-alert-bd);
|
|
158
|
+
--btn-radius: var(--kit-alert-radius);
|
|
159
|
+
|
|
160
|
+
position: relative;
|
|
161
|
+
display: grid;
|
|
162
|
+
grid-template-columns: auto minmax(0, 1fr) auto auto;
|
|
163
|
+
gap: var(--kit-alert-gap);
|
|
164
|
+
align-items: start;
|
|
165
|
+
padding: var(--kit-alert-py) var(--kit-alert-px);
|
|
166
|
+
border-radius: var(--kit-alert-radius);
|
|
167
|
+
color: var(--kit-alert-fg);
|
|
168
|
+
background: var(--kit-alert-bg);
|
|
169
|
+
border: 1px solid var(--kit-alert-bd);
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
.kit-alert[data-variant='filled'] {
|
|
173
|
+
background: var(--kit-alert-bg);
|
|
174
|
+
color: var(--kit-alert-fg);
|
|
175
|
+
border-color: var(--kit-alert-bd);
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
.kit-alert[data-variant='outline'] {
|
|
179
|
+
background: transparent;
|
|
180
|
+
color: var(--kit-alert-fg);
|
|
181
|
+
border-color: transparent;
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
.kit-alert[data-variant='text'] {
|
|
185
|
+
background: transparent;
|
|
186
|
+
color: var(--kit-alert-fg);
|
|
187
|
+
border-color: transparent;
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
.kit-alert .outline {
|
|
191
|
+
pointer-events: none;
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
.kit-alert[data-tone='info'] {
|
|
195
|
+
--kit-alert-bg: hsl(var(--kit-h-info, 205) 90% 95%);
|
|
196
|
+
--kit-alert-fg: hsl(var(--kit-h-info, 205) 36% 24%);
|
|
197
|
+
--kit-alert-bd: hsl(var(--kit-h-info, 205) 45% 78%);
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
.kit-alert[data-tone='success'] {
|
|
201
|
+
--kit-alert-bg: hsl(var(--kit-h-success, 145) 58% 93%);
|
|
202
|
+
--kit-alert-fg: hsl(var(--kit-h-success, 145) 38% 23%);
|
|
203
|
+
--kit-alert-bd: hsl(var(--kit-h-success, 145) 30% 75%);
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
.kit-alert[data-tone='warning'] {
|
|
207
|
+
--kit-alert-bg: hsl(var(--kit-h-warning, 35) 95% 92%);
|
|
208
|
+
--kit-alert-fg: hsl(var(--kit-h-warning, 35) 55% 24%);
|
|
209
|
+
--kit-alert-bd: hsl(var(--kit-h-warning, 35) 55% 72%);
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
.kit-alert[data-tone='error'] {
|
|
213
|
+
--kit-alert-bg: hsl(var(--kit-h-danger, 5) 90% 94%);
|
|
214
|
+
--kit-alert-fg: hsl(var(--kit-h-danger, 5) 48% 28%);
|
|
215
|
+
--kit-alert-bd: hsl(var(--kit-h-danger, 5) 55% 78%);
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
.kit-alert[data-density='compact'] {
|
|
219
|
+
--kit-alert-py: 0.5rem;
|
|
220
|
+
--kit-alert-px: 0.75rem;
|
|
221
|
+
--kit-alert-gap: 0.5rem;
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
.kit-alert[data-density='default'] {
|
|
225
|
+
--kit-alert-py: 0.75rem;
|
|
226
|
+
--kit-alert-px: 0.875rem;
|
|
227
|
+
--kit-alert-gap: 0.625rem;
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
.kit-alert[data-density='comfortable'] {
|
|
231
|
+
--kit-alert-py: 0.95rem;
|
|
232
|
+
--kit-alert-px: 1rem;
|
|
233
|
+
--kit-alert-gap: 0.75rem;
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
.kit-alert[data-rounded='0'] {
|
|
237
|
+
--kit-alert-radius: 0;
|
|
238
|
+
}
|
|
239
|
+
.kit-alert[data-rounded='xs'] {
|
|
240
|
+
--kit-alert-radius: 2px;
|
|
241
|
+
}
|
|
242
|
+
.kit-alert[data-rounded='sm'] {
|
|
243
|
+
--kit-alert-radius: 4px;
|
|
244
|
+
}
|
|
245
|
+
.kit-alert[data-rounded='md'] {
|
|
246
|
+
--kit-alert-radius: 8px;
|
|
247
|
+
}
|
|
248
|
+
.kit-alert[data-rounded='lg'] {
|
|
249
|
+
--kit-alert-radius: 16px;
|
|
250
|
+
}
|
|
251
|
+
.kit-alert[data-rounded='xl'] {
|
|
252
|
+
--kit-alert-radius: 99999px;
|
|
253
|
+
}
|
|
254
|
+
|
|
255
|
+
.kit-alert__prepend,
|
|
256
|
+
.kit-alert__append {
|
|
257
|
+
display: inline-flex;
|
|
258
|
+
align-items: center;
|
|
259
|
+
justify-content: center;
|
|
260
|
+
line-height: 1;
|
|
261
|
+
}
|
|
262
|
+
|
|
263
|
+
.kit-alert__content {
|
|
264
|
+
min-width: 0;
|
|
265
|
+
line-height: 1.4;
|
|
266
|
+
}
|
|
267
|
+
|
|
268
|
+
.kit-alert__close {
|
|
269
|
+
appearance: none;
|
|
270
|
+
border: 0;
|
|
271
|
+
background: transparent;
|
|
272
|
+
color: inherit;
|
|
273
|
+
padding: 0;
|
|
274
|
+
width: 1.25rem;
|
|
275
|
+
height: 1.25rem;
|
|
276
|
+
display: inline-flex;
|
|
277
|
+
align-items: center;
|
|
278
|
+
justify-content: center;
|
|
279
|
+
cursor: pointer;
|
|
280
|
+
border-radius: 6px;
|
|
281
|
+
}
|
|
282
|
+
|
|
283
|
+
.kit-alert__close:hover {
|
|
284
|
+
background: color-mix(in oklab, currentColor 10%, transparent);
|
|
285
|
+
}
|
|
286
|
+
</style>
|