rayyy-vue-table-components 2.0.34 → 2.0.36

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.
@@ -1,6 +1,7 @@
1
1
  import { VNode } from 'vue';
2
2
  import { TableColumnCtx } from 'element-plus';
3
3
  import { SortChangValue, TableColumn } from '../../types';
4
+ import { Language } from 'element-plus/es/locale';
4
5
  declare const _default: <T extends Record<string, unknown> = Record<string, unknown>>(__VLS_props: NonNullable<Awaited<typeof __VLS_setup>>["props"], __VLS_ctx?: __VLS_PrettifyLocal<Pick<NonNullable<Awaited<typeof __VLS_setup>>, "attrs" | "emit" | "slots">>, __VLS_expose?: NonNullable<Awaited<typeof __VLS_setup>>["expose"], __VLS_setup?: Promise<{
5
6
  props: __VLS_PrettifyLocal<Pick<Partial<{}> & Omit<{
6
7
  readonly "onSelection-change"?: ((selection: T[]) => any) | undefined;
@@ -26,6 +27,7 @@ declare const _default: <T extends Record<string, unknown> = Record<string, unkn
26
27
  }) => string) | undefined;
27
28
  showCheckBtn?: boolean;
28
29
  showEditBtn?: boolean;
30
+ locale?: Language;
29
31
  } & Partial<{}>> & import('vue').PublicProps;
30
32
  expose(exposed: import('vue').ShallowUnwrapRef<{}>): void;
31
33
  attrs: any;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "rayyy-vue-table-components",
3
- "version": "2.0.34",
3
+ "version": "2.0.36",
4
4
  "description": "Vue 3 + Element Plus 表格組件庫",
5
5
  "type": "module",
6
6
  "main": "./dist/index.umd.js",
@@ -4,6 +4,8 @@ import { computed } from 'vue'
4
4
  import { useI18n } from 'vue-i18n'
5
5
  import type { TableColumnCtx } from 'element-plus'
6
6
  import type { SortChangValue, TableColumn } from '@/types'
7
+ import type { Language } from 'element-plus/es/locale'
8
+ import { useComponentElementLocale } from '@/utils/i18n'
7
9
 
8
10
  const { t } = useI18n()
9
11
 
@@ -21,6 +23,7 @@ type Props<T extends Record<string, unknown> = Record<string, unknown>> = {
21
23
  baseTableRowClassName?: (data: { row: T; rowIndex: number }) => string
22
24
  showCheckBtn?: boolean
23
25
  showEditBtn?: boolean
26
+ locale?: Language // 新增:Element Plus locale
24
27
  }
25
28
 
26
29
  // 組件屬性默認值
@@ -77,10 +80,20 @@ const operatorWidth = computed(() => {
77
80
  return 60
78
81
  }
79
82
  })
83
+
84
+ // 優先使用 prop,沒有 prop 則使用 composable
85
+ const elementLocale = computed(() => {
86
+ if (props.locale) {
87
+ return props.locale
88
+ }
89
+ // 回退:使用簡化的 composable
90
+ return useComponentElementLocale().value
91
+ })
80
92
  </script>
81
93
 
82
94
  <template>
83
95
  <el-table
96
+ v-if="data.length > 0"
84
97
  v-loading="loading"
85
98
  :element-loading-text="t('common.loading')"
86
99
  :data="data"
@@ -144,6 +157,7 @@ const operatorWidth = computed(() => {
144
157
  </template>
145
158
  </el-table-column>
146
159
  </el-table>
160
+ <el-empty v-else :locale="elementLocale" />
147
161
  </template>
148
162
 
149
163
  <style scoped lang="scss"></style>
@@ -1,11 +1,10 @@
1
1
  <script setup lang="ts" generic="T extends Record<string, unknown>">
2
2
  import type { SortChangValue, TableColumn } from '@/types'
3
3
  import type { TableColumnCtx } from 'element-plus'
4
- import { reactive, type VNode } from 'vue'
4
+ import { reactive, type VNode } from 'vue'
5
5
  import { Setting } from '@element-plus/icons-vue'
6
6
  import { BaseTable } from '@/components'
7
7
 
8
-
9
8
  defineProps<{
10
9
  data: T[]
11
10
  columns: TableColumn<T>[]