@blueking/date-picker 2.0.0-beta.9 → 3.0.0-beta.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (39) hide show
  1. package/README.md +15 -10
  2. package/package.json +14 -79
  3. package/typings/components/baseline-select.vue.d.ts +12 -0
  4. package/typings/components/common-submit.vue.d.ts +10 -19
  5. package/typings/components/common-tab.vue.d.ts +10 -14
  6. package/typings/components/date-list.vue.d.ts +15 -0
  7. package/typings/components/date-panel.vue.d.ts +9 -28
  8. package/typings/components/date-picker.vue.d.ts +8 -15
  9. package/typings/components/date-title.vue.d.ts +6 -0
  10. package/typings/components/natural-picker.vue.d.ts +6 -13
  11. package/typings/components/panel-wrapper.vue.d.ts +12 -21
  12. package/typings/components/recent-picker.vue.d.ts +10 -28
  13. package/typings/components/timezone-picker.vue.d.ts +14 -19
  14. package/typings/date-picker.vue.d.ts +21 -44
  15. package/typings/hooks/use-keydown-enter.d.ts +1 -0
  16. package/typings/hooks/use-validate.d.ts +17 -0
  17. package/typings/lang/lang.d.ts +14 -4
  18. package/typings/utils/constant.d.ts +8 -5
  19. package/typings/utils/cookie.d.ts +4 -0
  20. package/typings/utils/date.d.ts +38 -15
  21. package/typings/utils/duration.d.ts +5 -0
  22. package/typings/utils/index.d.ts +4 -3
  23. package/typings/utils/provider.d.ts +20 -0
  24. package/typings/utils/store.d.ts +1 -1
  25. package/typings/utils/timezone.d.ts +4 -4
  26. package/typings/utils/types.d.ts +22 -14
  27. package/typings/vue2.d.ts +4 -30
  28. package/typings/vue3.d.ts +7 -2
  29. package/vue2/config.json +1 -1
  30. package/vue2/index.es.min.js +25578 -19189
  31. package/vue2/index.iife.min.js +36664 -76
  32. package/vue2/index.umd.min.js +29075 -57
  33. package/vue2/vue2.css +3520 -1
  34. package/vue3/config.json +1 -1
  35. package/vue3/index.es.min.js +2956 -1716
  36. package/vue3/index.iife.min.js +29562 -57
  37. package/vue3/index.umd.min.js +4554 -2
  38. package/vue3/vue3.css +796 -1
  39. package/typings/utils/utils.d.ts +0 -15
