easy-component-ui 3.0.14 → 3.0.15

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 (167) hide show
  1. package/dist/assets/icon.css +1 -0
  2. package/dist/components/Base.js +941 -0
  3. package/dist/components/ea-alert.js +213 -0
  4. package/dist/components/ea-avatar.js +164 -0
  5. package/dist/components/ea-backtop.js +136 -0
  6. package/dist/components/ea-badge.js +144 -0
  7. package/dist/components/ea-breadcrumb.js +148 -0
  8. package/dist/components/ea-button.js +266 -0
  9. package/dist/components/ea-calendar.js +10 -0
  10. package/dist/components/ea-calendar2.js +673 -0
  11. package/dist/components/ea-card.js +121 -0
  12. package/dist/components/ea-carousel.js +415 -0
  13. package/dist/components/ea-checkbox.js +446 -0
  14. package/dist/components/ea-collapse.js +313 -0
  15. package/dist/components/ea-color-picker.js +888 -0
  16. package/dist/components/ea-container.js +206 -0
  17. package/dist/components/ea-countdown.js +142 -0
  18. package/dist/components/ea-date-picker.js +649 -0
  19. package/dist/components/ea-descriptions.js +474 -0
  20. package/dist/components/ea-dialog.js +249 -0
  21. package/dist/components/ea-drawer.js +216 -0
  22. package/dist/components/ea-dropdown.js +228 -0
  23. package/dist/components/ea-empty.js +93 -0
  24. package/dist/components/ea-icon.js +159 -0
  25. package/dist/components/ea-image-preview.js +532 -0
  26. package/dist/components/ea-image.js +327 -0
  27. package/dist/components/ea-infinite-scroll.js +109 -0
  28. package/dist/components/ea-input-number.js +367 -0
  29. package/dist/components/ea-input.js +588 -0
  30. package/dist/components/ea-layout.js +132 -0
  31. package/dist/components/ea-link.js +101 -0
  32. package/dist/components/ea-menu.js +433 -0
  33. package/dist/components/ea-message-box.js +624 -0
  34. package/dist/components/ea-message.js +313 -0
  35. package/dist/components/ea-notification.js +331 -0
  36. package/dist/components/ea-overlay.js +168 -0
  37. package/dist/components/ea-page-header.js +108 -0
  38. package/dist/components/ea-pagination.js +481 -0
  39. package/dist/components/ea-popconfirm.js +275 -0
  40. package/dist/components/ea-popover.js +147 -0
  41. package/dist/components/ea-popper.js +203 -0
  42. package/dist/components/ea-progress.js +286 -0
  43. package/dist/components/ea-radio.js +364 -0
  44. package/dist/components/ea-rate.js +241 -0
  45. package/dist/components/ea-result.js +100 -0
  46. package/dist/components/ea-scrollbar.js +235 -0
  47. package/dist/components/ea-segmented.js +215 -0
  48. package/dist/components/ea-select.js +609 -0
  49. package/dist/components/ea-skeleton.js +263 -0
  50. package/dist/components/ea-slider.js +430 -0
  51. package/dist/components/ea-space.js +123 -0
  52. package/dist/components/ea-splitter.js +233 -0
  53. package/dist/components/ea-statistic.js +74 -0
  54. package/dist/components/ea-steps.js +346 -0
  55. package/dist/components/ea-switch.js +271 -0
  56. package/dist/components/ea-table.js +1137 -0
  57. package/dist/components/ea-tabs.js +503 -0
  58. package/dist/components/ea-tag.js +228 -0
  59. package/dist/components/ea-text.js +113 -0
  60. package/dist/components/ea-time-picker.js +510 -0
  61. package/dist/components/ea-timeline.js +185 -0
  62. package/dist/components/ea-tooltip.js +161 -0
  63. package/dist/components/ea-tour.js +544 -0
  64. package/dist/components/ea-transfer.js +949 -0
  65. package/dist/components/ea-tree.js +1125 -0
  66. package/dist/components/index.js +60 -0
  67. package/dist/core/FormBase.js +238 -0
  68. package/dist/css/ea-alert.style.js +4 -0
  69. package/dist/css/ea-aside.style.js +4 -0
  70. package/dist/css/ea-avatar.style.js +4 -0
  71. package/dist/css/ea-backtop.style.js +4 -0
  72. package/dist/css/ea-badge.style.js +4 -0
  73. package/dist/css/ea-breadcrumb-item.style.js +4 -0
  74. package/dist/css/ea-breadcrumb.style.js +4 -0
  75. package/dist/css/ea-button-group.style.js +4 -0
  76. package/dist/css/ea-button.style.js +4 -0
  77. package/dist/css/ea-calendar.style.js +4 -0
  78. package/dist/css/ea-card.style.js +4 -0
  79. package/dist/css/ea-carousel-item.style.js +4 -0
  80. package/dist/css/ea-carousel.style.js +4 -0
  81. package/dist/css/ea-check-tag.style.js +4 -0
  82. package/dist/css/ea-checkbox-group.style.js +4 -0
  83. package/dist/css/ea-checkbox.style.js +4 -0
  84. package/dist/css/ea-col.style.js +4 -0
  85. package/dist/css/ea-collapse-item.style.js +4 -0
  86. package/dist/css/ea-collapse.style.js +4 -0
  87. package/dist/css/ea-color-picker-panel.style.js +4 -0
  88. package/dist/css/ea-color-picker.style.js +4 -0
  89. package/dist/css/ea-container.style.js +4 -0
  90. package/dist/css/ea-date-picker.style.js +4 -0
  91. package/dist/css/ea-descriptions-item.style.js +4 -0
  92. package/dist/css/ea-descriptions.style.js +4 -0
  93. package/dist/css/ea-dialog.style.js +4 -0
  94. package/dist/css/ea-drawer.style.js +4 -0
  95. package/dist/css/ea-dropdown-item.style.js +4 -0
  96. package/dist/css/ea-dropdown-menu.style.js +4 -0
  97. package/dist/css/ea-dropdown.style.js +4 -0
  98. package/dist/css/ea-empty.style.js +4 -0
  99. package/dist/css/ea-footer.style.js +4 -0
  100. package/dist/css/ea-header.style.js +4 -0
  101. package/dist/css/ea-icon.style.js +4 -0
  102. package/dist/css/ea-image-preview.style.js +4 -0
  103. package/dist/css/ea-image.style.js +4 -0
  104. package/dist/css/ea-infinite-scroll.style.js +4 -0
  105. package/dist/css/ea-input-number.style.js +4 -0
  106. package/dist/css/ea-input.style.js +4 -0
  107. package/dist/css/ea-link.style.js +4 -0
  108. package/dist/css/ea-main.style.js +4 -0
  109. package/dist/css/ea-menu-item-group.style.js +4 -0
  110. package/dist/css/ea-menu-item.style.js +4 -0
  111. package/dist/css/ea-menu.style.js +4 -0
  112. package/dist/css/ea-message-box.style.js +4 -0
  113. package/dist/css/ea-message.style.js +4 -0
  114. package/dist/css/ea-notification.style.js +4 -0
  115. package/dist/css/ea-option-gropu.style.js +4 -0
  116. package/dist/css/ea-option.style.js +4 -0
  117. package/dist/css/ea-overlay.style.js +4 -0
  118. package/dist/css/ea-page-header.style.js +4 -0
  119. package/dist/css/ea-pagination.style.js +4 -0
  120. package/dist/css/ea-popconfirm.style.js +4 -0
  121. package/dist/css/ea-popover.style.js +4 -0
  122. package/dist/css/ea-popper.style.js +4 -0
  123. package/dist/css/ea-progress.style.js +4 -0
  124. package/dist/css/ea-radio-group.style.js +4 -0
  125. package/dist/css/ea-radio.style.js +4 -0
  126. package/dist/css/ea-rate.style.js +4 -0
  127. package/dist/css/ea-result.style.js +4 -0
  128. package/dist/css/ea-row.style.js +4 -0
  129. package/dist/css/ea-scrollbar.style.js +4 -0
  130. package/dist/css/ea-segmented.style.js +4 -0
  131. package/dist/css/ea-select.style.js +4 -0
  132. package/dist/css/ea-skeleton-item.style.js +4 -0
  133. package/dist/css/ea-skeleton.style.js +4 -0
  134. package/dist/css/ea-slider.style.js +4 -0
  135. package/dist/css/ea-space.style.js +4 -0
  136. package/dist/css/ea-splitter-bar.style.js +4 -0
  137. package/dist/css/ea-splitter-panel.style.js +4 -0
  138. package/dist/css/ea-splitter.style.js +4 -0
  139. package/dist/css/ea-statistic.style.js +4 -0
  140. package/dist/css/ea-step.style.js +4 -0
  141. package/dist/css/ea-steps.style.js +4 -0
  142. package/dist/css/ea-sub-menu.style.js +4 -0
  143. package/dist/css/ea-switch.style.js +4 -0
  144. package/dist/css/ea-tab-panel.style.js +4 -0
  145. package/dist/css/ea-tab.style.js +4 -0
  146. package/dist/css/ea-table-column.style.js +4 -0
  147. package/dist/css/ea-table.style.js +4 -0
  148. package/dist/css/ea-tabs.style.js +4 -0
  149. package/dist/css/ea-tag.style.js +4 -0
  150. package/dist/css/ea-text.style.js +4 -0
  151. package/dist/css/ea-time-picker.style.js +4 -0
  152. package/dist/css/ea-timeline-item.style.js +4 -0
  153. package/dist/css/ea-timeline.style.js +4 -0
  154. package/dist/css/ea-tooltip.style.js +4 -0
  155. package/dist/css/ea-tour-step.style.js +4 -0
  156. package/dist/css/ea-tour.style.js +4 -0
  157. package/dist/css/ea-transfer.style.js +5 -0
  158. package/dist/css/ea-tree.style.js +6 -0
  159. package/dist/css/ea-ui-component.style.js +4 -0
  160. package/dist/favicon.ico +0 -0
  161. package/dist/utils/Color.js +439 -0
  162. package/dist/utils/I18nManager.js +218 -0
  163. package/dist/utils/Utils.js +65 -0
  164. package/dist/utils/Variables.js +12 -0
  165. package/dist/utils/parseTime.js +73 -0
  166. package/dist/utils/timeout.js +9 -0
  167. package/package.json +1 -1
