rayyy-vue-table-components 2.0.10 → 2.0.12

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.
@@ -8,7 +8,7 @@ import { default as TitleTable } from './components/tables/TitleTable.vue';
8
8
  import { default as SearchBar } from './components/items/SearchBar.vue';
9
9
  export * from './types';
10
10
  export * from './utils/tableHelper';
11
- export { useI18n, setLocale } from './utils/i18n';
11
+ export { useI18n, setLocale, useElementLocale } from './utils/i18n';
12
12
  export * from './locales';
13
13
  export { BaseTable, BaseBtn, BaseInput, BaseDialog, SortTable, TitleTable, SearchBar };
14
14
  export type { BaseTableProps, BaseTableEmits, BaseTableInstance, BaseBtnProps, BaseBtnEmits, BaseBtnInstance, BaseDialogProps, BaseDialogEmits, BaseDialogInstance, PluginOptions, VueTableComponentsPlugin, } from './types/components';
@@ -18,4 +18,186 @@ export declare function useComponentI18n(): {
18
18
  * 全域 i18n 實例(用於非組件環境)
19
19
  */
20
20
  export declare function useI18n(): Composer;
21
+ /**
22
+ * Element Plus locale composable
23
+ * 返回響應式的 Element Plus locale 對象
24
+ */
25
+ export declare function useElementLocale(): import('vue').ComputedRef<{
26
+ name: string;
27
+ el: {
28
+ breadcrumb: {
29
+ label: string;
30
+ };
31
+ colorpicker: {
32
+ confirm: string;
33
+ clear: string;
34
+ defaultLabel: string;
35
+ description: string;
36
+ alphaLabel: string;
37
+ };
38
+ datepicker: {
39
+ now: string;
40
+ today: string;
41
+ cancel: string;
42
+ clear: string;
43
+ confirm: string;
44
+ dateTablePrompt: string;
45
+ monthTablePrompt: string;
46
+ yearTablePrompt: string;
47
+ selectedDate: string;
48
+ selectDate: string;
49
+ selectTime: string;
50
+ startDate: string;
51
+ startTime: string;
52
+ endDate: string;
53
+ endTime: string;
54
+ prevYear: string;
55
+ nextYear: string;
56
+ prevMonth: string;
57
+ nextMonth: string;
58
+ year: string;
59
+ month1: string;
60
+ month2: string;
61
+ month3: string;
62
+ month4: string;
63
+ month5: string;
64
+ month6: string;
65
+ month7: string;
66
+ month8: string;
67
+ month9: string;
68
+ month10: string;
69
+ month11: string;
70
+ month12: string;
71
+ weeks: {
72
+ sun: string;
73
+ mon: string;
74
+ tue: string;
75
+ wed: string;
76
+ thu: string;
77
+ fri: string;
78
+ sat: string;
79
+ };
80
+ weeksFull: {
81
+ sun: string;
82
+ mon: string;
83
+ tue: string;
84
+ wed: string;
85
+ thu: string;
86
+ fri: string;
87
+ sat: string;
88
+ };
89
+ months: {
90
+ jan: string;
91
+ feb: string;
92
+ mar: string;
93
+ apr: string;
94
+ may: string;
95
+ jun: string;
96
+ jul: string;
97
+ aug: string;
98
+ sep: string;
99
+ oct: string;
100
+ nov: string;
101
+ dec: string;
102
+ };
103
+ };
104
+ inputNumber: {
105
+ decrease: string;
106
+ increase: string;
107
+ };
108
+ select: {
109
+ loading: string;
110
+ noMatch: string;
111
+ noData: string;
112
+ placeholder: string;
113
+ };
114
+ mention: {
115
+ loading: string;
116
+ };
117
+ dropdown: {
118
+ toggleDropdown: string;
119
+ };
120
+ cascader: {
121
+ noMatch: string;
122
+ loading: string;
123
+ placeholder: string;
124
+ noData: string;
125
+ };
126
+ pagination: {
127
+ goto: string;
128
+ pagesize: string;
129
+ total: string;
130
+ pageClassifier: string;
131
+ page: string;
132
+ prev: string;
133
+ next: string;
134
+ currentPage: string;
135
+ prevPages: string;
136
+ nextPages: string;
137
+ deprecationWarning: string;
138
+ };
139
+ dialog: {
140
+ close: string;
141
+ };
142
+ drawer: {
143
+ close: string;
144
+ };
145
+ messagebox: {
146
+ title: string;
147
+ confirm: string;
148
+ cancel: string;
149
+ error: string;
150
+ close: string;
151
+ };
152
+ upload: {
153
+ deleteTip: string;
154
+ delete: string;
155
+ preview: string;
156
+ continue: string;
157
+ };
158
+ slider: {
159
+ defaultLabel: string;
160
+ defaultRangeStartLabel: string;
161
+ defaultRangeEndLabel: string;
162
+ };
163
+ table: {
164
+ emptyText: string;
165
+ confirmFilter: string;
166
+ resetFilter: string;
167
+ clearFilter: string;
168
+ sumText: string;
169
+ };
170
+ tour: {
171
+ next: string;
172
+ previous: string;
173
+ finish: string;
174
+ };
175
+ tree: {
176
+ emptyText: string;
177
+ };
178
+ transfer: {
179
+ noMatch: string;
180
+ noData: string;
181
+ titles: string[];
182
+ filterPlaceholder: string;
183
+ noCheckedFormat: string;
184
+ hasCheckedFormat: string;
185
+ };
186
+ image: {
187
+ error: string;
188
+ };
189
+ pageHeader: {
190
+ title: string;
191
+ };
192
+ popconfirm: {
193
+ confirmButtonText: string;
194
+ cancelButtonText: string;
195
+ };
196
+ carousel: {
197
+ leftArrow: string;
198
+ rightArrow: string;
199
+ indicator: string;
200
+ };
201
+ };
202
+ }>;
21
203
  export type { I18n, Composer };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "rayyy-vue-table-components",
3
- "version": "2.0.10",
3
+ "version": "2.0.12",
4
4
  "description": "Vue 3 + Element Plus 表格組件庫",
5
5
  "type": "module",
6
6
  "main": "./dist/index.umd.js",
@@ -1,5 +1,3 @@
1
- // 導入 Element Plus 配置
2
- //@use 'element-plus/theme-chalk/src/mixins/config.scss' as *;
3
1
 
4
2
  // 聲明變數
5
3
  $namespace: 'ep';
@@ -4,6 +4,9 @@
4
4
  @use "dialogs";
5
5
  @use "components";
6
6
 
7
+ // 導入 Element Plus 樣式
8
+ @use "element";
9
+
7
10
  @tailwind base;
8
11
  @tailwind components;
9
12
  @tailwind utilities;
package/src/utils/i18n.ts CHANGED
@@ -1,6 +1,8 @@
1
1
  import { createI18n, type I18n, type Composer } from 'vue-i18n'
2
2
  import { getCurrentInstance, computed } from 'vue'
3
3
  import { messages } from '../locales'
4
+ import zhTw from 'element-plus/es/locale/lang/zh-tw'
5
+ import enUs from 'element-plus/es/locale/lang/en'
4
6
 
5
7
  // 內部 i18n 實例
6
8
  let internalI18n: I18n | null = null
@@ -84,6 +86,42 @@ export function useI18n() {
84
86
  return i18n.global as Composer
85
87
  }
86
88
 
89
+ /**
90
+ * Element Plus locale composable
91
+ * 返回響應式的 Element Plus locale 對象
92
+ */
93
+ export function useElementLocale() {
94
+ const instance = getCurrentInstance()
95
+
96
+ // 嘗試取得外部專案的 i18n(支援 Composition API 模式)
97
+ let externalI18n: Composer | undefined
98
+ try {
99
+ const globalProperties = instance?.appContext.config.globalProperties
100
+ const externalI18nInstance = globalProperties?.$i18n as I18n | undefined
101
+
102
+ // 如果是 I18n 實例,取得其 global 屬性
103
+ if (externalI18nInstance && 'global' in externalI18nInstance) {
104
+ externalI18n = externalI18nInstance.global as Composer
105
+ }
106
+ } catch (e) {
107
+ // 如果取得失敗,繼續使用內部 i18n
108
+ externalI18n = undefined
109
+ }
110
+
111
+ // 取得內部 i18n
112
+ const internalI18nInstance = getInternalI18n()
113
+ const internalGlobal = internalI18nInstance.global as Composer
114
+
115
+ // 如果存在外部 i18n,優先使用外部的,否則使用內部的
116
+ const currentI18n = externalI18n || internalGlobal
117
+
118
+ // 返回響應式的 Element Plus locale
119
+ return computed(() => {
120
+ const locale = currentI18n.locale.value
121
+ return locale === 'zh-TW' ? zhTw : enUs
122
+ })
123
+ }
124
+
87
125
  // 導出類型
88
126
  export type { I18n, Composer }
89
127