@pisell/materials 6.11.5 → 6.11.6

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 (137) hide show
  1. package/build/lowcode/assets-daily.json +11 -11
  2. package/build/lowcode/assets-dev.json +2 -2
  3. package/build/lowcode/assets-prod.json +11 -11
  4. package/build/lowcode/index.js +1 -1
  5. package/build/lowcode/meta.js +7 -7
  6. package/build/lowcode/preview.js +9 -9
  7. package/build/lowcode/render/default/view.css +1 -1
  8. package/build/lowcode/render/default/view.js +16 -16
  9. package/build/lowcode/view.css +1 -1
  10. package/build/lowcode/view.js +15 -15
  11. package/es/components/PisellTabbar/PisellTabbar.js +47 -44
  12. package/es/components/PisellTabbar/template/Template1/PisellTabbar.d.ts +3 -18
  13. package/es/components/PisellTabbar/template/Template1/PisellTabbar.js +124 -28
  14. package/es/components/PisellTabbar/template/Template1/constants.js +1 -1
  15. package/es/components/dataSourceComponents/dataSourceTable/hooks/useDataSourceKey.d.ts +2 -2
  16. package/es/components/dataSourceComponents/dataSourceTable/hooks/useTableProps.d.ts +2 -2
  17. package/es/components/pisellDataSourceContainer/hooks/useDataSourceKey.d.ts +2 -2
  18. package/es/components/pisellDateTimeDisplay/PisellDateTimeDisplay.js +47 -34
  19. package/es/components/pisellDateTimeDisplay/PisellDateTimeDisplay.stories.d.ts +19 -0
  20. package/es/components/pisellDateTimeDisplay/PisellDateTimeDisplay.stories.js +74 -0
  21. package/es/components/pisellDateTimeDisplay/components/DateDisplay.d.ts +6 -1
  22. package/es/components/pisellDateTimeDisplay/components/DateDisplay.js +10 -3
  23. package/es/components/pisellDateTimeDisplay/formats/dateTimeDisplayFormats.d.ts +7 -0
  24. package/es/components/pisellDateTimeDisplay/formats/dateTimeDisplayFormats.js +81 -0
  25. package/es/components/pisellDateTimeDisplay/formats/index.d.ts +1 -0
  26. package/es/components/pisellDateTimeDisplay/formats/index.js +1 -0
  27. package/es/components/pisellDateTimeDisplay/hooks/useCurrentTime.d.ts +2 -2
  28. package/es/components/pisellDateTimeDisplay/hooks/useCurrentTime.js +2 -2
  29. package/es/components/pisellDateTimeDisplay/types.d.ts +48 -2
  30. package/es/components/pisellDateTimeDisplay/utils/formatDate.js +25 -6
  31. package/es/components/pisellDateTimeDisplay/utils/formatDateOrRelative.d.ts +17 -0
  32. package/es/components/pisellDateTimeDisplay/utils/formatDateOrRelative.js +38 -0
  33. package/es/components/pisellDateTimeDisplay/utils/formatWeekday.js +11 -12
  34. package/es/components/pisellDateTimeDisplay/utils/index.d.ts +3 -1
  35. package/es/components/pisellDateTimeDisplay/utils/index.js +3 -1
  36. package/es/components/pisellDateTimeDisplay/utils/localeUtils.d.ts +2 -7
  37. package/es/components/pisellDateTimeDisplay/utils/localeUtils.js +4 -17
  38. package/es/components/pisellDateTimeDisplay/utils/relativeDay.d.ts +23 -0
  39. package/es/components/pisellDateTimeDisplay/utils/relativeDay.js +45 -0
  40. package/es/components/pisellLookup/components/LookupTrigger.js +66 -6
  41. package/es/components/pisellTimeRangeDisplay/PisellTimeRangeDisplay.d.ts +32 -0
  42. package/es/components/pisellTimeRangeDisplay/PisellTimeRangeDisplay.js +197 -0
  43. package/es/components/pisellTimeRangeDisplay/PisellTimeRangeDisplay.less +49 -0
  44. package/es/components/pisellTimeRangeDisplay/PisellTimeRangeDisplay.stories.d.ts +61 -0
  45. package/es/components/pisellTimeRangeDisplay/PisellTimeRangeDisplay.stories.js +209 -0
  46. package/es/components/pisellTimeRangeDisplay/components/DateBlock.d.ts +20 -0
  47. package/es/components/pisellTimeRangeDisplay/components/DateBlock.js +30 -0
  48. package/es/components/pisellTimeRangeDisplay/components/DurationBlock.d.ts +19 -0
  49. package/es/components/pisellTimeRangeDisplay/components/DurationBlock.js +25 -0
  50. package/es/components/pisellTimeRangeDisplay/components/TimeRangeBlock.d.ts +30 -0
  51. package/es/components/pisellTimeRangeDisplay/components/TimeRangeBlock.js +86 -0
  52. package/es/components/pisellTimeRangeDisplay/components/WeekdayBlock.d.ts +18 -0
  53. package/es/components/pisellTimeRangeDisplay/components/WeekdayBlock.js +23 -0
  54. package/es/components/pisellTimeRangeDisplay/components/index.d.ts +8 -0
  55. package/es/components/pisellTimeRangeDisplay/components/index.js +4 -0
  56. package/es/components/pisellTimeRangeDisplay/index.d.ts +3 -0
  57. package/es/components/pisellTimeRangeDisplay/index.js +1 -0
  58. package/es/components/pisellTimeRangeDisplay/types.d.ts +137 -0
  59. package/es/components/pisellTimeRangeDisplay/types.js +1 -0
  60. package/es/components/pisellTimeRangeDisplay/utils/formatDuration.d.ts +14 -0
  61. package/es/components/pisellTimeRangeDisplay/utils/formatDuration.js +53 -0
  62. package/es/components/pisellTimeRangeDisplay/utils/index.d.ts +4 -0
  63. package/es/components/pisellTimeRangeDisplay/utils/index.js +5 -0
  64. package/es/components/pisellTimeRangeDisplay/utils/parseTimeRange.d.ts +23 -0
  65. package/es/components/pisellTimeRangeDisplay/utils/parseTimeRange.js +27 -0
  66. package/es/components/table/Gallery/components/VirtualGrid/useGapSize.d.ts +2 -2
  67. package/es/components/table/Table/fields/select/filterUtil/index.d.ts +1 -1
  68. package/es/components/table/Table/fields/treeSelect/filterUtil/index.d.ts +1 -1
  69. package/es/index.d.ts +2 -0
  70. package/es/index.js +7 -0
  71. package/es/utils/index.d.ts +1 -1
  72. package/es/utils/platform.d.ts +1 -1
  73. package/lib/components/PisellTabbar/PisellTabbar.js +64 -57
  74. package/lib/components/PisellTabbar/template/Template1/PisellTabbar.d.ts +3 -18
  75. package/lib/components/PisellTabbar/template/Template1/PisellTabbar.js +171 -55
  76. package/lib/components/PisellTabbar/template/Template1/constants.js +1 -1
  77. package/lib/components/dataSourceComponents/dataSourceTable/hooks/useDataSourceKey.d.ts +2 -2
  78. package/lib/components/dataSourceComponents/dataSourceTable/hooks/useTableProps.d.ts +2 -2
  79. package/lib/components/pisellDataSourceContainer/hooks/useDataSourceKey.d.ts +2 -2
  80. package/lib/components/pisellDateTimeDisplay/PisellDateTimeDisplay.js +27 -17
  81. package/lib/components/pisellDateTimeDisplay/PisellDateTimeDisplay.stories.d.ts +19 -0
  82. package/lib/components/pisellDateTimeDisplay/PisellDateTimeDisplay.stories.js +63 -0
  83. package/lib/components/pisellDateTimeDisplay/components/DateDisplay.d.ts +6 -1
  84. package/lib/components/pisellDateTimeDisplay/components/DateDisplay.js +5 -1
  85. package/lib/components/pisellDateTimeDisplay/formats/dateTimeDisplayFormats.d.ts +7 -0
  86. package/lib/components/pisellDateTimeDisplay/formats/dateTimeDisplayFormats.js +98 -0
  87. package/lib/components/pisellDateTimeDisplay/formats/index.d.ts +1 -0
  88. package/lib/components/pisellDateTimeDisplay/formats/index.js +29 -0
  89. package/lib/components/pisellDateTimeDisplay/hooks/useCurrentTime.d.ts +2 -2
  90. package/lib/components/pisellDateTimeDisplay/types.d.ts +48 -2
  91. package/lib/components/pisellDateTimeDisplay/utils/formatDate.js +14 -1
  92. package/lib/components/pisellDateTimeDisplay/utils/formatDateOrRelative.d.ts +17 -0
  93. package/lib/components/pisellDateTimeDisplay/utils/formatDateOrRelative.js +54 -0
  94. package/lib/components/pisellDateTimeDisplay/utils/formatWeekday.js +6 -6
  95. package/lib/components/pisellDateTimeDisplay/utils/index.d.ts +3 -1
  96. package/lib/components/pisellDateTimeDisplay/utils/index.js +8 -2
  97. package/lib/components/pisellDateTimeDisplay/utils/localeUtils.d.ts +2 -7
  98. package/lib/components/pisellDateTimeDisplay/utils/localeUtils.js +2 -11
  99. package/lib/components/pisellDateTimeDisplay/utils/relativeDay.d.ts +23 -0
  100. package/lib/components/pisellDateTimeDisplay/utils/relativeDay.js +54 -0
  101. package/lib/components/pisellLookup/components/LookupTrigger.js +45 -7
  102. package/lib/components/pisellTimeRangeDisplay/PisellTimeRangeDisplay.d.ts +32 -0
  103. package/lib/components/pisellTimeRangeDisplay/PisellTimeRangeDisplay.js +193 -0
  104. package/lib/components/pisellTimeRangeDisplay/PisellTimeRangeDisplay.less +49 -0
  105. package/lib/components/pisellTimeRangeDisplay/PisellTimeRangeDisplay.stories.d.ts +61 -0
  106. package/lib/components/pisellTimeRangeDisplay/PisellTimeRangeDisplay.stories.js +187 -0
  107. package/lib/components/pisellTimeRangeDisplay/components/DateBlock.d.ts +20 -0
  108. package/lib/components/pisellTimeRangeDisplay/components/DateBlock.js +69 -0
  109. package/lib/components/pisellTimeRangeDisplay/components/DurationBlock.d.ts +19 -0
  110. package/lib/components/pisellTimeRangeDisplay/components/DurationBlock.js +65 -0
  111. package/lib/components/pisellTimeRangeDisplay/components/TimeRangeBlock.d.ts +30 -0
  112. package/lib/components/pisellTimeRangeDisplay/components/TimeRangeBlock.js +120 -0
  113. package/lib/components/pisellTimeRangeDisplay/components/WeekdayBlock.d.ts +18 -0
  114. package/lib/components/pisellTimeRangeDisplay/components/WeekdayBlock.js +64 -0
  115. package/lib/components/pisellTimeRangeDisplay/components/index.d.ts +8 -0
  116. package/lib/components/pisellTimeRangeDisplay/components/index.js +38 -0
  117. package/lib/components/pisellTimeRangeDisplay/index.d.ts +3 -0
  118. package/lib/components/pisellTimeRangeDisplay/index.js +40 -0
  119. package/lib/components/pisellTimeRangeDisplay/types.d.ts +137 -0
  120. package/lib/components/pisellTimeRangeDisplay/types.js +17 -0
  121. package/lib/components/pisellTimeRangeDisplay/utils/formatDuration.d.ts +14 -0
  122. package/lib/components/pisellTimeRangeDisplay/utils/formatDuration.js +52 -0
  123. package/lib/components/pisellTimeRangeDisplay/utils/index.d.ts +4 -0
  124. package/lib/components/pisellTimeRangeDisplay/utils/index.js +47 -0
  125. package/lib/components/pisellTimeRangeDisplay/utils/parseTimeRange.d.ts +23 -0
  126. package/lib/components/pisellTimeRangeDisplay/utils/parseTimeRange.js +49 -0
  127. package/lib/components/table/Gallery/components/VirtualGrid/useGapSize.d.ts +2 -2
  128. package/lib/components/table/Table/fields/select/filterUtil/index.d.ts +1 -1
  129. package/lib/components/table/Table/fields/treeSelect/filterUtil/index.d.ts +1 -1
  130. package/lib/index.d.ts +2 -0
  131. package/lib/index.js +3 -0
  132. package/lib/utils/index.d.ts +1 -1
  133. package/lib/utils/platform.d.ts +1 -1
  134. package/lowcode/pisell-time-range-display/index.ts +3 -0
  135. package/lowcode/pisell-time-range-display/meta.ts +375 -0
  136. package/lowcode/pisell-time-range-display/snippets.ts +1 -0
  137. package/package.json +3 -3
