@gez/date-time-kit 1.1.3 → 2.0.0-alpha.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/dist/assets/arrow-down.svg +1 -0
- package/dist/assets/arrow-left-double.svg +1 -0
- package/dist/assets/arrow-left.svg +1 -0
- package/dist/assets/arrow-right-double.svg +1 -0
- package/dist/assets/arrow-right.svg +1 -0
- package/dist/assets/back-arrow.svg +1 -0
- package/dist/assets/time.svg +1 -0
- package/dist/components/calendar/index.css +108 -0
- package/dist/components/calendar/index.d.ts +84 -0
- package/dist/components/calendar/index.mjs +238 -0
- package/dist/components/hhmmss-ms-list-grp/index.css +60 -0
- package/dist/components/hhmmss-ms-list-grp/index.d.ts +54 -0
- package/dist/components/hhmmss-ms-list-grp/index.mjs +226 -0
- package/dist/components/i18n/index.d.ts +13 -0
- package/dist/components/i18n/index.mjs +42 -0
- package/dist/components/num-list/index.css +35 -0
- package/dist/components/num-list/index.d.ts +68 -0
- package/dist/components/num-list/index.mjs +259 -0
- package/dist/components/period-selector/date-nav.css +92 -0
- package/dist/components/period-selector/date-nav.d.ts +64 -0
- package/dist/components/period-selector/date-nav.mjs +161 -0
- package/dist/components/period-selector/index.css +152 -0
- package/dist/components/period-selector/index.d.ts +68 -0
- package/dist/components/period-selector/index.mjs +312 -0
- package/dist/components/popover/index.d.ts +34 -0
- package/dist/components/popover/index.mjs +104 -0
- package/dist/components/quick-selector/index.css +167 -0
- package/dist/components/quick-selector/index.d.ts +74 -0
- package/dist/components/quick-selector/index.mjs +347 -0
- package/dist/components/web-component-base/index.css +9 -0
- package/dist/components/web-component-base/index.d.ts +46 -0
- package/dist/components/web-component-base/index.mjs +118 -0
- package/dist/components/web-component-base/scrollbar.css +25 -0
- package/dist/components/yyyymmdd-list-grp/index.css +32 -0
- package/dist/components/yyyymmdd-list-grp/index.d.ts +52 -0
- package/dist/components/yyyymmdd-list-grp/index.mjs +181 -0
- package/dist/i18n.d.ts +36 -0
- package/dist/i18n.mjs +368 -0
- package/dist/index.d.ts +7 -0
- package/dist/index.mjs +15 -0
- package/dist/utils.d.ts +12 -0
- package/dist/utils.mjs +21 -0
- package/package.json +37 -63
- package/src/assets/arrow-down.svg +1 -0
- package/src/assets/arrow-left-double.svg +1 -0
- package/src/assets/arrow-left.svg +1 -0
- package/src/assets/arrow-right-double.svg +1 -0
- package/src/assets/arrow-right.svg +1 -0
- package/src/assets/back-arrow.svg +1 -0
- package/src/assets/time.svg +1 -0
- package/src/components/calendar/index.scss +128 -0
- package/src/components/calendar/index.ts +453 -0
- package/src/components/hhmmss-ms-list-grp/index.scss +61 -0
- package/src/components/hhmmss-ms-list-grp/index.ts +387 -0
- package/src/components/i18n/index.ts +48 -0
- package/src/components/num-list/index.scss +38 -0
- package/src/components/num-list/index.ts +357 -0
- package/src/components/period-selector/date-nav.scss +108 -0
- package/src/components/period-selector/date-nav.ts +322 -0
- package/src/components/period-selector/index.scss +160 -0
- package/src/components/period-selector/index.ts +552 -0
- package/src/components/popover/index.ts +127 -0
- package/src/components/quick-selector/index.scss +183 -0
- package/src/components/quick-selector/index.ts +611 -0
- package/src/components/web-component-base/index.scss +11 -0
- package/src/components/web-component-base/index.ts +235 -0
- package/src/components/web-component-base/scrollbar.scss +30 -0
- package/src/components/yyyymmdd-list-grp/index.scss +33 -0
- package/src/components/yyyymmdd-list-grp/index.ts +257 -0
- package/src/i18n.ts +415 -0
- package/src/index.ts +12 -0
- package/src/utils.ts +36 -0
- package/README.md +0 -152
- package/dist/index.css +0 -1
- package/dist/index.html +0 -85
- package/dist/index.js +0 -145
- package/type.d.ts +0 -164
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
.wrapper {
|
|
2
|
+
display: block;
|
|
3
|
+
width: 100%;
|
|
4
|
+
height: 100%;
|
|
5
|
+
display: flex;
|
|
6
|
+
justify-content: space-between;
|
|
7
|
+
overflow: hidden;
|
|
8
|
+
}
|
|
9
|
+
.wrapper.show-list .btns {
|
|
10
|
+
display: none;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
.btns {
|
|
14
|
+
display: flex;
|
|
15
|
+
align-items: center;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
.btn {
|
|
19
|
+
width: 25px;
|
|
20
|
+
height: 25px;
|
|
21
|
+
cursor: pointer;
|
|
22
|
+
background: 50%/16px 16px no-repeat;
|
|
23
|
+
--icon-arrow-left: url("@/assets/arrow-left.svg");
|
|
24
|
+
--icon-arrow-left-double: url("@/assets/arrow-left-double.svg");
|
|
25
|
+
--icon-arrow-right: url("@/assets/arrow-right.svg");
|
|
26
|
+
--icon-arrow-right-double: url("@/assets/arrow-right-double.svg");
|
|
27
|
+
background-image: var(--bg-img);
|
|
28
|
+
border-radius: 50%;
|
|
29
|
+
}
|
|
30
|
+
.btn:hover {
|
|
31
|
+
background-color: #eee;
|
|
32
|
+
}
|
|
33
|
+
:host(:not([show-ctrl-btn-year-add])) .btn.add.year, :host(:not([show-ctrl-btn-year-sub])) .btn.sub.year, :host(:not([show-ctrl-btn-month-add])) .btn.add.month, :host(:not([show-ctrl-btn-month-sub])) .btn.sub.month {
|
|
34
|
+
display: none;
|
|
35
|
+
}
|
|
36
|
+
.btn.sub {
|
|
37
|
+
--bg-img: var(--icon-arrow-left);
|
|
38
|
+
}
|
|
39
|
+
:host([show-ctrl-btn-month-add]) .btn.sub.add.year, :host([show-ctrl-btn-month-sub]) .btn.sub.sub.year {
|
|
40
|
+
--bg-img: var(--icon-arrow-left-double);
|
|
41
|
+
}
|
|
42
|
+
.btn.add {
|
|
43
|
+
--bg-img: var(--icon-arrow-right);
|
|
44
|
+
}
|
|
45
|
+
:host([show-ctrl-btn-month-add]) .btn.add.add.year, :host([show-ctrl-btn-month-sub]) .btn.add.sub.year {
|
|
46
|
+
--bg-img: var(--icon-arrow-right-double);
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
dt-yyyymmdd-list-grp {
|
|
50
|
+
width: 100%;
|
|
51
|
+
}
|
|
52
|
+
dt-yyyymmdd-list-grp::part(list) {
|
|
53
|
+
scroll-behavior: smooth;
|
|
54
|
+
}
|
|
55
|
+
dt-yyyymmdd-list-grp::part(col label) {
|
|
56
|
+
display: none;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
dt-popover {
|
|
60
|
+
width: 100%;
|
|
61
|
+
display: flex;
|
|
62
|
+
flex-direction: column;
|
|
63
|
+
align-items: center;
|
|
64
|
+
justify-content: center;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
.title-wrapper {
|
|
68
|
+
box-sizing: border-box;
|
|
69
|
+
display: flex;
|
|
70
|
+
align-items: center;
|
|
71
|
+
gap: 2px;
|
|
72
|
+
cursor: pointer;
|
|
73
|
+
margin: 10px 0;
|
|
74
|
+
min-height: 25px;
|
|
75
|
+
padding: 0 10px;
|
|
76
|
+
border-radius: 2px;
|
|
77
|
+
user-select: none;
|
|
78
|
+
}
|
|
79
|
+
.title-wrapper:hover {
|
|
80
|
+
background-color: #eee;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
.title-arrow {
|
|
84
|
+
display: inline-block;
|
|
85
|
+
width: 16px;
|
|
86
|
+
height: 16px;
|
|
87
|
+
background: url("@/assets/arrow-down.svg") no-repeat center center;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
dt-popover[open] .title-arrow {
|
|
91
|
+
transform: rotate(180deg);
|
|
92
|
+
}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import { type BaseAttrs, type Emit2EventMap, UiBase } from '../../components/web-component-base';
|
|
2
|
+
export interface Attrs extends BaseAttrs {
|
|
3
|
+
millisecond: number;
|
|
4
|
+
/**
|
|
5
|
+
* 选择器的粒度,表示最大可选的时间单位。默认为 year。
|
|
6
|
+
*/
|
|
7
|
+
'max-granularity'?: 'year' | 'month';
|
|
8
|
+
/**
|
|
9
|
+
* 选择器的粒度,表示最小可选的时间单位。默认为 month。
|
|
10
|
+
*/
|
|
11
|
+
'min-granularity'?: 'year' | 'month';
|
|
12
|
+
/**
|
|
13
|
+
* 是否显示年份控制按钮(快速增减年份)
|
|
14
|
+
* @default false
|
|
15
|
+
*/
|
|
16
|
+
'show-ctrl-btn-year-add'?: boolean;
|
|
17
|
+
'show-ctrl-btn-year-sub'?: boolean;
|
|
18
|
+
/**
|
|
19
|
+
* 是否显示月份控制按钮(快速增减月份)
|
|
20
|
+
* @default false
|
|
21
|
+
*/
|
|
22
|
+
'show-ctrl-btn-month-add'?: boolean;
|
|
23
|
+
'show-ctrl-btn-month-sub'?: boolean;
|
|
24
|
+
}
|
|
25
|
+
export interface Emits {
|
|
26
|
+
change: {
|
|
27
|
+
oldStartTime: Date;
|
|
28
|
+
oldEndTime: Date;
|
|
29
|
+
newStartTime: Date;
|
|
30
|
+
newEndTime: Date;
|
|
31
|
+
};
|
|
32
|
+
'popover-open-change': boolean;
|
|
33
|
+
}
|
|
34
|
+
export type EventMap = Emit2EventMap<Emits>;
|
|
35
|
+
/**
|
|
36
|
+
* 日期导航组件
|
|
37
|
+
*
|
|
38
|
+
* 存在一个 titleFormatter 方法,可以重写该方法以自定义年月标题的回显格式。
|
|
39
|
+
*/
|
|
40
|
+
export declare class Ele extends UiBase<Attrs, Emits> {
|
|
41
|
+
static readonly tagName: "dt-date-nav";
|
|
42
|
+
static get observedAttributes(): string[];
|
|
43
|
+
protected _style: string;
|
|
44
|
+
protected _template: string;
|
|
45
|
+
get millisecond(): number;
|
|
46
|
+
set millisecond(v: number);
|
|
47
|
+
get showCtrlBtnYearAdd(): boolean;
|
|
48
|
+
set showCtrlBtnYearAdd(val: boolean);
|
|
49
|
+
get showCtrlBtnYearSub(): boolean;
|
|
50
|
+
set showCtrlBtnYearSub(val: boolean);
|
|
51
|
+
get showCtrlBtnMonthAdd(): boolean;
|
|
52
|
+
set showCtrlBtnMonthAdd(val: boolean);
|
|
53
|
+
get showCtrlBtnMonthSub(): boolean;
|
|
54
|
+
set showCtrlBtnMonthSub(val: boolean);
|
|
55
|
+
constructor();
|
|
56
|
+
connectedCallback(): void;
|
|
57
|
+
disconnectedCallback(): void;
|
|
58
|
+
protected _onAttrChanged(name: string, oldValue: string, newValue: string): void;
|
|
59
|
+
private _render;
|
|
60
|
+
private _onTitleToggle;
|
|
61
|
+
private _onItemSelect;
|
|
62
|
+
private _onBtnClick;
|
|
63
|
+
titleFormatter: (ms: number) => string;
|
|
64
|
+
}
|
|
@@ -0,0 +1,161 @@
|
|
|
1
|
+
var __freeze = Object.freeze;
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
4
|
+
var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
5
|
+
var __template = (cooked, raw) => __freeze(__defProp(cooked, "raw", { value: __freeze(raw || cooked.slice()) }));
|
|
6
|
+
var _a, _b;
|
|
7
|
+
import {
|
|
8
|
+
UiBase
|
|
9
|
+
} from "../../components/web-component-base/index.mjs";
|
|
10
|
+
import { css, debounce, html } from "../../utils.mjs";
|
|
11
|
+
const styleStr = css(_a || (_a = __template(["\n.wrapper {\n display: block;\n width: 100%;\n height: 100%;\n display: flex;\n justify-content: space-between;\n overflow: hidden;\n}\n.wrapper.show-list .btns {\n display: none;\n}\n\n.btns {\n display: flex;\n align-items: center;\n}\n\n.btn {\n width: 25px;\n height: 25px;\n cursor: pointer;\n background: 50%/16px 16px no-repeat;\n --icon-arrow-left: url(\"data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='17' fill='currentColor'%3E%3Cpath d='M11.687 1.703a.5.5 0 0 0-.707 0L4.852 7.83a.505.505 0 0 0-.045.05.5.5 0 0 0-.051.752l6.128 6.128a.5.5 0 0 0 .707-.707L5.817 8.28l5.87-5.87a.5.5 0 0 0 0-.707Z'/%3E%3C/svg%3E\");\n --icon-arrow-left-double: url(\"data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='17' fill='currentColor'%3E%3Cpath d='M9.037 1.98a.5.5 0 1 1 .707.707l-5.87 5.87 5.774 5.774a.5.5 0 1 1-.707.707L2.813 8.911a.5.5 0 0 1 .051-.752.505.505 0 0 1 .045-.051L9.037 1.98ZM13.037 1.98a.5.5 0 0 1 .707.707l-5.87 5.87 5.774 5.774a.5.5 0 1 1-.707.707L6.813 8.911a.5.5 0 0 1 .051-.752.505.505 0 0 1 .045-.051l6.128-6.128Z'/%3E%3C/svg%3E\");\n --icon-arrow-right: url(\"data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='17' height='17' fill='currentColor'%3E%3Cpath d='M5.256 1.703a.5.5 0 0 1 .707 0l6.128 6.128a.493.493 0 0 1 .045.05.5.5 0 0 1 .051.752l-6.128 6.128a.5.5 0 0 1-.707-.707l5.774-5.774-5.87-5.87a.5.5 0 0 1 0-.707Z'/%3E%3C/svg%3E\");\n --icon-arrow-right-double: url(\"data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='17' height='17' fill='currentColor'%3E%3Cpath d='M7.963 1.703a.5.5 0 0 0-.707.707l5.87 5.87-5.774 5.774a.5.5 0 0 0 .707.707l6.128-6.128a.5.5 0 0 0-.051-.751.493.493 0 0 0-.045-.051L7.963 1.703ZM3.963 1.703a.5.5 0 0 0-.707.707l5.87 5.87-5.774 5.774a.5.5 0 0 0 .707.707l6.128-6.128a.5.5 0 0 0-.051-.751.493.493 0 0 0-.045-.051L3.963 1.703Z'/%3E%3C/svg%3E\");\n background-image: var(--bg-img);\n border-radius: 50%;\n}\n.btn:hover {\n background-color: #eee;\n}\n:host(:not([show-ctrl-btn-year-add])) .btn.add.year, :host(:not([show-ctrl-btn-year-sub])) .btn.sub.year, :host(:not([show-ctrl-btn-month-add])) .btn.add.month, :host(:not([show-ctrl-btn-month-sub])) .btn.sub.month {\n display: none;\n}\n.btn.sub {\n --bg-img: var(--icon-arrow-left);\n}\n:host([show-ctrl-btn-month-add]) .btn.sub.add.year, :host([show-ctrl-btn-month-sub]) .btn.sub.sub.year {\n --bg-img: var(--icon-arrow-left-double);\n}\n.btn.add {\n --bg-img: var(--icon-arrow-right);\n}\n:host([show-ctrl-btn-month-add]) .btn.add.add.year, :host([show-ctrl-btn-month-sub]) .btn.add.sub.year {\n --bg-img: var(--icon-arrow-right-double);\n}\n\ndt-yyyymmdd-list-grp {\n width: 100%;\n}\ndt-yyyymmdd-list-grp::part(list) {\n scroll-behavior: smooth;\n}\ndt-yyyymmdd-list-grp::part(col label) {\n display: none;\n}\n\ndt-popover {\n width: 100%;\n display: flex;\n flex-direction: column;\n align-items: center;\n justify-content: center;\n}\n\n.title-wrapper {\n box-sizing: border-box;\n display: flex;\n align-items: center;\n gap: 2px;\n cursor: pointer;\n margin: 10px 0;\n min-height: 25px;\n padding: 0 10px;\n border-radius: 2px;\n user-select: none;\n}\n.title-wrapper:hover {\n background-color: #eee;\n}\n\n.title-arrow {\n display: inline-block;\n width: 16px;\n height: 16px;\n background: url(\"data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='15' height='15' fill='currentColor'%3E%3Cpath d='m8.02 10.54 3.96-4.4a.583.583 0 0 0-.433-.973h-7.88a.583.583 0 0 0-.434.973l3.94 4.378c.216.24.585.26.824.044l.022-.021Z'/%3E%3C/svg%3E\") no-repeat center center;\n}\n\ndt-popover[open] .title-arrow {\n transform: rotate(180deg);\n}\n"])));
|
|
12
|
+
import { Ele as PopoverEle } from "../popover/index.mjs";
|
|
13
|
+
PopoverEle.define();
|
|
14
|
+
import {
|
|
15
|
+
Ele as YyyyMmDdListGrpEle
|
|
16
|
+
} from "../yyyymmdd-list-grp/index.mjs";
|
|
17
|
+
YyyyMmDdListGrpEle.define();
|
|
18
|
+
export class Ele extends UiBase {
|
|
19
|
+
constructor() {
|
|
20
|
+
super();
|
|
21
|
+
__publicField(this, "_style", styleStr);
|
|
22
|
+
__publicField(this, "_template", html(_b || (_b = __template(['\n<div class="wrapper">\n <div class="btns sub">\n <i class="btn sub year"></i>\n <i class="btn sub month"></i>\n </div>\n <dt-popover class="echo">\n <div slot="trigger" class="title-wrapper">\n <span class="title">title</span>\n <i class="title-arrow"></i>\n </div>\n <dt-yyyymmdd-list-grp slot="pop" min-granularity="month" part="list-grp"></dt-yyyymmdd-list-grp>\n </dt-popover>\n <div class="btns add">\n <i class="btn add month"></i>\n <i class="btn add year"></i>\n </div>\n</div>\n']))));
|
|
23
|
+
__publicField(this, "_render", debounce(() => {
|
|
24
|
+
const root = this.shadowRoot;
|
|
25
|
+
const ms = this.millisecond;
|
|
26
|
+
root.querySelector(
|
|
27
|
+
"dt-yyyymmdd-list-grp"
|
|
28
|
+
).millisecond = ms;
|
|
29
|
+
root.querySelector(".title").textContent = this.titleFormatter(ms);
|
|
30
|
+
}, 0));
|
|
31
|
+
__publicField(this, "_onTitleToggle", ({
|
|
32
|
+
detail: isOpen
|
|
33
|
+
}) => {
|
|
34
|
+
this.shadowRoot.querySelector(".wrapper").classList.toggle(
|
|
35
|
+
"show-list",
|
|
36
|
+
isOpen
|
|
37
|
+
);
|
|
38
|
+
this.shadowRoot.querySelector(
|
|
39
|
+
"dt-yyyymmdd-list-grp"
|
|
40
|
+
).scrollToCurrentItem();
|
|
41
|
+
this.dispatchEvent("popover-open-change", isOpen, true);
|
|
42
|
+
});
|
|
43
|
+
__publicField(this, "_onItemSelect", (e) => {
|
|
44
|
+
if (!(e.target instanceof YyyyMmDdListGrpEle)) return;
|
|
45
|
+
this.millisecond = e.target.millisecond;
|
|
46
|
+
});
|
|
47
|
+
__publicField(this, "_onBtnClick", (e) => {
|
|
48
|
+
if (!(e.target instanceof HTMLElement)) return;
|
|
49
|
+
const date = new Date(this.millisecond);
|
|
50
|
+
date.setDate(1);
|
|
51
|
+
if (e.target.matches(".add.year")) {
|
|
52
|
+
date.setFullYear(date.getFullYear() + 1);
|
|
53
|
+
} else if (e.target.matches(".sub.year")) {
|
|
54
|
+
date.setFullYear(date.getFullYear() - 1);
|
|
55
|
+
} else if (e.target.matches(".add.month")) {
|
|
56
|
+
date.setMonth(date.getMonth() + 1);
|
|
57
|
+
} else if (e.target.matches(".sub.month")) {
|
|
58
|
+
date.setMonth(date.getMonth() - 1);
|
|
59
|
+
}
|
|
60
|
+
this.millisecond = +date;
|
|
61
|
+
});
|
|
62
|
+
__publicField(this, "titleFormatter", (ms) => {
|
|
63
|
+
const date = new Date(ms);
|
|
64
|
+
const year = date.getFullYear();
|
|
65
|
+
const month = date.getMonth() + 1;
|
|
66
|
+
return "".concat(("0" + month).slice(-2), "/").concat(year);
|
|
67
|
+
});
|
|
68
|
+
this._applyTemplate();
|
|
69
|
+
}
|
|
70
|
+
static get observedAttributes() {
|
|
71
|
+
return [
|
|
72
|
+
...super.observedAttributes,
|
|
73
|
+
"millisecond",
|
|
74
|
+
"max-granularity",
|
|
75
|
+
"min-granularity",
|
|
76
|
+
"show-ctrl-btn-month-add",
|
|
77
|
+
"show-ctrl-btn-year-sub",
|
|
78
|
+
"show-ctrl-btn-month-add",
|
|
79
|
+
"show-ctrl-btn-month-sub"
|
|
80
|
+
];
|
|
81
|
+
}
|
|
82
|
+
get millisecond() {
|
|
83
|
+
return Math.floor(+this._getAttr("millisecond", "0"));
|
|
84
|
+
}
|
|
85
|
+
set millisecond(v) {
|
|
86
|
+
if (!Number.isSafeInteger(v)) return;
|
|
87
|
+
this.setAttribute("millisecond", "" + Math.floor(v));
|
|
88
|
+
}
|
|
89
|
+
get showCtrlBtnYearAdd() {
|
|
90
|
+
return this.hasAttribute("show-ctrl-btn-year-add");
|
|
91
|
+
}
|
|
92
|
+
set showCtrlBtnYearAdd(val) {
|
|
93
|
+
this.toggleAttribute("show-ctrl-btn-year-add", val);
|
|
94
|
+
}
|
|
95
|
+
get showCtrlBtnYearSub() {
|
|
96
|
+
return this.hasAttribute("show-ctrl-btn-year-sub");
|
|
97
|
+
}
|
|
98
|
+
set showCtrlBtnYearSub(val) {
|
|
99
|
+
this.toggleAttribute("show-ctrl-btn-year-sub", val);
|
|
100
|
+
}
|
|
101
|
+
get showCtrlBtnMonthAdd() {
|
|
102
|
+
return this.hasAttribute("show-ctrl-btn-month-add");
|
|
103
|
+
}
|
|
104
|
+
set showCtrlBtnMonthAdd(val) {
|
|
105
|
+
this.toggleAttribute("show-ctrl-btn-month-add", val);
|
|
106
|
+
}
|
|
107
|
+
get showCtrlBtnMonthSub() {
|
|
108
|
+
return this.hasAttribute("show-ctrl-btn-month-sub");
|
|
109
|
+
}
|
|
110
|
+
set showCtrlBtnMonthSub(val) {
|
|
111
|
+
this.toggleAttribute("show-ctrl-btn-month-sub", val);
|
|
112
|
+
}
|
|
113
|
+
connectedCallback() {
|
|
114
|
+
if (!super.connectedCallback()) return;
|
|
115
|
+
this._render();
|
|
116
|
+
this.shadowRoot.querySelector(".echo").addEventListener(
|
|
117
|
+
"open-change",
|
|
118
|
+
this._onTitleToggle
|
|
119
|
+
);
|
|
120
|
+
this.shadowRoot.querySelector(
|
|
121
|
+
"dt-yyyymmdd-list-grp"
|
|
122
|
+
).addEventListener("change", this._onItemSelect);
|
|
123
|
+
this.shadowRoot.querySelectorAll(".btn").forEach(
|
|
124
|
+
(btn) => {
|
|
125
|
+
btn.addEventListener("click", this._onBtnClick);
|
|
126
|
+
}
|
|
127
|
+
);
|
|
128
|
+
}
|
|
129
|
+
disconnectedCallback() {
|
|
130
|
+
if (!super.disconnectedCallback()) return;
|
|
131
|
+
this.shadowRoot.querySelector(
|
|
132
|
+
".echo"
|
|
133
|
+
).removeEventListener("open-change", this._onTitleToggle);
|
|
134
|
+
this.shadowRoot.querySelector(
|
|
135
|
+
"dt-yyyymmdd-list-grp"
|
|
136
|
+
).removeEventListener("change", this._onItemSelect);
|
|
137
|
+
this.shadowRoot.querySelectorAll(".btn").forEach(
|
|
138
|
+
(btn) => {
|
|
139
|
+
btn.removeEventListener("click", this._onBtnClick);
|
|
140
|
+
}
|
|
141
|
+
);
|
|
142
|
+
}
|
|
143
|
+
_onAttrChanged(name, oldValue, newValue) {
|
|
144
|
+
super._onAttrChanged(name, oldValue, newValue);
|
|
145
|
+
this._render();
|
|
146
|
+
if (name === "millisecond") {
|
|
147
|
+
this.dispatchEvent(
|
|
148
|
+
"change",
|
|
149
|
+
{
|
|
150
|
+
oldStartTime: /* @__PURE__ */ new Date(+oldValue),
|
|
151
|
+
oldEndTime: /* @__PURE__ */ new Date(+oldValue),
|
|
152
|
+
newStartTime: /* @__PURE__ */ new Date(+newValue),
|
|
153
|
+
newEndTime: /* @__PURE__ */ new Date(+newValue)
|
|
154
|
+
},
|
|
155
|
+
true
|
|
156
|
+
);
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
__publicField(Ele, "tagName", "dt-date-nav");
|
|
161
|
+
Ele.define();
|
|
@@ -0,0 +1,152 @@
|
|
|
1
|
+
:host {
|
|
2
|
+
display: flex;
|
|
3
|
+
flex-direction: column;
|
|
4
|
+
gap: 15px;
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
.date-echo {
|
|
8
|
+
display: flex;
|
|
9
|
+
gap: 5px;
|
|
10
|
+
align-items: center;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
.start-date-echo-wrapper,
|
|
14
|
+
.end-date-echo-wrapper {
|
|
15
|
+
width: 100%;
|
|
16
|
+
flex: 1;
|
|
17
|
+
display: flex;
|
|
18
|
+
flex-direction: column;
|
|
19
|
+
gap: 2px;
|
|
20
|
+
border-radius: 6px;
|
|
21
|
+
border: 1px solid rgba(0, 0, 0, 0.1490196078);
|
|
22
|
+
padding: 4px;
|
|
23
|
+
}
|
|
24
|
+
.start-date-echo-wrapper.active,
|
|
25
|
+
.end-date-echo-wrapper.active {
|
|
26
|
+
border-color: #333;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
.date-echo .label {
|
|
30
|
+
font-size: 14px;
|
|
31
|
+
line-height: 1;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
.start-date-echo, .end-date-echo {
|
|
35
|
+
font-size: 16px;
|
|
36
|
+
line-height: 1;
|
|
37
|
+
font-weight: bold;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
.dividing-line {
|
|
41
|
+
display: block;
|
|
42
|
+
height: 1px;
|
|
43
|
+
width: 20px;
|
|
44
|
+
background-color: #eee;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
dt-date-nav::part(list-grp) {
|
|
48
|
+
height: 254px;
|
|
49
|
+
margin-top: 15px;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
dt-calendar-base.hide {
|
|
53
|
+
display: none;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
.calendars {
|
|
57
|
+
display: flex;
|
|
58
|
+
gap: 20px;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
.wrapper {
|
|
62
|
+
flex: 1;
|
|
63
|
+
height: 100%;
|
|
64
|
+
display: flex;
|
|
65
|
+
flex-direction: column;
|
|
66
|
+
gap: 15px;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
dt-popover {
|
|
70
|
+
position: relative;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
[open] .time-echo-wrapper {
|
|
74
|
+
border-color: #18181B;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
.time-echo-wrapper {
|
|
78
|
+
width: 100%;
|
|
79
|
+
padding: 4px;
|
|
80
|
+
display: flex;
|
|
81
|
+
gap: 5px;
|
|
82
|
+
border-radius: 4px;
|
|
83
|
+
min-height: 30px;
|
|
84
|
+
border: 1px solid rgba(0, 0, 0, 0.0666666667);
|
|
85
|
+
box-sizing: border-box;
|
|
86
|
+
align-items: center;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
.time-selector {
|
|
90
|
+
position: absolute;
|
|
91
|
+
width: 100%;
|
|
92
|
+
height: 461px;
|
|
93
|
+
box-sizing: border-box;
|
|
94
|
+
background-color: #fff;
|
|
95
|
+
display: flex;
|
|
96
|
+
flex-direction: column;
|
|
97
|
+
gap: 15px;
|
|
98
|
+
padding: 15px;
|
|
99
|
+
border-radius: 6px;
|
|
100
|
+
border: 1px solid #eee;
|
|
101
|
+
box-shadow: 0 6px 16px rgba(0, 0, 0, 0.2);
|
|
102
|
+
}
|
|
103
|
+
.time-selector .title {
|
|
104
|
+
font-size: 16px;
|
|
105
|
+
margin: 0;
|
|
106
|
+
line-height: 1;
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
dt-hhmmss-ms-list-grp::part(list-container) {
|
|
110
|
+
gap: 2px;
|
|
111
|
+
}
|
|
112
|
+
dt-hhmmss-ms-list-grp::part(list) {
|
|
113
|
+
scroll-behavior: smooth;
|
|
114
|
+
}
|
|
115
|
+
dt-hhmmss-ms-list-grp::part(item) {
|
|
116
|
+
font-size: 14px;
|
|
117
|
+
line-height: 17px;
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
#time-selector-done-btn {
|
|
121
|
+
border: none;
|
|
122
|
+
min-height: 30px;
|
|
123
|
+
border-radius: 6px;
|
|
124
|
+
padding: 5px 10px;
|
|
125
|
+
font-size: 14px;
|
|
126
|
+
background-color: #18181B;
|
|
127
|
+
color: #fff;
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
.time-icon {
|
|
131
|
+
display: inline-block;
|
|
132
|
+
width: 20px;
|
|
133
|
+
height: 20px;
|
|
134
|
+
background: url("@/assets/time.svg") 50%/20px 20px no-repeat;
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
.time-echo {
|
|
138
|
+
font-size: 14px;
|
|
139
|
+
color: #999;
|
|
140
|
+
line-height: 1;
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
dt-calendar-base {
|
|
144
|
+
height: 254px;
|
|
145
|
+
}
|
|
146
|
+
dt-calendar-base::part(week) {
|
|
147
|
+
font-size: 12px;
|
|
148
|
+
line-height: 14px;
|
|
149
|
+
}
|
|
150
|
+
dt-calendar-base::part(item) {
|
|
151
|
+
font-size: 14px;
|
|
152
|
+
}
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import { type BaseAttrs, UiBase } from '../web-component-base';
|
|
2
|
+
export interface Attrs extends BaseAttrs {
|
|
3
|
+
/**
|
|
4
|
+
* The start time of the calendar display range.
|
|
5
|
+
* @type {`string | number`} A value that can be passed to the Date constructor.
|
|
6
|
+
* @default Date.now()
|
|
7
|
+
*/
|
|
8
|
+
'time-start'?: string | number;
|
|
9
|
+
/**
|
|
10
|
+
* The end time of the calendar display range.
|
|
11
|
+
* @type {`string | number`} A value that can be passed to the Date constructor.
|
|
12
|
+
* @default 'time-start'
|
|
13
|
+
*/
|
|
14
|
+
'time-end': string | number;
|
|
15
|
+
/**
|
|
16
|
+
* 选择器的粒度,表示最小可选的时间单位。默认为 millisecond。
|
|
17
|
+
* 例如设置为 'minute',则表示只能选择到分钟,秒和毫秒将被忽略。
|
|
18
|
+
*/
|
|
19
|
+
'min-granularity'?: 'day' | 'hour' | 'minute' | 'second' | 'millisecond';
|
|
20
|
+
}
|
|
21
|
+
export interface Emits {
|
|
22
|
+
change: {
|
|
23
|
+
oldStartTime: Date;
|
|
24
|
+
oldEndTime: Date;
|
|
25
|
+
newStartTime: Date;
|
|
26
|
+
newEndTime: Date;
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* 时间段选择器(两个日历)
|
|
31
|
+
*
|
|
32
|
+
* 存在一个 timeFormatter 方法,可以重写该方法以自定义时分秒毫秒的回显格式。
|
|
33
|
+
*/
|
|
34
|
+
export declare class Ele extends UiBase<Attrs, Emits> {
|
|
35
|
+
static readonly tagName: "dt-period-selector";
|
|
36
|
+
static get observedAttributes(): string[];
|
|
37
|
+
get timeStart(): number | string | Date;
|
|
38
|
+
set timeStart(val: number | string | Date);
|
|
39
|
+
get timeEnd(): number | string | Date;
|
|
40
|
+
set timeEnd(val: number | string | Date);
|
|
41
|
+
protected _style: string;
|
|
42
|
+
protected _template: string;
|
|
43
|
+
constructor();
|
|
44
|
+
private get _startNavEle();
|
|
45
|
+
private get _endNavEle();
|
|
46
|
+
private get _startCalendar();
|
|
47
|
+
private get _endCalendar();
|
|
48
|
+
private get _startTimeSelector();
|
|
49
|
+
private get _endTimeSelector();
|
|
50
|
+
private get _startTimePopover();
|
|
51
|
+
private get _endTimePopover();
|
|
52
|
+
private _selectedDate;
|
|
53
|
+
connectedCallback(): void;
|
|
54
|
+
disconnectedCallback(): void;
|
|
55
|
+
protected _onAttrChanged(name: string, oldValue: string, newValue: string): void;
|
|
56
|
+
private _updateNavCtrlBtn;
|
|
57
|
+
private _render;
|
|
58
|
+
private _updateDateEcho;
|
|
59
|
+
private _onCalendarSelect;
|
|
60
|
+
private _onCalendarItemHover;
|
|
61
|
+
private _onNavChange;
|
|
62
|
+
private _onNavOpenToggle;
|
|
63
|
+
private _onTimePopoverOpenChange;
|
|
64
|
+
private _onTimeSelectorDoneClick;
|
|
65
|
+
showCalendarDatePoint(): void;
|
|
66
|
+
timeFormatter: (time: Date) => string;
|
|
67
|
+
dateFormatter: (time: Date) => string;
|
|
68
|
+
}
|