@alauda-fe/common 1.4.28-beta.5 → 1.4.28

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 (174) hide show
  1. package/core/constants/constants.d.ts +0 -3
  2. package/core/services/intercept-deactivate.service.d.ts +2 -2
  3. package/core/services/time.service.d.ts +2 -8
  4. package/esm2022/abnormal-page/abnormal-page.component.mjs +1 -1
  5. package/esm2022/array-form-table/form/component.mjs +1 -1
  6. package/esm2022/array-form-table/key-value-form/component.mjs +1 -1
  7. package/esm2022/array-form-table/key-value-table/component.mjs +1 -1
  8. package/esm2022/array-form-table/string-array-form/component.mjs +1 -1
  9. package/esm2022/async-data/error-page/component.mjs +1 -1
  10. package/esm2022/async-data/page-state/component.mjs +1 -1
  11. package/esm2022/business/notification-disabled-container/component.mjs +1 -1
  12. package/esm2022/business/resource-select/exports/cluster-list/component.mjs +1 -1
  13. package/esm2022/business/resource-select/exports/cluster-selector/component.mjs +1 -1
  14. package/esm2022/business/resource-select/exports/icon/component.mjs +1 -1
  15. package/esm2022/business/resource-select/exports/mesh-group-selector/component.mjs +1 -1
  16. package/esm2022/business/resource-select/exports/namespace-list/component.mjs +1 -1
  17. package/esm2022/business/resource-select/exports/namespace-page/component.mjs +1 -1
  18. package/esm2022/business/resource-select/exports/namespace-selector/component.mjs +1 -1
  19. package/esm2022/business/resource-select/exports/project-list/component.mjs +1 -1
  20. package/esm2022/business/resource-select/exports/project-page/component.mjs +1 -1
  21. package/esm2022/business/resource-select/exports/project-selector/component.mjs +1 -1
  22. package/esm2022/business/resource-select/internals/data-grid/component.mjs +1 -1
  23. package/esm2022/business/resource-select/internals/meshgroup-list/component.mjs +1 -1
  24. package/esm2022/business/resource-select/internals/no-data/component.mjs +1 -1
  25. package/esm2022/business/resource-select/internals/resource-dashboard/component.mjs +1 -1
  26. package/esm2022/business/resource-select/internals/selector-popup/component.mjs +1 -1
  27. package/esm2022/chart/common/axis/axis-label.component.mjs +1 -1
  28. package/esm2022/chart/common/axis/x-axis-ticks.component.mjs +1 -1
  29. package/esm2022/chart/common/axis/x-axis.component.mjs +1 -1
  30. package/esm2022/chart/common/axis/x-plot-lines.component.mjs +1 -1
  31. package/esm2022/chart/common/axis/y-axis-ticks.component.mjs +1 -1
  32. package/esm2022/chart/common/axis/y-axis.component.mjs +1 -1
  33. package/esm2022/chart/common/axis/y-plot-lines.component.mjs +1 -1
  34. package/esm2022/chart/common/chart/chart.component.mjs +1 -1
  35. package/esm2022/chart/common/legend/legend.component.mjs +1 -1
  36. package/esm2022/chart/common/range-area/range-area.component.mjs +1 -1
  37. package/esm2022/chart/common/reference-area/reference-area.component.mjs +1 -1
  38. package/esm2022/chart/common/series/area-series.component.mjs +1 -1
  39. package/esm2022/chart/common/series/bar-path.component.mjs +1 -1
  40. package/esm2022/chart/common/series/bar-series.component.mjs +1 -1
  41. package/esm2022/chart/common/series/line-series.component.mjs +1 -1
  42. package/esm2022/chart/common/tooltip/tooltip.component.mjs +1 -1
  43. package/esm2022/chart/custom-template/dropdown-legend.mjs +1 -1
  44. package/esm2022/code/code-display-dialog/component.mjs +1 -1
  45. package/esm2022/code/k8s-yaml-display-dialog/component.mjs +1 -1
  46. package/esm2022/code/resource-yaml-display/component.mjs +1 -1
  47. package/esm2022/code/resource-yaml-editor/component.mjs +1 -1
  48. package/esm2022/code/yaml-sidebar/component.mjs +1 -1
  49. package/esm2022/core/components/tree/node/component.mjs +1 -1
  50. package/esm2022/core/components/tree/tree/component.mjs +1 -1
  51. package/esm2022/core/constants/constants.mjs +1 -4
  52. package/esm2022/core/directives/readonly-field.directive.mjs +1 -1
  53. package/esm2022/core/guards/intercept-deactivate.guard.mjs +2 -2
  54. package/esm2022/core/services/intercept-deactivate.service.mjs +1 -1
  55. package/esm2022/core/services/time.service.mjs +36 -13
  56. package/esm2022/custom-columns-setting/component.mjs +1 -1
  57. package/esm2022/disabled-container/disabled-container.component.mjs +1 -1
  58. package/esm2022/editable/editable.component.mjs +1 -1
  59. package/esm2022/editable-text/component.mjs +1 -1
  60. package/esm2022/exec/placeholder/component.mjs +1 -1
  61. package/esm2022/exec/terminal/component.mjs +1 -1
  62. package/esm2022/exec/terminal-group/component.mjs +1 -1
  63. package/esm2022/feature-gate-forbidden/component/component.mjs +1 -1
  64. package/esm2022/form/errors-mapper/errors-mapper-component/component.mjs +1 -1
  65. package/esm2022/form/errors-mapper/errors-mapper.directive.mjs +1 -1
  66. package/esm2022/form/labels-editor/component.mjs +1 -1
  67. package/esm2022/form/taints-editor/component.mjs +1 -1
  68. package/esm2022/form/upload-file/component.mjs +1 -1
  69. package/esm2022/form/validators/strong-password/strong-password-tooltip/component.mjs +1 -1
  70. package/esm2022/graph-canvas/components/graph-actions.component.mjs +1 -1
  71. package/esm2022/graph-canvas/components/graph-canvas.component.mjs +1 -1
  72. package/esm2022/graph-canvas/components/graph-link.component.mjs +1 -1
  73. package/esm2022/graph-canvas/components/graph-links.component.mjs +1 -1
  74. package/esm2022/grid-layout/components/grid/component.mjs +1 -1
  75. package/esm2022/grid-layout/components/grid-items/component.mjs +1 -1
  76. package/esm2022/help-document/component.mjs +1 -1
  77. package/esm2022/k8s-resource-list/footer/component.mjs +1 -1
  78. package/esm2022/k8s-shared/resource-mark/k8s-resource-mark.component.mjs +1 -1
  79. package/esm2022/k8s-shared/update-description-dialog/component.mjs +1 -1
  80. package/esm2022/k8s-shared/update-display-name-dialog/component.mjs +1 -1
  81. package/esm2022/k8s-shared/update-key-value-dialog/component.mjs +1 -1
  82. package/esm2022/lazy-component/lazy-load-component.mjs +1 -1
  83. package/esm2022/license/license-error/component.mjs +1 -1
  84. package/esm2022/list-display/component.mjs +1 -1
  85. package/esm2022/metric-chart/metric-chart.component.mjs +1 -1
  86. package/esm2022/metric-chart/metric-time-pick.mjs +1 -1
  87. package/esm2022/multi-search/action-input/component.mjs +1 -1
  88. package/esm2022/multi-search/form/component.mjs +1 -1
  89. package/esm2022/multi-search/multi-search-tags/component.mjs +1 -1
  90. package/esm2022/mutable/mosaic/mosaic.component.mjs +1 -1
  91. package/esm2022/notification/feedback-notification/component.mjs +1 -1
  92. package/esm2022/overview-banner/overview-banner.component.mjs +1 -1
  93. package/esm2022/page-guard/component/component.mjs +1 -1
  94. package/esm2022/page-scaffold/navigation/breadcrumb/breadcrumb.component.mjs +1 -1
  95. package/esm2022/page-scaffold/navigation/nav-menu/nav-item-li/nav-item-li.component.mjs +1 -1
  96. package/esm2022/page-scaffold/navigation/nav-menu/nav-item-ul/nav-item-ul.component.mjs +1 -1
  97. package/esm2022/page-scaffold/navigation/nav-menu/nav-menu.component.mjs +1 -1
  98. package/esm2022/page-scaffold/page/notices/maintenance.component.mjs +1 -1
  99. package/esm2022/page-scaffold/page/notices/notice.component.mjs +1 -1
  100. package/esm2022/page-scaffold/page/page.component.mjs +1 -1
  101. package/esm2022/page-scaffold/page/page.module.mjs +6 -5
  102. package/esm2022/page-scaffold/page-header/account-menu/component/component.mjs +1 -1
  103. package/esm2022/page-scaffold/page-header/common-layout/namespace-select/component.mjs +1 -1
  104. package/esm2022/page-scaffold/page-header/common-layout/product-select/component.mjs +1 -1
  105. package/esm2022/page-scaffold/page-header/component.mjs +1 -1
  106. package/esm2022/page-scaffold/page-header/enterprise-support-status/component.mjs +1 -1
  107. package/esm2022/page-scaffold/page-header/header-notify/component/header-notify.component.mjs +1 -1
  108. package/esm2022/page-scaffold/page-header/header-notify/component/notification-list/notification-list.component.mjs +1 -1
  109. package/esm2022/page-scaffold/page-header/help-menu/component/component.mjs +1 -1
  110. package/esm2022/page-scaffold/page-header/help-menu/module.mjs +9 -8
  111. package/esm2022/pie-derivative-chart/donut-status/component.mjs +1 -1
  112. package/esm2022/pie-derivative-chart/radial-bar/radial-bar-chart.component.mjs +1 -1
  113. package/esm2022/pod-status/component.mjs +1 -1
  114. package/esm2022/searchable-selector/component.mjs +1 -1
  115. package/esm2022/skeleton/item/component.mjs +1 -1
  116. package/esm2022/skeleton/nav-skeleton/component.mjs +1 -1
  117. package/esm2022/table/component.mjs +1 -1
  118. package/esm2022/table/module.mjs +12 -11
  119. package/esm2022/translate/constants.mjs +1 -2
  120. package/esm2022/translate/intl-format.pipes.mjs +293 -0
  121. package/esm2022/translate/public-api.mjs +4 -3
  122. package/esm2022/translate/relative-time-manager.service.mjs +87 -0
  123. package/esm2022/translate/translate.directive.mjs +5 -4
  124. package/esm2022/translate/translate.module.mjs +22 -3
  125. package/esm2022/translate/translate.pipe.mjs +7 -8
  126. package/esm2022/translate/translate.service.mjs +721 -142
  127. package/esm2022/translate/types.mjs +1 -1
  128. package/esm2022/view-chart/custom-template/dropdown-legend.mjs +1 -1
  129. package/esm2022/view-chart/legend/legend.component.mjs +1 -1
  130. package/esm2022/view-chart/view-chart.component.mjs +1 -1
  131. package/esm2022/view-zchart/custom-template/dropdown-legend.mjs +1 -1
  132. package/esm2022/view-zchart/legend/legend.component.mjs +1 -1
  133. package/esm2022/view-zchart/view-zchart.component.mjs +1 -1
  134. package/esm2022/widget/card-section/card-section.component.mjs +1 -1
  135. package/esm2022/widget/confirm-delete/confirm-delete.component.mjs +1 -1
  136. package/esm2022/widget/current-time/component.mjs +1 -1
  137. package/esm2022/widget/date-range-picker/component.mjs +1 -1
  138. package/esm2022/widget/field-set/column/component.mjs +2 -2
  139. package/esm2022/widget/field-set/group/component.mjs +1 -1
  140. package/esm2022/widget/field-set/item/component.mjs +1 -1
  141. package/esm2022/widget/foldable-block/component.mjs +1 -1
  142. package/esm2022/widget/foldable-item-in-table/component.mjs +1 -1
  143. package/esm2022/widget/loading-mask/loading-mask.component.mjs +1 -1
  144. package/esm2022/widget/password-input/component.mjs +1 -1
  145. package/esm2022/widget/relative-time/component.mjs +1 -1
  146. package/esm2022/widget/resource-label/component.mjs +1 -1
  147. package/esm2022/widget/resource-multi-select/component.mjs +1 -1
  148. package/esm2022/widget/search-panel/component.mjs +1 -1
  149. package/esm2022/widget/search-panel/search-item/component.mjs +1 -1
  150. package/esm2022/widget/status-icon/status-icon.component.mjs +1 -1
  151. package/esm2022/widget/tags-label/component.mjs +1 -1
  152. package/esm2022/widget/terminating-tag/component.mjs +1 -1
  153. package/esm2022/widget/text-ellipsis/component.mjs +1 -1
  154. package/esm2022/widget/text-with-url/component.mjs +1 -1
  155. package/esm2022/widget/zero-state/zero-state.component.mjs +1 -1
  156. package/esm2022/workload-status-icon/component.mjs +1 -1
  157. package/esm2022/xterm/xterm-terminal/xterm-terminal.component.mjs +1 -1
  158. package/esm2022/xterm/xterm.component.mjs +1 -1
  159. package/package.json +2 -2
  160. package/page-scaffold/page/page.module.d.ts +4 -3
  161. package/page-scaffold/page-header/help-menu/module.d.ts +2 -1
  162. package/table/component.d.ts +1 -1
  163. package/table/module.d.ts +2 -1
  164. package/translate/intl-format.pipes.d.ts +122 -0
  165. package/translate/public-api.d.ts +3 -2
  166. package/translate/relative-time-manager.service.d.ts +32 -0
  167. package/translate/translate.module.d.ts +4 -2
  168. package/translate/translate.pipe.d.ts +4 -5
  169. package/translate/translate.service.d.ts +292 -20
  170. package/translate/types.d.ts +16 -0
  171. package/code/resource-yaml-display/schema/component.d.ts +0 -61
  172. package/code/yaml-sidebar/yaml-examples.d.ts +0 -8
  173. package/esm2022/code/resource-yaml-display/schema/component.mjs +0 -531
  174. package/esm2022/code/yaml-sidebar/yaml-examples.mjs +0 -340
