@iyulab/components 0.1.0 → 0.1.2
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 +8 -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 +38 -26
- package/dist/utilities/theme.js +110 -85
- package/package.json +2 -2
- package/dist/utilities/storage.d.ts +0 -60
- package/dist/utilities/storage.js +0 -120
|
@@ -1,36 +1,63 @@
|
|
|
1
|
-
import { html
|
|
2
|
-
import { property
|
|
3
|
-
import { BaseElement
|
|
4
|
-
import { styles
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
1
|
+
import { html, nothing } from 'lit';
|
|
2
|
+
import { property } from 'lit/decorators.js';
|
|
3
|
+
import { BaseElement } from '../BaseElement.js';
|
|
4
|
+
import { styles } from './MenuItem.styles.js';
|
|
5
|
+
|
|
6
|
+
var __defProp = Object.defineProperty;
|
|
7
|
+
var __decorateClass = (decorators, target, key, kind) => {
|
|
8
|
+
var result = void 0 ;
|
|
9
|
+
for (var i = decorators.length - 1, decorator; i >= 0; i--)
|
|
10
|
+
if (decorator = decorators[i])
|
|
11
|
+
result = (decorator(target, key, result) ) || result;
|
|
12
|
+
if (result) __defProp(target, key, result);
|
|
13
|
+
return result;
|
|
9
14
|
};
|
|
10
|
-
class
|
|
15
|
+
class MenuItem extends BaseElement {
|
|
11
16
|
constructor() {
|
|
12
|
-
super(...arguments)
|
|
17
|
+
super(...arguments);
|
|
18
|
+
this.disabled = false;
|
|
19
|
+
this.selected = false;
|
|
20
|
+
this.checked = false;
|
|
21
|
+
this.checkable = false;
|
|
22
|
+
this.value = "";
|
|
23
|
+
/** 클릭 이벤트를 처리합니다. */
|
|
24
|
+
this.handleClick = (e) => {
|
|
13
25
|
if (this.disabled) {
|
|
14
|
-
e.preventDefault()
|
|
26
|
+
e.preventDefault();
|
|
27
|
+
e.stopPropagation();
|
|
15
28
|
return;
|
|
16
29
|
}
|
|
17
|
-
|
|
30
|
+
if (this.checkable) {
|
|
31
|
+
this.checked = !this.checked;
|
|
32
|
+
this.emit("u-check", { checked: this.checked });
|
|
33
|
+
} else {
|
|
34
|
+
this.emit("u-select", { value: this.value });
|
|
35
|
+
}
|
|
18
36
|
};
|
|
19
37
|
}
|
|
20
38
|
static {
|
|
21
|
-
this.styles = [super.styles,
|
|
39
|
+
this.styles = [super.styles, styles];
|
|
22
40
|
}
|
|
23
41
|
static {
|
|
24
42
|
this.dependencies = {};
|
|
25
43
|
}
|
|
26
44
|
connectedCallback() {
|
|
27
|
-
super.connectedCallback()
|
|
45
|
+
super.connectedCallback();
|
|
46
|
+
this.setAttribute("role", "menuitem");
|
|
47
|
+
this.setAttribute("tabindex", this.disabled ? "-1" : "0");
|
|
28
48
|
}
|
|
29
|
-
updated(
|
|
30
|
-
super.updated(
|
|
49
|
+
updated(changedProperties) {
|
|
50
|
+
super.updated(changedProperties);
|
|
51
|
+
if (changedProperties.has("disabled")) {
|
|
52
|
+
this.setAttribute("tabindex", this.disabled ? "-1" : "0");
|
|
53
|
+
this.setAttribute("aria-disabled", this.disabled ? "true" : "false");
|
|
54
|
+
}
|
|
55
|
+
if (changedProperties.has("checked")) {
|
|
56
|
+
this.setAttribute("aria-checked", this.checked ? "true" : "false");
|
|
57
|
+
}
|
|
31
58
|
}
|
|
32
59
|
render() {
|
|
33
|
-
return
|
|
60
|
+
return html`
|
|
34
61
|
<div class="container" @click=${this.handleClick}>
|
|
35
62
|
${this.renderPrefixItem()}
|
|
36
63
|
<slot name="prefix"></slot>
|
|
@@ -43,26 +70,29 @@ class r extends o {
|
|
|
43
70
|
}
|
|
44
71
|
/** 메뉴 항목의 앞부분을 렌더링합니다. */
|
|
45
72
|
renderPrefixItem() {
|
|
46
|
-
|
|
73
|
+
if (this.checkable) {
|
|
74
|
+
return html`
|
|
47
75
|
<span class="checker" ?checked=${this.checked}>✓</span>
|
|
48
|
-
|
|
76
|
+
`;
|
|
77
|
+
} else {
|
|
78
|
+
return nothing;
|
|
79
|
+
}
|
|
49
80
|
}
|
|
50
81
|
}
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
],
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
],
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
],
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
],
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
],
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
};
|
|
82
|
+
__decorateClass([
|
|
83
|
+
property({ type: Boolean, reflect: true })
|
|
84
|
+
], MenuItem.prototype, "disabled");
|
|
85
|
+
__decorateClass([
|
|
86
|
+
property({ type: Boolean, reflect: true })
|
|
87
|
+
], MenuItem.prototype, "selected");
|
|
88
|
+
__decorateClass([
|
|
89
|
+
property({ type: Boolean, reflect: true })
|
|
90
|
+
], MenuItem.prototype, "checked");
|
|
91
|
+
__decorateClass([
|
|
92
|
+
property({ type: Boolean })
|
|
93
|
+
], MenuItem.prototype, "checkable");
|
|
94
|
+
__decorateClass([
|
|
95
|
+
property({ type: String })
|
|
96
|
+
], MenuItem.prototype, "value");
|
|
97
|
+
|
|
98
|
+
export { MenuItem };
|
|
@@ -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
|
|
|
@@ -59,6 +60,5 @@ const r = e`
|
|
|
59
60
|
white-space: nowrap;
|
|
60
61
|
}
|
|
61
62
|
`;
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
};
|
|
63
|
+
|
|
64
|
+
export { styles };
|
|
@@ -1,20 +1,21 @@
|
|
|
1
|
-
import { html
|
|
2
|
-
import { BaseElement
|
|
3
|
-
import { styles
|
|
4
|
-
|
|
1
|
+
import { html } from 'lit';
|
|
2
|
+
import { BaseElement } from '../BaseElement.js';
|
|
3
|
+
import { styles } from './Panel.styles.js';
|
|
4
|
+
|
|
5
|
+
class Panel extends BaseElement {
|
|
5
6
|
static {
|
|
6
|
-
this.styles = [super.styles,
|
|
7
|
+
this.styles = [super.styles, styles];
|
|
7
8
|
}
|
|
8
9
|
static {
|
|
9
10
|
this.dependencies = {};
|
|
10
11
|
}
|
|
11
12
|
connectedCallback() {
|
|
12
|
-
super.connectedCallback()
|
|
13
|
+
super.connectedCallback();
|
|
14
|
+
this.classList.add("scrollable");
|
|
13
15
|
}
|
|
14
16
|
render() {
|
|
15
|
-
return
|
|
17
|
+
return html`<slot></slot>`;
|
|
16
18
|
}
|
|
17
19
|
}
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
};
|
|
20
|
+
|
|
21
|
+
export { Panel };
|
|
@@ -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: block;
|
|
@@ -7,6 +8,5 @@ const s = t`
|
|
|
7
8
|
height: 100%;
|
|
8
9
|
}
|
|
9
10
|
`;
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
};
|
|
11
|
+
|
|
12
|
+
export { styles };
|
|
@@ -1,48 +1,65 @@
|
|
|
1
|
-
import { html
|
|
2
|
-
import { state
|
|
3
|
-
import { BaseElement
|
|
4
|
-
import { styles
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
1
|
+
import { html } from 'lit';
|
|
2
|
+
import { state, property } from 'lit/decorators.js';
|
|
3
|
+
import { BaseElement } from '../BaseElement.js';
|
|
4
|
+
import { styles } from './ProgressRing.styles.js';
|
|
5
|
+
|
|
6
|
+
var __defProp = Object.defineProperty;
|
|
7
|
+
var __decorateClass = (decorators, target, key, kind) => {
|
|
8
|
+
var result = void 0 ;
|
|
9
|
+
for (var i = decorators.length - 1, decorator; i >= 0; i--)
|
|
10
|
+
if (decorator = decorators[i])
|
|
11
|
+
result = (decorator(target, key, result) ) || result;
|
|
12
|
+
if (result) __defProp(target, key, result);
|
|
13
|
+
return result;
|
|
9
14
|
};
|
|
10
|
-
const
|
|
11
|
-
class
|
|
15
|
+
const PATH_LENGTH = 100;
|
|
16
|
+
class ProgressRing extends BaseElement {
|
|
12
17
|
constructor() {
|
|
13
|
-
super(...arguments)
|
|
18
|
+
super(...arguments);
|
|
19
|
+
this.progress = 0;
|
|
20
|
+
this.dasharray = PATH_LENGTH.toString();
|
|
21
|
+
this.variant = "smooth";
|
|
22
|
+
this.minValue = 0;
|
|
23
|
+
this.maxValue = 100;
|
|
24
|
+
this.value = 0;
|
|
14
25
|
}
|
|
15
26
|
static {
|
|
16
|
-
this.styles = [super.styles,
|
|
27
|
+
this.styles = [super.styles, styles];
|
|
17
28
|
}
|
|
18
29
|
static {
|
|
19
30
|
this.dependencies = {};
|
|
20
31
|
}
|
|
21
|
-
willUpdate(
|
|
22
|
-
super.willUpdate(
|
|
32
|
+
willUpdate(changedProperties) {
|
|
33
|
+
super.willUpdate(changedProperties);
|
|
34
|
+
if (changedProperties.has("variant")) {
|
|
35
|
+
this.dasharray = this.updateDashArray(this.variant);
|
|
36
|
+
}
|
|
37
|
+
if (changedProperties.has("minValue") || changedProperties.has("maxValue") || changedProperties.has("value")) {
|
|
38
|
+
this.progress = this.updateProgress(this.minValue, this.maxValue, this.value);
|
|
39
|
+
}
|
|
23
40
|
}
|
|
24
41
|
render() {
|
|
25
|
-
return
|
|
42
|
+
return html`
|
|
26
43
|
<svg class="progress-ring" part="base">
|
|
27
44
|
<defs>
|
|
28
45
|
<mask id="progress-mask">
|
|
29
46
|
<circle
|
|
30
|
-
pathLength="${
|
|
47
|
+
pathLength="${PATH_LENGTH}"
|
|
31
48
|
stroke="white"
|
|
32
|
-
stroke-dasharray="${
|
|
33
|
-
stroke-dashoffset="${
|
|
49
|
+
stroke-dasharray="${PATH_LENGTH}"
|
|
50
|
+
stroke-dashoffset="${PATH_LENGTH * (1 - this.progress)}"
|
|
34
51
|
></circle>
|
|
35
52
|
</mask>
|
|
36
53
|
</defs>
|
|
37
54
|
|
|
38
55
|
<circle
|
|
39
56
|
class="track"
|
|
40
|
-
pathLength="${
|
|
57
|
+
pathLength="${PATH_LENGTH}"
|
|
41
58
|
stroke-dasharray="${this.dasharray}"
|
|
42
59
|
></circle>
|
|
43
60
|
<circle
|
|
44
61
|
class="indicator"
|
|
45
|
-
pathLength="${
|
|
62
|
+
pathLength="${PATH_LENGTH}"
|
|
46
63
|
stroke-dasharray="${this.dasharray}"
|
|
47
64
|
mask="url(#progress-mask)"
|
|
48
65
|
></circle>
|
|
@@ -51,35 +68,43 @@ class i extends c {
|
|
|
51
68
|
`;
|
|
52
69
|
}
|
|
53
70
|
/** 진행 상태를 0과 1 사이의 값으로 반환합니다. */
|
|
54
|
-
updateProgress(
|
|
55
|
-
|
|
71
|
+
updateProgress(min, max, val) {
|
|
72
|
+
min = Number(min ?? 0);
|
|
73
|
+
max = Number(max ?? 100);
|
|
74
|
+
val = Math.min(Math.max(Number(val ?? 0), min), max);
|
|
75
|
+
return max === min ? 0 : (val - min) / (max - min);
|
|
56
76
|
}
|
|
57
77
|
/**
|
|
58
78
|
* variant에 따라 dasharray 값을 반환합니다.
|
|
59
79
|
* [dash-length] [gap-length] or [dash-length] 형식
|
|
60
80
|
*/
|
|
61
|
-
updateDashArray(
|
|
62
|
-
|
|
81
|
+
updateDashArray(variant) {
|
|
82
|
+
if (variant === "ticks") {
|
|
83
|
+
return "1 1";
|
|
84
|
+
} else if (variant === "blocks") {
|
|
85
|
+
return "8 2";
|
|
86
|
+
} else {
|
|
87
|
+
return PATH_LENGTH.toString();
|
|
88
|
+
}
|
|
63
89
|
}
|
|
64
90
|
}
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
],
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
],
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
],
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
],
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
],
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
],
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
};
|
|
91
|
+
__decorateClass([
|
|
92
|
+
state()
|
|
93
|
+
], ProgressRing.prototype, "progress");
|
|
94
|
+
__decorateClass([
|
|
95
|
+
state()
|
|
96
|
+
], ProgressRing.prototype, "dasharray");
|
|
97
|
+
__decorateClass([
|
|
98
|
+
property({ type: String, reflect: true })
|
|
99
|
+
], ProgressRing.prototype, "variant");
|
|
100
|
+
__decorateClass([
|
|
101
|
+
property({ type: Number })
|
|
102
|
+
], ProgressRing.prototype, "minValue");
|
|
103
|
+
__decorateClass([
|
|
104
|
+
property({ type: Number })
|
|
105
|
+
], ProgressRing.prototype, "maxValue");
|
|
106
|
+
__decorateClass([
|
|
107
|
+
property({ type: Number })
|
|
108
|
+
], ProgressRing.prototype, "value");
|
|
109
|
+
|
|
110
|
+
export { ProgressRing };
|
|
@@ -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;
|
|
@@ -48,6 +49,5 @@ const r = t`
|
|
|
48
49
|
pointer-events: none;
|
|
49
50
|
}
|
|
50
51
|
`;
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
};
|
|
52
|
+
|
|
53
|
+
export { styles };
|
|
@@ -1,15 +1,16 @@
|
|
|
1
|
-
import { html
|
|
2
|
-
import { BaseElement
|
|
3
|
-
import { styles
|
|
4
|
-
|
|
1
|
+
import { html } from 'lit';
|
|
2
|
+
import { BaseElement } from '../BaseElement.js';
|
|
3
|
+
import { styles } from './Spinner.styles.js';
|
|
4
|
+
|
|
5
|
+
class Spinner extends BaseElement {
|
|
5
6
|
static {
|
|
6
|
-
this.styles = [super.styles,
|
|
7
|
+
this.styles = [super.styles, styles];
|
|
7
8
|
}
|
|
8
9
|
static {
|
|
9
10
|
this.dependencies = {};
|
|
10
11
|
}
|
|
11
12
|
render() {
|
|
12
|
-
return
|
|
13
|
+
return html`
|
|
13
14
|
<svg class="spinner" part="base">
|
|
14
15
|
<circle class="track"></circle>
|
|
15
16
|
<circle class="indicator"></circle>
|
|
@@ -17,6 +18,5 @@ class a extends e {
|
|
|
17
18
|
`;
|
|
18
19
|
}
|
|
19
20
|
}
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
};
|
|
21
|
+
|
|
22
|
+
export { Spinner };
|
|
@@ -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-flex;
|
|
5
6
|
font-size: inherit;
|
|
@@ -52,6 +53,5 @@ const t = r`
|
|
|
52
53
|
}
|
|
53
54
|
}
|
|
54
55
|
`;
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
};
|
|
56
|
+
|
|
57
|
+
export { styles };
|
|
@@ -1,86 +1,147 @@
|
|
|
1
|
-
import { html
|
|
2
|
-
import { property
|
|
3
|
-
import { arrayAttributeConverter
|
|
4
|
-
import { BaseElement
|
|
5
|
-
import { Panel
|
|
6
|
-
import { Splitter
|
|
7
|
-
import { styles
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
1
|
+
import { html } from 'lit';
|
|
2
|
+
import { property } from 'lit/decorators.js';
|
|
3
|
+
import { arrayAttributeConverter } from '../../internals/attribute-converters.js';
|
|
4
|
+
import { BaseElement } from '../BaseElement.js';
|
|
5
|
+
import { Panel } from '../panel/Panel.js';
|
|
6
|
+
import { Splitter } from './Splitter.js';
|
|
7
|
+
import { styles } from './SplitPanel.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 SplitPanel extends BaseElement {
|
|
14
19
|
constructor() {
|
|
15
|
-
super(...arguments)
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
20
|
+
super(...arguments);
|
|
21
|
+
this.panels = [];
|
|
22
|
+
this.splitters = [];
|
|
23
|
+
this.isDragging = false;
|
|
24
|
+
this.currentSplitter = null;
|
|
25
|
+
this.totalSize = 0;
|
|
26
|
+
this.startPosition = 0;
|
|
27
|
+
this.startRatio = [];
|
|
28
|
+
this.orientation = "horizontal";
|
|
29
|
+
this.ratio = [];
|
|
30
|
+
this.handleSlotChange = async (e) => {
|
|
31
|
+
const slot = e.target;
|
|
32
|
+
const childrens = slot.assignedElements({ flatten: true });
|
|
33
|
+
const panels = childrens.filter((el) => el instanceof Panel);
|
|
34
|
+
if (this.panels.length === panels.length && this.panels.every((p, i) => p === panels[i])) {
|
|
35
|
+
return;
|
|
36
|
+
}
|
|
37
|
+
this.splitters.forEach((splitter) => splitter.remove());
|
|
38
|
+
this.splitters = [];
|
|
39
|
+
this.panels = panels;
|
|
40
|
+
panels.forEach((panel, index) => {
|
|
41
|
+
if (index === panels.length - 1) {
|
|
29
42
|
return;
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
this.
|
|
43
|
+
}
|
|
44
|
+
const splitter = new Splitter();
|
|
45
|
+
splitter.orientation = this.orientation;
|
|
46
|
+
splitter.addEventListener("mousedown", this.handleMouseDown);
|
|
47
|
+
this.splitters.push(splitter);
|
|
48
|
+
panel.after(splitter);
|
|
49
|
+
});
|
|
50
|
+
if (this.ratio.length === panels.length) {
|
|
51
|
+
const totalRatio = this.ratio.reduce((sum, r) => sum + r, 0);
|
|
52
|
+
panels.forEach((panel, i) => {
|
|
53
|
+
const panelRatio = this.ratio[i] / totalRatio * 100;
|
|
54
|
+
panel.style.flex = `${panelRatio} 1 0%`;
|
|
55
|
+
});
|
|
56
|
+
return;
|
|
57
|
+
} else {
|
|
58
|
+
panels.forEach((panel) => {
|
|
59
|
+
panel.style.flex = `${100 / panels.length} 1 0%`;
|
|
60
|
+
});
|
|
35
61
|
}
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
62
|
+
this.requestUpdate();
|
|
63
|
+
await this.updateComplete;
|
|
64
|
+
};
|
|
65
|
+
this.handleMouseDown = (e) => {
|
|
66
|
+
e.preventDefault();
|
|
67
|
+
const splitter = e.currentTarget;
|
|
68
|
+
this.currentSplitter = splitter;
|
|
69
|
+
this.isDragging = true;
|
|
70
|
+
this.startPosition = this.orientation === "horizontal" ? e.clientX : e.clientY;
|
|
71
|
+
const containerRect = this.getBoundingClientRect();
|
|
72
|
+
const containerSize = this.orientation === "horizontal" ? containerRect.width : containerRect.height;
|
|
73
|
+
const splittersSize = this.splitters.reduce((sum, sp) => sum + sp.size, 0);
|
|
74
|
+
this.totalSize = containerSize - splittersSize;
|
|
75
|
+
this.startRatio = this.panels.map((panel) => {
|
|
76
|
+
const rect = panel.getBoundingClientRect();
|
|
77
|
+
const size = this.orientation === "horizontal" ? rect.width : rect.height;
|
|
78
|
+
return size / this.totalSize * 100;
|
|
79
|
+
});
|
|
80
|
+
splitter.dragging = true;
|
|
81
|
+
document.addEventListener("mousemove", this.handleMouseMove);
|
|
82
|
+
document.addEventListener("mouseup", this.handleMouseUp);
|
|
83
|
+
document.body.style.userSelect = "none";
|
|
84
|
+
document.body.style.cursor = this.orientation === "horizontal" ? "col-resize" : "row-resize";
|
|
85
|
+
};
|
|
86
|
+
this.handleMouseMove = (e) => {
|
|
46
87
|
if (!this.isDragging || !this.currentSplitter) return;
|
|
47
|
-
|
|
48
|
-
const
|
|
49
|
-
|
|
50
|
-
const
|
|
51
|
-
if (
|
|
52
|
-
const
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
88
|
+
e.preventDefault();
|
|
89
|
+
const currentPosition = this.orientation === "horizontal" ? e.clientX : e.clientY;
|
|
90
|
+
const deltaPixels = currentPosition - this.startPosition;
|
|
91
|
+
const splitterIndex = this.splitters.indexOf(this.currentSplitter);
|
|
92
|
+
if (splitterIndex === -1) return;
|
|
93
|
+
const prevPanel = this.panels[splitterIndex];
|
|
94
|
+
const nextPanel = this.panels[splitterIndex + 1];
|
|
95
|
+
if (!prevPanel || !nextPanel) return;
|
|
96
|
+
const deltaRatio = deltaPixels / this.totalSize * 100;
|
|
97
|
+
const prevRatio = this.startRatio[splitterIndex] + deltaRatio;
|
|
98
|
+
const nextRatio = this.startRatio[splitterIndex + 1] - deltaRatio;
|
|
99
|
+
if (prevRatio < 0 || nextRatio < 0) return;
|
|
100
|
+
prevPanel.style.flex = `${prevRatio} 1 0%`;
|
|
101
|
+
nextPanel.style.flex = `${nextRatio} 1 0%`;
|
|
102
|
+
};
|
|
103
|
+
this.handleMouseUp = (_e) => {
|
|
104
|
+
if (!this.isDragging) return;
|
|
105
|
+
this.isDragging = false;
|
|
106
|
+
if (this.currentSplitter) {
|
|
107
|
+
this.currentSplitter.dragging = false;
|
|
108
|
+
this.currentSplitter = null;
|
|
109
|
+
}
|
|
110
|
+
document.removeEventListener("mousemove", this.handleMouseMove);
|
|
111
|
+
document.removeEventListener("mouseup", this.handleMouseUp);
|
|
112
|
+
document.body.style.userSelect = "";
|
|
113
|
+
document.body.style.cursor = "";
|
|
56
114
|
};
|
|
57
115
|
}
|
|
58
116
|
static {
|
|
59
|
-
this.styles = [super.styles,
|
|
117
|
+
this.styles = [super.styles, styles];
|
|
60
118
|
}
|
|
61
119
|
static {
|
|
62
120
|
this.dependencies = {
|
|
63
|
-
"u-panel":
|
|
64
|
-
"u-splitter":
|
|
121
|
+
"u-panel": Panel,
|
|
122
|
+
"u-splitter": Splitter
|
|
65
123
|
};
|
|
66
124
|
}
|
|
67
125
|
disconnectedCallback() {
|
|
68
|
-
document.removeEventListener("mousemove", this.handleMouseMove)
|
|
69
|
-
|
|
70
|
-
|
|
126
|
+
document.removeEventListener("mousemove", this.handleMouseMove);
|
|
127
|
+
document.removeEventListener("mouseup", this.handleMouseUp);
|
|
128
|
+
this.splitters.forEach((splitter) => {
|
|
129
|
+
splitter.removeEventListener("mousedown", this.handleMouseDown);
|
|
130
|
+
splitter.remove();
|
|
131
|
+
});
|
|
132
|
+
super.disconnectedCallback();
|
|
71
133
|
}
|
|
72
134
|
render() {
|
|
73
|
-
return
|
|
135
|
+
return html`
|
|
74
136
|
<slot @slotchange=${this.handleSlotChange}></slot>
|
|
75
137
|
`;
|
|
76
138
|
}
|
|
77
139
|
}
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
],
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
],
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
};
|
|
140
|
+
__decorateClass([
|
|
141
|
+
property({ type: String, reflect: true })
|
|
142
|
+
], SplitPanel.prototype, "orientation");
|
|
143
|
+
__decorateClass([
|
|
144
|
+
property({ type: Array, converter: arrayAttributeConverter(parseFloat) })
|
|
145
|
+
], SplitPanel.prototype, "ratio");
|
|
146
|
+
|
|
147
|
+
export { SplitPanel };
|