@@ -0,0 +1,241 @@
1
+ var A = Object.defineProperty;
2
+ var _ = (s) => {
3
+ throw TypeError(s);
4
+ };
5
+ var S = (s, i, t) => i in s ? A(s, i, { enumerable: !0, configurable: !0, writable: !0, value: t }) : s[i] = t;
6
+ var C = (s, i, t) => S(s, typeof i != "symbol" ? i + "" : i, t), x = (s, i, t) => i.has(s) || _("Cannot " + t);
7
+ var e = (s, i, t) => (x(s, i, "read from private field"), t ? t.call(s) : i.get(s)), n = (s, i, t) => i.has(s) ? _("Cannot add the same private member more than once") : i instanceof WeakSet ? i.add(s) : i.set(s, t), b = (s, i, t, a) => (x(s, i, "write to private field"), a ? a.call(s, t) : i.set(s, t), t);
8
+ import { F as V } from "../core/FormBase.js";
9
+ import { s as L } from "../css/ea-rate.style.js";
10
+ import { E as M } from "../utils/Variables.js";
11
+ var r, p, d, u, v, c, m, y, f, g;
12
+ class R extends V {
13
+ constructor() {
14
+ super();
15
+ /** @type {HTMLElement} */
16
+ n(this, r);
17
+ /** @type {HTMLElement} */
18
+ n(this, p);
19
+ /** @type {AbortController} */
20
+ n(this, d, new AbortController());
21
+ /** @type {AbortController} */
22
+ n(this, u, new AbortController());
23
+ C(this, "state", this.properties({
24
+ label: {
25
+ type: String,
26
+ default: "",
27
+ observer: async (t) => {
28
+ e(this, p).textContent = t;
29
+ }
30
+ },
31
+ value: {
32
+ type: Number,
33
+ default: 0,
34
+ observer: (t) => {
35
+ this.setValue(t), e(this, c).call(this, t - 1);
36
+ }
37
+ },
38
+ max: {
39
+ type: Number,
40
+ default: 5,
41
+ observer: () => {
42
+ }
43
+ },
44
+ size: {
45
+ type: M,
46
+ default: "",
47
+ observer: () => {
48
+ this.updateContainerClasslist();
49
+ }
50
+ },
51
+ readonly: {
52
+ type: Boolean,
53
+ default: !1,
54
+ observer: () => {
55
+ }
56
+ },
57
+ disabled: {
58
+ type: Boolean,
59
+ default: !1,
60
+ observer: () => {
61
+ this.updateContainerClasslist();
62
+ }
63
+ }
64
+ }));
65
+ C(this, "funcStates", this.properties({
66
+ getSymbol: {
67
+ props: !0,
68
+ type: Function,
69
+ rawFunction: !0,
70
+ /**
71
+ * 获取图标
72
+ * @param {string} [value]
73
+ * @param {boolean} [isSelected]
74
+ * @returns {string}
75
+ */
76
+ default: () => () => '<ea-icon name="star" part="icon"></ea-icon>',
77
+ /** @param {Function} cb */
78
+ observer: (t) => {
79
+ !t || typeof t != "function" || (e(this, r).innerHTML = e(this, v).call(this, t), e(this, c).call(this, this.value - 1));
80
+ }
81
+ }
82
+ }));
83
+ /**
84
+ * 渲染 rate 元素
85
+ * @param {(value: Number, isSelected: Boolean) => String} renderer
86
+ * @param {Number} activeValue
87
+ * @return {String}
88
+ */
89
+ n(this, v, (t, a = this.value, h = this.max) => {
90
+ if (!t) return;
91
+ const l = Array.from({ length: h }).map(
92
+ (o, E) => `
93
+ <span class='ea-rate__symbol' part='symbol-wrap'>
94
+ ${t(E, a)}
95
+ </span>`
96
+ ).join("");
97
+ return e(this, r).innerHTML = l, l;
98
+ });
99
+ /**
100
+ * 设置 rate 元素选中状态
101
+ * @param {Number} index
102
+ */
103
+ n(this, c, (t = this.value - 1) => {
104
+ [...e(this, r).children].forEach((h, l) => {
105
+ h.classList.toggle("is-selected", l <= t);
106
+ });
107
+ });
108
+ /**
109
+ * 取消 rate 元素选中状态
110
+ * @param {Number} [currentValue]
111
+ */
112
+ n(this, m, (t = this.value - 1) => {
113
+ [...e(this, r).children].forEach((h, l) => {
114
+ h.classList.toggle("is-selected", l <= t);
115
+ });
116
+ });
117
+ /**
118
+ * 触发 hover 事件
119
+ * @param {Number} [value]
120
+ * @param {HTMLElement} [target]
121
+ */
122
+ n(this, y, (t = this.value, a = null) => {
123
+ this.emit("hover", {
124
+ detail: {
125
+ value: t,
126
+ target: a
127
+ }
128
+ });
129
+ });
130
+ /**
131
+ * 当鼠标移入父元素时,设置子元素的选中状态
132
+ */
133
+ n(this, f, () => {
134
+ var h;
135
+ if (this.readonly || this.disabled) return;
136
+ (h = e(this, u)) == null || h.abort(), b(this, u, new AbortController());
137
+ const t = (l) => {
138
+ const o = l.target.closest(".ea-rate__symbol"), w = [...e(this, r).children].indexOf(o);
139
+ e(this, c).call(this, w), o && e(this, y).call(this, w, o);
140
+ }, a = () => {
141
+ const l = this.hasAttribute("value") ? this.value - 1 : null, o = this.children[l];
142
+ e(this, m).call(this), e(this, y).call(this, l, o);
143
+ };
144
+ e(this, r).addEventListener("mousemove", t, {
145
+ signal: e(this, u).signal
146
+ }), e(this, r).addEventListener("mouseout", a, {
147
+ signal: e(this, u).signal
148
+ });
149
+ });
150
+ /**
151
+ * 通过监听父元素的点击事件,设置子元素的选中状态
152
+ */
153
+ n(this, g, (t) => {
154
+ if (this.readonly || this.disabled) return;
155
+ const a = t.target.closest(".ea-rate__symbol"), o = [...e(this, r).children].indexOf(a) + 1;
156
+ this.value === o ? (this.value = 0, e(this, m).call(this, 0)) : this.value = o, this.emit("change", { detail: { value: o } });
157
+ });
158
+ this.stylesheet = L, this.$render();
159
+ }
160
+ static get observedAttributes() {
161
+ return [
162
+ ...super.observedAttributes,
163
+ "label",
164
+ "value",
165
+ "max",
166
+ "size",
167
+ "readonly",
168
+ "disabled"
169
+ ];
170
+ }
171
+ /**
172
+ * 获取 classlist 列表
173
+ * @return {string} 属性值
174
+ */
175
+ updateContainerClasslist() {
176
+ const t = this.computedClasslist(
177
+ "ea-rate",
178
+ {
179
+ ["--" + this.size]: this.size
180
+ },
181
+ {
182
+ disabled: this.disabled
183
+ }
184
+ );
185
+ return e(this, r).className = t, t;
186
+ }
187
+ $render() {
188
+ this.shadowRoot.innerHTML = `
189
+ <label class="ea-rate__label" part="label"></label>
190
+ <div class='ea-rate' part='container'></div>
191
+ `, b(this, p, this.shadowRoot.querySelector(".ea-rate__label")), b(this, r, this.shadowRoot.querySelector(".ea-rate")), e(this, v).call(this, this.getSymbol), this.updateContainerClasslist();
192
+ }
193
+ /**
194
+ * 获取验证目标元素
195
+ * @returns {HTMLElement}
196
+ */
197
+ get validationTarget() {
198
+ return this;
199
+ }
200
+ /**
201
+ * 更新表单验证状态
202
+ */
203
+ updateValidity() {
204
+ this.required && !this.value ? this.internals.setValidity(
205
+ { valueMissing: !0 },
206
+ "请选择一个评分",
207
+ this
208
+ ) : this.internals.setValidity({}, "", this);
209
+ }
210
+ /**
211
+ * 检查表单字段的有效性
212
+ * @returns {boolean} 如果字段有效返回 true,否则返回 false
213
+ */
214
+ checkValidity() {
215
+ return this.updateValidity(), this.internals.checkValidity();
216
+ }
217
+ /**
218
+ * 报告表单字段的有效性(显示验证提示)
219
+ * @returns {boolean} 如果字段有效返回 true,否则返回 false
220
+ */
221
+ reportValidity() {
222
+ return this.updateValidity(), this.internals.reportValidity();
223
+ }
224
+ connectedCallback() {
225
+ var t;
226
+ super.connectedCallback(), (t = e(this, d)) == null || t.abort(), b(this, d, new AbortController()), e(this, r).addEventListener("mouseover", e(this, f), {
227
+ signal: e(this, d).signal
228
+ }), e(this, r).addEventListener("click", e(this, g), {
229
+ signal: e(this, d).signal
230
+ });
231
+ }
232
+ $beforeUnmounted() {
233
+ var t, a;
234
+ (t = e(this, d)) == null || t.abort(), (a = e(this, u)) == null || a.abort();
235
+ }
236
+ }
237
+ r = new WeakMap(), p = new WeakMap(), d = new WeakMap(), u = new WeakMap(), v = new WeakMap(), c = new WeakMap(), m = new WeakMap(), y = new WeakMap(), f = new WeakMap(), g = new WeakMap();
238
+ window.customElements.get("ea-rate") || window.customElements.define("ea-rate", R);
239
+ export {
240
+ R as EaRate
241
+ };
@@ -0,0 +1,100 @@
1
+ var b = Object.defineProperty;
2
+ var h = (e) => {
3
+ throw TypeError(e);
4
+ };
5
+ var y = (e, s, t) => s in e ? b(e, s, { enumerable: !0, configurable: !0, writable: !0, value: t }) : e[s] = t;
6
+ var p = (e, s, t) => y(e, typeof s != "symbol" ? s + "" : s, t), _ = (e, s, t) => s.has(e) || h("Cannot " + t);
7
+ var i = (e, s, t) => (_(e, s, "read from private field"), t ? t.call(e) : s.get(e)), a = (e, s, t) => s.has(e) ? h("Cannot add the same private member more than once") : s instanceof WeakSet ? s.add(e) : s.set(e, t), o = (e, s, t, d) => (_(e, s, "write to private field"), d ? d.call(e, t) : s.set(e, t), t);
8
+ import { B as v } from "./Base.js";
9
+ import { s as f } from "../css/ea-result.style.js";
10
+ import { t as m } from "../utils/Variables.js";
11
+ var l, r, n, u, c;
12
+ class w extends v {
13
+ constructor() {
14
+ super();
15
+ /** @type {HTMLElement} */
16
+ a(this, l);
17
+ /** @type {HTMLElement} */
18
+ a(this, r);
19
+ /** @type {HTMLElement} */
20
+ a(this, n);
21
+ /** @type {HTMLElement} */
22
+ a(this, u);
23
+ /** @type {HTMLElement} */
24
+ a(this, c);
25
+ p(this, "state", this.properties({
26
+ type: {
27
+ type: ["primary", "success", "warning", "info", "error"],
28
+ default: "",
29
+ observer: (t) => {
30
+ i(this, r).setAttribute("name", m[t]), this.updateContainerClasslist();
31
+ }
32
+ },
33
+ title: {
34
+ type: String,
35
+ default: "",
36
+ observer: (t) => {
37
+ i(this, n).textContent = t;
38
+ }
39
+ },
40
+ "sub-title": {
41
+ type: String,
42
+ default: "",
43
+ observer: (t) => {
44
+ i(this, u).textContent = t;
45
+ }
46
+ },
47
+ icon: {
48
+ type: String,
49
+ default: "",
50
+ observer: (t) => {
51
+ t ? i(this, r).setAttribute("name", t) : i(this, r).setAttribute("name", m[this.type]);
52
+ }
53
+ }
54
+ }));
55
+ this.stylesheet = f, this.$render();
56
+ }
57
+ static get observedAttributes() {
58
+ return [...super.observedAttributes, "type", "title", "sub-title", "icon"];
59
+ }
60
+ /**
61
+ * 获取 classlist 列表
62
+ * @return {string} 属性值
63
+ */
64
+ updateContainerClasslist() {
65
+ const t = this.computedClasslist("ea-result", {
66
+ ["--" + this.type]: this.type
67
+ });
68
+ return i(this, l).className = t, t;
69
+ }
70
+ $render() {
71
+ this.shadowRoot.innerHTML = `
72
+ <div class='ea-result' part='container'>
73
+ <div class="ea-result__icon ea-result__icon-wrap" part="icon-wrap">
74
+ <slot name="icon">
75
+ <ea-icon class="ea-result__icon ea-result__default-icon" part="icon"></ea-icon>
76
+ </slot>
77
+ </div>
78
+ <div class="ea-result__title" part="title">
79
+ <slot name="title"></slot>
80
+ </div>
81
+ <div class="ea-result__sub-title" part="sub-title">
82
+ <slot name="sub-title"></slot>
83
+ </div>
84
+ <div class="ea-result__extra" part="extra">
85
+ <slot name="extra"></slot>
86
+ </div>
87
+ </div>
88
+ `, o(this, l, this.shadowRoot.querySelector(".ea-result")), o(this, r, this.shadowRoot.querySelector(".ea-result__default-icon")), o(this, n, this.shadowRoot.querySelector(".ea-result__title slot")), o(this, u, this.shadowRoot.querySelector(
89
+ ".ea-result__sub-title slot"
90
+ )), o(this, c, this.shadowRoot.querySelector(".ea-result__extra slot"));
91
+ }
92
+ connectedCallback() {
93
+ super.connectedCallback();
94
+ }
95
+ }
96
+ l = new WeakMap(), r = new WeakMap(), n = new WeakMap(), u = new WeakMap(), c = new WeakMap();
97
+ window.customElements.get("ea-result") || window.customElements.define("ea-result", w);
98
+ export {
99
+ w as EaResult
100
+ };
@@ -0,0 +1,235 @@
1
+ var z = Object.defineProperty;
2
+ var _ = (o) => {
3
+ throw TypeError(o);
4
+ };
5
+ var R = (o, i, s) => i in o ? z(o, i, { enumerable: !0, configurable: !0, writable: !0, value: s }) : o[i] = s;
6
+ var k = (o, i, s) => R(o, typeof i != "symbol" ? i + "" : i, s), E = (o, i, s) => i.has(o) || _("Cannot " + s);
7
+ var t = (o, i, s) => (E(o, i, "read from private field"), s ? s.call(o) : i.get(o)), r = (o, i, s) => i.has(o) ? _("Cannot add the same private member more than once") : i instanceof WeakSet ? i.add(o) : i.set(o, s), h = (o, i, s, l) => (E(o, i, "write to private field"), l ? l.call(o, s) : i.set(o, s), s);
8
+ import { B as C } from "./Base.js";
9
+ import { s as H } from "../css/ea-scrollbar.style.js";
10
+ var n, b, g, c, a, e, L, u, d, p, f, w, m;
11
+ class S extends C {
12
+ constructor() {
13
+ super();
14
+ /** @type {HTMLElement} */
15
+ r(this, n);
16
+ /** @type {HTMLElement} */
17
+ r(this, b);
18
+ /** @type {HTMLElement} */
19
+ r(this, g);
20
+ /** @type {HTMLElement} */
21
+ r(this, c);
22
+ /** @type {HTMLElement} */
23
+ r(this, a);
24
+ /** @type {HTMLElement} */
25
+ r(this, e);
26
+ r(this, L, {
27
+ verticalScrollDistance: 0,
28
+ horizontalScrollDistance: 0
29
+ });
30
+ /**
31
+ * @typedef {Object} State
32
+ */
33
+ /** @type {State} */
34
+ k(this, "state", this.properties({
35
+ height: {
36
+ type: String,
37
+ default: "",
38
+ observer: (s) => {
39
+ }
40
+ },
41
+ native: {
42
+ type: Boolean,
43
+ default: !1,
44
+ observer: (s) => {
45
+ t(this, n).classList.toggle("ea-scrollbar--native", s);
46
+ }
47
+ },
48
+ noresize: {
49
+ type: Boolean,
50
+ default: !1,
51
+ observer: (s) => {
52
+ t(this, n).classList.toggle("ea-scrollbar--noresize", s);
53
+ }
54
+ },
55
+ always: {
56
+ type: Boolean,
57
+ default: !1,
58
+ observer: (s) => {
59
+ t(this, n).classList.toggle("ea-scrollbar--always", s);
60
+ }
61
+ }
62
+ }));
63
+ /**
64
+ * 滚动事件 - 修改滚动条样式 和 事件派发
65
+ */
66
+ r(this, u, () => {
67
+ t(this, c).style.setProperty(
68
+ "--ea-scrollbar-top",
69
+ `${t(this, e).scrollTop / t(this, e).scrollHeight * 100}%`
70
+ ), t(this, a).style.setProperty(
71
+ "--ea-scrollbar-left",
72
+ `${t(this, e).scrollLeft / t(this, e).scrollWidth * 100}%`
73
+ ), this.dispatchEvent(
74
+ new CustomEvent("scroll", {
75
+ detail: {
76
+ scrollTop: t(this, e).scrollTop,
77
+ scrollLeft: t(this, e).scrollLeft
78
+ }
79
+ })
80
+ );
81
+ const s = {
82
+ left: t(this, e).scrollTop / t(this, e).scrollHeight <= 0,
83
+ right: t(this, e).scrollTop / t(this, e).scrollHeight >= 1,
84
+ top: t(this, e).scrollLeft / t(this, e).scrollWidth <= 0,
85
+ bottom: t(this, e).scrollLeft / t(this, e).scrollWidth >= 1
86
+ };
87
+ Object.keys(s).forEach((l) => {
88
+ s[l] && this.dispatchEvent(
89
+ new CustomEvent("end-reached", {
90
+ detail: {
91
+ direction: l,
92
+ scrollTop: t(this, e).scrollTop,
93
+ scrollLeft: t(this, e).scrollLeft
94
+ }
95
+ })
96
+ );
97
+ });
98
+ });
99
+ /**
100
+ * 页面尺寸改变后,调整滚动条样式
101
+ */
102
+ r(this, d, () => {
103
+ queueMicrotask(() => {
104
+ const s = t(this, e).getBoundingClientRect(), l = s.height / t(this, e).scrollHeight, v = s.width / t(this, e).scrollWidth;
105
+ t(this, c).style.setProperty(
106
+ "--ea-scrollbar-thumb-vertical-height",
107
+ `${l * 100}%`
108
+ ), t(this, a).style.setProperty(
109
+ "--ea-scrollbar-thumb-horizontal-width",
110
+ `${v * 100}%`
111
+ ), t(this, g).classList.toggle(
112
+ "is-show",
113
+ l >= 0.999
114
+ ), t(this, b).classList.toggle(
115
+ "is-show",
116
+ v >= 0.999
117
+ );
118
+ });
119
+ });
120
+ /**
121
+ * 垂直滚动条拖动事件
122
+ * @param {MouseEvent} e
123
+ */
124
+ r(this, p, (s) => {
125
+ const l = t(this, g).getBoundingClientRect(), y = (s.clientY - l.top) / l.height * (t(this, e).scrollHeight - t(this, e).clientHeight);
126
+ t(this, e).scrollTo({
127
+ top: y,
128
+ behavior: "instant"
129
+ }), t(this, c).classList.add("is-active");
130
+ });
131
+ /**
132
+ * 水平滚动条拖动事件
133
+ * @param {MouseEvent} e
134
+ */
135
+ r(this, f, (s) => {
136
+ const l = t(this, b).getBoundingClientRect(), y = (s.clientX - l.left) / l.width * (t(this, e).scrollWidth - t(this, e).clientWidth);
137
+ t(this, e).scrollTo({
138
+ left: y,
139
+ behavior: "instant"
140
+ }), t(this, a).classList.add("is-active");
141
+ });
142
+ /**
143
+ * 鼠标按下事件
144
+ * @param {MouseEvent} e
145
+ */
146
+ r(this, w, (s) => {
147
+ s.preventDefault(), s.stopPropagation();
148
+ const l = new AbortController(), v = s.target === t(this, a);
149
+ window.addEventListener(
150
+ "mousemove",
151
+ v ? t(this, f) : t(this, p),
152
+ { signal: l.signal }
153
+ ), window.addEventListener(
154
+ "mouseup",
155
+ () => {
156
+ l.abort(), t(this, a).classList.remove("is-active"), t(this, c).classList.remove("is-active");
157
+ },
158
+ { signal: l.signal }
159
+ );
160
+ });
161
+ /**
162
+ * 键盘事件
163
+ * @param {KeyboardEvent} e
164
+ */
165
+ r(this, m, (s) => {
166
+ s.key === "ArrowUp" || s.key === "ArrowDown" ? t(this, e).scrollTo({
167
+ top: t(this, e).scrollTop + t(this, e).scrollHeight / 8 * (s.key === "ArrowUp" ? -1 : 1),
168
+ behavior: "smooth"
169
+ }) : (s.key === "ArrowLeft" || s.key === "ArrowRight") && t(this, e).scrollTo({
170
+ left: t(this, e).scrollLeft + t(this, e).scrollWidth / 8 * (s.key === "ArrowLeft" ? -1 : 1),
171
+ behavior: "smooth"
172
+ });
173
+ });
174
+ this.stylesheet = H, this.isMounted = !1;
175
+ }
176
+ static get observedAttributes() {
177
+ return ["native", "noresize", "always"];
178
+ }
179
+ $render() {
180
+ this.shadowRoot.innerHTML = `
181
+ <div class="ea-scrollbar" part="container">
182
+ <div class="ea-scrollbar__track ea-scrollbar__track-horizontal" part="track-horizontal">
183
+ <div class="ea-scrollbar__thumb-horizontal" part="thumb"></div>
184
+ </div>
185
+ <div class="ea-scrollbar__track ea-scrollbar__track-vertical" part="track-vertical">
186
+ <div class="ea-scrollbar__thumb-vertical" part="thumb"></div>
187
+ </div>
188
+ <div class="ea-scrollbar__view" part="view-container">
189
+ <slot></slot>
190
+ </div>
191
+ </div>
192
+ `, h(this, n, this.shadowRoot.querySelector(".ea-scrollbar")), h(this, g, this.shadowRoot.querySelector(
193
+ ".ea-scrollbar__track-vertical"
194
+ )), h(this, b, this.shadowRoot.querySelector(
195
+ ".ea-scrollbar__track-horizontal"
196
+ )), h(this, c, this.shadowRoot.querySelector(
197
+ ".ea-scrollbar__thumb-vertical"
198
+ )), h(this, a, this.shadowRoot.querySelector(
199
+ ".ea-scrollbar__thumb-horizontal"
200
+ )), h(this, e, this.shadowRoot.querySelector(".ea-scrollbar__view")), this.isMounted = !0;
201
+ }
202
+ connectedCallback() {
203
+ super.connectedCallback(), this.$render(), this.native = this.native, this.noresize = this.noresize, this.always = this.always, this.eventController = new AbortController();
204
+ const s = this.eventController;
205
+ t(this, d).call(this), t(this, e).addEventListener("scroll", t(this, u), {
206
+ signal: s.signal
207
+ }), t(this, a).addEventListener("mousedown", t(this, w), {
208
+ signal: s.signal
209
+ }), t(this, c).addEventListener("mousedown", t(this, w), {
210
+ signal: s.signal
211
+ }), this.addEventListener("keydown", t(this, m)), this.noresize || window.addEventListener("resize", t(this, d), {
212
+ signal: s.signal
213
+ }), this.shadowRoot.addEventListener("slotchange", t(this, d), {
214
+ signal: s.signal
215
+ }), window.addEventListener("load", t(this, d), {
216
+ signal: s.signal
217
+ });
218
+ }
219
+ /**
220
+ * @exports scrollTo
221
+ * @param {ScrollToOptions} options
222
+ */
223
+ scrollTo(s) {
224
+ t(this, e).scrollTo(s);
225
+ }
226
+ $beforeUnmounted() {
227
+ var s;
228
+ (s = this.eventController) == null || s.abort();
229
+ }
230
+ }
231
+ n = new WeakMap(), b = new WeakMap(), g = new WeakMap(), c = new WeakMap(), a = new WeakMap(), e = new WeakMap(), L = new WeakMap(), u = new WeakMap(), d = new WeakMap(), p = new WeakMap(), f = new WeakMap(), w = new WeakMap(), m = new WeakMap();
232
+ window.customElements.get("ea-scrollbar") || window.customElements.define("ea-scrollbar", S);
233
+ export {
234
+ S as EaScrollbar
235
+ };