@ysgroup/ui 0.1.46 → 0.1.48

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.46",
3
+ "version": "0.1.48",
4
4
  "type": "module",
5
5
  "main": "src/index.ts",
6
6
  "types": "src/index.ts",
@@ -11,8 +11,8 @@
11
11
  },
12
12
  "peerDependencies": {
13
13
  "@ysgroup/contracts": ">=0.1.50",
14
- "@ysgroup/core": ">=0.1.27",
15
- "@ysgroup/theme": ">=0.3.0",
14
+ "@ysgroup/core": ">=0.1.28",
15
+ "@ysgroup/theme": ">=0.3.1",
16
16
  "element-plus": ">=2.9",
17
17
  "vue": ">=3.5"
18
18
  },
@@ -26,8 +26,8 @@
26
26
  },
27
27
  "devDependencies": {
28
28
  "@ysgroup/contracts": "^0.1.50",
29
- "@ysgroup/core": "^0.1.27",
30
- "@ysgroup/theme": "^0.3.0",
29
+ "@ysgroup/core": "^0.1.28",
30
+ "@ysgroup/theme": "^0.3.1",
31
31
  "docx-preview": "^0.4.1"
32
32
  }
33
33
  }
@@ -0,0 +1,68 @@
1
+ <!-- YsAmount —— 表格里的金额单元格(规范 8.5「数值列」):按大小自动换单位,列名只写「金额」「市值」,不写单位。
2
+ 不足 1 万显示原数(1,377.00),满 1 万「123.48万」,满 1 亿「3.56亿」;换算过的值鼠标移上立即显示完整金额(1,234,756.78)。
3
+ 所在列 align="right"。盈亏、涨跌加 signed(正数带 +)和 updown(涨红跌绿,跟随 --ys-color-up / -down)。
4
+ 搜索文本传 formatAmount(值) 和原值,显示的「123.48万」和原值都能搜到。
5
+
6
+ <el-table-column label="金额" :width="columnWidth('orders', 'amount')" align="right">
7
+ <template #default="{ row }"><YsAmount :value="row.amount" /></template>
8
+ </el-table-column> -->
9
+ <script setup lang="ts">
10
+ import { computed } from "vue";
11
+ import { splitAmount } from "@ysgroup/core";
12
+ import { vTip } from "../vTip";
13
+
14
+ const props = withDefaults(
15
+ defineProps<{
16
+ value: number | string | null | undefined;
17
+ /** 小数位,默认 2。 */
18
+ digits?: number;
19
+ /** 正数带「+」(盈亏、涨跌)。 */
20
+ signed?: boolean;
21
+ /** 涨红跌绿,0 不上色。 */
22
+ updown?: boolean;
23
+ /** 空值显示,默认「—」。 */
24
+ empty?: string;
25
+ }>(),
26
+ { digits: 2, signed: false, updown: false, empty: "—" },
27
+ );
28
+
29
+ const parts = computed(() => splitAmount(props.value, { digits: props.digits, signed: props.signed }));
30
+ const tone = computed(() => {
31
+ if (!props.updown || !parts.value?.sign) return "";
32
+ return parts.value.sign > 0 ? "is-up" : "is-down";
33
+ });
34
+ </script>
35
+
36
+ <template>
37
+ <span v-if="parts" v-tip="parts.unit ? parts.full : ''" class="ys-amount" :class="[tone, { 'has-unit': parts.unit }]"
38
+ >{{ parts.number }}<span v-if="parts.unit" class="ys-amount__unit">{{ parts.unit }}</span></span
39
+ >
40
+ <span v-else class="ys-amount is-empty">{{ empty }}</span>
41
+ </template>
42
+
43
+ <style scoped>
44
+ .ys-amount {
45
+ font-variant-numeric: tabular-nums;
46
+ white-space: nowrap;
47
+ }
48
+ /* 单位比数字退后一档:颜色淡一级、字号略小,数字仍是视觉重心 */
49
+ .ys-amount__unit {
50
+ margin-left: 1px;
51
+ color: var(--ys-color-text-3);
52
+ font-size: 0.92em;
53
+ }
54
+ .ys-amount.has-unit {
55
+ cursor: default;
56
+ }
57
+ .ys-amount.is-up,
58
+ .ys-amount.is-up .ys-amount__unit {
59
+ color: var(--ys-color-up);
60
+ }
61
+ .ys-amount.is-down,
62
+ .ys-amount.is-down .ys-amount__unit {
63
+ color: var(--ys-color-down);
64
+ }
65
+ .ys-amount.is-empty {
66
+ color: var(--ys-color-text-3);
67
+ }
68
+ </style>
@@ -147,11 +147,15 @@ function settingsCommand(command: string) {
147
147
  background: var(--ys-color-bg-hover);
148
148
  color: var(--ys-color-primary);
149
149
  }
