litos-ui 0.17.1 → 0.17.3
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/base.d.ts +13 -1
- package/lib/base.js +35 -5
- package/lib/button/index.js +32 -17
- package/lib/calendar/index.d.ts +30 -0
- package/lib/calendar/index.js +91 -0
- package/lib/calendar/langs.d.ts +4 -0
- package/lib/calendar/langs.js +8 -0
- package/lib/{date_picker → date_picker_ori}/index.d.ts +15 -7
- package/lib/date_picker_ori/index.js +129 -0
- package/lib/dialog/dialog_container.d.ts +16 -8
- package/lib/dialog/dialog_container.js +95 -62
- package/lib/form/form_inner.js +1 -1
- package/lib/form/index.js +5 -5
- package/lib/index.d.ts +5 -3
- package/lib/index.js +16 -14
- package/lib/modal/index.d.ts +24 -6
- package/lib/modal/index.js +145 -96
- package/lib/modal/modal_box.js +9 -13
- package/lib/theme/theme_color.d.ts +10 -4
- package/lib/theme/theme_color.js +14 -17
- package/package.json +1 -1
- package/lib/date_picker/index.js +0 -99
package/lib/modal/index.js
CHANGED
|
@@ -1,147 +1,196 @@
|
|
|
1
|
-
import
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
const
|
|
5
|
-
class
|
|
1
|
+
import f from "../base.js";
|
|
2
|
+
import { $one as d, transition as r, $$ as a, on as b, off as x, shouldEventNext as k } from "ph-utils/dom";
|
|
3
|
+
import { parseAttrValue as n, unitNumberStr as g, kebabToCamel as u } from "../utils/index.js";
|
|
4
|
+
const y = ":host{display:none}:host(.open){display:block}.l-modal-mask{z-index:var(--l-modal-zindex, 100)}.l-modal-wrapper{position:fixed;top:0;left:0;width:100%;height:100%;z-index:calc(var(--l-modal-zindex, 100) + 1)}.l-modal{--l-modal-translate: translate3d(0, 80px, 0);background-color:#fff;border-radius:5px;width:var(--l-modal-width, 27%);margin:auto;box-shadow:0 0 8px #0000001a;position:relative;opacity:1;transform:var(--l-modal-translate) scaleZ(1);transition:opacity .3s,transform .3s}.l-modal-header{display:block;padding:10px;font-size:16px;border-bottom:1px solid var(--l-modal-line-color, rgba(0, 0, 0, .06));font-weight:600;display:flex;align-items:center;gap:5px}.l-modal-footer{padding:10px;border-top:1px solid var(--l-modal-line-color, rgba(0, 0, 0, .06));display:flex;justify-content:flex-end;gap:10px}.l-modal-container{padding:var(--l-modal-container-padding, 15px 10px);font-size:14px}.l-btn-modal-close{--l-form-control-height: auto;position:absolute}.l-modal-close1{right:5px;top:8px}.l-modal-close1::part(default){width:auto;height:auto;padding:5px;border:none;font-size:16px}.l-modal-close2{right:-10px;top:-10px}.l-modal-close2::part(default){width:20px;height:20px;padding:0;background-color:#fff}.mask-transition-enter-from,.mask-transition-leave-to{opacity:0}.modal-transition-enter-from,.modal-transition-leave-to{transform:translateZ(0) scale3d(0,0,0)}.l-modal--mobile{border-radius:10px}.l-modal--mobile .l-modal-header{text-align:center;border-bottom-color:transparent;padding:20px 10px 5px;display:flex;justify-content:center}.l-modal--mobile .l-modal-container{--l-modal-container-padding: 5px 15px 20px;text-align:center}.l-modal--mobile .l-modal-footer{display:flex;justify-content:stretch;align-items:stretch;padding:0;text-align:center;height:50px;gap:0}.l-modal--mobile .l-modal-footer-btn{flex-grow:1;height:100%}.l-modal--mobile .l-modal-footer-btn+.l-modal-footer-btn{border-left:1px solid var(--l-modal-line-color, rgba(0, 0, 0, .06))}.l-modal--middle{--l-modal-translate: translate3d(0, -50%, 0);top:50%}.l-modal--bottom{--l-modal-translate: translate3d(0, -100%, 0);top:100%;width:100%;border-bottom-left-radius:0;border-bottom-right-radius:0}@media screen and (max-width:768px){:host{--l-modal-width: 80%}}", v = ".l-mask{position:fixed;z-index:var(--l-mask-zindex, 100);inset:0;background-color:#0009;transition:opacity .3s;opacity:1}";
|
|
5
|
+
class z extends f {
|
|
6
6
|
static baseName = "modal";
|
|
7
|
-
/** 关闭时销毁 Modal 里的子元素 */
|
|
8
|
-
destroyOnClose = !1;
|
|
9
|
-
/** 点击蒙层是否允许关闭 */
|
|
10
|
-
maskClosable = !0;
|
|
11
|
-
/** 是否展示遮罩 */
|
|
12
|
-
mask = !0;
|
|
13
|
-
/** 是否显示取消按钮 */
|
|
14
|
-
cancel = !0;
|
|
15
|
-
/** 取消按钮文本 */
|
|
16
|
-
cancelText = "取消";
|
|
17
|
-
/** 确定按钮文本 */
|
|
18
|
-
okText = "确定";
|
|
19
|
-
/** 对话框宽度 */
|
|
20
|
-
width;
|
|
21
|
-
/** 确认按钮加载中 */
|
|
22
|
-
confirmLoading = !1;
|
|
23
|
-
/** 右上角关闭按钮, 1-显示在框内,2-显示在框角, 0-不显示 */
|
|
24
|
-
close = 1;
|
|
25
|
-
/** 对话框垂直方向位置 */
|
|
26
|
-
verticalAlign = "top";
|
|
27
|
-
/** 是否是移动风格弹出框 */
|
|
28
|
-
mobile = !1;
|
|
29
|
-
/** 设置 Modal 的 z-index */
|
|
30
|
-
zIndex;
|
|
31
7
|
_bodyOverflow = "";
|
|
8
|
+
constructor() {
|
|
9
|
+
super(), this.version = 2, this._state = {
|
|
10
|
+
destroyOnClose: !1,
|
|
11
|
+
maskClosable: !0,
|
|
12
|
+
mask: !0,
|
|
13
|
+
cancel: !0,
|
|
14
|
+
cancelText: "取消",
|
|
15
|
+
okText: "确定",
|
|
16
|
+
confirmLoading: !1,
|
|
17
|
+
close: 1,
|
|
18
|
+
verticalAlign: "top",
|
|
19
|
+
mobile: !1,
|
|
20
|
+
show: !1,
|
|
21
|
+
header: !0,
|
|
22
|
+
footer: !0
|
|
23
|
+
};
|
|
24
|
+
}
|
|
32
25
|
static get observedAttributes() {
|
|
33
|
-
return [
|
|
26
|
+
return [
|
|
27
|
+
"show",
|
|
28
|
+
"width",
|
|
29
|
+
"confirm-loading",
|
|
30
|
+
"destroy-on-close",
|
|
31
|
+
"mask-closable",
|
|
32
|
+
"mask",
|
|
33
|
+
"cancel",
|
|
34
|
+
"cancel-text",
|
|
35
|
+
"ok-text",
|
|
36
|
+
"close",
|
|
37
|
+
"vertical-align",
|
|
38
|
+
"mobile",
|
|
39
|
+
"z-index",
|
|
40
|
+
"header",
|
|
41
|
+
"footer",
|
|
42
|
+
"header-title"
|
|
43
|
+
];
|
|
34
44
|
}
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
45
|
+
attributeChanged(t, o, e) {
|
|
46
|
+
switch (t) {
|
|
47
|
+
case "show":
|
|
48
|
+
case "confirm-loading":
|
|
49
|
+
case "destroy-on-close":
|
|
50
|
+
case "mask-closable":
|
|
51
|
+
case "mask":
|
|
52
|
+
case "cancel":
|
|
53
|
+
case "mobile":
|
|
54
|
+
case "header":
|
|
55
|
+
case "footer":
|
|
56
|
+
this._state[u(t)] = n(e, !1, t);
|
|
57
|
+
break;
|
|
58
|
+
case "cancel-text":
|
|
59
|
+
this._state.cancelText = n(e, "取消");
|
|
60
|
+
break;
|
|
61
|
+
case "ok-text":
|
|
62
|
+
this._state.okText = n(e, "确定");
|
|
63
|
+
break;
|
|
64
|
+
case "close":
|
|
65
|
+
this._state.close = n(e, 1);
|
|
66
|
+
break;
|
|
67
|
+
case "width":
|
|
68
|
+
this._state[t] = g(e);
|
|
69
|
+
break;
|
|
70
|
+
case "vertical-align":
|
|
71
|
+
this._state.verticalAlign = n(e, "top");
|
|
72
|
+
break;
|
|
73
|
+
case "z-index":
|
|
74
|
+
this._state.zIndex = e;
|
|
75
|
+
break;
|
|
76
|
+
case "header-title":
|
|
77
|
+
this._state.headerTitle = e;
|
|
78
|
+
break;
|
|
46
79
|
}
|
|
47
80
|
}
|
|
48
|
-
|
|
49
|
-
|
|
81
|
+
updateDOM(t) {
|
|
82
|
+
if (t.has("show") && (this._state.show ? this.#t() : this.#a()), t.has("width") && this._setWidth(), t.has("confirm-loading")) {
|
|
83
|
+
const o = d('l-button[modal-action="ok"]', this.root);
|
|
84
|
+
o && o.setAttribute("loading", this._state.confirmLoading.toString());
|
|
85
|
+
}
|
|
86
|
+
t.has("z-index") && this._setZIndex();
|
|
50
87
|
}
|
|
51
|
-
|
|
52
|
-
this.
|
|
88
|
+
afterInit() {
|
|
89
|
+
this._setWidth(), this._setZIndex(), this._state.show && this.#t();
|
|
53
90
|
}
|
|
54
|
-
|
|
55
|
-
|
|
91
|
+
render_v2() {
|
|
92
|
+
return {
|
|
93
|
+
style: [v, y]
|
|
94
|
+
};
|
|
95
|
+
}
|
|
96
|
+
_setZIndex() {
|
|
97
|
+
this._state.zIndex ? this.style.setProperty("--l-modal-zindex", this._state.zIndex) : this.style.removeProperty("--l-modal-zindex");
|
|
56
98
|
}
|
|
57
|
-
|
|
99
|
+
_setWidth() {
|
|
100
|
+
this._state.width ? this.style.setProperty("--l-modal-width", this._state.width) : this.style.removeProperty("--l-modal-width");
|
|
101
|
+
}
|
|
102
|
+
#t() {
|
|
58
103
|
this._bodyOverflow = getComputedStyle(document.body).overflow, this.classList.add("open"), document.body.style.overflow = "hidden";
|
|
59
|
-
let t =
|
|
104
|
+
let t = d(".l-modal-wrapper", this.root);
|
|
60
105
|
if (t) {
|
|
61
|
-
const
|
|
62
|
-
|
|
63
|
-
const
|
|
64
|
-
|
|
106
|
+
const o = d(".l-mask", this.root);
|
|
107
|
+
o && r(o, "mask-transition");
|
|
108
|
+
const e = d(".l-modal", this.root);
|
|
109
|
+
r(e, "modal-transition");
|
|
65
110
|
} else {
|
|
66
|
-
const
|
|
67
|
-
let
|
|
68
|
-
this.mask && (
|
|
69
|
-
const
|
|
111
|
+
const o = document.createDocumentFragment();
|
|
112
|
+
let e = null;
|
|
113
|
+
this._state.mask && (e = a("div", { class: "l-mask l-modal-mask", part: "mask" }), o.appendChild(e)), t = a("div", { class: "l-modal-wrapper", part: "wrapper" });
|
|
114
|
+
const l = a("div", {
|
|
70
115
|
class: [
|
|
71
116
|
"l-modal",
|
|
72
|
-
`l-modal--${this.mobile ? "mobile" : "pc"}`,
|
|
73
|
-
`l-modal--${this.verticalAlign}`
|
|
117
|
+
`l-modal--${this._state.mobile ? "mobile" : "pc"}`,
|
|
118
|
+
`l-modal--${this._state.verticalAlign}`
|
|
74
119
|
],
|
|
75
120
|
part: "default"
|
|
76
121
|
});
|
|
77
|
-
if (
|
|
78
|
-
const
|
|
122
|
+
if (l.setAttribute("modal-action", "modal"), this._state.close !== 0) {
|
|
123
|
+
const s = a("l-button", {
|
|
79
124
|
shape: "circle",
|
|
80
125
|
type: "normal",
|
|
81
|
-
class: `l-btn-modal-close l-modal-close${this.close}`,
|
|
126
|
+
class: `l-btn-modal-close l-modal-close${this._state.close}`,
|
|
82
127
|
"modal-action": "close"
|
|
83
|
-
}),
|
|
84
|
-
|
|
128
|
+
}), i = a("l-close-icon");
|
|
129
|
+
s.appendChild(i), l.appendChild(s);
|
|
130
|
+
}
|
|
131
|
+
if (this._state.header) {
|
|
132
|
+
const s = a("header", { class: "l-modal-header", part: "header" }), i = a("slot", {
|
|
133
|
+
name: "header"
|
|
134
|
+
});
|
|
135
|
+
i.textContent = this._state.headerTitle || "", s.appendChild(i), l.appendChild(s);
|
|
85
136
|
}
|
|
86
|
-
const
|
|
87
|
-
h.textContent = this.getAttr("header", ""), p.appendChild(h), e.appendChild(p);
|
|
88
|
-
const f = a("div", {
|
|
137
|
+
const h = a("div", {
|
|
89
138
|
class: "l-modal-container",
|
|
90
139
|
part: "container"
|
|
91
|
-
}),
|
|
92
|
-
if (
|
|
93
|
-
const
|
|
140
|
+
}), p = a("slot");
|
|
141
|
+
if (h.appendChild(p), l.appendChild(h), this._state.footer) {
|
|
142
|
+
const s = a("footer", {
|
|
94
143
|
class: "l-modal-footer",
|
|
95
144
|
part: "footer"
|
|
96
|
-
}),
|
|
97
|
-
if (this.cancel) {
|
|
145
|
+
}), i = a("slot", { name: "footer" });
|
|
146
|
+
if (this._state.cancel) {
|
|
98
147
|
const m = a("l-button", {
|
|
99
148
|
class: "l-modal-footer-btn",
|
|
100
|
-
text: this.mobile
|
|
149
|
+
text: this._state.mobile
|
|
101
150
|
});
|
|
102
|
-
m.textContent = this.cancelText, m.setAttribute("modal-action", "cancel"),
|
|
151
|
+
m.textContent = this._state.cancelText, m.setAttribute("modal-action", "cancel"), i.appendChild(m);
|
|
103
152
|
}
|
|
104
|
-
const
|
|
153
|
+
const c = a("l-button", {
|
|
105
154
|
type: "primary",
|
|
106
155
|
class: "l-modal-footer-btn",
|
|
107
|
-
loading: this.confirmLoading,
|
|
108
|
-
text: this.mobile
|
|
156
|
+
loading: this._state.confirmLoading,
|
|
157
|
+
text: this._state.mobile
|
|
109
158
|
});
|
|
110
|
-
|
|
159
|
+
c.textContent = this._state.okText, c.setAttribute("modal-action", "ok"), i.appendChild(c), s.appendChild(i), l.appendChild(s);
|
|
111
160
|
}
|
|
112
|
-
t.appendChild(
|
|
161
|
+
t.appendChild(l), t.setAttribute("role", "dialog"), t.setAttribute("modal-action", "mask"), b(t, "click", this.#o), o.appendChild(t), this.appendToRoot(o), r(l, "modal-transition"), e && r(e, "mask-transition");
|
|
113
162
|
}
|
|
114
163
|
}
|
|
115
164
|
#a() {
|
|
116
165
|
document.body.style.setProperty("overflow", this._bodyOverflow);
|
|
117
|
-
const t =
|
|
118
|
-
|
|
119
|
-
this.destroyOnClose && this.#e(), this.classList.remove("open"), this.dispatchEvent(new CustomEvent("close"));
|
|
166
|
+
const t = d(".l-modal", this.root);
|
|
167
|
+
r(t, "modal-transition", "leave", () => {
|
|
168
|
+
this._state.destroyOnClose && this.#e(), this.classList.remove("open"), this.dispatchEvent(new CustomEvent("close"));
|
|
120
169
|
});
|
|
121
|
-
const
|
|
122
|
-
|
|
170
|
+
const o = d(".l-mask", this.root);
|
|
171
|
+
o && r(o, "mask-transition", "leave");
|
|
123
172
|
}
|
|
124
173
|
disconnectedCallback() {
|
|
125
174
|
this.#e(), super.disconnectedCallback();
|
|
126
175
|
}
|
|
127
176
|
#e() {
|
|
128
|
-
const t =
|
|
129
|
-
t && (
|
|
130
|
-
const
|
|
131
|
-
|
|
177
|
+
const t = d(".l-modal-wrapper", this.root);
|
|
178
|
+
t && (x(t, "click", this.#o), this.root.removeChild(t));
|
|
179
|
+
const o = d(".l-mask", this.root);
|
|
180
|
+
o && this.root.removeChild(o);
|
|
132
181
|
}
|
|
133
|
-
#
|
|
134
|
-
const [
|
|
135
|
-
if (
|
|
136
|
-
let
|
|
137
|
-
this.maskClosable &&
|
|
138
|
-
new CustomEvent(
|
|
139
|
-
detail: { action:
|
|
182
|
+
#o = (t) => {
|
|
183
|
+
const [o, e] = k(t, "modal-action", this.root);
|
|
184
|
+
if (o) {
|
|
185
|
+
let l = "";
|
|
186
|
+
this._state.maskClosable && e === "mask" || e === "cancel" || e === "close" ? l = "cancel" : e === "ok" && (l = "ok"), l && this.dispatchEvent(
|
|
187
|
+
new CustomEvent(l, {
|
|
188
|
+
detail: { action: e }
|
|
140
189
|
})
|
|
141
190
|
);
|
|
142
191
|
}
|
|
143
192
|
};
|
|
144
193
|
}
|
|
145
194
|
export {
|
|
146
|
-
|
|
195
|
+
z as default
|
|
147
196
|
};
|
package/lib/modal/modal_box.js
CHANGED
|
@@ -13,11 +13,7 @@ function f(t, e, o, l = "alert") {
|
|
|
13
13
|
let s = o.icon();
|
|
14
14
|
s.setAttribute("slot", "header"), n.push(s.outerHTML);
|
|
15
15
|
}
|
|
16
|
-
n.push(`<span slot="header">${t}</span>`), l === "prompt" ? (n.push(
|
|
17
|
-
`<l-form-item label="${e}" label-position="top" inner-block>`
|
|
18
|
-
), n.push(
|
|
19
|
-
`<l-input placeholder="${o.placeholder || ""}"></l-input>`
|
|
20
|
-
), n.push("</l-form-item>")) : n.push(`<span>${e}</span>`);
|
|
16
|
+
n.push(`<span slot="header">${t}</span>`), l === "prompt" ? (n.push(`<l-form-item label="${e}" label-position="top" inner-block>`), n.push(`<l-input placeholder="${o.placeholder || ""}"></l-input>`), n.push("</l-form-item>")) : n.push(`<span>${e}</span>`);
|
|
21
17
|
let r = h("l-modal", {
|
|
22
18
|
cancel: `${o.showCancel}`,
|
|
23
19
|
innerHTML: n.join(""),
|
|
@@ -38,20 +34,20 @@ function f(t, e, o, l = "alert") {
|
|
|
38
34
|
"ok",
|
|
39
35
|
() => {
|
|
40
36
|
let s = !0;
|
|
41
|
-
l === "prompt" && (s = b(".l-modal-box l-input").value), r.removeAttribute("
|
|
37
|
+
l === "prompt" && (s = b(".l-modal-box l-input").value), r.removeAttribute("show"), a(s);
|
|
42
38
|
},
|
|
43
39
|
{ once: !0 }
|
|
44
40
|
), m(
|
|
45
41
|
r,
|
|
46
42
|
"cancel",
|
|
47
43
|
() => {
|
|
48
|
-
r.removeAttribute("
|
|
44
|
+
r.removeAttribute("show"), a(!1);
|
|
49
45
|
},
|
|
50
46
|
{ once: !0 }
|
|
51
47
|
), document.body.appendChild(r);
|
|
52
48
|
});
|
|
53
49
|
}
|
|
54
|
-
function
|
|
50
|
+
function w(t, e, o) {
|
|
55
51
|
return p([i, c, u]), new Promise((l) => {
|
|
56
52
|
const a = {
|
|
57
53
|
showCancel: !1,
|
|
@@ -63,7 +59,7 @@ function k(t, e, o) {
|
|
|
63
59
|
return f(e || "提示", t, a, "alert");
|
|
64
60
|
});
|
|
65
61
|
}
|
|
66
|
-
function
|
|
62
|
+
function k(t, e, o) {
|
|
67
63
|
p([i, c, u, d]);
|
|
68
64
|
const l = {
|
|
69
65
|
showCancel: !0,
|
|
@@ -74,7 +70,7 @@ function v(t, e, o) {
|
|
|
74
70
|
};
|
|
75
71
|
return f(e || "提示", t, l, "confirm");
|
|
76
72
|
}
|
|
77
|
-
function
|
|
73
|
+
function v(t, e, o) {
|
|
78
74
|
p([i, c, u, d, $, C]);
|
|
79
75
|
const l = {
|
|
80
76
|
showCancel: !0,
|
|
@@ -86,9 +82,9 @@ function w(t, e, o) {
|
|
|
86
82
|
return f(e || "提示", t, l, "prompt");
|
|
87
83
|
}
|
|
88
84
|
const j = {
|
|
89
|
-
alert:
|
|
90
|
-
confirm:
|
|
91
|
-
prompt:
|
|
85
|
+
alert: w,
|
|
86
|
+
confirm: k,
|
|
87
|
+
prompt: v
|
|
92
88
|
};
|
|
93
89
|
export {
|
|
94
90
|
j as default
|
|
@@ -1,9 +1,15 @@
|
|
|
1
1
|
import BaseComponent from "../base";
|
|
2
|
-
|
|
2
|
+
type ThemeColorState = {
|
|
3
|
+
color: string;
|
|
4
|
+
};
|
|
5
|
+
export default class ThemeColor extends BaseComponent<ThemeColorState> {
|
|
3
6
|
#private;
|
|
4
7
|
static baseName: string;
|
|
5
|
-
color: string;
|
|
6
8
|
constructor();
|
|
7
|
-
|
|
8
|
-
|
|
9
|
+
render_v2(): {
|
|
10
|
+
template?: string | HTMLElement | DocumentFragment;
|
|
11
|
+
style?: string | string[];
|
|
12
|
+
};
|
|
13
|
+
afterInit(): void;
|
|
9
14
|
}
|
|
15
|
+
export {};
|
package/lib/theme/theme_color.js
CHANGED
|
@@ -1,28 +1,25 @@
|
|
|
1
1
|
import { $one as t, on as r } from "ph-utils/dom";
|
|
2
|
-
import
|
|
3
|
-
import { getColorTheme as
|
|
4
|
-
class m extends
|
|
2
|
+
import s from "../base.js";
|
|
3
|
+
import { getColorTheme as a, applyColorTheme as c } from "ph-utils/theme";
|
|
4
|
+
class m extends s {
|
|
5
5
|
static baseName = "theme-color";
|
|
6
|
-
color;
|
|
7
6
|
constructor() {
|
|
8
|
-
super(), this.
|
|
7
|
+
super(), this.version = 2, this._state = {
|
|
8
|
+
color: a() || "#722ed1"
|
|
9
|
+
};
|
|
9
10
|
}
|
|
10
|
-
|
|
11
|
-
|
|
11
|
+
render_v2() {
|
|
12
|
+
return {
|
|
13
|
+
template: `<l-color-picker value="${this._state.color}"></l-color-picker>`
|
|
14
|
+
};
|
|
12
15
|
}
|
|
13
|
-
|
|
14
|
-
const e = document.createElement(
|
|
15
|
-
"l-color-picker"
|
|
16
|
-
);
|
|
17
|
-
return e.value = this.color, e;
|
|
18
|
-
}
|
|
19
|
-
#e() {
|
|
16
|
+
afterInit() {
|
|
20
17
|
const e = t("l-color-picker", this.root);
|
|
21
|
-
e && r(e, "change", this.#
|
|
18
|
+
e && r(e, "change", this.#e);
|
|
22
19
|
}
|
|
23
|
-
#
|
|
20
|
+
#e = async (e) => {
|
|
24
21
|
const o = e.detail;
|
|
25
|
-
this.color = o, await
|
|
22
|
+
this._state.color = o, await c(o), this.dispatchEvent(new CustomEvent("change", { detail: o }));
|
|
26
23
|
};
|
|
27
24
|
}
|
|
28
25
|
export {
|
package/package.json
CHANGED
package/lib/date_picker/index.js
DELETED
|
@@ -1,99 +0,0 @@
|
|
|
1
|
-
import { initAttr as l } from "../utils/index.js";
|
|
2
|
-
import n from "../form/form_inner.js";
|
|
3
|
-
import { iterate as o, formatStyle as d, $ as c, on as a, off as r, $$ as h } from "ph-utils/dom";
|
|
4
|
-
import { parse as m } from "ph-utils/date";
|
|
5
|
-
const u = ":host{display:inline-flex;align-items:center;width:var(--l-date-picker-width, auto)}.l-date-inner{height:var(--l-form-control-height, 32px);border-radius:3px;outline:none;border:1px solid var(--l-border-color, #dedede);cursor:text;padding:0 5px;flex-grow:1;transition:border-color .3s}.l-date-inner:hover{border-color:var(--l-primary-color-light1, #9254de)}.l-date-inner:focus{border-color:var(--l-primary-color, #722ed1)}.l-date-range-divider{margin:0 10px}";
|
|
6
|
-
class y extends n {
|
|
7
|
-
static baseName = "date-picker";
|
|
8
|
-
/** 是否显示日期范围选择 */
|
|
9
|
-
range = !1;
|
|
10
|
-
/** 范围选择器时,为了性能考虑, 立即改变一个日期后,会延迟 300ms 通知, 以响应其它选择器, 0 - 立即触发 */
|
|
11
|
-
emitTimeout = 300;
|
|
12
|
-
/** 原生 type 属性 */
|
|
13
|
-
type = "date";
|
|
14
|
-
width;
|
|
15
|
-
/** 日期范围 */
|
|
16
|
-
min;
|
|
17
|
-
max;
|
|
18
|
-
allowEmpty = !0;
|
|
19
|
-
#t = [];
|
|
20
|
-
#e = [];
|
|
21
|
-
#i = -1;
|
|
22
|
-
// 至上一次触发change后,是否有更改
|
|
23
|
-
#s = !1;
|
|
24
|
-
set value(t) {
|
|
25
|
-
this.setValue(t), this.#e = t.split(","), o(this.#t, (i, e) => {
|
|
26
|
-
i.value = this.#e[e];
|
|
27
|
-
});
|
|
28
|
-
}
|
|
29
|
-
connectedCallback() {
|
|
30
|
-
l(this), this.loadStyleText(u);
|
|
31
|
-
const t = {};
|
|
32
|
-
this.width && (t["--l-date-picker-width"] = this.width), this.style.cssText = d(t), super.connectedCallback();
|
|
33
|
-
}
|
|
34
|
-
afterInit() {
|
|
35
|
-
this.#t = c(".l-date-inner", this.root), a(this.#t, "change", this.#h), this.range && (a(this.#t, "focus", this.#n), a(this.#t, "blur", this.#o));
|
|
36
|
-
}
|
|
37
|
-
beforeDestroy() {
|
|
38
|
-
r(this.#t, "change", this.#h), this.range && (r(this.#t, "focus", this.#n), r(this.#t, "blur", this.#o)), this.#a();
|
|
39
|
-
}
|
|
40
|
-
attributeChange(t, i, e) {
|
|
41
|
-
t === "value" && e !== this._value && (this.value = e);
|
|
42
|
-
}
|
|
43
|
-
render() {
|
|
44
|
-
const t = document.createDocumentFragment();
|
|
45
|
-
if (t.appendChild(this.#r(0)), this.range) {
|
|
46
|
-
const i = h("span", {
|
|
47
|
-
class: "l-date-range-divider",
|
|
48
|
-
textContent: "-"
|
|
49
|
-
});
|
|
50
|
-
t.appendChild(i), t.appendChild(this.#r(1));
|
|
51
|
-
}
|
|
52
|
-
return t;
|
|
53
|
-
}
|
|
54
|
-
#r(t = 0) {
|
|
55
|
-
return h("input", {
|
|
56
|
-
type: this.type,
|
|
57
|
-
class: `l-date-inner l-date-inner${t}`,
|
|
58
|
-
name: this.getName(),
|
|
59
|
-
value: this.#e[t],
|
|
60
|
-
"l-datepicker": `${t}`,
|
|
61
|
-
disabled: this.isDisabled(),
|
|
62
|
-
min: this.min,
|
|
63
|
-
max: this.max
|
|
64
|
-
});
|
|
65
|
-
}
|
|
66
|
-
#h = (t) => {
|
|
67
|
-
const i = t.target, e = Number(i.getAttribute("l-datepicker"));
|
|
68
|
-
let s = i.value;
|
|
69
|
-
!s && !this.allowEmpty && (s = this._resetValue || "", s = s.split(",")[e], i.value = s), this.#e[e] = s, this.#e.join(",") !== this._value && (this.setValue(this.#e.join(",")), this.#s = !0), e === 0 && this.#t.length > 1 ? this.#t[1].min = s : e === 1 && (this.#t[0].max = s), this.range ? this.#l() : this.#d();
|
|
70
|
-
};
|
|
71
|
-
#a() {
|
|
72
|
-
this.#i !== -1 && (clearTimeout(this.#i), this.#i = -1);
|
|
73
|
-
}
|
|
74
|
-
#l() {
|
|
75
|
-
this.#s && (this.#a(), this.#i = setTimeout(() => {
|
|
76
|
-
this.#d(), this.#s = !1;
|
|
77
|
-
}, this.emitTimeout));
|
|
78
|
-
}
|
|
79
|
-
#n = () => {
|
|
80
|
-
this.#a();
|
|
81
|
-
};
|
|
82
|
-
#o = () => {
|
|
83
|
-
this.#l();
|
|
84
|
-
};
|
|
85
|
-
#d() {
|
|
86
|
-
this.dispatchEvent(
|
|
87
|
-
new CustomEvent("change", {
|
|
88
|
-
detail: {
|
|
89
|
-
value: this.getValue(),
|
|
90
|
-
dateStr: this.#e,
|
|
91
|
-
dates: this.#e.map((t) => m(t))
|
|
92
|
-
}
|
|
93
|
-
})
|
|
94
|
-
);
|
|
95
|
-
}
|
|
96
|
-
}
|
|
97
|
-
export {
|
|
98
|
-
y as default
|
|
99
|
-
};
|