rayyy-vue-table-components 2.0.11 → 2.0.13

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, useComponentElementLocale } 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,368 @@ 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
+ }>;
203
+ /**
204
+ * 組件庫內部使用的 Element Plus locale composable
205
+ * 專門用於組件庫內部的 Element Plus 組件
206
+ */
207
+ export declare function useComponentElementLocale(): import('vue').ComputedRef<{
208
+ name: string;
209
+ el: {
210
+ breadcrumb: {
211
+ label: string;
212
+ };
213
+ colorpicker: {
214
+ confirm: string;
215
+ clear: string;
216
+ defaultLabel: string;
217
+ description: string;
218
+ alphaLabel: string;
219
+ };
220
+ datepicker: {
221
+ now: string;
222
+ today: string;
223
+ cancel: string;
224
+ clear: string;
225
+ confirm: string;
226
+ dateTablePrompt: string;
227
+ monthTablePrompt: string;
228
+ yearTablePrompt: string;
229
+ selectedDate: string;
230
+ selectDate: string;
231
+ selectTime: string;
232
+ startDate: string;
233
+ startTime: string;
234
+ endDate: string;
235
+ endTime: string;
236
+ prevYear: string;
237
+ nextYear: string;
238
+ prevMonth: string;
239
+ nextMonth: string;
240
+ year: string;
241
+ month1: string;
242
+ month2: string;
243
+ month3: string;
244
+ month4: string;
245
+ month5: string;
246
+ month6: string;
247
+ month7: string;
248
+ month8: string;
249
+ month9: string;
250
+ month10: string;
251
+ month11: string;
252
+ month12: string;
253
+ weeks: {
254
+ sun: string;
255
+ mon: string;
256
+ tue: string;
257
+ wed: string;
258
+ thu: string;
259
+ fri: string;
260
+ sat: string;
261
+ };
262
+ weeksFull: {
263
+ sun: string;
264
+ mon: string;
265
+ tue: string;
266
+ wed: string;
267
+ thu: string;
268
+ fri: string;
269
+ sat: string;
270
+ };
271
+ months: {
272
+ jan: string;
273
+ feb: string;
274
+ mar: string;
275
+ apr: string;
276
+ may: string;
277
+ jun: string;
278
+ jul: string;
279
+ aug: string;
280
+ sep: string;
281
+ oct: string;
282
+ nov: string;
283
+ dec: string;
284
+ };
285
+ };
286
+ inputNumber: {
287
+ decrease: string;
288
+ increase: string;
289
+ };
290
+ select: {
291
+ loading: string;
292
+ noMatch: string;
293
+ noData: string;
294
+ placeholder: string;
295
+ };
296
+ mention: {
297
+ loading: string;
298
+ };
299
+ dropdown: {
300
+ toggleDropdown: string;
301
+ };
302
+ cascader: {
303
+ noMatch: string;
304
+ loading: string;
305
+ placeholder: string;
306
+ noData: string;
307
+ };
308
+ pagination: {
309
+ goto: string;
310
+ pagesize: string;
311
+ total: string;
312
+ pageClassifier: string;
313
+ page: string;
314
+ prev: string;
315
+ next: string;
316
+ currentPage: string;
317
+ prevPages: string;
318
+ nextPages: string;
319
+ deprecationWarning: string;
320
+ };
321
+ dialog: {
322
+ close: string;
323
+ };
324
+ drawer: {
325
+ close: string;
326
+ };
327
+ messagebox: {
328
+ title: string;
329
+ confirm: string;
330
+ cancel: string;
331
+ error: string;
332
+ close: string;
333
+ };
334
+ upload: {
335
+ deleteTip: string;
336
+ delete: string;
337
+ preview: string;
338
+ continue: string;
339
+ };
340
+ slider: {
341
+ defaultLabel: string;
342
+ defaultRangeStartLabel: string;
343
+ defaultRangeEndLabel: string;
344
+ };
345
+ table: {
346
+ emptyText: string;
347
+ confirmFilter: string;
348
+ resetFilter: string;
349
+ clearFilter: string;
350
+ sumText: string;
351
+ };
352
+ tour: {
353
+ next: string;
354
+ previous: string;
355
+ finish: string;
356
+ };
357
+ tree: {
358
+ emptyText: string;
359
+ };
360
+ transfer: {
361
+ noMatch: string;
362
+ noData: string;
363
+ titles: string[];
364
+ filterPlaceholder: string;
365
+ noCheckedFormat: string;
366
+ hasCheckedFormat: string;
367
+ };
368
+ image: {
369
+ error: string;
370
+ };
371
+ pageHeader: {
372
+ title: string;
373
+ };
374
+ popconfirm: {
375
+ confirmButtonText: string;
376
+ cancelButtonText: string;
377
+ };
378
+ carousel: {
379
+ leftArrow: string;
380
+ rightArrow: string;
381
+ indicator: string;
382
+ };
383
+ };
384
+ }>;
21
385
  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.11",