@@ -49,6 +49,7 @@ __export(PisellDateTimeDisplay_stories_exports, {
49
49
  DateMDY: () => DateMDY,
50
50
  DisableRefresh: () => DisableRefresh,
51
51
  HorizontalLayout: () => HorizontalLayout,
52
+ InlineDateTimeWeekdayZh: () => InlineDateTimeWeekdayZh,
52
53
  InlineLayout: () => InlineLayout,
53
54
  InlineWithCustomSeparator: () => InlineWithCustomSeparator,
54
55
  LocaleChinese: () => LocaleChinese,
@@ -56,6 +57,9 @@ __export(PisellDateTimeDisplay_stories_exports, {
56
57
  MultiLanguage: () => MultiLanguage,
57
58
  OnlyDate: () => OnlyDate,
58
59
  OnlyTime: () => OnlyTime,
60
+ RelativeDay: () => RelativeDay,
61
+ RelativeDayCustomLabels: () => RelativeDayCustomLabels,
62
+ RelativeDayEn: () => RelativeDayEn,
59
63
  ScenarioDashboard: () => ScenarioDashboard,
60
64
  ScenarioLargeScreen: () => ScenarioLargeScreen,
61
65
  ScenarioStatusBar: () => ScenarioStatusBar,
@@ -122,6 +126,23 @@ var InlineWithCustomSeparator = {
122
126
  inlineSeparator: " | "
123
127
  }
124
128
  };
129
+ var InlineDateTimeWeekdayZh = {
130
+ args: {
131
+ layout: "inline",
132
+ locale: "zh-cn",
133
+ fields: {
134
+ fieldOrder: ["date", "time", "weekday"],
135
+ inlineSeparators: [" - ", " "]
136
+ },
137
+ dateFormat: {
138
+ order: "YMD",
139
+ showYear: true,
140
+ separator: "-",
141
+ showChineseUnit: false,
142
+ showRelativeDay: false
143
+ }
144
+ }
145
+ };
125
146
  var Time12Hour = {
126
147
  args: {
127
148
  timeFormat: {
@@ -196,6 +217,44 @@ var DateChinese = {
196
217
  }
197
218
  }
198
219
  };
220
+ var RelativeDay = {
221
+ args: {
222
+ layout: "horizontal",
223
+ dateFormat: {
224
+ showRelativeDay: true,
225
+ showYear: true,
226
+ showChineseUnit: true
227
+ },
228
+ locale: "zh-cn"
229
+ }
230
+ };
231
+ var RelativeDayEn = {
232
+ args: {
233
+ layout: "horizontal",
234
+ dateFormat: {
235
+ showRelativeDay: true,
236
+ order: "MDY",
237
+ showYear: true
238
+ },
239
+ locale: "en"
240
+ }
241
+ };
242
+ var RelativeDayCustomLabels = {
243
+ args: {
244
+ layout: "horizontal",
245
+ dateFormat: {
246
+ showRelativeDay: true,
247
+ relativeDayLabels: {
248
+ today: "今日",
249
+ yesterday: "昨日",
250
+ tomorrow: "翌日"
251
+ },
252
+ showYear: true,
253
+ showChineseUnit: true
254
+ },
255
+ locale: "zh-cn"
256
+ }
257
+ };
199
258
  var DateFullMonth = {
200
259
  args: {
201
260
  locale: "en",
@@ -758,6 +817,7 @@ var DarkTheme = {
758
817
  DateMDY,
759
818
  DisableRefresh,
760
819
  HorizontalLayout,
820
+ InlineDateTimeWeekdayZh,
761
821
  InlineLayout,
762
822
  InlineWithCustomSeparator,
763
823
  LocaleChinese,
@@ -765,6 +825,9 @@ var DarkTheme = {
765
825
  MultiLanguage,
766
826
  OnlyDate,
767
827
  OnlyTime,
828
+ RelativeDay,
829
+ RelativeDayCustomLabels,
830
+ RelativeDayEn,
768
831
  ScenarioDashboard,
769
832
  ScenarioLargeScreen,
770
833
  ScenarioStatusBar,
@@ -1,5 +1,5 @@
1
1
  import React from 'react';
2
- import type { Dayjs } from 'dayjs';
2
+ import { type Dayjs } from 'dayjs';
3
3
  import type { DateFormatConfig, TextStyleConfig } from '../types';
4
4
  /**
5
5
  * DateDisplay 组件 Props
@@ -13,6 +13,10 @@ export interface DateDisplayProps {
13
13
  * 日期格式配置
14
14
  */
15
15
  format?: DateFormatConfig;
16
+ /**
17
+ * 参考日期(用于「今天/昨天/明天」判定,默认当前时间 dayjs())
18
+ */
19
+ referenceDate?: Dayjs;
16
20
  /**
17
21
  * 文本样式
18
22
  */
@@ -27,6 +31,7 @@ export interface DateDisplayProps {
27
31
  *
28
32
  * @description
29
33
  * - 格式化并展示日期
34
+ * - 支持 showRelativeDay:今天/昨天/明天时用相对日替换原日期展示,不展示具体日期
30
35
  * - 支持不同的日期顺序(YMD/MDY/DMY)
31
36
  * - 支持年月日字段显隐
32
37
  * - 支持中文单位(年、月、日)
@@ -34,14 +34,18 @@ __export(DateDisplay_exports, {
34
34
  });
35
35
  module.exports = __toCommonJS(DateDisplay_exports);
36
36
  var import_react = __toESM(require("react"));
37
+ var import_dayjs = __toESM(require("dayjs"));
37
38
  var import_utils = require("../utils");
38
39
  var DateDisplay = ({
39
40
  date,
40
41
  format,
42
+ referenceDate = (0, import_dayjs.default)(),
41
43
  style,
42
44
  className
43
45
  }) => {
44
- const formattedDate = (0, import_utils.formatDate)(date, format);
46
+ const labels = format == null ? void 0 : format.relativeDayLabels;
47
+ const relativeDay = (format == null ? void 0 : format.showRelativeDay) ? (0, import_utils.getRelativeDay)(date, referenceDate) : null;
48
+ const formattedDate = relativeDay ? (labels == null ? void 0 : labels[relativeDay]) ?? (0, import_utils.getRelativeDayLabel)(relativeDay, date.locale()) : (0, import_utils.formatDate)(date, format);
45
49
  if (!formattedDate) {
46
50
  return null;
47
51
  }
@@ -0,0 +1,7 @@
1
+ import type { DateTimeDisplayFormatPreset } from '../types';
2
+ /**
3
+ * PisellDateTimeDisplay 按语言预设的格式
4
+ * - zh-cn:完整日期 - 时间 星期(如 2025-12-31 - 2:00 周四)、相对日今天/昨天/明天
5
+ * - en:时间 星期, 日期(如 2:00 Sat, 21 Mar, 2026)、相对日 Today/Yesterday/Tomorrow
6
+ */
7
+ export declare const DATETIME_DISPLAY_FORMATS: Record<string, Partial<DateTimeDisplayFormatPreset>>;
@@ -0,0 +1,98 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
+ var __getOwnPropNames = Object.getOwnPropertyNames;
4
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
5
+ var __export = (target, all) => {
6
+ for (var name in all)
7
+ __defProp(target, name, { get: all[name], enumerable: true });
8
+ };
9
+ var __copyProps = (to, from, except, desc) => {
10
+ if (from && typeof from === "object" || typeof from === "function") {
11
+ for (let key of __getOwnPropNames(from))
12
+ if (!__hasOwnProp.call(to, key) && key !== except)
13
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
14
+ }
15
+ return to;
16
+ };
17
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
18
+
19
+ // src/components/pisellDateTimeDisplay/formats/dateTimeDisplayFormats.ts
20
+ var dateTimeDisplayFormats_exports = {};
21
+ __export(dateTimeDisplayFormats_exports, {
22
+ DATETIME_DISPLAY_FORMATS: () => DATETIME_DISPLAY_FORMATS
23
+ });
24
+ module.exports = __toCommonJS(dateTimeDisplayFormats_exports);
25
+ var DATETIME_DISPLAY_FORMATS = {
26
+ "zh-cn": {
27
+ dateFormat: {
28
+ order: "YMD",
29
+ showYear: true,
30
+ separator: "-",
31
+ showChineseUnit: false,
32
+ showRelativeDay: true
33
+ },
34
+ timeFormat: {
35
+ use12Hour: false,
36
+ showSeconds: false
37
+ },
38
+ weekdayFormat: {
39
+ full: false,
40
+ singleLetter: false
41
+ },
42
+ fields: {
43
+ showTime: true,
44
+ showDate: true,
45
+ showWeekday: true,
46
+ fieldOrder: ["date", "time", "weekday"],
47
+ inlineSeparators: [" - ", " "]
48
+ }
49
+ },
50
+ zh: {
51
+ // 兜底 zh
52
+ dateFormat: {
53
+ order: "YMD",
54
+ showYear: true,
55
+ separator: "-",
56
+ showChineseUnit: false,
57
+ showRelativeDay: true
58
+ },
59
+ timeFormat: { use12Hour: false, showSeconds: false },
60
+ weekdayFormat: { full: false, singleLetter: false },
61
+ fields: {
62
+ showTime: true,
63
+ showDate: true,
64
+ showWeekday: true,
65
+ fieldOrder: ["date", "time", "weekday"],
66
+ inlineSeparators: [" - ", " "]
67
+ }
68
+ },
69
+ en: {
70
+ dateFormat: {
71
+ order: "DMY",
72
+ shortMonth: true,
73
+ showYear: true,
74
+ showRelativeDay: true,
75
+ useCommaBeforeYear: true
76
+ },
77
+ timeFormat: {
78
+ use12Hour: false,
79
+ showSeconds: false
80
+ },
81
+ weekdayFormat: {
82
+ full: false,
83
+ singleLetter: false,
84
+ trailingComma: true
85
+ },
86
+ fields: {
87
+ showTime: true,
88
+ showDate: true,
89
+ showWeekday: true,
90
+ fieldOrder: ["time", "weekday", "date"],
91
+ inlineSeparators: [" ", " "]
92
+ }
93
+ }
94
+ };
95
+ // Annotate the CommonJS export names for ESM import in node:
96
+ 0 && (module.exports = {
97
+ DATETIME_DISPLAY_FORMATS
98
+ });
@@ -0,0 +1 @@
1
+ export { DATETIME_DISPLAY_FORMATS } from './dateTimeDisplayFormats';
@@ -0,0 +1,29 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
+ var __getOwnPropNames = Object.getOwnPropertyNames;
4
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
5
+ var __export = (target, all) => {
6
+ for (var name in all)
7
+ __defProp(target, name, { get: all[name], enumerable: true });
8
+ };
9
+ var __copyProps = (to, from, except, desc) => {
10
+ if (from && typeof from === "object" || typeof from === "function") {
11
+ for (let key of __getOwnPropNames(from))
12
+ if (!__hasOwnProp.call(to, key) && key !== except)
13
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
14
+ }
15
+ return to;
16
+ };
17
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
18
+
19
+ // src/components/pisellDateTimeDisplay/formats/index.ts
20
+ var formats_exports = {};
21
+ __export(formats_exports, {
22
+ DATETIME_DISPLAY_FORMATS: () => import_dateTimeDisplayFormats.DATETIME_DISPLAY_FORMATS
23
+ });
24
+ module.exports = __toCommonJS(formats_exports);
25
+ var import_dateTimeDisplayFormats = require("./dateTimeDisplayFormats");
26
+ // Annotate the CommonJS export names for ESM import in node:
27
+ 0 && (module.exports = {
28
+ DATETIME_DISPLAY_FORMATS
29
+ });
@@ -15,7 +15,7 @@ export interface UseCurrentTimeOptions {
15
15
  disabled?: boolean;
16
16
  /**
17
17
  * dayjs locale
18
- * @default 优先使用全局配置,其次使用浏览器语言
18
+ * @default 优先使用全局配置,其次使用 i18n 当前语言(getCurrentLocale)
19
19
  * @example 'zh-CN' | 'zh-HK' | 'en' | 'en-US' | 'ja'
20
20
  */
21
21
  locale?: string;
@@ -30,7 +30,7 @@ export interface UseCurrentTimeOptions {
30
30
  * @description
31
31
  * - 自动创建定时器刷新时间
32
32
  * - 支持自定义刷新间隔
33
- * - 支持国际化(locale):优先级为 用户指定 > 全局配置 > 浏览器语言
33
+ * - 支持国际化(locale):优先级为 用户指定 > 全局配置 > i18n 当前语言
34
34
  * - 组件卸载时自动清除定时器
35
35
  *
36
36
  * @example
@@ -99,6 +99,26 @@ export interface DateFormatConfig {
99
99
  * @default true
100
100
  */
101
101
  showDay?: boolean;
102
+ /**
103
+ * 英文 DMY 时年月之间是否加逗号(如 21 Mar, 2026;false 时为 22 Jan 2025)
104
+ * @default true
105
+ */
106
+ useCommaBeforeYear?: boolean;
107
+ /**
108
+ * 是否在「今天/昨天/明天」时用相对日替换具体日期
109
+ * 开启后:与参考日同天显示「今天」,前一天「昨天」,后一天「明天」;其他日期仍按原格式
110
+ * @default false
111
+ */
112
+ showRelativeDay?: boolean;
113
+ /**
114
+ * 相对日文案覆盖(用于 i18n 或自定义)
115
+ * 不传时按 locale 使用默认:zh 今天/昨天/明天,en Today/Yesterday/Tomorrow
116
+ */
117
+ relativeDayLabels?: {
118
+ today?: string;
119
+ yesterday?: string;
120
+ tomorrow?: string;
121
+ };
102
122
  }
103
123
  /**
104
124
  * 星期格式配置
@@ -116,6 +136,11 @@ export interface WeekdayFormatConfig {
116
136
  * @example true -> "S" / "六" | false -> "Sat" / "周六"
117
137
  */
118
138
  singleLetter?: boolean;
139
+ /**
140
+ * 是否在星期后加逗号(用于与日期拼接如 "Sat, 21 Mar, 2026")
141
+ * @default false
142
+ */
143
+ trailingComma?: boolean;
119
144
  }
120
145
  /**
121
146
  * 字段配置
@@ -141,6 +166,12 @@ export interface FieldConfig {
141
166
  * @default ['time', 'date', 'weekday']
142
167
  */
143
168
  fieldOrder?: FieldType[];
169
+ /**
170
+ * 单行布局时每段之间的分隔符,按顺序对应字段之间
171
+ * 如 ['date','time','weekday'] 配 inlineSeparators: [' - ', ' '] => "2025-12-31 - 2:00 周四"
172
+ * 不足时用组件 inlineSeparator 补齐
173
+ */
174
+ inlineSeparators?: string[];
144
175
  }
145
176
  /**
146
177
  * 文本样式配置
@@ -202,6 +233,16 @@ export interface ContainerStyleConfig {
202
233
  */
203
234
  gap?: number | string;
204
235
  }
236
+ /**
237
+ * 多语言格式预设(日期/时间/星期 + 字段顺序与分隔符)
238
+ * 用于 formatByLocale[locale] 或默认多语言配置
239
+ */
240
+ export interface DateTimeDisplayFormatPreset {
241
+ dateFormat?: DateFormatConfig;
242
+ timeFormat?: TimeFormatConfig;
243
+ weekdayFormat?: WeekdayFormatConfig;
244
+ fields?: FieldConfig;
245
+ }
205
246
  /**
206
247
  * PisellDateTimeDisplay 组件 Props
207
248
  */
@@ -220,6 +261,11 @@ export interface PisellDateTimeDisplayProps {
220
261
  * 字段显示配置
221
262
  */
222
263
  fields?: FieldConfig;
264
+ /**
265
+ * 多语言格式配置:按 locale 取对应格式预设,再与下方单项配置合并(单项优先)
266
+ * @example formatByLocale={{ 'zh-cn': { dateFormat: {...}, fields: { fieldOrder: ['date','time','weekday'], inlineSeparators: [' - ', ' '] } }, 'en': {...} }}
267
+ */
268
+ formatByLocale?: Record<string, Partial<DateTimeDisplayFormatPreset>>;
223
269
  /**
224
270
  * 时间格式配置
225
271
  */
@@ -274,11 +320,11 @@ export interface PisellDateTimeDisplayProps {
274
320
  disableAutoRefresh?: boolean;
275
321
  /**
276
322
  * dayjs locale(语言代码)
277
- * @default 优先使用全局配置(usePisellConfig),其次使用浏览器语言
323
+ * @default 优先使用全局配置(usePisellConfig),其次使用 i18n 当前语言(getCurrentLocale:全局配置 / umi_locale)
278
324
  * @example 'zh-CN' | 'zh-HK' | 'en' | 'en-US' | 'ja'
279
325
  * @description
280
326
  * - 支持标准 BCP 47 语言代码,会自动标准化为 dayjs 兼容格式
281
- * - 优先级:组件 locale 属性 > PisellConfigProvider 全局配置 > 浏览器语言
327
+ * - 优先级:组件 locale 属性 > PisellConfigProvider 全局配置 > i18n 当前语言
282
328
  */
283
329
  locale?: string;
284
330
  /**
@@ -32,7 +32,8 @@ function formatDate(date, config) {
32
32
  separator = "-",
33
33
  showYear = false,
34
34
  showMonth = true,
35
- showDay = true
35
+ showDay = true,
36
+ useCommaBeforeYear = true
36
37
  } = config || {};
37
38
  const locale = date.locale();
38
39
  const isChinese = (0, import_localeUtils.isChinese)(locale);
@@ -84,6 +85,18 @@ function formatDate(date, config) {
84
85
  }
85
86
  return formatted;
86
87
  }
88
+ if (order === "DMY" && !isChinese) {
89
+ const formatted = date.format(parts.join(" "));
90
+ if (showYear && showMonth && showDay && useCommaBeforeYear) {
91
+ const [day, month, year] = formatted.split(" ");
92
+ return `${day} ${month}, ${year}`;
93
+ }
94
+ if (showYear && showDay && !showMonth && useCommaBeforeYear) {
95
+ const [day, year] = formatted.split(" ");
96
+ return `${day}, ${year}`;
97
+ }
98
+ return formatted;
99
+ }
87
100
  return date.format(parts.join(separator));
88
101
  }
89
102
  // Annotate the CommonJS export names for ESM import in node:
@@ -0,0 +1,17 @@
1
+ import type { Dayjs } from 'dayjs';
2
+ import type { DateFormatConfig, WeekdayFormatConfig } from '../types';
3
+ /**
4
+ * 获取「日期部分」的展示文案(相对日内置在 datetime)
5
+ * - 若开启 showRelativeDay 且日期为今天/昨天/明天,返回相对日文案(如「今天」「Yesterday」)
6
+ * - 否则返回「星期, 日期」格式(用于时间区间跨天等场景)
7
+ *
8
+ * 供 PisellDateTimeDisplay、PisellTimeRangeDisplay 等统一使用,相对时间逻辑只在此处维护
9
+ */
10
+ export declare function getDatePartDisplay(params: {
11
+ date: Dayjs;
12
+ dateFormat?: DateFormatConfig;
13
+ weekdayFormat?: WeekdayFormatConfig;
14
+ referenceDate: Dayjs;
15
+ /** 覆盖日期格式(如跨天时的 order: 'DMY', shortMonth: true) */
16
+ dateFormatOverride?: Partial<DateFormatConfig>;
17
+ }): string;
@@ -0,0 +1,54 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
+ var __getOwnPropNames = Object.getOwnPropertyNames;
4
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
5
+ var __export = (target, all) => {
6
+ for (var name in all)
7
+ __defProp(target, name, { get: all[name], enumerable: true });
8
+ };
9
+ var __copyProps = (to, from, except, desc) => {
10
+ if (from && typeof from === "object" || typeof from === "function") {
11
+ for (let key of __getOwnPropNames(from))
12
+ if (!__hasOwnProp.call(to, key) && key !== except)
13
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
14
+ }
15
+ return to;
16
+ };
17
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
18
+
19
+ // src/components/pisellDateTimeDisplay/utils/formatDateOrRelative.ts
20
+ var formatDateOrRelative_exports = {};
21
+ __export(formatDateOrRelative_exports, {
22
+ getDatePartDisplay: () => getDatePartDisplay
23
+ });
24
+ module.exports = __toCommonJS(formatDateOrRelative_exports);
25
+ var import_formatDate = require("./formatDate");
26
+ var import_formatWeekday = require("./formatWeekday");
27
+ var import_relativeDay = require("./relativeDay");
28
+ function getDatePartDisplay(params) {
29
+ const {
30
+ date,
31
+ dateFormat,
32
+ weekdayFormat,
33
+ referenceDate,
34
+ dateFormatOverride
35
+ } = params;
36
+ if (dateFormat == null ? void 0 : dateFormat.showRelativeDay) {
37
+ const rel = (0, import_relativeDay.getRelativeDay)(date, referenceDate);
38
+ if (rel) {
39
+ const labels = dateFormat.relativeDayLabels;
40
+ return (labels == null ? void 0 : labels[rel]) ?? (0, import_relativeDay.getRelativeDayLabel)(rel, date.locale());
41
+ }
42
+ }
43
+ const mergedDateConfig = {
44
+ ...dateFormat,
45
+ ...dateFormatOverride
46
+ };
47
+ const weekdayStr = (0, import_formatWeekday.formatWeekday)(date, { ...weekdayFormat, trailingComma: true });
48
+ const dateStr = (0, import_formatDate.formatDate)(date, mergedDateConfig);
49
+ return `${weekdayStr} ${dateStr}`;
50
+ }
51
+ // Annotate the CommonJS export names for ESM import in node:
52
+ 0 && (module.exports = {
53
+ getDatePartDisplay
54
+ });
@@ -24,21 +24,21 @@ __export(formatWeekday_exports, {
24
24
  module.exports = __toCommonJS(formatWeekday_exports);
25
25
  var import_localeUtils = require("./localeUtils");
26
26
  function formatWeekday(weekday, config) {
27
- const { full = false, singleLetter = false } = config || {};
27
+ const { full = false, singleLetter = false, trailingComma = false } = config || {};
28
28
  const locale = weekday.locale();
29
29
  const isChinese = (0, import_localeUtils.isChinese)(locale);
30
+ const appendComma = (s) => trailingComma ? isChinese ? `${s},` : `${s},` : s;
30
31
  if (singleLetter) {
31
32
  if (isChinese) {
32
33
  const weekdayMap = ["日", "一", "二", "三", "四", "五", "六"];
33
- return weekdayMap[weekday.day()];
34
- } else {
35
- return weekday.format("dd").charAt(0);
34
+ return appendComma(weekdayMap[weekday.day()]);
36
35
  }
36
+ return appendComma(weekday.format("dd").charAt(0));
37
37
  }
38
38
  if (full) {
39
- return weekday.format("dddd");
39
+ return appendComma(weekday.format("dddd"));
40
40
  }
41
- return weekday.format("ddd");
41
+ return appendComma(weekday.format("ddd"));
42
42
  }
43
43
  // Annotate the CommonJS export names for ESM import in node:
44
44
  0 && (module.exports = {
@@ -1,5 +1,7 @@
1
1
  export { formatTime } from './formatTime';
2
2
  export { formatDate } from './formatDate';
3
3
  export { formatWeekday } from './formatWeekday';
4
+ export { getDatePartDisplay } from './formatDateOrRelative';
4
5
  export { getRefreshInterval } from './getRefreshInterval';
5
- export { getBrowserLocale, normalizeLocale, isChinese, getDayjsLocale, } from './localeUtils';
6
+ export { getRelativeDay, getRelativeDayLabel, type RelativeDay, } from './relativeDay';
7
+ export { normalizeLocale, isChinese, getDayjsLocale, } from './localeUtils';
@@ -22,9 +22,11 @@ __export(utils_exports, {
22
22
  formatDate: () => import_formatDate.formatDate,
23
23
  formatTime: () => import_formatTime.formatTime,
24
24
  formatWeekday: () => import_formatWeekday.formatWeekday,
25
- getBrowserLocale: () => import_localeUtils.getBrowserLocale,
25
+ getDatePartDisplay: () => import_formatDateOrRelative.getDatePartDisplay,
26
26
  getDayjsLocale: () => import_localeUtils.getDayjsLocale,
27
27
  getRefreshInterval: () => import_getRefreshInterval.getRefreshInterval,
28
+ getRelativeDay: () => import_relativeDay.getRelativeDay,
29
+ getRelativeDayLabel: () => import_relativeDay.getRelativeDayLabel,
28
30
  isChinese: () => import_localeUtils.isChinese,
29
31
  normalizeLocale: () => import_localeUtils.normalizeLocale
30
32
  });
@@ -32,16 +34,20 @@ module.exports = __toCommonJS(utils_exports);
32
34
  var import_formatTime = require("./formatTime");
33
35
  var import_formatDate = require("./formatDate");
34
36
  var import_formatWeekday = require("./formatWeekday");
37
+ var import_formatDateOrRelative = require("./formatDateOrRelative");
35
38
  var import_getRefreshInterval = require("./getRefreshInterval");
39
+ var import_relativeDay = require("./relativeDay");
36
40
  var import_localeUtils = require("./localeUtils");
37
41
  // Annotate the CommonJS export names for ESM import in node:
38
42
  0 && (module.exports = {
39
43
  formatDate,
40
44
  formatTime,
41
45
  formatWeekday,
42
- getBrowserLocale,
46
+ getDatePartDisplay,
43
47
  getDayjsLocale,
44
48
  getRefreshInterval,
49
+ getRelativeDay,
50
+ getRelativeDayLabel,
45
51
  isChinese,
46
52
  normalizeLocale
47
53
  });
@@ -1,9 +1,3 @@
1
- /**
2
- * 获取浏览器语言
3
- * @returns 浏览器语言代码
4
- * @example 'zh-CN' | 'en' | 'zh-HK'
5
- */
6
- export declare function getBrowserLocale(): string;
7
1
  /**
8
2
  * 标准化 locale 代码
9
3
  * @param locale 原始 locale 代码
@@ -20,7 +14,8 @@ export declare function normalizeLocale(locale: string): string;
20
14
  export declare function isChinese(locale: string): boolean;
21
15
  /**
22
16
  * 获取 dayjs 兼容的 locale 代码
23
- * @param locale 原始 locale 代码
17
+ * 未传 locale 时使用 i18n 当前语言(全局配置 / umi_locale),不再使用浏览器语言
18
+ * @param locale 原始 locale 代码(可选)
24
19
  * @returns dayjs 兼容的 locale 代码
25
20
  * @example 'zh-CN' -> 'zh-cn', 'en-US' -> 'en'
26
21
  */
@@ -19,19 +19,12 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
19
19
  // src/components/pisellDateTimeDisplay/utils/localeUtils.ts
20
20
  var localeUtils_exports = {};
21
21
  __export(localeUtils_exports, {
22
- getBrowserLocale: () => getBrowserLocale,
23
22
  getDayjsLocale: () => getDayjsLocale,
24
23
  isChinese: () => isChinese,
25
24
  normalizeLocale: () => normalizeLocale
26
25
  });
27
26
  module.exports = __toCommonJS(localeUtils_exports);
28
- function getBrowserLocale() {
29
- if (typeof window === "undefined" || typeof navigator === "undefined") {
30
- return "en";
31
- }
32
- const browserLang = navigator.language || navigator.userLanguage || "en";
33
- return browserLang;
34
- }
27
+ var import_locale = require("../../../utils/locale");
35
28
  function normalizeLocale(locale) {
36
29
  return locale.toLowerCase();
37
30
  }
@@ -41,14 +34,12 @@ function isChinese(locale) {
41
34
  }
42
35
  function getDayjsLocale(locale) {
43
36
  if (!locale) {
44
- const browserLocale = getBrowserLocale();
45
- return normalizeLocale(browserLocale);
37
+ return normalizeLocale((0, import_locale.getCurrentLocale)());
46
38
  }
47
39
  return normalizeLocale(locale);
48
40
  }
49
41
  // Annotate the CommonJS export names for ESM import in node:
50
42
  0 && (module.exports = {
51
- getBrowserLocale,
52
43
  getDayjsLocale,
53
44
  isChinese,
54
45
  normalizeLocale
@@ -0,0 +1,23 @@
1
+ import type { Dayjs } from 'dayjs';
2
+ export declare type RelativeDay = 'today' | 'yesterday' | 'tomorrow';
3
+ /**
4
+ * 判断日期相对于参考日期是今天、昨天还是明天
5
+ *
6
+ * @param date 要展示的日期
7
+ * @param reference 参考日期(通常为「当前」dayjs())
8
+ * @returns 'today' | 'yesterday' | 'tomorrow' | null
9
+ *
10
+ * @example
11
+ * getRelativeDay(dayjs(), dayjs()) // => 'today'
12
+ * getRelativeDay(dayjs().add(1,'day'), dayjs()) // => 'tomorrow'
13
+ * getRelativeDay(dayjs().subtract(1,'day'), dayjs()) // => 'yesterday'
14
+ */
15
+ export declare function getRelativeDay(date: Dayjs, reference: Dayjs): RelativeDay | null;
16
+ /**
17
+ * 根据 locale 返回相对日期的展示文案
18
+ *
19
+ * @param day 'today' | 'yesterday' | 'tomorrow'
20
+ * @param locale dayjs locale,如 'zh-cn'、'en'
21
+ * @returns 如 '今天'、'Today'
22
+ */
23
+ export declare function getRelativeDayLabel(day: RelativeDay, locale?: string): string;