@adia-ai/web-components 0.0.26 → 0.0.27
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/components/agent-artifact/agent-artifact.a2ui.json +1 -1
- package/components/agent-artifact/agent-artifact.css +11 -0
- package/components/agent-artifact/agent-artifact.js +23 -2
- package/components/agent-artifact/agent-artifact.yaml +1 -1
- package/components/agent-reasoning/agent-reasoning.css +11 -0
- package/components/agent-reasoning/agent-reasoning.js +16 -0
- package/components/agent-trace/agent-trace.css +19 -0
- package/components/alert/alert.a2ui.json +10 -4
- package/components/alert/alert.css +13 -0
- package/components/alert/alert.js +1 -1
- package/components/alert/alert.yaml +21 -4
- package/components/badge/badge.a2ui.json +0 -2
- package/components/badge/badge.css +20 -0
- package/components/badge/badge.js +1 -1
- package/components/badge/badge.yaml +0 -2
- package/components/calendar-picker/calendar-picker.css +17 -0
- package/components/code/code.css +41 -0
- package/components/code/code.js +44 -3
- package/components/empty-state/empty-state.js +32 -21
- package/components/list/list.js +20 -16
- package/components/menu/menu.css +18 -0
- package/components/menu/menu.js +24 -10
- package/components/pane/pane.css +5 -0
- package/components/pipeline-status/pipeline-status.css +15 -1
- package/components/popover/popover.css +17 -0
- package/components/select/select.css +18 -0
- package/components/swiper/swiper.css +9 -0
- package/components/table/table.css +5 -0
- package/components/table/table.js +45 -1
- package/components/table-toolbar/table-toolbar.css +13 -0
- package/components/tag/tag.css +10 -0
- package/components/timeline/timeline.css +10 -3
- package/components/toast/toast.css +93 -48
- package/components/toast/toast.js +101 -22
- package/components/toolbar/toolbar.css +13 -0
- package/components/tooltip/tooltip.css +8 -0
- package/package.json +1 -1
- package/styles/colors/semantics.css +1 -1
|
@@ -1,14 +1,25 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* <toast-ui> — Notification popup
|
|
2
|
+
* <toast-ui> — Notification popup wired through a shared top-layer
|
|
3
|
+
* messaging channel.
|
|
3
4
|
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
5
|
+
* All toasts — declarative AND imperative — route through one
|
|
6
|
+
* lazily-mounted `[data-toast-container][data-toast-position]` per
|
|
7
|
+
* position. Per-position singletons; consumers can post from anywhere
|
|
8
|
+
* without holding a reference to the toast component:
|
|
6
9
|
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
10
|
+
* // Imperative API
|
|
11
|
+
* AdiaToast.show({ text: 'Saved!', variant: 'success' });
|
|
9
12
|
*
|
|
10
|
-
*
|
|
11
|
-
*
|
|
13
|
+
* // Global event channel — same shape, dispatched on `window`.
|
|
14
|
+
* // Any code (other components, integration scripts) can post
|
|
15
|
+
* // without importing AdiaToast.
|
|
16
|
+
* window.dispatchEvent(new CustomEvent('toast', {
|
|
17
|
+
* detail: { text: 'Saved!', variant: 'success' }
|
|
18
|
+
* }));
|
|
19
|
+
*
|
|
20
|
+
* // Declarative — auto-routes to the per-position container on
|
|
21
|
+
* // connect. No need to author <toast-ui> inside the container.
|
|
22
|
+
* <toast-ui text="Saved!" variant="success"></toast-ui>
|
|
12
23
|
*
|
|
13
24
|
* Events:
|
|
14
25
|
* close — fired after the toast finishes its exit animation
|
|
@@ -21,6 +32,7 @@ class AdiaToast extends AdiaElement {
|
|
|
21
32
|
#removing = false;
|
|
22
33
|
#closeTimer = null;
|
|
23
34
|
#openRaf = null;
|
|
35
|
+
#routed = false;
|
|
24
36
|
|
|
25
37
|
static properties = {
|
|
26
38
|
text: { type: String, default: '', reflect: true },
|
|
@@ -31,25 +43,27 @@ class AdiaToast extends AdiaElement {
|
|
|
31
43
|
|
|
32
44
|
static parts = {
|
|
33
45
|
message: '<div slot="message"></div>',
|
|
34
|
-
close: '<
|
|
46
|
+
close: '<button-ui slot="close" icon="x" variant="ghost" size="sm" aria-label="Dismiss"></button-ui>',
|
|
35
47
|
};
|
|
36
48
|
|
|
37
49
|
static template = () => html``;
|
|
38
50
|
|
|
39
|
-
#
|
|
51
|
+
#onPress = (e) => {
|
|
40
52
|
if (e.target.closest('[slot="close"]')) this.dismiss();
|
|
41
53
|
};
|
|
42
54
|
|
|
43
|
-
#onKeydown = (e) => {
|
|
44
|
-
if (e.target.closest('[slot="close"]') && (e.key === 'Enter' || e.key === ' ')) {
|
|
45
|
-
e.preventDefault();
|
|
46
|
-
this.dismiss();
|
|
47
|
-
}
|
|
48
|
-
};
|
|
49
|
-
|
|
50
55
|
connected() {
|
|
51
|
-
this.addEventListener('
|
|
52
|
-
|
|
56
|
+
this.addEventListener('press', this.#onPress);
|
|
57
|
+
|
|
58
|
+
// Route declarative <toast-ui> instances into the shared per-position
|
|
59
|
+
// container so authored toasts share the same lane as imperatively-
|
|
60
|
+
// posted ones (no overlap, consistent stacking). Skipped if we're
|
|
61
|
+
// already inside a container (re-entrant connect after reparent).
|
|
62
|
+
if (!this.#routed && !this.parentElement?.matches?.('[data-toast-container]')) {
|
|
63
|
+
this.#routed = true;
|
|
64
|
+
const container = AdiaToast.#getContainer(this.position || 'bottom-right');
|
|
65
|
+
if (this.parentElement !== container) container.appendChild(this);
|
|
66
|
+
}
|
|
53
67
|
}
|
|
54
68
|
|
|
55
69
|
#getDuration() {
|
|
@@ -97,14 +111,19 @@ class AdiaToast extends AdiaElement {
|
|
|
97
111
|
this.#closeTimer = setTimeout(() => {
|
|
98
112
|
this.#closeTimer = null;
|
|
99
113
|
this.removeAttribute('data-closing');
|
|
114
|
+
const container = this.parentElement;
|
|
100
115
|
this.dispatchEvent(new Event('close', { bubbles: true }));
|
|
101
116
|
this.remove();
|
|
117
|
+
/* If the lane is now empty, hide its popover and remove the
|
|
118
|
+
container — keeps document.body free of leaked containers. */
|
|
119
|
+
if (container?.matches?.('[data-toast-container]')) {
|
|
120
|
+
AdiaToast.#releaseContainerIfEmpty(container);
|
|
121
|
+
}
|
|
102
122
|
}, this.#getDuration());
|
|
103
123
|
}
|
|
104
124
|
|
|
105
125
|
disconnected() {
|
|
106
|
-
this.removeEventListener('
|
|
107
|
-
this.removeEventListener('keydown', this.#onKeydown);
|
|
126
|
+
this.removeEventListener('press', this.#onPress);
|
|
108
127
|
if (this.#timer) { clearTimeout(this.#timer); this.#timer = null; }
|
|
109
128
|
if (this.#closeTimer) { clearTimeout(this.#closeTimer); this.#closeTimer = null; }
|
|
110
129
|
if (this.#openRaf != null) { cancelAnimationFrame(this.#openRaf); this.#openRaf = null; }
|
|
@@ -121,16 +140,58 @@ class AdiaToast extends AdiaElement {
|
|
|
121
140
|
*/
|
|
122
141
|
static #containers = new Map();
|
|
123
142
|
|
|
143
|
+
/**
|
|
144
|
+
* Get (or lazily create) the per-position lane. Each lane is a manual
|
|
145
|
+
* Popover-API container — `[popover="manual"]` puts it in the browser's
|
|
146
|
+
* top-layer, above ALL page content with no z-index wars, and the
|
|
147
|
+
* native popover stack lets multiple lanes coexist (e.g. one toast in
|
|
148
|
+
* top-right + another in bottom-center) without collision.
|
|
149
|
+
*
|
|
150
|
+
* `popover="manual"` (not `auto`) — toasts must NOT light-dismiss on
|
|
151
|
+
* outside click; they auto-fade by their own duration timer.
|
|
152
|
+
*
|
|
153
|
+
* Falls back gracefully if the Popover API is unsupported (Safari < 17 /
|
|
154
|
+
* Firefox < 125): the lane still renders as a `position: fixed` div via
|
|
155
|
+
* the CSS `[data-toast-container]` rules. Browser baseline (Chromium
|
|
156
|
+
* 125+, Safari 18.0+, Firefox 129+) all support `[popover]`.
|
|
157
|
+
*/
|
|
124
158
|
static #getContainer(position) {
|
|
125
|
-
|
|
126
|
-
|
|
159
|
+
let el = AdiaToast.#containers.get(position);
|
|
160
|
+
if (el && el.isConnected) return el;
|
|
161
|
+
el = document.createElement('div');
|
|
127
162
|
el.setAttribute('data-toast-container', position);
|
|
163
|
+
/* `manual` = no light-dismiss; container stays open until we
|
|
164
|
+
explicitly hidePopover() it when its last toast leaves. */
|
|
165
|
+
if ('popover' in HTMLElement.prototype) {
|
|
166
|
+
el.setAttribute('popover', 'manual');
|
|
167
|
+
}
|
|
128
168
|
document.body.appendChild(el);
|
|
169
|
+
/* Show the popover so the lane lifts into the top-layer. Wrapped in
|
|
170
|
+
try/catch because some test rigs (happy-dom) don't ship the API. */
|
|
171
|
+
try { el.showPopover?.(); } catch { /* graceful fallback to fixed */ }
|
|
129
172
|
AdiaToast.#containers.set(position, el);
|
|
130
173
|
return el;
|
|
131
174
|
}
|
|
132
175
|
|
|
176
|
+
/**
|
|
177
|
+
* Tear down the per-position lane when its last toast has been
|
|
178
|
+
* dismissed. Keeps `document.body` clean — addresses the audit's L-B4
|
|
179
|
+
* "container leak" finding (toasts permanently leaving DIVs in body).
|
|
180
|
+
*/
|
|
181
|
+
static #releaseContainerIfEmpty(container) {
|
|
182
|
+
if (!container) return;
|
|
183
|
+
if (container.children.length > 0) return;
|
|
184
|
+
try { container.hidePopover?.(); } catch { /* noop */ }
|
|
185
|
+
container.remove();
|
|
186
|
+
/* Clear from the singleton map so the next post() rebuilds. */
|
|
187
|
+
for (const [pos, el] of AdiaToast.#containers) {
|
|
188
|
+
if (el === container) AdiaToast.#containers.delete(pos);
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
|
|
133
192
|
static show({ text, variant = 'info', duration = 4000, position = 'bottom-right' } = {}) {
|
|
193
|
+
/* `error` is a documented alias of `danger` (Phase 6 variant table). */
|
|
194
|
+
if (variant === 'error') variant = 'danger';
|
|
134
195
|
const container = AdiaToast.#getContainer(position);
|
|
135
196
|
const toast = document.createElement('toast-ui');
|
|
136
197
|
toast.text = text;
|
|
@@ -140,7 +201,25 @@ class AdiaToast extends AdiaElement {
|
|
|
140
201
|
container.appendChild(toast);
|
|
141
202
|
return toast;
|
|
142
203
|
}
|
|
204
|
+
|
|
143
205
|
}
|
|
206
|
+
|
|
207
|
+
/* Install the global 'toast' CustomEvent listener once, at module load,
|
|
208
|
+
so any code can post into the channel without importing AdiaToast
|
|
209
|
+
directly:
|
|
210
|
+
|
|
211
|
+
window.dispatchEvent(new CustomEvent('toast', {
|
|
212
|
+
detail: { text: 'Saved!', variant: 'success' }
|
|
213
|
+
}));
|
|
214
|
+
|
|
215
|
+
Idempotent — guarded by a window flag so HMR / re-imports are safe. */
|
|
216
|
+
if (typeof window !== 'undefined' && !window.__adiaToastListenerInstalled) {
|
|
217
|
+
window.__adiaToastListenerInstalled = true;
|
|
218
|
+
window.addEventListener('toast', (e) => {
|
|
219
|
+
if (e?.detail && typeof e.detail === 'object') AdiaToast.show(e.detail);
|
|
220
|
+
});
|
|
221
|
+
}
|
|
222
|
+
|
|
144
223
|
customElements.define('toast-ui', AdiaToast);
|
|
145
224
|
|
|
146
225
|
export { AdiaToast };
|
|
@@ -109,6 +109,19 @@ toolbar-ui [data-toolbar-spillover-menu]:popover-open {
|
|
|
109
109
|
display: flex;
|
|
110
110
|
flex-direction: column;
|
|
111
111
|
gap: var(--a-space-1);
|
|
112
|
+
/* Fade + lift in on first paint. */
|
|
113
|
+
opacity: 1;
|
|
114
|
+
translate: 0 0;
|
|
115
|
+
transition: opacity var(--a-duration-fast) var(--a-easing-out),
|
|
116
|
+
translate var(--a-duration-fast) var(--a-easing-out);
|
|
117
|
+
@starting-style {
|
|
118
|
+
opacity: 0;
|
|
119
|
+
translate: 0 -4px;
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
@media (prefers-reduced-motion: reduce) {
|
|
124
|
+
toolbar-ui [data-toolbar-spillover-menu]:popover-open { transition: none; }
|
|
112
125
|
}
|
|
113
126
|
|
|
114
127
|
/* Inside the spillover, render as a vertical list — every item (groups and
|
|
@@ -36,12 +36,20 @@
|
|
|
36
36
|
box-shadow: var(--a-shadow-sm);
|
|
37
37
|
white-space: nowrap;
|
|
38
38
|
pointer-events: none;
|
|
39
|
+
/* Fade in on first paint via @starting-style. */
|
|
40
|
+
opacity: 1;
|
|
41
|
+
transition: opacity var(--a-duration-fast) var(--a-easing-out);
|
|
39
42
|
/* No z-index needed — Popover API renders in the top layer which
|
|
40
43
|
has its own stacking above all document content. */
|
|
41
44
|
}
|
|
42
45
|
|
|
43
46
|
.tooltip-popup:popover-open {
|
|
44
47
|
display: block;
|
|
48
|
+
@starting-style { opacity: 0; }
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
@media (prefers-reduced-motion: reduce) {
|
|
52
|
+
.tooltip-popup { transition: none; }
|
|
45
53
|
}
|
|
46
54
|
|
|
47
55
|
/* ── Pointer-follow mode (chart/heatmap) ──
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@adia-ai/web-components",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.27",
|
|
4
4
|
"description": "AdiaUI web components — vanilla custom elements. A2UI runtime (renderer, registry, streams, wiring) lives in @adia-ai/a2ui-utils.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"exports": {
|
|
@@ -176,7 +176,7 @@
|
|
|
176
176
|
--a-primary-bg-disabled: var(--a-accent-muted);
|
|
177
177
|
--a-primary-bg-invalid: var(--a-danger-muted);
|
|
178
178
|
|
|
179
|
-
--a-primary-fg: var(--a-accent-
|
|
179
|
+
--a-primary-fg: var(--a-accent-05-tint);
|
|
180
180
|
--a-primary-fg-hover: var(--a-accent-text-strong);
|
|
181
181
|
--a-primary-fg-active: var(--a-accent-text-strong);
|
|
182
182
|
--a-primary-fg-selected: var(--a-accent-text-strong);
|