@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,186 @@
|
|
|
1
|
+
import { LitElement, html, css } from 'lit';
|
|
2
|
+
import { tokenStyles } from '../shared-styles.js';
|
|
3
|
+
|
|
4
|
+
export class ArcHoverCard extends LitElement {
|
|
5
|
+
static properties = {
|
|
6
|
+
position: { type: String, reflect: true },
|
|
7
|
+
openDelay: { type: Number, attribute: 'open-delay' },
|
|
8
|
+
closeDelay: { type: Number, attribute: 'close-delay' },
|
|
9
|
+
_visible: { state: true },
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
static styles = [
|
|
13
|
+
tokenStyles,
|
|
14
|
+
css`
|
|
15
|
+
:host {
|
|
16
|
+
display: inline-block;
|
|
17
|
+
position: relative;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
.hovercard__trigger {
|
|
21
|
+
display: inline-block;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
.hovercard__card {
|
|
25
|
+
position: absolute;
|
|
26
|
+
z-index: 1000;
|
|
27
|
+
background: var(--bg-card);
|
|
28
|
+
border: 1px solid var(--border-default);
|
|
29
|
+
border-radius: var(--radius-lg);
|
|
30
|
+
padding: var(--space-md);
|
|
31
|
+
box-shadow: var(--shadow-overlay);
|
|
32
|
+
min-width: 200px;
|
|
33
|
+
max-width: 360px;
|
|
34
|
+
opacity: 0;
|
|
35
|
+
transform: scale(0.96);
|
|
36
|
+
pointer-events: none;
|
|
37
|
+
transition: opacity var(--transition-base), transform var(--transition-base);
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
.hovercard__card--visible {
|
|
41
|
+
opacity: 1;
|
|
42
|
+
transform: scale(1);
|
|
43
|
+
pointer-events: auto;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
/* Positions */
|
|
47
|
+
:host(:not([position])) .hovercard__card,
|
|
48
|
+
:host([position="bottom"]) .hovercard__card {
|
|
49
|
+
top: calc(100% + var(--space-sm));
|
|
50
|
+
left: 50%;
|
|
51
|
+
transform: translateX(-50%) scale(0.96);
|
|
52
|
+
}
|
|
53
|
+
:host(:not([position])) .hovercard__card--visible,
|
|
54
|
+
:host([position="bottom"]) .hovercard__card--visible {
|
|
55
|
+
transform: translateX(-50%) scale(1);
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
:host([position="top"]) .hovercard__card {
|
|
59
|
+
bottom: calc(100% + var(--space-sm));
|
|
60
|
+
left: 50%;
|
|
61
|
+
transform: translateX(-50%) scale(0.96);
|
|
62
|
+
}
|
|
63
|
+
:host([position="top"]) .hovercard__card--visible {
|
|
64
|
+
transform: translateX(-50%) scale(1);
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
:host([position="left"]) .hovercard__card {
|
|
68
|
+
right: calc(100% + var(--space-sm));
|
|
69
|
+
top: 50%;
|
|
70
|
+
transform: translateY(-50%) scale(0.96);
|
|
71
|
+
}
|
|
72
|
+
:host([position="left"]) .hovercard__card--visible {
|
|
73
|
+
transform: translateY(-50%) scale(1);
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
:host([position="right"]) .hovercard__card {
|
|
77
|
+
left: calc(100% + var(--space-sm));
|
|
78
|
+
top: 50%;
|
|
79
|
+
transform: translateY(-50%) scale(0.96);
|
|
80
|
+
}
|
|
81
|
+
:host([position="right"]) .hovercard__card--visible {
|
|
82
|
+
transform: translateY(-50%) scale(1);
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
@media (prefers-reduced-motion: reduce) {
|
|
86
|
+
:host *,
|
|
87
|
+
:host *::before,
|
|
88
|
+
:host *::after {
|
|
89
|
+
animation-duration: 0.01ms !important;
|
|
90
|
+
animation-iteration-count: 1 !important;
|
|
91
|
+
transition-duration: 0.01ms !important;
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
`,
|
|
95
|
+
];
|
|
96
|
+
|
|
97
|
+
constructor() {
|
|
98
|
+
super();
|
|
99
|
+
this.position = 'bottom';
|
|
100
|
+
this.openDelay = 400;
|
|
101
|
+
this.closeDelay = 300;
|
|
102
|
+
this._visible = false;
|
|
103
|
+
this._openTimeout = null;
|
|
104
|
+
this._closeTimeout = null;
|
|
105
|
+
this._onKeyDown = this._onKeyDown.bind(this);
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
connectedCallback() {
|
|
109
|
+
super.connectedCallback();
|
|
110
|
+
this.addEventListener('keydown', this._onKeyDown);
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
disconnectedCallback() {
|
|
114
|
+
super.disconnectedCallback();
|
|
115
|
+
this.removeEventListener('keydown', this._onKeyDown);
|
|
116
|
+
clearTimeout(this._openTimeout);
|
|
117
|
+
clearTimeout(this._closeTimeout);
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
_onKeyDown(e) {
|
|
121
|
+
if (e.key === 'Escape' && this._visible) {
|
|
122
|
+
this._hide();
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
_scheduleOpen() {
|
|
127
|
+
clearTimeout(this._closeTimeout);
|
|
128
|
+
if (this._visible) return;
|
|
129
|
+
this._openTimeout = setTimeout(() => {
|
|
130
|
+
this._visible = true;
|
|
131
|
+
this.dispatchEvent(new CustomEvent('arc-open', {
|
|
132
|
+
bubbles: true,
|
|
133
|
+
composed: true,
|
|
134
|
+
}));
|
|
135
|
+
}, this.openDelay);
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
_scheduleClose() {
|
|
139
|
+
clearTimeout(this._openTimeout);
|
|
140
|
+
if (!this._visible) return;
|
|
141
|
+
this._closeTimeout = setTimeout(() => {
|
|
142
|
+
this._hide();
|
|
143
|
+
}, this.closeDelay);
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
_cancelClose() {
|
|
147
|
+
clearTimeout(this._closeTimeout);
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
_hide() {
|
|
151
|
+
clearTimeout(this._openTimeout);
|
|
152
|
+
clearTimeout(this._closeTimeout);
|
|
153
|
+
this._visible = false;
|
|
154
|
+
this.dispatchEvent(new CustomEvent('arc-close', {
|
|
155
|
+
bubbles: true,
|
|
156
|
+
composed: true,
|
|
157
|
+
}));
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
render() {
|
|
161
|
+
return html`
|
|
162
|
+
<div
|
|
163
|
+
class="hovercard__trigger"
|
|
164
|
+
@mouseenter=${this._scheduleOpen}
|
|
165
|
+
@mouseleave=${this._scheduleClose}
|
|
166
|
+
@focusin=${this._scheduleOpen}
|
|
167
|
+
@focusout=${this._scheduleClose}
|
|
168
|
+
part="trigger"
|
|
169
|
+
>
|
|
170
|
+
<slot></slot>
|
|
171
|
+
</div>
|
|
172
|
+
<div
|
|
173
|
+
class="hovercard__card ${this._visible ? 'hovercard__card--visible' : ''}"
|
|
174
|
+
@mouseenter=${this._cancelClose}
|
|
175
|
+
@mouseleave=${this._scheduleClose}
|
|
176
|
+
role="dialog"
|
|
177
|
+
aria-hidden=${String(!this._visible)}
|
|
178
|
+
part="card"
|
|
179
|
+
>
|
|
180
|
+
<slot name="content"></slot>
|
|
181
|
+
</div>
|
|
182
|
+
`;
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
customElements.define('arc-hover-card', ArcHoverCard);
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
// ARC UI — Feedback tier
|
|
2
|
+
// Alerts, modals, overlays, and user feedback components
|
|
3
|
+
|
|
4
|
+
export { ArcAlert } from './alert.js';
|
|
5
|
+
export { ArcCommandItem } from './command-item.js';
|
|
6
|
+
export { ArcCommandPalette } from './command-palette.js';
|
|
7
|
+
export { ArcContextMenu } from './context-menu.js';
|
|
8
|
+
export { ArcDialog } from './dialog.js';
|
|
9
|
+
export { ArcDropdownMenu } from './dropdown-menu.js';
|
|
10
|
+
export { ArcHoverCard } from './hover-card.js';
|
|
11
|
+
export { ArcModal } from './modal.js';
|
|
12
|
+
export { ArcNotificationPanel } from './notification-panel.js';
|
|
13
|
+
export { ArcPopover } from './popover.js';
|
|
14
|
+
export { ArcProgress } from './progress.js';
|
|
15
|
+
export { ArcSheet } from './sheet.js';
|
|
16
|
+
export { ArcToast } from './toast.js';
|
|
17
|
+
export { ArcTooltip } from './tooltip.js';
|
|
@@ -0,0 +1,226 @@
|
|
|
1
|
+
import { LitElement, html, css } from 'lit';
|
|
2
|
+
import { tokenStyles } from '../shared-styles.js';
|
|
3
|
+
|
|
4
|
+
export class ArcModal extends LitElement {
|
|
5
|
+
static properties = {
|
|
6
|
+
open: { type: Boolean, reflect: true },
|
|
7
|
+
heading: { type: String },
|
|
8
|
+
size: { type: String, reflect: true },
|
|
9
|
+
closable: { type: Boolean },
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
static styles = [
|
|
13
|
+
tokenStyles,
|
|
14
|
+
css`
|
|
15
|
+
:host { display: contents; }
|
|
16
|
+
|
|
17
|
+
.modal__backdrop {
|
|
18
|
+
position: fixed;
|
|
19
|
+
inset: 0;
|
|
20
|
+
background: var(--overlay-backdrop);
|
|
21
|
+
backdrop-filter: blur(4px);
|
|
22
|
+
z-index: 1000;
|
|
23
|
+
display: flex;
|
|
24
|
+
align-items: center;
|
|
25
|
+
justify-content: center;
|
|
26
|
+
padding: var(--space-lg);
|
|
27
|
+
opacity: 0;
|
|
28
|
+
visibility: hidden;
|
|
29
|
+
transition: opacity var(--transition-base), visibility var(--transition-base);
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
:host([open]) .modal__backdrop {
|
|
33
|
+
opacity: 1;
|
|
34
|
+
visibility: visible;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
.modal__dialog {
|
|
38
|
+
position: relative;
|
|
39
|
+
background: var(--bg-card);
|
|
40
|
+
border: 1px solid var(--border-subtle);
|
|
41
|
+
border-radius: var(--radius-lg);
|
|
42
|
+
box-shadow: var(--shadow-overlay);
|
|
43
|
+
width: 100%;
|
|
44
|
+
max-height: calc(100vh - var(--space-2xl) * 2);
|
|
45
|
+
overflow-y: auto;
|
|
46
|
+
display: flex;
|
|
47
|
+
flex-direction: column;
|
|
48
|
+
transform: translateY(16px);
|
|
49
|
+
transition: transform var(--transition-base);
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
:host([open]) .modal__dialog {
|
|
53
|
+
transform: translateY(0);
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
:host([size="sm"]) .modal__dialog { max-width: 400px; }
|
|
57
|
+
:host(:not([size])) .modal__dialog,
|
|
58
|
+
:host([size="md"]) .modal__dialog { max-width: 560px; }
|
|
59
|
+
:host([size="lg"]) .modal__dialog { max-width: 720px; }
|
|
60
|
+
|
|
61
|
+
.modal__header {
|
|
62
|
+
display: flex;
|
|
63
|
+
align-items: center;
|
|
64
|
+
justify-content: space-between;
|
|
65
|
+
padding: var(--space-lg) var(--space-xl);
|
|
66
|
+
border-bottom: 1px solid var(--border-subtle);
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
.modal__heading {
|
|
70
|
+
font-size: var(--text-md);
|
|
71
|
+
font-weight: 600;
|
|
72
|
+
color: var(--text-primary);
|
|
73
|
+
margin: 0;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
.modal__close {
|
|
77
|
+
background: none;
|
|
78
|
+
border: none;
|
|
79
|
+
color: var(--text-ghost);
|
|
80
|
+
cursor: pointer;
|
|
81
|
+
font-size: var(--text-md);
|
|
82
|
+
width: 32px;
|
|
83
|
+
height: 32px;
|
|
84
|
+
display: flex;
|
|
85
|
+
align-items: center;
|
|
86
|
+
justify-content: center;
|
|
87
|
+
border-radius: var(--radius-sm);
|
|
88
|
+
transition: color var(--transition-fast), background var(--transition-fast);
|
|
89
|
+
line-height: 1;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
.modal__close:hover {
|
|
93
|
+
color: var(--text-primary);
|
|
94
|
+
background: var(--bg-hover);
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
.modal__close:focus-visible {
|
|
98
|
+
outline: none;
|
|
99
|
+
box-shadow: var(--focus-ring);
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
.modal__body {
|
|
103
|
+
padding: var(--space-lg) var(--space-xl);
|
|
104
|
+
color: var(--text-secondary);
|
|
105
|
+
font-size: var(--body-size);
|
|
106
|
+
line-height: var(--body-lh);
|
|
107
|
+
flex: 1;
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
.modal__footer {
|
|
111
|
+
padding: var(--space-md) var(--space-xl);
|
|
112
|
+
border-top: 1px solid var(--border-subtle);
|
|
113
|
+
display: flex;
|
|
114
|
+
justify-content: flex-end;
|
|
115
|
+
gap: var(--space-sm);
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
@media (prefers-reduced-motion: reduce) {
|
|
119
|
+
.modal__backdrop,
|
|
120
|
+
.modal__dialog { transition: none; }
|
|
121
|
+
}
|
|
122
|
+
`,
|
|
123
|
+
];
|
|
124
|
+
|
|
125
|
+
constructor() {
|
|
126
|
+
super();
|
|
127
|
+
this.open = false;
|
|
128
|
+
this.heading = '';
|
|
129
|
+
this.size = 'md';
|
|
130
|
+
this.closable = true;
|
|
131
|
+
this._handleKeydown = this._handleKeydown.bind(this);
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
disconnectedCallback() {
|
|
135
|
+
super.disconnectedCallback();
|
|
136
|
+
document.removeEventListener('keydown', this._handleKeydown);
|
|
137
|
+
document.body.style.overflow = '';
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
_handleKeydown(e) {
|
|
141
|
+
if (e.key === 'Escape' && this.closable) {
|
|
142
|
+
this._close();
|
|
143
|
+
return;
|
|
144
|
+
}
|
|
145
|
+
// Focus trap
|
|
146
|
+
if (e.key === 'Tab') {
|
|
147
|
+
const focusable = this.shadowRoot.querySelectorAll(
|
|
148
|
+
'button, [href], input, select, textarea, [tabindex]:not([tabindex="-1"])'
|
|
149
|
+
);
|
|
150
|
+
const first = focusable[0];
|
|
151
|
+
const last = focusable[focusable.length - 1];
|
|
152
|
+
const active = this.shadowRoot.activeElement;
|
|
153
|
+
|
|
154
|
+
if (e.shiftKey && (!active || active === first)) {
|
|
155
|
+
e.preventDefault();
|
|
156
|
+
last?.focus();
|
|
157
|
+
} else if (!e.shiftKey && active === last) {
|
|
158
|
+
e.preventDefault();
|
|
159
|
+
first?.focus();
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
_close() {
|
|
165
|
+
this.open = false;
|
|
166
|
+
this.dispatchEvent(new CustomEvent('arc-close', { bubbles: true, composed: true }));
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
_backdropClick(e) {
|
|
170
|
+
if (e.target === e.currentTarget && this.closable) {
|
|
171
|
+
this._close();
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
updated(changed) {
|
|
176
|
+
if (changed.has('open')) {
|
|
177
|
+
if (this.open) {
|
|
178
|
+
document.addEventListener('keydown', this._handleKeydown);
|
|
179
|
+
document.body.style.overflow = 'hidden';
|
|
180
|
+
this.dispatchEvent(new CustomEvent('arc-open', { bubbles: true, composed: true }));
|
|
181
|
+
this.updateComplete.then(() => {
|
|
182
|
+
const closeBtn = this.shadowRoot.querySelector('.modal__close');
|
|
183
|
+
closeBtn?.focus();
|
|
184
|
+
});
|
|
185
|
+
} else {
|
|
186
|
+
document.removeEventListener('keydown', this._handleKeydown);
|
|
187
|
+
document.body.style.overflow = '';
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
render() {
|
|
193
|
+
return html`
|
|
194
|
+
<div
|
|
195
|
+
class="modal__backdrop"
|
|
196
|
+
@click=${this._backdropClick}
|
|
197
|
+
part="backdrop"
|
|
198
|
+
>
|
|
199
|
+
<div
|
|
200
|
+
class="modal__dialog"
|
|
201
|
+
role="dialog"
|
|
202
|
+
aria-modal="true"
|
|
203
|
+
aria-label=${this.heading || 'Dialog'}
|
|
204
|
+
part="dialog"
|
|
205
|
+
>
|
|
206
|
+
<div class="modal__header" part="header">
|
|
207
|
+
<slot name="header">
|
|
208
|
+
<h2 class="modal__heading">${this.heading}</h2>
|
|
209
|
+
</slot>
|
|
210
|
+
${this.closable ? html`
|
|
211
|
+
<button class="modal__close" aria-label="Close" @click=${this._close} part="close">×</button>
|
|
212
|
+
` : ''}
|
|
213
|
+
</div>
|
|
214
|
+
<div class="modal__body" part="body">
|
|
215
|
+
<slot></slot>
|
|
216
|
+
</div>
|
|
217
|
+
<div class="modal__footer" part="footer">
|
|
218
|
+
<slot name="footer"></slot>
|
|
219
|
+
</div>
|
|
220
|
+
</div>
|
|
221
|
+
</div>
|
|
222
|
+
`;
|
|
223
|
+
}
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
customElements.define('arc-modal', ArcModal);
|
|
@@ -0,0 +1,196 @@
|
|
|
1
|
+
import { LitElement, html, css } from 'lit';
|
|
2
|
+
import { tokenStyles } from '../shared-styles.js';
|
|
3
|
+
|
|
4
|
+
export class ArcNotificationPanel extends LitElement {
|
|
5
|
+
static properties = {
|
|
6
|
+
open: { type: Boolean, reflect: true },
|
|
7
|
+
position: { type: String, reflect: true },
|
|
8
|
+
maxHeight: { type: String, attribute: 'max-height' },
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
static styles = [
|
|
12
|
+
tokenStyles,
|
|
13
|
+
css`
|
|
14
|
+
:host {
|
|
15
|
+
display: inline-block;
|
|
16
|
+
position: relative;
|
|
17
|
+
box-sizing: border-box;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
.trigger {
|
|
21
|
+
cursor: pointer;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
/* ---- Panel shell ---- */
|
|
25
|
+
.panel {
|
|
26
|
+
position: absolute;
|
|
27
|
+
top: calc(100% + var(--space-sm));
|
|
28
|
+
background: var(--bg-card);
|
|
29
|
+
border: 1px solid var(--border-default);
|
|
30
|
+
border-radius: var(--radius-lg);
|
|
31
|
+
box-shadow: var(--shadow-overlay);
|
|
32
|
+
z-index: 1000;
|
|
33
|
+
min-width: 340px;
|
|
34
|
+
max-width: 400px;
|
|
35
|
+
display: flex;
|
|
36
|
+
flex-direction: column;
|
|
37
|
+
|
|
38
|
+
/* closed state */
|
|
39
|
+
opacity: 0;
|
|
40
|
+
transform: translateY(-6px) scale(0.97);
|
|
41
|
+
transform-origin: top right;
|
|
42
|
+
pointer-events: none;
|
|
43
|
+
|
|
44
|
+
/* closing transition — slightly faster */
|
|
45
|
+
transition:
|
|
46
|
+
opacity 120ms ease-in,
|
|
47
|
+
transform 120ms ease-in;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
:host([position='top-left']) .panel {
|
|
51
|
+
transform-origin: top left;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
:host([open]) .panel {
|
|
55
|
+
opacity: 1;
|
|
56
|
+
transform: translateY(0) scale(1);
|
|
57
|
+
pointer-events: auto;
|
|
58
|
+
|
|
59
|
+
/* opening transition — cubic overshoot for a pop feel */
|
|
60
|
+
transition:
|
|
61
|
+
opacity 180ms ease-out,
|
|
62
|
+
transform 250ms cubic-bezier(0.34, 1.56, 0.64, 1);
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
:host([position='top-right']) .panel {
|
|
66
|
+
right: 0;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
:host([position='top-left']) .panel {
|
|
70
|
+
left: 0;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
/* ---- Header ---- */
|
|
74
|
+
.header {
|
|
75
|
+
display: flex;
|
|
76
|
+
align-items: center;
|
|
77
|
+
justify-content: space-between;
|
|
78
|
+
border-bottom: 1px solid var(--border-subtle);
|
|
79
|
+
padding: var(--space-md) var(--space-lg);
|
|
80
|
+
font-family: var(--font-body);
|
|
81
|
+
font-weight: 600;
|
|
82
|
+
font-size: var(--text-sm);
|
|
83
|
+
color: var(--text-primary);
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
/* ---- Scrollable body ---- */
|
|
87
|
+
.panel-body {
|
|
88
|
+
overflow-y: auto;
|
|
89
|
+
max-height: var(--max-height);
|
|
90
|
+
overscroll-behavior: contain;
|
|
91
|
+
scrollbar-width: thin;
|
|
92
|
+
scrollbar-color: var(--border-default) transparent;
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
.panel-body::-webkit-scrollbar {
|
|
96
|
+
width: 4px;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
.panel-body::-webkit-scrollbar-track {
|
|
100
|
+
background: transparent;
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
.panel-body::-webkit-scrollbar-thumb {
|
|
104
|
+
background: var(--border-default);
|
|
105
|
+
border-radius: var(--radius-xs);
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
/* ---- Footer ---- */
|
|
109
|
+
.footer {
|
|
110
|
+
border-top: 1px solid var(--border-subtle);
|
|
111
|
+
padding: var(--space-sm) var(--space-lg);
|
|
112
|
+
text-align: center;
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
/* ---- Reduced motion ---- */
|
|
116
|
+
@media (prefers-reduced-motion: reduce) {
|
|
117
|
+
.panel,
|
|
118
|
+
:host([open]) .panel {
|
|
119
|
+
transition: opacity 100ms ease;
|
|
120
|
+
transform: none;
|
|
121
|
+
}
|
|
122
|
+
:host([open]) .panel {
|
|
123
|
+
transform: none;
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
`,
|
|
127
|
+
];
|
|
128
|
+
|
|
129
|
+
constructor() {
|
|
130
|
+
super();
|
|
131
|
+
this.open = false;
|
|
132
|
+
this.position = 'top-right';
|
|
133
|
+
this.maxHeight = '400px';
|
|
134
|
+
this._onOutsideClick = this._onOutsideClick.bind(this);
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
disconnectedCallback() {
|
|
138
|
+
super.disconnectedCallback();
|
|
139
|
+
document.removeEventListener('click', this._onOutsideClick, true);
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
updated(changedProperties) {
|
|
143
|
+
this.style.setProperty('--max-height', this.maxHeight);
|
|
144
|
+
|
|
145
|
+
if (changedProperties.has('open')) {
|
|
146
|
+
if (this.open) {
|
|
147
|
+
// Defer so we don't catch the same click that opened the panel
|
|
148
|
+
requestAnimationFrame(() => {
|
|
149
|
+
document.addEventListener('click', this._onOutsideClick, true);
|
|
150
|
+
});
|
|
151
|
+
this.dispatchEvent(
|
|
152
|
+
new CustomEvent('arc-open', { bubbles: true, composed: true })
|
|
153
|
+
);
|
|
154
|
+
} else {
|
|
155
|
+
document.removeEventListener('click', this._onOutsideClick, true);
|
|
156
|
+
if (changedProperties.get('open') === true) {
|
|
157
|
+
this.dispatchEvent(
|
|
158
|
+
new CustomEvent('arc-close', { bubbles: true, composed: true })
|
|
159
|
+
);
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
_onTriggerClick() {
|
|
166
|
+
this.open = !this.open;
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
_onOutsideClick(e) {
|
|
170
|
+
const path = e.composedPath();
|
|
171
|
+
if (!path.includes(this)) {
|
|
172
|
+
this.open = false;
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
render() {
|
|
177
|
+
return html`
|
|
178
|
+
<div class="trigger" part="trigger" @click="${this._onTriggerClick}">
|
|
179
|
+
<slot name="trigger"></slot>
|
|
180
|
+
</div>
|
|
181
|
+
<div class="panel" part="panel">
|
|
182
|
+
<div class="header" part="header">
|
|
183
|
+
<slot name="header"></slot>
|
|
184
|
+
</div>
|
|
185
|
+
<div class="panel-body" part="body">
|
|
186
|
+
<slot></slot>
|
|
187
|
+
</div>
|
|
188
|
+
<div class="footer" part="footer">
|
|
189
|
+
<slot name="footer"></slot>
|
|
190
|
+
</div>
|
|
191
|
+
</div>
|
|
192
|
+
`;
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
customElements.define('arc-notification-panel', ArcNotificationPanel);
|