lapikit 0.6.3 → 0.6.4
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/accordion/accordion.svelte +172 -42
- package/dist/components/accordion/accordion.types.d.ts +8 -3
- package/dist/components/accordion/modules/accordion-item.svelte +71 -72
- package/dist/components/alert/alert.svelte +201 -118
- package/dist/components/alert/alert.types.d.ts +8 -6
- package/dist/components/app/app.svelte +4 -4
- package/dist/components/appbar/appbar.svelte +115 -64
- package/dist/components/appbar/appbar.types.d.ts +4 -4
- package/dist/components/aspect-ratio/aspect-ratio.svelte +4 -12
- package/dist/components/aspect-ratio/aspect-ratio.types.d.ts +2 -1
- package/dist/components/avatar/avatar.svelte +108 -66
- package/dist/components/avatar/avatar.types.d.ts +7 -5
- package/dist/components/btn/btn.svelte +167 -169
- package/dist/components/btn/btn.types.d.ts +5 -2
- package/dist/components/chip/chip.svelte +162 -140
- package/dist/components/chip/chip.types.d.ts +7 -3
- package/dist/components/dialog/dialog.svelte +84 -81
- package/dist/components/dialog/dialog.types.d.ts +7 -5
- package/dist/components/dropdown/dropdown.svelte +46 -36
- package/dist/components/dropdown/dropdown.types.d.ts +4 -2
- package/dist/components/icon/icon.svelte +28 -52
- package/dist/components/list/modules/list-item.svelte +0 -55
- package/dist/components/modal/modal.svelte +104 -98
- package/dist/components/modal/modal.types.d.ts +7 -5
- package/dist/components/popover/popover.svelte +46 -34
- package/dist/components/popover/popover.types.d.ts +3 -1
- package/dist/components/separator/separator.svelte +11 -30
- package/dist/components/separator/separator.types.d.ts +1 -2
- package/dist/components/textfield/textfield.svelte +180 -157
- package/dist/components/textfield/textfield.types.d.ts +4 -3
- package/dist/components/toolbar/toolbar.svelte +126 -108
- package/dist/components/toolbar/toolbar.types.d.ts +6 -7
- package/dist/components/tooltip/tooltip.svelte +39 -45
- package/dist/components/tooltip/tooltip.types.d.ts +3 -3
- package/package.json +1 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
<script lang="ts">
|
|
2
|
-
import { useClassName, useStyles } from '../../utils';
|
|
2
|
+
import { useClassName, useElevation, useStyles } from '../../utils';
|
|
3
3
|
import { makeComponentProps } from '../../html-mapped';
|
|
4
4
|
import { ripple } from '../../animations';
|
|
5
5
|
import type { ChipProps } from './chip.types.js';
|
|
@@ -14,9 +14,10 @@
|
|
|
14
14
|
's-style': sStyle,
|
|
15
15
|
variant = 'filled',
|
|
16
16
|
density = 'default',
|
|
17
|
+
rounded = 'full',
|
|
17
18
|
loading,
|
|
18
19
|
active = false,
|
|
19
|
-
size = '
|
|
20
|
+
size = 'md',
|
|
20
21
|
labelStyle = false,
|
|
21
22
|
disabled = false,
|
|
22
23
|
href,
|
|
@@ -30,31 +31,18 @@
|
|
|
30
31
|
append,
|
|
31
32
|
prepend,
|
|
32
33
|
readonly = false,
|
|
34
|
+
elevation,
|
|
35
|
+
background,
|
|
36
|
+
color,
|
|
33
37
|
...rest
|
|
34
38
|
}: ChipProps = $props();
|
|
35
39
|
|
|
36
|
-
let safeVariant = $derived(
|
|
37
|
-
variant === 'filled' || variant === 'outline' || variant === 'text' || variant === 'link'
|
|
38
|
-
? variant
|
|
39
|
-
: 'filled'
|
|
40
|
-
);
|
|
41
|
-
let safeSize = $derived(
|
|
42
|
-
size === 'default'
|
|
43
|
-
? 'md'
|
|
44
|
-
: size === 'xs' || size === 'sm' || size === 'md' || size === 'lg' || size === 'xl'
|
|
45
|
-
? size
|
|
46
|
-
: 'md'
|
|
47
|
-
);
|
|
48
|
-
let safeDensity = $derived(
|
|
49
|
-
density === 'compact' || density === 'comfortable' || density === 'default'
|
|
50
|
-
? density
|
|
51
|
-
: 'default'
|
|
52
|
-
);
|
|
53
|
-
|
|
54
40
|
let { classProps, styleProps, restProps } = $derived(
|
|
55
41
|
makeComponentProps(rest as Record<string, unknown>)
|
|
56
42
|
);
|
|
57
43
|
|
|
44
|
+
let elevationState = $derived(useElevation(elevation));
|
|
45
|
+
|
|
58
46
|
let componentClass = $derived(
|
|
59
47
|
useClassName({
|
|
60
48
|
baseClass: 'kit-chip',
|
|
@@ -107,23 +95,29 @@
|
|
|
107
95
|
bind:this={ref}
|
|
108
96
|
class={componentClass}
|
|
109
97
|
style={componentStyle}
|
|
110
|
-
data-size={
|
|
111
|
-
data-variant={
|
|
98
|
+
data-size={size}
|
|
99
|
+
data-variant={variant}
|
|
100
|
+
data-rounded={rounded}
|
|
112
101
|
data-loading={loading}
|
|
113
102
|
data-active={active}
|
|
114
103
|
data-disabled={isDisabled}
|
|
115
104
|
data-readonly={isReadonly}
|
|
116
|
-
data-density={
|
|
105
|
+
data-density={density}
|
|
117
106
|
data-label-style={labelStyle}
|
|
118
107
|
data-interactive={isInteractive}
|
|
119
108
|
aria-busy={loading}
|
|
120
109
|
aria-disabled={isLocked || undefined}
|
|
110
|
+
data-elevation={elevationState.base}
|
|
111
|
+
data-elevation-hover={elevationState.hover}
|
|
112
|
+
data-elevation-active={elevationState.active}
|
|
121
113
|
use:ripple={{
|
|
122
114
|
component: 'chip',
|
|
123
115
|
disabled: noRipple || isLocked
|
|
124
116
|
}}
|
|
117
|
+
style:--kit-chip-fg={color && `var(--kit-color-${color})`}
|
|
118
|
+
style:--kit-chip-bg={background && `var(--kit-color-${background})`}
|
|
125
119
|
>
|
|
126
|
-
{#if
|
|
120
|
+
{#if variant === 'outline'}
|
|
127
121
|
<span class="outline"></span>
|
|
128
122
|
{/if}
|
|
129
123
|
<input
|
|
@@ -150,28 +144,34 @@
|
|
|
150
144
|
bind:this={ref}
|
|
151
145
|
class={componentClass}
|
|
152
146
|
style={componentStyle}
|
|
153
|
-
{...restProps}
|
|
154
147
|
type={resolvedType}
|
|
155
148
|
href={resolvedHref}
|
|
156
|
-
data-size={
|
|
157
|
-
data-variant={
|
|
149
|
+
data-size={size}
|
|
150
|
+
data-variant={variant}
|
|
151
|
+
data-rounded={rounded}
|
|
158
152
|
data-loading={loading}
|
|
159
153
|
data-active={active}
|
|
160
154
|
data-disabled={isDisabled}
|
|
161
155
|
data-readonly={isReadonly}
|
|
162
|
-
data-density={
|
|
156
|
+
data-density={density}
|
|
163
157
|
data-label-style={labelStyle}
|
|
164
158
|
data-interactive={isInteractive}
|
|
165
159
|
disabled={resolvedDisabled}
|
|
166
160
|
aria-busy={loading}
|
|
161
|
+
data-elevation={elevationState.base}
|
|
162
|
+
data-elevation-hover={elevationState.hover}
|
|
163
|
+
data-elevation-active={elevationState.active}
|
|
167
164
|
aria-disabled={((tag === 'a' || tag === 'div') && isLocked) || undefined}
|
|
168
165
|
tabindex={tag === 'a' && isLocked ? -1 : undefined}
|
|
169
166
|
use:ripple={{
|
|
170
167
|
component: 'chip',
|
|
171
168
|
disabled: noRipple || !isInteractive
|
|
172
169
|
}}
|
|
170
|
+
style:--kit-chip-fg={color && `var(--kit-color-${color})`}
|
|
171
|
+
style:--kit-chip-bg={background && `var(--kit-color-${background})`}
|
|
172
|
+
{...restProps}
|
|
173
173
|
>
|
|
174
|
-
{#if
|
|
174
|
+
{#if variant === 'outline'}
|
|
175
175
|
<span class="outline"></span>
|
|
176
176
|
{/if}
|
|
177
177
|
|
|
@@ -227,26 +227,6 @@
|
|
|
227
227
|
}
|
|
228
228
|
|
|
229
229
|
.kit-chip {
|
|
230
|
-
--kit-chip-bg: var(--kit-surface-2);
|
|
231
|
-
--kit-chip-fg: var(--kit-fg);
|
|
232
|
-
--kit-chip-bd: var(--kit-border);
|
|
233
|
-
--kit-chip-hover-bg: color-mix(in oklab, var(--kit-chip-bg), var(--kit-chip-fg) 6%);
|
|
234
|
-
--kit-chip-active-bg: color-mix(in oklab, var(--kit-chip-bg), var(--kit-chip-fg) 10%);
|
|
235
|
-
--kit-chip-h-xs: 24px;
|
|
236
|
-
--kit-chip-h-sm: 28px;
|
|
237
|
-
--kit-chip-h-md: 32px;
|
|
238
|
-
--kit-chip-h-lg: 36px;
|
|
239
|
-
--kit-chip-h-xl: 40px;
|
|
240
|
-
--kit-chip-px-xs: 8px;
|
|
241
|
-
--kit-chip-px-sm: 10px;
|
|
242
|
-
--kit-chip-px-md: 12px;
|
|
243
|
-
--kit-chip-px-lg: 14px;
|
|
244
|
-
--kit-chip-px-xl: 16px;
|
|
245
|
-
--kit-chip-density-scale: 1;
|
|
246
|
-
--kit-chip-density-h-scale: 1;
|
|
247
|
-
--kit-chip-radius: 99999px;
|
|
248
|
-
--kit-chip-gap: 0.35em;
|
|
249
|
-
|
|
250
230
|
position: relative;
|
|
251
231
|
display: inline-flex;
|
|
252
232
|
box-sizing: border-box;
|
|
@@ -255,7 +235,7 @@
|
|
|
255
235
|
font-family: var(--kit-font);
|
|
256
236
|
background: var(--kit-chip-bg);
|
|
257
237
|
color: var(--kit-chip-fg);
|
|
258
|
-
height:
|
|
238
|
+
height: calc(var(--kit-chip-h) * var(--kit-chip-density-h-scale));
|
|
259
239
|
padding-inline: calc(var(--kit-chip-px) * var(--kit-chip-density-scale));
|
|
260
240
|
border-radius: var(--kit-chip-radius);
|
|
261
241
|
text-decoration: none;
|
|
@@ -313,96 +293,6 @@
|
|
|
313
293
|
cursor: pointer;
|
|
314
294
|
}
|
|
315
295
|
|
|
316
|
-
.kit-chip[data-variant='filled'] {
|
|
317
|
-
--kit-chip-bg: var(--kit-accent);
|
|
318
|
-
--kit-chip-fg: white;
|
|
319
|
-
--kit-chip-hover-bg: color-mix(in oklab, var(--kit-chip-bg), black 10%);
|
|
320
|
-
--kit-chip-active-bg: color-mix(in oklab, var(--kit-chip-bg), black 16%);
|
|
321
|
-
}
|
|
322
|
-
|
|
323
|
-
.kit-chip[data-variant='outline'] {
|
|
324
|
-
--outline-color: var(--kit-accent);
|
|
325
|
-
--kit-chip-bg: transparent;
|
|
326
|
-
--kit-chip-fg: var(--kit-accent);
|
|
327
|
-
--kit-chip-hover-bg: color-mix(in oklab, var(--kit-chip-fg), transparent 80%);
|
|
328
|
-
--kit-chip-active-bg: color-mix(in oklab, var(--kit-chip-fg), transparent 92%);
|
|
329
|
-
}
|
|
330
|
-
|
|
331
|
-
.kit-chip[data-variant='text'] {
|
|
332
|
-
--kit-chip-bg: transparent;
|
|
333
|
-
--kit-chip-fg: var(--kit-accent);
|
|
334
|
-
--kit-chip-hover-bg: color-mix(in oklab, var(--kit-chip-fg), transparent 80%);
|
|
335
|
-
--kit-chip-active-bg: color-mix(in oklab, var(--kit-chip-fg), transparent 92%);
|
|
336
|
-
}
|
|
337
|
-
|
|
338
|
-
.kit-chip[data-variant='link'] {
|
|
339
|
-
--kit-chip-bg: transparent;
|
|
340
|
-
--kit-chip-fg: var(--kit-accent);
|
|
341
|
-
--kit-chip-decoration: underline;
|
|
342
|
-
height: inherit;
|
|
343
|
-
padding: 0;
|
|
344
|
-
}
|
|
345
|
-
|
|
346
|
-
.kit-chip[data-size='xs'] {
|
|
347
|
-
--kit-chip-h: var(--kit-chip-h-xs);
|
|
348
|
-
--kit-chip-px: var(--kit-chip-px-xs);
|
|
349
|
-
font-size: 12px;
|
|
350
|
-
}
|
|
351
|
-
.kit-chip[data-size='xs'] :global(.kit-icon:not([data-size])) {
|
|
352
|
-
--kit-icon-current-size: var(--kit-icon-size-xs);
|
|
353
|
-
}
|
|
354
|
-
|
|
355
|
-
.kit-chip[data-size='sm'] {
|
|
356
|
-
--kit-chip-h: var(--kit-chip-h-sm);
|
|
357
|
-
--kit-chip-px: var(--kit-chip-px-sm);
|
|
358
|
-
font-size: 13px;
|
|
359
|
-
}
|
|
360
|
-
.kit-chip[data-size='sm'] :global(.kit-icon:not([data-size])) {
|
|
361
|
-
--kit-icon-current-size: var(--kit-icon-size-sm);
|
|
362
|
-
}
|
|
363
|
-
|
|
364
|
-
.kit-chip[data-size='md'] {
|
|
365
|
-
--kit-chip-h: var(--kit-chip-h-md);
|
|
366
|
-
--kit-chip-px: var(--kit-chip-px-md);
|
|
367
|
-
font-size: 14px;
|
|
368
|
-
}
|
|
369
|
-
.kit-chip[data-size='md'] :global(.kit-icon:not([data-size])) {
|
|
370
|
-
--kit-icon-current-size: var(--kit-icon-size-md);
|
|
371
|
-
}
|
|
372
|
-
|
|
373
|
-
.kit-chip[data-size='lg'] {
|
|
374
|
-
--kit-chip-h: var(--kit-chip-h-lg);
|
|
375
|
-
--kit-chip-px: var(--kit-chip-px-lg);
|
|
376
|
-
font-size: 15px;
|
|
377
|
-
}
|
|
378
|
-
.kit-chip[data-size='lg'] :global(.kit-icon:not([data-size])) {
|
|
379
|
-
--kit-icon-current-size: var(--kit-icon-size-lg);
|
|
380
|
-
}
|
|
381
|
-
|
|
382
|
-
.kit-chip[data-size='xl'] {
|
|
383
|
-
--kit-chip-h: var(--kit-chip-h-xl);
|
|
384
|
-
--kit-chip-px: var(--kit-chip-px-xl);
|
|
385
|
-
font-size: 16px;
|
|
386
|
-
}
|
|
387
|
-
.kit-chip[data-size='xl'] :global(.kit-icon:not([data-size])) {
|
|
388
|
-
--kit-icon-current-size: var(--kit-icon-size-xl);
|
|
389
|
-
}
|
|
390
|
-
|
|
391
|
-
.kit-chip[data-density='default'] {
|
|
392
|
-
--kit-chip-density-scale: 1;
|
|
393
|
-
--kit-chip-density-h-scale: 1;
|
|
394
|
-
}
|
|
395
|
-
|
|
396
|
-
.kit-chip[data-density='compact'] {
|
|
397
|
-
--kit-chip-density-scale: 0.92;
|
|
398
|
-
--kit-chip-density-h-scale: 0.9;
|
|
399
|
-
}
|
|
400
|
-
|
|
401
|
-
.kit-chip[data-density='comfortable'] {
|
|
402
|
-
--kit-chip-density-scale: 1.08;
|
|
403
|
-
--kit-chip-density-h-scale: 1.08;
|
|
404
|
-
}
|
|
405
|
-
|
|
406
296
|
.kit-chip[data-label-style='true'] {
|
|
407
297
|
font-weight: 600;
|
|
408
298
|
letter-spacing: 0.01em;
|
|
@@ -424,6 +314,7 @@
|
|
|
424
314
|
align-items: center;
|
|
425
315
|
justify-content: center;
|
|
426
316
|
line-height: 1;
|
|
317
|
+
font-weight: normal;
|
|
427
318
|
}
|
|
428
319
|
|
|
429
320
|
.kit-chip__content :global(.kit-icon),
|
|
@@ -489,4 +380,135 @@
|
|
|
489
380
|
.kit-chip[data-disabled='true'] > input {
|
|
490
381
|
cursor: default;
|
|
491
382
|
}
|
|
383
|
+
|
|
384
|
+
/**
|
|
385
|
+
* size
|
|
386
|
+
* @link nothing...
|
|
387
|
+
*/
|
|
388
|
+
.kit-chip[data-size='xs'] {
|
|
389
|
+
--kit-chip-h: 24px;
|
|
390
|
+
--kit-chip-px: 8px;
|
|
391
|
+
--kit-chip-gap: 4px;
|
|
392
|
+
--kit-chip-font: 0.75rem;
|
|
393
|
+
}
|
|
394
|
+
.kit-chip[data-size='xs'] :global(.kit-icon:not([data-size])) {
|
|
395
|
+
--kit-icon-current-size: var(--kit-icon-size-xs);
|
|
396
|
+
}
|
|
397
|
+
.kit-chip[data-size='sm'] {
|
|
398
|
+
--kit-chip-h: 28px;
|
|
399
|
+
--kit-chip-px: 10px;
|
|
400
|
+
--kit-chip-gap: 6px;
|
|
401
|
+
--kit-chip-font: 0.875rem;
|
|
402
|
+
}
|
|
403
|
+
.kit-chip[data-size='sm'] :global(.kit-icon:not([data-size])) {
|
|
404
|
+
--kit-icon-current-size: var(--kit-icon-size-sm);
|
|
405
|
+
}
|
|
406
|
+
|
|
407
|
+
.kit-chip[data-size='md'] {
|
|
408
|
+
--kit-chip-h: 32px;
|
|
409
|
+
--kit-chip-px: 12px;
|
|
410
|
+
--kit-chip-gap: 8px;
|
|
411
|
+
--kit-chip-font: 1rem;
|
|
412
|
+
}
|
|
413
|
+
.kit-chip[data-size='md'] :global(.kit-icon:not([data-size])) {
|
|
414
|
+
--kit-icon-current-size: var(--kit-icon-size-md);
|
|
415
|
+
}
|
|
416
|
+
|
|
417
|
+
.kit-chip[data-size='lg'] {
|
|
418
|
+
--kit-chip-h: 36px;
|
|
419
|
+
--kit-chip-px: 14px;
|
|
420
|
+
--kit-chip-gap: 10px;
|
|
421
|
+
--kit-chip-font: 1.125rem;
|
|
422
|
+
}
|
|
423
|
+
.kit-chip[data-size='lg'] :global(.kit-icon:not([data-size])) {
|
|
424
|
+
--kit-icon-current-size: var(--kit-icon-size-lg);
|
|
425
|
+
}
|
|
426
|
+
|
|
427
|
+
.kit-chip[data-size='xl'] {
|
|
428
|
+
--kit-chip-h: 40px;
|
|
429
|
+
--kit-chip-px: 16px;
|
|
430
|
+
--kit-chip-gap: 12px;
|
|
431
|
+
--kit-chip-font: 1.25rem;
|
|
432
|
+
}
|
|
433
|
+
.kit-chip[data-size='xl'] :global(.kit-icon:not([data-size])) {
|
|
434
|
+
--kit-icon-current-size: var(--kit-icon-size-xl);
|
|
435
|
+
}
|
|
436
|
+
|
|
437
|
+
/**
|
|
438
|
+
* density
|
|
439
|
+
* @link no links
|
|
440
|
+
*/
|
|
441
|
+
.kit-chip[data-density='none'] {
|
|
442
|
+
--kit-chip-density-scale: 0;
|
|
443
|
+
--kit-chip-density-h-scale: 0;
|
|
444
|
+
}
|
|
445
|
+
.kit-chip[data-density='compact'] {
|
|
446
|
+
--kit-chip-density-scale: 0.9;
|
|
447
|
+
--kit-chip-density-h-scale: 0.92;
|
|
448
|
+
}
|
|
449
|
+
.kit-chip[data-density='default'] {
|
|
450
|
+
--kit-chip-density-scale: 1;
|
|
451
|
+
--kit-chip-density-h-scale: 1;
|
|
452
|
+
}
|
|
453
|
+
.kit-chip[data-density='comfortable'] {
|
|
454
|
+
--kit-chip-density-scale: 1.1;
|
|
455
|
+
--kit-chip-density-h-scale: 1.15;
|
|
456
|
+
}
|
|
457
|
+
|
|
458
|
+
/**
|
|
459
|
+
* rounded
|
|
460
|
+
* @link ...
|
|
461
|
+
*/
|
|
462
|
+
.kit-chip[data-rounded='0'] {
|
|
463
|
+
--kit-chip-radius: var(--kit-shape-none);
|
|
464
|
+
}
|
|
465
|
+
.kit-chip[data-rounded='xs'] {
|
|
466
|
+
--kit-chip-radius: var(--kit-shape-xs);
|
|
467
|
+
}
|
|
468
|
+
.kit-chip[data-rounded='sm'] {
|
|
469
|
+
--kit-chip-radius: var(--kit-shape-sm);
|
|
470
|
+
}
|
|
471
|
+
.kit-chip[data-rounded='md'] {
|
|
472
|
+
--kit-chip-radius: var(--kit-shape-md);
|
|
473
|
+
}
|
|
474
|
+
.kit-chip[data-rounded='lg'] {
|
|
475
|
+
--kit-chip-radius: var(--kit-shape-lg);
|
|
476
|
+
}
|
|
477
|
+
.kit-chip[data-rounded='xl'] {
|
|
478
|
+
--kit-chip-radius: var(--kit-shape-xl);
|
|
479
|
+
}
|
|
480
|
+
.kit-chip[data-rounded='full'] {
|
|
481
|
+
--kit-chip-radius: var(--kit-shape-full);
|
|
482
|
+
}
|
|
483
|
+
|
|
484
|
+
/**
|
|
485
|
+
* variant
|
|
486
|
+
* @link no links...
|
|
487
|
+
*/
|
|
488
|
+
.kit-chip[data-variant='filled'] {
|
|
489
|
+
--kit-chip-bg: var(--kit-color-surface-2);
|
|
490
|
+
--kit-chip-fg: var(--kit-color-text);
|
|
491
|
+
|
|
492
|
+
--kit-chip-hover-bg: color-mix(in oklab, var(--kit-chip-bg), black 10%);
|
|
493
|
+
--kit-chip-active-bg: color-mix(in oklab, var(--kit-chip-bg), black 16%);
|
|
494
|
+
}
|
|
495
|
+
.kit-chip[data-variant='outline'] {
|
|
496
|
+
--kit-chip-bg: transparent;
|
|
497
|
+
--kit-chip-fg: var(--kit-color-text);
|
|
498
|
+
--kit-chip-bd: var(--kit-chip-fg);
|
|
499
|
+
|
|
500
|
+
--kit-chip-hover-bg: color-mix(in oklab, var(--kit-chip-fg), transparent 80%);
|
|
501
|
+
--kit-chip-active-bg: color-mix(in oklab, var(--kit-chip-fg), transparent 92%);
|
|
502
|
+
}
|
|
503
|
+
.kit-chip[data-variant='text'] {
|
|
504
|
+
--kit-chip-bg: transparent;
|
|
505
|
+
--kit-chip-fg: var(--kit-color-text);
|
|
506
|
+
|
|
507
|
+
--kit-chip-hover-bg: color-mix(in oklab, var(--kit-chip-fg), transparent 80%);
|
|
508
|
+
--kit-chip-active-bg: color-mix(in oklab, var(--kit-chip-fg), transparent 92%);
|
|
509
|
+
}
|
|
510
|
+
|
|
511
|
+
.kit-chip .outline {
|
|
512
|
+
--outline-color: var(--kit-chip-bd);
|
|
513
|
+
}
|
|
492
514
|
</style>
|
|
@@ -1,12 +1,13 @@
|
|
|
1
|
-
import type { Component, SizeType } from '../../@types';
|
|
1
|
+
import type { Component, DensityType, ElevationProps, RoundedType, SizeType } from '../../@types';
|
|
2
2
|
import type { Snippet } from 'svelte';
|
|
3
3
|
export interface ChipProps extends Component {
|
|
4
4
|
ref?: HTMLElement | null;
|
|
5
5
|
is?: 'div' | 'a' | 'input' | 'button';
|
|
6
6
|
input?: boolean;
|
|
7
7
|
href?: string;
|
|
8
|
-
variant?: 'outline' | 'text' | 'filled'
|
|
9
|
-
density?:
|
|
8
|
+
variant?: 'outline' | 'text' | 'filled';
|
|
9
|
+
density?: DensityType;
|
|
10
|
+
rounded?: RoundedType | 'full';
|
|
10
11
|
active?: boolean;
|
|
11
12
|
loading?: boolean;
|
|
12
13
|
disabled?: boolean;
|
|
@@ -21,4 +22,7 @@ export interface ChipProps extends Component {
|
|
|
21
22
|
load?: Snippet;
|
|
22
23
|
append?: Snippet;
|
|
23
24
|
prepend?: Snippet;
|
|
25
|
+
elevation?: ElevationProps;
|
|
26
|
+
background?: string;
|
|
27
|
+
color?: string;
|
|
24
28
|
}
|
|
@@ -1,23 +1,7 @@
|
|
|
1
1
|
<script lang="ts">
|
|
2
2
|
import { makeComponentProps } from '../../html-mapped';
|
|
3
|
-
import { useClassName, useStyles, disabledScroll } from '../../utils';
|
|
4
|
-
import type {
|
|
5
|
-
|
|
6
|
-
function resolveSize(value: DialogSize | undefined): DialogSize {
|
|
7
|
-
return value === 'xs' || value === 'sm' || value === 'md' || value === 'lg' || value === 'xl'
|
|
8
|
-
? value
|
|
9
|
-
: 'md';
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
function resolvePosition(value: DialogPosition | undefined): DialogPosition {
|
|
13
|
-
return value === 'top' || value === 'center' || value === 'bottom' ? value : 'center';
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
function resolveDensity(value: DialogDensity | undefined): DialogDensity {
|
|
17
|
-
return value === 'compact' || value === 'comfortable' || value === 'default'
|
|
18
|
-
? value
|
|
19
|
-
: 'default';
|
|
20
|
-
}
|
|
3
|
+
import { useClassName, useStyles, disabledScroll, useElevation } from '../../utils';
|
|
4
|
+
import type { DialogProps } from './dialog.types.js';
|
|
21
5
|
|
|
22
6
|
let {
|
|
23
7
|
ref = $bindable(),
|
|
@@ -33,8 +17,10 @@
|
|
|
33
17
|
density = 'default',
|
|
34
18
|
rounded = 'md',
|
|
35
19
|
classContent = '',
|
|
36
|
-
color
|
|
37
|
-
background
|
|
20
|
+
color,
|
|
21
|
+
background,
|
|
22
|
+
elevation = '2',
|
|
23
|
+
space,
|
|
38
24
|
...rest
|
|
39
25
|
}: DialogProps = $props();
|
|
40
26
|
|
|
@@ -42,6 +28,8 @@
|
|
|
42
28
|
makeComponentProps(rest as Record<string, unknown>)
|
|
43
29
|
);
|
|
44
30
|
|
|
31
|
+
let elevationState = $derived(useElevation(elevation));
|
|
32
|
+
|
|
45
33
|
let componentClass = $derived(
|
|
46
34
|
useClassName({
|
|
47
35
|
baseClass: 'kit-dialog',
|
|
@@ -65,18 +53,7 @@
|
|
|
65
53
|
: `${classContent ?? ''}`.trim()
|
|
66
54
|
);
|
|
67
55
|
|
|
68
|
-
let
|
|
69
|
-
let safePosition = $derived(resolvePosition(position));
|
|
70
|
-
let safeDensity = $derived(resolveDensity(density));
|
|
71
|
-
let mergedStyle = $derived(
|
|
72
|
-
[
|
|
73
|
-
componentStyle,
|
|
74
|
-
color ? `--kit-dialog-fg:${color}` : '',
|
|
75
|
-
background ? `--kit-dialog-bg:${background}` : ''
|
|
76
|
-
]
|
|
77
|
-
.filter(Boolean)
|
|
78
|
-
.join('; ')
|
|
79
|
-
);
|
|
56
|
+
let mergedStyle = $derived([componentStyle].filter(Boolean).join('; '));
|
|
80
57
|
|
|
81
58
|
$effect(() => {
|
|
82
59
|
if (!ref) return;
|
|
@@ -126,8 +103,8 @@
|
|
|
126
103
|
bind:this={ref}
|
|
127
104
|
class={componentClass}
|
|
128
105
|
style={mergedStyle}
|
|
129
|
-
data-size={
|
|
130
|
-
data-position={
|
|
106
|
+
data-size={size}
|
|
107
|
+
data-position={position}
|
|
131
108
|
data-persistent={persistent}
|
|
132
109
|
onclose={handleClose}
|
|
133
110
|
oncancel={handleCancel}
|
|
@@ -136,9 +113,15 @@
|
|
|
136
113
|
<div
|
|
137
114
|
{...restProps}
|
|
138
115
|
class={['kit-dialog__content', contentClass]}
|
|
139
|
-
data-density={
|
|
116
|
+
data-density={density}
|
|
140
117
|
data-rounded={rounded}
|
|
118
|
+
data-elevation={elevationState.base}
|
|
119
|
+
data-elevation-hover={elevationState.hover}
|
|
120
|
+
data-elevation-active={elevationState.active}
|
|
141
121
|
onclick={(event: MouseEvent) => event.stopPropagation()}
|
|
122
|
+
style:--kit-dialog-fg={color && `var(--kit-color-${color})`}
|
|
123
|
+
style:--kit-dialog-bg={background && `var(--kit-color-${background})`}
|
|
124
|
+
style:--kit-dialog-space={space}
|
|
142
125
|
>
|
|
143
126
|
{@render children?.()}
|
|
144
127
|
</div>
|
|
@@ -146,14 +129,6 @@
|
|
|
146
129
|
|
|
147
130
|
<style>
|
|
148
131
|
.kit-dialog {
|
|
149
|
-
--kit-dialog-bg: var(--kit-surface-1);
|
|
150
|
-
--kit-dialog-fg: var(--kit-fg);
|
|
151
|
-
--kit-dialog-bd: var(--kit-border);
|
|
152
|
-
--kit-dialog-radius: 12px;
|
|
153
|
-
--kit-dialog-px: 1rem;
|
|
154
|
-
--kit-dialog-py: 1rem;
|
|
155
|
-
--kit-dialog-max: min(32rem, calc(100vw - 2rem));
|
|
156
|
-
|
|
157
132
|
border: 0;
|
|
158
133
|
padding: 0;
|
|
159
134
|
margin: auto;
|
|
@@ -165,97 +140,125 @@
|
|
|
165
140
|
}
|
|
166
141
|
|
|
167
142
|
.kit-dialog::backdrop {
|
|
168
|
-
background:
|
|
143
|
+
background: color-mix(in oklab, var(--kit-color-shadow), transparent 70%);
|
|
169
144
|
backdrop-filter: blur(2px);
|
|
170
145
|
}
|
|
171
146
|
|
|
172
|
-
|
|
173
|
-
|
|
147
|
+
/**
|
|
148
|
+
* position
|
|
149
|
+
* @link nothing...
|
|
150
|
+
*/
|
|
151
|
+
.kit-dialog[data-position='top'],
|
|
152
|
+
.kit-dialog[data-position='top-left'],
|
|
153
|
+
.kit-dialog[data-position='top-right'] {
|
|
154
|
+
margin-top: var(--kit-dialog-space, 1rem);
|
|
174
155
|
margin-bottom: auto;
|
|
175
156
|
}
|
|
176
|
-
|
|
177
|
-
.kit-dialog[data-position='center']
|
|
157
|
+
.kit-dialog[data-position='center'],
|
|
158
|
+
.kit-dialog[data-position='center-left'],
|
|
159
|
+
.kit-dialog[data-position='center-right'] {
|
|
178
160
|
margin-top: auto;
|
|
179
161
|
margin-bottom: auto;
|
|
180
162
|
}
|
|
181
|
-
|
|
182
|
-
.kit-dialog[data-position='bottom']
|
|
163
|
+
.kit-dialog[data-position='bottom'],
|
|
164
|
+
.kit-dialog[data-position='bottom-left'],
|
|
165
|
+
.kit-dialog[data-position='bottom-right'] {
|
|
183
166
|
margin-top: auto;
|
|
184
|
-
margin-bottom: 1rem;
|
|
167
|
+
margin-bottom: var(--kit-dialog-space, 1rem);
|
|
168
|
+
}
|
|
169
|
+
.kit-dialog[data-position='top-left'] .kit-dialog__content,
|
|
170
|
+
.kit-dialog[data-position='center-left'] .kit-dialog__content,
|
|
171
|
+
.kit-dialog[data-position='bottom-left'] .kit-dialog__content {
|
|
172
|
+
margin-left: var(--kit-dialog-space, 1rem);
|
|
173
|
+
}
|
|
174
|
+
.kit-dialog[data-position='top-right'] .kit-dialog__content,
|
|
175
|
+
.kit-dialog[data-position='center-right'] .kit-dialog__content,
|
|
176
|
+
.kit-dialog[data-position='bottom-right'] .kit-dialog__content {
|
|
177
|
+
margin-right: var(--kit-dialog-space, 1rem);
|
|
185
178
|
}
|
|
186
179
|
|
|
180
|
+
/**
|
|
181
|
+
* size
|
|
182
|
+
* @link nothing...
|
|
183
|
+
*/
|
|
187
184
|
.kit-dialog[data-size='xs'] {
|
|
188
|
-
--kit-dialog-max:
|
|
185
|
+
--kit-dialog-max: 20rem;
|
|
186
|
+
--kit-dialog-px: 10px;
|
|
189
187
|
}
|
|
190
188
|
|
|
191
189
|
.kit-dialog[data-size='sm'] {
|
|
192
|
-
--kit-dialog-max:
|
|
190
|
+
--kit-dialog-max: 24rem;
|
|
191
|
+
--kit-dialog-px: 12px;
|
|
193
192
|
}
|
|
194
193
|
|
|
195
194
|
.kit-dialog[data-size='md'] {
|
|
196
|
-
--kit-dialog-max:
|
|
195
|
+
--kit-dialog-max: 32rem;
|
|
196
|
+
--kit-dialog-px: 16px;
|
|
197
197
|
}
|
|
198
198
|
|
|
199
199
|
.kit-dialog[data-size='lg'] {
|
|
200
|
-
--kit-dialog-max:
|
|
200
|
+
--kit-dialog-max: 42rem;
|
|
201
|
+
--kit-dialog-px: 20px;
|
|
201
202
|
}
|
|
202
203
|
|
|
203
204
|
.kit-dialog[data-size='xl'] {
|
|
204
|
-
--kit-dialog-max:
|
|
205
|
+
--kit-dialog-max: 56rem;
|
|
206
|
+
--kit-dialog-px: 24px;
|
|
205
207
|
}
|
|
206
208
|
|
|
207
209
|
.kit-dialog__content {
|
|
210
|
+
--kit-dialog-fg: var(--kit-color-text);
|
|
211
|
+
--kit-dialog-bg: var(--kit-color-surface-1);
|
|
212
|
+
|
|
208
213
|
box-sizing: border-box;
|
|
209
|
-
width: min(100%, var(--kit-dialog-max));
|
|
214
|
+
width: min(100%, min(var(--kit-dialog-max), calc(100vw - 2rem)));
|
|
210
215
|
max-height: calc(100dvh - 2rem);
|
|
211
216
|
overflow: auto;
|
|
212
|
-
padding: var(--kit-dialog-
|
|
213
|
-
border:
|
|
217
|
+
padding: calc(var(--kit-dialog-px) * var(--kit-dialog-density-scale));
|
|
218
|
+
border: 0;
|
|
214
219
|
border-radius: var(--kit-dialog-radius);
|
|
215
220
|
background: var(--kit-dialog-bg);
|
|
216
221
|
color: var(--kit-dialog-fg);
|
|
217
222
|
margin: 0 auto;
|
|
218
|
-
box-shadow:
|
|
219
|
-
0 20px 50px rgb(15 23 42 / 0.18),
|
|
220
|
-
0 4px 16px rgb(15 23 42 / 0.1);
|
|
221
223
|
}
|
|
222
224
|
|
|
225
|
+
/**
|
|
226
|
+
* density
|
|
227
|
+
* @link no links
|
|
228
|
+
*/
|
|
229
|
+
.kit-dialog__content[data-density='none'] {
|
|
230
|
+
--kit-dialog-density-scale: 0;
|
|
231
|
+
}
|
|
223
232
|
.kit-dialog__content[data-density='compact'] {
|
|
224
|
-
--kit-dialog-
|
|
225
|
-
--kit-dialog-py: 0.75rem;
|
|
233
|
+
--kit-dialog-density-scale: 0.9;
|
|
226
234
|
}
|
|
227
|
-
|
|
228
235
|
.kit-dialog__content[data-density='default'] {
|
|
229
|
-
--kit-dialog-
|
|
230
|
-
--kit-dialog-py: 1rem;
|
|
236
|
+
--kit-dialog-density-scale: 1;
|
|
231
237
|
}
|
|
232
|
-
|
|
233
238
|
.kit-dialog__content[data-density='comfortable'] {
|
|
234
|
-
--kit-dialog-
|
|
235
|
-
--kit-dialog-py: 1.25rem;
|
|
239
|
+
--kit-dialog-density-scale: 1.1;
|
|
236
240
|
}
|
|
237
241
|
|
|
242
|
+
/**
|
|
243
|
+
* rounded
|
|
244
|
+
* @link ...
|
|
245
|
+
*/
|
|
238
246
|
.kit-dialog__content[data-rounded='0'] {
|
|
239
|
-
--kit-dialog-radius:
|
|
247
|
+
--kit-dialog-radius: var(--kit-shape-none);
|
|
240
248
|
}
|
|
241
|
-
|
|
242
249
|
.kit-dialog__content[data-rounded='xs'] {
|
|
243
|
-
--kit-dialog-radius:
|
|
250
|
+
--kit-dialog-radius: var(--kit-shape-xs);
|
|
244
251
|
}
|
|
245
|
-
|
|
246
252
|
.kit-dialog__content[data-rounded='sm'] {
|
|
247
|
-
--kit-dialog-radius:
|
|
253
|
+
--kit-dialog-radius: var(--kit-shape-sm);
|
|
248
254
|
}
|
|
249
|
-
|
|
250
255
|
.kit-dialog__content[data-rounded='md'] {
|
|
251
|
-
--kit-dialog-radius:
|
|
256
|
+
--kit-dialog-radius: var(--kit-shape-md);
|
|
252
257
|
}
|
|
253
|
-
|
|
254
258
|
.kit-dialog__content[data-rounded='lg'] {
|
|
255
|
-
--kit-dialog-radius:
|
|
259
|
+
--kit-dialog-radius: var(--kit-shape-lg);
|
|
256
260
|
}
|
|
257
|
-
|
|
258
261
|
.kit-dialog__content[data-rounded='xl'] {
|
|
259
|
-
--kit-dialog-radius:
|
|
262
|
+
--kit-dialog-radius: var(--kit-shape-xl);
|
|
260
263
|
}
|
|
261
264
|
</style>
|