litos-ui 0.17.5 → 0.18.1
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/animation-CTt9qgA7.js +4 -0
- package/lib/base-Dm0WS1pK.js +62 -0
- package/lib/base.js +111 -147
- package/lib/button/index.d.ts +8 -3
- package/lib/button/index.js +2 -137
- package/lib/button-CC5PmAb1.js +146 -0
- package/lib/calendar/index.d.ts +10 -5
- package/lib/calendar/index.js +2 -123
- package/lib/calendar-GpYHNmXG.js +149 -0
- package/lib/carousel/index.js +2 -280
- package/lib/carousel/item.js +2 -15
- package/lib/carousel-dT3FJPQo.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-C3IRHLeg.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-BY2yljeC.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-COPKk8Jm.js +162 -0
- package/lib/image_preview-CYEup07F.js +92 -0
- package/lib/index.d.ts +5 -81
- package/lib/index.js +78 -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-B7Elh5xE.js +14 -0
- package/lib/item-CvoJt3wp.js +60 -0
- package/lib/item-DRsOV_Tc.js +119 -0
- package/lib/list/index.js +2 -58
- package/lib/list-CU7vHS6s.js +51 -0
- package/lib/loading/index.d.ts +3 -2
- package/lib/loading/index.js +109 -127
- package/lib/mask/index.js +2 -105
- package/lib/mask-CEznzwji.js +112 -0
- package/lib/md_input/index.js +2 -60
- package/lib/md_input-DSQx5TMW.js +58 -0
- package/lib/menu/index.d.ts +30 -13
- package/lib/menu/index.js +2 -105
- package/lib/menu/types.d.ts +6 -0
- package/lib/menu/types.js +0 -0
- package/lib/menu-CzV6lOlw.js +224 -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-BJkEstRw.js +101 -0
- package/lib/pagination/index.js +2 -248
- package/lib/pagination-5t7AOeFV.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-BKG2MibP.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-Bv-p0DL8.js +38 -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-CI1xSj1G.js +96 -0
- package/lib/table/index.js +2 -269
- package/lib/table-DfL2hFqA.js +234 -0
- package/lib/tabs/index.js +38 -42
- package/lib/tag/index.js +2 -72
- package/lib/tag-72DwCkvq.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 +14 -14
- 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/menu/menu_item.d.ts +0 -6
- package/lib/menu/menu_item.js +0 -21
- package/lib/menu/sub_menu.d.ts +0 -15
- package/lib/menu/sub_menu.js +0 -83
- package/lib/table/types.js +0 -1
package/lib/calendar/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import BaseComponent from "../base";
|
|
2
2
|
type CalendarState = {
|
|
3
3
|
locale: string;
|
|
4
4
|
minDate: number;
|
|
@@ -7,19 +7,25 @@ type CalendarState = {
|
|
|
7
7
|
month: number;
|
|
8
8
|
type: "select" | "range";
|
|
9
9
|
};
|
|
10
|
-
export default class Calendar extends
|
|
10
|
+
export default class Calendar extends BaseComponent<CalendarState> {
|
|
11
11
|
static baseName: string;
|
|
12
12
|
private _langData;
|
|
13
13
|
private $container?;
|
|
14
14
|
/** 选择的日期列表 */
|
|
15
15
|
private _selectDates;
|
|
16
|
-
private _range
|
|
16
|
+
private _range;
|
|
17
|
+
private _value;
|
|
17
18
|
constructor();
|
|
19
|
+
get value(): string;
|
|
20
|
+
set value(v: string);
|
|
18
21
|
setValue(v: string): void;
|
|
19
|
-
|
|
22
|
+
private _updateValue;
|
|
20
23
|
afterInit(): void;
|
|
21
24
|
beforeDestroy(): void;
|
|
22
25
|
static get observedAttributes(): string[];
|
|
26
|
+
handleCellClick: (e: Event) => void;
|
|
27
|
+
handleCellHover: (e: Event) => void;
|
|
28
|
+
private _emitDayAction;
|
|
23
29
|
protected attributeChanged(name: string, oldValue: string, newValue: string): void;
|
|
24
30
|
protected updateDOM(changedProps: Set<string>): void;
|
|
25
31
|
private _renderHeader;
|
|
@@ -31,6 +37,5 @@ export default class Calendar extends FormInner<CalendarState> {
|
|
|
31
37
|
template?: string | HTMLElement | DocumentFragment;
|
|
32
38
|
style?: string | string[];
|
|
33
39
|
};
|
|
34
|
-
private _updateCellsState;
|
|
35
40
|
}
|
|
36
41
|
export {};
|
package/lib/calendar/index.js
CHANGED
|
@@ -1,123 +1,2 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
3
|
-
import { $one as m } from "ph-utils/dom";
|
|
4
|
-
import { langs as f } from "./langs.js";
|
|
5
|
-
import { get as T } from "ph-utils/storage";
|
|
6
|
-
import { parse as w, endOf as M, startOf as I, format as c } from "ph-utils/date";
|
|
7
|
-
const O = ":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}";
|
|
8
|
-
class Y extends u {
|
|
9
|
-
static baseName = "calendar";
|
|
10
|
-
_langData;
|
|
11
|
-
$container;
|
|
12
|
-
/** 选择的日期列表 */
|
|
13
|
-
_selectDates;
|
|
14
|
-
_range;
|
|
15
|
-
constructor() {
|
|
16
|
-
super(), this.version = 2;
|
|
17
|
-
const t = T("l_app_locale", "zh-CN", { storage: "session" }), e = /* @__PURE__ */ new Date();
|
|
18
|
-
this._state = {
|
|
19
|
-
locale: t,
|
|
20
|
-
minDate: -1 / 0,
|
|
21
|
-
maxDate: 1 / 0,
|
|
22
|
-
year: e.getFullYear(),
|
|
23
|
-
month: e.getMonth(),
|
|
24
|
-
type: "select"
|
|
25
|
-
}, this._langData = f[t], this._selectDates = [];
|
|
26
|
-
}
|
|
27
|
-
setValue(t) {
|
|
28
|
-
t != this.value && (super.setValue(t), this._state.type === "select" ? this._selectDates = t.split(",") : this._range = t.split(",").map((e) => w(e).getTime()), this.batchUpdate());
|
|
29
|
-
}
|
|
30
|
-
connectedCallback() {
|
|
31
|
-
super.connectedCallback();
|
|
32
|
-
}
|
|
33
|
-
afterInit() {
|
|
34
|
-
this.$container = m(".calendar-table", this.root);
|
|
35
|
-
}
|
|
36
|
-
beforeDestroy() {
|
|
37
|
-
this.$container = void 0;
|
|
38
|
-
}
|
|
39
|
-
static get observedAttributes() {
|
|
40
|
-
return [
|
|
41
|
-
...u.observedAttributes,
|
|
42
|
-
"locale",
|
|
43
|
-
"year",
|
|
44
|
-
"month",
|
|
45
|
-
"min-date",
|
|
46
|
-
"max-date",
|
|
47
|
-
"type"
|
|
48
|
-
];
|
|
49
|
-
}
|
|
50
|
-
attributeChanged(t, e, a) {
|
|
51
|
-
switch (t) {
|
|
52
|
-
case "locale":
|
|
53
|
-
f.hasOwnProperty(a) && (this._state.locale = a, this._langData = f[a]);
|
|
54
|
-
break;
|
|
55
|
-
case "min-date":
|
|
56
|
-
this._state.minDate = I(a).getTime();
|
|
57
|
-
break;
|
|
58
|
-
case "max-date":
|
|
59
|
-
this._state.maxDate = M(a).getTime();
|
|
60
|
-
break;
|
|
61
|
-
case "year":
|
|
62
|
-
this._state.year = g(a, this._state.year);
|
|
63
|
-
break;
|
|
64
|
-
case "month":
|
|
65
|
-
this._state.month = g(a, this._state.month + 1) - 1;
|
|
66
|
-
break;
|
|
67
|
-
case "type":
|
|
68
|
-
this._state.type = a;
|
|
69
|
-
break;
|
|
70
|
-
}
|
|
71
|
-
}
|
|
72
|
-
updateDOM(t) {
|
|
73
|
-
t.has("locale") ? this.rerenderHeader() : (t.has("year") || t.has("month")) && this.$container && (this.$container.innerHTML = this.rerender());
|
|
74
|
-
}
|
|
75
|
-
_renderHeader() {
|
|
76
|
-
return `<tr>${this._langData.weekdays.map((e) => `<th>${e}</th>`).join("")}</tr>`;
|
|
77
|
-
}
|
|
78
|
-
_renderBody() {
|
|
79
|
-
const t = this._state.year, e = this._state.month, a = c(null, "yyyy-mm-dd"), b = new Date(t, e, 1);
|
|
80
|
-
let s = b.getDay() - 1;
|
|
81
|
-
s < 0 && (s = 6);
|
|
82
|
-
const p = new Date(t, e + 1, 0), D = p.getDate(), $ = c(p, "yyyy-mm"), _ = new Date(t, e, 0), x = _.getDate(), v = c(_, "yyyy-mm"), k = new Date(t, e + 1, 1), C = c(k, "yyyy-mm"), d = new Date(b);
|
|
83
|
-
d.setDate(d.getDate() - s);
|
|
84
|
-
let h = d.setHours(0, 0, 0, 0);
|
|
85
|
-
const H = 864e5;
|
|
86
|
-
let i = "";
|
|
87
|
-
for (let r = 0; r < 42; r++) {
|
|
88
|
-
r % 7 === 0 && (i += "<tr>");
|
|
89
|
-
let n, o = "day", l = "";
|
|
90
|
-
r < s ? (n = `${x - s + r + 1}`, o += " prev-month", l = v) : r < s + D ? (n = `${r - s + 1}`, l = $) : (n = `${r - s - D + 1}`, o += " next-month", l = C), (h < this._state.minDate || h > this._state.maxDate) && (o += " disabled");
|
|
91
|
-
const y = `${l}-${n.padStart(2, "0")}`;
|
|
92
|
-
y === a && (o += " today"), y === this.value && (o += " active"), i += `<td class="${o}" title="${y}">${n}</td>`, h += H, r % 7 === 6 && (i += "</tr>");
|
|
93
|
-
}
|
|
94
|
-
return i;
|
|
95
|
-
}
|
|
96
|
-
rerenderHeader() {
|
|
97
|
-
if (this.$container) {
|
|
98
|
-
const t = m("thead", this.$container);
|
|
99
|
-
t.innerHTML = this._renderHeader();
|
|
100
|
-
}
|
|
101
|
-
}
|
|
102
|
-
rerenderBody() {
|
|
103
|
-
if (this.$container) {
|
|
104
|
-
const t = m("tbody", this.$container);
|
|
105
|
-
t.innerHTML = this._renderBody();
|
|
106
|
-
}
|
|
107
|
-
}
|
|
108
|
-
rerender() {
|
|
109
|
-
return `<thead>${this._renderHeader()}</thead><tbody>${this._renderBody()}</tbody>`;
|
|
110
|
-
}
|
|
111
|
-
render_v2() {
|
|
112
|
-
return {
|
|
113
|
-
template: `<table class="calendar-table">${this.rerender()}</table>`,
|
|
114
|
-
style: [O]
|
|
115
|
-
};
|
|
116
|
-
}
|
|
117
|
-
//只要 minDate、maxDate、_rangeStart、_rangeEnd、_hoverDate、_selectedDates 任何一个发生了改变,都调用这个统一的函数。
|
|
118
|
-
_updateCellsState() {
|
|
119
|
-
}
|
|
120
|
-
}
|
|
121
|
-
export {
|
|
122
|
-
Y as default
|
|
123
|
-
};
|
|
1
|
+
import { t as e } from "../calendar-GpYHNmXG.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 };
|
package/lib/carousel/index.js
CHANGED
|
@@ -1,280 +1,2 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
3
|
-
import { debounce as x } from "ph-utils/web";
|
|
4
|
-
import { parseAttrValue as d } from "../utils/index.js";
|
|
5
|
-
import b from "./timer.js";
|
|
6
|
-
const g = ":host{display:block;width:100%;height:180px;margin:0 auto;box-sizing:border-box;position:relative;overflow:hidden}.container{min-width:900%;height:100%;box-sizing:border-box;position:relative;display:flex}.nav-button{position:absolute;top:50%;transform:translateY(-50%);width:30px;height:30px;border:none;outline:none;border-radius:50%;cursor:pointer;display:flex;justify-content:center;align-items:center;z-index:20;font-size:16px;background-color:#292d3d4d;margin:0;padding:0;color:#fff;transition:background-color .3s}.nav-button:hover{background-color:#292d3d66}.nav-button:active{background-color:#292d3d80}.nav-prev{left:20px}.nav-next{right:20px}.pagination{position:absolute;bottom:10px;left:0;width:100%;z-index:2;display:flex;align-items:center;gap:8px;justify-content:center}.bullet{display:inline-block;width:8px;height:8px;border-radius:50%;background-color:#0000004d;cursor:pointer;transition:background-color .3s}.bullet.active{background-color:var(--l-primary-color, #722ed1)}";
|
|
7
|
-
class A extends u {
|
|
8
|
-
static baseName = "carousel";
|
|
9
|
-
/** 是否显示箭头 */
|
|
10
|
-
arrows = "hover";
|
|
11
|
-
currentIndex = 0;
|
|
12
|
-
allIndex = -1;
|
|
13
|
-
#s = 0;
|
|
14
|
-
// 当前偏移量
|
|
15
|
-
loop = !0;
|
|
16
|
-
observer;
|
|
17
|
-
autoplay = !1;
|
|
18
|
-
#e = void 0;
|
|
19
|
-
/* 手势 */
|
|
20
|
-
#o = 0;
|
|
21
|
-
#i = !1;
|
|
22
|
-
#d = 0;
|
|
23
|
-
#r = 0;
|
|
24
|
-
// 节点引用
|
|
25
|
-
#t;
|
|
26
|
-
static get observedAttributes() {
|
|
27
|
-
return ["arrows", "loop", "current-index", "autoplay"];
|
|
28
|
-
}
|
|
29
|
-
attributeChangedCallback(t, e, i) {
|
|
30
|
-
switch (t) {
|
|
31
|
-
case "arrows":
|
|
32
|
-
const s = d(i, "hover");
|
|
33
|
-
if (s !== this.arrows) {
|
|
34
|
-
this.arrows = s;
|
|
35
|
-
const a = document.createDocumentFragment();
|
|
36
|
-
this.renderArrows(a), this.root.appendChild(a);
|
|
37
|
-
}
|
|
38
|
-
break;
|
|
39
|
-
case "loop":
|
|
40
|
-
this.loop = d(i, !1, "loop");
|
|
41
|
-
break;
|
|
42
|
-
case "current-index":
|
|
43
|
-
const n = d(i, 0);
|
|
44
|
-
n !== this.currentIndex && this.#x(this.loop ? n + 1 : n);
|
|
45
|
-
break;
|
|
46
|
-
case "autoplay":
|
|
47
|
-
const o = d(i, !1, "autoplay");
|
|
48
|
-
o !== this.autoplay && (this.autoplay = o, this.#e && (o ? this.#e.start() : this.#e.stop()));
|
|
49
|
-
break;
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
connectedCallback() {
|
|
53
|
-
this.loadStyleText(g), this.style.setProperty(
|
|
54
|
-
"--carousel-width",
|
|
55
|
-
`${Math.floor(this.clientWidth)}px`
|
|
56
|
-
);
|
|
57
|
-
const t = m(this, "height");
|
|
58
|
-
t && this.style.setProperty("height", `${t}px`), this.#m(), super.connectedCallback();
|
|
59
|
-
}
|
|
60
|
-
afterInit() {
|
|
61
|
-
this.setAttribute("data-page", "__stop__"), l(this.root, "click", this.#v), this.#f(), this.#e = b(() => {
|
|
62
|
-
this.#a("next");
|
|
63
|
-
}), this.autoplay && this.#e.start(), this.#t = h(".container", this.root), l(this.#t, "pointerdown", this.#y), l(this.#t, "pointerup", this.#I), l(this.#t, "pointermove", this.#$), l(this.#t, "pointercancel", this.#n), l(this.#t, "pointerleave", this.#n);
|
|
64
|
-
}
|
|
65
|
-
beforeDestroy() {
|
|
66
|
-
r(this, "mouseenter", this.#l), r(this, "mouseleave", this.#h), r(this.root, "click", this.#v), r(this.#t, "pointerdown", this.#y), r(this.#t, "pointerup", this.#I), r(this.#t, "pointermove", this.#$), r(this.#t, "pointercancel", this.#n), r(this.#t, "pointerleave", this.#n), this.#t = void 0, this.#u(!0), this.#e.stop(), this.#e = void 0;
|
|
67
|
-
}
|
|
68
|
-
render() {
|
|
69
|
-
const t = document.createDocumentFragment();
|
|
70
|
-
let e = "";
|
|
71
|
-
if (this.allIndex > 0) {
|
|
72
|
-
const n = this.loop ? this.currentIndex + 1 : this.currentIndex, o = Math.floor(n * this.clientWidth * -1);
|
|
73
|
-
e = `transform:translateX(${o}px);`;
|
|
74
|
-
const a = Math.floor(this.clientWidth * (this.allIndex + 3));
|
|
75
|
-
e += `min-width:${a}px;`, this.#s = o;
|
|
76
|
-
}
|
|
77
|
-
const i = c("div", {
|
|
78
|
-
class: "container",
|
|
79
|
-
style: e,
|
|
80
|
-
"data-container": "1"
|
|
81
|
-
});
|
|
82
|
-
i.appendChild(c("slot")), t.appendChild(i), this.renderArrows(t);
|
|
83
|
-
const s = c("div", { class: "pagination", part: "pagination" });
|
|
84
|
-
return this.allIndex >= 0 && s.replaceChildren(this.#p()), t.appendChild(s), t;
|
|
85
|
-
}
|
|
86
|
-
renderArrows(t) {
|
|
87
|
-
if (this.arrows !== "never")
|
|
88
|
-
this.renderNavigationButton("prev", t), this.renderNavigationButton("next", t), this.arrows === "hover" && (l(this, "mouseenter", this.#l), l(this, "mouseleave", this.#h));
|
|
89
|
-
else {
|
|
90
|
-
r(this, "mouseenter", this.#l), r(this, "mouseleave", this.#h);
|
|
91
|
-
const e = p(".nav-button", this.root);
|
|
92
|
-
e.length && f(e, (i) => {
|
|
93
|
-
i.remove();
|
|
94
|
-
});
|
|
95
|
-
}
|
|
96
|
-
}
|
|
97
|
-
#p() {
|
|
98
|
-
const t = document.createDocumentFragment();
|
|
99
|
-
for (let e = 0; e <= this.allIndex; e++)
|
|
100
|
-
t.appendChild(
|
|
101
|
-
c("div", {
|
|
102
|
-
class: ["bullet", e === this.currentIndex ? "active" : ""],
|
|
103
|
-
"aria-label": `第 ${e + 1} 页`,
|
|
104
|
-
"data-page": `${e}`,
|
|
105
|
-
id: `bullet-${e}`
|
|
106
|
-
})
|
|
107
|
-
);
|
|
108
|
-
return t;
|
|
109
|
-
}
|
|
110
|
-
renderNavigationButton(t = "prev", e) {
|
|
111
|
-
let i = h(`.nav-${t}`, this.root);
|
|
112
|
-
if (i == null) {
|
|
113
|
-
const s = t === "prev" ? "left" : "right";
|
|
114
|
-
i = c("button", {
|
|
115
|
-
class: `nav-button nav-${t}`,
|
|
116
|
-
type: "button",
|
|
117
|
-
innerHTML: `<l-arrow-${s}-icon></l-arrow-${s}-icon>`,
|
|
118
|
-
"aria-label": t,
|
|
119
|
-
"data-page": t
|
|
120
|
-
}), e.appendChild(i);
|
|
121
|
-
}
|
|
122
|
-
this.arrows === "always" ? i.style.display = "flex" : i.style.display = "none";
|
|
123
|
-
}
|
|
124
|
-
#f() {
|
|
125
|
-
this.observer == null && (this.observer = new MutationObserver(this.#C)), this.observer.observe(this, { childList: !0 });
|
|
126
|
-
}
|
|
127
|
-
#u(t = !1) {
|
|
128
|
-
this.observer && (this.observer.disconnect(), t && (this.observer = void 0));
|
|
129
|
-
}
|
|
130
|
-
#w = x(() => {
|
|
131
|
-
const t = h("#cloneFirst", this);
|
|
132
|
-
t && t.remove();
|
|
133
|
-
const e = h("#cloneLast", this);
|
|
134
|
-
if (e && e.remove(), this.#m(), this.#t) {
|
|
135
|
-
if (this.allIndex > 0) {
|
|
136
|
-
const o = Math.floor(
|
|
137
|
-
this.clientWidth * (this.allIndex + 3)
|
|
138
|
-
);
|
|
139
|
-
this.#t.style.minWidth = `${o}px`;
|
|
140
|
-
} else
|
|
141
|
-
this.#t.style.minWidth = "900%";
|
|
142
|
-
const s = this.loop ? this.currentIndex + 1 : this.currentIndex, n = Math.floor(s * this.clientWidth * -1);
|
|
143
|
-
this.#t.style.transform = `translateX(${n}px)`, this.#s = n;
|
|
144
|
-
}
|
|
145
|
-
const i = h(".pagination", this.root);
|
|
146
|
-
i && i.replaceChildren(this.#p()), this.#f();
|
|
147
|
-
}, 300);
|
|
148
|
-
#m() {
|
|
149
|
-
const t = this.children, e = t.length;
|
|
150
|
-
if (e > 0 && this.loop) {
|
|
151
|
-
const i = t[0].cloneNode(!0);
|
|
152
|
-
i.id = "cloneFirst";
|
|
153
|
-
const s = t[e - 1].cloneNode(!0);
|
|
154
|
-
s.id = "cloneLast", this.children[e - 1].insertAdjacentElement("afterend", i), this.children[0].insertAdjacentElement("beforebegin", s);
|
|
155
|
-
}
|
|
156
|
-
this.allIndex = this.children.length - (this.loop ? 3 : 1);
|
|
157
|
-
}
|
|
158
|
-
#C = (t) => {
|
|
159
|
-
for (const e of t)
|
|
160
|
-
e.type === "childList" && (this.#u(), this.#w());
|
|
161
|
-
};
|
|
162
|
-
#v = (t) => {
|
|
163
|
-
const [e, i] = v(t, "data-page", this.root);
|
|
164
|
-
e && this.#a(i);
|
|
165
|
-
};
|
|
166
|
-
#a(t) {
|
|
167
|
-
this.#e.stop();
|
|
168
|
-
const e = this.loop ? this.currentIndex + 1 : this.currentIndex;
|
|
169
|
-
let i = e;
|
|
170
|
-
if (t === "prev")
|
|
171
|
-
this.loop && this.currentIndex === 0 ? i = 0 : i = e - 1, i < 0 && (i = 0);
|
|
172
|
-
else if (t === "next")
|
|
173
|
-
this.loop && this.currentIndex === this.allIndex ? i = this.allIndex + 2 : i = e + 1, !this.loop && i > this.allIndex && (i = this.allIndex);
|
|
174
|
-
else {
|
|
175
|
-
const s = Number(t);
|
|
176
|
-
s !== this.currentIndex && (i = this.loop ? s + 1 : s);
|
|
177
|
-
}
|
|
178
|
-
i !== e && this.#x(i), requestAnimationFrame(() => {
|
|
179
|
-
this.#c();
|
|
180
|
-
});
|
|
181
|
-
}
|
|
182
|
-
#x(t) {
|
|
183
|
-
if (this.#t) {
|
|
184
|
-
const s = Math.floor(t * this.clientWidth * -1), n = this.#t.style.transform;
|
|
185
|
-
this.#t.animate(
|
|
186
|
-
[{ transform: n }, { transform: `translateX(${s}px)` }],
|
|
187
|
-
{ duration: 300 }
|
|
188
|
-
).addEventListener(
|
|
189
|
-
"finish",
|
|
190
|
-
() => {
|
|
191
|
-
let a = s;
|
|
192
|
-
this.loop && t === this.allIndex + 2 ? a = Math.floor(this.clientWidth * -1) : this.loop && t === 0 && (a = Math.floor(this.clientWidth * (this.allIndex + 1) * -1)), this.#t.style.transform = `translateX(${a}px)`, this.#s = a;
|
|
193
|
-
},
|
|
194
|
-
{ once: !0 }
|
|
195
|
-
);
|
|
196
|
-
}
|
|
197
|
-
this.loop && this.allIndex > 0 && t === this.allIndex + 2 ? this.currentIndex = 0 : this.loop && this.allIndex > 0 && t === 0 ? this.currentIndex = this.allIndex : this.currentIndex = this.loop ? t - 1 : t;
|
|
198
|
-
const e = h(".bullet.active", this.root);
|
|
199
|
-
e && e.classList.remove("active");
|
|
200
|
-
const i = h(`#bullet-${this.currentIndex}`, this.root);
|
|
201
|
-
i && i.classList.add("active");
|
|
202
|
-
}
|
|
203
|
-
#l = () => {
|
|
204
|
-
if (this.arrows === "hover") {
|
|
205
|
-
const t = p(".nav-button", this.root);
|
|
206
|
-
f(t, (e) => {
|
|
207
|
-
e.style.display = "flex", this.#b(e, !0);
|
|
208
|
-
});
|
|
209
|
-
}
|
|
210
|
-
};
|
|
211
|
-
#h = () => {
|
|
212
|
-
if (this.arrows === "hover") {
|
|
213
|
-
const t = p(".nav-button", this.root);
|
|
214
|
-
f(t, (e) => {
|
|
215
|
-
this.#b(e, !1);
|
|
216
|
-
});
|
|
217
|
-
}
|
|
218
|
-
};
|
|
219
|
-
#b(t, e = !0) {
|
|
220
|
-
const s = t.getAttribute("data-page") === "prev" ? -10 : 10, n = [];
|
|
221
|
-
e ? n.push(
|
|
222
|
-
{ opacity: 0, transform: `translate3d(${s}px, -50%, 0)` },
|
|
223
|
-
{ opacity: 1, transform: "translate3d(0px, -50%, 0)" }
|
|
224
|
-
) : n.push(
|
|
225
|
-
{ opacity: 1, transform: "translate3d(0px, -50%, 0)" },
|
|
226
|
-
{ opacity: 0, transform: `translate3d(${s}px, -50%, 0)` }
|
|
227
|
-
);
|
|
228
|
-
const o = t.animate(n, {
|
|
229
|
-
duration: 300,
|
|
230
|
-
fill: "both"
|
|
231
|
-
});
|
|
232
|
-
e || o.addEventListener(
|
|
233
|
-
"finish",
|
|
234
|
-
() => {
|
|
235
|
-
t.style.display = "none";
|
|
236
|
-
},
|
|
237
|
-
{ once: !0 }
|
|
238
|
-
);
|
|
239
|
-
}
|
|
240
|
-
#g = () => {
|
|
241
|
-
const t = h(".container", this.root);
|
|
242
|
-
t.style.transition = "transform 0.3s", requestAnimationFrame(() => {
|
|
243
|
-
t.style.transform = `translateX(${this.#s}px)`;
|
|
244
|
-
}), t.addEventListener(
|
|
245
|
-
"transitionend",
|
|
246
|
-
() => {
|
|
247
|
-
t.style.transition = "";
|
|
248
|
-
},
|
|
249
|
-
{ once: !0 }
|
|
250
|
-
);
|
|
251
|
-
};
|
|
252
|
-
#y = (t) => {
|
|
253
|
-
this.#o = t.clientX, this.#i = !0, this.#d = Date.now(), this.#e.stop();
|
|
254
|
-
};
|
|
255
|
-
#$ = (t) => {
|
|
256
|
-
this.#i && (this.#r && cancelAnimationFrame(this.#r), this.#r = requestAnimationFrame(() => {
|
|
257
|
-
const e = Math.floor(t.clientX - this.#o);
|
|
258
|
-
if (!this.loop && (e < 0 && this.currentIndex === this.allIndex || e > 0 && this.currentIndex === 0))
|
|
259
|
-
return;
|
|
260
|
-
const i = this.#s + e;
|
|
261
|
-
this.#t.style.transform = `translateX(${i}px)`;
|
|
262
|
-
}), t.preventDefault());
|
|
263
|
-
};
|
|
264
|
-
#I = (t) => {
|
|
265
|
-
if (!this.#i) return;
|
|
266
|
-
const e = Date.now() - this.#d, i = t.clientX - this.#o;
|
|
267
|
-
if (this.#i = !1, i === 0) return;
|
|
268
|
-
let s = "cancel";
|
|
269
|
-
e <= 200 ? i >= 20 ? s = "prev" : i <= -20 && (s = "next") : i >= this.clientWidth / 2 ? s = "prev" : i <= -this.clientWidth / 2 && (s = "next"), s === "cancel" ? this.#g() : this.#a(s), this.#c();
|
|
270
|
-
};
|
|
271
|
-
#c = () => {
|
|
272
|
-
this.autoplay && this.#e.start();
|
|
273
|
-
};
|
|
274
|
-
#n = () => {
|
|
275
|
-
this.#i && (this.#i = !1, this.#g(), this.#c());
|
|
276
|
-
};
|
|
277
|
-
}
|
|
278
|
-
export {
|
|
279
|
-
A as default
|
|
280
|
-
};
|
|
1
|
+
import { t as e } from "../carousel-dT3FJPQo.js";
|
|
2
|
+
export { e as default };
|
package/lib/carousel/item.js
CHANGED
|
@@ -1,15 +1,2 @@
|
|
|
1
|
-
import e from "../
|
|
2
|
-
|
|
3
|
-
const o = ":host{width:var(--carousel-width, 100%);height:100%;box-sizing:border-box;display:block}:host(.active){display:block}";
|
|
4
|
-
class r extends e {
|
|
5
|
-
static baseName = "carousel-item";
|
|
6
|
-
connectedCallback() {
|
|
7
|
-
this.loadStyleText(o), super.connectedCallback();
|
|
8
|
-
}
|
|
9
|
-
render() {
|
|
10
|
-
return t("slot");
|
|
11
|
-
}
|
|
12
|
-
}
|
|
13
|
-
export {
|
|
14
|
-
r as default
|
|
15
|
-
};
|
|
1
|
+
import { t as e } from "../item-B7Elh5xE.js";
|
|
2
|
+
export { e as default };
|