litos-ui 0.17.2 → 0.17.4
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/calendar/index.d.ts +30 -0
- package/lib/calendar/index.js +95 -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/index.js +19 -19
- 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/base.d.ts
CHANGED
|
@@ -6,6 +6,8 @@ export default class BaseComponent<T = Record<string, any>> extends HTMLElement
|
|
|
6
6
|
protected _pendingUpdate: boolean;
|
|
7
7
|
protected _pendingTask?: number;
|
|
8
8
|
protected _changedProperties: Set<string>;
|
|
9
|
+
/** 版本, 1 - 直接调用 render, 2 - 渲染 render_v2 */
|
|
10
|
+
protected version: number;
|
|
9
11
|
constructor(shadow?: boolean, init?: Partial<ShadowRootInit>);
|
|
10
12
|
/**
|
|
11
13
|
* 返回一个数组,表示观察的属性列表
|
|
@@ -22,6 +24,7 @@ export default class BaseComponent<T = Record<string, any>> extends HTMLElement
|
|
|
22
24
|
createStyle(text: string): void;
|
|
23
25
|
createLink(href: string): void;
|
|
24
26
|
loadStyleText(styleText: string | string[]): void;
|
|
27
|
+
styleHtml(styleText: string | string[]): string;
|
|
25
28
|
/**
|
|
26
29
|
* 获取属性值
|
|
27
30
|
* @param key 属性名称
|
|
@@ -37,9 +40,18 @@ export default class BaseComponent<T = Record<string, any>> extends HTMLElement
|
|
|
37
40
|
getAttr(key: string, defaultValue: boolean): boolean;
|
|
38
41
|
getAttr<T extends Record<string, string | number | boolean>>(filepath: string, defaultValue: T): T;
|
|
39
42
|
appendToRoot(el?: HTMLElement | HTMLElement[] | string | DocumentFragment): void;
|
|
43
|
+
appendToRootV2(template?: HTMLElement | string | DocumentFragment, style?: string | string[]): void;
|
|
40
44
|
connectedCallback(): void;
|
|
41
45
|
disconnectedCallback(): void;
|
|
42
|
-
render(): void | string | HTMLElement |
|
|
46
|
+
render(): void | string | HTMLElement | DocumentFragment;
|
|
47
|
+
/**
|
|
48
|
+
* 渲染器
|
|
49
|
+
* @returns [渲染节点,内容, 模板样式]
|
|
50
|
+
*/
|
|
51
|
+
render_v2(): {
|
|
52
|
+
template?: string | HTMLElement | DocumentFragment;
|
|
53
|
+
style?: string | string[];
|
|
54
|
+
};
|
|
43
55
|
/**
|
|
44
56
|
* 初始化事件
|
|
45
57
|
* @deprecated 自0.12.0起弃用,使用 afterInit() 替代
|
package/lib/base.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { getAttr as
|
|
1
|
+
import { getAttr as s } from "ph-utils/dom";
|
|
2
2
|
class a extends HTMLElement {
|
|
3
3
|
static baseName = "base-component";
|
|
4
4
|
/** 组件是否渲染完成, 是否已经调用 connectedCallback */
|
|
@@ -11,8 +11,10 @@ class a extends HTMLElement {
|
|
|
11
11
|
// 延迟任务id
|
|
12
12
|
_changedProperties;
|
|
13
13
|
// 已改变的属性集合
|
|
14
|
+
/** 版本, 1 - 直接调用 render, 2 - 渲染 render_v2 */
|
|
15
|
+
version;
|
|
14
16
|
constructor(e = !0, t = {}) {
|
|
15
|
-
super(), this.rendered = !1, this._state = {}, this._pendingUpdate = !1, this._changedProperties = /* @__PURE__ */ new Set(), e && this.attachShadow({ mode: "open", ...t });
|
|
17
|
+
super(), this.rendered = !1, this._state = {}, this._pendingUpdate = !1, this.version = 1, this._changedProperties = /* @__PURE__ */ new Set(), e && this.attachShadow({ mode: "open", ...t });
|
|
16
18
|
}
|
|
17
19
|
/**
|
|
18
20
|
* 返回一个数组,表示观察的属性列表
|
|
@@ -22,7 +24,7 @@ class a extends HTMLElement {
|
|
|
22
24
|
}
|
|
23
25
|
// 当属性发生变化时调用的回调函数
|
|
24
26
|
attributeChangedCallback(e, t, n) {
|
|
25
|
-
t !== n && (this.attributeChanged(e, t, n), this.
|
|
27
|
+
t !== n && (this._changedProperties.add(e), this.attributeChanged(e, t, n), this.rendered && this.batchUpdate());
|
|
26
28
|
}
|
|
27
29
|
attributeChanged(e, t, n) {
|
|
28
30
|
}
|
|
@@ -56,8 +58,12 @@ class a extends HTMLElement {
|
|
|
56
58
|
let t = e;
|
|
57
59
|
Array.isArray(t) && (t = t.join("")), this.createStyle(t);
|
|
58
60
|
}
|
|
61
|
+
styleHtml(e) {
|
|
62
|
+
let t = e;
|
|
63
|
+
return Array.isArray(t) && (t = t.join("")), `<style>${t}</style>`;
|
|
64
|
+
}
|
|
59
65
|
getAttr(e, t) {
|
|
60
|
-
return
|
|
66
|
+
return s(this, e, t);
|
|
61
67
|
}
|
|
62
68
|
appendToRoot(e) {
|
|
63
69
|
if (e)
|
|
@@ -66,14 +72,38 @@ class a extends HTMLElement {
|
|
|
66
72
|
t.innerHTML = e, this.root.append(...t.childNodes), t = void 0;
|
|
67
73
|
} else e.length ? this.root.append(...e) : this.root.append(e);
|
|
68
74
|
}
|
|
75
|
+
appendToRootV2(e, t) {
|
|
76
|
+
const n = [];
|
|
77
|
+
if (t && n.push(this.styleHtml(t)), e)
|
|
78
|
+
if (typeof e == "string")
|
|
79
|
+
n.push(e);
|
|
80
|
+
else {
|
|
81
|
+
let i = document.createElement("div");
|
|
82
|
+
i.appendChild(e), n.push(i.innerHTML), i = void 0;
|
|
83
|
+
}
|
|
84
|
+
this.root.innerHTML = n.join("");
|
|
85
|
+
}
|
|
69
86
|
connectedCallback() {
|
|
70
|
-
|
|
87
|
+
if (this.version === 1)
|
|
88
|
+
this.appendToRoot(this.render());
|
|
89
|
+
else {
|
|
90
|
+
const e = this.render_v2();
|
|
91
|
+
this.appendToRootV2(e.template, e.style);
|
|
92
|
+
}
|
|
93
|
+
this.rendered = !0, this.initEvents(), this.afterInit();
|
|
71
94
|
}
|
|
72
95
|
disconnectedCallback() {
|
|
73
96
|
this.cancelPending(), this.removeEvents(), this.beforeDestroy(), this.root.innerHTML = "", this.rendered = !1;
|
|
74
97
|
}
|
|
75
98
|
render() {
|
|
76
99
|
}
|
|
100
|
+
/**
|
|
101
|
+
* 渲染器
|
|
102
|
+
* @returns [渲染节点,内容, 模板样式]
|
|
103
|
+
*/
|
|
104
|
+
render_v2() {
|
|
105
|
+
return {};
|
|
106
|
+
}
|
|
77
107
|
/**
|
|
78
108
|
* 初始化事件
|
|
79
109
|
* @deprecated 自0.12.0起弃用,使用 afterInit() 替代
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import FormInner from "../form/form_inner";
|
|
2
|
+
type CalendarState = {
|
|
3
|
+
locale: string;
|
|
4
|
+
minDate: number;
|
|
5
|
+
maxDate: number;
|
|
6
|
+
};
|
|
7
|
+
export default class Calendar extends FormInner<CalendarState> {
|
|
8
|
+
static baseName: string;
|
|
9
|
+
private _currentDate;
|
|
10
|
+
private _langData;
|
|
11
|
+
private $container?;
|
|
12
|
+
constructor();
|
|
13
|
+
setValue(v: string): void;
|
|
14
|
+
connectedCallback(): void;
|
|
15
|
+
afterInit(): void;
|
|
16
|
+
beforeDestroy(): void;
|
|
17
|
+
static get observedAttributes(): string[];
|
|
18
|
+
protected attributeChanged(name: string, oldValue: string, newValue: string): void;
|
|
19
|
+
protected updateDOM(changedProps: Set<string>): void;
|
|
20
|
+
private _renderHeader;
|
|
21
|
+
private _renderBody;
|
|
22
|
+
rerenderHeader(): void;
|
|
23
|
+
rerenderBody(): void;
|
|
24
|
+
rerender(): string;
|
|
25
|
+
render_v2(): {
|
|
26
|
+
template?: string | HTMLElement | DocumentFragment;
|
|
27
|
+
style?: string | string[];
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
export {};
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
import D from "../form/form_inner.js";
|
|
2
|
+
import { $one as y } from "ph-utils/dom";
|
|
3
|
+
import { langs as f } from "./langs.js";
|
|
4
|
+
import { get as k } from "ph-utils/storage";
|
|
5
|
+
import { parse as w, endOf as H, startOf as C, format as c } from "ph-utils/date";
|
|
6
|
+
const T = ":host{display:block;box-sizing:border-box;width:100%;height:100%}.calendar-table{width:100%;height:100%;border-collapse:collapse}.calendar-table thead{height:var(--calendar-header-height, auto)}.calendar-table th{font-weight:400;cursor:default}.calendar-table .prev-month,.calendar-table .next-month{color:var(--l-calendar-off-text-color, #a8abb2)}.calendar-table .today{color:var(--l-primary-color, #007bff)}.day{text-align:center;cursor:pointer;transition:background-color .2s;font-size:13px}.day:hover{background-color:#0000000a}.day.disabled{background-color:#0000000a;cursor:not-allowed}.day.active{background-color:var(--l-primary-color, #007bff);color:#fff;font-weight:700}";
|
|
7
|
+
class A extends D {
|
|
8
|
+
static baseName = "calendar";
|
|
9
|
+
_currentDate;
|
|
10
|
+
_langData;
|
|
11
|
+
$container;
|
|
12
|
+
constructor() {
|
|
13
|
+
super(), this.version = 2, this._currentDate = /* @__PURE__ */ new Date();
|
|
14
|
+
const t = k("l_app_locale", "zh-CN", { storage: "session" });
|
|
15
|
+
this._state = {
|
|
16
|
+
locale: t,
|
|
17
|
+
minDate: -1 / 0,
|
|
18
|
+
maxDate: 1 / 0
|
|
19
|
+
}, this._langData = f[t];
|
|
20
|
+
}
|
|
21
|
+
setValue(t) {
|
|
22
|
+
t != this.value && (super.setValue(t), this._currentDate = w(t), this.rerenderBody());
|
|
23
|
+
}
|
|
24
|
+
connectedCallback() {
|
|
25
|
+
super.connectedCallback();
|
|
26
|
+
}
|
|
27
|
+
afterInit() {
|
|
28
|
+
this.$container = y(".calendar-table", this.root);
|
|
29
|
+
}
|
|
30
|
+
beforeDestroy() {
|
|
31
|
+
this.$container = void 0;
|
|
32
|
+
}
|
|
33
|
+
static get observedAttributes() {
|
|
34
|
+
return [...D.observedAttributes, "locale"];
|
|
35
|
+
}
|
|
36
|
+
attributeChanged(t, r, n) {
|
|
37
|
+
switch (t) {
|
|
38
|
+
case "locale":
|
|
39
|
+
f.hasOwnProperty(n) && (this._state.locale = n, this._langData = f[n]);
|
|
40
|
+
break;
|
|
41
|
+
case "min-date":
|
|
42
|
+
this._state.minDate = C(n).getTime();
|
|
43
|
+
break;
|
|
44
|
+
case "max-date":
|
|
45
|
+
this._state.maxDate = H(n).getTime();
|
|
46
|
+
break;
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
updateDOM(t) {
|
|
50
|
+
t.has("locale") && this.rerenderHeader(), this.$container && (this.$container.innerHTML = this.rerender());
|
|
51
|
+
}
|
|
52
|
+
_renderHeader() {
|
|
53
|
+
return `<tr>${this._langData.weekdays.map((r) => `<th>${r}</th>`).join("")}</tr>`;
|
|
54
|
+
}
|
|
55
|
+
_renderBody() {
|
|
56
|
+
const t = this._currentDate.getFullYear(), r = this._currentDate.getMonth(), n = c(null, "yyyy-mm-dd"), b = new Date(t, r, 1);
|
|
57
|
+
let a = b.getDay() - 1;
|
|
58
|
+
a < 0 && (a = 6);
|
|
59
|
+
const m = new Date(t, r + 1, 0), u = m.getDate(), g = c(m, "yyyy-mm"), p = new Date(t, r, 0), $ = p.getDate(), _ = c(p, "yyyy-mm"), x = new Date(t, r + 1, 1), v = c(x, "yyyy-mm"), d = new Date(b);
|
|
60
|
+
d.setDate(d.getDate() - a), d.setHours(0, 0, 0, 0);
|
|
61
|
+
let i = "";
|
|
62
|
+
for (let e = 0; e < 42; e++) {
|
|
63
|
+
e % 7 === 0 && (i += "<tr>");
|
|
64
|
+
let o, s = "day", l = "";
|
|
65
|
+
e < a ? (o = `${$ - a + e + 1}`, s += " prev-month", l = _) : e < a + u ? (o = `${e - a + 1}`, l = g) : (o = `${e - a - u + 1}`, s += " next-month disabled", l = v);
|
|
66
|
+
const h = `${l}-${o.padStart(2, "0")}`;
|
|
67
|
+
h === n && (s += " today"), h === this.value && (s += " active"), i += `<td class="${s}" title="${h}">${o}</td>`, e % 7 === 6 && (i += "</tr>");
|
|
68
|
+
}
|
|
69
|
+
return i;
|
|
70
|
+
}
|
|
71
|
+
rerenderHeader() {
|
|
72
|
+
if (this.$container) {
|
|
73
|
+
const t = y("thead", this.$container);
|
|
74
|
+
t.innerHTML = this._renderHeader();
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
rerenderBody() {
|
|
78
|
+
if (this.$container) {
|
|
79
|
+
const t = y("tbody", this.$container);
|
|
80
|
+
t.innerHTML = this._renderBody();
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
rerender() {
|
|
84
|
+
return `<thead>${this._renderHeader()}</thead><tbody>${this._renderBody()}</tbody>`;
|
|
85
|
+
}
|
|
86
|
+
render_v2() {
|
|
87
|
+
return {
|
|
88
|
+
template: `<table class="calendar-table">${this.rerender()}</table>`,
|
|
89
|
+
style: [T]
|
|
90
|
+
};
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
export {
|
|
94
|
+
A as default
|
|
95
|
+
};
|
|
@@ -1,22 +1,30 @@
|
|
|
1
1
|
import FormInner from "../form/form_inner";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
static baseName: string;
|
|
2
|
+
type DateInputType = "date" | "datetime-local" | "time" | "month" | "week";
|
|
3
|
+
type DatePickerOriState = {
|
|
5
4
|
/** 是否显示日期范围选择 */
|
|
6
5
|
range: boolean;
|
|
7
6
|
/** 范围选择器时,为了性能考虑, 立即改变一个日期后,会延迟 300ms 通知, 以响应其它选择器, 0 - 立即触发 */
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
type: "date" | "datetime-local" | "time" | "month" | "week";
|
|
7
|
+
delay: number;
|
|
8
|
+
type: DateInputType;
|
|
11
9
|
width?: string;
|
|
12
10
|
/** 日期范围 */
|
|
13
11
|
min?: string;
|
|
14
12
|
max?: string;
|
|
15
13
|
allowEmpty: boolean;
|
|
16
|
-
|
|
14
|
+
};
|
|
15
|
+
export default class DatePicker extends FormInner {
|
|
16
|
+
#private;
|
|
17
|
+
static baseName: string;
|
|
18
|
+
_state: DatePickerOriState;
|
|
19
|
+
constructor();
|
|
20
|
+
setValue(v: string): void;
|
|
21
|
+
static get observedAttributes(): string[];
|
|
17
22
|
connectedCallback(): void;
|
|
18
23
|
afterInit(): void;
|
|
19
24
|
beforeDestroy(): void;
|
|
20
25
|
protected attributeChange(name: string, oldValue: string, newValue: string): void;
|
|
26
|
+
protected updateDOM(changedProps: Set<string>): void;
|
|
27
|
+
private _updateWidth;
|
|
21
28
|
render(): DocumentFragment;
|
|
22
29
|
}
|
|
30
|
+
export {};
|
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
import h from "../form/form_inner.js";
|
|
2
|
+
import { iterate as n, $ as o, on as a, off as r, $$ as l } from "ph-utils/dom";
|
|
3
|
+
import { parse as c } from "ph-utils/date";
|
|
4
|
+
import { unitNumberStr as p, parseAttrValue as d, kebabToCamel as u } from "../utils/index.js";
|
|
5
|
+
const m = ":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 w extends h {
|
|
7
|
+
static baseName = "date-picker-ori";
|
|
8
|
+
#t;
|
|
9
|
+
#e;
|
|
10
|
+
#i;
|
|
11
|
+
// 至上一次触发change后,是否有更改
|
|
12
|
+
#s;
|
|
13
|
+
_state;
|
|
14
|
+
constructor() {
|
|
15
|
+
super(), this._state = {
|
|
16
|
+
range: !1,
|
|
17
|
+
delay: 300,
|
|
18
|
+
type: "date",
|
|
19
|
+
allowEmpty: !0
|
|
20
|
+
}, this.#e = [], this.#s = !1;
|
|
21
|
+
}
|
|
22
|
+
setValue(t) {
|
|
23
|
+
super.setValue(t), this.#e = t.split(","), this.rendered && n(this.#t, (i, e) => {
|
|
24
|
+
i.value = this.#e[e];
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
static get observedAttributes() {
|
|
28
|
+
return [
|
|
29
|
+
...h.observedAttributes,
|
|
30
|
+
"range",
|
|
31
|
+
"delay",
|
|
32
|
+
"type",
|
|
33
|
+
"width",
|
|
34
|
+
"min",
|
|
35
|
+
"max",
|
|
36
|
+
"allow-empty"
|
|
37
|
+
];
|
|
38
|
+
}
|
|
39
|
+
connectedCallback() {
|
|
40
|
+
this.loadStyleText(m), this._updateWidth(), super.connectedCallback();
|
|
41
|
+
}
|
|
42
|
+
afterInit() {
|
|
43
|
+
this.#t = o(".l-date-inner", this.root), a(this.#t, "change", this.#h), this._state.range && (a(this.#t, "focus", this.#d), a(this.#t, "blur", this.#n));
|
|
44
|
+
}
|
|
45
|
+
beforeDestroy() {
|
|
46
|
+
r(this.#t, "change", this.#h), this._state.range && (r(this.#t, "focus", this.#d), r(this.#t, "blur", this.#n)), this.#a();
|
|
47
|
+
}
|
|
48
|
+
attributeChange(t, i, e) {
|
|
49
|
+
switch (t) {
|
|
50
|
+
case "type":
|
|
51
|
+
case "min":
|
|
52
|
+
case "max":
|
|
53
|
+
this._state[t] = e;
|
|
54
|
+
break;
|
|
55
|
+
case "range":
|
|
56
|
+
case "allow-empty":
|
|
57
|
+
this._state[u(t)] = d(e, !1, t);
|
|
58
|
+
break;
|
|
59
|
+
case "delay":
|
|
60
|
+
this._state.delay = d(e, 300);
|
|
61
|
+
break;
|
|
62
|
+
case "width":
|
|
63
|
+
this._state.width = p(e);
|
|
64
|
+
break;
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
updateDOM(t) {
|
|
68
|
+
t.has("width") && this._updateWidth();
|
|
69
|
+
}
|
|
70
|
+
_updateWidth() {
|
|
71
|
+
this._state.width ? this.style.setProperty("--l-date-picker-width", this._state.width) : this.style.removeProperty("--l-date-picker-width");
|
|
72
|
+
}
|
|
73
|
+
render() {
|
|
74
|
+
const t = document.createDocumentFragment();
|
|
75
|
+
if (t.appendChild(this.#r(0)), this._state.range) {
|
|
76
|
+
const i = l("span", {
|
|
77
|
+
class: "l-date-range-divider",
|
|
78
|
+
textContent: "-"
|
|
79
|
+
});
|
|
80
|
+
t.appendChild(i), t.appendChild(this.#r(1));
|
|
81
|
+
}
|
|
82
|
+
return t;
|
|
83
|
+
}
|
|
84
|
+
#r(t = 0) {
|
|
85
|
+
return l("input", {
|
|
86
|
+
type: this._state.type,
|
|
87
|
+
class: `l-date-inner l-date-inner${t}`,
|
|
88
|
+
name: this.getName(),
|
|
89
|
+
value: this.#e[t],
|
|
90
|
+
"l-datepicker": `${t}`,
|
|
91
|
+
disabled: this.isDisabled() ? !0 : void 0,
|
|
92
|
+
min: this._state.min,
|
|
93
|
+
max: this._state.max
|
|
94
|
+
});
|
|
95
|
+
}
|
|
96
|
+
#h = (t) => {
|
|
97
|
+
const i = t.target, e = Number(i.getAttribute("l-datepicker"));
|
|
98
|
+
let s = i.value;
|
|
99
|
+
!s && !this._state.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._state.range ? this.#l() : this.#o();
|
|
100
|
+
};
|
|
101
|
+
#a() {
|
|
102
|
+
this.#i !== -1 && (clearTimeout(this.#i), this.#i = -1);
|
|
103
|
+
}
|
|
104
|
+
#l() {
|
|
105
|
+
this.#s && (this.#a(), this.#i = setTimeout(() => {
|
|
106
|
+
this.#o(), this.#s = !1;
|
|
107
|
+
}, this._state.delay));
|
|
108
|
+
}
|
|
109
|
+
#d = () => {
|
|
110
|
+
this.#a();
|
|
111
|
+
};
|
|
112
|
+
#n = () => {
|
|
113
|
+
this.#l();
|
|
114
|
+
};
|
|
115
|
+
#o() {
|
|
116
|
+
this.dispatchEvent(
|
|
117
|
+
new CustomEvent("change", {
|
|
118
|
+
detail: {
|
|
119
|
+
value: this.getValue(),
|
|
120
|
+
dateStr: this.#e,
|
|
121
|
+
dates: this.#e.map((t) => c(t))
|
|
122
|
+
}
|
|
123
|
+
})
|
|
124
|
+
);
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
export {
|
|
128
|
+
w as default
|
|
129
|
+
};
|
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
import BaseComponent from "../base";
|
|
2
|
-
|
|
3
|
-
#private;
|
|
4
|
-
static baseName: string;
|
|
2
|
+
type DialogContainerState = {
|
|
5
3
|
/** 是否显示标题栏 */
|
|
6
4
|
showHeader: boolean;
|
|
7
5
|
/** 头部内容 */
|
|
@@ -18,11 +16,21 @@ export default class DialogContainer extends BaseComponent {
|
|
|
18
16
|
okText: string;
|
|
19
17
|
/** 是否显示右上角关闭按钮, 1 - 显示在框内, 2 - 显示在框角, 0 - 不显示 */
|
|
20
18
|
showClose: number;
|
|
19
|
+
/** 容器类名 */
|
|
21
20
|
containerClass?: string;
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
21
|
+
};
|
|
22
|
+
export default class DialogContainer extends BaseComponent<DialogContainerState> {
|
|
23
|
+
#private;
|
|
24
|
+
static baseName: string;
|
|
25
|
+
constructor();
|
|
26
|
+
afterInit(): void;
|
|
27
|
+
beforeDestroy(): void;
|
|
25
28
|
static get observedAttributes(): string[] | null | undefined;
|
|
26
|
-
|
|
27
|
-
|
|
29
|
+
protected attributeChanged(name: string, oldValue: string, newValue: string): void;
|
|
30
|
+
render_v2(): {
|
|
31
|
+
template?: string | HTMLElement | DocumentFragment;
|
|
32
|
+
style?: string | string[];
|
|
33
|
+
};
|
|
34
|
+
render(): DocumentFragment;
|
|
28
35
|
}
|
|
36
|
+
export {};
|
|
@@ -1,98 +1,131 @@
|
|
|
1
1
|
import p from "../base.js";
|
|
2
|
-
import { $ as
|
|
3
|
-
import { initAttr as x } from "../utils/index.js";
|
|
2
|
+
import { $ as c, iterate as d, on as r, off as h, shouldEventNext as g, $one as b, $$ as s, formatClass as f } from "ph-utils/dom";
|
|
4
3
|
const C = ":host{display:block;position:relative}:host(.l-container-close-outside){padding-top:10px;padding-right:10px}.l-dialog-main{box-shadow:0 0 8px #0000001a;border-radius:5px;background-color:#fff}.l-dialog-header{padding:10px;font-size:16px;border-bottom:1px solid var(--l-dialog-line-color, rgba(0, 0, 0, .06));font-weight:600;display:flex;align-items:center;gap:5px}.l-dialog-footer{padding:10px;border-top:1px solid var(--l-dialog-line-color, rgba(0, 0, 0, .06));display:flex;justify-content:flex-end;gap:10px}.l-dialog-container{padding:15px 10px;font-size:14px}.l-btn-dialog-close{--l-form-control-height: auto;position:absolute}.l-dialog-close1{right:5px;top:6px}.l-dialog-close1::part(default){width:auto;height:auto;padding:5px;border:none;font-size:16px}.l-dialog-close2{right:0;top:0}.l-dialog-close2::part(default){width:20px;height:20px;padding:0;background-color:#fff}";
|
|
5
|
-
class
|
|
4
|
+
class m extends p {
|
|
6
5
|
static baseName = "dialog-container";
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
/** 是否显示确定按钮 */
|
|
18
|
-
showOk = !0;
|
|
19
|
-
/** 确定按钮文本 */
|
|
20
|
-
okText = "确定";
|
|
21
|
-
/** 是否显示右上角关闭按钮, 1 - 显示在框内, 2 - 显示在框角, 0 - 不显示 */
|
|
22
|
-
showClose = 1;
|
|
23
|
-
containerClass;
|
|
24
|
-
connectedCallback() {
|
|
25
|
-
this.loadStyleText(C), x(this), this.showClose === 2 && this.classList.add("l-container-close-outside"), super.connectedCallback();
|
|
6
|
+
constructor() {
|
|
7
|
+
super(), this.version = 2, this._state = {
|
|
8
|
+
showHeader: !0,
|
|
9
|
+
showFooter: !0,
|
|
10
|
+
showCancel: !0,
|
|
11
|
+
cancelText: "取消",
|
|
12
|
+
showOk: !0,
|
|
13
|
+
okText: "确定",
|
|
14
|
+
showClose: 1
|
|
15
|
+
};
|
|
26
16
|
}
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
c(
|
|
17
|
+
afterInit() {
|
|
18
|
+
this._state.showClose === 2 && this.classList.add("l-container-close-outside");
|
|
19
|
+
const t = c("[data-action]", this.root);
|
|
20
|
+
d(t, (o) => {
|
|
30
21
|
r(o, "click", this.#t);
|
|
31
22
|
});
|
|
32
23
|
}
|
|
33
|
-
|
|
34
|
-
const t =
|
|
35
|
-
|
|
24
|
+
beforeDestroy() {
|
|
25
|
+
const t = c("[data-action]", this.root);
|
|
26
|
+
d(t, (o) => {
|
|
36
27
|
h(o, "click", this.#t);
|
|
37
28
|
});
|
|
38
29
|
}
|
|
39
30
|
#t(t) {
|
|
40
|
-
const [o,
|
|
31
|
+
const [o, e] = g(t, "data-action");
|
|
41
32
|
o && this.dispatchEvent(
|
|
42
33
|
new CustomEvent("dialogAction", {
|
|
43
|
-
detail: { action:
|
|
34
|
+
detail: { action: e },
|
|
44
35
|
composed: !0
|
|
45
36
|
})
|
|
46
37
|
);
|
|
47
38
|
}
|
|
48
39
|
static get observedAttributes() {
|
|
49
|
-
return [
|
|
40
|
+
return [
|
|
41
|
+
"show-header",
|
|
42
|
+
"header",
|
|
43
|
+
"show-footer",
|
|
44
|
+
"show-cancel",
|
|
45
|
+
"cancel-text",
|
|
46
|
+
"show-ok",
|
|
47
|
+
"ok-text",
|
|
48
|
+
"show-close",
|
|
49
|
+
"container-class"
|
|
50
|
+
];
|
|
50
51
|
}
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
52
|
+
attributeChanged(t, o, e) {
|
|
53
|
+
switch (t) {
|
|
54
|
+
case "show-header":
|
|
55
|
+
this._state.showHeader = e !== null, this.connectedCallback();
|
|
56
|
+
break;
|
|
57
|
+
case "header":
|
|
58
|
+
this._state.header = e || void 0, this.connectedCallback();
|
|
59
|
+
break;
|
|
60
|
+
case "show-footer":
|
|
61
|
+
this._state.showFooter = e !== null, this.connectedCallback();
|
|
62
|
+
break;
|
|
63
|
+
case "show-cancel":
|
|
64
|
+
this._state.showCancel = e !== null, this.connectedCallback();
|
|
65
|
+
break;
|
|
66
|
+
case "cancel-text":
|
|
67
|
+
this._state.cancelText = e || "取消", this.connectedCallback();
|
|
68
|
+
break;
|
|
69
|
+
case "show-ok":
|
|
70
|
+
this._state.showOk = e !== null, this.connectedCallback();
|
|
71
|
+
break;
|
|
72
|
+
case "ok-text":
|
|
73
|
+
this._state.okText = e || "确定", this.connectedCallback();
|
|
74
|
+
break;
|
|
75
|
+
case "show-close":
|
|
76
|
+
this._state.showClose = Number(e), this._state.showClose === 2 ? this.classList.add("l-container-close-outside") : this.classList.remove("l-container-close-outside");
|
|
77
|
+
let a = b(".l-btn-dialog-close", this.root);
|
|
78
|
+
this._state.showClose === 0 && a ? (h(a, "click", this.#t), a.remove()) : a ? a.className = this.#e() : (a = this.#o(), r(a, "click", this.#t), this.root.appendChild(a));
|
|
79
|
+
break;
|
|
80
|
+
case "container-class":
|
|
81
|
+
this._state.containerClass = e || void 0, this.connectedCallback();
|
|
82
|
+
break;
|
|
56
83
|
}
|
|
57
84
|
}
|
|
58
|
-
#o() {
|
|
59
|
-
return `l-btn-dialog-close l-dialog-close${this.showClose}`;
|
|
60
|
-
}
|
|
61
85
|
#e() {
|
|
62
|
-
|
|
86
|
+
return `l-btn-dialog-close l-dialog-close${this._state.showClose}`;
|
|
87
|
+
}
|
|
88
|
+
#o() {
|
|
89
|
+
const t = s("l-button", {
|
|
63
90
|
shape: "circle",
|
|
64
91
|
type: "normal",
|
|
65
|
-
class: this.#
|
|
92
|
+
class: this.#e(),
|
|
66
93
|
"data-action": "close"
|
|
67
|
-
}), o =
|
|
94
|
+
}), o = s("l-close-icon");
|
|
68
95
|
return t.appendChild(o), t;
|
|
69
96
|
}
|
|
97
|
+
render_v2() {
|
|
98
|
+
return {
|
|
99
|
+
style: C,
|
|
100
|
+
template: this.render()
|
|
101
|
+
};
|
|
102
|
+
}
|
|
70
103
|
render() {
|
|
71
|
-
const t =
|
|
72
|
-
this.showClose !== 0 && t.
|
|
73
|
-
const o =
|
|
74
|
-
if (this.showHeader) {
|
|
75
|
-
const l =
|
|
76
|
-
|
|
104
|
+
const t = document.createDocumentFragment();
|
|
105
|
+
this._state.showClose !== 0 && t.appendChild(this.#o());
|
|
106
|
+
const o = s("div", { class: "l-dialog-main" });
|
|
107
|
+
if (this._state.showHeader) {
|
|
108
|
+
const l = s("header", { class: "l-dialog-header" }), i = s("slot", { name: "header" });
|
|
109
|
+
i.textContent = this._state.header || "", l.appendChild(i), o.appendChild(l);
|
|
77
110
|
}
|
|
78
|
-
const
|
|
79
|
-
class:
|
|
80
|
-
}),
|
|
81
|
-
if (
|
|
82
|
-
const l =
|
|
83
|
-
if (this.showCancel) {
|
|
84
|
-
const n =
|
|
85
|
-
n.textContent = this.cancelText,
|
|
111
|
+
const e = s("div", {
|
|
112
|
+
class: f(["l-dialog-container", this._state.containerClass])
|
|
113
|
+
}), a = s("slot");
|
|
114
|
+
if (e.appendChild(a), o.appendChild(e), this._state.showFooter) {
|
|
115
|
+
const l = s("div", { class: "l-dialog-footer" }), i = s("slot", { name: "footer" });
|
|
116
|
+
if (this._state.showCancel) {
|
|
117
|
+
const n = s("l-button", { "data-action": "cancel" });
|
|
118
|
+
n.textContent = this._state.cancelText, i.appendChild(n);
|
|
86
119
|
}
|
|
87
|
-
if (this.showOk) {
|
|
88
|
-
const n =
|
|
89
|
-
n.textContent = this.okText,
|
|
120
|
+
if (this._state.showOk) {
|
|
121
|
+
const n = s("l-button", { type: "primary", "data-action": "ok" });
|
|
122
|
+
n.textContent = this._state.okText, i.appendChild(n);
|
|
90
123
|
}
|
|
91
|
-
l.appendChild(
|
|
124
|
+
l.appendChild(i), o.appendChild(l);
|
|
92
125
|
}
|
|
93
|
-
return t.
|
|
126
|
+
return t.appendChild(o), t;
|
|
94
127
|
}
|
|
95
128
|
}
|
|
96
129
|
export {
|
|
97
|
-
|
|
130
|
+
m as default
|
|
98
131
|
};
|