@iyulab/components 0.1.0 → 0.1.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 +5 -0
- package/dist/assets/icons/arrow-clockwise.svg.js +3 -7
- package/dist/assets/icons/arrow-down.svg.js +3 -6
- package/dist/assets/icons/arrow-up.svg.js +3 -6
- package/dist/assets/icons/ban.svg.js +3 -6
- package/dist/assets/icons/bell-fill.svg.js +3 -6
- package/dist/assets/icons/check-circle-fill.svg.js +3 -6
- package/dist/assets/icons/check-lg.svg.js +3 -6
- package/dist/assets/icons/chevron-down.svg.js +3 -6
- package/dist/assets/icons/chevron-left.svg.js +3 -6
- package/dist/assets/icons/chevron-right.svg.js +3 -6
- package/dist/assets/icons/chevron-up.svg.js +3 -6
- package/dist/assets/icons/copy.svg.js +3 -6
- package/dist/assets/icons/dash-lg.svg.js +3 -6
- package/dist/assets/icons/exclamation-circle-fill.svg.js +3 -6
- package/dist/assets/icons/exclamation-triangle-fill.svg.js +3 -6
- package/dist/assets/icons/eye-slash.svg.js +3 -8
- package/dist/assets/icons/eye.svg.js +3 -7
- package/dist/assets/icons/info-circle-fill.svg.js +3 -6
- package/dist/assets/icons/layout-sidebar.svg.js +3 -6
- package/dist/assets/icons/lightbulb-fill.svg.js +3 -6
- package/dist/assets/icons/lightbulb-off.svg.js +3 -6
- package/dist/assets/icons/lightbulb.svg.js +3 -6
- package/dist/assets/icons/mic-fill.svg.js +3 -7
- package/dist/assets/icons/mic-mute-fill.svg.js +3 -7
- package/dist/assets/icons/paperclip.svg.js +3 -6
- package/dist/assets/icons/pencil-square.svg.js +3 -7
- package/dist/assets/icons/plus-lg.svg.js +3 -6
- package/dist/assets/icons/search.svg.js +3 -6
- package/dist/assets/icons/speedometer.svg.js +3 -7
- package/dist/assets/icons/x-lg.svg.js +3 -6
- package/dist/assets/styles/dark.css.js +3 -4
- package/dist/assets/styles/light.css.js +3 -4
- package/dist/components/BaseElement.js +32 -22
- package/dist/components/BaseElement.styles.js +5 -5
- package/dist/components/alert/Alert.js +79 -51
- package/dist/components/alert/Alert.styles.js +5 -5
- package/dist/components/button/Button.js +29 -23
- package/dist/components/button/Button.styles.js +5 -5
- package/dist/components/context-menu/ContextMenu.js +123 -72
- package/dist/components/context-menu/ContextMenu.styles.js +5 -5
- package/dist/components/dialog/Dialog.js +73 -40
- package/dist/components/dialog/Dialog.styles.js +5 -5
- package/dist/components/form/Form.js +51 -32
- package/dist/components/form/Form.styles.js +5 -5
- package/dist/components/icon/Icon.js +53 -36
- package/dist/components/icon/Icon.styles.js +5 -5
- package/dist/components/icon-button/IconButton.js +44 -36
- package/dist/components/icon-button/IconButton.styles.js +5 -5
- package/dist/components/input/Input.js +161 -112
- package/dist/components/input/Input.styles.js +5 -5
- package/dist/components/menu/Menu.js +108 -58
- package/dist/components/menu/Menu.styles.js +5 -5
- package/dist/components/menu-item/MenuItem.js +67 -37
- package/dist/components/menu-item/MenuItem.styles.js +5 -5
- package/dist/components/panel/Panel.js +11 -10
- package/dist/components/panel/Panel.styles.js +5 -5
- package/dist/components/progress-ring/ProgressRing.js +70 -45
- package/dist/components/progress-ring/ProgressRing.styles.js +5 -5
- package/dist/components/spinner/Spinner.js +9 -9
- package/dist/components/spinner/Spinner.styles.js +5 -5
- package/dist/components/split-panel/SplitPanel.js +127 -66
- package/dist/components/split-panel/SplitPanel.styles.js +5 -5
- package/dist/components/split-panel/Splitter.js +29 -23
- package/dist/components/split-panel/Splitter.styles.js +5 -5
- package/dist/components/tooltip/Tooltip.js +115 -74
- package/dist/components/tooltip/Tooltip.styles.js +5 -5
- package/dist/index.js +18 -40
- package/dist/internals/attribute-converters.js +10 -8
- package/dist/internals/icons.js +41 -66
- package/dist/internals/node-helpers.js +16 -17
- package/dist/utilities/BrowserStorage.d.ts +43 -0
- package/dist/utilities/BrowserStorage.js +87 -0
- package/dist/utilities/decorators.js +19 -14
- package/dist/utilities/index.d.ts +1 -1
- package/dist/utilities/notifier.js +62 -20
- package/dist/utilities/theme.d.ts +39 -26
- package/dist/utilities/theme.js +111 -86
- package/package.json +2 -2
- package/dist/utilities/storage.d.ts +0 -60
- package/dist/utilities/storage.js +0 -120
|
@@ -1,46 +1,85 @@
|
|
|
1
|
-
import { html
|
|
2
|
-
import { query
|
|
3
|
-
import { ifDefined
|
|
4
|
-
import { live
|
|
5
|
-
import { BaseElement
|
|
6
|
-
import { Icon
|
|
7
|
-
import { Tooltip
|
|
8
|
-
import { styles
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
1
|
+
import { html, nothing } from 'lit';
|
|
2
|
+
import { query, state, property } from 'lit/decorators.js';
|
|
3
|
+
import { ifDefined } from 'lit/directives/if-defined.js';
|
|
4
|
+
import { live } from 'lit/directives/live.js';
|
|
5
|
+
import { BaseElement } from '../BaseElement.js';
|
|
6
|
+
import { Icon } from '../icon/Icon.js';
|
|
7
|
+
import { Tooltip } from '../tooltip/Tooltip.js';
|
|
8
|
+
import { styles } from './Input.styles.js';
|
|
9
|
+
|
|
10
|
+
var __defProp = Object.defineProperty;
|
|
11
|
+
var __decorateClass = (decorators, target, key, kind) => {
|
|
12
|
+
var result = void 0 ;
|
|
13
|
+
for (var i = decorators.length - 1, decorator; i >= 0; i--)
|
|
14
|
+
if (decorator = decorators[i])
|
|
15
|
+
result = (decorator(target, key, result) ) || result;
|
|
16
|
+
if (result) __defProp(target, key, result);
|
|
17
|
+
return result;
|
|
13
18
|
};
|
|
14
|
-
class
|
|
19
|
+
class Input extends BaseElement {
|
|
15
20
|
constructor() {
|
|
16
|
-
super(...arguments)
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
21
|
+
super(...arguments);
|
|
22
|
+
this.showPassword = false;
|
|
23
|
+
this.isInvalid = false;
|
|
24
|
+
this.currentValidationMessage = "";
|
|
25
|
+
this.type = "text";
|
|
26
|
+
this.required = false;
|
|
27
|
+
this.disabled = false;
|
|
28
|
+
this.clearable = false;
|
|
29
|
+
this.readonly = false;
|
|
30
|
+
this.spellcheck = false;
|
|
31
|
+
this.value = "";
|
|
32
|
+
/** input 이벤트 핸들러 */
|
|
33
|
+
this.handleInput = (e) => {
|
|
34
|
+
const input = e.target;
|
|
35
|
+
this.value = input.value;
|
|
36
|
+
if (this.isInvalid) {
|
|
37
|
+
this.isInvalid = false;
|
|
38
|
+
this.currentValidationMessage = "";
|
|
39
|
+
}
|
|
40
|
+
this.emit("u-input", { value: this.value });
|
|
41
|
+
};
|
|
42
|
+
/** change 이벤트 핸들러 */
|
|
43
|
+
this.handleChange = (e) => {
|
|
44
|
+
const input = e.target;
|
|
45
|
+
this.value = input.value;
|
|
46
|
+
this.emit("u-change", { value: this.value });
|
|
47
|
+
};
|
|
48
|
+
/** blur 이벤트 핸들러 */
|
|
49
|
+
this.handleBlur = () => {
|
|
23
50
|
this.validate();
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
51
|
+
};
|
|
52
|
+
/** 클리어 버튼 클릭 핸들러 */
|
|
53
|
+
this.handleClear = (e) => {
|
|
54
|
+
e.stopPropagation();
|
|
55
|
+
this.clear();
|
|
56
|
+
};
|
|
57
|
+
/** 비밀번호 표시/숨김 토글 핸들러 */
|
|
58
|
+
this.handlePasswordToggle = (e) => {
|
|
59
|
+
e.stopPropagation();
|
|
60
|
+
this.showPassword = !this.showPassword;
|
|
61
|
+
this.focus();
|
|
28
62
|
};
|
|
29
63
|
}
|
|
30
64
|
static {
|
|
31
|
-
this.styles = [super.styles,
|
|
65
|
+
this.styles = [super.styles, styles];
|
|
32
66
|
}
|
|
33
67
|
static {
|
|
34
68
|
this.dependencies = {
|
|
35
|
-
"u-icon":
|
|
36
|
-
"u-tooltip":
|
|
69
|
+
"u-icon": Icon,
|
|
70
|
+
"u-tooltip": Tooltip
|
|
37
71
|
};
|
|
38
72
|
}
|
|
39
|
-
updated(
|
|
40
|
-
super.updated(
|
|
73
|
+
updated(changedProperties) {
|
|
74
|
+
super.updated(changedProperties);
|
|
75
|
+
if (changedProperties.has("value") && this.input) {
|
|
76
|
+
if (this.input.value !== this.value) {
|
|
77
|
+
this.input.value = this.value;
|
|
78
|
+
}
|
|
79
|
+
}
|
|
41
80
|
}
|
|
42
81
|
render() {
|
|
43
|
-
return
|
|
82
|
+
return html`
|
|
44
83
|
${this.renderHeader()}
|
|
45
84
|
|
|
46
85
|
<div class="container"
|
|
@@ -51,17 +90,17 @@ class e extends v {
|
|
|
51
90
|
|
|
52
91
|
<input part="input"
|
|
53
92
|
type=${this.type === "password" && this.showPassword ? "text" : this.type}
|
|
54
|
-
name=${
|
|
93
|
+
name=${ifDefined(this.name)}
|
|
55
94
|
?required=${this.required}
|
|
56
95
|
?disabled=${this.disabled}
|
|
57
96
|
?readonly=${this.readonly}
|
|
58
|
-
placeholder=${
|
|
59
|
-
minlength=${
|
|
60
|
-
maxlength=${
|
|
97
|
+
placeholder=${ifDefined(this.placeholder)}
|
|
98
|
+
minlength=${ifDefined(this.minlength)}
|
|
99
|
+
maxlength=${ifDefined(this.maxlength)}
|
|
61
100
|
spellcheck=${this.spellcheck}
|
|
62
|
-
autocomplete=${
|
|
63
|
-
pattern=${
|
|
64
|
-
.value=${
|
|
101
|
+
autocomplete=${ifDefined(this.autocomplete)}
|
|
102
|
+
pattern=${ifDefined(this.pattern)}
|
|
103
|
+
.value=${live(this.value)}
|
|
65
104
|
@input=${this.handleInput}
|
|
66
105
|
@change=${this.handleChange}
|
|
67
106
|
@blur=${this.handleBlur}
|
|
@@ -92,29 +131,40 @@ class e extends v {
|
|
|
92
131
|
}
|
|
93
132
|
/** 라벨 영역을 렌더링합니다. */
|
|
94
133
|
renderHeader() {
|
|
95
|
-
|
|
134
|
+
if (!this.label) return nothing;
|
|
135
|
+
return html`
|
|
96
136
|
<div class="header">
|
|
97
137
|
<label class="label" @click=${this.focus}>
|
|
98
138
|
${this.label}
|
|
99
|
-
${this.required ?
|
|
139
|
+
${this.required ? html`<span class="required-mark">*</span>` : ""}
|
|
100
140
|
</label>
|
|
101
141
|
|
|
102
|
-
${this.labelhelp ?
|
|
142
|
+
${this.labelhelp ? html`
|
|
103
143
|
<u-icon class="help-icon" name="info-circle-fill"></u-icon>
|
|
104
144
|
<u-tooltip trigger-selectors=".help-icon" placement="right-end">${this.labelhelp}</u-tooltip>
|
|
105
|
-
` :
|
|
145
|
+
` : nothing}
|
|
106
146
|
</div>
|
|
107
|
-
|
|
147
|
+
`;
|
|
108
148
|
}
|
|
109
149
|
/** 유효성 검사를 수행합니다. */
|
|
110
150
|
validate() {
|
|
111
|
-
if (!this.input) return
|
|
112
|
-
const
|
|
113
|
-
|
|
151
|
+
if (!this.input) return true;
|
|
152
|
+
const isValid = this.input.checkValidity();
|
|
153
|
+
this.isInvalid = !isValid;
|
|
154
|
+
if (!isValid) {
|
|
155
|
+
this.currentValidationMessage = this.validationMessage || this.input.validationMessage;
|
|
156
|
+
} else {
|
|
157
|
+
this.currentValidationMessage = "";
|
|
158
|
+
}
|
|
159
|
+
return isValid;
|
|
114
160
|
}
|
|
115
161
|
/** 입력값을 초기화합니다. */
|
|
116
162
|
clear() {
|
|
117
|
-
this.value = ""
|
|
163
|
+
this.value = "";
|
|
164
|
+
this.isInvalid = false;
|
|
165
|
+
this.currentValidationMessage = "";
|
|
166
|
+
this.focus();
|
|
167
|
+
this.emit("u-clear");
|
|
118
168
|
}
|
|
119
169
|
/** 입력 필드에 포커스를 설정합니다. */
|
|
120
170
|
focus() {
|
|
@@ -125,69 +175,68 @@ class e extends v {
|
|
|
125
175
|
this.input?.blur();
|
|
126
176
|
}
|
|
127
177
|
}
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
],
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
],
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
],
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
],
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
],
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
],
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
],
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
],
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
],
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
],
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
],
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
],
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
],
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
],
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
],
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
],
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
],
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
],
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
],
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
],
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
],
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
};
|
|
178
|
+
__decorateClass([
|
|
179
|
+
query("input")
|
|
180
|
+
], Input.prototype, "input");
|
|
181
|
+
__decorateClass([
|
|
182
|
+
state()
|
|
183
|
+
], Input.prototype, "showPassword");
|
|
184
|
+
__decorateClass([
|
|
185
|
+
state()
|
|
186
|
+
], Input.prototype, "isInvalid");
|
|
187
|
+
__decorateClass([
|
|
188
|
+
state()
|
|
189
|
+
], Input.prototype, "currentValidationMessage");
|
|
190
|
+
__decorateClass([
|
|
191
|
+
property({ type: String, reflect: true })
|
|
192
|
+
], Input.prototype, "type");
|
|
193
|
+
__decorateClass([
|
|
194
|
+
property({ type: Boolean, reflect: true })
|
|
195
|
+
], Input.prototype, "required");
|
|
196
|
+
__decorateClass([
|
|
197
|
+
property({ type: Boolean, reflect: true })
|
|
198
|
+
], Input.prototype, "disabled");
|
|
199
|
+
__decorateClass([
|
|
200
|
+
property({ type: Boolean, reflect: true })
|
|
201
|
+
], Input.prototype, "clearable");
|
|
202
|
+
__decorateClass([
|
|
203
|
+
property({ type: Boolean, reflect: true })
|
|
204
|
+
], Input.prototype, "readonly");
|
|
205
|
+
__decorateClass([
|
|
206
|
+
property({ type: String })
|
|
207
|
+
], Input.prototype, "name");
|
|
208
|
+
__decorateClass([
|
|
209
|
+
property({ type: String })
|
|
210
|
+
], Input.prototype, "label");
|
|
211
|
+
__decorateClass([
|
|
212
|
+
property({ type: String })
|
|
213
|
+
], Input.prototype, "labelhelp");
|
|
214
|
+
__decorateClass([
|
|
215
|
+
property({ type: String })
|
|
216
|
+
], Input.prototype, "placeholder");
|
|
217
|
+
__decorateClass([
|
|
218
|
+
property({ type: String })
|
|
219
|
+
], Input.prototype, "description");
|
|
220
|
+
__decorateClass([
|
|
221
|
+
property({ type: Number })
|
|
222
|
+
], Input.prototype, "minlength");
|
|
223
|
+
__decorateClass([
|
|
224
|
+
property({ type: Number })
|
|
225
|
+
], Input.prototype, "maxlength");
|
|
226
|
+
__decorateClass([
|
|
227
|
+
property({ type: Boolean })
|
|
228
|
+
], Input.prototype, "spellcheck");
|
|
229
|
+
__decorateClass([
|
|
230
|
+
property({ type: String })
|
|
231
|
+
], Input.prototype, "autocomplete");
|
|
232
|
+
__decorateClass([
|
|
233
|
+
property({ type: String })
|
|
234
|
+
], Input.prototype, "value");
|
|
235
|
+
__decorateClass([
|
|
236
|
+
property({ type: String })
|
|
237
|
+
], Input.prototype, "pattern");
|
|
238
|
+
__decorateClass([
|
|
239
|
+
property({ type: String })
|
|
240
|
+
], Input.prototype, "validationMessage");
|
|
241
|
+
|
|
242
|
+
export { Input };
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import { css
|
|
2
|
-
|
|
1
|
+
import { css } from 'lit';
|
|
2
|
+
|
|
3
|
+
const styles = css`
|
|
3
4
|
:host {
|
|
4
5
|
display: inline-block;
|
|
5
6
|
font-size: inherit;
|
|
@@ -144,6 +145,5 @@ const r = o`
|
|
|
144
145
|
margin: 0;
|
|
145
146
|
}
|
|
146
147
|
`;
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
};
|
|
148
|
+
|
|
149
|
+
export { styles };
|
|
@@ -1,103 +1,153 @@
|
|
|
1
|
-
import { html
|
|
2
|
-
import { queryAssignedElements
|
|
3
|
-
import { BaseElement
|
|
4
|
-
import { MenuItem
|
|
5
|
-
import { styles
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
1
|
+
import { html } from 'lit';
|
|
2
|
+
import { queryAssignedElements, property } from 'lit/decorators.js';
|
|
3
|
+
import { BaseElement } from '../BaseElement.js';
|
|
4
|
+
import { MenuItem } from '../menu-item/MenuItem.js';
|
|
5
|
+
import { styles } from './Menu.styles.js';
|
|
6
|
+
|
|
7
|
+
var __defProp = Object.defineProperty;
|
|
8
|
+
var __decorateClass = (decorators, target, key, kind) => {
|
|
9
|
+
var result = void 0 ;
|
|
10
|
+
for (var i = decorators.length - 1, decorator; i >= 0; i--)
|
|
11
|
+
if (decorator = decorators[i])
|
|
12
|
+
result = (decorator(target, key, result) ) || result;
|
|
13
|
+
if (result) __defProp(target, key, result);
|
|
14
|
+
return result;
|
|
10
15
|
};
|
|
11
|
-
class
|
|
16
|
+
class Menu extends BaseElement {
|
|
12
17
|
constructor() {
|
|
13
|
-
super(...arguments)
|
|
14
|
-
|
|
15
|
-
|
|
18
|
+
super(...arguments);
|
|
19
|
+
this.open = false;
|
|
20
|
+
this.selectable = false;
|
|
21
|
+
this.value = "";
|
|
22
|
+
/** 메뉴를 표시합니다. */
|
|
23
|
+
this.show = async () => {
|
|
24
|
+
await this.updateComplete;
|
|
25
|
+
requestAnimationFrame(() => {
|
|
26
|
+
this.open = true;
|
|
16
27
|
});
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
|
|
28
|
+
};
|
|
29
|
+
/** 메뉴를 숨깁니다. */
|
|
30
|
+
this.hide = async () => {
|
|
31
|
+
await this.updateComplete;
|
|
32
|
+
requestAnimationFrame(() => {
|
|
33
|
+
this.open = false;
|
|
20
34
|
});
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
35
|
+
};
|
|
36
|
+
/** 슬롯 변경 이벤트를 처리합니다. */
|
|
37
|
+
this.handleSlotChange = () => {
|
|
38
|
+
if (this.selectable && this.value) {
|
|
39
|
+
this.updateSelection();
|
|
40
|
+
}
|
|
41
|
+
};
|
|
42
|
+
/** 메뉴 항목 선택 이벤트를 처리합니다. */
|
|
43
|
+
this.handleSelect = (e) => {
|
|
44
|
+
const event = e;
|
|
45
|
+
const menuItem = e.target;
|
|
46
|
+
if (this.selectable && menuItem) {
|
|
47
|
+
this.value = menuItem.value || event.detail?.value || "";
|
|
48
|
+
this.updateSelection();
|
|
49
|
+
}
|
|
50
|
+
};
|
|
51
|
+
/** 키보드 네비게이션을 처리합니다. */
|
|
52
|
+
this.handleKeydown = (e) => {
|
|
53
|
+
const items = this.items.filter((item) => !item.disabled);
|
|
54
|
+
if (items.length === 0) return;
|
|
55
|
+
const currentIndex = items.findIndex((item) => item === e.target);
|
|
56
|
+
let nextIndex = currentIndex;
|
|
31
57
|
switch (e.key) {
|
|
32
58
|
case "ArrowDown":
|
|
33
|
-
e.preventDefault()
|
|
59
|
+
e.preventDefault();
|
|
60
|
+
nextIndex = (currentIndex + 1) % items.length;
|
|
61
|
+
items[nextIndex].focus();
|
|
34
62
|
break;
|
|
35
63
|
case "ArrowUp":
|
|
36
|
-
e.preventDefault()
|
|
64
|
+
e.preventDefault();
|
|
65
|
+
nextIndex = currentIndex - 1 < 0 ? items.length - 1 : currentIndex - 1;
|
|
66
|
+
items[nextIndex].focus();
|
|
37
67
|
break;
|
|
38
68
|
case "Home":
|
|
39
|
-
e.preventDefault()
|
|
69
|
+
e.preventDefault();
|
|
70
|
+
items[0].focus();
|
|
40
71
|
break;
|
|
41
72
|
case "End":
|
|
42
|
-
e.preventDefault()
|
|
73
|
+
e.preventDefault();
|
|
74
|
+
items[items.length - 1].focus();
|
|
43
75
|
break;
|
|
44
76
|
case "Enter":
|
|
45
77
|
case " ":
|
|
46
|
-
e.preventDefault()
|
|
78
|
+
e.preventDefault();
|
|
79
|
+
if (currentIndex >= 0) {
|
|
80
|
+
items[currentIndex].click();
|
|
81
|
+
}
|
|
47
82
|
break;
|
|
48
83
|
case "Escape":
|
|
49
|
-
e.preventDefault()
|
|
84
|
+
e.preventDefault();
|
|
85
|
+
this.hide();
|
|
50
86
|
break;
|
|
51
87
|
}
|
|
52
88
|
};
|
|
53
89
|
}
|
|
54
90
|
static {
|
|
55
|
-
this.styles = [super.styles,
|
|
91
|
+
this.styles = [super.styles, styles];
|
|
56
92
|
}
|
|
57
93
|
static {
|
|
58
94
|
this.dependencies = {
|
|
59
|
-
"u-menu-item":
|
|
95
|
+
"u-menu-item": MenuItem
|
|
60
96
|
};
|
|
61
97
|
}
|
|
62
98
|
connectedCallback() {
|
|
63
|
-
super.connectedCallback()
|
|
99
|
+
super.connectedCallback();
|
|
100
|
+
this.setAttribute("role", "menu");
|
|
101
|
+
this.addEventListener("u-select", this.handleSelect);
|
|
102
|
+
this.addEventListener("keydown", this.handleKeydown);
|
|
64
103
|
}
|
|
65
104
|
disconnectedCallback() {
|
|
66
|
-
this.removeEventListener("u-select", this.handleSelect)
|
|
105
|
+
this.removeEventListener("u-select", this.handleSelect);
|
|
106
|
+
this.removeEventListener("keydown", this.handleKeydown);
|
|
107
|
+
super.disconnectedCallback();
|
|
67
108
|
}
|
|
68
|
-
updated(
|
|
69
|
-
super.updated(
|
|
109
|
+
updated(changedProperties) {
|
|
110
|
+
super.updated(changedProperties);
|
|
111
|
+
if (changedProperties.has("value") && this.selectable) {
|
|
112
|
+
this.updateSelection();
|
|
113
|
+
}
|
|
114
|
+
if (changedProperties.has("open")) {
|
|
115
|
+
this.updateOpenState(this.open);
|
|
116
|
+
}
|
|
70
117
|
}
|
|
71
118
|
render() {
|
|
72
|
-
return
|
|
119
|
+
return html`
|
|
73
120
|
<div class="container">
|
|
74
121
|
<slot @slotchange=${this.handleSlotChange}></slot>
|
|
75
122
|
</div>
|
|
76
123
|
`;
|
|
77
124
|
}
|
|
78
125
|
/** open 상태가 변경될 때 호출됩니다. */
|
|
79
|
-
updateOpenState(
|
|
80
|
-
|
|
126
|
+
updateOpenState(open) {
|
|
127
|
+
if (open) {
|
|
128
|
+
this.emit("u-show");
|
|
129
|
+
} else {
|
|
130
|
+
this.emit("u-hide");
|
|
131
|
+
}
|
|
81
132
|
}
|
|
82
133
|
/** 선택 상태를 업데이트합니다. */
|
|
83
134
|
updateSelection() {
|
|
84
|
-
this.items.forEach((
|
|
85
|
-
|
|
135
|
+
this.items.forEach((item) => {
|
|
136
|
+
item.selected = item.value === this.value;
|
|
86
137
|
});
|
|
87
138
|
}
|
|
88
139
|
}
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
],
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
],
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
],
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
],
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
};
|
|
140
|
+
__decorateClass([
|
|
141
|
+
queryAssignedElements({ selector: "u-menu-item" })
|
|
142
|
+
], Menu.prototype, "items");
|
|
143
|
+
__decorateClass([
|
|
144
|
+
property({ type: Boolean, reflect: true })
|
|
145
|
+
], Menu.prototype, "open");
|
|
146
|
+
__decorateClass([
|
|
147
|
+
property({ type: Boolean })
|
|
148
|
+
], Menu.prototype, "selectable");
|
|
149
|
+
__decorateClass([
|
|
150
|
+
property({ type: String })
|
|
151
|
+
], Menu.prototype, "value");
|
|
152
|
+
|
|
153
|
+
export { Menu };
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import { css
|
|
2
|
-
|
|
1
|
+
import { css } from 'lit';
|
|
2
|
+
|
|
3
|
+
const styles = css`
|
|
3
4
|
:host {
|
|
4
5
|
display: block;
|
|
5
6
|
width: max-content;
|
|
@@ -28,6 +29,5 @@ const t = o`
|
|
|
28
29
|
overflow: auto;
|
|
29
30
|
}
|
|
30
31
|
`;
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
};
|
|
32
|
+
|
|
33
|
+
export { styles };
|