@blueking/date-picker 3.0.3 → 3.0.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,9 +1,17 @@
1
1
  {
2
2
  "name": "@blueking/date-picker",
3
- "version": "3.0.3",
3
+ "version": "3.0.5",
4
4
  "description": "蓝鲸监控平台日期时间选择",
5
5
  "license": "MIT",
6
6
  "author": "Tencent BlueKing",
7
+ "scripts": {
8
+ "prepublishOnly": "run-p build dts",
9
+ "dev": "vite --mode development -c scripts/vite.dev.ts",
10
+ "build": "tsx ./scripts/vite.build.ts",
11
+ "dts": "vue-tsc --project tsconfig.dts.json",
12
+ "prettier": "prettier ./src ./scripts ./playground --write",
13
+ "visualize": "vite-bundle-visualizer -c scripts/vite.vusualizer.ts"
14
+ },
7
15
  "exports": {
8
16
  ".": {
9
17
  "types": "./typings/vue3.d.ts",
@@ -54,12 +62,5 @@
54
62
  "bkui-vue": "^2.0.1",
55
63
  "dayjs": "^1.11.10",
56
64
  "vue": "^3"
57
- },
58
- "scripts": {
59
- "dev": "vite --mode development -c scripts/vite.dev.ts",
60
- "build": "tsx ./scripts/vite.build.ts",
61
- "dts": "vue-tsc --project tsconfig.dts.json",
62
- "prettier": "prettier ./src ./scripts ./playground --write",
63
- "visualize": "vite-bundle-visualizer -c scripts/vite.vusualizer.ts"
64
65
  }
65
- }
66
+ }
@@ -24494,6 +24494,40 @@ const t = (key) => {
24494
24494
  };
24495
24495
  dayjs.extend(utc);
24496
24496
  dayjs.extend(tz);
