@gez/date-time-kit 2.0.0-alpha.0 → 2.0.0-alpha.2

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.
Files changed (31) hide show
  1. package/dist/components/calendar/index.d.ts +1 -1
  2. package/dist/components/calendar/index.mjs +1 -1
  3. package/dist/components/date-time-selector/index.d.ts +61 -0
  4. package/dist/components/date-time-selector/index.mjs +212 -0
  5. package/dist/components/date-time-selector/styleStr.d.ts +1 -0
  6. package/dist/components/date-time-selector/styleStr.mjs +6 -0
  7. package/dist/components/hhmmss-ms-list-grp/index.d.ts +3 -3
  8. package/dist/components/hhmmss-ms-list-grp/index.mjs +35 -33
  9. package/dist/components/period-selector/index.css +2 -1
  10. package/dist/components/period-selector/index.d.ts +9 -0
  11. package/dist/components/period-selector/index.mjs +31 -12
  12. package/dist/components/quick-selector/index.d.ts +14 -2
  13. package/dist/components/quick-selector/index.mjs +89 -57
  14. package/dist/components/{period-selector/date-nav.d.ts → yyyymm-nav/index.d.ts} +4 -6
  15. package/dist/components/{period-selector/date-nav.mjs → yyyymm-nav/index.mjs} +9 -10
  16. package/dist/components/yyyymmdd-list-grp/index.mjs +6 -6
  17. package/dist/index.d.ts +1 -0
  18. package/dist/index.mjs +2 -0
  19. package/package.json +2 -2
  20. package/src/components/calendar/index.ts +2 -2
  21. package/src/components/date-time-selector/index.ts +291 -0
  22. package/src/components/date-time-selector/styleStr.ts +125 -0
  23. package/src/components/hhmmss-ms-list-grp/index.ts +44 -54
  24. package/src/components/period-selector/index.scss +3 -2
  25. package/src/components/period-selector/index.ts +45 -16
  26. package/src/components/quick-selector/index.ts +102 -57
  27. package/src/components/{period-selector/date-nav.ts → yyyymm-nav/index.ts} +12 -15
  28. package/src/components/yyyymmdd-list-grp/index.ts +38 -17
  29. package/src/index.ts +1 -0
  30. /package/dist/components/{period-selector/date-nav.css → yyyymm-nav/index.css} +0 -0
  31. /package/src/components/{period-selector/date-nav.scss → yyyymm-nav/index.scss} +0 -0
