@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,30 +1,49 @@
|
|
|
1
|
-
import { html
|
|
2
|
-
import { property
|
|
3
|
-
import { BaseElement
|
|
4
|
-
import { Icon
|
|
5
|
-
import { styles
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
1
|
+
import { html } from 'lit';
|
|
2
|
+
import { property } from 'lit/decorators.js';
|
|
3
|
+
import { BaseElement } from '../BaseElement.js';
|
|
4
|
+
import { Icon } from '../icon/Icon.js';
|
|
5
|
+
import { styles } from './Alert.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 Alert extends BaseElement {
|
|
12
17
|
constructor() {
|
|
13
|
-
super(...arguments)
|
|
18
|
+
super(...arguments);
|
|
19
|
+
this.open = false;
|
|
20
|
+
this.type = "info";
|
|
21
|
+
this.minRows = 1;
|
|
22
|
+
this.maxRows = 3;
|
|
23
|
+
this.duration = 0;
|
|
14
24
|
}
|
|
15
25
|
static {
|
|
16
|
-
this.styles = [super.styles,
|
|
26
|
+
this.styles = [super.styles, styles];
|
|
17
27
|
}
|
|
18
28
|
static {
|
|
19
29
|
this.dependencies = {
|
|
20
|
-
"u-icon":
|
|
30
|
+
"u-icon": Icon
|
|
21
31
|
};
|
|
22
32
|
}
|
|
23
|
-
updated(
|
|
24
|
-
super.updated(
|
|
33
|
+
updated(changedProperties) {
|
|
34
|
+
super.updated(changedProperties);
|
|
35
|
+
if (changedProperties.has("minRows") && this.minRows < this.maxRows && this.minRows > 0) {
|
|
36
|
+
this.style.setProperty("--min-content-rows", `${this.minRows}`);
|
|
37
|
+
}
|
|
38
|
+
if (changedProperties.has("maxRows") && this.maxRows > this.minRows && this.maxRows > 0) {
|
|
39
|
+
this.style.setProperty("--max-content-rows", `${this.maxRows}`);
|
|
40
|
+
}
|
|
41
|
+
if (changedProperties.has("open")) {
|
|
42
|
+
this.updateOpenState(this.open);
|
|
43
|
+
}
|
|
25
44
|
}
|
|
26
45
|
render() {
|
|
27
|
-
return
|
|
46
|
+
return html`
|
|
28
47
|
<div class="container">
|
|
29
48
|
<div class="header">
|
|
30
49
|
<u-icon class="icon"
|
|
@@ -39,7 +58,7 @@ class s extends c {
|
|
|
39
58
|
></u-icon>
|
|
40
59
|
</div>
|
|
41
60
|
<div class="content scrollable">
|
|
42
|
-
${this.content ||
|
|
61
|
+
${this.content || html`<slot></slot>`}
|
|
43
62
|
</div>
|
|
44
63
|
<div class="footer"></div>
|
|
45
64
|
</div>
|
|
@@ -47,19 +66,21 @@ class s extends c {
|
|
|
47
66
|
}
|
|
48
67
|
/** Alert를 표시합니다. */
|
|
49
68
|
async show() {
|
|
50
|
-
await this.updateComplete
|
|
51
|
-
|
|
69
|
+
await this.updateComplete;
|
|
70
|
+
requestAnimationFrame(() => {
|
|
71
|
+
this.open = true;
|
|
52
72
|
});
|
|
53
73
|
}
|
|
54
74
|
/** Alert를 숨깁니다. */
|
|
55
75
|
async hide() {
|
|
56
|
-
await this.updateComplete
|
|
57
|
-
|
|
76
|
+
await this.updateComplete;
|
|
77
|
+
requestAnimationFrame(() => {
|
|
78
|
+
this.open = false;
|
|
58
79
|
});
|
|
59
80
|
}
|
|
60
81
|
/** Alert 타입에 따른 아이콘 이름을 반환합니다. */
|
|
61
|
-
getIcon(
|
|
62
|
-
switch (
|
|
82
|
+
getIcon(type) {
|
|
83
|
+
switch (type) {
|
|
63
84
|
case "error":
|
|
64
85
|
return "exclamation-circle-fill";
|
|
65
86
|
case "warning":
|
|
@@ -75,33 +96,40 @@ class s extends c {
|
|
|
75
96
|
}
|
|
76
97
|
}
|
|
77
98
|
/** open 속성 변경에 따른 상태 업데이트를 처리합니다. */
|
|
78
|
-
updateOpenState(
|
|
79
|
-
|
|
80
|
-
this.
|
|
81
|
-
|
|
99
|
+
updateOpenState(open) {
|
|
100
|
+
if (open) {
|
|
101
|
+
if (this.duration && this.duration > 0) {
|
|
102
|
+
this.timeoutId = window.setTimeout(() => {
|
|
103
|
+
this.hide();
|
|
104
|
+
}, this.duration);
|
|
105
|
+
}
|
|
106
|
+
this.emit("u-show");
|
|
107
|
+
} else {
|
|
108
|
+
clearTimeout(this.timeoutId);
|
|
109
|
+
this.emit("u-hide");
|
|
110
|
+
}
|
|
82
111
|
}
|
|
83
112
|
}
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
],
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
],
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
],
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
],
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
],
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
],
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
],
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
};
|
|
113
|
+
__decorateClass([
|
|
114
|
+
property({ type: Boolean, reflect: true })
|
|
115
|
+
], Alert.prototype, "open");
|
|
116
|
+
__decorateClass([
|
|
117
|
+
property({ type: String, reflect: true })
|
|
118
|
+
], Alert.prototype, "type");
|
|
119
|
+
__decorateClass([
|
|
120
|
+
property({ type: String })
|
|
121
|
+
], Alert.prototype, "label");
|
|
122
|
+
__decorateClass([
|
|
123
|
+
property({ type: String })
|
|
124
|
+
], Alert.prototype, "content");
|
|
125
|
+
__decorateClass([
|
|
126
|
+
property({ type: Number })
|
|
127
|
+
], Alert.prototype, "minRows");
|
|
128
|
+
__decorateClass([
|
|
129
|
+
property({ type: Number })
|
|
130
|
+
], Alert.prototype, "maxRows");
|
|
131
|
+
__decorateClass([
|
|
132
|
+
property({ type: Number })
|
|
133
|
+
], Alert.prototype, "duration");
|
|
134
|
+
|
|
135
|
+
export { Alert };
|
|
@@ -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
|
min-width: 300px;
|
|
@@ -109,6 +110,5 @@ const e = r`
|
|
|
109
110
|
display: none;
|
|
110
111
|
}
|
|
111
112
|
`;
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
};
|
|
113
|
+
|
|
114
|
+
export { styles };
|
|
@@ -1,27 +1,34 @@
|
|
|
1
|
-
import { html
|
|
2
|
-
import { property
|
|
3
|
-
import { BaseElement
|
|
4
|
-
import { Spinner
|
|
5
|
-
import { styles
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
1
|
+
import { html } from 'lit';
|
|
2
|
+
import { property } from 'lit/decorators.js';
|
|
3
|
+
import { BaseElement } from '../BaseElement.js';
|
|
4
|
+
import { Spinner } from '../spinner/Spinner.js';
|
|
5
|
+
import { styles } from './Button.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 Button extends BaseElement {
|
|
12
17
|
constructor() {
|
|
13
|
-
super(...arguments)
|
|
18
|
+
super(...arguments);
|
|
19
|
+
this.disabled = false;
|
|
20
|
+
this.loading = false;
|
|
14
21
|
}
|
|
15
22
|
static {
|
|
16
|
-
this.styles = [super.styles,
|
|
23
|
+
this.styles = [super.styles, styles];
|
|
17
24
|
}
|
|
18
25
|
static {
|
|
19
26
|
this.dependencies = {
|
|
20
|
-
"u-spinner":
|
|
27
|
+
"u-spinner": Spinner
|
|
21
28
|
};
|
|
22
29
|
}
|
|
23
30
|
render() {
|
|
24
|
-
return
|
|
31
|
+
return html`
|
|
25
32
|
<button part="base" ?disabled=${this.disabled || this.loading}>
|
|
26
33
|
<slot name="prefix"></slot>
|
|
27
34
|
<slot></slot>
|
|
@@ -34,12 +41,11 @@ class a extends d {
|
|
|
34
41
|
`;
|
|
35
42
|
}
|
|
36
43
|
}
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
],
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
],
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
};
|
|
44
|
+
__decorateClass([
|
|
45
|
+
property({ type: Boolean, reflect: true })
|
|
46
|
+
], Button.prototype, "disabled");
|
|
47
|
+
__decorateClass([
|
|
48
|
+
property({ type: Boolean, reflect: true })
|
|
49
|
+
], Button.prototype, "loading");
|
|
50
|
+
|
|
51
|
+
export { Button };
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import { css
|
|
2
|
-
|
|
1
|
+
import { css } from 'lit';
|
|
2
|
+
|
|
3
|
+
const styles = css`
|
|
3
4
|
:host {
|
|
4
5
|
position: relative;
|
|
5
6
|
display: inline-flex;
|
|
@@ -84,6 +85,5 @@ const t = o`
|
|
|
84
85
|
background-color: inherit;
|
|
85
86
|
}
|
|
86
87
|
`;
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
};
|
|
88
|
+
|
|
89
|
+
export { styles };
|
|
@@ -1,20 +1,35 @@
|
|
|
1
|
-
import { html
|
|
2
|
-
import { property
|
|
3
|
-
import { offset
|
|
4
|
-
import { getParentElement
|
|
5
|
-
import { BaseElement
|
|
6
|
-
import { MenuItem
|
|
7
|
-
import { styles
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
1
|
+
import { html } from 'lit';
|
|
2
|
+
import { property } from 'lit/decorators.js';
|
|
3
|
+
import { offset, shift, flip, autoPlacement, computePosition } from '@floating-ui/dom';
|
|
4
|
+
import { getParentElement } from '../../internals/node-helpers.js';
|
|
5
|
+
import { BaseElement } from '../BaseElement.js';
|
|
6
|
+
import { MenuItem } from '../menu-item/MenuItem.js';
|
|
7
|
+
import { styles } from './ContextMenu.styles.js';
|
|
8
|
+
|
|
9
|
+
var __defProp = Object.defineProperty;
|
|
10
|
+
var __decorateClass = (decorators, target, key, kind) => {
|
|
11
|
+
var result = void 0 ;
|
|
12
|
+
for (var i = decorators.length - 1, decorator; i >= 0; i--)
|
|
13
|
+
if (decorator = decorators[i])
|
|
14
|
+
result = (decorator(target, key, result) ) || result;
|
|
15
|
+
if (result) __defProp(target, key, result);
|
|
16
|
+
return result;
|
|
12
17
|
};
|
|
13
|
-
class
|
|
18
|
+
class ContextMenu extends BaseElement {
|
|
14
19
|
constructor() {
|
|
15
|
-
super(...arguments)
|
|
16
|
-
|
|
17
|
-
|
|
20
|
+
super(...arguments);
|
|
21
|
+
/** 마우스 클릭 위치 */
|
|
22
|
+
this.mouseX = 0;
|
|
23
|
+
this.mouseY = 0;
|
|
24
|
+
this.open = false;
|
|
25
|
+
this.hoist = true;
|
|
26
|
+
this.distance = 2;
|
|
27
|
+
/** 컨텍스트 메뉴를 표시합니다. */
|
|
28
|
+
this.show = async (x, y) => {
|
|
29
|
+
if (x !== void 0) this.mouseX = x;
|
|
30
|
+
if (y !== void 0) this.mouseY = y;
|
|
31
|
+
await this.updateComplete;
|
|
32
|
+
const virtualElement = {
|
|
18
33
|
getBoundingClientRect: () => ({
|
|
19
34
|
width: 0,
|
|
20
35
|
height: 0,
|
|
@@ -25,64 +40,95 @@ class r extends v {
|
|
|
25
40
|
right: this.mouseX,
|
|
26
41
|
bottom: this.mouseY
|
|
27
42
|
})
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
43
|
+
};
|
|
44
|
+
const middleware = [
|
|
45
|
+
offset({ mainAxis: this.distance }),
|
|
46
|
+
shift({ padding: 8 }),
|
|
47
|
+
flip()
|
|
32
48
|
];
|
|
33
|
-
this.placement
|
|
34
|
-
|
|
49
|
+
if (!this.placement) {
|
|
50
|
+
middleware.push(autoPlacement({ allowedPlacements: ["bottom-start", "bottom-end", "top-start", "top-end"] }));
|
|
51
|
+
}
|
|
52
|
+
const position = await computePosition(virtualElement, this, {
|
|
35
53
|
placement: this.placement || "bottom-start",
|
|
36
|
-
middleware
|
|
54
|
+
middleware,
|
|
37
55
|
strategy: this.hoist ? "fixed" : "absolute"
|
|
38
56
|
});
|
|
39
57
|
Object.assign(this.style, {
|
|
40
|
-
left: `${
|
|
41
|
-
top: `${
|
|
42
|
-
transformOrigin: this.getTransformOrigin(
|
|
43
|
-
}), await this.updateComplete, requestAnimationFrame(() => {
|
|
44
|
-
this.open = !0, this.emit("u-show");
|
|
58
|
+
left: `${position.x}px`,
|
|
59
|
+
top: `${position.y}px`,
|
|
60
|
+
transformOrigin: this.getTransformOrigin(position.placement)
|
|
45
61
|
});
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
this.open =
|
|
62
|
+
await this.updateComplete;
|
|
63
|
+
requestAnimationFrame(() => {
|
|
64
|
+
this.open = true;
|
|
65
|
+
this.emit("u-show");
|
|
49
66
|
});
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
67
|
+
};
|
|
68
|
+
/** 컨텍스트 메뉴를 숨깁니다. */
|
|
69
|
+
this.hide = async () => {
|
|
70
|
+
await this.updateComplete;
|
|
71
|
+
requestAnimationFrame(() => {
|
|
72
|
+
this.open = false;
|
|
73
|
+
this.emit("u-hide");
|
|
74
|
+
});
|
|
75
|
+
};
|
|
76
|
+
/** 컨텍스트 메뉴 이벤트를 처리합니다. */
|
|
77
|
+
this.handleContextMenu = (e) => {
|
|
78
|
+
e.preventDefault();
|
|
79
|
+
e.stopPropagation();
|
|
80
|
+
this.show(e.clientX, e.clientY);
|
|
81
|
+
};
|
|
82
|
+
/** 문서 클릭 이벤트를 처리합니다. */
|
|
83
|
+
this.handleDocumentClick = (e) => {
|
|
84
|
+
if (this.open && !this.contains(e.target)) {
|
|
85
|
+
this.hide();
|
|
86
|
+
}
|
|
87
|
+
};
|
|
88
|
+
/** 문서 컨텍스트 메뉴 이벤트를 처리합니다. */
|
|
89
|
+
this.handleDocumentContextMenu = (e) => {
|
|
90
|
+
if (this.open && !this.trigger?.contains(e.target)) {
|
|
91
|
+
this.hide();
|
|
92
|
+
}
|
|
93
|
+
};
|
|
94
|
+
/** 슬롯 변경 이벤트를 처리합니다. */
|
|
95
|
+
this.handleSlotChange = () => {
|
|
96
|
+
const slot = this.shadowRoot?.querySelector("slot");
|
|
97
|
+
const items = slot?.assignedElements({ flatten: true });
|
|
98
|
+
items?.forEach((item) => {
|
|
99
|
+
item.addEventListener("u-select", () => {
|
|
59
100
|
this.hide();
|
|
60
101
|
});
|
|
61
102
|
});
|
|
62
103
|
};
|
|
63
104
|
}
|
|
64
105
|
static {
|
|
65
|
-
this.styles = [super.styles,
|
|
106
|
+
this.styles = [super.styles, styles];
|
|
66
107
|
}
|
|
67
108
|
static {
|
|
68
109
|
this.dependencies = {
|
|
69
|
-
"u-menu-item":
|
|
110
|
+
"u-menu-item": MenuItem
|
|
70
111
|
};
|
|
71
112
|
}
|
|
72
113
|
connectedCallback() {
|
|
73
|
-
super.connectedCallback()
|
|
114
|
+
super.connectedCallback();
|
|
115
|
+
this.trigger ||= getParentElement(this);
|
|
116
|
+
this.setAttribute("role", "menu");
|
|
74
117
|
}
|
|
75
118
|
disconnectedCallback() {
|
|
76
|
-
this.detachTrigger(this.trigger)
|
|
119
|
+
this.detachTrigger(this.trigger);
|
|
120
|
+
super.disconnectedCallback();
|
|
77
121
|
}
|
|
78
|
-
updated(
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
122
|
+
updated(changedProperties) {
|
|
123
|
+
super.updated(changedProperties);
|
|
124
|
+
if (changedProperties.has("trigger") && this.trigger) {
|
|
125
|
+
const oldTrigger = changedProperties.get("trigger");
|
|
126
|
+
this.detachTrigger(oldTrigger);
|
|
127
|
+
this.attachTrigger(this.trigger);
|
|
82
128
|
}
|
|
83
129
|
}
|
|
84
130
|
render() {
|
|
85
|
-
return
|
|
131
|
+
return html`
|
|
86
132
|
<div class="container">
|
|
87
133
|
<slot @slotchange=${this.handleSlotChange}></slot>
|
|
88
134
|
</div>
|
|
@@ -91,8 +137,8 @@ class r extends v {
|
|
|
91
137
|
/**
|
|
92
138
|
* 메뉴가 나타날 위치에 따라 transform-origin 값을 반환합니다.
|
|
93
139
|
*/
|
|
94
|
-
getTransformOrigin(
|
|
95
|
-
switch (
|
|
140
|
+
getTransformOrigin(placement) {
|
|
141
|
+
switch (placement) {
|
|
96
142
|
case "top":
|
|
97
143
|
case "top-start":
|
|
98
144
|
case "top-end":
|
|
@@ -114,29 +160,34 @@ class r extends v {
|
|
|
114
160
|
}
|
|
115
161
|
}
|
|
116
162
|
/** 대상 엘리먼트에 컨텍스트 메뉴 이벤트를 바인딩 합니다. */
|
|
117
|
-
attachTrigger(
|
|
118
|
-
|
|
163
|
+
attachTrigger(trigger) {
|
|
164
|
+
if (!trigger) return;
|
|
165
|
+
trigger.addEventListener("contextmenu", this.handleContextMenu);
|
|
166
|
+
document.addEventListener("click", this.handleDocumentClick);
|
|
167
|
+
document.addEventListener("contextmenu", this.handleDocumentContextMenu);
|
|
119
168
|
}
|
|
120
169
|
/** 대상 엘리먼트에 바인딩된 컨텍스트 메뉴 이벤트를 제거합니다. */
|
|
121
|
-
detachTrigger(
|
|
122
|
-
|
|
170
|
+
detachTrigger(trigger) {
|
|
171
|
+
if (!trigger) return;
|
|
172
|
+
trigger.removeEventListener("contextmenu", this.handleContextMenu);
|
|
173
|
+
document.removeEventListener("click", this.handleDocumentClick);
|
|
174
|
+
document.removeEventListener("contextmenu", this.handleDocumentContextMenu);
|
|
123
175
|
}
|
|
124
176
|
}
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
],
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
],
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
],
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
],
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
],
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
};
|
|
177
|
+
__decorateClass([
|
|
178
|
+
property({ attribute: false })
|
|
179
|
+
], ContextMenu.prototype, "trigger");
|
|
180
|
+
__decorateClass([
|
|
181
|
+
property({ type: Boolean, reflect: true })
|
|
182
|
+
], ContextMenu.prototype, "open");
|
|
183
|
+
__decorateClass([
|
|
184
|
+
property({ type: Boolean, reflect: true })
|
|
185
|
+
], ContextMenu.prototype, "hoist");
|
|
186
|
+
__decorateClass([
|
|
187
|
+
property({ type: String })
|
|
188
|
+
], ContextMenu.prototype, "placement");
|
|
189
|
+
__decorateClass([
|
|
190
|
+
property({ type: Number })
|
|
191
|
+
], ContextMenu.prototype, "distance");
|
|
192
|
+
|
|
193
|
+
export { ContextMenu };
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import { css
|
|
2
|
-
|
|
1
|
+
import { css } from 'lit';
|
|
2
|
+
|
|
3
|
+
const styles = css`
|
|
3
4
|
:host {
|
|
4
5
|
position: absolute;
|
|
5
6
|
z-index: 1000;
|
|
@@ -35,6 +36,5 @@ const e = o`
|
|
|
35
36
|
overflow: hidden;
|
|
36
37
|
}
|
|
37
38
|
`;
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
};
|
|
39
|
+
|
|
40
|
+
export { styles };
|