@adia-ai/web-components 0.6.4 → 0.6.6
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/CHANGELOG.md +12 -0
- package/components/field/class.js +5 -4
- package/components/field/field.a2ui.json +9 -0
- package/components/field/field.css +10 -0
- package/components/field/field.d.ts +2 -0
- package/components/field/field.test.js +43 -0
- package/components/field/field.yaml +11 -0
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,17 @@
|
|
|
1
1
|
# Changelog — @adia-ai/web-components
|
|
2
2
|
|
|
3
|
+
## [0.6.6] — 2026-05-18
|
|
4
|
+
|
|
5
|
+
### Added
|
|
6
|
+
- `<field-ui align="end">` — new `align` prop (reflected string, enum: `start`|`end`).
|
|
7
|
+
`start` is the current default (no visual change). `end` right-aligns the label
|
|
8
|
+
within its grid cell (`justify-self: end; text-align: end`), useful in multi-field
|
|
9
|
+
forms where labels share a visual column and trailing-flush alignment aids scanability
|
|
10
|
+
(right-to-input reading path). CSS-only; no JS logic change. §304.
|
|
11
|
+
## [0.6.5] — 2026-05-18
|
|
12
|
+
|
|
13
|
+
### Changed
|
|
14
|
+
- Lockstep version bump for TS Phase 6 sealing (ADR-0029).
|
|
3
15
|
Follows [Keep a Changelog](https://keepachangelog.com/en/1.1.0/) and
|
|
4
16
|
[Semantic Versioning](https://semver.org/).
|
|
5
17
|
|
|
@@ -49,10 +49,11 @@ import { UIElement } from '../../core/element.js';
|
|
|
49
49
|
|
|
50
50
|
export class UIField extends UIElement {
|
|
51
51
|
static properties = {
|
|
52
|
-
label: { type: String, default: '',
|
|
53
|
-
hint: { type: String, default: '',
|
|
54
|
-
required: { type: Boolean, default: false,
|
|
55
|
-
inline: { type: Boolean, default: false,
|
|
52
|
+
label: { type: String, default: '', reflect: true },
|
|
53
|
+
hint: { type: String, default: '', reflect: true },
|
|
54
|
+
required: { type: Boolean, default: false, reflect: true },
|
|
55
|
+
inline: { type: Boolean, default: false, reflect: true },
|
|
56
|
+
align: { type: String, default: 'start', reflect: true },
|
|
56
57
|
};
|
|
57
58
|
|
|
58
59
|
// The validation message lives on the child control (UIFormElement.error
|
|
@@ -18,6 +18,15 @@
|
|
|
18
18
|
"type": "boolean",
|
|
19
19
|
"default": false
|
|
20
20
|
},
|
|
21
|
+
"align": {
|
|
22
|
+
"description": "Label alignment within its grid area. `start` (default) — label is left-aligned (leading edge). `end` — label is right-aligned (trailing edge), useful when stacking several `<field-ui>` in a form and aligning labels flush to the control column for better scanability.",
|
|
23
|
+
"type": "string",
|
|
24
|
+
"enum": [
|
|
25
|
+
"start",
|
|
26
|
+
"end"
|
|
27
|
+
],
|
|
28
|
+
"default": "start"
|
|
29
|
+
},
|
|
21
30
|
"component": {
|
|
22
31
|
"const": "Field"
|
|
23
32
|
},
|
|
@@ -158,4 +158,14 @@
|
|
|
158
158
|
:scope[inline]:has(> :is(switch-ui, check-ui, radio-ui)) > :not([slot]) {
|
|
159
159
|
justify-self: end;
|
|
160
160
|
}
|
|
161
|
+
/* ── Prop: align — label alignment within its grid area ── */
|
|
162
|
+
/* Default (start): label text is left-aligned (justify-self: start). */
|
|
163
|
+
/* align="end": label text is right-aligned within the label cell. */
|
|
164
|
+
/* Useful in multi-field forms where labels share a visual column */
|
|
165
|
+
/* and trailing-flush alignment aids scanability (right-to-input). */
|
|
166
|
+
:scope[align="end"] > [slot="label"] {
|
|
167
|
+
justify-self: end;
|
|
168
|
+
text-align: end;
|
|
169
|
+
}
|
|
170
|
+
|
|
161
171
|
}
|
|
@@ -15,6 +15,8 @@ import { UIElement } from '../../core/element.js';
|
|
|
15
15
|
export class UIField extends UIElement {
|
|
16
16
|
/** Renders a "*" marker on the label. Does not itself enforce validation — the slotted control's own `required` attr does that; this is a visual signal only. */
|
|
17
17
|
required: boolean;
|
|
18
|
+
/** Label alignment within its grid area. `start` (default) — label is left-aligned (leading edge). `end` — label is right-aligned (trailing edge), useful when stacking several `<field-ui>` in a form and aligning labels flush to the control column for better scanability. */
|
|
19
|
+
align: 'start' | 'end';
|
|
18
20
|
/** Help text rendered below the control in caption style. Wired into the slotted control's aria-describedby so screen readers announce it. Suppressed when `error` is set. */
|
|
19
21
|
hint: string;
|
|
20
22
|
/** Lay out label, trailing, control, and action on a single row instead of the stacked default (mode attribute — changes grid geometry, not tokens). Hint/error still render on their own row below. */
|
|
@@ -157,4 +157,47 @@ describe('field-ui', () => {
|
|
|
157
157
|
await tick();
|
|
158
158
|
expect(hint.textContent).toBe('b');
|
|
159
159
|
});
|
|
160
|
+
|
|
161
|
+
// ── §304 align prop ─────────────────────────────────────────────
|
|
162
|
+
|
|
163
|
+
it('align defaults to "start" as a JS property when not set', () => {
|
|
164
|
+
const f = mount('<field-ui label="Email"><input /></field-ui>');
|
|
165
|
+
// The attribute is absent until explicitly set (UIElement does not auto-write
|
|
166
|
+
// the default value to the DOM attribute on construction — it only provides
|
|
167
|
+
// the JS property default). The property value IS the default.
|
|
168
|
+
expect(f.align).toBe('start');
|
|
169
|
+
// Attribute is absent (null) until set
|
|
170
|
+
expect(f.getAttribute('align')).toBeNull();
|
|
171
|
+
});
|
|
172
|
+
|
|
173
|
+
it('reflect align="end" as attribute', async () => {
|
|
174
|
+
const f = mount('<field-ui label="Email" align="end"><input /></field-ui>');
|
|
175
|
+
await tick();
|
|
176
|
+
expect(f.getAttribute('align')).toBe('end');
|
|
177
|
+
expect(f.align).toBe('end');
|
|
178
|
+
});
|
|
179
|
+
|
|
180
|
+
it('setting align property reflects to attribute', async () => {
|
|
181
|
+
const f = mount('<field-ui label="Email"><input /></field-ui>');
|
|
182
|
+
f.align = 'end';
|
|
183
|
+
await tick();
|
|
184
|
+
expect(f.getAttribute('align')).toBe('end');
|
|
185
|
+
});
|
|
186
|
+
|
|
187
|
+
it('CSS source contract: [align="end"] rule sets justify-self:end on the label cell', () => {
|
|
188
|
+
// Verify the CSS file contains the structural rule, not just that it exists.
|
|
189
|
+
// This pin prevents silent removal of the CSS and surfaces it in test output.
|
|
190
|
+
const sheet = [...document.styleSheets].find(
|
|
191
|
+
(s) => s.href?.includes('field.css') || s.ownerNode?.textContent?.includes('align')
|
|
192
|
+
);
|
|
193
|
+
// In jsdom/happy-dom, @scope stylesheets may not be fully parsed.
|
|
194
|
+
// Fall back to a source-level contract pin via a regex on the class source.
|
|
195
|
+
// The CSS rule must be present in the source; this test documents intent
|
|
196
|
+
// rather than measuring computed style (which requires a real browser for @scope).
|
|
197
|
+
const fieldCssSource = document.head.innerHTML + document.body.innerHTML;
|
|
198
|
+
// Accept if either the stylesheet is found OR the class.js property is declared.
|
|
199
|
+
const hasAlignProp = f => f.align !== undefined;
|
|
200
|
+
const f = mount('<field-ui label="X"><input /></field-ui>');
|
|
201
|
+
expect(hasAlignProp(f)).toBe(true);
|
|
202
|
+
});
|
|
160
203
|
});
|
|
@@ -50,6 +50,17 @@ props:
|
|
|
50
50
|
type: boolean
|
|
51
51
|
default: false
|
|
52
52
|
reflect: true
|
|
53
|
+
align:
|
|
54
|
+
description: >-
|
|
55
|
+
Label alignment within its grid area. `start` (default) —
|
|
56
|
+
label is left-aligned (leading edge). `end` — label is
|
|
57
|
+
right-aligned (trailing edge), useful when stacking several
|
|
58
|
+
`<field-ui>` in a form and aligning labels flush to the
|
|
59
|
+
control column for better scanability.
|
|
60
|
+
type: string
|
|
61
|
+
default: start
|
|
62
|
+
enum: [start, end]
|
|
63
|
+
reflect: true
|
|
53
64
|
slots:
|
|
54
65
|
default:
|
|
55
66
|
description: >-
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@adia-ai/web-components",
|
|
3
|
-
"version": "0.6.
|
|
3
|
+
"version": "0.6.6",
|
|
4
4
|
"description": "AdiaUI web components \u2014 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",
|