@gez/date-time-kit 2.0.0-alpha.13 → 2.0.0-alpha.14
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/assets/index.d.ts +1 -0
- package/dist/assets/index.mjs +1 -0
- package/dist/components/calendar/index.d.ts +3 -3
- package/dist/components/date-time-selector/index.d.ts +7 -5
- package/dist/components/date-time-selector/index.mjs +16 -1
- package/dist/components/date-time-selector/styleStr.mjs +1 -1
- package/dist/components/hhmmss-ms-list-grp/base.d.ts +3 -4
- package/dist/components/hhmmss-ms-list-grp/css.mjs +1 -1
- package/dist/components/hhmmss-ms-list-grp/html.mjs +1 -1
- package/dist/components/hhmmss-ms-list-grp/index.d.ts +1 -1
- package/dist/components/hhmmss-ms-list-grp/selector.d.ts +1 -1
- package/dist/components/hhmmss-ms-list-grp/selector.mjs +11 -12
- package/dist/components/num-list/index.css.mjs +1 -1
- package/dist/components/num-list/index.d.ts +4 -9
- package/dist/components/num-list/index.mjs +19 -3
- package/dist/components/period-selector/index.css.mjs +1 -1
- package/dist/components/period-selector/index.d.ts +6 -4
- package/dist/components/period-selector/index.html.mjs +1 -1
- package/dist/components/period-selector/index.mjs +73 -18
- package/dist/components/popover/attr-sync-helper.d.ts +9 -0
- package/dist/components/popover/attr-sync-helper.mjs +39 -0
- package/dist/components/popover/css.d.ts +1 -0
- package/dist/components/popover/css.mjs +7 -0
- package/dist/components/popover/index.d.ts +23 -7
- package/dist/components/popover/index.mjs +141 -30
- package/dist/components/quick-selector/index.css.mjs +2 -1
- package/dist/components/quick-selector/index.d.ts +25 -12
- package/dist/components/quick-selector/index.html.d.ts +1 -3
- package/dist/components/quick-selector/index.html.mjs +8 -20
- package/dist/components/quick-selector/index.mjs +93 -55
- package/dist/components/quick-selector/quick-key.d.ts +10 -1
- package/dist/components/quick-selector/quick-key.mjs +4 -2
- package/dist/components/web-component-base/index.d.ts +13 -4
- package/dist/components/web-component-base/index.mjs +9 -3
- package/dist/components/yyyymm-nav/index.d.ts +3 -3
- package/dist/components/yyyymm-nav/index.html.mjs +1 -1
- package/dist/components/yyyymm-nav/index.mjs +2 -2
- package/dist/components/yyyymmdd-list-grp/index.d.ts +3 -3
- package/dist/utils.d.ts +13 -2
- package/dist/utils.mjs +32 -2
- package/package.json +5 -2
- package/src/assets/index.ts +1 -0
- package/src/components/calendar/index.ts +3 -2
- package/src/components/date-time-selector/index.ts +63 -39
- package/src/components/date-time-selector/styleStr.ts +6 -1
- package/src/components/hhmmss-ms-list-grp/base.ts +3 -3
- package/src/components/hhmmss-ms-list-grp/css.ts +3 -2
- package/src/components/hhmmss-ms-list-grp/html.ts +1 -1
- package/src/components/hhmmss-ms-list-grp/index.ts +2 -2
- package/src/components/hhmmss-ms-list-grp/selector.ts +12 -9
- package/src/components/num-list/index.css.ts +6 -0
- package/src/components/num-list/index.ts +40 -11
- package/src/components/period-selector/index.css.ts +19 -0
- package/src/components/period-selector/index.html.ts +8 -5
- package/src/components/period-selector/index.ts +93 -24
- package/src/components/popover/attr-sync-helper.ts +60 -0
- package/src/components/popover/css.ts +75 -0
- package/src/components/popover/index.ts +158 -40
- package/src/components/quick-selector/index.css.ts +38 -13
- package/src/components/quick-selector/index.html.ts +17 -31
- package/src/components/quick-selector/index.ts +129 -71
- package/src/components/quick-selector/quick-key.ts +15 -2
- package/src/components/web-component-base/index.ts +37 -12
- package/src/components/yyyymm-nav/index.html.ts +1 -1
- package/src/components/yyyymm-nav/index.ts +5 -4
- package/src/components/yyyymmdd-list-grp/index.ts +3 -2
- package/src/utils.ts +29 -2
package/dist/assets/index.d.ts
CHANGED
|
@@ -7,3 +7,4 @@ export declare const arrowRightDoubleSvg = "<svg class=\"bidirectional-flip\" wi
|
|
|
7
7
|
export declare const arrowDownSvg = "<svg class=\"bidirectional-flip\" width=\"15\" height=\"15\" fill=\"currentColor\"><path d=\"m8.02 10.54 3.96-4.4a.583.583 0 0 0-.433-.973h-7.88a.583.583 0 0 0-.434.973l3.94 4.378c.216.24.585.26.824.044l.022-.021Z\"/></svg>";
|
|
8
8
|
export declare const backArrowSvg = "<svg class=\"bidirectional-flip\" width=\"24\" height=\"24\" fill=\"currentColor\"><path d=\"M9.894 5.106a.75.75 0 0 1 0 1.06L4.811 11.25 21 11.25a.75.75 0 0 1 0 1.5l-16.191-.001 5.085 5.085a.75.75 0 0 1-1.06 1.06L2.47 12.53a.75.75 0 0 1 0-1.06l6.364-6.364a.75.75 0 0 1 1.06 0Z\"/></svg>";
|
|
9
9
|
export declare const timeSvg = "<svg width=\"14\" height=\"15\" fill=\"currentColor\"><path 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\"/></svg>";
|
|
10
|
+
export declare const closeBarSvg = "<svg><rect width=\"40\" height=\"4\" rx=\"2\"/></svg>";
|
package/dist/assets/index.mjs
CHANGED
|
@@ -11,3 +11,4 @@ export const arrowRightDoubleSvg = '<svg class="bidirectional-flip" width="17" h
|
|
|
11
11
|
export const arrowDownSvg = '<svg class="bidirectional-flip" width="15" height="15" fill="currentColor"><path d="m8.02 10.54 3.96-4.4a.583.583 0 0 0-.433-.973h-7.88a.583.583 0 0 0-.434.973l3.94 4.378c.216.24.585.26.824.044l.022-.021Z"/></svg>';
|
|
12
12
|
export const backArrowSvg = '<svg class="bidirectional-flip" width="24" height="24" fill="currentColor"><path d="M9.894 5.106a.75.75 0 0 1 0 1.06L4.811 11.25 21 11.25a.75.75 0 0 1 0 1.5l-16.191-.001 5.085 5.085a.75.75 0 0 1-1.06 1.06L2.47 12.53a.75.75 0 0 1 0-1.06l6.364-6.364a.75.75 0 0 1 1.06 0Z"/></svg>';
|
|
13
13
|
export const timeSvg = '<svg width="14" height="15" fill="currentColor"><path 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"/></svg>';
|
|
14
|
+
export const closeBarSvg = '<svg><rect width="40" height="4" rx="2"/></svg>';
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type BaseAttrs, type Emit2EventMap, UiBase } from '../web-component-base';
|
|
1
|
+
import { type BaseAttrs, type BaseEmits, type Emit2EventMap, UiBase } from '../web-component-base';
|
|
2
2
|
import { type Weeks } from './weeks';
|
|
3
3
|
export { type Weeks, weekKey, getWeekInOrder } from './weeks';
|
|
4
4
|
export interface Attrs extends BaseAttrs {
|
|
@@ -43,7 +43,7 @@ export interface Attrs extends BaseAttrs {
|
|
|
43
43
|
*/
|
|
44
44
|
'show-other-month'?: boolean;
|
|
45
45
|
}
|
|
46
|
-
export interface Emits {
|
|
46
|
+
export interface Emits extends BaseEmits {
|
|
47
47
|
'select-time': Date;
|
|
48
48
|
'hover-item': Date;
|
|
49
49
|
}
|
|
@@ -74,7 +74,7 @@ export declare class Ele extends UiBase<Attrs, Emits> {
|
|
|
74
74
|
constructor();
|
|
75
75
|
connectedCallback(): void;
|
|
76
76
|
disconnectedCallback(): void;
|
|
77
|
-
protected _onAttrChanged(name: string, oldValue: string, newValue: string): void;
|
|
77
|
+
protected _onAttrChanged(name: string, oldValue: string | null, newValue: string | null): void;
|
|
78
78
|
private _onWeekStartAtChange;
|
|
79
79
|
private _onTimeChange;
|
|
80
80
|
private _onClick;
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import { type Weeks } from '../calendar';
|
|
2
2
|
import { type Granularity as TimeGranularity } from '../hhmmss-ms-list-grp/selector';
|
|
3
|
-
import { type
|
|
3
|
+
import { type reExportPopoverAttrs } from '../popover/attr-sync-helper';
|
|
4
|
+
import { type BaseAttrs, type BaseEmits, type Emit2EventMap, UiBase } from '../web-component-base';
|
|
4
5
|
export declare const granularityList: readonly ["day", "hour", "minute", "second", "millisecond"];
|
|
5
6
|
export type Granularity = (typeof granularityList)[number];
|
|
6
|
-
export
|
|
7
|
+
export type Attrs = BaseAttrs & reExportPopoverAttrs & {
|
|
7
8
|
/**
|
|
8
9
|
* Set which day of the week is the first day.
|
|
9
10
|
* @type `'sun' | 'mon' | 'tue' | 'wed' | 'thu' | 'fri' | 'sat'`
|
|
@@ -37,8 +38,8 @@ export interface Attrs extends BaseAttrs {
|
|
|
37
38
|
* @type {`string | number`} A value that can be passed to the Date constructor.
|
|
38
39
|
*/
|
|
39
40
|
'max-time'?: string | number;
|
|
40
|
-
}
|
|
41
|
-
export interface Emits {
|
|
41
|
+
};
|
|
42
|
+
export interface Emits extends BaseEmits {
|
|
42
43
|
'select-time': Date;
|
|
43
44
|
'open-change': boolean;
|
|
44
45
|
}
|
|
@@ -71,10 +72,11 @@ export declare class Ele extends UiBase<Attrs, Emits> {
|
|
|
71
72
|
private get _navEle();
|
|
72
73
|
private get _calendar();
|
|
73
74
|
private get _timeSelector();
|
|
75
|
+
private get _popoverEle();
|
|
74
76
|
constructor();
|
|
75
77
|
connectedCallback(): void;
|
|
76
78
|
disconnectedCallback(): void;
|
|
77
|
-
protected _onAttrChanged(name: string, oldValue: string, newValue: string): void;
|
|
79
|
+
protected _onAttrChanged(name: string, oldValue: string | null, newValue: string | null): void;
|
|
78
80
|
private _render;
|
|
79
81
|
private _onCalendarSelect;
|
|
80
82
|
private _onNavChange;
|
|
@@ -8,6 +8,12 @@ import {
|
|
|
8
8
|
import {
|
|
9
9
|
granularityList as timeGranularityList
|
|
10
10
|
} from "../hhmmss-ms-list-grp/selector.mjs";
|
|
11
|
+
import {
|
|
12
|
+
clearupPopEleAttrSync2Parent,
|
|
13
|
+
parentPopAttrSync2PopEle,
|
|
14
|
+
popEleAttrSync2Parent,
|
|
15
|
+
popoverAttrKeys
|
|
16
|
+
} from "../popover/attr-sync-helper.mjs";
|
|
11
17
|
import {
|
|
12
18
|
UiBase
|
|
13
19
|
} from "../web-component-base/index.mjs";
|
|
@@ -69,7 +75,8 @@ export class Ele extends UiBase {
|
|
|
69
75
|
"showing-time",
|
|
70
76
|
"min-time",
|
|
71
77
|
"max-time",
|
|
72
|
-
"min-granularity"
|
|
78
|
+
"min-granularity",
|
|
79
|
+
...popoverAttrKeys
|
|
73
80
|
];
|
|
74
81
|
}
|
|
75
82
|
_getTimeAttr(name, defaultValue) {
|
|
@@ -135,10 +142,14 @@ export class Ele extends UiBase {
|
|
|
135
142
|
"dt-hhmmss-ms-selector"
|
|
136
143
|
);
|
|
137
144
|
}
|
|
145
|
+
get _popoverEle() {
|
|
146
|
+
return this.shadowRoot.querySelector("dt-popover");
|
|
147
|
+
}
|
|
138
148
|
connectedCallback() {
|
|
139
149
|
if (!super.connectedCallback()) return;
|
|
140
150
|
this._calendar.formatter = (i) => String(i).padStart(2, "0");
|
|
141
151
|
this._render();
|
|
152
|
+
popEleAttrSync2Parent(this, this._popoverEle);
|
|
142
153
|
this._calendar.addEventListener("select-time", this._onCalendarSelect);
|
|
143
154
|
this._navEle.addEventListener("change", this._onNavChange);
|
|
144
155
|
this._navEle.addEventListener(
|
|
@@ -153,6 +164,7 @@ export class Ele extends UiBase {
|
|
|
153
164
|
}
|
|
154
165
|
disconnectedCallback() {
|
|
155
166
|
if (!super.disconnectedCallback()) return;
|
|
167
|
+
clearupPopEleAttrSync2Parent(this);
|
|
156
168
|
this._calendar.removeEventListener(
|
|
157
169
|
"select-time",
|
|
158
170
|
this._onCalendarSelect
|
|
@@ -170,6 +182,9 @@ export class Ele extends UiBase {
|
|
|
170
182
|
}
|
|
171
183
|
_onAttrChanged(name, oldValue, newValue) {
|
|
172
184
|
super._onAttrChanged(name, oldValue, newValue);
|
|
185
|
+
if (parentPopAttrSync2PopEle(name, oldValue, newValue, this._popoverEle)) {
|
|
186
|
+
return;
|
|
187
|
+
}
|
|
173
188
|
this._render();
|
|
174
189
|
if (name === "current-time") {
|
|
175
190
|
this.dispatchEvent("select-time", this.currentTime);
|
|
@@ -3,4 +3,4 @@ var __defProp = Object.defineProperty;
|
|
|
3
3
|
var __template = (cooked, raw) => __freeze(__defProp(cooked, "raw", { value: __freeze(raw || cooked.slice()) }));
|
|
4
4
|
var _a;
|
|
5
5
|
import { css } from "../../utils.mjs";
|
|
6
|
-
export const styleStr = css(_a || (_a = __template(["\n:host {\n font-size: 14px;\n}\ndt-popover {\n width: 100%;\n}\n.wrapper {\n display: flex;\n flex-direction: column;\n align-items: center;\n gap: 15px;\n
|
|
6
|
+
export const styleStr = css(_a || (_a = __template(["\n:host {\n font-size: 14px;\n}\ndt-popover {\n width: 100%;\n}\n.wrapper {\n display: flex;\n flex-direction: column;\n align-items: center;\n gap: 15px;\n width: 285px;\n}\n.wrapper > * {\n width: 100%;\n}\n\ndt-calendar-base {\n // 254 = item height 6 * 30 + week 14 + gap 10 * 6\n height: 254px;\n}\ndt-calendar-base::part(week) {\n font-size: 12px;\n line-height: 14px;\n}\ndt-calendar-base::part(item) {\n font-size: 14px;\n}\ndt-calendar-base.hide {\n display: none;\n}\n\ndt-yyyymm-nav::part(list-grp) {\n height: 254px;\n margin-top: 15px;\n}\n\n@media (max-width: 750px) {\n .wrapper {\n width: 100%;\n }\n}\n"])));
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type BaseAttrs, UiBase } from '../web-component-base';
|
|
1
|
+
import { type BaseAttrs, BaseEmits, UiBase } from '../web-component-base';
|
|
2
2
|
export declare const granularityList: readonly ["hour", "minute", "second", "millisecond"];
|
|
3
3
|
export type Granularity = (typeof granularityList)[number];
|
|
4
4
|
export declare const colOrderList: readonly ["hms", "hsm", "mhs", "msh", "shm", "smh"];
|
|
@@ -17,8 +17,7 @@ export interface Attrs extends BaseAttrs {
|
|
|
17
17
|
'min-granularity'?: Granularity;
|
|
18
18
|
'col-order'?: ColOrder;
|
|
19
19
|
}
|
|
20
|
-
export
|
|
21
|
-
}
|
|
20
|
+
export type { BaseEmits };
|
|
22
21
|
/**
|
|
23
22
|
* 时分秒毫秒选择器
|
|
24
23
|
*/
|
|
@@ -41,7 +40,7 @@ export declare class BaseEle<A extends Attrs, E extends BaseEmits> extends UiBas
|
|
|
41
40
|
scrollToCurrentItem(): void;
|
|
42
41
|
connectedCallback(): boolean | void;
|
|
43
42
|
disconnectedCallback(): boolean | void;
|
|
44
|
-
protected _onAttrChanged(name: string, oldValue: string, newValue: string): void;
|
|
43
|
+
protected _onAttrChanged(name: string, oldValue: string | null, newValue: string | null): void;
|
|
45
44
|
private _renderCols;
|
|
46
45
|
private _updateGranularity;
|
|
47
46
|
private _updateColsValue;
|
|
@@ -6,4 +6,4 @@ import { css } from "../../utils.mjs";
|
|
|
6
6
|
export const baseCss = css(_a || (_a = __template(["\n.cols {\n flex: 1;\n display: flex;\n flex-direction: row;\n height: 0;\n justify-content: space-between;\n gap: 2px;\n}\n\n.col {\n flex: 1;\n display: flex;\n flex-direction: column;\n gap: 10px;\n}\n\n.col > span {\n text-align: center;\n display: inline-block;\n line-height: 27px;\n}\n\ndt-num-list {\n flex: 1;\n}\n\n.ms-input {\n width: 100%;\n border: 1px solid var(--dt-border-input, #0003);\n border-radius: 6px;\n padding: 4px;\n cursor: text;\n}\n.ms-input input {\n background-color: transparent;\n color: inherit;\n}\n\nlabel > span {\n display: inline-block;\n line-height: 1;\n font-size: 14px;\n margin-bottom: 2px;\n}\n\ninput {\n width: 100%;\n padding: 0;\n border: none;\n outline: none;\n}\n\ninput::placeholder {\n color: var(--dt-text-secondary, #999);\n}\n"])));
|
|
7
7
|
export const listGrpCss = css(_b || (_b = __template(["", "\n:host {\n display: flex;\n flex-direction: column;\n overflow: hidden;\n gap: 15px;\n}\n"])), baseCss);
|
|
8
8
|
import { svg2cssUrl, timeSvg } from "../../assets/index.mjs";
|
|
9
|
-
export const selectorCss = css(_c || (_c = __template(["", '\n.list-grp {\n display: flex;\n flex-direction: column;\n overflow: hidden;\n gap: 15px;\n}\n\ndt-popover {\n
|
|
9
|
+
export const selectorCss = css(_c || (_c = __template(["", '\n.list-grp {\n display: flex;\n flex-direction: column;\n overflow: hidden;\n gap: 15px;\n}\n\ndt-popover {\n width: 100%;\n}\ndt-popover::part(pop) {\n width: 100%;\n}\n\n[slot="trigger"] {\n width: 100%;\n padding: 4px;\n display: flex;\n gap: 5px;\n border-radius: 4px;\n min-height: 30px;\n border: 1px solid var(--dt-border-input, #0001);\n align-items: center;\n cursor: pointer;\n}\n\n[open] > [slot="trigger"] {\n border-color: var(--dt-accent, #18181B);\n}\n\n.time-icon {\n display: inline-block;\n width: 20px;\n height: 20px;\n position: relative;\n}\n.time-icon::before {\n content: \'\';\n background-color: var(--dt-text-main, #333);\n display: block;\n position: absolute;\n top: 0;\n left: 0;\n width: 100%;\n height: 100%;\n mask-repeat: no-repeat;\n mask-position: center;\n mask-size: contain;\n mask-image: ', ";\n -webkit-mask-repeat: no-repeat;\n -webkit-mask-position: center;\n -webkit-mask-size: contain;\n -webkit-mask-image: ", ';\n}\n\n.time-echo {\n font-size: 14px;\n color: var(--dt-text-secondary, #999);\n line-height: 1;\n}\n\n[slot="pop"] {\n width: 100%;\n height: 461px;\n\n display: flex;\n flex-direction: column;\n gap: 15px;\n padding: 15px;\n}\n\nh3 {\n font-size: 16px;\n margin: 0;\n line-height: 1;\n}\n\nbutton {\n border: none;\n min-height: 30px;\n border-radius: 6px;\n padding: 5px 10px;\n font-size: 14px;\n background-color: var(--dt-accent, #18181B);\n color: var(--dt-text-reverse, #fff);\n}\nbutton:hover {\n background-color: var(--color-accent-hover, #000);\n}\n\ndt-num-list {\n scroll-behavior: smooth;\n}\ndt-num-list::part(container) {\n gap: 2px;\n}\ndt-num-list::part(item) {\n font-size: 14px;\n line-height: 17px;\n}\n'])), baseCss, svg2cssUrl(timeSvg), svg2cssUrl(timeSvg));
|
|
@@ -8,4 +8,4 @@ NumListEle.define();
|
|
|
8
8
|
export const baseHtml = html(_a || (_a = __template(['\n<div class="cols" part="cols">\n <div class="col hour" part="col hour">\n <span><dt-i18n i18n-key="timeUnit.hour"></dt-i18n></span>\n <dt-num-list\n exportparts="container:list-container, item, item-current"\n part="list hour"\n class="hour"\n min-num="0"\n max-num="23"\n ></dt-num-list>\n </div>\n <div class="col minute" part="col minute">\n <span><dt-i18n i18n-key="timeUnit.minute"></dt-i18n></span>\n <dt-num-list\n exportparts="container:list-container, item, item-current"\n part="list minute"\n class="minute"\n min-num="0"\n max-num="59"\n ></dt-num-list>\n </div>\n <div class="col second" part="col second">\n <span><dt-i18n i18n-key="timeUnit.second"></dt-i18n></span>\n <dt-num-list\n exportparts="container:list-container, item, item-current"\n part="list second"\n class="second"\n min-num="0"\n max-num="59"\n ></dt-num-list>\n </div>\n</div>\n<label class="ms-input" part="ms-wrapper">\n <span part="ms-label"><dt-i18n i18n-key="timeUnit.millisecond"></dt-i18n></span>\n <input part="ms-input" id="ms" type="number" class="millisecond" min="0" max="999" step="1" placeholder="000" />\n</label>\n'])));
|
|
9
9
|
import { Ele as PopoverEle } from "../popover/index.mjs";
|
|
10
10
|
PopoverEle.define();
|
|
11
|
-
export const selectorHtml = html(_b || (_b = __template(['\n<dt-popover part="popover">\n <div slot="trigger">\n <i class="time-icon"></i>\n <span class="time-echo">hh:mm:ss.sss</span>\n </div>\n <div slot="pop">\n <h3><slot name="title"><dt-i18n i18n-key="time.singleTitle"></dt-i18n></slot></h3>\n <div class="list-grp">', '</div>\n <button><dt-i18n i18n-key="box.confirm"></dt-i18n></button>\n </div>\n</dt-popover>\n'])), baseHtml);
|
|
11
|
+
export const selectorHtml = html(_b || (_b = __template(['\n<dt-popover part="popover" strategy="absolute" placement="bottom">\n <div slot="trigger">\n <i class="time-icon"></i>\n <span class="time-echo">hh:mm:ss.sss</span>\n </div>\n <div slot="pop">\n <h3><slot name="title"><dt-i18n i18n-key="time.singleTitle"></dt-i18n></slot></h3>\n <div class="list-grp">', '</div>\n <button><dt-i18n i18n-key="box.confirm"></dt-i18n></button>\n </div>\n</dt-popover>\n'])), baseHtml);
|
|
@@ -14,6 +14,6 @@ export type EventMap = Emit2EventMap<Emits>;
|
|
|
14
14
|
export declare class Ele extends BaseEle<BaseAttrs, Emits> {
|
|
15
15
|
static readonly tagName: "dt-hhmmss-ms-list-grp";
|
|
16
16
|
constructor();
|
|
17
|
-
protected _onAttrChanged(name: string, oldValue: string, newValue: string): void;
|
|
17
|
+
protected _onAttrChanged(name: string, oldValue: string | null, newValue: string | null): void;
|
|
18
18
|
private _emitChange;
|
|
19
19
|
}
|
|
@@ -27,7 +27,7 @@ export declare class Ele extends BaseEle<Attrs, Emits> {
|
|
|
27
27
|
get open(): boolean;
|
|
28
28
|
connectedCallback(): void;
|
|
29
29
|
disconnectedCallback(): void;
|
|
30
|
-
protected _onAttrChanged(name: string, oldValue: string, newValue: string): void;
|
|
30
|
+
protected _onAttrChanged(name: string, oldValue: string | null, newValue: string | null): void;
|
|
31
31
|
get currentTime(): number | string | Date;
|
|
32
32
|
set currentTime(val: number | string | Date);
|
|
33
33
|
private _render;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
var __defProp = Object.defineProperty;
|
|
2
2
|
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
3
3
|
var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
4
|
-
import { debounce,
|
|
4
|
+
import { debounce, getCurrentTzOffsetMs } from "../../utils.mjs";
|
|
5
5
|
import { Ele as PopoverEle } from "../popover/index.mjs";
|
|
6
6
|
import {
|
|
7
7
|
BaseEle
|
|
@@ -16,8 +16,8 @@ export class Ele extends BaseEle {
|
|
|
16
16
|
__publicField(this, "_template", selectorHtml);
|
|
17
17
|
__publicField(this, "_render", debounce(() => {
|
|
18
18
|
if (!this.isConnected) return;
|
|
19
|
-
const tz =
|
|
20
|
-
this.millisecond = (+this.currentTime
|
|
19
|
+
const tz = getCurrentTzOffsetMs();
|
|
20
|
+
this.millisecond = (+this.currentTime - tz) % (24 * 60 * 60 * 1e3);
|
|
21
21
|
this.shadowRoot.querySelector(".time-echo").textContent = this.timeFormatter(this.currentTime, this.minGranularity);
|
|
22
22
|
}, 0));
|
|
23
23
|
__publicField(this, "_onPopoverChange", (e) => {
|
|
@@ -26,17 +26,19 @@ export class Ele extends BaseEle {
|
|
|
26
26
|
this.scrollToCurrentItem();
|
|
27
27
|
});
|
|
28
28
|
__publicField(this, "_onDoneBtnClick", (_e) => {
|
|
29
|
-
const calcTime = (
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
return
|
|
29
|
+
const calcTime = (time2, ms) => {
|
|
30
|
+
time2.setHours(0, 0, 0, 0);
|
|
31
|
+
time2.setMilliseconds(ms);
|
|
32
|
+
return time2;
|
|
33
33
|
};
|
|
34
|
-
|
|
34
|
+
const time = calcTime(this.currentTime, this.millisecond);
|
|
35
|
+
this.currentTime = time;
|
|
36
|
+
this.dispatchEvent("select-time", time);
|
|
35
37
|
this._render();
|
|
36
38
|
this._popoverEle.open = false;
|
|
37
39
|
});
|
|
38
40
|
__publicField(this, "timeFormatter", (time, minGranularity) => {
|
|
39
|
-
const t = new Date(+time
|
|
41
|
+
const t = new Date(+time - getCurrentTzOffsetMs()).toISOString().slice(11, 23);
|
|
40
42
|
if (minGranularity === "hour") return t.slice(0, 2);
|
|
41
43
|
if (minGranularity === "minute") return t.slice(0, 5);
|
|
42
44
|
if (minGranularity === "second") return t.slice(0, 8);
|
|
@@ -80,9 +82,6 @@ export class Ele extends BaseEle {
|
|
|
80
82
|
super._onAttrChanged(name, oldValue, newValue);
|
|
81
83
|
if (name === "millisecond") return;
|
|
82
84
|
this._render();
|
|
83
|
-
if (name === "current-time") {
|
|
84
|
-
this.dispatchEvent("select-time", this.currentTime);
|
|
85
|
-
}
|
|
86
85
|
}
|
|
87
86
|
get currentTime() {
|
|
88
87
|
const v = this._getAttr("current-time", "" + Date.now());
|
|
@@ -3,4 +3,4 @@ var __defProp = Object.defineProperty;
|
|
|
3
3
|
var __template = (cooked, raw) => __freeze(__defProp(cooked, "raw", { value: __freeze(raw || cooked.slice()) }));
|
|
4
4
|
var _a;
|
|
5
5
|
import { css } from "../../utils.mjs";
|
|
6
|
-
export default css(_a || (_a = __template(["\n:host {\n --color-current-bg: var(--calendar-item-in-range-bg, #002BE726);\n --color-current-text: var(--calendar-item-in-range-text, #002BE7);\n --color-hover-bg: var(--calendar-item-hover-bg, #0000000D);\n --color-hover-text: var(--calendar-item-hover-text, #000);\n display: block;\n overflow: hidden auto;\n position: relative !important;\n overflow-anchor: none;\n}\n\n.container {\n display: flex;\n flex-direction: column;\n align-items: center;\n gap: 5px;\n}\n\n.item {\n cursor: pointer;\n user-select: none;\n width: 100%;\n text-align: center;\n border-radius: 2px;\n padding: 5px 2px;\n}\n.item.item-current {\n color: var(--color-current-text);\n background-color: var(--color-current-bg);\n}\n.item:hover {\n color: var(--color-hover-text);\n background-color: var(--color-hover-bg);\n}\n"])));
|
|
6
|
+
export default css(_a || (_a = __template(["\n:host {\n --color-current-bg: var(--calendar-item-in-range-bg, #002BE726);\n --color-current-text: var(--calendar-item-in-range-text, #002BE7);\n --color-hover-bg: var(--calendar-item-hover-bg, #0000000D);\n --color-hover-text: var(--calendar-item-hover-text, #000);\n --color-current-hover-bg: var(--calendar-item-in-range-hover-bg, var(--color-current-bg));\n --color-current-hover-text: var(--calendar-item-in-range-hover-text, var(--color-current-text));\n display: block;\n overflow: hidden auto;\n position: relative !important;\n overflow-anchor: none;\n}\n\n.container {\n display: flex;\n flex-direction: column;\n align-items: center;\n gap: 5px;\n}\n\n.item {\n cursor: pointer;\n user-select: none;\n width: 100%;\n text-align: center;\n border-radius: 2px;\n padding: 5px 2px;\n}\n.item.item-current {\n color: var(--color-current-text);\n background-color: var(--color-current-bg);\n}\n.item:hover {\n color: var(--color-hover-text);\n background-color: var(--color-hover-bg);\n}\n.item.item-current:hover {\n color: var(--color-current-hover-text);\n background-color: var(--color-current-hover-bg);\n}\n"])));
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type BaseAttrs, type Emit2EventMap, UiBase } from '../web-component-base';
|
|
1
|
+
import { type BaseAttrs, type BaseEmits, type Emit2EventMap, UiBase } from '../web-component-base';
|
|
2
2
|
export interface Attrs extends BaseAttrs {
|
|
3
3
|
/**
|
|
4
4
|
* The current number in the list. The component will scroll to this number when rendered.
|
|
@@ -17,14 +17,8 @@ export interface Attrs extends BaseAttrs {
|
|
|
17
17
|
* @default Infinity
|
|
18
18
|
*/
|
|
19
19
|
'max-num'?: number;
|
|
20
|
-
/**
|
|
21
|
-
* The position to scroll the current number into view.
|
|
22
|
-
* @type {`"center" | "end" | "nearest" | "start"`}
|
|
23
|
-
* @default "start"
|
|
24
|
-
*/
|
|
25
|
-
position?: ScrollLogicalPosition;
|
|
26
20
|
}
|
|
27
|
-
export interface Emits {
|
|
21
|
+
export interface Emits extends BaseEmits {
|
|
28
22
|
'select-num': {
|
|
29
23
|
oldNum: number;
|
|
30
24
|
newNum: number;
|
|
@@ -58,9 +52,10 @@ export declare class Ele extends UiBase<Attrs, Emits> {
|
|
|
58
52
|
private _loadAfter;
|
|
59
53
|
connectedCallback(): void;
|
|
60
54
|
disconnectedCallback(): void;
|
|
61
|
-
protected _onAttrChanged(name: string, oldValue: string, newValue: string): void;
|
|
55
|
+
protected _onAttrChanged(name: string, oldValue: string | null, newValue: string | null): void;
|
|
62
56
|
private get _itemHeight();
|
|
63
57
|
private get _pageSize();
|
|
58
|
+
private _isScrolling;
|
|
64
59
|
scrollToCurrent: () => void;
|
|
65
60
|
private _render;
|
|
66
61
|
private _onClick;
|
|
@@ -50,6 +50,7 @@ export class Ele extends UiBase {
|
|
|
50
50
|
});
|
|
51
51
|
(_c = this._intersectionOb) == null ? void 0 : _c.observe(items[0]);
|
|
52
52
|
(_d = this._intersectionOb) == null ? void 0 : _d.observe(container.lastElementChild);
|
|
53
|
+
if (this._isScrolling) this.scrollToCurrent();
|
|
53
54
|
}, 0));
|
|
54
55
|
__publicField(this, "_loadAfter", debounce(() => {
|
|
55
56
|
var _a2, _b, _c, _d;
|
|
@@ -77,15 +78,19 @@ export class Ele extends UiBase {
|
|
|
77
78
|
});
|
|
78
79
|
(_c = this._intersectionOb) == null ? void 0 : _c.observe(container.firstElementChild);
|
|
79
80
|
(_d = this._intersectionOb) == null ? void 0 : _d.observe(items[items.length - 1]);
|
|
81
|
+
if (this._isScrolling) this.scrollToCurrent();
|
|
80
82
|
}, 0));
|
|
83
|
+
__publicField(this, "_isScrolling", false);
|
|
81
84
|
__publicField(this, "scrollToCurrent", () => {
|
|
82
85
|
var _a2;
|
|
83
86
|
const ele = this._currentItemEle;
|
|
84
87
|
if (!ele) return;
|
|
88
|
+
const thisRect = this.getBoundingClientRect();
|
|
89
|
+
if (thisRect.height === 0) return;
|
|
85
90
|
(_a2 = this._intersectionOb) == null ? void 0 : _a2.observe(ele);
|
|
86
|
-
|
|
91
|
+
this._isScrolling = true;
|
|
87
92
|
const eleRect = ele.getBoundingClientRect();
|
|
88
|
-
const offsetTop = eleRect.top -
|
|
93
|
+
const offsetTop = eleRect.top - thisRect.top + this.scrollTop;
|
|
89
94
|
this.scrollTo({
|
|
90
95
|
top: offsetTop
|
|
91
96
|
});
|
|
@@ -189,12 +194,23 @@ export class Ele extends UiBase {
|
|
|
189
194
|
const container = this._containerEle;
|
|
190
195
|
const firstItem = container.firstElementChild;
|
|
191
196
|
const lastItem = container.lastElementChild;
|
|
192
|
-
for (const {
|
|
197
|
+
for (const {
|
|
198
|
+
target,
|
|
199
|
+
isIntersecting,
|
|
200
|
+
intersectionRatio,
|
|
201
|
+
rootBounds,
|
|
202
|
+
boundingClientRect
|
|
203
|
+
} of entries) {
|
|
193
204
|
if (!isIntersecting) continue;
|
|
194
205
|
observer.unobserve(target);
|
|
195
206
|
if (target === this._currentItemEle) {
|
|
196
207
|
observer.observe(firstItem);
|
|
197
208
|
observer.observe(lastItem);
|
|
209
|
+
if (intersectionRatio !== 1 || rootBounds && boundingClientRect && rootBounds.top !== boundingClientRect.top) {
|
|
210
|
+
observer.observe(target);
|
|
211
|
+
} else {
|
|
212
|
+
this._isScrolling = false;
|
|
213
|
+
}
|
|
198
214
|
}
|
|
199
215
|
if (target === firstItem) {
|
|
200
216
|
this._loadBefore();
|
|
@@ -3,4 +3,4 @@ var __defProp = Object.defineProperty;
|
|
|
3
3
|
var __template = (cooked, raw) => __freeze(__defProp(cooked, "raw", { value: __freeze(raw || cooked.slice()) }));
|
|
4
4
|
var _a;
|
|
5
5
|
import { css } from "../../utils.mjs";
|
|
6
|
-
export default css(_a || (_a = __template(["\n:host {\n display: flex;\n flex-direction: column;\n gap: 15px;\n}\n\n.date-echo {\n display: flex;\n gap: 5px;\n align-items: center;\n}\n\n.start-date-echo-wrapper,\n.end-date-echo-wrapper {\n width: 100%;\n flex: 1;\n display: flex;\n flex-direction: column;\n gap: 2px;\n border-radius: 6px;\n border: 1px solid var(--dt-border-input, #00000026);\n padding: 4px;\n}\n.start-date-echo-wrapper.active,\n.end-date-echo-wrapper.active {\n border-color: var(--dt-accent, #333);\n}\n\n.date-echo .label {\n font-size: 14px;\n line-height: 1;\n}\n\n.start-date-echo, .end-date-echo {\n font-size: 16px;\n line-height: 1;\n font-weight: bold;\n}\n\n.dividing-line {\n display: block;\n height: 1px;\n width: 20px;\n background-color: var(--dt-border-input, #eee);\n}\n\ndt-yyyymm-nav::part(list-grp) {\n height: 254px;\n margin-top: 15px;\n}\n\ndt-calendar-base.hide {\n display: none;\n}\n\n.calendars {\n display: flex;\n gap: 20px;\n}\n\n.wrapper {\n flex: 1;\n height: 100%;\n display: flex;\n flex-direction: column;\n gap: 15px;\n}\n\ndt-calendar-base {\n height: 254px;\n}\ndt-calendar-base::part(week) {\n font-size: 12px;\n line-height: 14px;\n}\ndt-calendar-base::part(item) {\n font-size: 14px;\n}\n"])));
|
|
6
|
+
export default css(_a || (_a = __template(["\n:host {\n display: flex;\n flex-direction: column;\n gap: 15px;\n}\n\n.date-echo {\n display: flex;\n gap: 5px;\n align-items: center;\n}\n\n.start-date-echo-wrapper,\n.end-date-echo-wrapper {\n width: 100%;\n flex: 1;\n display: flex;\n flex-direction: column;\n gap: 2px;\n border-radius: 6px;\n border: 1px solid var(--dt-border-input, #00000026);\n padding: 4px;\n}\n.start-date-echo-wrapper.active,\n.end-date-echo-wrapper.active {\n border-color: var(--dt-accent, #333);\n}\n\n.date-echo .label {\n font-size: 14px;\n line-height: 1;\n}\n\n.start-date-echo, .end-date-echo {\n font-size: 16px;\n line-height: 1;\n font-weight: bold;\n white-space: pre-wrap;\n}\n\n.dividing-line {\n display: block;\n height: 1px;\n width: 20px;\n background-color: var(--dt-border-input, #eee);\n}\n\ndt-yyyymm-nav::part(list-grp) {\n height: 254px;\n margin-top: 15px;\n}\n\ndt-calendar-base.hide {\n display: none;\n}\n\n.calendars {\n display: flex;\n gap: 20px;\n}\n\n.wrapper {\n flex: 1;\n height: 100%;\n display: flex;\n flex-direction: column;\n gap: 15px;\n}\n\ndt-calendar-base {\n height: 254px;\n}\ndt-calendar-base::part(week) {\n font-size: 12px;\n line-height: 14px;\n}\ndt-calendar-base::part(item) {\n font-size: 14px;\n}\n\ndt-hhmmss-ms-selector {\n width: 100%;\n}\n\n@media (max-width: 750px) {\n .wrapper.end {\n display: none;\n }\n .time-selector-wrapper {\n display: flex;\n gap: 5px;\n align-items: center;\n }\n dt-hhmmss-ms-selector {\n flex: 1;\n }\n}\n"])));
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { type Weeks } from '../calendar';
|
|
2
2
|
import { type Granularity as TimeGranularity } from '../hhmmss-ms-list-grp/selector';
|
|
3
|
-
import { type BaseAttrs, UiBase } from '../web-component-base';
|
|
3
|
+
import { type BaseAttrs, type BaseEmits, UiBase } from '../web-component-base';
|
|
4
4
|
export declare const granularityList: readonly ["day", "hour", "minute", "second", "millisecond"];
|
|
5
5
|
export type Granularity = (typeof granularityList)[number];
|
|
6
6
|
export interface Attrs extends BaseAttrs {
|
|
@@ -28,7 +28,7 @@ export interface Attrs extends BaseAttrs {
|
|
|
28
28
|
*/
|
|
29
29
|
'week-start-at'?: Weeks;
|
|
30
30
|
}
|
|
31
|
-
export interface Emits {
|
|
31
|
+
export interface Emits extends BaseEmits {
|
|
32
32
|
change: {
|
|
33
33
|
oldStartTime: Date;
|
|
34
34
|
oldEndTime: Date;
|
|
@@ -64,17 +64,19 @@ export declare class Ele extends UiBase<Attrs, Emits> {
|
|
|
64
64
|
private _selectedDate;
|
|
65
65
|
connectedCallback(): void;
|
|
66
66
|
disconnectedCallback(): void;
|
|
67
|
-
protected _onAttrChanged(name: string, oldValue: string, newValue: string): void;
|
|
67
|
+
protected _onAttrChanged(name: string, oldValue: string | null, newValue: string | null): void;
|
|
68
68
|
private _updateNavCtrlBtn;
|
|
69
69
|
private _render;
|
|
70
70
|
private _updateDateEcho;
|
|
71
|
+
private _updateDatePoint;
|
|
71
72
|
private _onCalendarSelect;
|
|
72
73
|
private _onCalendarItemHover;
|
|
74
|
+
abortSelecting(): void;
|
|
73
75
|
private _onNavChange;
|
|
74
76
|
private _onNavOpenToggle;
|
|
75
77
|
private _onTimeSelectorChange;
|
|
76
78
|
showCalendarDatePoint(): void;
|
|
77
|
-
dateFormatter: (time: Date) => string;
|
|
79
|
+
dateFormatter: (time: Date, minGranularity: Granularity, isSmall: boolean) => string;
|
|
78
80
|
get timeFormatter(): (time: Date, minGranularity: TimeGranularity) => string;
|
|
79
81
|
set timeFormatter(fn: (time: Date, minGranularity: TimeGranularity) => string);
|
|
80
82
|
}
|
|
@@ -12,5 +12,5 @@ PopoverEle.define();
|
|
|
12
12
|
import { Ele as HhMmSsMsSelector } from "../hhmmss-ms-list-grp/selector.mjs";
|
|
13
13
|
HhMmSsMsSelector.define();
|
|
14
14
|
export default html(_b || (_b = __template(['\n<div class="date-echo">\n <div class="start-date-echo-wrapper active">\n <span class="label"><dt-i18n i18n-key="time.startDate"></dt-i18n></span>\n <span class="start-date-echo">dd/mm/yyyy</span>\n </div>\n <i class="dividing-line"></i>\n <div class="end-date-echo-wrapper">\n <span class="label"><dt-i18n i18n-key="time.endDate"></dt-i18n></span>\n <span class="end-date-echo">dd/mm/yyyy</span>\n </div>\n</div><div class="calendars">', "</div>"])), ["start", "end"].map(
|
|
15
|
-
(s) => html(_a || (_a = __template(['\n<div class="wrapper ', '">\n <dt-yyyymm-nav\n show-ctrl-btn-month-add\n show-ctrl-btn-month-sub\n ></dt-yyyymm-nav>\n <dt-calendar-base data-type="', '"></dt-calendar-base>\n <dt-hhmmss-ms-selector data-type="', '">\n
|
|
15
|
+
(s) => html(_a || (_a = __template(['\n<div class="wrapper ', '">\n <dt-yyyymm-nav\n show-ctrl-btn-month-add\n show-ctrl-btn-month-sub\n ></dt-yyyymm-nav>\n <dt-calendar-base data-type="', '"></dt-calendar-base>\n <div class="time-selector-wrapper">\n <dt-hhmmss-ms-selector data-type="', '">\n <span slot="title"><dt-i18n i18n-key="time.', '"></dt-i18n></span>\n </dt-hhmmss-ms-selector>\n <i class="dividing-line" style="display:none"></i>\n </div>\n</div>'])), s, s, s, s === "start" ? "startTime" : "endTime")
|
|
16
16
|
).join(""));
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
var __defProp = Object.defineProperty;
|
|
2
2
|
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
3
3
|
var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
4
|
-
import { closestByEvent, debounce } from "../../utils.mjs";
|
|
4
|
+
import { closestByEvent, debounce, smallScreenObserver } from "../../utils.mjs";
|
|
5
5
|
import {
|
|
6
6
|
weekKey
|
|
7
7
|
} from "../calendar/index.mjs";
|
|
@@ -36,9 +36,16 @@ export class Ele extends UiBase {
|
|
|
36
36
|
let timeStart = this.timeStart;
|
|
37
37
|
let timeEnd = this.timeEnd;
|
|
38
38
|
if (timeStart > timeEnd) [timeStart, timeEnd] = [timeEnd, timeStart];
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
39
|
+
const { _startCalendar, _endCalendar } = this;
|
|
40
|
+
_startCalendar.weekStartAt = _endCalendar.weekStartAt = this.weekStartAt;
|
|
41
|
+
_startCalendar.timeStart = _endCalendar.timeStart = +timeStart;
|
|
42
|
+
_endCalendar.timeEnd = _startCalendar.timeEnd = +timeEnd;
|
|
43
|
+
const isSmall = smallScreenObserver.isSmall;
|
|
44
|
+
if (!isSmall || !this._selectedDate || +timeStart !== +this._selectedDate) {
|
|
45
|
+
this._startNavEle.millisecond = _startCalendar.showingTime = +timeStart;
|
|
46
|
+
} else {
|
|
47
|
+
this._startNavEle.millisecond = _startCalendar.showingTime = +timeEnd;
|
|
48
|
+
}
|
|
42
49
|
if (diffInMonth(timeStart, timeEnd) <= 1) {
|
|
43
50
|
const nextMonth = new Date(
|
|
44
51
|
timeStart.getFullYear(),
|
|
@@ -63,21 +70,57 @@ export class Ele extends UiBase {
|
|
|
63
70
|
}
|
|
64
71
|
this._updateDateEcho();
|
|
65
72
|
this._updateNavCtrlBtn();
|
|
73
|
+
const startSelectorWrapper = this.shadowRoot.querySelector(
|
|
74
|
+
".start .time-selector-wrapper"
|
|
75
|
+
);
|
|
76
|
+
const dividingLine = startSelectorWrapper.querySelector(
|
|
77
|
+
".dividing-line"
|
|
78
|
+
);
|
|
79
|
+
if (smallScreenObserver.isSmall) {
|
|
80
|
+
startSelectorWrapper.appendChild(this._endTimeSelector);
|
|
81
|
+
dividingLine.style.display = "";
|
|
82
|
+
} else {
|
|
83
|
+
this.shadowRoot.querySelector(
|
|
84
|
+
".end .time-selector-wrapper"
|
|
85
|
+
).appendChild(this._endTimeSelector);
|
|
86
|
+
dividingLine.style.display = "none";
|
|
87
|
+
}
|
|
66
88
|
}, 0));
|
|
89
|
+
__publicField(this, "_updateDatePoint", (datePoint) => {
|
|
90
|
+
if (!this._selectedDate) return;
|
|
91
|
+
const newDate = new Date(datePoint).setHours(0, 0, 0, 0);
|
|
92
|
+
const oldDate = new Date(this._selectedDate).setHours(0, 0, 0, 0);
|
|
93
|
+
const setStartDate = (date) => this.timeStart = new Date(
|
|
94
|
+
date + this._startTimeSelector.millisecond
|
|
95
|
+
);
|
|
96
|
+
const setEndDate = (date) => this.timeEnd = new Date(date + this._endTimeSelector.millisecond);
|
|
97
|
+
if (newDate === oldDate) {
|
|
98
|
+
setStartDate(newDate);
|
|
99
|
+
setEndDate(newDate);
|
|
100
|
+
} else if (newDate < oldDate) {
|
|
101
|
+
setStartDate(newDate);
|
|
102
|
+
setEndDate(oldDate);
|
|
103
|
+
} else {
|
|
104
|
+
setStartDate(oldDate);
|
|
105
|
+
setEndDate(newDate);
|
|
106
|
+
}
|
|
107
|
+
});
|
|
67
108
|
__publicField(this, "_onCalendarSelect", (e) => {
|
|
68
109
|
e.stopPropagation();
|
|
69
|
-
if (this._selectedDate) {
|
|
70
|
-
|
|
71
|
-
|
|
110
|
+
if (this._selectedDate === null) {
|
|
111
|
+
const newTimePoint = new Date(
|
|
112
|
+
+e.detail + this._startTimeSelector.millisecond
|
|
113
|
+
);
|
|
114
|
+
this._selectedDate = newTimePoint;
|
|
115
|
+
this.timeStart = newTimePoint;
|
|
72
116
|
} else {
|
|
73
|
-
this.
|
|
74
|
-
this.
|
|
117
|
+
this._updateDatePoint(e.detail);
|
|
118
|
+
this._selectedDate = null;
|
|
75
119
|
}
|
|
76
120
|
});
|
|
77
121
|
__publicField(this, "_onCalendarItemHover", (e) => {
|
|
78
122
|
e.stopPropagation();
|
|
79
|
-
|
|
80
|
-
this.timeEnd = +e.detail + this._endTimeSelector.millisecond;
|
|
123
|
+
this._updateDatePoint(e.detail);
|
|
81
124
|
});
|
|
82
125
|
__publicField(this, "_onNavChange", (e) => {
|
|
83
126
|
e.stopPropagation();
|
|
@@ -107,7 +150,7 @@ export class Ele extends UiBase {
|
|
|
107
150
|
this.timeEnd = e.detail;
|
|
108
151
|
}
|
|
109
152
|
});
|
|
110
|
-
__publicField(this, "dateFormatter", (time) => time.toLocaleDateString("en-GB"));
|
|
153
|
+
__publicField(this, "dateFormatter", (time, minGranularity, isSmall) => time.toLocaleDateString("en-GB"));
|
|
111
154
|
this._applyTemplate();
|
|
112
155
|
}
|
|
113
156
|
static get observedAttributes() {
|
|
@@ -178,13 +221,13 @@ export class Ele extends UiBase {
|
|
|
178
221
|
get _startTimeSelector() {
|
|
179
222
|
var _a;
|
|
180
223
|
return (_a = this.shadowRoot) == null ? void 0 : _a.querySelector(
|
|
181
|
-
|
|
224
|
+
'dt-hhmmss-ms-selector[data-type="start"]'
|
|
182
225
|
);
|
|
183
226
|
}
|
|
184
227
|
get _endTimeSelector() {
|
|
185
228
|
var _a;
|
|
186
229
|
return (_a = this.shadowRoot) == null ? void 0 : _a.querySelector(
|
|
187
|
-
|
|
230
|
+
'dt-hhmmss-ms-selector[data-type="end"]'
|
|
188
231
|
);
|
|
189
232
|
}
|
|
190
233
|
connectedCallback() {
|
|
@@ -231,6 +274,7 @@ export class Ele extends UiBase {
|
|
|
231
274
|
"select-time",
|
|
232
275
|
this._onTimeSelectorChange
|
|
233
276
|
);
|
|
277
|
+
smallScreenObserver.observe(this, this._render);
|
|
234
278
|
}
|
|
235
279
|
disconnectedCallback() {
|
|
236
280
|
if (!super.disconnectedCallback()) return;
|
|
@@ -276,6 +320,7 @@ export class Ele extends UiBase {
|
|
|
276
320
|
"select-time",
|
|
277
321
|
this._onTimeSelectorChange
|
|
278
322
|
);
|
|
323
|
+
smallScreenObserver.unobserve(this);
|
|
279
324
|
}
|
|
280
325
|
_onAttrChanged(name, oldValue, newValue) {
|
|
281
326
|
super._onAttrChanged(name, oldValue, newValue);
|
|
@@ -285,15 +330,17 @@ export class Ele extends UiBase {
|
|
|
285
330
|
const timeStart = new Date(this._startNavEle.millisecond);
|
|
286
331
|
const timeEnd = new Date(this._endNavEle.millisecond);
|
|
287
332
|
const showCtrlBtn = diffInMonth(timeStart, timeEnd) > 1;
|
|
288
|
-
|
|
289
|
-
this.
|
|
333
|
+
const isSmall = smallScreenObserver.isSmall;
|
|
334
|
+
this._startNavEle.showCtrlBtnMonthAdd = isSmall || showCtrlBtn;
|
|
335
|
+
this._endNavEle.showCtrlBtnMonthSub = isSmall || showCtrlBtn;
|
|
290
336
|
}
|
|
291
337
|
_updateDateEcho() {
|
|
292
338
|
let timeStart = this.timeStart;
|
|
293
339
|
let timeEnd = this.timeEnd;
|
|
294
340
|
if (timeStart > timeEnd) [timeStart, timeEnd] = [timeEnd, timeStart];
|
|
295
|
-
|
|
296
|
-
this.shadowRoot.querySelector(".
|
|
341
|
+
const isSmall = smallScreenObserver.isSmall;
|
|
342
|
+
this.shadowRoot.querySelector(".start-date-echo").textContent = this.dateFormatter(timeStart, this.minGranularity, isSmall);
|
|
343
|
+
this.shadowRoot.querySelector(".end-date-echo").textContent = this.dateFormatter(timeEnd, this.minGranularity, isSmall);
|
|
297
344
|
this.shadowRoot.querySelector(
|
|
298
345
|
".start-date-echo-wrapper"
|
|
299
346
|
).classList.toggle("active", !this._selectedDate);
|
|
@@ -301,9 +348,17 @@ export class Ele extends UiBase {
|
|
|
301
348
|
".end-date-echo-wrapper"
|
|
302
349
|
).classList.toggle("active", !!this._selectedDate);
|
|
303
350
|
}
|
|
351
|
+
abortSelecting() {
|
|
352
|
+
if (!this._selectedDate) return;
|
|
353
|
+
this._selectedDate = null;
|
|
354
|
+
this._render();
|
|
355
|
+
}
|
|
304
356
|
showCalendarDatePoint() {
|
|
305
357
|
this._render();
|
|
306
358
|
}
|
|
359
|
+
// + (isSmall && minGranularity !== 'day'
|
|
360
|
+
// ? ' ' + this.timeFormatter(time, minGranularity)
|
|
361
|
+
// : '');
|
|
307
362
|
get timeFormatter() {
|
|
308
363
|
return this._startTimeSelector.timeFormatter;
|
|
309
364
|
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { type Attrs as PopoverAttrs, Ele as PopoverEle } from '.';
|
|
2
|
+
import type { BaseAttrs } from '../web-component-base';
|
|
3
|
+
export type reExportPopoverAttrs = {
|
|
4
|
+
[K in `pop-${Exclude<keyof PopoverAttrs, keyof BaseAttrs>}`]?: K extends `pop-${infer U}` ? U extends keyof PopoverAttrs ? PopoverAttrs[U] : never : never;
|
|
5
|
+
};
|
|
6
|
+
export declare const popoverAttrKeys: readonly ["pop-disabled", "pop-open", "pop-placement", "pop-strategy", "pop-offset"];
|
|
7
|
+
export declare const parentPopAttrSync2PopEle: (name: string, oldValue: string | null, newValue: string | null, popEle: PopoverEle) => name is (typeof popoverAttrKeys)[number];
|
|
8
|
+
export declare const popEleAttrSync2Parent: (parent: HTMLElement, popEle: PopoverEle) => void;
|
|
9
|
+
export declare const clearupPopEleAttrSync2Parent: (parent: HTMLElement) => void | undefined;
|