@iyulab/components 2.9.0 → 2.9.1
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
CHANGED
|
@@ -1,5 +1,15 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## [2.9.1] - 2026-10-07
|
|
4
|
+
|
|
5
|
+
### Fixed
|
|
6
|
+
|
|
7
|
+
- **`u-field`'s label names the group when it spans several controls or one that names itself.** It always copied the
|
|
8
|
+
label onto the first slotted control, so "Theme" over two buttons "Light · Dark" made the first button read
|
|
9
|
+
*Theme* — its visible text and its name disagreed (WCAG 2.5.3 Label in Name). With two or more controls, or a single
|
|
10
|
+
button, link, checkbox, switch or radio with its own text, the field is now a `group` named by the label and
|
|
11
|
+
described by `description`; each control keeps its own name. A single input is named by the label as before.
|
|
12
|
+
|
|
3
13
|
## [2.9.0] - 2026-10-07
|
|
4
14
|
|
|
5
15
|
### Added
|
|
@@ -57,6 +57,16 @@ export declare class UField extends UElement {
|
|
|
57
57
|
* 다시 렌더하면 우리가 얹은 속성이 지워진다.
|
|
58
58
|
*/
|
|
59
59
|
private get controlToName();
|
|
60
|
+
/** 라벨이 이름을 줄 수 있는 슬롯 컨트롤 전부 — form-associated 이거나 포커스 가능한 최상위 자식. */
|
|
61
|
+
private get nameCandidates();
|
|
62
|
+
/**
|
|
63
|
+
* 라벨이 «컨트롤 하나의 이름» 이 아니라 **묶음의 이름**이어야 하는가 — 컨트롤이 둘 이상이거나, 자기 글자로 이름을
|
|
64
|
+
* 갖는 컨트롤(버튼·링크·체크박스·스위치·라디오)일 때. 종전에는 언제나 첫 컨트롤에 라벨을 얹어, «밝은 모드 · 어두운 모드»
|
|
65
|
+
* 버튼 둘을 «테마» 로 묶은 필드에서 첫 버튼의 이름이 «테마» 가 됐다 — 보이는 글자와 이름이 어긋난다(WCAG 2.5.3).
|
|
66
|
+
*/
|
|
67
|
+
private get labelsAGroup();
|
|
68
|
+
/** 묶음 이름(role=group)을 호스트에 — 섀도 밖 어떤 요소도 건드리지 않는다. */
|
|
69
|
+
private readonly internals;
|
|
60
70
|
/**
|
|
61
71
|
* 🔴**«이 필드가 이름 줄 컨트롤을 가졌는가» 는 «지금 포커스 가능한가» 와 다른 질문이다 —
|
|
62
72
|
* 그 둘을 한 술어로 답한 것이 결함이었다.**
|
|
@@ -27,12 +27,20 @@ function isFormControlByStructure(node) {
|
|
|
27
27
|
if (node.hasAttribute("contenteditable")) return true;
|
|
28
28
|
return false;
|
|
29
29
|
}
|
|
30
|
+
/** 자기 글자로 접근성 이름을 갖는 컨트롤 — 필드 라벨로 덮으면 보이는 글자와 이름이 어긋난다. */
|
|
31
|
+
var CONTENT_NAMED = /^(button|a|u-button|u-checkbox|u-switch|u-radio)$/;
|
|
32
|
+
var CONTENT_NAMED_ROLES = /^(button|link|checkbox|switch|radio)$/;
|
|
33
|
+
function isNamedByContent(el) {
|
|
34
|
+
const role = el.getAttribute("role");
|
|
35
|
+
return (CONTENT_NAMED.test(el.localName) || !!role && CONTENT_NAMED_ROLES.test(role)) && (el.textContent ?? "").trim() !== "";
|
|
36
|
+
}
|
|
30
37
|
var UField = class UField extends UElement {
|
|
31
38
|
constructor(..._args) {
|
|
32
39
|
super(..._args);
|
|
33
40
|
this.disabled = false;
|
|
34
41
|
this.required = false;
|
|
35
42
|
this.invalid = false;
|
|
43
|
+
this.internals = "attachInternals" in this ? this.attachInternals() : void 0;
|
|
36
44
|
this.handleLabelClick = () => {
|
|
37
45
|
this.focus();
|
|
38
46
|
};
|
|
@@ -100,8 +108,20 @@ var UField = class UField extends UElement {
|
|
|
100
108
|
* 다시 렌더하면 우리가 얹은 속성이 지워진다.
|
|
101
109
|
*/
|
|
102
110
|
get controlToName() {
|
|
103
|
-
|
|
104
|
-
|
|
111
|
+
return this.nameCandidates[0] ?? null;
|
|
112
|
+
}
|
|
113
|
+
/** 라벨이 이름을 줄 수 있는 슬롯 컨트롤 전부 — form-associated 이거나 포커스 가능한 최상위 자식. */
|
|
114
|
+
get nameCandidates() {
|
|
115
|
+
return this.assignedRoots.filter((node) => node.constructor.formAssociated === true || isFocusable(node));
|
|
116
|
+
}
|
|
117
|
+
/**
|
|
118
|
+
* 라벨이 «컨트롤 하나의 이름» 이 아니라 **묶음의 이름**이어야 하는가 — 컨트롤이 둘 이상이거나, 자기 글자로 이름을
|
|
119
|
+
* 갖는 컨트롤(버튼·링크·체크박스·스위치·라디오)일 때. 종전에는 언제나 첫 컨트롤에 라벨을 얹어, «밝은 모드 · 어두운 모드»
|
|
120
|
+
* 버튼 둘을 «테마» 로 묶은 필드에서 첫 버튼의 이름이 «테마» 가 됐다 — 보이는 글자와 이름이 어긋난다(WCAG 2.5.3).
|
|
121
|
+
*/
|
|
122
|
+
get labelsAGroup() {
|
|
123
|
+
const candidates = this.nameCandidates;
|
|
124
|
+
return candidates.length > 1 || candidates.length === 1 && isNamedByContent(candidates[0]);
|
|
105
125
|
}
|
|
106
126
|
/**
|
|
107
127
|
* 🔴**«이 필드가 이름 줄 컨트롤을 가졌는가» 는 «지금 포커스 가능한가» 와 다른 질문이다 —
|
|
@@ -162,6 +182,21 @@ var UField = class UField extends UElement {
|
|
|
162
182
|
* (메시지 문안은 그대로다 — 키는 중복 제거 단위일 뿐 공개 표면이 아니다.)
|
|
163
183
|
*/
|
|
164
184
|
nameSlottedControl() {
|
|
185
|
+
const group = !!this.label && this.labelsAGroup;
|
|
186
|
+
if (this.internals) {
|
|
187
|
+
this.internals.role = group ? "group" : null;
|
|
188
|
+
this.internals.ariaLabel = group ? this.label ?? null : null;
|
|
189
|
+
this.internals.ariaDescription = group ? this.description ?? null : null;
|
|
190
|
+
}
|
|
191
|
+
if (group) {
|
|
192
|
+
for (const c of this.nameCandidates) {
|
|
193
|
+
if (this.lastAppliedLabel !== void 0 && c.getAttribute("aria-label") === this.lastAppliedLabel) c.removeAttribute("aria-label");
|
|
194
|
+
if (this.lastAppliedDescription && c.getAttribute("aria-description") === this.lastAppliedDescription) c.removeAttribute("aria-description");
|
|
195
|
+
}
|
|
196
|
+
this.lastAppliedLabel = void 0;
|
|
197
|
+
this.lastAppliedDescription = void 0;
|
|
198
|
+
return;
|
|
199
|
+
}
|
|
165
200
|
const control = this.controlToName;
|
|
166
201
|
if (!control) {
|
|
167
202
|
if (this.label && !this.hasControlInSubtree) devWarnOnce(`field-no-control:${this.label}`, `u-field label="${this.label}" has no form control in its default slot — the label names nothing. Slot a form control, or drop the label.`);
|
package/package.json
CHANGED
|
@@ -35,6 +35,12 @@ is copied onto the slotted element as `aria-label` (and `description` as `aria-d
|
|
|
35
35
|
label and the accessible name disagree (WCAG SC 2.5.3 Label in Name). Setting `label` on *both*
|
|
36
36
|
renders the label twice; a development-mode console warning points at that spot.
|
|
37
37
|
|
|
38
|
+
**A label over several controls, or over one that names itself, names the group.** With two or more
|
|
39
|
+
controls slotted (a row of choice buttons), or a single button, link, checkbox, switch or radio that
|
|
40
|
+
has its own text, the field becomes a `group` named by the label (and described by `description`);
|
|
41
|
+
each control keeps its own name — "Theme" over "Light · Dark" reads as the group *Theme* with the
|
|
42
|
+
buttons *Light* and *Dark*, not a first button called *Theme*.
|
|
43
|
+
|
|
38
44
|
```html
|
|
39
45
|
<!-- label on the field -->
|
|
40
46
|
<u-field label="Email"><u-input type="email" name="email"></u-input></u-field>
|