easy-component-ui 3.0.13 → 3.0.14

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 (168) hide show
  1. package/README.md +162 -162
  2. package/package.json +8 -2
  3. package/dist/assets/icon.css +0 -1
  4. package/dist/components/Base.js +0 -874
  5. package/dist/components/ea-alert.js +0 -213
  6. package/dist/components/ea-avatar.js +0 -164
  7. package/dist/components/ea-backtop.js +0 -136
  8. package/dist/components/ea-badge.js +0 -144
  9. package/dist/components/ea-breadcrumb.js +0 -148
  10. package/dist/components/ea-button.js +0 -266
  11. package/dist/components/ea-calendar.js +0 -10
  12. package/dist/components/ea-calendar2.js +0 -673
  13. package/dist/components/ea-card.js +0 -121
  14. package/dist/components/ea-carousel.js +0 -415
  15. package/dist/components/ea-checkbox.js +0 -446
  16. package/dist/components/ea-collapse.js +0 -313
  17. package/dist/components/ea-color-picker.js +0 -888
  18. package/dist/components/ea-container.js +0 -206
  19. package/dist/components/ea-countdown.js +0 -142
  20. package/dist/components/ea-date-picker.js +0 -649
  21. package/dist/components/ea-descriptions.js +0 -474
  22. package/dist/components/ea-dialog.js +0 -249
  23. package/dist/components/ea-drawer.js +0 -216
  24. package/dist/components/ea-dropdown.js +0 -228
  25. package/dist/components/ea-empty.js +0 -93
  26. package/dist/components/ea-icon.js +0 -158
  27. package/dist/components/ea-image-preview.js +0 -532
  28. package/dist/components/ea-image.js +0 -327
  29. package/dist/components/ea-infinite-scroll.js +0 -109
  30. package/dist/components/ea-input-number.js +0 -367
  31. package/dist/components/ea-input.js +0 -588
  32. package/dist/components/ea-layout.js +0 -132
  33. package/dist/components/ea-link.js +0 -101
  34. package/dist/components/ea-menu.js +0 -433
  35. package/dist/components/ea-message-box.js +0 -624
  36. package/dist/components/ea-message.js +0 -314
  37. package/dist/components/ea-notification.js +0 -331
  38. package/dist/components/ea-overlay.js +0 -168
  39. package/dist/components/ea-page-header.js +0 -108
  40. package/dist/components/ea-pagination.js +0 -481
  41. package/dist/components/ea-popconfirm.js +0 -275
  42. package/dist/components/ea-popover.js +0 -147
  43. package/dist/components/ea-popper.js +0 -203
  44. package/dist/components/ea-progress.js +0 -286
  45. package/dist/components/ea-radio.js +0 -364
  46. package/dist/components/ea-rate.js +0 -241
  47. package/dist/components/ea-result.js +0 -100
  48. package/dist/components/ea-scrollbar.js +0 -235
  49. package/dist/components/ea-segmented.js +0 -215
  50. package/dist/components/ea-select.js +0 -609
  51. package/dist/components/ea-skeleton.js +0 -263
  52. package/dist/components/ea-slider.js +0 -430
  53. package/dist/components/ea-space.js +0 -123
  54. package/dist/components/ea-splitter.js +0 -233
  55. package/dist/components/ea-statistic.js +0 -74
  56. package/dist/components/ea-steps.js +0 -346
  57. package/dist/components/ea-switch.js +0 -271
  58. package/dist/components/ea-table.js +0 -1135
  59. package/dist/components/ea-tabs.js +0 -501
  60. package/dist/components/ea-tag.js +0 -228
  61. package/dist/components/ea-text.js +0 -113
  62. package/dist/components/ea-time-picker.js +0 -510
  63. package/dist/components/ea-timeline.js +0 -185
  64. package/dist/components/ea-tooltip.js +0 -161
  65. package/dist/components/ea-tour.js +0 -544
  66. package/dist/components/ea-transfer.js +0 -949
  67. package/dist/components/ea-tree.js +0 -1125
  68. package/dist/components/index.js +0 -60
  69. package/dist/core/FormBase.js +0 -238
  70. package/dist/css/ea-alert.style.js +0 -4
  71. package/dist/css/ea-aside.style.js +0 -4
  72. package/dist/css/ea-avatar.style.js +0 -4
  73. package/dist/css/ea-backtop.style.js +0 -4
  74. package/dist/css/ea-badge.style.js +0 -4
  75. package/dist/css/ea-breadcrumb-item.style.js +0 -4
  76. package/dist/css/ea-breadcrumb.style.js +0 -4
  77. package/dist/css/ea-button-group.style.js +0 -4
  78. package/dist/css/ea-button.style.js +0 -4
  79. package/dist/css/ea-calendar.style.js +0 -4
  80. package/dist/css/ea-card.style.js +0 -4
  81. package/dist/css/ea-carousel-item.style.js +0 -4
  82. package/dist/css/ea-carousel.style.js +0 -4
  83. package/dist/css/ea-check-tag.style.js +0 -4
  84. package/dist/css/ea-checkbox-group.style.js +0 -4
  85. package/dist/css/ea-checkbox.style.js +0 -4
  86. package/dist/css/ea-col.style.js +0 -4
  87. package/dist/css/ea-collapse-item.style.js +0 -4
  88. package/dist/css/ea-collapse.style.js +0 -4
  89. package/dist/css/ea-color-picker-panel.style.js +0 -4
  90. package/dist/css/ea-color-picker.style.js +0 -4
  91. package/dist/css/ea-container.style.js +0 -4
  92. package/dist/css/ea-date-picker.style.js +0 -4
  93. package/dist/css/ea-descriptions-item.style.js +0 -4
  94. package/dist/css/ea-descriptions.style.js +0 -4
  95. package/dist/css/ea-dialog.style.js +0 -4
  96. package/dist/css/ea-drawer.style.js +0 -4
  97. package/dist/css/ea-dropdown-item.style.js +0 -4
  98. package/dist/css/ea-dropdown-menu.style.js +0 -4
  99. package/dist/css/ea-dropdown.style.js +0 -4
  100. package/dist/css/ea-empty.style.js +0 -4
  101. package/dist/css/ea-footer.style.js +0 -4
  102. package/dist/css/ea-header.style.js +0 -4
  103. package/dist/css/ea-icon.style.js +0 -4
  104. package/dist/css/ea-image-preview.style.js +0 -4
  105. package/dist/css/ea-image.style.js +0 -4
  106. package/dist/css/ea-infinite-scroll.style.js +0 -4
  107. package/dist/css/ea-input-number.style.js +0 -4
  108. package/dist/css/ea-input.style.js +0 -4
  109. package/dist/css/ea-link.style.js +0 -4
  110. package/dist/css/ea-main.style.js +0 -4
  111. package/dist/css/ea-menu-item-group.style.js +0 -4
  112. package/dist/css/ea-menu-item.style.js +0 -4
  113. package/dist/css/ea-menu.style.js +0 -4
  114. package/dist/css/ea-message-box.style.js +0 -4
  115. package/dist/css/ea-message.style.js +0 -4
  116. package/dist/css/ea-notification.style.js +0 -4
  117. package/dist/css/ea-option-gropu.style.js +0 -4
  118. package/dist/css/ea-option.style.js +0 -4
  119. package/dist/css/ea-overlay.style.js +0 -4
  120. package/dist/css/ea-page-header.style.js +0 -4
  121. package/dist/css/ea-pagination.style.js +0 -4
  122. package/dist/css/ea-popconfirm.style.js +0 -4
  123. package/dist/css/ea-popover.style.js +0 -4
  124. package/dist/css/ea-popper.style.js +0 -4
  125. package/dist/css/ea-progress.style.js +0 -4
  126. package/dist/css/ea-radio-group.style.js +0 -4
  127. package/dist/css/ea-radio.style.js +0 -4
  128. package/dist/css/ea-rate.style.js +0 -4
  129. package/dist/css/ea-result.style.js +0 -4
  130. package/dist/css/ea-row.style.js +0 -4
  131. package/dist/css/ea-scrollbar.style.js +0 -4
  132. package/dist/css/ea-segmented.style.js +0 -4
  133. package/dist/css/ea-select.style.js +0 -4
  134. package/dist/css/ea-skeleton-item.style.js +0 -4
  135. package/dist/css/ea-skeleton.style.js +0 -4
  136. package/dist/css/ea-slider.style.js +0 -4
  137. package/dist/css/ea-space.style.js +0 -4
  138. package/dist/css/ea-splitter-bar.style.js +0 -4
  139. package/dist/css/ea-splitter-panel.style.js +0 -4
  140. package/dist/css/ea-splitter.style.js +0 -4
  141. package/dist/css/ea-statistic.style.js +0 -4
  142. package/dist/css/ea-step.style.js +0 -4
  143. package/dist/css/ea-steps.style.js +0 -4
  144. package/dist/css/ea-sub-menu.style.js +0 -4
  145. package/dist/css/ea-switch.style.js +0 -4
  146. package/dist/css/ea-tab-panel.style.js +0 -4
  147. package/dist/css/ea-tab.style.js +0 -4
  148. package/dist/css/ea-table-column.style.js +0 -4
  149. package/dist/css/ea-table.style.js +0 -4
  150. package/dist/css/ea-tabs.style.js +0 -4
  151. package/dist/css/ea-tag.style.js +0 -4
  152. package/dist/css/ea-text.style.js +0 -4
  153. package/dist/css/ea-time-picker.style.js +0 -4
  154. package/dist/css/ea-timeline-item.style.js +0 -4
  155. package/dist/css/ea-timeline.style.js +0 -4
  156. package/dist/css/ea-tooltip.style.js +0 -4
  157. package/dist/css/ea-tour-step.style.js +0 -4
  158. package/dist/css/ea-tour.style.js +0 -4
  159. package/dist/css/ea-transfer.style.js +0 -5
  160. package/dist/css/ea-tree.style.js +0 -6
  161. package/dist/css/ea-ui-component.style.js +0 -4
  162. package/dist/favicon.ico +0 -0
  163. package/dist/utils/Color.js +0 -439
  164. package/dist/utils/I18nManager.js +0 -218
  165. package/dist/utils/Utils.js +0 -65
  166. package/dist/utils/Variables.js +0 -12
  167. package/dist/utils/parseTime.js +0 -73
  168. package/dist/utils/timeout.js +0 -9
@@ -1,241 +0,0 @@
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
- };
@@ -1,100 +0,0 @@
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
- };
@@ -1,235 +0,0 @@
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
- };