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

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