@@ -1,36 +1,43 @@
1
- var se = Object.defineProperty;
2
- var ce = (l, a, i) => a in l ? se(l, a, { enumerable: !0, configurable: !0, writable: !0, value: i }) : l[a] = i;
3
- var na = (l, a, i) => (ce(l, typeof a != "symbol" ? a + "" : a, i), i);
4
- import d from "dayjs";
5
- import { default as ni } from "dayjs";
6
- import Oa from "dayjs/plugin/customParseFormat";
7
- import ue from "dayjs/plugin/localizedFormat";
8
- import qa from "dayjs/plugin/timezone";
9
- import Fa from "dayjs/plugin/utc";
10
- import { provide as oe, inject as de, defineComponent as X, openBlock as p, createElementBlock as z, createVNode as E, unref as t, withCtx as j, Fragment as U, renderList as q, createBlock as K, createCommentVNode as sa, createTextVNode as G, toDisplayString as k, shallowRef as Q, watch as ma, createElementVNode as v, normalizeClass as da, withModifiers as Ga, ref as L, computed as J, normalizeStyle as Ja, withDirectives as fa, withKeys as ja, mergeProps as Ya, KeepAlive as me, resolveDynamicComponent as he, vShow as ve, onBeforeUnmount as be } from "vue";
11
- import { Tab as Ba, PopConfirm as fe, Popover as ca, Button as wa, Checkbox as pe, Select as Z, Input as Za, Exception as Ae, provideGlobalConfig as ge } from "bkui-vue";
12
- import { clickoutside as Aa } from "bkui-vue/lib/directives";
13
- import { Del as xe, AngleDoubleLeft as Ie, AngleLeft as Wa, AngleRight as Qa, AngleDoubleRight as ke, Close as ye } from "bkui-vue/lib/icon";
14
- import "bkui-vue/lib/styles/reset.css";
15
- import _e from "dayjs/locale/en";
16
- import we from "dayjs/locale/zh-cn";
17
- const De = (l) => {
18
- const a = document.cookie.match(new RegExp(`(^| )${l}=([^;]*)(;|$)`));
19
- return a ? a[2] : "";
20
- }, Me = {
1
+ var __defProp = Object.defineProperty;
2
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
3
+ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
4
+ import dayjs from "dayjs";
5
+ import { default as default2 } from "dayjs";
6
+ import customParseFormat from "dayjs/plugin/customParseFormat";
7
+ import localizedFormat from "dayjs/plugin/localizedFormat";
8
+ import tz from "dayjs/plugin/timezone";
9
+ import utc from "dayjs/plugin/utc";
10
+ import { defineComponent, useAttrs, useSlots, openBlock, createBlock, resolveDynamicComponent, h, renderSlot, effectScope, getCurrentScope, onScopeDispose, provide, inject, createElementBlock, createVNode, unref, withCtx, Fragment, renderList, ref, customRef, normalizeClass, toDisplayString, createElementVNode, createTextVNode, createCommentVNode, shallowRef, watch, withModifiers, computed, onActivated, normalizeStyle, withDirectives, withKeys, onMounted, vShow, nextTick, KeepAlive, onBeforeUnmount } from "vue";
11
+ import { provideGlobalConfig, Select, Tab, Exception, $bkPopover, Popover, Button, Checkbox, clickoutside, PopConfirm, Input } from "bkui-vue";
12
+ import { AngleDoubleLeft, AngleLeft, AngleRight, AngleDoubleRight, Close, Transfer, Del } from "bkui-vue/lib/icon";
13
+ import en from "dayjs/locale/en";
14
+ import cn from "dayjs/locale/zh-cn";
15
+ const getCookieByName = (name) => {
16
+ const match = document.cookie.match(new RegExp(`(^| )${name}=([^;]*)(;|$)`));
17
+ if (match) {
18
+ return match[2];
19
+ }
20
+ return "";
21
+ };
22
+ const naturalDateLangData = {
23
+ "N 天前": "N days ago",
21
24
  上周: "Last week",
22
25
  上月: "Last month",
23
26
  今天: "Today",
24
27
  今年: "This year",
28
+ 具体时间: "Specific time",
25
29
  "前 N 周": "Previous N weeks",
26
30
  "前 N 天": "Previous N days",
27
31
  前天: "The day before yesterday",
28
32
  前年: "The year before last",
29
33
  去年: "Last year",
34
+ 基于: "Based on",
35
+ 天前: "days ago",
30
36
  昨天: "Yesterday",
31
37
  本周: "This week",
32
38
  本月: "This month"
33
- }, ze = {
39
+ };
40
+ const timeUnitLangData = {
34
41
  分钟: "minute",
35
42
  周: "week",
36
43
  天: "day",
@@ -39,7 +46,8 @@ const De = (l) => {
39
46
  月: "month",
40
47
  毫秒: "millisecond",
41
48
  秒: "second"
42
- }, la = {
49
+ };
50
+ const shortTimeUnitLangData = {
43
51
  M: "月",
44
52
  d: "天",
45
53
  h: "小时",
@@ -48,7 +56,8 @@ const De = (l) => {
48
56
  s: "秒",
49
57
  w: "周",
50
58
  y: "年"
51
- }, ga = {
59
+ };
60
+ const langData = {
52
61
  前: "Previous",
53
62
  取消: "Cancel",
54
63
  将来: "Future",
@@ -73,6 +82,7 @@ const De = (l) => {
73
82
  格式: "Format",
74
83
  此刻: "now",
75
84
  浏览器时区: "Browser timezone",
85
+ 的最近: "Last",
76
86
  确定: "Confirm",
77
87
  示例: "Example",
78
88
  结束时间: "End Time",
@@ -80,208 +90,29 @@ const De = (l) => {
80
90
  至今: "so far",
81
91
  请输入: "Please enter",
82
92
  "请输入搜索(国家,城市,简称)": "Please enter search (country, city, abbreviation)",
93
+ 超出可选范围: "Out of range",
83
94
  近: "Last",
84
- "(至今)": " so far"
95
+ "(至今)": " so far",
96
+ ",无法选择": ", cannot be selected",
97
+ 时间范围不能小于: "Time range cannot be less than",
98
+ 时间范围不能大于: "Time range cannot be greater than",
99
+ 时间格式转换: "Time format conversion"
85
100
  };
86
- Object.keys(ga).reduce(
87
- (l, a) => (l[ga[a]] = a, l),
101
+ Object.keys(langData).reduce(
102
+ (pre, cur) => {
103
+ pre[langData[cur]] = cur;
104
+ return pre;
105
+ },
88
106
  {}
89
107
  );
90
- const pa = De("blueking_language") || "zh-cn", r = (l) => pa !== "en" ? la[l] || l : la[l] || ze[l] || Me[l] || ga[l] || l;
91
- var I = /* @__PURE__ */ ((l) => (l.Date = "date", l.FUTURE = "now+", l.NATURAL = "natural", l.RECENT = "now-", l))(I || {});
92
- const Xa = [
93
- {
94
- id: "s",
95
- name: r("秒")
96
- },
97
- {
98
- id: "m",
99
- name: r("分钟")
100
- },
101
- {
102
- id: "h",
103
- name: r("小时")
104
- },
105
- {
106
- id: "d",
107
- name: r("天")
108
- },
109
- {
110
- id: "w",
111
- name: r("周")
112
- },
113
- {
114
- id: "M",
115
- name: r("月")
116
- },
117
- {
118
- id: "y",
119
- name: r("年")
120
- }
121
- ], ua = Xa.map((l) => l.id).join("");
122
- var ia = /* @__PURE__ */ ((l) => (l.custom = "custom", l.default = "default", l.edit = "edit", l))(ia || {});
123
- const xa = [
124
- {
125
- id: "now/d",
126
- name: r("今天"),
127
- type: "default"
128
- /* default */
129
- },
130
- {
131
- id: "now-1d/d",
132
- name: r("昨天"),
133
- type: "default"
134
- /* default */
135
- },
136
- {
137
- id: "now-2d/d",
138
- name: r("前天"),
139
- type: "default"
140
- /* default */
141
- },
142
- {
143
- id: "now/w",
144
- name: r("本周"),
145
- type: "default"
146
- /* default */
147
- },
148
- {
149
- id: "now-1w/w",
150
- name: r("上周"),
151
- type: "default"
152
- /* default */
153
- },
154
- {
155
- id: "now/M",
156
- name: r("本月"),
157
- type: "default"
158
- /* default */
159
- },
160
- {
161
- id: "now-1M/M",
162
- name: r("上月"),
163
- type: "default"
164
- /* default */
165
- },
166
- {
167
- id: "now-nd/d",
168
- name: r("前 N 天"),
169
- prefix: r("前"),
170
- suffix: r("天"),
171
- type: "edit",
172
- unit: "d"
173
- },
174
- {
175
- id: "now-nw/w",
176
- name: r("前 N 周"),
177
- prefix: r("前"),
178
- suffix: r("周"),
179
- type: "edit",
180
- unit: "w"
181
- }
182
- ];
183
- var ba = /* @__PURE__ */ ((l) => (l.ALL = "all", l.NOW = "now", l))(ba || {});
184
- const Ra = [
185
- {
186
- id: "all",
187
- name: r("整")
188
- },
189
- {
190
- id: "now",
191
- name: r("至今")
192
- }
193
- ], Ee = [
194
- {
195
- id: "common",
196
- name: r("常用时间")
197
- },
198
- {
199
- id: "recent",
200
- name: r("最近使用")
201
- }
202
- ], Se = [
203
- {
204
- id: I.RECENT,
205
- name: r("最近")
206
- },
207
- {
208
- id: I.FUTURE,
209
- name: r("未来")
210
- },
211
- {
212
- id: I.NATURAL,
213
- name: r("自然日期")
214
- },
215
- {
216
- id: I.Date,
217
- name: r("日期选择")
218
- }
219
- ], Ce = "BK_DATE_PICKER_STORE", Pe = "BK_DATE_PICKER_STORE_TAB", Te = "blueking_timezone", Ia = (l = 1) => `${Ce}_${l}`, La = (l = 1) => `${Pe}_${l}`, Ve = [
220
- "YYYY-MM-DD HH:mm:ss",
221
- "YYYY-MM-DD HH:mm:ss,SSS",
222
- "YYYY-MM-DD HH:mm:ss.SSS",
223
- "YYYY-MM-DD+HH:mm:ss",
224
- "MM/DD/YYYY HH:mm:ss",
225
- "YYYYMMDDHHmmss",
226
- "YYYYMMDD HHmmss",
227
- "YYYYMMDD HHmmss.SSS",
228
- "DD/MMM/YYYY:HH:mm:ss",
229
- "DD/MMM/YYYY:HH:mm:ssZ",
230
- "DD/MMM/YYYY:HH:mm:ss Z",
231
- "DD/MMM/YYYY:HH:mm:ssZZ",
232
- "DD/MMM/YYYY:HH:mm:ss ZZ",
233
- "YYYY-MM-DDTHH:mm:ss",
234
- "YYYY-MM-DDTHH:mm:ss.SSS",
235
- "YYYYMMDDTHHmmssZ",
236
- "YYYYMMDDTHHmmss.SSSSSSZ",
237
- "YYYY-MM-DDTHH:mm:ss.SSSZ",
238
- "YYYY-MM-DDTHH:mm:ssZ",
239
- "YYYY-MM-DDTHH:mm:ss.SSSSSSZ"
240
- ], Ne = {
241
- "now/M~now/M": r("本月"),
242
- "now/d~now/d": r("今天"),
243
- "now/w~now/w": r("本周"),
244
- "now/y~now/y": r("今年"),
245
- "now-1M/M~now-1M/M": r("上月"),
246
- "now-1d/d~now-1d/d": r("昨天"),
247
- "now-1w/w~now-1w/w": r("上周"),
248
- "now-1y/y~now-1y/y": r("去年"),
249
- "now-2d/d~now-2d/d": r("前天"),
250
- "now-2y/y~now-2y/y": r("前年")
251
- }, ka = [
252
- ["now-5m", "now"],
253
- ["now-15m", "now"],
254
- ["now-30m", "now"],
255
- ["now-1h", "now"],
256
- ["now-6h", "now"],
257
- ["now-12h", "now"],
258
- ["now-24h", "now"],
259
- ["now-7d", "now"],
260
- ["now-30d", "now"],
261
- ["now/d", "now/d"],
262
- ["now/d", "now"],
263
- ["now-1d/d", "now-1d/d"],
264
- ["now-2d/d", "now-2d/d"],
265
- ["now/w", "now/w"],
266
- ["now/w", "now"],
267
- ["now-1w/w", "now-1w/w"],
268
- ["now/M", "now/M"],
269
- ["now/M", "now"],
270
- ["now-1M/M", "now-1M/M"],
271
- ["now-1M/M", "now"]
272
- ], C = "now", $e = /^(\d{4})[-/](\d+)[-/](\d+)[Tt\s]*(\d+)?:(\d+)?:(\d+)?[.:]?(\d*)$/, Xt = /\[([^\]]+)]|Y{1,4}|M{1,4}|D{1,2}|d{1,4}|H{1,2}|h{1,2}|a|A|m{1,2}|s{1,2}|Z{1,2}|SSS/g, ae = Symbol("DATE_PICKER_PROVIDER_KEY"), je = (l) => {
273
- oe(ae, l);
274
- }, ee = () => de(ae);
275
- d.extend(Fa);
276
- d.extend(qa);
277
- const Ye = [
278
- // {
279
- // label: '',
280
- // options: [
281
- // { label: 'Browser Time', searchIndex: 'browser time|cst|utc+08:00|china|cn', value: 'browser' },
282
- // // { label: 'Coordinated Universal Time', searchIndex: 'coordinated universal time|utc, gmt|utc', value: 'utc' },
283
- // ],
284
- // },
108
+ const lang = getCookieByName("blueking_language") || "zh-cn";
109
+ const t = (key) => {
110
+ if (lang !== "en") return shortTimeUnitLangData[key] || key;
111
+ return shortTimeUnitLangData[key] || timeUnitLangData[key] || naturalDateLangData[key] || langData[key] || key;
112
+ };
113
+ dayjs.extend(utc);
114
+ dayjs.extend(tz);
115
+ const timezoneData = [
285
116
  {
286
117
  label: "Africa",
287
118
  options: [
@@ -1118,7 +949,7 @@ const Ye = [
1118
949
  searchIndex: "asia/srednekolymsk||utc+11:00|russian federation|ru",
1119
950
  value: "Asia/Srednekolymsk"
1120
951
  },
1121
- { label: "Asia/Taipei", searchIndex: "asia/taipei|cst|utc+08:00|taiwan|tw", value: "Asia/Taipei" },
952
+ { label: "Asia/Taipei", searchIndex: "asia/taipei|cst|utc+08:00|china|cn", value: "Asia/Taipei" },
1122
953
  { label: "Asia/Tashkent", searchIndex: "asia/tashkent||utc+05:00|uzbekistan|uz", value: "Asia/Tashkent" },
1123
954
  { label: "Asia/Tbilisi", searchIndex: "asia/tbilisi||utc+04:00|georgia|ge", value: "Asia/Tbilisi" },
1124
955
  {
@@ -1617,314 +1448,1081 @@ const Ye = [
1617
1448
  }
1618
1449
  ]
1619
1450
  }
1620
- ], Be = () => {
1621
- const l = d.tz.guess(), a = [], i = Ye.map((e) => ({
1622
- label: e.label,
1623
- options: e.options.map((n) => {
1624
- const b = {
1625
- ...n,
1626
- ...Re(n.searchIndex)
1627
- };
1628
- return n.value === l && a.push({
1629
- ...n,
1630
- ...b,
1631
- label: b.label
1632
- }), b;
1633
- })
1634
- }));
1635
- return i.unshift({
1451
+ ];
1452
+ const getTimezoneDetails = () => {
1453
+ const browserTimeZone = dayjs.tz.guess();
1454
+ const defaultTimezoneList = [];
1455
+ const list = timezoneData.map((group) => {
1456
+ return {
1457
+ label: group.label,
1458
+ options: group.options.map((option) => {
1459
+ const info = {
1460
+ ...option,
1461
+ ...getTimezoneInfo(option.searchIndex)
1462
+ };
1463
+ if (option.value === browserTimeZone) {
1464
+ defaultTimezoneList.push({
1465
+ ...option,
1466
+ ...info,
1467
+ label: info.label
1468
+ });
1469
+ }
1470
+ return info;
1471
+ })
1472
+ };
1473
+ });
1474
+ list.unshift({
1636
1475
  label: "",
1637
- options: a
1638
- }), i;
1639
- }, Re = (l) => {
1640
- const a = l.split("|");
1476
+ options: defaultTimezoneList
1477
+ });
1478
+ return list;
1479
+ };
1480
+ const getTimezoneInfo = (searchIndex) => {
1481
+ const list = searchIndex.split("|");
1641
1482
  return {
1642
- abbreviation: a[1].toLocaleUpperCase(),
1643
- country: (a[3] || "").replace(/(\b\w)/g, (i) => i.toLocaleUpperCase()),
1644
- countryCode: a[4] || "",
1645
- utc: a[2].toLocaleUpperCase()
1483
+ abbreviation: list[1].toLocaleUpperCase(),
1484
+ country: (list[3] || "").replace(/(\b\w)/g, (v) => v.toLocaleUpperCase()),
1485
+ countryCode: list[4] || "",
1486
+ utc: list[2].toLocaleUpperCase()
1646
1487
  };
1647
- }, te = Be(), ie = (l) => te.reduce((a, i) => (a == null ? void 0 : a.label) === l ? a : i.options.find((e) => e.label === l), {}), oa = new RegExp(`now([+-]?\\d*)([${ua}]?)\\/?([${ua}]?)`), Le = new RegExp(`now[-](\\d+)([${ua}]{1})$`), Ue = new RegExp(`now[+](\\d+)([${ua}]{1})$`), ya = new RegExp(`now([+-]?\\d*)([${ua}]?)\\/([${ua}])$`);
1648
- class ra {
1649
- constructor(a = ["", ""], i = "YYYY-MM-DD HH:mm:ss", e = d.tz.guess()) {
1650
- na(this, "endDate");
1651
- na(this, "endNum");
1652
- na(this, "endUnit");
1653
- na(this, "startDate");
1654
- na(this, "startNum");
1655
- na(this, "startUnit");
1656
- this.dateValue = a, this.format = i, this.timezome = e;
1657
- const [n, b] = a;
1658
- this.startDate = n ? this.transformValue2Dayjs(n) : null, this.endDate = b ? this.transformValue2Dayjs(b, "end") : null;
1659
- }
1660
- dateDuration() {
1661
- if (!this.startDate || !this.endDate || !this.isValidate)
1662
- return;
1663
- let a = this.endDate.diff(this.startDate);
1664
- const i = 24 * 60 * 60 * 1e3;
1665
- switch (this.dateMode) {
1666
- case I.RECENT:
1667
- a = d().add(this.startNum, this.startUnit).diff(d());
1668
- break;
1669
- case I.FUTURE:
1670
- a = d().diff(
1671
- d().add(this.endNum, this.endUnit),
1672
- this.endUnit
1673
- );
1674
- break;
1675
- case I.NATURAL:
1676
- a = this.endDate.diff(this.startDate);
1677
- const n = 24 * 60 * 60 * 1e3;
1678
- a % n === n - 1 && (a += 1);
1679
- break;
1680
- default:
1681
- case I.Date:
1682
- a = this.endDate.diff(this.startDate);
1683
- break;
1684
- }
1685
- const e = a % i;
1686
- return e === i - 1 ? a += 1 : e === i - 1e3 && (a += 1e3), a;
1687
- }
1688
- toDisplayString() {
1689
- var b, h, m;
1690
- if (!this.startDate || !this.endDate || !this.isValidate)
1691
- return ((b = this.dateValue) == null ? void 0 : b.join(" ~ ")) || "";
1692
- if (this.dateMode === I.RECENT)
1693
- return `${r("近")} ${Math.abs(this.startNum)} ${r(
1694
- la[this.startUnit]
1695
- )}`;
1696
- if (this.dateMode === I.FUTURE)
1697
- return `${r("未来")} ${Math.abs(this.endNum)} ${r(
1698
- la[this.endUnit]
1699
- )}`;
1700
- const [a, i] = this.dateValue;
1701
- if (this.dateMode === I.NATURAL) {
1702
- const c = i !== C ? "" : r("(至今)"), s = xa.find((o) => o.id === a);
1703
- return s ? r(s.name) + c : `${`${r("前")} ${this.startNum} ${r(
1704
- la[this.startUnit]
1705
- )}`}${c}`;
1706
- }
1707
- let e = this.format;
1708
- if (a === C)
1709
- return `${r("此刻")} ~ ${(h = this.endDate) == null ? void 0 : h.format(this.format)}`;
1710
- if (i === C)
1711
- return `${(m = this.startDate) == null ? void 0 : m.format(this.format)} ~ ${r("此刻")}`;
1712
- const n = ["Y", "M", "D", "H", "m", "s"].reduce(
1713
- (c, s, o, y) => (o < 1 || (this.format.indexOf(s) > this.format.indexOf(y[o - 1]) ? c.push(s) : c = []), c),
1714
- ["Y"]
1715
- );
1716
- if (n.length > 1 && n.includes("D") && this.startDate.isSame(this.endDate, "year")) {
1717
- const [, c] = this.format.match(/(Y+)/) || [];
1718
- let s = this.format.replace(c, this.startDate.format(c));
1719
- if (e = e.replace(/Y+[^\w\s]*/, ""), this.startDate.isSame(this.endDate, "day") && this.startDate.isSame(this.endDate, "month")) {
1720
- const [, y] = this.format.match(/(M+)/) || [];
1721
- if (s = s.replace(y, this.startDate.format(y)), e = e.replace(/M+[^\w\s]*/, ""), this.startDate.isSame(this.endDate, "day")) {
1722
- const [, S] = this.format.match(/(d+|D+)/) || [];
1723
- s = s.replace(S, this.startDate.format(S)), e = e.replace(/(d|D)+[^\w\s]*/, "");
1724
- }
1725
- }
1726
- const o = s.replace(e, "").slice(-1);
1727
- return s.length <= e.length ? `${this.startDate.format(this.format)} ~ ${this.endDate.format(this.format)}` : s.replace(
1728
- `${o.match(/([^\w\s]{1})/) ? o : ""}${e}`,
1729
- ` ( ${this.startDate.format(e)} ~ ${this.endDate.format(e)} )`
1730
- );
1731
- }
1732
- return `${this.startDate.format(this.format)} ~ ${this.endDate.format(this.format)}`;
1733
- }
1734
- toEmitValue() {
1735
- var a, i, e, n;
1736
- return [
1737
- this.dateMode === I.Date ? [
1738
- this.dateValue[0] === C ? C : (a = this.startDate) == null ? void 0 : a.valueOf(),
1739
- this.dateValue[1] === C ? C : (i = this.endDate) == null ? void 0 : i.valueOf()
1740
- ] : [...this.dateValue],
1741
- [
1488
+ };
1489
+ const timezoneDetails = getTimezoneDetails();
1490
+ const getTimezoneInfoByValue = (value) => {
1491
+ return timezoneDetails.reduce((pre, group) => {
1492
+ if ((pre == null ? void 0 : pre.label) === value) return pre;
1493
+ return group.options.find((option) => option.label === value);
1494
+ }, void 0);
1495
+ };
1496
+ const _sfc_main$b = /* @__PURE__ */ defineComponent({
1497
+ ...{
1498
+ name: "TimezonePicker",
1499
+ inheritAttrs: false
1500
+ },
1501
+ __name: "timezone-picker",
1502
+ props: {
1503
+ timezoneOptions: { default: () => timezoneDetails },
1504
+ value: {}
1505
+ },
1506
+ emits: ["update:value"],
1507
+ setup(__props, { emit: __emit }) {
1508
+ provideGlobalConfig({
1509
+ prefix: "bk"
1510
+ });
1511
+ const emits = __emit;
1512
+ const $attrs = useAttrs();
1513
+ const props = __props;
1514
+ const slots = useSlots();
1515
+ const TimezonePicker = () => {
1516
+ return h(
1517
+ Select,
1742
1518
  {
1743
- dayjs: this.startDate,
1744
- formatText: (e = this.startDate) == null ? void 0 : e.format(this.format)
1519
+ class: $attrs.class + " bk-timezone-picker",
1520
+ clearable: $attrs.clearable ?? false,
1521
+ filterOption: handleSearch,
1522
+ filterable: true,
1523
+ inputSearch: false,
1524
+ modelValue: props.value,
1525
+ noMatchText: t("无匹配数据"),
1526
+ placeholder: t("请输入搜索(国家,城市,简称)"),
1527
+ popoverOptions: {
1528
+ "ext-cls": "__bk-date-picker-popover__ __bk-timezone-picker-popover__ ",
1529
+ minWidth: 1600
1530
+ },
1531
+ searchPlaceholder: t("请输入搜索(国家,城市,简称)"),
1532
+ onChange: handleChange,
1533
+ ...$attrs
1745
1534
  },
1746
1535
  {
1747
- dayjs: this.endDate,
1748
- formatText: (n = this.endDate) == null ? void 0 : n.format(this.format)
1536
+ default: () => [
1537
+ renderSlot(slots, "default", { options: props.timezoneOptions }, () => {
1538
+ return props.timezoneOptions.map((group) => {
1539
+ if (group.label.length < 1) {
1540
+ return group.options.map((item) => {
1541
+ return renderSlot(slots, "option", { option: item }, () => [
1542
+ h(
1543
+ Select.Option,
1544
+ {
1545
+ ...item,
1546
+ id: item.label,
1547
+ key: item.label,
1548
+ name: item.label
1549
+ },
1550
+ {
1551
+ default: () => [
1552
+ h(
1553
+ "div",
1554
+ {
1555
+ class: {
1556
+ "bk-timezone-picker-option": true,
1557
+ "is-selected": item.label === props.value
1558
+ }
1559
+ },
1560
+ [
1561
+ h("span", { class: "option-name" }, `${t("浏览器时区")} ${item.label}`),
1562
+ h("span", { class: "option-country" }, `${item.country}, ${item.abbreviation}`),
1563
+ h("span", { class: "option-utc" }, item.utc)
1564
+ ]
1565
+ )
1566
+ ]
1567
+ }
1568
+ )
1569
+ ]);
1570
+ });
1571
+ } else {
1572
+ if (!group.options.length) return null;
1573
+ return h(
1574
+ Select.Group,
1575
+ {
1576
+ key: group.label,
1577
+ label: group.label
1578
+ },
1579
+ {
1580
+ default: () => group.options.map((item) => {
1581
+ return renderSlot(slots, "option", { option: item }, () => [
1582
+ h(
1583
+ Select.Option,
1584
+ {
1585
+ ...item,
1586
+ id: item.label,
1587
+ key: item.label,
1588
+ name: item.label
1589
+ },
1590
+ {
1591
+ default: () => [
1592
+ h(
1593
+ "div",
1594
+ {
1595
+ class: {
1596
+ "bk-timezone-picker-option": true,
1597
+ "is-selected": item.label === props.value
1598
+ }
1599
+ },
1600
+ [
1601
+ h("span", { class: "option-name" }, item.label),
1602
+ h("span", { class: "option-country" }, `${item.country}, ${item.abbreviation}`),
1603
+ h("span", { class: "option-utc" }, item.utc)
1604
+ ]
1605
+ )
1606
+ ]
1607
+ }
1608
+ )
1609
+ ]);
1610
+ })
1611
+ }
1612
+ );
1613
+ }
1614
+ });
1615
+ })
1616
+ ]
1749
1617
  }
1750
- ]
1751
- ];
1752
- }
1753
- transformValue2Dayjs(a, i = "start") {
1754
- const e = isNaN(a) ? a : +a;
1755
- let n = d(e);
1756
- if (typeof e == "number" || d.isDayjs(e) || n.isValid())
1757
- return d.tz(n.valueOf(), this.timezome);
1758
- const [, b, h, m] = e.match(oa) || [];
1759
- return i === "start" ? (this.startNum = Math.abs(+b), this.startUnit = h || m) : i === "end" && (this.endNum = Math.abs(+b), this.endUnit = h || m), b ? n = d().add(+b, h || m) : e === C && (n = d()), m ? (n = i === "start" ? d(d(n.isValid() ? n : void 0).valueOf()) : d(d(n.isValid() ? n : void 0)), i === "start" ? d.tz(n.valueOf(), this.timezome).startOf(m) : d.tz(n.valueOf(), this.timezome).endOf(m)) : d.tz(n.valueOf(), this.timezome);
1760
- }
1761
- updateDateValue(a, i) {
1762
- this.dateValue = a;
1763
- const [e, n] = a;
1764
- i && (this.timezome = i), this.startDate = e ? this.transformValue2Dayjs(e) : null, this.endDate = n ? this.transformValue2Dayjs(n, "end") : null;
1765
- }
1766
- updateFormat(a) {
1767
- this.format = a;
1618
+ );
1619
+ };
1620
+ const handleChange = (val) => {
1621
+ const info = getTimezoneInfoByValue(val);
1622
+ emits("update:value", val, info);
1623
+ };
1624
+ const handleSearch = (keyword, timezone) => {
1625
+ var _a, _b, _c, _d;
1626
+ return ((_a = timezone.label) == null ? void 0 : _a.toLowerCase().includes(keyword.toLowerCase())) || ((_b = timezone.country) == null ? void 0 : _b.toLowerCase().includes(keyword.toLowerCase())) || ((_c = timezone.abbreviation) == null ? void 0 : _c.toLowerCase().includes(keyword.toLowerCase())) || ((_d = timezone.utc) == null ? void 0 : _d.toLowerCase().includes(keyword.toLowerCase()));
1627
+ };
1628
+ return (_ctx, _cache) => {
1629
+ return openBlock(), createBlock(resolveDynamicComponent(TimezonePicker));
1630
+ };
1768
1631
  }
1769
- get dateMode() {
1770
- const [a, i] = this.dateValue;
1771
- if (typeof a == "number" || typeof i == "number" || d.isDayjs(a) || d.isDayjs(i) || d(a).isValid() || d(i).isValid())
1772
- return I.Date;
1773
- if (a === C && Ue.test(i))
1774
- return I.FUTURE;
1775
- if (i === C && Le.test(a))
1776
- return I.RECENT;
1777
- if (Ne[this.dateValue.join("~")])
1778
- return I.NATURAL;
1779
- if (ya.test(a) && (ya.test(i) || i === C)) {
1780
- const [, e, n, b] = a.match(oa) || [], [, h, m, c] = i.match(oa) || [];
1781
- if (b && (i === C || e && +h == -1 && n === b && m === c && n === m))
1782
- return I.NATURAL;
1632
+ });
1633
+ function useKeydownEnter(callback) {
1634
+ const scope = effectScope();
1635
+ const handleKeydown = (event) => {
1636
+ if (event.key === "Enter") {
1637
+ callback(event);
1783
1638
  }
1784
- return I.Date;
1785
- }
1786
- get endDisplayText() {
1787
- var a;
1788
- return d.tz(((a = this.endDate) == null ? void 0 : a.valueOf()) || void 0, this.timezome).format(this.format);
1789
- }
1790
- get isValidate() {
1791
- var a, i;
1792
- return ((a = this.startDate) == null ? void 0 : a.isValid()) && ((i = this.endDate) == null ? void 0 : i.isValid());
1793
- }
1794
- get recentOrFuturedateNum() {
1795
- if (this.dateMode === I.RECENT)
1796
- return this.startNum;
1797
- if (this.dateMode === I.FUTURE)
1798
- return this.endNum;
1799
- }
1800
- get recentOrFuturedateUnit() {
1801
- return this.dateMode === I.RECENT ? this.startUnit : this.dateMode === I.FUTURE ? this.endUnit : "m";
1802
- }
1803
- get startDisplayText() {
1804
- var a;
1805
- return d.tz(((a = this.startDate) == null ? void 0 : a.valueOf()) || void 0, this.timezome).format(this.format);
1639
+ };
1640
+ scope.run(() => {
1641
+ window.addEventListener("keydown", handleKeydown);
1642
+ });
1643
+ const stop = () => {
1644
+ scope.stop();
1645
+ window.removeEventListener("keydown", handleKeydown);
1646
+ };
1647
+ if (getCurrentScope()) {
1648
+ onScopeDispose(stop);
1806
1649
  }
1650
+ return stop;
1807
1651
  }
1808
- const _a = (l, a = "start", i) => {
1809
- const e = isNaN(l) ? l : +l;
1810
- let n = d(e);
1811
- if (typeof e == "number" || d.isDayjs(e) || n.isValid())
1812
- return d.tz(n.valueOf(), i || d.tz.guess());
1813
- const [, b, h, m] = e.match(oa) || [];
1814
- return b ? n = d().add(+b, h || m || "d") : e === C && (n = d()), m ? (n = a === "start" ? d.tz(d(n.isValid() ? n : void 0).valueOf(), i).startOf(m) : d.tz(d(n.isValid() ? n : void 0), i).endOf(m), n != null && n.isValid() ? n : void 0) : n.isValid() ? d.tz(n.valueOf(), i || d.tz.guess()) : void 0;
1815
- }, ai = (l, a) => {
1816
- if (!Array.isArray(l) || l.length < 1)
1817
- return [];
1818
- const [i, e] = l || [], n = _a(i, "start", a), b = _a(e, "end", a);
1819
- return [n, b];
1820
- }, ne = (l, a = "local") => {
1821
- const e = (a === "local" ? localStorage : sessionStorage).getItem(l);
1822
- let n = [];
1823
- if (e)
1824
- try {
1825
- n = JSON.parse(e);
1826
- } catch {
1827
- n = [];
1828
- }
1829
- return Array.isArray(n) || (n = []), n;
1830
- }, re = (l, a, i = "local") => {
1831
- let e = [];
1832
- const n = i === "local" ? localStorage : sessionStorage, b = n.getItem(a);
1833
- if (b)
1834
- try {
1835
- e = JSON.parse(b);
1836
- } catch {
1837
- e = [];
1838
- }
1839
- Array.isArray(e) || (e = []), !e.some((h) => h[0] === l[0] && h[1] === l[1]) && (e.unshift(l), n.setItem(a, JSON.stringify(e.slice(0, 10))));
1840
- }, He = { class: "common-panel-tab" }, Ua = /* @__PURE__ */ X({
1841
- __name: "common-tab",
1842
- props: {
1843
- /** modelValue 选中的tab */
1844
- modelValue: {
1845
- required: !0,
1846
- type: String
1847
- },
1848
- /** panels */
1849
- panels: {
1850
- required: !0,
1851
- type: Array
1852
- },
1853
- showDeleteAll: {
1854
- default: !1,
1855
- type: Boolean
1856
- }
1652
+ var DateMode = /* @__PURE__ */ ((DateMode2) => {
1653
+ DateMode2["Date"] = "date";
1654
+ DateMode2["FUTURE"] = "now+";
1655
+ DateMode2["NATURAL"] = "natural";
1656
+ DateMode2["RECENT"] = "now-";
1657
+ return DateMode2;
1658
+ })(DateMode || {});
1659
+ const DateUnitList = [
1660
+ {
1661
+ id: "s",
1662
+ name: t("")
1857
1663
  },
1858
- setup(l) {
1859
- return (a, i) => (p(), z("div", He, [
1860
- E(t(Ba), {
1861
- active: l.modelValue,
1862
- "onUpdate:active": i[0] || (i[0] = (e) => a.$emit("update:modelValue", e)),
1863
- type: "unborder-card"
1864
- }, {
1865
- default: j(() => [
1866
- (p(!0), z(
1867
- U,
1868
- null,
1869
- q(l.panels, (e) => (p(), K(t(Ba).TabPanel, {
1870
- key: e.id,
1871
- label: e.name,
1872
- name: e.id
1873
- }, null, 8, ["label", "name"]))),
1874
- 128
1875
- /* KEYED_FRAGMENT */
1876
- ))
1877
- ]),
1878
- _: 1
1879
- /* STABLE */
1880
- }, 8, ["active"]),
1881
- l.showDeleteAll ? (p(), K(t(fe), {
1882
- key: 0,
1883
- "cancel-text": t(r)("取消"),
1884
- "confirm-text": t(r)("确定"),
1885
- content: t(r)("是否清空最近使用?"),
1886
- trigger: "click",
1887
- width: 189,
1888
- onConfirm: i[1] || (i[1] = (e) => a.$emit("confirm")),
1889
- "ext-cls": "__bk-date-picker-popover__ __bk-date-picker-popover-delete__"
1890
- }, {
1891
- default: j(() => [
1892
- E(t(xe), { class: "delete-all" })
1893
- ]),
1894
- _: 1
1895
- /* STABLE */
1896
- }, 8, ["cancel-text", "confirm-text", "content"])) : sa("v-if", !0)
1897
- ]));
1664
+ {
1665
+ id: "m",
1666
+ name: t("分钟")
1667
+ },
1668
+ {
1669
+ id: "h",
1670
+ name: t("小时")
1671
+ },
1672
+ {
1673
+ id: "d",
1674
+ name: t("天")
1675
+ },
1676
+ {
1677
+ id: "w",
1678
+ name: t("周")
1679
+ },
1680
+ {
1681
+ id: "M",
1682
+ name: t("月")
1683
+ },
1684
+ {
1685
+ id: "y",
1686
+ name: t("")
1898
1687
  }
1899
- }), Da = /* @__PURE__ */ X({
1900
- __name: "common-submit",
1901
- props: {
1902
- disableTips: {},
1903
- disabled: { type: Boolean }
1688
+ ];
1689
+ const dateUnit = DateUnitList.map((item) => item.id).join("");
1690
+ var NaturalOptionType = /* @__PURE__ */ ((NaturalOptionType2) => {
1691
+ NaturalOptionType2["custom"] = "custom";
1692
+ NaturalOptionType2["default"] = "default";
1693
+ NaturalOptionType2["edit"] = "edit";
1694
+ NaturalOptionType2["specific"] = "specific";
1695
+ return NaturalOptionType2;
1696
+ })(NaturalOptionType || {});
1697
+ const CommonNaturalOptions = [
1698
+ {
1699
+ id: "now/d",
1700
+ name: t("今天"),
1701
+ type: "default"
1702
+ /* default */
1904
1703
  },
1905
- emits: ["submit"],
1906
- setup(l) {
1907
- return (a, i) => {
1908
- var e;
1909
- return p(), z(
1910
- U,
1911
- null,
1912
- [
1913
- E(t(ca), {
1914
- content: a.disableTips,
1915
- disabled: !a.disabled || !((e = a.disableTips) != null && e.length)
1916
- }, {
1917
- default: j(() => [
1918
- E(t(wa), {
1919
- disabled: a.disabled,
1920
- outline: !0,
1921
- onClick: i[0] || (i[0] = (n) => a.$emit("submit")),
1704
+ {
1705
+ id: "now-1d/d",
1706
+ name: t("昨天"),
1707
+ type: "default"
1708
+ /* default */
1709
+ },
1710
+ {
1711
+ id: "now-2d/d",
1712
+ name: t("前天"),
1713
+ type: "default"
1714
+ /* default */
1715
+ },
1716
+ {
1717
+ id: "now/w",
1718
+ name: t("本周"),
1719
+ type: "default"
1720
+ /* default */
1721
+ },
1722
+ {
1723
+ id: "now-1w/w",
1724
+ name: t("上周"),
1725
+ type: "default"
1726
+ /* default */
1727
+ },
1728
+ {
1729
+ id: "now/M",
1730
+ name: t("本月"),
1731
+ type: "default"
1732
+ /* default */
1733
+ },
1734
+ {
1735
+ id: "now-1M/M",
1736
+ name: t("上月"),
1737
+ type: "default"
1738
+ /* default */
1739
+ },
1740
+ {
1741
+ id: "now-nd/d",
1742
+ name: t("前 N 天"),
1743
+ prefix: t("前"),
1744
+ suffix: t("天"),
1745
+ type: "edit",
1746
+ unit: "d"
1747
+ },
1748
+ {
1749
+ id: "now-nw/w",
1750
+ name: t("前 N 周"),
1751
+ prefix: t("前"),
1752
+ suffix: t("周"),
1753
+ type: "edit",
1754
+ unit: "w"
1755
+ }
1756
+ ];
1757
+ var NaturalUnit = /* @__PURE__ */ ((NaturalUnit2) => {
1758
+ NaturalUnit2["ALL"] = "all";
1759
+ NaturalUnit2["NOW"] = "now";
1760
+ return NaturalUnit2;
1761
+ })(NaturalUnit || {});
1762
+ const naturalUnitOptions = [
1763
+ {
1764
+ id: "all",
1765
+ name: t("整")
1766
+ },
1767
+ {
1768
+ id: "now",
1769
+ name: t("至今")
1770
+ }
1771
+ ];
1772
+ const panels = [
1773
+ {
1774
+ id: "common",
1775
+ name: t("常用时间")
1776
+ },
1777
+ {
1778
+ id: "recent",
1779
+ name: t("最近使用")
1780
+ }
1781
+ ];
1782
+ const datePickTabList = [
1783
+ {
1784
+ id: DateMode.Date,
1785
+ name: t("日期选择")
1786
+ },
1787
+ {
1788
+ id: DateMode.RECENT,
1789
+ name: t("最近")
1790
+ },
1791
+ {
1792
+ id: DateMode.FUTURE,
1793
+ name: t("未来")
1794
+ },
1795
+ {
1796
+ id: DateMode.NATURAL,
1797
+ name: t("自然日期")
1798
+ }
1799
+ ];
1800
+ const storeKey = "BK_DATE_PICKER_STORE";
1801
+ const storeTabKey = "BK_DATE_PICKER_STORE_TAB";
1802
+ const timezoneStoreKey = "blueking_timezone";
1803
+ const getStoreKey = (key = 1) => `${storeKey}_${key}`;
1804
+ const getStoreTabKey = (key = 1) => `${storeTabKey}_${key}`;
1805
+ const dateFormatList = [
1806
+ "YYYY-MM-DD HH:mm:ss",
1807
+ "YYYY-MM-DD HH:mm:ss.SSS",
1808
+ "YYYY-MM-DD+HH:mm:ss",
1809
+ "MM/DD/YYYY HH:mm:ss",
1810
+ "YYYYMMDDHHmmss",
1811
+ "YYYYMMDD HHmmss",
1812
+ "YYYYMMDD HHmmss.SSS",
1813
+ "DD/MMM/YYYY:HH:mm:ss",
1814
+ "DD/MMM/YYYY:HH:mm:ssZ",
1815
+ "DD/MMM/YYYY:HH:mm:ss Z",
1816
+ "DD/MMM/YYYY:HH:mm:ssZZ",
1817
+ "DD/MMM/YYYY:HH:mm:ss ZZ",
1818
+ "YYYY-MM-DDTHH:mm:ss",
1819
+ "YYYY-MM-DDTHH:mm:ss.SSS",
1820
+ "YYYYMMDDTHHmmssZ",
1821
+ "YYYYMMDDTHHmmss.SSSSSSZ",
1822
+ "YYYY-MM-DDTHH:mm:ss.SSSZ",
1823
+ "YYYY-MM-DDTHH:mm:ssZ",
1824
+ "YYYY-MM-DDTHH:mm:ss.SSSSSSZ"
1825
+ ];
1826
+ const naturalDateShortcutMap = {
1827
+ "now/M~now/M": t("本月"),
1828
+ "now/d~now/d": t("今天"),
1829
+ "now/w~now/w": t("本周"),
1830
+ "now/y~now/y": t("今年"),
1831
+ "now-1M/M~now-1M/M": t("上月"),
1832
+ "now-1d/d~now-1d/d": t("昨天"),
1833
+ "now-1w/w~now-1w/w": t("上周"),
1834
+ "now-1y/y~now-1y/y": t("去年"),
1835
+ "now-2d/d~now-2d/d": t("前天"),
1836
+ "now-2y/y~now-2y/y": t("前年")
1837
+ };
1838
+ const commonDateList = [
1839
+ ["now-5m", "now"],
1840
+ ["now-15m", "now"],
1841
+ ["now-30m", "now"],
1842
+ ["now-1h", "now"],
1843
+ ["now-6h", "now"],
1844
+ ["now-12h", "now"],
1845
+ ["now-24h", "now"],
1846
+ ["now-7d", "now"],
1847
+ ["now-30d", "now"],
1848
+ ["now/d", "now/d"],
1849
+ ["now/d", "now"],
1850
+ ["now-1d/d", "now-1d/d"],
1851
+ ["now-2d/d", "now-2d/d"],
1852
+ ["now/w", "now/w"],
1853
+ ["now/w", "now"],
1854
+ ["now-1w/w", "now-1w/w"],
1855
+ ["now/M", "now/M"],
1856
+ ["now/M", "now"],
1857
+ ["now-1M/M", "now-1M/M"],
1858
+ ["now-1M/M", "now"]
1859
+ ];
1860
+ const NowConstant = "now";
1861
+ const DATE_REGEX_PARSE = /^(\d{4})[-/](\d+)[-/](\d+)[Tt\s]*(\d+)?:(\d+)?:(\d+)?[.:]?(\d*)$/;
1862
+ const DATE_REGEX_FORMAT = /\[([^\]]+)]|Y{1,4}|M{1,4}|D{1,2}|d{1,4}|H{1,2}|h{1,2}|a|A|m{1,2}|s{1,2}|Z{1,2}|SSS/g;
1863
+ const DEFAULT_TIMEZONE = "Asia/Shanghai";
1864
+ const MAX_NUMBER_VALUE = 1e4;
1865
+ const baselineDateRegexp = new RegExp(`(\\(.+\\)|now)([+-]?\\d*)([${dateUnit}]?)\\/?([${dateUnit}]?)`);
1866
+ const commonDateRegexp = new RegExp(`now([+-]?\\d*)([${dateUnit}]?)\\/?([${dateUnit}]?)`);
1867
+ const recentDateRegexp = new RegExp(`now[-](\\d+)([${dateUnit}]{1})$`);
1868
+ const futureDateRegexp = new RegExp(`now[+](\\d+)([${dateUnit}]{1})$`);
1869
+ const naturalDateRegexp = new RegExp(`now([+-]?\\d*)([${dateUnit}]?)\\/([${dateUnit}])$`);
1870
+ class DateRange {
1871
+ constructor(dateValue = ["", ""], format = "YYYY-MM-DD HH:mm:ss", timezone = dayjs.tz.guess()) {
1872
+ __publicField(this, "endBaselineNum");
1873
+ __publicField(this, "endBaselineTime");
1874
+ __publicField(this, "endBaselineUnit");
1875
+ __publicField(this, "endDate");
1876
+ __publicField(this, "endNum");
1877
+ __publicField(this, "endUnit");
1878
+ __publicField(this, "startBaselineNum");
1879
+ __publicField(this, "startBaselineTime");
1880
+ __publicField(this, "startBaselineUnit");
1881
+ __publicField(this, "startDate");
1882
+ __publicField(this, "startNum");
1883
+ __publicField(this, "startUnit");
1884
+ __publicField(this, "userDisplayName");
1885
+ this.dateValue = dateValue;
1886
+ this.format = format;
1887
+ this.timezone = timezone;
1888
+ const [start, end] = dateValue;
1889
+ this.startDate = start ? this.transformValue2Dayjs(start) : null;
1890
+ this.endDate = end ? this.transformValue2Dayjs(end, "end") : null;
1891
+ }
1892
+ get dateMode() {
1893
+ const [start, end] = this.dateValue;
1894
+ if (typeof start === "number" || typeof end === "number") return DateMode.Date;
1895
+ if (dayjs.isDayjs(start) || dayjs.isDayjs(end)) return DateMode.Date;
1896
+ if (dayjs(start).isValid() || dayjs(end).isValid()) return DateMode.Date;
1897
+ if (start === NowConstant && futureDateRegexp.test(end)) return DateMode.FUTURE;
1898
+ if (end === NowConstant && recentDateRegexp.test(start) || start.includes("(") && end.includes("("))
1899
+ return DateMode.RECENT;
1900
+ if (naturalDateShortcutMap[this.dateValue.join("~")]) {
1901
+ return DateMode.NATURAL;
1902
+ }
1903
+ if (naturalDateRegexp.test(start) && (naturalDateRegexp.test(end) || end === NowConstant)) {
1904
+ const [, startNum, startUnit, startDiffUnit] = start.match(commonDateRegexp) || [];
1905
+ const [, endNum, endUnit, endDiffUnit] = end.match(commonDateRegexp) || [];
1906
+ if (startDiffUnit) {
1907
+ if (end === NowConstant) return DateMode.NATURAL;
1908
+ if (startNum && +endNum == -1) {
1909
+ if (startUnit === startDiffUnit && endUnit === endDiffUnit && startUnit === endUnit) return DateMode.NATURAL;
1910
+ }
1911
+ }
1912
+ }
1913
+ return DateMode.Date;
1914
+ }
1915
+ get endDisplayText() {
1916
+ var _a;
1917
+ return dayjs.tz(((_a = this.endDate) == null ? void 0 : _a.valueOf()) || void 0, this.timezone).format(this.format);
1918
+ }
1919
+ get isValidate() {
1920
+ var _a, _b;
1921
+ return ((_a = this.startDate) == null ? void 0 : _a.isValid()) && ((_b = this.endDate) == null ? void 0 : _b.isValid());
1922
+ }
1923
+ get recentOrFutureDateNum() {
1924
+ if (this.dateMode === DateMode.RECENT) {
1925
+ return this.startNum;
1926
+ }
1927
+ if (this.dateMode === DateMode.FUTURE) {
1928
+ return this.endNum;
1929
+ }
1930
+ return void 0;
1931
+ }
1932
+ get recentOrFutureDateUnit() {
1933
+ if (this.dateMode === DateMode.RECENT) {
1934
+ return this.startUnit;
1935
+ }
1936
+ if (this.dateMode === DateMode.FUTURE) {
1937
+ return this.endUnit;
1938
+ }
1939
+ return "m";
1940
+ }
1941
+ get startDisplayText() {
1942
+ var _a;
1943
+ return dayjs.tz(((_a = this.startDate) == null ? void 0 : _a.valueOf()) || void 0, this.timezone).format(this.format);
1944
+ }
1945
+ dateDuration(unit) {
1946
+ if (!this.startDate || !this.endDate || !this.isValidate) return;
1947
+ let durations = this.endDate.diff(this.startDate);
1948
+ const dayDuration = 24 * 60 * 60 * 1e3;
1949
+ switch (this.dateMode) {
1950
+ case DateMode.RECENT:
1951
+ durations = dayjs().add(this.startNum, this.startUnit).diff(dayjs(), unit);
1952
+ break;
1953
+ case DateMode.FUTURE:
1954
+ durations = dayjs().diff(
1955
+ dayjs().add(this.endNum, this.endUnit),
1956
+ unit || this.endUnit
1957
+ );
1958
+ break;
1959
+ case DateMode.NATURAL: {
1960
+ durations = this.endDate.diff(this.startDate, unit);
1961
+ const dayDuration2 = 24 * 60 * 60 * 1e3;
1962
+ if (durations % dayDuration2 === dayDuration2 - 1) {
1963
+ durations += 1;
1964
+ }
1965
+ break;
1966
+ }
1967
+ default:
1968
+ case DateMode.Date:
1969
+ durations = this.endDate.diff(this.startDate, unit);
1970
+ break;
1971
+ }
1972
+ const durationMod = durations % dayDuration;
1973
+ if (durationMod === dayDuration - 1) {
1974
+ durations += 1;
1975
+ } else if (durationMod === dayDuration - 1e3) {
1976
+ durations += 1e3;
1977
+ }
1978
+ return durations;
1979
+ }
1980
+ isInValidDateRange(date) {
1981
+ if (!this.startDate || !this.endDate) return false;
1982
+ return (this.startDate.isSame(date.startDate, "ms") || this.startDate.isBefore(date.startDate)) && (this.endDate.isSame(date.endDate, "ms") || this.endDate.isAfter(date.endDate));
1983
+ }
1984
+ isInValidDuration(minDuration = 0, maxDuration = Number.MAX_SAFE_INTEGER) {
1985
+ if (!this.startDate || !this.endDate) return false;
1986
+ const durations = this.dateDuration();
1987
+ if (durations === void 0) return false;
1988
+ return durations >= minDuration && durations <= maxDuration;
1989
+ }
1990
+ setUserDisplayName(v) {
1991
+ this.userDisplayName = v;
1992
+ }
1993
+ toDisplayString() {
1994
+ var _a, _b;
1995
+ const {
1996
+ dateMode,
1997
+ endDate,
1998
+ endNum,
1999
+ format,
2000
+ isValidate,
2001
+ startBaselineNum,
2002
+ startBaselineTime,
2003
+ startDate,
2004
+ startNum,
2005
+ startUnit
2006
+ } = this;
2007
+ if (this.userDisplayName) return this.userDisplayName;
2008
+ if (!startDate || !endDate || !isValidate) {
2009
+ return ((_a = this.dateValue) == null ? void 0 : _a.join(" ~ ")) || "";
2010
+ }
2011
+ if (this.dateMode === DateMode.RECENT) {
2012
+ let displayStr = startBaselineTime ? `${t("基于")} ` : "";
2013
+ const item = CommonNaturalOptions.find((option) => option.id === startBaselineTime);
2014
+ if (item == null ? void 0 : item.name) {
2015
+ displayStr += `${t(item.name)} `;
2016
+ } else if (startBaselineNum) {
2017
+ displayStr += `${startBaselineNum} ${t("天前")} `;
2018
+ } else if (startBaselineTime) {
2019
+ displayStr += `${startBaselineTime} `;
2020
+ }
2021
+ return `${displayStr}${t(startBaselineTime ? "的最近" : "近")} ${Math.abs(startNum)} ${t(
2022
+ shortTimeUnitLangData[startUnit]
2023
+ )}`;
2024
+ }
2025
+ if (dateMode === DateMode.FUTURE) {
2026
+ return `${t("未来")} ${Math.abs(endNum)} ${t(
2027
+ shortTimeUnitLangData[this.endUnit]
2028
+ )}`;
2029
+ }
2030
+ const [start, end] = this.dateValue;
2031
+ if (this.dateMode === DateMode.NATURAL) {
2032
+ const suffix = end !== NowConstant ? "" : t("(至今)");
2033
+ const item = CommonNaturalOptions.find((option) => option.id === start);
2034
+ if (item) {
2035
+ return t(item.name) + suffix;
2036
+ }
2037
+ return naturalDateShortcutMap[this.dateValue.join("~")] || `${`${t("前")} ${this.startNum} ${t(
2038
+ shortTimeUnitLangData[this.startUnit]
2039
+ )}`}${suffix}`;
2040
+ }
2041
+ if (start === NowConstant) {
2042
+ return `${t("此刻")} ~ ${(_b = this.endDate) == null ? void 0 : _b.format(format)}`;
2043
+ }
2044
+ if (end === NowConstant) {
2045
+ return `${startDate == null ? void 0 : startDate.format(format)} ~ ${t("此刻")}`;
2046
+ }
2047
+ const dateUnits = [
2048
+ { regex: /Y{2,4}|y{2,4}/, unit: "year" },
2049
+ // { regex: /M{1,2}/, unit: 'month' },
2050
+ { regex: /D{1,2}|d{1,2}/, unit: "day" }
2051
+ // { regex: /H{1,2}|h{1,2}/, unit: 'hour' },
2052
+ // { regex: /m{1,2}/, unit: 'minute' },
2053
+ // { regex: /s{1,2}/, unit: 'second' },
2054
+ ];
2055
+ let remainingFormat = format;
2056
+ let commonFormat = "";
2057
+ let lastEndIndex = 0;
2058
+ for (const { regex, unit } of dateUnits) {
2059
+ if (startDate.isSame(endDate, unit)) {
2060
+ const match = regex.exec(format.slice(lastEndIndex));
2061
+ if (match) {
2062
+ commonFormat += format.slice(lastEndIndex, lastEndIndex + match.index + match[0].length);
2063
+ lastEndIndex += match.index + match[0].length;
2064
+ }
2065
+ } else {
2066
+ break;
2067
+ }
2068
+ }
2069
+ remainingFormat = format.slice(lastEndIndex).trim().replace(/^[:\-\\/]/, "");
2070
+ const commonPrefix = startDate.format(commonFormat.trim());
2071
+ if (!remainingFormat || remainingFormat == format) {
2072
+ return `${startDate.format(format)} ~ ${endDate.format(format)}`;
2073
+ }
2074
+ const formattedStart = startDate.format(remainingFormat);
2075
+ const formattedEnd = endDate.format(remainingFormat);
2076
+ return `${commonPrefix.trim()} (${formattedStart} ~ ${formattedEnd})`;
2077
+ }
2078
+ toEmitValue() {
2079
+ var _a, _b;
2080
+ return [
2081
+ this.dateMode === DateMode.Date ? [
2082
+ this.dateValue[0] === NowConstant ? NowConstant : this.startDate.valueOf(),
2083
+ this.dateValue[1] === NowConstant ? NowConstant : this.endDate.valueOf()
2084
+ ] : [...this.dateValue],
2085
+ [
2086
+ {
2087
+ dayjs: this.startDate,
2088
+ formatText: ((_a = this.startDate) == null ? void 0 : _a.format(this.format)) || null
2089
+ },
2090
+ {
2091
+ dayjs: this.endDate,
2092
+ formatText: ((_b = this.endDate) == null ? void 0 : _b.format(this.format)) || null
2093
+ }
2094
+ ]
2095
+ ];
2096
+ }
2097
+ transformValue2Dayjs(val, type = "start") {
2098
+ const value = isNaN(val) ? val : +val;
2099
+ let date = dayjs(value);
2100
+ if (typeof value === "number" || dayjs.isDayjs(value) || date.isValid())
2101
+ return dayjs.tz(date.valueOf(), this.timezone);
2102
+ const [, baselineTimeStr, num, unit, diffUnit] = value.match(baselineDateRegexp) || [];
2103
+ const baselineTime = baselineTimeStr.replace(/[()]/g, "");
2104
+ let baselineDayjs = dayjs();
2105
+ if (baselineTime && baselineTime !== NowConstant) {
2106
+ baselineDayjs = dayjs(baselineTime);
2107
+ if (baselineDayjs.isValid()) {
2108
+ date = baselineDayjs.add(-1, "ms").endOf("ms");
2109
+ } else {
2110
+ const [, , baseNum, baseUnit, baseDiffUnit] = baselineTime.match(baselineDateRegexp) || [];
2111
+ this[`${type}BaselineNum`] = Math.abs(+baseNum);
2112
+ this[`${type}BaselineUnit`] = baseUnit || baseDiffUnit;
2113
+ baselineDayjs = transformValue2Dayjs(baselineTime, "start") || dayjs();
2114
+ if (baselineTimeStr === value && baselineTimeStr.includes(NowConstant)) {
2115
+ date = baselineDayjs.add(-1, "d").endOf("d");
2116
+ }
2117
+ }
2118
+ this[`${type}BaselineTime`] = baselineTime;
2119
+ }
2120
+ if (type === "start") {
2121
+ this.startNum = Math.abs(+num);
2122
+ this.startUnit = unit || diffUnit;
2123
+ } else if (type === "end") {
2124
+ this.endNum = Math.abs(+num);
2125
+ this.endUnit = unit || diffUnit;
2126
+ }
2127
+ if (num) {
2128
+ date = baselineDayjs.add(+num, unit || diffUnit);
2129
+ } else if (value === NowConstant) {
2130
+ date = baselineDayjs;
2131
+ }
2132
+ if (diffUnit) {
2133
+ date = type === "start" ? dayjs(date.isValid() ? date : baselineDayjs.valueOf()) : dayjs(date.isValid() ? date : baselineDayjs);
2134
+ return type === "start" ? dayjs.tz(date.valueOf(), this.timezone).startOf(diffUnit) : dayjs.tz(date.valueOf(), this.timezone).endOf(diffUnit);
2135
+ }
2136
+ return dayjs.tz(date.valueOf(), this.timezone);
2137
+ }
2138
+ updateDateValue(dateValue, timezone) {
2139
+ this.dateValue = dateValue;
2140
+ const [start, end] = dateValue;
2141
+ if (timezone) this.timezone = timezone;
2142
+ this.startDate = start ? this.transformValue2Dayjs(start) : null;
2143
+ this.endDate = end ? this.transformValue2Dayjs(end, "end") : null;
2144
+ }
2145
+ updateFormat(format) {
2146
+ this.format = format;
2147
+ }
2148
+ }
2149
+ const transformValue2Dayjs = (val, type = "start", timezone) => {
2150
+ const value = isNaN(val) ? val : +val;
2151
+ let date = dayjs(value);
2152
+ if (typeof value === "number" || dayjs.isDayjs(value) || date.isValid())
2153
+ return dayjs.tz(date.valueOf(), timezone || dayjs.tz.guess());
2154
+ const [, baselineTimeStr, num, unit, diffUnit] = value.match(baselineDateRegexp) || [];
2155
+ const baselineTime = baselineTimeStr.replace(/[()]/g, "");
2156
+ let baselineDayjs = dayjs();
2157
+ if (baselineTime && baselineTime !== NowConstant) {
2158
+ baselineDayjs = transformValue2Dayjs(baselineTime, "start") || dayjs();
2159
+ if (baselineTimeStr === value) {
2160
+ date = baselineDayjs;
2161
+ }
2162
+ }
2163
+ if (num) {
2164
+ date = dayjs().add(+num, unit || diffUnit || "d");
2165
+ } else if (value === NowConstant) {
2166
+ date = dayjs();
2167
+ }
2168
+ if (diffUnit) {
2169
+ date = type === "start" ? dayjs.tz(dayjs(date.isValid() ? date : void 0).valueOf(), timezone).startOf(diffUnit) : dayjs.tz(dayjs(date.isValid() ? date : void 0), timezone).endOf(diffUnit);
2170
+ return (date == null ? void 0 : date.isValid()) ? date : void 0;
2171
+ }
2172
+ return date.isValid() ? dayjs.tz(date.valueOf(), timezone || dayjs.tz.guess()) : void 0;
2173
+ };
2174
+ const transformDateRange2Dayjs = (dateValue, timezone) => {
2175
+ if (!Array.isArray(dateValue) || dateValue.length < 1) return [];
2176
+ const [start, end] = dateValue || [];
2177
+ const startDate = transformValue2Dayjs(start, "start", timezone);
2178
+ const endDate = transformValue2Dayjs(end, "end", timezone);
2179
+ return [startDate, endDate];
2180
+ };
2181
+ const inputVal2Dayjs = (val, format, defaultDate) => {
2182
+ let date;
2183
+ if (commonDateRegexp.test(val)) {
2184
+ date = transformValue2Dayjs(val);
2185
+ }
2186
+ if (!date && !/Z$/i.test(val) && "YYYY-MM-DD HH:mm:ss".includes(format)) {
2187
+ const d = val.match(DATE_REGEX_PARSE) || [];
2188
+ if (d.length) {
2189
+ let validate = true;
2190
+ const ms = (d[7] || "0").substring(0, 3);
2191
+ const s = d[6] || 0;
2192
+ validate = +s < 60;
2193
+ const m = d[5] || 0;
2194
+ validate = validate && +m < 60;
2195
+ const h2 = d[4] || 0;
2196
+ validate = validate && +h2 < 24;
2197
+ const day = d[3] || 1;
2198
+ validate = validate && +day < 32;
2199
+ const M = +d[2] - 1 || 0;
2200
+ validate = validate && M < 12;
2201
+ const y = d[1];
2202
+ validate = validate && y.length < 5;
2203
+ date = validate ? dayjs(new Date(+y, M, +day, +h2, +m, +s, +ms)) : defaultDate;
2204
+ }
2205
+ }
2206
+ if (!date) {
2207
+ date = dayjs(val);
2208
+ }
2209
+ return date;
2210
+ };
2211
+ function getTimezoneOffset(timezone) {
2212
+ const localTime = dayjs().tz(timezone);
2213
+ const offset = localTime.utcOffset() / 60;
2214
+ return offset;
2215
+ }
2216
+ const isValidTimeZone = (timeZone) => {
2217
+ try {
2218
+ new Intl.DateTimeFormat("en-US", { timeZone });
2219
+ return true;
2220
+ } catch (e) {
2221
+ return false;
2222
+ }
2223
+ };
2224
+ const timeUnits = {
2225
+ 天: 24 * 60 * 60 * 1e3,
2226
+ 小时: 60 * 60 * 1e3,
2227
+ 分钟: 60 * 1e3,
2228
+ 秒: 1e3
2229
+ };
2230
+ const formatDuration = (milliseconds) => {
2231
+ let remainingTime = milliseconds;
2232
+ let result = "";
2233
+ for (const [unit, value] of Object.entries(timeUnits)) {
2234
+ const amount = Math.floor(remainingTime / value);
2235
+ if (amount > 0) {
2236
+ result += `${amount} ${t(unit)} `;
2237
+ remainingTime %= value;
2238
+ }
2239
+ }
2240
+ return result.trim();
2241
+ };
2242
+ const DATE_PICKER_PROVIDER_KEY = Symbol("DATE_PICKER_PROVIDER_KEY");
2243
+ const useDatePickerProvider = (data) => {
2244
+ provide(DATE_PICKER_PROVIDER_KEY, data);
2245
+ };
2246
+ const useDatePickerInject = () => inject(DATE_PICKER_PROVIDER_KEY);
2247
+ const getStoreDateList = (storeKey2, type = "local") => {
2248
+ const store = type === "local" ? localStorage : sessionStorage;
2249
+ const storeListStr = store.getItem(storeKey2);
2250
+ let list = [];
2251
+ if (storeListStr) {
2252
+ try {
2253
+ list = JSON.parse(storeListStr);
2254
+ } catch {
2255
+ list = [];
2256
+ }
2257
+ }
2258
+ if (!Array.isArray(list)) {
2259
+ list = [];
2260
+ }
2261
+ return list;
2262
+ };
2263
+ const setStoreDateList = (val, storeKey2, type = "local") => {
2264
+ let list = [];
2265
+ const store = type === "local" ? localStorage : sessionStorage;
2266
+ const storeListStr = store.getItem(storeKey2);
2267
+ if (storeListStr) {
2268
+ try {
2269
+ list = JSON.parse(storeListStr);
2270
+ } catch {
2271
+ list = [];
2272
+ }
2273
+ }
2274
+ if (!Array.isArray(list)) {
2275
+ list = [];
2276
+ }
2277
+ if (list.some((item) => item[0] === val[0] && item[1] === val[1])) return;
2278
+ list.unshift(val);
2279
+ store.setItem(storeKey2, JSON.stringify(list.slice(0, 10)));
2280
+ };
2281
+ const _hoisted_1$9 = { class: "common-panel-tab" };
2282
+ const _sfc_main$a = /* @__PURE__ */ defineComponent({
2283
+ __name: "common-tab",
2284
+ props: {
2285
+ /** modelValue 选中的tab */
2286
+ modelValue: {
2287
+ required: true,
2288
+ type: String
2289
+ },
2290
+ /** panels */
2291
+ panels: {
2292
+ required: true,
2293
+ type: Array
2294
+ }
2295
+ },
2296
+ emits: ["confirm", "update:modelValue"],
2297
+ setup(__props) {
2298
+ return (_ctx, _cache) => {
2299
+ return openBlock(), createElementBlock("div", _hoisted_1$9, [
2300
+ createVNode(unref(Tab), {
2301
+ active: __props.modelValue,
2302
+ type: "unborder-card",
2303
+ "onUpdate:active": _cache[0] || (_cache[0] = ($event) => _ctx.$emit("update:modelValue", $event))
2304
+ }, {
2305
+ default: withCtx(() => [
2306
+ (openBlock(true), createElementBlock(
2307
+ Fragment,
2308
+ null,
2309
+ renderList(__props.panels, (item) => {
2310
+ return openBlock(), createBlock(unref(Tab).TabPanel, {
2311
+ key: item.id,
2312
+ label: item.name,
2313
+ name: item.id
2314
+ }, null, 8, ["label", "name"]);
2315
+ }),
2316
+ 128
2317
+ /* KEYED_FRAGMENT */
2318
+ ))
2319
+ ]),
2320
+ _: 1
2321
+ /* STABLE */
2322
+ }, 8, ["active"])
2323
+ ]);
2324
+ };
2325
+ }
2326
+ });
2327
+ const useValidate = () => {
2328
+ var _a;
2329
+ const { format, timezoneInfo, validateTimeRange, minDuration, maxDuration } = useDatePickerInject();
2330
+ const validMsg = ref("");
2331
+ const validDateRange = customRef((track) => {
2332
+ const date = new DateRange(validateTimeRange.value, format.value, timezoneInfo.value.label);
2333
+ return {
2334
+ get() {
2335
+ var _a2;
2336
+ track();
2337
+ if (((_a2 = validateTimeRange.value) == null ? void 0 : _a2.length) !== 2) return void 0;
2338
+ if (validateTimeRange.value.some((v) => typeof v === "string" && v.includes("now")))
2339
+ return new DateRange(validateTimeRange.value, format.value, timezoneInfo.value.label);
2340
+ return date;
2341
+ },
2342
+ set() {
2343
+ }
2344
+ };
2345
+ });
2346
+ const rangeMsg = t("超出可选范围") + " (" + ((_a = validDateRange.value) == null ? void 0 : _a.toDisplayString()) + ") " + t(",无法选择");
2347
+ const validDuration = (validDate) => {
2348
+ let date;
2349
+ if (validDate instanceof DateRange) {
2350
+ date = validDate;
2351
+ } else {
2352
+ date = new DateRange(validDate, format.value, timezoneInfo.value.label);
2353
+ }
2354
+ const durations = Math.abs(date.dateDuration("ms") || 0);
2355
+ let message = "";
2356
+ if (minDuration.value && durations < minDuration.value) {
2357
+ message = t("时间范围不能小于") + " " + formatDuration(minDuration.value);
2358
+ }
2359
+ if (!message && maxDuration.value && durations > maxDuration.value) {
2360
+ message = t("时间范围不能大于") + " " + formatDuration(maxDuration.value);
2361
+ }
2362
+ return message;
2363
+ };
2364
+ const commonValidateFn = (date) => {
2365
+ var _a2;
2366
+ const isValid = ((_a2 = validDateRange.value) == null ? void 0 : _a2.isInValidDateRange(date)) ?? true;
2367
+ if (!isValid) {
2368
+ validMsg.value = rangeMsg;
2369
+ return isValid;
2370
+ }
2371
+ const message = validDuration(date);
2372
+ validMsg.value = message;
2373
+ return !message;
2374
+ };
2375
+ const validateDateValue = (validDate) => {
2376
+ if (!(validDate == null ? void 0 : validDate.length)) return false;
2377
+ const date = new DateRange(validDate, format.value, timezoneInfo.value.label);
2378
+ return commonValidateFn(date);
2379
+ };
2380
+ const validateDateRange = (validDate) => {
2381
+ if (!validDate.isValidate) return false;
2382
+ return commonValidateFn(validDate);
2383
+ };
2384
+ const validateDayjs = (validDate) => {
2385
+ var _a2;
2386
+ validMsg.value = "";
2387
+ if (!validDate.isValid()) return false;
2388
+ const date = new DateRange([validDate.startOf("d"), validDate.endOf("d")], format.value, timezoneInfo.value.label);
2389
+ const isValid = ((_a2 = validDateRange.value) == null ? void 0 : _a2.isInValidDateRange(date)) ?? true;
2390
+ if (!isValid) {
2391
+ validMsg.value = rangeMsg;
2392
+ }
2393
+ return isValid;
2394
+ };
2395
+ return {
2396
+ validDateRange,
2397
+ validMsg,
2398
+ validateDateRange,
2399
+ validateDateValue,
2400
+ validateDayjs
2401
+ };
2402
+ };
2403
+ const _hoisted_1$8 = {
2404
+ key: 0,
2405
+ class: "common-date-list"
2406
+ };
2407
+ const _hoisted_2$6 = ["onClick", "onMouseenter"];
2408
+ const _hoisted_3$5 = {
2409
+ key: 1,
2410
+ class: "common-wrapper"
2411
+ };
2412
+ const _hoisted_4$4 = { class: "empty-tips" };
2413
+ const _sfc_main$9 = /* @__PURE__ */ defineComponent({
2414
+ __name: "date-list",
2415
+ props: {
2416
+ dateList: {},
2417
+ defaultDate: {},
2418
+ isRecent: { type: Boolean }
2419
+ },
2420
+ emits: ["change"],
2421
+ setup(__props, { emit: __emit }) {
2422
+ const emits = __emit;
2423
+ let popoverInstance = null;
2424
+ const { validMsg, validateDateRange } = useValidate();
2425
+ const isSameDateRange = (date1, date2) => {
2426
+ var _a, _b, _c, _d, _e, _f;
2427
+ if (!date1 || !date2) return false;
2428
+ if (((_b = (_a = date1.dateValue) == null ? void 0 : _a.join) == null ? void 0 : _b.call(_a, "~")) === ((_d = (_c = date2 == null ? void 0 : date2.dateValue) == null ? void 0 : _c.join) == null ? void 0 : _d.call(_c, "~"))) return true;
2429
+ if (((_e = date1 == null ? void 0 : date1.toDisplayString) == null ? void 0 : _e.call(date1)) === ((_f = date2 == null ? void 0 : date2.toDisplayString) == null ? void 0 : _f.call(date2))) return true;
2430
+ return false;
2431
+ };
2432
+ const handleChange = (date) => {
2433
+ emits("change", date);
2434
+ };
2435
+ const handleShowDisableMsg = (e, date) => {
2436
+ if (validateDateRange(date)) return;
2437
+ popoverInstance = $bkPopover({
2438
+ content: validMsg.value,
2439
+ immediate: false,
2440
+ isShow: true,
2441
+ popoverDelay: 0,
2442
+ target: e.target,
2443
+ trigger: "manual"
2444
+ });
2445
+ popoverInstance == null ? void 0 : popoverInstance.show(e.target);
2446
+ };
2447
+ const handleHideDisableMsg = () => {
2448
+ popoverInstance == null ? void 0 : popoverInstance.hide();
2449
+ };
2450
+ return (_ctx, _cache) => {
2451
+ return _ctx.dateList.length ? (openBlock(), createElementBlock("ul", _hoisted_1$8, [
2452
+ (openBlock(true), createElementBlock(
2453
+ Fragment,
2454
+ null,
2455
+ renderList(_ctx.dateList, (date, index) => {
2456
+ return openBlock(), createElementBlock("li", {
2457
+ key: index,
2458
+ class: normalizeClass({
2459
+ "list-item": true,
2460
+ "is-recent-item": _ctx.isRecent,
2461
+ "is-selected": isSameDateRange(date, _ctx.defaultDate),
2462
+ "is-disabled": !unref(validateDateRange)(date)
2463
+ }),
2464
+ onClick: ($event) => unref(validateDateRange)(date) && handleChange(date.dateValue),
2465
+ onMouseenter: (e) => handleShowDisableMsg(e, date),
2466
+ onMouseleave: handleHideDisableMsg
2467
+ }, toDisplayString(date.toDisplayString()), 43, _hoisted_2$6);
2468
+ }),
2469
+ 128
2470
+ /* KEYED_FRAGMENT */
2471
+ ))
2472
+ ])) : (openBlock(), createElementBlock("div", _hoisted_3$5, [
2473
+ createVNode(unref(Exception), {
2474
+ class: "empty-content",
2475
+ scene: "part",
2476
+ type: "empty"
2477
+ }),
2478
+ createElementVNode(
2479
+ "div",
2480
+ _hoisted_4$4,
2481
+ toDisplayString(_ctx.isRecent ? unref(t)("暂无最近使用记录") : unref(t)("暂无常用时间")),
2482
+ 1
2483
+ /* TEXT */
2484
+ )
2485
+ ]));
2486
+ };
2487
+ }
2488
+ });
2489
+ const _export_sfc = (sfc, props) => {
2490
+ const target = sfc.__vccOpts || sfc;
2491
+ for (const [key, val] of props) {
2492
+ target[key] = val;
2493
+ }
2494
+ return target;
2495
+ };
2496
+ const DateList = /* @__PURE__ */ _export_sfc(_sfc_main$9, [["__scopeId", "data-v-ed496942"]]);
2497
+ const _sfc_main$8 = /* @__PURE__ */ defineComponent({
2498
+ __name: "common-submit",
2499
+ props: {
2500
+ disabled: { type: Boolean },
2501
+ disableTips: {}
2502
+ },
2503
+ emits: ["submit"],
2504
+ setup(__props) {
2505
+ return (_ctx, _cache) => {
2506
+ var _a;
2507
+ return openBlock(), createElementBlock(
2508
+ Fragment,
2509
+ null,
2510
+ [
2511
+ createVNode(unref(Popover), {
2512
+ content: _ctx.disableTips,
2513
+ disabled: !_ctx.disabled || !((_a = _ctx.disableTips) == null ? void 0 : _a.length)
2514
+ }, {
2515
+ default: withCtx(() => [
2516
+ createVNode(unref(Button), {
1922
2517
  class: "common-submit",
1923
- theme: "primary"
2518
+ disabled: _ctx.disabled,
2519
+ outline: true,
2520
+ theme: "primary",
2521
+ onClick: _cache[0] || (_cache[0] = ($event) => _ctx.$emit("submit"))
1924
2522
  }, {
1925
- default: j(() => [
1926
- G(
1927
- k(t(r)("确定")),
2523
+ default: withCtx(() => [
2524
+ createTextVNode(
2525
+ toDisplayString(unref(t)("确定")),
1928
2526
  1
1929
2527
  /* TEXT */
1930
2528
  )
@@ -1936,480 +2534,650 @@ const _a = (l, a = "start", i) => {
1936
2534
  _: 1
1937
2535
  /* STABLE */
1938
2536
  }, 8, ["content", "disabled"]),
1939
- sa("v-if", !0)
2537
+ createCommentVNode("v-if", true)
1940
2538
  ],
1941
2539
  64
1942
2540
  /* STABLE_FRAGMENT */
1943
2541
  );
1944
2542
  };
1945
2543
  }
1946
- }), Ke = { class: "date-panel" }, Oe = { class: "date-panel-title" }, qe = { class: "date-panel-main" }, Fe = { class: "date-header" }, Ge = { class: "date-header-left" }, Je = { class: "date-header-center" }, Ze = /* @__PURE__ */ v(
1947
- "span",
1948
- { class: "date-split" },
1949
- null,
1950
- -1
1951
- /* HOISTED */
1952
- ), We = { class: "date-header-right" }, Qe = { class: "date-content" }, Xe = { class: "date-grid" }, at = ["onClick"], Ha = 6, va = 7, Ka = /* @__PURE__ */ X({
1953
- __name: "date-panel",
1954
- props: {
1955
- diableNow: { type: Boolean },
1956
- format: { default: "YYYY-MM-DD HH:mm:ss" },
1957
- isNow: { type: Boolean },
1958
- minDate: {},
1959
- modelValue: {},
1960
- title: {}
1961
- },
1962
- emits: ["update:isNow", "update:modelValue"],
1963
- setup(l, { emit: a }) {
1964
- const i = l, e = a, n = pa === "en" ? ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"] : ["日", "一", "二", "三", "四", "五", "六"], b = Q([]), h = d(), m = Q(i.modelValue || h);
1965
- ma(
1966
- m,
1967
- () => {
1968
- const D = m.value.startOf("month").startOf("week").add(-1, "day"), N = [];
1969
- for (let Y = 0; Y < Ha * va; Y++)
1970
- N.push(D.add(Y, "day"));
1971
- b.value = N;
1972
- },
1973
- {
1974
- immediate: !0
1975
- }
1976
- );
1977
- const c = (D) => {
1978
- m.value = m.value.add(D, "month");
1979
- }, s = (D) => {
1980
- m.value = m.value.add(D, "year");
1981
- }, o = (D) => {
1982
- i.minDate && D.isBefore(i.minDate, "day") || e("update:modelValue", D);
1983
- };
1984
- let y;
1985
- const S = (D) => {
1986
- D.preventDefault(), !i.diableNow && (y || (e("update:isNow", !i.isNow), y = setTimeout(() => {
1987
- clearTimeout(y), y = null;
1988
- }, 500)));
1989
- };
1990
- return (D, N) => (p(), z("div", Ke, [
1991
- v("div", Oe, [
1992
- G(
1993
- k(D.title) + " ",
1994
- 1
1995
- /* TEXT */
1996
- ),
1997
- v(
1998
- "span",
1999
- {
2000
- onMousedown: S,
2001
- class: "title-check"
2002
- },
2003
- [
2004
- E(t(pe), {
2005
- disabled: D.diableNow,
2006
- "model-value": D.isNow,
2007
- size: "small"
2008
- }, {
2009
- default: j(() => [
2010
- G(" now ")
2011
- ]),
2012
- _: 1
2013
- /* STABLE */
2014
- }, 8, ["disabled", "model-value"])
2015
- ],
2016
- 32
2017
- /* NEED_HYDRATION */
2018
- )
2019
- ]),
2020
- v("div", qe, [
2021
- v("div", Fe, [
2022
- v("div", Ge, [
2023
- E(t(Ie), {
2024
- onClick: N[0] || (N[0] = (Y) => s(-1)),
2025
- class: "hand-icon"
2026
- }),
2027
- E(t(Wa), {
2028
- onClick: N[1] || (N[1] = (Y) => c(-1)),
2029
- class: "hand-icon"
2030
- })
2031
- ]),
2032
- v("div", Je, [
2033
- G(
2034
- k(m.value.year()),
2035
- 1
2036
- /* TEXT */
2037
- ),
2038
- Ze,
2039
- G(
2040
- k(m.value.month() + 1),
2041
- 1
2042
- /* TEXT */
2043
- )
2044
- ]),
2045
- v("div", We, [
2046
- E(t(Qa), {
2047
- onClick: N[2] || (N[2] = (Y) => c(1)),
2048
- class: "hand-icon"
2049
- }),
2050
- E(t(ke), {
2051
- onClick: N[3] || (N[3] = (Y) => s(1)),
2052
- class: "hand-icon"
2053
- })
2054
- ])
2055
- ]),
2056
- v("div", Qe, [
2057
- v("ul", Xe, [
2058
- (p(!0), z(
2059
- U,
2060
- null,
2061
- q(t(n), (Y, $) => (p(), z(
2062
- "li",
2063
- {
2064
- key: $,
2065
- class: "date-grid-item not-click"
2066
- },
2067
- k(Y),
2544
+ });
2545
+ const _hoisted_1$7 = { class: "date-panel" };
2546
+ const _hoisted_2$5 = {
2547
+ key: 0,
2548
+ class: "date-panel-title"
2549
+ };
2550
+ const _hoisted_3$4 = { class: "date-panel-main" };
2551
+ const _hoisted_4$3 = { class: "date-header" };
2552
+ const _hoisted_5$2 = { class: "date-header-left" };
2553
+ const _hoisted_6$2 = { class: "date-header-center" };
2554
+ const _hoisted_7$2 = { class: "date-header-right" };
2555
+ const _hoisted_8$1 = { class: "date-content" };
2556
+ const _hoisted_9 = { class: "date-grid" };
2557
+ const _hoisted_10 = ["onClick"];
2558
+ const panelRowCount = 6;
2559
+ const weekItemCount = 7;
2560
+ const _sfc_main$7 = /* @__PURE__ */ defineComponent({
2561
+ __name: "date-panel",
2562
+ props: {
2563
+ disableNow: { type: Boolean },
2564
+ format: { default: "YYYY-MM-DD HH:mm:ss" },
2565
+ isNow: { type: Boolean },
2566
+ minDate: {},
2567
+ modelValue: {},
2568
+ showTitle: { type: Boolean, default: true },
2569
+ title: {}
2570
+ },
2571
+ emits: ["update:isNow", "update:modelValue"],
2572
+ setup(__props, { emit: __emit }) {
2573
+ const props = __props;
2574
+ const emits = __emit;
2575
+ const weekList = lang === "en" ? ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"] : ["日", "一", "二", "三", "四", "五", "六"];
2576
+ const panelDateList = shallowRef([]);
2577
+ const today = dayjs();
2578
+ const curPanelDate = shallowRef(props.modelValue || today);
2579
+ const { validateDayjs } = useValidate();
2580
+ watch(
2581
+ curPanelDate,
2582
+ () => {
2583
+ const firstDay = curPanelDate.value.startOf("month").startOf("week").add(-1, "day");
2584
+ const list = [];
2585
+ for (let i = 0; i < panelRowCount * weekItemCount; i++) {
2586
+ list.push(firstDay.add(i, "day"));
2587
+ }
2588
+ panelDateList.value = list;
2589
+ },
2590
+ {
2591
+ immediate: true
2592
+ }
2593
+ );
2594
+ const nextMonth = (number) => {
2595
+ curPanelDate.value = curPanelDate.value.add(number, "month");
2596
+ };
2597
+ const nextYear = (number) => {
2598
+ curPanelDate.value = curPanelDate.value.add(number, "year");
2599
+ };
2600
+ const handleDateChange = (date) => {
2601
+ if (!validateDayjs(date) || props.minDate && date.isBefore(props.minDate, "day")) {
2602
+ return;
2603
+ }
2604
+ emits("update:modelValue", date);
2605
+ };
2606
+ let timeout;
2607
+ const handleMouseDown = (e) => {
2608
+ e.preventDefault();
2609
+ if (props.disableNow) return;
2610
+ if (timeout) return;
2611
+ emits("update:isNow", !props.isNow);
2612
+ timeout = setTimeout(() => {
2613
+ clearTimeout(timeout);
2614
+ timeout = null;
2615
+ }, 500);
2616
+ };
2617
+ return (_ctx, _cache) => {
2618
+ return openBlock(), createElementBlock("div", _hoisted_1$7, [
2619
+ _ctx.showTitle ? (openBlock(), createElementBlock("div", _hoisted_2$5, [
2620
+ createTextVNode(
2621
+ toDisplayString(_ctx.title) + " ",
2622
+ 1
2623
+ /* TEXT */
2624
+ ),
2625
+ createElementVNode(
2626
+ "span",
2627
+ {
2628
+ class: "title-check",
2629
+ onMousedown: handleMouseDown
2630
+ },
2631
+ [
2632
+ createVNode(unref(Checkbox), {
2633
+ disabled: _ctx.disableNow,
2634
+ "model-value": _ctx.isNow,
2635
+ size: "small"
2636
+ }, {
2637
+ default: withCtx(() => _cache[4] || (_cache[4] = [
2638
+ createTextVNode(" now ")
2639
+ ])),
2640
+ _: 1
2641
+ /* STABLE */
2642
+ }, 8, ["disabled", "model-value"])
2643
+ ],
2644
+ 32
2645
+ /* NEED_HYDRATION */
2646
+ )
2647
+ ])) : createCommentVNode("v-if", true),
2648
+ createElementVNode("div", _hoisted_3$4, [
2649
+ createElementVNode("div", _hoisted_4$3, [
2650
+ createElementVNode("div", _hoisted_5$2, [
2651
+ createVNode(unref(AngleDoubleLeft), {
2652
+ class: "hand-icon",
2653
+ onClick: _cache[0] || (_cache[0] = ($event) => nextYear(-1))
2654
+ }),
2655
+ createVNode(unref(AngleLeft), {
2656
+ class: "hand-icon",
2657
+ onClick: _cache[1] || (_cache[1] = ($event) => nextMonth(-1))
2658
+ })
2659
+ ]),
2660
+ createElementVNode("div", _hoisted_6$2, [
2661
+ createTextVNode(
2662
+ toDisplayString(curPanelDate.value.year()),
2068
2663
  1
2069
2664
  /* TEXT */
2070
- ))),
2071
- 128
2072
- /* KEYED_FRAGMENT */
2073
- ))
2665
+ ),
2666
+ _cache[5] || (_cache[5] = createElementVNode(
2667
+ "span",
2668
+ { class: "date-split" },
2669
+ null,
2670
+ -1
2671
+ /* HOISTED */
2672
+ )),
2673
+ createTextVNode(
2674
+ toDisplayString(curPanelDate.value.month() + 1),
2675
+ 1
2676
+ /* TEXT */
2677
+ )
2678
+ ]),
2679
+ createElementVNode("div", _hoisted_7$2, [
2680
+ createVNode(unref(AngleRight), {
2681
+ class: "hand-icon",
2682
+ onClick: _cache[2] || (_cache[2] = ($event) => nextMonth(1))
2683
+ }),
2684
+ createVNode(unref(AngleDoubleRight), {
2685
+ class: "hand-icon",
2686
+ onClick: _cache[3] || (_cache[3] = ($event) => nextYear(1))
2687
+ })
2688
+ ])
2074
2689
  ]),
2075
- (p(), z(
2076
- U,
2077
- null,
2078
- q(Ha, (Y) => v("ul", {
2079
- key: Y,
2080
- class: "date-grid"
2081
- }, [
2082
- (p(!0), z(
2083
- U,
2690
+ createElementVNode("div", _hoisted_8$1, [
2691
+ createElementVNode("ul", _hoisted_9, [
2692
+ (openBlock(true), createElementBlock(
2693
+ Fragment,
2084
2694
  null,
2085
- q(b.value.slice((Y - 1) * va, (Y - 1) * va + va), ($) => (p(), z("li", {
2086
- class: da([{
2087
- "is-last-month": $.isBefore(m.value, "month"),
2088
- "is-next-month": $.isAfter(m.value, "month"),
2089
- "is-today": $.isSame(t(h), "day"),
2090
- "is-disabled": D.minDate && $.isBefore(D.minDate, "day"),
2091
- "is-selected": i.modelValue && $.isSame(i.modelValue, "day")
2092
- }, "date-grid-item"]),
2093
- key: $.unix(),
2094
- onClick: Ga((H) => o($), ["prevent"])
2095
- }, k($.date()), 11, at))),
2695
+ renderList(unref(weekList), (day, index) => {
2696
+ return openBlock(), createElementBlock(
2697
+ "li",
2698
+ {
2699
+ key: index,
2700
+ class: "date-grid-item not-click"
2701
+ },
2702
+ toDisplayString(day),
2703
+ 1
2704
+ /* TEXT */
2705
+ );
2706
+ }),
2096
2707
  128
2097
2708
  /* KEYED_FRAGMENT */
2098
2709
  ))
2099
- ])),
2100
- 64
2101
- /* STABLE_FRAGMENT */
2102
- ))
2710
+ ]),
2711
+ (openBlock(), createElementBlock(
2712
+ Fragment,
2713
+ null,
2714
+ renderList(panelRowCount, (row) => {
2715
+ return createElementVNode("ul", {
2716
+ key: row,
2717
+ class: "date-grid"
2718
+ }, [
2719
+ (openBlock(true), createElementBlock(
2720
+ Fragment,
2721
+ null,
2722
+ renderList(panelDateList.value.slice((row - 1) * weekItemCount, (row - 1) * weekItemCount + weekItemCount), (date) => {
2723
+ return openBlock(), createElementBlock("li", {
2724
+ key: date.unix(),
2725
+ class: normalizeClass(["date-grid-item", {
2726
+ "is-last-month": date.isBefore(curPanelDate.value, "month"),
2727
+ "is-next-month": date.isAfter(curPanelDate.value, "month"),
2728
+ "is-today": date.isSame(unref(today), "day"),
2729
+ "is-disabled": !unref(validateDayjs)(date) || _ctx.minDate && date.isBefore(_ctx.minDate, "day"),
2730
+ "is-selected": props.modelValue && date.isSame(props.modelValue, "day")
2731
+ }]),
2732
+ onClick: withModifiers(($event) => handleDateChange(date), ["prevent"])
2733
+ }, toDisplayString(date.date()), 11, _hoisted_10);
2734
+ }),
2735
+ 128
2736
+ /* KEYED_FRAGMENT */
2737
+ ))
2738
+ ]);
2739
+ }),
2740
+ 64
2741
+ /* STABLE_FRAGMENT */
2742
+ ))
2743
+ ])
2103
2744
  ])
2104
- ])
2105
- ]));
2745
+ ]);
2746
+ };
2106
2747
  }
2107
- }), et = { class: "date-wrapper" }, tt = { class: "date-input" }, it = /* @__PURE__ */ v(
2108
- "span",
2109
- { class: "date-picker-icon" },
2110
- [
2111
- /* @__PURE__ */ v("svg", {
2112
- class: "date-content-icon",
2113
- height: "14",
2114
- version: "1.1",
2115
- viewBox: "0 0 1024 1024",
2116
- width: "14",
2117
- xmlns: "http://www.w3.org/2000/svg",
2118
- "xmlns:xlink": "http://www.w3.org/1999/xlink"
2119
- }, [
2120
- /* @__PURE__ */ v("path", {
2121
- d: "M558.933 465.067h-93.866v93.866h93.866v-93.866z m0 162.133h-93.866v93.867h93.866V627.2z m371.2-533.333h-93.866V21.333c0-12.8-8.534-21.333-21.334-21.333S793.6 8.533 793.6 21.333V89.6H234.667V21.333c0-12.8-12.8-21.333-25.6-21.333s-21.334 8.533-21.334 21.333V89.6H93.867C42.667 93.867 0 136.533 0 187.733V934.4c0 46.933 42.667 89.6 93.867 89.6h836.266c51.2 0 93.867-42.667 93.867-93.867v-742.4c0-51.2-42.667-93.866-93.867-93.866z m46.934 836.266c0 25.6-21.334 46.934-46.934 46.934H93.867c-25.6 0-46.934-21.334-46.934-46.934V371.2h930.134v558.933z m0-605.866H46.933V187.733c0-25.6 21.334-46.933 46.934-46.933h93.866v68.267c0 12.8 8.534 21.333 21.334 21.333s21.333-8.533 21.333-21.333V140.8h558.933v68.267c0 12.8 8.534 21.333 21.334 21.333S832 221.867 832 209.067V140.8h93.867c25.6 0 46.933 21.333 46.933 46.933v136.534h4.267zM789.333 627.2h-93.866v93.867h93.866V627.2z m0-162.133h-93.866v93.866h93.866v-93.866z m-230.4 324.266h-93.866V883.2h93.866v-93.867z m-234.666 0h-89.6V883.2h93.866v-93.867h-4.266z m0-324.266h-89.6v93.866h93.866v-93.866h-4.266z m0 162.133h-89.6v93.867h93.866V627.2h-4.266z",
2122
- fill: "#C4C6CC",
2123
- xmlns: "http://www.w3.org/2000/svg"
2124
- })
2125
- ])
2126
- ],
2127
- -1
2128
- /* HOISTED */
2129
- ), nt = ["placeholder", "value"], rt = /* @__PURE__ */ v(
2130
- "span",
2131
- { class: "date-picker-split" },
2132
- "~",
2133
- -1
2134
- /* HOISTED */
2135
- ), lt = ["placeholder", "value"], st = { class: "show-format" }, ct = { class: "date-format-wrapper" }, ut = { class: "content-title" }, ot = { class: "content-table" }, dt = /* @__PURE__ */ X({
2748
+ });
2749
+ const _hoisted_1$6 = { class: "date-wrapper" };
2750
+ const _hoisted_2$4 = { class: "date-input" };
2751
+ const _hoisted_3$3 = ["placeholder", "value"];
2752
+ const _hoisted_4$2 = ["placeholder", "value"];
2753
+ const _hoisted_5$1 = {
2754
+ key: 0,
2755
+ style: { "margin": "-8px 0 8px", "color": "#ea3636" }
2756
+ };
2757
+ const _hoisted_6$1 = { class: "show-format" };
2758
+ const _hoisted_7$1 = { class: "content-table" };
2759
+ const _hoisted_8 = ["onClick"];
2760
+ const DefaultCommitFormat = "YYYY-MM-DD HH:mm:ss";
2761
+ const _sfc_main$6 = /* @__PURE__ */ defineComponent({
2136
2762
  __name: "date-picker",
2137
2763
  props: {
2138
2764
  value: {}
2139
2765
  },
2140
2766
  emits: ["change"],
2141
- setup(l, { emit: a }) {
2142
- d.extend(Oa);
2143
- const i = l, e = a, n = L(null), b = L(null), h = L(!1), m = L(!1), c = Q(), s = Q(), o = L(!1), y = L(!1), { format: S, timezoneInfo: D } = ee(), N = d();
2144
- ma(
2145
- () => i.value,
2146
- (f) => {
2147
- const { dateValue: u, endDate: M, startDate: w } = f;
2148
- c.value = w, s.value = M, o.value = u[0] === C, y.value = u[1] === C;
2767
+ setup(__props, { expose: __expose, emit: __emit }) {
2768
+ dayjs.extend(customParseFormat);
2769
+ const props = __props;
2770
+ const emits = __emit;
2771
+ const startInput = ref(null);
2772
+ const endInput = ref(null);
2773
+ const showStartPanel = ref(false);
2774
+ const showEndPanel = ref(false);
2775
+ const startDate = shallowRef();
2776
+ const endDate = shallowRef();
2777
+ const isStartNow = ref(false);
2778
+ const isEndNow = ref(false);
2779
+ const { format, timezoneInfo, formatChange, enableFormatClick } = useDatePickerInject();
2780
+ const today = dayjs();
2781
+ const isValidate = ref(true);
2782
+ const { validMsg, validateDateValue } = useValidate();
2783
+ const curTimezoneInfo = ref(timezoneInfo.value || dayjs.tz.guess());
2784
+ const canConfirm = computed(() => {
2785
+ if (!startDate.value || !endDate.value) return false;
2786
+ if (!startDate.value.isValid() || !endDate.value.isValid()) return false;
2787
+ if (startDate.value.isSame(endDate.value, "ms")) return false;
2788
+ if (startDate.value.format(format.value) === endDate.value.format(format.value)) return false;
2789
+ if (startDate.value.isAfter(endDate.value)) return false;
2790
+ return true;
2791
+ });
2792
+ const handleFormatChange = (f) => {
2793
+ formatChange(f);
2794
+ };
2795
+ watch(
2796
+ () => props.value,
2797
+ (date) => {
2798
+ const { dateValue, endDate: dateEnd, startDate: dateStart } = date;
2799
+ startDate.value = dateStart;
2800
+ endDate.value = dateEnd;
2801
+ isStartNow.value = dateValue[0] === NowConstant;
2802
+ isEndNow.value = dateValue[1] === NowConstant;
2149
2803
  },
2150
2804
  {
2151
- immediate: !0
2805
+ immediate: true
2152
2806
  }
2153
2807
  );
2154
- const Y = J(() => !(!c.value || !s.value || !c.value.isValid() || !s.value.isValid() || c.value.isSame(s.value, "ms") || c.value.format(S.value) === s.value.format(S.value) || c.value.isAfter(s.value))), $ = async (f, u) => {
2155
- setTimeout(() => {
2156
- var za, Ea, Sa;
2157
- const M = u === "start" ? n.value : b.value, w = (za = M == null ? void 0 : M.value) == null ? void 0 : za.toString().trim(), R = u === "start" ? c.value : s.value, ea = u === "start" ? o : y, Ma = u === "start" ? y : o, ha = R == null ? void 0 : R.format(S.value);
2158
- if (w === ha || !w || w === C && ea.value)
2159
- return;
2160
- if (w === C && !ea.value && !Ma.value) {
2161
- x(u);
2162
- return;
2808
+ watch(
2809
+ () => timezoneInfo,
2810
+ (newTimezone) => {
2811
+ if (!timezoneInfo.value) return;
2812
+ if (newTimezone.value.label === curTimezoneInfo.value.label) return;
2813
+ if (newTimezone.value.utc === curTimezoneInfo.value.utc) return;
2814
+ curTimezoneInfo.value = newTimezone.value || dayjs.tz.guess();
2815
+ if (startDate.value) {
2816
+ startDate.value = dayjs.tz(startDate.value, curTimezoneInfo.value.label);
2817
+ startInput.value.value = startDate.value.format(format.value);
2163
2818
  }
2164
- let F;
2165
- if (oa.test(w) && (F = _a(w, u)), !F && !/Z$/i.test(w) && "YYYY-MM-DD HH:mm:ss".includes(S.value)) {
2166
- const ta = w.match($e) || [];
2167
- if (ta.length) {
2168
- let O = !0;
2169
- const le = (ta[7] || "0").substring(0, 3), Ca = ta[6] || 0;
2170
- O = +Ca < 60;
2171
- const Pa = ta[5] || 0;
2172
- O = O && +Pa < 60;
2173
- const Ta = ta[4] || 0;
2174
- O = O && +Ta < 24;
2175
- const Va = ta[3] || 1;
2176
- O = O && +Va < 32;
2177
- const Na = +ta[2] - 1 || 0;
2178
- O = O && Na < 12;
2179
- const $a = ta[1];
2180
- O = O && $a.length < 5, F = O ? d(new Date(+$a, Na, +Va, +Ta, +Pa, +Ca, +le)) : R;
2819
+ if (endDate.value) {
2820
+ endDate.value = dayjs.tz(endDate.value, curTimezoneInfo.value.label);
2821
+ endInput.value.value = endDate.value.format(format.value);
2822
+ }
2823
+ },
2824
+ {
2825
+ deep: true
2826
+ }
2827
+ );
2828
+ onActivated(() => {
2829
+ setTimeout(() => {
2830
+ var _a;
2831
+ (_a = startInput.value) == null ? void 0 : _a.focus();
2832
+ handleFocusStart();
2833
+ }, 200);
2834
+ });
2835
+ const handleInputEnter = async (_, type) => {
2836
+ var _a, _b, _c;
2837
+ const target = type === "start" ? startInput.value : endInput.value;
2838
+ const val = (_a = target == null ? void 0 : target.value) == null ? void 0 : _a.toString().trim();
2839
+ const editDate = type === "start" ? startDate.value : endDate.value;
2840
+ const curNow = type === "start" ? isStartNow : isEndNow;
2841
+ const otherNow = type === "start" ? isEndNow : isStartNow;
2842
+ const formatValue = editDate == null ? void 0 : editDate.format(format.value);
2843
+ if (val === formatValue) return;
2844
+ if (!val || val === NowConstant && curNow.value) return;
2845
+ if (val === NowConstant && !curNow.value && !otherNow.value) {
2846
+ handleIsNowChange(type);
2847
+ return;
2848
+ }
2849
+ let date = inputVal2Dayjs(val, format.value, editDate);
2850
+ if (date.isValid()) {
2851
+ if (!(editDate == null ? void 0 : editDate.isSame(date))) {
2852
+ curNow.value = val === NowConstant;
2853
+ if (type === "start") {
2854
+ handleStartTimeChange(!startDate.value ? date.startOf("d") : date);
2855
+ } else {
2856
+ handleEndTimeChange(!endDate.value ? date.endOf("d") : date);
2181
2857
  }
2182
2858
  }
2183
- F || (F = d(w)), F.isValid() && (R != null && R.isSame(F) || (ea.value = w === C, u === "start" ? P(c ? F : F.startOf("d")) : B(s ? F : F.endOf("d")))), M.value = u === "start" ? ((Ea = c.value) == null ? void 0 : Ea.format(S.value)) || "" : ((Sa = s.value) == null ? void 0 : Sa.format(S.value)) || "";
2184
- }, 16);
2185
- }, H = () => {
2186
- h.value = !0, g();
2187
- }, _ = () => {
2188
- m.value = !0, A();
2189
- }, A = (f = 32) => {
2190
- setTimeout(() => h.value = !1, f);
2191
- }, g = (f = 32) => {
2192
- setTimeout(() => m.value = !1, f);
2193
- }, P = (f) => {
2194
- var u, M;
2195
- (u = c.value) != null && u.isSame(f) || (c.value = f, o.value = !1), s.value || ((M = b.value) == null || M.focus(), _()), A();
2196
- }, B = (f) => {
2197
- var u, M;
2198
- (u = s.value) != null && u.isSame(f) || (s.value = f, y.value = !1), c.value || ((M = n.value) == null || M.focus(), H()), g();
2199
- }, x = (f) => {
2200
- f === "start" ? (o.value = !o.value, y.value = !1, c.value = d(), s.value ? o.value && A() : (setTimeout(() => {
2201
- var u;
2202
- (u = b.value) == null || u.focus(), _();
2203
- }, 200), A())) : (y.value = !y.value, o.value = !1, s.value = d(), c.value ? y.value && g() : (setTimeout(() => {
2204
- var u;
2205
- (u = n.value) == null || u.focus(), H();
2206
- }, 200), g()));
2207
- }, T = () => {
2208
- c.value = void 0, s.value = void 0, o.value = !1, y.value = !1, A(), g();
2209
- }, V = () => {
2210
- if (c.value && s.value) {
2211
- const f = o.value ? C : c.value.tz(D.value.label, !0).valueOf(), u = y.value ? C : s.value.tz(D.value.label, !0).valueOf();
2212
- e("change", [f || "", u || ""]);
2213
2859
  }
2214
- }, aa = (f) => {
2215
- var u;
2216
- h.value && ((u = document.querySelector(".__date-picker-popover-start__")) != null && u.contains(f.target) || A());
2217
- }, W = (f) => {
2218
- var u;
2219
- m.value && ((u = document.querySelector(".__date-picker-popover-end__")) != null && u.contains(f.target) || g());
2220
- };
2221
- return (f, u) => {
2222
- var M;
2223
- return p(), z("div", et, [
2224
- v("div", tt, [
2225
- v(
2860
+ target.value = type === "start" ? ((_b = startDate.value) == null ? void 0 : _b.format(format.value)) || "" : ((_c = endDate.value) == null ? void 0 : _c.format(format.value)) || "";
2861
+ };
2862
+ const handleFocusStart = () => {
2863
+ showStartPanel.value = true;
2864
+ isValidate.value = true;
2865
+ hiddenEndPanel();
2866
+ };
2867
+ const handleFocusEnd = () => {
2868
+ showEndPanel.value = true;
2869
+ isValidate.value = true;
2870
+ hiddenStartPanel();
2871
+ };
2872
+ const hiddenStartPanel = (interval = 32) => {
2873
+ setTimeout(() => showStartPanel.value = false, interval);
2874
+ };
2875
+ const hiddenEndPanel = (interval = 32) => {
2876
+ setTimeout(() => showEndPanel.value = false, interval);
2877
+ };
2878
+ const handleStartTimeChange = (date) => {
2879
+ var _a, _b;
2880
+ if (!((_a = startDate.value) == null ? void 0 : _a.isSame(date))) {
2881
+ startDate.value = date;
2882
+ isStartNow.value = false;
2883
+ }
2884
+ (_b = endInput.value) == null ? void 0 : _b.focus();
2885
+ handleFocusEnd();
2886
+ hiddenStartPanel();
2887
+ };
2888
+ const handleEndTimeChange = (date) => {
2889
+ var _a, _b;
2890
+ if (!((_a = endDate.value) == null ? void 0 : _a.isSame(date))) {
2891
+ endDate.value = date;
2892
+ isEndNow.value = false;
2893
+ }
2894
+ if (!startDate.value) {
2895
+ (_b = startInput.value) == null ? void 0 : _b.focus();
2896
+ handleFocusStart();
2897
+ }
2898
+ hiddenEndPanel();
2899
+ };
2900
+ const handleIsNowChange = (type) => {
2901
+ if (type === "start") {
2902
+ isStartNow.value = !isStartNow.value;
2903
+ isEndNow.value = false;
2904
+ startDate.value = dayjs();
2905
+ if (!endDate.value) {
2906
+ setTimeout(() => {
2907
+ var _a;
2908
+ (_a = endInput.value) == null ? void 0 : _a.focus();
2909
+ handleFocusEnd();
2910
+ }, 200);
2911
+ hiddenStartPanel();
2912
+ } else if (isStartNow.value) {
2913
+ hiddenStartPanel();
2914
+ }
2915
+ } else {
2916
+ isEndNow.value = !isEndNow.value;
2917
+ isStartNow.value = false;
2918
+ endDate.value = dayjs();
2919
+ if (!startDate.value) {
2920
+ setTimeout(() => {
2921
+ var _a;
2922
+ (_a = startInput.value) == null ? void 0 : _a.focus();
2923
+ handleFocusStart();
2924
+ }, 200);
2925
+ hiddenEndPanel();
2926
+ } else if (isEndNow.value) {
2927
+ hiddenEndPanel();
2928
+ }
2929
+ }
2930
+ };
2931
+ const handleClear = () => {
2932
+ startDate.value = void 0;
2933
+ endDate.value = void 0;
2934
+ isStartNow.value = false;
2935
+ isEndNow.value = false;
2936
+ hiddenStartPanel();
2937
+ hiddenEndPanel();
2938
+ };
2939
+ const handleSubmit = () => {
2940
+ if (startDate.value && endDate.value && canConfirm.value) {
2941
+ const startValue = isStartNow.value ? NowConstant : dayjs.tz(startDate.value.format(format.value ?? DefaultCommitFormat), timezoneInfo.value.label).valueOf();
2942
+ const endValue = isEndNow.value ? NowConstant : dayjs.tz(endDate.value.format(format.value ?? DefaultCommitFormat), timezoneInfo.value.label).valueOf();
2943
+ isValidate.value = validateDateValue([startValue || "", endValue || ""]);
2944
+ if (!isValidate.value) return;
2945
+ emits("change", [startValue || "", endValue || ""]);
2946
+ }
2947
+ };
2948
+ const handleClickoutsideStart = (e) => {
2949
+ var _a;
2950
+ if (!showStartPanel.value) return;
2951
+ if (!((_a = document.querySelector(".__date-picker-popover-start__")) == null ? void 0 : _a.contains(e.target))) {
2952
+ hiddenStartPanel();
2953
+ }
2954
+ };
2955
+ const handleClickoutsideEnd = (e) => {
2956
+ var _a;
2957
+ if (!showEndPanel.value) return;
2958
+ if (!((_a = document.querySelector(".__date-picker-popover-end__")) == null ? void 0 : _a.contains(e.target))) {
2959
+ hiddenEndPanel();
2960
+ }
2961
+ };
2962
+ __expose({
2963
+ handleSubmit
2964
+ });
2965
+ return (_ctx, _cache) => {
2966
+ var _a;
2967
+ return openBlock(), createElementBlock("div", _hoisted_1$6, [
2968
+ createElementVNode("div", _hoisted_2$4, [
2969
+ createElementVNode(
2226
2970
  "div",
2227
2971
  {
2228
- style: Ja({
2229
- "border-color": h.value || m.value ? "#3A84FF" : "#C4C6CC"
2230
- }),
2231
- class: "date-picker"
2972
+ class: "date-picker",
2973
+ style: normalizeStyle({
2974
+ "border-color": !isValidate.value ? "#ea3636" : showStartPanel.value || showEndPanel.value ? "#3A84FF" : "#C4C6CC"
2975
+ })
2232
2976
  },
2233
2977
  [
2234
- it,
2235
- E(t(ca), {
2236
- arrow: !1,
2237
- "is-show": h.value,
2978
+ _cache[8] || (_cache[8] = createElementVNode(
2979
+ "span",
2980
+ { class: "date-picker-icon" },
2981
+ [
2982
+ createElementVNode("svg", {
2983
+ class: "date-content-icon",
2984
+ height: "14",
2985
+ version: "1.1",
2986
+ viewBox: "0 0 1024 1024",
2987
+ width: "14",
2988
+ xmlns: "http://www.w3.org/2000/svg",
2989
+ "xmlns:xlink": "http://www.w3.org/1999/xlink"
2990
+ }, [
2991
+ createElementVNode("path", {
2992
+ d: "M558.933 465.067h-93.866v93.866h93.866v-93.866z m0 162.133h-93.866v93.867h93.866V627.2z m371.2-533.333h-93.866V21.333c0-12.8-8.534-21.333-21.334-21.333S793.6 8.533 793.6 21.333V89.6H234.667V21.333c0-12.8-12.8-21.333-25.6-21.333s-21.334 8.533-21.334 21.333V89.6H93.867C42.667 93.867 0 136.533 0 187.733V934.4c0 46.933 42.667 89.6 93.867 89.6h836.266c51.2 0 93.867-42.667 93.867-93.867v-742.4c0-51.2-42.667-93.866-93.867-93.866z m46.934 836.266c0 25.6-21.334 46.934-46.934 46.934H93.867c-25.6 0-46.934-21.334-46.934-46.934V371.2h930.134v558.933z m0-605.866H46.933V187.733c0-25.6 21.334-46.933 46.934-46.933h93.866v68.267c0 12.8 8.534 21.333 21.334 21.333s21.333-8.533 21.333-21.333V140.8h558.933v68.267c0 12.8 8.534 21.333 21.334 21.333S832 221.867 832 209.067V140.8h93.867c25.6 0 46.933 21.333 46.933 46.933v136.534h4.267zM789.333 627.2h-93.866v93.867h93.866V627.2z m0-162.133h-93.866v93.866h93.866v-93.866z m-230.4 324.266h-93.866V883.2h93.866v-93.867z m-234.666 0h-89.6V883.2h93.866v-93.867h-4.266z m0-324.266h-89.6v93.866h93.866v-93.866h-4.266z m0 162.133h-89.6v93.867h93.866V627.2h-4.266z",
2993
+ fill: "#C4C6CC",
2994
+ xmlns: "http://www.w3.org/2000/svg"
2995
+ })
2996
+ ])
2997
+ ],
2998
+ -1
2999
+ /* HOISTED */
3000
+ )),
3001
+ createVNode(unref(Popover), {
3002
+ arrow: false,
2238
3003
  boundary: "parent",
2239
3004
  "ext-cls": "__bk-date-picker-popover__ __date-picker-popover-start__",
3005
+ "is-show": showStartPanel.value,
2240
3006
  placement: "bottom-start",
2241
3007
  theme: "light",
2242
3008
  trigger: "manual"
2243
3009
  }, {
2244
- content: j(() => [
2245
- E(Ka, {
2246
- "diable-now": y.value,
2247
- format: t(S),
2248
- "is-now": o.value,
2249
- "model-value": c.value,
2250
- title: t(r)("开始时间"),
2251
- "onUpdate:isNow": u[2] || (u[2] = () => x("start")),
2252
- "onUpdate:modelValue": P,
2253
- key: "start"
2254
- }, null, 8, ["diable-now", "format", "is-now", "model-value", "title"])
3010
+ content: withCtx(() => [
3011
+ createVNode(_sfc_main$7, {
3012
+ key: "start",
3013
+ "disable-now": isEndNow.value,
3014
+ format: unref(format),
3015
+ "is-now": isStartNow.value,
3016
+ "model-value": startDate.value,
3017
+ title: unref(t)("开始时间"),
3018
+ "onUpdate:isNow": _cache[2] || (_cache[2] = () => handleIsNowChange("start")),
3019
+ "onUpdate:modelValue": _cache[3] || (_cache[3] = (date) => handleStartTimeChange(date.startOf("d")))
3020
+ }, null, 8, ["disable-now", "format", "is-now", "model-value", "title"])
2255
3021
  ]),
2256
- default: j(() => {
2257
- var w;
3022
+ default: withCtx(() => {
3023
+ var _a2;
2258
3024
  return [
2259
- fa(v("input", {
2260
- placeholder: t(r)("开始时间"),
2261
- value: o.value ? t(C) : (w = c.value) == null ? void 0 : w.format(t(S)),
2262
- onBlur: u[0] || (u[0] = (R) => $(R, "start")),
2263
- onClick: H,
2264
- onKeypress: u[1] || (u[1] = ja((R) => $(R, "start"), ["enter"])),
2265
- class: "date-picker-start",
3025
+ withDirectives(createElementVNode("input", {
2266
3026
  ref_key: "startInput",
2267
- ref: n,
2268
- spellcheck: "false"
2269
- }, null, 40, nt), [
2270
- [t(Aa), aa]
3027
+ ref: startInput,
3028
+ class: "date-picker-start",
3029
+ placeholder: unref(t)("开始时间"),
3030
+ spellcheck: "false",
3031
+ value: isStartNow.value ? unref(NowConstant) : (_a2 = startDate.value) == null ? void 0 : _a2.format(unref(format)),
3032
+ onBlur: _cache[0] || (_cache[0] = (e) => handleInputEnter(e, "start")),
3033
+ onClick: handleFocusStart,
3034
+ onKeypress: _cache[1] || (_cache[1] = withKeys((e) => handleInputEnter(e, "start"), ["enter"]))
3035
+ }, null, 40, _hoisted_3$3), [
3036
+ [unref(clickoutside), handleClickoutsideStart]
2271
3037
  ])
2272
3038
  ];
2273
3039
  }),
2274
3040
  _: 1
2275
3041
  /* STABLE */
2276
3042
  }, 8, ["is-show"]),
2277
- rt,
2278
- E(t(ca), {
2279
- arrow: !1,
2280
- "is-show": m.value,
3043
+ _cache[9] || (_cache[9] = createElementVNode(
3044
+ "span",
3045
+ { class: "date-picker-split" },
3046
+ "~",
3047
+ -1
3048
+ /* HOISTED */
3049
+ )),
3050
+ createVNode(unref(Popover), {
3051
+ arrow: false,
2281
3052
  boundary: "parent",
2282
3053
  "ext-cls": "__bk-date-picker-popover__ __date-picker-popover-end__",
3054
+ "is-show": showEndPanel.value,
2283
3055
  placement: "bottom-start",
2284
3056
  theme: "light",
2285
3057
  trigger: "manual"
2286
3058
  }, {
2287
- content: j(() => [
2288
- E(Ka, {
2289
- "diable-now": o.value,
2290
- format: t(S),
2291
- "is-now": y.value,
2292
- "model-value": s.value,
2293
- title: t(r)("结束时间"),
2294
- "onUpdate:isNow": u[5] || (u[5] = () => x("end")),
2295
- "onUpdate:modelValue": u[6] || (u[6] = (w) => B(w.endOf("d"))),
2296
- key: "end"
2297
- }, null, 8, ["diable-now", "format", "is-now", "model-value", "title"])
3059
+ content: withCtx(() => [
3060
+ createVNode(_sfc_main$7, {
3061
+ key: "end",
3062
+ "disable-now": isStartNow.value,
3063
+ format: unref(format),
3064
+ "is-now": isEndNow.value,
3065
+ "model-value": endDate.value,
3066
+ title: unref(t)("结束时间"),
3067
+ "onUpdate:isNow": _cache[6] || (_cache[6] = () => handleIsNowChange("end")),
3068
+ "onUpdate:modelValue": _cache[7] || (_cache[7] = (date) => handleEndTimeChange(date.endOf("d")))
3069
+ }, null, 8, ["disable-now", "format", "is-now", "model-value", "title"])
2298
3070
  ]),
2299
- default: j(() => {
2300
- var w;
3071
+ default: withCtx(() => {
3072
+ var _a2;
2301
3073
  return [
2302
- fa(v("input", {
2303
- placeholder: t(r)("结束时间"),
2304
- value: y.value ? t(C) : (w = s.value) == null ? void 0 : w.format(t(S)),
2305
- onBlur: u[3] || (u[3] = (R) => $(R, "end")),
2306
- onClick: _,
2307
- onKeypress: u[4] || (u[4] = ja((R) => $(R, "end"), ["enter"])),
2308
- class: "date-picker-end",
3074
+ withDirectives(createElementVNode("input", {
2309
3075
  ref_key: "endInput",
2310
- ref: b
2311
- }, null, 40, lt), [
2312
- [t(Aa), W]
3076
+ ref: endInput,
3077
+ class: "date-picker-end",
3078
+ placeholder: unref(t)("结束时间"),
3079
+ value: isEndNow.value ? unref(NowConstant) : (_a2 = endDate.value) == null ? void 0 : _a2.format(unref(format)),
3080
+ onBlur: _cache[4] || (_cache[4] = (e) => handleInputEnter(e, "end")),
3081
+ onClick: handleFocusEnd,
3082
+ onKeypress: _cache[5] || (_cache[5] = withKeys((e) => handleInputEnter(e, "end"), ["enter"]))
3083
+ }, null, 40, _hoisted_4$2), [
3084
+ [unref(clickoutside), handleClickoutsideEnd]
2313
3085
  ])
2314
3086
  ];
2315
3087
  }),
2316
3088
  _: 1
2317
3089
  /* STABLE */
2318
3090
  }, 8, ["is-show"]),
2319
- c.value || s.value ? (p(), K(t(ye), {
2320
- key: 0,
2321
- onClick: T,
2322
- class: "date-picker-clear"
2323
- })) : sa("v-if", !0)
3091
+ createVNode(unref(Close), {
3092
+ class: "date-picker-clear",
3093
+ style: normalizeStyle({
3094
+ visibility: startDate.value || endDate.value ? "visible" : "hidden"
3095
+ }),
3096
+ onClick: handleClear
3097
+ }, null, 8, ["style"])
2324
3098
  ],
2325
3099
  4
2326
3100
  /* STYLE */
2327
3101
  ),
2328
- E(Da, {
2329
- "disable-tips": (M = c.value) != null && M.isAfter(s.value) ? t(r)("开始时间不能大于结束时间") : "",
2330
- disabled: !Y.value,
2331
- onSubmit: V
2332
- }, null, 8, ["disable-tips", "disabled"])
3102
+ createElementVNode("div", null, [
3103
+ createVNode(_sfc_main$8, {
3104
+ ref: "submit",
3105
+ "disable-tips": ((_a = startDate.value) == null ? void 0 : _a.isAfter(endDate.value)) ? unref(t)("开始时间不能大于结束时间") : "",
3106
+ disabled: !canConfirm.value,
3107
+ onSubmit: handleSubmit
3108
+ }, null, 8, ["disable-tips", "disabled"])
3109
+ ])
2333
3110
  ]),
2334
- v("div", st, [
2335
- G(
2336
- k(t(r)("支持多种时间格式自动转换")) + " ",
2337
- 1
2338
- /* TEXT */
2339
- ),
2340
- E(t(ca), {
2341
- trigger: "click",
3111
+ !isValidate.value ? (openBlock(), createElementBlock(
3112
+ "div",
3113
+ _hoisted_5$1,
3114
+ toDisplayString(unref(validMsg)),
3115
+ 1
3116
+ /* TEXT */
3117
+ )) : createCommentVNode("v-if", true),
3118
+ createElementVNode("div", _hoisted_6$1, [
3119
+ createCommentVNode(" {{ t('支持多种时间格式自动转换') }} "),
3120
+ createVNode(unref(Popover), {
3121
+ arrow: false,
2342
3122
  "ext-cls": "__bk-date-picker-popover__",
2343
- placement: "bottom",
2344
- theme: "light"
3123
+ placement: "bottom-start",
3124
+ theme: "light",
3125
+ trigger: "click"
2345
3126
  }, {
2346
- content: j(() => [
2347
- v("div", ct, [
2348
- v(
2349
- "div",
2350
- ut,
2351
- k(t(r)("时间格式支持")),
2352
- 1
2353
- /* TEXT */
2354
- ),
2355
- v("table", ot, [
2356
- v("thead", null, [
2357
- v("tr", null, [
2358
- v(
2359
- "th",
2360
- null,
2361
- k(t(r)("格式")),
2362
- 1
2363
- /* TEXT */
2364
- ),
2365
- v(
2366
- "th",
3127
+ content: withCtx(() => [
3128
+ createElementVNode(
3129
+ "div",
3130
+ {
3131
+ class: normalizeClass(["date-format-wrapper", { "enable-format-click": unref(enableFormatClick) }])
3132
+ },
3133
+ [
3134
+ createCommentVNode(` <div class="content-title">
3135
+ {{ t('时间格式支持') }}
3136
+ </div> `),
3137
+ createElementVNode("table", _hoisted_7$1, [
3138
+ createCommentVNode(" <thead>\n <tr>\n <th>{{ t('格式') }}</th>\n <th>{{ t('示例') }}</th>\n </tr>\n </thead> "),
3139
+ createElementVNode("tbody", null, [
3140
+ (openBlock(true), createElementBlock(
3141
+ Fragment,
2367
3142
  null,
2368
- k(t(r)("示例")),
2369
- 1
2370
- /* TEXT */
2371
- )
3143
+ renderList(unref(dateFormatList), (f) => {
3144
+ return openBlock(), createElementBlock("tr", { key: f }, [
3145
+ createElementVNode("td", {
3146
+ class: "cell-format-value",
3147
+ onClick: () => handleFormatChange(f)
3148
+ }, toDisplayString(f), 9, _hoisted_8),
3149
+ createElementVNode(
3150
+ "td",
3151
+ null,
3152
+ toDisplayString(unref(today).format(f)),
3153
+ 1
3154
+ /* TEXT */
3155
+ )
3156
+ ]);
3157
+ }),
3158
+ 128
3159
+ /* KEYED_FRAGMENT */
3160
+ ))
2372
3161
  ])
2373
- ]),
2374
- v("tbody", null, [
2375
- (p(!0), z(
2376
- U,
2377
- null,
2378
- q(t(Ve), (w) => (p(), z("tr", { key: w }, [
2379
- v(
2380
- "td",
2381
- null,
2382
- k(w),
2383
- 1
2384
- /* TEXT */
2385
- ),
2386
- v(
2387
- "td",
2388
- null,
2389
- k(t(N).format(w)),
2390
- 1
2391
- /* TEXT */
2392
- )
2393
- ]))),
2394
- 128
2395
- /* KEYED_FRAGMENT */
2396
- ))
2397
3162
  ])
2398
- ])
2399
- ])
3163
+ ],
3164
+ 2
3165
+ /* CLASS */
3166
+ )
2400
3167
  ]),
2401
- default: j(() => [
2402
- E(t(wa), {
3168
+ default: withCtx(() => [
3169
+ createVNode(unref(Button), {
2403
3170
  class: "format-button",
2404
3171
  text: "",
2405
3172
  theme: "primary"
2406
3173
  }, {
2407
- default: j(() => [
2408
- G(
2409
- k(t(r)("查看支持格式")),
3174
+ default: withCtx(() => [
3175
+ createTextVNode(
3176
+ toDisplayString(unref(t)("时间格式转换")) + " ",
2410
3177
  1
2411
3178
  /* TEXT */
2412
- )
3179
+ ),
3180
+ createVNode(unref(Transfer))
2413
3181
  ]),
2414
3182
  _: 1
2415
3183
  /* STABLE */
@@ -2422,434 +3190,774 @@ const _a = (l, a = "start", i) => {
2422
3190
  ]);
2423
3191
  };
2424
3192
  }
2425
- }), mt = { class: "natural-picker" }, ht = ["onClick"], vt = "__", bt = /* @__PURE__ */ X({
3193
+ });
3194
+ const _hoisted_1$5 = { class: "date-title" };
3195
+ const _sfc_main$5 = /* @__PURE__ */ defineComponent({
3196
+ __name: "date-title",
3197
+ emits: ["confirm"],
3198
+ setup(__props) {
3199
+ return (_ctx, _cache) => {
3200
+ return openBlock(), createElementBlock("div", _hoisted_1$5, [
3201
+ (openBlock(true), createElementBlock(
3202
+ Fragment,
3203
+ null,
3204
+ renderList(unref(panels), (item) => {
3205
+ return openBlock(), createElementBlock("div", {
3206
+ key: item.id,
3207
+ class: "date-title-item"
3208
+ }, [
3209
+ createTextVNode(
3210
+ toDisplayString(item.name) + " ",
3211
+ 1
3212
+ /* TEXT */
3213
+ ),
3214
+ item.id === "recent" ? (openBlock(), createBlock(unref(PopConfirm), {
3215
+ key: 0,
3216
+ "cancel-text": unref(t)("取消"),
3217
+ "confirm-text": unref(t)("确定"),
3218
+ content: unref(t)("是否清空最近使用?"),
3219
+ "ext-cls": "__bk-date-picker-popover__ __bk-date-picker-popover-delete__",
3220
+ trigger: "click",
3221
+ width: 189,
3222
+ onConfirm: _cache[0] || (_cache[0] = ($event) => _ctx.$emit("confirm"))
3223
+ }, {
3224
+ default: withCtx(() => [
3225
+ createVNode(unref(Del), { class: "delete-all" })
3226
+ ]),
3227
+ _: 1
3228
+ /* STABLE */
3229
+ }, 8, ["cancel-text", "confirm-text", "content"])) : createCommentVNode("v-if", true)
3230
+ ]);
3231
+ }),
3232
+ 128
3233
+ /* KEYED_FRAGMENT */
3234
+ ))
3235
+ ]);
3236
+ };
3237
+ }
3238
+ });
3239
+ const DateTitle = /* @__PURE__ */ _export_sfc(_sfc_main$5, [["__scopeId", "data-v-03d5d182"]]);
3240
+ const _hoisted_1$4 = ["onClick"];
3241
+ const _hoisted_2$3 = {
3242
+ key: 0,
3243
+ style: { "margin": "-8px 0 4px", "color": "#ea3636" }
3244
+ };
3245
+ const splitDate = "__";
3246
+ const _sfc_main$4 = /* @__PURE__ */ defineComponent({
2426
3247
  __name: "natural-picker",
2427
3248
  props: {
2428
3249
  value: {}
2429
3250
  },
2430
3251
  emits: ["change"],
2431
- setup(l, { emit: a }) {
2432
- const i = L(), e = a, n = l, b = L(), h = Q(xa.slice()), m = L(Ra[0].id), c = L(""), s = L(), o = L(h.value[0]);
2433
- ne(Ia(), "session").forEach((_) => {
2434
- const [A, g] = _;
2435
- if (d.isDayjs(A) || d.isDayjs(g))
2436
- return;
2437
- const P = new ra(_), { startNum: B, startUnit: x } = P;
2438
- if (!h.value.find((V) => V.id === A)) {
2439
- const V = `${`${r("前")} ${B} ${r(
2440
- la[x]
3252
+ setup(__props, { expose: __expose, emit: __emit }) {
3253
+ const emits = __emit;
3254
+ const props = __props;
3255
+ const inputRef = ref();
3256
+ const naturalSelectRef = ref();
3257
+ const naturalOptions = shallowRef(CommonNaturalOptions.slice());
3258
+ const naturalUnitValue = ref(naturalUnitOptions[0].id);
3259
+ const canEditNaturalId = ref("");
3260
+ const inputValue = ref();
3261
+ const naturalValue = ref(naturalOptions.value[0]);
3262
+ const isValidate = ref(true);
3263
+ const { validMsg, validateDateValue } = useValidate();
3264
+ getStoreDateList(getStoreKey(), "session").forEach((item) => {
3265
+ const [start, end] = item;
3266
+ if (dayjs.isDayjs(start) || dayjs.isDayjs(end)) return;
3267
+ const date = new DateRange(item);
3268
+ const { startNum, startUnit } = date;
3269
+ const specialDate = naturalOptions.value.find((item2) => item2.id === start);
3270
+ if (!specialDate) {
3271
+ const name = `${`${t("前")} ${startNum} ${t(
3272
+ shortTimeUnitLangData[startUnit]
2441
3273
  )}`}`;
2442
- h.value.unshift({
2443
- id: A,
2444
- name: V,
2445
- type: ia.custom
3274
+ naturalOptions.value.unshift({
3275
+ id: start,
3276
+ name,
3277
+ type: NaturalOptionType.custom
2446
3278
  });
2447
3279
  }
2448
- }), ma(
2449
- () => n.value,
2450
- (_) => {
2451
- if (!_ || _.dateMode !== I.NATURAL)
2452
- return;
2453
- const [A, g] = _.dateValue;
2454
- if (d.isDayjs(A) || d.isDayjs(g))
2455
- return;
2456
- const { startNum: P, startUnit: B } = _;
2457
- m.value = g === C ? ba.NOW : ba.ALL;
2458
- const x = h.value.find((V) => V.id === A && V.type === ia.custom);
2459
- if (x) {
2460
- o.value = x;
3280
+ });
3281
+ watch(
3282
+ () => props.value,
3283
+ (date) => {
3284
+ if (!date) return;
3285
+ if (date.dateMode !== DateMode.NATURAL) return;
3286
+ const [start, end] = date.dateValue;
3287
+ if (dayjs.isDayjs(start) || dayjs.isDayjs(end)) return;
3288
+ const { startNum, startUnit } = date;
3289
+ naturalUnitValue.value = end === NowConstant ? NaturalUnit.NOW : NaturalUnit.ALL;
3290
+ const customDate = naturalOptions.value.find((item) => item.id === start && item.type === NaturalOptionType.custom);
3291
+ if (customDate) {
3292
+ naturalValue.value = customDate;
2461
3293
  return;
2462
3294
  }
2463
- const T = xa.find((V) => V.id === A && V.type === ia.default);
2464
- if (g !== C && A !== g && T || !T) {
2465
- const V = `${`${r("前")} ${P} ${r(
2466
- la[B]
3295
+ const specialDate = CommonNaturalOptions.find(
3296
+ (item) => item.id === start && item.type === NaturalOptionType.default
3297
+ );
3298
+ if (end !== NowConstant && start !== end && specialDate || !specialDate) {
3299
+ const name = `${`${t("前")} ${startNum} ${t(
3300
+ shortTimeUnitLangData[startUnit]
2467
3301
  )}`}`;
2468
- h.value.unshift({
2469
- id: A,
2470
- name: V,
2471
- type: ia.custom
2472
- }), [o.value] = h.value;
3302
+ naturalOptions.value.unshift({
3303
+ id: start,
3304
+ name,
3305
+ type: NaturalOptionType.custom
3306
+ });
3307
+ [naturalValue.value] = naturalOptions.value;
2473
3308
  return;
2474
3309
  }
2475
- T && (o.value = T);
3310
+ specialDate && (naturalValue.value = specialDate);
2476
3311
  },
2477
3312
  {
2478
- immediate: !0
3313
+ immediate: true
2479
3314
  }
2480
3315
  );
2481
- const y = (_) => `${_.id}${vt}${_.type}`, S = (_) => {
2482
- const A = _.id;
2483
- if (m.value === ba.ALL) {
2484
- const [, g, P, B] = A.match(ya) || [];
2485
- return Math.abs(+g) > 1 ? Math.abs(+g) === 2 && P === "d" ? [A, A] : [A, `now-1${P}/${B}`] : [A, A];
3316
+ const getNaturalOptionId = (date) => {
3317
+ return `${date.id}${splitDate}${date.type}`;
3318
+ };
3319
+ const getNaturalDateValue = (date) => {
3320
+ const value = date.id;
3321
+ if (naturalUnitValue.value === NaturalUnit.ALL) {
3322
+ const [, num, unit, dateUnit2] = value.match(naturalDateRegexp) || [];
3323
+ if (Math.abs(+num) > 1) {
3324
+ if (Math.abs(+num) === 2 && unit === "d") return [value, value];
3325
+ return [value, `now-1${unit}/${dateUnit2}`];
3326
+ }
3327
+ return [value, value];
2486
3328
  }
2487
- return [A, C];
2488
- }, D = (_) => {
2489
- var A;
2490
- if (_.type === ia.edit) {
2491
- s.value = 1, c.value = _.id, setTimeout(() => {
2492
- var g, P, B;
2493
- (B = (P = (g = i.value) == null ? void 0 : g[0]) == null ? void 0 : P.focus) == null || B.call(P);
3329
+ return [value, NowConstant];
3330
+ };
3331
+ const handleClickItem = (item) => {
3332
+ var _a;
3333
+ if (item.type === NaturalOptionType.edit) {
3334
+ inputValue.value = 1;
3335
+ canEditNaturalId.value = item.id;
3336
+ setTimeout(() => {
3337
+ var _a2, _b, _c;
3338
+ (_c = (_b = (_a2 = inputRef.value) == null ? void 0 : _a2[0]) == null ? void 0 : _b.focus) == null ? void 0 : _c.call(_b);
2494
3339
  }, 20);
2495
3340
  return;
2496
3341
  }
2497
- o.value = _, c.value = "", (A = b.value) == null || A.hidePopover();
2498
- }, N = (_) => {
2499
- m.value = _;
2500
- }, Y = (_, A) => {
2501
- var B, x;
2502
- c.value = "";
2503
- const g = `now-${+_}${A.unit}/${A.unit}`, P = h.value.find((T) => T.id === g);
2504
- if (P) {
2505
- o.value = P, (B = b.value) == null || B.hidePopover();
3342
+ naturalValue.value = item;
3343
+ canEditNaturalId.value = "";
3344
+ (_a = naturalSelectRef.value) == null ? void 0 : _a.hidePopover();
3345
+ };
3346
+ const handleUnitChange = (value) => {
3347
+ naturalUnitValue.value = value;
3348
+ };
3349
+ const customNaturalOptions = (v, item) => {
3350
+ var _a, _b;
3351
+ canEditNaturalId.value = "";
3352
+ const value = `now-${+v}${item.unit}/${item.unit}`;
3353
+ const date = naturalOptions.value.find((item2) => item2.id === value);
3354
+ if (date) {
3355
+ naturalValue.value = date;
3356
+ (_a = naturalSelectRef.value) == null ? void 0 : _a.hidePopover();
2506
3357
  return;
2507
3358
  }
2508
- h.value.unshift({
2509
- id: g,
2510
- name: A.name.replace("N", _.toString()),
2511
- type: ia.custom
2512
- }), [o.value] = h.value, (x = b.value) == null || x.hidePopover();
2513
- }, $ = (_, A, g) => {
2514
- !A || +A < 1 || _.key !== "Enter" || !c.value || Y(Math.ceil(A), g);
2515
- }, H = () => {
2516
- h.value.filter((_) => _.type === ia.custom).forEach((_) => {
2517
- re(S(_), Ia(), "session");
2518
- }), e("change", S(o.value));
2519
- };
2520
- return (_, A) => (p(), z("div", mt, [
2521
- E(t(Z), {
2522
- clearable: !1,
2523
- "input-search": !1,
2524
- "model-value": y(o.value),
2525
- "no-match-text": t(r)("无匹配数据"),
2526
- "popover-min-width": 130,
2527
- "popover-options": { boundary: "parent", extCls: "__bk-date-picker-popover__" },
2528
- prefix: t(r)("自然日期"),
2529
- "search-placeholder": t(r)("请输入"),
2530
- class: "natural-date",
2531
- filterable: "",
2532
- ref_key: "naturalSelectRef",
2533
- ref: b
2534
- }, {
2535
- default: j(() => [
2536
- (p(!0), z(
2537
- U,
2538
- null,
2539
- q(h.value, (g) => (p(), K(t(Z).Option, {
2540
- id: y(g),
2541
- key: y(g),
2542
- name: g.name
2543
- }, {
2544
- default: j(() => [
2545
- v("div", {
2546
- onClick: A[1] || (A[1] = Ga(() => {
2547
- }, ["prevent", "stop"])),
2548
- class: "natural-custom-option"
2549
- }, [
2550
- c.value === g.id ? (p(), K(t(Za), {
2551
- key: 0,
2552
- clearable: !1,
2553
- min: 1,
2554
- placeholder: t(r)("请输入"),
2555
- precision: 0,
2556
- prefix: g.prefix,
2557
- "show-control": !0,
2558
- suffix: g.suffix,
2559
- onKeypress: (P, B) => $(B, P, g),
2560
- autofocus: "true",
2561
- ref_for: !0,
2562
- ref_key: "inputRef",
2563
- ref: i,
2564
- size: "small",
2565
- style: { width: "150px" },
2566
- type: "number",
2567
- modelValue: s.value,
2568
- "onUpdate:modelValue": A[0] || (A[0] = (P) => s.value = P)
2569
- }, null, 8, ["placeholder", "prefix", "suffix", "onKeypress", "modelValue"])) : (p(), z("div", {
2570
- key: 1,
2571
- onClick: (P) => D(g),
2572
- style: { width: "100%" }
2573
- }, k(g.name), 9, ht))
2574
- ])
2575
- ]),
2576
- _: 2
2577
- /* DYNAMIC */
2578
- }, 1032, ["id", "name"]))),
2579
- 128
2580
- /* KEYED_FRAGMENT */
2581
- ))
2582
- ]),
2583
- _: 1
2584
- /* STABLE */
2585
- }, 8, ["model-value", "no-match-text", "prefix", "search-placeholder"]),
2586
- E(t(Z), {
2587
- clearable: !1,
2588
- "model-value": m.value,
2589
- "popover-options": { boundary: "parent" },
2590
- onChange: N,
2591
- class: "natural-unit"
2592
- }, {
2593
- default: j(() => [
2594
- (p(!0), z(
2595
- U,
2596
- null,
2597
- q(t(Ra), (g) => (p(), K(t(Z).Option, {
2598
- id: g.id,
2599
- key: g.id,
2600
- name: g.name
2601
- }, null, 8, ["id", "name"]))),
2602
- 128
2603
- /* KEYED_FRAGMENT */
2604
- ))
2605
- ]),
2606
- _: 1
2607
- /* STABLE */
2608
- }, 8, ["model-value"]),
2609
- E(Da, { onSubmit: H })
2610
- ]));
3359
+ naturalOptions.value.unshift({
3360
+ id: value,
3361
+ name: item.name.replace("N", v.toString()),
3362
+ type: NaturalOptionType.custom
3363
+ });
3364
+ [naturalValue.value] = naturalOptions.value;
3365
+ (_b = naturalSelectRef.value) == null ? void 0 : _b.hidePopover();
3366
+ };
3367
+ const handleInputKeyPress = (e, v, item) => {
3368
+ if (!v || +v < 1) return;
3369
+ if (e.key !== "Enter" || !canEditNaturalId.value) return;
3370
+ customNaturalOptions(Math.min(Math.ceil(v), MAX_NUMBER_VALUE), item);
3371
+ };
3372
+ const handleSubmit = () => {
3373
+ const value = getNaturalDateValue(naturalValue.value);
3374
+ isValidate.value = validateDateValue(value);
3375
+ if (!isValidate.value) return;
3376
+ naturalOptions.value.filter((item) => item.type === NaturalOptionType.custom).forEach((item) => {
3377
+ setStoreDateList(getNaturalDateValue(item), getStoreKey(), "session");
3378
+ });
3379
+ emits("change", value);
3380
+ };
3381
+ __expose({
3382
+ handleSubmit
3383
+ });
3384
+ return (_ctx, _cache) => {
3385
+ return openBlock(), createElementBlock(
3386
+ Fragment,
3387
+ null,
3388
+ [
3389
+ createElementVNode(
3390
+ "div",
3391
+ {
3392
+ class: normalizeClass(["natural-picker", {
3393
+ "is-invalid": !isValidate.value
3394
+ }])
3395
+ },
3396
+ [
3397
+ createVNode(unref(Select), {
3398
+ ref_key: "naturalSelectRef",
3399
+ ref: naturalSelectRef,
3400
+ class: "natural-date",
3401
+ clearable: false,
3402
+ filterable: "",
3403
+ "input-search": false,
3404
+ "model-value": getNaturalOptionId(naturalValue.value),
3405
+ "no-match-text": unref(t)("无匹配数据"),
3406
+ "popover-min-width": 130,
3407
+ "popover-options": { boundary: "parent", extCls: "__bk-date-picker-popover__" },
3408
+ prefix: unref(t)("自然日期"),
3409
+ "search-placeholder": unref(t)("请输入"),
3410
+ onClick: _cache[2] || (_cache[2] = ($event) => isValidate.value = true)
3411
+ }, {
3412
+ default: withCtx(() => [
3413
+ (openBlock(true), createElementBlock(
3414
+ Fragment,
3415
+ null,
3416
+ renderList(naturalOptions.value, (item) => {
3417
+ return openBlock(), createBlock(unref(Select).Option, {
3418
+ id: getNaturalOptionId(item),
3419
+ key: getNaturalOptionId(item),
3420
+ name: item.name
3421
+ }, {
3422
+ default: withCtx(() => [
3423
+ createElementVNode("div", {
3424
+ class: "natural-custom-option",
3425
+ onClick: _cache[1] || (_cache[1] = withModifiers(() => {
3426
+ }, ["prevent", "stop"]))
3427
+ }, [
3428
+ canEditNaturalId.value === item.id ? (openBlock(), createBlock(unref(Input), {
3429
+ key: 0,
3430
+ ref_for: true,
3431
+ ref_key: "inputRef",
3432
+ ref: inputRef,
3433
+ modelValue: inputValue.value,
3434
+ "onUpdate:modelValue": _cache[0] || (_cache[0] = ($event) => inputValue.value = $event),
3435
+ autofocus: "true",
3436
+ clearable: false,
3437
+ max: unref(MAX_NUMBER_VALUE),
3438
+ min: 1,
3439
+ placeholder: unref(t)("请输入"),
3440
+ precision: 0,
3441
+ prefix: item.prefix,
3442
+ "show-control": true,
3443
+ size: "small",
3444
+ style: { "width": "150px" },
3445
+ suffix: item.suffix,
3446
+ type: "number",
3447
+ onKeypress: (v, e) => handleInputKeyPress(e, v, item)
3448
+ }, null, 8, ["modelValue", "max", "placeholder", "prefix", "suffix", "onKeypress"])) : (openBlock(), createElementBlock("div", {
3449
+ key: 1,
3450
+ style: { "width": "100%" },
3451
+ onClick: ($event) => handleClickItem(item)
3452
+ }, toDisplayString(item.name), 9, _hoisted_1$4))
3453
+ ])
3454
+ ]),
3455
+ _: 2
3456
+ /* DYNAMIC */
3457
+ }, 1032, ["id", "name"]);
3458
+ }),
3459
+ 128
3460
+ /* KEYED_FRAGMENT */
3461
+ ))
3462
+ ]),
3463
+ _: 1
3464
+ /* STABLE */
3465
+ }, 8, ["model-value", "no-match-text", "prefix", "search-placeholder"]),
3466
+ createVNode(unref(Select), {
3467
+ class: "natural-unit",
3468
+ clearable: false,
3469
+ "model-value": naturalUnitValue.value,
3470
+ "popover-options": { boundary: "parent" },
3471
+ onChange: handleUnitChange,
3472
+ onClick: _cache[3] || (_cache[3] = ($event) => isValidate.value = true)
3473
+ }, {
3474
+ default: withCtx(() => [
3475
+ (openBlock(true), createElementBlock(
3476
+ Fragment,
3477
+ null,
3478
+ renderList(unref(naturalUnitOptions), (item) => {
3479
+ return openBlock(), createBlock(unref(Select).Option, {
3480
+ id: item.id,
3481
+ key: item.id,
3482
+ name: item.name
3483
+ }, null, 8, ["id", "name"]);
3484
+ }),
3485
+ 128
3486
+ /* KEYED_FRAGMENT */
3487
+ ))
3488
+ ]),
3489
+ _: 1
3490
+ /* STABLE */
3491
+ }, 8, ["model-value"]),
3492
+ createVNode(_sfc_main$8, { onSubmit: handleSubmit })
3493
+ ],
3494
+ 2
3495
+ /* CLASS */
3496
+ ),
3497
+ !isValidate.value ? (openBlock(), createElementBlock(
3498
+ "div",
3499
+ _hoisted_2$3,
3500
+ toDisplayString(unref(validMsg)),
3501
+ 1
3502
+ /* TEXT */
3503
+ )) : createCommentVNode("v-if", true)
3504
+ ],
3505
+ 64
3506
+ /* STABLE_FRAGMENT */
3507
+ );
3508
+ };
3509
+ }
3510
+ });
3511
+ const _hoisted_1$3 = { class: "baseline-picker" };
3512
+ const _hoisted_2$2 = {
3513
+ key: 0,
3514
+ class: "specific-date"
3515
+ };
3516
+ const _hoisted_3$2 = ["placeholder", "value", "onKeydown"];
3517
+ const _hoisted_4$1 = ["onClick"];
3518
+ const _sfc_main$3 = /* @__PURE__ */ defineComponent({
3519
+ __name: "baseline-select",
3520
+ props: {
3521
+ modelValue: { default: "now" }
3522
+ },
3523
+ emits: ["update:modelValue"],
3524
+ setup(__props, { emit: __emit }) {
3525
+ const props = __props;
3526
+ const emits = __emit;
3527
+ const { format } = useDatePickerInject();
3528
+ const inputRef = ref();
3529
+ const specificInput = ref();
3530
+ const baselineSelectRef = ref();
3531
+ const inputValue = ref();
3532
+ const specificDate = ref();
3533
+ const canEditNaturalId = ref("");
3534
+ const baselineValue = customRef((track, trigger) => {
3535
+ return {
3536
+ get() {
3537
+ track();
3538
+ return props.modelValue;
3539
+ },
3540
+ set(value) {
3541
+ if (props.modelValue !== value) {
3542
+ emits("update:modelValue", value);
3543
+ trigger();
3544
+ }
3545
+ }
3546
+ };
3547
+ });
3548
+ const showSpecificPanel = ref(false);
3549
+ const baselineOptions = shallowRef([
3550
+ {
3551
+ id: "now",
3552
+ name: t("此刻")
3553
+ },
3554
+ {
3555
+ id: "now/d",
3556
+ name: t("今天")
3557
+ },
3558
+ {
3559
+ id: "now-1d/d",
3560
+ name: t("昨天")
3561
+ },
3562
+ {
3563
+ id: "now-2d/d",
3564
+ name: t("前天")
3565
+ },
3566
+ {
3567
+ id: "now-nd/d",
3568
+ name: t("N 天前"),
3569
+ suffix: t("天前"),
3570
+ type: NaturalOptionType.edit
3571
+ },
3572
+ {
3573
+ id: "date",
3574
+ name: t("具体时间"),
3575
+ type: NaturalOptionType.specific
3576
+ }
3577
+ ]);
3578
+ onMounted(() => {
3579
+ const item = baselineOptions.value.find((item2) => item2.id === props.modelValue);
3580
+ if (!item) {
3581
+ baselineOptions.value.unshift({
3582
+ id: props.modelValue,
3583
+ name: props.modelValue.includes(NowConstant) ? t("N 天前").replace("N", props.modelValue.replace("now-", "").replace("d/d", "")) : props.modelValue,
3584
+ type: NaturalOptionType.custom
3585
+ });
3586
+ }
3587
+ });
3588
+ const handleClickItem = (item) => {
3589
+ var _a;
3590
+ if (item.type === NaturalOptionType.specific) {
3591
+ canEditNaturalId.value = item.id;
3592
+ specificDate.value = void 0;
3593
+ nextTick(() => {
3594
+ var _a2, _b;
3595
+ showSpecificPanel.value = true;
3596
+ (_b = (_a2 = specificInput.value) == null ? void 0 : _a2[0]) == null ? void 0 : _b.focus();
3597
+ });
3598
+ return;
3599
+ }
3600
+ if (item.type === NaturalOptionType.edit) {
3601
+ inputValue.value = 1;
3602
+ canEditNaturalId.value = item.id;
3603
+ setTimeout(() => {
3604
+ var _a2, _b, _c;
3605
+ (_c = (_b = (_a2 = inputRef.value) == null ? void 0 : _a2[0]) == null ? void 0 : _b.focus) == null ? void 0 : _c.call(_b);
3606
+ }, 20);
3607
+ return;
3608
+ }
3609
+ baselineValue.value = item.id;
3610
+ canEditNaturalId.value = "";
3611
+ (_a = baselineSelectRef.value) == null ? void 0 : _a.hidePopover();
3612
+ specificDate.value = void 0;
3613
+ inputValue.value = 1;
3614
+ emits("update:modelValue", item.id);
3615
+ };
3616
+ const handleInputKeyPress = (e, v, item) => {
3617
+ if (!v || +v < 1) return;
3618
+ if (e.key !== "Enter" || !canEditNaturalId.value) return;
3619
+ customNaturalOptions(Math.ceil(v), item);
3620
+ };
3621
+ const customNaturalOptions = (v, item) => {
3622
+ var _a, _b;
3623
+ canEditNaturalId.value = "";
3624
+ const value = `now-${+v}d/d`;
3625
+ const date = baselineOptions.value.find((item2) => item2.id === value);
3626
+ if (date) {
3627
+ baselineValue.value = date.id;
3628
+ (_a = baselineSelectRef.value) == null ? void 0 : _a.hidePopover();
3629
+ return;
3630
+ }
3631
+ baselineOptions.value.unshift({
3632
+ id: value,
3633
+ name: item.name.replace("N", v.toString()),
3634
+ type: NaturalOptionType.custom
3635
+ });
3636
+ baselineValue.value = value;
3637
+ (_b = baselineSelectRef.value) == null ? void 0 : _b.hidePopover();
3638
+ };
3639
+ const handleInputEnter = () => {
3640
+ var _a, _b, _c, _d;
3641
+ const target = (_a = specificInput.value) == null ? void 0 : _a[0];
3642
+ const val = (_b = target == null ? void 0 : target.value) == null ? void 0 : _b.toString().trim();
3643
+ if (!val) {
3644
+ return;
3645
+ }
3646
+ let date = inputVal2Dayjs(val, format.value, specificDate == null ? void 0 : specificDate.value);
3647
+ if (date == null ? void 0 : date.isValid()) {
3648
+ canEditNaturalId.value = "";
3649
+ const formatValue = date.format(format.value);
3650
+ const item = baselineOptions.value.find((item2) => item2.id === formatValue);
3651
+ if (item) {
3652
+ baselineValue.value = item.id;
3653
+ (_c = baselineSelectRef.value) == null ? void 0 : _c.hidePopover();
3654
+ specificDate.value = void 0;
3655
+ return;
3656
+ }
3657
+ baselineOptions.value.unshift({
3658
+ id: formatValue,
3659
+ name: formatValue,
3660
+ type: NaturalOptionType.custom
3661
+ });
3662
+ baselineValue.value = formatValue;
3663
+ (_d = baselineSelectRef.value) == null ? void 0 : _d.hidePopover();
3664
+ specificDate.value = void 0;
3665
+ target.value = (date == null ? void 0 : date.format(format.value)) || "";
3666
+ }
3667
+ };
3668
+ const handleInputFocus = () => {
3669
+ showSpecificPanel.value = true;
3670
+ };
3671
+ const handleSpecificTimeChange = (date) => {
3672
+ var _a, _b, _c;
3673
+ if (!((_a = specificDate.value) == null ? void 0 : _a.isSame(date))) {
3674
+ specificDate.value = date;
3675
+ }
3676
+ showSpecificPanel.value = false;
3677
+ (_c = (_b = specificInput.value) == null ? void 0 : _b[0]) == null ? void 0 : _c.focus();
3678
+ };
3679
+ return (_ctx, _cache) => {
3680
+ return openBlock(), createElementBlock("div", _hoisted_1$3, [
3681
+ createVNode(unref(Select), {
3682
+ ref_key: "baselineSelectRef",
3683
+ ref: baselineSelectRef,
3684
+ class: "baseline-picker-select",
3685
+ clearable: false,
3686
+ filterable: "",
3687
+ "input-search": false,
3688
+ "model-value": baselineValue.value,
3689
+ "no-match-text": unref(t)("无匹配数据"),
3690
+ "popover-min-width": 130,
3691
+ "popover-options": {
3692
+ boundary: "parent",
3693
+ extCls: "__bk-date-picker-popover__ __bk-date-picker-baseline-popover__"
3694
+ },
3695
+ prefix: unref(t)("基于"),
3696
+ "search-placeholder": unref(t)("请输入")
3697
+ }, {
3698
+ default: withCtx(() => [
3699
+ (openBlock(true), createElementBlock(
3700
+ Fragment,
3701
+ null,
3702
+ renderList(baselineOptions.value, (item) => {
3703
+ return openBlock(), createBlock(unref(Select).Option, {
3704
+ id: item.id,
3705
+ key: item.id,
3706
+ name: item.name,
3707
+ style: { "overflow": "inherit" }
3708
+ }, {
3709
+ default: withCtx(() => {
3710
+ var _a;
3711
+ return [
3712
+ createElementVNode("div", {
3713
+ class: "baseline-custom-option",
3714
+ onClick: _cache[2] || (_cache[2] = withModifiers(() => {
3715
+ }, ["prevent", "stop"]))
3716
+ }, [
3717
+ canEditNaturalId.value === item.id ? (openBlock(), createElementBlock(
3718
+ Fragment,
3719
+ { key: 0 },
3720
+ [
3721
+ item.type === unref(NaturalOptionType).specific ? (openBlock(), createElementBlock("div", _hoisted_2$2, [
3722
+ _cache[3] || (_cache[3] = createElementVNode(
3723
+ "span",
3724
+ { class: "specific-date-icon" },
3725
+ [
3726
+ createElementVNode("svg", {
3727
+ class: "date-content-icon",
3728
+ height: "14",
3729
+ version: "1.1",
3730
+ viewBox: "0 0 1024 1024",
3731
+ width: "14",
3732
+ xmlns: "http://www.w3.org/2000/svg",
3733
+ "xmlns:xlink": "http://www.w3.org/1999/xlink"
3734
+ }, [
3735
+ createElementVNode("path", {
3736
+ d: "M558.933 465.067h-93.866v93.866h93.866v-93.866z m0 162.133h-93.866v93.867h93.866V627.2z m371.2-533.333h-93.866V21.333c0-12.8-8.534-21.333-21.334-21.333S793.6 8.533 793.6 21.333V89.6H234.667V21.333c0-12.8-12.8-21.333-25.6-21.333s-21.334 8.533-21.334 21.333V89.6H93.867C42.667 93.867 0 136.533 0 187.733V934.4c0 46.933 42.667 89.6 93.867 89.6h836.266c51.2 0 93.867-42.667 93.867-93.867v-742.4c0-51.2-42.667-93.866-93.867-93.866z m46.934 836.266c0 25.6-21.334 46.934-46.934 46.934H93.867c-25.6 0-46.934-21.334-46.934-46.934V371.2h930.134v558.933z m0-605.866H46.933V187.733c0-25.6 21.334-46.933 46.934-46.933h93.866v68.267c0 12.8 8.534 21.333 21.334 21.333s21.333-8.533 21.333-21.333V140.8h558.933v68.267c0 12.8 8.534 21.333 21.334 21.333S832 221.867 832 209.067V140.8h93.867c25.6 0 46.933 21.333 46.933 46.933v136.534h4.267zM789.333 627.2h-93.866v93.867h93.866V627.2z m0-162.133h-93.866v93.866h93.866v-93.866z m-230.4 324.266h-93.866V883.2h93.866v-93.867z m-234.666 0h-89.6V883.2h93.866v-93.867h-4.266z m0-324.266h-89.6v93.866h93.866v-93.866h-4.266z m0 162.133h-89.6v93.867h93.866V627.2h-4.266z",
3737
+ fill: "#C4C6CC",
3738
+ xmlns: "http://www.w3.org/2000/svg"
3739
+ })
3740
+ ])
3741
+ ],
3742
+ -1
3743
+ /* HOISTED */
3744
+ )),
3745
+ createElementVNode("input", {
3746
+ ref_for: true,
3747
+ ref_key: "specificInput",
3748
+ ref: specificInput,
3749
+ class: "specific-date-input",
3750
+ placeholder: unref(t)("具体时间"),
3751
+ spellcheck: "false",
3752
+ value: (_a = specificDate.value) == null ? void 0 : _a.format(unref(format)),
3753
+ onClick: handleInputFocus,
3754
+ onKeydown: withKeys(withModifiers(handleInputEnter, ["stop"]), ["enter"])
3755
+ }, null, 40, _hoisted_3$2),
3756
+ withDirectives(createVNode(_sfc_main$7, {
3757
+ key: "specific",
3758
+ class: "specific-date-panel",
3759
+ format: unref(format),
3760
+ "model-value": specificDate.value,
3761
+ "show-title": false,
3762
+ onClick: _cache[0] || (_cache[0] = withModifiers(() => {
3763
+ }, ["prevent", "stop"])),
3764
+ "onUpdate:modelValue": handleSpecificTimeChange
3765
+ }, null, 8, ["format", "model-value"]), [
3766
+ [vShow, showSpecificPanel.value]
3767
+ ])
3768
+ ])) : (openBlock(), createBlock(unref(Input), {
3769
+ key: 1,
3770
+ ref_for: true,
3771
+ ref_key: "inputRef",
3772
+ ref: inputRef,
3773
+ modelValue: inputValue.value,
3774
+ "onUpdate:modelValue": _cache[1] || (_cache[1] = ($event) => inputValue.value = $event),
3775
+ autofocus: "true",
3776
+ clearable: false,
3777
+ min: 1,
3778
+ placeholder: unref(t)("请输入"),
3779
+ precision: 0,
3780
+ "show-control": true,
3781
+ size: "small",
3782
+ style: { "width": "174px" },
3783
+ suffix: item.suffix,
3784
+ type: "number",
3785
+ onKeypress: (v, e) => handleInputKeyPress(e, v, item)
3786
+ }, null, 8, ["modelValue", "placeholder", "suffix", "onKeypress"]))
3787
+ ],
3788
+ 64
3789
+ /* STABLE_FRAGMENT */
3790
+ )) : (openBlock(), createElementBlock("div", {
3791
+ key: 1,
3792
+ style: { "width": "100%" },
3793
+ onClick: ($event) => handleClickItem(item)
3794
+ }, toDisplayString(item.name), 9, _hoisted_4$1))
3795
+ ])
3796
+ ];
3797
+ }),
3798
+ _: 2
3799
+ /* DYNAMIC */
3800
+ }, 1032, ["id", "name"]);
3801
+ }),
3802
+ 128
3803
+ /* KEYED_FRAGMENT */
3804
+ ))
3805
+ ]),
3806
+ _: 1
3807
+ /* STABLE */
3808
+ }, 8, ["model-value", "no-match-text", "prefix", "search-placeholder"])
3809
+ ]);
3810
+ };
2611
3811
  }
2612
- }), ft = { class: "recent-picker" }, pt = /* @__PURE__ */ X({
3812
+ });
3813
+ const _hoisted_1$2 = {
3814
+ key: 0,
3815
+ style: { "margin": "-8px 0 4px", "color": "#ea3636" }
3816
+ };
3817
+ const _sfc_main$2 = /* @__PURE__ */ defineComponent({
2613
3818
  __name: "recent-picker",
2614
3819
  props: {
2615
- type: { default: I.RECENT },
3820
+ baselineTime: {},
3821
+ type: { default: DateMode.RECENT },
2616
3822
  value: {}
2617
3823
  },
2618
3824
  emits: ["change"],
2619
- setup(l, { emit: a }) {
2620
- const i = a, e = l, n = L("m"), b = L();
2621
- ma(
2622
- () => e.value,
2623
- (c) => {
2624
- c && e.type === c.dateMode && (n.value = c.recentOrFuturedateUnit, b.value = c.recentOrFuturedateNum || void 0);
2625
- },
2626
- {
2627
- immediate: !0
3825
+ setup(__props, { expose: __expose, emit: __emit }) {
3826
+ const emits = __emit;
3827
+ const props = __props;
3828
+ const recentUnit = ref("m");
3829
+ const dateValue = ref();
3830
+ const canSubmit = computed(() => !!dateValue.value && !!recentUnit.value);
3831
+ const isValidate = ref(true);
3832
+ const recentBaselineTime = ref();
3833
+ const { validMsg, validateDateValue } = useValidate();
3834
+ watch(
3835
+ () => props.value,
3836
+ (val) => {
3837
+ if (!val) return;
3838
+ if (props.type !== val.dateMode) return;
3839
+ recentUnit.value = val.recentOrFutureDateUnit;
3840
+ dateValue.value = val.recentOrFutureDateNum || void 0;
3841
+ recentBaselineTime.value = val == null ? void 0 : val.startBaselineTime;
3842
+ },
3843
+ {
3844
+ immediate: true
2628
3845
  }
2629
3846
  );
2630
- const h = J(() => !!b.value && !!n.value), m = () => {
2631
- if (b.value) {
2632
- if (e.type === I.FUTURE) {
2633
- i("change", [C, `${I.FUTURE}${b.value}${n.value}`]);
2634
- return;
2635
- }
2636
- i("change", [`${I.RECENT}${b.value}${n.value}`, C]);
3847
+ const handleSubmit = () => {
3848
+ if (!dateValue.value || !canSubmit.value) return;
3849
+ const emitDate = props.type === DateMode.FUTURE ? [NowConstant, `${DateMode.FUTURE}${dateValue.value}${recentUnit.value}`] : [`${DateMode.RECENT}${dateValue.value}${recentUnit.value}`, NowConstant].map(
3850
+ (v) => recentBaselineTime.value && recentBaselineTime.value !== NowConstant ? v.replace(NowConstant, `(${recentBaselineTime.value})`) : v
3851
+ );
3852
+ isValidate.value = !!validateDateValue(emitDate);
3853
+ if (!isValidate.value) return;
3854
+ if (props.type === DateMode.FUTURE) {
3855
+ emits("change", emitDate);
3856
+ return;
2637
3857
  }
3858
+ emits("change", emitDate);
2638
3859
  };
2639
- return (c, s) => (p(), z("div", ft, [
2640
- E(t(Za), {
2641
- min: 1,
2642
- placeholder: t(r)("请输入"),
2643
- precision: 0,
2644
- prefix: c.type === "now-" ? t(r)("最近") : t(r)("未来"),
2645
- class: "recent-input",
2646
- type: "number",
2647
- modelValue: b.value,
2648
- "onUpdate:modelValue": s[0] || (s[0] = (o) => b.value = o)
2649
- }, null, 8, ["placeholder", "prefix", "modelValue"]),
2650
- E(t(Z), {
2651
- clearable: !1,
2652
- "popover-options": { boundary: "parent" },
2653
- class: "recent-unit",
2654
- filterable: "",
2655
- modelValue: n.value,
2656
- "onUpdate:modelValue": s[1] || (s[1] = (o) => n.value = o)
2657
- }, {
2658
- default: j(() => [
2659
- (p(!0), z(
2660
- U,
2661
- null,
2662
- q(t(Xa), (o) => (p(), K(t(Z).Option, {
2663
- id: o.id,
2664
- key: o.id,
2665
- name: o.name
2666
- }, null, 8, ["id", "name"]))),
2667
- 128
2668
- /* KEYED_FRAGMENT */
2669
- ))
2670
- ]),
2671
- _: 1
2672
- /* STABLE */
2673
- }, 8, ["modelValue"]),
2674
- E(Da, {
2675
- disabled: !h.value,
2676
- onSubmit: m
2677
- }, null, 8, ["disabled"])
2678
- ]));
2679
- }
2680
- }), At = { class: "option-name" }, gt = { class: "option-country" }, xt = { class: "option-utc" }, It = { class: "option-name" }, kt = { class: "option-country" }, yt = { class: "option-utc" }, _t = /* @__PURE__ */ X({
2681
- __name: "timezone-picker",
2682
- props: {
2683
- value: {}
2684
- },
2685
- emits: ["change"],
2686
- setup(l, { emit: a }) {
2687
- const i = a, e = Q(te), n = (h) => {
2688
- const m = ie(h);
2689
- i("change", h, m);
2690
- }, b = (h, m) => {
2691
- var c, s, o, y;
2692
- return ((c = m.label) == null ? void 0 : c.toLowerCase().includes(h.toLowerCase())) || ((s = m.country) == null ? void 0 : s.toLowerCase().includes(h.toLowerCase())) || ((o = m.abbreviation) == null ? void 0 : o.toLowerCase().includes(h.toLowerCase())) || ((y = m.utc) == null ? void 0 : y.toLowerCase().includes(h.toLowerCase()));
2693
- };
2694
- return (h, m) => (p(), K(t(Z), {
2695
- clearable: !1,
2696
- "filter-option": b,
2697
- "input-search": !1,
2698
- "model-value": h.value,
2699
- "no-match-text": t(r)("无匹配数据"),
2700
- placeholder: t(r)("请输入搜索(国家,城市,简称)"),
2701
- "popover-options": { "ext-cls": "__bk-date-picker-popover__" },
2702
- "search-placeholder": t(r)("请输入搜索(国家,城市,简称)"),
2703
- onChange: n,
2704
- class: "timezone-picker",
2705
- filterable: ""
2706
- }, {
2707
- default: j(() => [
2708
- (p(!0), z(
2709
- U,
2710
- null,
2711
- q(e.value, (c) => (p(), z(
2712
- U,
2713
- null,
3860
+ __expose({
3861
+ handleSubmit
3862
+ });
3863
+ return (_ctx, _cache) => {
3864
+ return openBlock(), createElementBlock(
3865
+ Fragment,
3866
+ null,
3867
+ [
3868
+ createElementVNode(
3869
+ "div",
3870
+ {
3871
+ class: normalizeClass(["recent-picker", {
3872
+ "is-invalid": !isValidate.value
3873
+ }])
3874
+ },
2714
3875
  [
2715
- c.label.length < 1 ? (p(!0), z(
2716
- U,
2717
- { key: 0 },
2718
- q(c.options, (s) => (p(), K(t(Z).Option, Ya(s, {
2719
- id: s.label,
2720
- key: s.label,
2721
- name: s.label
2722
- }), {
2723
- default: j(() => [
2724
- v(
2725
- "div",
2726
- {
2727
- class: da({
2728
- "timezone-picker-option": !0,
2729
- "is-selected": s.label === h.value
2730
- })
2731
- },
2732
- [
2733
- v(
2734
- "span",
2735
- At,
2736
- k(t(r)("浏览器时区")) + " " + k(s.label),
2737
- 1
2738
- /* TEXT */
2739
- ),
2740
- v(
2741
- "span",
2742
- gt,
2743
- k(s.country) + ", " + k(s.abbreviation),
2744
- 1
2745
- /* TEXT */
2746
- ),
2747
- v(
2748
- "span",
2749
- xt,
2750
- k(s.utc),
2751
- 1
2752
- /* TEXT */
2753
- )
2754
- ],
2755
- 2
2756
- /* CLASS */
2757
- )
2758
- ]),
2759
- _: 2
2760
- /* DYNAMIC */
2761
- }, 1040, ["id", "name"]))),
2762
- 128
2763
- /* KEYED_FRAGMENT */
2764
- )) : (p(), z(
2765
- U,
2766
- { key: 1 },
2767
- [
2768
- c.options.length ? (p(), K(t(Z).Group, {
2769
- key: c.label,
2770
- label: c.label
2771
- }, {
2772
- default: j(() => [
2773
- (p(!0), z(
2774
- U,
2775
- null,
2776
- q(c.options, (s) => (p(), K(t(Z).Option, Ya(s, {
2777
- id: s.label,
2778
- key: s.label,
2779
- name: s.label
2780
- }), {
2781
- default: j(() => [
2782
- v(
2783
- "div",
2784
- {
2785
- class: da({
2786
- "timezone-picker-option": !0,
2787
- "is-selected": s.label === h.value
2788
- })
2789
- },
2790
- [
2791
- v(
2792
- "span",
2793
- It,
2794
- k(s.label),
2795
- 1
2796
- /* TEXT */
2797
- ),
2798
- v(
2799
- "span",
2800
- kt,
2801
- k(s.country) + ", " + k(s.abbreviation),
2802
- 1
2803
- /* TEXT */
2804
- ),
2805
- v(
2806
- "span",
2807
- yt,
2808
- k(s.utc),
2809
- 1
2810
- /* TEXT */
2811
- )
2812
- ],
2813
- 2
2814
- /* CLASS */
2815
- )
2816
- ]),
2817
- _: 2
2818
- /* DYNAMIC */
2819
- }, 1040, ["id", "name"]))),
2820
- 128
2821
- /* KEYED_FRAGMENT */
2822
- ))
2823
- ]),
2824
- _: 2
2825
- /* DYNAMIC */
2826
- }, 1032, ["label"])) : sa("v-if", !0)
2827
- ],
2828
- 64
2829
- /* STABLE_FRAGMENT */
2830
- ))
3876
+ _ctx.type === unref(DateMode).RECENT ? (openBlock(), createBlock(_sfc_main$3, {
3877
+ key: 0,
3878
+ modelValue: recentBaselineTime.value,
3879
+ "onUpdate:modelValue": _cache[0] || (_cache[0] = ($event) => recentBaselineTime.value = $event)
3880
+ }, null, 8, ["modelValue"])) : createCommentVNode("v-if", true),
3881
+ createVNode(unref(Input), {
3882
+ modelValue: dateValue.value,
3883
+ "onUpdate:modelValue": _cache[1] || (_cache[1] = ($event) => dateValue.value = $event),
3884
+ class: "recent-input",
3885
+ max: unref(MAX_NUMBER_VALUE),
3886
+ min: 1,
3887
+ placeholder: unref(t)("请输入"),
3888
+ precision: 0,
3889
+ prefix: _ctx.type === unref(DateMode).RECENT ? unref(t)("的最近") : unref(t)("未来"),
3890
+ "stop-propagation": false,
3891
+ type: "number",
3892
+ onClick: _cache[2] || (_cache[2] = ($event) => isValidate.value = true)
3893
+ }, null, 8, ["modelValue", "max", "placeholder", "prefix"]),
3894
+ createVNode(unref(Select), {
3895
+ modelValue: recentUnit.value,
3896
+ "onUpdate:modelValue": _cache[3] || (_cache[3] = ($event) => recentUnit.value = $event),
3897
+ class: "recent-unit",
3898
+ clearable: false,
3899
+ filterable: "",
3900
+ "popover-min-width": 130,
3901
+ "popover-options": { boundary: "parent" },
3902
+ onClick: _cache[4] || (_cache[4] = ($event) => isValidate.value = true)
3903
+ }, {
3904
+ default: withCtx(() => [
3905
+ (openBlock(true), createElementBlock(
3906
+ Fragment,
3907
+ null,
3908
+ renderList(unref(DateUnitList), (item) => {
3909
+ return openBlock(), createBlock(unref(Select).Option, {
3910
+ id: item.id,
3911
+ key: item.id,
3912
+ name: item.name
3913
+ }, null, 8, ["id", "name"]);
3914
+ }),
3915
+ 128
3916
+ /* KEYED_FRAGMENT */
3917
+ ))
3918
+ ]),
3919
+ _: 1
3920
+ /* STABLE */
3921
+ }, 8, ["modelValue"]),
3922
+ createVNode(_sfc_main$8, {
3923
+ disabled: !canSubmit.value,
3924
+ onSubmit: handleSubmit
3925
+ }, null, 8, ["disabled"])
2831
3926
  ],
2832
- 64
2833
- /* STABLE_FRAGMENT */
2834
- ))),
2835
- 256
2836
- /* UNKEYED_FRAGMENT */
2837
- ))
2838
- ]),
2839
- _: 1
2840
- /* STABLE */
2841
- }, 8, ["model-value", "no-match-text", "placeholder", "search-placeholder"]));
3927
+ 2
3928
+ /* CLASS */
3929
+ ),
3930
+ !isValidate.value ? (openBlock(), createElementBlock(
3931
+ "div",
3932
+ _hoisted_1$2,
3933
+ toDisplayString(unref(validMsg)),
3934
+ 1
3935
+ /* TEXT */
3936
+ )) : createCommentVNode("v-if", true)
3937
+ ],
3938
+ 64
3939
+ /* STABLE_FRAGMENT */
3940
+ );
3941
+ };
2842
3942
  }
2843
- }), wt = { class: "panel-wrapper" }, Dt = {
3943
+ });
3944
+ const _hoisted_1$1 = { class: "panel-wrapper" };
3945
+ const _hoisted_2$1 = { class: "date-list-wrapper" };
3946
+ const _hoisted_3$1 = {
2844
3947
  key: 0,
2845
- class: "common-date-list"
2846
- }, Mt = ["onClick"], zt = {
2847
- key: 1,
2848
- class: "common-wrapper"
2849
- }, Et = { class: "empty-tips" }, St = {
2850
- key: 2,
2851
3948
  class: "time-zone-panel"
2852
- }, Ct = { class: "time-zone" }, Pt = { class: "time-zone-area" }, Tt = { class: "time-zone-tag" }, Vt = { class: "time-zone-picker" }, Nt = /* @__PURE__ */ X({
3949
+ };
3950
+ const _hoisted_4 = { class: "time-zone" };
3951
+ const _hoisted_5 = {
3952
+ key: 0,
3953
+ class: "time-zone-area"
3954
+ };
3955
+ const _hoisted_6 = {
3956
+ key: 0,
3957
+ class: "time-zone-tag"
3958
+ };
3959
+ const _hoisted_7 = { class: "time-zone-picker" };
3960
+ const _sfc_main$1 = /* @__PURE__ */ defineComponent({
2853
3961
  __name: "panel-wrapper",
2854
3962
  props: {
2855
3963
  defaultDate: {},
@@ -2857,462 +3965,594 @@ const _a = (l, a = "start", i) => {
2857
3965
  timezone: {}
2858
3966
  },
2859
3967
  emits: ["change", "update:timezone"],
2860
- setup(l, { emit: a }) {
2861
- const i = l, { commonUseList: e, format: n, storeKey: b, timezoneInfo: h, version: m } = ee(), c = a, s = L(!1), o = L("common"), y = J(() => {
2862
- const x = localStorage.getItem(La(m.value));
2863
- return x ? Object.values(I).includes(x) ? x : null : I.Date;
2864
- }), S = L(i.defaultDate.dateMode || y.value), D = d.tz.guess(), N = Q(ne(b.value)), Y = J(
2865
- () => (o.value === "common" ? e.value || ka : N.value).map(
2866
- (x) => new ra(x, n.value, i.timezone)
2867
- )
2868
- ), $ = (x) => {
2869
- c("change", x);
2870
- }, H = () => {
2871
- switch (S.value) {
2872
- case I.RECENT:
2873
- case I.FUTURE:
2874
- return pt;
2875
- case I.NATURAL:
2876
- return bt;
2877
- case I.Date:
3968
+ setup(__props, { emit: __emit }) {
3969
+ const { commonUseList, format, storeKey: storeKey2, timezoneInfo, version } = useDatePickerInject();
3970
+ const props = __props;
3971
+ const emits = __emit;
3972
+ const timezoneSet = ref(false);
3973
+ const component = ref();
3974
+ const defaultTabKey = computed(() => {
3975
+ const tab = localStorage.getItem(getStoreTabKey(version.value));
3976
+ if (!tab) return DateMode.Date;
3977
+ if (Object.values(DateMode).includes(tab)) {
3978
+ return tab;
3979
+ }
3980
+ return null;
3981
+ });
3982
+ const activeDatePickTab = ref(props.defaultDate.dateMode || defaultTabKey.value);
3983
+ const browserTimezone = dayjs.tz.guess();
3984
+ const recentUseList = shallowRef(getStoreDateList(storeKey2.value));
3985
+ const commonUseDateList = computed(() => {
3986
+ var _a;
3987
+ return (_a = commonUseList.value || commonDateList) == null ? void 0 : _a.map((date) => {
3988
+ if ((date == null ? void 0 : date.id) && date.name) {
3989
+ const dateRange = new DateRange(date.id, format.value, props.timezone);
3990
+ dateRange.setUserDisplayName(date.name);
3991
+ return dateRange;
3992
+ }
3993
+ return new DateRange(date, format.value, props.timezone);
3994
+ });
3995
+ });
3996
+ const recentUseDateList = computed(() => {
3997
+ var _a;
3998
+ return (_a = recentUseList.value) == null ? void 0 : _a.map((date) => {
3999
+ return new DateRange(date, format.value, props.timezone);
4000
+ });
4001
+ });
4002
+ useKeydownEnter(() => {
4003
+ let element = document == null ? void 0 : document.activeElement;
4004
+ element == null ? void 0 : element.blur();
4005
+ nextTick(() => {
4006
+ var _a;
4007
+ (_a = component.value) == null ? void 0 : _a.handleSubmit();
4008
+ });
4009
+ });
4010
+ const handleChange = (date) => {
4011
+ emits("change", date);
4012
+ };
4013
+ const getComponent = () => {
4014
+ switch (activeDatePickTab.value) {
4015
+ case DateMode.RECENT:
4016
+ case DateMode.FUTURE:
4017
+ return _sfc_main$2;
4018
+ case DateMode.NATURAL:
4019
+ return _sfc_main$4;
4020
+ case DateMode.Date:
2878
4021
  default:
2879
- return dt;
4022
+ return _sfc_main$6;
2880
4023
  }
2881
- }, _ = () => {
2882
- s.value = !s.value;
2883
- }, A = (x, T) => {
2884
- c("update:timezone", x, T);
2885
- }, g = (x) => {
2886
- S.value = x, localStorage.setItem(La(m.value), x);
2887
- }, P = (x, T) => {
2888
- var V, aa, W, f, u, M;
2889
- return !x || !T ? !1 : ((aa = (V = x.dateValue) == null ? void 0 : V.join) == null ? void 0 : aa.call(V, "~")) === ((f = (W = T == null ? void 0 : T.dateValue) == null ? void 0 : W.join) == null ? void 0 : f.call(W, "~")) || ((u = x == null ? void 0 : x.toDisplayString) == null ? void 0 : u.call(x)) === ((M = T == null ? void 0 : T.toDisplayString) == null ? void 0 : M.call(T));
2890
- }, B = () => {
2891
- N.value = [], localStorage.removeItem(b.value);
2892
- };
2893
- return (x, T) => (p(), z("div", wt, [
2894
- E(Ua, {
2895
- panels: t(Ee),
2896
- "show-delete-all": o.value === "recent" && !!N.value.length,
2897
- onConfirm: B,
2898
- modelValue: o.value,
2899
- "onUpdate:modelValue": T[0] || (T[0] = (V) => o.value = V)
2900
- }, null, 8, ["panels", "show-delete-all", "modelValue"]),
2901
- Y.value.length ? (p(), z("ul", Dt, [
2902
- (p(!0), z(
2903
- U,
4024
+ };
4025
+ const handleToggleTimezoneSet = () => {
4026
+ timezoneSet.value = !timezoneSet.value;
4027
+ };
4028
+ const handleTimezoneChange = (v, info) => {
4029
+ emits("update:timezone", v, info);
4030
+ };
4031
+ const handleDateTabChange = (v) => {
4032
+ activeDatePickTab.value = v;
4033
+ localStorage.setItem(getStoreTabKey(version.value), v);
4034
+ };
4035
+ const handleDeleteConfirm = () => {
4036
+ recentUseList.value = [];
4037
+ localStorage.removeItem(storeKey2.value);
4038
+ };
4039
+ return (_ctx, _cache) => {
4040
+ return openBlock(), createElementBlock("div", _hoisted_1$1, [
4041
+ createVNode(DateTitle, { onConfirm: handleDeleteConfirm }),
4042
+ createElementVNode("div", _hoisted_2$1, [
4043
+ createVNode(DateList, {
4044
+ "date-list": commonUseDateList.value,
4045
+ "default-date": _ctx.defaultDate,
4046
+ "is-recent": false,
4047
+ onChange: handleChange
4048
+ }, null, 8, ["date-list", "default-date"]),
4049
+ createVNode(DateList, {
4050
+ "date-list": recentUseDateList.value,
4051
+ "default-date": _ctx.defaultDate,
4052
+ "is-recent": true,
4053
+ onChange: handleChange
4054
+ }, null, 8, ["date-list", "default-date"])
4055
+ ]),
4056
+ createVNode(_sfc_main$a, {
4057
+ class: "date-pick-tab",
4058
+ "model-value": activeDatePickTab.value,
4059
+ panels: unref(datePickTabList),
4060
+ "onUpdate:modelValue": handleDateTabChange
4061
+ }, null, 8, ["model-value", "panels"]),
4062
+ (openBlock(), createBlock(
4063
+ KeepAlive,
2904
4064
  null,
2905
- q(Y.value, (V, aa) => (p(), z("li", {
2906
- class: da({
2907
- "list-item": !0,
2908
- "is-recent-item": o.value === "recent",
2909
- "is-selected": P(V, x.defaultDate)
2910
- }),
2911
- key: aa,
2912
- onClick: (W) => $(V.dateValue)
2913
- }, k(V.toDisplayString()), 11, Mt))),
2914
- 128
2915
- /* KEYED_FRAGMENT */
2916
- ))
2917
- ])) : (p(), z("div", zt, [
2918
- E(t(Ae), {
2919
- class: "empty-content",
2920
- scene: "part",
2921
- type: "empty"
2922
- }),
2923
- v(
2924
- "div",
2925
- Et,
2926
- k(o.value === "recent" ? t(r)("暂无最近使用记录") : t(r)("暂无常用时间")),
2927
- 1
2928
- /* TEXT */
2929
- )
2930
- ])),
2931
- E(Ua, {
2932
- "model-value": S.value,
2933
- panels: t(Se),
2934
- "onUpdate:modelValue": g,
2935
- class: "date-pick-tab"
2936
- }, null, 8, ["model-value", "panels"]),
2937
- (p(), K(
2938
- me,
2939
- null,
2940
- [
2941
- (p(), K(he(H()), {
2942
- key: S.value,
2943
- type: S.value,
2944
- value: x.defaultDate,
2945
- onChange: $
2946
- }, null, 40, ["type", "value"]))
2947
- ],
2948
- 1024
2949
- /* DYNAMIC_SLOTS */
2950
- )),
2951
- x.needTimezone ? (p(), z("div", St, [
2952
- G(
2953
- k(t(h).label === t(D) ? t(r)("浏览器时区") : "") + " ",
2954
- 1
2955
- /* TEXT */
2956
- ),
2957
- v("span", Ct, [
2958
- G(
2959
- k(t(h).label) + " ",
4065
+ [
4066
+ (openBlock(), createBlock(resolveDynamicComponent(getComponent()), {
4067
+ key: activeDatePickTab.value,
4068
+ ref_key: "component",
4069
+ ref: component,
4070
+ type: activeDatePickTab.value,
4071
+ value: _ctx.defaultDate,
4072
+ onChange: handleChange
4073
+ }, null, 40, ["type", "value"]))
4074
+ ],
4075
+ 1024
4076
+ /* DYNAMIC_SLOTS */
4077
+ )),
4078
+ _ctx.needTimezone ? (openBlock(), createElementBlock("div", _hoisted_3$1, [
4079
+ createTextVNode(
4080
+ toDisplayString(unref(timezoneInfo).label === unref(browserTimezone) ? unref(t)("浏览器时区") : "") + " ",
2960
4081
  1
2961
4082
  /* TEXT */
2962
4083
  ),
2963
- v(
2964
- "span",
2965
- Pt,
2966
- k(t(h).country) + ", " + k(t(h).abbreviation),
2967
- 1
2968
- /* TEXT */
2969
- )
2970
- ]),
2971
- v(
2972
- "span",
2973
- Tt,
2974
- k(t(h).utc),
2975
- 1
2976
- /* TEXT */
2977
- ),
2978
- E(t(wa), {
2979
- onClick: _,
2980
- class: "time-zone-btn",
2981
- size: "small"
2982
- }, {
2983
- default: j(() => [
2984
- G(
2985
- k(t(r)("时区设置")),
4084
+ createElementVNode("span", _hoisted_4, [
4085
+ createTextVNode(
4086
+ toDisplayString(unref(timezoneInfo).label) + " ",
2986
4087
  1
2987
4088
  /* TEXT */
2988
- )
4089
+ ),
4090
+ unref(timezoneInfo).country ? (openBlock(), createElementBlock(
4091
+ "span",
4092
+ _hoisted_5,
4093
+ toDisplayString(unref(timezoneInfo).country) + ", " + toDisplayString(unref(timezoneInfo).abbreviation),
4094
+ 1
4095
+ /* TEXT */
4096
+ )) : createCommentVNode("v-if", true)
2989
4097
  ]),
2990
- _: 1
2991
- /* STABLE */
2992
- })
2993
- ])) : sa("v-if", !0),
2994
- fa(v(
2995
- "div",
2996
- Vt,
2997
- [
2998
- E(_t, {
2999
- value: x.timezone || t(D),
3000
- onChange: A
3001
- }, null, 8, ["value"])
3002
- ],
3003
- 512
3004
- /* NEED_PATCH */
3005
- ), [
3006
- [ve, s.value]
3007
- ])
3008
- ]));
4098
+ typeof unref(timezoneInfo).utc !== "undefined" ? (openBlock(), createElementBlock(
4099
+ "span",
4100
+ _hoisted_6,
4101
+ toDisplayString(unref(timezoneInfo).utc),
4102
+ 1
4103
+ /* TEXT */
4104
+ )) : createCommentVNode("v-if", true),
4105
+ createVNode(unref(Button), {
4106
+ class: "time-zone-btn",
4107
+ size: "small",
4108
+ onClick: handleToggleTimezoneSet
4109
+ }, {
4110
+ default: withCtx(() => [
4111
+ createTextVNode(
4112
+ toDisplayString(unref(t)("时区设置")),
4113
+ 1
4114
+ /* TEXT */
4115
+ )
4116
+ ]),
4117
+ _: 1
4118
+ /* STABLE */
4119
+ })
4120
+ ])) : createCommentVNode("v-if", true),
4121
+ withDirectives(createElementVNode(
4122
+ "div",
4123
+ _hoisted_7,
4124
+ [
4125
+ createVNode(_sfc_main$b, {
4126
+ value: _ctx.timezone || unref(browserTimezone),
4127
+ "onUpdate:value": handleTimezoneChange
4128
+ }, null, 8, ["value"])
4129
+ ],
4130
+ 512
4131
+ /* NEED_PATCH */
4132
+ ), [
4133
+ [vShow, timezoneSet.value]
4134
+ ])
4135
+ ]);
4136
+ };
3009
4137
  }
3010
- }), $t = /* @__PURE__ */ v(
3011
- "svg",
3012
- {
3013
- class: "date-content-icon",
3014
- height: "14",
3015
- version: "1.1",
3016
- viewBox: "0 0 1024 1024",
3017
- width: "14",
3018
- xmlns: "http://www.w3.org/2000/svg",
3019
- "xmlns:xlink": "http://www.w3.org/1999/xlink"
3020
- },
3021
- [
3022
- /* @__PURE__ */ v("path", {
3023
- d: "M486.656 997.312c-268.288 0-486.656-218.304-486.656-486.656 0-268.288 218.304-486.656 486.656-486.656 268.352 0 486.656 218.304 486.656 486.656C973.376 779.008 755.008 997.312 486.656 997.312zM486.656 88c-233.088 0-422.656 189.568-422.656 422.656 0 233.088 189.568 422.656 422.656 422.656s422.656-189.632 422.656-422.656C909.376 277.568 719.744 88 486.656 88z",
3024
- fill: "#979BA5"
3025
- }),
3026
- /* @__PURE__ */ v("path", {
3027
- d: "M816.064 544 432.064 544 432.064 160 496.064 160 496.064 480 816.064 480Z",
3028
- fill: "#979BA5"
3029
- })
3030
- ],
3031
- -1
3032
- /* HOISTED */
3033
- ), jt = {
4138
+ });
4139
+ const _hoisted_1 = {
3034
4140
  key: 0,
3035
4141
  class: "date-content-utc"
3036
- }, Yt = { class: "date-tooltips-timezone" }, Bt = {
4142
+ };
4143
+ const _hoisted_2 = { class: "date-tooltips-timezone" };
4144
+ const _hoisted_3 = {
3037
4145
  key: 0,
3038
4146
  class: "date-tooltips-diff"
3039
- }, ei = /* @__PURE__ */ X({
3040
- name: "DatePicker",
4147
+ };
4148
+ const _sfc_main = /* @__PURE__ */ defineComponent({
4149
+ ...{
4150
+ name: "DatePicker"
4151
+ },
3041
4152
  __name: "date-picker",
3042
4153
  props: {
3043
4154
  behavior: { default: "normal" },
3044
- commonUseList: { default: () => ka },
3045
4155
  disabled: { type: Boolean },
4156
+ enableFormatClick: { type: Boolean, default: true },
3046
4157
  format: { default: "YYYY-MM-DD HH:mm:ss" },
4158
+ id: { default: "key" },
4159
+ maxDuration: {},
4160
+ minDuration: {},
3047
4161
  modelValue: {},
3048
- needTimezone: { type: Boolean, default: !0 },
4162
+ needTimezone: { type: Boolean, default: true },
3049
4163
  timezone: {},
3050
- version: { default: "1.0" }
4164
+ validDateRange: {},
4165
+ version: { default: "1.0" },
4166
+ commonUseList: { default: () => commonDateList }
3051
4167
  },
3052
- emits: ["update:modelValue", "update:timezone"],
3053
- setup(l, { expose: a, emit: i }) {
3054
- d.locale({
3055
- ...pa === "en" ? _e : we,
4168
+ emits: ["update:modelValue", "update:timezone", "update:format"],
4169
+ setup(__props, { expose: __expose, emit: __emit }) {
4170
+ dayjs.locale({
4171
+ ...lang === "en" ? en : cn,
3056
4172
  weekStart: 1
3057
- }), ge({
4173
+ });
4174
+ provideGlobalConfig({
3058
4175
  prefix: "bk"
3059
4176
  });
3060
- const e = l, n = i, b = L(), h = L(), m = J(() => e.format), c = J(() => ie(e.timezone || d.tz.guess())), s = J(() => {
3061
- const f = e.timezone;
3062
- if (!f || e.timezone === d.tz.guess())
3063
- return 0;
3064
- const u = d().utcOffset();
3065
- return (d.tz(d(), f).utcOffset() - u) / 60;
3066
- }), o = Q(new ra(e.modelValue, e.format, e.timezone)), y = Q(), S = J(() => Ia(e.version)), D = L(!1), N = L(!1);
3067
- ma(
3068
- () => e.modelValue,
3069
- (f) => {
3070
- var u, M;
3071
- (M = (u = o.value) == null ? void 0 : u.dateValue) != null && M.length && o.value.dateValue.every((w, R) => w === (f == null ? void 0 : f[R])) || (o.value = new ra(f, m.value, e.timezone));
3072
- },
3073
- {
3074
- immediate: !0
4177
+ const props = __props;
4178
+ const emits = __emit;
4179
+ const dateTooltipsRef = ref();
4180
+ const dateContentRef = ref();
4181
+ const format = ref(props.format);
4182
+ const timezoneInfo = computed(() => {
4183
+ let timezone = props.timezone || dayjs.tz.guess();
4184
+ if (!isValidTimeZone(timezone)) {
4185
+ console.error(`invalid timezone: ${props.timezone} datepicker will use ${DEFAULT_TIMEZONE} as default`);
4186
+ timezone = DEFAULT_TIMEZONE;
4187
+ }
4188
+ return getTimezoneInfoByValue(timezone) || { label: props.timezone, value: props.timezone };
4189
+ });
4190
+ const diffTimezone = computed(() => {
4191
+ const timezone = timezoneInfo.value.label;
4192
+ if (!timezone || props.timezone === dayjs.tz.guess()) return 0;
4193
+ const a = dayjs().utcOffset();
4194
+ const b = dayjs.tz(dayjs(), timezone).utcOffset();
4195
+ return (b - a) / 60;
4196
+ });
4197
+ const dateDetail = shallowRef(new DateRange(props.modelValue, props.format));
4198
+ const tooltipsDetail = shallowRef();
4199
+ const storeKey2 = computed(() => getStoreKey(props.version));
4200
+ const datePanelShow = ref(false);
4201
+ const tooltipsShow = ref(false);
4202
+ let enterTimer;
4203
+ let leaveTimer;
4204
+ const commonDateUseList = computed(() => {
4205
+ var _a;
4206
+ return ((_a = props.commonUseList) == null ? void 0 : _a.length) ? props.commonUseList : commonDateList;
4207
+ });
4208
+ const dateDetailDisplayString = computed(() => {
4209
+ var _a;
4210
+ const commonDate = commonDateUseList.value.find((item) => {
4211
+ var _a2, _b, _c, _d;
4212
+ return Array.isArray(item.id) && ((_b = (_a2 = item.id).join) == null ? void 0 : _b.call(_a2, "_")) === ((_d = (_c = dateDetail.value) == null ? void 0 : _c.dateValue) == null ? void 0 : _d.join("_"));
4213
+ });
4214
+ if (commonDate) {
4215
+ return commonDate.name;
4216
+ }
4217
+ return (_a = dateDetail.value) == null ? void 0 : _a.toDisplayString();
4218
+ });
4219
+ watch(
4220
+ () => props.format,
4221
+ () => {
4222
+ format.value = props.format;
4223
+ }
4224
+ );
4225
+ watch(
4226
+ () => props.modelValue,
4227
+ (v) => {
4228
+ var _a, _b;
4229
+ if (((_b = (_a = dateDetail.value) == null ? void 0 : _a.dateValue) == null ? void 0 : _b.length) && dateDetail.value.dateValue.every((item, index) => item === (v == null ? void 0 : v[index])))
4230
+ return;
4231
+ dateDetail.value = new DateRange(v, format.value, timezoneInfo.value.label);
4232
+ },
4233
+ {
4234
+ immediate: true
3075
4235
  }
3076
4236
  );
3077
- const Y = J(() => {
3078
- var f;
3079
- return (f = e.commonUseList) != null && f.length ? e.commonUseList : ka;
4237
+ const formatChange = (f) => {
4238
+ if (props.enableFormatClick) {
4239
+ emits("update:format", f);
4240
+ format.value = f;
4241
+ }
4242
+ };
4243
+ useDatePickerProvider({
4244
+ formatChange,
4245
+ commonUseList: commonDateUseList,
4246
+ format,
4247
+ storeKey: storeKey2,
4248
+ t,
4249
+ timezoneInfo,
4250
+ enableFormatClick: props.enableFormatClick,
4251
+ version: computed(() => props.version),
4252
+ validateTimeRange: computed(() => props.validDateRange),
4253
+ minDuration: computed(() => props.minDuration),
4254
+ maxDuration: computed(() => props.maxDuration)
3080
4255
  });
3081
- je({
3082
- commonUseList: Y,
3083
- format: m,
3084
- storeKey: S,
3085
- t: r,
3086
- timezoneInfo: c,
3087
- version: J(() => e.version)
3088
- }), be(() => {
3089
- N.value = !1, D.value = !1;
4256
+ onBeforeUnmount(() => {
4257
+ tooltipsShow.value = false;
4258
+ datePanelShow.value = false;
3090
4259
  });
3091
- let $, H;
3092
- function _() {
3093
- $ || ($ = setTimeout(() => {
3094
- N.value = !0, y.value = new ra(o.value.dateValue, m.value, e.timezone), $ = null;
3095
- }, 100));
4260
+ function handleDateMouseenter() {
4261
+ if (enterTimer) return;
4262
+ enterTimer = setTimeout(() => {
4263
+ tooltipsShow.value = true;
4264
+ tooltipsDetail.value = new DateRange(dateDetail.value.dateValue, format.value, timezoneInfo.value.label);
4265
+ enterTimer = null;
4266
+ }, 100);
3096
4267
  }
3097
- function A() {
3098
- H && clearTimeout(H), H = setTimeout(() => {
3099
- N.value = !1, H = null;
4268
+ function handleDateMouseleave() {
4269
+ if (leaveTimer) clearTimeout(leaveTimer);
4270
+ leaveTimer = setTimeout(() => {
4271
+ tooltipsShow.value = false;
4272
+ leaveTimer = null;
3100
4273
  }, 301);
3101
4274
  }
3102
- const g = (f) => {
3103
- D.value = !1;
3104
- const [u, M] = f, [w, R] = e.modelValue || [];
3105
- if (u && M && u === w && M === R)
3106
- return;
3107
- o.value = new ra(f, m.value, e.timezone);
3108
- const ea = o.value.toEmitValue();
3109
- n("update:modelValue", ...ea), !Y.value.some((ha) => ha[0] === u && ha[1] === M) && o.value.isValidate && re(f, S.value);
3110
- }, P = (f, u) => {
3111
- o.value = new ra(e.modelValue, m.value, f), n("update:timezone", f, { ...u }), sessionStorage.setItem(Te, f);
3112
- }, B = () => {
3113
- D.value = !1;
3114
- }, x = (f) => {
3115
- var ea;
3116
- if (((ea = o.value.dateValue) == null ? void 0 : ea.length) < 2)
3117
- return;
3118
- const { endDate: u, startDate: M } = o.value, w = o.value.dateDuration(), R = f === "left" ? [M.subtract(w), u.subtract(w)] : [M.add(w), u.add(w)];
3119
- g(R);
3120
- }, T = () => {
3121
- x("left");
3122
- }, V = () => {
3123
- x("right");
3124
- }, aa = (f) => {
3125
- D.value && (Array.from(document.querySelectorAll(".__bk-date-picker-popover__")).some(
3126
- (u) => u.contains(f.target)
3127
- ) || B());
3128
- }, W = () => {
3129
- D.value = !D.value, D.value && (N.value = !1);
3130
- };
3131
- return a({
4275
+ const handleChange = (val) => {
4276
+ datePanelShow.value = false;
4277
+ const [start, end] = val;
4278
+ const [oldStart, oldEnd] = props.modelValue || [];
4279
+ if (start && end && start === oldStart && end === oldEnd) return;
4280
+ dateDetail.value = new DateRange(val, format.value, timezoneInfo.value.label);
4281
+ const emitValue = dateDetail.value.toEmitValue();
4282
+ emits("update:modelValue", ...emitValue, [...val]);
4283
+ const canStore = commonDateUseList.value.some((item) => {
4284
+ const startDate = Array.isArray(item == null ? void 0 : item.id) ? item.id[0] : item[0];
4285
+ const endDate = Array.isArray(item == null ? void 0 : item.id) ? item.id[1] : item[1];
4286
+ return startDate === start && endDate === end;
4287
+ });
4288
+ if (canStore && dateDetail.value.isValidate) {
4289
+ setStoreDateList(val, storeKey2.value);
4290
+ }
4291
+ };
4292
+ const handleTimezoneChange = (val, info) => {
4293
+ dateDetail.value = new DateRange(props.modelValue, format.value, val);
4294
+ emits("update:timezone", val, { ...info });
4295
+ sessionStorage.setItem(timezoneStoreKey, val);
4296
+ };
4297
+ const handleHidden = () => {
4298
+ datePanelShow.value = false;
4299
+ };
4300
+ const diffDateDuration = (type) => {
4301
+ var _a, _b;
4302
+ if (((_a = dateDetail.value.dateValue) == null ? void 0 : _a.length) < 2) return;
4303
+ const { endDate, startDate } = dateDetail.value;
4304
+ const durations = dateDetail.value.dateDuration();
4305
+ const val = type === "left" ? [startDate.subtract(durations), endDate.subtract(durations)] : [startDate.add(durations), endDate.add(durations)];
4306
+ if ((_b = props.validDateRange) == null ? void 0 : _b.length) {
4307
+ const validDateRange = new DateRange(props.validDateRange, props.format);
4308
+ if (!validDateRange.isInValidDateRange(new DateRange(val, props.format))) return;
4309
+ }
4310
+ handleChange(val);
4311
+ };
4312
+ const handleClickLeft = () => {
4313
+ diffDateDuration("left");
4314
+ };
4315
+ const handleClickRight = () => {
4316
+ diffDateDuration("right");
4317
+ };
4318
+ const handleClickoutside = (e) => {
4319
+ if (!datePanelShow.value) return;
4320
+ if (!Array.from(document.querySelectorAll(".__bk-date-picker-popover__")).some(
4321
+ (item) => item.contains(e.target)
4322
+ )) {
4323
+ handleHidden();
4324
+ }
4325
+ };
4326
+ const handleClickDate = () => {
4327
+ datePanelShow.value = !datePanelShow.value;
4328
+ if (datePanelShow.value) {
4329
+ tooltipsShow.value = false;
4330
+ }
4331
+ };
4332
+ __expose({
3132
4333
  handleHidePanel: () => {
3133
- D.value = !1;
4334
+ datePanelShow.value = false;
3134
4335
  },
3135
4336
  handleShowPanel: () => {
3136
- D.value = !0;
4337
+ datePanelShow.value = true;
3137
4338
  }
3138
- }), (f, u) => (p(), z(
3139
- "div",
3140
- {
3141
- class: da({
3142
- __bk_date_picker__: !0,
3143
- "is-simplicity": f.behavior === "simplicity",
3144
- "is-disabled": f.disabled
3145
- })
3146
- },
3147
- [
3148
- v("span", {
3149
- onClick: T,
3150
- class: "date-icon"
3151
- }, [
3152
- E(t(Wa), { class: "date-icon-left" })
3153
- ]),
3154
- E(t(ca), {
3155
- arrow: !1,
3156
- "is-show": D.value,
3157
- offset: { mainAxis: 10, crossAxis: 10, alignmentAxis: -32 },
3158
- onAfterHidden: B,
3159
- "ext-cls": "bk-date-picker-popover __bk-date-picker-popover__",
3160
- placement: "bottom-start",
3161
- theme: "light",
3162
- trigger: "manual"
3163
- }, {
3164
- content: j(() => [
3165
- E(Nt, {
3166
- "default-date": o.value,
3167
- "need-timezone": f.needTimezone,
3168
- timezone: f.timezone,
3169
- onChange: g,
3170
- "onUpdate:timezone": P
3171
- }, null, 8, ["default-date", "need-timezone", "timezone"])
4339
+ });
4340
+ return (_ctx, _cache) => {
4341
+ return openBlock(), createElementBlock(
4342
+ "div",
4343
+ {
4344
+ class: normalizeClass({
4345
+ __bk_date_picker__: true,
4346
+ "is-simplicity": _ctx.behavior === "simplicity",
4347
+ "is-disabled": _ctx.disabled
4348
+ })
4349
+ },
4350
+ [
4351
+ createElementVNode("span", {
4352
+ class: "date-icon",
4353
+ onClick: handleClickLeft
4354
+ }, [
4355
+ createVNode(unref(AngleLeft), { class: "date-icon-left" })
3172
4356
  ]),
3173
- default: j(() => {
3174
- var M;
3175
- return [
3176
- fa((p(), z(
3177
- "span",
3178
- {
3179
- popoverDelay: [100, 10],
3180
- onClick: W,
3181
- onMouseenter: _,
3182
- onMouseleave: A,
3183
- class: "date-content",
3184
- ref_key: "dateContentRef",
3185
- ref: h
3186
- },
3187
- [
3188
- $t,
3189
- v(
3190
- "span",
3191
- null,
3192
- k(o.value.toDisplayString()),
3193
- 1
3194
- /* TEXT */
3195
- ),
3196
- f.needTimezone && c.value.label !== t(d).tz.guess() ? (p(), z(
3197
- "span",
3198
- jt,
3199
- k(c.value.abbreviation || ((M = c.value.utc) == null ? void 0 : M.replace("UTC", "").replace(":00", ""))),
3200
- 1
3201
- /* TEXT */
3202
- )) : sa("v-if", !0)
3203
- ],
3204
- 32
3205
- /* NEED_HYDRATION */
3206
- )), [
3207
- [t(Aa), aa]
3208
- ])
3209
- ];
3210
- }),
3211
- _: 1
3212
- /* STABLE */
3213
- }, 8, ["is-show"]),
3214
- v("span", {
3215
- onClick: V,
3216
- class: "date-icon"
3217
- }, [
3218
- E(t(Qa), { class: "date-icon-right" })
3219
- ]),
3220
- E(t(ca), {
3221
- "is-show": N.value,
3222
- offset: 12,
3223
- target: h.value,
3224
- placement: "top",
3225
- trigger: "manual"
3226
- }, {
3227
- content: j(() => {
3228
- var M, w;
3229
- return [
3230
- v(
3231
- "div",
3232
- {
3233
- style: Ja({ maxWidth: t(pa) === "en" ? "210px" : "156px" }),
3234
- class: "__date-tooltips__",
3235
- ref_key: "dateTooltipsRef",
3236
- ref: b
3237
- },
3238
- [
3239
- v(
3240
- "div",
3241
- null,
3242
- k((M = y.value) == null ? void 0 : M.startDisplayText),
3243
- 1
3244
- /* TEXT */
3245
- ),
3246
- G(" to "),
3247
- v(
3248
- "div",
3249
- null,
3250
- k((w = y.value) == null ? void 0 : w.endDisplayText),
3251
- 1
3252
- /* TEXT */
3253
- ),
3254
- v(
3255
- "div",
3256
- Yt,
3257
- k(c.value.label === t(d).tz.guess() ? `${t(r)("浏览器时区")} (${c.value.label})` : c.value.label),
3258
- 1
3259
- /* TEXT */
3260
- ),
3261
- s.value ? (p(), z(
3262
- "div",
3263
- Bt,
3264
- k(t(r)(s.value < 0 ? "时差:晚 $n 小时" : "时差:早 $n 小时").replace(
3265
- "$n",
3266
- Math.abs(s.value).toString()
4357
+ createVNode(unref(Popover), {
4358
+ arrow: false,
4359
+ "ext-cls": `bk-date-picker-popover __bk-date-picker-popover__ __bk-date-picker-popover__${_ctx.id}`,
4360
+ "is-show": datePanelShow.value,
4361
+ offset: { mainAxis: 10, crossAxis: 10, alignmentAxis: -32 },
4362
+ placement: "bottom-start",
4363
+ theme: "light",
4364
+ trigger: "manual",
4365
+ onAfterHidden: handleHidden
4366
+ }, {
4367
+ content: withCtx(() => [
4368
+ createVNode(_sfc_main$1, {
4369
+ "default-date": dateDetail.value,
4370
+ "max-duration": _ctx.maxDuration,
4371
+ "min-duration": _ctx.minDuration,
4372
+ "need-timezone": _ctx.needTimezone,
4373
+ timezone: timezoneInfo.value.label,
4374
+ onChange: handleChange,
4375
+ "onUpdate:timezone": handleTimezoneChange
4376
+ }, null, 8, ["default-date", "max-duration", "min-duration", "need-timezone", "timezone"])
4377
+ ]),
4378
+ default: withCtx(() => {
4379
+ var _a, _b, _c, _d;
4380
+ return [
4381
+ withDirectives((openBlock(), createElementBlock(
4382
+ "span",
4383
+ {
4384
+ ref_key: "dateContentRef",
4385
+ ref: dateContentRef,
4386
+ class: "date-content",
4387
+ popoverDelay: [100, 10],
4388
+ onClick: handleClickDate,
4389
+ onMouseenter: handleDateMouseenter,
4390
+ onMouseleave: handleDateMouseleave
4391
+ },
4392
+ [
4393
+ _cache[0] || (_cache[0] = createElementVNode(
4394
+ "svg",
4395
+ {
4396
+ class: "date-content-icon",
4397
+ height: "14",
4398
+ version: "1.1",
4399
+ viewBox: "0 0 1024 1024",
4400
+ width: "14",
4401
+ xmlns: "http://www.w3.org/2000/svg",
4402
+ "xmlns:xlink": "http://www.w3.org/1999/xlink"
4403
+ },
4404
+ [
4405
+ createElementVNode("path", {
4406
+ d: "M486.656 997.312c-268.288 0-486.656-218.304-486.656-486.656 0-268.288 218.304-486.656 486.656-486.656 268.352 0 486.656 218.304 486.656 486.656C973.376 779.008 755.008 997.312 486.656 997.312zM486.656 88c-233.088 0-422.656 189.568-422.656 422.656 0 233.088 189.568 422.656 422.656 422.656s422.656-189.632 422.656-422.656C909.376 277.568 719.744 88 486.656 88z",
4407
+ fill: "#979BA5"
4408
+ }),
4409
+ createElementVNode("path", {
4410
+ d: "M816.064 544 432.064 544 432.064 160 496.064 160 496.064 480 816.064 480Z",
4411
+ fill: "#979BA5"
4412
+ })
4413
+ ],
4414
+ -1
4415
+ /* HOISTED */
3267
4416
  )),
3268
- 1
3269
- /* TEXT */
3270
- )) : sa("v-if", !0)
3271
- ],
3272
- 4
3273
- /* STYLE */
3274
- )
3275
- ];
3276
- }),
3277
- _: 1
3278
- /* STABLE */
3279
- }, 8, ["is-show", "target"])
3280
- ],
3281
- 2
3282
- /* CLASS */
3283
- ));
4417
+ createElementVNode(
4418
+ "span",
4419
+ null,
4420
+ toDisplayString(dateDetailDisplayString.value),
4421
+ 1
4422
+ /* TEXT */
4423
+ ),
4424
+ _ctx.needTimezone && ((_a = timezoneInfo.value) == null ? void 0 : _a.label) !== unref(dayjs).tz.guess() ? (openBlock(), createElementBlock(
4425
+ "span",
4426
+ _hoisted_1,
4427
+ toDisplayString(((_b = timezoneInfo.value) == null ? void 0 : _b.abbreviation) || ((_d = (_c = timezoneInfo.value) == null ? void 0 : _c.utc) == null ? void 0 : _d.replace("UTC", "").replace(":00", ""))),
4428
+ 1
4429
+ /* TEXT */
4430
+ )) : createCommentVNode("v-if", true)
4431
+ ],
4432
+ 32
4433
+ /* NEED_HYDRATION */
4434
+ )), [
4435
+ [unref(clickoutside), handleClickoutside]
4436
+ ])
4437
+ ];
4438
+ }),
4439
+ _: 1
4440
+ /* STABLE */
4441
+ }, 8, ["ext-cls", "is-show"]),
4442
+ createElementVNode("span", {
4443
+ class: "date-icon",
4444
+ onClick: handleClickRight
4445
+ }, [
4446
+ createVNode(unref(AngleRight), { class: "date-icon-right" })
4447
+ ]),
4448
+ createVNode(unref(Popover), {
4449
+ "is-show": tooltipsShow.value,
4450
+ offset: 12,
4451
+ placement: "top",
4452
+ target: dateContentRef.value,
4453
+ trigger: "manual"
4454
+ }, {
4455
+ content: withCtx(() => {
4456
+ var _a, _b, _c, _d, _e;
4457
+ return [
4458
+ createElementVNode(
4459
+ "div",
4460
+ {
4461
+ ref_key: "dateTooltipsRef",
4462
+ ref: dateTooltipsRef,
4463
+ class: "__date-tooltips__",
4464
+ style: normalizeStyle({ maxWidth: unref(lang) === "en" ? "210px" : "156px" })
4465
+ },
4466
+ [
4467
+ createElementVNode(
4468
+ "div",
4469
+ null,
4470
+ toDisplayString((_a = tooltipsDetail.value) == null ? void 0 : _a.startDisplayText),
4471
+ 1
4472
+ /* TEXT */
4473
+ ),
4474
+ _cache[1] || (_cache[1] = createTextVNode(" to ")),
4475
+ createElementVNode(
4476
+ "div",
4477
+ null,
4478
+ toDisplayString((_b = tooltipsDetail.value) == null ? void 0 : _b.endDisplayText),
4479
+ 1
4480
+ /* TEXT */
4481
+ ),
4482
+ createElementVNode(
4483
+ "div",
4484
+ _hoisted_2,
4485
+ toDisplayString(((_c = timezoneInfo.value) == null ? void 0 : _c.label) === unref(dayjs).tz.guess() ? `${unref(t)("浏览器时区")} (${(_d = timezoneInfo.value) == null ? void 0 : _d.label})` : (_e = timezoneInfo.value) == null ? void 0 : _e.label),
4486
+ 1
4487
+ /* TEXT */
4488
+ ),
4489
+ diffTimezone.value ? (openBlock(), createElementBlock(
4490
+ "div",
4491
+ _hoisted_3,
4492
+ toDisplayString(unref(t)(diffTimezone.value < 0 ? "时差:晚 $n 小时" : "时差:早 $n 小时").replace(
4493
+ "$n",
4494
+ Math.abs(diffTimezone.value).toString()
4495
+ )),
4496
+ 1
4497
+ /* TEXT */
4498
+ )) : createCommentVNode("v-if", true)
4499
+ ],
4500
+ 4
4501
+ /* STYLE */
4502
+ )
4503
+ ];
4504
+ }),
4505
+ _: 1
4506
+ /* STABLE */
4507
+ }, 8, ["is-show", "target"])
4508
+ ],
4509
+ 2
4510
+ /* CLASS */
4511
+ );
4512
+ };
3284
4513
  }
3285
4514
  });
3286
- d.extend(Oa);
3287
- d.extend(ue);
3288
- d.extend(qa);
3289
- d.extend(Fa);
4515
+ dayjs.extend(customParseFormat);
4516
+ dayjs.extend(localizedFormat);
4517
+ dayjs.extend(tz);
4518
+ dayjs.extend(utc);
3290
4519
  export {
3291
- xa as CommonNaturalOptions,
3292
- Xt as DATE_REGEX_FORMAT,
3293
- $e as DATE_REGEX_PARSE,
3294
- ei as DatePicker,
3295
- ra as DateRange,
3296
- Xa as DateUnitList,
3297
- ia as NaturalOptionType,
3298
- ba as NaturalUnit,
3299
- C as NowConstant,
3300
- ka as commonDateList,
3301
- oa as commonDateRegexp,
3302
- Ve as dateFormatList,
3303
- Se as datePickTabList,
3304
- ua as dateUnit,
3305
- ni as dayjs,
3306
- ei as default,
3307
- Ue as futureDateRegexp,
3308
- Ia as getStoreKey,
3309
- La as getStoreTabKey,
3310
- ya as naturalDateRegexp,
3311
- Ne as naturalDateShortcutMap,
3312
- Ra as naturalUnitOptions,
3313
- Ee as panels,
3314
- Le as recentDateRegexp,
3315
- Te as timezoneStoreKey,
3316
- ai as transformDateRange2Dayjs,
3317
- _a as transformValue2Dayjs
4520
+ CommonNaturalOptions,
4521
+ DATE_REGEX_FORMAT,
4522
+ DATE_REGEX_PARSE,
4523
+ DEFAULT_TIMEZONE,
4524
+ _sfc_main as DatePicker,
4525
+ DateRange,
4526
+ DateUnitList,
4527
+ MAX_NUMBER_VALUE,
4528
+ NaturalOptionType,
4529
+ NaturalUnit,
4530
+ NowConstant,
4531
+ _sfc_main$b as TimezonePicker,
4532
+ baselineDateRegexp,
4533
+ commonDateList,
4534
+ commonDateRegexp,
4535
+ dateFormatList,
4536
+ datePickTabList,
4537
+ dateUnit,
4538
+ default2 as dayjs,
4539
+ _sfc_main as default,
4540
+ futureDateRegexp,
4541
+ getStoreKey,
4542
+ getStoreTabKey,
4543
+ getTimezoneDetails,
4544
+ getTimezoneInfo,
4545
+ getTimezoneInfoByValue,
4546
+ getTimezoneOffset,
4547
+ inputVal2Dayjs,
4548
+ isValidTimeZone,
4549
+ naturalDateRegexp,
4550
+ naturalDateShortcutMap,
4551
+ naturalUnitOptions,
4552
+ panels,
4553
+ recentDateRegexp,
4554
+ timezoneDetails,
4555
+ timezoneStoreKey,
4556
+ transformDateRange2Dayjs,
4557
+ transformValue2Dayjs
3318
4558
  };