@@ -0,0 +1,122 @@
1
+ /**
2
+ * @packageDocumentation
3
+ * @module translate
4
+ */
5
+ import { ChangeDetectorRef, OnDestroy, PipeTransform } from '@angular/core';
6
+ import { Subject } from 'rxjs';
7
+ import { TranslateService } from './translate.service';
8
+ import * as i0 from "@angular/core";
9
+ /**
10
+ * 基础国际化格式化 Pipe 抽象类
11
+ * 提供响应式的 locale 变化监听功能
12
+ */
13
+ declare abstract class BaseIntlPipe implements PipeTransform, OnDestroy {
14
+ protected readonly destroy$$: Subject<void>;
15
+ protected readonly cdr: ChangeDetectorRef;
16
+ protected readonly translate: TranslateService;
17
+ constructor();
18
+ ngOnDestroy(): void;
19
+ abstract transform(value: any, ...args: any[]): string;
20
+ static ɵfac: i0.ɵɵFactoryDeclaration<BaseIntlPipe, never>;
21
+ static ɵprov: i0.ɵɵInjectableDeclaration<BaseIntlPipe>;
22
+ }
23
+ /**
24
+ * 数字格式化 Pipe
25
+ * @example
26
+ * {{ 1234.56 | aclIntlNumber }} // "1,234.56"
27
+ * {{ 0.85 | aclIntlNumber:{ style: 'percent' } }} // "85%"
28
+ * {{ 1234.56 | aclIntlNumber:{ minimumFractionDigits: 2 } }} // "1,234.56"
29
+ */
30
+ export declare class IntlNumberPipe extends BaseIntlPipe implements PipeTransform {
31
+ transform(value: number, options?: Intl.NumberFormatOptions): string;
32
+ static ɵfac: i0.ɵɵFactoryDeclaration<IntlNumberPipe, never>;
33
+ static ɵpipe: i0.ɵɵPipeDeclaration<IntlNumberPipe, "aclIntlNumber", true>;
34
+ }
35
+ /**
36
+ * 货币格式化 Pipe
37
+ * @example
38
+ * {{ 1234.56 | aclIntlCurrency }} // "¥1,234.56"
39
+ * {{ 1234.56 | aclIntlCurrency:'USD' }} // "$1,234.56"
40
+ * {{ 1234.56 | aclIntlCurrency:'EUR':{ minimumFractionDigits: 2 } }} // "€1,234.56"
41
+ */
42
+ export declare class IntlCurrencyPipe extends BaseIntlPipe implements PipeTransform {
43
+ transform(value: number, currency?: string, options?: Intl.NumberFormatOptions): string;
44
+ static ɵfac: i0.ɵɵFactoryDeclaration<IntlCurrencyPipe, never>;
45
+ static ɵpipe: i0.ɵɵPipeDeclaration<IntlCurrencyPipe, "aclIntlCurrency", true>;
46
+ }
47
+ /**
48
+ * 百分比格式化 Pipe
49
+ * @example
50
+ * {{ 0.85 | aclIntlPercent }} // "85%"
51
+ * {{ 0.8567 | aclIntlPercent:{ minimumFractionDigits: 2 } }} // "85.67%"
52
+ */
53
+ export declare class IntlPercentPipe extends BaseIntlPipe implements PipeTransform {
54
+ transform(value: number, options?: Omit<Intl.NumberFormatOptions, 'style'>): string;
55
+ static ɵfac: i0.ɵɵFactoryDeclaration<IntlPercentPipe, never>;
56
+ static ɵpipe: i0.ɵɵPipeDeclaration<IntlPercentPipe, "aclIntlPercent", true>;
57
+ }
58
+ /**
59
+ * 日期格式化 Pipe
60
+ * @example
61
+ * {{ date | aclIntlDate }} // "2025/01/01"
62
+ * {{ date | aclIntlDate:{ dateStyle: 'long' } }} // "2025年1月1日"
63
+ * {{ date | aclIntlDate:{ year: 'numeric', month: 'long' } }} // "2025年1月"
64
+ */
65
+ export declare class IntlDatePipe extends BaseIntlPipe implements PipeTransform {
66
+ transform(value: Date | string | number, options?: Intl.DateTimeFormatOptions): string;
67
+ static ɵfac: i0.ɵɵFactoryDeclaration<IntlDatePipe, never>;
68
+ static ɵpipe: i0.ɵɵPipeDeclaration<IntlDatePipe, "aclIntlDate", true>;
69
+ }
70
+ /**
71
+ * 日期时间格式化 Pipe
72
+ * @example
73
+ * {{ date | aclIntlDateTime }} // "2025/01/01 14:30:00"
74
+ * {{ date | aclIntlDateTime:{ dateStyle: 'medium', timeStyle: 'short' } }} // "2025年1月1日 14:30"
75
+ */
76
+ export declare class IntlDateTimePipe extends BaseIntlPipe implements PipeTransform {
77
+ transform(value: Date | string | number, options?: Intl.DateTimeFormatOptions): string;
78
+ static ɵfac: i0.ɵɵFactoryDeclaration<IntlDateTimePipe, never>;
79
+ static ɵpipe: i0.ɵɵPipeDeclaration<IntlDateTimePipe, "aclIntlDateTime", true>;
80
+ }
81
+ /**
82
+ * 相对时间格式化 Pipe
83
+ * 支持两种使用方式:
84
+ * 1. 传入 Date 对象,自动计算相对时间
85
+ * 2. 传入数值和单位,手动指定相对时间
86
+ *
87
+ * 特性:
88
+ * - 自动刷新UI:根据时间距离智能调整刷新频率
89
+ * - 性能优化:共享定时器,避免大量单独计时器
90
+ * - 响应式设计:监听语言变化自动更新
91
+ *
92
+ * @example
93
+ * // 自动计算
94
+ * {{ pastDate | aclIntlRelativeTime }} // "2 hours ago"
95
+ * {{ futureDate | aclIntlRelativeTime:{ numeric: 'always' } }} // "in 2 hours"
96
+ *
97
+ * // 手动指定
98
+ * {{ -1 | aclIntlRelativeTime:'day' }} // "yesterday"
99
+ * {{ 2 | aclIntlRelativeTime:'hour':{ numeric: 'always' } }} // "in 2 hours"
100
+ * {{ -30 | aclIntlRelativeTime:'minute':{ numeric: 'always' } }} // "30 minutes ago"
101
+ */
102
+ export declare class IntlRelativeTimePipe extends BaseIntlPipe implements PipeTransform, OnDestroy {
103
+ private readonly relativeTimeManager;
104
+ private currentInterval?;
105
+ private refreshSubscription?;
106
+ private currentValue?;
107
+ ngOnDestroy(): void;
108
+ transform(value: Date | number, unitOrOptions?: Intl.RelativeTimeFormatUnit | Intl.RelativeTimeFormatOptions, options?: Intl.RelativeTimeFormatOptions): string;
109
+ /**
110
+ * 设置自动刷新机制
111
+ * 使用共享的计时器管理器,提高多实例场景下的性能
112
+ * 时间间隔大于一天时不设置自动刷新
113
+ */
114
+ private setupAutoRefresh;
115
+ /**
116
+ * 清理刷新相关资源
117
+ */
118
+ private cleanupRefresh;
119
+ static ɵfac: i0.ɵɵFactoryDeclaration<IntlRelativeTimePipe, never>;
120
+ static ɵpipe: i0.ɵɵPipeDeclaration<IntlRelativeTimePipe, "aclIntlRelativeTime", true>;
121
+ }
122
+ export {};
@@ -6,11 +6,12 @@
6
6
  /** imports */
