@gez/date-time-kit 2.0.0-alpha.16 → 2.0.0-alpha.18
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/popover/css.mjs +1 -1
- package/dist/components/quick-selector/index.mjs +24 -20
- package/dist/components/quick-selector/quick-key.mjs +2 -0
- package/package.json +2 -2
- package/src/components/popover/css.ts +1 -1
- package/src/components/quick-selector/index.ts +8 -4
- package/src/components/quick-selector/quick-key.ts +2 -0
|
@@ -4,4 +4,4 @@ var __template = (cooked, raw) => __freeze(__defProp(cooked, "raw", { value: __f
|
|
|
4
4
|
var _a;
|
|
5
5
|
import { closeBarSvg, svg2cssUrl } from "../../assets/index.mjs";
|
|
6
6
|
import { css } from "../../utils.mjs";
|
|
7
|
-
export const styleStr = css(_a || (_a = __template(["\n::slotted([slot='pop']:not(.not-pop-bg)) {\n background-color: var(--dt-bg-block-light, #fff);\n padding: 10px 5px;\n border-radius: 6px;\n border: 1px solid var(--dt-border-dark, #0000001A);\n box-shadow: var(--dt-pop-box-shadow, 0 6px 16px #0003);\n}\n:host(:not([open])) slot[name='pop'] { display: none; }\n:host([open]:not([strategy='none'])) slot[name='pop'] { display: block; }\n\n:host(:not([strategy='none'])) slot[name='pop'] {\n position: fixed;\n z-index: var(--dt-pop-z-index, 9999);\n top: 0;\n left: 0;\n}\n:host([strategy='absolute']) slot[name='pop'] { position: absolute; }\n:host([strategy='absolute']) { position: relative; }\n\n@media (max-width: 750px) {\n :host([open]) slot[name='pop'] {\n width: 100vw;\n max-height: min(90vh, 600px);\n top: unset;\n left: 0;\n bottom: 0;\n position: fixed;\n }\n :host([open]) slot[name='pop']::after, :host([open]) slot[name='pop']::before {\n content: '';\n display: block;\n position: absolute;\n }\n :host([open]) slot[name='pop']::before {\n bottom: 100%;\n left: 0;\n right: 0;\n height: 24px;\n border-radius: 20px 20px 0 0;\n background: var(--dt-bg-block-light, #fff);\n }\n :host([open]) slot[name='pop']::after {\n bottom: calc(100% + (24px - 4px) / 2);\n left: 50%;\n transform: translateX(-50%);\n width: 40px;\n height: 4px;\n background: var(--dt-border-dark, #0000001A);\n mask-image: ", ";\n -webkit-mask-image: ", ";\n cursor: pointer;\n }\n ::slotted([slot='pop']:not(.not-pop-bg)) {\n padding: 15px;\n border-radius: 0;\n border: none;\n box-shadow: none;\n }\n /* for masking */\n :host([open]:not([strategy='none']))::before {\n content: '';\n position: fixed;\n top: 0;\n left: 0;\n right: 0;\n bottom: 0;\n background-color: #0008;\n z-index: var(--dt-pop-z-index, 9999);\n }\n}\n"])), svg2cssUrl(closeBarSvg), svg2cssUrl(closeBarSvg));
|
|
7
|
+
export const styleStr = css(_a || (_a = __template(["\n::slotted([slot='pop']:not(.not-pop-bg)) {\n background-color: var(--dt-bg-block-light, #fff);\n padding: 10px 5px;\n border-radius: var(--dt-pop-border-radius, 6px);\n border: 1px solid var(--dt-border-dark, #0000001A);\n box-shadow: var(--dt-pop-box-shadow, 0 6px 16px #0003);\n}\n:host(:not([open])) slot[name='pop'] { display: none; }\n:host([open]:not([strategy='none'])) slot[name='pop'] { display: block; }\n\n:host(:not([strategy='none'])) slot[name='pop'] {\n position: fixed;\n z-index: var(--dt-pop-z-index, 9999);\n top: 0;\n left: 0;\n}\n:host([strategy='absolute']) slot[name='pop'] { position: absolute; }\n:host([strategy='absolute']) { position: relative; }\n\n@media (max-width: 750px) {\n :host([open]) slot[name='pop'] {\n width: 100vw;\n max-height: min(90vh, 600px);\n top: unset;\n left: 0;\n bottom: 0;\n position: fixed;\n }\n :host([open]) slot[name='pop']::after, :host([open]) slot[name='pop']::before {\n content: '';\n display: block;\n position: absolute;\n }\n :host([open]) slot[name='pop']::before {\n bottom: 100%;\n left: 0;\n right: 0;\n height: 24px;\n border-radius: 20px 20px 0 0;\n background: var(--dt-bg-block-light, #fff);\n }\n :host([open]) slot[name='pop']::after {\n bottom: calc(100% + (24px - 4px) / 2);\n left: 50%;\n transform: translateX(-50%);\n width: 40px;\n height: 4px;\n background: var(--dt-border-dark, #0000001A);\n mask-image: ", ";\n -webkit-mask-image: ", ";\n cursor: pointer;\n }\n ::slotted([slot='pop']:not(.not-pop-bg)) {\n padding: 15px;\n border-radius: 0;\n border: none;\n box-shadow: none;\n }\n /* for masking */\n :host([open]:not([strategy='none']))::before {\n content: '';\n position: fixed;\n top: 0;\n left: 0;\n right: 0;\n bottom: 0;\n background-color: #0008;\n z-index: var(--dt-pop-z-index, 9999);\n }\n}\n"])), svg2cssUrl(closeBarSvg), svg2cssUrl(closeBarSvg));
|
|
@@ -85,6 +85,24 @@ export class Ele extends UiBase {
|
|
|
85
85
|
this._showMenu("custom");
|
|
86
86
|
});
|
|
87
87
|
__publicField(this, "_onBackBtnClick", () => this._showMenu("top"));
|
|
88
|
+
__publicField(this, "_dispatchTimeChangeEvent", debounce(() => {
|
|
89
|
+
const quickKey = this.quickKey;
|
|
90
|
+
if (quickKey !== "custom") {
|
|
91
|
+
const t = this.quickGenPeriodTimeInfo(quickKey);
|
|
92
|
+
this.dispatchEvent("time-changed", t, true);
|
|
93
|
+
return;
|
|
94
|
+
}
|
|
95
|
+
this.dispatchEvent(
|
|
96
|
+
"time-changed",
|
|
97
|
+
{
|
|
98
|
+
tzOffset: this.tzOffset,
|
|
99
|
+
start: this.startTime,
|
|
100
|
+
end: this.endTime,
|
|
101
|
+
type: "custom"
|
|
102
|
+
},
|
|
103
|
+
true
|
|
104
|
+
);
|
|
105
|
+
}));
|
|
88
106
|
__publicField(this, "_onRadioChange", (e) => {
|
|
89
107
|
if (!(e.target instanceof HTMLInputElement)) return;
|
|
90
108
|
if (e.target.type !== "radio") return;
|
|
@@ -93,7 +111,6 @@ export class Ele extends UiBase {
|
|
|
93
111
|
const v = value;
|
|
94
112
|
if (v === "custom") return;
|
|
95
113
|
this.quickKey = v;
|
|
96
|
-
this._dispatchTimeChangeEvent();
|
|
97
114
|
} else if (name === "tz") {
|
|
98
115
|
this.tzOffset = +value;
|
|
99
116
|
}
|
|
@@ -102,6 +119,10 @@ export class Ele extends UiBase {
|
|
|
102
119
|
const selector = this._periodSelector;
|
|
103
120
|
selector.abortSelecting();
|
|
104
121
|
this._showMenu("top");
|
|
122
|
+
let { timeStart, timeEnd } = this._periodSelector;
|
|
123
|
+
if (timeStart > timeEnd) [timeStart, timeEnd] = [timeEnd, timeStart];
|
|
124
|
+
this.startTime = timeStart;
|
|
125
|
+
this.endTime = timeEnd;
|
|
105
126
|
this.quickKey = "custom";
|
|
106
127
|
this._dispatchTimeChangeEvent();
|
|
107
128
|
});
|
|
@@ -174,7 +195,7 @@ export class Ele extends UiBase {
|
|
|
174
195
|
}
|
|
175
196
|
const v = new Date(val);
|
|
176
197
|
if (Number.isNaN(+v)) return;
|
|
177
|
-
this.setAttribute("time
|
|
198
|
+
this.setAttribute("end-time", +v + "");
|
|
178
199
|
}
|
|
179
200
|
get excludeField() {
|
|
180
201
|
const v = this._getAttr("exclude-field", "") || "";
|
|
@@ -279,6 +300,7 @@ export class Ele extends UiBase {
|
|
|
279
300
|
}
|
|
280
301
|
if (name === "quick-key") {
|
|
281
302
|
this._updateRadio();
|
|
303
|
+
this._dispatchTimeChangeEvent();
|
|
282
304
|
}
|
|
283
305
|
if (name === "week-start-at") {
|
|
284
306
|
this._updatePeriodSelector();
|
|
@@ -298,24 +320,6 @@ export class Ele extends UiBase {
|
|
|
298
320
|
this._updatePeriodSelector();
|
|
299
321
|
}
|
|
300
322
|
}
|
|
301
|
-
_dispatchTimeChangeEvent() {
|
|
302
|
-
const quickKey = this.quickKey;
|
|
303
|
-
if (quickKey !== "custom") {
|
|
304
|
-
const t = this.quickGenPeriodTimeInfo(quickKey);
|
|
305
|
-
this.dispatchEvent("time-changed", t, true);
|
|
306
|
-
return;
|
|
307
|
-
}
|
|
308
|
-
this.dispatchEvent(
|
|
309
|
-
"time-changed",
|
|
310
|
-
{
|
|
311
|
-
tzOffset: this.tzOffset,
|
|
312
|
-
start: this.startTime,
|
|
313
|
-
end: this.endTime,
|
|
314
|
-
type: "custom"
|
|
315
|
-
},
|
|
316
|
-
true
|
|
317
|
-
);
|
|
318
|
-
}
|
|
319
323
|
}
|
|
320
324
|
__publicField(Ele, "tagName", "dt-quick-selector");
|
|
321
325
|
Ele.define();
|
|
@@ -105,6 +105,7 @@ export const quickGenPeriodTimeInfo = (type, options = {}, tzOffset = getCurrent
|
|
|
105
105
|
return !t ? { type, tzOffset } : { type, ...t, tzOffset };
|
|
106
106
|
};
|
|
107
107
|
export const localeInfo2UTCInfo = (info) => {
|
|
108
|
+
info = { ...info };
|
|
108
109
|
if (info.type === "all") return info;
|
|
109
110
|
const { tzOffset, start, end } = info;
|
|
110
111
|
info.start = new Date(
|
|
@@ -114,6 +115,7 @@ export const localeInfo2UTCInfo = (info) => {
|
|
|
114
115
|
return info;
|
|
115
116
|
};
|
|
116
117
|
export const UTCInfo2LocaleInfo = (info) => {
|
|
118
|
+
info = { ...info };
|
|
117
119
|
if (info.type === "all") return info;
|
|
118
120
|
const { tzOffset, start, end } = info;
|
|
119
121
|
info.start = new Date(
|
package/package.json
CHANGED
|
@@ -20,7 +20,7 @@
|
|
|
20
20
|
"unbuild": "3.6.0",
|
|
21
21
|
"vitest": "3.2.4"
|
|
22
22
|
},
|
|
23
|
-
"version": "2.0.0-alpha.
|
|
23
|
+
"version": "2.0.0-alpha.18",
|
|
24
24
|
"type": "module",
|
|
25
25
|
"private": false,
|
|
26
26
|
"exports": {
|
|
@@ -39,5 +39,5 @@
|
|
|
39
39
|
"template",
|
|
40
40
|
"public"
|
|
41
41
|
],
|
|
42
|
-
"gitHead": "
|
|
42
|
+
"gitHead": "58e79732be2ec46ffe4cc21495b2e88e6d12c340"
|
|
43
43
|
}
|
|
@@ -5,7 +5,7 @@ export const styleStr = css`
|
|
|
5
5
|
::slotted([slot='pop']:not(.not-pop-bg)) {
|
|
6
6
|
background-color: var(--dt-bg-block-light, #fff);
|
|
7
7
|
padding: 10px 5px;
|
|
8
|
-
border-radius: 6px;
|
|
8
|
+
border-radius: var(--dt-pop-border-radius, 6px);
|
|
9
9
|
border: 1px solid var(--dt-border-dark, #0000001A);
|
|
10
10
|
box-shadow: var(--dt-pop-box-shadow, 0 6px 16px #0003);
|
|
11
11
|
}
|
|
@@ -158,7 +158,7 @@ export class Ele extends UiBase<Attrs, Emits> {
|
|
|
158
158
|
}
|
|
159
159
|
const v = new Date(val);
|
|
160
160
|
if (Number.isNaN(+v)) return;
|
|
161
|
-
this.setAttribute('time
|
|
161
|
+
this.setAttribute('end-time', +v + '');
|
|
162
162
|
}
|
|
163
163
|
public get excludeField() {
|
|
164
164
|
const v = this._getAttr('exclude-field', '') || '';
|
|
@@ -281,6 +281,7 @@ export class Ele extends UiBase<Attrs, Emits> {
|
|
|
281
281
|
}
|
|
282
282
|
if (name === 'quick-key') {
|
|
283
283
|
this._updateRadio();
|
|
284
|
+
this._dispatchTimeChangeEvent();
|
|
284
285
|
}
|
|
285
286
|
if (name === 'week-start-at') {
|
|
286
287
|
this._updatePeriodSelector();
|
|
@@ -357,7 +358,7 @@ export class Ele extends UiBase<Attrs, Emits> {
|
|
|
357
358
|
};
|
|
358
359
|
private _onBackBtnClick = () => this._showMenu('top');
|
|
359
360
|
|
|
360
|
-
private _dispatchTimeChangeEvent() {
|
|
361
|
+
private _dispatchTimeChangeEvent = debounce(() => {
|
|
361
362
|
const quickKey = this.quickKey;
|
|
362
363
|
if (quickKey !== 'custom') {
|
|
363
364
|
const t = this.quickGenPeriodTimeInfo(quickKey);
|
|
@@ -374,7 +375,7 @@ export class Ele extends UiBase<Attrs, Emits> {
|
|
|
374
375
|
},
|
|
375
376
|
true
|
|
376
377
|
);
|
|
377
|
-
}
|
|
378
|
+
});
|
|
378
379
|
private _onRadioChange = (e: Event) => {
|
|
379
380
|
if (!(e.target instanceof HTMLInputElement)) return;
|
|
380
381
|
if (e.target.type !== 'radio') return;
|
|
@@ -383,7 +384,6 @@ export class Ele extends UiBase<Attrs, Emits> {
|
|
|
383
384
|
const v = value as QuickKey;
|
|
384
385
|
if (v === 'custom') return;
|
|
385
386
|
this.quickKey = v;
|
|
386
|
-
this._dispatchTimeChangeEvent();
|
|
387
387
|
} else if (name === 'tz') {
|
|
388
388
|
this.tzOffset = +value;
|
|
389
389
|
}
|
|
@@ -392,6 +392,10 @@ export class Ele extends UiBase<Attrs, Emits> {
|
|
|
392
392
|
const selector = this._periodSelector;
|
|
393
393
|
selector.abortSelecting();
|
|
394
394
|
this._showMenu('top');
|
|
395
|
+
let { timeStart, timeEnd } = this._periodSelector;
|
|
396
|
+
if (timeStart > timeEnd) [timeStart, timeEnd] = [timeEnd, timeStart];
|
|
397
|
+
this.startTime = timeStart;
|
|
398
|
+
this.endTime = timeEnd;
|
|
395
399
|
this.quickKey = 'custom';
|
|
396
400
|
this._dispatchTimeChangeEvent();
|
|
397
401
|
};
|
|
@@ -183,6 +183,7 @@ export const quickGenPeriodTimeInfo = <T extends DataLimit = DataLimit>(
|
|
|
183
183
|
};
|
|
184
184
|
|
|
185
185
|
export const localeInfo2UTCInfo = (info: PeriodTimeInfo) => {
|
|
186
|
+
info = { ...info };
|
|
186
187
|
if (info.type === 'all') return info;
|
|
187
188
|
const { tzOffset, start, end } = info;
|
|
188
189
|
info.start = new Date(
|
|
@@ -193,6 +194,7 @@ export const localeInfo2UTCInfo = (info: PeriodTimeInfo) => {
|
|
|
193
194
|
};
|
|
194
195
|
|
|
195
196
|
export const UTCInfo2LocaleInfo = (info: PeriodTimeInfo) => {
|
|
197
|
+
info = { ...info };
|
|
196
198
|
if (info.type === 'all') return info;
|
|
197
199
|
const { tzOffset, start, end } = info;
|
|
198
200
|
info.start = new Date(
|