@@ -0,0 +1,291 @@
1
+ import { closestByEvent, debounce, html } from '../../utils';
2
+ import {
3
+ type BaseAttrs,
4
+ type Emit2EventMap,
5
+ UiBase
6
+ } from '../web-component-base';
7
+ import {
8
+ Ele as YyyyMmNavEle,
9
+ type EventMap as YyyyMmNavEvent
10
+ } from '../yyyymm-nav';
11
+ import { styleStr } from './styleStr';
12
+ YyyyMmNavEle.define();
13
+ import {
14
+ Ele as CalendarBaseEle,
15
+ type EventMap as CalendarBaseEvent,
16
+ type Weeks,
17
+ weekKey
18
+ } from '../calendar';
19
+ CalendarBaseEle.define();
20
+ import { Ele as HhMmSsMsListGrpEle } from '../hhmmss-ms-list-grp';
21
+ HhMmSsMsListGrpEle.define();
22
+ import { Ele as PopoverEle, type EventMap as PopoverEvent } from '../popover';
23
+ PopoverEle.define();
24
+
25
+ const granularityList = [
26
+ 'day',
27
+ 'hour',
28
+ 'minute',
29
+ 'second',
30
+ 'millisecond'
31
+ ] as const;
32
+
33
+ export interface Attrs extends BaseAttrs {
34
+ /**
35
+ * Set which day of the week is the first day.
36
+ * @type `'sun' | 'mon' | 'tue' | 'wed' | 'thu' | 'fri' | 'sat'`
37
+ * @default 'sun'
38
+ */
39
+ 'week-start-at'?: Weeks;
40
+ /**
41
+ * The time of the calendar.
42
+ * @type {`string | number`} A value that can be passed to the Date constructor.
43
+ * @default Date.now()
44
+ */
45
+ 'current-time'?: string | number;
46
+ /**
47
+ * The showing time, used to determine the month to show on calendar.
48
+ * @type {`string | number`} A value that can be passed to the Date constructor.
49
+ * @default 'current-time'
50
+ */
51
+ 'showing-time'?: string | number;
52
+ /**
53
+ * 选择器的粒度,表示最小可选的时间单位。默认为 millisecond。
54
+ * 例如设置为 'minute',则表示只能选择到分钟,秒和毫秒将被忽略。
55
+ */
56
+ 'min-granularity'?: 'day' | 'hour' | 'minute' | 'second' | 'millisecond';
57
+ }
58
+
59
+ export interface Emits {
60
+ 'select-time': Date;
61
+ 'open-change': boolean;
62
+ }
63
+ export type EventMap = Emit2EventMap<Emits>;
64
+
65
+ export class Ele extends UiBase<Attrs, Emits> {
66
+ public static readonly tagName = 'dt-date-time-selector' as const;
67
+ static get observedAttributes(): string[] {
68
+ return [
69
+ ...(super.observedAttributes as (keyof BaseAttrs)[]),
70
+ 'week-start-at',
71
+ 'current-time',
72
+ 'showing-time',
73
+ 'min-granularity'
74
+ ] satisfies (keyof Attrs)[];
75
+ }
76
+ public get currentTime() {
77
+ const v = this._getAttr('current-time', '' + Date.now());
78
+ return new Date(Number.isNaN(+v) ? v : +v);
79
+ }
80
+ public set currentTime(val: number | string | Date) {
81
+ const v = new Date(val);
82
+ if (Number.isNaN(+v)) return;
83
+ this.setAttribute('current-time', +v + '');
84
+ }
85
+ public get showingTime() {
86
+ const v = this._getAttr('showing-time', '' + this.currentTime);
87
+ return new Date(Number.isNaN(+v) ? v : +v);
88
+ }
89
+ public set showingTime(val: number | string | Date) {
90
+ const v = new Date(val);
91
+ if (Number.isNaN(+v)) return;
92
+ this.setAttribute('showing-time', +v + '');
93
+ }
94
+ public get weekStartAt() {
95
+ return this._getAttr('week-start-at', 'sun');
96
+ }
97
+ public set weekStartAt(val: Weeks) {
98
+ if (!weekKey.includes(val)) return;
99
+ this.setAttribute('week-start-at', val);
100
+ }
101
+ public get minGranularity() {
102
+ return this._getAttr('min-granularity', 'millisecond');
103
+ }
104
+ public set minGranularity(val:
105
+ | 'day'
106
+ | 'hour'
107
+ | 'minute'
108
+ | 'second'
109
+ | 'millisecond') {
110
+ if (!granularityList.includes(val)) return;
111
+ this.setAttribute('min-granularity', val);
112
+ }
113
+
114
+ protected _style = styleStr;
115
+ protected _template = html`
116
+ <dt-popover>
117
+ <slot slot="trigger" name="trigger"><button>select date and time</button></slot>
118
+ <div slot="pop" class="wrapper menu">
119
+ <dt-yyyymm-nav
120
+ show-ctrl-btn-month-add
121
+ show-ctrl-btn-month-sub
122
+ ></dt-yyyymm-nav>
123
+ <dt-calendar-base></dt-calendar-base>
124
+ <dt-popover id="time-popover">
125
+ <div slot="trigger" class="time-echo-wrapper">
126
+ <i class="time-icon"></i>
127
+ <span class="time-echo">hh:mm:ss.sss</span>
128
+ </div>
129
+ <div slot="pop" class="time-selector">
130
+ <h3 class="title">Select Time</h3>
131
+ <dt-hhmmss-ms-list-grp></dt-hhmmss-ms-list-grp>
132
+ <button id="time-selector-done-btn">Done</button>
133
+ </div>
134
+ </dt-popover>
135
+ </div>
136
+ </dt-popover>
137
+ `;
138
+
139
+ private get _navEle() {
140
+ return this.shadowRoot?.querySelector('dt-yyyymm-nav') as YyyyMmNavEle;
141
+ }
142
+ private get _calendar() {
143
+ return this.shadowRoot?.querySelector(
144
+ 'dt-calendar-base'
145
+ ) as CalendarBaseEle;
146
+ }
147
+ private get _timeSelector() {
148
+ return this.shadowRoot?.querySelector(
149
+ 'dt-hhmmss-ms-list-grp'
150
+ ) as HhMmSsMsListGrpEle;
151
+ }
152
+ private get _timePopover() {
153
+ return this.shadowRoot?.querySelector('#time-popover') as PopoverEle;
154
+ }
155
+
156
+ constructor() {
157
+ super();
158
+ this._applyTemplate();
159
+ }
160
+
161
+ public connectedCallback() {
162
+ if (!super.connectedCallback()) return;
163
+ this._calendar.formatter = (i: number) => String(i).padStart(2, '0');
164
+ this._render();
165
+ this._calendar.addEventListener('select-time', this._onCalendarSelect);
166
+ this._navEle.addEventListener('change', this._onNavChange);
167
+ this._timePopover.addEventListener(
168
+ 'open-change',
169
+ this._onTimePopoverOpenChange
170
+ );
171
+ this._navEle.addEventListener(
172
+ 'popover-open-change',
173
+ this._onNavOpenToggle
174
+ );
175
+ this.shadowRoot
176
+ ?.querySelectorAll('#time-selector-done-btn')
177
+ .forEach((btn) => {
178
+ btn.addEventListener('click', this._onTimeSelectorDoneClick);
179
+ });
180
+ }
181
+ public disconnectedCallback() {
182
+ if (!super.disconnectedCallback()) return;
183
+ this._calendar.removeEventListener(
184
+ 'select-time',
185
+ this._onCalendarSelect
186
+ );
187
+ this._navEle.removeEventListener('change', this._onNavChange);
188
+ this._timePopover.removeEventListener(
189
+ 'open-change',
190
+ this._onTimePopoverOpenChange
191
+ );
192
+ this._navEle.removeEventListener(
193
+ 'popover-open-change',
194
+ this._onNavOpenToggle
195
+ );
196
+ this.shadowRoot
197
+ ?.querySelectorAll('#time-selector-done-btn')
198
+ .forEach((btn) => {
199
+ btn.removeEventListener('click', this._onTimeSelectorDoneClick);
200
+ });
201
+ }
202
+ protected _onAttrChanged(name: string, oldValue: string, newValue: string) {
203
+ super._onAttrChanged(name, oldValue, newValue);
204
+ this._render();
205
+ if (name === 'current-time') {
206
+ this.dispatchEvent('select-time', this.currentTime as Date);
207
+ }
208
+ }
209
+
210
+ private _render = debounce(() => {
211
+ if (!this.isConnected) return;
212
+ const currentTime = this.currentTime as Date;
213
+ this._calendar.weekStartAt = this.weekStartAt;
214
+ const tz = new Date().getTimezoneOffset() * 60 * 1000;
215
+ this._navEle.millisecond =
216
+ this._calendar.timeStart =
217
+ this._calendar.timeEnd =
218
+ +currentTime;
219
+ this._calendar.showingTime = this.showingTime;
220
+
221
+ const selectorWrapper =
222
+ this.shadowRoot!.querySelector<HTMLElement>('.time-selector')!;
223
+ if (this.minGranularity === 'day') {
224
+ this._timeSelector.millisecond = 0;
225
+ selectorWrapper.style.display = 'none';
226
+ return;
227
+ }
228
+ selectorWrapper.style.display = '';
229
+ this._timeSelector.minGranularity = this.minGranularity;
230
+
231
+ this._timeSelector.millisecond =
232
+ (+currentTime - tz) % (24 * 60 * 60 * 1000);
233
+ this.shadowRoot!.querySelector('.wrapper .time-echo')!.textContent =
234
+ this.timeFormatter(currentTime as Date, this.minGranularity);
235
+ }, 0);
236
+
237
+ private _onCalendarSelect = (e: CalendarBaseEvent['select-time']) => {
238
+ e.stopPropagation();
239
+ this.currentTime = +e.detail + this._timeSelector.millisecond;
240
+ };
241
+ private _onNavChange = (e: YyyyMmNavEvent['change']) => {
242
+ e.stopPropagation();
243
+ const wrapper = closestByEvent(e, '.wrapper');
244
+ if (!wrapper) return;
245
+ const { newTime } = e.detail;
246
+ this._calendar.showingTime = +newTime;
247
+ };
248
+ private _onTimePopoverOpenChange = (e: PopoverEvent['open-change']) => {
249
+ if (!(e.target instanceof PopoverEle)) return;
250
+ e.stopPropagation();
251
+ if (!e.detail) return this._render(); // for reset time selector value
252
+ e.target
253
+ .querySelector<HhMmSsMsListGrpEle>('dt-hhmmss-ms-list-grp')
254
+ ?.scrollToCurrentItem();
255
+ };
256
+ private _onNavOpenToggle = (e: YyyyMmNavEvent['popover-open-change']) => {
257
+ if (!(e.target instanceof YyyyMmNavEle)) return;
258
+ e.stopPropagation();
259
+ e.target.nextElementSibling?.classList.toggle('hide', e.detail);
260
+ };
261
+ private _onTimeSelectorDoneClick = (e: Event) => {
262
+ const btn = closestByEvent(e, '#time-selector-done-btn');
263
+ if (!btn) return;
264
+ const calcTime = (time: Date, ms: number) => {
265
+ time.setHours(0, 0, 0, 0);
266
+ time.setMilliseconds(ms);
267
+ return time;
268
+ };
269
+ this.currentTime = calcTime(
270
+ this.currentTime as Date,
271
+ this._timeSelector.millisecond
272
+ );
273
+ this._timePopover.open = false;
274
+ };
275
+
276
+ public timeFormatter = (
277
+ time: Date,
278
+ minGranularity: 'day' | 'hour' | 'minute' | 'second' | 'millisecond'
279
+ ) => {
280
+ const t = new Date(+time - new Date().getTimezoneOffset() * 60 * 1000)
281
+ .toISOString()
282
+ .slice(11, 23);
283
+ if (minGranularity === 'day') return '';
284
+ if (minGranularity === 'hour') return t.slice(0, 2);
285
+ if (minGranularity === 'minute') return t.slice(0, 5);
286
+ if (minGranularity === 'second') return t.slice(0, 8);
287
+ return t;
288
+ };
289
+ }
290
+
291
+ Ele.define();
@@ -0,0 +1,125 @@
1
+ import { css } from '../../utils';
2
+
3
+ export const styleStr = css`
4
+ .wrapper {
5
+ display: flex;
6
+ flex-direction: column;
7
+ gap: 15px;
8
+ }
9
+ dt-popover {
10
+ position: relative;
11
+ }
12
+
13
+ [open] > .time-echo-wrapper {
14
+ border-color: #18181B;
15
+ }
16
+
17
+ .time-echo-wrapper {
18
+ width: 100%;
19
+ padding: 4px;
20
+ display: flex;
21
+ gap: 5px;
22
+ border-radius: 4px;
23
+ min-height: 30px;
24
+ border: 1px solid #0001;
25
+ box-sizing: border-box;
26
+ align-items: center;
27
+ cursor: pointer;
28
+ }
29
+
30
+ .time-selector {
31
+ position: absolute;
32
+ width: 100%;
33
+ height: 461px;
34
+ box-sizing: border-box;
35
+ background-color: #fff;
36
+
37
+ display: flex;
38
+ flex-direction: column;
39
+ gap: 15px;
40
+ padding: 15px;
41
+ border-radius: 6px;
42
+ border: 1px solid #eee;
43
+ box-shadow: 0 6px 16px rgba(0, 0, 0, 0.2);
44
+
45
+ .title {
46
+ font-size: 16px;
47
+ margin: 0;
48
+ line-height: 1;
49
+ }
50
+ }
51
+
52
+ dt-hhmmss-ms-list-grp::part(list-container) {
53
+ gap: 2px;
54
+ }
55
+ dt-hhmmss-ms-list-grp::part(list) {
56
+ scroll-behavior: smooth;
57
+ }
58
+ dt-hhmmss-ms-list-grp::part(item) {
59
+ font-size: 14px;
60
+ line-height: 17px;
61
+ }
62
+
63
+ #time-selector-done-btn {
64
+ border: none;
65
+ min-height: 30px;
66
+ border-radius: 6px;
67
+ padding: 5px 10px;
68
+ font-size: 14px;
69
+ background-color: #18181B;
70
+ color: #fff;
71
+ }
72
+
73
+ .time-icon {
74
+ display: inline-block;
75
+ width: 20px;
76
+ height: 20px;
77
+ background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='15' fill='currentColor'%3E%3Cpath d='M7.4335 4.241a.4376.4376 0 0 0-.871.0594v3.783l.0044.0622a.4375.4375 0 0 0 .1921.3029L8.9242 9.877l.0566.0317a.4376.4376 0 0 0 .5495-.1559l.0317-.0566a.4376.4376 0 0 0-.1559-.5495L7.4375 7.8471V4.3004l-.004-.0593ZM7 1.6667c-3.2217 0-5.8333 2.6116-5.8333 5.8333 0 3.2217 2.6116 5.8333 5.8333 5.8333 3.2217 0 5.8333-2.6116 5.8333-5.8333 0-3.2217-2.6116-5.8333-5.8333-5.8333Zm0 .814c2.7721 0 5.0194 2.2472 5.0194 5.0193 0 2.7721-2.2473 5.0194-5.0194 5.0194S1.9806 10.2721 1.9806 7.5 4.228 2.4806 7 2.4806Z'/%3E%3C/svg%3E") 50%/20px 20px no-repeat;
78
+ }
79
+
80
+ .time-echo {
81
+ font-size: 14px;
82
+ color: #999;
83
+ line-height: 1;
84
+ }
85
+
86
+ .menu {
87
+ display: flex;
88
+ flex-direction: column;
89
+ align-items: center;
90
+ padding: 10px 5px;
91
+ font-size: 14px;
92
+ gap: 10px;
93
+ border-radius: 6px;
94
+ border: 1px solid #eee;
95
+ box-shadow: 0 6px 16px rgba(0, 0, 0, 0.2);
96
+ background-color: #fff;
97
+ width: 285px;
98
+
99
+ & > * {
100
+ width: 100%;
101
+ box-sizing: border-box;
102
+ }
103
+ }
104
+
105
+ dt-calendar-base {
106
+ // 254 = item height 6 * 30 + week 14 + gap 10 * 6
107
+ height: 254px;
108
+
109
+ &::part(week) {
110
+ font-size: 12px;
111
+ line-height: 14px;
112
+ }
113
+
114
+ &::part(item) {
115
+ font-size: 14px;
116
+ }
117
+ }
118
+ dt-yyyymm-nav::part(list-grp) {
119
+ height: 254px;
120
+ margin-top: 10px;
121
+ }
122
+ dt-calendar-base.hide {
123
+ display: none;
124
+ }
125
+ `;
@@ -114,7 +114,7 @@ export class Ele extends UiBase<Attrs, Emits> {
114
114
  protected _style = styleStr;
115
115
  protected _template = html`
116
116
  <div class="cols" part="cols">
117
- <div class="col" part="col hour">
117
+ <div class="col hour" part="col hour">
118
118
  <span>Hour</span>
119
119
  <dt-num-list
120
120
  exportparts="container:list-container, item, item-current"
@@ -124,7 +124,7 @@ export class Ele extends UiBase<Attrs, Emits> {
124
124
  max-num="23"
125
125
  ></dt-num-list>
126
126
  </div>
127
- <div class="col" part="col minute">
127
+ <div class="col minute" part="col minute">
128
128
  <span>Minute</span>
129
129
  <dt-num-list
130
130
  exportparts="container:list-container, item, item-current"
@@ -134,7 +134,7 @@ export class Ele extends UiBase<Attrs, Emits> {
134
134
  max-num="59"
135
135
  ></dt-num-list>
136
136
  </div>
137
- <div class="col" part="col second">
137
+ <div class="col second" part="col second">
138
138
  <span>Second</span>
139
139
  <dt-num-list
140
140
  exportparts="container:list-container, item, item-current"
@@ -156,14 +156,18 @@ export class Ele extends UiBase<Attrs, Emits> {
156
156
  this._applyTemplate();
157
157
  }
158
158
 
159
- private get _colsHourEle() {
160
- return this.shadowRoot?.querySelector('.cols .hour') as NumListEle;
159
+ private get _listEleHour() {
160
+ return this.shadowRoot?.querySelector('dt-num-list.hour') as NumListEle;
161
161
  }
162
- private get _colsMinuteEle() {
163
- return this.shadowRoot?.querySelector('.cols .minute') as NumListEle;
162
+ private get _listEleMinute() {
163
+ return this.shadowRoot?.querySelector(
164
+ 'dt-num-list.minute'
165
+ ) as NumListEle;
164
166
  }
165
- private get _colsSecondEle() {
166
- return this.shadowRoot?.querySelector('.cols .second') as NumListEle;
167
+ private get _listEleSecond() {
168
+ return this.shadowRoot?.querySelector(
169
+ 'dt-num-list.second'
170
+ ) as NumListEle;
167
171
  }
168
172
  private get _msInputEle() {
169
173
  return this.shadowRoot?.querySelector('input#ms') as HTMLInputElement;
@@ -178,35 +182,21 @@ export class Ele extends UiBase<Attrs, Emits> {
178
182
  this.setAttribute('millisecond', '' + v);
179
183
  }
180
184
  public get maxGranularity() {
181
- return this._getAttr('max-granularity', 'hour') as
182
- | 'hour'
183
- | 'minute'
184
- | 'second'
185
- | 'millisecond';
185
+ return this._getAttr('max-granularity', 'hour');
186
186
  }
187
187
  public set maxGranularity(v: 'hour' | 'minute' | 'second' | 'millisecond') {
188
188
  if (!['hour', 'minute', 'second', 'millisecond'].includes(v)) return;
189
189
  this.setAttribute('max-granularity', v);
190
190
  }
191
191
  public get minGranularity() {
192
- return this._getAttr('min-granularity', 'millisecond') as
193
- | 'hour'
194
- | 'minute'
195
- | 'second'
196
- | 'millisecond';
192
+ return this._getAttr('min-granularity', 'millisecond');
197
193
  }
198
194
  public set minGranularity(v: 'hour' | 'minute' | 'second' | 'millisecond') {
199
195
  if (!['hour', 'minute', 'second', 'millisecond'].includes(v)) return;
200
196
  this.setAttribute('min-granularity', v);
201
197
  }
202
198
  public get colOrder() {
203
- return this._getAttr('col-order', 'smh') as
204
- | 'hms'
205
- | 'hsm'
206
- | 'mhs'
207
- | 'msh'
208
- | 'shm'
209
- | 'smh';
199
+ return this._getAttr('col-order', 'smh');
210
200
  }
211
201
  public set colOrder(v: 'hms' | 'hsm' | 'mhs' | 'msh' | 'shm' | 'smh') {
212
202
  if (!['hms', 'hsm', 'mhs', 'msh', 'shm', 'smh'].includes(v)) return;
@@ -221,28 +211,28 @@ export class Ele extends UiBase<Attrs, Emits> {
221
211
 
222
212
  public connectedCallback() {
223
213
  if (!super.connectedCallback()) return;
224
- this._colsHourEle.formatter =
225
- this._colsMinuteEle.formatter =
226
- this._colsSecondEle.formatter =
214
+ this._listEleHour.formatter =
215
+ this._listEleMinute.formatter =
216
+ this._listEleSecond.formatter =
227
217
  (num) => ('0' + num).slice(-2);
228
218
 
229
219
  this._renderCols();
230
220
  this._updateGranularity();
231
221
  this._updateColsValue();
232
222
 
233
- this._colsHourEle.addEventListener('select-num', this._onColsSelect);
234
- this._colsMinuteEle.addEventListener('select-num', this._onColsSelect);
235
- this._colsSecondEle.addEventListener('select-num', this._onColsSelect);
223
+ this._listEleHour.addEventListener('select-num', this._onColsSelect);
224
+ this._listEleMinute.addEventListener('select-num', this._onColsSelect);
225
+ this._listEleSecond.addEventListener('select-num', this._onColsSelect);
236
226
  this._msInputEle.addEventListener('input', this._onMsInput);
237
227
  }
238
228
  public disconnectedCallback() {
239
229
  if (!super.disconnectedCallback()) return;
240
- this._colsHourEle.removeEventListener('select-num', this._onColsSelect);
241
- this._colsMinuteEle.removeEventListener(
230
+ this._listEleHour.removeEventListener('select-num', this._onColsSelect);
231
+ this._listEleMinute.removeEventListener(
242
232
  'select-num',
243
233
  this._onColsSelect
244
234
  );
245
- this._colsSecondEle.removeEventListener(
235
+ this._listEleSecond.removeEventListener(
246
236
  'select-num',
247
237
  this._onColsSelect
248
238
  );
@@ -261,9 +251,9 @@ export class Ele extends UiBase<Attrs, Emits> {
261
251
  if (!this.isConnected) return;
262
252
  const {
263
253
  colOrder,
264
- _colsHourEle: hEle,
265
- _colsMinuteEle: mEle,
266
- _colsSecondEle: sEle
254
+ _listEleHour: hEle,
255
+ _listEleMinute: mEle,
256
+ _listEleSecond: sEle
267
257
  } = this;
268
258
  // columns order
269
259
  const orderedCols: HTMLElement[] = [];
@@ -283,13 +273,15 @@ export class Ele extends UiBase<Attrs, Emits> {
283
273
 
284
274
  private _updateGranularity = debounce(() => {
285
275
  if (!this.isConnected) return;
286
- const {
287
- _colsHourEle: hEle,
288
- _colsMinuteEle: mEle,
289
- _colsSecondEle: sEle,
290
- maxGranularity,
291
- minGranularity
292
- } = this;
276
+ const { maxGranularity, minGranularity } = this;
277
+ const hEle = this.shadowRoot!.querySelector<HTMLElement>('.col.hour')!;
278
+ const mEle =
279
+ this.shadowRoot!.querySelector<HTMLElement>('.col.minute')!;
280
+ const sEle =
281
+ this.shadowRoot!.querySelector<HTMLElement>('.col.second')!;
282
+ const msEle = this.shadowRoot!.querySelector<HTMLElement>(
283
+ '[part="ms-wrapper"]'
284
+ )!;
293
285
  const colsContainer =
294
286
  this.shadowRoot!.querySelector<HTMLElement>('.cols')!;
295
287
 
@@ -311,17 +303,15 @@ export class Ele extends UiBase<Attrs, Emits> {
311
303
  ).length
312
304
  ? ''
313
305
  : 'none';
314
- this.shadowRoot!.querySelector<HTMLElement>(
315
- '[part="ms-wrapper"]'
316
- )!.style.display = maxG >= 0 && minG <= 0 ? '' : 'none';
306
+ msEle.style.display = maxG >= 0 && minG <= 0 ? '' : 'none';
317
307
  }, 0);
318
308
 
319
309
  private _updateColsValue = debounce(() => {
320
310
  if (!this.isConnected) return;
321
311
  const {
322
- _colsHourEle: hEle,
323
- _colsMinuteEle: mEle,
324
- _colsSecondEle: sEle,
312
+ _listEleHour: hEle,
313
+ _listEleMinute: mEle,
314
+ _listEleSecond: sEle,
325
315
  millisecond
326
316
  } = this;
327
317
 
@@ -339,9 +329,9 @@ export class Ele extends UiBase<Attrs, Emits> {
339
329
  }, 0);
340
330
 
341
331
  private _getMsFromEle() {
342
- const hour = this._colsHourEle.currentNum;
343
- const minute = this._colsMinuteEle.currentNum;
344
- const second = this._colsSecondEle.currentNum;
332
+ const hour = this._listEleHour.currentNum;
333
+ const minute = this._listEleMinute.currentNum;
334
+ const second = this._listEleSecond.currentNum;
345
335
  const ms = Math.min(Math.max(0, +this._msInputEle.value || 0), 999);
346
336
  return ((hour * 60 + minute) * 60 + second) * 1000 + ms;
347
337
  }
@@ -45,7 +45,7 @@
45
45
  background-color: #eee;
46
46
  }
47
47
 
48
- dt-date-nav::part(list-grp) {
48
+ dt-yyyymm-nav::part(list-grp) {
49
49
  height: 254px;
50
50
  margin-top: 15px;
51
51
  }
@@ -85,6 +85,7 @@ dt-popover {
85
85
  border: 1px solid #0001;
86
86
  box-sizing: border-box;
87
87
  align-items: center;
88
+ cursor: pointer;
88
89
  }
89
90
 
90
91
  .time-selector {
@@ -109,7 +110,7 @@ dt-popover {
109
110
  }
110
111
  }
111
112
 
112
- dt-hhmmss-ms-list-grp{
113
+ dt-hhmmss-ms-list-grp {
113
114
  &::part(list-container) {
114
115
  gap: 2px;
115
116
  }