@gez/date-time-kit 1.1.4 → 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,347 @@
|
|
|
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, _c, _d, _e, _f;
|
|
7
|
+
import { css, debounce, html } from "../../utils.mjs";
|
|
8
|
+
import { Ele as PeriodSelectorEle } from "../period-selector/index.mjs";
|
|
9
|
+
import {
|
|
10
|
+
UiBase
|
|
11
|
+
} from "../web-component-base/index.mjs";
|
|
12
|
+
PeriodSelectorEle.define();
|
|
13
|
+
import { Ele as I18nEle } from "../i18n/index.mjs";
|
|
14
|
+
I18nEle.define();
|
|
15
|
+
import { weekKey } from "../calendar/index.mjs";
|
|
16
|
+
const styleStr = css(_a || (_a = __template(["\n:host {\n width: fit-content;\n display: block;\n}\n\n.menu {\n display: flex;\n flex-direction: column;\n align-items: center;\n padding: 10px 5px;\n font-size: 14px;\n gap: 10px;\n border-radius: 6px;\n border: 1px solid #eee;\n box-shadow: 0 6px 16px rgba(0, 0, 0, 0.2);\n background-color: #fff;\n}\n.menu > * {\n width: 100%;\n box-sizing: border-box;\n}\n\n.radio-grp {\n display: flex;\n flex-direction: column;\n gap: 5px;\n width: 100%;\n}\n.radio-grp > label {\n display: flex;\n align-items: center;\n gap: 10px;\n cursor: pointer;\n padding: 5px;\n}\n.radio-grp > label:hover {\n background-color: #f5f5f5;\n}\n.radio-grp dt-i18n {\n flex: 1;\n}\n.radio-grp input {\n margin: 0;\n width: 24px;\n height: 24px;\n cursor: pointer;\n}\n\n.arrow-right-icon {\n display: inline-block;\n width: 15px;\n height: 15px;\n background: 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\") no-repeat center center;\n cursor: pointer;\n}\n\n.dividing-line {\n display: block;\n height: 1px;\n width: 100%;\n background-color: #eee;\n}\n\n.tz-trigger {\n display: flex;\n align-items: center;\n justify-content: space-between;\n padding: 5px;\n gap: 10px;\n cursor: pointer;\n white-space: nowrap;\n}\n.tz-trigger:hover {\n background-color: #f5f5f5;\n}\n.tz-trigger bdo {\n direction: ltr;\n}\n\n.title {\n display: flex;\n align-items: center;\n padding: 5px;\n gap: 10px;\n font-weight: 700;\n font-size: 18px;\n box-sizing: border-box;\n}\n.title svg {\n border: 5px solid transparent;\n border-radius: 50%;\n margin: -5px;\n cursor: pointer;\n}\n.title svg:hover {\n background-color: #eee;\n border-color: #eee;\n}\n\n.menu.tz {\n min-width: 180px;\n max-height: 293px;\n overflow: hidden auto;\n}\n.menu.tz fieldset {\n width: 100%;\n border: none;\n border-top: 1px solid #eee;\n margin: 0;\n padding: 0;\n display: flex;\n flex-direction: column;\n gap: 5px;\n}\n.menu.tz fieldset legend {\n padding: 0 5px;\n margin-bottom: 5px;\n font-size: 12px;\n line-height: 24px;\n color: #666;\n}\n.menu.tz label {\n display: flex;\n align-items: center;\n gap: 10px;\n cursor: pointer;\n padding: 5px;\n}\n.menu.tz label:hover {\n background-color: #f5f5f5;\n}\n.menu.tz input {\n margin: 0;\n width: 24px;\n height: 24px;\n cursor: pointer;\n}\n\nbutton {\n border: none;\n min-height: 40px;\n border-radius: 6px;\n padding: 5px 15px;\n font-size: 16px;\n line-height: 1;\n background-color: #18181B;\n color: #fff;\n font-weight: 500;\n cursor: pointer;\n}\n\n.menu.custom {\n padding: 14px;\n gap: 15px;\n}\n.menu.custom dt-period-selector {\n width: 590px;\n}\n.menu.custom .btns {\n display: flex;\n justify-content: flex-end;\n gap: 10px;\n}\n.menu.custom #reset {\n background-color: #E5E7E8;\n color: #333;\n}\n"])));
|
|
17
|
+
const backArrowSvg = html(_b || (_b = __template(['<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" fill="currentColor"><path d="M9.894 5.106a.75.75 0 0 1 0 1.06L4.811 11.25 21 11.25a.75.75 0 0 1 0 1.5l-16.191-.001 5.085 5.085a.75.75 0 0 1-1.06 1.06L2.47 12.53a.75.75 0 0 1 0-1.06l6.364-6.364a.75.75 0 0 1 1.06 0Z"/></svg>'])));
|
|
18
|
+
const ArrowRightSvg = html(_c || (_c = __template(['<svg xmlns="http://www.w3.org/2000/svg" width="17" height="17" fill="currentColor"><path 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"/></svg>'])));
|
|
19
|
+
const getCurrentTz = () => -(/* @__PURE__ */ new Date()).getTimezoneOffset();
|
|
20
|
+
const utcText = (tz = getCurrentTz()) => tz >= 0 ? "UTC+".concat((~~(tz / 60) + "").padStart(2, "0"), ":").concat((tz % 60 + "").padStart(2, "0")) : "UTC-".concat((~~-(tz / 60) + "").padStart(2, "0"), ":").concat((-tz % 60 + "").padStart(2, "0"));
|
|
21
|
+
const genTzRadio = (tz) => html(_d || (_d = __template(['<label><input type="radio" name="tz" value="', '"/><span>', "</span></label>"])), tz, utcText(tz));
|
|
22
|
+
const genDateWithHours = (isStart, fn = (_t) => {
|
|
23
|
+
}, t = /* @__PURE__ */ new Date()) => {
|
|
24
|
+
if (isStart) t.setHours(0, 0, 0, 0);
|
|
25
|
+
else t.setHours(23, 59, 59, 999);
|
|
26
|
+
fn(t);
|
|
27
|
+
return t;
|
|
28
|
+
};
|
|
29
|
+
const genStartDate = (fn, t) => genDateWithHours(true, fn, t);
|
|
30
|
+
const genEndDate = (fn, t) => genDateWithHours(false, fn, t);
|
|
31
|
+
const quickPeriodTimes = (weekOffset = 0) => ({
|
|
32
|
+
all: null,
|
|
33
|
+
today: {
|
|
34
|
+
start: genStartDate(),
|
|
35
|
+
end: genEndDate()
|
|
36
|
+
},
|
|
37
|
+
yesterday: {
|
|
38
|
+
start: genStartDate((t) => t.setDate(t.getDate() - 1)),
|
|
39
|
+
end: genEndDate((t) => t.setDate(t.getDate() - 1))
|
|
40
|
+
},
|
|
41
|
+
week: {
|
|
42
|
+
start: genStartDate(
|
|
43
|
+
(t) => t.setDate(t.getDate() - t.getDay() + weekOffset)
|
|
44
|
+
),
|
|
45
|
+
end: genEndDate(
|
|
46
|
+
(t) => t.setDate(t.getDate() - t.getDay() + weekOffset + 6)
|
|
47
|
+
)
|
|
48
|
+
},
|
|
49
|
+
lastWeek: {
|
|
50
|
+
start: genStartDate(
|
|
51
|
+
(t) => t.setDate(t.getDate() - t.getDay() + weekOffset - 7)
|
|
52
|
+
),
|
|
53
|
+
end: genEndDate(
|
|
54
|
+
(t) => t.setDate(t.getDate() - t.getDay() + weekOffset - 1)
|
|
55
|
+
)
|
|
56
|
+
},
|
|
57
|
+
last7Days: {
|
|
58
|
+
start: genStartDate((t) => t.setDate(t.getDate() - 6)),
|
|
59
|
+
end: genEndDate()
|
|
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
|
+
}
|
|
81
|
+
});
|
|
82
|
+
export class Ele extends UiBase {
|
|
83
|
+
constructor() {
|
|
84
|
+
super();
|
|
85
|
+
__publicField(this, "_style", styleStr);
|
|
86
|
+
__publicField(this, "_template", html(_f || (_f = __template(['\n<div class="menu top" part="menu top"\n ><div class="radio-grp">', '<label class="custom-trigger"\n ><input type="radio" name="radio" value="custom"\n /><dt-i18n i18n-key="quick.custom">Custom</dt-i18n\n >', '</label\n ></div\n ><i class="dividing-line"></i\n ><div class="tz-trigger"\n ><span\n ><dt-i18n i18n-key="quick.timezone"></dt-i18n\n ><bdo>', "</bdo\n ></span\n >", '</div\n></div\n><div class="menu tz" part="menu tz" style="display:none"\n ><div class="title"\n >', '<span>Time Zone</span\n ></div\n ><fieldset class="subtitle"\n ><legend><dt-i18n i18n-key="quick.recommend"></dt-i18n></legend\n >', '</fieldset\n ><fieldset class="subtitle"\n ><legend><dt-i18n i18n-key="quick.timezoneList"></dt-i18n></legend\n >', '</fieldset\n ></div\n><div class="menu custom" part="menu custom" style="display:none"\n ><div class="title"\n >', '<span>Custom</span\n ></div\n ><dt-period-selector></dt-period-selector\n ><div class="btns"\n ><button id="reset">Reset</button\n ><button id="done">Done</button\n ></div\n></div>'])), [
|
|
87
|
+
"all",
|
|
88
|
+
"today",
|
|
89
|
+
"yesterday",
|
|
90
|
+
"week",
|
|
91
|
+
"lastWeek",
|
|
92
|
+
"last7Days",
|
|
93
|
+
"month",
|
|
94
|
+
"last30Days",
|
|
95
|
+
"last180Days",
|
|
96
|
+
"last6Month",
|
|
97
|
+
"year"
|
|
98
|
+
].map(
|
|
99
|
+
(k) => html(_e || (_e = __template(['<label\n ><input type="radio" name="radio" value="', '"\n /><dt-i18n i18n-key="quick.', '">', "</dt-i18n\n ></label>"])), k, k, k)
|
|
100
|
+
).join(""), ArrowRightSvg, utcText(), ArrowRightSvg, backArrowSvg, [.../* @__PURE__ */ new Set([getCurrentTz(), 120])].map(genTzRadio).join(""), [
|
|
101
|
+
-12,
|
|
102
|
+
-11,
|
|
103
|
+
-10,
|
|
104
|
+
-9.5,
|
|
105
|
+
-9,
|
|
106
|
+
-8,
|
|
107
|
+
-7,
|
|
108
|
+
-6,
|
|
109
|
+
-5,
|
|
110
|
+
-4,
|
|
111
|
+
-3,
|
|
112
|
+
-3.5,
|
|
113
|
+
-2,
|
|
114
|
+
-1,
|
|
115
|
+
0,
|
|
116
|
+
1,
|
|
117
|
+
2,
|
|
118
|
+
3,
|
|
119
|
+
3.5,
|
|
120
|
+
4,
|
|
121
|
+
4.5,
|
|
122
|
+
5,
|
|
123
|
+
5.5,
|
|
124
|
+
5.75,
|
|
125
|
+
6,
|
|
126
|
+
6.5,
|
|
127
|
+
7,
|
|
128
|
+
8,
|
|
129
|
+
8.75,
|
|
130
|
+
9,
|
|
131
|
+
9.5,
|
|
132
|
+
10,
|
|
133
|
+
10.5,
|
|
134
|
+
11,
|
|
135
|
+
12,
|
|
136
|
+
12.45,
|
|
137
|
+
13,
|
|
138
|
+
14
|
|
139
|
+
].map(
|
|
140
|
+
(tz) => tz === 2 || tz * 60 === getCurrentTz() ? "" : genTzRadio(tz * 60)
|
|
141
|
+
).join(""), backArrowSvg));
|
|
142
|
+
__publicField(this, "_updatePeriodSelector", debounce(() => {
|
|
143
|
+
var _a2, _b2;
|
|
144
|
+
if (((_b2 = (_a2 = this.shadowRoot) == null ? void 0 : _a2.querySelector(".menu.custom")) == null ? void 0 : _b2.style.display) === "none") {
|
|
145
|
+
return;
|
|
146
|
+
}
|
|
147
|
+
const defaultPeriod = quickPeriodTimes().last30Days;
|
|
148
|
+
const ele = this._periodSelector;
|
|
149
|
+
ele.timeStart = defaultPeriod.start;
|
|
150
|
+
ele.timeEnd = defaultPeriod.end;
|
|
151
|
+
ele.showCalendarDatePoint();
|
|
152
|
+
}, 0));
|
|
153
|
+
__publicField(this, "_renderTz", debounce(() => {
|
|
154
|
+
const tz = this.timezone;
|
|
155
|
+
const tzRadios = this.shadowRoot.querySelectorAll(
|
|
156
|
+
'input[name="tz"]'
|
|
157
|
+
);
|
|
158
|
+
tzRadios.forEach((radio) => {
|
|
159
|
+
radio.checked = +radio.value === tz;
|
|
160
|
+
});
|
|
161
|
+
this.shadowRoot.querySelector(".tz-trigger bdo").textContent = utcText(tz);
|
|
162
|
+
}, 0));
|
|
163
|
+
__publicField(this, "_updateRadio", debounce(() => {
|
|
164
|
+
const quickKey = this.quickKey;
|
|
165
|
+
const radio = this.shadowRoot.querySelector(
|
|
166
|
+
'input[name="radio"][value="'.concat(quickKey, '"]')
|
|
167
|
+
);
|
|
168
|
+
radio.checked = true;
|
|
169
|
+
}, 0));
|
|
170
|
+
__publicField(this, "_onTzTriggerClick", () => this._showMenu("tz"));
|
|
171
|
+
__publicField(this, "_onCustomTriggerClick", (e) => {
|
|
172
|
+
e.preventDefault();
|
|
173
|
+
this._showMenu("custom");
|
|
174
|
+
});
|
|
175
|
+
__publicField(this, "_onBackBtnClick", () => this._showMenu("top"));
|
|
176
|
+
__publicField(this, "_onRadioChange", (e) => {
|
|
177
|
+
if (!(e.target instanceof HTMLInputElement)) return;
|
|
178
|
+
if (e.target.type !== "radio") return;
|
|
179
|
+
const { name, value } = e.target;
|
|
180
|
+
if (name === "radio") {
|
|
181
|
+
const v = value;
|
|
182
|
+
if (v === "custom") return;
|
|
183
|
+
const t = quickPeriodTimes()[v];
|
|
184
|
+
this.dispatchEvent(
|
|
185
|
+
"time-changed",
|
|
186
|
+
!t ? { type: "all" } : {
|
|
187
|
+
...t,
|
|
188
|
+
type: v
|
|
189
|
+
},
|
|
190
|
+
true
|
|
191
|
+
);
|
|
192
|
+
} else if (name === "tz") {
|
|
193
|
+
this.timezone = +value;
|
|
194
|
+
}
|
|
195
|
+
});
|
|
196
|
+
__publicField(this, "_onDoneBtnClick", (_e2) => {
|
|
197
|
+
const selector = this._periodSelector;
|
|
198
|
+
this._showMenu("top");
|
|
199
|
+
this.shadowRoot.querySelector(
|
|
200
|
+
'input[name="radio"][value="custom"]'
|
|
201
|
+
).checked = true;
|
|
202
|
+
this.dispatchEvent(
|
|
203
|
+
"time-changed",
|
|
204
|
+
{
|
|
205
|
+
start: selector.timeStart,
|
|
206
|
+
end: selector.timeEnd,
|
|
207
|
+
type: "custom"
|
|
208
|
+
},
|
|
209
|
+
true
|
|
210
|
+
);
|
|
211
|
+
});
|
|
212
|
+
this._applyTemplate();
|
|
213
|
+
}
|
|
214
|
+
static get observedAttributes() {
|
|
215
|
+
return [
|
|
216
|
+
...super.observedAttributes,
|
|
217
|
+
"time-zone",
|
|
218
|
+
"week-start-at",
|
|
219
|
+
"quick-key",
|
|
220
|
+
"start-time",
|
|
221
|
+
"end-time"
|
|
222
|
+
];
|
|
223
|
+
}
|
|
224
|
+
get timezone() {
|
|
225
|
+
return +this._getAttr("time-zone", "" + getCurrentTz());
|
|
226
|
+
}
|
|
227
|
+
set timezone(v) {
|
|
228
|
+
if (!Number.isSafeInteger(v)) return;
|
|
229
|
+
this.setAttribute("time-zone", "" + v);
|
|
230
|
+
}
|
|
231
|
+
get quickKey() {
|
|
232
|
+
return this._getAttr("quick-key", "all");
|
|
233
|
+
}
|
|
234
|
+
set quickKey(val) {
|
|
235
|
+
if (![
|
|
236
|
+
"all",
|
|
237
|
+
"today",
|
|
238
|
+
"yesterday",
|
|
239
|
+
"week",
|
|
240
|
+
"lastWeek",
|
|
241
|
+
"last7Days",
|
|
242
|
+
"month",
|
|
243
|
+
"last30Days",
|
|
244
|
+
"last180Days",
|
|
245
|
+
"last6Month",
|
|
246
|
+
"year",
|
|
247
|
+
"custom"
|
|
248
|
+
].includes(val)) {
|
|
249
|
+
return;
|
|
250
|
+
}
|
|
251
|
+
this.setAttribute("quick-key", val);
|
|
252
|
+
}
|
|
253
|
+
get weekStartAt() {
|
|
254
|
+
return this._getAttr("week-start-at", "sun");
|
|
255
|
+
}
|
|
256
|
+
set weekStartAt(val) {
|
|
257
|
+
if (weekKey.includes(val)) return;
|
|
258
|
+
this.setAttribute("week-start-at", val);
|
|
259
|
+
}
|
|
260
|
+
get _periodSelector() {
|
|
261
|
+
return this.shadowRoot.querySelector(
|
|
262
|
+
"dt-period-selector"
|
|
263
|
+
);
|
|
264
|
+
}
|
|
265
|
+
connectedCallback() {
|
|
266
|
+
var _a2, _b2, _c2, _d2, _e2, _f2;
|
|
267
|
+
if (!super.connectedCallback()) return;
|
|
268
|
+
this._renderTz();
|
|
269
|
+
this._updateRadio();
|
|
270
|
+
(_a2 = this.shadowRoot.querySelector(".tz-trigger")) == null ? void 0 : _a2.addEventListener(
|
|
271
|
+
"click",
|
|
272
|
+
this._onTzTriggerClick
|
|
273
|
+
);
|
|
274
|
+
(_b2 = this.shadowRoot.querySelector(".custom-trigger")) == null ? void 0 : _b2.addEventListener(
|
|
275
|
+
"click",
|
|
276
|
+
this._onCustomTriggerClick
|
|
277
|
+
);
|
|
278
|
+
(_c2 = this.shadowRoot.querySelector(".menu.tz .title svg")) == null ? void 0 : _c2.addEventListener(
|
|
279
|
+
"click",
|
|
280
|
+
this._onBackBtnClick
|
|
281
|
+
);
|
|
282
|
+
(_d2 = this.shadowRoot.querySelector(
|
|
283
|
+
".menu.custom .title svg"
|
|
284
|
+
)) == null ? void 0 : _d2.addEventListener("click", this._onBackBtnClick);
|
|
285
|
+
this.shadowRoot.querySelectorAll(".menu").forEach((menu) => {
|
|
286
|
+
menu.addEventListener("change", this._onRadioChange);
|
|
287
|
+
});
|
|
288
|
+
(_e2 = this.shadowRoot.querySelector("#reset")) == null ? void 0 : _e2.addEventListener(
|
|
289
|
+
"click",
|
|
290
|
+
this._updatePeriodSelector
|
|
291
|
+
);
|
|
292
|
+
(_f2 = this.shadowRoot.querySelector("#done")) == null ? void 0 : _f2.addEventListener(
|
|
293
|
+
"click",
|
|
294
|
+
this._onDoneBtnClick
|
|
295
|
+
);
|
|
296
|
+
}
|
|
297
|
+
disconnectedCallback() {
|
|
298
|
+
var _a2, _b2, _c2, _d2, _e2, _f2;
|
|
299
|
+
if (!super.disconnectedCallback()) return;
|
|
300
|
+
(_a2 = this.shadowRoot.querySelector(".tz-trigger")) == null ? void 0 : _a2.removeEventListener(
|
|
301
|
+
"click",
|
|
302
|
+
this._onTzTriggerClick
|
|
303
|
+
);
|
|
304
|
+
(_b2 = this.shadowRoot.querySelector(".custom-trigger")) == null ? void 0 : _b2.removeEventListener(
|
|
305
|
+
"click",
|
|
306
|
+
this._onCustomTriggerClick
|
|
307
|
+
);
|
|
308
|
+
(_c2 = this.shadowRoot.querySelector(
|
|
309
|
+
".menu.tz .title svg"
|
|
310
|
+
)) == null ? void 0 : _c2.removeEventListener("click", this._onBackBtnClick);
|
|
311
|
+
(_d2 = this.shadowRoot.querySelector(
|
|
312
|
+
".menu.custom .title svg"
|
|
313
|
+
)) == null ? void 0 : _d2.removeEventListener("click", this._onBackBtnClick);
|
|
314
|
+
this.shadowRoot.querySelectorAll(".menu").forEach((menu) => {
|
|
315
|
+
menu.removeEventListener("change", this._onRadioChange);
|
|
316
|
+
});
|
|
317
|
+
(_e2 = this.shadowRoot.querySelector("#reset")) == null ? void 0 : _e2.removeEventListener(
|
|
318
|
+
"click",
|
|
319
|
+
this._updatePeriodSelector
|
|
320
|
+
);
|
|
321
|
+
(_f2 = this.shadowRoot.querySelector("#done")) == null ? void 0 : _f2.removeEventListener(
|
|
322
|
+
"click",
|
|
323
|
+
this._onDoneBtnClick
|
|
324
|
+
);
|
|
325
|
+
}
|
|
326
|
+
_onAttrChanged(name, oldValue, newValue) {
|
|
327
|
+
super._onAttrChanged(name, oldValue, newValue);
|
|
328
|
+
if (name === "time-zone") {
|
|
329
|
+
this._renderTz();
|
|
330
|
+
}
|
|
331
|
+
if (name === "quick-key") {
|
|
332
|
+
this._updateRadio();
|
|
333
|
+
}
|
|
334
|
+
}
|
|
335
|
+
_showMenu(type) {
|
|
336
|
+
var _a2;
|
|
337
|
+
const menus = (_a2 = this.shadowRoot) == null ? void 0 : _a2.querySelectorAll(".menu");
|
|
338
|
+
menus == null ? void 0 : menus.forEach(
|
|
339
|
+
(menu) => menu.style.display = menu.classList.contains(type) ? "" : "none"
|
|
340
|
+
);
|
|
341
|
+
if (type === "custom") {
|
|
342
|
+
this._updatePeriodSelector();
|
|
343
|
+
}
|
|
344
|
+
}
|
|
345
|
+
}
|
|
346
|
+
__publicField(Ele, "tagName", "dt-quick-selector");
|
|
347
|
+
Ele.define();
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
@-moz-document url-prefix() {
|
|
2
|
+
:host, * {
|
|
3
|
+
scrollbar-width: thin;
|
|
4
|
+
scrollbar-color: var(--scrollbar-thumb-color, rgba(68, 68, 68, 0.2666666667)) transparent;
|
|
5
|
+
}
|
|
6
|
+
:host:hover, *:hover {
|
|
7
|
+
scrollbar-color: var(--scrollbar-thumb-color-hover, var(--scrollbar-thumb-color, rgba(136, 136, 136, 0.5333333333))) transparent;
|
|
8
|
+
}
|
|
9
|
+
}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import type { Lang } from '../../i18n';
|
|
2
|
+
type EmitType = Record<string, any>;
|
|
3
|
+
export type Emit2EventMap<Emit extends EmitType> = {
|
|
4
|
+
[K in keyof Emit]: CustomEvent<Emit[K]>;
|
|
5
|
+
};
|
|
6
|
+
export type ListenerFn<Emit extends EmitType, K extends keyof Emit | keyof HTMLElementEventMap> = (this: HTMLElement, ev: K extends keyof Emit ? CustomEvent<Emit[K]> : HTMLElementEventMap[K & keyof HTMLElementEventMap]) => any;
|
|
7
|
+
export type EventListenerObj<Emit extends EmitType, K extends keyof Emit | keyof HTMLElementEventMap> = {
|
|
8
|
+
handleEvent: ListenerFn<Emit, K>;
|
|
9
|
+
};
|
|
10
|
+
export type EventListenerOrListenerObj<Emit extends EmitType, K extends keyof Emit | keyof HTMLElementEventMap> = ListenerFn<Emit, K> | EventListenerObj<Emit, K>;
|
|
11
|
+
type getAttrType<Attr, K extends keyof Attr> = Extract<Attr[K], string> extends never ? string : Extract<Attr[K], string>;
|
|
12
|
+
export interface BaseAttrs {
|
|
13
|
+
/**
|
|
14
|
+
* The language of the component.
|
|
15
|
+
* @type `Lang`
|
|
16
|
+
*/
|
|
17
|
+
lang?: Lang;
|
|
18
|
+
}
|
|
19
|
+
declare const HTMLElementBase: {
|
|
20
|
+
new (): HTMLElement;
|
|
21
|
+
prototype: HTMLElement;
|
|
22
|
+
};
|
|
23
|
+
export declare class UiBase<Attr extends BaseAttrs = BaseAttrs, Emit extends Record<string, any> = {}> extends HTMLElementBase {
|
|
24
|
+
static readonly tagName: string;
|
|
25
|
+
protected static _definePromise: Promise<CustomElementConstructor> | null;
|
|
26
|
+
static define(): Promise<CustomElementConstructor> | undefined;
|
|
27
|
+
static get observedAttributes(): string[];
|
|
28
|
+
protected _template: string;
|
|
29
|
+
protected _style: string;
|
|
30
|
+
protected _initTemplate(): HTMLTemplateElement;
|
|
31
|
+
protected _applyTemplate(): void;
|
|
32
|
+
constructor();
|
|
33
|
+
protected _getAttr<K extends keyof Attr, D extends undefined | getAttrType<Attr, K> = undefined>(qualifiedName: K, defaultValue?: D): undefined extends D ? getAttrType<Attr, K> | null : getAttrType<Attr, K>;
|
|
34
|
+
protected _onAttrChanged(_name: string, _oldVal: string, _newVal: string): void;
|
|
35
|
+
attributeChangedCallback(name: string, oldValue: string, newValue: string): void;
|
|
36
|
+
/** return false | void means not continue */
|
|
37
|
+
connectedCallback(): boolean | void;
|
|
38
|
+
/** return false | void means not continue */
|
|
39
|
+
disconnectedCallback(): boolean | void;
|
|
40
|
+
connectedMoveCallback(): void;
|
|
41
|
+
adoptedCallback(): void;
|
|
42
|
+
dispatchEvent<K extends keyof Emit | undefined = undefined>(type: K | Event, data?: K extends keyof Emit ? Emit[K] : any, global?: boolean): boolean;
|
|
43
|
+
addEventListener<K extends keyof Emit | keyof HTMLElementEventMap>(type: K | string, listener: EventListenerOrListenerObj<Emit, K>, options?: boolean | EventListenerOptions): void;
|
|
44
|
+
removeEventListener<K extends keyof Emit | keyof HTMLElementEventMap>(type: K | string, listener: EventListenerOrListenerObj<Emit, K>, options?: boolean | EventListenerOptions): void;
|
|
45
|
+
}
|
|
46
|
+
export {};
|
|
@@ -0,0 +1,118 @@
|
|
|
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 { css } from "../../utils.mjs";
|
|
8
|
+
const styleStr = css(_a || (_a = __template(["\n/* firefox only: */\n@-moz-document url-prefix() {\n :host, * {\n scrollbar-width: thin;\n scrollbar-color: var(--scrollbar-thumb-color, #4444) transparent;\n }\n :host:hover, *:hover {\n scrollbar-color: var(--scrollbar-thumb-color-hover, var(--scrollbar-thumb-color, #8888)) transparent;\n }\n}\n"])));
|
|
9
|
+
const scrollbarStyleStr = css(_b || (_b = __template(["\n[dt]::-webkit-scrollbar, :host *::-webkit-scrollbar {\n width: 6px;\n height: 6px;\n}\n[dt]::-webkit-scrollbar-button, :host *::-webkit-scrollbar-button {\n display: none;\n}\n[dt]::-webkit-scrollbar-corner, :host *::-webkit-scrollbar-corner {\n display: none;\n}\n[dt]::-webkit-scrollbar-thumb, :host *::-webkit-scrollbar-thumb {\n background-color: var(--scrollbar-thumb-color, #4444);\n border-radius: 4px;\n cursor: grab;\n}\n[dt]::-webkit-scrollbar-thumb:hover, :host *::-webkit-scrollbar-thumb:hover {\n background-color: var(--scrollbar-thumb-color-hover, var(--scrollbar-thumb-color, #8888));\n}\n[dt]::-webkit-scrollbar-thumb:active, :host *::-webkit-scrollbar-thumb:active {\n background-color: var(--scrollbar-thumb-color-active, var(--scrollbar-thumb-color, #2222));\n cursor: grabbing;\n}\n[dt]::-webkit-scrollbar-track, :host *::-webkit-scrollbar-track {\n background: transparent;\n}\n"])));
|
|
10
|
+
const templateCache = /* @__PURE__ */ new Map();
|
|
11
|
+
if (typeof document === "object") {
|
|
12
|
+
const styleSheet = new CSSStyleSheet();
|
|
13
|
+
styleSheet.replaceSync(scrollbarStyleStr);
|
|
14
|
+
document.adoptedStyleSheets.unshift(styleSheet);
|
|
15
|
+
}
|
|
16
|
+
const HTMLElementBase = (() => {
|
|
17
|
+
if (typeof HTMLElement === "function") return HTMLElement;
|
|
18
|
+
return class {
|
|
19
|
+
};
|
|
20
|
+
})();
|
|
21
|
+
export class UiBase extends HTMLElementBase {
|
|
22
|
+
constructor() {
|
|
23
|
+
super();
|
|
24
|
+
__publicField(this, "_template", "");
|
|
25
|
+
__publicField(this, "_style", "");
|
|
26
|
+
this.attachShadow({ mode: "open" });
|
|
27
|
+
}
|
|
28
|
+
static define() {
|
|
29
|
+
if (this._definePromise) return this._definePromise;
|
|
30
|
+
if (typeof customElements === "undefined") {
|
|
31
|
+
return;
|
|
32
|
+
}
|
|
33
|
+
const tagName = this.tagName;
|
|
34
|
+
if (!tagName) throw new Error("UiBase.define: tagName is not defined.");
|
|
35
|
+
console.log("Define custom element:", tagName);
|
|
36
|
+
customElements.define(tagName, this);
|
|
37
|
+
return this._definePromise = customElements.whenDefined(tagName);
|
|
38
|
+
}
|
|
39
|
+
// TODO: use override keyword in subclasses
|
|
40
|
+
static get observedAttributes() {
|
|
41
|
+
return ["lang"];
|
|
42
|
+
}
|
|
43
|
+
_initTemplate() {
|
|
44
|
+
const { tagName } = this;
|
|
45
|
+
if (templateCache.has(tagName)) return templateCache.get(tagName);
|
|
46
|
+
const templateEle = document.createElement("template");
|
|
47
|
+
templateEle.innerHTML = "<style>".concat(scrollbarStyleStr).concat(styleStr).concat(this._style, "</style>").concat(this._template);
|
|
48
|
+
templateCache.set(tagName, templateEle);
|
|
49
|
+
return templateEle;
|
|
50
|
+
}
|
|
51
|
+
_applyTemplate() {
|
|
52
|
+
if (!this.shadowRoot) return;
|
|
53
|
+
this.shadowRoot.innerHTML = "";
|
|
54
|
+
this.shadowRoot.appendChild(
|
|
55
|
+
this._initTemplate().content.cloneNode(true)
|
|
56
|
+
);
|
|
57
|
+
}
|
|
58
|
+
_getAttr(qualifiedName, defaultValue) {
|
|
59
|
+
const attr = this.getAttribute(qualifiedName);
|
|
60
|
+
return attr === null && defaultValue !== void 0 ? defaultValue : attr;
|
|
61
|
+
}
|
|
62
|
+
_onAttrChanged(_name, _oldVal, _newVal) {
|
|
63
|
+
}
|
|
64
|
+
attributeChangedCallback(name, oldValue, newValue) {
|
|
65
|
+
var _a2;
|
|
66
|
+
if (oldValue === newValue) return;
|
|
67
|
+
if (name !== "lang")
|
|
68
|
+
return this._onAttrChanged(name, oldValue, newValue);
|
|
69
|
+
(_a2 = this.shadowRoot) == null ? void 0 : _a2.querySelectorAll("[dt]").forEach((ele) => {
|
|
70
|
+
if (newValue) {
|
|
71
|
+
ele.setAttribute("lang", newValue);
|
|
72
|
+
} else {
|
|
73
|
+
ele.removeAttribute("lang");
|
|
74
|
+
}
|
|
75
|
+
});
|
|
76
|
+
}
|
|
77
|
+
/** return false | void means not continue */
|
|
78
|
+
connectedCallback() {
|
|
79
|
+
this.setAttribute("dt", "");
|
|
80
|
+
return !!this.shadowRoot;
|
|
81
|
+
}
|
|
82
|
+
/** return false | void means not continue */
|
|
83
|
+
disconnectedCallback() {
|
|
84
|
+
return !!this.shadowRoot;
|
|
85
|
+
}
|
|
86
|
+
connectedMoveCallback() {
|
|
87
|
+
}
|
|
88
|
+
adoptedCallback() {
|
|
89
|
+
}
|
|
90
|
+
dispatchEvent(type, data, global = false) {
|
|
91
|
+
return type instanceof Event ? super.dispatchEvent(type) : super.dispatchEvent(
|
|
92
|
+
new CustomEvent(type, {
|
|
93
|
+
...global ? {
|
|
94
|
+
bubbles: true,
|
|
95
|
+
cancelable: true,
|
|
96
|
+
composed: true
|
|
97
|
+
} : {},
|
|
98
|
+
detail: data
|
|
99
|
+
})
|
|
100
|
+
);
|
|
101
|
+
}
|
|
102
|
+
addEventListener(type, listener, options) {
|
|
103
|
+
super.addEventListener(
|
|
104
|
+
type,
|
|
105
|
+
listener,
|
|
106
|
+
options
|
|
107
|
+
);
|
|
108
|
+
}
|
|
109
|
+
removeEventListener(type, listener, options) {
|
|
110
|
+
super.removeEventListener(
|
|
111
|
+
type,
|
|
112
|
+
listener,
|
|
113
|
+
options
|
|
114
|
+
);
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
__publicField(UiBase, "tagName", "");
|
|
118
|
+
__publicField(UiBase, "_definePromise", null);
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
[dt]::-webkit-scrollbar, :host *::-webkit-scrollbar {
|
|
2
|
+
width: 6px;
|
|
3
|
+
height: 6px;
|
|
4
|
+
}
|
|
5
|
+
[dt]::-webkit-scrollbar-button, :host *::-webkit-scrollbar-button {
|
|
6
|
+
display: none;
|
|
7
|
+
}
|
|
8
|
+
[dt]::-webkit-scrollbar-corner, :host *::-webkit-scrollbar-corner {
|
|
9
|
+
display: none;
|
|
10
|
+
}
|
|
11
|
+
[dt]::-webkit-scrollbar-thumb, :host *::-webkit-scrollbar-thumb {
|
|
12
|
+
background-color: var(--scrollbar-thumb-color, rgba(68, 68, 68, 0.2666666667));
|
|
13
|
+
border-radius: 4px;
|
|
14
|
+
cursor: grab;
|
|
15
|
+
}
|
|
16
|
+
[dt]::-webkit-scrollbar-thumb:hover, :host *::-webkit-scrollbar-thumb:hover {
|
|
17
|
+
background-color: var(--scrollbar-thumb-color-hover, var(--scrollbar-thumb-color, rgba(136, 136, 136, 0.5333333333)));
|
|
18
|
+
}
|
|
19
|
+
[dt]::-webkit-scrollbar-thumb:active, :host *::-webkit-scrollbar-thumb:active {
|
|
20
|
+
background-color: var(--scrollbar-thumb-color-active, var(--scrollbar-thumb-color, rgba(34, 34, 34, 0.1333333333)));
|
|
21
|
+
cursor: grabbing;
|
|
22
|
+
}
|
|
23
|
+
[dt]::-webkit-scrollbar-track, :host *::-webkit-scrollbar-track {
|
|
24
|
+
background: transparent;
|
|
25
|
+
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
:host {
|
|
2
|
+
display: flex;
|
|
3
|
+
flex-direction: column;
|
|
4
|
+
overflow: hidden;
|
|
5
|
+
gap: 15px;
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
.cols {
|
|
9
|
+
flex: 1;
|
|
10
|
+
display: flex;
|
|
11
|
+
flex-direction: row;
|
|
12
|
+
height: 0;
|
|
13
|
+
justify-content: space-between;
|
|
14
|
+
gap: 2px;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
.col {
|
|
18
|
+
flex: 1;
|
|
19
|
+
display: flex;
|
|
20
|
+
flex-direction: column;
|
|
21
|
+
gap: 10px;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
.col > span {
|
|
25
|
+
text-align: center;
|
|
26
|
+
display: inline-block;
|
|
27
|
+
line-height: 27px;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
dt-num-list {
|
|
31
|
+
flex: 1;
|
|
32
|
+
}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { type BaseAttrs, type Emit2EventMap, UiBase } from '../web-component-base';
|
|
2
|
+
export interface Attrs extends BaseAttrs {
|
|
3
|
+
millisecond: number;
|
|
4
|
+
/**
|
|
5
|
+
* 选择器的粒度,表示最大可选的时间单位。默认为 year。
|
|
6
|
+
* 例如设置为 'month',则表示最大只能选择到月份,年将被忽略。
|
|
7
|
+
*/
|
|
8
|
+
'max-granularity'?: 'year' | 'month' | 'day';
|
|
9
|
+
/**
|
|
10
|
+
* 选择器的粒度,表示最小可选的时间单位。默认为 second。
|
|
11
|
+
* 例如设置为 'month',则表示只能选择到月份,日会将被忽略。
|
|
12
|
+
*/
|
|
13
|
+
'min-granularity'?: 'year' | 'month' | 'day';
|
|
14
|
+
'col-order'?: 'ymd' | 'ydm' | 'myd' | 'mdy' | 'dym' | 'dmy';
|
|
15
|
+
}
|
|
16
|
+
export interface Emits {
|
|
17
|
+
change: {
|
|
18
|
+
oldMs: number;
|
|
19
|
+
newMs: number;
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
export type EventMap = Emit2EventMap<Emits>;
|
|
23
|
+
/**
|
|
24
|
+
* 日期选择器
|
|
25
|
+
*/
|
|
26
|
+
export declare class Ele extends UiBase<Attrs, Emits> {
|
|
27
|
+
static readonly tagName: "dt-yyyymmdd-list-grp";
|
|
28
|
+
static get observedAttributes(): string[];
|
|
29
|
+
protected _style: string;
|
|
30
|
+
protected _template: string;
|
|
31
|
+
constructor();
|
|
32
|
+
private get _listEleYear();
|
|
33
|
+
private get _listEleMonth();
|
|
34
|
+
private get _listEleDay();
|
|
35
|
+
get millisecond(): number;
|
|
36
|
+
set millisecond(v: number);
|
|
37
|
+
get maxGranularity(): "year" | "month" | "day";
|
|
38
|
+
set maxGranularity(v: 'year' | 'month' | 'day');
|
|
39
|
+
get minGranularity(): "year" | "month" | "day";
|
|
40
|
+
set minGranularity(v: 'year' | 'month' | 'day');
|
|
41
|
+
get colOrder(): "ymd" | "ydm" | "myd" | "mdy" | "dym" | "dmy";
|
|
42
|
+
set colOrder(v: 'ymd' | 'ydm' | 'myd' | 'mdy' | 'dym' | 'dmy');
|
|
43
|
+
scrollToCurrentItem(): void;
|
|
44
|
+
connectedCallback(): void;
|
|
45
|
+
disconnectedCallback(): void;
|
|
46
|
+
protected _onAttrChanged(name: string, oldValue: string, newValue: string): void;
|
|
47
|
+
private _renderCols;
|
|
48
|
+
private _updateGranularity;
|
|
49
|
+
private _updateColsValue;
|
|
50
|
+
private _getMsFromEle;
|
|
51
|
+
private _onColsSelect;
|
|
52
|
+
}
|