easy-component-ui 3.0.6 → 3.0.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/components/ea-calendar2.js +327 -329
- package/dist/components/ea-carousel.js +114 -99
- package/dist/components/ea-space.js +45 -31
- package/dist/components/ea-text.js +8 -5
- package/dist/css/ea-button.style.js +1 -1
- package/dist/css/ea-link.style.js +1 -1
- package/dist/css/ea-space.style.js +1 -1
- package/dist/css/ea-ui-component.style.js +1 -1
- package/package.json +304 -304
|
@@ -1,19 +1,19 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
3
|
-
throw TypeError(
|
|
1
|
+
var N = Object.defineProperty;
|
|
2
|
+
var z = (i) => {
|
|
3
|
+
throw TypeError(i);
|
|
4
4
|
};
|
|
5
|
-
var
|
|
6
|
-
var
|
|
7
|
-
var t = (
|
|
8
|
-
import { B
|
|
9
|
-
import { s as
|
|
5
|
+
var O = (i, o, e) => o in i ? N(i, o, { enumerable: !0, configurable: !0, writable: !0, value: e }) : i[o] = e;
|
|
6
|
+
var M = (i, o, e) => O(i, typeof o != "symbol" ? o + "" : o, e), H = (i, o, e) => o.has(i) || z("Cannot " + e);
|
|
7
|
+
var t = (i, o, e) => (H(i, o, "read from private field"), e ? e.call(i) : o.get(i)), n = (i, o, e) => o.has(i) ? z("Cannot add the same private member more than once") : o instanceof WeakSet ? o.add(i) : o.set(i, e), f = (i, o, e, r) => (H(i, o, "write to private field"), r ? r.call(i, e) : o.set(i, e), e), c = (i, o, e) => (H(i, o, "access private method"), e);
|
|
8
|
+
import { B } from "./Base.js";
|
|
9
|
+
import { s as j } from "../css/ea-carousel-item.style.js";
|
|
10
10
|
import { s as U } from "../css/ea-carousel.style.js";
|
|
11
|
-
class
|
|
11
|
+
class W extends B {
|
|
12
12
|
static get observedAttributes() {
|
|
13
13
|
return [...super.observedAttributes];
|
|
14
14
|
}
|
|
15
15
|
constructor() {
|
|
16
|
-
super(), this.stylesheet =
|
|
16
|
+
super(), this.stylesheet = j, this.$render();
|
|
17
17
|
}
|
|
18
18
|
$render() {
|
|
19
19
|
this.shadowRoot.innerHTML = `
|
|
@@ -26,38 +26,39 @@ class j extends N {
|
|
|
26
26
|
super.connectedCallback();
|
|
27
27
|
}
|
|
28
28
|
}
|
|
29
|
-
window.customElements.get("ea-carousel-item") || window.customElements.define("ea-carousel-item",
|
|
30
|
-
var
|
|
31
|
-
class
|
|
29
|
+
window.customElements.get("ea-carousel-item") || window.customElements.define("ea-carousel-item", W);
|
|
30
|
+
var v, b, _, L, p, g, h, u, s, S, C, l, $, w, k, A, m, y, E, q, P, R, I, T;
|
|
31
|
+
class X extends B {
|
|
32
32
|
constructor() {
|
|
33
33
|
super();
|
|
34
34
|
n(this, l);
|
|
35
35
|
/** @type {HTMLElement} */
|
|
36
|
-
n(this,
|
|
36
|
+
n(this, v);
|
|
37
37
|
/** @type {HTMLElement} */
|
|
38
|
-
n(this,
|
|
38
|
+
n(this, b);
|
|
39
39
|
/** @type {HTMLElement} */
|
|
40
|
-
n(this,
|
|
40
|
+
n(this, _);
|
|
41
41
|
/** @type {HTMLElement} */
|
|
42
|
-
n(this,
|
|
42
|
+
n(this, L);
|
|
43
43
|
/** @type {HTMLElement} */
|
|
44
|
-
n(this,
|
|
44
|
+
n(this, p);
|
|
45
45
|
/** @type {HTMLElement[]} */
|
|
46
|
-
n(this,
|
|
46
|
+
n(this, g, []);
|
|
47
47
|
/** @type {AbortController} */
|
|
48
48
|
n(this, h);
|
|
49
|
-
n(this,
|
|
49
|
+
n(this, u, {
|
|
50
50
|
triggerAbortControllers: new AbortController()
|
|
51
51
|
});
|
|
52
|
-
n(this,
|
|
52
|
+
n(this, s, {
|
|
53
53
|
prevIndex: 0,
|
|
54
54
|
originLength: 0,
|
|
55
55
|
timer: null,
|
|
56
56
|
pause: !1,
|
|
57
57
|
isMouseEnter: !1,
|
|
58
|
-
isEnd: !1
|
|
58
|
+
isEnd: !1,
|
|
59
|
+
isProcessingSlotChange: !1
|
|
59
60
|
});
|
|
60
|
-
|
|
61
|
+
M(this, "state", this.properties({
|
|
61
62
|
height: {
|
|
62
63
|
type: String,
|
|
63
64
|
default: "100%",
|
|
@@ -75,12 +76,12 @@ class W extends N {
|
|
|
75
76
|
index: {
|
|
76
77
|
type: Number,
|
|
77
78
|
default: 0,
|
|
78
|
-
observer: (e,
|
|
79
|
-
if (t(this,
|
|
80
|
-
e < 0 ? (e = t(this,
|
|
79
|
+
observer: (e, r) => {
|
|
80
|
+
if (t(this, w).call(this, e), t(this, s).isEnd) return t(this, s).isEnd = !1;
|
|
81
|
+
e < 0 ? (e = t(this, g).length - 1, r = 0, t(this, s).isEnd = !0) : e > t(this, g).length - 1 && (r = t(this, g).length - 1, e = 0, t(this, s).isEnd = !0), t(this, s).prevIndex = r, this.emit("change", {
|
|
81
82
|
detail: {
|
|
82
83
|
current: e,
|
|
83
|
-
prev:
|
|
84
|
+
prev: r
|
|
84
85
|
}
|
|
85
86
|
});
|
|
86
87
|
}
|
|
@@ -90,12 +91,12 @@ class W extends N {
|
|
|
90
91
|
default: "hover",
|
|
91
92
|
/** @param {'click' | 'hover'} newVal */
|
|
92
93
|
observer: (e) => {
|
|
93
|
-
var
|
|
94
|
-
(
|
|
94
|
+
var r;
|
|
95
|
+
(r = t(this, u).triggerAbortControllers) == null || r.abort(), t(this, u).triggerAbortControllers = new AbortController(), t(this, p).addEventListener(
|
|
95
96
|
e === "hover" ? "mouseover" : "click",
|
|
96
|
-
t(this,
|
|
97
|
+
t(this, q),
|
|
97
98
|
{
|
|
98
|
-
signal: t(this,
|
|
99
|
+
signal: t(this, u).triggerAbortControllers.signal
|
|
99
100
|
}
|
|
100
101
|
);
|
|
101
102
|
}
|
|
@@ -117,7 +118,7 @@ class W extends N {
|
|
|
117
118
|
type: Boolean,
|
|
118
119
|
default: !0,
|
|
119
120
|
observer: (e) => {
|
|
120
|
-
e ?
|
|
121
|
+
e ? c(this, l, m).call(this) : c(this, l, A).call(this);
|
|
121
122
|
}
|
|
122
123
|
},
|
|
123
124
|
loop: {
|
|
@@ -144,76 +145,76 @@ class W extends N {
|
|
|
144
145
|
* 处理 index 溢出的情况
|
|
145
146
|
* @return {number}
|
|
146
147
|
*/
|
|
147
|
-
n(this,
|
|
148
|
+
n(this, S, () => this.index === t(this, g).length ? 0 : this.index === -1 ? t(this, g).length - 1 : this.index);
|
|
148
149
|
/**
|
|
149
150
|
* 渲染 轮播图指示器,为了避免vue组件缓存,所以在初始化和组件挂载时都进行渲染
|
|
150
151
|
*/
|
|
151
|
-
n(this,
|
|
152
|
+
n(this, C, () => {
|
|
152
153
|
const e = Array.from(
|
|
153
|
-
this.querySelectorAll("ea-carousel-item"),
|
|
154
|
-
(
|
|
154
|
+
this.querySelectorAll("ea-carousel-item:not([slot])"),
|
|
155
|
+
(r, a) => `<button class='ea-carousel__indicator' part='indicator' tabindex="1" data-index="${a}"></button>`
|
|
155
156
|
).join("");
|
|
156
|
-
t(this,
|
|
157
|
-
...t(this,
|
|
157
|
+
t(this, p).innerHTML = e, f(this, g, [
|
|
158
|
+
...t(this, p).querySelectorAll(".ea-carousel__indicator")
|
|
158
159
|
]);
|
|
159
160
|
});
|
|
160
161
|
/**
|
|
161
162
|
* 更新轮播图位置
|
|
162
163
|
* @param {number} index
|
|
163
164
|
*/
|
|
164
|
-
n(this,
|
|
165
|
-
const { width:
|
|
165
|
+
n(this, w, (e = 0) => {
|
|
166
|
+
const { width: r, height: a } = t(this, v).getBoundingClientRect(), d = this.direction === "horizontal" ? "X" : "Y", x = this.direction === "horizontal" ? r : a;
|
|
166
167
|
this.style.setProperty(
|
|
167
168
|
"--ea-carousel-transform",
|
|
168
|
-
`translate${
|
|
169
|
-
), t(this,
|
|
169
|
+
`translate${d}(-${(e + 1) * x}px)`
|
|
170
|
+
), t(this, k).call(this);
|
|
170
171
|
});
|
|
171
172
|
/**
|
|
172
173
|
* 更新指示器位置
|
|
173
174
|
*/
|
|
174
|
-
n(this,
|
|
175
|
-
t(this,
|
|
176
|
-
e.classList.toggle("is-active",
|
|
175
|
+
n(this, k, () => {
|
|
176
|
+
t(this, g).forEach((e, r) => {
|
|
177
|
+
e.classList.toggle("is-active", r === t(this, S).call(this));
|
|
177
178
|
});
|
|
178
179
|
});
|
|
179
180
|
/**
|
|
180
181
|
* 开启轮播图过渡属性
|
|
181
182
|
*/
|
|
182
|
-
n(this,
|
|
183
|
+
n(this, y, () => {
|
|
183
184
|
this.clientHeight, this.style.removeProperty("--ea-carousel-transition");
|
|
184
185
|
});
|
|
185
186
|
/**
|
|
186
187
|
* 关闭轮播图过渡属性
|
|
187
188
|
*/
|
|
188
|
-
n(this,
|
|
189
|
+
n(this, E, () => {
|
|
189
190
|
this.style.setProperty("--ea-carousel-transition", "none"), this.clientHeight;
|
|
190
191
|
});
|
|
191
192
|
/**
|
|
192
193
|
* 指示器 处理事件,需要按照 `this.trigger` 来确定事件名
|
|
193
194
|
* @param {MouseEvent} e
|
|
194
195
|
*/
|
|
195
|
-
n(this,
|
|
196
|
-
const
|
|
196
|
+
n(this, q, (e) => {
|
|
197
|
+
const r = t(this, p).querySelectorAll(
|
|
197
198
|
".ea-carousel__indicator"
|
|
198
199
|
), a = e.target.closest(".ea-carousel__indicator");
|
|
199
|
-
a &&
|
|
200
|
-
|
|
200
|
+
a && r.forEach((d, x) => {
|
|
201
|
+
d.classList.toggle("is-active", d === a), d === a && (this.index = x);
|
|
201
202
|
});
|
|
202
203
|
});
|
|
203
204
|
/**
|
|
204
205
|
* 轮播图切换结束事件,即能确保轮播图在视觉上连续
|
|
205
206
|
*/
|
|
206
|
-
n(this,
|
|
207
|
-
t(this,
|
|
207
|
+
n(this, P, () => {
|
|
208
|
+
t(this, E).call(this), this.autoplay && !t(this, s).isMouseEnter && c(this, l, A).call(this), this.index = t(this, S).call(this), this.autoplay && !t(this, s).isMouseEnter && c(this, l, m).call(this), t(this, y).call(this), t(this, s).pause = !1;
|
|
208
209
|
});
|
|
209
210
|
/**
|
|
210
211
|
* 箭头显示事件
|
|
211
212
|
*/
|
|
212
|
-
n(this,
|
|
213
|
+
n(this, R, () => {
|
|
213
214
|
const e = () => {
|
|
214
|
-
t(this,
|
|
215
|
+
t(this, s).isMouseEnter = !1, this["pause-on-hover"] && c(this, l, m).call(this), this.updateContainerClasslist();
|
|
215
216
|
};
|
|
216
|
-
t(this,
|
|
217
|
+
t(this, s).isMouseEnter = !0, this["pause-on-hover"] && c(this, l, A).call(this), this.updateContainerClasslist(), t(this, v).addEventListener("mouseleave", e, {
|
|
217
218
|
signal: t(this, h).signal,
|
|
218
219
|
once: !0
|
|
219
220
|
});
|
|
@@ -226,7 +227,7 @@ class W extends N {
|
|
|
226
227
|
return {
|
|
227
228
|
listener: () => {
|
|
228
229
|
clearTimeout(e), e = null, e = setTimeout(() => {
|
|
229
|
-
t(this,
|
|
230
|
+
t(this, w).call(this, this.index);
|
|
230
231
|
}, 100);
|
|
231
232
|
},
|
|
232
233
|
unsetHandler: () => {
|
|
@@ -234,17 +235,25 @@ class W extends N {
|
|
|
234
235
|
}
|
|
235
236
|
};
|
|
236
237
|
});
|
|
238
|
+
/**
|
|
239
|
+
* 处理 slotchange 事件,当 slot 内容变化时重新渲染
|
|
240
|
+
*/
|
|
241
|
+
n(this, T, () => {
|
|
242
|
+
t(this, s).isProcessingSlotChange || (console.log(1), t(this, s).isProcessingSlotChange = !0, t(this, E).call(this), c(this, l, A).call(this), t(this, s).prevIndex = 0, t(this, s).originLength = 0, t(this, s).pause = !1, t(this, s).isEnd = !1, this.index = 0, t(this, C).call(this), c(this, l, $).call(this), t(this, k).call(this), this.autoplay && c(this, l, m).call(this), queueMicrotask(() => {
|
|
243
|
+
t(this, y).call(this), t(this, s).isProcessingSlotChange = !1;
|
|
244
|
+
}));
|
|
245
|
+
});
|
|
237
246
|
/**
|
|
238
247
|
* 上一张轮播图
|
|
239
248
|
*/
|
|
240
|
-
|
|
241
|
-
t(this,
|
|
249
|
+
M(this, "prev", () => {
|
|
250
|
+
t(this, s).pause || (this.index--, t(this, s).pause = !0);
|
|
242
251
|
});
|
|
243
252
|
/**
|
|
244
253
|
* 下一张轮播图
|
|
245
254
|
*/
|
|
246
|
-
|
|
247
|
-
t(this,
|
|
255
|
+
M(this, "next", () => {
|
|
256
|
+
t(this, s).pause || (this.index++, t(this, s).pause = !0);
|
|
248
257
|
});
|
|
249
258
|
this.stylesheet = U, this.$render();
|
|
250
259
|
}
|
|
@@ -277,11 +286,11 @@ class W extends N {
|
|
|
277
286
|
["--" + this.direction]: this.direction
|
|
278
287
|
},
|
|
279
288
|
{
|
|
280
|
-
["arrow-" + this.arrow]: this.arrow === "always" || this.arrow === "never" || t(this,
|
|
289
|
+
["arrow-" + this.arrow]: this.arrow === "always" || this.arrow === "never" || t(this, s).isMouseEnter,
|
|
281
290
|
[this["indicator-position"] + "-indicator"]: this["indicator-position"]
|
|
282
291
|
}
|
|
283
292
|
);
|
|
284
|
-
return t(this,
|
|
293
|
+
return t(this, v).className = e, e;
|
|
285
294
|
}
|
|
286
295
|
$render() {
|
|
287
296
|
this.shadowRoot.innerHTML = `
|
|
@@ -293,82 +302,88 @@ class W extends N {
|
|
|
293
302
|
<ea-icon icon="icon-angle-right" part="arrow-right-icon"></ea-icon>
|
|
294
303
|
</button>
|
|
295
304
|
<ul class="ea-carousel__content" part="content">
|
|
305
|
+
<slot name="clone-last"></slot>
|
|
296
306
|
<slot></slot>
|
|
307
|
+
<slot name="clone-first"></slot>
|
|
297
308
|
</ul>
|
|
298
309
|
<footer class="ea-carousel__indicator-wrap" part="indicator-wrap">
|
|
299
310
|
|
|
300
311
|
</footer>
|
|
301
312
|
</div>
|
|
302
|
-
`,
|
|
313
|
+
`, f(this, v, this.shadowRoot.querySelector(".ea-carousel")), f(this, b, this.shadowRoot.querySelector(".ea-carousel__content")), f(this, p, this.shadowRoot.querySelector(
|
|
303
314
|
".ea-carousel__indicator-wrap"
|
|
304
|
-
)),
|
|
315
|
+
)), f(this, _, this.shadowRoot.querySelector(
|
|
305
316
|
".ea-carousel__arrow.arrow-left"
|
|
306
|
-
)),
|
|
317
|
+
)), f(this, L, this.shadowRoot.querySelector(
|
|
307
318
|
".ea-carousel__arrow.arrow-right"
|
|
308
|
-
)), t(this,
|
|
319
|
+
)), t(this, C).call(this), this.updateContainerClasslist();
|
|
309
320
|
}
|
|
310
321
|
connectedCallback() {
|
|
311
|
-
var e,
|
|
312
|
-
super.connectedCallback(), (e = t(this, h)) == null || e.abort(),
|
|
313
|
-
for (const a in t(this,
|
|
314
|
-
(
|
|
315
|
-
t(this,
|
|
322
|
+
var e, r;
|
|
323
|
+
super.connectedCallback(), (e = t(this, h)) == null || e.abort(), f(this, h, new AbortController());
|
|
324
|
+
for (const a in t(this, u))
|
|
325
|
+
(r = t(this, u)[a]) == null || r.abort(), t(this, u)[a] = new AbortController();
|
|
326
|
+
t(this, E).call(this), t(this, C).call(this), c(this, l, $).call(this), this.autoplay && c(this, l, m).call(this), t(this, p).addEventListener(
|
|
316
327
|
this.trigger === "hover" ? "mouseover" : "click",
|
|
317
|
-
t(this,
|
|
328
|
+
t(this, q),
|
|
318
329
|
{
|
|
319
|
-
signal: t(this,
|
|
330
|
+
signal: t(this, u).triggerAbortControllers.signal
|
|
320
331
|
}
|
|
321
|
-
), t(this,
|
|
332
|
+
), t(this, b).addEventListener(
|
|
322
333
|
"transitionend",
|
|
323
|
-
t(this,
|
|
334
|
+
t(this, P),
|
|
324
335
|
{ signal: t(this, h).signal }
|
|
325
|
-
), this.arrow !== "never" && this.direction !== "vertical" && (t(this,
|
|
336
|
+
), this.arrow !== "never" && this.direction !== "vertical" && (t(this, _).addEventListener("click", this.prev, {
|
|
326
337
|
signal: t(this, h).signal
|
|
327
|
-
}), t(this,
|
|
338
|
+
}), t(this, L).addEventListener("click", this.next, {
|
|
328
339
|
signal: t(this, h).signal
|
|
329
|
-
})), t(this,
|
|
340
|
+
})), t(this, v).addEventListener("mouseenter", t(this, R), {
|
|
330
341
|
signal: t(this, h).signal
|
|
331
342
|
}), window.addEventListener("resize", t(this, I).call(this).listener, {
|
|
332
343
|
signal: t(this, h).signal
|
|
344
|
+
}), t(this, b).querySelector("slot:not([name])").addEventListener("slotchange", t(this, T), {
|
|
345
|
+
signal: t(this, h).signal
|
|
333
346
|
}), queueMicrotask(() => {
|
|
334
|
-
t(this,
|
|
347
|
+
t(this, y).call(this);
|
|
335
348
|
});
|
|
336
349
|
}
|
|
337
350
|
$beforeUnmounted() {
|
|
338
|
-
var e,
|
|
351
|
+
var e, r, a;
|
|
339
352
|
(e = t(this, h)) == null || e.abort();
|
|
340
|
-
for (const
|
|
341
|
-
(
|
|
353
|
+
for (const d in t(this, u))
|
|
354
|
+
(r = t(this, u)[d]) == null || r.abort();
|
|
342
355
|
(a = t(this, I).call(this)) == null || a.unsetHandler();
|
|
343
356
|
}
|
|
344
357
|
}
|
|
345
|
-
|
|
358
|
+
v = new WeakMap(), b = new WeakMap(), _ = new WeakMap(), L = new WeakMap(), p = new WeakMap(), g = new WeakMap(), h = new WeakMap(), u = new WeakMap(), s = new WeakMap(), S = new WeakMap(), C = new WeakMap(), l = new WeakSet(), /**
|
|
346
359
|
* 初始化 `轮播图元素` 结构
|
|
347
360
|
*/
|
|
348
|
-
|
|
361
|
+
$ = function() {
|
|
349
362
|
try {
|
|
350
|
-
this.
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
363
|
+
const e = this.querySelectorAll("ea-carousel-item:not([slot])");
|
|
364
|
+
if (e.length === 0) return;
|
|
365
|
+
t(this, s).originLength = e.length, this.querySelectorAll(
|
|
366
|
+
'ea-carousel-item[slot^="clone-"]'
|
|
367
|
+
).forEach((x) => x.remove());
|
|
368
|
+
const a = e[0].cloneNode(!0), d = e[e.length - 1].cloneNode(!0);
|
|
369
|
+
a.setAttribute("slot", "clone-first"), d.setAttribute("slot", "clone-last"), this.appendChild(a), this.appendChild(d), queueMicrotask(() => {
|
|
370
|
+
t(this, w).call(this);
|
|
356
371
|
});
|
|
357
372
|
} catch {
|
|
358
373
|
}
|
|
359
|
-
},
|
|
374
|
+
}, w = new WeakMap(), k = new WeakMap(), /**
|
|
360
375
|
* 清除轮播图自动播放
|
|
361
376
|
*/
|
|
362
|
-
|
|
363
|
-
t(this,
|
|
377
|
+
A = function() {
|
|
378
|
+
t(this, s).timer && (clearInterval(t(this, s).timer), t(this, s).timer = null);
|
|
364
379
|
}, /**
|
|
365
380
|
* 处理轮播图自动播放
|
|
366
381
|
*/
|
|
367
382
|
m = function() {
|
|
368
|
-
this.autoplay && (t(this,
|
|
369
|
-
},
|
|
370
|
-
window.customElements.get("ea-carousel") || window.customElements.define("ea-carousel",
|
|
383
|
+
this.autoplay && (t(this, s).timer = setInterval(this.next, this.interval));
|
|
384
|
+
}, y = new WeakMap(), E = new WeakMap(), q = new WeakMap(), P = new WeakMap(), R = new WeakMap(), I = new WeakMap(), T = new WeakMap();
|
|
385
|
+
window.customElements.get("ea-carousel") || window.customElements.define("ea-carousel", X);
|
|
371
386
|
export {
|
|
372
|
-
|
|
373
|
-
|
|
387
|
+
X as EaCarousel,
|
|
388
|
+
W as EaCarouselItem
|
|
374
389
|
};
|
|
@@ -1,19 +1,19 @@
|
|
|
1
|
-
var
|
|
1
|
+
var m = Object.defineProperty;
|
|
2
2
|
var n = (t) => {
|
|
3
3
|
throw TypeError(t);
|
|
4
4
|
};
|
|
5
|
-
var
|
|
6
|
-
var
|
|
7
|
-
var
|
|
8
|
-
import { B as
|
|
9
|
-
import { s as
|
|
10
|
-
var
|
|
11
|
-
class v extends
|
|
5
|
+
var b = (t, s, e) => s in t ? m(t, s, { enumerable: !0, configurable: !0, writable: !0, value: e }) : t[s] = e;
|
|
6
|
+
var p = (t, s, e) => b(t, typeof s != "symbol" ? s + "" : s, e), c = (t, s, e) => s.has(t) || n("Cannot " + e);
|
|
7
|
+
var u = (t, s, e) => (c(t, s, "read from private field"), e ? e.call(t) : s.get(t)), d = (t, s, e) => s.has(t) ? n("Cannot add the same private member more than once") : s instanceof WeakSet ? s.add(t) : s.set(t, e), h = (t, s, e, a) => (c(t, s, "write to private field"), a ? a.call(t, e) : s.set(t, e), e);
|
|
8
|
+
import { B as g } from "./Base.js";
|
|
9
|
+
import { s as y } from "../css/ea-space.style.js";
|
|
10
|
+
var r;
|
|
11
|
+
class v extends g {
|
|
12
12
|
constructor() {
|
|
13
13
|
super();
|
|
14
14
|
/** @type {HTMLElement} */
|
|
15
|
-
|
|
16
|
-
|
|
15
|
+
d(this, r);
|
|
16
|
+
p(this, "state", this.properties({
|
|
17
17
|
wrap: {
|
|
18
18
|
type: Boolean,
|
|
19
19
|
default: !1,
|
|
@@ -22,18 +22,19 @@ class v extends y {
|
|
|
22
22
|
}
|
|
23
23
|
},
|
|
24
24
|
alignment: {
|
|
25
|
-
type:
|
|
25
|
+
type: ["", "center", "flex-start", "flex-end", "baseline", "stretch"],
|
|
26
26
|
default: "",
|
|
27
27
|
observer: (e) => {
|
|
28
|
-
if (!CSS.supports("align-items", e))
|
|
28
|
+
if (!CSS.supports("align-items", e))
|
|
29
|
+
return console.warn(`[ea-space] Invalid alignment value ${e}`);
|
|
29
30
|
this.style.setProperty("--ea-space-alignment", e);
|
|
30
31
|
}
|
|
31
32
|
},
|
|
32
33
|
direction: {
|
|
33
34
|
type: ["vertical", "horizontal"],
|
|
34
35
|
default: "horizontal",
|
|
35
|
-
observer: (
|
|
36
|
-
|
|
36
|
+
observer: () => {
|
|
37
|
+
this.updateContainerClasslist();
|
|
37
38
|
}
|
|
38
39
|
},
|
|
39
40
|
size: {
|
|
@@ -41,9 +42,10 @@ class v extends y {
|
|
|
41
42
|
default: "default",
|
|
42
43
|
observer: (e) => {
|
|
43
44
|
if (["large", "small", "default"].includes(e))
|
|
44
|
-
|
|
45
|
+
this.updateContainerClasslist();
|
|
45
46
|
else {
|
|
46
|
-
if (!CSS.supports("gap", e))
|
|
47
|
+
if (!CSS.supports("gap", e))
|
|
48
|
+
return console.warn("[ea-space] Invalid size value");
|
|
47
49
|
this.style.setProperty("--ea-space-gap", e);
|
|
48
50
|
}
|
|
49
51
|
}
|
|
@@ -52,11 +54,12 @@ class v extends y {
|
|
|
52
54
|
type: String,
|
|
53
55
|
default: "",
|
|
54
56
|
observer: (e) => {
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
57
|
+
if (this.querySelectorAll('[part="spacer"]').forEach((i) => i.remove()), !e) return;
|
|
58
|
+
const o = [...this.children];
|
|
59
|
+
o.forEach((i, f) => {
|
|
60
|
+
if (f < o.length - 1) {
|
|
58
61
|
const l = document.createElement("span");
|
|
59
|
-
l.innerText = e, l.part = "spacer", this.insertBefore(l,
|
|
62
|
+
l.innerText = e, l.part = "spacer", this.insertBefore(l, i.nextSibling);
|
|
60
63
|
}
|
|
61
64
|
});
|
|
62
65
|
}
|
|
@@ -64,45 +67,56 @@ class v extends y {
|
|
|
64
67
|
fill: {
|
|
65
68
|
type: Boolean,
|
|
66
69
|
default: !1,
|
|
67
|
-
observer: (
|
|
68
|
-
|
|
70
|
+
observer: () => {
|
|
71
|
+
this.updateContainerClasslist();
|
|
69
72
|
}
|
|
70
73
|
},
|
|
71
74
|
"fill-ratio": {
|
|
72
75
|
type: Number,
|
|
73
76
|
default: 100,
|
|
74
77
|
observer: (e) => {
|
|
75
|
-
this.style.setProperty("--ea-space-fill-ratio", `${e}%`);
|
|
78
|
+
Number.isNaN(Number(e)) || this.toggleAttribute("fill", !0), this.style.setProperty("--ea-space-fill-ratio", `${e}%`);
|
|
76
79
|
}
|
|
77
80
|
}
|
|
78
81
|
}));
|
|
79
|
-
this.stylesheet =
|
|
82
|
+
this.stylesheet = y, this.$render();
|
|
80
83
|
}
|
|
81
84
|
static get observedAttributes() {
|
|
82
|
-
return [
|
|
85
|
+
return [
|
|
86
|
+
...super.observedAttributes,
|
|
87
|
+
"wrap",
|
|
88
|
+
"direction",
|
|
89
|
+
"size",
|
|
90
|
+
"spacer",
|
|
91
|
+
"alignment",
|
|
92
|
+
"fill",
|
|
93
|
+
"fill-ratio"
|
|
94
|
+
];
|
|
83
95
|
}
|
|
84
96
|
/**
|
|
85
97
|
* 获取 classlist 列表
|
|
86
98
|
* @return {string} 属性值
|
|
87
99
|
*/
|
|
88
100
|
updateContainerClasslist() {
|
|
89
|
-
|
|
101
|
+
const e = this.computedClasslist("ea-space", {
|
|
102
|
+
[`--${this.size}`]: !CSS.supports("gap", this.size),
|
|
90
103
|
["--" + this.direction]: this.direction,
|
|
91
104
|
"--fill": this.fill
|
|
92
105
|
});
|
|
106
|
+
return u(this, r).className = e, e;
|
|
93
107
|
}
|
|
94
108
|
$render() {
|
|
95
109
|
this.shadowRoot.innerHTML = `
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
110
|
+
<div class="ea-space" part="container">
|
|
111
|
+
<slot></slot>
|
|
112
|
+
</div>
|
|
113
|
+
`, h(this, r, this.shadowRoot.querySelector(".ea-space")), this.updateContainerClasslist();
|
|
100
114
|
}
|
|
101
115
|
connectedCallback() {
|
|
102
116
|
super.connectedCallback();
|
|
103
117
|
}
|
|
104
118
|
}
|
|
105
|
-
|
|
119
|
+
r = new WeakMap();
|
|
106
120
|
window.customElements.get("ea-space") || window.customElements.define("ea-space", v);
|
|
107
121
|
export {
|
|
108
122
|
v as EaSpace
|
|
@@ -2,13 +2,13 @@ var y = Object.defineProperty;
|
|
|
2
2
|
var p = (e) => {
|
|
3
3
|
throw TypeError(e);
|
|
4
4
|
};
|
|
5
|
-
var
|
|
6
|
-
var u = (e, s, t) =>
|
|
5
|
+
var w = (e, s, t) => s in e ? y(e, s, { enumerable: !0, configurable: !0, writable: !0, value: t }) : e[s] = t;
|
|
6
|
+
var u = (e, s, t) => w(e, typeof s != "symbol" ? s + "" : s, t), m = (e, s, t) => s.has(e) || p("Cannot " + t);
|
|
7
7
|
var i = (e, s, t) => (m(e, s, "read from private field"), t ? t.call(e) : s.get(e)), o = (e, s, t) => s.has(e) ? p("Cannot add the same private member more than once") : s instanceof WeakSet ? s.add(e) : s.set(e, t), h = (e, s, t, l) => (m(e, s, "write to private field"), l ? l.call(e, t) : s.set(e, t), t);
|
|
8
|
-
import { B as
|
|
8
|
+
import { B as f } from "./Base.js";
|
|
9
9
|
import { s as C } from "../css/ea-text.style.js";
|
|
10
10
|
var a, n, r;
|
|
11
|
-
class g extends
|
|
11
|
+
class g extends f {
|
|
12
12
|
constructor() {
|
|
13
13
|
super();
|
|
14
14
|
/** @type {HTMLElement} */
|
|
@@ -70,7 +70,10 @@ class g extends w {
|
|
|
70
70
|
type: String,
|
|
71
71
|
default: "span",
|
|
72
72
|
observer: (t) => {
|
|
73
|
-
this.$render(), this.hasAttribute("line-clamp") && i(this, a).style.setProperty(
|
|
73
|
+
this.$render(), this.hasAttribute("line-clamp") && i(this, a).style.setProperty(
|
|
74
|
+
"--ea-text-line-clamp",
|
|
75
|
+
this["line-clamp"]
|
|
76
|
+
), (this.hasAttribute("truncated") || this.hasAttribute("line-clamp")) && (this.title = this.innerText || ""), this.updateContainerClasslist();
|
|
74
77
|
}
|
|
75
78
|
}
|
|
76
79
|
}));
|