@arclux/arc-ui 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 +21 -0
- package/README.md +64 -0
- package/package.json +186 -0
- package/src/content/accordion-item.js +27 -0
- package/src/content/accordion.js +151 -0
- package/src/content/animated-number.js +160 -0
- package/src/content/aspect-ratio.js +78 -0
- package/src/content/avatar-group.js +101 -0
- package/src/content/avatar.js +92 -0
- package/src/content/badge.js +98 -0
- package/src/content/callout.js +141 -0
- package/src/content/card.js +75 -0
- package/src/content/carousel.js +300 -0
- package/src/content/code-block.js +152 -0
- package/src/content/collapsible.js +142 -0
- package/src/content/color-swatch.js +86 -0
- package/src/content/column.js +28 -0
- package/src/content/data-table.js +332 -0
- package/src/content/divider.js +153 -0
- package/src/content/empty-state.js +78 -0
- package/src/content/feature-card.js +142 -0
- package/src/content/highlight.js +63 -0
- package/src/content/icon-library.js +30 -0
- package/src/content/icon-registry.js +39 -0
- package/src/content/icon.js +95 -0
- package/src/content/index.js +44 -0
- package/src/content/infinite-scroll.js +144 -0
- package/src/content/kbd.js +40 -0
- package/src/content/markdown.js +294 -0
- package/src/content/marquee.js +166 -0
- package/src/content/meter.js +167 -0
- package/src/content/scroll-area.js +107 -0
- package/src/content/skeleton.js +85 -0
- package/src/content/spinner.js +77 -0
- package/src/content/stack.js +68 -0
- package/src/content/stat.js +72 -0
- package/src/content/step.js +22 -0
- package/src/content/stepper.js +202 -0
- package/src/content/table.js +134 -0
- package/src/content/tag.js +156 -0
- package/src/content/text.js +111 -0
- package/src/content/timeline-item.js +29 -0
- package/src/content/timeline.js +170 -0
- package/src/content/truncate.js +161 -0
- package/src/content/value-card.js +94 -0
- package/src/feedback/alert.js +187 -0
- package/src/feedback/command-item.js +28 -0
- package/src/feedback/command-palette.js +346 -0
- package/src/feedback/context-menu.js +299 -0
- package/src/feedback/dialog.js +298 -0
- package/src/feedback/dropdown-menu.js +259 -0
- package/src/feedback/hover-card.js +186 -0
- package/src/feedback/index.js +17 -0
- package/src/feedback/modal.js +226 -0
- package/src/feedback/notification-panel.js +196 -0
- package/src/feedback/popover.js +184 -0
- package/src/feedback/progress.js +169 -0
- package/src/feedback/sheet.js +249 -0
- package/src/feedback/toast.js +207 -0
- package/src/feedback/tooltip.js +189 -0
- package/src/icons/lucide.d.ts +1915 -0
- package/src/icons/lucide.js +1915 -0
- package/src/icons/phosphor.d.ts +1517 -0
- package/src/icons/phosphor.js +1517 -0
- package/src/icons/types.d.ts +8 -0
- package/src/index.js +9 -0
- package/src/input/button.js +127 -0
- package/src/input/calendar.js +340 -0
- package/src/input/checkbox.js +159 -0
- package/src/input/chip.js +120 -0
- package/src/input/color-picker.js +461 -0
- package/src/input/combobox.js +295 -0
- package/src/input/copy-button.js +144 -0
- package/src/input/date-picker.js +534 -0
- package/src/input/file-upload.js +333 -0
- package/src/input/form.js +179 -0
- package/src/input/icon-button.js +179 -0
- package/src/input/index.js +31 -0
- package/src/input/input.js +158 -0
- package/src/input/multi-select.js +392 -0
- package/src/input/number-input.js +239 -0
- package/src/input/otp-input.js +221 -0
- package/src/input/pin-input.js +294 -0
- package/src/input/radio-group.js +177 -0
- package/src/input/radio.js +28 -0
- package/src/input/rating.js +195 -0
- package/src/input/search.js +371 -0
- package/src/input/segmented-control.js +174 -0
- package/src/input/select.js +267 -0
- package/src/input/slider.js +217 -0
- package/src/input/sortable-list.js +345 -0
- package/src/input/suggestion.js +26 -0
- package/src/input/textarea.js +203 -0
- package/src/input/theme-toggle.js +196 -0
- package/src/input/toggle.js +166 -0
- package/src/layout/app-shell.js +266 -0
- package/src/layout/auth-shell.js +153 -0
- package/src/layout/container.js +37 -0
- package/src/layout/dashboard-grid.js +62 -0
- package/src/layout/index.js +15 -0
- package/src/layout/page-header.js +100 -0
- package/src/layout/page-layout.js +112 -0
- package/src/layout/resizable.js +221 -0
- package/src/layout/section.js +54 -0
- package/src/layout/settings-layout.js +91 -0
- package/src/layout/split-pane.js +172 -0
- package/src/layout/status-bar.js +84 -0
- package/src/layout/toolbar.js +92 -0
- package/src/navigation/breadcrumb-item.js +26 -0
- package/src/navigation/breadcrumb.js +129 -0
- package/src/navigation/drawer.js +183 -0
- package/src/navigation/footer.js +99 -0
- package/src/navigation/index.js +22 -0
- package/src/navigation/link.js +120 -0
- package/src/navigation/nav-item.js +46 -0
- package/src/navigation/navigation-menu.js +687 -0
- package/src/navigation/pagination.js +186 -0
- package/src/navigation/scroll-spy.js +198 -0
- package/src/navigation/scroll-to-top.js +163 -0
- package/src/navigation/sidebar-link.js +28 -0
- package/src/navigation/sidebar-section.js +45 -0
- package/src/navigation/sidebar.js +336 -0
- package/src/navigation/spy-link.js +26 -0
- package/src/navigation/tab.js +26 -0
- package/src/navigation/tabs.js +202 -0
- package/src/navigation/top-bar.js +263 -0
- package/src/navigation/tree-item.js +38 -0
- package/src/navigation/tree-view.js +255 -0
- package/src/shared/index.js +6 -0
- package/src/shared/menu-divider.js +9 -0
- package/src/shared/menu-item.js +30 -0
- package/src/shared/option.js +31 -0
- package/src/shared-styles.js +81 -0
- package/src/tokens.js +445 -0
- package/types/index.d.ts +973 -0
|
@@ -0,0 +1,263 @@
|
|
|
1
|
+
import { LitElement, html, css } from 'lit';
|
|
2
|
+
import { tokenStyles } from '../shared-styles.js';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* @arc-prism hybrid — display works without JS; mobile menu toggle requires JS
|
|
6
|
+
*/
|
|
7
|
+
export class ArcTopBar extends LitElement {
|
|
8
|
+
static properties = {
|
|
9
|
+
heading: { type: String },
|
|
10
|
+
fixed: { type: Boolean, reflect: true },
|
|
11
|
+
menuOpen: { type: Boolean, attribute: 'menu-open', reflect: true },
|
|
12
|
+
mobileMenu: { type: String, attribute: 'mobile-menu' },
|
|
13
|
+
menuPosition: { type: String, attribute: 'menu-position' },
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
static styles = [
|
|
17
|
+
tokenStyles,
|
|
18
|
+
css`
|
|
19
|
+
:host {
|
|
20
|
+
display: block;
|
|
21
|
+
width: 100%;
|
|
22
|
+
z-index: 100;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
:host([fixed]) {
|
|
26
|
+
position: fixed;
|
|
27
|
+
top: 0;
|
|
28
|
+
left: 0;
|
|
29
|
+
right: 0;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
.topbar {
|
|
33
|
+
position: relative;
|
|
34
|
+
display: flex;
|
|
35
|
+
align-items: center;
|
|
36
|
+
height: var(--nav-height);
|
|
37
|
+
padding: 0 var(--space-lg);
|
|
38
|
+
background: color-mix(in srgb, var(--bg-deep) 85%, transparent);
|
|
39
|
+
backdrop-filter: blur(12px) saturate(130%);
|
|
40
|
+
-webkit-backdrop-filter: blur(12px) saturate(130%);
|
|
41
|
+
border-bottom: 1px solid var(--border-subtle);
|
|
42
|
+
gap: var(--space-md);
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
.topbar__glow {
|
|
46
|
+
position: absolute;
|
|
47
|
+
bottom: -1px;
|
|
48
|
+
left: 20%;
|
|
49
|
+
right: 20%;
|
|
50
|
+
height: 1px;
|
|
51
|
+
background: linear-gradient(90deg, transparent, rgba(var(--accent-secondary-rgb), 0.2), rgba(var(--accent-primary-rgb), 0.15), transparent);
|
|
52
|
+
opacity: 0;
|
|
53
|
+
transition: opacity var(--transition-slow);
|
|
54
|
+
pointer-events: none;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
:host([scrolled]) .topbar__glow {
|
|
58
|
+
opacity: 1;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
.topbar__brand {
|
|
62
|
+
display: flex;
|
|
63
|
+
align-items: center;
|
|
64
|
+
gap: var(--space-sm);
|
|
65
|
+
color: var(--text-primary);
|
|
66
|
+
text-decoration: none;
|
|
67
|
+
flex: 0 0 auto;
|
|
68
|
+
overflow: visible;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
.topbar__heading {
|
|
72
|
+
font-family: var(--font-body);
|
|
73
|
+
font-size: var(--wordmark-size);
|
|
74
|
+
font-weight: var(--wordmark-weight);
|
|
75
|
+
letter-spacing: var(--wordmark-spacing);
|
|
76
|
+
text-transform: uppercase;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
.topbar__center {
|
|
80
|
+
flex: 1;
|
|
81
|
+
display: flex;
|
|
82
|
+
align-items: center;
|
|
83
|
+
justify-content: center;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
.topbar__actions {
|
|
87
|
+
display: flex;
|
|
88
|
+
align-items: center;
|
|
89
|
+
gap: var(--space-sm);
|
|
90
|
+
flex-shrink: 0;
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
.topbar__menu-btn {
|
|
94
|
+
display: none;
|
|
95
|
+
align-items: center;
|
|
96
|
+
justify-content: center;
|
|
97
|
+
width: 36px;
|
|
98
|
+
height: 36px;
|
|
99
|
+
min-width: 36px;
|
|
100
|
+
aspect-ratio: 1;
|
|
101
|
+
background: none;
|
|
102
|
+
border: 1px solid var(--border-subtle);
|
|
103
|
+
color: var(--text-primary);
|
|
104
|
+
cursor: pointer;
|
|
105
|
+
padding: 0;
|
|
106
|
+
border-radius: var(--radius-sm);
|
|
107
|
+
transition: background var(--transition-fast), border-color var(--transition-fast), box-shadow var(--transition-fast);
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
.topbar__menu-btn:hover {
|
|
111
|
+
background: var(--bg-hover);
|
|
112
|
+
border-color: var(--border-default);
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
.topbar__menu-btn:focus-visible {
|
|
116
|
+
outline: none;
|
|
117
|
+
box-shadow: var(--focus-glow);
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
.topbar__menu-btn--open {
|
|
121
|
+
border-color: rgba(var(--accent-primary-rgb), 0.3);
|
|
122
|
+
background: rgba(var(--accent-primary-rgb), 0.06);
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
.topbar__hamburger {
|
|
126
|
+
width: 16px;
|
|
127
|
+
height: 12px;
|
|
128
|
+
position: relative;
|
|
129
|
+
display: flex;
|
|
130
|
+
flex-direction: column;
|
|
131
|
+
justify-content: space-between;
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
.topbar__hamburger-line {
|
|
135
|
+
display: block;
|
|
136
|
+
width: 100%;
|
|
137
|
+
height: 1.5px;
|
|
138
|
+
background: currentColor;
|
|
139
|
+
border-radius: 1px; /* cosmetic rounding on 1.5px hamburger lines -- intentionally not tokenized */
|
|
140
|
+
transition: transform 400ms var(--ease-out-expo), opacity 250ms ease, width 400ms var(--ease-out-expo);
|
|
141
|
+
transform-origin: center;
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
.topbar__hamburger-line:nth-child(2) {
|
|
145
|
+
width: 100%;
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
.topbar__menu-btn--open .topbar__hamburger-line:nth-child(1) {
|
|
149
|
+
transform: translateY(5.25px) rotate(45deg);
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
.topbar__menu-btn--open .topbar__hamburger-line:nth-child(2) {
|
|
153
|
+
opacity: 0;
|
|
154
|
+
width: 0;
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
.topbar__menu-btn--open .topbar__hamburger-line:nth-child(3) {
|
|
158
|
+
transform: translateY(-5.25px) rotate(-45deg);
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
@media (max-width: 900px) {
|
|
162
|
+
.topbar__menu-btn { display: flex; }
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
@media (prefers-reduced-motion: reduce) {
|
|
166
|
+
:host *,
|
|
167
|
+
:host *::before,
|
|
168
|
+
:host *::after {
|
|
169
|
+
animation-duration: 0.01ms !important;
|
|
170
|
+
animation-iteration-count: 1 !important;
|
|
171
|
+
transition-duration: 0.01ms !important;
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
`,
|
|
175
|
+
];
|
|
176
|
+
|
|
177
|
+
constructor() {
|
|
178
|
+
super();
|
|
179
|
+
this.heading = '';
|
|
180
|
+
this.fixed = false;
|
|
181
|
+
this.menuOpen = false;
|
|
182
|
+
this.mobileMenu = 'sidebar';
|
|
183
|
+
this.menuPosition = 'left';
|
|
184
|
+
this._onExternalToggle = this._onExternalToggle.bind(this);
|
|
185
|
+
this._onScroll = this._onScroll.bind(this);
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
connectedCallback() {
|
|
189
|
+
super.connectedCallback();
|
|
190
|
+
document.addEventListener('arc-mobile-menu-toggle', this._onExternalToggle);
|
|
191
|
+
window.addEventListener('scroll', this._onScroll, { passive: true });
|
|
192
|
+
this._onScroll();
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
disconnectedCallback() {
|
|
196
|
+
super.disconnectedCallback();
|
|
197
|
+
document.removeEventListener('arc-mobile-menu-toggle', this._onExternalToggle);
|
|
198
|
+
window.removeEventListener('scroll', this._onScroll);
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
_onScroll() {
|
|
202
|
+
this.toggleAttribute('scrolled', window.scrollY > 20);
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
_onExternalToggle(e) {
|
|
206
|
+
if (this.mobileMenu !== 'nav') return;
|
|
207
|
+
if (e.target === this) return;
|
|
208
|
+
this.menuOpen = e.detail?.value ?? !this.menuOpen;
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
_toggleMenu() {
|
|
212
|
+
this.menuOpen = !this.menuOpen;
|
|
213
|
+
const eventName = this.mobileMenu === 'nav' ? 'arc-mobile-menu-toggle' : 'arc-toggle';
|
|
214
|
+
this.dispatchEvent(new CustomEvent(eventName, {
|
|
215
|
+
detail: { value: this.menuOpen },
|
|
216
|
+
bubbles: true,
|
|
217
|
+
composed: true,
|
|
218
|
+
}));
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
_renderMenuButton() {
|
|
222
|
+
return html`
|
|
223
|
+
<button
|
|
224
|
+
class="topbar__menu-btn ${this.menuOpen ? 'topbar__menu-btn--open' : ''}"
|
|
225
|
+
@click=${this._toggleMenu}
|
|
226
|
+
aria-label="Toggle menu"
|
|
227
|
+
aria-expanded=${this.menuOpen ? 'true' : 'false'}
|
|
228
|
+
part="menu-btn"
|
|
229
|
+
>
|
|
230
|
+
<span class="topbar__hamburger">
|
|
231
|
+
<span class="topbar__hamburger-line"></span>
|
|
232
|
+
<span class="topbar__hamburger-line"></span>
|
|
233
|
+
<span class="topbar__hamburger-line"></span>
|
|
234
|
+
</span>
|
|
235
|
+
</button>
|
|
236
|
+
`;
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
render() {
|
|
240
|
+
const menuLeft = this.menuPosition !== 'right';
|
|
241
|
+
|
|
242
|
+
return html`
|
|
243
|
+
<header class="topbar" part="topbar">
|
|
244
|
+
${menuLeft ? this._renderMenuButton() : ''}
|
|
245
|
+
<a class="topbar__brand" href="/" part="brand">
|
|
246
|
+
<slot name="logo"></slot>
|
|
247
|
+
${this.heading ? html`<span class="topbar__heading">${this.heading}</span>` : ''}
|
|
248
|
+
<slot name="subtitle"></slot>
|
|
249
|
+
</a>
|
|
250
|
+
<div class="topbar__center" part="center">
|
|
251
|
+
<slot name="center"></slot>
|
|
252
|
+
</div>
|
|
253
|
+
<div class="topbar__actions" part="actions">
|
|
254
|
+
<slot name="actions"></slot>
|
|
255
|
+
</div>
|
|
256
|
+
${!menuLeft ? this._renderMenuButton() : ''}
|
|
257
|
+
<div class="topbar__glow"></div>
|
|
258
|
+
</header>
|
|
259
|
+
`;
|
|
260
|
+
}
|
|
261
|
+
}
|
|
262
|
+
|
|
263
|
+
customElements.define('arc-top-bar', ArcTopBar);
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { LitElement, html, css } from 'lit';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* @arc-prism interactive — tree item, child of arc-tree-view
|
|
5
|
+
*/
|
|
6
|
+
export class ArcTreeItem extends LitElement {
|
|
7
|
+
static properties = {
|
|
8
|
+
label: { type: String, reflect: true },
|
|
9
|
+
icon: { type: String },
|
|
10
|
+
expanded: { type: Boolean, reflect: true },
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
static styles = css`
|
|
14
|
+
:host { display: contents; }
|
|
15
|
+
`;
|
|
16
|
+
|
|
17
|
+
constructor() {
|
|
18
|
+
super();
|
|
19
|
+
this.label = '';
|
|
20
|
+
this.icon = '';
|
|
21
|
+
this.expanded = false;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
/** Nested arc-tree-item children */
|
|
25
|
+
get items() {
|
|
26
|
+
return [...this.querySelectorAll(':scope > arc-tree-item')];
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
get hasChildren() {
|
|
30
|
+
return this.items.length > 0;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
render() {
|
|
34
|
+
return html`<slot></slot>`;
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
customElements.define('arc-tree-item', ArcTreeItem);
|
|
@@ -0,0 +1,255 @@
|
|
|
1
|
+
import { LitElement, html, css } from 'lit';
|
|
2
|
+
import { tokenStyles } from '../shared-styles.js';
|
|
3
|
+
import './tree-item.js';
|
|
4
|
+
|
|
5
|
+
export class ArcTreeView extends LitElement {
|
|
6
|
+
static properties = {
|
|
7
|
+
_items: { state: true },
|
|
8
|
+
_selected: { state: true },
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
static styles = [
|
|
12
|
+
tokenStyles,
|
|
13
|
+
css`
|
|
14
|
+
:host {
|
|
15
|
+
display: block;
|
|
16
|
+
font-family: var(--font-body);
|
|
17
|
+
color: var(--text-primary);
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
.tree {
|
|
21
|
+
list-style: none;
|
|
22
|
+
margin: 0;
|
|
23
|
+
padding: 0;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
.tree__group {
|
|
27
|
+
list-style: none;
|
|
28
|
+
margin: 0;
|
|
29
|
+
padding: 0;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
.tree__item {
|
|
33
|
+
position: relative;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
.tree__row {
|
|
37
|
+
display: flex;
|
|
38
|
+
align-items: center;
|
|
39
|
+
gap: var(--space-xs);
|
|
40
|
+
width: 100%;
|
|
41
|
+
text-align: left;
|
|
42
|
+
font-family: var(--font-body);
|
|
43
|
+
font-size: var(--text-sm);
|
|
44
|
+
color: var(--text-secondary);
|
|
45
|
+
background: none;
|
|
46
|
+
border: none;
|
|
47
|
+
padding: var(--space-xs) var(--space-sm);
|
|
48
|
+
border-radius: var(--radius-sm);
|
|
49
|
+
cursor: pointer;
|
|
50
|
+
transition: background var(--transition-fast), color var(--transition-fast);
|
|
51
|
+
white-space: nowrap;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
.tree__row:hover {
|
|
55
|
+
color: var(--text-primary);
|
|
56
|
+
background: rgba(var(--accent-primary-rgb), 0.04);
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
.tree__row--selected {
|
|
60
|
+
color: var(--accent-primary);
|
|
61
|
+
background: rgba(var(--accent-primary-rgb), 0.1);
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
.tree__row:focus-visible {
|
|
65
|
+
outline: none;
|
|
66
|
+
box-shadow: var(--focus-glow);
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
.tree__chevron {
|
|
70
|
+
display: inline-flex;
|
|
71
|
+
align-items: center;
|
|
72
|
+
justify-content: center;
|
|
73
|
+
width: 16px;
|
|
74
|
+
height: 16px;
|
|
75
|
+
flex-shrink: 0;
|
|
76
|
+
transition: transform var(--transition-fast);
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
.tree__chevron--expanded {
|
|
80
|
+
transform: rotate(90deg);
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
.tree__chevron--placeholder {
|
|
84
|
+
visibility: hidden;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
.tree__icon {
|
|
88
|
+
display: inline-flex;
|
|
89
|
+
flex-shrink: 0;
|
|
90
|
+
font-size: var(--text-sm);
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
.tree__label {
|
|
94
|
+
flex: 1;
|
|
95
|
+
overflow: hidden;
|
|
96
|
+
text-overflow: ellipsis;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
.tree__line {
|
|
100
|
+
position: absolute;
|
|
101
|
+
left: 11px;
|
|
102
|
+
top: 0;
|
|
103
|
+
bottom: 0;
|
|
104
|
+
width: 1px;
|
|
105
|
+
background: var(--border-subtle);
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
.tree__slot-host { display: none; }
|
|
109
|
+
|
|
110
|
+
@media (prefers-reduced-motion: reduce) {
|
|
111
|
+
:host *,
|
|
112
|
+
:host *::before,
|
|
113
|
+
:host *::after {
|
|
114
|
+
animation-duration: 0.01ms !important;
|
|
115
|
+
animation-iteration-count: 1 !important;
|
|
116
|
+
transition-duration: 0.01ms !important;
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
`,
|
|
120
|
+
];
|
|
121
|
+
|
|
122
|
+
constructor() {
|
|
123
|
+
super();
|
|
124
|
+
this._items = [];
|
|
125
|
+
this._selected = null;
|
|
126
|
+
this._expandedSet = new Set();
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
_onSlotChange(e) {
|
|
130
|
+
this._items = e.target.assignedElements({ flatten: true })
|
|
131
|
+
.filter(el => el.tagName === 'ARC-TREE-ITEM');
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
_isExpanded(item) {
|
|
135
|
+
const key = item.label;
|
|
136
|
+
if (this._expandedSet.has(key)) return true;
|
|
137
|
+
return item.expanded === true && !this._expandedSet.has(`collapsed:${key}`);
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
_toggleExpand(item, e) {
|
|
141
|
+
e.stopPropagation();
|
|
142
|
+
const key = item.label;
|
|
143
|
+
const wasExpanded = this._isExpanded(item);
|
|
144
|
+
|
|
145
|
+
if (wasExpanded) {
|
|
146
|
+
this._expandedSet.delete(key);
|
|
147
|
+
this._expandedSet.add(`collapsed:${key}`);
|
|
148
|
+
} else {
|
|
149
|
+
this._expandedSet.add(key);
|
|
150
|
+
this._expandedSet.delete(`collapsed:${key}`);
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
this.dispatchEvent(new CustomEvent('arc-toggle', {
|
|
154
|
+
detail: { item: { label: item.label, icon: item.icon }, expanded: !wasExpanded },
|
|
155
|
+
bubbles: true,
|
|
156
|
+
composed: true,
|
|
157
|
+
}));
|
|
158
|
+
|
|
159
|
+
this.requestUpdate();
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
_selectItem(item, path) {
|
|
163
|
+
this._selected = item.label;
|
|
164
|
+
|
|
165
|
+
this.dispatchEvent(new CustomEvent('arc-select', {
|
|
166
|
+
detail: { item: { label: item.label, icon: item.icon }, path },
|
|
167
|
+
bubbles: true,
|
|
168
|
+
composed: true,
|
|
169
|
+
}));
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
_onKeyDown(e, item, path, hasChildren) {
|
|
173
|
+
switch (e.key) {
|
|
174
|
+
case 'ArrowRight':
|
|
175
|
+
if (hasChildren && !this._isExpanded(item)) {
|
|
176
|
+
this._toggleExpand(item, e);
|
|
177
|
+
}
|
|
178
|
+
break;
|
|
179
|
+
case 'ArrowLeft':
|
|
180
|
+
if (hasChildren && this._isExpanded(item)) {
|
|
181
|
+
this._toggleExpand(item, e);
|
|
182
|
+
}
|
|
183
|
+
break;
|
|
184
|
+
case 'ArrowDown': {
|
|
185
|
+
e.preventDefault();
|
|
186
|
+
const rows = [...this.shadowRoot.querySelectorAll('.tree__row')];
|
|
187
|
+
const idx = rows.indexOf(e.target);
|
|
188
|
+
if (idx < rows.length - 1) rows[idx + 1].focus();
|
|
189
|
+
break;
|
|
190
|
+
}
|
|
191
|
+
case 'ArrowUp': {
|
|
192
|
+
e.preventDefault();
|
|
193
|
+
const rows = [...this.shadowRoot.querySelectorAll('.tree__row')];
|
|
194
|
+
const idx = rows.indexOf(e.target);
|
|
195
|
+
if (idx > 0) rows[idx - 1].focus();
|
|
196
|
+
break;
|
|
197
|
+
}
|
|
198
|
+
case 'Enter':
|
|
199
|
+
case ' ':
|
|
200
|
+
e.preventDefault();
|
|
201
|
+
this._selectItem(item, path);
|
|
202
|
+
break;
|
|
203
|
+
}
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
_renderItems(items, level = 0, parentPath = []) {
|
|
207
|
+
return html`
|
|
208
|
+
<ul class="${level === 0 ? 'tree' : 'tree__group'}" role="${level === 0 ? 'tree' : 'group'}" part="${level === 0 ? 'tree' : 'group'}">
|
|
209
|
+
${(items || []).map((item, idx) => {
|
|
210
|
+
const children = item.items;
|
|
211
|
+
const hasChildren = children.length > 0;
|
|
212
|
+
const expanded = this._isExpanded(item);
|
|
213
|
+
const isSelected = this._selected === item.label;
|
|
214
|
+
const path = [...parentPath, item.label];
|
|
215
|
+
|
|
216
|
+
return html`
|
|
217
|
+
<li class="tree__item" role="treeitem" aria-expanded=${hasChildren ? String(expanded) : undefined} part="item">
|
|
218
|
+
${level > 0 ? html`<div class="tree__line" style="left: ${level * 16 + 3}px"></div>` : ''}
|
|
219
|
+
<button
|
|
220
|
+
class="tree__row ${isSelected ? 'tree__row--selected' : ''}"
|
|
221
|
+
style="padding-left: ${level * 16 + 8}px"
|
|
222
|
+
tabindex=${level === 0 && idx === 0 ? '0' : '-1'}
|
|
223
|
+
@click=${(e) => { this._selectItem(item, path); if (hasChildren) this._toggleExpand(item, e); }}
|
|
224
|
+
@keydown=${(e) => this._onKeyDown(e, item, path, hasChildren)}
|
|
225
|
+
part="row"
|
|
226
|
+
>
|
|
227
|
+
<span class="tree__chevron ${hasChildren ? (expanded ? 'tree__chevron--expanded' : '') : 'tree__chevron--placeholder'}">
|
|
228
|
+
${hasChildren ? html`
|
|
229
|
+
<svg width="10" height="10" viewBox="0 0 10 10" fill="none" aria-hidden="true">
|
|
230
|
+
<path d="M3 1.5L7 5L3 8.5" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"/>
|
|
231
|
+
</svg>
|
|
232
|
+
` : ''}
|
|
233
|
+
</span>
|
|
234
|
+
${item.icon ? html`<span class="tree__icon">${item.icon}</span>` : ''}
|
|
235
|
+
<span class="tree__label">${item.label}</span>
|
|
236
|
+
</button>
|
|
237
|
+
${hasChildren && expanded ? this._renderItems(children, level + 1, path) : ''}
|
|
238
|
+
</li>
|
|
239
|
+
`;
|
|
240
|
+
})}
|
|
241
|
+
</ul>
|
|
242
|
+
`;
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
render() {
|
|
246
|
+
return html`
|
|
247
|
+
<div class="tree__slot-host">
|
|
248
|
+
<slot @slotchange=${this._onSlotChange}></slot>
|
|
249
|
+
</div>
|
|
250
|
+
${this._renderItems(this._items)}
|
|
251
|
+
`;
|
|
252
|
+
}
|
|
253
|
+
}
|
|
254
|
+
|
|
255
|
+
customElements.define('arc-tree-view', ArcTreeView);
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { LitElement, html, css } from 'lit';
|
|
2
|
+
|
|
3
|
+
export class ArcMenuItem extends LitElement {
|
|
4
|
+
static properties = {
|
|
5
|
+
shortcut: { type: String, reflect: true },
|
|
6
|
+
disabled: { type: Boolean, reflect: true },
|
|
7
|
+
icon: { type: String },
|
|
8
|
+
};
|
|
9
|
+
|
|
10
|
+
static styles = css`
|
|
11
|
+
:host { display: none; }
|
|
12
|
+
`;
|
|
13
|
+
|
|
14
|
+
constructor() {
|
|
15
|
+
super();
|
|
16
|
+
this.shortcut = '';
|
|
17
|
+
this.disabled = false;
|
|
18
|
+
this.icon = '';
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
get label() {
|
|
22
|
+
return this.textContent.trim();
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
render() {
|
|
26
|
+
return html`<slot></slot>`;
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
customElements.define('arc-menu-item', ArcMenuItem);
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { LitElement, html, css } from 'lit';
|
|
2
|
+
|
|
3
|
+
export class ArcOption extends LitElement {
|
|
4
|
+
static properties = {
|
|
5
|
+
value: { type: String, reflect: true },
|
|
6
|
+
disabled: { type: Boolean, reflect: true },
|
|
7
|
+
selected: { type: Boolean, reflect: true },
|
|
8
|
+
};
|
|
9
|
+
|
|
10
|
+
static styles = css`
|
|
11
|
+
:host { display: none; }
|
|
12
|
+
`;
|
|
13
|
+
|
|
14
|
+
constructor() {
|
|
15
|
+
super();
|
|
16
|
+
this.value = '';
|
|
17
|
+
this.disabled = false;
|
|
18
|
+
this.selected = false;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
/** Expose text content as label */
|
|
22
|
+
get label() {
|
|
23
|
+
return this.textContent.trim();
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
render() {
|
|
27
|
+
return html`<slot></slot>`;
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
customElements.define('arc-option', ArcOption);
|