@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,345 @@
|
|
|
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/nav/nav.ts
|
|
13
|
+
import { html as html2, nothing as nothing2 } 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/nav/nav.ts
|
|
38
|
+
import { customElement as customElement2, property as property3 } from "lit/decorators.js";
|
|
39
|
+
|
|
40
|
+
// src/components/nav/nav.styles.ts
|
|
41
|
+
import { css } from "lit";
|
|
42
|
+
var navStyles = css`
|
|
43
|
+
:host {
|
|
44
|
+
display: block;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
nav {
|
|
48
|
+
display: flex;
|
|
49
|
+
flex-direction: column;
|
|
50
|
+
gap: 0;
|
|
51
|
+
list-style: none;
|
|
52
|
+
margin: 0;
|
|
53
|
+
padding: 0;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
:host([orientation='horizontal']) nav {
|
|
57
|
+
flex-direction: row;
|
|
58
|
+
align-items: center;
|
|
59
|
+
flex-wrap: wrap;
|
|
60
|
+
}
|
|
61
|
+
`;
|
|
62
|
+
var navItemStyles = css`
|
|
63
|
+
:host {
|
|
64
|
+
display: contents;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
.item-root {
|
|
68
|
+
position: relative;
|
|
69
|
+
display: flex;
|
|
70
|
+
flex-direction: column;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
/* Trigger row: link + optional chevron */
|
|
74
|
+
.item-trigger {
|
|
75
|
+
display: flex;
|
|
76
|
+
align-items: center;
|
|
77
|
+
gap: var(--lt-spacing-2);
|
|
78
|
+
width: 100%;
|
|
79
|
+
padding: var(--lt-nav-item-padding, var(--lt-spacing-2) var(--lt-spacing-3));
|
|
80
|
+
border-radius: 6px;
|
|
81
|
+
border: none;
|
|
82
|
+
background: none;
|
|
83
|
+
cursor: pointer;
|
|
84
|
+
color: inherit;
|
|
85
|
+
font-size: var(--lt-nav-item-font-size, 0.9375rem);
|
|
86
|
+
font-family: inherit;
|
|
87
|
+
text-decoration: none;
|
|
88
|
+
text-align: left;
|
|
89
|
+
transition: background 120ms;
|
|
90
|
+
white-space: nowrap;
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
.item-trigger:hover {
|
|
94
|
+
background: color-mix(in srgb, currentColor 10%, transparent);
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
.item-trigger:active {
|
|
98
|
+
background: color-mix(in srgb, currentColor 18%, transparent);
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
:host([active]) .item-trigger {
|
|
102
|
+
background: var(--lt-nav-item-active-bg, color-mix(in srgb, currentColor 15%, transparent));
|
|
103
|
+
color: var(--lt-nav-item-active-color, inherit);
|
|
104
|
+
font-weight: 600;
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
:host([disabled]) .item-trigger {
|
|
108
|
+
opacity: 0.4;
|
|
109
|
+
pointer-events: none;
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
.label {
|
|
113
|
+
flex: 1;
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
.icon-start {
|
|
117
|
+
flex-shrink: 0;
|
|
118
|
+
color: inherit;
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
/* Chevron rotates when open */
|
|
122
|
+
.chevron {
|
|
123
|
+
flex-shrink: 0;
|
|
124
|
+
color: inherit;
|
|
125
|
+
opacity: 0.6;
|
|
126
|
+
transition: transform 180ms ease;
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
:host([open]) .chevron {
|
|
130
|
+
transform: rotate(180deg);
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
/* Collapsible children */
|
|
134
|
+
.children {
|
|
135
|
+
overflow: hidden;
|
|
136
|
+
height: 0;
|
|
137
|
+
transition: height 200ms ease;
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
.children-inner {
|
|
141
|
+
padding-left: var(--lt-spacing-4);
|
|
142
|
+
padding-top: var(--lt-spacing-1);
|
|
143
|
+
padding-bottom: var(--lt-spacing-1);
|
|
144
|
+
display: flex;
|
|
145
|
+
flex-direction: column;
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
/* In horizontal nav, top-level items lay out row-style */
|
|
149
|
+
:host([orientation='horizontal']) .item-root {
|
|
150
|
+
flex-direction: row;
|
|
151
|
+
align-items: center;
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
/* Horizontal children drop down as a popover-style panel */
|
|
155
|
+
:host([orientation='horizontal']) .children {
|
|
156
|
+
position: absolute;
|
|
157
|
+
top: 100%;
|
|
158
|
+
left: 0;
|
|
159
|
+
min-width: 160px;
|
|
160
|
+
background: var(--lt-bg-default);
|
|
161
|
+
color: var(--lt-color-neutral-700);
|
|
162
|
+
border: 1px solid var(--lt-color-neutral-200);
|
|
163
|
+
border-radius: 8px;
|
|
164
|
+
box-shadow:
|
|
165
|
+
0 4px 6px -1px rgb(0 0 0 / 0.08),
|
|
166
|
+
0 2px 4px -2px rgb(0 0 0 / 0.05);
|
|
167
|
+
z-index: 100;
|
|
168
|
+
height: auto !important;
|
|
169
|
+
display: none;
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
:host([orientation='horizontal'][open]) .children {
|
|
173
|
+
display: block;
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
:host([orientation='horizontal']) .children-inner {
|
|
177
|
+
padding: var(--lt-spacing-2);
|
|
178
|
+
}
|
|
179
|
+
`;
|
|
180
|
+
|
|
181
|
+
// src/components/nav/nav-item.ts
|
|
182
|
+
import { html, nothing } from "lit";
|
|
183
|
+
import { customElement, property as property2, query } from "lit/decorators.js";
|
|
184
|
+
import "@latty-ds/icons";
|
|
185
|
+
var NavItem = class extends ThemeableElement {
|
|
186
|
+
constructor() {
|
|
187
|
+
super(...arguments);
|
|
188
|
+
this.href = "";
|
|
189
|
+
this.label = "";
|
|
190
|
+
this.iconStart = "";
|
|
191
|
+
this.active = false;
|
|
192
|
+
this.disabled = false;
|
|
193
|
+
this.open = false;
|
|
194
|
+
this.orientation = "vertical";
|
|
195
|
+
this._hasChildren = false;
|
|
196
|
+
}
|
|
197
|
+
_onSlotChange(e) {
|
|
198
|
+
const slot = e.target;
|
|
199
|
+
const nodes = slot.assignedElements();
|
|
200
|
+
this._hasChildren = nodes.length > 0;
|
|
201
|
+
nodes.forEach((el) => {
|
|
202
|
+
if (el.tagName.toLowerCase() === "lt-nav-item") {
|
|
203
|
+
el.removeAttribute("orientation");
|
|
204
|
+
}
|
|
205
|
+
});
|
|
206
|
+
this.requestUpdate();
|
|
207
|
+
}
|
|
208
|
+
updated(changed) {
|
|
209
|
+
if (changed.has("open") && this._childrenEl && this._childrenInnerEl && this.orientation === "vertical") {
|
|
210
|
+
const inner = this._childrenInnerEl;
|
|
211
|
+
const container = this._childrenEl;
|
|
212
|
+
if (this.open) {
|
|
213
|
+
container.style.height = `${inner.offsetHeight}px`;
|
|
214
|
+
} else {
|
|
215
|
+
container.style.height = `${inner.offsetHeight}px`;
|
|
216
|
+
requestAnimationFrame(() => {
|
|
217
|
+
container.style.height = "0px";
|
|
218
|
+
});
|
|
219
|
+
}
|
|
220
|
+
}
|
|
221
|
+
}
|
|
222
|
+
_handleTransitionEnd() {
|
|
223
|
+
if (this.open && this._childrenEl) {
|
|
224
|
+
this._childrenEl.style.height = "auto";
|
|
225
|
+
}
|
|
226
|
+
}
|
|
227
|
+
_handleTriggerClick(e) {
|
|
228
|
+
if (this.disabled) return;
|
|
229
|
+
this.dispatchEvent(
|
|
230
|
+
new CustomEvent("nav-item-click", {
|
|
231
|
+
detail: { href: this.href, label: this.label },
|
|
232
|
+
bubbles: true,
|
|
233
|
+
composed: true
|
|
234
|
+
})
|
|
235
|
+
);
|
|
236
|
+
if (this._hasChildren) {
|
|
237
|
+
e.preventDefault();
|
|
238
|
+
this.open = !this.open;
|
|
239
|
+
this.dispatchEvent(
|
|
240
|
+
new CustomEvent("nav-collapse", {
|
|
241
|
+
detail: { open: this.open },
|
|
242
|
+
bubbles: true,
|
|
243
|
+
composed: true
|
|
244
|
+
})
|
|
245
|
+
);
|
|
246
|
+
}
|
|
247
|
+
}
|
|
248
|
+
_renderTrigger() {
|
|
249
|
+
const showChevron = this._hasChildren;
|
|
250
|
+
const inner = html`
|
|
251
|
+
${this.iconStart ? html`<lt-icon class="icon-start" name=${this.iconStart} size="sm"></lt-icon>` : nothing}
|
|
252
|
+
<span class="label">${this.label}</span>
|
|
253
|
+
${showChevron ? html`<lt-icon class="chevron" name="caret-down" size="sm"></lt-icon>` : nothing}
|
|
254
|
+
`;
|
|
255
|
+
if (this.href && !this._hasChildren) {
|
|
256
|
+
return html`<a class="item-trigger" href=${this.href} @click=${this._handleTriggerClick}>${inner}</a>`;
|
|
257
|
+
}
|
|
258
|
+
return html`<button class="item-trigger" @click=${this._handleTriggerClick} ?disabled=${this.disabled}>
|
|
259
|
+
${inner}
|
|
260
|
+
</button>`;
|
|
261
|
+
}
|
|
262
|
+
render() {
|
|
263
|
+
return html`
|
|
264
|
+
<div class="item-root">
|
|
265
|
+
${this._renderTrigger()}
|
|
266
|
+
${this._hasChildren ? html`
|
|
267
|
+
<div class="children" @transitionend=${this._handleTransitionEnd}>
|
|
268
|
+
<div class="children-inner">
|
|
269
|
+
<slot @slotchange=${this._onSlotChange}></slot>
|
|
270
|
+
</div>
|
|
271
|
+
</div>
|
|
272
|
+
` : html`<slot @slotchange=${this._onSlotChange} style="display:none"></slot>`}
|
|
273
|
+
</div>
|
|
274
|
+
`;
|
|
275
|
+
}
|
|
276
|
+
};
|
|
277
|
+
NavItem.styles = navItemStyles;
|
|
278
|
+
__decorateClass([
|
|
279
|
+
property2()
|
|
280
|
+
], NavItem.prototype, "href", 2);
|
|
281
|
+
__decorateClass([
|
|
282
|
+
property2()
|
|
283
|
+
], NavItem.prototype, "label", 2);
|
|
284
|
+
__decorateClass([
|
|
285
|
+
property2({ attribute: "icon-start" })
|
|
286
|
+
], NavItem.prototype, "iconStart", 2);
|
|
287
|
+
__decorateClass([
|
|
288
|
+
property2({ type: Boolean, reflect: true })
|
|
289
|
+
], NavItem.prototype, "active", 2);
|
|
290
|
+
__decorateClass([
|
|
291
|
+
property2({ type: Boolean, reflect: true })
|
|
292
|
+
], NavItem.prototype, "disabled", 2);
|
|
293
|
+
__decorateClass([
|
|
294
|
+
property2({ type: Boolean, reflect: true })
|
|
295
|
+
], NavItem.prototype, "open", 2);
|
|
296
|
+
__decorateClass([
|
|
297
|
+
property2({ reflect: true })
|
|
298
|
+
], NavItem.prototype, "orientation", 2);
|
|
299
|
+
__decorateClass([
|
|
300
|
+
query(".children")
|
|
301
|
+
], NavItem.prototype, "_childrenEl", 2);
|
|
302
|
+
__decorateClass([
|
|
303
|
+
query(".children-inner")
|
|
304
|
+
], NavItem.prototype, "_childrenInnerEl", 2);
|
|
305
|
+
NavItem = __decorateClass([
|
|
306
|
+
customElement("lt-nav-item")
|
|
307
|
+
], NavItem);
|
|
308
|
+
|
|
309
|
+
// src/components/nav/nav.ts
|
|
310
|
+
var Nav = class extends ThemeableElement {
|
|
311
|
+
constructor() {
|
|
312
|
+
super(...arguments);
|
|
313
|
+
this.label = "";
|
|
314
|
+
this.orientation = "vertical";
|
|
315
|
+
}
|
|
316
|
+
_propagateOrientation() {
|
|
317
|
+
this.querySelectorAll(":scope > lt-nav-item").forEach((item) => {
|
|
318
|
+
item.setAttribute("orientation", this.orientation);
|
|
319
|
+
});
|
|
320
|
+
}
|
|
321
|
+
updated(changedProperties) {
|
|
322
|
+
if (changedProperties.has("orientation")) this._propagateOrientation();
|
|
323
|
+
}
|
|
324
|
+
render() {
|
|
325
|
+
return html2`
|
|
326
|
+
<nav role="navigation" aria-label=${this.label || nothing2}>
|
|
327
|
+
<slot @slotchange=${this._propagateOrientation}></slot>
|
|
328
|
+
</nav>
|
|
329
|
+
`;
|
|
330
|
+
}
|
|
331
|
+
};
|
|
332
|
+
Nav.styles = navStyles;
|
|
333
|
+
__decorateClass([
|
|
334
|
+
property3()
|
|
335
|
+
], Nav.prototype, "label", 2);
|
|
336
|
+
__decorateClass([
|
|
337
|
+
property3({ reflect: true })
|
|
338
|
+
], Nav.prototype, "orientation", 2);
|
|
339
|
+
Nav = __decorateClass([
|
|
340
|
+
customElement2("lt-nav")
|
|
341
|
+
], Nav);
|
|
342
|
+
export {
|
|
343
|
+
Nav,
|
|
344
|
+
NavItem
|
|
345
|
+
};
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import { ThemeableElement } from '../../base';
|
|
2
|
+
import { NavOrientation } from './nav.types';
|
|
3
|
+
import '@latty-ds/icons';
|
|
4
|
+
/**
|
|
5
|
+
* A single navigation item. Can render as an anchor link or a collapsible group header
|
|
6
|
+
* when children are slotted.
|
|
7
|
+
*
|
|
8
|
+
* When slotted inside `<lt-nav orientation="horizontal">`, top-level items lay out in a row
|
|
9
|
+
* and nested children appear as a dropdown panel. In vertical mode, nested children
|
|
10
|
+
* collapse/expand inline.
|
|
11
|
+
*
|
|
12
|
+
* @element lt-nav-item
|
|
13
|
+
*
|
|
14
|
+
* @fires {CustomEvent<{ href: string; label: string }>} nav-item-click - Fired when the item
|
|
15
|
+
* is clicked (even when it has no href).
|
|
16
|
+
* @fires {CustomEvent<{ open: boolean }>} nav-collapse - Fired when a collapsible item
|
|
17
|
+
* is opened or closed.
|
|
18
|
+
*
|
|
19
|
+
* @slot - Nested `<lt-nav-item>` children (makes this item a collapsible group)
|
|
20
|
+
*
|
|
21
|
+
* @example
|
|
22
|
+
* ```html
|
|
23
|
+
* <!-- Simple link -->
|
|
24
|
+
* <lt-nav-item href="/dashboard" label="Dashboard" icon-start="home"></lt-nav-item>
|
|
25
|
+
* ```
|
|
26
|
+
*
|
|
27
|
+
* @example
|
|
28
|
+
* ```html
|
|
29
|
+
* <!-- Collapsible group -->
|
|
30
|
+
* <lt-nav-item label="Settings" icon-start="settings">
|
|
31
|
+
* <lt-nav-item href="/settings/profile" label="Profile"></lt-nav-item>
|
|
32
|
+
* <lt-nav-item href="/settings/security" label="Security"></lt-nav-item>
|
|
33
|
+
* </lt-nav-item>
|
|
34
|
+
* ```
|
|
35
|
+
*/
|
|
36
|
+
export declare class NavItem extends ThemeableElement {
|
|
37
|
+
static styles: import("lit").CSSResult;
|
|
38
|
+
/** Destination URL. If omitted, the item acts as a group header. */
|
|
39
|
+
href: string;
|
|
40
|
+
/** Label text shown in the item. */
|
|
41
|
+
label: string;
|
|
42
|
+
/**
|
|
43
|
+
* Icon name (from the built-in Latty icon set) shown before the label.
|
|
44
|
+
* @default ''
|
|
45
|
+
*/
|
|
46
|
+
iconStart: string;
|
|
47
|
+
/**
|
|
48
|
+
* Whether this item is currently the active/selected page.
|
|
49
|
+
* @default false
|
|
50
|
+
*/
|
|
51
|
+
active: boolean;
|
|
52
|
+
/**
|
|
53
|
+
* Whether the item is disabled.
|
|
54
|
+
* @default false
|
|
55
|
+
*/
|
|
56
|
+
disabled: boolean;
|
|
57
|
+
/**
|
|
58
|
+
* Whether nested children are expanded. Only relevant when children are slotted.
|
|
59
|
+
* @default false
|
|
60
|
+
*/
|
|
61
|
+
open: boolean;
|
|
62
|
+
/** Set by the parent `<lt-nav>` — do not set manually. */
|
|
63
|
+
orientation: NavOrientation;
|
|
64
|
+
private _childrenEl?;
|
|
65
|
+
private _childrenInnerEl?;
|
|
66
|
+
private _hasChildren;
|
|
67
|
+
private _onSlotChange;
|
|
68
|
+
protected updated(changed: Map<string, unknown>): void;
|
|
69
|
+
private _handleTransitionEnd;
|
|
70
|
+
private _handleTriggerClick;
|
|
71
|
+
private _renderTrigger;
|
|
72
|
+
render(): import("lit").TemplateResult<1>;
|
|
73
|
+
}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { ThemeableElement } from '../../base';
|
|
2
|
+
import { NavOrientation } from './nav.types';
|
|
3
|
+
import './nav-item';
|
|
4
|
+
/**
|
|
5
|
+
* Navigation container. Renders a `<nav>` element wrapping a list of `<lt-nav-item>` links.
|
|
6
|
+
* Supports horizontal or vertical orientation and propagates the orientation to all
|
|
7
|
+
* `<lt-nav-item>` children so nested items behave correctly.
|
|
8
|
+
*
|
|
9
|
+
* @element lt-nav
|
|
10
|
+
*
|
|
11
|
+
* @slot - Slot for `<lt-nav-item>` elements
|
|
12
|
+
*
|
|
13
|
+
* @example
|
|
14
|
+
* ```html
|
|
15
|
+
* <!-- Vertical (default) -->
|
|
16
|
+
* <lt-nav>
|
|
17
|
+
* <lt-nav-item href="/" label="Home" icon-start="home"></lt-nav-item>
|
|
18
|
+
* <lt-nav-item href="/about" label="About"></lt-nav-item>
|
|
19
|
+
* </lt-nav>
|
|
20
|
+
* ```
|
|
21
|
+
*
|
|
22
|
+
* @example
|
|
23
|
+
* ```html
|
|
24
|
+
* <!-- Horizontal with nested dropdown -->
|
|
25
|
+
* <lt-nav orientation="horizontal">
|
|
26
|
+
* <lt-nav-item href="/" label="Home"></lt-nav-item>
|
|
27
|
+
* <lt-nav-item label="Products">
|
|
28
|
+
* <lt-nav-item href="/products/a" label="Product A"></lt-nav-item>
|
|
29
|
+
* <lt-nav-item href="/products/b" label="Product B"></lt-nav-item>
|
|
30
|
+
* </lt-nav-item>
|
|
31
|
+
* </lt-nav>
|
|
32
|
+
* ```
|
|
33
|
+
*/
|
|
34
|
+
export declare class Nav extends ThemeableElement {
|
|
35
|
+
static styles: import("lit").CSSResult;
|
|
36
|
+
/**
|
|
37
|
+
* Accessible label for the navigation region. Required when multiple nav elements appear on one page.
|
|
38
|
+
* @default ''
|
|
39
|
+
*/
|
|
40
|
+
label: string;
|
|
41
|
+
/**
|
|
42
|
+
* Layout direction of the navigation.
|
|
43
|
+
* @default 'vertical'
|
|
44
|
+
*/
|
|
45
|
+
orientation: NavOrientation;
|
|
46
|
+
private _propagateOrientation;
|
|
47
|
+
protected updated(changedProperties: Map<string, unknown>): void;
|
|
48
|
+
render(): import("lit").TemplateResult<1>;
|
|
49
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export type NavOrientation = 'horizontal' | 'vertical';
|
|
@@ -0,0 +1,210 @@
|
|
|
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/pagination/pagination.ts
|
|
13
|
+
import { html, nothing } 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/pagination/pagination.ts
|
|
38
|
+
import { customElement, property as property2 } from "lit/decorators.js";
|
|
39
|
+
|
|
40
|
+
// src/components/pagination/pagination.styles.ts
|
|
41
|
+
import { css } from "lit";
|
|
42
|
+
var paginationStyles = css`
|
|
43
|
+
:host {
|
|
44
|
+
display: inline-flex;
|
|
45
|
+
font-family: 'Hanken Grotesk', sans-serif;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
nav {
|
|
49
|
+
align-items: center;
|
|
50
|
+
display: flex;
|
|
51
|
+
gap: var(--lt-spacing-1);
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
button {
|
|
55
|
+
align-items: center;
|
|
56
|
+
background: transparent;
|
|
57
|
+
border-radius: var(--lt-border-radius);
|
|
58
|
+
border: 1px solid transparent;
|
|
59
|
+
color: var(--lt-text-default);
|
|
60
|
+
cursor: pointer;
|
|
61
|
+
display: inline-flex;
|
|
62
|
+
font-family: inherit;
|
|
63
|
+
font-weight: 500;
|
|
64
|
+
justify-content: center;
|
|
65
|
+
line-height: 1;
|
|
66
|
+
transition:
|
|
67
|
+
background 120ms ease,
|
|
68
|
+
border-color 120ms ease,
|
|
69
|
+
color 120ms ease;
|
|
70
|
+
user-select: none;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
/* Sizes */
|
|
74
|
+
:host([size='sm']) button {
|
|
75
|
+
font-size: 0.75rem;
|
|
76
|
+
height: 28px;
|
|
77
|
+
min-width: 28px;
|
|
78
|
+
padding: 0 var(--lt-spacing-1);
|
|
79
|
+
}
|
|
80
|
+
:host([size='md']) button,
|
|
81
|
+
:host(:not([size])) button {
|
|
82
|
+
font-size: 0.8125rem;
|
|
83
|
+
height: 36px;
|
|
84
|
+
min-width: 36px;
|
|
85
|
+
padding: 0 var(--lt-spacing-2);
|
|
86
|
+
}
|
|
87
|
+
:host([size='lg']) button {
|
|
88
|
+
font-size: 0.9375rem;
|
|
89
|
+
height: 44px;
|
|
90
|
+
min-width: 44px;
|
|
91
|
+
padding: 0 var(--lt-spacing-3);
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
button:hover:not(:disabled) {
|
|
95
|
+
background: var(--lt-bg-neutral-subtle);
|
|
96
|
+
border-color: var(--lt-border-default);
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
button[aria-current='page'] {
|
|
100
|
+
background: var(--lt-bg-primary-subtle);
|
|
101
|
+
border-color: var(--lt-border-primary);
|
|
102
|
+
color: var(--lt-color-primary-700);
|
|
103
|
+
font-weight: 600;
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
button.ellipsis {
|
|
107
|
+
cursor: default;
|
|
108
|
+
pointer-events: none;
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
button:disabled {
|
|
112
|
+
color: var(--lt-color-neutral-400);
|
|
113
|
+
cursor: not-allowed;
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
:host([disabled]) button {
|
|
117
|
+
color: var(--lt-color-neutral-400);
|
|
118
|
+
cursor: not-allowed;
|
|
119
|
+
pointer-events: none;
|
|
120
|
+
}
|
|
121
|
+
`;
|
|
122
|
+
|
|
123
|
+
// src/utils/dispatch.ts
|
|
124
|
+
var dispatch = (host, name, detail, init) => host.dispatchEvent(new CustomEvent(name, { detail, bubbles: true, composed: true, ...init }));
|
|
125
|
+
|
|
126
|
+
// src/components/pagination/pagination.ts
|
|
127
|
+
import "@latty-ds/icons";
|
|
128
|
+
var Pagination = class extends ThemeableElement {
|
|
129
|
+
constructor() {
|
|
130
|
+
super(...arguments);
|
|
131
|
+
this.page = 1;
|
|
132
|
+
this.totalPages = 1;
|
|
133
|
+
this.size = "md";
|
|
134
|
+
this.disabled = false;
|
|
135
|
+
}
|
|
136
|
+
_go(page) {
|
|
137
|
+
if (this.disabled || page < 1 || page > this.totalPages || page === this.page) return;
|
|
138
|
+
this.page = page;
|
|
139
|
+
dispatch(this, "change", { page });
|
|
140
|
+
}
|
|
141
|
+
_pages() {
|
|
142
|
+
const total = this.totalPages;
|
|
143
|
+
const current = this.page;
|
|
144
|
+
if (total <= 7) return Array.from({ length: total }, (_, i) => i + 1);
|
|
145
|
+
const pages = [1];
|
|
146
|
+
if (current > 3) pages.push("\u2026");
|
|
147
|
+
const start = Math.max(2, current - 1);
|
|
148
|
+
const end = Math.min(total - 1, current + 1);
|
|
149
|
+
for (let i = start; i <= end; i++) pages.push(i);
|
|
150
|
+
if (current < total - 2) pages.push("\u2026");
|
|
151
|
+
pages.push(total);
|
|
152
|
+
return pages;
|
|
153
|
+
}
|
|
154
|
+
render() {
|
|
155
|
+
const pages = this._pages();
|
|
156
|
+
const atFirst = this.page <= 1;
|
|
157
|
+
const atLast = this.page >= this.totalPages;
|
|
158
|
+
return html`
|
|
159
|
+
<nav aria-label="Pagination">
|
|
160
|
+
<button aria-label="First page" ?disabled=${atFirst || this.disabled} @click=${() => this._go(1)}>
|
|
161
|
+
<lt-icon name="double-nav-arrow-left" size="sm"></lt-icon>
|
|
162
|
+
</button>
|
|
163
|
+
<button
|
|
164
|
+
aria-label="Previous page"
|
|
165
|
+
?disabled=${atFirst || this.disabled}
|
|
166
|
+
@click=${() => this._go(this.page - 1)}
|
|
167
|
+
>
|
|
168
|
+
<lt-icon name="nav-arrow-left" size="sm"></lt-icon>
|
|
169
|
+
</button>
|
|
170
|
+
|
|
171
|
+
${pages.map(
|
|
172
|
+
(p) => p === "\u2026" ? html`<button class="ellipsis" aria-hidden="true" tabindex="-1">…</button>` : html`<button
|
|
173
|
+
aria-label="Page ${p}"
|
|
174
|
+
aria-current=${p === this.page ? "page" : nothing}
|
|
175
|
+
?disabled=${this.disabled}
|
|
176
|
+
@click=${() => this._go(p)}
|
|
177
|
+
>
|
|
178
|
+
${p}
|
|
179
|
+
</button>`
|
|
180
|
+
)}
|
|
181
|
+
|
|
182
|
+
<button aria-label="Next page" ?disabled=${atLast || this.disabled} @click=${() => this._go(this.page + 1)}>
|
|
183
|
+
<lt-icon name="nav-arrow-right" size="sm"></lt-icon>
|
|
184
|
+
</button>
|
|
185
|
+
<button aria-label="Last page" ?disabled=${atLast || this.disabled} @click=${() => this._go(this.totalPages)}>
|
|
186
|
+
<lt-icon name="double-nav-arrow-right" size="sm"></lt-icon>
|
|
187
|
+
</button>
|
|
188
|
+
</nav>
|
|
189
|
+
`;
|
|
190
|
+
}
|
|
191
|
+
};
|
|
192
|
+
Pagination.styles = paginationStyles;
|
|
193
|
+
__decorateClass([
|
|
194
|
+
property2({ type: Number, reflect: true })
|
|
195
|
+
], Pagination.prototype, "page", 2);
|
|
196
|
+
__decorateClass([
|
|
197
|
+
property2({ type: Number, attribute: "total-pages", reflect: true })
|
|
198
|
+
], Pagination.prototype, "totalPages", 2);
|
|
199
|
+
__decorateClass([
|
|
200
|
+
property2({ reflect: true })
|
|
201
|
+
], Pagination.prototype, "size", 2);
|
|
202
|
+
__decorateClass([
|
|
203
|
+
property2({ type: Boolean, reflect: true })
|
|
204
|
+
], Pagination.prototype, "disabled", 2);
|
|
205
|
+
Pagination = __decorateClass([
|
|
206
|
+
customElement("lt-pagination")
|
|
207
|
+
], Pagination);
|
|
208
|
+
export {
|
|
209
|
+
Pagination
|
|
210
|
+
};
|