@gez/date-time-kit 2.0.0-alpha.0 → 2.0.0-alpha.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/dist/components/calendar/index.d.ts +1 -1
- package/dist/components/calendar/index.mjs +1 -1
- package/dist/components/date-time-selector/index.d.ts +53 -0
- package/dist/components/date-time-selector/index.mjs +180 -0
- package/dist/components/date-time-selector/styleStr.d.ts +1 -0
- package/dist/components/date-time-selector/styleStr.mjs +6 -0
- package/dist/components/period-selector/index.css +2 -1
- package/dist/components/period-selector/index.d.ts +9 -0
- package/dist/components/period-selector/index.mjs +31 -12
- package/dist/components/quick-selector/index.d.ts +14 -2
- package/dist/components/quick-selector/index.mjs +89 -57
- package/dist/components/{period-selector/date-nav.d.ts → yyyymm-nav/index.d.ts} +4 -6
- package/dist/components/{period-selector/date-nav.mjs → yyyymm-nav/index.mjs} +9 -10
- package/dist/components/yyyymmdd-list-grp/index.mjs +6 -6
- package/dist/index.d.ts +1 -0
- package/dist/index.mjs +2 -0
- package/package.json +2 -2
- package/src/components/calendar/index.ts +2 -2
- package/src/components/date-time-selector/index.ts +239 -0
- package/src/components/date-time-selector/styleStr.ts +86 -0
- package/src/components/period-selector/index.scss +3 -2
- package/src/components/period-selector/index.ts +45 -16
- package/src/components/quick-selector/index.ts +102 -57
- package/src/components/{period-selector/date-nav.ts → yyyymm-nav/index.ts} +12 -15
- package/src/components/yyyymmdd-list-grp/index.ts +35 -2
- package/src/index.ts +1 -0
- /package/dist/components/{period-selector/date-nav.css → yyyymm-nav/index.css} +0 -0
- /package/src/components/{period-selector/date-nav.scss → yyyymm-nav/index.scss} +0 -0
|
@@ -12,7 +12,7 @@ export interface Attrs extends BaseAttrs {
|
|
|
12
12
|
/**
|
|
13
13
|
* The start time of the calendar display range.
|
|
14
14
|
* @type {`string | number`} A value that can be passed to the Date constructor.
|
|
15
|
-
* @default '
|
|
15
|
+
* @default 'showing-time'
|
|
16
16
|
*/
|
|
17
17
|
'time-start'?: string | number;
|
|
18
18
|
/**
|
|
@@ -191,7 +191,7 @@ export class Ele extends UiBase {
|
|
|
191
191
|
return this._getAttr("week-start-at", "sun");
|
|
192
192
|
}
|
|
193
193
|
set weekStartAt(val) {
|
|
194
|
-
if (weekKey.includes(val)) return;
|
|
194
|
+
if (!weekKey.includes(val)) return;
|
|
195
195
|
this.setAttribute("week-start-at", val);
|
|
196
196
|
}
|
|
197
197
|
get showOtherMonth() {
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { type BaseAttrs, type Emit2EventMap, UiBase } from '../web-component-base';
|
|
2
|
+
import { type Weeks } from '../calendar';
|
|
3
|
+
export interface Attrs extends BaseAttrs {
|
|
4
|
+
/**
|
|
5
|
+
* Set which day of the week is the first day.
|
|
6
|
+
* @type `'sun' | 'mon' | 'tue' | 'wed' | 'thu' | 'fri' | 'sat'`
|
|
7
|
+
* @default 'sun'
|
|
8
|
+
*/
|
|
9
|
+
'week-start-at'?: Weeks;
|
|
10
|
+
/**
|
|
11
|
+
* The time of the calendar.
|
|
12
|
+
* @type {`string | number`} A value that can be passed to the Date constructor.
|
|
13
|
+
* @default Date.now()
|
|
14
|
+
*/
|
|
15
|
+
'current-time'?: string | number;
|
|
16
|
+
/**
|
|
17
|
+
* The showing time, used to determine the month to show on calendar.
|
|
18
|
+
* @type {`string | number`} A value that can be passed to the Date constructor.
|
|
19
|
+
* @default 'current-time'
|
|
20
|
+
*/
|
|
21
|
+
'showing-time'?: string | number;
|
|
22
|
+
}
|
|
23
|
+
export interface Emits {
|
|
24
|
+
'select-time': Date;
|
|
25
|
+
}
|
|
26
|
+
export type EventMap = Emit2EventMap<Emits>;
|
|
27
|
+
export declare class Ele extends UiBase<Attrs, Emits> {
|
|
28
|
+
static readonly tagName: "dt-date-time-selector";
|
|
29
|
+
static get observedAttributes(): string[];
|
|
30
|
+
get currentTime(): number | string | Date;
|
|
31
|
+
set currentTime(val: number | string | Date);
|
|
32
|
+
get showingTime(): number | string | Date;
|
|
33
|
+
set showingTime(val: number | string | Date);
|
|
34
|
+
get weekStartAt(): Weeks;
|
|
35
|
+
set weekStartAt(val: Weeks);
|
|
36
|
+
protected _style: string;
|
|
37
|
+
protected _template: string;
|
|
38
|
+
private get _navEle();
|
|
39
|
+
private get _calendar();
|
|
40
|
+
private get _timeSelector();
|
|
41
|
+
private get _timePopover();
|
|
42
|
+
constructor();
|
|
43
|
+
connectedCallback(): void;
|
|
44
|
+
disconnectedCallback(): void;
|
|
45
|
+
protected _onAttrChanged(name: string, oldValue: string, newValue: string): void;
|
|
46
|
+
private _render;
|
|
47
|
+
private _onCalendarSelect;
|
|
48
|
+
private _onNavChange;
|
|
49
|
+
private _onTimePopoverOpenChange;
|
|
50
|
+
private _onNavOpenToggle;
|
|
51
|
+
private _onTimeSelectorDoneClick;
|
|
52
|
+
timeFormatter: (time: Date) => string;
|
|
53
|
+
}
|
|
@@ -0,0 +1,180 @@
|
|
|
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;
|
|
7
|
+
import { closestByEvent, debounce, html } from "../../utils.mjs";
|
|
8
|
+
import {
|
|
9
|
+
UiBase
|
|
10
|
+
} from "../web-component-base/index.mjs";
|
|
11
|
+
import {
|
|
12
|
+
Ele as YyyyMmNavEle
|
|
13
|
+
} from "../yyyymm-nav/index.mjs";
|
|
14
|
+
import { styleStr } from "./styleStr.mjs";
|
|
15
|
+
YyyyMmNavEle.define();
|
|
16
|
+
import {
|
|
17
|
+
Ele as CalendarBaseEle,
|
|
18
|
+
weekKey
|
|
19
|
+
} from "../calendar/index.mjs";
|
|
20
|
+
CalendarBaseEle.define();
|
|
21
|
+
import { Ele as HhMmSsMsListGrpEle } from "../hhmmss-ms-list-grp/index.mjs";
|
|
22
|
+
HhMmSsMsListGrpEle.define();
|
|
23
|
+
import { Ele as PopoverEle } from "../popover/index.mjs";
|
|
24
|
+
PopoverEle.define();
|
|
25
|
+
export class Ele extends UiBase {
|
|
26
|
+
constructor() {
|
|
27
|
+
super();
|
|
28
|
+
__publicField(this, "_style", styleStr);
|
|
29
|
+
__publicField(this, "_template", html(_a || (_a = __template(['\n<div class="wrapper">\n <dt-yyyymm-nav\n show-ctrl-btn-month-add\n show-ctrl-btn-month-sub\n ></dt-yyyymm-nav>\n <dt-calendar-base></dt-calendar-base>\n <dt-popover>\n <div slot="trigger" class="time-echo-wrapper">\n <i class="time-icon"></i>\n <span class="time-echo">hh:mm:ss.sss</span>\n </div>\n <div slot="pop" class="time-selector">\n <h3 class="title">Select Time</h3>\n <dt-hhmmss-ms-list-grp></dt-hhmmss-ms-list-grp>\n <button id="time-selector-done-btn">Done</button>\n </div>\n </dt-popover>\n</div>\n']))));
|
|
30
|
+
__publicField(this, "_render", debounce(() => {
|
|
31
|
+
if (!this.isConnected) return;
|
|
32
|
+
const currentTime = this.currentTime;
|
|
33
|
+
this._calendar.weekStartAt = this.weekStartAt;
|
|
34
|
+
const tz = (/* @__PURE__ */ new Date()).getTimezoneOffset() * 60 * 1e3;
|
|
35
|
+
this._navEle.millisecond = this._calendar.timeStart = this._calendar.timeEnd = +currentTime;
|
|
36
|
+
this._calendar.showingTime = this.showingTime;
|
|
37
|
+
this._timeSelector.millisecond = (+currentTime - tz) % (24 * 60 * 60 * 1e3);
|
|
38
|
+
this.shadowRoot.querySelector(".wrapper .time-echo").textContent = this.timeFormatter(currentTime);
|
|
39
|
+
}, 0));
|
|
40
|
+
__publicField(this, "_onCalendarSelect", (e) => {
|
|
41
|
+
e.stopPropagation();
|
|
42
|
+
this.currentTime = +e.detail + this._timeSelector.millisecond;
|
|
43
|
+
});
|
|
44
|
+
__publicField(this, "_onNavChange", (e) => {
|
|
45
|
+
e.stopPropagation();
|
|
46
|
+
const wrapper = closestByEvent(e, ".wrapper");
|
|
47
|
+
if (!wrapper) return;
|
|
48
|
+
const { newTime } = e.detail;
|
|
49
|
+
this._calendar.showingTime = +newTime;
|
|
50
|
+
});
|
|
51
|
+
__publicField(this, "_onTimePopoverOpenChange", (e) => {
|
|
52
|
+
var _a2;
|
|
53
|
+
if (!(e.target instanceof PopoverEle)) return;
|
|
54
|
+
e.stopPropagation();
|
|
55
|
+
if (!e.detail) return this._render();
|
|
56
|
+
(_a2 = e.target.querySelector("dt-hhmmss-ms-list-grp")) == null ? void 0 : _a2.scrollToCurrentItem();
|
|
57
|
+
});
|
|
58
|
+
__publicField(this, "_onNavOpenToggle", (e) => {
|
|
59
|
+
var _a2;
|
|
60
|
+
if (!(e.target instanceof YyyyMmNavEle)) return;
|
|
61
|
+
e.stopPropagation();
|
|
62
|
+
(_a2 = e.target.nextElementSibling) == null ? void 0 : _a2.classList.toggle("hide", e.detail);
|
|
63
|
+
});
|
|
64
|
+
__publicField(this, "_onTimeSelectorDoneClick", (e) => {
|
|
65
|
+
const btn = closestByEvent(e, "#time-selector-done-btn");
|
|
66
|
+
if (!btn) return;
|
|
67
|
+
const type = btn.dataset.type;
|
|
68
|
+
const calcTime = (time, ms) => {
|
|
69
|
+
time.setHours(0, 0, 0, 0);
|
|
70
|
+
time.setMilliseconds(ms);
|
|
71
|
+
return time;
|
|
72
|
+
};
|
|
73
|
+
this.currentTime = calcTime(
|
|
74
|
+
this.currentTime,
|
|
75
|
+
this._timeSelector.millisecond
|
|
76
|
+
);
|
|
77
|
+
this._timePopover.open = false;
|
|
78
|
+
});
|
|
79
|
+
__publicField(this, "timeFormatter", (time) => new Date(+time - (/* @__PURE__ */ new Date()).getTimezoneOffset() * 60 * 1e3).toISOString().slice(11, 23));
|
|
80
|
+
this._applyTemplate();
|
|
81
|
+
}
|
|
82
|
+
static get observedAttributes() {
|
|
83
|
+
return [
|
|
84
|
+
...super.observedAttributes,
|
|
85
|
+
"week-start-at",
|
|
86
|
+
"current-time",
|
|
87
|
+
"showing-time"
|
|
88
|
+
];
|
|
89
|
+
}
|
|
90
|
+
get currentTime() {
|
|
91
|
+
const v = this._getAttr("current-time", "" + Date.now());
|
|
92
|
+
return new Date(Number.isNaN(+v) ? v : +v);
|
|
93
|
+
}
|
|
94
|
+
set currentTime(val) {
|
|
95
|
+
const v = new Date(val);
|
|
96
|
+
if (Number.isNaN(+v)) return;
|
|
97
|
+
this.setAttribute("current-time", +v + "");
|
|
98
|
+
}
|
|
99
|
+
get showingTime() {
|
|
100
|
+
const v = this._getAttr("showing-time", "" + this.currentTime);
|
|
101
|
+
return new Date(Number.isNaN(+v) ? v : +v);
|
|
102
|
+
}
|
|
103
|
+
set showingTime(val) {
|
|
104
|
+
const v = new Date(val);
|
|
105
|
+
if (Number.isNaN(+v)) return;
|
|
106
|
+
this.setAttribute("showing-time", +v + "");
|
|
107
|
+
}
|
|
108
|
+
get weekStartAt() {
|
|
109
|
+
return this._getAttr("week-start-at", "sun");
|
|
110
|
+
}
|
|
111
|
+
set weekStartAt(val) {
|
|
112
|
+
if (!weekKey.includes(val)) return;
|
|
113
|
+
this.setAttribute("week-start-at", val);
|
|
114
|
+
}
|
|
115
|
+
get _navEle() {
|
|
116
|
+
var _a2;
|
|
117
|
+
return (_a2 = this.shadowRoot) == null ? void 0 : _a2.querySelector("dt-yyyymm-nav");
|
|
118
|
+
}
|
|
119
|
+
get _calendar() {
|
|
120
|
+
var _a2;
|
|
121
|
+
return (_a2 = this.shadowRoot) == null ? void 0 : _a2.querySelector(
|
|
122
|
+
"dt-calendar-base"
|
|
123
|
+
);
|
|
124
|
+
}
|
|
125
|
+
get _timeSelector() {
|
|
126
|
+
var _a2;
|
|
127
|
+
return (_a2 = this.shadowRoot) == null ? void 0 : _a2.querySelector(
|
|
128
|
+
"dt-hhmmss-ms-list-grp"
|
|
129
|
+
);
|
|
130
|
+
}
|
|
131
|
+
get _timePopover() {
|
|
132
|
+
var _a2;
|
|
133
|
+
return (_a2 = this.shadowRoot) == null ? void 0 : _a2.querySelector("dt-popover");
|
|
134
|
+
}
|
|
135
|
+
connectedCallback() {
|
|
136
|
+
var _a2;
|
|
137
|
+
if (!super.connectedCallback()) return;
|
|
138
|
+
this._calendar.formatter = (i) => String(i).padStart(2, "0");
|
|
139
|
+
this._render();
|
|
140
|
+
this._calendar.addEventListener("select-time", this._onCalendarSelect);
|
|
141
|
+
this._navEle.addEventListener("change", this._onNavChange);
|
|
142
|
+
this._timePopover.addEventListener(
|
|
143
|
+
"open-change",
|
|
144
|
+
this._onTimePopoverOpenChange
|
|
145
|
+
);
|
|
146
|
+
this._navEle.addEventListener(
|
|
147
|
+
"popover-open-change",
|
|
148
|
+
this._onNavOpenToggle
|
|
149
|
+
);
|
|
150
|
+
(_a2 = this.shadowRoot) == null ? void 0 : _a2.querySelectorAll("#time-selector-done-btn").forEach((btn) => {
|
|
151
|
+
btn.addEventListener("click", this._onTimeSelectorDoneClick);
|
|
152
|
+
});
|
|
153
|
+
}
|
|
154
|
+
disconnectedCallback() {
|
|
155
|
+
var _a2;
|
|
156
|
+
if (!super.disconnectedCallback()) return;
|
|
157
|
+
this._calendar.removeEventListener(
|
|
158
|
+
"select-time",
|
|
159
|
+
this._onCalendarSelect
|
|
160
|
+
);
|
|
161
|
+
this._navEle.removeEventListener("change", this._onNavChange);
|
|
162
|
+
this._timePopover.removeEventListener(
|
|
163
|
+
"open-change",
|
|
164
|
+
this._onTimePopoverOpenChange
|
|
165
|
+
);
|
|
166
|
+
this._navEle.removeEventListener(
|
|
167
|
+
"popover-open-change",
|
|
168
|
+
this._onNavOpenToggle
|
|
169
|
+
);
|
|
170
|
+
(_a2 = this.shadowRoot) == null ? void 0 : _a2.querySelectorAll("#time-selector-done-btn").forEach((btn) => {
|
|
171
|
+
btn.removeEventListener("click", this._onTimeSelectorDoneClick);
|
|
172
|
+
});
|
|
173
|
+
}
|
|
174
|
+
_onAttrChanged(name, oldValue, newValue) {
|
|
175
|
+
super._onAttrChanged(name, oldValue, newValue);
|
|
176
|
+
this._render();
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
__publicField(Ele, "tagName", "dt-date-time-selector");
|
|
180
|
+
Ele.define();
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const styleStr: string;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
var __freeze = Object.freeze;
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __template = (cooked, raw) => __freeze(__defProp(cooked, "raw", { value: __freeze(raw || cooked.slice()) }));
|
|
4
|
+
var _a;
|
|
5
|
+
import { css } from "../../utils.mjs";
|
|
6
|
+
export const styleStr = css(_a || (_a = __template(["\n.wrapper {\n display: flex;\n flex-direction: column;\n gap: 15px;\n}\ndt-popover {\n position: relative;\n}\n\n[open] .time-echo-wrapper {\n border-color: #18181B;\n}\n\n.time-echo-wrapper {\n width: 100%;\n padding: 4px;\n display: flex;\n gap: 5px;\n border-radius: 4px;\n min-height: 30px;\n border: 1px solid #0001;\n box-sizing: border-box;\n align-items: center;\n cursor: pointer;\n}\n\n.time-selector {\n position: absolute;\n width: 100%;\n height: 461px;\n box-sizing: border-box;\n background-color: #fff;\n\n display: flex;\n flex-direction: column;\n gap: 15px;\n padding: 15px;\n border-radius: 6px;\n border: 1px solid #eee;\n box-shadow: 0 6px 16px rgba(0, 0, 0, 0.2);\n\n .title {\n font-size: 16px;\n margin: 0;\n line-height: 1;\n }\n}\n\ndt-hhmmss-ms-list-grp::part(list-container) {\n gap: 2px;\n}\ndt-hhmmss-ms-list-grp::part(list) {\n scroll-behavior: smooth;\n}\ndt-hhmmss-ms-list-grp::part(item) {\n font-size: 14px;\n line-height: 17px;\n}\n\n#time-selector-done-btn {\n border: none;\n min-height: 30px;\n border-radius: 6px;\n padding: 5px 10px;\n font-size: 14px;\n background-color: #18181B;\n color: #fff;\n}\n\n.time-icon {\n display: inline-block;\n width: 20px;\n height: 20px;\n background: url(\"data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='15' fill='currentColor'%3E%3Cpath d='M7.4335 4.241a.4376.4376 0 0 0-.871.0594v3.783l.0044.0622a.4375.4375 0 0 0 .1921.3029L8.9242 9.877l.0566.0317a.4376.4376 0 0 0 .5495-.1559l.0317-.0566a.4376.4376 0 0 0-.1559-.5495L7.4375 7.8471V4.3004l-.004-.0593ZM7 1.6667c-3.2217 0-5.8333 2.6116-5.8333 5.8333 0 3.2217 2.6116 5.8333 5.8333 5.8333 3.2217 0 5.8333-2.6116 5.8333-5.8333 0-3.2217-2.6116-5.8333-5.8333-5.8333Zm0 .814c2.7721 0 5.0194 2.2472 5.0194 5.0193 0 2.7721-2.2473 5.0194-5.0194 5.0194S1.9806 10.2721 1.9806 7.5 4.228 2.4806 7 2.4806Z'/%3E%3C/svg%3E\") 50%/20px 20px no-repeat;\n}\n\n.time-echo {\n font-size: 14px;\n color: #999;\n line-height: 1;\n}\n\n"])));
|
|
@@ -44,7 +44,7 @@
|
|
|
44
44
|
background-color: #eee;
|
|
45
45
|
}
|
|
46
46
|
|
|
47
|
-
dt-
|
|
47
|
+
dt-yyyymm-nav::part(list-grp) {
|
|
48
48
|
height: 254px;
|
|
49
49
|
margin-top: 15px;
|
|
50
50
|
}
|
|
@@ -84,6 +84,7 @@ dt-popover {
|
|
|
84
84
|
border: 1px solid rgba(0, 0, 0, 0.0666666667);
|
|
85
85
|
box-sizing: border-box;
|
|
86
86
|
align-items: center;
|
|
87
|
+
cursor: pointer;
|
|
87
88
|
}
|
|
88
89
|
|
|
89
90
|
.time-selector {
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { type BaseAttrs, UiBase } from '../web-component-base';
|
|
2
|
+
import { type Weeks } from '../calendar';
|
|
2
3
|
export interface Attrs extends BaseAttrs {
|
|
3
4
|
/**
|
|
4
5
|
* The start time of the calendar display range.
|
|
@@ -17,6 +18,12 @@ export interface Attrs extends BaseAttrs {
|
|
|
17
18
|
* 例如设置为 'minute',则表示只能选择到分钟,秒和毫秒将被忽略。
|
|
18
19
|
*/
|
|
19
20
|
'min-granularity'?: 'day' | 'hour' | 'minute' | 'second' | 'millisecond';
|
|
21
|
+
/**
|
|
22
|
+
* Set which day of the week is the first day.
|
|
23
|
+
* @type `'sun' | 'mon' | 'tue' | 'wed' | 'thu' | 'fri' | 'sat'`
|
|
24
|
+
* @default 'sun'
|
|
25
|
+
*/
|
|
26
|
+
'week-start-at'?: Weeks;
|
|
20
27
|
}
|
|
21
28
|
export interface Emits {
|
|
22
29
|
change: {
|
|
@@ -38,6 +45,8 @@ export declare class Ele extends UiBase<Attrs, Emits> {
|
|
|
38
45
|
set timeStart(val: number | string | Date);
|
|
39
46
|
get timeEnd(): number | string | Date;
|
|
40
47
|
set timeEnd(val: number | string | Date);
|
|
48
|
+
get weekStartAt(): Weeks;
|
|
49
|
+
set weekStartAt(val: Weeks);
|
|
41
50
|
protected _style: string;
|
|
42
51
|
protected _template: string;
|
|
43
52
|
constructor();
|
|
@@ -6,11 +6,14 @@ var __template = (cooked, raw) => __freeze(__defProp(cooked, "raw", { value: __f
|
|
|
6
6
|
var _a, _b, _c;
|
|
7
7
|
import { closestByEvent, css, debounce, html } from "../../utils.mjs";
|
|
8
8
|
import { UiBase } from "../web-component-base/index.mjs";
|
|
9
|
-
const styleStr = css(_a || (_a = __template(["\n:host {\n display: flex;\n flex-direction: column;\n gap: 15px;\n}\n\n.date-echo {\n display: flex;\n gap: 5px;\n align-items: center;\n}\n\n.start-date-echo-wrapper,\n.end-date-echo-wrapper {\n width: 100%;\n flex: 1;\n display: flex;\n flex-direction: column;\n gap: 2px;\n border-radius: 6px;\n border: 1px solid rgba(0, 0, 0, 0.1490196078);\n padding: 4px;\n}\n.start-date-echo-wrapper.active,\n.end-date-echo-wrapper.active {\n border-color: #333;\n}\n\n.date-echo .label {\n font-size: 14px;\n line-height: 1;\n}\n\n.start-date-echo, .end-date-echo {\n font-size: 16px;\n line-height: 1;\n font-weight: bold;\n}\n\n.dividing-line {\n display: block;\n height: 1px;\n width: 20px;\n background-color: #eee;\n}\n\ndt-
|
|
10
|
-
import { Ele as DateNavEle } from "./date-nav.mjs";
|
|
11
|
-
DateNavEle.define();
|
|
9
|
+
const styleStr = css(_a || (_a = __template(["\n:host {\n display: flex;\n flex-direction: column;\n gap: 15px;\n}\n\n.date-echo {\n display: flex;\n gap: 5px;\n align-items: center;\n}\n\n.start-date-echo-wrapper,\n.end-date-echo-wrapper {\n width: 100%;\n flex: 1;\n display: flex;\n flex-direction: column;\n gap: 2px;\n border-radius: 6px;\n border: 1px solid rgba(0, 0, 0, 0.1490196078);\n padding: 4px;\n}\n.start-date-echo-wrapper.active,\n.end-date-echo-wrapper.active {\n border-color: #333;\n}\n\n.date-echo .label {\n font-size: 14px;\n line-height: 1;\n}\n\n.start-date-echo, .end-date-echo {\n font-size: 16px;\n line-height: 1;\n font-weight: bold;\n}\n\n.dividing-line {\n display: block;\n height: 1px;\n width: 20px;\n background-color: #eee;\n}\n\ndt-yyyymm-nav::part(list-grp) {\n height: 254px;\n margin-top: 15px;\n}\n\ndt-calendar-base.hide {\n display: none;\n}\n\n.calendars {\n display: flex;\n gap: 20px;\n}\n\n.wrapper {\n flex: 1;\n height: 100%;\n display: flex;\n flex-direction: column;\n gap: 15px;\n}\n\ndt-popover {\n position: relative;\n}\n\n[open] .time-echo-wrapper {\n border-color: #18181B;\n}\n\n.time-echo-wrapper {\n width: 100%;\n padding: 4px;\n display: flex;\n gap: 5px;\n border-radius: 4px;\n min-height: 30px;\n border: 1px solid rgba(0, 0, 0, 0.0666666667);\n box-sizing: border-box;\n align-items: center;\n cursor: pointer;\n}\n\n.time-selector {\n position: absolute;\n width: 100%;\n height: 461px;\n box-sizing: border-box;\n background-color: #fff;\n display: flex;\n flex-direction: column;\n gap: 15px;\n padding: 15px;\n border-radius: 6px;\n border: 1px solid #eee;\n box-shadow: 0 6px 16px rgba(0, 0, 0, 0.2);\n}\n.time-selector .title {\n font-size: 16px;\n margin: 0;\n line-height: 1;\n}\n\ndt-hhmmss-ms-list-grp::part(list-container) {\n gap: 2px;\n}\ndt-hhmmss-ms-list-grp::part(list) {\n scroll-behavior: smooth;\n}\ndt-hhmmss-ms-list-grp::part(item) {\n font-size: 14px;\n line-height: 17px;\n}\n\n#time-selector-done-btn {\n border: none;\n min-height: 30px;\n border-radius: 6px;\n padding: 5px 10px;\n font-size: 14px;\n background-color: #18181B;\n color: #fff;\n}\n\n.time-icon {\n display: inline-block;\n width: 20px;\n height: 20px;\n background: url(\"data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='15' fill='currentColor'%3E%3Cpath d='M7.4335 4.241a.4376.4376 0 0 0-.871.0594v3.783l.0044.0622a.4375.4375 0 0 0 .1921.3029L8.9242 9.877l.0566.0317a.4376.4376 0 0 0 .5495-.1559l.0317-.0566a.4376.4376 0 0 0-.1559-.5495L7.4375 7.8471V4.3004l-.004-.0593ZM7 1.6667c-3.2217 0-5.8333 2.6116-5.8333 5.8333 0 3.2217 2.6116 5.8333 5.8333 5.8333 3.2217 0 5.8333-2.6116 5.8333-5.8333 0-3.2217-2.6116-5.8333-5.8333-5.8333Zm0 .814c2.7721 0 5.0194 2.2472 5.0194 5.0193 0 2.7721-2.2473 5.0194-5.0194 5.0194S1.9806 10.2721 1.9806 7.5 4.228 2.4806 7 2.4806Z'/%3E%3C/svg%3E\") 50%/20px 20px no-repeat;\n}\n\n.time-echo {\n font-size: 14px;\n color: #999;\n line-height: 1;\n}\n\ndt-calendar-base {\n height: 254px;\n}\ndt-calendar-base::part(week) {\n font-size: 12px;\n line-height: 14px;\n}\ndt-calendar-base::part(item) {\n font-size: 14px;\n}\n"])));
|
|
12
10
|
import {
|
|
13
|
-
Ele as
|
|
11
|
+
Ele as YyyyMmNavEle
|
|
12
|
+
} from "../yyyymm-nav/index.mjs";
|
|
13
|
+
YyyyMmNavEle.define();
|
|
14
|
+
import {
|
|
15
|
+
Ele as CalendarBaseEle,
|
|
16
|
+
weekKey
|
|
14
17
|
} from "../calendar/index.mjs";
|
|
15
18
|
CalendarBaseEle.define();
|
|
16
19
|
import { Ele as HhMmSsMsListGrpEle } from "../hhmmss-ms-list-grp/index.mjs";
|
|
@@ -30,7 +33,7 @@ export class Ele extends UiBase {
|
|
|
30
33
|
super();
|
|
31
34
|
__publicField(this, "_style", styleStr);
|
|
32
35
|
__publicField(this, "_template", html(_c || (_c = __template(['\n<div class="date-echo">\n <div class="start-date-echo-wrapper active">\n <span class="label">Start Date</span>\n <span class="start-date-echo">dd/mm/yyyy</span>\n </div>\n <i class="dividing-line"></i>\n <div class="end-date-echo-wrapper">\n <span class="label">End Date</span>\n <span class="end-date-echo">dd/mm/yyyy</span>\n </div>\n</div><div class="calendars">', "</div>"])), ["start", "end"].map(
|
|
33
|
-
(s) => html(_b || (_b = __template(['\n<div class="wrapper ', '">\n <dt-
|
|
36
|
+
(s) => html(_b || (_b = __template(['\n<div class="wrapper ', '">\n <dt-yyyymm-nav\n show-ctrl-btn-month-add\n show-ctrl-btn-month-sub\n ></dt-yyyymm-nav>\n <dt-calendar-base data-type="', '"></dt-calendar-base>\n <dt-popover>\n <div slot="trigger" class="time-echo-wrapper">\n <i class="time-icon"></i>\n <span class="time-echo">hh:mm:ss.sss</span>\n </div>\n <div slot="pop" class="time-selector">\n <h3 class="title">', '</h3>\n <dt-hhmmss-ms-list-grp></dt-hhmmss-ms-list-grp>\n <button id="time-selector-done-btn" data-type="', '">Done</button>\n </div>\n </dt-popover>\n</div>'])), s, s, s === "start" ? "Start Time" : "End Time", s)
|
|
34
37
|
).join("")));
|
|
35
38
|
// 存放的是结束时间点
|
|
36
39
|
__publicField(this, "_selectedDate", null);
|
|
@@ -39,6 +42,7 @@ export class Ele extends UiBase {
|
|
|
39
42
|
let timeStart = this.timeStart;
|
|
40
43
|
let timeEnd = this.timeEnd;
|
|
41
44
|
if (timeStart > timeEnd) [timeStart, timeEnd] = [timeEnd, timeStart];
|
|
45
|
+
this._startCalendar.weekStartAt = this._endCalendar.weekStartAt = this.weekStartAt;
|
|
42
46
|
const tz = (/* @__PURE__ */ new Date()).getTimezoneOffset() * 60 * 1e3;
|
|
43
47
|
this._startNavEle.millisecond = this._startCalendar.showingTime = this._startCalendar.timeStart = this._endCalendar.timeStart = +timeStart;
|
|
44
48
|
this._startTimeSelector.millisecond = (+timeStart - tz) % (24 * 60 * 60 * 1e3);
|
|
@@ -63,6 +67,7 @@ export class Ele extends UiBase {
|
|
|
63
67
|
this._updateNavCtrlBtn();
|
|
64
68
|
}, 0));
|
|
65
69
|
__publicField(this, "_onCalendarSelect", (e) => {
|
|
70
|
+
e.stopPropagation();
|
|
66
71
|
if (this._selectedDate) {
|
|
67
72
|
this._selectedDate = null;
|
|
68
73
|
this.timeEnd = +e.detail + this._endTimeSelector.millisecond;
|
|
@@ -72,27 +77,31 @@ export class Ele extends UiBase {
|
|
|
72
77
|
}
|
|
73
78
|
});
|
|
74
79
|
__publicField(this, "_onCalendarItemHover", (e) => {
|
|
80
|
+
e.stopPropagation();
|
|
75
81
|
if (!this._selectedDate) return;
|
|
76
82
|
this.timeEnd = +e.detail + this._endTimeSelector.millisecond;
|
|
77
83
|
});
|
|
78
84
|
__publicField(this, "_onNavChange", (e) => {
|
|
85
|
+
e.stopPropagation();
|
|
79
86
|
const wrapper = closestByEvent(e, ".wrapper");
|
|
80
87
|
if (!wrapper) return;
|
|
81
|
-
const {
|
|
88
|
+
const { newTime } = e.detail;
|
|
82
89
|
if (wrapper.classList.contains("start")) {
|
|
83
|
-
this._startCalendar.showingTime = +
|
|
90
|
+
this._startCalendar.showingTime = +newTime;
|
|
84
91
|
} else {
|
|
85
|
-
this._endCalendar.showingTime = +
|
|
92
|
+
this._endCalendar.showingTime = +newTime;
|
|
86
93
|
}
|
|
87
94
|
this._updateNavCtrlBtn();
|
|
88
95
|
});
|
|
89
96
|
__publicField(this, "_onNavOpenToggle", (e) => {
|
|
90
97
|
var _a2;
|
|
91
|
-
if (!(e.target instanceof
|
|
98
|
+
if (!(e.target instanceof YyyyMmNavEle)) return;
|
|
99
|
+
e.stopPropagation();
|
|
92
100
|
(_a2 = e.target.nextElementSibling) == null ? void 0 : _a2.classList.toggle("hide", e.detail);
|
|
93
101
|
});
|
|
94
102
|
__publicField(this, "_onTimePopoverOpenChange", (e) => {
|
|
95
103
|
if (!(e.target instanceof PopoverEle)) return;
|
|
104
|
+
e.stopPropagation();
|
|
96
105
|
if (!e.detail) return this._render();
|
|
97
106
|
e.target.querySelectorAll("dt-hhmmss-ms-list-grp").forEach((ele) => {
|
|
98
107
|
ele.scrollToCurrentItem();
|
|
@@ -130,7 +139,8 @@ export class Ele extends UiBase {
|
|
|
130
139
|
...super.observedAttributes,
|
|
131
140
|
"time-start",
|
|
132
141
|
"time-end",
|
|
133
|
-
"min-granularity"
|
|
142
|
+
"min-granularity",
|
|
143
|
+
"week-start-at"
|
|
134
144
|
];
|
|
135
145
|
}
|
|
136
146
|
get timeStart() {
|
|
@@ -151,15 +161,24 @@ export class Ele extends UiBase {
|
|
|
151
161
|
if (Number.isNaN(+v)) return;
|
|
152
162
|
this.setAttribute("time-end", +v + "");
|
|
153
163
|
}
|
|
164
|
+
get weekStartAt() {
|
|
165
|
+
return this._getAttr("week-start-at", "sun");
|
|
166
|
+
}
|
|
167
|
+
set weekStartAt(val) {
|
|
168
|
+
if (!weekKey.includes(val)) return;
|
|
169
|
+
this.setAttribute("week-start-at", val);
|
|
170
|
+
}
|
|
154
171
|
get _startNavEle() {
|
|
155
172
|
var _a2;
|
|
156
173
|
return (_a2 = this.shadowRoot) == null ? void 0 : _a2.querySelector(
|
|
157
|
-
".start dt-
|
|
174
|
+
".start dt-yyyymm-nav"
|
|
158
175
|
);
|
|
159
176
|
}
|
|
160
177
|
get _endNavEle() {
|
|
161
178
|
var _a2;
|
|
162
|
-
return (_a2 = this.shadowRoot) == null ? void 0 : _a2.querySelector(
|
|
179
|
+
return (_a2 = this.shadowRoot) == null ? void 0 : _a2.querySelector(
|
|
180
|
+
".end dt-yyyymm-nav"
|
|
181
|
+
);
|
|
163
182
|
}
|
|
164
183
|
get _startCalendar() {
|
|
165
184
|
var _a2;
|
|
@@ -25,11 +25,11 @@ export interface Attrs extends BaseAttrs {
|
|
|
25
25
|
/**
|
|
26
26
|
* Start time of the quick selection. Only works in custom mode.
|
|
27
27
|
*/
|
|
28
|
-
'start-time'?:
|
|
28
|
+
'start-time'?: string | number | '';
|
|
29
29
|
/**
|
|
30
30
|
* End time of the quick selection. Only works in custom mode.
|
|
31
31
|
*/
|
|
32
|
-
'end-time'?:
|
|
32
|
+
'end-time'?: string | number | '';
|
|
33
33
|
}
|
|
34
34
|
export interface Emits {
|
|
35
35
|
'time-changed': {
|
|
@@ -43,6 +43,10 @@ export interface Emits {
|
|
|
43
43
|
};
|
|
44
44
|
}
|
|
45
45
|
export type EventMap = Emit2EventMap<Emits>;
|
|
46
|
+
export declare const genPeriodTimes: (startFn?: (_t: Date, weekOffset: number) => void, endFn?: (_t: Date, weekOffset: number) => void, t?: Date, weekStartAt?: Weeks) => {
|
|
47
|
+
start: Date;
|
|
48
|
+
end: Date;
|
|
49
|
+
};
|
|
46
50
|
/**
|
|
47
51
|
* 快速选择下拉选项
|
|
48
52
|
*/
|
|
@@ -55,6 +59,10 @@ export declare class Ele extends UiBase<Attrs, Emits> {
|
|
|
55
59
|
set quickKey(val: QuickKey);
|
|
56
60
|
get weekStartAt(): Weeks;
|
|
57
61
|
set weekStartAt(val: Weeks);
|
|
62
|
+
get startTime(): number | string | Date;
|
|
63
|
+
set startTime(val: number | string | Date);
|
|
64
|
+
get endTime(): number | string | Date;
|
|
65
|
+
set endTime(val: number | string | Date);
|
|
58
66
|
protected _style: string;
|
|
59
67
|
protected _template: string;
|
|
60
68
|
private get _periodSelector();
|
|
@@ -71,4 +79,8 @@ export declare class Ele extends UiBase<Attrs, Emits> {
|
|
|
71
79
|
private _onBackBtnClick;
|
|
72
80
|
private _onRadioChange;
|
|
73
81
|
private _onDoneBtnClick;
|
|
82
|
+
readonly genPeriodTimes: (startFn?: (_t: Date, weekOffset: number) => void, endFn?: (_t: Date, weekOffset: number) => void, t?: Date) => {
|
|
83
|
+
start: Date;
|
|
84
|
+
end: Date;
|
|
85
|
+
};
|
|
74
86
|
}
|