@iyulab/components 2.5.0 → 2.6.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/CHANGELOG.md CHANGED
@@ -1,5 +1,23 @@
1
1
  # Changelog
2
2
 
3
+ ## [2.6.0] - 2026-10-06
4
+
5
+ ### Changed
6
+
7
+ - **`u-rating` is one Tab stop and its arrows choose**, like a native radio group (WAI-ARIA APG Radio Group). Every
8
+ star was a Tab stop, so Tab walked through five stars; arrows only moved focus, so the next Tab jumped back to the
9
+ chosen star. Now Tab enters on the chosen star (the first when there is none) and leaves on the next press;
10
+ `Arrow` keys move and choose, firing `change`, and `Home`/`End` choose the first/last. `focus()` goes to the chosen
11
+ star (it went to the first).
12
+
13
+ ### Fixed
14
+
15
+ - **`u-tree` is one Tab stop** (APG Tree View). Every item was a Tab stop. Now Tab enters on the item focused last (at
16
+ first the selected item, else the first) and the next Tab leaves the tree; arrows move inside as before. When that
17
+ item is collapsed away or disabled the stop moves to its nearest visible ancestor. Only the stop carries `tabindex`
18
+ — an item is a shadow host and its children render in its slot, so a `tabindex="-1"` parent would take its whole
19
+ subtree out of Tab order; `item.focus()` and a click make an item the stop first.
20
+
3
21
  ## [2.5.0] - 2026-10-06
4
22
 
5
23
  An accessibility-tree audit of the interactive widgets — what a screen reader receives, not what the DOM says.
