@ysgroup/ui 0.1.15 → 0.1.16

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ysgroup/ui",
3
- "version": "0.1.15",
3
+ "version": "0.1.16",
4
4
  "type": "module",
5
5
  "main": "src/index.ts",
6
6
  "types": "src/index.ts",
@@ -7,6 +7,7 @@ import { FIELD_SPECS, ENUM_META } from "@ysgroup/contracts";
7
7
  import { enumLabel } from "../tokens-runtime";
8
8
  import YsFormDialog from "./YsFormDialog.vue";
9
9
  import YsRowActionMenu from "./YsRowActionMenu.vue";
10
+ import YsTableToolbar from "./YsTableToolbar.vue";
10
11
 
11
12
  interface FieldSpec {
12
13
  key: string;
@@ -95,11 +96,7 @@ const filtered = computed(() => {
95
96
  const kw = keyword.value.trim().toLowerCase();
96
97
  if (!kw) return props.rows;
97
98
  return props.rows.filter((r) =>
98
- displayColumns.value.some((c) =>
99
- String(r[c.key] ?? "")
100
- .toLowerCase()
101
- .includes(kw),
102
- ),
99
+ displayColumns.value.some((c) => display(r, c).toLowerCase().includes(kw)),
103
100
  );
104
101
  });
105
102
 
@@ -159,11 +156,9 @@ function onSubmit(payload: Record<string, unknown>) {
159
156
 
160
157
  <template>
161
158
  <div class="ys-crud">
162
- <div class="ys-crud__toolbar">
163
- <el-input v-model="keyword" placeholder="搜索" clearable style="width: 200px" />
164
- <div class="ys-crud__spacer" />
165
- <el-button v-if="!readonly" type="primary" @click="onCreate">{{ createLabel || "新建" }}</el-button>
166
- </div>
159
+ <YsTableToolbar v-model:keyword="keyword">
160
+ <template #actions><el-button v-if="!readonly" type="primary" @click="onCreate">{{ createLabel || "新建" }}</el-button></template>
161
+ </YsTableToolbar>
167
162
 
168
163
  <el-table :data="paged" v-loading="loading" stripe border size="small" table-layout="fixed" row-key="_id">
169
164
  <el-table-column v-for="c in displayColumns" :key="c.key" :label="c.title" :width="columnWidth(c)" show-overflow-tooltip>
@@ -195,12 +190,4 @@ function onSubmit(payload: Record<string, unknown>) {
195
190
  </template>
196
191
 
197
192
  <style scoped>
198
- .ys-crud__toolbar {
199
- display: flex;
200
- align-items: center;
201
- margin-bottom: 12px;
202
- }
203
- .ys-crud__spacer {
204
- flex: 1;
205
- }
206
193
  </style>
@@ -0,0 +1,41 @@
1
+ <script setup lang="ts">
2
+ defineProps<{
3
+ keyword: string;
4
+ placeholder?: string;
5
+ }>();
6
+
7
+ const emit = defineEmits<{
8
+ "update:keyword": [value: string];
9
+ }>();
10
+ </script>
11
+
12
+ <template>
13
+ <div class="ys-table-toolbar">
14
+ <el-input
15
+ :model-value="keyword"
16
+ :placeholder="placeholder || '搜索'"
17
+ clearable
18
+ class="ys-table-toolbar__search"
19
+ @update:model-value="emit('update:keyword', String($event))"
20
+ />
21
+ <slot />
22
+ <div class="ys-table-toolbar__spacer" />
23
+ <slot name="actions" />
24
+ </div>
25
+ </template>
26
+
27
+ <style scoped>
28
+ .ys-table-toolbar {
29
+ display: flex;
30
+ align-items: center;
31
+ gap: 10px;
32
+ margin-bottom: 12px;
33
+ flex-wrap: wrap;
34
+ }
35
+ .ys-table-toolbar__search {
36
+ width: 200px;
37
+ }
38
+ .ys-table-toolbar__spacer {
39
+ flex: 1;
40
+ }
41
+ </style>
package/src/index.ts CHANGED
@@ -1,6 +1,7 @@
1
1
  /* @ysgroup/ui —— 平台组件库(基于 Element Plus 封装,令牌来自 @ysgroup/theme)。 */
2
2
 
3
3
  export { default as YsCrudTable } from "./components/YsCrudTable.vue";
4
+ export { default as YsTableToolbar } from "./components/YsTableToolbar.vue";
4
5
  export { default as YsTablePagination } from "./components/YsTablePagination.vue";
5
6
  export { default as YsRowActionMenu } from "./components/YsRowActionMenu.vue";
6
7
  export type { YsRowAction } from "./components/YsRowActionMenu.vue";