7
7
  export * from './constants';
8
8
  export * from './helpers';
9
+ export * from './i18n-assets-loader';
10
+ export * from './i18n-config';
11
+ export * from './intl-format.pipes';
9
12
  export * from './tokens';
10
13
  export * from './translate.directive';
11
14
  export * from './translate.module';
12
15
  export * from './translate.pipe';
13
16
  export * from './translate.service';
14
17
  export * from './types';
15
- export * from './i18n-assets-loader';
16
- export * from './i18n-config';
@@ -0,0 +1,32 @@
1
+ /**
2
+ * @packageDocumentation
3
+ * @module translate
4
+ */
5
+ import { OnDestroy } from '@angular/core';
6
+ import { Subject } from 'rxjs';
7
+ import * as i0 from "@angular/core";
8
+ /**
9
+ * 相对时间管理器服务
10
+ *
11
+ * 用于优化大量相对时间显示的性能,通过共享定时器避免创建过多独立计时器。
12
+ * 当页面存在大量相对时间显示时,使用统一的刷新频率来批量更新所有实例。
13
+ */
14
+ export declare class RelativeTimeManagerService implements OnDestroy {
15
+ private readonly refreshSubjects;
16
+ private readonly timers;
17
+ /**
18
+ * 获取指定刷新间隔的 Subject
19
+ * 多个 pipe 实例可以共享同一个刷新频率
20
+ */
21
+ getRefreshSubject(interval: number): Subject<void>;
22
+ /**
23
+ * 释放指定间隔的订阅
24
+ * 当没有 pipe 实例使用时,自动清理定时器
25
+ */
26
+ releaseRefreshSubject(interval: number): void;
27
+ private startTimer;
28
+ private stopTimer;
29
+ ngOnDestroy(): void;
30
+ static ɵfac: i0.ɵɵFactoryDeclaration<RelativeTimeManagerService, never>;
31
+ static ɵprov: i0.ɵɵInjectableDeclaration<RelativeTimeManagerService>;
32
+ }
@@ -1,14 +1,16 @@
1
+ import { IntlNumberPipe, IntlCurrencyPipe, IntlPercentPipe, IntlDatePipe, IntlDateTimePipe, IntlRelativeTimePipe } from './intl-format.pipes';
1
2
  import { TranslateDirective, TranslateMatchDirective, TranslateTextDirective } from './translate.directive';
