@latty-ds/web 0.2.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 +21 -0
- package/README.md +106 -0
- package/custom-elements.json +8785 -0
- package/dist/base/index.d.ts +1 -0
- package/dist/base/index.js +35 -0
- package/dist/base/themeable-element.d.ts +20 -0
- package/dist/components/accordion/accordion.d.ts +82 -0
- package/dist/components/accordion/accordion.styles.d.ts +1 -0
- package/dist/components/accordion/accordion.types.d.ts +10 -0
- package/dist/components/accordion/index.d.ts +8 -0
- package/dist/components/accordion/index.js +468 -0
- package/dist/components/alert/alert.d.ts +51 -0
- package/dist/components/alert/alert.styles.d.ts +1 -0
- package/dist/components/alert/alert.types.d.ts +2 -0
- package/dist/components/alert/index.d.ts +2 -0
- package/dist/components/alert/index.js +746 -0
- package/dist/components/avatar/avatar.d.ts +27 -0
- package/dist/components/avatar/avatar.styles.d.ts +1 -0
- package/dist/components/avatar/avatar.types.d.ts +3 -0
- package/dist/components/avatar/index.d.ts +2 -0
- package/dist/components/avatar/index.js +222 -0
- package/dist/components/badge/badge.d.ts +29 -0
- package/dist/components/badge/badge.styles.d.ts +1 -0
- package/dist/components/badge/badge.types.d.ts +3 -0
- package/dist/components/badge/index.d.ts +2 -0
- package/dist/components/badge/index.js +277 -0
- package/dist/components/breadcrumb/breadcrumb.d.ts +53 -0
- package/dist/components/breadcrumb/breadcrumb.styles.d.ts +2 -0
- package/dist/components/breadcrumb/breadcrumb.types.d.ts +1 -0
- package/dist/components/breadcrumb/index.d.ts +2 -0
- package/dist/components/breadcrumb/index.js +166 -0
- package/dist/components/button/button.d.ts +111 -0
- package/dist/components/button/button.styles.d.ts +1 -0
- package/dist/components/button/button.types.d.ts +38 -0
- package/dist/components/button/index.d.ts +8 -0
- package/dist/components/button/index.js +466 -0
- package/dist/components/calendar/calendar.d.ts +84 -0
- package/dist/components/calendar/calendar.styles.d.ts +1 -0
- package/dist/components/calendar/calendar.types.d.ts +15 -0
- package/dist/components/calendar/index.d.ts +1 -0
- package/dist/components/calendar/index.js +958 -0
- package/dist/components/checkbox/checkbox.d.ts +113 -0
- package/dist/components/checkbox/checkbox.styles.d.ts +1 -0
- package/dist/components/checkbox/checkbox.types.d.ts +21 -0
- package/dist/components/checkbox/index.d.ts +8 -0
- package/dist/components/checkbox/index.js +320 -0
- package/dist/components/chip/chip.d.ts +35 -0
- package/dist/components/chip/chip.styles.d.ts +1 -0
- package/dist/components/chip/chip.types.d.ts +3 -0
- package/dist/components/chip/index.d.ts +2 -0
- package/dist/components/chip/index.js +282 -0
- package/dist/components/color-input/color-input.d.ts +55 -0
- package/dist/components/color-input/color-input.styles.d.ts +1 -0
- package/dist/components/color-input/color-input.types.d.ts +2 -0
- package/dist/components/color-input/index.d.ts +1 -0
- package/dist/components/color-input/index.js +489 -0
- package/dist/components/combobox/combobox.d.ts +59 -0
- package/dist/components/combobox/combobox.styles.d.ts +1 -0
- package/dist/components/combobox/combobox.types.d.ts +7 -0
- package/dist/components/combobox/index.d.ts +2 -0
- package/dist/components/combobox/index.js +1988 -0
- package/dist/components/date-input/date-input.d.ts +66 -0
- package/dist/components/date-input/date-input.styles.d.ts +1 -0
- package/dist/components/date-input/date-input.types.d.ts +3 -0
- package/dist/components/date-input/index.d.ts +2 -0
- package/dist/components/date-input/index.js +2863 -0
- package/dist/components/datepicker/datepicker.d.ts +52 -0
- package/dist/components/datepicker/datepicker.styles.d.ts +1 -0
- package/dist/components/datepicker/datepicker.types.d.ts +3 -0
- package/dist/components/datepicker/index.d.ts +2 -0
- package/dist/components/datepicker/index.js +416 -0
- package/dist/components/dialog/dialog.d.ts +114 -0
- package/dist/components/dialog/dialog.styles.d.ts +1 -0
- package/dist/components/dialog/dialog.types.d.ts +11 -0
- package/dist/components/dialog/index.d.ts +2 -0
- package/dist/components/dialog/index.js +920 -0
- package/dist/components/divider/divider.d.ts +35 -0
- package/dist/components/divider/divider.styles.d.ts +1 -0
- package/dist/components/divider/divider.types.d.ts +2 -0
- package/dist/components/divider/index.d.ts +2 -0
- package/dist/components/divider/index.js +149 -0
- package/dist/components/dropdown/dropdown-item.d.ts +24 -0
- package/dist/components/dropdown/dropdown-item.styles.d.ts +1 -0
- package/dist/components/dropdown/dropdown.d.ts +30 -0
- package/dist/components/dropdown/dropdown.styles.d.ts +1 -0
- package/dist/components/dropdown/dropdown.types.d.ts +1 -0
- package/dist/components/dropdown/index.d.ts +3 -0
- package/dist/components/dropdown/index.js +1791 -0
- package/dist/components/header/header.d.ts +19 -0
- package/dist/components/header/header.styles.d.ts +1 -0
- package/dist/components/header/header.types.d.ts +1 -0
- package/dist/components/header/index.d.ts +2 -0
- package/dist/components/header/index.js +104 -0
- package/dist/components/icon-button/icon-button.d.ts +52 -0
- package/dist/components/icon-button/icon-button.styles.d.ts +1 -0
- package/dist/components/icon-button/icon-button.types.d.ts +8 -0
- package/dist/components/icon-button/index.d.ts +1 -0
- package/dist/components/icon-button/index.js +342 -0
- package/dist/components/image/image.d.ts +26 -0
- package/dist/components/image/image.styles.d.ts +1 -0
- package/dist/components/image/image.types.d.ts +0 -0
- package/dist/components/image/index.d.ts +1 -0
- package/dist/components/image/index.js +105 -0
- package/dist/components/link/index.d.ts +1 -0
- package/dist/components/link/index.js +108 -0
- package/dist/components/link/link.d.ts +22 -0
- package/dist/components/link/link.styles.d.ts +1 -0
- package/dist/components/link/link.types.d.ts +1 -0
- package/dist/components/list/index.d.ts +9 -0
- package/dist/components/list/index.js +254 -0
- package/dist/components/list/list-item.d.ts +41 -0
- package/dist/components/list/list-item.styles.d.ts +1 -0
- package/dist/components/list/list.d.ts +85 -0
- package/dist/components/list/list.styles.d.ts +1 -0
- package/dist/components/list/list.types.d.ts +16 -0
- package/dist/components/nav/index.d.ts +3 -0
- package/dist/components/nav/index.js +345 -0
- package/dist/components/nav/nav-item.d.ts +73 -0
- package/dist/components/nav/nav.d.ts +49 -0
- package/dist/components/nav/nav.styles.d.ts +2 -0
- package/dist/components/nav/nav.types.d.ts +1 -0
- package/dist/components/pagination/index.d.ts +2 -0
- package/dist/components/pagination/index.js +210 -0
- package/dist/components/pagination/pagination.d.ts +34 -0
- package/dist/components/pagination/pagination.styles.d.ts +1 -0
- package/dist/components/pagination/pagination.types.d.ts +1 -0
- package/dist/components/progress/index.d.ts +2 -0
- package/dist/components/progress/index.js +167 -0
- package/dist/components/progress/progress.d.ts +44 -0
- package/dist/components/progress/progress.styles.d.ts +1 -0
- package/dist/components/progress/progress.types.d.ts +2 -0
- package/dist/components/radio/index.d.ts +8 -0
- package/dist/components/radio/index.js +294 -0
- package/dist/components/radio/radio.d.ts +96 -0
- package/dist/components/radio/radio.styles.d.ts +1 -0
- package/dist/components/radio/radio.types.d.ts +21 -0
- package/dist/components/radio-group/index.d.ts +8 -0
- package/dist/components/radio-group/index.js +384 -0
- package/dist/components/radio-group/radio-group.d.ts +100 -0
- package/dist/components/radio-group/radio-group.styles.d.ts +1 -0
- package/dist/components/radio-group/radio-group.types.d.ts +8 -0
- package/dist/components/select/index.d.ts +8 -0
- package/dist/components/select/index.js +2123 -0
- package/dist/components/select/select.d.ts +129 -0
- package/dist/components/select/select.styles.d.ts +1 -0
- package/dist/components/select/select.types.d.ts +37 -0
- package/dist/components/shared/backdrop.styles.d.ts +1 -0
- package/dist/components/shared/floating.d.ts +10 -0
- package/dist/components/sidepanel/index.d.ts +1 -0
- package/dist/components/sidepanel/index.js +768 -0
- package/dist/components/sidepanel/sidepanel.d.ts +48 -0
- package/dist/components/sidepanel/sidepanel.styles.d.ts +1 -0
- package/dist/components/sidepanel/sidepanel.types.d.ts +1 -0
- package/dist/components/skeleton/index.d.ts +2 -0
- package/dist/components/skeleton/index.js +129 -0
- package/dist/components/skeleton/skeleton.d.ts +39 -0
- package/dist/components/skeleton/skeleton.styles.d.ts +1 -0
- package/dist/components/skeleton/skeleton.types.d.ts +1 -0
- package/dist/components/slider/index.d.ts +2 -0
- package/dist/components/slider/index.js +635 -0
- package/dist/components/slider/slider.d.ts +33 -0
- package/dist/components/slider/slider.styles.d.ts +1 -0
- package/dist/components/slider/slider.types.d.ts +1 -0
- package/dist/components/snackbar/index.d.ts +2 -0
- package/dist/components/snackbar/index.js +358 -0
- package/dist/components/snackbar/snackbar.d.ts +63 -0
- package/dist/components/snackbar/snackbar.styles.d.ts +1 -0
- package/dist/components/snackbar/snackbar.types.d.ts +1 -0
- package/dist/components/spinner/index.d.ts +8 -0
- package/dist/components/spinner/index.js +131 -0
- package/dist/components/spinner/spineer.styles.d.ts +1 -0
- package/dist/components/spinner/spinner.d.ts +52 -0
- package/dist/components/spinner/spinner.types.d.ts +18 -0
- package/dist/components/surface/index.d.ts +8 -0
- package/dist/components/surface/index.js +128 -0
- package/dist/components/surface/surface.d.ts +48 -0
- package/dist/components/surface/surface.styles.d.ts +1 -0
- package/dist/components/surface/surface.types.d.ts +20 -0
- package/dist/components/switch/index.d.ts +8 -0
- package/dist/components/switch/index.js +293 -0
- package/dist/components/switch/switch.d.ts +90 -0
- package/dist/components/switch/switch.styles.d.ts +1 -0
- package/dist/components/switch/switch.types.d.ts +21 -0
- package/dist/components/tab/index.d.ts +9 -0
- package/dist/components/tab/index.js +252 -0
- package/dist/components/tab/tab-panel.d.ts +28 -0
- package/dist/components/tab/tab-panel.styles.d.ts +1 -0
- package/dist/components/tab/tab.d.ts +59 -0
- package/dist/components/tab/tab.styles.d.ts +1 -0
- package/dist/components/tab/tab.types.d.ts +7 -0
- package/dist/components/tab-group/index.d.ts +8 -0
- package/dist/components/tab-group/index.js +441 -0
- package/dist/components/tab-group/tab-group.d.ts +99 -0
- package/dist/components/tab-group/tab-group.styles.d.ts +1 -0
- package/dist/components/tab-group/tab-group.types.d.ts +11 -0
- package/dist/components/table/index.d.ts +2 -0
- package/dist/components/table/index.js +582 -0
- package/dist/components/table/table.d.ts +160 -0
- package/dist/components/table/table.styles.d.ts +1 -0
- package/dist/components/table/table.types.d.ts +106 -0
- package/dist/components/text/index.d.ts +1 -0
- package/dist/components/text/index.js +207 -0
- package/dist/components/text/text.d.ts +32 -0
- package/dist/components/text/text.styles.d.ts +1 -0
- package/dist/components/text/text.types.d.ts +2 -0
- package/dist/components/textfield/index.d.ts +8 -0
- package/dist/components/textfield/index.js +718 -0
- package/dist/components/textfield/textfield.d.ts +168 -0
- package/dist/components/textfield/textfield.styles.d.ts +1 -0
- package/dist/components/textfield/textfield.types.d.ts +40 -0
- package/dist/components/tooltip/index.d.ts +2 -0
- package/dist/components/tooltip/index.js +379 -0
- package/dist/components/tooltip/tooltip.d.ts +42 -0
- package/dist/components/tooltip/tooltip.styles.d.ts +1 -0
- package/dist/components/tooltip/tooltip.types.d.ts +1 -0
- package/dist/css/font-face.css +22 -0
- package/dist/css/latty.css +57 -0
- package/dist/fonts/HankenGrotesk-Variable.woff2 +0 -0
- package/dist/fonts/HankenGrotesk-VariableItalic.woff2 +0 -0
- package/dist/index.cjs +12739 -0
- package/dist/index.d.ts +101 -0
- package/dist/index.js +11406 -0
- package/dist/manifest.json +2396 -0
- package/dist/utils/click-outside.d.ts +22 -0
- package/dist/utils/color.d.ts +14 -0
- package/dist/utils/dispatch.d.ts +18 -0
- package/dist/utils/index.d.ts +3 -0
- package/package.json +231 -0
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __decorateClass = (decorators, target, key, kind) => {
|
|
4
|
+
var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc(target, key) : target;
|
|
5
|
+
for (var i = decorators.length - 1, decorator; i >= 0; i--)
|
|
6
|
+
if (decorator = decorators[i])
|
|
7
|
+
result = (kind ? decorator(target, key, result) : decorator(result)) || result;
|
|
8
|
+
if (kind && result) __defProp(target, key, result);
|
|
9
|
+
return result;
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
// src/components/surface/surface.ts
|
|
13
|
+
import { html } from "lit";
|
|
14
|
+
|
|
15
|
+
// src/base/themeable-element.ts
|
|
16
|
+
import { LitElement } from "lit";
|
|
17
|
+
import { property } from "lit/decorators.js";
|
|
18
|
+
var ThemeableElement = class extends LitElement {
|
|
19
|
+
willUpdate(changed) {
|
|
20
|
+
super.willUpdate(changed);
|
|
21
|
+
if (changed.has("theme")) {
|
|
22
|
+
this._syncThemeAttribute();
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
_syncThemeAttribute() {
|
|
26
|
+
if (this.theme === "dark" || this.theme === "light") {
|
|
27
|
+
this.setAttribute("data-theme", this.theme);
|
|
28
|
+
} else {
|
|
29
|
+
this.removeAttribute("data-theme");
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
};
|
|
33
|
+
__decorateClass([
|
|
34
|
+
property({ reflect: true })
|
|
35
|
+
], ThemeableElement.prototype, "theme", 2);
|
|
36
|
+
|
|
37
|
+
// src/components/surface/surface.ts
|
|
38
|
+
import { customElement, property as property2 } from "lit/decorators.js";
|
|
39
|
+
import { styleMap } from "lit/directives/style-map.js";
|
|
40
|
+
|
|
41
|
+
// src/components/surface/surface.styles.ts
|
|
42
|
+
import { css } from "lit";
|
|
43
|
+
var surfaceStyles = css`
|
|
44
|
+
:host {
|
|
45
|
+
display: block;
|
|
46
|
+
font-family: 'Hanken Grotesk', sans-serif;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
.surface {
|
|
50
|
+
background: var(--lt-surface-bg, var(--lt-bg-subtle));
|
|
51
|
+
border-radius: var(--lt-border-radius);
|
|
52
|
+
box-sizing: border-box;
|
|
53
|
+
transition:
|
|
54
|
+
box-shadow 120ms ease,
|
|
55
|
+
border-color 120ms ease;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
/* Elevation variants */
|
|
59
|
+
:host([elevation='0']) .surface {
|
|
60
|
+
box-shadow: var(--lt-elevation-0);
|
|
61
|
+
}
|
|
62
|
+
:host([elevation='1']) .surface {
|
|
63
|
+
box-shadow: var(--lt-elevation-1);
|
|
64
|
+
}
|
|
65
|
+
:host([elevation='2']) .surface {
|
|
66
|
+
box-shadow: var(--lt-elevation-2);
|
|
67
|
+
}
|
|
68
|
+
:host([elevation='3']) .surface {
|
|
69
|
+
box-shadow: var(--lt-elevation-3);
|
|
70
|
+
}
|
|
71
|
+
:host([elevation='4']) .surface {
|
|
72
|
+
box-shadow: var(--lt-elevation-4);
|
|
73
|
+
}
|
|
74
|
+
:host([elevation='5']) .surface {
|
|
75
|
+
box-shadow: var(--lt-elevation-5);
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
/* Visual appearances */
|
|
79
|
+
:host([appearance='filled']) .surface {
|
|
80
|
+
border: none;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
:host([appearance='outlined']) .surface {
|
|
84
|
+
background: var(--lt-surface-bg, transparent);
|
|
85
|
+
border: 1px solid var(--lt-border-default);
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
:host([appearance='outlined']:hover) .surface {
|
|
89
|
+
border-color: var(--lt-border-strong);
|
|
90
|
+
}
|
|
91
|
+
`;
|
|
92
|
+
|
|
93
|
+
// src/utils/color.ts
|
|
94
|
+
var resolveColorValue = (value) => value.startsWith("--") ? `var(${value})` : value;
|
|
95
|
+
|
|
96
|
+
// src/components/surface/surface.ts
|
|
97
|
+
var Surface = class extends ThemeableElement {
|
|
98
|
+
constructor() {
|
|
99
|
+
super(...arguments);
|
|
100
|
+
this.elevation = "1";
|
|
101
|
+
this.appearance = "filled";
|
|
102
|
+
this.background = "";
|
|
103
|
+
}
|
|
104
|
+
render() {
|
|
105
|
+
const style = this.background ? { "--_surface-bg": resolveColorValue(this.background) } : {};
|
|
106
|
+
return html`
|
|
107
|
+
<div class="surface" part="surface" style=${styleMap(style)}>
|
|
108
|
+
<slot></slot>
|
|
109
|
+
</div>
|
|
110
|
+
`;
|
|
111
|
+
}
|
|
112
|
+
};
|
|
113
|
+
Surface.styles = surfaceStyles;
|
|
114
|
+
__decorateClass([
|
|
115
|
+
property2({ reflect: true })
|
|
116
|
+
], Surface.prototype, "elevation", 2);
|
|
117
|
+
__decorateClass([
|
|
118
|
+
property2({ reflect: true })
|
|
119
|
+
], Surface.prototype, "appearance", 2);
|
|
120
|
+
__decorateClass([
|
|
121
|
+
property2({ reflect: true })
|
|
122
|
+
], Surface.prototype, "background", 2);
|
|
123
|
+
Surface = __decorateClass([
|
|
124
|
+
customElement("lt-surface")
|
|
125
|
+
], Surface);
|
|
126
|
+
export {
|
|
127
|
+
Surface
|
|
128
|
+
};
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { ThemeableElement } from '../../base';
|
|
2
|
+
import { SurfaceElevation, SurfaceAppearance } from './surface.types';
|
|
3
|
+
/**
|
|
4
|
+
* A container component that provides elevation and surface styling.
|
|
5
|
+
* Used for cards, dropdowns, modals, and other elevated UI elements.
|
|
6
|
+
*
|
|
7
|
+
* @element lt-surface
|
|
8
|
+
*
|
|
9
|
+
* @slot - Content to be displayed within the surface
|
|
10
|
+
*
|
|
11
|
+
* @example
|
|
12
|
+
* ```html
|
|
13
|
+
* <lt-surface elevation="2">
|
|
14
|
+
* <p>This is a card with medium elevation</p>
|
|
15
|
+
* </lt-surface>
|
|
16
|
+
* ```
|
|
17
|
+
*
|
|
18
|
+
* @example
|
|
19
|
+
* ```html
|
|
20
|
+
* <lt-surface appearance="outlined" elevation="0">
|
|
21
|
+
* <p>This is an outlined surface with no shadow</p>
|
|
22
|
+
* </lt-surface>
|
|
23
|
+
* ```
|
|
24
|
+
*
|
|
25
|
+
* @example
|
|
26
|
+
* ```html
|
|
27
|
+
* <lt-surface elevation="4">
|
|
28
|
+
* <h3>Modal Dialog</h3>
|
|
29
|
+
* <p>Content with high elevation for modals</p>
|
|
30
|
+
* </lt-surface>
|
|
31
|
+
* ```
|
|
32
|
+
*/
|
|
33
|
+
export declare class Surface extends ThemeableElement {
|
|
34
|
+
static styles: import("lit").CSSResult;
|
|
35
|
+
/**
|
|
36
|
+
* Elevation level that determines shadow depth.
|
|
37
|
+
* @default '1'
|
|
38
|
+
*/
|
|
39
|
+
elevation: SurfaceElevation;
|
|
40
|
+
/**
|
|
41
|
+
* Visual appearance that determines border and background.
|
|
42
|
+
* @default 'filled'
|
|
43
|
+
*/
|
|
44
|
+
appearance: SurfaceAppearance;
|
|
45
|
+
/** Background color override. Accepts a hex value (#1a1a2e) or a CSS token name (--lt-color-primary-600). */
|
|
46
|
+
background: string;
|
|
47
|
+
render(): import("lit").TemplateResult<1>;
|
|
48
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const surfaceStyles: import("lit").CSSResult;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Elevation level for the surface component.
|
|
3
|
+
* Determines the shadow depth applied to the surface.
|
|
4
|
+
*
|
|
5
|
+
* - `0`: No shadow (flat surface)
|
|
6
|
+
* - `1`: Minimal shadow (slightly raised)
|
|
7
|
+
* - `2`: Medium shadow (card-like elevation)
|
|
8
|
+
* - `3`: High shadow (prominent elevation)
|
|
9
|
+
* - `4`: Very high shadow (floating elements)
|
|
10
|
+
* - `5`: Maximum shadow (modals, overlays)
|
|
11
|
+
*/
|
|
12
|
+
export type SurfaceElevation = '0' | '1' | '2' | '3' | '4' | '5';
|
|
13
|
+
/**
|
|
14
|
+
* Visual appearance of the surface component.
|
|
15
|
+
* Determines the border and background styling.
|
|
16
|
+
*
|
|
17
|
+
* - `filled`: Solid background with no border
|
|
18
|
+
* - `outlined`: Transparent background with border
|
|
19
|
+
*/
|
|
20
|
+
export type SurfaceAppearance = 'filled' | 'outlined';
|
|
@@ -0,0 +1,293 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __decorateClass = (decorators, target, key, kind) => {
|
|
4
|
+
var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc(target, key) : target;
|
|
5
|
+
for (var i = decorators.length - 1, decorator; i >= 0; i--)
|
|
6
|
+
if (decorator = decorators[i])
|
|
7
|
+
result = (kind ? decorator(target, key, result) : decorator(result)) || result;
|
|
8
|
+
if (kind && result) __defProp(target, key, result);
|
|
9
|
+
return result;
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
// src/components/switch/switch.ts
|
|
13
|
+
import { html } from "lit";
|
|
14
|
+
|
|
15
|
+
// src/base/themeable-element.ts
|
|
16
|
+
import { LitElement } from "lit";
|
|
17
|
+
import { property } from "lit/decorators.js";
|
|
18
|
+
var ThemeableElement = class extends LitElement {
|
|
19
|
+
willUpdate(changed) {
|
|
20
|
+
super.willUpdate(changed);
|
|
21
|
+
if (changed.has("theme")) {
|
|
22
|
+
this._syncThemeAttribute();
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
_syncThemeAttribute() {
|
|
26
|
+
if (this.theme === "dark" || this.theme === "light") {
|
|
27
|
+
this.setAttribute("data-theme", this.theme);
|
|
28
|
+
} else {
|
|
29
|
+
this.removeAttribute("data-theme");
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
};
|
|
33
|
+
__decorateClass([
|
|
34
|
+
property({ reflect: true })
|
|
35
|
+
], ThemeableElement.prototype, "theme", 2);
|
|
36
|
+
|
|
37
|
+
// src/components/switch/switch.ts
|
|
38
|
+
import { customElement, property as property2 } from "lit/decorators.js";
|
|
39
|
+
|
|
40
|
+
// src/components/switch/switch.styles.ts
|
|
41
|
+
import { css } from "lit";
|
|
42
|
+
var switchStyles = css`
|
|
43
|
+
:host {
|
|
44
|
+
display: inline-block;
|
|
45
|
+
font-family: 'Hanken Grotesk', sans-serif;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
.switch-wrapper {
|
|
49
|
+
align-items: center;
|
|
50
|
+
cursor: pointer;
|
|
51
|
+
display: inline-flex;
|
|
52
|
+
gap: var(--lt-spacing-2);
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
:host([label-position='left']) .switch-wrapper {
|
|
56
|
+
flex-direction: row-reverse;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
:host([disabled]) .switch-wrapper {
|
|
60
|
+
cursor: not-allowed;
|
|
61
|
+
opacity: 0.6;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
.switch-container {
|
|
65
|
+
display: inline-flex;
|
|
66
|
+
position: relative;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
input[type='checkbox'] {
|
|
70
|
+
appearance: none;
|
|
71
|
+
background: var(--lt-border-default);
|
|
72
|
+
border-radius: 999px;
|
|
73
|
+
cursor: pointer;
|
|
74
|
+
flex-shrink: 0;
|
|
75
|
+
margin: 0;
|
|
76
|
+
position: relative;
|
|
77
|
+
transition: background-color 200ms ease;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
input[type='checkbox']:hover:not(:disabled) {
|
|
81
|
+
background: var(--lt-border-strong);
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
input[type='checkbox']:focus-visible {
|
|
85
|
+
outline: 3px solid var(--lt-border-focus);
|
|
86
|
+
outline-offset: 2px;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
input[type='checkbox']:disabled {
|
|
90
|
+
cursor: not-allowed;
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
.thumb {
|
|
94
|
+
background: white;
|
|
95
|
+
border-radius: 50%;
|
|
96
|
+
box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
|
|
97
|
+
pointer-events: none;
|
|
98
|
+
position: absolute;
|
|
99
|
+
transition: left 200ms ease;
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
.label {
|
|
103
|
+
color: var(--lt-text-default);
|
|
104
|
+
user-select: none;
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
/* Size variants */
|
|
108
|
+
:host([size='sm']) input[type='checkbox'] {
|
|
109
|
+
height: 18px;
|
|
110
|
+
width: 32px;
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
:host([size='sm']) .thumb {
|
|
114
|
+
height: 14px;
|
|
115
|
+
width: 14px;
|
|
116
|
+
left: 2px;
|
|
117
|
+
top: 2px;
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
:host([size='sm']) input[type='checkbox']:checked ~ .thumb {
|
|
121
|
+
left: 16px;
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
:host([size='sm']) .label {
|
|
125
|
+
font-size: 0.875rem;
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
:host([size='md']) input[type='checkbox'] {
|
|
129
|
+
height: 22px;
|
|
130
|
+
width: 40px;
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
:host([size='md']) .thumb {
|
|
134
|
+
height: 18px;
|
|
135
|
+
width: 18px;
|
|
136
|
+
left: 2px;
|
|
137
|
+
top: 2px;
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
:host([size='md']) input[type='checkbox']:checked ~ .thumb {
|
|
141
|
+
left: 20px;
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
:host([size='md']) .label {
|
|
145
|
+
font-size: 1rem;
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
:host([size='lg']) input[type='checkbox'] {
|
|
149
|
+
height: 26px;
|
|
150
|
+
width: 48px;
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
:host([size='lg']) .thumb {
|
|
154
|
+
height: 22px;
|
|
155
|
+
width: 22px;
|
|
156
|
+
left: 2px;
|
|
157
|
+
top: 2px;
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
:host([size='lg']) input[type='checkbox']:checked ~ .thumb {
|
|
161
|
+
left: 24px;
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
:host([size='lg']) .label {
|
|
165
|
+
font-size: 1.0625rem;
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
/* Variant styles */
|
|
169
|
+
:host([variant='primary']) input[type='checkbox']:checked {
|
|
170
|
+
background: var(--lt-interactive-primary-bg);
|
|
171
|
+
}
|
|
172
|
+
:host([variant='primary']) input[type='checkbox']:checked:hover:not(:disabled) {
|
|
173
|
+
background: var(--lt-interactive-primary-bg-hover);
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
:host([variant='secondary']) input[type='checkbox']:checked {
|
|
177
|
+
background: var(--lt-interactive-secondary-bg);
|
|
178
|
+
}
|
|
179
|
+
:host([variant='secondary']) input[type='checkbox']:checked:hover:not(:disabled) {
|
|
180
|
+
background: var(--lt-interactive-secondary-bg-hover);
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
:host([variant='success']) input[type='checkbox']:checked {
|
|
184
|
+
background: var(--lt-interactive-success-bg);
|
|
185
|
+
}
|
|
186
|
+
:host([variant='success']) input[type='checkbox']:checked:hover:not(:disabled) {
|
|
187
|
+
background: var(--lt-interactive-success-bg-hover);
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
:host([variant='error']) input[type='checkbox']:checked {
|
|
191
|
+
background: var(--lt-interactive-error-bg);
|
|
192
|
+
}
|
|
193
|
+
:host([variant='error']) input[type='checkbox']:checked:hover:not(:disabled) {
|
|
194
|
+
background: var(--lt-interactive-error-bg-hover);
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
:host([variant='info']) input[type='checkbox']:checked {
|
|
198
|
+
background: var(--lt-interactive-info-bg);
|
|
199
|
+
}
|
|
200
|
+
:host([variant='info']) input[type='checkbox']:checked:hover:not(:disabled) {
|
|
201
|
+
background: var(--lt-interactive-info-bg-hover);
|
|
202
|
+
}
|
|
203
|
+
`;
|
|
204
|
+
|
|
205
|
+
// src/components/switch/switch.ts
|
|
206
|
+
var Switch = class extends ThemeableElement {
|
|
207
|
+
constructor() {
|
|
208
|
+
super(...arguments);
|
|
209
|
+
this.variant = "primary";
|
|
210
|
+
this.size = "md";
|
|
211
|
+
this.checked = false;
|
|
212
|
+
this.disabled = false;
|
|
213
|
+
this.required = false;
|
|
214
|
+
this.label = "";
|
|
215
|
+
this.labelPosition = "right";
|
|
216
|
+
this.name = "";
|
|
217
|
+
this.value = "on";
|
|
218
|
+
}
|
|
219
|
+
/**
|
|
220
|
+
* Handles switch change events.
|
|
221
|
+
* Updates the checked state and dispatches a custom change event.
|
|
222
|
+
*
|
|
223
|
+
* @param e - The native change event
|
|
224
|
+
* @private
|
|
225
|
+
*/
|
|
226
|
+
handleChange(e) {
|
|
227
|
+
const target = e.target;
|
|
228
|
+
this.checked = target.checked;
|
|
229
|
+
this.dispatchEvent(
|
|
230
|
+
new CustomEvent("change", {
|
|
231
|
+
detail: { checked: this.checked },
|
|
232
|
+
bubbles: true,
|
|
233
|
+
composed: true
|
|
234
|
+
})
|
|
235
|
+
);
|
|
236
|
+
}
|
|
237
|
+
render() {
|
|
238
|
+
return html`
|
|
239
|
+
<label class="switch-wrapper">
|
|
240
|
+
<div class="switch-container">
|
|
241
|
+
<input
|
|
242
|
+
type="checkbox"
|
|
243
|
+
.checked=${this.checked}
|
|
244
|
+
?disabled=${this.disabled}
|
|
245
|
+
?required=${this.required}
|
|
246
|
+
name=${this.name}
|
|
247
|
+
value=${this.value}
|
|
248
|
+
@change=${this.handleChange}
|
|
249
|
+
aria-label=${this.label || "switch"}
|
|
250
|
+
role="switch"
|
|
251
|
+
aria-checked=${this.checked ? "true" : "false"}
|
|
252
|
+
/>
|
|
253
|
+
<span class="thumb"></span>
|
|
254
|
+
</div>
|
|
255
|
+
${this.label ? html`<span class="label">${this.label}</span>` : ""}
|
|
256
|
+
</label>
|
|
257
|
+
`;
|
|
258
|
+
}
|
|
259
|
+
};
|
|
260
|
+
Switch.styles = switchStyles;
|
|
261
|
+
__decorateClass([
|
|
262
|
+
property2({ reflect: true })
|
|
263
|
+
], Switch.prototype, "variant", 2);
|
|
264
|
+
__decorateClass([
|
|
265
|
+
property2({ reflect: true })
|
|
266
|
+
], Switch.prototype, "size", 2);
|
|
267
|
+
__decorateClass([
|
|
268
|
+
property2({ type: Boolean, reflect: true })
|
|
269
|
+
], Switch.prototype, "checked", 2);
|
|
270
|
+
__decorateClass([
|
|
271
|
+
property2({ type: Boolean, reflect: true })
|
|
272
|
+
], Switch.prototype, "disabled", 2);
|
|
273
|
+
__decorateClass([
|
|
274
|
+
property2({ type: Boolean, reflect: true })
|
|
275
|
+
], Switch.prototype, "required", 2);
|
|
276
|
+
__decorateClass([
|
|
277
|
+
property2()
|
|
278
|
+
], Switch.prototype, "label", 2);
|
|
279
|
+
__decorateClass([
|
|
280
|
+
property2({ attribute: "label-position", reflect: true })
|
|
281
|
+
], Switch.prototype, "labelPosition", 2);
|
|
282
|
+
__decorateClass([
|
|
283
|
+
property2()
|
|
284
|
+
], Switch.prototype, "name", 2);
|
|
285
|
+
__decorateClass([
|
|
286
|
+
property2()
|
|
287
|
+
], Switch.prototype, "value", 2);
|
|
288
|
+
Switch = __decorateClass([
|
|
289
|
+
customElement("lt-switch")
|
|
290
|
+
], Switch);
|
|
291
|
+
export {
|
|
292
|
+
Switch
|
|
293
|
+
};
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
import { ThemeableElement } from '../../base';
|
|
2
|
+
import { SwitchSize, SwitchVariant, SwitchLabelPosition } from './switch.types';
|
|
3
|
+
/**
|
|
4
|
+
* A toggle switch component with sliding animation.
|
|
5
|
+
* Internally uses a checkbox input with custom toggle styling.
|
|
6
|
+
*
|
|
7
|
+
* @element lt-switch
|
|
8
|
+
*
|
|
9
|
+
* @fires {CustomEvent<{checked: boolean}>} change - Dispatched when the switch state changes
|
|
10
|
+
*
|
|
11
|
+
* @example
|
|
12
|
+
* ```html
|
|
13
|
+
* <lt-switch label="Enable notifications"></lt-switch>
|
|
14
|
+
* ```
|
|
15
|
+
*
|
|
16
|
+
* @example
|
|
17
|
+
* ```html
|
|
18
|
+
* <lt-switch
|
|
19
|
+
* variant="success"
|
|
20
|
+
* label="Dark mode"
|
|
21
|
+
* checked
|
|
22
|
+
* ></lt-switch>
|
|
23
|
+
* ```
|
|
24
|
+
*
|
|
25
|
+
* @example
|
|
26
|
+
* ```html
|
|
27
|
+
* <lt-switch
|
|
28
|
+
* variant="error"
|
|
29
|
+
* label="Delete on exit"
|
|
30
|
+
* disabled
|
|
31
|
+
* ></lt-switch>
|
|
32
|
+
* ```
|
|
33
|
+
*/
|
|
34
|
+
export declare class Switch extends ThemeableElement {
|
|
35
|
+
static styles: import("lit").CSSResult;
|
|
36
|
+
/**
|
|
37
|
+
* Visual variant that determines the color when checked.
|
|
38
|
+
* @default 'primary'
|
|
39
|
+
*/
|
|
40
|
+
variant: SwitchVariant;
|
|
41
|
+
/**
|
|
42
|
+
* Size of the switch.
|
|
43
|
+
* @default 'md'
|
|
44
|
+
*/
|
|
45
|
+
size: SwitchSize;
|
|
46
|
+
/**
|
|
47
|
+
* Whether the switch is checked (on).
|
|
48
|
+
* @default false
|
|
49
|
+
*/
|
|
50
|
+
checked: boolean;
|
|
51
|
+
/**
|
|
52
|
+
* Whether the switch is disabled.
|
|
53
|
+
* @default false
|
|
54
|
+
*/
|
|
55
|
+
disabled: boolean;
|
|
56
|
+
/**
|
|
57
|
+
* Whether the switch is required.
|
|
58
|
+
* @default false
|
|
59
|
+
*/
|
|
60
|
+
required: boolean;
|
|
61
|
+
/**
|
|
62
|
+
* Label text displayed next to the switch.
|
|
63
|
+
* @default ''
|
|
64
|
+
*/
|
|
65
|
+
label: string;
|
|
66
|
+
/**
|
|
67
|
+
* Position of the label relative to the switch.
|
|
68
|
+
* @default 'right'
|
|
69
|
+
*/
|
|
70
|
+
labelPosition: SwitchLabelPosition;
|
|
71
|
+
/**
|
|
72
|
+
* Name attribute for form submission.
|
|
73
|
+
* @default ''
|
|
74
|
+
*/
|
|
75
|
+
name: string;
|
|
76
|
+
/**
|
|
77
|
+
* Value attribute for form submission.
|
|
78
|
+
* @default 'on'
|
|
79
|
+
*/
|
|
80
|
+
value: string;
|
|
81
|
+
/**
|
|
82
|
+
* Handles switch change events.
|
|
83
|
+
* Updates the checked state and dispatches a custom change event.
|
|
84
|
+
*
|
|
85
|
+
* @param e - The native change event
|
|
86
|
+
* @private
|
|
87
|
+
*/
|
|
88
|
+
private handleChange;
|
|
89
|
+
render(): import("lit").TemplateResult<1>;
|
|
90
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const switchStyles: import("lit").CSSResult;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Size variant of the switch component.
|
|
3
|
+
* Affects the switch size and label font size.
|
|
4
|
+
*
|
|
5
|
+
* - `sm`: 32px width x 18px height, 0.875rem label
|
|
6
|
+
* - `md`: 40px width x 22px height, 1rem label (default)
|
|
7
|
+
* - `lg`: 48px width x 26px height, 1.0625rem label
|
|
8
|
+
*/
|
|
9
|
+
export type SwitchSize = 'sm' | 'md' | 'lg';
|
|
10
|
+
/**
|
|
11
|
+
* Visual variant of the switch component.
|
|
12
|
+
* Determines the color when checked.
|
|
13
|
+
*
|
|
14
|
+
* - `primary`: Primary brand color (default)
|
|
15
|
+
* - `secondary`: Secondary brand color
|
|
16
|
+
* - `success`: Green color
|
|
17
|
+
* - `error`: Red color
|
|
18
|
+
* - `info`: Blue color
|
|
19
|
+
*/
|
|
20
|
+
export type SwitchVariant = 'primary' | 'secondary' | 'success' | 'error' | 'info';
|
|
21
|
+
export type SwitchLabelPosition = 'left' | 'right';
|