litos-ui 0.17.4 → 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 +15 -4
- package/lib/calendar/index.js +2 -95
- 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 +4 -2
- package/lib/loading/index.js +109 -123
- 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
|
@@ -0,0 +1,146 @@
|
|
|
1
|
+
import e from "./base.js";
|
|
2
|
+
import { kebabToCamel as t, parseAttrValue as n, unitNumberStr as r } from "./utils/index.js";
|
|
3
|
+
import { t as i } from "./animation-CTt9qgA7.js";
|
|
4
|
+
import { addClass as a, formatClass as o, formatStyle as s, off as c, on as l, removeClass as u, replaceClass as d } from "ph-utils/dom";
|
|
5
|
+
import { adjust as f } from "ph-utils/color";
|
|
6
|
+
//#region src/components/button/index.less?inline
|
|
7
|
+
var p = ":host{--l-btn-padding:0 15px;--l-btn-text-color:#fff;--l-btn-hover-text-color:var(--l-btn-text-color);--l-btn-active-text-color:var(--l-btn-text-color);--l-btn-border-color:var(--l-primary-color,#722ed1);--l-btn-background:var(--l-btn-border-color);--l-btn-hover-border-color:var(--l-primary-color-light1,#9254de);--l-btn-hover-background:var(--l-btn-hover-border-color);--l-btn-active-border-color:var(--l-primary-color-dark1,#531dab);--l-btn-active-background:var(--l-btn-active-border-color);--l-btn-disabled-color:#c9c9c9;--l-btn-disabled-background:#fbfbfb;--l-btn-disabled-border-color:#e6e6e6;--l-btn-height:var(--l-form-control-height,32px);width:auto;height:var(--l-btn-height);text-indent:0;box-sizing:border-box;border-radius:var(--l-border-radius,3px);display:inline-flex}:host([block]){width:100%}:host(.l-btn-small){--l-btn-height:24px;--l-btn-padding:0 7px}:host(.l-btn-large){--l-border-radius:6px;--l-btn-height:40px;--l-btn-padding:0 15px;font-size:16px}.l-btn{cursor:pointer;box-sizing:border-box;vertical-align:middle;width:100%;padding:var(--l-btn-padding);border-radius:inherit;height:100%;color:var(--l-btn-text-color);background:var(--l-btn-background);border:1px solid var(--l-btn-border-color);justify-content:center;align-items:center;gap:var(--l-btn-gap,5px);line-height:1;font-size:inherit;outline:none;transition:border-color .3s,background-color .3s,color .3s;display:inline-flex;position:relative}.l-btn:hover{border-color:var(--l-btn-hover-border-color,var(--l-btn-hover-background));color:var(--l-btn-hover-text-color);background:var(--l-btn-hover-background)}.l-btn:active{border-color:var(--l-btn-active-border-color,var(--l-btn-active-background));color:var(--l-btn-active-text-color);background:var(--l-btn-active-background)}.l-btn-normal{--l-btn-text-color:auto;--l-btn-background:transparent;--l-btn-border-color:#d9d9d9;--l-btn-hover-text-color:var(--l-primary-color-light1,#9254de);--l-btn-active-text-color:var(--l-primary-color-dark1,#531dab);--l-btn-hover-background:#fff;--l-btn-active-background:#fff;--l-btn-hover-border-color:var(--l-btn-hover-text-color);--l-btn-active-border-color:var(--l-btn-active-text-color)}.l-btn-primary{--l-btn-background:var(--l-primary-color,#722ed1);--l-btn-hover-background:var(--l-primary-color-light1,#9254de);--l-btn-active-background:var(--l-primary-color-dark1,#531dab);--l-btn-disabled-border-color:var(--l-primary-color-light2,#b37feb);--l-btn-disabled-background:var(--l-primary-color-light2,#b37feb);--l-btn-disabled-color:#fff}.l-btn:disabled{border-color:var(--l-btn-disabled-border-color);background:var(--l-btn-disabled-background);color:var(--l-btn-disabled-color);cursor:not-allowed;opacity:1}.l-btn.l-btn-loading{cursor:default}.l-btn-text{--l-btn-background:transparent;--l-btn-border-color:transparent;--l-btn-hover-border-color:transparent;--l-btn-active-border-color:transparent;--l-btn-disabled-background:transparent;--l-btn-disabled-border-color:transparent;--l-btn-hover-background:transparent;--l-btn-active-background:transparent;--l-btn-padding:5px}.l-btn-primary.l-btn-text{--l-btn-text-color:var(--l-primary-color,#722ed1);--l-btn-hover-text-color:var(--l-primary-color-light1,#9254de);--l-btn-active-text-color:var(--l-primary-color-dark1,#531dab)}.l-btn-ghost{--l-btn-text-color:var(--l-btn-border-color);--l-btn-background:transparent;--l-btn-hover-background:transparent;--l-btn-active-background:transparent;--l-btn-hover-text-color:var(--l-btn-hover-border-color);--l-btn-active-text-color:var(--l-btn-active-border-color)}.l-btn-round{border-radius:calc(var(--l-form-control-height,32px) / 2)}.l-btn-circle{width:var(--l-form-control-height,32px);border-radius:50%;padding:0}.l-btn:not(.l-btn-text)+.l-btn{margin-left:10px}html.dark .l-btn:disabled{--l-btn-disabled-background:#ffffff14;--l-btn-disabled-color:#ffffff4d;--l-btn-disabled-border-color:#ffffff4d}", m = class extends e {
|
|
8
|
+
static baseName = "button";
|
|
9
|
+
$btn;
|
|
10
|
+
constructor() {
|
|
11
|
+
super(), this.version = 2, this._state = {
|
|
12
|
+
loading: !1,
|
|
13
|
+
htmlType: "button",
|
|
14
|
+
text: !1,
|
|
15
|
+
ghost: !1,
|
|
16
|
+
disabled: !1,
|
|
17
|
+
type: "normal",
|
|
18
|
+
shape: "default",
|
|
19
|
+
loadingText: "加载中……",
|
|
20
|
+
size: "default"
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
get disabled() {
|
|
24
|
+
return this._state.disabled;
|
|
25
|
+
}
|
|
26
|
+
set disabled(e) {
|
|
27
|
+
this.setDisabled(e);
|
|
28
|
+
}
|
|
29
|
+
setLoading(e) {
|
|
30
|
+
this.$btn && (e ? (a(this.$btn, "l-btn-loading"), this.$btn.disabled = !0, this.$btn.innerHTML = this.loadingBody()) : (u(this.$btn, "l-btn-loading"), this.$btn.disabled = this.disabled, this.$btn.innerHTML = "<slot></slot>"));
|
|
31
|
+
}
|
|
32
|
+
setDisabled(e) {
|
|
33
|
+
this._state.disabled = e, this.$btn && (this.$btn.disabled = e);
|
|
34
|
+
}
|
|
35
|
+
static get observedAttributes() {
|
|
36
|
+
return [
|
|
37
|
+
"loading",
|
|
38
|
+
"color",
|
|
39
|
+
"text",
|
|
40
|
+
"ghost",
|
|
41
|
+
"disabled",
|
|
42
|
+
"height",
|
|
43
|
+
"html-type",
|
|
44
|
+
"type",
|
|
45
|
+
"shape",
|
|
46
|
+
"loading-text",
|
|
47
|
+
"size"
|
|
48
|
+
];
|
|
49
|
+
}
|
|
50
|
+
attributeChanged(e, i, a) {
|
|
51
|
+
switch (e) {
|
|
52
|
+
case "color":
|
|
53
|
+
case "shape":
|
|
54
|
+
case "type":
|
|
55
|
+
case "size":
|
|
56
|
+
this._state[e] = a;
|
|
57
|
+
break;
|
|
58
|
+
case "height":
|
|
59
|
+
this._state[e] = r(a);
|
|
60
|
+
break;
|
|
61
|
+
case "text":
|
|
62
|
+
case "ghost":
|
|
63
|
+
case "disabled":
|
|
64
|
+
case "loading":
|
|
65
|
+
this._state[e] = n(a, !1, e);
|
|
66
|
+
break;
|
|
67
|
+
case "html-type":
|
|
68
|
+
case "loading-text":
|
|
69
|
+
this._state[t(e)] = a;
|
|
70
|
+
break;
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
updateDOM(e) {
|
|
74
|
+
this.$btn && (e.has("loading") && this.setLoading(this._state.loading), e.has("disabled") && this.setDisabled(this.disabled), e.has("color") && this._state.color && (this.$btn.style.cssText = this.applyColor(this._state.color, this._state.text, this._state.ghost)), e.has("type") && d(this.$btn, 1, `l-btn-${this._state.type || "normal"}`), e.has("size") && d(this.$btn, 2, `l-btn-${this._state.size || "default"}`), e.has("shape") && d(this.$btn, 3, `l-btn-${this._state.shape || "default"}`)), e.has("height") && this._updateHeight();
|
|
75
|
+
}
|
|
76
|
+
connectedCallback() {
|
|
77
|
+
this.className = `l-btn-${this._state.size || "default"} ${this.className}`, super.connectedCallback(), this.isFormButton() && l(this, "click", this._handleClick), this._updateHeight();
|
|
78
|
+
}
|
|
79
|
+
disconnectedCallback() {
|
|
80
|
+
super.disconnectedCallback(), this.isFormButton() && c(this, "click", this._handleClick), this.$btn = void 0;
|
|
81
|
+
}
|
|
82
|
+
isFormButton() {
|
|
83
|
+
let e = this.getHtmlType();
|
|
84
|
+
return e === "submit" || e === "reset";
|
|
85
|
+
}
|
|
86
|
+
getHtmlType() {
|
|
87
|
+
return this._state.htmlType;
|
|
88
|
+
}
|
|
89
|
+
render_v2() {
|
|
90
|
+
return {
|
|
91
|
+
style: [i, p],
|
|
92
|
+
template: this.render()
|
|
93
|
+
};
|
|
94
|
+
}
|
|
95
|
+
render() {
|
|
96
|
+
let e = document.createElement("button"), t = this._state.loading, n = this._state.text, r = this._state.ghost;
|
|
97
|
+
e.className = o([
|
|
98
|
+
"l-btn",
|
|
99
|
+
`l-btn-${this._state.type}`,
|
|
100
|
+
`l-btn-${this._state.size}`,
|
|
101
|
+
`l-btn-${this._state.shape}`,
|
|
102
|
+
r ? "l-btn-ghost" : "",
|
|
103
|
+
n ? "l-btn-text" : "",
|
|
104
|
+
t ? "l-btn-loading" : ""
|
|
105
|
+
]), (this.disabled || t) && (e.disabled = !0), e.type = this._state.htmlType;
|
|
106
|
+
let i = this.applyColor(this._state.color || "", n, r);
|
|
107
|
+
return i && (e.style.cssText = i), t ? e.innerHTML = this.loadingBody() : e.innerHTML = "<slot></slot>", e.setAttribute("part", "default"), this.$btn = e, e;
|
|
108
|
+
}
|
|
109
|
+
loadingBody() {
|
|
110
|
+
let e = this._state.loadingText, t = ["<l-loading-icon class=\"l-rotate-anim\"></l-loading-icon>"];
|
|
111
|
+
return e ? t.push(`<span>${e}</span>`) : t.push("<slot></slot>"), t.join("");
|
|
112
|
+
}
|
|
113
|
+
applyColor(e, t = !1, n = !1) {
|
|
114
|
+
if (!e) return "";
|
|
115
|
+
let r = f(e, 1, !0), i = f(e, 3, !1);
|
|
116
|
+
return s({
|
|
117
|
+
"--l-btn-border-color": t ? "transparent" : e,
|
|
118
|
+
"--l-btn-text-color": n || t ? e : "#ffffff",
|
|
119
|
+
"--l-btn-hover-text-color": n || t ? r : "#ffffff",
|
|
120
|
+
"--l-btn-background": n || t ? "transparent" : e,
|
|
121
|
+
"--l-btn-active-text-color": n || t ? i : "#ffffff",
|
|
122
|
+
"--l-btn-hover-border-color": t ? "transparent" : r,
|
|
123
|
+
"--l-btn-hover-background": n || t ? "transparent" : r,
|
|
124
|
+
"--l-btn-active-background": n || t ? "transparent" : i,
|
|
125
|
+
"--l-btn-active-border-color": t ? "transparent" : i
|
|
126
|
+
});
|
|
127
|
+
}
|
|
128
|
+
_updateHeight() {
|
|
129
|
+
this._state.height ? this.style.setProperty("--l-btn-height", this._state.height) : this.style.removeProperty("--l-btn-height");
|
|
130
|
+
}
|
|
131
|
+
_replaceBtnClass(e, t) {
|
|
132
|
+
if (this.$btn) {
|
|
133
|
+
let n = this.$btn.classList.item(e);
|
|
134
|
+
n && this.$btn.classList.replace(n, t);
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
_handleClick = () => {
|
|
138
|
+
(this._state.htmlType === "reset" || this._state.htmlType === "submit") && this.emit("form-action", {
|
|
139
|
+
bubbles: !0,
|
|
140
|
+
composed: !0,
|
|
141
|
+
detail: this._state.htmlType
|
|
142
|
+
});
|
|
143
|
+
};
|
|
144
|
+
};
|
|
145
|
+
//#endregion
|
|
146
|
+
export { m as t };
|
package/lib/calendar/index.d.ts
CHANGED
|
@@ -1,20 +1,31 @@
|
|
|
1
|
-
import
|
|
1
|
+
import BaseComponent from "../base";
|
|
2
2
|
type CalendarState = {
|
|
3
3
|
locale: string;
|
|
4
4
|
minDate: number;
|
|
5
5
|
maxDate: number;
|
|
6
|
+
year: number;
|
|
7
|
+
month: number;
|
|
8
|
+
type: "select" | "range";
|
|
6
9
|
};
|
|
7
|
-
export default class Calendar extends
|
|
10
|
+
export default class Calendar extends BaseComponent<CalendarState> {
|
|
8
11
|
static baseName: string;
|
|
9
|
-
private _currentDate;
|
|
10
12
|
private _langData;
|
|
11
13
|
private $container?;
|
|
14
|
+
/** 选择的日期列表 */
|
|
15
|
+
private _selectDates;
|
|
16
|
+
private _range;
|
|
17
|
+
private _value;
|
|
12
18
|
constructor();
|
|
19
|
+
get value(): string;
|
|
20
|
+
set value(v: string);
|
|
13
21
|
setValue(v: string): void;
|
|
14
|
-
|
|
22
|
+
private _updateValue;
|
|
15
23
|
afterInit(): void;
|
|
16
24
|
beforeDestroy(): void;
|
|
17
25
|
static get observedAttributes(): string[];
|
|
26
|
+
handleCellClick: (e: Event) => void;
|
|
27
|
+
handleCellHover: (e: Event) => void;
|
|
28
|
+
private _emitDayAction;
|
|
18
29
|
protected attributeChanged(name: string, oldValue: string, newValue: string): void;
|
|
19
30
|
protected updateDOM(changedProps: Set<string>): void;
|
|
20
31
|
private _renderHeader;
|
package/lib/calendar/index.js
CHANGED
|
@@ -1,95 +1,2 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
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
|
+
import { t as e } from "../calendar-DeP6yZB0.js";
|
|
2
|
+
export { e as default };
|
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
import e from "./base.js";
|
|
2
|
+
import { parseAttrValue as t } from "./utils/index.js";
|
|
3
|
+
import { $one as n, hasClass as r, off as i, on as a, shouldEventNext as o } from "ph-utils/dom";
|
|
4
|
+
import { endOf as s, format as c, startOf as l, timestamp as u } from "ph-utils/date";
|
|
5
|
+
import { get as d } from "ph-utils/storage";
|
|
6
|
+
//#region src/components/calendar/index.less?inline
|
|
7
|
+
var f = ":host{box-sizing:border-box;width:100%;height:100%;display:block}.calendar-table{border-collapse:collapse;table-layout:fixed;width:100%;height:100%}.calendar-table thead{height:var(--l-calendar-header-height,32px)}.calendar-table th{cursor:default;font-weight:400}.calendar-table .excluded{color:var(--l-calendar-off-text-color,#a8abb2)}.day{text-align:center;cursor:pointer;font-size:14px;transition:background-color .2s}:where(.day:hover){background-color:#0000000a}.day.disabled{color:var(--l-calendar-off-text-color,#a8abb2);cursor:not-allowed}.day.active:not(.disabled){background-color:var(--l-primary-color,#007bff);color:#fff;font-weight:700}.day.today{color:var(--l-primary-color,#007bff)}.day.range{background-color:var(--l-primary-color-light4,#cce6ff)}.day.range-start,.day.range-end{background-color:var(--l-primary-color,#007bff);color:#fff}", p = { "zh-CN": { weekdays: [
|
|
8
|
+
"一",
|
|
9
|
+
"二",
|
|
10
|
+
"三",
|
|
11
|
+
"四",
|
|
12
|
+
"五",
|
|
13
|
+
"六",
|
|
14
|
+
"七"
|
|
15
|
+
] } }, m = class extends e {
|
|
16
|
+
static baseName = "calendar";
|
|
17
|
+
_langData;
|
|
18
|
+
$container;
|
|
19
|
+
_selectDates;
|
|
20
|
+
_range;
|
|
21
|
+
_value;
|
|
22
|
+
constructor() {
|
|
23
|
+
super(), this.version = 2;
|
|
24
|
+
let e = d("l_app_locale", "zh-CN", { storage: "session" }), t = /* @__PURE__ */ new Date();
|
|
25
|
+
this._value = "", this._state = {
|
|
26
|
+
locale: e,
|
|
27
|
+
minDate: -Infinity,
|
|
28
|
+
maxDate: Infinity,
|
|
29
|
+
year: t.getFullYear(),
|
|
30
|
+
type: "select",
|
|
31
|
+
month: t.getMonth()
|
|
32
|
+
}, this._langData = p[e], this._selectDates = /* @__PURE__ */ new Set(), this._range = [0, 0];
|
|
33
|
+
}
|
|
34
|
+
get value() {
|
|
35
|
+
return this._value;
|
|
36
|
+
}
|
|
37
|
+
set value(e) {
|
|
38
|
+
this.setValue(e);
|
|
39
|
+
}
|
|
40
|
+
setValue(e) {
|
|
41
|
+
e != this._value && (this._value = e, this._updateValue());
|
|
42
|
+
}
|
|
43
|
+
_updateValue() {
|
|
44
|
+
this._state.type === "range" ? (this._value ? this._range = this._value.split(",").map((e) => /^\d+$/.test(e) ? e.length === 10 ? Number(e) * 1e3 : Number(e) : u(e, "ms")) : this._range = [0, 0], this._selectDates.clear()) : (this._selectDates = new Set(this._value.split("&")), this._range = [0, 0]), this.batchUpdate();
|
|
45
|
+
}
|
|
46
|
+
afterInit() {
|
|
47
|
+
this.$container = n(".calendar-table", this.root), a(this.root, "click", this.handleCellClick), a(this.$container, "mouseover", this.handleCellHover);
|
|
48
|
+
}
|
|
49
|
+
beforeDestroy() {
|
|
50
|
+
i(this.root, "click", this.handleCellClick), this.$container &&= (i(this.$container, "mouseover", this.handleCellHover), void 0);
|
|
51
|
+
}
|
|
52
|
+
static get observedAttributes() {
|
|
53
|
+
return [
|
|
54
|
+
"value",
|
|
55
|
+
"locale",
|
|
56
|
+
"year",
|
|
57
|
+
"month",
|
|
58
|
+
"min-date",
|
|
59
|
+
"max-date",
|
|
60
|
+
"type"
|
|
61
|
+
];
|
|
62
|
+
}
|
|
63
|
+
handleCellClick = (e) => {
|
|
64
|
+
let [t, n, r] = o(e, "l-day", this.root);
|
|
65
|
+
t && this._emitDayAction(r, "click", n);
|
|
66
|
+
};
|
|
67
|
+
handleCellHover = (e) => {
|
|
68
|
+
let [t, n, r] = o(e, "l-day", this.root);
|
|
69
|
+
t && this._emitDayAction(r, "hover", n);
|
|
70
|
+
};
|
|
71
|
+
_emitDayAction(e, t, n) {
|
|
72
|
+
this.emit(`day-${t}`, { detail: {
|
|
73
|
+
minTimestamp: this._state.minDate,
|
|
74
|
+
maxTimestamp: this._state.maxDate,
|
|
75
|
+
dayTimestamp: Number(n),
|
|
76
|
+
day: e.title,
|
|
77
|
+
isActiveMonth: !r(e, "excluded")
|
|
78
|
+
} });
|
|
79
|
+
}
|
|
80
|
+
attributeChanged(e, n, r) {
|
|
81
|
+
switch (e) {
|
|
82
|
+
case "locale":
|
|
83
|
+
p.hasOwnProperty(r) && (this._state.locale = r, this._langData = p[r]);
|
|
84
|
+
break;
|
|
85
|
+
case "min-date":
|
|
86
|
+
this._state.minDate = l(r).getTime();
|
|
87
|
+
break;
|
|
88
|
+
case "max-date":
|
|
89
|
+
this._state.maxDate = s(r).getTime();
|
|
90
|
+
break;
|
|
91
|
+
case "year":
|
|
92
|
+
this._state.year = t(r, this._state.year);
|
|
93
|
+
break;
|
|
94
|
+
case "month":
|
|
95
|
+
this._state.month = t(r, this._state.month + 1) - 1;
|
|
96
|
+
break;
|
|
97
|
+
case "type":
|
|
98
|
+
this._state.type = r, this._updateValue();
|
|
99
|
+
break;
|
|
100
|
+
case "value":
|
|
101
|
+
this.setValue(r);
|
|
102
|
+
break;
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
updateDOM(e) {
|
|
106
|
+
e.has("locale") ? this.rerenderHeader() : e.has("year") || e.has("month") ? this.$container && (this.$container.innerHTML = this.rerender()) : this.rerenderBody();
|
|
107
|
+
}
|
|
108
|
+
_renderHeader() {
|
|
109
|
+
return `<tr>${this._langData.weekdays.map((e) => `<th>${e}</th>`).join("")}</tr>`;
|
|
110
|
+
}
|
|
111
|
+
_renderBody() {
|
|
112
|
+
let e = this._state.year, t = this._state.month, n = c(null, "yyyy-mm-dd"), r = new Date(e, t, 1), i = r.getDay() - 1;
|
|
113
|
+
i < 0 && (i = 6);
|
|
114
|
+
let a = new Date(e, t + 1, 0), o = a.getDate(), s = c(a, "yyyy-mm"), l = new Date(e, t, 0), u = l.getDate(), d = c(l, "yyyy-mm"), f = c(new Date(e, t + 1, 1), "yyyy-mm"), p = new Date(r);
|
|
115
|
+
p.setDate(p.getDate() - i);
|
|
116
|
+
let m = p.setHours(0, 0, 0, 0), h = "", [g, _] = this._range || [];
|
|
117
|
+
for (let e = 0; e < 42; e++) {
|
|
118
|
+
e % 7 == 0 && (h += "<tr>");
|
|
119
|
+
let t, r = "day", a = "";
|
|
120
|
+
e < i ? (t = `${u - i + e + 1}`, r += " excluded", a = d) : e < i + o ? (t = `${e - i + 1}`, a = s) : (t = `${e - i - o + 1}`, r += " excluded", a = f), (m < this._state.minDate || m > this._state.maxDate) && (r += " disabled");
|
|
121
|
+
let c = `${a}-${t.padStart(2, "0")}`;
|
|
122
|
+
c === n && (r += " today"), this._selectDates.has(c) && (r += " active"), g && _ && (g === m ? r += " range-start" : _ === m ? r += " range-end" : g < m && m < _ && (r += " range")), h += `<td class="${r}" title="${c}" l-day="${m}">${t}</td>`, m += 864e5, e % 7 == 6 && (h += "</tr>");
|
|
123
|
+
}
|
|
124
|
+
return h;
|
|
125
|
+
}
|
|
126
|
+
rerenderHeader() {
|
|
127
|
+
if (this.$container) {
|
|
128
|
+
let e = n("thead", this.$container);
|
|
129
|
+
e.innerHTML = this._renderHeader();
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
rerenderBody() {
|
|
133
|
+
if (this.$container) {
|
|
134
|
+
let e = n("tbody", this.$container);
|
|
135
|
+
e.innerHTML = this._renderBody();
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
rerender() {
|
|
139
|
+
return `<thead>${this._renderHeader()}</thead><tbody>${this._renderBody()}</tbody>`;
|
|
140
|
+
}
|
|
141
|
+
render_v2() {
|
|
142
|
+
return {
|
|
143
|
+
template: `<table class="calendar-table" l-day="__stop__">${this.rerender()}</table>`,
|
|
144
|
+
style: [f]
|
|
145
|
+
};
|
|
146
|
+
}
|
|
147
|
+
};
|
|
148
|
+
//#endregion
|
|
149
|
+
export { m as t };
|