@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.
Files changed (81) hide show
  1. package/CHANGELOG.md +8 -0
  2. package/dist/assets/icons/arrow-clockwise.svg.js +3 -7
  3. package/dist/assets/icons/arrow-down.svg.js +3 -6
  4. package/dist/assets/icons/arrow-up.svg.js +3 -6
  5. package/dist/assets/icons/ban.svg.js +3 -6
  6. package/dist/assets/icons/bell-fill.svg.js +3 -6
  7. package/dist/assets/icons/check-circle-fill.svg.js +3 -6
  8. package/dist/assets/icons/check-lg.svg.js +3 -6
  9. package/dist/assets/icons/chevron-down.svg.js +3 -6
  10. package/dist/assets/icons/chevron-left.svg.js +3 -6
  11. package/dist/assets/icons/chevron-right.svg.js +3 -6
  12. package/dist/assets/icons/chevron-up.svg.js +3 -6
  13. package/dist/assets/icons/copy.svg.js +3 -6
  14. package/dist/assets/icons/dash-lg.svg.js +3 -6
  15. package/dist/assets/icons/exclamation-circle-fill.svg.js +3 -6
  16. package/dist/assets/icons/exclamation-triangle-fill.svg.js +3 -6
  17. package/dist/assets/icons/eye-slash.svg.js +3 -8
  18. package/dist/assets/icons/eye.svg.js +3 -7
  19. package/dist/assets/icons/info-circle-fill.svg.js +3 -6
  20. package/dist/assets/icons/layout-sidebar.svg.js +3 -6
  21. package/dist/assets/icons/lightbulb-fill.svg.js +3 -6
  22. package/dist/assets/icons/lightbulb-off.svg.js +3 -6
  23. package/dist/assets/icons/lightbulb.svg.js +3 -6
  24. package/dist/assets/icons/mic-fill.svg.js +3 -7
  25. package/dist/assets/icons/mic-mute-fill.svg.js +3 -7
  26. package/dist/assets/icons/paperclip.svg.js +3 -6
  27. package/dist/assets/icons/pencil-square.svg.js +3 -7
  28. package/dist/assets/icons/plus-lg.svg.js +3 -6
  29. package/dist/assets/icons/search.svg.js +3 -6
  30. package/dist/assets/icons/speedometer.svg.js +3 -7
  31. package/dist/assets/icons/x-lg.svg.js +3 -6
  32. package/dist/assets/styles/dark.css.js +3 -4
  33. package/dist/assets/styles/light.css.js +3 -4
  34. package/dist/components/BaseElement.js +32 -22
  35. package/dist/components/BaseElement.styles.js +5 -5
  36. package/dist/components/alert/Alert.js +79 -51
  37. package/dist/components/alert/Alert.styles.js +5 -5
  38. package/dist/components/button/Button.js +29 -23
  39. package/dist/components/button/Button.styles.js +5 -5
  40. package/dist/components/context-menu/ContextMenu.js +123 -72
  41. package/dist/components/context-menu/ContextMenu.styles.js +5 -5
  42. package/dist/components/dialog/Dialog.js +73 -40
  43. package/dist/components/dialog/Dialog.styles.js +5 -5
  44. package/dist/components/form/Form.js +51 -32
  45. package/dist/components/form/Form.styles.js +5 -5
  46. package/dist/components/icon/Icon.js +53 -36
  47. package/dist/components/icon/Icon.styles.js +5 -5
  48. package/dist/components/icon-button/IconButton.js +44 -36
  49. package/dist/components/icon-button/IconButton.styles.js +5 -5
  50. package/dist/components/input/Input.js +161 -112
  51. package/dist/components/input/Input.styles.js +5 -5
  52. package/dist/components/menu/Menu.js +108 -58
  53. package/dist/components/menu/Menu.styles.js +5 -5
  54. package/dist/components/menu-item/MenuItem.js +67 -37
  55. package/dist/components/menu-item/MenuItem.styles.js +5 -5
  56. package/dist/components/panel/Panel.js +11 -10
  57. package/dist/components/panel/Panel.styles.js +5 -5
  58. package/dist/components/progress-ring/ProgressRing.js +70 -45
  59. package/dist/components/progress-ring/ProgressRing.styles.js +5 -5
  60. package/dist/components/spinner/Spinner.js +9 -9
  61. package/dist/components/spinner/Spinner.styles.js +5 -5
  62. package/dist/components/split-panel/SplitPanel.js +127 -66
  63. package/dist/components/split-panel/SplitPanel.styles.js +5 -5
  64. package/dist/components/split-panel/Splitter.js +29 -23
  65. package/dist/components/split-panel/Splitter.styles.js +5 -5
  66. package/dist/components/tooltip/Tooltip.js +115 -74
  67. package/dist/components/tooltip/Tooltip.styles.js +5 -5
  68. package/dist/index.js +18 -40
  69. package/dist/internals/attribute-converters.js +10 -8
  70. package/dist/internals/icons.js +41 -66
  71. package/dist/internals/node-helpers.js +16 -17
  72. package/dist/utilities/BrowserStorage.d.ts +43 -0
  73. package/dist/utilities/BrowserStorage.js +87 -0
  74. package/dist/utilities/decorators.js +19 -14
  75. package/dist/utilities/index.d.ts +1 -1
  76. package/dist/utilities/notifier.js +62 -20
  77. package/dist/utilities/theme.d.ts +38 -26
  78. package/dist/utilities/theme.js +110 -85
  79. package/package.json +2 -2
  80. package/dist/utilities/storage.d.ts +0 -60
  81. package/dist/utilities/storage.js +0 -120