3
+ "version": "2.0.13",
4
4
  "description": "Vue 3 + Element Plus 表格組件庫",
5
5
  "type": "module",
6
6
  "main": "./dist/index.umd.js",
@@ -2,6 +2,7 @@
2
2
  import { toRefs, computed } from 'vue'
3
3
  import type { Pager } from '@/types'
4
4
  import { MainPanel, SearchBar } from '@/components'
5
+ import { useComponentElementLocale } from '@/utils/i18n'
5
6
 
6
7
  const props = withDefaults(
7
8
  defineProps<{
@@ -48,9 +49,12 @@ const showPager = computed(() => {
48
49
  if (props.showPagination) {
49
50
  return props.showPagination
50
51
  } else {
51
- return props.pagination.totalCount > 0
52
+ return props.pagination.totalCount > 0
52
53
  }
53
54
  })
55
+
56
+ // 取得響應式的 Element Plus locale
57
+ const elementLocale = useComponentElementLocale()
54
58
  </script>
55
59
 
56
60
  <template>
@@ -72,16 +76,18 @@ const showPager = computed(() => {
72
76
  </template>
73
77
 
74
78
  <template #footer>
75
- <el-pagination
76
- v-if="showPager"
77
- layout="jumper, prev, pager, next, total, sizes"
78
- :page-sizes="pageSizeList"
79
- :current-page="pagination.page"
80
- :page-size="pagination.limit"
81
- :total="pagination.totalCount"
82
- @current-change="updatePage"
83
- @size-change="changePageSize"
84
- />
79
+ <el-config-provider :locale="elementLocale">
80
+ <el-pagination
81
+ v-if="showPager"
82
+ layout="jumper, prev, pager, next, total, sizes"
83
+ :page-sizes="pageSizeList"
84
+ :current-page="pagination.page"
85
+ :page-size="pagination.limit"
86
+ :total="pagination.totalCount"
87
+ @current-change="updatePage"
88
+ @size-change="changePageSize"
89
+ />
90
+ </el-config-provider>
85
91
  </template>
86
92
  </main-panel>
87
93
  </template>
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,78 @@ 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
+
125
+ /**
126
+ * 組件庫內部使用的 Element Plus locale composable
127
+ * 專門用於組件庫內部的 Element Plus 組件
128
+ */
129
+ export function useComponentElementLocale() {
130
+ const instance = getCurrentInstance()
131
+
132
+ // 嘗試取得外部專案的 i18n(支援 Composition API 模式)
133
+ let externalI18n: Composer | undefined
134
+ try {
135
+ const globalProperties = instance?.appContext.config.globalProperties
136
+ const externalI18nInstance = globalProperties?.$i18n as I18n | undefined
137
+
138
+ // 如果是 I18n 實例,取得其 global 屬性
139
+ if (externalI18nInstance && 'global' in externalI18nInstance) {
140
+ externalI18n = externalI18nInstance.global as Composer
141
+ }
142
+ } catch (e) {
143
+ // 如果取得失敗,繼續使用內部 i18n
144
+ externalI18n = undefined
145
+ }
146
+
147
+ // 取得內部 i18n
148
+ const internalI18nInstance = getInternalI18n()
149
+ const internalGlobal = internalI18nInstance.global as Composer
150
+
151
+ // 如果存在外部 i18n,優先使用外部的,否則使用內部的
152
+ const currentI18n = externalI18n || internalGlobal
153
+
154
+ // 返回響應式的 Element Plus locale
155
+ return computed(() => {
156
+ const locale = currentI18n.locale.value
157
+ return locale === 'zh-TW' ? zhTw : enUs
158
+ })
159
+ }
160
+
87
161
  // 導出類型
88
162
  export type { I18n, Composer }
89
163