@gez/date-time-kit 2.0.0-alpha.19 → 2.0.0-alpha.20
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.
|
@@ -55,7 +55,7 @@ export declare class Ele extends UiBase<Attrs, Emits> {
|
|
|
55
55
|
static get observedAttributes(): string[];
|
|
56
56
|
private _getTimeAttr;
|
|
57
57
|
private _setTimeAttr;
|
|
58
|
-
private
|
|
58
|
+
private _getMaxMinTime;
|
|
59
59
|
get currentTime(): number | string | Date;
|
|
60
60
|
set currentTime(val: number | string | Date);
|
|
61
61
|
get showingTime(): number | string | Date;
|
|
@@ -35,7 +35,7 @@ export class Ele extends UiBase {
|
|
|
35
35
|
_calendar.weekStartAt = this.weekStartAt;
|
|
36
36
|
this._navEle.millisecond = _calendar.timeStart = _calendar.timeEnd = +currentTime;
|
|
37
37
|
_calendar.showingTime = this.showingTime;
|
|
38
|
-
const { min, max } = this.
|
|
38
|
+
const { min, max } = this._getMaxMinTime();
|
|
39
39
|
_calendar.minTime = min;
|
|
40
40
|
_calendar.maxTime = max;
|
|
41
41
|
if (this.minGranularity === "day") {
|
|
@@ -89,16 +89,17 @@ export class Ele extends UiBase {
|
|
|
89
89
|
if (Number.isNaN(+v)) return;
|
|
90
90
|
this.setAttribute(name, +v + "");
|
|
91
91
|
}
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
92
|
+
_getMaxMinTime({
|
|
93
|
+
min = +this._getTimeAttr("min-time", "NaN"),
|
|
94
|
+
max = +this._getTimeAttr("max-time", "NaN")
|
|
95
|
+
} = {}) {
|
|
95
96
|
if (Number.isNaN(min)) min = Number.NEGATIVE_INFINITY;
|
|
96
97
|
if (Number.isNaN(max)) max = Number.POSITIVE_INFINITY;
|
|
97
98
|
if (min > max) [min, max] = [max, min];
|
|
98
99
|
return { min, max };
|
|
99
100
|
}
|
|
100
101
|
get currentTime() {
|
|
101
|
-
const { min, max } = this.
|
|
102
|
+
const { min, max } = this._getMaxMinTime();
|
|
102
103
|
const currTime = this._getTimeAttr("current-time", "" + Date.now());
|
|
103
104
|
if (+currTime < min) return new Date(min);
|
|
104
105
|
if (+currTime > max) return new Date(max);
|
|
@@ -107,7 +108,7 @@ export class Ele extends UiBase {
|
|
|
107
108
|
set currentTime(val) {
|
|
108
109
|
const v = new Date(val);
|
|
109
110
|
if (Number.isNaN(+v)) return;
|
|
110
|
-
const { min, max } = this.
|
|
111
|
+
const { min, max } = this._getMaxMinTime();
|
|
111
112
|
this._setTimeAttr("current-time", Math.min(max, Math.max(min, +v)));
|
|
112
113
|
}
|
|
113
114
|
get showingTime() {
|
|
@@ -117,16 +118,24 @@ export class Ele extends UiBase {
|
|
|
117
118
|
this._setTimeAttr("showing-time", val);
|
|
118
119
|
}
|
|
119
120
|
get minTime() {
|
|
120
|
-
return this.
|
|
121
|
+
return this._getMaxMinTime().min;
|
|
121
122
|
}
|
|
122
123
|
set minTime(val) {
|
|
123
|
-
this.
|
|
124
|
+
const { min, max } = this._getMaxMinTime({
|
|
125
|
+
min: +new Date(Number.isNaN(+val) ? val : +val)
|
|
126
|
+
});
|
|
127
|
+
this._setTimeAttr("min-time", min);
|
|
128
|
+
this._setTimeAttr("max-time", max);
|
|
124
129
|
}
|
|
125
130
|
get maxTime() {
|
|
126
|
-
return this.
|
|
131
|
+
return this._getMaxMinTime().max;
|
|
127
132
|
}
|
|
128
133
|
set maxTime(val) {
|
|
129
|
-
this.
|
|
134
|
+
const { min, max } = this._getMaxMinTime({
|
|
135
|
+
max: +new Date(Number.isNaN(+val) ? val : +val)
|
|
136
|
+
});
|
|
137
|
+
this._setTimeAttr("min-time", min);
|
|
138
|
+
this._setTimeAttr("max-time", max);
|
|
130
139
|
}
|
|
131
140
|
get weekStartAt() {
|
|
132
141
|
return this._getAttr("week-start-at", "sun");
|
|
@@ -177,6 +186,7 @@ export class Ele extends UiBase {
|
|
|
177
186
|
this._onTimeSelectorChange
|
|
178
187
|
);
|
|
179
188
|
this._timeSelector.addEventListener("open-change", this._stopEvent);
|
|
189
|
+
this.dispatchEvent("select-time", this.currentTime);
|
|
180
190
|
}
|
|
181
191
|
disconnectedCallback() {
|
|
182
192
|
if (!super.disconnectedCallback()) return;
|
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.20",
|
|
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": "6a911eae4985534a9682a943846f75f4d551e76e"
|
|
43
43
|
}
|
|
@@ -107,16 +107,17 @@ export class Ele extends UiBase<Attrs, Emits> {
|
|
|
107
107
|
if (Number.isNaN(+v)) return;
|
|
108
108
|
this.setAttribute(name, +v + '');
|
|
109
109
|
}
|
|
110
|
-
private
|
|
111
|
-
|
|
112
|
-
|
|
110
|
+
private _getMaxMinTime({
|
|
111
|
+
min = +this._getTimeAttr('min-time', 'NaN'),
|
|
112
|
+
max = +this._getTimeAttr('max-time', 'NaN')
|
|
113
|
+
} = {}) {
|
|
113
114
|
if (Number.isNaN(min)) min = Number.NEGATIVE_INFINITY;
|
|
114
115
|
if (Number.isNaN(max)) max = Number.POSITIVE_INFINITY;
|
|
115
116
|
if (min > max) [min, max] = [max, min];
|
|
116
117
|
return { min, max };
|
|
117
118
|
}
|
|
118
119
|
public get currentTime() {
|
|
119
|
-
const { min, max } = this.
|
|
120
|
+
const { min, max } = this._getMaxMinTime();
|
|
120
121
|
const currTime = this._getTimeAttr('current-time', '' + Date.now());
|
|
121
122
|
if (+currTime < min) return new Date(min);
|
|
122
123
|
if (+currTime > max) return new Date(max);
|
|
@@ -125,7 +126,7 @@ export class Ele extends UiBase<Attrs, Emits> {
|
|
|
125
126
|
public set currentTime(val: number | string | Date) {
|
|
126
127
|
const v = new Date(val);
|
|
127
128
|
if (Number.isNaN(+v)) return;
|
|
128
|
-
const { min, max } = this.
|
|
129
|
+
const { min, max } = this._getMaxMinTime();
|
|
129
130
|
this._setTimeAttr('current-time', Math.min(max, Math.max(min, +v)));
|
|
130
131
|
}
|
|
131
132
|
public get showingTime() {
|
|
@@ -135,16 +136,24 @@ export class Ele extends UiBase<Attrs, Emits> {
|
|
|
135
136
|
this._setTimeAttr('showing-time', val);
|
|
136
137
|
}
|
|
137
138
|
public get minTime() {
|
|
138
|
-
return this.
|
|
139
|
+
return this._getMaxMinTime().min;
|
|
139
140
|
}
|
|
140
141
|
public set minTime(val: number | string | Date) {
|
|
141
|
-
this.
|
|
142
|
+
const { min, max } = this._getMaxMinTime({
|
|
143
|
+
min: +new Date(Number.isNaN(+val) ? val : +val)
|
|
144
|
+
});
|
|
145
|
+
this._setTimeAttr('min-time', min);
|
|
146
|
+
this._setTimeAttr('max-time', max);
|
|
142
147
|
}
|
|
143
148
|
public get maxTime() {
|
|
144
|
-
return this.
|
|
149
|
+
return this._getMaxMinTime().max;
|
|
145
150
|
}
|
|
146
151
|
public set maxTime(val: number | string | Date) {
|
|
147
|
-
this.
|
|
152
|
+
const { min, max } = this._getMaxMinTime({
|
|
153
|
+
max: +new Date(Number.isNaN(+val) ? val : +val)
|
|
154
|
+
});
|
|
155
|
+
this._setTimeAttr('min-time', min);
|
|
156
|
+
this._setTimeAttr('max-time', max);
|
|
148
157
|
}
|
|
149
158
|
public get weekStartAt() {
|
|
150
159
|
return this._getAttr('week-start-at', 'sun');
|
|
@@ -202,6 +211,7 @@ export class Ele extends UiBase<Attrs, Emits> {
|
|
|
202
211
|
this._onTimeSelectorChange
|
|
203
212
|
);
|
|
204
213
|
this._timeSelector.addEventListener('open-change', this._stopEvent);
|
|
214
|
+
this.dispatchEvent('select-time', this.currentTime as Date);
|
|
205
215
|
}
|
|
206
216
|
public disconnectedCallback() {
|
|
207
217
|
if (!super.disconnectedCallback()) return;
|
|
@@ -248,7 +258,7 @@ export class Ele extends UiBase<Attrs, Emits> {
|
|
|
248
258
|
_calendar.timeEnd =
|
|
249
259
|
+currentTime;
|
|
250
260
|
_calendar.showingTime = this.showingTime;
|
|
251
|
-
const { min, max } = this.
|
|
261
|
+
const { min, max } = this._getMaxMinTime();
|
|
252
262
|
_calendar.minTime = min;
|
|
253
263
|
_calendar.maxTime = max;
|
|
254
264
|
|