@gez/date-time-kit 2.0.0-alpha.0 → 2.0.0-alpha.2
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 +61 -0
- package/dist/components/date-time-selector/index.mjs +212 -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/hhmmss-ms-list-grp/index.d.ts +3 -3
- package/dist/components/hhmmss-ms-list-grp/index.mjs +35 -33
- 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 +291 -0
- package/src/components/date-time-selector/styleStr.ts +125 -0
- package/src/components/hhmmss-ms-list-grp/index.ts +44 -54
- 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 +38 -17
- 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
|
@@ -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
|
}
|
|
@@ -28,56 +28,43 @@ const genDateWithHours = (isStart, fn = (_t) => {
|
|
|
28
28
|
};
|
|
29
29
|
const genStartDate = (fn, t) => genDateWithHours(true, fn, t);
|
|
30
30
|
const genEndDate = (fn, t) => genDateWithHours(false, fn, t);
|
|
31
|
-
const
|
|
31
|
+
export const genPeriodTimes = (startFn, endFn, t = /* @__PURE__ */ new Date(), weekStartAt = "sun") => {
|
|
32
|
+
const weekOffset = weekKey.indexOf(weekStartAt);
|
|
33
|
+
return {
|
|
34
|
+
start: genStartDate((t2) => startFn == null ? void 0 : startFn(t2, weekOffset), new Date(t)),
|
|
35
|
+
end: genEndDate((t2) => endFn == null ? void 0 : endFn(t2, weekOffset), new Date(t))
|
|
36
|
+
};
|
|
37
|
+
};
|
|
38
|
+
const quickPeriodTimes = (weekStartAt = "sun") => ({
|
|
32
39
|
all: null,
|
|
33
|
-
today:
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
)
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
)
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
month: {
|
|
62
|
-
start: genStartDate((t) => t.setDate(1)),
|
|
63
|
-
end: genEndDate((t) => t.setMonth(t.getMonth() + 1, 0))
|
|
64
|
-
},
|
|
65
|
-
last30Days: {
|
|
66
|
-
start: genStartDate((t) => t.setDate(t.getDate() - 29)),
|
|
67
|
-
end: genEndDate()
|
|
68
|
-
},
|
|
69
|
-
last180Days: {
|
|
70
|
-
start: genStartDate((t) => t.setDate(t.getDate() - 179)),
|
|
71
|
-
end: genEndDate()
|
|
72
|
-
},
|
|
73
|
-
last6Month: {
|
|
74
|
-
start: genStartDate((t) => t.setMonth(t.getMonth() - 5, 1)),
|
|
75
|
-
end: genEndDate((t) => t.setMonth(t.getMonth() + 1, 0))
|
|
76
|
-
},
|
|
77
|
-
year: {
|
|
78
|
-
start: genStartDate((t) => t.setMonth(0, 1)),
|
|
79
|
-
end: genEndDate((t) => t.setFullYear(t.getFullYear() + 1, 0, 0))
|
|
80
|
-
}
|
|
40
|
+
today: genPeriodTimes(),
|
|
41
|
+
yesterday: genPeriodTimes(
|
|
42
|
+
(t) => t.setDate(t.getDate() - 1),
|
|
43
|
+
(t) => t.setDate(t.getDate() - 1)
|
|
44
|
+
),
|
|
45
|
+
week: genPeriodTimes(
|
|
46
|
+
(t, weekOffset) => t.setDate(t.getDate() - t.getDay() + weekOffset),
|
|
47
|
+
(t, weekOffset) => t.setDate(t.getDate() - t.getDay() + weekOffset + 6)
|
|
48
|
+
),
|
|
49
|
+
lastWeek: genPeriodTimes(
|
|
50
|
+
(t, weekOffset) => t.setDate(t.getDate() - t.getDay() + weekOffset - 7),
|
|
51
|
+
(t, weekOffset) => t.setDate(t.getDate() - t.getDay() + weekOffset - 1)
|
|
52
|
+
),
|
|
53
|
+
last7Days: genPeriodTimes((t) => t.setDate(t.getDate() - 6)),
|
|
54
|
+
month: genPeriodTimes(
|
|
55
|
+
(t) => t.setDate(1),
|
|
56
|
+
(t) => t.setMonth(t.getMonth() + 1, 0)
|
|
57
|
+
),
|
|
58
|
+
last30Days: genPeriodTimes((t) => t.setDate(t.getDate() - 29)),
|
|
59
|
+
last180Days: genPeriodTimes((t) => t.setDate(t.getDate() - 179)),
|
|
60
|
+
last6Month: genPeriodTimes(
|
|
61
|
+
(t) => t.setMonth(t.getMonth() - 5, 1),
|
|
62
|
+
(t) => t.setMonth(t.getMonth() + 1, 0)
|
|
63
|
+
),
|
|
64
|
+
year: genPeriodTimes(
|
|
65
|
+
(t) => t.setMonth(0, 1),
|
|
66
|
+
(t) => t.setFullYear(t.getFullYear() + 1, 0, 0)
|
|
67
|
+
)
|
|
81
68
|
});
|
|
82
69
|
export class Ele extends UiBase {
|
|
83
70
|
constructor() {
|
|
@@ -141,13 +128,21 @@ export class Ele extends UiBase {
|
|
|
141
128
|
).join(""), backArrowSvg));
|
|
142
129
|
__publicField(this, "_updatePeriodSelector", debounce(() => {
|
|
143
130
|
var _a2, _b2;
|
|
131
|
+
this._periodSelector.weekStartAt = this.weekStartAt;
|
|
144
132
|
if (((_b2 = (_a2 = this.shadowRoot) == null ? void 0 : _a2.querySelector(".menu.custom")) == null ? void 0 : _b2.style.display) === "none") {
|
|
145
133
|
return;
|
|
146
134
|
}
|
|
147
|
-
const defaultPeriod = quickPeriodTimes().last30Days;
|
|
148
135
|
const ele = this._periodSelector;
|
|
149
|
-
|
|
150
|
-
|
|
136
|
+
const startTime = this.startTime;
|
|
137
|
+
const endTime = this.endTime;
|
|
138
|
+
if (startTime !== "" && endTime !== "") {
|
|
139
|
+
ele.timeStart = startTime;
|
|
140
|
+
ele.timeEnd = endTime;
|
|
141
|
+
} else {
|
|
142
|
+
const defaultPeriod = quickPeriodTimes(this.weekStartAt).last30Days;
|
|
143
|
+
ele.timeStart = defaultPeriod.start;
|
|
144
|
+
ele.timeEnd = defaultPeriod.end;
|
|
145
|
+
}
|
|
151
146
|
ele.showCalendarDatePoint();
|
|
152
147
|
}, 0));
|
|
153
148
|
__publicField(this, "_renderTz", debounce(() => {
|
|
@@ -180,7 +175,7 @@ export class Ele extends UiBase {
|
|
|
180
175
|
if (name === "radio") {
|
|
181
176
|
const v = value;
|
|
182
177
|
if (v === "custom") return;
|
|
183
|
-
const t = quickPeriodTimes()[v];
|
|
178
|
+
const t = quickPeriodTimes(this.weekStartAt)[v];
|
|
184
179
|
this.dispatchEvent(
|
|
185
180
|
"time-changed",
|
|
186
181
|
!t ? { type: "all" } : {
|
|
@@ -196,9 +191,7 @@ export class Ele extends UiBase {
|
|
|
196
191
|
__publicField(this, "_onDoneBtnClick", (_e2) => {
|
|
197
192
|
const selector = this._periodSelector;
|
|
198
193
|
this._showMenu("top");
|
|
199
|
-
this.
|
|
200
|
-
'input[name="radio"][value="custom"]'
|
|
201
|
-
).checked = true;
|
|
194
|
+
this.quickKey = "custom";
|
|
202
195
|
this.dispatchEvent(
|
|
203
196
|
"time-changed",
|
|
204
197
|
{
|
|
@@ -209,6 +202,9 @@ export class Ele extends UiBase {
|
|
|
209
202
|
true
|
|
210
203
|
);
|
|
211
204
|
});
|
|
205
|
+
__publicField(this, "genPeriodTimes", (startFn, endFn, t = /* @__PURE__ */ new Date()) => {
|
|
206
|
+
return genPeriodTimes(startFn, endFn, t, this.weekStartAt);
|
|
207
|
+
});
|
|
212
208
|
this._applyTemplate();
|
|
213
209
|
}
|
|
214
210
|
static get observedAttributes() {
|
|
@@ -254,9 +250,37 @@ export class Ele extends UiBase {
|
|
|
254
250
|
return this._getAttr("week-start-at", "sun");
|
|
255
251
|
}
|
|
256
252
|
set weekStartAt(val) {
|
|
257
|
-
if (weekKey.includes(val)) return;
|
|
253
|
+
if (!weekKey.includes(val)) return;
|
|
258
254
|
this.setAttribute("week-start-at", val);
|
|
259
255
|
}
|
|
256
|
+
get startTime() {
|
|
257
|
+
const v = this._getAttr("start-time", "");
|
|
258
|
+
if (v === "") return "";
|
|
259
|
+
return new Date(Number.isNaN(+v) ? v : +v);
|
|
260
|
+
}
|
|
261
|
+
set startTime(val) {
|
|
262
|
+
if (val === "") {
|
|
263
|
+
this.removeAttribute("start-time");
|
|
264
|
+
return;
|
|
265
|
+
}
|
|
266
|
+
const v = new Date(val);
|
|
267
|
+
if (Number.isNaN(+v)) return;
|
|
268
|
+
this.setAttribute("time-start", +v + "");
|
|
269
|
+
}
|
|
270
|
+
get endTime() {
|
|
271
|
+
const v = this._getAttr("end-time", "" + this.startTime);
|
|
272
|
+
if (v === "") return "";
|
|
273
|
+
return new Date(Number.isNaN(+v) ? v : +v);
|
|
274
|
+
}
|
|
275
|
+
set endTime(val) {
|
|
276
|
+
if (val === "") {
|
|
277
|
+
this.removeAttribute("end-time");
|
|
278
|
+
return;
|
|
279
|
+
}
|
|
280
|
+
const v = new Date(val);
|
|
281
|
+
if (Number.isNaN(+v)) return;
|
|
282
|
+
this.setAttribute("time-end", +v + "");
|
|
283
|
+
}
|
|
260
284
|
get _periodSelector() {
|
|
261
285
|
return this.shadowRoot.querySelector(
|
|
262
286
|
"dt-period-selector"
|
|
@@ -267,6 +291,7 @@ export class Ele extends UiBase {
|
|
|
267
291
|
if (!super.connectedCallback()) return;
|
|
268
292
|
this._renderTz();
|
|
269
293
|
this._updateRadio();
|
|
294
|
+
this._updatePeriodSelector();
|
|
270
295
|
(_a2 = this.shadowRoot.querySelector(".tz-trigger")) == null ? void 0 : _a2.addEventListener(
|
|
271
296
|
"click",
|
|
272
297
|
this._onTzTriggerClick
|
|
@@ -331,6 +356,13 @@ export class Ele extends UiBase {
|
|
|
331
356
|
if (name === "quick-key") {
|
|
332
357
|
this._updateRadio();
|
|
333
358
|
}
|
|
359
|
+
if (name === "week-start-at") {
|
|
360
|
+
this._updatePeriodSelector();
|
|
361
|
+
}
|
|
362
|
+
if (name === "start-time" || name === "end-time") {
|
|
363
|
+
if (this.quickKey !== "custom") return;
|
|
364
|
+
this._updatePeriodSelector();
|
|
365
|
+
}
|
|
334
366
|
}
|
|
335
367
|
_showMenu(type) {
|
|
336
368
|
var _a2;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type BaseAttrs, type Emit2EventMap, UiBase } from '
|
|
1
|
+
import { type BaseAttrs, type Emit2EventMap, UiBase } from '../web-component-base';
|
|
2
2
|
export interface Attrs extends BaseAttrs {
|
|
3
3
|
millisecond: number;
|
|
4
4
|
/**
|
|
@@ -24,10 +24,8 @@ export interface Attrs extends BaseAttrs {
|
|
|
24
24
|
}
|
|
25
25
|
export interface Emits {
|
|
26
26
|
change: {
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
newStartTime: Date;
|
|
30
|
-
newEndTime: Date;
|
|
27
|
+
oldTime: Date;
|
|
28
|
+
newTime: Date;
|
|
31
29
|
};
|
|
32
30
|
'popover-open-change': boolean;
|
|
33
31
|
}
|
|
@@ -38,7 +36,7 @@ export type EventMap = Emit2EventMap<Emits>;
|
|
|
38
36
|
* 存在一个 titleFormatter 方法,可以重写该方法以自定义年月标题的回显格式。
|
|
39
37
|
*/
|
|
40
38
|
export declare class Ele extends UiBase<Attrs, Emits> {
|
|
41
|
-
static readonly tagName: "dt-
|
|
39
|
+
static readonly tagName: "dt-yyyymm-nav";
|
|
42
40
|
static get observedAttributes(): string[];
|
|
43
41
|
protected _style: string;
|
|
44
42
|
protected _template: string;
|
|
@@ -4,10 +4,10 @@ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { en
|
|
|
4
4
|
var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
5
5
|
var __template = (cooked, raw) => __freeze(__defProp(cooked, "raw", { value: __freeze(raw || cooked.slice()) }));
|
|
6
6
|
var _a, _b;
|
|
7
|
+
import { css, debounce, html } from "../../utils.mjs";
|
|
7
8
|
import {
|
|
8
9
|
UiBase
|
|
9
|
-
} from "
|
|
10
|
-
import { css, debounce, html } from "../../utils.mjs";
|
|
10
|
+
} from "../web-component-base/index.mjs";
|
|
11
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
12
|
import { Ele as PopoverEle } from "../popover/index.mjs";
|
|
13
13
|
PopoverEle.define();
|
|
@@ -28,9 +28,9 @@ export class Ele extends UiBase {
|
|
|
28
28
|
).millisecond = ms;
|
|
29
29
|
root.querySelector(".title").textContent = this.titleFormatter(ms);
|
|
30
30
|
}, 0));
|
|
31
|
-
__publicField(this, "_onTitleToggle", ({
|
|
32
|
-
|
|
33
|
-
|
|
31
|
+
__publicField(this, "_onTitleToggle", (e) => {
|
|
32
|
+
const isOpen = e.detail;
|
|
33
|
+
e.stopPropagation();
|
|
34
34
|
this.shadowRoot.querySelector(".wrapper").classList.toggle(
|
|
35
35
|
"show-list",
|
|
36
36
|
isOpen
|
|
@@ -42,6 +42,7 @@ export class Ele extends UiBase {
|
|
|
42
42
|
});
|
|
43
43
|
__publicField(this, "_onItemSelect", (e) => {
|
|
44
44
|
if (!(e.target instanceof YyyyMmDdListGrpEle)) return;
|
|
45
|
+
e.stopPropagation();
|
|
45
46
|
this.millisecond = e.target.millisecond;
|
|
46
47
|
});
|
|
47
48
|
__publicField(this, "_onBtnClick", (e) => {
|
|
@@ -147,15 +148,13 @@ export class Ele extends UiBase {
|
|
|
147
148
|
this.dispatchEvent(
|
|
148
149
|
"change",
|
|
149
150
|
{
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
newStartTime: /* @__PURE__ */ new Date(+newValue),
|
|
153
|
-
newEndTime: /* @__PURE__ */ new Date(+newValue)
|
|
151
|
+
oldTime: /* @__PURE__ */ new Date(+oldValue),
|
|
152
|
+
newTime: /* @__PURE__ */ new Date(+newValue)
|
|
154
153
|
},
|
|
155
154
|
true
|
|
156
155
|
);
|
|
157
156
|
}
|
|
158
157
|
}
|
|
159
158
|
}
|
|
160
|
-
__publicField(Ele, "tagName", "dt-
|
|
159
|
+
__publicField(Ele, "tagName", "dt-yyyymm-nav");
|
|
161
160
|
Ele.define();
|
|
@@ -3,19 +3,19 @@ var __defProp = Object.defineProperty;
|
|
|
3
3
|
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
4
4
|
var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
5
5
|
var __template = (cooked, raw) => __freeze(__defProp(cooked, "raw", { value: __freeze(raw || cooked.slice()) }));
|
|
6
|
-
var _a;
|
|
7
|
-
import { debounce, html } from "../../utils.mjs";
|
|
6
|
+
var _a, _b;
|
|
7
|
+
import { css, debounce, html } from "../../utils.mjs";
|
|
8
8
|
import { Ele as NumListEle } from "../num-list/index.mjs";
|
|
9
9
|
NumListEle.define();
|
|
10
10
|
import {
|
|
11
11
|
UiBase
|
|
12
12
|
} from "../web-component-base/index.mjs";
|
|
13
|
-
const styleStr = "";
|
|
13
|
+
const styleStr = css(_a || (_a = __template(["\n:host {\n display: flex;\n flex-direction: column;\n overflow: hidden;\n gap: 15px;\n}\n\n.cols {\n flex: 1;\n display: flex;\n flex-direction: row;\n height: 0;\n justify-content: space-between;\n gap: 2px;\n}\n\n.col {\n flex: 1;\n display: flex;\n flex-direction: column;\n gap: 10px;\n}\n\n.col > span {\n text-align: center;\n display: inline-block;\n line-height: 27px;\n}\n\ndt-num-list {\n flex: 1;\n}\n"])));
|
|
14
14
|
export class Ele extends UiBase {
|
|
15
15
|
constructor() {
|
|
16
16
|
super();
|
|
17
17
|
__publicField(this, "_style", styleStr);
|
|
18
|
-
__publicField(this, "_template", html(
|
|
18
|
+
__publicField(this, "_template", html(_b || (_b = __template(['\n <div class="cols" part="cols">\n <div class="col year" part="col year">\n <span part="col label year">Year</span>\n <dt-num-list part="list year" class="year"></dt-num-list>\n </div>\n <div class="col month" part="col month">\n <span part="col label month">Month</span>\n <dt-num-list part="list month" class="month" min-num="1" max-num="12"></dt-num-list>\n </div>\n <div class="col day" part="col day">\n <span part="col label day">Day</span>\n <dt-num-list part="list day" class="day" min-num="1" max-num="31"></dt-num-list>\n </div>\n </div>\n ']))));
|
|
19
19
|
__publicField(this, "_renderCols", debounce(() => {
|
|
20
20
|
if (!this.isConnected) return;
|
|
21
21
|
const { colOrder } = this;
|
|
@@ -28,7 +28,7 @@ export class Ele extends UiBase {
|
|
|
28
28
|
colsContainer.append(...orderedCols);
|
|
29
29
|
}, 0));
|
|
30
30
|
__publicField(this, "_updateGranularity", debounce(() => {
|
|
31
|
-
var _a2,
|
|
31
|
+
var _a2, _b2;
|
|
32
32
|
if (!this.isConnected) return;
|
|
33
33
|
const { maxGranularity, minGranularity } = this;
|
|
34
34
|
const colsContainer = this.shadowRoot.querySelector(".cols");
|
|
@@ -37,7 +37,7 @@ export class Ele extends UiBase {
|
|
|
37
37
|
const dEle = this.shadowRoot.querySelector(".col.day");
|
|
38
38
|
const granularityMap = { year: 3, month: 2, day: 1 };
|
|
39
39
|
let maxG = (_a2 = granularityMap[maxGranularity]) != null ? _a2 : 1;
|
|
40
|
-
let minG = (
|
|
40
|
+
let minG = (_b2 = granularityMap[minGranularity]) != null ? _b2 : 3;
|
|
41
41
|
if (maxG < minG) [maxG, minG] = [minG, maxG];
|
|
42
42
|
yEle.style.display = maxG >= 3 && minG <= 3 ? "" : "none";
|
|
43
43
|
mEle.style.display = maxG >= 2 && minG <= 2 ? "" : "none";
|
package/dist/index.d.ts
CHANGED
|
@@ -4,4 +4,5 @@ export * as DtHhMmSsMsListGrp from './components/hhmmss-ms-list-grp';
|
|
|
4
4
|
export * as DtYyyyMmDdListGrp from './components/yyyymmdd-list-grp';
|
|
5
5
|
export * as DtQuickSelector from './components/quick-selector';
|
|
6
6
|
export * as DtPopover from './components/popover';
|
|
7
|
+
export * as DtDataTimeSelector from './components/date-time-selector';
|
|
7
8
|
export { i18n as dtI18n, type Lang as DtLang, type I18n as DtI18n } from './i18n';
|
package/dist/index.mjs
CHANGED
|
@@ -10,6 +10,8 @@ import * as DtQuickSelector from "./components/quick-selector/index.mjs";
|
|
|
10
10
|
export { DtQuickSelector };
|
|
11
11
|
import * as DtPopover from "./components/popover/index.mjs";
|
|
12
12
|
export { DtPopover };
|
|
13
|
+
import * as DtDataTimeSelector from "./components/date-time-selector/index.mjs";
|
|
14
|
+
export { DtDataTimeSelector };
|
|
13
15
|
export {
|
|
14
16
|
i18n as dtI18n
|
|
15
17
|
} from "./i18n.mjs";
|
package/package.json
CHANGED
|
@@ -17,7 +17,7 @@
|
|
|
17
17
|
"unbuild": "3.6.0",
|
|
18
18
|
"vitest": "3.2.4"
|
|
19
19
|
},
|
|
20
|
-
"version": "2.0.0-alpha.
|
|
20
|
+
"version": "2.0.0-alpha.2",
|
|
21
21
|
"type": "module",
|
|
22
22
|
"private": false,
|
|
23
23
|
"exports": {
|
|
@@ -36,5 +36,5 @@
|
|
|
36
36
|
"template",
|
|
37
37
|
"public"
|
|
38
38
|
],
|
|
39
|
-
"gitHead": "
|
|
39
|
+
"gitHead": "6dd8a158176b175cf723d37e851e9b41fdfcbefb"
|
|
40
40
|
}
|
|
@@ -146,7 +146,7 @@ export interface Attrs extends BaseAttrs {
|
|
|
146
146
|
/**
|
|
147
147
|
* The start time of the calendar display range.
|
|
148
148
|
* @type {`string | number`} A value that can be passed to the Date constructor.
|
|
149
|
-
* @default '
|
|
149
|
+
* @default 'showing-time'
|
|
150
150
|
*/
|
|
151
151
|
'time-start'?: string | number;
|
|
152
152
|
/**
|
|
@@ -253,7 +253,7 @@ export class Ele extends UiBase<Attrs, Emits> {
|
|
|
253
253
|
return this._getAttr('week-start-at', 'sun');
|
|
254
254
|
}
|
|
255
255
|
public set weekStartAt(val: Weeks) {
|
|
256
|
-
if (weekKey.includes(val)) return;
|
|
256
|
+
if (!weekKey.includes(val)) return;
|
|
257
257
|
this.setAttribute('week-start-at', val);
|
|
258
258
|
}
|
|
259
259
|
public get showOtherMonth() {
|