@gez/date-time-kit 2.0.0-alpha.2 → 2.0.0-alpha.21
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 +10 -0
- package/dist/assets/index.mjs +14 -0
- package/dist/components/calendar/index.css.d.ts +2 -0
- package/dist/components/calendar/index.css.mjs +11 -0
- package/dist/components/calendar/index.d.ts +5 -6
- package/dist/components/calendar/index.html.d.ts +2 -0
- package/dist/components/calendar/index.html.mjs +13 -0
- package/dist/components/calendar/index.mjs +10 -31
- package/dist/components/calendar/weeks.d.ts +3 -0
- package/dist/components/calendar/weeks.mjs +15 -0
- package/dist/components/date-time-selector/index.d.ts +40 -13
- package/dist/components/date-time-selector/index.html.d.ts +2 -0
- package/dist/components/date-time-selector/index.html.mjs +14 -0
- package/dist/components/date-time-selector/index.mjs +114 -98
- package/dist/components/date-time-selector/styleStr.mjs +1 -1
- package/dist/components/hhmmss-ms-list-grp/base.d.ts +50 -0
- package/dist/components/hhmmss-ms-list-grp/base.mjs +207 -0
- package/dist/components/hhmmss-ms-list-grp/css.d.ts +3 -0
- package/dist/components/hhmmss-ms-list-grp/css.mjs +9 -0
- package/dist/components/hhmmss-ms-list-grp/html.d.ts +2 -0
- package/dist/components/hhmmss-ms-list-grp/html.mjs +11 -0
- package/dist/components/hhmmss-ms-list-grp/index.d.ts +7 -42
- package/dist/components/hhmmss-ms-list-grp/index.mjs +8 -214
- package/dist/components/hhmmss-ms-list-grp/selector.d.ts +37 -0
- package/dist/components/hhmmss-ms-list-grp/selector.mjs +97 -0
- package/dist/components/i18n/index.d.ts +2 -1
- package/dist/components/i18n/index.mjs +10 -6
- package/dist/components/num-list/index.css.d.ts +2 -0
- package/dist/components/num-list/index.css.mjs +6 -0
- package/dist/components/num-list/index.d.ts +4 -9
- package/dist/components/num-list/index.mjs +29 -11
- package/dist/components/period-selector/index.css.d.ts +2 -0
- package/dist/components/period-selector/index.css.mjs +6 -0
- package/dist/components/period-selector/index.d.ts +15 -10
- package/dist/components/period-selector/index.html.d.ts +2 -0
- package/dist/components/period-selector/index.html.mjs +16 -0
- package/dist/components/period-selector/index.mjs +158 -117
- 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 +25 -7
- package/dist/components/popover/index.mjs +140 -28
- package/dist/components/quick-selector/index.css.d.ts +2 -0
- package/dist/components/quick-selector/index.css.mjs +8 -0
- package/dist/components/quick-selector/index.d.ts +43 -28
- package/dist/components/quick-selector/index.html.d.ts +3 -0
- package/dist/components/quick-selector/index.html.mjs +57 -0
- package/dist/components/quick-selector/index.mjs +137 -191
- package/dist/components/quick-selector/quick-key.d.ts +242 -0
- package/dist/components/quick-selector/quick-key.mjs +126 -0
- package/dist/components/web-component-base/css.d.ts +2 -0
- package/dist/components/web-component-base/css.mjs +12 -0
- package/dist/components/web-component-base/index.d.ts +16 -5
- package/dist/components/web-component-base/index.mjs +22 -14
- package/dist/components/yyyymm-nav/index.css.d.ts +2 -0
- package/dist/components/yyyymm-nav/index.css.mjs +14 -0
- package/dist/components/yyyymm-nav/index.d.ts +3 -3
- package/dist/components/yyyymm-nav/index.html.d.ts +2 -0
- package/dist/components/yyyymm-nav/index.html.mjs +10 -0
- package/dist/components/yyyymm-nav/index.mjs +6 -11
- package/dist/components/yyyymmdd-list-grp/index.css.d.ts +2 -0
- package/dist/components/yyyymmdd-list-grp/index.css.mjs +6 -0
- package/dist/components/yyyymmdd-list-grp/index.d.ts +3 -3
- package/dist/components/yyyymmdd-list-grp/index.html.d.ts +2 -0
- package/dist/components/yyyymmdd-list-grp/index.html.mjs +8 -0
- package/dist/components/yyyymmdd-list-grp/index.mjs +15 -17
- package/dist/i18n.d.ts +14 -0
- package/dist/i18n.mjs +153 -27
- package/dist/index.d.ts +1 -1
- package/dist/index.mjs +2 -1
- package/dist/utils.d.ts +16 -0
- package/dist/utils.mjs +35 -0
- package/package.json +5 -2
- package/src/assets/index.ts +24 -0
- package/src/components/calendar/index.css.ts +175 -0
- package/src/components/calendar/index.html.ts +20 -0
- package/src/components/calendar/index.ts +13 -153
- package/src/components/calendar/weeks.ts +17 -0
- package/src/components/date-time-selector/index.html.ts +23 -0
- package/src/components/date-time-selector/index.ts +173 -156
- package/src/components/date-time-selector/styleStr.ts +22 -101
- package/src/components/hhmmss-ms-list-grp/base.ts +252 -0
- package/src/components/hhmmss-ms-list-grp/css.ts +173 -0
- package/src/components/hhmmss-ms-list-grp/html.ts +59 -0
- package/src/components/hhmmss-ms-list-grp/index.ts +12 -351
- package/src/components/hhmmss-ms-list-grp/selector.ts +134 -0
- package/src/components/i18n/index.ts +12 -4
- package/{dist/components/num-list/index.css → src/components/num-list/index.css.ts} +11 -2
- package/src/components/num-list/index.ts +44 -50
- package/src/components/period-selector/index.css.ts +101 -0
- package/src/components/period-selector/index.html.ts +41 -0
- package/src/components/period-selector/index.ts +179 -303
- package/src/components/popover/attr-sync-helper.ts +60 -0
- package/src/components/popover/css.ts +75 -0
- package/src/components/popover/index.ts +160 -31
- package/src/components/quick-selector/index.css.ts +202 -0
- package/src/components/quick-selector/index.html.ts +76 -0
- package/src/components/quick-selector/index.ts +193 -428
- package/src/components/quick-selector/quick-key.ts +205 -0
- package/src/components/web-component-base/css.ts +56 -0
- package/src/components/web-component-base/index.ts +59 -69
- package/{dist/components/yyyymm-nav/index.css → src/components/yyyymm-nav/index.css.ts} +53 -10
- package/src/components/yyyymm-nav/index.html.ts +25 -0
- package/src/components/yyyymm-nav/index.ts +10 -122
- package/{dist/components/yyyymmdd-list-grp/index.css → src/components/yyyymmdd-list-grp/index.css.ts} +5 -1
- package/src/components/yyyymmdd-list-grp/index.html.ts +20 -0
- package/src/components/yyyymmdd-list-grp/index.ts +7 -54
- package/src/i18n.ts +167 -27
- package/src/index.ts +1 -0
- package/src/utils.ts +34 -0
- package/dist/components/calendar/index.css +0 -108
- package/dist/components/hhmmss-ms-list-grp/index.css +0 -60
- package/dist/components/period-selector/index.css +0 -153
- package/dist/components/quick-selector/index.css +0 -167
- package/dist/components/web-component-base/index.css +0 -9
- package/dist/components/web-component-base/scrollbar.css +0 -25
- package/src/components/calendar/index.scss +0 -128
- package/src/components/hhmmss-ms-list-grp/index.scss +0 -61
- package/src/components/num-list/index.scss +0 -38
- package/src/components/period-selector/index.scss +0 -161
- package/src/components/quick-selector/index.scss +0 -183
- package/src/components/web-component-base/index.scss +0 -11
- package/src/components/web-component-base/scrollbar.scss +0 -30
- package/src/components/yyyymm-nav/index.scss +0 -108
- package/src/components/yyyymmdd-list-grp/index.scss +0 -33
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export declare const svg2url: (svg: string) => string;
|
|
2
|
+
export declare const svg2cssUrl: (svg: string) => string;
|
|
3
|
+
export declare const arrowLeftSvg = "<svg class=\"bidirectional-flip\" width=\"16\" height=\"17\" fill=\"currentColor\"><path d=\"M11.687 1.703a.5.5 0 0 0-.707 0L4.852 7.83a.505.505 0 0 0-.045.05.5.5 0 0 0-.051.752l6.128 6.128a.5.5 0 0 0 .707-.707L5.817 8.28l5.87-5.87a.5.5 0 0 0 0-.707Z\"/></svg>";
|
|
4
|
+
export declare const arrowRightSvg = "<svg class=\"bidirectional-flip\" width=\"17\" height=\"17\" fill=\"currentColor\"><path d=\"M5.256 1.703a.5.5 0 0 1 .707 0l6.128 6.128a.493.493 0 0 1 .045.05.5.5 0 0 1 .051.752l-6.128 6.128a.5.5 0 0 1-.707-.707l5.774-5.774-5.87-5.87a.5.5 0 0 1 0-.707Z\"/></svg>";
|
|
5
|
+
export declare const arrowLeftDoubleSvg = "<svg class=\"bidirectional-flip\" width=\"16\" height=\"17\" fill=\"currentColor\"><path d=\"M9.037 1.98a.5.5 0 1 1 .707.707l-5.87 5.87 5.774 5.774a.5.5 0 1 1-.707.707L2.813 8.911a.5.5 0 0 1 .051-.752.505.505 0 0 1 .045-.051L9.037 1.98ZM13.037 1.98a.5.5 0 0 1 .707.707l-5.87 5.87 5.774 5.774a.5.5 0 1 1-.707.707L6.813 8.911a.5.5 0 0 1 .051-.752.505.505 0 0 1 .045-.051l6.128-6.128Z\"/></svg>";
|
|
6
|
+
export declare const arrowRightDoubleSvg = "<svg class=\"bidirectional-flip\" width=\"17\" height=\"17\" fill=\"currentColor\"><path d=\"M7.963 1.703a.5.5 0 0 0-.707.707l5.87 5.87-5.774 5.774a.5.5 0 0 0 .707.707l6.128-6.128a.5.5 0 0 0-.051-.751.493.493 0 0 0-.045-.051L7.963 1.703ZM3.963 1.703a.5.5 0 0 0-.707.707l5.87 5.87-5.774 5.774a.5.5 0 0 0 .707.707l6.128-6.128a.5.5 0 0 0-.051-.751.493.493 0 0 0-.045-.051L3.963 1.703Z\"/></svg>";
|
|
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
|
+
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
|
+
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>";
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
const symbols = /[\r\n%#()<>?[\\\]^`{|}]/g;
|
|
2
|
+
export const svg2url = (svg) => "data:image/svg+xml," + svg.replace(
|
|
3
|
+
"<svg",
|
|
4
|
+
~svg.indexOf("xmlns") ? "<svg" : '<svg xmlns="http://www.w3.org/2000/svg"'
|
|
5
|
+
).replace(/"/g, "'").replace(/>\s{1,}</g, "><").replace(/\s{2,}/g, " ").replace(symbols, encodeURIComponent);
|
|
6
|
+
export const svg2cssUrl = (svg) => 'url("'.concat(svg2url(svg), '")');
|
|
7
|
+
export const arrowLeftSvg = '<svg class="bidirectional-flip" width="16" height="17" fill="currentColor"><path d="M11.687 1.703a.5.5 0 0 0-.707 0L4.852 7.83a.505.505 0 0 0-.045.05.5.5 0 0 0-.051.752l6.128 6.128a.5.5 0 0 0 .707-.707L5.817 8.28l5.87-5.87a.5.5 0 0 0 0-.707Z"/></svg>';
|
|
8
|
+
export const arrowRightSvg = '<svg class="bidirectional-flip" width="17" height="17" fill="currentColor"><path d="M5.256 1.703a.5.5 0 0 1 .707 0l6.128 6.128a.493.493 0 0 1 .045.05.5.5 0 0 1 .051.752l-6.128 6.128a.5.5 0 0 1-.707-.707l5.774-5.774-5.87-5.87a.5.5 0 0 1 0-.707Z"/></svg>';
|
|
9
|
+
export const arrowLeftDoubleSvg = '<svg class="bidirectional-flip" width="16" height="17" fill="currentColor"><path d="M9.037 1.98a.5.5 0 1 1 .707.707l-5.87 5.87 5.774 5.774a.5.5 0 1 1-.707.707L2.813 8.911a.5.5 0 0 1 .051-.752.505.505 0 0 1 .045-.051L9.037 1.98ZM13.037 1.98a.5.5 0 0 1 .707.707l-5.87 5.87 5.774 5.774a.5.5 0 1 1-.707.707L6.813 8.911a.5.5 0 0 1 .051-.752.505.505 0 0 1 .045-.051l6.128-6.128Z"/></svg>';
|
|
10
|
+
export const arrowRightDoubleSvg = '<svg class="bidirectional-flip" width="17" height="17" fill="currentColor"><path d="M7.963 1.703a.5.5 0 0 0-.707.707l5.87 5.87-5.774 5.774a.5.5 0 0 0 .707.707l6.128-6.128a.5.5 0 0 0-.051-.751.493.493 0 0 0-.045-.051L7.963 1.703ZM3.963 1.703a.5.5 0 0 0-.707.707l5.87 5.87-5.774 5.774a.5.5 0 0 0 .707.707l6.128-6.128a.5.5 0 0 0-.051-.751.493.493 0 0 0-.045-.051L3.963 1.703Z"/></svg>';
|
|
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
|
+
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
|
+
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>';
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
var __freeze = Object.freeze;
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __template = (cooked, raw) => __freeze(__defProp(cooked, "raw", { value: __freeze(raw || cooked.slice()) }));
|
|
4
|
+
var _a;
|
|
5
|
+
import {
|
|
6
|
+
css,
|
|
7
|
+
cssDirLtrSelector1,
|
|
8
|
+
cssDirLtrSelector2,
|
|
9
|
+
cssDirLtrSelector3
|
|
10
|
+
} from "../../utils.mjs";
|
|
11
|
+
export default css(_a || (_a = __template(["\n:host {\n --gap: var(--calendar-item-gap, 10px 0);\n --item-size: var(--calendar-item-size, 30px);\n --color-disabled-text: var(--calendar-item-disabled-text, #aaa);\n --color-active-bg: var(--calendar-item-active-bg, #002BE7);\n --color-active-text: var(--calendar-item-active-text, #fff);\n --color-in-range-bg: var(--calendar-item-in-range-bg, #002BE726);\n --color-in-range-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-active-hover-bg: var(--calendar-item-active-hover-bg, var(--color-active-bg));\n --color-active-hover-text: var(--calendar-item-active-hover-text, var(--color-active-text));\n}\n\n.wrapper {\n display: grid;\n grid-template-columns: repeat(7, 1fr);\n gap: var(--gap);\n width: 100%;\n height: 100%;\n justify-content: space-between;\n text-align: center;\n}\n\n.week {\n min-width: var(--item-size);\n display: inline-block;\n}\n\n.item {\n min-width: var(--item-size);\n line-height: var(--item-size);\n height: var(--item-size);\n position: relative;\n --half-period-bg-w: calc(50% + var(--item-size) / 2);\n}\n.item span {\n position: relative;\n z-index: 2;\n}\n.item:not(.disabled) {\n cursor: pointer;\n}\n:host([show-other-month]) .item.prev.disabled, :host([show-other-month]) .item.next.disabled, .item.disabled:not(.prev, .next) {\n cursor: not-allowed;\n color: var(--color-disabled-text);\n}\n.item:hover {\n color: var(--color-hover-text);\n}\n.item.in-range {\n color: var(--color-in-range-text);\n}\n.item:not(.disabled) .highlight {\n display: block;\n border-radius: 50%;\n position: absolute;\n top: 50%;\n left: 50%;\n width: var(--item-size);\n height: var(--item-size);\n transform: translate(-50%, -50%);\n}\n.item.start, .item.end {\n color: var(--color-active-text);\n}\n.item.start .highlight, .item.end .highlight {\n background-color: var(--color-active-bg);\n}\n.item:hover .highlight {\n background-color: var(--color-hover-bg);\n}\n.item.start:hover .highlight, .item.end:hover .highlight {\n background-color: var(--color-active-hover-bg);\n}\n.item.start:hover, .item.end:hover {\n color: var(--color-active-hover-text);\n}\n.item.in-range .bg {\n display: block;\n position: absolute;\n top: 0;\n left: 0;\n width: 100%;\n height: 100%;\n background-color: rgba(0, 43, 231, 0.1490196078);\n}\n.item:nth-of-type(7n + 1) .bg {\n border-radius: var(--item-size) 0 0 var(--item-size);\n width: var(--half-period-bg-w);\n left: calc(50% - var(--item-size) / 2);\n}\n.item:nth-of-type(7n) .bg {\n border-radius: 0 var(--item-size) var(--item-size) 0;\n width: var(--half-period-bg-w);\n}\n.item:nth-of-type(7n).range-start .bg {\n width: var(--item-size);\n left: calc(50% - var(--item-size) / 2);\n}\n.item.range-start .bg {\n border-top-left-radius: var(--item-size);\n border-bottom-left-radius: var(--item-size);\n width: var(--half-period-bg-w);\n left: calc(50% - var(--item-size) / 2);\n}\n.item.range-end .bg {\n border-top-right-radius: var(--item-size);\n border-bottom-right-radius: var(--item-size);\n width: var(--half-period-bg-w);\n}\n.item.range-start.range-end .bg {\n width: var(--item-size);\n}\n.item:nth-of-type(7n).range-start .bg, .item:nth-of-type(7n + 1).range-end .bg {\n width: var(--item-size);\n}\n\n.item .bg", " { border-radius: 0; }\n.item .bg", " { border-radius: 0; }\n.item .bg", " { border-radius: 0; }\n.item.in-range .bg", " { left: auto; right: 0; }\n.item.in-range .bg", " { left: auto; right: 0; }\n.item.in-range .bg", " { left: auto; right: 0; }\n.item:nth-of-type(7n + 1) .bg", " { left: auto; right: calc(50% - var(--item-size) / 2); border-radius: 0 var(--item-size) var(--item-size) 0; }\n.item:nth-of-type(7n + 1) .bg", " { left: auto; right: calc(50% - var(--item-size) / 2); border-radius: 0 var(--item-size) var(--item-size) 0; }\n.item:nth-of-type(7n + 1) .bg", " { left: auto; right: calc(50% - var(--item-size) / 2); border-radius: 0 var(--item-size) var(--item-size) 0; }\n.item:nth-of-type(7n) .bg", " { border-radius: var(--item-size) 0 0 var(--item-size); }\n.item:nth-of-type(7n) .bg", " { border-radius: var(--item-size) 0 0 var(--item-size); }\n.item:nth-of-type(7n) .bg", " { border-radius: var(--item-size) 0 0 var(--item-size); }\n.item:nth-of-type(7n).range-start .bg", " { left: auto; right: calc(50% - var(--item-size) / 2); }\n.item:nth-of-type(7n).range-start .bg", " { left: auto; right: calc(50% - var(--item-size) / 2); }\n.item:nth-of-type(7n).range-start .bg", " { left: auto; right: calc(50% - var(--item-size) / 2); }\n.item.range-start .bg", " {\n border-top-right-radius: var(--item-size);\n border-bottom-right-radius: var(--item-size);\n left: auto;\n right: calc(50% - var(--item-size) / 2);\n}\n.item.range-start .bg", " {\n border-top-right-radius: var(--item-size);\n border-bottom-right-radius: var(--item-size);\n left: auto;\n right: calc(50% - var(--item-size) / 2);\n}\n.item.range-start .bg", " {\n border-top-right-radius: var(--item-size);\n border-bottom-right-radius: var(--item-size);\n left: auto;\n right: calc(50% - var(--item-size) / 2);\n}\n.item.range-end .bg", " {\n border-top-left-radius: var(--item-size);\n border-bottom-left-radius: var(--item-size);\n}\n.item.range-end .bg", " {\n border-top-left-radius: var(--item-size);\n border-bottom-left-radius: var(--item-size);\n}\n.item.range-end .bg", " {\n border-top-left-radius: var(--item-size);\n border-bottom-left-radius: var(--item-size);\n}\n"])), cssDirLtrSelector1, cssDirLtrSelector2, cssDirLtrSelector3, cssDirLtrSelector1, cssDirLtrSelector2, cssDirLtrSelector3, cssDirLtrSelector1, cssDirLtrSelector2, cssDirLtrSelector3, cssDirLtrSelector1, cssDirLtrSelector2, cssDirLtrSelector3, cssDirLtrSelector1, cssDirLtrSelector2, cssDirLtrSelector3, cssDirLtrSelector1, cssDirLtrSelector2, cssDirLtrSelector3, cssDirLtrSelector1, cssDirLtrSelector2, cssDirLtrSelector3);
|
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
import { type BaseAttrs, type Emit2EventMap, UiBase } from '../web-component-base';
|
|
2
|
-
|
|
3
|
-
export
|
|
4
|
-
export declare const getWeekInOrder: (startAt?: Weeks | null) => Weeks[];
|
|
1
|
+
import { type BaseAttrs, type BaseEmits, type Emit2EventMap, UiBase } from '../web-component-base';
|
|
2
|
+
import { type Weeks } from './weeks';
|
|
3
|
+
export { type Weeks, weekKey, getWeekInOrder } from './weeks';
|
|
5
4
|
export interface Attrs extends BaseAttrs {
|
|
6
5
|
/**
|
|
7
6
|
* The showing time, used to determine the month to show on calendar.
|
|
@@ -44,7 +43,7 @@ export interface Attrs extends BaseAttrs {
|
|
|
44
43
|
*/
|
|
45
44
|
'show-other-month'?: boolean;
|
|
46
45
|
}
|
|
47
|
-
export interface Emits {
|
|
46
|
+
export interface Emits extends BaseEmits {
|
|
48
47
|
'select-time': Date;
|
|
49
48
|
'hover-item': Date;
|
|
50
49
|
}
|
|
@@ -75,7 +74,7 @@ export declare class Ele extends UiBase<Attrs, Emits> {
|
|
|
75
74
|
constructor();
|
|
76
75
|
connectedCallback(): void;
|
|
77
76
|
disconnectedCallback(): void;
|
|
78
|
-
protected _onAttrChanged(name: string, oldValue: string, newValue: string): void;
|
|
77
|
+
protected _onAttrChanged(name: string, oldValue: string | null, newValue: string | null): void;
|
|
79
78
|
private _onWeekStartAtChange;
|
|
80
79
|
private _onTimeChange;
|
|
81
80
|
private _onClick;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
var __freeze = Object.freeze;
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __template = (cooked, raw) => __freeze(__defProp(cooked, "raw", { value: __freeze(raw || cooked.slice()) }));
|
|
4
|
+
var _a, _b, _c;
|
|
5
|
+
import { html } from "../../utils.mjs";
|
|
6
|
+
import { Ele as I18nEle } from "../i18n/index.mjs";
|
|
7
|
+
I18nEle.define();
|
|
8
|
+
import { weekKey } from "./weeks.mjs";
|
|
9
|
+
export default html(_c || (_c = __template(['\n<div class="wrapper">', "</div>"])), weekKey.map(
|
|
10
|
+
(key) => html(_a || (_a = __template(['<dt-i18n class="week" i18n-key="date.', '" part="week"></dt-i18n>'])), key)
|
|
11
|
+
).join("") + [...Array(7 * 6)].map(
|
|
12
|
+
(_, i) => html(_b || (_b = __template(['<div class="item" part="item"><i class="bg"></i><i class="highlight"></i><span>', "</span></div>"])), i % 31 + 1)
|
|
13
|
+
).join(""));
|
|
@@ -1,40 +1,19 @@
|
|
|
1
|
-
var __freeze = Object.freeze;
|
|
2
1
|
var __defProp = Object.defineProperty;
|
|
3
2
|
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
4
3
|
var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
5
|
-
|
|
6
|
-
var _a, _b, _c, _d;
|
|
7
|
-
import { closestByEvent, css, debounce, html } from "../../utils.mjs";
|
|
8
|
-
import { Ele as I18nEle } from "../i18n/index.mjs";
|
|
9
|
-
I18nEle.define();
|
|
4
|
+
import { closestByEvent, debounce } from "../../utils.mjs";
|
|
10
5
|
import {
|
|
11
6
|
UiBase
|
|
12
7
|
} from "../web-component-base/index.mjs";
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
"tue",
|
|
18
|
-
"wed",
|
|
19
|
-
"thu",
|
|
20
|
-
"fri",
|
|
21
|
-
"sat"
|
|
22
|
-
];
|
|
23
|
-
export const getWeekInOrder = (startAt) => {
|
|
24
|
-
if (!startAt) startAt = "sun";
|
|
25
|
-
const index = weekKey.indexOf(startAt);
|
|
26
|
-
if (index === -1) return weekKey;
|
|
27
|
-
return [...weekKey.slice(index), ...weekKey.slice(0, index)];
|
|
28
|
-
};
|
|
8
|
+
import styleStr from "./index.css.mjs";
|
|
9
|
+
import html from "./index.html.mjs";
|
|
10
|
+
import { getWeekInOrder, weekKey } from "./weeks.mjs";
|
|
11
|
+
export { weekKey, getWeekInOrder } from "./weeks.mjs";
|
|
29
12
|
export class Ele extends UiBase {
|
|
30
13
|
constructor() {
|
|
31
14
|
super();
|
|
32
15
|
__publicField(this, "_style", styleStr);
|
|
33
|
-
__publicField(this, "_template", html
|
|
34
|
-
(key) => html(_b || (_b = __template(['<dt-i18n class="week" i18n-key="date.', '" part="week"></dt-i18n>'])), key)
|
|
35
|
-
).join("") + [...Array(7 * 6)].map(
|
|
36
|
-
(_, i) => html(_c || (_c = __template(['<div class="item" part="item"><i class="bg"></i><i class="highlight"></i><span>', "</span></div>"])), i % 31 + 1)
|
|
37
|
-
).join("")));
|
|
16
|
+
__publicField(this, "_template", html);
|
|
38
17
|
__publicField(this, "_onWeekStartAtChange", debounce(() => {
|
|
39
18
|
if (!this.isConnected) return;
|
|
40
19
|
const weekOrder = getWeekInOrder(this.weekStartAt);
|
|
@@ -58,8 +37,8 @@ export class Ele extends UiBase {
|
|
|
58
37
|
if (timeStart > timeEnd) {
|
|
59
38
|
[timeStart, timeEnd] = [timeEnd, timeStart];
|
|
60
39
|
}
|
|
61
|
-
const minTime =
|
|
62
|
-
const maxTime =
|
|
40
|
+
const minTime = this.minTime;
|
|
41
|
+
const maxTime = this.maxTime;
|
|
63
42
|
minTime.setHours(0, 0, 0, 0);
|
|
64
43
|
maxTime.setHours(0, 0, 0, 0);
|
|
65
44
|
if (maxTime < timeEnd) timeEnd = maxTime;
|
|
@@ -160,11 +139,11 @@ export class Ele extends UiBase {
|
|
|
160
139
|
return new Date(Number.isNaN(+v) ? v : +v);
|
|
161
140
|
}
|
|
162
141
|
get minTime() {
|
|
163
|
-
const v = this._getAttr("min-time", "");
|
|
142
|
+
const v = this._getAttr("min-time", "null");
|
|
164
143
|
return new Date(Number.isNaN(+v) ? v : +v);
|
|
165
144
|
}
|
|
166
145
|
get maxTime() {
|
|
167
|
-
const v = this._getAttr("max-time", "");
|
|
146
|
+
const v = this._getAttr("max-time", "null");
|
|
168
147
|
return new Date(Number.isNaN(+v) ? v : +v);
|
|
169
148
|
}
|
|
170
149
|
_setTimeAttr(name, value) {
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export const weekKey = [
|
|
2
|
+
"sun",
|
|
3
|
+
"mon",
|
|
4
|
+
"tue",
|
|
5
|
+
"wed",
|
|
6
|
+
"thu",
|
|
7
|
+
"fri",
|
|
8
|
+
"sat"
|
|
9
|
+
];
|
|
10
|
+
export const getWeekInOrder = (startAt) => {
|
|
11
|
+
if (!startAt) startAt = "sun";
|
|
12
|
+
const index = weekKey.indexOf(startAt);
|
|
13
|
+
if (index === -1) return weekKey;
|
|
14
|
+
return [...weekKey.slice(index), ...weekKey.slice(0, index)];
|
|
15
|
+
};
|
|
@@ -1,6 +1,10 @@
|
|
|
1
|
-
import { type BaseAttrs, type Emit2EventMap, UiBase } from '../web-component-base';
|
|
2
1
|
import { type Weeks } from '../calendar';
|
|
3
|
-
|
|
2
|
+
import { type Granularity as TimeGranularity } from '../hhmmss-ms-list-grp/selector';
|
|
3
|
+
import { type reExportPopoverAttrs } from '../popover/attr-sync-helper';
|
|
4
|
+
import { type BaseAttrs, type BaseEmits, type Emit2EventMap, UiBase } from '../web-component-base';
|
|
5
|
+
export declare const granularityList: readonly ["day", "hour", "minute", "second", "millisecond"];
|
|
6
|
+
export type Granularity = (typeof granularityList)[number];
|
|
7
|
+
export type Attrs = BaseAttrs & reExportPopoverAttrs & {
|
|
4
8
|
/**
|
|
5
9
|
* Set which day of the week is the first day.
|
|
6
10
|
* @type `'sun' | 'mon' | 'tue' | 'wed' | 'thu' | 'fri' | 'sat'`
|
|
@@ -10,7 +14,7 @@ export interface Attrs extends BaseAttrs {
|
|
|
10
14
|
/**
|
|
11
15
|
* The time of the calendar.
|
|
12
16
|
* @type {`string | number`} A value that can be passed to the Date constructor.
|
|
13
|
-
* @default Date.now()
|
|
17
|
+
* @default Math.min('max-time', Math.max('min-time', Date.now()))
|
|
14
18
|
*/
|
|
15
19
|
'current-time'?: string | number;
|
|
16
20
|
/**
|
|
@@ -23,39 +27,62 @@ export interface Attrs extends BaseAttrs {
|
|
|
23
27
|
* 选择器的粒度,表示最小可选的时间单位。默认为 millisecond。
|
|
24
28
|
* 例如设置为 'minute',则表示只能选择到分钟,秒和毫秒将被忽略。
|
|
25
29
|
*/
|
|
26
|
-
'min-granularity'?:
|
|
27
|
-
|
|
28
|
-
|
|
30
|
+
'min-granularity'?: Granularity;
|
|
31
|
+
/**
|
|
32
|
+
* The minimum time of the calendar display range.
|
|
33
|
+
* @type {`string | number`} A value that can be passed to the Date constructor.
|
|
34
|
+
*/
|
|
35
|
+
'min-time'?: string | number;
|
|
36
|
+
/**
|
|
37
|
+
* The maximum time of the calendar display range.
|
|
38
|
+
* @type {`string | number`} A value that can be passed to the Date constructor.
|
|
39
|
+
*/
|
|
40
|
+
'max-time'?: string | number;
|
|
41
|
+
};
|
|
42
|
+
export interface Emits extends BaseEmits {
|
|
29
43
|
'select-time': Date;
|
|
30
44
|
'open-change': boolean;
|
|
31
45
|
}
|
|
32
46
|
export type EventMap = Emit2EventMap<Emits>;
|
|
47
|
+
/**
|
|
48
|
+
* 日期时间选择器(单个时间点)
|
|
49
|
+
* 包括日历和时分秒毫秒选择。
|
|
50
|
+
*
|
|
51
|
+
* 存在一个 timeFormatter 方法,用于格式化时分秒毫秒显示时间。
|
|
52
|
+
*/
|
|
33
53
|
export declare class Ele extends UiBase<Attrs, Emits> {
|
|
34
54
|
static readonly tagName: "dt-date-time-selector";
|
|
35
55
|
static get observedAttributes(): string[];
|
|
56
|
+
private _getTimeAttr;
|
|
57
|
+
private _setTimeAttr;
|
|
58
|
+
private _getMaxMinTime;
|
|
36
59
|
get currentTime(): number | string | Date;
|
|
37
60
|
set currentTime(val: number | string | Date);
|
|
38
61
|
get showingTime(): number | string | Date;
|
|
39
62
|
set showingTime(val: number | string | Date);
|
|
63
|
+
get minTime(): number | string | Date;
|
|
64
|
+
set minTime(val: number | string | Date);
|
|
65
|
+
get maxTime(): number | string | Date;
|
|
66
|
+
set maxTime(val: number | string | Date);
|
|
40
67
|
get weekStartAt(): Weeks;
|
|
41
68
|
set weekStartAt(val: Weeks);
|
|
42
|
-
get minGranularity(): "
|
|
43
|
-
set minGranularity(val: '
|
|
69
|
+
get minGranularity(): NonNullable<Attrs["min-granularity"]>;
|
|
70
|
+
set minGranularity(val: NonNullable<Attrs['min-granularity']>);
|
|
44
71
|
protected _style: string;
|
|
45
72
|
protected _template: string;
|
|
46
73
|
private get _navEle();
|
|
47
74
|
private get _calendar();
|
|
48
75
|
private get _timeSelector();
|
|
49
|
-
private get
|
|
76
|
+
private get _popoverEle();
|
|
50
77
|
constructor();
|
|
51
78
|
connectedCallback(): void;
|
|
52
79
|
disconnectedCallback(): void;
|
|
53
|
-
protected _onAttrChanged(name: string, oldValue: string, newValue: string): void;
|
|
80
|
+
protected _onAttrChanged(name: string, oldValue: string | null, newValue: string | null): void;
|
|
54
81
|
private _render;
|
|
55
82
|
private _onCalendarSelect;
|
|
56
83
|
private _onNavChange;
|
|
57
|
-
private _onTimePopoverOpenChange;
|
|
58
84
|
private _onNavOpenToggle;
|
|
59
|
-
private
|
|
60
|
-
timeFormatter: (time: Date, minGranularity:
|
|
85
|
+
private _onTimeSelectorChange;
|
|
86
|
+
get timeFormatter(): (time: Date, minGranularity: TimeGranularity) => string;
|
|
87
|
+
set timeFormatter(fn: (time: Date, minGranularity: TimeGranularity) => string);
|
|
61
88
|
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
var __freeze = Object.freeze;
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __template = (cooked, raw) => __freeze(__defProp(cooked, "raw", { value: __freeze(raw || cooked.slice()) }));
|
|
4
|
+
var _a;
|
|
5
|
+
import { html } from "../../utils.mjs";
|
|
6
|
+
import { Ele as PopoverEle } from "../popover/index.mjs";
|
|
7
|
+
PopoverEle.define();
|
|
8
|
+
import { Ele as YyyyMmNavEle } from "../yyyymm-nav/index.mjs";
|
|
9
|
+
YyyyMmNavEle.define();
|
|
10
|
+
import { Ele as CalendarBaseEle } from "../calendar/index.mjs";
|
|
11
|
+
CalendarBaseEle.define();
|
|
12
|
+
import { Ele as HhMmSsMsSelector } from "../hhmmss-ms-list-grp/selector.mjs";
|
|
13
|
+
HhMmSsMsSelector.define();
|
|
14
|
+
export default html(_a || (_a = __template(['\n<dt-popover part="popover">\n <slot slot="trigger" name="trigger"><button>select date and time</button></slot>\n <div slot="pop" class="wrapper" part="pop">\n <dt-yyyymm-nav\n show-ctrl-btn-month-add\n show-ctrl-btn-month-sub\n ></dt-yyyymm-nav>\n <dt-calendar-base></dt-calendar-base>\n <dt-hhmmss-ms-selector></dt-hhmmss-ms-selector>\n </div>\n</dt-popover>\n'])));
|
|
@@ -1,56 +1,50 @@
|
|
|
1
|
-
var __freeze = Object.freeze;
|
|
2
1
|
var __defProp = Object.defineProperty;
|
|
3
2
|
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
4
3
|
var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
4
|
+
import { closestByEvent, debounce } from "../../utils.mjs";
|
|
5
|
+
import {
|
|
6
|
+
weekKey
|
|
7
|
+
} from "../calendar/index.mjs";
|
|
8
|
+
import {
|
|
9
|
+
granularityList as timeGranularityList
|
|
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";
|
|
8
17
|
import {
|
|
9
18
|
UiBase
|
|
10
19
|
} from "../web-component-base/index.mjs";
|
|
11
20
|
import {
|
|
12
21
|
Ele as YyyyMmNavEle
|
|
13
22
|
} from "../yyyymm-nav/index.mjs";
|
|
23
|
+
import html from "./index.html.mjs";
|
|
14
24
|
import { styleStr } from "./styleStr.mjs";
|
|
15
|
-
|
|
16
|
-
import {
|
|
17
|
-
Ele as CalendarBaseEle,
|
|
18
|
-
weekKey
|
|
19
|
-
} from "../calendar/index.mjs";
|
|
20
|
-
CalendarBaseEle.define();
|
|
21
|
-
import { Ele as HhMmSsMsListGrpEle } from "../hhmmss-ms-list-grp/index.mjs";
|
|
22
|
-
HhMmSsMsListGrpEle.define();
|
|
23
|
-
import { Ele as PopoverEle } from "../popover/index.mjs";
|
|
24
|
-
PopoverEle.define();
|
|
25
|
-
const granularityList = [
|
|
26
|
-
"day",
|
|
27
|
-
"hour",
|
|
28
|
-
"minute",
|
|
29
|
-
"second",
|
|
30
|
-
"millisecond"
|
|
31
|
-
];
|
|
25
|
+
export const granularityList = ["day", ...timeGranularityList];
|
|
32
26
|
export class Ele extends UiBase {
|
|
33
27
|
constructor() {
|
|
34
28
|
super();
|
|
35
29
|
__publicField(this, "_style", styleStr);
|
|
36
|
-
__publicField(this, "_template", html
|
|
30
|
+
__publicField(this, "_template", html);
|
|
37
31
|
__publicField(this, "_render", debounce(() => {
|
|
38
32
|
if (!this.isConnected) return;
|
|
39
33
|
const currentTime = this.currentTime;
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
this._navEle.millisecond =
|
|
43
|
-
|
|
44
|
-
const
|
|
34
|
+
const { _calendar, _timeSelector } = this;
|
|
35
|
+
_calendar.weekStartAt = this.weekStartAt;
|
|
36
|
+
this._navEle.millisecond = _calendar.timeStart = _calendar.timeEnd = +currentTime;
|
|
37
|
+
_calendar.showingTime = this.showingTime;
|
|
38
|
+
const { min, max } = this._getMaxMinTime();
|
|
39
|
+
_calendar.minTime = min;
|
|
40
|
+
_calendar.maxTime = max;
|
|
45
41
|
if (this.minGranularity === "day") {
|
|
46
|
-
|
|
47
|
-
selectorWrapper.style.display = "none";
|
|
42
|
+
_timeSelector.style.display = "none";
|
|
48
43
|
return;
|
|
49
44
|
}
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
this.shadowRoot.querySelector(".wrapper .time-echo").textContent = this.timeFormatter(currentTime, this.minGranularity);
|
|
45
|
+
_timeSelector.style.display = "";
|
|
46
|
+
_timeSelector.minGranularity = this.minGranularity;
|
|
47
|
+
_timeSelector.currentTime = currentTime;
|
|
54
48
|
}, 0));
|
|
55
49
|
__publicField(this, "_onCalendarSelect", (e) => {
|
|
56
50
|
e.stopPropagation();
|
|
@@ -63,40 +57,14 @@ export class Ele extends UiBase {
|
|
|
63
57
|
const { newTime } = e.detail;
|
|
64
58
|
this._calendar.showingTime = +newTime;
|
|
65
59
|
});
|
|
66
|
-
__publicField(this, "_onTimePopoverOpenChange", (e) => {
|
|
67
|
-
var _a2;
|
|
68
|
-
if (!(e.target instanceof PopoverEle)) return;
|
|
69
|
-
e.stopPropagation();
|
|
70
|
-
if (!e.detail) return this._render();
|
|
71
|
-
(_a2 = e.target.querySelector("dt-hhmmss-ms-list-grp")) == null ? void 0 : _a2.scrollToCurrentItem();
|
|
72
|
-
});
|
|
73
60
|
__publicField(this, "_onNavOpenToggle", (e) => {
|
|
74
|
-
var
|
|
61
|
+
var _a;
|
|
75
62
|
if (!(e.target instanceof YyyyMmNavEle)) return;
|
|
76
63
|
e.stopPropagation();
|
|
77
|
-
(
|
|
64
|
+
(_a = e.target.nextElementSibling) == null ? void 0 : _a.classList.toggle("hide", e.detail);
|
|
78
65
|
});
|
|
79
|
-
__publicField(this, "
|
|
80
|
-
|
|
81
|
-
if (!btn) return;
|
|
82
|
-
const calcTime = (time, ms) => {
|
|
83
|
-
time.setHours(0, 0, 0, 0);
|
|
84
|
-
time.setMilliseconds(ms);
|
|
85
|
-
return time;
|
|
86
|
-
};
|
|
87
|
-
this.currentTime = calcTime(
|
|
88
|
-
this.currentTime,
|
|
89
|
-
this._timeSelector.millisecond
|
|
90
|
-
);
|
|
91
|
-
this._timePopover.open = false;
|
|
92
|
-
});
|
|
93
|
-
__publicField(this, "timeFormatter", (time, minGranularity) => {
|
|
94
|
-
const t = new Date(+time - (/* @__PURE__ */ new Date()).getTimezoneOffset() * 60 * 1e3).toISOString().slice(11, 23);
|
|
95
|
-
if (minGranularity === "day") return "";
|
|
96
|
-
if (minGranularity === "hour") return t.slice(0, 2);
|
|
97
|
-
if (minGranularity === "minute") return t.slice(0, 5);
|
|
98
|
-
if (minGranularity === "second") return t.slice(0, 8);
|
|
99
|
-
return t;
|
|
66
|
+
__publicField(this, "_onTimeSelectorChange", (e) => {
|
|
67
|
+
this.currentTime = e.detail;
|
|
100
68
|
});
|
|
101
69
|
this._applyTemplate();
|
|
102
70
|
}
|
|
@@ -106,26 +74,68 @@ export class Ele extends UiBase {
|
|
|
106
74
|
"week-start-at",
|
|
107
75
|
"current-time",
|
|
108
76
|
"showing-time",
|
|
109
|
-
"min-
|
|
77
|
+
"min-time",
|
|
78
|
+
"max-time",
|
|
79
|
+
"min-granularity",
|
|
80
|
+
...popoverAttrKeys
|
|
110
81
|
];
|
|
111
82
|
}
|
|
112
|
-
|
|
113
|
-
const v = this._getAttr(
|
|
83
|
+
_getTimeAttr(name, defaultValue) {
|
|
84
|
+
const v = this._getAttr(name, defaultValue);
|
|
114
85
|
return new Date(Number.isNaN(+v) ? v : +v);
|
|
115
86
|
}
|
|
87
|
+
_setTimeAttr(name, value) {
|
|
88
|
+
const v = new Date(value);
|
|
89
|
+
if (Number.isNaN(+v)) return;
|
|
90
|
+
this.setAttribute(name, +v + "");
|
|
91
|
+
}
|
|
92
|
+
_getMaxMinTime({
|
|
93
|
+
min = +this._getTimeAttr("min-time", "NaN"),
|
|
94
|
+
max = +this._getTimeAttr("max-time", "NaN")
|
|
95
|
+
} = {}) {
|
|
96
|
+
if (Number.isNaN(min)) min = Number.NEGATIVE_INFINITY;
|
|
97
|
+
if (Number.isNaN(max)) max = Number.POSITIVE_INFINITY;
|
|
98
|
+
if (min > max) [min, max] = [max, min];
|
|
99
|
+
return { min, max };
|
|
100
|
+
}
|
|
101
|
+
get currentTime() {
|
|
102
|
+
const { min, max } = this._getMaxMinTime();
|
|
103
|
+
const currTime = this._getTimeAttr("current-time", "" + Date.now());
|
|
104
|
+
if (+currTime < min) return new Date(min);
|
|
105
|
+
if (+currTime > max) return new Date(max);
|
|
106
|
+
return currTime;
|
|
107
|
+
}
|
|
116
108
|
set currentTime(val) {
|
|
117
109
|
const v = new Date(val);
|
|
118
110
|
if (Number.isNaN(+v)) return;
|
|
119
|
-
|
|
111
|
+
const { min, max } = this._getMaxMinTime();
|
|
112
|
+
this._setTimeAttr("current-time", Math.min(max, Math.max(min, +v)));
|
|
120
113
|
}
|
|
121
114
|
get showingTime() {
|
|
122
|
-
|
|
123
|
-
return new Date(Number.isNaN(+v) ? v : +v);
|
|
115
|
+
return this._getTimeAttr("showing-time", "" + +this.currentTime);
|
|
124
116
|
}
|
|
125
117
|
set showingTime(val) {
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
118
|
+
this._setTimeAttr("showing-time", val);
|
|
119
|
+
}
|
|
120
|
+
get minTime() {
|
|
121
|
+
return this._getMaxMinTime().min;
|
|
122
|
+
}
|
|
123
|
+
set minTime(val) {
|
|
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);
|
|
129
|
+
}
|
|
130
|
+
get maxTime() {
|
|
131
|
+
return this._getMaxMinTime().max;
|
|
132
|
+
}
|
|
133
|
+
set maxTime(val) {
|
|
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);
|
|
129
139
|
}
|
|
130
140
|
get weekStartAt() {
|
|
131
141
|
return this._getAttr("week-start-at", "sun");
|
|
@@ -142,71 +152,77 @@ export class Ele extends UiBase {
|
|
|
142
152
|
this.setAttribute("min-granularity", val);
|
|
143
153
|
}
|
|
144
154
|
get _navEle() {
|
|
145
|
-
var
|
|
146
|
-
return (
|
|
155
|
+
var _a;
|
|
156
|
+
return (_a = this.shadowRoot) == null ? void 0 : _a.querySelector("dt-yyyymm-nav");
|
|
147
157
|
}
|
|
148
158
|
get _calendar() {
|
|
149
|
-
var
|
|
150
|
-
return (
|
|
159
|
+
var _a;
|
|
160
|
+
return (_a = this.shadowRoot) == null ? void 0 : _a.querySelector(
|
|
151
161
|
"dt-calendar-base"
|
|
152
162
|
);
|
|
153
163
|
}
|
|
154
164
|
get _timeSelector() {
|
|
155
|
-
var
|
|
156
|
-
return (
|
|
157
|
-
"dt-hhmmss-ms-
|
|
165
|
+
var _a;
|
|
166
|
+
return (_a = this.shadowRoot) == null ? void 0 : _a.querySelector(
|
|
167
|
+
"dt-hhmmss-ms-selector"
|
|
158
168
|
);
|
|
159
169
|
}
|
|
160
|
-
get
|
|
161
|
-
|
|
162
|
-
return (_a2 = this.shadowRoot) == null ? void 0 : _a2.querySelector("#time-popover");
|
|
170
|
+
get _popoverEle() {
|
|
171
|
+
return this.shadowRoot.querySelector("dt-popover");
|
|
163
172
|
}
|
|
164
173
|
connectedCallback() {
|
|
165
|
-
var _a2;
|
|
166
174
|
if (!super.connectedCallback()) return;
|
|
167
175
|
this._calendar.formatter = (i) => String(i).padStart(2, "0");
|
|
168
176
|
this._render();
|
|
177
|
+
popEleAttrSync2Parent(this, this._popoverEle);
|
|
169
178
|
this._calendar.addEventListener("select-time", this._onCalendarSelect);
|
|
170
179
|
this._navEle.addEventListener("change", this._onNavChange);
|
|
171
|
-
this._timePopover.addEventListener(
|
|
172
|
-
"open-change",
|
|
173
|
-
this._onTimePopoverOpenChange
|
|
174
|
-
);
|
|
175
180
|
this._navEle.addEventListener(
|
|
176
181
|
"popover-open-change",
|
|
177
182
|
this._onNavOpenToggle
|
|
178
183
|
);
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
184
|
+
this._timeSelector.addEventListener(
|
|
185
|
+
"select-time",
|
|
186
|
+
this._onTimeSelectorChange
|
|
187
|
+
);
|
|
188
|
+
this._timeSelector.addEventListener("open-change", this._stopEvent);
|
|
189
|
+
this.dispatchEvent("select-time", this.currentTime);
|
|
182
190
|
}
|
|
183
191
|
disconnectedCallback() {
|
|
184
|
-
var _a2;
|
|
185
192
|
if (!super.disconnectedCallback()) return;
|
|
193
|
+
clearupPopEleAttrSync2Parent(this);
|
|
186
194
|
this._calendar.removeEventListener(
|
|
187
195
|
"select-time",
|
|
188
196
|
this._onCalendarSelect
|
|
189
197
|
);
|
|
190
198
|
this._navEle.removeEventListener("change", this._onNavChange);
|
|
191
|
-
this._timePopover.removeEventListener(
|
|
192
|
-
"open-change",
|
|
193
|
-
this._onTimePopoverOpenChange
|
|
194
|
-
);
|
|
195
199
|
this._navEle.removeEventListener(
|
|
196
200
|
"popover-open-change",
|
|
197
201
|
this._onNavOpenToggle
|
|
198
202
|
);
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
203
|
+
this._timeSelector.removeEventListener(
|
|
204
|
+
"select-time",
|
|
205
|
+
this._onTimeSelectorChange
|
|
206
|
+
);
|
|
207
|
+
this._timeSelector.removeEventListener("open-change", this._stopEvent);
|
|
202
208
|
}
|
|
203
209
|
_onAttrChanged(name, oldValue, newValue) {
|
|
204
210
|
super._onAttrChanged(name, oldValue, newValue);
|
|
211
|
+
if (parentPopAttrSync2PopEle(name, oldValue, newValue, this._popoverEle)) {
|
|
212
|
+
return;
|
|
213
|
+
}
|
|
205
214
|
this._render();
|
|
206
215
|
if (name === "current-time") {
|
|
207
216
|
this.dispatchEvent("select-time", this.currentTime);
|
|
208
217
|
}
|
|
209
218
|
}
|
|
219
|
+
get timeFormatter() {
|
|
220
|
+
return this._timeSelector.timeFormatter;
|
|
221
|
+
}
|
|
222
|
+
set timeFormatter(fn) {
|
|
223
|
+
if (typeof fn !== "function") return;
|
|
224
|
+
this._timeSelector.timeFormatter = fn;
|
|
225
|
+
}
|
|
210
226
|
}
|
|
211
227
|
__publicField(Ele, "tagName", "dt-date-time-selector");
|
|
212
228
|
Ele.define();
|