@gez/date-time-kit 2.0.0-alpha.11 → 2.0.0-alpha.13
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/quick-selector/index.d.ts +3 -3
- package/dist/components/quick-selector/quick-key.d.ts +4 -4
- package/dist/components/quick-selector/quick-key.mjs +13 -4
- package/dist/index.d.ts +1 -1
- package/dist/index.mjs +2 -1
- package/package.json +2 -2
- package/src/components/quick-selector/index.ts +2 -0
- package/src/components/quick-selector/quick-key.ts +31 -18
- package/src/index.ts +1 -0
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { type Weeks } from '../calendar';
|
|
2
2
|
import { type BaseAttrs, type Emit2EventMap, UiBase } from '../web-component-base';
|
|
3
|
-
import { type DataLimit, type GenPeriodTimesOptions, type PeriodTimeInfo, type QuickKey, genPeriodTimes, quickGenPeriodTime, quickGenPeriodTimeInfo, quickGenPeriodTimes } from './quick-key';
|
|
4
|
-
export { type QuickKey, type DataLimit, type GenPeriodTimesOptions, type PeriodTimeInfo, type Weeks, genPeriodTimes, quickGenPeriodTime, quickGenPeriodTimes, quickGenPeriodTimeInfo };
|
|
3
|
+
import { type DataLimit, type GenPeriodTimesOptions, type PeriodTimeInfo, type QuickGenPeriodTimesOptions, type QuickKey, genPeriodTimes, quickGenPeriodTime, quickGenPeriodTimeInfo, quickGenPeriodTimes } from './quick-key';
|
|
4
|
+
export { type QuickKey, type DataLimit, type GenPeriodTimesOptions, type QuickGenPeriodTimesOptions, type PeriodTimeInfo, type Weeks, genPeriodTimes, quickGenPeriodTime, quickGenPeriodTimes, quickGenPeriodTimeInfo };
|
|
5
5
|
export interface Attrs extends BaseAttrs {
|
|
6
6
|
/**
|
|
7
7
|
* Timezone in minutes. For example: UTC+05:45 => `345`, UTC-01:00 => `-60`.
|
|
@@ -83,5 +83,5 @@ export declare class Ele extends UiBase<Attrs, Emits> {
|
|
|
83
83
|
start: Date;
|
|
84
84
|
end: Date;
|
|
85
85
|
};
|
|
86
|
-
readonly quickGenPeriodTimeInfo: <T extends DataLimit = DataLimit>(type: T) => PeriodTimeInfo<T>;
|
|
86
|
+
readonly quickGenPeriodTimeInfo: <T extends DataLimit = DataLimit>(type: T) => PeriodTimeInfo<T, Date>;
|
|
87
87
|
}
|
|
@@ -27,13 +27,13 @@ export declare const quickGenPeriodTime: <T extends DataLimit = DataLimit>(perio
|
|
|
27
27
|
start: Date;
|
|
28
28
|
end: Date;
|
|
29
29
|
};
|
|
30
|
-
export type PeriodTimeInfo<T extends QuickKey = QuickKey> = {
|
|
30
|
+
export type PeriodTimeInfo<T extends QuickKey = QuickKey, RT = Date> = T extends 'all' ? {
|
|
31
31
|
type: 'all';
|
|
32
32
|
start?: null;
|
|
33
33
|
end?: null;
|
|
34
|
-
}
|
|
34
|
+
} : {
|
|
35
35
|
type: Exclude<T, 'all'>;
|
|
36
|
-
start:
|
|
37
|
-
end:
|
|
36
|
+
start: RT;
|
|
37
|
+
end: RT;
|
|
38
38
|
};
|
|
39
39
|
export declare const quickGenPeriodTimeInfo: <T extends DataLimit = DataLimit>(type: T, options?: QuickGenPeriodTimesOptions) => PeriodTimeInfo<T>;
|
|
@@ -33,9 +33,15 @@ export const genPeriodTimes = ({
|
|
|
33
33
|
end: genEndDate((t) => end == null ? void 0 : end(t, weekOffset), new Date(initTime))
|
|
34
34
|
};
|
|
35
35
|
};
|
|
36
|
+
const noop = () => {
|
|
37
|
+
};
|
|
36
38
|
const presetPeriods = {
|
|
37
39
|
all: () => null,
|
|
38
|
-
today: (ops) => genPeriodTimes(
|
|
40
|
+
today: (ops) => genPeriodTimes({
|
|
41
|
+
...ops,
|
|
42
|
+
start: noop,
|
|
43
|
+
end: noop
|
|
44
|
+
}),
|
|
39
45
|
yesterday: (ops) => genPeriodTimes({
|
|
40
46
|
...ops,
|
|
41
47
|
start: (t) => t.setDate(t.getDate() - 1),
|
|
@@ -53,7 +59,8 @@ const presetPeriods = {
|
|
|
53
59
|
}),
|
|
54
60
|
last7Days: (ops) => genPeriodTimes({
|
|
55
61
|
...ops,
|
|
56
|
-
start: (t) => t.setDate(t.getDate() - 6)
|
|
62
|
+
start: (t) => t.setDate(t.getDate() - 6),
|
|
63
|
+
end: noop
|
|
57
64
|
}),
|
|
58
65
|
month: (ops) => genPeriodTimes({
|
|
59
66
|
...ops,
|
|
@@ -62,11 +69,13 @@ const presetPeriods = {
|
|
|
62
69
|
}),
|
|
63
70
|
last30Days: (ops) => genPeriodTimes({
|
|
64
71
|
...ops,
|
|
65
|
-
start: (t) => t.setDate(t.getDate() - 29)
|
|
72
|
+
start: (t) => t.setDate(t.getDate() - 29),
|
|
73
|
+
end: noop
|
|
66
74
|
}),
|
|
67
75
|
last180Days: (ops) => genPeriodTimes({
|
|
68
76
|
...ops,
|
|
69
|
-
start: (t) => t.setDate(t.getDate() - 179)
|
|
77
|
+
start: (t) => t.setDate(t.getDate() - 179),
|
|
78
|
+
end: noop
|
|
70
79
|
}),
|
|
71
80
|
last6Month: (ops) => genPeriodTimes({
|
|
72
81
|
...ops,
|
package/dist/index.d.ts
CHANGED
|
@@ -5,4 +5,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
7
|
export * as DtDataTimeSelector from './components/date-time-selector';
|
|
8
|
-
export { i18n as dtI18n, type Lang as DtLang, type I18n as DtI18n } from './i18n';
|
|
8
|
+
export { i18n as dtI18n, langs as dtLangsList, type Lang as DtLang, type I18n as DtI18n } from './i18n';
|
package/dist/index.mjs
CHANGED
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.13",
|
|
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": "53fc0a1fa8e300ca6b7005bdfc36dc07f4dfcc86"
|
|
40
40
|
}
|
|
@@ -13,6 +13,7 @@ import {
|
|
|
13
13
|
type DataLimit,
|
|
14
14
|
type GenPeriodTimesOptions,
|
|
15
15
|
type PeriodTimeInfo,
|
|
16
|
+
type QuickGenPeriodTimesOptions,
|
|
16
17
|
type QuickKey,
|
|
17
18
|
genPeriodTimes,
|
|
18
19
|
quickGenPeriodTime,
|
|
@@ -24,6 +25,7 @@ export {
|
|
|
24
25
|
type QuickKey,
|
|
25
26
|
type DataLimit,
|
|
26
27
|
type GenPeriodTimesOptions,
|
|
28
|
+
type QuickGenPeriodTimesOptions,
|
|
27
29
|
type PeriodTimeInfo,
|
|
28
30
|
type Weeks,
|
|
29
31
|
genPeriodTimes,
|
|
@@ -57,16 +57,23 @@ export const genPeriodTimes = ({
|
|
|
57
57
|
};
|
|
58
58
|
};
|
|
59
59
|
|
|
60
|
+
const noop = () => {};
|
|
61
|
+
|
|
60
62
|
const presetPeriods = {
|
|
61
63
|
all: () => null,
|
|
62
|
-
today: (ops:
|
|
63
|
-
|
|
64
|
+
today: (ops: QuickGenPeriodTimesOptions) =>
|
|
65
|
+
genPeriodTimes({
|
|
66
|
+
...ops,
|
|
67
|
+
start: noop,
|
|
68
|
+
end: noop
|
|
69
|
+
}),
|
|
70
|
+
yesterday: (ops: QuickGenPeriodTimesOptions) =>
|
|
64
71
|
genPeriodTimes({
|
|
65
72
|
...ops,
|
|
66
73
|
start: (t) => t.setDate(t.getDate() - 1),
|
|
67
74
|
end: (t) => t.setDate(t.getDate() - 1)
|
|
68
75
|
}),
|
|
69
|
-
week: (ops:
|
|
76
|
+
week: (ops: QuickGenPeriodTimesOptions) =>
|
|
70
77
|
genPeriodTimes({
|
|
71
78
|
...ops,
|
|
72
79
|
start: (t, weekOffset) =>
|
|
@@ -74,7 +81,7 @@ const presetPeriods = {
|
|
|
74
81
|
end: (t, weekOffset) =>
|
|
75
82
|
t.setDate(t.getDate() - t.getDay() + weekOffset + 6)
|
|
76
83
|
}),
|
|
77
|
-
lastWeek: (ops:
|
|
84
|
+
lastWeek: (ops: QuickGenPeriodTimesOptions) =>
|
|
78
85
|
genPeriodTimes({
|
|
79
86
|
...ops,
|
|
80
87
|
start: (t, weekOffset) =>
|
|
@@ -82,34 +89,37 @@ const presetPeriods = {
|
|
|
82
89
|
end: (t, weekOffset) =>
|
|
83
90
|
t.setDate(t.getDate() - t.getDay() + weekOffset - 1)
|
|
84
91
|
}),
|
|
85
|
-
last7Days: (ops:
|
|
92
|
+
last7Days: (ops: QuickGenPeriodTimesOptions) =>
|
|
86
93
|
genPeriodTimes({
|
|
87
94
|
...ops,
|
|
88
|
-
start: (t) => t.setDate(t.getDate() - 6)
|
|
95
|
+
start: (t) => t.setDate(t.getDate() - 6),
|
|
96
|
+
end: noop
|
|
89
97
|
}),
|
|
90
|
-
month: (ops:
|
|
98
|
+
month: (ops: QuickGenPeriodTimesOptions) =>
|
|
91
99
|
genPeriodTimes({
|
|
92
100
|
...ops,
|
|
93
101
|
start: (t) => t.setDate(1),
|
|
94
102
|
end: (t) => t.setMonth(t.getMonth() + 1, 0)
|
|
95
103
|
}),
|
|
96
|
-
last30Days: (ops:
|
|
104
|
+
last30Days: (ops: QuickGenPeriodTimesOptions) =>
|
|
97
105
|
genPeriodTimes({
|
|
98
106
|
...ops,
|
|
99
|
-
start: (t) => t.setDate(t.getDate() - 29)
|
|
107
|
+
start: (t) => t.setDate(t.getDate() - 29),
|
|
108
|
+
end: noop
|
|
100
109
|
}),
|
|
101
|
-
last180Days: (ops:
|
|
110
|
+
last180Days: (ops: QuickGenPeriodTimesOptions) =>
|
|
102
111
|
genPeriodTimes({
|
|
103
112
|
...ops,
|
|
104
|
-
start: (t) => t.setDate(t.getDate() - 179)
|
|
113
|
+
start: (t) => t.setDate(t.getDate() - 179),
|
|
114
|
+
end: noop
|
|
105
115
|
}),
|
|
106
|
-
last6Month: (ops:
|
|
116
|
+
last6Month: (ops: QuickGenPeriodTimesOptions) =>
|
|
107
117
|
genPeriodTimes({
|
|
108
118
|
...ops,
|
|
109
119
|
start: (t) => t.setMonth(t.getMonth() - 5, 1),
|
|
110
120
|
end: (t) => t.setMonth(t.getMonth() + 1, 0)
|
|
111
121
|
}),
|
|
112
|
-
year: (ops:
|
|
122
|
+
year: (ops: QuickGenPeriodTimesOptions) =>
|
|
113
123
|
genPeriodTimes({
|
|
114
124
|
...ops,
|
|
115
125
|
start: (t) => t.setMonth(0, 1),
|
|
@@ -136,16 +146,19 @@ export const quickGenPeriodTime = <T extends DataLimit = DataLimit>(
|
|
|
136
146
|
? null
|
|
137
147
|
: { start: Date; end: Date };
|
|
138
148
|
|
|
139
|
-
export type PeriodTimeInfo<
|
|
140
|
-
|
|
149
|
+
export type PeriodTimeInfo<
|
|
150
|
+
T extends QuickKey = QuickKey,
|
|
151
|
+
RT = Date
|
|
152
|
+
> = T extends 'all'
|
|
153
|
+
? {
|
|
141
154
|
type: 'all';
|
|
142
155
|
start?: null;
|
|
143
156
|
end?: null;
|
|
144
157
|
}
|
|
145
|
-
|
|
158
|
+
: {
|
|
146
159
|
type: Exclude<T, 'all'>;
|
|
147
|
-
start:
|
|
148
|
-
end:
|
|
160
|
+
start: RT;
|
|
161
|
+
end: RT;
|
|
149
162
|
};
|
|
150
163
|
|
|
151
164
|
export const quickGenPeriodTimeInfo = <T extends DataLimit = DataLimit>(
|