litos-ui 0.17.5 → 0.18.0
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/README.md +49 -49
- package/lib/animation-CTt9qgA7.js +4 -0
- package/lib/base-Dm0WS1pK.js +62 -0
- package/lib/base.js +111 -147
- package/lib/button/index.d.ts +8 -3
- package/lib/button/index.js +2 -137
- package/lib/button-CC5PmAb1.js +146 -0
- package/lib/calendar/index.d.ts +10 -5
- package/lib/calendar/index.js +2 -123
- package/lib/calendar-DeP6yZB0.js +149 -0
- package/lib/carousel/index.js +2 -280
- package/lib/carousel/item.js +2 -15
- package/lib/carousel-D4Fe3LEx.js +272 -0
- package/lib/check/checkbox.js +2 -18
- package/lib/check/checkbox_group.js +6 -6
- package/lib/check/radio.js +2 -15
- package/lib/check/radio_group.js +9 -9
- package/lib/check-B0XraJvb.js +73 -0
- package/lib/check-CvGaONEx.js +117 -0
- package/lib/checkbox-DbWsmAaL.js +16 -0
- package/lib/collapse/index.d.ts +18 -11
- package/lib/collapse/index.js +2 -88
- package/lib/collapse/item.d.ts +28 -9
- package/lib/collapse/item.js +2 -115
- package/lib/collapse/types.d.ts +7 -0
- package/lib/collapse-CeKRZ-43.js +104 -0
- package/lib/color_picker/index.js +2 -42
- package/lib/color_picker-D0brKFm-.js +41 -0
- package/lib/date_picker/index.d.ts +23 -0
- package/lib/date_picker/index.js +3 -0
- package/lib/date_picker-DQGoiN8v.js +103 -0
- package/lib/date_picker_ori/index.js +2 -129
- package/lib/date_picker_ori-aRuSSi9D.js +122 -0
- package/lib/description_panel/index.js +2 -66
- package/lib/description_panel-Df_8rVbX.js +57 -0
- package/lib/dialog/dialog_container.js +2 -131
- package/lib/dialog/index.js +67 -85
- package/lib/dialog_container-DcN87wj0.js +126 -0
- package/lib/esm-sVEoAVPu.js +244 -0
- package/lib/form/form_item.d.ts +1 -0
- package/lib/form/form_item.js +2 -136
- package/lib/form/index.js +2 -147
- package/lib/form-DdU0yK0k.js +154 -0
- package/lib/form_inner-DR9tyB_r.js +117 -0
- package/lib/form_item-Bv-YafZK.js +137 -0
- package/lib/icon/arrow_down.js +12 -12
- package/lib/icon/arrow_left.js +9 -9
- package/lib/icon/arrow_right.js +9 -9
- package/lib/icon/arrow_up.js +12 -12
- package/lib/icon/base.d.ts +16 -2
- package/lib/icon/base.js +2 -38
- package/lib/icon/calendar.d.ts +5 -0
- package/lib/icon/calendar.js +10 -0
- package/lib/icon/caret_bottom.js +9 -9
- package/lib/icon/caret_top.js +9 -9
- package/lib/icon/close.js +9 -9
- package/lib/icon/close_filled.js +12 -12
- package/lib/icon/d_arrow_left.js +12 -12
- package/lib/icon/d_arrow_right.js +12 -12
- package/lib/icon/font_icon.d.ts +2 -3
- package/lib/icon/font_icon.js +35 -39
- package/lib/icon/info.js +12 -12
- package/lib/icon/loading.js +9 -9
- package/lib/icon/moon.js +12 -12
- package/lib/icon/more.js +12 -12
- package/lib/icon/reduction.js +12 -12
- package/lib/icon/refresh.d.ts +5 -0
- package/lib/icon/refresh.js +10 -0
- package/lib/icon/refresh_left.js +12 -12
- package/lib/icon/refresh_right.js +9 -9
- package/lib/icon/search.js +9 -9
- package/lib/icon/select.js +12 -12
- package/lib/icon/sort.js +9 -9
- package/lib/icon/success.js +12 -12
- package/lib/icon/sun.js +12 -12
- package/lib/icon/theme_default.js +12 -12
- package/lib/icon/warn.js +12 -12
- package/lib/icon/zoom_in.js +12 -12
- package/lib/icon/zoom_out.js +12 -12
- package/lib/image/image_preview.js +2 -104
- package/lib/image/index.js +2 -176
- package/lib/image-CeQVfS-v.js +162 -0
- package/lib/image_preview-PzZzwo6m.js +92 -0
- package/lib/index.d.ts +10 -4
- package/lib/index.js +80 -169
- package/lib/input/index.d.ts +6 -2
- package/lib/input/index.js +188 -203
- package/lib/input-DjKxcxry.js +4 -0
- package/lib/input_inner-BKJg9n9A.js +4 -0
- package/lib/item-Cuw_ZPyn.js +14 -0
- package/lib/item-DV842Aux.js +57 -0
- package/lib/item-ZXLWFzSm.js +119 -0
- package/lib/list/index.js +2 -58
- package/lib/list-CU7vHS6s.js +51 -0
- package/lib/loading/index.d.ts +3 -2
- package/lib/loading/index.js +109 -127
- package/lib/mask/index.js +2 -105
- package/lib/mask-BlV5QfTj.js +112 -0
- package/lib/md_input/index.js +2 -60
- package/lib/md_input-DSQx5TMW.js +58 -0
- package/lib/menu/index.js +2 -105
- package/lib/menu/menu_item.js +2 -21
- package/lib/menu/sub_menu.js +2 -83
- package/lib/menu-DAtplYAH.js +91 -0
- package/lib/menu_item-BW1Tu11Q.js +20 -0
- package/lib/message/index.js +67 -60
- package/lib/modal/index.js +2 -196
- package/lib/modal/modal_box.js +87 -86
- package/lib/modal-DWyWrN-D.js +192 -0
- package/lib/page_header/index.js +2 -109
- package/lib/page_header-DdeRDN4U.js +101 -0
- package/lib/pagination/index.js +2 -248
- package/lib/pagination-BoPzSPjT.js +210 -0
- package/lib/polygon/index.js +2 -27
- package/lib/polygon-C4Ow2lxi.js +20 -0
- package/lib/qrcode/index.d.ts +13 -4
- package/lib/qrcode/index.js +2 -57
- package/lib/qrcode-BFxsD_OP.js +64 -0
- package/lib/radio-2mNSYujz.js +13 -0
- package/lib/select/index.js +3 -401
- package/lib/select-CAgggYh7.js +326 -0
- package/lib/select_ori/index.js +47 -50
- package/lib/space/index.js +2 -35
- package/lib/space-CpTmBfHP.js +38 -0
- package/lib/sub_menu-D1s8ABNu.js +75 -0
- package/lib/switch/index.js +2 -50
- package/lib/switch-BaVBi5Ip.js +48 -0
- package/lib/tabbar/index.js +2 -109
- package/lib/tabbar/item.js +2 -58
- package/lib/tabbar-4_d2Fj1n.js +91 -0
- package/lib/table/index.js +2 -269
- package/lib/table-Hifj8jAX.js +234 -0
- package/lib/tabs/index.js +38 -42
- package/lib/tag/index.js +2 -72
- package/lib/tag-DPENZf_V.js +76 -0
- package/lib/theme/index.js +2 -89
- package/lib/theme/theme_color.js +22 -26
- package/lib/theme-BRTI2-Yk.js +83 -0
- package/lib/utils/clickoutside.js +18 -18
- package/lib/utils/context_provide.js +21 -21
- package/lib/utils/event.js +13 -18
- package/lib/utils/index.js +55 -58
- package/lib/utils/popover.d.ts +4 -1
- package/lib/utils/popover.js +276 -352
- package/lib/utils/transition.js +33 -31
- package/package.json +10 -11
- package/styles/container.css +4 -0
- package/styles/datepicker.css +55 -0
- package/styles/popover.css +14 -1
- package/lib/animation-DttknHkX.js +0 -4
- package/lib/calendar/langs.js +0 -8
- package/lib/carousel/timer.js +0 -19
- package/lib/check/check.js +0 -118
- package/lib/check/index.js +0 -68
- package/lib/check-CksURvTv.js +0 -4
- package/lib/form/form_inner.js +0 -125
- package/lib/form/types.js +0 -1
- package/lib/index-CrMiSe0x.js +0 -249
- package/lib/index-DY6m9Wbe.js +0 -4
- package/lib/litos-ui.css +0 -1
- package/lib/table/types.js +0 -1
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import e from "
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
}
|
|
11
|
-
export {
|
|
12
|
-
r as default
|
|
1
|
+
import { t as e } from "../base-Dm0WS1pK.js";
|
|
2
|
+
//#region src/components/icon/theme_default.ts
|
|
3
|
+
var t = class extends e {
|
|
4
|
+
static baseName = "theme-default-icon";
|
|
5
|
+
constructor() {
|
|
6
|
+
super(), this.viewBox = "0 0 24 24";
|
|
7
|
+
}
|
|
8
|
+
renderChildren() {
|
|
9
|
+
return "<path d=\"M12 22c5.523 0 10-4.477 10-10S17.523 2 12 2S2 6.477 2 12s4.477 10 10 10m0-1.5v-17a8.5 8.5 0 0 1 0 17\"/>";
|
|
10
|
+
}
|
|
13
11
|
};
|
|
12
|
+
//#endregion
|
|
13
|
+
export { t as default };
|
package/lib/icon/warn.js
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import e from "
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
}
|
|
11
|
-
export {
|
|
12
|
-
r as default
|
|
1
|
+
import { t as e } from "../base-Dm0WS1pK.js";
|
|
2
|
+
//#region src/components/icon/warn.ts
|
|
3
|
+
var t = class extends e {
|
|
4
|
+
static baseName = "warn-icon";
|
|
5
|
+
connectedCallback() {
|
|
6
|
+
super.connectedCallback();
|
|
7
|
+
}
|
|
8
|
+
renderChildren() {
|
|
9
|
+
return "<path fill=\"currentColor\" d=\"M512 1024C229.234 1024 0 794.766 0 512S229.234 0 512 0s512 229.234 512 512-229.234 512-512 512z m-64.853-734.52l19.484 244.906 1.309 16.156c1.251 15.93 15.018 28.644 30.72 28.644h25.571c15.56 0 29.298-12.601 30.663-28.132l1.422-16.668 21.334-244.907c3.214-36.978-24.434-66.844-61.725-66.844h-6.627c-37.462 0-65.138 29.923-62.18 66.844zM512 801.393a66.788 66.788 0 1 0 0-133.575 66.788 66.788 0 0 0 0 133.575z\"></path>";
|
|
10
|
+
}
|
|
13
11
|
};
|
|
12
|
+
//#endregion
|
|
13
|
+
export { t as default };
|
package/lib/icon/zoom_in.js
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
}
|
|
11
|
-
export {
|
|
12
|
-
o as default
|
|
1
|
+
import { t as e } from "../base-Dm0WS1pK.js";
|
|
2
|
+
//#region src/components/icon/zoom_in.ts
|
|
3
|
+
var t = class extends e {
|
|
4
|
+
static baseName = "zoom-in-icon";
|
|
5
|
+
connectedCallback() {
|
|
6
|
+
super.connectedCallback();
|
|
7
|
+
}
|
|
8
|
+
renderChildren() {
|
|
9
|
+
return "<path fill=\"currentColor\" d=\"m795.904 750.72 124.992 124.928a32 32 0 0 1-45.248 45.248L750.656 795.904a416 416 0 1 1 45.248-45.248zM480 832a352 352 0 1 0 0-704 352 352 0 0 0 0 704m-32-384v-96a32 32 0 0 1 64 0v96h96a32 32 0 0 1 0 64h-96v96a32 32 0 0 1-64 0v-96h-96a32 32 0 0 1 0-64z\"></path>";
|
|
10
|
+
}
|
|
13
11
|
};
|
|
12
|
+
//#endregion
|
|
13
|
+
export { t as default };
|
package/lib/icon/zoom_out.js
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
}
|
|
11
|
-
export {
|
|
12
|
-
t as default
|
|
1
|
+
import { t as e } from "../base-Dm0WS1pK.js";
|
|
2
|
+
//#region src/components/icon/zoom_out.ts
|
|
3
|
+
var t = class extends e {
|
|
4
|
+
static baseName = "zoom-out-icon";
|
|
5
|
+
connectedCallback() {
|
|
6
|
+
super.connectedCallback();
|
|
7
|
+
}
|
|
8
|
+
renderChildren() {
|
|
9
|
+
return "<path fill=\"currentColor\" d=\"m795.904 750.72 124.992 124.928a32 32 0 0 1-45.248 45.248L750.656 795.904a416 416 0 1 1 45.248-45.248zM480 832a352 352 0 1 0 0-704 352 352 0 0 0 0 704M352 448h256a32 32 0 0 1 0 64H352a32 32 0 0 1 0-64\"></path>";
|
|
10
|
+
}
|
|
13
11
|
};
|
|
12
|
+
//#endregion
|
|
13
|
+
export { t as default };
|
|
@@ -1,104 +1,2 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
3
|
-
const l = ".l-image-preview--container{position:relative;width:100%;height:100%;display:flex;justify-content:center;align-items:center}.l-image-preview__btn,.l-image-preview-operations{display:flex;justify-content:center;align-items:center;background-color:#606666}.l-image-preview__btn{z-index:1;position:absolute;border-radius:50%;opacity:.8;cursor:pointer;background-color:#606666;color:#fff;width:40px;height:40px;font-size:20px;display:flex;justify-content:center;align-items:center;transition:color .3s ease-in-out;outline:none;border:none}.l-image-preview__btn:hover{color:var(--l-primary-color, #4998f6)}.l-image-preview__close{right:30px;top:30px}.l-image-preview__prev,.l-image-preview__next{top:50%;transform:translateY(-50%)}.l-image-preview__prev{left:30px}.l-image-preview__next{right:30px}.l-image-preview-footer{position:absolute;bottom:30px;left:50%;transform:translate(-50%);display:flex;align-items:center;flex-direction:column;z-index:1}.l-image-preview-progress{color:#fff;margin-bottom:10px}.l-image-preview-operations{cursor:default;padding:0 25px;border-radius:20px}.l-image-preview-operations .l-image-preview__btn{position:static;width:40px}.l-image-preview-img{max-width:calc(100vw - 40px);max-height:calc(100vh - 200px);vertical-align:middle;transform-origin:center center;transition:transform .25s;user-select:none;z-index:0}";
|
|
4
|
-
class p extends s {
|
|
5
|
-
static baseName = "image-preview";
|
|
6
|
-
urlList = [];
|
|
7
|
-
currentIndex = 0;
|
|
8
|
-
// 缩放
|
|
9
|
-
_scale = 1;
|
|
10
|
-
// 旋转
|
|
11
|
-
_rotate = 0;
|
|
12
|
-
setImages(e) {
|
|
13
|
-
this.urlList = e;
|
|
14
|
-
}
|
|
15
|
-
setCurrentIndex(e) {
|
|
16
|
-
this.currentIndex = e;
|
|
17
|
-
}
|
|
18
|
-
static customAttributes = ["current-index"];
|
|
19
|
-
connectedCallback() {
|
|
20
|
-
this.loadStyleText(l), super.connectedCallback();
|
|
21
|
-
}
|
|
22
|
-
contentRender() {
|
|
23
|
-
const e = [this._generateBtnString("close", "close")];
|
|
24
|
-
this.urlList.length > 1 && (e.push(this._generateBtnString("prev", "arrow-left")), e.push(this._generateBtnString("next", "arrow-right"))), e.push('<div class="l-image-preview-footer">'), e.push(
|
|
25
|
-
`<div class="l-image-preview-progress">${this._getProgress()}</div>`
|
|
26
|
-
), e.push(
|
|
27
|
-
'<div data-action="operations" class="l-image-preview-operations">'
|
|
28
|
-
), e.push(this._generateBtnString("zoom-in", "zoom-in")), e.push(this._generateBtnString("zoom-out", "zoom-out")), e.push(this._generateBtnString("reduction", "reduction")), e.push(this._generateBtnString("refresh-left", "refresh-left")), e.push(this._generateBtnString("refresh-right", "refresh-right")), e.push("</div></div>");
|
|
29
|
-
const t = this.urlList[this.currentIndex], i = this._getTransformStyleValue();
|
|
30
|
-
return e.push(
|
|
31
|
-
`<img src="${t}" data-action="previewer" class="l-image-preview-img" style="transform: ${i};" />`
|
|
32
|
-
), n("div", {
|
|
33
|
-
class: "l-image-preview--container",
|
|
34
|
-
innerHTML: e.join("")
|
|
35
|
-
});
|
|
36
|
-
}
|
|
37
|
-
_generateBtnString(e, t) {
|
|
38
|
-
return `<button aria-label="${e}" data-action="${e}" class="l-image-preview__btn l-image-preview__${e}"><l-${t}-icon></l-${t}-icon></button>`;
|
|
39
|
-
}
|
|
40
|
-
_getProgress() {
|
|
41
|
-
return `${this.currentIndex + 1} / ${this.urlList.length}`;
|
|
42
|
-
}
|
|
43
|
-
_getTransformStyleValue() {
|
|
44
|
-
return `scale3d(${this._scale}, ${this._scale}, 1) rotate3d(0, 0, 1, ${this._rotate}deg)`;
|
|
45
|
-
}
|
|
46
|
-
_updateImgAttr() {
|
|
47
|
-
const e = r(".l-image-preview-img", this.root);
|
|
48
|
-
e && (e.src = this.urlList[this.currentIndex], e.style.transform = this._getTransformStyleValue());
|
|
49
|
-
}
|
|
50
|
-
_updateProgress() {
|
|
51
|
-
const e = r(
|
|
52
|
-
".l-image-preview-progress",
|
|
53
|
-
this.root
|
|
54
|
-
);
|
|
55
|
-
e && (e.innerHTML = this._getProgress());
|
|
56
|
-
}
|
|
57
|
-
_resetTransform() {
|
|
58
|
-
this._scale = 1, this._rotate = 0, this._updateImgAttr();
|
|
59
|
-
}
|
|
60
|
-
onAction(e) {
|
|
61
|
-
switch (e) {
|
|
62
|
-
case "close":
|
|
63
|
-
this.open = !1;
|
|
64
|
-
break;
|
|
65
|
-
case "prev":
|
|
66
|
-
this.currentIndex === 0 ? this.currentIndex = this.urlList.length - 1 : this.currentIndex--, this._resetTransform(), this._updateProgress();
|
|
67
|
-
break;
|
|
68
|
-
case "next":
|
|
69
|
-
this.currentIndex === this.urlList.length - 1 ? this.currentIndex = 0 : this.currentIndex++, this._resetTransform(), this._updateProgress();
|
|
70
|
-
break;
|
|
71
|
-
case "zoom-in":
|
|
72
|
-
this._transformScale("in");
|
|
73
|
-
break;
|
|
74
|
-
case "zoom-out":
|
|
75
|
-
this._transformScale("out");
|
|
76
|
-
break;
|
|
77
|
-
case "reduction":
|
|
78
|
-
this._resetTransform();
|
|
79
|
-
break;
|
|
80
|
-
case "refresh-left":
|
|
81
|
-
this._rotate -= 90, this._updateImgAttr();
|
|
82
|
-
break;
|
|
83
|
-
case "refresh-right":
|
|
84
|
-
this._rotate += 90, this._updateImgAttr();
|
|
85
|
-
break;
|
|
86
|
-
}
|
|
87
|
-
return !0;
|
|
88
|
-
}
|
|
89
|
-
_handleWhell = (e) => {
|
|
90
|
-
e.deltaY > 0 ? this._transformScale("out") : this._transformScale("in");
|
|
91
|
-
};
|
|
92
|
-
afterOpened() {
|
|
93
|
-
a(document, "wheel", this._handleWhell, { passive: !0 });
|
|
94
|
-
}
|
|
95
|
-
_transformScale(e) {
|
|
96
|
-
e === "in" ? this._scale < 3 && (this._scale += 0.25) : this._scale > 0.25 && (this._scale -= 0.25), this._updateImgAttr();
|
|
97
|
-
}
|
|
98
|
-
afterClosed() {
|
|
99
|
-
o(document, "wheel", this._handleWhell);
|
|
100
|
-
}
|
|
101
|
-
}
|
|
102
|
-
export {
|
|
103
|
-
p as default
|
|
104
|
-
};
|
|
1
|
+
import { t as e } from "../image_preview-PzZzwo6m.js";
|
|
2
|
+
export { e as default };
|
package/lib/image/index.js
CHANGED
|
@@ -1,176 +1,2 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
3
|
-
import { $$ as l, formatClass as c, $one as h, on as s, off as r, addClass as g, removeClass as p, shouldEventNext as m } from "ph-utils/dom";
|
|
4
|
-
const f = ":host{vertical-align:middle;display:inline-flex;box-sizing:border-box;width:auto;height:auto}.l-image-inner{vertical-align:middle;width:100%;height:100%;object-fit:var(--l-image-fit, fill)}.l-image-inner--preview{cursor:pointer}.l-image-hide{display:none}.l-image-fallback{width:100%;height:100%;display:inline-flex;justify-content:center;align-items:center;background-color:#0000001a}";
|
|
5
|
-
class b extends o {
|
|
6
|
-
static baseName = "image";
|
|
7
|
-
alt;
|
|
8
|
-
_src = "";
|
|
9
|
-
/** eager - 立即加载图像, lazy - 懒加载 */
|
|
10
|
-
_loading = "eager";
|
|
11
|
-
fit;
|
|
12
|
-
width;
|
|
13
|
-
height;
|
|
14
|
-
fallback;
|
|
15
|
-
customFallback = !1;
|
|
16
|
-
/** 是否加载错误 */
|
|
17
|
-
isError = !1;
|
|
18
|
-
/** 是否禁用图片预览 */
|
|
19
|
-
previewDisabled = !1;
|
|
20
|
-
_previewEl;
|
|
21
|
-
_previewImageList;
|
|
22
|
-
_previewIndex = 0;
|
|
23
|
-
_placeholder;
|
|
24
|
-
_imageInner;
|
|
25
|
-
get src() {
|
|
26
|
-
return this._src;
|
|
27
|
-
}
|
|
28
|
-
set src(e) {
|
|
29
|
-
this._src = e, this._loadActualImage();
|
|
30
|
-
}
|
|
31
|
-
get loading() {
|
|
32
|
-
return this._loading;
|
|
33
|
-
}
|
|
34
|
-
set loading(e) {
|
|
35
|
-
this._loading = e;
|
|
36
|
-
}
|
|
37
|
-
get placeholder() {
|
|
38
|
-
return this._placeholder;
|
|
39
|
-
}
|
|
40
|
-
set placeholder(e) {
|
|
41
|
-
this._placeholder = e;
|
|
42
|
-
}
|
|
43
|
-
get previewImageList() {
|
|
44
|
-
return this._previewImageList;
|
|
45
|
-
}
|
|
46
|
-
set previewImageList(e) {
|
|
47
|
-
this.setPreviewImageList(e);
|
|
48
|
-
}
|
|
49
|
-
get previewIndex() {
|
|
50
|
-
return this._previewIndex;
|
|
51
|
-
}
|
|
52
|
-
set previewIndex(e) {
|
|
53
|
-
this.setPreviewIndex(e);
|
|
54
|
-
}
|
|
55
|
-
setPreviewImageList(e) {
|
|
56
|
-
this._previewImageList = e;
|
|
57
|
-
}
|
|
58
|
-
setPreviewIndex(e) {
|
|
59
|
-
this._previewIndex = e;
|
|
60
|
-
}
|
|
61
|
-
connectedCallback() {
|
|
62
|
-
this.loadStyleText(f), super.connectedCallback();
|
|
63
|
-
}
|
|
64
|
-
static get observedAttributes() {
|
|
65
|
-
return [
|
|
66
|
-
"src",
|
|
67
|
-
"loading",
|
|
68
|
-
"fit",
|
|
69
|
-
"width",
|
|
70
|
-
"height",
|
|
71
|
-
"placeholder",
|
|
72
|
-
"preview-disabled",
|
|
73
|
-
"preview-image-list",
|
|
74
|
-
"preview-index",
|
|
75
|
-
"fallback",
|
|
76
|
-
"custom-fallback"
|
|
77
|
-
];
|
|
78
|
-
}
|
|
79
|
-
attributeChangedCallback(e, i, a) {
|
|
80
|
-
e = n(e);
|
|
81
|
-
const t = d(
|
|
82
|
-
a,
|
|
83
|
-
this[e],
|
|
84
|
-
e
|
|
85
|
-
);
|
|
86
|
-
switch (t !== this[e] && (e === "previewImageList" ? this.setPreviewImageList(
|
|
87
|
-
t ? t.split(",") : void 0
|
|
88
|
-
) : this[e] = t), e) {
|
|
89
|
-
case "width":
|
|
90
|
-
case "height":
|
|
91
|
-
this.rendered && this._updateSize();
|
|
92
|
-
break;
|
|
93
|
-
}
|
|
94
|
-
}
|
|
95
|
-
render() {
|
|
96
|
-
const e = this.alt || this.getAttribute("alt"), i = this.placeholder || this.src;
|
|
97
|
-
return l("img", {
|
|
98
|
-
class: c([
|
|
99
|
-
"l-image-inner",
|
|
100
|
-
this.previewDisabled ? void 0 : "l-image-inner--preview"
|
|
101
|
-
]),
|
|
102
|
-
alt: e,
|
|
103
|
-
loading: this.loading,
|
|
104
|
-
src: i,
|
|
105
|
-
part: "inner",
|
|
106
|
-
"l-action": "inner"
|
|
107
|
-
});
|
|
108
|
-
}
|
|
109
|
-
_updateSize() {
|
|
110
|
-
this.width ? this.style.setProperty("width", this.width) : this.style.removeProperty("width"), this.height ? this.style.setProperty("height", this.height) : this.style.removeProperty("height");
|
|
111
|
-
}
|
|
112
|
-
afterInit() {
|
|
113
|
-
this.fit && this.fit !== "fill" && this.style.setProperty("--l-image-fit", this.fit), this._updateSize(), this._imageInner = h(".l-image-inner", this.root), s(this._imageInner, "click", this._onTap), s(this._imageInner, "error", this._onError), s(this._imageInner, "load", this._onLoad), this._loadActualImage();
|
|
114
|
-
}
|
|
115
|
-
beforeDestroy() {
|
|
116
|
-
this._imageInner && (r(this._imageInner, "click", this._onTap), r(this._imageInner, "error", this._onError), r(this._imageInner, "load", this._onLoad));
|
|
117
|
-
}
|
|
118
|
-
setIsError(e = !1) {
|
|
119
|
-
if (this.isError !== e)
|
|
120
|
-
if (this.isError = e, e) {
|
|
121
|
-
if (!this.customFallback) {
|
|
122
|
-
this.fallback && this._imageInner && (this._imageInner.src = this.fallback);
|
|
123
|
-
return;
|
|
124
|
-
}
|
|
125
|
-
this._imageInner && g(this._imageInner, "l-image-hide");
|
|
126
|
-
let i = h(".l-image-fallback", this.root);
|
|
127
|
-
this.fallback || (i = l("div", {
|
|
128
|
-
class: "l-image-fallback",
|
|
129
|
-
part: "fallback",
|
|
130
|
-
innerHTML: "<slot name='fallback'></slot>"
|
|
131
|
-
}), this.root.appendChild(i));
|
|
132
|
-
} else {
|
|
133
|
-
this._imageInner && p(this._imageInner, "l-image-hide");
|
|
134
|
-
const i = h(".l-image-fallback", this.root);
|
|
135
|
-
i && i.remove();
|
|
136
|
-
}
|
|
137
|
-
}
|
|
138
|
-
openPreview() {
|
|
139
|
-
if (!this._previewEl) {
|
|
140
|
-
const e = l("l-image-preview");
|
|
141
|
-
e.setImages(this.previewImageList || [this.src]), e.setCurrentIndex(this.previewIndex || 0), e.setAttribute("open", "on"), this._previewEl = e, document.body.appendChild(e), s(this._previewEl, "closed", this._onPreviewClosed);
|
|
142
|
-
}
|
|
143
|
-
}
|
|
144
|
-
closePreview() {
|
|
145
|
-
this._previewEl && (r(this._previewEl, "closed", this._onPreviewClosed), this._previewEl.remove(), this._previewEl = void 0);
|
|
146
|
-
}
|
|
147
|
-
_onError = () => {
|
|
148
|
-
this.setIsError(!0);
|
|
149
|
-
};
|
|
150
|
-
_onLoad = () => {
|
|
151
|
-
this.setIsError(!1);
|
|
152
|
-
};
|
|
153
|
-
_onPreviewClosed = () => {
|
|
154
|
-
this.closePreview();
|
|
155
|
-
};
|
|
156
|
-
_onTap = (e) => {
|
|
157
|
-
const [i, a] = m(e, "l-action", this.root);
|
|
158
|
-
i && a === "inner" && !this.previewDisabled && !this.isError && this.openPreview();
|
|
159
|
-
};
|
|
160
|
-
_clearTmpImg(e) {
|
|
161
|
-
e && (e.onload = null, e.onerror = null, e = void 0);
|
|
162
|
-
}
|
|
163
|
-
_loadActualImage() {
|
|
164
|
-
if (this.placeholder && this.rendered) {
|
|
165
|
-
let e = new Image();
|
|
166
|
-
e.src = this.src, e.onload = () => {
|
|
167
|
-
this._imageInner && (this._imageInner.src = this.src), this._clearTmpImg(e);
|
|
168
|
-
}, e.onerror = () => {
|
|
169
|
-
this.setIsError(!0), this._clearTmpImg(e);
|
|
170
|
-
};
|
|
171
|
-
}
|
|
172
|
-
}
|
|
173
|
-
}
|
|
174
|
-
export {
|
|
175
|
-
b as default
|
|
176
|
-
};
|
|
1
|
+
import { t as e } from "../image-CeQVfS-v.js";
|
|
2
|
+
export { e as default };
|
|
@@ -0,0 +1,162 @@
|
|
|
1
|
+
import e from "./base.js";
|
|
2
|
+
import { kebabToCamel as t, parseAttrValue as n } from "./utils/index.js";
|
|
3
|
+
import { $$ as r, $one as i, addClass as a, formatClass as o, off as s, on as c, removeClass as l, shouldEventNext as u } from "ph-utils/dom";
|
|
4
|
+
//#region src/components/image/index.less?inline
|
|
5
|
+
var d = ":host{vertical-align:middle;box-sizing:border-box;width:auto;height:auto;display:inline-flex}.l-image-inner{vertical-align:middle;object-fit:var(--l-image-fit,fill);width:100%;height:100%}.l-image-inner--preview{cursor:pointer}.l-image-hide{display:none}.l-image-fallback{background-color:#0000001a;justify-content:center;align-items:center;width:100%;height:100%;display:inline-flex}", f = class extends e {
|
|
6
|
+
static baseName = "image";
|
|
7
|
+
alt;
|
|
8
|
+
_src = "";
|
|
9
|
+
_loading = "eager";
|
|
10
|
+
fit;
|
|
11
|
+
width;
|
|
12
|
+
height;
|
|
13
|
+
fallback;
|
|
14
|
+
customFallback = !1;
|
|
15
|
+
isError = !1;
|
|
16
|
+
previewDisabled = !1;
|
|
17
|
+
_previewEl;
|
|
18
|
+
_previewImageList;
|
|
19
|
+
_previewIndex = 0;
|
|
20
|
+
_placeholder;
|
|
21
|
+
_imageInner;
|
|
22
|
+
get src() {
|
|
23
|
+
return this._src;
|
|
24
|
+
}
|
|
25
|
+
set src(e) {
|
|
26
|
+
this._src = e, this._loadActualImage();
|
|
27
|
+
}
|
|
28
|
+
get loading() {
|
|
29
|
+
return this._loading;
|
|
30
|
+
}
|
|
31
|
+
set loading(e) {
|
|
32
|
+
this._loading = e;
|
|
33
|
+
}
|
|
34
|
+
get placeholder() {
|
|
35
|
+
return this._placeholder;
|
|
36
|
+
}
|
|
37
|
+
set placeholder(e) {
|
|
38
|
+
this._placeholder = e;
|
|
39
|
+
}
|
|
40
|
+
get previewImageList() {
|
|
41
|
+
return this._previewImageList;
|
|
42
|
+
}
|
|
43
|
+
set previewImageList(e) {
|
|
44
|
+
this.setPreviewImageList(e);
|
|
45
|
+
}
|
|
46
|
+
get previewIndex() {
|
|
47
|
+
return this._previewIndex;
|
|
48
|
+
}
|
|
49
|
+
set previewIndex(e) {
|
|
50
|
+
this.setPreviewIndex(e);
|
|
51
|
+
}
|
|
52
|
+
setPreviewImageList(e) {
|
|
53
|
+
this._previewImageList = e;
|
|
54
|
+
}
|
|
55
|
+
setPreviewIndex(e) {
|
|
56
|
+
this._previewIndex = e;
|
|
57
|
+
}
|
|
58
|
+
connectedCallback() {
|
|
59
|
+
this.loadStyleText(d), super.connectedCallback();
|
|
60
|
+
}
|
|
61
|
+
static get observedAttributes() {
|
|
62
|
+
return [
|
|
63
|
+
"src",
|
|
64
|
+
"loading",
|
|
65
|
+
"fit",
|
|
66
|
+
"width",
|
|
67
|
+
"height",
|
|
68
|
+
"placeholder",
|
|
69
|
+
"preview-disabled",
|
|
70
|
+
"preview-image-list",
|
|
71
|
+
"preview-index",
|
|
72
|
+
"fallback",
|
|
73
|
+
"custom-fallback"
|
|
74
|
+
];
|
|
75
|
+
}
|
|
76
|
+
attributeChangedCallback(e, r, i) {
|
|
77
|
+
e = t(e);
|
|
78
|
+
let a = n(i, this[e], e);
|
|
79
|
+
switch (a !== this[e] && (e === "previewImageList" ? this.setPreviewImageList(a ? a.split(",") : void 0) : this[e] = a), e) {
|
|
80
|
+
case "width":
|
|
81
|
+
case "height":
|
|
82
|
+
this.rendered && this._updateSize();
|
|
83
|
+
break;
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
render() {
|
|
87
|
+
let e = this.alt || this.getAttribute("alt"), t = this.placeholder || this.src;
|
|
88
|
+
return r("img", {
|
|
89
|
+
class: o(["l-image-inner", this.previewDisabled ? void 0 : "l-image-inner--preview"]),
|
|
90
|
+
alt: e,
|
|
91
|
+
loading: this.loading,
|
|
92
|
+
src: t,
|
|
93
|
+
part: "inner",
|
|
94
|
+
"l-action": "inner"
|
|
95
|
+
});
|
|
96
|
+
}
|
|
97
|
+
_updateSize() {
|
|
98
|
+
this.width ? this.style.setProperty("width", this.width) : this.style.removeProperty("width"), this.height ? this.style.setProperty("height", this.height) : this.style.removeProperty("height");
|
|
99
|
+
}
|
|
100
|
+
afterInit() {
|
|
101
|
+
this.fit && this.fit !== "fill" && this.style.setProperty("--l-image-fit", this.fit), this._updateSize(), this._imageInner = i(".l-image-inner", this.root), c(this._imageInner, "click", this._onTap), c(this._imageInner, "error", this._onError), c(this._imageInner, "load", this._onLoad), this._loadActualImage();
|
|
102
|
+
}
|
|
103
|
+
beforeDestroy() {
|
|
104
|
+
this._imageInner && (s(this._imageInner, "click", this._onTap), s(this._imageInner, "error", this._onError), s(this._imageInner, "load", this._onLoad));
|
|
105
|
+
}
|
|
106
|
+
setIsError(e = !1) {
|
|
107
|
+
if (this.isError !== e) if (this.isError = e, e) {
|
|
108
|
+
if (!this.customFallback) {
|
|
109
|
+
this.fallback && this._imageInner && (this._imageInner.src = this.fallback);
|
|
110
|
+
return;
|
|
111
|
+
}
|
|
112
|
+
this._imageInner && a(this._imageInner, "l-image-hide");
|
|
113
|
+
let e = i(".l-image-fallback", this.root);
|
|
114
|
+
this.fallback || (e = r("div", {
|
|
115
|
+
class: "l-image-fallback",
|
|
116
|
+
part: "fallback",
|
|
117
|
+
innerHTML: "<slot name='fallback'></slot>"
|
|
118
|
+
}), this.root.appendChild(e));
|
|
119
|
+
} else {
|
|
120
|
+
this._imageInner && l(this._imageInner, "l-image-hide");
|
|
121
|
+
let e = i(".l-image-fallback", this.root);
|
|
122
|
+
e && e.remove();
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
openPreview() {
|
|
126
|
+
if (!this._previewEl) {
|
|
127
|
+
let e = r("l-image-preview");
|
|
128
|
+
e.setImages(this.previewImageList || [this.src]), e.setCurrentIndex(this.previewIndex || 0), e.setAttribute("open", "on"), this._previewEl = e, document.body.appendChild(e), c(this._previewEl, "closed", this._onPreviewClosed);
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
closePreview() {
|
|
132
|
+
this._previewEl &&= (s(this._previewEl, "closed", this._onPreviewClosed), this._previewEl.remove(), void 0);
|
|
133
|
+
}
|
|
134
|
+
_onError = () => {
|
|
135
|
+
this.setIsError(!0);
|
|
136
|
+
};
|
|
137
|
+
_onLoad = () => {
|
|
138
|
+
this.setIsError(!1);
|
|
139
|
+
};
|
|
140
|
+
_onPreviewClosed = () => {
|
|
141
|
+
this.closePreview();
|
|
142
|
+
};
|
|
143
|
+
_onTap = (e) => {
|
|
144
|
+
let [t, n] = u(e, "l-action", this.root);
|
|
145
|
+
t && n === "inner" && !this.previewDisabled && !this.isError && this.openPreview();
|
|
146
|
+
};
|
|
147
|
+
_clearTmpImg(e) {
|
|
148
|
+
e &&= (e.onload = null, e.onerror = null, void 0);
|
|
149
|
+
}
|
|
150
|
+
_loadActualImage() {
|
|
151
|
+
if (this.placeholder && this.rendered) {
|
|
152
|
+
let e = new Image();
|
|
153
|
+
e.src = this.src, e.onload = () => {
|
|
154
|
+
this._imageInner && (this._imageInner.src = this.src), this._clearTmpImg(e);
|
|
155
|
+
}, e.onerror = () => {
|
|
156
|
+
this.setIsError(!0), this._clearTmpImg(e);
|
|
157
|
+
};
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
};
|
|
161
|
+
//#endregion
|
|
162
|
+
export { f as t };
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
import { t as e } from "./mask-BlV5QfTj.js";
|
|
2
|
+
import { $$ as t, $one as n, off as r, on as i } from "ph-utils/dom";
|
|
3
|
+
//#region src/components/image/image_preview.less?inline
|
|
4
|
+
var a = ".l-image-preview--container{justify-content:center;align-items:center;width:100%;height:100%;display:flex;position:relative}.l-image-preview__btn,.l-image-preview-operations{background-color:#606666;justify-content:center;align-items:center;display:flex}.l-image-preview__btn{z-index:1;opacity:.8;cursor:pointer;color:#fff;background-color:#606666;border:none;border-radius:50%;outline:none;justify-content:center;align-items:center;width:40px;height:40px;font-size:20px;transition:color .3s ease-in-out;display:flex;position:absolute}.l-image-preview__btn:hover{color:var(--l-primary-color,#4998f6)}.l-image-preview__close{top:30px;right:30px}.l-image-preview__prev,.l-image-preview__next{top:50%;transform:translateY(-50%)}.l-image-preview__prev{left:30px}.l-image-preview__next{right:30px}.l-image-preview-footer{z-index:1;flex-direction:column;align-items:center;display:flex;position:absolute;bottom:30px;left:50%;transform:translate(-50%)}.l-image-preview-progress{color:#fff;margin-bottom:10px}.l-image-preview-operations{cursor:default;border-radius:20px;padding:0 25px}.l-image-preview-operations .l-image-preview__btn{width:40px;position:static}.l-image-preview-img{vertical-align:middle;transform-origin:50%;user-select:none;z-index:0;max-width:calc(100vw - 40px);max-height:calc(100vh - 200px);transition:transform .25s}", o = class extends e {
|
|
5
|
+
static baseName = "image-preview";
|
|
6
|
+
urlList = [];
|
|
7
|
+
currentIndex = 0;
|
|
8
|
+
_scale = 1;
|
|
9
|
+
_rotate = 0;
|
|
10
|
+
setImages(e) {
|
|
11
|
+
this.urlList = e;
|
|
12
|
+
}
|
|
13
|
+
setCurrentIndex(e) {
|
|
14
|
+
this.currentIndex = e;
|
|
15
|
+
}
|
|
16
|
+
static customAttributes = ["current-index"];
|
|
17
|
+
connectedCallback() {
|
|
18
|
+
this.loadStyleText(a), super.connectedCallback();
|
|
19
|
+
}
|
|
20
|
+
contentRender() {
|
|
21
|
+
let e = [this._generateBtnString("close", "close")];
|
|
22
|
+
this.urlList.length > 1 && (e.push(this._generateBtnString("prev", "arrow-left")), e.push(this._generateBtnString("next", "arrow-right"))), e.push("<div class=\"l-image-preview-footer\">"), e.push(`<div class="l-image-preview-progress">${this._getProgress()}</div>`), e.push("<div data-action=\"operations\" class=\"l-image-preview-operations\">"), e.push(this._generateBtnString("zoom-in", "zoom-in")), e.push(this._generateBtnString("zoom-out", "zoom-out")), e.push(this._generateBtnString("reduction", "reduction")), e.push(this._generateBtnString("refresh-left", "refresh-left")), e.push(this._generateBtnString("refresh-right", "refresh-right")), e.push("</div></div>");
|
|
23
|
+
let n = this.urlList[this.currentIndex], r = this._getTransformStyleValue();
|
|
24
|
+
return e.push(`<img src="${n}" data-action="previewer" class="l-image-preview-img" style="transform: ${r};" />`), t("div", {
|
|
25
|
+
class: "l-image-preview--container",
|
|
26
|
+
innerHTML: e.join("")
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
_generateBtnString(e, t) {
|
|
30
|
+
return `<button aria-label="${e}" data-action="${e}" class="l-image-preview__btn l-image-preview__${e}"><l-${t}-icon></l-${t}-icon></button>`;
|
|
31
|
+
}
|
|
32
|
+
_getProgress() {
|
|
33
|
+
return `${this.currentIndex + 1} / ${this.urlList.length}`;
|
|
34
|
+
}
|
|
35
|
+
_getTransformStyleValue() {
|
|
36
|
+
return `scale3d(${this._scale}, ${this._scale}, 1) rotate3d(0, 0, 1, ${this._rotate}deg)`;
|
|
37
|
+
}
|
|
38
|
+
_updateImgAttr() {
|
|
39
|
+
let e = n(".l-image-preview-img", this.root);
|
|
40
|
+
e && (e.src = this.urlList[this.currentIndex], e.style.transform = this._getTransformStyleValue());
|
|
41
|
+
}
|
|
42
|
+
_updateProgress() {
|
|
43
|
+
let e = n(".l-image-preview-progress", this.root);
|
|
44
|
+
e && (e.innerHTML = this._getProgress());
|
|
45
|
+
}
|
|
46
|
+
_resetTransform() {
|
|
47
|
+
this._scale = 1, this._rotate = 0, this._updateImgAttr();
|
|
48
|
+
}
|
|
49
|
+
onAction(e) {
|
|
50
|
+
switch (e) {
|
|
51
|
+
case "close":
|
|
52
|
+
this.open = !1;
|
|
53
|
+
break;
|
|
54
|
+
case "prev":
|
|
55
|
+
this.currentIndex === 0 ? this.currentIndex = this.urlList.length - 1 : this.currentIndex--, this._resetTransform(), this._updateProgress();
|
|
56
|
+
break;
|
|
57
|
+
case "next":
|
|
58
|
+
this.currentIndex === this.urlList.length - 1 ? this.currentIndex = 0 : this.currentIndex++, this._resetTransform(), this._updateProgress();
|
|
59
|
+
break;
|
|
60
|
+
case "zoom-in":
|
|
61
|
+
this._transformScale("in");
|
|
62
|
+
break;
|
|
63
|
+
case "zoom-out":
|
|
64
|
+
this._transformScale("out");
|
|
65
|
+
break;
|
|
66
|
+
case "reduction":
|
|
67
|
+
this._resetTransform();
|
|
68
|
+
break;
|
|
69
|
+
case "refresh-left":
|
|
70
|
+
this._rotate -= 90, this._updateImgAttr();
|
|
71
|
+
break;
|
|
72
|
+
case "refresh-right":
|
|
73
|
+
this._rotate += 90, this._updateImgAttr();
|
|
74
|
+
break;
|
|
75
|
+
}
|
|
76
|
+
return !0;
|
|
77
|
+
}
|
|
78
|
+
_handleWhell = (e) => {
|
|
79
|
+
e.deltaY > 0 ? this._transformScale("out") : this._transformScale("in");
|
|
80
|
+
};
|
|
81
|
+
afterOpened() {
|
|
82
|
+
i(document, "wheel", this._handleWhell, { passive: !0 });
|
|
83
|
+
}
|
|
84
|
+
_transformScale(e) {
|
|
85
|
+
e === "in" ? this._scale < 3 && (this._scale += .25) : this._scale > .25 && (this._scale -= .25), this._updateImgAttr();
|
|
86
|
+
}
|
|
87
|
+
afterClosed() {
|
|
88
|
+
r(document, "wheel", this._handleWhell);
|
|
89
|
+
}
|
|
90
|
+
};
|
|
91
|
+
//#endregion
|
|
92
|
+
export { o as t };
|