@byan99/vue-base-table 0.1.0 → 0.2.0

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/README.md CHANGED
@@ -1,20 +1,28 @@
1
1
  # @byan99/vue-base-table
2
2
 
3
- 基于 Vue 3 + TypeScript 的可复用表格组件。
3
+ 基于 Vue 3 + Element Plus + TypeScript 的可复用表格组件。
4
4
 
5
5
  ## 安装
6
6
 
7
7
  ```bash
8
- npm install @byan99/vue-base-table
8
+ npm install @byan99/vue-base-table element-plus
9
9
  ```
10
10
 
11
11
  ## 使用
12
12
 
13
+ 在入口文件中注册 Element Plus 并引入样式:
14
+
15
+ ```ts
16
+ import ElementPlus from 'element-plus'
17
+ import 'element-plus/dist/index.css'
18
+
19
+ app.use(ElementPlus)
20
+ ```
21
+
13
22
  ```vue
14
23
  <script setup lang="ts">
15
24
  import { BaseTable } from '@byan99/vue-base-table'
16
25
  import type { TableColumn } from '@byan99/vue-base-table'
17
- import '@byan99/vue-base-table/style.css'
18
26
 
19
27
  interface UserRow {
20
28
  id: number
package/dist/index.css CHANGED
@@ -1,2 +1,2 @@
1
- .table-wrapper[data-v-c67b71ed]{border-radius:8px;width:100%;overflow-x:auto}.table-wrapper--bordered[data-v-c67b71ed]{border:1px solid var(--border)}.base-table[data-v-c67b71ed]{border-collapse:collapse;text-align:left;width:100%;font-size:15px}.base-table th[data-v-c67b71ed],.base-table td[data-v-c67b71ed]{border-bottom:1px solid var(--border);padding:12px 16px}.base-table th[data-v-c67b71ed]{color:var(--text-h);background:var(--code-bg);font-weight:500}.base-table td[data-v-c67b71ed]{color:var(--text)}.base-table tbody tr:last-child td[data-v-c67b71ed]{border-bottom:none}.base-table--stripe tbody tr[data-v-c67b71ed]:nth-child(2n){background:var(--social-bg)}.base-table tbody tr:hover td[data-v-c67b71ed]{background:var(--accent-bg)}.base-table__state[data-v-c67b71ed]{text-align:center;color:var(--text);padding:32px 16px}
1
+ .base-table[data-v-7d862b68]{width:100%}
2
2
  /*$vite$:1*/
package/dist/index.js CHANGED
@@ -1,6 +1,8 @@
1
- import { Fragment as e, createElementBlock as t, createElementVNode as n, createTextVNode as r, defineComponent as i, normalizeClass as a, normalizeStyle as o, openBlock as s, renderList as c, renderSlot as l, toDisplayString as u } from "vue";
2
- //#region src/components/Table/BaseTable.vue?vue&type=script&setup=true&lang.ts
3
- var d = { key: 0 }, f = ["colspan"], p = { key: 1 }, m = ["colspan"], h = /*#__PURE__*/ ((e, t) => {
1
+ import { Fragment as e, createBlock as t, createElementBlock as n, createTextVNode as r, defineComponent as i, openBlock as a, renderList as o, renderSlot as s, toDisplayString as c, unref as l, withCtx as u } from "vue";
2
+ import { ElTable as d, ElTableColumn as f } from "element-plus";
3
+ //#endregion
4
+ //#region src/components/Table/BaseTable.vue
5
+ var p = /*#__PURE__*/ ((e, t) => {
4
6
  let n = e.__vccOpts || e;
5
7
  for (let [e, r] of t) n[e] = r;
6
8
  return n;
@@ -15,30 +17,45 @@ var d = { key: 0 }, f = ["colspan"], p = { key: 1 }, m = ["colspan"], h = /*#__P
15
17
  bordered: { type: Boolean }
16
18
  },
17
19
  setup(i) {
18
- function h(e, t) {
20
+ function p(e, t) {
19
21
  let n = e[t];
20
22
  return n == null ? "" : String(n);
21
23
  }
22
- return (g, _) => (s(), t("div", { class: a(["table-wrapper", { "table-wrapper--bordered": i.bordered }]) }, [n("table", { class: a(["base-table", { "base-table--stripe": i.stripe }]) }, [n("thead", null, [n("tr", null, [(s(!0), t(e, null, c(i.columns, (e) => (s(), t("th", {
23
- key: e.key,
24
- style: o({
24
+ return (m, h) => (a(), t(l(d), {
25
+ class: "base-table",
26
+ data: i.data,
27
+ stripe: i.stripe,
28
+ border: i.bordered,
29
+ loading: i.loading,
30
+ "empty-text": i.emptyText ?? "暂无数据"
31
+ }, {
32
+ default: u(() => [(a(!0), n(e, null, o(i.columns, (e) => (a(), t(l(f), {
33
+ key: e.key,
34
+ prop: e.key,
35
+ label: e.label,
25
36
  width: e.width,
26
- textAlign: e.align ?? "left"
27
- })
28
- }, u(e.label), 5))), 128))])]), n("tbody", null, [i.loading ? (s(), t("tr", d, [n("td", {
29
- colspan: i.columns.length,
30
- class: "base-table__state"
31
- }, " 加载中... ", 8, f)])) : i.data.length ? (s(!0), t(e, { key: 2 }, c(i.data, (n, a) => (s(), t("tr", { key: a }, [(s(!0), t(e, null, c(i.columns, (e) => (s(), t("td", {
32
- key: e.key,
33
- style: o({ textAlign: e.align ?? "left" })
34
- }, [l(g.$slots, e.key, {
35
- row: n,
36
- value: n[e.key]
37
- }, () => [r(u(h(n, e.key)), 1)], !0)], 4))), 128))]))), 128)) : (s(), t("tr", p, [n("td", {
38
- colspan: i.columns.length,
39
- class: "base-table__state"
40
- }, u(i.emptyText ?? "暂无数据"), 9, m)]))])], 2)], 2));
37
+ align: e.align ?? "left"
38
+ }, {
39
+ default: u(({ row: t }) => [s(m.$slots, e.key, {
40
+ row: t,
41
+ value: t[e.key]
42
+ }, () => [r(c(p(t, e.key)), 1)], !0)]),
43
+ _: 2
44
+ }, 1032, [
45
+ "prop",
46
+ "label",
47
+ "width",
48
+ "align"
49
+ ]))), 128))]),
50
+ _: 3
51
+ }, 8, [
52
+ "data",
53
+ "stripe",
54
+ "border",
55
+ "loading",
56
+ "empty-text"
57
+ ]));
41
58
  }
42
- }), [["__scopeId", "data-v-c67b71ed"]]);
59
+ }), [["__scopeId", "data-v-7d862b68"]]);
43
60
  //#endregion
44
- export { h as BaseTable };
61
+ export { p as BaseTable };
@@ -11,8 +11,8 @@ declare const _default: <T extends object>(__VLS_props: NonNullable<Awaited<type
11
11
  expose(exposed: import('vue').ShallowUnwrapRef<{}>): void;
12
12
  attrs: any;
13
13
  slots: Partial<Record<NonNullable<keyof T & string>, (_: {
14
- row: T;
15
- value: T[keyof T & string];
14
+ row: import('element-plus/es/components/table/src/table/defaults.mjs').DefaultRow;
15
+ value: import('element-plus/es/components/table/src/table/defaults.mjs').DefaultRow[keyof T & string];
16
16
  }) => any>>;
17
17
  emit: {};
18
18
  }>) => import('vue').VNode & {
package/package.json CHANGED
@@ -1,15 +1,19 @@
1
1
  {
2
2
  "name": "@byan99/vue-base-table",
3
- "version": "0.1.0",
4
- "description": "A reusable Vue 3 table component with TypeScript support",
3
+ "version": "0.2.0",
4
+ "description": "A reusable Vue 3 table component based on Element Plus with TypeScript support",
5
5
  "type": "module",
6
6
  "keywords": [
7
7
  "vue",
8
8
  "vue3",
9
9
  "table",
10
10
  "component",
11
- "typescript"
11
+ "typescript",
12
+ "element-plus"
12
13
  ],
14
+ "publishConfig": {
15
+ "access": "public"
16
+ },
13
17
  "license": "MIT",
14
18
  "author": "byan99",
15
19
  "repository": {
@@ -42,12 +46,14 @@
42
46
  "prepublishOnly": "npm run build:lib"
43
47
  },
44
48
  "peerDependencies": {
49
+ "element-plus": "^2.9.0",
45
50
  "vue": "^3.5.0"
46
51
  },
47
52
  "devDependencies": {
48
53
  "@types/node": "^24.13.2",
49
54
  "@vitejs/plugin-vue": "^6.0.7",
50
55
  "@vue/tsconfig": "^0.9.1",
56
+ "element-plus": "^2.14.2",
51
57
  "typescript": "~6.0.2",
52
58
  "vite": "^8.1.1",
53
59
  "vite-plugin-dts": "^4.5.4",