@ysgroup/ui 0.1.54 → 0.1.55

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.54",
3
+ "version": "0.1.55",
4
4
  "type": "module",
5
5
  "main": "src/index.ts",
6
6
  "types": "src/index.ts",
@@ -11,7 +11,7 @@
11
11
  },
12
12
  "peerDependencies": {
13
13
  "@ysgroup/contracts": ">=0.1.50",
14
- "@ysgroup/core": ">=0.1.29",
14
+ "@ysgroup/core": ">=0.1.30",
15
15
  "@ysgroup/theme": ">=0.3.3",
16
16
  "element-plus": ">=2.9",
17
17
  "vue": ">=3.5"
@@ -26,7 +26,7 @@
26
26
  },
27
27
  "devDependencies": {
28
28
  "@ysgroup/contracts": "^0.1.51",
29
- "@ysgroup/core": "^0.1.29",
29
+ "@ysgroup/core": "^0.1.30",
30
30
  "@ysgroup/theme": "^0.3.3",
31
31
  "docx-preview": "^0.4.1"
32
32
  }
@@ -0,0 +1,63 @@
1
+ <script setup lang="ts">
2
+ /**
3
+ * 表格上方的状态勾选框:「显示已停用」「显示已归档」「显示软删除」,放在 YsTableToolbar 的下拉框后面。
4
+ * - 列表默认只显示启用的记录;勾一个就只看这一类,三者互斥,取消勾选回到启用(v-model 是当前查看的状态)。
5
+ * - 传 counts 时每个勾选框后面带数量,不勾也知道有几条被隐藏;为 0 时数字变淡。
6
+ * - options 只列表里有的字段:没有启用字段的表去掉 disabled,不能归档的去掉 archived。
7
+ * 判断、计数和提示文字见 @ysgroup/core 的 ysRecordStatus、ysStatusCounts、ysStatusRevealHint、ysStatusEmptyText。
8
+ */
9
+ import {
10
+ YS_STATUS_LABELS,
11
+ YS_STATUS_OPTIONS,
12
+ ysStatusToggle,
13
+ type YsRecordStatus,
14
+ type YsStatusCounts,
15
+ type YsStatusOption,
16
+ } from "@ysgroup/core";
17
+
18
+ withDefaults(
19
+ defineProps<{
20
+ modelValue: YsRecordStatus;
21
+ counts?: YsStatusCounts | null;
22
+ options?: readonly YsStatusOption[];
23
+ }>(),
24
+ { counts: null, options: () => YS_STATUS_OPTIONS },
25
+ );
26
+
27
+ const emit = defineEmits<{ "update:modelValue": [value: YsRecordStatus] }>();
28
+
29
+ function order(options: readonly YsStatusOption[]): YsStatusOption[] {
30
+ return YS_STATUS_OPTIONS.filter((option) => options.includes(option));
31
+ }
32
+ </script>
33
+
34
+ <template>
35
+ <el-checkbox
36
+ v-for="option in order(options)"
37
+ :key="option"
38
+ class="ys-status-filter"
39
+ :model-value="modelValue === option"
40
+ @update:model-value="
41
+ emit('update:modelValue', ysStatusToggle(option, Boolean($event)))
42
+ "
43
+ >
44
+ {{ YS_STATUS_LABELS[option]
45
+ }}<span
46
+ v-if="counts"
47
+ class="ys-status-filter__count"
48
+ :class="{ 'is-zero': !counts[option] }"
49
+ >{{ counts[option] }}</span
50
+ >
51
+ </el-checkbox>
52
+ </template>
53
+
54
+ <style scoped>
55
+ .ys-status-filter__count {
56
+ margin-left: 4px;
57
+ color: var(--ys-color-text-2);
58
+ font-variant-numeric: tabular-nums;
59
+ }
60
+ .ys-status-filter__count.is-zero {
61
+ color: var(--ys-color-text-3);
62
+ }
63
+ </style>
package/src/index.ts CHANGED
@@ -2,6 +2,7 @@
2
2
 
3
3
  export { default as YsCrudTable } from "./components/YsCrudTable.vue";
4
4
  export { default as YsTableToolbar } from "./components/YsTableToolbar.vue";
5
+ export { default as YsStatusFilter } from "./components/YsStatusFilter.vue";
5
6
  export { default as YsTablePagination } from "./components/YsTablePagination.vue";
6
7
  export { default as YsRowActionMenu } from "./components/YsRowActionMenu.vue";
7
8
  export type { YsRowAction } from "./components/YsRowActionMenu.vue";