2
3
  import { TranslatePipe } from './translate.pipe';
3
4
  import * as i0 from "@angular/core";
4
5
  import * as i1 from "./translate.pipe";
5
6
  import * as i2 from "./translate.directive";
6
- export declare const TRANSLATE_MODULE: readonly [typeof TranslatePipe, typeof TranslateDirective, typeof TranslateMatchDirective, typeof TranslateTextDirective];
7
+ import * as i3 from "./intl-format.pipes";
8
+ export declare const TRANSLATE_MODULE: readonly [typeof TranslatePipe, typeof TranslateDirective, typeof TranslateMatchDirective, typeof TranslateTextDirective, typeof IntlNumberPipe, typeof IntlCurrencyPipe, typeof IntlPercentPipe, typeof IntlDatePipe, typeof IntlDateTimePipe, typeof IntlRelativeTimePipe];
7
9
  /**
8
10
  * @deprecated use `TranslatePipe` or `TRANSLATE_MODULE` except `.forRoot`
9
11
  */
10
12
  export declare class TranslateModule {
11
13
  static ɵfac: i0.ɵɵFactoryDeclaration<TranslateModule, never>;
12
- static ɵmod: i0.ɵɵNgModuleDeclaration<TranslateModule, never, [typeof i1.TranslatePipe, typeof i2.TranslateDirective, typeof i2.TranslateMatchDirective, typeof i2.TranslateTextDirective], [typeof i1.TranslatePipe, typeof i2.TranslateDirective, typeof i2.TranslateMatchDirective, typeof i2.TranslateTextDirective]>;
14
+ static ɵmod: i0.ɵɵNgModuleDeclaration<TranslateModule, never, [typeof i1.TranslatePipe, typeof i2.TranslateDirective, typeof i2.TranslateMatchDirective, typeof i2.TranslateTextDirective, typeof i3.IntlNumberPipe, typeof i3.IntlCurrencyPipe, typeof i3.IntlPercentPipe, typeof i3.IntlDatePipe, typeof i3.IntlDateTimePipe, typeof i3.IntlRelativeTimePipe], [typeof i1.TranslatePipe, typeof i2.TranslateDirective, typeof i2.TranslateMatchDirective, typeof i2.TranslateTextDirective, typeof i3.IntlNumberPipe, typeof i3.IntlCurrencyPipe, typeof i3.IntlPercentPipe, typeof i3.IntlDatePipe, typeof i3.IntlDateTimePipe, typeof i3.IntlRelativeTimePipe]>;
13
15
  static ɵinj: i0.ɵɵInjectorDeclaration<TranslateModule>;
14
16
  }
