@adia-ai/web-components 0.5.6 → 0.5.8
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/accordion/accordion-item.a2ui.json +19 -2
- package/components/accordion/accordion-item.yaml +20 -0
- package/components/accordion/accordion.a2ui.json +1 -1
- package/components/accordion/accordion.yaml +1 -1
- package/components/accordion/class.js +5 -0
- package/components/agent-artifact/agent-artifact.yaml +3 -0
- package/components/agent-artifact/class.js +5 -0
- package/components/calendar-picker/calendar-picker.d.ts +10 -0
- package/components/code/code.d.ts +8 -0
- package/components/color-picker/class.js +42 -4
- package/components/color-picker/color-picker.test.js +96 -0
- package/components/color-picker/color-picker.yaml +2 -0
- package/components/demo-toggle/demo-toggle.a2ui.json +3 -1
- package/components/demo-toggle/demo-toggle.yaml +2 -0
- package/components/feed/feed.css +1 -1
- package/components/fields/fields.a2ui.json +3 -1
- package/components/fields/fields.yaml +2 -0
- package/components/input/class.js +101 -1
- package/components/input/input.a2ui.json +2 -2
- package/components/input/input.css +57 -0
- package/components/input/input.d.ts +2 -0
- package/components/input/input.test.js +123 -0
- package/components/input/input.yaml +15 -2
- package/components/nav/nav.a2ui.json +6 -1
- package/components/nav/nav.yaml +6 -0
- package/components/nav-group/nav-group.a2ui.json +5 -1
- package/components/nav-group/nav-group.css +1 -1
- package/components/nav-group/nav-group.yaml +5 -0
- package/components/nav-item/nav-item.a2ui.json +4 -1
- package/components/nav-item/nav-item.css +1 -1
- package/components/nav-item/nav-item.yaml +4 -0
- package/components/select/select.d.ts +2 -0
- package/components/slider/slider.d.ts +4 -0
- package/components/switch/switch.d.ts +2 -0
- package/components/table/class.js +9 -1
- package/components/table/table.yaml +4 -0
- package/components/table-toolbar/class.js +5 -0
- package/components/table-toolbar/table-toolbar.yaml +4 -0
- package/components/text/text.a2ui.json +1 -8
- package/components/text/text.css +13 -0
- package/components/text/text.d.ts +1 -1
- package/components/text/text.test.js +106 -0
- package/components/text/text.yaml +0 -7
- package/components/timeline/class.js +5 -0
- package/components/timeline/timeline.yaml +3 -0
- package/components/toggle-scheme/class.js +31 -0
- package/components/toggle-scheme/toggle-scheme.test.js +110 -0
- package/components/upload/upload.d.ts +6 -0
- package/package.json +4 -2
- package/styles/components.css +2 -0
- package/styles/typography.css +3 -1
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* toggle-scheme-ui §200 race-fix tests — v0.5.7 (FEEDBACK-10 §1).
|
|
3
|
+
*
|
|
4
|
+
* Verifies the post-connect attribute application is HONORED — not raced over
|
|
5
|
+
* by the synchronous #initState() call in connected(). Per the bug class:
|
|
6
|
+
*
|
|
7
|
+
* 1. template.js scan() strips placeholder attributes pre-insertion
|
|
8
|
+
* 2. replaceChildren() upgrades the element; connectedCallback fires
|
|
9
|
+
* 3. #initState() reads this.scheme (default 'auto')
|
|
10
|
+
* 4. template.js update() then setAttribute('scheme', 'dark')
|
|
11
|
+
* 5. attributeChangedCallback syncs to property — but #initState already ran
|
|
12
|
+
*
|
|
13
|
+
* Pre-§200, step 4 was a no-op for the scheme cascade. Post-§200,
|
|
14
|
+
* attributeChangedCallback re-runs #initState() (until user-touched).
|
|
15
|
+
*/
|
|
16
|
+
|
|
17
|
+
import { describe, it, expect, beforeEach } from 'vitest';
|
|
18
|
+
import '../../core/element.js';
|
|
19
|
+
import './toggle-scheme.js';
|
|
20
|
+
|
|
21
|
+
const tick = () => new Promise((r) => queueMicrotask(r));
|
|
22
|
+
|
|
23
|
+
function mount(html) {
|
|
24
|
+
const wrap = document.createElement('div');
|
|
25
|
+
wrap.innerHTML = html;
|
|
26
|
+
document.body.appendChild(wrap);
|
|
27
|
+
return wrap.firstElementChild;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
describe('toggle-scheme-ui §200 race fix', () => {
|
|
31
|
+
beforeEach(() => {
|
|
32
|
+
document.body.innerHTML = '';
|
|
33
|
+
document.documentElement.style.removeProperty('color-scheme');
|
|
34
|
+
});
|
|
35
|
+
|
|
36
|
+
it('honors post-connect scheme attribute application (reactive consumer)', async () => {
|
|
37
|
+
// Simulate template.js's strip-then-restamp pattern: mount without scheme,
|
|
38
|
+
// then set the attribute immediately afterward (mimics post-connect apply).
|
|
39
|
+
const t = mount('<toggle-scheme-ui></toggle-scheme-ui>');
|
|
40
|
+
await tick();
|
|
41
|
+
t.setAttribute('scheme', 'dark');
|
|
42
|
+
await tick();
|
|
43
|
+
expect(t.activeScheme).toBe('dark');
|
|
44
|
+
expect(document.documentElement.style.colorScheme).toBe('dark');
|
|
45
|
+
});
|
|
46
|
+
|
|
47
|
+
it('honors the initial scheme attribute (no race scenario)', async () => {
|
|
48
|
+
const t = mount('<toggle-scheme-ui scheme="dark"></toggle-scheme-ui>');
|
|
49
|
+
await tick();
|
|
50
|
+
expect(t.activeScheme).toBe('dark');
|
|
51
|
+
});
|
|
52
|
+
|
|
53
|
+
it('user button press locks #userTouched — subsequent attr changes are ignored', async () => {
|
|
54
|
+
const t = mount('<toggle-scheme-ui scheme="dark"></toggle-scheme-ui>');
|
|
55
|
+
await tick();
|
|
56
|
+
expect(t.activeScheme).toBe('dark');
|
|
57
|
+
|
|
58
|
+
// User press: flips to light. #userTouched flips true.
|
|
59
|
+
const btn = t.querySelector(':scope > button-ui');
|
|
60
|
+
btn.dispatchEvent(new CustomEvent('press', { bubbles: true }));
|
|
61
|
+
await tick();
|
|
62
|
+
expect(t.activeScheme).toBe('light');
|
|
63
|
+
|
|
64
|
+
// Consumer re-renders with scheme="dark" — should NOT clobber user choice.
|
|
65
|
+
t.setAttribute('scheme', 'dark');
|
|
66
|
+
await tick();
|
|
67
|
+
expect(t.activeScheme).toBe('light'); // user choice survives
|
|
68
|
+
});
|
|
69
|
+
|
|
70
|
+
it('programmatic setScheme also locks #userTouched', async () => {
|
|
71
|
+
const t = mount('<toggle-scheme-ui scheme="auto"></toggle-scheme-ui>');
|
|
72
|
+
await tick();
|
|
73
|
+
|
|
74
|
+
t.setScheme('dark');
|
|
75
|
+
await tick();
|
|
76
|
+
expect(t.activeScheme).toBe('dark');
|
|
77
|
+
|
|
78
|
+
// Consumer reactive write should NOT override.
|
|
79
|
+
t.setAttribute('scheme', 'light');
|
|
80
|
+
await tick();
|
|
81
|
+
expect(t.activeScheme).toBe('dark');
|
|
82
|
+
});
|
|
83
|
+
|
|
84
|
+
it('toggle() also locks #userTouched', async () => {
|
|
85
|
+
const t = mount('<toggle-scheme-ui scheme="auto"></toggle-scheme-ui>');
|
|
86
|
+
await tick();
|
|
87
|
+
const initial = t.activeScheme; // depends on prefers-color-scheme (likely light in test env)
|
|
88
|
+
|
|
89
|
+
t.toggle();
|
|
90
|
+
await tick();
|
|
91
|
+
expect(t.activeScheme).not.toBe(initial);
|
|
92
|
+
|
|
93
|
+
const afterToggle = t.activeScheme;
|
|
94
|
+
t.setAttribute('scheme', initial === 'dark' ? 'dark' : 'light');
|
|
95
|
+
await tick();
|
|
96
|
+
expect(t.activeScheme).toBe(afterToggle); // user choice survives
|
|
97
|
+
});
|
|
98
|
+
|
|
99
|
+
it('removing the attribute (back to auto) is honored pre-touch', async () => {
|
|
100
|
+
const t = mount('<toggle-scheme-ui scheme="dark"></toggle-scheme-ui>');
|
|
101
|
+
await tick();
|
|
102
|
+
expect(t.activeScheme).toBe('dark');
|
|
103
|
+
|
|
104
|
+
t.removeAttribute('scheme');
|
|
105
|
+
await tick();
|
|
106
|
+
// After removal, attr is null; #initState falls to auto → resolves
|
|
107
|
+
// prefers-color-scheme. Test env should resolve to light by default.
|
|
108
|
+
expect(['light', 'dark']).toContain(t.activeScheme);
|
|
109
|
+
});
|
|
110
|
+
});
|
|
@@ -17,6 +17,12 @@ export type UploadChangeEvent = CustomEvent<UploadChangeEventDetail>;
|
|
|
17
17
|
export class UIUpload extends UIFormElement {
|
|
18
18
|
/** Files currently selected. */
|
|
19
19
|
readonly files: FileList | File[];
|
|
20
|
+
/** §207 (v0.5.7): label rendered above the dropzone. */
|
|
21
|
+
label: string;
|
|
22
|
+
/** §207 (v0.5.7): MIME-type accept filter (e.g. `"image/*"` or `".pdf,.txt"`). */
|
|
23
|
+
accept: string;
|
|
24
|
+
/** §207 (v0.5.7): allow multi-file selection. */
|
|
25
|
+
multiple: boolean;
|
|
20
26
|
|
|
21
27
|
addEventListener<K extends keyof HTMLElementEventMap>(
|
|
22
28
|
type: K,
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@adia-ai/web-components",
|
|
3
|
-
"version": "0.5.
|
|
4
|
-
"description": "AdiaUI web components
|
|
3
|
+
"version": "0.5.8",
|
|
4
|
+
"description": "AdiaUI web components — vanilla custom elements. A2UI runtime (renderer, registry, streams, wiring) lives in @adia-ai/a2ui-runtime.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"types": "./index.d.ts",
|
|
7
7
|
"exports": {
|
|
@@ -28,6 +28,8 @@
|
|
|
28
28
|
"default": "./components/*/class.js"
|
|
29
29
|
},
|
|
30
30
|
"./components/*.css": "./components/*/*.css",
|
|
31
|
+
"./components/*/*.css": "./components/*/*.css",
|
|
32
|
+
"./components/*/css/*.css": "./components/*/css/*.css",
|
|
31
33
|
"./styles/*": "./styles/*",
|
|
32
34
|
"./traits": "./traits/index.js",
|
|
33
35
|
"./traits/*": "./traits/*.js",
|
package/styles/components.css
CHANGED
|
@@ -13,6 +13,7 @@
|
|
|
13
13
|
/* ── Components ── */
|
|
14
14
|
@import "../components/icon/icon.css";
|
|
15
15
|
@import "../components/button/button.css";
|
|
16
|
+
@import "../components/link/link.css";
|
|
16
17
|
@import "../components/input/input.css";
|
|
17
18
|
@import "../components/textarea/textarea.css";
|
|
18
19
|
@import "../components/check/check.css";
|
|
@@ -84,6 +85,7 @@
|
|
|
84
85
|
@import "../components/block/block.css";
|
|
85
86
|
@import "../components/text/text.css";
|
|
86
87
|
@import "../components/toggle-group/toggle-group.css";
|
|
88
|
+
@import "../components/toggle-scheme/toggle-scheme.css";
|
|
87
89
|
@import "../components/demo-toggle/demo-toggle.css";
|
|
88
90
|
@import "../components/richtext/richtext.css";
|
|
89
91
|
@import "../components/stream/stream.css";
|
package/styles/typography.css
CHANGED
|
@@ -88,7 +88,9 @@
|
|
|
88
88
|
/* ── Font weight — single canonical scale ──
|
|
89
89
|
Conventional weights: thin=100, light=300, normal=400, medium=500,
|
|
90
90
|
semibold=600, bold=700. Fonts must provide these axes or fall back
|
|
91
|
-
gracefully. --a-font-weight-*
|
|
91
|
+
gracefully. Earlier --a-font-weight-* aliases were REMOVED in v0.5.0;
|
|
92
|
+
use --a-weight-* directly. (v0.5.8 §230 closed 3 consumer references
|
|
93
|
+
that still pointed at the removed family per FEEDBACK-20 §1.) */
|
|
92
94
|
--a-weight-thin: 100;
|
|
93
95
|
--a-weight-light: 300;
|
|
94
96
|
--a-weight-normal: 400;
|