20260811165111
This commit is contained in:
1 parent
5adbf59425
commit
ce78653207
34 files changed
+3793
-366
No files matched your search
@@ -21,6 +21,15 @@ import { cn } from "@/lib/utils";
|
||||
import { createEditableCell } from "./createEditableCellRenderer";
|
||||
|
||||
const stop = (event) => event.stopPropagation();
|
||||
const actionButtonClass = cn(buttonVariants({ variant: "ghost", size: "xs" }), "fms-action-btn");
|
||||
const dangerActionButtonClass = cn(
|
||||
actionButtonClass,
|
||||
"text-destructive hover:bg-destructive/10 hover:text-destructive",
|
||||
);
|
||||
const moreActionButtonClass = cn(
|
||||
buttonVariants({ variant: "ghost", size: "xs" }),
|
||||
"fms-action-btn fms-action-more",
|
||||
);
|
||||
|
||||
function resolveActionState(state, row) {
|
||||
return typeof state === "function" ? Boolean(state(row)) : Boolean(state);
|
||||
@@ -30,7 +39,7 @@ function isActionVisible(action, row) {
|
||||
return action.visible === undefined || resolveActionState(action.visible, row);
|
||||
}
|
||||
|
||||
function actionButton(action, row, triggerAction, className = "fms-action-btn") {
|
||||
function actionButton(action, row, triggerAction) {
|
||||
const disabled = resolveActionState(action.disabled, row);
|
||||
const danger = action.danger || action.type === "danger" || action.type === "delete";
|
||||
const content = [];
|
||||
@@ -40,11 +49,7 @@ function actionButton(action, row, triggerAction, className = "fms-action-btn")
|
||||
"button",
|
||||
{
|
||||
type: "button",
|
||||
class: cn(
|
||||
buttonVariants({ variant: "ghost", size: "xs" }),
|
||||
danger && "text-destructive hover:bg-destructive/10 hover:text-destructive",
|
||||
className,
|
||||
),
|
||||
class: danger ? dangerActionButtonClass : actionButtonClass,
|
||||
title: action.title || action.label,
|
||||
disabled,
|
||||
onMousedown: stop,
|
||||
@@ -82,7 +87,10 @@ function createConfirmDialog(state, close, confirm) {
|
||||
h(
|
||||
AlertDialogAction,
|
||||
{
|
||||
class: config.okType === "danger" ? buttonVariants({ variant: "destructive" }) : undefined,
|
||||
class:
|
||||
config.okType === "danger"
|
||||
? buttonVariants({ variant: "destructive" })
|
||||
: undefined,
|
||||
onClick: () => {
|
||||
const pending = state.value;
|
||||
close();
|
||||
@@ -133,11 +141,10 @@ function createActionsCell(actions) {
|
||||
"button",
|
||||
{
|
||||
type: "button",
|
||||
class: cn(
|
||||
buttonVariants({ variant: "ghost", size: "xs" }),
|
||||
"fms-action-btn fms-action-more",
|
||||
class: [
|
||||
moreActionButtonClass,
|
||||
openRow.value === row && "bg-accent text-accent-foreground",
|
||||
),
|
||||
],
|
||||
title: moreAction.title || "更多操作",
|
||||
"aria-label": moreAction.title || "更多操作",
|
||||
onMousedown: stop,
|
||||
@@ -212,16 +219,6 @@ export function resolveCustomCell(col, editingContext) {
|
||||
if (customCell) return { ...col, customCell };
|
||||
}
|
||||
|
||||
// 纯展示列:保持文本可选中,同时通过表格选区激活行编辑。
|
||||
if (col.dataIndex) {
|
||||
return {
|
||||
...col,
|
||||
customCell: ({ row }) => {
|
||||
const value = row[col.dataIndex];
|
||||
const content = value ?? "";
|
||||
return h("span", { class: "fms-cell-display", title: String(content) }, content);
|
||||
},
|
||||
};
|
||||
}
|
||||
// 纯展示列使用 StkTable 原生渲染,避免虚拟滚动时重复创建函数组件。
|
||||
return col;
|
||||
}
|
||||
Reference in new issue
Block a user