easy-component-ui 3.0.6 → 3.0.7
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 +109 -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 +1 -1
|
@@ -1,19 +1,19 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
3
|
-
throw TypeError(
|
|
1
|
+
var P = 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
|
|
10
|
-
import { s as
|
|
11
|
-
class
|
|
5
|
+
var O = (i, o, e) => o in i ? P(i, o, { enumerable: !0, configurable: !0, writable: !0, value: e }) : i[o] = e;
|
|
6
|
+
var S = (i, o, e) => O(i, typeof o != "symbol" ? o + "" : o, e), $ = (i, o, e) => o.has(i) || z("Cannot " + e);
|
|
7
|
+
var t = (i, o, e) => ($(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), v = (i, o, e, r) => ($(i, o, "write to private field"), r ? r.call(i, e) : o.set(i, e), e), c = (i, o, e) => ($(i, o, "access private method"), e);
|
|
8
|
+
import { B } from "./Base.js";
|
|
9
|
+
import { s as U } from "../css/ea-carousel-item.style.js";
|
|
10
|
+
import { s as j } from "../css/ea-carousel.style.js";
|
|
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 = U, this.$render();
|
|
17
17
|
}
|
|
18
18
|
$render() {
|
|
19
19
|
this.shadowRoot.innerHTML = `
|
|
@@ -26,30 +26,30 @@ 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 f,
|
|
31
|
-
class
|
|
29
|
+
window.customElements.get("ea-carousel-item") || window.customElements.define("ea-carousel-item", W);
|
|
30
|
+
var f, m, _, A, g, p, h, u, s, L, w, a, N, y, I, x, b, C, E, k, q, R, M, T;
|
|
31
|
+
class X extends B {
|
|
32
32
|
constructor() {
|
|
33
33
|
super();
|
|
34
|
-
n(this,
|
|
34
|
+
n(this, a);
|
|
35
35
|
/** @type {HTMLElement} */
|
|
36
36
|
n(this, f);
|
|
37
37
|
/** @type {HTMLElement} */
|
|
38
|
-
n(this,
|
|
38
|
+
n(this, m);
|
|
39
39
|
/** @type {HTMLElement} */
|
|
40
|
-
n(this,
|
|
40
|
+
n(this, _);
|
|
41
41
|
/** @type {HTMLElement} */
|
|
42
|
-
n(this,
|
|
42
|
+
n(this, A);
|
|
43
43
|
/** @type {HTMLElement} */
|
|
44
44
|
n(this, g);
|
|
45
45
|
/** @type {HTMLElement[]} */
|
|
46
|
-
n(this,
|
|
46
|
+
n(this, p, []);
|
|
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,
|
|
@@ -57,7 +57,7 @@ class W extends N {
|
|
|
57
57
|
isMouseEnter: !1,
|
|
58
58
|
isEnd: !1
|
|
59
59
|
});
|
|
60
|
-
|
|
60
|
+
S(this, "state", this.properties({
|
|
61
61
|
height: {
|
|
62
62
|
type: String,
|
|
63
63
|
default: "100%",
|
|
@@ -75,12 +75,12 @@ class W extends N {
|
|
|
75
75
|
index: {
|
|
76
76
|
type: Number,
|
|
77
77
|
default: 0,
|
|
78
|
-
observer: (e,
|
|
79
|
-
if (t(this,
|
|
80
|
-
e < 0 ? (e = t(this,
|
|
78
|
+
observer: (e, r) => {
|
|
79
|
+
if (t(this, y).call(this, e), t(this, s).isEnd) return t(this, s).isEnd = !1;
|
|
80
|
+
e < 0 ? (e = t(this, p).length - 1, r = 0, t(this, s).isEnd = !0) : e > t(this, p).length - 1 && (r = t(this, p).length - 1, e = 0, t(this, s).isEnd = !0), t(this, s).prevIndex = r, this.emit("change", {
|
|
81
81
|
detail: {
|
|
82
82
|
current: e,
|
|
83
|
-
prev:
|
|
83
|
+
prev: r
|
|
84
84
|
}
|
|
85
85
|
});
|
|
86
86
|
}
|
|
@@ -90,12 +90,12 @@ class W extends N {
|
|
|
90
90
|
default: "hover",
|
|
91
91
|
/** @param {'click' | 'hover'} newVal */
|
|
92
92
|
observer: (e) => {
|
|
93
|
-
var
|
|
94
|
-
(
|
|
93
|
+
var r;
|
|
94
|
+
(r = t(this, u).triggerAbortControllers) == null || r.abort(), t(this, u).triggerAbortControllers = new AbortController(), t(this, g).addEventListener(
|
|
95
95
|
e === "hover" ? "mouseover" : "click",
|
|
96
|
-
t(this,
|
|
96
|
+
t(this, k),
|
|
97
97
|
{
|
|
98
|
-
signal: t(this,
|
|
98
|
+
signal: t(this, u).triggerAbortControllers.signal
|
|
99
99
|
}
|
|
100
100
|
);
|
|
101
101
|
}
|
|
@@ -117,7 +117,7 @@ class W extends N {
|
|
|
117
117
|
type: Boolean,
|
|
118
118
|
default: !0,
|
|
119
119
|
observer: (e) => {
|
|
120
|
-
e ?
|
|
120
|
+
e ? c(this, a, b).call(this) : c(this, a, x).call(this);
|
|
121
121
|
}
|
|
122
122
|
},
|
|
123
123
|
loop: {
|
|
@@ -144,16 +144,16 @@ class W extends N {
|
|
|
144
144
|
* 处理 index 溢出的情况
|
|
145
145
|
* @return {number}
|
|
146
146
|
*/
|
|
147
|
-
n(this,
|
|
147
|
+
n(this, L, () => this.index === t(this, p).length ? 0 : this.index === -1 ? t(this, p).length - 1 : this.index);
|
|
148
148
|
/**
|
|
149
149
|
* 渲染 轮播图指示器,为了避免vue组件缓存,所以在初始化和组件挂载时都进行渲染
|
|
150
150
|
*/
|
|
151
|
-
n(this,
|
|
151
|
+
n(this, w, () => {
|
|
152
152
|
const e = Array.from(
|
|
153
153
|
this.querySelectorAll("ea-carousel-item"),
|
|
154
|
-
(
|
|
154
|
+
(r, l) => `<button class='ea-carousel__indicator' part='indicator' tabindex="1" data-index="${l}"></button>`
|
|
155
155
|
).join("");
|
|
156
|
-
t(this, g).innerHTML = e, v(this,
|
|
156
|
+
t(this, g).innerHTML = e, v(this, p, [
|
|
157
157
|
...t(this, g).querySelectorAll(".ea-carousel__indicator")
|
|
158
158
|
]);
|
|
159
159
|
});
|
|
@@ -161,59 +161,59 @@ class W extends N {
|
|
|
161
161
|
* 更新轮播图位置
|
|
162
162
|
* @param {number} index
|
|
163
163
|
*/
|
|
164
|
-
n(this,
|
|
165
|
-
const { width:
|
|
164
|
+
n(this, y, (e = 0) => {
|
|
165
|
+
const { width: r, height: l } = t(this, f).getBoundingClientRect(), d = this.direction === "horizontal" ? "X" : "Y", H = this.direction === "horizontal" ? r : l;
|
|
166
166
|
this.style.setProperty(
|
|
167
167
|
"--ea-carousel-transform",
|
|
168
|
-
`translate${
|
|
169
|
-
), t(this,
|
|
168
|
+
`translate${d}(-${(e + 1) * H}px)`
|
|
169
|
+
), t(this, I).call(this);
|
|
170
170
|
});
|
|
171
171
|
/**
|
|
172
172
|
* 更新指示器位置
|
|
173
173
|
*/
|
|
174
|
-
n(this,
|
|
175
|
-
t(this,
|
|
176
|
-
e.classList.toggle("is-active",
|
|
174
|
+
n(this, I, () => {
|
|
175
|
+
t(this, p).forEach((e, r) => {
|
|
176
|
+
e.classList.toggle("is-active", r === t(this, L).call(this));
|
|
177
177
|
});
|
|
178
178
|
});
|
|
179
179
|
/**
|
|
180
180
|
* 开启轮播图过渡属性
|
|
181
181
|
*/
|
|
182
|
-
n(this,
|
|
182
|
+
n(this, C, () => {
|
|
183
183
|
this.clientHeight, this.style.removeProperty("--ea-carousel-transition");
|
|
184
184
|
});
|
|
185
185
|
/**
|
|
186
186
|
* 关闭轮播图过渡属性
|
|
187
187
|
*/
|
|
188
|
-
n(this,
|
|
188
|
+
n(this, E, () => {
|
|
189
189
|
this.style.setProperty("--ea-carousel-transition", "none"), this.clientHeight;
|
|
190
190
|
});
|
|
191
191
|
/**
|
|
192
192
|
* 指示器 处理事件,需要按照 `this.trigger` 来确定事件名
|
|
193
193
|
* @param {MouseEvent} e
|
|
194
194
|
*/
|
|
195
|
-
n(this,
|
|
196
|
-
const
|
|
195
|
+
n(this, k, (e) => {
|
|
196
|
+
const r = t(this, g).querySelectorAll(
|
|
197
197
|
".ea-carousel__indicator"
|
|
198
|
-
),
|
|
199
|
-
|
|
200
|
-
|
|
198
|
+
), l = e.target.closest(".ea-carousel__indicator");
|
|
199
|
+
l && r.forEach((d, H) => {
|
|
200
|
+
d.classList.toggle("is-active", d === l), d === l && (this.index = H);
|
|
201
201
|
});
|
|
202
202
|
});
|
|
203
203
|
/**
|
|
204
204
|
* 轮播图切换结束事件,即能确保轮播图在视觉上连续
|
|
205
205
|
*/
|
|
206
|
-
n(this,
|
|
207
|
-
t(this,
|
|
206
|
+
n(this, q, () => {
|
|
207
|
+
t(this, E).call(this), this.autoplay && !t(this, s).isMouseEnter && c(this, a, x).call(this), this.index = t(this, L).call(this), this.autoplay && !t(this, s).isMouseEnter && c(this, a, b).call(this), t(this, C).call(this), t(this, s).pause = !1;
|
|
208
208
|
});
|
|
209
209
|
/**
|
|
210
210
|
* 箭头显示事件
|
|
211
211
|
*/
|
|
212
|
-
n(this,
|
|
212
|
+
n(this, R, () => {
|
|
213
213
|
const e = () => {
|
|
214
|
-
t(this,
|
|
214
|
+
t(this, s).isMouseEnter = !1, this["pause-on-hover"] && c(this, a, b).call(this), this.updateContainerClasslist();
|
|
215
215
|
};
|
|
216
|
-
t(this,
|
|
216
|
+
t(this, s).isMouseEnter = !0, this["pause-on-hover"] && c(this, a, x).call(this), this.updateContainerClasslist(), t(this, f).addEventListener("mouseleave", e, {
|
|
217
217
|
signal: t(this, h).signal,
|
|
218
218
|
once: !0
|
|
219
219
|
});
|
|
@@ -221,12 +221,12 @@ class W extends N {
|
|
|
221
221
|
/**
|
|
222
222
|
* 当窗口大小变化时,更新轮播图位置
|
|
223
223
|
*/
|
|
224
|
-
n(this,
|
|
224
|
+
n(this, M, () => {
|
|
225
225
|
let e = null;
|
|
226
226
|
return {
|
|
227
227
|
listener: () => {
|
|
228
228
|
clearTimeout(e), e = null, e = setTimeout(() => {
|
|
229
|
-
t(this,
|
|
229
|
+
t(this, y).call(this, this.index);
|
|
230
230
|
}, 100);
|
|
231
231
|
},
|
|
232
232
|
unsetHandler: () => {
|
|
@@ -234,19 +234,27 @@ class W extends N {
|
|
|
234
234
|
}
|
|
235
235
|
};
|
|
236
236
|
});
|
|
237
|
+
/**
|
|
238
|
+
* 处理 slotchange 事件,当 slot 内容变化时重新渲染
|
|
239
|
+
*/
|
|
240
|
+
n(this, T, () => {
|
|
241
|
+
t(this, E).call(this), c(this, a, x).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, w).call(this), c(this, a, N).call(this), t(this, I).call(this), this.autoplay && c(this, a, b).call(this), queueMicrotask(() => {
|
|
242
|
+
t(this, C).call(this);
|
|
243
|
+
});
|
|
244
|
+
});
|
|
237
245
|
/**
|
|
238
246
|
* 上一张轮播图
|
|
239
247
|
*/
|
|
240
|
-
|
|
241
|
-
t(this,
|
|
248
|
+
S(this, "prev", () => {
|
|
249
|
+
t(this, s).pause || (this.index--, t(this, s).pause = !0);
|
|
242
250
|
});
|
|
243
251
|
/**
|
|
244
252
|
* 下一张轮播图
|
|
245
253
|
*/
|
|
246
|
-
|
|
247
|
-
t(this,
|
|
254
|
+
S(this, "next", () => {
|
|
255
|
+
t(this, s).pause || (this.index++, t(this, s).pause = !0);
|
|
248
256
|
});
|
|
249
|
-
this.stylesheet =
|
|
257
|
+
this.stylesheet = j, this.$render();
|
|
250
258
|
}
|
|
251
259
|
static get observedAttributes() {
|
|
252
260
|
return [
|
|
@@ -277,7 +285,7 @@ class W extends N {
|
|
|
277
285
|
["--" + this.direction]: this.direction
|
|
278
286
|
},
|
|
279
287
|
{
|
|
280
|
-
["arrow-" + this.arrow]: this.arrow === "always" || this.arrow === "never" || t(this,
|
|
288
|
+
["arrow-" + this.arrow]: this.arrow === "always" || this.arrow === "never" || t(this, s).isMouseEnter,
|
|
281
289
|
[this["indicator-position"] + "-indicator"]: this["indicator-position"]
|
|
282
290
|
}
|
|
283
291
|
);
|
|
@@ -299,76 +307,78 @@ class W extends N {
|
|
|
299
307
|
|
|
300
308
|
</footer>
|
|
301
309
|
</div>
|
|
302
|
-
`, v(this, f, this.shadowRoot.querySelector(".ea-carousel")), v(this,
|
|
310
|
+
`, v(this, f, this.shadowRoot.querySelector(".ea-carousel")), v(this, m, this.shadowRoot.querySelector(".ea-carousel__content")), v(this, g, this.shadowRoot.querySelector(
|
|
303
311
|
".ea-carousel__indicator-wrap"
|
|
304
|
-
)), v(this,
|
|
312
|
+
)), v(this, _, this.shadowRoot.querySelector(
|
|
305
313
|
".ea-carousel__arrow.arrow-left"
|
|
306
|
-
)), v(this,
|
|
314
|
+
)), v(this, A, this.shadowRoot.querySelector(
|
|
307
315
|
".ea-carousel__arrow.arrow-right"
|
|
308
|
-
)), t(this,
|
|
316
|
+
)), t(this, w).call(this), this.updateContainerClasslist();
|
|
309
317
|
}
|
|
310
318
|
connectedCallback() {
|
|
311
|
-
var e,
|
|
319
|
+
var e, r;
|
|
312
320
|
super.connectedCallback(), (e = t(this, h)) == null || e.abort(), v(this, h, new AbortController());
|
|
313
|
-
for (const
|
|
314
|
-
(
|
|
315
|
-
t(this,
|
|
321
|
+
for (const l in t(this, u))
|
|
322
|
+
(r = t(this, u)[l]) == null || r.abort(), t(this, u)[l] = new AbortController();
|
|
323
|
+
t(this, E).call(this), t(this, w).call(this), c(this, a, N).call(this), this.autoplay && c(this, a, b).call(this), t(this, g).addEventListener(
|
|
316
324
|
this.trigger === "hover" ? "mouseover" : "click",
|
|
317
|
-
t(this,
|
|
325
|
+
t(this, k),
|
|
318
326
|
{
|
|
319
|
-
signal: t(this,
|
|
327
|
+
signal: t(this, u).triggerAbortControllers.signal
|
|
320
328
|
}
|
|
321
|
-
), t(this,
|
|
329
|
+
), t(this, m).addEventListener(
|
|
322
330
|
"transitionend",
|
|
323
|
-
t(this,
|
|
331
|
+
t(this, q),
|
|
324
332
|
{ signal: t(this, h).signal }
|
|
325
|
-
), this.arrow !== "never" && this.direction !== "vertical" && (t(this,
|
|
333
|
+
), this.arrow !== "never" && this.direction !== "vertical" && (t(this, _).addEventListener("click", this.prev, {
|
|
334
|
+
signal: t(this, h).signal
|
|
335
|
+
}), t(this, A).addEventListener("click", this.next, {
|
|
326
336
|
signal: t(this, h).signal
|
|
327
|
-
}), t(this,
|
|
337
|
+
})), t(this, f).addEventListener("mouseenter", t(this, R), {
|
|
328
338
|
signal: t(this, h).signal
|
|
329
|
-
})
|
|
339
|
+
}), window.addEventListener("resize", t(this, M).call(this).listener, {
|
|
330
340
|
signal: t(this, h).signal
|
|
331
|
-
}),
|
|
341
|
+
}), t(this, m).querySelector("slot").addEventListener("slotchange", t(this, T), {
|
|
332
342
|
signal: t(this, h).signal
|
|
333
343
|
}), queueMicrotask(() => {
|
|
334
|
-
t(this,
|
|
344
|
+
t(this, C).call(this);
|
|
335
345
|
});
|
|
336
346
|
}
|
|
337
347
|
$beforeUnmounted() {
|
|
338
|
-
var e,
|
|
348
|
+
var e, r, l;
|
|
339
349
|
(e = t(this, h)) == null || e.abort();
|
|
340
|
-
for (const
|
|
341
|
-
(
|
|
342
|
-
(
|
|
350
|
+
for (const d in t(this, u))
|
|
351
|
+
(r = t(this, u)[d]) == null || r.abort();
|
|
352
|
+
(l = t(this, M).call(this)) == null || l.unsetHandler();
|
|
343
353
|
}
|
|
344
354
|
}
|
|
345
|
-
f = new WeakMap(),
|
|
355
|
+
f = new WeakMap(), m = new WeakMap(), _ = new WeakMap(), A = new WeakMap(), g = new WeakMap(), p = new WeakMap(), h = new WeakMap(), u = new WeakMap(), s = new WeakMap(), L = new WeakMap(), w = new WeakMap(), a = new WeakSet(), /**
|
|
346
356
|
* 初始化 `轮播图元素` 结构
|
|
347
357
|
*/
|
|
348
|
-
|
|
358
|
+
N = function() {
|
|
349
359
|
try {
|
|
350
|
-
this.childNodes.forEach((
|
|
351
|
-
|
|
360
|
+
this.childNodes.forEach((d) => {
|
|
361
|
+
d.tagName !== "EA-CAROUSEL-ITEM" && d.remove();
|
|
352
362
|
});
|
|
353
|
-
const e = this.children,
|
|
354
|
-
t(this,
|
|
355
|
-
t(this,
|
|
363
|
+
const e = this.children, r = e[0].cloneNode(!0), l = e[e.length - 1].cloneNode(!0);
|
|
364
|
+
t(this, s).originLength = e.length, this.insertBefore(l, this.firstChild), this.appendChild(r), queueMicrotask(() => {
|
|
365
|
+
t(this, y).call(this);
|
|
356
366
|
});
|
|
357
367
|
} catch {
|
|
358
368
|
}
|
|
359
|
-
},
|
|
369
|
+
}, y = new WeakMap(), I = new WeakMap(), /**
|
|
360
370
|
* 清除轮播图自动播放
|
|
361
371
|
*/
|
|
362
|
-
|
|
363
|
-
t(this,
|
|
372
|
+
x = function() {
|
|
373
|
+
t(this, s).timer && (clearInterval(t(this, s).timer), t(this, s).timer = null);
|
|
364
374
|
}, /**
|
|
365
375
|
* 处理轮播图自动播放
|
|
366
376
|
*/
|
|
367
|
-
|
|
368
|
-
this.autoplay && (t(this,
|
|
369
|
-
},
|
|
370
|
-
window.customElements.get("ea-carousel") || window.customElements.define("ea-carousel",
|
|
377
|
+
b = function() {
|
|
378
|
+
this.autoplay && (t(this, s).timer = setInterval(this.next, this.interval));
|
|
379
|
+
}, C = new WeakMap(), E = new WeakMap(), k = new WeakMap(), q = new WeakMap(), R = new WeakMap(), M = new WeakMap(), T = new WeakMap();
|
|
380
|
+
window.customElements.get("ea-carousel") || window.customElements.define("ea-carousel", X);
|
|
371
381
|
export {
|
|
372
|
-
|
|
373
|
-
|
|
382
|
+
X as EaCarousel,
|
|
383
|
+
W as EaCarouselItem
|
|
374
384
|
};
|
|
@@ -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
|
}));
|