@wcomp/elementum 0.0.0-stage → 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 +282 -2
- package/custom-elements.json +3613 -0
- package/mcp/server.js +593 -0
- package/package.json +77 -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/behaviors/index.js +760 -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 +231 -0
- package/src/components/el-calendar.js +436 -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 +230 -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 +229 -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 +183 -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 +164 -0
- package/src/components/el-otp-input.js +266 -0
- package/src/components/el-pagination.js +231 -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 +220 -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 +504 -0
- package/src/index.d.ts +1093 -0
- package/src/index.js +112 -0
- package/src/signal.js +215 -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,182 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* <el-dropdown>
|
|
3
|
+
* Accessible overlay container with light-dismiss, trigger slot, and anchor positioning.
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
import { Elementum } from '../elementum.js';
|
|
7
|
+
import { html, css } from '../template.js';
|
|
8
|
+
import { signal } from '../signal.js';
|
|
9
|
+
|
|
10
|
+
export class ElDropdown extends Elementum {
|
|
11
|
+
static observedAttributes = ['open'];
|
|
12
|
+
|
|
13
|
+
isOpen = signal(false);
|
|
14
|
+
|
|
15
|
+
static styles = css`
|
|
16
|
+
:host {
|
|
17
|
+
display: inline-block;
|
|
18
|
+
position: relative;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
.trigger-wrapper {
|
|
22
|
+
display: inline-block;
|
|
23
|
+
width: 100%;
|
|
24
|
+
cursor: pointer;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
.panel {
|
|
28
|
+
position: absolute;
|
|
29
|
+
top: calc(100% + var(--el-spacing-xs, 4px));
|
|
30
|
+
left: 0;
|
|
31
|
+
z-index: 1000;
|
|
32
|
+
min-width: var(--anchor-width, 240px);
|
|
33
|
+
max-width: calc(100vw - 24px);
|
|
34
|
+
max-height: var(--available-height, 400px);
|
|
35
|
+
overflow-y: auto;
|
|
36
|
+
background: var(--el-surface-base, #ffffff);
|
|
37
|
+
border: 1px solid var(--el-surface-border, #e5e7eb);
|
|
38
|
+
border-radius: var(--el-radius-md, 8px);
|
|
39
|
+
box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -4px rgba(0, 0, 0, 0.1);
|
|
40
|
+
padding: var(--el-spacing-sm, 8px);
|
|
41
|
+
box-sizing: border-box;
|
|
42
|
+
opacity: 0;
|
|
43
|
+
transform: translateY(-4px) scale(0.98);
|
|
44
|
+
transform-origin: var(--transform-origin, top left);
|
|
45
|
+
pointer-events: none;
|
|
46
|
+
transition: opacity 150ms ease, transform 150ms ease;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
.panel.open,
|
|
50
|
+
.panel[data-state="open"],
|
|
51
|
+
:host([data-state="open"]) .panel {
|
|
52
|
+
opacity: 1;
|
|
53
|
+
transform: translateY(0) scale(1);
|
|
54
|
+
pointer-events: auto;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
@starting-style {
|
|
58
|
+
.panel[data-state="open"],
|
|
59
|
+
:host([data-state="open"]) .panel {
|
|
60
|
+
opacity: 0;
|
|
61
|
+
transform: translateY(-4px) scale(0.98);
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
`;
|
|
65
|
+
|
|
66
|
+
connected() {
|
|
67
|
+
if (this.hasAttribute('open') && this.getAttribute('open') !== 'false') {
|
|
68
|
+
this.isOpen.value = true;
|
|
69
|
+
}
|
|
70
|
+
this.setAttribute('data-state', this.isOpen.value ? 'open' : 'closed');
|
|
71
|
+
this.setAttribute('data-side', 'bottom');
|
|
72
|
+
|
|
73
|
+
// Light-dismiss: close on click outside or escape key
|
|
74
|
+
const onDocPointerDown = (e) => {
|
|
75
|
+
if (!this.isOpen.value) return;
|
|
76
|
+
// Check if click was inside this component (or shadow root)
|
|
77
|
+
const path = e.composedPath();
|
|
78
|
+
if (!path.includes(this)) {
|
|
79
|
+
this.close();
|
|
80
|
+
}
|
|
81
|
+
};
|
|
82
|
+
|
|
83
|
+
const onDocKeyDown = (e) => {
|
|
84
|
+
if (this.isOpen.value && e.key === 'Escape') {
|
|
85
|
+
this.close();
|
|
86
|
+
e.stopPropagation();
|
|
87
|
+
}
|
|
88
|
+
};
|
|
89
|
+
|
|
90
|
+
document.addEventListener('pointerdown', onDocPointerDown, { signal: this.signal });
|
|
91
|
+
document.addEventListener('keydown', onDocKeyDown, { signal: this.signal });
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
rendered() {
|
|
95
|
+
if (this.isOpen.value) {
|
|
96
|
+
this.#updateAnchorMetrics();
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
attributeChanged(name, oldValue, newValue) {
|
|
101
|
+
if (name === 'open') {
|
|
102
|
+
const shouldOpen = newValue !== null && newValue !== 'false';
|
|
103
|
+
if (shouldOpen) this.open();
|
|
104
|
+
else this.close();
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
#updateAnchorMetrics() {
|
|
109
|
+
if (typeof window === 'undefined') return;
|
|
110
|
+
const trigger = this.root?.querySelector('.trigger-wrapper') || this;
|
|
111
|
+
if (trigger && typeof trigger.getBoundingClientRect === 'function') {
|
|
112
|
+
const rect = trigger.getBoundingClientRect();
|
|
113
|
+
const anchorW = Math.round(rect.width);
|
|
114
|
+
const availH = Math.max(120, Math.round(window.innerHeight - rect.bottom - 16));
|
|
115
|
+
this.style.setProperty('--anchor-width', `${anchorW}px`);
|
|
116
|
+
this.style.setProperty('--available-height', `${availH}px`);
|
|
117
|
+
this.style.setProperty('--transform-origin', 'top left');
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
open() {
|
|
122
|
+
if (!this.isOpen.value) {
|
|
123
|
+
this.#updateAnchorMetrics();
|
|
124
|
+
this.isOpen.value = true;
|
|
125
|
+
this.setAttribute('data-state', 'open');
|
|
126
|
+
this.emit('open');
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
show() {
|
|
131
|
+
this.open();
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
close() {
|
|
135
|
+
if (this.isOpen.value) {
|
|
136
|
+
this.isOpen.value = false;
|
|
137
|
+
this.setAttribute('data-state', 'closed');
|
|
138
|
+
this.emit('close');
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
hide() {
|
|
143
|
+
this.close();
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
toggle() {
|
|
147
|
+
if (this.isOpen.value) {
|
|
148
|
+
this.close();
|
|
149
|
+
} else {
|
|
150
|
+
this.open();
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
render() {
|
|
155
|
+
return html`
|
|
156
|
+
<div
|
|
157
|
+
class="trigger-wrapper"
|
|
158
|
+
part="trigger"
|
|
159
|
+
@click=${() => this.toggle()}
|
|
160
|
+
>
|
|
161
|
+
<slot name="trigger"></slot>
|
|
162
|
+
</div>
|
|
163
|
+
|
|
164
|
+
<div
|
|
165
|
+
class=${() => `panel ${this.isOpen.value ? 'open' : ''}`}
|
|
166
|
+
data-state=${() => (this.isOpen.value ? 'open' : 'closed')}
|
|
167
|
+
data-side="bottom"
|
|
168
|
+
part="panel"
|
|
169
|
+
role="region"
|
|
170
|
+
aria-hidden=${() => !this.isOpen.value}
|
|
171
|
+
>
|
|
172
|
+
<slot name="menu"></slot>
|
|
173
|
+
<slot name="content"></slot>
|
|
174
|
+
<slot></slot>
|
|
175
|
+
</div>
|
|
176
|
+
`;
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
if (typeof customElements !== 'undefined' && !customElements.get('el-dropdown')) {
|
|
181
|
+
customElements.define('el-dropdown', ElDropdown);
|
|
182
|
+
}
|
|
@@ -0,0 +1,242 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* <el-dropzone>
|
|
3
|
+
* Accessible drag-and-drop file upload target inspired by shadcn/ui community.
|
|
4
|
+
* Handles dragenter, dragover, dragleave, drop, file type filtering,
|
|
5
|
+
* max file size checks, and programmatic file dialog triggers.
|
|
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 ElDropzone extends Elementum {
|
|
13
|
+
static observedAttributes = ['accept', 'max-size', 'multiple', 'disabled'];
|
|
14
|
+
|
|
15
|
+
accept = signal('');
|
|
16
|
+
maxSize = signal(null); // in bytes
|
|
17
|
+
multiple = signal(false);
|
|
18
|
+
disabled = signal(false);
|
|
19
|
+
isDragOver = signal(false);
|
|
20
|
+
selectedFiles = signal([]);
|
|
21
|
+
|
|
22
|
+
static styles = css`
|
|
23
|
+
:host {
|
|
24
|
+
display: block;
|
|
25
|
+
font-family: var(--el-font-sans, system-ui, sans-serif);
|
|
26
|
+
box-sizing: border-box;
|
|
27
|
+
width: 100%;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
.dropzone-box {
|
|
31
|
+
display: flex;
|
|
32
|
+
flex-direction: column;
|
|
33
|
+
align-items: center;
|
|
34
|
+
justify-content: center;
|
|
35
|
+
padding: 32px 20px;
|
|
36
|
+
border: 2px dashed var(--el-surface-border, #cbd5e1);
|
|
37
|
+
border-radius: var(--el-radius-lg, 12px);
|
|
38
|
+
background: var(--el-surface-base, #ffffff);
|
|
39
|
+
cursor: pointer;
|
|
40
|
+
text-align: center;
|
|
41
|
+
transition: border-color 0.15s ease, background-color 0.15s ease;
|
|
42
|
+
position: relative;
|
|
43
|
+
box-sizing: border-box;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
:root[data-theme="dark"] .dropzone-box {
|
|
47
|
+
background: #1e293b;
|
|
48
|
+
border-color: #334155;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
.dropzone-box:hover:not(.disabled),
|
|
52
|
+
.dropzone-box.dragover {
|
|
53
|
+
border-color: var(--el-color-primary, #2563eb);
|
|
54
|
+
background: rgba(37, 99, 235, 0.03);
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
:root[data-theme="dark"] .dropzone-box:hover:not(.disabled),
|
|
58
|
+
:root[data-theme="dark"] .dropzone-box.dragover {
|
|
59
|
+
background: rgba(59, 130, 246, 0.1);
|
|
60
|
+
border-color: #3b82f6;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
.dropzone-box.disabled {
|
|
64
|
+
opacity: 0.6;
|
|
65
|
+
cursor: not-allowed;
|
|
66
|
+
background: var(--el-surface-muted, #f8fafc);
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
.icon {
|
|
70
|
+
width: 44px;
|
|
71
|
+
height: 44px;
|
|
72
|
+
border-radius: 999px;
|
|
73
|
+
background: var(--el-surface-muted, #f1f5f9);
|
|
74
|
+
display: flex;
|
|
75
|
+
align-items: center;
|
|
76
|
+
justify-content: center;
|
|
77
|
+
margin-bottom: 12px;
|
|
78
|
+
color: var(--el-color-primary, #2563eb);
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
:root[data-theme="dark"] .icon {
|
|
82
|
+
background: #0f172a;
|
|
83
|
+
color: #60a5fa;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
.headline {
|
|
87
|
+
font-size: 0.95rem;
|
|
88
|
+
font-weight: 600;
|
|
89
|
+
color: var(--el-text-primary, #0f172a);
|
|
90
|
+
margin: 0 0 4px 0;
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
:root[data-theme="dark"] .headline {
|
|
94
|
+
color: #f8fafc;
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
.subtext {
|
|
98
|
+
font-size: 0.8rem;
|
|
99
|
+
color: var(--el-text-muted, #64748b);
|
|
100
|
+
margin: 0;
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
.file-input {
|
|
104
|
+
display: none;
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
.file-list {
|
|
108
|
+
margin-top: 12px;
|
|
109
|
+
display: flex;
|
|
110
|
+
flex-direction: column;
|
|
111
|
+
gap: 6px;
|
|
112
|
+
width: 100%;
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
.file-item {
|
|
116
|
+
display: flex;
|
|
117
|
+
align-items: center;
|
|
118
|
+
justify-content: space-between;
|
|
119
|
+
padding: 6px 12px;
|
|
120
|
+
background: var(--el-surface-muted, #f1f5f9);
|
|
121
|
+
border-radius: var(--el-radius-sm, 6px);
|
|
122
|
+
font-size: 0.8rem;
|
|
123
|
+
color: var(--el-text-secondary, #334155);
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
:root[data-theme="dark"] .file-item {
|
|
127
|
+
background: #0f172a;
|
|
128
|
+
color: #94a3b8;
|
|
129
|
+
}
|
|
130
|
+
`;
|
|
131
|
+
|
|
132
|
+
connected() {
|
|
133
|
+
this.#syncAttrs();
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
attributeChanged(name, oldValue, newValue) {
|
|
137
|
+
this.#syncAttrs();
|
|
138
|
+
return true;
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
#syncAttrs() {
|
|
142
|
+
this.accept.value = this.getAttribute('accept') || '';
|
|
143
|
+
this.maxSize.value = this.hasAttribute('max-size') ? parseInt(this.getAttribute('max-size'), 10) : null;
|
|
144
|
+
this.multiple.value = this.hasAttribute('multiple');
|
|
145
|
+
this.disabled.value = this.hasAttribute('disabled');
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
openFileDialog = () => {
|
|
149
|
+
if (this.disabled.value) return;
|
|
150
|
+
const input = this.shadowRoot?.querySelector('.file-input');
|
|
151
|
+
input?.click();
|
|
152
|
+
};
|
|
153
|
+
|
|
154
|
+
#onDragOver = (e) => {
|
|
155
|
+
e.preventDefault();
|
|
156
|
+
if (this.disabled.value) return;
|
|
157
|
+
this.isDragOver.value = true;
|
|
158
|
+
};
|
|
159
|
+
|
|
160
|
+
#onDragLeave = () => {
|
|
161
|
+
this.isDragOver.value = false;
|
|
162
|
+
};
|
|
163
|
+
|
|
164
|
+
#onDrop = (e) => {
|
|
165
|
+
e.preventDefault();
|
|
166
|
+
this.isDragOver.value = false;
|
|
167
|
+
if (this.disabled.value) return;
|
|
168
|
+
|
|
169
|
+
if (e.dataTransfer?.files) {
|
|
170
|
+
this.#processFiles(Array.from(e.dataTransfer.files));
|
|
171
|
+
}
|
|
172
|
+
};
|
|
173
|
+
|
|
174
|
+
#onFileInputChange = (e) => {
|
|
175
|
+
if (e.target.files) {
|
|
176
|
+
this.#processFiles(Array.from(e.target.files));
|
|
177
|
+
}
|
|
178
|
+
};
|
|
179
|
+
|
|
180
|
+
#processFiles(files) {
|
|
181
|
+
let validFiles = files;
|
|
182
|
+
|
|
183
|
+
if (this.maxSize.value) {
|
|
184
|
+
validFiles = validFiles.filter(f => f.size <= this.maxSize.value);
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
if (!this.multiple.value && validFiles.length > 1) {
|
|
188
|
+
validFiles = [validFiles[0]];
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
this.selectedFiles.value = validFiles;
|
|
192
|
+
this.emit('files-selected', { files: validFiles });
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
render() {
|
|
196
|
+
return html`
|
|
197
|
+
<div
|
|
198
|
+
class=${() => `dropzone-box ${this.isDragOver.value ? 'dragover' : ''} ${this.disabled.value ? 'disabled' : ''}`}
|
|
199
|
+
part="dropzone"
|
|
200
|
+
role="button"
|
|
201
|
+
tabindex="0"
|
|
202
|
+
onclick=${this.openFileDialog}
|
|
203
|
+
ondragover=${this.#onDragOver}
|
|
204
|
+
ondragleave=${this.#onDragLeave}
|
|
205
|
+
ondrop=${this.#onDrop}
|
|
206
|
+
>
|
|
207
|
+
<input
|
|
208
|
+
type="file"
|
|
209
|
+
class="file-input"
|
|
210
|
+
accept=${() => this.accept.value}
|
|
211
|
+
?multiple=${() => this.multiple.value}
|
|
212
|
+
onchange=${this.#onFileInputChange}
|
|
213
|
+
/>
|
|
214
|
+
<div class="icon" part="icon">
|
|
215
|
+
<slot name="icon">
|
|
216
|
+
<svg width="22" height="22" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4"/><polyline points="17 8 12 3 7 8"/><line x1="12" y1="3" x2="12" y2="15"/></svg>
|
|
217
|
+
</slot>
|
|
218
|
+
</div>
|
|
219
|
+
<p class="headline" part="headline">
|
|
220
|
+
<slot name="title">Click to upload or drag & drop</slot>
|
|
221
|
+
</p>
|
|
222
|
+
<p class="subtext" part="subtext">
|
|
223
|
+
<slot name="description">Any file up to 10MB</slot>
|
|
224
|
+
</p>
|
|
225
|
+
</div>
|
|
226
|
+
|
|
227
|
+
${() => {
|
|
228
|
+
const files = this.selectedFiles.value;
|
|
229
|
+
if (files.length === 0) return '';
|
|
230
|
+
return html`
|
|
231
|
+
<div class="file-list" part="file-list">
|
|
232
|
+
${files.map(f => html`<div class="file-item"><span>📄 ${f.name}</span><span>${(f.size / 1024).toFixed(1)} KB</span></div>`)}
|
|
233
|
+
</div>
|
|
234
|
+
`;
|
|
235
|
+
}}
|
|
236
|
+
`;
|
|
237
|
+
}
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
if (typeof customElements !== 'undefined' && !customElements.get('el-dropzone')) {
|
|
241
|
+
customElements.define('el-dropzone', ElDropzone);
|
|
242
|
+
}
|
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* <el-empty-state>
|
|
3
|
+
* Accessible zero-data feedback placeholder inspired by shadcn/ui.
|
|
4
|
+
* Renders an illustrative graphic/icon, headline title, description text,
|
|
5
|
+
* and customizable action buttons.
|
|
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 ElEmptyState extends Elementum {
|
|
13
|
+
static observedAttributes = ['title', 'description', 'icon'];
|
|
14
|
+
|
|
15
|
+
stateTitle = signal('');
|
|
16
|
+
stateDescription = signal('');
|
|
17
|
+
stateIcon = signal('');
|
|
18
|
+
|
|
19
|
+
static styles = css`
|
|
20
|
+
:host {
|
|
21
|
+
display: flex;
|
|
22
|
+
flex-direction: column;
|
|
23
|
+
align-items: center;
|
|
24
|
+
justify-content: center;
|
|
25
|
+
text-align: center;
|
|
26
|
+
padding: 48px 24px;
|
|
27
|
+
border: 2px dashed var(--el-surface-border, #e2e8f0);
|
|
28
|
+
border-radius: var(--el-radius-lg, 12px);
|
|
29
|
+
background: var(--el-surface-base, #ffffff);
|
|
30
|
+
font-family: var(--el-font-sans, system-ui, sans-serif);
|
|
31
|
+
box-sizing: border-box;
|
|
32
|
+
width: 100%;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
:root[data-theme="dark"] :host {
|
|
36
|
+
background: #1e293b;
|
|
37
|
+
border-color: #334155;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
.icon-container {
|
|
41
|
+
width: 54px;
|
|
42
|
+
height: 54px;
|
|
43
|
+
border-radius: 999px;
|
|
44
|
+
background: var(--el-surface-muted, #f1f5f9);
|
|
45
|
+
display: flex;
|
|
46
|
+
align-items: center;
|
|
47
|
+
justify-content: center;
|
|
48
|
+
margin-bottom: 16px;
|
|
49
|
+
color: var(--el-text-muted, #64748b);
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
:root[data-theme="dark"] .icon-container {
|
|
53
|
+
background: #0f172a;
|
|
54
|
+
color: #94a3b8;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
.title {
|
|
58
|
+
font-size: 1.15rem;
|
|
59
|
+
font-weight: 700;
|
|
60
|
+
color: var(--el-text-primary, #0f172a);
|
|
61
|
+
margin: 0 0 6px 0;
|
|
62
|
+
letter-spacing: -0.02em;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
:root[data-theme="dark"] .title {
|
|
66
|
+
color: #f8fafc;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
.description {
|
|
70
|
+
font-size: 0.875rem;
|
|
71
|
+
color: var(--el-text-secondary, #64748b);
|
|
72
|
+
max-width: 420px;
|
|
73
|
+
line-height: 1.5;
|
|
74
|
+
margin: 0 0 20px 0;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
:root[data-theme="dark"] .description {
|
|
78
|
+
color: #94a3b8;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
.actions {
|
|
82
|
+
display: flex;
|
|
83
|
+
align-items: center;
|
|
84
|
+
gap: 12px;
|
|
85
|
+
flex-wrap: wrap;
|
|
86
|
+
justify-content: center;
|
|
87
|
+
}
|
|
88
|
+
`;
|
|
89
|
+
|
|
90
|
+
connected() {
|
|
91
|
+
this.#syncAttrs();
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
attributeChanged(name, oldValue, newValue) {
|
|
95
|
+
this.#syncAttrs();
|
|
96
|
+
return true;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
#syncAttrs() {
|
|
100
|
+
this.stateTitle.value = this.getAttribute('title') || 'No items found';
|
|
101
|
+
this.stateDescription.value = this.getAttribute('description') || '';
|
|
102
|
+
this.stateIcon.value = this.getAttribute('icon') || '';
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
render() {
|
|
106
|
+
return html`
|
|
107
|
+
<div class="icon-container" part="icon">
|
|
108
|
+
<slot name="icon">
|
|
109
|
+
${() =>
|
|
110
|
+
this.stateIcon.value
|
|
111
|
+
? html`<span style="font-size: 1.5rem; line-height: 1;">${() => this.stateIcon.value}</span>`
|
|
112
|
+
: html`<svg width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><circle cx="11" cy="11" r="8"/><path d="m21 21-4.3-4.3"/></svg>`}
|
|
113
|
+
</slot>
|
|
114
|
+
</div>
|
|
115
|
+
<h3 class="title" part="title">${() => this.stateTitle.value}</h3>
|
|
116
|
+
${() =>
|
|
117
|
+
this.stateDescription.value
|
|
118
|
+
? html`<p class="description" part="description">${() => this.stateDescription.value}</p>`
|
|
119
|
+
: html`<div class="description" part="description"><slot></slot></div>`
|
|
120
|
+
}
|
|
121
|
+
<div class="actions" part="actions">
|
|
122
|
+
<slot name="action"></slot>
|
|
123
|
+
</div>
|
|
124
|
+
`;
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
if (typeof customElements !== 'undefined' && !customElements.get('el-empty-state')) {
|
|
129
|
+
customElements.define('el-empty-state', ElEmptyState);
|
|
130
|
+
}
|