@@ -2,11 +2,10 @@
2
2
  * @packageDocumentation
3
3
  * @module translate
4
4
  */
5
- import { Injector, OnDestroy, PipeTransform } from '@angular/core';
6
- import { TranslateKey } from './types';
5
+ import { OnDestroy, PipeTransform } from '@angular/core';
6
+ import { TranslateKey, TemplateData } from './types';
7
7
  import * as i0 from "@angular/core";
8
8
  export declare class TranslatePipe implements PipeTransform, OnDestroy {
9
- protected readonly injector: Injector;
10
9
  private readonly cdr;
11
10
  private readonly translate;
12
11
  private value;
@@ -14,8 +13,8 @@ export declare class TranslatePipe implements PipeTransform, OnDestroy {
14
13
  private lastData?;
15
14
  private onChange;
16
15
  private readonly destroy$$;
17
- constructor(injector: Injector);
18
- transform(key: TranslateKey | any, data?: unknown): string;
16
+ constructor();
17
+ transform(key: TranslateKey | any, data?: TemplateData): string;
19
18
  private updateValue;
20
19
  private dispose;
21
20
  ngOnDestroy(): void;
@@ -4,59 +4,331 @@
4
4
  */
5
5
  import { HttpClient } from '@angular/common/http';
6
6
  import { OnDestroy } from '@angular/core';
7
- import { Observable, Subject } from 'rxjs';
8
- import { TranslateKey, TranslateOptions, Translation, Translations } from './types';
7
+ import { Observable } from 'rxjs';
8
+ import { TranslateKey, TranslateOptions, Translation, Translations, TemplateData } from './types';
9
9
  import * as i0 from "@angular/core";
10
+ /**
11
+ * 国际化翻译服务
12
+ *
13
+ * 特性:
14
+ * - 支持多层级翻译优先级(远程翻译 > 手动添加翻译 > 配置翻译)
15
+ * - 支持动态语言切换
16
+ * - 支持 ICU Message Format 模板插值
17
+ * - 支持宽松模式语言匹配
18
+ * - 支持异步远程翻译加载
19
+ */
10
20
  export declare class TranslateService implements OnDestroy {
11
21
  private readonly http;
12
22
  private readonly baseHref;
13
- readonly translationsAdded$: Subject<void>;
23
+ /** 翻译添加通知流 */
24
+ private readonly translationsAdded$$;
25
+ readonly translationsAdded$: Observable<void>;
26
+ /** 组件销毁通知流 */
14
27
  private readonly destroy$$;
28
+ /** 本地翻译列表(优先级:后加入的优先级更高) */
15
29
  readonly translationsList: Array<Readonly<Translations>>;
30
+ /** 远程翻译列表(优先级最高) */
16
31
  readonly remoteTranslationsList: Array<Readonly<Translations>>;
32
+ /** 翻译配置选项 */
17
33
  readonly options: TranslateOptions;
34
+ /** 当前语言环境 */
18
35
  locale: string;
36
+ /** 当前语言环境(响应式) */
19
37
  readonly locale$: Observable<string>;
38
+ /** 获取支持的语言列表 */
20
39
  get locales(): string[];
40
+ /** 获取回退语言 */
21
41
  get fallbackLocale(): string;
22
42
  constructor(http: HttpClient, baseHref: string, options: TranslateOptions, translationList: Translations[]);
43
+ /**
44
+ * 组件销毁清理
45
+ */
23
46
  ngOnDestroy(): void;
24
47
  /**
25
- * @param key - 翻译key
26
- * @param data - 根据翻译上下文数据获取翻译内容,翻译项不存在直接返回 key 文本
27
- * @param ignoreNonExist - 开发环境是否忽视不存在的翻译项
48
+ * 获取翻译文本并进行模板插值
49
+ * 自动将传统 {{ key }} 语法转换为 ICU {key} 格式进行解析
50
+ * 同时支持原生 ICU Message Format 语法
51
+ * @param key - 翻译键或翻译对象
52
+ * @param data - 模板数据(支持基本类型、Date、对象和数组)
53
+ * @returns 翻译后的文本
54
+ *
55
+ * @example
56
+ * ```typescript
57
+ * // 对象参数(推荐)
58
+ * translate.get('hello', { name: 'World' }) // 模板: "Hello {name}"
59
+ *
60
+ * // 基本类型参数(自动转换为 {value})
61
+ * translate.get('welcome', 'John') // 模板: "Welcome {value}"
62
+ *
63
+ * // ICU 格式(数字)
64
+ * translate.get('itemCount', { count: 5 })
65
+ *
66
+ * // ICU 格式(日期,默认本地化)
67
+ * translate.get('createdAt', { date: new Date() })
68
+ * ```
28
69
  */
29
- get(key: TranslateKey, data?: unknown): string;
70
+ get(key: TranslateKey, data?: TemplateData): string;
30
71
  /**
31
- * 直接返回翻译文本模板
32
- * @param key - 翻译key
33
- * @param ignoreNonExist - 开发环境是否忽视不存在的翻译项
72
+ * 获取原始翻译文本模板(不进行插值处理)
73
+ * @param key - 翻译键或翻译对象
74
+ * @returns 原始翻译模板文本
34
75
  */
35
76
  getRaw(key: TranslateKey): string;
36
77
  /**
37
- * 根据 `locales` 循环切换当前区域设置
78
+ * 切换到下一个支持的语言环境
38
79
  */
39
80
  toggleLocale(): void;
81
+ /**
82
+ * 设置当前语言环境
83
+ * @param locale - 要设置的语言环境
84
+ */
40
85
  setLocale(locale: string): void;
41
86
  /**
42
- * 手动添加语言包
87
+ * 手动添加翻译包
88
+ * @param translations - 要添加的翻译包
43
89
  */
44
90
  addTranslations(translations: Translations): void;
45
91
  /**
46
- * 手动添加语言包
92
+ * 添加远程翻译包
93
+ * @param remoteUrl - 远程翻译文件URL
47
94
  */
48
95
  addRemoteTranslations(remoteUrl: string): void;
49
96
  /**
50
- * 从远程 url 模板和区域获取翻译包
97
+ * 从远程URL获取翻译数据
98
+ * @param remoteUrl - 远程URL
99
+ * @param locale - 可选的语言环境(用于URL模板替换)
100
+ * @returns 翻译数据的Observable
51
101
  */
52
102
  fetchTranslation(remoteUrl: string): Observable<Translations>;
53
103
  fetchTranslation(remoteUrl: string, locale: string): Observable<Translation>;
54
- private _getLooseLocale;
55
- private _getValue;
56
- private _getWithFallback;
57
- private _getBase;
58
- protected _get(key: string, locale?: string): string;
59
- private _compareKeys;
104
+ /**
105
+ * 获取初始语言环境
106
+ */
107
+ private getInitialLocale;
108
+ /**
109
+ * 获取初始翻译列表
110
+ */
111
+ private getInitializeTranslations;
112
+ /**
113
+ * 加载远程翻译
114
+ */
115
+ private loadRemoteTranslations;
116
+ /**
117
+ * 转换模板数据为 ICU 兼容格式
118
+ * @param data - 模板数据
119
+ * @returns ICU 兼容的数据对象
120
+ */
121
+ private normalizeAndConvertToIcuData;
122
+ /**
123
+ * 检查是否为纯模板对象(不是数组、Date等特殊对象)
124
+ */
125
+ private isPlainTemplateObject;
126
+ /**
127
+ * 转换对象的所有属性为 ICU 兼容值
128
+ */
129
+ private convertObjectToIcuData;
130
+ /**
131
+ * 将单个值转换为 ICU 兼容类型
132
+ * 按照 ICU MessageFormat 规范,只支持 string | number | Date
133
+ */
134
+ private convertValueToIcuValue;
135
+ /**
136
+ * 处理模板错误
137
+ */
138
+ private handleTemplateError;
139
+ /**
140
+ * 将传统的 {{ key }} 语法转换为 ICU {key} 格式
141
+ * 同时保持已有的 ICU 格式不变
142
+ * @param message - 原始消息模板
143
+ * @returns 转换后的 ICU 格式消息
144
+ */
145
+ private convertToIcuFormat;
146
+ /**
147
+ * 使用 ICU message format 格式化文本
148
+ */
149
+ private formatIcuMessage;
150
+ /**
151
+ * 格式化数字
152
+ * @param value - 要格式化的数字
153
+ * @param options - 格式化选项
154
+ * @returns 格式化后的数字字符串
155
+ *
156
+ * @example
157
+ * formatNumber(1234.56) // "1,234.56"
158
+ * formatNumber(0.85, { style: 'percent' }) // "85%"
159
+ * formatNumber(1234.56, { style: 'currency', currency: 'CNY' }) // "¥1,234.56"
160
+ */
161
+ formatNumber(value: number, options?: Intl.NumberFormatOptions): string;
162
+ /**
163
+ * 格式化货币
164
+ * @param value - 要格式化的金额
165
+ * @param currency - 货币代码,默认为 CNY
166
+ * @param options - 其他格式化选项
167
+ * @returns 格式化后的货币字符串
168
+ *
169
+ * @example
170
+ * formatCurrency(1234.56) // en-US: "CN¥1,234.56", zh-CN: "¥1,234.56"
171
+ * formatCurrency(1234.56, 'USD') // en-US: "$1,234.56", zh-CN: "US$1,234.56"
172
+ */
173
+ formatCurrency(value: number, currency?: string, options?: Omit<Intl.NumberFormatOptions, 'style' | 'currency'>): string;
174
+ /**
175
+ * 格式化百分比
176
+ * @param value - 要格式化的值(0.85 表示 85%)
177
+ * @param options - 格式化选项
178
+ * @returns 格式化后的百分比字符串
179
+ *
180
+ * @example
181
+ * formatPercent(0.85) // "85%"
182
+ * formatPercent(0.8567, { minimumFractionDigits: 2 }) // "85.67%"
183
+ */
184
+ formatPercent(value: number, options?: Omit<Intl.NumberFormatOptions, 'style'>): string;
185
+ /**
186
+ * 格式化日期
187
+ * @param date - 要格式化的日期
188
+ * @param options - Intl.DateTimeFormatOptions 格式配置
189
+ * @returns 格式化后的日期字符串
190
+ *
191
+ * @example
192
+ * formatDate(new Date()) // en-US: "01/01/2025", zh-CN: "2025/01/01"
193
+ * formatDate(new Date(), { dateStyle: 'full' }) // "2024年8月20日星期二"
194
+ * formatDate(new Date(), { year: 'numeric', month: '2-digit', day: '2-digit' }) // 根据locale格式化
195
+ * formatDate(new Date(), { year: 'numeric', month: 'long' }) // "2024年8月"
196
+ */
197
+ formatDate(date: Date | string | number, options?: Intl.DateTimeFormatOptions): string;
198
+ /**
199
+ * 格式化日期和时间
200
+ * @param date - 要格式化的日期时间
201
+ * @param options - Intl.DateTimeFormatOptions 格式配置
202
+ * @returns 格式化后的日期时间字符串
203
+ *
204
+ * @example
205
+ * formatDateTime(new Date()) // en-US: "01/01/2025, 14:30:00", zh-CN: "2025/01/01 14:30:00"
206
+ * formatDateTime(new Date(), { dateStyle: 'medium', timeStyle: 'short' }) // "2024年8月20日 14:30"
207
+ * formatDateTime(new Date(), { year: 'numeric', month: '2-digit', day: '2-digit', hour: '2-digit', minute: '2-digit', second: '2-digit', hour12: false }) // 根据locale格式化
208
+ */
209
+ formatDateTime(date: Date | string | number, options?: Intl.DateTimeFormatOptions): string;
210
+ /**
211
+ * 格式化相对时间
212
+ * @param value - 时间差值(数字)或日期对象
213
+ * @param unit - 时间单位(当value为数字时必须提供)
214
+ * @param options - 格式化选项
215
+ * @returns 格式化后的相对时间字符串
216
+ *
217
+ * @example
218
+ * // 手动指定单位
219
+ * formatRelativeTime(-1, 'day') // en-US: "yesterday", zh-CN: "昨天"
220
+ * formatRelativeTime(2, 'hour') // en-US: "in 2 hours", zh-CN: "2小时后"
221
+ * formatRelativeTime(-30, 'minute') // en-US: "30 minutes ago", zh-CN: "30分钟前"
222
+ *
223
+ * // 自动计算单位
224
+ * formatRelativeTime(new Date(Date.now() - 60000)) // "1 minute ago"
225
+ * formatRelativeTime(new Date(Date.now() + 7200000)) // "in 2 hours"
226
+ * formatRelativeTime(new Date(Date.now() - 86400000)) // "yesterday"
227
+ */
228
+ formatRelativeTime(value: Date, options?: Intl.RelativeTimeFormatOptions): string;
229
+ formatRelativeTime(value: number, unit: Intl.RelativeTimeFormatUnit, options?: Intl.RelativeTimeFormatOptions): string;
230
+ /**
231
+ * 根据日期计算相对时间差值和最合适的单位
232
+ * @param date - 目标日期
233
+ * @returns 包含时间差值和单位的对象
234
+ */
235
+ private calculateRelativeTime;
236
+ /**
237
+ * 根据日期格式配置格式化日期
238
+ * 使用标准 Intl.DateTimeFormatOptions 确保格式可预测性
239
+ */
240
+ private formatDateByOptions;
241
+ /**
242
+ * 通过字符串键获取翻译
243
+ */
244
+ private getTranslationByKey;
245
+ /**
246
+ * 通过翻译对象获取翻译值
247
+ */
248
+ private getTranslationByObject;
249
+ /**
250
+ * 处理无效语言环境
251
+ */
252
+ private handleInvalidLocale;
253
+ /**
254
+ * 验证语言环境是否有效
255
+ */
256
+ private isValidLocale;
257
+ /**
258
+ * 检查重复翻译(开发模式)
259
+ */
260
+ private checkForDuplicateTranslations;
261
+ /**
262
+ * 标准化远程URL
263
+ */
264
+ private normalizeRemoteUrl;
265
+ /**
266
+ * 清理URL(移除hash片段)
267
+ */
268
+ private cleanUrl;
269
+ /**
270
+ * 验证远程URL(开发模式)
271
+ */
272
+ private validateRemoteUrl;
273
+ /**
274
+ * 创建远程翻译请求
275
+ */
276
+ private createRemoteTranslationRequest;
277
+ /**
278
+ * 创建多语言请求
279
+ */
280
+ private createMultiLocaleRequest;
281
+ /**
282
+ * 创建单语言请求
283
+ */
284
+ private createSingleLocaleRequest;
285
+ /**
286
+ * 执行翻译请求
287
+ */
288
+ private performTranslationRequest;
289
+ /**
290
+ * 验证fetchTranslation参数
291
+ */
292
+ private validateFetchTranslationParams;
293
+ /**
294
+ * 解析翻译文本
295
+ */
296
+ private resolveTranslation;
297
+ /**
298
+ * 在翻译列表中搜索
299
+ */
300
+ private searchInTranslationsList;
301
+ /**
302
+ * 在单个翻译对象中搜索
303
+ */
304
+ private searchInTranslations;
305
+ /**
306
+ * 从翻译源获取翻译值,支持扁平和嵌套两种结构
307
+ * @param source - 翻译源对象
308
+ * @param key - 翻译键(如 'a.b.c')
309
+ * @returns 翻译值或undefined
310
+ */
311
+ private getTranslationFromSource;
312
+ /**
313
+ * 获取指定语言的翻译值(处理loose模式和fallback逻辑)
314
+ */
315
+ private getTranslationValue;
316
+ /**
317
+ * 宽松模式下获取翻译值
318
+ */
319
+ private getLooseTranslationValue;
320
+ /**
321
+ * 提取宽松语言代码(如:zh-CN -> zh)
322
+ */
323
+ private extractLooseLocale;
324
+ /**
325
+ * 验证翻译值(开发模式)
326
+ */
327
+ private validateTranslationValue;
328
+ /**
329
+ * 比较翻译键(开发模式下检查重复)
330
+ */
331
+ private compareTranslationKeys;
60
332
  static ɵfac: i0.ɵɵFactoryDeclaration<TranslateService, [null, null, { optional: true; }, { optional: true; }]>;
61
333
  static ɵprov: i0.ɵɵInjectableDeclaration<TranslateService>;
62
334
  }
@@ -9,6 +9,22 @@ export interface Translation {
9
9
  }
10
10
  export type Translations = Record<string, Translation>;
11
11
  export type TranslateKey = string | Translation;
12
+ /**
13
+ * 模板插值数据类型
14
+ * 参考主流 i18n 库的类型定义
15
+ */
16
+ export type TemplateData = string | number | boolean | Date | null | undefined | TemplateDataObject | TemplateData[] | unknown;
17
+ export interface TemplateDataObject {
18
+ [key: string]: TemplateData;
19
+ }
20
+ /**
21
+ * ICU 兼容的简化数据类型
22
+ * ICU MessageFormat 原生支持的数据类型
23
+ */
24
+ export type IcuValue = string | number | Date;
25
+ export interface IcuData {
26
+ [key: string]: IcuValue;
27
+ }
12
28
  export interface TranslateOptions {
13
29
  locale?: string;
14
30
  fallbackLocale?: string;
@@ -1,61 +0,0 @@
1
- import { HttpClient } from '@angular/common/http';
2
- import { OnInit, OnChanges, SimpleChanges, EventEmitter, ChangeDetectorRef } from '@angular/core';
3
- import { KubernetesSchemaService } from '../../../core/services/kubernetes-schema.service';
4
- import { KubernetesResource } from '../../../core/types/k8s/core';
5
- import { OpenAPIV3SchemaObject } from '../../../core/types/schema';
6
- import * as i0 from "@angular/core";
7
- interface YamlExample {
8
- title: string;
9
- description: string;
10
- yaml: string;
11
- snippet?: boolean;
12
- }
13
- export declare class ResourceYamlSchemaComponent implements OnInit, OnChanges {
14
- private schemaService;
15
- private http;
16
- private cdr;
17
- resource: KubernetesResource;
18
- schema: OpenAPIV3SchemaObject;
19
- close: EventEmitter<void>;
20
- tryYaml: EventEmitter<string>;
21
- private readonly DEFINITIONS_PREFIX;
22
- currentSchema: OpenAPIV3SchemaObject;
23
- properties: {
24
- [key: string]: OpenAPIV3SchemaObject;
25
- };
26
- path: string[];
27
- resourceKind: string;
28
- examples: YamlExample[];
29
- hasSchema: boolean;
30
- hasExamples: boolean;
31
- private readonly builtInExamples;
32
- constructor(schemaService: KubernetesSchemaService, http: HttpClient, cdr: ChangeDetectorRef);
33
- ngOnInit(): void;
34
- ngOnChanges(changes: SimpleChanges): void;
35
- refresh(): void;
36
- private loadExamples;
37
- private loadConsoleYAMLSamples;
38
- drilldownToProperty(name: string): void;
39
- navigateToPath(index: number): void;
40
- hasNestedProperties(property: OpenAPIV3SchemaObject): boolean;
41
- getPropertyType(property: OpenAPIV3SchemaObject): string;
42
- isRequired(propertyName: string): boolean;
43
- /**
44
- * 检查属性是否有 $ref 引用或嵌套属性
45
- */
46
- hasViewableContent(property: OpenAPIV3SchemaObject): boolean;
47
- /**
48
- * 检查属性是否有 $ref 引用
49
- */
50
- hasRefProperty(property: OpenAPIV3SchemaObject): boolean;
51
- /**
52
- * 获取 $ref 引用的定义名称
53
- */
54
- getRefDefinitionName(property: OpenAPIV3SchemaObject): string;
55
- tryExample(example: YamlExample): void;
56
- downloadYaml(example: YamlExample): void;
57
- processDescription(description: string): string;
58
- static ɵfac: i0.ɵɵFactoryDeclaration<ResourceYamlSchemaComponent, never>;
59
- static ɵcmp: i0.ɵɵComponentDeclaration<ResourceYamlSchemaComponent, "acl-resource-yaml-schema", never, { "resource": { "alias": "resource"; "required": false; }; "schema": { "alias": "schema"; "required": false; }; }, { "close": "close"; "tryYaml": "tryYaml"; }, never, never, true, never>;
60
- }
61
- export {};
@@ -1,8 +0,0 @@
1
- import { YamlExample } from './types';
2
- /**
3
- * Kubernetes 资源的内置 YAML 示例
4
- * 按照 apiVersion.kind 的格式组织
5
- */
6
- export declare const BUILT_IN_YAML_EXAMPLES: {
7
- [key: string]: YamlExample[];
8
- };