kanto-ds 1.0.0
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/LICENSE +26 -0
- package/README.md +155 -0
- package/dist/assets/fonts/README.md +19 -0
- package/dist/assets/fonts/manrope/OFL.txt +93 -0
- package/dist/assets/fonts/manrope/manrope-cyrillic-ext-wght-normal.woff2 +0 -0
- package/dist/assets/fonts/manrope/manrope-cyrillic-wght-normal.woff2 +0 -0
- package/dist/assets/fonts/manrope/manrope-latin-ext-wght-normal.woff2 +0 -0
- package/dist/assets/fonts/manrope/manrope-latin-wght-normal.woff2 +0 -0
- package/dist/assets/fonts/mulish/OFL.txt +93 -0
- package/dist/assets/fonts/mulish/mulish-cyrillic-ext-wght-italic.woff2 +0 -0
- package/dist/assets/fonts/mulish/mulish-cyrillic-ext-wght-normal.woff2 +0 -0
- package/dist/assets/fonts/mulish/mulish-cyrillic-wght-italic.woff2 +0 -0
- package/dist/assets/fonts/mulish/mulish-cyrillic-wght-normal.woff2 +0 -0
- package/dist/assets/fonts/mulish/mulish-latin-ext-wght-italic.woff2 +0 -0
- package/dist/assets/fonts/mulish/mulish-latin-ext-wght-normal.woff2 +0 -0
- package/dist/assets/fonts/mulish/mulish-latin-wght-italic.woff2 +0 -0
- package/dist/assets/fonts/mulish/mulish-latin-wght-normal.woff2 +0 -0
- package/dist/assets/fonts/source_code_pro/OFL.txt +93 -0
- package/dist/assets/fonts/source_code_pro/SourceCodePro-Regular.woff2 +0 -0
- package/dist/chunks/dialog-CPIfFIlF.js +29 -0
- package/dist/chunks/dialog-CPIfFIlF.js.map +1 -0
- package/dist/chunks/events-Bjl5Zmmq.js +18 -0
- package/dist/chunks/events-Bjl5Zmmq.js.map +1 -0
- package/dist/chunks/form-control-CxjBTt1c.js +17 -0
- package/dist/chunks/form-control-CxjBTt1c.js.map +1 -0
- package/dist/chunks/kt-element-CcMLO5e8.js +28 -0
- package/dist/chunks/kt-element-CcMLO5e8.js.map +1 -0
- package/dist/chunks/listbox-CUXYn_3S.js +101 -0
- package/dist/chunks/listbox-CUXYn_3S.js.map +1 -0
- package/dist/chunks/registry-X4LS9J5K.js +30 -0
- package/dist/chunks/registry-X4LS9J5K.js.map +1 -0
- package/dist/chunks/slots-BPbIdxAJ.js +7 -0
- package/dist/chunks/slots-BPbIdxAJ.js.map +1 -0
- package/dist/chunks/toaster-PmdKSV5x.js +40 -0
- package/dist/chunks/toaster-PmdKSV5x.js.map +1 -0
- package/dist/components/core/kt-avatar/kt-avatar.d.ts +49 -0
- package/dist/components/core/kt-avatar/kt-avatar.js +156 -0
- package/dist/components/core/kt-avatar/kt-avatar.js.map +1 -0
- package/dist/components/core/kt-badge/kt-badge.d.ts +77 -0
- package/dist/components/core/kt-badge/kt-badge.js +254 -0
- package/dist/components/core/kt-badge/kt-badge.js.map +1 -0
- package/dist/components/core/kt-button/kt-button.d.ts +71 -0
- package/dist/components/core/kt-button/kt-button.js +271 -0
- package/dist/components/core/kt-button/kt-button.js.map +1 -0
- package/dist/components/core/kt-card/kt-card.d.ts +62 -0
- package/dist/components/core/kt-card/kt-card.js +230 -0
- package/dist/components/core/kt-card/kt-card.js.map +1 -0
- package/dist/components/core/kt-code/kt-code.d.ts +55 -0
- package/dist/components/core/kt-code/kt-code.js +155 -0
- package/dist/components/core/kt-code/kt-code.js.map +1 -0
- package/dist/components/core/kt-icon/kt-icon.d.ts +44 -0
- package/dist/components/core/kt-icon/kt-icon.js +85 -0
- package/dist/components/core/kt-icon/kt-icon.js.map +1 -0
- package/dist/components/core/kt-kbd/kt-kbd.d.ts +38 -0
- package/dist/components/core/kt-kbd/kt-kbd.js +89 -0
- package/dist/components/core/kt-kbd/kt-kbd.js.map +1 -0
- package/dist/components/data/kt-chart/kt-chart.d.ts +99 -0
- package/dist/components/data/kt-chart/kt-chart.js +406 -0
- package/dist/components/data/kt-chart/kt-chart.js.map +1 -0
- package/dist/components/data/kt-meter/kt-meter.d.ts +63 -0
- package/dist/components/data/kt-meter/kt-meter.js +177 -0
- package/dist/components/data/kt-meter/kt-meter.js.map +1 -0
- package/dist/components/data/kt-pagination/kt-pagination.d.ts +35 -0
- package/dist/components/data/kt-pagination/kt-pagination.js +88 -0
- package/dist/components/data/kt-pagination/kt-pagination.js.map +1 -0
- package/dist/components/data/kt-stat/kt-stat.d.ts +60 -0
- package/dist/components/data/kt-stat/kt-stat.js +137 -0
- package/dist/components/data/kt-stat/kt-stat.js.map +1 -0
- package/dist/components/data/kt-table/kt-table.d.ts +99 -0
- package/dist/components/data/kt-table/kt-table.js +340 -0
- package/dist/components/data/kt-table/kt-table.js.map +1 -0
- package/dist/components/data/kt-timeline/kt-timeline.d.ts +78 -0
- package/dist/components/data/kt-timeline/kt-timeline.js +252 -0
- package/dist/components/data/kt-timeline/kt-timeline.js.map +1 -0
- package/dist/components/feedback/kt-alert/kt-alert.d.ts +46 -0
- package/dist/components/feedback/kt-alert/kt-alert.js +180 -0
- package/dist/components/feedback/kt-alert/kt-alert.js.map +1 -0
- package/dist/components/feedback/kt-empty-state/kt-empty-state.d.ts +40 -0
- package/dist/components/feedback/kt-empty-state/kt-empty-state.js +100 -0
- package/dist/components/feedback/kt-empty-state/kt-empty-state.js.map +1 -0
- package/dist/components/feedback/kt-progress-bar/kt-progress-bar.d.ts +53 -0
- package/dist/components/feedback/kt-progress-bar/kt-progress-bar.js +212 -0
- package/dist/components/feedback/kt-progress-bar/kt-progress-bar.js.map +1 -0
- package/dist/components/feedback/kt-skeleton/kt-skeleton.d.ts +43 -0
- package/dist/components/feedback/kt-skeleton/kt-skeleton.js +117 -0
- package/dist/components/feedback/kt-skeleton/kt-skeleton.js.map +1 -0
- package/dist/components/feedback/kt-toast/kt-toast.d.ts +57 -0
- package/dist/components/feedback/kt-toast/kt-toast.js +231 -0
- package/dist/components/feedback/kt-toast/kt-toast.js.map +1 -0
- package/dist/components/feedback/kt-toast-container/kt-toast-container.d.ts +60 -0
- package/dist/components/feedback/kt-toast-container/kt-toast-container.js +100 -0
- package/dist/components/feedback/kt-toast-container/kt-toast-container.js.map +1 -0
- package/dist/components/feedback/kt-toast-container/toaster.d.ts +37 -0
- package/dist/components/feedback/kt-tooltip/kt-tooltip.d.ts +57 -0
- package/dist/components/feedback/kt-tooltip/kt-tooltip.js +138 -0
- package/dist/components/feedback/kt-tooltip/kt-tooltip.js.map +1 -0
- package/dist/components/forms/kt-drag-drop/kt-drag-drop.d.ts +68 -0
- package/dist/components/forms/kt-drag-drop/kt-drag-drop.js +287 -0
- package/dist/components/forms/kt-drag-drop/kt-drag-drop.js.map +1 -0
- package/dist/components/forms/kt-form/kt-form.d.ts +75 -0
- package/dist/components/forms/kt-form/kt-form.js +187 -0
- package/dist/components/forms/kt-form/kt-form.js.map +1 -0
- package/dist/components/forms/kt-input/kt-input.d.ts +112 -0
- package/dist/components/forms/kt-input/kt-input.js +556 -0
- package/dist/components/forms/kt-input/kt-input.js.map +1 -0
- package/dist/components/forms/kt-input-menu/kt-input-menu.d.ts +60 -0
- package/dist/components/forms/kt-input-menu/kt-input-menu.js +313 -0
- package/dist/components/forms/kt-input-menu/kt-input-menu.js.map +1 -0
- package/dist/components/forms/kt-label-input/kt-label-input.d.ts +42 -0
- package/dist/components/forms/kt-label-input/kt-label-input.js +69 -0
- package/dist/components/forms/kt-label-input/kt-label-input.js.map +1 -0
- package/dist/components/forms/kt-select/kt-select.d.ts +80 -0
- package/dist/components/forms/kt-select/kt-select.js +334 -0
- package/dist/components/forms/kt-select/kt-select.js.map +1 -0
- package/dist/components/forms/kt-textarea/kt-textarea.d.ts +62 -0
- package/dist/components/forms/kt-textarea/kt-textarea.js +239 -0
- package/dist/components/forms/kt-textarea/kt-textarea.js.map +1 -0
- package/dist/components/forms/kt-toggle/kt-toggle.d.ts +53 -0
- package/dist/components/forms/kt-toggle/kt-toggle.js +170 -0
- package/dist/components/forms/kt-toggle/kt-toggle.js.map +1 -0
- package/dist/components/navigation/kt-breadcrumb/kt-breadcrumb.d.ts +45 -0
- package/dist/components/navigation/kt-breadcrumb/kt-breadcrumb.js +93 -0
- package/dist/components/navigation/kt-breadcrumb/kt-breadcrumb.js.map +1 -0
- package/dist/components/navigation/kt-header/kt-header.d.ts +67 -0
- package/dist/components/navigation/kt-header/kt-header.js +195 -0
- package/dist/components/navigation/kt-header/kt-header.js.map +1 -0
- package/dist/components/navigation/kt-page-header/kt-page-header.d.ts +48 -0
- package/dist/components/navigation/kt-page-header/kt-page-header.js +111 -0
- package/dist/components/navigation/kt-page-header/kt-page-header.js.map +1 -0
- package/dist/components/navigation/kt-segmented-control/kt-segmented-control.d.ts +63 -0
- package/dist/components/navigation/kt-segmented-control/kt-segmented-control.js +228 -0
- package/dist/components/navigation/kt-segmented-control/kt-segmented-control.js.map +1 -0
- package/dist/components/navigation/kt-sub-menu-navigation/kt-sub-menu-navigation.d.ts +94 -0
- package/dist/components/navigation/kt-sub-menu-navigation/kt-sub-menu-navigation.js +265 -0
- package/dist/components/navigation/kt-sub-menu-navigation/kt-sub-menu-navigation.js.map +1 -0
- package/dist/components/navigation/kt-tabs/kt-tabs.d.ts +64 -0
- package/dist/components/navigation/kt-tabs/kt-tabs.js +175 -0
- package/dist/components/navigation/kt-tabs/kt-tabs.js.map +1 -0
- package/dist/components/navigation/kt-toggle-button/kt-toggle-button.d.ts +50 -0
- package/dist/components/navigation/kt-toggle-button/kt-toggle-button.js +191 -0
- package/dist/components/navigation/kt-toggle-button/kt-toggle-button.js.map +1 -0
- package/dist/components/navigation/kt-toggle-button-group/kt-toggle-button-group.d.ts +55 -0
- package/dist/components/navigation/kt-toggle-button-group/kt-toggle-button-group.js +128 -0
- package/dist/components/navigation/kt-toggle-button-group/kt-toggle-button-group.js.map +1 -0
- package/dist/components/overlays/kt-collapsible/kt-collapsible.d.ts +42 -0
- package/dist/components/overlays/kt-collapsible/kt-collapsible.js +107 -0
- package/dist/components/overlays/kt-collapsible/kt-collapsible.js.map +1 -0
- package/dist/components/overlays/kt-confirm-dialog/kt-confirm-dialog.d.ts +56 -0
- package/dist/components/overlays/kt-confirm-dialog/kt-confirm-dialog.js +155 -0
- package/dist/components/overlays/kt-confirm-dialog/kt-confirm-dialog.js.map +1 -0
- package/dist/components/overlays/kt-dropdown/kt-dropdown.d.ts +64 -0
- package/dist/components/overlays/kt-dropdown/kt-dropdown.js +212 -0
- package/dist/components/overlays/kt-dropdown/kt-dropdown.js.map +1 -0
- package/dist/components/overlays/kt-modal/kt-modal.d.ts +61 -0
- package/dist/components/overlays/kt-modal/kt-modal.js +207 -0
- package/dist/components/overlays/kt-modal/kt-modal.js.map +1 -0
- package/dist/components/overlays/kt-side-panel/kt-side-panel.d.ts +52 -0
- package/dist/components/overlays/kt-side-panel/kt-side-panel.js +178 -0
- package/dist/components/overlays/kt-side-panel/kt-side-panel.js.map +1 -0
- package/dist/icons/defaults.d.ts +25 -0
- package/dist/icons/index.d.ts +3 -0
- package/dist/icons/index.js +37 -0
- package/dist/icons/index.js.map +1 -0
- package/dist/icons/registry.d.ts +38 -0
- package/dist/index.d.ts +81 -0
- package/dist/index.js +96 -0
- package/dist/index.js.map +1 -0
- package/dist/internal/countries.d.ts +37 -0
- package/dist/internal/dialog.d.ts +22 -0
- package/dist/internal/events.d.ts +14 -0
- package/dist/internal/form-control.d.ts +27 -0
- package/dist/internal/format.d.ts +8 -0
- package/dist/internal/kt-element.d.ts +22 -0
- package/dist/internal/listbox.d.ts +36 -0
- package/dist/internal/slots.d.ts +10 -0
- package/dist/react/index.d.ts +208 -0
- package/dist/react/index.js +314 -0
- package/dist/react/index.js.map +1 -0
- package/dist/styles.css +13 -0
- package/dist/tokens/README.md +63 -0
- package/dist/tokens/base.css +79 -0
- package/dist/tokens/colors.css +125 -0
- package/dist/tokens/fonts.css +136 -0
- package/dist/tokens/index.css +12 -0
- package/dist/tokens/responsive.css +108 -0
- package/dist/tokens/spacing.css +66 -0
- package/dist/tokens/theme-light.css +144 -0
- package/dist/tokens/typography.css +41 -0
- package/dist/vue/index.d.ts +143 -0
- package/dist/vue/index.js +56 -0
- package/dist/vue/index.js.map +1 -0
- package/package.json +296 -0
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { type TemplateResult } from 'lit';
|
|
2
|
+
import { KtElement } from '#internal/kt-element';
|
|
3
|
+
export type KtProgressVariant = 'primary' | 'info' | 'success' | 'warning' | 'danger' | 'neutral';
|
|
4
|
+
export type KtProgressSize = 'small' | 'medium' | 'large';
|
|
5
|
+
/**
|
|
6
|
+
* A determinate progress bar.
|
|
7
|
+
*
|
|
8
|
+
* Reaching `max` switches the fill to the success colour, so "done" reads at a
|
|
9
|
+
* glance without the caller having to swap the variant.
|
|
10
|
+
*
|
|
11
|
+
* @element kt-progress-bar
|
|
12
|
+
*
|
|
13
|
+
* @csspart track - The groove.
|
|
14
|
+
* @csspart fill - The filled portion.
|
|
15
|
+
* @csspart base - The container.
|
|
16
|
+
* @csspart caption - The row above the bar.
|
|
17
|
+
* @csspart value - The percentage, when `show-value` is set.
|
|
18
|
+
*
|
|
19
|
+
* @example
|
|
20
|
+
* ```html
|
|
21
|
+
* <kt-progress-bar value="64" show-value></kt-progress-bar>
|
|
22
|
+
* <kt-progress-bar value="90" variant="warning" striped animated></kt-progress-bar>
|
|
23
|
+
* ```
|
|
24
|
+
*/
|
|
25
|
+
export declare class KtProgressBar extends KtElement {
|
|
26
|
+
static styles: import("lit").CSSResultGroup[];
|
|
27
|
+
value: number;
|
|
28
|
+
max: number;
|
|
29
|
+
size: KtProgressSize;
|
|
30
|
+
variant: KtProgressVariant;
|
|
31
|
+
/** Draws the percentage in a caption above the bar. */
|
|
32
|
+
showValue: boolean;
|
|
33
|
+
/**
|
|
34
|
+
* Shows `label` above the bar as visible text, beside the value.
|
|
35
|
+
*
|
|
36
|
+
* `label` alone is the accessible name and stays invisible, which is right
|
|
37
|
+
* when the surrounding copy already says what is progressing.
|
|
38
|
+
*/
|
|
39
|
+
showLabel: boolean;
|
|
40
|
+
striped: boolean;
|
|
41
|
+
/** Animates the stripes. Requires `striped`. */
|
|
42
|
+
animated: boolean;
|
|
43
|
+
/** Accessible name — what is progressing. */
|
|
44
|
+
label: string;
|
|
45
|
+
/** The value as a whole percentage, clamped to 0–100. */
|
|
46
|
+
get percent(): number;
|
|
47
|
+
render(): TemplateResult;
|
|
48
|
+
}
|
|
49
|
+
declare global {
|
|
50
|
+
interface HTMLElementTagNameMap {
|
|
51
|
+
'kt-progress-bar': KtProgressBar;
|
|
52
|
+
}
|
|
53
|
+
}
|
|
@@ -0,0 +1,212 @@
|
|
|
1
|
+
import { css as v, nothing as p, html as o } from "lit";
|
|
2
|
+
import { property as t } from "lit/decorators.js";
|
|
3
|
+
import { classMap as h } from "lit/directives/class-map.js";
|
|
4
|
+
import { styleMap as m } from "lit/directives/style-map.js";
|
|
5
|
+
import { K as u, d as b } from "../../../chunks/kt-element-CcMLO5e8.js";
|
|
6
|
+
var f = Object.defineProperty, r = (n, e, i, c) => {
|
|
7
|
+
for (var s = void 0, l = n.length - 1, d; l >= 0; l--)
|
|
8
|
+
(d = n[l]) && (s = d(e, i, s) || s);
|
|
9
|
+
return s && f(e, i, s), s;
|
|
10
|
+
};
|
|
11
|
+
class a extends u {
|
|
12
|
+
constructor() {
|
|
13
|
+
super(...arguments), this.value = 0, this.max = 100, this.size = "medium", this.variant = "primary", this.showValue = !1, this.showLabel = !1, this.striped = !1, this.animated = !1, this.label = "";
|
|
14
|
+
}
|
|
15
|
+
static {
|
|
16
|
+
this.styles = [
|
|
17
|
+
u.styles,
|
|
18
|
+
v`
|
|
19
|
+
:host {
|
|
20
|
+
display: block;
|
|
21
|
+
width: 100%;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
.bar {
|
|
25
|
+
display: flex;
|
|
26
|
+
flex-direction: column;
|
|
27
|
+
gap: 6px;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
/* The caption sits above the track, not inside it. A label centred over
|
|
31
|
+
an 8px bar is half on the fill and half off it, so it is unreadable at
|
|
32
|
+
one end of the range whatever colour it is given — and at size="small"
|
|
33
|
+
the track is 4px and clips it outright. Above the bar it reads in every
|
|
34
|
+
theme, at every size, at every value. */
|
|
35
|
+
.caption {
|
|
36
|
+
display: flex;
|
|
37
|
+
align-items: baseline;
|
|
38
|
+
justify-content: space-between;
|
|
39
|
+
gap: 12px;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
.caption-label {
|
|
43
|
+
overflow: hidden;
|
|
44
|
+
color: var(--text-body);
|
|
45
|
+
font: var(--font-normal-regular);
|
|
46
|
+
white-space: nowrap;
|
|
47
|
+
text-overflow: ellipsis;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
.caption-value {
|
|
51
|
+
flex: none;
|
|
52
|
+
color: var(--text-muted);
|
|
53
|
+
font: var(--font-normal-small);
|
|
54
|
+
font-variant-numeric: tabular-nums;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
.complete .caption-value {
|
|
58
|
+
color: var(--color-success-base);
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
.track {
|
|
62
|
+
position: relative;
|
|
63
|
+
height: 8px;
|
|
64
|
+
overflow: hidden;
|
|
65
|
+
background: var(--surface-raised);
|
|
66
|
+
border-radius: var(--border-radius);
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
:host([size='small']) .track {
|
|
70
|
+
height: 4px;
|
|
71
|
+
}
|
|
72
|
+
:host([size='large']) .track {
|
|
73
|
+
height: 12px;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
.fill {
|
|
77
|
+
width: 0;
|
|
78
|
+
height: 100%;
|
|
79
|
+
background: var(--color-primary-base);
|
|
80
|
+
transition: width 0.4s var(--easing-standard);
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
:host([variant='info']) .fill {
|
|
84
|
+
background: var(--color-info-base);
|
|
85
|
+
}
|
|
86
|
+
:host([variant='success']) .fill {
|
|
87
|
+
background: var(--color-success-base);
|
|
88
|
+
}
|
|
89
|
+
:host([variant='warning']) .fill {
|
|
90
|
+
background: var(--color-warning-base);
|
|
91
|
+
}
|
|
92
|
+
:host([variant='danger']) .fill {
|
|
93
|
+
background: var(--color-danger-base);
|
|
94
|
+
}
|
|
95
|
+
:host([variant='neutral']) .fill {
|
|
96
|
+
background: var(--color-text-500);
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
/* Completion reads as success whatever the variant was. */
|
|
100
|
+
.fill.complete {
|
|
101
|
+
background: var(--color-success-base);
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
/* The one decorative animation in Kanto, and it earns its place: a
|
|
105
|
+
striped bar is how an operation says it is still working. */
|
|
106
|
+
.fill.striped {
|
|
107
|
+
background-image: linear-gradient(
|
|
108
|
+
45deg,
|
|
109
|
+
rgba(255, 255, 255, 0.07) 25%,
|
|
110
|
+
transparent 25%,
|
|
111
|
+
transparent 50%,
|
|
112
|
+
rgba(255, 255, 255, 0.07) 50%,
|
|
113
|
+
rgba(255, 255, 255, 0.07) 75%,
|
|
114
|
+
transparent 75%,
|
|
115
|
+
transparent
|
|
116
|
+
);
|
|
117
|
+
background-size: 1rem 1rem;
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
.fill.striped.animated {
|
|
121
|
+
animation: kt-progress-stripes 1s linear infinite;
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
@keyframes kt-progress-stripes {
|
|
125
|
+
from {
|
|
126
|
+
background-position: 0 0;
|
|
127
|
+
}
|
|
128
|
+
to {
|
|
129
|
+
background-position: 1rem 0;
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
@media (prefers-reduced-motion: reduce) {
|
|
134
|
+
.fill {
|
|
135
|
+
transition: none;
|
|
136
|
+
}
|
|
137
|
+
.fill.striped.animated {
|
|
138
|
+
animation: none;
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
`
|
|
142
|
+
];
|
|
143
|
+
}
|
|
144
|
+
/** The value as a whole percentage, clamped to 0–100. */
|
|
145
|
+
get percent() {
|
|
146
|
+
const e = this.max > 0 ? this.max : 100, i = Math.min(Math.max(this.value, 0), e);
|
|
147
|
+
return Math.round(i / e * 100);
|
|
148
|
+
}
|
|
149
|
+
render() {
|
|
150
|
+
const e = this.percent, i = this.value >= (this.max > 0 ? this.max : 100), c = this.showLabel && this.label || this.showValue;
|
|
151
|
+
return o`<div part="base" class=${h({ bar: !0, complete: i })}>
|
|
152
|
+
${c ? o`<div part="caption" class="caption">
|
|
153
|
+
${this.showLabel && this.label ? o`<span class="caption-label">${this.label}</span>` : o`<span></span>`}
|
|
154
|
+
${this.showValue ? o`<span part="value" class="caption-value">${e}%</span>` : p}
|
|
155
|
+
</div>` : p}
|
|
156
|
+
|
|
157
|
+
<div
|
|
158
|
+
part="track"
|
|
159
|
+
class="track"
|
|
160
|
+
role="progressbar"
|
|
161
|
+
aria-valuemin="0"
|
|
162
|
+
aria-valuemax=${this.max}
|
|
163
|
+
aria-valuenow=${this.value}
|
|
164
|
+
aria-valuetext=${`${e}%`}
|
|
165
|
+
aria-label=${this.label || p}
|
|
166
|
+
>
|
|
167
|
+
<div
|
|
168
|
+
part="fill"
|
|
169
|
+
class=${h({
|
|
170
|
+
fill: !0,
|
|
171
|
+
complete: i,
|
|
172
|
+
striped: this.striped,
|
|
173
|
+
animated: this.animated
|
|
174
|
+
})}
|
|
175
|
+
style=${m({ width: `${e}%` })}
|
|
176
|
+
></div>
|
|
177
|
+
</div>
|
|
178
|
+
</div>`;
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
r([
|
|
182
|
+
t({ type: Number })
|
|
183
|
+
], a.prototype, "value");
|
|
184
|
+
r([
|
|
185
|
+
t({ type: Number })
|
|
186
|
+
], a.prototype, "max");
|
|
187
|
+
r([
|
|
188
|
+
t({ type: String, reflect: !0 })
|
|
189
|
+
], a.prototype, "size");
|
|
190
|
+
r([
|
|
191
|
+
t({ type: String, reflect: !0 })
|
|
192
|
+
], a.prototype, "variant");
|
|
193
|
+
r([
|
|
194
|
+
t({ type: Boolean, attribute: "show-value" })
|
|
195
|
+
], a.prototype, "showValue");
|
|
196
|
+
r([
|
|
197
|
+
t({ type: Boolean, attribute: "show-label" })
|
|
198
|
+
], a.prototype, "showLabel");
|
|
199
|
+
r([
|
|
200
|
+
t({ type: Boolean, reflect: !0 })
|
|
201
|
+
], a.prototype, "striped");
|
|
202
|
+
r([
|
|
203
|
+
t({ type: Boolean, reflect: !0 })
|
|
204
|
+
], a.prototype, "animated");
|
|
205
|
+
r([
|
|
206
|
+
t({ type: String })
|
|
207
|
+
], a.prototype, "label");
|
|
208
|
+
b("kt-progress-bar", a);
|
|
209
|
+
export {
|
|
210
|
+
a as KtProgressBar
|
|
211
|
+
};
|
|
212
|
+
//# sourceMappingURL=kt-progress-bar.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"kt-progress-bar.js","sources":["../../../../src/components/feedback/kt-progress-bar/kt-progress-bar.ts"],"sourcesContent":["import { css, html, nothing, type TemplateResult } from 'lit';\nimport { property } from 'lit/decorators.js';\nimport { classMap } from 'lit/directives/class-map.js';\nimport { styleMap } from 'lit/directives/style-map.js';\nimport { KtElement, defineElement } from '#internal/kt-element';\n\nexport type KtProgressVariant = 'primary' | 'info' | 'success' | 'warning' | 'danger' | 'neutral';\nexport type KtProgressSize = 'small' | 'medium' | 'large';\n\n/**\n * A determinate progress bar.\n *\n * Reaching `max` switches the fill to the success colour, so \"done\" reads at a\n * glance without the caller having to swap the variant.\n *\n * @element kt-progress-bar\n *\n * @csspart track - The groove.\n * @csspart fill - The filled portion.\n * @csspart base - The container.\n * @csspart caption - The row above the bar.\n * @csspart value - The percentage, when `show-value` is set.\n *\n * @example\n * ```html\n * <kt-progress-bar value=\"64\" show-value></kt-progress-bar>\n * <kt-progress-bar value=\"90\" variant=\"warning\" striped animated></kt-progress-bar>\n * ```\n */\nexport class KtProgressBar extends KtElement {\n static override styles = [\n KtElement.styles,\n css`\n :host {\n display: block;\n width: 100%;\n }\n\n .bar {\n display: flex;\n flex-direction: column;\n gap: 6px;\n }\n\n /* The caption sits above the track, not inside it. A label centred over\n an 8px bar is half on the fill and half off it, so it is unreadable at\n one end of the range whatever colour it is given — and at size=\"small\"\n the track is 4px and clips it outright. Above the bar it reads in every\n theme, at every size, at every value. */\n .caption {\n display: flex;\n align-items: baseline;\n justify-content: space-between;\n gap: 12px;\n }\n\n .caption-label {\n overflow: hidden;\n color: var(--text-body);\n font: var(--font-normal-regular);\n white-space: nowrap;\n text-overflow: ellipsis;\n }\n\n .caption-value {\n flex: none;\n color: var(--text-muted);\n font: var(--font-normal-small);\n font-variant-numeric: tabular-nums;\n }\n\n .complete .caption-value {\n color: var(--color-success-base);\n }\n\n .track {\n position: relative;\n height: 8px;\n overflow: hidden;\n background: var(--surface-raised);\n border-radius: var(--border-radius);\n }\n\n :host([size='small']) .track {\n height: 4px;\n }\n :host([size='large']) .track {\n height: 12px;\n }\n\n .fill {\n width: 0;\n height: 100%;\n background: var(--color-primary-base);\n transition: width 0.4s var(--easing-standard);\n }\n\n :host([variant='info']) .fill {\n background: var(--color-info-base);\n }\n :host([variant='success']) .fill {\n background: var(--color-success-base);\n }\n :host([variant='warning']) .fill {\n background: var(--color-warning-base);\n }\n :host([variant='danger']) .fill {\n background: var(--color-danger-base);\n }\n :host([variant='neutral']) .fill {\n background: var(--color-text-500);\n }\n\n /* Completion reads as success whatever the variant was. */\n .fill.complete {\n background: var(--color-success-base);\n }\n\n /* The one decorative animation in Kanto, and it earns its place: a\n striped bar is how an operation says it is still working. */\n .fill.striped {\n background-image: linear-gradient(\n 45deg,\n rgba(255, 255, 255, 0.07) 25%,\n transparent 25%,\n transparent 50%,\n rgba(255, 255, 255, 0.07) 50%,\n rgba(255, 255, 255, 0.07) 75%,\n transparent 75%,\n transparent\n );\n background-size: 1rem 1rem;\n }\n\n .fill.striped.animated {\n animation: kt-progress-stripes 1s linear infinite;\n }\n\n @keyframes kt-progress-stripes {\n from {\n background-position: 0 0;\n }\n to {\n background-position: 1rem 0;\n }\n }\n\n @media (prefers-reduced-motion: reduce) {\n .fill {\n transition: none;\n }\n .fill.striped.animated {\n animation: none;\n }\n }\n `,\n ];\n\n @property({ type: Number })\n value = 0;\n\n @property({ type: Number })\n max = 100;\n\n @property({ type: String, reflect: true })\n size: KtProgressSize = 'medium';\n\n @property({ type: String, reflect: true })\n variant: KtProgressVariant = 'primary';\n\n /** Draws the percentage in a caption above the bar. */\n @property({ type: Boolean, attribute: 'show-value' })\n showValue = false;\n\n /**\n * Shows `label` above the bar as visible text, beside the value.\n *\n * `label` alone is the accessible name and stays invisible, which is right\n * when the surrounding copy already says what is progressing.\n */\n @property({ type: Boolean, attribute: 'show-label' })\n showLabel = false;\n\n @property({ type: Boolean, reflect: true })\n striped = false;\n\n /** Animates the stripes. Requires `striped`. */\n @property({ type: Boolean, reflect: true })\n animated = false;\n\n /** Accessible name — what is progressing. */\n @property({ type: String })\n label = '';\n\n /** The value as a whole percentage, clamped to 0–100. */\n get percent(): number {\n const max = this.max > 0 ? this.max : 100;\n const clamped = Math.min(Math.max(this.value, 0), max);\n return Math.round((clamped / max) * 100);\n }\n\n override render(): TemplateResult {\n const percent = this.percent;\n const complete = this.value >= (this.max > 0 ? this.max : 100);\n\n const caption = (this.showLabel && this.label) || this.showValue;\n\n return html`<div part=\"base\" class=${classMap({ bar: true, complete })}>\n ${\n caption\n ? html`<div part=\"caption\" class=\"caption\">\n ${\n this.showLabel && this.label\n ? html`<span class=\"caption-label\">${this.label}</span>`\n : html`<span></span>`\n }\n ${\n this.showValue\n ? html`<span part=\"value\" class=\"caption-value\">${percent}%</span>`\n : nothing\n }\n </div>`\n : nothing\n }\n\n <div\n part=\"track\"\n class=\"track\"\n role=\"progressbar\"\n aria-valuemin=\"0\"\n aria-valuemax=${this.max}\n aria-valuenow=${this.value}\n aria-valuetext=${`${percent}%`}\n aria-label=${this.label || nothing}\n >\n <div\n part=\"fill\"\n class=${classMap({\n fill: true,\n complete,\n striped: this.striped,\n animated: this.animated,\n })}\n style=${styleMap({ width: `${percent}%` })}\n ></div>\n </div>\n </div>`;\n }\n}\n\ndefineElement('kt-progress-bar', KtProgressBar);\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'kt-progress-bar': KtProgressBar;\n }\n}\n"],"names":["KtProgressBar","KtElement","css","max","clamped","percent","complete","caption","html","classMap","nothing","styleMap","__decorateClass","property","defineElement"],"mappings":"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"}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { type TemplateResult } from 'lit';
|
|
2
|
+
import { KtElement } from '#internal/kt-element';
|
|
3
|
+
export type KtSkeletonVariant = 'text' | 'rect' | 'circle';
|
|
4
|
+
/**
|
|
5
|
+
* A loading placeholder, pulsing between two steps of the surface ramp.
|
|
6
|
+
*
|
|
7
|
+
* With `count` above one, the last line is drawn short — the shape a paragraph
|
|
8
|
+
* actually has, which is what makes a skeleton read as text rather than as
|
|
9
|
+
* stacked bars.
|
|
10
|
+
*
|
|
11
|
+
* The whole thing is `aria-hidden`: it is a picture of content that is not
|
|
12
|
+
* there yet. Announce loading state on the region that owns it, with
|
|
13
|
+
* `aria-busy`.
|
|
14
|
+
*
|
|
15
|
+
* @element kt-skeleton
|
|
16
|
+
*
|
|
17
|
+
* @csspart line - One placeholder line.
|
|
18
|
+
*
|
|
19
|
+
* @example
|
|
20
|
+
* ```html
|
|
21
|
+
* <kt-skeleton count="3"></kt-skeleton>
|
|
22
|
+
* <kt-skeleton variant="circle" width="48px" height="48px"></kt-skeleton>
|
|
23
|
+
* ```
|
|
24
|
+
*/
|
|
25
|
+
export declare class KtSkeleton extends KtElement {
|
|
26
|
+
static styles: import("lit").CSSResultGroup[];
|
|
27
|
+
variant: KtSkeletonVariant;
|
|
28
|
+
/** Any CSS length. Defaults to the full width, or 40px for a circle. */
|
|
29
|
+
width: string;
|
|
30
|
+
/** Any CSS length. Defaults to the variant's natural height. */
|
|
31
|
+
height: string;
|
|
32
|
+
/** How many lines to draw. Above one, the last is shortened. */
|
|
33
|
+
count: number;
|
|
34
|
+
animated: boolean;
|
|
35
|
+
private line;
|
|
36
|
+
render(): TemplateResult;
|
|
37
|
+
connectedCallback(): void;
|
|
38
|
+
}
|
|
39
|
+
declare global {
|
|
40
|
+
interface HTMLElementTagNameMap {
|
|
41
|
+
'kt-skeleton': KtSkeleton;
|
|
42
|
+
}
|
|
43
|
+
}
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
import { css as c, html as d } from "lit";
|
|
2
|
+
import { property as s } from "lit/decorators.js";
|
|
3
|
+
import { classMap as h } from "lit/directives/class-map.js";
|
|
4
|
+
import { styleMap as m } from "lit/directives/style-map.js";
|
|
5
|
+
import { K as u, d as f } from "../../../chunks/kt-element-CcMLO5e8.js";
|
|
6
|
+
var y = Object.defineProperty, a = (n, i, t, p) => {
|
|
7
|
+
for (var e = void 0, o = n.length - 1, l; o >= 0; o--)
|
|
8
|
+
(l = n[o]) && (e = l(i, t, e) || e);
|
|
9
|
+
return e && y(i, t, e), e;
|
|
10
|
+
};
|
|
11
|
+
const v = {
|
|
12
|
+
text: "14px",
|
|
13
|
+
rect: "80px",
|
|
14
|
+
circle: "40px"
|
|
15
|
+
};
|
|
16
|
+
class r extends u {
|
|
17
|
+
constructor() {
|
|
18
|
+
super(...arguments), this.variant = "text", this.width = "", this.height = "", this.count = 1, this.animated = !0;
|
|
19
|
+
}
|
|
20
|
+
static {
|
|
21
|
+
this.styles = [
|
|
22
|
+
u.styles,
|
|
23
|
+
c`
|
|
24
|
+
:host {
|
|
25
|
+
display: block;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
.group {
|
|
29
|
+
display: flex;
|
|
30
|
+
flex-direction: column;
|
|
31
|
+
gap: 10px;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
.line {
|
|
35
|
+
display: block;
|
|
36
|
+
background: var(--surface-raised);
|
|
37
|
+
border-radius: var(--border-radius);
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
.text {
|
|
41
|
+
border-radius: 4px;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
.circle {
|
|
45
|
+
border-radius: var(--radius-full);
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
.pulse {
|
|
49
|
+
animation: kt-skeleton-pulse 1.4s var(--easing-standard) infinite;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
@keyframes kt-skeleton-pulse {
|
|
53
|
+
0%,
|
|
54
|
+
100% {
|
|
55
|
+
background: var(--surface-raised);
|
|
56
|
+
}
|
|
57
|
+
50% {
|
|
58
|
+
background: var(--surface-hover);
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
@media (prefers-reduced-motion: reduce) {
|
|
63
|
+
.pulse {
|
|
64
|
+
animation: none;
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
`
|
|
68
|
+
];
|
|
69
|
+
}
|
|
70
|
+
line(i, t) {
|
|
71
|
+
const p = t && this.count > 1 && this.variant === "text";
|
|
72
|
+
return d`<span
|
|
73
|
+
part="line"
|
|
74
|
+
class=${h({
|
|
75
|
+
line: !0,
|
|
76
|
+
[this.variant]: !0,
|
|
77
|
+
pulse: this.animated
|
|
78
|
+
})}
|
|
79
|
+
style=${m({
|
|
80
|
+
width: p ? "60%" : this.width || (this.variant === "circle" ? "40px" : "100%"),
|
|
81
|
+
height: this.height || v[this.variant]
|
|
82
|
+
})}
|
|
83
|
+
data-index=${i}
|
|
84
|
+
></span>`;
|
|
85
|
+
}
|
|
86
|
+
render() {
|
|
87
|
+
return this.count <= 1 ? this.line(0, !1) : d`<span class="group">
|
|
88
|
+
${Array.from(
|
|
89
|
+
{ length: this.count },
|
|
90
|
+
(i, t) => this.line(t, t === this.count - 1)
|
|
91
|
+
)}
|
|
92
|
+
</span>`;
|
|
93
|
+
}
|
|
94
|
+
connectedCallback() {
|
|
95
|
+
super.connectedCallback(), this.setAttribute("aria-hidden", "true");
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
a([
|
|
99
|
+
s({ type: String, reflect: !0 })
|
|
100
|
+
], r.prototype, "variant");
|
|
101
|
+
a([
|
|
102
|
+
s({ type: String })
|
|
103
|
+
], r.prototype, "width");
|
|
104
|
+
a([
|
|
105
|
+
s({ type: String })
|
|
106
|
+
], r.prototype, "height");
|
|
107
|
+
a([
|
|
108
|
+
s({ type: Number })
|
|
109
|
+
], r.prototype, "count");
|
|
110
|
+
a([
|
|
111
|
+
s({ type: Boolean })
|
|
112
|
+
], r.prototype, "animated");
|
|
113
|
+
f("kt-skeleton", r);
|
|
114
|
+
export {
|
|
115
|
+
r as KtSkeleton
|
|
116
|
+
};
|
|
117
|
+
//# sourceMappingURL=kt-skeleton.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"kt-skeleton.js","sources":["../../../../src/components/feedback/kt-skeleton/kt-skeleton.ts"],"sourcesContent":["import { css, html, type TemplateResult } from 'lit';\nimport { property } from 'lit/decorators.js';\nimport { classMap } from 'lit/directives/class-map.js';\nimport { styleMap } from 'lit/directives/style-map.js';\nimport { KtElement, defineElement } from '#internal/kt-element';\n\nexport type KtSkeletonVariant = 'text' | 'rect' | 'circle';\n\n/** Default height per variant, when none is given. */\nconst HEIGHT: Record<KtSkeletonVariant, string> = {\n text: '14px',\n rect: '80px',\n circle: '40px',\n};\n\n/**\n * A loading placeholder, pulsing between two steps of the surface ramp.\n *\n * With `count` above one, the last line is drawn short — the shape a paragraph\n * actually has, which is what makes a skeleton read as text rather than as\n * stacked bars.\n *\n * The whole thing is `aria-hidden`: it is a picture of content that is not\n * there yet. Announce loading state on the region that owns it, with\n * `aria-busy`.\n *\n * @element kt-skeleton\n *\n * @csspart line - One placeholder line.\n *\n * @example\n * ```html\n * <kt-skeleton count=\"3\"></kt-skeleton>\n * <kt-skeleton variant=\"circle\" width=\"48px\" height=\"48px\"></kt-skeleton>\n * ```\n */\nexport class KtSkeleton extends KtElement {\n static override styles = [\n KtElement.styles,\n css`\n :host {\n display: block;\n }\n\n .group {\n display: flex;\n flex-direction: column;\n gap: 10px;\n }\n\n .line {\n display: block;\n background: var(--surface-raised);\n border-radius: var(--border-radius);\n }\n\n .text {\n border-radius: 4px;\n }\n\n .circle {\n border-radius: var(--radius-full);\n }\n\n .pulse {\n animation: kt-skeleton-pulse 1.4s var(--easing-standard) infinite;\n }\n\n @keyframes kt-skeleton-pulse {\n 0%,\n 100% {\n background: var(--surface-raised);\n }\n 50% {\n background: var(--surface-hover);\n }\n }\n\n @media (prefers-reduced-motion: reduce) {\n .pulse {\n animation: none;\n }\n }\n `,\n ];\n\n @property({ type: String, reflect: true })\n variant: KtSkeletonVariant = 'text';\n\n /** Any CSS length. Defaults to the full width, or 40px for a circle. */\n @property({ type: String })\n width = '';\n\n /** Any CSS length. Defaults to the variant's natural height. */\n @property({ type: String })\n height = '';\n\n /** How many lines to draw. Above one, the last is shortened. */\n @property({ type: Number })\n count = 1;\n\n @property({ type: Boolean })\n animated = true;\n\n private line(index: number, last: boolean): TemplateResult {\n const shortened = last && this.count > 1 && this.variant === 'text';\n\n return html`<span\n part=\"line\"\n class=${classMap({\n line: true,\n [this.variant]: true,\n pulse: this.animated,\n })}\n style=${styleMap({\n width: shortened ? '60%' : this.width || (this.variant === 'circle' ? '40px' : '100%'),\n height: this.height || HEIGHT[this.variant],\n })}\n data-index=${index}\n ></span>`;\n }\n\n override render(): TemplateResult {\n if (this.count <= 1) return this.line(0, false);\n\n return html`<span class=\"group\">\n ${Array.from({ length: this.count }, (_, index) =>\n this.line(index, index === this.count - 1),\n )}\n </span>`;\n }\n\n override connectedCallback(): void {\n super.connectedCallback();\n // A skeleton is a picture of absent content: there is nothing here to\n // announce, and reading out a dozen empty boxes is worse than silence.\n this.setAttribute('aria-hidden', 'true');\n }\n}\n\ndefineElement('kt-skeleton', KtSkeleton);\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'kt-skeleton': KtSkeleton;\n }\n}\n"],"names":["HEIGHT","KtSkeleton","KtElement","css","index","last","shortened","html","classMap","styleMap","_","__decorateClass","property","defineElement"],"mappings":";;;;;;;;;;AASA,MAAMA,IAA4C;AAAA,EAChD,MAAM;AAAA,EACN,MAAM;AAAA,EACN,QAAQ;AACV;AAuBO,MAAMC,UAAmBC,EAAU;AAAA,EAAnC,cAAA;AAAA,UAAA,GAAA,SAAA,GAmDL,KAAA,UAA6B,QAI7B,KAAA,QAAQ,IAIR,KAAA,SAAS,IAIT,KAAA,QAAQ,GAGR,KAAA,WAAW;AAAA,EAAA;AAAA,EAjEX,OAAA;AAAA,SAAgB,SAAS;AAAA,MACvBA,EAAU;AAAA,MACVC;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,IAAA;AAAA,EA6CF;AAAA,EAoBQ,KAAKC,GAAeC,GAA+B;AACzD,UAAMC,IAAYD,KAAQ,KAAK,QAAQ,KAAK,KAAK,YAAY;AAE7D,WAAOE;AAAA;AAAA,cAEGC,EAAS;AAAA,MACf,MAAM;AAAA,MACN,CAAC,KAAK,OAAO,GAAG;AAAA,MAChB,OAAO,KAAK;AAAA,IAAA,CACb,CAAC;AAAA,cACMC,EAAS;AAAA,MACf,OAAOH,IAAY,QAAQ,KAAK,UAAU,KAAK,YAAY,WAAW,SAAS;AAAA,MAC/E,QAAQ,KAAK,UAAUN,EAAO,KAAK,OAAO;AAAA,IAAA,CAC3C,CAAC;AAAA,mBACWI,CAAK;AAAA;AAAA,EAEtB;AAAA,EAES,SAAyB;AAChC,WAAI,KAAK,SAAS,IAAU,KAAK,KAAK,GAAG,EAAK,IAEvCG;AAAA,QACH,MAAM;AAAA,MAAK,EAAE,QAAQ,KAAK,MAAA;AAAA,MAAS,CAACG,GAAGN,MACvC,KAAK,KAAKA,GAAOA,MAAU,KAAK,QAAQ,CAAC;AAAA,IAAA,CAC1C;AAAA;AAAA,EAEL;AAAA,EAES,oBAA0B;AACjC,UAAM,kBAAA,GAGN,KAAK,aAAa,eAAe,MAAM;AAAA,EACzC;AACF;AAnDEO,EAAA;AAAA,EADCC,EAAS,EAAE,MAAM,QAAQ,SAAS,IAAM;AAAA,GAlD9BX,EAmDX,WAAA,SAAA;AAIAU,EAAA;AAAA,EADCC,EAAS,EAAE,MAAM,OAAA,CAAQ;AAAA,GAtDfX,EAuDX,WAAA,OAAA;AAIAU,EAAA;AAAA,EADCC,EAAS,EAAE,MAAM,OAAA,CAAQ;AAAA,GA1DfX,EA2DX,WAAA,QAAA;AAIAU,EAAA;AAAA,EADCC,EAAS,EAAE,MAAM,OAAA,CAAQ;AAAA,GA9DfX,EA+DX,WAAA,OAAA;AAGAU,EAAA;AAAA,EADCC,EAAS,EAAE,MAAM,QAAA,CAAS;AAAA,GAjEhBX,EAkEX,WAAA,UAAA;AAsCFY,EAAc,eAAeZ,CAAU;"}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { type TemplateResult } from 'lit';
|
|
2
|
+
import { KtElement } from '#internal/kt-element';
|
|
3
|
+
import '../../core/kt-icon/kt-icon.js';
|
|
4
|
+
import '../kt-progress-bar/kt-progress-bar.js';
|
|
5
|
+
export type KtToastVariant = 'success' | 'information' | 'warning' | 'error';
|
|
6
|
+
/**
|
|
7
|
+
* A transient notification.
|
|
8
|
+
*
|
|
9
|
+
* The only element in Kanto with a real shadow, and the only one that blurs
|
|
10
|
+
* what is behind it: a toast floats above the page, so it has to say so.
|
|
11
|
+
*
|
|
12
|
+
* @element kt-toast
|
|
13
|
+
*
|
|
14
|
+
* @csspart base - The toast surface.
|
|
15
|
+
* @csspart close - The dismiss button.
|
|
16
|
+
*
|
|
17
|
+
* @fires kt-toast-close - The toast asked to be removed, by timeout or by the
|
|
18
|
+
* dismiss button. `<kt-toast-container>` listens for this.
|
|
19
|
+
*/
|
|
20
|
+
export declare class KtToast extends KtElement {
|
|
21
|
+
static styles: import("lit").CSSResultGroup[];
|
|
22
|
+
private timer;
|
|
23
|
+
private remaining;
|
|
24
|
+
variant: KtToastVariant;
|
|
25
|
+
/**
|
|
26
|
+
* The toast's title.
|
|
27
|
+
*
|
|
28
|
+
* Named `heading` because every element already has a `title`, and shadowing
|
|
29
|
+
* it would turn the toast into its own tooltip.
|
|
30
|
+
*/
|
|
31
|
+
heading: string;
|
|
32
|
+
description: string;
|
|
33
|
+
dismissible: boolean;
|
|
34
|
+
/**
|
|
35
|
+
* Auto-dismiss after this many milliseconds, with a countdown bar. Zero
|
|
36
|
+
* keeps the toast until something removes it.
|
|
37
|
+
*/
|
|
38
|
+
duration: number;
|
|
39
|
+
connectedCallback(): void;
|
|
40
|
+
disconnectedCallback(): void;
|
|
41
|
+
private startCountdown;
|
|
42
|
+
/** Runs the countdown from whatever `remaining` currently is. */
|
|
43
|
+
private tick;
|
|
44
|
+
private stopCountdown;
|
|
45
|
+
/** Pauses the countdown. The container calls this while the pointer is over the stack. */
|
|
46
|
+
pause(): void;
|
|
47
|
+
/** Resumes a paused countdown from where it stopped. */
|
|
48
|
+
resume(): void;
|
|
49
|
+
/** Asks to be removed. The container is what actually removes it. */
|
|
50
|
+
close(): void;
|
|
51
|
+
render(): TemplateResult;
|
|
52
|
+
}
|
|
53
|
+
declare global {
|
|
54
|
+
interface HTMLElementTagNameMap {
|
|
55
|
+
'kt-toast': KtToast;
|
|
56
|
+
}
|
|
57
|
+
}
|