litos-ui 0.15.5 → 0.15.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/lib/button/index.d.ts +4 -0
- package/lib/button/index.js +84 -57
- package/lib/check/checkbox.js +1 -1
- package/lib/check/radio.js +1 -1
- package/lib/{check-BlDsQQo0.js → check-A86JxUfd.js} +1 -1
- package/lib/collapse/index.d.ts +19 -0
- package/lib/collapse/index.js +88 -0
- package/lib/collapse/item.d.ts +15 -0
- package/lib/collapse/item.js +115 -0
- package/lib/color_picker/index.js +1 -1
- package/lib/date_picker/index.js +1 -1
- package/lib/description_panel/index.d.ts +4 -4
- package/lib/description_panel/index.js +59 -11
- package/lib/dialog/dialog_container.js +1 -1
- package/lib/form/form_inner.d.ts +2 -1
- package/lib/form/form_inner.js +16 -15
- package/lib/form/form_item.d.ts +3 -1
- package/lib/form/form_item.js +19 -13
- package/lib/form/index.js +8 -6
- package/lib/icon/d_arrow_left.d.ts +6 -0
- package/lib/icon/d_arrow_left.js +13 -0
- package/lib/icon/d_arrow_right.d.ts +6 -0
- package/lib/icon/d_arrow_right.js +13 -0
- package/lib/icon/more.d.ts +6 -0
- package/lib/icon/more.js +13 -0
- package/lib/icon/select.d.ts +6 -0
- package/lib/icon/select.js +13 -0
- package/lib/icon/zoom_in.d.ts +6 -0
- package/lib/icon/zoom_in.js +13 -0
- package/lib/icon/zoom_out.d.ts +6 -0
- package/lib/icon/zoom_out.js +13 -0
- package/lib/image/image_preview.d.ts +24 -0
- package/lib/image/image_preview.js +104 -0
- package/lib/image/index.d.ts +50 -0
- package/lib/image/index.js +176 -0
- package/lib/index-D4II9KsF.js +4 -0
- package/lib/index.d.ts +36 -4
- package/lib/index.js +157 -120
- package/lib/input/index.d.ts +6 -2
- package/lib/input/index.js +70 -51
- package/lib/litos-ui.css +1 -1
- package/lib/mask/index.d.ts +23 -0
- package/lib/mask/index.js +110 -0
- package/lib/md_input/index.js +11 -11
- package/lib/menu/index.js +46 -42
- package/lib/modal/index.d.ts +1 -1
- package/lib/modal/index.js +7 -7
- package/lib/modal/modal_box.js +10 -10
- package/lib/page_header/index.d.ts +20 -0
- package/lib/page_header/index.js +109 -0
- package/lib/pagination/index.d.ts +27 -0
- package/lib/pagination/index.js +248 -0
- package/lib/qrcode/index.js +4 -4
- package/lib/select/index.d.ts +79 -0
- package/lib/select/index.js +406 -0
- package/lib/select_ori/index.js +10 -10
- package/lib/switch/index.js +4 -4
- package/lib/tabbar/index.js +1 -1
- package/lib/tabbar/item.js +1 -1
- package/lib/table/index.d.ts +46 -0
- package/lib/table/index.js +200 -0
- package/lib/table/types.d.ts +28 -0
- package/lib/table/types.js +1 -0
- package/lib/tabs/index.d.ts +7 -0
- package/lib/tabs/index.js +43 -0
- package/lib/tag/index.d.ts +16 -0
- package/lib/tag/index.js +77 -0
- package/lib/theme/index.js +6 -6
- package/lib/utils/index.d.ts +6 -28
- package/lib/utils/index.js +61 -86
- package/lib/utils/popover.d.ts +137 -0
- package/lib/utils/popover.js +354 -0
- package/lib/utils/transition.js +26 -50
- package/package.json +13 -13
- package/styles/popover.css +66 -0
- package/styles/reset.css +1 -1
- package/styles/select.css +37 -0
- package/styles/tabs.css +13 -0
- package/styles/vars.css +2 -1
- package/lib/index-dwS1N2uN.js +0 -4
- package/lib/popconfirm/index.d.ts +0 -7
- package/lib/popconfirm/index.js +0 -30
- package/lib/popover/index.d.ts +0 -34
- package/lib/popover/index.js +0 -150
package/lib/form/form_inner.js
CHANGED
|
@@ -2,7 +2,7 @@ import o from "../base.js";
|
|
|
2
2
|
import { parseAttrValue as d } from "../utils/index.js";
|
|
3
3
|
import { add as l, remove as u, emit as f } from "../utils/event.js";
|
|
4
4
|
import { getAttr as m } from "ph-utils/dom";
|
|
5
|
-
class
|
|
5
|
+
class c extends o {
|
|
6
6
|
disabled = !1;
|
|
7
7
|
formAttrs = {};
|
|
8
8
|
formItemAttrs = {};
|
|
@@ -13,9 +13,10 @@ class _ extends o {
|
|
|
13
13
|
/**
|
|
14
14
|
*
|
|
15
15
|
* @param firstPushValue 是否第一次赋值 value 时, 推送数据到 Form, 默认: true
|
|
16
|
+
* @param delegatesFocus 是否委托焦点, 默认: true
|
|
16
17
|
*/
|
|
17
|
-
constructor(t = !0) {
|
|
18
|
-
super(!0, { delegatesFocus:
|
|
18
|
+
constructor(t = !0, e = !0) {
|
|
19
|
+
super(!0, { delegatesFocus: e }), this._firstPushValue = t;
|
|
19
20
|
}
|
|
20
21
|
get value() {
|
|
21
22
|
return this._value;
|
|
@@ -32,13 +33,13 @@ class _ extends o {
|
|
|
32
33
|
static get observedAttributes() {
|
|
33
34
|
return ["disabled", "value"];
|
|
34
35
|
}
|
|
35
|
-
attributeChangedCallback(t,
|
|
36
|
+
attributeChangedCallback(t, e, r) {
|
|
36
37
|
if (t === "disabled") {
|
|
37
|
-
const i = d(
|
|
38
|
+
const i = d(r, !1, t);
|
|
38
39
|
i !== this.disabled && (this.disabled = i, this.disabledChange());
|
|
39
|
-
} else t === "value" ? this.value =
|
|
40
|
+
} else t === "value" ? this.value = r : this.attributeChange(t, e, r);
|
|
40
41
|
}
|
|
41
|
-
attributeChange(t,
|
|
42
|
+
attributeChange(t, e, r) {
|
|
42
43
|
}
|
|
43
44
|
connectedCallback() {
|
|
44
45
|
const t = this._getForm();
|
|
@@ -63,14 +64,14 @@ class _ extends o {
|
|
|
63
64
|
return t || this.formItemAttrs.name;
|
|
64
65
|
}
|
|
65
66
|
_getForm() {
|
|
66
|
-
let t = this.parentElement,
|
|
67
|
+
let t = this.parentElement, e = {}, r = {};
|
|
67
68
|
for (; t != null; ) {
|
|
68
69
|
const i = t.tagName;
|
|
69
70
|
if (i === "L-FORM") {
|
|
70
71
|
const a = t.sharedAttrs;
|
|
71
72
|
for (let s = 0; s < a.length; s++) {
|
|
72
73
|
const h = a[s];
|
|
73
|
-
|
|
74
|
+
e[h] = t[h];
|
|
74
75
|
}
|
|
75
76
|
break;
|
|
76
77
|
}
|
|
@@ -79,18 +80,18 @@ class _ extends o {
|
|
|
79
80
|
const a = t.sharedAttrs;
|
|
80
81
|
for (let s = 0; s < a.length; s++) {
|
|
81
82
|
const h = a[s];
|
|
82
|
-
|
|
83
|
+
r[h] = t[h];
|
|
83
84
|
}
|
|
84
85
|
}
|
|
85
86
|
t = t.parentElement;
|
|
86
87
|
}
|
|
87
88
|
return t = null, {
|
|
88
|
-
formAttr:
|
|
89
|
-
formItemAttr:
|
|
89
|
+
formAttr: e,
|
|
90
|
+
formItemAttr: r
|
|
90
91
|
};
|
|
91
92
|
}
|
|
92
|
-
_formAttributeChanged = (t,
|
|
93
|
-
|
|
93
|
+
_formAttributeChanged = (t, e, r) => {
|
|
94
|
+
r === this.formAttrs.formId ? this.formAttrs[t] = e : this.formItemAttrs[t] = e, t === "disabled" && this.disabledChange();
|
|
94
95
|
};
|
|
95
96
|
disabledChange() {
|
|
96
97
|
}
|
|
@@ -112,5 +113,5 @@ class _ extends o {
|
|
|
112
113
|
}
|
|
113
114
|
}
|
|
114
115
|
export {
|
|
115
|
-
|
|
116
|
+
c as default
|
|
116
117
|
};
|
package/lib/form/form_item.d.ts
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import BaseComponent from "../base";
|
|
2
2
|
import type { RuleType } from "ph-utils/validator";
|
|
3
3
|
export default class FormItem extends BaseComponent {
|
|
4
|
+
#private;
|
|
4
5
|
static baseName: string;
|
|
5
6
|
disabled: boolean;
|
|
6
7
|
sharedAttrs: string[];
|
|
7
8
|
/** 是否必须 */
|
|
8
9
|
required: boolean;
|
|
9
|
-
error?: string;
|
|
10
10
|
/** 标签文本 */
|
|
11
11
|
label?: string;
|
|
12
12
|
/** 内置验证规则: required - 必填, same:password - 一般用于验证确认密码和密码, phone - 验证电话号码 */
|
|
@@ -20,6 +20,8 @@ export default class FormItem extends BaseComponent {
|
|
|
20
20
|
labelPosition?: "left" | "right" | "top";
|
|
21
21
|
private formId?;
|
|
22
22
|
static get observedAttributes(): string[];
|
|
23
|
+
get error(): string | undefined;
|
|
24
|
+
set error(error: string | undefined);
|
|
23
25
|
attributeChangedCallback(name: string, oldValue: string, newValue: string): void;
|
|
24
26
|
connectedCallback(): void;
|
|
25
27
|
disconnectedCallback(): void;
|
package/lib/form/form_item.js
CHANGED
|
@@ -1,16 +1,15 @@
|
|
|
1
|
-
import { $$ as i, $one as
|
|
1
|
+
import { $$ as i, $one as o, addClass as n, removeClass as d } from "ph-utils/dom";
|
|
2
2
|
import { parseAttrValue as h, initAttr as m } from "../utils/index.js";
|
|
3
3
|
import f from "../base.js";
|
|
4
|
-
import { emit as
|
|
4
|
+
import { emit as s, add as c, clear as p, remove as b } from "../utils/event.js";
|
|
5
5
|
import { random as a } from "ph-utils";
|
|
6
|
-
const u = ':host{display:var(--l-form-item-display, flex);font-size:14px}.l-form-item__label{text-align:var(--l-form-label-align, right);display:inline-block;width:var(--l-form-label-width, auto);height:var(--l-form-
|
|
6
|
+
const u = ':host{display:var(--l-form-item-display, flex);font-size:14px}.l-form-item__label{text-align:var(--l-form-label-align, right);display:inline-block;width:var(--l-form-label-width, auto);height:var(--l-form-control-height, 32px);line-height:var(--l-form-control-height, 32px);color:#606266;padding:0 10px 0 0;box-sizing:border-box}.l-form-item__label:empty{display:var(--l-form-label-empty-display, inline-block)}:host(.is-required) .l-form-item__label:before{content:"*";margin-right:4px;color:var(--l-warn-color, #f56c6c);vertical-align:middle}.l-form-item__content{flex:1;position:relative;display:flex;align-items:center}.l-form-item__error{font-size:12px;line-height:1;position:absolute;top:100%;left:0;color:var(--nt-error-color, #ed3f13);padding-top:3px}:host(.l-form-item--left){--l-form-label-align: left}:host(.l-form-item--top){--l-form-item-display: grid;--l-form-label-align: left;--l-form-label-empty-display: none;grid-template-columns:1fr}';
|
|
7
7
|
class I extends f {
|
|
8
8
|
static baseName = "form-item";
|
|
9
9
|
disabled = !1;
|
|
10
10
|
sharedAttrs = ["disabled", "id", "name", "innerBlock"];
|
|
11
11
|
/** 是否必须 */
|
|
12
12
|
required = !1;
|
|
13
|
-
error;
|
|
14
13
|
/** 标签文本 */
|
|
15
14
|
label;
|
|
16
15
|
/** 内置验证规则: required - 必填, same:password - 一般用于验证确认密码和密码, phone - 验证电话号码 */
|
|
@@ -23,17 +22,24 @@ class I extends f {
|
|
|
23
22
|
innerBlock = !1;
|
|
24
23
|
labelPosition = "right";
|
|
25
24
|
formId;
|
|
25
|
+
#e;
|
|
26
26
|
static get observedAttributes() {
|
|
27
27
|
return ["error", "label", "disabled"];
|
|
28
28
|
}
|
|
29
|
+
get error() {
|
|
30
|
+
return this.#e;
|
|
31
|
+
}
|
|
32
|
+
set error(e) {
|
|
33
|
+
this.#e = e, this._updateError();
|
|
34
|
+
}
|
|
29
35
|
attributeChangedCallback(e, t, r) {
|
|
30
36
|
if (e === "error")
|
|
31
|
-
r != this
|
|
37
|
+
r != this.#e && (this.error = r);
|
|
32
38
|
else if (e === "label")
|
|
33
39
|
this.label = r, this._updateLabel();
|
|
34
40
|
else if (e === "disabled") {
|
|
35
41
|
const l = h(r, !1, e);
|
|
36
|
-
l !== this.disabled && (
|
|
42
|
+
l !== this.disabled && (s(this.id, "attributeChanged", e, l, this.id), this.disabled = l);
|
|
37
43
|
}
|
|
38
44
|
}
|
|
39
45
|
connectedCallback() {
|
|
@@ -46,15 +52,15 @@ class I extends f {
|
|
|
46
52
|
message: this.validity,
|
|
47
53
|
rules: e
|
|
48
54
|
};
|
|
49
|
-
|
|
55
|
+
s(this.formId, "ruleChange", t), c(this.formId, "validateChange", this._validateChange);
|
|
50
56
|
}
|
|
51
57
|
}
|
|
52
58
|
disconnectedCallback() {
|
|
53
|
-
|
|
59
|
+
p(this.id), this.formId && b(this.formId, "validateChange", this._validateChange);
|
|
54
60
|
}
|
|
55
61
|
setRules(e) {
|
|
56
62
|
const t = { ...e, key: this.name };
|
|
57
|
-
t.required != null && this.required && (t.required = !0), this.formId &&
|
|
63
|
+
t.required != null && this.required && (t.required = !0), this.formId && s(this.formId, "ruleChange", t);
|
|
58
64
|
}
|
|
59
65
|
setError(e) {
|
|
60
66
|
this.error = e;
|
|
@@ -75,23 +81,23 @@ class I extends f {
|
|
|
75
81
|
}
|
|
76
82
|
_validateChange = (e, t) => {
|
|
77
83
|
const r = e === !0 ? void 0 : e[this.name];
|
|
78
|
-
(t == null || t === this.name && this.error != r) && (this.error = r
|
|
84
|
+
(t == null || t === this.name && this.error != r) && (this.error = r);
|
|
79
85
|
};
|
|
80
86
|
_updateError() {
|
|
81
87
|
if (!this.rendered) return;
|
|
82
|
-
let e =
|
|
88
|
+
let e = o(".l-form-item__error", this.root);
|
|
83
89
|
if (e)
|
|
84
90
|
this.error ? e.textContent = this.error : e.remove();
|
|
85
91
|
else if (this.error) {
|
|
86
92
|
e = document.createElement("div"), e.className = "l-form-item__error", e.textContent = this.error;
|
|
87
|
-
const t =
|
|
93
|
+
const t = o(".l-form-item__content", this.root);
|
|
88
94
|
t && t.appendChild(e);
|
|
89
95
|
}
|
|
90
96
|
this.error ? n(this, "is-error") : d(this, "is-error");
|
|
91
97
|
}
|
|
92
98
|
_updateLabel() {
|
|
93
99
|
if (!this.rendered) return;
|
|
94
|
-
let e =
|
|
100
|
+
let e = o(".l-form-item__label", this.root);
|
|
95
101
|
e == null ? this.label != null && (e = document.createElement("div"), e.className = "l-form-item__label", e.textContent = this.label, this.root.prepend(e)) : this.label != null ? e.textContent = this.label : e.remove();
|
|
96
102
|
}
|
|
97
103
|
_getFormId() {
|
package/lib/form/index.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { $one as
|
|
1
|
+
import { $one as n, formatClass as o, formatStyle as f } from "ph-utils/dom";
|
|
2
2
|
import m from "../base.js";
|
|
3
3
|
import { parseAttrValue as c, initAttr as u } from "../utils/index.js";
|
|
4
4
|
import { random as d } from "ph-utils";
|
|
5
|
-
import { emit as l, add as
|
|
5
|
+
import { emit as l, add as h, clear as v } from "../utils/event.js";
|
|
6
6
|
import p from "ph-utils/validator";
|
|
7
7
|
const b = ":host{display:block}.l-form{display:flex;gap:20px;flex-flow:column nowrap}.l-form-inline{display:flex;gap:20px;flex-flow:row wrap}.l-form.l-form-inline{--l-form-item-display: flex}.l-form.l-form--left{--l-form-label-align: left}.l-form.l-form--top{--l-form-item-display: grid;--l-form-label-align: left;--l-form-label-empty-display: none;grid-template-columns:1fr}";
|
|
8
8
|
class $ extends m {
|
|
@@ -28,7 +28,7 @@ class $ extends m {
|
|
|
28
28
|
const a = c(i, !1, t);
|
|
29
29
|
a !== this.disabled && (l(this.id, "attributeChanged", t, a, this.id), this.disabled = a);
|
|
30
30
|
} else if (t === "label-position") {
|
|
31
|
-
const a =
|
|
31
|
+
const a = n("form", this.root);
|
|
32
32
|
a && (a.className = o([
|
|
33
33
|
"l-form",
|
|
34
34
|
this.inline ? "l-form-inline" : void 0,
|
|
@@ -37,7 +37,7 @@ class $ extends m {
|
|
|
37
37
|
}
|
|
38
38
|
}
|
|
39
39
|
connectedCallback() {
|
|
40
|
-
u(this), this.id || (this.id = `l-f${d(3)}-${d(6)}`), this.loadStyleText([b]), super.connectedCallback(),
|
|
40
|
+
u(this), this.id || (this.id = `l-f${d(3)}-${d(6)}`), this.loadStyleText([b]), super.connectedCallback(), h(this.id, "ruleChange", this.ruleChange), h(this.id, "valueChange", this._valueChange);
|
|
41
41
|
}
|
|
42
42
|
disconnectedCallback() {
|
|
43
43
|
v(this.id), this.validator = void 0;
|
|
@@ -96,8 +96,10 @@ class $ extends m {
|
|
|
96
96
|
this.clearValidate(), l(this.id, "reset");
|
|
97
97
|
}
|
|
98
98
|
submit() {
|
|
99
|
-
this.novalidate ? this.dispatchEvent(new CustomEvent("submit")) : this.validate().then((t) => {
|
|
100
|
-
t && this.dispatchEvent(
|
|
99
|
+
this.novalidate ? this.dispatchEvent(new CustomEvent("submit", { detail: this.getData() })) : this.validate().then((t) => {
|
|
100
|
+
t && this.dispatchEvent(
|
|
101
|
+
new CustomEvent("submit", { detail: this.getData() })
|
|
102
|
+
);
|
|
101
103
|
});
|
|
102
104
|
}
|
|
103
105
|
/**
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import a from "./base.js";
|
|
2
|
+
class t extends a {
|
|
3
|
+
static baseName = "d-arrow-left-icon";
|
|
4
|
+
constructor() {
|
|
5
|
+
super(), this.viewBox = "0 0 1024 1024";
|
|
6
|
+
}
|
|
7
|
+
renderChildren() {
|
|
8
|
+
return '<path d="M529.408 149.376a29.12 29.12 0 0 1 41.728 0 30.592 30.592 0 0 1 0 42.688L259.264 511.936l311.872 319.936a30.592 30.592 0 0 1-.512 43.264 29.12 29.12 0 0 1-41.216-.512L197.76 534.272a32 32 0 0 1 0-44.672l331.648-340.224zm256 0a29.12 29.12 0 0 1 41.728 0 30.592 30.592 0 0 1 0 42.688L515.264 511.936l311.872 319.936a30.592 30.592 0 0 1-.512 43.264 29.12 29.12 0 0 1-41.216-.512L453.76 534.272a32 32 0 0 1 0-44.672l331.648-340.224z"></path>';
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
export {
|
|
12
|
+
t as default
|
|
13
|
+
};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import a from "./base.js";
|
|
2
|
+
class t extends a {
|
|
3
|
+
static baseName = "d-arrow-right-icon";
|
|
4
|
+
constructor() {
|
|
5
|
+
super(), this.viewBox = "0 0 1024 1024";
|
|
6
|
+
}
|
|
7
|
+
renderChildren() {
|
|
8
|
+
return '<path d="M452.864 149.312a29.12 29.12 0 0 1 41.728.064L826.24 489.664a32 32 0 0 1 0 44.672L494.592 874.624a29.12 29.12 0 0 1-41.728 0 30.592 30.592 0 0 1 0-42.752L764.736 512 452.864 192a30.592 30.592 0 0 1 0-42.688m-256 0a29.12 29.12 0 0 1 41.728.064L570.24 489.664a32 32 0 0 1 0 44.672L238.592 874.624a29.12 29.12 0 0 1-41.728 0 30.592 30.592 0 0 1 0-42.752L508.736 512 196.864 192a30.592 30.592 0 0 1 0-42.688z"></path>';
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
export {
|
|
12
|
+
t as default
|
|
13
|
+
};
|
package/lib/icon/more.js
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import e from "./base.js";
|
|
2
|
+
class t extends e {
|
|
3
|
+
static baseName = "more-icon";
|
|
4
|
+
constructor() {
|
|
5
|
+
super(), this.viewBox = "0 0 1024 1024";
|
|
6
|
+
}
|
|
7
|
+
renderChildren() {
|
|
8
|
+
return '<path d="M176 416a112 112 0 1 1 0 224 112 112 0 0 1 0-224m336 0a112 112 0 1 1 0 224 112 112 0 0 1 0-224m336 0a112 112 0 1 1 0 224 112 112 0 0 1 0-224"></path>';
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
export {
|
|
12
|
+
t as default
|
|
13
|
+
};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import e from "./base.js";
|
|
2
|
+
class t extends e {
|
|
3
|
+
static baseName = "select-icon";
|
|
4
|
+
connectedCallback() {
|
|
5
|
+
super.connectedCallback();
|
|
6
|
+
}
|
|
7
|
+
renderChildren() {
|
|
8
|
+
return '<path fill="currentColor" d="M77.248 415.04a64 64 0 0 1 90.496 0l226.304 226.304L846.528 188.8a64 64 0 1 1 90.56 90.496l-543.04 543.04-316.8-316.8a64 64 0 0 1 0-90.496z"></path>';
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
export {
|
|
12
|
+
t as default
|
|
13
|
+
};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import a from "./base.js";
|
|
2
|
+
class o extends a {
|
|
3
|
+
static baseName = "zoom-in-icon";
|
|
4
|
+
connectedCallback() {
|
|
5
|
+
super.connectedCallback();
|
|
6
|
+
}
|
|
7
|
+
renderChildren() {
|
|
8
|
+
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>';
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
export {
|
|
12
|
+
o as default
|
|
13
|
+
};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import a from "./base.js";
|
|
2
|
+
class t extends a {
|
|
3
|
+
static baseName = "zoom-out-icon";
|
|
4
|
+
connectedCallback() {
|
|
5
|
+
super.connectedCallback();
|
|
6
|
+
}
|
|
7
|
+
renderChildren() {
|
|
8
|
+
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>';
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
export {
|
|
12
|
+
t as default
|
|
13
|
+
};
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import Mask from "../mask";
|
|
2
|
+
export default class ImagePreview extends Mask {
|
|
3
|
+
static baseName: string;
|
|
4
|
+
urlList: string[];
|
|
5
|
+
currentIndex: number;
|
|
6
|
+
private _scale;
|
|
7
|
+
private _rotate;
|
|
8
|
+
setImages(urlList: string[]): void;
|
|
9
|
+
setCurrentIndex(index: number): void;
|
|
10
|
+
static customAttributes: string[];
|
|
11
|
+
connectedCallback(): void;
|
|
12
|
+
contentRender(): string | HTMLElement | DocumentFragment;
|
|
13
|
+
_generateBtnString(name: string, iconName: string): string;
|
|
14
|
+
_getProgress(): string;
|
|
15
|
+
_getTransformStyleValue(): string;
|
|
16
|
+
private _updateImgAttr;
|
|
17
|
+
private _updateProgress;
|
|
18
|
+
private _resetTransform;
|
|
19
|
+
onAction(action: string): boolean;
|
|
20
|
+
private _handleWhell;
|
|
21
|
+
afterOpened(): void;
|
|
22
|
+
private _transformScale;
|
|
23
|
+
afterClosed(): void;
|
|
24
|
+
}
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
import s from "../mask/index.js";
|
|
2
|
+
import { $$ as n, $one as r, on as a, off as o } from "ph-utils/dom";
|
|
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 g 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.preventDefault(), 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
|
+
g as default
|
|
104
|
+
};
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import BaseComponent from "../base";
|
|
2
|
+
export default class ImageHTML extends BaseComponent {
|
|
3
|
+
static baseName: string;
|
|
4
|
+
alt?: string;
|
|
5
|
+
private _src;
|
|
6
|
+
/** eager - 立即加载图像, lazy - 懒加载 */
|
|
7
|
+
private _loading;
|
|
8
|
+
fit?: "fill" | "contain" | "cover" | "none" | "scale-down";
|
|
9
|
+
width?: string;
|
|
10
|
+
height?: string;
|
|
11
|
+
fallback?: string;
|
|
12
|
+
customFallback?: boolean;
|
|
13
|
+
/** 是否加载错误 */
|
|
14
|
+
isError?: boolean;
|
|
15
|
+
/** 是否禁用图片预览 */
|
|
16
|
+
previewDisabled?: boolean;
|
|
17
|
+
private _previewEl?;
|
|
18
|
+
private _previewImageList?;
|
|
19
|
+
private _previewIndex?;
|
|
20
|
+
private _placeholder?;
|
|
21
|
+
private _imageInner?;
|
|
22
|
+
get src(): string;
|
|
23
|
+
set src(value: string);
|
|
24
|
+
get loading(): "lazy" | "eager";
|
|
25
|
+
set loading(value: "lazy" | "eager");
|
|
26
|
+
get placeholder(): string | undefined;
|
|
27
|
+
set placeholder(value: string);
|
|
28
|
+
get previewImageList(): string[] | undefined;
|
|
29
|
+
set previewImageList(value: string[]);
|
|
30
|
+
get previewIndex(): number | undefined;
|
|
31
|
+
set previewIndex(value: number);
|
|
32
|
+
setPreviewImageList(imageList: string[] | undefined): void;
|
|
33
|
+
setPreviewIndex(index: number): void;
|
|
34
|
+
connectedCallback(): void;
|
|
35
|
+
static get observedAttributes(): string[];
|
|
36
|
+
attributeChangedCallback(name: string, oldValue: string, newValue: string): void;
|
|
37
|
+
render(): HTMLElement;
|
|
38
|
+
private _updateSize;
|
|
39
|
+
afterInit(): void;
|
|
40
|
+
beforeDestroy(): void;
|
|
41
|
+
setIsError(isError?: boolean): void;
|
|
42
|
+
openPreview(): void;
|
|
43
|
+
closePreview(): void;
|
|
44
|
+
private _onError;
|
|
45
|
+
private _onLoad;
|
|
46
|
+
private _onPreviewClosed;
|
|
47
|
+
private _onTap;
|
|
48
|
+
private _clearTmpImg;
|
|
49
|
+
private _loadActualImage;
|
|
50
|
+
}
|