@gez/date-time-kit
Version:
58 lines (57 loc) • 3.49 kB
JavaScript
var __freeze = Object.freeze;
var __defProp = Object.defineProperty;
var __template = (cooked, raw) => __freeze(__defProp(cooked, "raw", { value: __freeze(raw || cooked.slice()) }));
var _a, _b, _c;
import { getCurrentTzOffset, html } from "../../utils/index.mjs";
import { Ele as PeriodSelectorEle } from "../period-selector/index.mjs";
import { limitKeys } from "./quick-key.mjs";
PeriodSelectorEle.define();
import { Ele as I18nEle } from "../i18n/index.mjs";
I18nEle.define();
import { arrowRightSvg, backArrowSvg } from "../../assets/index.mjs";
export const utcText = (tzOffset = getCurrentTzOffset()) => tzOffset > 0 ? "UTC-".concat((~~(tzOffset / 60) + "").padStart(2, "0"), ":").concat((tzOffset % 60 + "").padStart(2, "0")) : "UTC+".concat((~~-(tzOffset / 60) + "").padStart(2, "0"), ":").concat((-tzOffset % 60 + "").padStart(2, "0"));
const genTzRadio = (tzOffset) => html(_a || (_a = __template(['<label><input type="radio" name="tz" value="', '" hidden/><i class="radio"></i><span>', "</span></label>"])), tzOffset, utcText(tzOffset));
export default html(_c || (_c = __template(['\n<dt-popover part="popover">\n<slot name="trigger" slot="trigger"><input type="button" value="quick selector"/></slot>\n<div class="menu top" part="menu top" slot="pop"\n ><div class="radio-grp">', '<label class="custom-trigger" data-field="custom"\n ><input type="radio" name="radio" value="custom" hidden\n /><i class="radio"></i><dt-i18n i18n-key="quick.custom" style="display:inline-block">Custom</dt-i18n\n >', '</label\n ></div\n ><i class="dividing-line"></i\n ><div class="tz-trigger" data-field="timezone"\n ><span\n ><dt-i18n i18n-key="quick.timezoneWithColon"></dt-i18n\n ><bdo>', "</bdo\n ></span\n >", '</div\n></div\n><div class="menu tz" part="menu tz"\n ><div class="title"\n >', '<span><dt-i18n i18n-key="quick.timezone"></dt-i18n></span\n ></div\n ><fieldset class="subtitle"\n ><legend><dt-i18n i18n-key="quick.recommend"></dt-i18n></legend\n >', '</fieldset\n ><fieldset class="subtitle"\n ><legend><dt-i18n i18n-key="quick.timezoneList"></dt-i18n></legend\n >', '</fieldset\n ></div\n><div class="menu custom" part="menu custom"\n ><div class="title"\n >', '<span><dt-i18n i18n-key="quick.custom" style="display:inline-block">Custom</dt-i18n></span\n ></div\n ><dt-period-selector></dt-period-selector\n ><div class="btns"\n ><button id="reset"><dt-i18n i18n-key="box.reset"></dt-i18n></button\n ><button id="done"><dt-i18n i18n-key="box.confirm"></dt-i18n></button\n ></div\n></div>\n</dt-popover>'])), limitKeys.map(
(k) => html(_b || (_b = __template(['<label data-field="', '"\n ><input type="radio" name="radio" value="', '" hidden\n /><i class="radio"></i><dt-i18n i18n-key="quick.', '">', "</dt-i18n\n ></label>"])), k, k, k, k)
).join(""), arrowRightSvg, utcText(), arrowRightSvg, backArrowSvg, [.../* @__PURE__ */ new Set([getCurrentTzOffset(), 2 * -60])].map(genTzRadio).join(""), [
-12,
-11,
-10,
-9.5,
-9,
-8,
-7,
-6,
-5,
-4,
-3,
-3.5,
-2,
-1,
0,
1,
2,
3,
3.5,
4,
4.5,
5,
5.5,
5.75,
6,
6.5,
7,
8,
8.75,
9,
9.5,
10,
10.5,
11,
12,
12.45,
13,
14
].map(
(tz) => tz === 2 || tz * -60 === getCurrentTzOffset() ? "" : genTzRadio(tz * -60)
).join(""), backArrowSvg);