@@ -42,6 +42,11 @@ export declare class URating extends UFormControlElement<number> {
42
42
  * `<span>`이라 disabled/readonly일 때 `tabindex="-1"`(=`!interactive`)이고,
43
43
  * 다른 컴포넌트의 `.container`/thumb와 같은 이유로 프로그램적 focus는 여전히
44
44
  * 통과하므로 직접 가드한다. */
45
+ /**
46
+ * 탭 정지는 그룹에 하나 — 고른 별(없으면 첫 별)이다(APG Radio Group · 네이티브 라디오 묶음과 같다). 종전에는 별마다
47
+ * 탭 정지라 Tab 이 별 다섯을 다 지나갔다.
48
+ */
49
+ private get tabStopScore();
45
50
  focus(options?: FocusOptions): void;
46
51
  blur(): void;
47
52
  private onChangeValue;
@@ -49,24 +49,29 @@ var URating = class URating extends UFormControlElement {
49
49
  const currentSymbol = e.currentTarget;
50
50
  const currentIndex = symbols.indexOf(currentSymbol);
51
51
  if (currentIndex === -1) return;
52
+ const moveTo = (index) => {
53
+ e.preventDefault();
54
+ const score = index + 1;
55
+ if (score !== this.value) {
56
+ this.value = score;
57
+ this.emitChange();
58
+ }
59
+ this.updateComplete.then(() => symbols[index].focus());
60
+ };
52
61
  switch (e.key) {
53
62
  case "ArrowRight":
54
63
  case "ArrowUp":
55
- e.preventDefault();
56
- symbols[Math.min(symbols.length - 1, currentIndex + 1)].focus();
64
+ moveTo(Math.min(symbols.length - 1, currentIndex + 1));
57
65
  break;
58
66
  case "ArrowLeft":
59
67
  case "ArrowDown":
60
- e.preventDefault();
61
- symbols[Math.max(0, currentIndex - 1)].focus();
68
+ moveTo(Math.max(0, currentIndex - 1));
62
69
  break;
63
70
  case "Home":
64
- e.preventDefault();
65
- symbols[0].focus();
71
+ moveTo(0);
66
72
  break;
67
73
  case "End":
68
- e.preventDefault();
69
- symbols[symbols.length - 1].focus();
74
+ moveTo(symbols.length - 1);
70
75
  break;
71
76
  case " ":
72
77
  case "Enter": {
@@ -124,7 +129,7 @@ var URating = class URating extends UFormControlElement {
124
129
  aria-label=${String(score)}
125
130
  aria-checked=${score === Math.round(this.value || 0) ? "true" : "false"}
126
131
  aria-disabled=${this.interactive ? "false" : "true"}
127
- tabindex=${this.interactive ? "0" : "-1"}
132
+ tabindex=${this.interactive && score === this.tabStopScore ? "0" : "-1"}
128
133
  data-score=${score}
129
134
  @pointermove=${this.handleSymbolPointerMove}
130
135
  @pointerleave=${this.handleSymbolPointerLeave}
@@ -182,9 +187,16 @@ var URating = class URating extends UFormControlElement {
182
187
  * `<span>`이라 disabled/readonly일 때 `tabindex="-1"`(=`!interactive`)이고,
183
188
  * 다른 컴포넌트의 `.container`/thumb와 같은 이유로 프로그램적 focus는 여전히
184
189
  * 통과하므로 직접 가드한다. */
190
+ /**
191
+ * 탭 정지는 그룹에 하나 — 고른 별(없으면 첫 별)이다(APG Radio Group · 네이티브 라디오 묶음과 같다). 종전에는 별마다
192
+ * 탭 정지라 Tab 이 별 다섯을 다 지나갔다.
193
+ */
194
+ get tabStopScore() {
195
+ return Math.min(this.max, Math.max(1, Math.round(this.value || 0) || 1));
196
+ }
185
197
  focus(options) {
186
198
  if (!this.interactive) return;
187
- this.renderRoot.querySelector(".symbol")?.focus(options);
199
+ this.renderRoot.querySelector(`.symbol[data-score="${this.tabStopScore}"]`)?.focus(options);
188
200
  }
189
201
  blur() {
190
202
  (this.shadowRoot?.activeElement)?.blur();
@@ -60,6 +60,20 @@ export declare class UTree extends UElement {
60
60
  mapItems(fn: (item: UTreeItem) => void): void;
61
61
  private propagate;
62
62
  private handleSlotChange;
63
+ /** 탭 정지 — 트리 전체에 하나(APG Tree View). 마지막으로 포커스된 항목, 처음에는 선택된 항목 또는 첫 항목. */
64
+ private tabStop?;
65
+ /**
66
+ * 정지를 다시 정한다 — `preferred` 가 있으면 그것(포커스를 받으려는 항목), 아니면 지금 정지를 지키되 비활성이 되거나
67
+ * 접힌 부모 밑에 숨으면 보이는 가장 가까운 조상으로 옮긴다(숨은 항목의 tabindex 0 은 Tab 이 건너뛰어 트리에 들어갈
68
+ * 길이 사라진다).
69
+ *
70
+ * ⚠정지가 아닌 항목은 `tabindex` 를 **떼어 낸다**(-1 이 아니다). 항목은 섀도 호스트이고 자식 항목은 그 섀도의 슬롯으로
71
+ * 그려진다 — 음수 tabindex 호스트의 범위는 순차 탐색에서 통째로 빠져, 부모가 -1 이면 그 밑의 정지에 Tab 이 닿지
72
+ * 않았다(실측: Shift+Tab 이 트리를 건너뛰었다). 그래서 항목은 포커스를 받기 직전에 정지가 된다(`UTreeItem.focus`).
73
+ * @internal 항목이 부른다.
74
+ */
75
+ syncTabStop(preferred?: UTreeItem): void;
76
+ private handleFocusin;
63
77
  private handleIconSlotChange;
64
78
  private handlePick;
65
79
  private selectRange;
@@ -23,6 +23,13 @@ var UTree = class UTree extends UElement {
23
23
  const slot = e.target;
24
24
  this._items = slot.assignedElements({ flatten: true }).filter((el) => el instanceof UTreeItem);
25
25
  this.propagate();
26
+ this.syncTabStop();
27
+ };
28
+ this.handleFocusin = (e) => {
29
+ const item = e.composedPath().find((el) => el instanceof UTreeItem);
30
+ if (!item || item === this.tabStop || item.disabled) return;
31
+ this.tabStop = item;
32
+ this.syncTabStop();
26
33
  };
27
34
  this.handleIconSlotChange = (e) => {
28
35
  const slot = e.target;
@@ -149,11 +156,13 @@ var UTree = class UTree extends UElement {
149
156
  this.addEventListener("pick", this.handlePick);
150
157
  this.addEventListener("check", this.handleCheck);
151
158
  this.addEventListener("keydown", this.handleKeydown);
159
+ this.addEventListener("focusin", this.handleFocusin);
152
160
  }
153
161
  disconnectedCallback() {
154
162
  this.removeEventListener("pick", this.handlePick);
155
163
  this.removeEventListener("check", this.handleCheck);
156
164
  this.removeEventListener("keydown", this.handleKeydown);
165
+ this.removeEventListener("focusin", this.handleFocusin);
157
166
  super.disconnectedCallback();
158
167
  }
159
168
  willUpdate(changedProperties) {
@@ -240,6 +249,31 @@ var UTree = class UTree extends UElement {
240
249
  item.collapseIcon = this.collapseIcon?.cloneNode(true);
241
250
  });
242
251
  }
252
+ /**
253
+ * 정지를 다시 정한다 — `preferred` 가 있으면 그것(포커스를 받으려는 항목), 아니면 지금 정지를 지키되 비활성이 되거나
254
+ * 접힌 부모 밑에 숨으면 보이는 가장 가까운 조상으로 옮긴다(숨은 항목의 tabindex 0 은 Tab 이 건너뛰어 트리에 들어갈
255
+ * 길이 사라진다).
256
+ *
257
+ * ⚠정지가 아닌 항목은 `tabindex` 를 **떼어 낸다**(-1 이 아니다). 항목은 섀도 호스트이고 자식 항목은 그 섀도의 슬롯으로
258
+ * 그려진다 — 음수 tabindex 호스트의 범위는 순차 탐색에서 통째로 빠져, 부모가 -1 이면 그 밑의 정지에 Tab 이 닿지
259
+ * 않았다(실측: Shift+Tab 이 트리를 건너뛰었다). 그래서 항목은 포커스를 받기 직전에 정지가 된다(`UTreeItem.focus`).
260
+ * @internal 항목이 부른다.
261
+ */
262
+ syncTabStop(preferred) {
263
+ if (preferred && !preferred.disabled) this.tabStop = preferred;
264
+ const shown = (item) => {
265
+ for (let p = item.parentItem; p; p = p.parentItem) if (!p.expanded) return false;
266
+ return true;
267
+ };
268
+ const reachable = this.getItems((item) => !item.disabled && shown(item));
269
+ let stop = this.tabStop;
270
+ while (stop && !reachable.includes(stop)) stop = stop.parentItem ?? void 0;
271
+ this.tabStop = stop ?? reachable.find((item) => item.selected) ?? reachable[0];
272
+ this.mapItems((item) => {
273
+ if (item === this.tabStop) item.setAttribute("tabindex", "0");
274
+ else item.removeAttribute("tabindex");
275
+ });
276
+ }
243
277
  selectRange(anchor, target) {
244
278
  const visible = this.getItems((item) => !item.disabled && (!item.parentItem || item.parentItem.expanded));
245
279
  const from = visible.indexOf(anchor);
@@ -65,6 +65,11 @@ export declare class UTreeItem extends UElement {
65
65
  private propagate;
66
66
  private handleSlotChange;
67
67
  private handleChildrenSlotChange;
68
+ private requestTabStopSync;
69
+ /** 포커스를 받기 직전에 탭 정지가 된다 — 정지가 아닌 항목은 tabindex 가 없어 그대로는 포커스를 받지 못한다. */
70
+ focus(options?: FocusOptions): void;
71
+ /** 누르면 포커스가 오도록 — 브라우저가 포커스 대상을 정하기 전(pointerdown)에 정지가 된다. 바깥 항목의 처리는 막는다. */
72
+ private handlePointerdown;
68
73
  private handleHeaderClick;
69
74
  private handleToggleClick;
70
75
  private handleCheckboxClick;
@@ -45,6 +45,10 @@ var UTreeItem = class UTreeItem extends UElement {
45
45
  this._childItems = slot.assignedElements({ flatten: true }).filter((el) => el instanceof _UTreeItem);
46
46
  this.leaf = this._childItems.length === 0;
47
47
  this.propagate();
48
+ this.requestTabStopSync();
49
+ };
50
+ this.handlePointerdown = (e) => {
51
+ if (e.composedPath().find((el) => el instanceof _UTreeItem) === this) this.requestTabStopSync(this);
48
52
  };
49
53
  this.handleHeaderClick = (e) => {
50
54
  if (isFromNestedControl(e, this)) return;
@@ -82,7 +86,7 @@ var UTreeItem = class UTreeItem extends UElement {
82
86
  connectedCallback() {
83
87
  super.connectedCallback();
84
88
  this.setAttribute("role", "treeitem");
85
- this.setAttribute("tabindex", this.disabled ? "-1" : "0");
89
+ this.addEventListener("pointerdown", this.handlePointerdown);
86
90
  if (this.parentElement instanceof _UTreeItem) {
87
91
  this._parentItem = this.parentElement;
88
92
  this.depth = this._parentItem.depth + 1;
@@ -91,8 +95,8 @@ var UTreeItem = class UTreeItem extends UElement {
91
95
  }
92
96
  updated(changedProperties) {
93
97
  super.updated(changedProperties);
98
+ if (changedProperties.has("disabled") || changedProperties.has("expanded")) this.requestTabStopSync();
94
99
  if (changedProperties.has("disabled")) {
95
- this.setAttribute("tabindex", this.disabled ? "-1" : "0");
96
100
  if (this.disabled) this.setAttribute("aria-disabled", "true");
97
101
  else this.removeAttribute("aria-disabled");
98
102
  }
@@ -188,6 +192,14 @@ var UTreeItem = class UTreeItem extends UElement {
188
192
  item.collapseIcon = this.collapseIcon?.cloneNode(true);
189
193
  });
190
194
  }
195
+ requestTabStopSync(preferred) {
196
+ this.closest("u-tree")?.syncTabStop?.(preferred);
197
+ }
198
+ /** 포커스를 받기 직전에 탭 정지가 된다 — 정지가 아닌 항목은 tabindex 가 없어 그대로는 포커스를 받지 못한다. */
199
+ focus(options) {
200
+ this.requestTabStopSync(this);
201
+ super.focus(options);
202
+ }
191
203
  };
192
204
  __decorate([property({
193
205
  type: Boolean,
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@iyulab/components",
3
3
  "description": "web-components library based on lit-element made by iyulab",
4
- "version": "2.5.0",
4
+ "version": "2.6.0",
5
5
  "keywords": [
6
6
  "iyulab",
7
7
  "components",
@@ -27,6 +27,10 @@ Star/custom-symbol rating input. Supports fractional precision and custom symbol
27
27
 
28
28
  A `radiogroup` (named by `label`) of radios named `1`…`max` — a screen reader adds the position ("3 of 5").
29
29
 
30
+ **Keyboard** — like a native radio group: one Tab stop (the chosen star, or the first when there is none);
31
+ `ArrowRight`/`ArrowUp` and `ArrowLeft`/`ArrowDown` move **and choose** (firing `change`), `Home`/`End` choose the
32
+ first/last; `Space`/`Enter` choose the focused star (again on the chosen one clears it). `focus()` goes to the Tab stop.
33
+
30
34
  ## Slots
31
35
 
32
36
  | Name | Description |
@@ -30,6 +30,11 @@ Items are `treeitem`s with `aria-level` (depth), `aria-expanded` (items with chi
30
30
  `selectable` tree) and `aria-checked` (`mixed` for a partly checked parent, in a `checkable` tree). An item is
31
31
  named by its own label — not by the text of the items under it.
32
32
 
33
+ **Keyboard** — the tree is **one** Tab stop: the item focused last (at first the selected item, else the first).
34
+ Tab enters on it and the next Tab leaves the tree; arrows move inside (`↑`/`↓` items, `→` expand / first child,
35
+ `←` collapse / parent, `Home`/`End`). If that item is collapsed away or disabled, the stop moves to its nearest visible
36
+ ancestor. Only the stop carries `tabindex`; `item.focus()` and a click make an item the stop.
37
+
33
38
  ## u-tree
34
39
 
35
40
  ### Slots