24497
+ const getDynamicTimezoneInfo = (timezone) => {
24498
+ try {
24499
+ const now2 = dayjs().tz(timezone);
24500
+ const offsetMinutes = now2.utcOffset();
24501
+ const hours = Math.floor(Math.abs(offsetMinutes) / 60);
24502
+ const minutes = Math.abs(offsetMinutes) % 60;
24503
+ const sign = offsetMinutes >= 0 ? "+" : "-";
24504
+ const utcOffset = minutes > 0 ? `utc${sign}${String(hours).padStart(2, "0")}:${String(minutes).padStart(2, "0")}` : `utc${sign}${String(hours).padStart(2, "0")}:00`;
24505
+ const abbreviation = getTimezoneAbbreviation(timezone);
24506
+ return { abbreviation: abbreviation.toLowerCase(), utcOffset: utcOffset.toLowerCase() };
24507
+ } catch {
24508
+ return { abbreviation: "", utcOffset: "" };
24509
+ }
24510
+ };
24511
+ const getTimezoneAbbreviation = (timezone) => {
24512
+ try {
24513
+ const formatter = new Intl.DateTimeFormat("en-US", {
24514
+ timeZone: timezone,
24515
+ timeZoneName: "short"
24516
+ });
24517
+ const parts = formatter.formatToParts(/* @__PURE__ */ new Date());
24518
+ const tzPart = parts.find((part) => part.type === "timeZoneName");
24519
+ return (tzPart == null ? void 0 : tzPart.value) || "";
24520
+ } catch {
24521
+ return "";
24522
+ }
24523
+ };
24524
+ const updateSearchIndex = (searchIndex, timezone) => {
24525
+ const parts = searchIndex.split("|");
24526
+ const { abbreviation, utcOffset } = getDynamicTimezoneInfo(timezone);
24527
+ parts[1] = abbreviation;
24528
+ parts[2] = utcOffset;
24529
+ return parts.join("|");
24530
+ };
24497
24531
  const timezoneData = [
24498
24532
  {
24499
24533
  label: "Africa",
@@ -25838,9 +25872,11 @@ const getTimezoneDetails = () => {
25838
25872
  return {
25839
25873
  label: group.label,
25840
25874
  options: group.options.map((option) => {
25875
+ const dynamicSearchIndex = updateSearchIndex(option.searchIndex, option.value);
25841
25876
  const info = {
25842
25877
  ...option,
25843
- ...getTimezoneInfo(option.searchIndex)
25878
+ searchIndex: dynamicSearchIndex,
25879
+ ...getTimezoneInfo(dynamicSearchIndex)
25844
25880
  };
25845
25881
  if (option.value === browserTimeZone) {
25846
25882
  defaultTimezoneList.push({
@@ -26487,7 +26523,7 @@ class DateRange {
26487
26523
  if (typeof value === "number" || dayjs.isDayjs(value) || date.isValid())
26488
26524
  return dayjs.tz(date.valueOf(), this.timezone);
26489
26525
  const [, baselineTimeStr, num, unit, diffUnit] = value.match(baselineDateRegexp) || [];
26490
- const baselineTime = baselineTimeStr.replace(/[()]/g, "");
26526
+ const baselineTime = baselineTimeStr == null ? void 0 : baselineTimeStr.replace(/[()]/g, "");
26491
26527
  let baselineDayjs = dayjs();
26492
26528
  if (baselineTime && baselineTime !== NowConstant) {
26493
26529
  baselineDayjs = dayjs(baselineTime);
@@ -32065,6 +32065,40 @@ ${$(r2)}`), n2;
32065
32065
  };
32066
32066
  dayjs.extend(utc);
32067
32067
  dayjs.extend(tz);
32068
+ const getDynamicTimezoneInfo = (timezone2) => {
32069
+ try {
32070
+ const now2 = dayjs().tz(timezone2);
32071
+ const offsetMinutes = now2.utcOffset();
32072
+ const hours = Math.floor(Math.abs(offsetMinutes) / 60);
32073
+ const minutes = Math.abs(offsetMinutes) % 60;
32074
+ const sign = offsetMinutes >= 0 ? "+" : "-";
32075
+ const utcOffset = minutes > 0 ? `utc${sign}${String(hours).padStart(2, "0")}:${String(minutes).padStart(2, "0")}` : `utc${sign}${String(hours).padStart(2, "0")}:00`;
32076
+ const abbreviation = getTimezoneAbbreviation(timezone2);
32077
+ return { abbreviation: abbreviation.toLowerCase(), utcOffset: utcOffset.toLowerCase() };
32078
+ } catch {
32079
+ return { abbreviation: "", utcOffset: "" };
32080
+ }
32081
+ };
32082
+ const getTimezoneAbbreviation = (timezone2) => {
32083
+ try {
32084
+ const formatter = new Intl.DateTimeFormat("en-US", {
32085
+ timeZone: timezone2,
32086
+ timeZoneName: "short"
32087
+ });
32088
+ const parts = formatter.formatToParts(/* @__PURE__ */ new Date());
32089
+ const tzPart = parts.find((part) => part.type === "timeZoneName");
32090
+ return (tzPart == null ? void 0 : tzPart.value) || "";
32091
+ } catch {
32092
+ return "";
32093
+ }
32094
+ };
32095
+ const updateSearchIndex = (searchIndex, timezone2) => {
32096
+ const parts = searchIndex.split("|");
32097
+ const { abbreviation, utcOffset } = getDynamicTimezoneInfo(timezone2);
32098
+ parts[1] = abbreviation;
32099
+ parts[2] = utcOffset;
32100
+ return parts.join("|");
32101
+ };
32068
32102
  const timezoneData = [
32069
32103
  {
32070
32104
  label: "Africa",
@@ -33409,9 +33443,11 @@ ${$(r2)}`), n2;
33409
33443
  return {
33410
33444
  label: group.label,
33411
33445
  options: group.options.map((option) => {
33446
+ const dynamicSearchIndex = updateSearchIndex(option.searchIndex, option.value);
33412
33447
  const info = {
33413
33448
  ...option,
33414
- ...getTimezoneInfo(option.searchIndex)
33449
+ searchIndex: dynamicSearchIndex,
33450
+ ...getTimezoneInfo(dynamicSearchIndex)
33415
33451
  };
33416
33452
  if (option.value === browserTimeZone) {
33417
33453
  defaultTimezoneList.push({
@@ -34090,7 +34126,7 @@ ${$(r2)}`), n2;
34090
34126
  if (typeof value === "number" || dayjs.isDayjs(value) || date.isValid())
34091
34127
  return dayjs.tz(date.valueOf(), this.timezone);
34092
34128
  const [, baselineTimeStr, num, unit, diffUnit] = value.match(baselineDateRegexp) || [];
34093
- const baselineTime = baselineTimeStr.replace(/[()]/g, "");
34129
+ const baselineTime = baselineTimeStr == null ? void 0 : baselineTimeStr.replace(/[()]/g, "");
34094
34130
  let baselineDayjs = dayjs();
34095
34131
  if (baselineTime && baselineTime !== NowConstant) {
34096
34132
  baselineDayjs = dayjs(baselineTime);
@@ -24509,6 +24509,40 @@ ${$(r2)}`), n2;
24509
24509
  };
24510
24510
  dayjs.extend(utc);
24511
24511
  dayjs.extend(tz);
24512
+ const getDynamicTimezoneInfo = (timezone) => {
24513
+ try {
24514
+ const now2 = dayjs().tz(timezone);
24515
+ const offsetMinutes = now2.utcOffset();
24516
+ const hours = Math.floor(Math.abs(offsetMinutes) / 60);
24517
+ const minutes = Math.abs(offsetMinutes) % 60;
24518
+ const sign = offsetMinutes >= 0 ? "+" : "-";
24519
+ const utcOffset = minutes > 0 ? `utc${sign}${String(hours).padStart(2, "0")}:${String(minutes).padStart(2, "0")}` : `utc${sign}${String(hours).padStart(2, "0")}:00`;
24520
+ const abbreviation = getTimezoneAbbreviation(timezone);
24521
+ return { abbreviation: abbreviation.toLowerCase(), utcOffset: utcOffset.toLowerCase() };
24522
+ } catch {
24523
+ return { abbreviation: "", utcOffset: "" };
24524
+ }
24525
+ };
24526
+ const getTimezoneAbbreviation = (timezone) => {
24527
+ try {
24528
+ const formatter = new Intl.DateTimeFormat("en-US", {
24529
+ timeZone: timezone,
24530
+ timeZoneName: "short"
24531
+ });
24532
+ const parts = formatter.formatToParts(/* @__PURE__ */ new Date());
24533
+ const tzPart = parts.find((part) => part.type === "timeZoneName");
24534
+ return (tzPart == null ? void 0 : tzPart.value) || "";
24535
+ } catch {
24536
+ return "";
24537
+ }
24538
+ };
24539
+ const updateSearchIndex = (searchIndex, timezone) => {
24540
+ const parts = searchIndex.split("|");
24541
+ const { abbreviation, utcOffset } = getDynamicTimezoneInfo(timezone);
24542
+ parts[1] = abbreviation;
24543
+ parts[2] = utcOffset;
24544
+ return parts.join("|");
24545
+ };
24512
24546
  const timezoneData = [
24513
24547
  {
24514
24548
  label: "Africa",
@@ -25853,9 +25887,11 @@ ${$(r2)}`), n2;
25853
25887
  return {
25854
25888
  label: group.label,
25855
25889
  options: group.options.map((option) => {
25890
+ const dynamicSearchIndex = updateSearchIndex(option.searchIndex, option.value);
25856
25891
  const info = {
25857
25892
  ...option,
25858
- ...getTimezoneInfo(option.searchIndex)
25893
+ searchIndex: dynamicSearchIndex,
25894
+ ...getTimezoneInfo(dynamicSearchIndex)
25859
25895
  };
25860
25896
  if (option.value === browserTimeZone) {
25861
25897
  defaultTimezoneList.push({
@@ -26502,7 +26538,7 @@ ${$(r2)}`), n2;
26502
26538
  if (typeof value === "number" || dayjs.isDayjs(value) || date.isValid())
26503
26539
  return dayjs.tz(date.valueOf(), this.timezone);
26504
26540
  const [, baselineTimeStr, num, unit, diffUnit] = value.match(baselineDateRegexp) || [];
26505
- const baselineTime = baselineTimeStr.replace(/[()]/g, "");
26541
+ const baselineTime = baselineTimeStr == null ? void 0 : baselineTimeStr.replace(/[()]/g, "");
26506
26542
  let baselineDayjs = dayjs();
26507
26543
  if (baselineTime && baselineTime !== NowConstant) {
26508
26544
  baselineDayjs = dayjs(baselineTime);
@@ -112,6 +112,40 @@ const t = (key) => {
112
112
  };
113
113
  dayjs.extend(utc);
114
114
  dayjs.extend(tz);
115
+ const getDynamicTimezoneInfo = (timezone) => {
116
+ try {
117
+ const now = dayjs().tz(timezone);
118
+ const offsetMinutes = now.utcOffset();
119
+ const hours = Math.floor(Math.abs(offsetMinutes) / 60);
120
+ const minutes = Math.abs(offsetMinutes) % 60;
121
+ const sign = offsetMinutes >= 0 ? "+" : "-";
122
+ const utcOffset = minutes > 0 ? `utc${sign}${String(hours).padStart(2, "0")}:${String(minutes).padStart(2, "0")}` : `utc${sign}${String(hours).padStart(2, "0")}:00`;
123
+ const abbreviation = getTimezoneAbbreviation(timezone);
124
+ return { abbreviation: abbreviation.toLowerCase(), utcOffset: utcOffset.toLowerCase() };
125
+ } catch {
126
+ return { abbreviation: "", utcOffset: "" };
127
+ }
128
+ };
129
+ const getTimezoneAbbreviation = (timezone) => {
130
+ try {
131
+ const formatter = new Intl.DateTimeFormat("en-US", {
132
+ timeZone: timezone,
133
+ timeZoneName: "short"
134
+ });
135
+ const parts = formatter.formatToParts(/* @__PURE__ */ new Date());
136
+ const tzPart = parts.find((part) => part.type === "timeZoneName");
137
+ return (tzPart == null ? void 0 : tzPart.value) || "";
138
+ } catch {
139
+ return "";
140
+ }
141
+ };
142
+ const updateSearchIndex = (searchIndex, timezone) => {
143
+ const parts = searchIndex.split("|");
144
+ const { abbreviation, utcOffset } = getDynamicTimezoneInfo(timezone);
145
+ parts[1] = abbreviation;
146
+ parts[2] = utcOffset;
147
+ return parts.join("|");
148
+ };
115
149
  const timezoneData = [
116
150
  {
117
151
  label: "Africa",
@@ -1456,9 +1490,11 @@ const getTimezoneDetails = () => {
1456
1490
  return {
1457
1491
  label: group.label,
1458
1492
  options: group.options.map((option) => {
1493
+ const dynamicSearchIndex = updateSearchIndex(option.searchIndex, option.value);
1459
1494
  const info = {
1460
1495
  ...option,
1461
- ...getTimezoneInfo(option.searchIndex)
1496
+ searchIndex: dynamicSearchIndex,
1497
+ ...getTimezoneInfo(dynamicSearchIndex)
1462
1498
  };
1463
1499
  if (option.value === browserTimeZone) {
1464
1500
  defaultTimezoneList.push({
@@ -2105,7 +2141,7 @@ class DateRange {
2105
2141
  if (typeof value === "number" || dayjs.isDayjs(value) || date.isValid())
2106
2142
  return dayjs.tz(date.valueOf(), this.timezone);
2107
2143
  const [, baselineTimeStr, num, unit, diffUnit] = value.match(baselineDateRegexp) || [];
2108
- const baselineTime = baselineTimeStr.replace(/[()]/g, "");
2144
+ const baselineTime = baselineTimeStr == null ? void 0 : baselineTimeStr.replace(/[()]/g, "");
2109
2145
  let baselineDayjs = dayjs();
2110
2146
  if (baselineTime && baselineTime !== NowConstant) {
2111
2147
  baselineDayjs = dayjs(baselineTime);
@@ -25083,6 +25083,40 @@ ${$(r2)}`), n2;
25083
25083
  };
25084
25084
  dayjs.extend(utc);
25085
25085
  dayjs.extend(tz);
25086
+ const getDynamicTimezoneInfo = (timezone2) => {
25087
+ try {
25088
+ const now2 = dayjs().tz(timezone2);
25089
+ const offsetMinutes = now2.utcOffset();
25090
+ const hours = Math.floor(Math.abs(offsetMinutes) / 60);
25091
+ const minutes = Math.abs(offsetMinutes) % 60;
25092
+ const sign = offsetMinutes >= 0 ? "+" : "-";
25093
+ const utcOffset = minutes > 0 ? `utc${sign}${String(hours).padStart(2, "0")}:${String(minutes).padStart(2, "0")}` : `utc${sign}${String(hours).padStart(2, "0")}:00`;
25094
+ const abbreviation = getTimezoneAbbreviation(timezone2);
25095
+ return { abbreviation: abbreviation.toLowerCase(), utcOffset: utcOffset.toLowerCase() };
25096
+ } catch {
25097
+ return { abbreviation: "", utcOffset: "" };
25098
+ }
25099
+ };
25100
+ const getTimezoneAbbreviation = (timezone2) => {
25101
+ try {
25102
+ const formatter = new Intl.DateTimeFormat("en-US", {
25103
+ timeZone: timezone2,
25104
+ timeZoneName: "short"
25105
+ });
25106
+ const parts = formatter.formatToParts(/* @__PURE__ */ new Date());
25107
+ const tzPart = parts.find((part) => part.type === "timeZoneName");
25108
+ return (tzPart == null ? void 0 : tzPart.value) || "";
25109
+ } catch {
25110
+ return "";
25111
+ }
25112
+ };
25113
+ const updateSearchIndex = (searchIndex, timezone2) => {
25114
+ const parts = searchIndex.split("|");
25115
+ const { abbreviation, utcOffset } = getDynamicTimezoneInfo(timezone2);
25116
+ parts[1] = abbreviation;
25117
+ parts[2] = utcOffset;
25118
+ return parts.join("|");
25119
+ };
25086
25120
  const timezoneData = [
25087
25121
  {
25088
25122
  label: "Africa",
@@ -26427,9 +26461,11 @@ ${$(r2)}`), n2;
26427
26461
  return {
26428
26462
  label: group.label,
26429
26463
  options: group.options.map((option) => {
26464
+ const dynamicSearchIndex = updateSearchIndex(option.searchIndex, option.value);
26430
26465
  const info = {
26431
26466
  ...option,
26432
- ...getTimezoneInfo(option.searchIndex)
26467
+ searchIndex: dynamicSearchIndex,
26468
+ ...getTimezoneInfo(dynamicSearchIndex)
26433
26469
  };
26434
26470
  if (option.value === browserTimeZone) {
26435
26471
  defaultTimezoneList.push({
@@ -27108,7 +27144,7 @@ ${$(r2)}`), n2;
27108
27144
  if (typeof value === "number" || dayjs.isDayjs(value) || date.isValid())
27109
27145
  return dayjs.tz(date.valueOf(), this.timezone);
27110
27146
  const [, baselineTimeStr, num, unit, diffUnit] = value.match(baselineDateRegexp) || [];
27111
- const baselineTime = baselineTimeStr.replace(/[()]/g, "");
27147
+ const baselineTime = baselineTimeStr == null ? void 0 : baselineTimeStr.replace(/[()]/g, "");
27112
27148
  let baselineDayjs = dayjs();
27113
27149
  if (baselineTime && baselineTime !== NowConstant) {
27114
27150
  baselineDayjs = dayjs(baselineTime);
@@ -108,6 +108,40 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
108
108
  };
109
109
  dayjs.extend(utc);
110
110
  dayjs.extend(tz);
111
+ const getDynamicTimezoneInfo = (timezone) => {
112
+ try {
113
+ const now = dayjs().tz(timezone);
114
+ const offsetMinutes = now.utcOffset();
115
+ const hours = Math.floor(Math.abs(offsetMinutes) / 60);
116
+ const minutes = Math.abs(offsetMinutes) % 60;
117
+ const sign = offsetMinutes >= 0 ? "+" : "-";
118
+ const utcOffset = minutes > 0 ? `utc${sign}${String(hours).padStart(2, "0")}:${String(minutes).padStart(2, "0")}` : `utc${sign}${String(hours).padStart(2, "0")}:00`;
119
+ const abbreviation = getTimezoneAbbreviation(timezone);
120
+ return { abbreviation: abbreviation.toLowerCase(), utcOffset: utcOffset.toLowerCase() };
121
+ } catch {
122
+ return { abbreviation: "", utcOffset: "" };
123
+ }
124
+ };
125
+ const getTimezoneAbbreviation = (timezone) => {
126
+ try {
127
+ const formatter = new Intl.DateTimeFormat("en-US", {
128
+ timeZone: timezone,
129
+ timeZoneName: "short"
130
+ });
131
+ const parts = formatter.formatToParts(/* @__PURE__ */ new Date());
132
+ const tzPart = parts.find((part) => part.type === "timeZoneName");
133
+ return (tzPart == null ? void 0 : tzPart.value) || "";
134
+ } catch {
135
+ return "";
136
+ }
137
+ };
138
+ const updateSearchIndex = (searchIndex, timezone) => {
139
+ const parts = searchIndex.split("|");
140
+ const { abbreviation, utcOffset } = getDynamicTimezoneInfo(timezone);
141
+ parts[1] = abbreviation;
142
+ parts[2] = utcOffset;
143
+ return parts.join("|");
144
+ };
111
145
  const timezoneData = [
112
146
  {
113
147
  label: "Africa",
@@ -1452,9 +1486,11 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
1452
1486
  return {
1453
1487
  label: group.label,
1454
1488
  options: group.options.map((option) => {
1489
+ const dynamicSearchIndex = updateSearchIndex(option.searchIndex, option.value);
1455
1490
  const info = {
1456
1491
  ...option,
1457
- ...getTimezoneInfo(option.searchIndex)
1492
+ searchIndex: dynamicSearchIndex,
1493
+ ...getTimezoneInfo(dynamicSearchIndex)
1458
1494
  };
1459
1495
  if (option.value === browserTimeZone) {
1460
1496
  defaultTimezoneList.push({
@@ -2101,7 +2137,7 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
2101
2137
  if (typeof value === "number" || dayjs.isDayjs(value) || date.isValid())
2102
2138
  return dayjs.tz(date.valueOf(), this.timezone);
2103
2139
  const [, baselineTimeStr, num, unit, diffUnit] = value.match(baselineDateRegexp) || [];
2104
- const baselineTime = baselineTimeStr.replace(/[()]/g, "");
2140
+ const baselineTime = baselineTimeStr == null ? void 0 : baselineTimeStr.replace(/[()]/g, "");
2105
2141
  let baselineDayjs = dayjs();
2106
2142
  if (baselineTime && baselineTime !== NowConstant) {
2107
2143
  baselineDayjs = dayjs(baselineTime);