rayyy-vue-table-components 2.0.12 → 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.
- package/dist/index.es.js +3580 -3512
- package/dist/index.umd.js +8 -8
- package/dist/src/index.d.ts +1 -1
- package/dist/src/utils/i18n.d.ts +182 -0
- package/package.json +1 -1
- package/src/components/layout/SearchableListPanel.vue +17 -11
- package/src/utils/i18n.ts +36 -0
package/dist/src/index.d.ts
CHANGED
|
@@ -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, useElementLocale } 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';
|
package/dist/src/utils/i18n.d.ts
CHANGED
|
@@ -200,4 +200,186 @@ export declare function useElementLocale(): import('vue').ComputedRef<{
|
|
|
200
200
|
};
|
|
201
201
|
};
|
|
202
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
|
+
}>;
|
|
203
385
|
export type { I18n, Composer };
|
package/package.json
CHANGED
|
@@ -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
|
-
|
|
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-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
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
|
@@ -122,6 +122,42 @@ export function useElementLocale() {
|
|
|
122
122
|
})
|
|
123
123
|
}
|
|
124
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
|
+
|
|
125
161
|
// 導出類型
|
|
126
162
|
export type { I18n, Composer }
|
|
127
163
|
|