@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,192 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* <el-datepicker>
|
|
3
|
+
* Composite Datepicker combining <el-dropdown>, <el-input>, <el-calendar>, and <el-button>.
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
import { Elementum } from '../elementum.js';
|
|
7
|
+
import { html, css } from '../template.js';
|
|
8
|
+
import { signal } from '../signal.js';
|
|
9
|
+
import './el-dropdown.js';
|
|
10
|
+
import './el-input.js';
|
|
11
|
+
import './el-calendar.js';
|
|
12
|
+
import './el-button.js';
|
|
13
|
+
|
|
14
|
+
function getTodayString() {
|
|
15
|
+
const d = new Date();
|
|
16
|
+
const y = d.getFullYear();
|
|
17
|
+
const m = String(d.getMonth() + 1).padStart(2, '0');
|
|
18
|
+
const day = String(d.getDate()).padStart(2, '0');
|
|
19
|
+
return `${y}-${m}-${day}`;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export class ElDatepicker extends Elementum {
|
|
23
|
+
static formAssociated = true;
|
|
24
|
+
static observedAttributes = ['value', 'placeholder', 'disabled', 'required'];
|
|
25
|
+
|
|
26
|
+
value = signal('');
|
|
27
|
+
placeholder = signal('Select date...');
|
|
28
|
+
disabled = signal(false);
|
|
29
|
+
required = signal(false);
|
|
30
|
+
|
|
31
|
+
connected() {
|
|
32
|
+
this.required.value = this.hasAttribute('required');
|
|
33
|
+
this.setFormValue(this.value.value);
|
|
34
|
+
this.validate();
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
formReset() {
|
|
38
|
+
this.value.value = this.getAttribute('value') || '';
|
|
39
|
+
this.setFormValue(this.value.value);
|
|
40
|
+
this.validate();
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
attributeChanged(name, oldValue, newValue) {
|
|
44
|
+
if (name === 'required') {
|
|
45
|
+
this.required.value = newValue !== null && newValue !== 'false';
|
|
46
|
+
this.validate();
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
validate() {
|
|
51
|
+
const val = String(this.value.value || '');
|
|
52
|
+
if (this.required.value && !val.trim()) {
|
|
53
|
+
this.setValidity({ valueMissing: true }, 'Please select a date.');
|
|
54
|
+
this.setAttribute('aria-invalid', 'true');
|
|
55
|
+
return false;
|
|
56
|
+
}
|
|
57
|
+
this.setValidity({});
|
|
58
|
+
this.removeAttribute('aria-invalid');
|
|
59
|
+
return true;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
static styles = css`
|
|
63
|
+
:host {
|
|
64
|
+
display: inline-block;
|
|
65
|
+
font-family: inherit;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
el-dropdown {
|
|
69
|
+
width: 100%;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
.calendar-footer {
|
|
73
|
+
display: flex;
|
|
74
|
+
align-items: center;
|
|
75
|
+
justify-content: space-between;
|
|
76
|
+
margin-top: var(--el-spacing-sm, 8px);
|
|
77
|
+
padding-top: var(--el-spacing-xs, 4px);
|
|
78
|
+
border-top: 1px solid var(--el-surface-border, #e5e7eb);
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
.icon-prefix {
|
|
82
|
+
font-size: 1rem;
|
|
83
|
+
cursor: pointer;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
.clear-btn {
|
|
87
|
+
background: none;
|
|
88
|
+
border: none;
|
|
89
|
+
cursor: pointer;
|
|
90
|
+
font-size: 0.875rem;
|
|
91
|
+
color: var(--el-text-muted, #6b7280);
|
|
92
|
+
padding: 2px 6px;
|
|
93
|
+
border-radius: var(--el-radius-sm, 4px);
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
.clear-btn:hover {
|
|
97
|
+
background: var(--el-surface-muted, #f3f4f6);
|
|
98
|
+
color: var(--el-text-base, #111827);
|
|
99
|
+
}
|
|
100
|
+
`;
|
|
101
|
+
|
|
102
|
+
#getDropdown() {
|
|
103
|
+
return this.root.querySelector('el-dropdown');
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
#onDateSelect = (e) => {
|
|
107
|
+
const selected = e.detail.date;
|
|
108
|
+
this.value.value = selected;
|
|
109
|
+
this.setFormValue(selected);
|
|
110
|
+
this.validate();
|
|
111
|
+
this.emit('change', { value: selected });
|
|
112
|
+
this.#getDropdown()?.close();
|
|
113
|
+
};
|
|
114
|
+
|
|
115
|
+
#selectToday = () => {
|
|
116
|
+
const today = getTodayString();
|
|
117
|
+
this.value.value = today;
|
|
118
|
+
this.setFormValue(today);
|
|
119
|
+
this.validate();
|
|
120
|
+
this.emit('change', { value: today });
|
|
121
|
+
this.#getDropdown()?.close();
|
|
122
|
+
};
|
|
123
|
+
|
|
124
|
+
#clear = (e) => {
|
|
125
|
+
e?.stopPropagation();
|
|
126
|
+
this.value.value = '';
|
|
127
|
+
this.setFormValue('');
|
|
128
|
+
this.validate();
|
|
129
|
+
this.emit('change', { value: '' });
|
|
130
|
+
};
|
|
131
|
+
|
|
132
|
+
render() {
|
|
133
|
+
return html`
|
|
134
|
+
<el-dropdown part="dropdown">
|
|
135
|
+
<!-- TRIGGER: The Input Component -->
|
|
136
|
+
<el-input
|
|
137
|
+
slot="trigger"
|
|
138
|
+
part="input"
|
|
139
|
+
readonly
|
|
140
|
+
.value=${this.value}
|
|
141
|
+
placeholder=${this.placeholder}
|
|
142
|
+
?disabled=${this.disabled}
|
|
143
|
+
>
|
|
144
|
+
<span slot="prefix" class="icon-prefix">📅</span>
|
|
145
|
+
${() =>
|
|
146
|
+
this.value.value
|
|
147
|
+
? html`
|
|
148
|
+
<button
|
|
149
|
+
slot="suffix"
|
|
150
|
+
type="button"
|
|
151
|
+
class="clear-btn"
|
|
152
|
+
title="Clear date"
|
|
153
|
+
@click=${this.#clear}
|
|
154
|
+
>
|
|
155
|
+
✕
|
|
156
|
+
</button>
|
|
157
|
+
`
|
|
158
|
+
: ''}
|
|
159
|
+
</el-input>
|
|
160
|
+
|
|
161
|
+
<!-- DROPDOWN CONTENT: Calendar & Quick Action Buttons -->
|
|
162
|
+
<div part="panel-content">
|
|
163
|
+
<el-calendar
|
|
164
|
+
.value=${this.value}
|
|
165
|
+
@select=${this.#onDateSelect}
|
|
166
|
+
></el-calendar>
|
|
167
|
+
|
|
168
|
+
<div class="calendar-footer">
|
|
169
|
+
<el-button
|
|
170
|
+
variant="ghost"
|
|
171
|
+
size="sm"
|
|
172
|
+
@click=${this.#clear}
|
|
173
|
+
>
|
|
174
|
+
Clear
|
|
175
|
+
</el-button>
|
|
176
|
+
<el-button
|
|
177
|
+
variant="primary"
|
|
178
|
+
size="sm"
|
|
179
|
+
@click=${this.#selectToday}
|
|
180
|
+
>
|
|
181
|
+
Today
|
|
182
|
+
</el-button>
|
|
183
|
+
</div>
|
|
184
|
+
</div>
|
|
185
|
+
</el-dropdown>
|
|
186
|
+
`;
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
if (typeof customElements !== 'undefined' && !customElements.get('el-datepicker')) {
|
|
191
|
+
customElements.define('el-datepicker', ElDatepicker);
|
|
192
|
+
}
|
|
@@ -0,0 +1,272 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* <el-dialog>
|
|
3
|
+
* Accessible modal dialog powered by the native <dialog> element.
|
|
4
|
+
* Follows modern web guidance with overscroll containment and top-layer rendering.
|
|
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 ElDialog extends Elementum {
|
|
12
|
+
static observedAttributes = ['open', 'title', 'heading'];
|
|
13
|
+
|
|
14
|
+
isOpen = signal(false);
|
|
15
|
+
titleText = signal('');
|
|
16
|
+
|
|
17
|
+
static styles = css`
|
|
18
|
+
:host {
|
|
19
|
+
display: contents;
|
|
20
|
+
font-family: inherit;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
dialog {
|
|
24
|
+
margin: auto;
|
|
25
|
+
padding: 0;
|
|
26
|
+
border: 1px solid var(--el-surface-border, #e5e7eb);
|
|
27
|
+
border-radius: var(--el-radius-lg, 16px);
|
|
28
|
+
background: var(--el-surface-base, #ffffff);
|
|
29
|
+
color: var(--el-text-base, #111827);
|
|
30
|
+
box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 8px 10px -6px rgba(0, 0, 0, 0.1);
|
|
31
|
+
width: min(90vw, 500px);
|
|
32
|
+
box-sizing: border-box;
|
|
33
|
+
overscroll-behavior: contain;
|
|
34
|
+
opacity: 0;
|
|
35
|
+
transform: scale(0.96) translateY(8px);
|
|
36
|
+
transition: opacity 180ms ease, transform 180ms cubic-bezier(0.16, 1, 0.3, 1), display 180ms allow-discrete, overlay 180ms allow-discrete;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
dialog[open] {
|
|
40
|
+
opacity: 1;
|
|
41
|
+
transform: scale(1) translateY(0);
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
@starting-style {
|
|
45
|
+
dialog[open] {
|
|
46
|
+
opacity: 0;
|
|
47
|
+
transform: scale(0.96) translateY(8px);
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
dialog::backdrop {
|
|
52
|
+
background: rgba(0, 0, 0, 0.45);
|
|
53
|
+
backdrop-filter: blur(2px);
|
|
54
|
+
overflow: hidden;
|
|
55
|
+
overscroll-behavior: contain;
|
|
56
|
+
opacity: 0;
|
|
57
|
+
transition: opacity 180ms ease, display 180ms allow-discrete, overlay 180ms allow-discrete;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
dialog[open]::backdrop {
|
|
61
|
+
opacity: 1;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
@starting-style {
|
|
65
|
+
dialog[open]::backdrop {
|
|
66
|
+
opacity: 0;
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
.dialog-container {
|
|
71
|
+
display: flex;
|
|
72
|
+
flex-direction: column;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
.dialog-header {
|
|
76
|
+
display: flex;
|
|
77
|
+
align-items: center;
|
|
78
|
+
justify-content: space-between;
|
|
79
|
+
padding: var(--el-spacing-md, 16px) var(--el-spacing-lg, 24px);
|
|
80
|
+
border-bottom: 1px solid var(--el-surface-border, #e5e7eb);
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
.dialog-title {
|
|
84
|
+
font-size: 1.125rem;
|
|
85
|
+
font-weight: 600;
|
|
86
|
+
margin: 0;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
.close-button {
|
|
90
|
+
background: none;
|
|
91
|
+
border: none;
|
|
92
|
+
font-size: 1.25rem;
|
|
93
|
+
cursor: pointer;
|
|
94
|
+
color: var(--el-text-muted, #6b7280);
|
|
95
|
+
padding: 4px 8px;
|
|
96
|
+
border-radius: var(--el-radius-sm, 4px);
|
|
97
|
+
line-height: 1;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
.close-button:hover {
|
|
101
|
+
background: var(--el-surface-muted, #f3f4f6);
|
|
102
|
+
color: var(--el-text-base, #111827);
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
.dialog-body {
|
|
106
|
+
padding: var(--el-spacing-lg, 24px);
|
|
107
|
+
overflow-y: auto;
|
|
108
|
+
max-height: 60vh;
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
.dialog-footer {
|
|
112
|
+
display: flex;
|
|
113
|
+
align-items: center;
|
|
114
|
+
justify-content: flex-end;
|
|
115
|
+
gap: var(--el-spacing-sm, 8px);
|
|
116
|
+
padding: var(--el-spacing-md, 16px) var(--el-spacing-lg, 24px);
|
|
117
|
+
border-top: 1px solid var(--el-surface-border, #e5e7eb);
|
|
118
|
+
background: var(--el-surface-muted, #f8fafc);
|
|
119
|
+
border-bottom-left-radius: var(--el-radius-lg, 16px);
|
|
120
|
+
border-bottom-right-radius: var(--el-radius-lg, 16px);
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
@media (max-width: 640px) {
|
|
124
|
+
dialog {
|
|
125
|
+
width: calc(100vw - 24px);
|
|
126
|
+
max-height: calc(100dvh - 32px);
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
.dialog-header,
|
|
130
|
+
.dialog-body,
|
|
131
|
+
.dialog-footer {
|
|
132
|
+
padding-left: var(--el-spacing-md, 16px);
|
|
133
|
+
padding-right: var(--el-spacing-md, 16px);
|
|
134
|
+
padding-bottom: calc(var(--el-spacing-md, 16px) + env(safe-area-inset-bottom, 0px));
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
`;
|
|
138
|
+
|
|
139
|
+
#previousActiveElement = null;
|
|
140
|
+
|
|
141
|
+
#getNativeDialog() {
|
|
142
|
+
return this.root?.querySelector('dialog') || null;
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
connected() {
|
|
146
|
+
this.titleText.value = this.getAttribute('heading') || this.getAttribute('title') || '';
|
|
147
|
+
this.setAttribute('data-state', this.isOpen.value ? 'open' : 'closed');
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
rendered() {
|
|
151
|
+
if (this.hasAttribute('open') && this.getAttribute('open') !== 'false') {
|
|
152
|
+
this.showModal();
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
attributeChanged(name, oldValue, newValue) {
|
|
157
|
+
if (name === 'open') {
|
|
158
|
+
const shouldOpen = newValue !== null && newValue !== 'false';
|
|
159
|
+
if (shouldOpen) this.showModal();
|
|
160
|
+
else this.close();
|
|
161
|
+
} else if (name === 'title' || name === 'heading') {
|
|
162
|
+
this.titleText.value = newValue || this.getAttribute('heading') || this.getAttribute('title') || '';
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
show() {
|
|
167
|
+
this.showModal();
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
showModal() {
|
|
171
|
+
const dlg = this.#getNativeDialog();
|
|
172
|
+
if (dlg && !dlg.open) {
|
|
173
|
+
if (typeof document !== 'undefined' && document.activeElement) {
|
|
174
|
+
this.#previousActiveElement = document.activeElement;
|
|
175
|
+
}
|
|
176
|
+
dlg.showModal();
|
|
177
|
+
this.isOpen.value = true;
|
|
178
|
+
this.setAttribute('data-state', 'open');
|
|
179
|
+
dlg.setAttribute('data-state', 'open');
|
|
180
|
+
this.emit('open');
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
close(returnValue = '') {
|
|
185
|
+
const dlg = this.#getNativeDialog();
|
|
186
|
+
if (dlg && dlg.open) {
|
|
187
|
+
dlg.close(returnValue);
|
|
188
|
+
this.isOpen.value = false;
|
|
189
|
+
this.setAttribute('data-state', 'closed');
|
|
190
|
+
dlg.setAttribute('data-state', 'closed');
|
|
191
|
+
if (this.hasAttribute('open')) {
|
|
192
|
+
this.removeAttribute('open');
|
|
193
|
+
}
|
|
194
|
+
this.emit('close', { returnValue });
|
|
195
|
+
this.#restoreFocus();
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
#restoreFocus() {
|
|
200
|
+
if (this.#previousActiveElement && typeof this.#previousActiveElement.focus === 'function') {
|
|
201
|
+
try {
|
|
202
|
+
this.#previousActiveElement.focus();
|
|
203
|
+
} catch {
|
|
204
|
+
// Ignore focus failures if detached
|
|
205
|
+
}
|
|
206
|
+
this.#previousActiveElement = null;
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
#onBackdropClick = (e) => {
|
|
211
|
+
const dlg = this.#getNativeDialog();
|
|
212
|
+
if (!dlg) return;
|
|
213
|
+
const rect = dlg.getBoundingClientRect();
|
|
214
|
+
const isInDialog = (
|
|
215
|
+
rect.top <= e.clientY &&
|
|
216
|
+
e.clientY <= rect.top + rect.height &&
|
|
217
|
+
rect.left <= e.clientX &&
|
|
218
|
+
e.clientX <= rect.left + rect.width
|
|
219
|
+
);
|
|
220
|
+
if (!isInDialog) {
|
|
221
|
+
this.close('cancel');
|
|
222
|
+
}
|
|
223
|
+
};
|
|
224
|
+
|
|
225
|
+
#onDialogClose = (e) => {
|
|
226
|
+
const dlg = e.target;
|
|
227
|
+
this.isOpen.value = false;
|
|
228
|
+
const returnValue = dlg.returnValue;
|
|
229
|
+
dlg.returnValue = ''; // Reset per modern web guidance to prevent stale leaks
|
|
230
|
+
this.emit('close', { returnValue });
|
|
231
|
+
this.#restoreFocus();
|
|
232
|
+
};
|
|
233
|
+
|
|
234
|
+
render() {
|
|
235
|
+
return html`
|
|
236
|
+
<dialog
|
|
237
|
+
part="dialog"
|
|
238
|
+
aria-labelledby="dialog-title"
|
|
239
|
+
@click=${this.#onBackdropClick}
|
|
240
|
+
@close=${this.#onDialogClose}
|
|
241
|
+
>
|
|
242
|
+
<div class="dialog-container">
|
|
243
|
+
<div class="dialog-header">
|
|
244
|
+
<h2 id="dialog-title" class="dialog-title">
|
|
245
|
+
<slot name="header">${() => this.titleText.value}</slot>
|
|
246
|
+
</h2>
|
|
247
|
+
<button
|
|
248
|
+
type="button"
|
|
249
|
+
class="close-button"
|
|
250
|
+
aria-label="Close dialog"
|
|
251
|
+
@click=${() => this.close('cancel')}
|
|
252
|
+
>
|
|
253
|
+
✕
|
|
254
|
+
</button>
|
|
255
|
+
</div>
|
|
256
|
+
|
|
257
|
+
<div class="dialog-body" part="body">
|
|
258
|
+
<slot></slot>
|
|
259
|
+
</div>
|
|
260
|
+
|
|
261
|
+
<div class="dialog-footer" part="footer">
|
|
262
|
+
<slot name="footer"></slot>
|
|
263
|
+
</div>
|
|
264
|
+
</div>
|
|
265
|
+
</dialog>
|
|
266
|
+
`;
|
|
267
|
+
}
|
|
268
|
+
}
|
|
269
|
+
|
|
270
|
+
if (typeof customElements !== 'undefined' && !customElements.get('el-dialog')) {
|
|
271
|
+
customElements.define('el-dialog', ElDialog);
|
|
272
|
+
}
|