@iyulab/components 2.33.0 → 2.34.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 +39 -0
- package/dist/components/auto-scroll/UAutoScroll.d.ts +14 -0
- package/dist/components/auto-scroll/UAutoScroll.js +25 -2
- package/dist/components/badge/UBadge.d.ts +2 -0
- package/dist/components/badge/UBadge.js +4 -2
- package/dist/components/badge/UBadge.styles.js +11 -2
- package/dist/components/breadcrumb-item/UBreadcrumbItem.d.ts +2 -0
- package/dist/components/breadcrumb-item/UBreadcrumbItem.js +6 -4
- package/dist/components/breadcrumb-item/UBreadcrumbItem.styles.js +11 -2
- package/dist/components/button/UButton.d.ts +2 -0
- package/dist/components/button/UButton.js +4 -2
- package/dist/components/button/UButton.styles.js +11 -2
- package/dist/components/carousel/UCarousel.d.ts +23 -1
- package/dist/components/carousel/UCarousel.js +64 -5
- package/dist/components/dialog/UDialog.d.ts +3 -0
- package/dist/components/dialog/UDialog.js +8 -1
- package/dist/components/dialog/UDialog.styles.js +10 -3
- package/dist/components/drawer/UDrawer.d.ts +3 -0
- package/dist/components/drawer/UDrawer.js +8 -1
- package/dist/components/drawer/UDrawer.styles.js +10 -3
- package/dist/components/input/UInput.d.ts +2 -0
- package/dist/components/input/UInput.js +4 -2
- package/dist/components/input/UInput.styles.js +11 -2
- package/dist/components/menu-item/UMenuItem.d.ts +2 -0
- package/dist/components/menu-item/UMenuItem.js +4 -2
- package/dist/components/menu-item/UMenuItem.styles.js +11 -2
- package/dist/components/option/UOption.d.ts +2 -0
- package/dist/components/option/UOption.js +4 -2
- package/dist/components/option/UOption.styles.js +16 -2
- package/dist/components/radio/URadio.styles.js +5 -2
- package/dist/components/select/USelect.d.ts +21 -2
- package/dist/components/select/USelect.js +144 -41
- package/dist/components/select/USelect.styles.js +60 -22
- package/dist/components/tab/UTab.d.ts +2 -0
- package/dist/components/tab/UTab.js +4 -2
- package/dist/components/tab/UTab.styles.js +16 -2
- package/dist/components/tab-panel/UTabPanel.styles.js +14 -14
- package/dist/components/tree-item/UTreeItem.d.ts +2 -0
- package/dist/components/tree-item/UTreeItem.js +4 -2
- package/dist/components/tree-item/UTreeItem.styles.js +11 -2
- package/dist/utilities/slotPresence.d.ts +21 -0
- package/dist/utilities/slotPresence.js +41 -0
- package/dist/utilities/unattended.d.ts +5 -0
- package/dist/utilities/unattended.js +7 -0
- package/package.json +1 -1
- package/skills/iyulab-components/references/components/auto-scroll.md +5 -0
- package/skills/iyulab-components/references/components/carousel.md +19 -1
- package/skills/iyulab-components/references/components/dialog.md +1 -0
- package/skills/iyulab-components/references/components/drawer.md +1 -0
- package/skills/iyulab-components/references/components/select.md +16 -11
|
@@ -14,6 +14,7 @@ var UDrawer = class UDrawer extends UOverlayElement {
|
|
|
14
14
|
this.closable = false;
|
|
15
15
|
this.placement = "left";
|
|
16
16
|
this.hasHeader = false;
|
|
17
|
+
this.hasFooter = false;
|
|
17
18
|
}
|
|
18
19
|
static {
|
|
19
20
|
this.styles = [super.styles, styles];
|
|
@@ -35,10 +36,15 @@ var UDrawer = class UDrawer extends UOverlayElement {
|
|
|
35
36
|
<div class="body" part="body">
|
|
36
37
|
<slot></slot>
|
|
37
38
|
</div>
|
|
38
|
-
<
|
|
39
|
+
<div class="footer" part="footer" ?hidden=${!this.hasFooter}>
|
|
40
|
+
<slot name="footer" @slotchange=${this.handleFooterSlotChange}></slot>
|
|
41
|
+
</div>
|
|
39
42
|
</div>
|
|
40
43
|
`;
|
|
41
44
|
}
|
|
45
|
+
handleFooterSlotChange(e) {
|
|
46
|
+
this.hasFooter = e.target.assignedNodes({ flatten: true }).length > 0;
|
|
47
|
+
}
|
|
42
48
|
handleHeaderSlotChange(e) {
|
|
43
49
|
const slot = e.target;
|
|
44
50
|
this.hasHeader = slot.assignedNodes({ flatten: true }).length > 0;
|
|
@@ -54,5 +60,6 @@ __decorate([property({
|
|
|
54
60
|
reflect: true
|
|
55
61
|
}), __decorateMetadata("design:type", Object)], UDrawer.prototype, "placement", void 0);
|
|
56
62
|
__decorate([state(), __decorateMetadata("design:type", Object)], UDrawer.prototype, "hasHeader", void 0);
|
|
63
|
+
__decorate([state(), __decorateMetadata("design:type", Object)], UDrawer.prototype, "hasFooter", void 0);
|
|
57
64
|
UDrawer = __decorate([customElement("u-drawer")], UDrawer);
|
|
58
65
|
export { UDrawer };
|
|
@@ -97,14 +97,21 @@ var styles = css`
|
|
|
97
97
|
overflow: auto;
|
|
98
98
|
}
|
|
99
99
|
|
|
100
|
-
|
|
100
|
+
|
|
101
|
+
|
|
102
|
+
.footer {
|
|
101
103
|
flex-shrink: 0;
|
|
104
|
+
padding: var(--u-space-md, 12px) var(--u-space-lg, 16px);
|
|
105
|
+
border-top: 1px solid var(--u-border-color, #E0E0E0);
|
|
106
|
+
}
|
|
107
|
+
.footer[hidden] {
|
|
108
|
+
display: none;
|
|
109
|
+
}
|
|
110
|
+
::slotted([slot="footer"]) {
|
|
102
111
|
display: flex;
|
|
103
112
|
align-items: center;
|
|
104
113
|
justify-content: flex-end;
|
|
105
114
|
gap: var(--u-space-sm, 8px);
|
|
106
|
-
padding: var(--u-space-md, 12px) var(--u-space-lg, 16px);
|
|
107
|
-
border-top: 1px solid var(--u-border-color, #E0E0E0);
|
|
108
115
|
}
|
|
109
116
|
`;
|
|
110
117
|
export { styles };
|
|
@@ -52,6 +52,8 @@ export type FieldSize = 'sm' | 'md' | 'lg';
|
|
|
52
52
|
*/
|
|
53
53
|
export declare class UInput extends UFormControlElement<string> {
|
|
54
54
|
static styles: import('lit').CSSResultGroup[];
|
|
55
|
+
/** 접두 · 접미 슬롯이 찼는가 — 그 옆 간격은 섀도 안 상자가 갖는다(`::slotted` 여백은 문서의 전역 리셋에 진다). */
|
|
56
|
+
private readonly affixes;
|
|
55
57
|
/** 외형 정도 */
|
|
56
58
|
appearance: FieldAppearance;
|
|
57
59
|
/** 전체 지우기 버튼 표시 여부 */
|
|
@@ -4,6 +4,7 @@ import __decorate from "../../_virtual/_@oxc-project_runtime@0.155.0/helpers/esm
|
|
|
4
4
|
import { UFormControlElement } from "../UFormControlElement.js";
|
|
5
5
|
import { isImeComposing } from "../../utilities/keyboard.js";
|
|
6
6
|
import "../spinner/USpinner.js";
|
|
7
|
+
import { SlotPresence } from "../../utilities/slotPresence.js";
|
|
7
8
|
import "../icon/UIcon.js";
|
|
8
9
|
import { parseNumber } from "../../utilities/format.js";
|
|
9
10
|
import "../field/UField.js";
|
|
@@ -19,6 +20,7 @@ import { live } from "lit/directives/live.js";
|
|
|
19
20
|
var UInput = class UInput extends UFormControlElement {
|
|
20
21
|
constructor(..._args) {
|
|
21
22
|
super(..._args);
|
|
23
|
+
this.affixes = new SlotPresence(this, ["prefix", "suffix"]);
|
|
22
24
|
this.appearance = "outlined";
|
|
23
25
|
this.clearable = false;
|
|
24
26
|
this.type = "text";
|
|
@@ -205,7 +207,7 @@ var UInput = class UInput extends UFormControlElement {
|
|
|
205
207
|
<div class="container" part="container"
|
|
206
208
|
style=${`--_icons: ${(showStepper ? 2 : 0) + (showClear ? 1 : 0) + (showToggle ? 1 : 0)}${this.charsWidth.width ? `; --input-min-text: ${this.charsWidth.width}` : ""}`}>
|
|
207
209
|
|
|
208
|
-
<slot name="prefix"></slot>
|
|
210
|
+
<span class="affix affix-prefix" ?hidden=${!this.affixes.has("prefix")}><slot name="prefix"></slot></span>
|
|
209
211
|
|
|
210
212
|
<input part="input"
|
|
211
213
|
style=${ifDefined(this.charsWidth.width ? `inline-size: ${this.charsWidth.width}` : void 0)}
|
|
@@ -240,7 +242,7 @@ var UInput = class UInput extends UFormControlElement {
|
|
|
240
242
|
@compositionend=${this.handleCompositionEnd}
|
|
241
243
|
/>
|
|
242
244
|
|
|
243
|
-
<slot name="suffix"></slot>
|
|
245
|
+
<span class="affix affix-suffix" ?hidden=${!this.affixes.has("suffix")}><slot name="suffix"></slot></span>
|
|
244
246
|
|
|
245
247
|
<u-icon class="suffix-item"
|
|
246
248
|
?hidden=${!showToggle}
|
|
@@ -173,10 +173,19 @@ var styles = css`
|
|
|
173
173
|
}
|
|
174
174
|
|
|
175
175
|
|
|
176
|
-
|
|
176
|
+
|
|
177
|
+
.affix {
|
|
178
|
+
display: inline-flex;
|
|
179
|
+
align-items: center;
|
|
180
|
+
flex: none;
|
|
181
|
+
}
|
|
182
|
+
.affix[hidden] {
|
|
183
|
+
display: none;
|
|
184
|
+
}
|
|
185
|
+
.affix-prefix {
|
|
177
186
|
margin-right: 0.25em;
|
|
178
187
|
}
|
|
179
|
-
|
|
188
|
+
.affix-suffix {
|
|
180
189
|
margin-left: 0.25em;
|
|
181
190
|
}
|
|
182
191
|
|
|
@@ -21,6 +21,8 @@ export type MenuItemAlign = 'left' | 'center' | 'right';
|
|
|
21
21
|
*/
|
|
22
22
|
export declare class UMenuItem extends UElement {
|
|
23
23
|
static styles: import('lit').CSSResultGroup[];
|
|
24
|
+
/** 접두 · 접미 슬롯이 찼는가 — 그 옆 간격은 섀도 안 상자가 갖는다(`::slotted` 여백은 문서의 전역 리셋에 진다). */
|
|
25
|
+
private readonly affixes;
|
|
24
26
|
/** 서브메뉴 확장 여부 */
|
|
25
27
|
expanded: boolean;
|
|
26
28
|
/** 비활성화 여부 */
|
|
@@ -2,6 +2,7 @@ import { UElement } from "../UElement.js";
|
|
|
2
2
|
import __decorateMetadata from "../../_virtual/_@oxc-project_runtime@0.155.0/helpers/esm/decorateMetadata.js";
|
|
3
3
|
import __decorate from "../../_virtual/_@oxc-project_runtime@0.155.0/helpers/esm/decorate.js";
|
|
4
4
|
import { HostAria } from "../../utilities/hostAria.js";
|
|
5
|
+
import { SlotPresence } from "../../utilities/slotPresence.js";
|
|
5
6
|
import "../icon/UIcon.js";
|
|
6
7
|
import "../popover/UPopover.js";
|
|
7
8
|
import { UDivider } from "../divider/UDivider.js";
|
|
@@ -18,6 +19,7 @@ var UMenuItem = class UMenuItem extends UElement {
|
|
|
18
19
|
}
|
|
19
20
|
constructor(..._args) {
|
|
20
21
|
super(..._args);
|
|
22
|
+
this.affixes = new SlotPresence(this, ["prefix", "suffix"]);
|
|
21
23
|
this.expanded = false;
|
|
22
24
|
this.disabled = false;
|
|
23
25
|
this.selected = false;
|
|
@@ -104,11 +106,11 @@ var UMenuItem = class UMenuItem extends UElement {
|
|
|
104
106
|
name="check"
|
|
105
107
|
></u-icon>
|
|
106
108
|
|
|
107
|
-
<slot name="prefix"></slot>
|
|
109
|
+
<span class="affix affix-prefix" ?hidden=${!this.affixes.has("prefix")}><slot name="prefix"></slot></span>
|
|
108
110
|
<div class="content" part="content">
|
|
109
111
|
<slot @slotchange=${this.handleSlotChange}></slot>
|
|
110
112
|
</div>
|
|
111
|
-
<slot name="suffix"></slot>
|
|
113
|
+
<span class="affix affix-suffix" ?hidden=${!this.affixes.has("suffix")}><slot name="suffix"></slot></span>
|
|
112
114
|
|
|
113
115
|
${this.inline ? html`
|
|
114
116
|
<span class="suffix-toggler"
|
|
@@ -110,10 +110,19 @@ var styles = css`
|
|
|
110
110
|
margin-left: 0.25em;
|
|
111
111
|
}
|
|
112
112
|
|
|
113
|
-
|
|
113
|
+
|
|
114
|
+
.affix {
|
|
115
|
+
display: inline-flex;
|
|
116
|
+
align-items: center;
|
|
117
|
+
flex: none;
|
|
118
|
+
}
|
|
119
|
+
.affix[hidden] {
|
|
120
|
+
display: none;
|
|
121
|
+
}
|
|
122
|
+
.affix-prefix {
|
|
114
123
|
margin-right: 0.25em;
|
|
115
124
|
}
|
|
116
|
-
|
|
125
|
+
.affix-suffix {
|
|
117
126
|
margin-left: 0.25em;
|
|
118
127
|
}
|
|
119
128
|
|
|
@@ -30,6 +30,8 @@ export type OptionMarker = 'radio' | 'check';
|
|
|
30
30
|
*/
|
|
31
31
|
export declare class UOption extends UElement {
|
|
32
32
|
static styles: import('lit').CSSResultGroup[];
|
|
33
|
+
/** 접두 · 접미 슬롯이 찼는가 — 그 옆 간격은 섀도 안 상자가 갖는다(`::slotted` 여백은 문서의 전역 리셋에 진다). */
|
|
34
|
+
private readonly affixes;
|
|
33
35
|
/** 비활성화 여부 */
|
|
34
36
|
disabled: boolean;
|
|
35
37
|
/** 선택 여부 */
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { UElement } from "../UElement.js";
|
|
2
2
|
import __decorateMetadata from "../../_virtual/_@oxc-project_runtime@0.155.0/helpers/esm/decorateMetadata.js";
|
|
3
3
|
import __decorate from "../../_virtual/_@oxc-project_runtime@0.155.0/helpers/esm/decorate.js";
|
|
4
|
+
import { SlotPresence } from "../../utilities/slotPresence.js";
|
|
4
5
|
import "../icon/UIcon.js";
|
|
5
6
|
import { styles } from "./UOption.styles.js";
|
|
6
7
|
import { html, nothing } from "lit";
|
|
@@ -9,6 +10,7 @@ import { customElement, property } from "lit/decorators.js";
|
|
|
9
10
|
var UOption = class UOption extends UElement {
|
|
10
11
|
constructor(..._args) {
|
|
11
12
|
super(..._args);
|
|
13
|
+
this.affixes = new SlotPresence(this, ["prefix", "suffix"]);
|
|
12
14
|
this.disabled = false;
|
|
13
15
|
this.selected = false;
|
|
14
16
|
this.active = false;
|
|
@@ -38,11 +40,11 @@ var UOption = class UOption extends UElement {
|
|
|
38
40
|
return html`
|
|
39
41
|
<div class="base" part="base">
|
|
40
42
|
${this.renderMarker()}
|
|
41
|
-
<slot name="prefix"></slot>
|
|
43
|
+
<span class="affix affix-prefix" ?hidden=${!this.affixes.has("prefix")}><slot name="prefix"></slot></span>
|
|
42
44
|
<div class="content" part="content">
|
|
43
45
|
<slot></slot>
|
|
44
46
|
</div>
|
|
45
|
-
<slot name="suffix"></slot>
|
|
47
|
+
<span class="affix affix-suffix" ?hidden=${!this.affixes.has("suffix")}><slot name="suffix"></slot></span>
|
|
46
48
|
</div>
|
|
47
49
|
`;
|
|
48
50
|
}
|
|
@@ -37,6 +37,11 @@ var styles = css`
|
|
|
37
37
|
|
|
38
38
|
min-height: var(--u-target-size, 0px);
|
|
39
39
|
border-radius: inherit;
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
border-style: solid;
|
|
43
|
+
border-width: var(--_option-divider-width, 0);
|
|
44
|
+
border-color: var(--_option-divider-color, transparent);
|
|
40
45
|
}
|
|
41
46
|
:host(:focus-visible) {
|
|
42
47
|
outline: none;
|
|
@@ -144,10 +149,19 @@ var styles = css`
|
|
|
144
149
|
color: var(--option-color-active);
|
|
145
150
|
}
|
|
146
151
|
|
|
147
|
-
|
|
152
|
+
|
|
153
|
+
.affix {
|
|
154
|
+
display: inline-flex;
|
|
155
|
+
align-items: center;
|
|
156
|
+
flex: none;
|
|
157
|
+
}
|
|
158
|
+
.affix[hidden] {
|
|
159
|
+
display: none;
|
|
160
|
+
}
|
|
161
|
+
.affix-prefix {
|
|
148
162
|
margin-right: 0.25em;
|
|
149
163
|
}
|
|
150
|
-
|
|
164
|
+
.affix-suffix {
|
|
151
165
|
margin-left: 0.25em;
|
|
152
166
|
}
|
|
153
167
|
`;
|
|
@@ -93,8 +93,10 @@ var styles = css`
|
|
|
93
93
|
:host([type="button"]:not([appearance="soft"])[orientation="horizontal"]) ::slotted(u-option:last-child) {
|
|
94
94
|
border-radius: 0 0.35em 0.35em 0;
|
|
95
95
|
}
|
|
96
|
+
|
|
96
97
|
:host([type="button"]:not([appearance="soft"])[orientation="horizontal"]) ::slotted(u-option:not(:last-child)) {
|
|
97
|
-
|
|
98
|
+
--_option-divider-width: 0 1px 0 0;
|
|
99
|
+
--_option-divider-color: var(--u-neutral-300, #E0E0E0);
|
|
98
100
|
}
|
|
99
101
|
|
|
100
102
|
|
|
@@ -109,7 +111,8 @@ var styles = css`
|
|
|
109
111
|
border-radius: 0 0 0.35em 0.35em;
|
|
110
112
|
}
|
|
111
113
|
:host([type="button"]:not([appearance="soft"])[orientation="vertical"]) ::slotted(u-option:not(:last-child)) {
|
|
112
|
-
|
|
114
|
+
--_option-divider-width: 0 0 1px 0;
|
|
115
|
+
--_option-divider-color: var(--u-neutral-300, #E0E0E0);
|
|
113
116
|
}
|
|
114
117
|
|
|
115
118
|
|
|
@@ -19,7 +19,7 @@ import { UPopover } from '../popover/UPopover.js';
|
|
|
19
19
|
* @csspart field - u-field 요소
|
|
20
20
|
* @csspart container - 트리거 영역을 감싸는 요소
|
|
21
21
|
* @csspart popover - 옵션 목록이 표시되는 팝오버 요소
|
|
22
|
-
* @csspart search-input - 검색 입력
|
|
22
|
+
* @csspart search-input - 검색 가능일 때 트리거 안의 검색 입력(콤보박스 자신)
|
|
23
23
|
* @csspart no-matches - 검색어에 맞는 옵션이 없을 때의 «일치하는 항목 없음» 상태 줄
|
|
24
24
|
*
|
|
25
25
|
* @cssprop --u-select-display - 호스트의 display (기본값: inline-block). 폼/그리드 셀에서
|
|
@@ -41,6 +41,8 @@ import { UPopover } from '../popover/UPopover.js';
|
|
|
41
41
|
*/
|
|
42
42
|
export declare class USelect extends UFormControlElement<string | string[]> {
|
|
43
43
|
static styles: import('lit').CSSResultGroup[];
|
|
44
|
+
/** 접두 · 접미 슬롯이 찼는가 — 그 옆 간격은 섀도 안 상자가 갖는다(`::slotted` 여백은 문서의 전역 리셋에 진다). */
|
|
45
|
+
private readonly affixes;
|
|
44
46
|
/** 트리거 영역의 스타일 변형 */
|
|
45
47
|
/** 외형 정도 */
|
|
46
48
|
appearance: FieldAppearance;
|
|
@@ -96,7 +98,11 @@ export declare class USelect extends UFormControlElement<string | string[]> {
|
|
|
96
98
|
private noMatches;
|
|
97
99
|
/** aria-expanded 배선용 팝오버 열림 상태 */
|
|
98
100
|
private open;
|
|
99
|
-
/**
|
|
101
|
+
/** 트리거의 검색 입력에 글자가 있다(조합 중 포함) — 선택값 표시를 가리고 친 글자를 보인다. */
|
|
102
|
+
private typing;
|
|
103
|
+
/** 검색 불가 트리거의 type-ahead 버퍼 — APG select-only: 첫 글자들로 옵션을 찾는다(짧은 간격의 연속 입력은 이어 붙인다). */
|
|
104
|
+
private typeahead;
|
|
105
|
+
/** 팝업 · listbox 의 고유 id — 콤보박스(검색 불가면 트리거, 검색 가능이면 트리거 안 입력)의 aria-controls 가 listbox 를 가리킨다. */
|
|
100
106
|
private readonly idBase;
|
|
101
107
|
private readonly listboxId;
|
|
102
108
|
private readonly popupId;
|
|
@@ -138,6 +144,19 @@ export declare class USelect extends UFormControlElement<string | string[]> {
|
|
|
138
144
|
* 바깥 클릭으로 닫힐 때는 포커스가 이미 다른 곳에 있으므로 건드리지 않는다.
|
|
139
145
|
*/
|
|
140
146
|
private handlePopoverHide;
|
|
147
|
+
/** 검색 가능일 때 목록을 연다(여닫기는 이 요소가 한다 — 팝오버는 `trigger="manual"`). */
|
|
148
|
+
private openPopup;
|
|
149
|
+
/** 트리거를 누르면 — 검색 가능이면 입력에 포커스를 두고 여닫는다(열린 채 입력을 눌러 캐럿을 옮기는 것은 닫지 않는다). */
|
|
150
|
+
private handleContainerClick;
|
|
151
|
+
/** 조합이 시작되면 연다 — 첫 음절부터 검색어다. */
|
|
152
|
+
private handleCompositionStart;
|
|
153
|
+
/**
|
|
154
|
+
* 검색 불가 트리거의 type-ahead(APG select-only combobox · 네이티브 select). 인쇄 가능한 글자 — 닫혀 있으면 그 글자로
|
|
155
|
+
* 시작하는 다음 옵션을 바로 고르고(값 바뀜 → change), 열려 있으면 그 옵션으로 포커스를 옮긴다. 같은 글자를 거듭 치면
|
|
156
|
+
* 그 글자로 시작하는 옵션을 돈다. 여러 글자는 짧은 간격(0.5초) 안에 이어 친 것만 한 낱말이다.
|
|
157
|
+
*/
|
|
158
|
+
private handleTriggerKeydown;
|
|
159
|
+
private typeAhead;
|
|
141
160
|
private handleOptionClick;
|
|
142
161
|
private handleOptionKeydown;
|
|
143
162
|
/**
|
|
@@ -4,6 +4,7 @@ import __decorate from "../../_virtual/_@oxc-project_runtime@0.155.0/helpers/esm
|
|
|
4
4
|
import { UFormControlElement } from "../UFormControlElement.js";
|
|
5
5
|
import { isImeComposing } from "../../utilities/keyboard.js";
|
|
6
6
|
import "../spinner/USpinner.js";
|
|
7
|
+
import { SlotPresence } from "../../utilities/slotPresence.js";
|
|
7
8
|
import "../icon/UIcon.js";
|
|
8
9
|
import "../chip/UChip.js";
|
|
9
10
|
import "../field/UField.js";
|
|
@@ -12,13 +13,14 @@ import { CharsWidthController } from "../../utilities/chars.js";
|
|
|
12
13
|
import { UOptionGroup, collectOptions } from "../option-group/UOptionGroup.js";
|
|
13
14
|
import { CompositionTracker } from "../../utilities/composition.js";
|
|
14
15
|
import { styles } from "./USelect.styles.js";
|
|
15
|
-
import { html } from "lit";
|
|
16
|
+
import { html, nothing } from "lit";
|
|
16
17
|
import { customElement, property, query, state } from "lit/decorators.js";
|
|
17
18
|
import { ifDefined } from "lit/directives/if-defined.js";
|
|
18
19
|
// src/components/select/USelect.ts
|
|
19
20
|
var USelect = class USelect extends UFormControlElement {
|
|
20
21
|
constructor(..._args) {
|
|
21
22
|
super(..._args);
|
|
23
|
+
this.affixes = new SlotPresence(this, ["prefix", "suffix"]);
|
|
22
24
|
this.appearance = "outlined";
|
|
23
25
|
this.size = "md";
|
|
24
26
|
this.charsWidth = new CharsWidthController(this, {
|
|
@@ -36,6 +38,11 @@ var USelect = class USelect extends UFormControlElement {
|
|
|
36
38
|
this.queryComposing = false;
|
|
37
39
|
this.noMatches = false;
|
|
38
40
|
this.open = false;
|
|
41
|
+
this.typing = false;
|
|
42
|
+
this.typeahead = {
|
|
43
|
+
text: "",
|
|
44
|
+
at: 0
|
|
45
|
+
};
|
|
39
46
|
this.idBase = `u-select-${Math.random().toString(36).slice(2, 8)}`;
|
|
40
47
|
this.listboxId = `${this.idBase}-listbox`;
|
|
41
48
|
this.popupId = `${this.idBase}-popup`;
|
|
@@ -46,7 +53,29 @@ var USelect = class USelect extends UFormControlElement {
|
|
|
46
53
|
this.handlePopoverHide = () => {
|
|
47
54
|
this.open = false;
|
|
48
55
|
this.setActiveOption(void 0);
|
|
49
|
-
if (this.popoverEl?.matches(":focus-within")) this.
|
|
56
|
+
if (this.popoverEl?.matches(":focus-within")) this.focus();
|
|
57
|
+
const input = this.searchInputEl;
|
|
58
|
+
if (this.searchable && input && input.value) {
|
|
59
|
+
input.value = "";
|
|
60
|
+
this.updateSearch(input);
|
|
61
|
+
}
|
|
62
|
+
};
|
|
63
|
+
this.handleContainerClick = (e) => {
|
|
64
|
+
if (!this.searchable || this.effectivelyDisabled || this.readonly) return;
|
|
65
|
+
const input = this.searchInputEl;
|
|
66
|
+
if (!input) return;
|
|
67
|
+
if (this.shadowRoot?.activeElement !== input) input.focus();
|
|
68
|
+
if (!this.open) this.openPopup();
|
|
69
|
+
else if (!e.composedPath().includes(input)) this.popoverEl?.hide();
|
|
70
|
+
};
|
|
71
|
+
this.handleCompositionStart = (e) => {
|
|
72
|
+
this.composition.handleEvent(e);
|
|
73
|
+
this.typing = true;
|
|
74
|
+
this.openPopup();
|
|
75
|
+
};
|
|
76
|
+
this.handleTriggerKeydown = (e) => {
|
|
77
|
+
if (this.searchable || e.target !== this.containerEl) return;
|
|
78
|
+
this.typeAhead(e);
|
|
50
79
|
};
|
|
51
80
|
this.handleOptionClick = (e) => {
|
|
52
81
|
const option = e.currentTarget;
|
|
@@ -71,6 +100,13 @@ var USelect = class USelect extends UFormControlElement {
|
|
|
71
100
|
const currentOption = e.currentTarget;
|
|
72
101
|
const currentIndex = options.indexOf(currentOption);
|
|
73
102
|
if (currentIndex === -1) return;
|
|
103
|
+
if (!e.ctrlKey && !e.metaKey && !e.altKey && e.key.length === 1 && !(e.key === " " && !this.typeahead.text)) {
|
|
104
|
+
if (this.searchable) {
|
|
105
|
+
this.searchInputEl?.focus();
|
|
106
|
+
return;
|
|
107
|
+
}
|
|
108
|
+
if (this.typeAhead(e)) return;
|
|
109
|
+
}
|
|
74
110
|
switch (e.key) {
|
|
75
111
|
case "Enter":
|
|
76
112
|
case " ":
|
|
@@ -103,9 +139,25 @@ var USelect = class USelect extends UFormControlElement {
|
|
|
103
139
|
this.updateSearch(e.target);
|
|
104
140
|
};
|
|
105
141
|
this.handleSearchKeydown = (e) => {
|
|
106
|
-
if (e.key === "Enter" && !isImeComposing(e)
|
|
107
|
-
|
|
108
|
-
|
|
142
|
+
if (e.key === "Enter" && !isImeComposing(e)) {
|
|
143
|
+
if (this.open && this.activeOption) {
|
|
144
|
+
e.preventDefault();
|
|
145
|
+
this.activeOption.click();
|
|
146
|
+
} else if (!this.open) {
|
|
147
|
+
e.preventDefault();
|
|
148
|
+
this.openPopup();
|
|
149
|
+
}
|
|
150
|
+
return;
|
|
151
|
+
}
|
|
152
|
+
if (!this.open) {
|
|
153
|
+
if (e.key === "ArrowDown" || e.key === "ArrowUp") {
|
|
154
|
+
e.preventDefault();
|
|
155
|
+
this.openPopup();
|
|
156
|
+
} else if (e.key === "Escape" && e.target.value) {
|
|
157
|
+
e.preventDefault();
|
|
158
|
+
e.target.value = "";
|
|
159
|
+
this.updateSearch(e.target);
|
|
160
|
+
}
|
|
109
161
|
return;
|
|
110
162
|
}
|
|
111
163
|
const options = this.options.filter((o) => !o.hidden && !o.disabled);
|
|
@@ -129,7 +181,10 @@ var USelect = class USelect extends UFormControlElement {
|
|
|
129
181
|
e.stopPropagation();
|
|
130
182
|
this.reset();
|
|
131
183
|
this.emitChange();
|
|
132
|
-
this.
|
|
184
|
+
if (this.searchable) {
|
|
185
|
+
this.searchInputEl?.focus();
|
|
186
|
+
this.openPopup();
|
|
187
|
+
} else this.containerEl?.click();
|
|
133
188
|
};
|
|
134
189
|
this.handleClearKeydown = (e) => {
|
|
135
190
|
if (e.key !== "Enter" && e.key !== " ") return;
|
|
@@ -199,18 +254,45 @@ var USelect = class USelect extends UFormControlElement {
|
|
|
199
254
|
${this.valueAsArray.length} / ${this.maxCount}
|
|
200
255
|
</span>
|
|
201
256
|
|
|
202
|
-
|
|
257
|
+
<!-- 검색 가능이면 콤보박스는 트리거 안의 입력이다(APG «editable combobox with list autocomplete») — 포커스가
|
|
258
|
+
처음부터 편집 칸에 있어야 닫힌 채 친 글자(한글 조합의 첫 음절까지)가 검색어가 된다. 편집할 수 없는 칸에서는
|
|
259
|
+
입력기가 조합을 시작하지 못한다. 검색 불가면 트리거 자신이 콤보박스다(APG «select-only»). -->
|
|
260
|
+
<div class="container ${this.typing ? "typing" : ""}" part="container"
|
|
261
|
+
tabindex=${ifDefined(this.searchable ? void 0 : this.effectivelyDisabled ? "-1" : "0")}
|
|
203
262
|
style=${`--_clear: ${this.clearable && this.hasValue && !this.effectivelyDisabled && !this.readonly ? 1 : 0}${chars ? `; --select-min-text: ${chars}; --_chars: ${chars}` : ""}`}
|
|
204
|
-
role
|
|
205
|
-
aria-disabled=${ifDefined(this.effectivelyDisabled ? "true" : void 0)}
|
|
206
|
-
aria-label=${ifDefined(this.resolvedAriaLabel)}
|
|
207
|
-
aria-description=${ifDefined(this.resolvedAriaDescription)}
|
|
208
|
-
aria-haspopup=${this.searchable ?
|
|
209
|
-
aria-expanded=${this.open}
|
|
210
|
-
aria-controls=${this.searchable ?
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
<slot name="
|
|
263
|
+
role=${ifDefined(this.searchable ? void 0 : "combobox")}
|
|
264
|
+
aria-disabled=${ifDefined(!this.searchable && this.effectivelyDisabled ? "true" : void 0)}
|
|
265
|
+
aria-label=${ifDefined(this.searchable ? void 0 : this.resolvedAriaLabel)}
|
|
266
|
+
aria-description=${ifDefined(this.searchable ? void 0 : this.resolvedAriaDescription)}
|
|
267
|
+
aria-haspopup=${ifDefined(this.searchable ? void 0 : "listbox")}
|
|
268
|
+
aria-expanded=${ifDefined(this.searchable ? void 0 : String(this.open))}
|
|
269
|
+
aria-controls=${ifDefined(this.searchable ? void 0 : this.listboxId)}
|
|
270
|
+
@click=${this.handleContainerClick}
|
|
271
|
+
@keydown=${this.handleTriggerKeydown}>
|
|
272
|
+
<span class="affix affix-prefix" ?hidden=${!this.affixes.has("prefix")}><slot name="prefix"></slot></span>
|
|
273
|
+
<div class="value-area">
|
|
274
|
+
<slot name="display">${this.renderContent()}</slot>
|
|
275
|
+
${this.searchable ? html`<input class="search" part="search-input"
|
|
276
|
+
type="text"
|
|
277
|
+
role="combobox"
|
|
278
|
+
autocomplete="off"
|
|
279
|
+
spellcheck="false"
|
|
280
|
+
aria-autocomplete="list"
|
|
281
|
+
aria-haspopup="listbox"
|
|
282
|
+
aria-expanded=${String(this.open)}
|
|
283
|
+
aria-controls=${this.listboxId}
|
|
284
|
+
aria-label=${this.resolvedAriaLabel || Locale.getValue("search")}
|
|
285
|
+
aria-description=${ifDefined(this.resolvedAriaDescription)}
|
|
286
|
+
?disabled=${this.effectivelyDisabled}
|
|
287
|
+
?readonly=${this.readonly}
|
|
288
|
+
@input=${this.handleSearchInput}
|
|
289
|
+
@compositionstart=${this.handleCompositionStart}
|
|
290
|
+
@compositionupdate=${this.composition}
|
|
291
|
+
@compositionend=${this.composition}
|
|
292
|
+
@keydown=${this.handleSearchKeydown}
|
|
293
|
+
/>` : nothing}
|
|
294
|
+
</div>
|
|
295
|
+
<span class="affix affix-suffix" ?hidden=${!this.affixes.has("suffix")}><slot name="suffix"></slot></span>
|
|
214
296
|
|
|
215
297
|
<u-icon class="suffix-item"
|
|
216
298
|
?hidden=${!this.clearable || !this.hasValue || this.effectivelyDisabled || this.readonly}
|
|
@@ -233,17 +315,14 @@ var USelect = class USelect extends UFormControlElement {
|
|
|
233
315
|
</div>
|
|
234
316
|
</u-field>
|
|
235
317
|
|
|
236
|
-
<!--
|
|
237
|
-
|
|
238
|
-
키보드 모델 그대로다). 검색 불가면 팝업은 역할 없는 컨테이너이고 목록만 담는다. -->
|
|
318
|
+
<!-- 팝업은 역할 없는 컨테이너이고 listbox 와 «일치 없음» 상태 줄만 담는다(listbox 는 option 과 group 만).
|
|
319
|
+
검색 가능이면 여닫기는 이 요소가 한다(trigger="manual") — 트리거 안 입력의 스페이스 · Enter 는 글자와 고르기다. -->
|
|
239
320
|
<u-popover part="popover"
|
|
240
321
|
id=${this.popupId}
|
|
241
|
-
role=${ifDefined(this.searchable ? "dialog" : void 0)}
|
|
242
|
-
aria-label=${ifDefined(this.searchable ? this.resolvedAriaLabel || Locale.getValue("search") : void 0)}
|
|
243
322
|
scrollable
|
|
244
|
-
autofocus
|
|
323
|
+
?autofocus=${!this.searchable}
|
|
245
324
|
for=".container"
|
|
246
|
-
trigger
|
|
325
|
+
trigger=${this.searchable ? "manual" : "click"}
|
|
247
326
|
@show=${() => {
|
|
248
327
|
this.open = true;
|
|
249
328
|
this.updateActiveOption();
|
|
@@ -253,20 +332,6 @@ var USelect = class USelect extends UFormControlElement {
|
|
|
253
332
|
placement="bottom-start"
|
|
254
333
|
offset="1"
|
|
255
334
|
>
|
|
256
|
-
<div class="search-input" part="search-input"
|
|
257
|
-
?hidden=${!this.searchable}>
|
|
258
|
-
<u-icon lib="internal" name="search"></u-icon>
|
|
259
|
-
<input
|
|
260
|
-
type="text"
|
|
261
|
-
aria-label=${Locale.getValue("search")}
|
|
262
|
-
aria-controls=${this.listboxId}
|
|
263
|
-
@input=${this.handleSearchInput}
|
|
264
|
-
@compositionstart=${this.composition}
|
|
265
|
-
@compositionupdate=${this.composition}
|
|
266
|
-
@compositionend=${this.composition}
|
|
267
|
-
@keydown=${this.handleSearchKeydown}
|
|
268
|
-
/>
|
|
269
|
-
</div>
|
|
270
335
|
<div class="no-matches" part="no-matches" role="status">${this.noMatches ? Locale.getValue("noMatches") : ""}</div>
|
|
271
336
|
<div class="listbox" role="listbox" id=${this.listboxId}
|
|
272
337
|
aria-multiselectable=${ifDefined(this.multiple ? "true" : void 0)}>
|
|
@@ -323,10 +388,10 @@ var USelect = class USelect extends UFormControlElement {
|
|
|
323
388
|
* 네이티브 `disabled` `<input>`에서 얻는 것과 같은 no-op을 여기서 직접 재현한다. */
|
|
324
389
|
focus(options) {
|
|
325
390
|
if (this.effectivelyDisabled) return;
|
|
326
|
-
this.containerEl?.focus(options);
|
|
391
|
+
(this.searchable ? this.searchInputEl : this.containerEl)?.focus(options);
|
|
327
392
|
}
|
|
328
393
|
blur() {
|
|
329
|
-
this.containerEl?.blur();
|
|
394
|
+
(this.searchable ? this.searchInputEl : this.containerEl)?.blur();
|
|
330
395
|
}
|
|
331
396
|
setup(options) {
|
|
332
397
|
for (const option of options) {
|
|
@@ -371,7 +436,44 @@ var USelect = class USelect extends UFormControlElement {
|
|
|
371
436
|
this.setup(this.options);
|
|
372
437
|
this.applyFilter();
|
|
373
438
|
}
|
|
439
|
+
/** 검색 가능일 때 목록을 연다(여닫기는 이 요소가 한다 — 팝오버는 `trigger="manual"`). */
|
|
440
|
+
openPopup() {
|
|
441
|
+
if (this.open || this.effectivelyDisabled || this.readonly || !this.containerEl) return;
|
|
442
|
+
this.popoverEl?.show(this.containerEl);
|
|
443
|
+
}
|
|
444
|
+
typeAhead(e) {
|
|
445
|
+
if (this.effectivelyDisabled || this.readonly) return false;
|
|
446
|
+
if (e.ctrlKey || e.metaKey || e.altKey || e.key.length !== 1 || isImeComposing(e)) return false;
|
|
447
|
+
const now = e.timeStamp || Date.now();
|
|
448
|
+
const fresh = now - this.typeahead.at > 500;
|
|
449
|
+
if (e.key === " " && (fresh || !this.typeahead.text)) return false;
|
|
450
|
+
e.preventDefault();
|
|
451
|
+
this.typeahead = {
|
|
452
|
+
text: fresh ? e.key : this.typeahead.text + e.key,
|
|
453
|
+
at: now
|
|
454
|
+
};
|
|
455
|
+
const text = this.typeahead.text.toLowerCase();
|
|
456
|
+
const repeat = [...text].every((c) => c === text[0]);
|
|
457
|
+
const needle = repeat ? text[0] : text;
|
|
458
|
+
const options = this.options.filter((o) => !o.hidden && !o.disabled);
|
|
459
|
+
if (!options.length) return true;
|
|
460
|
+
const focused = options.find((o) => o.matches(":focus"));
|
|
461
|
+
const current = focused ?? options.find((o) => o.value === this.value) ?? options.find((o) => o.selected);
|
|
462
|
+
const start = current ? options.indexOf(current) + (repeat || !focused ? 1 : 0) : 0;
|
|
463
|
+
const match = [...options.slice(start), ...options.slice(0, start)].find((o) => o.getText().trim().toLowerCase().startsWith(needle));
|
|
464
|
+
if (!match) return true;
|
|
465
|
+
if (this.open) match.focus();
|
|
466
|
+
else if (!this.multiple) {
|
|
467
|
+
if (match.value !== this.value) {
|
|
468
|
+
this.value = match.value;
|
|
469
|
+
this.emitChange();
|
|
470
|
+
}
|
|
471
|
+
} else this.popoverEl?.show(this.containerEl).then(() => match.focus());
|
|
472
|
+
return true;
|
|
473
|
+
}
|
|
374
474
|
updateSearch(input) {
|
|
475
|
+
this.typing = input.value !== "" || this.composition.composing;
|
|
476
|
+
if (this.typing) this.openPopup();
|
|
375
477
|
const { query, composing } = this.composition.searchQuery(input);
|
|
376
478
|
this.query = query.trim();
|
|
377
479
|
this.queryComposing = composing;
|
|
@@ -418,7 +520,7 @@ var USelect = class USelect extends UFormControlElement {
|
|
|
418
520
|
if (input && "ariaActiveDescendantElement" in input) input.ariaActiveDescendantElement = option ?? null;
|
|
419
521
|
}
|
|
420
522
|
get searchInputEl() {
|
|
421
|
-
return this.shadowRoot?.querySelector(".search
|
|
523
|
+
return this.shadowRoot?.querySelector("input.search") ?? null;
|
|
422
524
|
}
|
|
423
525
|
};
|
|
424
526
|
__decorate([property({
|
|
@@ -476,5 +578,6 @@ __decorate([query("u-popover", true), __decorateMetadata("design:type", Object)]
|
|
|
476
578
|
__decorate([state(), __decorateMetadata("design:type", Array)], USelect.prototype, "options", void 0);
|
|
477
579
|
__decorate([state(), __decorateMetadata("design:type", Object)], USelect.prototype, "noMatches", void 0);
|
|
478
580
|
__decorate([state(), __decorateMetadata("design:type", Boolean)], USelect.prototype, "open", void 0);
|
|
581
|
+
__decorate([state(), __decorateMetadata("design:type", Object)], USelect.prototype, "typing", void 0);
|
|
479
582
|
USelect = __decorate([customElement("u-select")], USelect);
|
|
480
583
|
export { USelect };
|