@gez/date-time-kit 2.0.0-alpha.21 → 2.0.0-alpha.22

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.
@@ -3,6 +3,8 @@ import { type reExportPopoverAttrs } from '../popover/attr-sync-helper';
3
3
  import { type BaseAttrs, type BaseEmits, type Emit2EventMap, UiBase } from '../web-component-base';
4
4
  import { type DataLimit, type GenPeriodTimesOptions, type PeriodTimeInfo, type QuickGenPeriodTimesOptions, type QuickKey, UTCInfo2LocaleInfo, genPeriodTimes, localeInfo2UTCInfo, quickGenPeriodTime, quickGenPeriodTimeInfo, quickGenPeriodTimes } from './quick-key';
5
5
  export { type QuickKey, type DataLimit, type GenPeriodTimesOptions, type QuickGenPeriodTimesOptions, type PeriodTimeInfo, type Weeks, genPeriodTimes, quickGenPeriodTime, quickGenPeriodTimes, quickGenPeriodTimeInfo, localeInfo2UTCInfo, UTCInfo2LocaleInfo };
6
+ export declare const granularityList: readonly ["day", "hour", "minute", "second", "millisecond"];
7
+ export type Granularity = (typeof granularityList)[number];
6
8
  export type Attrs = BaseAttrs & reExportPopoverAttrs & {
7
9
  /**
8
10
  * Timezone in minutes. For example: UTC+05:45 => `-345`, UTC-01:00 => `60`.
@@ -31,6 +33,11 @@ export type Attrs = BaseAttrs & reExportPopoverAttrs & {
31
33
  * End locale time of the quick selection. Only works in custom mode.
32
34
  */
33
35
  'end-time'?: string | number | '';
36
+ /**
37
+ * 选择器的粒度,表示最小可选的时间单位。默认为 millisecond。
38
+ * 例如设置为 'minute',则表示只能选择到分钟,秒和毫秒将被忽略。
39
+ */
40
+ 'min-granularity'?: Granularity;
34
41
  /**
35
42
  * Exclude some quick selection options.
36
43
  *
@@ -62,6 +69,8 @@ export declare class Ele extends UiBase<Attrs, Emits> {
62
69
  set startTime(val: number | string | Date);
63
70
  get endTime(): number | string | Date;
64
71
  set endTime(val: number | string | Date);
72
+ get minGranularity(): NonNullable<Attrs["min-granularity"]>;
73
+ set minGranularity(val: NonNullable<Attrs['min-granularity']>);
65
74
  get excludeField(): (QuickKey | "timezone")[];
66
75
  set excludeField(v: (QuickKey | 'timezone')[]);
67
76
  protected _style: string;
@@ -3,6 +3,7 @@ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { en
3
3
  var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
4
4
  import { debounce, getCurrentTzOffset } from "../../utils.mjs";
5
5
  import { weekKey } from "../calendar/index.mjs";
6
+ import { granularityList as timeGranularityList } from "../hhmmss-ms-list-grp/selector.mjs";
6
7
  import { Ele as PopoverEle } from "../popover/index.mjs";
7
8
  import {
8
9
  clearupPopEleAttrSync2Parent,
@@ -32,6 +33,7 @@ export {
32
33
  localeInfo2UTCInfo,
33
34
  UTCInfo2LocaleInfo
34
35
  };
36
+ export const granularityList = ["day", ...timeGranularityList];
35
37
  export class Ele extends UiBase {
36
38
  constructor() {
37
39
  super();
@@ -54,6 +56,7 @@ export class Ele extends UiBase {
54
56
  ele.timeStart = defaultPeriod.start;
55
57
  ele.timeEnd = defaultPeriod.end;
56
58
  }
59
+ ele.minGranularity = this.minGranularity;
57
60
  ele.showCalendarDatePoint();
58
61
  }, 0));
59
62
  __publicField(this, "_renderTz", debounce(() => {
@@ -144,6 +147,7 @@ export class Ele extends UiBase {
144
147
  "quick-key",
145
148
  "start-time",
146
149
  "end-time",
150
+ "min-granularity",
147
151
  "exclude-field",
148
152
  ...popoverAttrKeys
149
153
  ];
@@ -197,6 +201,13 @@ export class Ele extends UiBase {
197
201
  if (Number.isNaN(+v)) return;
198
202
  this.setAttribute("end-time", +v + "");
199
203
  }
204
+ get minGranularity() {
205
+ return this._getAttr("min-granularity", "millisecond");
206
+ }
207
+ set minGranularity(val) {
208
+ if (!granularityList.includes(val)) return;
209
+ this.setAttribute("min-granularity", val);
210
+ }
200
211
  get excludeField() {
201
212
  const v = this._getAttr("exclude-field", "") || "";
202
213
  if (v === "") 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.21",
23
+ "version": "2.0.0-alpha.22",
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": "3e500ac773a8879132d6d1b7f57e142d7d71bf2a"
42
+ "gitHead": "e09ca88e6677d715f924fc792cfe444cf7ab53ec"
43
43
  }
@@ -1,5 +1,6 @@
1
1
  import { debounce, getCurrentTzOffset } from '../../utils';
2
2
  import { type Weeks, weekKey } from '../calendar';
3
+ import { granularityList as timeGranularityList } from '../hhmmss-ms-list-grp/selector';
3
4
  import type { Ele as PeriodSelectorEle } from '../period-selector';
4
5
  import { Ele as PopoverEle, type EventMap as PopoverEvent } from '../popover';
5
6
  import {
@@ -47,6 +48,9 @@ export {
47
48
  UTCInfo2LocaleInfo
48
49
  };
49
50
 
51
+ export const granularityList = ['day', ...timeGranularityList] as const;
52
+ export type Granularity = (typeof granularityList)[number];
53
+
50
54
  export type Attrs = BaseAttrs &
51
55
  reExportPopoverAttrs & {
52
56
  /**
@@ -76,6 +80,11 @@ export type Attrs = BaseAttrs &
76
80
  * End locale time of the quick selection. Only works in custom mode.
77
81
  */
78
82
  'end-time'?: string | number | '';
83
+ /**
84
+ * 选择器的粒度,表示最小可选的时间单位。默认为 millisecond。
85
+ * 例如设置为 'minute',则表示只能选择到分钟,秒和毫秒将被忽略。
86
+ */
87
+ 'min-granularity'?: Granularity;
79
88
  /**
80
89
  * Exclude some quick selection options.
81
90
  *
@@ -106,6 +115,7 @@ export class Ele extends UiBase<Attrs, Emits> {
106
115
  'quick-key',
107
116
  'start-time',
108
117
  'end-time',
118
+ 'min-granularity',
109
119
  'exclude-field',
110
120
  ...popoverAttrKeys
111
121
  ] satisfies (keyof Attrs)[];
@@ -160,6 +170,13 @@ export class Ele extends UiBase<Attrs, Emits> {
160
170
  if (Number.isNaN(+v)) return;
161
171
  this.setAttribute('end-time', +v + '');
162
172
  }
173
+ public get minGranularity() {
174
+ return this._getAttr('min-granularity', 'millisecond');
175
+ }
176
+ public set minGranularity(val: NonNullable<Attrs['min-granularity']>) {
177
+ if (!granularityList.includes(val)) return;
178
+ this.setAttribute('min-granularity', val);
179
+ }
163
180
  public get excludeField() {
164
181
  const v = this._getAttr('exclude-field', '') || '';
165
182
  if (v === '') return [];
@@ -311,6 +328,7 @@ export class Ele extends UiBase<Attrs, Emits> {
311
328
  ele.timeStart = defaultPeriod.start;
312
329
  ele.timeEnd = defaultPeriod.end;
313
330
  }
331
+ ele.minGranularity = this.minGranularity;
314
332
  ele.showCalendarDatePoint();
315
333
  }, 0);
316
334