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,888 @@
1
+ var xt = Object.defineProperty;
2
+ var ot = (h) => {
3
+ throw TypeError(h);
4
+ };
5
+ var Et = (h, n, e) => n in h ? xt(h, n, { enumerable: !0, configurable: !0, writable: !0, value: e }) : h[n] = e;
6
+ var T = (h, n, e) => Et(h, typeof n != "symbol" ? n + "" : n, e), tt = (h, n, e) => n.has(h) || ot("Cannot " + e);
7
+ var t = (h, n, e) => (tt(h, n, "read from private field"), e ? e.call(h) : n.get(h)), l = (h, n, e) => n.has(h) ? ot("Cannot add the same private member more than once") : n instanceof WeakSet ? n.add(h) : n.set(h, e), d = (h, n, e, i) => (tt(h, n, "write to private field"), i ? i.call(h, e) : n.set(h, e), e), a = (h, n, e) => (tt(h, n, "access private method"), e);
8
+ import { F as kt } from "../core/FormBase.js";
9
+ import { n as rt } from "./ea-calendar2.js";
10
+ import { C as F } from "../utils/Color.js";
11
+ import { s as Mt } from "../css/ea-color-picker.style.js";
12
+ import { E as $t } from "../utils/Variables.js";
13
+ import { B as At } from "./Base.js";
14
+ import { s as Pt } from "../css/ea-color-picker-panel.style.js";
15
+ import "./ea-input.js";
16
+ import { E as G } from "../utils/Utils.js";
17
+ import "./ea-popper.js";
18
+ import "./ea-button.js";
19
+ class Rt extends Event {
20
+ constructor(n) {
21
+ super("ea-active-change", {
22
+ bubbles: !0,
23
+ cancelable: !0,
24
+ composed: !0
25
+ }), this.detail = n;
26
+ }
27
+ }
28
+ class qt extends Event {
29
+ constructor(n) {
30
+ super("ea-invalid-color", {
31
+ bubbles: !0,
32
+ composed: !0
33
+ }), this.detail = n;
34
+ }
35
+ }
36
+ var W, A, m, P, k, R, J, M, L, g, B, y, v, s, o, lt, ht, nt, ut, et, D, ct, H, dt, pt, st, it, Z, vt, bt;
37
+ class Lt extends At {
38
+ constructor() {
39
+ super();
40
+ l(this, o);
41
+ /** @type {HTMLDivElement} */
42
+ l(this, W);
43
+ /** @type {HTMLDivElement} */
44
+ l(this, A);
45
+ /** @type {HTMLDivElement} */
46
+ l(this, m);
47
+ /** @type {HTMLDivElement} */
48
+ l(this, P);
49
+ /** @type {HTMLDivElement} */
50
+ l(this, k);
51
+ /** @type {HTMLDivElement} */
52
+ l(this, R);
53
+ /** @type {HTMLDivElement} */
54
+ l(this, J);
55
+ /** @type {HTMLDivElement} */
56
+ l(this, M);
57
+ /** @type {HTMLDivElement} */
58
+ l(this, L);
59
+ /** @type {HTMLInputElement} */
60
+ l(this, g);
61
+ /** @type {HTMLDivElement} */
62
+ l(this, B);
63
+ l(this, y, new AbortController());
64
+ l(this, v, {
65
+ /** @type {AbortController | null} 饱和度拖拽控制器 */
66
+ saturationMove: null,
67
+ /** @type {AbortController | null} 色调拖拽控制器 */
68
+ hueMove: null,
69
+ /** @type {AbortController | null} 透明度拖拽控制器 */
70
+ alphaMove: null
71
+ });
72
+ l(this, s, {
73
+ /** @type {boolean} 是否首次更新值 */
74
+ isFirstValueUpdate: !1,
75
+ /** @type {number} 色调值 (0-360) */
76
+ hue: 0,
77
+ /** @type {number} 饱和度值 (0-1) */
78
+ saturation: 1,
79
+ /** @type {number} 亮度值 (0-1) */
80
+ value: 1,
81
+ /** @type {number} 透明度值 (0-1) */
82
+ alpha: 1,
83
+ /** @type {import("@/utils/Color").Color} 当前颜色对象 */
84
+ color: new F(),
85
+ /** @type {boolean} 是否正在拖拽 */
86
+ isDragging: !1,
87
+ /** @type {string} 上一个验证通过的颜色值 */
88
+ lastValidValue: ""
89
+ });
90
+ T(this, "state", this.properties({
91
+ value: {
92
+ type: String,
93
+ default: "",
94
+ observer: (e) => {
95
+ t(this, s).lastValidValue = e, a(this, o, et).call(this), t(this, D).call(this), a(this, o, Z).call(this);
96
+ }
97
+ },
98
+ "color-format": {
99
+ type: ["hsl", "hsv", "hex", "rgb", "rgba"],
100
+ default: () => this.hasAttribute("show-alpha") ? "rgba" : "hex",
101
+ observer: (e) => {
102
+ this.value && (this.value = t(this, s).color.toString(e));
103
+ }
104
+ },
105
+ "show-alpha": {
106
+ type: Boolean,
107
+ default: !1,
108
+ observer: (e) => {
109
+ this.updateContainerClasslist();
110
+ }
111
+ },
112
+ disabled: {
113
+ type: Boolean,
114
+ default: !1,
115
+ observer: (e) => {
116
+ this.updateContainerClasslist();
117
+ }
118
+ },
119
+ border: {
120
+ type: Boolean,
121
+ default: !1,
122
+ observer: (e) => {
123
+ this.updateContainerClasslist();
124
+ }
125
+ },
126
+ clearable: {
127
+ type: Boolean,
128
+ default: !0,
129
+ observer: (e) => {
130
+ a(this, o, it).call(this);
131
+ }
132
+ }
133
+ }));
134
+ T(this, "propStates", this.properties({
135
+ predefine: {
136
+ props: !0,
137
+ type: Array,
138
+ default: [],
139
+ observer: (e) => {
140
+ a(this, o, dt).call(this, e);
141
+ }
142
+ }
143
+ }));
144
+ /**
145
+ * 更新饱和度面板的背景颜色
146
+ */
147
+ l(this, D, () => {
148
+ const e = new F({
149
+ h: t(this, s).hue,
150
+ s: 1,
151
+ v: 1,
152
+ a: 1
153
+ });
154
+ this.style.setProperty(
155
+ "--ea-color-picker-panel-background-color",
156
+ e.toString(this["color-format"])
157
+ );
158
+ });
159
+ this.stylesheet = Pt, this.$render();
160
+ }
161
+ static get observedAttributes() {
162
+ return [
163
+ ...super.observedAttributes,
164
+ "value",
165
+ "color-format",
166
+ "predefine",
167
+ "show-alpha",
168
+ "disabled",
169
+ "border",
170
+ "clearable"
171
+ ];
172
+ }
173
+ /**
174
+ * 获取 classlist 列表
175
+ * @return {string} 属性值
176
+ */
177
+ updateContainerClasslist() {
178
+ const e = this.computedClasslist(
179
+ this.ns.b("container"),
180
+ {},
181
+ {
182
+ disabled: this.disabled,
183
+ border: this.border,
184
+ "show-alpha": this["show-alpha"],
185
+ clearable: this.clearable
186
+ }
187
+ );
188
+ return t(this, W).className = e, e;
189
+ }
190
+ $render() {
191
+ const e = rt("color-picker-panel");
192
+ this.ns = e, this.shadowRoot.innerHTML = this.html(`
193
+ <div class="${e.b()}" part="container">
194
+ <div class="${e.e("wrapper")}" part="wrapper">
195
+ <div class="${e.e("svpanel")}" part="svpanel">
196
+ <div class="${e.e("cursor")} ${e.e("svpanel-cursor")}" part="svpanel-cursor"></div>
197
+ </div>
198
+ <div class="${e.e("hue-slider")} ${e.m("vertical")}" part="hue-slider">
199
+ <div class="${e.e("thumb")} ${e.e("hue-slider-thumb")}" part="hue-slider-thumb"></div>
200
+ </div>
201
+ </div>
202
+ <div class="${e.e("alpha-slider")}" part="alpha-slider">
203
+ <div class="${e.e("thumb")} ${e.e("alpha-slider-thumb")}" part="alpha-slider-thumb"></div>
204
+ </div>
205
+ <div class="${e.e("predefine")}" part="predefine">
206
+ <div class="${e.e("colors")}" part="predefine-colors"></div>
207
+ </div>
208
+ <div class="${e.e("footer")}" part="footer">
209
+ <div class="${e.e("text-display")}" part="text-display"></div>
210
+ <ea-input class="${e.e("color-input")}" part="color-input" type="text" size="small"></ea-input>
211
+ <section class="${e.e("append")}" part="append">
212
+ <slot name="footer"></slot>
213
+ </section>
214
+ </div>
215
+ </div>
216
+ `), d(this, W, this.shadowRoot.querySelector(e.cb())), d(this, A, this.shadowRoot.querySelector(e.ce("svpanel"))), d(this, m, this.shadowRoot.querySelector(
217
+ e.ce("svpanel-cursor")
218
+ )), d(this, P, this.shadowRoot.querySelector(e.ce("hue-slider"))), d(this, k, this.shadowRoot.querySelector(e.ce("hue-slider-thumb"))), d(this, R, this.shadowRoot.querySelector(e.ce("alpha-slider"))), d(this, J, this.shadowRoot.querySelector(
219
+ e.ce("alpha-slider-bar")
220
+ )), d(this, M, this.shadowRoot.querySelector(
221
+ e.ce("alpha-slider-thumb")
222
+ )), d(this, L, this.shadowRoot.querySelector(e.ce("predefine"))), d(this, g, this.shadowRoot.querySelector(e.ce("color-input"))), d(this, B, this.shadowRoot.querySelector(e.ce("text-display"))), this.updateContainerClasslist(), a(this, o, it).call(this);
223
+ }
224
+ connectedCallback() {
225
+ var e;
226
+ super.connectedCallback(), (e = t(this, y)) == null || e.abort(), d(this, y, new AbortController()), a(this, o, lt).call(this);
227
+ }
228
+ $beforeUnmounted() {
229
+ var e;
230
+ (e = t(this, y)) == null || e.abort();
231
+ }
232
+ /**
233
+ * 重置光标和滑块位置到初始状态
234
+ */
235
+ resetCursorPosition() {
236
+ t(this, s).hue = 0, t(this, s).saturation = 1, t(this, s).value = 1, t(this, s).alpha = 1, t(this, s).isFirstValueUpdate = !1, t(this, m) && (t(this, m).style.left = "", t(this, m).style.top = ""), t(this, k) && (t(this, k).style.top = ""), t(this, M) && (t(this, M).style.left = ""), t(this, D).call(this);
237
+ }
238
+ }
239
+ W = new WeakMap(), A = new WeakMap(), m = new WeakMap(), P = new WeakMap(), k = new WeakMap(), R = new WeakMap(), J = new WeakMap(), M = new WeakMap(), L = new WeakMap(), g = new WeakMap(), B = new WeakMap(), y = new WeakMap(), v = new WeakMap(), s = new WeakMap(), o = new WeakSet(), /**
240
+ * 绑定组件事件监听器
241
+ */
242
+ lt = function() {
243
+ t(this, A).addEventListener(
244
+ "mousedown",
245
+ a(this, o, ht).bind(this),
246
+ {
247
+ signal: t(this, y).signal
248
+ }
249
+ ), t(this, P).addEventListener("mousedown", a(this, o, nt).bind(this), {
250
+ signal: t(this, y).signal
251
+ }), t(this, R).addEventListener(
252
+ "mousedown",
253
+ a(this, o, ut).bind(this),
254
+ {
255
+ signal: t(this, y).signal
256
+ }
257
+ ), t(this, g).addEventListener(
258
+ "change",
259
+ a(this, o, ct).bind(this),
260
+ {
261
+ signal: t(this, y).signal
262
+ }
263
+ ), t(this, g).addEventListener(
264
+ "blur",
265
+ a(this, o, vt).bind(this),
266
+ {
267
+ signal: t(this, y).signal
268
+ }
269
+ ), t(this, L) && t(this, L).addEventListener(
270
+ "click",
271
+ a(this, o, pt).bind(this),
272
+ {
273
+ signal: t(this, y).signal
274
+ }
275
+ );
276
+ }, /**
277
+ * 处理饱和度和值的更新
278
+ * @param {MouseEvent} e - 鼠标事件对象
279
+ */
280
+ ht = function(e) {
281
+ var u, b;
282
+ if ((u = t(this, v).saturationMove) == null || u.abort(), (b = t(this, v).hueMove) == null || b.abort(), this.disabled) return;
283
+ e.preventDefault(), t(this, v).saturationMove = new AbortController(), t(this, s).isDragging = !0;
284
+ const i = (c) => {
285
+ const p = t(this, A).getBoundingClientRect(), x = Math.max(0, Math.min(c.clientX - p.left, p.width)), E = Math.max(0, Math.min(c.clientY - p.top, p.height)), V = x / p.width, Q = 1 - E / p.height;
286
+ t(this, s).saturation = V, t(this, s).value = Q, t(this, s).color.setValue({
287
+ h: t(this, s).hue,
288
+ s: V,
289
+ v: Q,
290
+ a: t(this, s).alpha
291
+ }), this.value = t(this, s).color.toString(this["color-format"]), a(this, o, H).call(this), t(this, m).style.left = V * p.width + "px", t(this, m).style.top = (1 - Q) * p.height + "px";
292
+ };
293
+ i(e), window.addEventListener("mousemove", i, {
294
+ signal: t(this, v).saturationMove.signal
295
+ }), window.addEventListener(
296
+ "mouseup",
297
+ () => {
298
+ var c;
299
+ (c = t(this, v).saturationMove) == null || c.abort(), t(this, s).isDragging = !1;
300
+ },
301
+ {
302
+ signal: t(this, v).saturationMove.signal
303
+ }
304
+ );
305
+ }, /**
306
+ * 处理色调的更新
307
+ * @param {MouseEvent} e - 鼠标事件对象
308
+ */
309
+ nt = function(e) {
310
+ var u, b;
311
+ if ((u = t(this, v).hueMove) == null || u.abort(), (b = t(this, v).saturationMove) == null || b.abort(), this.disabled) return;
312
+ e.preventDefault(), t(this, v).hueMove = new AbortController(), t(this, s).isDragging = !0;
313
+ const i = (c) => {
314
+ const p = t(this, P).getBoundingClientRect(), E = (1 - Math.max(0.01, Math.min(c.clientY - p.top, p.height)) / p.height) * 360;
315
+ t(this, s).hue = E, t(this, s).color.setValue({
316
+ h: E,
317
+ s: t(this, s).saturation,
318
+ v: t(this, s).value,
319
+ a: t(this, s).alpha
320
+ }), this.value = t(this, s).color.toString(this["color-format"]), a(this, o, H).call(this), t(this, k).style.top = (1 - E / 360) * p.height + "px", t(this, D).call(this);
321
+ };
322
+ i(e), window.addEventListener("mousemove", i, {
323
+ signal: t(this, v).hueMove.signal
324
+ }), window.addEventListener(
325
+ "mouseup",
326
+ () => {
327
+ var c;
328
+ (c = t(this, v).hueMove) == null || c.abort(), t(this, s).isDragging = !1;
329
+ },
330
+ {
331
+ signal: t(this, v).hueMove.signal
332
+ }
333
+ );
334
+ }, /**
335
+ * 处理透明度的更新
336
+ * @param {MouseEvent} e - 鼠标事件对象
337
+ */
338
+ ut = function(e) {
339
+ var u, b, c;
340
+ if ((u = t(this, v).alphaMove) == null || u.abort(), (b = t(this, v).saturationMove) == null || b.abort(), (c = t(this, v).hueMove) == null || c.abort(), this.disabled) return;
341
+ e.preventDefault(), t(this, v).alphaMove = new AbortController(), t(this, s).isDragging = !0;
342
+ const i = (p) => {
343
+ const x = t(this, R).getBoundingClientRect(), E = Math.max(0, Math.min(p.clientX - x.left, x.width)), V = Number((E / x.width).toFixed(2));
344
+ Math.abs(t(this, s).alpha - V) > 1e-3 && (t(this, s).alpha = V, t(this, s).color.setValue({
345
+ h: t(this, s).hue,
346
+ s: t(this, s).saturation,
347
+ v: t(this, s).value,
348
+ a: V
349
+ }), this.value = t(this, s).color.toString(this["color-format"]), a(this, o, H).call(this), t(this, M).style.left = V * x.width + "px");
350
+ };
351
+ i(e), window.addEventListener("mousemove", i, {
352
+ signal: t(this, v).alphaMove.signal
353
+ }), window.addEventListener(
354
+ "mouseup",
355
+ () => {
356
+ var p;
357
+ (p = t(this, v).alphaMove) == null || p.abort(), t(this, s).isDragging = !1;
358
+ },
359
+ {
360
+ signal: t(this, v).alphaMove.signal
361
+ }
362
+ );
363
+ }, /**
364
+ * 更新光标位置
365
+ */
366
+ et = function() {
367
+ if (!t(this, s).isFirstValueUpdate) {
368
+ t(this, s).color.setValue(this.value);
369
+ const e = t(this, s).color.hsvStrToHsvObject(
370
+ t(this, s).color.toHsv(!0)
371
+ );
372
+ if (e) {
373
+ const i = parseInt(e.h), u = e.s, b = e.v, c = e.a ? parseFloat(e.a) : 1;
374
+ t(this, s).hue = i, t(this, s).saturation = u, t(this, s).value = b, t(this, s).alpha = c;
375
+ }
376
+ t(this, s).isFirstValueUpdate = !0;
377
+ }
378
+ if (t(this, m) && t(this, A)) {
379
+ const e = t(this, s).saturation, i = t(this, s).value, u = t(this, A).getBoundingClientRect(), b = G.CSS.px2num(
380
+ this.style.getPropertyValue("--ea-color-picker-panel-svpanel-width")
381
+ ) || 280, c = G.CSS.px2num(
382
+ this.style.getPropertyValue("--ea-color-picker-panel-svpanel-height")
383
+ ) || 180, p = Math.max(
384
+ 0,
385
+ Math.min(u.width, b),
386
+ b
387
+ ), x = Math.max(
388
+ 0,
389
+ Math.min(u.height, c),
390
+ c
391
+ ), E = e * p, V = (1 - i) * x;
392
+ t(this, m).style.left = E + "px", t(this, m).style.top = V + "px";
393
+ }
394
+ if (t(this, k) && t(this, P)) {
395
+ const e = t(this, s).hue, i = t(this, P).getBoundingClientRect(), u = G.CSS.px2num(
396
+ this.style.getPropertyValue(
397
+ "--ea-color-picker-panel-hue-slider-height"
398
+ )
399
+ ) || 180, b = Math.max(0, Math.min(i.height, u), u), c = (1 - e / 360) * b;
400
+ t(this, k).style.top = c + "px";
401
+ }
402
+ if (t(this, M) && t(this, R)) {
403
+ const e = t(this, s).alpha, i = t(this, R).getBoundingClientRect(), u = G.CSS.px2num(
404
+ this.style.getPropertyValue(
405
+ "--ea-color-picker-panel-alpha-slider-width"
406
+ )
407
+ ) || 280, b = Math.max(0, Math.min(i.width, u), u), c = e * b;
408
+ t(this, M).style.left = c + "px";
409
+ }
410
+ }, D = new WeakMap(), /**
411
+ * 处理颜色输入框变化事件
412
+ * @param {Event} e - 事件对象
413
+ */
414
+ ct = function(e) {
415
+ const i = e.target.value;
416
+ try {
417
+ const u = new F(i);
418
+ this.value = u.toString(this["color-format"]), a(this, o, H).call(this);
419
+ } catch {
420
+ t(this, g).value = this.value;
421
+ }
422
+ }, /**
423
+ * 触发颜色变化事件
424
+ */
425
+ H = function() {
426
+ this.dispatchEvent(
427
+ new CustomEvent("change", {
428
+ detail: {
429
+ value: this.value,
430
+ color: t(this, s).color
431
+ },
432
+ bubbles: !0,
433
+ composed: !0
434
+ })
435
+ ), this.dispatchEvent(
436
+ new Rt({ value: this.value })
437
+ );
438
+ }, /**
439
+ * 渲染预设颜色列表
440
+ * @param {Array} list - 预设颜色列表
441
+ */
442
+ dt = function(e) {
443
+ !e || e.length === 0 || (t(this, L).innerHTML = this.html(
444
+ e.map(
445
+ (i) => `
446
+ <div class="${this.ns.e("predefine-color")}"
447
+ part="predefine-color"
448
+ style="background-color: ${i}"
449
+ data-color="${i}"
450
+ ></div>
451
+ `
452
+ ).join("")
453
+ ));
454
+ }, /**
455
+ * 处理预设颜色点击事件
456
+ * @param {MouseEvent} e - 鼠标事件对象
457
+ */
458
+ pt = function(e) {
459
+ if (this.disabled) return;
460
+ const i = e.target.closest(this.ns.ce("predefine-color"));
461
+ if (!i) return;
462
+ const u = i.getAttribute("data-color");
463
+ u && a(this, o, st).call(this, u);
464
+ }, /**
465
+ * 根据颜色值更新所有相关状态
466
+ * @param {string} colorValue - 颜色值字符串
467
+ */
468
+ st = function(e) {
469
+ a(this, o, Z).call(this), this.value = e, t(this, s).color.setValue(e);
470
+ const i = t(this, s).color.hsvStrToHsvObject(
471
+ t(this, s).color.toHsv(!0)
472
+ );
473
+ if (i) {
474
+ const u = parseInt(i.h), b = i.s, c = i.v, p = i.a ? parseFloat(i.a) : 1;
475
+ t(this, s).hue = u, t(this, s).saturation = b, t(this, s).value = c, t(this, s).alpha = p;
476
+ }
477
+ a(this, o, et).call(this), t(this, D).call(this), a(this, o, H).call(this);
478
+ }, /**
479
+ * 更新文字展示模式
480
+ */
481
+ it = function() {
482
+ !t(this, g) || !t(this, B) || (a(this, o, Z).call(this), this.updateContainerClasslist());
483
+ }, /**
484
+ * 更新颜色输入框的值
485
+ */
486
+ Z = function() {
487
+ this.clearable && t(this, g) ? t(this, g).setAttribute("value", this.value) : !this.clearable && t(this, B) && (t(this, B).textContent = this.value);
488
+ }, /**
489
+ * 处理颜色输入框blur事件
490
+ * @param {FocusEvent} e - 焦点事件对象
491
+ */
492
+ vt = function(e) {
493
+ if (!t(this, g)) return;
494
+ const i = t(this, g).getAttribute("value") || "";
495
+ if (!i) {
496
+ this.value = "", t(this, s).lastValidValue = "";
497
+ return;
498
+ }
499
+ a(this, o, bt).call(this, i) ? (t(this, s).lastValidValue = i, a(this, o, st).call(this, i)) : (t(this, g).setAttribute("value", t(this, s).lastValidValue || ""), this.dispatchEvent(
500
+ new qt({ value: i })
501
+ ));
502
+ }, /**
503
+ * 验证颜色格式是否合法
504
+ * @param {string} colorValue - 颜色值
505
+ * @returns {boolean} 是否合法
506
+ */
507
+ bt = function(e) {
508
+ return F.isValidColor(e);
509
+ };
510
+ customElements.get("ea-color-picker-panel") || customElements.define("ea-color-picker-panel", Lt);
511
+ class Bt extends Event {
512
+ constructor() {
513
+ super("ea-clear", { bubbles: !0, composed: !0 });
514
+ }
515
+ }
516
+ var $, w, I, K, q, U, C, X, Y, _, S, f, N, r, ft, gt, mt, yt, wt, Ct, at, O, z, j, St, Vt;
517
+ class Dt extends kt {
518
+ constructor() {
519
+ super();
520
+ l(this, r);
521
+ /** @type {HTMLDivElement} */
522
+ l(this, $);
523
+ /** @type {import("@/common/ea-popper").EaPopper} */
524
+ l(this, w);
525
+ /** @type {HTMLDivElement} */
526
+ l(this, I);
527
+ /** @type {HTMLDivElement} */
528
+ l(this, K);
529
+ /** @type {HTMLDivElement} */
530
+ l(this, q);
531
+ /** @type {import("@/components/ea-icon").EaIcon} */
532
+ l(this, U);
533
+ /** @type {import("@/components/ea-color-picker/components/ea-color-picker-panel").EaColorPickerPanel} */
534
+ l(this, C);
535
+ /** @type {HTMLLabelElement} */
536
+ l(this, X);
537
+ /** @type {import("@/components/ea-button").EaButton} */
538
+ l(this, Y);
539
+ /** @type {import("@/components/ea-button").EaButton} */
540
+ l(this, _);
541
+ l(this, S, new AbortController());
542
+ l(this, f, {
543
+ /** @type {boolean} 弹窗是否打开 */
544
+ isOpen: !1,
545
+ /** @type {import("@/utils/Color").Color} 当前颜色对象 */
546
+ color: new F(),
547
+ isPanelDefined: !1,
548
+ /** @type {string} 打开面板前的颜色值 */
549
+ previousValue: ""
550
+ });
551
+ l(this, N, {
552
+ /** @type {AbortController | null} 关闭弹窗的控制器 */
553
+ close: null
554
+ });
555
+ T(this, "state", this.properties({
556
+ label: {
557
+ type: String,
558
+ default: "",
559
+ observer: async (e) => {
560
+ t(this, X).textContent = e;
561
+ }
562
+ },
563
+ value: {
564
+ type: String,
565
+ default: "",
566
+ observer: (e) => {
567
+ a(this, r, z).call(this), a(this, r, j).call(this, e), t(this, C).setAttribute("value", e);
568
+ }
569
+ },
570
+ disabled: {
571
+ type: Boolean,
572
+ default: !1,
573
+ observer: (e) => {
574
+ this.updateContainerClasslist();
575
+ }
576
+ },
577
+ clearable: {
578
+ type: Boolean,
579
+ default: !1,
580
+ observer: (e) => {
581
+ this.updateContainerClasslist(), t(this, C).setAttribute("clearable", e);
582
+ }
583
+ },
584
+ size: {
585
+ type: $t,
586
+ default: "",
587
+ observer: (e) => {
588
+ this.updateContainerClasslist();
589
+ }
590
+ },
591
+ "color-format": {
592
+ type: ["hsl", "hsv", "hex", "rgb"],
593
+ default: "hex",
594
+ observer: (e) => {
595
+ t(this, C).setAttribute("color-format", e);
596
+ }
597
+ },
598
+ "show-alpha": {
599
+ type: Boolean,
600
+ default: !1,
601
+ observer: (e) => {
602
+ t(this, C).setAttribute("show-alpha", e);
603
+ }
604
+ },
605
+ tabindex: {
606
+ type: Number,
607
+ default: 0,
608
+ observer: (e) => {
609
+ }
610
+ },
611
+ required: {
612
+ type: Boolean,
613
+ default: !1
614
+ }
615
+ }));
616
+ T(this, "propState", this.properties({
617
+ predefine: {
618
+ props: !0,
619
+ type: Array,
620
+ default: [],
621
+ observer: async (e) => {
622
+ t(this, f).isPanelDefined || (await customElements.whenDefined("ea-color-picker-panel"), t(this, f).isPanelDefined = !0), t(this, C).predefine = e;
623
+ }
624
+ }
625
+ }));
626
+ T(this, "popperState", this.properties({
627
+ placement: {
628
+ type: [
629
+ "top",
630
+ "top-start",
631
+ "top-end",
632
+ "bottom",
633
+ "bottom-start",
634
+ "bottom-end",
635
+ "left",
636
+ "left-start",
637
+ "left-end",
638
+ "right",
639
+ "right-start",
640
+ "right-end"
641
+ ],
642
+ default: "bottom",
643
+ observer: (e) => {
644
+ t(this, w).setAttribute("placement", e);
645
+ }
646
+ }
647
+ }));
648
+ this.stylesheet = Mt, this.$render();
649
+ }
650
+ static get observedAttributes() {
651
+ return [
652
+ ...super.observedAttributes,
653
+ "label",
654
+ "value",
655
+ "disabled",
656
+ "clearable",
657
+ "size",
658
+ "color-format",
659
+ "predefine",
660
+ "tabindex",
661
+ "placement",
662
+ "show-alpha",
663
+ "required"
664
+ ];
665
+ }
666
+ $render() {
667
+ const e = rt("color-picker");
668
+ this.ns = e, this.shadowRoot.innerHTML = this.html(`
669
+ <label class="${e.e("form-label")}" part="form-label"></label>
670
+ <div class="${e.b("container")}" part="container" tabindex="${this.tabindex}">
671
+ <ea-popper
672
+ class="${e.e("popper")}"
673
+ part="popper"
674
+ show-arrow="false"
675
+ >
676
+ <div class="${e.e("trigger")}" part="trigger" slot="reference">
677
+ <div class="${e.e("outer")}" part="outer">
678
+ <div class="${e.e("inner")}" part="inner"></div>
679
+ </div>
680
+ <div class="${e.e("icon-wrapper")}" part="icon-wrapper">
681
+ <ea-icon class="${e.e("icon", "status")}" part="status-icon" name="xmark"></ea-icon>
682
+ </div>
683
+ </div>
684
+ <ea-color-picker-panel class="${e.e("panel")}" part="panel">
685
+ <div slot="footer" class="${e.e("footer-actions")}" part="footer-actions">
686
+ <ea-button class="${e.e("clear-btn")}" part="clear-btn" plain text>clear</ea-button>
687
+ <ea-button class="${e.e("confirm-btn")}" part="confirm-btn" plain>ok</ea-button>
688
+ </div>
689
+ </ea-color-picker-panel>
690
+ </ea-popper>
691
+ </div>
692
+ `), d(this, X, this.shadowRoot.querySelector(e.ce("form-label"))), d(this, $, this.shadowRoot.querySelector(e.cb())), d(this, w, this.shadowRoot.querySelector(e.ce("popper"))), d(this, I, this.shadowRoot.querySelector(e.ce("trigger"))), d(this, K, this.shadowRoot.querySelector(e.ce("outer"))), d(this, q, this.shadowRoot.querySelector(e.ce("inner"))), d(this, U, this.shadowRoot.querySelector(e.ce("icon", "status"))), d(this, C, this.shadowRoot.querySelector(e.ce("panel"))), d(this, Y, this.shadowRoot.querySelector(this.ns.ce("clear-btn"))), d(this, _, this.shadowRoot.querySelector(this.ns.ce("confirm-btn"))), this.updateContainerClasslist();
693
+ }
694
+ connectedCallback() {
695
+ var e;
696
+ super.connectedCallback(), (e = t(this, S)) == null || e.abort(), d(this, S, new AbortController()), a(this, r, ft).call(this);
697
+ }
698
+ /**
699
+ * 获取 classlist 列表
700
+ * @return {string} 属性值
701
+ */
702
+ updateContainerClasslist() {
703
+ const e = this.computedClasslist(
704
+ this.ns.b("container"),
705
+ {
706
+ ["--" + this.size]: this.size
707
+ },
708
+ {
709
+ "has-value": this.value,
710
+ disabled: this.disabled
711
+ }
712
+ );
713
+ return t(this, $).className = e, e;
714
+ }
715
+ $beforeUnmounted() {
716
+ var e;
717
+ (e = t(this, S)) == null || e.abort();
718
+ }
719
+ /**
720
+ * 手动显示颜色选择器面板
721
+ */
722
+ show() {
723
+ a(this, r, at).call(this);
724
+ }
725
+ /**
726
+ * 手动隐藏颜色选择器面板
727
+ */
728
+ hide() {
729
+ a(this, r, O).call(this);
730
+ }
731
+ /**
732
+ * 使颜色选择器获得焦点
733
+ */
734
+ focus() {
735
+ t(this, $) && t(this, $).focus();
736
+ }
737
+ /**
738
+ * 使颜色选择器失去焦点
739
+ */
740
+ blur() {
741
+ t(this, $) && t(this, $).blur();
742
+ }
743
+ /**
744
+ * 获取验证目标元素
745
+ * @returns {HTMLElement}
746
+ */
747
+ get validationTarget() {
748
+ return this;
749
+ }
750
+ /**
751
+ * 更新表单验证状态
752
+ */
753
+ updateValidity() {
754
+ this.required && !this.value ? this.internals.setValidity(
755
+ { valueMissing: !0 },
756
+ "请选择一个颜色",
757
+ this
758
+ ) : this.internals.setValidity({}, "", this);
759
+ }
760
+ /**
761
+ * 检查表单字段的有效性
762
+ * @returns {boolean} 如果字段有效返回 true,否则返回 false
763
+ */
764
+ checkValidity() {
765
+ return this.updateValidity(), this.internals.checkValidity();
766
+ }
767
+ /**
768
+ * 报告表单字段的有效性(显示验证提示)
769
+ * @returns {boolean} 如果字段有效返回 true,否则返回 false
770
+ */
771
+ reportValidity() {
772
+ return this.updateValidity(), this.internals.reportValidity();
773
+ }
774
+ }
775
+ $ = new WeakMap(), w = new WeakMap(), I = new WeakMap(), K = new WeakMap(), q = new WeakMap(), U = new WeakMap(), C = new WeakMap(), X = new WeakMap(), Y = new WeakMap(), _ = new WeakMap(), S = new WeakMap(), f = new WeakMap(), N = new WeakMap(), r = new WeakSet(), /**
776
+ * 绑定组件事件监听器
777
+ */
778
+ ft = function() {
779
+ !t(this, I) || !t(this, w) || (t(this, I).addEventListener("click", a(this, r, gt).bind(this), {
780
+ signal: t(this, S).signal
781
+ }), t(this, w).addEventListener("show", a(this, r, mt).bind(this), {
782
+ signal: t(this, S).signal
783
+ }), t(this, w).addEventListener("hide", a(this, r, yt).bind(this), {
784
+ signal: t(this, S).signal
785
+ }), t(this, C).addEventListener("change", a(this, r, wt).bind(this), {
786
+ signal: t(this, S).signal
787
+ }), t(this, Y).addEventListener("click", a(this, r, St).bind(this), {
788
+ signal: t(this, S).signal
789
+ }), t(this, _).addEventListener(
790
+ "click",
791
+ a(this, r, Vt).bind(this),
792
+ {
793
+ signal: t(this, S).signal
794
+ }
795
+ ));
796
+ }, /**
797
+ * 处理触发器点击事件
798
+ * @param {MouseEvent} e - 鼠标事件对象
799
+ */
800
+ gt = function(e) {
801
+ var i;
802
+ this.disabled || ((i = t(this, N).close) == null || i.abort(), t(this, N).close = new AbortController(), t(this, f).previousValue = this.value, a(this, r, at).call(this), document.addEventListener("click", a(this, r, Ct).bind(this), {
803
+ signal: t(this, N).close.signal
804
+ }));
805
+ }, /**
806
+ * 处理弹窗显示事件
807
+ */
808
+ mt = function() {
809
+ t(this, f).isOpen = !0, this.updateContainerClasslist();
810
+ }, /**
811
+ * 处理弹窗隐藏事件
812
+ */
813
+ yt = function() {
814
+ t(this, f).isOpen = !1, this.updateContainerClasslist(), t(this, f).previousValue !== void 0 && t(this, f).previousValue !== this.value && (this.value = t(this, f).previousValue, a(this, r, z).call(this), a(this, r, j).call(this));
815
+ }, /**
816
+ * 处理面板颜色变化事件
817
+ * @param {CustomEvent} e - 自定义事件对象
818
+ */
819
+ wt = function(e) {
820
+ const { value: i } = e.detail;
821
+ this.value = i, a(this, r, z).call(this), a(this, r, j).call(this);
822
+ }, /**
823
+ * 处理文档点击事件(用于关闭弹窗)
824
+ * @param {MouseEvent} e - 鼠标事件对象
825
+ */
826
+ Ct = function(e) {
827
+ t(this, f).isOpen && (!this.contains(e.target) || e.target !== this) && a(this, r, O).call(this);
828
+ }, /**
829
+ * 显示颜色选择器弹窗
830
+ */
831
+ at = function() {
832
+ t(this, w) && t(this, w).show();
833
+ }, /**
834
+ * 隐藏颜色选择器弹窗
835
+ */
836
+ O = function() {
837
+ t(this, w) && t(this, w).hide();
838
+ }, /**
839
+ * 更新触发元素的背景颜色
840
+ */
841
+ z = function() {
842
+ if (t(this, q)) {
843
+ if (!this.value) {
844
+ t(this, q).style.setProperty(
845
+ "--ea-color-picker-inner-background-color",
846
+ "transparent"
847
+ );
848
+ return;
849
+ }
850
+ try {
851
+ const e = new F(this.value);
852
+ t(this, q).style.setProperty(
853
+ "--ea-color-picker-inner-background-color",
854
+ e.toRgb(!0)
855
+ );
856
+ } catch {
857
+ t(this, q).style.setProperty(
858
+ "--ea-color-picker-inner-background-color",
859
+ "transparent"
860
+ );
861
+ }
862
+ }
863
+ }, /**
864
+ * 更新状态图标
865
+ * @param {string} colorValue - 颜色值
866
+ */
867
+ j = function(e = this.value) {
868
+ t(this, U) && t(this, U).setAttribute("name", e ? "angle-down" : "xmark");
869
+ }, /**
870
+ * 处理清除按钮点击事件
871
+ */
872
+ St = function() {
873
+ var e, i;
874
+ this.value = "", t(this, C).style.setProperty(
875
+ "--ea-color-picker-panel-background-color",
876
+ "#ff0000"
877
+ ), (i = (e = t(this, C)).resetCursorPosition) == null || i.call(e), a(this, r, z).call(this), a(this, r, j).call(this), this.emit("change", { detail: { value: "" } }), this.dispatchEvent(new Bt()), t(this, f).previousValue = "", a(this, r, O).call(this);
878
+ }, /**
879
+ * 处理确认按钮点击事件
880
+ */
881
+ Vt = function() {
882
+ t(this, f).previousValue = this.value, a(this, r, O).call(this);
883
+ };
884
+ customElements.get("ea-color-picker") || customElements.define("ea-color-picker", Dt);
885
+ export {
886
+ Dt as EaColorPicker,
887
+ Lt as EaColorPickerPanel
888
+ };