@wcomp/elementum 0.0.0-stage → 0.1.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 +266 -2
- package/custom-elements.json +3613 -0
- package/mcp/server.js +408 -0
- package/package.json +72 -4
- package/skills/elementum-break-ui/CATALOG.md +11 -0
- package/skills/elementum-break-ui/SKILL.md +16 -0
- package/skills/elementum-mobile/SKILL.md +18 -0
- package/skills/elementum-motion/SKILL.md +18 -0
- package/skills/elementum-motion/STANDARDS.md +15 -0
- package/skills/elementum-penpot/SKILL.md +45 -0
- package/skills/elementum-ui/CATALOG.md +14 -0
- package/skills/elementum-ui/SKILL.md +21 -0
- package/src/ag-ui.js +474 -0
- package/src/components/el-accordion.js +201 -0
- package/src/components/el-alert-dialog.js +186 -0
- package/src/components/el-alert.js +254 -0
- package/src/components/el-aspect-ratio.js +73 -0
- package/src/components/el-autocomplete.js +775 -0
- package/src/components/el-avatar.js +271 -0
- package/src/components/el-badge.js +131 -0
- package/src/components/el-border-beam.js +135 -0
- package/src/components/el-breadcrumb.js +203 -0
- package/src/components/el-button.js +220 -0
- package/src/components/el-calendar.js +413 -0
- package/src/components/el-callout.js +158 -0
- package/src/components/el-card.js +298 -0
- package/src/components/el-carousel.js +308 -0
- package/src/components/el-chart.js +632 -0
- package/src/components/el-checkbox-card.js +221 -0
- package/src/components/el-checkbox.js +208 -0
- package/src/components/el-chip.js +276 -0
- package/src/components/el-code-block.js +228 -0
- package/src/components/el-collapsible.js +124 -0
- package/src/components/el-command.js +556 -0
- package/src/components/el-context-menu.js +328 -0
- package/src/components/el-data-list.js +210 -0
- package/src/components/el-datepicker.js +192 -0
- package/src/components/el-dialog.js +272 -0
- package/src/components/el-diff-viewer.js +441 -0
- package/src/components/el-drawer.js +782 -0
- package/src/components/el-dropdown.js +182 -0
- package/src/components/el-dropzone.js +242 -0
- package/src/components/el-empty-state.js +130 -0
- package/src/components/el-field.js +394 -0
- package/src/components/el-form.js +185 -0
- package/src/components/el-input.js +212 -0
- package/src/components/el-inset.js +90 -0
- package/src/components/el-insight-card.js +263 -0
- package/src/components/el-kbd.js +151 -0
- package/src/components/el-menubar.js +254 -0
- package/src/components/el-meter.js +182 -0
- package/src/components/el-navbar.js +294 -0
- package/src/components/el-navigation-menu.js +327 -0
- package/src/components/el-number-field.js +510 -0
- package/src/components/el-number-flow.js +153 -0
- package/src/components/el-otp-input.js +266 -0
- package/src/components/el-pagination.js +229 -0
- package/src/components/el-popover.js +288 -0
- package/src/components/el-preview-card.js +202 -0
- package/src/components/el-progress.js +179 -0
- package/src/components/el-prompt-input.js +383 -0
- package/src/components/el-radio-card.js +360 -0
- package/src/components/el-radio.js +257 -0
- package/src/components/el-rating.js +165 -0
- package/src/components/el-reasoning-card.js +293 -0
- package/src/components/el-resizable.js +324 -0
- package/src/components/el-router.js +305 -0
- package/src/components/el-scroll-area.js +150 -0
- package/src/components/el-segmented-control.js +282 -0
- package/src/components/el-select.js +219 -0
- package/src/components/el-separator.js +85 -0
- package/src/components/el-sidebar.js +386 -0
- package/src/components/el-skeleton.js +156 -0
- package/src/components/el-slider.js +351 -0
- package/src/components/el-sources.js +288 -0
- package/src/components/el-spinner.js +159 -0
- package/src/components/el-streaming-text.js +199 -0
- package/src/components/el-switch.js +221 -0
- package/src/components/el-table.js +397 -0
- package/src/components/el-tabs.js +235 -0
- package/src/components/el-task-list.js +230 -0
- package/src/components/el-textarea.js +175 -0
- package/src/components/el-theme-switch.js +120 -0
- package/src/components/el-timeline.js +254 -0
- package/src/components/el-toast.js +778 -0
- package/src/components/el-toggle.js +311 -0
- package/src/components/el-tool-call.js +386 -0
- package/src/components/el-toolbar.js +183 -0
- package/src/components/el-tooltip.js +172 -0
- package/src/components/el-tree-view.js +261 -0
- package/src/components/el-visually-hidden.js +32 -0
- package/src/elementum.js +485 -0
- package/src/index.d.ts +1007 -0
- package/src/index.js +99 -0
- package/src/signal.js +194 -0
- package/src/ssr.js +136 -0
- package/src/template.js +321 -0
- package/src/tokens.css +416 -0
- package/tokens/figma-tokens.json +69 -0
- package/tokens/penpot-tokens.json +98 -0
|
@@ -0,0 +1,288 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* <el-popover>
|
|
3
|
+
* Accessible, zero-dependency floating popover primitive inspired by Base UI.
|
|
4
|
+
* Supports anchor positioning, collision boundaries, directional arrow,
|
|
5
|
+
* light-dismiss, and modern @starting-style CSS transitions.
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
import { Elementum } from '../elementum.js';
|
|
9
|
+
import { html, css } from '../template.js';
|
|
10
|
+
import { signal } from '../signal.js';
|
|
11
|
+
|
|
12
|
+
export class ElPopover extends Elementum {
|
|
13
|
+
static observedAttributes = ['open', 'placement', 'offset', 'arrow'];
|
|
14
|
+
|
|
15
|
+
isOpen = signal(false);
|
|
16
|
+
placement = signal('bottom');
|
|
17
|
+
offset = signal(8);
|
|
18
|
+
hasArrow = signal(false);
|
|
19
|
+
|
|
20
|
+
static styles = css`
|
|
21
|
+
:host {
|
|
22
|
+
display: inline-block;
|
|
23
|
+
position: relative;
|
|
24
|
+
font-family: var(--el-font-sans, system-ui, sans-serif);
|
|
25
|
+
color: var(--el-text-primary, #0f172a);
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
.trigger-wrapper {
|
|
29
|
+
display: inline-block;
|
|
30
|
+
cursor: pointer;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
.popup {
|
|
34
|
+
position: absolute;
|
|
35
|
+
z-index: 1000;
|
|
36
|
+
min-width: var(--anchor-width, 220px);
|
|
37
|
+
max-width: calc(100vw - 32px);
|
|
38
|
+
max-height: var(--available-height, 420px);
|
|
39
|
+
overflow: visible;
|
|
40
|
+
background: var(--el-surface-elevated, #ffffff);
|
|
41
|
+
color: var(--el-text-primary, #0f172a);
|
|
42
|
+
border: 1px solid var(--el-surface-border, #e2e8f0);
|
|
43
|
+
border-radius: var(--el-radius-md, 8px);
|
|
44
|
+
box-shadow: var(--el-shadow-popover, 0 10px 25px -5px rgba(0, 0, 0, 0.1), 0 8px 10px -6px rgba(0, 0, 0, 0.1));
|
|
45
|
+
padding: 12px;
|
|
46
|
+
box-sizing: border-box;
|
|
47
|
+
opacity: 0;
|
|
48
|
+
pointer-events: none;
|
|
49
|
+
transform: translateY(-4px) scale(0.97);
|
|
50
|
+
transform-origin: var(--transform-origin, top center);
|
|
51
|
+
transition: opacity 160ms cubic-bezier(0.16, 1, 0.3, 1), transform 160ms cubic-bezier(0.16, 1, 0.3, 1);
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
:root[data-theme="dark"] .popup {
|
|
55
|
+
background: var(--el-surface-card, #111827);
|
|
56
|
+
border-color: #334155;
|
|
57
|
+
color: #f8fafc;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
/* Placements */
|
|
61
|
+
.popup[data-side="bottom"] {
|
|
62
|
+
top: calc(100% + var(--popover-offset, 8px));
|
|
63
|
+
left: 50%;
|
|
64
|
+
transform: translateX(-50%) translateY(-4px) scale(0.97);
|
|
65
|
+
transform-origin: top center;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
.popup[data-side="top"] {
|
|
69
|
+
bottom: calc(100% + var(--popover-offset, 8px));
|
|
70
|
+
left: 50%;
|
|
71
|
+
transform: translateX(-50%) translateY(4px) scale(0.97);
|
|
72
|
+
transform-origin: bottom center;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
.popup[data-side="right"] {
|
|
76
|
+
left: calc(100% + var(--popover-offset, 8px));
|
|
77
|
+
top: 50%;
|
|
78
|
+
transform: translateY(-50%) translateX(-4px) scale(0.97);
|
|
79
|
+
transform-origin: left center;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
.popup[data-side="left"] {
|
|
83
|
+
right: calc(100% + var(--popover-offset, 8px));
|
|
84
|
+
top: 50%;
|
|
85
|
+
transform: translateY(-50%) translateX(4px) scale(0.97);
|
|
86
|
+
transform-origin: right center;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
/* Open State */
|
|
90
|
+
.popup.open,
|
|
91
|
+
.popup[data-state="open"] {
|
|
92
|
+
opacity: 1;
|
|
93
|
+
pointer-events: auto;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
.popup[data-side="bottom"].open {
|
|
97
|
+
transform: translateX(-50%) translateY(0) scale(1);
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
.popup[data-side="top"].open {
|
|
101
|
+
transform: translateX(-50%) translateY(0) scale(1);
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
.popup[data-side="right"].open {
|
|
105
|
+
transform: translateY(-50%) translateX(0) scale(1);
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
.popup[data-side="left"].open {
|
|
109
|
+
transform: translateY(-50%) translateX(0) scale(1);
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
@starting-style {
|
|
113
|
+
.popup.open {
|
|
114
|
+
opacity: 0;
|
|
115
|
+
transform: translateY(-4px) scale(0.97);
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
/* Arrow */
|
|
120
|
+
.arrow {
|
|
121
|
+
position: absolute;
|
|
122
|
+
width: 10px;
|
|
123
|
+
height: 10px;
|
|
124
|
+
background: var(--el-surface-elevated, #ffffff);
|
|
125
|
+
border: 1px solid var(--el-surface-border, #e2e8f0);
|
|
126
|
+
transform: rotate(45deg);
|
|
127
|
+
pointer-events: none;
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
:root[data-theme="dark"] .arrow {
|
|
131
|
+
background: var(--el-surface-card, #111827);
|
|
132
|
+
border-color: #334155;
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
.popup[data-side="bottom"] .arrow {
|
|
136
|
+
top: -6px;
|
|
137
|
+
left: calc(50% - 5px);
|
|
138
|
+
border-bottom: none;
|
|
139
|
+
border-right: none;
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
.popup[data-side="top"] .arrow {
|
|
143
|
+
bottom: -6px;
|
|
144
|
+
left: calc(50% - 5px);
|
|
145
|
+
border-top: none;
|
|
146
|
+
border-left: none;
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
.popup[data-side="right"] .arrow {
|
|
150
|
+
left: -6px;
|
|
151
|
+
top: calc(50% - 5px);
|
|
152
|
+
border-top: none;
|
|
153
|
+
border-right: none;
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
.popup[data-side="left"] .arrow {
|
|
157
|
+
right: -6px;
|
|
158
|
+
top: calc(50% - 5px);
|
|
159
|
+
border-bottom: none;
|
|
160
|
+
border-left: none;
|
|
161
|
+
}
|
|
162
|
+
`;
|
|
163
|
+
|
|
164
|
+
connected() {
|
|
165
|
+
this.#syncAttributes();
|
|
166
|
+
this.setAttribute('data-state', this.isOpen.value ? 'open' : 'closed');
|
|
167
|
+
|
|
168
|
+
const onDocPointerDown = (e) => {
|
|
169
|
+
if (!this.isOpen.value) return;
|
|
170
|
+
const path = e.composedPath();
|
|
171
|
+
if (!path.includes(this)) {
|
|
172
|
+
this.close();
|
|
173
|
+
}
|
|
174
|
+
};
|
|
175
|
+
|
|
176
|
+
const onDocKeyDown = (e) => {
|
|
177
|
+
if (this.isOpen.value && e.key === 'Escape') {
|
|
178
|
+
this.close();
|
|
179
|
+
e.stopPropagation();
|
|
180
|
+
}
|
|
181
|
+
};
|
|
182
|
+
|
|
183
|
+
document.addEventListener('pointerdown', onDocPointerDown, { signal: this.signal });
|
|
184
|
+
document.addEventListener('keydown', onDocKeyDown, { signal: this.signal });
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
rendered() {
|
|
188
|
+
if (this.isOpen.value) {
|
|
189
|
+
this.#updateAnchorMetrics();
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
attributeChanged(name, oldValue, newValue) {
|
|
194
|
+
if (name === 'open') {
|
|
195
|
+
const open = newValue !== null && newValue !== 'false';
|
|
196
|
+
if (open) this.open();
|
|
197
|
+
else this.close();
|
|
198
|
+
} else if (name === 'placement') {
|
|
199
|
+
this.placement.value = newValue || 'bottom';
|
|
200
|
+
} else if (name === 'offset') {
|
|
201
|
+
const parsed = parseInt(newValue, 10);
|
|
202
|
+
this.offset.value = !Number.isNaN(parsed) ? parsed : 8;
|
|
203
|
+
this.style.setProperty('--popover-offset', `${this.offset.value}px`);
|
|
204
|
+
} else if (name === 'arrow') {
|
|
205
|
+
this.hasArrow.value = newValue !== null && newValue !== 'false';
|
|
206
|
+
}
|
|
207
|
+
return true;
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
#syncAttributes() {
|
|
211
|
+
this.isOpen.value = this.hasAttribute('open') && this.getAttribute('open') !== 'false';
|
|
212
|
+
if (this.hasAttribute('placement')) this.placement.value = this.getAttribute('placement');
|
|
213
|
+
if (this.hasAttribute('offset')) {
|
|
214
|
+
const parsed = parseInt(this.getAttribute('offset'), 10);
|
|
215
|
+
this.offset.value = !Number.isNaN(parsed) ? parsed : 8;
|
|
216
|
+
}
|
|
217
|
+
this.style.setProperty('--popover-offset', `${this.offset.value}px`);
|
|
218
|
+
this.hasArrow.value = this.hasAttribute('arrow') && this.getAttribute('arrow') !== 'false';
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
#updateAnchorMetrics() {
|
|
222
|
+
if (typeof window === 'undefined') return;
|
|
223
|
+
const trigger = this.root?.querySelector('.trigger-wrapper') || this;
|
|
224
|
+
if (trigger && typeof trigger.getBoundingClientRect === 'function') {
|
|
225
|
+
const rect = trigger.getBoundingClientRect();
|
|
226
|
+
const anchorW = Math.round(rect.width);
|
|
227
|
+
const availH = Math.max(120, Math.round(window.innerHeight - rect.bottom - 16));
|
|
228
|
+
this.style.setProperty('--anchor-width', `${anchorW}px`);
|
|
229
|
+
this.style.setProperty('--available-height', `${availH}px`);
|
|
230
|
+
this.style.setProperty('--popover-offset', `${this.offset.value}px`);
|
|
231
|
+
}
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
open() {
|
|
235
|
+
if (!this.isOpen.value) {
|
|
236
|
+
this.#updateAnchorMetrics();
|
|
237
|
+
this.isOpen.value = true;
|
|
238
|
+
this.setAttribute('data-state', 'open');
|
|
239
|
+
this.emit('open');
|
|
240
|
+
}
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
close() {
|
|
244
|
+
if (this.isOpen.value) {
|
|
245
|
+
this.isOpen.value = false;
|
|
246
|
+
this.setAttribute('data-state', 'closed');
|
|
247
|
+
this.emit('close');
|
|
248
|
+
}
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
toggle() {
|
|
252
|
+
if (this.isOpen.value) this.close();
|
|
253
|
+
else this.open();
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
show() { this.open(); }
|
|
257
|
+
hide() { this.close(); }
|
|
258
|
+
|
|
259
|
+
render() {
|
|
260
|
+
return html`
|
|
261
|
+
<div
|
|
262
|
+
class="trigger-wrapper"
|
|
263
|
+
part="trigger"
|
|
264
|
+
@click=${() => this.toggle()}
|
|
265
|
+
>
|
|
266
|
+
<slot name="trigger"></slot>
|
|
267
|
+
</div>
|
|
268
|
+
|
|
269
|
+
<div
|
|
270
|
+
class=${() => `popup ${this.isOpen.value ? 'open' : ''}`}
|
|
271
|
+
data-state=${() => (this.isOpen.value ? 'open' : 'closed')}
|
|
272
|
+
data-side=${() => this.placement.value}
|
|
273
|
+
part="popup"
|
|
274
|
+
role="dialog"
|
|
275
|
+
aria-hidden=${() => !this.isOpen.value}
|
|
276
|
+
>
|
|
277
|
+
${() => (this.hasArrow.value ? html`<div class="arrow" part="arrow"></div>` : '')}
|
|
278
|
+
<slot name="content"></slot>
|
|
279
|
+
<slot name="popup"></slot>
|
|
280
|
+
<slot></slot>
|
|
281
|
+
</div>
|
|
282
|
+
`;
|
|
283
|
+
}
|
|
284
|
+
}
|
|
285
|
+
|
|
286
|
+
if (typeof customElements !== 'undefined' && !customElements.get('el-popover')) {
|
|
287
|
+
customElements.define('el-popover', ElPopover);
|
|
288
|
+
}
|
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* <el-preview-card>
|
|
3
|
+
* Accessible, zero-dependency hover card primitive inspired by Base UI.
|
|
4
|
+
* Delays opening on hover (intent-based) to display rich previews without distracting false-triggers.
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
import { Elementum } from '../elementum.js';
|
|
8
|
+
import { html, css } from '../template.js';
|
|
9
|
+
import { signal } from '../signal.js';
|
|
10
|
+
|
|
11
|
+
export class ElPreviewCard extends Elementum {
|
|
12
|
+
static observedAttributes = ['open', 'delay', 'open-delay', 'close-delay', 'placement'];
|
|
13
|
+
|
|
14
|
+
isOpen = signal(false);
|
|
15
|
+
openDelay = signal(400);
|
|
16
|
+
closeDelay = signal(300);
|
|
17
|
+
placement = signal('bottom');
|
|
18
|
+
|
|
19
|
+
#openTimer = null;
|
|
20
|
+
#closeTimer = null;
|
|
21
|
+
|
|
22
|
+
static styles = css`
|
|
23
|
+
:host {
|
|
24
|
+
display: inline-block;
|
|
25
|
+
position: relative;
|
|
26
|
+
font-family: var(--el-font-sans, system-ui, sans-serif);
|
|
27
|
+
color: var(--el-text-primary, #0f172a);
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
.trigger-wrapper {
|
|
31
|
+
display: inline-block;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
.card {
|
|
35
|
+
position: absolute;
|
|
36
|
+
z-index: 1050;
|
|
37
|
+
width: max-content;
|
|
38
|
+
max-width: 320px;
|
|
39
|
+
background: var(--el-surface-elevated, #ffffff);
|
|
40
|
+
border: 1px solid var(--el-surface-border, #e2e8f0);
|
|
41
|
+
border-radius: var(--el-radius-lg, 12px);
|
|
42
|
+
box-shadow: 0 12px 28px -4px rgba(0, 0, 0, 0.12), 0 4px 10px -2px rgba(0, 0, 0, 0.05);
|
|
43
|
+
padding: 16px;
|
|
44
|
+
box-sizing: border-box;
|
|
45
|
+
opacity: 0;
|
|
46
|
+
pointer-events: none;
|
|
47
|
+
transform: translateY(-4px) scale(0.97);
|
|
48
|
+
transition: opacity 180ms cubic-bezier(0.16, 1, 0.3, 1), transform 180ms cubic-bezier(0.16, 1, 0.3, 1);
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
:root[data-theme="dark"] .card {
|
|
52
|
+
background: var(--el-surface-card, #111827);
|
|
53
|
+
border-color: #334155;
|
|
54
|
+
color: #f8fafc;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
.card[data-side="bottom"] {
|
|
58
|
+
top: calc(100% + 8px);
|
|
59
|
+
left: 50%;
|
|
60
|
+
transform-origin: top center;
|
|
61
|
+
transform: translateX(-50%) translateY(-4px) scale(0.97);
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
.card[data-side="top"] {
|
|
65
|
+
bottom: calc(100% + 8px);
|
|
66
|
+
left: 50%;
|
|
67
|
+
transform-origin: bottom center;
|
|
68
|
+
transform: translateX(-50%) translateY(4px) scale(0.97);
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
.card[data-side="right"] {
|
|
72
|
+
left: calc(100% + 10px);
|
|
73
|
+
top: 50%;
|
|
74
|
+
transform-origin: left center;
|
|
75
|
+
transform: translateY(-50%) translateX(-4px) scale(0.97);
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
.card[data-side="left"] {
|
|
79
|
+
right: calc(100% + 10px);
|
|
80
|
+
top: 50%;
|
|
81
|
+
transform-origin: right center;
|
|
82
|
+
transform: translateY(-50%) translateX(4px) scale(0.97);
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
.card.open,
|
|
86
|
+
.card[data-state="open"] {
|
|
87
|
+
opacity: 1;
|
|
88
|
+
pointer-events: auto;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
.card[data-side="bottom"].open,
|
|
92
|
+
.card[data-side="top"].open {
|
|
93
|
+
transform: translateX(-50%) translateY(0) scale(1);
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
.card[data-side="right"].open,
|
|
97
|
+
.card[data-side="left"].open {
|
|
98
|
+
transform: translateY(-50%) translateX(0) scale(1);
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
@starting-style {
|
|
102
|
+
.card.open {
|
|
103
|
+
opacity: 0;
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
`;
|
|
107
|
+
|
|
108
|
+
connected() {
|
|
109
|
+
if (this.hasAttribute('delay')) this.openDelay.value = parseInt(this.getAttribute('delay'), 10) || 400;
|
|
110
|
+
if (this.hasAttribute('open-delay')) this.openDelay.value = parseInt(this.getAttribute('open-delay'), 10) || 400;
|
|
111
|
+
if (this.hasAttribute('close-delay')) this.closeDelay.value = parseInt(this.getAttribute('close-delay'), 10) || 300;
|
|
112
|
+
if (this.hasAttribute('placement')) this.placement.value = this.getAttribute('placement');
|
|
113
|
+
this.isOpen.value = this.hasAttribute('open') && this.getAttribute('open') !== 'false';
|
|
114
|
+
this.setAttribute('data-state', this.isOpen.value ? 'open' : 'closed');
|
|
115
|
+
|
|
116
|
+
this.addEventListener('pointerenter', this.#onMouseEnter);
|
|
117
|
+
this.addEventListener('pointerleave', this.#onMouseLeave);
|
|
118
|
+
this.addEventListener('focusin', this.#onFocusIn);
|
|
119
|
+
this.addEventListener('focusout', this.#onFocusOut);
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
attributeChanged(name, oldValue, newValue) {
|
|
123
|
+
if (name === 'open') {
|
|
124
|
+
const shouldOpen = newValue !== null && newValue !== 'false';
|
|
125
|
+
if (shouldOpen) this.open();
|
|
126
|
+
else this.close();
|
|
127
|
+
} else if (name === 'delay' || name === 'open-delay') {
|
|
128
|
+
this.openDelay.value = parseInt(newValue, 10) || 400;
|
|
129
|
+
} else if (name === 'close-delay') {
|
|
130
|
+
this.closeDelay.value = parseInt(newValue, 10) || 300;
|
|
131
|
+
} else if (name === 'placement') {
|
|
132
|
+
this.placement.value = newValue || 'bottom';
|
|
133
|
+
}
|
|
134
|
+
return true;
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
#onMouseEnter = () => {
|
|
138
|
+
clearTimeout(this.#closeTimer);
|
|
139
|
+
this.#openTimer = setTimeout(() => {
|
|
140
|
+
this.open();
|
|
141
|
+
}, this.openDelay.value);
|
|
142
|
+
};
|
|
143
|
+
|
|
144
|
+
#onMouseLeave = () => {
|
|
145
|
+
clearTimeout(this.#openTimer);
|
|
146
|
+
this.#closeTimer = setTimeout(() => {
|
|
147
|
+
this.close();
|
|
148
|
+
}, this.closeDelay.value);
|
|
149
|
+
};
|
|
150
|
+
|
|
151
|
+
#onFocusIn = () => {
|
|
152
|
+
clearTimeout(this.#closeTimer);
|
|
153
|
+
this.open();
|
|
154
|
+
};
|
|
155
|
+
|
|
156
|
+
#onFocusOut = (e) => {
|
|
157
|
+
if (!this.contains(e.relatedTarget)) {
|
|
158
|
+
this.close();
|
|
159
|
+
}
|
|
160
|
+
};
|
|
161
|
+
|
|
162
|
+
open() {
|
|
163
|
+
if (!this.isOpen.value) {
|
|
164
|
+
this.isOpen.value = true;
|
|
165
|
+
this.setAttribute('data-state', 'open');
|
|
166
|
+
this.emit('open');
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
close() {
|
|
171
|
+
if (this.isOpen.value) {
|
|
172
|
+
this.isOpen.value = false;
|
|
173
|
+
this.setAttribute('data-state', 'closed');
|
|
174
|
+
this.emit('close');
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
render() {
|
|
179
|
+
return html`
|
|
180
|
+
<div class="trigger-wrapper" part="trigger">
|
|
181
|
+
<slot name="trigger"></slot>
|
|
182
|
+
</div>
|
|
183
|
+
|
|
184
|
+
<div
|
|
185
|
+
class=${() => `card ${this.isOpen.value ? 'open' : ''}`}
|
|
186
|
+
data-state=${() => (this.isOpen.value ? 'open' : 'closed')}
|
|
187
|
+
data-side=${() => this.placement.value}
|
|
188
|
+
part="card"
|
|
189
|
+
role="tooltip"
|
|
190
|
+
aria-hidden=${() => !this.isOpen.value}
|
|
191
|
+
>
|
|
192
|
+
<slot name="preview"></slot>
|
|
193
|
+
<slot name="content"></slot>
|
|
194
|
+
<slot></slot>
|
|
195
|
+
</div>
|
|
196
|
+
`;
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
if (typeof customElements !== 'undefined' && !customElements.get('el-preview-card')) {
|
|
201
|
+
customElements.define('el-preview-card', ElPreviewCard);
|
|
202
|
+
}
|
|
@@ -0,0 +1,179 @@
|
|
|
1
|
+
import { Elementum } from '../elementum.js';
|
|
2
|
+
import { html, css } from '../template.js';
|
|
3
|
+
import { signal } from '../signal.js';
|
|
4
|
+
|
|
5
|
+
export class ElProgress extends Elementum {
|
|
6
|
+
static observedAttributes = ['value', 'max', 'variant', 'size', 'indeterminate', 'striped'];
|
|
7
|
+
|
|
8
|
+
value = signal(0);
|
|
9
|
+
max = signal(100);
|
|
10
|
+
variant = signal('primary'); // 'primary' | 'success' | 'danger'
|
|
11
|
+
size = signal('md'); // 'sm' | 'md' | 'lg'
|
|
12
|
+
indeterminate = signal(false);
|
|
13
|
+
striped = signal(false);
|
|
14
|
+
|
|
15
|
+
connected() {
|
|
16
|
+
this.#syncValues();
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
attributeChanged(name, oldValue, newValue) {
|
|
20
|
+
this.#syncValues();
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
#syncValues() {
|
|
24
|
+
const rawVal = this.getAttribute('value');
|
|
25
|
+
this.value.value = rawVal !== null ? Math.max(0, Number(rawVal) || 0) : 0;
|
|
26
|
+
this.max.value = Math.max(1, Number(this.getAttribute('max')) || 100);
|
|
27
|
+
this.indeterminate.value = this.hasAttribute('indeterminate') || rawVal === null;
|
|
28
|
+
this.striped.value = this.hasAttribute('striped');
|
|
29
|
+
this.variant.value = this.getAttribute('variant') || 'primary';
|
|
30
|
+
this.size.value = this.getAttribute('size') || 'md';
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
static styles = css`
|
|
34
|
+
:host {
|
|
35
|
+
display: block;
|
|
36
|
+
width: 100%;
|
|
37
|
+
box-sizing: border-box;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
.track {
|
|
41
|
+
position: relative;
|
|
42
|
+
width: 100%;
|
|
43
|
+
background: var(--el-surface-muted, #f1f5f9);
|
|
44
|
+
border-radius: var(--el-radius-full, 9999px);
|
|
45
|
+
overflow: hidden;
|
|
46
|
+
border: 1px solid var(--el-surface-border, #e2e8f0);
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
:host([size='sm']) .track {
|
|
50
|
+
height: 6px;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
:host([size='md']) .track,
|
|
54
|
+
.track {
|
|
55
|
+
height: 10px;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
:host([size='lg']) .track {
|
|
59
|
+
height: 16px;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
.bar {
|
|
63
|
+
height: 100%;
|
|
64
|
+
border-radius: var(--el-radius-full, 9999px);
|
|
65
|
+
transition: width 0.3s cubic-bezier(0.4, 0, 0.2, 1);
|
|
66
|
+
font-variant-numeric: tabular-nums;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
.bar[data-variant='primary'] {
|
|
70
|
+
background: var(--el-color-primary, #2563eb);
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
.bar[data-variant='secondary'] {
|
|
74
|
+
background: var(--el-text-secondary, #475569);
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
.bar[data-variant='success'] {
|
|
78
|
+
background: var(--el-color-success, #10b981);
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
.bar[data-variant='warning'] {
|
|
82
|
+
background: var(--el-color-warning, #f59e0b);
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
.bar[data-variant='info'] {
|
|
86
|
+
background: var(--el-color-info, #0284c7);
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
.bar[data-variant='danger'] {
|
|
90
|
+
background: var(--el-color-danger, #ef4444);
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
/* Indeterminate animation */
|
|
94
|
+
:host([indeterminate]) .bar {
|
|
95
|
+
width: 40% !important;
|
|
96
|
+
position: absolute;
|
|
97
|
+
animation: el-progress-indeterminate 1.5s infinite ease-in-out;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
@keyframes el-progress-indeterminate {
|
|
101
|
+
0% {
|
|
102
|
+
left: -40%;
|
|
103
|
+
}
|
|
104
|
+
50% {
|
|
105
|
+
left: 40%;
|
|
106
|
+
width: 60%;
|
|
107
|
+
}
|
|
108
|
+
100% {
|
|
109
|
+
left: 100%;
|
|
110
|
+
width: 40%;
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
/* Striped styling */
|
|
115
|
+
:host([striped]) .bar {
|
|
116
|
+
background-image: linear-gradient(
|
|
117
|
+
45deg,
|
|
118
|
+
rgba(255, 255, 255, 0.2) 25%,
|
|
119
|
+
transparent 25%,
|
|
120
|
+
transparent 50%,
|
|
121
|
+
rgba(255, 255, 255, 0.2) 50%,
|
|
122
|
+
rgba(255, 255, 255, 0.2) 75%,
|
|
123
|
+
transparent 75%,
|
|
124
|
+
transparent
|
|
125
|
+
);
|
|
126
|
+
background-size: 1rem 1rem;
|
|
127
|
+
animation: el-progress-stripes 1s linear infinite;
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
@keyframes el-progress-stripes {
|
|
131
|
+
from {
|
|
132
|
+
background-position: 1rem 0;
|
|
133
|
+
}
|
|
134
|
+
to {
|
|
135
|
+
background-position: 0 0;
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
@media (prefers-reduced-motion: reduce) {
|
|
140
|
+
.bar,
|
|
141
|
+
:host([indeterminate]) .bar,
|
|
142
|
+
:host([striped]) .bar {
|
|
143
|
+
animation: none;
|
|
144
|
+
transition: none;
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
`;
|
|
148
|
+
|
|
149
|
+
render() {
|
|
150
|
+
const percentage = () => {
|
|
151
|
+
if (this.indeterminate.value) return '0%';
|
|
152
|
+
const clamped = Math.min(this.max.value, Math.max(0, this.value.value));
|
|
153
|
+
return `${Math.round((clamped / this.max.value) * 100)}%`;
|
|
154
|
+
};
|
|
155
|
+
|
|
156
|
+
return html`
|
|
157
|
+
<div
|
|
158
|
+
class="track"
|
|
159
|
+
part="track"
|
|
160
|
+
role="progressbar"
|
|
161
|
+
aria-valuenow=${() => (this.indeterminate.value ? null : this.value.value)}
|
|
162
|
+
aria-valuemin="0"
|
|
163
|
+
aria-valuemax=${() => this.max.value}
|
|
164
|
+
aria-label=${() => this.getAttribute('aria-label') || 'Progress'}
|
|
165
|
+
>
|
|
166
|
+
<div
|
|
167
|
+
class="bar"
|
|
168
|
+
part="bar"
|
|
169
|
+
data-variant=${() => this.variant.value}
|
|
170
|
+
style=${() => `width: ${percentage()};`}
|
|
171
|
+
></div>
|
|
172
|
+
</div>
|
|
173
|
+
`;
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
if (typeof customElements !== 'undefined' && !customElements.get('el-progress')) {
|
|
178
|
+
customElements.define('el-progress', ElProgress);
|
|
179
|
+
}
|