@iyulab/components 2.22.0 → 2.23.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 +32 -0
- package/dist/components/UOverlayElement.d.ts +8 -1
- package/dist/components/UOverlayElement.js +14 -4
- package/dist/components/field/UField.d.ts +54 -0
- package/dist/components/field/UField.js +107 -2
- package/dist/components/field/UField.styles.js +20 -0
- package/dist/components/option/UOption.d.ts +5 -0
- package/dist/components/option/UOption.js +5 -0
- package/dist/components/option/UOption.styles.js +7 -3
- package/dist/components/select/USelect.d.ts +9 -0
- package/dist/components/select/USelect.js +31 -1
- package/dist/components/tooltip/UTooltip.d.ts +1 -1
- package/dist/components/tooltip/UTooltip.js +8 -0
- package/dist/utilities/elements.d.ts +2 -1
- package/dist/utilities/elements.js +3 -2
- package/package.json +1 -1
- package/skills/iyulab-components/references/components/field.md +27 -1
- package/skills/iyulab-components/references/components/option.md +1 -0
- package/skills/iyulab-components/references/components/select.md +4 -1
- package/skills/iyulab-components/references/components/tooltip.md +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,37 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## [2.23.1] - 2026-10-13
|
|
4
|
+
|
|
5
|
+
### Fixed
|
|
6
|
+
|
|
7
|
+
- A `u-dialog` or `u-drawer` whose controls are components — `u-button`, `u-icon-button` — gives the first of them the
|
|
8
|
+
focus when it opens. The focus stayed on the dialog itself: the initial-focus search did not count a host whose
|
|
9
|
+
shadow root delegates focus as focusable, and the trap's own «first tabbable» did not see inside it at that moment
|
|
10
|
+
(a native `<button>` was found). `autofocus` on a `u-icon-button` is honoured for the same reason.
|
|
11
|
+
|
|
12
|
+
## [2.23.0] - 2026-10-13
|
|
13
|
+
|
|
14
|
+
### Added
|
|
15
|
+
|
|
16
|
+
- `u-field` can show its `description` as an info icon beside the label, with the text in a tooltip on hover, instead of
|
|
17
|
+
a line under the control: `description-display="hint"` on one field, or `UField.descriptionDisplay = 'hint'` once for
|
|
18
|
+
the whole app (that default also reaches the fields `u-input`, `u-select` and the other controls render internally).
|
|
19
|
+
The control keeps the text as `aria-description`, a validation message still shows under the control, and a field
|
|
20
|
+
without a label keeps the description inline. The hint opens on hovering the icon, on entering the field's control
|
|
21
|
+
from the keyboard (a click into the control does not), and on tapping the icon (touch); Escape or focus leaving the
|
|
22
|
+
field closes it. The icon is not a Tab stop.
|
|
23
|
+
- **`u-select searchable`: Enter in the search field picks the first match.** While there is a query, the first
|
|
24
|
+
visible option is the active candidate — shown like a hovered option (`u-option[active]`) and announced through the
|
|
25
|
+
search field's `aria-activedescendant` — and Enter selects it (and closes the list; with `multiple` it toggles and
|
|
26
|
+
the list stays open). Typing «ap» and pressing Enter used to do nothing; the match took ArrowDown, then Enter. The
|
|
27
|
+
Enter that commits an IME composition does not pick. Options a remote search puts in get a candidate as they arrive.
|
|
28
|
+
|
|
29
|
+
### Fixed
|
|
30
|
+
|
|
31
|
+
- An open `u-tooltip` closes on Escape — content shown on hover or focus could only be dismissed by moving the pointer
|
|
32
|
+
or the focus away (WCAG 1.4.13). The tooltip joins the overlay layer stack, so inside a dialog the first Escape
|
|
33
|
+
closes the tooltip and the next one the dialog.
|
|
34
|
+
|
|
3
35
|
## [2.22.0] - 2026-10-13
|
|
4
36
|
|
|
5
37
|
### Added
|
|
@@ -82,7 +82,12 @@ export declare abstract class UOverlayElement extends UElement {
|
|
|
82
82
|
/**
|
|
83
83
|
* 열릴 때 포커스를 받을 요소를 정한다 — **입력을 먼저 본다.**
|
|
84
84
|
*
|
|
85
|
-
* 순서: `[autofocus]` → 첫 입력 컨트롤 → (없으면) focus-trap
|
|
85
|
+
* 순서: `[autofocus]` → 첫 입력 컨트롤 → 첫 포커스 가능 요소(섀도 안까지) → (없으면) focus-trap 기본값.
|
|
86
|
+
*
|
|
87
|
+
* 셋째 단계는 우리가 찾는다 — focus-trap 의 «첫 tabbable» 은 여는 순간 슬롯 자식 컴포넌트(`u-button` 의
|
|
88
|
+
* 섀도 안 버튼)를 보지 못해, 버튼만 든 대화상자의 포커스가 호스트에 머물렀다(브라우저 실측 — 네이티브
|
|
89
|
+
* `<button>` 은 잡았다. 열린 뒤의 Tab 가두기는 그 버튼들을 정상으로 돈다). 후보마다 실제로 포커스해 보고,
|
|
90
|
+
* 포커스가 그 안에 들어간 첫 요소에서 멈춘다(`delegatesFocus` 호스트가 안에 포커스할 것이 없으면 다음으로).
|
|
86
91
|
*
|
|
87
92
|
* 🔴**두 분기가 «각각» 무엇을 하는지 되돌려 재서 갈랐다** — 이 함수는 그 기록이다.
|
|
88
93
|
*
|
|
@@ -97,6 +102,8 @@ export declare abstract class UOverlayElement extends UElement {
|
|
|
97
102
|
* (`tests/browser/overlay-initial-focus.browser.test.ts` 가 둘 다 감시한다.)
|
|
98
103
|
*/
|
|
99
104
|
private resolveInitialFocus;
|
|
105
|
+
/** `el` 을 포커스하고, 실제 포커스가 그 안(섀도 포함)에 들어갔는가. */
|
|
106
|
+
private focusLands;
|
|
100
107
|
/** 오버레이가 닫힐 때 설정을 해제합니다. */
|
|
101
108
|
private cleanup;
|
|
102
109
|
/** host 자체를 클릭한 경우(백드롭)만 닫기 요청 */
|
|
@@ -121,7 +121,12 @@ var UOverlayElement = class extends UElement {
|
|
|
121
121
|
/**
|
|
122
122
|
* 열릴 때 포커스를 받을 요소를 정한다 — **입력을 먼저 본다.**
|
|
123
123
|
*
|
|
124
|
-
* 순서: `[autofocus]` → 첫 입력 컨트롤 → (없으면) focus-trap
|
|
124
|
+
* 순서: `[autofocus]` → 첫 입력 컨트롤 → 첫 포커스 가능 요소(섀도 안까지) → (없으면) focus-trap 기본값.
|
|
125
|
+
*
|
|
126
|
+
* 셋째 단계는 우리가 찾는다 — focus-trap 의 «첫 tabbable» 은 여는 순간 슬롯 자식 컴포넌트(`u-button` 의
|
|
127
|
+
* 섀도 안 버튼)를 보지 못해, 버튼만 든 대화상자의 포커스가 호스트에 머물렀다(브라우저 실측 — 네이티브
|
|
128
|
+
* `<button>` 은 잡았다. 열린 뒤의 Tab 가두기는 그 버튼들을 정상으로 돈다). 후보마다 실제로 포커스해 보고,
|
|
129
|
+
* 포커스가 그 안에 들어간 첫 요소에서 멈춘다(`delegatesFocus` 호스트가 안에 포커스할 것이 없으면 다음으로).
|
|
125
130
|
*
|
|
126
131
|
* 🔴**두 분기가 «각각» 무엇을 하는지 되돌려 재서 갈랐다** — 이 함수는 그 기록이다.
|
|
127
132
|
*
|
|
@@ -138,11 +143,16 @@ var UOverlayElement = class extends UElement {
|
|
|
138
143
|
resolveInitialFocus() {
|
|
139
144
|
const content = Array.from(this.children);
|
|
140
145
|
const target = querySelectorDeep(content, "[autofocus]", isFocusCandidate) ?? querySelectorDeep(content, "input, select, textarea, u-input, u-textarea, u-select, u-checkbox, u-radio, u-switch, u-slider", isFocusCandidate);
|
|
141
|
-
if (
|
|
142
|
-
|
|
146
|
+
if (target && this.focusLands(target)) return false;
|
|
147
|
+
return querySelectorDeep(content, "*", (el) => isFocusCandidate(el) && this.focusLands(el)) ? false : void 0;
|
|
148
|
+
}
|
|
149
|
+
/** `el` 을 포커스하고, 실제 포커스가 그 안(섀도 포함)에 들어갔는가. */
|
|
150
|
+
focusLands(el) {
|
|
151
|
+
el.focus();
|
|
143
152
|
let active = document.activeElement;
|
|
144
153
|
while (active?.shadowRoot?.activeElement) active = active.shadowRoot.activeElement;
|
|
145
|
-
for (let n = active; n; n = n.parentNode ?? n.host ?? null) if (n ===
|
|
154
|
+
for (let n = active; n; n = n.parentNode ?? n.host ?? null) if (n === el) return true;
|
|
155
|
+
return false;
|
|
146
156
|
}
|
|
147
157
|
/** 오버레이가 닫힐 때 설정을 해제합니다. */
|
|
148
158
|
cleanup() {
|
|
@@ -1,11 +1,22 @@
|
|
|
1
1
|
import { PropertyValues } from 'lit';
|
|
2
2
|
import { UElement } from '../UElement.js';
|
|
3
|
+
/**
|
|
4
|
+
* 설명(`description`)을 어디에 보이는가.
|
|
5
|
+
* - `inline` — 컨트롤 아래 한 줄(기본).
|
|
6
|
+
* - `hint` — 라벨 옆 정보 아이콘에 마우스를 올리면 툴팁으로. 컨트롤 아래 공간을 쓰지 않아 폼이 촘촘해진다.
|
|
7
|
+
* 설명은 두 방식 모두 컨트롤의 `aria-description` 으로도 전달된다(보조기기에는 차이가 없다).
|
|
8
|
+
* 유효성 검사 메시지는 방식과 무관하게 언제나 아래에 보인다 — 오류는 숨기지 않는다.
|
|
9
|
+
* 라벨이 없으면 아이콘을 둘 자리가 없어 `inline` 으로 보인다.
|
|
10
|
+
*/
|
|
11
|
+
export type FieldDescriptionDisplay = 'inline' | 'hint';
|
|
3
12
|
/**
|
|
4
13
|
* 폼 컨트롤의 공통 레이아웃을 제공하는 필드 컴포넌트입니다.
|
|
5
14
|
* 라벨, 필수 표시, 설명 텍스트, 유효성 검사 메시지를 포함합니다.
|
|
6
15
|
*
|
|
7
16
|
* @slot - 폼 컨트롤 (input, select, textarea 등)
|
|
8
17
|
* @slot label-aside - 라벨 오른쪽 슬롯 영역 (숫자 표시, 알림 등)
|
|
18
|
+
* @csspart hint - `description-display="hint"` 의 정보 아이콘 감싸개
|
|
19
|
+
* @csspart hint-tooltip - 그 툴팁
|
|
9
20
|
*/
|
|
10
21
|
export declare class UField extends UElement {
|
|
11
22
|
static styles: import('lit').CSSResultGroup[];
|
|
@@ -28,7 +39,50 @@ export declare class UField extends UElement {
|
|
|
28
39
|
* 형제 프로퍼티들도 명시형을 쓴다(`show-delay`·`hide-delay`).
|
|
29
40
|
*/
|
|
30
41
|
validationMessage?: string;
|
|
42
|
+
/**
|
|
43
|
+
* 설명을 보이는 방식 — 비우면 앱 전역 기본값(`UField.descriptionDisplay`)을 따른다.
|
|
44
|
+
* 컨트롤(`u-input` 등)이 안에 두는 필드는 전역 기본값을 따르므로, 앱 전체를 바꿀 때는 전역 기본값을 쓴다.
|
|
45
|
+
*/
|
|
46
|
+
descriptionDisplay?: FieldDescriptionDisplay;
|
|
47
|
+
/**
|
|
48
|
+
* 앱 전역 기본값 — 앱 시작 때 한 번 정한다(예: `UField.descriptionDisplay = 'hint'`). 이미 그려진 필드는 다음 렌더부터 따른다.
|
|
49
|
+
* @default 'inline'
|
|
50
|
+
*/
|
|
51
|
+
static descriptionDisplay: FieldDescriptionDisplay;
|
|
52
|
+
/** 이 필드에서 실제로 쓰는 방식 — 라벨이 없으면 아이콘을 둘 자리가 없어 `inline`. */
|
|
53
|
+
private get effectiveDescriptionDisplay();
|
|
31
54
|
render(): import('lit-html').TemplateResult<1>;
|
|
55
|
+
/**
|
|
56
|
+
* `hint` — 라벨 옆 정보 아이콘 + 툴팁. 설명은 컨트롤의 `aria-description` 으로 이미 전달되므로 아이콘은 보조기기에서 숨긴다.
|
|
57
|
+
* 툴팁은 라벨 «위»(입력 칸을 가리지 않는다) · 아이콘 왼쪽 끝에 맞추고 화면 밖으로 나가면 밀어 넣는다.
|
|
58
|
+
*
|
|
59
|
+
* 여는 길은 셋이다 — 아이콘에 마우스를 올린다 · 필드의 컨트롤에 **키보드로** 들어온다(Tab · 프로그램 `focus()` — 눈으로 보는 키보드
|
|
60
|
+
* 사용자는 마우스가 없다) · 아이콘을 **탭**한다(터치에는 오버가 없다). 아이콘을 포커스 가능한 버튼으로 만들지 않는
|
|
61
|
+
* 이유: 칸이 수십 개인 폼에서 탭 정지가 칸마다 하나씩 늘어난다. 닫는 길은 Escape(툴팁이 층이다) · 포커스가 필드를
|
|
62
|
+
* 떠남 · 바깥 탭.
|
|
63
|
+
*/
|
|
64
|
+
private renderHint;
|
|
65
|
+
private get hintEl();
|
|
66
|
+
private get hintTooltip();
|
|
67
|
+
/** 아이콘을 누른 포인터의 종류 — 터치·펜의 탭만 «고정해서 연다». 마우스는 오버가 이미 열었다. */
|
|
68
|
+
private hintPointerType;
|
|
69
|
+
/** 탭으로 고정해 연 상태 — 오버의 `pointerleave` 가 닫아도 탭이 다시 연다. 바깥 탭 · 두 번째 탭이 푼다. */
|
|
70
|
+
private hintPinned;
|
|
71
|
+
private handleHintPointerDown;
|
|
72
|
+
private handleHintClick;
|
|
73
|
+
private handleOutsidePointerDown;
|
|
74
|
+
private unpinHint;
|
|
75
|
+
/**
|
|
76
|
+
* 필드 안을 포인터로 눌러 생긴 포커스인가. `:focus-visible` 로는 가르지 못한다 — 글자를 받는 입력은 마우스로 눌러도
|
|
77
|
+
* 늘 `:focus-visible` 이다(브라우저 휴리스틱). 그래서 누름을 직접 본다: 필드 안 `pointerdown` 뒤의 첫 포커스가 그것이다.
|
|
78
|
+
*/
|
|
79
|
+
private focusByPointer;
|
|
80
|
+
private handleHostPointerDown;
|
|
81
|
+
/** 컨트롤에 키보드로 들어오면 설명을 보인다 — 포인터로 누른 포커스에는 열지 않는다(마우스에는 오버가 있다). */
|
|
82
|
+
private handleFocusIn;
|
|
83
|
+
private handleFocusOut;
|
|
84
|
+
connectedCallback(): void;
|
|
85
|
+
disconnectedCallback(): void;
|
|
32
86
|
private renderFooter;
|
|
33
87
|
/** 슬롯에 꽂힌 첫 포커스 가능 자식으로 위임한다 — 라벨 클릭과 같은 대상 탐색 로직을
|
|
34
88
|
* 공개 API로도 노출해, 소비자가 임의의 폼 컨트롤(자체 웹 컴포넌트가 아닌 것 포함)을
|
|
@@ -3,11 +3,14 @@ import __decorateMetadata from "../../_virtual/_@oxc-project_runtime@0.153.0/hel
|
|
|
3
3
|
import __decorate from "../../_virtual/_@oxc-project_runtime@0.153.0/helpers/esm/decorate.js";
|
|
4
4
|
import { HostAria } from "../../utilities/hostAria.js";
|
|
5
5
|
import { devWarnOnce } from "../../utilities/devWarning.js";
|
|
6
|
+
import "../icon/UIcon.js";
|
|
7
|
+
import "../tooltip/UTooltip.js";
|
|
6
8
|
import { styles } from "./UField.styles.js";
|
|
7
9
|
import { html, nothing } from "lit";
|
|
8
10
|
import { customElement, property } from "lit/decorators.js";
|
|
9
11
|
import { isFocusable } from "tabbable";
|
|
10
12
|
//#region src/components/field/UField.ts
|
|
13
|
+
var _UField;
|
|
11
14
|
/** 네이티브로 «폼 컨트롤이거나 포커스를 받도록 저작된» 태그 — 가시성과 무관한 구조 사실이다. */
|
|
12
15
|
var NATIVE_CONTROL_TAGS = /* @__PURE__ */ new Set([
|
|
13
16
|
"INPUT",
|
|
@@ -36,11 +39,58 @@ function isNamedByContent(el) {
|
|
|
36
39
|
return (CONTENT_NAMED.test(el.localName) || !!role && CONTENT_NAMED_ROLES.test(role)) && (el.textContent ?? "").trim() !== "";
|
|
37
40
|
}
|
|
38
41
|
var UField = class UField extends UElement {
|
|
42
|
+
static {
|
|
43
|
+
_UField = this;
|
|
44
|
+
}
|
|
39
45
|
constructor(..._args) {
|
|
40
46
|
super(..._args);
|
|
41
47
|
this.disabled = false;
|
|
42
48
|
this.required = false;
|
|
43
49
|
this.invalid = false;
|
|
50
|
+
this.hintPointerType = "";
|
|
51
|
+
this.hintPinned = false;
|
|
52
|
+
this.handleHintPointerDown = (e) => {
|
|
53
|
+
this.hintPointerType = e.pointerType;
|
|
54
|
+
};
|
|
55
|
+
this.handleHintClick = () => {
|
|
56
|
+
if (this.hintPointerType !== "touch" && this.hintPointerType !== "pen") return;
|
|
57
|
+
if (this.hintPinned) {
|
|
58
|
+
this.unpinHint();
|
|
59
|
+
this.hintTooltip?.hide();
|
|
60
|
+
return;
|
|
61
|
+
}
|
|
62
|
+
const hint = this.hintEl;
|
|
63
|
+
if (!hint) return;
|
|
64
|
+
this.hintPinned = true;
|
|
65
|
+
document.addEventListener("pointerdown", this.handleOutsidePointerDown, true);
|
|
66
|
+
this.hintTooltip?.show(hint);
|
|
67
|
+
};
|
|
68
|
+
this.handleOutsidePointerDown = (e) => {
|
|
69
|
+
const hint = this.hintEl;
|
|
70
|
+
if (hint && e.composedPath().includes(hint)) return;
|
|
71
|
+
this.unpinHint();
|
|
72
|
+
this.hintTooltip?.hide();
|
|
73
|
+
};
|
|
74
|
+
this.focusByPointer = false;
|
|
75
|
+
this.handleHostPointerDown = () => {
|
|
76
|
+
this.focusByPointer = true;
|
|
77
|
+
setTimeout(() => {
|
|
78
|
+
this.focusByPointer = false;
|
|
79
|
+
});
|
|
80
|
+
};
|
|
81
|
+
this.handleFocusIn = () => {
|
|
82
|
+
const byPointer = this.focusByPointer;
|
|
83
|
+
this.focusByPointer = false;
|
|
84
|
+
const hint = this.hintEl;
|
|
85
|
+
if (!hint || byPointer) return;
|
|
86
|
+
this.hintTooltip?.show(hint);
|
|
87
|
+
};
|
|
88
|
+
this.handleFocusOut = (e) => {
|
|
89
|
+
const next = e.relatedTarget;
|
|
90
|
+
if (next instanceof Node && (this.contains(next) || this.shadowRoot?.contains(next))) return;
|
|
91
|
+
if (this.hintPinned) return;
|
|
92
|
+
this.hintTooltip?.hide();
|
|
93
|
+
};
|
|
44
94
|
this.aria = new HostAria(this);
|
|
45
95
|
this.handleLabelClick = () => {
|
|
46
96
|
this.focus();
|
|
@@ -49,6 +99,13 @@ var UField = class UField extends UElement {
|
|
|
49
99
|
static {
|
|
50
100
|
this.styles = [super.styles, styles];
|
|
51
101
|
}
|
|
102
|
+
static {
|
|
103
|
+
this.descriptionDisplay = "inline";
|
|
104
|
+
}
|
|
105
|
+
/** 이 필드에서 실제로 쓰는 방식 — 라벨이 없으면 아이콘을 둘 자리가 없어 `inline`. */
|
|
106
|
+
get effectiveDescriptionDisplay() {
|
|
107
|
+
return (this.descriptionDisplay ?? _UField.descriptionDisplay) === "hint" && this.label ? "hint" : "inline";
|
|
108
|
+
}
|
|
52
109
|
render() {
|
|
53
110
|
return html`
|
|
54
111
|
<div class="header" ?hidden=${!this.label}>
|
|
@@ -56,6 +113,7 @@ var UField = class UField extends UElement {
|
|
|
56
113
|
<span class="required" ?hidden=${!this.required}>*</span>
|
|
57
114
|
${this.label}
|
|
58
115
|
</label>
|
|
116
|
+
${this.renderHint()}
|
|
59
117
|
<slot name="label-aside"></slot>
|
|
60
118
|
</div>
|
|
61
119
|
|
|
@@ -64,8 +122,51 @@ var UField = class UField extends UElement {
|
|
|
64
122
|
${this.renderFooter()}
|
|
65
123
|
`;
|
|
66
124
|
}
|
|
125
|
+
/**
|
|
126
|
+
* `hint` — 라벨 옆 정보 아이콘 + 툴팁. 설명은 컨트롤의 `aria-description` 으로 이미 전달되므로 아이콘은 보조기기에서 숨긴다.
|
|
127
|
+
* 툴팁은 라벨 «위»(입력 칸을 가리지 않는다) · 아이콘 왼쪽 끝에 맞추고 화면 밖으로 나가면 밀어 넣는다.
|
|
128
|
+
*
|
|
129
|
+
* 여는 길은 셋이다 — 아이콘에 마우스를 올린다 · 필드의 컨트롤에 **키보드로** 들어온다(Tab · 프로그램 `focus()` — 눈으로 보는 키보드
|
|
130
|
+
* 사용자는 마우스가 없다) · 아이콘을 **탭**한다(터치에는 오버가 없다). 아이콘을 포커스 가능한 버튼으로 만들지 않는
|
|
131
|
+
* 이유: 칸이 수십 개인 폼에서 탭 정지가 칸마다 하나씩 늘어난다. 닫는 길은 Escape(툴팁이 층이다) · 포커스가 필드를
|
|
132
|
+
* 떠남 · 바깥 탭.
|
|
133
|
+
*/
|
|
134
|
+
renderHint() {
|
|
135
|
+
if (!this.description || this.effectiveDescriptionDisplay !== "hint") return nothing;
|
|
136
|
+
return html`
|
|
137
|
+
<span class="hint" part="hint" aria-hidden="true"
|
|
138
|
+
@pointerdown=${this.handleHintPointerDown}
|
|
139
|
+
@click=${this.handleHintClick}>
|
|
140
|
+
<u-icon lib="internal" name="info-circle-fill"></u-icon>
|
|
141
|
+
<u-tooltip part="hint-tooltip" placement="top-start" shift>${this.description}</u-tooltip>
|
|
142
|
+
</span>
|
|
143
|
+
`;
|
|
144
|
+
}
|
|
145
|
+
get hintEl() {
|
|
146
|
+
return this.shadowRoot?.querySelector(".hint") ?? null;
|
|
147
|
+
}
|
|
148
|
+
get hintTooltip() {
|
|
149
|
+
return this.shadowRoot?.querySelector(".hint u-tooltip") ?? null;
|
|
150
|
+
}
|
|
151
|
+
unpinHint() {
|
|
152
|
+
this.hintPinned = false;
|
|
153
|
+
document.removeEventListener("pointerdown", this.handleOutsidePointerDown, true);
|
|
154
|
+
}
|
|
155
|
+
connectedCallback() {
|
|
156
|
+
super.connectedCallback();
|
|
157
|
+
this.addEventListener("pointerdown", this.handleHostPointerDown, true);
|
|
158
|
+
this.addEventListener("focusin", this.handleFocusIn);
|
|
159
|
+
this.addEventListener("focusout", this.handleFocusOut);
|
|
160
|
+
}
|
|
161
|
+
disconnectedCallback() {
|
|
162
|
+
this.removeEventListener("pointerdown", this.handleHostPointerDown, true);
|
|
163
|
+
this.removeEventListener("focusin", this.handleFocusIn);
|
|
164
|
+
this.removeEventListener("focusout", this.handleFocusOut);
|
|
165
|
+
this.unpinHint();
|
|
166
|
+
super.disconnectedCallback();
|
|
167
|
+
}
|
|
67
168
|
renderFooter() {
|
|
68
|
-
const message = this.invalid && this.validationMessage ? this.validationMessage : this.description;
|
|
169
|
+
const message = this.invalid && this.validationMessage ? this.validationMessage : this.effectiveDescriptionDisplay === "inline" ? this.description : void 0;
|
|
69
170
|
if (!message) return nothing;
|
|
70
171
|
return html`<div class="footer">${message}</div>`;
|
|
71
172
|
}
|
|
@@ -259,6 +360,10 @@ __decorate([property({
|
|
|
259
360
|
type: String,
|
|
260
361
|
attribute: "validation-message"
|
|
261
362
|
}), __decorateMetadata("design:type", String)], UField.prototype, "validationMessage", void 0);
|
|
262
|
-
|
|
363
|
+
__decorate([property({
|
|
364
|
+
type: String,
|
|
365
|
+
attribute: "description-display"
|
|
366
|
+
}), __decorateMetadata("design:type", Object)], UField.prototype, "descriptionDisplay", void 0);
|
|
367
|
+
UField = _UField = __decorate([customElement("u-field")], UField);
|
|
263
368
|
//#endregion
|
|
264
369
|
export { UField };
|
|
@@ -40,6 +40,26 @@ var styles = css`
|
|
|
40
40
|
user-select: none;
|
|
41
41
|
}
|
|
42
42
|
|
|
43
|
+
.hint {
|
|
44
|
+
display: inline-flex;
|
|
45
|
+
align-items: center;
|
|
46
|
+
margin-inline-start: 0.35em;
|
|
47
|
+
margin-inline-end: auto;
|
|
48
|
+
color: var(--u-txt-color-weak, #616161);
|
|
49
|
+
font-size: 1.05em;
|
|
50
|
+
cursor: help;
|
|
51
|
+
}
|
|
52
|
+
.hint:hover {
|
|
53
|
+
color: var(--u-txt-color, #212121);
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
.hint u-tooltip {
|
|
57
|
+
max-width: min(20rem, calc(100vw - 2rem));
|
|
58
|
+
white-space: normal;
|
|
59
|
+
font-weight: 400;
|
|
60
|
+
line-height: 1.45;
|
|
61
|
+
}
|
|
62
|
+
|
|
43
63
|
.label {
|
|
44
64
|
font-weight: 500;
|
|
45
65
|
line-height: 1.25;
|
|
@@ -34,6 +34,11 @@ export declare class UOption extends UElement {
|
|
|
34
34
|
disabled: boolean;
|
|
35
35
|
/** 선택 여부 */
|
|
36
36
|
selected: boolean;
|
|
37
|
+
/**
|
|
38
|
+
* The candidate Enter picks from the owning select's search box — shown like a hovered option. Set by `u-select`
|
|
39
|
+
* while its search box has the focus; not meant to be set by hand.
|
|
40
|
+
*/
|
|
41
|
+
active: boolean;
|
|
37
42
|
/** 옵션 마커 유형. 'radio'는 원형, 'check'는 체크 모양의 마커를 표시합니다. */
|
|
38
43
|
marker?: OptionMarker;
|
|
39
44
|
/** 옵션 고유값 */
|
|
@@ -11,6 +11,7 @@ var UOption = class UOption extends UElement {
|
|
|
11
11
|
super(..._args);
|
|
12
12
|
this.disabled = false;
|
|
13
13
|
this.selected = false;
|
|
14
|
+
this.active = false;
|
|
14
15
|
this.value = "";
|
|
15
16
|
}
|
|
16
17
|
static {
|
|
@@ -84,6 +85,10 @@ __decorate([property({
|
|
|
84
85
|
type: Boolean,
|
|
85
86
|
reflect: true
|
|
86
87
|
}), __decorateMetadata("design:type", Boolean)], UOption.prototype, "selected", void 0);
|
|
88
|
+
__decorate([property({
|
|
89
|
+
type: Boolean,
|
|
90
|
+
reflect: true
|
|
91
|
+
}), __decorateMetadata("design:type", Boolean)], UOption.prototype, "active", void 0);
|
|
87
92
|
__decorate([property({
|
|
88
93
|
type: String,
|
|
89
94
|
reflect: true
|
|
@@ -33,7 +33,9 @@ var styles = css`
|
|
|
33
33
|
display: flex;
|
|
34
34
|
flex-direction: row;
|
|
35
35
|
align-items: center;
|
|
36
|
-
padding: var(--option-padding-block) var(--option-padding-inline)
|
|
36
|
+
padding: var(--option-padding-block) var(--option-padding-inline);
|
|
37
|
+
|
|
38
|
+
min-height: var(--u-target-size, 0px);
|
|
37
39
|
border-radius: inherit;
|
|
38
40
|
}
|
|
39
41
|
:host(:focus-visible) {
|
|
@@ -45,7 +47,8 @@ var styles = css`
|
|
|
45
47
|
}
|
|
46
48
|
|
|
47
49
|
:host(:not([disabled]):hover),
|
|
48
|
-
:host(:not([disabled]):focus-visible)
|
|
50
|
+
:host(:not([disabled]):focus-visible),
|
|
51
|
+
:host([active]:not([disabled])) {
|
|
49
52
|
color: var(--option-color-interactive);
|
|
50
53
|
border-color: var(--option-border-color-interactive);
|
|
51
54
|
background-color: var(--option-background-color-interactive);
|
|
@@ -57,7 +60,8 @@ var styles = css`
|
|
|
57
60
|
background-color: var(--option-background-color-active);
|
|
58
61
|
}
|
|
59
62
|
:host([selected]:hover),
|
|
60
|
-
:host([selected]:focus-visible)
|
|
63
|
+
:host([selected]:focus-visible),
|
|
64
|
+
:host([selected][active]) {
|
|
61
65
|
color: var(--option-color-active-interactive);
|
|
62
66
|
border-color: var(--option-border-color-active-interactive);
|
|
63
67
|
background-color: var(--option-background-color-active-interactive);
|
|
@@ -87,6 +87,11 @@ export declare class USelect extends UFormControlElement<string | string[]> {
|
|
|
87
87
|
private query;
|
|
88
88
|
/** `query` 의 마지막 음절이 아직 조합 중인가 — 검색 일치가 그 음절을 자모 앞부분으로 견준다. */
|
|
89
89
|
private queryComposing;
|
|
90
|
+
/**
|
|
91
|
+
* 검색칸의 활성 후보 — 검색어가 있으면 첫 보이는 옵션. Enter 가 그것을 고른다(APG «list autocomplete with automatic
|
|
92
|
+
* selection»). 포커스는 검색칸에 남고, 보조기기에는 검색칸의 `aria-activedescendant` 로 알린다.
|
|
93
|
+
*/
|
|
94
|
+
private activeOption?;
|
|
90
95
|
/** 검색어가 있는데 보이는 옵션이 없다 — 팝업에 «일치하는 항목 없음» 을 알린다. */
|
|
91
96
|
private noMatches;
|
|
92
97
|
/** aria-expanded 배선용 팝오버 열림 상태 */
|
|
@@ -145,6 +150,10 @@ export declare class USelect extends UFormControlElement<string | string[]> {
|
|
|
145
150
|
* 들고 남지 않게). `filter="none"` 이면 아무것도 숨기지 않는다.
|
|
146
151
|
*/
|
|
147
152
|
private applyFilter;
|
|
153
|
+
/** 검색어가 있으면 첫 보이는(고를 수 있는) 옵션이 활성 후보 — 없으면 후보도 없다(화살표로 목록에 들어간다). */
|
|
154
|
+
private updateActiveOption;
|
|
155
|
+
private setActiveOption;
|
|
156
|
+
private get searchInputEl();
|
|
148
157
|
private handleSearchKeydown;
|
|
149
158
|
private handleClearClick;
|
|
150
159
|
/** suffix `u-icon`은 순수 표시 요소(버튼 아님)라 네이티브 키보드 활성화가 없다 —
|
|
@@ -2,6 +2,7 @@ import { Locale } from "../../utilities/Locale.js";
|
|
|
2
2
|
import __decorateMetadata from "../../_virtual/_@oxc-project_runtime@0.153.0/helpers/esm/decorateMetadata.js";
|
|
3
3
|
import __decorate from "../../_virtual/_@oxc-project_runtime@0.153.0/helpers/esm/decorate.js";
|
|
4
4
|
import { UFormControlElement } from "../UFormControlElement.js";
|
|
5
|
+
import { isImeComposing } from "../../utilities/keyboard.js";
|
|
5
6
|
import "../spinner/USpinner.js";
|
|
6
7
|
import "../icon/UIcon.js";
|
|
7
8
|
import "../chip/UChip.js";
|
|
@@ -47,6 +48,7 @@ var USelect = class USelect extends UFormControlElement {
|
|
|
47
48
|
};
|
|
48
49
|
this.handlePopoverHide = () => {
|
|
49
50
|
this.open = false;
|
|
51
|
+
this.setActiveOption(void 0);
|
|
50
52
|
if (this.popoverEl?.matches(":focus-within")) this.containerEl?.focus();
|
|
51
53
|
};
|
|
52
54
|
this.handleOptionClick = (e) => {
|
|
@@ -104,6 +106,11 @@ var USelect = class USelect extends UFormControlElement {
|
|
|
104
106
|
this.updateSearch(e.target);
|
|
105
107
|
};
|
|
106
108
|
this.handleSearchKeydown = (e) => {
|
|
109
|
+
if (e.key === "Enter" && !isImeComposing(e) && this.activeOption) {
|
|
110
|
+
e.preventDefault();
|
|
111
|
+
this.activeOption.click();
|
|
112
|
+
return;
|
|
113
|
+
}
|
|
107
114
|
const options = this.options.filter((o) => !o.hidden && !o.disabled);
|
|
108
115
|
if (options.length === 0) return;
|
|
109
116
|
switch (e.key) {
|
|
@@ -231,7 +238,10 @@ var USelect = class USelect extends UFormControlElement {
|
|
|
231
238
|
autofocus
|
|
232
239
|
for=".container"
|
|
233
240
|
trigger="click"
|
|
234
|
-
@show=${() =>
|
|
241
|
+
@show=${() => {
|
|
242
|
+
this.open = true;
|
|
243
|
+
this.updateActiveOption();
|
|
244
|
+
}}
|
|
235
245
|
@hide=${this.handlePopoverHide}
|
|
236
246
|
strategy="fixed"
|
|
237
247
|
placement="bottom-start"
|
|
@@ -374,6 +384,26 @@ var USelect = class USelect extends UFormControlElement {
|
|
|
374
384
|
option.hidden = !Locale.matchesSearch(option.getText(), query, options) && !Locale.matchesSearch(option.value, query, options);
|
|
375
385
|
}
|
|
376
386
|
this.noMatches = !!this.query && !this.loading && !this.options.some((o) => !o.hidden);
|
|
387
|
+
this.updateActiveOption();
|
|
388
|
+
}
|
|
389
|
+
/** 검색어가 있으면 첫 보이는(고를 수 있는) 옵션이 활성 후보 — 없으면 후보도 없다(화살표로 목록에 들어간다). */
|
|
390
|
+
updateActiveOption() {
|
|
391
|
+
const candidate = this.searchable && this.open && this.query ? this.options.find((o) => !o.hidden && !o.disabled) : void 0;
|
|
392
|
+
this.setActiveOption(candidate);
|
|
393
|
+
}
|
|
394
|
+
setActiveOption(option) {
|
|
395
|
+
if (this.activeOption === option) return;
|
|
396
|
+
if (this.activeOption) this.activeOption.active = false;
|
|
397
|
+
this.activeOption = option;
|
|
398
|
+
if (option) {
|
|
399
|
+
option.active = true;
|
|
400
|
+
option.scrollIntoView?.({ block: "nearest" });
|
|
401
|
+
}
|
|
402
|
+
const input = this.searchInputEl;
|
|
403
|
+
if (input && "ariaActiveDescendantElement" in input) input.ariaActiveDescendantElement = option ?? null;
|
|
404
|
+
}
|
|
405
|
+
get searchInputEl() {
|
|
406
|
+
return this.shadowRoot?.querySelector(".search-input input") ?? null;
|
|
377
407
|
}
|
|
378
408
|
};
|
|
379
409
|
__decorate([property({
|
|
@@ -2,7 +2,7 @@ import { PropertyValues } from 'lit';
|
|
|
2
2
|
import { UFloatingElement } from '../UFloatingElement.js';
|
|
3
3
|
/**
|
|
4
4
|
* 특정 요소에 툴팁을 표시하는 컴포넌트입니다.
|
|
5
|
-
* 호버 또는 포커스 시 자동으로 표시합니다.
|
|
5
|
+
* 호버 또는 포커스 시 자동으로 표시합니다. 열린 툴팁은 Escape 로 닫힌다(포인터·포커스를 옮기지 않고 — WCAG 1.4.13).
|
|
6
6
|
*
|
|
7
7
|
* @slot - 툴팁 콘텐츠
|
|
8
8
|
*
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import __decorateMetadata from "../../_virtual/_@oxc-project_runtime@0.153.0/helpers/esm/decorateMetadata.js";
|
|
2
2
|
import __decorate from "../../_virtual/_@oxc-project_runtime@0.153.0/helpers/esm/decorate.js";
|
|
3
3
|
import { UFloatingElement } from "../UFloatingElement.js";
|
|
4
|
+
import { OverlayManager } from "../../utilities/OverlayManager.js";
|
|
4
5
|
import { styles } from "./UTooltip.styles.js";
|
|
5
6
|
import { html } from "lit";
|
|
6
7
|
import { customElement, property } from "lit/decorators.js";
|
|
@@ -44,11 +45,18 @@ var UTooltip = class UTooltip extends UFloatingElement {
|
|
|
44
45
|
this.styles = [super.styles, styles];
|
|
45
46
|
}
|
|
46
47
|
disconnectedCallback() {
|
|
48
|
+
OverlayManager.closeLayer(this);
|
|
47
49
|
if (this.anchors) this.unbind(this.anchors);
|
|
48
50
|
super.disconnectedCallback();
|
|
49
51
|
}
|
|
50
52
|
updated(changedProperties) {
|
|
51
53
|
super.updated(changedProperties);
|
|
54
|
+
if (changedProperties.has("open")) {
|
|
55
|
+
if (this.open) OverlayManager.openLayer(this, () => {
|
|
56
|
+
this.hide();
|
|
57
|
+
});
|
|
58
|
+
else OverlayManager.closeLayer(this);
|
|
59
|
+
}
|
|
52
60
|
if (changedProperties.has("anchors")) {
|
|
53
61
|
const oldAnchors = changedProperties.get("anchors");
|
|
54
62
|
const newAnchors = this.anchors;
|
|
@@ -23,7 +23,8 @@ export declare function querySelectorAllWithin(element: Element, selectors: stri
|
|
|
23
23
|
export declare function isCoarsePointer(event: PointerEvent): boolean;
|
|
24
24
|
/**
|
|
25
25
|
* 포커스를 «받을 수 있는» 요소인가 — 초기 포커스 후보를 고를 때 쓴다.
|
|
26
|
-
* 네이티브 포커스 요소 · `focus()` 를 재정의한(안쪽으로 넘겨 주는) 컴포넌트 · `
|
|
26
|
+
* 네이티브 포커스 요소 · `focus()` 를 재정의한(안쪽으로 넘겨 주는) 컴포넌트 · 섀도 루트가 `delegatesFocus` 인
|
|
27
|
+
* 호스트(`u-button` · `u-icon-button` — `focus()` 를 플랫폼이 안쪽으로 넘긴다) · `tabindex` 를 가진 요소이고,
|
|
27
28
|
* 비활성·`inert`·안 보임이 아니어야 한다. 걸러진 호스트는 그 안쪽(섀도 루트)에서 계속 찾는다.
|
|
28
29
|
* `u-select` 의 섀도에는 속성 `autofocus` 를 가진 닫힌 `u-popover` 가 늘 있다 — 이것을 집으면
|
|
29
30
|
* 포커스가 아무 데도 가지 않는다.
|
|
@@ -44,7 +44,8 @@ function isCoarsePointer(event) {
|
|
|
44
44
|
}
|
|
45
45
|
/**
|
|
46
46
|
* 포커스를 «받을 수 있는» 요소인가 — 초기 포커스 후보를 고를 때 쓴다.
|
|
47
|
-
* 네이티브 포커스 요소 · `focus()` 를 재정의한(안쪽으로 넘겨 주는) 컴포넌트 · `
|
|
47
|
+
* 네이티브 포커스 요소 · `focus()` 를 재정의한(안쪽으로 넘겨 주는) 컴포넌트 · 섀도 루트가 `delegatesFocus` 인
|
|
48
|
+
* 호스트(`u-button` · `u-icon-button` — `focus()` 를 플랫폼이 안쪽으로 넘긴다) · `tabindex` 를 가진 요소이고,
|
|
48
49
|
* 비활성·`inert`·안 보임이 아니어야 한다. 걸러진 호스트는 그 안쪽(섀도 루트)에서 계속 찾는다.
|
|
49
50
|
* `u-select` 의 섀도에는 속성 `autofocus` 를 가진 닫힌 `u-popover` 가 늘 있다 — 이것을 집으면
|
|
50
51
|
* 포커스가 아무 데도 가지 않는다.
|
|
@@ -52,7 +53,7 @@ function isCoarsePointer(event) {
|
|
|
52
53
|
function isFocusCandidate(el) {
|
|
53
54
|
if (!(el instanceof HTMLElement)) return false;
|
|
54
55
|
const native = el.matches("input:not([type=\"hidden\"]), select, textarea, button, a[href], [contenteditable=\"\"], [contenteditable=\"true\"]");
|
|
55
|
-
const forwards = el.focus !== HTMLElement.prototype.focus;
|
|
56
|
+
const forwards = el.focus !== HTMLElement.prototype.focus || el.shadowRoot?.delegatesFocus === true;
|
|
56
57
|
if (!native && !forwards && !el.hasAttribute("tabindex")) return false;
|
|
57
58
|
if (el.matches(":disabled") || el.hasAttribute("disabled") || el.closest("[inert]")) return false;
|
|
58
59
|
return typeof el.checkVisibility === "function" ? el.checkVisibility() : true;
|
package/package.json
CHANGED
|
@@ -83,12 +83,38 @@ because their name normally comes from their own content:
|
|
|
83
83
|
| Property | Type | Default | Reflect | Description |
|
|
84
84
|
|----------|------|---------|---------|-------------|
|
|
85
85
|
| `label` | `string` | — | — | Label text |
|
|
86
|
-
| `description` | `string` | — | — | Helper text
|
|
86
|
+
| `description` | `string` | — | — | Helper text — below the control, or in a tooltip beside the label (see `descriptionDisplay`) |
|
|
87
|
+
| `descriptionDisplay` | `'inline' \| 'hint'` | — | — | Where the description shows: `inline` (under the control) or `hint` (info icon beside the label, text on hover). Unset follows `UField.descriptionDisplay` |
|
|
87
88
|
| `validationMessage` | `string` | — | — | Error message shown when `invalid` |
|
|
88
89
|
| `required` | `boolean` | `false` | ✓ | Show the required marker and make the slotted control required (a single control — with several controls the field only shows the marker). Turning it off removes only the `required` the field set |
|
|
89
90
|
| `invalid` | `boolean` | `false` | ✓ | Show validation error state |
|
|
90
91
|
| `disabled` | `boolean` | `false` | ✓ | Disable state forwarding |
|
|
91
92
|
|
|
93
|
+
## App-wide description display
|
|
94
|
+
|
|
95
|
+
```ts
|
|
96
|
+
import { UField } from '@iyulab/components';
|
|
97
|
+
|
|
98
|
+
UField.descriptionDisplay = 'hint'; // once, before the first render — default 'inline'
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
Sets where every field shows its description, including the fields that `u-input`, `u-select` and the other controls
|
|
102
|
+
render inside their own shadow roots. A field's own `description-display` wins. In `hint` mode a validation message
|
|
103
|
+
still shows under the control, the control keeps the text as `aria-description`, and a field without a label shows the
|
|
104
|
+
description inline (there is no label to put the icon beside).
|
|
105
|
+
|
|
106
|
+
The hint opens three ways — hovering the icon, entering the field's control from the keyboard (Tab, or a programmatic
|
|
107
|
+
`focus()`; a click into the control does not, the mouse has hover), and tapping the icon (touch has no hover; the tap
|
|
108
|
+
pins it until a tap elsewhere or a second tap). Escape closes it, and so does focus leaving the field. The icon itself
|
|
109
|
+
is not a Tab stop — a form of dozens of fields would otherwise double its Tabs.
|
|
110
|
+
|
|
111
|
+
## CSS Parts
|
|
112
|
+
|
|
113
|
+
| Part | Description |
|
|
114
|
+
|------|-------------|
|
|
115
|
+
| `hint` | The info icon beside the label (`description-display="hint"`) |
|
|
116
|
+
| `hint-tooltip` | The tooltip that holds the description |
|
|
117
|
+
|
|
92
118
|
## Methods
|
|
93
119
|
|
|
94
120
|
| Method | Description |
|
|
@@ -44,6 +44,7 @@ Selectable option item. Used inside `u-select`, `u-radio`, and `u-input` (combob
|
|
|
44
44
|
| `value` | `string` | `''` | — | Submitted value |
|
|
45
45
|
| `disabled` | `boolean` | `false` | ✓ | Disable the option |
|
|
46
46
|
| `selected` | `boolean` | `false` | ✓ | Selected state |
|
|
47
|
+
| `active` | `boolean` | `false` | ✓ | The candidate `Enter` picks from the owning `u-select`'s search field — shown like a hovered option. Set by the select; not meant to be set by hand |
|
|
47
48
|
| `marker` | `'radio'\|'check'` | — | ✓ | Show leading marker icon |
|
|
48
49
|
|
|
49
50
|
## Methods
|
|
@@ -78,7 +78,10 @@ Dropdown select with single or multiple selection, search, and clear support. Fo
|
|
|
78
78
|
The trigger is a `role="combobox"`. Without `searchable` the dropdown holds a `role="listbox"`
|
|
79
79
|
and opening it focuses the first option. With `searchable` the dropdown is a `role="dialog"`
|
|
80
80
|
(named by `label`, or "Search") that holds the search field and the listbox; opening it focuses
|
|
81
|
-
the search field, so typing filters at once.
|
|
81
|
+
the search field, so typing filters at once. While there is a query, the first visible option is the
|
|
82
|
+
**active candidate** — shown like a hovered option and announced through the search field's
|
|
83
|
+
`aria-activedescendant` — and `Enter` picks it (closing the list, or toggling it with `multiple`); the
|
|
84
|
+
`Enter` that commits an IME composition does not. From the search field `ArrowDown`/`ArrowUp` move to
|
|
82
85
|
the first/last visible option; on an option, arrows, `Home`/`End`, `Enter`/`Space` (select) and
|
|
83
86
|
`Escape` (close) work as usual.
|
|
84
87
|
|
|
@@ -6,7 +6,7 @@ import '@iyulab/components/dist/components/tooltip/UTooltip.js';
|
|
|
6
6
|
|
|
7
7
|
**Tag:** `u-tooltip`
|
|
8
8
|
|
|
9
|
-
Hover/focus tooltip anchored to a `for` target. Opens and closes automatically.
|
|
9
|
+
Hover/focus tooltip anchored to a `for` target. Opens and closes automatically; Escape closes an open tooltip without moving the pointer or focus (WCAG 1.4.13) — inside a dialog, the first Escape closes the tooltip and the next one the dialog.
|
|
10
10
|
|
|
11
11
|
```html
|
|
12
12
|
<u-button id="save-btn">Save</u-button>
|