@@ -1,36 +1,63 @@
1
- import { html as d, nothing as n } from "lit";
2
- import { property as s } from "lit/decorators.js";
3
- import { BaseElement as o } from "../BaseElement.js";
4
- import { styles as p } from "./MenuItem.styles.js";
5
- var u = Object.defineProperty, i = (l, e, c, f) => {
6
- for (var t = void 0, a = l.length - 1, h; a >= 0; a--)
7
- (h = l[a]) && (t = h(e, c, t) || t);
8
- return t && u(e, c, t), t;
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 r extends o {
15
+ class MenuItem extends BaseElement {
11
16
  constructor() {
12
- super(...arguments), this.disabled = !1, this.selected = !1, this.checked = !1, this.checkable = !1, this.value = "", this.handleClick = (e) => {
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(), e.stopPropagation();
26
+ e.preventDefault();
27
+ e.stopPropagation();
15
28
  return;
16
29
  }
17
- this.checkable ? (this.checked = !this.checked, this.emit("u-check", { checked: this.checked })) : this.emit("u-select", { value: this.value });
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, p];
39
+ this.styles = [super.styles, styles];
22
40
  }
23
41
  static {
24
42
  this.dependencies = {};
25
43
  }
26
44
  connectedCallback() {
27
- super.connectedCallback(), this.setAttribute("role", "menuitem"), this.setAttribute("tabindex", this.disabled ? "-1" : "0");
45
+ super.connectedCallback();
46
+ this.setAttribute("role", "menuitem");
47
+ this.setAttribute("tabindex", this.disabled ? "-1" : "0");
28
48
  }
29
- updated(e) {
30
- super.updated(e), e.has("disabled") && (this.setAttribute("tabindex", this.disabled ? "-1" : "0"), this.setAttribute("aria-disabled", this.disabled ? "true" : "false")), e.has("checked") && this.setAttribute("aria-checked", this.checked ? "true" : "false");
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 d`
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
- return this.checkable ? d`
73
+ if (this.checkable) {
74
+ return html`
47
75
  <span class="checker" ?checked=${this.checked}>✓</span>
48
- ` : n;
76
+ `;
77
+ } else {
78
+ return nothing;
79
+ }
49
80
  }
50
81
  }
51
- i([
52
- s({ type: Boolean, reflect: !0 })
53
- ], r.prototype, "disabled");
54
- i([
55
- s({ type: Boolean, reflect: !0 })
56
- ], r.prototype, "selected");
57
- i([
58
- s({ type: Boolean, reflect: !0 })
59
- ], r.prototype, "checked");
60
- i([
61
- s({ type: Boolean })
62
- ], r.prototype, "checkable");
63
- i([
64
- s({ type: String })
65
- ], r.prototype, "value");
66
- export {
67
- r as MenuItem
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 as e } from "lit";
2
- const r = e`
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
- export {
63
- r as styles
64
- };
63
+
64
+ export { styles };
@@ -1,20 +1,21 @@
1
- import { html as e } from "lit";
2
- import { BaseElement as s } from "../BaseElement.js";
3
- import { styles as t } from "./Panel.styles.js";
4
- class o extends s {
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, t];
7
+ this.styles = [super.styles, styles];
7
8
  }
8
9
  static {
9
10
  this.dependencies = {};
10
11
  }
11
12
  connectedCallback() {
12
- super.connectedCallback(), this.classList.add("scrollable");
13
+ super.connectedCallback();
14
+ this.classList.add("scrollable");
13
15
  }
14
16
  render() {
15
- return e`<slot></slot>`;
17
+ return html`<slot></slot>`;
16
18
  }
17
19
  }
18
- export {
19
- o as Panel
20
- };
20
+
21
+ export { Panel };
@@ -1,5 +1,6 @@
1
- import { css as t } from "lit";
2
- const s = t`
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
- export {
11
- s as styles
12
- };
11
+
12
+ export { styles };
@@ -1,48 +1,65 @@
1
- import { html as d } from "lit";
2
- import { state as n, property as h } from "lit/decorators.js";
3
- import { BaseElement as c } from "../BaseElement.js";
4
- import { styles as m } from "./ProgressRing.styles.js";
5
- var y = Object.defineProperty, a = (p, r, s, o) => {
6
- for (var e = void 0, l = p.length - 1, u; l >= 0; l--)
7
- (u = p[l]) && (e = u(r, s, e) || e);
8
- return e && y(r, s, e), e;
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 t = 100;
11
- class i extends c {
15
+ const PATH_LENGTH = 100;
16
+ class ProgressRing extends BaseElement {
12
17
  constructor() {
13
- super(...arguments), this.progress = 0, this.dasharray = t.toString(), this.variant = "smooth", this.minValue = 0, this.maxValue = 100, this.value = 0;
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, m];
27
+ this.styles = [super.styles, styles];
17
28
  }
18
29
  static {
19
30
  this.dependencies = {};
20
31
  }
21
- willUpdate(r) {
22
- super.willUpdate(r), r.has("variant") && (this.dasharray = this.updateDashArray(this.variant)), (r.has("minValue") || r.has("maxValue") || r.has("value")) && (this.progress = this.updateProgress(this.minValue, this.maxValue, this.value));
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 d`
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="${t}"
47
+ pathLength="${PATH_LENGTH}"
31
48
  stroke="white"
32
- stroke-dasharray="${t}"
33
- stroke-dashoffset="${t * (1 - this.progress)}"
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="${t}"
57
+ pathLength="${PATH_LENGTH}"
41
58
  stroke-dasharray="${this.dasharray}"
42
59
  ></circle>
43
60
  <circle
44
61
  class="indicator"
45
- pathLength="${t}"
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(r, s, o) {
55
- return r = Number(r ?? 0), s = Number(s ?? 100), o = Math.min(Math.max(Number(o ?? 0), r), s), s === r ? 0 : (o - r) / (s - r);
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(r) {
62
- return r === "ticks" ? "1 1" : r === "blocks" ? "8 2" : t.toString();
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
- a([
66
- n()
67
- ], i.prototype, "progress");
68
- a([
69
- n()
70
- ], i.prototype, "dasharray");
71
- a([
72
- h({ type: String, reflect: !0 })
73
- ], i.prototype, "variant");
74
- a([
75
- h({ type: Number })
76
- ], i.prototype, "minValue");
77
- a([
78
- h({ type: Number })
79
- ], i.prototype, "maxValue");
80
- a([
81
- h({ type: Number })
82
- ], i.prototype, "value");
83
- export {
84
- i as ProgressRing
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 as t } from "lit";
2
- const r = t`
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
- export {
52
- r as styles
53
- };
52
+
53
+ export { styles };
@@ -1,15 +1,16 @@
1
- import { html as s } from "lit";
2
- import { BaseElement as e } from "../BaseElement.js";
3
- import { styles as r } from "./Spinner.styles.js";
4
- class a extends e {
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, r];
7
+ this.styles = [super.styles, styles];
7
8
  }
8
9
  static {
9
10
  this.dependencies = {};
10
11
  }
11
12
  render() {
12
- return s`
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
- export {
21
- a as Spinner
22
- };
21
+
22
+ export { Spinner };
@@ -1,5 +1,6 @@
1
- import { css as r } from "lit";
2
- const t = r`
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
- export {
56
- t as styles
57
- };
56
+
57
+ export { styles };
@@ -1,86 +1,147 @@
1
- import { html as f } from "lit";
2
- import { property as p } from "lit/decorators.js";
3
- import { arrayAttributeConverter as g } from "../../internals/attribute-converters.js";
4
- import { BaseElement as v } from "../BaseElement.js";
5
- import { Panel as c } from "../panel/Panel.js";
6
- import { Splitter as u } from "./Splitter.js";
7
- import { styles as y } from "./SplitPanel.styles.js";
8
- var S = Object.defineProperty, d = (a, s, r, o) => {
9
- for (var t = void 0, e = a.length - 1, i; e >= 0; e--)
10
- (i = a[e]) && (t = i(s, r, t) || t);
11
- return t && S(s, r, t), t;
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 m extends v {
18
+ class SplitPanel extends BaseElement {
14
19
  constructor() {
15
- super(...arguments), this.panels = [], this.splitters = [], this.isDragging = !1, this.currentSplitter = null, this.totalSize = 0, this.startPosition = 0, this.startRatio = [], this.orientation = "horizontal", this.ratio = [], this.handleSlotChange = async (s) => {
16
- const t = s.target.assignedElements({ flatten: !0 }).filter((e) => e instanceof c);
17
- if (!(this.panels.length === t.length && this.panels.every((e, i) => e === t[i]))) {
18
- if (this.splitters.forEach((e) => e.remove()), this.splitters = [], this.panels = t, t.forEach((e, i) => {
19
- if (i === t.length - 1)
20
- return;
21
- const n = new u();
22
- n.orientation = this.orientation, n.addEventListener("mousedown", this.handleMouseDown), this.splitters.push(n), e.after(n);
23
- }), this.ratio.length === t.length) {
24
- const e = this.ratio.reduce((i, n) => i + n, 0);
25
- t.forEach((i, n) => {
26
- const l = this.ratio[n] / e * 100;
27
- i.style.flex = `${l} 1 0%`;
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
- } else
31
- t.forEach((e) => {
32
- e.style.flex = `${100 / t.length} 1 0%`;
33
- });
34
- this.requestUpdate(), await this.updateComplete;
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
- }, this.handleMouseDown = (s) => {
37
- s.preventDefault();
38
- const r = s.currentTarget;
39
- this.currentSplitter = r, this.isDragging = !0, this.startPosition = this.orientation === "horizontal" ? s.clientX : s.clientY;
40
- const o = this.getBoundingClientRect(), t = this.orientation === "horizontal" ? o.width : o.height, e = this.splitters.reduce((i, n) => i + n.size, 0);
41
- this.totalSize = t - e, this.startRatio = this.panels.map((i) => {
42
- const n = i.getBoundingClientRect();
43
- return (this.orientation === "horizontal" ? n.width : n.height) / this.totalSize * 100;
44
- }), r.dragging = !0, document.addEventListener("mousemove", this.handleMouseMove), document.addEventListener("mouseup", this.handleMouseUp), document.body.style.userSelect = "none", document.body.style.cursor = this.orientation === "horizontal" ? "col-resize" : "row-resize";
45
- }, this.handleMouseMove = (s) => {
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
- s.preventDefault();
48
- const o = (this.orientation === "horizontal" ? s.clientX : s.clientY) - this.startPosition, t = this.splitters.indexOf(this.currentSplitter);
49
- if (t === -1) return;
50
- const e = this.panels[t], i = this.panels[t + 1];
51
- if (!e || !i) return;
52
- const n = o / this.totalSize * 100, l = this.startRatio[t] + n, h = this.startRatio[t + 1] - n;
53
- l < 0 || h < 0 || (e.style.flex = `${l} 1 0%`, i.style.flex = `${h} 1 0%`);
54
- }, this.handleMouseUp = (s) => {
55
- this.isDragging && (this.isDragging = !1, this.currentSplitter && (this.currentSplitter.dragging = !1, this.currentSplitter = null), document.removeEventListener("mousemove", this.handleMouseMove), document.removeEventListener("mouseup", this.handleMouseUp), document.body.style.userSelect = "", document.body.style.cursor = "");
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, y];
117
+ this.styles = [super.styles, styles];
60
118
  }
61
119
  static {
62
120
  this.dependencies = {
63
- "u-panel": c,
64
- "u-splitter": u
121
+ "u-panel": Panel,
122
+ "u-splitter": Splitter
65
123
  };
66
124
  }
67
125
  disconnectedCallback() {
68
- document.removeEventListener("mousemove", this.handleMouseMove), document.removeEventListener("mouseup", this.handleMouseUp), this.splitters.forEach((s) => {
69
- s.removeEventListener("mousedown", this.handleMouseDown), s.remove();
70
- }), super.disconnectedCallback();
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 f`
135
+ return html`
74
136
  <slot @slotchange=${this.handleSlotChange}></slot>
75
137
  `;
76
138
  }
77
139
  }
78
- d([
79
- p({ type: String, reflect: !0 })
80
- ], m.prototype, "orientation");
81
- d([
82
- p({ type: Array, converter: g(parseFloat) })
83
- ], m.prototype, "ratio");
84
- export {
85
- m as SplitPanel
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 };