150
- /* 顶栏图标按钮不画聚焦框:菜单关闭后焦点会回到按钮,框时有时无反而像出错。 */
151
- .ys-app-toolbar__button:focus,
152
- .ys-app-toolbar__button:focus-visible {
150
+ /* 顶栏图标按钮只在键盘操作时画聚焦框(:focus-visible):鼠标点开菜单再关闭,焦点回到按钮也不画,不会时有时无。 */
151
+ .ys-app-toolbar__button:focus {
153
152
  outline: none;
154
153
  }
154
+ .ys-app-toolbar__button:focus-visible {
155
+ outline: var(--ys-focus-outline);
156
+ outline-offset: -2px;
157
+ color: var(--ys-color-primary);
158
+ }
155
159
  @media (max-width: 600px) {
156
160
  .ys-app-toolbar {
157
161
  padding-left: 4px;
@@ -21,8 +21,9 @@ defineProps<{
21
21
  .ys-bool-mark {
22
22
  vertical-align: middle;
23
23
  }
24
+ /* 图形用的成功色:比文字成功色亮一档,一眼看得出「是」 */
24
25
  .ys-bool-mark.is-yes {
25
- color: var(--ys-color-success);
26
+ color: var(--ys-color-success-mark);
26
27
  }
27
28
  .ys-bool-mark.is-no {
28
29
  color: color-mix(in srgb, var(--ys-color-text-3) 35%, var(--ys-color-bg-elevated));
@@ -8,6 +8,8 @@ import { ysMatch, ysSearchText } from "@ysgroup/core";
8
8
  import { enumLabel } from "../tokens-runtime";
9
9
  import { columnWidth as lookupColumnWidth } from "../columnWidths";
10
10
  import YsBoolMark from "./YsBoolMark.vue";
11
+ import YsMultiCell from "./YsMultiCell.vue";
12
+ import { ysMultiText } from "../multiValue";
11
13
  import YsFormDialog from "./YsFormDialog.vue";
12
14
  import YsRowActionMenu from "./YsRowActionMenu.vue";
13
15
  import YsTableToolbar from "./YsTableToolbar.vue";
@@ -104,8 +106,15 @@ function switchLabels(field: FieldSpec): { on: string; off: string } {
104
106
  return { on: "是", off: "否" };
105
107
  }
106
108
 
109
+ function cellValue(row: Record<string, unknown>, f: FieldSpec): unknown {
110
+ return props.rowDisplay ? props.rowDisplay(row, f.key, row[f.key]) : row[f.key];
111
+ }
112
+
113
+ /** 本页有数组值的列:单元格用 YsMultiCell(一行「、」隔开,悬停每项一行),列上不再开表格自带的悬停提示。 */
114
+ const multiColumns = computed(() => new Set(displayColumns.value.filter((c) => paged.value.some((row) => Array.isArray(cellValue(row, c)))).map((c) => c.key)));
115
+
107
116
  function display(row: Record<string, unknown>, f: FieldSpec): string {
108
- const v = props.rowDisplay ? props.rowDisplay(row, f.key, row[f.key]) : row[f.key];
117
+ const v = cellValue(row, f);
109
118
  if (f.widget === "switch") {
110
119
  const labels = switchLabels(f);
111
120
  return v ? labels.on : labels.off;
@@ -113,7 +122,7 @@ function display(row: Record<string, unknown>, f: FieldSpec): string {
113
122
  if (f.widget === "enum" && f.enum && ENUM_META[f.enum as keyof typeof ENUM_META]) {
114
123
  return enumLabel(f.enum as keyof typeof ENUM_META, String(v ?? ""));
115
124
  }
116
- if (Array.isArray(v)) return v.join(", ");
125
+ if (Array.isArray(v)) return ysMultiText(v);
117
126
  return String(v ?? "");
118
127
  }
119
128
 
@@ -157,12 +166,14 @@ function onSubmit(payload: Record<string, unknown>) {
157
166
  :key="c.key"
158
167
  :label="c.title"
159
168
  :width="columnWidth(c)"
160
- :show-overflow-tooltip="c.widget !== 'switch'"
169
+ :show-overflow-tooltip="c.widget !== 'switch' && !multiColumns.has(c.key)"
161
170
  :align="c.widget === 'switch' ? 'center' : undefined"
162
171
  >
163
172
  <template #default="{ row }">
164
173
  <YsBoolMark v-if="c.widget === 'switch'" :value="row[c.key]" :on-label="switchLabels(c).on" :off-label="switchLabels(c).off" />
165
- <slot v-else name="cell" :row="row" :column="c" :text="display(row, c)">{{ display(row, c) }}</slot>
174
+ <slot v-else name="cell" :row="row" :column="c" :text="display(row, c)"
175
+ ><YsMultiCell v-if="Array.isArray(cellValue(row, c))" :items="cellValue(row, c)" /><template v-else>{{ display(row, c) }}</template></slot
176
+ >
166
177
  </template>
167
178
  </el-table-column>
168
179
  <el-table-column v-if="!readonly" label="操作栏" :width="actionWidth ?? 76" fixed="right" align="center">
@@ -49,7 +49,13 @@ const emit = defineEmits<{ retry: [] }>();
49
49
  }
50
50
  .ys-load-error__retry:hover,
51
51
  .ys-load-error__retry:focus-visible {
52
- outline: none;
53
52
  background: color-mix(in srgb, var(--ys-color-primary) 10%, transparent);
54
53
  }
54
+ .ys-load-error__retry:focus {
55
+ outline: none;
56
+ }
57
+ .ys-load-error__retry:focus-visible {
58
+ outline: var(--ys-focus-outline);
59
+ outline-offset: 1px;
60
+ }
55
61
  </style>
@@ -290,10 +290,14 @@ html[data-theme="dark"] .ys-login__card::after {
290
290
  background: var(--ys-color-bg-hover);
291
291
  color: var(--ys-color-primary);
292
292
  }
293
- .ys-login__theme-button:focus,
294
- .ys-login__theme-button:focus-visible {
293
+ .ys-login__theme-button:focus {
295
294
  outline: none;
296
295
  }
296
+ .ys-login__theme-button:focus-visible {
297
+ outline: var(--ys-focus-outline);
298
+ outline-offset: -2px;
299
+ color: var(--ys-color-primary);
300
+ }
297
301
  .ys-login__logo {
298
302
  width: 68px;
299
303
  height: 68px;
@@ -380,7 +380,7 @@ defineExpose({ toggle, seekBy, setVolume, setRate });
380
380
  outline: none;
381
381
  }
382
382
  .ys-media:focus-visible {
383
- box-shadow: inset 0 0 0 2px color-mix(in srgb, var(--ys-color-primary) 55%, transparent);
383
+ box-shadow: inset 0 0 0 2px var(--ys-color-primary);
384
384
  }
385
385
 
386
386
  /* ---------- 视频 ---------- */
@@ -510,7 +510,7 @@ defineExpose({ toggle, seekBy, setVolume, setRate });
510
510
  outline: none;
511
511
  }
512
512
  .ys-media__btn:focus-visible {
513
- outline: 2px solid color-mix(in srgb, var(--ys-color-primary) 70%, transparent);
513
+ outline: var(--ys-focus-outline);
514
514
  outline-offset: -2px;
515
515
  }
516
516
  .ys-media__btn svg {
@@ -645,7 +645,8 @@ defineExpose({ toggle, seekBy, setVolume, setRate });
645
645
  border: 0;
646
646
  border-radius: 50%;
647
647
  background: var(--ys-color-primary);
648
- color: #fff;
648
+ /* 实心主色上的图标跟明暗走:暗色主色提亮了,白色图标压不住 */
649
+ color: var(--ys-color-on-solid);
649
650
  cursor: pointer;
650
651
  box-shadow: 0 4px 12px -2px color-mix(in srgb, var(--ys-color-primary) 45%, transparent);
651
652
  transition:
@@ -663,8 +664,11 @@ defineExpose({ toggle, seekBy, setVolume, setRate });
663
664
  .ys-media__round:focus {
664
665
  outline: none;
665
666
  }
667
+ /* 按钮本身就是主色,轮廓隔一圈底色再画,才看得出来 */
666
668
  .ys-media__round:focus-visible {
667
- box-shadow: 0 0 0 3px color-mix(in srgb, var(--ys-color-primary) 35%, transparent);
669
+ box-shadow:
670
+ 0 0 0 2px var(--ys-color-bg-elevated),
671
+ 0 0 0 4px var(--ys-color-primary);
668
672
  }
669
673
  .ys-media__round svg {
670
674
  width: 20px;
@@ -0,0 +1,33 @@
1
+ <script setup lang="ts">
2
+ /**
3
+ * 多值单元格(规范 8.5「多值单元格」):表格里一行显示,各项用「、」隔开,放不下时省略号;
4
+ * 只在被截断时悬停立即显示提示,提示里每项一行,方便逐条阅读。
5
+ *
6
+ * <YsMultiCell :items="row.fund_names" />
7
+ * <YsMultiCell :items="row.ips" empty="—" />
8
+ *
9
+ * items 可以是数组(空值、空字符串自动去掉),也可以是单个值;YsCrudTable 遇到数组值时自动用它。
10
+ * 列上不要再开 show-overflow-tooltip(会和本组件的提示叠在一起)。
11
+ */
12
+ import { computed } from "vue";
13
+ import { vTip } from "../vTip";
14
+ import { ysMultiItems, YS_MULTI_SEPARATOR } from "../multiValue";
15
+
16
+ const props = withDefaults(defineProps<{ items: unknown; empty?: string }>(), { empty: "" });
17
+ const lines = computed(() => ysMultiItems(props.items));
18
+ const text = computed(() => lines.value.join(YS_MULTI_SEPARATOR) || props.empty);
19
+ const tip = computed(() => lines.value.join("\n"));
20
+ </script>
21
+
22
+ <template>
23
+ <span v-tip.overflow="tip" class="ys-multi-cell">{{ text }}</span>
24
+ </template>
25
+
26
+ <style scoped>
27
+ .ys-multi-cell {
28
+ display: block;
29
+ overflow: hidden;
30
+ text-overflow: ellipsis;
31
+ white-space: nowrap;
32
+ }
33
+ </style>
@@ -191,10 +191,14 @@ function toggleSidebar() {
191
191
  color: var(--ys-color-primary);
192
192
  background: var(--ys-color-bg-hover);
193
193
  }
194
- .ys-layout__toggle:focus,
195
- .ys-layout__toggle:focus-visible {
194
+ .ys-layout__toggle:focus {
196
195
  outline: none;
197
196
  }
197
+ .ys-layout__toggle:focus-visible {
198
+ outline: var(--ys-focus-outline);
199
+ outline-offset: -2px;
200
+ color: var(--ys-color-primary);
201
+ }
198
202
  .ys-layout__toggle-icon {
199
203
  width: 18px;
200
204
  height: 18px;
@@ -645,7 +645,7 @@ defineExpose({ goTo, setZoom });
645
645
  outline: none;
646
646
  }
647
647
  .ys-pdf__thumb:focus-visible {
648
- outline: 2px solid color-mix(in srgb, var(--ys-color-primary) 55%, transparent);
648
+ outline: var(--ys-focus-outline);
649
649
  }
650
650
  .ys-pdf__thumb-paper {
651
651
  position: relative;
@@ -1,7 +1,12 @@
1
1
  <!-- YsRowActionMenu —— 表格行「操作」菜单:齿轮按钮点开,按调用方给的顺序列出动作。
2
- divided 的动作上方画一条分隔线(不会被挪到最后);#extra 插槽的内容排在第一个 divided 动作之前,没有 divided 动作时排在最后。 -->
2
+ divided 的动作上方画一条分隔线(不会被挪到最后);#extra 插槽的内容排在第一个 divided 动作之前,没有 divided 动作时排在最后。
3
+ 分隔线只出现在两组之间:菜单只剩一项、唯一一项标了 divided、插槽内容为空时都不画,首尾和连续的分隔线由样式兜底隐藏。
4
+ actions 为空且没有 #extra 时不显示齿轮。
5
+ 键盘(WAI-ARIA 菜单按钮):齿轮上 Enter、空格、↓ 打开并聚焦第一项,↑ 打开并聚焦最后一项;菜单里 ↑↓ 循环移动、Home/End 到首尾,
6
+ Enter/空格执行;Esc 关闭并回到齿轮;Tab 关闭菜单,焦点照常移到齿轮的前后一个控件。选中动作、插槽调用 close 后焦点也回到齿轮,
7
+ 动作打开的弹窗关闭时 Element Plus 会把焦点还给齿轮,不会丢在页面末尾。 -->
3
8
  <script setup lang="ts">
4
- import { computed, ref } from "vue";
9
+ import { computed, nextTick, ref, useId, useSlots } from "vue";
5
10
  import { Setting } from "@element-plus/icons-vue";
6
11
 
7
12
  export interface YsRowAction {
@@ -25,7 +30,70 @@ const props = withDefaults(
25
30
  { ariaLabel: "", menuWidth: 150 },
26
31
  );
27
32
  const emit = defineEmits<{ action: [key: string] }>();
33
+ const slots = useSlots();
28
34
  const visible = ref(false);
35
+ const triggerButton = ref<HTMLButtonElement>();
36
+ const menu = ref<HTMLElement>();
37
+ const menuId = `ys-row-action-${useId()}`;
38
+
39
+ /** 菜单里能聚焦的项:自带动作和 #extra 插槽里的按钮,跳过禁用的。 */
40
+ function items(): HTMLElement[] {
41
+ return Array.from(menu.value?.querySelectorAll<HTMLElement>("button, [role='menuitem']") ?? []).filter(
42
+ (el) => !(el as HTMLButtonElement).disabled && el.getAttribute("aria-disabled") !== "true",
43
+ );
44
+ }
45
+
46
+ /** 打开后聚焦第一项或最后一项。浮层首次打开时内容可能晚一帧才挂上,等一帧再找。 */
47
+ async function focusItem(which: "first" | "last") {
48
+ await nextTick();
49
+ let list = items();
50
+ if (!list.length) {
51
+ await new Promise((resolve) => requestAnimationFrame(resolve));
52
+ list = items();
53
+ }
54
+ list[which === "first" ? 0 : list.length - 1]?.focus();
55
+ }
56
+
57
+ function onTriggerKeydown(event: KeyboardEvent) {
58
+ if (!["Enter", " ", "ArrowDown", "ArrowUp"].includes(event.key)) return;
59
+ // 自己处理:阻止按钮的原生点击,否则 Enter/空格会再触发一次开关
60
+ event.preventDefault();
61
+ visible.value = true;
62
+ void focusItem(event.key === "ArrowUp" ? "last" : "first");
63
+ }
64
+
65
+ /** 关闭菜单;焦点在菜单里时还给齿轮,避免落到 body 上(菜单挂在 body 末尾)。 */
66
+ function close() {
67
+ const focusInside = !!menu.value?.contains(document.activeElement);
68
+ visible.value = false;
69
+ if (focusInside) triggerButton.value?.focus();
70
+ }
71
+
72
+ function onMenuKeydown(event: KeyboardEvent) {
73
+ if (event.key === "Escape") {
74
+ event.preventDefault();
75
+ event.stopPropagation();
76
+ close();
77
+ return;
78
+ }
79
+ if (event.key === "Tab") {
80
+ // 不阻止默认行为:先把焦点放回齿轮,浏览器再从齿轮往前或往后移
81
+ close();
82
+ return;
83
+ }
84
+ if (!["ArrowDown", "ArrowUp", "Home", "End"].includes(event.key)) return;
85
+ const list = items();
86
+ if (!list.length) return;
87
+ event.preventDefault();
88
+ const index = list.indexOf(document.activeElement as HTMLElement);
89
+ const next =
90
+ event.key === "Home"
91
+ ? 0
92
+ : event.key === "End"
93
+ ? list.length - 1
94
+ : (index + (event.key === "ArrowDown" ? 1 : -1) + list.length) % list.length;
95
+ list[next]?.focus();
96
+ }
29
97
 
30
98
  /** #extra 插槽的位置:第一个 divided 动作之前;没有就在最后。 */
31
99
  const extraIndex = computed(() => {
@@ -33,19 +101,21 @@ const extraIndex = computed(() => {
33
101
  return index < 0 ? props.actions.length : index;
34
102
  });
35
103
 
36
- function close() {
37
- visible.value = false;
38
- }
104
+ /** 分隔线只画在两组之间:第一个动作上方不画;传了 #extra 且排在它前面时才画,插槽渲染为空时由下方 CSS 兜底隐藏。 */
105
+ const firstVisible = computed(() => (extraIndex.value === 0 && slots.extra ? -1 : 0));
39
106
 
40
107
  function select(action: YsRowAction) {
41
108
  if (action.disabled) return;
42
- visible.value = false;
109
+ // 先还焦点再通知:动作若打开弹窗,弹窗记下的「之前的焦点」就是齿轮
110
+ close();
43
111
  emit("action", action.key);
44
112
  }
45
113
  </script>
46
114
 
47
115
  <template>
116
+ <!-- 没有任何动作、也没有 #extra 内容时不显示齿轮(规范:没有可做的操作就不给入口) -->
48
117
  <el-popover
118
+ v-if="actions.length || $slots.extra"
49
119
  :visible="visible"
50
120
  placement="left-start"
51
121
  :fallback-placements="['left', 'left-end', 'top-end', 'bottom-end']"
@@ -53,26 +123,52 @@ function select(action: YsRowAction) {
53
123
  :offset="8"
54
124
  :hide-after="0"
55
125
  :teleported="true"
126
+ :trigger-keys="[]"
56
127
  trigger="click"
57
128
  popper-class="ys-action-popover"
58
129
  @update:visible="visible = $event"
59
130
  >
131
+ <!-- 包一层 span 给 EP 挂触发器:EP 会改写参考元素的 aria-*(按 tooltip 处理),按钮自己的菜单按钮语义才能保留 -->
60
132
  <template #reference
61
- ><button class="ys-row-action__trigger" type="button" :aria-label="ariaLabel || '操作'">
133
+ ><span class="ys-row-action__anchor"
134
+ ><button
135
+ ref="triggerButton"
136
+ class="ys-row-action__trigger"
137
+ type="button"
138
+ :aria-label="ariaLabel || '操作'"
139
+ aria-haspopup="menu"
140
+ :aria-expanded="visible"
141
+ :aria-controls="menuId"
142
+ @keydown="onTriggerKeydown"
143
+ >
62
144
  <el-icon :size="17"><Setting /></el-icon></button
63
- ></template>
64
- <nav class="ys-row-action__menu" :aria-label="ariaLabel || '操作菜单'">
145
+ ></span></template>
146
+ <div :id="menuId" ref="menu" class="ys-row-action__menu" role="menu" :aria-label="ariaLabel || '操作菜单'" @keydown="onMenuKeydown">
65
147
  <template v-for="(action, index) in actions" :key="action.key">
66
148
  <slot v-if="index === extraIndex" name="extra" :close="close" />
67
- <div v-if="action.divided && (index > 0 || $slots.extra)" class="ys-row-action__divider" />
68
- <button class="ys-row-action__item" :class="`is-${action.tone || 'neutral'}`" type="button" :disabled="action.disabled" @click="select(action)">{{ action.label }}</button>
149
+ <div v-if="action.divided && index > firstVisible" class="ys-row-action__divider" role="separator" />
150
+ <button
151
+ class="ys-row-action__item"
152
+ :class="`is-${action.tone || 'neutral'}`"
153
+ type="button"
154
+ role="menuitem"
155
+ tabindex="-1"
156
+ :disabled="action.disabled"
157
+ @click="select(action)"
158
+ >
159
+ {{ action.label }}
160
+ </button>
69
161
  </template>
70
162
  <slot v-if="extraIndex === actions.length" name="extra" :close="close" />
71
- </nav>
163
+ </div>
72
164
  </el-popover>
73
165
  </template>
74
166
 
75
167
  <style scoped>
168
+ .ys-row-action__anchor {
169
+ display: inline-flex;
170
+ vertical-align: middle;
171
+ }
76
172
  .ys-row-action__trigger {
77
173
  display: inline-grid;
78
174
  place-items: center;
@@ -88,11 +184,18 @@ function select(action: YsRowAction) {
88
184
  cursor: pointer;
89
185
  }
90
186
  .ys-row-action__trigger:hover,
91
- .ys-row-action__trigger:focus-visible {
92
- outline: none;
187
+ .ys-row-action__trigger[aria-expanded="true"] {
93
188
  color: var(--ys-color-primary);
94
189
  background: color-mix(in srgb, var(--ys-color-primary) 9%, transparent);
95
190
  }
191
+ .ys-row-action__trigger:focus {
192
+ outline: none;
193
+ }
194
+ .ys-row-action__trigger:focus-visible {
195
+ outline: var(--ys-focus-outline);
196
+ outline-offset: -2px;
197
+ color: var(--ys-color-primary);
198
+ }
96
199
  .ys-row-action__menu {
97
200
  display: grid;
98
201
  gap: 3px;
@@ -119,6 +222,11 @@ function select(action: YsRowAction) {
119
222
  background: color-mix(in srgb, var(--item-color) 10%, transparent);
120
223
  color: var(--item-color);
121
224
  }
225
+ /* 键盘移到的项除了底色再画轮廓:底色只有 10%,单靠它在暗色下不够明显 */
226
+ .ys-row-action__item:focus-visible {
227
+ outline: var(--ys-focus-outline);
228
+ outline-offset: -2px;
229
+ }
122
230
  .ys-row-action__item:disabled {
123
231
  opacity: 0.45;
124
232
  cursor: not-allowed;
@@ -162,6 +270,12 @@ function select(action: YsRowAction) {
162
270
  text-align: left;
163
271
  cursor: pointer;
164
272
  }
273
+ /* 兜底:分隔线不出现在菜单首尾、不连续出现。插槽渲染为空、调用方把唯一一项标成 divided 时都不会多一条线。 */
274
+ .ys-row-action__divider:first-child,
275
+ .ys-row-action__divider:last-child,
276
+ .ys-row-action__divider + .ys-row-action__divider {
277
+ display: none;
278
+ }
165
279
  .ys-row-action__divider {
166
280
  height: 1px;
167
281
  margin: 3px 4px;
@@ -446,7 +446,7 @@ onBeforeUnmount(() => {
446
446
  outline: none;
447
447
  }
448
448
  .ys-sheet__tab:focus-visible {
449
- outline: 2px solid color-mix(in srgb, var(--ys-color-primary) 55%, transparent);
449
+ outline: var(--ys-focus-outline);
450
450
  outline-offset: -2px;
451
451
  }
452
452
  .ys-sheet__tab.is-active {
package/src/index.ts CHANGED
@@ -25,6 +25,9 @@ export { default as YsServiceStatus } from "./components/YsServiceStatus.vue";
25
25
  export { default as YsSettingsCenterDialog } from "./components/YsSettingsCenterDialog.vue";
26
26
  export { default as YsPortalGrid } from "./components/YsPortalGrid.vue";
27
27
  export { default as YsRoleTag } from "./components/YsRoleTag.vue";
28
+ export { default as YsAmount } from "./components/YsAmount.vue";
29
+ export { default as YsMultiCell } from "./components/YsMultiCell.vue";
30
+ export { ysMultiItems, ysMultiText, YS_MULTI_SEPARATOR } from "./multiValue";
28
31
  export { default as YsBoolMark } from "./components/YsBoolMark.vue";
29
32
  export { default as YsSegmented } from "./components/YsSegmented.vue";
30
33
  export { default as YsCountBadge } from "./components/YsCountBadge.vue";
@@ -0,0 +1,15 @@
1
+ /** 多值单元格的文字规则(YsMultiCell、YsCrudTable 共用,业务仓拼搜索文本时也用它)。 */
2
+
3
+ /** 表格里各项之间的分隔符。 */
4
+ export const YS_MULTI_SEPARATOR = "、";
5
+
6
+ /** 把数组(或单个值)整理成要显示的各项:去掉空值和首尾空白,嵌套数组展开。 */
7
+ export function ysMultiItems(value: unknown): string[] {
8
+ const list = Array.isArray(value) ? value.flat(Infinity) : [value];
9
+ return list.map((item) => (item === null || item === undefined ? "" : String(item).trim())).filter(Boolean);
10
+ }
11
+
12
+ /** 单元格里显示的一行文字:各项用「、」隔开。 */
13
+ export function ysMultiText(value: unknown): string {
14
+ return ysMultiItems(value).join(YS_MULTI_SEPARATOR);
15
+ }
@@ -93,7 +93,7 @@
93
93
  }
94
94
 
95
95
  .ys-viewer__btn:focus-visible {
96
- outline: 2px solid color-mix(in srgb, var(--ys-color-primary) 55%, transparent);
96
+ outline: var(--ys-focus-outline);
97
97
  outline-offset: -2px;
98
98
  }
99
99